diff --git a/dist/dweb-transports-bundle.js b/dist/dweb-transports-bundle.js index cb36a41..50e0156 100644 --- a/dist/dweb-transports-bundle.js +++ b/dist/dweb-transports-bundle.js @@ -1,18 +1,18 @@ -!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}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=631)}([function(e,t,r){"use strict";(function(e){ +!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}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=622)}([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(637),i=r(335),o=r(333);function s(){return u.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 d(e,t){if(u.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 U(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(e).length;default:if(n)return U(e).length;t=(""+t).toLowerCase(),n=!0}}function y(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=u.from(t,n)),u.isBuffer(t))return 0===t.length?-1:m(e,t,r,n,i);if("number"==typeof t)return t&=255,u.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,u=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,u/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,h=0;hi&&(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 E(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function A(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:c>223?3:c>191?2:1;if(i+l<=r)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&c)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=x)return String.fromCharCode.apply(String,e);for(var r="",n=0;nthis.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 B(this,t,r);case"utf8":case"utf-8":return A(this,t,r);case"ascii":return I(this,t,r);case"latin1":case"binary":return T(this,t,r);case"base64":return E(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}.apply(this,arguments)},u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),""},u.prototype.compare=function(e,t,r,n,i){if(!u.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(t>>>=0,r>>>=0,n>>>=0,i>>>=0,this===e)return 0;for(var o=i-n,s=r-t,a=Math.min(o,s),c=this.slice(n,i),f=e.slice(t,r),l=0;li)&&(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 b(this,e,t,r);case"utf8":case"utf-8":return v(this,e,t,r);case"ascii":return _(this,e,t,r);case"latin1":case"binary":return w(this,e,t,r);case"base64":return S(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}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var x=4096;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 O(e,t,r,n,i,o){if(!u.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 R(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 N(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 K(e,t,r,n,o){return o||L(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function j(e,t,r,n,o){return o||L(e,0,r,8),i.write(e,t,r,n,52,8),r+8}u.prototype.slice=function(e,t){var r,n=this.length;if(e=~~e,t=void 0===t?n:~~t,e<0?(e+=n)<0&&(e=0):e>n&&(e=n),t<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},u.prototype.readUInt8=function(e,t){return t||P(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return t||P(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return t||P(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return t||P(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return t||P(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||P(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},u.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||P(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},u.prototype.readInt8=function(e,t){return t||P(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){t||P(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(e,t){t||P(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(e,t){return t||P(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return t||P(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return t||P(e,4,this.length),i.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||P(e,4,this.length),i.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||P(e,8,this.length),i.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||P(e,8,this.length),i.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,r,n){e=+e,t|=0,r|=0,n||O(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},u.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):R(this,e,t,!0),t+2},u.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):R(this,e,t,!1),t+2},u.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):N(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):N(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);O(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},u.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);O(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},u.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):R(this,e,t,!0),t+2},u.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):R(this,e,t,!1),t+2},u.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):N(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):N(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,r){return K(this,e,t,!0,r)},u.prototype.writeFloatBE=function(e,t,r){return K(this,e,t,!1,r)},u.prototype.writeDoubleLE=function(e,t,r){return j(this,e,t,!0,r)},u.prototype.writeDoubleBE=function(e,t,r){return j(this,e,t,!1,r)},u.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||!u.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 F(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(M,"")).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,r){(function(n){function i(){var e;try{e=t.storage.debug}catch(e){}return!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG),e}(t=e.exports=r(691)).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var r=this.useColors;if(e[0]=(r?"%c":"")+this.namespace+(r?" %c":" ")+e[0]+(r?"%c ":" ")+"+"+t.humanize(this.diff),r){var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var i=0,o=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&"%c"===e&&(o=++i)}),e.splice(o,0,n)}},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=i,t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(i())}).call(this,r(7))},function(e,t,r){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),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";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e){return e&&e.__esModule?e:{default:e}}(r(213));t.default=n.default,e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){if(t=(0,o.default)(t||i.default),!(0,n.default)(e))return t(new Error("First argument to waterfall must be an array of functions"));if(!e.length)return t();var r=0;function c(t){var n=(0,u.default)(e[r++]);t.push((0,a.default)(f)),n.apply(null,t)}function f(n){if(n||r===e.length)return t.apply(null,arguments);c((0,s.default)(arguments,1))}c([])};var n=c(r(88)),i=c(r(54)),o=c(r(156)),s=c(r(102)),a=c(r(103)),u=c(r(34));function c(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default},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){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(r=window)}e.exports=r},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 u,c=[],f=!1,l=-1;function h(){f&&u&&(f=!1,u.length?c=u.concat(c):l=-1,c.length&&p())}function p(){if(!f){var e=a(h);f=!0;for(var t=c.length;t;){for(u=c,c=[];++l1)for(var r=1;r0&&this._events[e].length>s&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){if(!n(t))throw TypeError("listener must be a function");var r=!1;function i(){this.removeListener(e,i),r||(r=!0,t.apply(this,arguments))}return i.listener=t,this.on(e,i),this},r.prototype.removeListener=function(e,t){var r,o,s,a;if(!n(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(s=(r=this._events[e]).length,o=-1,r===t||n(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(i(r)){for(a=s;a-- >0;)if(r[a]===t||r[a].listener&&r[a].listener===t){o=a;break}if(o<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(o,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n(r=this._events[e]))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){return this._events&&this._events[e]?n(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(n(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t,r){"use strict";(function(e){const n=r(14),i=r(341);t.names=i.names,t.codes=i.codes,t.defaultLengths=i.defaultLengths;const o=r(20);function s(e){t.decode(e)}t.toHexString=function(t){if(!e.isBuffer(t))throw new Error("must be passed a buffer");return t.toString("hex")},t.fromHexString=function(t){return e.from(t,"hex")},t.toB58String=function(t){if(!e.isBuffer(t))throw new Error("must be passed a buffer");return n.encode(t)},t.fromB58String=function(t){let r=t;return e.isBuffer(t)&&(r=t.toString()),e.from(n.decode(r))},t.decode=function(r){if(!e.isBuffer(r))throw new Error("multihash must be a Buffer");if(r.length<3)throw new Error("multihash too short. must be > 3 bytes.");let n=o.decode(r);if(!t.isValidCode(n))throw new Error(`multihash unknown function code: 0x${n.toString(16)}`);r=r.slice(o.decode.bytes);let s=o.decode(r);if(s<1)throw new Error(`multihash invalid length: 0x${s.toString(16)}`);if((r=r.slice(o.decode.bytes)).length!==s)throw new Error(`multihash length inconsistent: 0x${r.toString("hex")}`);return{code:n,name:i.codes[n],length:s,digest:r}},t.encode=function(r,n,i){if(!r||!n)throw new Error("multihash encode requires at least two args: digest, code");const s=t.coerceCode(n);if(!e.isBuffer(r))throw new Error("digest should be a Buffer");if(null==i&&(i=r.length),i&&r.length!==i)throw new Error("digest length should be equal to specified length.");return e.concat([e.from(o.encode(s)),e.from(o.encode(i)),r])},t.coerceCode=function(e){let r=e;if("string"==typeof e){if(!i.names[e])throw new Error(`Unrecognized hash function named: ${e}`);r=i.names[e]}if("number"!=typeof r)throw new Error(`Hash function code should be a number. Got: ${r}`);if(!i.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)||!!i.codes[e]},t.validate=s,t.prefix=function(e){return s(e),e.slice(0,2)}}).call(this,r(0).Buffer)},function(e,t){e.exports={options:{usePureJavaScript:!1}}},function(e,t,r){var n=r(340);e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},function(e,t,r){"use strict";const n=t;n.bignum=r(55),n.define=r(931).define,n.base=r(135),n.constants=r(466),n.decoders=r(936),n.encoders=r(938)},function(e,t,r){e.exports=r(13),r(98),r(918),r(76),r(257),r(459),r(182),r(920),r(133),r(921),r(461),r(922),r(458),r(259),r(112),r(454),r(456),r(923),r(448),r(455),r(452),r(261),r(69),r(453),r(924),r(925),r(447),r(19)},function(e,t,r){"use strict";(function(t){ +var n=r(628),i=r(333),o=r(331);function s(){return u.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 d(e,t){if(u.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 U(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(e).length;default:if(n)return U(e).length;t=(""+t).toLowerCase(),n=!0}}function y(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=u.from(t,n)),u.isBuffer(t))return 0===t.length?-1:m(e,t,r,n,i);if("number"==typeof t)return t&=255,u.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,u=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,u/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,h=0;hi&&(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 E(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function A(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:c>223?3:c>191?2:1;if(i+l<=r)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&c)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=x)return String.fromCharCode.apply(String,e);for(var r="",n=0;nthis.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 B(this,t,r);case"utf8":case"utf-8":return A(this,t,r);case"ascii":return I(this,t,r);case"latin1":case"binary":return T(this,t,r);case"base64":return E(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}.apply(this,arguments)},u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),""},u.prototype.compare=function(e,t,r,n,i){if(!u.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(t>>>=0,r>>>=0,n>>>=0,i>>>=0,this===e)return 0;for(var o=i-n,s=r-t,a=Math.min(o,s),c=this.slice(n,i),f=e.slice(t,r),l=0;li)&&(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 b(this,e,t,r);case"utf8":case"utf-8":return v(this,e,t,r);case"ascii":return _(this,e,t,r);case"latin1":case"binary":return w(this,e,t,r);case"base64":return S(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}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var x=4096;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 O(e,t,r,n,i,o){if(!u.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 R(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 N(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 j(e,t,r,n,o){return o||L(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function M(e,t,r,n,o){return o||L(e,0,r,8),i.write(e,t,r,n,52,8),r+8}u.prototype.slice=function(e,t){var r,n=this.length;if(e=~~e,t=void 0===t?n:~~t,e<0?(e+=n)<0&&(e=0):e>n&&(e=n),t<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},u.prototype.readUInt8=function(e,t){return t||P(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return t||P(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return t||P(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return t||P(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return t||P(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||P(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},u.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||P(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},u.prototype.readInt8=function(e,t){return t||P(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){t||P(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(e,t){t||P(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(e,t){return t||P(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return t||P(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return t||P(e,4,this.length),i.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||P(e,4,this.length),i.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||P(e,8,this.length),i.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||P(e,8,this.length),i.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,r,n){e=+e,t|=0,r|=0,n||O(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},u.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):R(this,e,t,!0),t+2},u.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):R(this,e,t,!1),t+2},u.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):N(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):N(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);O(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},u.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);O(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},u.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):R(this,e,t,!0),t+2},u.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):R(this,e,t,!1),t+2},u.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):N(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):N(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,r){return j(this,e,t,!0,r)},u.prototype.writeFloatBE=function(e,t,r){return j(this,e,t,!1,r)},u.prototype.writeDoubleLE=function(e,t,r){return M(this,e,t,!0,r)},u.prototype.writeDoubleBE=function(e,t,r){return M(this,e,t,!1,r)},u.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||!u.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 F(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(K,"")).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(7))},function(e,t,r){(function(n){function i(){var e;try{e=t.storage.debug}catch(e){}return!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG),e}(t=e.exports=r(682)).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var r=this.useColors;if(e[0]=(r?"%c":"")+this.namespace+(r?" %c":" ")+e[0]+(r?"%c ":" ")+"+"+t.humanize(this.diff),r){var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var i=0,o=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&"%c"===e&&(o=++i)}),e.splice(o,0,n)}},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=i,t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(i())}).call(this,r(6))},function(e,t,r){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),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";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e){return e&&e.__esModule?e:{default:e}}(r(214));t.default=n.default,e.exports=t.default},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";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){if(t=(0,o.default)(t||i.default),!(0,n.default)(e))return t(new Error("First argument to waterfall must be an array of functions"));if(!e.length)return t();var r=0;function c(t){var n=(0,u.default)(e[r++]);t.push((0,a.default)(f)),n.apply(null,t)}function f(n){if(n||r===e.length)return t.apply(null,arguments);c((0,s.default)(arguments,1))}c([])};var n=c(r(88)),i=c(r(54)),o=c(r(156)),s=c(r(103)),a=c(r(104)),u=c(r(34));function c(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default},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 u,c=[],f=!1,l=-1;function h(){f&&u&&(f=!1,u.length?c=u.concat(c):l=-1,c.length&&p())}function p(){if(!f){var e=a(h);f=!0;for(var t=c.length;t;){for(u=c,c=[];++l1)for(var r=1;r0&&this._events[e].length>s&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){if(!n(t))throw TypeError("listener must be a function");var r=!1;function i(){this.removeListener(e,i),r||(r=!0,t.apply(this,arguments))}return i.listener=t,this.on(e,i),this},r.prototype.removeListener=function(e,t){var r,o,s,a;if(!n(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(s=(r=this._events[e]).length,o=-1,r===t||n(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(i(r)){for(a=s;a-- >0;)if(r[a]===t||r[a].listener&&r[a].listener===t){o=a;break}if(o<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(o,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n(r=this._events[e]))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){return this._events&&this._events[e]?n(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(n(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t,r){"use strict";(function(t){var n=r(745),i=r(749);e.exports=function(e,r){if(r||(r={}),!e)throw new Error("Pass in a .proto string or a protobuf-schema parsed object");var o="object"!=typeof e||t.isBuffer(e)?n.parse(e):e,s=function(){var e=this;i(o,r.encodings||{}).forEach(function(t){e[t.name]=function(e){if(!e)return null;var t={};return Object.keys(e).forEach(function(r){t[r]=e[r].value}),t}(t.values)||t})};return s.prototype.toString=function(){return n.stringify(o)},s.prototype.toJSON=function(){return o},new s}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(14),i=r(339);t.names=i.names,t.codes=i.codes,t.defaultLengths=i.defaultLengths;const o=r(20);function s(e){t.decode(e)}t.toHexString=function(t){if(!e.isBuffer(t))throw new Error("must be passed a buffer");return t.toString("hex")},t.fromHexString=function(t){return e.from(t,"hex")},t.toB58String=function(t){if(!e.isBuffer(t))throw new Error("must be passed a buffer");return n.encode(t)},t.fromB58String=function(t){let r=t;return e.isBuffer(t)&&(r=t.toString()),e.from(n.decode(r))},t.decode=function(r){if(!e.isBuffer(r))throw new Error("multihash must be a Buffer");if(r.length<3)throw new Error("multihash too short. must be > 3 bytes.");let n=o.decode(r);if(!t.isValidCode(n))throw new Error(`multihash unknown function code: 0x${n.toString(16)}`);r=r.slice(o.decode.bytes);let s=o.decode(r);if(s<1)throw new Error(`multihash invalid length: 0x${s.toString(16)}`);if((r=r.slice(o.decode.bytes)).length!==s)throw new Error(`multihash length inconsistent: 0x${r.toString("hex")}`);return{code:n,name:i.codes[n],length:s,digest:r}},t.encode=function(r,n,i){if(!r||!n)throw new Error("multihash encode requires at least two args: digest, code");const s=t.coerceCode(n);if(!e.isBuffer(r))throw new Error("digest should be a Buffer");if(null==i&&(i=r.length),i&&r.length!==i)throw new Error("digest length should be equal to specified length.");return e.concat([e.from(o.encode(s)),e.from(o.encode(i)),r])},t.coerceCode=function(e){let r=e;if("string"==typeof e){if(!i.names[e])throw new Error(`Unrecognized hash function named: ${e}`);r=i.names[e]}if("number"!=typeof r)throw new Error(`Hash function code should be a number. Got: ${r}`);if(!i.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)||!!i.codes[e]},t.validate=s,t.prefix=function(e){return s(e),e.slice(0,2)}}).call(this,r(0).Buffer)},function(e,t){e.exports={options:{usePureJavaScript:!1}}},function(e,t,r){var n=r(338);e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},function(e,t,r){"use strict";const n=t;n.bignum=r(55),n.define=r(922).define,n.base=r(135),n.constants=r(463),n.decoders=r(927),n.encoders=r(929)},function(e,t,r){"use strict";(function(t){ /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */ -function n(e,t){if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i=0;c--)if(f[c]!==l[c])return!1;for(c=f.length-1;c>=0;c--)if(!b(e[u=f[c]],t[u],r,n))return!1;return!0}function w(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 s="string"==typeof n,a=!e&&o.isError(i),u=!e&&i&&!r;if((a&&s&&w(i,r)||u)&&g(i,r,"Got unwanted exception"+n),e&&i&&r&&!w(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 d(y(e.actual),128)+" "+e.operator+" "+d(y(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}}},o.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){b(e,t,!1)||g(e,t,r,"deepEqual",l.deepEqual)},l.deepStrictEqual=function(e,t,r){b(e,t,!0)||g(e,t,r,"deepStrictEqual",l.deepStrictEqual)},l.notDeepEqual=function(e,t,r){b(e,t,!1)&&g(e,t,r,"notDeepEqual",l.notDeepEqual)},l.notDeepStrictEqual=function e(t,r,n){b(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};var k=Object.keys||function(e){var t=[];for(var r in e)s.call(e,r)&&t.push(r);return t}}).call(this,r(6))},function(e,t,r){(function(e,n){var i; +function n(e,t){if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i=0;c--)if(f[c]!==l[c])return!1;for(c=f.length-1;c>=0;c--)if(!b(e[u=f[c]],t[u],r,n))return!1;return!0}function w(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 s="string"==typeof n,a=!e&&o.isError(i),u=!e&&i&&!r;if((a&&s&&w(i,r)||u)&&g(i,r,"Got unwanted exception"+n),e&&i&&r&&!w(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 d(y(e.actual),128)+" "+e.operator+" "+d(y(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}}},o.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){b(e,t,!1)||g(e,t,r,"deepEqual",l.deepEqual)},l.deepStrictEqual=function(e,t,r){b(e,t,!0)||g(e,t,r,"deepStrictEqual",l.deepStrictEqual)},l.notDeepEqual=function(e,t,r){b(e,t,!1)&&g(e,t,r,"notDeepEqual",l.notDeepEqual)},l.notDeepStrictEqual=function e(t,r,n){b(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};var k=Object.keys||function(e){var t=[];for(var r in e)s.call(e,r)&&t.push(r);return t}}).call(this,r(7))},function(e,t,r){e.exports=r(13),r(99),r(909),r(76),r(258),r(456),r(182),r(911),r(133),r(912),r(458),r(913),r(455),r(260),r(112),r(451),r(453),r(914),r(445),r(452),r(449),r(262),r(67),r(450),r(915),r(916),r(444),r(19)},function(e,t,r){(function(e,n){var i; /** * @license * lodash 3.10.1 (Custom Build) @@ -31,7 +31,7 @@ function n(e,t){if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors * Available under MIT license */ -(function(){var o,s,a,u="3.10.1",c=1,f=2,l=4,h=8,p=16,d=32,y=64,g=128,m=256,b=30,v="...",_=150,w=16,S=200,k=1,E=2,A="Expected a function",x="__lodash_placeholder__",I="[object Arguments]",T="[object Array]",B="[object Boolean]",C="[object Date]",P="[object Error]",O="[object Function]",R="[object Map]",N="[object Number]",L="[object Object]",K="[object RegExp]",j="[object Set]",M="[object String]",D="[object WeakMap]",U="[object ArrayBuffer]",F="[object Float32Array]",q="[object Float64Array]",H="[object Int8Array]",z="[object Int16Array]",V="[object Int32Array]",G="[object Uint8Array]",W="[object Uint8ClampedArray]",$="[object Uint16Array]",Y="[object Uint32Array]",J=/\b__p \+= '';/g,X=/\b(__p \+=) '' \+/g,Z=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Q=/&(?:amp|lt|gt|quot|#39|#96);/g,ee=/[&<>"'`]/g,te=RegExp(Q.source),re=RegExp(ee.source),ne=/<%-([\s\S]+?)%>/g,ie=/<%([\s\S]+?)%>/g,oe=/<%=([\s\S]+?)%>/g,se=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,ae=/^\w*$/,ue=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g,ce=/^[:!,]|[\\^$.*+?()[\]{}|\/]|(^[0-9a-fA-Fnrtuvx])|([\n\r\u2028\u2029])/g,fe=RegExp(ce.source),le=/[\u0300-\u036f\ufe20-\ufe23]/g,he=/\\(\\)?/g,pe=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,de=/\w*$/,ye=/^0[xX]/,ge=/^\[object .+?Constructor\]$/,me=/^\d+$/,be=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,ve=/($^)/,_e=/['\n\r\u2028\u2029\\]/g,we=(s="[A-Z\\xc0-\\xd6\\xd8-\\xde]",a="[a-z\\xdf-\\xf6\\xf8-\\xff]+",RegExp(s+"+(?="+s+a+")|"+s+"?"+a+"|"+s+"+|[0-9]+","g")),Se=["Array","ArrayBuffer","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Math","Number","Object","RegExp","Set","String","_","clearTimeout","isFinite","parseFloat","parseInt","setTimeout","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap"],ke=-1,Ee={};Ee[F]=Ee[q]=Ee[H]=Ee[z]=Ee[V]=Ee[G]=Ee[W]=Ee[$]=Ee[Y]=!0,Ee[I]=Ee[T]=Ee[U]=Ee[B]=Ee[C]=Ee[P]=Ee[O]=Ee[R]=Ee[N]=Ee[L]=Ee[K]=Ee[j]=Ee[M]=Ee[D]=!1;var Ae={};Ae[I]=Ae[T]=Ae[U]=Ae[B]=Ae[C]=Ae[F]=Ae[q]=Ae[H]=Ae[z]=Ae[V]=Ae[N]=Ae[L]=Ae[K]=Ae[M]=Ae[G]=Ae[W]=Ae[$]=Ae[Y]=!0,Ae[P]=Ae[O]=Ae[R]=Ae[j]=Ae[D]=!1;var xe={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss"},Ie={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Te={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Be={function:!0,object:!0},Ce={0:"x30",1:"x31",2:"x32",3:"x33",4:"x34",5:"x35",6:"x36",7:"x37",8:"x38",9:"x39",A:"x41",B:"x42",C:"x43",D:"x44",E:"x45",F:"x46",a:"x61",b:"x62",c:"x63",d:"x64",e:"x65",f:"x66",n:"x6e",r:"x72",t:"x74",u:"x75",v:"x76",x:"x78"},Pe={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Oe=Be[typeof t]&&t&&!t.nodeType&&t,Re=Be[typeof e]&&e&&!e.nodeType&&e,Ne=Oe&&Re&&"object"==typeof n&&n&&n.Object&&n,Le=Be[typeof self]&&self&&self.Object&&self,Ke=Be[typeof window]&&window&&window.Object&&window,je=(Re&&Re.exports,Ne||Ke!==(this&&this.window)&&Ke||Le||this);function Me(e,t){if(e!==t){var r=null===e,n=e===o,i=e==e,s=null===t,a=t===o,u=t==t;if(e>t&&!s||!i||r&&!a&&u||n&&u)return 1;if(e-1;);return r}function ze(e,t){for(var r=e.length;r--&&t.indexOf(e.charAt(r))>-1;);return r}function Ve(e,t){return Me(e.criteria,t.criteria)||e.index-t.index}function Ge(e){return xe[e]}function We(e){return Ie[e]}function $e(e,t,r){return t?e=Ce[e]:r&&(e=Pe[e]),"\\"+e}function Ye(e){return"\\"+Pe[e]}function Je(e,t,r){for(var n=e.length,i=t+(r?0:-1);r?i--:++i=9&&e<=13||32==e||160==e||5760==e||6158==e||e>=8192&&(e<=8202||8232==e||8233==e||8239==e||8287==e||12288==e||65279==e)}function Qe(e,t){for(var r=-1,n=e.length,i=-1,o=[];++r>>1,Bt=9007199254740991,Ct=ht&&new ht,Pt={};function Ot(e){if(Xe(e)&&!Xi(e)&&!(e instanceof Lt)){if(e instanceof Nt)return e;if(Oe.call(e,"__chain__")&&Oe.call(e,"__wrapped__"))return Fn(e)}return new Nt(e)}function Rt(){}function Nt(e,t,r){this.__wrapped__=e,this.__actions__=r||[],this.__chain__=!!t}Ot.support={};function Lt(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=At,this.__views__=[]}function Kt(){this.__data__={}}function jt(e){var t=e?e.length:0;for(this.data={hash:dt(null),set:new ut};t--;)this.push(e[t])}function Mt(e,t){var r=e.data;return("string"==typeof t||to(t)?r.set.has(t):r.hash[t])?0:-1}function Dt(e,t){for(var n=-1,i=e.length,o=-1,s=t.length,a=r(i+s);++n=S?zr(t):null,u=t.length;a&&(o=Mt,s=!1,t=a);e:for(;++is?0:s+t),(n=n===o||n>s?s:+n||0)<0&&(n+=s),s=t>n?0:n-t>>>0,t>>>=0;for(var a=r(s);++i=a)return u;var c=r[n];return u*("asc"===c||!0===c?1:-1)}}return e.index-t.index}(e,t,r)})}function Cr(e,t){var r=-1,n=vn(),i=e.length,o=n==Ue,s=o&&i>=S,a=s?zr():null,u=[];a?(n=Mt,o=!1):(s=!1,a=t?[]:u);e:for(;++r>>1,s=e[o];(r?s<=t:s2?r[i-2]:o,a=i>2?r[2]:o,u=i>1?r[i-1]:o;for("function"==typeof s?(s=Kr(s,u,5),i-=2):i-=(s="function"==typeof u?u:o)?1:0,a&&xn(r[0],r[1],a)&&(s=i<3?o:s,i=1);++n-1?r[s]:o}return ur(r,n,e)}}function Xr(e){return function(t,r,n){return t&&t.length?De(t,r=gn(r,n,3),e):-1}}function Zr(e){return function(t,r,n){return ur(t,r=gn(r,n,3),e,!0)}}function Qr(e){return function(){for(var t,n=arguments.length,i=e?n:-1,s=0,a=r(n);e?i--:++i=S)return t.plant(r).value();for(var i=0,o=n?a[i].apply(this,e):r;++i=(t=+t)||!mt(t))return"";var i=t-n;return Ko(r=null==r?" ":r+"",pt(i/r.length)).slice(0,i)}function fn(e,t,n,i){var o=t&c,s=Gr(e);return function t(){for(var a=-1,u=arguments.length,c=-1,f=i.length,l=r(f+u);++cc))return!1;for(;++u-1&&e%1==0&&e-1&&e%1==0&&e<=Bt}function Cn(e){return e==e&&!to(e)}function Pn(e,t){var r=e[1],n=t[1],i=r|n,o=i0){if(++Nn>=_)return e}else Nn=0;return Ar(e,t)});function jn(e){for(var t=Eo(e),r=t.length,n=r&&e.length,i=!!n&&Bn(n)&&(Xi(e)||Ji(e)),o=-1,s=[];++o=120?zr(n&&u):null}var c=e[0],f=-1,l=c?c.length:0,h=i[0];e:for(;++f2?e[t-2]:o,n=t>1?e[t-1]:o;return t>2&&"function"==typeof r?t-=2:(r=t>1&&"function"==typeof n?(--t,n):o,n=o),e.length=t,ii(e,r,n)});function ci(e){var t=Ot(e);return t.__chain__=!0,t}function fi(e,t,r){return t.call(r,e)}var li=$i(function(e){return e=cr(e),this.thru(function(t){return Dt(Xi(t)?t:[Dn(t)],e)})});var hi=$i(function(e,t){return Xt(e,cr(t))}),pi=Ur(function(e,t,r){Oe.call(e,r)?++e[r]:e[r]=1});function di(e,t,r){var n=Xi(e)?qt:sr;return r&&xn(e,t,r)&&(t=o),"function"==typeof t&&r===o||(t=gn(t,r,3)),n(e,t)}function yi(e,t,r){return(Xi(e)?Ht:ar)(e,t=gn(t,r,3))}var gi=Jr(ir),mi=Jr(or,!0);var bi=en(Ft,ir),vi=en(function(e,t){for(var r=e.length;r--&&!1!==t(e[r],r,e););return e},or),_i=Ur(function(e,t,r){Oe.call(e,r)?e[r].push(t):e[r]=[t]});function wi(e,t,r,n){var i=e?_n(e):0;return Bn(i)||(i=(e=Co(e)).length),r="number"!=typeof r||n&&xn(t,r,n)?0:r<0?vt(i+r,0):r||0,"string"==typeof e||!Xi(e)&&so(e)?r<=i&&e.indexOf(t,r)>-1:!!i&&vn(e,t,r)>-1}var Si=Ur(function(e,t,r){e[r]=t}),ki=$i(function(e,t,n){var i=-1,s="function"==typeof t,a=In(t),u=En(e)?r(e.length):[];return ir(e,function(e){var r=s?t:a&&null!=e?e[t]:o;u[++i]=r?r.apply(e,n):kn(e,t,n)}),u});function Ei(e,t,r){return(Xi(e)?zt:vr)(e,t=gn(t,r,3))}var Ai=Ur(function(e,t,r){e[r?0:1].push(t)},function(){return[[],[]]});var xi=an(Gt,ir),Ii=an(function(e,t,r,n){var i=e.length;for(n&&i&&(r=e[--i]);i--;)r=t(r,e[i],i,e);return r},or);function Ti(e,t,r){if(r?xn(e,t,r):null==t)return(n=(e=Mn(e)).length)>0?e[Er(0,n-1)]:o;var n,i=-1,s=co(e),a=(n=s.length)-1;for(t=_t(t<0?0:+t||0,n);++i0&&(r=t.apply(this,arguments)),e<=1&&(t=o),r}}var Ri=$i(function(e,t,r){var n=c;if(r.length){var i=Qe(r,Ri.placeholder);n|=d}return pn(e,n,t,r,i)}),Ni=$i(function(e,t){for(var r=-1,n=(t=t.length?cr(t):So(e)).length;++rt?y(f,i):c=ct(g,e)}function m(){y(p,c)}function b(){if(n=arguments,a=Pi(),u=this,f=p&&(c||!d),!1===h)var r=d&&!c;else{i||d||(l=a);var y=h-(a-l),b=y<=0||y>h;b?(i&&(i=it(i)),l=a,s=e.apply(u,n)):i||(i=ct(m,y))}return b&&c?c=it(c):c||t===h||(c=ct(g,t)),r&&(b=!0,s=e.apply(u,n)),!b||c||i||(n=u=o),s}return b.cancel=function(){c&&it(c),i&&it(i),l=0,i=c=f=o},b}var Di=$i(function(e,t){return rr(e,1,t)}),Ui=$i(function(e,t,r){return rr(e,t,r)}),Fi=Qr(),qi=Qr(!0);function Hi(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new Ie(A);var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var s=e.apply(this,n);return r.cache=o.set(i,s),s};return r.cache=new Hi.Cache,r}var zi=$i(function(e,t){if(t=cr(t),"function"!=typeof e||!qt(t,Fe))throw new Ie(A);var r=t.length;return $i(function(n){for(var i=_t(n.length,r);i--;)n[i]=t[i](n[i]);return e.apply(this,n)})});var Vi=sn(d),Gi=sn(y),Wi=$i(function(e,t){return pn(e,m,o,o,o,cr(t))});function $i(e,t){if("function"!=typeof e)throw new Ie(A);return t=vt(t===o?e.length-1:+t||0,0),function(){for(var n=arguments,i=-1,o=vt(n.length-t,0),s=r(o);++it}function Ji(e){return Xe(e)&&En(e)&&Oe.call(e,"callee")&&!at.call(e,"callee")}var Xi=gt||function(e){return Xe(e)&&Bn(e.length)&&Ne.call(e)==T};function Zi(e,t,r,n){var i=(r="function"==typeof r?Kr(r,n,3):o)?r(e,t):o;return i===o?mr(e,t,r):!!i}function Qi(e){return Xe(e)&&"string"==typeof e.message&&Ne.call(e)==P}function eo(e){return to(e)&&Ne.call(e)==O}function to(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function ro(e){return null!=e&&(eo(e)?Ke.test(Pe.call(e)):Xe(e)&&ge.test(e))}function no(e){return"number"==typeof e||Xe(e)&&Ne.call(e)==N}function io(e){var t,r;return!(!Xe(e)||Ne.call(e)!=L||Ji(e)||!(Oe.call(e,"constructor")||"function"!=typeof(t=e.constructor)||t instanceof t))&&(hr(e,function(e,t){r=t}),r===o||Oe.call(e,r))}function oo(e){return to(e)&&Ne.call(e)==K}function so(e){return"string"==typeof e||Xe(e)&&Ne.call(e)==M}function ao(e){return Xe(e)&&Bn(e.length)&&!!Ee[Ne.call(e)]}function uo(e,t){return e0;++ii?0:i+r),(n=n===o||n>i?i:+n||0)<0&&(n+=i),i=r>n?0:n>>>0,r>>>=0;r-1;)ft.call(t,o,1);return t},Ot.pullAt=Xn,Ot.range=function(e,t,n){n&&xn(e,t,n)&&(t=n=o),e=+e||0,n=null==n?1:+n||0,null==t?(t=e,e=0):t=+t||0;for(var i=-1,s=vt(pt((t-e)/(n||1)),0),a=r(s);++i=0&&e.indexOf(t,r)==r},Ot.escape=function(e){return(e=qe(e))&&re.test(e)?e.replace(ee,We):e},Ot.escapeRegExp=function(e){return(e=qe(e))&&fe.test(e)?e.replace(ce,$e):e||"(?:)"},Ot.every=di,Ot.find=gi,Ot.findIndex=Vn,Ot.findKey=go,Ot.findLast=mi,Ot.findLastIndex=Gn,Ot.findLastKey=mo,Ot.findWhere=function(e,t){return gi(e,_r(t))},Ot.first=Wn,Ot.floor=Zo,Ot.get=function(e,t,r){var n=null==e?o:gr(e,Un(t),t+"");return n===o?r:n},Ot.gt=Yi,Ot.gte=function(e,t){return e>=t},Ot.has=function(e,t){if(null==e)return!1;var r=Oe.call(e,t);if(!r&&!In(t)){if(null==(e=1==(t=Un(t)).length?e:gr(e,xr(t,0,-1))))return!1;t=Jn(t),r=Oe.call(e,t)}return r||Bn(e.length)&&An(t,e.length)&&(Xi(e)||Ji(e))},Ot.identity=Ho,Ot.includes=wi,Ot.indexOf=$n,Ot.inRange=function(e,t,r){return t=+t||0,r===o?(r=t,t=0):r=+r||0,e>=_t(t,r)&&e=t||!mt(t))return e;var i=(t-n)/2,o=yt(i);return(r=cn("",pt(i),r)).slice(0,o)+e+r},Ot.padLeft=No,Ot.padRight=Lo,Ot.parseInt=function(e,t,r){return(r?xn(e,t,r):null==t)?t=0:t&&(t=+t),e=Do(e),St(e,t||(ye.test(e)?16:10))},Ot.random=function(e,t,r){r&&xn(e,t,r)&&(t=r=o);var n=null==e,i=null==t;if(null==r&&(i&&"boolean"==typeof e?(r=e,e=1):"boolean"==typeof t&&(r=t,i=!0)),n&&i&&(t=1,i=!1),e=+e||0,i?(t=e,e=0):t=+t||0,r||e%1||t%1){var s=kt();return _t(e+s*(t-e+ot("1e-"+((s+"").length-1))),t)}return Er(e,t)},Ot.reduce=xi,Ot.reduceRight=Ii,Ot.repeat=Ko,Ot.result=function(e,t,r){var n=null==e?o:e[t];return n===o&&(null==e||In(t,e)||(n=null==(e=1==(t=Un(t)).length?e:gr(e,xr(t,0,-1)))?o:e[Jn(t)]),n=n===o?r:n),eo(n)?n.call(e):n},Ot.round=ts,Ot.runInContext=e,Ot.size=function(e){var t=e?_n(e):0;return Bn(t)?t:ko(e).length},Ot.snakeCase=jo,Ot.some=Bi,Ot.sortedIndex=Qn,Ot.sortedLastIndex=ei,Ot.startCase=Mo,Ot.startsWith=function(e,t,r){return e=qe(e),r=null==r?0:_t(r<0?0:+r||0,e.length),e.lastIndexOf(t,r)==r},Ot.sum=function(e,t,r){return r&&xn(e,t,r)&&(t=o),1==(t=gn(t,r,3)).length?function(e,t){for(var r=e.length,n=0;r--;)n+=+t(e[r])||0;return n}(Xi(e)?e:Mn(e),t):function(e,t){var r=0;return ir(e,function(e,n,i){r+=+t(e,n,i)||0}),r}(e,t)},Ot.template=function(e,t,r){var n=Ot.templateSettings;r&&xn(e,t,r)&&(t=r=o),e=qe(e);var i,a,u=Yt(Jt({},(t=Yt(Jt({},r||t),n,$t)).imports),n.imports,$t),c=ko(u),f=Pr(u,c),l=0,h=t.interpolate||ve,p="__p += '",d=D((t.escape||ve).source+"|"+h.source+"|"+(h===oe?pe:ve).source+"|"+(t.evaluate||ve).source+"|$","g"),y="//# sourceURL="+("sourceURL"in t?t.sourceURL:"lodash.templateSources["+ ++ke+"]")+"\n";e.replace(d,function(t,r,n,o,s,u){return n||(n=o),p+=e.slice(l,u).replace(_e,Ye),r&&(i=!0,p+="' +\n__e("+r+") +\n'"),s&&(a=!0,p+="';\n"+s+";\n__p += '"),n&&(p+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),l=u+t.length,t}),p+="';\n";var g=t.variable;g||(p="with (obj) {\n"+p+"\n}\n"),p=(a?p.replace(J,""):p).replace(X,"$1").replace(Z,"$1;"),p="function("+(g||"obj")+") {\n"+(g?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(a?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+p+"return __p\n}";var m=Fo(function(){return s(c,y+"return "+p).apply(o,f)});if(m.source=p,Qi(m))throw m;return m},Ot.trim=Do,Ot.trimLeft=function(e,t,r){var n=e;return(e=qe(e))?(r?xn(n,t,r):null==t)?e.slice(et(e)):e.slice(He(e,t+"")):e},Ot.trimRight=function(e,t,r){var n=e;return(e=qe(e))?(r?xn(n,t,r):null==t)?e.slice(0,tt(e)+1):e.slice(0,ze(e,t+"")+1):e},Ot.trunc=function(e,t,r){r&&xn(e,t,r)&&(t=o);var n=b,i=v;if(null!=t)if(to(t)){var s="separator"in t?t.separator:s;n="length"in t?+t.length||0:n,i="omission"in t?qe(t.omission):i}else n=+t||0;if(n>=(e=qe(e)).length)return e;var a=n-i.length;if(a<1)return i;var u=e.slice(0,a);if(null==s)return u+i;if(oo(s)){if(e.slice(a).search(s)){var c,f,l=e.slice(0,a);for(s.global||(s=D(s.source,(de.exec(s)||"")+"g")),s.lastIndex=0;c=s.exec(l);)f=c.index;u=u.slice(0,null==f?a:f)}}else if(e.indexOf(s,a)!=a){var h=u.lastIndexOf(s);h>-1&&(u=u.slice(0,h))}return u+i},Ot.unescape=function(e){return(e=qe(e))&&te.test(e)?e.replace(Q,rt):e},Ot.uniqueId=function(e){var t=++Re;return qe(e)+t},Ot.words=Uo,Ot.all=di,Ot.any=Bi,Ot.contains=wi,Ot.eq=Zi,Ot.detect=gi,Ot.foldl=xi,Ot.foldr=Ii,Ot.head=Wn,Ot.include=wi,Ot.inject=xi,Wo(Ot,(Jo={},pr(Ot,function(e,t){Ot.prototype[t]||(Jo[t]=e)}),Jo),!1),Ot.sample=Ti,Ot.prototype.sample=function(e){return this.__chain__||null!=e?this.thru(function(t){return Ti(t,e)}):Ti(this.value())},Ot.VERSION=u,Ft(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){Ot[e].placeholder=Ot}),Ft(["drop","take"],function(e,t){Lt.prototype[e]=function(r){var n=this.__filtered__;if(n&&!t)return new Lt(this);r=null==r?1:vt(yt(r)||0,0);var i=this.clone();return n?i.__takeCount__=_t(i.__takeCount__,r):i.__views__.push({size:r,type:e+(i.__dir__<0?"Right":"")}),i},Lt.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}}),Ft(["filter","map","takeWhile"],function(e,t){var r=t+1,n=r!=E;Lt.prototype[e]=function(e,t){var i=this.clone();return i.__iteratees__.push({iteratee:gn(e,t,1),type:r}),i.__filtered__=i.__filtered__||n,i}}),Ft(["first","last"],function(e,t){var r="take"+(t?"Right":"");Lt.prototype[e]=function(){return this[r](1).value()[0]}}),Ft(["initial","rest"],function(e,t){var r="drop"+(t?"":"Right");Lt.prototype[e]=function(){return this.__filtered__?new Lt(this):this[r](1)}}),Ft(["pluck","where"],function(e,t){var r=t?"filter":"map",n=t?_r:Yo;Lt.prototype[e]=function(e){return this[r](n(e))}}),Lt.prototype.compact=function(){return this.filter(Ho)},Lt.prototype.reject=function(e,t){return e=gn(e,t,1),this.filter(function(t){return!e(t)})},Lt.prototype.slice=function(e,t){e=null==e?0:+e||0;var r=this;return r.__filtered__&&(e>0||t<0)?new Lt(r):(e<0?r=r.takeRight(-e):e&&(r=r.drop(e)),t!==o&&(r=(t=+t||0)<0?r.dropRight(-t):r.take(t-e)),r)},Lt.prototype.takeRightWhile=function(e,t){return this.reverse().takeWhile(e,t).reverse()},Lt.prototype.toArray=function(){return this.take(At)},pr(Lt.prototype,function(e,t){var r=/^(?:filter|map|reject)|While$/.test(t),n=/^(?:first|last)$/.test(t),i=Ot[n?"take"+("last"==t?"Right":""):t];i&&(Ot.prototype[t]=function(){var t=n?[1]:arguments,s=this.__chain__,a=this.__wrapped__,u=!!this.__actions__.length,c=a instanceof Lt,f=t[0],l=c||Xi(a);l&&r&&"function"==typeof f&&1!=f.length&&(c=l=!1);var h=function(e){return n&&s?i(e,1)[0]:i.apply(o,Vt([e],t))},p={func:fi,args:[h],thisArg:o},d=c&&!u;if(n&&!s)return d?((a=a.clone()).__actions__.push(p),e.call(a)):i.call(o,this.value())[0];if(!n&&l){a=d?a:new Lt(this);var y=e.apply(a,t);return y.__actions__.push(p),new Nt(y,s)}return this.thru(h)})}),Ft(["join","pop","push","replace","shift","sort","splice","split","unshift"],function(e){var t=(/^(?:replace|split)$/.test(e)?Ce:Te)[e],r=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",n=/^(?:join|pop|replace|shift)$/.test(e);Ot.prototype[e]=function(){var e=arguments;return n&&!this.__chain__?t.apply(this.value(),e):this[r](function(r){return t.apply(r,e)})}}),pr(Lt.prototype,function(e,t){var r=Ot[t];if(r){var n=r.name;(Pt[n]||(Pt[n]=[])).push({name:t,func:r})}}),Pt[un(o,f).name]=[{name:"wrapper",func:o}],Lt.prototype.clone=function(){var e=new Lt(this.__wrapped__);return e.__actions__=Ut(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Ut(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Ut(this.__views__),e},Lt.prototype.reverse=function(){if(this.__filtered__){var e=new Lt(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},Lt.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,r=Xi(e),n=t<0,i=r?e.length:0,o=function(e,t,r){for(var n=-1,i=r.length;++n15?(n=Date.now(),a(e)):(r.push(e),1===r.length&&o.setAttribute("a",i=!i))}}s.nextTick=s.setImmediate}(),s.isNodejs=void 0!==t&&t.versions&&t.versions.node,s.isArray=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},s.isArrayBuffer=function(e){return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer},s.isArrayBufferView=function(e){return e&&s.isArrayBuffer(e.buffer)&&void 0!==e.byteLength},s.ByteBuffer=u,s.ByteStringBuffer=u;s.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},s.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},s.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},s.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))},s.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},s.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this},s.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(s.encodeUtf8(e))},s.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},s.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},s.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))},s.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255))},s.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))},s.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))},s.ByteStringBuffer.prototype.putInt=function(e,t){a(t);var r="";do{t-=8,r+=String.fromCharCode(e>>t&255)}while(t>0);return this.putBytes(r)},s.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<0);return t},s.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<=r&&(t-=r<<1),t},s.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},s.ByteStringBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},s.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)},s.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},s.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},s.ByteStringBuffer.prototype.copy=function(){var e=s.createBuffer(this.data);return e.read=this.read,e},s.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},s.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},s.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},s.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},s.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this},s.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},s.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this},s.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this},s.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},s.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this},s.DataBuffer.prototype.putInt=function(e,t){a(t),this.accommodate(t/8);do{t-=8,this.data.setInt8(this.write++,e>>t&255)}while(t>0);return this},s.DataBuffer.prototype.putSignedInt=function(e,t){return a(t),this.accommodate(t/8),e<0&&(e+=2<0);return t},s.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<=r&&(t-=r<<1),t},s.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},s.DataBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},s.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)},s.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this},s.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},s.DataBuffer.prototype.copy=function(){return new s.DataBuffer(this)},s.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},s.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},s.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this},s.DataBuffer.prototype.toHex=function(){for(var e="",t=this.read;t0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return r},s.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},s.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 c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",f=[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],l="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";s.encode64=function(e,t){for(var r,n,i,o="",s="",a=0;a>2),o+=c.charAt((3&r)<<4|n>>4),isNaN(n)?o+="==":(o+=c.charAt((15&n)<<2|i>>6),o+=isNaN(i)?"=":c.charAt(63&i)),t&&o.length>t&&(s+=o.substr(0,t)+"\r\n",o=o.substr(t));return s+o},s.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},s.encodeUtf8=function(e){return unescape(encodeURIComponent(e))},s.decodeUtf8=function(e){return decodeURIComponent(escape(e))},s.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:o.encode,decode:o.decode}},s.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)},s.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+=c.charAt((3&r)<<4|n>>4),isNaN(n)?o+="==":(o+=c.charAt((15&n)<<2|i>>6),o+=isNaN(i)?"=":c.charAt(63&i)),t&&o.length>t&&(s+=o.substr(0,t)+"\r\n",o=o.substr(t));return s+o},s.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 u=0,c=r=r||0;u>4,64!==o&&(a[c++]=(15&i)<<4|o>>2,64!==s&&(a[c++]=(3&o)<<6|s));return t?c-r:a.subarray(0,c)},s.binary.base58.encode=function(e,t){return s.binary.baseN.encode(e,l,t)},s.binary.base58.decode=function(e,t){return s.binary.baseN.decode(e,l,t)},s.text={utf8:{},utf16:{}},s.text.utf8.encode=function(e,t,r){e=s.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===v&&(v="undefined"!=typeof window&&window.location&&window.location.search?r(window.location.search.substring(1)):{}),t=v):t=r(e),t},s.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?{}:s.getQueryVariables(r)}},s.makeRequest=function(e){var t=s.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},s.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:"")},s.setPath=function(e,t,r){if("object"==typeof e&&null!==e)for(var n=0,i=t.length;n0&&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("")},s.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,u=i<0?"-":"",c=parseInt(i=Math.abs(+i||0).toFixed(o),10)+"",f=c.length>3?c.length%3:0;return u+(f?c.substr(0,f)+a:"")+c.substr(f).replace(/(\d{3})(?=\d)/g,"$1"+a)+(o?s+Math.abs(i-c).toFixed(o).slice(2):"")},s.formatSize=function(e){return e>=1073741824?s.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?s.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?s.formatNumber(e/1024,0)+" KiB":s.formatNumber(e,0)+" bytes"},s.bytesFromIP=function(e){return-1!==e.indexOf(".")?s.bytesFromIPv4(e):-1!==e.indexOf(":")?s.bytesFromIPv6(e):null},s.bytesFromIPv4=function(e){if(4!==(e=e.split(".")).length)return null;for(var t=s.createBuffer(),r=0;rr[n].end-r[n].start&&(n=r.length-1)):r.push({start:u,end:u})}t.push(o)}if(r.length>0){var c=r[n];c.end-c.start>0&&(t.splice(c.start,c.end-c.start+1,""),0===c.start&&t.unshift(""),7===c.end&&t.push(""))}return t.join(":")},s.estimateCores=function(e,t){if("function"==typeof e&&(t=e,e={}),e=e||{},"cores"in s&&!e.update)return t(null,s.cores);if("undefined"!=typeof navigator&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return s.cores=navigator.hardwareConcurrency,t(null,s.cores);if("undefined"==typeof Worker)return s.cores=1,t(null,s.cores);if("undefined"==typeof Blob)return s.cores=2,t(null,s.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.st"'`]/g,te=RegExp(Q.source),re=RegExp(ee.source),ne=/<%-([\s\S]+?)%>/g,ie=/<%([\s\S]+?)%>/g,oe=/<%=([\s\S]+?)%>/g,se=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,ae=/^\w*$/,ue=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g,ce=/^[:!,]|[\\^$.*+?()[\]{}|\/]|(^[0-9a-fA-Fnrtuvx])|([\n\r\u2028\u2029])/g,fe=RegExp(ce.source),le=/[\u0300-\u036f\ufe20-\ufe23]/g,he=/\\(\\)?/g,pe=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,de=/\w*$/,ye=/^0[xX]/,ge=/^\[object .+?Constructor\]$/,me=/^\d+$/,be=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,ve=/($^)/,_e=/['\n\r\u2028\u2029\\]/g,we=(s="[A-Z\\xc0-\\xd6\\xd8-\\xde]",a="[a-z\\xdf-\\xf6\\xf8-\\xff]+",RegExp(s+"+(?="+s+a+")|"+s+"?"+a+"|"+s+"+|[0-9]+","g")),Se=["Array","ArrayBuffer","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Math","Number","Object","RegExp","Set","String","_","clearTimeout","isFinite","parseFloat","parseInt","setTimeout","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap"],ke=-1,Ee={};Ee[F]=Ee[q]=Ee[H]=Ee[z]=Ee[V]=Ee[G]=Ee[W]=Ee[$]=Ee[Y]=!0,Ee[I]=Ee[T]=Ee[U]=Ee[B]=Ee[C]=Ee[P]=Ee[O]=Ee[R]=Ee[N]=Ee[L]=Ee[j]=Ee[M]=Ee[K]=Ee[D]=!1;var Ae={};Ae[I]=Ae[T]=Ae[U]=Ae[B]=Ae[C]=Ae[F]=Ae[q]=Ae[H]=Ae[z]=Ae[V]=Ae[N]=Ae[L]=Ae[j]=Ae[K]=Ae[G]=Ae[W]=Ae[$]=Ae[Y]=!0,Ae[P]=Ae[O]=Ae[R]=Ae[M]=Ae[D]=!1;var xe={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss"},Ie={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Te={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Be={function:!0,object:!0},Ce={0:"x30",1:"x31",2:"x32",3:"x33",4:"x34",5:"x35",6:"x36",7:"x37",8:"x38",9:"x39",A:"x41",B:"x42",C:"x43",D:"x44",E:"x45",F:"x46",a:"x61",b:"x62",c:"x63",d:"x64",e:"x65",f:"x66",n:"x6e",r:"x72",t:"x74",u:"x75",v:"x76",x:"x78"},Pe={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Oe=Be[typeof t]&&t&&!t.nodeType&&t,Re=Be[typeof e]&&e&&!e.nodeType&&e,Ne=Oe&&Re&&"object"==typeof n&&n&&n.Object&&n,Le=Be[typeof self]&&self&&self.Object&&self,je=Be[typeof window]&&window&&window.Object&&window,Me=(Re&&Re.exports,Ne||je!==(this&&this.window)&&je||Le||this);function Ke(e,t){if(e!==t){var r=null===e,n=e===o,i=e==e,s=null===t,a=t===o,u=t==t;if(e>t&&!s||!i||r&&!a&&u||n&&u)return 1;if(e-1;);return r}function ze(e,t){for(var r=e.length;r--&&t.indexOf(e.charAt(r))>-1;);return r}function Ve(e,t){return Ke(e.criteria,t.criteria)||e.index-t.index}function Ge(e){return xe[e]}function We(e){return Ie[e]}function $e(e,t,r){return t?e=Ce[e]:r&&(e=Pe[e]),"\\"+e}function Ye(e){return"\\"+Pe[e]}function Je(e,t,r){for(var n=e.length,i=t+(r?0:-1);r?i--:++i=9&&e<=13||32==e||160==e||5760==e||6158==e||e>=8192&&(e<=8202||8232==e||8233==e||8239==e||8287==e||12288==e||65279==e)}function Qe(e,t){for(var r=-1,n=e.length,i=-1,o=[];++r>>1,Bt=9007199254740991,Ct=ht&&new ht,Pt={};function Ot(e){if(Xe(e)&&!Xi(e)&&!(e instanceof Lt)){if(e instanceof Nt)return e;if(Oe.call(e,"__chain__")&&Oe.call(e,"__wrapped__"))return Fn(e)}return new Nt(e)}function Rt(){}function Nt(e,t,r){this.__wrapped__=e,this.__actions__=r||[],this.__chain__=!!t}Ot.support={};function Lt(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=At,this.__views__=[]}function jt(){this.__data__={}}function Mt(e){var t=e?e.length:0;for(this.data={hash:dt(null),set:new ut};t--;)this.push(e[t])}function Kt(e,t){var r=e.data;return("string"==typeof t||to(t)?r.set.has(t):r.hash[t])?0:-1}function Dt(e,t){for(var n=-1,i=e.length,o=-1,s=t.length,a=r(i+s);++n=S?zr(t):null,u=t.length;a&&(o=Kt,s=!1,t=a);e:for(;++is?0:s+t),(n=n===o||n>s?s:+n||0)<0&&(n+=s),s=t>n?0:n-t>>>0,t>>>=0;for(var a=r(s);++i=a)return u;var c=r[n];return u*("asc"===c||!0===c?1:-1)}}return e.index-t.index}(e,t,r)})}function Cr(e,t){var r=-1,n=vn(),i=e.length,o=n==Ue,s=o&&i>=S,a=s?zr():null,u=[];a?(n=Kt,o=!1):(s=!1,a=t?[]:u);e:for(;++r>>1,s=e[o];(r?s<=t:s2?r[i-2]:o,a=i>2?r[2]:o,u=i>1?r[i-1]:o;for("function"==typeof s?(s=jr(s,u,5),i-=2):i-=(s="function"==typeof u?u:o)?1:0,a&&xn(r[0],r[1],a)&&(s=i<3?o:s,i=1);++n-1?r[s]:o}return ur(r,n,e)}}function Xr(e){return function(t,r,n){return t&&t.length?De(t,r=gn(r,n,3),e):-1}}function Zr(e){return function(t,r,n){return ur(t,r=gn(r,n,3),e,!0)}}function Qr(e){return function(){for(var t,n=arguments.length,i=e?n:-1,s=0,a=r(n);e?i--:++i=S)return t.plant(r).value();for(var i=0,o=n?a[i].apply(this,e):r;++i=(t=+t)||!mt(t))return"";var i=t-n;return jo(r=null==r?" ":r+"",pt(i/r.length)).slice(0,i)}function fn(e,t,n,i){var o=t&c,s=Gr(e);return function t(){for(var a=-1,u=arguments.length,c=-1,f=i.length,l=r(f+u);++cc))return!1;for(;++u-1&&e%1==0&&e-1&&e%1==0&&e<=Bt}function Cn(e){return e==e&&!to(e)}function Pn(e,t){var r=e[1],n=t[1],i=r|n,o=i0){if(++Nn>=_)return e}else Nn=0;return Ar(e,t)});function Mn(e){for(var t=Eo(e),r=t.length,n=r&&e.length,i=!!n&&Bn(n)&&(Xi(e)||Ji(e)),o=-1,s=[];++o=120?zr(n&&u):null}var c=e[0],f=-1,l=c?c.length:0,h=i[0];e:for(;++f2?e[t-2]:o,n=t>1?e[t-1]:o;return t>2&&"function"==typeof r?t-=2:(r=t>1&&"function"==typeof n?(--t,n):o,n=o),e.length=t,ii(e,r,n)});function ci(e){var t=Ot(e);return t.__chain__=!0,t}function fi(e,t,r){return t.call(r,e)}var li=$i(function(e){return e=cr(e),this.thru(function(t){return Dt(Xi(t)?t:[Dn(t)],e)})});var hi=$i(function(e,t){return Xt(e,cr(t))}),pi=Ur(function(e,t,r){Oe.call(e,r)?++e[r]:e[r]=1});function di(e,t,r){var n=Xi(e)?qt:sr;return r&&xn(e,t,r)&&(t=o),"function"==typeof t&&r===o||(t=gn(t,r,3)),n(e,t)}function yi(e,t,r){return(Xi(e)?Ht:ar)(e,t=gn(t,r,3))}var gi=Jr(ir),mi=Jr(or,!0);var bi=en(Ft,ir),vi=en(function(e,t){for(var r=e.length;r--&&!1!==t(e[r],r,e););return e},or),_i=Ur(function(e,t,r){Oe.call(e,r)?e[r].push(t):e[r]=[t]});function wi(e,t,r,n){var i=e?_n(e):0;return Bn(i)||(i=(e=Co(e)).length),r="number"!=typeof r||n&&xn(t,r,n)?0:r<0?vt(i+r,0):r||0,"string"==typeof e||!Xi(e)&&so(e)?r<=i&&e.indexOf(t,r)>-1:!!i&&vn(e,t,r)>-1}var Si=Ur(function(e,t,r){e[r]=t}),ki=$i(function(e,t,n){var i=-1,s="function"==typeof t,a=In(t),u=En(e)?r(e.length):[];return ir(e,function(e){var r=s?t:a&&null!=e?e[t]:o;u[++i]=r?r.apply(e,n):kn(e,t,n)}),u});function Ei(e,t,r){return(Xi(e)?zt:vr)(e,t=gn(t,r,3))}var Ai=Ur(function(e,t,r){e[r?0:1].push(t)},function(){return[[],[]]});var xi=an(Gt,ir),Ii=an(function(e,t,r,n){var i=e.length;for(n&&i&&(r=e[--i]);i--;)r=t(r,e[i],i,e);return r},or);function Ti(e,t,r){if(r?xn(e,t,r):null==t)return(n=(e=Kn(e)).length)>0?e[Er(0,n-1)]:o;var n,i=-1,s=co(e),a=(n=s.length)-1;for(t=_t(t<0?0:+t||0,n);++i0&&(r=t.apply(this,arguments)),e<=1&&(t=o),r}}var Ri=$i(function(e,t,r){var n=c;if(r.length){var i=Qe(r,Ri.placeholder);n|=d}return pn(e,n,t,r,i)}),Ni=$i(function(e,t){for(var r=-1,n=(t=t.length?cr(t):So(e)).length;++rt?y(f,i):c=ct(g,e)}function m(){y(p,c)}function b(){if(n=arguments,a=Pi(),u=this,f=p&&(c||!d),!1===h)var r=d&&!c;else{i||d||(l=a);var y=h-(a-l),b=y<=0||y>h;b?(i&&(i=it(i)),l=a,s=e.apply(u,n)):i||(i=ct(m,y))}return b&&c?c=it(c):c||t===h||(c=ct(g,t)),r&&(b=!0,s=e.apply(u,n)),!b||c||i||(n=u=o),s}return b.cancel=function(){c&&it(c),i&&it(i),l=0,i=c=f=o},b}var Di=$i(function(e,t){return rr(e,1,t)}),Ui=$i(function(e,t,r){return rr(e,t,r)}),Fi=Qr(),qi=Qr(!0);function Hi(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new Ie(A);var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var s=e.apply(this,n);return r.cache=o.set(i,s),s};return r.cache=new Hi.Cache,r}var zi=$i(function(e,t){if(t=cr(t),"function"!=typeof e||!qt(t,Fe))throw new Ie(A);var r=t.length;return $i(function(n){for(var i=_t(n.length,r);i--;)n[i]=t[i](n[i]);return e.apply(this,n)})});var Vi=sn(d),Gi=sn(y),Wi=$i(function(e,t){return pn(e,m,o,o,o,cr(t))});function $i(e,t){if("function"!=typeof e)throw new Ie(A);return t=vt(t===o?e.length-1:+t||0,0),function(){for(var n=arguments,i=-1,o=vt(n.length-t,0),s=r(o);++it}function Ji(e){return Xe(e)&&En(e)&&Oe.call(e,"callee")&&!at.call(e,"callee")}var Xi=gt||function(e){return Xe(e)&&Bn(e.length)&&Ne.call(e)==T};function Zi(e,t,r,n){var i=(r="function"==typeof r?jr(r,n,3):o)?r(e,t):o;return i===o?mr(e,t,r):!!i}function Qi(e){return Xe(e)&&"string"==typeof e.message&&Ne.call(e)==P}function eo(e){return to(e)&&Ne.call(e)==O}function to(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function ro(e){return null!=e&&(eo(e)?je.test(Pe.call(e)):Xe(e)&&ge.test(e))}function no(e){return"number"==typeof e||Xe(e)&&Ne.call(e)==N}function io(e){var t,r;return!(!Xe(e)||Ne.call(e)!=L||Ji(e)||!(Oe.call(e,"constructor")||"function"!=typeof(t=e.constructor)||t instanceof t))&&(hr(e,function(e,t){r=t}),r===o||Oe.call(e,r))}function oo(e){return to(e)&&Ne.call(e)==j}function so(e){return"string"==typeof e||Xe(e)&&Ne.call(e)==K}function ao(e){return Xe(e)&&Bn(e.length)&&!!Ee[Ne.call(e)]}function uo(e,t){return e0;++ii?0:i+r),(n=n===o||n>i?i:+n||0)<0&&(n+=i),i=r>n?0:n>>>0,r>>>=0;r-1;)ft.call(t,o,1);return t},Ot.pullAt=Xn,Ot.range=function(e,t,n){n&&xn(e,t,n)&&(t=n=o),e=+e||0,n=null==n?1:+n||0,null==t?(t=e,e=0):t=+t||0;for(var i=-1,s=vt(pt((t-e)/(n||1)),0),a=r(s);++i=0&&e.indexOf(t,r)==r},Ot.escape=function(e){return(e=qe(e))&&re.test(e)?e.replace(ee,We):e},Ot.escapeRegExp=function(e){return(e=qe(e))&&fe.test(e)?e.replace(ce,$e):e||"(?:)"},Ot.every=di,Ot.find=gi,Ot.findIndex=Vn,Ot.findKey=go,Ot.findLast=mi,Ot.findLastIndex=Gn,Ot.findLastKey=mo,Ot.findWhere=function(e,t){return gi(e,_r(t))},Ot.first=Wn,Ot.floor=Zo,Ot.get=function(e,t,r){var n=null==e?o:gr(e,Un(t),t+"");return n===o?r:n},Ot.gt=Yi,Ot.gte=function(e,t){return e>=t},Ot.has=function(e,t){if(null==e)return!1;var r=Oe.call(e,t);if(!r&&!In(t)){if(null==(e=1==(t=Un(t)).length?e:gr(e,xr(t,0,-1))))return!1;t=Jn(t),r=Oe.call(e,t)}return r||Bn(e.length)&&An(t,e.length)&&(Xi(e)||Ji(e))},Ot.identity=Ho,Ot.includes=wi,Ot.indexOf=$n,Ot.inRange=function(e,t,r){return t=+t||0,r===o?(r=t,t=0):r=+r||0,e>=_t(t,r)&&e=t||!mt(t))return e;var i=(t-n)/2,o=yt(i);return(r=cn("",pt(i),r)).slice(0,o)+e+r},Ot.padLeft=No,Ot.padRight=Lo,Ot.parseInt=function(e,t,r){return(r?xn(e,t,r):null==t)?t=0:t&&(t=+t),e=Do(e),St(e,t||(ye.test(e)?16:10))},Ot.random=function(e,t,r){r&&xn(e,t,r)&&(t=r=o);var n=null==e,i=null==t;if(null==r&&(i&&"boolean"==typeof e?(r=e,e=1):"boolean"==typeof t&&(r=t,i=!0)),n&&i&&(t=1,i=!1),e=+e||0,i?(t=e,e=0):t=+t||0,r||e%1||t%1){var s=kt();return _t(e+s*(t-e+ot("1e-"+((s+"").length-1))),t)}return Er(e,t)},Ot.reduce=xi,Ot.reduceRight=Ii,Ot.repeat=jo,Ot.result=function(e,t,r){var n=null==e?o:e[t];return n===o&&(null==e||In(t,e)||(n=null==(e=1==(t=Un(t)).length?e:gr(e,xr(t,0,-1)))?o:e[Jn(t)]),n=n===o?r:n),eo(n)?n.call(e):n},Ot.round=ts,Ot.runInContext=e,Ot.size=function(e){var t=e?_n(e):0;return Bn(t)?t:ko(e).length},Ot.snakeCase=Mo,Ot.some=Bi,Ot.sortedIndex=Qn,Ot.sortedLastIndex=ei,Ot.startCase=Ko,Ot.startsWith=function(e,t,r){return e=qe(e),r=null==r?0:_t(r<0?0:+r||0,e.length),e.lastIndexOf(t,r)==r},Ot.sum=function(e,t,r){return r&&xn(e,t,r)&&(t=o),1==(t=gn(t,r,3)).length?function(e,t){for(var r=e.length,n=0;r--;)n+=+t(e[r])||0;return n}(Xi(e)?e:Kn(e),t):function(e,t){var r=0;return ir(e,function(e,n,i){r+=+t(e,n,i)||0}),r}(e,t)},Ot.template=function(e,t,r){var n=Ot.templateSettings;r&&xn(e,t,r)&&(t=r=o),e=qe(e);var i,a,u=Yt(Jt({},(t=Yt(Jt({},r||t),n,$t)).imports),n.imports,$t),c=ko(u),f=Pr(u,c),l=0,h=t.interpolate||ve,p="__p += '",d=D((t.escape||ve).source+"|"+h.source+"|"+(h===oe?pe:ve).source+"|"+(t.evaluate||ve).source+"|$","g"),y="//# sourceURL="+("sourceURL"in t?t.sourceURL:"lodash.templateSources["+ ++ke+"]")+"\n";e.replace(d,function(t,r,n,o,s,u){return n||(n=o),p+=e.slice(l,u).replace(_e,Ye),r&&(i=!0,p+="' +\n__e("+r+") +\n'"),s&&(a=!0,p+="';\n"+s+";\n__p += '"),n&&(p+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),l=u+t.length,t}),p+="';\n";var g=t.variable;g||(p="with (obj) {\n"+p+"\n}\n"),p=(a?p.replace(J,""):p).replace(X,"$1").replace(Z,"$1;"),p="function("+(g||"obj")+") {\n"+(g?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(i?", __e = _.escape":"")+(a?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+p+"return __p\n}";var m=Fo(function(){return s(c,y+"return "+p).apply(o,f)});if(m.source=p,Qi(m))throw m;return m},Ot.trim=Do,Ot.trimLeft=function(e,t,r){var n=e;return(e=qe(e))?(r?xn(n,t,r):null==t)?e.slice(et(e)):e.slice(He(e,t+"")):e},Ot.trimRight=function(e,t,r){var n=e;return(e=qe(e))?(r?xn(n,t,r):null==t)?e.slice(0,tt(e)+1):e.slice(0,ze(e,t+"")+1):e},Ot.trunc=function(e,t,r){r&&xn(e,t,r)&&(t=o);var n=b,i=v;if(null!=t)if(to(t)){var s="separator"in t?t.separator:s;n="length"in t?+t.length||0:n,i="omission"in t?qe(t.omission):i}else n=+t||0;if(n>=(e=qe(e)).length)return e;var a=n-i.length;if(a<1)return i;var u=e.slice(0,a);if(null==s)return u+i;if(oo(s)){if(e.slice(a).search(s)){var c,f,l=e.slice(0,a);for(s.global||(s=D(s.source,(de.exec(s)||"")+"g")),s.lastIndex=0;c=s.exec(l);)f=c.index;u=u.slice(0,null==f?a:f)}}else if(e.indexOf(s,a)!=a){var h=u.lastIndexOf(s);h>-1&&(u=u.slice(0,h))}return u+i},Ot.unescape=function(e){return(e=qe(e))&&te.test(e)?e.replace(Q,rt):e},Ot.uniqueId=function(e){var t=++Re;return qe(e)+t},Ot.words=Uo,Ot.all=di,Ot.any=Bi,Ot.contains=wi,Ot.eq=Zi,Ot.detect=gi,Ot.foldl=xi,Ot.foldr=Ii,Ot.head=Wn,Ot.include=wi,Ot.inject=xi,Wo(Ot,(Jo={},pr(Ot,function(e,t){Ot.prototype[t]||(Jo[t]=e)}),Jo),!1),Ot.sample=Ti,Ot.prototype.sample=function(e){return this.__chain__||null!=e?this.thru(function(t){return Ti(t,e)}):Ti(this.value())},Ot.VERSION=u,Ft(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){Ot[e].placeholder=Ot}),Ft(["drop","take"],function(e,t){Lt.prototype[e]=function(r){var n=this.__filtered__;if(n&&!t)return new Lt(this);r=null==r?1:vt(yt(r)||0,0);var i=this.clone();return n?i.__takeCount__=_t(i.__takeCount__,r):i.__views__.push({size:r,type:e+(i.__dir__<0?"Right":"")}),i},Lt.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}}),Ft(["filter","map","takeWhile"],function(e,t){var r=t+1,n=r!=E;Lt.prototype[e]=function(e,t){var i=this.clone();return i.__iteratees__.push({iteratee:gn(e,t,1),type:r}),i.__filtered__=i.__filtered__||n,i}}),Ft(["first","last"],function(e,t){var r="take"+(t?"Right":"");Lt.prototype[e]=function(){return this[r](1).value()[0]}}),Ft(["initial","rest"],function(e,t){var r="drop"+(t?"":"Right");Lt.prototype[e]=function(){return this.__filtered__?new Lt(this):this[r](1)}}),Ft(["pluck","where"],function(e,t){var r=t?"filter":"map",n=t?_r:Yo;Lt.prototype[e]=function(e){return this[r](n(e))}}),Lt.prototype.compact=function(){return this.filter(Ho)},Lt.prototype.reject=function(e,t){return e=gn(e,t,1),this.filter(function(t){return!e(t)})},Lt.prototype.slice=function(e,t){e=null==e?0:+e||0;var r=this;return r.__filtered__&&(e>0||t<0)?new Lt(r):(e<0?r=r.takeRight(-e):e&&(r=r.drop(e)),t!==o&&(r=(t=+t||0)<0?r.dropRight(-t):r.take(t-e)),r)},Lt.prototype.takeRightWhile=function(e,t){return this.reverse().takeWhile(e,t).reverse()},Lt.prototype.toArray=function(){return this.take(At)},pr(Lt.prototype,function(e,t){var r=/^(?:filter|map|reject)|While$/.test(t),n=/^(?:first|last)$/.test(t),i=Ot[n?"take"+("last"==t?"Right":""):t];i&&(Ot.prototype[t]=function(){var t=n?[1]:arguments,s=this.__chain__,a=this.__wrapped__,u=!!this.__actions__.length,c=a instanceof Lt,f=t[0],l=c||Xi(a);l&&r&&"function"==typeof f&&1!=f.length&&(c=l=!1);var h=function(e){return n&&s?i(e,1)[0]:i.apply(o,Vt([e],t))},p={func:fi,args:[h],thisArg:o},d=c&&!u;if(n&&!s)return d?((a=a.clone()).__actions__.push(p),e.call(a)):i.call(o,this.value())[0];if(!n&&l){a=d?a:new Lt(this);var y=e.apply(a,t);return y.__actions__.push(p),new Nt(y,s)}return this.thru(h)})}),Ft(["join","pop","push","replace","shift","sort","splice","split","unshift"],function(e){var t=(/^(?:replace|split)$/.test(e)?Ce:Te)[e],r=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",n=/^(?:join|pop|replace|shift)$/.test(e);Ot.prototype[e]=function(){var e=arguments;return n&&!this.__chain__?t.apply(this.value(),e):this[r](function(r){return t.apply(r,e)})}}),pr(Lt.prototype,function(e,t){var r=Ot[t];if(r){var n=r.name;(Pt[n]||(Pt[n]=[])).push({name:t,func:r})}}),Pt[un(o,f).name]=[{name:"wrapper",func:o}],Lt.prototype.clone=function(){var e=new Lt(this.__wrapped__);return e.__actions__=Ut(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Ut(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Ut(this.__views__),e},Lt.prototype.reverse=function(){if(this.__filtered__){var e=new Lt(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},Lt.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,r=Xi(e),n=t<0,i=r?e.length:0,o=function(e,t,r){for(var n=-1,i=r.length;++n15?(n=Date.now(),a(e)):(r.push(e),1===r.length&&o.setAttribute("a",i=!i))}}s.nextTick=s.setImmediate}(),s.isNodejs=void 0!==t&&t.versions&&t.versions.node,s.isArray=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},s.isArrayBuffer=function(e){return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer},s.isArrayBufferView=function(e){return e&&s.isArrayBuffer(e.buffer)&&void 0!==e.byteLength},s.ByteBuffer=u,s.ByteStringBuffer=u;s.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},s.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},s.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},s.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))},s.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},s.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this},s.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(s.encodeUtf8(e))},s.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},s.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},s.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))},s.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255))},s.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))},s.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))},s.ByteStringBuffer.prototype.putInt=function(e,t){a(t);var r="";do{t-=8,r+=String.fromCharCode(e>>t&255)}while(t>0);return this.putBytes(r)},s.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<0);return t},s.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<=r&&(t-=r<<1),t},s.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},s.ByteStringBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},s.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)},s.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},s.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},s.ByteStringBuffer.prototype.copy=function(){var e=s.createBuffer(this.data);return e.read=this.read,e},s.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},s.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},s.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},s.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},s.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this},s.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},s.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this},s.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this},s.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},s.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this},s.DataBuffer.prototype.putInt=function(e,t){a(t),this.accommodate(t/8);do{t-=8,this.data.setInt8(this.write++,e>>t&255)}while(t>0);return this},s.DataBuffer.prototype.putSignedInt=function(e,t){return a(t),this.accommodate(t/8),e<0&&(e+=2<0);return t},s.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<=r&&(t-=r<<1),t},s.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},s.DataBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},s.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)},s.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this},s.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},s.DataBuffer.prototype.copy=function(){return new s.DataBuffer(this)},s.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},s.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},s.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this},s.DataBuffer.prototype.toHex=function(){for(var e="",t=this.read;t0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return r},s.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},s.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 c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",f=[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],l="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";s.encode64=function(e,t){for(var r,n,i,o="",s="",a=0;a>2),o+=c.charAt((3&r)<<4|n>>4),isNaN(n)?o+="==":(o+=c.charAt((15&n)<<2|i>>6),o+=isNaN(i)?"=":c.charAt(63&i)),t&&o.length>t&&(s+=o.substr(0,t)+"\r\n",o=o.substr(t));return s+o},s.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},s.encodeUtf8=function(e){return unescape(encodeURIComponent(e))},s.decodeUtf8=function(e){return decodeURIComponent(escape(e))},s.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:o.encode,decode:o.decode}},s.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)},s.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+=c.charAt((3&r)<<4|n>>4),isNaN(n)?o+="==":(o+=c.charAt((15&n)<<2|i>>6),o+=isNaN(i)?"=":c.charAt(63&i)),t&&o.length>t&&(s+=o.substr(0,t)+"\r\n",o=o.substr(t));return s+o},s.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 u=0,c=r=r||0;u>4,64!==o&&(a[c++]=(15&i)<<4|o>>2,64!==s&&(a[c++]=(3&o)<<6|s));return t?c-r:a.subarray(0,c)},s.binary.base58.encode=function(e,t){return s.binary.baseN.encode(e,l,t)},s.binary.base58.decode=function(e,t){return s.binary.baseN.decode(e,l,t)},s.text={utf8:{},utf16:{}},s.text.utf8.encode=function(e,t,r){e=s.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===v&&(v="undefined"!=typeof window&&window.location&&window.location.search?r(window.location.search.substring(1)):{}),t=v):t=r(e),t},s.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?{}:s.getQueryVariables(r)}},s.makeRequest=function(e){var t=s.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},s.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:"")},s.setPath=function(e,t,r){if("object"==typeof e&&null!==e)for(var n=0,i=t.length;n0&&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("")},s.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,u=i<0?"-":"",c=parseInt(i=Math.abs(+i||0).toFixed(o),10)+"",f=c.length>3?c.length%3:0;return u+(f?c.substr(0,f)+a:"")+c.substr(f).replace(/(\d{3})(?=\d)/g,"$1"+a)+(o?s+Math.abs(i-c).toFixed(o).slice(2):"")},s.formatSize=function(e){return e>=1073741824?s.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?s.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?s.formatNumber(e/1024,0)+" KiB":s.formatNumber(e,0)+" bytes"},s.bytesFromIP=function(e){return-1!==e.indexOf(".")?s.bytesFromIPv4(e):-1!==e.indexOf(":")?s.bytesFromIPv6(e):null},s.bytesFromIPv4=function(e){if(4!==(e=e.split(".")).length)return null;for(var t=s.createBuffer(),r=0;rr[n].end-r[n].start&&(n=r.length-1)):r.push({start:u,end:u})}t.push(o)}if(r.length>0){var c=r[n];c.end-c.start>0&&(t.splice(c.start,c.end-c.start+1,""),0===c.start&&t.unshift(""),7===c.end&&t.push(""))}return t.join(":")},s.estimateCores=function(e,t){if("function"==typeof e&&(t=e,e={}),e=e||{},"cores"in s&&!e.update)return t(null,s.cores);if("undefined"!=typeof navigator&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return s.cores=navigator.hardwareConcurrency,t(null,s.cores);if("undefined"==typeof Worker)return s.cores=1,t(null,s.cores);if("undefined"==typeof Blob)return s.cores=2,t(null,s.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?r[n]:null;return"function"==typeof i&&i?e.apply(t,r):new Promise(function(n,i){r.push(function(e,t){if(e)return i(e);n(t)}),e.apply(t,r)})}};e.exports=function(e,t){t=t||{};var r=Object.prototype.toString.call(e);if("[object Object]"===r||"[object Array]"===r){var i=t.replace?e:{};for(var o in e)e.hasOwnProperty(o)&&(i[o]=n(e[o]));return i}return n(e,t.context||e)}},function(e,t,r){"use strict";(function(t){var n=r(0),i=r(17),o=r(29),s=r(21);function a(e,t){if(e.length!==t.length)return!1;for(var r=e.length,n=0;n>24&255),r.push(e>>16&255),r.push(e>>8&255),r.push(255&e),new t(r)},integerFromBuffer:function(e){return s.checkArgumentType(e,"Buffer","buffer"),e[0]<<24|e[1]<<16|e[2]<<8|e[3]},integerFromSingleByteBuffer:function(e){return s.checkArgumentType(e,"Buffer","buffer"),e[0]},bufferToHex:function(e){return s.checkArgumentType(e,"Buffer","buffer"),e.toString("hex")},reverse:function(e){for(var t=new n.Buffer(e.length),r=0;r=c.OP_1&&e<=c.OP_16||e===c.OP_1NEGATE)}(e)}function p(e){return a.Array(e)&&e.every(h)}function d(e){return 0===e.length?c.OP_0:1===e.length?e[0]>=1&&e[0]<=16?l+e[0]:129===e[0]?c.OP_1NEGATE:void 0:void 0}function y(e){if(n.isBuffer(e))return e;s(a.Array,e);var t=e.reduce(function(e,t){return n.isBuffer(t)?1===t.length&&void 0!==d(t)?e+1:e+o.encodingLength(t.length)+t.length:e+1},0),r=n.allocUnsafe(t),i=0;if(e.forEach(function(e){if(n.isBuffer(e)){var t=d(e);if(void 0!==t)return r.writeUInt8(t,i),void(i+=1);i+=o.encode(r,e.length,i),e.copy(r,i),i+=e.length}else r.writeUInt8(e,i),i+=1}),i!==r.length)throw new Error("Could not decode chunks");return r}function g(e){if(a.Array(e))return e;s(a.Buffer,e);for(var t=[],r=0;rc.OP_0&&n<=c.OP_PUSHDATA4){var i=o.decode(e,r);if(null===i)return[];if((r+=i.size)+i.number>e.length)return[];var u=e.slice(r,r+i.number);r+=i.number;var f=d(u);void 0!==f?t.push(f):t.push(u)}else t.push(n),r+=1}return t}function m(e){var t=-129&e;return t>0&&t<4}e.exports={compile:y,decompile:g,fromASM:function(e){return s(a.String,e),y(e.split(" ").map(function(e){return void 0!==c[e]?c[e]:(s(a.Hex,e),n.from(e,"hex"))}))},toASM:function(e){return n.isBuffer(e)&&(e=g(e)),e.map(function(e){if(n.isBuffer(e)){var t=d(e);if(void 0===t)return e.toString("hex");e=t}return f[e]}).join(" ")},toStack:function(e){return e=g(e),s(p,e),e.map(function(e){return n.isBuffer(e)?e:e===c.OP_0?n.allocUnsafe(0):u.encode(e-l)})},number:r(403),isCanonicalPubKey:function(e){if(!n.isBuffer(e))return!1;if(e.length<33)return!1;switch(e[0]){case 2:case 3:return 33===e.length;case 4:return 65===e.length}return!1},isCanonicalSignature:function(e){return!!n.isBuffer(e)&&!!m(e[e.length-1])&&i.check(e.slice(0,-1))},isPushOnly:p,isDefinedHashType:m}},function(e,t,r){"use strict";var n=r(18),i=function(e){return!!n.isString(e)&&/^[0-9a-fA-F]+$/.test(e)};e.exports={isValidJSON:function(e){var t;if(!n.isString(e))return!1;try{t=JSON.parse(e)}catch(e){return!1}return"object"==typeof t},isHexa:i,isHexaString:i,cloneArray:function(e){return[].concat(e)},defineImmutable:function(e,t){return Object.keys(t).forEach(function(r){Object.defineProperty(e,r,{configurable:!1,enumerable:!0,value:t[r]})}),e},isNaturalNumber:function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e&&e>=0}}},function(e,t,r){var n=r(1131);function i(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function o(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},r=e.name||"Function wrapped with `once`";return t.onceError=r+" shouldn't be called more than once",t.called=!1,t}e.exports=n(i),e.exports.strict=n(o),i.proto=i(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return i(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return o(this)},configurable:!0})})},function(e,t,r){var n=r(25),i=Math.pow(2,31)-1;function o(e){return n.String(e)&&e.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}o.toJSON=function(){return"BIP32 derivation path"};var s=21e14;var a=n.quacksLike("BigInteger"),u=n.quacksLike("Point"),c=n.compile({r:a,s:a}),f=n.compile({messagePrefix:n.oneOf(n.Buffer,n.String),bip32:{public:n.UInt32,private:n.UInt32},pubKeyHash:n.UInt8,scriptHash:n.UInt8,wif:n.UInt8}),l={BigInt:a,BIP32Path:o,Buffer256bit:n.BufferN(32),ECPoint:u,ECSignature:c,Hash160bit:n.BufferN(20),Hash256bit:n.BufferN(32),Network:f,Satoshi:function(e){return n.UInt53(e)&&e<=s},UInt31:function(e){return n.UInt32(e)&&e<=i}};for(var h in n)l[h]=n[h];e.exports=l},function(e,t,r){"use strict";(function(t){var n=r(74),i=r(21),o=r(18),s=function(e){for(var r=new t(e.length),n=0;ne.size?r=n.trim(r,o):o0&&0==(127&e[e.length-1])&&(e.length<=1||0==(128&e[e.length-2])))throw new Error("non-minimally encoded script number");return n.fromSM(e,{endian:"little"})},n.prototype.toScriptNumBuffer=function(){return this.toSM({endian:"little"})},n.prototype.gt=function(e){return this.cmp(e)>0},n.prototype.gte=function(e){return this.cmp(e)>=0},n.prototype.lt=function(e){return this.cmp(e)<0},n.trim=function(e,t){return e.slice(t-e.length,e.length)},n.pad=function(e,r,n){for(var i=new t(n),o=0;o",'"',"`"," ","\r","\n","\t"]),f=["'"].concat(c),l=["%","/","?",";","#"].concat(f),h=["/","?","#"],p=/^[+a-z0-9A-Z_-]{0,63}$/,d=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,y={javascript:!0,"javascript:":!0},g={javascript:!0,"javascript:":!0},m={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},b=r(209);function v(e,t,r){if(e&&i.isObject(e)&&e instanceof o)return e;var n=new o;return n.parse(e,t,r),n}o.prototype.parse=function(e,t,r){if(!i.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),a=-1!==o&&o127?R+="x":R+=O[N];if(!R.match(p)){var K=C.slice(0,I),j=C.slice(I+1),M=O.match(d);M&&(K.push(M[1]),j.unshift(M[2])),j.length&&(v="/"+j.join(".")+v),this.hostname=K.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),B||(this.hostname=n.toASCII(this.hostname));var D=this.port?":"+this.port:"",U=this.hostname||"";this.host=U+D,this.href+=this.host,B&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==v[0]&&(v="/"+v))}if(!y[S])for(I=0,P=f.length;I0)&&r.host.split("@"))&&(r.auth=B.shift(),r.host=r.hostname=B.shift())),r.search=e.search,r.query=e.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!k.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var A=k.slice(-1)[0],x=(r.host||e.host||k.length>1)&&("."===A||".."===A)||""===A,I=0,T=k.length;T>=0;T--)"."===(A=k[T])?k.splice(T,1):".."===A?(k.splice(T,1),I++):I&&(k.splice(T,1),I--);if(!w&&!S)for(;I--;I)k.unshift("..");!w||""===k[0]||k[0]&&"/"===k[0].charAt(0)||k.unshift(""),x&&"/"!==k.join("/").substr(-1)&&k.push("");var B,C=""===k[0]||k[0]&&"/"===k[0].charAt(0);return E&&(r.hostname=r.host=C?"":k.length?k.shift():"",(B=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=B.shift(),r.host=r.hostname=B.shift())),(w=w||r.host&&k.length)&&!C&&k.unshift(""),k.length?r.pathname=k.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var e=this.host,t=a.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isAsync=void 0;var n=function(e){return e&&e.__esModule?e:{default:e}}(r(154));var i="function"==typeof Symbol;function o(e){return i&&"AsyncFunction"===e[Symbol.toStringTag]}t.default=function(e){return o(e)?(0,n.default)(e):e},t.isAsync=o},function(e,t,r){"use strict";const n=r(365),i=r(694),o=r(221);t.Key=n,t.MemoryDatastore=i,t.utils=o},function(e,t,r){"use strict";const n=r(10)(r(1073)).Data,i=["raw","directory","file","metadata","symlink","hamt-sharded-directory"],o=["directory","hamt-sharded-directory"];function s(e,t){if(!(this instanceof s))return new s(e,t);if(-1===i.indexOf(e))throw new Error("Type: "+e+" is not valid");this.type=e,this.data=t,this.blockSizes=[],this.addBlockSize=(e=>{this.blockSizes.push(e)}),this.removeBlockSize=(e=>{this.blockSizes.splice(e,1)}),this.fileSize=(()=>{if(o.indexOf(this.type)>=0)return;let e=0;return this.blockSizes.forEach(t=>{e+=t}),t&&(e+=t.length),e}),this.marshal=(()=>{let e;switch(this.type){case"raw":e=n.DataType.Raw;break;case"directory":e=n.DataType.Directory;break;case"file":e=n.DataType.File;break;case"metadata":e=n.DataType.Metadata;break;case"symlink":e=n.DataType.Symlink;break;case"hamt-sharded-directory":e=n.DataType.HAMTShard;break;default:throw new Error(`Unkown type: "${this.type}"`)}let t=this.fileSize(),r=this.data;this.data&&this.data.length||(r=void 0);let i=this.blockSizes;return this.blockSizes&&this.blockSizes.length||(i=void 0),n.encode({Type:e,Data:r,filesize:t,blocksizes:i,hashType:this.hashType,fanout:this.fanout})})}s.unmarshal=(e=>{const t=n.decode(e);t.Data||(t.Data=void 0);const r=new s(i[t.Type],t.Data);return r.blockSizes=t.blocksizes,r}),e.exports=s},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 u=function(t){if(t)return r(t);if(e())return a(u);var n=(0,i.default)(arguments,1);r.apply(null,[null].concat(n))};a(u)};var n=a(r(54)),i=a(r(102)),o=a(r(103)),s=a(r(34));function a(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default},function(e,t,r){(function(n,i){var o; +var n=function(e,t){return function(){var r=Array.prototype.slice.call(arguments),n=r.length-1,i=r&&r.length>0?r[n]:null;return"function"==typeof i&&i?e.apply(t,r):new Promise(function(n,i){r.push(function(e,t){if(e)return i(e);n(t)}),e.apply(t,r)})}};e.exports=function(e,t){t=t||{};var r=Object.prototype.toString.call(e);if("[object Object]"===r||"[object Array]"===r){var i=t.replace?e:{};for(var o in e)e.hasOwnProperty(o)&&(i[o]=n(e[o]));return i}return n(e,t.context||e)}},function(e,t,r){"use strict";(function(t){var n=r(0),i=r(16),o=r(29),s=r(21);function a(e,t){if(e.length!==t.length)return!1;for(var r=e.length,n=0;n>24&255),r.push(e>>16&255),r.push(e>>8&255),r.push(255&e),new t(r)},integerFromBuffer:function(e){return s.checkArgumentType(e,"Buffer","buffer"),e[0]<<24|e[1]<<16|e[2]<<8|e[3]},integerFromSingleByteBuffer:function(e){return s.checkArgumentType(e,"Buffer","buffer"),e[0]},bufferToHex:function(e){return s.checkArgumentType(e,"Buffer","buffer"),e.toString("hex")},reverse:function(e){for(var t=new n.Buffer(e.length),r=0;r=c.OP_1&&e<=c.OP_16||e===c.OP_1NEGATE)}(e)}function p(e){return a.Array(e)&&e.every(h)}function d(e){return 0===e.length?c.OP_0:1===e.length?e[0]>=1&&e[0]<=16?l+e[0]:129===e[0]?c.OP_1NEGATE:void 0:void 0}function y(e){if(n.isBuffer(e))return e;s(a.Array,e);var t=e.reduce(function(e,t){return n.isBuffer(t)?1===t.length&&void 0!==d(t)?e+1:e+o.encodingLength(t.length)+t.length:e+1},0),r=n.allocUnsafe(t),i=0;if(e.forEach(function(e){if(n.isBuffer(e)){var t=d(e);if(void 0!==t)return r.writeUInt8(t,i),void(i+=1);i+=o.encode(r,e.length,i),e.copy(r,i),i+=e.length}else r.writeUInt8(e,i),i+=1}),i!==r.length)throw new Error("Could not decode chunks");return r}function g(e){if(a.Array(e))return e;s(a.Buffer,e);for(var t=[],r=0;rc.OP_0&&n<=c.OP_PUSHDATA4){var i=o.decode(e,r);if(null===i)return[];if((r+=i.size)+i.number>e.length)return[];var u=e.slice(r,r+i.number);r+=i.number;var f=d(u);void 0!==f?t.push(f):t.push(u)}else t.push(n),r+=1}return t}function m(e){var t=-129&e;return t>0&&t<4}e.exports={compile:y,decompile:g,fromASM:function(e){return s(a.String,e),y(e.split(" ").map(function(e){return void 0!==c[e]?c[e]:(s(a.Hex,e),n.from(e,"hex"))}))},toASM:function(e){return n.isBuffer(e)&&(e=g(e)),e.map(function(e){if(n.isBuffer(e)){var t=d(e);if(void 0===t)return e.toString("hex");e=t}return f[e]}).join(" ")},toStack:function(e){return e=g(e),s(p,e),e.map(function(e){return n.isBuffer(e)?e:e===c.OP_0?n.allocUnsafe(0):u.encode(e-l)})},number:r(400),isCanonicalPubKey:function(e){if(!n.isBuffer(e))return!1;if(e.length<33)return!1;switch(e[0]){case 2:case 3:return 33===e.length;case 4:return 65===e.length}return!1},isCanonicalSignature:function(e){return!!n.isBuffer(e)&&!!m(e[e.length-1])&&i.check(e.slice(0,-1))},isPushOnly:p,isDefinedHashType:m}},function(e,t,r){"use strict";var n=r(18),i=function(e){return!!n.isString(e)&&/^[0-9a-fA-F]+$/.test(e)};e.exports={isValidJSON:function(e){var t;if(!n.isString(e))return!1;try{t=JSON.parse(e)}catch(e){return!1}return"object"==typeof t},isHexa:i,isHexaString:i,cloneArray:function(e){return[].concat(e)},defineImmutable:function(e,t){return Object.keys(t).forEach(function(r){Object.defineProperty(e,r,{configurable:!1,enumerable:!0,value:t[r]})}),e},isNaturalNumber:function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e&&e>=0}}},function(e,t,r){var n=r(1122);function i(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function o(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},r=e.name||"Function wrapped with `once`";return t.onceError=r+" shouldn't be called more than once",t.called=!1,t}e.exports=n(i),e.exports.strict=n(o),i.proto=i(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return i(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return o(this)},configurable:!0})})},function(e,t,r){var n=r(25),i=Math.pow(2,31)-1;function o(e){return n.String(e)&&e.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}o.toJSON=function(){return"BIP32 derivation path"};var s=21e14;var a=n.quacksLike("BigInteger"),u=n.quacksLike("Point"),c=n.compile({r:a,s:a}),f=n.compile({messagePrefix:n.oneOf(n.Buffer,n.String),bip32:{public:n.UInt32,private:n.UInt32},pubKeyHash:n.UInt8,scriptHash:n.UInt8,wif:n.UInt8}),l={BigInt:a,BIP32Path:o,Buffer256bit:n.BufferN(32),ECPoint:u,ECSignature:c,Hash160bit:n.BufferN(20),Hash256bit:n.BufferN(32),Network:f,Satoshi:function(e){return n.UInt53(e)&&e<=s},UInt31:function(e){return n.UInt32(e)&&e<=i}};for(var h in n)l[h]=n[h];e.exports=l},function(e,t,r){"use strict";(function(t){var n=r(74),i=r(21),o=r(18),s=function(e){for(var r=new t(e.length),n=0;ne.size?r=n.trim(r,o):o0&&0==(127&e[e.length-1])&&(e.length<=1||0==(128&e[e.length-2])))throw new Error("non-minimally encoded script number");return n.fromSM(e,{endian:"little"})},n.prototype.toScriptNumBuffer=function(){return this.toSM({endian:"little"})},n.prototype.gt=function(e){return this.cmp(e)>0},n.prototype.gte=function(e){return this.cmp(e)>=0},n.prototype.lt=function(e){return this.cmp(e)<0},n.trim=function(e,t){return e.slice(t-e.length,e.length)},n.pad=function(e,r,n){for(var i=new t(n),o=0;o",'"',"`"," ","\r","\n","\t"]),f=["'"].concat(c),l=["%","/","?",";","#"].concat(f),h=["/","?","#"],p=/^[+a-z0-9A-Z_-]{0,63}$/,d=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,y={javascript:!0,"javascript:":!0},g={javascript:!0,"javascript:":!0},m={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},b=r(209);function v(e,t,r){if(e&&i.isObject(e)&&e instanceof o)return e;var n=new o;return n.parse(e,t,r),n}o.prototype.parse=function(e,t,r){if(!i.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),a=-1!==o&&o127?R+="x":R+=O[N];if(!R.match(p)){var j=C.slice(0,I),M=C.slice(I+1),K=O.match(d);K&&(j.push(K[1]),M.unshift(K[2])),M.length&&(v="/"+M.join(".")+v),this.hostname=j.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),B||(this.hostname=n.toASCII(this.hostname));var D=this.port?":"+this.port:"",U=this.hostname||"";this.host=U+D,this.href+=this.host,B&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==v[0]&&(v="/"+v))}if(!y[S])for(I=0,P=f.length;I0)&&r.host.split("@"))&&(r.auth=B.shift(),r.host=r.hostname=B.shift())),r.search=e.search,r.query=e.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!k.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var A=k.slice(-1)[0],x=(r.host||e.host||k.length>1)&&("."===A||".."===A)||""===A,I=0,T=k.length;T>=0;T--)"."===(A=k[T])?k.splice(T,1):".."===A?(k.splice(T,1),I++):I&&(k.splice(T,1),I--);if(!w&&!S)for(;I--;I)k.unshift("..");!w||""===k[0]||k[0]&&"/"===k[0].charAt(0)||k.unshift(""),x&&"/"!==k.join("/").substr(-1)&&k.push("");var B,C=""===k[0]||k[0]&&"/"===k[0].charAt(0);return E&&(r.hostname=r.host=C?"":k.length?k.shift():"",(B=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=B.shift(),r.host=r.hostname=B.shift())),(w=w||r.host&&k.length)&&!C&&k.unshift(""),k.length?r.pathname=k.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var e=this.host,t=a.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isAsync=void 0;var n=function(e){return e&&e.__esModule?e:{default:e}}(r(154));var i="function"==typeof Symbol;function o(e){return i&&"AsyncFunction"===e[Symbol.toStringTag]}t.default=function(e){return o(e)?(0,n.default)(e):e},t.isAsync=o},function(e,t,r){"use strict";const n=r(362),i=r(685),o=r(222);t.Key=n,t.MemoryDatastore=i,t.utils=o},function(e,t,r){"use strict";const n=r(11)(r(1064)).Data,i=["raw","directory","file","metadata","symlink","hamt-sharded-directory"],o=["directory","hamt-sharded-directory"];function s(e,t){if(!(this instanceof s))return new s(e,t);if(-1===i.indexOf(e))throw new Error("Type: "+e+" is not valid");this.type=e,this.data=t,this.blockSizes=[],this.addBlockSize=(e=>{this.blockSizes.push(e)}),this.removeBlockSize=(e=>{this.blockSizes.splice(e,1)}),this.fileSize=(()=>{if(o.indexOf(this.type)>=0)return;let e=0;return this.blockSizes.forEach(t=>{e+=t}),t&&(e+=t.length),e}),this.marshal=(()=>{let e;switch(this.type){case"raw":e=n.DataType.Raw;break;case"directory":e=n.DataType.Directory;break;case"file":e=n.DataType.File;break;case"metadata":e=n.DataType.Metadata;break;case"symlink":e=n.DataType.Symlink;break;case"hamt-sharded-directory":e=n.DataType.HAMTShard;break;default:throw new Error(`Unkown type: "${this.type}"`)}let t=this.fileSize(),r=this.data;this.data&&this.data.length||(r=void 0);let i=this.blockSizes;return this.blockSizes&&this.blockSizes.length||(i=void 0),n.encode({Type:e,Data:r,filesize:t,blocksizes:i,hashType:this.hashType,fanout:this.fanout})})}s.unmarshal=(e=>{const t=n.decode(e);t.Data||(t.Data=void 0);const r=new s(i[t.Type],t.Data);return r.blockSizes=t.blocksizes,r}),e.exports=s},function(e){e.exports={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255}},function(e,t,r){"use strict";(function(t){var n=r(95),i=r(24),o=r(21),s=e.exports;s.sha1=function(e){return o.checkArgument(i.isBuffer(e)),n.createHash("sha1").update(e).digest()},s.sha1.blocksize=512,s.sha256=function(e){return o.checkArgument(i.isBuffer(e)),n.createHash("sha256").update(e).digest()},s.sha256.blocksize=512,s.sha256sha256=function(e){return o.checkArgument(i.isBuffer(e)),s.sha256(s.sha256(e))},s.ripemd160=function(e){return o.checkArgument(i.isBuffer(e)),n.createHash("ripemd160").update(e).digest()},s.sha256ripemd160=function(e){return o.checkArgument(i.isBuffer(e)),s.ripemd160(s.sha256(e))},s.sha512=function(e){return o.checkArgument(i.isBuffer(e)),n.createHash("sha512").update(e).digest()},s.sha512.blocksize=1024,s.hmac=function(e,r,n){o.checkArgument(i.isBuffer(r)),o.checkArgument(i.isBuffer(n)),o.checkArgument(e.blocksize);var s=e.blocksize/8;if(n.length>s)n=e(n);else if(n-1},Ee.prototype.set=function(e,t){var r=this.__data__,n=Be(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Ae.prototype.clear=function(){this.__data__={hash:new ke,map:new(fe||Ee),string:new ke}},Ae.prototype.delete=function(e){return Fe(this,e).delete(e)},Ae.prototype.get=function(e){return Fe(this,e).get(e)},Ae.prototype.has=function(e){return Fe(this,e).has(e)},Ae.prototype.set=function(e,t){return Fe(this,e).set(e,t),this},xe.prototype.add=xe.prototype.push=function(e){return this.__data__.set(e,o),this},xe.prototype.has=function(e){return this.__data__.has(e)},Ie.prototype.clear=function(){this.__data__=new Ee},Ie.prototype.delete=function(e){return this.__data__.delete(e)},Ie.prototype.get=function(e){return this.__data__.get(e)},Ie.prototype.has=function(e){return this.__data__.has(e)},Ie.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Ee){var i=r.__data__;if(!fe||i.lengthc))return!1;var l=o.get(e);if(l&&o.get(t))return l==t;var h=-1,p=!0,d=i&s?new xe:void 0;for(o.set(e,t),o.set(t,e);++h-1&&e%1==0&&e-1&&e%1==0&&e<=c}function it(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function ot(e){return!!e&&"object"==typeof e}function st(e){return"symbol"==typeof e||ot(e)&&re.call(e)==E}var at=H?function(e){return function(t){return e(t)}}(H):function(e){return ot(e)&&nt(e.length)&&!!L[re.call(e)]};function ut(e){return tt(e)?Te(e):Me(e)}function ct(e){return e}r.exports=function(e,t){return(et(e)?function(e,t){for(var r=-1,n=e?e.length:0,i=Array(n);++r>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 j(e,t,r){K.call(this,e,t,r)}K.prototype.update=function(e){if(!this.finalized){var t,r=typeof e;if("string"!==r){if("object"!==r)throw s;if(null===e)throw s;if(h&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||h&&ArrayBuffer.isView(e)))throw s;t=!0}for(var n,i,o=this.blocks,a=this.byteCount,u=e.length,c=this.blockCount,f=0,l=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[c],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},K.prototype.encodeString=function(e){var t,r=typeof e;if("string"!==r){if("object"!==r)throw s;if(null===e)throw s;if(h&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||h&&ArrayBuffer.isView(e)))throw 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},K.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]+p[15&e]+p[e>>12&15]+p[e>>8&15]+p[e>>20&15]+p[e>>16&15]+p[e>>28&15]+p[e>>24&15];s%t==0&&(M(r),o=0)}return i&&(e=r[o],a+=p[e>>4&15]+p[15&e],i>1&&(a+=p[e>>12&15]+p[e>>8&15]),i>2&&(a+=p[e>>20&15]+p[e>>16&15])),a},K.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 u=new Uint32Array(e);s>8&255,u[e+2]=t>>16&255,u[e+3]=t>>24&255;a%r==0&&M(n)}return o&&(e=a<<2,t=n[s],u[e]=255&t,o>1&&(u[e+1]=t>>8&255),o>2&&(u[e+2]=t>>16&255)),u},j.prototype=new K,j.prototype.finalize=function(){return this.encode(this.outputBits,!0),K.prototype.finalize.call(this)};var M=function(e){var t,r,n,i,o,s,a,u,c,f,l,h,p,d,y,m,b,v,_,w,S,k,E,A,x,I,T,B,C,P,O,R,N,L,K,j,M,D,U,F,q,H,z,V,G,W,$,Y,J,X,Z,Q,ee,te,re,ne,ie,oe,se,ae,ue,ce,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],u=e[4]^e[14]^e[24]^e[34]^e[44],c=e[5]^e[15]^e[25]^e[35]^e[45],f=e[6]^e[16]^e[26]^e[36]^e[46],l=e[7]^e[17]^e[27]^e[37]^e[47],t=(h=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|a>>>31),r=(p=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^(u<<1|c>>>31),r=o^(c<<1|u>>>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|l>>>31),r=a^(l<<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=u^(h<<1|p>>>31),r=c^(p<<1|h>>>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=l^(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,d=e[0],y=e[1],W=e[11]<<4|e[10]>>>28,$=e[10]<<4|e[11]>>>28,B=e[20]<<3|e[21]>>>29,C=e[21]<<3|e[20]>>>29,ae=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,H=e[40]<<18|e[41]>>>14,z=e[41]<<18|e[40]>>>14,L=e[2]<<1|e[3]>>>31,K=e[3]<<1|e[2]>>>31,m=e[13]<<12|e[12]>>>20,b=e[12]<<12|e[13]>>>20,Y=e[22]<<10|e[23]>>>22,J=e[23]<<10|e[22]>>>22,P=e[33]<<13|e[32]>>>19,O=e[32]<<13|e[33]>>>19,ce=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,j=e[14]<<6|e[15]>>>26,M=e[15]<<6|e[14]>>>26,v=e[25]<<11|e[24]>>>21,_=e[24]<<11|e[25]>>>21,X=e[34]<<15|e[35]>>>17,Z=e[35]<<15|e[34]>>>17,R=e[45]<<29|e[44]>>>3,N=e[44]<<29|e[45]>>>3,A=e[6]<<28|e[7]>>>4,x=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,U=e[27]<<25|e[26]>>>7,w=e[36]<<21|e[37]>>>11,S=e[37]<<21|e[36]>>>11,Q=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,V=e[8]<<27|e[9]>>>5,G=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,F=e[38]<<8|e[39]>>>24,q=e[39]<<8|e[38]>>>24,k=e[48]<<14|e[49]>>>18,E=e[49]<<14|e[48]>>>18,e[0]=d^~m&v,e[1]=y^~b&_,e[10]=A^~I&B,e[11]=x^~T&C,e[20]=L^~j&D,e[21]=K^~M&U,e[30]=V^~W&Y,e[31]=G^~$&J,e[40]=te^~ne&oe,e[41]=re^~ie&se,e[2]=m^~v&w,e[3]=b^~_&S,e[12]=I^~B&P,e[13]=T^~C&O,e[22]=j^~D&F,e[23]=M^~U&q,e[32]=W^~Y&X,e[33]=$^~J&Z,e[42]=ne^~oe&ae,e[43]=ie^~se&ue,e[4]=v^~w&k,e[5]=_^~S&E,e[14]=B^~P&R,e[15]=C^~O&N,e[24]=D^~F&H,e[25]=U^~q&z,e[34]=Y^~X&Q,e[35]=J^~Z&ee,e[44]=oe^~ae&ce,e[45]=se^~ue&fe,e[6]=w^~k&d,e[7]=S^~E&y,e[16]=P^~R&A,e[17]=O^~N&x,e[26]=F^~H&L,e[27]=q^~z&K,e[36]=X^~Q&V,e[37]=Z^~ee&G,e[46]=ae^~ce&te,e[47]=ue^~fe&re,e[8]=k^~d&m,e[9]=E^~y&b,e[18]=R^~A&I,e[19]=N^~x&T,e[28]=H^~L&j,e[29]=z^~K&M,e[38]=Q^~V&W,e[39]=ee^~G&$,e[48]=ce^~te&ne,e[49]=fe^~re&ie,e[0]^=g[n],e[1]^=g[n+1]};if(f)e.exports=T;else{for(C=0;Cs)n=e(n);else if(n-1},Ee.prototype.set=function(e,t){var r=this.__data__,n=Be(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Ae.prototype.clear=function(){this.__data__={hash:new ke,map:new(fe||Ee),string:new ke}},Ae.prototype.delete=function(e){return Fe(this,e).delete(e)},Ae.prototype.get=function(e){return Fe(this,e).get(e)},Ae.prototype.has=function(e){return Fe(this,e).has(e)},Ae.prototype.set=function(e,t){return Fe(this,e).set(e,t),this},xe.prototype.add=xe.prototype.push=function(e){return this.__data__.set(e,o),this},xe.prototype.has=function(e){return this.__data__.has(e)},Ie.prototype.clear=function(){this.__data__=new Ee},Ie.prototype.delete=function(e){return this.__data__.delete(e)},Ie.prototype.get=function(e){return this.__data__.get(e)},Ie.prototype.has=function(e){return this.__data__.has(e)},Ie.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Ee){var i=r.__data__;if(!fe||i.lengthc))return!1;var l=o.get(e);if(l&&o.get(t))return l==t;var h=-1,p=!0,d=i&s?new xe:void 0;for(o.set(e,t),o.set(t,e);++h-1&&e%1==0&&e-1&&e%1==0&&e<=c}function it(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function ot(e){return!!e&&"object"==typeof e}function st(e){return"symbol"==typeof e||ot(e)&&re.call(e)==E}var at=H?function(e){return function(t){return e(t)}}(H):function(e){return ot(e)&&nt(e.length)&&!!L[re.call(e)]};function ut(e){return tt(e)?Te(e):je(e)}function ct(e){return e}r.exports=function(e,t){return(et(e)?function(e,t){for(var r=-1,n=e?e.length:0,i=Array(n);++r{if("function"==typeof e)return t=e,e=null,void n.create((e,r)=>{if(e)return t(e);t(null,new a(r))});"function"==typeof e.toJSON?t(null,new a(e)):n.createFromJSON(e,(e,r)=>t(e,new a(r)))}),a.isPeerInfo=(e=>Boolean("object"==typeof e&&e.id&&e.multiaddrs)),e.exports=a},function(e,t,r){"use strict";(function(t){const n=r(44),i=r(26),o=r(985),s=r(269),a=r(20),u=r(14),c=r(62),f=new Error("Sorry, Not Implemented Yet."),l=c.proto(function(e){if(!(this instanceof l))return new l(e);if(null==e&&(e=""),e instanceof t)this.buffer=o.fromBuffer(e);else if("string"==typeof e||e instanceof String){if(e.length>0&&"/"!==e.charAt(0))throw new Error(`multiaddr "${e}" must start with a "/"`);this.buffer=o.fromString(e)}else{if(!(e.buffer&&e.protos&&e.protoCodes))throw new Error("addr must be a string, Buffer, or another Multiaddr");this.buffer=o.fromBuffer(e.buffer)}},{className:"Multiaddr",symbolName:"@multiformats/js-multiaddr/multiaddr"});l.prototype.toString=function(){return o.bufferToString(this.buffer)},l.prototype.toOptions=function(){const e={},t=this.toString().split("/");return e.family="ip4"===t[1]?"ipv4":"ipv6",e.host=t[2],e.transport=t[3],e.port=t[4],e},l.prototype.inspect=function(){return""},l.prototype.protos=function(){return n(this.protoCodes(),function(e){return i(s(e))})},l.prototype.protoCodes=function(){const e=[],t=this.buffer;let r=0;for(;r{if(e[0]===s.names.ipfs.code)return!0})[0][1],u.decode(e)}catch(t){e=null}return e},l.prototype.equals=function(e){return this.buffer.equals(e.buffer)},l.prototype.nodeAddress=function(){const e=this.protoCodes(),t=this.protoNames(),r=this.toString().split("/").slice(1);if(r.length<4)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6}/{address}/{tcp, udp}/{port}".');if(4!==e[0]&&41!==e[0]&&54!==e[0]&&55!==e[0])throw new Error(`no protocol with name: "'${t[0]}'". Must have a valid family name: "{ip4, ip6, dns4, dns6}".`);if("tcp"!==r[2]&&"udp"!==r[2])throw new Error(`no protocol with name: "'${t[1]}'". Must have a valid transport protocol: "{tcp, udp}".`);return{family:41===e[0]||55===e[0]?6:4,address:r[1],port:r[3]}},l.fromNodeAddress=function(e,t){if(!e)throw new Error("requires node address object");if(!t)throw new Error("requires transport protocol");const r="IPv6"===e.family?"ip6":"ip4";return l("/"+[r,e.address,t,e.port].join("/"))},l.prototype.isThinWaistAddress=function(e){const t=(e||this).protos();return!(2!==t.length||4!==t[0].code&&41!==t[0].code||6!==t[1].code&&17!==t[1].code)},l.prototype.fromStupidString=function(e){throw f},l.protocols=s,l.isName=function(e){return!!l.isMultiaddr(e)&&e.protos().some(e=>e.resolvable)},l.resolve=function(e,t){return l.isMultiaddr(e)&&l.isName(e)?t(new Error("not implemented yet")):t(new Error("not a valid name"))},e.exports=l}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(1051),i=r(1052);t.encode=n,t.decode=i.decode,t.decodeFromReader=i.decodeFromReader},function(e,t){e.exports=function(){}},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=r(829).Buffer}catch(e){}function a(e,t,r){for(var n=0,i=Math.min(e.length,r),o=t;o=49&&s<=54?s-49+10:s>=17&&s<=22?s-17+10:15&s}return 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++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;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){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=a(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=a(e,t,r+6),this.words[n]|=i<>>26-o&4194303),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 c=["","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"],f=[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 h(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,u=s/67108864|0;r.words[0]=a;for(var c=1;c>>26,l=67108863&u,h=Math.min(c,t.length-1),p=Math.max(0,c-e.length+1);p<=h;p++){var d=c-p|0;f+=(s=(i=0|e.words[d])*(o=0|t.words[p])+l)/67108864|0,l=67108863&s}r.words[c]=0|l,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(e=e||10,t=0|t||1,16===e||"hex"===e){r="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?c[6-u.length]+u+r:u+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 h=f[e],p=l[e];r="";var d=this.clone();for(d.negative=0;!d.isZero();){var y=d.modn(p).toString(e);r=(d=d.idivn(p)).isZero()?y+r:c[h-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,u="le"===t,c=new e(o),f=this.clone();if(u){for(a=0;!f.isZero();a++)s=f.andln(255),f.iushrn(8),c[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,p=0|s[1],d=8191&p,y=p>>>13,g=0|s[2],m=8191&g,b=g>>>13,v=0|s[3],_=8191&v,w=v>>>13,S=0|s[4],k=8191&S,E=S>>>13,A=0|s[5],x=8191&A,I=A>>>13,T=0|s[6],B=8191&T,C=T>>>13,P=0|s[7],O=8191&P,R=P>>>13,N=0|s[8],L=8191&N,K=N>>>13,j=0|s[9],M=8191&j,D=j>>>13,U=0|a[0],F=8191&U,q=U>>>13,H=0|a[1],z=8191&H,V=H>>>13,G=0|a[2],W=8191&G,$=G>>>13,Y=0|a[3],J=8191&Y,X=Y>>>13,Z=0|a[4],Q=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],ue=8191&ae,ce=ae>>>13,fe=0|a[8],le=8191&fe,he=fe>>>13,pe=0|a[9],de=8191&pe,ye=pe>>>13;r.negative=e.negative^t.negative,r.length=19;var ge=(c+(n=Math.imul(l,F))|0)+((8191&(i=(i=Math.imul(l,q))+Math.imul(h,F)|0))<<13)|0;c=((o=Math.imul(h,q))+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(d,F),i=(i=Math.imul(d,q))+Math.imul(y,F)|0,o=Math.imul(y,q);var me=(c+(n=n+Math.imul(l,z)|0)|0)+((8191&(i=(i=i+Math.imul(l,V)|0)+Math.imul(h,z)|0))<<13)|0;c=((o=o+Math.imul(h,V)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,F),i=(i=Math.imul(m,q))+Math.imul(b,F)|0,o=Math.imul(b,q),n=n+Math.imul(d,z)|0,i=(i=i+Math.imul(d,V)|0)+Math.imul(y,z)|0,o=o+Math.imul(y,V)|0;var be=(c+(n=n+Math.imul(l,W)|0)|0)+((8191&(i=(i=i+Math.imul(l,$)|0)+Math.imul(h,W)|0))<<13)|0;c=((o=o+Math.imul(h,$)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(_,F),i=(i=Math.imul(_,q))+Math.imul(w,F)|0,o=Math.imul(w,q),n=n+Math.imul(m,z)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(b,z)|0,o=o+Math.imul(b,V)|0,n=n+Math.imul(d,W)|0,i=(i=i+Math.imul(d,$)|0)+Math.imul(y,W)|0,o=o+Math.imul(y,$)|0;var ve=(c+(n=n+Math.imul(l,J)|0)|0)+((8191&(i=(i=i+Math.imul(l,X)|0)+Math.imul(h,J)|0))<<13)|0;c=((o=o+Math.imul(h,X)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(k,F),i=(i=Math.imul(k,q))+Math.imul(E,F)|0,o=Math.imul(E,q),n=n+Math.imul(_,z)|0,i=(i=i+Math.imul(_,V)|0)+Math.imul(w,z)|0,o=o+Math.imul(w,V)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,$)|0)+Math.imul(b,W)|0,o=o+Math.imul(b,$)|0,n=n+Math.imul(d,J)|0,i=(i=i+Math.imul(d,X)|0)+Math.imul(y,J)|0,o=o+Math.imul(y,X)|0;var _e=(c+(n=n+Math.imul(l,Q)|0)|0)+((8191&(i=(i=i+Math.imul(l,ee)|0)+Math.imul(h,Q)|0))<<13)|0;c=((o=o+Math.imul(h,ee)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(x,F),i=(i=Math.imul(x,q))+Math.imul(I,F)|0,o=Math.imul(I,q),n=n+Math.imul(k,z)|0,i=(i=i+Math.imul(k,V)|0)+Math.imul(E,z)|0,o=o+Math.imul(E,V)|0,n=n+Math.imul(_,W)|0,i=(i=i+Math.imul(_,$)|0)+Math.imul(w,W)|0,o=o+Math.imul(w,$)|0,n=n+Math.imul(m,J)|0,i=(i=i+Math.imul(m,X)|0)+Math.imul(b,J)|0,o=o+Math.imul(b,X)|0,n=n+Math.imul(d,Q)|0,i=(i=i+Math.imul(d,ee)|0)+Math.imul(y,Q)|0,o=o+Math.imul(y,ee)|0;var we=(c+(n=n+Math.imul(l,re)|0)|0)+((8191&(i=(i=i+Math.imul(l,ne)|0)+Math.imul(h,re)|0))<<13)|0;c=((o=o+Math.imul(h,ne)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(B,F),i=(i=Math.imul(B,q))+Math.imul(C,F)|0,o=Math.imul(C,q),n=n+Math.imul(x,z)|0,i=(i=i+Math.imul(x,V)|0)+Math.imul(I,z)|0,o=o+Math.imul(I,V)|0,n=n+Math.imul(k,W)|0,i=(i=i+Math.imul(k,$)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,$)|0,n=n+Math.imul(_,J)|0,i=(i=i+Math.imul(_,X)|0)+Math.imul(w,J)|0,o=o+Math.imul(w,X)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,ee)|0,n=n+Math.imul(d,re)|0,i=(i=i+Math.imul(d,ne)|0)+Math.imul(y,re)|0,o=o+Math.imul(y,ne)|0;var Se=(c+(n=n+Math.imul(l,oe)|0)|0)+((8191&(i=(i=i+Math.imul(l,se)|0)+Math.imul(h,oe)|0))<<13)|0;c=((o=o+Math.imul(h,se)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(O,F),i=(i=Math.imul(O,q))+Math.imul(R,F)|0,o=Math.imul(R,q),n=n+Math.imul(B,z)|0,i=(i=i+Math.imul(B,V)|0)+Math.imul(C,z)|0,o=o+Math.imul(C,V)|0,n=n+Math.imul(x,W)|0,i=(i=i+Math.imul(x,$)|0)+Math.imul(I,W)|0,o=o+Math.imul(I,$)|0,n=n+Math.imul(k,J)|0,i=(i=i+Math.imul(k,X)|0)+Math.imul(E,J)|0,o=o+Math.imul(E,X)|0,n=n+Math.imul(_,Q)|0,i=(i=i+Math.imul(_,ee)|0)+Math.imul(w,Q)|0,o=o+Math.imul(w,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0,n=n+Math.imul(d,oe)|0,i=(i=i+Math.imul(d,se)|0)+Math.imul(y,oe)|0,o=o+Math.imul(y,se)|0;var ke=(c+(n=n+Math.imul(l,ue)|0)|0)+((8191&(i=(i=i+Math.imul(l,ce)|0)+Math.imul(h,ue)|0))<<13)|0;c=((o=o+Math.imul(h,ce)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(L,F),i=(i=Math.imul(L,q))+Math.imul(K,F)|0,o=Math.imul(K,q),n=n+Math.imul(O,z)|0,i=(i=i+Math.imul(O,V)|0)+Math.imul(R,z)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(B,W)|0,i=(i=i+Math.imul(B,$)|0)+Math.imul(C,W)|0,o=o+Math.imul(C,$)|0,n=n+Math.imul(x,J)|0,i=(i=i+Math.imul(x,X)|0)+Math.imul(I,J)|0,o=o+Math.imul(I,X)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,ee)|0)+Math.imul(E,Q)|0,o=o+Math.imul(E,ee)|0,n=n+Math.imul(_,re)|0,i=(i=i+Math.imul(_,ne)|0)+Math.imul(w,re)|0,o=o+Math.imul(w,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,se)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,se)|0,n=n+Math.imul(d,ue)|0,i=(i=i+Math.imul(d,ce)|0)+Math.imul(y,ue)|0,o=o+Math.imul(y,ce)|0;var Ee=(c+(n=n+Math.imul(l,le)|0)|0)+((8191&(i=(i=i+Math.imul(l,he)|0)+Math.imul(h,le)|0))<<13)|0;c=((o=o+Math.imul(h,he)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(M,F),i=(i=Math.imul(M,q))+Math.imul(D,F)|0,o=Math.imul(D,q),n=n+Math.imul(L,z)|0,i=(i=i+Math.imul(L,V)|0)+Math.imul(K,z)|0,o=o+Math.imul(K,V)|0,n=n+Math.imul(O,W)|0,i=(i=i+Math.imul(O,$)|0)+Math.imul(R,W)|0,o=o+Math.imul(R,$)|0,n=n+Math.imul(B,J)|0,i=(i=i+Math.imul(B,X)|0)+Math.imul(C,J)|0,o=o+Math.imul(C,X)|0,n=n+Math.imul(x,Q)|0,i=(i=i+Math.imul(x,ee)|0)+Math.imul(I,Q)|0,o=o+Math.imul(I,ee)|0,n=n+Math.imul(k,re)|0,i=(i=i+Math.imul(k,ne)|0)+Math.imul(E,re)|0,o=o+Math.imul(E,ne)|0,n=n+Math.imul(_,oe)|0,i=(i=i+Math.imul(_,se)|0)+Math.imul(w,oe)|0,o=o+Math.imul(w,se)|0,n=n+Math.imul(m,ue)|0,i=(i=i+Math.imul(m,ce)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,ce)|0,n=n+Math.imul(d,le)|0,i=(i=i+Math.imul(d,he)|0)+Math.imul(y,le)|0,o=o+Math.imul(y,he)|0;var Ae=(c+(n=n+Math.imul(l,de)|0)|0)+((8191&(i=(i=i+Math.imul(l,ye)|0)+Math.imul(h,de)|0))<<13)|0;c=((o=o+Math.imul(h,ye)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(M,z),i=(i=Math.imul(M,V))+Math.imul(D,z)|0,o=Math.imul(D,V),n=n+Math.imul(L,W)|0,i=(i=i+Math.imul(L,$)|0)+Math.imul(K,W)|0,o=o+Math.imul(K,$)|0,n=n+Math.imul(O,J)|0,i=(i=i+Math.imul(O,X)|0)+Math.imul(R,J)|0,o=o+Math.imul(R,X)|0,n=n+Math.imul(B,Q)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,ee)|0,n=n+Math.imul(x,re)|0,i=(i=i+Math.imul(x,ne)|0)+Math.imul(I,re)|0,o=o+Math.imul(I,ne)|0,n=n+Math.imul(k,oe)|0,i=(i=i+Math.imul(k,se)|0)+Math.imul(E,oe)|0,o=o+Math.imul(E,se)|0,n=n+Math.imul(_,ue)|0,i=(i=i+Math.imul(_,ce)|0)+Math.imul(w,ue)|0,o=o+Math.imul(w,ce)|0,n=n+Math.imul(m,le)|0,i=(i=i+Math.imul(m,he)|0)+Math.imul(b,le)|0,o=o+Math.imul(b,he)|0;var xe=(c+(n=n+Math.imul(d,de)|0)|0)+((8191&(i=(i=i+Math.imul(d,ye)|0)+Math.imul(y,de)|0))<<13)|0;c=((o=o+Math.imul(y,ye)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(M,W),i=(i=Math.imul(M,$))+Math.imul(D,W)|0,o=Math.imul(D,$),n=n+Math.imul(L,J)|0,i=(i=i+Math.imul(L,X)|0)+Math.imul(K,J)|0,o=o+Math.imul(K,X)|0,n=n+Math.imul(O,Q)|0,i=(i=i+Math.imul(O,ee)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(C,re)|0,o=o+Math.imul(C,ne)|0,n=n+Math.imul(x,oe)|0,i=(i=i+Math.imul(x,se)|0)+Math.imul(I,oe)|0,o=o+Math.imul(I,se)|0,n=n+Math.imul(k,ue)|0,i=(i=i+Math.imul(k,ce)|0)+Math.imul(E,ue)|0,o=o+Math.imul(E,ce)|0,n=n+Math.imul(_,le)|0,i=(i=i+Math.imul(_,he)|0)+Math.imul(w,le)|0,o=o+Math.imul(w,he)|0;var Ie=(c+(n=n+Math.imul(m,de)|0)|0)+((8191&(i=(i=i+Math.imul(m,ye)|0)+Math.imul(b,de)|0))<<13)|0;c=((o=o+Math.imul(b,ye)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(M,J),i=(i=Math.imul(M,X))+Math.imul(D,J)|0,o=Math.imul(D,X),n=n+Math.imul(L,Q)|0,i=(i=i+Math.imul(L,ee)|0)+Math.imul(K,Q)|0,o=o+Math.imul(K,ee)|0,n=n+Math.imul(O,re)|0,i=(i=i+Math.imul(O,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,se)|0)+Math.imul(C,oe)|0,o=o+Math.imul(C,se)|0,n=n+Math.imul(x,ue)|0,i=(i=i+Math.imul(x,ce)|0)+Math.imul(I,ue)|0,o=o+Math.imul(I,ce)|0,n=n+Math.imul(k,le)|0,i=(i=i+Math.imul(k,he)|0)+Math.imul(E,le)|0,o=o+Math.imul(E,he)|0;var Te=(c+(n=n+Math.imul(_,de)|0)|0)+((8191&(i=(i=i+Math.imul(_,ye)|0)+Math.imul(w,de)|0))<<13)|0;c=((o=o+Math.imul(w,ye)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(M,Q),i=(i=Math.imul(M,ee))+Math.imul(D,Q)|0,o=Math.imul(D,ee),n=n+Math.imul(L,re)|0,i=(i=i+Math.imul(L,ne)|0)+Math.imul(K,re)|0,o=o+Math.imul(K,ne)|0,n=n+Math.imul(O,oe)|0,i=(i=i+Math.imul(O,se)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,se)|0,n=n+Math.imul(B,ue)|0,i=(i=i+Math.imul(B,ce)|0)+Math.imul(C,ue)|0,o=o+Math.imul(C,ce)|0,n=n+Math.imul(x,le)|0,i=(i=i+Math.imul(x,he)|0)+Math.imul(I,le)|0,o=o+Math.imul(I,he)|0;var Be=(c+(n=n+Math.imul(k,de)|0)|0)+((8191&(i=(i=i+Math.imul(k,ye)|0)+Math.imul(E,de)|0))<<13)|0;c=((o=o+Math.imul(E,ye)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(M,re),i=(i=Math.imul(M,ne))+Math.imul(D,re)|0,o=Math.imul(D,ne),n=n+Math.imul(L,oe)|0,i=(i=i+Math.imul(L,se)|0)+Math.imul(K,oe)|0,o=o+Math.imul(K,se)|0,n=n+Math.imul(O,ue)|0,i=(i=i+Math.imul(O,ce)|0)+Math.imul(R,ue)|0,o=o+Math.imul(R,ce)|0,n=n+Math.imul(B,le)|0,i=(i=i+Math.imul(B,he)|0)+Math.imul(C,le)|0,o=o+Math.imul(C,he)|0;var Ce=(c+(n=n+Math.imul(x,de)|0)|0)+((8191&(i=(i=i+Math.imul(x,ye)|0)+Math.imul(I,de)|0))<<13)|0;c=((o=o+Math.imul(I,ye)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,n=Math.imul(M,oe),i=(i=Math.imul(M,se))+Math.imul(D,oe)|0,o=Math.imul(D,se),n=n+Math.imul(L,ue)|0,i=(i=i+Math.imul(L,ce)|0)+Math.imul(K,ue)|0,o=o+Math.imul(K,ce)|0,n=n+Math.imul(O,le)|0,i=(i=i+Math.imul(O,he)|0)+Math.imul(R,le)|0,o=o+Math.imul(R,he)|0;var Pe=(c+(n=n+Math.imul(B,de)|0)|0)+((8191&(i=(i=i+Math.imul(B,ye)|0)+Math.imul(C,de)|0))<<13)|0;c=((o=o+Math.imul(C,ye)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(M,ue),i=(i=Math.imul(M,ce))+Math.imul(D,ue)|0,o=Math.imul(D,ce),n=n+Math.imul(L,le)|0,i=(i=i+Math.imul(L,he)|0)+Math.imul(K,le)|0,o=o+Math.imul(K,he)|0;var Oe=(c+(n=n+Math.imul(O,de)|0)|0)+((8191&(i=(i=i+Math.imul(O,ye)|0)+Math.imul(R,de)|0))<<13)|0;c=((o=o+Math.imul(R,ye)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(M,le),i=(i=Math.imul(M,he))+Math.imul(D,le)|0,o=Math.imul(D,he);var Re=(c+(n=n+Math.imul(L,de)|0)|0)+((8191&(i=(i=i+Math.imul(L,ye)|0)+Math.imul(K,de)|0))<<13)|0;c=((o=o+Math.imul(K,ye)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863;var Ne=(c+(n=Math.imul(M,de))|0)+((8191&(i=(i=Math.imul(M,ye))+Math.imul(D,de)|0))<<13)|0;return c=((o=Math.imul(D,ye))+(i>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,u[0]=ge,u[1]=me,u[2]=be,u[3]=ve,u[4]=_e,u[5]=we,u[6]=Se,u[7]=ke,u[8]=Ee,u[9]=Ae,u[10]=xe,u[11]=Ie,u[12]=Te,u[13]=Be,u[14]=Ce,u[15]=Pe,u[16]=Oe,u[17]=Re,u[18]=Ne,0!==c&&(u[19]=c,r.length++),r};function d(e,t,r){return(new y).mulp(e,t,r)}function y(e,t){this.x=e,this.y=t}Math.imul||(p=h),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?h(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):d(this,e,t)},y.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},y.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,c=0;c=0&&(0!==f||c>=i);c--){var l=0|this.words[c];this.words[c]=f<<26-o|l>>>o,f=l&a}return u&&0!==f&&(u.words[u.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)-(u/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,u=n.length-i.length;if("mod"!==t){(a=new o(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c=0;l--){var h=67108864*(0|n.words[i.length+l])+(0|n.words[i.length+l-1]);for(h=Math.min(h/s|0,67108863),n._ishlnsubmul(i,h,l);0!==n.negative;)h--,n.negative=0,n._ishlnsubmul(i,1,l),n.isZero()||(n.negative^=1);a&&(a.words[l]=h)}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),u=new o(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),l=t.clone();!t.isZero();){for(var h=0,p=1;0==(t.words[0]&p)&&h<26;++h,p<<=1);if(h>0)for(t.iushrn(h);h-- >0;)(i.isOdd()||s.isOdd())&&(i.iadd(f),s.isub(l)),i.iushrn(1),s.iushrn(1);for(var d=0,y=1;0==(r.words[0]&y)&&d<26;++d,y<<=1);if(d>0)for(r.iushrn(d);d-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(f),u.isub(l)),a.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(a),s.isub(u)):(r.isub(t),a.isub(i),u.isub(s))}return{a:a,b:u,gcd:r.iushln(c)}},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),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(t.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(t.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var l=0,h=1;0==(r.words[0]&h)&&l<26;++l,h<<=1);if(l>0)for(r.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(u),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 S(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 b(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function v(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function _(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function w(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function S(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){S.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):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(b,m),b.prototype.split=function(e,t){for(var r=4194303,n=Math.min(e.length,9),i=0;i>>22,o=s}o>>>=22,e.words[i-10]=o,0===o&&e.length>10?e.length-=10:e.length-=9},b.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 b;else if("p224"===e)t=new v;else if("p192"===e)t=new _;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new w}return g[e]=t,t},S.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},S.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")},S.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},S.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},S.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)},S.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},S.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)},S.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},S.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},S.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},S.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},S.prototype.isqr=function(e){return this.imul(e,e.clone())},S.prototype.sqr=function(e){return this.mul(e,e)},S.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),u=a.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var l=this.pow(f,i),h=this.pow(e,i.addn(1).iushrn(1)),p=this.pow(e,i),d=s;0!==p.cmp(a);){for(var y=p,g=0;0!==y.cmp(a);g++)y=y.redSqr();n(g=0;n--){for(var c=t.words[n],f=u-1;f>=0;f--){var l=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==l||0!==s?(s<<=1,s|=l,(4==++a||0===n&&0===f)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}u=26}return i},S.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},S.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new k(e)},i(k,S),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)}}(void 0===e||e,this)}).call(this,r(27)(e))},function(e,t,r){"use strict";var n=t;n.version=r(830).version,n.utils=r(831),n.rand=r(832),n.curve=r(174),n.curves=r(838),n.ec=r(846),n.eddsa=r(850)},function(e,t,r){"use strict";(function(t){var n=r(24),i=r(17),o=function e(t){if(!(this instanceof e))return new e(t);t?this.set(t):this.bufs=[]};o.prototype.set=function(e){return this.bufs=e.bufs||this.bufs||[],this},o.prototype.toBuffer=function(){return this.concat()},o.prototype.concat=function(){return t.concat(this.bufs)},o.prototype.write=function(e){return i(n.isBuffer(e)),this.bufs.push(e),this},o.prototype.writeReverse=function(e){return i(n.isBuffer(e)),this.bufs.push(n.reverse(e)),this},o.prototype.writeUInt8=function(e){var r=new t(1);return r.writeUInt8(e,0),this.write(r),this},o.prototype.writeUInt16BE=function(e){var r=new t(2);return r.writeUInt16BE(e,0),this.write(r),this},o.prototype.writeUInt16LE=function(e){var r=new t(2);return r.writeUInt16LE(e,0),this.write(r),this},o.prototype.writeUInt32BE=function(e){var r=new t(4);return r.writeUInt32BE(e,0),this.write(r),this},o.prototype.writeInt32LE=function(e){var r=new t(4);return r.writeInt32LE(e,0),this.write(r),this},o.prototype.writeUInt32LE=function(e){var r=new t(4);return r.writeUInt32LE(e,0),this.write(r),this},o.prototype.writeUInt64BEBN=function(e){var t=e.toBuffer({size:8});return this.write(t),this},o.prototype.writeUInt64LEBN=function(e){var t=e.toBuffer({size:8});return this.writeReverse(t),this},o.prototype.writeVarintNum=function(e){var t=o.varintBufNum(e);return this.write(t),this},o.prototype.writeVarintBN=function(e){var t=o.varintBufBN(e);return this.write(t),this},o.varintBufNum=function(e){var r=void 0;return e<253?(r=new t(1)).writeUInt8(e,0):e<65536?((r=new t(3)).writeUInt8(253,0),r.writeUInt16LE(e,1)):e<4294967296?((r=new t(5)).writeUInt8(254,0),r.writeUInt32LE(e,1)):((r=new t(9)).writeUInt8(255,0),r.writeInt32LE(-1&e,1),r.writeUInt32LE(Math.floor(e/4294967296),5)),r},o.varintBufBN=function(e){var r=void 0,n=e.toNumber();if(n<253)(r=new t(1)).writeUInt8(n,0);else if(n<65536)(r=new t(3)).writeUInt8(253,0),r.writeUInt16LE(n,1);else if(n<4294967296)(r=new t(5)).writeUInt8(254,0),r.writeUInt32LE(n,1);else{var i=new o;i.writeUInt8(255),i.writeUInt64LEBN(e);r=i.concat()}return r},e.exports=o}).call(this,r(0).Buffer)},function(e,t){ + */!function(){"use strict";var s="input is invalid type",a="object"==typeof window,u=a?window:{};u.JS_SHA3_NO_WINDOW&&(a=!1);var c=!a&&"object"==typeof self;!u.JS_SHA3_NO_NODE_JS&&"object"==typeof n&&n.versions&&n.versions.node?u=i:c&&(u=self);var f=!u.JS_SHA3_NO_COMMON_JS&&"object"==typeof e&&e.exports,l=r(737),h=!u.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,p="0123456789abcdef".split(""),d=[4,1024,262144,67108864],y=[0,8,16,24],g=[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],m=[224,256,384,512],b=[128,256],v=["hex","buffer","arrayBuffer","array","digest"],_={128:168,256:136};!u.JS_SHA3_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!h||!u.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 w=function(e,t,r){return function(n){return new j(e,t,e).update(n)[r]()}},S=function(e,t,r){return function(n,i){return new j(e,t,i).update(n)[r]()}},k=function(e,t,r){return function(t,n,i,o){return T["cshake"+e].update(t,n,i,o)[r]()}},E=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 M(e,t,r){j.call(this,e,t,r)}j.prototype.update=function(e){if(!this.finalized){var t,r=typeof e;if("string"!==r){if("object"!==r)throw s;if(null===e)throw s;if(h&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||h&&ArrayBuffer.isView(e)))throw s;t=!0}for(var n,i,o=this.blocks,a=this.byteCount,u=e.length,c=this.blockCount,f=0,l=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[c],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},j.prototype.encodeString=function(e){var t,r=typeof e;if("string"!==r){if("object"!==r)throw s;if(null===e)throw s;if(h&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||h&&ArrayBuffer.isView(e)))throw 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},j.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]+p[15&e]+p[e>>12&15]+p[e>>8&15]+p[e>>20&15]+p[e>>16&15]+p[e>>28&15]+p[e>>24&15];s%t==0&&(K(r),o=0)}return i&&(e=r[o],a+=p[e>>4&15]+p[15&e],i>1&&(a+=p[e>>12&15]+p[e>>8&15]),i>2&&(a+=p[e>>20&15]+p[e>>16&15])),a},j.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 u=new Uint32Array(e);s>8&255,u[e+2]=t>>16&255,u[e+3]=t>>24&255;a%r==0&&K(n)}return o&&(e=a<<2,t=n[s],u[e]=255&t,o>1&&(u[e+1]=t>>8&255),o>2&&(u[e+2]=t>>16&255)),u},M.prototype=new j,M.prototype.finalize=function(){return this.encode(this.outputBits,!0),j.prototype.finalize.call(this)};var K=function(e){var t,r,n,i,o,s,a,u,c,f,l,h,p,d,y,m,b,v,_,w,S,k,E,A,x,I,T,B,C,P,O,R,N,L,j,M,K,D,U,F,q,H,z,V,G,W,$,Y,J,X,Z,Q,ee,te,re,ne,ie,oe,se,ae,ue,ce,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],u=e[4]^e[14]^e[24]^e[34]^e[44],c=e[5]^e[15]^e[25]^e[35]^e[45],f=e[6]^e[16]^e[26]^e[36]^e[46],l=e[7]^e[17]^e[27]^e[37]^e[47],t=(h=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|a>>>31),r=(p=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^(u<<1|c>>>31),r=o^(c<<1|u>>>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|l>>>31),r=a^(l<<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=u^(h<<1|p>>>31),r=c^(p<<1|h>>>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=l^(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,d=e[0],y=e[1],W=e[11]<<4|e[10]>>>28,$=e[10]<<4|e[11]>>>28,B=e[20]<<3|e[21]>>>29,C=e[21]<<3|e[20]>>>29,ae=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,H=e[40]<<18|e[41]>>>14,z=e[41]<<18|e[40]>>>14,L=e[2]<<1|e[3]>>>31,j=e[3]<<1|e[2]>>>31,m=e[13]<<12|e[12]>>>20,b=e[12]<<12|e[13]>>>20,Y=e[22]<<10|e[23]>>>22,J=e[23]<<10|e[22]>>>22,P=e[33]<<13|e[32]>>>19,O=e[32]<<13|e[33]>>>19,ce=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,M=e[14]<<6|e[15]>>>26,K=e[15]<<6|e[14]>>>26,v=e[25]<<11|e[24]>>>21,_=e[24]<<11|e[25]>>>21,X=e[34]<<15|e[35]>>>17,Z=e[35]<<15|e[34]>>>17,R=e[45]<<29|e[44]>>>3,N=e[44]<<29|e[45]>>>3,A=e[6]<<28|e[7]>>>4,x=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,U=e[27]<<25|e[26]>>>7,w=e[36]<<21|e[37]>>>11,S=e[37]<<21|e[36]>>>11,Q=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,V=e[8]<<27|e[9]>>>5,G=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,F=e[38]<<8|e[39]>>>24,q=e[39]<<8|e[38]>>>24,k=e[48]<<14|e[49]>>>18,E=e[49]<<14|e[48]>>>18,e[0]=d^~m&v,e[1]=y^~b&_,e[10]=A^~I&B,e[11]=x^~T&C,e[20]=L^~M&D,e[21]=j^~K&U,e[30]=V^~W&Y,e[31]=G^~$&J,e[40]=te^~ne&oe,e[41]=re^~ie&se,e[2]=m^~v&w,e[3]=b^~_&S,e[12]=I^~B&P,e[13]=T^~C&O,e[22]=M^~D&F,e[23]=K^~U&q,e[32]=W^~Y&X,e[33]=$^~J&Z,e[42]=ne^~oe&ae,e[43]=ie^~se&ue,e[4]=v^~w&k,e[5]=_^~S&E,e[14]=B^~P&R,e[15]=C^~O&N,e[24]=D^~F&H,e[25]=U^~q&z,e[34]=Y^~X&Q,e[35]=J^~Z&ee,e[44]=oe^~ae&ce,e[45]=se^~ue&fe,e[6]=w^~k&d,e[7]=S^~E&y,e[16]=P^~R&A,e[17]=O^~N&x,e[26]=F^~H&L,e[27]=q^~z&j,e[36]=X^~Q&V,e[37]=Z^~ee&G,e[46]=ae^~ce&te,e[47]=ue^~fe&re,e[8]=k^~d&m,e[9]=E^~y&b,e[18]=R^~A&I,e[19]=N^~x&T,e[28]=H^~L&M,e[29]=z^~j&K,e[38]=Q^~V&W,e[39]=ee^~G&$,e[48]=ce^~te&ne,e[49]=fe^~re&ie,e[0]^=g[n],e[1]^=g[n+1]};if(f)e.exports=T;else{for(C=0;C{if("function"==typeof e)return t=e,e=null,void n.create((e,r)=>{if(e)return t(e);t(null,new a(r))});"function"==typeof e.toJSON?t(null,new a(e)):n.createFromJSON(e,(e,r)=>t(e,new a(r)))}),a.isPeerInfo=(e=>Boolean("object"==typeof e&&e.id&&e.multiaddrs)),e.exports=a},function(e,t,r){"use strict";(function(t){const n=r(39),i=r(26),o=r(976),s=r(270),a=r(20),u=r(14),c=r(58),f=new Error("Sorry, Not Implemented Yet."),l=c.proto(function(e){if(!(this instanceof l))return new l(e);if(null==e&&(e=""),e instanceof t)this.buffer=o.fromBuffer(e);else if("string"==typeof e||e instanceof String){if(e.length>0&&"/"!==e.charAt(0))throw new Error(`multiaddr "${e}" must start with a "/"`);this.buffer=o.fromString(e)}else{if(!(e.buffer&&e.protos&&e.protoCodes))throw new Error("addr must be a string, Buffer, or another Multiaddr");this.buffer=o.fromBuffer(e.buffer)}},{className:"Multiaddr",symbolName:"@multiformats/js-multiaddr/multiaddr"});l.prototype.toString=function(){return o.bufferToString(this.buffer)},l.prototype.toOptions=function(){const e={},t=this.toString().split("/");return e.family="ip4"===t[1]?"ipv4":"ipv6",e.host=t[2],e.transport=t[3],e.port=t[4],e},l.prototype.inspect=function(){return""},l.prototype.protos=function(){return n(this.protoCodes(),function(e){return i(s(e))})},l.prototype.protoCodes=function(){const e=[],t=this.buffer;let r=0;for(;r{if(e[0]===s.names.ipfs.code)return!0})[0][1],u.decode(e)}catch(t){e=null}return e},l.prototype.equals=function(e){return this.buffer.equals(e.buffer)},l.prototype.nodeAddress=function(){const e=this.protoCodes(),t=this.protoNames(),r=this.toString().split("/").slice(1);if(r.length<4)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6}/{address}/{tcp, udp}/{port}".');if(4!==e[0]&&41!==e[0]&&54!==e[0]&&55!==e[0])throw new Error(`no protocol with name: "'${t[0]}'". Must have a valid family name: "{ip4, ip6, dns4, dns6}".`);if("tcp"!==r[2]&&"udp"!==r[2])throw new Error(`no protocol with name: "'${t[1]}'". Must have a valid transport protocol: "{tcp, udp}".`);return{family:41===e[0]||55===e[0]?6:4,address:r[1],port:r[3]}},l.fromNodeAddress=function(e,t){if(!e)throw new Error("requires node address object");if(!t)throw new Error("requires transport protocol");const r="IPv6"===e.family?"ip6":"ip4";return l("/"+[r,e.address,t,e.port].join("/"))},l.prototype.isThinWaistAddress=function(e){const t=(e||this).protos();return!(2!==t.length||4!==t[0].code&&41!==t[0].code||6!==t[1].code&&17!==t[1].code)},l.prototype.fromStupidString=function(e){throw f},l.protocols=s,l.isName=function(e){return!!l.isMultiaddr(e)&&e.protos().some(e=>e.resolvable)},l.resolve=function(e,t){return l.isMultiaddr(e)&&l.isName(e)?t(new Error("not implemented yet")):t(new Error("not a valid name"))},e.exports=l}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(1042),i=r(1043);t.encode=n,t.decode=i.decode,t.decodeFromReader=i.decodeFromReader},function(e,t){e.exports=function(){}},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=r(820).Buffer}catch(e){}function a(e,t,r){for(var n=0,i=Math.min(e.length,r),o=t;o=49&&s<=54?s-49+10:s>=17&&s<=22?s-17+10:15&s}return 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++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;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){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=a(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=a(e,t,r+6),this.words[n]|=i<>>26-o&4194303),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 c=["","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"],f=[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 h(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,u=s/67108864|0;r.words[0]=a;for(var c=1;c>>26,l=67108863&u,h=Math.min(c,t.length-1),p=Math.max(0,c-e.length+1);p<=h;p++){var d=c-p|0;f+=(s=(i=0|e.words[d])*(o=0|t.words[p])+l)/67108864|0,l=67108863&s}r.words[c]=0|l,u=0|f}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(e=e||10,t=0|t||1,16===e||"hex"===e){r="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?c[6-u.length]+u+r:u+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 h=f[e],p=l[e];r="";var d=this.clone();for(d.negative=0;!d.isZero();){var y=d.modn(p).toString(e);r=(d=d.idivn(p)).isZero()?y+r:c[h-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,u="le"===t,c=new e(o),f=this.clone();if(u){for(a=0;!f.isZero();a++)s=f.andln(255),f.iushrn(8),c[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,p=0|s[1],d=8191&p,y=p>>>13,g=0|s[2],m=8191&g,b=g>>>13,v=0|s[3],_=8191&v,w=v>>>13,S=0|s[4],k=8191&S,E=S>>>13,A=0|s[5],x=8191&A,I=A>>>13,T=0|s[6],B=8191&T,C=T>>>13,P=0|s[7],O=8191&P,R=P>>>13,N=0|s[8],L=8191&N,j=N>>>13,M=0|s[9],K=8191&M,D=M>>>13,U=0|a[0],F=8191&U,q=U>>>13,H=0|a[1],z=8191&H,V=H>>>13,G=0|a[2],W=8191&G,$=G>>>13,Y=0|a[3],J=8191&Y,X=Y>>>13,Z=0|a[4],Q=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],ue=8191&ae,ce=ae>>>13,fe=0|a[8],le=8191&fe,he=fe>>>13,pe=0|a[9],de=8191&pe,ye=pe>>>13;r.negative=e.negative^t.negative,r.length=19;var ge=(c+(n=Math.imul(l,F))|0)+((8191&(i=(i=Math.imul(l,q))+Math.imul(h,F)|0))<<13)|0;c=((o=Math.imul(h,q))+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(d,F),i=(i=Math.imul(d,q))+Math.imul(y,F)|0,o=Math.imul(y,q);var me=(c+(n=n+Math.imul(l,z)|0)|0)+((8191&(i=(i=i+Math.imul(l,V)|0)+Math.imul(h,z)|0))<<13)|0;c=((o=o+Math.imul(h,V)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,F),i=(i=Math.imul(m,q))+Math.imul(b,F)|0,o=Math.imul(b,q),n=n+Math.imul(d,z)|0,i=(i=i+Math.imul(d,V)|0)+Math.imul(y,z)|0,o=o+Math.imul(y,V)|0;var be=(c+(n=n+Math.imul(l,W)|0)|0)+((8191&(i=(i=i+Math.imul(l,$)|0)+Math.imul(h,W)|0))<<13)|0;c=((o=o+Math.imul(h,$)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(_,F),i=(i=Math.imul(_,q))+Math.imul(w,F)|0,o=Math.imul(w,q),n=n+Math.imul(m,z)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(b,z)|0,o=o+Math.imul(b,V)|0,n=n+Math.imul(d,W)|0,i=(i=i+Math.imul(d,$)|0)+Math.imul(y,W)|0,o=o+Math.imul(y,$)|0;var ve=(c+(n=n+Math.imul(l,J)|0)|0)+((8191&(i=(i=i+Math.imul(l,X)|0)+Math.imul(h,J)|0))<<13)|0;c=((o=o+Math.imul(h,X)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(k,F),i=(i=Math.imul(k,q))+Math.imul(E,F)|0,o=Math.imul(E,q),n=n+Math.imul(_,z)|0,i=(i=i+Math.imul(_,V)|0)+Math.imul(w,z)|0,o=o+Math.imul(w,V)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,$)|0)+Math.imul(b,W)|0,o=o+Math.imul(b,$)|0,n=n+Math.imul(d,J)|0,i=(i=i+Math.imul(d,X)|0)+Math.imul(y,J)|0,o=o+Math.imul(y,X)|0;var _e=(c+(n=n+Math.imul(l,Q)|0)|0)+((8191&(i=(i=i+Math.imul(l,ee)|0)+Math.imul(h,Q)|0))<<13)|0;c=((o=o+Math.imul(h,ee)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(x,F),i=(i=Math.imul(x,q))+Math.imul(I,F)|0,o=Math.imul(I,q),n=n+Math.imul(k,z)|0,i=(i=i+Math.imul(k,V)|0)+Math.imul(E,z)|0,o=o+Math.imul(E,V)|0,n=n+Math.imul(_,W)|0,i=(i=i+Math.imul(_,$)|0)+Math.imul(w,W)|0,o=o+Math.imul(w,$)|0,n=n+Math.imul(m,J)|0,i=(i=i+Math.imul(m,X)|0)+Math.imul(b,J)|0,o=o+Math.imul(b,X)|0,n=n+Math.imul(d,Q)|0,i=(i=i+Math.imul(d,ee)|0)+Math.imul(y,Q)|0,o=o+Math.imul(y,ee)|0;var we=(c+(n=n+Math.imul(l,re)|0)|0)+((8191&(i=(i=i+Math.imul(l,ne)|0)+Math.imul(h,re)|0))<<13)|0;c=((o=o+Math.imul(h,ne)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(B,F),i=(i=Math.imul(B,q))+Math.imul(C,F)|0,o=Math.imul(C,q),n=n+Math.imul(x,z)|0,i=(i=i+Math.imul(x,V)|0)+Math.imul(I,z)|0,o=o+Math.imul(I,V)|0,n=n+Math.imul(k,W)|0,i=(i=i+Math.imul(k,$)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,$)|0,n=n+Math.imul(_,J)|0,i=(i=i+Math.imul(_,X)|0)+Math.imul(w,J)|0,o=o+Math.imul(w,X)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,ee)|0,n=n+Math.imul(d,re)|0,i=(i=i+Math.imul(d,ne)|0)+Math.imul(y,re)|0,o=o+Math.imul(y,ne)|0;var Se=(c+(n=n+Math.imul(l,oe)|0)|0)+((8191&(i=(i=i+Math.imul(l,se)|0)+Math.imul(h,oe)|0))<<13)|0;c=((o=o+Math.imul(h,se)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(O,F),i=(i=Math.imul(O,q))+Math.imul(R,F)|0,o=Math.imul(R,q),n=n+Math.imul(B,z)|0,i=(i=i+Math.imul(B,V)|0)+Math.imul(C,z)|0,o=o+Math.imul(C,V)|0,n=n+Math.imul(x,W)|0,i=(i=i+Math.imul(x,$)|0)+Math.imul(I,W)|0,o=o+Math.imul(I,$)|0,n=n+Math.imul(k,J)|0,i=(i=i+Math.imul(k,X)|0)+Math.imul(E,J)|0,o=o+Math.imul(E,X)|0,n=n+Math.imul(_,Q)|0,i=(i=i+Math.imul(_,ee)|0)+Math.imul(w,Q)|0,o=o+Math.imul(w,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0,n=n+Math.imul(d,oe)|0,i=(i=i+Math.imul(d,se)|0)+Math.imul(y,oe)|0,o=o+Math.imul(y,se)|0;var ke=(c+(n=n+Math.imul(l,ue)|0)|0)+((8191&(i=(i=i+Math.imul(l,ce)|0)+Math.imul(h,ue)|0))<<13)|0;c=((o=o+Math.imul(h,ce)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(L,F),i=(i=Math.imul(L,q))+Math.imul(j,F)|0,o=Math.imul(j,q),n=n+Math.imul(O,z)|0,i=(i=i+Math.imul(O,V)|0)+Math.imul(R,z)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(B,W)|0,i=(i=i+Math.imul(B,$)|0)+Math.imul(C,W)|0,o=o+Math.imul(C,$)|0,n=n+Math.imul(x,J)|0,i=(i=i+Math.imul(x,X)|0)+Math.imul(I,J)|0,o=o+Math.imul(I,X)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,ee)|0)+Math.imul(E,Q)|0,o=o+Math.imul(E,ee)|0,n=n+Math.imul(_,re)|0,i=(i=i+Math.imul(_,ne)|0)+Math.imul(w,re)|0,o=o+Math.imul(w,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,se)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,se)|0,n=n+Math.imul(d,ue)|0,i=(i=i+Math.imul(d,ce)|0)+Math.imul(y,ue)|0,o=o+Math.imul(y,ce)|0;var Ee=(c+(n=n+Math.imul(l,le)|0)|0)+((8191&(i=(i=i+Math.imul(l,he)|0)+Math.imul(h,le)|0))<<13)|0;c=((o=o+Math.imul(h,he)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(K,F),i=(i=Math.imul(K,q))+Math.imul(D,F)|0,o=Math.imul(D,q),n=n+Math.imul(L,z)|0,i=(i=i+Math.imul(L,V)|0)+Math.imul(j,z)|0,o=o+Math.imul(j,V)|0,n=n+Math.imul(O,W)|0,i=(i=i+Math.imul(O,$)|0)+Math.imul(R,W)|0,o=o+Math.imul(R,$)|0,n=n+Math.imul(B,J)|0,i=(i=i+Math.imul(B,X)|0)+Math.imul(C,J)|0,o=o+Math.imul(C,X)|0,n=n+Math.imul(x,Q)|0,i=(i=i+Math.imul(x,ee)|0)+Math.imul(I,Q)|0,o=o+Math.imul(I,ee)|0,n=n+Math.imul(k,re)|0,i=(i=i+Math.imul(k,ne)|0)+Math.imul(E,re)|0,o=o+Math.imul(E,ne)|0,n=n+Math.imul(_,oe)|0,i=(i=i+Math.imul(_,se)|0)+Math.imul(w,oe)|0,o=o+Math.imul(w,se)|0,n=n+Math.imul(m,ue)|0,i=(i=i+Math.imul(m,ce)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,ce)|0,n=n+Math.imul(d,le)|0,i=(i=i+Math.imul(d,he)|0)+Math.imul(y,le)|0,o=o+Math.imul(y,he)|0;var Ae=(c+(n=n+Math.imul(l,de)|0)|0)+((8191&(i=(i=i+Math.imul(l,ye)|0)+Math.imul(h,de)|0))<<13)|0;c=((o=o+Math.imul(h,ye)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(K,z),i=(i=Math.imul(K,V))+Math.imul(D,z)|0,o=Math.imul(D,V),n=n+Math.imul(L,W)|0,i=(i=i+Math.imul(L,$)|0)+Math.imul(j,W)|0,o=o+Math.imul(j,$)|0,n=n+Math.imul(O,J)|0,i=(i=i+Math.imul(O,X)|0)+Math.imul(R,J)|0,o=o+Math.imul(R,X)|0,n=n+Math.imul(B,Q)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,ee)|0,n=n+Math.imul(x,re)|0,i=(i=i+Math.imul(x,ne)|0)+Math.imul(I,re)|0,o=o+Math.imul(I,ne)|0,n=n+Math.imul(k,oe)|0,i=(i=i+Math.imul(k,se)|0)+Math.imul(E,oe)|0,o=o+Math.imul(E,se)|0,n=n+Math.imul(_,ue)|0,i=(i=i+Math.imul(_,ce)|0)+Math.imul(w,ue)|0,o=o+Math.imul(w,ce)|0,n=n+Math.imul(m,le)|0,i=(i=i+Math.imul(m,he)|0)+Math.imul(b,le)|0,o=o+Math.imul(b,he)|0;var xe=(c+(n=n+Math.imul(d,de)|0)|0)+((8191&(i=(i=i+Math.imul(d,ye)|0)+Math.imul(y,de)|0))<<13)|0;c=((o=o+Math.imul(y,ye)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(K,W),i=(i=Math.imul(K,$))+Math.imul(D,W)|0,o=Math.imul(D,$),n=n+Math.imul(L,J)|0,i=(i=i+Math.imul(L,X)|0)+Math.imul(j,J)|0,o=o+Math.imul(j,X)|0,n=n+Math.imul(O,Q)|0,i=(i=i+Math.imul(O,ee)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(C,re)|0,o=o+Math.imul(C,ne)|0,n=n+Math.imul(x,oe)|0,i=(i=i+Math.imul(x,se)|0)+Math.imul(I,oe)|0,o=o+Math.imul(I,se)|0,n=n+Math.imul(k,ue)|0,i=(i=i+Math.imul(k,ce)|0)+Math.imul(E,ue)|0,o=o+Math.imul(E,ce)|0,n=n+Math.imul(_,le)|0,i=(i=i+Math.imul(_,he)|0)+Math.imul(w,le)|0,o=o+Math.imul(w,he)|0;var Ie=(c+(n=n+Math.imul(m,de)|0)|0)+((8191&(i=(i=i+Math.imul(m,ye)|0)+Math.imul(b,de)|0))<<13)|0;c=((o=o+Math.imul(b,ye)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(K,J),i=(i=Math.imul(K,X))+Math.imul(D,J)|0,o=Math.imul(D,X),n=n+Math.imul(L,Q)|0,i=(i=i+Math.imul(L,ee)|0)+Math.imul(j,Q)|0,o=o+Math.imul(j,ee)|0,n=n+Math.imul(O,re)|0,i=(i=i+Math.imul(O,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,se)|0)+Math.imul(C,oe)|0,o=o+Math.imul(C,se)|0,n=n+Math.imul(x,ue)|0,i=(i=i+Math.imul(x,ce)|0)+Math.imul(I,ue)|0,o=o+Math.imul(I,ce)|0,n=n+Math.imul(k,le)|0,i=(i=i+Math.imul(k,he)|0)+Math.imul(E,le)|0,o=o+Math.imul(E,he)|0;var Te=(c+(n=n+Math.imul(_,de)|0)|0)+((8191&(i=(i=i+Math.imul(_,ye)|0)+Math.imul(w,de)|0))<<13)|0;c=((o=o+Math.imul(w,ye)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(K,Q),i=(i=Math.imul(K,ee))+Math.imul(D,Q)|0,o=Math.imul(D,ee),n=n+Math.imul(L,re)|0,i=(i=i+Math.imul(L,ne)|0)+Math.imul(j,re)|0,o=o+Math.imul(j,ne)|0,n=n+Math.imul(O,oe)|0,i=(i=i+Math.imul(O,se)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,se)|0,n=n+Math.imul(B,ue)|0,i=(i=i+Math.imul(B,ce)|0)+Math.imul(C,ue)|0,o=o+Math.imul(C,ce)|0,n=n+Math.imul(x,le)|0,i=(i=i+Math.imul(x,he)|0)+Math.imul(I,le)|0,o=o+Math.imul(I,he)|0;var Be=(c+(n=n+Math.imul(k,de)|0)|0)+((8191&(i=(i=i+Math.imul(k,ye)|0)+Math.imul(E,de)|0))<<13)|0;c=((o=o+Math.imul(E,ye)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(K,re),i=(i=Math.imul(K,ne))+Math.imul(D,re)|0,o=Math.imul(D,ne),n=n+Math.imul(L,oe)|0,i=(i=i+Math.imul(L,se)|0)+Math.imul(j,oe)|0,o=o+Math.imul(j,se)|0,n=n+Math.imul(O,ue)|0,i=(i=i+Math.imul(O,ce)|0)+Math.imul(R,ue)|0,o=o+Math.imul(R,ce)|0,n=n+Math.imul(B,le)|0,i=(i=i+Math.imul(B,he)|0)+Math.imul(C,le)|0,o=o+Math.imul(C,he)|0;var Ce=(c+(n=n+Math.imul(x,de)|0)|0)+((8191&(i=(i=i+Math.imul(x,ye)|0)+Math.imul(I,de)|0))<<13)|0;c=((o=o+Math.imul(I,ye)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,n=Math.imul(K,oe),i=(i=Math.imul(K,se))+Math.imul(D,oe)|0,o=Math.imul(D,se),n=n+Math.imul(L,ue)|0,i=(i=i+Math.imul(L,ce)|0)+Math.imul(j,ue)|0,o=o+Math.imul(j,ce)|0,n=n+Math.imul(O,le)|0,i=(i=i+Math.imul(O,he)|0)+Math.imul(R,le)|0,o=o+Math.imul(R,he)|0;var Pe=(c+(n=n+Math.imul(B,de)|0)|0)+((8191&(i=(i=i+Math.imul(B,ye)|0)+Math.imul(C,de)|0))<<13)|0;c=((o=o+Math.imul(C,ye)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(K,ue),i=(i=Math.imul(K,ce))+Math.imul(D,ue)|0,o=Math.imul(D,ce),n=n+Math.imul(L,le)|0,i=(i=i+Math.imul(L,he)|0)+Math.imul(j,le)|0,o=o+Math.imul(j,he)|0;var Oe=(c+(n=n+Math.imul(O,de)|0)|0)+((8191&(i=(i=i+Math.imul(O,ye)|0)+Math.imul(R,de)|0))<<13)|0;c=((o=o+Math.imul(R,ye)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(K,le),i=(i=Math.imul(K,he))+Math.imul(D,le)|0,o=Math.imul(D,he);var Re=(c+(n=n+Math.imul(L,de)|0)|0)+((8191&(i=(i=i+Math.imul(L,ye)|0)+Math.imul(j,de)|0))<<13)|0;c=((o=o+Math.imul(j,ye)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863;var Ne=(c+(n=Math.imul(K,de))|0)+((8191&(i=(i=Math.imul(K,ye))+Math.imul(D,de)|0))<<13)|0;return c=((o=Math.imul(D,ye))+(i>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,u[0]=ge,u[1]=me,u[2]=be,u[3]=ve,u[4]=_e,u[5]=we,u[6]=Se,u[7]=ke,u[8]=Ee,u[9]=Ae,u[10]=xe,u[11]=Ie,u[12]=Te,u[13]=Be,u[14]=Ce,u[15]=Pe,u[16]=Oe,u[17]=Re,u[18]=Ne,0!==c&&(u[19]=c,r.length++),r};function d(e,t,r){return(new y).mulp(e,t,r)}function y(e,t){this.x=e,this.y=t}Math.imul||(p=h),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?h(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):d(this,e,t)},y.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},y.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,c=0;c=0&&(0!==f||c>=i);c--){var l=0|this.words[c];this.words[c]=f<<26-o|l>>>o,f=l&a}return u&&0!==f&&(u.words[u.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)-(u/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,u=n.length-i.length;if("mod"!==t){(a=new o(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c=0;l--){var h=67108864*(0|n.words[i.length+l])+(0|n.words[i.length+l-1]);for(h=Math.min(h/s|0,67108863),n._ishlnsubmul(i,h,l);0!==n.negative;)h--,n.negative=0,n._ishlnsubmul(i,1,l),n.isZero()||(n.negative^=1);a&&(a.words[l]=h)}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),u=new o(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var f=r.clone(),l=t.clone();!t.isZero();){for(var h=0,p=1;0==(t.words[0]&p)&&h<26;++h,p<<=1);if(h>0)for(t.iushrn(h);h-- >0;)(i.isOdd()||s.isOdd())&&(i.iadd(f),s.isub(l)),i.iushrn(1),s.iushrn(1);for(var d=0,y=1;0==(r.words[0]&y)&&d<26;++d,y<<=1);if(d>0)for(r.iushrn(d);d-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(f),u.isub(l)),a.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(a),s.isub(u)):(r.isub(t),a.isub(i),u.isub(s))}return{a:a,b:u,gcd:r.iushln(c)}},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),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,f=1;0==(t.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(t.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var l=0,h=1;0==(r.words[0]&h)&&l<26;++l,h<<=1);if(l>0)for(r.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(u),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 S(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 b(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function v(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function _(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function w(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function S(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){S.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):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(b,m),b.prototype.split=function(e,t){for(var r=4194303,n=Math.min(e.length,9),i=0;i>>22,o=s}o>>>=22,e.words[i-10]=o,0===o&&e.length>10?e.length-=10:e.length-=9},b.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 b;else if("p224"===e)t=new v;else if("p192"===e)t=new _;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new w}return g[e]=t,t},S.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},S.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")},S.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},S.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},S.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)},S.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},S.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)},S.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},S.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},S.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},S.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},S.prototype.isqr=function(e){return this.imul(e,e.clone())},S.prototype.sqr=function(e){return this.mul(e,e)},S.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),u=a.redNeg(),c=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var l=this.pow(f,i),h=this.pow(e,i.addn(1).iushrn(1)),p=this.pow(e,i),d=s;0!==p.cmp(a);){for(var y=p,g=0;0!==y.cmp(a);g++)y=y.redSqr();n(g=0;n--){for(var c=t.words[n],f=u-1;f>=0;f--){var l=c>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==l||0!==s?(s<<=1,s|=l,(4==++a||0===n&&0===f)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}u=26}return i},S.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},S.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new k(e)},i(k,S),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)}}(void 0===e||e,this)}).call(this,r(27)(e))},function(e,t,r){"use strict";var n=t;n.version=r(821).version,n.utils=r(822),n.rand=r(823),n.curve=r(174),n.curves=r(829),n.ec=r(837),n.eddsa=r(841)},function(e,t,r){"use strict";(function(t){var n=r(24),i=r(16),o=function e(t){if(!(this instanceof e))return new e(t);t?this.set(t):this.bufs=[]};o.prototype.set=function(e){return this.bufs=e.bufs||this.bufs||[],this},o.prototype.toBuffer=function(){return this.concat()},o.prototype.concat=function(){return t.concat(this.bufs)},o.prototype.write=function(e){return i(n.isBuffer(e)),this.bufs.push(e),this},o.prototype.writeReverse=function(e){return i(n.isBuffer(e)),this.bufs.push(n.reverse(e)),this},o.prototype.writeUInt8=function(e){var r=new t(1);return r.writeUInt8(e,0),this.write(r),this},o.prototype.writeUInt16BE=function(e){var r=new t(2);return r.writeUInt16BE(e,0),this.write(r),this},o.prototype.writeUInt16LE=function(e){var r=new t(2);return r.writeUInt16LE(e,0),this.write(r),this},o.prototype.writeUInt32BE=function(e){var r=new t(4);return r.writeUInt32BE(e,0),this.write(r),this},o.prototype.writeInt32LE=function(e){var r=new t(4);return r.writeInt32LE(e,0),this.write(r),this},o.prototype.writeUInt32LE=function(e){var r=new t(4);return r.writeUInt32LE(e,0),this.write(r),this},o.prototype.writeUInt64BEBN=function(e){var t=e.toBuffer({size:8});return this.write(t),this},o.prototype.writeUInt64LEBN=function(e){var t=e.toBuffer({size:8});return this.writeReverse(t),this},o.prototype.writeVarintNum=function(e){var t=o.varintBufNum(e);return this.write(t),this},o.prototype.writeVarintBN=function(e){var t=o.varintBufBN(e);return this.write(t),this},o.varintBufNum=function(e){var r=void 0;return e<253?(r=new t(1)).writeUInt8(e,0):e<65536?((r=new t(3)).writeUInt8(253,0),r.writeUInt16LE(e,1)):e<4294967296?((r=new t(5)).writeUInt8(254,0),r.writeUInt32LE(e,1)):((r=new t(9)).writeUInt8(255,0),r.writeInt32LE(-1&e,1),r.writeUInt32LE(Math.floor(e/4294967296),5)),r},o.varintBufBN=function(e){var r=void 0,n=e.toNumber();if(n<253)(r=new t(1)).writeUInt8(n,0);else if(n<65536)(r=new t(3)).writeUInt8(253,0),r.writeUInt16LE(n,1);else if(n<4294967296)(r=new t(5)).writeUInt8(254,0),r.writeUInt32LE(n,1);else{var i=new o;i.writeUInt8(255),i.writeUInt64LEBN(e);r=i.concat()}return r},e.exports=o}).call(this,r(0).Buffer)},function(e,t,r){"use strict";e.exports=function(e,{className:t,symbolName:r}){const n=Symbol.for(r),i={[t]:class extends e{constructor(...e){super(...e),Object.defineProperty(this,n,{value:!0})}get[Symbol.toStringTag](){return t}}}[t];return i[`is${t}`]=(e=>!(!e||!e[n])),i},e.exports.proto=function(e,{className:t,symbolName:r,withoutNew:n}){const i=Symbol.for(r),o={[t]:function(...t){if(n&&!(this instanceof o))return new o(...t);const r=e.call(this,...t)||this;return r&&!r[i]&&Object.defineProperty(r,i,{value:!0}),r}}[t];return o.prototype=Object.create(e.prototype),o.prototype.constructor=o,Object.defineProperty(o.prototype,Symbol.toStringTag,{get:()=>t}),o[`is${t}`]=(e=>!(!e||!e[i])),o}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){(0,i.default)(n.default,e,t)};var n=o(r(219)),i=o(r(351));function o(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default},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}var n=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,i=function(e){return n.exec(e).slice(1)};function o(e,t){if(e.filter)return e.filter(t);for(var r=[],n=0;n=-1&&!n;i--){var s=i>=0?arguments[i]:e.cwd();if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");s&&(t=s+"/"+t,n="/"===s.charAt(0))}return t=r(o(t.split("/"),function(e){return!!e}),!n).join("/"),(n?"/":"")+t||"."},t.normalize=function(e){var n=t.isAbsolute(e),i="/"===s(e,-1);return(e=r(o(e.split("/"),function(e){return!!e}),!n).join("/"))||n||(e="."),e&&i&&(e+="/"),(n?"/":"")+e},t.isAbsolute=function(e){return"/"===e.charAt(0)},t.join=function(){var e=Array.prototype.slice.call(arguments,0);return t.normalize(o(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,u=0;u{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){"use strict";var n=r(18);var i=function(e,t){var r=function(){if(n.isString(t.message))this.message=function(e,t){return e.replace("{0}",t[0]).replace("{1}",t[1]).replace("{2}",t[2])}(t.message,arguments);else{if(!n.isFunction(t.message))throw new Error("Invalid error definition for "+t.name);this.message=t.message.apply(null,arguments)}this.stack=this.message+"\n"+(new Error).stack};return(r.prototype=Object.create(e.prototype)).name=e.prototype.name+t.name,e[t.name]=r,t.errors&&o(r,t.errors),r},o=function(e,t){n.each(t,function(t){i(e,t)})},s={Error:function(){this.message="Internal error",this.stack=this.message+"\n"+(new Error).stack}};s.Error.prototype=Object.create(Error.prototype),s.Error.prototype.name="bitcore.Error";var a=r(864);(function(e,t){o(e,t)})(s.Error,a),e.exports=s.Error,e.exports.extend=function(e){return i(s.Error,e)}},function(e,t,r){"use strict";(function(t){var n=r(32),i=r(18),o=r(21),s=r(24),a=r(29),u=function e(t,r){if(!(this instanceof e))return new e(t,r);if(t instanceof n)this.set({r:t,s:r});else if(t){var i=t;this.set(i)}};u.prototype.set=function(e){return this.r=e.r||this.r||void 0,this.s=e.s||this.s||void 0,this.i=void 0!==e.i?e.i:this.i,this.compressed=void 0!==e.compressed?e.compressed:this.compressed,this.nhashtype=e.nhashtype||this.nhashtype||void 0,this},u.fromCompact=function(e){o.checkArgument(s.isBuffer(e),"Argument is expected to be a Buffer");var t=new u,r=!0,i=e.slice(0,1)[0]-27-4;i<0&&(r=!1,i+=4);var a=e.slice(1,33),c=e.slice(33,65);return o.checkArgument(0===i||1===i||2===i||3===i,new Error("i must be 0, 1, 2, or 3")),o.checkArgument(32===a.length,new Error("r must be 32 bytes")),o.checkArgument(32===c.length,new Error("s must be 32 bytes")),t.compressed=r,t.i=i,t.r=n.fromBuffer(a),t.s=n.fromBuffer(c),t},u.fromDER=u.fromBuffer=function(e,t){var r=u.parseDER(e,t),n=new u;return n.r=r.r,n.s=r.s,n},u.fromTxFormat=function(e){var t=e.readUInt8(e.length-1),r=e.slice(0,e.length-1),n=new u.fromDER(r,!1);return n.nhashtype=t,n},u.fromString=function(e){var r=new t(e,"hex");return u.fromDER(r)},u.parseDER=function(e,t){o.checkArgument(s.isBuffer(e),new Error("DER formatted signature should be a buffer")),i.isUndefined(t)&&(t=!0);var r=e[0];o.checkArgument(48===r,new Error("Header byte should be 0x30"));var a=e[1],u=e.slice(2).length;o.checkArgument(!t||a===u,new Error("Length byte should length of what follows")),a=a73)return!1;if(48!==e[0])return!1;if(e[1]!==e.length-3)return!1;var t=e[3];if(5+t>=e.length)return!1;var r=e[5+t];if(t+r+7!==e.length)return!1;var n=e.slice(4);if(2!==e[2])return!1;if(0===t)return!1;if(128&n[0])return!1;if(t>1&&0===n[0]&&!(128&n[1]))return!1;var i=e.slice(6+t);return!(2!==e[6+t-2]||0===r||128&i[0]||r>1&&0===i[0]&&!(128&i[1]))},u.prototype.hasLowS=function(){return!this.s.lt(new n(1))&&!this.s.gt(new n("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex"))},u.prototype.hasDefinedHashtype=function(){if(!a.isNaturalNumber(this.nhashtype))return!1;var e=this.nhashtype&~u.SIGHASH_ANYONECANPAY;return!(eu.SIGHASH_SINGLE)},u.prototype.toTxFormat=function(){var e=this.toDER(),r=new t(1);return r.writeUInt8(this.nhashtype,0),t.concat([e,r])},u.SIGHASH_ALL=1,u.SIGHASH_NONE=2,u.SIGHASH_SINGLE=3,u.SIGHASH_ANYONECANPAY=128,e.exports=u}).call(this,r(0).Buffer)},function(e,t,r){e.exports=r(430),e.exports.Interpreter=r(883)},function(e,t){ /** * @file Web Cryptography API shim * @author Artem S Vybornov * @license MIT */ -e.exports=function(e){"use strict";if("function"!=typeof Promise)throw"Promise support required";var t=e.crypto||e.msCrypto;if(t){var r=t.subtle||t.webkitSubtle;if(r){var n=e.Crypto||t.constructor||Object,i=e.SubtleCrypto||r.constructor||Object,o=(e.CryptoKey||e.Key||Object,e.navigator.userAgent.indexOf("Edge/")>-1),s=!!e.msCrypto&&!o,a=!t.subtle&&!!t.webkitSubtle;if(s||a){var u={KoZIhvcNAQEB:"1.2.840.113549.1.1.1"},c={"1.2.840.113549.1.1.1":"KoZIhvcNAQEB"};if(["generateKey","importKey","unwrapKey"].forEach(function(e){var n=r[e];r[e]=function(i,o,u){var c,f,l,d,v=[].slice.call(arguments);switch(e){case"generateKey":c=y(i),f=o,l=u;break;case"importKey":c=y(u),f=v[3],l=v[4],"jwk"===i&&((o=m(o)).alg||(o.alg=g(c)),o.key_ops||(o.key_ops="oct"!==o.kty?"d"in o?l.filter(k):l.filter(S):l.slice()),v[1]=function(e){var t=m(e);return s&&(t.extractable=t.ext,delete t.ext),p(unescape(encodeURIComponent(JSON.stringify(t)))).buffer}(o));break;case"unwrapKey":c=v[4],f=v[5],l=v[6],v[2]=u._key}if("generateKey"===e&&"HMAC"===c.name&&c.hash)return c.length=c.length||{"SHA-1":512,"SHA-256":512,"SHA-384":1024,"SHA-512":1024}[c.hash.name],r.importKey("raw",t.getRandomValues(new Uint8Array(c.length+7>>3)),c,f,l);if(a&&"generateKey"===e&&"RSASSA-PKCS1-v1_5"===c.name&&(!c.modulusLength||c.modulusLength>=2048))return(i=y(i)).name="RSAES-PKCS1-v1_5",delete i.hash,r.generateKey(i,!0,["encrypt","decrypt"]).then(function(e){return Promise.all([r.exportKey("jwk",e.publicKey),r.exportKey("jwk",e.privateKey)])}).then(function(e){return e[0].alg=e[1].alg=g(c),e[0].key_ops=l.filter(S),e[1].key_ops=l.filter(k),Promise.all([r.importKey("jwk",e[0],c,!0,e[0].key_ops),r.importKey("jwk",e[1],c,f,e[1].key_ops)])}).then(function(e){return{publicKey:e[0],privateKey:e[1]}});if((a||s&&"SHA-1"===(c.hash||{}).name)&&"importKey"===e&&"jwk"===i&&"HMAC"===c.name&&"oct"===o.kty)return r.importKey("raw",p(h(o.k)),u,v[3],v[4]);if(a&&"importKey"===e&&("spki"===i||"pkcs8"===i))return r.importKey("jwk",b(o),u,v[3],v[4]);if(s&&"unwrapKey"===e)return r.decrypt(v[3],u,o).then(function(e){return r.importKey(i,e,v[4],v[5],v[6])});try{d=n.apply(r,v)}catch(e){return Promise.reject(e)}return s&&(d=new Promise(function(e,t){d.onabort=d.onerror=function(e){t(e)},d.oncomplete=function(t){e(t.target.result)}})),d=d.then(function(e){return"HMAC"===c.name&&(c.length||(c.length=8*e.algorithm.length)),0==c.name.search("RSA")&&(c.modulusLength||(c.modulusLength=(e.publicKey||e).algorithm.modulusLength),c.publicExponent||(c.publicExponent=(e.publicKey||e).algorithm.publicExponent)),e.publicKey&&e.privateKey?{publicKey:new w(e.publicKey,c,f,l.filter(S)),privateKey:new w(e.privateKey,c,f,l.filter(k))}:new w(e,c,f,l)})}}),["exportKey","wrapKey"].forEach(function(e){var t=r[e];r[e]=function(n,i,o){var u,c=[].slice.call(arguments);switch(e){case"exportKey":c[1]=i._key;break;case"wrapKey":c[1]=i._key,c[2]=o._key}if((a||s&&"SHA-1"===(i.algorithm.hash||{}).name)&&"exportKey"===e&&"jwk"===n&&"HMAC"===i.algorithm.name&&(c[0]="raw"),!a||"exportKey"!==e||"spki"!==n&&"pkcs8"!==n||(c[0]="jwk"),s&&"wrapKey"===e)return r.exportKey(n,i).then(function(e){return"jwk"===n&&(e=p(unescape(encodeURIComponent(JSON.stringify(m(e)))))),r.encrypt(c[3],o,e)});try{u=t.apply(r,c)}catch(e){return Promise.reject(e)}return s&&(u=new Promise(function(e,t){u.onabort=u.onerror=function(e){t(e)},u.oncomplete=function(t){e(t.target.result)}})),"exportKey"===e&&"jwk"===n&&(u=u.then(function(e){return(a||s&&"SHA-1"===(i.algorithm.hash||{}).name)&&"HMAC"===i.algorithm.name?{kty:"oct",alg:g(i.algorithm),key_ops:i.usages.slice(),ext:!0,k:l(d(e))}:((e=m(e)).alg||(e.alg=g(i.algorithm)),e.key_ops||(e.key_ops="public"===i.type?i.usages.filter(S):"private"===i.type?i.usages.filter(k):i.usages.slice()),e)})),!a||"exportKey"!==e||"spki"!==n&&"pkcs8"!==n||(u=u.then(function(e){return function(e){var t,r=[["",null]],n=!1;switch(e.kty){case"RSA":for(var i=["n","e","d","p","q","dp","dq","qi"],o=[],s=0;s2&&(n=!0,o.unshift(new Uint8Array([0]))),r[0][0]="1.2.840.113549.1.1.1",t=o;break;default:throw new TypeError("Unsupported key type")}return r.push(new Uint8Array(_(t)).buffer),n?r.unshift(new Uint8Array([0])):r[1]={tag:3,value:r[1]},new Uint8Array(_(r)).buffer}(m(e))})),u}}),["encrypt","decrypt","sign","verify"].forEach(function(e){var t=r[e];r[e]=function(n,i,o,a){if(s&&(!o.byteLength||a&&!a.byteLength))throw new Error("Empy input is not allowed");var u,c=[].slice.call(arguments),f=y(n);if(s&&"decrypt"===e&&"AES-GCM"===f.name){var l=n.tagLength>>3;c[2]=(o.buffer||o).slice(0,o.byteLength-l),n.tag=(o.buffer||o).slice(o.byteLength-l)}c[1]=i._key;try{u=t.apply(r,c)}catch(e){return Promise.reject(e)}return s&&(u=new Promise(function(t,r){u.onabort=u.onerror=function(e){r(e)},u.oncomplete=function(r){r=r.target.result;if("encrypt"===e&&r instanceof AesGcmEncryptResult){var n=r.ciphertext,i=r.tag;(r=new Uint8Array(n.byteLength+i.byteLength)).set(new Uint8Array(n),0),r.set(new Uint8Array(i),n.byteLength),r=r.buffer}t(r)}})),u}}),s){var f=r.digest;r.digest=function(e,t){if(!t.byteLength)throw new Error("Empy input is not allowed");var n;try{n=f.call(r,e,t)}catch(e){return Promise.reject(e)}return n=new Promise(function(e,t){n.onabort=n.onerror=function(e){t(e)},n.oncomplete=function(t){e(t.target.result)}})},e.crypto=Object.create(t,{getRandomValues:{value:function(e){return t.getRandomValues(e)}},subtle:{value:r}}),e.CryptoKey=w}a&&(t.subtle=r,e.Crypto=n,e.SubtleCrypto=i,e.CryptoKey=w)}}}function l(e){return btoa(e).replace(/\=+$/,"").replace(/\+/g,"-").replace(/\//g,"_")}function h(e){return e=(e+="===").slice(0,-e.length%4),atob(e.replace(/-/g,"+").replace(/_/g,"/"))}function p(e){for(var t=new Uint8Array(e.length),r=0;r2&&(r=!0,t.shift());var n={ext:!0};switch(t[0][0]){case"1.2.840.113549.1.1.1":var i=["n","e","d","p","q","dp","dq","qi"],o=v(t[1]);r&&o.shift();for(var s=0;se.length)throw new RangeError("Malformed DER");var r,n=e[t.pos++],i=e[t.pos++];if(i>=128){if(i&=127,t.end-t.pos=128){var a=n;n=4;for(t.splice(i,0,a>>24&255,a>>16&255,a>>8&255,255&a);n>1&&!(a>>24);)a<<=8,n--;n<4&&t.splice(i,4-n),n|=128}return t.splice(i-2,2,r,n),t}function w(e,t,r,n){Object.defineProperties(this,{_key:{value:e},type:{value:e.type,enumerable:!0},extractable:{value:void 0===r?e.extractable:r,enumerable:!0},algorithm:{value:void 0===t?e.algorithm:t,enumerable:!0},usages:{value:void 0===n?e.usages:n,enumerable:!0}})}function S(e){return"verify"===e||"encrypt"===e||"wrapKey"===e}function k(e){return"sign"===e||"decrypt"===e||"unwrapKey"===e}}},function(e,t,r){var n=r(907),i=r(915),o=r(442);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){!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 g(e,t,r,n){return y(e,t,r,n,16)}function m(e,t,r,n){return y(e,t,r,n,32)}function b(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,u=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,c=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,l=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,h=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,p=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,d=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,g=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,m=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,b=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,_=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,w=o,S=s,k=a,E=u,A=c,x=f,I=l,T=h,B=p,C=d,P=y,O=g,R=m,N=b,L=v,K=_,j=0;j<20;j+=2)w^=(i=(R^=(i=(B^=(i=(A^=(i=w+R|0)<<7|i>>>25)+w|0)<<9|i>>>23)+A|0)<<13|i>>>19)+B|0)<<18|i>>>14,x^=(i=(S^=(i=(N^=(i=(C^=(i=x+S|0)<<7|i>>>25)+x|0)<<9|i>>>23)+C|0)<<13|i>>>19)+N|0)<<18|i>>>14,P^=(i=(I^=(i=(k^=(i=(L^=(i=P+I|0)<<7|i>>>25)+P|0)<<9|i>>>23)+L|0)<<13|i>>>19)+k|0)<<18|i>>>14,K^=(i=(O^=(i=(T^=(i=(E^=(i=K+O|0)<<7|i>>>25)+K|0)<<9|i>>>23)+E|0)<<13|i>>>19)+T|0)<<18|i>>>14,w^=(i=(E^=(i=(k^=(i=(S^=(i=w+E|0)<<7|i>>>25)+w|0)<<9|i>>>23)+S|0)<<13|i>>>19)+k|0)<<18|i>>>14,x^=(i=(A^=(i=(T^=(i=(I^=(i=x+A|0)<<7|i>>>25)+x|0)<<9|i>>>23)+I|0)<<13|i>>>19)+T|0)<<18|i>>>14,P^=(i=(C^=(i=(B^=(i=(O^=(i=P+C|0)<<7|i>>>25)+P|0)<<9|i>>>23)+O|0)<<13|i>>>19)+B|0)<<18|i>>>14,K^=(i=(L^=(i=(N^=(i=(R^=(i=K+L|0)<<7|i>>>25)+K|0)<<9|i>>>23)+R|0)<<13|i>>>19)+N|0)<<18|i>>>14;w=w+o|0,S=S+s|0,k=k+a|0,E=E+u|0,A=A+c|0,x=x+f|0,I=I+l|0,T=T+h|0,B=B+p|0,C=C+d|0,P=P+y|0,O=O+g|0,R=R+m|0,N=N+b|0,L=L+v|0,K=K+_|0,e[0]=w>>>0&255,e[1]=w>>>8&255,e[2]=w>>>16&255,e[3]=w>>>24&255,e[4]=S>>>0&255,e[5]=S>>>8&255,e[6]=S>>>16&255,e[7]=S>>>24&255,e[8]=k>>>0&255,e[9]=k>>>8&255,e[10]=k>>>16&255,e[11]=k>>>24&255,e[12]=E>>>0&255,e[13]=E>>>8&255,e[14]=E>>>16&255,e[15]=E>>>24&255,e[16]=A>>>0&255,e[17]=A>>>8&255,e[18]=A>>>16&255,e[19]=A>>>24&255,e[20]=x>>>0&255,e[21]=x>>>8&255,e[22]=x>>>16&255,e[23]=x>>>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]=B>>>0&255,e[33]=B>>>8&255,e[34]=B>>>16&255,e[35]=B>>>24&255,e[36]=C>>>0&255,e[37]=C>>>8&255,e[38]=C>>>16&255,e[39]=C>>>24&255,e[40]=P>>>0&255,e[41]=P>>>8&255,e[42]=P>>>16&255,e[43]=P>>>24&255,e[44]=O>>>0&255,e[45]=O>>>8&255,e[46]=O>>>16&255,e[47]=O>>>24&255,e[48]=R>>>0&255,e[49]=R>>>8&255,e[50]=R>>>16&255,e[51]=R>>>24&255,e[52]=N>>>0&255,e[53]=N>>>8&255,e[54]=N>>>16&255,e[55]=N>>>24&255,e[56]=L>>>0&255,e[57]=L>>>8&255,e[58]=L>>>16&255,e[59]=L>>>24&255,e[60]=K>>>0&255,e[61]=K>>>8&255,e[62]=K>>>16&255,e[63]=K>>>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,u=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,c=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,l=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,h=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,p=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,d=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,g=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,m=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,b=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,_=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,w=0;w<20;w+=2)o^=(i=(m^=(i=(p^=(i=(c^=(i=o+m|0)<<7|i>>>25)+o|0)<<9|i>>>23)+c|0)<<13|i>>>19)+p|0)<<18|i>>>14,f^=(i=(s^=(i=(b^=(i=(d^=(i=f+s|0)<<7|i>>>25)+f|0)<<9|i>>>23)+d|0)<<13|i>>>19)+b|0)<<18|i>>>14,y^=(i=(l^=(i=(a^=(i=(v^=(i=y+l|0)<<7|i>>>25)+y|0)<<9|i>>>23)+v|0)<<13|i>>>19)+a|0)<<18|i>>>14,_^=(i=(g^=(i=(h^=(i=(u^=(i=_+g|0)<<7|i>>>25)+_|0)<<9|i>>>23)+u|0)<<13|i>>>19)+h|0)<<18|i>>>14,o^=(i=(u^=(i=(a^=(i=(s^=(i=o+u|0)<<7|i>>>25)+o|0)<<9|i>>>23)+s|0)<<13|i>>>19)+a|0)<<18|i>>>14,f^=(i=(c^=(i=(h^=(i=(l^=(i=f+c|0)<<7|i>>>25)+f|0)<<9|i>>>23)+l|0)<<13|i>>>19)+h|0)<<18|i>>>14,y^=(i=(d^=(i=(p^=(i=(g^=(i=y+d|0)<<7|i>>>25)+y|0)<<9|i>>>23)+g|0)<<13|i>>>19)+p|0)<<18|i>>>14,_^=(i=(v^=(i=(b^=(i=(m^=(i=_+v|0)<<7|i>>>25)+_|0)<<9|i>>>23)+m|0)<<13|i>>>19)+b|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]=_>>>0&255,e[13]=_>>>8&255,e[14]=_>>>16&255,e[15]=_>>>24&255,e[16]=l>>>0&255,e[17]=l>>>8&255,e[18]=l>>>16&255,e[19]=l>>>24&255,e[20]=h>>>0&255,e[21]=h>>>8&255,e[22]=h>>>16&255,e[23]=h>>>24&255,e[24]=p>>>0&255,e[25]=p>>>8&255,e[26]=p>>>16&255,e[27]=p>>>24&255,e[28]=d>>>0&255,e[29]=d>>>8&255,e[30]=d>>>16&255,e[31]=d>>>24&255}(e,t,r,n)}var _=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function w(e,t,r,n,i,o,s){var a,u,c=new Uint8Array(16),f=new Uint8Array(64);for(u=0;u<16;u++)c[u]=0;for(u=0;u<8;u++)c[u]=o[u];for(;i>=64;){for(b(f,c,s,_),u=0;u<64;u++)e[t+u]=r[n+u]^f[u];for(a=1,u=8;u<16;u++)a=a+(255&c[u])|0,c[u]=255&a,a>>>=8;i-=64,t+=64,n+=64}if(i>0)for(b(f,c,s,_),u=0;u=64;){for(b(u,a,i,_),s=0;s<64;s++)e[t+s]=u[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(b(u,a,i,_),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),u=255&e[14]|(255&e[15])<<8,this.r[8]=8191&(a>>>8|u<<8),this.r[9]=u>>>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 x(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 x(s,0,r,n,i,o),g(e,t,s,0)}function T(e,t,r,n,i){var o;if(r<32)return-1;for(E(e,0,t,0,r,n,i),x(e,16,e,32,r-32,e),o=0;o<16;o++)e[o]=0;return 0}function B(e,t,r,n,i){var o,s=new Uint8Array(32);if(r<32)return-1;if(k(s,0,32,n,i),0!==I(t,16,t,32,r-32,s))return-1;for(E(e,0,t,0,r,n,i),o=0;o<32;o++)e[o]=0;return 0}function C(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function P(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 O(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 R(e,r){var n,i,o,s=t(),a=t();for(n=0;n<16;n++)a[n]=r[n];for(P(a),P(a),P(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,O(a,s,1-o)}for(n=0;n<16;n++)e[2*n]=255&a[n],e[2*n+1]=a[n]>>8}function N(e,t){var r=new Uint8Array(32),n=new Uint8Array(32);return R(r,e),R(n,t),m(r,0,n,0)}function L(e){var t=new Uint8Array(32);return R(t,e),1&t[0]}function K(e,t){var r;for(r=0;r<16;r++)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}function j(e,t,r){for(var n=0;n<16;n++)e[n]=t[n]+r[n]}function M(e,t,r){for(var n=0;n<16;n++)e[n]=t[n]-r[n]}function D(e,t,r){var n,i,o=0,s=0,a=0,u=0,c=0,f=0,l=0,h=0,p=0,d=0,y=0,g=0,m=0,b=0,v=0,_=0,w=0,S=0,k=0,E=0,A=0,x=0,I=0,T=0,B=0,C=0,P=0,O=0,R=0,N=0,L=0,K=r[0],j=r[1],M=r[2],D=r[3],U=r[4],F=r[5],q=r[6],H=r[7],z=r[8],V=r[9],G=r[10],W=r[11],$=r[12],Y=r[13],J=r[14],X=r[15];o+=(n=t[0])*K,s+=n*j,a+=n*M,u+=n*D,c+=n*U,f+=n*F,l+=n*q,h+=n*H,p+=n*z,d+=n*V,y+=n*G,g+=n*W,m+=n*$,b+=n*Y,v+=n*J,_+=n*X,s+=(n=t[1])*K,a+=n*j,u+=n*M,c+=n*D,f+=n*U,l+=n*F,h+=n*q,p+=n*H,d+=n*z,y+=n*V,g+=n*G,m+=n*W,b+=n*$,v+=n*Y,_+=n*J,w+=n*X,a+=(n=t[2])*K,u+=n*j,c+=n*M,f+=n*D,l+=n*U,h+=n*F,p+=n*q,d+=n*H,y+=n*z,g+=n*V,m+=n*G,b+=n*W,v+=n*$,_+=n*Y,w+=n*J,S+=n*X,u+=(n=t[3])*K,c+=n*j,f+=n*M,l+=n*D,h+=n*U,p+=n*F,d+=n*q,y+=n*H,g+=n*z,m+=n*V,b+=n*G,v+=n*W,_+=n*$,w+=n*Y,S+=n*J,k+=n*X,c+=(n=t[4])*K,f+=n*j,l+=n*M,h+=n*D,p+=n*U,d+=n*F,y+=n*q,g+=n*H,m+=n*z,b+=n*V,v+=n*G,_+=n*W,w+=n*$,S+=n*Y,k+=n*J,E+=n*X,f+=(n=t[5])*K,l+=n*j,h+=n*M,p+=n*D,d+=n*U,y+=n*F,g+=n*q,m+=n*H,b+=n*z,v+=n*V,_+=n*G,w+=n*W,S+=n*$,k+=n*Y,E+=n*J,A+=n*X,l+=(n=t[6])*K,h+=n*j,p+=n*M,d+=n*D,y+=n*U,g+=n*F,m+=n*q,b+=n*H,v+=n*z,_+=n*V,w+=n*G,S+=n*W,k+=n*$,E+=n*Y,A+=n*J,x+=n*X,h+=(n=t[7])*K,p+=n*j,d+=n*M,y+=n*D,g+=n*U,m+=n*F,b+=n*q,v+=n*H,_+=n*z,w+=n*V,S+=n*G,k+=n*W,E+=n*$,A+=n*Y,x+=n*J,I+=n*X,p+=(n=t[8])*K,d+=n*j,y+=n*M,g+=n*D,m+=n*U,b+=n*F,v+=n*q,_+=n*H,w+=n*z,S+=n*V,k+=n*G,E+=n*W,A+=n*$,x+=n*Y,I+=n*J,T+=n*X,d+=(n=t[9])*K,y+=n*j,g+=n*M,m+=n*D,b+=n*U,v+=n*F,_+=n*q,w+=n*H,S+=n*z,k+=n*V,E+=n*G,A+=n*W,x+=n*$,I+=n*Y,T+=n*J,B+=n*X,y+=(n=t[10])*K,g+=n*j,m+=n*M,b+=n*D,v+=n*U,_+=n*F,w+=n*q,S+=n*H,k+=n*z,E+=n*V,A+=n*G,x+=n*W,I+=n*$,T+=n*Y,B+=n*J,C+=n*X,g+=(n=t[11])*K,m+=n*j,b+=n*M,v+=n*D,_+=n*U,w+=n*F,S+=n*q,k+=n*H,E+=n*z,A+=n*V,x+=n*G,I+=n*W,T+=n*$,B+=n*Y,C+=n*J,P+=n*X,m+=(n=t[12])*K,b+=n*j,v+=n*M,_+=n*D,w+=n*U,S+=n*F,k+=n*q,E+=n*H,A+=n*z,x+=n*V,I+=n*G,T+=n*W,B+=n*$,C+=n*Y,P+=n*J,O+=n*X,b+=(n=t[13])*K,v+=n*j,_+=n*M,w+=n*D,S+=n*U,k+=n*F,E+=n*q,A+=n*H,x+=n*z,I+=n*V,T+=n*G,B+=n*W,C+=n*$,P+=n*Y,O+=n*J,R+=n*X,v+=(n=t[14])*K,_+=n*j,w+=n*M,S+=n*D,k+=n*U,E+=n*F,A+=n*q,x+=n*H,I+=n*z,T+=n*V,B+=n*G,C+=n*W,P+=n*$,O+=n*Y,R+=n*J,N+=n*X,_+=(n=t[15])*K,s+=38*(S+=n*M),a+=38*(k+=n*D),u+=38*(E+=n*U),c+=38*(A+=n*F),f+=38*(x+=n*q),l+=38*(I+=n*H),h+=38*(T+=n*z),p+=38*(B+=n*V),d+=38*(C+=n*G),y+=38*(P+=n*W),g+=38*(O+=n*$),m+=38*(R+=n*Y),b+=38*(N+=n*J),v+=38*(L+=n*X),o=(n=(o+=38*(w+=n*j))+(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)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+i+65535)-65536*(i=Math.floor(n/65536)),f=(n=f+i+65535)-65536*(i=Math.floor(n/65536)),l=(n=l+i+65535)-65536*(i=Math.floor(n/65536)),h=(n=h+i+65535)-65536*(i=Math.floor(n/65536)),p=(n=p+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+i+65535)-65536*(i=Math.floor(n/65536)),y=(n=y+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)),b=(n=b+i+65535)-65536*(i=Math.floor(n/65536)),v=(n=v+i+65535)-65536*(i=Math.floor(n/65536)),_=(n=_+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)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+i+65535)-65536*(i=Math.floor(n/65536)),f=(n=f+i+65535)-65536*(i=Math.floor(n/65536)),l=(n=l+i+65535)-65536*(i=Math.floor(n/65536)),h=(n=h+i+65535)-65536*(i=Math.floor(n/65536)),p=(n=p+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+i+65535)-65536*(i=Math.floor(n/65536)),y=(n=y+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)),b=(n=b+i+65535)-65536*(i=Math.floor(n/65536)),v=(n=v+i+65535)-65536*(i=Math.floor(n/65536)),_=(n=_+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]=u,e[4]=c,e[5]=f,e[6]=l,e[7]=h,e[8]=p,e[9]=d,e[10]=y,e[11]=g,e[12]=m,e[13]=b,e[14]=v,e[15]=_}function U(e,t){D(e,t,t)}function F(e,r){var n,i=t();for(n=0;n<16;n++)i[n]=r[n];for(n=253;n>=0;n--)U(i,i),2!==n&&4!==n&&D(i,i,r);for(n=0;n<16;n++)e[n]=i[n]}function q(e,r,n){var i,o,s=new Uint8Array(32),a=new Float64Array(80),c=t(),f=t(),l=t(),h=t(),p=t(),d=t();for(o=0;o<31;o++)s[o]=r[o];for(s[31]=127&r[31]|64,s[0]&=248,K(a,n),o=0;o<16;o++)f[o]=a[o],h[o]=c[o]=l[o]=0;for(c[0]=h[0]=1,o=254;o>=0;--o)O(c,f,i=s[o>>>3]>>>(7&o)&1),O(l,h,i),j(p,c,l),M(c,c,l),j(l,f,h),M(f,f,h),U(h,p),U(d,c),D(c,l,c),D(l,f,p),j(p,c,l),M(c,c,l),U(f,c),M(l,h,d),D(c,l,u),j(c,c,h),D(l,l,c),D(c,h,d),D(h,f,a),U(f,p),O(c,f,i),O(l,h,i);for(o=0;o<16;o++)a[o+16]=c[o],a[o+32]=l[o],a[o+48]=f[o],a[o+64]=h[o];var y=a.subarray(32),g=a.subarray(16);return F(y,y),D(g,g,y),R(e,g),0}function H(e,t){return q(e,t,o)}function z(e,t){return n(t,32),H(e,t)}function V(e,t,r){var n=new Uint8Array(32);return q(n,r,t),v(e,i,n,_)}A.prototype.blocks=function(e,t,r){for(var n,i,o,s,a,u,c,f,l,h,p,d,y,g,m,b,v,_,w,S=this.fin?0:2048,k=this.h[0],E=this.h[1],A=this.h[2],x=this.h[3],I=this.h[4],T=this.h[5],B=this.h[6],C=this.h[7],P=this.h[8],O=this.h[9],R=this.r[0],N=this.r[1],L=this.r[2],K=this.r[3],j=this.r[4],M=this.r[5],D=this.r[6],U=this.r[7],F=this.r[8],q=this.r[9];r>=16;)k+=8191&(n=255&e[t+0]|(255&e[t+1])<<8),E+=8191&(n>>>13|(i=255&e[t+2]|(255&e[t+3])<<8)<<3),A+=8191&(i>>>10|(o=255&e[t+4]|(255&e[t+5])<<8)<<6),x+=8191&(o>>>7|(s=255&e[t+6]|(255&e[t+7])<<8)<<9),I+=8191&(s>>>4|(a=255&e[t+8]|(255&e[t+9])<<8)<<12),T+=a>>>1&8191,B+=8191&(a>>>14|(u=255&e[t+10]|(255&e[t+11])<<8)<<2),C+=8191&(u>>>11|(c=255&e[t+12]|(255&e[t+13])<<8)<<5),f=255&e[t+14]|(255&e[t+15])<<8,h=l=0,h+=k*R,h+=E*(5*q),h+=A*(5*F),h+=x*(5*U),l=(h+=I*(5*D))>>>13,h&=8191,h+=T*(5*M),h+=B*(5*j),h+=C*(5*K),h+=(P+=8191&(c>>>8|f<<8))*(5*L),p=l+=(h+=(O+=f>>>5|S)*(5*N))>>>13,p+=k*N,p+=E*R,p+=A*(5*q),p+=x*(5*F),l=(p+=I*(5*U))>>>13,p&=8191,p+=T*(5*D),p+=B*(5*M),p+=C*(5*j),p+=P*(5*K),l+=(p+=O*(5*L))>>>13,p&=8191,d=l,d+=k*L,d+=E*N,d+=A*R,d+=x*(5*q),l=(d+=I*(5*F))>>>13,d&=8191,d+=T*(5*U),d+=B*(5*D),d+=C*(5*M),d+=P*(5*j),y=l+=(d+=O*(5*K))>>>13,y+=k*K,y+=E*L,y+=A*N,y+=x*R,l=(y+=I*(5*q))>>>13,y&=8191,y+=T*(5*F),y+=B*(5*U),y+=C*(5*D),y+=P*(5*M),g=l+=(y+=O*(5*j))>>>13,g+=k*j,g+=E*K,g+=A*L,g+=x*N,l=(g+=I*R)>>>13,g&=8191,g+=T*(5*q),g+=B*(5*F),g+=C*(5*U),g+=P*(5*D),m=l+=(g+=O*(5*M))>>>13,m+=k*M,m+=E*j,m+=A*K,m+=x*L,l=(m+=I*N)>>>13,m&=8191,m+=T*R,m+=B*(5*q),m+=C*(5*F),m+=P*(5*U),b=l+=(m+=O*(5*D))>>>13,b+=k*D,b+=E*M,b+=A*j,b+=x*K,l=(b+=I*L)>>>13,b&=8191,b+=T*N,b+=B*R,b+=C*(5*q),b+=P*(5*F),v=l+=(b+=O*(5*U))>>>13,v+=k*U,v+=E*D,v+=A*M,v+=x*j,l=(v+=I*K)>>>13,v&=8191,v+=T*L,v+=B*N,v+=C*R,v+=P*(5*q),_=l+=(v+=O*(5*F))>>>13,_+=k*F,_+=E*U,_+=A*D,_+=x*M,l=(_+=I*j)>>>13,_&=8191,_+=T*K,_+=B*L,_+=C*N,_+=P*R,w=l+=(_+=O*(5*q))>>>13,w+=k*q,w+=E*F,w+=A*U,w+=x*D,l=(w+=I*M)>>>13,w&=8191,w+=T*j,w+=B*K,w+=C*L,w+=P*N,k=h=8191&(l=(l=((l+=(w+=O*R)>>>13)<<2)+l|0)+(h&=8191)|0),E=p+=l>>>=13,A=d&=8191,x=y&=8191,I=g&=8191,T=m&=8191,B=b&=8191,C=v&=8191,P=_&=8191,O=w&=8191,t+=16,r-=16;this.h[0]=k,this.h[1]=E,this.h[2]=A,this.h[3]=x,this.h[4]=I,this.h[5]=T,this.h[6]=B,this.h[7]=C,this.h[8]=P,this.h[9]=O},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++)k=8*S+Y,C[S]=r[k+0]<<24|r[k+1]<<16|r[k+2]<<8|r[k+3],P[S]=r[k+4]<<24|r[k+5]<<16|r[k+6]<<8|r[k+7];for(S=0;S<80;S++)if(i=O,o=R,s=N,a=L,u=K,c=j,f=M,l=D,h=U,p=F,d=q,y=H,g=z,m=V,b=G,v=W,x=65535&(A=W),I=A>>>16,T=65535&(E=D),B=E>>>16,x+=65535&(A=(z>>>14|K<<18)^(z>>>18|K<<14)^(K>>>9|z<<23)),I+=A>>>16,T+=65535&(E=(K>>>14|z<<18)^(K>>>18|z<<14)^(z>>>9|K<<23)),B+=E>>>16,x+=65535&(A=z&V^~z&G),I+=A>>>16,T+=65535&(E=K&j^~K&M),B+=E>>>16,E=$[2*S],x+=65535&(A=$[2*S+1]),I+=A>>>16,T+=65535&E,B+=E>>>16,E=C[S%16],I+=(A=P[S%16])>>>16,T+=65535&E,B+=E>>>16,T+=(I+=(x+=65535&A)>>>16)>>>16,x=65535&(A=w=65535&x|I<<16),I=A>>>16,T=65535&(E=_=65535&T|(B+=T>>>16)<<16),B=E>>>16,x+=65535&(A=(U>>>28|O<<4)^(O>>>2|U<<30)^(O>>>7|U<<25)),I+=A>>>16,T+=65535&(E=(O>>>28|U<<4)^(U>>>2|O<<30)^(U>>>7|O<<25)),B+=E>>>16,I+=(A=U&F^U&q^F&q)>>>16,T+=65535&(E=O&R^O&N^R&N),B+=E>>>16,l=65535&(T+=(I+=(x+=65535&A)>>>16)>>>16)|(B+=T>>>16)<<16,v=65535&x|I<<16,x=65535&(A=y),I=A>>>16,T=65535&(E=a),B=E>>>16,I+=(A=w)>>>16,T+=65535&(E=_),B+=E>>>16,R=i,N=o,L=s,K=a=65535&(T+=(I+=(x+=65535&A)>>>16)>>>16)|(B+=T>>>16)<<16,j=u,M=c,D=f,O=l,F=h,q=p,H=d,z=y=65535&x|I<<16,V=g,G=m,W=b,U=v,S%16==15)for(k=0;k<16;k++)E=C[k],x=65535&(A=P[k]),I=A>>>16,T=65535&E,B=E>>>16,E=C[(k+9)%16],x+=65535&(A=P[(k+9)%16]),I+=A>>>16,T+=65535&E,B+=E>>>16,_=C[(k+1)%16],x+=65535&(A=((w=P[(k+1)%16])>>>1|_<<31)^(w>>>8|_<<24)^(w>>>7|_<<25)),I+=A>>>16,T+=65535&(E=(_>>>1|w<<31)^(_>>>8|w<<24)^_>>>7),B+=E>>>16,_=C[(k+14)%16],I+=(A=((w=P[(k+14)%16])>>>19|_<<13)^(_>>>29|w<<3)^(w>>>6|_<<26))>>>16,T+=65535&(E=(_>>>19|w<<13)^(w>>>29|_<<3)^_>>>6),B+=E>>>16,B+=(T+=(I+=(x+=65535&A)>>>16)>>>16)>>>16,C[k]=65535&T|B<<16,P[k]=65535&x|I<<16;x=65535&(A=U),I=A>>>16,T=65535&(E=O),B=E>>>16,E=e[0],I+=(A=t[0])>>>16,T+=65535&E,B+=E>>>16,B+=(T+=(I+=(x+=65535&A)>>>16)>>>16)>>>16,e[0]=O=65535&T|B<<16,t[0]=U=65535&x|I<<16,x=65535&(A=F),I=A>>>16,T=65535&(E=R),B=E>>>16,E=e[1],I+=(A=t[1])>>>16,T+=65535&E,B+=E>>>16,B+=(T+=(I+=(x+=65535&A)>>>16)>>>16)>>>16,e[1]=R=65535&T|B<<16,t[1]=F=65535&x|I<<16,x=65535&(A=q),I=A>>>16,T=65535&(E=N),B=E>>>16,E=e[2],I+=(A=t[2])>>>16,T+=65535&E,B+=E>>>16,B+=(T+=(I+=(x+=65535&A)>>>16)>>>16)>>>16,e[2]=N=65535&T|B<<16,t[2]=q=65535&x|I<<16,x=65535&(A=H),I=A>>>16,T=65535&(E=L),B=E>>>16,E=e[3],I+=(A=t[3])>>>16,T+=65535&E,B+=E>>>16,B+=(T+=(I+=(x+=65535&A)>>>16)>>>16)>>>16,e[3]=L=65535&T|B<<16,t[3]=H=65535&x|I<<16,x=65535&(A=z),I=A>>>16,T=65535&(E=K),B=E>>>16,E=e[4],I+=(A=t[4])>>>16,T+=65535&E,B+=E>>>16,B+=(T+=(I+=(x+=65535&A)>>>16)>>>16)>>>16,e[4]=K=65535&T|B<<16,t[4]=z=65535&x|I<<16,x=65535&(A=V),I=A>>>16,T=65535&(E=j),B=E>>>16,E=e[5],I+=(A=t[5])>>>16,T+=65535&E,B+=E>>>16,B+=(T+=(I+=(x+=65535&A)>>>16)>>>16)>>>16,e[5]=j=65535&T|B<<16,t[5]=V=65535&x|I<<16,x=65535&(A=G),I=A>>>16,T=65535&(E=M),B=E>>>16,E=e[6],I+=(A=t[6])>>>16,T+=65535&E,B+=E>>>16,B+=(T+=(I+=(x+=65535&A)>>>16)>>>16)>>>16,e[6]=M=65535&T|B<<16,t[6]=G=65535&x|I<<16,x=65535&(A=W),I=A>>>16,T=65535&(E=D),B=E>>>16,E=e[7],I+=(A=t[7])>>>16,T+=65535&E,B+=E>>>16,B+=(T+=(I+=(x+=65535&A)>>>16)>>>16)>>>16,e[7]=D=65535&T|B<<16,t[7]=W=65535&x|I<<16,Y+=128,n-=128}return n}function J(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,Y(i,o,t,r),r%=128,n=0;n=0;--i)Z(e,t,n=r[i/8|0]>>(7&i)&1),X(t,e),X(e,e),Z(e,t,n)}function te(e,r){var n=[t(),t(),t(),t()];C(n[0],l),C(n[1],h),C(n[2],a),D(n[3],l,h),ee(e,n,r)}function re(e,r,i){var o,s=new Uint8Array(64),a=[t(),t(),t(),t()];for(i||n(r,32),J(s,r,32),s[0]&=248,s[31]&=127,s[31]|=64,te(a,s),Q(e,a),o=0;o<32;o++)r[o+32]=e[o];return 0}var ne=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 ie(e,t){var r,n,i,o;for(n=63;n>=32;--n){for(r=0,i=n-32,o=n-12;i>8,t[i]-=256*r;t[i]+=r,t[n]=0}for(r=0,i=0;i<32;i++)t[i]+=r-(t[31]>>4)*ne[i],r=t[i]>>8,t[i]&=255;for(i=0;i<32;i++)t[i]-=r*ne[i];for(n=0;n<32;n++)t[n+1]+=t[n]>>8,e[n]=255&t[n]}function oe(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;ie(e,r)}function se(e,r,n,i){var o,s,a=new Uint8Array(64),u=new Uint8Array(64),c=new Uint8Array(64),f=new Float64Array(64),l=[t(),t(),t(),t()];J(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var h=n+64;for(o=0;o=0;n--)U(i,i),1!==n&&D(i,i,r);for(n=0;n<16;n++)e[n]=i[n]}(n,n),D(n,n,o),D(n,n,u),D(n,n,u),D(e[0],n,u),U(i,e[0]),D(i,i,u),N(i,o)&&D(e[0],e[0],p),U(i,e[0]),D(i,i,u),N(i,o)?-1:(L(e[0])===r[31]>>7&&M(e[0],s,e[0]),D(e[3],e[0],e[1]),0)}function ue(e,r,n,i){var o,s=new Uint8Array(32),a=new Uint8Array(64),u=[t(),t(),t(),t()],c=[t(),t(),t(),t()];if(-1,n<64)return-1;if(ae(c,i))return-1;for(o=0;o=0},e.sign.keyPair=function(){var e=new Uint8Array(32),t=new Uint8Array(64);return re(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if(ye(e),64!==e.length)throw new Error("bad secret key size");for(var t=new Uint8Array(32),r=0;r{i=i||r(946)(t);class o{constructor(e){i.validatePublicKey(e),this._key=e}verify(e,t,r){a(r),i.hashAndVerify(this._key,t,e,r)}marshal(){return i.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){a(e),n(this.bytes,"sha2-256",e)}}class s{constructor(e,t){this._key=e,this._publicKey=t||i.computePublicKey(e),i.validatePrivateKey(this._key),i.validatePublicKey(this._publicKey)}sign(e,t){a(t),i.hashAndSign(this._key,e,t)}get public(){return new o(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){a(e),n(this.bytes,"sha2-256",e)}}function a(e){if("function"!=typeof e)throw new Error("callback is required")}return{Secp256k1PublicKey:o,Secp256k1PrivateKey:s,unmarshalSecp256k1PrivateKey:function(e,t){t(null,new s(e),null)},unmarshalSecp256k1PublicKey:function(e){return new o(e)},generateKeyPair:function(e,t){void 0===t&&"function"==typeof e&&(t=e),a(t),i.generateKey((e,r)=>{if(e)return t(e);let n;try{n=new s(r)}catch(e){return t(e)}t(null,n)})}}})},function(e,t,r){"use strict";e.exports=function(e,{className:t,symbolName:r}){const n=Symbol.for(r),i={[t]:class extends e{constructor(...e){super(...e),Object.defineProperty(this,n,{value:!0})}get[Symbol.toStringTag](){return t}}}[t];return i[`is${t}`]=(e=>!(!e||!e[n])),i},e.exports.proto=function(e,{className:t,symbolName:r,withoutNew:n}){const i=Symbol.for(r),o={[t]:function(...t){if(n&&!(this instanceof o))return new o(...t);const r=e.call(this,...t)||this;return r&&!r[i]&&Object.defineProperty(r,i,{value:!0}),r}}[t];return o.prototype=Object.create(e.prototype),o.prototype.constructor=o,Object.defineProperty(o.prototype,Symbol.toStringTag,{get:()=>t}),o[`is${t}`]=(e=>!(!e||!e[i])),o}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){(0,i.default)(n.default,e,t)};var n=o(r(218)),i=o(r(354));function o(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default},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}var n=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,i=function(e){return n.exec(e).slice(1)};function o(e,t){if(e.filter)return e.filter(t);for(var r=[],n=0;n=-1&&!n;i--){var s=i>=0?arguments[i]:e.cwd();if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");s&&(t=s+"/"+t,n="/"===s.charAt(0))}return t=r(o(t.split("/"),function(e){return!!e}),!n).join("/"),(n?"/":"")+t||"."},t.normalize=function(e){var n=t.isAbsolute(e),i="/"===s(e,-1);return(e=r(o(e.split("/"),function(e){return!!e}),!n).join("/"))||n||(e="."),e&&i&&(e+="/"),(n?"/":"")+e},t.isAbsolute=function(e){return"/"===e.charAt(0)},t.join=function(){var e=Array.prototype.slice.call(arguments,0);return t.normalize(o(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,u=0;u{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){"use strict";var n=r(18);var i=function(e,t){var r=function(){if(n.isString(t.message))this.message=function(e,t){return e.replace("{0}",t[0]).replace("{1}",t[1]).replace("{2}",t[2])}(t.message,arguments);else{if(!n.isFunction(t.message))throw new Error("Invalid error definition for "+t.name);this.message=t.message.apply(null,arguments)}this.stack=this.message+"\n"+(new Error).stack};return(r.prototype=Object.create(e.prototype)).name=e.prototype.name+t.name,e[t.name]=r,t.errors&&o(r,t.errors),r},o=function(e,t){n.each(t,function(t){i(e,t)})},s={Error:function(){this.message="Internal error",this.stack=this.message+"\n"+(new Error).stack}};s.Error.prototype=Object.create(Error.prototype),s.Error.prototype.name="bitcore.Error";var a=r(873);(function(e,t){o(e,t)})(s.Error,a),e.exports=s.Error,e.exports.extend=function(e){return i(s.Error,e)}},function(e,t,r){"use strict";(function(t){var n=r(32),i=r(18),o=r(21),s=r(24),a=r(29),u=function e(t,r){if(!(this instanceof e))return new e(t,r);if(t instanceof n)this.set({r:t,s:r});else if(t){var i=t;this.set(i)}};u.prototype.set=function(e){return this.r=e.r||this.r||void 0,this.s=e.s||this.s||void 0,this.i=void 0!==e.i?e.i:this.i,this.compressed=void 0!==e.compressed?e.compressed:this.compressed,this.nhashtype=e.nhashtype||this.nhashtype||void 0,this},u.fromCompact=function(e){o.checkArgument(s.isBuffer(e),"Argument is expected to be a Buffer");var t=new u,r=!0,i=e.slice(0,1)[0]-27-4;i<0&&(r=!1,i+=4);var a=e.slice(1,33),c=e.slice(33,65);return o.checkArgument(0===i||1===i||2===i||3===i,new Error("i must be 0, 1, 2, or 3")),o.checkArgument(32===a.length,new Error("r must be 32 bytes")),o.checkArgument(32===c.length,new Error("s must be 32 bytes")),t.compressed=r,t.i=i,t.r=n.fromBuffer(a),t.s=n.fromBuffer(c),t},u.fromDER=u.fromBuffer=function(e,t){var r=u.parseDER(e,t),n=new u;return n.r=r.r,n.s=r.s,n},u.fromTxFormat=function(e){var t=e.readUInt8(e.length-1),r=e.slice(0,e.length-1),n=new u.fromDER(r,!1);return n.nhashtype=t,n},u.fromString=function(e){var r=new t(e,"hex");return u.fromDER(r)},u.parseDER=function(e,t){o.checkArgument(s.isBuffer(e),new Error("DER formatted signature should be a buffer")),i.isUndefined(t)&&(t=!0);var r=e[0];o.checkArgument(48===r,new Error("Header byte should be 0x30"));var a=e[1],u=e.slice(2).length;o.checkArgument(!t||a===u,new Error("Length byte should length of what follows")),a=a73)return!1;if(48!==e[0])return!1;if(e[1]!==e.length-3)return!1;var t=e[3];if(5+t>=e.length)return!1;var r=e[5+t];if(t+r+7!==e.length)return!1;var n=e.slice(4);if(2!==e[2])return!1;if(0===t)return!1;if(128&n[0])return!1;if(t>1&&0===n[0]&&!(128&n[1]))return!1;var i=e.slice(6+t);return!(2!==e[6+t-2]||0===r||128&i[0]||r>1&&0===i[0]&&!(128&i[1]))},u.prototype.hasLowS=function(){return!this.s.lt(new n(1))&&!this.s.gt(new n("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex"))},u.prototype.hasDefinedHashtype=function(){if(!a.isNaturalNumber(this.nhashtype))return!1;var e=this.nhashtype&~u.SIGHASH_ANYONECANPAY;return!(eu.SIGHASH_SINGLE)},u.prototype.toTxFormat=function(){var e=this.toDER(),r=new t(1);return r.writeUInt8(this.nhashtype,0),t.concat([e,r])},u.SIGHASH_ALL=1,u.SIGHASH_NONE=2,u.SIGHASH_SINGLE=3,u.SIGHASH_ANYONECANPAY=128,e.exports=u}).call(this,r(0).Buffer)},function(e,t,r){e.exports=r(433),e.exports.Interpreter=r(892)},function(e,t,r){var n=r(13);r(98),r(451),r(452),r(19),n.random&&n.random.getBytes?e.exports=n.random:function(t){var r={},i=new Array(4),o=n.util.createBuffer();function s(){var e=n.prng.create(r);return e.getBytes=function(t,r){return e.generate(t,r)},e.getBytesSync=function(t){return e.generate(t)},e}r.formatKey=function(e){var t=n.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),n.aes._expandKey(e,!1)},r.formatSeed=function(e){var t=n.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),e},r.cipher=function(e,t){return n.aes._updateBlock(e,t,i,!1),o.putInt32(i[0]),o.putInt32(i[1]),o.putInt32(i[2]),o.putInt32(i[3]),o.getBytes()},r.increment=function(e){return++e[3],e},r.md=n.md.sha256;var a=s(),u=null;if("undefined"!=typeof window){var c=window.crypto||window.msCrypto;c&&c.getRandomValues&&(u=function(e){return c.getRandomValues(e)})}if(n.options.usePureJavaScript||!n.util.isNodejs&&!u){if("undefined"==typeof window||window.document,a.collectInt(+new Date,32),"undefined"!=typeof navigator){var f="";for(var l in navigator)try{"string"==typeof navigator[l]&&(f+=navigator[l])}catch(e){}a.collect(f),f=null}t&&(t().mousemove(function(e){a.collectInt(e.clientX,16),a.collectInt(e.clientY,16)}),t().keypress(function(e){a.collectInt(e.charCode,8)}))}if(n.random)for(var l in a)n.random[l]=a[l];else n.random=a;n.random.createInstance=s,e.exports=n.random}("undefined"!=typeof jQuery?jQuery:null)},function(e,t,r){"use strict";e.exports=function e(t){var r=arguments.length;if("function"==typeof t&&1===t.length){for(var n=new Array(r),i=0;i>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function s(e){return 1===e.length?"0"+e:e}function a(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),n=0;n>8,s=255&i;o?r.push(o,s):r.push(s)}else for(n=0;n>>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 u=0,c=t;return u+=(c=c+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,u,c){var f=0,l=t;return f+=(l=l+n>>>0)>>0)>>0)>>0)>>0},t.sum64_5_lo=function(e,t,r,n,i,o,s,a,u,c){return t+n+o+a+c>>>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";var n=t;n.version=r(874).version,n.utils=r(875),n.rand=r(876),n.hmacDRBG=r(877),n.curve=r(175),n.curves=r(887),n.ec=r(889)},function(e,t,r){"use strict";(function(t){var n=r(32),i=r(108),o=r(43),s=r(29),a=r(96),u=r(18),c=r(21);function f(e,t){if(!(this instanceof f))return new f(e,t);if(c.checkArgument(e,"First argument is required, please include public key data."),e instanceof f)return e;t=t||{};var r=this._classifyArgs(e,t);return r.point.validate(),s.defineImmutable(this,{point:r.point,compressed:r.compressed,network:r.network||a.defaultNetwork}),this}f.prototype._classifyArgs=function(e,r){var n={compressed:u.isUndefined(r.compressed)||r.compressed};if(e instanceof i)n.point=e;else if(e.x&&e.y)n=f._transformObject(e);else if("string"==typeof e)n=f._transformDER(new t(e,"hex"));else if(f._isBuffer(e))n=f._transformDER(e);else{if(!f._isPrivateKey(e))throw new TypeError("First argument is an unrecognized data format.");n=f._transformPrivateKey(e)}return n.network||(n.network=u.isUndefined(r.network)?void 0:a.get(r.network)),n},f._isPrivateKey=function(e){return e instanceof r(176)},f._isBuffer=function(e){return e instanceof t||e instanceof Uint8Array},f._transformPrivateKey=function(e){c.checkArgument(f._isPrivateKey(e),"Must be an instance of PrivateKey");var t={};return t.point=i.getG().mul(e.bn),t.compressed=e.compressed,t.network=e.network,t},f._transformDER=function(e,t){c.checkArgument(f._isBuffer(e),"Must be a hex buffer of DER encoded public key");var r,o,s,a,l={};if(t=!!u.isUndefined(t)||t,4!==e[0]&&(t||6!==e[0]&&7!==e[0]))if(3===e[0])s=e.slice(1),r=new n(s),(l=f._transformX(!0,r)).compressed=!0;else{if(2!==e[0])throw new TypeError("Invalid DER format public key");s=e.slice(1),r=new n(s),(l=f._transformX(!1,r)).compressed=!0}else{if(s=e.slice(1,33),a=e.slice(33,65),32!==s.length||32!==a.length||65!==e.length)throw new TypeError("Length of x and y must be 32 bytes");r=new n(s),o=new n(a),l.point=new i(r,o),l.compressed=!1}return l},f._transformX=function(e,t){c.checkArgument("boolean"==typeof e,"Must specify whether y is odd or not (true or false)");var r={};return r.point=i.fromX(e,t),r},f._transformObject=function(e){var t=new n(e.x,"hex"),r=new n(e.y,"hex");return new f(new i(t,r),{compressed:e.compressed})},f.fromPrivateKey=function(e){c.checkArgument(f._isPrivateKey(e),"Must be an instance of PrivateKey");var t=f._transformPrivateKey(e);return new f(t.point,{compressed:t.compressed,network:t.network})},f.fromDER=f.fromBuffer=function(e,t){c.checkArgument(f._isBuffer(e),"Must be a hex buffer of DER encoded public key");var r=f._transformDER(e,t);return new f(r.point,{compressed:r.compressed})},f.fromPoint=function(e,t){return c.checkArgument(e instanceof i,"First argument must be an instance of Point."),new f(e,{compressed:t})},f.fromString=function(e,r){var n=new t(e,r||"hex"),i=f._transformDER(n);return new f(i.point,{compressed:i.compressed})},f.fromX=function(e,t){var r=f._transformX(e,t);return new f(r.point,{compressed:r.compressed})},f.getValidationError=function(e){var t;try{new f(e)}catch(e){t=e}return t},f.isValid=function(e){return!f.getValidationError(e)},f.prototype.toObject=f.prototype.toJSON=function(){return{x:this.point.getX().toString("hex",2),y:this.point.getY().toString("hex",2),compressed:this.compressed}},f.prototype.toBuffer=f.prototype.toDER=function(){var e,r=this.point.getX(),n=this.point.getY(),i=r.toBuffer({size:32}),o=n.toBuffer({size:32});if(this.compressed){var s=o[o.length-1]%2;return e=new t(s?[3]:[2]),t.concat([e,i])}return e=new t([4]),t.concat([e,i,o])},f.prototype._getID=function(){return o.sha256ripemd160(this.toBuffer())},f.prototype.toAddress=function(e){return r(97).fromPublicKey(this,e||this.network)},f.prototype.toString=function(){return this.toDER().toString("hex")},f.prototype.inspect=function(){return""},e.exports=f}).call(this,r(0).Buffer)},function(e,t,r){(function(e){!function(e,t){"use strict";function r(e,t){if(!e)throw new Error(t||"Assertion failed")}function n(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function i(e,t,r){if(null!==e&&"object"==typeof e&&Array.isArray(e.words))return e;this.sign=!1,this.words=null,this.length=0,this.red=null,"le"!==t&&"be"!==t||(r=t,t=10),null!==e&&this._init(e||0,t||10,r||"be")}function o(e,t,r){for(var n=0,i=Math.min(e.length,r),o=t;o=49&&s<=54?s-49+10:s>=17&&s<=22?s-17+10:15&s}return n}function s(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}"object"==typeof e?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26,i.prototype._init=function(e,t,n){if("number"==typeof e)return e<0&&(this.sign=!0,e=-e),void(e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(r(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3));if("object"==typeof e)return this._initArray(e,t,n);"hex"===t&&(t=16),r(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.sign=!0),this.strip()},i.prototype._initArray=function(e,t,n){if(r("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3){var a=e[i]|e[i-1]<<8|e[i-2]<<16;this.words[s]|=a<>>26-o&67108863,(o+=24)>=26&&(o-=26,s++)}}else if("le"===n)for(i=0,s=0;i>>26-o&67108863,(o+=24)>=26&&(o-=26,s++)}return this.strip()},i.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6){var s=o(e,r,r+6);this.words[i]|=s<>>26-n&4194303,(n+=24)>=26&&(n-=26,i++)}if(r+6!==t){s=o(e,t,r+6);this.words[i]|=s<>>26-n&4194303}this.strip()},i.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,a=o%n,u=Math.min(o,o-a)+r,c=0,f=r;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.sign=!1),this},i.prototype.inspect=function(){return(this.red?""};var a=["","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"],u=[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],c=[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];i.prototype.toString=function(e,t){if(16===(e=e||10)||"hex"===e){for(var n="",i=0,o=(t=0|t||1,0),s=0;s>>24-i&16777215)||s!==this.length-1?a[6-l.length]+l+n:l+n,(i+=2)>=26&&(i-=26,s--)}for(0!==o&&(n=o.toString(16)+n);n.length%t!=0;)n="0"+n;return this.sign&&(n="-"+n),n}if(e===(0|e)&&e>=2&&e<=36){var h=u[e],p=c[e],d=(n="",this.clone());for(d.sign=!1;0!==d.cmpn(0);){var y=d.modn(p).toString(e);n=0!==(d=d.idivn(p)).cmpn(0)?a[h-y.length]+y+n:y+n}return 0===this.cmpn(0)&&(n="0"+n),this.sign&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toArray=function(){this.strip();var e=new Array(this.byteLength());e[0]=0;for(var t=this.clone(),r=0;0!==t.cmpn(0);r++){var n=t.andln(255);t.ishrn(8),e[e.length-r-1]=n}return e},Math.clz32?i.prototype._countBits=function(e){return 32-Math.clz32(e)}:i.prototype._countBits=function(e){var t=e,r=0;return t>=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},i.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},i.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(0===this.cmpn(0))return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},i.prototype.iand=function(e){var t;this.sign=this.sign&&e.sign,t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},i.prototype.ixor=function(e){var t,r;this.sign=this.sign||e.sign,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)},i.prototype.setn=function(e,t){r("number"==typeof e&&e>=0);for(var n=e/26|0,i=e%26;this.length<=n;)this.words[this.length++]=0;return this.words[n]=t?this.words[n]|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)},i.prototype.isub=function(e){if(e.sign){e.sign=!1;var t=this.iadd(e);return e.sign=!0,t._normSign()}if(this.sign)return this.sign=!1,this.iadd(e),this.sign=!0,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.sign=!1,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>>26,o=67108863&r,s=Math.min(n,e.length-1),a=Math.max(0,n-this.length+1);a<=s;a++){var u=n-a,c=(0|this.words[u])*(0|e.words[a]),f=67108863&c;o=67108863&(f=f+o|0),i=(i=i+(c/67108864|0)|0)+(f>>>26)|0}t.words[n]=o,r=i}return 0!==r?t.words[n]=r:t.length--,t.strip()},i.prototype._bigMulTo=function(e,t){t.sign=e.sign!==this.sign,t.length=this.length+e.length;for(var r=0,n=0,i=0;i>>26)|0)>>>26,o&=67108863}t.words[i]=s,r=o,o=n}return 0!==r?t.words[i]=r:t.length--,t.strip()},i.prototype.mulTo=function(e,t){return this.length+e.length<63?this._smallMulTo(e,t):this._bigMulTo(e,t)},i.prototype.mul=function(e){var t=new i(null);return t.words=new Array(this.length+e.length),this.mulTo(e,t)},i.prototype.imul=function(e){if(0===this.cmpn(0)||0===e.cmpn(0))return this.words[0]=0,this.length=1,this;var t=this.length,r=e.length;this.sign=e.sign!==this.sign,this.length=this.length+e.length,this.words[this.length-1]=0;for(var n=this.length-2;n>=0;n--){for(var i=0,o=0,s=Math.min(n,r-1),a=Math.max(0,n-t+1);a<=s;a++){var u=n-a,c=this.words[u]*e.words[a],f=67108863&c;i+=c/67108864|0,o=67108863&(f+=o),i+=f>>>26}this.words[n]=o,this.words[n+1]+=i,i=0}for(i=0,u=1;u>>26}return this.strip()},i.prototype.imuln=function(e){r("number"==typeof e);for(var t=0,n=0;n>=26,t+=i/67108864|0,t+=o>>>26,this.words[n]=67108863&o}return 0!==t&&(this.words[n]=t,this.length++),this},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.mul(this)},i.prototype.ishln=function(e){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26,i=67108863>>>26-t<<26-t;if(0!==t){for(var o=0,s=0;s>>26-t}o&&(this.words[s]=o,this.length++)}if(0!==n){for(s=this.length-1;s>=0;s--)this.words[s+n]=this.words[s];for(s=0;s=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){this.length-=s;for(c=0;c=0&&(0!==f||c>=i);c--){var l=this.words[c];this.words[c]=f<<26-o|l>>>o,f=l&a}return u&&0!==f&&(u.words[u.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip(),this},i.prototype.shln=function(e){return this.clone().ishln(e)},i.prototype.shrn=function(e){return this.clone().ishrn(e)},i.prototype.testn=function(e){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26,i=1<=0);var t=e%26,n=(e-t)/26;if(r(!this.sign,"imaskn works only with positive numbers"),0!==t&&n++,this.length=Math.min(n,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},i.prototype.isubn=function(e){if(r("number"==typeof e),e<0)return this.iaddn(-e);if(this.sign)return this.sign=!1,this.iaddn(e),this.sign=!0,this;this.words[0]-=e;for(var t=0;t>26)-(c/67108864|0),this.words[s+n]=67108863&u}for(;s>26,this.words[s+n]=67108863&u}if(0===a)return this.strip();r(-1===a),a=0;for(s=0;s>26,this.words[s]=67108863&u}return this.sign=!0,this.strip()},i.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),o=e,s=o.words[o.length-1];0!=(r=26-this._countBits(s))&&(o=o.shln(r),n.ishln(r),s=o.words[o.length-1]);var a,u=n.length-o.length;if("mod"!==t){(a=new i(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c=0;l--){var h=67108864*n.words[o.length+l]+n.words[o.length+l-1];for(h=Math.min(h/s|0,67108863),n._ishlnsubmul(o,h,l);n.sign;)h--,n.sign=!1,n._ishlnsubmul(o,1,l),0!==n.cmpn(0)&&(n.sign=!n.sign);a&&(a.words[l]=h)}return a&&a.strip(),n.strip(),"div"!==t&&0!==r&&n.ishrn(r),{div:a||null,mod:n}},i.prototype.divmod=function(e,t){if(r(0!==e.cmpn(0)),this.sign&&!e.sign){var n,o=this.neg().divmod(e,t);return"mod"!==t&&(s=o.div.neg()),"div"!==t&&(n=0===o.mod.cmpn(0)?o.mod:e.sub(o.mod)),{div:s,mod:n}}if(!this.sign&&e.sign){var s;o=this.divmod(e.neg(),t);return"mod"!==t&&(s=o.div.neg()),{div:s,mod:o.mod}}return this.sign&&e.sign?this.neg().divmod(e.neg(),t):e.length>this.length||this.cmp(e)<0?{div:new i(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new i(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new i(this.modn(e.words[0]))}:this._wordDiv(e,t)},i.prototype.div=function(e){return this.divmod(e,"div").div},i.prototype.mod=function(e){return this.divmod(e,"mod").mod},i.prototype.divRound=function(e){var t=this.divmod(e);if(0===t.mod.cmpn(0))return t.div;var r=t.div.sign?t.mod.isub(e):t.mod,n=e.shrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:t.div.sign?t.div.isubn(1):t.div.iaddn(1)},i.prototype.modn=function(e){r(e<=67108863);for(var t=(1<<26)%e,n=0,i=this.length-1;i>=0;i--)n=(t*n+this.words[i])%e;return n},i.prototype.idivn=function(e){r(e<=67108863);for(var t=0,n=this.length-1;n>=0;n--){var i=this.words[n]+67108864*t;this.words[n]=i/e|0,t=i%e}return this.strip()},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){r(!e.sign),r(0!==e.cmpn(0));var t=this,n=e.clone();t=t.sign?t.mod(e):t.clone();for(var o=new i(1),s=new i(0),a=new i(0),u=new i(1),c=0;t.isEven()&&n.isEven();)t.ishrn(1),n.ishrn(1),++c;for(var f=n.clone(),l=t.clone();0!==t.cmpn(0);){for(;t.isEven();)t.ishrn(1),o.isEven()&&s.isEven()?(o.ishrn(1),s.ishrn(1)):(o.iadd(f).ishrn(1),s.isub(l).ishrn(1));for(;n.isEven();)n.ishrn(1),a.isEven()&&u.isEven()?(a.ishrn(1),u.ishrn(1)):(a.iadd(f).ishrn(1),u.isub(l).ishrn(1));t.cmp(n)>=0?(t.isub(n),o.isub(a),s.isub(u)):(n.isub(t),a.isub(o),u.isub(s))}return{a:a,b:u,gcd:n.ishln(c)}},i.prototype._invmp=function(e){r(!e.sign),r(0!==e.cmpn(0));var t=this,n=e.clone();t=t.sign?t.mod(e):t.clone();for(var o=new i(1),s=new i(0),a=n.clone();t.cmpn(1)>0&&n.cmpn(1)>0;){for(;t.isEven();)t.ishrn(1),o.isEven()?o.ishrn(1):o.iadd(a).ishrn(1);for(;n.isEven();)n.ishrn(1),s.isEven()?s.ishrn(1):s.iadd(a).ishrn(1);t.cmp(n)>=0?(t.isub(n),o.isub(s)):(n.isub(t),s.isub(o))}return 0===t.cmpn(1)?o:s},i.prototype.gcd=function(e){if(0===this.cmpn(0))return e.clone();if(0===e.cmpn(0))return this.clone();var t=this.clone(),r=e.clone();t.sign=!1,r.sign=!1;for(var n=0;t.isEven()&&r.isEven();n++)t.ishrn(1),r.ishrn(1);for(;;){for(;t.isEven();)t.ishrn(1);for(;r.isEven();)r.ishrn(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.ishln(n)},i.prototype.invm=function(e){return this.egcd(e).a.mod(e)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){r("number"==typeof e);var t=e%26,n=(e-t)/26,i=1<>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},i.prototype.cmpn=function(e){var t,r=e<0;if(r&&(e=-e),this.sign&&!r)return-1;if(!this.sign&&r)return 1;if(e&=67108863,this.strip(),this.length>1)t=1;else{var n=this.words[0];t=n===e?0:ne.length)return 1;if(this.length=0;r--){var n=this.words[r],i=e.words[r];if(n!==i){ni&&(t=1);break}}return t},i.red=function(e){return new g(e)},i.prototype.toRed=function(e){return r(!this.red,"Already a number in reduction context"),r(!this.sign,"red works only with positives"),e.convertTo(this)._forceRed(e)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(e){return this.red=e,this},i.prototype.forceRed=function(e){return r(!this.red,"Already a number in reduction context"),this._forceRed(e)},i.prototype.redAdd=function(e){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},i.prototype.redIAdd=function(e){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},i.prototype.redSub=function(e){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},i.prototype.redISub=function(e){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},i.prototype.redShl=function(e){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},i.prototype.redMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},i.prototype.redIMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(e){return r(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var f={k256:null,p224:null,p192:null,p25519:null};function l(e,t){this.name=e,this.p=new i(t,16),this.n=this.p.bitLength(),this.k=new i(1).ishln(this.n).isub(this.p),this.tmp=this._tmp()}function h(){l.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function p(){l.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function d(){l.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function y(){l.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function g(e){if("string"==typeof e){var t=i._prime(e);this.m=t.p,this.prime=t}else this.m=e,this.prime=null}function m(e){g.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(1).ishln(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.sign=!0,this.minv=this.minv.mod(this.r)}l.prototype._tmp=function(){var e=new i(null);return e.words=new Array(Math.ceil(this.n/13)),e},l.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):r.strip(),r},l.prototype.split=function(e,t){e.ishrn(this.n,0,t)},l.prototype.imulK=function(e){return e.imul(this.k)},n(h,l),h.prototype.split=function(e,t){for(var r=4194303,n=Math.min(e.length,9),i=0;i>>22,o=s}e.words[i-10]=o>>>22,e.length-=9},h.prototype.imulK=function(e){var t;e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var r=0,n=0;n>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},i._prime=function(e){if(f[e])return f[e];var t;if("k256"===e)t=new h;else if("p224"===e)t=new p;else if("p192"===e)t=new d;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new y}return f[e]=t,t},g.prototype._verify1=function(e){r(!e.sign,"red works only with positives"),r(e.red,"red works only with red numbers")},g.prototype._verify2=function(e,t){r(!e.sign&&!t.sign,"red works only with positives"),r(e.red&&e.red===t.red,"red works only with red numbers")},g.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.mod(this.m)._forceRed(this)},g.prototype.neg=function(e){var t=e.clone();return t.sign=!t.sign,t.iadd(this.m)._forceRed(this)},g.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)},g.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},g.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)},g.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},g.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.shln(t))},g.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},g.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},g.prototype.isqr=function(e){return this.imul(e,e)},g.prototype.sqr=function(e){return this.mul(e,e)},g.prototype.sqrt=function(e){if(0===e.cmpn(0))return e.clone();var t=this.m.andln(3);if(r(t%2==1),3===t){var n=this.m.add(new i(1)).ishrn(2);return this.pow(e,n)}for(var o=this.m.subn(1),s=0;0!==o.cmpn(0)&&0===o.andln(1);)s++,o.ishrn(1);r(0!==o.cmpn(0));var a=new i(1).toRed(this),u=a.redNeg(),c=this.m.subn(1).ishrn(1),f=this.m.bitLength();for(f=new i(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var l=this.pow(f,o),h=this.pow(e,o.addn(1).ishrn(1)),p=this.pow(e,o),d=s;0!==p.cmp(a);){for(var y=p,g=0;0!==y.cmp(a);g++)y=y.redSqr();r(g=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},m.prototype.mul=function(e,t){if(0===e.cmpn(0)||0===t.cmpn(0))return new i(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(n).ishrn(this.shift),s=o;return o.cmp(this.m)>=0?s=o.isub(this.m):o.cmpn(0)<0&&(s=o.iadd(this.m)),s._forceRed(this)},m.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===e||e,this)}).call(this,r(27)(e))},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){var n=r(13);r(19),r(99);var i=e.exports=n.asn1=n.asn1||{};function o(e,t,r){if(r>t){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=[],u=0;ur){if(a.strict){var y=new Error("Too few bytes to read ASN.1 value.");throw y.available=t.length(),y.remaining=r,y.requested=d,y}d=r}var g=32==(32&c);if(g)if(h=[],void 0===d)for(;;){if(o(t,r,2),t.bytes(2)===String.fromCharCode(0,0)){t.getBytes(2),r-=2;break}u=t.length(),h.push(e(t,r,n+1,a)),r-=u-t.length()}else for(;d>0;)u=t.length(),h.push(e(t,d,n+1,a)),r-=u-t.length(),d-=u-t.length();if(void 0===h&&f===i.Class.UNIVERSAL&&l===i.Type.BITSTRING&&(p=t.bytes(d)),void 0===h&&a.decodeBitStrings&&f===i.Class.UNIVERSAL&&l===i.Type.BITSTRING&&d>1){var m=t.read,b=r,v=0;if(l===i.Type.BITSTRING&&(o(t,r,1),v=t.getByte(),r--),0===v)try{u=t.length();var _=e(t,r,n+1,{verbose:a.verbose,strict:!0,decodeBitStrings:!0}),w=u-t.length();r-=w,l==i.Type.BITSTRING&&w++;var S=_.tagClass;w!==d||S!==i.Class.UNIVERSAL&&S!==i.Class.CONTEXT_SPECIFIC||(h=[_])}catch(t){}void 0===h&&(t.read=m,r=b)}if(void 0===h){if(void 0===d){if(a.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");d=r}if(l===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 k=void 0===p?null:{bitStringContents:p};return i.create(f,l,g,h,k)}(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 u=o.length(),c="";do{c+=String.fromCharCode(255&u),u>>>=8}while(u>0);t.putByte(128|c.length);for(a=c.length-1;a>=0;--a)t.putByte(c.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 u=2;u>>=7,t||(o|=128),r.push(o),t=!1}while(i>0);for(var c=r.length-1;c>=0;--c)a.putByte(r[c])}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 u=e.charAt(10),c=10;"+"!==u&&"-"!==u&&(a=parseInt(e.substr(10,2),10),c+=2)}if(t.setUTCFullYear(r,n,i),t.setUTCHours(o,s,a,0),c&&("+"===(u=e.charAt(c))||"-"===u)){var f=60*parseInt(e.substr(c+1,2),10)+parseInt(e.substr(c+4,2),10);f*=6e4,"+"===u?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),u=0,c=0,f=!1;"Z"===e.charAt(e.length-1)&&(f=!0);var l=e.length-5,h=e.charAt(l);return"+"!==h&&"-"!==h||(c=60*parseInt(e.substr(l+1,2),10)+parseInt(e.substr(l+4,2),10),c*=6e4,"+"===h&&(c*=-1),f=!0),"."===e.charAt(14)&&(u=1e3*parseFloat(e.substr(14),10)),f?(t.setUTCFullYear(r,n,i),t.setUTCHours(o,s,a,u),t.setTime(+t+c)):(t.setFullYear(r,n,i),t.setHours(o,s,a,u)),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,u=0;s&&u0&&(o+="\n");for(var s="",u=0;u1?o+="0x"+n.util.bytesToHex(e.value.slice(1)):o+="(none)",e.value.length>0){var h=e.value.charCodeAt(0);1==h?o+=" (1 unused bit shown)":h>1&&(o+=" ("+h+" unused bits shown)")}}else e.type===i.Type.OCTETSTRING?(a.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:a.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(13);e.exports=n.md=n.md||{},n.md.algorithms=n.md.algorithms||{}},function(e,t,r){"use strict";const n=r(1009),i=x("dns4"),o=x("dns6"),s=A(x("dnsaddr"),i,o),a=A(x("ip4"),x("ip6")),u=E(a,x("tcp")),c=E(a,x("udp")),f=E(c,x("utp")),l=A(E(s,x("tcp")),s),h=A(E(u,x("ws")),E(l,x("ws"))),p=A(E(u,x("wss")),E(l,x("wss"))),d=A(E(u,x("http")),E(l),E(l,x("http"))),y=A(E(h,x("p2p-webrtc-star"),x("ipfs")),E(p,x("p2p-webrtc-star"),x("ipfs"))),g=A(E(h,x("p2p-websocket-star"),x("ipfs")),E(p,x("p2p-websocket-star"),x("ipfs")),E(h,x("p2p-websocket-star")),E(p,x("p2p-websocket-star"))),m=E(d,x("p2p-webrtc-direct")),b=A(h,p,d,y,m,u,f);let v=A(E(b,x("ipfs")),y,x("ipfs"));const _=A(E(v,x("p2p-circuit"),v),E(v,x("p2p-circuit")),E(x("p2p-circuit"),v),E(b,x("p2p-circuit")),E(x("p2p-circuit"),b),x("p2p-circuit")),w=()=>A(E(_,w),_),S=w(),k=A(E(S,v,S),E(v,S),E(S,v),S,v);function E(){const e=Array.from(arguments);function t(t){return t.length{if(null===(t="function"==typeof e?e().partialMatch(t):e.partialMatch(t)))return!0}),t)}return{input:e,matches:function(e){"string"==typeof e&&(e=n(e));let r=t(e.protoNames());return null!==r&&0===r.length},partialMatch:t}}function A(){const e=Array.from(arguments);function t(t){let r=null;return e.some(e=>{const n="function"==typeof e?e().partialMatch(t):e.partialMatch(t);if(n)return r=n,!0}),r}return{toString:function(){return"{ "+e.join(" ")+" }"},input:e,matches:function(e){"string"==typeof e&&(e=n(e));const r=t(e.protoNames());return null!==r&&0===r.length},partialMatch:t}}function x(e){const t=e;return{toString:function(){return t},matches:function(e){"string"==typeof e&&(e=n(e));const r=e.protoNames();return 1===r.length&&r[0]===t},partialMatch:function(e){return 0===e.length?null:e[0]===t?e.slice(1):null}}}t.DNS=l,t.DNS4=i,t.DNS6=o,t.IP=a,t.TCP=u,t.UDP=c,t.UTP=f,t.HTTP=d,t.WebSockets=h,t.WebSocketsSecure=p,t.WebSocketStar=g,t.WebRTCStar=y,t.WebRTCDirect=m,t.Reliable=b,t.Circuit=S,t.IPFS=k},function(e,t){errors={};errors.CodingError=class extends Error{constructor(e){super(e||"Coding Error"),this.name="CodingError"}};errors.ToBeImplementedError=class extends Error{constructor(e){super("To be implemented: "+e),this.name="ToBeImplementedError"}};errors.TransportError=class extends Error{constructor(e){super(e||"Transport failure"),this.name="TransportError"}};errors.TimeoutError=class extends Error{constructor(e){super(e||"Timed out"),this.name="TimeoutError"}};errors.IntentionallyUnimplementedError=class extends Error{constructor(e){super(e||"Intentionally Unimplemented Function"),this.name="IntentionallyUnimplementedError"}},e.exports=errors},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=o(r(164)),i=o(r(744));function o(e){return e&&e.__esModule?e:{default:e}}t.default=(0,n.default)(i.default),e.exports=t.default},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";(function(t){var n=r(18),i=r(21),o=r(24),s=r(32),a=function e(r){if(!(this instanceof e))return new e(r);if(!n.isUndefined(r))if(t.isBuffer(r))this.set({buf:r});else if(n.isString(r))this.set({buf:new t(r,"hex")});else{if(!n.isObject(r))throw new TypeError("Unrecognized argument for BufferReader");var i=r;this.set(i)}};a.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this.pos=e.pos||this.pos||0,this},a.prototype.eof=function(){return this.pos>=this.buf.length},a.prototype.finished=a.prototype.eof,a.prototype.read=function(e){i.checkArgument(!n.isUndefined(e),"Must specify a length");var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,t},a.prototype.readAll=function(){var e=this.buf.slice(this.pos,this.buf.length);return this.pos=this.buf.length,e},a.prototype.readUInt8=function(){var e=this.buf.readUInt8(this.pos);return this.pos=this.pos+1,e},a.prototype.readUInt16BE=function(){var e=this.buf.readUInt16BE(this.pos);return this.pos=this.pos+2,e},a.prototype.readUInt16LE=function(){var e=this.buf.readUInt16LE(this.pos);return this.pos=this.pos+2,e},a.prototype.readUInt32BE=function(){var e=this.buf.readUInt32BE(this.pos);return this.pos=this.pos+4,e},a.prototype.readUInt32LE=function(){var e=this.buf.readUInt32LE(this.pos);return this.pos=this.pos+4,e},a.prototype.readUInt64BEBN=function(){var e=this.buf.slice(this.pos,this.pos+8),t=s.fromBuffer(e);return this.pos=this.pos+8,t},a.prototype.readUInt64LEBN=function(){var e,t=this.buf.readUInt32LE(this.pos),r=4294967296*this.buf.readUInt32LE(this.pos+4)+t;if(r<=9007199254740991)e=new s(r);else{var n=Array.prototype.slice.call(this.buf,this.pos,this.pos+8);e=new s(n,10,"le")}return this.pos=this.pos+8,e},a.prototype.readVarintNum=function(){var e=this.readUInt8();switch(e){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:var t=this.readUInt64LEBN().toNumber();if(t<=Math.pow(2,53))return t;throw new Error("number too large to retain precision - use readVarintBN");default:return e}},a.prototype.readVarLengthBuffer=function(){var e=this.readVarintNum(),t=this.read(e);return i.checkState(t.length===e,"Invalid length while reading varlength buffer. Expected to read: "+e+" and read "+t.length),t},a.prototype.readVarintBuf=function(){switch(this.buf.readUInt8(this.pos)){case 253:return this.read(3);case 254:return this.read(5);case 255:return this.read(9);default:return this.read(1)}},a.prototype.readVarintBN=function(){var e=this.readUInt8();switch(e){case 253:return new s(this.readUInt16LE());case 254:return new s(this.readUInt32LE());case 255:return this.readUInt64LEBN();default:return new s(e)}},a.prototype.reverse=function(){for(var e=new t(this.buf.length),r=0;r=m.outputs.length)return new t("0000000000000000000000000000000000000000000000000000000000000001","hex");for(m.outputs.length=h+1,d=0;d9007199254740991?"transaction txout satoshis greater than max safe integer":this._satoshis!==this._satoshisBN.toNumber()?"transaction txout satoshis has corrupted value":this._satoshis<0&&"transaction txout negative"},h.prototype.toObject=h.prototype.toJSON=function(){var e={satoshis:this.satoshis};return e.script=this._scriptBuffer.toString("hex"),e},h.fromObject=function(e){return new h(e)},h.prototype.setScriptFromBuffer=function(e){this._scriptBuffer=e;try{this._script=c.fromBuffer(this._scriptBuffer),this._script._isOutput=!0}catch(e){if(!(e instanceof l.Script.InvalidBuffer))throw e;this._script=null}},h.prototype.setScript=function(e){if(e instanceof c)this._scriptBuffer=e.toBuffer(),this._script=e,this._script._isOutput=!0;else if(n.isString(e))this._script=c.fromString(e),this._scriptBuffer=this._script.toBuffer(),this._script._isOutput=!0;else{if(!s.isBuffer(e))throw new TypeError("Invalid argument type: script");this.setScriptFromBuffer(e)}return this},h.prototype.inspect=function(){var e;return e=this.script?this.script.inspect():this._scriptBuffer.toString("hex"),""},h.fromBufferReader=function(e){var t={};t.satoshis=e.readUInt64LEBN();var r=e.readVarintNum();return t.script=0!==r?e.read(r):new o.Buffer([]),new h(t)},h.prototype.toBufferWriter=function(e){e||(e=new u),e.writeUInt64LEBN(this._satoshisBN);var t=this._scriptBuffer;return e.writeVarintNum(t.length),e.write(t),e},e.exports=h},function(e,t,r){"use strict";var n=r(150),i=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};e.exports=l;var o=r(117);o.inherits=r(5);var s=r(332),a=r(210);o.inherits(l,s);for(var u=i(a.prototype),c=0;c=e.length?o(!0):o(null,e[r++])}}},function(e,t,r){"use strict";var n=r(212);e.exports=function(e){return n(function(e,t){return e.push(t),e},[],e)}},function(e,t){var r=Array.isArray;e.exports=r},function(e,t,r){var n=r(214),i=r(356);e.exports=function(e){return null!=e&&i(e.length)&&!n(e)}},function(e,t,r){e.exports=i;var n=r(11).EventEmitter;function i(){n.call(this)}r(5)(i,n),i.Readable=r(22),i.Writable=r(737),i.Duplex=r(738),i.Transform=r(739),i.PassThrough=r(740),i.Stream=i,i.prototype.pipe=function(e,t){var r=this;function i(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),e.on("drain",o),e._isStdio||t&&!1===t.end||(r.on("end",a),r.on("close",u));var s=!1;function a(){s||(s=!0,e.end())}function u(){s||(s=!0,"function"==typeof e.destroy&&e.destroy())}function c(e){if(f(),0===n.listenerCount(this,"error"))throw e}function f(){r.removeListener("data",i),e.removeListener("drain",o),r.removeListener("end",a),r.removeListener("close",u),r.removeListener("error",c),e.removeListener("error",c),r.removeListener("end",f),r.removeListener("close",f),e.removeListener("close",f)}return r.on("error",c),e.on("error",c),r.on("end",f),r.on("close",f),e.on("close",f),e.emit("pipe",r),e}},function(e,t,r){"use strict";(function(n){const i=r(12),o=r(17),s=r(62);(t=e.exports=s(class{constructor(e,t,r){o(r,"A link requires a multihash to point to"),this._name=e||"",this._size=t,"string"==typeof r?this._multihash=i.fromB58String(r):n.isBuffer(r)&&(this._multihash=r)}toString(){return`DAGLink <${i.toB58String(this.multihash)} - name: "${this.name}", size: ${this.size}>`}toJSON(){return{name:this.name,size:this.size,multihash:i.toB58String(this._multihash)}}get name(){return this._name}set name(e){throw new Error("Can't set property: 'name' is immutable")}get size(){return this._size}set size(e){throw new Error("Can't set property: 'size' is immutable")}get multihash(){return this._multihash}set multihash(e){throw new Error("Can't set property: 'multihash' is immutable")}},{className:"DAGLink",symbolName:"@ipld/js-ipld-dag-pb/daglink"})).create=r(765),t.util=r(766)}).call(this,r(0).Buffer)},function(e,t,r){var n=r(2).Buffer,i=r(90).Transform,o=r(211).StringDecoder;function s(e){i.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}r(5)(s,i),s.prototype.update=function(e,t,r){"string"==typeof e&&(e=n.from(e,t));var i=this._update(e);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)},s.prototype.setAutoPadding=function(){},s.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},s.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},s.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},s.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){n=e}finally{r(n)}},s.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},s.prototype._finalOrDigest=function(e){var t=this.__final()||n.alloc(0);return e&&(t=this._toString(t,e,!0)),t},s.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new o(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n},e.exports=s},function(e,t,r){var n=r(413);r(812),e.exports=n},function(e,t,r){"use strict";t.ethAccountSnapshot=r(416),t.ethBlock=r(426),t.ethBlockList=r(857),t.ethStateTrie=r(862),t.ethStorageTrie=r(865),t.ethTx=r(429),t.ethTxTrie=r(868)},function(e,t){},function(e,t,r){"use strict";var n=r(18),i=r(24),o=r(29),s=[],a={};function u(){}function c(e,t){if(~s.indexOf(e))return e;if(!t)return a[e];n.isArray(t)||(t=[t]);var r=function(t){return s[i][t]===e};for(var i in s)if(n.any(t,r))return s[i]}function f(e){var t=new u;return o.defineImmutable(t,{name:e.name,alias:e.alias,pubkeyhash:e.pubkeyhash,privatekey:e.privatekey,scripthash:e.scripthash,xpubkey:e.xpubkey,xprivkey:e.xprivkey,zaddr:e.zaddr,zkey:e.zkey}),e.networkMagic&&o.defineImmutable(t,{networkMagic:i.integerAsBuffer(e.networkMagic)}),e.port&&o.defineImmutable(t,{port:e.port}),e.dnsSeeds&&o.defineImmutable(t,{dnsSeeds:e.dnsSeeds}),n.each(t,function(e){n.isUndefined(e)||n.isObject(e)||(a[e]=t)}),s.push(t),t}u.prototype.toString=function(){return this.name},f({name:"livenet",alias:"mainnet",pubkeyhash:7352,privatekey:128,scripthash:7357,xpubkey:76067358,xprivkey:76066276,zaddr:5786,zkey:43830,networkMagic:4179340459,port:8233,dnsSeeds:[]});var l=c("livenet");f({name:"testnet",alias:"regtest",pubkeyhash:7461,privatekey:239,scripthash:7354,xpubkey:70617039,xprivkey:70615956,zaddr:5814,zkey:44040});var h=c("testnet"),p={PORT:18233,NETWORK_MAGIC:i.integerAsBuffer(4187956406),DNS_SEEDS:["dnsseed.testnet.z.cash"]};for(var d in p)n.isObject(p[d])||(a[p[d]]=h);var y={PORT:18444,NETWORK_MAGIC:i.integerAsBuffer(2867347295),DNS_SEEDS:[]};for(var d in y)n.isObject(y[d])||(a[y[d]]=h);Object.defineProperty(h,"port",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?y.PORT:p.PORT}}),Object.defineProperty(h,"networkMagic",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?y.NETWORK_MAGIC:p.NETWORK_MAGIC}}),Object.defineProperty(h,"dnsSeeds",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?y.DNS_SEEDS:p.DNS_SEEDS}}),e.exports={add:f,remove:function(e){for(var t=0;t"},e.exports=l;var h=r(68)}).call(this,r(0).Buffer)},function(e,t,r){var n=r(13);function i(e,t){n.cipher.registerAlgorithm(e,function(){return new n.aes.Algorithm(e,t)})}r(257),r(446),r(19),e.exports=n.aes=n.aes||{},n.aes.startEncrypting=function(e,t,r,n){var i=y({key:e,output:r,decrypt:!1,mode:n});return i.start(t),i},n.aes.createEncryptionCipher=function(e,t){return y({key:e,output:null,decrypt:!1,mode:t})},n.aes.startDecrypting=function(e,t,r,n){var i=y({key:e,output:r,decrypt:!0,mode:n});return i.start(t),i},n.aes.createDecryptionCipher=function(e,t){return y({key:e,output:null,decrypt:!0,mode:t})},n.aes.Algorithm=function(e,t){f||h();var r=this;r.name=e,r.mode=new t({blockSize:16,cipher:{encrypt:function(e,t){return d(r._w,e,t,!1)},decrypt:function(e,t){return d(r._w,e,t,!0)}}}),r._init=!1},n.aes.Algorithm.prototype.initialize=function(e){if(!this._init){var t,r=e.key;if("string"!=typeof r||16!==r.length&&24!==r.length&&32!==r.length){if(n.util.isArray(r)&&(16===r.length||24===r.length||32===r.length)){t=r,r=n.util.createBuffer();for(var i=0;i>>=2;for(i=0;i>8^255&l^99,o[y]=l,s[l]=y,p=(h=e[l])<<24^l<<16^l<<8^l^h,d=((r=e[y])^(n=e[r])^(i=e[n]))<<24^(y^i)<<16^(y^n^i)<<8^y^r^i;for(var m=0;m<4;++m)u[m][y]=p,c[m][l]=d,p=p<<24|p>>>8,d=d<<24|d>>>8;0===y?y=g=1:(y=r^e[e[e[r^i]]],g^=e[e[g]])}}function p(e,t){for(var r,n=e.slice(0),i=1,s=n.length,u=l*(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,p=c[0],d=c[1],y=c[2],g=c[3],m=n.slice(0),b=(f=0,(u=n.length)-l);f>>24]]^d[o[h>>>16&255]]^y[o[h>>>8&255]]^g[o[255&h]];n=m}return n}function d(e,t,r,n){var i,a,f,l,h,p,d,y,g,m,b,v,_=e.length/4-1;n?(i=c[0],a=c[1],f=c[2],l=c[3],h=s):(i=u[0],a=u[1],f=u[2],l=u[3],h=o),p=t[0]^e[0],d=t[n?3:1]^e[1],y=t[2]^e[2],g=t[n?1:3]^e[3];for(var w=3,S=1;S<_;++S)m=i[p>>>24]^a[d>>>16&255]^f[y>>>8&255]^l[255&g]^e[++w],b=i[d>>>24]^a[y>>>16&255]^f[g>>>8&255]^l[255&p]^e[++w],v=i[y>>>24]^a[g>>>16&255]^f[p>>>8&255]^l[255&d]^e[++w],g=i[g>>>24]^a[p>>>16&255]^f[d>>>8&255]^l[255&y]^e[++w],p=m,d=b,y=v;r[0]=h[p>>>24]<<24^h[d>>>16&255]<<16^h[y>>>8&255]<<8^h[255&g]^e[++w],r[n?3:1]=h[d>>>24]<<24^h[y>>>16&255]<<16^h[g>>>8&255]<<8^h[255&p]^e[++w],r[2]=h[y>>>24]<<24^h[g>>>16&255]<<16^h[p>>>8&255]<<8^h[255&d]^e[++w],r[n?1:3]=h[g>>>24]<<24^h[p>>>16&255]<<16^h[d>>>8&255]<<8^h[255&y]^e[++w]}function y(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,r){var n=r(13);n.pki=n.pki||{};var i=e.exports=n.pki.oids=n.oids=n.oids||{};function o(e,t){i[e]=t,i[t]=e}function s(e,t){i[e]=t}o("1.2.840.113549.1.1.1","rsaEncryption"),o("1.2.840.113549.1.1.4","md5WithRSAEncryption"),o("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),o("1.2.840.113549.1.1.7","RSAES-OAEP"),o("1.2.840.113549.1.1.8","mgf1"),o("1.2.840.113549.1.1.9","pSpecified"),o("1.2.840.113549.1.1.10","RSASSA-PSS"),o("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),o("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),o("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),o("1.2.840.10040.4.3","dsa-with-sha1"),o("1.3.14.3.2.7","desCBC"),o("1.3.14.3.2.26","sha1"),o("2.16.840.1.101.3.4.2.1","sha256"),o("2.16.840.1.101.3.4.2.2","sha384"),o("2.16.840.1.101.3.4.2.3","sha512"),o("1.2.840.113549.2.5","md5"),o("1.2.840.113549.1.7.1","data"),o("1.2.840.113549.1.7.2","signedData"),o("1.2.840.113549.1.7.3","envelopedData"),o("1.2.840.113549.1.7.4","signedAndEnvelopedData"),o("1.2.840.113549.1.7.5","digestedData"),o("1.2.840.113549.1.7.6","encryptedData"),o("1.2.840.113549.1.9.1","emailAddress"),o("1.2.840.113549.1.9.2","unstructuredName"),o("1.2.840.113549.1.9.3","contentType"),o("1.2.840.113549.1.9.4","messageDigest"),o("1.2.840.113549.1.9.5","signingTime"),o("1.2.840.113549.1.9.6","counterSignature"),o("1.2.840.113549.1.9.7","challengePassword"),o("1.2.840.113549.1.9.8","unstructuredAddress"),o("1.2.840.113549.1.9.14","extensionRequest"),o("1.2.840.113549.1.9.20","friendlyName"),o("1.2.840.113549.1.9.21","localKeyId"),o("1.2.840.113549.1.9.22.1","x509Certificate"),o("1.2.840.113549.1.12.10.1.1","keyBag"),o("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),o("1.2.840.113549.1.12.10.1.3","certBag"),o("1.2.840.113549.1.12.10.1.4","crlBag"),o("1.2.840.113549.1.12.10.1.5","secretBag"),o("1.2.840.113549.1.12.10.1.6","safeContentsBag"),o("1.2.840.113549.1.5.13","pkcs5PBES2"),o("1.2.840.113549.1.5.12","pkcs5PBKDF2"),o("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),o("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),o("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),o("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),o("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),o("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),o("1.2.840.113549.2.7","hmacWithSHA1"),o("1.2.840.113549.2.8","hmacWithSHA224"),o("1.2.840.113549.2.9","hmacWithSHA256"),o("1.2.840.113549.2.10","hmacWithSHA384"),o("1.2.840.113549.2.11","hmacWithSHA512"),o("1.2.840.113549.3.7","des-EDE3-CBC"),o("2.16.840.1.101.3.4.1.2","aes128-CBC"),o("2.16.840.1.101.3.4.1.22","aes192-CBC"),o("2.16.840.1.101.3.4.1.42","aes256-CBC"),o("2.5.4.3","commonName"),o("2.5.4.5","serialName"),o("2.5.4.6","countryName"),o("2.5.4.7","localityName"),o("2.5.4.8","stateOrProvinceName"),o("2.5.4.10","organizationName"),o("2.5.4.11","organizationalUnitName"),o("2.16.840.1.113730.1.1","nsCertType"),s("2.5.29.1","authorityKeyIdentifier"),s("2.5.29.2","keyAttributes"),s("2.5.29.3","certificatePolicies"),s("2.5.29.4","keyUsageRestriction"),s("2.5.29.5","policyMapping"),s("2.5.29.6","subtreesConstraint"),s("2.5.29.7","subjectAltName"),s("2.5.29.8","issuerAltName"),s("2.5.29.9","subjectDirectoryAttributes"),s("2.5.29.10","basicConstraints"),s("2.5.29.11","nameConstraints"),s("2.5.29.12","policyConstraints"),s("2.5.29.13","basicConstraints"),o("2.5.29.14","subjectKeyIdentifier"),o("2.5.29.15","keyUsage"),s("2.5.29.16","privateKeyUsagePeriod"),o("2.5.29.17","subjectAltName"),o("2.5.29.18","issuerAltName"),o("2.5.29.19","basicConstraints"),s("2.5.29.20","cRLNumber"),s("2.5.29.21","cRLReason"),s("2.5.29.22","expirationDate"),s("2.5.29.23","instructionCode"),s("2.5.29.24","invalidityDate"),s("2.5.29.25","cRLDistributionPoints"),s("2.5.29.26","issuingDistributionPoint"),s("2.5.29.27","deltaCRLIndicator"),s("2.5.29.28","issuingDistributionPoint"),s("2.5.29.29","certificateIssuer"),s("2.5.29.30","nameConstraints"),o("2.5.29.31","cRLDistributionPoints"),o("2.5.29.32","certificatePolicies"),s("2.5.29.33","policyMappings"),s("2.5.29.34","policyConstraints"),o("2.5.29.35","authorityKeyIdentifier"),s("2.5.29.36","policyConstraints"),o("2.5.29.37","extKeyUsage"),s("2.5.29.46","freshestCRL"),s("2.5.29.54","inhibitAnyPolicy"),o("1.3.6.1.4.1.11129.2.4.2","timestampList"),o("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),o("1.3.6.1.5.5.7.3.1","serverAuth"),o("1.3.6.1.5.5.7.3.2","clientAuth"),o("1.3.6.1.5.5.7.3.3","codeSigning"),o("1.3.6.1.5.5.7.3.4","emailProtection"),o("1.3.6.1.5.5.7.3.8","timeStamping")},function(e,t,r){var n=r(506),i=r(46),o=r(141),s=r(194);e.exports=function(e,t){(function(e){return"function"==typeof e})(e)&&(t=e,e={}),t=function(e){var t=0;return function(r,n,i){t++||e(r,n,i)}}(t||function(){});var r=n(e&&e.timeout||5e3),a=i(function(e){e&&t(e)}),u=s();return{handshake:{read:r.read,abort:function(e){a.end(e),r.abort(e,function(e){}),t(e)},write:a.push,rest:function(){return a.end(),{source:r.read(),sink:u.sink}}},sink:r,source:o([a,u.source])}}},function(e,t,r){const n=r(33),i=r(79),o=r(149);class s{constructor(e,t){t&&console.log("Transports(%o)",e)}static _connected(){return this._transports.filter(e=>!e.status)}static async p_connectedNames(){return this._connected().map(e=>e.name)}static async p_connectedNamesParm(){return(await this.p_connectedNames()).map(e=>"transport="+e).join("&")}static async p_statuses(){return this._transports.map(e=>({name:e.name,status:e.status}))}static validFor(e,t,r){return e&&e[0]||["store","newlisturls","newdatabase","newtable"].includes(t)?e&&e.length>0?[].concat(...e.map(e=>"string"==typeof e?n.parse(e):e).map(e=>this._connected().filter(r=>r.supports(e,t)).map(t=>[e,t]))):this._connected().filter(e=>e.supports(void 0,t)).map(e=>[void 0,e]):(console.warn("Transports.validFor called with invalid arguments: urls=",e,"func=",t),[])}static async p_urlsValidFor(e,t,r){return this.validFor(e,t,r).map(e=>e[0])}static http(e){return s._connected().find(e=>"HTTP"===e.name)}static ipfs(e){return s._connected().find(e=>"IPFS"===e.name)}static webtorrent(e){return s._connected().find(e=>"WEBTORRENT"===e.name)}static gun(e){return s._connected().find(e=>"GUN"===e.name)}static async p_resolveNames(e){return this.namingcb?await this.namingcb(e):e}static resolveNamesWith(e){this.namingcb=e}static async _p_rawstore(e,t,{verbose:r}){let n=[],o=await Promise.all(e.map(async function(e){try{return await e.p_rawstore(t,{verbose:r})}catch(t){return console.log("Could not rawstore to",e.name,t.message),void n.push(t)}}));if(!(o=o.filter(e=>!!e)).length)throw new i.TransportError(n.map(e=>e.message).join(", "));return o}static async p_rawstore(e,{verbose:t}){let r=this.validFor(void 0,"store").map(([e,t])=>t);if(t&&console.log("Valid for transports:",r.map(e=>e.name)),!r.length)throw new i.TransportError("Transports.p_rawstore: Cant find transport for store");return this._p_rawstore(r,e,{verbose:t})}static async p_rawlist(e,{verbose:t=!1}={}){e=await this.p_resolveNames(e);let r=this.validFor(e,"list");if(!r.length)throw new i.TransportError('Transports.p_rawlist: Cant find transport to "list" urls:'+e.join(","));let n=[],o=await Promise.all(r.map(async function([e,r]){try{return await r.p_rawlist(e,{verbose:t})}catch(t){return console.log("Could not rawlist ",e,"from",r.name,t.message),n.push(t),[]}}));if(n.length>=r.length)throw new i.TransportError(n.map(e=>e.message).join(", "));let s={};return[].concat(...o).filter(e=>!s[e.signature]&&(s[e.signature]=!0))}static async p_rawfetch(e,t){let r=t.verbose;if(!e.length)throw new i.TransportError("Transports.p_rawfetch given an empty list of urls");let n=await this.p_resolveNames(e);if(!n.length)throw new i.TransportError("Transports.p_rawfetch none of the urls resolved: "+e);let o=this.validFor(n,"fetch");if(!o.length)throw new i.TransportError("Transports.p_rawfetch cant find any transport for urls: "+n);let s=[],a=[];for(const[e,n]of o)try{let i=await n.p_rawfetch(e,t);return t.relay&&a.length&&(console.log(`Relaying ${i.length} bytes from ${"string"==typeof e?e:e.href} to ${a.map(e=>e.name)}`),this._p_rawstore(a,i,{verbose:r}).then(e=>console.log(`Relayed to ${e}`))),i}catch(t){a.push(n),s.push(t),console.log("Could not retrieve ",e&&e.href,"from",n&&n.name,t.message)}throw new i.TransportError(s.map(e=>e.message).join(", "))}static async p_rawadd(e,t,{verbose:r=!1}={}){e=await this.p_resolveNames(e);let n=this.validFor(e,"add");if(!n.length)throw new i.TransportError("Transports.p_rawstore: Cant find transport for urls:"+e.join(","));let o=[];if(await Promise.all(n.map(async function([e,n]){try{return void await n.p_rawadd(e,t,{verbose:r})}catch(t){return console.log("Could not rawlist ",e,"from",n.name,t.message),void o.push(t)}})),o.length>=n.length)throw new i.TransportError(o.map(e=>e.message).join(", "))}static listmonitor(e,t,r={}){this.validFor(e,"listmonitor").map(([e,n])=>n.listmonitor(e,t,r))}static async p_newlisturls(e,{verbose:t=!1}={}){let r=await Promise.all(this.validFor(void 0,"newlisturls").map(([r,n])=>n.p_newlisturls(e,{verbose:t})));return[r.map(e=>e[0]),r.map(e=>e[1])]}static async p_f_createReadStream(e,{verbose:t=!1,wanturl:r=!1}={}){let n=this.validFor(e,"createReadStream",{});if(!n.length)throw new i.TransportError("Transports.p_createReadStream cant find any transport for urls: "+e);let o,s=[];for(;(o=n.splice(Math.floor(Math.random()*n.length),1)).length;){let e=o[0][0],n=o[0][1];try{return await n.p_f_createReadStream(e,{verbose:t,wanturl:r})}catch(t){s.push(t),console.log("Could not retrieve ",e.href,"from",n.name,t.message)}}throw new i.TransportError(s.map(e=>e.message).join(", "))}static async p_get(e,t,{verbose:r=!1}={}){let n=this.validFor(e,"get");if(!n.length)throw new i.TransportError("Transports.p_get cant find any transport for urls: "+e);let o=[];for(const[e,i]of n)try{return await i.p_get(e,t,{verbose:r})}catch(t){o.push(t),console.log("Could not retrieve ",e.href,"from",i.name,t.message)}throw new i.TransportError(o.map(e=>e.message).join(", "))}static async p_set(e,t,r,{verbose:n=!1}={}){e=await this.p_resolveNames(e);let o=this.validFor(e,"set");if(!o.length)throw new i.TransportError("Transports.p_set cant find any transport for urls: "+e);let s=[],a=!1;if(await Promise.all(o.map(async function([e,i]){try{await i.p_set(e,t,r,{verbose:n}),a=!0}catch(e){console.log("Could not rawstore to",i.name,e.message),s.push(e)}})),!a)throw new i.TransportError(s.map(e=>e.message).join(", "))}static async p_delete(e,t,{verbose:r=!1}={}){e=await this.p_resolveNames(e);let n=this.validFor(e,"set");if(!n.length)throw new i.TransportError("Transports.p_set cant find any transport for urls: "+e);let o=[],s=!1;if(await Promise.all(n.map(async function([e,n]){try{await n.p_delete(e,t,{verbose:r}),s=!0}catch(e){console.log("Could not rawstore to",n.name,e.message),o.push(e)}})),!s)throw new i.TransportError(o.map(e=>e.message).join(", "))}static async p_keys(e,{verbose:t=!1}={}){e=await this.p_resolveNames(e);let r=this.validFor(e,"keys");if(!r.length)throw new i.TransportError("Transports.p_keys cant find any transport for urls: "+e);let n=[];for(const[e,i]of r)try{return await i.p_keys(e,{verbose:t})}catch(t){n.push(t),console.log("Could not retrieve keys for",e.href,"from",i.name,t.message)}throw new i.TransportError(n.map(e=>e.message).join(", "))}static async p_getall(e,{verbose:t=!1}={}){e=await this.p_resolveNames(e);let r=this.validFor(e,"getall");if(!r.length)throw new i.TransportError("Transports.p_getall cant find any transport for urls: "+e);let n=[];for(const[e,i]of r)try{return await i.p_getall(e,{verbose:t})}catch(t){n.push(t),console.log("Could not retrieve all keys for",e.href,"from",i.name,t.message)}throw new i.TransportError(n.map(e=>e.message).join(", "))}static async p_newdatabase(e,{verbose:t=!1}={}){let r=await Promise.all(this.validFor(void 0,"newdatabase").map(([r,n])=>n.p_newdatabase(e,{verbose:t})));return{privateurls:r.map(e=>e.privateurl),publicurls:r.map(e=>e.publicurl)}}static async p_newtable(e,t,{verbose:r=!1}={}){let n=await Promise.all(this.validFor(void 0,"newtable").map(([n,i])=>i.p_newtable(e,t,{verbose:r})));return{privateurls:n.map(e=>e.privateurl),publicurls:n.map(e=>e.publicurl)}}static async p_connection(e,t){e=await this.p_resolveNames(e),await Promise.all(this.validFor(e,"connection").map(([e,r])=>r.p_connection(e,t)))}static monitor(e,t,{verbose:r=!1,current:n=!1}={}){this.validFor(e,"monitor").map(([e,i])=>i.monitor(e,t,{verbose:r,current:n}))}static addtransport(e){s._transports.push(e)}static setup0(e,t,r,n){let i={http:{urlbase:"http://localhost:4244"}};return e.map(e=>{let n;if(n="LOCAL"===e?this._transportclasses.HTTP:this._transportclasses[e])return n.setup0("LOCAL"===e?i:t,r);{let t=Object.keys(this._transportclasses);return void console.error(`Requested ${e} but ${t.length?t:"No"} transports have been loaded`)}}).filter(e=>!!e)}static async p_setup1(e,t){await Promise.all(this._transports.filter(e=>!this._optionspaused.includes(e.name)).map(r=>r.p_setup1(e,t)))}static async p_setup2(e,t){await Promise.all(this._transports.filter(e=>!this._optionspaused.includes(e.name)).map(r=>r.p_setup2(e,t)))}static async refreshstatus(e){let t=["transportstatus0","transportstatus1","transportstatus2","transportstatus3","transportstatus4"],r=e.statuselement;r&&(r.classList.remove(...t),r.classList.add(t[e.status])),s.statuscb&&s.statuscb(e)}static async p_connect(e,t){t&&console.group("p_connect ---");try{let r=(e=e||{}).transports;this._optionspaused=(e.paused||[]).map(e=>e.toUpperCase()),r&&r.length||(r=e.defaulttransports||[]),r.length||(r=["HTTP","YJS","IPFS","WEBTORRENT","GUN"]),r=r.map(e=>e.toUpperCase());let n=this.setup0(r,e,t);if(e.statuscb&&(this.statuscb=e.statuscb),e.statuselement){let t=e.statuselement;for(;t.lastChild;)t.removeChild(t.lastChild);t.appendChild(o.createElement("UL",{},n.map(e=>{let t=o.createElement("LI",{onclick:"this.source.togglePaused(DwebTransports.refreshstatus);",source:e,name:e.name},e.name);return e.statuselement=t,t})))}await this.p_setup1(t,this.refreshstatus),await this.p_setup2(t,this.refreshstatus)}catch(e){throw console.error("ERROR in p_connect:",e.message),e}t&&console.groupEnd("p_connect ---")}static async p_urlsFrom(e){if("string"==typeof e&&(e="["===e[0]?JSON.parse(e):e.includes(",")?e.split(","):[e]),!Array.isArray(e))throw new Error(`Unparsable url: ${e}`);return e}static async p_httpfetchurl(e){return s.http()._url(e.find(e=>e.startsWith("contenthash")||e.startsWith("http")),"content/rawfetch")}static async test(e){e&&console.log("Transports.test")}}s._transports=[],s.namingcb=void 0,s._transportclasses={},e.exports=s},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=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}}),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),y(r)?n.showHidden=r:r&&t._extend(n,r),v(n.showHidden)&&(n.showHidden=!1),v(n.depth)&&(n.depth=2),v(n.colors)&&(n.colors=!1),v(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),f(n,e,n.depth)}function u(e,t){var r=a.styles[t];return r?"["+a.colors[r][0]+"m"+e+"["+a.colors[r][1]+"m":e}function c(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 b(i)||(i=f(e,i,n)),i}var o=l(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)),k(r)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return h(r);if(0===s.length){if(E(r)){var u=r.name?": "+r.name:"";return e.stylize("[Function"+u+"]","special")}if(_(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(S(r))return e.stylize(Date.prototype.toString.call(r),"date");if(k(r))return h(r)}var c,y="",g=!1,m=["{","}"];return d(r)&&(g=!0,m=["[","]"]),E(r)&&(y=" [Function"+(r.name?": "+r.name:"")+"]"),_(r)&&(y=" "+RegExp.prototype.toString.call(r)),S(r)&&(y=" "+Date.prototype.toUTCString.call(r)),k(r)&&(y=" "+h(r)),0!==s.length||g&&0!=r.length?n<0?_(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special"):(e.seen.push(r),c=g?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?r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}(c,y,m)):m[0]+y+m[1]}function l(e,t){if(v(t))return e.stylize("undefined","undefined");if(b(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}return m(t)?e.stylize(""+t,"number"):y(t)?e.stylize(""+t,"boolean"):g(t)?e.stylize("null","null"):void 0}function h(e){return"["+Error.prototype.toString.call(e)+"]"}function p(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),T(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=g(r)?f(e,u.value,null):f(e,u.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")),v(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 y(e){return"boolean"==typeof e}function g(e){return null===e}function m(e){return"number"==typeof e}function b(e){return"string"==typeof e}function v(e){return void 0===e}function _(e){return w(e)&&"[object RegExp]"===A(e)}function w(e){return"object"==typeof e&&null!==e}function S(e){return w(e)&&"[object Date]"===A(e)}function k(e){return w(e)&&("[object Error]"===A(e)||e instanceof Error)}function E(e){return"function"==typeof e}function A(e){return Object.prototype.toString.call(e)}function x(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(e){if(v(o)&&(o=n.env.NODE_DEBUG||""),e=e.toUpperCase(),!s[e])if(new RegExp("\\b"+e+"\\b","i").test(o)){var r=n.pid;s[e]=function(){var n=t.format.apply(t,arguments);console.error("%s %d: %s",e,r,n)}}else s[e]=function(){};return s[e]},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=y,t.isNull=g,t.isNullOrUndefined=function(e){return null==e},t.isNumber=m,t.isString=b,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=v,t.isRegExp=_,t.isObject=w,t.isDate=S,t.isError=k,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(689);var I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function T(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){console.log("%s - %s",function(){var e=new Date,t=[x(e.getHours()),x(e.getMinutes()),x(e.getSeconds())].join(":");return[e.getDate(),I[e.getMonth()],t].join(" ")}(),t.format.apply(t,arguments))},t.inherits=r(690),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}}).call(this,r(6),r(7))},function(e,t,r){var n=r(123);function i(e){return n("rmd160").update(e).digest()}function o(e){return n("sha256").update(e).digest()}e.exports={hash160:function(e){return i(o(e))},hash256:function(e){return o(o(e))},ripemd160:i,sha1:function(e){return n("sha1").update(e).digest()},sha256:o}},function(e,t,r){var n=r(2).Buffer;function i(e,t){this._block=n.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}i.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=n.from(e,t));for(var r=this._block,i=this._blockSize,o=e.length,s=this._len,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";(function(t,n){var i=r(2).Buffer,o=t.crypto||t.msCrypto;o&&o.getRandomValues?e.exports=function(e,r){if(e>65536)throw new Error("requested too many random bytes");var s=new t.Uint8Array(e);e>0&&o.getRandomValues(s);var a=i.from(s.buffer);return"function"==typeof r?n.nextTick(function(){r(null,a)}):a}:e.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}}).call(this,r(6),r(7))},function(e,t,r){"use strict";(function(t){var n=r(32),i=r(24),o=r(72).curves.secp256k1,s=o.curve.point.bind(o.curve),a=o.curve.pointFromX.bind(o.curve),u=function(e,t,r){var n=s(e,t,r);return n.validate(),n};u.prototype=Object.getPrototypeOf(o.curve.point()),u.fromX=function(e,t){var r=a(e,t);return r.validate(),r},u.getG=function(){return o.curve.g},u.getN=function(){return new n(o.curve.n.toArray())},u.prototype._getX=u.prototype.getX,u.prototype.getX=function(){return new n(this._getX().toArray())},u.prototype._getY=u.prototype.getY,u.prototype.getY=function(){return new n(this._getY().toArray())},u.prototype.validate=function(){if(this.isInfinity())throw new Error("Point cannot be equal to Infinity");if(0===this.getX().cmp(n.Zero)||0===this.getY().cmp(n.Zero))throw new Error("Invalid x,y value for curve, cannot equal 0.");if(0!==a(this.getY().isOdd(),this.getX()).y.cmp(this.y))throw new Error("Invalid y value for curve.");var e=this.getX().gt(n.Minus1)&&this.getX().lt(u.getN()),t=this.getY().gt(n.Minus1)&&this.getY().lt(u.getN());if(!e||!t)throw new Error("Point does not lie on the curve");if(!this.mul(u.getN()).isInfinity())throw new Error("Point times N must be infinity");return this},u.pointToCompressed=function(e){var r,n=e.getX().toBuffer({size:32}),o=e.getY().toBuffer({size:32}),s=o[o.length-1]%2;return r=new t(s?[3]:[2]),i.concat([r,n])},e.exports=u}).call(this,r(0).Buffer)},function(e,t,r){var n=t;n.utils=r(878),n.common=r(879),n.sha=r(880),n.ripemd=r(881),n.hmac=r(882),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";(function(n){const i=r(12),o=r(111),s=r(17),a=r(4);class u{constructor(e,t,r){s(n.isBuffer(e),"invalid id provided"),t&&r&&s(t.public.bytes.equals(r.bytes),"inconsistent arguments"),this._id=e,this._idB58String=i.toB58String(this.id),this._privKey=t,this._pubKey=r}get id(){return this._id}set id(e){throw new Error("Id is immutable")}get privKey(){return this._privKey}set privKey(e){this._privKey=e}get pubKey(){return this._pubKey?this._pubKey:this._privKey?this._privKey.public:void 0}set pubKey(e){this._pubKey=e}marshalPubKey(){if(this.pubKey)return o.keys.marshalPublicKey(this.pubKey)}marshalPrivKey(){if(this.privKey)return o.keys.marshalPrivateKey(this.privKey)}toPrint(){let e=this.toB58String();e.startsWith("Qm")&&(e=e.slice(2));let t=6;return e.length"}toJSON(){return{id:this.toB58String(),privKey:c(this.marshalPrivKey()),pubKey:c(this.marshalPubKey())}}toHexString(){return i.toHexString(this.id)}toBytes(){return this.id}toB58String(){return this._idB58String}isEqual(e){if(n.isBuffer(e))return this.id.equals(e);if(e.id)return this.id.equals(e.id);throw new Error("not valid Id")}isValid(e){this.privKey&&this.privKey.public&&this.privKey.public.bytes&&n.isBuffer(this.pubKey.bytes)&&this.privKey.public.bytes.equals(this.pubKey.bytes)?e():e(new Error("Keys not match"))}}function c(e){if(e)return e.toString("base64")}(t=e.exports=u).create=function(e,t){"function"==typeof e&&(t=e,e={}),(e=e||{}).bits=e.bits||2048,a([t=>o.keys.generateKeyPair("RSA",e.bits,t),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n))})},t.createFromHexString=function(e){return new u(i.fromHexString(e))},t.createFromBytes=function(e){return new u(e)},t.createFromB58String=function(e){return new u(i.fromB58String(e))},t.createFromPubKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r;try{let i=e;if("string"==typeof i&&(i=n.from(e,"base64")),!n.isBuffer(i))throw new Error("Supplied key is neither a base64 string nor a buffer");r=o.keys.unmarshalPublicKey(i)}catch(e){return t(e)}r.hash((e,n)=>{if(e)return t(e);t(null,new u(n,null,r))})},t.createFromPrivKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r=e;try{if("string"==typeof r&&(r=n.from(e,"base64")),!n.isBuffer(r))throw new Error("Supplied key is neither a base64 string nor a buffer")}catch(e){return t(e)}a([e=>o.keys.unmarshalPrivateKey(r,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n,n.public))})},t.createFromJSON=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r,s,c,f;try{r=i.fromB58String(e.id),s=e.privKey&&n.from(e.privKey,"base64"),c=e.pubKey&&n.from(e.pubKey,"base64"),f=c&&o.keys.unmarshalPublicKey(c)}catch(e){return t(e)}s?a([e=>o.keys.unmarshalPrivateKey(s,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)}),(e,t,r)=>{f?f.hash((n,i)=>{r(n,e,t,i)}):r(null,e,t)}],(e,n,i,o)=>e?t(e):f&&!n.equals(o)?t(new Error("Public and private key do not match")):r&&!n.equals(r)?t(new Error("Id and private key do not match")):void t(null,new u(r,i,f))):t(null,new u(r,null,f))},t.isPeerId=function(e){return Boolean("object"==typeof e&&e._id&&e._idB58String)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(438),i=r(905),o=r(916);(t=e.exports).aes=i,t.hmac=n,t.keys=o,t.randomBytes=r(474),t.pbkdf2=r(956)},function(e,t,r){var n=r(13);r(19);var i=e.exports=n.pem=n.pem||{};function o(e){for(var t=e.name+": ",r=[],n=function(e,t){return" "+t},i=0;i65&&-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{const r=["bitswap"];t&&r.push(t),e&&r.push(`${e.toB58String().slice(0,8)}`);const i=n(r.join(":"));return i.error=n(r.concat(["error"]).join(":")),i})},function(e,t,r){function n(e){if(e)return function(e){for(var t in n.prototype)e[t]=n.prototype[t];return e}(e)}e.exports=n,n.prototype.on=n.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},n.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+e];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;i1?{type:p[i],data:e.substring(1)}:{type:p[i]}:d}i=new Uint8Array(e)[0];var o=s(e,1);return y&&"blob"===r&&(o=new y([o])),{type:p[i],data:o}},t.decodeBase64Packet=function(e,t){var r=p[e.charAt(0)];if(!n)return{type:r,data:{base64:!0,data:e.substr(1)}};var i=n.decode(e.substr(1));return"blob"===t&&y&&(i=new y([i])),{type:r,data:i}},t.encodePayload=function(e,r,n){"function"==typeof r&&(n=r,r=null);var i=o(e);if(r&&i)return y&&!l?t.encodePayloadAsBlob(e,n):t.encodePayloadAsArrayBuffer(e,n);if(!e.length)return n("0:");_(e,function(e,n){t.encodePacket(e,!!i&&r,!1,function(e){n(null,function(e){return e.length+":"+e}(e))})},function(e,t){return n(t.join(""))})},t.decodePayload=function(e,r,n){if("string"!=typeof e)return t.decodePayloadAsBinary(e,r,n);var i;if("function"==typeof r&&(n=r,r=null),""===e)return n(d,0,1);for(var o,s,a="",u=0,c=e.length;u0;){for(var a=new Uint8Array(i),u=0===a[0],c="",f=1;255!==a[f];f++){if(c.length>310)return n(d,0,1);c+=a[f]}i=s(i,2+c.length),c=parseInt(c);var l=s(i,0,c);if(u)try{l=String.fromCharCode.apply(null,new Uint8Array(l))}catch(e){var h=new Uint8Array(l);l="";for(f=0;f{setTimeout(()=>{r(t)},e)})}class s{constructor(e,t){}static setup0(e,t){throw new i.IntentionallyUnimplementedError("Intentionally undefined function Transport.setup0 should have been subclassed")}p_setup1(e,t){return this}p_setup2(e,t){return this}static async p_setup(e,t,r){return(await this.setup0(e,t).p_setup1(t,r)).p_setup2(t,r)}togglePaused(e){switch(this.status){case s.STATUS_CONNECTED:this.status=s.STATUS_PAUSED;break;case s.STATUS_PAUSED:this.status=s.STATUS_CONNECTED}e&&e(this)}async p_status(e){return this.status}supports(e,t){if("string"==typeof e&&(e=n.parse(e)),e&&!e.protocol)throw new Error("URL failed to specific a scheme (before :) "+e.href);return(!e||this.supportURLs.includes(e.protocol.slice(0,-1)))&&(!t||this.supportFunctions.includes(t))}p_rawstore(e,t){throw new i.ToBeImplementedError("Intentionally undefined function Transport.p_rawstore should have been subclassed")}async p_rawstoreCaught(e,{verbose:t}){try{return await this.p_rawstore(e,{verbose:t})}catch(e){}}p_store(){throw new i.ToBeImplementedError("Undefined function Transport.p_store - may define higher level semantics here (see Python)")}p_rawfetch(e,{timeoutMS:t,start:r,end:n,relay:i=!1,verbose:o=!1}={}){return console.assert(!1,"Intentionally undefined function Transport.p_rawfetch should have been subclassed"),"UNIMPLEMENTED"}p_fetch(){throw new i.ToBeImplementedError("Undefined function Transport.p_fetch - may define higher level semantics here (see Python)")}p_rawadd(e,t,{verbose:r=!1}={}){throw new i.ToBeImplementedError("Undefined function Transport.p_rawadd")}p_rawlist(e,{verbose:t=!1}={}){throw new i.ToBeImplementedError("Undefined function Transport.p_rawlist")}p_list(){throw new Error("Undefined function Transport.p_list")}p_newlisturls(e,{verbose:t=!1}={}){throw new Error("undefined function Transport.p_newlisturls")}p_rawreverse(e,{verbose:t=!1}={}){throw new i.ToBeImplementedError("Undefined function Transport.p_rawreverse")}listmonitor(e,t,{verbose:r=!1,current:n=!1}={}){console.log("Undefined function Transport.listmonitor")}async p_newdatabase(e,{verbose:t=!1}={}){throw new i.ToBeImplementedError("Undefined function Transport.p_newdatabase")}async p_newtable(e,t,{verbose:r=!1}={}){throw new i.ToBeImplementedError("Undefined function Transport.p_newtable")}async p_set(e,t,r,{verbose:n=!1}={}){throw new i.ToBeImplementedError("Undefined function Transport.p_set")}async p_get(e,t,{verbose:r=!1}={}){throw new i.ToBeImplementedError("Undefined function Transport.p_get")}async p_delete(e,t,{verbose:r=!1}={}){throw new i.ToBeImplementedError("Undefined function Transport.p_delete")}async p_keys(e,{verbose:t=!1}={}){throw new i.ToBeImplementedError("Undefined function Transport.p_keys")}async p_getall(e,{verbose:t=!1}={}){throw new i.ToBeImplementedError("Undefined function Transport.p_keys")}static async p_f_createReadStream(e,{wanturl:t=!1,verbose:r=!1}){}static mergeoptions(e){let t={};for(let r=0;r",n),console.assert("bar"===n.testkey2.foo&&2===n.testkey3[1]&&!n.testkey),await o(200),t&&console.log(this.name,"p_test_kvt complete")}catch(e){throw console.log("Exception thrown in ",this.name,"p_test_kvt:",e.message),e}}}s.STATUS_CONNECTED=0,s.STATUS_FAILED=1,s.STATUS_STARTING=2,s.STATUS_LOADED=3,s.STATUS_PAUSED=4,e.exports=s},function(e,t,r){(function(e){function r(e){return Object.prototype.toString.call(e)}t.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===r(e)},t.isBoolean=function(e){return"boolean"==typeof e},t.isNull=function(e){return null===e},t.isNullOrUndefined=function(e){return null==e},t.isNumber=function(e){return"number"==typeof e},t.isString=function(e){return"string"==typeof e},t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=function(e){return void 0===e},t.isRegExp=function(e){return"[object RegExp]"===r(e)},t.isObject=function(e){return"object"==typeof e&&null!==e},t.isDate=function(e){return"[object Date]"===r(e)},t.isError=function(e){return"[object Error]"===r(e)||e instanceof Error},t.isFunction=function(e){return"function"==typeof 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=e.isBuffer}).call(this,r(0).Buffer)},function(e,t,r){"use strict";e.exports=function(e,t){var r,n;function i(o){if(r=o,n)return i.abort();!function i(){for(var o=!0,s=!1;o;)if(s=!1,r(null,function(a,u){if(s=!0,a=a||n){if(o=!1,t)t(!0===a?null:a);else if(a&&!0!==a)throw a}else e&&!1===e(u)||n?(o=!1,r(n||!0,t||function(){})):o||i()}),!s)return void(o=!1)}()}return i.abort=function(e,t){if("function"==typeof e&&(t=e,e=!0),n=e||!0,r)return r(n,t||function(){})},i}},function(e,t){e.exports=function(e){return e&&("string"==typeof e?function(t){return t[e]}:"object"==typeof e&&"function"==typeof e.exec?function(t){var r=e.exec(t);return r&&r[0]}:e)}},function(e,t,r){"use strict";var n=r(349);e.exports=function(e){return e=n(e),function(t){return function r(n,i){for(var o,s=!0;s;)s=!1,o=!0,t(n,function(t,n){if(!t&&!e(n))return o?s=!0:r(t,i);i(t,n)}),o=!1}}}},function(e,t){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},function(e,t,r){var n;!function(i){"use strict";var o,s=20,a=1,u=1e6,c=-7,f=21,l="[big.js] ",h=l+"Invalid ",p=h+"decimal places",d=h+"rounding mode",y=l+"Division by zero",g={},m=void 0,b=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function v(e,t,r,n){var i=e.c,o=e.e+t+1;if(o=5;else if(2===r)n=i[o]>5||5==i[o]&&(n||o<0||i[o+1]!==m||1&i[o-1]);else if(3===r)n=n||i[o]!==m||o<0;else if(n=!1,0!==r)throw Error(d);if(o<1)i.length=1,n?(e.e=-t,i[0]=1):i[0]=e.e=0;else{if(i.length=o--,n)for(;++i[o]>9;)i[o]=0,o--||(++e.e,i.unshift(1));for(o=i.length;!i[--o];)i.pop()}}else if(r<0||r>3||r!==~~r)throw Error(d);return e}function _(e,t,r,n){var i,o,s=e.constructor,a=!e.c[0];if(r!==m){if(r!==~~r||r<(3==t)||r>u)throw Error(3==t?h+"precision":p);for(r=n-(e=new s(e)).e,e.c.length>++n&&v(e,r,s.RM),2==t&&(n=e.e+r+1);e.c.length=s.PE))o=o.charAt(0)+(r>1?"."+o.slice(1):"")+(i<0?"e":"e+")+i;else if(i<0){for(;++i;)o="0"+o;o="0."+o}else if(i>0)if(++i>r)for(i-=r;i--;)o+="0";else i1&&(o=o.charAt(0)+"."+o.slice(1));return e.s<0&&(!a||4==t)?"-"+o:o}g.abs=function(){var e=new this.constructor(this);return e.s=1,e},g.cmp=function(e){var t,r=this,n=r.c,i=(e=new r.constructor(e)).c,o=r.s,s=e.s,a=r.e,u=e.e;if(!n[0]||!i[0])return n[0]?o:i[0]?-s:0;if(o!=s)return o;if(t=o<0,a!=u)return a>u^t?1:-1;for(s=(a=n.length)<(u=i.length)?a:u,o=-1;++oi[o]^t?1:-1;return a==u?0:a>u^t?1:-1},g.div=function(e){var t=this,r=t.constructor,n=t.c,i=(e=new r(e)).c,o=t.s==e.s?1:-1,s=r.DP;if(s!==~~s||s<0||s>u)throw Error(p);if(!i[0])throw Error(y);if(!n[0])return new r(0*o);var a,c,f,l,h,d=i.slice(),g=a=i.length,b=n.length,_=n.slice(0,a),w=_.length,S=e,k=S.c=[],E=0,A=s+(S.e=t.e-e.e)+1;for(S.s=o,o=A<0?0:A,d.unshift(0);w++w?1:-1;else for(h=-1,l=0;++h_[h]?1:-1;break}if(!(l<0))break;for(c=w==a?i:d;w;){if(_[--w]A&&v(S,s,r.RM,_[0]!==m),S},g.eq=function(e){return!this.cmp(e)},g.gt=function(e){return this.cmp(e)>0},g.gte=function(e){return this.cmp(e)>-1},g.lt=function(e){return this.cmp(e)<0},g.lte=function(e){return this.cmp(e)<1},g.minus=g.sub=function(e){var t,r,n,i,o=this,s=o.constructor,a=o.s,u=(e=new s(e)).s;if(a!=u)return e.s=-u,o.plus(e);var c=o.c.slice(),f=o.e,l=e.c,h=e.e;if(!c[0]||!l[0])return l[0]?(e.s=-u,e):new s(c[0]?o:0);if(a=f-h){for((i=a<0)?(a=-a,n=c):(h=f,n=l),n.reverse(),u=a;u--;)n.push(0);n.reverse()}else for(r=((i=c.length0)for(;u--;)c[t++]=0;for(u=t;r>a;){if(c[--r]0?(u=s,t=c):(i=-i,t=a),t.reverse();i--;)t.push(0);t.reverse()}for(a.length-c.length<0&&(t=c,c=a,a=t),i=c.length,o=0;i;a[i]%=10)o=(a[--i]=a[i]+c[i]+o)/10|0;for(o&&(a.unshift(o),++u),i=a.length;0===a[--i];)a.pop();return e.c=a,e.e=u,e},g.pow=function(e){var t=this,r=new t.constructor(1),n=r,i=e<0;if(e!==~~e||e<-1e6||e>1e6)throw Error(h+"exponent");for(i&&(e=-e);1&e&&(n=n.times(t)),e>>=1;)t=t.times(t);return i?r.div(n):n},g.round=function(e,t){var r=this.constructor;if(e===m)e=0;else if(e!==~~e||e<0||e>u)throw Error(p);return v(new r(this),e,t===m?r.RM:t)},g.sqrt=function(){var e,t,r,n=this,i=n.constructor,o=n.s,s=n.e,a=new i(.5);if(!n.c[0])return new i(n);if(o<0)throw Error(l+"No square root");0===(o=Math.sqrt(n.toString()))||o===1/0?((t=n.c.join("")).length+s&1||(t+="0"),(e=new i(Math.sqrt(t).toString())).e=((s+1)/2|0)-(s<0||1&s)):e=new i(o.toString()),s=e.e+(i.DP+=4);do{r=e,e=a.times(r.plus(n.div(r)))}while(r.c.slice(0,s).join("")!==e.c.slice(0,s).join(""));return v(e,i.DP-=4,i.RM)},g.times=g.mul=function(e){var t,r=this,n=r.constructor,i=r.c,o=(e=new n(e)).c,s=i.length,a=o.length,u=r.e,c=e.e;if(e.s=r.s==e.s?1:-1,!i[0]||!o[0])return new n(0*e.s);for(e.e=u+c,su;)a=t[c]+o[u]*i[c-u-1]+a,t[c--]=a%10,a=a/10|0;t[c]=(t[c]+a)%10}for(a?++e.e:t.shift(),u=t.length;!t[--u];)t.pop();return e.c=t,e},g.toExponential=function(e){return _(this,1,e,e)},g.toFixed=function(e){return _(this,2,e,this.e+e)},g.toPrecision=function(e){return _(this,3,e,e-1)},g.toString=function(){return _(this)},g.valueOf=g.toJSON=function(){return _(this,4)},(o=function e(){function t(r){var n=this;if(!(n instanceof t))return r===m?e():new t(r);r instanceof t?(n.s=r.s,n.e=r.e,n.c=r.c.slice()):function(e,t){var r,n,i;if(0===t&&1/t<0)t="-0";else if(!b.test(t+=""))throw Error(h+"number");for(e.s="-"==t.charAt(0)?(t=t.slice(1),-1):1,(r=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(r<0&&(r=n),r+=+t.slice(n+1),t=t.substring(0,n)):r<0&&(r=t.length),i=t.length,n=0;n0&&"0"==t.charAt(--i););for(e.e=r-n-1,e.c=[],r=0;n<=i;)e.c[r++]=+t.charAt(n++)}}(n,r),n.constructor=t}return t.prototype=g,t.DP=s,t.RM=a,t.NE=c,t.PE=f,t.version="5.0.2",t}()).default=o.Big=o,void 0===(n=function(){return o}.call(t,r,t,e))||(e.exports=n)}()},function(e,t,r){"use strict";var n=r(5),i=r(237),o=r(409),s=r(410),a=r(92);function u(e){a.call(this,"digest"),this._hash=e}n(u,a),u.prototype._update=function(e){this._hash.update(e)},u.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 u(s(e))}},function(e,t){e.exports={bitcoin:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},testnet:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},litecoin:{messagePrefix:"Litecoin Signed Message:\n",bip32:{public:27108450,private:27106558},pubKeyHash:48,scriptHash:50,wif:176}}},function(e,t,r){"use strict";var n=r(71),i=r(81);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;ot.length)throw new Error("invalid rlp: total length is larger than the data");if(0===(a=t.slice(n,l)).length)throw new Error("invalid rlp, List has a invalid length");for(;a.length;)u=e(a),c.push(u.data),a=u.remainder;return{data:c,remainder:t.slice(l)}}(e=c(e));return t?r:(n.equal(r.remainder.length,0,"invalid remainder"),r.data)},t.getLength=function(e){if(!e||0===e.length)return i.from([]);var t=(e=c(e))[0];if(t<=127)return e.length;if(t<=183)return t-127;if(t<=191)return t-182;if(t<=247)return t-191;var r=t-246;return r+o(e.slice(1,r).toString("hex"),16)}},function(e,t,r){"use strict";const n=r(9),i=r(12);e.exports=function(e,t,r){const o=(r=r||{}).hashAlg||"keccak-256",s=void 0===r.version?1:r.version,a=i.encode(t,o);return new n(s,e,a)}},function(e,t,r){"use strict";const n=r(4),i=r(423),o=r(424);e.exports=function(e,t,r){const s=o(e,t);return{resolver:{multicodec:e,defaultHashAlg:"keccak-256",resolve:u,tree:function(e,t,r){"function"==typeof t&&(r=t,t=void 0),t||(t={}),n([t=>s.deserialize(e,t),(e,r)=>a(e,t,r)],r)},isLink:i(u),_resolveFromEthObject:c,_treeFromEthObject:a,_mapFromEthObject:r},util:s};function a(e,t,i){n([n=>r(e,t,n),(e,t)=>t(null,e.map(e=>e.path))],i)}function u(e,t,r){n([t=>s.deserialize(e,t),(e,r)=>c(e,t,r)],r)}function c(e,t,n){if(!t||"/"===t)return n(null,{value:e,remainderPath:""});r(e,{},(e,r)=>{if(e)return n(e);const i=t.split("/");let o=r.filter(e=>e.path===t.slice(0,e.path.length));const s=(o=o.filter(e=>e.path.split("/").every((e,t)=>e===i[t]))).sort((e,t)=>e.path.lengtht.blockLength&&(t.start(),t.update(s.bytes()),s=t.digest()),r=n.util.createBuffer(),i=n.util.createBuffer(),c=s.length();for(u=0;u>>0,u>>>0];for(var c=i.fullMessageLength.length-1;c>=0;--c)i.fullMessageLength[c]+=u[1],u[1]=u[0]+(i.fullMessageLength[c]/4294967296>>>0),i.fullMessageLength[c]=i.fullMessageLength[c]>>>0,u[0]=u[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 u,c=i.fullMessageLength[i.fullMessageLength.length-1]+i.messageLengthSize&i.blockLength-1;s.putBytes(o.substr(0,i.blockLength-c));for(var f=8*i.fullMessageLength[0],l=0;l>>0,s.putInt32(f>>>0),f=u>>>0;s.putInt32(f);var h={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};a(h,r,s);var p=n.util.createBuffer();return p.putInt32(h.h0),p.putInt32(h.h1),p.putInt32(h.h2),p.putInt32(h.h3),p.putInt32(h.h4),p},i};var o=null,s=!1;function a(e,t,r){for(var n,i,o,s,a,u,c,f=r.length();f>=64;){for(i=e.h0,o=e.h1,s=e.h2,a=e.h3,u=e.h4,c=0;c<16;++c)n=r.getInt32(),t[c]=n,n=(i<<5|i>>>27)+(a^o&(s^a))+u+1518500249+n,u=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;c<20;++c)n=(n=t[c-3]^t[c-8]^t[c-14]^t[c-16])<<1|n>>>31,t[c]=n,n=(i<<5|i>>>27)+(a^o&(s^a))+u+1518500249+n,u=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;c<32;++c)n=(n=t[c-3]^t[c-8]^t[c-14]^t[c-16])<<1|n>>>31,t[c]=n,n=(i<<5|i>>>27)+(o^s^a)+u+1859775393+n,u=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;c<40;++c)n=(n=t[c-6]^t[c-16]^t[c-28]^t[c-32])<<2|n>>>30,t[c]=n,n=(i<<5|i>>>27)+(o^s^a)+u+1859775393+n,u=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;c<60;++c)n=(n=t[c-6]^t[c-16]^t[c-28]^t[c-32])<<2|n>>>30,t[c]=n,n=(i<<5|i>>>27)+(o&s|a&(o^s))+u+2400959708+n,u=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;c<80;++c)n=(n=t[c-6]^t[c-16]^t[c-28]^t[c-32])<<2|n>>>30,t[c]=n,n=(i<<5|i>>>27)+(o^s^a)+u+3395469782+n,u=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+u|0,f-=64}}},function(e,t,r){"use strict";const n=t;n.Reporter=r(933).Reporter,n.DecoderBuffer=r(465).DecoderBuffer,n.EncoderBuffer=r(465).EncoderBuffer,n.Node=r(934)},function(e,t,r){(function(e,r){var n=200,i="Expected a function",o="__lodash_hash_undefined__",s=1,a=2,u=1/0,c=9007199254740991,f="[object Arguments]",l="[object Array]",h="[object Boolean]",p="[object Date]",d="[object Error]",y="[object Function]",g="[object GeneratorFunction]",m="[object Map]",b="[object Number]",v="[object Object]",_="[object Promise]",w="[object RegExp]",S="[object Set]",k="[object String]",E="[object Symbol]",A="[object WeakMap]",x="[object ArrayBuffer]",I="[object DataView]",T=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,B=/^\w*$/,C=/^\./,P=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,O=/\\(\\)?/g,R=/^\[object .+?Constructor\]$/,N=/^(?:0|[1-9]\d*)$/,L={};L["[object Float32Array]"]=L["[object Float64Array]"]=L["[object Int8Array]"]=L["[object Int16Array]"]=L["[object Int32Array]"]=L["[object Uint8Array]"]=L["[object Uint8ClampedArray]"]=L["[object Uint16Array]"]=L["[object Uint32Array]"]=!0,L[f]=L[l]=L[x]=L[h]=L[I]=L[p]=L[d]=L[y]=L[m]=L[b]=L[v]=L[w]=L[S]=L[k]=L[A]=!1;var K="object"==typeof e&&e&&e.Object===Object&&e,j="object"==typeof self&&self&&self.Object===Object&&self,M=K||j||Function("return this")(),D="object"==typeof t&&t&&!t.nodeType&&t,U=D&&"object"==typeof r&&r&&!r.nodeType&&r,F=U&&U.exports===D&&K.process,q=function(){try{return F&&F.binding("util")}catch(e){}}(),H=q&&q.isTypedArray;function z(e,t){for(var r=-1,n=e?e.length:0;++r-1},Ee.prototype.set=function(e,t){var r=this.__data__,n=Be(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Ae.prototype.clear=function(){this.__data__={hash:new ke,map:new(fe||Ee),string:new ke}},Ae.prototype.delete=function(e){return Fe(this,e).delete(e)},Ae.prototype.get=function(e){return Fe(this,e).get(e)},Ae.prototype.has=function(e){return Fe(this,e).has(e)},Ae.prototype.set=function(e,t){return Fe(this,e).set(e,t),this},xe.prototype.add=xe.prototype.push=function(e){return this.__data__.set(e,o),this},xe.prototype.has=function(e){return this.__data__.has(e)},Ie.prototype.clear=function(){this.__data__=new Ee},Ie.prototype.delete=function(e){return this.__data__.delete(e)},Ie.prototype.get=function(e){return this.__data__.get(e)},Ie.prototype.has=function(e){return this.__data__.has(e)},Ie.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Ee){var i=r.__data__;if(!fe||i.lengthc))return!1;var l=o.get(e);if(l&&o.get(t))return l==t;var h=-1,p=!0,d=i&s?new xe:void 0;for(o.set(e,t),o.set(t,e);++h-1&&e%1==0&&e-1&&e%1==0&&e<=c}function it(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function ot(e){return!!e&&"object"==typeof e}function st(e){return"symbol"==typeof e||ot(e)&&re.call(e)==E}var at=H?function(e){return function(t){return e(t)}}(H):function(e){return ot(e)&&nt(e.length)&&!!L[re.call(e)]};function ut(e){return tt(e)?Te(e):je(e)}function ct(e){return e}r.exports=function(e,t){return(et(e)?function(e,t){for(var r=-1,n=e?e.length:0,i=0,o=[];++r0;o--)u.push("0");s.splice.apply(s,u)}for(n=t||new i(r+16),o=0;o>8&255,n[r++]=255&c}}if(!n)throw Error("Invalid ip address: "+e);return n},n.toString=function(e,t,r){t=~~t;var n=[];if(4===(r=r||e.length-t)){for(var i=0;i32?"ipv6":u(t))&&(r=16);for(var o=new i(r),s=0,a=o.length;s>c)}return n.toString(o)},n.mask=function(e,t){e=n.toBuffer(e),t=n.toBuffer(t);var r=new i(Math.max(e.length,t.length)),o=0;if(e.length===t.length)for(o=0;oe.length&&(i=t,o=e);var s=i.length-o.length;for(r=s;r>>0},n.fromLong=function(e){return(e>>>24)+"."+(e>>16&255)+"."+(e>>8&255)+"."+(255&e)}},function(e,t,r){"use strict";t.Address4=r(482),t.Address6=r(977),t.v6={helpers:r(488)}},function(e,t,r){var n;!function(i){"use strict";var o={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[\+\-]/};function s(){var e=arguments[0],t=s.cache;return t[e]||(t[e]=s.parse(e)),s.format.call(null,t[e],arguments)}s.format=function(e,t){var r,n,i,a,c,l,h,p=1,d=e.length,y="",g=[],m=!0,b="";for(n=0;n=0),a[8]){case"b":r=parseInt(r,10).toString(2);break;case"c":r=String.fromCharCode(parseInt(r,10));break;case"d":case"i":r=parseInt(r,10);break;case"j":r=JSON.stringify(r,null,a[6]?parseInt(a[6]):0);break;case"e":r=a[7]?parseFloat(r).toExponential(a[7]):parseFloat(r).toExponential();break;case"f":r=a[7]?parseFloat(r).toFixed(a[7]):parseFloat(r);break;case"g":r=a[7]?parseFloat(r).toPrecision(a[7]):parseFloat(r);break;case"o":r=r.toString(8);break;case"s":r=String(r),r=a[7]?r.substring(0,a[7]):r;break;case"t":r=String(!!r),r=a[7]?r.substring(0,a[7]):r;break;case"T":r=u(r),r=a[7]?r.substring(0,a[7]):r;break;case"u":r=parseInt(r,10)>>>0;break;case"v":r=r.valueOf(),r=a[7]?r.substring(0,a[7]):r;break;case"x":r=parseInt(r,10).toString(16);break;case"X":r=parseInt(r,10).toString(16).toUpperCase()}o.json.test(a[8])?g[g.length]=r:(!o.number.test(a[8])||m&&!a[3]?b="":(b=m?"+":"-",r=r.toString().replace(o.sign,"")),l=a[4]?"0"===a[4]?"0":a[4].charAt(1):" ",h=a[6]-(b+r).length,c=a[6]&&h>0?f(l,h):"",g[g.length]=a[5]?b+r+c:"0"===l?b+c+r:c+b+r)}return g.join("")},s.cache=Object.create(null),s.parse=function(e){for(var t=e,r=[],n=[],i=0;t;){if(null!==(r=o.text.exec(t)))n[n.length]=r[0];else if(null!==(r=o.modulo.exec(t)))n[n.length]="%";else{if(null===(r=o.placeholder.exec(t)))throw new SyntaxError("[sprintf] unexpected placeholder");if(r[2]){i|=1;var s=[],a=r[2],u=[];if(null===(u=o.key.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(s[s.length]=u[1];""!==(a=a.substring(u[0].length));)if(null!==(u=o.key_access.exec(a)))s[s.length]=u[1];else{if(null===(u=o.index_access.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");s[s.length]=u[1]}r[2]=s}else i|=2;if(3===i)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");n[n.length]=r}t=t.substring(r[0].length)}return n};var a=function(e,t,r){return(r=(t||[]).slice(0)).splice(0,0,e),s.apply(null,r)};function u(e){return"number"==typeof e?"number":"string"==typeof e?"string":Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}var c={0:["","0","00","000","0000","00000","000000","0000000"]," ":[""," "," "," "," "," "," "," "],_:["","_","__","___","____","_____","______","_______"]};function f(e,t){return t>=0&&t<=7&&c[e]?c[e][t]:Array(t+1).join(e)}t.sprintf=s,t.vsprintf=a,void 0!==i&&(i.sprintf=s,i.vsprintf=a,void 0===(n=function(){return{sprintf:s,vsprintf:a}}.call(t,r,t,e))||(e.exports=n))}("undefined"==typeof window?this:window)},function(e,t,r){(function(t){var n=r(90);e.exports=o,e.exports.source=function(e){return o(null,e)},e.exports.sink=function(e){return o(e,null)};var i="undefined"==typeof setImmediate?t.nextTick:setImmediate;function o(e,t){e&&"object"==typeof e&&(t=e.source,e=e.sink);var r,o,s,a=[],u=[],c=new n;c.writable=c.readable=!0,c.write=function(e){return a.length?a.shift()(null,e):u.push(e),a.length||(o=!0),!!a.length},c.end=function(){t?u.length?d():t(r=!0,a.length?a.shift():function(){}):a.length&&a.shift()(!0)},c.source=function(e,t){u.length?(t(null,u.shift()),u.length||c.emit("drain")):((r=r||e)?t(r):a.push(t),o&&(o=!1,c.emit("drain")))},e&&(s=e(c.source)),s&&!t&&(t=s);var f=[],l=!1,h=!1;if(c.sink=function(e){t=e,i(d)},t){c.sink(t);var p=c.pipe.bind(c);c.pipe=function(e,t){var r=p(e,t);return c.paused&&c.resume(),r}}function d(){if(!1,t&&!h){for(;f.length&&!c.paused;)c.emit("data",f.shift());if(!c.paused){if(l)return c.emit("end");h=!0,t(null,function e(n,i){h=!1,c.paused?(!0===n?l=n:n?c.emit("error",n):f.push(i),!0):n&&!0!==(r=n)?c.emit("error",n):(r=r||n)?c.emit("end"):(c.emit("data",i),h=!0,t(null,e))})}}}return c.pause=function(){return c.paused=!0,c},c.resume=function(){return c.paused=!1,d(),c},c.destroy=function(){!r&&t&&t(r=!0,function(){}),r=!0,a.length&&a.shift()(!0),c.emit("close")},c}}).call(this,r(7))},function(e,t){function r(e,t,r){var n=e.length;if(!n)return r(t);function i(){--n||r(t)}e.forEach(function(e){e?e(t,i):i()}),n||i()}e.exports=function(e){return function(t,n){!function i(){t?r(e,t,n):e.length?e[0]?e[0](null,function(t,o){t?(e.shift(),!0===t?i():r(e,t,n)):n(null,o)}):(e.shift(),i()):n(!0)}()}}},function(e,t,r){"use strict";(function(t){const n=r(44),i=r(26),o=r(1240),s=r(306),a=r(20),u=r(14),c=r(62),f=new Error("Sorry, Not Implemented Yet."),l=c.proto(function(e){if(!(this instanceof l))return new l(e);if(null==e&&(e=""),e instanceof t)this.buffer=o.fromBuffer(e);else if("string"==typeof e||e instanceof String)this.buffer=o.fromString(e);else{if(!(e.buffer&&e.protos&&e.protoCodes))throw new Error("addr must be a string, Buffer, or another Multiaddr");this.buffer=o.fromBuffer(e.buffer)}},{className:"Multiaddr",symbolName:"@multiformats/js-multiaddr/multiaddr"});l.prototype.toString=function(){return o.bufferToString(this.buffer)},l.prototype.toOptions=function(){const e={},t=this.toString().split("/");return e.family="ip4"===t[1]?"ipv4":"ipv6",e.host=t[2],e.transport=t[3],e.port=t[4],e},l.prototype.inspect=function(){return""},l.prototype.protos=function(){return n(this.protoCodes(),function(e){return i(s(e))})},l.prototype.protoCodes=function(){const e=[],t=this.buffer;let r=0;for(;r{if(e[0]===s.names.ipfs.code)return!0})[0][1],u.decode(e)}catch(t){e=null}return e},l.prototype.equals=function(e){return this.buffer.equals(e.buffer)},l.prototype.nodeAddress=function(){if(!this.isThinWaistAddress())throw new Error('Multiaddr must be "thin waist" address for nodeAddress.');const e=this.protoCodes(),t=this.toString().split("/").slice(1);return{family:41===e[0]?"IPv6":"IPv4",address:t[1],port:t[3]}},l.fromNodeAddress=function(e,t){if(!e)throw new Error("requires node address object");if(!t)throw new Error("requires transport protocol");const r="IPv6"===e.family?"ip6":"ip4";return l("/"+[r,e.address,t,e.port].join("/"))},l.prototype.isThinWaistAddress=function(e){const t=(e||this).protos();return!(2!==t.length||4!==t[0].code&&41!==t[0].code||6!==t[1].code&&17!==t[1].code)},l.prototype.fromStupidString=function(e){throw f},l.protocols=s,l.isName=function(e){return!!l.isMultiaddr(e)&&e.protos().some(e=>e.resolvable)},l.resolve=function(e,t){return l.isMultiaddr(e)&&l.isName(e)?t(new Error("not implemented yet")):t(new Error("not a valid name"))},e.exports=l}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(142),i=r(51),o=r(196),s=r(144);e.exports=function(e){function t(e,t,r){return r=r||(()=>{}),e.write(s.CircuitRelay.encode({type:s.CircuitRelay.Type.STATUS,code:t})),r()}return{getB58String:function(e){let t=null;n.isMultiaddr(e)?t=n(e).getPeerId():i.isPeerInfo(e)&&(t=e.id.toB58String());return t},peerInfoFromMa:function(t){let r;if(i.isPeerInfo(t))r=t;else if(n.isMultiaddr(t)){const n=t.getPeerId();try{r=e._peerBook.get(n)}catch(e){r=new i(o.createFromB58String(n))}r.multiaddrs.add(t)}else if(o.isPeerId(t)){const n=t.toB58String();r=e._peerBook.has(n)?e._peerBook.get(n):t}return r},isPeerConnected:function(t){return e.muxedConns[t]||e.conns[t]},validateAddrs:function(e,r,i,o){try{e.dstPeer.addrs.forEach(e=>n(e))}catch(e){return t(r,i===s.CircuitRelay.Type.HOP?s.CircuitRelay.Status.HOP_DST_MULTIADDR_INVALID:s.CircuitRelay.Status.STOP_DST_MULTIADDR_INVALID),o(e)}try{e.srcPeer.addrs.forEach(e=>n(e))}catch(e){return t(r,i===s.CircuitRelay.Type.HOP?s.CircuitRelay.Status.HOP_SRC_MULTIADDR_INVALID:s.CircuitRelay.Status.STOP_SRC_MULTIADDR_INVALID),o(e)}return o(null)},writeResponse:t}}},function(e,t,r){"use strict";const n=r(10);e.exports=n(r(1259))},function(e,t,r){"use strict";t.importer=t.Importer=r(1389),t.exporter=t.Exporter=r(1411)},function(e,t,r){"use strict";const n=r(35).Key;e.exports={FILE_SEPARATOR:"/",MFS_ROOT_KEY:new n("/local/filesroot"),MAX_CHUNK_SIZE:262144,MAX_LINKS:174,FILE_TYPES:{file:0,directory:1}}},function(e,t,r){(function(t){e.exports=function(e,r){var n,i,o,s=!0;function a(e){function i(){r&&r(e,n),r=null}s?t.nextTick(i):i()}function u(e,t,r){n[e]=r,(0==--i||t)&&a(t)}Array.isArray(e)?(n=[],i=e.length):(o=Object.keys(e),n={},i=o.length),i?o?o.forEach(function(t){e[t](function(e,r){u(t,e,r)})}):e.forEach(function(e,t){e(function(e,r){u(t,e,r)})}):a(null),s=!1}}).call(this,r(7))},function(e,t,r){var n=new(r(1521)),i="undefined"!=typeof window?window:self,o=i.crypto||i.msCrypto||{},s=o.subtle||o.webkitSubtle;function a(e){return n.digest(e)}try{s.digest({name:"sha-1"},new Uint8Array).catch(function(){s=!1})}catch(e){s=!1}e.exports=function(e,t){s?("string"==typeof e&&(e=function(e){for(var t=e.length,r=new Uint8Array(t),n=0;n>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")}(new Uint8Array(e)))},function(r){t(a(e))})):setTimeout(t,0,a(e))},e.exports.sync=a},function(e,t,r){const n=r(79);utils={},utils.consolearr=(e=>e&&e.length>0?[e.length+" items inc:",e[e.length-1]]:e),utils.stringfrom=function(e,t={}){try{return"Url"===e.constructor.name?e.href:"string"==typeof e?e:e.toString()}catch(t){throw new n.CodingError(`Unable to turn ${e} into a string ${t.message}`)}},utils.p_timeout=function(e,t,r){let i=null;return Promise.race([new Promise((e,o)=>{i=setTimeout(o,t,new n.TimeoutError(r||`Timed out in ${t}ms`))}),e.then(e=>(clearTimeout(i),e))])},utils.createElement=function(e,t,r){var n=document.createElement(e);for(let e in t){let r="classname"===e.toLowerCase()?"class":e;if("dangerouslySetInnerHTML"===e&&(n.innerHTML=t[e].__html,delete t.dangerouslySetInnerHTML),t.hasOwnProperty(e)){let i=t[e];if(!0===i)n.setAttribute(r,e);else if("object"!=typeof i||Array.isArray(i))!1!==i&&null!=i&&n.setAttribute(r,i.toString());else if(["style"].includes(r))for(let e in i)n[r][e]=i[e];else n[r]=i}}for(let e=2;en.appendChild(null==e.nodeType?document.createTextNode(e.toString()):e)):n.appendChild(null==t.nodeType?document.createTextNode(t.toString()):t))}return n},e.exports=utils},function(e,t,r){"use strict";(function(t){!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,r,n,i){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick(function(){e.call(null,r)});case 3:return t.nextTick(function(){e.call(null,r,n)});case 4:return t.nextTick(function(){e.call(null,r,n,i)});default:for(o=new Array(a-1),s=0;se.plus(t.value.byteLength).plus(t.key._buf.byteLength),new f(0),t))}function E(e,t){return r=>{t(r&&!e(r)?r:null)}}function A(e){return E(e=>"Already open"===e.message,e)}e.exports=class{constructor(e,t){a.equal(typeof e,"string","missing repoPath"),this.options=function(e){const t=Object.assign({},m,e);return t.storageBackends=Object.assign({},m.storageBackends,t.storageBackends),t.storageBackendOptions=Object.assign({},m.storageBackendOptions,t.storageBackendOptions),t}(t),this.closed=!0,this.path=e,this._locker=this._getLocker(),this.root=h.create("root",this.path,this.options),this.version=p(this.root),this.config=d(this.root),this.apiAddr=y(this.root)}init(e,t){v("initializing at: %s",this.path),i([e=>this.root.open(A(e)),t=>this.config.set(e,t),e=>this.version.set(S,e)],t)}open(e){this.closed?(v("opening at: %s",this.path),n([e=>this.root.open(A(e)),e=>this._isInitialized(e),e=>this._openLock(this.path,e),(e,t)=>{v("aquired repo.lock"),this.lockfile=e,t()},e=>{v("creating datastore"),this.datastore=h.create("datastore",u.join(this.path,"datastore"),this.options),v("creating blocks");const t=h.create("blocks",u.join(this.path,"blocks"),this.options);g(t,this.options.storageBackendOptions.blocks,e)},(e,t)=>{this.blocks=e,t()},e=>{v("creating keystore"),this.keys=h.create("keys",u.join(this.path,"keys"),this.options),e()},e=>{this.closed=!1,v("all opened"),e()}],t=>{t&&this.lockfile?this._closeLock(r=>{r?v("error removing lock",r):this.lockfile=null,e(t)}):e(t)})):setImmediate(()=>e(new Error("repo is already open")))}_getLocker(){return"string"==typeof this.options.lock?(a(w[this.options.lock],"Unknown lock type: "+this.options.lock),w[this.options.lock]):(a(this.options.lock,"No lock provided"),this.options.lock)}_openLock(e,t){this._locker.lock(e,(e,r)=>{if(e)return t(e,null);a.equal(typeof r.close,"function","Locks must have a close method"),t(null,r)})}_closeLock(e){if(this.lockfile)return this.lockfile.close(e);e()}_isLocked(e,t){if(this._locker)return this._locker.locked(e,t);t(null,!1)}_isInitialized(e){v("init check"),o({config:e=>this.config.exists(e),version:e=>this.version.check(S,e)},(t,r)=>{if(v("init",t,r),t&&!r.config)return e(Object.assign(new Error("repo is not initialized yet"),{code:b.ERR_REPO_NOT_INITIALIZED,path:this.path}));e(t)})}close(e){if(this.closed)return e(new Error("repo is already closed"));v("closing at: %s",this.path),i([e=>this.apiAddr.delete(function(e){return E(e=>e&&(e.code===b.ERR_REPO_NOT_INITIALIZED||e.message.startsWith("ENOENT")),e)}(e)),e=>{s([this.blocks,this.keys,this.datastore],(e,t)=>e.close(t),e)},e=>{v("unlocking"),this.closed=!0,this._closeLock(e)},e=>{this.lockfile=null,e()}],t=>e(t))}exists(e){this.version.exists(e)}stat(e,t){"function"==typeof e&&(t=e,e={}),e=Object.assign({},{human:!1},e),o({storageMax:e=>this.config.get("Datastore.StorageMax",(t,r)=>{e(null,new f(t?_:r))}),version:e=>this.version.get(e),blocks:e=>this.blocks.query({},(t,r)=>{const n=new f((r=r||[]).length);let i=new f(0);r.forEach(e=>{i=i.plus(e.value.byteLength).plus(e.key._buf.byteLength)}),e(t,{count:n,size:i})}),datastore:e=>k(this.datastore,e),keys:e=>k(this.keys,e)},(r,n)=>{if(r)return t(r);let i=n.blocks.size.plus(n.datastore).plus(n.keys);e.human&&(i=i.div(1048576)),t(null,{repoPath:this.path,storageMax:n.storageMax,version:n.version,numObjects:n.blocks.count,repoSize:i})})}},e.exports.repoVersion=S,e.exports.errors=b},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return function(){if(null!==e){var t=e;e=null,t.apply(this,arguments)}}},e.exports=t.default},function(e,t,r){var n=r(158),i=r(674),o=r(675),s="[object Null]",a="[object Undefined]",u=n?n.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?a:s:u&&u in Object(e)?i(e):o(e)}},function(e,t,r){var n=r(159).Symbol;e.exports=n},function(e,t,r){var n=r(355),i="object"==typeof self&&self&&self.Object===Object&&self,o=n||i||Function("return this")();e.exports=o},function(e,t){e.exports=function(e){return null!=e&&"object"==typeof e}},function(e,t){e.exports=function(){var e,t,r,n,i=function(i,o){e?e(i,o):i?(n=i,r=o):t=o};return i.resolve=function(i){if(e)throw new Error("already resolved");if(!(e=i))throw new Error("no read cannot resolve!"+e);t&&i(null,t),r&&i(n,r)},i.abort=function(e){i.resolve(function(t,r){r(e||!0)})},i}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){var r=(0,i.default)(e);return(0,n.default)(function(e,t){r(e[0],t)},t,1)};var n=o(r(696)),i=o(r(34));function o(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default},function(e,t,r){"use strict";const n=r(8);e.exports=class{constructor(e,t){this.child=e,this.transform=t}open(e){this.child.open(e)}put(e,t,r){this.child.put(this.transform.convert(e),t,r)}get(e,t){this.child.get(this.transform.convert(e),t)}has(e,t){this.child.has(this.transform.convert(e),t)}delete(e,t){this.child.delete(this.transform.convert(e),t)}batch(){const e=this.child.batch();return{put:(t,r)=>{e.put(this.transform.convert(t),r)},delete:t=>{e.delete(this.transform.convert(t))},commit:t=>{e.commit(t)}}}query(e){return n(this.child.query(e),n.map(e=>(e.key=this.transform.invert(e.key),e)))}close(e){this.child.close(e)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return function(t,r,o){return e(n.default,t,(0,i.default)(r),o)}};var n=o(r(218)),i=o(r(34));function o(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default},function(e,t,r){"use strict";(function(t){const n=r(8),i=r(719),o=r(35).utils.asyncFilter,s=r(35).utils.asyncSort,a=r(35).Key,u=r(727);e.exports=class{constructor(e,t){let n;t&&t.db?(n=t.db,delete t.db):n=r(732),this.db=i(u(n(e),{valueEncoding:"binary"}),Object.assign({},t,{compression:!1}),e=>{if(e)throw e})}open(e){this.db.open(e)}put(e,t,r){this.db.put(e.toString(),t,r)}get(e,t){this.db.get(e.toString(),t)}has(e,t){this.db.get(e.toString(),(e,r)=>{if(e)return e.notFound?void t(null,!1):void t(e);t(null,!0)})}delete(e,t){this.db.del(e.toString(),e=>{t(e)})}close(e){this.db.close(e)}batch(){const e=[];return{put:(t,r)=>{e.push({type:"put",key:t.toString(),value:r})},delete:t=>{e.push({type:"del",key:t.toString()})},commit:t=>{this.db.batch(e,t)}}}query(e){let r=!0;null!=e.keysOnly&&(r=!e.keysOnly);const i=this.db.db.iterator({keys:!0,values:r,keyAsBuffer:!0});let u=[(e,n)=>{if(e)return i.end(t=>{n(t||e)});i.next((e,o,s)=>{if(e)return n(e);if(null==e&&null==o&&null==s)return i.end(e=>{n(e||!0)});const u={key:new a(o,!1)};r&&(u.value=t.from(s)),n(null,u)})}],c=[];if(null!=e.prefix){const t=e.prefix;c.push((e,r)=>r(null,e.key.toString().startsWith(t)))}if(null!=e.filters&&(c=c.concat(e.filters)),u=u.concat(c.map(e=>o(e))),null!=e.orders&&(u=u.concat(e.orders.map(e=>s(e)))),null!=e.offset){let t=0;u.push(n.filter(()=>t++>=e.offset))}return null!=e.limit&&u.push(n.take(e.limit)),n.apply(null,u)}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(n){const i=r(12),o=r(17),s=r(62);(t=e.exports=s(class{constructor(e,t,r,s){o(r,"DAGNode needs its serialized format"),o(s,"DAGNode needs its multihash"),"string"==typeof s&&(s=i.fromB58String(s)),this._data=e||n.alloc(0),this._links=t||[],this._serialized=r,this._multihash=s,this._size=this.links.reduce((e,t)=>e+t.size,this.serialized.length),this._json={data:this.data,links:this.links.map(e=>e.toJSON()),multihash:i.toB58String(this.multihash),size:this.size}}toJSON(){return this._json}toString(){return`DAGNode <${i.toB58String(this.multihash)} - data: "${this.data.toString()}", links: ${this.links.length}, size: ${this.size}>`}get data(){return this._data}set data(e){throw new Error("Can't set property: 'data' is immutable")}get links(){return this._links}set links(e){throw new Error("Can't set property: 'links' is immutable")}get serialized(){return this._serialized}set serialized(e){throw new Error("Can't set property: 'serialized' is immutable")}get size(){return this._size}set size(e){throw new Error("Can't set property: 'size' is immutable")}get multihash(){return this._multihash}set multihash(e){throw new Error("Can't set property: 'multihash' is immutable")}},{className:"DAGNode",symbolName:"@ipld/js-ipld-dag-pb/dagnode"})).create=r(167),t.clone=r(767),t.addLink=r(768),t.rmLink=r(769)}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(65),i=r(753),o=r(226).serialize,s=r(168).linkSort,a=r(166),u=r(91);e.exports=function(e,r,c,f){if("function"==typeof e?(f=e,e=void 0):"string"==typeof e&&(e=t.from(e)),"function"==typeof r&&(f=r,r=[]),"function"==typeof c&&(f=c,c=void 0),!t.isBuffer(e))return f(new Error("Passed 'data' is not a buffer or a string!"));c||(c="sha2-256");const l=r.map(e=>u.isDAGLink(e)?e:u.util.createDagLinkFromB58EncodedHash(e)),h=i(l,s);o({data:e,links:h},(t,r)=>{if(t)return f(t);n(r,c,(t,n)=>{if(t)return f(t);const i=new a(e,h,r,n);f(null,i)})})}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(n){const i=r(91);(t=e.exports).cloneData=function(e){let t;return e.data&&e.data.length>0?(t=n.alloc(e.data.length),e.data.copy(t)):t=n.alloc(0),t},t.cloneLinks=function(e){return e.links.slice()},t.linkSort=function(e,t){const r=n.from(e.name||""),i=n.from(t.name||"");return r.compare(i)},t.toDAGLink=function(e){return new i("",e.size,e.multihash)}}).call(this,r(0).Buffer)},function(e,t,r){var n;!function(i){"use strict";var o,s=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,a=Math.ceil,u=Math.floor,c="[BigNumber Error] ",f=c+"Number primitive has more than 15 significant digits: ",l=1e14,h=14,p=9007199254740991,d=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],y=1e7,g=1e9;function m(e){var t=0|e;return e>0||e===t?t:t-1}function b(e){for(var t,r,n=1,i=e.length,o=e[0]+"";nc^r?1:-1;for(a=(u=i.length)<(c=o.length)?u:c,s=0;so[s]^r?1:-1;return u==c?0:u>c^r?1:-1}function _(e,t,r,n){if(er||e!==(e<0?a(e):u(e)))throw Error(c+(n||"Argument")+("number"==typeof e?er?" out of range: ":" not an integer: ":" not a primitive number: ")+e)}function w(e){return"[object Array]"==Object.prototype.toString.call(e)}function S(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function k(e,t,r){var n,i;if(t<0){for(i=r+".";++t;i+=r);e=i+e}else if(++t>(n=e.length)){for(i=r,t-=n;--t;i+=r);e+=i}else t=10;c/=10,a++);return g.e=a,void(g.c=[e])}y=e+""}else{if(!s.test(y=e+""))return i(g,y,l);g.s=45==y.charCodeAt(0)?(y=y.slice(1),-1):1}}else{if(_(t,2,q.length,"Base"),y=e+"",10==t)return W(g=new H(e instanceof H?e:y),O+g.e+1,R);if(l="number"==typeof e){if(0*e!=0)return i(g,y,l,t);if(g.s=1/e<0?(y=y.slice(1),-1):1,y.replace(/^0\.0*|\./,"").length>15)throw Error(f+e);l=!1}else g.s=45===y.charCodeAt(0)?(y=y.slice(1),-1):1,t>10&&t<37&&(y=y.toLowerCase());for(r=q.slice(0,t),a=c=0,d=y.length;ca){a=d;continue}return i(g,e+"",l,t)}y=n(y,t,10,g.s)}for((a=y.indexOf("."))>-1&&(y=y.replace(".","")),(c=y.search(/e/i))>0?(a<0&&(a=c),a+=+y.slice(c+1),y=y.substring(0,c)):a<0&&(a=y.length),c=0;48===y.charCodeAt(c);c++);for(d=y.length;48===y.charCodeAt(--d););if(y=y.slice(c,d+1)){if(d=y.length,l&&d>15&&(e>p||e!==u(e)))throw Error(f+g.s*e);if((a=a-c-1)>j)g.c=g.e=null;else if(aa){if(--t>0)for(u+=".";t--;u+="0");}else if((t+=o-a)>0)for(o+1==a&&(u+=".");t--;u+="0");return e.s<0&&i?"-"+u:u}function V(e,t){var r,n,i=0;for(w(e[0])&&(e=e[0]),r=new H(e[0]);++i=10;i/=10,n++);return(r=n+r*h-1)>j?e.c=e.e=null:r=10;c/=10,i++);if((o=t-i)<0)o+=h,s=t,y=(f=g[p=0])/m[i-s-1]%10|0;else if((p=a((o+1)/h))>=g.length){if(!n)break e;for(;g.length<=p;g.push(0));f=y=0,i=1,s=(o%=h)-h+1}else{for(f=c=g[p],i=1;c>=10;c/=10,i++);y=(s=(o%=h)-h+i)<0?0:f/m[i-s-1]%10|0}if(n=n||t<0||null!=g[p+1]||(s<0?f:f%m[i-s-1]),n=r<4?(y||n)&&(0==r||r==(e.s<0?3:2)):y>5||5==y&&(4==r||n||6==r&&(o>0?s>0?f/m[i-s]:0:g[p-1])%10&1||r==(e.s<0?8:7)),t<1||!g[0])return g.length=0,n?(t-=e.e+1,g[0]=m[(h-t%h)%h],e.e=-t||0):g[0]=e.e=0,e;if(0==o?(g.length=p,c=1,p--):(g.length=p+1,c=m[h-o],g[p]=s>0?u(f/m[i-s]%m[s])*c:0),n)for(;;){if(0==p){for(o=1,s=g[0];s>=10;s/=10,o++);for(s=g[0]+=c,c=1;s>=10;s/=10,c++);o!=c&&(e.e++,g[0]==l&&(g[0]=1));break}if(g[p]+=c,g[p]!=l)break;g[p--]=0,c=1}for(o=g.length;0===g[--o];g.pop());}e.e>j?e.c=e.e=null:e.e>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),t[s]=r[0],t[s+1]=r[1]):(f.push(o%1e14),s+=2);s=i/2}else{if(!crypto.randomBytes)throw M=!1,Error(c+"crypto unavailable");for(t=crypto.randomBytes(i*=7);s=9e15?crypto.randomBytes(7).copy(t,s):(f.push(o%1e14),s+=7);s=i/7}if(!M)for(;s=10;o/=10,s++);sr-1&&(null==s[i+1]&&(s[i+1]=0),s[i+1]+=s[i]/r|0,s[i]%=r)}return s.reverse()}return function(n,i,o,s,a){var u,c,f,l,h,p,d,y,g=n.indexOf("."),m=O,v=R;for(g>=0&&(l=U,U=0,n=n.replace(".",""),p=(y=new H(i)).pow(n.length-g),U=l,y.c=t(k(b(p.c),p.e,"0"),10,o,e),y.e=y.c.length),f=l=(d=t(n,i,o,a?(u=q,e):(u=e,q))).length;0==d[--l];d.pop());if(!d[0])return u.charAt(0);if(g<0?--f:(p.c=d,p.e=f,p.s=s,d=(p=r(p,y,m,v,o)).c,h=p.r,f=p.e),g=d[c=f+m+1],l=o/2,h=h||c<0||null!=d[c+1],h=v<4?(null!=g||h)&&(0==v||v==(p.s<0?3:2)):g>l||g==l&&(4==v||h||6==v&&1&d[c-1]||v==(p.s<0?8:7)),c<1||!d[0])n=h?k(u.charAt(1),-m,u.charAt(0)):u.charAt(0);else{if(d.length=c,h)for(--o;++d[--c]>o;)d[c]=0,c||(++f,d=[1].concat(d));for(l=d.length;!d[--l];);for(g=0,n="";g<=l;n+=u.charAt(d[g++]));n=k(n,f,u.charAt(0))}return n}}(),r=function(){function e(e,t,r){var n,i,o,s,a=0,u=e.length,c=t%y,f=t/y|0;for(e=e.slice();u--;)a=((i=c*(o=e[u]%y)+(n=f*o+(s=e[u]/y|0)*c)%y*y+a)/r|0)+(n/y|0)+f*s,e[u]=i%r;return a&&(e=[a].concat(e)),e}function t(e,t,r,n){var i,o;if(r!=n)o=r>n?1:-1;else for(i=o=0;it[i]?1:-1;break}return o}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]1;e.splice(0,1));}return function(n,i,o,s,a){var c,f,p,d,y,g,b,v,_,w,S,k,E,A,x,I,T,B=n.s==i.s?1:-1,C=n.c,P=i.c;if(!(C&&C[0]&&P&&P[0]))return new H(n.s&&i.s&&(C?!P||C[0]!=P[0]:P)?C&&0==C[0]||!P?0*B:B/0:NaN);for(_=(v=new H(B)).c=[],B=o+(f=n.e-i.e)+1,a||(a=l,f=m(n.e/h)-m(i.e/h),B=B/h|0),p=0;P[p]==(C[p]||0);p++);if(P[p]>(C[p]||0)&&f--,B<0)_.push(1),d=!0;else{for(A=C.length,I=P.length,p=0,B+=2,(y=u(a/(P[0]+1)))>1&&(P=e(P,y,a),C=e(C,y,a),I=P.length,A=C.length),E=I,S=(w=C.slice(0,I)).length;S=a/2&&x++;do{if(y=0,(c=t(P,w,I,S))<0){if(k=w[0],I!=S&&(k=k*a+(w[1]||0)),(y=u(k/x))>1)for(y>=a&&(y=a-1),b=(g=e(P,y,a)).length,S=w.length;1==t(g,w,b,S);)y--,r(g,I=10;B/=10,p++);W(v,o+(v.e=p+f*h-1)+1,s,d)}else v.e=f,v.r=+d;return v}}(),A=/^(-?)0([xbo])(?=\w[\w.]*$)/i,x=/^([^.]+)\.$/,I=/^\.([^.]+)$/,T=/^-?(Infinity|NaN)$/,B=/^\s*\+(?=[\w.])|^\s+|\s+$/g,i=function(e,t,r,n){var i,o=r?t:t.replace(B,"");if(!T.test(o)){if(!r&&(o=o.replace(A,function(e,t,r){return i="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=i?e:t}),n&&(i=n,o=o.replace(x,"$1").replace(I,"0.$1")),t!=o))return new H(o,i);throw Error(c+"Not a"+(n?" base "+n:"")+" number: "+t)}e.s=isNaN(o)?null:o<0?-1:1,e.c=e.e=null},C.absoluteValue=C.abs=function(){var e=new H(this);return e.s<0&&(e.s=1),e},C.comparedTo=function(e,t){return v(this,new H(e,t))},C.decimalPlaces=C.dp=function(e,t){var r,n,i,o=this;if(null!=e)return _(e,0,g),null==t?t=R:_(t,0,8),W(new H(o),e+o.e+1,t);if(!(r=o.c))return null;if(n=((i=r.length-1)-m(this.e/h))*h,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},C.dividedBy=C.div=function(e,t){return r(this,new H(e,t),O,R)},C.dividedToIntegerBy=C.idiv=function(e,t){return r(this,new H(e,t),0,1)},C.isEqualTo=C.eq=function(e,t){return 0===v(this,new H(e,t))},C.integerValue=function(e){var t=new H(this);return null==e?e=R:_(e,0,8),W(t,t.e+1,e)},C.isGreaterThan=C.gt=function(e,t){return v(this,new H(e,t))>0},C.isGreaterThanOrEqualTo=C.gte=function(e,t){return 1===(t=v(this,new H(e,t)))||0===t},C.isFinite=function(){return!!this.c},C.isInteger=function(){return!!this.c&&m(this.e/h)>this.c.length-2},C.isNaN=function(){return!this.s},C.isNegative=function(){return this.s<0},C.isPositive=function(){return this.s>0},C.isZero=function(){return!!this.c&&0==this.c[0]},C.isLessThan=C.lt=function(e,t){return v(this,new H(e,t))<0},C.isLessThanOrEqualTo=C.lte=function(e,t){return-1===(t=v(this,new H(e,t)))||0===t},C.minus=function(e,t){var r,n,i,o,s=this,a=s.s;if(t=(e=new H(e,t)).s,!a||!t)return new H(NaN);if(a!=t)return e.s=-t,s.plus(e);var u=s.e/h,c=e.e/h,f=s.c,p=e.c;if(!u||!c){if(!f||!p)return f?(e.s=-t,e):new H(p?s:NaN);if(!f[0]||!p[0])return p[0]?(e.s=-t,e):new H(f[0]?s:3==R?-0:0)}if(u=m(u),c=m(c),f=f.slice(),a=u-c){for((o=a<0)?(a=-a,i=f):(c=u,i=p),i.reverse(),t=a;t--;i.push(0));i.reverse()}else for(n=(o=(a=f.length)<(t=p.length))?a:t,a=t=0;t0)for(;t--;f[r++]=0);for(t=l-1;n>a;){if(f[--n]=0;){for(r=0,d=k[i]%_,g=k[i]/_|0,o=i+(s=u);o>i;)r=((c=d*(c=S[--s]%_)+(a=g*c+(f=S[s]/_|0)*d)%_*_+b[o]+r)/v|0)+(a/_|0)+g*f,b[o--]=c%v;b[o]=r}return r?++n:b.splice(0,1),G(e,b,n)},C.negated=function(){var e=new H(this);return e.s=-e.s||null,e},C.plus=function(e,t){var r,n=this,i=n.s;if(t=(e=new H(e,t)).s,!i||!t)return new H(NaN);if(i!=t)return e.s=-t,n.minus(e);var o=n.e/h,s=e.e/h,a=n.c,u=e.c;if(!o||!s){if(!a||!u)return new H(i/0);if(!a[0]||!u[0])return u[0]?e:new H(a[0]?n:0*i)}if(o=m(o),s=m(s),a=a.slice(),i=o-s){for(i>0?(s=o,r=u):(i=-i,r=a),r.reverse();i--;r.push(0));r.reverse()}for((i=a.length)-(t=u.length)<0&&(r=u,u=a,a=r,t=i),i=0;t;)i=(a[--t]=a[t]+u[t]+i)/l|0,a[t]=l===a[t]?0:a[t]%l;return i&&(a=[i].concat(a),++s),G(e,a,s)},C.precision=C.sd=function(e,t){var r,n,i,o=this;if(null!=e&&e!==!!e)return _(e,1,g),null==t?t=R:_(t,0,8),W(new H(o),e,t);if(!(r=o.c))return null;if(n=(i=r.length-1)*h+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return e&&o.e+1>n&&(n=o.e+1),n},C.shiftedBy=function(e){return _(e,-p,p),this.times("1e"+e)},C.squareRoot=C.sqrt=function(){var e,t,n,i,o,s=this,a=s.c,u=s.s,c=s.e,f=O+4,l=new H("0.5");if(1!==u||!a||!a[0])return new H(!u||u<0&&(!a||a[0])?NaN:a?s:1/0);if(0==(u=Math.sqrt(+s))||u==1/0?(((t=b(a)).length+c)%2==0&&(t+="0"),u=Math.sqrt(t),c=m((c+1)/2)-(c<0||c%2),n=new H(t=u==1/0?"1e"+c:(t=u.toExponential()).slice(0,t.indexOf("e")+1)+c)):n=new H(u+""),n.c[0])for((u=(c=n.e)+f)<3&&(u=0);;)if(o=n,n=l.times(o.plus(r(s,o,f,1))),b(o.c).slice(0,u)===(t=b(n.c)).slice(0,u)){if(n.e0&&h>0){for(n=h%o||o,u=l.substr(0,n);n0&&(u+=a+l.slice(n)),f&&(u="-"+u)}r=c?u+F.decimalSeparator+((s=+F.fractionGroupSize)?c.replace(new RegExp("\\d{"+s+"}\\B","g"),"$&"+F.fractionGroupSeparator):c):u}return r},C.toFraction=function(e){var t,n,i,o,s,a,u,f,l,p,y,g,m=this,v=m.c;if(null!=e&&(!(f=new H(e)).isInteger()||f.lt(P)))throw Error(c+"Argument "+(f.isInteger()?"out of range: ":"not an integer: ")+e);if(!v)return m.toString();for(n=new H(P),p=i=new H(P),o=l=new H(P),g=b(v),a=n.e=g.length-m.e-1,n.c[0]=d[(u=a%h)<0?h+u:u],e=!e||f.comparedTo(n)>0?a>0?n:p:f,u=j,j=1/0,f=new H(g),l.c[0]=0;y=r(f,n,0,1),1!=(s=i.plus(y.times(o))).comparedTo(e);)i=o,o=s,p=l.plus(y.times(s=p)),l=s,n=f.minus(y.times(s=n)),f=s;return s=r(e.minus(i),o,0,1),l=l.plus(s.times(p)),i=i.plus(s.times(o)),l.s=p.s=m.s,t=r(p,o,a*=2,R).minus(m).abs().comparedTo(r(l,i,a,R).minus(m).abs())<1?[p.toString(),o.toString()]:[l.toString(),i.toString()],j=u,t},C.toNumber=function(){return+this},C.exponentiatedBy=C.pow=function(e,t){var r,n,i,o,s=this;for(_(e,-p,p),null!=t&&(t=new H(t)),t?e>1&&s.gt(P)&&s.isInteger()&&t.gt(P)&&t.isInteger()?s=s.mod(t):(o=t,t=null):U&&(n=a(U/h+2)),i=new H(P),r=u(e<0?-e:e);;){if(r%2){if(!(i=i.times(s)).c)break;n?i.c.length>n&&(i.c.length=n):t&&(i=i.mod(t))}if(!(r=u(r/2)))break;s=s.times(s),n?s.c&&s.c.length>n&&(s.c.length=n):t&&(s=s.mod(t))}return t?i:(e<0&&(i=P.div(i)),o?i.mod(o):n?W(i,U,R):i)},C.toPrecision=function(e,t){return null!=e&&_(e,1,g),z(this,e,t,2)},C.toString=function(e){var t,r=this,i=r.s,o=r.e;return null===o?i?(t="Infinity",i<0&&(t="-"+t)):t="NaN":(t=b(r.c),null==e?t=o<=N||o>=L?S(t,o):k(t,o,"0"):(_(e,2,q.length,"Base"),t=n(k(t,o,"0"),10,e,i,!0)),i<0&&r.c[0]&&(t="-"+t)),t},C.valueOf=C.toJSON=function(){var e,t=this,r=t.e;return null===r?t.toString():(e=b(t.c),e=r<=N||r>=L?S(e,r):k(e,r,"0"),t.s<0?"-"+e:e)},C._isBigNumber=!0,null!=t&&H.set(t),H}()).default=o.BigNumber=o,void 0===(n=function(){return o}.call(t,r,t,e))||(e.exports=n)}()},function(e,t,r){"use strict";const n=r(169);t.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7},t.TAG={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,REGEXP:35,MIME:36},t.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31},t.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23},t.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")},t.SHIFT32=Math.pow(2,32),t.SHIFT16=Math.pow(2,16),t.MAX_SAFE_HIGH=2097151,t.NEG_ONE=new n(-1),t.TEN=new n(10),t.TWO=new n(2),t.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}},function(e,t,r){"use strict";const n=r(172).SmartBuffer,i=r(341),o=r(152),s=r(12),a=r(9);(t=e.exports).SHA1_LENGTH=i.defaultLengths[i.names.sha1],t.find=((e,t)=>{for(let r=0;r{let t=e.match(/^(([^<]+)\s)?\s?<([^>]+)>\s?(\d+\s[+\-\d]+)?$/);return null===t?null:{name:t[2],email:t[3],date:t[4]}}),t.serializePersonLine=(e=>{let t=[];return e.name&&t.push(e.name),t.push("<"+e.email+">"),e.date&&t.push(e.date),t.join(" ")}),t.shaToCid=(e=>{let r=new n;return r.writeUInt8(1),r.writeBuffer(o["git-raw"]),r.writeUInt8(i.names.sha1),r.writeUInt8(t.SHA1_LENGTH),r.writeBuffer(e),r.toBuffer()}),t.cidToSha=(e=>{let t=s.decode(new a(e).multihash);return"sha1"!==t.name?null:t.digest})},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(777),i=4096,o="utf8";class s{constructor(t){if(this.length=0,this._encoding=o,this._writeOffset=0,this._readOffset=0,s.isSmartBufferOptions(t))if(t.encoding&&(n.checkEncoding(t.encoding),this._encoding=t.encoding),t.size){if(!(n.isFiniteInteger(t.size)&&t.size>0))throw new Error(n.ERRORS.INVALID_SMARTBUFFER_SIZE);this._buff=e.allocUnsafe(t.size)}else if(t.buff){if(!(t.buff instanceof e))throw new Error(n.ERRORS.INVALID_SMARTBUFFER_BUFFER);this._buff=t.buff,this.length=t.buff.length}else this._buff=e.allocUnsafe(i);else{if(void 0!==t)throw new Error(n.ERRORS.INVALID_SMARTBUFFER_OBJECT);this._buff=e.allocUnsafe(i)}}static fromSize(e,t){return new this({size:e,encoding:t})}static fromBuffer(e,t){return new this({buff:e,encoding:t})}static fromOptions(e){return new this(e)}static isSmartBufferOptions(e){const t=e;return t&&(void 0!==t.encoding||void 0!==t.size||void 0!==t.buff)}readInt8(t){return this._readNumberValue(e.prototype.readInt8,1,t)}readInt16BE(t){return this._readNumberValue(e.prototype.readInt16BE,2,t)}readInt16LE(t){return this._readNumberValue(e.prototype.readInt16LE,2,t)}readInt32BE(t){return this._readNumberValue(e.prototype.readInt32BE,4,t)}readInt32LE(t){return this._readNumberValue(e.prototype.readInt32LE,4,t)}writeInt8(t,r){return this._writeNumberValue(e.prototype.writeInt8,1,t,r),this}insertInt8(t,r){return this._insertNumberValue(e.prototype.writeInt8,1,t,r),this}writeInt16BE(t,r){return this._writeNumberValue(e.prototype.writeInt16BE,2,t,r),this}insertInt16BE(t,r){return this._insertNumberValue(e.prototype.writeInt16BE,2,t,r),this}writeInt16LE(t,r){return this._writeNumberValue(e.prototype.writeInt16LE,2,t,r),this}insertInt16LE(t,r){return this._insertNumberValue(e.prototype.writeInt16LE,2,t,r),this}writeInt32BE(t,r){return this._writeNumberValue(e.prototype.writeInt32BE,4,t,r),this}insertInt32BE(t,r){return this._insertNumberValue(e.prototype.writeInt32BE,4,t,r),this}writeInt32LE(t,r){return this._writeNumberValue(e.prototype.writeInt32LE,4,t,r),this}insertInt32LE(t,r){return this._insertNumberValue(e.prototype.writeInt32LE,4,t,r),this}readUInt8(t){return this._readNumberValue(e.prototype.readUInt8,1,t)}readUInt16BE(t){return this._readNumberValue(e.prototype.readUInt16BE,2,t)}readUInt16LE(t){return this._readNumberValue(e.prototype.readUInt16LE,2,t)}readUInt32BE(t){return this._readNumberValue(e.prototype.readUInt32BE,4,t)}readUInt32LE(t){return this._readNumberValue(e.prototype.readUInt32LE,4,t)}writeUInt8(t,r){return this._writeNumberValue(e.prototype.writeUInt8,1,t,r),this}insertUInt8(t,r){return this._insertNumberValue(e.prototype.writeUInt8,1,t,r),this}writeUInt16BE(t,r){return this._writeNumberValue(e.prototype.writeUInt16BE,2,t,r),this}insertUInt16BE(t,r){return this._insertNumberValue(e.prototype.writeUInt16BE,2,t,r),this}writeUInt16LE(t,r){return this._writeNumberValue(e.prototype.writeUInt16LE,2,t,r),this}insertUInt16LE(t,r){return this._insertNumberValue(e.prototype.writeUInt16LE,2,t,r),this}writeUInt32BE(t,r){return this._writeNumberValue(e.prototype.writeUInt32BE,4,t,r),this}insertUInt32BE(t,r){return this._insertNumberValue(e.prototype.writeUInt32BE,4,t,r),this}writeUInt32LE(t,r){return this._writeNumberValue(e.prototype.writeUInt32LE,4,t,r),this}insertUInt32LE(t,r){return this._insertNumberValue(e.prototype.writeUInt32LE,4,t,r),this}readFloatBE(t){return this._readNumberValue(e.prototype.readFloatBE,4,t)}readFloatLE(t){return this._readNumberValue(e.prototype.readFloatLE,4,t)}writeFloatBE(t,r){return this._writeNumberValue(e.prototype.writeFloatBE,4,t,r),this}insertFloatBE(t,r){return this._insertNumberValue(e.prototype.writeFloatBE,4,t,r),this}writeFloatLE(t,r){return this._writeNumberValue(e.prototype.writeFloatLE,4,t,r),this}insertFloatLE(t,r){return this._insertNumberValue(e.prototype.writeFloatLE,4,t,r),this}readDoubleBE(t){return this._readNumberValue(e.prototype.readDoubleBE,8,t)}readDoubleLE(t){return this._readNumberValue(e.prototype.readDoubleLE,8,t)}writeDoubleBE(t,r){return this._writeNumberValue(e.prototype.writeDoubleBE,8,t,r),this}insertDoubleBE(t,r){return this._insertNumberValue(e.prototype.writeDoubleBE,8,t,r),this}writeDoubleLE(t,r){return this._writeNumberValue(e.prototype.writeDoubleLE,8,t,r),this}insertDoubleLE(t,r){return this._insertNumberValue(e.prototype.writeDoubleLE,8,t,r),this}readString(e,t){let r;"number"==typeof e?(n.checkLengthValue(e),r=Math.min(e,this.length-this._readOffset)):(t=e,r=this.length-this._readOffset),void 0!==t&&n.checkEncoding(t);const i=this._buff.slice(this._readOffset,this._readOffset+r).toString(t||this._encoding);return this._readOffset+=r,i}insertString(e,t,r){return n.checkOffsetValue(t),this._handleString(e,!0,t,r)}writeString(e,t,r){return this._handleString(e,!1,t,r)}readStringNT(e){void 0!==e&&n.checkEncoding(e);let t=this.length;for(let e=this._readOffset;ethis.length)throw new Error(n.ERRORS.INVALID_READ_BEYOND_BOUNDS)}ensureInsertable(e,t){n.checkOffsetValue(t),this._ensureCapacity(this.length+e),tthis.length?this.length=t+e:this.length+=e}_ensureWriteable(e,t){const r="number"==typeof t?t:this._writeOffset;this._ensureCapacity(r+e),r+e>this.length&&(this.length=r+e)}_ensureCapacity(t){const r=this._buff.length;if(t>r){let n=this._buff,i=3*r/2+1;i0&&"0"===r.toString();)r=(e=e.slice(1))[0];return e},t.toBuffer=function(e){if(!f.isBuffer(e))if(Array.isArray(e))e=f.from(e);else if("string"==typeof e)e=t.isHexString(e)?f.from(t.padToEven(t.stripHexPrefix(e)),"hex"):f.from(e);else if("number"==typeof e)e=t.intToBuffer(e);else if(null===e||void 0===e)e=f.allocUnsafe(0);else if(u.isBN(e))e=e.toArrayLike(f);else{if(!e.toArray)throw new Error("invalid type");e=f.from(e.toArray())}return e},t.bufferToInt=function(e){return new u(t.toBuffer(e)).toNumber()},t.bufferToHex=function(e){return"0x"+(e=t.toBuffer(e)).toString("hex")},t.fromSigned=function(e){return new u(e).fromTwos(256)},t.toUnsigned=function(e){return f.from(e.toTwos(256).toArray())},t.keccak=function(e,r){return e=t.toBuffer(e),r||(r=256),i("keccak"+r).update(e).digest()},t.keccak256=function(e){return t.keccak(e)},t.sha3=t.keccak,t.sha256=function(e){return e=t.toBuffer(e),c("sha256").update(e).digest()},t.ripemd160=function(e,r){e=t.toBuffer(e);var n=c("rmd160").update(e).digest();return!0===r?t.setLength(n,32):n},t.rlphash=function(e){return t.keccak(a.encode(e))},t.isValidPrivate=function(e){return o.privateKeyVerify(e)},t.isValidPublic=function(e,t){return 64===e.length?o.publicKeyVerify(f.concat([f.from([4]),e])):!!t&&o.publicKeyVerify(e)},t.pubToAddress=t.publicToAddress=function(e,r){return e=t.toBuffer(e),r&&64!==e.length&&(e=o.publicKeyConvert(e,!1).slice(1)),s(64===e.length),t.keccak(e).slice(-20)};var l=t.privateToPublic=function(e){return e=t.toBuffer(e),o.publicKeyCreate(e,!1).slice(1)};t.importPublic=function(e){return 64!==(e=t.toBuffer(e)).length&&(e=o.publicKeyConvert(e,!1).slice(1)),e},t.ecsign=function(e,t){var r=o.sign(e,t),n={};return n.r=r.signature.slice(0,32),n.s=r.signature.slice(32,64),n.v=r.recovery+27,n},t.hashPersonalMessage=function(e){var r=t.toBuffer("Ethereum Signed Message:\n"+e.length.toString());return t.keccak(f.concat([r,e]))},t.ecrecover=function(e,r,n,i){var s=f.concat([t.setLength(n,32),t.setLength(i,32)],64),a=r-27;if(0!==a&&1!==a)throw new Error("Invalid signature v value");var u=o.recover(e,s,a);return o.publicKeyConvert(u,!1).slice(1)},t.toRpcSig=function(e,r,n){if(27!==e&&28!==e)throw new Error("Invalid recovery id");return t.bufferToHex(f.concat([t.setLengthLeft(r,32),t.setLengthLeft(n,32),t.toBuffer(e-27)]))},t.fromRpcSig=function(e){if(65!==(e=t.toBuffer(e)).length)throw new Error("Invalid signature length");var r=e[64];return r<27&&(r+=27),{v:r,r:e.slice(0,32),s:e.slice(32,64)}},t.privateToAddress=function(e){return t.publicToAddress(l(e))},t.isValidAddress=function(e){return/^0x[0-9a-fA-F]{40}$/.test(e)},t.isZeroAddress=function(e){return t.zeroAddress()===t.addHexPrefix(e)},t.toChecksumAddress=function(e){e=t.stripHexPrefix(e).toLowerCase();for(var r=t.keccak(e).toString("hex"),n="0x",i=0;i=8?n+=e[i].toUpperCase():n+=e[i];return n},t.isValidChecksumAddress=function(e){return t.isValidAddress(e)&&t.toChecksumAddress(e)===e},t.generateAddress=function(e,r){return e=t.toBuffer(e),r=(r=new u(r)).isZero()?null:f.from(r.toArray()),t.rlphash([e,r]).slice(-20)},t.isPrecompiled=function(e){var r=t.unpad(e);return 1===r.length&&r[0]>=1&&r[0]<=8},t.addHexPrefix=function(e){return"string"!=typeof e?e:t.isHexPrefixed(e)?e:"0x"+e},t.isValidSignature=function(e,t,r,n){var i=new u("7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0",16),o=new u("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",16);return!(32!==t.length||32!==r.length||27!==e&&28!==e||(t=new u(t),r=new u(r),t.isZero()||t.gt(o)||r.isZero()||r.gt(o)||!1===n&&1===new u(r).cmp(i)))},t.baToJSON=function(e){if(f.isBuffer(e))return"0x"+e.toString("hex");if(e instanceof Array){for(var r=[],n=0;n=i.length,"The field "+r.name+" must not have more "+r.length+" bytes")):r.allowZero&&0===i.length||!r.length||s(r.length===i.length,"The field "+r.name+" must have byte length of "+r.length),e.raw[n]=i}e._fields.push(r.name),Object.defineProperty(e,r.name,{enumerable:!0,configurable:!0,get:i,set:o}),r.default&&(e[r.name]=r.default),r.alias&&Object.defineProperty(e,r.alias,{enumerable:!1,configurable:!0,set:o,get:i})}),i)if("string"==typeof i&&(i=f.from(t.stripHexPrefix(i),"hex")),f.isBuffer(i)&&(i=a.decode(i)),Array.isArray(i)){if(i.length>e._fields.length)throw new Error("wrong number of fields in data");i.forEach(function(r,n){e[e._fields[n]]=t.toBuffer(r)})}else{if("object"!==(void 0===i?"undefined":n(i)))throw new Error("invalid data");var o=Object.keys(i);r.forEach(function(t){-1!==o.indexOf(t.name)&&(e[t.name]=i[t.name]),-1!==o.indexOf(t.alias)&&(e[t.alias]=i[t.alias])})}}},function(e,t,r){"use strict";var n=t;n.base=r(834),n.short=r(835),n.mont=r(836),n.edwards=r(837)},function(e,t,r){"use strict";var n=t;n.base=r(883),n.short=r(884),n.mont=r(885),n.edwards=r(886)},function(e,t,r){"use strict";(function(t){var n=r(18),i=r(97),o=r(129),s=r(32),a=r(29),u=r(96),c=r(108),f=r(73),l=r(179),h=r(21);function p(e,t){if(!(this instanceof p))return new p(e,t);if(e instanceof p)return e;var r=this._classifyArguments(e,t);if(!r.bn||0===r.bn.cmp(new s(0)))throw new TypeError("Number can not be equal to zero, undefined, null or false");if(!r.bn.lt(c.getN()))throw new TypeError("Number must be less than N");if(void 0===r.network)throw new TypeError('Must specify the network ("livenet" or "testnet")');return a.defineImmutable(this,{bn:r.bn,compressed:r.compressed,network:r.network}),Object.defineProperty(this,"publicKey",{configurable:!1,enumerable:!0,get:this.toPublicKey.bind(this)}),this}p.prototype._classifyArguments=function(e,r){var i={compressed:!0,network:r?u.get(r):u.defaultNetwork};if(n.isUndefined(e)||n.isNull(e))i.bn=p._getRandomBN();else if(e instanceof s)i.bn=e;else if(e instanceof t||e instanceof Uint8Array)i=p._transformBuffer(e,r);else if(e.bn&&e.network)i=p._transformObject(e);else if(!r&&u.get(e))i.bn=p._getRandomBN(),i.network=u.get(e);else{if("string"!=typeof e)throw new TypeError("First argument is an unrecognized data type.");a.isHexa(e)?i.bn=new s(new t(e,"hex")):i=p._transformWIF(e,r)}return i},p._getRandomBN=function(){var e,t;do{var r=l.getRandomBuffer(32);e=(t=s.fromBuffer(r)).lt(c.getN())}while(!e);return t},p._transformBuffer=function(e,t){var r={};if(32===e.length)return p._transformBNBuffer(e,t);if(r.network=u.get(e[0],"privatekey"),!r.network)throw new Error("Invalid network");if(t&&r.network!==u.get(t))throw new TypeError("Private key network mismatch");if(34===e.length&&1===e[33])r.compressed=!0;else{if(33!==e.length)throw new Error("Length of buffer must be 33 (uncompressed) or 34 (compressed)");r.compressed=!1}return r.bn=s.fromBuffer(e.slice(1,33)),r},p._transformBNBuffer=function(e,t){var r={};return r.network=u.get(t)||u.defaultNetwork,r.bn=s.fromBuffer(e),r.compressed=!1,r},p._transformWIF=function(e,t){return p._transformBuffer(o.decode(e),t)},p.fromBuffer=function(e,t){return new p(e,t)},p._transformObject=function(e){return{bn:new s(e.bn,"hex"),network:u.get(e.network),compressed:e.compressed}},p.fromString=p.fromWIF=function(e){return h.checkArgument(n.isString(e),"First argument is expected to be a string."),new p(e)},p.fromObject=function(e){return h.checkArgument(n.isObject(e),"First argument is expected to be an object."),new p(e)},p.fromRandom=function(e){return new p(p._getRandomBN(),e)},p.getValidationError=function(e,t){var r;try{new p(e,t)}catch(e){r=e}return r},p.isValid=function(e,t){return!!e&&!p.getValidationError(e,t)},p.prototype.toString=function(){return this.toBuffer().toString("hex")},p.prototype.toWIF=function(){var e,r=this.network;return e=this.compressed?t.concat([new t([r.privatekey]),this.bn.toBuffer({size:32}),new t([1])]):t.concat([new t([r.privatekey]),this.bn.toBuffer({size:32})]),o.encode(e)},p.prototype.toBigNumber=function(){return this.bn},p.prototype.toBuffer=function(){return this.bn.toBuffer()},p.prototype.toPublicKey=function(){return this._pubkey||(this._pubkey=f.fromPrivateKey(this)),this._pubkey},p.prototype.toAddress=function(e){var t=this.toPublicKey();return i.fromPublicKey(t,e||this.network)},p.prototype.toObject=p.prototype.toJSON=function(){return{bn:this.bn.toString("hex"),compressed:this.compressed,network:this.network.toString()}},p.prototype.inspect=function(){var e=this.compressed?"":", uncompressed";return""},e.exports=p}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){var n=r(18),i=r(432),o=r(0),s="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".split(""),a=function e(r){if(!(this instanceof e))return new e(r);if(t.isBuffer(r)){var n=r;this.fromBuffer(n)}else if("string"==typeof r){var i=r;this.fromString(i)}else r&&this.set(r)};a.validCharacters=function(e){return o.Buffer.isBuffer(e)&&(e=e.toString()),n.all(n.map(e,function(e){return n.contains(s,e)}))},a.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this},a.encode=function(e){if(!o.Buffer.isBuffer(e))throw new Error("Input should be a buffer");return i.encode(e)},a.decode=function(e){if("string"!=typeof e)throw new Error("Input should be a string");return new t(i.decode(e))},a.prototype.fromBuffer=function(e){return this.buf=e,this},a.prototype.fromString=function(e){var t=a.decode(e);return this.buf=t,this},a.prototype.toBuffer=function(){return this.buf},a.prototype.toString=function(){return a.encode(this.buf)},e.exports=a}).call(this,r(0).Buffer)},function(e,t,r){e.exports=r(250),e.exports.Input=r(251),e.exports.Output=r(84),e.exports.UnspentOutput=r(434),e.exports.Signature=r(131),e.exports.Sighash=r(83)},function(e,t,r){"use strict";(function(t,n){function i(){}i.getRandomBuffer=function(e){return t.browser?i.getRandomBufferBrowser(e):i.getRandomBufferNode(e)},i.getRandomBufferNode=function(e){return r(95).randomBytes(e)},i.getRandomBufferBrowser=function(e){if(!window.crypto&&!window.msCrypto)throw new Error("window.crypto not available");if(window.crypto&&window.crypto.getRandomValues)var t=window.crypto;else{if(!window.msCrypto||!window.msCrypto.getRandomValues)throw new Error("window.crypto.getRandomValues not available");t=window.msCrypto}var r=new Uint8Array(e);return t.getRandomValues(r),new n(r)},i.getPseudoRandomBuffer=function(e){for(var t,r=new n(e),i=0;i<=e;i++){0==i-4*Math.floor(i/4)?(t=4294967296*Math.random(),r[i]=255&t):r[i]=255&(t>>>=8)}return r},e.exports=i}).call(this,r(7),r(0).Buffer)},function(e,t,r){"use strict";(function(t){var n=r(18),i=r(32),o=r(24),s=r(82),a=r(57),u=r(43),c=(r(29),r(21)),f=function e(t){if(!(this instanceof e))return new e(t);var r=e._from(t);return this.version=r.version,this.prevHash=r.prevHash,this.merkleRoot=r.merkleRoot,this.reserved=r.reserved,this.time=r.time,this.timestamp=r.time,this.bits=r.bits,this.nonce=r.nonce,this.solution=r.solution,r.hash&&c.checkState(this.hash===r.hash,"Argument object hash property does not match block hash."),this};f._from=function(e){var t={};if(o.isBuffer(e))t=f._fromBufferReader(s(e));else{if(!n.isObject(e))throw new TypeError("Unrecognized argument for BlockHeader");t=f._fromObject(e)}return t},f._fromObject=function(e){c.checkArgument(e,"data is required");var r=e.prevHash,i=e.merkleRoot,s=e.reserved,a=e.nonce,u=e.solution;return n.isString(e.prevHash)&&(r=o.reverse(new t(e.prevHash,"hex"))),n.isString(e.merkleRoot)&&(i=o.reverse(new t(e.merkleRoot,"hex"))),n.isString(e.reserved)&&(s=o.reverse(new t(e.reserved,"hex"))),n.isString(e.nonce)&&(a=o.reverse(new t(e.nonce,"hex"))),n.isString(e.solution)&&(u=new t(e.solution,"hex")),{hash:e.hash,version:e.version,prevHash:r,merkleRoot:i,reserved:s,time:e.time,timestamp:e.time,bits:e.bits,nonce:a,solution:u}},f.fromObject=function(e){var t=f._fromObject(e);return new f(t)},f.fromRawBlock=function(e){o.isBuffer(e)||(e=new t(e,"binary"));var r=s(e);r.pos=f.Constants.START_OF_HEADER;var n=f._fromBufferReader(r);return new f(n)},f.fromBuffer=function(e){var t=f._fromBufferReader(s(e));return new f(t)},f.fromString=function(e){var r=new t(e,"hex");return f.fromBuffer(r)},f._fromBufferReader=function(e){var t={};t.version=e.readUInt32LE(),t.prevHash=e.read(32),t.merkleRoot=e.read(32),t.reserved=e.read(32),t.time=e.readUInt32LE(),t.bits=e.readUInt32LE(),t.nonce=e.read(32);var r=e.readVarintNum();return t.solution=e.read(r),t},f.fromBufferReader=function(e){var t=f._fromBufferReader(e);return new f(t)},f.prototype.toObject=f.prototype.toJSON=function(){return{hash:this.hash,version:this.version,prevHash:o.reverse(this.prevHash).toString("hex"),merkleRoot:o.reverse(this.merkleRoot).toString("hex"),reserved:o.reverse(this.reserved).toString("hex"),time:this.time,bits:this.bits,nonce:o.reverse(this.nonce).toString("hex"),solution:this.solution.toString("hex")}},f.prototype.toBuffer=function(){return this.toBufferWriter().concat()},f.prototype.toString=function(){return this.toBuffer().toString("hex")},f.prototype.toBufferWriter=function(e){return e||(e=new a),e.writeUInt32LE(this.version),e.write(this.prevHash),e.write(this.merkleRoot),e.write(this.reserved),e.writeUInt32LE(this.time),e.writeUInt32LE(this.bits),e.write(this.nonce),e.writeVarintNum(this.solution.length),e.write(this.solution),e},f.prototype.getTargetDifficulty=function(e){e=e||this.bits;for(var t=new i(16777215&e),r=8*((e>>>24)-3);r-- >0;)t=t.mul(new i(2));return t},f.prototype.getDifficulty=function(){var e=this.getTargetDifficulty(537133055).mul(new i(Math.pow(10,8))),t=this.getTargetDifficulty(),r=e.div(t).toString(10),n=r.length-8;return r=r.slice(0,n)+"."+r.slice(n),parseFloat(r)},f.prototype._getHash=function(){var e=this.toBuffer();return u.sha256sha256(e)};var l={configurable:!1,enumerable:!0,get:function(){return this._id||(this._id=s(this._getHash()).readReverse().toString("hex")),this._id},set:n.noop};Object.defineProperty(f.prototype,"id",l),Object.defineProperty(f.prototype,"hash",l),f.prototype.validTimestamp=function(){var e=Math.round((new Date).getTime()/1e3);return!(this.time>e+f.Constants.MAX_TIME_OFFSET)},f.prototype.validProofOfWork=function(){var e=new i(this.id,"hex"),t=this.getTargetDifficulty();return!(e.cmp(t)>0)},f.prototype.inspect=function(){return""},f.Constants={START_OF_HEADER:8,MAX_TIME_OFFSET:7200,LARGEST_HASH:new i("10000000000000000000000000000000000000000000000000000000000000000","hex")},e.exports=f}).call(this,r(0).Buffer)},function(e,t,r){var n=r(2).Buffer;function i(e){n.isBuffer(e)||(e=n.from(e));for(var t=e.length/4|0,r=new Array(t),i=0;i>>24]^f[d>>>16&255]^l[y>>>8&255]^h[255&g]^t[m++],s=c[d>>>24]^f[y>>>16&255]^l[g>>>8&255]^h[255&p]^t[m++],a=c[y>>>24]^f[g>>>16&255]^l[p>>>8&255]^h[255&d]^t[m++],u=c[g>>>24]^f[p>>>16&255]^l[d>>>8&255]^h[255&y]^t[m++],p=o,d=s,y=a,g=u;return o=(n[p>>>24]<<24|n[d>>>16&255]<<16|n[y>>>8&255]<<8|n[255&g])^t[m++],s=(n[d>>>24]<<24|n[y>>>16&255]<<16|n[g>>>8&255]<<8|n[255&p])^t[m++],a=(n[y>>>24]<<24|n[g>>>16&255]<<16|n[p>>>8&255]<<8|n[255&d])^t[m++],u=(n[g>>>24]<<24|n[p>>>16&255]<<16|n[d>>>8&255]<<8|n[255&y])^t[m++],[o>>>=0,s>>>=0,a>>>=0,u>>>=0]}var a=[0,1,2,4,8,16,32,64,128,27,54],u=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,u=0;u<256;++u){var c=a^a<<1^a<<2^a<<3^a<<4;c=c>>>8^255&c^99,r[s]=c,n[c]=s;var f=e[s],l=e[f],h=e[l],p=257*e[c]^16843008*c;i[0][s]=p<<24|p>>>8,i[1][s]=p<<16|p>>>16,i[2][s]=p<<8|p>>>24,i[3][s]=p,p=16843009*h^65537*l^257*f^16843008*s,o[0][c]=p<<24|p>>>8,o[1][c]=p<<16|p>>>16,o[2][c]=p<<8|p>>>24,o[3][c]=p,0===s?s=a=1:(s=f^e[e[e[h^f]]],a^=e[e[a]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function c(e){this._key=i(e),this._reset()}c.blockSize=16,c.keySize=32,c.prototype.blockSize=c.blockSize,c.prototype.keySize=c.keySize,c.prototype._reset=function(){for(var e=this._key,t=e.length,r=t+6,n=4*(r+1),i=[],o=0;o>>24,s=u.SBOX[s>>>24]<<24|u.SBOX[s>>>16&255]<<16|u.SBOX[s>>>8&255]<<8|u.SBOX[255&s],s^=a[o/t|0]<<24):t>6&&o%t==4&&(s=u.SBOX[s>>>24]<<24|u.SBOX[s>>>16&255]<<16|u.SBOX[s>>>8&255]<<8|u.SBOX[255&s]),i[o]=i[o-t]^s}for(var c=[],f=0;f>>24]]^u.INV_SUB_MIX[1][u.SBOX[h>>>16&255]]^u.INV_SUB_MIX[2][u.SBOX[h>>>8&255]]^u.INV_SUB_MIX[3][u.SBOX[255&h]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=c},c.prototype.encryptBlockRaw=function(e){return s(e=i(e),this._keySchedule,u.SUB_MIX,u.SBOX,this._nRounds)},c.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},c.prototype.decryptBlock=function(e){var t=(e=i(e))[1];e[1]=e[3],e[3]=t;var r=s(e,this._invKeySchedule,u.INV_SUB_MIX,u.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},c.prototype.scrub=function(){o(this._keySchedule),o(this._invKeySchedule),o(this._key)},e.exports.AES=c},function(e,t,r){var n=r(13);function i(e,t){n.cipher.registerAlgorithm(e,function(){return new n.des.Algorithm(e,t)})}r(257),r(446),r(19),e.exports=n.des=n.des||{},n.des.startEncrypting=function(e,t,r,n){var i=d({key:e,output:r,decrypt:!1,mode:n||(null===t?"ECB":"CBC")});return i.start(t),i},n.des.createEncryptionCipher=function(e,t){return d({key:e,output:null,decrypt:!1,mode:t})},n.des.startDecrypting=function(e,t,r,n){var i=d({key:e,output:r,decrypt:!0,mode:n||(null===t?"ECB":"CBC")});return i.start(t),i},n.des.createDecryptionCipher=function(e,t){return d({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 p(r._keys,e,t,!1)},decrypt:function(e,t){return p(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],u=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],c=[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],l=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],h=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],p=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],d=[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],g=e.length()>8?3:1,m=[],b=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],v=0,_=0;_>>4^S))<<4,w^=t=65535&((S^=t)>>>-16^w),w^=(t=858993459&(w>>>2^(S^=t<<-16)))<<2,w^=t=65535&((S^=t)>>>-16^w),w^=(t=1431655765&(w>>>1^(S^=t<<-16)))<<1,w^=t=16711935&((S^=t)>>>8^w),t=(w^=(t=1431655765&(w>>>1^(S^=t<<8)))<<1)<<8|(S^=t)>>>20&240,w=S<<24|S<<8&16711680|S>>>8&65280|S>>>24&240,S=t;for(var k=0;k>>26,S=S<<2|S>>>26):(w=w<<1|w>>>27,S=S<<1|S>>>27);var E=r[(w&=-15)>>>28]|n[w>>>24&15]|i[w>>>20&15]|o[w>>>16&15]|s[w>>>12&15]|a[w>>>8&15]|u[w>>>4&15],A=c[(S&=-15)>>>28]|f[S>>>24&15]|l[S>>>20&15]|h[S>>>16&15]|p[S>>>12&15]|d[S>>>8&15]|y[S>>>4&15];t=65535&(A>>>16^E),m[v++]=E^t,m[v++]=A^t<<16}}return m}(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],u=[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],c=[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],l=[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],h=[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 p(e,t,r,n){var i,p,d=32===e.length?3:9;i=3===d?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],g=t[1];y^=(p=252645135&(y>>>4^g))<<4,y^=(p=65535&(y>>>16^(g^=p)))<<16,y^=p=858993459&((g^=p)>>>2^y),y^=p=16711935&((g^=p<<2)>>>8^y),y=(y^=(p=1431655765&(y>>>1^(g^=p<<8)))<<1)<<1|y>>>31,g=(g^=p)<<1|g>>>31;for(var m=0;m>>4|g<<28)^e[_+1];p=y,y=g,g=p^(s[w>>>24&63]|u[w>>>16&63]|f[w>>>8&63]|h[63&w]|o[S>>>24&63]|a[S>>>16&63]|c[S>>>8&63]|l[63&S])}p=y,y=g,g=p}g=g>>>1|g<<31,g^=p=1431655765&((y=y>>>1|y<<31)>>>1^g),g^=(p=16711935&(g>>>8^(y^=p<<1)))<<8,g^=(p=858993459&(g>>>2^(y^=p)))<<2,g^=p=65535&((y^=p)>>>16^g),g^=p=252645135&((y^=p<<16)>>>4^g),y^=p<<4,r[0]=y,r[1]=g}function d(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(13);if(r(76),r(184),r(99),r(454),r(455),r(69),r(19),void 0===i)var i=n.jsbn.BigInteger;var o=n.asn1;n.pki=n.pki||{},e.exports=n.pki.rsa=n.rsa=n.rsa||{};var s=n.pki,a=[6,4,2,4,2,4,6,2],u={name:"PrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",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:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},c={name:"RSAPrivateKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},f={name:"RSAPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},l=n.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",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:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},h=function(e){var t;if(!(e.algorithm in s.oids)){var r=new Error("Unknown message digest algorithm.");throw r.algorithm=e.algorithm,r}t=s.oids[e.algorithm];var n=o.oidToDer(t).getBytes(),i=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[]),a=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[]);a.value.push(o.create(o.Class.UNIVERSAL,o.Type.OID,!1,n)),a.value.push(o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,""));var u=o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,e.digest().getBytes());return i.value.push(a),i.value.push(u),o.toDer(i).getBytes()},p=function(e,t,r){if(r)return e.modPow(t.e,t.n);if(!t.p||!t.q)return e.modPow(t.d,t.n);var o;t.dP||(t.dP=t.d.mod(t.p.subtract(i.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(i.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));do{o=new i(n.util.bytesToHex(n.random.getBytes(t.n.bitLength()/8)),16)}while(o.compareTo(t.n)>=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 u=s.subtract(a).multiply(t.qInv).mod(t.p).multiply(t.q).add(a);return u.multiply(o.modInverse(t.n)).mod(t.n)};function d(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,u=o-3-e.length;if(0===r||1===r){a=0===r?0:255;for(var c=0;c0;){var f=0,l=n.random.getBytes(u);for(c=0;c1;){if(255!==s.getByte()){--s.read;break}++c}else if(2===u)for(c=0;s.length()>1;){if(0===s.getByte()){--s.read;break}++c}if(0!==s.getByte()||c!==o-3-s.length())throw new Error("Encryption block is invalid.");return s.getBytes()}function g(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 a(){u(e.pBits,function(t,n){return t?r(t):(e.p=n,null!==e.q?c(t,e.q):void u(e.qBits,c))})}function u(e,t){n.prime.generateProbablePrime(e,o,t)}function c(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 a();if(0!==e.q.subtract(i.ONE).gcd(e.e).compareTo(i.ONE))return e.q=null,void u(e.qBits,c);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 a();if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits)return e.q=null,void u(e.qBits,c);var f=e.e.modInverse(e.phi);e.keys={privateKey:s.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:s.rsa.setPublicKey(e.n,e.e)},r(null,e.keys)}"prng"in t&&(o.prng=t.prng),a()}function m(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 b(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 v(e){return"undefined"!=typeof window&&"object"==typeof window.crypto&&"object"==typeof window.crypto.subtle&&"function"==typeof window.crypto.subtle[e]}function _(e){return"undefined"!=typeof window&&"object"==typeof window.msCrypto&&"object"==typeof window.msCrypto.subtle&&"function"==typeof window.msCrypto.subtle[e]}function w(e){for(var t=n.util.hexToBytes(e.toString(16)),r=new Uint8Array(t.length),i=0;i0;)f.putByte(0),--l;return f.putBytes(n.util.hexToBytes(c)),f.getBytes()},s.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 u=new i(n.util.createBuffer(e).toHex(),16);if(u.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var c=p(u,t,r).toString(16),f=n.util.createBuffer(),l=s-Math.ceil(c.length/2);l>0;)f.putByte(0),--l;return f.putBytes(n.util.hexToBytes(c)),!1!==o?y(f.getBytes(),t,r):f.getBytes()},s.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},s.rsa.stepKeyPairGenerationState=function(e,t){"algorithm"in e||(e.algorithm="PRIMEINC");var r=new i(null);r.fromInt(30);for(var n,o=0,u=function(e,t){return e|t},c=+new Date,f=0;null===e.keys&&(t<=0||fl?e.pqState=0:e.num.isProbablePrime(b(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(a[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 p=e.e.modInverse(e.phi);e.keys={privateKey:s.rsa.setPrivateKey(e.n,e.e,p,e.p,e.q,p.mod(e.p1),p.mod(e.q1),e.q.modInverse(e.p)),publicKey:s.rsa.setPublicKey(e.n,e.e)}}f+=(n=+new Date)-c,c=n}return null!==e.keys},s.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&&i&&e>=256&&e<=16384&&(65537===t||3===t)){if(v("generateKey")&&v("exportKey"))return window.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:w(t),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(e){return window.crypto.subtle.exportKey("pkcs8",e.privateKey)}).then(void 0,function(e){i(e)}).then(function(e){if(e){var t=s.privateKeyFromAsn1(o.fromDer(n.util.createBuffer(e)));i(null,{privateKey:t,publicKey:s.setRsaPublicKey(t.n,t.e)})}});if(_("generateKey")&&_("exportKey")){var a=window.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:w(t),hash:{name:"SHA-256"}},!0,["sign","verify"]);return a.oncomplete=function(e){var t=e.target.result,r=window.msCrypto.subtle.exportKey("pkcs8",t.privateKey);r.oncomplete=function(e){var t=e.target.result,r=s.privateKeyFromAsn1(o.fromDer(n.util.createBuffer(t)));i(null,{privateKey:r,publicKey:s.setRsaPublicKey(r.n,r.e)})},r.onerror=function(e){i(e)}},void(a.onerror=function(e){i(e)})}}var u=s.rsa.createKeyPairGenerationState(e,t,r);if(!i)return s.rsa.stepKeyPairGenerationState(u,0),u.keys;g(u,r,i)},s.setRsaPublicKey=s.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 d(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 s.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=y(t,r,!0),e===o.fromDer(t).value[1].value}}:"NONE"!==n&&"NULL"!==n&&null!==n||(n={verify:function(e,t){return e===y(t,r,!0)}});var i=s.rsa.decrypt(t,r,!0,!1);return n.verify(e,i,r.n.bitLength())}};return r},s.setRsaPrivateKey=s.rsa.setPrivateKey=function(e,t,r,i,o,a,u,c){var f={n:e,e:t,d:r,p:i,q:o,dP:a,dQ:u,qInv:c,decrypt:function(e,t,r){"string"==typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5");var i=s.rsa.decrypt(e,f,!1,!1);if("RSAES-PKCS1-V1_5"===t)t={decode:y};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:h},r=1):"NONE"!==t&&"NULL"!==t&&null!==t||(t={encode:function(){return e}},r=1);var n=t.encode(e,f.n.bitLength());return s.rsa.encrypt(n,f,r)}};return f},s.wrapRsaPrivateKey=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,o.integerToDer(0).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(s.oids.rsaEncryption).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")]),o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,o.toDer(e).getBytes())])},s.privateKeyFromAsn1=function(e){var t,r,a,f,l,h,p,d,y={},g=[];if(o.validate(e,u,y,g)&&(e=o.fromDer(n.util.createBuffer(y.privateKey))),y={},g=[],!o.validate(e,c,y,g)){var m=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw m.errors=g,m}return t=n.util.createBuffer(y.privateKeyModulus).toHex(),r=n.util.createBuffer(y.privateKeyPublicExponent).toHex(),a=n.util.createBuffer(y.privateKeyPrivateExponent).toHex(),f=n.util.createBuffer(y.privateKeyPrime1).toHex(),l=n.util.createBuffer(y.privateKeyPrime2).toHex(),h=n.util.createBuffer(y.privateKeyExponent1).toHex(),p=n.util.createBuffer(y.privateKeyExponent2).toHex(),d=n.util.createBuffer(y.privateKeyCoefficient).toHex(),s.setRsaPrivateKey(new i(t,16),new i(r,16),new i(a,16),new i(f,16),new i(l,16),new i(h,16),new i(p,16),new i(d,16))},s.privateKeyToAsn1=s.privateKeyToRSAPrivateKey=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,o.integerToDer(0).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,m(e.n)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,m(e.e)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,m(e.d)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,m(e.p)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,m(e.q)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,m(e.dP)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,m(e.dQ)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,m(e.qInv))])},s.publicKeyFromAsn1=function(e){var t={},r=[];if(o.validate(e,l,t,r)){var a,u=o.derToOid(t.publicKeyOid);if(u!==s.oids.rsaEncryption)throw(a=new Error("Cannot read public key. Unknown OID.")).oid=u,a;e=t.rsaPublicKey}if(r=[],!o.validate(e,f,t,r))throw(a=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=r,a;var c=n.util.createBuffer(t.publicKeyModulus).toHex(),h=n.util.createBuffer(t.publicKeyExponent).toHex();return s.setRsaPublicKey(new i(c,16),new i(h,16))},s.publicKeyToAsn1=s.publicKeyToSubjectPublicKeyInfo=function(e){return 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(s.oids.rsaEncryption).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")]),o.create(o.Class.UNIVERSAL,o.Type.BITSTRING,!1,[s.publicKeyToRSAPublicKey(e)])])},s.publicKeyToRSAPublicKey=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,m(e.n)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,m(e.e))])}},function(e,t,r){var n,i=r(13);e.exports=i.jsbn=i.jsbn||{};function o(e,t,r){this.data=[],null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}function s(){return new o(null)}function a(e,t,r,n,i,o){for(var s=16383&t,a=t>>14;--o>=0;){var u=16383&this.data[e],c=this.data[e++]>>14,f=a*u+c*s;i=((u=s*u+((16383&f)<<14)+r.data[n]+i)>>28)+(f>>14)+a*c,r.data[n++]=268435455&u}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 u=32767&this.data[e],c=this.data[e++]>>15,f=a*u+c*s;i=((u=s*u+((32767&f)<<15)+r.data[n]+(1073741823&i))>>>30)+(f>>>15)+a*c+(i>>>30),r.data[n++]=1073741823&u}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 g(e){this.m=e}function m(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 k(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function E(){}function A(e){return e}function x(e){this.r2=s(),this.q3=s(),o.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}g.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},g.prototype.revert=function(e){return e},g.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},g.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},g.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},m.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},m.prototype.revert=function(e){var t=s();return e.copyTo(t),this.reduce(t),t},m.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)},m.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},m.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]:p(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 l=a.t,h=a.data[l-1];if(0!=h){var p=h*(1<1?a.data[l-2]>>this.F2:0),d=this.FV/p,g=(1<=0&&(r.data[r.t++]=1,r.subTo(_,r)),o.ONE.dlShiftTo(l,_),_.subTo(a,a);a.t=0;){var w=r.data[--b]==h?this.DM:Math.floor(r.data[b]*d+(r.data[b-1]+m)*g);if((r.data[b]+=a.am(0,w,r,v,0,l))0&&r.rShiftTo(f,r),u<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=y(e)-1;for(i.copyTo(r);--a>=0;)if(t.sqrTo(r,n),(e&1<0)t.mulTo(n,i,r);else{var u=r;r=n,n=u}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)+y(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 g(t):new m(t),this.exp(e,r)},o.ZERO=d(0),o.ONE=d(1),E.prototype.convert=A,E.prototype.revert=A,E.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},E.prototype.sqrTo=function(e,t){e.squareTo(t)},x.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},x.prototype.revert=function(e){return e},x.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)},x.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},x.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var I=[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],T=(1<<26)/I[I.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,u=0;u=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),v,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 u=n.modPow(i,this);if(0!=u.compareTo(o.ONE)&&0!=u.compareTo(t)){for(var c=1;c++>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,b,t),t},o.prototype.or=function(e){var t=s();return this.bitwiseTo(e,v,t),t},o.prototype.xor=function(e){var t=s();return this.bitwiseTo(e,_,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 l=s();for(n.sqrTo(a[1],l);u<=f;)a[u]=s(),n.mulTo(l,a[u-2],a[u]),u+=2}var h,p,b=e.t-1,v=!0,_=s();for(i=y(e.data[b])-1;b>=0;){for(i>=c?h=e.data[b]>>i-c&f:(h=(e.data[b]&(1<0&&(h|=e.data[b-1]>>this.DB+i-c)),u=r;0==(1&h);)h>>=1,--u;if((i-=u)<0&&(i+=this.DB,--b),v)a[h].copyTo(o),v=!1;else{for(;u>1;)n.sqrTo(o,_),n.sqrTo(_,o),u-=2;u>0?n.sqrTo(o,_):(p=o,o=_,_=p),n.mulTo(_,a[h],o)}for(;b>=0&&0==(e.data[b]&1<=0?(r.subTo(n,r),t&&i.subTo(a,i),s.subTo(u,s)):(n.subTo(r,n),t&&a.subTo(i,a),u.subTo(s,u))}return 0!=n.compareTo(o.ONE)?o.ZERO:u.compareTo(e)>=0?u.subtract(e):u.signum()<0?(u.addTo(e,u),u.signum()<0?u.add(e):u):u},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]<=I[I.length-1]){for(t=0;t>>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,u=67108863&i,c=Math.max(0,o-e.length+1),f=Math.min(o,t.length-1);c<=f;c++){var l=o-c,h=e.words[l]*t.words[c]+u;a+=h/67108864|0,u=67108863&h}r.words[o]=u,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,u=1;0==(e.words[0]&u)&&0==(t.words[0]&u)&&a<26;++a,u<<=1);e.ishrn(a),t.ishrn(a)}for(var c=t.clone(),f=e.clone();!e.isZero();){for(var l=0,h=1;0==(e.words[0]&h)&&l<26;++l,h<<=1);if(l>0)for(e.ishrn(l);l-- >0;)(r.isOdd()||n.isOdd())&&(r.iadd(c),n.isub(f)),r.ishrn(1),n.ishrn(1);for(var p=0,d=1;0==(t.words[0]&d)&&p<26;++p,d<<=1);if(p>0)for(t.ishrn(p);p-- >0;)(i.isOdd()||s.isOdd())&&(i.iadd(c),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 u=0,c=1;0==(r.words[0]&c)&&u<26;++u,c<<=1);if(u>0)for(r.ishrn(u);u-- >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 u=o.words[0]&n;if(u>=i)t.push(i-u),o.iuaddn(u-i).ishrn(1);else if(t.push(u),o.words[0]-=u,!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";const n=r(10),i=r(151),o=r(1043),s=r(17),a=r(50),u=r(9),c=r(345),f=r(1044),l=r(65),h=n(r(1045)),p=r(1046);class d{constructor(e){this.full=e,this.wantlist=new Map,this.blocks=new Map}get empty(){return 0===this.blocks.size&&0===this.wantlist.size}addEntry(e,t,r){s(e&&u.isCID(e),"must be a valid cid");const n=e.buffer.toString(),i=this.wantlist.get(n);i?(i.priority=t,i.cancel=Boolean(r)):this.wantlist.set(n,new p(e,t,r))}addBlock(e){s(i.isBlock(e),"must be a valid cid");const t=e.cid.buffer.toString();this.blocks.set(t,e)}cancel(e){s(u.isCID(e),"must be a valid cid");const t=e.buffer.toString();this.wantlist.delete(t),this.addEntry(e,0,!0)}serializeToBitswap100(){const e={wantlist:{entries:Array.from(this.wantlist.values()).map(e=>({block:e.cid.buffer,priority:Number(e.priority),cancel:Boolean(e.cancel)}))},blocks:Array.from(this.blocks.values()).map(e=>e.data)};return this.full&&(e.wantlist.full=!0),h.Message.encode(e)}serializeToBitswap110(){const e={wantlist:{entries:Array.from(this.wantlist.values()).map(e=>({block:e.cid.buffer,priority:Number(e.priority),cancel:Boolean(e.cancel)}))},payload:[]};return this.full&&(e.wantlist.full=!0),this.blocks.forEach(t=>{e.payload.push({prefix:t.cid.prefix,data:t.data})}),h.Message.encode(e)}equals(e){const t=(e,t)=>{if(e.equals&&"function"==typeof e.equals)return e.equals(t)};return!(this.full!==e.full||!o(this.wantlist,e.wantlist,t)||!o(this.blocks,e.blocks,t))}get[Symbol.toStringTag](){const e=Array.from(this.wantlist.keys()),t=Array.from(this.blocks.keys());return`BitswapMessage `}}d.deserialize=((e,t)=>{let r;try{r=h.Message.decode(e)}catch(e){return setImmediate(()=>t(e))}const n=r.wantlist&&r.wantlist.full||!1,o=new d(n);return r.wantlist&&r.wantlist.entries.forEach(e=>{let r;try{r=new u(e.block)}catch(e){return t(e)}o.addEntry(r,e.priority,e.cancel)}),r.blocks.length>0?a(r.blocks,(e,r)=>{l(e,"sha2-256",(n,s)=>{if(n)return r(n);let a;try{a=new u(s)}catch(n){return t(n)}o.addBlock(new i(e,a)),r()})},e=>{if(e)return t(e);t(null,o)}):r.payload.length>0?a(r.payload,(e,r)=>{e.prefix&&e.data||r();const n=f(e.prefix),s=n[0],a=n[1],h=n[2];l(e.data,h,(n,f)=>{if(n)return r(n);let l;try{l=new u(s,c[a.toString("16")],f)}catch(n){return t(n)}o.addBlock(new i(e.data,l)),r()})},e=>{if(e)return t(e);t(null,o)}):void t(null,o)}),d.Entry=p,e.exports=d},function(e,t,r){"use strict";const n=r(1047),i=r(1048);class o{constructor(e){this.set=new Map,this._stats=e}get length(){return this.set.size}add(e,t){const r=e.buffer.toString(),n=this.set.get(r);n?(n.inc(),n.priority=t):(this.set.set(r,new i(e,t)),this._stats&&this._stats.push(null,"wantListSize",1))}remove(e){const t=e.buffer.toString(),r=this.set.get(t);r&&(r.dec(),r.hasRefs()||(this.set.delete(t),this._stats&&this._stats.push(null,"wantListSize",-1)))}removeForce(e){this.set.has(e)&&this.set.delete(e)}forEach(e){return this.set.forEach(e)}entries(){return this.set.entries()}sortedEntries(){return new Map(n(Array.from(this.set.entries()),e=>e[1].key))}contains(e){const t=e.buffer.toString();return this.set.get(t)}}o.Entry=i,e.exports=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=o(r(1055)),i=o(r(217));function o(e){return e&&e.__esModule?e:{default:e}}t.default=(0,i.default)(n.default,1),e.exports=t.default},function(e,t){t.encode=function(e){var t="";for(var r in e)e.hasOwnProperty(r)&&(t.length&&(t+="&"),t+=encodeURIComponent(r)+"="+encodeURIComponent(e[r]));return t},t.decode=function(e){for(var t={},r=e.split("&"),n=0,i=r.length;n65536?(this._debug("start backpressure: bufferedAmount %d",this._channel.bufferedAmount),this._cb=r):r(null)}else this._debug("write before connect"),this._chunk=e,this._cb=r},u.prototype._onFinish=function(){var e=this;function t(){setTimeout(function(){e.destroy()},1e3)}e.destroyed||(e.connected?t():e.once("connect",t))},u.prototype._createOffer=function(){var e=this;e.destroyed||e._pc.createOffer(function(t){function r(){var r=e._pc.localDescription||t;e._debug("signal"),e.emit("signal",{type:r.type,sdp:r.sdp})}e.destroyed||(t.sdp=e.sdpTransform(t.sdp),e._pc.setLocalDescription(t,function(){e._debug("createOffer success"),e.destroyed||(e.trickle||e._iceComplete?r():e.once("_iceComplete",r))},function(t){e.destroy(c(t,"ERR_SET_LOCAL_DESCRIPTION"))}))},function(t){e.destroy(c(t,"ERR_CREATE_OFFER"))},e.offerConstraints)},u.prototype._createAnswer=function(){var e=this;e.destroyed||e._pc.createAnswer(function(t){function r(){var r=e._pc.localDescription||t;e._debug("signal"),e.emit("signal",{type:r.type,sdp:r.sdp})}e.destroyed||(t.sdp=e.sdpTransform(t.sdp),e._pc.setLocalDescription(t,function(){e.destroyed||(e.trickle||e._iceComplete?r():e.once("_iceComplete",r))},function(t){e.destroy(c(t,"ERR_SET_LOCAL_DESCRIPTION"))}))},function(t){e.destroy(c(t,"ERR_CREATE_ANSWER"))},e.answerConstraints)},u.prototype._onIceStateChange=function(){if(!this.destroyed){var e=this._pc.iceConnectionState,t=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",e,t),this.emit("iceStateChange",e,t),"connected"!==e&&"completed"!==e||(this._pcReady=!0,this._maybeReady()),"failed"===e&&this.destroy(c("Ice connection failed.","ERR_ICE_CONNECTION_FAILURE")),"closed"===e&&this.destroy(new Error("Ice connection closed."))}},u.prototype.getStats=function(e){var t=this;0===t._pc.getStats.length?t._pc.getStats().then(function(t){var r=[];t.forEach(function(e){r.push(e)}),e(null,r)},function(t){e(t)}):t._isReactNativeWebrtc?t._pc.getStats(null,function(t){var r=[];t.forEach(function(e){r.push(e)}),e(null,r)},function(t){e(t)}):t._pc.getStats.length>0?t._pc.getStats(function(r){if(!t.destroyed){var n=[];r.result().forEach(function(e){var t={};e.names().forEach(function(r){t[r]=e.stat(r)}),t.id=e.id,t.type=e.type,t.timestamp=e.timestamp,n.push(t)}),e(null,n)}},function(t){e(t)}):e(null,[])},u.prototype._maybeReady=function(){var e=this;e._debug("maybeReady pc %s channel %s",e._pcReady,e._channelReady),!e.connected&&!e._connecting&&e._pcReady&&e._channelReady&&(e._connecting=!0,function t(){e.destroyed||e.getStats(function(r,n){if(!e.destroyed){r&&(n=[]);var i={},o={},s={},a=!1;if(n.forEach(function(e){"remotecandidate"!==e.type&&"remote-candidate"!==e.type||(i[e.id]=e),"localcandidate"!==e.type&&"local-candidate"!==e.type||(o[e.id]=e),"candidatepair"!==e.type&&"candidate-pair"!==e.type||(s[e.id]=e)}),n.forEach(function(e){"transport"===e.type&&e.selectedCandidatePairId&&f(s[e.selectedCandidatePairId]),("googCandidatePair"===e.type&&"true"===e.googActiveConnection||("candidatepair"===e.type||"candidate-pair"===e.type)&&e.selected)&&f(e)}),a||Object.keys(s).length&&!Object.keys(o).length){if(e._connecting=!1,e.connected=!0,e._chunk){try{e.send(e._chunk)}catch(r){return e.destroy(c(r,"ERR_DATA_CHANNEL"))}e._chunk=null,e._debug('sent chunk from "write before connect"');var u=e._cb;e._cb=null,u(null)}"number"!=typeof e._channel.bufferedAmountLowThreshold&&(e._interval=setInterval(function(){e._onInterval()},150),e._interval.unref&&e._interval.unref()),e._debug("connect"),e.emit("connect")}else setTimeout(t,100)}function f(t){a=!0;var r=o[t.localCandidateId];r&&r.ip?(e.localAddress=r.ip,e.localPort=Number(r.port)):r&&r.ipAddress?(e.localAddress=r.ipAddress,e.localPort=Number(r.portNumber)):"string"==typeof t.googLocalAddress&&(r=t.googLocalAddress.split(":"),e.localAddress=r[0],e.localPort=Number(r[1]));var n=i[t.remoteCandidateId];n&&n.ip?(e.remoteAddress=n.ip,e.remotePort=Number(n.port)):n&&n.ipAddress?(e.remoteAddress=n.ipAddress,e.remotePort=Number(n.portNumber)):"string"==typeof t.googRemoteAddress&&(n=t.googRemoteAddress.split(":"),e.remoteAddress=n[0],e.remotePort=Number(n[1])),e.remoteFamily="IPv4",e._debug("connect local: %s:%s remote: %s:%s",e.localAddress,e.localPort,e.remoteAddress,e.remotePort)}})}())},u.prototype._onInterval=function(){!this._cb||!this._channel||this._channel.bufferedAmount>65536||this._onChannelBufferedAmountLow()},u.prototype._onSignalingStateChange=function(){var e=this;e.destroyed||("stable"===e._pc.signalingState&&(e._isNegotiating=!1,e._debug("flushing sender queue",e._sendersAwaitingStable),e._sendersAwaitingStable.forEach(function(t){e.removeTrack(t),e._queuedNegotiation=!0}),e._sendersAwaitingStable=[],e._queuedNegotiation&&(e._debug("flushing negotiation queue"),e._queuedNegotiation=!1,e._needsNegotiation()),e._debug("negotiate"),e.emit("negotiate")),e._debug("signalingStateChange %s",e._pc.signalingState),e.emit("signalingStateChange",e._pc.signalingState))},u.prototype._onIceCandidate=function(e){this.destroyed||(e.candidate&&this.trickle?this.emit("signal",{candidate:{candidate:e.candidate.candidate,sdpMLineIndex:e.candidate.sdpMLineIndex,sdpMid:e.candidate.sdpMid}}):e.candidate||(this._iceComplete=!0,this.emit("_iceComplete")))},u.prototype._onChannelMessage=function(e){if(!this.destroyed){var r=e.data;r instanceof ArrayBuffer&&(r=t.from(r)),this.push(r)}},u.prototype._onChannelBufferedAmountLow=function(){if(!this.destroyed&&this._cb){this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);var e=this._cb;this._cb=null,e(null)}},u.prototype._onChannelOpen=function(){this.connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())},u.prototype._onChannelClose=function(){this.destroyed||(this._debug("on channel close"),this.destroy())},u.prototype._onTrack=function(e){var t=this;t.destroyed||e.streams.forEach(function(r){t._debug("on track"),t.emit("track",e.track,r),t._remoteTracks.push({track:e.track,stream:r}),t._remoteStreams.some(function(e){return e.id===r.id})||(t._remoteStreams.push(r),setTimeout(function(){t.emit("stream",r)},0))})},u.prototype._debug=function(){var e=[].slice.call(arguments);e[0]="["+this._id+"] "+e[0],n.apply(null,e)},u.prototype._transformConstraints=function(e){if(0===Object.keys(e).length)return e;if((e.mandatory||e.optional)&&!this._isChromium){var t=Object.assign({},e.optional,e.mandatory);return void 0!==t.OfferToReceiveVideo&&(t.offerToReceiveVideo=t.OfferToReceiveVideo,delete t.OfferToReceiveVideo),void 0!==t.OfferToReceiveAudio&&(t.offerToReceiveAudio=t.OfferToReceiveAudio,delete t.OfferToReceiveAudio),t}return e.mandatory||e.optional||!this._isChromium?e:(void 0!==e.offerToReceiveVideo&&(e.OfferToReceiveVideo=e.offerToReceiveVideo,delete e.offerToReceiveVideo),void 0!==e.offerToReceiveAudio&&(e.OfferToReceiveAudio=e.offerToReceiveAudio,delete e.offerToReceiveAudio),{mandatory:e})}}).call(this,r(0).Buffer)},function(e,t,r){(function(n){r(70);var i=r(531);function o(e,t){function r(){i(),t()}function n(e){i(),t(e)}function i(){e.removeListener("close",r),e.removeListener("error",n)}e.on("close",r),e.on("error",n)}function o(e){e.destroy?e.destroy():console.error("warning, stream-to-pull-stream: \nthe wrapped node-stream does not implement `destroy`, \nthis may cause resource leaks.")}function s(e,t,r){var s,a,u=!1;function c(){a||(a=!0,r&&r(!0===s?null:s))}function f(){u||(u=!0,h(),s?c():e(s=!0,c))}function l(t){h(),s||e(s=t,c)}function h(){t.on("finish",f),t.removeListener("close",f),t.removeListener("error",l)}t.on("close",f),t.on("finish",f),t.on("error",l),n.nextTick(function(){i(function(r){e(null,function(e,n){return s=s||e,!0===e?t._isStdio?c():t.end():(s=s||e)?(o(t),c()):void(t._isStdio?t.write(n,function(){r()}):!1===t.write(n)?t.once("drain",r):r())})})})}function a(e){var t,r=[],n=[],i=!1;function s(){for(;(r.length||t)&&n.length;)n.shift()(r.length?null:t,r.shift());!r.length&&i&&(i=!1,e.resume())}return e.on("data",function(t){r.push(t),s(),r.length&&e.pause&&(i=!0,e.pause())}),e.on("end",function(){t=!0,s()}),e.on("close",function(){t=!0,s()}),e.on("error",function(e){t=e,s()}),function(r,i){if(!i)throw new Error("*must* provide cb");if(r){function a(){for(;n.length;)n.shift()(r);i(r)}if(t)return a();e.once("close",a),o(e)}else n.push(i),s()}}var u=a,c=function(e,t){return function(r){return s(r,e,t)}},f=function(e){return a(e)};(t=e.exports=function(e,t){return e.writable&&e.write?e.readable?function(r){return s(r,e,t),a(e)}:c(e,t):f(e)}).sink=c,t.source=f,t.read=u,t.read1=a,t.read2=function(e){var t,r=!1,n=!1;function i(){var r=e.read();if(null!==r&&t){var n=t;t=null,n(null,r)}}return e.on("readable",function(){n=!0,t&&i()}).on("end",function(){r=!0,t&&t(r)}).on("error",function(e){r=e,t&&t(r)}),function(e,o){t=o,r?o(r):n&&i()}},t.duplex=function(e,t){return{source:f(e),sink:c(e,t)}},t.transform=function(e){return function(t){var r=f(e);return c(e)(t),r}}}).call(this,r(7))},function(e,t,r){var n=r(30),i=function(){},o=function(e,t,r){if("function"==typeof t)return o(e,null,t);t||(t={}),r=n(r||i);var s=e._writableState,a=e._readableState,u=t.readable||!1!==t.readable&&e.readable,c=t.writable||!1!==t.writable&&e.writable,f=function(){e.writable||l()},l=function(){c=!1,u||r.call(e)},h=function(){u=!1,c||r.call(e)},p=function(t){r.call(e,t?new Error("exited with error code: "+t):null)},d=function(t){r.call(e,t)},y=function(){return(!u||a&&a.ended)&&(!c||s&&s.ended)?void 0:r.call(e,new Error("premature close"))},g=function(){e.req.on("finish",l)};return function(e){return e.setHeader&&"function"==typeof e.abort}(e)?(e.on("complete",l),e.on("abort",y),e.req?g():e.on("request",g)):c&&!s&&(e.on("end",f),e.on("close",f)),function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length}(e)&&e.on("exit",p),e.on("end",h),e.on("finish",l),!1!==t.error&&e.on("error",d),e.on("close",y),function(){e.removeListener("complete",l),e.removeListener("abort",y),e.removeListener("request",g),e.req&&e.req.removeListener("finish",l),e.removeListener("end",f),e.removeListener("close",f),e.removeListener("finish",l),e.removeListener("exit",p),e.removeListener("end",h),e.removeListener("error",d),e.removeListener("close",y)}};e.exports=o},function(e,t,r){"use strict";e.exports=function(){var e,t;return{source:function(r,n){e?e(r,n):t=[r,n]},sink:function(r){if("function"!=typeof r)throw new Error("read must be function");if(e)throw new Error("already piped");if(e=r,t){var n=t;t=null,e.apply(null,n)}}}}},function(e,t,r){"use strict";(function(n){const i=r(8),o=r(53),s=r(1);function a(e){const t=(~~(1e9*Math.random())).toString(36);function r(e){return r=>{Array.isArray(r)&&(r=r.join(" ")),e("(%s) %s",t,r)}}const n=r(s("mss:"+e));return n.error=r(s("mss:"+e+":error")),n}(t=e.exports).writeEncoded=((e,t,r)=>{!function(e,t){const r=n.isBuffer(e)?[e]:[n.from(e)];i(i.values(r),o.encode(),i.collect((e,r)=>{if(e)return t(e);t(null,r[0])}))}(t,(t,n)=>{if(t)return r(t);e.write(n)})}),t.log={},t.log.dialer=(()=>a("dialer\t")),t.log.listener=(()=>a("listener\t"))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(n){const i=r(12),o=r(1243),s=r(17),a=r(4);class u{constructor(e,t,r){s(n.isBuffer(e),"invalid id provided"),t&&r&&s(t.public.bytes.equals(r.bytes),"inconsistent arguments"),this._id=e,this._idB58String=i.toB58String(this.id),this._privKey=t,this._pubKey=r}get id(){return this._id}set id(e){throw new Error("Id is immutable")}get privKey(){return this._privKey}set privKey(e){this._privKey=e}get pubKey(){return this._pubKey?this._pubKey:this._privKey?this._privKey.public:void 0}set pubKey(e){this._pubKey=e}marshalPubKey(){if(this.pubKey)return o.keys.marshalPublicKey(this.pubKey)}marshalPrivKey(){if(this.privKey)return o.keys.marshalPrivateKey(this.privKey)}toPrint(){return this.toJSON()}toJSON(){return{id:this.toB58String(),privKey:c(this.marshalPrivKey()),pubKey:c(this.marshalPubKey())}}toHexString(){return i.toHexString(this.id)}toBytes(){return this.id}toB58String(){return this._idB58String}isEqual(e){if(n.isBuffer(e))return this.id.equals(e);if(e.id)return this.id.equals(e.id);throw new Error("not valid Id")}isValid(e){this.privKey&&this.privKey.public&&this.privKey.public.bytes&&n.isBuffer(this.pubKey.bytes)&&this.privKey.public.bytes.equals(this.pubKey.bytes)?e():e(new Error("Keys not match"))}}function c(e){if(e)return e.toString("base64")}(t=e.exports=u).create=function(e,t){"function"==typeof e&&(t=e,e={}),(e=e||{}).bits=e.bits||2048,a([t=>o.keys.generateKeyPair("RSA",e.bits,t),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n))})},t.createFromHexString=function(e){return new u(i.fromHexString(e))},t.createFromBytes=function(e){return new u(e)},t.createFromB58String=function(e){return new u(i.fromB58String(e))},t.createFromPubKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r;try{let i=e;if("string"==typeof i&&(i=n.from(e,"base64")),!n.isBuffer(i))throw new Error("Supplied key is neither a base64 string nor a buffer");r=o.keys.unmarshalPublicKey(i)}catch(e){return t(e)}r.hash((e,n)=>{if(e)return t(e);t(null,new u(n,null,r))})},t.createFromPrivKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r=e;try{if("string"==typeof r&&(r=n.from(e,"base64")),!n.isBuffer(r))throw new Error("Supplied key is neither a base64 string nor a buffer")}catch(e){return t(e)}a([e=>o.keys.unmarshalPrivateKey(r,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n,n.public))})},t.createFromJSON=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r,s,c,f;try{r=i.fromB58String(e.id),s=e.privKey&&n.from(e.privKey,"base64"),c=e.pubKey&&n.from(e.pubKey,"base64"),f=c&&o.keys.unmarshalPublicKey(c)}catch(e){return t(e)}s?a([e=>o.keys.unmarshalPrivateKey(s,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)}),(e,t,r)=>{f?f.hash((n,i)=>{r(n,e,t,i)}):r(null,e,t)}],(e,n,i,o)=>e?t(e):f&&!n.equals(o)?t(new Error("Public and private key do not match")):r&&!n.equals(r)?t(new Error("Id and private key do not match")):void t(null,new u(r,i,f))):t(null,new u(r,null,f))},t.isPeerId=function(e){return Boolean("object"==typeof e&&e._id&&e._idB58String)}}).call(this,r(0).Buffer)},function(e,t,r){var n=r(312)(Object,"create");e.exports=n},function(e,t,r){var n=r(313);e.exports=function(e,t){for(var r=e.length;r--;)if(n(e[r][0],t))return r;return-1}},function(e,t,r){var n=r(1336);e.exports=function(e,t){var r=e.__data__;return n(t)?r["string"==typeof t?"string":"hash"]:r.map}},function(e,t,r){"use strict";const n=r(23),i=r(80),o=r(489),s=r(9);t.OFFLINE_ERROR="This command must be run in online mode. Try running 'ipfs daemon' first.";const a=n(function(e,r,n){Array.isArray(r)||(r=[r]),i(r,(r,n)=>{if("string"!=typeof r){let e;try{e=new s(r)}catch(e){return n(e)}return n(null,e.buffer)}let i;try{i=t.parseIpfsPath(r)}catch(e){return n(e)}const o=new s(i.hash),a=i.links;if(!a.length)return n(null,o.buffer);e.get(o,function t(r,i,o){if(i)return n(i);if(!r.length)return n(null,o.multihash);const s=r[0],a=o.links.find(e=>e.name===s);if(!a)return n(new Error(`no link named "${s}" under ${o.toJSON().multihash}`));e.get(a.multihash,t.bind(null,r.slice(1)))}.bind(null,a))},n)});t.parseIpfsPath=function(e){const t=new Error("invalid ipfs ref path"),r=(e=e.replace(/^\/ipfs\//,"")).match(/([^/]+(?:\/[^/]+)*)\/?$/);if(!r)throw t;const[n,...i]=r[1].split("/");if(o.cid(n))return{hash:n,links:i};throw t},t.resolvePath=a},function(e,t,r){var n=r(1390);function i(e,t){return(e=e||[]).push(t),e}e.exports=function(e,t,r,o){var s,a;function u(i){var c=null,f=!1,l=0;if(i,s)return i(!!s.abort||s,function(e){o(e),a&&a()});var h=!1,p=n(function(){h||s||(h=!0,i(null,function(e,n){h=!1,function(e,n){s||((s=e)?f||o(!0===s?null:s):(c=t(c,n),l=c&&c.length||0,null!=c&&d(),l0;)i=s.nextValue(),e=Math.floor(i*t.length),r.push(t.splice(e,1)[0]);return r.join("")}())}e.exports={get:function(){return n||a},characters:function(e){return c(e),n},seed:function(e){s.seed(e),i!==e&&(u(),i=e)},lookup:function(e){return f()[e]},shuffled:f}},function(e,t,r){var n=e.exports;n.encode=r(1512),n.decode=r(1513),n.byteLength=n.encodingLength=function(e){return n.encode(e).length}},function(e,t,r){"use strict";e.exports=function(e,t,r){return 0===e.length?e:t?(r||e.sort(t),function(e,t){for(var r=1,n=e.length,i=e[0],o=e[0],s=1;s>3;return e%8!=0&&t++,t}n.prototype.get=function(e){var t=e>>3;return t>e%8)},n.prototype.set=function(e,t){var r=e>>3;t||1===arguments.length?(this.buffer.length>e%8):r>e%8))},n.prototype._grow=function(e){if(this.buffer.length4294967295&&(o=1),t.writeUInt32BE(o,r),t.write(e.type,r+4,4,"ascii");var c=r+8;if(1===o&&(n.encode(e.length,t,c),c+=8),s.fullBoxes[i]&&(t.writeUInt32BE(e.flags||0,c),t.writeUInt8(e.version||0,c),c+=4),u[i])u[i].forEach(function(r){if(5===r.length){var n=e[r]||[];r=r.substr(0,4),n.forEach(function(e){a._encode(e,t,c),c+=a.encode.bytes})}else e[r]&&(a._encode(e[r],t,c),c+=a.encode.bytes)}),e.otherBoxes&&e.otherBoxes.forEach(function(e){a._encode(e,t,c),c+=a.encode.bytes});else if(s[i]){var f=s[i].encode;f(e,t,c),c+=f.bytes}else{if(!e.buffer)throw new Error("Either `type` must be set to a known type (not'"+i+"') or `buffer` must be set");e.buffer.copy(t,c),c+=e.buffer.length}return a.encode.bytes=c-r,t},a.readHeaders=function(e,t,r){if(t=t||0,(r=r||e.length)-t<8)return 8;var i,o,a=e.readUInt32BE(t),u=e.toString("ascii",t+4,t+8),c=t+8;if(1===a){if(r-t<16)return 16;a=n.decode(e,c),c+=8}return s.fullBoxes[u]&&(i=e.readUInt8(c),o=16777215&e.readUInt32BE(c),c+=4),{length:a,headersLen:c-t,contentLen:a-(c-t),type:u,version:i,flags:o}},a.decode=function(e,t,r){t=t||0,r=r||e.length;var n=a.readHeaders(e,t,r);if(!n||n.length>r-t)throw new Error("Data too short");return a.decodeWithoutHeaders(n,e,t+n.headersLen,t+n.length)},a.decodeWithoutHeaders=function(e,t,r,n){r=r||0,n=n||t.length;var i=e.type,c={};if(u[i]){c.otherBoxes=[];for(var f=u[i],l=r;n-l>=8;){var h=a.decode(t,l,n);if(l+=h.length,f.indexOf(h.type)>=0)c[h.type]=h;else if(f.indexOf(h.type+"s")>=0){var p=h.type+"s";(c[p]=c[p]||[]).push(h)}else c.otherBoxes.push(h)}}else if(s[i]){c=(0,s[i].decode)(t,r,n)}else c.buffer=o(t.slice(r,n));return c.length=e.length,c.contentLen=e.contentLen,c.type=e.type,c.version=e.version,c.flags=e.flags,c},a.encodingLength=function(e){var t=e.type,r=8;if(s.fullBoxes[t]&&(r+=4),u[t])u[t].forEach(function(t){if(5===t.length){var n=e[t]||[];t=t.substr(0,4),n.forEach(function(e){e.type=t,r+=a.encodingLength(e)})}else if(e[t]){var i=e[t];i.type=t,r+=a.encodingLength(i)}}),e.otherBoxes&&e.otherBoxes.forEach(function(e){r+=a.encodingLength(e)});else if(s[t])r+=s[t].encodingLength(e);else{if(!e.buffer)throw new Error("Either `type` must be set to a known type (not'"+t+"') or `buffer` must be set");r+=e.buffer.length}return r>4294967295&&(r+=8),e.length=r,r}},function(e,t,r){(function(t){var n=r(1571),i=r(1572);e.exports=function(e,r,o){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative');if(t.alloc)return t.alloc(e,r,o);var s=i(e);return 0===e?s:void 0===r?n(s,0):("string"!=typeof o&&(o=void 0),n(s,r,o))}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";t.decode=t.parse=r(634),t.encode=t.stringify=r(635)},function(e,t,r){"use strict";(function(t,n){var i=r(150);function o(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,r){var n=e.entry;for(e.entry=null;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 s,a=!t.browser&&["v0.10","v0.9."].indexOf(t.version.slice(0,5))>-1?setImmediate:i.nextTick;m.WritableState=g;var u=r(117);u.inherits=r(5);var c={deprecate:r(641)},f=r(334),l=r(2).Buffer,h=n.Uint8Array||function(){};var p,d=r(336);function y(){}function g(e,t){s=s||r(85),e=e||{};var n=t instanceof s;this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,a=e.writableHighWaterMark,u=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(a||0===a)?a:u,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 c=!1===e.decodeStrings;this.decodeStrings=!c,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){k(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 o(this)}function m(e){if(s=s||r(85),!(p.call(m,this)||this instanceof s))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)),f.call(this)}function b(e,t){var r=new Error("write after end");e.emit("error",r),i.nextTick(t,r)}function v(e,t,r,n){var o=!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),i.nextTick(n,s),o=!1),o}function _(e,t,r,n,i,o){if(!r){var s=function(e,t,r){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=l.from(t,r)),t}(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var u=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&&void 0!==e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,T(e,t),r&&(t.finished?i.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=d.destroy,m.prototype._undestroy=d.undestroy,m.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,r(7),r(6))},function(e,t,r){"use strict";var n=r(2).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=u,this.end=c,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=f,this.end=l,t=3;break;default:return this.write=h,void(this.end=p)}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 u(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 c(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 l(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function h(e){return e.toString(this.encoding)}function p(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?(i>0&&(e.lastNeed=i-1),i):--n=0?(i>0&&(e.lastNeed=i-2),i):--n=0?(i>0&&(2===i?i=0:e.lastNeed=i-3),i):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){"use strict";var n=r(118);e.exports=function(e,t,r){r||(r=t,t=null);var i=n(function(r){t=e(t,r)},function(e){r(e,t)});return 2===arguments.length?function(e){e(null,function(n,o){if(n)return r(!0===n?null:n);t=o,i(e)})}:i}},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.hasNextTick=t.hasSetImmediate=void 0,t.fallback=a,t.wrap=u;var n=function(e){return e&&e.__esModule?e:{default:e}}(r(102));var i,o=t.hasSetImmediate="function"==typeof setImmediate&&setImmediate,s=t.hasNextTick="object"==typeof e&&"function"==typeof e.nextTick;function a(e){setTimeout(e,0)}function u(e){return function(t){var r=(0,n.default)(arguments,1);e(function(){t.apply(null,r)})}}i=o?setImmediate:s?e.nextTick:a,t.default=u(i)}).call(this,r(7))},function(e,t,r){var n=r(157),i=r(121),o="[object AsyncFunction]",s="[object Function]",a="[object GeneratorFunction]",u="[object Proxy]";e.exports=function(e){if(!i(e))return!1;var t=n(e);return t==s||t==a||t==o||t==u}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=o(r(357)),i=o(r(217));function o(e){return e&&e.__esModule?e:{default:e}}t.default=(0,i.default)(n.default,1),e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={},e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){return function(r,n,i){return e(r,t,n,i)}},e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){((0,n.default)(e)?function(e,t,r){r=(0,u.default)(r||a.default);var n=0,o=0,s=e.length;function f(e,t){e?r(e):++o!==s&&t!==i.default||r(null)}for(0===s&&r(null);n100)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var a=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return a*s;case"days":case"day":case"d":return a*o;case"hours":case"hour":case"hrs":case"hr":case"h":return a*i;case"minutes":case"minute":case"mins":case"min":case"m":return a*n;case"seconds":case"second":case"secs":case"sec":case"s":return a*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}function u(e){return e>=o?Math.round(e/o)+"d":e>=i?Math.round(e/i)+"h":e>=n?Math.round(e/n)+"m":e>=r?Math.round(e/r)+"s":e+"ms"}function c(e){return f(e,o,"day")||f(e,i,"hour")||f(e,n,"minute")||f(e,r,"second")||e+" ms"}function f(e,t,r){if(!(e0)return a(e);if("number"===r&&!1===isNaN(e))return t.long?c(e):u(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,r){var n=r(366),i=r(367);e.exports=function(e,t,r){var o=t&&r||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var s=(e=e||{}).random||(e.rng||n)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t)for(var a=0;a<16;++a)t[o+a]=s[a];return t||i(s)}},function(e,t,r){"use strict";const n=r(8),i=r(161),o=r(64),s=r(368),a=r(220);t.asyncFilter=function(e){let t,r,n=!1;return function(i){return function o(s,a){if(r)return a(r);s?(r=s,i(s,n?()=>{n?t=a:a(s)}:a)):i(null,(i,s)=>{i?a(i):r?a(r):(n=!0,e(s,(e,i)=>{n=!1,r?(a(r),t(r)):e?o(e,a):i?a(null,s):o(null,a)}))})}}},t.asyncSort=function(e){const t=i(),r=n.collect((r,i)=>{if(r)return t.abort(r);e(i,(e,r)=>{if(e)return t.abort(e);t.resolve(n.values(i))})});return function(e){return r(e),t}},t.replaceStartWith=function(e,t){const r=new RegExp("^"+t);return e.replace(r,"")},t.tmpdir=(()=>o.join(s.tmpdir(),a()))},function(e,t){e.exports=function(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++ra.isDAGLink(e)?e:a.util.createDagLinkFromB58EncodedHash(e)));try{r=o.PBNode.encode(function(e){const t={};return e.data&&e.data.length>0?t.Data=e.data:t.Data=null,e.links&&e.links.length>0?t.Links=e.links.map(e=>({Hash:e.multihash,Name:e.name,Tsize:e.size})):t.Links=null,t}(e))}catch(e){return t(e)}t(null,r)}(t=e.exports).serialize=l,t.deserialize=function(e,t){const r=o.PBNode.decode(e),i=r.Links.map(e=>new a(e.Name,e.Tsize,e.Hash)),s=null==r.Data?n.alloc(0):n.from(r.Data);u.create(s,i,t)},t.cid=function(e,t,r){"function"==typeof t&&(r=t,t={});const n=(t=t||{}).hashAlg||s.defaultHashAlg;let o=t.version;void 0===o&&(o="sha2-256"===n?0:1),f([t=>l(e,t),(e,t)=>c(e,n,t),(e,t)=>t(null,new i(o,s.multicodec,e))],r)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";t.defined=function(e){return null!==e&&void 0!==e&&("number"!=typeof e||!isNaN(e))}},function(e,t,r){"use strict";(function(e){const n=r(169),i=r(170),o=i.SHIFT32,s=i.SHIFT16;function a(e){return e<16?"0"+e.toString(16):e.toString(16)}t.parseHalf=function(e){var t,r,n;return n=128&e[0]?-1:1,t=(124&e[0])>>2,r=(3&e[0])<<8|e[1],t?31===t?n*(r?NaN:1/0):n*Math.pow(2,t-25)*(1024+r):5.960464477539063e-8*n*r},t.arrayBufferToBignumber=function(e){const t=e.byteLength;let r="";for(let n=0;n{const t=new Map,r=Object.keys(e),n=r.length;for(let i=0;ie*s+t),t.buildInt64=((e,r,i,s)=>{const a=t.buildInt32(e,r),u=t.buildInt32(i,s);return a>2097151?new n(a).times(o).plus(u):a*o+u}),t.writeHalf=function(t,r){const n=e.allocUnsafe(4);n.writeFloatBE(r,0);const i=n.readUInt32BE(0);if(0!=(8191&i))return!1;var o=i>>16&32768;const s=i>>23&255,a=8388607&i;if(s>=113&&s<=142)o+=(s-112<<10)+(a>>13);else{if(!(s>=103&&s<113))return!1;if(a&(1<<126-s)-1)return!1;o+=a+8388608>>126-s}return t.writeUInt16BE(o,0),!0},t.keySorter=function(e,t){var r=e[0].byteLength,n=t[0].byteLength;return r>n?1:n>r?-1:e[0].compare(t[0])},t.isNegativeZero=(e=>0===e&&1/e<0),t.nextPowerOf2=(e=>{let t=0;if(e&&!(e&e-1))return e;for(;0!==e;)e>>=1,t+=1;return 1<{switch(t){case"version":return e.version;case"timestamp":return e.timestamp;case"difficulty":return e.bits;case"nonce":return e.nonce;case"parent":return{"/":n.hashToCid(e.prevHash)};case"tx":return{"/":n.hashToCid(e.merkleRoot)};default:return null}};e.exports={multicodec:"bitcoin-block",defaultHashAlg:"dbl-sha2-256",resolve:(e,t,r)=>{"function"==typeof t&&(r=t,t=void 0),n.deserialize(e,(e,n)=>{if(e)return r(e);if(!t)return r(null,{value:n,remainderPath:""});const o=t.split("/"),s=i(n,o[0]);if(null===s)return r(new Error("No such path"),null);let a=o.slice(1).join("/");return void 0!==s["/"]?r(null,{value:s,remainderPath:a}):a.length>0?r(new Error("No such path"),null):r(null,{value:s,remainderPath:""})})},tree:(e,t,r)=>{"function"==typeof t&&(r=t,t=void 0),t=t||{},n.deserialize(e,(e,n)=>{if(e)return r(e);const o=["version","timestamp","difficulty","nonce","parent","tx"];if(!0===t.values){const e={};for(let t of o)e[t]=i(n,t);return r(null,e)}return r(null,o)})}}},function(e,t,r){var n=r(2).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){var r={Array:function(e){return null!==e&&void 0!==e&&e.constructor===Array},Boolean:function(e){return"boolean"==typeof e},Function:function(e){return"function"==typeof e},Nil:function(e){return void 0===e||null===e},Number:function(e){return"number"==typeof e},Object:function(e){return"object"==typeof e},String:function(e){return"string"==typeof e},"":function(){return!0}};for(var n in r.Null=r.Nil,r)r[n].toJSON=function(e){return e}.bind(null,n);e.exports=r},function(e,t,r){var n=r(28).decompile,i=r(233),o=r(786),s=r(234),a=r(235),u=r(791),c=r(794),f=r(796),l=r(798),h={MULTISIG:"multisig",NONSTANDARD:"nonstandard",NULLDATA:"nulldata",P2PK:"pubkey",P2PKH:"pubkeyhash",P2SH:"scripthash",P2WPKH:"witnesspubkeyhash",P2WSH:"witnessscripthash",WITNESS_COMMITMENT:"witnesscommitment"};e.exports={classifyInput:function(e,t){var r=n(e);return a.input.check(r)?h.P2PKH:u.input.check(r,t)?h.P2SH:i.input.check(r,t)?h.MULTISIG:s.input.check(r)?h.P2PK:h.NONSTANDARD},classifyOutput:function(e){if(c.output.check(e))return h.P2WPKH;if(f.output.check(e))return h.P2WSH;if(a.output.check(e))return h.P2PKH;if(u.output.check(e))return h.P2SH;var t=n(e);return i.output.check(t)?h.MULTISIG:s.output.check(t)?h.P2PK:l.output.check(t)?h.WITNESS_COMMITMENT:o.output.check(t)?h.NULLDATA:h.NONSTANDARD},classifyWitness:function(e,t){var r=n(e);return c.input.check(r)?h.P2WPKH:f.input.check(r,t)?h.P2WSH:h.NONSTANDARD},multisig:i,nullData:o,pubKey:s,pubKeyHash:a,scriptHash:u,witnessPubKeyHash:c,witnessScriptHash:f,witnessCommitment:l,types:h}},function(e,t,r){e.exports={input:r(785),output:r(404)}},function(e,t,r){e.exports={input:r(787),output:r(788)}},function(e,t,r){e.exports={input:r(789),output:r(790)}},function(e,t,r){"use strict";var n=r(2).Buffer,i=9007199254740991;function o(e){if(e<0||e>i||e%1!=0)throw new RangeError("value out of range")}function s(e){return o(e),e<253?1:e<=65535?3:e<=4294967295?5:9}e.exports={encode:function e(t,r,i){if(o(t),r||(r=n.allocUnsafe(s(t))),!n.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return i||(i=0),t<253?(r.writeUInt8(t,i),e.bytes=1):t<=65535?(r.writeUInt8(253,i),r.writeUInt16LE(t,i+1),e.bytes=3):t<=4294967295?(r.writeUInt8(254,i),r.writeUInt32LE(t,i+1),e.bytes=5):(r.writeUInt8(255,i),r.writeUInt32LE(t>>>0,i+1),r.writeUInt32LE(t/4294967296|0,i+5),e.bytes=9),r},decode:function e(t,r){if(!n.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");r||(r=0);var i=t.readUInt8(r);if(i<253)return e.bytes=1,i;if(253===i)return e.bytes=3,t.readUInt16LE(r+1);if(254===i)return e.bytes=5,t.readUInt32LE(r+1);e.bytes=9;var s=t.readUInt32LE(r+1),a=4294967296*t.readUInt32LE(r+5)+s;return o(a),a},encodingLength:s}},function(e,t,r){"use strict";(function(t){var n=r(5),i=r(408),o=new Array(16);function s(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function a(e,t){return e<>>32-t}function u(e,t,r,n,i,o,s){return a(e+(t&r|~t&n)+i+o|0,s)+t|0}function c(e,t,r,n,i,o,s){return a(e+(t&n|r&~n)+i+o|0,s)+t|0}function f(e,t,r,n,i,o,s){return a(e+(t^r^n)+i+o|0,s)+t|0}function l(e,t,r,n,i,o,s){return a(e+(r^(t|~n))+i+o|0,s)+t|0}n(s,i),s.prototype._update=function(){for(var e=o,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,i=this._c,s=this._d;n=l(n=l(n=l(n=l(n=f(n=f(n=f(n=f(n=c(n=c(n=c(n=c(n=u(n=u(n=u(n=u(n,i=u(i,s=u(s,r=u(r,n,i,s,e[0],3614090360,7),n,i,e[1],3905402710,12),r,n,e[2],606105819,17),s,r,e[3],3250441966,22),i=u(i,s=u(s,r=u(r,n,i,s,e[4],4118548399,7),n,i,e[5],1200080426,12),r,n,e[6],2821735955,17),s,r,e[7],4249261313,22),i=u(i,s=u(s,r=u(r,n,i,s,e[8],1770035416,7),n,i,e[9],2336552879,12),r,n,e[10],4294925233,17),s,r,e[11],2304563134,22),i=u(i,s=u(s,r=u(r,n,i,s,e[12],1804603682,7),n,i,e[13],4254626195,12),r,n,e[14],2792965006,17),s,r,e[15],1236535329,22),i=c(i,s=c(s,r=c(r,n,i,s,e[1],4129170786,5),n,i,e[6],3225465664,9),r,n,e[11],643717713,14),s,r,e[0],3921069994,20),i=c(i,s=c(s,r=c(r,n,i,s,e[5],3593408605,5),n,i,e[10],38016083,9),r,n,e[15],3634488961,14),s,r,e[4],3889429448,20),i=c(i,s=c(s,r=c(r,n,i,s,e[9],568446438,5),n,i,e[14],3275163606,9),r,n,e[3],4107603335,14),s,r,e[8],1163531501,20),i=c(i,s=c(s,r=c(r,n,i,s,e[13],2850285829,5),n,i,e[2],4243563512,9),r,n,e[7],1735328473,14),s,r,e[12],2368359562,20),i=f(i,s=f(s,r=f(r,n,i,s,e[5],4294588738,4),n,i,e[8],2272392833,11),r,n,e[11],1839030562,16),s,r,e[14],4259657740,23),i=f(i,s=f(s,r=f(r,n,i,s,e[1],2763975236,4),n,i,e[4],1272893353,11),r,n,e[7],4139469664,16),s,r,e[10],3200236656,23),i=f(i,s=f(s,r=f(r,n,i,s,e[13],681279174,4),n,i,e[0],3936430074,11),r,n,e[3],3572445317,16),s,r,e[6],76029189,23),i=f(i,s=f(s,r=f(r,n,i,s,e[9],3654602809,4),n,i,e[12],3873151461,11),r,n,e[15],530742520,16),s,r,e[2],3299628645,23),i=l(i,s=l(s,r=l(r,n,i,s,e[0],4096336452,6),n,i,e[7],1126891415,10),r,n,e[14],2878612391,15),s,r,e[5],4237533241,21),i=l(i,s=l(s,r=l(r,n,i,s,e[12],1700485571,6),n,i,e[3],2399980690,10),r,n,e[10],4293915773,15),s,r,e[1],2240044497,21),i=l(i,s=l(s,r=l(r,n,i,s,e[8],1873313359,6),n,i,e[15],4264355552,10),r,n,e[6],2734768916,15),s,r,e[13],1309151649,21),i=l(i,s=l(s,r=l(r,n,i,s,e[4],4149444226,6),n,i,e[11],3174756917,10),r,n,e[2],718787259,15),s,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+s|0},s.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=new t(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=s}).call(this,r(0).Buffer)},function(e,t,r){var n=r(2).Buffer,i=r(105),o=r(28),s=r(407),a=r(42),u=r(25),c=r(31),f=r(236);function l(e){var t=e.length;return f.encodingLength(t)+t}function h(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}h.DEFAULT_SEQUENCE=4294967295,h.SIGHASH_ALL=1,h.SIGHASH_NONE=2,h.SIGHASH_SINGLE=3,h.SIGHASH_ANYONECANPAY=128,h.ADVANCED_TRANSACTION_MARKER=0,h.ADVANCED_TRANSACTION_FLAG=1;var p=n.allocUnsafe(0),d=[],y=n.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),g=n.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),m=n.from("ffffffffffffffff","hex"),b={script:p,valueBuffer:m};h.fromBuffer=function(e,t){var r=0;function n(t){return r+=t,e.slice(r-t,r)}function i(){var t=e.readUInt32LE(r);return r+=4,t}function o(){var t=s.readUInt64LE(e,r);return r+=8,t}function a(){var t=f.decode(e,r);return r+=f.decode.bytes,t}function u(){return n(a())}function c(){for(var e=a(),t=[],r=0;r=this.ins.length)return g;var s=o.compile(o.decompile(t).filter(function(e){return e!==a.OP_CODESEPARATOR})),f=this.clone();if((31&r)===h.SIGHASH_NONE)f.outs=[],f.ins.forEach(function(t,r){r!==e&&(t.sequence=0)});else if((31&r)===h.SIGHASH_SINGLE){if(e>=this.outs.length)return g;f.outs.length=e+1;for(var l=0;l=0)throw new Error("Private key must be less than the curve order");if(t)throw new TypeError("Unexpected publicKey parameter");this.d=e}else a(u.ECPoint,t),this.__Q=t;this.compressed=void 0===r.compressed||r.compressed,this.network=r.network||f.bitcoin}Object.defineProperty(d.prototype,"Q",{get:function(){return!this.__Q&&this.d&&(this.__Q=p.G.multiply(this.d)),this.__Q}}),d.fromPublicKeyBuffer=function(e,t){var r=h.Point.decodeFrom(p,e);return new d(null,r,{compressed:r.compressed,network:t})},d.fromWIF=function(e,t){var r=c.decode(e),n=r.version;if(u.Array(t)){if(!(t=t.filter(function(e){return n===e.wif}).pop()))throw new Error("Unknown network version")}else if(t=t||f.bitcoin,n!==t.wif)throw new Error("Invalid network version");return new d(l.fromBuffer(r.privateKey),null,{compressed:r.compressed,network:t})},d.makeRandom=function(e){var t,r=(e=e||{}).rng||s;do{var n=r(32);a(u.Buffer256bit,n),t=l.fromBuffer(n)}while(t.signum()<=0||t.compareTo(p.n)>=0);return new d(t,null,e)},d.prototype.getAddress=function(){return n.toBase58Check(i.hash160(this.getPublicKeyBuffer()),this.getNetwork().pubKeyHash)},d.prototype.getNetwork=function(){return this.network},d.prototype.getPublicKeyBuffer=function(){return this.Q.getEncoded(this.compressed)},d.prototype.sign=function(e){if(!this.d)throw new Error("Missing private key");return o.sign(e,this.d)},d.prototype.toWIF=function(){if(!this.d)throw new Error("Missing private key");return c.encode(this.network.wif,this.d.toBuffer(32),this.compressed)},d.prototype.verify=function(e,t){return o.verify(e,t,this.Q)},e.exports=d},function(e,t,r){var n=r(2).Buffer,i=r(806),o=r(241),s=r(28),a=r(232),u=r(124),c=r(25),f=r(31);function l(e){var t=o.decode(e);if(t.length<21)throw new TypeError(e+" is too short");if(t.length>21)throw new TypeError(e+" is too long");return{version:t.readUInt8(0),hash:t.slice(1)}}function h(e){var t=i.decode(e),r=i.fromWords(t.words.slice(1));return{version:t.words[0],prefix:t.prefix,data:n.from(r)}}function p(e,t){c(f.tuple(f.Hash160bit,f.UInt8),arguments);var r=n.allocUnsafe(21);return r.writeUInt8(t,0),e.copy(r,1),o.encode(r)}function d(e,t,r){var n=i.toWords(e);return n.unshift(t),i.encode(r,n)}e.exports={fromBase58Check:l,fromBech32:h,fromOutputScript:function(e,t){if(t=t||u.bitcoin,a.pubKeyHash.output.check(e))return p(s.compile(e).slice(3,23),t.pubKeyHash);if(a.scriptHash.output.check(e))return p(s.compile(e).slice(2,22),t.scriptHash);if(a.witnessPubKeyHash.output.check(e))return d(s.compile(e).slice(2,22),0,t.bech32);if(a.witnessScriptHash.output.check(e))return d(s.compile(e).slice(2,34),0,t.bech32);throw new Error(s.toASM(e)+" has no matching Address")},toBase58Check:p,toBech32:d,toOutputScript:function(e,t){var r;t=t||u.bitcoin;try{r=l(e)}catch(e){}if(r){if(r.version===t.pubKeyHash)return a.pubKeyHash.output.encode(r.hash);if(r.version===t.scriptHash)return a.scriptHash.output.encode(r.hash)}else{try{r=h(e)}catch(e){}if(r){if(r.prefix!==t.bech32)throw new Error(e+" has an invalid prefix");if(0===r.version){if(20===r.data.length)return a.witnessPubKeyHash.output.encode(r.data);if(32===r.data.length)return a.witnessScriptHash.output.encode(r.data)}}}throw new Error(e+" has no matching Script")}}},function(e,t,r){"use strict";var n=r(123),i=r(807);e.exports=i(function(e){var t=n("sha256").update(e).digest();return n("sha256").update(t).digest()})},function(e,t,r){"use strict";var n=r(5),i=r(809),o=r(92),s=r(2).Buffer,a=r(810),u=r(409),c=r(410),f=s.alloc(128);function l(e,t){o.call(this,"digest"),"string"==typeof t&&(t=s.from(t));var r="sha512"===e||"sha384"===e?128:64;this._alg=e,this._key=t,t.length>r?t=("rmd160"===e?new u:c(e)).update(t).digest():t.length=4)throw new Error("Invalid hashType "+t);return{signature:a.fromDER(e.slice(0,-1)),hashType:t}},a.prototype.toCompact=function(e,r){r&&(e+=4),e+=27;var n=t.alloc(65);return n.writeUInt8(e,0),this.toRSBuffer(n,1),n},a.prototype.toDER=function(){var e=t.from(this.r.toDERInteger()),r=t.from(this.s.toDERInteger());return n.encode(e,r)},a.prototype.toRSBuffer=function(e,r){return e=e||t.alloc(64),this.r.toBuffer(32).copy(e,r),this.s.toBuffer(32).copy(e,r+32),e},a.prototype.toScriptSignature=function(e){var r=-129&e;if(r<=0||r>=4)throw new Error("Invalid hashType "+e);var n=t.alloc(1);return n.writeUInt8(e,0),t.concat([this.toDER(),n])},e.exports=a}).call(this,r(0).Buffer)},function(e,t,r){var n=r(414),i=r(415),o=r(813);e.exports={Curve:i,Point:n,getCurveByName:o}},function(e){e.exports={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){var n=t;n.utils=r(71),n.common=r(125),n.sha=r(839),n.ripemd=r(843),n.hmac=r(844),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";(function(t){const n=r(50),i=r(4),o=r(154),s=r(126),a=r(863),u=r(127),c=r(128);r(864),r(424),r(423),r(425);function f(e){return e.map(e=>e.toString(16)).join("/")}e.exports=function(e,r){const l=c(e,a,function(e,o,s){h(e,o,(e,a)=>{if(e)return s(e);if(!r)return s(null,a);let u=a.slice();const c=a.filter(e=>t.isBuffer(e.value));n(c,(e,t)=>i([t=>r.util.deserialize(e.value,t),(e,t)=>r.resolver._mapFromEthObject(e,o,t)],(r,n)=>{if(r)return t(r);n.forEach(t=>{u.push({path:e.path+"/"+t.path,value:t.value})}),t()}),e=>{if(e)return s(e);s(null,u)})})});return l.util.deserialize=o(e=>{const t=s.decode(e);return new a(t)}),l;function h(t,r,i){let o=[];"leaf"===t.type&&o.push({path:f(t.getKey()),value:t.getValue()}),n(t.getChildren(),(t,n)=>{const i=f(t[0]),s=t[1];if(a.isRawNode(s)){const e=new a(s);o.push({path:i,value:e}),h(e,r,(e,t)=>{if(e)return n(e);t.forEach(e=>{e.path=i+"/"+e.path}),o=o.concat(t),n()})}else{let t={"/":u(e,s).toBaseEncodedString()};o.push({path:i,value:t}),n()}},e=>{if(e)return i(e);i(null,o)})}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(430),i=(e,t)=>{switch(t){case"version":return e.version;case"timestamp":return e.time;case"difficulty":return e.bits;case"nonce":return e.nonce;case"solution":return e.solution;case"reserved":return e.reserved;case"parent":return{"/":n.hashToCid(e.prevHash)};case"tx":return{"/":n.hashToCid(e.merkleRoot)};default:return null}};e.exports={multicodec:"zcash-block",defaultHashAlg:"dbl-sha2-256",resolve:(e,t,r)=>{"function"==typeof t&&(r=t,t=void 0),n.deserialize(e,(e,n)=>{if(e)return r(e);if(!t)return r(null,{value:n,remainderPath:""});const o=t.split("/"),s=i(n,o[0]);if(null===s)return r(new Error("No such path"),null);let a=o.slice(1).join("/");return void 0!==s["/"]?r(null,{value:s,remainderPath:a}):a.length>0?r(new Error("No such path"),null):r(null,{value:s,remainderPath:""})})},tree:(e,t,r)=>{"function"==typeof t&&(r=t,t=void 0),t=t||{},n.deserialize(e,(e,n)=>{if(e)return r(e);const o=["version","timestamp","difficulty","nonce","solution","reserved","parent","tx"];if(!0===t.values){const e={};for(let t of o)e[t]=i(n,t);return r(null,e)}return r(null,o)})}}},function(e,t,r){"use strict";(function(t){var n=r(18),i=r(21),o=r(24),s=r(29);function a(e){if(!(this instanceof a))return new a(e);var t;if(n.isNumber(e))t=e;else{if(!n.isString(e))throw new TypeError('Unrecognized num type: "'+typeof e+'" for Opcode');t=a.map[e]}return s.defineImmutable(this,{num:t}),this}for(var u in a.fromBuffer=function(e){return i.checkArgument(o.isBuffer(e)),new a(Number("0x"+e.toString("hex")))},a.fromNumber=function(e){return i.checkArgument(n.isNumber(e)),new a(e)},a.fromString=function(e){i.checkArgument(n.isString(e));var t=a.map[e];if(void 0===t)throw new TypeError("Invalid opcodestr");return new a(t)},a.prototype.toHex=function(){return this.num.toString(16)},a.prototype.toBuffer=function(){return new t(this.toHex(),"hex")},a.prototype.toNumber=function(){return this.num},a.prototype.toString=function(){var e=a.reverseMap[this.num];if(void 0===e)throw new Error("Opcode does not have a string representation");return e},a.smallInt=function(e){return i.checkArgument(n.isNumber(e),"Invalid Argument: n should be number"),i.checkArgument(e>=0&&e<=16,"Invalid Argument: n must be between 0 and 16"),0===e?a("OP_0"):new a(a.map.OP_1+e-1)},a.map={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP1:176,OP_NOP2:177,OP_NOP3:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255},a.reverseMap=[],a.map)a.reverseMap[a.map[u]]=u;n.extend(a,a.map),a.isSmallIntOp=function(e){return e instanceof a&&(e=e.toNumber()),e===a.map.OP_0||e>=a.map.OP_1&&e<=a.map.OP_16},a.prototype.inspect=function(){return""},e.exports=a}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){var n=r(18),i=r(21),o=r(0),s=t.compare||r(893),a=r(66),u=r(24),c=r(29),f=r(82),l=r(57),h=r(43),p=r(67),d=r(83),y=r(97),g=r(434),m=r(251),b=m.PublicKeyHash,v=m.PublicKey,_=m.MultiSigScriptHash,w=m.MultiSig,S=r(84),k=r(68),E=r(176),A=r(32),x=r(898);function I(e){if(!(this instanceof I))return new I(e);if(this.inputs=[],this.outputs=[],this.joinSplits=[],this._inputAmount=void 0,this._outputAmount=void 0,e){if(e instanceof I)return I.shallowCopy(e);if(c.isHexa(e))this.fromString(e);else if(u.isBuffer(e))this.fromBuffer(e);else{if(!n.isObject(e))throw new a.InvalidArgument("Must provide an object or string to deserialize a transaction");this.fromObject(e)}}else this._newTransaction()}I.DUST_AMOUNT=546,I.FEE_SECURITY_MARGIN=15,I.MAX_MONEY=21e14,I.NLOCKTIME_BLOCKHEIGHT_LIMIT=5e8,I.NLOCKTIME_MAX_VALUE=4294967295,I.FEE_PER_KB=1e4,I.CHANGE_OUTPUT_MAX_SIZE=62,I.MAXIMUM_EXTRA_SIZE=26,I.shallowCopy=function(e){return new I(e.toBuffer())};var T={configurable:!1,enumerable:!0,get:function(){return new f(this._getHash()).readReverse().toString("hex")}};Object.defineProperty(I.prototype,"hash",T),Object.defineProperty(I.prototype,"id",T);var B={configurable:!1,enumerable:!0,get:function(){return this._getInputAmount()}};Object.defineProperty(I.prototype,"inputAmount",B),B.get=function(){return this._getOutputAmount()},Object.defineProperty(I.prototype,"outputAmount",B),I.prototype._getHash=function(){return h.sha256sha256(this.toBuffer())},I.prototype.serialize=function(e){return!0===e||e&&e.disableAll?this.uncheckedSerialize():this.checkedSerialize(e)},I.prototype.uncheckedSerialize=I.prototype.toString=function(){return this.toBuffer().toString("hex")},I.prototype.checkedSerialize=function(e){var t=this.getSerializationError(e);if(t)throw t.message+=" Use Transaction#uncheckedSerialize if you want to skip security checks. See http://bitcore.io/guide/transaction.html#Serialization for more info.",t;return this.uncheckedSerialize()},I.prototype.invalidSatoshis=function(){for(var e=!1,t=0;tr)return this._missingChange()?new a.Transaction.ChangeAddressMissing("Fee is too large and no change address was provided"):new a.Transaction.FeeError.TooLarge("expected less than "+r+" but got "+t)}if(!e.disableSmallFees){var i=Math.ceil(this._estimateFee()/I.FEE_SECURITY_MARGIN);if(t"},I.prototype.toBuffer=function(){var e=new l;return this.toBufferWriter(e).toBuffer()},I.prototype.toBufferWriter=function(e){return e.writeUInt32LE(this.version),e.writeVarintNum(this.inputs.length),n.each(this.inputs,function(t){t.toBufferWriter(e)}),e.writeVarintNum(this.outputs.length),n.each(this.outputs,function(t){t.toBufferWriter(e)}),e.writeUInt32LE(this.nLockTime),this.version>=2&&(e.writeVarintNum(this.joinSplits.length),n.each(this.joinSplits,function(t){t.toBufferWriter(e)}),this.joinSplits.length>0&&(e.write(this.joinSplitPubKey),e.write(this.joinSplitSig))),e},I.prototype.fromBuffer=function(e){var t=new f(e);return this.fromBufferReader(t)},I.prototype.fromBufferReader=function(e){var t,r,n,o;for(i.checkArgument(!e.finished(),"No transaction data received"),this.version=e.readUInt32LE(),r=e.readVarintNum(),t=0;t=2){for(o=e.readVarintNum(),t=0;t0&&(this.joinSplitPubKey=e.read(32),this.joinSplitSig=e.read(64))}return this},I.prototype.toObject=I.prototype.toJSON=function(){var e=[];this.inputs.forEach(function(t){e.push(t.toObject())});var t=[];this.outputs.forEach(function(e){t.push(e.toObject())});var r={hash:this.hash,version:this.version,inputs:e,outputs:t,nLockTime:this.nLockTime};if(this.version>=2){var i=[];this.joinSplits.forEach(function(e){i.push(e.toObject())}),r.joinSplits=i,this.joinSplits.length>0&&(r.joinSplitPubKey=u.reverse(this.joinSplitPubKey).toString("hex"),r.joinSplitSig=this.joinSplitSig.toString("hex"))}return this._changeScript&&(r.changeScript=this._changeScript.toString()),n.isUndefined(this._changeIndex)||(r.changeIndex=this._changeIndex),n.isUndefined(this._fee)||(r.fee=this._fee),r},I.prototype.fromObject=function(e){i.checkArgument(n.isObject(e)||e instanceof I);var r,o=this;return r=e instanceof I?r.toObject():e,n.each(r.inputs,function(e){if(e.output&&e.output.script){var t,r=new k(e.output.script);if(r.isPublicKeyHashOut())t=new m.PublicKeyHash(e);else if(r.isScriptHashOut()&&e.publicKeys&&e.threshold)t=new m.MultiSigScriptHash(e,e.publicKeys,e.threshold,e.signatures);else{if(!r.isPublicKeyOut())throw new a.Transaction.Input.UnsupportedScript(e.output.script);t=new m.PublicKey(e)}o.addInput(t)}else o.uncheckedAddInput(new m(e))}),n.each(r.outputs,function(e){o.addOutput(new S(e))}),r.changeIndex&&(this._changeIndex=r.changeIndex),r.changeScript&&(this._changeScript=new k(r.changeScript)),r.fee&&(this._fee=r.fee),this.nLockTime=r.nLockTime,this.version=r.version,this.version>=2&&(n.each(r.joinSplits,function(e){o.joinSplits.push(new x(e))}),o.joinSplits.length>0&&(o.joinSplitPubKey=u.reverse(new t(r.joinSplitPubKey,"hex")),o.joinSplitSig=new t(r.joinSplitSig,"hex"))),this._checkConsistency(e),this},I.prototype._checkConsistency=function(e){n.isUndefined(this._changeIndex)||(i.checkState(this._changeScript),i.checkState(this.outputs[this._changeIndex]),i.checkState(this.outputs[this._changeIndex].script.toString()===this._changeScript.toString())),e&&e.hash&&i.checkState(e.hash===this.hash,"Hash in object does not match transaction hash")},I.prototype.lockUntilDate=function(e){if(i.checkArgument(e),n.isNumber(e)&&e=I.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new a.Transaction.BlockHeightTooHigh;if(e<0)throw new a.Transaction.NLockTimeOutOfRange;for(var t=0;t0?(this._changeIndex=this.outputs.length,this._addOutput(new S({script:this._changeScript,satoshis:e}))):this._changeIndex=void 0}},I.prototype.getFee=function(){return this.isCoinbase()?0:n.isUndefined(this._fee)?this._changeScript?this._estimateFee():this._getUnspentValue():this._fee},I.prototype._estimateFee=function(){var e=this._estimateSize(),t=this._getUnspentValue();return I._estimateFee(e,t,this._feePerKb)},I.prototype._getUnspentValue=function(){return this._getInputAmount()-this._getOutputAmount()},I.prototype._clearSignatures=function(){n.each(this.inputs,function(e){e.clearSignatures()})},I._estimateFee=function(e,t,r){return t>Math.ceil(e/1e3)*(r||I.FEE_PER_KB)&&(e+=I.CHANGE_OUTPUT_MAX_SIZE),Math.ceil(e/1e3)*(r||I.FEE_PER_KB)},I.prototype._estimateSize=function(){var e=I.MAXIMUM_EXTRA_SIZE;return n.each(this.inputs,function(t){e+=t._estimateSize()}),n.each(this.outputs,function(t){e+=t.script.toBuffer().length+9}),e},I.prototype._removeOutput=function(e){var t=this.outputs[e];this.outputs=n.without(this.outputs,t),this._outputAmount=void 0},I.prototype.removeOutput=function(e){this._removeOutput(e),this._updateChangeOutput()},I.prototype.sort=function(){return this.sortInputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(e,t){return s(e.prevTxId,t.prevTxId)||e.outputIndex-t.outputIndex}),t}),this.sortOutputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(e,t){return e.satoshis-t.satoshis||s(e.script.toBuffer(),t.script.toBuffer())}),t}),this},I.prototype.shuffleOutputs=function(){return this.sortOutputs(n.shuffle)},I.prototype.sortOutputs=function(e){var t=e(this.outputs);return this._newOutputOrder(t)},I.prototype.sortInputs=function(e){return this.inputs=e(this.inputs),this._clearSignatures(),this},I.prototype._newOutputOrder=function(e){if(this.outputs.length!==e.length||0!==n.difference(this.outputs,e).length)throw new a.Transaction.InvalidSorting;if(!n.isUndefined(this._changeIndex)){var t=this.outputs[this._changeIndex];this._changeIndex=n.findIndex(e,t)}return this.outputs=e,this},I.prototype.removeInput=function(e,t){var r;if((r=!t&&n.isNumber(e)?e:n.findIndex(this.inputs,function(r){return r.prevTxId.toString("hex")===e&&r.outputIndex===t}))<0||r>=this.inputs.length)throw new a.Transaction.InvalidIndex(r,this.inputs.length);var i=this.inputs[r];this.inputs=n.without(this.inputs,i),this._inputAmount=void 0,this._updateChangeOutput()},I.prototype.sign=function(e,t){i.checkState(this.hasAllUtxoInfo());var r=this;return n.isArray(e)?(n.each(e,function(e){r.sign(e,t)}),this):(n.each(this.getSignatures(e,t),function(e){r.applySignature(e)}),this)},I.prototype.getSignatures=function(e,t){e=new E(e),t=t||p.SIGHASH_ALL;var r=this,i=[],o=h.sha256ripemd160(e.publicKey.toBuffer());return n.each(this.inputs,function(s,a){n.each(s.getSignatures(r,e,a,t,o),function(e){i.push(e)})}),i},I.prototype.applySignature=function(e){return this.inputs[e.inputIndex].addSignature(this,e),this},I.prototype.isFullySigned=function(){return n.each(this.inputs,function(e){if(e.isFullySigned===m.prototype.isFullySigned)throw new a.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction")}),n.all(n.map(this.inputs,function(e){return e.isFullySigned()}))},I.prototype.isValidSignature=function(e){if(this.inputs[e.inputIndex].isValidSignature===m.prototype.isValidSignature)throw new a.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction");return this.inputs[e.inputIndex].isValidSignature(this,e)},I.prototype.verifySignature=function(e,t,r,n){return d.verify(this,e,t,r,n)},I.prototype.verify=function(){if(0===this.inputs.length)return"transaction txins empty";if(0===this.outputs.length)return"transaction txouts empty";for(var e=new A(0),t=0;t1e6)return"transaction over the maximum block size";var i={};for(t=0;t100)return"coinbase transaction script size invalid"}else for(t=0;t=m.MAXINT-1&&(t.sequenceNumber=m.DEFAULT_RBF_SEQNUMBER)}return this},e.exports=I}).call(this,r(0).Buffer)},function(e,t,r){e.exports=r(130),e.exports.PublicKey=r(894),e.exports.PublicKeyHash=r(895),e.exports.MultiSig=r(896),e.exports.MultiSigScriptHash=r(897)},function(e,t,r){"use strict";var n=r(18),i=r(66),o=r(21),s={BTC:[1e8,8],mBTC:[1e5,5],uBTC:[100,2],bits:[100,2],satoshis:[1,0]};function a(e,t){if(!(this instanceof a))return new a(e,t);if(n.isNumber(t)){if(t<=0)throw new i.Unit.InvalidRate(t);e/=t,t=a.BTC}this._value=this._from(e,t);var r=this;Object.keys(s).forEach(function(e){Object.defineProperty(r,e,{get:function(){return r.to(e)},enumerable:!0})})}Object.keys(s).forEach(function(e){a[e]=e}),a.fromObject=function(e){return o.checkArgument(n.isObject(e),"Argument is expected to be an object"),new a(e.amount,e.code)},a.fromBTC=function(e){return new a(e,a.BTC)},a.fromMillis=a.fromMilis=function(e){return new a(e,a.mBTC)},a.fromMicros=a.fromBits=function(e){return new a(e,a.bits)},a.fromSatoshis=function(e){return new a(e,a.satoshis)},a.fromFiat=function(e,t){return new a(e,t)},a.prototype._from=function(e,t){if(!s[t])throw new i.Unit.UnknownCode(t);return parseInt((e*s[t][0]).toFixed())},a.prototype.to=function(e){if(n.isNumber(e)){if(e<=0)throw new i.Unit.InvalidRate(e);return parseFloat((this.BTC*e).toFixed(2))}if(!s[e])throw new i.Unit.UnknownCode(e);var t=this._value/s[e][0];return parseFloat(t.toFixed(s[e][1]))},a.prototype.toBTC=function(){return this.to(a.BTC)},a.prototype.toMillis=a.prototype.toMilis=function(){return this.to(a.mBTC)},a.prototype.toMicros=a.prototype.toBits=function(){return this.to(a.bits)},a.prototype.toSatoshis=function(){return this.to(a.satoshis)},a.prototype.atRate=function(e){return this.to(e)},a.prototype.toString=function(){return this.satoshis+" satoshis"},a.prototype.toObject=a.prototype.toJSON=function(){return{amount:this.BTC,code:a.BTC}},a.prototype.inspect=function(){return""},e.exports=a},function(e,t,r){"use strict";e.exports={_cache:{},_count:0,_eraseIndex:0,_usedList:{},_usedIndex:{},_CACHE_SIZE:5e3,get:function(e,t,r){var n=e+"/"+t+"/"+(r=!!r);if(this._cache[n])return this._cacheHit(n),this._cache[n]},set:function(e,t,r,n){var i=e+"/"+t+"/"+(r=!!r);this._cache[i]=n,this._cacheHit(i)},_cacheHit:function(e){this._usedIndex[e]&&delete this._usedList[this._usedIndex[e]],this._usedList[this._count]=e,this._usedIndex[e]=this._count,this._count++,this._cacheRemove()},_cacheRemove:function(){for(;this._eraseIndex{t(null,e)},e=>{t(e)})}},function(e,t,r){"use strict";e.exports=(()=>{if("undefined"!=typeof self&&(r(58)(self),self.crypto))return self.crypto;throw new Error("Please use an environment with crypto support")})},function(e,t,r){"use strict";e.exports="enum KeyType {\n RSA = 0;\n Ed25519 = 1;\n Secp256k1 = 2;\n}\nmessage PublicKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}\nmessage PrivateKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}"},function(e,t,r){var n=r(13);r(19),e.exports=n.cipher=n.cipher||{},n.cipher.algorithms=n.cipher.algorithms||{},n.cipher.createCipher=function(e,t){var r=e;if("string"==typeof r&&(r=n.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+e);return new n.cipher.BlockCipher({algorithm:r,key:t,decrypt:!1})},n.cipher.createDecipher=function(e,t){var r=e;if("string"==typeof r&&(r=n.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+e);return new n.cipher.BlockCipher({algorithm:r,key:t,decrypt:!0})},n.cipher.registerAlgorithm=function(e,t){e=e.toUpperCase(),n.cipher.algorithms[e]=t},n.cipher.getAlgorithm=function(e){return(e=e.toUpperCase())in n.cipher.algorithms?n.cipher.algorithms[e]:null};var i=n.cipher.BlockCipher=function(e){this.algorithm=e.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=e.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=e.decrypt,this.algorithm.initialize(e)};i.prototype.start=function(e){e=e||{};var t={};for(var r in e)t[r]=e[r];t.decrypt=this._decrypt,this._finish=!1,this._input=n.util.createBuffer(),this.output=e.output||n.util.createBuffer(),this.mode.start(t)},i.prototype.update=function(e){for(e&&this._input.putBuffer(e);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},i.prototype.finish=function(e){!e||"ECB"!==this.mode.name&&"CBC"!==this.mode.name||(this.mode.pad=function(t){return e(this.blockSize,t,!1)},this.mode.unpad=function(t){return e(this.blockSize,t,!0)});var t={};return t.decrypt=this._decrypt,t.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,t)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,t)||this.mode.afterFinish&&!this.mode.afterFinish(this.output,t)))}},function(e,t,r){var n=r(13);r(77),r(19);var i=e.exports=n.md5=n.md5||{};n.md.md5=n.md.algorithms.md5=i,i.create=function(){c||function(){o=String.fromCharCode(128),o+=n.util.fillString(String.fromCharCode(0),64),s=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12,5,8,11,14,1,4,7,10,13,0,3,6,9,12,15,2,0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9],a=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],u=new Array(64);for(var e=0;e<64;++e)u[e]=Math.floor(4294967296*Math.abs(Math.sin(e+1)));c=!0}();var e=null,t=n.util.createBuffer(),r=new Array(16),i={algorithm:"md5",blockLength:64,digestLength:16,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){i.messageLength=0,i.fullMessageLength=i.messageLength64=[];for(var r=i.messageLengthSize/4,o=0;o>>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),f(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=i.fullMessageLength[i.fullMessageLength.length-1]+i.messageLengthSize&i.blockLength-1;s.putBytes(o.substr(0,i.blockLength-a));for(var u,c=0,l=i.fullMessageLength.length-1;l>=0;--l)c=(u=8*i.fullMessageLength[l]+c)/4294967296>>>0,s.putInt32Le(u>>>0);var h={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3};f(h,r,s);var p=n.util.createBuffer();return p.putInt32Le(h.h0),p.putInt32Le(h.h1),p.putInt32Le(h.h2),p.putInt32Le(h.h3),p},i};var o=null,s=null,a=null,u=null,c=!1;function f(e,t,r){for(var n,i,o,c,f,l,h,p=r.length();p>=64;){for(i=e.h0,o=e.h1,c=e.h2,f=e.h3,h=0;h<16;++h)t[h]=r.getInt32Le(),n=i+(f^o&(c^f))+u[h]+t[h],i=f,f=c,c=o,o+=n<<(l=a[h])|n>>>32-l;for(;h<32;++h)n=i+(c^f&(o^c))+u[h]+t[s[h]],i=f,f=c,c=o,o+=n<<(l=a[h])|n>>>32-l;for(;h<48;++h)n=i+(o^c^f)+u[h]+t[s[h]],i=f,f=c,c=o,o+=n<<(l=a[h])|n>>>32-l;for(;h<64;++h)n=i+(c^(o|~f))+u[h]+t[s[h]],i=f,f=c,c=o,o+=n<<(l=a[h])|n>>>32-l;e.h0=e.h0+i|0,e.h1=e.h1+o|0,e.h2=e.h2+c|0,e.h3=e.h3+f|0,p-=64}}},function(e,t,r){(function(t){var n=r(13);r(133),r(77),r(19);var i,o=n.pkcs5=n.pkcs5||{};n.util.isNodejs&&!n.options.usePureJavaScript&&(i=r(450)),e.exports=n.pbkdf2=o.pbkdf2=function(e,r,o,s,a,u){if("function"==typeof a&&(u=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=new t(e,"binary"),r=new t(r,"binary"),u?4===i.pbkdf2Sync.length?i.pbkdf2(e,r,o,s,function(e,t){if(e)return u(e);u(null,t.toString("binary"))}):i.pbkdf2(e,r,o,s,a,function(e,t){if(e)return u(e);u(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(void 0!==a&&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 c=a.digestLength;if(s>4294967295*c){var f=new Error("Derived key is too long.");if(u)return u(f);throw f}var l=Math.ceil(s/c),h=s-(l-1)*c,p=n.hmac.create();p.start(a,e);var d,y,g,m="";if(!u){for(var b=1;b<=l;++b){p.start(null,null),p.update(r),p.update(n.util.int32ToBytes(b)),d=g=p.digest().getBytes();for(var v=2;v<=o;++v)p.start(null,null),p.update(g),y=p.digest().getBytes(),d=n.util.xorBytes(d,y,c),g=y;m+=bl)return u(null,m);p.start(null,null),p.update(r),p.update(n.util.int32ToBytes(b)),d=g=p.digest().getBytes(),v=2,w()}function w(){if(v<=o)return p.start(null,null),p.update(g),y=p.digest().getBytes(),d=n.util.xorBytes(d,y,c),g=y,++v,n.util.setImmediate(w);m+=b2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(l.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(u.validity.notBefore=l[0],u.validity.notAfter=l[1],u.tbsCertificate=r.tbsCertificate,t){var h;if(u.md=null,u.signatureOid in s)switch(s[u.signatureOid]){case"sha1WithRSAEncryption":u.md=n.md.sha1.create();break;case"md5WithRSAEncryption":u.md=n.md.md5.create();break;case"sha256WithRSAEncryption":u.md=n.md.sha256.create();break;case"sha384WithRSAEncryption":u.md=n.md.sha384.create();break;case"sha512WithRSAEncryption":u.md=n.md.sha512.create();break;case"RSASSA-PSS":u.md=n.md.sha256.create()}if(null===u.md)throw(h=new Error("Could not compute certificate digest. Unknown signature OID.")).signatureOid=u.signatureOid,h;var y=i.toDer(u.tbsCertificate);u.md.update(y.getBytes())}var m=n.md.sha1.create();u.issuer.getField=function(e){return p(u.issuer,e)},u.issuer.addField=function(e){g([e]),u.issuer.attributes.push(e)},u.issuer.attributes=o.RDNAttributesAsArray(r.certIssuer,m),r.certIssuerUniqueId&&(u.issuer.uniqueId=r.certIssuerUniqueId),u.issuer.hash=m.digest().toHex();var b=n.md.sha1.create();return u.subject.getField=function(e){return p(u.subject,e)},u.subject.addField=function(e){g([e]),u.subject.attributes.push(e)},u.subject.attributes=o.RDNAttributesAsArray(r.certSubject,b),r.certSubjectUniqueId&&(u.subject.uniqueId=r.certSubjectUniqueId),u.subject.hash=b.digest().toHex(),r.certExtensions?u.extensions=o.certificateExtensionsFromAsn1(r.certExtensions):u.extensions=[],u.publicKey=o.publicKeyFromAsn1(r.subjectPublicKeyInfo),u},o.certificateExtensionsFromAsn1=function(e){for(var t=[],r=0;r1&&(r=u.value.charCodeAt(1),o=u.value.length>2?u.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){(u=i.fromDer(t.value)).value.length>0&&u.value[0].type===i.Type.BOOLEAN?t.cA=0!==u.value[0].value.charCodeAt(0):t.cA=!1;var a=null;u.value.length>0&&u.value[0].type===i.Type.INTEGER?a=u.value[0].value:u.value.length>1&&(a=u.value[1].value),null!==a&&(t.pathLenConstraint=i.derToInteger(a))}else if("extKeyUsage"===t.name)for(var u=i.fromDer(t.value),c=0;c1&&(r=u.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 l;t.altNames=[];u=i.fromDer(t.value);for(var h=0;h0&&t.value.push(o.certificateExtensionsToAsn1(e.extensions)),t},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),function(e){var t=i.create(i.Class.CONTEXT_SPECIFIC,0,!0,[]);if(0===e.attributes.length)return t;for(var r=e.attributes,o=0;of.validity.notAfter)&&(u={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===u){if(null===(l=t[0]||e.getIssuer(f))&&f.isIssuer(f)&&(h=!0,l=f),l){var p=l;n.util.isArray(p)||(p=[p]);for(var d=!1;!d&&p.length>0;){l=p.shift();try{d=l.verify(f)}catch(e){}}d||(u={message:"Certificate signature is invalid.",error:o.certificateError.bad_certificate})}null!==u||l&&!h||e.hasCertificate(f)||(u={message:"Certificate is not trusted.",error:o.certificateError.unknown_ca})}if(null===u&&l&&!f.isIssuer(l)&&(u={message:"Certificate issuer is invalid.",error:o.certificateError.bad_certificate}),null===u)for(var y={keyUsage:!0,basicConstraints:!0},g=0;null===u&&gb.pathLenConstraint&&(u={message:"Certificate basicConstraints pathLenConstraint violated.",error:o.certificateError.bad_certificate})}var _=null===u||u.error,w=r?r(_,c,i):_;if(!0!==w)throw!0===_&&(u={message:"The application rejected the certificate.",error:o.certificateError.bad_certificate}),(w||0===w)&&("object"!=typeof w||n.util.isArray(w)?"string"==typeof w&&(u.error=w):(w.message&&(u.message=w.message),w.error&&(u.error=w.error))),u;u=null,a=!1,++c}while(t.length>0);return!0}},function(e,t,r){var n=r(13);r(69),r(19),(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;return{encode:function(e,u){var c,f,l=u-1,h=Math.ceil(l/8),p=e.digest().getBytes();if(h>8*h-l&255;return(_=String.fromCharCode(_.charCodeAt(0)&~w)+_.substr(1))+y+String.fromCharCode(188)},verify:function(e,s,a){var u,c=a-1,f=Math.ceil(c/8);if(s=s.substr(-f),f>8*f-c&255;if(0!=(h.charCodeAt(0)&d))throw new Error("Bits beyond keysize not zero as expected.");var y=i.generate(p,l),g="";for(u=0;u{t(null,e)},e=>{t(e)})}},function(e,t,r){"use strict";e.exports=(()=>{if("undefined"!=typeof self&&(r(58)(self),self.crypto))return self.crypto;throw new Error("Please use an environment with crypto support")})},function(e,t,r){"use strict";e.exports="enum KeyType {\n RSA = 0;\n Ed25519 = 1;\n Secp256k1 = 2;\n}\nmessage PublicKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}\nmessage PrivateKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}"},function(e,t){t.BITS=32,t.GROUPS=4,t.RE_ADDRESS=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/g,t.RE_SUBNET_STRING=/\/\d{1,2}$/},function(e,t){t.BITS=128,t.GROUPS=8,t.SCOPES={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"},t.TYPES={"ff01::1/128":"Multicast (All nodes on this interface)","ff01::2/128":"Multicast (All routers on this interface)","ff02::1/128":"Multicast (All nodes on this link)","ff02::2/128":"Multicast (All routers on this link)","ff05::2/128":"Multicast (All routers in this site)","ff02::5/128":"Multicast (OSPFv3 AllSPF routers)","ff02::6/128":"Multicast (OSPFv3 AllDR routers)","ff02::9/128":"Multicast (RIP routers)","ff02::a/128":"Multicast (EIGRP routers)","ff02::d/128":"Multicast (PIM routers)","ff02::16/128":"Multicast (MLDv2 reports)","ff01::fb/128":"Multicast (mDNSv6)","ff02::fb/128":"Multicast (mDNSv6)","ff05::fb/128":"Multicast (mDNSv6)","ff02::1:2/128":"Multicast (All DHCP servers and relay agents on this link)","ff05::1:2/128":"Multicast (All DHCP servers and relay agents in this site)","ff02::1:3/128":"Multicast (All DHCP servers on this link)","ff05::1:3/128":"Multicast (All DHCP servers in this site)","::/128":"Unspecified","::1/128":"Loopback","ff00::/8":"Multicast","fe80::/10":"Link-local unicast"},t.RE_BAD_CHARACTERS=/([^0-9a-f:\/%])/gi,t.RE_BAD_ADDRESS=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi,t.RE_SUBNET_STRING=/\/\d{1,3}(?=%|$)/,t.RE_ZONE_STRING=/%.*$/,t.RE_URL=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/),t.RE_URL_WITH_PORT=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/)},function(e,t,r){"use strict";const n=r(44);function i(e){if("number"==typeof e){if(i.codes[e])return i.codes[e];throw new Error("no protocol with code: "+e)}if("string"==typeof e||e instanceof String){if(i.names[e])return i.names[e];throw new Error("no protocol with name: "+e)}throw new Error("invalid protocol id type: "+e)}function o(e,t,r,n){return{code:e,size:t,name:r,resolvable:Boolean(n)}}i.lengthPrefixedVarSize=-1,i.V=-1,i.table=[[4,32,"ip4"],[6,16,"tcp"],[17,16,"udp"],[33,16,"dccp"],[41,128,"ip6"],[54,-1,"dns4","resolvable"],[55,-1,"dns6","resolvable"],[56,-1,"dnsaddr","resolvable"],[132,16,"sctp"],[302,0,"utp"],[421,i.lengthPrefixedVarSize,"ipfs"],[480,0,"http"],[443,0,"https"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[290,0,"p2p-circuit"]],i.names={},i.codes={},n(i.table,function(e){const t=o.apply(null,e);i.codes[t.code]=t,i.names[t.name]=t}),i.object=o,e.exports=i},function(e,t,r){"use strict";const n=r(44);function i(e){if("number"==typeof e){if(i.codes[e])return i.codes[e];throw new Error("no protocol with code: "+e)}if("string"==typeof e||e instanceof String){if(i.names[e])return i.names[e];throw new Error("no protocol with name: "+e)}throw new Error("invalid protocol id type: "+e)}function o(e,t,r,n){return{code:e,size:t,name:r,resolvable:Boolean(n)}}i.lengthPrefixedVarSize=-1,i.V=-1,i.table=[[4,32,"ip4"],[6,16,"tcp"],[17,16,"udp"],[33,16,"dccp"],[41,128,"ip6"],[54,-1,"dns4","resolvable"],[55,-1,"dns6","resolvable"],[56,-1,"dnsaddr","resolvable"],[132,16,"sctp"],[302,0,"utp"],[421,i.lengthPrefixedVarSize,"ipfs"],[480,0,"http"],[443,0,"https"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[290,0,"p2p-circuit"]],i.names={},i.codes={},n(i.table,function(e){const t=o.apply(null,e);i.codes[t.code]=t,i.names[t.name]=t}),i.object=o,e.exports=i},function(e,t,r){"use strict";e.exports=function(e,t){return e.then(e=>{t(null,e)},e=>{t(e)})}},function(e,t,r){"use strict";e.exports=(()=>{if("undefined"!=typeof self&&(r(58)(self),self.crypto))return self.crypto;throw new Error("Please use an environment with crypto support")})},function(e,t,r){"use strict";e.exports="enum KeyType {\n RSA = 0;\n Ed25519 = 1;\n Secp256k1 = 2;\n}\nmessage PublicKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}\nmessage PrivateKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}"},function(e,t,r){"use strict";(function(t){ +e.exports=function(e){"use strict";if("function"!=typeof Promise)throw"Promise support required";var t=e.crypto||e.msCrypto;if(t){var r=t.subtle||t.webkitSubtle;if(r){var n=e.Crypto||t.constructor||Object,i=e.SubtleCrypto||r.constructor||Object,o=(e.CryptoKey||e.Key||Object,e.navigator.userAgent.indexOf("Edge/")>-1),s=!!e.msCrypto&&!o,a=!t.subtle&&!!t.webkitSubtle;if(s||a){var u={KoZIhvcNAQEB:"1.2.840.113549.1.1.1"},c={"1.2.840.113549.1.1.1":"KoZIhvcNAQEB"};if(["generateKey","importKey","unwrapKey"].forEach(function(e){var n=r[e];r[e]=function(i,o,u){var c,f,l,d,v=[].slice.call(arguments);switch(e){case"generateKey":c=y(i),f=o,l=u;break;case"importKey":c=y(u),f=v[3],l=v[4],"jwk"===i&&((o=m(o)).alg||(o.alg=g(c)),o.key_ops||(o.key_ops="oct"!==o.kty?"d"in o?l.filter(k):l.filter(S):l.slice()),v[1]=function(e){var t=m(e);return s&&(t.extractable=t.ext,delete t.ext),p(unescape(encodeURIComponent(JSON.stringify(t)))).buffer}(o));break;case"unwrapKey":c=v[4],f=v[5],l=v[6],v[2]=u._key}if("generateKey"===e&&"HMAC"===c.name&&c.hash)return c.length=c.length||{"SHA-1":512,"SHA-256":512,"SHA-384":1024,"SHA-512":1024}[c.hash.name],r.importKey("raw",t.getRandomValues(new Uint8Array(c.length+7>>3)),c,f,l);if(a&&"generateKey"===e&&"RSASSA-PKCS1-v1_5"===c.name&&(!c.modulusLength||c.modulusLength>=2048))return(i=y(i)).name="RSAES-PKCS1-v1_5",delete i.hash,r.generateKey(i,!0,["encrypt","decrypt"]).then(function(e){return Promise.all([r.exportKey("jwk",e.publicKey),r.exportKey("jwk",e.privateKey)])}).then(function(e){return e[0].alg=e[1].alg=g(c),e[0].key_ops=l.filter(S),e[1].key_ops=l.filter(k),Promise.all([r.importKey("jwk",e[0],c,!0,e[0].key_ops),r.importKey("jwk",e[1],c,f,e[1].key_ops)])}).then(function(e){return{publicKey:e[0],privateKey:e[1]}});if((a||s&&"SHA-1"===(c.hash||{}).name)&&"importKey"===e&&"jwk"===i&&"HMAC"===c.name&&"oct"===o.kty)return r.importKey("raw",p(h(o.k)),u,v[3],v[4]);if(a&&"importKey"===e&&("spki"===i||"pkcs8"===i))return r.importKey("jwk",b(o),u,v[3],v[4]);if(s&&"unwrapKey"===e)return r.decrypt(v[3],u,o).then(function(e){return r.importKey(i,e,v[4],v[5],v[6])});try{d=n.apply(r,v)}catch(e){return Promise.reject(e)}return s&&(d=new Promise(function(e,t){d.onabort=d.onerror=function(e){t(e)},d.oncomplete=function(t){e(t.target.result)}})),d=d.then(function(e){return"HMAC"===c.name&&(c.length||(c.length=8*e.algorithm.length)),0==c.name.search("RSA")&&(c.modulusLength||(c.modulusLength=(e.publicKey||e).algorithm.modulusLength),c.publicExponent||(c.publicExponent=(e.publicKey||e).algorithm.publicExponent)),e.publicKey&&e.privateKey?{publicKey:new w(e.publicKey,c,f,l.filter(S)),privateKey:new w(e.privateKey,c,f,l.filter(k))}:new w(e,c,f,l)})}}),["exportKey","wrapKey"].forEach(function(e){var t=r[e];r[e]=function(n,i,o){var u,c=[].slice.call(arguments);switch(e){case"exportKey":c[1]=i._key;break;case"wrapKey":c[1]=i._key,c[2]=o._key}if((a||s&&"SHA-1"===(i.algorithm.hash||{}).name)&&"exportKey"===e&&"jwk"===n&&"HMAC"===i.algorithm.name&&(c[0]="raw"),!a||"exportKey"!==e||"spki"!==n&&"pkcs8"!==n||(c[0]="jwk"),s&&"wrapKey"===e)return r.exportKey(n,i).then(function(e){return"jwk"===n&&(e=p(unescape(encodeURIComponent(JSON.stringify(m(e)))))),r.encrypt(c[3],o,e)});try{u=t.apply(r,c)}catch(e){return Promise.reject(e)}return s&&(u=new Promise(function(e,t){u.onabort=u.onerror=function(e){t(e)},u.oncomplete=function(t){e(t.target.result)}})),"exportKey"===e&&"jwk"===n&&(u=u.then(function(e){return(a||s&&"SHA-1"===(i.algorithm.hash||{}).name)&&"HMAC"===i.algorithm.name?{kty:"oct",alg:g(i.algorithm),key_ops:i.usages.slice(),ext:!0,k:l(d(e))}:((e=m(e)).alg||(e.alg=g(i.algorithm)),e.key_ops||(e.key_ops="public"===i.type?i.usages.filter(S):"private"===i.type?i.usages.filter(k):i.usages.slice()),e)})),!a||"exportKey"!==e||"spki"!==n&&"pkcs8"!==n||(u=u.then(function(e){return function(e){var t,r=[["",null]],n=!1;switch(e.kty){case"RSA":for(var i=["n","e","d","p","q","dp","dq","qi"],o=[],s=0;s2&&(n=!0,o.unshift(new Uint8Array([0]))),r[0][0]="1.2.840.113549.1.1.1",t=o;break;default:throw new TypeError("Unsupported key type")}return r.push(new Uint8Array(_(t)).buffer),n?r.unshift(new Uint8Array([0])):r[1]={tag:3,value:r[1]},new Uint8Array(_(r)).buffer}(m(e))})),u}}),["encrypt","decrypt","sign","verify"].forEach(function(e){var t=r[e];r[e]=function(n,i,o,a){if(s&&(!o.byteLength||a&&!a.byteLength))throw new Error("Empy input is not allowed");var u,c=[].slice.call(arguments),f=y(n);if(s&&"decrypt"===e&&"AES-GCM"===f.name){var l=n.tagLength>>3;c[2]=(o.buffer||o).slice(0,o.byteLength-l),n.tag=(o.buffer||o).slice(o.byteLength-l)}c[1]=i._key;try{u=t.apply(r,c)}catch(e){return Promise.reject(e)}return s&&(u=new Promise(function(t,r){u.onabort=u.onerror=function(e){r(e)},u.oncomplete=function(r){r=r.target.result;if("encrypt"===e&&r instanceof AesGcmEncryptResult){var n=r.ciphertext,i=r.tag;(r=new Uint8Array(n.byteLength+i.byteLength)).set(new Uint8Array(n),0),r.set(new Uint8Array(i),n.byteLength),r=r.buffer}t(r)}})),u}}),s){var f=r.digest;r.digest=function(e,t){if(!t.byteLength)throw new Error("Empy input is not allowed");var n;try{n=f.call(r,e,t)}catch(e){return Promise.reject(e)}return n=new Promise(function(e,t){n.onabort=n.onerror=function(e){t(e)},n.oncomplete=function(t){e(t.target.result)}})},e.crypto=Object.create(t,{getRandomValues:{value:function(e){return t.getRandomValues(e)}},subtle:{value:r}}),e.CryptoKey=w}a&&(t.subtle=r,e.Crypto=n,e.SubtleCrypto=i,e.CryptoKey=w)}}}function l(e){return btoa(e).replace(/\=+$/,"").replace(/\+/g,"-").replace(/\//g,"_")}function h(e){return e=(e+="===").slice(0,-e.length%4),atob(e.replace(/-/g,"+").replace(/_/g,"/"))}function p(e){for(var t=new Uint8Array(e.length),r=0;r2&&(r=!0,t.shift());var n={ext:!0};switch(t[0][0]){case"1.2.840.113549.1.1.1":var i=["n","e","d","p","q","dp","dq","qi"],o=v(t[1]);r&&o.shift();for(var s=0;se.length)throw new RangeError("Malformed DER");var r,n=e[t.pos++],i=e[t.pos++];if(i>=128){if(i&=127,t.end-t.pos=128){var a=n;n=4;for(t.splice(i,0,a>>24&255,a>>16&255,a>>8&255,255&a);n>1&&!(a>>24);)a<<=8,n--;n<4&&t.splice(i,4-n),n|=128}return t.splice(i-2,2,r,n),t}function w(e,t,r,n){Object.defineProperties(this,{_key:{value:e},type:{value:e.type,enumerable:!0},extractable:{value:void 0===r?e.extractable:r,enumerable:!0},algorithm:{value:void 0===t?e.algorithm:t,enumerable:!0},usages:{value:void 0===n?e.usages:n,enumerable:!0}})}function S(e){return"verify"===e||"encrypt"===e||"wrapKey"===e}function k(e){return"sign"===e||"decrypt"===e||"unwrapKey"===e}}},function(e,t,r){var n=r(898),i=r(906),o=r(439);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(13);r(99),r(448),r(449),r(19),n.random&&n.random.getBytes?e.exports=n.random:function(t){var r={},i=new Array(4),o=n.util.createBuffer();function s(){var e=n.prng.create(r);return e.getBytes=function(t,r){return e.generate(t,r)},e.getBytesSync=function(t){return e.generate(t)},e}r.formatKey=function(e){var t=n.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),n.aes._expandKey(e,!1)},r.formatSeed=function(e){var t=n.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),e},r.cipher=function(e,t){return n.aes._updateBlock(e,t,i,!1),o.putInt32(i[0]),o.putInt32(i[1]),o.putInt32(i[2]),o.putInt32(i[3]),o.getBytes()},r.increment=function(e){return++e[3],e},r.md=n.md.sha256;var a=s(),u=null;if("undefined"!=typeof window){var c=window.crypto||window.msCrypto;c&&c.getRandomValues&&(u=function(e){return c.getRandomValues(e)})}if(n.options.usePureJavaScript||!n.util.isNodejs&&!u){if("undefined"==typeof window||window.document,a.collectInt(+new Date,32),"undefined"!=typeof navigator){var f="";for(var l in navigator)try{"string"==typeof navigator[l]&&(f+=navigator[l])}catch(e){}a.collect(f),f=null}t&&(t().mousemove(function(e){a.collectInt(e.clientX,16),a.collectInt(e.clientY,16)}),t().keypress(function(e){a.collectInt(e.charCode,8)}))}if(n.random)for(var l in a)n.random[l]=a[l];else n.random=a;n.random.createInstance=s,e.exports=n.random}("undefined"!=typeof jQuery?jQuery:null)},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 g(e,t,r,n){return y(e,t,r,n,16)}function m(e,t,r,n){return y(e,t,r,n,32)}function b(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,u=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,c=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,l=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,h=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,p=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,d=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,g=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,m=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,b=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,_=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,w=o,S=s,k=a,E=u,A=c,x=f,I=l,T=h,B=p,C=d,P=y,O=g,R=m,N=b,L=v,j=_,M=0;M<20;M+=2)w^=(i=(R^=(i=(B^=(i=(A^=(i=w+R|0)<<7|i>>>25)+w|0)<<9|i>>>23)+A|0)<<13|i>>>19)+B|0)<<18|i>>>14,x^=(i=(S^=(i=(N^=(i=(C^=(i=x+S|0)<<7|i>>>25)+x|0)<<9|i>>>23)+C|0)<<13|i>>>19)+N|0)<<18|i>>>14,P^=(i=(I^=(i=(k^=(i=(L^=(i=P+I|0)<<7|i>>>25)+P|0)<<9|i>>>23)+L|0)<<13|i>>>19)+k|0)<<18|i>>>14,j^=(i=(O^=(i=(T^=(i=(E^=(i=j+O|0)<<7|i>>>25)+j|0)<<9|i>>>23)+E|0)<<13|i>>>19)+T|0)<<18|i>>>14,w^=(i=(E^=(i=(k^=(i=(S^=(i=w+E|0)<<7|i>>>25)+w|0)<<9|i>>>23)+S|0)<<13|i>>>19)+k|0)<<18|i>>>14,x^=(i=(A^=(i=(T^=(i=(I^=(i=x+A|0)<<7|i>>>25)+x|0)<<9|i>>>23)+I|0)<<13|i>>>19)+T|0)<<18|i>>>14,P^=(i=(C^=(i=(B^=(i=(O^=(i=P+C|0)<<7|i>>>25)+P|0)<<9|i>>>23)+O|0)<<13|i>>>19)+B|0)<<18|i>>>14,j^=(i=(L^=(i=(N^=(i=(R^=(i=j+L|0)<<7|i>>>25)+j|0)<<9|i>>>23)+R|0)<<13|i>>>19)+N|0)<<18|i>>>14;w=w+o|0,S=S+s|0,k=k+a|0,E=E+u|0,A=A+c|0,x=x+f|0,I=I+l|0,T=T+h|0,B=B+p|0,C=C+d|0,P=P+y|0,O=O+g|0,R=R+m|0,N=N+b|0,L=L+v|0,j=j+_|0,e[0]=w>>>0&255,e[1]=w>>>8&255,e[2]=w>>>16&255,e[3]=w>>>24&255,e[4]=S>>>0&255,e[5]=S>>>8&255,e[6]=S>>>16&255,e[7]=S>>>24&255,e[8]=k>>>0&255,e[9]=k>>>8&255,e[10]=k>>>16&255,e[11]=k>>>24&255,e[12]=E>>>0&255,e[13]=E>>>8&255,e[14]=E>>>16&255,e[15]=E>>>24&255,e[16]=A>>>0&255,e[17]=A>>>8&255,e[18]=A>>>16&255,e[19]=A>>>24&255,e[20]=x>>>0&255,e[21]=x>>>8&255,e[22]=x>>>16&255,e[23]=x>>>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]=B>>>0&255,e[33]=B>>>8&255,e[34]=B>>>16&255,e[35]=B>>>24&255,e[36]=C>>>0&255,e[37]=C>>>8&255,e[38]=C>>>16&255,e[39]=C>>>24&255,e[40]=P>>>0&255,e[41]=P>>>8&255,e[42]=P>>>16&255,e[43]=P>>>24&255,e[44]=O>>>0&255,e[45]=O>>>8&255,e[46]=O>>>16&255,e[47]=O>>>24&255,e[48]=R>>>0&255,e[49]=R>>>8&255,e[50]=R>>>16&255,e[51]=R>>>24&255,e[52]=N>>>0&255,e[53]=N>>>8&255,e[54]=N>>>16&255,e[55]=N>>>24&255,e[56]=L>>>0&255,e[57]=L>>>8&255,e[58]=L>>>16&255,e[59]=L>>>24&255,e[60]=j>>>0&255,e[61]=j>>>8&255,e[62]=j>>>16&255,e[63]=j>>>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,u=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,c=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,l=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,h=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,p=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,d=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,g=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,m=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,b=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,_=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,w=0;w<20;w+=2)o^=(i=(m^=(i=(p^=(i=(c^=(i=o+m|0)<<7|i>>>25)+o|0)<<9|i>>>23)+c|0)<<13|i>>>19)+p|0)<<18|i>>>14,f^=(i=(s^=(i=(b^=(i=(d^=(i=f+s|0)<<7|i>>>25)+f|0)<<9|i>>>23)+d|0)<<13|i>>>19)+b|0)<<18|i>>>14,y^=(i=(l^=(i=(a^=(i=(v^=(i=y+l|0)<<7|i>>>25)+y|0)<<9|i>>>23)+v|0)<<13|i>>>19)+a|0)<<18|i>>>14,_^=(i=(g^=(i=(h^=(i=(u^=(i=_+g|0)<<7|i>>>25)+_|0)<<9|i>>>23)+u|0)<<13|i>>>19)+h|0)<<18|i>>>14,o^=(i=(u^=(i=(a^=(i=(s^=(i=o+u|0)<<7|i>>>25)+o|0)<<9|i>>>23)+s|0)<<13|i>>>19)+a|0)<<18|i>>>14,f^=(i=(c^=(i=(h^=(i=(l^=(i=f+c|0)<<7|i>>>25)+f|0)<<9|i>>>23)+l|0)<<13|i>>>19)+h|0)<<18|i>>>14,y^=(i=(d^=(i=(p^=(i=(g^=(i=y+d|0)<<7|i>>>25)+y|0)<<9|i>>>23)+g|0)<<13|i>>>19)+p|0)<<18|i>>>14,_^=(i=(v^=(i=(b^=(i=(m^=(i=_+v|0)<<7|i>>>25)+_|0)<<9|i>>>23)+m|0)<<13|i>>>19)+b|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]=_>>>0&255,e[13]=_>>>8&255,e[14]=_>>>16&255,e[15]=_>>>24&255,e[16]=l>>>0&255,e[17]=l>>>8&255,e[18]=l>>>16&255,e[19]=l>>>24&255,e[20]=h>>>0&255,e[21]=h>>>8&255,e[22]=h>>>16&255,e[23]=h>>>24&255,e[24]=p>>>0&255,e[25]=p>>>8&255,e[26]=p>>>16&255,e[27]=p>>>24&255,e[28]=d>>>0&255,e[29]=d>>>8&255,e[30]=d>>>16&255,e[31]=d>>>24&255}(e,t,r,n)}var _=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function w(e,t,r,n,i,o,s){var a,u,c=new Uint8Array(16),f=new Uint8Array(64);for(u=0;u<16;u++)c[u]=0;for(u=0;u<8;u++)c[u]=o[u];for(;i>=64;){for(b(f,c,s,_),u=0;u<64;u++)e[t+u]=r[n+u]^f[u];for(a=1,u=8;u<16;u++)a=a+(255&c[u])|0,c[u]=255&a,a>>>=8;i-=64,t+=64,n+=64}if(i>0)for(b(f,c,s,_),u=0;u=64;){for(b(u,a,i,_),s=0;s<64;s++)e[t+s]=u[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(b(u,a,i,_),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),u=255&e[14]|(255&e[15])<<8,this.r[8]=8191&(a>>>8|u<<8),this.r[9]=u>>>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 x(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 x(s,0,r,n,i,o),g(e,t,s,0)}function T(e,t,r,n,i){var o;if(r<32)return-1;for(E(e,0,t,0,r,n,i),x(e,16,e,32,r-32,e),o=0;o<16;o++)e[o]=0;return 0}function B(e,t,r,n,i){var o,s=new Uint8Array(32);if(r<32)return-1;if(k(s,0,32,n,i),0!==I(t,16,t,32,r-32,s))return-1;for(E(e,0,t,0,r,n,i),o=0;o<32;o++)e[o]=0;return 0}function C(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function P(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 O(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 R(e,r){var n,i,o,s=t(),a=t();for(n=0;n<16;n++)a[n]=r[n];for(P(a),P(a),P(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,O(a,s,1-o)}for(n=0;n<16;n++)e[2*n]=255&a[n],e[2*n+1]=a[n]>>8}function N(e,t){var r=new Uint8Array(32),n=new Uint8Array(32);return R(r,e),R(n,t),m(r,0,n,0)}function L(e){var t=new Uint8Array(32);return R(t,e),1&t[0]}function j(e,t){var r;for(r=0;r<16;r++)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}function M(e,t,r){for(var n=0;n<16;n++)e[n]=t[n]+r[n]}function K(e,t,r){for(var n=0;n<16;n++)e[n]=t[n]-r[n]}function D(e,t,r){var n,i,o=0,s=0,a=0,u=0,c=0,f=0,l=0,h=0,p=0,d=0,y=0,g=0,m=0,b=0,v=0,_=0,w=0,S=0,k=0,E=0,A=0,x=0,I=0,T=0,B=0,C=0,P=0,O=0,R=0,N=0,L=0,j=r[0],M=r[1],K=r[2],D=r[3],U=r[4],F=r[5],q=r[6],H=r[7],z=r[8],V=r[9],G=r[10],W=r[11],$=r[12],Y=r[13],J=r[14],X=r[15];o+=(n=t[0])*j,s+=n*M,a+=n*K,u+=n*D,c+=n*U,f+=n*F,l+=n*q,h+=n*H,p+=n*z,d+=n*V,y+=n*G,g+=n*W,m+=n*$,b+=n*Y,v+=n*J,_+=n*X,s+=(n=t[1])*j,a+=n*M,u+=n*K,c+=n*D,f+=n*U,l+=n*F,h+=n*q,p+=n*H,d+=n*z,y+=n*V,g+=n*G,m+=n*W,b+=n*$,v+=n*Y,_+=n*J,w+=n*X,a+=(n=t[2])*j,u+=n*M,c+=n*K,f+=n*D,l+=n*U,h+=n*F,p+=n*q,d+=n*H,y+=n*z,g+=n*V,m+=n*G,b+=n*W,v+=n*$,_+=n*Y,w+=n*J,S+=n*X,u+=(n=t[3])*j,c+=n*M,f+=n*K,l+=n*D,h+=n*U,p+=n*F,d+=n*q,y+=n*H,g+=n*z,m+=n*V,b+=n*G,v+=n*W,_+=n*$,w+=n*Y,S+=n*J,k+=n*X,c+=(n=t[4])*j,f+=n*M,l+=n*K,h+=n*D,p+=n*U,d+=n*F,y+=n*q,g+=n*H,m+=n*z,b+=n*V,v+=n*G,_+=n*W,w+=n*$,S+=n*Y,k+=n*J,E+=n*X,f+=(n=t[5])*j,l+=n*M,h+=n*K,p+=n*D,d+=n*U,y+=n*F,g+=n*q,m+=n*H,b+=n*z,v+=n*V,_+=n*G,w+=n*W,S+=n*$,k+=n*Y,E+=n*J,A+=n*X,l+=(n=t[6])*j,h+=n*M,p+=n*K,d+=n*D,y+=n*U,g+=n*F,m+=n*q,b+=n*H,v+=n*z,_+=n*V,w+=n*G,S+=n*W,k+=n*$,E+=n*Y,A+=n*J,x+=n*X,h+=(n=t[7])*j,p+=n*M,d+=n*K,y+=n*D,g+=n*U,m+=n*F,b+=n*q,v+=n*H,_+=n*z,w+=n*V,S+=n*G,k+=n*W,E+=n*$,A+=n*Y,x+=n*J,I+=n*X,p+=(n=t[8])*j,d+=n*M,y+=n*K,g+=n*D,m+=n*U,b+=n*F,v+=n*q,_+=n*H,w+=n*z,S+=n*V,k+=n*G,E+=n*W,A+=n*$,x+=n*Y,I+=n*J,T+=n*X,d+=(n=t[9])*j,y+=n*M,g+=n*K,m+=n*D,b+=n*U,v+=n*F,_+=n*q,w+=n*H,S+=n*z,k+=n*V,E+=n*G,A+=n*W,x+=n*$,I+=n*Y,T+=n*J,B+=n*X,y+=(n=t[10])*j,g+=n*M,m+=n*K,b+=n*D,v+=n*U,_+=n*F,w+=n*q,S+=n*H,k+=n*z,E+=n*V,A+=n*G,x+=n*W,I+=n*$,T+=n*Y,B+=n*J,C+=n*X,g+=(n=t[11])*j,m+=n*M,b+=n*K,v+=n*D,_+=n*U,w+=n*F,S+=n*q,k+=n*H,E+=n*z,A+=n*V,x+=n*G,I+=n*W,T+=n*$,B+=n*Y,C+=n*J,P+=n*X,m+=(n=t[12])*j,b+=n*M,v+=n*K,_+=n*D,w+=n*U,S+=n*F,k+=n*q,E+=n*H,A+=n*z,x+=n*V,I+=n*G,T+=n*W,B+=n*$,C+=n*Y,P+=n*J,O+=n*X,b+=(n=t[13])*j,v+=n*M,_+=n*K,w+=n*D,S+=n*U,k+=n*F,E+=n*q,A+=n*H,x+=n*z,I+=n*V,T+=n*G,B+=n*W,C+=n*$,P+=n*Y,O+=n*J,R+=n*X,v+=(n=t[14])*j,_+=n*M,w+=n*K,S+=n*D,k+=n*U,E+=n*F,A+=n*q,x+=n*H,I+=n*z,T+=n*V,B+=n*G,C+=n*W,P+=n*$,O+=n*Y,R+=n*J,N+=n*X,_+=(n=t[15])*j,s+=38*(S+=n*K),a+=38*(k+=n*D),u+=38*(E+=n*U),c+=38*(A+=n*F),f+=38*(x+=n*q),l+=38*(I+=n*H),h+=38*(T+=n*z),p+=38*(B+=n*V),d+=38*(C+=n*G),y+=38*(P+=n*W),g+=38*(O+=n*$),m+=38*(R+=n*Y),b+=38*(N+=n*J),v+=38*(L+=n*X),o=(n=(o+=38*(w+=n*M))+(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)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+i+65535)-65536*(i=Math.floor(n/65536)),f=(n=f+i+65535)-65536*(i=Math.floor(n/65536)),l=(n=l+i+65535)-65536*(i=Math.floor(n/65536)),h=(n=h+i+65535)-65536*(i=Math.floor(n/65536)),p=(n=p+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+i+65535)-65536*(i=Math.floor(n/65536)),y=(n=y+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)),b=(n=b+i+65535)-65536*(i=Math.floor(n/65536)),v=(n=v+i+65535)-65536*(i=Math.floor(n/65536)),_=(n=_+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)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+i+65535)-65536*(i=Math.floor(n/65536)),f=(n=f+i+65535)-65536*(i=Math.floor(n/65536)),l=(n=l+i+65535)-65536*(i=Math.floor(n/65536)),h=(n=h+i+65535)-65536*(i=Math.floor(n/65536)),p=(n=p+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+i+65535)-65536*(i=Math.floor(n/65536)),y=(n=y+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)),b=(n=b+i+65535)-65536*(i=Math.floor(n/65536)),v=(n=v+i+65535)-65536*(i=Math.floor(n/65536)),_=(n=_+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]=u,e[4]=c,e[5]=f,e[6]=l,e[7]=h,e[8]=p,e[9]=d,e[10]=y,e[11]=g,e[12]=m,e[13]=b,e[14]=v,e[15]=_}function U(e,t){D(e,t,t)}function F(e,r){var n,i=t();for(n=0;n<16;n++)i[n]=r[n];for(n=253;n>=0;n--)U(i,i),2!==n&&4!==n&&D(i,i,r);for(n=0;n<16;n++)e[n]=i[n]}function q(e,r,n){var i,o,s=new Uint8Array(32),a=new Float64Array(80),c=t(),f=t(),l=t(),h=t(),p=t(),d=t();for(o=0;o<31;o++)s[o]=r[o];for(s[31]=127&r[31]|64,s[0]&=248,j(a,n),o=0;o<16;o++)f[o]=a[o],h[o]=c[o]=l[o]=0;for(c[0]=h[0]=1,o=254;o>=0;--o)O(c,f,i=s[o>>>3]>>>(7&o)&1),O(l,h,i),M(p,c,l),K(c,c,l),M(l,f,h),K(f,f,h),U(h,p),U(d,c),D(c,l,c),D(l,f,p),M(p,c,l),K(c,c,l),U(f,c),K(l,h,d),D(c,l,u),M(c,c,h),D(l,l,c),D(c,h,d),D(h,f,a),U(f,p),O(c,f,i),O(l,h,i);for(o=0;o<16;o++)a[o+16]=c[o],a[o+32]=l[o],a[o+48]=f[o],a[o+64]=h[o];var y=a.subarray(32),g=a.subarray(16);return F(y,y),D(g,g,y),R(e,g),0}function H(e,t){return q(e,t,o)}function z(e,t){return n(t,32),H(e,t)}function V(e,t,r){var n=new Uint8Array(32);return q(n,r,t),v(e,i,n,_)}A.prototype.blocks=function(e,t,r){for(var n,i,o,s,a,u,c,f,l,h,p,d,y,g,m,b,v,_,w,S=this.fin?0:2048,k=this.h[0],E=this.h[1],A=this.h[2],x=this.h[3],I=this.h[4],T=this.h[5],B=this.h[6],C=this.h[7],P=this.h[8],O=this.h[9],R=this.r[0],N=this.r[1],L=this.r[2],j=this.r[3],M=this.r[4],K=this.r[5],D=this.r[6],U=this.r[7],F=this.r[8],q=this.r[9];r>=16;)k+=8191&(n=255&e[t+0]|(255&e[t+1])<<8),E+=8191&(n>>>13|(i=255&e[t+2]|(255&e[t+3])<<8)<<3),A+=8191&(i>>>10|(o=255&e[t+4]|(255&e[t+5])<<8)<<6),x+=8191&(o>>>7|(s=255&e[t+6]|(255&e[t+7])<<8)<<9),I+=8191&(s>>>4|(a=255&e[t+8]|(255&e[t+9])<<8)<<12),T+=a>>>1&8191,B+=8191&(a>>>14|(u=255&e[t+10]|(255&e[t+11])<<8)<<2),C+=8191&(u>>>11|(c=255&e[t+12]|(255&e[t+13])<<8)<<5),f=255&e[t+14]|(255&e[t+15])<<8,h=l=0,h+=k*R,h+=E*(5*q),h+=A*(5*F),h+=x*(5*U),l=(h+=I*(5*D))>>>13,h&=8191,h+=T*(5*K),h+=B*(5*M),h+=C*(5*j),h+=(P+=8191&(c>>>8|f<<8))*(5*L),p=l+=(h+=(O+=f>>>5|S)*(5*N))>>>13,p+=k*N,p+=E*R,p+=A*(5*q),p+=x*(5*F),l=(p+=I*(5*U))>>>13,p&=8191,p+=T*(5*D),p+=B*(5*K),p+=C*(5*M),p+=P*(5*j),l+=(p+=O*(5*L))>>>13,p&=8191,d=l,d+=k*L,d+=E*N,d+=A*R,d+=x*(5*q),l=(d+=I*(5*F))>>>13,d&=8191,d+=T*(5*U),d+=B*(5*D),d+=C*(5*K),d+=P*(5*M),y=l+=(d+=O*(5*j))>>>13,y+=k*j,y+=E*L,y+=A*N,y+=x*R,l=(y+=I*(5*q))>>>13,y&=8191,y+=T*(5*F),y+=B*(5*U),y+=C*(5*D),y+=P*(5*K),g=l+=(y+=O*(5*M))>>>13,g+=k*M,g+=E*j,g+=A*L,g+=x*N,l=(g+=I*R)>>>13,g&=8191,g+=T*(5*q),g+=B*(5*F),g+=C*(5*U),g+=P*(5*D),m=l+=(g+=O*(5*K))>>>13,m+=k*K,m+=E*M,m+=A*j,m+=x*L,l=(m+=I*N)>>>13,m&=8191,m+=T*R,m+=B*(5*q),m+=C*(5*F),m+=P*(5*U),b=l+=(m+=O*(5*D))>>>13,b+=k*D,b+=E*K,b+=A*M,b+=x*j,l=(b+=I*L)>>>13,b&=8191,b+=T*N,b+=B*R,b+=C*(5*q),b+=P*(5*F),v=l+=(b+=O*(5*U))>>>13,v+=k*U,v+=E*D,v+=A*K,v+=x*M,l=(v+=I*j)>>>13,v&=8191,v+=T*L,v+=B*N,v+=C*R,v+=P*(5*q),_=l+=(v+=O*(5*F))>>>13,_+=k*F,_+=E*U,_+=A*D,_+=x*K,l=(_+=I*M)>>>13,_&=8191,_+=T*j,_+=B*L,_+=C*N,_+=P*R,w=l+=(_+=O*(5*q))>>>13,w+=k*q,w+=E*F,w+=A*U,w+=x*D,l=(w+=I*K)>>>13,w&=8191,w+=T*M,w+=B*j,w+=C*L,w+=P*N,k=h=8191&(l=(l=((l+=(w+=O*R)>>>13)<<2)+l|0)+(h&=8191)|0),E=p+=l>>>=13,A=d&=8191,x=y&=8191,I=g&=8191,T=m&=8191,B=b&=8191,C=v&=8191,P=_&=8191,O=w&=8191,t+=16,r-=16;this.h[0]=k,this.h[1]=E,this.h[2]=A,this.h[3]=x,this.h[4]=I,this.h[5]=T,this.h[6]=B,this.h[7]=C,this.h[8]=P,this.h[9]=O},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++)k=8*S+Y,C[S]=r[k+0]<<24|r[k+1]<<16|r[k+2]<<8|r[k+3],P[S]=r[k+4]<<24|r[k+5]<<16|r[k+6]<<8|r[k+7];for(S=0;S<80;S++)if(i=O,o=R,s=N,a=L,u=j,c=M,f=K,l=D,h=U,p=F,d=q,y=H,g=z,m=V,b=G,v=W,x=65535&(A=W),I=A>>>16,T=65535&(E=D),B=E>>>16,x+=65535&(A=(z>>>14|j<<18)^(z>>>18|j<<14)^(j>>>9|z<<23)),I+=A>>>16,T+=65535&(E=(j>>>14|z<<18)^(j>>>18|z<<14)^(z>>>9|j<<23)),B+=E>>>16,x+=65535&(A=z&V^~z&G),I+=A>>>16,T+=65535&(E=j&M^~j&K),B+=E>>>16,E=$[2*S],x+=65535&(A=$[2*S+1]),I+=A>>>16,T+=65535&E,B+=E>>>16,E=C[S%16],I+=(A=P[S%16])>>>16,T+=65535&E,B+=E>>>16,T+=(I+=(x+=65535&A)>>>16)>>>16,x=65535&(A=w=65535&x|I<<16),I=A>>>16,T=65535&(E=_=65535&T|(B+=T>>>16)<<16),B=E>>>16,x+=65535&(A=(U>>>28|O<<4)^(O>>>2|U<<30)^(O>>>7|U<<25)),I+=A>>>16,T+=65535&(E=(O>>>28|U<<4)^(U>>>2|O<<30)^(U>>>7|O<<25)),B+=E>>>16,I+=(A=U&F^U&q^F&q)>>>16,T+=65535&(E=O&R^O&N^R&N),B+=E>>>16,l=65535&(T+=(I+=(x+=65535&A)>>>16)>>>16)|(B+=T>>>16)<<16,v=65535&x|I<<16,x=65535&(A=y),I=A>>>16,T=65535&(E=a),B=E>>>16,I+=(A=w)>>>16,T+=65535&(E=_),B+=E>>>16,R=i,N=o,L=s,j=a=65535&(T+=(I+=(x+=65535&A)>>>16)>>>16)|(B+=T>>>16)<<16,M=u,K=c,D=f,O=l,F=h,q=p,H=d,z=y=65535&x|I<<16,V=g,G=m,W=b,U=v,S%16==15)for(k=0;k<16;k++)E=C[k],x=65535&(A=P[k]),I=A>>>16,T=65535&E,B=E>>>16,E=C[(k+9)%16],x+=65535&(A=P[(k+9)%16]),I+=A>>>16,T+=65535&E,B+=E>>>16,_=C[(k+1)%16],x+=65535&(A=((w=P[(k+1)%16])>>>1|_<<31)^(w>>>8|_<<24)^(w>>>7|_<<25)),I+=A>>>16,T+=65535&(E=(_>>>1|w<<31)^(_>>>8|w<<24)^_>>>7),B+=E>>>16,_=C[(k+14)%16],I+=(A=((w=P[(k+14)%16])>>>19|_<<13)^(_>>>29|w<<3)^(w>>>6|_<<26))>>>16,T+=65535&(E=(_>>>19|w<<13)^(w>>>29|_<<3)^_>>>6),B+=E>>>16,B+=(T+=(I+=(x+=65535&A)>>>16)>>>16)>>>16,C[k]=65535&T|B<<16,P[k]=65535&x|I<<16;x=65535&(A=U),I=A>>>16,T=65535&(E=O),B=E>>>16,E=e[0],I+=(A=t[0])>>>16,T+=65535&E,B+=E>>>16,B+=(T+=(I+=(x+=65535&A)>>>16)>>>16)>>>16,e[0]=O=65535&T|B<<16,t[0]=U=65535&x|I<<16,x=65535&(A=F),I=A>>>16,T=65535&(E=R),B=E>>>16,E=e[1],I+=(A=t[1])>>>16,T+=65535&E,B+=E>>>16,B+=(T+=(I+=(x+=65535&A)>>>16)>>>16)>>>16,e[1]=R=65535&T|B<<16,t[1]=F=65535&x|I<<16,x=65535&(A=q),I=A>>>16,T=65535&(E=N),B=E>>>16,E=e[2],I+=(A=t[2])>>>16,T+=65535&E,B+=E>>>16,B+=(T+=(I+=(x+=65535&A)>>>16)>>>16)>>>16,e[2]=N=65535&T|B<<16,t[2]=q=65535&x|I<<16,x=65535&(A=H),I=A>>>16,T=65535&(E=L),B=E>>>16,E=e[3],I+=(A=t[3])>>>16,T+=65535&E,B+=E>>>16,B+=(T+=(I+=(x+=65535&A)>>>16)>>>16)>>>16,e[3]=L=65535&T|B<<16,t[3]=H=65535&x|I<<16,x=65535&(A=z),I=A>>>16,T=65535&(E=j),B=E>>>16,E=e[4],I+=(A=t[4])>>>16,T+=65535&E,B+=E>>>16,B+=(T+=(I+=(x+=65535&A)>>>16)>>>16)>>>16,e[4]=j=65535&T|B<<16,t[4]=z=65535&x|I<<16,x=65535&(A=V),I=A>>>16,T=65535&(E=M),B=E>>>16,E=e[5],I+=(A=t[5])>>>16,T+=65535&E,B+=E>>>16,B+=(T+=(I+=(x+=65535&A)>>>16)>>>16)>>>16,e[5]=M=65535&T|B<<16,t[5]=V=65535&x|I<<16,x=65535&(A=G),I=A>>>16,T=65535&(E=K),B=E>>>16,E=e[6],I+=(A=t[6])>>>16,T+=65535&E,B+=E>>>16,B+=(T+=(I+=(x+=65535&A)>>>16)>>>16)>>>16,e[6]=K=65535&T|B<<16,t[6]=G=65535&x|I<<16,x=65535&(A=W),I=A>>>16,T=65535&(E=D),B=E>>>16,E=e[7],I+=(A=t[7])>>>16,T+=65535&E,B+=E>>>16,B+=(T+=(I+=(x+=65535&A)>>>16)>>>16)>>>16,e[7]=D=65535&T|B<<16,t[7]=W=65535&x|I<<16,Y+=128,n-=128}return n}function J(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,Y(i,o,t,r),r%=128,n=0;n=0;--i)Z(e,t,n=r[i/8|0]>>(7&i)&1),X(t,e),X(e,e),Z(e,t,n)}function te(e,r){var n=[t(),t(),t(),t()];C(n[0],l),C(n[1],h),C(n[2],a),D(n[3],l,h),ee(e,n,r)}function re(e,r,i){var o,s=new Uint8Array(64),a=[t(),t(),t(),t()];for(i||n(r,32),J(s,r,32),s[0]&=248,s[31]&=127,s[31]|=64,te(a,s),Q(e,a),o=0;o<32;o++)r[o+32]=e[o];return 0}var ne=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 ie(e,t){var r,n,i,o;for(n=63;n>=32;--n){for(r=0,i=n-32,o=n-12;i>8,t[i]-=256*r;t[i]+=r,t[n]=0}for(r=0,i=0;i<32;i++)t[i]+=r-(t[31]>>4)*ne[i],r=t[i]>>8,t[i]&=255;for(i=0;i<32;i++)t[i]-=r*ne[i];for(n=0;n<32;n++)t[n+1]+=t[n]>>8,e[n]=255&t[n]}function oe(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;ie(e,r)}function se(e,r,n,i){var o,s,a=new Uint8Array(64),u=new Uint8Array(64),c=new Uint8Array(64),f=new Float64Array(64),l=[t(),t(),t(),t()];J(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var h=n+64;for(o=0;o=0;n--)U(i,i),1!==n&&D(i,i,r);for(n=0;n<16;n++)e[n]=i[n]}(n,n),D(n,n,o),D(n,n,u),D(n,n,u),D(e[0],n,u),U(i,e[0]),D(i,i,u),N(i,o)&&D(e[0],e[0],p),U(i,e[0]),D(i,i,u),N(i,o)?-1:(L(e[0])===r[31]>>7&&K(e[0],s,e[0]),D(e[3],e[0],e[1]),0)}function ue(e,r,n,i){var o,s=new Uint8Array(32),a=new Uint8Array(64),u=[t(),t(),t(),t()],c=[t(),t(),t(),t()];if(-1,n<64)return-1;if(ae(c,i))return-1;for(o=0;o=0},e.sign.keyPair=function(){var e=new Uint8Array(32),t=new Uint8Array(64);return re(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if(ye(e),64!==e.length)throw new Error("bad secret key size");for(var t=new Uint8Array(32),r=0;r{i=i||r(937)(t);class o{constructor(e){i.validatePublicKey(e),this._key=e}verify(e,t,r){a(r),i.hashAndVerify(this._key,t,e,r)}marshal(){return i.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){a(e),n(this.bytes,"sha2-256",e)}}class s{constructor(e,t){this._key=e,this._publicKey=t||i.computePublicKey(e),i.validatePrivateKey(this._key),i.validatePublicKey(this._publicKey)}sign(e,t){a(t),i.hashAndSign(this._key,e,t)}get public(){return new o(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){a(e),n(this.bytes,"sha2-256",e)}}function a(e){if("function"!=typeof e)throw new Error("callback is required")}return{Secp256k1PublicKey:o,Secp256k1PrivateKey:s,unmarshalSecp256k1PrivateKey:function(e,t){t(null,new s(e),null)},unmarshalSecp256k1PublicKey:function(e){return new o(e)},generateKeyPair:function(e,t){void 0===t&&"function"==typeof e&&(t=e),a(t),i.generateKey((e,r)=>{if(e)return t(e);let n;try{n=new s(r)}catch(e){return t(e)}t(null,n)})}}})},function(e,t,r){"use strict";e.exports=function e(t){var r=arguments.length;if("function"==typeof t&&1===t.length){for(var n=new Array(r),i=0;i>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function s(e){return 1===e.length?"0"+e:e}function a(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),n=0;n>8,s=255&i;o?r.push(o,s):r.push(s)}else for(n=0;n>>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 u=0,c=t;return u+=(c=c+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,u,c){var f=0,l=t;return f+=(l=l+n>>>0)>>0)>>0)>>0)>>0},t.sum64_5_lo=function(e,t,r,n,i,o,s,a,u,c){return t+n+o+a+c>>>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";var n=t;n.version=r(865).version,n.utils=r(866),n.rand=r(867),n.hmacDRBG=r(868),n.curve=r(175),n.curves=r(878),n.ec=r(880)},function(e,t,r){"use strict";(function(t){var n=r(32),i=r(109),o=r(38),s=r(29),a=r(96),u=r(18),c=r(21);function f(e,t){if(!(this instanceof f))return new f(e,t);if(c.checkArgument(e,"First argument is required, please include public key data."),e instanceof f)return e;t=t||{};var r=this._classifyArgs(e,t);return r.point.validate(),s.defineImmutable(this,{point:r.point,compressed:r.compressed,network:r.network||a.defaultNetwork}),this}f.prototype._classifyArgs=function(e,r){var n={compressed:u.isUndefined(r.compressed)||r.compressed};if(e instanceof i)n.point=e;else if(e.x&&e.y)n=f._transformObject(e);else if("string"==typeof e)n=f._transformDER(new t(e,"hex"));else if(f._isBuffer(e))n=f._transformDER(e);else{if(!f._isPrivateKey(e))throw new TypeError("First argument is an unrecognized data format.");n=f._transformPrivateKey(e)}return n.network||(n.network=u.isUndefined(r.network)?void 0:a.get(r.network)),n},f._isPrivateKey=function(e){return e instanceof r(176)},f._isBuffer=function(e){return e instanceof t||e instanceof Uint8Array},f._transformPrivateKey=function(e){c.checkArgument(f._isPrivateKey(e),"Must be an instance of PrivateKey");var t={};return t.point=i.getG().mul(e.bn),t.compressed=e.compressed,t.network=e.network,t},f._transformDER=function(e,t){c.checkArgument(f._isBuffer(e),"Must be a hex buffer of DER encoded public key");var r,o,s,a,l={};if(t=!!u.isUndefined(t)||t,4!==e[0]&&(t||6!==e[0]&&7!==e[0]))if(3===e[0])s=e.slice(1),r=new n(s),(l=f._transformX(!0,r)).compressed=!0;else{if(2!==e[0])throw new TypeError("Invalid DER format public key");s=e.slice(1),r=new n(s),(l=f._transformX(!1,r)).compressed=!0}else{if(s=e.slice(1,33),a=e.slice(33,65),32!==s.length||32!==a.length||65!==e.length)throw new TypeError("Length of x and y must be 32 bytes");r=new n(s),o=new n(a),l.point=new i(r,o),l.compressed=!1}return l},f._transformX=function(e,t){c.checkArgument("boolean"==typeof e,"Must specify whether y is odd or not (true or false)");var r={};return r.point=i.fromX(e,t),r},f._transformObject=function(e){var t=new n(e.x,"hex"),r=new n(e.y,"hex");return new f(new i(t,r),{compressed:e.compressed})},f.fromPrivateKey=function(e){c.checkArgument(f._isPrivateKey(e),"Must be an instance of PrivateKey");var t=f._transformPrivateKey(e);return new f(t.point,{compressed:t.compressed,network:t.network})},f.fromDER=f.fromBuffer=function(e,t){c.checkArgument(f._isBuffer(e),"Must be a hex buffer of DER encoded public key");var r=f._transformDER(e,t);return new f(r.point,{compressed:r.compressed})},f.fromPoint=function(e,t){return c.checkArgument(e instanceof i,"First argument must be an instance of Point."),new f(e,{compressed:t})},f.fromString=function(e,r){var n=new t(e,r||"hex"),i=f._transformDER(n);return new f(i.point,{compressed:i.compressed})},f.fromX=function(e,t){var r=f._transformX(e,t);return new f(r.point,{compressed:r.compressed})},f.getValidationError=function(e){var t;try{new f(e)}catch(e){t=e}return t},f.isValid=function(e){return!f.getValidationError(e)},f.prototype.toObject=f.prototype.toJSON=function(){return{x:this.point.getX().toString("hex",2),y:this.point.getY().toString("hex",2),compressed:this.compressed}},f.prototype.toBuffer=f.prototype.toDER=function(){var e,r=this.point.getX(),n=this.point.getY(),i=r.toBuffer({size:32}),o=n.toBuffer({size:32});if(this.compressed){var s=o[o.length-1]%2;return e=new t(s?[3]:[2]),t.concat([e,i])}return e=new t([4]),t.concat([e,i,o])},f.prototype._getID=function(){return o.sha256ripemd160(this.toBuffer())},f.prototype.toAddress=function(e){return r(97).fromPublicKey(this,e||this.network)},f.prototype.toString=function(){return this.toDER().toString("hex")},f.prototype.inspect=function(){return""},e.exports=f}).call(this,r(0).Buffer)},function(e,t,r){(function(e){!function(e,t){"use strict";function r(e,t){if(!e)throw new Error(t||"Assertion failed")}function n(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function i(e,t,r){if(null!==e&&"object"==typeof e&&Array.isArray(e.words))return e;this.sign=!1,this.words=null,this.length=0,this.red=null,"le"!==t&&"be"!==t||(r=t,t=10),null!==e&&this._init(e||0,t||10,r||"be")}function o(e,t,r){for(var n=0,i=Math.min(e.length,r),o=t;o=49&&s<=54?s-49+10:s>=17&&s<=22?s-17+10:15&s}return n}function s(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}"object"==typeof e?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26,i.prototype._init=function(e,t,n){if("number"==typeof e)return e<0&&(this.sign=!0,e=-e),void(e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(r(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3));if("object"==typeof e)return this._initArray(e,t,n);"hex"===t&&(t=16),r(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.sign=!0),this.strip()},i.prototype._initArray=function(e,t,n){if(r("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3){var a=e[i]|e[i-1]<<8|e[i-2]<<16;this.words[s]|=a<>>26-o&67108863,(o+=24)>=26&&(o-=26,s++)}}else if("le"===n)for(i=0,s=0;i>>26-o&67108863,(o+=24)>=26&&(o-=26,s++)}return this.strip()},i.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6){var s=o(e,r,r+6);this.words[i]|=s<>>26-n&4194303,(n+=24)>=26&&(n-=26,i++)}if(r+6!==t){s=o(e,t,r+6);this.words[i]|=s<>>26-n&4194303}this.strip()},i.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,a=o%n,u=Math.min(o,o-a)+r,c=0,f=r;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.sign=!1),this},i.prototype.inspect=function(){return(this.red?""};var a=["","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"],u=[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],c=[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];i.prototype.toString=function(e,t){if(16===(e=e||10)||"hex"===e){for(var n="",i=0,o=(t=0|t||1,0),s=0;s>>24-i&16777215)||s!==this.length-1?a[6-l.length]+l+n:l+n,(i+=2)>=26&&(i-=26,s--)}for(0!==o&&(n=o.toString(16)+n);n.length%t!=0;)n="0"+n;return this.sign&&(n="-"+n),n}if(e===(0|e)&&e>=2&&e<=36){var h=u[e],p=c[e],d=(n="",this.clone());for(d.sign=!1;0!==d.cmpn(0);){var y=d.modn(p).toString(e);n=0!==(d=d.idivn(p)).cmpn(0)?a[h-y.length]+y+n:y+n}return 0===this.cmpn(0)&&(n="0"+n),this.sign&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toArray=function(){this.strip();var e=new Array(this.byteLength());e[0]=0;for(var t=this.clone(),r=0;0!==t.cmpn(0);r++){var n=t.andln(255);t.ishrn(8),e[e.length-r-1]=n}return e},Math.clz32?i.prototype._countBits=function(e){return 32-Math.clz32(e)}:i.prototype._countBits=function(e){var t=e,r=0;return t>=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},i.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},i.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(0===this.cmpn(0))return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},i.prototype.iand=function(e){var t;this.sign=this.sign&&e.sign,t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},i.prototype.ixor=function(e){var t,r;this.sign=this.sign||e.sign,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)},i.prototype.setn=function(e,t){r("number"==typeof e&&e>=0);for(var n=e/26|0,i=e%26;this.length<=n;)this.words[this.length++]=0;return this.words[n]=t?this.words[n]|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)},i.prototype.isub=function(e){if(e.sign){e.sign=!1;var t=this.iadd(e);return e.sign=!0,t._normSign()}if(this.sign)return this.sign=!1,this.iadd(e),this.sign=!0,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.sign=!1,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>>26,o=67108863&r,s=Math.min(n,e.length-1),a=Math.max(0,n-this.length+1);a<=s;a++){var u=n-a,c=(0|this.words[u])*(0|e.words[a]),f=67108863&c;o=67108863&(f=f+o|0),i=(i=i+(c/67108864|0)|0)+(f>>>26)|0}t.words[n]=o,r=i}return 0!==r?t.words[n]=r:t.length--,t.strip()},i.prototype._bigMulTo=function(e,t){t.sign=e.sign!==this.sign,t.length=this.length+e.length;for(var r=0,n=0,i=0;i>>26)|0)>>>26,o&=67108863}t.words[i]=s,r=o,o=n}return 0!==r?t.words[i]=r:t.length--,t.strip()},i.prototype.mulTo=function(e,t){return this.length+e.length<63?this._smallMulTo(e,t):this._bigMulTo(e,t)},i.prototype.mul=function(e){var t=new i(null);return t.words=new Array(this.length+e.length),this.mulTo(e,t)},i.prototype.imul=function(e){if(0===this.cmpn(0)||0===e.cmpn(0))return this.words[0]=0,this.length=1,this;var t=this.length,r=e.length;this.sign=e.sign!==this.sign,this.length=this.length+e.length,this.words[this.length-1]=0;for(var n=this.length-2;n>=0;n--){for(var i=0,o=0,s=Math.min(n,r-1),a=Math.max(0,n-t+1);a<=s;a++){var u=n-a,c=this.words[u]*e.words[a],f=67108863&c;i+=c/67108864|0,o=67108863&(f+=o),i+=f>>>26}this.words[n]=o,this.words[n+1]+=i,i=0}for(i=0,u=1;u>>26}return this.strip()},i.prototype.imuln=function(e){r("number"==typeof e);for(var t=0,n=0;n>=26,t+=i/67108864|0,t+=o>>>26,this.words[n]=67108863&o}return 0!==t&&(this.words[n]=t,this.length++),this},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.mul(this)},i.prototype.ishln=function(e){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26,i=67108863>>>26-t<<26-t;if(0!==t){for(var o=0,s=0;s>>26-t}o&&(this.words[s]=o,this.length++)}if(0!==n){for(s=this.length-1;s>=0;s--)this.words[s+n]=this.words[s];for(s=0;s=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){this.length-=s;for(c=0;c=0&&(0!==f||c>=i);c--){var l=this.words[c];this.words[c]=f<<26-o|l>>>o,f=l&a}return u&&0!==f&&(u.words[u.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip(),this},i.prototype.shln=function(e){return this.clone().ishln(e)},i.prototype.shrn=function(e){return this.clone().ishrn(e)},i.prototype.testn=function(e){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26,i=1<=0);var t=e%26,n=(e-t)/26;if(r(!this.sign,"imaskn works only with positive numbers"),0!==t&&n++,this.length=Math.min(n,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},i.prototype.isubn=function(e){if(r("number"==typeof e),e<0)return this.iaddn(-e);if(this.sign)return this.sign=!1,this.iaddn(e),this.sign=!0,this;this.words[0]-=e;for(var t=0;t>26)-(c/67108864|0),this.words[s+n]=67108863&u}for(;s>26,this.words[s+n]=67108863&u}if(0===a)return this.strip();r(-1===a),a=0;for(s=0;s>26,this.words[s]=67108863&u}return this.sign=!0,this.strip()},i.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),o=e,s=o.words[o.length-1];0!=(r=26-this._countBits(s))&&(o=o.shln(r),n.ishln(r),s=o.words[o.length-1]);var a,u=n.length-o.length;if("mod"!==t){(a=new i(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c=0;l--){var h=67108864*n.words[o.length+l]+n.words[o.length+l-1];for(h=Math.min(h/s|0,67108863),n._ishlnsubmul(o,h,l);n.sign;)h--,n.sign=!1,n._ishlnsubmul(o,1,l),0!==n.cmpn(0)&&(n.sign=!n.sign);a&&(a.words[l]=h)}return a&&a.strip(),n.strip(),"div"!==t&&0!==r&&n.ishrn(r),{div:a||null,mod:n}},i.prototype.divmod=function(e,t){if(r(0!==e.cmpn(0)),this.sign&&!e.sign){var n,o=this.neg().divmod(e,t);return"mod"!==t&&(s=o.div.neg()),"div"!==t&&(n=0===o.mod.cmpn(0)?o.mod:e.sub(o.mod)),{div:s,mod:n}}if(!this.sign&&e.sign){var s;o=this.divmod(e.neg(),t);return"mod"!==t&&(s=o.div.neg()),{div:s,mod:o.mod}}return this.sign&&e.sign?this.neg().divmod(e.neg(),t):e.length>this.length||this.cmp(e)<0?{div:new i(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new i(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new i(this.modn(e.words[0]))}:this._wordDiv(e,t)},i.prototype.div=function(e){return this.divmod(e,"div").div},i.prototype.mod=function(e){return this.divmod(e,"mod").mod},i.prototype.divRound=function(e){var t=this.divmod(e);if(0===t.mod.cmpn(0))return t.div;var r=t.div.sign?t.mod.isub(e):t.mod,n=e.shrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:t.div.sign?t.div.isubn(1):t.div.iaddn(1)},i.prototype.modn=function(e){r(e<=67108863);for(var t=(1<<26)%e,n=0,i=this.length-1;i>=0;i--)n=(t*n+this.words[i])%e;return n},i.prototype.idivn=function(e){r(e<=67108863);for(var t=0,n=this.length-1;n>=0;n--){var i=this.words[n]+67108864*t;this.words[n]=i/e|0,t=i%e}return this.strip()},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){r(!e.sign),r(0!==e.cmpn(0));var t=this,n=e.clone();t=t.sign?t.mod(e):t.clone();for(var o=new i(1),s=new i(0),a=new i(0),u=new i(1),c=0;t.isEven()&&n.isEven();)t.ishrn(1),n.ishrn(1),++c;for(var f=n.clone(),l=t.clone();0!==t.cmpn(0);){for(;t.isEven();)t.ishrn(1),o.isEven()&&s.isEven()?(o.ishrn(1),s.ishrn(1)):(o.iadd(f).ishrn(1),s.isub(l).ishrn(1));for(;n.isEven();)n.ishrn(1),a.isEven()&&u.isEven()?(a.ishrn(1),u.ishrn(1)):(a.iadd(f).ishrn(1),u.isub(l).ishrn(1));t.cmp(n)>=0?(t.isub(n),o.isub(a),s.isub(u)):(n.isub(t),a.isub(o),u.isub(s))}return{a:a,b:u,gcd:n.ishln(c)}},i.prototype._invmp=function(e){r(!e.sign),r(0!==e.cmpn(0));var t=this,n=e.clone();t=t.sign?t.mod(e):t.clone();for(var o=new i(1),s=new i(0),a=n.clone();t.cmpn(1)>0&&n.cmpn(1)>0;){for(;t.isEven();)t.ishrn(1),o.isEven()?o.ishrn(1):o.iadd(a).ishrn(1);for(;n.isEven();)n.ishrn(1),s.isEven()?s.ishrn(1):s.iadd(a).ishrn(1);t.cmp(n)>=0?(t.isub(n),o.isub(s)):(n.isub(t),s.isub(o))}return 0===t.cmpn(1)?o:s},i.prototype.gcd=function(e){if(0===this.cmpn(0))return e.clone();if(0===e.cmpn(0))return this.clone();var t=this.clone(),r=e.clone();t.sign=!1,r.sign=!1;for(var n=0;t.isEven()&&r.isEven();n++)t.ishrn(1),r.ishrn(1);for(;;){for(;t.isEven();)t.ishrn(1);for(;r.isEven();)r.ishrn(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.ishln(n)},i.prototype.invm=function(e){return this.egcd(e).a.mod(e)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){r("number"==typeof e);var t=e%26,n=(e-t)/26,i=1<>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},i.prototype.cmpn=function(e){var t,r=e<0;if(r&&(e=-e),this.sign&&!r)return-1;if(!this.sign&&r)return 1;if(e&=67108863,this.strip(),this.length>1)t=1;else{var n=this.words[0];t=n===e?0:ne.length)return 1;if(this.length=0;r--){var n=this.words[r],i=e.words[r];if(n!==i){ni&&(t=1);break}}return t},i.red=function(e){return new g(e)},i.prototype.toRed=function(e){return r(!this.red,"Already a number in reduction context"),r(!this.sign,"red works only with positives"),e.convertTo(this)._forceRed(e)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(e){return this.red=e,this},i.prototype.forceRed=function(e){return r(!this.red,"Already a number in reduction context"),this._forceRed(e)},i.prototype.redAdd=function(e){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},i.prototype.redIAdd=function(e){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},i.prototype.redSub=function(e){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},i.prototype.redISub=function(e){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},i.prototype.redShl=function(e){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},i.prototype.redMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},i.prototype.redIMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(e){return r(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var f={k256:null,p224:null,p192:null,p25519:null};function l(e,t){this.name=e,this.p=new i(t,16),this.n=this.p.bitLength(),this.k=new i(1).ishln(this.n).isub(this.p),this.tmp=this._tmp()}function h(){l.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function p(){l.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function d(){l.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function y(){l.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function g(e){if("string"==typeof e){var t=i._prime(e);this.m=t.p,this.prime=t}else this.m=e,this.prime=null}function m(e){g.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(1).ishln(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.sign=!0,this.minv=this.minv.mod(this.r)}l.prototype._tmp=function(){var e=new i(null);return e.words=new Array(Math.ceil(this.n/13)),e},l.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):r.strip(),r},l.prototype.split=function(e,t){e.ishrn(this.n,0,t)},l.prototype.imulK=function(e){return e.imul(this.k)},n(h,l),h.prototype.split=function(e,t){for(var r=4194303,n=Math.min(e.length,9),i=0;i>>22,o=s}e.words[i-10]=o>>>22,e.length-=9},h.prototype.imulK=function(e){var t;e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var r=0,n=0;n>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},i._prime=function(e){if(f[e])return f[e];var t;if("k256"===e)t=new h;else if("p224"===e)t=new p;else if("p192"===e)t=new d;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new y}return f[e]=t,t},g.prototype._verify1=function(e){r(!e.sign,"red works only with positives"),r(e.red,"red works only with red numbers")},g.prototype._verify2=function(e,t){r(!e.sign&&!t.sign,"red works only with positives"),r(e.red&&e.red===t.red,"red works only with red numbers")},g.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.mod(this.m)._forceRed(this)},g.prototype.neg=function(e){var t=e.clone();return t.sign=!t.sign,t.iadd(this.m)._forceRed(this)},g.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)},g.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},g.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)},g.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},g.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.shln(t))},g.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},g.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},g.prototype.isqr=function(e){return this.imul(e,e)},g.prototype.sqr=function(e){return this.mul(e,e)},g.prototype.sqrt=function(e){if(0===e.cmpn(0))return e.clone();var t=this.m.andln(3);if(r(t%2==1),3===t){var n=this.m.add(new i(1)).ishrn(2);return this.pow(e,n)}for(var o=this.m.subn(1),s=0;0!==o.cmpn(0)&&0===o.andln(1);)s++,o.ishrn(1);r(0!==o.cmpn(0));var a=new i(1).toRed(this),u=a.redNeg(),c=this.m.subn(1).ishrn(1),f=this.m.bitLength();for(f=new i(2*f*f).toRed(this);0!==this.pow(f,c).cmp(u);)f.redIAdd(u);for(var l=this.pow(f,o),h=this.pow(e,o.addn(1).ishrn(1)),p=this.pow(e,o),d=s;0!==p.cmp(a);){for(var y=p,g=0;0!==y.cmp(a);g++)y=y.redSqr();r(g=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},m.prototype.mul=function(e,t){if(0===e.cmpn(0)||0===t.cmpn(0))return new i(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(n).ishrn(this.shift),s=o;return o.cmp(this.m)>=0?s=o.isub(this.m):o.cmpn(0)<0&&(s=o.iadd(this.m)),s._forceRed(this)},m.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===e||e,this)}).call(this,r(27)(e))},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){var n=r(13);r(19),r(100);var i=e.exports=n.asn1=n.asn1||{};function o(e,t,r){if(r>t){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=[],u=0;ur){if(a.strict){var y=new Error("Too few bytes to read ASN.1 value.");throw y.available=t.length(),y.remaining=r,y.requested=d,y}d=r}var g=32==(32&c);if(g)if(h=[],void 0===d)for(;;){if(o(t,r,2),t.bytes(2)===String.fromCharCode(0,0)){t.getBytes(2),r-=2;break}u=t.length(),h.push(e(t,r,n+1,a)),r-=u-t.length()}else for(;d>0;)u=t.length(),h.push(e(t,d,n+1,a)),r-=u-t.length(),d-=u-t.length();if(void 0===h&&f===i.Class.UNIVERSAL&&l===i.Type.BITSTRING&&(p=t.bytes(d)),void 0===h&&a.decodeBitStrings&&f===i.Class.UNIVERSAL&&l===i.Type.BITSTRING&&d>1){var m=t.read,b=r,v=0;if(l===i.Type.BITSTRING&&(o(t,r,1),v=t.getByte(),r--),0===v)try{u=t.length();var _=e(t,r,n+1,{verbose:a.verbose,strict:!0,decodeBitStrings:!0}),w=u-t.length();r-=w,l==i.Type.BITSTRING&&w++;var S=_.tagClass;w!==d||S!==i.Class.UNIVERSAL&&S!==i.Class.CONTEXT_SPECIFIC||(h=[_])}catch(t){}void 0===h&&(t.read=m,r=b)}if(void 0===h){if(void 0===d){if(a.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");d=r}if(l===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 k=void 0===p?null:{bitStringContents:p};return i.create(f,l,g,h,k)}(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 u=o.length(),c="";do{c+=String.fromCharCode(255&u),u>>>=8}while(u>0);t.putByte(128|c.length);for(a=c.length-1;a>=0;--a)t.putByte(c.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 u=2;u>>=7,t||(o|=128),r.push(o),t=!1}while(i>0);for(var c=r.length-1;c>=0;--c)a.putByte(r[c])}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 u=e.charAt(10),c=10;"+"!==u&&"-"!==u&&(a=parseInt(e.substr(10,2),10),c+=2)}if(t.setUTCFullYear(r,n,i),t.setUTCHours(o,s,a,0),c&&("+"===(u=e.charAt(c))||"-"===u)){var f=60*parseInt(e.substr(c+1,2),10)+parseInt(e.substr(c+4,2),10);f*=6e4,"+"===u?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),u=0,c=0,f=!1;"Z"===e.charAt(e.length-1)&&(f=!0);var l=e.length-5,h=e.charAt(l);return"+"!==h&&"-"!==h||(c=60*parseInt(e.substr(l+1,2),10)+parseInt(e.substr(l+4,2),10),c*=6e4,"+"===h&&(c*=-1),f=!0),"."===e.charAt(14)&&(u=1e3*parseFloat(e.substr(14),10)),f?(t.setUTCFullYear(r,n,i),t.setUTCHours(o,s,a,u),t.setTime(+t+c)):(t.setFullYear(r,n,i),t.setHours(o,s,a,u)),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,u=0;s&&u0&&(o+="\n");for(var s="",u=0;u1?o+="0x"+n.util.bytesToHex(e.value.slice(1)):o+="(none)",e.value.length>0){var h=e.value.charCodeAt(0);1==h?o+=" (1 unused bit shown)":h>1&&(o+=" ("+h+" unused bits shown)")}}else e.type===i.Type.OCTETSTRING?(a.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:a.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(13);e.exports=n.md=n.md||{},n.md.algorithms=n.md.algorithms||{}},function(e,t,r){"use strict";const n=r(1e3),i=x("dns4"),o=x("dns6"),s=A(x("dnsaddr"),i,o),a=A(x("ip4"),x("ip6")),u=E(a,x("tcp")),c=E(a,x("udp")),f=E(c,x("utp")),l=A(E(s,x("tcp")),s),h=A(E(u,x("ws")),E(l,x("ws"))),p=A(E(u,x("wss")),E(l,x("wss"))),d=A(E(u,x("http")),E(l),E(l,x("http"))),y=A(E(h,x("p2p-webrtc-star"),x("ipfs")),E(p,x("p2p-webrtc-star"),x("ipfs"))),g=A(E(h,x("p2p-websocket-star"),x("ipfs")),E(p,x("p2p-websocket-star"),x("ipfs")),E(h,x("p2p-websocket-star")),E(p,x("p2p-websocket-star"))),m=E(d,x("p2p-webrtc-direct")),b=A(h,p,d,y,m,u,f);let v=A(E(b,x("ipfs")),y,x("ipfs"));const _=A(E(v,x("p2p-circuit"),v),E(v,x("p2p-circuit")),E(x("p2p-circuit"),v),E(b,x("p2p-circuit")),E(x("p2p-circuit"),b),x("p2p-circuit")),w=()=>A(E(_,w),_),S=w(),k=A(E(S,v,S),E(v,S),E(S,v),S,v);function E(){const e=Array.from(arguments);function t(t){return t.length{if(null===(t="function"==typeof e?e().partialMatch(t):e.partialMatch(t)))return!0}),t)}return{input:e,matches:function(e){"string"==typeof e&&(e=n(e));let r=t(e.protoNames());return null!==r&&0===r.length},partialMatch:t}}function A(){const e=Array.from(arguments);function t(t){let r=null;return e.some(e=>{const n="function"==typeof e?e().partialMatch(t):e.partialMatch(t);if(n)return r=n,!0}),r}return{toString:function(){return"{ "+e.join(" ")+" }"},input:e,matches:function(e){"string"==typeof e&&(e=n(e));const r=t(e.protoNames());return null!==r&&0===r.length},partialMatch:t}}function x(e){const t=e;return{toString:function(){return t},matches:function(e){"string"==typeof e&&(e=n(e));const r=e.protoNames();return 1===r.length&&r[0]===t},partialMatch:function(e){return 0===e.length?null:e[0]===t?e.slice(1):null}}}t.DNS=l,t.DNS4=i,t.DNS6=o,t.IP=a,t.TCP=u,t.UDP=c,t.UTP=f,t.HTTP=d,t.WebSockets=h,t.WebSocketsSecure=p,t.WebSocketStar=g,t.WebRTCStar=y,t.WebRTCDirect=m,t.Reliable=b,t.Circuit=S,t.IPFS=k},function(e,t){errors={};errors.CodingError=class extends Error{constructor(e){super(e||"Coding Error"),this.name="CodingError"}};errors.ToBeImplementedError=class extends Error{constructor(e){super("To be implemented: "+e),this.name="ToBeImplementedError"}};errors.TransportError=class extends Error{constructor(e){super(e||"Transport failure"),this.name="TransportError"}};errors.TimeoutError=class extends Error{constructor(e){super(e||"Timed out"),this.name="TimeoutError"}};errors.IntentionallyUnimplementedError=class extends Error{constructor(e){super(e||"Intentionally Unimplemented Function"),this.name="IntentionallyUnimplementedError"}},e.exports=errors},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=o(r(164)),i=o(r(735));function o(e){return e&&e.__esModule?e:{default:e}}t.default=(0,n.default)(i.default),e.exports=t.default},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";(function(t){var n=r(18),i=r(21),o=r(24),s=r(32),a=function e(r){if(!(this instanceof e))return new e(r);if(!n.isUndefined(r))if(t.isBuffer(r))this.set({buf:r});else if(n.isString(r))this.set({buf:new t(r,"hex")});else{if(!n.isObject(r))throw new TypeError("Unrecognized argument for BufferReader");var i=r;this.set(i)}};a.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this.pos=e.pos||this.pos||0,this},a.prototype.eof=function(){return this.pos>=this.buf.length},a.prototype.finished=a.prototype.eof,a.prototype.read=function(e){i.checkArgument(!n.isUndefined(e),"Must specify a length");var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,t},a.prototype.readAll=function(){var e=this.buf.slice(this.pos,this.buf.length);return this.pos=this.buf.length,e},a.prototype.readUInt8=function(){var e=this.buf.readUInt8(this.pos);return this.pos=this.pos+1,e},a.prototype.readUInt16BE=function(){var e=this.buf.readUInt16BE(this.pos);return this.pos=this.pos+2,e},a.prototype.readUInt16LE=function(){var e=this.buf.readUInt16LE(this.pos);return this.pos=this.pos+2,e},a.prototype.readUInt32BE=function(){var e=this.buf.readUInt32BE(this.pos);return this.pos=this.pos+4,e},a.prototype.readUInt32LE=function(){var e=this.buf.readUInt32LE(this.pos);return this.pos=this.pos+4,e},a.prototype.readUInt64BEBN=function(){var e=this.buf.slice(this.pos,this.pos+8),t=s.fromBuffer(e);return this.pos=this.pos+8,t},a.prototype.readUInt64LEBN=function(){var e,t=this.buf.readUInt32LE(this.pos),r=4294967296*this.buf.readUInt32LE(this.pos+4)+t;if(r<=9007199254740991)e=new s(r);else{var n=Array.prototype.slice.call(this.buf,this.pos,this.pos+8);e=new s(n,10,"le")}return this.pos=this.pos+8,e},a.prototype.readVarintNum=function(){var e=this.readUInt8();switch(e){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:var t=this.readUInt64LEBN().toNumber();if(t<=Math.pow(2,53))return t;throw new Error("number too large to retain precision - use readVarintBN");default:return e}},a.prototype.readVarLengthBuffer=function(){var e=this.readVarintNum(),t=this.read(e);return i.checkState(t.length===e,"Invalid length while reading varlength buffer. Expected to read: "+e+" and read "+t.length),t},a.prototype.readVarintBuf=function(){switch(this.buf.readUInt8(this.pos)){case 253:return this.read(3);case 254:return this.read(5);case 255:return this.read(9);default:return this.read(1)}},a.prototype.readVarintBN=function(){var e=this.readUInt8();switch(e){case 253:return new s(this.readUInt16LE());case 254:return new s(this.readUInt32LE());case 255:return this.readUInt64LEBN();default:return new s(e)}},a.prototype.reverse=function(){for(var e=new t(this.buf.length),r=0;r=m.outputs.length)return new t("0000000000000000000000000000000000000000000000000000000000000001","hex");for(m.outputs.length=h+1,d=0;d9007199254740991?"transaction txout satoshis greater than max safe integer":this._satoshis!==this._satoshisBN.toNumber()?"transaction txout satoshis has corrupted value":this._satoshis<0&&"transaction txout negative"},h.prototype.toObject=h.prototype.toJSON=function(){var e={satoshis:this.satoshis};return e.script=this._scriptBuffer.toString("hex"),e},h.fromObject=function(e){return new h(e)},h.prototype.setScriptFromBuffer=function(e){this._scriptBuffer=e;try{this._script=c.fromBuffer(this._scriptBuffer),this._script._isOutput=!0}catch(e){if(!(e instanceof l.Script.InvalidBuffer))throw e;this._script=null}},h.prototype.setScript=function(e){if(e instanceof c)this._scriptBuffer=e.toBuffer(),this._script=e,this._script._isOutput=!0;else if(n.isString(e))this._script=c.fromString(e),this._scriptBuffer=this._script.toBuffer(),this._script._isOutput=!0;else{if(!s.isBuffer(e))throw new TypeError("Invalid argument type: script");this.setScriptFromBuffer(e)}return this},h.prototype.inspect=function(){var e;return e=this.script?this.script.inspect():this._scriptBuffer.toString("hex"),""},h.fromBufferReader=function(e){var t={};t.satoshis=e.readUInt64LEBN();var r=e.readVarintNum();return t.script=0!==r?e.read(r):new o.Buffer([]),new h(t)},h.prototype.toBufferWriter=function(e){e||(e=new u),e.writeUInt64LEBN(this._satoshisBN);var t=this._scriptBuffer;return e.writeVarintNum(t.length),e.write(t),e},e.exports=h},function(e,t,r){"use strict";var n=r(150),i=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};e.exports=l;var o=r(117);o.inherits=r(4);var s=r(330),a=r(210);o.inherits(l,s);for(var u=i(a.prototype),c=0;c=e.length?o(!0):o(null,e[r++])}}},function(e,t,r){"use strict";var n=r(213);e.exports=function(e){return n(function(e,t){return e.push(t),e},[],e)}},function(e,t){var r=Array.isArray;e.exports=r},function(e,t,r){var n=r(215),i=r(353);e.exports=function(e){return null!=e&&i(e.length)&&!n(e)}},function(e,t,r){e.exports=i;var n=r(10).EventEmitter;function i(){n.call(this)}r(4)(i,n),i.Readable=r(22),i.Writable=r(728),i.Duplex=r(729),i.Transform=r(730),i.PassThrough=r(731),i.Stream=i,i.prototype.pipe=function(e,t){var r=this;function i(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),e.on("drain",o),e._isStdio||t&&!1===t.end||(r.on("end",a),r.on("close",u));var s=!1;function a(){s||(s=!0,e.end())}function u(){s||(s=!0,"function"==typeof e.destroy&&e.destroy())}function c(e){if(f(),0===n.listenerCount(this,"error"))throw e}function f(){r.removeListener("data",i),e.removeListener("drain",o),r.removeListener("end",a),r.removeListener("close",u),r.removeListener("error",c),e.removeListener("error",c),r.removeListener("end",f),r.removeListener("close",f),e.removeListener("close",f)}return r.on("error",c),e.on("error",c),r.on("end",f),r.on("close",f),e.on("close",f),e.emit("pipe",r),e}},function(e,t,r){"use strict";(function(n){const i=r(12),o=r(16),s=r(58);(t=e.exports=s(class{constructor(e,t,r){o(r,"A link requires a multihash to point to"),this._name=e||"",this._size=t,"string"==typeof r?this._multihash=i.fromB58String(r):n.isBuffer(r)&&(this._multihash=r)}toString(){return`DAGLink <${i.toB58String(this.multihash)} - name: "${this.name}", size: ${this.size}>`}toJSON(){return{name:this.name,size:this.size,multihash:i.toB58String(this._multihash)}}get name(){return this._name}set name(e){throw new Error("Can't set property: 'name' is immutable")}get size(){return this._size}set size(e){throw new Error("Can't set property: 'size' is immutable")}get multihash(){return this._multihash}set multihash(e){throw new Error("Can't set property: 'multihash' is immutable")}},{className:"DAGLink",symbolName:"@ipld/js-ipld-dag-pb/daglink"})).create=r(756),t.util=r(757)}).call(this,r(0).Buffer)},function(e,t,r){var n=r(2).Buffer,i=r(90).Transform,o=r(211).StringDecoder;function s(e){i.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}r(4)(s,i),s.prototype.update=function(e,t,r){"string"==typeof e&&(e=n.from(e,t));var i=this._update(e);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)},s.prototype.setAutoPadding=function(){},s.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},s.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},s.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},s.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){n=e}finally{r(n)}},s.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},s.prototype._finalOrDigest=function(e){var t=this.__final()||n.alloc(0);return e&&(t=this._toString(t,e,!0)),t},s.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new o(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n},e.exports=s},function(e,t,r){var n=r(410);r(803),e.exports=n},function(e,t,r){"use strict";t.ethAccountSnapshot=r(413),t.ethBlock=r(423),t.ethBlockList=r(848),t.ethStateTrie=r(853),t.ethStorageTrie=r(856),t.ethTx=r(426),t.ethTxTrie=r(859)},function(e,t){},function(e,t,r){"use strict";var n=r(18),i=r(24),o=r(29),s=[],a={};function u(){}function c(e,t){if(~s.indexOf(e))return e;if(!t)return a[e];n.isArray(t)||(t=[t]);var r=function(t){return s[i][t]===e};for(var i in s)if(n.any(t,r))return s[i]}function f(e){var t=new u;return o.defineImmutable(t,{name:e.name,alias:e.alias,pubkeyhash:e.pubkeyhash,privatekey:e.privatekey,scripthash:e.scripthash,xpubkey:e.xpubkey,xprivkey:e.xprivkey,zaddr:e.zaddr,zkey:e.zkey}),e.networkMagic&&o.defineImmutable(t,{networkMagic:i.integerAsBuffer(e.networkMagic)}),e.port&&o.defineImmutable(t,{port:e.port}),e.dnsSeeds&&o.defineImmutable(t,{dnsSeeds:e.dnsSeeds}),n.each(t,function(e){n.isUndefined(e)||n.isObject(e)||(a[e]=t)}),s.push(t),t}u.prototype.toString=function(){return this.name},f({name:"livenet",alias:"mainnet",pubkeyhash:7352,privatekey:128,scripthash:7357,xpubkey:76067358,xprivkey:76066276,zaddr:5786,zkey:43830,networkMagic:4179340459,port:8233,dnsSeeds:[]});var l=c("livenet");f({name:"testnet",alias:"regtest",pubkeyhash:7461,privatekey:239,scripthash:7354,xpubkey:70617039,xprivkey:70615956,zaddr:5814,zkey:44040});var h=c("testnet"),p={PORT:18233,NETWORK_MAGIC:i.integerAsBuffer(4187956406),DNS_SEEDS:["dnsseed.testnet.z.cash"]};for(var d in p)n.isObject(p[d])||(a[p[d]]=h);var y={PORT:18444,NETWORK_MAGIC:i.integerAsBuffer(2867347295),DNS_SEEDS:[]};for(var d in y)n.isObject(y[d])||(a[y[d]]=h);Object.defineProperty(h,"port",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?y.PORT:p.PORT}}),Object.defineProperty(h,"networkMagic",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?y.NETWORK_MAGIC:p.NETWORK_MAGIC}}),Object.defineProperty(h,"dnsSeeds",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?y.DNS_SEEDS:p.DNS_SEEDS}}),e.exports={add:f,remove:function(e){for(var t=0;t"},e.exports=l;var h=r(64)}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(n){const i=r(12),o=r(111),s=r(16),a=r(5);class u{constructor(e,t,r){s(n.isBuffer(e),"invalid id provided"),t&&r&&s(t.public.bytes.equals(r.bytes),"inconsistent arguments"),this._id=e,this._idB58String=i.toB58String(this.id),this._privKey=t,this._pubKey=r}get id(){return this._id}set id(e){throw new Error("Id is immutable")}get privKey(){return this._privKey}set privKey(e){this._privKey=e}get pubKey(){return this._pubKey?this._pubKey:this._privKey?this._privKey.public:void 0}set pubKey(e){this._pubKey=e}marshalPubKey(){if(this.pubKey)return o.keys.marshalPublicKey(this.pubKey)}marshalPrivKey(){if(this.privKey)return o.keys.marshalPrivateKey(this.privKey)}toPrint(){let e=this.toB58String();e.startsWith("Qm")&&(e=e.slice(2));let t=6;return e.length"}toJSON(){return{id:this.toB58String(),privKey:c(this.marshalPrivKey()),pubKey:c(this.marshalPubKey())}}toHexString(){return i.toHexString(this.id)}toBytes(){return this.id}toB58String(){return this._idB58String}isEqual(e){if(n.isBuffer(e))return this.id.equals(e);if(e.id)return this.id.equals(e.id);throw new Error("not valid Id")}isValid(e){this.privKey&&this.privKey.public&&this.privKey.public.bytes&&n.isBuffer(this.pubKey.bytes)&&this.privKey.public.bytes.equals(this.pubKey.bytes)?e():e(new Error("Keys not match"))}}function c(e){if(e)return e.toString("base64")}(t=e.exports=u).create=function(e,t){"function"==typeof e&&(t=e,e={}),(e=e||{}).bits=e.bits||2048,a([t=>o.keys.generateKeyPair("RSA",e.bits,t),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n))})},t.createFromHexString=function(e){return new u(i.fromHexString(e))},t.createFromBytes=function(e){return new u(e)},t.createFromB58String=function(e){return new u(i.fromB58String(e))},t.createFromPubKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r;try{let i=e;if("string"==typeof i&&(i=n.from(e,"base64")),!n.isBuffer(i))throw new Error("Supplied key is neither a base64 string nor a buffer");r=o.keys.unmarshalPublicKey(i)}catch(e){return t(e)}r.hash((e,n)=>{if(e)return t(e);t(null,new u(n,null,r))})},t.createFromPrivKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r=e;try{if("string"==typeof r&&(r=n.from(e,"base64")),!n.isBuffer(r))throw new Error("Supplied key is neither a base64 string nor a buffer")}catch(e){return t(e)}a([e=>o.keys.unmarshalPrivateKey(r,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n,n.public))})},t.createFromJSON=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r,s,c,f;try{r=i.fromB58String(e.id),s=e.privKey&&n.from(e.privKey,"base64"),c=e.pubKey&&n.from(e.pubKey,"base64"),f=c&&o.keys.unmarshalPublicKey(c)}catch(e){return t(e)}s?a([e=>o.keys.unmarshalPrivateKey(s,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)}),(e,t,r)=>{f?f.hash((n,i)=>{r(n,e,t,i)}):r(null,e,t)}],(e,n,i,o)=>e?t(e):f&&!n.equals(o)?t(new Error("Public and private key do not match")):r&&!n.equals(r)?t(new Error("Id and private key do not match")):void t(null,new u(r,i,f))):t(null,new u(r,null,f))},t.isPeerId=function(e){return Boolean("object"==typeof e&&e._id&&e._idB58String)}}).call(this,r(0).Buffer)},function(e,t,r){var n=r(13);function i(e,t){n.cipher.registerAlgorithm(e,function(){return new n.aes.Algorithm(e,t)})}r(258),r(443),r(19),e.exports=n.aes=n.aes||{},n.aes.startEncrypting=function(e,t,r,n){var i=y({key:e,output:r,decrypt:!1,mode:n});return i.start(t),i},n.aes.createEncryptionCipher=function(e,t){return y({key:e,output:null,decrypt:!1,mode:t})},n.aes.startDecrypting=function(e,t,r,n){var i=y({key:e,output:r,decrypt:!0,mode:n});return i.start(t),i},n.aes.createDecryptionCipher=function(e,t){return y({key:e,output:null,decrypt:!0,mode:t})},n.aes.Algorithm=function(e,t){f||h();var r=this;r.name=e,r.mode=new t({blockSize:16,cipher:{encrypt:function(e,t){return d(r._w,e,t,!1)},decrypt:function(e,t){return d(r._w,e,t,!0)}}}),r._init=!1},n.aes.Algorithm.prototype.initialize=function(e){if(!this._init){var t,r=e.key;if("string"!=typeof r||16!==r.length&&24!==r.length&&32!==r.length){if(n.util.isArray(r)&&(16===r.length||24===r.length||32===r.length)){t=r,r=n.util.createBuffer();for(var i=0;i>>=2;for(i=0;i>8^255&l^99,o[y]=l,s[l]=y,p=(h=e[l])<<24^l<<16^l<<8^l^h,d=((r=e[y])^(n=e[r])^(i=e[n]))<<24^(y^i)<<16^(y^n^i)<<8^y^r^i;for(var m=0;m<4;++m)u[m][y]=p,c[m][l]=d,p=p<<24|p>>>8,d=d<<24|d>>>8;0===y?y=g=1:(y=r^e[e[e[r^i]]],g^=e[e[g]])}}function p(e,t){for(var r,n=e.slice(0),i=1,s=n.length,u=l*(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,p=c[0],d=c[1],y=c[2],g=c[3],m=n.slice(0),b=(f=0,(u=n.length)-l);f>>24]]^d[o[h>>>16&255]]^y[o[h>>>8&255]]^g[o[255&h]];n=m}return n}function d(e,t,r,n){var i,a,f,l,h,p,d,y,g,m,b,v,_=e.length/4-1;n?(i=c[0],a=c[1],f=c[2],l=c[3],h=s):(i=u[0],a=u[1],f=u[2],l=u[3],h=o),p=t[0]^e[0],d=t[n?3:1]^e[1],y=t[2]^e[2],g=t[n?1:3]^e[3];for(var w=3,S=1;S<_;++S)m=i[p>>>24]^a[d>>>16&255]^f[y>>>8&255]^l[255&g]^e[++w],b=i[d>>>24]^a[y>>>16&255]^f[g>>>8&255]^l[255&p]^e[++w],v=i[y>>>24]^a[g>>>16&255]^f[p>>>8&255]^l[255&d]^e[++w],g=i[g>>>24]^a[p>>>16&255]^f[d>>>8&255]^l[255&y]^e[++w],p=m,d=b,y=v;r[0]=h[p>>>24]<<24^h[d>>>16&255]<<16^h[y>>>8&255]<<8^h[255&g]^e[++w],r[n?3:1]=h[d>>>24]<<24^h[y>>>16&255]<<16^h[g>>>8&255]<<8^h[255&p]^e[++w],r[2]=h[y>>>24]<<24^h[g>>>16&255]<<16^h[p>>>8&255]<<8^h[255&d]^e[++w],r[n?1:3]=h[g>>>24]<<24^h[p>>>16&255]<<16^h[d>>>8&255]<<8^h[255&y]^e[++w]}function y(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,r){var n=r(13);n.pki=n.pki||{};var i=e.exports=n.pki.oids=n.oids=n.oids||{};function o(e,t){i[e]=t,i[t]=e}function s(e,t){i[e]=t}o("1.2.840.113549.1.1.1","rsaEncryption"),o("1.2.840.113549.1.1.4","md5WithRSAEncryption"),o("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),o("1.2.840.113549.1.1.7","RSAES-OAEP"),o("1.2.840.113549.1.1.8","mgf1"),o("1.2.840.113549.1.1.9","pSpecified"),o("1.2.840.113549.1.1.10","RSASSA-PSS"),o("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),o("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),o("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),o("1.2.840.10040.4.3","dsa-with-sha1"),o("1.3.14.3.2.7","desCBC"),o("1.3.14.3.2.26","sha1"),o("2.16.840.1.101.3.4.2.1","sha256"),o("2.16.840.1.101.3.4.2.2","sha384"),o("2.16.840.1.101.3.4.2.3","sha512"),o("1.2.840.113549.2.5","md5"),o("1.2.840.113549.1.7.1","data"),o("1.2.840.113549.1.7.2","signedData"),o("1.2.840.113549.1.7.3","envelopedData"),o("1.2.840.113549.1.7.4","signedAndEnvelopedData"),o("1.2.840.113549.1.7.5","digestedData"),o("1.2.840.113549.1.7.6","encryptedData"),o("1.2.840.113549.1.9.1","emailAddress"),o("1.2.840.113549.1.9.2","unstructuredName"),o("1.2.840.113549.1.9.3","contentType"),o("1.2.840.113549.1.9.4","messageDigest"),o("1.2.840.113549.1.9.5","signingTime"),o("1.2.840.113549.1.9.6","counterSignature"),o("1.2.840.113549.1.9.7","challengePassword"),o("1.2.840.113549.1.9.8","unstructuredAddress"),o("1.2.840.113549.1.9.14","extensionRequest"),o("1.2.840.113549.1.9.20","friendlyName"),o("1.2.840.113549.1.9.21","localKeyId"),o("1.2.840.113549.1.9.22.1","x509Certificate"),o("1.2.840.113549.1.12.10.1.1","keyBag"),o("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),o("1.2.840.113549.1.12.10.1.3","certBag"),o("1.2.840.113549.1.12.10.1.4","crlBag"),o("1.2.840.113549.1.12.10.1.5","secretBag"),o("1.2.840.113549.1.12.10.1.6","safeContentsBag"),o("1.2.840.113549.1.5.13","pkcs5PBES2"),o("1.2.840.113549.1.5.12","pkcs5PBKDF2"),o("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),o("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),o("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),o("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),o("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),o("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),o("1.2.840.113549.2.7","hmacWithSHA1"),o("1.2.840.113549.2.8","hmacWithSHA224"),o("1.2.840.113549.2.9","hmacWithSHA256"),o("1.2.840.113549.2.10","hmacWithSHA384"),o("1.2.840.113549.2.11","hmacWithSHA512"),o("1.2.840.113549.3.7","des-EDE3-CBC"),o("2.16.840.1.101.3.4.1.2","aes128-CBC"),o("2.16.840.1.101.3.4.1.22","aes192-CBC"),o("2.16.840.1.101.3.4.1.42","aes256-CBC"),o("2.5.4.3","commonName"),o("2.5.4.5","serialName"),o("2.5.4.6","countryName"),o("2.5.4.7","localityName"),o("2.5.4.8","stateOrProvinceName"),o("2.5.4.10","organizationName"),o("2.5.4.11","organizationalUnitName"),o("2.16.840.1.113730.1.1","nsCertType"),s("2.5.29.1","authorityKeyIdentifier"),s("2.5.29.2","keyAttributes"),s("2.5.29.3","certificatePolicies"),s("2.5.29.4","keyUsageRestriction"),s("2.5.29.5","policyMapping"),s("2.5.29.6","subtreesConstraint"),s("2.5.29.7","subjectAltName"),s("2.5.29.8","issuerAltName"),s("2.5.29.9","subjectDirectoryAttributes"),s("2.5.29.10","basicConstraints"),s("2.5.29.11","nameConstraints"),s("2.5.29.12","policyConstraints"),s("2.5.29.13","basicConstraints"),o("2.5.29.14","subjectKeyIdentifier"),o("2.5.29.15","keyUsage"),s("2.5.29.16","privateKeyUsagePeriod"),o("2.5.29.17","subjectAltName"),o("2.5.29.18","issuerAltName"),o("2.5.29.19","basicConstraints"),s("2.5.29.20","cRLNumber"),s("2.5.29.21","cRLReason"),s("2.5.29.22","expirationDate"),s("2.5.29.23","instructionCode"),s("2.5.29.24","invalidityDate"),s("2.5.29.25","cRLDistributionPoints"),s("2.5.29.26","issuingDistributionPoint"),s("2.5.29.27","deltaCRLIndicator"),s("2.5.29.28","issuingDistributionPoint"),s("2.5.29.29","certificateIssuer"),s("2.5.29.30","nameConstraints"),o("2.5.29.31","cRLDistributionPoints"),o("2.5.29.32","certificatePolicies"),s("2.5.29.33","policyMappings"),s("2.5.29.34","policyConstraints"),o("2.5.29.35","authorityKeyIdentifier"),s("2.5.29.36","policyConstraints"),o("2.5.29.37","extKeyUsage"),s("2.5.29.46","freshestCRL"),s("2.5.29.54","inhibitAnyPolicy"),o("1.3.6.1.4.1.11129.2.4.2","timestampList"),o("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),o("1.3.6.1.5.5.7.3.1","serverAuth"),o("1.3.6.1.5.5.7.3.2","clientAuth"),o("1.3.6.1.5.5.7.3.3","codeSigning"),o("1.3.6.1.5.5.7.3.4","emailProtection"),o("1.3.6.1.5.5.7.3.8","timeStamping")},function(e,t,r){var n=r(503),i=r(46),o=r(141),s=r(194);e.exports=function(e,t){(function(e){return"function"==typeof e})(e)&&(t=e,e={}),t=function(e){var t=0;return function(r,n,i){t++||e(r,n,i)}}(t||function(){});var r=n(e&&e.timeout||5e3),a=i(function(e){e&&t(e)}),u=s();return{handshake:{read:r.read,abort:function(e){a.end(e),r.abort(e,function(e){}),t(e)},write:a.push,rest:function(){return a.end(),{source:r.read(),sink:u.sink}}},sink:r,source:o([a,u.source])}}},function(e,t,r){const n=r(33),i=r(79),o=r(149);class s{constructor(e,t){t&&console.log("Transports(%o)",e)}static _connected(){return this._transports.filter(e=>!e.status)}static async p_connectedNames(){return this._connected().map(e=>e.name)}static async p_connectedNamesParm(){return(await this.p_connectedNames()).map(e=>"transport="+e).join("&")}static async p_statuses(){return this._transports.map(e=>({name:e.name,status:e.status}))}static validFor(e,t,r){return e&&e[0]||["store","newlisturls","newdatabase","newtable"].includes(t)?e&&e.length>0?[].concat(...e.map(e=>"string"==typeof e?n.parse(e):e).map(e=>this._connected().filter(r=>r.supports(e,t)).map(t=>[e,t]))):this._connected().filter(e=>e.supports(void 0,t)).map(e=>[void 0,e]):(console.warn("Transports.validFor called with invalid arguments: urls=",e,"func=",t),[])}static async p_urlsValidFor(e,t,r){return this.validFor(e,t,r).map(e=>e[0])}static http(e){return s._connected().find(e=>"HTTP"===e.name)}static ipfs(e){return s._connected().find(e=>"IPFS"===e.name)}static webtorrent(e){return s._connected().find(e=>"WEBTORRENT"===e.name)}static gun(e){return s._connected().find(e=>"GUN"===e.name)}static async p_resolveNames(e){return this.namingcb?await this.namingcb(e):e}static resolveNamesWith(e){this.namingcb=e}static async _p_rawstore(e,t,{verbose:r}){let n=[],o=await Promise.all(e.map(async function(e){try{return await e.p_rawstore(t,{verbose:r})}catch(t){return console.log("Could not rawstore to",e.name,t.message),void n.push(t)}}));if(!(o=o.filter(e=>!!e)).length)throw new i.TransportError(n.map(e=>e.message).join(", "));return o}static async p_rawstore(e,{verbose:t}){let r=this.validFor(void 0,"store").map(([e,t])=>t);if(t&&console.log("Valid for transports:",r.map(e=>e.name)),!r.length)throw new i.TransportError("Transports.p_rawstore: Cant find transport for store");return this._p_rawstore(r,e,{verbose:t})}static async p_rawlist(e,{verbose:t=!1}={}){e=await this.p_resolveNames(e);let r=this.validFor(e,"list");if(!r.length)throw new i.TransportError('Transports.p_rawlist: Cant find transport to "list" urls:'+e.join(","));let n=[],o=await Promise.all(r.map(async function([e,r]){try{return await r.p_rawlist(e,{verbose:t})}catch(t){return console.log("Could not rawlist ",e,"from",r.name,t.message),n.push(t),[]}}));if(n.length>=r.length)throw new i.TransportError(n.map(e=>e.message).join(", "));let s={};return[].concat(...o).filter(e=>!s[e.signature]&&(s[e.signature]=!0))}static async p_rawfetch(e,t){let r=t.verbose;if(!e.length)throw new i.TransportError("Transports.p_rawfetch given an empty list of urls");let n=await this.p_resolveNames(e);if(!n.length)throw new i.TransportError("Transports.p_rawfetch none of the urls resolved: "+e);let o=this.validFor(n,"fetch");if(!o.length)throw new i.TransportError("Transports.p_rawfetch cant find any transport for urls: "+n);let s=[],a=[];for(const[e,n]of o)try{let i=await n.p_rawfetch(e,t);return t.relay&&a.length&&(console.log(`Relaying ${i.length} bytes from ${"string"==typeof e?e:e.href} to ${a.map(e=>e.name)}`),this._p_rawstore(a,i,{verbose:r}).then(e=>console.log(`Relayed to ${e}`))),i}catch(t){a.push(n),s.push(t),console.log("Could not retrieve ",e&&e.href,"from",n&&n.name,t.message)}throw new i.TransportError(s.map(e=>e.message).join(", "))}static async p_rawadd(e,t,{verbose:r=!1}={}){e=await this.p_resolveNames(e);let n=this.validFor(e,"add");if(!n.length)throw new i.TransportError("Transports.p_rawstore: Cant find transport for urls:"+e.join(","));let o=[];if(await Promise.all(n.map(async function([e,n]){try{return void await n.p_rawadd(e,t,{verbose:r})}catch(t){return console.log("Could not rawlist ",e,"from",n.name,t.message),void o.push(t)}})),o.length>=n.length)throw new i.TransportError(o.map(e=>e.message).join(", "))}static listmonitor(e,t,r={}){this.validFor(e,"listmonitor").map(([e,n])=>n.listmonitor(e,t,r))}static async p_newlisturls(e,{verbose:t=!1}={}){let r=await Promise.all(this.validFor(void 0,"newlisturls").map(([r,n])=>n.p_newlisturls(e,{verbose:t})));return[r.map(e=>e[0]),r.map(e=>e[1])]}static async p_f_createReadStream(e,{verbose:t=!1,wanturl:r=!1}={}){let n=this.validFor(e,"createReadStream",{});if(!n.length)throw new i.TransportError("Transports.p_createReadStream cant find any transport for urls: "+e);let o,s=[];for(;(o=n.splice(Math.floor(Math.random()*n.length),1)).length;){let e=o[0][0],n=o[0][1];try{return await n.p_f_createReadStream(e,{verbose:t,wanturl:r})}catch(t){s.push(t),console.log("Could not retrieve ",e.href,"from",n.name,t.message)}}throw new i.TransportError(s.map(e=>e.message).join(", "))}static async p_get(e,t,{verbose:r=!1}={}){let n=this.validFor(e,"get");if(!n.length)throw new i.TransportError("Transports.p_get cant find any transport for urls: "+e);let o=[];for(const[e,i]of n)try{return await i.p_get(e,t,{verbose:r})}catch(t){o.push(t),console.log("Could not retrieve ",e.href,"from",i.name,t.message)}throw new i.TransportError(o.map(e=>e.message).join(", "))}static async p_set(e,t,r,{verbose:n=!1}={}){e=await this.p_resolveNames(e);let o=this.validFor(e,"set");if(!o.length)throw new i.TransportError("Transports.p_set cant find any transport for urls: "+e);let s=[],a=!1;if(await Promise.all(o.map(async function([e,i]){try{await i.p_set(e,t,r,{verbose:n}),a=!0}catch(e){console.log("Could not rawstore to",i.name,e.message),s.push(e)}})),!a)throw new i.TransportError(s.map(e=>e.message).join(", "))}static async p_delete(e,t,{verbose:r=!1}={}){e=await this.p_resolveNames(e);let n=this.validFor(e,"set");if(!n.length)throw new i.TransportError("Transports.p_set cant find any transport for urls: "+e);let o=[],s=!1;if(await Promise.all(n.map(async function([e,n]){try{await n.p_delete(e,t,{verbose:r}),s=!0}catch(e){console.log("Could not rawstore to",n.name,e.message),o.push(e)}})),!s)throw new i.TransportError(o.map(e=>e.message).join(", "))}static async p_keys(e,{verbose:t=!1}={}){e=await this.p_resolveNames(e);let r=this.validFor(e,"keys");if(!r.length)throw new i.TransportError("Transports.p_keys cant find any transport for urls: "+e);let n=[];for(const[e,i]of r)try{return await i.p_keys(e,{verbose:t})}catch(t){n.push(t),console.log("Could not retrieve keys for",e.href,"from",i.name,t.message)}throw new i.TransportError(n.map(e=>e.message).join(", "))}static async p_getall(e,{verbose:t=!1}={}){e=await this.p_resolveNames(e);let r=this.validFor(e,"getall");if(!r.length)throw new i.TransportError("Transports.p_getall cant find any transport for urls: "+e);let n=[];for(const[e,i]of r)try{return await i.p_getall(e,{verbose:t})}catch(t){n.push(t),console.log("Could not retrieve all keys for",e.href,"from",i.name,t.message)}throw new i.TransportError(n.map(e=>e.message).join(", "))}static async p_newdatabase(e,{verbose:t=!1}={}){let r=await Promise.all(this.validFor(void 0,"newdatabase").map(([r,n])=>n.p_newdatabase(e,{verbose:t})));return{privateurls:r.map(e=>e.privateurl),publicurls:r.map(e=>e.publicurl)}}static async p_newtable(e,t,{verbose:r=!1}={}){let n=await Promise.all(this.validFor(void 0,"newtable").map(([n,i])=>i.p_newtable(e,t,{verbose:r})));return{privateurls:n.map(e=>e.privateurl),publicurls:n.map(e=>e.publicurl)}}static async p_connection(e,t){e=await this.p_resolveNames(e),await Promise.all(this.validFor(e,"connection").map(([e,r])=>r.p_connection(e,t)))}static monitor(e,t,{verbose:r=!1,current:n=!1}={}){this.validFor(e,"monitor").map(([e,i])=>i.monitor(e,t,{verbose:r,current:n}))}static addtransport(e){s._transports.push(e)}static setup0(e,t,r,n){let i={http:{urlbase:"http://localhost:4244"}};return e.map(e=>{let n;if(n="LOCAL"===e?this._transportclasses.HTTP:this._transportclasses[e])return n.setup0("LOCAL"===e?i:t,r);{let t=Object.keys(this._transportclasses);return void console.error(`Requested ${e} but ${t.length?t:"No"} transports have been loaded`)}}).filter(e=>!!e)}static async p_setup1(e,t){await Promise.all(this._transports.filter(e=>!this._optionspaused.includes(e.name)).map(r=>r.p_setup1(e,t)))}static async p_setup2(e,t){await Promise.all(this._transports.filter(e=>!this._optionspaused.includes(e.name)).map(r=>r.p_setup2(e,t)))}static async refreshstatus(e){let t=["transportstatus0","transportstatus1","transportstatus2","transportstatus3","transportstatus4"],r=e.statuselement;r&&(r.classList.remove(...t),r.classList.add(t[e.status])),s.statuscb&&s.statuscb(e)}static async p_connect(e,t){t&&console.group("p_connect ---");try{let r=(e=e||{}).transports;this._optionspaused=(e.paused||[]).map(e=>e.toUpperCase()),r&&r.length||(r=e.defaulttransports||[]),r.length||(r=["HTTP","YJS","IPFS","WEBTORRENT","GUN"]),r=r.map(e=>e.toUpperCase());let n=this.setup0(r,e,t);if(e.statuscb&&(this.statuscb=e.statuscb),e.statuselement){let t=e.statuselement;for(;t.lastChild;)t.removeChild(t.lastChild);t.appendChild(o.createElement("UL",{},n.map(e=>{let t=o.createElement("LI",{onclick:"this.source.togglePaused(DwebTransports.refreshstatus);",source:e,name:e.name},e.name);return e.statuselement=t,t})))}await this.p_setup1(t,this.refreshstatus),await this.p_setup2(t,this.refreshstatus)}catch(e){throw console.error("ERROR in p_connect:",e.message),e}t&&console.groupEnd("p_connect ---")}static async p_urlsFrom(e){if("string"==typeof e&&(e="["===e[0]?JSON.parse(e):e.includes(",")?e.split(","):[e]),!Array.isArray(e))throw new Error(`Unparsable url: ${e}`);return e}static async p_httpfetchurl(e){return s.http()._url(e.find(e=>e.startsWith("contenthash")||e.startsWith("http")),"content/rawfetch")}static async test(e){e&&console.log("Transports.test")}}s._transports=[],s.namingcb=void 0,s._transportclasses={},e.exports=s},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=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}}),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),y(r)?n.showHidden=r:r&&t._extend(n,r),v(n.showHidden)&&(n.showHidden=!1),v(n.depth)&&(n.depth=2),v(n.colors)&&(n.colors=!1),v(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),f(n,e,n.depth)}function u(e,t){var r=a.styles[t];return r?"["+a.colors[r][0]+"m"+e+"["+a.colors[r][1]+"m":e}function c(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 b(i)||(i=f(e,i,n)),i}var o=l(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)),k(r)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return h(r);if(0===s.length){if(E(r)){var u=r.name?": "+r.name:"";return e.stylize("[Function"+u+"]","special")}if(_(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(S(r))return e.stylize(Date.prototype.toString.call(r),"date");if(k(r))return h(r)}var c,y="",g=!1,m=["{","}"];return d(r)&&(g=!0,m=["[","]"]),E(r)&&(y=" [Function"+(r.name?": "+r.name:"")+"]"),_(r)&&(y=" "+RegExp.prototype.toString.call(r)),S(r)&&(y=" "+Date.prototype.toUTCString.call(r)),k(r)&&(y=" "+h(r)),0!==s.length||g&&0!=r.length?n<0?_(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special"):(e.seen.push(r),c=g?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?r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}(c,y,m)):m[0]+y+m[1]}function l(e,t){if(v(t))return e.stylize("undefined","undefined");if(b(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}return m(t)?e.stylize(""+t,"number"):y(t)?e.stylize(""+t,"boolean"):g(t)?e.stylize("null","null"):void 0}function h(e){return"["+Error.prototype.toString.call(e)+"]"}function p(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),T(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=g(r)?f(e,u.value,null):f(e,u.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")),v(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 y(e){return"boolean"==typeof e}function g(e){return null===e}function m(e){return"number"==typeof e}function b(e){return"string"==typeof e}function v(e){return void 0===e}function _(e){return w(e)&&"[object RegExp]"===A(e)}function w(e){return"object"==typeof e&&null!==e}function S(e){return w(e)&&"[object Date]"===A(e)}function k(e){return w(e)&&("[object Error]"===A(e)||e instanceof Error)}function E(e){return"function"==typeof e}function A(e){return Object.prototype.toString.call(e)}function x(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(e){if(v(o)&&(o=n.env.NODE_DEBUG||""),e=e.toUpperCase(),!s[e])if(new RegExp("\\b"+e+"\\b","i").test(o)){var r=n.pid;s[e]=function(){var n=t.format.apply(t,arguments);console.error("%s %d: %s",e,r,n)}}else s[e]=function(){};return s[e]},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=y,t.isNull=g,t.isNullOrUndefined=function(e){return null==e},t.isNumber=m,t.isString=b,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=v,t.isRegExp=_,t.isObject=w,t.isDate=S,t.isError=k,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(680);var I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function T(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){console.log("%s - %s",function(){var e=new Date,t=[x(e.getHours()),x(e.getMinutes()),x(e.getSeconds())].join(":");return[e.getDate(),I[e.getMonth()],t].join(" ")}(),t.format.apply(t,arguments))},t.inherits=r(681),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}}).call(this,r(7),r(6))},function(e,t,r){var n=r(123);function i(e){return n("rmd160").update(e).digest()}function o(e){return n("sha256").update(e).digest()}e.exports={hash160:function(e){return i(o(e))},hash256:function(e){return o(o(e))},ripemd160:i,sha1:function(e){return n("sha1").update(e).digest()},sha256:o}},function(e,t,r){var n=r(2).Buffer;function i(e,t){this._block=n.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}i.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=n.from(e,t));for(var r=this._block,i=this._blockSize,o=e.length,s=this._len,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";(function(t,n){var i=r(2).Buffer,o=t.crypto||t.msCrypto;o&&o.getRandomValues?e.exports=function(e,r){if(e>65536)throw new Error("requested too many random bytes");var s=new t.Uint8Array(e);e>0&&o.getRandomValues(s);var a=i.from(s.buffer);return"function"==typeof r?n.nextTick(function(){r(null,a)}):a}:e.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}}).call(this,r(7),r(6))},function(e,t,r){"use strict";(function(t){var n=r(32),i=r(24),o=r(72).curves.secp256k1,s=o.curve.point.bind(o.curve),a=o.curve.pointFromX.bind(o.curve),u=function(e,t,r){var n=s(e,t,r);return n.validate(),n};u.prototype=Object.getPrototypeOf(o.curve.point()),u.fromX=function(e,t){var r=a(e,t);return r.validate(),r},u.getG=function(){return o.curve.g},u.getN=function(){return new n(o.curve.n.toArray())},u.prototype._getX=u.prototype.getX,u.prototype.getX=function(){return new n(this._getX().toArray())},u.prototype._getY=u.prototype.getY,u.prototype.getY=function(){return new n(this._getY().toArray())},u.prototype.validate=function(){if(this.isInfinity())throw new Error("Point cannot be equal to Infinity");if(0===this.getX().cmp(n.Zero)||0===this.getY().cmp(n.Zero))throw new Error("Invalid x,y value for curve, cannot equal 0.");if(0!==a(this.getY().isOdd(),this.getX()).y.cmp(this.y))throw new Error("Invalid y value for curve.");var e=this.getX().gt(n.Minus1)&&this.getX().lt(u.getN()),t=this.getY().gt(n.Minus1)&&this.getY().lt(u.getN());if(!e||!t)throw new Error("Point does not lie on the curve");if(!this.mul(u.getN()).isInfinity())throw new Error("Point times N must be infinity");return this},u.pointToCompressed=function(e){var r,n=e.getX().toBuffer({size:32}),o=e.getY().toBuffer({size:32}),s=o[o.length-1]%2;return r=new t(s?[3]:[2]),i.concat([r,n])},e.exports=u}).call(this,r(0).Buffer)},function(e,t,r){var n=t;n.utils=r(869),n.common=r(870),n.sha=r(871),n.ripemd=r(872),n.hmac=r(873),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";const n=r(435),i=r(896),o=r(907);(t=e.exports).aes=i,t.hmac=n,t.keys=o,t.randomBytes=r(471),t.pbkdf2=r(947)},function(e,t,r){var n=r(13);r(19);var i=e.exports=n.pem=n.pem||{};function o(e){for(var t=e.name+": ",r=[],n=function(e,t){return" "+t},i=0;i65&&-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{const r=["bitswap"];t&&r.push(t),e&&r.push(`${e.toB58String().slice(0,8)}`);const i=n(r.join(":"));return i.error=n(r.concat(["error"]).join(":")),i})},function(e,t,r){function n(e){if(e)return function(e){for(var t in n.prototype)e[t]=n.prototype[t];return e}(e)}e.exports=n,n.prototype.on=n.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},n.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+e];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;i1?{type:p[i],data:e.substring(1)}:{type:p[i]}:d}i=new Uint8Array(e)[0];var o=s(e,1);return y&&"blob"===r&&(o=new y([o])),{type:p[i],data:o}},t.decodeBase64Packet=function(e,t){var r=p[e.charAt(0)];if(!n)return{type:r,data:{base64:!0,data:e.substr(1)}};var i=n.decode(e.substr(1));return"blob"===t&&y&&(i=new y([i])),{type:r,data:i}},t.encodePayload=function(e,r,n){"function"==typeof r&&(n=r,r=null);var i=o(e);if(r&&i)return y&&!l?t.encodePayloadAsBlob(e,n):t.encodePayloadAsArrayBuffer(e,n);if(!e.length)return n("0:");_(e,function(e,n){t.encodePacket(e,!!i&&r,!1,function(e){n(null,function(e){return e.length+":"+e}(e))})},function(e,t){return n(t.join(""))})},t.decodePayload=function(e,r,n){if("string"!=typeof e)return t.decodePayloadAsBinary(e,r,n);var i;if("function"==typeof r&&(n=r,r=null),""===e)return n(d,0,1);for(var o,s,a="",u=0,c=e.length;u0;){for(var a=new Uint8Array(i),u=0===a[0],c="",f=1;255!==a[f];f++){if(c.length>310)return n(d,0,1);c+=a[f]}i=s(i,2+c.length),c=parseInt(c);var l=s(i,0,c);if(u)try{l=String.fromCharCode.apply(null,new Uint8Array(l))}catch(e){var h=new Uint8Array(l);l="";for(f=0;f{setTimeout(()=>{r(t)},e)})}class s{constructor(e,t){}static setup0(e,t){throw new i.IntentionallyUnimplementedError("Intentionally undefined function Transport.setup0 should have been subclassed")}p_setup1(e,t){return this}p_setup2(e,t){return this}static async p_setup(e,t,r){return(await this.setup0(e,t).p_setup1(t,r)).p_setup2(t,r)}togglePaused(e){switch(this.status){case s.STATUS_CONNECTED:this.status=s.STATUS_PAUSED;break;case s.STATUS_PAUSED:this.status=s.STATUS_CONNECTED}e&&e(this)}async p_status(e){return this.status}supports(e,t){if("string"==typeof e&&(e=n.parse(e)),e&&!e.protocol)throw new Error("URL failed to specific a scheme (before :) "+e.href);return(!e||this.supportURLs.includes(e.protocol.slice(0,-1)))&&(!t||this.supportFunctions.includes(t))}p_rawstore(e,t){throw new i.ToBeImplementedError("Intentionally undefined function Transport.p_rawstore should have been subclassed")}async p_rawstoreCaught(e,{verbose:t}){try{return await this.p_rawstore(e,{verbose:t})}catch(e){}}p_store(){throw new i.ToBeImplementedError("Undefined function Transport.p_store - may define higher level semantics here (see Python)")}p_rawfetch(e,{timeoutMS:t,start:r,end:n,relay:i=!1,verbose:o=!1}={}){return console.assert(!1,"Intentionally undefined function Transport.p_rawfetch should have been subclassed"),"UNIMPLEMENTED"}p_fetch(){throw new i.ToBeImplementedError("Undefined function Transport.p_fetch - may define higher level semantics here (see Python)")}p_rawadd(e,t,{verbose:r=!1}={}){throw new i.ToBeImplementedError("Undefined function Transport.p_rawadd")}p_rawlist(e,{verbose:t=!1}={}){throw new i.ToBeImplementedError("Undefined function Transport.p_rawlist")}p_list(){throw new Error("Undefined function Transport.p_list")}p_newlisturls(e,{verbose:t=!1}={}){throw new Error("undefined function Transport.p_newlisturls")}p_rawreverse(e,{verbose:t=!1}={}){throw new i.ToBeImplementedError("Undefined function Transport.p_rawreverse")}listmonitor(e,t,{verbose:r=!1,current:n=!1}={}){console.log("Undefined function Transport.listmonitor")}async p_newdatabase(e,{verbose:t=!1}={}){throw new i.ToBeImplementedError("Undefined function Transport.p_newdatabase")}async p_newtable(e,t,{verbose:r=!1}={}){throw new i.ToBeImplementedError("Undefined function Transport.p_newtable")}async p_set(e,t,r,{verbose:n=!1}={}){throw new i.ToBeImplementedError("Undefined function Transport.p_set")}async p_get(e,t,{verbose:r=!1}={}){throw new i.ToBeImplementedError("Undefined function Transport.p_get")}async p_delete(e,t,{verbose:r=!1}={}){throw new i.ToBeImplementedError("Undefined function Transport.p_delete")}async p_keys(e,{verbose:t=!1}={}){throw new i.ToBeImplementedError("Undefined function Transport.p_keys")}async p_getall(e,{verbose:t=!1}={}){throw new i.ToBeImplementedError("Undefined function Transport.p_keys")}static async p_f_createReadStream(e,{wanturl:t=!1,verbose:r=!1}){}static mergeoptions(e){let t={};for(let r=0;r",n),console.assert("bar"===n.testkey2.foo&&2===n.testkey3[1]&&!n.testkey),await o(200),t&&console.log(this.name,"p_test_kvt complete")}catch(e){throw console.log("Exception thrown in ",this.name,"p_test_kvt:",e.message),e}}}s.STATUS_CONNECTED=0,s.STATUS_FAILED=1,s.STATUS_STARTING=2,s.STATUS_LOADED=3,s.STATUS_PAUSED=4,e.exports=s},function(e,t,r){(function(e){function r(e){return Object.prototype.toString.call(e)}t.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===r(e)},t.isBoolean=function(e){return"boolean"==typeof e},t.isNull=function(e){return null===e},t.isNullOrUndefined=function(e){return null==e},t.isNumber=function(e){return"number"==typeof e},t.isString=function(e){return"string"==typeof e},t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=function(e){return void 0===e},t.isRegExp=function(e){return"[object RegExp]"===r(e)},t.isObject=function(e){return"object"==typeof e&&null!==e},t.isDate=function(e){return"[object Date]"===r(e)},t.isError=function(e){return"[object Error]"===r(e)||e instanceof Error},t.isFunction=function(e){return"function"==typeof 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=e.isBuffer}).call(this,r(0).Buffer)},function(e,t,r){"use strict";e.exports=function(e,t){var r,n;function i(o){if(r=o,n)return i.abort();!function i(){for(var o=!0,s=!1;o;)if(s=!1,r(null,function(a,u){if(s=!0,a=a||n){if(o=!1,t)t(!0===a?null:a);else if(a&&!0!==a)throw a}else e&&!1===e(u)||n?(o=!1,r(n||!0,t||function(){})):o||i()}),!s)return void(o=!1)}()}return i.abort=function(e,t){if("function"==typeof e&&(t=e,e=!0),n=e||!0,r)return r(n,t||function(){})},i}},function(e,t){e.exports=function(e){return e&&("string"==typeof e?function(t){return t[e]}:"object"==typeof e&&"function"==typeof e.exec?function(t){var r=e.exec(t);return r&&r[0]}:e)}},function(e,t,r){"use strict";var n=r(346);e.exports=function(e){return e=n(e),function(t){return function r(n,i){for(var o,s=!0;s;)s=!1,o=!0,t(n,function(t,n){if(!t&&!e(n))return o?s=!0:r(t,i);i(t,n)}),o=!1}}}},function(e,t){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},function(e,t,r){var n;!function(i){"use strict";var o,s=20,a=1,u=1e6,c=-7,f=21,l="[big.js] ",h=l+"Invalid ",p=h+"decimal places",d=h+"rounding mode",y=l+"Division by zero",g={},m=void 0,b=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function v(e,t,r,n){var i=e.c,o=e.e+t+1;if(o=5;else if(2===r)n=i[o]>5||5==i[o]&&(n||o<0||i[o+1]!==m||1&i[o-1]);else if(3===r)n=n||i[o]!==m||o<0;else if(n=!1,0!==r)throw Error(d);if(o<1)i.length=1,n?(e.e=-t,i[0]=1):i[0]=e.e=0;else{if(i.length=o--,n)for(;++i[o]>9;)i[o]=0,o--||(++e.e,i.unshift(1));for(o=i.length;!i[--o];)i.pop()}}else if(r<0||r>3||r!==~~r)throw Error(d);return e}function _(e,t,r,n){var i,o,s=e.constructor,a=!e.c[0];if(r!==m){if(r!==~~r||r<(3==t)||r>u)throw Error(3==t?h+"precision":p);for(r=n-(e=new s(e)).e,e.c.length>++n&&v(e,r,s.RM),2==t&&(n=e.e+r+1);e.c.length=s.PE))o=o.charAt(0)+(r>1?"."+o.slice(1):"")+(i<0?"e":"e+")+i;else if(i<0){for(;++i;)o="0"+o;o="0."+o}else if(i>0)if(++i>r)for(i-=r;i--;)o+="0";else i1&&(o=o.charAt(0)+"."+o.slice(1));return e.s<0&&(!a||4==t)?"-"+o:o}g.abs=function(){var e=new this.constructor(this);return e.s=1,e},g.cmp=function(e){var t,r=this,n=r.c,i=(e=new r.constructor(e)).c,o=r.s,s=e.s,a=r.e,u=e.e;if(!n[0]||!i[0])return n[0]?o:i[0]?-s:0;if(o!=s)return o;if(t=o<0,a!=u)return a>u^t?1:-1;for(s=(a=n.length)<(u=i.length)?a:u,o=-1;++oi[o]^t?1:-1;return a==u?0:a>u^t?1:-1},g.div=function(e){var t=this,r=t.constructor,n=t.c,i=(e=new r(e)).c,o=t.s==e.s?1:-1,s=r.DP;if(s!==~~s||s<0||s>u)throw Error(p);if(!i[0])throw Error(y);if(!n[0])return new r(0*o);var a,c,f,l,h,d=i.slice(),g=a=i.length,b=n.length,_=n.slice(0,a),w=_.length,S=e,k=S.c=[],E=0,A=s+(S.e=t.e-e.e)+1;for(S.s=o,o=A<0?0:A,d.unshift(0);w++w?1:-1;else for(h=-1,l=0;++h_[h]?1:-1;break}if(!(l<0))break;for(c=w==a?i:d;w;){if(_[--w]A&&v(S,s,r.RM,_[0]!==m),S},g.eq=function(e){return!this.cmp(e)},g.gt=function(e){return this.cmp(e)>0},g.gte=function(e){return this.cmp(e)>-1},g.lt=function(e){return this.cmp(e)<0},g.lte=function(e){return this.cmp(e)<1},g.minus=g.sub=function(e){var t,r,n,i,o=this,s=o.constructor,a=o.s,u=(e=new s(e)).s;if(a!=u)return e.s=-u,o.plus(e);var c=o.c.slice(),f=o.e,l=e.c,h=e.e;if(!c[0]||!l[0])return l[0]?(e.s=-u,e):new s(c[0]?o:0);if(a=f-h){for((i=a<0)?(a=-a,n=c):(h=f,n=l),n.reverse(),u=a;u--;)n.push(0);n.reverse()}else for(r=((i=c.length0)for(;u--;)c[t++]=0;for(u=t;r>a;){if(c[--r]0?(u=s,t=c):(i=-i,t=a),t.reverse();i--;)t.push(0);t.reverse()}for(a.length-c.length<0&&(t=c,c=a,a=t),i=c.length,o=0;i;a[i]%=10)o=(a[--i]=a[i]+c[i]+o)/10|0;for(o&&(a.unshift(o),++u),i=a.length;0===a[--i];)a.pop();return e.c=a,e.e=u,e},g.pow=function(e){var t=this,r=new t.constructor(1),n=r,i=e<0;if(e!==~~e||e<-1e6||e>1e6)throw Error(h+"exponent");for(i&&(e=-e);1&e&&(n=n.times(t)),e>>=1;)t=t.times(t);return i?r.div(n):n},g.round=function(e,t){var r=this.constructor;if(e===m)e=0;else if(e!==~~e||e<0||e>u)throw Error(p);return v(new r(this),e,t===m?r.RM:t)},g.sqrt=function(){var e,t,r,n=this,i=n.constructor,o=n.s,s=n.e,a=new i(.5);if(!n.c[0])return new i(n);if(o<0)throw Error(l+"No square root");0===(o=Math.sqrt(n.toString()))||o===1/0?((t=n.c.join("")).length+s&1||(t+="0"),(e=new i(Math.sqrt(t).toString())).e=((s+1)/2|0)-(s<0||1&s)):e=new i(o.toString()),s=e.e+(i.DP+=4);do{r=e,e=a.times(r.plus(n.div(r)))}while(r.c.slice(0,s).join("")!==e.c.slice(0,s).join(""));return v(e,i.DP-=4,i.RM)},g.times=g.mul=function(e){var t,r=this,n=r.constructor,i=r.c,o=(e=new n(e)).c,s=i.length,a=o.length,u=r.e,c=e.e;if(e.s=r.s==e.s?1:-1,!i[0]||!o[0])return new n(0*e.s);for(e.e=u+c,su;)a=t[c]+o[u]*i[c-u-1]+a,t[c--]=a%10,a=a/10|0;t[c]=(t[c]+a)%10}for(a?++e.e:t.shift(),u=t.length;!t[--u];)t.pop();return e.c=t,e},g.toExponential=function(e){return _(this,1,e,e)},g.toFixed=function(e){return _(this,2,e,this.e+e)},g.toPrecision=function(e){return _(this,3,e,e-1)},g.toString=function(){return _(this)},g.valueOf=g.toJSON=function(){return _(this,4)},(o=function e(){function t(r){var n=this;if(!(n instanceof t))return r===m?e():new t(r);r instanceof t?(n.s=r.s,n.e=r.e,n.c=r.c.slice()):function(e,t){var r,n,i;if(0===t&&1/t<0)t="-0";else if(!b.test(t+=""))throw Error(h+"number");for(e.s="-"==t.charAt(0)?(t=t.slice(1),-1):1,(r=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(r<0&&(r=n),r+=+t.slice(n+1),t=t.substring(0,n)):r<0&&(r=t.length),i=t.length,n=0;n0&&"0"==t.charAt(--i););for(e.e=r-n-1,e.c=[],r=0;n<=i;)e.c[r++]=+t.charAt(n++)}}(n,r),n.constructor=t}return t.prototype=g,t.DP=s,t.RM=a,t.NE=c,t.PE=f,t.version="5.0.2",t}()).default=o.Big=o,void 0===(n=function(){return o}.call(t,r,t,e))||(e.exports=n)}()},function(e,t,r){"use strict";var n=r(4),i=r(238),o=r(406),s=r(407),a=r(92);function u(e){a.call(this,"digest"),this._hash=e}n(u,a),u.prototype._update=function(e){this._hash.update(e)},u.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 u(s(e))}},function(e,t){e.exports={bitcoin:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},testnet:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},litecoin:{messagePrefix:"Litecoin Signed Message:\n",bip32:{public:27108450,private:27106558},pubKeyHash:48,scriptHash:50,wif:176}}},function(e,t,r){"use strict";var n=r(71),i=r(81);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;ot.length)throw new Error("invalid rlp: total length is larger than the data");if(0===(a=t.slice(n,l)).length)throw new Error("invalid rlp, List has a invalid length");for(;a.length;)u=e(a),c.push(u.data),a=u.remainder;return{data:c,remainder:t.slice(l)}}(e=c(e));return t?r:(n.equal(r.remainder.length,0,"invalid remainder"),r.data)},t.getLength=function(e){if(!e||0===e.length)return i.from([]);var t=(e=c(e))[0];if(t<=127)return e.length;if(t<=183)return t-127;if(t<=191)return t-182;if(t<=247)return t-191;var r=t-246;return r+o(e.slice(1,r).toString("hex"),16)}},function(e,t,r){"use strict";const n=r(9),i=r(12);e.exports=function(e,t,r){const o=(r=r||{}).hashAlg||"keccak-256",s=void 0===r.version?1:r.version,a=i.encode(t,o);return new n(s,e,a)}},function(e,t,r){"use strict";const n=r(5),i=r(420),o=r(421);e.exports=function(e,t,r){const s=o(e,t);return{resolver:{multicodec:e,defaultHashAlg:"keccak-256",resolve:u,tree:function(e,t,r){"function"==typeof t&&(r=t,t=void 0),t||(t={}),n([t=>s.deserialize(e,t),(e,r)=>a(e,t,r)],r)},isLink:i(u),_resolveFromEthObject:c,_treeFromEthObject:a,_mapFromEthObject:r},util:s};function a(e,t,i){n([n=>r(e,t,n),(e,t)=>t(null,e.map(e=>e.path))],i)}function u(e,t,r){n([t=>s.deserialize(e,t),(e,r)=>c(e,t,r)],r)}function c(e,t,n){if(!t||"/"===t)return n(null,{value:e,remainderPath:""});r(e,{},(e,r)=>{if(e)return n(e);const i=t.split("/");let o=r.filter(e=>e.path===t.slice(0,e.path.length));const s=(o=o.filter(e=>e.path.split("/").every((e,t)=>e===i[t]))).sort((e,t)=>e.path.lengtht.blockLength&&(t.start(),t.update(s.bytes()),s=t.digest()),r=n.util.createBuffer(),i=n.util.createBuffer(),c=s.length();for(u=0;u>>0,u>>>0];for(var c=i.fullMessageLength.length-1;c>=0;--c)i.fullMessageLength[c]+=u[1],u[1]=u[0]+(i.fullMessageLength[c]/4294967296>>>0),i.fullMessageLength[c]=i.fullMessageLength[c]>>>0,u[0]=u[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 u,c=i.fullMessageLength[i.fullMessageLength.length-1]+i.messageLengthSize&i.blockLength-1;s.putBytes(o.substr(0,i.blockLength-c));for(var f=8*i.fullMessageLength[0],l=0;l>>0,s.putInt32(f>>>0),f=u>>>0;s.putInt32(f);var h={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};a(h,r,s);var p=n.util.createBuffer();return p.putInt32(h.h0),p.putInt32(h.h1),p.putInt32(h.h2),p.putInt32(h.h3),p.putInt32(h.h4),p},i};var o=null,s=!1;function a(e,t,r){for(var n,i,o,s,a,u,c,f=r.length();f>=64;){for(i=e.h0,o=e.h1,s=e.h2,a=e.h3,u=e.h4,c=0;c<16;++c)n=r.getInt32(),t[c]=n,n=(i<<5|i>>>27)+(a^o&(s^a))+u+1518500249+n,u=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;c<20;++c)n=(n=t[c-3]^t[c-8]^t[c-14]^t[c-16])<<1|n>>>31,t[c]=n,n=(i<<5|i>>>27)+(a^o&(s^a))+u+1518500249+n,u=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;c<32;++c)n=(n=t[c-3]^t[c-8]^t[c-14]^t[c-16])<<1|n>>>31,t[c]=n,n=(i<<5|i>>>27)+(o^s^a)+u+1859775393+n,u=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;c<40;++c)n=(n=t[c-6]^t[c-16]^t[c-28]^t[c-32])<<2|n>>>30,t[c]=n,n=(i<<5|i>>>27)+(o^s^a)+u+1859775393+n,u=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;c<60;++c)n=(n=t[c-6]^t[c-16]^t[c-28]^t[c-32])<<2|n>>>30,t[c]=n,n=(i<<5|i>>>27)+(o&s|a&(o^s))+u+2400959708+n,u=a,a=s,s=(o<<30|o>>>2)>>>0,o=i,i=n;for(;c<80;++c)n=(n=t[c-6]^t[c-16]^t[c-28]^t[c-32])<<2|n>>>30,t[c]=n,n=(i<<5|i>>>27)+(o^s^a)+u+3395469782+n,u=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+u|0,f-=64}}},function(e,t,r){"use strict";const n=t;n.Reporter=r(924).Reporter,n.DecoderBuffer=r(462).DecoderBuffer,n.EncoderBuffer=r(462).EncoderBuffer,n.Node=r(925)},function(e,t,r){(function(e,r){var n=200,i="Expected a function",o="__lodash_hash_undefined__",s=1,a=2,u=1/0,c=9007199254740991,f="[object Arguments]",l="[object Array]",h="[object Boolean]",p="[object Date]",d="[object Error]",y="[object Function]",g="[object GeneratorFunction]",m="[object Map]",b="[object Number]",v="[object Object]",_="[object Promise]",w="[object RegExp]",S="[object Set]",k="[object String]",E="[object Symbol]",A="[object WeakMap]",x="[object ArrayBuffer]",I="[object DataView]",T=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,B=/^\w*$/,C=/^\./,P=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,O=/\\(\\)?/g,R=/^\[object .+?Constructor\]$/,N=/^(?:0|[1-9]\d*)$/,L={};L["[object Float32Array]"]=L["[object Float64Array]"]=L["[object Int8Array]"]=L["[object Int16Array]"]=L["[object Int32Array]"]=L["[object Uint8Array]"]=L["[object Uint8ClampedArray]"]=L["[object Uint16Array]"]=L["[object Uint32Array]"]=!0,L[f]=L[l]=L[x]=L[h]=L[I]=L[p]=L[d]=L[y]=L[m]=L[b]=L[v]=L[w]=L[S]=L[k]=L[A]=!1;var j="object"==typeof e&&e&&e.Object===Object&&e,M="object"==typeof self&&self&&self.Object===Object&&self,K=j||M||Function("return this")(),D="object"==typeof t&&t&&!t.nodeType&&t,U=D&&"object"==typeof r&&r&&!r.nodeType&&r,F=U&&U.exports===D&&j.process,q=function(){try{return F&&F.binding("util")}catch(e){}}(),H=q&&q.isTypedArray;function z(e,t){for(var r=-1,n=e?e.length:0;++r-1},Ee.prototype.set=function(e,t){var r=this.__data__,n=Be(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Ae.prototype.clear=function(){this.__data__={hash:new ke,map:new(fe||Ee),string:new ke}},Ae.prototype.delete=function(e){return Fe(this,e).delete(e)},Ae.prototype.get=function(e){return Fe(this,e).get(e)},Ae.prototype.has=function(e){return Fe(this,e).has(e)},Ae.prototype.set=function(e,t){return Fe(this,e).set(e,t),this},xe.prototype.add=xe.prototype.push=function(e){return this.__data__.set(e,o),this},xe.prototype.has=function(e){return this.__data__.has(e)},Ie.prototype.clear=function(){this.__data__=new Ee},Ie.prototype.delete=function(e){return this.__data__.delete(e)},Ie.prototype.get=function(e){return this.__data__.get(e)},Ie.prototype.has=function(e){return this.__data__.has(e)},Ie.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Ee){var i=r.__data__;if(!fe||i.lengthc))return!1;var l=o.get(e);if(l&&o.get(t))return l==t;var h=-1,p=!0,d=i&s?new xe:void 0;for(o.set(e,t),o.set(t,e);++h-1&&e%1==0&&e-1&&e%1==0&&e<=c}function it(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function ot(e){return!!e&&"object"==typeof e}function st(e){return"symbol"==typeof e||ot(e)&&re.call(e)==E}var at=H?function(e){return function(t){return e(t)}}(H):function(e){return ot(e)&&nt(e.length)&&!!L[re.call(e)]};function ut(e){return tt(e)?Te(e):Me(e)}function ct(e){return e}r.exports=function(e,t){return(et(e)?function(e,t){for(var r=-1,n=e?e.length:0,i=0,o=[];++r0;o--)u.push("0");s.splice.apply(s,u)}for(n=t||new i(r+16),o=0;o>8&255,n[r++]=255&c}}if(!n)throw Error("Invalid ip address: "+e);return n},n.toString=function(e,t,r){t=~~t;var n=[];if(4===(r=r||e.length-t)){for(var i=0;i32?"ipv6":u(t))&&(r=16);for(var o=new i(r),s=0,a=o.length;s>c)}return n.toString(o)},n.mask=function(e,t){e=n.toBuffer(e),t=n.toBuffer(t);var r=new i(Math.max(e.length,t.length)),o=0;if(e.length===t.length)for(o=0;oe.length&&(i=t,o=e);var s=i.length-o.length;for(r=s;r>>0},n.fromLong=function(e){return(e>>>24)+"."+(e>>16&255)+"."+(e>>8&255)+"."+(255&e)}},function(e,t,r){"use strict";t.Address4=r(479),t.Address6=r(968),t.v6={helpers:r(485)}},function(e,t,r){var n;!function(i){"use strict";var o={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[\+\-]/};function s(){var e=arguments[0],t=s.cache;return t[e]||(t[e]=s.parse(e)),s.format.call(null,t[e],arguments)}s.format=function(e,t){var r,n,i,a,c,l,h,p=1,d=e.length,y="",g=[],m=!0,b="";for(n=0;n=0),a[8]){case"b":r=parseInt(r,10).toString(2);break;case"c":r=String.fromCharCode(parseInt(r,10));break;case"d":case"i":r=parseInt(r,10);break;case"j":r=JSON.stringify(r,null,a[6]?parseInt(a[6]):0);break;case"e":r=a[7]?parseFloat(r).toExponential(a[7]):parseFloat(r).toExponential();break;case"f":r=a[7]?parseFloat(r).toFixed(a[7]):parseFloat(r);break;case"g":r=a[7]?parseFloat(r).toPrecision(a[7]):parseFloat(r);break;case"o":r=r.toString(8);break;case"s":r=String(r),r=a[7]?r.substring(0,a[7]):r;break;case"t":r=String(!!r),r=a[7]?r.substring(0,a[7]):r;break;case"T":r=u(r),r=a[7]?r.substring(0,a[7]):r;break;case"u":r=parseInt(r,10)>>>0;break;case"v":r=r.valueOf(),r=a[7]?r.substring(0,a[7]):r;break;case"x":r=parseInt(r,10).toString(16);break;case"X":r=parseInt(r,10).toString(16).toUpperCase()}o.json.test(a[8])?g[g.length]=r:(!o.number.test(a[8])||m&&!a[3]?b="":(b=m?"+":"-",r=r.toString().replace(o.sign,"")),l=a[4]?"0"===a[4]?"0":a[4].charAt(1):" ",h=a[6]-(b+r).length,c=a[6]&&h>0?f(l,h):"",g[g.length]=a[5]?b+r+c:"0"===l?b+c+r:c+b+r)}return g.join("")},s.cache=Object.create(null),s.parse=function(e){for(var t=e,r=[],n=[],i=0;t;){if(null!==(r=o.text.exec(t)))n[n.length]=r[0];else if(null!==(r=o.modulo.exec(t)))n[n.length]="%";else{if(null===(r=o.placeholder.exec(t)))throw new SyntaxError("[sprintf] unexpected placeholder");if(r[2]){i|=1;var s=[],a=r[2],u=[];if(null===(u=o.key.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(s[s.length]=u[1];""!==(a=a.substring(u[0].length));)if(null!==(u=o.key_access.exec(a)))s[s.length]=u[1];else{if(null===(u=o.index_access.exec(a)))throw new SyntaxError("[sprintf] failed to parse named argument key");s[s.length]=u[1]}r[2]=s}else i|=2;if(3===i)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");n[n.length]=r}t=t.substring(r[0].length)}return n};var a=function(e,t,r){return(r=(t||[]).slice(0)).splice(0,0,e),s.apply(null,r)};function u(e){return"number"==typeof e?"number":"string"==typeof e?"string":Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}var c={0:["","0","00","000","0000","00000","000000","0000000"]," ":[""," "," "," "," "," "," "," "],_:["","_","__","___","____","_____","______","_______"]};function f(e,t){return t>=0&&t<=7&&c[e]?c[e][t]:Array(t+1).join(e)}t.sprintf=s,t.vsprintf=a,void 0!==i&&(i.sprintf=s,i.vsprintf=a,void 0===(n=function(){return{sprintf:s,vsprintf:a}}.call(t,r,t,e))||(e.exports=n))}("undefined"==typeof window?this:window)},function(e,t,r){(function(t){var n=r(90);e.exports=o,e.exports.source=function(e){return o(null,e)},e.exports.sink=function(e){return o(e,null)};var i="undefined"==typeof setImmediate?t.nextTick:setImmediate;function o(e,t){e&&"object"==typeof e&&(t=e.source,e=e.sink);var r,o,s,a=[],u=[],c=new n;c.writable=c.readable=!0,c.write=function(e){return a.length?a.shift()(null,e):u.push(e),a.length||(o=!0),!!a.length},c.end=function(){t?u.length?d():t(r=!0,a.length?a.shift():function(){}):a.length&&a.shift()(!0)},c.source=function(e,t){u.length?(t(null,u.shift()),u.length||c.emit("drain")):((r=r||e)?t(r):a.push(t),o&&(o=!1,c.emit("drain")))},e&&(s=e(c.source)),s&&!t&&(t=s);var f=[],l=!1,h=!1;if(c.sink=function(e){t=e,i(d)},t){c.sink(t);var p=c.pipe.bind(c);c.pipe=function(e,t){var r=p(e,t);return c.paused&&c.resume(),r}}function d(){if(!1,t&&!h){for(;f.length&&!c.paused;)c.emit("data",f.shift());if(!c.paused){if(l)return c.emit("end");h=!0,t(null,function e(n,i){h=!1,c.paused?(!0===n?l=n:n?c.emit("error",n):f.push(i),!0):n&&!0!==(r=n)?c.emit("error",n):(r=r||n)?c.emit("end"):(c.emit("data",i),h=!0,t(null,e))})}}}return c.pause=function(){return c.paused=!0,c},c.resume=function(){return c.paused=!1,d(),c},c.destroy=function(){!r&&t&&t(r=!0,function(){}),r=!0,a.length&&a.shift()(!0),c.emit("close")},c}}).call(this,r(6))},function(e,t){function r(e,t,r){var n=e.length;if(!n)return r(t);function i(){--n||r(t)}e.forEach(function(e){e?e(t,i):i()}),n||i()}e.exports=function(e){return function(t,n){!function i(){t?r(e,t,n):e.length?e[0]?e[0](null,function(t,o){t?(e.shift(),!0===t?i():r(e,t,n)):n(null,o)}):(e.shift(),i()):n(!0)}()}}},function(e,t,r){"use strict";(function(t){const n=r(39),i=r(26),o=r(1231),s=r(307),a=r(20),u=r(14),c=r(58),f=new Error("Sorry, Not Implemented Yet."),l=c.proto(function(e){if(!(this instanceof l))return new l(e);if(null==e&&(e=""),e instanceof t)this.buffer=o.fromBuffer(e);else if("string"==typeof e||e instanceof String)this.buffer=o.fromString(e);else{if(!(e.buffer&&e.protos&&e.protoCodes))throw new Error("addr must be a string, Buffer, or another Multiaddr");this.buffer=o.fromBuffer(e.buffer)}},{className:"Multiaddr",symbolName:"@multiformats/js-multiaddr/multiaddr"});l.prototype.toString=function(){return o.bufferToString(this.buffer)},l.prototype.toOptions=function(){const e={},t=this.toString().split("/");return e.family="ip4"===t[1]?"ipv4":"ipv6",e.host=t[2],e.transport=t[3],e.port=t[4],e},l.prototype.inspect=function(){return""},l.prototype.protos=function(){return n(this.protoCodes(),function(e){return i(s(e))})},l.prototype.protoCodes=function(){const e=[],t=this.buffer;let r=0;for(;r{if(e[0]===s.names.ipfs.code)return!0})[0][1],u.decode(e)}catch(t){e=null}return e},l.prototype.equals=function(e){return this.buffer.equals(e.buffer)},l.prototype.nodeAddress=function(){if(!this.isThinWaistAddress())throw new Error('Multiaddr must be "thin waist" address for nodeAddress.');const e=this.protoCodes(),t=this.toString().split("/").slice(1);return{family:41===e[0]?"IPv6":"IPv4",address:t[1],port:t[3]}},l.fromNodeAddress=function(e,t){if(!e)throw new Error("requires node address object");if(!t)throw new Error("requires transport protocol");const r="IPv6"===e.family?"ip6":"ip4";return l("/"+[r,e.address,t,e.port].join("/"))},l.prototype.isThinWaistAddress=function(e){const t=(e||this).protos();return!(2!==t.length||4!==t[0].code&&41!==t[0].code||6!==t[1].code&&17!==t[1].code)},l.prototype.fromStupidString=function(e){throw f},l.protocols=s,l.isName=function(e){return!!l.isMultiaddr(e)&&e.protos().some(e=>e.resolvable)},l.resolve=function(e,t){return l.isMultiaddr(e)&&l.isName(e)?t(new Error("not implemented yet")):t(new Error("not a valid name"))},e.exports=l}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(142),i=r(51),o=r(196),s=r(144);e.exports=function(e){function t(e,t,r){return r=r||(()=>{}),e.write(s.CircuitRelay.encode({type:s.CircuitRelay.Type.STATUS,code:t})),r()}return{getB58String:function(e){let t=null;n.isMultiaddr(e)?t=n(e).getPeerId():i.isPeerInfo(e)&&(t=e.id.toB58String());return t},peerInfoFromMa:function(t){let r;if(i.isPeerInfo(t))r=t;else if(n.isMultiaddr(t)){const n=t.getPeerId();try{r=e._peerBook.get(n)}catch(e){r=new i(o.createFromB58String(n))}r.multiaddrs.add(t)}else if(o.isPeerId(t)){const n=t.toB58String();r=e._peerBook.has(n)?e._peerBook.get(n):t}return r},isPeerConnected:function(t){return e.muxedConns[t]||e.conns[t]},validateAddrs:function(e,r,i,o){try{e.dstPeer.addrs.forEach(e=>n(e))}catch(e){return t(r,i===s.CircuitRelay.Type.HOP?s.CircuitRelay.Status.HOP_DST_MULTIADDR_INVALID:s.CircuitRelay.Status.STOP_DST_MULTIADDR_INVALID),o(e)}try{e.srcPeer.addrs.forEach(e=>n(e))}catch(e){return t(r,i===s.CircuitRelay.Type.HOP?s.CircuitRelay.Status.HOP_SRC_MULTIADDR_INVALID:s.CircuitRelay.Status.STOP_SRC_MULTIADDR_INVALID),o(e)}return o(null)},writeResponse:t}}},function(e,t,r){"use strict";const n=r(11);e.exports=n(r(1250))},function(e,t,r){"use strict";t.importer=t.Importer=r(1363),t.exporter=t.Exporter=r(1385)},function(e,t,r){"use strict";const n=r(35).Key;e.exports={FILE_SEPARATOR:"/",MFS_ROOT_KEY:new n("/local/filesroot"),MAX_CHUNK_SIZE:262144,MAX_LINKS:174,FILE_TYPES:{file:0,directory:1}}},function(e,t,r){(function(t){e.exports=function(e,r){var n,i,o,s=!0;function a(e){function i(){r&&r(e,n),r=null}s?t.nextTick(i):i()}function u(e,t,r){n[e]=r,(0==--i||t)&&a(t)}Array.isArray(e)?(n=[],i=e.length):(o=Object.keys(e),n={},i=o.length),i?o?o.forEach(function(t){e[t](function(e,r){u(t,e,r)})}):e.forEach(function(e,t){e(function(e,r){u(t,e,r)})}):a(null),s=!1}}).call(this,r(6))},function(e,t,r){var n=new(r(1495)),i="undefined"!=typeof window?window:self,o=i.crypto||i.msCrypto||{},s=o.subtle||o.webkitSubtle;function a(e){return n.digest(e)}try{s.digest({name:"sha-1"},new Uint8Array).catch(function(){s=!1})}catch(e){s=!1}e.exports=function(e,t){s?("string"==typeof e&&(e=function(e){for(var t=e.length,r=new Uint8Array(t),n=0;n>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")}(new Uint8Array(e)))},function(r){t(a(e))})):setTimeout(t,0,a(e))},e.exports.sync=a},function(e,t,r){const n=r(79);utils={},utils.consolearr=(e=>e&&e.length>0?[e.length+" items inc:",e[e.length-1]]:e),utils.stringfrom=function(e,t={}){try{return"Url"===e.constructor.name?e.href:"string"==typeof e?e:e.toString()}catch(t){throw new n.CodingError(`Unable to turn ${e} into a string ${t.message}`)}},utils.p_timeout=function(e,t,r){let i=null;return Promise.race([new Promise((e,o)=>{i=setTimeout(o,t,new n.TimeoutError(r||`Timed out in ${t}ms`))}),e.then(e=>(clearTimeout(i),e))])},utils.createElement=function(e,t,r){var n=document.createElement(e);for(let e in t){let r="classname"===e.toLowerCase()?"class":e;if("dangerouslySetInnerHTML"===e&&(n.innerHTML=t[e].__html,delete t.dangerouslySetInnerHTML),t.hasOwnProperty(e)){let i=t[e];if(!0===i)n.setAttribute(r,e);else if("object"!=typeof i||Array.isArray(i))!1!==i&&null!=i&&n.setAttribute(r,i.toString());else if(["style"].includes(r))for(let e in i)n[r][e]=i[e];else n[r]=i}}for(let e=2;en.appendChild(null==e.nodeType?document.createTextNode(e.toString()):e)):n.appendChild(null==t.nodeType?document.createTextNode(t.toString()):t))}return n},e.exports=utils},function(e,t,r){"use strict";(function(t){!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,r,n,i){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick(function(){e.call(null,r)});case 3:return t.nextTick(function(){e.call(null,r,n)});case 4:return t.nextTick(function(){e.call(null,r,n,i)});default:for(o=new Array(a-1),s=0;se.plus(t.value.byteLength).plus(t.key._buf.byteLength),new f(0),t))}function E(e,t){return r=>{t(r&&!e(r)?r:null)}}function A(e){return E(e=>"Already open"===e.message,e)}e.exports=class{constructor(e,t){a.equal(typeof e,"string","missing repoPath"),this.options=function(e){const t=Object.assign({},m,e);return t.storageBackends=Object.assign({},m.storageBackends,t.storageBackends),t.storageBackendOptions=Object.assign({},m.storageBackendOptions,t.storageBackendOptions),t}(t),this.closed=!0,this.path=e,this._locker=this._getLocker(),this.root=h.create("root",this.path,this.options),this.version=p(this.root),this.config=d(this.root),this.apiAddr=y(this.root)}init(e,t){v("initializing at: %s",this.path),i([e=>this.root.open(A(e)),t=>this.config.set(e,t),e=>this.version.set(S,e)],t)}open(e){this.closed?(v("opening at: %s",this.path),n([e=>this.root.open(A(e)),e=>this._isInitialized(e),e=>this._openLock(this.path,e),(e,t)=>{v("aquired repo.lock"),this.lockfile=e,t()},e=>{v("creating datastore"),this.datastore=h.create("datastore",u.join(this.path,"datastore"),this.options),v("creating blocks");const t=h.create("blocks",u.join(this.path,"blocks"),this.options);g(t,this.options.storageBackendOptions.blocks,e)},(e,t)=>{this.blocks=e,t()},e=>{v("creating keystore"),this.keys=h.create("keys",u.join(this.path,"keys"),this.options),e()},e=>{this.closed=!1,v("all opened"),e()}],t=>{t&&this.lockfile?this._closeLock(r=>{r?v("error removing lock",r):this.lockfile=null,e(t)}):e(t)})):setImmediate(()=>e(new Error("repo is already open")))}_getLocker(){return"string"==typeof this.options.lock?(a(w[this.options.lock],"Unknown lock type: "+this.options.lock),w[this.options.lock]):(a(this.options.lock,"No lock provided"),this.options.lock)}_openLock(e,t){this._locker.lock(e,(e,r)=>{if(e)return t(e,null);a.equal(typeof r.close,"function","Locks must have a close method"),t(null,r)})}_closeLock(e){if(this.lockfile)return this.lockfile.close(e);e()}_isLocked(e,t){if(this._locker)return this._locker.locked(e,t);t(null,!1)}_isInitialized(e){v("init check"),o({config:e=>this.config.exists(e),version:e=>this.version.check(S,e)},(t,r)=>{if(v("init",t,r),t&&!r.config)return e(Object.assign(new Error("repo is not initialized yet"),{code:b.ERR_REPO_NOT_INITIALIZED,path:this.path}));e(t)})}close(e){if(this.closed)return e(new Error("repo is already closed"));v("closing at: %s",this.path),i([e=>this.apiAddr.delete(function(e){return E(e=>e&&(e.code===b.ERR_REPO_NOT_INITIALIZED||e.message.startsWith("ENOENT")),e)}(e)),e=>{s([this.blocks,this.keys,this.datastore],(e,t)=>e.close(t),e)},e=>{v("unlocking"),this.closed=!0,this._closeLock(e)},e=>{this.lockfile=null,e()}],t=>e(t))}exists(e){this.version.exists(e)}stat(e,t){"function"==typeof e&&(t=e,e={}),e=Object.assign({},{human:!1},e),o({storageMax:e=>this.config.get("Datastore.StorageMax",(t,r)=>{e(null,new f(t?_:r))}),version:e=>this.version.get(e),blocks:e=>this.blocks.query({},(t,r)=>{const n=new f((r=r||[]).length);let i=new f(0);r.forEach(e=>{i=i.plus(e.value.byteLength).plus(e.key._buf.byteLength)}),e(t,{count:n,size:i})}),datastore:e=>k(this.datastore,e),keys:e=>k(this.keys,e)},(r,n)=>{if(r)return t(r);let i=n.blocks.size.plus(n.datastore).plus(n.keys);e.human&&(i=i.div(1048576)),t(null,{repoPath:this.path,storageMax:n.storageMax,version:n.version,numObjects:n.blocks.count,repoSize:i})})}},e.exports.repoVersion=S,e.exports.errors=b},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return function(){if(null!==e){var t=e;e=null,t.apply(this,arguments)}}},e.exports=t.default},function(e,t,r){var n=r(158),i=r(665),o=r(666),s="[object Null]",a="[object Undefined]",u=n?n.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?a:s:u&&u in Object(e)?i(e):o(e)}},function(e,t,r){var n=r(159).Symbol;e.exports=n},function(e,t,r){var n=r(352),i="object"==typeof self&&self&&self.Object===Object&&self,o=n||i||Function("return this")();e.exports=o},function(e,t){e.exports=function(e){return null!=e&&"object"==typeof e}},function(e,t){e.exports=function(){var e,t,r,n,i=function(i,o){e?e(i,o):i?(n=i,r=o):t=o};return i.resolve=function(i){if(e)throw new Error("already resolved");if(!(e=i))throw new Error("no read cannot resolve!"+e);t&&i(null,t),r&&i(n,r)},i.abort=function(e){i.resolve(function(t,r){r(e||!0)})},i}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){var r=(0,i.default)(e);return(0,n.default)(function(e,t){r(e[0],t)},t,1)};var n=o(r(687)),i=o(r(34));function o(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default},function(e,t,r){"use strict";const n=r(8);e.exports=class{constructor(e,t){this.child=e,this.transform=t}open(e){this.child.open(e)}put(e,t,r){this.child.put(this.transform.convert(e),t,r)}get(e,t){this.child.get(this.transform.convert(e),t)}has(e,t){this.child.has(this.transform.convert(e),t)}delete(e,t){this.child.delete(this.transform.convert(e),t)}batch(){const e=this.child.batch();return{put:(t,r)=>{e.put(this.transform.convert(t),r)},delete:t=>{e.delete(this.transform.convert(t))},commit:t=>{e.commit(t)}}}query(e){return n(this.child.query(e),n.map(e=>(e.key=this.transform.invert(e.key),e)))}close(e){this.child.close(e)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return function(t,r,o){return e(n.default,t,(0,i.default)(r),o)}};var n=o(r(219)),i=o(r(34));function o(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default},function(e,t,r){"use strict";(function(t){const n=r(8),i=r(710),o=r(35).utils.asyncFilter,s=r(35).utils.asyncSort,a=r(35).Key,u=r(718);e.exports=class{constructor(e,t){let n;t&&t.db?(n=t.db,delete t.db):n=r(723),this.db=i(u(n(e),{valueEncoding:"binary"}),Object.assign({},t,{compression:!1}),e=>{if(e)throw e})}open(e){this.db.open(e)}put(e,t,r){this.db.put(e.toString(),t,r)}get(e,t){this.db.get(e.toString(),t)}has(e,t){this.db.get(e.toString(),(e,r)=>{if(e)return e.notFound?void t(null,!1):void t(e);t(null,!0)})}delete(e,t){this.db.del(e.toString(),e=>{t(e)})}close(e){this.db.close(e)}batch(){const e=[];return{put:(t,r)=>{e.push({type:"put",key:t.toString(),value:r})},delete:t=>{e.push({type:"del",key:t.toString()})},commit:t=>{this.db.batch(e,t)}}}query(e){let r=!0;null!=e.keysOnly&&(r=!e.keysOnly);const i=this.db.db.iterator({keys:!0,values:r,keyAsBuffer:!0});let u=[(e,n)=>{if(e)return i.end(t=>{n(t||e)});i.next((e,o,s)=>{if(e)return n(e);if(null==e&&null==o&&null==s)return i.end(e=>{n(e||!0)});const u={key:new a(o,!1)};r&&(u.value=t.from(s)),n(null,u)})}],c=[];if(null!=e.prefix){const t=e.prefix;c.push((e,r)=>r(null,e.key.toString().startsWith(t)))}if(null!=e.filters&&(c=c.concat(e.filters)),u=u.concat(c.map(e=>o(e))),null!=e.orders&&(u=u.concat(e.orders.map(e=>s(e)))),null!=e.offset){let t=0;u.push(n.filter(()=>t++>=e.offset))}return null!=e.limit&&u.push(n.take(e.limit)),n.apply(null,u)}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(n){const i=r(12),o=r(16),s=r(58);(t=e.exports=s(class{constructor(e,t,r,s){o(r,"DAGNode needs its serialized format"),o(s,"DAGNode needs its multihash"),"string"==typeof s&&(s=i.fromB58String(s)),this._data=e||n.alloc(0),this._links=t||[],this._serialized=r,this._multihash=s,this._size=this.links.reduce((e,t)=>e+t.size,this.serialized.length),this._json={data:this.data,links:this.links.map(e=>e.toJSON()),multihash:i.toB58String(this.multihash),size:this.size}}toJSON(){return this._json}toString(){return`DAGNode <${i.toB58String(this.multihash)} - data: "${this.data.toString()}", links: ${this.links.length}, size: ${this.size}>`}get data(){return this._data}set data(e){throw new Error("Can't set property: 'data' is immutable")}get links(){return this._links}set links(e){throw new Error("Can't set property: 'links' is immutable")}get serialized(){return this._serialized}set serialized(e){throw new Error("Can't set property: 'serialized' is immutable")}get size(){return this._size}set size(e){throw new Error("Can't set property: 'size' is immutable")}get multihash(){return this._multihash}set multihash(e){throw new Error("Can't set property: 'multihash' is immutable")}},{className:"DAGNode",symbolName:"@ipld/js-ipld-dag-pb/dagnode"})).create=r(167),t.clone=r(758),t.addLink=r(759),t.rmLink=r(760)}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(61),i=r(744),o=r(227).serialize,s=r(168).linkSort,a=r(166),u=r(91);e.exports=function(e,r,c,f){if("function"==typeof e?(f=e,e=void 0):"string"==typeof e&&(e=t.from(e)),"function"==typeof r&&(f=r,r=[]),"function"==typeof c&&(f=c,c=void 0),!t.isBuffer(e))return f(new Error("Passed 'data' is not a buffer or a string!"));c||(c="sha2-256");const l=r.map(e=>u.isDAGLink(e)?e:u.util.createDagLinkFromB58EncodedHash(e)),h=i(l,s);o({data:e,links:h},(t,r)=>{if(t)return f(t);n(r,c,(t,n)=>{if(t)return f(t);const i=new a(e,h,r,n);f(null,i)})})}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(n){const i=r(91);(t=e.exports).cloneData=function(e){let t;return e.data&&e.data.length>0?(t=n.alloc(e.data.length),e.data.copy(t)):t=n.alloc(0),t},t.cloneLinks=function(e){return e.links.slice()},t.linkSort=function(e,t){const r=n.from(e.name||""),i=n.from(t.name||"");return r.compare(i)},t.toDAGLink=function(e){return new i("",e.size,e.multihash)}}).call(this,r(0).Buffer)},function(e,t,r){var n;!function(i){"use strict";var o,s=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,a=Math.ceil,u=Math.floor,c="[BigNumber Error] ",f=c+"Number primitive has more than 15 significant digits: ",l=1e14,h=14,p=9007199254740991,d=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],y=1e7,g=1e9;function m(e){var t=0|e;return e>0||e===t?t:t-1}function b(e){for(var t,r,n=1,i=e.length,o=e[0]+"";nc^r?1:-1;for(a=(u=i.length)<(c=o.length)?u:c,s=0;so[s]^r?1:-1;return u==c?0:u>c^r?1:-1}function _(e,t,r,n){if(er||e!==(e<0?a(e):u(e)))throw Error(c+(n||"Argument")+("number"==typeof e?er?" out of range: ":" not an integer: ":" not a primitive number: ")+e)}function w(e){return"[object Array]"==Object.prototype.toString.call(e)}function S(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function k(e,t,r){var n,i;if(t<0){for(i=r+".";++t;i+=r);e=i+e}else if(++t>(n=e.length)){for(i=r,t-=n;--t;i+=r);e+=i}else t=10;c/=10,a++);return g.e=a,void(g.c=[e])}y=e+""}else{if(!s.test(y=e+""))return i(g,y,l);g.s=45==y.charCodeAt(0)?(y=y.slice(1),-1):1}}else{if(_(t,2,q.length,"Base"),y=e+"",10==t)return W(g=new H(e instanceof H?e:y),O+g.e+1,R);if(l="number"==typeof e){if(0*e!=0)return i(g,y,l,t);if(g.s=1/e<0?(y=y.slice(1),-1):1,y.replace(/^0\.0*|\./,"").length>15)throw Error(f+e);l=!1}else g.s=45===y.charCodeAt(0)?(y=y.slice(1),-1):1,t>10&&t<37&&(y=y.toLowerCase());for(r=q.slice(0,t),a=c=0,d=y.length;ca){a=d;continue}return i(g,e+"",l,t)}y=n(y,t,10,g.s)}for((a=y.indexOf("."))>-1&&(y=y.replace(".","")),(c=y.search(/e/i))>0?(a<0&&(a=c),a+=+y.slice(c+1),y=y.substring(0,c)):a<0&&(a=y.length),c=0;48===y.charCodeAt(c);c++);for(d=y.length;48===y.charCodeAt(--d););if(y=y.slice(c,d+1)){if(d=y.length,l&&d>15&&(e>p||e!==u(e)))throw Error(f+g.s*e);if((a=a-c-1)>M)g.c=g.e=null;else if(aa){if(--t>0)for(u+=".";t--;u+="0");}else if((t+=o-a)>0)for(o+1==a&&(u+=".");t--;u+="0");return e.s<0&&i?"-"+u:u}function V(e,t){var r,n,i=0;for(w(e[0])&&(e=e[0]),r=new H(e[0]);++i=10;i/=10,n++);return(r=n+r*h-1)>M?e.c=e.e=null:r=10;c/=10,i++);if((o=t-i)<0)o+=h,s=t,y=(f=g[p=0])/m[i-s-1]%10|0;else if((p=a((o+1)/h))>=g.length){if(!n)break e;for(;g.length<=p;g.push(0));f=y=0,i=1,s=(o%=h)-h+1}else{for(f=c=g[p],i=1;c>=10;c/=10,i++);y=(s=(o%=h)-h+i)<0?0:f/m[i-s-1]%10|0}if(n=n||t<0||null!=g[p+1]||(s<0?f:f%m[i-s-1]),n=r<4?(y||n)&&(0==r||r==(e.s<0?3:2)):y>5||5==y&&(4==r||n||6==r&&(o>0?s>0?f/m[i-s]:0:g[p-1])%10&1||r==(e.s<0?8:7)),t<1||!g[0])return g.length=0,n?(t-=e.e+1,g[0]=m[(h-t%h)%h],e.e=-t||0):g[0]=e.e=0,e;if(0==o?(g.length=p,c=1,p--):(g.length=p+1,c=m[h-o],g[p]=s>0?u(f/m[i-s]%m[s])*c:0),n)for(;;){if(0==p){for(o=1,s=g[0];s>=10;s/=10,o++);for(s=g[0]+=c,c=1;s>=10;s/=10,c++);o!=c&&(e.e++,g[0]==l&&(g[0]=1));break}if(g[p]+=c,g[p]!=l)break;g[p--]=0,c=1}for(o=g.length;0===g[--o];g.pop());}e.e>M?e.c=e.e=null:e.e>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),t[s]=r[0],t[s+1]=r[1]):(f.push(o%1e14),s+=2);s=i/2}else{if(!crypto.randomBytes)throw K=!1,Error(c+"crypto unavailable");for(t=crypto.randomBytes(i*=7);s=9e15?crypto.randomBytes(7).copy(t,s):(f.push(o%1e14),s+=7);s=i/7}if(!K)for(;s=10;o/=10,s++);sr-1&&(null==s[i+1]&&(s[i+1]=0),s[i+1]+=s[i]/r|0,s[i]%=r)}return s.reverse()}return function(n,i,o,s,a){var u,c,f,l,h,p,d,y,g=n.indexOf("."),m=O,v=R;for(g>=0&&(l=U,U=0,n=n.replace(".",""),p=(y=new H(i)).pow(n.length-g),U=l,y.c=t(k(b(p.c),p.e,"0"),10,o,e),y.e=y.c.length),f=l=(d=t(n,i,o,a?(u=q,e):(u=e,q))).length;0==d[--l];d.pop());if(!d[0])return u.charAt(0);if(g<0?--f:(p.c=d,p.e=f,p.s=s,d=(p=r(p,y,m,v,o)).c,h=p.r,f=p.e),g=d[c=f+m+1],l=o/2,h=h||c<0||null!=d[c+1],h=v<4?(null!=g||h)&&(0==v||v==(p.s<0?3:2)):g>l||g==l&&(4==v||h||6==v&&1&d[c-1]||v==(p.s<0?8:7)),c<1||!d[0])n=h?k(u.charAt(1),-m,u.charAt(0)):u.charAt(0);else{if(d.length=c,h)for(--o;++d[--c]>o;)d[c]=0,c||(++f,d=[1].concat(d));for(l=d.length;!d[--l];);for(g=0,n="";g<=l;n+=u.charAt(d[g++]));n=k(n,f,u.charAt(0))}return n}}(),r=function(){function e(e,t,r){var n,i,o,s,a=0,u=e.length,c=t%y,f=t/y|0;for(e=e.slice();u--;)a=((i=c*(o=e[u]%y)+(n=f*o+(s=e[u]/y|0)*c)%y*y+a)/r|0)+(n/y|0)+f*s,e[u]=i%r;return a&&(e=[a].concat(e)),e}function t(e,t,r,n){var i,o;if(r!=n)o=r>n?1:-1;else for(i=o=0;it[i]?1:-1;break}return o}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]1;e.splice(0,1));}return function(n,i,o,s,a){var c,f,p,d,y,g,b,v,_,w,S,k,E,A,x,I,T,B=n.s==i.s?1:-1,C=n.c,P=i.c;if(!(C&&C[0]&&P&&P[0]))return new H(n.s&&i.s&&(C?!P||C[0]!=P[0]:P)?C&&0==C[0]||!P?0*B:B/0:NaN);for(_=(v=new H(B)).c=[],B=o+(f=n.e-i.e)+1,a||(a=l,f=m(n.e/h)-m(i.e/h),B=B/h|0),p=0;P[p]==(C[p]||0);p++);if(P[p]>(C[p]||0)&&f--,B<0)_.push(1),d=!0;else{for(A=C.length,I=P.length,p=0,B+=2,(y=u(a/(P[0]+1)))>1&&(P=e(P,y,a),C=e(C,y,a),I=P.length,A=C.length),E=I,S=(w=C.slice(0,I)).length;S=a/2&&x++;do{if(y=0,(c=t(P,w,I,S))<0){if(k=w[0],I!=S&&(k=k*a+(w[1]||0)),(y=u(k/x))>1)for(y>=a&&(y=a-1),b=(g=e(P,y,a)).length,S=w.length;1==t(g,w,b,S);)y--,r(g,I=10;B/=10,p++);W(v,o+(v.e=p+f*h-1)+1,s,d)}else v.e=f,v.r=+d;return v}}(),A=/^(-?)0([xbo])(?=\w[\w.]*$)/i,x=/^([^.]+)\.$/,I=/^\.([^.]+)$/,T=/^-?(Infinity|NaN)$/,B=/^\s*\+(?=[\w.])|^\s+|\s+$/g,i=function(e,t,r,n){var i,o=r?t:t.replace(B,"");if(!T.test(o)){if(!r&&(o=o.replace(A,function(e,t,r){return i="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=i?e:t}),n&&(i=n,o=o.replace(x,"$1").replace(I,"0.$1")),t!=o))return new H(o,i);throw Error(c+"Not a"+(n?" base "+n:"")+" number: "+t)}e.s=isNaN(o)?null:o<0?-1:1,e.c=e.e=null},C.absoluteValue=C.abs=function(){var e=new H(this);return e.s<0&&(e.s=1),e},C.comparedTo=function(e,t){return v(this,new H(e,t))},C.decimalPlaces=C.dp=function(e,t){var r,n,i,o=this;if(null!=e)return _(e,0,g),null==t?t=R:_(t,0,8),W(new H(o),e+o.e+1,t);if(!(r=o.c))return null;if(n=((i=r.length-1)-m(this.e/h))*h,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},C.dividedBy=C.div=function(e,t){return r(this,new H(e,t),O,R)},C.dividedToIntegerBy=C.idiv=function(e,t){return r(this,new H(e,t),0,1)},C.isEqualTo=C.eq=function(e,t){return 0===v(this,new H(e,t))},C.integerValue=function(e){var t=new H(this);return null==e?e=R:_(e,0,8),W(t,t.e+1,e)},C.isGreaterThan=C.gt=function(e,t){return v(this,new H(e,t))>0},C.isGreaterThanOrEqualTo=C.gte=function(e,t){return 1===(t=v(this,new H(e,t)))||0===t},C.isFinite=function(){return!!this.c},C.isInteger=function(){return!!this.c&&m(this.e/h)>this.c.length-2},C.isNaN=function(){return!this.s},C.isNegative=function(){return this.s<0},C.isPositive=function(){return this.s>0},C.isZero=function(){return!!this.c&&0==this.c[0]},C.isLessThan=C.lt=function(e,t){return v(this,new H(e,t))<0},C.isLessThanOrEqualTo=C.lte=function(e,t){return-1===(t=v(this,new H(e,t)))||0===t},C.minus=function(e,t){var r,n,i,o,s=this,a=s.s;if(t=(e=new H(e,t)).s,!a||!t)return new H(NaN);if(a!=t)return e.s=-t,s.plus(e);var u=s.e/h,c=e.e/h,f=s.c,p=e.c;if(!u||!c){if(!f||!p)return f?(e.s=-t,e):new H(p?s:NaN);if(!f[0]||!p[0])return p[0]?(e.s=-t,e):new H(f[0]?s:3==R?-0:0)}if(u=m(u),c=m(c),f=f.slice(),a=u-c){for((o=a<0)?(a=-a,i=f):(c=u,i=p),i.reverse(),t=a;t--;i.push(0));i.reverse()}else for(n=(o=(a=f.length)<(t=p.length))?a:t,a=t=0;t0)for(;t--;f[r++]=0);for(t=l-1;n>a;){if(f[--n]=0;){for(r=0,d=k[i]%_,g=k[i]/_|0,o=i+(s=u);o>i;)r=((c=d*(c=S[--s]%_)+(a=g*c+(f=S[s]/_|0)*d)%_*_+b[o]+r)/v|0)+(a/_|0)+g*f,b[o--]=c%v;b[o]=r}return r?++n:b.splice(0,1),G(e,b,n)},C.negated=function(){var e=new H(this);return e.s=-e.s||null,e},C.plus=function(e,t){var r,n=this,i=n.s;if(t=(e=new H(e,t)).s,!i||!t)return new H(NaN);if(i!=t)return e.s=-t,n.minus(e);var o=n.e/h,s=e.e/h,a=n.c,u=e.c;if(!o||!s){if(!a||!u)return new H(i/0);if(!a[0]||!u[0])return u[0]?e:new H(a[0]?n:0*i)}if(o=m(o),s=m(s),a=a.slice(),i=o-s){for(i>0?(s=o,r=u):(i=-i,r=a),r.reverse();i--;r.push(0));r.reverse()}for((i=a.length)-(t=u.length)<0&&(r=u,u=a,a=r,t=i),i=0;t;)i=(a[--t]=a[t]+u[t]+i)/l|0,a[t]=l===a[t]?0:a[t]%l;return i&&(a=[i].concat(a),++s),G(e,a,s)},C.precision=C.sd=function(e,t){var r,n,i,o=this;if(null!=e&&e!==!!e)return _(e,1,g),null==t?t=R:_(t,0,8),W(new H(o),e,t);if(!(r=o.c))return null;if(n=(i=r.length-1)*h+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return e&&o.e+1>n&&(n=o.e+1),n},C.shiftedBy=function(e){return _(e,-p,p),this.times("1e"+e)},C.squareRoot=C.sqrt=function(){var e,t,n,i,o,s=this,a=s.c,u=s.s,c=s.e,f=O+4,l=new H("0.5");if(1!==u||!a||!a[0])return new H(!u||u<0&&(!a||a[0])?NaN:a?s:1/0);if(0==(u=Math.sqrt(+s))||u==1/0?(((t=b(a)).length+c)%2==0&&(t+="0"),u=Math.sqrt(t),c=m((c+1)/2)-(c<0||c%2),n=new H(t=u==1/0?"1e"+c:(t=u.toExponential()).slice(0,t.indexOf("e")+1)+c)):n=new H(u+""),n.c[0])for((u=(c=n.e)+f)<3&&(u=0);;)if(o=n,n=l.times(o.plus(r(s,o,f,1))),b(o.c).slice(0,u)===(t=b(n.c)).slice(0,u)){if(n.e0&&h>0){for(n=h%o||o,u=l.substr(0,n);n0&&(u+=a+l.slice(n)),f&&(u="-"+u)}r=c?u+F.decimalSeparator+((s=+F.fractionGroupSize)?c.replace(new RegExp("\\d{"+s+"}\\B","g"),"$&"+F.fractionGroupSeparator):c):u}return r},C.toFraction=function(e){var t,n,i,o,s,a,u,f,l,p,y,g,m=this,v=m.c;if(null!=e&&(!(f=new H(e)).isInteger()||f.lt(P)))throw Error(c+"Argument "+(f.isInteger()?"out of range: ":"not an integer: ")+e);if(!v)return m.toString();for(n=new H(P),p=i=new H(P),o=l=new H(P),g=b(v),a=n.e=g.length-m.e-1,n.c[0]=d[(u=a%h)<0?h+u:u],e=!e||f.comparedTo(n)>0?a>0?n:p:f,u=M,M=1/0,f=new H(g),l.c[0]=0;y=r(f,n,0,1),1!=(s=i.plus(y.times(o))).comparedTo(e);)i=o,o=s,p=l.plus(y.times(s=p)),l=s,n=f.minus(y.times(s=n)),f=s;return s=r(e.minus(i),o,0,1),l=l.plus(s.times(p)),i=i.plus(s.times(o)),l.s=p.s=m.s,t=r(p,o,a*=2,R).minus(m).abs().comparedTo(r(l,i,a,R).minus(m).abs())<1?[p.toString(),o.toString()]:[l.toString(),i.toString()],M=u,t},C.toNumber=function(){return+this},C.exponentiatedBy=C.pow=function(e,t){var r,n,i,o,s=this;for(_(e,-p,p),null!=t&&(t=new H(t)),t?e>1&&s.gt(P)&&s.isInteger()&&t.gt(P)&&t.isInteger()?s=s.mod(t):(o=t,t=null):U&&(n=a(U/h+2)),i=new H(P),r=u(e<0?-e:e);;){if(r%2){if(!(i=i.times(s)).c)break;n?i.c.length>n&&(i.c.length=n):t&&(i=i.mod(t))}if(!(r=u(r/2)))break;s=s.times(s),n?s.c&&s.c.length>n&&(s.c.length=n):t&&(s=s.mod(t))}return t?i:(e<0&&(i=P.div(i)),o?i.mod(o):n?W(i,U,R):i)},C.toPrecision=function(e,t){return null!=e&&_(e,1,g),z(this,e,t,2)},C.toString=function(e){var t,r=this,i=r.s,o=r.e;return null===o?i?(t="Infinity",i<0&&(t="-"+t)):t="NaN":(t=b(r.c),null==e?t=o<=N||o>=L?S(t,o):k(t,o,"0"):(_(e,2,q.length,"Base"),t=n(k(t,o,"0"),10,e,i,!0)),i<0&&r.c[0]&&(t="-"+t)),t},C.valueOf=C.toJSON=function(){var e,t=this,r=t.e;return null===r?t.toString():(e=b(t.c),e=r<=N||r>=L?S(e,r):k(e,r,"0"),t.s<0?"-"+e:e)},C._isBigNumber=!0,null!=t&&H.set(t),H}()).default=o.BigNumber=o,void 0===(n=function(){return o}.call(t,r,t,e))||(e.exports=n)}()},function(e,t,r){"use strict";const n=r(169);t.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7},t.TAG={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,REGEXP:35,MIME:36},t.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31},t.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23},t.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")},t.SHIFT32=Math.pow(2,32),t.SHIFT16=Math.pow(2,16),t.MAX_SAFE_HIGH=2097151,t.NEG_ONE=new n(-1),t.TEN=new n(10),t.TWO=new n(2),t.PARENT={ARRAY:0,OBJECT:1,MAP:2,TAG:3,BYTE_STRING:4,UTF8_STRING:5}},function(e,t,r){"use strict";const n=r(172).SmartBuffer,i=r(339),o=r(152),s=r(12),a=r(9);(t=e.exports).SHA1_LENGTH=i.defaultLengths[i.names.sha1],t.find=((e,t)=>{for(let r=0;r{let t=e.match(/^(([^<]+)\s)?\s?<([^>]+)>\s?(\d+\s[+\-\d]+)?$/);return null===t?null:{name:t[2],email:t[3],date:t[4]}}),t.serializePersonLine=(e=>{let t=[];return e.name&&t.push(e.name),t.push("<"+e.email+">"),e.date&&t.push(e.date),t.join(" ")}),t.shaToCid=(e=>{let r=new n;return r.writeUInt8(1),r.writeBuffer(o["git-raw"]),r.writeUInt8(i.names.sha1),r.writeUInt8(t.SHA1_LENGTH),r.writeBuffer(e),r.toBuffer()}),t.cidToSha=(e=>{let t=s.decode(new a(e).multihash);return"sha1"!==t.name?null:t.digest})},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(768),i=4096,o="utf8";class s{constructor(t){if(this.length=0,this._encoding=o,this._writeOffset=0,this._readOffset=0,s.isSmartBufferOptions(t))if(t.encoding&&(n.checkEncoding(t.encoding),this._encoding=t.encoding),t.size){if(!(n.isFiniteInteger(t.size)&&t.size>0))throw new Error(n.ERRORS.INVALID_SMARTBUFFER_SIZE);this._buff=e.allocUnsafe(t.size)}else if(t.buff){if(!(t.buff instanceof e))throw new Error(n.ERRORS.INVALID_SMARTBUFFER_BUFFER);this._buff=t.buff,this.length=t.buff.length}else this._buff=e.allocUnsafe(i);else{if(void 0!==t)throw new Error(n.ERRORS.INVALID_SMARTBUFFER_OBJECT);this._buff=e.allocUnsafe(i)}}static fromSize(e,t){return new this({size:e,encoding:t})}static fromBuffer(e,t){return new this({buff:e,encoding:t})}static fromOptions(e){return new this(e)}static isSmartBufferOptions(e){const t=e;return t&&(void 0!==t.encoding||void 0!==t.size||void 0!==t.buff)}readInt8(t){return this._readNumberValue(e.prototype.readInt8,1,t)}readInt16BE(t){return this._readNumberValue(e.prototype.readInt16BE,2,t)}readInt16LE(t){return this._readNumberValue(e.prototype.readInt16LE,2,t)}readInt32BE(t){return this._readNumberValue(e.prototype.readInt32BE,4,t)}readInt32LE(t){return this._readNumberValue(e.prototype.readInt32LE,4,t)}writeInt8(t,r){return this._writeNumberValue(e.prototype.writeInt8,1,t,r),this}insertInt8(t,r){return this._insertNumberValue(e.prototype.writeInt8,1,t,r),this}writeInt16BE(t,r){return this._writeNumberValue(e.prototype.writeInt16BE,2,t,r),this}insertInt16BE(t,r){return this._insertNumberValue(e.prototype.writeInt16BE,2,t,r),this}writeInt16LE(t,r){return this._writeNumberValue(e.prototype.writeInt16LE,2,t,r),this}insertInt16LE(t,r){return this._insertNumberValue(e.prototype.writeInt16LE,2,t,r),this}writeInt32BE(t,r){return this._writeNumberValue(e.prototype.writeInt32BE,4,t,r),this}insertInt32BE(t,r){return this._insertNumberValue(e.prototype.writeInt32BE,4,t,r),this}writeInt32LE(t,r){return this._writeNumberValue(e.prototype.writeInt32LE,4,t,r),this}insertInt32LE(t,r){return this._insertNumberValue(e.prototype.writeInt32LE,4,t,r),this}readUInt8(t){return this._readNumberValue(e.prototype.readUInt8,1,t)}readUInt16BE(t){return this._readNumberValue(e.prototype.readUInt16BE,2,t)}readUInt16LE(t){return this._readNumberValue(e.prototype.readUInt16LE,2,t)}readUInt32BE(t){return this._readNumberValue(e.prototype.readUInt32BE,4,t)}readUInt32LE(t){return this._readNumberValue(e.prototype.readUInt32LE,4,t)}writeUInt8(t,r){return this._writeNumberValue(e.prototype.writeUInt8,1,t,r),this}insertUInt8(t,r){return this._insertNumberValue(e.prototype.writeUInt8,1,t,r),this}writeUInt16BE(t,r){return this._writeNumberValue(e.prototype.writeUInt16BE,2,t,r),this}insertUInt16BE(t,r){return this._insertNumberValue(e.prototype.writeUInt16BE,2,t,r),this}writeUInt16LE(t,r){return this._writeNumberValue(e.prototype.writeUInt16LE,2,t,r),this}insertUInt16LE(t,r){return this._insertNumberValue(e.prototype.writeUInt16LE,2,t,r),this}writeUInt32BE(t,r){return this._writeNumberValue(e.prototype.writeUInt32BE,4,t,r),this}insertUInt32BE(t,r){return this._insertNumberValue(e.prototype.writeUInt32BE,4,t,r),this}writeUInt32LE(t,r){return this._writeNumberValue(e.prototype.writeUInt32LE,4,t,r),this}insertUInt32LE(t,r){return this._insertNumberValue(e.prototype.writeUInt32LE,4,t,r),this}readFloatBE(t){return this._readNumberValue(e.prototype.readFloatBE,4,t)}readFloatLE(t){return this._readNumberValue(e.prototype.readFloatLE,4,t)}writeFloatBE(t,r){return this._writeNumberValue(e.prototype.writeFloatBE,4,t,r),this}insertFloatBE(t,r){return this._insertNumberValue(e.prototype.writeFloatBE,4,t,r),this}writeFloatLE(t,r){return this._writeNumberValue(e.prototype.writeFloatLE,4,t,r),this}insertFloatLE(t,r){return this._insertNumberValue(e.prototype.writeFloatLE,4,t,r),this}readDoubleBE(t){return this._readNumberValue(e.prototype.readDoubleBE,8,t)}readDoubleLE(t){return this._readNumberValue(e.prototype.readDoubleLE,8,t)}writeDoubleBE(t,r){return this._writeNumberValue(e.prototype.writeDoubleBE,8,t,r),this}insertDoubleBE(t,r){return this._insertNumberValue(e.prototype.writeDoubleBE,8,t,r),this}writeDoubleLE(t,r){return this._writeNumberValue(e.prototype.writeDoubleLE,8,t,r),this}insertDoubleLE(t,r){return this._insertNumberValue(e.prototype.writeDoubleLE,8,t,r),this}readString(e,t){let r;"number"==typeof e?(n.checkLengthValue(e),r=Math.min(e,this.length-this._readOffset)):(t=e,r=this.length-this._readOffset),void 0!==t&&n.checkEncoding(t);const i=this._buff.slice(this._readOffset,this._readOffset+r).toString(t||this._encoding);return this._readOffset+=r,i}insertString(e,t,r){return n.checkOffsetValue(t),this._handleString(e,!0,t,r)}writeString(e,t,r){return this._handleString(e,!1,t,r)}readStringNT(e){void 0!==e&&n.checkEncoding(e);let t=this.length;for(let e=this._readOffset;ethis.length)throw new Error(n.ERRORS.INVALID_READ_BEYOND_BOUNDS)}ensureInsertable(e,t){n.checkOffsetValue(t),this._ensureCapacity(this.length+e),tthis.length?this.length=t+e:this.length+=e}_ensureWriteable(e,t){const r="number"==typeof t?t:this._writeOffset;this._ensureCapacity(r+e),r+e>this.length&&(this.length=r+e)}_ensureCapacity(t){const r=this._buff.length;if(t>r){let n=this._buff,i=3*r/2+1;i0&&"0"===r.toString();)r=(e=e.slice(1))[0];return e},t.toBuffer=function(e){if(!f.isBuffer(e))if(Array.isArray(e))e=f.from(e);else if("string"==typeof e)e=t.isHexString(e)?f.from(t.padToEven(t.stripHexPrefix(e)),"hex"):f.from(e);else if("number"==typeof e)e=t.intToBuffer(e);else if(null===e||void 0===e)e=f.allocUnsafe(0);else if(u.isBN(e))e=e.toArrayLike(f);else{if(!e.toArray)throw new Error("invalid type");e=f.from(e.toArray())}return e},t.bufferToInt=function(e){return new u(t.toBuffer(e)).toNumber()},t.bufferToHex=function(e){return"0x"+(e=t.toBuffer(e)).toString("hex")},t.fromSigned=function(e){return new u(e).fromTwos(256)},t.toUnsigned=function(e){return f.from(e.toTwos(256).toArray())},t.keccak=function(e,r){return e=t.toBuffer(e),r||(r=256),i("keccak"+r).update(e).digest()},t.keccak256=function(e){return t.keccak(e)},t.sha3=t.keccak,t.sha256=function(e){return e=t.toBuffer(e),c("sha256").update(e).digest()},t.ripemd160=function(e,r){e=t.toBuffer(e);var n=c("rmd160").update(e).digest();return!0===r?t.setLength(n,32):n},t.rlphash=function(e){return t.keccak(a.encode(e))},t.isValidPrivate=function(e){return o.privateKeyVerify(e)},t.isValidPublic=function(e,t){return 64===e.length?o.publicKeyVerify(f.concat([f.from([4]),e])):!!t&&o.publicKeyVerify(e)},t.pubToAddress=t.publicToAddress=function(e,r){return e=t.toBuffer(e),r&&64!==e.length&&(e=o.publicKeyConvert(e,!1).slice(1)),s(64===e.length),t.keccak(e).slice(-20)};var l=t.privateToPublic=function(e){return e=t.toBuffer(e),o.publicKeyCreate(e,!1).slice(1)};t.importPublic=function(e){return 64!==(e=t.toBuffer(e)).length&&(e=o.publicKeyConvert(e,!1).slice(1)),e},t.ecsign=function(e,t){var r=o.sign(e,t),n={};return n.r=r.signature.slice(0,32),n.s=r.signature.slice(32,64),n.v=r.recovery+27,n},t.hashPersonalMessage=function(e){var r=t.toBuffer("Ethereum Signed Message:\n"+e.length.toString());return t.keccak(f.concat([r,e]))},t.ecrecover=function(e,r,n,i){var s=f.concat([t.setLength(n,32),t.setLength(i,32)],64),a=r-27;if(0!==a&&1!==a)throw new Error("Invalid signature v value");var u=o.recover(e,s,a);return o.publicKeyConvert(u,!1).slice(1)},t.toRpcSig=function(e,r,n){if(27!==e&&28!==e)throw new Error("Invalid recovery id");return t.bufferToHex(f.concat([t.setLengthLeft(r,32),t.setLengthLeft(n,32),t.toBuffer(e-27)]))},t.fromRpcSig=function(e){if(65!==(e=t.toBuffer(e)).length)throw new Error("Invalid signature length");var r=e[64];return r<27&&(r+=27),{v:r,r:e.slice(0,32),s:e.slice(32,64)}},t.privateToAddress=function(e){return t.publicToAddress(l(e))},t.isValidAddress=function(e){return/^0x[0-9a-fA-F]{40}$/.test(e)},t.isZeroAddress=function(e){return t.zeroAddress()===t.addHexPrefix(e)},t.toChecksumAddress=function(e){e=t.stripHexPrefix(e).toLowerCase();for(var r=t.keccak(e).toString("hex"),n="0x",i=0;i=8?n+=e[i].toUpperCase():n+=e[i];return n},t.isValidChecksumAddress=function(e){return t.isValidAddress(e)&&t.toChecksumAddress(e)===e},t.generateAddress=function(e,r){return e=t.toBuffer(e),r=(r=new u(r)).isZero()?null:f.from(r.toArray()),t.rlphash([e,r]).slice(-20)},t.isPrecompiled=function(e){var r=t.unpad(e);return 1===r.length&&r[0]>=1&&r[0]<=8},t.addHexPrefix=function(e){return"string"!=typeof e?e:t.isHexPrefixed(e)?e:"0x"+e},t.isValidSignature=function(e,t,r,n){var i=new u("7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0",16),o=new u("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",16);return!(32!==t.length||32!==r.length||27!==e&&28!==e||(t=new u(t),r=new u(r),t.isZero()||t.gt(o)||r.isZero()||r.gt(o)||!1===n&&1===new u(r).cmp(i)))},t.baToJSON=function(e){if(f.isBuffer(e))return"0x"+e.toString("hex");if(e instanceof Array){for(var r=[],n=0;n=i.length,"The field "+r.name+" must not have more "+r.length+" bytes")):r.allowZero&&0===i.length||!r.length||s(r.length===i.length,"The field "+r.name+" must have byte length of "+r.length),e.raw[n]=i}e._fields.push(r.name),Object.defineProperty(e,r.name,{enumerable:!0,configurable:!0,get:i,set:o}),r.default&&(e[r.name]=r.default),r.alias&&Object.defineProperty(e,r.alias,{enumerable:!1,configurable:!0,set:o,get:i})}),i)if("string"==typeof i&&(i=f.from(t.stripHexPrefix(i),"hex")),f.isBuffer(i)&&(i=a.decode(i)),Array.isArray(i)){if(i.length>e._fields.length)throw new Error("wrong number of fields in data");i.forEach(function(r,n){e[e._fields[n]]=t.toBuffer(r)})}else{if("object"!==(void 0===i?"undefined":n(i)))throw new Error("invalid data");var o=Object.keys(i);r.forEach(function(t){-1!==o.indexOf(t.name)&&(e[t.name]=i[t.name]),-1!==o.indexOf(t.alias)&&(e[t.alias]=i[t.alias])})}}},function(e,t,r){"use strict";var n=t;n.base=r(825),n.short=r(826),n.mont=r(827),n.edwards=r(828)},function(e,t,r){"use strict";var n=t;n.base=r(874),n.short=r(875),n.mont=r(876),n.edwards=r(877)},function(e,t,r){"use strict";(function(t){var n=r(18),i=r(97),o=r(129),s=r(32),a=r(29),u=r(96),c=r(109),f=r(73),l=r(179),h=r(21);function p(e,t){if(!(this instanceof p))return new p(e,t);if(e instanceof p)return e;var r=this._classifyArguments(e,t);if(!r.bn||0===r.bn.cmp(new s(0)))throw new TypeError("Number can not be equal to zero, undefined, null or false");if(!r.bn.lt(c.getN()))throw new TypeError("Number must be less than N");if(void 0===r.network)throw new TypeError('Must specify the network ("livenet" or "testnet")');return a.defineImmutable(this,{bn:r.bn,compressed:r.compressed,network:r.network}),Object.defineProperty(this,"publicKey",{configurable:!1,enumerable:!0,get:this.toPublicKey.bind(this)}),this}p.prototype._classifyArguments=function(e,r){var i={compressed:!0,network:r?u.get(r):u.defaultNetwork};if(n.isUndefined(e)||n.isNull(e))i.bn=p._getRandomBN();else if(e instanceof s)i.bn=e;else if(e instanceof t||e instanceof Uint8Array)i=p._transformBuffer(e,r);else if(e.bn&&e.network)i=p._transformObject(e);else if(!r&&u.get(e))i.bn=p._getRandomBN(),i.network=u.get(e);else{if("string"!=typeof e)throw new TypeError("First argument is an unrecognized data type.");a.isHexa(e)?i.bn=new s(new t(e,"hex")):i=p._transformWIF(e,r)}return i},p._getRandomBN=function(){var e,t;do{var r=l.getRandomBuffer(32);e=(t=s.fromBuffer(r)).lt(c.getN())}while(!e);return t},p._transformBuffer=function(e,t){var r={};if(32===e.length)return p._transformBNBuffer(e,t);if(r.network=u.get(e[0],"privatekey"),!r.network)throw new Error("Invalid network");if(t&&r.network!==u.get(t))throw new TypeError("Private key network mismatch");if(34===e.length&&1===e[33])r.compressed=!0;else{if(33!==e.length)throw new Error("Length of buffer must be 33 (uncompressed) or 34 (compressed)");r.compressed=!1}return r.bn=s.fromBuffer(e.slice(1,33)),r},p._transformBNBuffer=function(e,t){var r={};return r.network=u.get(t)||u.defaultNetwork,r.bn=s.fromBuffer(e),r.compressed=!1,r},p._transformWIF=function(e,t){return p._transformBuffer(o.decode(e),t)},p.fromBuffer=function(e,t){return new p(e,t)},p._transformObject=function(e){return{bn:new s(e.bn,"hex"),network:u.get(e.network),compressed:e.compressed}},p.fromString=p.fromWIF=function(e){return h.checkArgument(n.isString(e),"First argument is expected to be a string."),new p(e)},p.fromObject=function(e){return h.checkArgument(n.isObject(e),"First argument is expected to be an object."),new p(e)},p.fromRandom=function(e){return new p(p._getRandomBN(),e)},p.getValidationError=function(e,t){var r;try{new p(e,t)}catch(e){r=e}return r},p.isValid=function(e,t){return!!e&&!p.getValidationError(e,t)},p.prototype.toString=function(){return this.toBuffer().toString("hex")},p.prototype.toWIF=function(){var e,r=this.network;return e=this.compressed?t.concat([new t([r.privatekey]),this.bn.toBuffer({size:32}),new t([1])]):t.concat([new t([r.privatekey]),this.bn.toBuffer({size:32})]),o.encode(e)},p.prototype.toBigNumber=function(){return this.bn},p.prototype.toBuffer=function(){return this.bn.toBuffer()},p.prototype.toPublicKey=function(){return this._pubkey||(this._pubkey=f.fromPrivateKey(this)),this._pubkey},p.prototype.toAddress=function(e){var t=this.toPublicKey();return i.fromPublicKey(t,e||this.network)},p.prototype.toObject=p.prototype.toJSON=function(){return{bn:this.bn.toString("hex"),compressed:this.compressed,network:this.network.toString()}},p.prototype.inspect=function(){var e=this.compressed?"":", uncompressed";return""},e.exports=p}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){var n=r(18),i=r(429),o=r(0),s="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".split(""),a=function e(r){if(!(this instanceof e))return new e(r);if(t.isBuffer(r)){var n=r;this.fromBuffer(n)}else if("string"==typeof r){var i=r;this.fromString(i)}else r&&this.set(r)};a.validCharacters=function(e){return o.Buffer.isBuffer(e)&&(e=e.toString()),n.all(n.map(e,function(e){return n.contains(s,e)}))},a.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this},a.encode=function(e){if(!o.Buffer.isBuffer(e))throw new Error("Input should be a buffer");return i.encode(e)},a.decode=function(e){if("string"!=typeof e)throw new Error("Input should be a string");return new t(i.decode(e))},a.prototype.fromBuffer=function(e){return this.buf=e,this},a.prototype.fromString=function(e){var t=a.decode(e);return this.buf=t,this},a.prototype.toBuffer=function(){return this.buf},a.prototype.toString=function(){return a.encode(this.buf)},e.exports=a}).call(this,r(0).Buffer)},function(e,t,r){e.exports=r(251),e.exports.Input=r(252),e.exports.Output=r(84),e.exports.UnspentOutput=r(431),e.exports.Signature=r(131),e.exports.Sighash=r(83)},function(e,t,r){"use strict";(function(t,n){function i(){}i.getRandomBuffer=function(e){return t.browser?i.getRandomBufferBrowser(e):i.getRandomBufferNode(e)},i.getRandomBufferNode=function(e){return r(95).randomBytes(e)},i.getRandomBufferBrowser=function(e){if(!window.crypto&&!window.msCrypto)throw new Error("window.crypto not available");if(window.crypto&&window.crypto.getRandomValues)var t=window.crypto;else{if(!window.msCrypto||!window.msCrypto.getRandomValues)throw new Error("window.crypto.getRandomValues not available");t=window.msCrypto}var r=new Uint8Array(e);return t.getRandomValues(r),new n(r)},i.getPseudoRandomBuffer=function(e){for(var t,r=new n(e),i=0;i<=e;i++){0==i-4*Math.floor(i/4)?(t=4294967296*Math.random(),r[i]=255&t):r[i]=255&(t>>>=8)}return r},e.exports=i}).call(this,r(6),r(0).Buffer)},function(e,t,r){"use strict";(function(t){var n=r(18),i=r(32),o=r(24),s=r(82),a=r(57),u=r(38),c=(r(29),r(21)),f=function e(t){if(!(this instanceof e))return new e(t);var r=e._from(t);return this.version=r.version,this.prevHash=r.prevHash,this.merkleRoot=r.merkleRoot,this.reserved=r.reserved,this.time=r.time,this.timestamp=r.time,this.bits=r.bits,this.nonce=r.nonce,this.solution=r.solution,r.hash&&c.checkState(this.hash===r.hash,"Argument object hash property does not match block hash."),this};f._from=function(e){var t={};if(o.isBuffer(e))t=f._fromBufferReader(s(e));else{if(!n.isObject(e))throw new TypeError("Unrecognized argument for BlockHeader");t=f._fromObject(e)}return t},f._fromObject=function(e){c.checkArgument(e,"data is required");var r=e.prevHash,i=e.merkleRoot,s=e.reserved,a=e.nonce,u=e.solution;return n.isString(e.prevHash)&&(r=o.reverse(new t(e.prevHash,"hex"))),n.isString(e.merkleRoot)&&(i=o.reverse(new t(e.merkleRoot,"hex"))),n.isString(e.reserved)&&(s=o.reverse(new t(e.reserved,"hex"))),n.isString(e.nonce)&&(a=o.reverse(new t(e.nonce,"hex"))),n.isString(e.solution)&&(u=new t(e.solution,"hex")),{hash:e.hash,version:e.version,prevHash:r,merkleRoot:i,reserved:s,time:e.time,timestamp:e.time,bits:e.bits,nonce:a,solution:u}},f.fromObject=function(e){var t=f._fromObject(e);return new f(t)},f.fromRawBlock=function(e){o.isBuffer(e)||(e=new t(e,"binary"));var r=s(e);r.pos=f.Constants.START_OF_HEADER;var n=f._fromBufferReader(r);return new f(n)},f.fromBuffer=function(e){var t=f._fromBufferReader(s(e));return new f(t)},f.fromString=function(e){var r=new t(e,"hex");return f.fromBuffer(r)},f._fromBufferReader=function(e){var t={};t.version=e.readUInt32LE(),t.prevHash=e.read(32),t.merkleRoot=e.read(32),t.reserved=e.read(32),t.time=e.readUInt32LE(),t.bits=e.readUInt32LE(),t.nonce=e.read(32);var r=e.readVarintNum();return t.solution=e.read(r),t},f.fromBufferReader=function(e){var t=f._fromBufferReader(e);return new f(t)},f.prototype.toObject=f.prototype.toJSON=function(){return{hash:this.hash,version:this.version,prevHash:o.reverse(this.prevHash).toString("hex"),merkleRoot:o.reverse(this.merkleRoot).toString("hex"),reserved:o.reverse(this.reserved).toString("hex"),time:this.time,bits:this.bits,nonce:o.reverse(this.nonce).toString("hex"),solution:this.solution.toString("hex")}},f.prototype.toBuffer=function(){return this.toBufferWriter().concat()},f.prototype.toString=function(){return this.toBuffer().toString("hex")},f.prototype.toBufferWriter=function(e){return e||(e=new a),e.writeUInt32LE(this.version),e.write(this.prevHash),e.write(this.merkleRoot),e.write(this.reserved),e.writeUInt32LE(this.time),e.writeUInt32LE(this.bits),e.write(this.nonce),e.writeVarintNum(this.solution.length),e.write(this.solution),e},f.prototype.getTargetDifficulty=function(e){e=e||this.bits;for(var t=new i(16777215&e),r=8*((e>>>24)-3);r-- >0;)t=t.mul(new i(2));return t},f.prototype.getDifficulty=function(){var e=this.getTargetDifficulty(537133055).mul(new i(Math.pow(10,8))),t=this.getTargetDifficulty(),r=e.div(t).toString(10),n=r.length-8;return r=r.slice(0,n)+"."+r.slice(n),parseFloat(r)},f.prototype._getHash=function(){var e=this.toBuffer();return u.sha256sha256(e)};var l={configurable:!1,enumerable:!0,get:function(){return this._id||(this._id=s(this._getHash()).readReverse().toString("hex")),this._id},set:n.noop};Object.defineProperty(f.prototype,"id",l),Object.defineProperty(f.prototype,"hash",l),f.prototype.validTimestamp=function(){var e=Math.round((new Date).getTime()/1e3);return!(this.time>e+f.Constants.MAX_TIME_OFFSET)},f.prototype.validProofOfWork=function(){var e=new i(this.id,"hex"),t=this.getTargetDifficulty();return!(e.cmp(t)>0)},f.prototype.inspect=function(){return""},f.Constants={START_OF_HEADER:8,MAX_TIME_OFFSET:7200,LARGEST_HASH:new i("10000000000000000000000000000000000000000000000000000000000000000","hex")},e.exports=f}).call(this,r(0).Buffer)},function(e,t,r){var n=r(2).Buffer;function i(e){n.isBuffer(e)||(e=n.from(e));for(var t=e.length/4|0,r=new Array(t),i=0;i>>24]^f[d>>>16&255]^l[y>>>8&255]^h[255&g]^t[m++],s=c[d>>>24]^f[y>>>16&255]^l[g>>>8&255]^h[255&p]^t[m++],a=c[y>>>24]^f[g>>>16&255]^l[p>>>8&255]^h[255&d]^t[m++],u=c[g>>>24]^f[p>>>16&255]^l[d>>>8&255]^h[255&y]^t[m++],p=o,d=s,y=a,g=u;return o=(n[p>>>24]<<24|n[d>>>16&255]<<16|n[y>>>8&255]<<8|n[255&g])^t[m++],s=(n[d>>>24]<<24|n[y>>>16&255]<<16|n[g>>>8&255]<<8|n[255&p])^t[m++],a=(n[y>>>24]<<24|n[g>>>16&255]<<16|n[p>>>8&255]<<8|n[255&d])^t[m++],u=(n[g>>>24]<<24|n[p>>>16&255]<<16|n[d>>>8&255]<<8|n[255&y])^t[m++],[o>>>=0,s>>>=0,a>>>=0,u>>>=0]}var a=[0,1,2,4,8,16,32,64,128,27,54],u=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,u=0;u<256;++u){var c=a^a<<1^a<<2^a<<3^a<<4;c=c>>>8^255&c^99,r[s]=c,n[c]=s;var f=e[s],l=e[f],h=e[l],p=257*e[c]^16843008*c;i[0][s]=p<<24|p>>>8,i[1][s]=p<<16|p>>>16,i[2][s]=p<<8|p>>>24,i[3][s]=p,p=16843009*h^65537*l^257*f^16843008*s,o[0][c]=p<<24|p>>>8,o[1][c]=p<<16|p>>>16,o[2][c]=p<<8|p>>>24,o[3][c]=p,0===s?s=a=1:(s=f^e[e[e[h^f]]],a^=e[e[a]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function c(e){this._key=i(e),this._reset()}c.blockSize=16,c.keySize=32,c.prototype.blockSize=c.blockSize,c.prototype.keySize=c.keySize,c.prototype._reset=function(){for(var e=this._key,t=e.length,r=t+6,n=4*(r+1),i=[],o=0;o>>24,s=u.SBOX[s>>>24]<<24|u.SBOX[s>>>16&255]<<16|u.SBOX[s>>>8&255]<<8|u.SBOX[255&s],s^=a[o/t|0]<<24):t>6&&o%t==4&&(s=u.SBOX[s>>>24]<<24|u.SBOX[s>>>16&255]<<16|u.SBOX[s>>>8&255]<<8|u.SBOX[255&s]),i[o]=i[o-t]^s}for(var c=[],f=0;f>>24]]^u.INV_SUB_MIX[1][u.SBOX[h>>>16&255]]^u.INV_SUB_MIX[2][u.SBOX[h>>>8&255]]^u.INV_SUB_MIX[3][u.SBOX[255&h]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=c},c.prototype.encryptBlockRaw=function(e){return s(e=i(e),this._keySchedule,u.SUB_MIX,u.SBOX,this._nRounds)},c.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},c.prototype.decryptBlock=function(e){var t=(e=i(e))[1];e[1]=e[3],e[3]=t;var r=s(e,this._invKeySchedule,u.INV_SUB_MIX,u.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},c.prototype.scrub=function(){o(this._keySchedule),o(this._invKeySchedule),o(this._key)},e.exports.AES=c},function(e,t,r){var n=r(13);function i(e,t){n.cipher.registerAlgorithm(e,function(){return new n.des.Algorithm(e,t)})}r(258),r(443),r(19),e.exports=n.des=n.des||{},n.des.startEncrypting=function(e,t,r,n){var i=d({key:e,output:r,decrypt:!1,mode:n||(null===t?"ECB":"CBC")});return i.start(t),i},n.des.createEncryptionCipher=function(e,t){return d({key:e,output:null,decrypt:!1,mode:t})},n.des.startDecrypting=function(e,t,r,n){var i=d({key:e,output:r,decrypt:!0,mode:n||(null===t?"ECB":"CBC")});return i.start(t),i},n.des.createDecryptionCipher=function(e,t){return d({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 p(r._keys,e,t,!1)},decrypt:function(e,t){return p(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],u=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],c=[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],l=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],h=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],p=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],d=[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],g=e.length()>8?3:1,m=[],b=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],v=0,_=0;_>>4^S))<<4,w^=t=65535&((S^=t)>>>-16^w),w^=(t=858993459&(w>>>2^(S^=t<<-16)))<<2,w^=t=65535&((S^=t)>>>-16^w),w^=(t=1431655765&(w>>>1^(S^=t<<-16)))<<1,w^=t=16711935&((S^=t)>>>8^w),t=(w^=(t=1431655765&(w>>>1^(S^=t<<8)))<<1)<<8|(S^=t)>>>20&240,w=S<<24|S<<8&16711680|S>>>8&65280|S>>>24&240,S=t;for(var k=0;k>>26,S=S<<2|S>>>26):(w=w<<1|w>>>27,S=S<<1|S>>>27);var E=r[(w&=-15)>>>28]|n[w>>>24&15]|i[w>>>20&15]|o[w>>>16&15]|s[w>>>12&15]|a[w>>>8&15]|u[w>>>4&15],A=c[(S&=-15)>>>28]|f[S>>>24&15]|l[S>>>20&15]|h[S>>>16&15]|p[S>>>12&15]|d[S>>>8&15]|y[S>>>4&15];t=65535&(A>>>16^E),m[v++]=E^t,m[v++]=A^t<<16}}return m}(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],u=[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],c=[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],l=[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],h=[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 p(e,t,r,n){var i,p,d=32===e.length?3:9;i=3===d?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],g=t[1];y^=(p=252645135&(y>>>4^g))<<4,y^=(p=65535&(y>>>16^(g^=p)))<<16,y^=p=858993459&((g^=p)>>>2^y),y^=p=16711935&((g^=p<<2)>>>8^y),y=(y^=(p=1431655765&(y>>>1^(g^=p<<8)))<<1)<<1|y>>>31,g=(g^=p)<<1|g>>>31;for(var m=0;m>>4|g<<28)^e[_+1];p=y,y=g,g=p^(s[w>>>24&63]|u[w>>>16&63]|f[w>>>8&63]|h[63&w]|o[S>>>24&63]|a[S>>>16&63]|c[S>>>8&63]|l[63&S])}p=y,y=g,g=p}g=g>>>1|g<<31,g^=p=1431655765&((y=y>>>1|y<<31)>>>1^g),g^=(p=16711935&(g>>>8^(y^=p<<1)))<<8,g^=(p=858993459&(g>>>2^(y^=p)))<<2,g^=p=65535&((y^=p)>>>16^g),g^=p=252645135&((y^=p<<16)>>>4^g),y^=p<<4,r[0]=y,r[1]=g}function d(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(13);if(r(76),r(184),r(100),r(451),r(452),r(67),r(19),void 0===i)var i=n.jsbn.BigInteger;var o=n.asn1;n.pki=n.pki||{},e.exports=n.pki.rsa=n.rsa=n.rsa||{};var s=n.pki,a=[6,4,2,4,2,4,6,2],u={name:"PrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",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:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},c={name:"RSAPrivateKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},f={name:"RSAPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},l=n.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",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:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},h=function(e){var t;if(!(e.algorithm in s.oids)){var r=new Error("Unknown message digest algorithm.");throw r.algorithm=e.algorithm,r}t=s.oids[e.algorithm];var n=o.oidToDer(t).getBytes(),i=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[]),a=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[]);a.value.push(o.create(o.Class.UNIVERSAL,o.Type.OID,!1,n)),a.value.push(o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,""));var u=o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,e.digest().getBytes());return i.value.push(a),i.value.push(u),o.toDer(i).getBytes()},p=function(e,t,r){if(r)return e.modPow(t.e,t.n);if(!t.p||!t.q)return e.modPow(t.d,t.n);var o;t.dP||(t.dP=t.d.mod(t.p.subtract(i.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(i.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));do{o=new i(n.util.bytesToHex(n.random.getBytes(t.n.bitLength()/8)),16)}while(o.compareTo(t.n)>=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 u=s.subtract(a).multiply(t.qInv).mod(t.p).multiply(t.q).add(a);return u.multiply(o.modInverse(t.n)).mod(t.n)};function d(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,u=o-3-e.length;if(0===r||1===r){a=0===r?0:255;for(var c=0;c0;){var f=0,l=n.random.getBytes(u);for(c=0;c1;){if(255!==s.getByte()){--s.read;break}++c}else if(2===u)for(c=0;s.length()>1;){if(0===s.getByte()){--s.read;break}++c}if(0!==s.getByte()||c!==o-3-s.length())throw new Error("Encryption block is invalid.");return s.getBytes()}function g(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 a(){u(e.pBits,function(t,n){return t?r(t):(e.p=n,null!==e.q?c(t,e.q):void u(e.qBits,c))})}function u(e,t){n.prime.generateProbablePrime(e,o,t)}function c(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 a();if(0!==e.q.subtract(i.ONE).gcd(e.e).compareTo(i.ONE))return e.q=null,void u(e.qBits,c);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 a();if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits)return e.q=null,void u(e.qBits,c);var f=e.e.modInverse(e.phi);e.keys={privateKey:s.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:s.rsa.setPublicKey(e.n,e.e)},r(null,e.keys)}"prng"in t&&(o.prng=t.prng),a()}function m(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 b(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 v(e){return"undefined"!=typeof window&&"object"==typeof window.crypto&&"object"==typeof window.crypto.subtle&&"function"==typeof window.crypto.subtle[e]}function _(e){return"undefined"!=typeof window&&"object"==typeof window.msCrypto&&"object"==typeof window.msCrypto.subtle&&"function"==typeof window.msCrypto.subtle[e]}function w(e){for(var t=n.util.hexToBytes(e.toString(16)),r=new Uint8Array(t.length),i=0;i0;)f.putByte(0),--l;return f.putBytes(n.util.hexToBytes(c)),f.getBytes()},s.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 u=new i(n.util.createBuffer(e).toHex(),16);if(u.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var c=p(u,t,r).toString(16),f=n.util.createBuffer(),l=s-Math.ceil(c.length/2);l>0;)f.putByte(0),--l;return f.putBytes(n.util.hexToBytes(c)),!1!==o?y(f.getBytes(),t,r):f.getBytes()},s.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},s.rsa.stepKeyPairGenerationState=function(e,t){"algorithm"in e||(e.algorithm="PRIMEINC");var r=new i(null);r.fromInt(30);for(var n,o=0,u=function(e,t){return e|t},c=+new Date,f=0;null===e.keys&&(t<=0||fl?e.pqState=0:e.num.isProbablePrime(b(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(a[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 p=e.e.modInverse(e.phi);e.keys={privateKey:s.rsa.setPrivateKey(e.n,e.e,p,e.p,e.q,p.mod(e.p1),p.mod(e.q1),e.q.modInverse(e.p)),publicKey:s.rsa.setPublicKey(e.n,e.e)}}f+=(n=+new Date)-c,c=n}return null!==e.keys},s.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&&i&&e>=256&&e<=16384&&(65537===t||3===t)){if(v("generateKey")&&v("exportKey"))return window.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:w(t),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(e){return window.crypto.subtle.exportKey("pkcs8",e.privateKey)}).then(void 0,function(e){i(e)}).then(function(e){if(e){var t=s.privateKeyFromAsn1(o.fromDer(n.util.createBuffer(e)));i(null,{privateKey:t,publicKey:s.setRsaPublicKey(t.n,t.e)})}});if(_("generateKey")&&_("exportKey")){var a=window.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:w(t),hash:{name:"SHA-256"}},!0,["sign","verify"]);return a.oncomplete=function(e){var t=e.target.result,r=window.msCrypto.subtle.exportKey("pkcs8",t.privateKey);r.oncomplete=function(e){var t=e.target.result,r=s.privateKeyFromAsn1(o.fromDer(n.util.createBuffer(t)));i(null,{privateKey:r,publicKey:s.setRsaPublicKey(r.n,r.e)})},r.onerror=function(e){i(e)}},void(a.onerror=function(e){i(e)})}}var u=s.rsa.createKeyPairGenerationState(e,t,r);if(!i)return s.rsa.stepKeyPairGenerationState(u,0),u.keys;g(u,r,i)},s.setRsaPublicKey=s.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 d(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 s.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=y(t,r,!0),e===o.fromDer(t).value[1].value}}:"NONE"!==n&&"NULL"!==n&&null!==n||(n={verify:function(e,t){return e===y(t,r,!0)}});var i=s.rsa.decrypt(t,r,!0,!1);return n.verify(e,i,r.n.bitLength())}};return r},s.setRsaPrivateKey=s.rsa.setPrivateKey=function(e,t,r,i,o,a,u,c){var f={n:e,e:t,d:r,p:i,q:o,dP:a,dQ:u,qInv:c,decrypt:function(e,t,r){"string"==typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5");var i=s.rsa.decrypt(e,f,!1,!1);if("RSAES-PKCS1-V1_5"===t)t={decode:y};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:h},r=1):"NONE"!==t&&"NULL"!==t&&null!==t||(t={encode:function(){return e}},r=1);var n=t.encode(e,f.n.bitLength());return s.rsa.encrypt(n,f,r)}};return f},s.wrapRsaPrivateKey=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,o.integerToDer(0).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(s.oids.rsaEncryption).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")]),o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,o.toDer(e).getBytes())])},s.privateKeyFromAsn1=function(e){var t,r,a,f,l,h,p,d,y={},g=[];if(o.validate(e,u,y,g)&&(e=o.fromDer(n.util.createBuffer(y.privateKey))),y={},g=[],!o.validate(e,c,y,g)){var m=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw m.errors=g,m}return t=n.util.createBuffer(y.privateKeyModulus).toHex(),r=n.util.createBuffer(y.privateKeyPublicExponent).toHex(),a=n.util.createBuffer(y.privateKeyPrivateExponent).toHex(),f=n.util.createBuffer(y.privateKeyPrime1).toHex(),l=n.util.createBuffer(y.privateKeyPrime2).toHex(),h=n.util.createBuffer(y.privateKeyExponent1).toHex(),p=n.util.createBuffer(y.privateKeyExponent2).toHex(),d=n.util.createBuffer(y.privateKeyCoefficient).toHex(),s.setRsaPrivateKey(new i(t,16),new i(r,16),new i(a,16),new i(f,16),new i(l,16),new i(h,16),new i(p,16),new i(d,16))},s.privateKeyToAsn1=s.privateKeyToRSAPrivateKey=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,o.integerToDer(0).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,m(e.n)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,m(e.e)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,m(e.d)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,m(e.p)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,m(e.q)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,m(e.dP)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,m(e.dQ)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,m(e.qInv))])},s.publicKeyFromAsn1=function(e){var t={},r=[];if(o.validate(e,l,t,r)){var a,u=o.derToOid(t.publicKeyOid);if(u!==s.oids.rsaEncryption)throw(a=new Error("Cannot read public key. Unknown OID.")).oid=u,a;e=t.rsaPublicKey}if(r=[],!o.validate(e,f,t,r))throw(a=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=r,a;var c=n.util.createBuffer(t.publicKeyModulus).toHex(),h=n.util.createBuffer(t.publicKeyExponent).toHex();return s.setRsaPublicKey(new i(c,16),new i(h,16))},s.publicKeyToAsn1=s.publicKeyToSubjectPublicKeyInfo=function(e){return 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(s.oids.rsaEncryption).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")]),o.create(o.Class.UNIVERSAL,o.Type.BITSTRING,!1,[s.publicKeyToRSAPublicKey(e)])])},s.publicKeyToRSAPublicKey=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,m(e.n)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,m(e.e))])}},function(e,t,r){var n,i=r(13);e.exports=i.jsbn=i.jsbn||{};function o(e,t,r){this.data=[],null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}function s(){return new o(null)}function a(e,t,r,n,i,o){for(var s=16383&t,a=t>>14;--o>=0;){var u=16383&this.data[e],c=this.data[e++]>>14,f=a*u+c*s;i=((u=s*u+((16383&f)<<14)+r.data[n]+i)>>28)+(f>>14)+a*c,r.data[n++]=268435455&u}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 u=32767&this.data[e],c=this.data[e++]>>15,f=a*u+c*s;i=((u=s*u+((32767&f)<<15)+r.data[n]+(1073741823&i))>>>30)+(f>>>15)+a*c+(i>>>30),r.data[n++]=1073741823&u}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 g(e){this.m=e}function m(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 k(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function E(){}function A(e){return e}function x(e){this.r2=s(),this.q3=s(),o.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}g.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},g.prototype.revert=function(e){return e},g.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},g.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},g.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},m.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},m.prototype.revert=function(e){var t=s();return e.copyTo(t),this.reduce(t),t},m.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)},m.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},m.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]:p(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 l=a.t,h=a.data[l-1];if(0!=h){var p=h*(1<1?a.data[l-2]>>this.F2:0),d=this.FV/p,g=(1<=0&&(r.data[r.t++]=1,r.subTo(_,r)),o.ONE.dlShiftTo(l,_),_.subTo(a,a);a.t=0;){var w=r.data[--b]==h?this.DM:Math.floor(r.data[b]*d+(r.data[b-1]+m)*g);if((r.data[b]+=a.am(0,w,r,v,0,l))0&&r.rShiftTo(f,r),u<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=y(e)-1;for(i.copyTo(r);--a>=0;)if(t.sqrTo(r,n),(e&1<0)t.mulTo(n,i,r);else{var u=r;r=n,n=u}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)+y(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 g(t):new m(t),this.exp(e,r)},o.ZERO=d(0),o.ONE=d(1),E.prototype.convert=A,E.prototype.revert=A,E.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},E.prototype.sqrTo=function(e,t){e.squareTo(t)},x.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},x.prototype.revert=function(e){return e},x.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)},x.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},x.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var I=[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],T=(1<<26)/I[I.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,u=0;u=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),v,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 u=n.modPow(i,this);if(0!=u.compareTo(o.ONE)&&0!=u.compareTo(t)){for(var c=1;c++>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,b,t),t},o.prototype.or=function(e){var t=s();return this.bitwiseTo(e,v,t),t},o.prototype.xor=function(e){var t=s();return this.bitwiseTo(e,_,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 l=s();for(n.sqrTo(a[1],l);u<=f;)a[u]=s(),n.mulTo(l,a[u-2],a[u]),u+=2}var h,p,b=e.t-1,v=!0,_=s();for(i=y(e.data[b])-1;b>=0;){for(i>=c?h=e.data[b]>>i-c&f:(h=(e.data[b]&(1<0&&(h|=e.data[b-1]>>this.DB+i-c)),u=r;0==(1&h);)h>>=1,--u;if((i-=u)<0&&(i+=this.DB,--b),v)a[h].copyTo(o),v=!1;else{for(;u>1;)n.sqrTo(o,_),n.sqrTo(_,o),u-=2;u>0?n.sqrTo(o,_):(p=o,o=_,_=p),n.mulTo(_,a[h],o)}for(;b>=0&&0==(e.data[b]&1<=0?(r.subTo(n,r),t&&i.subTo(a,i),s.subTo(u,s)):(n.subTo(r,n),t&&a.subTo(i,a),u.subTo(s,u))}return 0!=n.compareTo(o.ONE)?o.ZERO:u.compareTo(e)>=0?u.subtract(e):u.signum()<0?(u.addTo(e,u),u.signum()<0?u.add(e):u):u},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]<=I[I.length-1]){for(t=0;t>>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,u=67108863&i,c=Math.max(0,o-e.length+1),f=Math.min(o,t.length-1);c<=f;c++){var l=o-c,h=e.words[l]*t.words[c]+u;a+=h/67108864|0,u=67108863&h}r.words[o]=u,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,u=1;0==(e.words[0]&u)&&0==(t.words[0]&u)&&a<26;++a,u<<=1);e.ishrn(a),t.ishrn(a)}for(var c=t.clone(),f=e.clone();!e.isZero();){for(var l=0,h=1;0==(e.words[0]&h)&&l<26;++l,h<<=1);if(l>0)for(e.ishrn(l);l-- >0;)(r.isOdd()||n.isOdd())&&(r.iadd(c),n.isub(f)),r.ishrn(1),n.ishrn(1);for(var p=0,d=1;0==(t.words[0]&d)&&p<26;++p,d<<=1);if(p>0)for(t.ishrn(p);p-- >0;)(i.isOdd()||s.isOdd())&&(i.iadd(c),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 u=0,c=1;0==(r.words[0]&c)&&u<26;++u,c<<=1);if(u>0)for(r.ishrn(u);u-- >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 u=o.words[0]&n;if(u>=i)t.push(i-u),o.iuaddn(u-i).ishrn(1);else if(t.push(u),o.words[0]-=u,!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";const n=r(11),i=r(151),o=r(1034),s=r(16),a=r(50),u=r(9),c=r(342),f=r(1035),l=r(61),h=n(r(1036)),p=r(1037);class d{constructor(e){this.full=e,this.wantlist=new Map,this.blocks=new Map}get empty(){return 0===this.blocks.size&&0===this.wantlist.size}addEntry(e,t,r){s(e&&u.isCID(e),"must be a valid cid");const n=e.buffer.toString(),i=this.wantlist.get(n);i?(i.priority=t,i.cancel=Boolean(r)):this.wantlist.set(n,new p(e,t,r))}addBlock(e){s(i.isBlock(e),"must be a valid cid");const t=e.cid.buffer.toString();this.blocks.set(t,e)}cancel(e){s(u.isCID(e),"must be a valid cid");const t=e.buffer.toString();this.wantlist.delete(t),this.addEntry(e,0,!0)}serializeToBitswap100(){const e={wantlist:{entries:Array.from(this.wantlist.values()).map(e=>({block:e.cid.buffer,priority:Number(e.priority),cancel:Boolean(e.cancel)}))},blocks:Array.from(this.blocks.values()).map(e=>e.data)};return this.full&&(e.wantlist.full=!0),h.Message.encode(e)}serializeToBitswap110(){const e={wantlist:{entries:Array.from(this.wantlist.values()).map(e=>({block:e.cid.buffer,priority:Number(e.priority),cancel:Boolean(e.cancel)}))},payload:[]};return this.full&&(e.wantlist.full=!0),this.blocks.forEach(t=>{e.payload.push({prefix:t.cid.prefix,data:t.data})}),h.Message.encode(e)}equals(e){const t=(e,t)=>{if(e.equals&&"function"==typeof e.equals)return e.equals(t)};return!(this.full!==e.full||!o(this.wantlist,e.wantlist,t)||!o(this.blocks,e.blocks,t))}get[Symbol.toStringTag](){const e=Array.from(this.wantlist.keys()),t=Array.from(this.blocks.keys());return`BitswapMessage `}}d.deserialize=((e,t)=>{let r;try{r=h.Message.decode(e)}catch(e){return setImmediate(()=>t(e))}const n=r.wantlist&&r.wantlist.full||!1,o=new d(n);return r.wantlist&&r.wantlist.entries.forEach(e=>{let r;try{r=new u(e.block)}catch(e){return t(e)}o.addEntry(r,e.priority,e.cancel)}),r.blocks.length>0?a(r.blocks,(e,r)=>{l(e,"sha2-256",(n,s)=>{if(n)return r(n);let a;try{a=new u(s)}catch(n){return t(n)}o.addBlock(new i(e,a)),r()})},e=>{if(e)return t(e);t(null,o)}):r.payload.length>0?a(r.payload,(e,r)=>{e.prefix&&e.data||r();const n=f(e.prefix),s=n[0],a=n[1],h=n[2];l(e.data,h,(n,f)=>{if(n)return r(n);let l;try{l=new u(s,c[a.toString("16")],f)}catch(n){return t(n)}o.addBlock(new i(e.data,l)),r()})},e=>{if(e)return t(e);t(null,o)}):void t(null,o)}),d.Entry=p,e.exports=d},function(e,t,r){"use strict";const n=r(1038),i=r(1039);class o{constructor(e){this.set=new Map,this._stats=e}get length(){return this.set.size}add(e,t){const r=e.buffer.toString(),n=this.set.get(r);n?(n.inc(),n.priority=t):(this.set.set(r,new i(e,t)),this._stats&&this._stats.push(null,"wantListSize",1))}remove(e){const t=e.buffer.toString(),r=this.set.get(t);r&&(r.dec(),r.hasRefs()||(this.set.delete(t),this._stats&&this._stats.push(null,"wantListSize",-1)))}removeForce(e){this.set.has(e)&&this.set.delete(e)}forEach(e){return this.set.forEach(e)}entries(){return this.set.entries()}sortedEntries(){return new Map(n(Array.from(this.set.entries()),e=>e[1].key))}contains(e){const t=e.buffer.toString();return this.set.get(t)}}o.Entry=i,e.exports=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=o(r(1046)),i=o(r(218));function o(e){return e&&e.__esModule?e:{default:e}}t.default=(0,i.default)(n.default,1),e.exports=t.default},function(e,t){t.encode=function(e){var t="";for(var r in e)e.hasOwnProperty(r)&&(t.length&&(t+="&"),t+=encodeURIComponent(r)+"="+encodeURIComponent(e[r]));return t},t.decode=function(e){for(var t={},r=e.split("&"),n=0,i=r.length;n65536?(this._debug("start backpressure: bufferedAmount %d",this._channel.bufferedAmount),this._cb=r):r(null)}else this._debug("write before connect"),this._chunk=e,this._cb=r},u.prototype._onFinish=function(){var e=this;function t(){setTimeout(function(){e.destroy()},1e3)}e.destroyed||(e.connected?t():e.once("connect",t))},u.prototype._createOffer=function(){var e=this;e.destroyed||e._pc.createOffer(function(t){function r(){var r=e._pc.localDescription||t;e._debug("signal"),e.emit("signal",{type:r.type,sdp:r.sdp})}e.destroyed||(t.sdp=e.sdpTransform(t.sdp),e._pc.setLocalDescription(t,function(){e._debug("createOffer success"),e.destroyed||(e.trickle||e._iceComplete?r():e.once("_iceComplete",r))},function(t){e.destroy(c(t,"ERR_SET_LOCAL_DESCRIPTION"))}))},function(t){e.destroy(c(t,"ERR_CREATE_OFFER"))},e.offerConstraints)},u.prototype._createAnswer=function(){var e=this;e.destroyed||e._pc.createAnswer(function(t){function r(){var r=e._pc.localDescription||t;e._debug("signal"),e.emit("signal",{type:r.type,sdp:r.sdp})}e.destroyed||(t.sdp=e.sdpTransform(t.sdp),e._pc.setLocalDescription(t,function(){e.destroyed||(e.trickle||e._iceComplete?r():e.once("_iceComplete",r))},function(t){e.destroy(c(t,"ERR_SET_LOCAL_DESCRIPTION"))}))},function(t){e.destroy(c(t,"ERR_CREATE_ANSWER"))},e.answerConstraints)},u.prototype._onIceStateChange=function(){if(!this.destroyed){var e=this._pc.iceConnectionState,t=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",e,t),this.emit("iceStateChange",e,t),"connected"!==e&&"completed"!==e||(this._pcReady=!0,this._maybeReady()),"failed"===e&&this.destroy(c("Ice connection failed.","ERR_ICE_CONNECTION_FAILURE")),"closed"===e&&this.destroy(new Error("Ice connection closed."))}},u.prototype.getStats=function(e){var t=this;0===t._pc.getStats.length?t._pc.getStats().then(function(t){var r=[];t.forEach(function(e){r.push(e)}),e(null,r)},function(t){e(t)}):t._isReactNativeWebrtc?t._pc.getStats(null,function(t){var r=[];t.forEach(function(e){r.push(e)}),e(null,r)},function(t){e(t)}):t._pc.getStats.length>0?t._pc.getStats(function(r){if(!t.destroyed){var n=[];r.result().forEach(function(e){var t={};e.names().forEach(function(r){t[r]=e.stat(r)}),t.id=e.id,t.type=e.type,t.timestamp=e.timestamp,n.push(t)}),e(null,n)}},function(t){e(t)}):e(null,[])},u.prototype._maybeReady=function(){var e=this;e._debug("maybeReady pc %s channel %s",e._pcReady,e._channelReady),!e.connected&&!e._connecting&&e._pcReady&&e._channelReady&&(e._connecting=!0,function t(){e.destroyed||e.getStats(function(r,n){if(!e.destroyed){r&&(n=[]);var i={},o={},s={},a=!1;if(n.forEach(function(e){"remotecandidate"!==e.type&&"remote-candidate"!==e.type||(i[e.id]=e),"localcandidate"!==e.type&&"local-candidate"!==e.type||(o[e.id]=e),"candidatepair"!==e.type&&"candidate-pair"!==e.type||(s[e.id]=e)}),n.forEach(function(e){"transport"===e.type&&e.selectedCandidatePairId&&f(s[e.selectedCandidatePairId]),("googCandidatePair"===e.type&&"true"===e.googActiveConnection||("candidatepair"===e.type||"candidate-pair"===e.type)&&e.selected)&&f(e)}),a||Object.keys(s).length&&!Object.keys(o).length){if(e._connecting=!1,e.connected=!0,e._chunk){try{e.send(e._chunk)}catch(r){return e.destroy(c(r,"ERR_DATA_CHANNEL"))}e._chunk=null,e._debug('sent chunk from "write before connect"');var u=e._cb;e._cb=null,u(null)}"number"!=typeof e._channel.bufferedAmountLowThreshold&&(e._interval=setInterval(function(){e._onInterval()},150),e._interval.unref&&e._interval.unref()),e._debug("connect"),e.emit("connect")}else setTimeout(t,100)}function f(t){a=!0;var r=o[t.localCandidateId];r&&r.ip?(e.localAddress=r.ip,e.localPort=Number(r.port)):r&&r.ipAddress?(e.localAddress=r.ipAddress,e.localPort=Number(r.portNumber)):"string"==typeof t.googLocalAddress&&(r=t.googLocalAddress.split(":"),e.localAddress=r[0],e.localPort=Number(r[1]));var n=i[t.remoteCandidateId];n&&n.ip?(e.remoteAddress=n.ip,e.remotePort=Number(n.port)):n&&n.ipAddress?(e.remoteAddress=n.ipAddress,e.remotePort=Number(n.portNumber)):"string"==typeof t.googRemoteAddress&&(n=t.googRemoteAddress.split(":"),e.remoteAddress=n[0],e.remotePort=Number(n[1])),e.remoteFamily="IPv4",e._debug("connect local: %s:%s remote: %s:%s",e.localAddress,e.localPort,e.remoteAddress,e.remotePort)}})}())},u.prototype._onInterval=function(){!this._cb||!this._channel||this._channel.bufferedAmount>65536||this._onChannelBufferedAmountLow()},u.prototype._onSignalingStateChange=function(){var e=this;e.destroyed||("stable"===e._pc.signalingState&&(e._isNegotiating=!1,e._debug("flushing sender queue",e._sendersAwaitingStable),e._sendersAwaitingStable.forEach(function(t){e.removeTrack(t),e._queuedNegotiation=!0}),e._sendersAwaitingStable=[],e._queuedNegotiation&&(e._debug("flushing negotiation queue"),e._queuedNegotiation=!1,e._needsNegotiation()),e._debug("negotiate"),e.emit("negotiate")),e._debug("signalingStateChange %s",e._pc.signalingState),e.emit("signalingStateChange",e._pc.signalingState))},u.prototype._onIceCandidate=function(e){this.destroyed||(e.candidate&&this.trickle?this.emit("signal",{candidate:{candidate:e.candidate.candidate,sdpMLineIndex:e.candidate.sdpMLineIndex,sdpMid:e.candidate.sdpMid}}):e.candidate||(this._iceComplete=!0,this.emit("_iceComplete")))},u.prototype._onChannelMessage=function(e){if(!this.destroyed){var r=e.data;r instanceof ArrayBuffer&&(r=t.from(r)),this.push(r)}},u.prototype._onChannelBufferedAmountLow=function(){if(!this.destroyed&&this._cb){this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);var e=this._cb;this._cb=null,e(null)}},u.prototype._onChannelOpen=function(){this.connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())},u.prototype._onChannelClose=function(){this.destroyed||(this._debug("on channel close"),this.destroy())},u.prototype._onTrack=function(e){var t=this;t.destroyed||e.streams.forEach(function(r){t._debug("on track"),t.emit("track",e.track,r),t._remoteTracks.push({track:e.track,stream:r}),t._remoteStreams.some(function(e){return e.id===r.id})||(t._remoteStreams.push(r),setTimeout(function(){t.emit("stream",r)},0))})},u.prototype._debug=function(){var e=[].slice.call(arguments);e[0]="["+this._id+"] "+e[0],n.apply(null,e)},u.prototype._transformConstraints=function(e){if(0===Object.keys(e).length)return e;if((e.mandatory||e.optional)&&!this._isChromium){var t=Object.assign({},e.optional,e.mandatory);return void 0!==t.OfferToReceiveVideo&&(t.offerToReceiveVideo=t.OfferToReceiveVideo,delete t.OfferToReceiveVideo),void 0!==t.OfferToReceiveAudio&&(t.offerToReceiveAudio=t.OfferToReceiveAudio,delete t.OfferToReceiveAudio),t}return e.mandatory||e.optional||!this._isChromium?e:(void 0!==e.offerToReceiveVideo&&(e.OfferToReceiveVideo=e.offerToReceiveVideo,delete e.offerToReceiveVideo),void 0!==e.offerToReceiveAudio&&(e.OfferToReceiveAudio=e.offerToReceiveAudio,delete e.offerToReceiveAudio),{mandatory:e})}}).call(this,r(0).Buffer)},function(e,t,r){(function(n){r(70);var i=r(528);function o(e,t){function r(){i(),t()}function n(e){i(),t(e)}function i(){e.removeListener("close",r),e.removeListener("error",n)}e.on("close",r),e.on("error",n)}function o(e){e.destroy?e.destroy():console.error("warning, stream-to-pull-stream: \nthe wrapped node-stream does not implement `destroy`, \nthis may cause resource leaks.")}function s(e,t,r){var s,a,u=!1;function c(){a||(a=!0,r&&r(!0===s?null:s))}function f(){u||(u=!0,h(),s?c():e(s=!0,c))}function l(t){h(),s||e(s=t,c)}function h(){t.on("finish",f),t.removeListener("close",f),t.removeListener("error",l)}t.on("close",f),t.on("finish",f),t.on("error",l),n.nextTick(function(){i(function(r){e(null,function(e,n){return s=s||e,!0===e?t._isStdio?c():t.end():(s=s||e)?(o(t),c()):void(t._isStdio?t.write(n,function(){r()}):!1===t.write(n)?t.once("drain",r):r())})})})}function a(e){var t,r=[],n=[],i=!1;function s(){for(;(r.length||t)&&n.length;)n.shift()(r.length?null:t,r.shift());!r.length&&i&&(i=!1,e.resume())}return e.on("data",function(t){r.push(t),s(),r.length&&e.pause&&(i=!0,e.pause())}),e.on("end",function(){t=!0,s()}),e.on("close",function(){t=!0,s()}),e.on("error",function(e){t=e,s()}),function(r,i){if(!i)throw new Error("*must* provide cb");if(r){function a(){for(;n.length;)n.shift()(r);i(r)}if(t)return a();e.once("close",a),o(e)}else n.push(i),s()}}var u=a,c=function(e,t){return function(r){return s(r,e,t)}},f=function(e){return a(e)};(t=e.exports=function(e,t){return e.writable&&e.write?e.readable?function(r){return s(r,e,t),a(e)}:c(e,t):f(e)}).sink=c,t.source=f,t.read=u,t.read1=a,t.read2=function(e){var t,r=!1,n=!1;function i(){var r=e.read();if(null!==r&&t){var n=t;t=null,n(null,r)}}return e.on("readable",function(){n=!0,t&&i()}).on("end",function(){r=!0,t&&t(r)}).on("error",function(e){r=e,t&&t(r)}),function(e,o){t=o,r?o(r):n&&i()}},t.duplex=function(e,t){return{source:f(e),sink:c(e,t)}},t.transform=function(e){return function(t){var r=f(e);return c(e)(t),r}}}).call(this,r(6))},function(e,t,r){var n=r(30),i=function(){},o=function(e,t,r){if("function"==typeof t)return o(e,null,t);t||(t={}),r=n(r||i);var s=e._writableState,a=e._readableState,u=t.readable||!1!==t.readable&&e.readable,c=t.writable||!1!==t.writable&&e.writable,f=function(){e.writable||l()},l=function(){c=!1,u||r.call(e)},h=function(){u=!1,c||r.call(e)},p=function(t){r.call(e,t?new Error("exited with error code: "+t):null)},d=function(t){r.call(e,t)},y=function(){return(!u||a&&a.ended)&&(!c||s&&s.ended)?void 0:r.call(e,new Error("premature close"))},g=function(){e.req.on("finish",l)};return function(e){return e.setHeader&&"function"==typeof e.abort}(e)?(e.on("complete",l),e.on("abort",y),e.req?g():e.on("request",g)):c&&!s&&(e.on("end",f),e.on("close",f)),function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length}(e)&&e.on("exit",p),e.on("end",h),e.on("finish",l),!1!==t.error&&e.on("error",d),e.on("close",y),function(){e.removeListener("complete",l),e.removeListener("abort",y),e.removeListener("request",g),e.req&&e.req.removeListener("finish",l),e.removeListener("end",f),e.removeListener("close",f),e.removeListener("finish",l),e.removeListener("exit",p),e.removeListener("end",h),e.removeListener("error",d),e.removeListener("close",y)}};e.exports=o},function(e,t,r){"use strict";e.exports=function(){var e,t;return{source:function(r,n){e?e(r,n):t=[r,n]},sink:function(r){if("function"!=typeof r)throw new Error("read must be function");if(e)throw new Error("already piped");if(e=r,t){var n=t;t=null,e.apply(null,n)}}}}},function(e,t,r){"use strict";(function(n){const i=r(8),o=r(53),s=r(1);function a(e){const t=(~~(1e9*Math.random())).toString(36);function r(e){return r=>{Array.isArray(r)&&(r=r.join(" ")),e("(%s) %s",t,r)}}const n=r(s("mss:"+e));return n.error=r(s("mss:"+e+":error")),n}(t=e.exports).writeEncoded=((e,t,r)=>{!function(e,t){const r=n.isBuffer(e)?[e]:[n.from(e)];i(i.values(r),o.encode(),i.collect((e,r)=>{if(e)return t(e);t(null,r[0])}))}(t,(t,n)=>{if(t)return r(t);e.write(n)})}),t.log={},t.log.dialer=(()=>a("dialer\t")),t.log.listener=(()=>a("listener\t"))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(n){const i=r(12),o=r(1234),s=r(16),a=r(5);class u{constructor(e,t,r){s(n.isBuffer(e),"invalid id provided"),t&&r&&s(t.public.bytes.equals(r.bytes),"inconsistent arguments"),this._id=e,this._idB58String=i.toB58String(this.id),this._privKey=t,this._pubKey=r}get id(){return this._id}set id(e){throw new Error("Id is immutable")}get privKey(){return this._privKey}set privKey(e){this._privKey=e}get pubKey(){return this._pubKey?this._pubKey:this._privKey?this._privKey.public:void 0}set pubKey(e){this._pubKey=e}marshalPubKey(){if(this.pubKey)return o.keys.marshalPublicKey(this.pubKey)}marshalPrivKey(){if(this.privKey)return o.keys.marshalPrivateKey(this.privKey)}toPrint(){return this.toJSON()}toJSON(){return{id:this.toB58String(),privKey:c(this.marshalPrivKey()),pubKey:c(this.marshalPubKey())}}toHexString(){return i.toHexString(this.id)}toBytes(){return this.id}toB58String(){return this._idB58String}isEqual(e){if(n.isBuffer(e))return this.id.equals(e);if(e.id)return this.id.equals(e.id);throw new Error("not valid Id")}isValid(e){this.privKey&&this.privKey.public&&this.privKey.public.bytes&&n.isBuffer(this.pubKey.bytes)&&this.privKey.public.bytes.equals(this.pubKey.bytes)?e():e(new Error("Keys not match"))}}function c(e){if(e)return e.toString("base64")}(t=e.exports=u).create=function(e,t){"function"==typeof e&&(t=e,e={}),(e=e||{}).bits=e.bits||2048,a([t=>o.keys.generateKeyPair("RSA",e.bits,t),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n))})},t.createFromHexString=function(e){return new u(i.fromHexString(e))},t.createFromBytes=function(e){return new u(e)},t.createFromB58String=function(e){return new u(i.fromB58String(e))},t.createFromPubKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r;try{let i=e;if("string"==typeof i&&(i=n.from(e,"base64")),!n.isBuffer(i))throw new Error("Supplied key is neither a base64 string nor a buffer");r=o.keys.unmarshalPublicKey(i)}catch(e){return t(e)}r.hash((e,n)=>{if(e)return t(e);t(null,new u(n,null,r))})},t.createFromPrivKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r=e;try{if("string"==typeof r&&(r=n.from(e,"base64")),!n.isBuffer(r))throw new Error("Supplied key is neither a base64 string nor a buffer")}catch(e){return t(e)}a([e=>o.keys.unmarshalPrivateKey(r,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n,n.public))})},t.createFromJSON=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r,s,c,f;try{r=i.fromB58String(e.id),s=e.privKey&&n.from(e.privKey,"base64"),c=e.pubKey&&n.from(e.pubKey,"base64"),f=c&&o.keys.unmarshalPublicKey(c)}catch(e){return t(e)}s?a([e=>o.keys.unmarshalPrivateKey(s,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)}),(e,t,r)=>{f?f.hash((n,i)=>{r(n,e,t,i)}):r(null,e,t)}],(e,n,i,o)=>e?t(e):f&&!n.equals(o)?t(new Error("Public and private key do not match")):r&&!n.equals(r)?t(new Error("Id and private key do not match")):void t(null,new u(r,i,f))):t(null,new u(r,null,f))},t.isPeerId=function(e){return Boolean("object"==typeof e&&e._id&&e._idB58String)}}).call(this,r(0).Buffer)},function(e,t,r){var n=r(313)(Object,"create");e.exports=n},function(e,t,r){var n=r(314);e.exports=function(e,t){for(var r=e.length;r--;)if(n(e[r][0],t))return r;return-1}},function(e,t,r){var n=r(1327);e.exports=function(e,t){var r=e.__data__;return n(t)?r["string"==typeof t?"string":"hash"]:r.map}},function(e,t,r){"use strict";const n=r(23),i=r(80),o=r(486),s=r(9);t.OFFLINE_ERROR="This command must be run in online mode. Try running 'ipfs daemon' first.";const a=n(function(e,r,n){Array.isArray(r)||(r=[r]),i(r,(r,n)=>{if("string"!=typeof r){let e;try{e=new s(r)}catch(e){return n(e)}return n(null,e.buffer)}let i;try{i=t.parseIpfsPath(r)}catch(e){return n(e)}const o=new s(i.hash),a=i.links;if(!a.length)return n(null,o.buffer);e.get(o,function t(r,i,o){if(i)return n(i);if(!r.length)return n(null,o.multihash);const s=r[0],a=o.links.find(e=>e.name===s);if(!a)return n(new Error(`no link named "${s}" under ${o.toJSON().multihash}`));e.get(a.multihash,t.bind(null,r.slice(1)))}.bind(null,a))},n)});t.parseIpfsPath=function(e){const t=new Error("invalid ipfs ref path"),r=(e=e.replace(/^\/ipfs\//,"")).match(/([^/]+(?:\/[^/]+)*)\/?$/);if(!r)throw t;const[n,...i]=r[1].split("/");if(o.cid(n))return{hash:n,links:i};throw t},t.resolvePath=a},function(e,t,r){var n=r(1364);function i(e,t){return(e=e||[]).push(t),e}e.exports=function(e,t,r,o){var s,a;function u(i){var c=null,f=!1,l=0;if(i,s)return i(!!s.abort||s,function(e){o(e),a&&a()});var h=!1,p=n(function(){h||s||(h=!0,i(null,function(e,n){h=!1,function(e,n){s||((s=e)?f||o(!0===s?null:s):(c=t(c,n),l=c&&c.length||0,null!=c&&d(),l0;)i=s.nextValue(),e=Math.floor(i*t.length),r.push(t.splice(e,1)[0]);return r.join("")}())}e.exports={get:function(){return n||a},characters:function(e){return c(e),n},seed:function(e){s.seed(e),i!==e&&(u(),i=e)},lookup:function(e){return f()[e]},shuffled:f}},function(e,t,r){var n=e.exports;n.encode=r(1486),n.decode=r(1487),n.byteLength=n.encodingLength=function(e){return n.encode(e).length}},function(e,t,r){"use strict";e.exports=function(e,t,r){return 0===e.length?e:t?(r||e.sort(t),function(e,t){for(var r=1,n=e.length,i=e[0],o=e[0],s=1;s>3;return e%8!=0&&t++,t}n.prototype.get=function(e){var t=e>>3;return t>e%8)},n.prototype.set=function(e,t){var r=e>>3;t||1===arguments.length?(this.buffer.length>e%8):r>e%8))},n.prototype._grow=function(e){if(this.buffer.length4294967295&&(o=1),t.writeUInt32BE(o,r),t.write(e.type,r+4,4,"ascii");var c=r+8;if(1===o&&(n.encode(e.length,t,c),c+=8),s.fullBoxes[i]&&(t.writeUInt32BE(e.flags||0,c),t.writeUInt8(e.version||0,c),c+=4),u[i])u[i].forEach(function(r){if(5===r.length){var n=e[r]||[];r=r.substr(0,4),n.forEach(function(e){a._encode(e,t,c),c+=a.encode.bytes})}else e[r]&&(a._encode(e[r],t,c),c+=a.encode.bytes)}),e.otherBoxes&&e.otherBoxes.forEach(function(e){a._encode(e,t,c),c+=a.encode.bytes});else if(s[i]){var f=s[i].encode;f(e,t,c),c+=f.bytes}else{if(!e.buffer)throw new Error("Either `type` must be set to a known type (not'"+i+"') or `buffer` must be set");e.buffer.copy(t,c),c+=e.buffer.length}return a.encode.bytes=c-r,t},a.readHeaders=function(e,t,r){if(t=t||0,(r=r||e.length)-t<8)return 8;var i,o,a=e.readUInt32BE(t),u=e.toString("ascii",t+4,t+8),c=t+8;if(1===a){if(r-t<16)return 16;a=n.decode(e,c),c+=8}return s.fullBoxes[u]&&(i=e.readUInt8(c),o=16777215&e.readUInt32BE(c),c+=4),{length:a,headersLen:c-t,contentLen:a-(c-t),type:u,version:i,flags:o}},a.decode=function(e,t,r){t=t||0,r=r||e.length;var n=a.readHeaders(e,t,r);if(!n||n.length>r-t)throw new Error("Data too short");return a.decodeWithoutHeaders(n,e,t+n.headersLen,t+n.length)},a.decodeWithoutHeaders=function(e,t,r,n){r=r||0,n=n||t.length;var i=e.type,c={};if(u[i]){c.otherBoxes=[];for(var f=u[i],l=r;n-l>=8;){var h=a.decode(t,l,n);if(l+=h.length,f.indexOf(h.type)>=0)c[h.type]=h;else if(f.indexOf(h.type+"s")>=0){var p=h.type+"s";(c[p]=c[p]||[]).push(h)}else c.otherBoxes.push(h)}}else if(s[i]){c=(0,s[i].decode)(t,r,n)}else c.buffer=o(t.slice(r,n));return c.length=e.length,c.contentLen=e.contentLen,c.type=e.type,c.version=e.version,c.flags=e.flags,c},a.encodingLength=function(e){var t=e.type,r=8;if(s.fullBoxes[t]&&(r+=4),u[t])u[t].forEach(function(t){if(5===t.length){var n=e[t]||[];t=t.substr(0,4),n.forEach(function(e){e.type=t,r+=a.encodingLength(e)})}else if(e[t]){var i=e[t];i.type=t,r+=a.encodingLength(i)}}),e.otherBoxes&&e.otherBoxes.forEach(function(e){r+=a.encodingLength(e)});else if(s[t])r+=s[t].encodingLength(e);else{if(!e.buffer)throw new Error("Either `type` must be set to a known type (not'"+t+"') or `buffer` must be set");r+=e.buffer.length}return r>4294967295&&(r+=8),e.length=r,r}},function(e,t,r){(function(t){var n=r(1545),i=r(1546);e.exports=function(e,r,o){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative');if(t.alloc)return t.alloc(e,r,o);var s=i(e);return 0===e?s:void 0===r?n(s,0):("string"!=typeof o&&(o=void 0),n(s,r,o))}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";t.decode=t.parse=r(625),t.encode=t.stringify=r(626)},function(e,t,r){"use strict";(function(t,n){var i=r(150);function o(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,r){var n=e.entry;for(e.entry=null;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 s,a=!t.browser&&["v0.10","v0.9."].indexOf(t.version.slice(0,5))>-1?setImmediate:i.nextTick;m.WritableState=g;var u=r(117);u.inherits=r(4);var c={deprecate:r(632)},f=r(332),l=r(2).Buffer,h=n.Uint8Array||function(){};var p,d=r(334);function y(){}function g(e,t){s=s||r(85),e=e||{};var n=t instanceof s;this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,a=e.writableHighWaterMark,u=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(a||0===a)?a:u,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 c=!1===e.decodeStrings;this.decodeStrings=!c,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){k(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 o(this)}function m(e){if(s=s||r(85),!(p.call(m,this)||this instanceof s))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)),f.call(this)}function b(e,t){var r=new Error("write after end");e.emit("error",r),i.nextTick(t,r)}function v(e,t,r,n){var o=!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),i.nextTick(n,s),o=!1),o}function _(e,t,r,n,i,o){if(!r){var s=function(e,t,r){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=l.from(t,r)),t}(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var u=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&&void 0!==e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,T(e,t),r&&(t.finished?i.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=d.destroy,m.prototype._undestroy=d.undestroy,m.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,r(6),r(7))},function(e,t,r){"use strict";var n=r(2).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=u,this.end=c,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=f,this.end=l,t=3;break;default:return this.write=h,void(this.end=p)}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 u(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 c(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 l(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function h(e){return e.toString(this.encoding)}function p(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?(i>0&&(e.lastNeed=i-1),i):--n=0?(i>0&&(e.lastNeed=i-2),i):--n=0?(i>0&&(2===i?i=0:e.lastNeed=i-3),i):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){"use strict";(function(n){const i=r(641);(t=e.exports=s).encode=function(e,t){const r=a(e);return s(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=a(t);return r.name,n.from(r.decode(e.toString()))},t.isEncoded=function(e){n.isBuffer(e)&&(e=e.toString());const t=e.substring(0,1);try{const r=a(t);return r.name}catch(e){return!1}};const o=new Error("Unsupported encoding");function s(e,t){if(!t)throw new Error("requires an encoded buffer");const r=a(e),i=n.from(r.code);return function(e,t){a(e).decode(t.toString())}(r.name,t),n.concat([i,t])}function a(e){let t;if(i.names[e])t=i.names[e];else{if(!i.codes[e])throw o;t=i.codes[e]}if(!t.isImplemented())throw new Error("Base "+e+" is not implemented yet");return t}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";var n=r(118);e.exports=function(e,t,r){r||(r=t,t=null);var i=n(function(r){t=e(t,r)},function(e){r(e,t)});return 2===arguments.length?function(e){e(null,function(n,o){if(n)return r(!0===n?null:n);t=o,i(e)})}:i}},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.hasNextTick=t.hasSetImmediate=void 0,t.fallback=a,t.wrap=u;var n=function(e){return e&&e.__esModule?e:{default:e}}(r(103));var i,o=t.hasSetImmediate="function"==typeof setImmediate&&setImmediate,s=t.hasNextTick="object"==typeof e&&"function"==typeof e.nextTick;function a(e){setTimeout(e,0)}function u(e){return function(t){var r=(0,n.default)(arguments,1);e(function(){t.apply(null,r)})}}i=o?setImmediate:s?e.nextTick:a,t.default=u(i)}).call(this,r(6))},function(e,t,r){var n=r(157),i=r(121),o="[object AsyncFunction]",s="[object Function]",a="[object GeneratorFunction]",u="[object Proxy]";e.exports=function(e){if(!i(e))return!1;var t=n(e);return t==s||t==a||t==o||t==u}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=o(r(354)),i=o(r(218));function o(e){return e&&e.__esModule?e:{default:e}}t.default=(0,i.default)(n.default,1),e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={},e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){return function(r,n,i){return e(r,t,n,i)}},e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){((0,n.default)(e)?function(e,t,r){r=(0,u.default)(r||a.default);var n=0,o=0,s=e.length;function f(e,t){e?r(e):++o!==s&&t!==i.default||r(null)}for(0===s&&r(null);n100)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var a=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return a*s;case"days":case"day":case"d":return a*o;case"hours":case"hour":case"hrs":case"hr":case"h":return a*i;case"minutes":case"minute":case"mins":case"min":case"m":return a*n;case"seconds":case"second":case"secs":case"sec":case"s":return a*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}}}function u(e){return e>=o?Math.round(e/o)+"d":e>=i?Math.round(e/i)+"h":e>=n?Math.round(e/n)+"m":e>=r?Math.round(e/r)+"s":e+"ms"}function c(e){return f(e,o,"day")||f(e,i,"hour")||f(e,n,"minute")||f(e,r,"second")||e+" ms"}function f(e,t,r){if(!(e0)return a(e);if("number"===r&&!1===isNaN(e))return t.long?c(e):u(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,r){var n=r(363),i=r(364);e.exports=function(e,t,r){var o=t&&r||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var s=(e=e||{}).random||(e.rng||n)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t)for(var a=0;a<16;++a)t[o+a]=s[a];return t||i(s)}},function(e,t,r){"use strict";const n=r(8),i=r(161),o=r(60),s=r(365),a=r(221);t.asyncFilter=function(e){let t,r,n=!1;return function(i){return function o(s,a){if(r)return a(r);s?(r=s,i(s,n?()=>{n?t=a:a(s)}:a)):i(null,(i,s)=>{i?a(i):r?a(r):(n=!0,e(s,(e,i)=>{n=!1,r?(a(r),t(r)):e?o(e,a):i?a(null,s):o(null,a)}))})}}},t.asyncSort=function(e){const t=i(),r=n.collect((r,i)=>{if(r)return t.abort(r);e(i,(e,r)=>{if(e)return t.abort(e);t.resolve(n.values(i))})});return function(e){return r(e),t}},t.replaceStartWith=function(e,t){const r=new RegExp("^"+t);return e.replace(r,"")},t.tmpdir=(()=>o.join(s.tmpdir(),a()))},function(e,t){e.exports=function(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++ra.isDAGLink(e)?e:a.util.createDagLinkFromB58EncodedHash(e)));try{r=o.PBNode.encode(function(e){const t={};return e.data&&e.data.length>0?t.Data=e.data:t.Data=null,e.links&&e.links.length>0?t.Links=e.links.map(e=>({Hash:e.multihash,Name:e.name,Tsize:e.size})):t.Links=null,t}(e))}catch(e){return t(e)}t(null,r)}(t=e.exports).serialize=l,t.deserialize=function(e,t){const r=o.PBNode.decode(e),i=r.Links.map(e=>new a(e.Name,e.Tsize,e.Hash)),s=null==r.Data?n.alloc(0):n.from(r.Data);u.create(s,i,t)},t.cid=function(e,t,r){"function"==typeof t&&(r=t,t={});const n=(t=t||{}).hashAlg||s.defaultHashAlg;let o=t.version;void 0===o&&(o="sha2-256"===n?0:1),f([t=>l(e,t),(e,t)=>c(e,n,t),(e,t)=>t(null,new i(o,s.multicodec,e))],r)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";t.defined=function(e){return null!==e&&void 0!==e&&("number"!=typeof e||!isNaN(e))}},function(e,t,r){"use strict";(function(e){const n=r(169),i=r(170),o=i.SHIFT32,s=i.SHIFT16;function a(e){return e<16?"0"+e.toString(16):e.toString(16)}t.parseHalf=function(e){var t,r,n;return n=128&e[0]?-1:1,t=(124&e[0])>>2,r=(3&e[0])<<8|e[1],t?31===t?n*(r?NaN:1/0):n*Math.pow(2,t-25)*(1024+r):5.960464477539063e-8*n*r},t.arrayBufferToBignumber=function(e){const t=e.byteLength;let r="";for(let n=0;n{const t=new Map,r=Object.keys(e),n=r.length;for(let i=0;ie*s+t),t.buildInt64=((e,r,i,s)=>{const a=t.buildInt32(e,r),u=t.buildInt32(i,s);return a>2097151?new n(a).times(o).plus(u):a*o+u}),t.writeHalf=function(t,r){const n=e.allocUnsafe(4);n.writeFloatBE(r,0);const i=n.readUInt32BE(0);if(0!=(8191&i))return!1;var o=i>>16&32768;const s=i>>23&255,a=8388607&i;if(s>=113&&s<=142)o+=(s-112<<10)+(a>>13);else{if(!(s>=103&&s<113))return!1;if(a&(1<<126-s)-1)return!1;o+=a+8388608>>126-s}return t.writeUInt16BE(o,0),!0},t.keySorter=function(e,t){var r=e[0].byteLength,n=t[0].byteLength;return r>n?1:n>r?-1:e[0].compare(t[0])},t.isNegativeZero=(e=>0===e&&1/e<0),t.nextPowerOf2=(e=>{let t=0;if(e&&!(e&e-1))return e;for(;0!==e;)e>>=1,t+=1;return 1<{switch(t){case"version":return e.version;case"timestamp":return e.timestamp;case"difficulty":return e.bits;case"nonce":return e.nonce;case"parent":return{"/":n.hashToCid(e.prevHash)};case"tx":return{"/":n.hashToCid(e.merkleRoot)};default:return null}};e.exports={multicodec:"bitcoin-block",defaultHashAlg:"dbl-sha2-256",resolve:(e,t,r)=>{"function"==typeof t&&(r=t,t=void 0),n.deserialize(e,(e,n)=>{if(e)return r(e);if(!t)return r(null,{value:n,remainderPath:""});const o=t.split("/"),s=i(n,o[0]);if(null===s)return r(new Error("No such path"),null);let a=o.slice(1).join("/");return void 0!==s["/"]?r(null,{value:s,remainderPath:a}):a.length>0?r(new Error("No such path"),null):r(null,{value:s,remainderPath:""})})},tree:(e,t,r)=>{"function"==typeof t&&(r=t,t=void 0),t=t||{},n.deserialize(e,(e,n)=>{if(e)return r(e);const o=["version","timestamp","difficulty","nonce","parent","tx"];if(!0===t.values){const e={};for(let t of o)e[t]=i(n,t);return r(null,e)}return r(null,o)})}}},function(e,t,r){var n=r(2).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){var r={Array:function(e){return null!==e&&void 0!==e&&e.constructor===Array},Boolean:function(e){return"boolean"==typeof e},Function:function(e){return"function"==typeof e},Nil:function(e){return void 0===e||null===e},Number:function(e){return"number"==typeof e},Object:function(e){return"object"==typeof e},String:function(e){return"string"==typeof e},"":function(){return!0}};for(var n in r.Null=r.Nil,r)r[n].toJSON=function(e){return e}.bind(null,n);e.exports=r},function(e,t,r){var n=r(28).decompile,i=r(234),o=r(777),s=r(235),a=r(236),u=r(782),c=r(785),f=r(787),l=r(789),h={MULTISIG:"multisig",NONSTANDARD:"nonstandard",NULLDATA:"nulldata",P2PK:"pubkey",P2PKH:"pubkeyhash",P2SH:"scripthash",P2WPKH:"witnesspubkeyhash",P2WSH:"witnessscripthash",WITNESS_COMMITMENT:"witnesscommitment"};e.exports={classifyInput:function(e,t){var r=n(e);return a.input.check(r)?h.P2PKH:u.input.check(r,t)?h.P2SH:i.input.check(r,t)?h.MULTISIG:s.input.check(r)?h.P2PK:h.NONSTANDARD},classifyOutput:function(e){if(c.output.check(e))return h.P2WPKH;if(f.output.check(e))return h.P2WSH;if(a.output.check(e))return h.P2PKH;if(u.output.check(e))return h.P2SH;var t=n(e);return i.output.check(t)?h.MULTISIG:s.output.check(t)?h.P2PK:l.output.check(t)?h.WITNESS_COMMITMENT:o.output.check(t)?h.NULLDATA:h.NONSTANDARD},classifyWitness:function(e,t){var r=n(e);return c.input.check(r)?h.P2WPKH:f.input.check(r,t)?h.P2WSH:h.NONSTANDARD},multisig:i,nullData:o,pubKey:s,pubKeyHash:a,scriptHash:u,witnessPubKeyHash:c,witnessScriptHash:f,witnessCommitment:l,types:h}},function(e,t,r){e.exports={input:r(776),output:r(401)}},function(e,t,r){e.exports={input:r(778),output:r(779)}},function(e,t,r){e.exports={input:r(780),output:r(781)}},function(e,t,r){"use strict";var n=r(2).Buffer,i=9007199254740991;function o(e){if(e<0||e>i||e%1!=0)throw new RangeError("value out of range")}function s(e){return o(e),e<253?1:e<=65535?3:e<=4294967295?5:9}e.exports={encode:function e(t,r,i){if(o(t),r||(r=n.allocUnsafe(s(t))),!n.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return i||(i=0),t<253?(r.writeUInt8(t,i),e.bytes=1):t<=65535?(r.writeUInt8(253,i),r.writeUInt16LE(t,i+1),e.bytes=3):t<=4294967295?(r.writeUInt8(254,i),r.writeUInt32LE(t,i+1),e.bytes=5):(r.writeUInt8(255,i),r.writeUInt32LE(t>>>0,i+1),r.writeUInt32LE(t/4294967296|0,i+5),e.bytes=9),r},decode:function e(t,r){if(!n.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");r||(r=0);var i=t.readUInt8(r);if(i<253)return e.bytes=1,i;if(253===i)return e.bytes=3,t.readUInt16LE(r+1);if(254===i)return e.bytes=5,t.readUInt32LE(r+1);e.bytes=9;var s=t.readUInt32LE(r+1),a=4294967296*t.readUInt32LE(r+5)+s;return o(a),a},encodingLength:s}},function(e,t,r){"use strict";(function(t){var n=r(4),i=r(405),o=new Array(16);function s(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function a(e,t){return e<>>32-t}function u(e,t,r,n,i,o,s){return a(e+(t&r|~t&n)+i+o|0,s)+t|0}function c(e,t,r,n,i,o,s){return a(e+(t&n|r&~n)+i+o|0,s)+t|0}function f(e,t,r,n,i,o,s){return a(e+(t^r^n)+i+o|0,s)+t|0}function l(e,t,r,n,i,o,s){return a(e+(r^(t|~n))+i+o|0,s)+t|0}n(s,i),s.prototype._update=function(){for(var e=o,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,i=this._c,s=this._d;n=l(n=l(n=l(n=l(n=f(n=f(n=f(n=f(n=c(n=c(n=c(n=c(n=u(n=u(n=u(n=u(n,i=u(i,s=u(s,r=u(r,n,i,s,e[0],3614090360,7),n,i,e[1],3905402710,12),r,n,e[2],606105819,17),s,r,e[3],3250441966,22),i=u(i,s=u(s,r=u(r,n,i,s,e[4],4118548399,7),n,i,e[5],1200080426,12),r,n,e[6],2821735955,17),s,r,e[7],4249261313,22),i=u(i,s=u(s,r=u(r,n,i,s,e[8],1770035416,7),n,i,e[9],2336552879,12),r,n,e[10],4294925233,17),s,r,e[11],2304563134,22),i=u(i,s=u(s,r=u(r,n,i,s,e[12],1804603682,7),n,i,e[13],4254626195,12),r,n,e[14],2792965006,17),s,r,e[15],1236535329,22),i=c(i,s=c(s,r=c(r,n,i,s,e[1],4129170786,5),n,i,e[6],3225465664,9),r,n,e[11],643717713,14),s,r,e[0],3921069994,20),i=c(i,s=c(s,r=c(r,n,i,s,e[5],3593408605,5),n,i,e[10],38016083,9),r,n,e[15],3634488961,14),s,r,e[4],3889429448,20),i=c(i,s=c(s,r=c(r,n,i,s,e[9],568446438,5),n,i,e[14],3275163606,9),r,n,e[3],4107603335,14),s,r,e[8],1163531501,20),i=c(i,s=c(s,r=c(r,n,i,s,e[13],2850285829,5),n,i,e[2],4243563512,9),r,n,e[7],1735328473,14),s,r,e[12],2368359562,20),i=f(i,s=f(s,r=f(r,n,i,s,e[5],4294588738,4),n,i,e[8],2272392833,11),r,n,e[11],1839030562,16),s,r,e[14],4259657740,23),i=f(i,s=f(s,r=f(r,n,i,s,e[1],2763975236,4),n,i,e[4],1272893353,11),r,n,e[7],4139469664,16),s,r,e[10],3200236656,23),i=f(i,s=f(s,r=f(r,n,i,s,e[13],681279174,4),n,i,e[0],3936430074,11),r,n,e[3],3572445317,16),s,r,e[6],76029189,23),i=f(i,s=f(s,r=f(r,n,i,s,e[9],3654602809,4),n,i,e[12],3873151461,11),r,n,e[15],530742520,16),s,r,e[2],3299628645,23),i=l(i,s=l(s,r=l(r,n,i,s,e[0],4096336452,6),n,i,e[7],1126891415,10),r,n,e[14],2878612391,15),s,r,e[5],4237533241,21),i=l(i,s=l(s,r=l(r,n,i,s,e[12],1700485571,6),n,i,e[3],2399980690,10),r,n,e[10],4293915773,15),s,r,e[1],2240044497,21),i=l(i,s=l(s,r=l(r,n,i,s,e[8],1873313359,6),n,i,e[15],4264355552,10),r,n,e[6],2734768916,15),s,r,e[13],1309151649,21),i=l(i,s=l(s,r=l(r,n,i,s,e[4],4149444226,6),n,i,e[11],3174756917,10),r,n,e[2],718787259,15),s,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+s|0},s.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=new t(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=s}).call(this,r(0).Buffer)},function(e,t,r){var n=r(2).Buffer,i=r(106),o=r(28),s=r(404),a=r(37),u=r(25),c=r(31),f=r(237);function l(e){var t=e.length;return f.encodingLength(t)+t}function h(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}h.DEFAULT_SEQUENCE=4294967295,h.SIGHASH_ALL=1,h.SIGHASH_NONE=2,h.SIGHASH_SINGLE=3,h.SIGHASH_ANYONECANPAY=128,h.ADVANCED_TRANSACTION_MARKER=0,h.ADVANCED_TRANSACTION_FLAG=1;var p=n.allocUnsafe(0),d=[],y=n.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),g=n.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),m=n.from("ffffffffffffffff","hex"),b={script:p,valueBuffer:m};h.fromBuffer=function(e,t){var r=0;function n(t){return r+=t,e.slice(r-t,r)}function i(){var t=e.readUInt32LE(r);return r+=4,t}function o(){var t=s.readUInt64LE(e,r);return r+=8,t}function a(){var t=f.decode(e,r);return r+=f.decode.bytes,t}function u(){return n(a())}function c(){for(var e=a(),t=[],r=0;r=this.ins.length)return g;var s=o.compile(o.decompile(t).filter(function(e){return e!==a.OP_CODESEPARATOR})),f=this.clone();if((31&r)===h.SIGHASH_NONE)f.outs=[],f.ins.forEach(function(t,r){r!==e&&(t.sequence=0)});else if((31&r)===h.SIGHASH_SINGLE){if(e>=this.outs.length)return g;f.outs.length=e+1;for(var l=0;l=0)throw new Error("Private key must be less than the curve order");if(t)throw new TypeError("Unexpected publicKey parameter");this.d=e}else a(u.ECPoint,t),this.__Q=t;this.compressed=void 0===r.compressed||r.compressed,this.network=r.network||f.bitcoin}Object.defineProperty(d.prototype,"Q",{get:function(){return!this.__Q&&this.d&&(this.__Q=p.G.multiply(this.d)),this.__Q}}),d.fromPublicKeyBuffer=function(e,t){var r=h.Point.decodeFrom(p,e);return new d(null,r,{compressed:r.compressed,network:t})},d.fromWIF=function(e,t){var r=c.decode(e),n=r.version;if(u.Array(t)){if(!(t=t.filter(function(e){return n===e.wif}).pop()))throw new Error("Unknown network version")}else if(t=t||f.bitcoin,n!==t.wif)throw new Error("Invalid network version");return new d(l.fromBuffer(r.privateKey),null,{compressed:r.compressed,network:t})},d.makeRandom=function(e){var t,r=(e=e||{}).rng||s;do{var n=r(32);a(u.Buffer256bit,n),t=l.fromBuffer(n)}while(t.signum()<=0||t.compareTo(p.n)>=0);return new d(t,null,e)},d.prototype.getAddress=function(){return n.toBase58Check(i.hash160(this.getPublicKeyBuffer()),this.getNetwork().pubKeyHash)},d.prototype.getNetwork=function(){return this.network},d.prototype.getPublicKeyBuffer=function(){return this.Q.getEncoded(this.compressed)},d.prototype.sign=function(e){if(!this.d)throw new Error("Missing private key");return o.sign(e,this.d)},d.prototype.toWIF=function(){if(!this.d)throw new Error("Missing private key");return c.encode(this.network.wif,this.d.toBuffer(32),this.compressed)},d.prototype.verify=function(e,t){return o.verify(e,t,this.Q)},e.exports=d},function(e,t,r){var n=r(2).Buffer,i=r(797),o=r(242),s=r(28),a=r(233),u=r(124),c=r(25),f=r(31);function l(e){var t=o.decode(e);if(t.length<21)throw new TypeError(e+" is too short");if(t.length>21)throw new TypeError(e+" is too long");return{version:t.readUInt8(0),hash:t.slice(1)}}function h(e){var t=i.decode(e),r=i.fromWords(t.words.slice(1));return{version:t.words[0],prefix:t.prefix,data:n.from(r)}}function p(e,t){c(f.tuple(f.Hash160bit,f.UInt8),arguments);var r=n.allocUnsafe(21);return r.writeUInt8(t,0),e.copy(r,1),o.encode(r)}function d(e,t,r){var n=i.toWords(e);return n.unshift(t),i.encode(r,n)}e.exports={fromBase58Check:l,fromBech32:h,fromOutputScript:function(e,t){if(t=t||u.bitcoin,a.pubKeyHash.output.check(e))return p(s.compile(e).slice(3,23),t.pubKeyHash);if(a.scriptHash.output.check(e))return p(s.compile(e).slice(2,22),t.scriptHash);if(a.witnessPubKeyHash.output.check(e))return d(s.compile(e).slice(2,22),0,t.bech32);if(a.witnessScriptHash.output.check(e))return d(s.compile(e).slice(2,34),0,t.bech32);throw new Error(s.toASM(e)+" has no matching Address")},toBase58Check:p,toBech32:d,toOutputScript:function(e,t){var r;t=t||u.bitcoin;try{r=l(e)}catch(e){}if(r){if(r.version===t.pubKeyHash)return a.pubKeyHash.output.encode(r.hash);if(r.version===t.scriptHash)return a.scriptHash.output.encode(r.hash)}else{try{r=h(e)}catch(e){}if(r){if(r.prefix!==t.bech32)throw new Error(e+" has an invalid prefix");if(0===r.version){if(20===r.data.length)return a.witnessPubKeyHash.output.encode(r.data);if(32===r.data.length)return a.witnessScriptHash.output.encode(r.data)}}}throw new Error(e+" has no matching Script")}}},function(e,t,r){"use strict";var n=r(123),i=r(798);e.exports=i(function(e){var t=n("sha256").update(e).digest();return n("sha256").update(t).digest()})},function(e,t,r){"use strict";var n=r(4),i=r(800),o=r(92),s=r(2).Buffer,a=r(801),u=r(406),c=r(407),f=s.alloc(128);function l(e,t){o.call(this,"digest"),"string"==typeof t&&(t=s.from(t));var r="sha512"===e||"sha384"===e?128:64;this._alg=e,this._key=t,t.length>r?t=("rmd160"===e?new u:c(e)).update(t).digest():t.length=4)throw new Error("Invalid hashType "+t);return{signature:a.fromDER(e.slice(0,-1)),hashType:t}},a.prototype.toCompact=function(e,r){r&&(e+=4),e+=27;var n=t.alloc(65);return n.writeUInt8(e,0),this.toRSBuffer(n,1),n},a.prototype.toDER=function(){var e=t.from(this.r.toDERInteger()),r=t.from(this.s.toDERInteger());return n.encode(e,r)},a.prototype.toRSBuffer=function(e,r){return e=e||t.alloc(64),this.r.toBuffer(32).copy(e,r),this.s.toBuffer(32).copy(e,r+32),e},a.prototype.toScriptSignature=function(e){var r=-129&e;if(r<=0||r>=4)throw new Error("Invalid hashType "+e);var n=t.alloc(1);return n.writeUInt8(e,0),t.concat([this.toDER(),n])},e.exports=a}).call(this,r(0).Buffer)},function(e,t,r){var n=r(411),i=r(412),o=r(804);e.exports={Curve:i,Point:n,getCurveByName:o}},function(e){e.exports={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){var n=t;n.utils=r(71),n.common=r(125),n.sha=r(830),n.ripemd=r(834),n.hmac=r(835),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";(function(t){const n=r(50),i=r(5),o=r(154),s=r(126),a=r(854),u=r(127),c=r(128);r(855),r(421),r(420),r(422);function f(e){return e.map(e=>e.toString(16)).join("/")}e.exports=function(e,r){const l=c(e,a,function(e,o,s){h(e,o,(e,a)=>{if(e)return s(e);if(!r)return s(null,a);let u=a.slice();const c=a.filter(e=>t.isBuffer(e.value));n(c,(e,t)=>i([t=>r.util.deserialize(e.value,t),(e,t)=>r.resolver._mapFromEthObject(e,o,t)],(r,n)=>{if(r)return t(r);n.forEach(t=>{u.push({path:e.path+"/"+t.path,value:t.value})}),t()}),e=>{if(e)return s(e);s(null,u)})})});return l.util.deserialize=o(e=>{const t=s.decode(e);return new a(t)}),l;function h(t,r,i){let o=[];"leaf"===t.type&&o.push({path:f(t.getKey()),value:t.getValue()}),n(t.getChildren(),(t,n)=>{const i=f(t[0]),s=t[1];if(a.isRawNode(s)){const e=new a(s);o.push({path:i,value:e}),h(e,r,(e,t)=>{if(e)return n(e);t.forEach(e=>{e.path=i+"/"+e.path}),o=o.concat(t),n()})}else{let t={"/":u(e,s).toBaseEncodedString()};o.push({path:i,value:t}),n()}},e=>{if(e)return i(e);i(null,o)})}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(427),i=(e,t)=>{switch(t){case"version":return e.version;case"timestamp":return e.time;case"difficulty":return e.bits;case"nonce":return e.nonce;case"solution":return e.solution;case"reserved":return e.reserved;case"parent":return{"/":n.hashToCid(e.prevHash)};case"tx":return{"/":n.hashToCid(e.merkleRoot)};default:return null}};e.exports={multicodec:"zcash-block",defaultHashAlg:"dbl-sha2-256",resolve:(e,t,r)=>{"function"==typeof t&&(r=t,t=void 0),n.deserialize(e,(e,n)=>{if(e)return r(e);if(!t)return r(null,{value:n,remainderPath:""});const o=t.split("/"),s=i(n,o[0]);if(null===s)return r(new Error("No such path"),null);let a=o.slice(1).join("/");return void 0!==s["/"]?r(null,{value:s,remainderPath:a}):a.length>0?r(new Error("No such path"),null):r(null,{value:s,remainderPath:""})})},tree:(e,t,r)=>{"function"==typeof t&&(r=t,t=void 0),t=t||{},n.deserialize(e,(e,n)=>{if(e)return r(e);const o=["version","timestamp","difficulty","nonce","solution","reserved","parent","tx"];if(!0===t.values){const e={};for(let t of o)e[t]=i(n,t);return r(null,e)}return r(null,o)})}}},function(e,t,r){"use strict";(function(t){var n=r(18),i=r(21),o=r(24),s=r(29);function a(e){if(!(this instanceof a))return new a(e);var t;if(n.isNumber(e))t=e;else{if(!n.isString(e))throw new TypeError('Unrecognized num type: "'+typeof e+'" for Opcode');t=a.map[e]}return s.defineImmutable(this,{num:t}),this}for(var u in a.fromBuffer=function(e){return i.checkArgument(o.isBuffer(e)),new a(Number("0x"+e.toString("hex")))},a.fromNumber=function(e){return i.checkArgument(n.isNumber(e)),new a(e)},a.fromString=function(e){i.checkArgument(n.isString(e));var t=a.map[e];if(void 0===t)throw new TypeError("Invalid opcodestr");return new a(t)},a.prototype.toHex=function(){return this.num.toString(16)},a.prototype.toBuffer=function(){return new t(this.toHex(),"hex")},a.prototype.toNumber=function(){return this.num},a.prototype.toString=function(){var e=a.reverseMap[this.num];if(void 0===e)throw new Error("Opcode does not have a string representation");return e},a.smallInt=function(e){return i.checkArgument(n.isNumber(e),"Invalid Argument: n should be number"),i.checkArgument(e>=0&&e<=16,"Invalid Argument: n must be between 0 and 16"),0===e?a("OP_0"):new a(a.map.OP_1+e-1)},a.map={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP1:176,OP_NOP2:177,OP_NOP3:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255},a.reverseMap=[],a.map)a.reverseMap[a.map[u]]=u;n.extend(a,a.map),a.isSmallIntOp=function(e){return e instanceof a&&(e=e.toNumber()),e===a.map.OP_0||e>=a.map.OP_1&&e<=a.map.OP_16},a.prototype.inspect=function(){return""},e.exports=a}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){var n=r(18),i=r(21),o=r(0),s=t.compare||r(884),a=r(62),u=r(24),c=r(29),f=r(82),l=r(57),h=r(38),p=r(63),d=r(83),y=r(97),g=r(431),m=r(252),b=m.PublicKeyHash,v=m.PublicKey,_=m.MultiSigScriptHash,w=m.MultiSig,S=r(84),k=r(64),E=r(176),A=r(32),x=r(889);function I(e){if(!(this instanceof I))return new I(e);if(this.inputs=[],this.outputs=[],this.joinSplits=[],this._inputAmount=void 0,this._outputAmount=void 0,e){if(e instanceof I)return I.shallowCopy(e);if(c.isHexa(e))this.fromString(e);else if(u.isBuffer(e))this.fromBuffer(e);else{if(!n.isObject(e))throw new a.InvalidArgument("Must provide an object or string to deserialize a transaction");this.fromObject(e)}}else this._newTransaction()}I.DUST_AMOUNT=546,I.FEE_SECURITY_MARGIN=15,I.MAX_MONEY=21e14,I.NLOCKTIME_BLOCKHEIGHT_LIMIT=5e8,I.NLOCKTIME_MAX_VALUE=4294967295,I.FEE_PER_KB=1e4,I.CHANGE_OUTPUT_MAX_SIZE=62,I.MAXIMUM_EXTRA_SIZE=26,I.shallowCopy=function(e){return new I(e.toBuffer())};var T={configurable:!1,enumerable:!0,get:function(){return new f(this._getHash()).readReverse().toString("hex")}};Object.defineProperty(I.prototype,"hash",T),Object.defineProperty(I.prototype,"id",T);var B={configurable:!1,enumerable:!0,get:function(){return this._getInputAmount()}};Object.defineProperty(I.prototype,"inputAmount",B),B.get=function(){return this._getOutputAmount()},Object.defineProperty(I.prototype,"outputAmount",B),I.prototype._getHash=function(){return h.sha256sha256(this.toBuffer())},I.prototype.serialize=function(e){return!0===e||e&&e.disableAll?this.uncheckedSerialize():this.checkedSerialize(e)},I.prototype.uncheckedSerialize=I.prototype.toString=function(){return this.toBuffer().toString("hex")},I.prototype.checkedSerialize=function(e){var t=this.getSerializationError(e);if(t)throw t.message+=" Use Transaction#uncheckedSerialize if you want to skip security checks. See http://bitcore.io/guide/transaction.html#Serialization for more info.",t;return this.uncheckedSerialize()},I.prototype.invalidSatoshis=function(){for(var e=!1,t=0;tr)return this._missingChange()?new a.Transaction.ChangeAddressMissing("Fee is too large and no change address was provided"):new a.Transaction.FeeError.TooLarge("expected less than "+r+" but got "+t)}if(!e.disableSmallFees){var i=Math.ceil(this._estimateFee()/I.FEE_SECURITY_MARGIN);if(t"},I.prototype.toBuffer=function(){var e=new l;return this.toBufferWriter(e).toBuffer()},I.prototype.toBufferWriter=function(e){return e.writeUInt32LE(this.version),e.writeVarintNum(this.inputs.length),n.each(this.inputs,function(t){t.toBufferWriter(e)}),e.writeVarintNum(this.outputs.length),n.each(this.outputs,function(t){t.toBufferWriter(e)}),e.writeUInt32LE(this.nLockTime),this.version>=2&&(e.writeVarintNum(this.joinSplits.length),n.each(this.joinSplits,function(t){t.toBufferWriter(e)}),this.joinSplits.length>0&&(e.write(this.joinSplitPubKey),e.write(this.joinSplitSig))),e},I.prototype.fromBuffer=function(e){var t=new f(e);return this.fromBufferReader(t)},I.prototype.fromBufferReader=function(e){var t,r,n,o;for(i.checkArgument(!e.finished(),"No transaction data received"),this.version=e.readUInt32LE(),r=e.readVarintNum(),t=0;t=2){for(o=e.readVarintNum(),t=0;t0&&(this.joinSplitPubKey=e.read(32),this.joinSplitSig=e.read(64))}return this},I.prototype.toObject=I.prototype.toJSON=function(){var e=[];this.inputs.forEach(function(t){e.push(t.toObject())});var t=[];this.outputs.forEach(function(e){t.push(e.toObject())});var r={hash:this.hash,version:this.version,inputs:e,outputs:t,nLockTime:this.nLockTime};if(this.version>=2){var i=[];this.joinSplits.forEach(function(e){i.push(e.toObject())}),r.joinSplits=i,this.joinSplits.length>0&&(r.joinSplitPubKey=u.reverse(this.joinSplitPubKey).toString("hex"),r.joinSplitSig=this.joinSplitSig.toString("hex"))}return this._changeScript&&(r.changeScript=this._changeScript.toString()),n.isUndefined(this._changeIndex)||(r.changeIndex=this._changeIndex),n.isUndefined(this._fee)||(r.fee=this._fee),r},I.prototype.fromObject=function(e){i.checkArgument(n.isObject(e)||e instanceof I);var r,o=this;return r=e instanceof I?r.toObject():e,n.each(r.inputs,function(e){if(e.output&&e.output.script){var t,r=new k(e.output.script);if(r.isPublicKeyHashOut())t=new m.PublicKeyHash(e);else if(r.isScriptHashOut()&&e.publicKeys&&e.threshold)t=new m.MultiSigScriptHash(e,e.publicKeys,e.threshold,e.signatures);else{if(!r.isPublicKeyOut())throw new a.Transaction.Input.UnsupportedScript(e.output.script);t=new m.PublicKey(e)}o.addInput(t)}else o.uncheckedAddInput(new m(e))}),n.each(r.outputs,function(e){o.addOutput(new S(e))}),r.changeIndex&&(this._changeIndex=r.changeIndex),r.changeScript&&(this._changeScript=new k(r.changeScript)),r.fee&&(this._fee=r.fee),this.nLockTime=r.nLockTime,this.version=r.version,this.version>=2&&(n.each(r.joinSplits,function(e){o.joinSplits.push(new x(e))}),o.joinSplits.length>0&&(o.joinSplitPubKey=u.reverse(new t(r.joinSplitPubKey,"hex")),o.joinSplitSig=new t(r.joinSplitSig,"hex"))),this._checkConsistency(e),this},I.prototype._checkConsistency=function(e){n.isUndefined(this._changeIndex)||(i.checkState(this._changeScript),i.checkState(this.outputs[this._changeIndex]),i.checkState(this.outputs[this._changeIndex].script.toString()===this._changeScript.toString())),e&&e.hash&&i.checkState(e.hash===this.hash,"Hash in object does not match transaction hash")},I.prototype.lockUntilDate=function(e){if(i.checkArgument(e),n.isNumber(e)&&e=I.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new a.Transaction.BlockHeightTooHigh;if(e<0)throw new a.Transaction.NLockTimeOutOfRange;for(var t=0;t0?(this._changeIndex=this.outputs.length,this._addOutput(new S({script:this._changeScript,satoshis:e}))):this._changeIndex=void 0}},I.prototype.getFee=function(){return this.isCoinbase()?0:n.isUndefined(this._fee)?this._changeScript?this._estimateFee():this._getUnspentValue():this._fee},I.prototype._estimateFee=function(){var e=this._estimateSize(),t=this._getUnspentValue();return I._estimateFee(e,t,this._feePerKb)},I.prototype._getUnspentValue=function(){return this._getInputAmount()-this._getOutputAmount()},I.prototype._clearSignatures=function(){n.each(this.inputs,function(e){e.clearSignatures()})},I._estimateFee=function(e,t,r){return t>Math.ceil(e/1e3)*(r||I.FEE_PER_KB)&&(e+=I.CHANGE_OUTPUT_MAX_SIZE),Math.ceil(e/1e3)*(r||I.FEE_PER_KB)},I.prototype._estimateSize=function(){var e=I.MAXIMUM_EXTRA_SIZE;return n.each(this.inputs,function(t){e+=t._estimateSize()}),n.each(this.outputs,function(t){e+=t.script.toBuffer().length+9}),e},I.prototype._removeOutput=function(e){var t=this.outputs[e];this.outputs=n.without(this.outputs,t),this._outputAmount=void 0},I.prototype.removeOutput=function(e){this._removeOutput(e),this._updateChangeOutput()},I.prototype.sort=function(){return this.sortInputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(e,t){return s(e.prevTxId,t.prevTxId)||e.outputIndex-t.outputIndex}),t}),this.sortOutputs(function(e){var t=Array.prototype.concat.apply([],e);return t.sort(function(e,t){return e.satoshis-t.satoshis||s(e.script.toBuffer(),t.script.toBuffer())}),t}),this},I.prototype.shuffleOutputs=function(){return this.sortOutputs(n.shuffle)},I.prototype.sortOutputs=function(e){var t=e(this.outputs);return this._newOutputOrder(t)},I.prototype.sortInputs=function(e){return this.inputs=e(this.inputs),this._clearSignatures(),this},I.prototype._newOutputOrder=function(e){if(this.outputs.length!==e.length||0!==n.difference(this.outputs,e).length)throw new a.Transaction.InvalidSorting;if(!n.isUndefined(this._changeIndex)){var t=this.outputs[this._changeIndex];this._changeIndex=n.findIndex(e,t)}return this.outputs=e,this},I.prototype.removeInput=function(e,t){var r;if((r=!t&&n.isNumber(e)?e:n.findIndex(this.inputs,function(r){return r.prevTxId.toString("hex")===e&&r.outputIndex===t}))<0||r>=this.inputs.length)throw new a.Transaction.InvalidIndex(r,this.inputs.length);var i=this.inputs[r];this.inputs=n.without(this.inputs,i),this._inputAmount=void 0,this._updateChangeOutput()},I.prototype.sign=function(e,t){i.checkState(this.hasAllUtxoInfo());var r=this;return n.isArray(e)?(n.each(e,function(e){r.sign(e,t)}),this):(n.each(this.getSignatures(e,t),function(e){r.applySignature(e)}),this)},I.prototype.getSignatures=function(e,t){e=new E(e),t=t||p.SIGHASH_ALL;var r=this,i=[],o=h.sha256ripemd160(e.publicKey.toBuffer());return n.each(this.inputs,function(s,a){n.each(s.getSignatures(r,e,a,t,o),function(e){i.push(e)})}),i},I.prototype.applySignature=function(e){return this.inputs[e.inputIndex].addSignature(this,e),this},I.prototype.isFullySigned=function(){return n.each(this.inputs,function(e){if(e.isFullySigned===m.prototype.isFullySigned)throw new a.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction")}),n.all(n.map(this.inputs,function(e){return e.isFullySigned()}))},I.prototype.isValidSignature=function(e){if(this.inputs[e.inputIndex].isValidSignature===m.prototype.isValidSignature)throw new a.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction");return this.inputs[e.inputIndex].isValidSignature(this,e)},I.prototype.verifySignature=function(e,t,r,n){return d.verify(this,e,t,r,n)},I.prototype.verify=function(){if(0===this.inputs.length)return"transaction txins empty";if(0===this.outputs.length)return"transaction txouts empty";for(var e=new A(0),t=0;t1e6)return"transaction over the maximum block size";var i={};for(t=0;t100)return"coinbase transaction script size invalid"}else for(t=0;t=m.MAXINT-1&&(t.sequenceNumber=m.DEFAULT_RBF_SEQNUMBER)}return this},e.exports=I}).call(this,r(0).Buffer)},function(e,t,r){e.exports=r(130),e.exports.PublicKey=r(885),e.exports.PublicKeyHash=r(886),e.exports.MultiSig=r(887),e.exports.MultiSigScriptHash=r(888)},function(e,t,r){"use strict";var n=r(18),i=r(62),o=r(21),s={BTC:[1e8,8],mBTC:[1e5,5],uBTC:[100,2],bits:[100,2],satoshis:[1,0]};function a(e,t){if(!(this instanceof a))return new a(e,t);if(n.isNumber(t)){if(t<=0)throw new i.Unit.InvalidRate(t);e/=t,t=a.BTC}this._value=this._from(e,t);var r=this;Object.keys(s).forEach(function(e){Object.defineProperty(r,e,{get:function(){return r.to(e)},enumerable:!0})})}Object.keys(s).forEach(function(e){a[e]=e}),a.fromObject=function(e){return o.checkArgument(n.isObject(e),"Argument is expected to be an object"),new a(e.amount,e.code)},a.fromBTC=function(e){return new a(e,a.BTC)},a.fromMillis=a.fromMilis=function(e){return new a(e,a.mBTC)},a.fromMicros=a.fromBits=function(e){return new a(e,a.bits)},a.fromSatoshis=function(e){return new a(e,a.satoshis)},a.fromFiat=function(e,t){return new a(e,t)},a.prototype._from=function(e,t){if(!s[t])throw new i.Unit.UnknownCode(t);return parseInt((e*s[t][0]).toFixed())},a.prototype.to=function(e){if(n.isNumber(e)){if(e<=0)throw new i.Unit.InvalidRate(e);return parseFloat((this.BTC*e).toFixed(2))}if(!s[e])throw new i.Unit.UnknownCode(e);var t=this._value/s[e][0];return parseFloat(t.toFixed(s[e][1]))},a.prototype.toBTC=function(){return this.to(a.BTC)},a.prototype.toMillis=a.prototype.toMilis=function(){return this.to(a.mBTC)},a.prototype.toMicros=a.prototype.toBits=function(){return this.to(a.bits)},a.prototype.toSatoshis=function(){return this.to(a.satoshis)},a.prototype.atRate=function(e){return this.to(e)},a.prototype.toString=function(){return this.satoshis+" satoshis"},a.prototype.toObject=a.prototype.toJSON=function(){return{amount:this.BTC,code:a.BTC}},a.prototype.inspect=function(){return""},e.exports=a},function(e,t,r){"use strict";e.exports={_cache:{},_count:0,_eraseIndex:0,_usedList:{},_usedIndex:{},_CACHE_SIZE:5e3,get:function(e,t,r){var n=e+"/"+t+"/"+(r=!!r);if(this._cache[n])return this._cacheHit(n),this._cache[n]},set:function(e,t,r,n){var i=e+"/"+t+"/"+(r=!!r);this._cache[i]=n,this._cacheHit(i)},_cacheHit:function(e){this._usedIndex[e]&&delete this._usedList[this._usedIndex[e]],this._usedList[this._count]=e,this._usedIndex[e]=this._count,this._count++,this._cacheRemove()},_cacheRemove:function(){for(;this._eraseIndex{t(null,e)},e=>{t(e)})}},function(e,t,r){"use strict";e.exports=(()=>{if("undefined"!=typeof self&&(r(65)(self),self.crypto))return self.crypto;throw new Error("Please use an environment with crypto support")})},function(e,t,r){"use strict";e.exports="enum KeyType {\n RSA = 0;\n Ed25519 = 1;\n Secp256k1 = 2;\n}\nmessage PublicKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}\nmessage PrivateKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}"},function(e,t,r){var n=r(13);r(19),e.exports=n.cipher=n.cipher||{},n.cipher.algorithms=n.cipher.algorithms||{},n.cipher.createCipher=function(e,t){var r=e;if("string"==typeof r&&(r=n.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+e);return new n.cipher.BlockCipher({algorithm:r,key:t,decrypt:!1})},n.cipher.createDecipher=function(e,t){var r=e;if("string"==typeof r&&(r=n.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+e);return new n.cipher.BlockCipher({algorithm:r,key:t,decrypt:!0})},n.cipher.registerAlgorithm=function(e,t){e=e.toUpperCase(),n.cipher.algorithms[e]=t},n.cipher.getAlgorithm=function(e){return(e=e.toUpperCase())in n.cipher.algorithms?n.cipher.algorithms[e]:null};var i=n.cipher.BlockCipher=function(e){this.algorithm=e.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=e.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=e.decrypt,this.algorithm.initialize(e)};i.prototype.start=function(e){e=e||{};var t={};for(var r in e)t[r]=e[r];t.decrypt=this._decrypt,this._finish=!1,this._input=n.util.createBuffer(),this.output=e.output||n.util.createBuffer(),this.mode.start(t)},i.prototype.update=function(e){for(e&&this._input.putBuffer(e);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},i.prototype.finish=function(e){!e||"ECB"!==this.mode.name&&"CBC"!==this.mode.name||(this.mode.pad=function(t){return e(this.blockSize,t,!1)},this.mode.unpad=function(t){return e(this.blockSize,t,!0)});var t={};return t.decrypt=this._decrypt,t.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,t)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,t)||this.mode.afterFinish&&!this.mode.afterFinish(this.output,t)))}},function(e,t,r){var n=r(13);r(77),r(19);var i=e.exports=n.md5=n.md5||{};n.md.md5=n.md.algorithms.md5=i,i.create=function(){c||function(){o=String.fromCharCode(128),o+=n.util.fillString(String.fromCharCode(0),64),s=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12,5,8,11,14,1,4,7,10,13,0,3,6,9,12,15,2,0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9],a=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],u=new Array(64);for(var e=0;e<64;++e)u[e]=Math.floor(4294967296*Math.abs(Math.sin(e+1)));c=!0}();var e=null,t=n.util.createBuffer(),r=new Array(16),i={algorithm:"md5",blockLength:64,digestLength:16,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){i.messageLength=0,i.fullMessageLength=i.messageLength64=[];for(var r=i.messageLengthSize/4,o=0;o>>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),f(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=i.fullMessageLength[i.fullMessageLength.length-1]+i.messageLengthSize&i.blockLength-1;s.putBytes(o.substr(0,i.blockLength-a));for(var u,c=0,l=i.fullMessageLength.length-1;l>=0;--l)c=(u=8*i.fullMessageLength[l]+c)/4294967296>>>0,s.putInt32Le(u>>>0);var h={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3};f(h,r,s);var p=n.util.createBuffer();return p.putInt32Le(h.h0),p.putInt32Le(h.h1),p.putInt32Le(h.h2),p.putInt32Le(h.h3),p},i};var o=null,s=null,a=null,u=null,c=!1;function f(e,t,r){for(var n,i,o,c,f,l,h,p=r.length();p>=64;){for(i=e.h0,o=e.h1,c=e.h2,f=e.h3,h=0;h<16;++h)t[h]=r.getInt32Le(),n=i+(f^o&(c^f))+u[h]+t[h],i=f,f=c,c=o,o+=n<<(l=a[h])|n>>>32-l;for(;h<32;++h)n=i+(c^f&(o^c))+u[h]+t[s[h]],i=f,f=c,c=o,o+=n<<(l=a[h])|n>>>32-l;for(;h<48;++h)n=i+(o^c^f)+u[h]+t[s[h]],i=f,f=c,c=o,o+=n<<(l=a[h])|n>>>32-l;for(;h<64;++h)n=i+(c^(o|~f))+u[h]+t[s[h]],i=f,f=c,c=o,o+=n<<(l=a[h])|n>>>32-l;e.h0=e.h0+i|0,e.h1=e.h1+o|0,e.h2=e.h2+c|0,e.h3=e.h3+f|0,p-=64}}},function(e,t,r){(function(t){var n=r(13);r(133),r(77),r(19);var i,o=n.pkcs5=n.pkcs5||{};n.util.isNodejs&&!n.options.usePureJavaScript&&(i=r(447)),e.exports=n.pbkdf2=o.pbkdf2=function(e,r,o,s,a,u){if("function"==typeof a&&(u=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=new t(e,"binary"),r=new t(r,"binary"),u?4===i.pbkdf2Sync.length?i.pbkdf2(e,r,o,s,function(e,t){if(e)return u(e);u(null,t.toString("binary"))}):i.pbkdf2(e,r,o,s,a,function(e,t){if(e)return u(e);u(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(void 0!==a&&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 c=a.digestLength;if(s>4294967295*c){var f=new Error("Derived key is too long.");if(u)return u(f);throw f}var l=Math.ceil(s/c),h=s-(l-1)*c,p=n.hmac.create();p.start(a,e);var d,y,g,m="";if(!u){for(var b=1;b<=l;++b){p.start(null,null),p.update(r),p.update(n.util.int32ToBytes(b)),d=g=p.digest().getBytes();for(var v=2;v<=o;++v)p.start(null,null),p.update(g),y=p.digest().getBytes(),d=n.util.xorBytes(d,y,c),g=y;m+=bl)return u(null,m);p.start(null,null),p.update(r),p.update(n.util.int32ToBytes(b)),d=g=p.digest().getBytes(),v=2,w()}function w(){if(v<=o)return p.start(null,null),p.update(g),y=p.digest().getBytes(),d=n.util.xorBytes(d,y,c),g=y,++v,n.util.setImmediate(w);m+=b2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(l.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(u.validity.notBefore=l[0],u.validity.notAfter=l[1],u.tbsCertificate=r.tbsCertificate,t){var h;if(u.md=null,u.signatureOid in s)switch(s[u.signatureOid]){case"sha1WithRSAEncryption":u.md=n.md.sha1.create();break;case"md5WithRSAEncryption":u.md=n.md.md5.create();break;case"sha256WithRSAEncryption":u.md=n.md.sha256.create();break;case"sha384WithRSAEncryption":u.md=n.md.sha384.create();break;case"sha512WithRSAEncryption":u.md=n.md.sha512.create();break;case"RSASSA-PSS":u.md=n.md.sha256.create()}if(null===u.md)throw(h=new Error("Could not compute certificate digest. Unknown signature OID.")).signatureOid=u.signatureOid,h;var y=i.toDer(u.tbsCertificate);u.md.update(y.getBytes())}var m=n.md.sha1.create();u.issuer.getField=function(e){return p(u.issuer,e)},u.issuer.addField=function(e){g([e]),u.issuer.attributes.push(e)},u.issuer.attributes=o.RDNAttributesAsArray(r.certIssuer,m),r.certIssuerUniqueId&&(u.issuer.uniqueId=r.certIssuerUniqueId),u.issuer.hash=m.digest().toHex();var b=n.md.sha1.create();return u.subject.getField=function(e){return p(u.subject,e)},u.subject.addField=function(e){g([e]),u.subject.attributes.push(e)},u.subject.attributes=o.RDNAttributesAsArray(r.certSubject,b),r.certSubjectUniqueId&&(u.subject.uniqueId=r.certSubjectUniqueId),u.subject.hash=b.digest().toHex(),r.certExtensions?u.extensions=o.certificateExtensionsFromAsn1(r.certExtensions):u.extensions=[],u.publicKey=o.publicKeyFromAsn1(r.subjectPublicKeyInfo),u},o.certificateExtensionsFromAsn1=function(e){for(var t=[],r=0;r1&&(r=u.value.charCodeAt(1),o=u.value.length>2?u.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){(u=i.fromDer(t.value)).value.length>0&&u.value[0].type===i.Type.BOOLEAN?t.cA=0!==u.value[0].value.charCodeAt(0):t.cA=!1;var a=null;u.value.length>0&&u.value[0].type===i.Type.INTEGER?a=u.value[0].value:u.value.length>1&&(a=u.value[1].value),null!==a&&(t.pathLenConstraint=i.derToInteger(a))}else if("extKeyUsage"===t.name)for(var u=i.fromDer(t.value),c=0;c1&&(r=u.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 l;t.altNames=[];u=i.fromDer(t.value);for(var h=0;h0&&t.value.push(o.certificateExtensionsToAsn1(e.extensions)),t},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),function(e){var t=i.create(i.Class.CONTEXT_SPECIFIC,0,!0,[]);if(0===e.attributes.length)return t;for(var r=e.attributes,o=0;of.validity.notAfter)&&(u={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===u){if(null===(l=t[0]||e.getIssuer(f))&&f.isIssuer(f)&&(h=!0,l=f),l){var p=l;n.util.isArray(p)||(p=[p]);for(var d=!1;!d&&p.length>0;){l=p.shift();try{d=l.verify(f)}catch(e){}}d||(u={message:"Certificate signature is invalid.",error:o.certificateError.bad_certificate})}null!==u||l&&!h||e.hasCertificate(f)||(u={message:"Certificate is not trusted.",error:o.certificateError.unknown_ca})}if(null===u&&l&&!f.isIssuer(l)&&(u={message:"Certificate issuer is invalid.",error:o.certificateError.bad_certificate}),null===u)for(var y={keyUsage:!0,basicConstraints:!0},g=0;null===u&&gb.pathLenConstraint&&(u={message:"Certificate basicConstraints pathLenConstraint violated.",error:o.certificateError.bad_certificate})}var _=null===u||u.error,w=r?r(_,c,i):_;if(!0!==w)throw!0===_&&(u={message:"The application rejected the certificate.",error:o.certificateError.bad_certificate}),(w||0===w)&&("object"!=typeof w||n.util.isArray(w)?"string"==typeof w&&(u.error=w):(w.message&&(u.message=w.message),w.error&&(u.error=w.error))),u;u=null,a=!1,++c}while(t.length>0);return!0}},function(e,t,r){var n=r(13);r(67),r(19),(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;return{encode:function(e,u){var c,f,l=u-1,h=Math.ceil(l/8),p=e.digest().getBytes();if(h>8*h-l&255;return(_=String.fromCharCode(_.charCodeAt(0)&~w)+_.substr(1))+y+String.fromCharCode(188)},verify:function(e,s,a){var u,c=a-1,f=Math.ceil(c/8);if(s=s.substr(-f),f>8*f-c&255;if(0!=(h.charCodeAt(0)&d))throw new Error("Bits beyond keysize not zero as expected.");var y=i.generate(p,l),g="";for(u=0;u{t(null,e)},e=>{t(e)})}},function(e,t,r){"use strict";e.exports=(()=>{if("undefined"!=typeof self&&(r(65)(self),self.crypto))return self.crypto;throw new Error("Please use an environment with crypto support")})},function(e,t,r){"use strict";e.exports="enum KeyType {\n RSA = 0;\n Ed25519 = 1;\n Secp256k1 = 2;\n}\nmessage PublicKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}\nmessage PrivateKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}"},function(e,t){t.BITS=32,t.GROUPS=4,t.RE_ADDRESS=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/g,t.RE_SUBNET_STRING=/\/\d{1,2}$/},function(e,t){t.BITS=128,t.GROUPS=8,t.SCOPES={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"},t.TYPES={"ff01::1/128":"Multicast (All nodes on this interface)","ff01::2/128":"Multicast (All routers on this interface)","ff02::1/128":"Multicast (All nodes on this link)","ff02::2/128":"Multicast (All routers on this link)","ff05::2/128":"Multicast (All routers in this site)","ff02::5/128":"Multicast (OSPFv3 AllSPF routers)","ff02::6/128":"Multicast (OSPFv3 AllDR routers)","ff02::9/128":"Multicast (RIP routers)","ff02::a/128":"Multicast (EIGRP routers)","ff02::d/128":"Multicast (PIM routers)","ff02::16/128":"Multicast (MLDv2 reports)","ff01::fb/128":"Multicast (mDNSv6)","ff02::fb/128":"Multicast (mDNSv6)","ff05::fb/128":"Multicast (mDNSv6)","ff02::1:2/128":"Multicast (All DHCP servers and relay agents on this link)","ff05::1:2/128":"Multicast (All DHCP servers and relay agents in this site)","ff02::1:3/128":"Multicast (All DHCP servers on this link)","ff05::1:3/128":"Multicast (All DHCP servers in this site)","::/128":"Unspecified","::1/128":"Loopback","ff00::/8":"Multicast","fe80::/10":"Link-local unicast"},t.RE_BAD_CHARACTERS=/([^0-9a-f:\/%])/gi,t.RE_BAD_ADDRESS=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi,t.RE_SUBNET_STRING=/\/\d{1,3}(?=%|$)/,t.RE_ZONE_STRING=/%.*$/,t.RE_URL=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/),t.RE_URL_WITH_PORT=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/)},function(e,t,r){"use strict";const n=r(39);function i(e){if("number"==typeof e){if(i.codes[e])return i.codes[e];throw new Error("no protocol with code: "+e)}if("string"==typeof e||e instanceof String){if(i.names[e])return i.names[e];throw new Error("no protocol with name: "+e)}throw new Error("invalid protocol id type: "+e)}function o(e,t,r,n){return{code:e,size:t,name:r,resolvable:Boolean(n)}}i.lengthPrefixedVarSize=-1,i.V=-1,i.table=[[4,32,"ip4"],[6,16,"tcp"],[17,16,"udp"],[33,16,"dccp"],[41,128,"ip6"],[54,-1,"dns4","resolvable"],[55,-1,"dns6","resolvable"],[56,-1,"dnsaddr","resolvable"],[132,16,"sctp"],[302,0,"utp"],[421,i.lengthPrefixedVarSize,"ipfs"],[480,0,"http"],[443,0,"https"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[290,0,"p2p-circuit"]],i.names={},i.codes={},n(i.table,function(e){const t=o.apply(null,e);i.codes[t.code]=t,i.names[t.name]=t}),i.object=o,e.exports=i},function(e,t,r){"use strict";const n=r(39);function i(e){if("number"==typeof e){if(i.codes[e])return i.codes[e];throw new Error("no protocol with code: "+e)}if("string"==typeof e||e instanceof String){if(i.names[e])return i.names[e];throw new Error("no protocol with name: "+e)}throw new Error("invalid protocol id type: "+e)}function o(e,t,r,n){return{code:e,size:t,name:r,resolvable:Boolean(n)}}i.lengthPrefixedVarSize=-1,i.V=-1,i.table=[[4,32,"ip4"],[6,16,"tcp"],[17,16,"udp"],[33,16,"dccp"],[41,128,"ip6"],[54,-1,"dns4","resolvable"],[55,-1,"dns6","resolvable"],[56,-1,"dnsaddr","resolvable"],[132,16,"sctp"],[302,0,"utp"],[421,i.lengthPrefixedVarSize,"ipfs"],[480,0,"http"],[443,0,"https"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[290,0,"p2p-circuit"]],i.names={},i.codes={},n(i.table,function(e){const t=o.apply(null,e);i.codes[t.code]=t,i.names[t.name]=t}),i.object=o,e.exports=i},function(e,t,r){"use strict";e.exports=function(e,t){return e.then(e=>{t(null,e)},e=>{t(e)})}},function(e,t,r){"use strict";e.exports=(()=>{if("undefined"!=typeof self&&(r(65)(self),self.crypto))return self.crypto;throw new Error("Please use an environment with crypto support")})},function(e,t,r){"use strict";e.exports="enum KeyType {\n RSA = 0;\n Ed25519 = 1;\n Secp256k1 = 2;\n}\nmessage PublicKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}\nmessage PrivateKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}"},function(e,t,r){"use strict";(function(t){ /*! * @description Recursive object extending * @author Viacheslav Lotsmanov @@ -103,31 +103,31 @@ e.exports=function(e){"use strict";if("function"!=typeof Promise)throw"Promise s * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -function r(e){return e instanceof t||e instanceof Date||e instanceof RegExp}function n(e){if(e instanceof t){var r=t.alloc?t.alloc(e.length):new t(e.length);return e.copy(r),r}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e);throw new Error("Unexpected situation")}function i(e,t){return"__proto__"===t?void 0:e[t]}var o=e.exports=function(){if(arguments.length<1||"object"!=typeof arguments[0])return!1;if(arguments.length<2)return arguments[0];var e,t,s=arguments[0];return Array.prototype.slice.call(arguments,1).forEach(function(a){"object"!=typeof a||null===a||Array.isArray(a)||Object.keys(a).forEach(function(u){return t=i(s,u),(e=i(a,u))===s?void 0:"object"!=typeof e||null===e?void(s[u]=e):Array.isArray(e)?void(s[u]=function e(t){var i=[];return t.forEach(function(t,s){"object"==typeof t&&null!==t?Array.isArray(t)?i[s]=e(t):r(t)?i[s]=n(t):i[s]=o({},t):i[s]=t}),i}(e)):r(e)?void(s[u]=n(e)):"object"!=typeof t||null===t||Array.isArray(t)?void(s[u]=o({},e)):void(s[u]=o(t,e))})}),s}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(44);function i(e){if("number"==typeof e){if(i.codes[e])return i.codes[e];throw new Error("no protocol with code: "+e)}if("string"==typeof e||e instanceof String){if(i.names[e])return i.names[e];throw new Error("no protocol with name: "+e)}throw new Error("invalid protocol id type: "+e)}function o(e,t,r,n){return{code:e,size:t,name:r,resolvable:Boolean(n)}}i.lengthPrefixedVarSize=-1,i.V=-1,i.table=[[4,32,"ip4"],[6,16,"tcp"],[17,16,"udp"],[33,16,"dccp"],[41,128,"ip6"],[54,-1,"dns4","resolvable"],[55,-1,"dns6","resolvable"],[56,-1,"dnsaddr","resolvable"],[132,16,"sctp"],[302,0,"utp"],[421,i.lengthPrefixedVarSize,"ipfs"],[480,0,"http"],[443,0,"https"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[290,0,"p2p-circuit"]],i.names={},i.codes={},n(i.table,function(e){const t=o.apply(null,e);i.codes[t.code]=t,i.names[t.name]=t}),i.object=o,e.exports=i},function(e,t,r){"use strict";const n=r(44);function i(e){if("number"==typeof e){if(i.codes[e])return i.codes[e];throw new Error("no protocol with code: "+e)}if("string"==typeof e||e instanceof String){if(i.names[e])return i.names[e];throw new Error("no protocol with name: "+e)}throw new Error("invalid protocol id type: "+e)}function o(e,t,r,n){return{code:e,size:t,name:r,resolvable:Boolean(n)}}i.lengthPrefixedVarSize=-1,i.V=-1,i.table=[[4,32,"ip4"],[6,16,"tcp"],[17,16,"udp"],[33,16,"dccp"],[41,128,"ip6"],[54,-1,"dns4","resolvable"],[55,-1,"dns6","resolvable"],[56,-1,"dnsaddr","resolvable"],[132,16,"sctp"],[302,0,"utp"],[421,i.lengthPrefixedVarSize,"ipfs"],[480,0,"http"],[443,0,"https"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[290,0,"p2p-circuit"]],i.names={},i.codes={},n(i.table,function(e){const t=o.apply(null,e);i.codes[t.code]=t,i.names[t.name]=t}),i.object=o,e.exports=i},function(e,t,r){"use strict";e.exports=function(e,t){return e.then(e=>{t(null,e)},e=>{t(e)})}},function(e,t,r){"use strict";e.exports=(()=>{if("undefined"!=typeof self&&(r(58)(self),self.crypto))return self.crypto;throw new Error("Please use an environment with crypto support")})},function(e,t,r){"use strict";e.exports="enum KeyType {\n RSA = 0;\n Ed25519 = 1;\n Secp256k1 = 2;\n}\nmessage PublicKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}\nmessage PrivateKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}"},function(e,t,r){(function(e,r,n){!function(e,r){r(t)}(0,function(t){"use strict";function i(e,t){t|=0;for(var r=Math.max(e.length-t,0),n=Array(r),i=0;i-1&&e%1==0&&e<=j}function D(e){return null!=e&&M(e.length)&&!function(e){if(!a(e))return!1;var t=O(e);return t==N||t==L||t==R||t==K}(e)}var U={};function F(){}function q(e){return function(){if(null!==e){var t=e;e=null,t.apply(this,arguments)}}}var H="function"==typeof Symbol&&Symbol.iterator,z=function(e){return H&&e[H]&&e[H]()};function V(e){return null!=e&&"object"==typeof e}var G="[object Arguments]";function W(e){return V(e)&&O(e)==G}var $=Object.prototype,Y=$.hasOwnProperty,J=$.propertyIsEnumerable,X=W(function(){return arguments}())?W:function(e){return V(e)&&Y.call(e,"callee")&&!J.call(e,"callee")},Z=Array.isArray;var Q="object"==typeof t&&t&&!t.nodeType&&t,ee=Q&&"object"==typeof n&&n&&!n.nodeType&&n,te=ee&&ee.exports===Q?S.Buffer:void 0,re=(te?te.isBuffer:void 0)||function(){return!1},ne=9007199254740991,ie=/^(?:0|[1-9]\d*)$/;function oe(e,t){var r=typeof e;return!!(t=null==t?ne:t)&&("number"==r||"symbol"!=r&&ie.test(e))&&e>-1&&e%1==0&&e2&&(n=i(arguments,1)),t){var c={};je(o,function(e,t){c[t]=e}),c[e]=n,a=!0,u=Object.create(null),r(t,c)}else o[e]=n,function(e){Le(u[e]||[],function(e){e()}),p()}(e)});s++;var c=b(t[t.length-1]);t.length>1?c(o,n):c(n)}}(e,t)})}function p(){if(0===c.length&&0===s)return r(null,o);for(;c.length&&s=0&&r.push(n)}),r}je(e,function(t,r){if(!Z(t))return h(r,[t]),void f.push(r);var n=t.slice(0,t.length-1),i=n.length;if(0===i)return h(r,t),void f.push(r);l[r]=i,Le(n,function(o){if(!e[o])throw new Error("async.auto task `"+r+"` has a non-existent dependency `"+o+"` in "+n.join(", "));!function(e,t){var r=u[e];r||(r=u[e]=[]),r.push(t)}(o,function(){0==--i&&h(r,t)})})}),function(){for(var e=0;f.length;)e++,Le(d(f.pop()),function(e){0==--l[e]&&f.push(e)});if(e!==n)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}(),p()};function Fe(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r=n?e:function(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Array(i);++n-1;);return r}(n,i),function(e,t){for(var r=e.length;r--&&De(t,e[r],0)>-1;);return r}(n,i)+1).join("")}var ut=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,ct=/,/,ft=/(=.+)?(\s*)$/,lt=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;function ht(e,t){var r={};je(e,function(e,t){var n,i=m(e),o=!i&&1===e.length||i&&0===e.length;if(Z(e))n=e.slice(0,-1),e=e[e.length-1],r[t]=n.concat(n.length>0?s:e);else if(o)r[t]=e;else{if(n=function(e){return(e=(e=(e=e.toString().replace(lt,"")).match(ut)[2].replace(" ",""))?e.split(ct):[]).map(function(e){return at(e.replace(ft,""))})}(e),0===e.length&&!i&&0===n.length)throw new Error("autoInject task functions require explicit parameters.");i||n.pop(),r[t]=n.concat(s)}function s(t,r){var i=Fe(n,function(e){return t[e]});i.push(r),b(e).apply(null,i)}}),Ue(r,t)}function pt(){this.head=this.tail=null,this.length=0}function dt(e,t){e.length=1,e.head=e.tail=t}function yt(e,t,r){if(null==t)t=1;else if(0===t)throw new Error("Concurrency must not be zero");var n=b(e),i=0,o=[],s=!1;function a(e,t,r){if(null!=r&&"function"!=typeof r)throw new Error("task callback must be a function");if(f.started=!0,Z(e)||(e=[e]),0===e.length&&f.idle())return h(function(){f.drain()});for(var n=0,i=e.length;n0&&o.splice(a,1),s.callback.apply(s,arguments),null!=t&&f.error(t,s.data)}i<=f.concurrency-f.buffer&&f.unsaturated(),f.idle()&&f.drain(),f.process()}}var c=!1,f={_tasks:new pt,concurrency:t,payload:r,saturated:F,unsaturated:F,buffer:t/4,empty:F,drain:F,error:F,started:!1,paused:!1,push:function(e,t){a(e,!1,t)},kill:function(){f.drain=F,f._tasks.empty()},unshift:function(e,t){a(e,!0,t)},remove:function(e){f._tasks.remove(e)},process:function(){if(!c){for(c=!0;!f.paused&&i2&&(o=i(arguments,1)),n[t]=o,r(e)})},function(e){r(e,n)})}function fr(e,t){cr(xe,e,t)}function lr(e,t,r){cr(Se(t),e,r)}var hr=function(e,t){var r=b(e);return yt(function(e,t){r(e[0],t)},t,1)},pr=function(e,t){var r=hr(e,t);return r.push=function(e,t,n){if(null==n&&(n=F),"function"!=typeof n)throw new Error("task callback must be a function");if(r.started=!0,Z(e)||(e=[e]),0===e.length)return h(function(){r.drain()});t=t||0;for(var i=r._tasks.head;i&&t>=i.priority;)i=i.next;for(var o=0,s=e.length;on?1:0}Be(e,function(e,t){n(e,function(r,n){if(r)return t(r);t(null,{value:e,criteria:n})})},function(e,t){if(e)return r(e);r(null,Fe(t.sort(i),Wt("value")))})}function Cr(e,t,r){var n=b(e);return s(function(i,o){var s,a=!1;i.push(function(){a||(o.apply(null,arguments),clearTimeout(s))}),s=setTimeout(function(){var t=e.name||"anonymous",n=new Error('Callback function "'+t+'" timed out.');n.code="ETIMEDOUT",r&&(n.info=r),a=!0,o(n)},t),n.apply(null,i)})}var Pr=Math.ceil,Or=Math.max;function Rr(e,t,r,n){var i=b(r);Oe(function(e,t,r,n){for(var i=-1,o=Or(Pr((t-e)/(r||1)),0),s=Array(o);o--;)s[n?o:++i]=e,e+=r;return s}(0,e,1),t,i,n)}var Nr=Ee(Rr,1/0),Lr=Ee(Rr,1);function Kr(e,t,r,n){arguments.length<=3&&(n=r,r=t,t=Z(e)?[]:{}),n=q(n||F);var i=b(r);xe(e,function(e,r,n){i(t,e,r,n)},function(e){n(e,t)})}function jr(e,t){var r,n=null;t=t||F,Ft(e,function(e,t){b(e)(function(e,o){r=arguments.length>2?i(arguments,1):o,n=e,t(!e)})},function(){t(n,r)})}function Mr(e){return function(){return(e.unmemoized||e).apply(null,arguments)}}function Dr(e,t,r){r=we(r||F);var n=b(t);if(!e())return r(null);var o=function(t){if(t)return r(t);if(e())return n(o);var s=i(arguments,1);r.apply(null,[null].concat(s))};n(o)}function Ur(e,t,r){Dr(function(){return!e.apply(this,arguments)},t,r)}var Fr=function(e,t){if(t=q(t||F),!Z(e))return t(new Error("First argument to waterfall must be an array of functions"));if(!e.length)return t();var r=0;function n(t){var n=b(e[r++]);t.push(we(o)),n.apply(null,t)}function o(o){if(o||r===e.length)return t.apply(null,arguments);n(i(arguments,1))}n([])},qr={apply:o,applyEach:Ce,applyEachSeries:Ne,asyncify:p,auto:Ue,autoInject:ht,cargo:gt,compose:_t,concat:kt,concatLimit:St,concatSeries:Et,constant:At,detect:Bt,detectLimit:Ct,detectSeries:Pt,dir:Rt,doDuring:Nt,doUntil:Kt,doWhilst:Lt,during:jt,each:Dt,eachLimit:Ut,eachOf:xe,eachOfLimit:ke,eachOfSeries:mt,eachSeries:Ft,ensureAsync:qt,every:zt,everyLimit:Vt,everySeries:Gt,filter:Yt,filterLimit:Jt,filterSeries:Xt,forever:Zt,groupBy:er,groupByLimit:Qt,groupBySeries:tr,log:rr,map:Be,mapLimit:Oe,mapSeries:Re,mapValues:ir,mapValuesLimit:nr,mapValuesSeries:or,memoize:ar,nextTick:ur,parallel:fr,parallelLimit:lr,priorityQueue:pr,queue:hr,race:dr,reduce:bt,reduceRight:yr,reflect:gr,reflectAll:mr,reject:vr,rejectLimit:_r,rejectSeries:wr,retry:kr,retryable:Er,seq:vt,series:Ar,setImmediate:h,some:xr,someLimit:Ir,someSeries:Tr,sortBy:Br,timeout:Cr,times:Nr,timesLimit:Rr,timesSeries:Lr,transform:Kr,tryEach:jr,unmemoize:Mr,until:Ur,waterfall:Fr,whilst:Dr,all:zt,allLimit:Vt,allSeries:Gt,any:xr,anyLimit:Ir,anySeries:Tr,find:Bt,findLimit:Ct,findSeries:Pt,forEach:Dt,forEachSeries:Ft,forEachLimit:Ut,forEachOf:xe,forEachOfSeries:mt,forEachOfLimit:ke,inject:bt,foldl:bt,foldr:yr,select:Yt,selectLimit:Jt,selectSeries:Xt,wrapSync:p};t.default=qr,t.apply=o,t.applyEach=Ce,t.applyEachSeries=Ne,t.asyncify=p,t.auto=Ue,t.autoInject=ht,t.cargo=gt,t.compose=_t,t.concat=kt,t.concatLimit=St,t.concatSeries=Et,t.constant=At,t.detect=Bt,t.detectLimit=Ct,t.detectSeries=Pt,t.dir=Rt,t.doDuring=Nt,t.doUntil=Kt,t.doWhilst=Lt,t.during=jt,t.each=Dt,t.eachLimit=Ut,t.eachOf=xe,t.eachOfLimit=ke,t.eachOfSeries=mt,t.eachSeries=Ft,t.ensureAsync=qt,t.every=zt,t.everyLimit=Vt,t.everySeries=Gt,t.filter=Yt,t.filterLimit=Jt,t.filterSeries=Xt,t.forever=Zt,t.groupBy=er,t.groupByLimit=Qt,t.groupBySeries=tr,t.log=rr,t.map=Be,t.mapLimit=Oe,t.mapSeries=Re,t.mapValues=ir,t.mapValuesLimit=nr,t.mapValuesSeries=or,t.memoize=ar,t.nextTick=ur,t.parallel=fr,t.parallelLimit=lr,t.priorityQueue=pr,t.queue=hr,t.race=dr,t.reduce=bt,t.reduceRight=yr,t.reflect=gr,t.reflectAll=mr,t.reject=vr,t.rejectLimit=_r,t.rejectSeries=wr,t.retry=kr,t.retryable=Er,t.seq=vt,t.series=Ar,t.setImmediate=h,t.some=xr,t.someLimit=Ir,t.someSeries=Tr,t.sortBy=Br,t.timeout=Cr,t.times=Nr,t.timesLimit=Rr,t.timesSeries=Lr,t.transform=Kr,t.tryEach=jr,t.unmemoize=Mr,t.until=Ur,t.waterfall=Fr,t.whilst=Dr,t.all=zt,t.allLimit=Vt,t.allSeries=Gt,t.any=xr,t.anyLimit=Ir,t.anySeries=Tr,t.find=Bt,t.findLimit=Ct,t.findSeries=Pt,t.forEach=Dt,t.forEachSeries=Ft,t.forEachLimit=Ut,t.forEachOf=xe,t.forEachOfSeries=mt,t.forEachOfLimit=ke,t.inject=bt,t.foldl=bt,t.foldr=yr,t.select=Yt,t.selectLimit=Jt,t.selectSeries=Xt,t.wrapSync=p,Object.defineProperty(t,"__esModule",{value:!0})})}).call(this,r(7),r(6),r(27)(e))},function(e,t,r){"use strict";e.exports={maxProvidersPerRequest:3,providerRequestTimeout:1e4,hasBlockTimeout:15e3,provideTimeout:15e3,kMaxPriority:Math.pow(2,31)-1,rebroadcastDelay:1e4,maxListeners:1e3}},function(e,t,r){var n=r(1)("socket.io-parser"),i=r(114),o=r(1096),s=r(515),a=r(516);function u(){}t.protocol=4,t.types=["CONNECT","DISCONNECT","EVENT","ACK","ERROR","BINARY_EVENT","BINARY_ACK"],t.CONNECT=0,t.DISCONNECT=1,t.EVENT=2,t.ACK=3,t.ERROR=4,t.BINARY_EVENT=5,t.BINARY_ACK=6,t.Encoder=u,t.Decoder=l;var c=t.ERROR+'"encode error"';function f(e){var r=""+e.type;if(t.BINARY_EVENT!==e.type&&t.BINARY_ACK!==e.type||(r+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(r+=e.nsp+","),null!=e.id&&(r+=e.id),null!=e.data){var i=function(e){try{return JSON.stringify(e)}catch(e){return!1}}(e.data);if(!1===i)return c;r+=i}return n("encoded %j as %s",e,r),r}function l(){this.reconstructor=null}function h(e){var r=0,i={type:Number(e.charAt(0))};if(null==t.types[i.type])return d("unknown packet type "+i.type);if(t.BINARY_EVENT===i.type||t.BINARY_ACK===i.type){for(var o="";"-"!==e.charAt(++r)&&(o+=e.charAt(r),r!=e.length););if(o!=Number(o)||"-"!==e.charAt(r))throw new Error("Illegal attachments");i.attachments=Number(o)}if("/"===e.charAt(r+1))for(i.nsp="";++r;){if(","===(u=e.charAt(r)))break;if(i.nsp+=u,r===e.length)break}else i.nsp="/";var a=e.charAt(r+1);if(""!==a&&Number(a)==a){for(i.id="";++r;){var u;if(null==(u=e.charAt(r))||Number(u)!=u){--r;break}if(i.id+=e.charAt(r),r===e.length)break}i.id=Number(i.id)}if(e.charAt(++r)){var c=function(e){try{return JSON.parse(e)}catch(e){return!1}}(e.substr(r));if(!1===c||i.type!==t.ERROR&&!s(c))return d("invalid payload");i.data=c}return n("decoded %s as %j",e,i),i}function p(e){this.reconPack=e,this.buffers=[]}function d(e){return{type:t.ERROR,data:"parser error: "+e}}u.prototype.encode=function(e,r){n("encoding packet %j",e),t.BINARY_EVENT===e.type||t.BINARY_ACK===e.type?function(e,t){o.removeBlobs(e,function(e){var r=o.deconstructPacket(e),n=f(r.packet),i=r.buffers;i.unshift(n),t(i)})}(e,r):r([f(e)])},i(l.prototype),l.prototype.add=function(e){var r;if("string"==typeof e)r=h(e),t.BINARY_EVENT===r.type||t.BINARY_ACK===r.type?(this.reconstructor=new p(r),0===this.reconstructor.reconPack.attachments&&this.emit("decoded",r)):this.emit("decoded",r);else{if(!a(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");(r=this.reconstructor.takeBinaryData(e))&&(this.reconstructor=null,this.emit("decoded",r))}},l.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},p.prototype.takeBinaryData=function(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){var t=o.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null},p.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]}},function(e,t,r){(function(t){var n=r(1099);e.exports=function(e){var r=e.xdomain,i=e.xscheme,o=e.enablesXDR;try{if("undefined"!=typeof XMLHttpRequest&&(!r||n))return new XMLHttpRequest}catch(e){}try{if("undefined"!=typeof XDomainRequest&&!i&&o)return new XDomainRequest}catch(e){}if(!r)try{return new(t[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}}).call(this,r(6))},function(e,t,r){var n=r(115),i=r(114);function o(e){this.path=e.path,this.hostname=e.hostname,this.port=e.port,this.secure=e.secure,this.query=e.query,this.timestampParam=e.timestampParam,this.timestampRequests=e.timestampRequests,this.readyState="",this.agent=e.agent||!1,this.socket=e.socket,this.enablesXDR=e.enablesXDR,this.pfx=e.pfx,this.key=e.key,this.passphrase=e.passphrase,this.cert=e.cert,this.ca=e.ca,this.ciphers=e.ciphers,this.rejectUnauthorized=e.rejectUnauthorized,this.forceNode=e.forceNode,this.extraHeaders=e.extraHeaders,this.localAddress=e.localAddress}e.exports=o,i(o.prototype),o.prototype.onError=function(e,t){var r=new Error(e);return r.type="TransportError",r.description=t,this.emit("error",r),this},o.prototype.open=function(){return"closed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this.doOpen()),this},o.prototype.close=function(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this},o.prototype.send=function(e){if("open"!==this.readyState)throw new Error("Transport not open");this.write(e)},o.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},o.prototype.onData=function(e){var t=n.decodePacket(e,this.socket.binaryType);this.onPacket(t)},o.prototype.onPacket=function(e){this.emit("packet",e)},o.prototype.onClose=function(){this.readyState="closed",this.emit("close")}},function(e,t,r){"use strict";e.exports=function(e,t){return e.then(e=>{t(null,e)},e=>{t(e)})}},function(e,t,r){"use strict";e.exports=(()=>{if("undefined"!=typeof self&&(r(58)(self),self.crypto))return self.crypto;throw new Error("Please use an environment with crypto support")})},function(e,t,r){"use strict";e.exports="enum KeyType {\n RSA = 0;\n Ed25519 = 1;\n Secp256k1 = 2;\n}\nmessage PublicKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}\nmessage PrivateKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}"},function(e,t,r){"use strict";e.exports=function(e,t){return e.then(e=>{t(null,e)},e=>{t(e)})}},function(e,t,r){"use strict";e.exports=(()=>{if("undefined"!=typeof self&&(r(58)(self),self.crypto))return self.crypto;throw new Error("Please use an environment with crypto support")})},function(e,t,r){"use strict";e.exports="enum KeyType {\n RSA = 0;\n Ed25519 = 1;\n Secp256k1 = 2;\n}\nmessage PublicKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}\nmessage PrivateKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}"},function(e,t,r){"use strict";(function(e){const n=r(291),i=r(53),o=r(8),s=r(292),a=r(63);t.exchanges=["P-256","P-384","P-521"],t.ciphers=["AES-256","AES-128"],t.hashes=["SHA256","SHA512"],t.theBest=((e,t,r)=>{let n,i;if(e<0)n=r,i=t;else{if(!(e>0))return t[0];n=t,i=r}for(let e of n)for(let t of i)if(e===t)return e;throw new Error("No algorithms in common!")}),t.makeMacAndCipher=((e,t)=>{a([t=>(function(e,t,r){s.hmac.create(e,t,r)})(e.hashT,e.keys.macKey,t),t=>(function(e,t,r,n){if("AES-128"===e||"AES-256"===e)return s.aes.create(r,t,n);n(new Error(`unrecognized cipher type: ${e}`))})(e.cipherT,e.keys.iv,e.keys.cipherKey,t)],(r,n)=>{if(r)return t(r);e.mac=n[0],e.cipher=n[1],t()})}),t.selectBest=((r,n,i)=>{t.digest(e.concat([n.pubKeyBytes,r.nonce]),(o,s)=>{if(o)return i(o);t.digest(e.concat([r.pubKeyBytes,n.nonce]),(o,a)=>{if(o)return i(o);const u=e.compare(s,a);if(0===u)return i(new Error("you are trying to talk to yourself"));i(null,{curveT:t.theBest(u,r.exchanges,n.exchanges),cipherT:t.theBest(u,r.ciphers,n.ciphers),hashT:t.theBest(u,r.hashes,n.hashes),order:u})})})}),t.digest=((e,t)=>{n.digest(e,"sha2-256",e.length,t)}),t.write=function(e,t,r){r=r||(()=>{}),o(o.values([t]),i.encode({fixed:!0,bytes:4}),o.collect((t,n)=>{if(t)return r(t);e.shake.write(n[0]),r()}))},t.read=function(e,t){i.decodeFromReader(e,{fixed:!0,bytes:4},t)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(12),i=r(1166);function o(e,t,r,i){if("function"==typeof r&&(i=r,r=void 0),!i)throw new Error("Missing callback");o.digest(e,t,r,(e,o)=>{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){"use strict";const n=r(544),i=r(1170),o=r(1172);(t=e.exports).aes=i,t.hmac=n,t.keys=o,t.randomBytes=r(547),t.pbkdf2=r(1180)},function(e,t,r){"use strict";e.exports=function(e,t){return e.then(e=>{t(null,e)},e=>{t(e)})}},function(e,t,r){"use strict";e.exports=(()=>{if("undefined"!=typeof self&&(r(58)(self),self.crypto))return self.crypto;throw new Error("Please use an environment with crypto support")})},function(e,t,r){"use strict";e.exports="enum KeyType {\n RSA = 0;\n Ed25519 = 1;\n Secp256k1 = 2;\n}\nmessage PublicKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}\nmessage PrivateKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}"},function(e,t,r){"use strict";(function(e){const n=r(10),i=r(1181),o=r(292),s=r(63),a=r(4),u=r(1),c=u("libp2p:secio");c.error=u("libp2p:secio:error");const f=n(r(1182)),l=r(290);t.createProposal=(e=>(e.proposal.out={rand:o.randomBytes(16),pubkey:e.key.local.public.bytes,exchanges:l.exchanges.join(","),ciphers:l.ciphers.join(","),hashes:l.hashes.join(",")},e.proposalEncoded.out=f.Propose.encode(e.proposal.out),e.proposalEncoded.out)),t.createExchange=((t,r)=>{o.keys.generateEphemeralKeyPair(t.protocols.local.curveT,(n,i)=>{if(n)return r(n);t.ephemeralKey.local=i.key,t.shared.generate=i.genSharedKey;const o=e.concat([t.proposalEncoded.out,t.proposalEncoded.in,t.ephemeralKey.local]);t.key.local.sign(o,(e,n)=>{if(e)return r(e);t.exchange.out={epubkey:t.ephemeralKey.local,signature:n},r(null,f.Exchange.encode(t.exchange.out))})})}),t.identify=((e,t,r)=>{c("1.1 identify"),e.proposalEncoded.in=t,e.proposal.in=f.Propose.decode(t);const n=e.proposal.in.pubkey;e.key.remote=o.keys.unmarshalPublicKey(n),i.createFromPubKey(n.toString("base64"),(t,n)=>{if(t)return r(t);if(e.id.remote){if(e.id.remote.toB58String()!==n.toB58String())return r(new Error("dialed to the wrong peer, Ids do not match"))}else e.id.remote=n;c("1.1 identify - %s - identified remote peer as %s",e.id.local.toB58String(),e.id.remote.toB58String()),r()})}),t.selectProtocols=((e,t)=>{c("1.2 selection");const r={pubKeyBytes:e.key.local.public.bytes,exchanges:l.exchanges,hashes:l.hashes,ciphers:l.ciphers,nonce:e.proposal.out.rand},n={pubKeyBytes:e.proposal.in.pubkey,exchanges:e.proposal.in.exchanges.split(","),hashes:e.proposal.in.hashes.split(","),ciphers:e.proposal.in.ciphers.split(","),nonce:e.proposal.in.rand};l.selectBest(r,n,(r,n)=>{if(r)return t(r);e.protocols.remote={order:n.order,curveT:n.curveT,cipherT:n.cipherT,hashT:n.hashT},e.protocols.local={order:n.order,curveT:n.curveT,cipherT:n.cipherT,hashT:n.hashT},t()})}),t.verify=((t,r,n)=>{c("2.1. verify"),t.exchange.in=f.Exchange.decode(r),t.ephemeralKey.remote=t.exchange.in.epubkey;const i=e.concat([t.proposalEncoded.in,t.proposalEncoded.out,t.ephemeralKey.remote]);t.key.remote.verify(i,t.exchange.in.signature,(e,t)=>e?n(e):t?(c("2.1. verify - signature verified"),void n()):n(new Error("Bad signature")))}),t.generateKeys=((e,t)=>{c("2.2. keys"),a([t=>e.shared.generate(e.exchange.in.epubkey,t),(t,r)=>{e.shared.secret=t,o.keys.keyStretcher(e.protocols.local.cipherT,e.protocols.local.hashT,e.shared.secret,r)},(t,r)=>{if(e.protocols.local.order>0)e.protocols.local.keys=t.k1,e.protocols.remote.keys=t.k2;else{if(!(e.protocols.local.order<0))return r(new Error("you are trying to talk to yourself"));e.protocols.local.keys=t.k2,e.protocols.remote.keys=t.k1}c("2.3. mac + cipher"),s([t=>l.makeMacAndCipher(e.protocols.local,t),t=>l.makeMacAndCipher(e.protocols.remote,t)],r)}],t)}),t.verifyNonce=((e,t)=>{const r=e.proposal.out.rand;if(!r.equals(t))throw new Error(`Failed to read our encrypted nonce: ${r.toString("hex")} != ${t.toString("hex")}`)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";e.exports=function(e,t){return e.then(e=>{t(null,e)},e=>{t(e)})}},function(e,t,r){"use strict";e.exports=(()=>{if("undefined"!=typeof self&&(r(58)(self),self.crypto))return self.crypto;throw new Error("Please use an environment with crypto support")})},function(e,t,r){"use strict";e.exports="enum KeyType {\n RSA = 0;\n Ed25519 = 1;\n Secp256k1 = 2;\n}\nmessage PublicKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}\nmessage PrivateKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}"},function(e,t,r){"use strict";const n=r(10);e.exports=n("\nmessage Identify {\n // protocolVersion determines compatibility between peers\n optional string protocolVersion = 5; // e.g. ipfs/1.0.0\n\n // agentVersion is like a UserAgent string in browsers, or client version in bittorrent\n // includes the client name and client.\n optional string agentVersion = 6; // e.g. go-ipfs/0.1.0\n\n // publicKey is this node's public key (which also gives its node.ID)\n // - may not need to be sent, as secure channel implies it has been sent.\n // - then again, if we change / disable secure channel, may still want it.\n optional bytes publicKey = 1;\n\n // listenAddrs are the multiaddrs the sender node listens for open connections on\n repeated bytes listenAddrs = 2;\n\n // oservedAddr is the multiaddr of the remote endpoint that the sender node perceives\n // this is useful information to convey to the other side, as it helps the remote endpoint\n // determine whether its connection to the local peer goes through NAT.\n optional bytes observedAddr = 4;\n\n repeated string protocols = 3;\n}\n").Identify},function(e,t,r){"use strict";e.exports=function(e,t){return e.then(e=>{t(null,e)},e=>{t(e)})}},function(e,t,r){"use strict";e.exports=(()=>{if("undefined"!=typeof self&&(r(58)(self),self.crypto))return self.crypto;throw new Error("Please use an environment with crypto support")})},function(e,t,r){"use strict";e.exports="enum KeyType {\n RSA = 0;\n Ed25519 = 1;\n Secp256k1 = 2;\n}\nmessage PublicKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}\nmessage PrivateKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}"},function(e,t,r){"use strict";t.Listener=t.listener=r(1232),t.Dialer=t.dialer=r(1236),t.matchSemver=r(1237),t.matchExact=r(563)},function(e,t){e.exports=function(e){return e}},function(e,t,r){"use strict";const n=r(44);function i(e){if("number"==typeof e){if(i.codes[e])return i.codes[e];throw new Error("no protocol with code: "+e)}if("string"==typeof e||e instanceof String){if(i.names[e])return i.names[e];throw new Error("no protocol with name: "+e)}throw new Error("invalid protocol id type: "+e)}function o(e,t,r,n){return{code:e,size:t,name:r,resolvable:Boolean(n)}}i.lengthPrefixedVarSize=-1,i.V=-1,i.table=[[4,32,"ip4"],[6,16,"tcp"],[17,16,"udp"],[33,16,"dccp"],[41,128,"ip6"],[54,-1,"dns4","resolvable"],[55,-1,"dns6","resolvable"],[56,-1,"dnsaddr","resolvable"],[132,16,"sctp"],[302,0,"utp"],[421,i.lengthPrefixedVarSize,"ipfs"],[480,0,"http"],[443,0,"https"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[290,0,"p2p-circuit"]],i.names={},i.codes={},n(i.table,function(e){const t=o.apply(null,e);i.codes[t.code]=t,i.names[t.name]=t}),i.object=o,e.exports=i},function(e,t,r){"use strict";e.exports=function(e,t){return e.then(e=>{t(null,e)},e=>{t(e)})}},function(e,t,r){"use strict";e.exports=(()=>{if("undefined"!=typeof self&&(r(58)(self),self.crypto))return self.crypto;throw new Error("Please use an environment with crypto support")})},function(e,t,r){"use strict";e.exports="enum KeyType {\n RSA = 0;\n Ed25519 = 1;\n Secp256k1 = 2;\n}\nmessage PublicKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}\nmessage PrivateKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}"},function(e,t,r){"use strict";const n=r(8),i=r(53),o=r(100),s=r(1),a=s("libp2p:circuit:stream-handler");a.err=s("libp2p:circuit:error:stream-handler");e.exports=class{constructor(e,t,r,i){this.conn=e,this.stream=null,this.shake=null,this.timeout=t||6e4,this.maxLength=i||4096,"function"==typeof t&&(this.timeout=r||6e4),this.stream=o({timeout:this.timeout},t),this.shake=this.stream.handshake,n(this.stream,e,this.stream)}isValid(){return this.conn&&this.shake&&this.stream}read(e){this.isValid()||e(new Error("handler is not in a valid state")),i.decodeFromReader(this.shake,{maxLength:this.maxLength},(t,r)=>t?(a.err(t),e(t)):e(null,r))}write(e,t){t=t||(()=>{}),this.isValid()||t(new Error("handler is not in a valid state")),n(n.values([e]),i.encode(),n.collect((e,r)=>{if(e)return a.err(e),this.shake.abort(e),t(e);r.forEach(e=>this.shake.write(e)),t()}))}getRawConn(){return this.conn}rest(){const e=this.shake.rest();return this.conn=null,this.stream=null,this.shake=null,e}}},function(e,t,r){"use strict";e.exports={relay:"/libp2p/circuit/relay/0.1.0"}},function(e,t,r){var n=r(1266),i=r(1270);e.exports=function(e,t){var r=i(e,t);return n(r)?r:void 0}},function(e,t){e.exports=function(e,t){return e===t||e!=e&&t!=t}},function(e,t,r){"use strict";e.exports=function(e,t){return e.then(e=>{t(null,e)},e=>{t(e)})}},function(e,t,r){"use strict";e.exports=(()=>{if("undefined"!=typeof self&&(r(58)(self),self.crypto))return self.crypto;throw new Error("Please use an environment with crypto support")})},function(e,t,r){"use strict";e.exports="enum KeyType {\n RSA = 0;\n Ed25519 = 1;\n Secp256k1 = 2;\n}\nmessage PublicKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}\nmessage PrivateKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}"},function(e,t,r){"use strict";e.exports={PROTOCOL:"/ipfs/ping/1.0.0",PING_LENGTH:32}},function(e,t,r){var n=r(157),i=r(160),o="[object Symbol]";e.exports=function(e){return"symbol"==typeof e||i(e)&&n(e)==o}},function(e,t,r){"use strict";e.exports=function(e,t){return e.then(e=>{t(null,e)},e=>{t(e)})}},function(e,t,r){"use strict";e.exports=(()=>{if("undefined"!=typeof self&&(r(58)(self),self.crypto))return self.crypto;throw new Error("Please use an environment with crypto support")})},function(e,t,r){"use strict";e.exports="enum KeyType {\n RSA = 0;\n Ed25519 = 1;\n Secp256k1 = 2;\n}\nmessage PublicKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}\nmessage PrivateKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}"},function(e,t,r){"use strict";const n=r(202);e.exports=function(e){const t=e||100;var r=[];return n(function(e){for(r=r.concat(e);r.length>=t;){const e=t,n=r.slice(0,e);r=r.slice(e),this.queue(n)}},function(e){r.length&&(this.queue(r),r=[]),this.queue(null)})}},function(e,t,r){"use strict";e.exports=class{constructor(e,t){this._options=t||{},Object.assign(this,e)}}},function(e,t,r){var n=r(1413);e.exports=function(e,t,r){r=void 0===r||r;var i,o=!1;return function(s){var a,u,c=0,f=0,l=0,h=[],p=!1,d=!1;function y(){if(a){var e=a;if(u)return a=null,e(u);if(Object.hasOwnProperty.call(h,f)){a=null;var r=h[f];delete h[f],f++,e(null,r),t&&g()}else f>=l&&d&&(a=null,e(d))}}var g=n(function(){if(p=!0,d)return y();o||t&&c-t>=f||(o=!0,s(i,function(t,n){if(o=!1,t)l=c,d=t,y();else{var i=c++;e(n,function(e,t){r?h[i]=t:h.push(t),e&&(u=e),y()}),d||g()}}))});return function(e,t){e?s(d=i=e,function(e){if(t)return t(e)}):(a=t,p||g(),y())}}}},function(e,t,r){"use strict";const n=r(9),i=r(45),{DAGNode:o,DAGLink:s}=i,a=r(4);e.exports=((e,t,r)=>(t=Object.assign({},{parent:void 0,child:void 0,name:"",flush:!0},t)).parent?t.child?void a([e=>{if(t.name)return o.rmLink(t.parent,t.name,e);e(null,t.parent)},(e,r)=>{o.addLink(e,new s(t.name,t.child.size,t.child.hash||t.child.multihash),r)},(r,i)=>{if(!t.flush)return i(null,r);e.dag.put(r,{cid:new n(r.hash||r.multihash)},e=>i(e,r))}],r):r(new Error("No child passed to addLink")):r(new Error("No parent passed to addLink")))},function(e,t,r){"use strict";const n=r(145).exporter,i=r(70),o=r(87),s=r(4),a=r(36),{traverseTo:u}=r(48),c=r(1)("ipfs:mfs:read-pull-stream"),f={offset:0,length:void 0};e.exports=(e=>(function(t,r,l){"function"==typeof r&&(l=r,r={}),r=Object.assign({},f,r),c(`Reading ${t}`),s([r=>u(e,t,{parents:!1},r),(u,c)=>{const f=u.node;if("file"!==a.unmarshal(f.data).type)return c(new Error(`${t} was not a file`));s([t=>i(n(f.multihash,e.dag,{offset:r.offset,length:r.length}),o(t)),(e,t)=>t(null,e[0].content)],c)}],l)}))},function(e,t,r){(function(t){e.exports=function(e,r){var n=[];e.on("data",function(e){n.push(e)}),e.once("end",function(){r&&r(null,t.concat(n)),r=null}),e.once("error",function(e){r&&r(e),r=null})}}).call(this,r(0).Buffer)},function(e,t,r){(function(e){var n=r(1527),i=r(619),o=r(26),s=r(1528),a=r(33),u=t;u.request=function(t,r){t="string"==typeof t?a.parse(t):o(t);var i=-1===e.location.protocol.search(/^https?:$/)?"http:":"",s=t.protocol||i,u=t.hostname||t.host,c=t.port,f=t.path||"/";u&&-1!==u.indexOf(":")&&(u="["+u+"]"),t.url=(u?s+"//"+u:"")+(c?":"+c:"")+f,t.method=(t.method||"GET").toUpperCase(),t.headers=t.headers||{};var l=new n(t);return r&&l.on("response",r),l},u.get=function(e,t){var r=u.request(e,t);return r.end(),r},u.ClientRequest=n,u.IncomingMessage=i.IncomingMessage,u.Agent=function(){},u.Agent.defaultMaxSockets=4,u.globalAgent=new u.Agent,u.STATUS_CODES=s,u.METHODS=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"]}).call(this,r(6))},function(e,t){var r,n=1,i=function(){n=n+1&65535};e.exports=function(e){r||(r=setInterval(i,250)).unref&&r.unref();var t=4*(e||5),o=[0],s=1,a=n-1&65535;return function(e){var r=n-a&65535;for(r>t&&(r=t),a=n;r--;)s===t&&(s=0),o[s]=o[0===s?t-1:s-1],s++;e&&(o[s-1]+=e);var i=o[s-1],u=o.length>>=0;var o=e.byteLength-r;if(o<0)throw new RangeError("'offset' is out of bounds");if(void 0===i)i=o;else if((i>>>=0)>o)throw new RangeError("'length' is out of bounds");return n?t.from(e.slice(r,r+i)):new t(new Uint8Array(e.slice(r,r+i)))}(e,r,o):"string"==typeof e?function(e,r){if("string"==typeof r&&""!==r||(r="utf8"),!t.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');return n?t.from(e,r):new t(e,r)}(e,r):n?t.from(e):new t(e)}}).call(this,r(0).Buffer)},function(e){e.exports={_from:"webtorrent@^0.99.3",_id:"webtorrent@0.99.4",_inBundle:!1,_integrity:"sha512-coJ61iJOFDrSzyCwmhlLaU8tvcchI5ZA0fH9Toj4wwUq/OTUNdjXtNXwpCb6ldbBnJ04lQzxyDeuSR3KtN0MWg==",_location:"/webtorrent",_phantomChildren:{"decompress-response":"3.3.0",once:"1.4.0","simple-concat":"1.0.0"},_requested:{type:"range",registry:!0,raw:"webtorrent@^0.99.3",name:"webtorrent",escapedName:"webtorrent",rawSpec:"^0.99.3",saveSpec:null,fetchSpec:"^0.99.3"},_requiredBy:["/"],_resolved:"https://registry.npmjs.org/webtorrent/-/webtorrent-0.99.4.tgz",_shasum:"b5d4652c72f20f6ad3322b6ecbc7215cf83c6a89",_spec:"webtorrent@^0.99.3",_where:"/Users/mitra/git/dweb-transports",author:{name:"WebTorrent, LLC",email:"feross@webtorrent.io",url:"https://webtorrent.io"},browser:{"./lib/server.js":!1,"./lib/tcp-pool.js":!1,"bittorrent-dht/client":!1,"fs-chunk-store":"memory-chunk-store","load-ip-set":!1,net:!1,os:!1,ut_pex:!1},browserify:{transform:["package-json-versionify"]},bugs:{url:"https://github.com/webtorrent/webtorrent/issues"},bundleDependencies:!1,dependencies:{"addr-to-ip-port":"^1.4.2",bitfield:"^2.0.0","bittorrent-dht":"^8.0.0","bittorrent-protocol":"^2.1.5","chunk-store-stream":"^2.0.2","create-torrent":"^3.24.5",debug:"^3.1.0","end-of-stream":"^1.1.0","fs-chunk-store":"^1.6.2","immediate-chunk-store":"^1.0.8",inherits:"^2.0.1","load-ip-set":"^1.2.7","memory-chunk-store":"^1.2.0",mime:"^2.2.0",multistream:"^2.0.5","package-json-versionify":"^1.0.2","parse-torrent":"^6.0.0",pump:"^3.0.0","random-iterate":"^1.0.1",randombytes:"^2.0.3","range-parser":"^1.2.0","readable-stream":"^2.1.4","render-media":"^3.0.0","run-parallel":"^1.1.6","run-parallel-limit":"^1.0.3","safe-buffer":"^5.0.1","simple-concat":"^1.0.0","simple-get":"^3.0.1","simple-peer":"^9.0.0","simple-sha1":"^2.0.8",speedometer:"^1.0.0","stream-to-blob":"^1.0.0","stream-to-blob-url":"^2.1.0","stream-with-known-length-to-buffer":"^1.0.0","torrent-discovery":"^8.3.1","torrent-piece":"^1.1.0",uniq:"^1.0.1","unordered-array-remove":"^1.0.2",ut_metadata:"^3.0.8",ut_pex:"^1.1.1",xtend:"^4.0.1","zero-fill":"^2.2.3"},deprecated:!1,description:"Streaming torrent client",devDependencies:{airtap:"0.0.4","babel-minify":"^0.3.0","bittorrent-tracker":"^9.4.0",brfs:"^1.4.3",browserify:"^16.0.0","cross-spawn":"^6.0.3",electron:"^2.0.0",finalhandler:"^1.0.0","network-address":"^1.1.0","run-series":"^1.1.4","serve-static":"^1.11.1",standard:"*",tape:"^4.6.0","webtorrent-fixtures":"^1.5.0"},engines:{node:">=4"},homepage:"https://webtorrent.io",keywords:["bittorrent","bittorrent client","download","mad science","p2p","peer-to-peer","peers","streaming","swarm","torrent","web torrent","webrtc","webrtc data","webtorrent"],license:"MIT",main:"index.js",name:"webtorrent",repository:{type:"git",url:"git://github.com/webtorrent/webtorrent.git"},scripts:{build:"browserify -s WebTorrent -e ./ | minify > webtorrent.min.js","build-debug":"browserify -s WebTorrent -e ./ > webtorrent.debug.js",size:"npm run build && cat webtorrent.min.js | gzip | wc -c",test:"standard && npm run test-node && npm run test-browser","test-browser":"airtap -- test/*.js test/browser/*.js","test-browser-local":"airtap --local -- test/*.js test/browser/*.js","test-node":"tape test/*.js test/node/*.js","update-authors":"./scripts/update-authors.sh"},version:"0.99.4"}},function(e,t,r){"use strict";(function(t,n){var i=r(150);e.exports=_;var o,s=r(333);_.ReadableState=v;r(11).EventEmitter;var a=function(e,t){return e.listeners(t).length},u=r(334),c=r(2).Buffer,f=t.Uint8Array||function(){};var l=r(117);l.inherits=r(5);var h=r(638),p=void 0;p=h&&h.debuglog?h.debuglog("stream"):function(){};var d,y=r(639),g=r(336);l.inherits(_,u);var m=["error","close","destroy","pause","resume"];function b(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)}function v(e,t){o=o||r(85),e=e||{};var n=t instanceof o;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&&(d||(d=r(211).StringDecoder),this.decoder=new d(e.encoding),this.encoding=e.encoding)}function _(e){if(o=o||r(85),!(this instanceof _))return new _(e);this._readableState=new v(e,this),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),u.call(this)}function w(e,t,r,n,i){var o,s=e._readableState;return null===t?(s.reading=!1,function(e,t){if(!t.ended){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,A(e)}}(e,s)):(i||(o=function(e,t){var r;return function(e){return c.isBuffer(e)||e instanceof f}(t)||"string"==typeof t||void 0===t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk")),r}(s,t)),o?e.emit("error",o):s.objectMode||t&&t.length>0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===c.prototype||(t=function(e){return c.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):S(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?S(e,s,t,!1):I(e,s)):S(e,s,t,!1))):n||(s.reading=!1)),function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=k?e=k:(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 A(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(p("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i.nextTick(x,e):x(e))}function x(e){p("emit readable"),e.emit("readable"),P(e)}function I(e,t){t.readingMore||(t.readingMore=!0,i.nextTick(T,e,t))}function T(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;return 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=c.allocUnsafe(e),n=t.head,i=1;for(n.data.copy(r),e-=n.data.length;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),n}(e,t.buffer,t.decoder),r);var r}function R(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(N,t,e))}function N(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function L(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return p("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?R(this):A(this),null;if(0===(e=E(e,t))&&t.ended)return 0===t.length&&R(this),null;var n,i=t.needReadable;return p("need readable",i),(0===t.length||t.length-e0?O(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&R(this)),null!==n&&this.emit("data",n),n},_.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},_.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,p("pipe count=%d opts=%j",o.pipesCount,t);var s=t&&!1===t.end||e===n.stdout||e===n.stderr?_:c;function u(e,t){p("onunpipe"),e===r&&t&&!1===t.hasUnpiped&&(t.hasUnpiped=!0,h())}function c(){p("onend"),e.end()}o.endEmitted?i.nextTick(s):r.once("end",s),e.on("unpipe",u);var f=function(e){return function(){var t=e._readableState;p("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&a(e,"data")&&(t.flowing=!0,P(e))}}(r);e.on("drain",f);var l=!1;function h(){p("cleanup"),e.removeListener("close",m),e.removeListener("finish",v),e.removeListener("drain",f),e.removeListener("error",g),e.removeListener("unpipe",u),r.removeListener("end",c),r.removeListener("end",_),r.removeListener("data",y),l=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||f()}var d=!1;function y(t){p("ondata"),d=!1,!1!==e.write(t)||d||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==L(o.pipes,e))&&!l&&(p("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,d=!0),r.pause())}function g(t){p("onerror",t),_(),e.removeListener("error",g),0===a(e,"error")&&e.emit("error",t)}function m(){e.removeListener("finish",v),_()}function v(){p("onfinish"),e.removeListener("close",m),_()}function _(){p("unpipe"),r.unpipe(e)}return r.on("data",y),b(e,"error",g),e.once("close",m),e.once("finish",v),e.emit("pipe",r),o.flowing||(p("pipe resume"),r.resume()),e},_.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?this:(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;o>1,f=-7,l=r?i-1:0,h=r?-1:1,p=e[t+l];for(l+=h,o=p&(1<<-f)-1,p>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=h,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=h,f-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var s,a,u,c=8*o-i-1,f=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=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*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+p]=255&a,p+=d,a/=256,i-=8);for(s=s<0;e[r+p]=255&s,p+=d,s/=256,c-=8);e[r+p-d]|=128*y}},function(e,t,r){"use strict";var n=r(150);function i(e,t){e.emit("error",t)}e.exports={destroy:function(e,t){var r=this,o=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return o||s?(t?t(e):!e||this._writableState&&this._writableState.errorEmitted||n.nextTick(i,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?(n.nextTick(i,r,e),r._writableState&&(r._writableState.errorEmitted=!0)):t&&t(e)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},function(e,t,r){"use strict";e.exports=o;var n=r(85),i=r(117);function o(e){if(!(this instanceof o))return new o(e);n.call(this,e),this._transformState={afterTransform:function(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{setTimeout(()=>{e()},t)}),t*=1+Math.random()}throw console.log("Looping",n,"failed"),o!==(window&&window.loopguard)?(console.log("Looping exited because of page change "+n),new Error("Looping exited because of page change "+n)):i}(s,500,12,"fetching "+e);if(a.ok){let e=a.headers.get("Content-Type");return o?a.body:"application/json"===e?a.json():e.startsWith("text")?a.text():new t(await a.arrayBuffer())}throw new i.TransportError(`Transport Error ${a.status}: ${a.statusText}`)}catch(r){throw console.log("Note error from fetch might be misleading especially TypeError can be Cors issue:",e),r instanceof i.TransportError?r:new i.TransportError(`Transport error thrown by ${e}: ${r.message}`)}},httptools.p_GET=async function(e,t={}){let r=new Headers;(t.start||t.end)&&r.append("range",`bytes=${t.start||0}-${t.end||""}`);let n={method:"GET",headers:r,mode:"cors",cache:"default",redirect:"follow",keepalive:!0};return await httptools.p_httpfetch(e,n,{verbose:t.verbose,wantstream:t.wantstream})},httptools.p_POST=async function(e,t,r,n){let i={method:"POST",headers:{},body:r,mode:"cors",cache:"default",redirect:"follow",keepalive:!0};return await httptools.p_httpfetch(e,i,{verbose:n})},e.exports=httptools}).call(this,r(0).Buffer)},function(e,t,r){"use strict";e.exports=class{constructor(e){this._repo=e,this._bitswap=null}setExchange(e){this._bitswap=e}unsetExchange(){this._bitswap=null}hasExchange(){return null!=this._bitswap}put(e,t){if(this.hasExchange())return this._bitswap.put(e,t);this._repo.blocks.put(e,t)}putMany(e,t){if(this.hasExchange())return this._bitswap.putMany(e,t);this._repo.blocks.putMany(e,t)}get(e,t){return this.hasExchange()?this._bitswap.get(e,t):this._repo.blocks.get(e,t)}delete(e,t){this._repo.blocks.delete(e,t)}}},function(e,t,r){var n=r(2).Buffer;e.exports=function(e){for(var t={},r=e.length,i=e.charAt(0),o=0;o>=8;for(;c>0;)o.push(255&c),c>>=8}for(var f=0;e[f]===i&&f0;)n.push(a%r),a=a/r|0}for(var u="",c=0;0===t[c]&&c=0;--f)u+=e[n[f]];return u},decodeUnsafe:a,decode:function(e){var t=a(e);if(t)return t;throw new Error("Non-base"+r+" character")}}}},function(e,t,r){"use strict";t.names=Object.freeze({sha1:17,"sha2-256":18,"sha2-512":19,"dbl-sha2-256":86,"sha3-224":23,"sha3-256":22,"sha3-384":21,"sha3-512":20,"shake-128":24,"shake-256":25,"keccak-224":26,"keccak-256":27,"keccak-384":28,"keccak-512":29,"murmur3-128":34,"murmur3-32":35,"blake2b-8":45569,"blake2b-16":45570,"blake2b-24":45571,"blake2b-32":45572,"blake2b-40":45573,"blake2b-48":45574,"blake2b-56":45575,"blake2b-64":45576,"blake2b-72":45577,"blake2b-80":45578,"blake2b-88":45579,"blake2b-96":45580,"blake2b-104":45581,"blake2b-112":45582,"blake2b-120":45583,"blake2b-128":45584,"blake2b-136":45585,"blake2b-144":45586,"blake2b-152":45587,"blake2b-160":45588,"blake2b-168":45589,"blake2b-176":45590,"blake2b-184":45591,"blake2b-192":45592,"blake2b-200":45593,"blake2b-208":45594,"blake2b-216":45595,"blake2b-224":45596,"blake2b-232":45597,"blake2b-240":45598,"blake2b-248":45599,"blake2b-256":45600,"blake2b-264":45601,"blake2b-272":45602,"blake2b-280":45603,"blake2b-288":45604,"blake2b-296":45605,"blake2b-304":45606,"blake2b-312":45607,"blake2b-320":45608,"blake2b-328":45609,"blake2b-336":45610,"blake2b-344":45611,"blake2b-352":45612,"blake2b-360":45613,"blake2b-368":45614,"blake2b-376":45615,"blake2b-384":45616,"blake2b-392":45617,"blake2b-400":45618,"blake2b-408":45619,"blake2b-416":45620,"blake2b-424":45621,"blake2b-432":45622,"blake2b-440":45623,"blake2b-448":45624,"blake2b-456":45625,"blake2b-464":45626,"blake2b-472":45627,"blake2b-480":45628,"blake2b-488":45629,"blake2b-496":45630,"blake2b-504":45631,"blake2b-512":45632,"blake2s-8":45633,"blake2s-16":45634,"blake2s-24":45635,"blake2s-32":45636,"blake2s-40":45637,"blake2s-48":45638,"blake2s-56":45639,"blake2s-64":45640,"blake2s-72":45641,"blake2s-80":45642,"blake2s-88":45643,"blake2s-96":45644,"blake2s-104":45645,"blake2s-112":45646,"blake2s-120":45647,"blake2s-128":45648,"blake2s-136":45649,"blake2s-144":45650,"blake2s-152":45651,"blake2s-160":45652,"blake2s-168":45653,"blake2s-176":45654,"blake2s-184":45655,"blake2s-192":45656,"blake2s-200":45657,"blake2s-208":45658,"blake2s-216":45659,"blake2s-224":45660,"blake2s-232":45661,"blake2s-240":45662,"blake2s-248":45663,"blake2s-256":45664,"Skein256-8":45825,"Skein256-16":45826,"Skein256-24":45827,"Skein256-32":45828,"Skein256-40":45829,"Skein256-48":45830,"Skein256-56":45831,"Skein256-64":45832,"Skein256-72":45833,"Skein256-80":45834,"Skein256-88":45835,"Skein256-96":45836,"Skein256-104":45837,"Skein256-112":45838,"Skein256-120":45839,"Skein256-128":45840,"Skein256-136":45841,"Skein256-144":45842,"Skein256-152":45843,"Skein256-160":45844,"Skein256-168":45845,"Skein256-176":45846,"Skein256-184":45847,"Skein256-192":45848,"Skein256-200":45849,"Skein256-208":45850,"Skein256-216":45851,"Skein256-224":45852,"Skein256-232":45853,"Skein256-240":45854,"Skein256-248":45855,"Skein256-256":45856,"Skein512-8":45857,"Skein512-16":45858,"Skein512-24":45859,"Skein512-32":45860,"Skein512-40":45861,"Skein512-48":45862,"Skein512-56":45863,"Skein512-64":45864,"Skein512-72":45865,"Skein512-80":45866,"Skein512-88":45867,"Skein512-96":45868,"Skein512-104":45869,"Skein512-112":45870,"Skein512-120":45871,"Skein512-128":45872,"Skein512-136":45873,"Skein512-144":45874,"Skein512-152":45875,"Skein512-160":45876,"Skein512-168":45877,"Skein512-176":45878,"Skein512-184":45879,"Skein512-192":45880,"Skein512-200":45881,"Skein512-208":45882,"Skein512-216":45883,"Skein512-224":45884,"Skein512-232":45885,"Skein512-240":45886,"Skein512-248":45887,"Skein512-256":45888,"Skein512-264":45889,"Skein512-272":45890,"Skein512-280":45891,"Skein512-288":45892,"Skein512-296":45893,"Skein512-304":45894,"Skein512-312":45895,"Skein512-320":45896,"Skein512-328":45897,"Skein512-336":45898,"Skein512-344":45899,"Skein512-352":45900,"Skein512-360":45901,"Skein512-368":45902,"Skein512-376":45903,"Skein512-384":45904,"Skein512-392":45905,"Skein512-400":45906,"Skein512-408":45907,"Skein512-416":45908,"Skein512-424":45909,"Skein512-432":45910,"Skein512-440":45911,"Skein512-448":45912,"Skein512-456":45913,"Skein512-464":45914,"Skein512-472":45915,"Skein512-480":45916,"Skein512-488":45917,"Skein512-496":45918,"Skein512-504":45919,"Skein512-512":45920,"Skein1024-8":45921,"Skein1024-16":45922,"Skein1024-24":45923,"Skein1024-32":45924,"Skein1024-40":45925,"Skein1024-48":45926,"Skein1024-56":45927,"Skein1024-64":45928,"Skein1024-72":45929,"Skein1024-80":45930,"Skein1024-88":45931,"Skein1024-96":45932,"Skein1024-104":45933,"Skein1024-112":45934,"Skein1024-120":45935,"Skein1024-128":45936,"Skein1024-136":45937,"Skein1024-144":45938,"Skein1024-152":45939,"Skein1024-160":45940,"Skein1024-168":45941,"Skein1024-176":45942,"Skein1024-184":45943,"Skein1024-192":45944,"Skein1024-200":45945,"Skein1024-208":45946,"Skein1024-216":45947,"Skein1024-224":45948,"Skein1024-232":45949,"Skein1024-240":45950,"Skein1024-248":45951,"Skein1024-256":45952,"Skein1024-264":45953,"Skein1024-272":45954,"Skein1024-280":45955,"Skein1024-288":45956,"Skein1024-296":45957,"Skein1024-304":45958,"Skein1024-312":45959,"Skein1024-320":45960,"Skein1024-328":45961,"Skein1024-336":45962,"Skein1024-344":45963,"Skein1024-352":45964,"Skein1024-360":45965,"Skein1024-368":45966,"Skein1024-376":45967,"Skein1024-384":45968,"Skein1024-392":45969,"Skein1024-400":45970,"Skein1024-408":45971,"Skein1024-416":45972,"Skein1024-424":45973,"Skein1024-432":45974,"Skein1024-440":45975,"Skein1024-448":45976,"Skein1024-456":45977,"Skein1024-464":45978,"Skein1024-472":45979,"Skein1024-480":45980,"Skein1024-488":45981,"Skein1024-496":45982,"Skein1024-504":45983,"Skein1024-512":45984,"Skein1024-520":45985,"Skein1024-528":45986,"Skein1024-536":45987,"Skein1024-544":45988,"Skein1024-552":45989,"Skein1024-560":45990,"Skein1024-568":45991,"Skein1024-576":45992,"Skein1024-584":45993,"Skein1024-592":45994,"Skein1024-600":45995,"Skein1024-608":45996,"Skein1024-616":45997,"Skein1024-624":45998,"Skein1024-632":45999,"Skein1024-640":46e3,"Skein1024-648":46001,"Skein1024-656":46002,"Skein1024-664":46003,"Skein1024-672":46004,"Skein1024-680":46005,"Skein1024-688":46006,"Skein1024-696":46007,"Skein1024-704":46008,"Skein1024-712":46009,"Skein1024-720":46010,"Skein1024-728":46011,"Skein1024-736":46012,"Skein1024-744":46013,"Skein1024-752":46014,"Skein1024-760":46015,"Skein1024-768":46016,"Skein1024-776":46017,"Skein1024-784":46018,"Skein1024-792":46019,"Skein1024-800":46020,"Skein1024-808":46021,"Skein1024-816":46022,"Skein1024-824":46023,"Skein1024-832":46024,"Skein1024-840":46025,"Skein1024-848":46026,"Skein1024-856":46027,"Skein1024-864":46028,"Skein1024-872":46029,"Skein1024-880":46030,"Skein1024-888":46031,"Skein1024-896":46032,"Skein1024-904":46033,"Skein1024-912":46034,"Skein1024-920":46035,"Skein1024-928":46036,"Skein1024-936":46037,"Skein1024-944":46038,"Skein1024-952":46039,"Skein1024-960":46040,"Skein1024-968":46041,"Skein1024-976":46042,"Skein1024-984":46043,"Skein1024-992":46044,"Skein1024-1000":46045,"Skein1024-1008":46046,"Skein1024-1016":46047,"Skein1024-1024":46048}),t.codes=Object.freeze({17:"sha1",18:"sha2-256",19:"sha2-512",86:"dbl-sha2-256",23:"sha3-224",22:"sha3-256",21:"sha3-384",20:"sha3-512",24:"shake-128",25:"shake-256",26:"keccak-224",27:"keccak-256",28:"keccak-384",29:"keccak-512",34:"murmur3-128",35:"murmur3-32",45569:"blake2b-8",45570:"blake2b-16",45571:"blake2b-24",45572:"blake2b-32",45573:"blake2b-40",45574:"blake2b-48",45575:"blake2b-56",45576:"blake2b-64",45577:"blake2b-72",45578:"blake2b-80",45579:"blake2b-88",45580:"blake2b-96",45581:"blake2b-104",45582:"blake2b-112",45583:"blake2b-120",45584:"blake2b-128",45585:"blake2b-136",45586:"blake2b-144",45587:"blake2b-152",45588:"blake2b-160",45589:"blake2b-168",45590:"blake2b-176",45591:"blake2b-184",45592:"blake2b-192",45593:"blake2b-200",45594:"blake2b-208",45595:"blake2b-216",45596:"blake2b-224",45597:"blake2b-232",45598:"blake2b-240",45599:"blake2b-248",45600:"blake2b-256",45601:"blake2b-264",45602:"blake2b-272",45603:"blake2b-280",45604:"blake2b-288",45605:"blake2b-296",45606:"blake2b-304",45607:"blake2b-312",45608:"blake2b-320",45609:"blake2b-328",45610:"blake2b-336",45611:"blake2b-344",45612:"blake2b-352",45613:"blake2b-360",45614:"blake2b-368",45615:"blake2b-376",45616:"blake2b-384",45617:"blake2b-392",45618:"blake2b-400",45619:"blake2b-408",45620:"blake2b-416",45621:"blake2b-424",45622:"blake2b-432",45623:"blake2b-440",45624:"blake2b-448",45625:"blake2b-456",45626:"blake2b-464",45627:"blake2b-472",45628:"blake2b-480",45629:"blake2b-488",45630:"blake2b-496",45631:"blake2b-504",45632:"blake2b-512",45633:"blake2s-8",45634:"blake2s-16",45635:"blake2s-24",45636:"blake2s-32",45637:"blake2s-40",45638:"blake2s-48",45639:"blake2s-56",45640:"blake2s-64",45641:"blake2s-72",45642:"blake2s-80",45643:"blake2s-88",45644:"blake2s-96",45645:"blake2s-104",45646:"blake2s-112",45647:"blake2s-120",45648:"blake2s-128",45649:"blake2s-136",45650:"blake2s-144",45651:"blake2s-152",45652:"blake2s-160",45653:"blake2s-168",45654:"blake2s-176",45655:"blake2s-184",45656:"blake2s-192",45657:"blake2s-200",45658:"blake2s-208",45659:"blake2s-216",45660:"blake2s-224",45661:"blake2s-232",45662:"blake2s-240",45663:"blake2s-248",45664:"blake2s-256",45825:"Skein256-8",45826:"Skein256-16",45827:"Skein256-24",45828:"Skein256-32",45829:"Skein256-40",45830:"Skein256-48",45831:"Skein256-56",45832:"Skein256-64",45833:"Skein256-72",45834:"Skein256-80",45835:"Skein256-88",45836:"Skein256-96",45837:"Skein256-104",45838:"Skein256-112",45839:"Skein256-120",45840:"Skein256-128",45841:"Skein256-136",45842:"Skein256-144",45843:"Skein256-152",45844:"Skein256-160",45845:"Skein256-168",45846:"Skein256-176",45847:"Skein256-184",45848:"Skein256-192",45849:"Skein256-200",45850:"Skein256-208",45851:"Skein256-216",45852:"Skein256-224",45853:"Skein256-232",45854:"Skein256-240",45855:"Skein256-248",45856:"Skein256-256",45857:"Skein512-8",45858:"Skein512-16",45859:"Skein512-24",45860:"Skein512-32",45861:"Skein512-40",45862:"Skein512-48",45863:"Skein512-56",45864:"Skein512-64",45865:"Skein512-72",45866:"Skein512-80",45867:"Skein512-88",45868:"Skein512-96",45869:"Skein512-104",45870:"Skein512-112",45871:"Skein512-120",45872:"Skein512-128",45873:"Skein512-136",45874:"Skein512-144",45875:"Skein512-152",45876:"Skein512-160",45877:"Skein512-168",45878:"Skein512-176",45879:"Skein512-184",45880:"Skein512-192",45881:"Skein512-200",45882:"Skein512-208",45883:"Skein512-216",45884:"Skein512-224",45885:"Skein512-232",45886:"Skein512-240",45887:"Skein512-248",45888:"Skein512-256",45889:"Skein512-264",45890:"Skein512-272",45891:"Skein512-280",45892:"Skein512-288",45893:"Skein512-296",45894:"Skein512-304",45895:"Skein512-312",45896:"Skein512-320",45897:"Skein512-328",45898:"Skein512-336",45899:"Skein512-344",45900:"Skein512-352",45901:"Skein512-360",45902:"Skein512-368",45903:"Skein512-376",45904:"Skein512-384",45905:"Skein512-392",45906:"Skein512-400",45907:"Skein512-408",45908:"Skein512-416",45909:"Skein512-424",45910:"Skein512-432",45911:"Skein512-440",45912:"Skein512-448",45913:"Skein512-456",45914:"Skein512-464",45915:"Skein512-472",45916:"Skein512-480",45917:"Skein512-488",45918:"Skein512-496",45919:"Skein512-504",45920:"Skein512-512",45921:"Skein1024-8",45922:"Skein1024-16",45923:"Skein1024-24",45924:"Skein1024-32",45925:"Skein1024-40",45926:"Skein1024-48",45927:"Skein1024-56",45928:"Skein1024-64",45929:"Skein1024-72",45930:"Skein1024-80",45931:"Skein1024-88",45932:"Skein1024-96",45933:"Skein1024-104",45934:"Skein1024-112",45935:"Skein1024-120",45936:"Skein1024-128",45937:"Skein1024-136",45938:"Skein1024-144",45939:"Skein1024-152",45940:"Skein1024-160",45941:"Skein1024-168",45942:"Skein1024-176",45943:"Skein1024-184",45944:"Skein1024-192",45945:"Skein1024-200",45946:"Skein1024-208",45947:"Skein1024-216",45948:"Skein1024-224",45949:"Skein1024-232",45950:"Skein1024-240",45951:"Skein1024-248",45952:"Skein1024-256",45953:"Skein1024-264",45954:"Skein1024-272",45955:"Skein1024-280",45956:"Skein1024-288",45957:"Skein1024-296",45958:"Skein1024-304",45959:"Skein1024-312",45960:"Skein1024-320",45961:"Skein1024-328",45962:"Skein1024-336",45963:"Skein1024-344",45964:"Skein1024-352",45965:"Skein1024-360",45966:"Skein1024-368",45967:"Skein1024-376",45968:"Skein1024-384",45969:"Skein1024-392",45970:"Skein1024-400",45971:"Skein1024-408",45972:"Skein1024-416",45973:"Skein1024-424",45974:"Skein1024-432",45975:"Skein1024-440",45976:"Skein1024-448",45977:"Skein1024-456",45978:"Skein1024-464",45979:"Skein1024-472",45980:"Skein1024-480",45981:"Skein1024-488",45982:"Skein1024-496",45983:"Skein1024-504",45984:"Skein1024-512",45985:"Skein1024-520",45986:"Skein1024-528",45987:"Skein1024-536",45988:"Skein1024-544",45989:"Skein1024-552",45990:"Skein1024-560",45991:"Skein1024-568",45992:"Skein1024-576",45993:"Skein1024-584",45994:"Skein1024-592",45995:"Skein1024-600",45996:"Skein1024-608",45997:"Skein1024-616",45998:"Skein1024-624",45999:"Skein1024-632",46000:"Skein1024-640",46001:"Skein1024-648",46002:"Skein1024-656",46003:"Skein1024-664",46004:"Skein1024-672",46005:"Skein1024-680",46006:"Skein1024-688",46007:"Skein1024-696",46008:"Skein1024-704",46009:"Skein1024-712",46010:"Skein1024-720",46011:"Skein1024-728",46012:"Skein1024-736",46013:"Skein1024-744",46014:"Skein1024-752",46015:"Skein1024-760",46016:"Skein1024-768",46017:"Skein1024-776",46018:"Skein1024-784",46019:"Skein1024-792",46020:"Skein1024-800",46021:"Skein1024-808",46022:"Skein1024-816",46023:"Skein1024-824",46024:"Skein1024-832",46025:"Skein1024-840",46026:"Skein1024-848",46027:"Skein1024-856",46028:"Skein1024-864",46029:"Skein1024-872",46030:"Skein1024-880",46031:"Skein1024-888",46032:"Skein1024-896",46033:"Skein1024-904",46034:"Skein1024-912",46035:"Skein1024-920",46036:"Skein1024-928",46037:"Skein1024-936",46038:"Skein1024-944",46039:"Skein1024-952",46040:"Skein1024-960",46041:"Skein1024-968",46042:"Skein1024-976",46043:"Skein1024-984",46044:"Skein1024-992",46045:"Skein1024-1000",46046:"Skein1024-1008",46047:"Skein1024-1016",46048:"Skein1024-1024"}),t.defaultLengths=Object.freeze({17:20,18:32,19:64,86:32,23:28,22:32,21:48,20:64,24:32,25:64,26:28,27:32,28:48,29:64,34:32,45569:1,45570:2,45571:3,45572:4,45573:5,45574:6,45575:7,45576:8,45577:9,45578:10,45579:11,45580:12,45581:13,45582:14,45583:15,45584:16,45585:17,45586:18,45587:19,45588:20,45589:21,45590:22,45591:23,45592:24,45593:25,45594:26,45595:27,45596:28,45597:29,45598:30,45599:31,45600:32,45601:33,45602:34,45603:35,45604:36,45605:37,45606:38,45607:39,45608:40,45609:41,45610:42,45611:43,45612:44,45613:45,45614:46,45615:47,45616:48,45617:49,45618:50,45619:51,45620:52,45621:53,45622:54,45623:55,45624:56,45625:57,45626:58,45627:59,45628:60,45629:61,45630:62,45631:63,45632:64,45633:1,45634:2,45635:3,45636:4,45637:5,45638:6,45639:7,45640:8,45641:9,45642:10,45643:11,45644:12,45645:13,45646:14,45647:15,45648:16,45649:17,45650:18,45651:19,45652:20,45653:21,45654:22,45655:23,45656:24,45657:25,45658:26,45659:27,45660:28,45661:29,45662:30,45663:31,45664:32,45825:1,45826:2,45827:3,45828:4,45829:5,45830:6,45831:7,45832:8,45833:9,45834:10,45835:11,45836:12,45837:13,45838:14,45839:15,45840:16,45841:17,45842:18,45843:19,45844:20,45845:21,45846:22,45847:23,45848:24,45849:25,45850:26,45851:27,45852:28,45853:29,45854:30,45855:31,45856:32,45857:1,45858:2,45859:3,45860:4,45861:5,45862:6,45863:7,45864:8,45865:9,45866:10,45867:11,45868:12,45869:13,45870:14,45871:15,45872:16,45873:17,45874:18,45875:19,45876:20,45877:21,45878:22,45879:23,45880:24,45881:25,45882:26,45883:27,45884:28,45885:29,45886:30,45887:31,45888:32,45889:33,45890:34,45891:35,45892:36,45893:37,45894:38,45895:39,45896:40,45897:41,45898:42,45899:43,45900:44,45901:45,45902:46,45903:47,45904:48,45905:49,45906:50,45907:51,45908:52,45909:53,45910:54,45911:55,45912:56,45913:57,45914:58,45915:59,45916:60,45917:61,45918:62,45919:63,45920:64,45921:1,45922:2,45923:3,45924:4,45925:5,45926:6,45927:7,45928:8,45929:9,45930:10,45931:11,45932:12,45933:13,45934:14,45935:15,45936:16,45937:17,45938:18,45939:19,45940:20,45941:21,45942:22,45943:23,45944:24,45945:25,45946:26,45947:27,45948:28,45949:29,45950:30,45951:31,45952:32,45953:33,45954:34,45955:35,45956:36,45957:37,45958:38,45959:39,45960:40,45961:41,45962:42,45963:43,45964:44,45965:45,45966:46,45967:47,45968:48,45969:49,45970:50,45971:51,45972:52,45973:53,45974:54,45975:55,45976:56,45977:57,45978:58,45979:59,45980:60,45981:61,45982:62,45983:63,45984:64,45985:65,45986:66,45987:67,45988:68,45989:69,45990:70,45991:71,45992:72,45993:73,45994:74,45995:75,45996:76,45997:77,45998:78,45999:79,46000:80,46001:81,46002:82,46003:83,46004:84,46005:85,46006:86,46007:87,46008:88,46009:89,46010:90,46011:91,46012:92,46013:93,46014:94,46015:95,46016:96,46017:97,46018:98,46019:99,46020:100,46021:101,46022:102,46023:103,46024:104,46025:105,46026:106,46027:107,46028:108,46029:109,46030:110,46031:111,46032:112,46033:113,46034:114,46035:115,46036:116,46037:117,46038:118,46039:119,46040:120,46041:121,46042:122,46043:123,46044:124,46045:125,46046:126,46047:127,46048:128})},function(e,t,r){"use strict";(function(n){const i=r(650);(t=e.exports=s).encode=function(e,t){const r=a(e);return s(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=a(t);return r.name,n.from(r.decode(e.toString()))},t.isEncoded=function(e){n.isBuffer(e)&&(e=e.toString());const t=e.substring(0,1);try{const r=a(t);return r.name}catch(e){return!1}};const o=new Error("Unsupported encoding");function s(e,t){if(!t)throw new Error("requires an encoded buffer");const r=a(e),i=n.from(r.code);return function(e,t){a(e).decode(t.toString())}(r.name,t),n.concat([i,t])}function a(e){let t;if(i.names[e])t=i.names[e];else{if(!i.codes[e])throw o;t=i.codes[e]}if(!t.isImplemented())throw new Error("Base "+e+" is not implemented yet");return t}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(152),i=r(344).varintBufferEncode,o={};e.exports=o;for(let e in n){let t=n[e];o[e]=i(t)}},function(e,t,r){"use strict";(function(t){const n=r(20);function i(e){return parseInt(e.toString("hex"),16)}function o(e){let r=e.toString(16);return r.length%2==1&&(r="0"+r),t.from(r,"hex")}e.exports={numberToBuffer:o,bufferToNumber:i,varintBufferEncode:function(e){return t.from(n.encode(i(e)))},varintBufferDecode:function(e){return o(n.decode(e))}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(152),i={};e.exports=i;for(let e in n){i[n[e].toString("hex")]=e}},function(e,t){e.exports=function(e,t,r){e(t),r&&r(!0===t?null:t)}},function(e,t,r){"use strict";var n=r(346);e.exports=function(e,t){return function(r,i){if(r)return n(i,r,t);if(null!=e){var o=e;e=null,i(null,o)}else i(!0)}}},function(e,t,r){"use strict";function n(e){return e}var i=r(119);e.exports=function(e){return e?(e=i(e),function(t){return function(r,n){t(r,function(r,i){try{i=r?null:e(i)}catch(e){return t(e,function(){return n(e)})}n(r,i)})}}):n}},function(e,t,r){var n=r(119);function i(e){return e}e.exports=function(e){return"object"==typeof e&&"function"==typeof e.test?function(t){return e.test(t)}:n(e)||i}},function(e,t,r){"use strict";e.exports=function(e,t){var r=!1;function n(e){!r&&t&&(r=!0,t(!0===e?null:e))}return function(t){return function(r,i){return r&&n(r),t(r,function(t,r){t?n(t):e&&e(r),i(t,r)})}}}},function(e,t,r){"use strict";function n(e){return e}var i=r(119),o=r(120);e.exports=function(e,t){e=i(e)||n;var r={};return o(function(n){var i=e(n);return r[i]?!!t:(r[i]=!0,!t)})}},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)(e),u=function(e){if(e)return r(e);var n=(0,i.default)(arguments,1);if(t.apply(this,n))return a(u);r.apply(null,[null].concat(n))};a(u)};var n=a(r(54)),i=a(r(102)),o=a(r(103)),s=a(r(34));function a(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return function(){var t=(0,n.default)(arguments),r=t.pop();e.call(this,t,r)}};var n=function(e){return e&&e.__esModule?e:{default:e}}(r(102));e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){r=r||n.default;var a=(0,i.default)(t)?[]:{};e(t,function(e,t,r){(0,s.default)(e)(function(e,n){arguments.length>2&&(n=(0,o.default)(arguments,1)),a[t]=n,r(e)})},function(e){r(e,a)})};var n=a(r(54)),i=a(r(89)),o=a(r(102)),s=a(r(34));function a(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default},function(e,t,r){(function(t){var r="object"==typeof t&&t&&t.Object===Object&&t;e.exports=r}).call(this,r(6))},function(e,t){var r=9007199254740991;e.exports=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=r}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,o){(0,n.default)(t)(e,(0,i.default)(r),o)};var n=o(r(358)),i=o(r(34));function o(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return function(t,r,u){if(u=(0,i.default)(u||n.default),e<=0||!t)return u(null);var c=(0,o.default)(t),f=!1,l=0,h=!1;function p(e,t){if(l-=1,e)f=!0,u(e);else{if(t===a.default||f&&l<=0)return f=!0,u(null);h||d()}}function d(){for(h=!0;l-1&&e%1==0&&e1&&this._buf[this._buf.length-1]===s;)this._buf=this._buf.slice(0,-1)}less(e){const t=this.list(),r=e.list();for(let e=0;ei)return!1}return t.length>>((3&t)<<3)&255;return i}}},function(e,t){for(var r=[],n=0;n<256;++n)r[n]=(n+256).toString(16).substr(1);e.exports=function(e,t){var n=t||0,i=r;return[i[e[n++]],i[e[n++]],i[e[n++]],i[e[n++]],"-",i[e[n++]],i[e[n++]],"-",i[e[n++]],i[e[n++]],"-",i[e[n++]],i[e[n++]],"-",i[e[n++]],i[e[n++]],i[e[n++]],i[e[n++]],i[e[n++]],i[e[n++]]].join("")}},function(e,t){t.endianness=function(){return"LE"},t.hostname=function(){return"undefined"!=typeof location?location.hostname:""},t.loadavg=function(){return[]},t.uptime=function(){return 0},t.freemem=function(){return Number.MAX_VALUE},t.totalmem=function(){return Number.MAX_VALUE},t.cpus=function(){return[]},t.type=function(){return"Browser"},t.release=function(){return"undefined"!=typeof navigator?navigator.appVersion:""},t.networkInterfaces=t.getNetworkInterfaces=function(){return{}},t.arch=function(){return"javascript"},t.platform=function(){return"browser"},t.tmpdir=t.tmpDir=function(){return"/tmp"},t.EOL="\n",t.homedir=function(){return"/"}},function(e,t,r){"use strict";const n=r(370),i=r(35).Key,o=r(709),s=t.PREFIX="/repo/flatfs/shard/",a=t.SHARDING_FN="SHARDING";t.README_FN="_README";class u{constructor(e){this.param=e}fun(e){throw new Error("implement me")}toString(){return`${s}v1/${this.name}/${this.param}`}}class c extends u{constructor(e){super(e),this._padding=n("",e,"_"),this.name="prefix"}fun(e){return(e+this._padding).slice(0,this.param)}}class f extends u{constructor(e){super(e),this._padding=n("",e,"_"),this.name="suffix"}fun(e){const t=this._padding+e;return t.slice(t.length-this.param)}}class l extends u{constructor(e){super(e),this._padding=n("",e+1,"_"),this.name="next-to-last"}fun(e){const t=this._padding+e,r=t.length-this.param-1;return t.slice(r,r+this.param)}}function h(e){if(0===(e=e.trim()).length)throw new Error("empty shard string");if(!e.startsWith(s))throw new Error(`invalid or no path prefix: ${e}`);const t=e.slice(s.length).split("/"),r=t[0];if("v1"!==r)throw new Error(`expect 'v1' version, got '${r}'`);const n=t[1];if(!t[2])throw new Error("missing param");const i=parseInt(t[2],10);switch(n){case"prefix":return new c(i);case"suffix":return new f(i);case"next-to-last":return new l(i);default:throw new Error(`unkown sharding function: ${n}`)}}t.readShardFun=((e,t,r)=>{const n=new i(e).child(new i(a));("function"==typeof t.getRaw?t.getRaw.bind(t):t.get.bind(t))(n,(e,t)=>{if(e)return r(e);let n;try{n=h((t||"").toString().trim())}catch(e){return r(e)}r(null,n)})}),t.readme=o,t.parseShardFun=h,t.Prefix=c,t.Suffix=f,t.NextToLast=l},function(e,t,r){"use strict";e.exports=function(e,t,r){if((t-=(e+="").length)<=0)return e;if(r||0===r||(r=" ")," "==(r+="")&&t<10)return n[t]+e;for(var i="";1&t&&(i+=r),t>>=1;)r+=r;return i+e};var n=[""," "," "," "," "," "," "," "," "," "]},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=o(r(715)),i=o(r(164));function o(e){return e&&e.__esModule?e:{default:e}}t.default=(0,i.default)(n.default),e.exports=t.default},function(e,t,r){t.AbstractLevelDOWN=r(721),t.AbstractIterator=r(373),t.AbstractChainedBatch=r(374)},function(e,t,r){(function(t){function r(e){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.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(7))},function(e,t,r){(function(t){function r(e){this._db=e,this._operations=[],this._written=!1}r.prototype._serializeKey=function(e){return this._db._serializeKey(e)},r.prototype._serializeValue=function(e){return this._db._serializeValue(e)},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,"key");if(r)throw r;return e=this._serializeKey(e),t=this._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,"key");if(t)throw t;return e=this._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._operations=[],this._clear(),this},r.prototype._clear=function(){},r.prototype.write=function(e,r){if(this._checkWritten(),"function"==typeof e&&(r=e),"function"!=typeof r)throw new Error("write() requires a callback argument");return"object"!=typeof e&&(e={}),this._written=!0,"function"==typeof this._write?this._write(r):"function"==typeof this._db._batch?this._db._batch(this._operations,e,r):void t.nextTick(r)},e.exports=r}).call(this,r(7))},function(e,t,r){var n=r(376).create,i=n("LevelUPError"),o=n("NotFoundError",i);o.prototype.notFound=!0,o.prototype.status=404,e.exports={LevelUPError:i,InitializationError:n("InitializationError",i),OpenError:n("OpenError",i),ReadError:n("ReadError",i),WriteError:n("WriteError",i),NotFoundError:o,EncodingError:n("EncodingError",i)}},function(e,t,r){var n=e.exports.all=[{errno:-2,code:"ENOENT",description:"no such file or directory"},{errno:-1,code:"UNKNOWN",description:"unknown error"},{errno:0,code:"OK",description:"success"},{errno:1,code:"EOF",description:"end of file"},{errno:2,code:"EADDRINFO",description:"getaddrinfo error"},{errno:3,code:"EACCES",description:"permission denied"},{errno:4,code:"EAGAIN",description:"resource temporarily unavailable"},{errno:5,code:"EADDRINUSE",description:"address already in use"},{errno:6,code:"EADDRNOTAVAIL",description:"address not available"},{errno:7,code:"EAFNOSUPPORT",description:"address family not supported"},{errno:8,code:"EALREADY",description:"connection already in progress"},{errno:9,code:"EBADF",description:"bad file descriptor"},{errno:10,code:"EBUSY",description:"resource busy or locked"},{errno:11,code:"ECONNABORTED",description:"software caused connection abort"},{errno:12,code:"ECONNREFUSED",description:"connection refused"},{errno:13,code:"ECONNRESET",description:"connection reset by peer"},{errno:14,code:"EDESTADDRREQ",description:"destination address required"},{errno:15,code:"EFAULT",description:"bad address in system call argument"},{errno:16,code:"EHOSTUNREACH",description:"host is unreachable"},{errno:17,code:"EINTR",description:"interrupted system call"},{errno:18,code:"EINVAL",description:"invalid argument"},{errno:19,code:"EISCONN",description:"socket is already connected"},{errno:20,code:"EMFILE",description:"too many open files"},{errno:21,code:"EMSGSIZE",description:"message too long"},{errno:22,code:"ENETDOWN",description:"network is down"},{errno:23,code:"ENETUNREACH",description:"network is unreachable"},{errno:24,code:"ENFILE",description:"file table overflow"},{errno:25,code:"ENOBUFS",description:"no buffer space available"},{errno:26,code:"ENOMEM",description:"not enough memory"},{errno:27,code:"ENOTDIR",description:"not a directory"},{errno:28,code:"EISDIR",description:"illegal operation on a directory"},{errno:29,code:"ENONET",description:"machine is not on the network"},{errno:31,code:"ENOTCONN",description:"socket is not connected"},{errno:32,code:"ENOTSOCK",description:"socket operation on non-socket"},{errno:33,code:"ENOTSUP",description:"operation not supported on socket"},{errno:34,code:"ENOENT",description:"no such file or directory"},{errno:35,code:"ENOSYS",description:"function not implemented"},{errno:36,code:"EPIPE",description:"broken pipe"},{errno:37,code:"EPROTO",description:"protocol error"},{errno:38,code:"EPROTONOSUPPORT",description:"protocol not supported"},{errno:39,code:"EPROTOTYPE",description:"protocol wrong type for socket"},{errno:40,code:"ETIMEDOUT",description:"connection timed out"},{errno:41,code:"ECHARSET",description:"invalid Unicode character"},{errno:42,code:"EAIFAMNOSUPPORT",description:"address family for hostname not supported"},{errno:44,code:"EAISERVICE",description:"servname not supported for ai_socktype"},{errno:45,code:"EAISOCKTYPE",description:"ai_socktype not supported"},{errno:46,code:"ESHUTDOWN",description:"cannot send after transport endpoint shutdown"},{errno:47,code:"EEXIST",description:"file already exists"},{errno:48,code:"ESRCH",description:"no such process"},{errno:49,code:"ENAMETOOLONG",description:"name too long"},{errno:50,code:"EPERM",description:"operation not permitted"},{errno:51,code:"ELOOP",description:"too many symbolic links encountered"},{errno:52,code:"EXDEV",description:"cross-device link not permitted"},{errno:53,code:"ENOTEMPTY",description:"directory not empty"},{errno:54,code:"ENOSPC",description:"no space left on device"},{errno:55,code:"EIO",description:"i/o error"},{errno:56,code:"EROFS",description:"read-only file system"},{errno:57,code:"ENODEV",description:"no such device"},{errno:58,code:"ESPIPE",description:"invalid seek"},{errno:59,code:"ECANCELED",description:"operation canceled"}];e.exports.errno={},e.exports.code={},n.forEach(function(t){e.exports.errno[t.errno]=t,e.exports.code[t.code]=t}),e.exports.custom=r(725)(e.exports),e.exports.create=e.exports.custom.createError},function(e,t){e.exports=function(){var e,t=new Promise(function(t,r){e=function(e,n){e?r(e):t(n)}});return e.promise=t,e}},function(e,t,r){(function(t){function r(e){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.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(7))},function(e,t,r){(function(t){function r(e){this._db=e,this._operations=[],this._written=!1}r.prototype._serializeKey=function(e){return this._db._serializeKey(e)},r.prototype._serializeValue=function(e){return this._db._serializeValue(e)},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,"key");if(r)throw r;return e=this._serializeKey(e),t=this._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,"key");if(t)throw t;return e=this._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._operations=[],this._clear(),this},r.prototype._clear=function(){},r.prototype.write=function(e,r){if(this._checkWritten(),"function"==typeof e&&(r=e),"function"!=typeof r)throw new Error("write() requires a callback argument");return"object"!=typeof e&&(e={}),this._written=!0,"function"==typeof this._write?this._write(r):"function"==typeof this._db._batch?this._db._batch(this._operations,e,r):void t.nextTick(r)},e.exports=r}).call(this,r(7))},function(e,t,r){t.AbstractLevelDOWN=r(381),t.AbstractIterator=r(382),t.AbstractChainedBatch=r(383),t.isLevelDOWN=r(733)},function(e,t,r){(function(t,n){var i=r(26),o=r(382),s=r(383);function a(e){if(!arguments.length||void 0===e)throw new Error("constructor requires at least a location argument");if("string"!=typeof e)throw new Error("constructor requires a location string argument");this.location=e,this.status="new"}a.prototype.open=function(e,r){var n=this,i=this.status;if("function"==typeof e&&(r=e),"function"!=typeof r)throw new Error("open() requires a callback argument");"object"!=typeof e&&(e={}),e.createIfMissing=0!=e.createIfMissing,e.errorIfExists=!!e.errorIfExists,"function"==typeof this._open?(this.status="opening",this._open(e,function(e){if(e)return n.status=i,r(e);n.status="open",r()})):(this.status="open",t.nextTick(r))},a.prototype.close=function(e){var r=this,n=this.status;if("function"!=typeof e)throw new Error("close() requires a callback argument");"function"==typeof this._close?(this.status="closing",this._close(function(t){if(t)return r.status=n,e(t);r.status="closed",e()})):(this.status="closed",t.nextTick(e))},a.prototype.get=function(e,r,n){var i;if("function"==typeof r&&(n=r),"function"!=typeof n)throw new Error("get() requires a callback argument");return(i=this._checkKey(e,"key",this._isBuffer))?n(i):(this._isBuffer(e)||(e=String(e)),"object"!=typeof r&&(r={}),r.asBuffer=0!=r.asBuffer,"function"==typeof this._get?this._get(e,r,n):void t.nextTick(function(){n(new Error("NotFound"))}))},a.prototype.put=function(e,r,n,i){var o;if("function"==typeof n&&(i=n),"function"!=typeof i)throw new Error("put() requires a callback argument");return(o=this._checkKey(e,"key",this._isBuffer))?i(o):(this._isBuffer(e)||(e=String(e)),null==r||this._isBuffer(r)||t.browser||(r=String(r)),"object"!=typeof n&&(n={}),"function"==typeof this._put?this._put(e,r,n,i):void t.nextTick(i))},a.prototype.del=function(e,r,n){var i;if("function"==typeof r&&(n=r),"function"!=typeof n)throw new Error("del() requires a callback argument");return(i=this._checkKey(e,"key",this._isBuffer))?n(i):(this._isBuffer(e)||(e=String(e)),"object"!=typeof r&&(r={}),"function"==typeof this._del?this._del(e,r,n):void t.nextTick(n))},a.prototype.batch=function(e,r,n){if(!arguments.length)return this._chainedBatch();if("function"==typeof r&&(n=r),"function"==typeof e&&(n=e),"function"!=typeof n)throw new Error("batch(array) requires a callback argument");if(!Array.isArray(e))return n(new Error("batch(array) requires an array argument"));r&&"object"==typeof r||(r={});for(var i,o,s=0,a=e.length;s{const r=e+"/"+s;o("locking %s",r),a[r]=!0;const n={close(e){a[r]&&delete a[r],i(e)}};i(()=>{t(null,n)})}),t.locked=((e,t)=>{const r=e+"/"+s;o("checking lock: %s");const n=a[r];i(()=>{t(null,n)})})},function(e,t){e.exports=function(e){var t,r=!1;Math.random();function n(n){if(!n)throw new Error("must be passed a readable");t=n,r&&e(t)}return n.resolve=n.ready=n.start=function(i){return r=!0,e=i||e,t&&e(t),n},n}},function(e,t,r){var n=r(161),i=r(385);e.exports=function(){var e=n(),t=i();return{source:e,sink:t,resolve:function(r){e.resolve(r.source),t.resolve(r.sink)}}}},function(e,t,r){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t){e.exports=function(e){return e&&"function"==typeof e.then}},function(e,t,r){(function(t){var r="Input must be an string, Buffer or Uint8Array";function n(e){return(4294967296+e).toString(16).substring(1)}e.exports={normalizeInput:function(e){var n;if(e instanceof Uint8Array)n=e;else if(e instanceof t)n=new Uint8Array(e);else{if("string"!=typeof e)throw new Error(r);n=new Uint8Array(t.from(e,"utf8"))}return n},toHex:function(e){return Array.prototype.map.call(e,function(e){return(e<16?"0":"")+e.toString(16)}).join("")},debugPrint:function(e,t,r){for(var i="\n"+e+" = ",o=0;o{n([t=>o.deserialize(e,t),(e,n)=>{if(!t)return r(null,{value:e,remainderPath:""});const i=t.split("/");if("Links"===i[0]){let t="";if(!i[1])return n(null,{value:e.links.map(e=>e.toJSON()),remainderPath:""});const r={};e.links.forEach((e,t)=>{const n=e.toJSON();r[t]=r[n.name]={hash:n.multihash,name:n.name,size:n.size}});let o=r[i[1]];"Hash"===i[2]?o={"/":o.hash}:"Tsize"===i[2]?o={"/":o.size}:"Name"===i[2]&&(o={"/":o.name}),n(null,{value:o,remainderPath:t=i.slice(3).join("/")})}else if("Data"===i[0])n(null,{value:e.data,remainderPath:""});else{const t={};e.links.forEach((e,r)=>{const n=e.toJSON();t[n.name]={hash:n.multihash,name:n.name,size:n.size}});const r=t[i[0]];if(r)return n(null,{value:{"/":r.hash},remainderPath:i.slice(1).join("/")});n(new Error("path not available"))}}],r)}),t.tree=((e,t,r)=>{"function"==typeof t&&(r=t,t={}),t=t||{},o.deserialize(e,(e,t)=>{if(e)return r(e);const n=[];n.push("Links"),t.links.forEach((e,t)=>{n.push(`Links/${t}/Name`),n.push(`Links/${t}/Tsize`),n.push(`Links/${t}/Hash`)}),n.push("Data"),r(null,n)})}),t.isLink=((e,r,n)=>{t.resolve(e,r,(e,t)=>{if(e)return n(e);if(t.remainderPath.length>0)return n(new Error("path out of scope"));if("object"==typeof t.value&&t.value["/"]){let r;try{r=i.isCID(new i(t.value["/"]))}catch(e){r=!1}if(r)return n(null,t.value)}n(null,!1)})})},function(e,t,r){"use strict";t.util=r(392),t.resolver=r(396)},function(e,t,r){"use strict";(function(n){const i=r(770),o=r(65),s=r(9),a=r(4),u=r(3),c=r(774),f=r(396),l=42;const h=new i.Decoder({tags:{[l]:e=>({"/":e=e.slice(1)})}});function p(e){let t;try{t=c(e)}catch(e){t=!1}if(t)throw new Error("The object passed has circular references");return function e(t){if(!t||n.isBuffer(t)||"string"==typeof t)return t;if(Array.isArray(t))return t.map(e);const r=Object.keys(t);if(1===r.length&&"/"===r[0])return function(e){return"string"==typeof e&&(e=new s(e).buffer),new i.Tagged(l,n.concat([n.from("00","hex"),e]))}(t["/"]);if(r.length>0){let n={};return r.forEach(r=>{"object"==typeof t[r]?n[r]=e(t[r]):n[r]=t[r]}),n}return t}(e)}(t=e.exports).serialize=((e,t)=>{let r;try{const n=p(e);r=i.encode(n)}catch(e){return u(()=>t(e))}u(()=>t(null,r))}),t.deserialize=((e,t)=>{let r;try{r=h.decodeFirst(e)}catch(e){return u(()=>t(e))}u(()=>t(null,r))}),t.cid=((e,r,n)=>{"function"==typeof r&&(n=r,r={});const i=(r=r||{}).hashAlg||f.defaultHashAlg,u=void 0===r.version?1:r.version;a([r=>t.serialize(e,r),(e,t)=>o(e,i,t),(e,t)=>t(null,new s(u,f.multicodec,e))],n)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t,n){const i=r(335),o=r(169),s=r(772),a=r(228),u=r(170),c=r(394),f=r(395),l=r(33);class h{constructor(e){!(e=e||{}).size||e.size<65536?e.size=65536:e.size=a.nextPowerOf2(e.size),this._heap=new ArrayBuffer(e.size),this._heap8=new Uint8Array(this._heap),this._reset(),this._knownTags=Object.assign({0:e=>new Date(e),1:e=>new Date(1e3*e),2:e=>a.arrayBufferToBignumber(e),3:e=>u.NEG_ONE.minus(a.arrayBufferToBignumber(e)),4:e=>u.TEN.pow(e[0]).times(e[1]),5:e=>u.TWO.pow(e[0]).times(e[1]),32:e=>l.parse(e),35:e=>new RegExp(e)},e.tags),this.parser=s(t,{log:console.log.bind(console),pushInt:this.pushInt.bind(this),pushInt32:this.pushInt32.bind(this),pushInt32Neg:this.pushInt32Neg.bind(this),pushInt64:this.pushInt64.bind(this),pushInt64Neg:this.pushInt64Neg.bind(this),pushFloat:this.pushFloat.bind(this),pushFloatSingle:this.pushFloatSingle.bind(this),pushFloatDouble:this.pushFloatDouble.bind(this),pushTrue:this.pushTrue.bind(this),pushFalse:this.pushFalse.bind(this),pushUndefined:this.pushUndefined.bind(this),pushNull:this.pushNull.bind(this),pushInfinity:this.pushInfinity.bind(this),pushInfinityNeg:this.pushInfinityNeg.bind(this),pushNaN:this.pushNaN.bind(this),pushNaNNeg:this.pushNaNNeg.bind(this),pushArrayStart:this.pushArrayStart.bind(this),pushArrayStartFixed:this.pushArrayStartFixed.bind(this),pushArrayStartFixed32:this.pushArrayStartFixed32.bind(this),pushArrayStartFixed64:this.pushArrayStartFixed64.bind(this),pushObjectStart:this.pushObjectStart.bind(this),pushObjectStartFixed:this.pushObjectStartFixed.bind(this),pushObjectStartFixed32:this.pushObjectStartFixed32.bind(this),pushObjectStartFixed64:this.pushObjectStartFixed64.bind(this),pushByteString:this.pushByteString.bind(this),pushByteStringStart:this.pushByteStringStart.bind(this),pushUtf8String:this.pushUtf8String.bind(this),pushUtf8StringStart:this.pushUtf8StringStart.bind(this),pushSimpleUnassigned:this.pushSimpleUnassigned.bind(this),pushTagUnassigned:this.pushTagUnassigned.bind(this),pushTagStart:this.pushTagStart.bind(this),pushTagStart4:this.pushTagStart4.bind(this),pushTagStart8:this.pushTagStart8.bind(this),pushBreak:this.pushBreak.bind(this)},this._heap)}get _depth(){return this._parents.length}get _currentParent(){return this._parents[this._depth-1]}get _ref(){return this._currentParent.ref}_closeParent(){var e=this._parents.pop();if(e.length>0)throw new Error(`Missing ${e.length} elements`);switch(e.type){case u.PARENT.TAG:this._push(this.createTag(e.ref[0],e.ref[1]));break;case u.PARENT.BYTE_STRING:this._push(this.createByteString(e.ref,e.length));break;case u.PARENT.UTF8_STRING:this._push(this.createUtf8String(e.ref,e.length));break;case u.PARENT.MAP:if(e.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createMap(e.ref,e.length));break;case u.PARENT.OBJECT:if(e.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createObject(e.ref,e.length));break;case u.PARENT.ARRAY:this._push(this.createArray(e.ref,e.length))}this._currentParent&&this._currentParent.type===u.PARENT.TAG&&this._dec()}_dec(){const e=this._currentParent;e.length<0||(e.length--,0===e.length&&this._closeParent())}_push(e,t){const r=this._currentParent;switch(r.values++,r.type){case u.PARENT.ARRAY:case u.PARENT.BYTE_STRING:case u.PARENT.UTF8_STRING:r.length>-1?this._ref[this._ref.length-r.length]=e:this._ref.push(e),this._dec();break;case u.PARENT.OBJECT:null!=r.tmpKey?(this._ref[r.tmpKey]=e,r.tmpKey=null,this._dec()):(r.tmpKey=e,"string"!=typeof r.tmpKey&&(r.type=u.PARENT.MAP,r.ref=a.buildMap(r.ref)));break;case u.PARENT.MAP:null!=r.tmpKey?(this._ref.set(r.tmpKey,e),r.tmpKey=null,this._dec()):r.tmpKey=e;break;case u.PARENT.TAG:this._ref.push(e),t||this._dec();break;default:throw new Error("Unknown parent type")}}_createParent(e,t,r){this._parents[this._depth]={type:t,length:r,ref:e,values:0,tmpKey:null}}_reset(){this._res=[],this._parents=[{type:u.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(e,t){const r=this._knownTags[e];return r?r(t):new f(e,t)}createMap(e,t){return e}createObject(e,t){return e}createArray(e,t){return e}createByteString(e,t){return n.concat(e)}createByteStringFromHeap(e,t){return e===t?n.alloc(0):n.from(this._heap.slice(e,t))}createInt(e){return e}createInt32(e,t){return a.buildInt32(e,t)}createInt64(e,t,r,n){return a.buildInt64(e,t,r,n)}createFloat(e){return e}createFloatSingle(e,t,r,n){return i.read([e,t,r,n],0,!1,23,4)}createFloatDouble(e,t,r,n,o,s,a,u){return i.read([e,t,r,n,o,s,a,u],0,!1,52,8)}createInt32Neg(e,t){return-1-a.buildInt32(e,t)}createInt64Neg(e,t,r,n){const i=a.buildInt32(e,t),s=a.buildInt32(r,n);return i>u.MAX_SAFE_HIGH?u.NEG_ONE.minus(new o(i).times(u.SHIFT32).plus(s)):-1-(i*u.SHIFT32+s)}createTrue(){return!0}createFalse(){return!1}createNull(){return null}createUndefined(){}createInfinity(){return 1/0}createInfinityNeg(){return-1/0}createNaN(){return NaN}createNaNNeg(){return NaN}createUtf8String(e,t){return e.join("")}createUtf8StringFromHeap(e,t){return e===t?"":n.from(this._heap.slice(e,t)).toString("utf8")}createSimpleUnassigned(e){return new c(e)}pushInt(e){this._push(this.createInt(e))}pushInt32(e,t){this._push(this.createInt32(e,t))}pushInt64(e,t,r,n){this._push(this.createInt64(e,t,r,n))}pushFloat(e){this._push(this.createFloat(e))}pushFloatSingle(e,t,r,n){this._push(this.createFloatSingle(e,t,r,n))}pushFloatDouble(e,t,r,n,i,o,s,a){this._push(this.createFloatDouble(e,t,r,n,i,o,s,a))}pushInt32Neg(e,t){this._push(this.createInt32Neg(e,t))}pushInt64Neg(e,t,r,n){this._push(this.createInt64Neg(e,t,r,n))}pushTrue(){this._push(this.createTrue())}pushFalse(){this._push(this.createFalse())}pushNull(){this._push(this.createNull())}pushUndefined(){this._push(this.createUndefined())}pushInfinity(){this._push(this.createInfinity())}pushInfinityNeg(){this._push(this.createInfinityNeg())}pushNaN(){this._push(this.createNaN())}pushNaNNeg(){this._push(this.createNaNNeg())}pushArrayStart(){this._createParent([],u.PARENT.ARRAY,-1)}pushArrayStartFixed(e){this._createArrayStartFixed(e)}pushArrayStartFixed32(e,t){const r=a.buildInt32(e,t);this._createArrayStartFixed(r)}pushArrayStartFixed64(e,t,r,n){const i=a.buildInt64(e,t,r,n);this._createArrayStartFixed(i)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(e){this._createObjectStartFixed(e)}pushObjectStartFixed32(e,t){const r=a.buildInt32(e,t);this._createObjectStartFixed(r)}pushObjectStartFixed64(e,t,r,n){const i=a.buildInt64(e,t,r,n);this._createObjectStartFixed(i)}pushByteStringStart(){this._parents[this._depth]={type:u.PARENT.BYTE_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushByteString(e,t){this._push(this.createByteStringFromHeap(e,t))}pushUtf8StringStart(){this._parents[this._depth]={type:u.PARENT.UTF8_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushUtf8String(e,t){this._push(this.createUtf8StringFromHeap(e,t))}pushSimpleUnassigned(e){this._push(this.createSimpleUnassigned(e))}pushTagStart(e){this._parents[this._depth]={type:u.PARENT.TAG,length:1,ref:[e]}}pushTagStart4(e,t){this.pushTagStart(a.buildInt32(e,t))}pushTagStart8(e,t,r,n){this.pushTagStart(a.buildInt64(e,t,r,n))}pushTagUnassigned(e){this._push(this.createTag(e))}pushBreak(){if(this._currentParent.length>-1)throw new Error("Unexpected break");this._closeParent()}_createObjectStartFixed(e){0!==e?this._createParent({},u.PARENT.OBJECT,e):this._push(this.createObject({}))}_createArrayStartFixed(e){0!==e?this._createParent(new Array(e),u.PARENT.ARRAY,e):this._push(this.createArray([]))}_decode(e){if(0===e.byteLength)throw new Error("Input too short");this._reset(),this._heap8.set(e);const t=this.parser.parse(e.byteLength);if(this._depth>1){for(;0===this._currentParent.length;)this._closeParent();if(this._depth>1)throw new Error("Undeterminated nesting")}if(t>0)throw new Error("Failed to parse");if(0===this._res.length)throw new Error("No valid result")}decodeFirst(e){return this._decode(e),this._res[0]}decodeAll(e){return this._decode(e),this._res}static decode(e,t){return"string"==typeof e&&(e=n.from(e,t||"hex")),new h({size:e.length}).decodeFirst(e)}static decodeAll(e,t){return"string"==typeof e&&(e=n.from(e,t||"hex")),new h({size:e.length}).decodeAll(e)}}h.decodeFirst=h.decode,e.exports=h}).call(this,r(6),r(0).Buffer)},function(e,t,r){"use strict";const n=r(170),i=n.MT,o=n.SIMPLE,s=n.SYMS;class a{constructor(e){if("number"!=typeof e)throw new Error("Invalid Simple type: "+typeof e);if(e<0||e>255||(0|e)!==e)throw new Error("value must be a small positive integer: "+e);this.value=e}toString(){return"simple("+this.value+")"}inspect(){return"simple("+this.value+")"}encodeCBOR(e){return e._pushInt(this.value,i.SIMPLE_FLOAT)}static isSimple(e){return e instanceof a}static decode(e,t){switch(null==t&&(t=!0),e){case o.FALSE:return!1;case o.TRUE:return!0;case o.NULL:return t?null:s.NULL;case o.UNDEFINED:return t?void 0:s.UNDEFINED;case-1:if(!t)throw new Error("Invalid BREAK");return s.BREAK;default:return new a(e)}}}e.exports=a},function(e,t,r){"use strict";class n{constructor(e,t,r){if(this.tag=e,this.value=t,this.err=r,"number"!=typeof this.tag)throw new Error("Invalid tag type ("+typeof this.tag+")");if(this.tag<0||(0|this.tag)!==this.tag)throw new Error("Tag must be a positive integer: "+this.tag)}toString(){return`${this.tag}(${JSON.stringify(this.value)})`}encodeCBOR(e){return e._pushTag(this.tag),e.pushAny(this.value)}convert(e){var t,r;if("function"!=typeof(r=null!=e?e[this.tag]:void 0)&&"function"!=typeof(r=n["_tag"+this.tag]))return this;try{return r.call(n,this.value)}catch(e){return t=e,this.err=t,this}}}e.exports=n},function(e,t,r){"use strict";(function(n){const i=r(392),o=r(397);(t=e.exports).multicodec="dag-cbor",t.defaultHashAlg="sha2-256",t.resolve=((e,t,r)=>{"function"==typeof t&&(r=t,t=void 0),i.deserialize(e,(e,i)=>{if(e)return r(e);if(!t||"/"===t)return r(null,{value:i,remainderPath:""});const s=t.split("/"),a=o(i).get(s);if(a)return r(null,{value:a,remainderPath:""});let u,c=s.length;for(let e=0;e{"function"==typeof t&&(r=t,t=void 0),t=t||{},i.deserialize(e,(e,t)=>{if(e)return r(e);const n=function(e,t){return t=t||"/",0===Object.keys(e).length?[]:o(e).reduce(function(e,r){"object"==typeof r&&r["/"]&&this.update(void 0);const n=this.path.join(t);return""!==n&&e.push({path:n,value:r}),e},[])}(t).map(e=>e.path);r(null,n)})}),t.isLink=((e,r,n)=>{t.resolve(e,r,(e,t)=>e?n(e):t.remainderPath.length>0?n(new Error("path out of scope")):void("object"==typeof t.value&&t.value["/"]?n(null,t.value):n(null,!1)))})}).call(this,r(0).Buffer)},function(e,t){var r=e.exports=function(e){return new n(e)};function n(e){this.value=e}function i(e,t,r){var n=[],i=[],a=!0;return function e(l){var h={},p=!0,d={node:r?o(l):l,node_:l,path:[].concat(n),parent:i[i.length-1],parents:i,key:n.slice(-1)[0],isRoot:0===n.length,level:n.length,circular:null,update:function(e,t){d.isRoot||(d.parent.node[d.key]=e),d.node=e,t&&(p=!1)},delete:function(e){delete d.parent.node[d.key],e&&(p=!1)},remove:function(e){u(d.parent.node)?d.parent.node.splice(d.key,1):delete d.parent.node[d.key],e&&(p=!1)},keys:null,before:function(e){h.before=e},after:function(e){h.after=e},pre:function(e){h.pre=e},post:function(e){h.post=e},stop:function(){a=!1},block:function(){p=!1}};if(!a)return d;function y(){if("object"==typeof d.node&&null!==d.node){d.keys&&d.node_===d.node||(d.keys=s(d.node)),d.isLeaf=0==d.keys.length;for(var e=0;e{if(null!==e)if(n.isBuffer(e))"blob"===e.slice(0,4).toString()?i(()=>t(null,e)):i(()=>t(new Error("unexpected dagNode passed to serialize"),null));else switch(e.gitType){case"commit":f.serialize(e,t);break;case"tag":l.serialize(e,t);break;default:h.serialize(e,t)}else i(()=>t(new Error("dagNode passed to serialize was null"),null))}),t.deserialize=((e,t)=>{let r=c.find(e,0),n=e.slice(0,r).toString().match(/([^ ]+) (\d+)/);if(n)switch(n[1]){case"blob":t(null,e);break;case"commit":f.deserialize(e.slice(r+1),t);break;case"tag":l.deserialize(e.slice(r+1),t);break;case"tree":h.deserialize(e.slice(r+1),t);break;default:i(()=>t(new Error("unknown object type "+n[1]),null))}else i(()=>t(new Error("invalid object header"),null))}),t.cid=((e,r,n)=>{"function"==typeof r&&(n=r,r={});const i=(r=r||{}).hashAlg||u.defaultHashAlg,c=void 0===r.version?1:r.version;o([r=>t.serialize(e,r),(e,t)=>s(e,i,t),(e,t)=>t(null,new a(c,u.multicodec,e))],n)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(n){const i=r(398),o=r(397);(t=e.exports).multicodec="git-raw",t.defaultHashAlg="sha1";const s=["original","name","email","date"];t.resolve=((e,t,r)=>{"function"==typeof t&&(r=t,t=void 0),i.deserialize(e,(e,i)=>{if(e)return r(e);if(!t||"/"===t)return r(null,{value:i,remainderPath:""});if(n.isBuffer(i))return r(null,{value:i,remainderPath:t});const s=t.split("/"),a=o(i).get(s);if(a)return r(null,{value:a,remainderPath:""});let u,c=s.length;for(let e=0;e{"function"==typeof t&&(r=t,t=void 0),t=t||{},i.deserialize(e,(e,t)=>{if(e)return r(e);if(n.isBuffer(t))return r(null,[]);let i=[];switch(t.gitType){case"commit":i=(i=(i=(i=["message","tree"]).concat(s.map(e=>"author/"+e))).concat(s.map(e=>"committer/"+e))).concat(t.parents.map((e,t)=>"parents/"+t)),t.encoding&&i.push("encoding");break;case"tag":i=["object","type","tag","message"],t.tagger&&(i=i.concat(s.map(e=>"tagger/"+e)));break;default:Object.keys(t).forEach(e=>{i.push(e),i.push(e+"/hash"),i.push(e+"/mode")})}r(null,i)})}),t.isLink=((e,r,n)=>{t.resolve(e,r,(e,t)=>e?n(e):t.remainderPath.length>0?n(new Error("path out of scope")):void("object"==typeof t.value&&t.value["/"]?n(null,t.value):n(null,!1)))})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(782).Block,i=r(9),o=r(12),s=r(65),a=r(4);e.exports={hashToCid:e=>{const t=r(229).defaultHashAlg,n=o.encode(e,t);return new i(1,"bitcoin-block",n)},BITCOIN_BLOCK_HEADER_SIZE:80,cid:(e,t,n)=>{"function"==typeof t&&(n=t,t={});const o=(t=t||{}).hashAlg||r(229).defaultHashAlg,u=void 0===t.version?1:t.version;a([t=>{try{s(e.toBuffer(!0),o,t)}catch(e){t(e)}},(e,t)=>t(null,new i(u,"bitcoin-block",e))],n)},deserialize:(e,t)=>{if(80!==e.length)return t(new Error("Bitcoin block header needs to be 80 bytes"));t(null,n.fromBuffer(e))},serialize:(e,t)=>{let r,n=null;try{r=e.toBuffer(!0)}catch(e){n=e}finally{t(n,r)}}}},function(e,t,r){var n=r(42);function i(e){return ee.length)return null;r=e.readUInt8(t+1),i=2}else if(o===n.OP_PUSHDATA2){if(t+3>e.length)return null;r=e.readUInt16LE(t+1),i=3}else{if(t+5>e.length)return null;if(o!==n.OP_PUSHDATA4)throw new Error("Unexpected opcode");r=e.readUInt32LE(t+1),i=5}return{opcode:o,number:r,size:i}}}},function(e,t,r){var n=r(231);function i(e){return e.name||e.toString().match(/function (.*?)\s*\(/)[1]}function o(e){return n.Nil(e)?"":i(e.constructor)}function s(e){return n.Function(e)?"":n.String(e)?JSON.stringify(e):e&&n.Object(e)?"":e}function a(e){return n.Function(e)?e.toJSON?e.toJSON():i(e):n.Array(e)?"Array":e&&n.Object(e)?"Object":void 0!==e?e:""}function u(e,t,r){var n=s(t);return"Expected "+a(e)+", got"+(""!==r?" "+r:"")+(""!==n?" "+n:"")}function c(e,t,r){r=r||o(t),this.message=u(e,t,r),Error.captureStackTrace(this,c),this.__type=e,this.__value=t,this.__valueTypeName=r}function f(e,t,r,n,i){e?(i=i||o(n),this.message=function(e,t,r,n,i){var o='" of type ';return"key"===t&&(o='" with key type '),u('property "'+a(r)+o+a(e),n,i)}(e,r,t,n,i)):this.message='Unexpected property "'+t+'"',Error.captureStackTrace(this,c),this.__label=r,this.__property=t,this.__type=e,this.__value=n,this.__valueTypeName=i}c.prototype=Object.create(Error.prototype),c.prototype.constructor=c,f.prototype=Object.create(Error.prototype),f.prototype.constructor=c,e.exports={TfTypeError:c,TfPropertyTypeError:f,tfCustomError:function(e,t){return new c(e,{},t)},tfSubError:function(e,t,r){return e instanceof f?(t=t+"."+e.__property,e=new f(e.__type,t,e.__label,e.__value,e.__valueTypeName)):e instanceof c&&(e=new f(e.__type,t,r,e.__value,e.__valueTypeName)),Error.captureStackTrace(e),e},tfJSON:a,getValueTypeName:o}},function(e,t,r){var n=r(2).Buffer;e.exports={decode:function(e,t,r){t=t||4,r=void 0===r||r;var n=e.length;if(0===n)return 0;if(n>t)throw new TypeError("Script number overflow");if(r&&0==(127&e[n-1])&&(n<=1||0==(128&e[n-2])))throw new Error("Non-minimally encoded script number");if(5===n){var i=e.readUInt32LE(0),o=e.readUInt8(4);return 128&o?-(4294967296*(-129&o)+i):4294967296*o+i}for(var s=0,a=0;a2147483647?5:e>8388607?4:e>32767?3:e>127?2:e>0?1:0}(t),i=n.allocUnsafe(r),o=e<0,s=0;s>=8;return 128&i[r-1]?i.writeUInt8(o?128:0,r-1):o&&(i[r-1]|=128),i}}},function(e,t,r){var n=r(28),i=r(31),o=r(25),s=r(42),a=s.OP_RESERVED;function u(e,t){var r=n.decompile(e);if(r.length<4)return!1;if(r[r.length-1]!==s.OP_CHECKMULTISIG)return!1;if(!i.Number(r[0]))return!1;if(!i.Number(r[r.length-2]))return!1;var o=r[0]-a,u=r[r.length-2]-a;return!(o<=0)&&!(u>16)&&!(o>u)&&u===r.length-3&&(!!t||r.slice(1,-2).every(n.isCanonicalPubKey))}u.toJSON=function(){return"multi-sig output"},e.exports={check:u,decode:function(e,t){var r=n.decompile(e);return o(u,r,t),{m:r[0]-a,pubKeys:r.slice(1,-2)}},encode:function(e,t){o({m:i.Number,pubKeys:[n.isCanonicalPubKey]},{m:e,pubKeys:t});var r=t.length;if(rt)throw new Error("RangeError: value out of range");if(Math.floor(e)!==e)throw new Error("value has a fractional component")}e.exports={pushDataSize:n.encodingLength,readPushDataInt:n.decode,readUInt64LE:function(e,t){var r=e.readUInt32LE(t),n=e.readUInt32LE(t+4);return o((n*=4294967296)+r,9007199254740991),n+r},readVarInt:function(e,t){return{number:i.decode(e,t),size:i.decode.bytes}},varIntBuffer:i.encode,varIntSize:i.encodingLength,writePushDataInt:n.encode,writeUInt64LE:function(e,t,r){return o(t,9007199254740991),e.writeInt32LE(-1&t,r),e.writeUInt32LE(Math.floor(t/4294967296),r+4),r+8},writeVarInt:function(e,t,r){return i.encode(t,e,r),i.encode.bytes}}},function(e,t,r){"use strict";var n=r(2).Buffer,i=r(90).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(5)(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";var n=r(0).Buffer,i=r(5),o=r(408),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],u=[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],c=[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],l=[0,1518500249,1859775393,2400959708,2840853838],h=[1352829926,1548603684,1836072691,2053994217,0];function p(){o.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function d(e,t){return e<>>32-t}function y(e,t,r,n,i,o,s,a){return d(e+(t^r^n)+o+s|0,a)+i|0}function g(e,t,r,n,i,o,s,a){return d(e+(t&r|~t&n)+o+s|0,a)+i|0}function m(e,t,r,n,i,o,s,a){return d(e+((t|~r)^n)+o+s|0,a)+i|0}function b(e,t,r,n,i,o,s,a){return d(e+(t&n|r&~n)+o+s|0,a)+i|0}function v(e,t,r,n,i,o,s,a){return d(e+(t^(r|~n))+o+s|0,a)+i|0}i(p,o),p.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,p=0|this._e,_=0|this._a,w=0|this._b,S=0|this._c,k=0|this._d,E=0|this._e,A=0;A<80;A+=1){var x,I;A<16?(x=y(r,n,i,o,p,e[a[A]],l[0],c[A]),I=v(_,w,S,k,E,e[u[A]],h[0],f[A])):A<32?(x=g(r,n,i,o,p,e[a[A]],l[1],c[A]),I=b(_,w,S,k,E,e[u[A]],h[1],f[A])):A<48?(x=m(r,n,i,o,p,e[a[A]],l[2],c[A]),I=m(_,w,S,k,E,e[u[A]],h[2],f[A])):A<64?(x=b(r,n,i,o,p,e[a[A]],l[3],c[A]),I=g(_,w,S,k,E,e[u[A]],h[3],f[A])):(x=v(r,n,i,o,p,e[a[A]],l[4],c[A]),I=y(_,w,S,k,E,e[u[A]],h[4],f[A])),r=p,p=o,o=d(i,10),i=n,n=x,_=E,E=k,k=d(S,10),S=w,w=I}var T=this._b+i+k|0;this._b=this._c+o+E|0,this._c=this._d+p+_|0,this._d=this._e+r+w|0,this._e=this._a+n+S|0,this._a=T},p.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=p},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(801),t.sha1=r(802),t.sha224=r(803),t.sha256=r(411),t.sha384=r(804),t.sha512=r(412)},function(e,t,r){var n=r(5),i=r(106),o=r(2).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 u(){this.init(),this._w=a,i.call(this,64,56)}function c(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function l(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function h(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function p(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function d(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}n(u,i),u.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},u.prototype._update=function(e){for(var t=this._w,r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,a=0|this._e,u=0|this._f,y=0|this._g,g=0|this._h,m=0;m<16;++m)t[m]=e.readInt32BE(4*m);for(;m<64;++m)t[m]=d(t[m-2])+t[m-7]+p(t[m-15])+t[m-16]|0;for(var b=0;b<64;++b){var v=g+h(a)+c(a,u,y)+s[b]+t[b]|0,_=l(r)+f(r,n,i)|0;g=y,y=u,u=a,a=o+v|0,o=i,i=n,n=r,r=v+_|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0,this._f=u+this._f|0,this._g=y+this._g|0,this._h=g+this._h|0},u.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=u},function(e,t,r){var n=r(5),i=r(106),o=r(2).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 u(){this.init(),this._w=a,i.call(this,128,112)}function c(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function l(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function h(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function p(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function d(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 g(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function m(e,t){return e>>>0>>0?1:0}n(u,i),u.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},u.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,u=0|this._fh,b=0|this._gh,v=0|this._hh,_=0|this._al,w=0|this._bl,S=0|this._cl,k=0|this._dl,E=0|this._el,A=0|this._fl,x=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 B=t[T-30],C=t[T-30+1],P=p(B,C),O=d(C,B),R=y(B=t[T-4],C=t[T-4+1]),N=g(C,B),L=t[T-14],K=t[T-14+1],j=t[T-32],M=t[T-32+1],D=O+K|0,U=P+L+m(D,O)|0;U=(U=U+R+m(D=D+N|0,N)|0)+j+m(D=D+M|0,M)|0,t[T]=U,t[T+1]=D}for(var F=0;F<160;F+=2){U=t[F],D=t[F+1];var q=f(r,n,i),H=f(_,w,S),z=l(r,_),V=l(_,r),G=h(a,E),W=h(E,a),$=s[F],Y=s[F+1],J=c(a,u,b),X=c(E,A,x),Z=I+W|0,Q=v+G+m(Z,I)|0;Q=(Q=(Q=Q+J+m(Z=Z+X|0,X)|0)+$+m(Z=Z+Y|0,Y)|0)+U+m(Z=Z+D|0,D)|0;var ee=V+H|0,te=z+q+m(ee,V)|0;v=b,I=x,b=u,x=A,u=a,A=E,a=o+Q+m(E=k+Z|0,k)|0,o=i,k=S,i=n,S=w,n=r,w=_,r=Q+te+m(_=Z+ee|0,Z)|0}this._al=this._al+_|0,this._bl=this._bl+w|0,this._cl=this._cl+S|0,this._dl=this._dl+k|0,this._el=this._el+E|0,this._fl=this._fl+A|0,this._gl=this._gl+x|0,this._hl=this._hl+I|0,this._ah=this._ah+r+m(this._al,_)|0,this._bh=this._bh+n+m(this._bl,w)|0,this._ch=this._ch+i+m(this._cl,S)|0,this._dh=this._dh+o+m(this._dl,k)|0,this._eh=this._eh+a+m(this._el,E)|0,this._fh=this._fh+u+m(this._fl,A)|0,this._gh=this._gh+b+m(this._gl,x)|0,this._hh=this._hh+v+m(this._hl,I)|0},u.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=u},function(e,t,r){function n(e,t,r){if(!(this instanceof n))return new n(e,t,r);null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}var i=n.prototype;i.__bigi=r(811).version,n.isBigInteger=function(e,t){return e&&e.__bigi&&(!t||e.__bigi===i.__bigi)},n.prototype.am=function(e,t,r,n,i,o){for(;--o>=0;){var s=t*this[e++]+r[n]+i;i=Math.floor(s/67108864),r[n++]=67108863&s}return i},n.prototype.DB=26,n.prototype.DM=67108863;var o=n.prototype.DV=1<<26;n.prototype.FV=Math.pow(2,52),n.prototype.F1=26,n.prototype.F2=0;var s,a,u="0123456789abcdefghijklmnopqrstuvwxyz",c=new Array;for(s="0".charCodeAt(0),a=0;a<=9;++a)c[s++]=a;for(s="a".charCodeAt(0),a=10;a<36;++a)c[s++]=a;for(s="A".charCodeAt(0),a=10;a<36;++a)c[s++]=a;function f(e){return u.charAt(e)}function l(e,t){var r=c[e.charCodeAt(t)];return null==r?-1:r}function h(e){var t=new n;return t.fromInt(e),t}function p(e){var t,r=1;return 0!=(t=e>>>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 d(e){this.m=e}function y(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 w(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function S(){}function k(e){return e}function E(e){this.r2=new n,this.q3=new n,n.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}d.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},d.prototype.revert=function(e){return e},d.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},d.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},d.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},y.prototype.convert=function(e){var t=new n;return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(n.ZERO)>0&&this.m.subTo(t,t),t},y.prototype.revert=function(e){var t=new n;return e.copyTo(t),this.reduce(t),t},y.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(e[r=t+this.m.t]+=this.m.am(0,n,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,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)},i.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s},i.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+o:this.t=0},i.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 i=e.length,o=!1,s=0;--i>=0;){var a=8==r?255&e[i]:l(e,i);a<0?"-"==e.charAt(i)&&(o=!0):(o=!1,0==s?this[this.t++]=a:s+r>this.DB?(this[this.t-1]|=(a&(1<>this.DB-s):this[this.t-1]|=a<=this.DB&&(s-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==e;)--this.t},i.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s},i.drShiftTo=function(e,t){for(var r=e;r=0;--r)t[r+s+1]=this[r]>>i|a,a=(this[r]&o)<=0;--r)t[r]=0;t[s]=a,t.t=this.t+s+1,t.s=this.s,t.clamp()},i.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[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[r++]=this.DV+n:n>0&&(t[r++]=n),t.t=r,t.clamp()},i.multiplyTo=function(e,t){var r=this.abs(),i=e.abs(),o=r.t;for(t.t=o+i.t;--o>=0;)t[o]=0;for(o=0;o=0;)e[r]=0;for(r=0;r=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()},i.divRemTo=function(e,t,r){var i=e.abs();if(!(i.t<=0)){var o=this.abs();if(o.t0?(i.lShiftTo(c,s),o.lShiftTo(c,r)):(i.copyTo(s),o.copyTo(r));var f=s.t,l=s[f-1];if(0!=l){var h=l*(1<1?s[f-2]>>this.F2:0),d=this.FV/h,y=(1<=0&&(r[r.t++]=1,r.subTo(v,r)),n.ONE.dlShiftTo(f,v),v.subTo(s,s);s.t=0;){var _=r[--m]==l?this.DM:Math.floor(r[m]*d+(r[m-1]+g)*y);if((r[m]+=s.am(0,_,r,b,0,f))<_)for(s.dlShiftTo(b,v),r.subTo(v,r);r[m]<--_;)r.subTo(v,r)}null!=t&&(r.drShiftTo(f,t),a!=u&&n.ZERO.subTo(t,t)),r.t=f,r.clamp(),c>0&&r.rShiftTo(c,r),a<0&&n.ZERO.subTo(r,r)}}},i.invDigit=function(){if(this.t<1)return 0;var e=this[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},i.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},i.exp=function(e,t){if(e>4294967295||e<1)return n.ONE;var r=new n,i=new n,o=t.convert(this),s=p(e)-1;for(o.copyTo(r);--s>=0;)if(t.sqrTo(r,i),(e&1<0)t.mulTo(i,o,r);else{var a=r;r=i,i=a}return t.revert(r)},i.toString=function(e){var t;if(this.s<0)return"-"+this.negate().toString(e);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=f(r));s>=0;)a>(a+=this.DB-t)):(r=this[s]>>(a-=t)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=f(r));return i?o:"0"},i.negate=function(){var e=new n;return n.ZERO.subTo(this,e),e},i.abs=function(){return this.s<0?this.negate():this},i.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[r]-e[r]))return t;return 0},i.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+p(this[this.t-1]^this.s&this.DM)},i.byteLength=function(){return this.bitLength()>>3},i.mod=function(e){var t=new n;return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(n.ZERO)>0&&e.subTo(t,t),t},i.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new d(t):new y(t),this.exp(e,r)},S.prototype.convert=k,S.prototype.revert=k,S.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},S.prototype.sqrTo=function(e,t){e.squareTo(t)},E.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=new n;return e.copyTo(t),this.reduce(t),t},E.prototype.revert=function(e){return e},E.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)},E.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},E.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var A=[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,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],x=(1<<26)/A[A.length-1];i.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},i.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),i=h(r),o=new n,s=new n,a="";for(this.divRemTo(i,o,s);o.signum()>0;)a=(r+s.intValue()).toString(e).substr(1)+a,o.divRemTo(i,o,s);return s.intValue().toString(e)+a},i.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),i=Math.pow(t,r),o=!1,s=0,a=0,u=0;u=r&&(this.dMultiply(i),this.dAddOffset(a,0),s=0,a=0))}s>0&&(this.dMultiply(Math.pow(t,s)),this.dAddOffset(a,0)),o&&n.ZERO.subTo(this,this)},i.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(n.ONE.shiftLeft(e-1),m,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(n.ONE.shiftLeft(e-1),this);else{var i=new Array,o=7&e;i.length=1+(e>>3),t.nextBytes(i),o>0?i[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[r++]=n:n<-1&&(t[r++]=this.DV+n),t.t=r,t.clamp()},i.dMultiply=function(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},i.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}},i.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[--i]=0;for(n=r.t-this.t;i=0;)r[n]=0;for(n=Math.max(t-this.t,0);n0)if(0==t)r=this[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this[n])%e;return r},i.millerRabin=function(e){var t=this.subtract(n.ONE),r=t.getLowestSetBit();if(r<=0)return!1;var i=t.shiftRight(r);(e=e+1>>1)>A.length&&(e=A.length);for(var o=new n(null),s=[],a=0;a>24},i.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},i.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},i.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[e]&(1<>(n+=this.DB-8)):(r=this[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},i.equals=function(e){return 0==this.compareTo(e)},i.min=function(e){return this.compareTo(e)<0?this:e},i.max=function(e){return this.compareTo(e)>0?this:e},i.and=function(e){var t=new n;return this.bitwiseTo(e,g,t),t},i.or=function(e){var t=new n;return this.bitwiseTo(e,m,t),t},i.xor=function(e){var t=new n;return this.bitwiseTo(e,b,t),t},i.andNot=function(e){var t=new n;return this.bitwiseTo(e,v,t),t},i.not=function(){for(var e=new n,t=0;t=this.t?0!=this.s:0!=(this[t]&1<1){var l=new n;for(i.sqrTo(a[1],l);u<=f;)a[u]=new n,i.mulTo(l,a[u-2],a[u]),u+=2}var g,m,b=e.t-1,v=!0,_=new n;for(o=p(e[b])-1;b>=0;){for(o>=c?g=e[b]>>o-c&f:(g=(e[b]&(1<0&&(g|=e[b-1]>>this.DB+o-c)),u=r;0==(1&g);)g>>=1,--u;if((o-=u)<0&&(o+=this.DB,--b),v)a[g].copyTo(s),v=!1;else{for(;u>1;)i.sqrTo(s,_),i.sqrTo(_,s),u-=2;u>0?i.sqrTo(s,_):(m=s,s=_,_=m),i.mulTo(_,a[g],s)}for(;b>=0&&0==(e[b]&1<=0?(r.subTo(i,r),t&&o.subTo(a,o),s.subTo(u,s)):(i.subTo(r,i),t&&a.subTo(o,a),u.subTo(s,u))}if(0!=i.compareTo(n.ONE))return n.ZERO;for(;u.compareTo(e)>=0;)u.subTo(e,u);for(;u.signum()<0;)u.addTo(e,u);return u},i.pow=function(e){return this.exp(e,new S)},i.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},i.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r[0]<=A[A.length-1]){for(t=0;t0;--o){var a=r.testBit(o),u=t.testBit(o);i=i.twice(),a!==u&&(i=i.add(a?this:n))}return i},a.prototype.multiplyTwo=function(e,t,r){for(var n=Math.max(e.bitLength(),r.bitLength())-1,i=this.curve.infinity,o=this.add(t);n>=0;){var s=e.testBit(n),a=r.testBit(n);i=i.twice(),s?i=a?i.add(o):i.add(this):a&&(i=i.add(t)),--n}return i},a.prototype.getEncoded=function(e){if(null==e&&(e=this.compressed),this.curve.isInfinity(this))return i.alloc(1,0);var t,r=this.affineX,n=this.affineY,o=this.curve.pLength;return e?(t=i.allocUnsafe(1+o)).writeUInt8(n.isEven()?2:3,0):((t=i.allocUnsafe(1+o+o)).writeUInt8(4,0),n.toBuffer(o).copy(t,1+o)),r.toBuffer(o).copy(t,1),t},a.decodeFrom=function(e,t){var r,i=t.readUInt8(0),s=4!==i,u=Math.floor((e.p.bitLength()+7)/8),c=o.fromBuffer(t.slice(1,1+u));if(s){n.equal(t.length,u+1,"Invalid sequence length"),n(2===i||3===i,"Invalid sequence tag");var f=3===i;r=e.pointFromX(f,c)}else{n.equal(t.length,1+u+u,"Invalid sequence length");var l=o.fromBuffer(t.slice(1+u));r=a.fromAffine(e,c,l)}return r.compressed=s,r},a.prototype.toString=function(){return this.curve.isInfinity(this)?"(INFINITY)":"("+this.affineX.toString()+","+this.affineY.toString()+")"},e.exports=a},function(e,t,r){var n=r(17),i=r(93),o=r(414);function s(e,t,r,n,s,a,u){this.p=e,this.a=t,this.b=r,this.G=o.fromAffine(this,n,s),this.n=a,this.h=u,this.infinity=new o(this,null,null,i.ZERO),this.pOverFour=e.add(i.ONE).shiftRight(2),this.pLength=Math.floor((this.p.bitLength()+7)/8)}s.prototype.pointFromX=function(e,t){var r=t.pow(3).add(this.a.multiply(t)).add(this.b).mod(this.p).modPow(this.pOverFour,this.p),n=r;return r.isEven()^!e&&(n=this.p.subtract(n)),o.fromAffine(this,t,n)},s.prototype.isInfinity=function(e){return e===this.infinity||0===e.z.signum()&&0!==e.y.signum()},s.prototype.isOnCurve=function(e){if(this.isInfinity(e))return!0;var t=e.affineX,r=e.affineY,n=this.a,i=this.b,o=this.p;if(t.signum()<0||t.compareTo(o)>=0)return!1;if(r.signum()<0||r.compareTo(o)>=0)return!1;var s=r.square().mod(o),a=t.pow(3).add(n.multiply(t)).add(i).mod(o);return s.equals(a)},s.prototype.validate=function(e){n(!this.isInfinity(e),"Point is at infinity"),n(this.isOnCurve(e),"Point is not on the curve");var t=e.multiply(this.n);return n(this.isInfinity(t),"Point is not a scalar multiple of G"),!0},e.exports=s},function(e,t,r){"use strict";(function(t){const n=r(818),i=r(127),o=r(128),s=r(855);e.exports=o("eth-account-snapshot",n,function(e,r,n){const o=[];o.push({path:"storage",value:{"/":i("eth-storage-trie",e.stateRoot).toBaseEncodedString()}}),s.equals(e.codeHash)?o.push({path:"code",value:t.from("")}):o.push({path:"code",value:{"/":i("raw",e.codeHash).toBaseEncodedString()}}),o.push({path:"stateRoot",value:e.stateRoot}),o.push({path:"codeHash",value:e.codeHash}),o.push({path:"nonce",value:e.nonce}),o.push({path:"balance",value:e.balance}),o.push({path:"isEmpty",value:e.isEmpty()}),o.push({path:"isContract",value:e.isContract()}),n(null,o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";var n=r(826),i=r(827),o=r(245);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>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){"use strict";var n=r(71).rotr32;function i(e,t,r){return e&t^~e&r}function o(e,t,r){return e&t^e&r^t&r}function s(e,t,r){return e^t^r}t.ft_1=function(e,t,r,n){return 0===e?i(t,r,n):1===e||3===e?s(t,r,n):2===e?o(t,r,n):void 0},t.ch32=i,t.maj32=o,t.p32=s,t.s0_256=function(e){return n(e,2)^n(e,13)^n(e,22)},t.s1_256=function(e){return n(e,6)^n(e,11)^n(e,25)},t.g0_256=function(e){return n(e,7)^n(e,18)^e>>>3},t.g1_256=function(e){return n(e,17)^n(e,19)^e>>>10}},function(e,t,r){"use strict";var n=r(71),i=r(125),o=r(419),s=r(81),a=n.sum32,u=n.sum32_4,c=n.sum32_5,f=o.ch32,l=o.maj32,h=o.s0_256,p=o.s1_256,d=o.g0_256,y=o.g1_256,g=i.BlockHash,m=[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 b(){if(!(this instanceof b))return new b;g.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=m,this.W=new Array(64)}n.inherits(b,g),e.exports=b,b.blockSize=512,b.outSize=256,b.hmacStrength=192,b.padLength=64,b.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;ne?n(e):t.remainderPath.length>0?n(new Error("path out of scope")):void("object"==typeof t.value&&t.value["/"]?n(null,t.value):n(null,!1)))}}},function(e,t,r){const n=r(425),i=r(154);e.exports=function(e,t){return{deserialize:i(e=>new t(e)),serialize:i(e=>e.serialize()),cid:i((t,r)=>n(e,t,r))}}},function(e,t,r){"use strict";const n=r(127);e.exports=function(e,t,r){const i=t.hash();return n(e,i,r)}},function(e,t,r){"use strict";const n=r(427),i=r(127),o=r(128);e.exports=o("eth-block",n,function(e,t,r){const n=[];n.push({path:"parent",value:{"/":i("eth-block",e.parentHash).toBaseEncodedString()}}),n.push({path:"ommers",value:{"/":i("eth-block-list",e.uncleHash).toBaseEncodedString()}}),n.push({path:"transactions",value:{"/":i("eth-tx-trie",e.transactionsTrie).toBaseEncodedString()}}),n.push({path:"transactionReceipts",value:{"/":i("eth-tx-receipt-trie",e.receiptTrie).toBaseEncodedString()}}),n.push({path:"state",value:{"/":i("eth-state-trie",e.stateRoot).toBaseEncodedString()}}),n.push({path:"parentHash",value:e.parentHash}),n.push({path:"ommerHash",value:e.uncleHash}),n.push({path:"transactionTrieRoot",value:e.transactionsTrie}),n.push({path:"transactionReceiptTrieRoot",value:e.receiptTrie}),n.push({path:"stateRoot",value:e.stateRoot}),n.push({path:"authorAddress",value:e.coinbase}),n.push({path:"bloom",value:e.bloom}),n.push({path:"difficulty",value:e.difficulty}),n.push({path:"number",value:e.number}),n.push({path:"gasLimit",value:e.gasLimit}),n.push({path:"gasUsed",value:e.gasUsed}),n.push({path:"timestamp",value:e.timestamp}),n.push({path:"extraData",value:e.extraData}),n.push({path:"mixHash",value:e.mixHash}),n.push({path:"nonce",value:e.nonce}),r(null,n)})},function(e,t,r){(function(t){const n=r(173),i=r(856),o=n.BN;var s=e.exports=function(e){var r=[{name:"parentHash",length:32,default:n.zeros(32)},{name:"uncleHash",default:n.SHA3_RLP_ARRAY},{name:"coinbase",length:20,default:n.zeros(20)},{name:"stateRoot",length:32,default:n.zeros(32)},{name:"transactionsTrie",length:32,default:n.SHA3_RLP},{name:"receiptTrie",length:32,default:n.SHA3_RLP},{name:"bloom",default:n.zeros(256)},{name:"difficulty",default:new t([])},{name:"number",default:n.intToBuffer(i.homeSteadForkNumber.v)},{name:"gasLimit",default:new t("ffffffffffffff","hex")},{name:"gasUsed",empty:!0,default:new t([])},{name:"timestamp",default:new t([])},{name:"extraData",allowZero:!0,empty:!0,default:new t([])},{name:"mixHash",default:n.zeros(32)},{name:"nonce",default:new t([])}];n.defineProperties(this,r,e)};s.prototype.canonicalDifficulty=function(e){const t=new o(this.timestamp),r=new o(e.header.timestamp),s=new o(e.header.difficulty),a=new o(i.minimumDifficulty.v);var u,c=s.div(new o(i.difficultyBoundDivisor.v)),f=e.header.uncleHash.equals(n.SHA3_RLP_ARRAY)?1:2,l=t.sub(r).idivn(9).ineg().iaddn(f),h=new o(-99);1===h.cmp(l)&&(l=h),u=s.add(c.mul(l));var p=new o(this.number).isubn(3e6);p.ltn(0)&&(p=new o(0));var d=p.idivn(1e5).isubn(2);return d.isNeg()||u.iadd(new o(2).pow(d)),-1===u.cmp(a)&&(u=a),u},s.prototype.validateDifficulty=function(e){return 0===this.canonicalDifficulty(e).cmp(new o(this.difficulty))},s.prototype.validateGasLimit=function(e){const t=new o(e.header.gasLimit),r=new o(this.gasLimit),n=t.div(new o(i.gasLimitBoundDivisor.v)),s=t.add(n),a=t.sub(n);return r.lt(s)&&r.gt(a)&&r.gte(i.minGasLimit.v)},s.prototype.validate=function(e,t,r){var s=this;if(2===arguments.length&&(r=t,t=!1),this.isGenesis())return r();e.getBlock(s.parentHash,function(e,a){if(e)return r("could not find parent block");if(s.parentBlock=a,0!==new o(s.number).cmp(new o(a.header.number).iaddn(1)))return r("invalid number");if(t){var u=t.sub(new o(a.header.number));if(-1!==u.cmpn(8)||1!==u.cmpn(1))return r("uncle block has a parent that is too old or to young")}return s.validateDifficulty(a)?s.validateGasLimit(a)?n.bufferToInt(a.header.number)+1!==n.bufferToInt(s.number)?r("invalid heigth"):n.bufferToInt(s.timestamp)<=n.bufferToInt(a.header.timestamp)?r("invalid timestamp"):s.extraData.length>i.maximumExtraDataSize.v?r("invalid amount of extra data"):void r():r("invalid gas limit"):r("invalid Difficulty")})},s.prototype.hash=function(){return n.rlphash(this.raw)},s.prototype.isGenesis=function(){return""===this.number.toString("hex")}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(866),i=r(128);e.exports=i("eth-tx",n,function(e,t,r){const n=[];n.push({path:"nonce",value:e.nonce}),n.push({path:"gasPrice",value:e.gasPrice}),n.push({path:"gasLimit",value:e.gasLimit}),n.push({path:"toAddress",value:e.to}),n.push({path:"value",value:e.value}),n.push({path:"data",value:e.data}),n.push({path:"v",value:e.v}),n.push({path:"r",value:e.r}),n.push({path:"s",value:e.s}),n.push({path:"fromAddress",value:e.from}),n.push({path:"signature",value:[e.v,e.r,e.s]}),n.push({path:"isContractPublish",value:e.toCreationAddress()}),r(null,n)})},function(e,t,r){"use strict";const n=r(871).BlockHeader,i=r(9),o=r(12),s=r(65),a=r(4);e.exports={hashToCid:e=>{const t=r(248).defaultHashAlg,n=o.encode(e,t);return new i(1,"zcash-block",n)},ZCASH_BLOCK_HEADER_SIZE:1487,cid:(e,t,n)=>{"function"==typeof t&&(n=t,t={});const o=(t=t||{}).hashAlg||r(248).defaultHashAlg,u=void 0===t.version?1:t.version;a([t=>{try{s(e.toBuffer(),o,t)}catch(e){t(e)}},(e,t)=>t(null,new i(u,"zcash-block",e))],n)},deserialize:(e,t)=>{if(1487!==e.length)return t(new Error("Zcash block header needs to be 1487 bytes"));t(null,n.fromBuffer(e))},serialize:(e,t)=>{let r,n=null;try{r=e.toBuffer()}catch(e){n=e}finally{t(n,r)}}}},function(e,t,r){"use strict";(function(t){var n=r(32),i=r(108),o=r(67),s=r(73),a=r(179),u=r(43),c=r(24),f=r(18),l=r(21),h=function e(t){if(!(this instanceof e))return new e(t);t&&this.set(t)};h.prototype.set=function(e){return this.hashbuf=e.hashbuf||this.hashbuf,this.endian=e.endian||this.endian,this.privkey=e.privkey||this.privkey,this.pubkey=e.pubkey||(this.privkey?this.privkey.publicKey:this.pubkey),this.sig=e.sig||this.sig,this.k=e.k||this.k,this.verified=e.verified||this.verified,this},h.prototype.privkey2pubkey=function(){this.pubkey=this.privkey.toPublicKey()},h.prototype.calci=function(){for(var e=0;e<4;e++){var t;this.sig.i=e;try{t=this.toPublicKey()}catch(e){console.error(e);continue}if(t.point.eq(this.pubkey.point))return this.sig.compressed=this.pubkey.compressed,this}throw this.sig.i=void 0,new Error("Unable to find valid recovery factor")},h.fromString=function(e){var t=JSON.parse(e);return new h(t)},h.prototype.randomK=function(){var e,t=i.getN();do{e=n.fromBuffer(a.getRandomBuffer(32))}while(!e.lt(t)||!e.gt(n.Zero));return this.k=e,this},h.prototype.deterministicK=function(e){f.isUndefined(e)&&(e=0);var r=new t(32);r.fill(1);var o=new t(32);o.fill(0);var s=this.privkey.bn.toBuffer({size:32}),a="little"===this.endian?c.reverse(this.hashbuf):this.hashbuf;o=u.sha256hmac(t.concat([r,new t([0]),s,a]),o),r=u.sha256hmac(r,o),o=u.sha256hmac(t.concat([r,new t([1]),s,a]),o),r=u.sha256hmac(r,o),r=u.sha256hmac(r,o);for(var l=n.fromBuffer(r),h=i.getN(),p=0;p>1,c=i.getN(),f=i.getG(),h=u?r.add(c):r,p=i.fromX(a,h);if(!p.mul(c).isInfinity())throw new Error("nR is not a valid curve point");var d=t.neg().mod(c),y=r.invm(c),g=p.mul(o).add(f.mul(d)).mul(y);return s.fromPoint(g,this.sig.compressed)},h.prototype.sigError=function(){if(!c.isBuffer(this.hashbuf)||32!==this.hashbuf.length)return"hashbuf must be a 32 byte buffer";var e=this.sig.r,t=this.sig.s;if(!(e.gt(n.Zero)&&e.lt(i.getN())&&t.gt(n.Zero)&&t.lt(i.getN())))return"r and s not in range";var r=n.fromBuffer(this.hashbuf,this.endian?{endian:this.endian}:void 0),o=i.getN(),s=t.invm(o),a=s.mul(r).mod(o),u=s.mul(e).mod(o),f=i.getG().mulAdd(a,this.pubkey.point,u);return f.isInfinity()?"p is infinity":0!==f.getX().mod(o).cmp(e)&&"Invalid signature"},h.toLowS=function(e){return e.gt(n.fromBuffer(new t("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))&&(e=i.getN().sub(e)),e},h.prototype._findSignature=function(e,t){var r,o,s,a=i.getN(),u=i.getG(),c=0;do{(!this.k||c>0)&&this.deterministicK(c),c++,r=this.k,o=u.mul(r).x.mod(a),s=r.invm(a).mul(t.add(e.mul(o))).mod(a)}while(o.cmp(n.Zero)<=0||s.cmp(n.Zero)<=0);return{s:s=h.toLowS(s),r:o}},h.prototype.sign=function(){var e=this.hashbuf,t=this.privkey,r=t.bn;l.checkState(e&&t&&r,new Error("invalid parameters")),l.checkState(c.isBuffer(e)&&32===e.length,new Error("hashbuf must be a 32 byte buffer"));var i=n.fromBuffer(e,this.endian?{endian:this.endian}:void 0),s=this._findSignature(r,i);return s.compressed=this.pubkey.compressed,this.sig=new o(s),this},h.prototype.signRandomK=function(){return this.randomK(),this.sign()},h.prototype.toString=function(){var e={};return this.hashbuf&&(e.hashbuf=this.hashbuf.toString("hex")),this.privkey&&(e.privkey=this.privkey.toString()),this.pubkey&&(e.pubkey=this.pubkey.toString()),this.sig&&(e.sig=this.sig.toString()),this.k&&(e.k=this.k.toString()),JSON.stringify(e)},h.prototype.verify=function(){return this.sigError()?this.verified=!1:this.verified=!0,this},h.sign=function(e,t,r){return h().set({hashbuf:e,endian:r,privkey:t}).sign().sig},h.verify=function(e,t,r,n){return h().set({hashbuf:e,endian:n,sig:t,pubkey:r}).verify().verified},e.exports=h}).call(this,r(0).Buffer)},function(e,t){for(var r="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",n={},i=0;i>8,i[r]&=255;for(;a;)i.push(255&a),a>>=8}for(t=0;"1"===e[t]&&t0&&s0&&s0&&(i=n?i+" "+e.buf.toString("hex"):i+" "+e.len+" 0x"+e.buf.toString("hex"));else if(void 0!==a.reverseMap[r])i=i+" "+a(r).toString();else{var o=r.toString(16);o.length%2!=0&&(o="0"+o),i=n?i+" "+o:i+" 0x"+o}return i},m.prototype.toASM=function(){for(var e="",t=0;t"},m.prototype.isPublicKeyHashOut=function(){return!(5!==this.chunks.length||this.chunks[0].opcodenum!==a.OP_DUP||this.chunks[1].opcodenum!==a.OP_HASH160||!this.chunks[2].buf||20!==this.chunks[2].buf.length||this.chunks[3].opcodenum!==a.OP_EQUALVERIFY||this.chunks[4].opcodenum!==a.OP_CHECKSIG)},m.prototype.isPublicKeyHashIn=function(){if(2===this.chunks.length){var e=this.chunks[0].buf,t=this.chunks[1].buf;if(e&&e.length&&48===e[0]&&t&&t.length){var r=t[0];if((4===r||6===r||7===r)&&65===t.length)return!0;if((3===r||2===r)&&33===t.length)return!0}}return!1},m.prototype.getPublicKey=function(){return l.checkState(this.isPublicKeyOut(),"Can't retreive PublicKey from a non-PK output"),this.chunks[0].buf},m.prototype.getPublicKeyHash=function(){return l.checkState(this.isPublicKeyHashOut(),"Can't retrieve PublicKeyHash from a non-PKH output"),this.chunks[2].buf},m.prototype.isPublicKeyOut=function(){if(2===this.chunks.length&&this.chunks[0].buf&&this.chunks[0].buf.length&&this.chunks[1].opcodenum===a.OP_CHECKSIG){var e=this.chunks[0].buf,t=e[0],r=!1;if((4!==t&&6!==t&&7!==t||65!==e.length)&&(3!==t&&2!==t||33!==e.length)||(r=!0),r)return u.isValid(e)}return!1},m.prototype.isPublicKeyIn=function(){if(1===this.chunks.length){var e=this.chunks[0].buf;if(e&&e.length&&48===e[0])return!0}return!1},m.prototype.isScriptHashOut=function(){var e=this.toBuffer();return 23===e.length&&e[0]===a.OP_HASH160&&20===e[1]&&e[e.length-1]===a.OP_EQUAL},m.prototype.isScriptHashIn=function(){if(this.chunks.length<=1)return!1;var e,t,r=this.chunks[this.chunks.length-1].buf;if(!r)return!1;try{t=m.fromBuffer(r)}catch(e){if(e instanceof p.Script.InvalidBuffer)return!1;throw e}return t.classify()!==m.types.UNKNOWN},m.prototype.isMultisigOut=function(){return this.chunks.length>3&&a.isSmallIntOp(this.chunks[0].opcodenum)&&this.chunks.slice(1,this.chunks.length-2).every(function(e){return e.buf&&y.isBuffer(e.buf)})&&a.isSmallIntOp(this.chunks[this.chunks.length-2].opcodenum)&&this.chunks[this.chunks.length-1].opcodenum===a.OP_CHECKMULTISIG},m.prototype.isMultisigIn=function(){return this.chunks.length>=2&&0===this.chunks[0].opcodenum&&this.chunks.slice(1,this.chunks.length).every(function(e){return e.buf&&y.isBuffer(e.buf)&&c.isTxDER(e.buf)})},m.prototype.isDataOut=function(){return this.chunks.length>=1&&this.chunks[0].opcodenum===a.OP_RETURN&&(1===this.chunks.length||2===this.chunks.length&&this.chunks[1].buf&&this.chunks[1].buf.length<=m.OP_RETURN_STANDARD_SIZE&&this.chunks[1].length===this.chunks.len)},m.prototype.getData=function(){if(this.isDataOut()||this.isScriptHashOut())return h.isUndefined(this.chunks[1])?new t(0):new t(this.chunks[1].buf);if(this.isPublicKeyHashOut())return new t(this.chunks[2].buf);throw new Error("Unrecognized script type to get data from")},m.prototype.isPushOnly=function(){return h.every(this.chunks,function(e){return e.opcodenum<=a.OP_16})},(m.types={}).UNKNOWN="Unknown",m.types.PUBKEY_OUT="Pay to public key",m.types.PUBKEY_IN="Spend from public key",m.types.PUBKEYHASH_OUT="Pay to public key hash",m.types.PUBKEYHASH_IN="Spend from public key hash",m.types.SCRIPTHASH_OUT="Pay to script hash",m.types.SCRIPTHASH_IN="Spend from script hash",m.types.MULTISIG_OUT="Pay to multisig",m.types.MULTISIG_IN="Spend from multisig",m.types.DATA_OUT="Data push",m.OP_RETURN_STANDARD_SIZE=80,m.prototype.classify=function(){if(this._isInput)return this.classifyInput();if(this._isOutput)return this.classifyOutput();var e=this.classifyOutput();return e!=m.types.UNKNOWN?e:this.classifyInput()},(m.outputIdentifiers={}).PUBKEY_OUT=m.prototype.isPublicKeyOut,m.outputIdentifiers.PUBKEYHASH_OUT=m.prototype.isPublicKeyHashOut,m.outputIdentifiers.MULTISIG_OUT=m.prototype.isMultisigOut,m.outputIdentifiers.SCRIPTHASH_OUT=m.prototype.isScriptHashOut,m.outputIdentifiers.DATA_OUT=m.prototype.isDataOut,m.prototype.classifyOutput=function(){for(var e in m.outputIdentifiers)if(m.outputIdentifiers[e].bind(this)())return m.types[e];return m.types.UNKNOWN},(m.inputIdentifiers={}).PUBKEY_IN=m.prototype.isPublicKeyIn,m.inputIdentifiers.PUBKEYHASH_IN=m.prototype.isPublicKeyHashIn,m.inputIdentifiers.MULTISIG_IN=m.prototype.isMultisigIn,m.inputIdentifiers.SCRIPTHASH_IN=m.prototype.isScriptHashIn,m.prototype.classifyInput=function(){for(var e in m.inputIdentifiers)if(m.inputIdentifiers[e].bind(this)())return m.types[e];return m.types.UNKNOWN},m.prototype.isStandard=function(){return this.classify()!==m.types.UNKNOWN},m.prototype.prepend=function(e){return this._addByType(e,!0),this},m.prototype.equals=function(e){if(l.checkState(e instanceof m,"Must provide another script"),this.chunks.length!==e.chunks.length)return!1;var t;for(t=0;t=0&&n=1&&r[0]<=16?n!==a.OP_1+(r[0]-1):1===r.length&&129===r[0]?n!==a.OP_1NEGATE:r.length<=75?n!==r.length:r.length<=255?n!==a.OP_PUSHDATA1:r.length<=65535&&n!==a.OP_PUSHDATA2))},m.prototype._decodeOP_N=function(e){if(e===a.OP_0)return 0;if(e>=a.OP_1&&e<=a.OP_16)return e-(a.OP_1-1);throw new Error("Invalid opcode: "+JSON.stringify(e))},m.prototype.getSignatureOperationsCount=function(e){e=!!h.isUndefined(e)||e;var t=this,r=0,n=a.OP_INVALIDOPCODE;return h.each(t.chunks,function(i){var o=i.opcodenum;o==a.OP_CHECKSIG||o==a.OP_CHECKSIGVERIFY?r++:o!=a.OP_CHECKMULTISIG&&o!=a.OP_CHECKMULTISIGVERIFY||(e&&n>=a.OP_1&&n<=a.OP_16?r+=t._decodeOP_N(n):r+=20),n=o}),r},e.exports=m}).call(this,r(0).Buffer)},function(e,t,r){"use strict";var n=r(18),i=r(21),o=r(29),s=r(68),a=r(97),u=r(252);function c(e){if(!(this instanceof c))return new c(e);i.checkArgument(n.isObject(e),"Must provide an object from where to extract data");var t=e.address?new a(e.address):void 0,r=e.txid?e.txid:e.txId;if(!r||!o.isHexaString(r)||r.length>64)throw new Error("Invalid TXID in object",e);var f=n.isUndefined(e.vout)?e.outputIndex:e.vout;if(!n.isNumber(f))throw new Error("Invalid outputIndex, received "+f);i.checkArgument(!n.isUndefined(e.scriptPubKey)||!n.isUndefined(e.script),"Must provide the scriptPubKey for that output!");var l=new s(e.scriptPubKey||e.script);i.checkArgument(!n.isUndefined(e.amount)||!n.isUndefined(e.satoshis),"Must provide an amount for the output");var h=n.isUndefined(e.amount)?e.satoshis:new u.fromBTC(e.amount).toSatoshis();i.checkArgument(n.isNumber(h),"Amount must be a number"),o.defineImmutable(this,{address:t,txId:r,outputIndex:f,script:l,satoshis:h})}c.prototype.inspect=function(){return""},c.prototype.toString=function(){return this.txId+":"+this.outputIndex},c.fromObject=function(e){return new c(e)},c.prototype.toObject=c.prototype.toJSON=function(){return{address:this.address?this.address.toString():void 0,txid:this.txId,vout:this.outputIndex,scriptPubKey:this.script.toBuffer().toString("hex"),amount:u.fromSatoshis(this.satoshis).toBTC()}},e.exports=c},function(e,t,r){"use strict";(function(t){var n=r(18),i=r(180),o=r(24),s=r(82),a=r(57),u=r(43),c=(r(29),r(178)),f=r(21);function l(e){if(!(this instanceof l))return new l(e);var t={};if(o.isBuffer(e))t=l._fromBufferReader(s(e));else{if(!n.isObject(e))throw new TypeError("Unrecognized argument for MerkleBlock");t={header:e.header instanceof i?e.header:i.fromObject(e.header),numTransactions:e.numTransactions,hashes:e.hashes,flags:e.flags}}return n.extend(this,t),this._flagBitsUsed=0,this._hashesUsed=0,this}l.fromBuffer=function(e){return l.fromBufferReader(s(e))},l.fromBufferReader=function(e){return new l(l._fromBufferReader(e))},l.prototype.toBuffer=function(){return this.toBufferWriter().concat()},l.prototype.toBufferWriter=function(e){e||(e=new a),e.write(this.header.toBuffer()),e.writeUInt32LE(this.numTransactions),e.writeVarintNum(this.hashes.length);for(var r=0;rthis.numTransactions)return!1;if(8*this.flags.length8*this.flags.length)return null;var i=this.flags[n.flagBitsUsed>>3]>>>(7&n.flagBitsUsed++)&1;if(0!==e&&i){var o=this._traverseMerkleTree(e-1,2*r,n),s=o;return 2*r+1=this.hashes.length)return null;var a=this.hashes[n.hashesUsed++];return 0===e&&i&&n.txs.push(a),new t(a,"hex")},l.prototype._calcTreeWidth=function(e){return this.numTransactions+(1<>e},l.prototype._calcTreeHeight=function(){for(var e=0;this._calcTreeWidth(e)>1;)e++;return e},l.prototype.hasTransaction=function(e){f.checkArgument(!n.isUndefined(e),"tx cannot be undefined"),f.checkArgument(e instanceof c||"string"==typeof e,'Invalid tx given, tx must be a "string" or "Transaction"');var r=e;e instanceof c&&(r=o.reverse(new t(e.id,"hex")).toString("hex"));var i=[],s=this._calcTreeHeight();return this._traverseMerkleTree(s,0,{txs:i}),-1!==i.indexOf(r)},l._fromBufferReader=function(e){f.checkState(!e.finished(),"No merkleblock data received");var t={};t.header=i.fromBufferReader(e),t.numTransactions=e.readUInt32LE();var r=e.readVarintNum();t.hashes=[];for(var n=0;n=0&&e<_.MaxIndex)},_._getDerivationIndexes=function(e){var t=e.split("/");if(o.contains(_.RootElementAlias,e))return[];if(!o.contains(_.RootElementAlias,t[0]))return null;var r=t.slice(1).map(function(e){var t="'"===e.slice(-1);if(t&&(e=e.slice(0,-1)),!e||"-"===e[0])return NaN;var r=+e;return t&&(r+=_.Hardened),r});return o.any(r,isNaN)?null:r},_.prototype.derive=function(e,t){if(o.isNumber(e))return this._deriveWithNumber(e,t);if(o.isString(e))return this._deriveFromString(e);throw new m.InvalidDerivationArgument(e)},_.prototype._deriveWithNumber=function(e,t){if(!_.isValidPath(e,t))throw new m.InvalidPath(e);t=e>=_.Hardened||t,e<_.Hardened&&!0===t&&(e+=_.Hardened);var r=h.get(this.xprivkey,e,t);if(r)return r;var n,o=b.integerAsBuffer(e);n=t?b.concat([new i.Buffer([0]),this.privateKey.toBuffer(),o]):b.concat([this.publicKey.toBuffer(),o]);var s=f.sha512hmac(n,this._buffers.chainCode),u=a.fromBuffer(s.slice(0,32),{size:32}),c=s.slice(32,64),l=u.add(this.privateKey.toBigNumber()).mod(p.getN()).toBuffer({size:32}),d=new _({network:this.network,depth:this.depth+1,parentFingerPrint:this.fingerPrint,childIndex:e,chainCode:c,privateKey:l});return h.set(this.xprivkey,e,t,d),d},_.prototype._deriveFromString=function(e){if(!_.isValidPath(e))throw new m.InvalidPath(e);return _._getDerivationIndexes(e).reduce(function(e,t){return e._deriveWithNumber(t)},this)},_.isValidSerialized=function(e,t){return!_.getSerializedError(e,t)},_.getSerializedError=function(e,t){if(!o.isString(e)&&!b.isBuffer(e))return new m.UnrecognizedArgument("Expected string or buffer");if(!u.validCharacters(e))return new g.InvalidB58Char("(unknown)",e);try{e=c.decode(e)}catch(t){return new g.InvalidB58Checksum(e)}if(e.length!==_.DataLength)return new m.InvalidLength(e);if(!o.isUndefined(t)){var r=_._validateNetwork(e,t);if(r)return r}return null},_._validateNetwork=function(e,t){var r=l.get(t);if(!r)return new g.InvalidNetworkArgument(t);var n=e.slice(0,4);return b.integerFromBuffer(n)!==r.xprivkey?new g.InvalidNetwork(n):null},_.fromString=function(e){return s.checkArgument(o.isString(e),"No valid string was provided"),new _(e)},_.fromObject=function(e){return s.checkArgument(o.isObject(e),"No valid argument was provided"),new _(e)},_.prototype._buildFromJSON=function(e){return this._buildFromObject(JSON.parse(e))},_.prototype._buildFromObject=function(e){var t={version:e.network?b.integerAsBuffer(l.get(e.network).xprivkey):e.version,depth:o.isNumber(e.depth)?b.integerAsSingleByteBuffer(e.depth):e.depth,parentFingerPrint:o.isNumber(e.parentFingerPrint)?b.integerAsBuffer(e.parentFingerPrint):e.parentFingerPrint,childIndex:o.isNumber(e.childIndex)?b.integerAsBuffer(e.childIndex):e.childIndex,chainCode:o.isString(e.chainCode)?b.hexToBuffer(e.chainCode):e.chainCode,privateKey:o.isString(e.privateKey)&&v.isHexa(e.privateKey)?b.hexToBuffer(e.privateKey):e.privateKey,checksum:e.checksum?e.checksum.length?e.checksum:b.integerAsBuffer(e.checksum):void 0};return this._buildFromBuffers(t)},_.prototype._buildFromSerialized=function(e){var t=c.decode(e),r={version:t.slice(_.VersionStart,_.VersionEnd),depth:t.slice(_.DepthStart,_.DepthEnd),parentFingerPrint:t.slice(_.ParentFingerPrintStart,_.ParentFingerPrintEnd),childIndex:t.slice(_.ChildIndexStart,_.ChildIndexEnd),chainCode:t.slice(_.ChainCodeStart,_.ChainCodeEnd),privateKey:t.slice(_.PrivateKeyStart,_.PrivateKeyEnd),checksum:t.slice(_.ChecksumStart,_.ChecksumEnd),xprivkey:e};return this._buildFromBuffers(r)},_.prototype._generateRandomly=function(e){return _.fromSeed(y.getRandomBuffer(64),e)},_.fromSeed=function(e,r){if(v.isHexaString(e)&&(e=b.hexToBuffer(e)),!t.isBuffer(e))throw new m.InvalidEntropyArgument(e);if(e.length<16)throw new m.InvalidEntropyArgument.NotEnoughEntropy(e);if(e.length>64)throw new m.InvalidEntropyArgument.TooMuchEntropy(e);var n=f.sha512hmac(e,new i.Buffer("Bitcoin seed"));return new _({network:l.get(r)||l.defaultNetwork,depth:0,parentFingerPrint:0,childIndex:0,privateKey:n.slice(0,32),chainCode:n.slice(32,64)})},_.prototype._calcHDPublicKey=function(){if(!this._hdPublicKey){var e=r(437);this._hdPublicKey=new e(this)}},_.prototype._buildFromBuffers=function(e){_._validateBufferArguments(e),v.defineImmutable(this,{_buffers:e});var r=[e.version,e.depth,e.parentFingerPrint,e.childIndex,e.chainCode,b.emptyBuffer(1),e.privateKey],n=i.Buffer.concat(r);if(e.checksum&&e.checksum.length){if(e.checksum.toString()!==c.checksum(n).toString())throw new g.InvalidB58Checksum(n)}else e.checksum=c.checksum(n);var o,s=l.get(b.integerFromBuffer(e.version));o=c.encode(i.Buffer.concat(r)),e.xprivkey=new t(o);var u=new d(a.fromBuffer(e.privateKey),s),h=u.toPublicKey(),p=_.ParentFingerPrintSize,y=f.sha256ripemd160(h.toBuffer()).slice(0,p);return v.defineImmutable(this,{xprivkey:o,network:s,depth:b.integerFromSingleByteBuffer(e.depth),privateKey:u,publicKey:h,fingerPrint:y}),this._hdPublicKey=null,Object.defineProperty(this,"hdPublicKey",{configurable:!1,enumerable:!0,get:function(){return this._calcHDPublicKey(),this._hdPublicKey}}),Object.defineProperty(this,"xpubkey",{configurable:!1,enumerable:!0,get:function(){return this._calcHDPublicKey(),this._hdPublicKey.xpubkey}}),this},_._validateBufferArguments=function(e){var t=function(t,r){var i=e[t];n(b.isBuffer(i),t+" argument is not a buffer"),n(i.length===r,t+" has not the expected size: found "+i.length+", expected "+r)};t("version",_.VersionSize),t("depth",_.DepthSize),t("parentFingerPrint",_.ParentFingerPrintSize),t("childIndex",_.ChildIndexSize),t("chainCode",_.ChainCodeSize),t("privateKey",_.PrivateKeySize),e.checksum&&e.checksum.length&&t("checksum",_.CheckSumSize)},_.prototype.toString=function(){return this.xprivkey},_.prototype.inspect=function(){return""},_.prototype.toObject=_.prototype.toJSON=function(){return{network:l.get(b.integerFromBuffer(this._buffers.version),"xprivkey").name,depth:b.integerFromSingleByteBuffer(this._buffers.depth),fingerPrint:b.integerFromBuffer(this.fingerPrint),parentFingerPrint:b.integerFromBuffer(this._buffers.parentFingerPrint),childIndex:b.integerFromBuffer(this._buffers.childIndex),chainCode:b.bufferToHex(this._buffers.chainCode),privateKey:this.privateKey.toBuffer().toString("hex"),checksum:b.integerFromBuffer(this._buffers.checksum),xprivkey:this.xprivkey}},_.fromBuffer=function(e){return new _(e.toString())},_.prototype.toBuffer=function(){return b.copy(this._buffers.xprivkey)},_.DefaultDepth=0,_.DefaultFingerprint=0,_.DefaultChildIndex=0,_.Hardened=2147483648,_.MaxIndex=2*_.Hardened,_.RootElementAlias=["m","M","m'","M'"],_.VersionSize=4,_.DepthSize=1,_.ParentFingerPrintSize=4,_.ChildIndexSize=4,_.ChainCodeSize=32,_.PrivateKeySize=32,_.CheckSumSize=4,_.DataLength=78,_.SerializedByteSize=82,_.VersionStart=0,_.VersionEnd=_.VersionStart+_.VersionSize,_.DepthStart=_.VersionEnd,_.DepthEnd=_.DepthStart+_.DepthSize,_.ParentFingerPrintStart=_.DepthEnd,_.ParentFingerPrintEnd=_.ParentFingerPrintStart+_.ParentFingerPrintSize,_.ChildIndexStart=_.ParentFingerPrintEnd,_.ChildIndexEnd=_.ChildIndexStart+_.ChildIndexSize,_.ChainCodeStart=_.ChildIndexEnd,_.ChainCodeEnd=_.ChainCodeStart+_.ChainCodeSize,_.PrivateKeyStart=_.ChainCodeEnd+1,_.PrivateKeyEnd=_.PrivateKeyStart+_.PrivateKeySize,_.ChecksumStart=_.PrivateKeyEnd,_.ChecksumEnd=_.ChecksumStart+_.CheckSumSize,n(_.ChecksumEnd===_.SerializedByteSize),e.exports=_}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){var n=r(18),i=r(21),o=r(32),s=r(177),a=r(129),u=r(43),c=r(436),f=r(253),l=r(96),h=r(108),p=r(73),d=r(66),y=d,g=d.HDPublicKey,m=r(17),b=r(29),v=r(24);function _(e){if(e instanceof _)return e;if(!(this instanceof _))return new _(e);if(e){if(n.isString(e)||v.isBuffer(e)){var t=_.getSerializedError(e);if(t){if(v.isBuffer(e)&&!_.getSerializedError(e.toString()))return this._buildFromSerialized(e.toString());if(t instanceof g.ArgumentIsPrivateExtended)return new c(e).hdPublicKey;throw t}return this._buildFromSerialized(e)}if(n.isObject(e))return e instanceof c?this._buildFromPrivate(e):this._buildFromObject(e);throw new g.UnrecognizedArgument(e)}throw new g.MustSupplyArgument}_.isValidPath=function(e){if(n.isString(e)){var t=c._getDerivationIndexes(e);return null!==t&&n.all(t,_.isValidPath)}return!!n.isNumber(e)&&e>=0&&e<_.Hardened},_.prototype.derive=function(e,t){if(n.isNumber(e))return this._deriveWithNumber(e,t);if(n.isString(e))return this._deriveFromString(e);throw new g.InvalidDerivationArgument(e)},_.prototype._deriveWithNumber=function(e,t){if(e>=_.Hardened||t)throw new g.InvalidIndexCantDeriveHardened;if(e<0)throw new g.InvalidPath(e);var r=f.get(this.xpubkey,e,!1);if(r)return r;var n=v.integerAsBuffer(e),i=v.concat([this.publicKey.toBuffer(),n]),s=u.sha512hmac(i,this._buffers.chainCode),a=o.fromBuffer(s.slice(0,32),{size:32}),c=s.slice(32,64),l=p.fromPoint(h.getG().mul(a).add(this.publicKey.point)),d=new _({network:this.network,depth:this.depth+1,parentFingerPrint:this.fingerPrint,childIndex:e,chainCode:c,publicKey:l});return f.set(this.xpubkey,e,!1,d),d},_.prototype._deriveFromString=function(e){if(n.contains(e,"'"))throw new g.InvalidIndexCantDeriveHardened;if(!_.isValidPath(e))throw new g.InvalidPath(e);return c._getDerivationIndexes(e).reduce(function(e,t){return e._deriveWithNumber(t)},this)},_.isValidSerialized=function(e,t){return n.isNull(_.getSerializedError(e,t))},_.getSerializedError=function(e,t){if(!n.isString(e)&&!v.isBuffer(e))return new g.UnrecognizedArgument("expected buffer or string");if(!s.validCharacters(e))return new y.InvalidB58Char("(unknown)",e);try{e=a.decode(e)}catch(t){return new y.InvalidB58Checksum(e)}if(e.length!==_.DataSize)return new g.InvalidLength(e);if(!n.isUndefined(t)){var r=_._validateNetwork(e,t);if(r)return r}var i=v.integerFromBuffer(e.slice(0,4));return i===l.livenet.xprivkey||i===l.testnet.xprivkey?new g.ArgumentIsPrivateExtended:null},_._validateNetwork=function(e,t){var r=l.get(t);if(!r)return new y.InvalidNetworkArgument(t);var n=e.slice(_.VersionStart,_.VersionEnd);return v.integerFromBuffer(n)!==r.xpubkey?new y.InvalidNetwork(n):null},_.prototype._buildFromPrivate=function(e){var t=n.clone(e._buffers),r=h.getG().mul(o.fromBuffer(t.privateKey));return t.publicKey=h.pointToCompressed(r),t.version=v.integerAsBuffer(l.get(v.integerFromBuffer(t.version)).xpubkey),t.privateKey=void 0,t.checksum=void 0,t.xprivkey=void 0,this._buildFromBuffers(t)},_.prototype._buildFromObject=function(e){var t={version:e.network?v.integerAsBuffer(l.get(e.network).xpubkey):e.version,depth:n.isNumber(e.depth)?v.integerAsSingleByteBuffer(e.depth):e.depth,parentFingerPrint:n.isNumber(e.parentFingerPrint)?v.integerAsBuffer(e.parentFingerPrint):e.parentFingerPrint,childIndex:n.isNumber(e.childIndex)?v.integerAsBuffer(e.childIndex):e.childIndex,chainCode:n.isString(e.chainCode)?v.hexToBuffer(e.chainCode):e.chainCode,publicKey:n.isString(e.publicKey)?v.hexToBuffer(e.publicKey):v.isBuffer(e.publicKey)?e.publicKey:e.publicKey.toBuffer(),checksum:n.isNumber(e.checksum)?v.integerAsBuffer(e.checksum):e.checksum};return this._buildFromBuffers(t)},_.prototype._buildFromSerialized=function(e){var t=a.decode(e),r={version:t.slice(_.VersionStart,_.VersionEnd),depth:t.slice(_.DepthStart,_.DepthEnd),parentFingerPrint:t.slice(_.ParentFingerPrintStart,_.ParentFingerPrintEnd),childIndex:t.slice(_.ChildIndexStart,_.ChildIndexEnd),chainCode:t.slice(_.ChainCodeStart,_.ChainCodeEnd),publicKey:t.slice(_.PublicKeyStart,_.PublicKeyEnd),checksum:t.slice(_.ChecksumStart,_.ChecksumEnd),xpubkey:e};return this._buildFromBuffers(r)},_.prototype._buildFromBuffers=function(e){_._validateBufferArguments(e),b.defineImmutable(this,{_buffers:e});var r=[e.version,e.depth,e.parentFingerPrint,e.childIndex,e.chainCode,e.publicKey],n=v.concat(r),i=a.checksum(n);if(e.checksum&&e.checksum.length){if(e.checksum.toString("hex")!==i.toString("hex"))throw new y.InvalidB58Checksum(n,i)}else e.checksum=i;var o,s=l.get(v.integerFromBuffer(e.version));o=a.encode(v.concat(r)),e.xpubkey=new t(o);var c=new p(e.publicKey,{network:s}),f=_.ParentFingerPrintSize,h=u.sha256ripemd160(c.toBuffer()).slice(0,f);return b.defineImmutable(this,{xpubkey:o,network:s,depth:v.integerFromSingleByteBuffer(e.depth),publicKey:c,fingerPrint:h}),this},_._validateBufferArguments=function(e){var t=function(t,r){var n=e[t];m(v.isBuffer(n),t+" argument is not a buffer, it's "+typeof n),m(n.length===r,t+" has not the expected size: found "+n.length+", expected "+r)};t("version",_.VersionSize),t("depth",_.DepthSize),t("parentFingerPrint",_.ParentFingerPrintSize),t("childIndex",_.ChildIndexSize),t("chainCode",_.ChainCodeSize),t("publicKey",_.PublicKeySize),e.checksum&&e.checksum.length&&t("checksum",_.CheckSumSize)},_.fromString=function(e){return i.checkArgument(n.isString(e),"No valid string was provided"),new _(e)},_.fromObject=function(e){return i.checkArgument(n.isObject(e),"No valid argument was provided"),new _(e)},_.prototype.toString=function(){return this.xpubkey},_.prototype.inspect=function(){return""},_.prototype.toObject=_.prototype.toJSON=function(){return{network:l.get(v.integerFromBuffer(this._buffers.version)).name,depth:v.integerFromSingleByteBuffer(this._buffers.depth),fingerPrint:v.integerFromBuffer(this.fingerPrint),parentFingerPrint:v.integerFromBuffer(this._buffers.parentFingerPrint),childIndex:v.integerFromBuffer(this._buffers.childIndex),chainCode:v.bufferToHex(this._buffers.chainCode),publicKey:this.publicKey.toString(),checksum:v.integerFromBuffer(this._buffers.checksum),xpubkey:this.xpubkey}},_.fromBuffer=function(e){return new _(e)},_.prototype.toBuffer=function(){return v.copy(this._buffers.xpubkey)},_.Hardened=2147483648,_.RootElementAlias=["m","M"],_.VersionSize=4,_.DepthSize=1,_.ParentFingerPrintSize=4,_.ChildIndexSize=4,_.ChainCodeSize=32,_.PublicKeySize=33,_.CheckSumSize=4,_.DataSize=78,_.SerializedByteSize=82,_.VersionStart=0,_.VersionEnd=_.VersionStart+_.VersionSize,_.DepthStart=_.VersionEnd,_.DepthEnd=_.DepthStart+_.DepthSize,_.ParentFingerPrintStart=_.DepthEnd,_.ParentFingerPrintEnd=_.ParentFingerPrintStart+_.ParentFingerPrintSize,_.ChildIndexStart=_.ParentFingerPrintEnd,_.ChildIndexEnd=_.ChildIndexStart+_.ChildIndexSize,_.ChainCodeStart=_.ChildIndexEnd,_.ChainCodeEnd=_.ChainCodeStart+_.ChainCodeSize,_.PublicKeyStart=_.ChainCodeEnd,_.PublicKeyEnd=_.PublicKeyStart+_.PublicKeySize,_.ChecksumStart=_.PublicKeyEnd,_.ChecksumEnd=_.ChecksumStart+_.CheckSumSize,m(_.PublicKeyEnd===_.DataSize),m(_.ChecksumEnd===_.SerializedByteSize),e.exports=_}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(254),i=r(255)(),o=r(904),s={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"},a=(t,r,o)=>{n(i.subtle.sign({name:"HMAC"},t,r).then(t=>e.from(t)),o)};t.create=function(e,t,r){const u=s[e];n(i.subtle.importKey("raw",t,{name:"HMAC",hash:{name:u}},!1,["sign"]).then(t=>({digest(e,r){a(t,e,r)},length:o[e]})),r)}}).call(this,r(0).Buffer)},function(e,t,r){var n={ECB:r(908),CBC:r(909),CFB:r(910),CFB8:r(911),CFB1:r(912),OFB:r(913),CTR:r(440),GCM:r(440)},i=r(442);for(var o in i)i[o].module=n[i[o].mode];e.exports=i},function(e,t,r){var n=r(132),i=r(2).Buffer,o=r(441);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(c),f.update(e),t&&f.update(t),c=f.digest();var l=0;if(s>0){var h=a.length-s;l=Math.min(s,c.length),c.copy(a,h,0,l),s-=l}if(l0){var p=u.length-o,d=Math.min(o,c.length-l);c.copy(u,p,l,l+d),o-=d}}return c.fill(0),{key:a,iv:u}}},function(e,t,r){var n=r(13);r(19),n.cipher=n.cipher||{};var i=e.exports=n.cipher.modes=n.cipher.modes||{};function o(e){if("string"==typeof e&&(e=n.util.createBuffer(e)),n.util.isArray(e)&&e.length>4){var t=e;e=n.util.createBuffer();for(var r=0;r0))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._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._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._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._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>1,a=s+(1&e.length),u=e.substr(0,a),c=e.substr(s,a),f=n.util.createBuffer(),l=n.hmac.create();r=t+r;var h=Math.ceil(i/16),p=Math.ceil(i/20);l.start("MD5",u);var d=n.util.createBuffer();f.putBytes(r);for(var y=0;y0&&(c.queue(e,c.createAlert(e,{level:c.Alert.Level.warning,description:c.Alert.Description.no_renegotiation})),c.flush(e)),e.process()},c.parseHelloMessage=function(e,t,r){var i=null,o=e.entity===c.ConnectionEnd.client;if(r<38)e.error(e,{message:o?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.illegal_parameter}});else{var s=t.fragment,u=s.length();if(i={version:{major:s.getByte(),minor:s.getByte()},random:n.util.createBuffer(s.getBytes(32)),session_id:a(s,1),extensions:[]},o?(i.cipher_suite=s.getBytes(2),i.compression_method=s.getByte()):(i.cipher_suites=a(s,2),i.compression_methods=a(s,1)),(u=r-(u-s.length()))>0){for(var f=a(s,2);f.length()>0;)i.extensions.push({type:[f.getByte(),f.getByte()],data:a(f,2)});if(!o)for(var l=0;l0;){if(0!==p.getByte())break;e.session.extensions.server_name.serverNameList.push(a(p,2).getBytes())}}}if(e.session.version&&(i.version.major!==e.session.version.major||i.version.minor!==e.session.version.minor))return e.error(e,{message:"TLS version change is disallowed during renegotiation.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.protocol_version}});if(o)e.session.cipherSuite=c.getCipherSuite(i.cipher_suite);else for(var d=n.util.createBuffer(i.cipher_suites.bytes());d.length()>0&&(e.session.cipherSuite=c.getCipherSuite(d.getBytes(2)),null===e.session.cipherSuite););if(null===e.session.cipherSuite)return e.error(e,{message:"No cipher suites in common.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.handshake_failure},cipherSuite:n.util.bytesToHex(i.cipher_suite)});e.session.compressionMethod=o?i.compression_method:c.CompressionMethod.none}return i},c.createSecurityParameters=function(e,t){var r=e.entity===c.ConnectionEnd.client,n=t.random.bytes(),i=r?e.session.sp.client_random:n,o=r?n:c.createRandom().getBytes();e.session.sp={entity:e.entity,prf_algorithm:c.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:null,cipher_type:null,enc_key_length:null,block_length:null,fixed_iv_length:null,record_iv_length:null,mac_algorithm:null,mac_length:null,mac_key_length:null,compression_algorithm:e.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:i,server_random:o}},c.handleServerHello=function(e,t,r){var n=c.parseHelloMessage(e,t,r);if(!e.fail){if(!(n.version.minor<=e.version.minor))return e.error(e,{message:"Incompatible TLS version.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.protocol_version}});e.version.minor=n.version.minor,e.session.version=e.version;var i=n.session_id.bytes();i.length>0&&i===e.session.id?(e.expect=d,e.session.resuming=!0,e.session.sp.server_random=n.random.bytes()):(e.expect=f,e.session.resuming=!1,c.createSecurityParameters(e,n)),e.session.id=i,e.process()}},c.handleClientHello=function(e,t,r){var i=c.parseHelloMessage(e,t,r);if(!e.fail){var o=i.session_id.bytes(),s=null;if(e.sessionCache&&(null===(s=e.sessionCache.getSession(o))?o="":(s.version.major!==i.version.major||s.version.minor>i.version.minor)&&(s=null,o="")),0===o.length&&(o=n.random.getBytes(32)),e.session.id=o,e.session.clientHelloVersion=i.version,e.session.sp={},s)e.version=e.session.version=s.version,e.session.sp=s.sp;else{for(var a,u=1;u0;)i=a(u.certificate_list,3),o=n.asn1.fromDer(i),i=n.pki.certificateFromAsn1(o,!0),f.push(i)}catch(t){return e.error(e,{message:"Could not parse certificate list.",cause:t,send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.bad_certificate}})}var h=e.entity===c.ConnectionEnd.client;!h&&!0!==e.verifyClient||0!==f.length?0===f.length?e.expect=h?l:v:(h?e.session.serverCertificate=f[0]:e.session.clientCertificate=f[0],c.verifyCertificateChain(e,f)&&(e.expect=h?l:v)):e.error(e,{message:h?"No server certificate provided.":"No client certificate provided.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.illegal_parameter}}),e.process()},c.handleServerKeyExchange=function(e,t,r){if(r>0)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.unsupported_certificate}});e.expect=h,e.process()},c.handleClientKeyExchange=function(e,t,r){if(r<48)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.unsupported_certificate}});var i=t.fragment,o={enc_pre_master_secret:a(i,2).getBytes()},s=null;if(e.getPrivateKey)try{s=e.getPrivateKey(e,e.session.serverCertificate),s=n.pki.privateKeyFromPem(s)}catch(t){e.error(e,{message:"Could not get private key.",cause:t,send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.internal_error}})}if(null===s)return e.error(e,{message:"No private key set.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.internal_error}});try{var u=e.session.sp;u.pre_master_secret=s.decrypt(o.enc_pre_master_secret);var f=e.session.clientHelloVersion;if(f.major!==u.pre_master_secret.charCodeAt(0)||f.minor!==u.pre_master_secret.charCodeAt(1))throw new Error("TLS version rollback attack detected.")}catch(e){u.pre_master_secret=n.random.getBytes(48)}e.expect=w,null!==e.session.clientCertificate&&(e.expect=_),e.process()},c.handleCertificateRequest=function(e,t,r){if(r<3)return e.error(e,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.illegal_parameter}});var n=t.fragment,i={certificate_types:a(n,1),certificate_authorities:a(n,2)};e.session.certificateRequest=i,e.expect=p,e.process()},c.handleCertificateVerify=function(e,t,r){if(r<2)return e.error(e,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.illegal_parameter}});var i=t.fragment;i.read-=4;var o=i.bytes();i.read+=4;var s={signature:a(i,2).getBytes()},u=n.util.createBuffer();u.putBuffer(e.session.md5.digest()),u.putBuffer(e.session.sha1.digest()),u=u.getBytes();try{if(!e.session.clientCertificate.publicKey.verify(u,s.signature,"NONE"))throw new Error("CertificateVerify signature does not match.");e.session.md5.update(o),e.session.sha1.update(o)}catch(t){return e.error(e,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.handshake_failure}})}e.expect=w,e.process()},c.handleServerHelloDone=function(e,t,r){if(r>0)return e.error(e,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.record_overflow}});if(null===e.serverCertificate){var i={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.insufficient_security}},o=e.verify(e,i.alert.description,0,[]);if(!0!==o)return(o||0===o)&&("object"!=typeof o||n.util.isArray(o)?"number"==typeof o&&(i.alert.description=o):(o.message&&(i.message=o.message),o.alert&&(i.alert.description=o.alert))),e.error(e,i)}null!==e.session.certificateRequest&&(t=c.createRecord(e,{type:c.ContentType.handshake,data:c.createCertificate(e)}),c.queue(e,t)),t=c.createRecord(e,{type:c.ContentType.handshake,data:c.createClientKeyExchange(e)}),c.queue(e,t),e.expect=m;var s=function(e,t){null!==e.session.certificateRequest&&null!==e.session.clientCertificate&&c.queue(e,c.createRecord(e,{type:c.ContentType.handshake,data:c.createCertificateVerify(e,t)})),c.queue(e,c.createRecord(e,{type:c.ContentType.change_cipher_spec,data:c.createChangeCipherSpec()})),e.state.pending=c.createConnectionState(e),e.state.current.write=e.state.pending.write,c.queue(e,c.createRecord(e,{type:c.ContentType.handshake,data:c.createFinished(e)})),e.expect=d,c.flush(e),e.process()};if(null===e.session.certificateRequest||null===e.session.clientCertificate)return s(e,null);c.getClientSignature(e,s)},c.handleChangeCipherSpec=function(e,t){if(1!==t.fragment.getByte())return e.error(e,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.illegal_parameter}});var r=e.entity===c.ConnectionEnd.client;(e.session.resuming&&r||!e.session.resuming&&!r)&&(e.state.pending=c.createConnectionState(e)),e.state.current.read=e.state.pending.read,(!e.session.resuming&&r||e.session.resuming&&!r)&&(e.state.pending=null),e.expect=r?y:S,e.process()},c.handleFinished=function(e,t,r){var o=t.fragment;o.read-=4;var s=o.bytes();o.read+=4;var a=t.fragment.getBytes();(o=n.util.createBuffer()).putBuffer(e.session.md5.digest()),o.putBuffer(e.session.sha1.digest());var u=e.entity===c.ConnectionEnd.client,f=u?"server finished":"client finished",l=e.session.sp;if((o=i(l.master_secret,f,o.getBytes(),12)).getBytes()!==a)return e.error(e,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.decrypt_error}});e.session.md5.update(s),e.session.sha1.update(s),(e.session.resuming&&u||!e.session.resuming&&!u)&&(c.queue(e,c.createRecord(e,{type:c.ContentType.change_cipher_spec,data:c.createChangeCipherSpec()})),e.state.current.write=e.state.pending.write,e.state.pending=null,c.queue(e,c.createRecord(e,{type:c.ContentType.handshake,data:c.createFinished(e)}))),e.expect=u?g:k,e.handshaking=!1,++e.handshakes,e.peerCertificate=u?e.session.serverCertificate:e.session.clientCertificate,c.flush(e),e.isConnected=!0,e.connected(e),e.process()},c.handleAlert=function(e,t){var r,n=t.fragment,i={level:n.getByte(),description:n.getByte()};switch(i.description){case c.Alert.Description.close_notify:r="Connection closed.";break;case c.Alert.Description.unexpected_message:r="Unexpected message.";break;case c.Alert.Description.bad_record_mac:r="Bad record MAC.";break;case c.Alert.Description.decryption_failed:r="Decryption failed.";break;case c.Alert.Description.record_overflow:r="Record overflow.";break;case c.Alert.Description.decompression_failure:r="Decompression failed.";break;case c.Alert.Description.handshake_failure:r="Handshake failure.";break;case c.Alert.Description.bad_certificate:r="Bad certificate.";break;case c.Alert.Description.unsupported_certificate:r="Unsupported certificate.";break;case c.Alert.Description.certificate_revoked:r="Certificate revoked.";break;case c.Alert.Description.certificate_expired:r="Certificate expired.";break;case c.Alert.Description.certificate_unknown:r="Certificate unknown.";break;case c.Alert.Description.illegal_parameter:r="Illegal parameter.";break;case c.Alert.Description.unknown_ca:r="Unknown certificate authority.";break;case c.Alert.Description.access_denied:r="Access denied.";break;case c.Alert.Description.decode_error:r="Decode error.";break;case c.Alert.Description.decrypt_error:r="Decrypt error.";break;case c.Alert.Description.export_restriction:r="Export restriction.";break;case c.Alert.Description.protocol_version:r="Unsupported protocol version.";break;case c.Alert.Description.insufficient_security:r="Insufficient security.";break;case c.Alert.Description.internal_error:r="Internal error.";break;case c.Alert.Description.user_canceled:r="User canceled.";break;case c.Alert.Description.no_renegotiation:r="Renegotiation not supported.";break;default:r="Unknown error."}if(i.description===c.Alert.Description.close_notify)return e.close();e.error(e,{message:r,send:!1,origin:e.entity===c.ConnectionEnd.client?"server":"client",alert:i}),e.process()},c.handleHandshake=function(e,t){var r=t.fragment,i=r.getByte(),o=r.getInt24();if(o>r.length())return e.fragmented=t,t.fragment=n.util.createBuffer(),r.read-=4,e.process();e.fragmented=null,r.read-=4;var s=r.bytes(o+4);r.read+=4,i in M[e.entity][e.expect]?(e.entity!==c.ConnectionEnd.server||e.open||e.fail||(e.handshaking=!0,e.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:n.md.md5.create(),sha1:n.md.sha1.create()}),i!==c.HandshakeType.hello_request&&i!==c.HandshakeType.certificate_verify&&i!==c.HandshakeType.finished&&(e.session.md5.update(s),e.session.sha1.update(s)),M[e.entity][e.expect][i](e,t,o)):c.handleUnexpected(e,t)},c.handleApplicationData=function(e,t){e.data.putBuffer(t.fragment),e.dataReady(e),e.process()},c.handleHeartbeat=function(e,t){var r=t.fragment,i=r.getByte(),o=r.getInt16(),s=r.getBytes(o);if(i===c.HeartbeatMessageType.heartbeat_request){if(e.handshaking||o>s.length)return e.process();c.queue(e,c.createRecord(e,{type:c.ContentType.heartbeat,data:c.createHeartbeat(c.HeartbeatMessageType.heartbeat_response,s)})),c.flush(e)}else if(i===c.HeartbeatMessageType.heartbeat_response){if(s!==e.expectedHeartbeatPayload)return e.process();e.heartbeatReceived&&e.heartbeatReceived(e,n.util.createBuffer(s))}e.process()};var f=1,l=2,h=3,p=4,d=5,y=6,g=7,m=8,b=1,v=2,_=3,w=4,S=5,k=6,E=c.handleUnexpected,A=c.handleChangeCipherSpec,x=c.handleAlert,I=c.handleHandshake,T=c.handleApplicationData,B=c.handleHeartbeat,C=[];C[c.ConnectionEnd.client]=[[E,x,I,E,B],[E,x,I,E,B],[E,x,I,E,B],[E,x,I,E,B],[E,x,I,E,B],[A,x,E,E,B],[E,x,I,E,B],[E,x,I,T,B],[E,x,I,E,B]],C[c.ConnectionEnd.server]=[[E,x,I,E,B],[E,x,I,E,B],[E,x,I,E,B],[E,x,I,E,B],[A,x,E,E,B],[E,x,I,E,B],[E,x,I,T,B],[E,x,I,E,B]];var P=c.handleHelloRequest,O=c.handleServerHello,R=c.handleCertificate,N=c.handleServerKeyExchange,L=c.handleCertificateRequest,K=c.handleServerHelloDone,j=c.handleFinished,M=[];M[c.ConnectionEnd.client]=[[E,E,O,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[P,E,E,E,E,E,E,E,E,E,E,R,N,L,K,E,E,E,E,E,E],[P,E,E,E,E,E,E,E,E,E,E,E,N,L,K,E,E,E,E,E,E],[P,E,E,E,E,E,E,E,E,E,E,E,E,L,K,E,E,E,E,E,E],[P,E,E,E,E,E,E,E,E,E,E,E,E,E,K,E,E,E,E,E,E],[P,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[P,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,j],[P,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[P,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E]];var D=c.handleClientHello,U=c.handleClientKeyExchange,F=c.handleCertificateVerify;M[c.ConnectionEnd.server]=[[E,D,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,R,E,E,E,E,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,U,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,F,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,j],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E]],c.generateKeys=function(e,t){var r=i,n=t.client_random+t.server_random;e.session.resuming||(t.master_secret=r(t.pre_master_secret,"master secret",n,48).bytes(),t.pre_master_secret=null),n=t.server_random+t.client_random;var o=2*t.mac_key_length+2*t.enc_key_length,s=e.version.major===c.Versions.TLS_1_0.major&&e.version.minor===c.Versions.TLS_1_0.minor;s&&(o+=2*t.fixed_iv_length);var a=r(t.master_secret,"key expansion",n,o),u={client_write_MAC_key:a.getBytes(t.mac_key_length),server_write_MAC_key:a.getBytes(t.mac_key_length),client_write_key:a.getBytes(t.enc_key_length),server_write_key:a.getBytes(t.enc_key_length)};return s&&(u.client_write_IV=a.getBytes(t.fixed_iv_length),u.server_write_IV=a.getBytes(t.fixed_iv_length)),u},c.createConnectionState=function(e){var t=e.entity===c.ConnectionEnd.client,r=function(){var e={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(e){return!0},compressionState:null,compressFunction:function(e){return!0},updateSequenceNumber:function(){4294967295===e.sequenceNumber[1]?(e.sequenceNumber[1]=0,++e.sequenceNumber[0]):++e.sequenceNumber[1]}};return e},n={read:r(),write:r()};if(n.read.update=function(e,t){return n.read.cipherFunction(t,n.read)?n.read.compressFunction(e,t,n.read)||e.error(e,{message:"Could not decompress record.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.decompression_failure}}):e.error(e,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.bad_record_mac}}),!e.fail},n.write.update=function(e,t){return n.write.compressFunction(e,t,n.write)?n.write.cipherFunction(t,n.write)||e.error(e,{message:"Could not encrypt record.",send:!1,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.internal_error}}):e.error(e,{message:"Could not compress record.",send:!1,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.internal_error}}),!e.fail},e.session){var i=e.session.sp;switch(e.session.cipherSuite.initSecurityParameters(i),i.keys=c.generateKeys(e,i),n.read.macKey=t?i.keys.server_write_MAC_key:i.keys.client_write_MAC_key,n.write.macKey=t?i.keys.client_write_MAC_key:i.keys.server_write_MAC_key,e.session.cipherSuite.initConnectionState(n,e,i),i.compression_algorithm){case c.CompressionMethod.none:break;case c.CompressionMethod.deflate:n.read.compressFunction=s,n.write.compressFunction=o;break;default:throw new Error("Unsupported compression algorithm.")}}return n},c.createRandom=function(){var e=new Date,t=+e+6e4*e.getTimezoneOffset(),r=n.util.createBuffer();return r.putInt32(t),r.putBytes(n.random.getBytes(28)),r},c.createRecord=function(e,t){return t.data?{type:t.type,version:{major:e.version.major,minor:e.version.minor},length:t.data.length(),fragment:t.data}:null},c.createAlert=function(e,t){var r=n.util.createBuffer();return r.putByte(t.level),r.putByte(t.description),c.createRecord(e,{type:c.ContentType.alert,data:r})},c.createClientHello=function(e){e.session.clientHelloVersion={major:e.version.major,minor:e.version.minor};for(var t=n.util.createBuffer(),r=0;r0&&(d+=2);var y=e.session.id,g=y.length+1+2+4+28+2+o+1+a+d,m=n.util.createBuffer();return m.putByte(c.HandshakeType.client_hello),m.putInt24(g),m.putByte(e.version.major),m.putByte(e.version.minor),m.putBytes(e.session.sp.client_random),u(m,1,n.util.createBuffer(y)),u(m,2,t),u(m,1,s),d>0&&u(m,2,f),m},c.createServerHello=function(e){var t=e.session.id,r=t.length+1+2+4+28+2+1,i=n.util.createBuffer();return i.putByte(c.HandshakeType.server_hello),i.putInt24(r),i.putByte(e.version.major),i.putByte(e.version.minor),i.putBytes(e.session.sp.server_random),u(i,1,n.util.createBuffer(t)),i.putByte(e.session.cipherSuite.id[0]),i.putByte(e.session.cipherSuite.id[1]),i.putByte(e.session.compressionMethod),i},c.createCertificate=function(e){var t,r=e.entity===c.ConnectionEnd.client,i=null;e.getCertificate&&(t=r?e.session.certificateRequest:e.session.extensions.server_name.serverNameList,i=e.getCertificate(e,t));var o=n.util.createBuffer();if(null!==i)try{n.util.isArray(i)||(i=[i]);for(var s=null,a=0;ac.MaxFragment;)i.push(c.createRecord(e,{type:t.type,data:n.util.createBuffer(o.slice(0,c.MaxFragment))})),o=o.slice(c.MaxFragment);o.length>0&&i.push(c.createRecord(e,{type:t.type,data:n.util.createBuffer(o)}))}for(var s=0;s0&&(i=r.order[0]),null!==i&&i in r.cache)for(var o in t=r.cache[i],delete r.cache[i],r.order)if(r.order[o]===i){r.order.splice(o,1);break}return t},r.setSession=function(e,t){if(r.order.length===r.capacity){var i=r.order.shift();delete r.cache[i]}i=n.util.bytesToHex(e);r.order.push(i),r.cache[i]=t}}return r},c.createConnection=function(e){var t;t=e.caStore?n.util.isArray(e.caStore)?n.pki.createCaStore(e.caStore):e.caStore:n.pki.createCaStore();var r=e.cipherSuites||null;if(null===r)for(var i in r=[],c.CipherSuites)r.push(c.CipherSuites[i]);var o=e.server?c.ConnectionEnd.server:c.ConnectionEnd.client,s=e.sessionCache?c.createSessionCache(e.sessionCache):null,a={version:{major:c.Version.major,minor:c.Version.minor},entity:o,sessionId:e.sessionId,caStore:t,sessionCache:s,cipherSuites:r,connected:e.connected,virtualHost:e.virtualHost||null,verifyClient:e.verifyClient||!1,verify:e.verify||function(e,t,r,n){return t},getCertificate:e.getCertificate||null,getPrivateKey:e.getPrivateKey||null,getSignature:e.getSignature||null,input:n.util.createBuffer(),tlsData:n.util.createBuffer(),data:n.util.createBuffer(),tlsDataReady:e.tlsDataReady,dataReady:e.dataReady,heartbeatReceived:e.heartbeatReceived,closed:e.closed,error:function(t,r){r.origin=r.origin||(t.entity===c.ConnectionEnd.client?"client":"server"),r.send&&(c.queue(t,c.createAlert(t,r.alert)),c.flush(t));var n=!1!==r.fatal;n&&(t.fail=!0),e.error(t,r),n&&t.close(!1)},deflate:e.deflate||null,inflate:e.inflate||null,reset:function(e){a.version={major:c.Version.major,minor:c.Version.minor},a.record=null,a.session=null,a.peerCertificate=null,a.state={pending:null,current:null},a.expect=(a.entity,c.ConnectionEnd.client,0),a.fragmented=null,a.records=[],a.open=!1,a.handshakes=0,a.handshaking=!1,a.isConnected=!1,a.fail=!(e||void 0===e),a.input.clear(),a.tlsData.clear(),a.data.clear(),a.state.current=c.createConnectionState(a)}};a.reset();return a.handshake=function(e){if(a.entity!==c.ConnectionEnd.client)a.error(a,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(a.handshaking)a.error(a,{message:"Handshake already in progress.",fatal:!1});else{a.fail&&!a.open&&0===a.handshakes&&(a.fail=!1),a.handshaking=!0;var t=null;(e=e||"").length>0&&(a.sessionCache&&(t=a.sessionCache.getSession(e)),null===t&&(e="")),0===e.length&&a.sessionCache&&null!==(t=a.sessionCache.getSession())&&(e=t.id),a.session={id:e,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:n.md.md5.create(),sha1:n.md.sha1.create()},t&&(a.version=t.version,a.session.sp=t.sp),a.session.sp.client_random=c.createRandom().getBytes(),a.open=!0,c.queue(a,c.createRecord(a,{type:c.ContentType.handshake,data:c.createClientHello(a)})),c.flush(a)}},a.process=function(e){var t=0;return e&&a.input.putBytes(e),a.fail||(null!==a.record&&a.record.ready&&a.record.fragment.isEmpty()&&(a.record=null),null===a.record&&(t=function(e){var t=0,r=e.input,i=r.length();if(i<5)t=5-i;else{e.record={type:r.getByte(),version:{major:r.getByte(),minor:r.getByte()},length:r.getInt16(),fragment:n.util.createBuffer(),ready:!1};var o=e.record.version.major===e.version.major;o&&e.session&&e.session.version&&(o=e.record.version.minor===e.version.minor),o||e.error(e,{message:"Incompatible TLS version.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.protocol_version}})}return t}(a)),a.fail||null===a.record||a.record.ready||(t=function(e){var t=0,r=e.input,n=r.length();return n=0;u--)B>>=8,B+=A.at(u)+T.at(u),T.setAt(u,255&B);I.putBuffer(T)}_=I,l.putBuffer(k)}return l.truncate(l.length()-o),l},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={},u=[];if(!o.validate(t,c,a,u))throw(i=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=u,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,l,p=a.kdfSalt,d=n.util.createBuffer(a.kdfIterationCount);switch(d=d.getInt(d.length()<<3),s.oids[e]){case"aes128-CBC":f=16,l=n.aes.createDecryptionCipher;break;case"aes192-CBC":f=24,l=n.aes.createDecryptionCipher;break;case"aes256-CBC":f=32,l=n.aes.createDecryptionCipher;break;case"des-EDE3-CBC":f=24,l=n.des.createDecryptionCipher;break;case"desCBC":f=8,l=n.des.createDecryptionCipher}var y=h(a.prfOid),g=n.pkcs5.pbkdf2(r,p,d,f,y),m=a.encIv,b=l(g);return b.start(m),b},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 u,c,l,p=n.util.createBuffer(i.salt),d=n.util.createBuffer(i.iterations);switch(d=d.getInt(d.length()<<3),e){case s.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:u=24,c=8,l=n.des.startDecrypting;break;case s.oids["pbewithSHAAnd40BitRC2-CBC"]:u=5,c=8,l=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 g=h(i.prfOid),m=s.pbe.generatePkcs12Key(r,p,1,d,u,g);return g.start(),l(m,s.pbe.generatePkcs12Key(r,p,2,d,c,g))},s.pbe.opensslDeriveBytes=function(e,t,r,i){if(void 0===i||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=[l(i,e+t)],s=16,a=1;s>>0,a>>>0];for(var c=i.fullMessageLength.length-1;c>=0;--c)i.fullMessageLength[c]+=a[1],a[1]=a[0]+(i.fullMessageLength[c]/4294967296>>>0),i.fullMessageLength[c]=i.fullMessageLength[c]>>>0,a[0]=a[1]/4294967296>>>0;return t.putBytes(o),u(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,c=i.fullMessageLength[i.fullMessageLength.length-1]+i.messageLengthSize&i.blockLength-1;s.putBytes(o.substr(0,i.blockLength-c));for(var f=8*i.fullMessageLength[0],l=0;l>>0,s.putInt32(f>>>0),f=a>>>0;s.putInt32(f);var h={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};u(h,r,s);var p=n.util.createBuffer();return p.putInt32(h.h0),p.putInt32(h.h1),p.putInt32(h.h2),p.putInt32(h.h3),p.putInt32(h.h4),p.putInt32(h.h5),p.putInt32(h.h6),p.putInt32(h.h7),p},i};var o=null,s=!1,a=null;function u(e,t,r){for(var n,i,o,s,u,c,f,l,h,p,d,y,g,m=r.length();m>=64;){for(u=0;u<16;++u)t[u]=r.getInt32();for(;u<64;++u)n=((n=t[u-2])>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,i=((i=t[u-15])>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,t[u]=n+t[u-7]+i+t[u-16]|0;for(c=e.h0,f=e.h1,l=e.h2,h=e.h3,p=e.h4,d=e.h5,y=e.h6,g=e.h7,u=0;u<64;++u)o=(c>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10),s=c&f|l&(c^f),n=g+((p>>>6|p<<26)^(p>>>11|p<<21)^(p>>>25|p<<7))+(y^p&(d^y))+a[u]+t[u],g=y,y=d,d=p,p=h+n>>>0,h=l,l=f,f=c,c=n+(i=o+s)>>>0;e.h0=e.h0+c|0,e.h1=e.h1+f|0,e.h2=e.h2+l|0,e.h3=e.h3+h|0,e.h4=e.h4+p|0,e.h5=e.h5+d|0,e.h6=e.h6+y|0,e.h7=e.h7+g|0,m-=64}}},function(e,t,r){(function(t){var n=r(13);r(19);var i=null;!n.util.isNodejs||n.options.usePureJavaScript||t.versions["node-webkit"]||(i=r(450)),(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(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()})}function u(){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 f(e){var t=null;if("undefined"!=typeof window){var r=window.crypto||window.msCrypto;r&&r.getRandomValues&&(t=function(e){return r.getRandomValues(e)})}var i=n.util.createBuffer();if(t)for(;i.length()>16)))<<16,l=4294967295&(c=(2147483647&(c+=u>>15))+(c>>31));for(a=0;a<3;++a)f=l>>>(a<<3),f^=Math.floor(256*Math.random()),i.putByte(String.fromCharCode(255&f))}return i.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,u=t.plugin.formatSeed,c=n.util.createBuffer();t.key=null,function f(l){if(l)return r(l);if(c.length()>=e)return r(null,c.getBytes(e));if(t.generated>1048575&&(t.key=null),null===t.key)return n.util.nextTick(function(){a(f)});var h=i(t.key,t.seed);t.generated+=h.length,c.putBytes(h),t.key=s(i(t.key,o(t.seed))),t.seed=u(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 a=n.util.createBuffer();a.length()1048575&&(t.key=null),null===t.key&&u();var c=r(t.key,t.seed);t.generated+=c.length,a.putBytes(c),t.key=o(r(t.key,i(t.seed))),t.seed=s(r(t.key,t.seed))}return a.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,f(e))}catch(e){t(e)}},t.seedFileSync=f),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(7))},function(e,t,r){var n=r(13);r(19);var i=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],o=[1,2,3,5],s=function(e,t){return e<>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,u=Math.ceil(a/8),c=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-u,i[o.at(128-u)&c]),r=127-u;r>=0;r--)o.setAt(r,i[o.at(r+1)^o.at(r+u)]);return o};var u=function(e,t,r){var i,u,c,f,l=!1,h=null,p=null,d=null,y=[];for(e=n.rc2.expandKey(e,t),c=0;c<64;c++)y.push(e.getInt16Le());r?(i=function(e){for(c=0;c<4;c++)e[c]+=y[f]+(e[(c+3)%4]&e[(c+2)%4])+(~e[(c+3)%4]&e[(c+1)%4]),e[c]=s(e[c],o[c]),f++},u=function(e){for(c=0;c<4;c++)e[c]+=y[63&e[(c+3)%4]]}):(i=function(e){for(c=3;c>=0;c--)e[c]=a(e[c],o[c]),e[c]-=y[f]+(e[(c+3)%4]&e[(c+2)%4])+(~e[(c+3)%4]&e[(c+1)%4]),f--},u=function(e){for(c=3;c>=0;c--)e[c]-=y[63&e[(c+3)%4]]});var g=function(e){var t=[];for(c=0;c<4;c++){var n=h.getInt16Le();null!==d&&(r?n^=d.getInt16Le():d.putInt16Le(n)),t.push(65535&n)}f=r?0:63;for(var i=0;i=8;)g([[5,i],[1,u],[6,i],[1,u],[5,i]])},finish:function(e){var t=!0;if(r)if(e)t=e(8,h,!r);else{var n=8===h.length()?8:8-h.length();h.fillWithByte(n,n)}if(t&&(l=!0,m.update()),!r&&(t=0===h.length()))if(e)t=e(8,p,!r);else{var i=p.length(),o=p.at(i-1);o>i?t=!1:p.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 u(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 u(e,t,!1)}},function(e,t,r){var n=r(13);r(19),r(69),r(134);var i=e.exports=n.pkcs1=n.pkcs1||{};function o(e,t,r){r||(r=n.md.sha1.create());for(var i="",o=Math.ceil(t/r.digestLength),s=0;s>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,u;"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&&(u=r.mgf1.md)),a?a.start():a=n.md.sha1.create(),u||(u=a);var c=Math.ceil(e.n.bitLength()/8),f=c-2*a.digestLength-2;if(t.length>f)throw(y=new Error("RSAES-OAEP input message length is too long.")).length=t.length,y.maxLength=f,y;i||(i=""),a.update(i,"raw");for(var l=a.digest(),h="",p=f-t.length,d=0;dt&&(e=f(t,r)),e.isProbablePrime(s))return c(null,e);e.dAddOffset(i[o++%8],0)}while(a<0||+new Date-le&&(s=f(e,t));var p=s.toString(16);i.target.postMessage({hex:p,workLoad:c}),s.dAddOffset(l,0)}}}p()}function f(e,t){var n=new r(e,t),i=e-1;return n.testBit(i)||n.bitwiseTo(r.ONE.shiftLeft(i),s,n),n.dAddOffset(31-n.mod(o).byteValue(),0),n}}()},function(e,t,r){var n=r(13);r(76),r(133),r(99),r(457),r(449),r(69),r(183),r(134),r(19),r(260);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"}]},u={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"}]}]},c={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"}]},l={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 h(e,t,r,n){for(var i=[],o=0;o=0&&i.push(a):i.push(a))}return i}function p(e){if(e.composed||e.constructed){for(var t=n.util.createBuffer(),r=0;r0&&(u=i.create(i.Class.UNIVERSAL,i.Type.SET,!0,l));var h=[],p=[];null!==t&&(p=n.util.isArray(t)?t:[t]);for(var d=[],y=0;y0){var v=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,d),_=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())])]);h.push(_)}var w=null;if(null!==e){var S=o.wrapRsaPrivateKey(o.privateKeyToAsn1(e));w=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]),u]):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)]),u]);var k=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[w]),E=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(k).getBytes())])]);h.push(E)}var A,x=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,h);if(a.useMac){var I=n.md.sha1.create(),T=new n.util.ByteBuffer(n.random.getBytes(a.saltSize)),B=a.count,C=(e=s.generateKey(r,T,3,B,20),n.hmac.create());C.start(I,e),C.update(i.toDer(x).getBytes());var P=C.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,P.getBytes())]),i.create(i.Class.UNIVERSAL,i.Type.OCTETSTRING,!1,T.getBytes()),i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,i.integerToDer(B).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(x).getBytes())])]),A])},s.generateKey=n.pbe.generatePkcs12Key},function(e,t,r){var n=r(13);r(76),r(19);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 u={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:[u]}]},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(13);r(19),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=p.fullMessageLength.length-1;a>=0;--a)p.fullMessageLength[a]+=s[1],s[1]=s[0]+(p.fullMessageLength[a]/4294967296>>>0),p.fullMessageLength[a]=p.fullMessageLength[a]>>>0,s[0]=s[1]/4294967296>>>0;return i.putBytes(e),l(r,o,i),(i.read>2048||0===i.length())&&i.compact(),p},p.digest=function(){var t=n.util.createBuffer();t.putBytes(i.bytes());var a,u=p.fullMessageLength[p.fullMessageLength.length-1]+p.messageLengthSize&p.blockLength-1;t.putBytes(s.substr(0,p.blockLength-u));for(var c=8*p.fullMessageLength[0],f=0;f>>0,t.putInt32(c>>>0),c=a>>>0;t.putInt32(c);var h=new Array(r.length);for(f=0;f=128;){for(C=0;C<16;++C)t[C][0]=r.getInt32()>>>0,t[C][1]=r.getInt32()>>>0;for(;C<80;++C)n=(((P=(R=t[C-2])[0])>>>19|(O=R[1])<<13)^(O>>>29|P<<3)^P>>>6)>>>0,i=((P<<13|O>>>19)^(O<<3|P>>>29)^(P<<26|O>>>6))>>>0,o=(((P=(L=t[C-15])[0])>>>1|(O=L[1])<<31)^(P>>>8|O<<24)^P>>>7)>>>0,s=((P<<31|O>>>1)^(P<<24|O>>>8)^(P<<25|O>>>7))>>>0,N=t[C-7],K=t[C-16],O=i+N[1]+s+K[1],t[C][0]=n+N[0]+o+K[0]+(O/4294967296>>>0)>>>0,t[C][1]=O>>>0;for(d=e[0][0],y=e[0][1],g=e[1][0],m=e[1][1],b=e[2][0],v=e[2][1],_=e[3][0],w=e[3][1],S=e[4][0],k=e[4][1],E=e[5][0],A=e[5][1],x=e[6][0],I=e[6][1],T=e[7][0],B=e[7][1],C=0;C<80;++C)f=((S>>>14|k<<18)^(S>>>18|k<<14)^(k>>>9|S<<23))>>>0,l=(x^S&(E^x))>>>0,a=((d>>>28|y<<4)^(y>>>2|d<<30)^(y>>>7|d<<25))>>>0,c=((d<<4|y>>>28)^(y<<30|d>>>2)^(y<<25|d>>>7))>>>0,h=(d&g|b&(d^g))>>>0,p=(y&m|v&(y^m))>>>0,O=B+(((S<<18|k>>>14)^(S<<14|k>>>18)^(k<<23|S>>>9))>>>0)+((I^k&(A^I))>>>0)+u[C][1]+t[C][1],n=T+f+l+u[C][0]+t[C][0]+(O/4294967296>>>0)>>>0,i=O>>>0,o=a+h+((O=c+p)/4294967296>>>0)>>>0,s=O>>>0,T=x,B=I,x=E,I=A,E=S,A=k,S=_+n+((O=w+i)/4294967296>>>0)>>>0,k=O>>>0,_=b,w=v,b=g,v=m,g=d,m=y,d=n+o+((O=i+s)/4294967296>>>0)>>>0,y=O>>>0;O=e[0][1]+y,e[0][0]=e[0][0]+d+(O/4294967296>>>0)>>>0,e[0][1]=O>>>0,O=e[1][1]+m,e[1][0]=e[1][0]+g+(O/4294967296>>>0)>>>0,e[1][1]=O>>>0,O=e[2][1]+v,e[2][0]=e[2][0]+b+(O/4294967296>>>0)>>>0,e[2][1]=O>>>0,O=e[3][1]+w,e[3][0]=e[3][0]+_+(O/4294967296>>>0)>>>0,e[3][1]=O>>>0,O=e[4][1]+k,e[4][0]=e[4][0]+S+(O/4294967296>>>0)>>>0,e[4][1]=O>>>0,O=e[5][1]+A,e[5][0]=e[5][0]+E+(O/4294967296>>>0)>>>0,e[5][1]=O>>>0,O=e[6][1]+I,e[6][0]=e[6][0]+x+(O/4294967296>>>0)>>>0,e[6][1]=O>>>0,O=e[7][1]+B,e[7][0]=e[7][0]+T+(O/4294967296>>>0)>>>0,e[7][1]=O>>>0,j-=128}}},function(e,t,r){var n=r(13);r(19),e.exports=n.log=n.log||{},n.log.levels=["none","error","warning","info","debug","verbose","max"];var i={},o=[],s=null;n.log.LEVEL_LOCKED=2,n.log.NO_LEVEL_CHECK=4,n.log.INTERPOLATE=8;for(var a=0;a{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){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(254),i=r(255)();function o(e){return Promise.all([i.subtle.exportKey("jwk",e.privateKey),i.subtle.exportKey("jwk",e.publicKey)])}t.utils=r(930),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(o).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"]);n(Promise.all([r,function(e){return i.subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}(e)]).then(e=>o({privateKey:e[0],publicKey:e[1]})).then(e=>({privateKey:e[0],publicKey:e[1]})),t)},t.getRandomValues=function(t){return e.from(i.getRandomValues(t))},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)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(5),i=r(135).Reporter,o=r(0).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 e instanceof a||(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.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.prototype.join=function(e,t){return e||(e=new o(this.length)),t||(t=0),0===this.length?e:(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";const n=t;n._reverse=function(e){const t={};return Object.keys(e).forEach(function(r){(0|r)==r&&(r|=0);const n=e[r];t[n]=r}),t},n.der=r(935)},function(e,t,r){"use strict";const n=r(5),i=r(15),o=i.base,s=i.bignum,a=i.constants.der;function u(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new c,this.tree._init(e.body)}function c(e){o.Node.call(this,"der",e)}function f(e,t){let r=e.readUInt8(t);if(e.isError(r))return r;const n=a.tagClass[r>>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 l(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;t=31?n.error("Multi-octet tag encoding unsupported"):(t||(i|=32),i|=a.tagClassByName[r||"universal"]<<6)}e.exports=u,u.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},n(c,s.Node),c.prototype._encodeComposite=function(e,t,r,n){const o=l(e,t,r,this.reporter);if(n.length<128){const e=new i(2);return e[0]=o,e[1]=n.length,this._createEncoderBuffer([e,n])}let s=1;for(let e=n.length;e>=256;e>>=8)s++;const a=new i(2+s);a[0]=o,a[1]=128|s;for(let e=1+s,t=n.length;t>0;e--,t>>=8)a[e]=255&t;return this._createEncoderBuffer([a,n])},c.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){const t=new i(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=new i(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=[f(n.getUTCFullYear()),f(n.getUTCMonth()+1),f(n.getUTCDate()),f(n.getUTCHours()),f(n.getUTCMinutes()),f(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[f(n.getUTCFullYear()%100),f(n.getUTCMonth()+1),f(n.getUTCDate()),f(n.getUTCHours()),f(n.getUTCMinutes()),f(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=new i(t)}if(i.isBuffer(e)){let t=e.length;0===e.length&&t++;const r=new i(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(new i(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{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){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";var n=r(2).Buffer,i=r(185),o=r(473);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: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 u=0;a>=0&&0===n[a];a--,++u);if(a>=0&&(u+=1),i=i.dblp(u),a<0)break;var c=n[a];i=c>0?i.mixedAdd(r[c-1>>1]):i.mixedAdd(r[-c-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<{n(i.subtle.sign({name:"HMAC"},t,r).then(t=>e.from(t)),o)};t.create=function(e,t,r){const u=s[e];n(i.subtle.importKey("raw",t,{name:"HMAC",hash:{name:u}},!1,["sign"]).then(t=>({digest(e,r){a(t,e,r)},length:o[e]})),r)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(12),i=r(964);function o(e,t,r,i){if("function"==typeof r&&(i=r,r=void 0),!i)throw new Error("Missing callback");o.digest(e,t,r,(e,o)=>{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){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(263),i=r(264)();function o(e){return Promise.all([i.subtle.exportKey("jwk",e.privateKey),i.subtle.exportKey("jwk",e.publicKey)])}t.utils=r(967),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(o).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"]);n(Promise.all([r,function(e){return i.subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}(e)]).then(e=>o({privateKey:e[0],publicKey:e[1]})).then(e=>({privateKey:e[0],publicKey:e[1]})),t)},t.getRandomValues=function(t){return e.from(i.getRandomValues(t))},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)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(15).bignum;t.toBase64=function(t,r){return t.toArrayLike(e,"be",r).toString("base64").replace(/(=*)$/,"").replace(/\+/g,"-").replace(/\//g,"_")},t.toBn=function(t){return new n(e.from(t,"base64"))}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(478);e.exports=function(e){if(!e||"number"!=typeof e)throw new Error("first argument must be a Number bigger than 0");return n.getRandomValues(new Uint8Array(e))}},function(e,t,r){"use strict";const n=r(974);e.exports={ensureMultiaddr:function(e){return n.isMultiaddr(e)?e:n(e)}}},function(e,t,r){"use strict";var n=r(483).BigInteger,i=r(484),o=r(485),s=r(486),a=r(139).sprintf,u=r(266);function c(e){this.valid=!1,this.address=e,this.groups=u.GROUPS,this.v4=!0,this.subnet="/32",this.subnetMask=32;var t=u.RE_SUBNET_STRING.exec(e);if(t){if(this.parsedSubnet=t[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet="/"+this.subnetMask,this.subnetMask<0||this.subnetMask>u.BITS)return this.valid=!1,void(this.error="Invalid subnet mask.");e=e.replace(u.RE_SUBNET_STRING,"")}this.addressMinusSuffix=e,this.parsedAddress=this.parse(e)}c.prototype.parse=function(e){var t=e.split(".");return e.match(u.RE_ADDRESS)?this.valid=!0:this.error="Invalid IPv4 address.",t},c.prototype.isValid=function(){return this.valid},c.prototype.correctForm=function(){return this.parsedAddress.map(function(e){return parseInt(e,10)}).join(".")},c.prototype.isCorrect=i.isCorrect(u.BITS),c.fromHex=function(e){var t,r=o(e.replace(/:/g,""),8,"0"),n=[];for(t=0;t<8;t+=2){var i=r.slice(t,t+2);n.push(parseInt(i,16))}return new c(n.join("."))},c.fromInteger=function(e){return c.fromHex(e.toString(16))},c.prototype.toHex=function(){return this.parsedAddress.map(function(e){return a("%02x",parseInt(e,10))}).join(":")},c.prototype.toArray=function(){return this.parsedAddress.map(function(e){return parseInt(e,10)})},c.prototype.toGroup6=function(){var e,t=[];for(e=0;e>15;--o>=0;){var u=32767&this[e],c=this[e++]>>15,f=a*u+c*s;i=((u=s*u+((32767&f)<<15)+r[n]+(1073741823&i))>>>30)+(f>>>15)+a*c+(i>>>30),r[n++]=1073741823&u}return i},t=30):i&&"Netscape"!=navigator.appName?(r.prototype.am=function(e,t,r,n,i,o){for(;--o>=0;){var s=t*this[e++]+r[n]+i;i=Math.floor(s/67108864),r[n++]=67108863&s}return i},t=26):(r.prototype.am=function(e,t,r,n,i,o){for(var s=16383&t,a=t>>14;--o>=0;){var u=16383&this[e],c=this[e++]>>14,f=a*u+c*s;i=((u=s*u+((16383&f)<<14)+r[n]+i)>>28)+(f>>14)+a*c,r[n++]=268435455&u}return i},t=28),r.prototype.DB=t,r.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 p(e){this.m=e}function d(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 _(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function w(){}function S(e){return e}function k(e){this.r2=n(),this.q3=n(),r.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}p.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},p.prototype.revert=function(e){return e},p.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},p.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},p.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},d.prototype.convert=function(e){var t=n();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(r.ZERO)>0&&this.m.subTo(t,t),t},d.prototype.revert=function(e){var t=n();return e.copyTo(t),this.reduce(t),t},d.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(e[r=t+this.m.t]+=this.m.am(0,n,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},d.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},d.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},r.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s},r.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0},r.prototype.fromString=function(e,t){var n;if(16==t)n=4;else if(8==t)n=3;else if(256==t)n=8;else if(2==t)n=1;else if(32==t)n=5;else{if(4!=t)return void this.fromRadix(e,t);n=2}this.t=0,this.s=0;for(var i=e.length,o=!1,s=0;--i>=0;){var a=8==n?255&e[i]:f(e,i);a<0?"-"==e.charAt(i)&&(o=!0):(o=!1,0==s?this[this.t++]=a:s+n>this.DB?(this[this.t-1]|=(a&(1<>this.DB-s):this[this.t-1]|=a<=this.DB&&(s-=this.DB))}8==n&&0!=(128&e[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==e;)--this.t},r.prototype.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s},r.prototype.drShiftTo=function(e,t){for(var r=e;r=0;--r)t[r+s+1]=this[r]>>i|a,a=(this[r]&o)<=0;--r)t[r]=0;t[s]=a,t.t=this.t+s+1,t.s=this.s,t.clamp()},r.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[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[r++]=this.DV+n:n>0&&(t[r++]=n),t.t=r,t.clamp()},r.prototype.multiplyTo=function(e,t){var n=this.abs(),i=e.abs(),o=n.t;for(t.t=o+i.t;--o>=0;)t[o]=0;for(o=0;o=0;)e[r]=0;for(r=0;r=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()},r.prototype.divRemTo=function(e,t,i){var o=e.abs();if(!(o.t<=0)){var s=this.abs();if(s.t0?(o.lShiftTo(f,a),s.lShiftTo(f,i)):(o.copyTo(a),s.copyTo(i));var l=a.t,p=a[l-1];if(0!=p){var d=p*(1<1?a[l-2]>>this.F2:0),y=this.FV/d,g=(1<=0&&(i[i.t++]=1,i.subTo(_,i)),r.ONE.dlShiftTo(l,_),_.subTo(a,a);a.t=0;){var w=i[--b]==p?this.DM:Math.floor(i[b]*y+(i[b-1]+m)*g);if((i[b]+=a.am(0,w,i,v,0,l))0&&i.rShiftTo(f,i),u<0&&r.ZERO.subTo(i,i)}}},r.prototype.invDigit=function(){if(this.t<1)return 0;var e=this[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},r.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},r.prototype.exp=function(e,t){if(e>4294967295||e<1)return r.ONE;var i=n(),o=n(),s=t.convert(this),a=h(e)-1;for(s.copyTo(i);--a>=0;)if(t.sqrTo(i,o),(e&1<0)t.mulTo(o,s,i);else{var u=i;i=o,o=u}return t.revert(i)},r.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=c(r));s>=0;)a>(a+=this.DB-t)):(r=this[s]>>(a-=t)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=c(r));return i?o:"0"},r.prototype.negate=function(){var e=n();return r.ZERO.subTo(this,e),e},r.prototype.abs=function(){return this.s<0?this.negate():this},r.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[r]-e[r]))return t;return 0},r.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+h(this[this.t-1]^this.s&this.DM)},r.prototype.mod=function(e){var t=n();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(r.ZERO)>0&&e.subTo(t,t),t},r.prototype.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new p(t):new d(t),this.exp(e,r)},r.ZERO=l(0),r.ONE=l(1),w.prototype.convert=S,w.prototype.revert=S,w.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},w.prototype.sqrTo=function(e,t){e.squareTo(t)},k.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=n();return e.copyTo(t),this.reduce(t),t},k.prototype.revert=function(e){return e},k.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)},k.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},k.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var E,A,x,I=[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,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],T=(1<<26)/I[I.length-1];function B(){!function(e){A[x++]^=255&e,A[x++]^=e>>8&255,A[x++]^=e>>16&255,A[x++]^=e>>24&255,x>=K&&(x-=K)}((new Date).getTime())}if(r.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},r.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),i=l(r),o=n(),s=n(),a="";for(this.divRemTo(i,o,s);o.signum()>0;)a=(r+s.intValue()).toString(e).substr(1)+a,o.divRemTo(i,o,s);return s.intValue().toString(e)+a},r.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var n=this.chunkSize(t),i=Math.pow(t,n),o=!1,s=0,a=0,u=0;u=n&&(this.dMultiply(i),this.dAddOffset(a,0),s=0,a=0))}s>0&&(this.dMultiply(Math.pow(t,s)),this.dAddOffset(a,0)),o&&r.ZERO.subTo(this,this)},r.prototype.fromNumber=function(e,t,n){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,n),this.testBit(e-1)||this.bitwiseTo(r.ONE.shiftLeft(e-1),g,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(r.ONE.shiftLeft(e-1),this);else{var i=new Array,o=7&e;i.length=1+(e>>3),t.nextBytes(i),o>0?i[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[r++]=n:n<-1&&(t[r++]=this.DV+n),t.t=r,t.clamp()},r.prototype.dMultiply=function(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},r.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}},r.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[--i]=0;for(n=r.t-this.t;i=0;)r[n]=0;for(n=Math.max(t-this.t,0);n0)if(0==t)r=this[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this[n])%e;return r},r.prototype.millerRabin=function(e){var t=this.subtract(r.ONE),i=t.getLowestSetBit();if(i<=0)return!1;var o=t.shiftRight(i);(e=e+1>>1)>I.length&&(e=I.length);for(var s=n(),a=0;a>24},r.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},r.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},r.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[e]&(1<>(n+=this.DB-8)):(r=this[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},r.prototype.equals=function(e){return 0==this.compareTo(e)},r.prototype.min=function(e){return this.compareTo(e)<0?this:e},r.prototype.max=function(e){return this.compareTo(e)>0?this:e},r.prototype.and=function(e){var t=n();return this.bitwiseTo(e,y,t),t},r.prototype.or=function(e){var t=n();return this.bitwiseTo(e,g,t),t},r.prototype.xor=function(e){var t=n();return this.bitwiseTo(e,m,t),t},r.prototype.andNot=function(e){var t=n();return this.bitwiseTo(e,b,t),t},r.prototype.not=function(){for(var e=n(),t=0;t=this.t?0!=this.s:0!=(this[t]&1<1){var y=n();for(i.sqrTo(a[1],y);u<=f;)a[u]=n(),i.mulTo(y,a[u-2],a[u]),u+=2}var g,m,b=e.t-1,v=!0,_=n();for(o=h(e[b])-1;b>=0;){for(o>=c?g=e[b]>>o-c&f:(g=(e[b]&(1<0&&(g|=e[b-1]>>this.DB+o-c)),u=r;0==(1&g);)g>>=1,--u;if((o-=u)<0&&(o+=this.DB,--b),v)a[g].copyTo(s),v=!1;else{for(;u>1;)i.sqrTo(s,_),i.sqrTo(_,s),u-=2;u>0?i.sqrTo(s,_):(m=s,s=_,_=m),i.mulTo(_,a[g],s)}for(;b>=0&&0==(e[b]&1<=0?(n.subTo(i,n),t&&o.subTo(a,o),s.subTo(u,s)):(i.subTo(n,i),t&&a.subTo(o,a),u.subTo(s,u))}return 0!=i.compareTo(r.ONE)?r.ZERO:u.compareTo(e)>=0?u.subtract(e):u.signum()<0?(u.addTo(e,u),u.signum()<0?u.add(e):u):u},r.prototype.pow=function(e){return this.exp(e,new w)},r.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},r.prototype.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r[0]<=I[I.length-1]){for(t=0;t>>8,A[x++]=255&C;x=0,B()}function R(){if(null==E){for(B(),(E=new L).init(A),x=0;xn)return r;do{t%2&&(r+=e),(t=N(t/2))&&(e+=e)}while(t);return r}function M(e){if("string"==typeof e)return e;if(F(e))return K?K.call(e):"";var t=e+"";return"0"==t&&1/e==-r?"-0":t}function D(e,t,r){var n=e.length;return r=void 0===r?n:r,!t&&r>=n?e:function(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Array(i);++n-1&&e%1==0&&e-1&&e%1==0&&e<=n}(e.length)&&!function(e){var t=A(e)?b.call(e):"";return t==s||t==a}(e)}(r)&&k(t,r.length):"string"==n&&t in r)&&function(e,t){return e===t||e!=e&&t!=t}(r[t],e)}function A(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function x(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&b.call(e)==u}function I(e){return e?(e=function(e){if("number"==typeof e)return e;if(x(e))return o;if(A(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=A(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(c,"");var r=l.test(e);return r||h.test(e)?d(e.slice(2),r?2:8):f.test(e)?o:+e}(e))===r||e===-r?(e<0?-1:1)*i:e==e?e:0:0===e?e:0}function T(e){return null==e?"":function(e){if("string"==typeof e)return e;if(x(e))return S?S.call(e):"";var t=e+"";return"0"==t&&1/e==-r?"-0":t}(e)}e.exports=function(e,t,r){return t=(r?E(e,t,r):void 0===t)?1:function(e){var t=I(e),r=t%1;return t==t?r?t-r:t:0}(t),function(e,t){var r="";if(!e||t<1||t>n)return r;do{t%2&&(r+=e),(t=_(t/2))&&(e+=e)}while(t);return r}(T(e),t)}}).call(this,r(6))},function(e,t,r){(function(e,r){var n=200,i="Expected a function",o="__lodash_hash_undefined__",s=1,a=2,u=1/0,c=9007199254740991,f=1.7976931348623157e308,l=NaN,h="[object Arguments]",p="[object Array]",d="[object Boolean]",y="[object Date]",g="[object Error]",m="[object Function]",b="[object GeneratorFunction]",v="[object Map]",_="[object Number]",w="[object Object]",S="[object Promise]",k="[object RegExp]",E="[object Set]",A="[object String]",x="[object Symbol]",I="[object WeakMap]",T="[object ArrayBuffer]",B="[object DataView]",C=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,P=/^\w*$/,O=/^\./,R=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,N=/^\s+|\s+$/g,L=/\\(\\)?/g,K=/^[-+]0x[0-9a-f]+$/i,j=/^0b[01]+$/i,M=/^\[object .+?Constructor\]$/,D=/^0o[0-7]+$/i,U=/^(?:0|[1-9]\d*)$/,F={};F["[object Float32Array]"]=F["[object Float64Array]"]=F["[object Int8Array]"]=F["[object Int16Array]"]=F["[object Int32Array]"]=F["[object Uint8Array]"]=F["[object Uint8ClampedArray]"]=F["[object Uint16Array]"]=F["[object Uint32Array]"]=!0,F[h]=F[p]=F[T]=F[d]=F[B]=F[y]=F[g]=F[m]=F[v]=F[_]=F[w]=F[k]=F[E]=F[A]=F[I]=!1;var q=parseInt,H="object"==typeof e&&e&&e.Object===Object&&e,z="object"==typeof self&&self&&self.Object===Object&&self,V=H||z||Function("return this")(),G="object"==typeof t&&t&&!t.nodeType&&t,W=G&&"object"==typeof r&&r&&!r.nodeType&&r,$=W&&W.exports===G&&H.process,Y=function(){try{return $&&$.binding("util")}catch(e){}}(),J=Y&&Y.isTypedArray;function X(e,t){for(var r=-1,n=e?e.length:0;++rc))return!1;var l=o.get(e);if(l&&o.get(t))return l==t;var h=-1,p=!0,d=i&s?new Ne:void 0;for(o.set(e,t),o.set(t,e);++h-1},Oe.prototype.set=function(e,t){var r=this.__data__,n=je(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Re.prototype.clear=function(){this.__data__={hash:new Pe,map:new(be||Oe),string:new Pe}},Re.prototype.delete=function(e){return We(this,e).delete(e)},Re.prototype.get=function(e){return We(this,e).get(e)},Re.prototype.has=function(e){return We(this,e).has(e)},Re.prototype.set=function(e,t){return We(this,e).set(e,t),this},Ne.prototype.add=Ne.prototype.push=function(e){return this.__data__.set(e,o),this},Ne.prototype.has=function(e){return this.__data__.has(e)},Le.prototype.clear=function(){this.__data__=new Oe},Le.prototype.delete=function(e){return this.__data__.delete(e)},Le.prototype.get=function(e){return this.__data__.get(e)},Le.prototype.has=function(e){return this.__data__.has(e)},Le.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Oe){var i=r.__data__;if(!be||i.length-1&&e%1==0&&e-1?i[o?t[s]:s]:void 0}}(function(e,t,r){var n=e?e.length:0;if(!n)return-1;var i=null==r?0:function(e){var t=function(e){return e?(e=function(e){if("number"==typeof e)return e;if(pt(e))return l;if(lt(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=lt(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(N,"");var r=j.test(e);return r||D.test(e)?q(e.slice(2),r?2:8):K.test(e)?l:+e}(e))===u||e===-u?(e<0?-1:1)*f:e==e?e:0:0===e?e:0}(e),r=t%1;return t==t?r?t-r:t:0}(r);return i<0&&(i=ge(n+i,0)),function(e,t,r,n){for(var i=e.length,o=r+(n?1:-1);n?o--:++o-1&&e%1==0&&e<=c}function lt(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function ht(e){return!!e&&"object"==typeof e}function pt(e){return"symbol"==typeof e||ht(e)&&ce.call(e)==x}var dt=J?function(e){return function(t){return e(t)}}(J):function(e){return ht(e)&&ft(e.length)&&!!F[ce.call(e)]};function yt(e){return ut(e)?Ke(e):He(e)}function gt(e){return e}r.exports=nt}).call(this,r(6),r(27)(e))},function(e,t,r){"use strict";var n=r(139).sprintf,i=t.spanAllZeroes=function(e){return e.replace(/(0+)/g,'$1')};function o(e){return e.replace(/^(0+)/,'$1')}t.spanAll=function(e,t){return void 0===t&&(t=0),e.split("").map(function(e,r){return n('%s',e,r+t,i(e))}).join("")},t.spanLeadingZeroes=function(e){return e.split(":").map(function(e){return o(e)}).join(":")},t.simpleGroup=function(e,t){var r=e.split(":");return t||(t=0),r.map(function(e,r){return/group-v4/.test(e)?e:n('%s',r+t,o(e))}).join(":")}},function(e,t,r){"use strict";(function(t){const n=r(14),i=r(12),o=r(9),s=/^https?:\/\/[^/]+\/(ip(f|n)s)\/((\w+).*)/,a=/^\/(ip(f|n)s)\/((\w+).*)/;function u(e){try{return o.isCID(new o(e))}catch(e){return!1}}function c(e,t){const r=l(e);if(!r)return!1;const n=r.match(t);return!!n&&("ipfs"===n[1]&&u(n[4]))}function f(e,t){const r=l(e);if(!r)return!1;const n=r.match(t);return!!n&&"ipns"===n[1]}function l(e){return t.isBuffer(e)?n.encode(e):"string"==typeof e&&e}e.exports={multihash:function(e){const r=l(e);try{const o=new t(n.decode(r));return i.decode(o),!0}catch(e){return!1}},cid:u,ipfsUrl:e=>c(e,s),ipnsUrl:e=>f(e,s),url:e=>c(e,s)||f(e,s),urlPattern:s,ipfsPath:e=>c(e,a),ipnsPath:e=>f(e,a),path:e=>c(e,a)||f(e,a),pathPattern:a,urlOrPath:e=>c(e,s)||f(e,s)||c(e,a)||f(e,a)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(14),i=r(987),o=r(51);function s(e){let r;if("string"==typeof e)r=e;else if(t.isBuffer(e))r=n.encode(e).toString();else if(i.isPeerId(e))r=e.toB58String();else{if(!o.isPeerInfo(e))throw new Error("not valid PeerId or PeerInfo, or B58Str");r=e.id.toB58String()}return r}e.exports=class{constructor(){this._peers={}}has(e){const t=s(e);return Boolean(this._peers[t])}put(e,t){const r=this._peers[e.id.toB58String()];if(!r||t)return this._peers[e.id.toB58String()]=e,e;e.multiaddrs.forEach(e=>r.multiaddrs.add(e));const n=e.isConnected();return n&&r.connect(n),e.protocols.forEach(e=>r.protocols.add(e)),!r.id.privKey&&e.id.privKey&&(r.id.privKey=e.id.privKey),!r.id.pubKey&&e.id.pubKey&&(r.id.pubKey=e.id.pubKey),r}get(e){const t=s(e),r=this._peers[t];if(r)return r;throw new Error("PeerInfo not found")}getAll(){return this._peers}getAllArray(){return Object.keys(this._peers).map(e=>this._peers[e])}getMultiaddrs(e){return this.get(e).multiaddrs.toArray()}remove(e){const t=s(e);this._peers[t]&&delete this._peers[t]}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(270),i=r(271)(),o=r(989),s={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"},a=(t,r,o)=>{n(i.subtle.sign({name:"HMAC"},t,r).then(t=>e.from(t)),o)};t.create=function(e,t,r){const u=s[e];n(i.subtle.importKey("raw",t,{name:"HMAC",hash:{name:u}},!1,["sign"]).then(t=>({digest(e,r){a(t,e,r)},length:o[e]})),r)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(12),i=r(994);function o(e,t,r,i){if("function"==typeof r&&(i=r,r=void 0),!i)throw new Error("Missing callback");o.digest(e,t,r,(e,o)=>{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){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(270),i=r(271)();function o(e){return Promise.all([i.subtle.exportKey("jwk",e.privateKey),i.subtle.exportKey("jwk",e.publicKey)])}t.utils=r(997),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(o).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"]);n(Promise.all([r,function(e){return i.subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}(e)]).then(e=>o({privateKey:e[0],publicKey:e[1]})).then(e=>({privateKey:e[0],publicKey:e[1]})),t)},t.getRandomValues=function(t){return e.from(i.getRandomValues(t))},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)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(15).bignum;t.toBase64=function(t,r){return t.toArrayLike(e,"be",r).toString("base64").replace(/(=*)$/,"").replace(/\+/g,"-").replace(/\//g,"_")},t.toBn=function(t){return new n(e.from(t,"base64"))}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(494);e.exports=function(e){if(!e||"number"!=typeof e)throw new Error("first argument must be a Number bigger than 0");return n.getRandomValues(new Uint8Array(e))}},function(e,t,r){!function(t,r){e.exports=r()}(0,function(){return 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.i=function(e){return e},r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get: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=32)}([function(e,t,r){"use strict";(function(e,n){var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=r(17),s=r(15),a=r(37),u=r(16),c=r(18),f={};t.clone=function(r,n){if("object"!==(void 0===r?"undefined":i(r))||null===r)return r;var o=(n=n||new Map).get(r);if(o)return o;var s=void 0,a=!1;if(Array.isArray(r))s=[],a=!0;else if(e.isBuffer(r))s=e.from(r);else if(r instanceof Date)s=new Date(r.getTime());else if(r instanceof RegExp)s=new RegExp(r);else{var u=Object.getPrototypeOf(r);u&&u.isImmutable?s=r:(s=Object.create(u),a=!0)}if(n.set(r,s),a)for(var c=Object.getOwnPropertyNames(r),f=0;f1||!n.part&&!l[A])return!1;return(!n.only||!f)&&E},t.flatten=function(e,r){for(var n=r||[],i=0;i1?r-1:0),i=1;i\?@\[\]\^`\{\|\}~\"\\]*$/.test(e),"Bad attribute value ("+e+")"),e.replace(/\\/g,"\\\\").replace(/\"/g,'\\"')},t.escapeHtml=function(e){return c.escapeHtml(e)},t.escapeJavaScript=function(e){return c.escapeJavaScript(e)},t.escapeJson=function(e){return c.escapeJson(e)},t.once=function(e){if(e._hoekOnce)return e;var t=!1,r=function(){if(!t){t=!0;for(var r=arguments.length,n=Array(r),i=0;i1;)y[d=h.shift()]||(y[d]={}),y=y[d];y[d=h.shift()]=t.reach(e,p,n)}return u},t.uniqueFilename=function(e,t){t=t?"."!==t[0]?"."+t:t:"",e=a.resolve(e);var r=[Date.now(),n.pid,s.randomBytes(8).toString("hex")].join("-")+t;return a.join(e,r)},t.stringify=function(){try{for(var e=arguments.length,t=Array(e),r=0;r4&&void 0!==arguments[4]?arguments[4]:this._flags;return u.create(e,t,r,n,i)},e.prototype.createOverrideError=function(e,t,r,n,i,o){return u.create(e,t,r,n,this._flags,i,o)},e.prototype.checkOptions=function(e){var t=r(21).options.validate(e);if(t.error)throw new Error(t.error.details[0].message)},e.prototype.clone=function(){var e=Object.create(Object.getPrototypeOf(this));e.isJoi=!0,e._currentJoi=this._currentJoi,e._type=this._type,e._settings=this._settings,e._baseType=this._baseType,e._valids=this._valids.slice(),e._invalids=this._invalids.slice(),e._tests=this._tests.slice(),e._refs=this._refs.slice(),e._flags=o.clone(this._flags),e._description=this._description,e._unit=this._unit,e._notes=this._notes.slice(),e._tags=this._tags.slice(),e._examples=this._examples.slice(),e._meta=this._meta.slice(),e._inner={};for(var t=Object.keys(this._inner),r=0;r=0?p[d[m]]={key:m,schema:p[d[m]].schema.concat(h[g].schema)}:p.push(h[g])}}else t._inner[f]=t._inner[f].concat(h);else t._inner[f]=h.slice()}}return t},e.prototype._test=function(e,t,r,n){var i=this.clone();return i._tests.push({func:r,name:e,arg:t,options:n}),i},e.prototype.options=function(e){o.assert(!e.context,"Cannot override context"),this.checkOptions(e);var t=this.clone();return t._settings=s.concat(t._settings,e),t},e.prototype.strict=function(e){var t=this.clone(),r=void 0!==e&&!e;return t._settings=s.concat(t._settings,{convert:r}),t},e.prototype.raw=function(e){var t=void 0===e||e;if(this._flags.raw===t)return this;var r=this.clone();return r._flags.raw=t,r},e.prototype.error=function(e){o.assert(e&&(e instanceof Error||"function"==typeof e),"Must provide a valid Error object or a function");var t=this.clone();return t._flags.error=e,t},e.prototype.allow=function(){for(var e=arguments.length,t=Array(e),r=0;r0,"description must be provided when default value is a function"));var r=this.clone();return r._flags.default=e,a.push(r._refs,e),r},e.prototype.empty=function(e){var t=this.clone();return void 0===e?delete t._flags.empty:t._flags.empty=f.schema(this._currentJoi,e),t},e.prototype.when=function(e,t){o.assert(t&&"object"===(void 0===t?"undefined":n(t)),"Invalid options"),o.assert(void 0!==t.then||void 0!==t.otherwise,'options must have at least one of "then" or "otherwise"');var i=t.hasOwnProperty("then")?this.concat(f.schema(this._currentJoi,t.then)):void 0,s=t.hasOwnProperty("otherwise")?this.concat(f.schema(this._currentJoi,t.otherwise)):void 0;c=c||r(10);var a={then:i,otherwise:s};Object.prototype.hasOwnProperty.call(t,"is")&&(a.is=t.is);var u=c.when(e,a);return u._flags.presence="ignore",u._baseType=this,u},e.prototype.description=function(e){o.assert(e&&"string"==typeof e,"Description must be a non-empty string");var t=this.clone();return t._description=e,t},e.prototype.notes=function(e){o.assert(e&&("string"==typeof e||Array.isArray(e)),"Notes must be a non-empty string or array");var t=this.clone();return t._notes=t._notes.concat(e),t},e.prototype.tags=function(e){o.assert(e&&("string"==typeof e||Array.isArray(e)),"Tags must be a non-empty string or array");var t=this.clone();return t._tags=t._tags.concat(e),t},e.prototype.meta=function(e){o.assert(void 0!==e,"Meta cannot be undefined");var t=this.clone();return t._meta=t._meta.concat(e),t},e.prototype.example=function(){o.assert(1===arguments.length,"Missing example");var e=arguments.length<=0?void 0:arguments[0],t=this.clone();return t._examples.push(e),t},e.prototype.unit=function(e){o.assert(e&&"string"==typeof e,"Unit name must be a non-empty string");var t=this.clone();return t._unit=e,t},e.prototype._prepareEmptyValue=function(e){return"string"==typeof e&&this._flags.trim?e.trim():e},e.prototype._validate=function(e,t,r,n){var i=this,c=e;t=t||{key:"",path:[],parent:null,reference:n},this._settings&&(r=s.concat(r,this._settings));var f=[],h=function(){var n=void 0;if(void 0!==e)n=i._flags.raw?c:e;else if(r.noDefaults)n=e;else if(a.isRef(i._flags.default))n=i._flags.default(t.parent,r);else if("function"!=typeof i._flags.default||i._flags.func&&!i._flags.default.description)n=o.clone(i._flags.default);else{var s=void 0;null!==t.parent&&i._flags.default.length>0&&(s=[o.clone(t.parent),r]);var u=l._try(i._flags.default,s);n=u.value,u.error&&f.push(i.createError("any.default",{error:u.error},t,r))}if(f.length&&"function"==typeof i._flags.error){var h=i._flags.error.call(i,f);f="string"==typeof h?[i.createOverrideError("override",{reason:f},t,r,h)]:[].concat(h).map(function(e){return e instanceof Error?e:i.createOverrideError(e.type||"override",e.context,t,r,e.message,e.template)})}return{value:i._flags.strip?void 0:n,finalValue:n,errors:f.length?f:null}};if(this._coerce){var p=this._coerce.call(this,e,t,r);if(p.errors)return e=p.value,f=f.concat(p.errors),h();e=p.value}this._flags.empty&&!this._flags.empty._validate(this._prepareEmptyValue(e),null,l.defaults).errors&&(e=void 0);var d=this._flags.presence||r.presence;if("optional"===d){if(void 0===e){if(!this._flags.hasOwnProperty("default")||void 0!==this._flags.default||"object"!==this._type)return h();e={}}}else{if("required"===d&&void 0===e)return f.push(this.createError("any.required",null,t,r)),h();if("forbidden"===d)return void 0===e?h():(f.push(this.createError("any.unknown",null,t,r)),h())}if(this._valids.has(e,t,r,this._flags.insensitive))return h();if(this._invalids.has(e,t,r,this._flags.insensitive)&&(f.push(this.createError(""===e?"any.empty":"any.invalid",{value:e,invalids:this._invalids.values({stripUndefined:!0})},t,r)),r.abortEarly||void 0===e))return h();if(this._base){var y=this._base.call(this,e,t,r);if(y.errors)return e=y.value,f=f.concat(y.errors),h();if(y.value!==e){if(e=y.value,this._valids.has(e,t,r,this._flags.insensitive))return h();if(this._invalids.has(e,t,r,this._flags.insensitive)&&(f.push(this.createError(""===e?"any.empty":"any.invalid",{value:e,invalids:this._invalids.values({stripUndefined:!0})},t,r)),r.abortEarly))return h()}}if(this._flags.allowOnly&&(f.push(this.createError("any.allowOnly",{value:e,valids:this._valids.values({stripUndefined:!0})},t,r)),r.abortEarly))return h();for(var g=0;g{t(null,e)},e=>{t(e)})}},function(e,t,r){"use strict";e.exports=(()=>{if("undefined"!=typeof self&&(r(65)(self),self.crypto))return self.crypto;throw new Error("Please use an environment with crypto support")})},function(e,t,r){"use strict";e.exports="enum KeyType {\n RSA = 0;\n Ed25519 = 1;\n Secp256k1 = 2;\n}\nmessage PublicKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}\nmessage PrivateKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}"},function(e,t,r){(function(e,r,n){!function(e,r){r(t)}(0,function(t){"use strict";function i(e,t){t|=0;for(var r=Math.max(e.length-t,0),n=Array(r),i=0;i-1&&e%1==0&&e<=M}function D(e){return null!=e&&K(e.length)&&!function(e){if(!a(e))return!1;var t=O(e);return t==N||t==L||t==R||t==j}(e)}var U={};function F(){}function q(e){return function(){if(null!==e){var t=e;e=null,t.apply(this,arguments)}}}var H="function"==typeof Symbol&&Symbol.iterator,z=function(e){return H&&e[H]&&e[H]()};function V(e){return null!=e&&"object"==typeof e}var G="[object Arguments]";function W(e){return V(e)&&O(e)==G}var $=Object.prototype,Y=$.hasOwnProperty,J=$.propertyIsEnumerable,X=W(function(){return arguments}())?W:function(e){return V(e)&&Y.call(e,"callee")&&!J.call(e,"callee")},Z=Array.isArray;var Q="object"==typeof t&&t&&!t.nodeType&&t,ee=Q&&"object"==typeof n&&n&&!n.nodeType&&n,te=ee&&ee.exports===Q?S.Buffer:void 0,re=(te?te.isBuffer:void 0)||function(){return!1},ne=9007199254740991,ie=/^(?:0|[1-9]\d*)$/;function oe(e,t){var r=typeof e;return!!(t=null==t?ne:t)&&("number"==r||"symbol"!=r&&ie.test(e))&&e>-1&&e%1==0&&e2&&(n=i(arguments,1)),t){var c={};Me(o,function(e,t){c[t]=e}),c[e]=n,a=!0,u=Object.create(null),r(t,c)}else o[e]=n,function(e){Le(u[e]||[],function(e){e()}),p()}(e)});s++;var c=b(t[t.length-1]);t.length>1?c(o,n):c(n)}}(e,t)})}function p(){if(0===c.length&&0===s)return r(null,o);for(;c.length&&s=0&&r.push(n)}),r}Me(e,function(t,r){if(!Z(t))return h(r,[t]),void f.push(r);var n=t.slice(0,t.length-1),i=n.length;if(0===i)return h(r,t),void f.push(r);l[r]=i,Le(n,function(o){if(!e[o])throw new Error("async.auto task `"+r+"` has a non-existent dependency `"+o+"` in "+n.join(", "));!function(e,t){var r=u[e];r||(r=u[e]=[]),r.push(t)}(o,function(){0==--i&&h(r,t)})})}),function(){for(var e=0;f.length;)e++,Le(d(f.pop()),function(e){0==--l[e]&&f.push(e)});if(e!==n)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}(),p()};function Fe(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r=n?e:function(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Array(i);++n-1;);return r}(n,i),function(e,t){for(var r=e.length;r--&&De(t,e[r],0)>-1;);return r}(n,i)+1).join("")}var ut=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,ct=/,/,ft=/(=.+)?(\s*)$/,lt=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;function ht(e,t){var r={};Me(e,function(e,t){var n,i=m(e),o=!i&&1===e.length||i&&0===e.length;if(Z(e))n=e.slice(0,-1),e=e[e.length-1],r[t]=n.concat(n.length>0?s:e);else if(o)r[t]=e;else{if(n=function(e){return(e=(e=(e=e.toString().replace(lt,"")).match(ut)[2].replace(" ",""))?e.split(ct):[]).map(function(e){return at(e.replace(ft,""))})}(e),0===e.length&&!i&&0===n.length)throw new Error("autoInject task functions require explicit parameters.");i||n.pop(),r[t]=n.concat(s)}function s(t,r){var i=Fe(n,function(e){return t[e]});i.push(r),b(e).apply(null,i)}}),Ue(r,t)}function pt(){this.head=this.tail=null,this.length=0}function dt(e,t){e.length=1,e.head=e.tail=t}function yt(e,t,r){if(null==t)t=1;else if(0===t)throw new Error("Concurrency must not be zero");var n=b(e),i=0,o=[],s=!1;function a(e,t,r){if(null!=r&&"function"!=typeof r)throw new Error("task callback must be a function");if(f.started=!0,Z(e)||(e=[e]),0===e.length&&f.idle())return h(function(){f.drain()});for(var n=0,i=e.length;n0&&o.splice(a,1),s.callback.apply(s,arguments),null!=t&&f.error(t,s.data)}i<=f.concurrency-f.buffer&&f.unsaturated(),f.idle()&&f.drain(),f.process()}}var c=!1,f={_tasks:new pt,concurrency:t,payload:r,saturated:F,unsaturated:F,buffer:t/4,empty:F,drain:F,error:F,started:!1,paused:!1,push:function(e,t){a(e,!1,t)},kill:function(){f.drain=F,f._tasks.empty()},unshift:function(e,t){a(e,!0,t)},remove:function(e){f._tasks.remove(e)},process:function(){if(!c){for(c=!0;!f.paused&&i2&&(o=i(arguments,1)),n[t]=o,r(e)})},function(e){r(e,n)})}function fr(e,t){cr(xe,e,t)}function lr(e,t,r){cr(Se(t),e,r)}var hr=function(e,t){var r=b(e);return yt(function(e,t){r(e[0],t)},t,1)},pr=function(e,t){var r=hr(e,t);return r.push=function(e,t,n){if(null==n&&(n=F),"function"!=typeof n)throw new Error("task callback must be a function");if(r.started=!0,Z(e)||(e=[e]),0===e.length)return h(function(){r.drain()});t=t||0;for(var i=r._tasks.head;i&&t>=i.priority;)i=i.next;for(var o=0,s=e.length;on?1:0}Be(e,function(e,t){n(e,function(r,n){if(r)return t(r);t(null,{value:e,criteria:n})})},function(e,t){if(e)return r(e);r(null,Fe(t.sort(i),Wt("value")))})}function Cr(e,t,r){var n=b(e);return s(function(i,o){var s,a=!1;i.push(function(){a||(o.apply(null,arguments),clearTimeout(s))}),s=setTimeout(function(){var t=e.name||"anonymous",n=new Error('Callback function "'+t+'" timed out.');n.code="ETIMEDOUT",r&&(n.info=r),a=!0,o(n)},t),n.apply(null,i)})}var Pr=Math.ceil,Or=Math.max;function Rr(e,t,r,n){var i=b(r);Oe(function(e,t,r,n){for(var i=-1,o=Or(Pr((t-e)/(r||1)),0),s=Array(o);o--;)s[n?o:++i]=e,e+=r;return s}(0,e,1),t,i,n)}var Nr=Ee(Rr,1/0),Lr=Ee(Rr,1);function jr(e,t,r,n){arguments.length<=3&&(n=r,r=t,t=Z(e)?[]:{}),n=q(n||F);var i=b(r);xe(e,function(e,r,n){i(t,e,r,n)},function(e){n(e,t)})}function Mr(e,t){var r,n=null;t=t||F,Ft(e,function(e,t){b(e)(function(e,o){r=arguments.length>2?i(arguments,1):o,n=e,t(!e)})},function(){t(n,r)})}function Kr(e){return function(){return(e.unmemoized||e).apply(null,arguments)}}function Dr(e,t,r){r=we(r||F);var n=b(t);if(!e())return r(null);var o=function(t){if(t)return r(t);if(e())return n(o);var s=i(arguments,1);r.apply(null,[null].concat(s))};n(o)}function Ur(e,t,r){Dr(function(){return!e.apply(this,arguments)},t,r)}var Fr=function(e,t){if(t=q(t||F),!Z(e))return t(new Error("First argument to waterfall must be an array of functions"));if(!e.length)return t();var r=0;function n(t){var n=b(e[r++]);t.push(we(o)),n.apply(null,t)}function o(o){if(o||r===e.length)return t.apply(null,arguments);n(i(arguments,1))}n([])},qr={apply:o,applyEach:Ce,applyEachSeries:Ne,asyncify:p,auto:Ue,autoInject:ht,cargo:gt,compose:_t,concat:kt,concatLimit:St,concatSeries:Et,constant:At,detect:Bt,detectLimit:Ct,detectSeries:Pt,dir:Rt,doDuring:Nt,doUntil:jt,doWhilst:Lt,during:Mt,each:Dt,eachLimit:Ut,eachOf:xe,eachOfLimit:ke,eachOfSeries:mt,eachSeries:Ft,ensureAsync:qt,every:zt,everyLimit:Vt,everySeries:Gt,filter:Yt,filterLimit:Jt,filterSeries:Xt,forever:Zt,groupBy:er,groupByLimit:Qt,groupBySeries:tr,log:rr,map:Be,mapLimit:Oe,mapSeries:Re,mapValues:ir,mapValuesLimit:nr,mapValuesSeries:or,memoize:ar,nextTick:ur,parallel:fr,parallelLimit:lr,priorityQueue:pr,queue:hr,race:dr,reduce:bt,reduceRight:yr,reflect:gr,reflectAll:mr,reject:vr,rejectLimit:_r,rejectSeries:wr,retry:kr,retryable:Er,seq:vt,series:Ar,setImmediate:h,some:xr,someLimit:Ir,someSeries:Tr,sortBy:Br,timeout:Cr,times:Nr,timesLimit:Rr,timesSeries:Lr,transform:jr,tryEach:Mr,unmemoize:Kr,until:Ur,waterfall:Fr,whilst:Dr,all:zt,allLimit:Vt,allSeries:Gt,any:xr,anyLimit:Ir,anySeries:Tr,find:Bt,findLimit:Ct,findSeries:Pt,forEach:Dt,forEachSeries:Ft,forEachLimit:Ut,forEachOf:xe,forEachOfSeries:mt,forEachOfLimit:ke,inject:bt,foldl:bt,foldr:yr,select:Yt,selectLimit:Jt,selectSeries:Xt,wrapSync:p};t.default=qr,t.apply=o,t.applyEach=Ce,t.applyEachSeries=Ne,t.asyncify=p,t.auto=Ue,t.autoInject=ht,t.cargo=gt,t.compose=_t,t.concat=kt,t.concatLimit=St,t.concatSeries=Et,t.constant=At,t.detect=Bt,t.detectLimit=Ct,t.detectSeries=Pt,t.dir=Rt,t.doDuring=Nt,t.doUntil=jt,t.doWhilst=Lt,t.during=Mt,t.each=Dt,t.eachLimit=Ut,t.eachOf=xe,t.eachOfLimit=ke,t.eachOfSeries=mt,t.eachSeries=Ft,t.ensureAsync=qt,t.every=zt,t.everyLimit=Vt,t.everySeries=Gt,t.filter=Yt,t.filterLimit=Jt,t.filterSeries=Xt,t.forever=Zt,t.groupBy=er,t.groupByLimit=Qt,t.groupBySeries=tr,t.log=rr,t.map=Be,t.mapLimit=Oe,t.mapSeries=Re,t.mapValues=ir,t.mapValuesLimit=nr,t.mapValuesSeries=or,t.memoize=ar,t.nextTick=ur,t.parallel=fr,t.parallelLimit=lr,t.priorityQueue=pr,t.queue=hr,t.race=dr,t.reduce=bt,t.reduceRight=yr,t.reflect=gr,t.reflectAll=mr,t.reject=vr,t.rejectLimit=_r,t.rejectSeries=wr,t.retry=kr,t.retryable=Er,t.seq=vt,t.series=Ar,t.setImmediate=h,t.some=xr,t.someLimit=Ir,t.someSeries=Tr,t.sortBy=Br,t.timeout=Cr,t.times=Nr,t.timesLimit=Rr,t.timesSeries=Lr,t.transform=jr,t.tryEach=Mr,t.unmemoize=Kr,t.until=Ur,t.waterfall=Fr,t.whilst=Dr,t.all=zt,t.allLimit=Vt,t.allSeries=Gt,t.any=xr,t.anyLimit=Ir,t.anySeries=Tr,t.find=Bt,t.findLimit=Ct,t.findSeries=Pt,t.forEach=Dt,t.forEachSeries=Ft,t.forEachLimit=Ut,t.forEachOf=xe,t.forEachOfSeries=mt,t.forEachOfLimit=ke,t.inject=bt,t.foldl=bt,t.foldr=yr,t.select=Yt,t.selectLimit=Jt,t.selectSeries=Xt,t.wrapSync=p,Object.defineProperty(t,"__esModule",{value:!0})})}).call(this,r(6),r(7),r(27)(e))},function(e,t,r){"use strict";e.exports={maxProvidersPerRequest:3,providerRequestTimeout:1e4,hasBlockTimeout:15e3,provideTimeout:15e3,kMaxPriority:Math.pow(2,31)-1,rebroadcastDelay:1e4,maxListeners:1e3}},function(e,t,r){var n=r(1)("socket.io-parser"),i=r(114),o=r(1087),s=r(512),a=r(513);function u(){}t.protocol=4,t.types=["CONNECT","DISCONNECT","EVENT","ACK","ERROR","BINARY_EVENT","BINARY_ACK"],t.CONNECT=0,t.DISCONNECT=1,t.EVENT=2,t.ACK=3,t.ERROR=4,t.BINARY_EVENT=5,t.BINARY_ACK=6,t.Encoder=u,t.Decoder=l;var c=t.ERROR+'"encode error"';function f(e){var r=""+e.type;if(t.BINARY_EVENT!==e.type&&t.BINARY_ACK!==e.type||(r+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(r+=e.nsp+","),null!=e.id&&(r+=e.id),null!=e.data){var i=function(e){try{return JSON.stringify(e)}catch(e){return!1}}(e.data);if(!1===i)return c;r+=i}return n("encoded %j as %s",e,r),r}function l(){this.reconstructor=null}function h(e){var r=0,i={type:Number(e.charAt(0))};if(null==t.types[i.type])return d("unknown packet type "+i.type);if(t.BINARY_EVENT===i.type||t.BINARY_ACK===i.type){for(var o="";"-"!==e.charAt(++r)&&(o+=e.charAt(r),r!=e.length););if(o!=Number(o)||"-"!==e.charAt(r))throw new Error("Illegal attachments");i.attachments=Number(o)}if("/"===e.charAt(r+1))for(i.nsp="";++r;){if(","===(u=e.charAt(r)))break;if(i.nsp+=u,r===e.length)break}else i.nsp="/";var a=e.charAt(r+1);if(""!==a&&Number(a)==a){for(i.id="";++r;){var u;if(null==(u=e.charAt(r))||Number(u)!=u){--r;break}if(i.id+=e.charAt(r),r===e.length)break}i.id=Number(i.id)}if(e.charAt(++r)){var c=function(e){try{return JSON.parse(e)}catch(e){return!1}}(e.substr(r));if(!1===c||i.type!==t.ERROR&&!s(c))return d("invalid payload");i.data=c}return n("decoded %s as %j",e,i),i}function p(e){this.reconPack=e,this.buffers=[]}function d(e){return{type:t.ERROR,data:"parser error: "+e}}u.prototype.encode=function(e,r){n("encoding packet %j",e),t.BINARY_EVENT===e.type||t.BINARY_ACK===e.type?function(e,t){o.removeBlobs(e,function(e){var r=o.deconstructPacket(e),n=f(r.packet),i=r.buffers;i.unshift(n),t(i)})}(e,r):r([f(e)])},i(l.prototype),l.prototype.add=function(e){var r;if("string"==typeof e)r=h(e),t.BINARY_EVENT===r.type||t.BINARY_ACK===r.type?(this.reconstructor=new p(r),0===this.reconstructor.reconPack.attachments&&this.emit("decoded",r)):this.emit("decoded",r);else{if(!a(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");(r=this.reconstructor.takeBinaryData(e))&&(this.reconstructor=null,this.emit("decoded",r))}},l.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},p.prototype.takeBinaryData=function(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){var t=o.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null},p.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]}},function(e,t,r){(function(t){var n=r(1090);e.exports=function(e){var r=e.xdomain,i=e.xscheme,o=e.enablesXDR;try{if("undefined"!=typeof XMLHttpRequest&&(!r||n))return new XMLHttpRequest}catch(e){}try{if("undefined"!=typeof XDomainRequest&&!i&&o)return new XDomainRequest}catch(e){}if(!r)try{return new(t[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}}).call(this,r(7))},function(e,t,r){var n=r(115),i=r(114);function o(e){this.path=e.path,this.hostname=e.hostname,this.port=e.port,this.secure=e.secure,this.query=e.query,this.timestampParam=e.timestampParam,this.timestampRequests=e.timestampRequests,this.readyState="",this.agent=e.agent||!1,this.socket=e.socket,this.enablesXDR=e.enablesXDR,this.pfx=e.pfx,this.key=e.key,this.passphrase=e.passphrase,this.cert=e.cert,this.ca=e.ca,this.ciphers=e.ciphers,this.rejectUnauthorized=e.rejectUnauthorized,this.forceNode=e.forceNode,this.extraHeaders=e.extraHeaders,this.localAddress=e.localAddress}e.exports=o,i(o.prototype),o.prototype.onError=function(e,t){var r=new Error(e);return r.type="TransportError",r.description=t,this.emit("error",r),this},o.prototype.open=function(){return"closed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this.doOpen()),this},o.prototype.close=function(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this},o.prototype.send=function(e){if("open"!==this.readyState)throw new Error("Transport not open");this.write(e)},o.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},o.prototype.onData=function(e){var t=n.decodePacket(e,this.socket.binaryType);this.onPacket(t)},o.prototype.onPacket=function(e){this.emit("packet",e)},o.prototype.onClose=function(){this.readyState="closed",this.emit("close")}},function(e,t,r){"use strict";e.exports=function(e,t){return e.then(e=>{t(null,e)},e=>{t(e)})}},function(e,t,r){"use strict";e.exports=(()=>{if("undefined"!=typeof self&&(r(65)(self),self.crypto))return self.crypto;throw new Error("Please use an environment with crypto support")})},function(e,t,r){"use strict";e.exports="enum KeyType {\n RSA = 0;\n Ed25519 = 1;\n Secp256k1 = 2;\n}\nmessage PublicKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}\nmessage PrivateKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}"},function(e,t,r){"use strict";e.exports=function(e,t){return e.then(e=>{t(null,e)},e=>{t(e)})}},function(e,t,r){"use strict";e.exports=(()=>{if("undefined"!=typeof self&&(r(65)(self),self.crypto))return self.crypto;throw new Error("Please use an environment with crypto support")})},function(e,t,r){"use strict";e.exports="enum KeyType {\n RSA = 0;\n Ed25519 = 1;\n Secp256k1 = 2;\n}\nmessage PublicKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}\nmessage PrivateKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}"},function(e,t,r){"use strict";(function(e){const n=r(292),i=r(53),o=r(8),s=r(293),a=r(59);t.exchanges=["P-256","P-384","P-521"],t.ciphers=["AES-256","AES-128"],t.hashes=["SHA256","SHA512"],t.theBest=((e,t,r)=>{let n,i;if(e<0)n=r,i=t;else{if(!(e>0))return t[0];n=t,i=r}for(let e of n)for(let t of i)if(e===t)return e;throw new Error("No algorithms in common!")}),t.makeMacAndCipher=((e,t)=>{a([t=>(function(e,t,r){s.hmac.create(e,t,r)})(e.hashT,e.keys.macKey,t),t=>(function(e,t,r,n){if("AES-128"===e||"AES-256"===e)return s.aes.create(r,t,n);n(new Error(`unrecognized cipher type: ${e}`))})(e.cipherT,e.keys.iv,e.keys.cipherKey,t)],(r,n)=>{if(r)return t(r);e.mac=n[0],e.cipher=n[1],t()})}),t.selectBest=((r,n,i)=>{t.digest(e.concat([n.pubKeyBytes,r.nonce]),(o,s)=>{if(o)return i(o);t.digest(e.concat([r.pubKeyBytes,n.nonce]),(o,a)=>{if(o)return i(o);const u=e.compare(s,a);if(0===u)return i(new Error("you are trying to talk to yourself"));i(null,{curveT:t.theBest(u,r.exchanges,n.exchanges),cipherT:t.theBest(u,r.ciphers,n.ciphers),hashT:t.theBest(u,r.hashes,n.hashes),order:u})})})}),t.digest=((e,t)=>{n.digest(e,"sha2-256",e.length,t)}),t.write=function(e,t,r){r=r||(()=>{}),o(o.values([t]),i.encode({fixed:!0,bytes:4}),o.collect((t,n)=>{if(t)return r(t);e.shake.write(n[0]),r()}))},t.read=function(e,t){i.decodeFromReader(e,{fixed:!0,bytes:4},t)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(12),i=r(1157);function o(e,t,r,i){if("function"==typeof r&&(i=r,r=void 0),!i)throw new Error("Missing callback");o.digest(e,t,r,(e,o)=>{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){"use strict";const n=r(541),i=r(1161),o=r(1163);(t=e.exports).aes=i,t.hmac=n,t.keys=o,t.randomBytes=r(544),t.pbkdf2=r(1171)},function(e,t,r){"use strict";e.exports=function(e,t){return e.then(e=>{t(null,e)},e=>{t(e)})}},function(e,t,r){"use strict";e.exports=(()=>{if("undefined"!=typeof self&&(r(65)(self),self.crypto))return self.crypto;throw new Error("Please use an environment with crypto support")})},function(e,t,r){"use strict";e.exports="enum KeyType {\n RSA = 0;\n Ed25519 = 1;\n Secp256k1 = 2;\n}\nmessage PublicKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}\nmessage PrivateKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}"},function(e,t,r){"use strict";(function(e){const n=r(11),i=r(1172),o=r(293),s=r(59),a=r(5),u=r(1),c=u("libp2p:secio");c.error=u("libp2p:secio:error");const f=n(r(1173)),l=r(291);t.createProposal=(e=>(e.proposal.out={rand:o.randomBytes(16),pubkey:e.key.local.public.bytes,exchanges:l.exchanges.join(","),ciphers:l.ciphers.join(","),hashes:l.hashes.join(",")},e.proposalEncoded.out=f.Propose.encode(e.proposal.out),e.proposalEncoded.out)),t.createExchange=((t,r)=>{o.keys.generateEphemeralKeyPair(t.protocols.local.curveT,(n,i)=>{if(n)return r(n);t.ephemeralKey.local=i.key,t.shared.generate=i.genSharedKey;const o=e.concat([t.proposalEncoded.out,t.proposalEncoded.in,t.ephemeralKey.local]);t.key.local.sign(o,(e,n)=>{if(e)return r(e);t.exchange.out={epubkey:t.ephemeralKey.local,signature:n},r(null,f.Exchange.encode(t.exchange.out))})})}),t.identify=((e,t,r)=>{c("1.1 identify"),e.proposalEncoded.in=t,e.proposal.in=f.Propose.decode(t);const n=e.proposal.in.pubkey;e.key.remote=o.keys.unmarshalPublicKey(n),i.createFromPubKey(n.toString("base64"),(t,n)=>{if(t)return r(t);if(e.id.remote){if(e.id.remote.toB58String()!==n.toB58String())return r(new Error("dialed to the wrong peer, Ids do not match"))}else e.id.remote=n;c("1.1 identify - %s - identified remote peer as %s",e.id.local.toB58String(),e.id.remote.toB58String()),r()})}),t.selectProtocols=((e,t)=>{c("1.2 selection");const r={pubKeyBytes:e.key.local.public.bytes,exchanges:l.exchanges,hashes:l.hashes,ciphers:l.ciphers,nonce:e.proposal.out.rand},n={pubKeyBytes:e.proposal.in.pubkey,exchanges:e.proposal.in.exchanges.split(","),hashes:e.proposal.in.hashes.split(","),ciphers:e.proposal.in.ciphers.split(","),nonce:e.proposal.in.rand};l.selectBest(r,n,(r,n)=>{if(r)return t(r);e.protocols.remote={order:n.order,curveT:n.curveT,cipherT:n.cipherT,hashT:n.hashT},e.protocols.local={order:n.order,curveT:n.curveT,cipherT:n.cipherT,hashT:n.hashT},t()})}),t.verify=((t,r,n)=>{c("2.1. verify"),t.exchange.in=f.Exchange.decode(r),t.ephemeralKey.remote=t.exchange.in.epubkey;const i=e.concat([t.proposalEncoded.in,t.proposalEncoded.out,t.ephemeralKey.remote]);t.key.remote.verify(i,t.exchange.in.signature,(e,t)=>e?n(e):t?(c("2.1. verify - signature verified"),void n()):n(new Error("Bad signature")))}),t.generateKeys=((e,t)=>{c("2.2. keys"),a([t=>e.shared.generate(e.exchange.in.epubkey,t),(t,r)=>{e.shared.secret=t,o.keys.keyStretcher(e.protocols.local.cipherT,e.protocols.local.hashT,e.shared.secret,r)},(t,r)=>{if(e.protocols.local.order>0)e.protocols.local.keys=t.k1,e.protocols.remote.keys=t.k2;else{if(!(e.protocols.local.order<0))return r(new Error("you are trying to talk to yourself"));e.protocols.local.keys=t.k2,e.protocols.remote.keys=t.k1}c("2.3. mac + cipher"),s([t=>l.makeMacAndCipher(e.protocols.local,t),t=>l.makeMacAndCipher(e.protocols.remote,t)],r)}],t)}),t.verifyNonce=((e,t)=>{const r=e.proposal.out.rand;if(!r.equals(t))throw new Error(`Failed to read our encrypted nonce: ${r.toString("hex")} != ${t.toString("hex")}`)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";e.exports=function(e,t){return e.then(e=>{t(null,e)},e=>{t(e)})}},function(e,t,r){"use strict";e.exports=(()=>{if("undefined"!=typeof self&&(r(65)(self),self.crypto))return self.crypto;throw new Error("Please use an environment with crypto support")})},function(e,t,r){"use strict";e.exports="enum KeyType {\n RSA = 0;\n Ed25519 = 1;\n Secp256k1 = 2;\n}\nmessage PublicKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}\nmessage PrivateKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}"},function(e,t,r){"use strict";const n=r(11);e.exports=n("\nmessage Identify {\n // protocolVersion determines compatibility between peers\n optional string protocolVersion = 5; // e.g. ipfs/1.0.0\n\n // agentVersion is like a UserAgent string in browsers, or client version in bittorrent\n // includes the client name and client.\n optional string agentVersion = 6; // e.g. go-ipfs/0.1.0\n\n // publicKey is this node's public key (which also gives its node.ID)\n // - may not need to be sent, as secure channel implies it has been sent.\n // - then again, if we change / disable secure channel, may still want it.\n optional bytes publicKey = 1;\n\n // listenAddrs are the multiaddrs the sender node listens for open connections on\n repeated bytes listenAddrs = 2;\n\n // oservedAddr is the multiaddr of the remote endpoint that the sender node perceives\n // this is useful information to convey to the other side, as it helps the remote endpoint\n // determine whether its connection to the local peer goes through NAT.\n optional bytes observedAddr = 4;\n\n repeated string protocols = 3;\n}\n").Identify},function(e,t,r){"use strict";e.exports=function(e,t){return e.then(e=>{t(null,e)},e=>{t(e)})}},function(e,t,r){"use strict";e.exports=(()=>{if("undefined"!=typeof self&&(r(65)(self),self.crypto))return self.crypto;throw new Error("Please use an environment with crypto support")})},function(e,t,r){"use strict";e.exports="enum KeyType {\n RSA = 0;\n Ed25519 = 1;\n Secp256k1 = 2;\n}\nmessage PublicKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}\nmessage PrivateKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}"},function(e,t,r){"use strict";t.Listener=t.listener=r(1223),t.Dialer=t.dialer=r(1227),t.matchSemver=r(1228),t.matchExact=r(560)},function(e,t){e.exports=function(e){return e}},function(e,t,r){"use strict";const n=r(39);function i(e){if("number"==typeof e){if(i.codes[e])return i.codes[e];throw new Error("no protocol with code: "+e)}if("string"==typeof e||e instanceof String){if(i.names[e])return i.names[e];throw new Error("no protocol with name: "+e)}throw new Error("invalid protocol id type: "+e)}function o(e,t,r,n){return{code:e,size:t,name:r,resolvable:Boolean(n)}}i.lengthPrefixedVarSize=-1,i.V=-1,i.table=[[4,32,"ip4"],[6,16,"tcp"],[17,16,"udp"],[33,16,"dccp"],[41,128,"ip6"],[54,-1,"dns4","resolvable"],[55,-1,"dns6","resolvable"],[56,-1,"dnsaddr","resolvable"],[132,16,"sctp"],[302,0,"utp"],[421,i.lengthPrefixedVarSize,"ipfs"],[480,0,"http"],[443,0,"https"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[290,0,"p2p-circuit"]],i.names={},i.codes={},n(i.table,function(e){const t=o.apply(null,e);i.codes[t.code]=t,i.names[t.name]=t}),i.object=o,e.exports=i},function(e,t,r){"use strict";e.exports=function(e,t){return e.then(e=>{t(null,e)},e=>{t(e)})}},function(e,t,r){"use strict";e.exports=(()=>{if("undefined"!=typeof self&&(r(65)(self),self.crypto))return self.crypto;throw new Error("Please use an environment with crypto support")})},function(e,t,r){"use strict";e.exports="enum KeyType {\n RSA = 0;\n Ed25519 = 1;\n Secp256k1 = 2;\n}\nmessage PublicKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}\nmessage PrivateKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}"},function(e,t,r){"use strict";const n=r(8),i=r(53),o=r(101),s=r(1),a=s("libp2p:circuit:stream-handler");a.err=s("libp2p:circuit:error:stream-handler");e.exports=class{constructor(e,t,r,i){this.conn=e,this.stream=null,this.shake=null,this.timeout=t||6e4,this.maxLength=i||4096,"function"==typeof t&&(this.timeout=r||6e4),this.stream=o({timeout:this.timeout},t),this.shake=this.stream.handshake,n(this.stream,e,this.stream)}isValid(){return this.conn&&this.shake&&this.stream}read(e){this.isValid()||e(new Error("handler is not in a valid state")),i.decodeFromReader(this.shake,{maxLength:this.maxLength},(t,r)=>t?(a.err(t),e(t)):e(null,r))}write(e,t){t=t||(()=>{}),this.isValid()||t(new Error("handler is not in a valid state")),n(n.values([e]),i.encode(),n.collect((e,r)=>{if(e)return a.err(e),this.shake.abort(e),t(e);r.forEach(e=>this.shake.write(e)),t()}))}getRawConn(){return this.conn}rest(){const e=this.shake.rest();return this.conn=null,this.stream=null,this.shake=null,e}}},function(e,t,r){"use strict";e.exports={relay:"/libp2p/circuit/relay/0.1.0"}},function(e,t,r){var n=r(1257),i=r(1261);e.exports=function(e,t){var r=i(e,t);return n(r)?r:void 0}},function(e,t){e.exports=function(e,t){return e===t||e!=e&&t!=t}},function(e,t,r){"use strict";e.exports=function(e,t){return e.then(e=>{t(null,e)},e=>{t(e)})}},function(e,t,r){"use strict";e.exports=(()=>{if("undefined"!=typeof self&&(r(65)(self),self.crypto))return self.crypto;throw new Error("Please use an environment with crypto support")})},function(e,t,r){"use strict";e.exports="enum KeyType {\n RSA = 0;\n Ed25519 = 1;\n Secp256k1 = 2;\n}\nmessage PublicKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}\nmessage PrivateKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}"},function(e,t,r){"use strict";e.exports={PROTOCOL:"/ipfs/ping/1.0.0",PING_LENGTH:32}},function(e,t,r){var n=r(157),i=r(160),o="[object Symbol]";e.exports=function(e){return"symbol"==typeof e||i(e)&&n(e)==o}},function(e,t,r){"use strict";const n=r(202);e.exports=function(e){const t=e||100;var r=[];return n(function(e){for(r=r.concat(e);r.length>=t;){const e=t,n=r.slice(0,e);r=r.slice(e),this.queue(n)}},function(e){r.length&&(this.queue(r),r=[]),this.queue(null)})}},function(e,t,r){"use strict";e.exports=class{constructor(e,t){this._options=t||{},Object.assign(this,e)}}},function(e,t,r){var n=r(1387);e.exports=function(e,t,r){r=void 0===r||r;var i,o=!1;return function(s){var a,u,c=0,f=0,l=0,h=[],p=!1,d=!1;function y(){if(a){var e=a;if(u)return a=null,e(u);if(Object.hasOwnProperty.call(h,f)){a=null;var r=h[f];delete h[f],f++,e(null,r),t&&g()}else f>=l&&d&&(a=null,e(d))}}var g=n(function(){if(p=!0,d)return y();o||t&&c-t>=f||(o=!0,s(i,function(t,n){if(o=!1,t)l=c,d=t,y();else{var i=c++;e(n,function(e,t){r?h[i]=t:h.push(t),e&&(u=e),y()}),d||g()}}))});return function(e,t){e?s(d=i=e,function(e){if(t)return t(e)}):(a=t,p||g(),y())}}}},function(e,t,r){"use strict";const n=r(9),i=r(41),{DAGNode:o,DAGLink:s}=i,a=r(5);e.exports=((e,t,r)=>(t=Object.assign({},{parent:void 0,child:void 0,name:"",flush:!0},t)).parent?t.child?void a([e=>{if(t.name)return o.rmLink(t.parent,t.name,e);e(null,t.parent)},(e,r)=>{o.addLink(e,new s(t.name,t.child.size,t.child.hash||t.child.multihash),r)},(r,i)=>{if(!t.flush)return i(null,r);e.dag.put(r,{cid:new n(r.hash||r.multihash)},e=>i(e,r))}],r):r(new Error("No child passed to addLink")):r(new Error("No parent passed to addLink")))},function(e,t,r){"use strict";const n=r(145).exporter,i=r(70),o=r(87),s=r(5),a=r(36),{traverseTo:u}=r(48),c=r(1)("ipfs:mfs:read-pull-stream"),f={offset:0,length:void 0};e.exports=(e=>(function(t,r,l){"function"==typeof r&&(l=r,r={}),r=Object.assign({},f,r),c(`Reading ${t}`),s([r=>u(e,t,{parents:!1},r),(u,c)=>{const f=u.node;if("file"!==a.unmarshal(f.data).type)return c(new Error(`${t} was not a file`));s([t=>i(n(f.multihash,e.dag,{offset:r.offset,length:r.length}),o(t)),(e,t)=>t(null,e[0].content)],c)}],l)}))},function(e,t,r){(function(t){e.exports=function(e,r){var n=[];e.on("data",function(e){n.push(e)}),e.once("end",function(){r&&r(null,t.concat(n)),r=null}),e.once("error",function(e){r&&r(e),r=null})}}).call(this,r(0).Buffer)},function(e,t,r){(function(e){var n=r(1501),i=r(610),o=r(26),s=r(1502),a=r(33),u=t;u.request=function(t,r){t="string"==typeof t?a.parse(t):o(t);var i=-1===e.location.protocol.search(/^https?:$/)?"http:":"",s=t.protocol||i,u=t.hostname||t.host,c=t.port,f=t.path||"/";u&&-1!==u.indexOf(":")&&(u="["+u+"]"),t.url=(u?s+"//"+u:"")+(c?":"+c:"")+f,t.method=(t.method||"GET").toUpperCase(),t.headers=t.headers||{};var l=new n(t);return r&&l.on("response",r),l},u.get=function(e,t){var r=u.request(e,t);return r.end(),r},u.ClientRequest=n,u.IncomingMessage=i.IncomingMessage,u.Agent=function(){},u.Agent.defaultMaxSockets=4,u.globalAgent=new u.Agent,u.STATUS_CODES=s,u.METHODS=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"]}).call(this,r(7))},function(e,t){var r,n=1,i=function(){n=n+1&65535};e.exports=function(e){r||(r=setInterval(i,250)).unref&&r.unref();var t=4*(e||5),o=[0],s=1,a=n-1&65535;return function(e){var r=n-a&65535;for(r>t&&(r=t),a=n;r--;)s===t&&(s=0),o[s]=o[0===s?t-1:s-1],s++;e&&(o[s-1]+=e);var i=o[s-1],u=o.length>>=0;var o=e.byteLength-r;if(o<0)throw new RangeError("'offset' is out of bounds");if(void 0===i)i=o;else if((i>>>=0)>o)throw new RangeError("'length' is out of bounds");return n?t.from(e.slice(r,r+i)):new t(new Uint8Array(e.slice(r,r+i)))}(e,r,o):"string"==typeof e?function(e,r){if("string"==typeof r&&""!==r||(r="utf8"),!t.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');return n?t.from(e,r):new t(e,r)}(e,r):n?t.from(e):new t(e)}}).call(this,r(0).Buffer)},function(e){e.exports={_from:"webtorrent@^0.99.3",_id:"webtorrent@0.99.4",_inBundle:!1,_integrity:"sha512-coJ61iJOFDrSzyCwmhlLaU8tvcchI5ZA0fH9Toj4wwUq/OTUNdjXtNXwpCb6ldbBnJ04lQzxyDeuSR3KtN0MWg==",_location:"/webtorrent",_phantomChildren:{"decompress-response":"3.3.0",once:"1.4.0","simple-concat":"1.0.0"},_requested:{type:"range",registry:!0,raw:"webtorrent@^0.99.3",name:"webtorrent",escapedName:"webtorrent",rawSpec:"^0.99.3",saveSpec:null,fetchSpec:"^0.99.3"},_requiredBy:["/"],_resolved:"https://registry.npmjs.org/webtorrent/-/webtorrent-0.99.4.tgz",_shasum:"b5d4652c72f20f6ad3322b6ecbc7215cf83c6a89",_spec:"webtorrent@^0.99.3",_where:"/Users/mitra/git/dweb-transports",author:{name:"WebTorrent, LLC",email:"feross@webtorrent.io",url:"https://webtorrent.io"},browser:{"./lib/server.js":!1,"./lib/tcp-pool.js":!1,"bittorrent-dht/client":!1,"fs-chunk-store":"memory-chunk-store","load-ip-set":!1,net:!1,os:!1,ut_pex:!1},browserify:{transform:["package-json-versionify"]},bugs:{url:"https://github.com/webtorrent/webtorrent/issues"},bundleDependencies:!1,dependencies:{"addr-to-ip-port":"^1.4.2",bitfield:"^2.0.0","bittorrent-dht":"^8.0.0","bittorrent-protocol":"^2.1.5","chunk-store-stream":"^2.0.2","create-torrent":"^3.24.5",debug:"^3.1.0","end-of-stream":"^1.1.0","fs-chunk-store":"^1.6.2","immediate-chunk-store":"^1.0.8",inherits:"^2.0.1","load-ip-set":"^1.2.7","memory-chunk-store":"^1.2.0",mime:"^2.2.0",multistream:"^2.0.5","package-json-versionify":"^1.0.2","parse-torrent":"^6.0.0",pump:"^3.0.0","random-iterate":"^1.0.1",randombytes:"^2.0.3","range-parser":"^1.2.0","readable-stream":"^2.1.4","render-media":"^3.0.0","run-parallel":"^1.1.6","run-parallel-limit":"^1.0.3","safe-buffer":"^5.0.1","simple-concat":"^1.0.0","simple-get":"^3.0.1","simple-peer":"^9.0.0","simple-sha1":"^2.0.8",speedometer:"^1.0.0","stream-to-blob":"^1.0.0","stream-to-blob-url":"^2.1.0","stream-with-known-length-to-buffer":"^1.0.0","torrent-discovery":"^8.3.1","torrent-piece":"^1.1.0",uniq:"^1.0.1","unordered-array-remove":"^1.0.2",ut_metadata:"^3.0.8",ut_pex:"^1.1.1",xtend:"^4.0.1","zero-fill":"^2.2.3"},deprecated:!1,description:"Streaming torrent client",devDependencies:{airtap:"0.0.4","babel-minify":"^0.3.0","bittorrent-tracker":"^9.4.0",brfs:"^1.4.3",browserify:"^16.0.0","cross-spawn":"^6.0.3",electron:"^2.0.0",finalhandler:"^1.0.0","network-address":"^1.1.0","run-series":"^1.1.4","serve-static":"^1.11.1",standard:"*",tape:"^4.6.0","webtorrent-fixtures":"^1.5.0"},engines:{node:">=4"},homepage:"https://webtorrent.io",keywords:["bittorrent","bittorrent client","download","mad science","p2p","peer-to-peer","peers","streaming","swarm","torrent","web torrent","webrtc","webrtc data","webtorrent"],license:"MIT",main:"index.js",name:"webtorrent",repository:{type:"git",url:"git://github.com/webtorrent/webtorrent.git"},scripts:{build:"browserify -s WebTorrent -e ./ | minify > webtorrent.min.js","build-debug":"browserify -s WebTorrent -e ./ > webtorrent.debug.js",size:"npm run build && cat webtorrent.min.js | gzip | wc -c",test:"standard && npm run test-node && npm run test-browser","test-browser":"airtap -- test/*.js test/browser/*.js","test-browser-local":"airtap --local -- test/*.js test/browser/*.js","test-node":"tape test/*.js test/node/*.js","update-authors":"./scripts/update-authors.sh"},version:"0.99.4"}},function(e,t,r){"use strict";(function(t,n){var i=r(150);e.exports=_;var o,s=r(331);_.ReadableState=v;r(10).EventEmitter;var a=function(e,t){return e.listeners(t).length},u=r(332),c=r(2).Buffer,f=t.Uint8Array||function(){};var l=r(117);l.inherits=r(4);var h=r(629),p=void 0;p=h&&h.debuglog?h.debuglog("stream"):function(){};var d,y=r(630),g=r(334);l.inherits(_,u);var m=["error","close","destroy","pause","resume"];function b(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)}function v(e,t){o=o||r(85),e=e||{};var n=t instanceof o;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&&(d||(d=r(211).StringDecoder),this.decoder=new d(e.encoding),this.encoding=e.encoding)}function _(e){if(o=o||r(85),!(this instanceof _))return new _(e);this._readableState=new v(e,this),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),u.call(this)}function w(e,t,r,n,i){var o,s=e._readableState;return null===t?(s.reading=!1,function(e,t){if(!t.ended){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,A(e)}}(e,s)):(i||(o=function(e,t){var r;return function(e){return c.isBuffer(e)||e instanceof f}(t)||"string"==typeof t||void 0===t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk")),r}(s,t)),o?e.emit("error",o):s.objectMode||t&&t.length>0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===c.prototype||(t=function(e){return c.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):S(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?S(e,s,t,!1):I(e,s)):S(e,s,t,!1))):n||(s.reading=!1)),function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=k?e=k:(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 A(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(p("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i.nextTick(x,e):x(e))}function x(e){p("emit readable"),e.emit("readable"),P(e)}function I(e,t){t.readingMore||(t.readingMore=!0,i.nextTick(T,e,t))}function T(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;return 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=c.allocUnsafe(e),n=t.head,i=1;for(n.data.copy(r),e-=n.data.length;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),n}(e,t.buffer,t.decoder),r);var r}function R(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(N,t,e))}function N(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function L(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return p("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?R(this):A(this),null;if(0===(e=E(e,t))&&t.ended)return 0===t.length&&R(this),null;var n,i=t.needReadable;return p("need readable",i),(0===t.length||t.length-e0?O(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&R(this)),null!==n&&this.emit("data",n),n},_.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},_.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,p("pipe count=%d opts=%j",o.pipesCount,t);var s=t&&!1===t.end||e===n.stdout||e===n.stderr?_:c;function u(e,t){p("onunpipe"),e===r&&t&&!1===t.hasUnpiped&&(t.hasUnpiped=!0,h())}function c(){p("onend"),e.end()}o.endEmitted?i.nextTick(s):r.once("end",s),e.on("unpipe",u);var f=function(e){return function(){var t=e._readableState;p("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&a(e,"data")&&(t.flowing=!0,P(e))}}(r);e.on("drain",f);var l=!1;function h(){p("cleanup"),e.removeListener("close",m),e.removeListener("finish",v),e.removeListener("drain",f),e.removeListener("error",g),e.removeListener("unpipe",u),r.removeListener("end",c),r.removeListener("end",_),r.removeListener("data",y),l=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||f()}var d=!1;function y(t){p("ondata"),d=!1,!1!==e.write(t)||d||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==L(o.pipes,e))&&!l&&(p("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,d=!0),r.pause())}function g(t){p("onerror",t),_(),e.removeListener("error",g),0===a(e,"error")&&e.emit("error",t)}function m(){e.removeListener("finish",v),_()}function v(){p("onfinish"),e.removeListener("close",m),_()}function _(){p("unpipe"),r.unpipe(e)}return r.on("data",y),b(e,"error",g),e.once("close",m),e.once("finish",v),e.emit("pipe",r),o.flowing||(p("pipe resume"),r.resume()),e},_.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?this:(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;o>1,f=-7,l=r?i-1:0,h=r?-1:1,p=e[t+l];for(l+=h,o=p&(1<<-f)-1,p>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=h,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=h,f-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var s,a,u,c=8*o-i-1,f=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=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*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+p]=255&a,p+=d,a/=256,i-=8);for(s=s<0;e[r+p]=255&s,p+=d,s/=256,c-=8);e[r+p-d]|=128*y}},function(e,t,r){"use strict";var n=r(150);function i(e,t){e.emit("error",t)}e.exports={destroy:function(e,t){var r=this,o=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return o||s?(t?t(e):!e||this._writableState&&this._writableState.errorEmitted||n.nextTick(i,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?(n.nextTick(i,r,e),r._writableState&&(r._writableState.errorEmitted=!0)):t&&t(e)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},function(e,t,r){"use strict";e.exports=o;var n=r(85),i=r(117);function o(e){if(!(this instanceof o))return new o(e);n.call(this,e),this._transformState={afterTransform:function(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{setTimeout(()=>{e()},t)}),t*=1+Math.random()}throw console.log("Looping",n,"failed"),o!==(window&&window.loopguard)?(console.log("Looping exited because of page change "+n),new Error("Looping exited because of page change "+n)):i}(s,500,12,"fetching "+e);if(a.ok){let e=a.headers.get("Content-Type");return o?a.body:"application/json"===e?a.json():e.startsWith("text")?a.text():new t(await a.arrayBuffer())}throw new i.TransportError(`Transport Error ${a.status}: ${a.statusText}`)}catch(r){throw console.log("Note error from fetch might be misleading especially TypeError can be Cors issue:",e),r instanceof i.TransportError?r:new i.TransportError(`Transport error thrown by ${e}: ${r.message}`)}},httptools.p_GET=async function(e,t={}){let r=new Headers;(t.start||t.end)&&r.append("range",`bytes=${t.start||0}-${t.end||""}`);let n={method:"GET",headers:r,mode:"cors",cache:"default",redirect:"follow",keepalive:!0};return await httptools.p_httpfetch(e,n,{verbose:t.verbose,wantstream:t.wantstream})},httptools.p_POST=async function(e,t,r,n){let i={method:"POST",headers:{},body:r,mode:"cors",cache:"default",redirect:"follow",keepalive:!0};return await httptools.p_httpfetch(e,i,{verbose:n})},e.exports=httptools}).call(this,r(0).Buffer)},function(e,t,r){"use strict";e.exports=class{constructor(e){this._repo=e,this._bitswap=null}setExchange(e){this._bitswap=e}unsetExchange(){this._bitswap=null}hasExchange(){return null!=this._bitswap}put(e,t){if(this.hasExchange())return this._bitswap.put(e,t);this._repo.blocks.put(e,t)}putMany(e,t){if(this.hasExchange())return this._bitswap.putMany(e,t);this._repo.blocks.putMany(e,t)}get(e,t){return this.hasExchange()?this._bitswap.get(e,t):this._repo.blocks.get(e,t)}delete(e,t){this._repo.blocks.delete(e,t)}}},function(e,t,r){var n=r(2).Buffer;e.exports=function(e){for(var t={},r=e.length,i=e.charAt(0),o=0;o>=8;for(;c>0;)o.push(255&c),c>>=8}for(var f=0;e[f]===i&&f0;)n.push(a%r),a=a/r|0}for(var u="",c=0;0===t[c]&&c=0;--f)u+=e[n[f]];return u},decodeUnsafe:a,decode:function(e){var t=a(e);if(t)return t;throw new Error("Non-base"+r+" character")}}}},function(e,t,r){"use strict";t.names=Object.freeze({sha1:17,"sha2-256":18,"sha2-512":19,"dbl-sha2-256":86,"sha3-224":23,"sha3-256":22,"sha3-384":21,"sha3-512":20,"shake-128":24,"shake-256":25,"keccak-224":26,"keccak-256":27,"keccak-384":28,"keccak-512":29,"murmur3-128":34,"murmur3-32":35,"blake2b-8":45569,"blake2b-16":45570,"blake2b-24":45571,"blake2b-32":45572,"blake2b-40":45573,"blake2b-48":45574,"blake2b-56":45575,"blake2b-64":45576,"blake2b-72":45577,"blake2b-80":45578,"blake2b-88":45579,"blake2b-96":45580,"blake2b-104":45581,"blake2b-112":45582,"blake2b-120":45583,"blake2b-128":45584,"blake2b-136":45585,"blake2b-144":45586,"blake2b-152":45587,"blake2b-160":45588,"blake2b-168":45589,"blake2b-176":45590,"blake2b-184":45591,"blake2b-192":45592,"blake2b-200":45593,"blake2b-208":45594,"blake2b-216":45595,"blake2b-224":45596,"blake2b-232":45597,"blake2b-240":45598,"blake2b-248":45599,"blake2b-256":45600,"blake2b-264":45601,"blake2b-272":45602,"blake2b-280":45603,"blake2b-288":45604,"blake2b-296":45605,"blake2b-304":45606,"blake2b-312":45607,"blake2b-320":45608,"blake2b-328":45609,"blake2b-336":45610,"blake2b-344":45611,"blake2b-352":45612,"blake2b-360":45613,"blake2b-368":45614,"blake2b-376":45615,"blake2b-384":45616,"blake2b-392":45617,"blake2b-400":45618,"blake2b-408":45619,"blake2b-416":45620,"blake2b-424":45621,"blake2b-432":45622,"blake2b-440":45623,"blake2b-448":45624,"blake2b-456":45625,"blake2b-464":45626,"blake2b-472":45627,"blake2b-480":45628,"blake2b-488":45629,"blake2b-496":45630,"blake2b-504":45631,"blake2b-512":45632,"blake2s-8":45633,"blake2s-16":45634,"blake2s-24":45635,"blake2s-32":45636,"blake2s-40":45637,"blake2s-48":45638,"blake2s-56":45639,"blake2s-64":45640,"blake2s-72":45641,"blake2s-80":45642,"blake2s-88":45643,"blake2s-96":45644,"blake2s-104":45645,"blake2s-112":45646,"blake2s-120":45647,"blake2s-128":45648,"blake2s-136":45649,"blake2s-144":45650,"blake2s-152":45651,"blake2s-160":45652,"blake2s-168":45653,"blake2s-176":45654,"blake2s-184":45655,"blake2s-192":45656,"blake2s-200":45657,"blake2s-208":45658,"blake2s-216":45659,"blake2s-224":45660,"blake2s-232":45661,"blake2s-240":45662,"blake2s-248":45663,"blake2s-256":45664,"Skein256-8":45825,"Skein256-16":45826,"Skein256-24":45827,"Skein256-32":45828,"Skein256-40":45829,"Skein256-48":45830,"Skein256-56":45831,"Skein256-64":45832,"Skein256-72":45833,"Skein256-80":45834,"Skein256-88":45835,"Skein256-96":45836,"Skein256-104":45837,"Skein256-112":45838,"Skein256-120":45839,"Skein256-128":45840,"Skein256-136":45841,"Skein256-144":45842,"Skein256-152":45843,"Skein256-160":45844,"Skein256-168":45845,"Skein256-176":45846,"Skein256-184":45847,"Skein256-192":45848,"Skein256-200":45849,"Skein256-208":45850,"Skein256-216":45851,"Skein256-224":45852,"Skein256-232":45853,"Skein256-240":45854,"Skein256-248":45855,"Skein256-256":45856,"Skein512-8":45857,"Skein512-16":45858,"Skein512-24":45859,"Skein512-32":45860,"Skein512-40":45861,"Skein512-48":45862,"Skein512-56":45863,"Skein512-64":45864,"Skein512-72":45865,"Skein512-80":45866,"Skein512-88":45867,"Skein512-96":45868,"Skein512-104":45869,"Skein512-112":45870,"Skein512-120":45871,"Skein512-128":45872,"Skein512-136":45873,"Skein512-144":45874,"Skein512-152":45875,"Skein512-160":45876,"Skein512-168":45877,"Skein512-176":45878,"Skein512-184":45879,"Skein512-192":45880,"Skein512-200":45881,"Skein512-208":45882,"Skein512-216":45883,"Skein512-224":45884,"Skein512-232":45885,"Skein512-240":45886,"Skein512-248":45887,"Skein512-256":45888,"Skein512-264":45889,"Skein512-272":45890,"Skein512-280":45891,"Skein512-288":45892,"Skein512-296":45893,"Skein512-304":45894,"Skein512-312":45895,"Skein512-320":45896,"Skein512-328":45897,"Skein512-336":45898,"Skein512-344":45899,"Skein512-352":45900,"Skein512-360":45901,"Skein512-368":45902,"Skein512-376":45903,"Skein512-384":45904,"Skein512-392":45905,"Skein512-400":45906,"Skein512-408":45907,"Skein512-416":45908,"Skein512-424":45909,"Skein512-432":45910,"Skein512-440":45911,"Skein512-448":45912,"Skein512-456":45913,"Skein512-464":45914,"Skein512-472":45915,"Skein512-480":45916,"Skein512-488":45917,"Skein512-496":45918,"Skein512-504":45919,"Skein512-512":45920,"Skein1024-8":45921,"Skein1024-16":45922,"Skein1024-24":45923,"Skein1024-32":45924,"Skein1024-40":45925,"Skein1024-48":45926,"Skein1024-56":45927,"Skein1024-64":45928,"Skein1024-72":45929,"Skein1024-80":45930,"Skein1024-88":45931,"Skein1024-96":45932,"Skein1024-104":45933,"Skein1024-112":45934,"Skein1024-120":45935,"Skein1024-128":45936,"Skein1024-136":45937,"Skein1024-144":45938,"Skein1024-152":45939,"Skein1024-160":45940,"Skein1024-168":45941,"Skein1024-176":45942,"Skein1024-184":45943,"Skein1024-192":45944,"Skein1024-200":45945,"Skein1024-208":45946,"Skein1024-216":45947,"Skein1024-224":45948,"Skein1024-232":45949,"Skein1024-240":45950,"Skein1024-248":45951,"Skein1024-256":45952,"Skein1024-264":45953,"Skein1024-272":45954,"Skein1024-280":45955,"Skein1024-288":45956,"Skein1024-296":45957,"Skein1024-304":45958,"Skein1024-312":45959,"Skein1024-320":45960,"Skein1024-328":45961,"Skein1024-336":45962,"Skein1024-344":45963,"Skein1024-352":45964,"Skein1024-360":45965,"Skein1024-368":45966,"Skein1024-376":45967,"Skein1024-384":45968,"Skein1024-392":45969,"Skein1024-400":45970,"Skein1024-408":45971,"Skein1024-416":45972,"Skein1024-424":45973,"Skein1024-432":45974,"Skein1024-440":45975,"Skein1024-448":45976,"Skein1024-456":45977,"Skein1024-464":45978,"Skein1024-472":45979,"Skein1024-480":45980,"Skein1024-488":45981,"Skein1024-496":45982,"Skein1024-504":45983,"Skein1024-512":45984,"Skein1024-520":45985,"Skein1024-528":45986,"Skein1024-536":45987,"Skein1024-544":45988,"Skein1024-552":45989,"Skein1024-560":45990,"Skein1024-568":45991,"Skein1024-576":45992,"Skein1024-584":45993,"Skein1024-592":45994,"Skein1024-600":45995,"Skein1024-608":45996,"Skein1024-616":45997,"Skein1024-624":45998,"Skein1024-632":45999,"Skein1024-640":46e3,"Skein1024-648":46001,"Skein1024-656":46002,"Skein1024-664":46003,"Skein1024-672":46004,"Skein1024-680":46005,"Skein1024-688":46006,"Skein1024-696":46007,"Skein1024-704":46008,"Skein1024-712":46009,"Skein1024-720":46010,"Skein1024-728":46011,"Skein1024-736":46012,"Skein1024-744":46013,"Skein1024-752":46014,"Skein1024-760":46015,"Skein1024-768":46016,"Skein1024-776":46017,"Skein1024-784":46018,"Skein1024-792":46019,"Skein1024-800":46020,"Skein1024-808":46021,"Skein1024-816":46022,"Skein1024-824":46023,"Skein1024-832":46024,"Skein1024-840":46025,"Skein1024-848":46026,"Skein1024-856":46027,"Skein1024-864":46028,"Skein1024-872":46029,"Skein1024-880":46030,"Skein1024-888":46031,"Skein1024-896":46032,"Skein1024-904":46033,"Skein1024-912":46034,"Skein1024-920":46035,"Skein1024-928":46036,"Skein1024-936":46037,"Skein1024-944":46038,"Skein1024-952":46039,"Skein1024-960":46040,"Skein1024-968":46041,"Skein1024-976":46042,"Skein1024-984":46043,"Skein1024-992":46044,"Skein1024-1000":46045,"Skein1024-1008":46046,"Skein1024-1016":46047,"Skein1024-1024":46048}),t.codes=Object.freeze({17:"sha1",18:"sha2-256",19:"sha2-512",86:"dbl-sha2-256",23:"sha3-224",22:"sha3-256",21:"sha3-384",20:"sha3-512",24:"shake-128",25:"shake-256",26:"keccak-224",27:"keccak-256",28:"keccak-384",29:"keccak-512",34:"murmur3-128",35:"murmur3-32",45569:"blake2b-8",45570:"blake2b-16",45571:"blake2b-24",45572:"blake2b-32",45573:"blake2b-40",45574:"blake2b-48",45575:"blake2b-56",45576:"blake2b-64",45577:"blake2b-72",45578:"blake2b-80",45579:"blake2b-88",45580:"blake2b-96",45581:"blake2b-104",45582:"blake2b-112",45583:"blake2b-120",45584:"blake2b-128",45585:"blake2b-136",45586:"blake2b-144",45587:"blake2b-152",45588:"blake2b-160",45589:"blake2b-168",45590:"blake2b-176",45591:"blake2b-184",45592:"blake2b-192",45593:"blake2b-200",45594:"blake2b-208",45595:"blake2b-216",45596:"blake2b-224",45597:"blake2b-232",45598:"blake2b-240",45599:"blake2b-248",45600:"blake2b-256",45601:"blake2b-264",45602:"blake2b-272",45603:"blake2b-280",45604:"blake2b-288",45605:"blake2b-296",45606:"blake2b-304",45607:"blake2b-312",45608:"blake2b-320",45609:"blake2b-328",45610:"blake2b-336",45611:"blake2b-344",45612:"blake2b-352",45613:"blake2b-360",45614:"blake2b-368",45615:"blake2b-376",45616:"blake2b-384",45617:"blake2b-392",45618:"blake2b-400",45619:"blake2b-408",45620:"blake2b-416",45621:"blake2b-424",45622:"blake2b-432",45623:"blake2b-440",45624:"blake2b-448",45625:"blake2b-456",45626:"blake2b-464",45627:"blake2b-472",45628:"blake2b-480",45629:"blake2b-488",45630:"blake2b-496",45631:"blake2b-504",45632:"blake2b-512",45633:"blake2s-8",45634:"blake2s-16",45635:"blake2s-24",45636:"blake2s-32",45637:"blake2s-40",45638:"blake2s-48",45639:"blake2s-56",45640:"blake2s-64",45641:"blake2s-72",45642:"blake2s-80",45643:"blake2s-88",45644:"blake2s-96",45645:"blake2s-104",45646:"blake2s-112",45647:"blake2s-120",45648:"blake2s-128",45649:"blake2s-136",45650:"blake2s-144",45651:"blake2s-152",45652:"blake2s-160",45653:"blake2s-168",45654:"blake2s-176",45655:"blake2s-184",45656:"blake2s-192",45657:"blake2s-200",45658:"blake2s-208",45659:"blake2s-216",45660:"blake2s-224",45661:"blake2s-232",45662:"blake2s-240",45663:"blake2s-248",45664:"blake2s-256",45825:"Skein256-8",45826:"Skein256-16",45827:"Skein256-24",45828:"Skein256-32",45829:"Skein256-40",45830:"Skein256-48",45831:"Skein256-56",45832:"Skein256-64",45833:"Skein256-72",45834:"Skein256-80",45835:"Skein256-88",45836:"Skein256-96",45837:"Skein256-104",45838:"Skein256-112",45839:"Skein256-120",45840:"Skein256-128",45841:"Skein256-136",45842:"Skein256-144",45843:"Skein256-152",45844:"Skein256-160",45845:"Skein256-168",45846:"Skein256-176",45847:"Skein256-184",45848:"Skein256-192",45849:"Skein256-200",45850:"Skein256-208",45851:"Skein256-216",45852:"Skein256-224",45853:"Skein256-232",45854:"Skein256-240",45855:"Skein256-248",45856:"Skein256-256",45857:"Skein512-8",45858:"Skein512-16",45859:"Skein512-24",45860:"Skein512-32",45861:"Skein512-40",45862:"Skein512-48",45863:"Skein512-56",45864:"Skein512-64",45865:"Skein512-72",45866:"Skein512-80",45867:"Skein512-88",45868:"Skein512-96",45869:"Skein512-104",45870:"Skein512-112",45871:"Skein512-120",45872:"Skein512-128",45873:"Skein512-136",45874:"Skein512-144",45875:"Skein512-152",45876:"Skein512-160",45877:"Skein512-168",45878:"Skein512-176",45879:"Skein512-184",45880:"Skein512-192",45881:"Skein512-200",45882:"Skein512-208",45883:"Skein512-216",45884:"Skein512-224",45885:"Skein512-232",45886:"Skein512-240",45887:"Skein512-248",45888:"Skein512-256",45889:"Skein512-264",45890:"Skein512-272",45891:"Skein512-280",45892:"Skein512-288",45893:"Skein512-296",45894:"Skein512-304",45895:"Skein512-312",45896:"Skein512-320",45897:"Skein512-328",45898:"Skein512-336",45899:"Skein512-344",45900:"Skein512-352",45901:"Skein512-360",45902:"Skein512-368",45903:"Skein512-376",45904:"Skein512-384",45905:"Skein512-392",45906:"Skein512-400",45907:"Skein512-408",45908:"Skein512-416",45909:"Skein512-424",45910:"Skein512-432",45911:"Skein512-440",45912:"Skein512-448",45913:"Skein512-456",45914:"Skein512-464",45915:"Skein512-472",45916:"Skein512-480",45917:"Skein512-488",45918:"Skein512-496",45919:"Skein512-504",45920:"Skein512-512",45921:"Skein1024-8",45922:"Skein1024-16",45923:"Skein1024-24",45924:"Skein1024-32",45925:"Skein1024-40",45926:"Skein1024-48",45927:"Skein1024-56",45928:"Skein1024-64",45929:"Skein1024-72",45930:"Skein1024-80",45931:"Skein1024-88",45932:"Skein1024-96",45933:"Skein1024-104",45934:"Skein1024-112",45935:"Skein1024-120",45936:"Skein1024-128",45937:"Skein1024-136",45938:"Skein1024-144",45939:"Skein1024-152",45940:"Skein1024-160",45941:"Skein1024-168",45942:"Skein1024-176",45943:"Skein1024-184",45944:"Skein1024-192",45945:"Skein1024-200",45946:"Skein1024-208",45947:"Skein1024-216",45948:"Skein1024-224",45949:"Skein1024-232",45950:"Skein1024-240",45951:"Skein1024-248",45952:"Skein1024-256",45953:"Skein1024-264",45954:"Skein1024-272",45955:"Skein1024-280",45956:"Skein1024-288",45957:"Skein1024-296",45958:"Skein1024-304",45959:"Skein1024-312",45960:"Skein1024-320",45961:"Skein1024-328",45962:"Skein1024-336",45963:"Skein1024-344",45964:"Skein1024-352",45965:"Skein1024-360",45966:"Skein1024-368",45967:"Skein1024-376",45968:"Skein1024-384",45969:"Skein1024-392",45970:"Skein1024-400",45971:"Skein1024-408",45972:"Skein1024-416",45973:"Skein1024-424",45974:"Skein1024-432",45975:"Skein1024-440",45976:"Skein1024-448",45977:"Skein1024-456",45978:"Skein1024-464",45979:"Skein1024-472",45980:"Skein1024-480",45981:"Skein1024-488",45982:"Skein1024-496",45983:"Skein1024-504",45984:"Skein1024-512",45985:"Skein1024-520",45986:"Skein1024-528",45987:"Skein1024-536",45988:"Skein1024-544",45989:"Skein1024-552",45990:"Skein1024-560",45991:"Skein1024-568",45992:"Skein1024-576",45993:"Skein1024-584",45994:"Skein1024-592",45995:"Skein1024-600",45996:"Skein1024-608",45997:"Skein1024-616",45998:"Skein1024-624",45999:"Skein1024-632",46000:"Skein1024-640",46001:"Skein1024-648",46002:"Skein1024-656",46003:"Skein1024-664",46004:"Skein1024-672",46005:"Skein1024-680",46006:"Skein1024-688",46007:"Skein1024-696",46008:"Skein1024-704",46009:"Skein1024-712",46010:"Skein1024-720",46011:"Skein1024-728",46012:"Skein1024-736",46013:"Skein1024-744",46014:"Skein1024-752",46015:"Skein1024-760",46016:"Skein1024-768",46017:"Skein1024-776",46018:"Skein1024-784",46019:"Skein1024-792",46020:"Skein1024-800",46021:"Skein1024-808",46022:"Skein1024-816",46023:"Skein1024-824",46024:"Skein1024-832",46025:"Skein1024-840",46026:"Skein1024-848",46027:"Skein1024-856",46028:"Skein1024-864",46029:"Skein1024-872",46030:"Skein1024-880",46031:"Skein1024-888",46032:"Skein1024-896",46033:"Skein1024-904",46034:"Skein1024-912",46035:"Skein1024-920",46036:"Skein1024-928",46037:"Skein1024-936",46038:"Skein1024-944",46039:"Skein1024-952",46040:"Skein1024-960",46041:"Skein1024-968",46042:"Skein1024-976",46043:"Skein1024-984",46044:"Skein1024-992",46045:"Skein1024-1000",46046:"Skein1024-1008",46047:"Skein1024-1016",46048:"Skein1024-1024"}),t.defaultLengths=Object.freeze({17:20,18:32,19:64,86:32,23:28,22:32,21:48,20:64,24:32,25:64,26:28,27:32,28:48,29:64,34:32,45569:1,45570:2,45571:3,45572:4,45573:5,45574:6,45575:7,45576:8,45577:9,45578:10,45579:11,45580:12,45581:13,45582:14,45583:15,45584:16,45585:17,45586:18,45587:19,45588:20,45589:21,45590:22,45591:23,45592:24,45593:25,45594:26,45595:27,45596:28,45597:29,45598:30,45599:31,45600:32,45601:33,45602:34,45603:35,45604:36,45605:37,45606:38,45607:39,45608:40,45609:41,45610:42,45611:43,45612:44,45613:45,45614:46,45615:47,45616:48,45617:49,45618:50,45619:51,45620:52,45621:53,45622:54,45623:55,45624:56,45625:57,45626:58,45627:59,45628:60,45629:61,45630:62,45631:63,45632:64,45633:1,45634:2,45635:3,45636:4,45637:5,45638:6,45639:7,45640:8,45641:9,45642:10,45643:11,45644:12,45645:13,45646:14,45647:15,45648:16,45649:17,45650:18,45651:19,45652:20,45653:21,45654:22,45655:23,45656:24,45657:25,45658:26,45659:27,45660:28,45661:29,45662:30,45663:31,45664:32,45825:1,45826:2,45827:3,45828:4,45829:5,45830:6,45831:7,45832:8,45833:9,45834:10,45835:11,45836:12,45837:13,45838:14,45839:15,45840:16,45841:17,45842:18,45843:19,45844:20,45845:21,45846:22,45847:23,45848:24,45849:25,45850:26,45851:27,45852:28,45853:29,45854:30,45855:31,45856:32,45857:1,45858:2,45859:3,45860:4,45861:5,45862:6,45863:7,45864:8,45865:9,45866:10,45867:11,45868:12,45869:13,45870:14,45871:15,45872:16,45873:17,45874:18,45875:19,45876:20,45877:21,45878:22,45879:23,45880:24,45881:25,45882:26,45883:27,45884:28,45885:29,45886:30,45887:31,45888:32,45889:33,45890:34,45891:35,45892:36,45893:37,45894:38,45895:39,45896:40,45897:41,45898:42,45899:43,45900:44,45901:45,45902:46,45903:47,45904:48,45905:49,45906:50,45907:51,45908:52,45909:53,45910:54,45911:55,45912:56,45913:57,45914:58,45915:59,45916:60,45917:61,45918:62,45919:63,45920:64,45921:1,45922:2,45923:3,45924:4,45925:5,45926:6,45927:7,45928:8,45929:9,45930:10,45931:11,45932:12,45933:13,45934:14,45935:15,45936:16,45937:17,45938:18,45939:19,45940:20,45941:21,45942:22,45943:23,45944:24,45945:25,45946:26,45947:27,45948:28,45949:29,45950:30,45951:31,45952:32,45953:33,45954:34,45955:35,45956:36,45957:37,45958:38,45959:39,45960:40,45961:41,45962:42,45963:43,45964:44,45965:45,45966:46,45967:47,45968:48,45969:49,45970:50,45971:51,45972:52,45973:53,45974:54,45975:55,45976:56,45977:57,45978:58,45979:59,45980:60,45981:61,45982:62,45983:63,45984:64,45985:65,45986:66,45987:67,45988:68,45989:69,45990:70,45991:71,45992:72,45993:73,45994:74,45995:75,45996:76,45997:77,45998:78,45999:79,46000:80,46001:81,46002:82,46003:83,46004:84,46005:85,46006:86,46007:87,46008:88,46009:89,46010:90,46011:91,46012:92,46013:93,46014:94,46015:95,46016:96,46017:97,46018:98,46019:99,46020:100,46021:101,46022:102,46023:103,46024:104,46025:105,46026:106,46027:107,46028:108,46029:109,46030:110,46031:111,46032:112,46033:113,46034:114,46035:115,46036:116,46037:117,46038:118,46039:119,46040:120,46041:121,46042:122,46043:123,46044:124,46045:125,46046:126,46047:127,46048:128})},function(e,t,r){"use strict";const n=r(152),i=r(341).varintBufferEncode,o={};e.exports=o;for(let e in n){let t=n[e];o[e]=i(t)}},function(e,t,r){"use strict";(function(t){const n=r(20);function i(e){return parseInt(e.toString("hex"),16)}function o(e){let r=e.toString(16);return r.length%2==1&&(r="0"+r),t.from(r,"hex")}e.exports={numberToBuffer:o,bufferToNumber:i,varintBufferEncode:function(e){return t.from(n.encode(i(e)))},varintBufferDecode:function(e){return o(n.decode(e))}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(152),i={};e.exports=i;for(let e in n){i[n[e].toString("hex")]=e}},function(e,t){e.exports=function(e,t,r){e(t),r&&r(!0===t?null:t)}},function(e,t,r){"use strict";var n=r(343);e.exports=function(e,t){return function(r,i){if(r)return n(i,r,t);if(null!=e){var o=e;e=null,i(null,o)}else i(!0)}}},function(e,t,r){"use strict";function n(e){return e}var i=r(119);e.exports=function(e){return e?(e=i(e),function(t){return function(r,n){t(r,function(r,i){try{i=r?null:e(i)}catch(e){return t(e,function(){return n(e)})}n(r,i)})}}):n}},function(e,t,r){var n=r(119);function i(e){return e}e.exports=function(e){return"object"==typeof e&&"function"==typeof e.test?function(t){return e.test(t)}:n(e)||i}},function(e,t,r){"use strict";e.exports=function(e,t){var r=!1;function n(e){!r&&t&&(r=!0,t(!0===e?null:e))}return function(t){return function(r,i){return r&&n(r),t(r,function(t,r){t?n(t):e&&e(r),i(t,r)})}}}},function(e,t,r){"use strict";function n(e){return e}var i=r(119),o=r(120);e.exports=function(e,t){e=i(e)||n;var r={};return o(function(n){var i=e(n);return r[i]?!!t:(r[i]=!0,!t)})}},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)(e),u=function(e){if(e)return r(e);var n=(0,i.default)(arguments,1);if(t.apply(this,n))return a(u);r.apply(null,[null].concat(n))};a(u)};var n=a(r(54)),i=a(r(103)),o=a(r(104)),s=a(r(34));function a(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return function(){var t=(0,n.default)(arguments),r=t.pop();e.call(this,t,r)}};var n=function(e){return e&&e.__esModule?e:{default:e}}(r(103));e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){r=r||n.default;var a=(0,i.default)(t)?[]:{};e(t,function(e,t,r){(0,s.default)(e)(function(e,n){arguments.length>2&&(n=(0,o.default)(arguments,1)),a[t]=n,r(e)})},function(e){r(e,a)})};var n=a(r(54)),i=a(r(89)),o=a(r(103)),s=a(r(34));function a(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default},function(e,t,r){(function(t){var r="object"==typeof t&&t&&t.Object===Object&&t;e.exports=r}).call(this,r(7))},function(e,t){var r=9007199254740991;e.exports=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=r}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,o){(0,n.default)(t)(e,(0,i.default)(r),o)};var n=o(r(355)),i=o(r(34));function o(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return function(t,r,u){if(u=(0,i.default)(u||n.default),e<=0||!t)return u(null);var c=(0,o.default)(t),f=!1,l=0,h=!1;function p(e,t){if(l-=1,e)f=!0,u(e);else{if(t===a.default||f&&l<=0)return f=!0,u(null);h||d()}}function d(){for(h=!0;l-1&&e%1==0&&e1&&this._buf[this._buf.length-1]===s;)this._buf=this._buf.slice(0,-1)}less(e){const t=this.list(),r=e.list();for(let e=0;ei)return!1}return t.length>>((3&t)<<3)&255;return i}}},function(e,t){for(var r=[],n=0;n<256;++n)r[n]=(n+256).toString(16).substr(1);e.exports=function(e,t){var n=t||0,i=r;return[i[e[n++]],i[e[n++]],i[e[n++]],i[e[n++]],"-",i[e[n++]],i[e[n++]],"-",i[e[n++]],i[e[n++]],"-",i[e[n++]],i[e[n++]],"-",i[e[n++]],i[e[n++]],i[e[n++]],i[e[n++]],i[e[n++]],i[e[n++]]].join("")}},function(e,t){t.endianness=function(){return"LE"},t.hostname=function(){return"undefined"!=typeof location?location.hostname:""},t.loadavg=function(){return[]},t.uptime=function(){return 0},t.freemem=function(){return Number.MAX_VALUE},t.totalmem=function(){return Number.MAX_VALUE},t.cpus=function(){return[]},t.type=function(){return"Browser"},t.release=function(){return"undefined"!=typeof navigator?navigator.appVersion:""},t.networkInterfaces=t.getNetworkInterfaces=function(){return{}},t.arch=function(){return"javascript"},t.platform=function(){return"browser"},t.tmpdir=t.tmpDir=function(){return"/tmp"},t.EOL="\n",t.homedir=function(){return"/"}},function(e,t,r){"use strict";const n=r(367),i=r(35).Key,o=r(700),s=t.PREFIX="/repo/flatfs/shard/",a=t.SHARDING_FN="SHARDING";t.README_FN="_README";class u{constructor(e){this.param=e}fun(e){throw new Error("implement me")}toString(){return`${s}v1/${this.name}/${this.param}`}}class c extends u{constructor(e){super(e),this._padding=n("",e,"_"),this.name="prefix"}fun(e){return(e+this._padding).slice(0,this.param)}}class f extends u{constructor(e){super(e),this._padding=n("",e,"_"),this.name="suffix"}fun(e){const t=this._padding+e;return t.slice(t.length-this.param)}}class l extends u{constructor(e){super(e),this._padding=n("",e+1,"_"),this.name="next-to-last"}fun(e){const t=this._padding+e,r=t.length-this.param-1;return t.slice(r,r+this.param)}}function h(e){if(0===(e=e.trim()).length)throw new Error("empty shard string");if(!e.startsWith(s))throw new Error(`invalid or no path prefix: ${e}`);const t=e.slice(s.length).split("/"),r=t[0];if("v1"!==r)throw new Error(`expect 'v1' version, got '${r}'`);const n=t[1];if(!t[2])throw new Error("missing param");const i=parseInt(t[2],10);switch(n){case"prefix":return new c(i);case"suffix":return new f(i);case"next-to-last":return new l(i);default:throw new Error(`unkown sharding function: ${n}`)}}t.readShardFun=((e,t,r)=>{const n=new i(e).child(new i(a));("function"==typeof t.getRaw?t.getRaw.bind(t):t.get.bind(t))(n,(e,t)=>{if(e)return r(e);let n;try{n=h((t||"").toString().trim())}catch(e){return r(e)}r(null,n)})}),t.readme=o,t.parseShardFun=h,t.Prefix=c,t.Suffix=f,t.NextToLast=l},function(e,t,r){"use strict";e.exports=function(e,t,r){if((t-=(e+="").length)<=0)return e;if(r||0===r||(r=" ")," "==(r+="")&&t<10)return n[t]+e;for(var i="";1&t&&(i+=r),t>>=1;)r+=r;return i+e};var n=[""," "," "," "," "," "," "," "," "," "]},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=o(r(706)),i=o(r(164));function o(e){return e&&e.__esModule?e:{default:e}}t.default=(0,i.default)(n.default),e.exports=t.default},function(e,t,r){t.AbstractLevelDOWN=r(712),t.AbstractIterator=r(370),t.AbstractChainedBatch=r(371)},function(e,t,r){(function(t){function r(e){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.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(6))},function(e,t,r){(function(t){function r(e){this._db=e,this._operations=[],this._written=!1}r.prototype._serializeKey=function(e){return this._db._serializeKey(e)},r.prototype._serializeValue=function(e){return this._db._serializeValue(e)},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,"key");if(r)throw r;return e=this._serializeKey(e),t=this._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,"key");if(t)throw t;return e=this._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._operations=[],this._clear(),this},r.prototype._clear=function(){},r.prototype.write=function(e,r){if(this._checkWritten(),"function"==typeof e&&(r=e),"function"!=typeof r)throw new Error("write() requires a callback argument");return"object"!=typeof e&&(e={}),this._written=!0,"function"==typeof this._write?this._write(r):"function"==typeof this._db._batch?this._db._batch(this._operations,e,r):void t.nextTick(r)},e.exports=r}).call(this,r(6))},function(e,t,r){var n=r(373).create,i=n("LevelUPError"),o=n("NotFoundError",i);o.prototype.notFound=!0,o.prototype.status=404,e.exports={LevelUPError:i,InitializationError:n("InitializationError",i),OpenError:n("OpenError",i),ReadError:n("ReadError",i),WriteError:n("WriteError",i),NotFoundError:o,EncodingError:n("EncodingError",i)}},function(e,t,r){var n=e.exports.all=[{errno:-2,code:"ENOENT",description:"no such file or directory"},{errno:-1,code:"UNKNOWN",description:"unknown error"},{errno:0,code:"OK",description:"success"},{errno:1,code:"EOF",description:"end of file"},{errno:2,code:"EADDRINFO",description:"getaddrinfo error"},{errno:3,code:"EACCES",description:"permission denied"},{errno:4,code:"EAGAIN",description:"resource temporarily unavailable"},{errno:5,code:"EADDRINUSE",description:"address already in use"},{errno:6,code:"EADDRNOTAVAIL",description:"address not available"},{errno:7,code:"EAFNOSUPPORT",description:"address family not supported"},{errno:8,code:"EALREADY",description:"connection already in progress"},{errno:9,code:"EBADF",description:"bad file descriptor"},{errno:10,code:"EBUSY",description:"resource busy or locked"},{errno:11,code:"ECONNABORTED",description:"software caused connection abort"},{errno:12,code:"ECONNREFUSED",description:"connection refused"},{errno:13,code:"ECONNRESET",description:"connection reset by peer"},{errno:14,code:"EDESTADDRREQ",description:"destination address required"},{errno:15,code:"EFAULT",description:"bad address in system call argument"},{errno:16,code:"EHOSTUNREACH",description:"host is unreachable"},{errno:17,code:"EINTR",description:"interrupted system call"},{errno:18,code:"EINVAL",description:"invalid argument"},{errno:19,code:"EISCONN",description:"socket is already connected"},{errno:20,code:"EMFILE",description:"too many open files"},{errno:21,code:"EMSGSIZE",description:"message too long"},{errno:22,code:"ENETDOWN",description:"network is down"},{errno:23,code:"ENETUNREACH",description:"network is unreachable"},{errno:24,code:"ENFILE",description:"file table overflow"},{errno:25,code:"ENOBUFS",description:"no buffer space available"},{errno:26,code:"ENOMEM",description:"not enough memory"},{errno:27,code:"ENOTDIR",description:"not a directory"},{errno:28,code:"EISDIR",description:"illegal operation on a directory"},{errno:29,code:"ENONET",description:"machine is not on the network"},{errno:31,code:"ENOTCONN",description:"socket is not connected"},{errno:32,code:"ENOTSOCK",description:"socket operation on non-socket"},{errno:33,code:"ENOTSUP",description:"operation not supported on socket"},{errno:34,code:"ENOENT",description:"no such file or directory"},{errno:35,code:"ENOSYS",description:"function not implemented"},{errno:36,code:"EPIPE",description:"broken pipe"},{errno:37,code:"EPROTO",description:"protocol error"},{errno:38,code:"EPROTONOSUPPORT",description:"protocol not supported"},{errno:39,code:"EPROTOTYPE",description:"protocol wrong type for socket"},{errno:40,code:"ETIMEDOUT",description:"connection timed out"},{errno:41,code:"ECHARSET",description:"invalid Unicode character"},{errno:42,code:"EAIFAMNOSUPPORT",description:"address family for hostname not supported"},{errno:44,code:"EAISERVICE",description:"servname not supported for ai_socktype"},{errno:45,code:"EAISOCKTYPE",description:"ai_socktype not supported"},{errno:46,code:"ESHUTDOWN",description:"cannot send after transport endpoint shutdown"},{errno:47,code:"EEXIST",description:"file already exists"},{errno:48,code:"ESRCH",description:"no such process"},{errno:49,code:"ENAMETOOLONG",description:"name too long"},{errno:50,code:"EPERM",description:"operation not permitted"},{errno:51,code:"ELOOP",description:"too many symbolic links encountered"},{errno:52,code:"EXDEV",description:"cross-device link not permitted"},{errno:53,code:"ENOTEMPTY",description:"directory not empty"},{errno:54,code:"ENOSPC",description:"no space left on device"},{errno:55,code:"EIO",description:"i/o error"},{errno:56,code:"EROFS",description:"read-only file system"},{errno:57,code:"ENODEV",description:"no such device"},{errno:58,code:"ESPIPE",description:"invalid seek"},{errno:59,code:"ECANCELED",description:"operation canceled"}];e.exports.errno={},e.exports.code={},n.forEach(function(t){e.exports.errno[t.errno]=t,e.exports.code[t.code]=t}),e.exports.custom=r(716)(e.exports),e.exports.create=e.exports.custom.createError},function(e,t){e.exports=function(){var e,t=new Promise(function(t,r){e=function(e,n){e?r(e):t(n)}});return e.promise=t,e}},function(e,t,r){(function(t){function r(e){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.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(6))},function(e,t,r){(function(t){function r(e){this._db=e,this._operations=[],this._written=!1}r.prototype._serializeKey=function(e){return this._db._serializeKey(e)},r.prototype._serializeValue=function(e){return this._db._serializeValue(e)},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,"key");if(r)throw r;return e=this._serializeKey(e),t=this._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,"key");if(t)throw t;return e=this._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._operations=[],this._clear(),this},r.prototype._clear=function(){},r.prototype.write=function(e,r){if(this._checkWritten(),"function"==typeof e&&(r=e),"function"!=typeof r)throw new Error("write() requires a callback argument");return"object"!=typeof e&&(e={}),this._written=!0,"function"==typeof this._write?this._write(r):"function"==typeof this._db._batch?this._db._batch(this._operations,e,r):void t.nextTick(r)},e.exports=r}).call(this,r(6))},function(e,t,r){t.AbstractLevelDOWN=r(378),t.AbstractIterator=r(379),t.AbstractChainedBatch=r(380),t.isLevelDOWN=r(724)},function(e,t,r){(function(t,n){var i=r(26),o=r(379),s=r(380);function a(e){if(!arguments.length||void 0===e)throw new Error("constructor requires at least a location argument");if("string"!=typeof e)throw new Error("constructor requires a location string argument");this.location=e,this.status="new"}a.prototype.open=function(e,r){var n=this,i=this.status;if("function"==typeof e&&(r=e),"function"!=typeof r)throw new Error("open() requires a callback argument");"object"!=typeof e&&(e={}),e.createIfMissing=0!=e.createIfMissing,e.errorIfExists=!!e.errorIfExists,"function"==typeof this._open?(this.status="opening",this._open(e,function(e){if(e)return n.status=i,r(e);n.status="open",r()})):(this.status="open",t.nextTick(r))},a.prototype.close=function(e){var r=this,n=this.status;if("function"!=typeof e)throw new Error("close() requires a callback argument");"function"==typeof this._close?(this.status="closing",this._close(function(t){if(t)return r.status=n,e(t);r.status="closed",e()})):(this.status="closed",t.nextTick(e))},a.prototype.get=function(e,r,n){var i;if("function"==typeof r&&(n=r),"function"!=typeof n)throw new Error("get() requires a callback argument");return(i=this._checkKey(e,"key",this._isBuffer))?n(i):(this._isBuffer(e)||(e=String(e)),"object"!=typeof r&&(r={}),r.asBuffer=0!=r.asBuffer,"function"==typeof this._get?this._get(e,r,n):void t.nextTick(function(){n(new Error("NotFound"))}))},a.prototype.put=function(e,r,n,i){var o;if("function"==typeof n&&(i=n),"function"!=typeof i)throw new Error("put() requires a callback argument");return(o=this._checkKey(e,"key",this._isBuffer))?i(o):(this._isBuffer(e)||(e=String(e)),null==r||this._isBuffer(r)||t.browser||(r=String(r)),"object"!=typeof n&&(n={}),"function"==typeof this._put?this._put(e,r,n,i):void t.nextTick(i))},a.prototype.del=function(e,r,n){var i;if("function"==typeof r&&(n=r),"function"!=typeof n)throw new Error("del() requires a callback argument");return(i=this._checkKey(e,"key",this._isBuffer))?n(i):(this._isBuffer(e)||(e=String(e)),"object"!=typeof r&&(r={}),"function"==typeof this._del?this._del(e,r,n):void t.nextTick(n))},a.prototype.batch=function(e,r,n){if(!arguments.length)return this._chainedBatch();if("function"==typeof r&&(n=r),"function"==typeof e&&(n=e),"function"!=typeof n)throw new Error("batch(array) requires a callback argument");if(!Array.isArray(e))return n(new Error("batch(array) requires an array argument"));r&&"object"==typeof r||(r={});for(var i,o,s=0,a=e.length;s{const r=e+"/"+s;o("locking %s",r),a[r]=!0;const n={close(e){a[r]&&delete a[r],i(e)}};i(()=>{t(null,n)})}),t.locked=((e,t)=>{const r=e+"/"+s;o("checking lock: %s");const n=a[r];i(()=>{t(null,n)})})},function(e,t){e.exports=function(e){var t,r=!1;Math.random();function n(n){if(!n)throw new Error("must be passed a readable");t=n,r&&e(t)}return n.resolve=n.ready=n.start=function(i){return r=!0,e=i||e,t&&e(t),n},n}},function(e,t,r){var n=r(161),i=r(382);e.exports=function(){var e=n(),t=i();return{source:e,sink:t,resolve:function(r){e.resolve(r.source),t.resolve(r.sink)}}}},function(e,t,r){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t){e.exports=function(e){return e&&"function"==typeof e.then}},function(e,t,r){(function(t){var r="Input must be an string, Buffer or Uint8Array";function n(e){return(4294967296+e).toString(16).substring(1)}e.exports={normalizeInput:function(e){var n;if(e instanceof Uint8Array)n=e;else if(e instanceof t)n=new Uint8Array(e);else{if("string"!=typeof e)throw new Error(r);n=new Uint8Array(t.from(e,"utf8"))}return n},toHex:function(e){return Array.prototype.map.call(e,function(e){return(e<16?"0":"")+e.toString(16)}).join("")},debugPrint:function(e,t,r){for(var i="\n"+e+" = ",o=0;o{n([t=>o.deserialize(e,t),(e,n)=>{if(!t)return r(null,{value:e,remainderPath:""});const i=t.split("/");if("Links"===i[0]){let t="";if(!i[1])return n(null,{value:e.links.map(e=>e.toJSON()),remainderPath:""});const r={};e.links.forEach((e,t)=>{const n=e.toJSON();r[t]=r[n.name]={hash:n.multihash,name:n.name,size:n.size}});let o=r[i[1]];"Hash"===i[2]?o={"/":o.hash}:"Tsize"===i[2]?o={"/":o.size}:"Name"===i[2]&&(o={"/":o.name}),n(null,{value:o,remainderPath:t=i.slice(3).join("/")})}else if("Data"===i[0])n(null,{value:e.data,remainderPath:""});else{const t={};e.links.forEach((e,r)=>{const n=e.toJSON();t[n.name]={hash:n.multihash,name:n.name,size:n.size}});const r=t[i[0]];if(r)return n(null,{value:{"/":r.hash},remainderPath:i.slice(1).join("/")});n(new Error("path not available"))}}],r)}),t.tree=((e,t,r)=>{"function"==typeof t&&(r=t,t={}),t=t||{},o.deserialize(e,(e,t)=>{if(e)return r(e);const n=[];n.push("Links"),t.links.forEach((e,t)=>{n.push(`Links/${t}/Name`),n.push(`Links/${t}/Tsize`),n.push(`Links/${t}/Hash`)}),n.push("Data"),r(null,n)})}),t.isLink=((e,r,n)=>{t.resolve(e,r,(e,t)=>{if(e)return n(e);if(t.remainderPath.length>0)return n(new Error("path out of scope"));if("object"==typeof t.value&&t.value["/"]){let r;try{r=i.isCID(new i(t.value["/"]))}catch(e){r=!1}if(r)return n(null,t.value)}n(null,!1)})})},function(e,t,r){"use strict";t.util=r(389),t.resolver=r(393)},function(e,t,r){"use strict";(function(n){const i=r(761),o=r(61),s=r(9),a=r(5),u=r(3),c=r(765),f=r(393),l=42;const h=new i.Decoder({tags:{[l]:e=>({"/":e=e.slice(1)})}});function p(e){let t;try{t=c(e)}catch(e){t=!1}if(t)throw new Error("The object passed has circular references");return function e(t){if(!t||n.isBuffer(t)||"string"==typeof t)return t;if(Array.isArray(t))return t.map(e);const r=Object.keys(t);if(1===r.length&&"/"===r[0])return function(e){return"string"==typeof e&&(e=new s(e).buffer),new i.Tagged(l,n.concat([n.from("00","hex"),e]))}(t["/"]);if(r.length>0){let n={};return r.forEach(r=>{"object"==typeof t[r]?n[r]=e(t[r]):n[r]=t[r]}),n}return t}(e)}(t=e.exports).serialize=((e,t)=>{let r;try{const n=p(e);r=i.encode(n)}catch(e){return u(()=>t(e))}u(()=>t(null,r))}),t.deserialize=((e,t)=>{let r;try{r=h.decodeFirst(e)}catch(e){return u(()=>t(e))}u(()=>t(null,r))}),t.cid=((e,r,n)=>{"function"==typeof r&&(n=r,r={});const i=(r=r||{}).hashAlg||f.defaultHashAlg,u=void 0===r.version?1:r.version;a([r=>t.serialize(e,r),(e,t)=>o(e,i,t),(e,t)=>t(null,new s(u,f.multicodec,e))],n)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t,n){const i=r(333),o=r(169),s=r(763),a=r(229),u=r(170),c=r(391),f=r(392),l=r(33);class h{constructor(e){!(e=e||{}).size||e.size<65536?e.size=65536:e.size=a.nextPowerOf2(e.size),this._heap=new ArrayBuffer(e.size),this._heap8=new Uint8Array(this._heap),this._reset(),this._knownTags=Object.assign({0:e=>new Date(e),1:e=>new Date(1e3*e),2:e=>a.arrayBufferToBignumber(e),3:e=>u.NEG_ONE.minus(a.arrayBufferToBignumber(e)),4:e=>u.TEN.pow(e[0]).times(e[1]),5:e=>u.TWO.pow(e[0]).times(e[1]),32:e=>l.parse(e),35:e=>new RegExp(e)},e.tags),this.parser=s(t,{log:console.log.bind(console),pushInt:this.pushInt.bind(this),pushInt32:this.pushInt32.bind(this),pushInt32Neg:this.pushInt32Neg.bind(this),pushInt64:this.pushInt64.bind(this),pushInt64Neg:this.pushInt64Neg.bind(this),pushFloat:this.pushFloat.bind(this),pushFloatSingle:this.pushFloatSingle.bind(this),pushFloatDouble:this.pushFloatDouble.bind(this),pushTrue:this.pushTrue.bind(this),pushFalse:this.pushFalse.bind(this),pushUndefined:this.pushUndefined.bind(this),pushNull:this.pushNull.bind(this),pushInfinity:this.pushInfinity.bind(this),pushInfinityNeg:this.pushInfinityNeg.bind(this),pushNaN:this.pushNaN.bind(this),pushNaNNeg:this.pushNaNNeg.bind(this),pushArrayStart:this.pushArrayStart.bind(this),pushArrayStartFixed:this.pushArrayStartFixed.bind(this),pushArrayStartFixed32:this.pushArrayStartFixed32.bind(this),pushArrayStartFixed64:this.pushArrayStartFixed64.bind(this),pushObjectStart:this.pushObjectStart.bind(this),pushObjectStartFixed:this.pushObjectStartFixed.bind(this),pushObjectStartFixed32:this.pushObjectStartFixed32.bind(this),pushObjectStartFixed64:this.pushObjectStartFixed64.bind(this),pushByteString:this.pushByteString.bind(this),pushByteStringStart:this.pushByteStringStart.bind(this),pushUtf8String:this.pushUtf8String.bind(this),pushUtf8StringStart:this.pushUtf8StringStart.bind(this),pushSimpleUnassigned:this.pushSimpleUnassigned.bind(this),pushTagUnassigned:this.pushTagUnassigned.bind(this),pushTagStart:this.pushTagStart.bind(this),pushTagStart4:this.pushTagStart4.bind(this),pushTagStart8:this.pushTagStart8.bind(this),pushBreak:this.pushBreak.bind(this)},this._heap)}get _depth(){return this._parents.length}get _currentParent(){return this._parents[this._depth-1]}get _ref(){return this._currentParent.ref}_closeParent(){var e=this._parents.pop();if(e.length>0)throw new Error(`Missing ${e.length} elements`);switch(e.type){case u.PARENT.TAG:this._push(this.createTag(e.ref[0],e.ref[1]));break;case u.PARENT.BYTE_STRING:this._push(this.createByteString(e.ref,e.length));break;case u.PARENT.UTF8_STRING:this._push(this.createUtf8String(e.ref,e.length));break;case u.PARENT.MAP:if(e.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createMap(e.ref,e.length));break;case u.PARENT.OBJECT:if(e.values%2>0)throw new Error("Odd number of elements in the map");this._push(this.createObject(e.ref,e.length));break;case u.PARENT.ARRAY:this._push(this.createArray(e.ref,e.length))}this._currentParent&&this._currentParent.type===u.PARENT.TAG&&this._dec()}_dec(){const e=this._currentParent;e.length<0||(e.length--,0===e.length&&this._closeParent())}_push(e,t){const r=this._currentParent;switch(r.values++,r.type){case u.PARENT.ARRAY:case u.PARENT.BYTE_STRING:case u.PARENT.UTF8_STRING:r.length>-1?this._ref[this._ref.length-r.length]=e:this._ref.push(e),this._dec();break;case u.PARENT.OBJECT:null!=r.tmpKey?(this._ref[r.tmpKey]=e,r.tmpKey=null,this._dec()):(r.tmpKey=e,"string"!=typeof r.tmpKey&&(r.type=u.PARENT.MAP,r.ref=a.buildMap(r.ref)));break;case u.PARENT.MAP:null!=r.tmpKey?(this._ref.set(r.tmpKey,e),r.tmpKey=null,this._dec()):r.tmpKey=e;break;case u.PARENT.TAG:this._ref.push(e),t||this._dec();break;default:throw new Error("Unknown parent type")}}_createParent(e,t,r){this._parents[this._depth]={type:t,length:r,ref:e,values:0,tmpKey:null}}_reset(){this._res=[],this._parents=[{type:u.PARENT.ARRAY,length:-1,ref:this._res,values:0,tmpKey:null}]}createTag(e,t){const r=this._knownTags[e];return r?r(t):new f(e,t)}createMap(e,t){return e}createObject(e,t){return e}createArray(e,t){return e}createByteString(e,t){return n.concat(e)}createByteStringFromHeap(e,t){return e===t?n.alloc(0):n.from(this._heap.slice(e,t))}createInt(e){return e}createInt32(e,t){return a.buildInt32(e,t)}createInt64(e,t,r,n){return a.buildInt64(e,t,r,n)}createFloat(e){return e}createFloatSingle(e,t,r,n){return i.read([e,t,r,n],0,!1,23,4)}createFloatDouble(e,t,r,n,o,s,a,u){return i.read([e,t,r,n,o,s,a,u],0,!1,52,8)}createInt32Neg(e,t){return-1-a.buildInt32(e,t)}createInt64Neg(e,t,r,n){const i=a.buildInt32(e,t),s=a.buildInt32(r,n);return i>u.MAX_SAFE_HIGH?u.NEG_ONE.minus(new o(i).times(u.SHIFT32).plus(s)):-1-(i*u.SHIFT32+s)}createTrue(){return!0}createFalse(){return!1}createNull(){return null}createUndefined(){}createInfinity(){return 1/0}createInfinityNeg(){return-1/0}createNaN(){return NaN}createNaNNeg(){return NaN}createUtf8String(e,t){return e.join("")}createUtf8StringFromHeap(e,t){return e===t?"":n.from(this._heap.slice(e,t)).toString("utf8")}createSimpleUnassigned(e){return new c(e)}pushInt(e){this._push(this.createInt(e))}pushInt32(e,t){this._push(this.createInt32(e,t))}pushInt64(e,t,r,n){this._push(this.createInt64(e,t,r,n))}pushFloat(e){this._push(this.createFloat(e))}pushFloatSingle(e,t,r,n){this._push(this.createFloatSingle(e,t,r,n))}pushFloatDouble(e,t,r,n,i,o,s,a){this._push(this.createFloatDouble(e,t,r,n,i,o,s,a))}pushInt32Neg(e,t){this._push(this.createInt32Neg(e,t))}pushInt64Neg(e,t,r,n){this._push(this.createInt64Neg(e,t,r,n))}pushTrue(){this._push(this.createTrue())}pushFalse(){this._push(this.createFalse())}pushNull(){this._push(this.createNull())}pushUndefined(){this._push(this.createUndefined())}pushInfinity(){this._push(this.createInfinity())}pushInfinityNeg(){this._push(this.createInfinityNeg())}pushNaN(){this._push(this.createNaN())}pushNaNNeg(){this._push(this.createNaNNeg())}pushArrayStart(){this._createParent([],u.PARENT.ARRAY,-1)}pushArrayStartFixed(e){this._createArrayStartFixed(e)}pushArrayStartFixed32(e,t){const r=a.buildInt32(e,t);this._createArrayStartFixed(r)}pushArrayStartFixed64(e,t,r,n){const i=a.buildInt64(e,t,r,n);this._createArrayStartFixed(i)}pushObjectStart(){this._createObjectStartFixed(-1)}pushObjectStartFixed(e){this._createObjectStartFixed(e)}pushObjectStartFixed32(e,t){const r=a.buildInt32(e,t);this._createObjectStartFixed(r)}pushObjectStartFixed64(e,t,r,n){const i=a.buildInt64(e,t,r,n);this._createObjectStartFixed(i)}pushByteStringStart(){this._parents[this._depth]={type:u.PARENT.BYTE_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushByteString(e,t){this._push(this.createByteStringFromHeap(e,t))}pushUtf8StringStart(){this._parents[this._depth]={type:u.PARENT.UTF8_STRING,length:-1,ref:[],values:0,tmpKey:null}}pushUtf8String(e,t){this._push(this.createUtf8StringFromHeap(e,t))}pushSimpleUnassigned(e){this._push(this.createSimpleUnassigned(e))}pushTagStart(e){this._parents[this._depth]={type:u.PARENT.TAG,length:1,ref:[e]}}pushTagStart4(e,t){this.pushTagStart(a.buildInt32(e,t))}pushTagStart8(e,t,r,n){this.pushTagStart(a.buildInt64(e,t,r,n))}pushTagUnassigned(e){this._push(this.createTag(e))}pushBreak(){if(this._currentParent.length>-1)throw new Error("Unexpected break");this._closeParent()}_createObjectStartFixed(e){0!==e?this._createParent({},u.PARENT.OBJECT,e):this._push(this.createObject({}))}_createArrayStartFixed(e){0!==e?this._createParent(new Array(e),u.PARENT.ARRAY,e):this._push(this.createArray([]))}_decode(e){if(0===e.byteLength)throw new Error("Input too short");this._reset(),this._heap8.set(e);const t=this.parser.parse(e.byteLength);if(this._depth>1){for(;0===this._currentParent.length;)this._closeParent();if(this._depth>1)throw new Error("Undeterminated nesting")}if(t>0)throw new Error("Failed to parse");if(0===this._res.length)throw new Error("No valid result")}decodeFirst(e){return this._decode(e),this._res[0]}decodeAll(e){return this._decode(e),this._res}static decode(e,t){return"string"==typeof e&&(e=n.from(e,t||"hex")),new h({size:e.length}).decodeFirst(e)}static decodeAll(e,t){return"string"==typeof e&&(e=n.from(e,t||"hex")),new h({size:e.length}).decodeAll(e)}}h.decodeFirst=h.decode,e.exports=h}).call(this,r(7),r(0).Buffer)},function(e,t,r){"use strict";const n=r(170),i=n.MT,o=n.SIMPLE,s=n.SYMS;class a{constructor(e){if("number"!=typeof e)throw new Error("Invalid Simple type: "+typeof e);if(e<0||e>255||(0|e)!==e)throw new Error("value must be a small positive integer: "+e);this.value=e}toString(){return"simple("+this.value+")"}inspect(){return"simple("+this.value+")"}encodeCBOR(e){return e._pushInt(this.value,i.SIMPLE_FLOAT)}static isSimple(e){return e instanceof a}static decode(e,t){switch(null==t&&(t=!0),e){case o.FALSE:return!1;case o.TRUE:return!0;case o.NULL:return t?null:s.NULL;case o.UNDEFINED:return t?void 0:s.UNDEFINED;case-1:if(!t)throw new Error("Invalid BREAK");return s.BREAK;default:return new a(e)}}}e.exports=a},function(e,t,r){"use strict";class n{constructor(e,t,r){if(this.tag=e,this.value=t,this.err=r,"number"!=typeof this.tag)throw new Error("Invalid tag type ("+typeof this.tag+")");if(this.tag<0||(0|this.tag)!==this.tag)throw new Error("Tag must be a positive integer: "+this.tag)}toString(){return`${this.tag}(${JSON.stringify(this.value)})`}encodeCBOR(e){return e._pushTag(this.tag),e.pushAny(this.value)}convert(e){var t,r;if("function"!=typeof(r=null!=e?e[this.tag]:void 0)&&"function"!=typeof(r=n["_tag"+this.tag]))return this;try{return r.call(n,this.value)}catch(e){return t=e,this.err=t,this}}}e.exports=n},function(e,t,r){"use strict";(function(n){const i=r(389),o=r(394);(t=e.exports).multicodec="dag-cbor",t.defaultHashAlg="sha2-256",t.resolve=((e,t,r)=>{"function"==typeof t&&(r=t,t=void 0),i.deserialize(e,(e,i)=>{if(e)return r(e);if(!t||"/"===t)return r(null,{value:i,remainderPath:""});const s=t.split("/"),a=o(i).get(s);if(a)return r(null,{value:a,remainderPath:""});let u,c=s.length;for(let e=0;e{"function"==typeof t&&(r=t,t=void 0),t=t||{},i.deserialize(e,(e,t)=>{if(e)return r(e);const n=function(e,t){return t=t||"/",0===Object.keys(e).length?[]:o(e).reduce(function(e,r){"object"==typeof r&&r["/"]&&this.update(void 0);const n=this.path.join(t);return""!==n&&e.push({path:n,value:r}),e},[])}(t).map(e=>e.path);r(null,n)})}),t.isLink=((e,r,n)=>{t.resolve(e,r,(e,t)=>e?n(e):t.remainderPath.length>0?n(new Error("path out of scope")):void("object"==typeof t.value&&t.value["/"]?n(null,t.value):n(null,!1)))})}).call(this,r(0).Buffer)},function(e,t){var r=e.exports=function(e){return new n(e)};function n(e){this.value=e}function i(e,t,r){var n=[],i=[],a=!0;return function e(l){var h={},p=!0,d={node:r?o(l):l,node_:l,path:[].concat(n),parent:i[i.length-1],parents:i,key:n.slice(-1)[0],isRoot:0===n.length,level:n.length,circular:null,update:function(e,t){d.isRoot||(d.parent.node[d.key]=e),d.node=e,t&&(p=!1)},delete:function(e){delete d.parent.node[d.key],e&&(p=!1)},remove:function(e){u(d.parent.node)?d.parent.node.splice(d.key,1):delete d.parent.node[d.key],e&&(p=!1)},keys:null,before:function(e){h.before=e},after:function(e){h.after=e},pre:function(e){h.pre=e},post:function(e){h.post=e},stop:function(){a=!1},block:function(){p=!1}};if(!a)return d;function y(){if("object"==typeof d.node&&null!==d.node){d.keys&&d.node_===d.node||(d.keys=s(d.node)),d.isLeaf=0==d.keys.length;for(var e=0;e{if(null!==e)if(n.isBuffer(e))"blob"===e.slice(0,4).toString()?i(()=>t(null,e)):i(()=>t(new Error("unexpected dagNode passed to serialize"),null));else switch(e.gitType){case"commit":f.serialize(e,t);break;case"tag":l.serialize(e,t);break;default:h.serialize(e,t)}else i(()=>t(new Error("dagNode passed to serialize was null"),null))}),t.deserialize=((e,t)=>{let r=c.find(e,0),n=e.slice(0,r).toString().match(/([^ ]+) (\d+)/);if(n)switch(n[1]){case"blob":t(null,e);break;case"commit":f.deserialize(e.slice(r+1),t);break;case"tag":l.deserialize(e.slice(r+1),t);break;case"tree":h.deserialize(e.slice(r+1),t);break;default:i(()=>t(new Error("unknown object type "+n[1]),null))}else i(()=>t(new Error("invalid object header"),null))}),t.cid=((e,r,n)=>{"function"==typeof r&&(n=r,r={});const i=(r=r||{}).hashAlg||u.defaultHashAlg,c=void 0===r.version?1:r.version;o([r=>t.serialize(e,r),(e,t)=>s(e,i,t),(e,t)=>t(null,new a(c,u.multicodec,e))],n)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(n){const i=r(395),o=r(394);(t=e.exports).multicodec="git-raw",t.defaultHashAlg="sha1";const s=["original","name","email","date"];t.resolve=((e,t,r)=>{"function"==typeof t&&(r=t,t=void 0),i.deserialize(e,(e,i)=>{if(e)return r(e);if(!t||"/"===t)return r(null,{value:i,remainderPath:""});if(n.isBuffer(i))return r(null,{value:i,remainderPath:t});const s=t.split("/"),a=o(i).get(s);if(a)return r(null,{value:a,remainderPath:""});let u,c=s.length;for(let e=0;e{"function"==typeof t&&(r=t,t=void 0),t=t||{},i.deserialize(e,(e,t)=>{if(e)return r(e);if(n.isBuffer(t))return r(null,[]);let i=[];switch(t.gitType){case"commit":i=(i=(i=(i=["message","tree"]).concat(s.map(e=>"author/"+e))).concat(s.map(e=>"committer/"+e))).concat(t.parents.map((e,t)=>"parents/"+t)),t.encoding&&i.push("encoding");break;case"tag":i=["object","type","tag","message"],t.tagger&&(i=i.concat(s.map(e=>"tagger/"+e)));break;default:Object.keys(t).forEach(e=>{i.push(e),i.push(e+"/hash"),i.push(e+"/mode")})}r(null,i)})}),t.isLink=((e,r,n)=>{t.resolve(e,r,(e,t)=>e?n(e):t.remainderPath.length>0?n(new Error("path out of scope")):void("object"==typeof t.value&&t.value["/"]?n(null,t.value):n(null,!1)))})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(773).Block,i=r(9),o=r(12),s=r(61),a=r(5);e.exports={hashToCid:e=>{const t=r(230).defaultHashAlg,n=o.encode(e,t);return new i(1,"bitcoin-block",n)},BITCOIN_BLOCK_HEADER_SIZE:80,cid:(e,t,n)=>{"function"==typeof t&&(n=t,t={});const o=(t=t||{}).hashAlg||r(230).defaultHashAlg,u=void 0===t.version?1:t.version;a([t=>{try{s(e.toBuffer(!0),o,t)}catch(e){t(e)}},(e,t)=>t(null,new i(u,"bitcoin-block",e))],n)},deserialize:(e,t)=>{if(80!==e.length)return t(new Error("Bitcoin block header needs to be 80 bytes"));t(null,n.fromBuffer(e))},serialize:(e,t)=>{let r,n=null;try{r=e.toBuffer(!0)}catch(e){n=e}finally{t(n,r)}}}},function(e,t,r){var n=r(37);function i(e){return ee.length)return null;r=e.readUInt8(t+1),i=2}else if(o===n.OP_PUSHDATA2){if(t+3>e.length)return null;r=e.readUInt16LE(t+1),i=3}else{if(t+5>e.length)return null;if(o!==n.OP_PUSHDATA4)throw new Error("Unexpected opcode");r=e.readUInt32LE(t+1),i=5}return{opcode:o,number:r,size:i}}}},function(e,t,r){var n=r(232);function i(e){return e.name||e.toString().match(/function (.*?)\s*\(/)[1]}function o(e){return n.Nil(e)?"":i(e.constructor)}function s(e){return n.Function(e)?"":n.String(e)?JSON.stringify(e):e&&n.Object(e)?"":e}function a(e){return n.Function(e)?e.toJSON?e.toJSON():i(e):n.Array(e)?"Array":e&&n.Object(e)?"Object":void 0!==e?e:""}function u(e,t,r){var n=s(t);return"Expected "+a(e)+", got"+(""!==r?" "+r:"")+(""!==n?" "+n:"")}function c(e,t,r){r=r||o(t),this.message=u(e,t,r),Error.captureStackTrace(this,c),this.__type=e,this.__value=t,this.__valueTypeName=r}function f(e,t,r,n,i){e?(i=i||o(n),this.message=function(e,t,r,n,i){var o='" of type ';return"key"===t&&(o='" with key type '),u('property "'+a(r)+o+a(e),n,i)}(e,r,t,n,i)):this.message='Unexpected property "'+t+'"',Error.captureStackTrace(this,c),this.__label=r,this.__property=t,this.__type=e,this.__value=n,this.__valueTypeName=i}c.prototype=Object.create(Error.prototype),c.prototype.constructor=c,f.prototype=Object.create(Error.prototype),f.prototype.constructor=c,e.exports={TfTypeError:c,TfPropertyTypeError:f,tfCustomError:function(e,t){return new c(e,{},t)},tfSubError:function(e,t,r){return e instanceof f?(t=t+"."+e.__property,e=new f(e.__type,t,e.__label,e.__value,e.__valueTypeName)):e instanceof c&&(e=new f(e.__type,t,r,e.__value,e.__valueTypeName)),Error.captureStackTrace(e),e},tfJSON:a,getValueTypeName:o}},function(e,t,r){var n=r(2).Buffer;e.exports={decode:function(e,t,r){t=t||4,r=void 0===r||r;var n=e.length;if(0===n)return 0;if(n>t)throw new TypeError("Script number overflow");if(r&&0==(127&e[n-1])&&(n<=1||0==(128&e[n-2])))throw new Error("Non-minimally encoded script number");if(5===n){var i=e.readUInt32LE(0),o=e.readUInt8(4);return 128&o?-(4294967296*(-129&o)+i):4294967296*o+i}for(var s=0,a=0;a2147483647?5:e>8388607?4:e>32767?3:e>127?2:e>0?1:0}(t),i=n.allocUnsafe(r),o=e<0,s=0;s>=8;return 128&i[r-1]?i.writeUInt8(o?128:0,r-1):o&&(i[r-1]|=128),i}}},function(e,t,r){var n=r(28),i=r(31),o=r(25),s=r(37),a=s.OP_RESERVED;function u(e,t){var r=n.decompile(e);if(r.length<4)return!1;if(r[r.length-1]!==s.OP_CHECKMULTISIG)return!1;if(!i.Number(r[0]))return!1;if(!i.Number(r[r.length-2]))return!1;var o=r[0]-a,u=r[r.length-2]-a;return!(o<=0)&&!(u>16)&&!(o>u)&&u===r.length-3&&(!!t||r.slice(1,-2).every(n.isCanonicalPubKey))}u.toJSON=function(){return"multi-sig output"},e.exports={check:u,decode:function(e,t){var r=n.decompile(e);return o(u,r,t),{m:r[0]-a,pubKeys:r.slice(1,-2)}},encode:function(e,t){o({m:i.Number,pubKeys:[n.isCanonicalPubKey]},{m:e,pubKeys:t});var r=t.length;if(rt)throw new Error("RangeError: value out of range");if(Math.floor(e)!==e)throw new Error("value has a fractional component")}e.exports={pushDataSize:n.encodingLength,readPushDataInt:n.decode,readUInt64LE:function(e,t){var r=e.readUInt32LE(t),n=e.readUInt32LE(t+4);return o((n*=4294967296)+r,9007199254740991),n+r},readVarInt:function(e,t){return{number:i.decode(e,t),size:i.decode.bytes}},varIntBuffer:i.encode,varIntSize:i.encodingLength,writePushDataInt:n.encode,writeUInt64LE:function(e,t,r){return o(t,9007199254740991),e.writeInt32LE(-1&t,r),e.writeUInt32LE(Math.floor(t/4294967296),r+4),r+8},writeVarInt:function(e,t,r){return i.encode(t,e,r),i.encode.bytes}}},function(e,t,r){"use strict";var n=r(2).Buffer,i=r(90).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(4)(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";var n=r(0).Buffer,i=r(4),o=r(405),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],u=[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],c=[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],l=[0,1518500249,1859775393,2400959708,2840853838],h=[1352829926,1548603684,1836072691,2053994217,0];function p(){o.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function d(e,t){return e<>>32-t}function y(e,t,r,n,i,o,s,a){return d(e+(t^r^n)+o+s|0,a)+i|0}function g(e,t,r,n,i,o,s,a){return d(e+(t&r|~t&n)+o+s|0,a)+i|0}function m(e,t,r,n,i,o,s,a){return d(e+((t|~r)^n)+o+s|0,a)+i|0}function b(e,t,r,n,i,o,s,a){return d(e+(t&n|r&~n)+o+s|0,a)+i|0}function v(e,t,r,n,i,o,s,a){return d(e+(t^(r|~n))+o+s|0,a)+i|0}i(p,o),p.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,p=0|this._e,_=0|this._a,w=0|this._b,S=0|this._c,k=0|this._d,E=0|this._e,A=0;A<80;A+=1){var x,I;A<16?(x=y(r,n,i,o,p,e[a[A]],l[0],c[A]),I=v(_,w,S,k,E,e[u[A]],h[0],f[A])):A<32?(x=g(r,n,i,o,p,e[a[A]],l[1],c[A]),I=b(_,w,S,k,E,e[u[A]],h[1],f[A])):A<48?(x=m(r,n,i,o,p,e[a[A]],l[2],c[A]),I=m(_,w,S,k,E,e[u[A]],h[2],f[A])):A<64?(x=b(r,n,i,o,p,e[a[A]],l[3],c[A]),I=g(_,w,S,k,E,e[u[A]],h[3],f[A])):(x=v(r,n,i,o,p,e[a[A]],l[4],c[A]),I=y(_,w,S,k,E,e[u[A]],h[4],f[A])),r=p,p=o,o=d(i,10),i=n,n=x,_=E,E=k,k=d(S,10),S=w,w=I}var T=this._b+i+k|0;this._b=this._c+o+E|0,this._c=this._d+p+_|0,this._d=this._e+r+w|0,this._e=this._a+n+S|0,this._a=T},p.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=p},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(792),t.sha1=r(793),t.sha224=r(794),t.sha256=r(408),t.sha384=r(795),t.sha512=r(409)},function(e,t,r){var n=r(4),i=r(107),o=r(2).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 u(){this.init(),this._w=a,i.call(this,64,56)}function c(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function l(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function h(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function p(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function d(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}n(u,i),u.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},u.prototype._update=function(e){for(var t=this._w,r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,a=0|this._e,u=0|this._f,y=0|this._g,g=0|this._h,m=0;m<16;++m)t[m]=e.readInt32BE(4*m);for(;m<64;++m)t[m]=d(t[m-2])+t[m-7]+p(t[m-15])+t[m-16]|0;for(var b=0;b<64;++b){var v=g+h(a)+c(a,u,y)+s[b]+t[b]|0,_=l(r)+f(r,n,i)|0;g=y,y=u,u=a,a=o+v|0,o=i,i=n,n=r,r=v+_|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0,this._f=u+this._f|0,this._g=y+this._g|0,this._h=g+this._h|0},u.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=u},function(e,t,r){var n=r(4),i=r(107),o=r(2).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 u(){this.init(),this._w=a,i.call(this,128,112)}function c(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function l(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function h(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function p(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function d(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 g(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function m(e,t){return e>>>0>>0?1:0}n(u,i),u.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},u.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,u=0|this._fh,b=0|this._gh,v=0|this._hh,_=0|this._al,w=0|this._bl,S=0|this._cl,k=0|this._dl,E=0|this._el,A=0|this._fl,x=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 B=t[T-30],C=t[T-30+1],P=p(B,C),O=d(C,B),R=y(B=t[T-4],C=t[T-4+1]),N=g(C,B),L=t[T-14],j=t[T-14+1],M=t[T-32],K=t[T-32+1],D=O+j|0,U=P+L+m(D,O)|0;U=(U=U+R+m(D=D+N|0,N)|0)+M+m(D=D+K|0,K)|0,t[T]=U,t[T+1]=D}for(var F=0;F<160;F+=2){U=t[F],D=t[F+1];var q=f(r,n,i),H=f(_,w,S),z=l(r,_),V=l(_,r),G=h(a,E),W=h(E,a),$=s[F],Y=s[F+1],J=c(a,u,b),X=c(E,A,x),Z=I+W|0,Q=v+G+m(Z,I)|0;Q=(Q=(Q=Q+J+m(Z=Z+X|0,X)|0)+$+m(Z=Z+Y|0,Y)|0)+U+m(Z=Z+D|0,D)|0;var ee=V+H|0,te=z+q+m(ee,V)|0;v=b,I=x,b=u,x=A,u=a,A=E,a=o+Q+m(E=k+Z|0,k)|0,o=i,k=S,i=n,S=w,n=r,w=_,r=Q+te+m(_=Z+ee|0,Z)|0}this._al=this._al+_|0,this._bl=this._bl+w|0,this._cl=this._cl+S|0,this._dl=this._dl+k|0,this._el=this._el+E|0,this._fl=this._fl+A|0,this._gl=this._gl+x|0,this._hl=this._hl+I|0,this._ah=this._ah+r+m(this._al,_)|0,this._bh=this._bh+n+m(this._bl,w)|0,this._ch=this._ch+i+m(this._cl,S)|0,this._dh=this._dh+o+m(this._dl,k)|0,this._eh=this._eh+a+m(this._el,E)|0,this._fh=this._fh+u+m(this._fl,A)|0,this._gh=this._gh+b+m(this._gl,x)|0,this._hh=this._hh+v+m(this._hl,I)|0},u.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=u},function(e,t,r){function n(e,t,r){if(!(this instanceof n))return new n(e,t,r);null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}var i=n.prototype;i.__bigi=r(802).version,n.isBigInteger=function(e,t){return e&&e.__bigi&&(!t||e.__bigi===i.__bigi)},n.prototype.am=function(e,t,r,n,i,o){for(;--o>=0;){var s=t*this[e++]+r[n]+i;i=Math.floor(s/67108864),r[n++]=67108863&s}return i},n.prototype.DB=26,n.prototype.DM=67108863;var o=n.prototype.DV=1<<26;n.prototype.FV=Math.pow(2,52),n.prototype.F1=26,n.prototype.F2=0;var s,a,u="0123456789abcdefghijklmnopqrstuvwxyz",c=new Array;for(s="0".charCodeAt(0),a=0;a<=9;++a)c[s++]=a;for(s="a".charCodeAt(0),a=10;a<36;++a)c[s++]=a;for(s="A".charCodeAt(0),a=10;a<36;++a)c[s++]=a;function f(e){return u.charAt(e)}function l(e,t){var r=c[e.charCodeAt(t)];return null==r?-1:r}function h(e){var t=new n;return t.fromInt(e),t}function p(e){var t,r=1;return 0!=(t=e>>>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 d(e){this.m=e}function y(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 w(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function S(){}function k(e){return e}function E(e){this.r2=new n,this.q3=new n,n.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}d.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},d.prototype.revert=function(e){return e},d.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},d.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},d.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},y.prototype.convert=function(e){var t=new n;return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(n.ZERO)>0&&this.m.subTo(t,t),t},y.prototype.revert=function(e){var t=new n;return e.copyTo(t),this.reduce(t),t},y.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(e[r=t+this.m.t]+=this.m.am(0,n,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,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)},i.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s},i.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+o:this.t=0},i.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 i=e.length,o=!1,s=0;--i>=0;){var a=8==r?255&e[i]:l(e,i);a<0?"-"==e.charAt(i)&&(o=!0):(o=!1,0==s?this[this.t++]=a:s+r>this.DB?(this[this.t-1]|=(a&(1<>this.DB-s):this[this.t-1]|=a<=this.DB&&(s-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==e;)--this.t},i.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s},i.drShiftTo=function(e,t){for(var r=e;r=0;--r)t[r+s+1]=this[r]>>i|a,a=(this[r]&o)<=0;--r)t[r]=0;t[s]=a,t.t=this.t+s+1,t.s=this.s,t.clamp()},i.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[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[r++]=this.DV+n:n>0&&(t[r++]=n),t.t=r,t.clamp()},i.multiplyTo=function(e,t){var r=this.abs(),i=e.abs(),o=r.t;for(t.t=o+i.t;--o>=0;)t[o]=0;for(o=0;o=0;)e[r]=0;for(r=0;r=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()},i.divRemTo=function(e,t,r){var i=e.abs();if(!(i.t<=0)){var o=this.abs();if(o.t0?(i.lShiftTo(c,s),o.lShiftTo(c,r)):(i.copyTo(s),o.copyTo(r));var f=s.t,l=s[f-1];if(0!=l){var h=l*(1<1?s[f-2]>>this.F2:0),d=this.FV/h,y=(1<=0&&(r[r.t++]=1,r.subTo(v,r)),n.ONE.dlShiftTo(f,v),v.subTo(s,s);s.t=0;){var _=r[--m]==l?this.DM:Math.floor(r[m]*d+(r[m-1]+g)*y);if((r[m]+=s.am(0,_,r,b,0,f))<_)for(s.dlShiftTo(b,v),r.subTo(v,r);r[m]<--_;)r.subTo(v,r)}null!=t&&(r.drShiftTo(f,t),a!=u&&n.ZERO.subTo(t,t)),r.t=f,r.clamp(),c>0&&r.rShiftTo(c,r),a<0&&n.ZERO.subTo(r,r)}}},i.invDigit=function(){if(this.t<1)return 0;var e=this[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},i.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},i.exp=function(e,t){if(e>4294967295||e<1)return n.ONE;var r=new n,i=new n,o=t.convert(this),s=p(e)-1;for(o.copyTo(r);--s>=0;)if(t.sqrTo(r,i),(e&1<0)t.mulTo(i,o,r);else{var a=r;r=i,i=a}return t.revert(r)},i.toString=function(e){var t;if(this.s<0)return"-"+this.negate().toString(e);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=f(r));s>=0;)a>(a+=this.DB-t)):(r=this[s]>>(a-=t)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=f(r));return i?o:"0"},i.negate=function(){var e=new n;return n.ZERO.subTo(this,e),e},i.abs=function(){return this.s<0?this.negate():this},i.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[r]-e[r]))return t;return 0},i.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+p(this[this.t-1]^this.s&this.DM)},i.byteLength=function(){return this.bitLength()>>3},i.mod=function(e){var t=new n;return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(n.ZERO)>0&&e.subTo(t,t),t},i.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new d(t):new y(t),this.exp(e,r)},S.prototype.convert=k,S.prototype.revert=k,S.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},S.prototype.sqrTo=function(e,t){e.squareTo(t)},E.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=new n;return e.copyTo(t),this.reduce(t),t},E.prototype.revert=function(e){return e},E.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)},E.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},E.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var A=[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,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],x=(1<<26)/A[A.length-1];i.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},i.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),i=h(r),o=new n,s=new n,a="";for(this.divRemTo(i,o,s);o.signum()>0;)a=(r+s.intValue()).toString(e).substr(1)+a,o.divRemTo(i,o,s);return s.intValue().toString(e)+a},i.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),i=Math.pow(t,r),o=!1,s=0,a=0,u=0;u=r&&(this.dMultiply(i),this.dAddOffset(a,0),s=0,a=0))}s>0&&(this.dMultiply(Math.pow(t,s)),this.dAddOffset(a,0)),o&&n.ZERO.subTo(this,this)},i.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(n.ONE.shiftLeft(e-1),m,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(n.ONE.shiftLeft(e-1),this);else{var i=new Array,o=7&e;i.length=1+(e>>3),t.nextBytes(i),o>0?i[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[r++]=n:n<-1&&(t[r++]=this.DV+n),t.t=r,t.clamp()},i.dMultiply=function(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},i.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}},i.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[--i]=0;for(n=r.t-this.t;i=0;)r[n]=0;for(n=Math.max(t-this.t,0);n0)if(0==t)r=this[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this[n])%e;return r},i.millerRabin=function(e){var t=this.subtract(n.ONE),r=t.getLowestSetBit();if(r<=0)return!1;var i=t.shiftRight(r);(e=e+1>>1)>A.length&&(e=A.length);for(var o=new n(null),s=[],a=0;a>24},i.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},i.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},i.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[e]&(1<>(n+=this.DB-8)):(r=this[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},i.equals=function(e){return 0==this.compareTo(e)},i.min=function(e){return this.compareTo(e)<0?this:e},i.max=function(e){return this.compareTo(e)>0?this:e},i.and=function(e){var t=new n;return this.bitwiseTo(e,g,t),t},i.or=function(e){var t=new n;return this.bitwiseTo(e,m,t),t},i.xor=function(e){var t=new n;return this.bitwiseTo(e,b,t),t},i.andNot=function(e){var t=new n;return this.bitwiseTo(e,v,t),t},i.not=function(){for(var e=new n,t=0;t=this.t?0!=this.s:0!=(this[t]&1<1){var l=new n;for(i.sqrTo(a[1],l);u<=f;)a[u]=new n,i.mulTo(l,a[u-2],a[u]),u+=2}var g,m,b=e.t-1,v=!0,_=new n;for(o=p(e[b])-1;b>=0;){for(o>=c?g=e[b]>>o-c&f:(g=(e[b]&(1<0&&(g|=e[b-1]>>this.DB+o-c)),u=r;0==(1&g);)g>>=1,--u;if((o-=u)<0&&(o+=this.DB,--b),v)a[g].copyTo(s),v=!1;else{for(;u>1;)i.sqrTo(s,_),i.sqrTo(_,s),u-=2;u>0?i.sqrTo(s,_):(m=s,s=_,_=m),i.mulTo(_,a[g],s)}for(;b>=0&&0==(e[b]&1<=0?(r.subTo(i,r),t&&o.subTo(a,o),s.subTo(u,s)):(i.subTo(r,i),t&&a.subTo(o,a),u.subTo(s,u))}if(0!=i.compareTo(n.ONE))return n.ZERO;for(;u.compareTo(e)>=0;)u.subTo(e,u);for(;u.signum()<0;)u.addTo(e,u);return u},i.pow=function(e){return this.exp(e,new S)},i.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},i.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r[0]<=A[A.length-1]){for(t=0;t0;--o){var a=r.testBit(o),u=t.testBit(o);i=i.twice(),a!==u&&(i=i.add(a?this:n))}return i},a.prototype.multiplyTwo=function(e,t,r){for(var n=Math.max(e.bitLength(),r.bitLength())-1,i=this.curve.infinity,o=this.add(t);n>=0;){var s=e.testBit(n),a=r.testBit(n);i=i.twice(),s?i=a?i.add(o):i.add(this):a&&(i=i.add(t)),--n}return i},a.prototype.getEncoded=function(e){if(null==e&&(e=this.compressed),this.curve.isInfinity(this))return i.alloc(1,0);var t,r=this.affineX,n=this.affineY,o=this.curve.pLength;return e?(t=i.allocUnsafe(1+o)).writeUInt8(n.isEven()?2:3,0):((t=i.allocUnsafe(1+o+o)).writeUInt8(4,0),n.toBuffer(o).copy(t,1+o)),r.toBuffer(o).copy(t,1),t},a.decodeFrom=function(e,t){var r,i=t.readUInt8(0),s=4!==i,u=Math.floor((e.p.bitLength()+7)/8),c=o.fromBuffer(t.slice(1,1+u));if(s){n.equal(t.length,u+1,"Invalid sequence length"),n(2===i||3===i,"Invalid sequence tag");var f=3===i;r=e.pointFromX(f,c)}else{n.equal(t.length,1+u+u,"Invalid sequence length");var l=o.fromBuffer(t.slice(1+u));r=a.fromAffine(e,c,l)}return r.compressed=s,r},a.prototype.toString=function(){return this.curve.isInfinity(this)?"(INFINITY)":"("+this.affineX.toString()+","+this.affineY.toString()+")"},e.exports=a},function(e,t,r){var n=r(16),i=r(93),o=r(411);function s(e,t,r,n,s,a,u){this.p=e,this.a=t,this.b=r,this.G=o.fromAffine(this,n,s),this.n=a,this.h=u,this.infinity=new o(this,null,null,i.ZERO),this.pOverFour=e.add(i.ONE).shiftRight(2),this.pLength=Math.floor((this.p.bitLength()+7)/8)}s.prototype.pointFromX=function(e,t){var r=t.pow(3).add(this.a.multiply(t)).add(this.b).mod(this.p).modPow(this.pOverFour,this.p),n=r;return r.isEven()^!e&&(n=this.p.subtract(n)),o.fromAffine(this,t,n)},s.prototype.isInfinity=function(e){return e===this.infinity||0===e.z.signum()&&0!==e.y.signum()},s.prototype.isOnCurve=function(e){if(this.isInfinity(e))return!0;var t=e.affineX,r=e.affineY,n=this.a,i=this.b,o=this.p;if(t.signum()<0||t.compareTo(o)>=0)return!1;if(r.signum()<0||r.compareTo(o)>=0)return!1;var s=r.square().mod(o),a=t.pow(3).add(n.multiply(t)).add(i).mod(o);return s.equals(a)},s.prototype.validate=function(e){n(!this.isInfinity(e),"Point is at infinity"),n(this.isOnCurve(e),"Point is not on the curve");var t=e.multiply(this.n);return n(this.isInfinity(t),"Point is not a scalar multiple of G"),!0},e.exports=s},function(e,t,r){"use strict";(function(t){const n=r(809),i=r(127),o=r(128),s=r(846);e.exports=o("eth-account-snapshot",n,function(e,r,n){const o=[];o.push({path:"storage",value:{"/":i("eth-storage-trie",e.stateRoot).toBaseEncodedString()}}),s.equals(e.codeHash)?o.push({path:"code",value:t.from("")}):o.push({path:"code",value:{"/":i("raw",e.codeHash).toBaseEncodedString()}}),o.push({path:"stateRoot",value:e.stateRoot}),o.push({path:"codeHash",value:e.codeHash}),o.push({path:"nonce",value:e.nonce}),o.push({path:"balance",value:e.balance}),o.push({path:"isEmpty",value:e.isEmpty()}),o.push({path:"isContract",value:e.isContract()}),n(null,o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";var n=r(817),i=r(818),o=r(246);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>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){"use strict";var n=r(71).rotr32;function i(e,t,r){return e&t^~e&r}function o(e,t,r){return e&t^e&r^t&r}function s(e,t,r){return e^t^r}t.ft_1=function(e,t,r,n){return 0===e?i(t,r,n):1===e||3===e?s(t,r,n):2===e?o(t,r,n):void 0},t.ch32=i,t.maj32=o,t.p32=s,t.s0_256=function(e){return n(e,2)^n(e,13)^n(e,22)},t.s1_256=function(e){return n(e,6)^n(e,11)^n(e,25)},t.g0_256=function(e){return n(e,7)^n(e,18)^e>>>3},t.g1_256=function(e){return n(e,17)^n(e,19)^e>>>10}},function(e,t,r){"use strict";var n=r(71),i=r(125),o=r(416),s=r(81),a=n.sum32,u=n.sum32_4,c=n.sum32_5,f=o.ch32,l=o.maj32,h=o.s0_256,p=o.s1_256,d=o.g0_256,y=o.g1_256,g=i.BlockHash,m=[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 b(){if(!(this instanceof b))return new b;g.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=m,this.W=new Array(64)}n.inherits(b,g),e.exports=b,b.blockSize=512,b.outSize=256,b.hmacStrength=192,b.padLength=64,b.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;ne?n(e):t.remainderPath.length>0?n(new Error("path out of scope")):void("object"==typeof t.value&&t.value["/"]?n(null,t.value):n(null,!1)))}}},function(e,t,r){const n=r(422),i=r(154);e.exports=function(e,t){return{deserialize:i(e=>new t(e)),serialize:i(e=>e.serialize()),cid:i((t,r)=>n(e,t,r))}}},function(e,t,r){"use strict";const n=r(127);e.exports=function(e,t,r){const i=t.hash();return n(e,i,r)}},function(e,t,r){"use strict";const n=r(424),i=r(127),o=r(128);e.exports=o("eth-block",n,function(e,t,r){const n=[];n.push({path:"parent",value:{"/":i("eth-block",e.parentHash).toBaseEncodedString()}}),n.push({path:"ommers",value:{"/":i("eth-block-list",e.uncleHash).toBaseEncodedString()}}),n.push({path:"transactions",value:{"/":i("eth-tx-trie",e.transactionsTrie).toBaseEncodedString()}}),n.push({path:"transactionReceipts",value:{"/":i("eth-tx-receipt-trie",e.receiptTrie).toBaseEncodedString()}}),n.push({path:"state",value:{"/":i("eth-state-trie",e.stateRoot).toBaseEncodedString()}}),n.push({path:"parentHash",value:e.parentHash}),n.push({path:"ommerHash",value:e.uncleHash}),n.push({path:"transactionTrieRoot",value:e.transactionsTrie}),n.push({path:"transactionReceiptTrieRoot",value:e.receiptTrie}),n.push({path:"stateRoot",value:e.stateRoot}),n.push({path:"authorAddress",value:e.coinbase}),n.push({path:"bloom",value:e.bloom}),n.push({path:"difficulty",value:e.difficulty}),n.push({path:"number",value:e.number}),n.push({path:"gasLimit",value:e.gasLimit}),n.push({path:"gasUsed",value:e.gasUsed}),n.push({path:"timestamp",value:e.timestamp}),n.push({path:"extraData",value:e.extraData}),n.push({path:"mixHash",value:e.mixHash}),n.push({path:"nonce",value:e.nonce}),r(null,n)})},function(e,t,r){(function(t){const n=r(173),i=r(847),o=n.BN;var s=e.exports=function(e){var r=[{name:"parentHash",length:32,default:n.zeros(32)},{name:"uncleHash",default:n.SHA3_RLP_ARRAY},{name:"coinbase",length:20,default:n.zeros(20)},{name:"stateRoot",length:32,default:n.zeros(32)},{name:"transactionsTrie",length:32,default:n.SHA3_RLP},{name:"receiptTrie",length:32,default:n.SHA3_RLP},{name:"bloom",default:n.zeros(256)},{name:"difficulty",default:new t([])},{name:"number",default:n.intToBuffer(i.homeSteadForkNumber.v)},{name:"gasLimit",default:new t("ffffffffffffff","hex")},{name:"gasUsed",empty:!0,default:new t([])},{name:"timestamp",default:new t([])},{name:"extraData",allowZero:!0,empty:!0,default:new t([])},{name:"mixHash",default:n.zeros(32)},{name:"nonce",default:new t([])}];n.defineProperties(this,r,e)};s.prototype.canonicalDifficulty=function(e){const t=new o(this.timestamp),r=new o(e.header.timestamp),s=new o(e.header.difficulty),a=new o(i.minimumDifficulty.v);var u,c=s.div(new o(i.difficultyBoundDivisor.v)),f=e.header.uncleHash.equals(n.SHA3_RLP_ARRAY)?1:2,l=t.sub(r).idivn(9).ineg().iaddn(f),h=new o(-99);1===h.cmp(l)&&(l=h),u=s.add(c.mul(l));var p=new o(this.number).isubn(3e6);p.ltn(0)&&(p=new o(0));var d=p.idivn(1e5).isubn(2);return d.isNeg()||u.iadd(new o(2).pow(d)),-1===u.cmp(a)&&(u=a),u},s.prototype.validateDifficulty=function(e){return 0===this.canonicalDifficulty(e).cmp(new o(this.difficulty))},s.prototype.validateGasLimit=function(e){const t=new o(e.header.gasLimit),r=new o(this.gasLimit),n=t.div(new o(i.gasLimitBoundDivisor.v)),s=t.add(n),a=t.sub(n);return r.lt(s)&&r.gt(a)&&r.gte(i.minGasLimit.v)},s.prototype.validate=function(e,t,r){var s=this;if(2===arguments.length&&(r=t,t=!1),this.isGenesis())return r();e.getBlock(s.parentHash,function(e,a){if(e)return r("could not find parent block");if(s.parentBlock=a,0!==new o(s.number).cmp(new o(a.header.number).iaddn(1)))return r("invalid number");if(t){var u=t.sub(new o(a.header.number));if(-1!==u.cmpn(8)||1!==u.cmpn(1))return r("uncle block has a parent that is too old or to young")}return s.validateDifficulty(a)?s.validateGasLimit(a)?n.bufferToInt(a.header.number)+1!==n.bufferToInt(s.number)?r("invalid heigth"):n.bufferToInt(s.timestamp)<=n.bufferToInt(a.header.timestamp)?r("invalid timestamp"):s.extraData.length>i.maximumExtraDataSize.v?r("invalid amount of extra data"):void r():r("invalid gas limit"):r("invalid Difficulty")})},s.prototype.hash=function(){return n.rlphash(this.raw)},s.prototype.isGenesis=function(){return""===this.number.toString("hex")}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(857),i=r(128);e.exports=i("eth-tx",n,function(e,t,r){const n=[];n.push({path:"nonce",value:e.nonce}),n.push({path:"gasPrice",value:e.gasPrice}),n.push({path:"gasLimit",value:e.gasLimit}),n.push({path:"toAddress",value:e.to}),n.push({path:"value",value:e.value}),n.push({path:"data",value:e.data}),n.push({path:"v",value:e.v}),n.push({path:"r",value:e.r}),n.push({path:"s",value:e.s}),n.push({path:"fromAddress",value:e.from}),n.push({path:"signature",value:[e.v,e.r,e.s]}),n.push({path:"isContractPublish",value:e.toCreationAddress()}),r(null,n)})},function(e,t,r){"use strict";const n=r(862).BlockHeader,i=r(9),o=r(12),s=r(61),a=r(5);e.exports={hashToCid:e=>{const t=r(249).defaultHashAlg,n=o.encode(e,t);return new i(1,"zcash-block",n)},ZCASH_BLOCK_HEADER_SIZE:1487,cid:(e,t,n)=>{"function"==typeof t&&(n=t,t={});const o=(t=t||{}).hashAlg||r(249).defaultHashAlg,u=void 0===t.version?1:t.version;a([t=>{try{s(e.toBuffer(),o,t)}catch(e){t(e)}},(e,t)=>t(null,new i(u,"zcash-block",e))],n)},deserialize:(e,t)=>{if(1487!==e.length)return t(new Error("Zcash block header needs to be 1487 bytes"));t(null,n.fromBuffer(e))},serialize:(e,t)=>{let r,n=null;try{r=e.toBuffer()}catch(e){n=e}finally{t(n,r)}}}},function(e,t,r){"use strict";(function(t){var n=r(32),i=r(109),o=r(63),s=r(73),a=r(179),u=r(38),c=r(24),f=r(18),l=r(21),h=function e(t){if(!(this instanceof e))return new e(t);t&&this.set(t)};h.prototype.set=function(e){return this.hashbuf=e.hashbuf||this.hashbuf,this.endian=e.endian||this.endian,this.privkey=e.privkey||this.privkey,this.pubkey=e.pubkey||(this.privkey?this.privkey.publicKey:this.pubkey),this.sig=e.sig||this.sig,this.k=e.k||this.k,this.verified=e.verified||this.verified,this},h.prototype.privkey2pubkey=function(){this.pubkey=this.privkey.toPublicKey()},h.prototype.calci=function(){for(var e=0;e<4;e++){var t;this.sig.i=e;try{t=this.toPublicKey()}catch(e){console.error(e);continue}if(t.point.eq(this.pubkey.point))return this.sig.compressed=this.pubkey.compressed,this}throw this.sig.i=void 0,new Error("Unable to find valid recovery factor")},h.fromString=function(e){var t=JSON.parse(e);return new h(t)},h.prototype.randomK=function(){var e,t=i.getN();do{e=n.fromBuffer(a.getRandomBuffer(32))}while(!e.lt(t)||!e.gt(n.Zero));return this.k=e,this},h.prototype.deterministicK=function(e){f.isUndefined(e)&&(e=0);var r=new t(32);r.fill(1);var o=new t(32);o.fill(0);var s=this.privkey.bn.toBuffer({size:32}),a="little"===this.endian?c.reverse(this.hashbuf):this.hashbuf;o=u.sha256hmac(t.concat([r,new t([0]),s,a]),o),r=u.sha256hmac(r,o),o=u.sha256hmac(t.concat([r,new t([1]),s,a]),o),r=u.sha256hmac(r,o),r=u.sha256hmac(r,o);for(var l=n.fromBuffer(r),h=i.getN(),p=0;p>1,c=i.getN(),f=i.getG(),h=u?r.add(c):r,p=i.fromX(a,h);if(!p.mul(c).isInfinity())throw new Error("nR is not a valid curve point");var d=t.neg().mod(c),y=r.invm(c),g=p.mul(o).add(f.mul(d)).mul(y);return s.fromPoint(g,this.sig.compressed)},h.prototype.sigError=function(){if(!c.isBuffer(this.hashbuf)||32!==this.hashbuf.length)return"hashbuf must be a 32 byte buffer";var e=this.sig.r,t=this.sig.s;if(!(e.gt(n.Zero)&&e.lt(i.getN())&&t.gt(n.Zero)&&t.lt(i.getN())))return"r and s not in range";var r=n.fromBuffer(this.hashbuf,this.endian?{endian:this.endian}:void 0),o=i.getN(),s=t.invm(o),a=s.mul(r).mod(o),u=s.mul(e).mod(o),f=i.getG().mulAdd(a,this.pubkey.point,u);return f.isInfinity()?"p is infinity":0!==f.getX().mod(o).cmp(e)&&"Invalid signature"},h.toLowS=function(e){return e.gt(n.fromBuffer(new t("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))&&(e=i.getN().sub(e)),e},h.prototype._findSignature=function(e,t){var r,o,s,a=i.getN(),u=i.getG(),c=0;do{(!this.k||c>0)&&this.deterministicK(c),c++,r=this.k,o=u.mul(r).x.mod(a),s=r.invm(a).mul(t.add(e.mul(o))).mod(a)}while(o.cmp(n.Zero)<=0||s.cmp(n.Zero)<=0);return{s:s=h.toLowS(s),r:o}},h.prototype.sign=function(){var e=this.hashbuf,t=this.privkey,r=t.bn;l.checkState(e&&t&&r,new Error("invalid parameters")),l.checkState(c.isBuffer(e)&&32===e.length,new Error("hashbuf must be a 32 byte buffer"));var i=n.fromBuffer(e,this.endian?{endian:this.endian}:void 0),s=this._findSignature(r,i);return s.compressed=this.pubkey.compressed,this.sig=new o(s),this},h.prototype.signRandomK=function(){return this.randomK(),this.sign()},h.prototype.toString=function(){var e={};return this.hashbuf&&(e.hashbuf=this.hashbuf.toString("hex")),this.privkey&&(e.privkey=this.privkey.toString()),this.pubkey&&(e.pubkey=this.pubkey.toString()),this.sig&&(e.sig=this.sig.toString()),this.k&&(e.k=this.k.toString()),JSON.stringify(e)},h.prototype.verify=function(){return this.sigError()?this.verified=!1:this.verified=!0,this},h.sign=function(e,t,r){return h().set({hashbuf:e,endian:r,privkey:t}).sign().sig},h.verify=function(e,t,r,n){return h().set({hashbuf:e,endian:n,sig:t,pubkey:r}).verify().verified},e.exports=h}).call(this,r(0).Buffer)},function(e,t){for(var r="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",n={},i=0;i>8,i[r]&=255;for(;a;)i.push(255&a),a>>=8}for(t=0;"1"===e[t]&&t0&&s0&&s0&&(i=n?i+" "+e.buf.toString("hex"):i+" "+e.len+" 0x"+e.buf.toString("hex"));else if(void 0!==a.reverseMap[r])i=i+" "+a(r).toString();else{var o=r.toString(16);o.length%2!=0&&(o="0"+o),i=n?i+" "+o:i+" 0x"+o}return i},m.prototype.toASM=function(){for(var e="",t=0;t"},m.prototype.isPublicKeyHashOut=function(){return!(5!==this.chunks.length||this.chunks[0].opcodenum!==a.OP_DUP||this.chunks[1].opcodenum!==a.OP_HASH160||!this.chunks[2].buf||20!==this.chunks[2].buf.length||this.chunks[3].opcodenum!==a.OP_EQUALVERIFY||this.chunks[4].opcodenum!==a.OP_CHECKSIG)},m.prototype.isPublicKeyHashIn=function(){if(2===this.chunks.length){var e=this.chunks[0].buf,t=this.chunks[1].buf;if(e&&e.length&&48===e[0]&&t&&t.length){var r=t[0];if((4===r||6===r||7===r)&&65===t.length)return!0;if((3===r||2===r)&&33===t.length)return!0}}return!1},m.prototype.getPublicKey=function(){return l.checkState(this.isPublicKeyOut(),"Can't retreive PublicKey from a non-PK output"),this.chunks[0].buf},m.prototype.getPublicKeyHash=function(){return l.checkState(this.isPublicKeyHashOut(),"Can't retrieve PublicKeyHash from a non-PKH output"),this.chunks[2].buf},m.prototype.isPublicKeyOut=function(){if(2===this.chunks.length&&this.chunks[0].buf&&this.chunks[0].buf.length&&this.chunks[1].opcodenum===a.OP_CHECKSIG){var e=this.chunks[0].buf,t=e[0],r=!1;if((4!==t&&6!==t&&7!==t||65!==e.length)&&(3!==t&&2!==t||33!==e.length)||(r=!0),r)return u.isValid(e)}return!1},m.prototype.isPublicKeyIn=function(){if(1===this.chunks.length){var e=this.chunks[0].buf;if(e&&e.length&&48===e[0])return!0}return!1},m.prototype.isScriptHashOut=function(){var e=this.toBuffer();return 23===e.length&&e[0]===a.OP_HASH160&&20===e[1]&&e[e.length-1]===a.OP_EQUAL},m.prototype.isScriptHashIn=function(){if(this.chunks.length<=1)return!1;var e,t,r=this.chunks[this.chunks.length-1].buf;if(!r)return!1;try{t=m.fromBuffer(r)}catch(e){if(e instanceof p.Script.InvalidBuffer)return!1;throw e}return t.classify()!==m.types.UNKNOWN},m.prototype.isMultisigOut=function(){return this.chunks.length>3&&a.isSmallIntOp(this.chunks[0].opcodenum)&&this.chunks.slice(1,this.chunks.length-2).every(function(e){return e.buf&&y.isBuffer(e.buf)})&&a.isSmallIntOp(this.chunks[this.chunks.length-2].opcodenum)&&this.chunks[this.chunks.length-1].opcodenum===a.OP_CHECKMULTISIG},m.prototype.isMultisigIn=function(){return this.chunks.length>=2&&0===this.chunks[0].opcodenum&&this.chunks.slice(1,this.chunks.length).every(function(e){return e.buf&&y.isBuffer(e.buf)&&c.isTxDER(e.buf)})},m.prototype.isDataOut=function(){return this.chunks.length>=1&&this.chunks[0].opcodenum===a.OP_RETURN&&(1===this.chunks.length||2===this.chunks.length&&this.chunks[1].buf&&this.chunks[1].buf.length<=m.OP_RETURN_STANDARD_SIZE&&this.chunks[1].length===this.chunks.len)},m.prototype.getData=function(){if(this.isDataOut()||this.isScriptHashOut())return h.isUndefined(this.chunks[1])?new t(0):new t(this.chunks[1].buf);if(this.isPublicKeyHashOut())return new t(this.chunks[2].buf);throw new Error("Unrecognized script type to get data from")},m.prototype.isPushOnly=function(){return h.every(this.chunks,function(e){return e.opcodenum<=a.OP_16})},(m.types={}).UNKNOWN="Unknown",m.types.PUBKEY_OUT="Pay to public key",m.types.PUBKEY_IN="Spend from public key",m.types.PUBKEYHASH_OUT="Pay to public key hash",m.types.PUBKEYHASH_IN="Spend from public key hash",m.types.SCRIPTHASH_OUT="Pay to script hash",m.types.SCRIPTHASH_IN="Spend from script hash",m.types.MULTISIG_OUT="Pay to multisig",m.types.MULTISIG_IN="Spend from multisig",m.types.DATA_OUT="Data push",m.OP_RETURN_STANDARD_SIZE=80,m.prototype.classify=function(){if(this._isInput)return this.classifyInput();if(this._isOutput)return this.classifyOutput();var e=this.classifyOutput();return e!=m.types.UNKNOWN?e:this.classifyInput()},(m.outputIdentifiers={}).PUBKEY_OUT=m.prototype.isPublicKeyOut,m.outputIdentifiers.PUBKEYHASH_OUT=m.prototype.isPublicKeyHashOut,m.outputIdentifiers.MULTISIG_OUT=m.prototype.isMultisigOut,m.outputIdentifiers.SCRIPTHASH_OUT=m.prototype.isScriptHashOut,m.outputIdentifiers.DATA_OUT=m.prototype.isDataOut,m.prototype.classifyOutput=function(){for(var e in m.outputIdentifiers)if(m.outputIdentifiers[e].bind(this)())return m.types[e];return m.types.UNKNOWN},(m.inputIdentifiers={}).PUBKEY_IN=m.prototype.isPublicKeyIn,m.inputIdentifiers.PUBKEYHASH_IN=m.prototype.isPublicKeyHashIn,m.inputIdentifiers.MULTISIG_IN=m.prototype.isMultisigIn,m.inputIdentifiers.SCRIPTHASH_IN=m.prototype.isScriptHashIn,m.prototype.classifyInput=function(){for(var e in m.inputIdentifiers)if(m.inputIdentifiers[e].bind(this)())return m.types[e];return m.types.UNKNOWN},m.prototype.isStandard=function(){return this.classify()!==m.types.UNKNOWN},m.prototype.prepend=function(e){return this._addByType(e,!0),this},m.prototype.equals=function(e){if(l.checkState(e instanceof m,"Must provide another script"),this.chunks.length!==e.chunks.length)return!1;var t;for(t=0;t=0&&n=1&&r[0]<=16?n!==a.OP_1+(r[0]-1):1===r.length&&129===r[0]?n!==a.OP_1NEGATE:r.length<=75?n!==r.length:r.length<=255?n!==a.OP_PUSHDATA1:r.length<=65535&&n!==a.OP_PUSHDATA2))},m.prototype._decodeOP_N=function(e){if(e===a.OP_0)return 0;if(e>=a.OP_1&&e<=a.OP_16)return e-(a.OP_1-1);throw new Error("Invalid opcode: "+JSON.stringify(e))},m.prototype.getSignatureOperationsCount=function(e){e=!!h.isUndefined(e)||e;var t=this,r=0,n=a.OP_INVALIDOPCODE;return h.each(t.chunks,function(i){var o=i.opcodenum;o==a.OP_CHECKSIG||o==a.OP_CHECKSIGVERIFY?r++:o!=a.OP_CHECKMULTISIG&&o!=a.OP_CHECKMULTISIGVERIFY||(e&&n>=a.OP_1&&n<=a.OP_16?r+=t._decodeOP_N(n):r+=20),n=o}),r},e.exports=m}).call(this,r(0).Buffer)},function(e,t,r){"use strict";var n=r(18),i=r(21),o=r(29),s=r(64),a=r(97),u=r(253);function c(e){if(!(this instanceof c))return new c(e);i.checkArgument(n.isObject(e),"Must provide an object from where to extract data");var t=e.address?new a(e.address):void 0,r=e.txid?e.txid:e.txId;if(!r||!o.isHexaString(r)||r.length>64)throw new Error("Invalid TXID in object",e);var f=n.isUndefined(e.vout)?e.outputIndex:e.vout;if(!n.isNumber(f))throw new Error("Invalid outputIndex, received "+f);i.checkArgument(!n.isUndefined(e.scriptPubKey)||!n.isUndefined(e.script),"Must provide the scriptPubKey for that output!");var l=new s(e.scriptPubKey||e.script);i.checkArgument(!n.isUndefined(e.amount)||!n.isUndefined(e.satoshis),"Must provide an amount for the output");var h=n.isUndefined(e.amount)?e.satoshis:new u.fromBTC(e.amount).toSatoshis();i.checkArgument(n.isNumber(h),"Amount must be a number"),o.defineImmutable(this,{address:t,txId:r,outputIndex:f,script:l,satoshis:h})}c.prototype.inspect=function(){return""},c.prototype.toString=function(){return this.txId+":"+this.outputIndex},c.fromObject=function(e){return new c(e)},c.prototype.toObject=c.prototype.toJSON=function(){return{address:this.address?this.address.toString():void 0,txid:this.txId,vout:this.outputIndex,scriptPubKey:this.script.toBuffer().toString("hex"),amount:u.fromSatoshis(this.satoshis).toBTC()}},e.exports=c},function(e,t,r){"use strict";(function(t){var n=r(18),i=r(180),o=r(24),s=r(82),a=r(57),u=r(38),c=(r(29),r(178)),f=r(21);function l(e){if(!(this instanceof l))return new l(e);var t={};if(o.isBuffer(e))t=l._fromBufferReader(s(e));else{if(!n.isObject(e))throw new TypeError("Unrecognized argument for MerkleBlock");t={header:e.header instanceof i?e.header:i.fromObject(e.header),numTransactions:e.numTransactions,hashes:e.hashes,flags:e.flags}}return n.extend(this,t),this._flagBitsUsed=0,this._hashesUsed=0,this}l.fromBuffer=function(e){return l.fromBufferReader(s(e))},l.fromBufferReader=function(e){return new l(l._fromBufferReader(e))},l.prototype.toBuffer=function(){return this.toBufferWriter().concat()},l.prototype.toBufferWriter=function(e){e||(e=new a),e.write(this.header.toBuffer()),e.writeUInt32LE(this.numTransactions),e.writeVarintNum(this.hashes.length);for(var r=0;rthis.numTransactions)return!1;if(8*this.flags.length8*this.flags.length)return null;var i=this.flags[n.flagBitsUsed>>3]>>>(7&n.flagBitsUsed++)&1;if(0!==e&&i){var o=this._traverseMerkleTree(e-1,2*r,n),s=o;return 2*r+1=this.hashes.length)return null;var a=this.hashes[n.hashesUsed++];return 0===e&&i&&n.txs.push(a),new t(a,"hex")},l.prototype._calcTreeWidth=function(e){return this.numTransactions+(1<>e},l.prototype._calcTreeHeight=function(){for(var e=0;this._calcTreeWidth(e)>1;)e++;return e},l.prototype.hasTransaction=function(e){f.checkArgument(!n.isUndefined(e),"tx cannot be undefined"),f.checkArgument(e instanceof c||"string"==typeof e,'Invalid tx given, tx must be a "string" or "Transaction"');var r=e;e instanceof c&&(r=o.reverse(new t(e.id,"hex")).toString("hex"));var i=[],s=this._calcTreeHeight();return this._traverseMerkleTree(s,0,{txs:i}),-1!==i.indexOf(r)},l._fromBufferReader=function(e){f.checkState(!e.finished(),"No merkleblock data received");var t={};t.header=i.fromBufferReader(e),t.numTransactions=e.readUInt32LE();var r=e.readVarintNum();t.hashes=[];for(var n=0;n=0&&e<_.MaxIndex)},_._getDerivationIndexes=function(e){var t=e.split("/");if(o.contains(_.RootElementAlias,e))return[];if(!o.contains(_.RootElementAlias,t[0]))return null;var r=t.slice(1).map(function(e){var t="'"===e.slice(-1);if(t&&(e=e.slice(0,-1)),!e||"-"===e[0])return NaN;var r=+e;return t&&(r+=_.Hardened),r});return o.any(r,isNaN)?null:r},_.prototype.derive=function(e,t){if(o.isNumber(e))return this._deriveWithNumber(e,t);if(o.isString(e))return this._deriveFromString(e);throw new m.InvalidDerivationArgument(e)},_.prototype._deriveWithNumber=function(e,t){if(!_.isValidPath(e,t))throw new m.InvalidPath(e);t=e>=_.Hardened||t,e<_.Hardened&&!0===t&&(e+=_.Hardened);var r=h.get(this.xprivkey,e,t);if(r)return r;var n,o=b.integerAsBuffer(e);n=t?b.concat([new i.Buffer([0]),this.privateKey.toBuffer(),o]):b.concat([this.publicKey.toBuffer(),o]);var s=f.sha512hmac(n,this._buffers.chainCode),u=a.fromBuffer(s.slice(0,32),{size:32}),c=s.slice(32,64),l=u.add(this.privateKey.toBigNumber()).mod(p.getN()).toBuffer({size:32}),d=new _({network:this.network,depth:this.depth+1,parentFingerPrint:this.fingerPrint,childIndex:e,chainCode:c,privateKey:l});return h.set(this.xprivkey,e,t,d),d},_.prototype._deriveFromString=function(e){if(!_.isValidPath(e))throw new m.InvalidPath(e);return _._getDerivationIndexes(e).reduce(function(e,t){return e._deriveWithNumber(t)},this)},_.isValidSerialized=function(e,t){return!_.getSerializedError(e,t)},_.getSerializedError=function(e,t){if(!o.isString(e)&&!b.isBuffer(e))return new m.UnrecognizedArgument("Expected string or buffer");if(!u.validCharacters(e))return new g.InvalidB58Char("(unknown)",e);try{e=c.decode(e)}catch(t){return new g.InvalidB58Checksum(e)}if(e.length!==_.DataLength)return new m.InvalidLength(e);if(!o.isUndefined(t)){var r=_._validateNetwork(e,t);if(r)return r}return null},_._validateNetwork=function(e,t){var r=l.get(t);if(!r)return new g.InvalidNetworkArgument(t);var n=e.slice(0,4);return b.integerFromBuffer(n)!==r.xprivkey?new g.InvalidNetwork(n):null},_.fromString=function(e){return s.checkArgument(o.isString(e),"No valid string was provided"),new _(e)},_.fromObject=function(e){return s.checkArgument(o.isObject(e),"No valid argument was provided"),new _(e)},_.prototype._buildFromJSON=function(e){return this._buildFromObject(JSON.parse(e))},_.prototype._buildFromObject=function(e){var t={version:e.network?b.integerAsBuffer(l.get(e.network).xprivkey):e.version,depth:o.isNumber(e.depth)?b.integerAsSingleByteBuffer(e.depth):e.depth,parentFingerPrint:o.isNumber(e.parentFingerPrint)?b.integerAsBuffer(e.parentFingerPrint):e.parentFingerPrint,childIndex:o.isNumber(e.childIndex)?b.integerAsBuffer(e.childIndex):e.childIndex,chainCode:o.isString(e.chainCode)?b.hexToBuffer(e.chainCode):e.chainCode,privateKey:o.isString(e.privateKey)&&v.isHexa(e.privateKey)?b.hexToBuffer(e.privateKey):e.privateKey,checksum:e.checksum?e.checksum.length?e.checksum:b.integerAsBuffer(e.checksum):void 0};return this._buildFromBuffers(t)},_.prototype._buildFromSerialized=function(e){var t=c.decode(e),r={version:t.slice(_.VersionStart,_.VersionEnd),depth:t.slice(_.DepthStart,_.DepthEnd),parentFingerPrint:t.slice(_.ParentFingerPrintStart,_.ParentFingerPrintEnd),childIndex:t.slice(_.ChildIndexStart,_.ChildIndexEnd),chainCode:t.slice(_.ChainCodeStart,_.ChainCodeEnd),privateKey:t.slice(_.PrivateKeyStart,_.PrivateKeyEnd),checksum:t.slice(_.ChecksumStart,_.ChecksumEnd),xprivkey:e};return this._buildFromBuffers(r)},_.prototype._generateRandomly=function(e){return _.fromSeed(y.getRandomBuffer(64),e)},_.fromSeed=function(e,r){if(v.isHexaString(e)&&(e=b.hexToBuffer(e)),!t.isBuffer(e))throw new m.InvalidEntropyArgument(e);if(e.length<16)throw new m.InvalidEntropyArgument.NotEnoughEntropy(e);if(e.length>64)throw new m.InvalidEntropyArgument.TooMuchEntropy(e);var n=f.sha512hmac(e,new i.Buffer("Bitcoin seed"));return new _({network:l.get(r)||l.defaultNetwork,depth:0,parentFingerPrint:0,childIndex:0,privateKey:n.slice(0,32),chainCode:n.slice(32,64)})},_.prototype._calcHDPublicKey=function(){if(!this._hdPublicKey){var e=r(434);this._hdPublicKey=new e(this)}},_.prototype._buildFromBuffers=function(e){_._validateBufferArguments(e),v.defineImmutable(this,{_buffers:e});var r=[e.version,e.depth,e.parentFingerPrint,e.childIndex,e.chainCode,b.emptyBuffer(1),e.privateKey],n=i.Buffer.concat(r);if(e.checksum&&e.checksum.length){if(e.checksum.toString()!==c.checksum(n).toString())throw new g.InvalidB58Checksum(n)}else e.checksum=c.checksum(n);var o,s=l.get(b.integerFromBuffer(e.version));o=c.encode(i.Buffer.concat(r)),e.xprivkey=new t(o);var u=new d(a.fromBuffer(e.privateKey),s),h=u.toPublicKey(),p=_.ParentFingerPrintSize,y=f.sha256ripemd160(h.toBuffer()).slice(0,p);return v.defineImmutable(this,{xprivkey:o,network:s,depth:b.integerFromSingleByteBuffer(e.depth),privateKey:u,publicKey:h,fingerPrint:y}),this._hdPublicKey=null,Object.defineProperty(this,"hdPublicKey",{configurable:!1,enumerable:!0,get:function(){return this._calcHDPublicKey(),this._hdPublicKey}}),Object.defineProperty(this,"xpubkey",{configurable:!1,enumerable:!0,get:function(){return this._calcHDPublicKey(),this._hdPublicKey.xpubkey}}),this},_._validateBufferArguments=function(e){var t=function(t,r){var i=e[t];n(b.isBuffer(i),t+" argument is not a buffer"),n(i.length===r,t+" has not the expected size: found "+i.length+", expected "+r)};t("version",_.VersionSize),t("depth",_.DepthSize),t("parentFingerPrint",_.ParentFingerPrintSize),t("childIndex",_.ChildIndexSize),t("chainCode",_.ChainCodeSize),t("privateKey",_.PrivateKeySize),e.checksum&&e.checksum.length&&t("checksum",_.CheckSumSize)},_.prototype.toString=function(){return this.xprivkey},_.prototype.inspect=function(){return""},_.prototype.toObject=_.prototype.toJSON=function(){return{network:l.get(b.integerFromBuffer(this._buffers.version),"xprivkey").name,depth:b.integerFromSingleByteBuffer(this._buffers.depth),fingerPrint:b.integerFromBuffer(this.fingerPrint),parentFingerPrint:b.integerFromBuffer(this._buffers.parentFingerPrint),childIndex:b.integerFromBuffer(this._buffers.childIndex),chainCode:b.bufferToHex(this._buffers.chainCode),privateKey:this.privateKey.toBuffer().toString("hex"),checksum:b.integerFromBuffer(this._buffers.checksum),xprivkey:this.xprivkey}},_.fromBuffer=function(e){return new _(e.toString())},_.prototype.toBuffer=function(){return b.copy(this._buffers.xprivkey)},_.DefaultDepth=0,_.DefaultFingerprint=0,_.DefaultChildIndex=0,_.Hardened=2147483648,_.MaxIndex=2*_.Hardened,_.RootElementAlias=["m","M","m'","M'"],_.VersionSize=4,_.DepthSize=1,_.ParentFingerPrintSize=4,_.ChildIndexSize=4,_.ChainCodeSize=32,_.PrivateKeySize=32,_.CheckSumSize=4,_.DataLength=78,_.SerializedByteSize=82,_.VersionStart=0,_.VersionEnd=_.VersionStart+_.VersionSize,_.DepthStart=_.VersionEnd,_.DepthEnd=_.DepthStart+_.DepthSize,_.ParentFingerPrintStart=_.DepthEnd,_.ParentFingerPrintEnd=_.ParentFingerPrintStart+_.ParentFingerPrintSize,_.ChildIndexStart=_.ParentFingerPrintEnd,_.ChildIndexEnd=_.ChildIndexStart+_.ChildIndexSize,_.ChainCodeStart=_.ChildIndexEnd,_.ChainCodeEnd=_.ChainCodeStart+_.ChainCodeSize,_.PrivateKeyStart=_.ChainCodeEnd+1,_.PrivateKeyEnd=_.PrivateKeyStart+_.PrivateKeySize,_.ChecksumStart=_.PrivateKeyEnd,_.ChecksumEnd=_.ChecksumStart+_.CheckSumSize,n(_.ChecksumEnd===_.SerializedByteSize),e.exports=_}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){var n=r(18),i=r(21),o=r(32),s=r(177),a=r(129),u=r(38),c=r(433),f=r(254),l=r(96),h=r(109),p=r(73),d=r(62),y=d,g=d.HDPublicKey,m=r(16),b=r(29),v=r(24);function _(e){if(e instanceof _)return e;if(!(this instanceof _))return new _(e);if(e){if(n.isString(e)||v.isBuffer(e)){var t=_.getSerializedError(e);if(t){if(v.isBuffer(e)&&!_.getSerializedError(e.toString()))return this._buildFromSerialized(e.toString());if(t instanceof g.ArgumentIsPrivateExtended)return new c(e).hdPublicKey;throw t}return this._buildFromSerialized(e)}if(n.isObject(e))return e instanceof c?this._buildFromPrivate(e):this._buildFromObject(e);throw new g.UnrecognizedArgument(e)}throw new g.MustSupplyArgument}_.isValidPath=function(e){if(n.isString(e)){var t=c._getDerivationIndexes(e);return null!==t&&n.all(t,_.isValidPath)}return!!n.isNumber(e)&&e>=0&&e<_.Hardened},_.prototype.derive=function(e,t){if(n.isNumber(e))return this._deriveWithNumber(e,t);if(n.isString(e))return this._deriveFromString(e);throw new g.InvalidDerivationArgument(e)},_.prototype._deriveWithNumber=function(e,t){if(e>=_.Hardened||t)throw new g.InvalidIndexCantDeriveHardened;if(e<0)throw new g.InvalidPath(e);var r=f.get(this.xpubkey,e,!1);if(r)return r;var n=v.integerAsBuffer(e),i=v.concat([this.publicKey.toBuffer(),n]),s=u.sha512hmac(i,this._buffers.chainCode),a=o.fromBuffer(s.slice(0,32),{size:32}),c=s.slice(32,64),l=p.fromPoint(h.getG().mul(a).add(this.publicKey.point)),d=new _({network:this.network,depth:this.depth+1,parentFingerPrint:this.fingerPrint,childIndex:e,chainCode:c,publicKey:l});return f.set(this.xpubkey,e,!1,d),d},_.prototype._deriveFromString=function(e){if(n.contains(e,"'"))throw new g.InvalidIndexCantDeriveHardened;if(!_.isValidPath(e))throw new g.InvalidPath(e);return c._getDerivationIndexes(e).reduce(function(e,t){return e._deriveWithNumber(t)},this)},_.isValidSerialized=function(e,t){return n.isNull(_.getSerializedError(e,t))},_.getSerializedError=function(e,t){if(!n.isString(e)&&!v.isBuffer(e))return new g.UnrecognizedArgument("expected buffer or string");if(!s.validCharacters(e))return new y.InvalidB58Char("(unknown)",e);try{e=a.decode(e)}catch(t){return new y.InvalidB58Checksum(e)}if(e.length!==_.DataSize)return new g.InvalidLength(e);if(!n.isUndefined(t)){var r=_._validateNetwork(e,t);if(r)return r}var i=v.integerFromBuffer(e.slice(0,4));return i===l.livenet.xprivkey||i===l.testnet.xprivkey?new g.ArgumentIsPrivateExtended:null},_._validateNetwork=function(e,t){var r=l.get(t);if(!r)return new y.InvalidNetworkArgument(t);var n=e.slice(_.VersionStart,_.VersionEnd);return v.integerFromBuffer(n)!==r.xpubkey?new y.InvalidNetwork(n):null},_.prototype._buildFromPrivate=function(e){var t=n.clone(e._buffers),r=h.getG().mul(o.fromBuffer(t.privateKey));return t.publicKey=h.pointToCompressed(r),t.version=v.integerAsBuffer(l.get(v.integerFromBuffer(t.version)).xpubkey),t.privateKey=void 0,t.checksum=void 0,t.xprivkey=void 0,this._buildFromBuffers(t)},_.prototype._buildFromObject=function(e){var t={version:e.network?v.integerAsBuffer(l.get(e.network).xpubkey):e.version,depth:n.isNumber(e.depth)?v.integerAsSingleByteBuffer(e.depth):e.depth,parentFingerPrint:n.isNumber(e.parentFingerPrint)?v.integerAsBuffer(e.parentFingerPrint):e.parentFingerPrint,childIndex:n.isNumber(e.childIndex)?v.integerAsBuffer(e.childIndex):e.childIndex,chainCode:n.isString(e.chainCode)?v.hexToBuffer(e.chainCode):e.chainCode,publicKey:n.isString(e.publicKey)?v.hexToBuffer(e.publicKey):v.isBuffer(e.publicKey)?e.publicKey:e.publicKey.toBuffer(),checksum:n.isNumber(e.checksum)?v.integerAsBuffer(e.checksum):e.checksum};return this._buildFromBuffers(t)},_.prototype._buildFromSerialized=function(e){var t=a.decode(e),r={version:t.slice(_.VersionStart,_.VersionEnd),depth:t.slice(_.DepthStart,_.DepthEnd),parentFingerPrint:t.slice(_.ParentFingerPrintStart,_.ParentFingerPrintEnd),childIndex:t.slice(_.ChildIndexStart,_.ChildIndexEnd),chainCode:t.slice(_.ChainCodeStart,_.ChainCodeEnd),publicKey:t.slice(_.PublicKeyStart,_.PublicKeyEnd),checksum:t.slice(_.ChecksumStart,_.ChecksumEnd),xpubkey:e};return this._buildFromBuffers(r)},_.prototype._buildFromBuffers=function(e){_._validateBufferArguments(e),b.defineImmutable(this,{_buffers:e});var r=[e.version,e.depth,e.parentFingerPrint,e.childIndex,e.chainCode,e.publicKey],n=v.concat(r),i=a.checksum(n);if(e.checksum&&e.checksum.length){if(e.checksum.toString("hex")!==i.toString("hex"))throw new y.InvalidB58Checksum(n,i)}else e.checksum=i;var o,s=l.get(v.integerFromBuffer(e.version));o=a.encode(v.concat(r)),e.xpubkey=new t(o);var c=new p(e.publicKey,{network:s}),f=_.ParentFingerPrintSize,h=u.sha256ripemd160(c.toBuffer()).slice(0,f);return b.defineImmutable(this,{xpubkey:o,network:s,depth:v.integerFromSingleByteBuffer(e.depth),publicKey:c,fingerPrint:h}),this},_._validateBufferArguments=function(e){var t=function(t,r){var n=e[t];m(v.isBuffer(n),t+" argument is not a buffer, it's "+typeof n),m(n.length===r,t+" has not the expected size: found "+n.length+", expected "+r)};t("version",_.VersionSize),t("depth",_.DepthSize),t("parentFingerPrint",_.ParentFingerPrintSize),t("childIndex",_.ChildIndexSize),t("chainCode",_.ChainCodeSize),t("publicKey",_.PublicKeySize),e.checksum&&e.checksum.length&&t("checksum",_.CheckSumSize)},_.fromString=function(e){return i.checkArgument(n.isString(e),"No valid string was provided"),new _(e)},_.fromObject=function(e){return i.checkArgument(n.isObject(e),"No valid argument was provided"),new _(e)},_.prototype.toString=function(){return this.xpubkey},_.prototype.inspect=function(){return""},_.prototype.toObject=_.prototype.toJSON=function(){return{network:l.get(v.integerFromBuffer(this._buffers.version)).name,depth:v.integerFromSingleByteBuffer(this._buffers.depth),fingerPrint:v.integerFromBuffer(this.fingerPrint),parentFingerPrint:v.integerFromBuffer(this._buffers.parentFingerPrint),childIndex:v.integerFromBuffer(this._buffers.childIndex),chainCode:v.bufferToHex(this._buffers.chainCode),publicKey:this.publicKey.toString(),checksum:v.integerFromBuffer(this._buffers.checksum),xpubkey:this.xpubkey}},_.fromBuffer=function(e){return new _(e)},_.prototype.toBuffer=function(){return v.copy(this._buffers.xpubkey)},_.Hardened=2147483648,_.RootElementAlias=["m","M"],_.VersionSize=4,_.DepthSize=1,_.ParentFingerPrintSize=4,_.ChildIndexSize=4,_.ChainCodeSize=32,_.PublicKeySize=33,_.CheckSumSize=4,_.DataSize=78,_.SerializedByteSize=82,_.VersionStart=0,_.VersionEnd=_.VersionStart+_.VersionSize,_.DepthStart=_.VersionEnd,_.DepthEnd=_.DepthStart+_.DepthSize,_.ParentFingerPrintStart=_.DepthEnd,_.ParentFingerPrintEnd=_.ParentFingerPrintStart+_.ParentFingerPrintSize,_.ChildIndexStart=_.ParentFingerPrintEnd,_.ChildIndexEnd=_.ChildIndexStart+_.ChildIndexSize,_.ChainCodeStart=_.ChildIndexEnd,_.ChainCodeEnd=_.ChainCodeStart+_.ChainCodeSize,_.PublicKeyStart=_.ChainCodeEnd,_.PublicKeyEnd=_.PublicKeyStart+_.PublicKeySize,_.ChecksumStart=_.PublicKeyEnd,_.ChecksumEnd=_.ChecksumStart+_.CheckSumSize,m(_.PublicKeyEnd===_.DataSize),m(_.ChecksumEnd===_.SerializedByteSize),e.exports=_}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(255),i=r(256)(),o=r(895),s={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"},a=(t,r,o)=>{n(i.subtle.sign({name:"HMAC"},t,r).then(t=>e.from(t)),o)};t.create=function(e,t,r){const u=s[e];n(i.subtle.importKey("raw",t,{name:"HMAC",hash:{name:u}},!1,["sign"]).then(t=>({digest(e,r){a(t,e,r)},length:o[e]})),r)}}).call(this,r(0).Buffer)},function(e,t,r){var n={ECB:r(899),CBC:r(900),CFB:r(901),CFB8:r(902),CFB1:r(903),OFB:r(904),CTR:r(437),GCM:r(437)},i=r(439);for(var o in i)i[o].module=n[i[o].mode];e.exports=i},function(e,t,r){var n=r(132),i=r(2).Buffer,o=r(438);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(c),f.update(e),t&&f.update(t),c=f.digest();var l=0;if(s>0){var h=a.length-s;l=Math.min(s,c.length),c.copy(a,h,0,l),s-=l}if(l0){var p=u.length-o,d=Math.min(o,c.length-l);c.copy(u,p,l,l+d),o-=d}}return c.fill(0),{key:a,iv:u}}},function(e,t,r){var n=r(13);r(19),n.cipher=n.cipher||{};var i=e.exports=n.cipher.modes=n.cipher.modes||{};function o(e){if("string"==typeof e&&(e=n.util.createBuffer(e)),n.util.isArray(e)&&e.length>4){var t=e;e=n.util.createBuffer();for(var r=0;r0))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._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._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._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._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>1,a=s+(1&e.length),u=e.substr(0,a),c=e.substr(s,a),f=n.util.createBuffer(),l=n.hmac.create();r=t+r;var h=Math.ceil(i/16),p=Math.ceil(i/20);l.start("MD5",u);var d=n.util.createBuffer();f.putBytes(r);for(var y=0;y0&&(c.queue(e,c.createAlert(e,{level:c.Alert.Level.warning,description:c.Alert.Description.no_renegotiation})),c.flush(e)),e.process()},c.parseHelloMessage=function(e,t,r){var i=null,o=e.entity===c.ConnectionEnd.client;if(r<38)e.error(e,{message:o?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.illegal_parameter}});else{var s=t.fragment,u=s.length();if(i={version:{major:s.getByte(),minor:s.getByte()},random:n.util.createBuffer(s.getBytes(32)),session_id:a(s,1),extensions:[]},o?(i.cipher_suite=s.getBytes(2),i.compression_method=s.getByte()):(i.cipher_suites=a(s,2),i.compression_methods=a(s,1)),(u=r-(u-s.length()))>0){for(var f=a(s,2);f.length()>0;)i.extensions.push({type:[f.getByte(),f.getByte()],data:a(f,2)});if(!o)for(var l=0;l0;){if(0!==p.getByte())break;e.session.extensions.server_name.serverNameList.push(a(p,2).getBytes())}}}if(e.session.version&&(i.version.major!==e.session.version.major||i.version.minor!==e.session.version.minor))return e.error(e,{message:"TLS version change is disallowed during renegotiation.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.protocol_version}});if(o)e.session.cipherSuite=c.getCipherSuite(i.cipher_suite);else for(var d=n.util.createBuffer(i.cipher_suites.bytes());d.length()>0&&(e.session.cipherSuite=c.getCipherSuite(d.getBytes(2)),null===e.session.cipherSuite););if(null===e.session.cipherSuite)return e.error(e,{message:"No cipher suites in common.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.handshake_failure},cipherSuite:n.util.bytesToHex(i.cipher_suite)});e.session.compressionMethod=o?i.compression_method:c.CompressionMethod.none}return i},c.createSecurityParameters=function(e,t){var r=e.entity===c.ConnectionEnd.client,n=t.random.bytes(),i=r?e.session.sp.client_random:n,o=r?n:c.createRandom().getBytes();e.session.sp={entity:e.entity,prf_algorithm:c.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:null,cipher_type:null,enc_key_length:null,block_length:null,fixed_iv_length:null,record_iv_length:null,mac_algorithm:null,mac_length:null,mac_key_length:null,compression_algorithm:e.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:i,server_random:o}},c.handleServerHello=function(e,t,r){var n=c.parseHelloMessage(e,t,r);if(!e.fail){if(!(n.version.minor<=e.version.minor))return e.error(e,{message:"Incompatible TLS version.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.protocol_version}});e.version.minor=n.version.minor,e.session.version=e.version;var i=n.session_id.bytes();i.length>0&&i===e.session.id?(e.expect=d,e.session.resuming=!0,e.session.sp.server_random=n.random.bytes()):(e.expect=f,e.session.resuming=!1,c.createSecurityParameters(e,n)),e.session.id=i,e.process()}},c.handleClientHello=function(e,t,r){var i=c.parseHelloMessage(e,t,r);if(!e.fail){var o=i.session_id.bytes(),s=null;if(e.sessionCache&&(null===(s=e.sessionCache.getSession(o))?o="":(s.version.major!==i.version.major||s.version.minor>i.version.minor)&&(s=null,o="")),0===o.length&&(o=n.random.getBytes(32)),e.session.id=o,e.session.clientHelloVersion=i.version,e.session.sp={},s)e.version=e.session.version=s.version,e.session.sp=s.sp;else{for(var a,u=1;u0;)i=a(u.certificate_list,3),o=n.asn1.fromDer(i),i=n.pki.certificateFromAsn1(o,!0),f.push(i)}catch(t){return e.error(e,{message:"Could not parse certificate list.",cause:t,send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.bad_certificate}})}var h=e.entity===c.ConnectionEnd.client;!h&&!0!==e.verifyClient||0!==f.length?0===f.length?e.expect=h?l:v:(h?e.session.serverCertificate=f[0]:e.session.clientCertificate=f[0],c.verifyCertificateChain(e,f)&&(e.expect=h?l:v)):e.error(e,{message:h?"No server certificate provided.":"No client certificate provided.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.illegal_parameter}}),e.process()},c.handleServerKeyExchange=function(e,t,r){if(r>0)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.unsupported_certificate}});e.expect=h,e.process()},c.handleClientKeyExchange=function(e,t,r){if(r<48)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.unsupported_certificate}});var i=t.fragment,o={enc_pre_master_secret:a(i,2).getBytes()},s=null;if(e.getPrivateKey)try{s=e.getPrivateKey(e,e.session.serverCertificate),s=n.pki.privateKeyFromPem(s)}catch(t){e.error(e,{message:"Could not get private key.",cause:t,send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.internal_error}})}if(null===s)return e.error(e,{message:"No private key set.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.internal_error}});try{var u=e.session.sp;u.pre_master_secret=s.decrypt(o.enc_pre_master_secret);var f=e.session.clientHelloVersion;if(f.major!==u.pre_master_secret.charCodeAt(0)||f.minor!==u.pre_master_secret.charCodeAt(1))throw new Error("TLS version rollback attack detected.")}catch(e){u.pre_master_secret=n.random.getBytes(48)}e.expect=w,null!==e.session.clientCertificate&&(e.expect=_),e.process()},c.handleCertificateRequest=function(e,t,r){if(r<3)return e.error(e,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.illegal_parameter}});var n=t.fragment,i={certificate_types:a(n,1),certificate_authorities:a(n,2)};e.session.certificateRequest=i,e.expect=p,e.process()},c.handleCertificateVerify=function(e,t,r){if(r<2)return e.error(e,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.illegal_parameter}});var i=t.fragment;i.read-=4;var o=i.bytes();i.read+=4;var s={signature:a(i,2).getBytes()},u=n.util.createBuffer();u.putBuffer(e.session.md5.digest()),u.putBuffer(e.session.sha1.digest()),u=u.getBytes();try{if(!e.session.clientCertificate.publicKey.verify(u,s.signature,"NONE"))throw new Error("CertificateVerify signature does not match.");e.session.md5.update(o),e.session.sha1.update(o)}catch(t){return e.error(e,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.handshake_failure}})}e.expect=w,e.process()},c.handleServerHelloDone=function(e,t,r){if(r>0)return e.error(e,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.record_overflow}});if(null===e.serverCertificate){var i={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.insufficient_security}},o=e.verify(e,i.alert.description,0,[]);if(!0!==o)return(o||0===o)&&("object"!=typeof o||n.util.isArray(o)?"number"==typeof o&&(i.alert.description=o):(o.message&&(i.message=o.message),o.alert&&(i.alert.description=o.alert))),e.error(e,i)}null!==e.session.certificateRequest&&(t=c.createRecord(e,{type:c.ContentType.handshake,data:c.createCertificate(e)}),c.queue(e,t)),t=c.createRecord(e,{type:c.ContentType.handshake,data:c.createClientKeyExchange(e)}),c.queue(e,t),e.expect=m;var s=function(e,t){null!==e.session.certificateRequest&&null!==e.session.clientCertificate&&c.queue(e,c.createRecord(e,{type:c.ContentType.handshake,data:c.createCertificateVerify(e,t)})),c.queue(e,c.createRecord(e,{type:c.ContentType.change_cipher_spec,data:c.createChangeCipherSpec()})),e.state.pending=c.createConnectionState(e),e.state.current.write=e.state.pending.write,c.queue(e,c.createRecord(e,{type:c.ContentType.handshake,data:c.createFinished(e)})),e.expect=d,c.flush(e),e.process()};if(null===e.session.certificateRequest||null===e.session.clientCertificate)return s(e,null);c.getClientSignature(e,s)},c.handleChangeCipherSpec=function(e,t){if(1!==t.fragment.getByte())return e.error(e,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.illegal_parameter}});var r=e.entity===c.ConnectionEnd.client;(e.session.resuming&&r||!e.session.resuming&&!r)&&(e.state.pending=c.createConnectionState(e)),e.state.current.read=e.state.pending.read,(!e.session.resuming&&r||e.session.resuming&&!r)&&(e.state.pending=null),e.expect=r?y:S,e.process()},c.handleFinished=function(e,t,r){var o=t.fragment;o.read-=4;var s=o.bytes();o.read+=4;var a=t.fragment.getBytes();(o=n.util.createBuffer()).putBuffer(e.session.md5.digest()),o.putBuffer(e.session.sha1.digest());var u=e.entity===c.ConnectionEnd.client,f=u?"server finished":"client finished",l=e.session.sp;if((o=i(l.master_secret,f,o.getBytes(),12)).getBytes()!==a)return e.error(e,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.decrypt_error}});e.session.md5.update(s),e.session.sha1.update(s),(e.session.resuming&&u||!e.session.resuming&&!u)&&(c.queue(e,c.createRecord(e,{type:c.ContentType.change_cipher_spec,data:c.createChangeCipherSpec()})),e.state.current.write=e.state.pending.write,e.state.pending=null,c.queue(e,c.createRecord(e,{type:c.ContentType.handshake,data:c.createFinished(e)}))),e.expect=u?g:k,e.handshaking=!1,++e.handshakes,e.peerCertificate=u?e.session.serverCertificate:e.session.clientCertificate,c.flush(e),e.isConnected=!0,e.connected(e),e.process()},c.handleAlert=function(e,t){var r,n=t.fragment,i={level:n.getByte(),description:n.getByte()};switch(i.description){case c.Alert.Description.close_notify:r="Connection closed.";break;case c.Alert.Description.unexpected_message:r="Unexpected message.";break;case c.Alert.Description.bad_record_mac:r="Bad record MAC.";break;case c.Alert.Description.decryption_failed:r="Decryption failed.";break;case c.Alert.Description.record_overflow:r="Record overflow.";break;case c.Alert.Description.decompression_failure:r="Decompression failed.";break;case c.Alert.Description.handshake_failure:r="Handshake failure.";break;case c.Alert.Description.bad_certificate:r="Bad certificate.";break;case c.Alert.Description.unsupported_certificate:r="Unsupported certificate.";break;case c.Alert.Description.certificate_revoked:r="Certificate revoked.";break;case c.Alert.Description.certificate_expired:r="Certificate expired.";break;case c.Alert.Description.certificate_unknown:r="Certificate unknown.";break;case c.Alert.Description.illegal_parameter:r="Illegal parameter.";break;case c.Alert.Description.unknown_ca:r="Unknown certificate authority.";break;case c.Alert.Description.access_denied:r="Access denied.";break;case c.Alert.Description.decode_error:r="Decode error.";break;case c.Alert.Description.decrypt_error:r="Decrypt error.";break;case c.Alert.Description.export_restriction:r="Export restriction.";break;case c.Alert.Description.protocol_version:r="Unsupported protocol version.";break;case c.Alert.Description.insufficient_security:r="Insufficient security.";break;case c.Alert.Description.internal_error:r="Internal error.";break;case c.Alert.Description.user_canceled:r="User canceled.";break;case c.Alert.Description.no_renegotiation:r="Renegotiation not supported.";break;default:r="Unknown error."}if(i.description===c.Alert.Description.close_notify)return e.close();e.error(e,{message:r,send:!1,origin:e.entity===c.ConnectionEnd.client?"server":"client",alert:i}),e.process()},c.handleHandshake=function(e,t){var r=t.fragment,i=r.getByte(),o=r.getInt24();if(o>r.length())return e.fragmented=t,t.fragment=n.util.createBuffer(),r.read-=4,e.process();e.fragmented=null,r.read-=4;var s=r.bytes(o+4);r.read+=4,i in K[e.entity][e.expect]?(e.entity!==c.ConnectionEnd.server||e.open||e.fail||(e.handshaking=!0,e.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:n.md.md5.create(),sha1:n.md.sha1.create()}),i!==c.HandshakeType.hello_request&&i!==c.HandshakeType.certificate_verify&&i!==c.HandshakeType.finished&&(e.session.md5.update(s),e.session.sha1.update(s)),K[e.entity][e.expect][i](e,t,o)):c.handleUnexpected(e,t)},c.handleApplicationData=function(e,t){e.data.putBuffer(t.fragment),e.dataReady(e),e.process()},c.handleHeartbeat=function(e,t){var r=t.fragment,i=r.getByte(),o=r.getInt16(),s=r.getBytes(o);if(i===c.HeartbeatMessageType.heartbeat_request){if(e.handshaking||o>s.length)return e.process();c.queue(e,c.createRecord(e,{type:c.ContentType.heartbeat,data:c.createHeartbeat(c.HeartbeatMessageType.heartbeat_response,s)})),c.flush(e)}else if(i===c.HeartbeatMessageType.heartbeat_response){if(s!==e.expectedHeartbeatPayload)return e.process();e.heartbeatReceived&&e.heartbeatReceived(e,n.util.createBuffer(s))}e.process()};var f=1,l=2,h=3,p=4,d=5,y=6,g=7,m=8,b=1,v=2,_=3,w=4,S=5,k=6,E=c.handleUnexpected,A=c.handleChangeCipherSpec,x=c.handleAlert,I=c.handleHandshake,T=c.handleApplicationData,B=c.handleHeartbeat,C=[];C[c.ConnectionEnd.client]=[[E,x,I,E,B],[E,x,I,E,B],[E,x,I,E,B],[E,x,I,E,B],[E,x,I,E,B],[A,x,E,E,B],[E,x,I,E,B],[E,x,I,T,B],[E,x,I,E,B]],C[c.ConnectionEnd.server]=[[E,x,I,E,B],[E,x,I,E,B],[E,x,I,E,B],[E,x,I,E,B],[A,x,E,E,B],[E,x,I,E,B],[E,x,I,T,B],[E,x,I,E,B]];var P=c.handleHelloRequest,O=c.handleServerHello,R=c.handleCertificate,N=c.handleServerKeyExchange,L=c.handleCertificateRequest,j=c.handleServerHelloDone,M=c.handleFinished,K=[];K[c.ConnectionEnd.client]=[[E,E,O,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[P,E,E,E,E,E,E,E,E,E,E,R,N,L,j,E,E,E,E,E,E],[P,E,E,E,E,E,E,E,E,E,E,E,N,L,j,E,E,E,E,E,E],[P,E,E,E,E,E,E,E,E,E,E,E,E,L,j,E,E,E,E,E,E],[P,E,E,E,E,E,E,E,E,E,E,E,E,E,j,E,E,E,E,E,E],[P,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[P,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,M],[P,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[P,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E]];var D=c.handleClientHello,U=c.handleClientKeyExchange,F=c.handleCertificateVerify;K[c.ConnectionEnd.server]=[[E,D,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,R,E,E,E,E,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,U,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,F,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,M],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E],[E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E,E]],c.generateKeys=function(e,t){var r=i,n=t.client_random+t.server_random;e.session.resuming||(t.master_secret=r(t.pre_master_secret,"master secret",n,48).bytes(),t.pre_master_secret=null),n=t.server_random+t.client_random;var o=2*t.mac_key_length+2*t.enc_key_length,s=e.version.major===c.Versions.TLS_1_0.major&&e.version.minor===c.Versions.TLS_1_0.minor;s&&(o+=2*t.fixed_iv_length);var a=r(t.master_secret,"key expansion",n,o),u={client_write_MAC_key:a.getBytes(t.mac_key_length),server_write_MAC_key:a.getBytes(t.mac_key_length),client_write_key:a.getBytes(t.enc_key_length),server_write_key:a.getBytes(t.enc_key_length)};return s&&(u.client_write_IV=a.getBytes(t.fixed_iv_length),u.server_write_IV=a.getBytes(t.fixed_iv_length)),u},c.createConnectionState=function(e){var t=e.entity===c.ConnectionEnd.client,r=function(){var e={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(e){return!0},compressionState:null,compressFunction:function(e){return!0},updateSequenceNumber:function(){4294967295===e.sequenceNumber[1]?(e.sequenceNumber[1]=0,++e.sequenceNumber[0]):++e.sequenceNumber[1]}};return e},n={read:r(),write:r()};if(n.read.update=function(e,t){return n.read.cipherFunction(t,n.read)?n.read.compressFunction(e,t,n.read)||e.error(e,{message:"Could not decompress record.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.decompression_failure}}):e.error(e,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.bad_record_mac}}),!e.fail},n.write.update=function(e,t){return n.write.compressFunction(e,t,n.write)?n.write.cipherFunction(t,n.write)||e.error(e,{message:"Could not encrypt record.",send:!1,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.internal_error}}):e.error(e,{message:"Could not compress record.",send:!1,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.internal_error}}),!e.fail},e.session){var i=e.session.sp;switch(e.session.cipherSuite.initSecurityParameters(i),i.keys=c.generateKeys(e,i),n.read.macKey=t?i.keys.server_write_MAC_key:i.keys.client_write_MAC_key,n.write.macKey=t?i.keys.client_write_MAC_key:i.keys.server_write_MAC_key,e.session.cipherSuite.initConnectionState(n,e,i),i.compression_algorithm){case c.CompressionMethod.none:break;case c.CompressionMethod.deflate:n.read.compressFunction=s,n.write.compressFunction=o;break;default:throw new Error("Unsupported compression algorithm.")}}return n},c.createRandom=function(){var e=new Date,t=+e+6e4*e.getTimezoneOffset(),r=n.util.createBuffer();return r.putInt32(t),r.putBytes(n.random.getBytes(28)),r},c.createRecord=function(e,t){return t.data?{type:t.type,version:{major:e.version.major,minor:e.version.minor},length:t.data.length(),fragment:t.data}:null},c.createAlert=function(e,t){var r=n.util.createBuffer();return r.putByte(t.level),r.putByte(t.description),c.createRecord(e,{type:c.ContentType.alert,data:r})},c.createClientHello=function(e){e.session.clientHelloVersion={major:e.version.major,minor:e.version.minor};for(var t=n.util.createBuffer(),r=0;r0&&(d+=2);var y=e.session.id,g=y.length+1+2+4+28+2+o+1+a+d,m=n.util.createBuffer();return m.putByte(c.HandshakeType.client_hello),m.putInt24(g),m.putByte(e.version.major),m.putByte(e.version.minor),m.putBytes(e.session.sp.client_random),u(m,1,n.util.createBuffer(y)),u(m,2,t),u(m,1,s),d>0&&u(m,2,f),m},c.createServerHello=function(e){var t=e.session.id,r=t.length+1+2+4+28+2+1,i=n.util.createBuffer();return i.putByte(c.HandshakeType.server_hello),i.putInt24(r),i.putByte(e.version.major),i.putByte(e.version.minor),i.putBytes(e.session.sp.server_random),u(i,1,n.util.createBuffer(t)),i.putByte(e.session.cipherSuite.id[0]),i.putByte(e.session.cipherSuite.id[1]),i.putByte(e.session.compressionMethod),i},c.createCertificate=function(e){var t,r=e.entity===c.ConnectionEnd.client,i=null;e.getCertificate&&(t=r?e.session.certificateRequest:e.session.extensions.server_name.serverNameList,i=e.getCertificate(e,t));var o=n.util.createBuffer();if(null!==i)try{n.util.isArray(i)||(i=[i]);for(var s=null,a=0;ac.MaxFragment;)i.push(c.createRecord(e,{type:t.type,data:n.util.createBuffer(o.slice(0,c.MaxFragment))})),o=o.slice(c.MaxFragment);o.length>0&&i.push(c.createRecord(e,{type:t.type,data:n.util.createBuffer(o)}))}for(var s=0;s0&&(i=r.order[0]),null!==i&&i in r.cache)for(var o in t=r.cache[i],delete r.cache[i],r.order)if(r.order[o]===i){r.order.splice(o,1);break}return t},r.setSession=function(e,t){if(r.order.length===r.capacity){var i=r.order.shift();delete r.cache[i]}i=n.util.bytesToHex(e);r.order.push(i),r.cache[i]=t}}return r},c.createConnection=function(e){var t;t=e.caStore?n.util.isArray(e.caStore)?n.pki.createCaStore(e.caStore):e.caStore:n.pki.createCaStore();var r=e.cipherSuites||null;if(null===r)for(var i in r=[],c.CipherSuites)r.push(c.CipherSuites[i]);var o=e.server?c.ConnectionEnd.server:c.ConnectionEnd.client,s=e.sessionCache?c.createSessionCache(e.sessionCache):null,a={version:{major:c.Version.major,minor:c.Version.minor},entity:o,sessionId:e.sessionId,caStore:t,sessionCache:s,cipherSuites:r,connected:e.connected,virtualHost:e.virtualHost||null,verifyClient:e.verifyClient||!1,verify:e.verify||function(e,t,r,n){return t},getCertificate:e.getCertificate||null,getPrivateKey:e.getPrivateKey||null,getSignature:e.getSignature||null,input:n.util.createBuffer(),tlsData:n.util.createBuffer(),data:n.util.createBuffer(),tlsDataReady:e.tlsDataReady,dataReady:e.dataReady,heartbeatReceived:e.heartbeatReceived,closed:e.closed,error:function(t,r){r.origin=r.origin||(t.entity===c.ConnectionEnd.client?"client":"server"),r.send&&(c.queue(t,c.createAlert(t,r.alert)),c.flush(t));var n=!1!==r.fatal;n&&(t.fail=!0),e.error(t,r),n&&t.close(!1)},deflate:e.deflate||null,inflate:e.inflate||null,reset:function(e){a.version={major:c.Version.major,minor:c.Version.minor},a.record=null,a.session=null,a.peerCertificate=null,a.state={pending:null,current:null},a.expect=(a.entity,c.ConnectionEnd.client,0),a.fragmented=null,a.records=[],a.open=!1,a.handshakes=0,a.handshaking=!1,a.isConnected=!1,a.fail=!(e||void 0===e),a.input.clear(),a.tlsData.clear(),a.data.clear(),a.state.current=c.createConnectionState(a)}};a.reset();return a.handshake=function(e){if(a.entity!==c.ConnectionEnd.client)a.error(a,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(a.handshaking)a.error(a,{message:"Handshake already in progress.",fatal:!1});else{a.fail&&!a.open&&0===a.handshakes&&(a.fail=!1),a.handshaking=!0;var t=null;(e=e||"").length>0&&(a.sessionCache&&(t=a.sessionCache.getSession(e)),null===t&&(e="")),0===e.length&&a.sessionCache&&null!==(t=a.sessionCache.getSession())&&(e=t.id),a.session={id:e,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:n.md.md5.create(),sha1:n.md.sha1.create()},t&&(a.version=t.version,a.session.sp=t.sp),a.session.sp.client_random=c.createRandom().getBytes(),a.open=!0,c.queue(a,c.createRecord(a,{type:c.ContentType.handshake,data:c.createClientHello(a)})),c.flush(a)}},a.process=function(e){var t=0;return e&&a.input.putBytes(e),a.fail||(null!==a.record&&a.record.ready&&a.record.fragment.isEmpty()&&(a.record=null),null===a.record&&(t=function(e){var t=0,r=e.input,i=r.length();if(i<5)t=5-i;else{e.record={type:r.getByte(),version:{major:r.getByte(),minor:r.getByte()},length:r.getInt16(),fragment:n.util.createBuffer(),ready:!1};var o=e.record.version.major===e.version.major;o&&e.session&&e.session.version&&(o=e.record.version.minor===e.version.minor),o||e.error(e,{message:"Incompatible TLS version.",send:!0,alert:{level:c.Alert.Level.fatal,description:c.Alert.Description.protocol_version}})}return t}(a)),a.fail||null===a.record||a.record.ready||(t=function(e){var t=0,r=e.input,n=r.length();return n=0;u--)B>>=8,B+=A.at(u)+T.at(u),T.setAt(u,255&B);I.putBuffer(T)}_=I,l.putBuffer(k)}return l.truncate(l.length()-o),l},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={},u=[];if(!o.validate(t,c,a,u))throw(i=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=u,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,l,p=a.kdfSalt,d=n.util.createBuffer(a.kdfIterationCount);switch(d=d.getInt(d.length()<<3),s.oids[e]){case"aes128-CBC":f=16,l=n.aes.createDecryptionCipher;break;case"aes192-CBC":f=24,l=n.aes.createDecryptionCipher;break;case"aes256-CBC":f=32,l=n.aes.createDecryptionCipher;break;case"des-EDE3-CBC":f=24,l=n.des.createDecryptionCipher;break;case"desCBC":f=8,l=n.des.createDecryptionCipher}var y=h(a.prfOid),g=n.pkcs5.pbkdf2(r,p,d,f,y),m=a.encIv,b=l(g);return b.start(m),b},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 u,c,l,p=n.util.createBuffer(i.salt),d=n.util.createBuffer(i.iterations);switch(d=d.getInt(d.length()<<3),e){case s.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:u=24,c=8,l=n.des.startDecrypting;break;case s.oids["pbewithSHAAnd40BitRC2-CBC"]:u=5,c=8,l=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 g=h(i.prfOid),m=s.pbe.generatePkcs12Key(r,p,1,d,u,g);return g.start(),l(m,s.pbe.generatePkcs12Key(r,p,2,d,c,g))},s.pbe.opensslDeriveBytes=function(e,t,r,i){if(void 0===i||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=[l(i,e+t)],s=16,a=1;s>>0,a>>>0];for(var c=i.fullMessageLength.length-1;c>=0;--c)i.fullMessageLength[c]+=a[1],a[1]=a[0]+(i.fullMessageLength[c]/4294967296>>>0),i.fullMessageLength[c]=i.fullMessageLength[c]>>>0,a[0]=a[1]/4294967296>>>0;return t.putBytes(o),u(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,c=i.fullMessageLength[i.fullMessageLength.length-1]+i.messageLengthSize&i.blockLength-1;s.putBytes(o.substr(0,i.blockLength-c));for(var f=8*i.fullMessageLength[0],l=0;l>>0,s.putInt32(f>>>0),f=a>>>0;s.putInt32(f);var h={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};u(h,r,s);var p=n.util.createBuffer();return p.putInt32(h.h0),p.putInt32(h.h1),p.putInt32(h.h2),p.putInt32(h.h3),p.putInt32(h.h4),p.putInt32(h.h5),p.putInt32(h.h6),p.putInt32(h.h7),p},i};var o=null,s=!1,a=null;function u(e,t,r){for(var n,i,o,s,u,c,f,l,h,p,d,y,g,m=r.length();m>=64;){for(u=0;u<16;++u)t[u]=r.getInt32();for(;u<64;++u)n=((n=t[u-2])>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,i=((i=t[u-15])>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,t[u]=n+t[u-7]+i+t[u-16]|0;for(c=e.h0,f=e.h1,l=e.h2,h=e.h3,p=e.h4,d=e.h5,y=e.h6,g=e.h7,u=0;u<64;++u)o=(c>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10),s=c&f|l&(c^f),n=g+((p>>>6|p<<26)^(p>>>11|p<<21)^(p>>>25|p<<7))+(y^p&(d^y))+a[u]+t[u],g=y,y=d,d=p,p=h+n>>>0,h=l,l=f,f=c,c=n+(i=o+s)>>>0;e.h0=e.h0+c|0,e.h1=e.h1+f|0,e.h2=e.h2+l|0,e.h3=e.h3+h|0,e.h4=e.h4+p|0,e.h5=e.h5+d|0,e.h6=e.h6+y|0,e.h7=e.h7+g|0,m-=64}}},function(e,t,r){(function(t){var n=r(13);r(19);var i=null;!n.util.isNodejs||n.options.usePureJavaScript||t.versions["node-webkit"]||(i=r(447)),(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(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()})}function u(){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 f(e){var t=null;if("undefined"!=typeof window){var r=window.crypto||window.msCrypto;r&&r.getRandomValues&&(t=function(e){return r.getRandomValues(e)})}var i=n.util.createBuffer();if(t)for(;i.length()>16)))<<16,l=4294967295&(c=(2147483647&(c+=u>>15))+(c>>31));for(a=0;a<3;++a)f=l>>>(a<<3),f^=Math.floor(256*Math.random()),i.putByte(String.fromCharCode(255&f))}return i.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,u=t.plugin.formatSeed,c=n.util.createBuffer();t.key=null,function f(l){if(l)return r(l);if(c.length()>=e)return r(null,c.getBytes(e));if(t.generated>1048575&&(t.key=null),null===t.key)return n.util.nextTick(function(){a(f)});var h=i(t.key,t.seed);t.generated+=h.length,c.putBytes(h),t.key=s(i(t.key,o(t.seed))),t.seed=u(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 a=n.util.createBuffer();a.length()1048575&&(t.key=null),null===t.key&&u();var c=r(t.key,t.seed);t.generated+=c.length,a.putBytes(c),t.key=o(r(t.key,i(t.seed))),t.seed=s(r(t.key,t.seed))}return a.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,f(e))}catch(e){t(e)}},t.seedFileSync=f),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(6))},function(e,t,r){var n=r(13);r(19);var i=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],o=[1,2,3,5],s=function(e,t){return e<>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,u=Math.ceil(a/8),c=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-u,i[o.at(128-u)&c]),r=127-u;r>=0;r--)o.setAt(r,i[o.at(r+1)^o.at(r+u)]);return o};var u=function(e,t,r){var i,u,c,f,l=!1,h=null,p=null,d=null,y=[];for(e=n.rc2.expandKey(e,t),c=0;c<64;c++)y.push(e.getInt16Le());r?(i=function(e){for(c=0;c<4;c++)e[c]+=y[f]+(e[(c+3)%4]&e[(c+2)%4])+(~e[(c+3)%4]&e[(c+1)%4]),e[c]=s(e[c],o[c]),f++},u=function(e){for(c=0;c<4;c++)e[c]+=y[63&e[(c+3)%4]]}):(i=function(e){for(c=3;c>=0;c--)e[c]=a(e[c],o[c]),e[c]-=y[f]+(e[(c+3)%4]&e[(c+2)%4])+(~e[(c+3)%4]&e[(c+1)%4]),f--},u=function(e){for(c=3;c>=0;c--)e[c]-=y[63&e[(c+3)%4]]});var g=function(e){var t=[];for(c=0;c<4;c++){var n=h.getInt16Le();null!==d&&(r?n^=d.getInt16Le():d.putInt16Le(n)),t.push(65535&n)}f=r?0:63;for(var i=0;i=8;)g([[5,i],[1,u],[6,i],[1,u],[5,i]])},finish:function(e){var t=!0;if(r)if(e)t=e(8,h,!r);else{var n=8===h.length()?8:8-h.length();h.fillWithByte(n,n)}if(t&&(l=!0,m.update()),!r&&(t=0===h.length()))if(e)t=e(8,p,!r);else{var i=p.length(),o=p.at(i-1);o>i?t=!1:p.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 u(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 u(e,t,!1)}},function(e,t,r){var n=r(13);r(19),r(67),r(134);var i=e.exports=n.pkcs1=n.pkcs1||{};function o(e,t,r){r||(r=n.md.sha1.create());for(var i="",o=Math.ceil(t/r.digestLength),s=0;s>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,u;"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&&(u=r.mgf1.md)),a?a.start():a=n.md.sha1.create(),u||(u=a);var c=Math.ceil(e.n.bitLength()/8),f=c-2*a.digestLength-2;if(t.length>f)throw(y=new Error("RSAES-OAEP input message length is too long.")).length=t.length,y.maxLength=f,y;i||(i=""),a.update(i,"raw");for(var l=a.digest(),h="",p=f-t.length,d=0;dt&&(e=f(t,r)),e.isProbablePrime(s))return c(null,e);e.dAddOffset(i[o++%8],0)}while(a<0||+new Date-le&&(s=f(e,t));var p=s.toString(16);i.target.postMessage({hex:p,workLoad:c}),s.dAddOffset(l,0)}}}p()}function f(e,t){var n=new r(e,t),i=e-1;return n.testBit(i)||n.bitwiseTo(r.ONE.shiftLeft(i),s,n),n.dAddOffset(31-n.mod(o).byteValue(),0),n}}()},function(e,t,r){var n=r(13);r(76),r(133),r(100),r(454),r(446),r(67),r(183),r(134),r(19),r(261);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"}]},u={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"}]}]},c={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"}]},l={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 h(e,t,r,n){for(var i=[],o=0;o=0&&i.push(a):i.push(a))}return i}function p(e){if(e.composed||e.constructed){for(var t=n.util.createBuffer(),r=0;r0&&(u=i.create(i.Class.UNIVERSAL,i.Type.SET,!0,l));var h=[],p=[];null!==t&&(p=n.util.isArray(t)?t:[t]);for(var d=[],y=0;y0){var v=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,d),_=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())])]);h.push(_)}var w=null;if(null!==e){var S=o.wrapRsaPrivateKey(o.privateKeyToAsn1(e));w=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]),u]):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)]),u]);var k=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[w]),E=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(k).getBytes())])]);h.push(E)}var A,x=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,h);if(a.useMac){var I=n.md.sha1.create(),T=new n.util.ByteBuffer(n.random.getBytes(a.saltSize)),B=a.count,C=(e=s.generateKey(r,T,3,B,20),n.hmac.create());C.start(I,e),C.update(i.toDer(x).getBytes());var P=C.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,P.getBytes())]),i.create(i.Class.UNIVERSAL,i.Type.OCTETSTRING,!1,T.getBytes()),i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,i.integerToDer(B).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(x).getBytes())])]),A])},s.generateKey=n.pbe.generatePkcs12Key},function(e,t,r){var n=r(13);r(76),r(19);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 u={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:[u]}]},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(13);r(19),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=p.fullMessageLength.length-1;a>=0;--a)p.fullMessageLength[a]+=s[1],s[1]=s[0]+(p.fullMessageLength[a]/4294967296>>>0),p.fullMessageLength[a]=p.fullMessageLength[a]>>>0,s[0]=s[1]/4294967296>>>0;return i.putBytes(e),l(r,o,i),(i.read>2048||0===i.length())&&i.compact(),p},p.digest=function(){var t=n.util.createBuffer();t.putBytes(i.bytes());var a,u=p.fullMessageLength[p.fullMessageLength.length-1]+p.messageLengthSize&p.blockLength-1;t.putBytes(s.substr(0,p.blockLength-u));for(var c=8*p.fullMessageLength[0],f=0;f>>0,t.putInt32(c>>>0),c=a>>>0;t.putInt32(c);var h=new Array(r.length);for(f=0;f=128;){for(C=0;C<16;++C)t[C][0]=r.getInt32()>>>0,t[C][1]=r.getInt32()>>>0;for(;C<80;++C)n=(((P=(R=t[C-2])[0])>>>19|(O=R[1])<<13)^(O>>>29|P<<3)^P>>>6)>>>0,i=((P<<13|O>>>19)^(O<<3|P>>>29)^(P<<26|O>>>6))>>>0,o=(((P=(L=t[C-15])[0])>>>1|(O=L[1])<<31)^(P>>>8|O<<24)^P>>>7)>>>0,s=((P<<31|O>>>1)^(P<<24|O>>>8)^(P<<25|O>>>7))>>>0,N=t[C-7],j=t[C-16],O=i+N[1]+s+j[1],t[C][0]=n+N[0]+o+j[0]+(O/4294967296>>>0)>>>0,t[C][1]=O>>>0;for(d=e[0][0],y=e[0][1],g=e[1][0],m=e[1][1],b=e[2][0],v=e[2][1],_=e[3][0],w=e[3][1],S=e[4][0],k=e[4][1],E=e[5][0],A=e[5][1],x=e[6][0],I=e[6][1],T=e[7][0],B=e[7][1],C=0;C<80;++C)f=((S>>>14|k<<18)^(S>>>18|k<<14)^(k>>>9|S<<23))>>>0,l=(x^S&(E^x))>>>0,a=((d>>>28|y<<4)^(y>>>2|d<<30)^(y>>>7|d<<25))>>>0,c=((d<<4|y>>>28)^(y<<30|d>>>2)^(y<<25|d>>>7))>>>0,h=(d&g|b&(d^g))>>>0,p=(y&m|v&(y^m))>>>0,O=B+(((S<<18|k>>>14)^(S<<14|k>>>18)^(k<<23|S>>>9))>>>0)+((I^k&(A^I))>>>0)+u[C][1]+t[C][1],n=T+f+l+u[C][0]+t[C][0]+(O/4294967296>>>0)>>>0,i=O>>>0,o=a+h+((O=c+p)/4294967296>>>0)>>>0,s=O>>>0,T=x,B=I,x=E,I=A,E=S,A=k,S=_+n+((O=w+i)/4294967296>>>0)>>>0,k=O>>>0,_=b,w=v,b=g,v=m,g=d,m=y,d=n+o+((O=i+s)/4294967296>>>0)>>>0,y=O>>>0;O=e[0][1]+y,e[0][0]=e[0][0]+d+(O/4294967296>>>0)>>>0,e[0][1]=O>>>0,O=e[1][1]+m,e[1][0]=e[1][0]+g+(O/4294967296>>>0)>>>0,e[1][1]=O>>>0,O=e[2][1]+v,e[2][0]=e[2][0]+b+(O/4294967296>>>0)>>>0,e[2][1]=O>>>0,O=e[3][1]+w,e[3][0]=e[3][0]+_+(O/4294967296>>>0)>>>0,e[3][1]=O>>>0,O=e[4][1]+k,e[4][0]=e[4][0]+S+(O/4294967296>>>0)>>>0,e[4][1]=O>>>0,O=e[5][1]+A,e[5][0]=e[5][0]+E+(O/4294967296>>>0)>>>0,e[5][1]=O>>>0,O=e[6][1]+I,e[6][0]=e[6][0]+x+(O/4294967296>>>0)>>>0,e[6][1]=O>>>0,O=e[7][1]+B,e[7][0]=e[7][0]+T+(O/4294967296>>>0)>>>0,e[7][1]=O>>>0,M-=128}}},function(e,t,r){var n=r(13);r(19),e.exports=n.log=n.log||{},n.log.levels=["none","error","warning","info","debug","verbose","max"];var i={},o=[],s=null;n.log.LEVEL_LOCKED=2,n.log.NO_LEVEL_CHECK=4,n.log.INTERPOLATE=8;for(var a=0;a{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){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(255),i=r(256)();function o(e){return Promise.all([i.subtle.exportKey("jwk",e.privateKey),i.subtle.exportKey("jwk",e.publicKey)])}t.utils=r(921),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(o).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"]);n(Promise.all([r,function(e){return i.subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}(e)]).then(e=>o({privateKey:e[0],publicKey:e[1]})).then(e=>({privateKey:e[0],publicKey:e[1]})),t)},t.getRandomValues=function(t){return e.from(i.getRandomValues(t))},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)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(4),i=r(135).Reporter,o=r(0).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 e instanceof a||(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.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.prototype.join=function(e,t){return e||(e=new o(this.length)),t||(t=0),0===this.length?e:(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";const n=t;n._reverse=function(e){const t={};return Object.keys(e).forEach(function(r){(0|r)==r&&(r|=0);const n=e[r];t[n]=r}),t},n.der=r(926)},function(e,t,r){"use strict";const n=r(4),i=r(15),o=i.base,s=i.bignum,a=i.constants.der;function u(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new c,this.tree._init(e.body)}function c(e){o.Node.call(this,"der",e)}function f(e,t){let r=e.readUInt8(t);if(e.isError(r))return r;const n=a.tagClass[r>>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 l(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;t=31?n.error("Multi-octet tag encoding unsupported"):(t||(i|=32),i|=a.tagClassByName[r||"universal"]<<6)}e.exports=u,u.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},n(c,s.Node),c.prototype._encodeComposite=function(e,t,r,n){const o=l(e,t,r,this.reporter);if(n.length<128){const e=new i(2);return e[0]=o,e[1]=n.length,this._createEncoderBuffer([e,n])}let s=1;for(let e=n.length;e>=256;e>>=8)s++;const a=new i(2+s);a[0]=o,a[1]=128|s;for(let e=1+s,t=n.length;t>0;e--,t>>=8)a[e]=255&t;return this._createEncoderBuffer([a,n])},c.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){const t=new i(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=new i(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=[f(n.getUTCFullYear()),f(n.getUTCMonth()+1),f(n.getUTCDate()),f(n.getUTCHours()),f(n.getUTCMinutes()),f(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[f(n.getUTCFullYear()%100),f(n.getUTCMonth()+1),f(n.getUTCDate()),f(n.getUTCHours()),f(n.getUTCMinutes()),f(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=new i(t)}if(i.isBuffer(e)){let t=e.length;0===e.length&&t++;const r=new i(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(new i(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{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){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";var n=r(2).Buffer,i=r(185),o=r(470);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: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 u=0;a>=0&&0===n[a];a--,++u);if(a>=0&&(u+=1),i=i.dblp(u),a<0)break;var c=n[a];i=c>0?i.mixedAdd(r[c-1>>1]):i.mixedAdd(r[-c-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<{n(i.subtle.sign({name:"HMAC"},t,r).then(t=>e.from(t)),o)};t.create=function(e,t,r){const u=s[e];n(i.subtle.importKey("raw",t,{name:"HMAC",hash:{name:u}},!1,["sign"]).then(t=>({digest(e,r){a(t,e,r)},length:o[e]})),r)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(12),i=r(955);function o(e,t,r,i){if("function"==typeof r&&(i=r,r=void 0),!i)throw new Error("Missing callback");o.digest(e,t,r,(e,o)=>{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){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(264),i=r(265)();function o(e){return Promise.all([i.subtle.exportKey("jwk",e.privateKey),i.subtle.exportKey("jwk",e.publicKey)])}t.utils=r(958),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(o).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"]);n(Promise.all([r,function(e){return i.subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}(e)]).then(e=>o({privateKey:e[0],publicKey:e[1]})).then(e=>({privateKey:e[0],publicKey:e[1]})),t)},t.getRandomValues=function(t){return e.from(i.getRandomValues(t))},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)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(15).bignum;t.toBase64=function(t,r){return t.toArrayLike(e,"be",r).toString("base64").replace(/(=*)$/,"").replace(/\+/g,"-").replace(/\//g,"_")},t.toBn=function(t){return new n(e.from(t,"base64"))}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(475);e.exports=function(e){if(!e||"number"!=typeof e)throw new Error("first argument must be a Number bigger than 0");return n.getRandomValues(new Uint8Array(e))}},function(e,t,r){"use strict";const n=r(965);e.exports={ensureMultiaddr:function(e){return n.isMultiaddr(e)?e:n(e)}}},function(e,t,r){"use strict";var n=r(480).BigInteger,i=r(481),o=r(482),s=r(483),a=r(139).sprintf,u=r(267);function c(e){this.valid=!1,this.address=e,this.groups=u.GROUPS,this.v4=!0,this.subnet="/32",this.subnetMask=32;var t=u.RE_SUBNET_STRING.exec(e);if(t){if(this.parsedSubnet=t[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet="/"+this.subnetMask,this.subnetMask<0||this.subnetMask>u.BITS)return this.valid=!1,void(this.error="Invalid subnet mask.");e=e.replace(u.RE_SUBNET_STRING,"")}this.addressMinusSuffix=e,this.parsedAddress=this.parse(e)}c.prototype.parse=function(e){var t=e.split(".");return e.match(u.RE_ADDRESS)?this.valid=!0:this.error="Invalid IPv4 address.",t},c.prototype.isValid=function(){return this.valid},c.prototype.correctForm=function(){return this.parsedAddress.map(function(e){return parseInt(e,10)}).join(".")},c.prototype.isCorrect=i.isCorrect(u.BITS),c.fromHex=function(e){var t,r=o(e.replace(/:/g,""),8,"0"),n=[];for(t=0;t<8;t+=2){var i=r.slice(t,t+2);n.push(parseInt(i,16))}return new c(n.join("."))},c.fromInteger=function(e){return c.fromHex(e.toString(16))},c.prototype.toHex=function(){return this.parsedAddress.map(function(e){return a("%02x",parseInt(e,10))}).join(":")},c.prototype.toArray=function(){return this.parsedAddress.map(function(e){return parseInt(e,10)})},c.prototype.toGroup6=function(){var e,t=[];for(e=0;e>15;--o>=0;){var u=32767&this[e],c=this[e++]>>15,f=a*u+c*s;i=((u=s*u+((32767&f)<<15)+r[n]+(1073741823&i))>>>30)+(f>>>15)+a*c+(i>>>30),r[n++]=1073741823&u}return i},t=30):i&&"Netscape"!=navigator.appName?(r.prototype.am=function(e,t,r,n,i,o){for(;--o>=0;){var s=t*this[e++]+r[n]+i;i=Math.floor(s/67108864),r[n++]=67108863&s}return i},t=26):(r.prototype.am=function(e,t,r,n,i,o){for(var s=16383&t,a=t>>14;--o>=0;){var u=16383&this[e],c=this[e++]>>14,f=a*u+c*s;i=((u=s*u+((16383&f)<<14)+r[n]+i)>>28)+(f>>14)+a*c,r[n++]=268435455&u}return i},t=28),r.prototype.DB=t,r.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 p(e){this.m=e}function d(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 _(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function w(){}function S(e){return e}function k(e){this.r2=n(),this.q3=n(),r.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}p.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},p.prototype.revert=function(e){return e},p.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},p.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},p.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},d.prototype.convert=function(e){var t=n();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(r.ZERO)>0&&this.m.subTo(t,t),t},d.prototype.revert=function(e){var t=n();return e.copyTo(t),this.reduce(t),t},d.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(e[r=t+this.m.t]+=this.m.am(0,n,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},d.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},d.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},r.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s},r.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0},r.prototype.fromString=function(e,t){var n;if(16==t)n=4;else if(8==t)n=3;else if(256==t)n=8;else if(2==t)n=1;else if(32==t)n=5;else{if(4!=t)return void this.fromRadix(e,t);n=2}this.t=0,this.s=0;for(var i=e.length,o=!1,s=0;--i>=0;){var a=8==n?255&e[i]:f(e,i);a<0?"-"==e.charAt(i)&&(o=!0):(o=!1,0==s?this[this.t++]=a:s+n>this.DB?(this[this.t-1]|=(a&(1<>this.DB-s):this[this.t-1]|=a<=this.DB&&(s-=this.DB))}8==n&&0!=(128&e[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==e;)--this.t},r.prototype.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s},r.prototype.drShiftTo=function(e,t){for(var r=e;r=0;--r)t[r+s+1]=this[r]>>i|a,a=(this[r]&o)<=0;--r)t[r]=0;t[s]=a,t.t=this.t+s+1,t.s=this.s,t.clamp()},r.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[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[r++]=this.DV+n:n>0&&(t[r++]=n),t.t=r,t.clamp()},r.prototype.multiplyTo=function(e,t){var n=this.abs(),i=e.abs(),o=n.t;for(t.t=o+i.t;--o>=0;)t[o]=0;for(o=0;o=0;)e[r]=0;for(r=0;r=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()},r.prototype.divRemTo=function(e,t,i){var o=e.abs();if(!(o.t<=0)){var s=this.abs();if(s.t0?(o.lShiftTo(f,a),s.lShiftTo(f,i)):(o.copyTo(a),s.copyTo(i));var l=a.t,p=a[l-1];if(0!=p){var d=p*(1<1?a[l-2]>>this.F2:0),y=this.FV/d,g=(1<=0&&(i[i.t++]=1,i.subTo(_,i)),r.ONE.dlShiftTo(l,_),_.subTo(a,a);a.t=0;){var w=i[--b]==p?this.DM:Math.floor(i[b]*y+(i[b-1]+m)*g);if((i[b]+=a.am(0,w,i,v,0,l))0&&i.rShiftTo(f,i),u<0&&r.ZERO.subTo(i,i)}}},r.prototype.invDigit=function(){if(this.t<1)return 0;var e=this[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},r.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},r.prototype.exp=function(e,t){if(e>4294967295||e<1)return r.ONE;var i=n(),o=n(),s=t.convert(this),a=h(e)-1;for(s.copyTo(i);--a>=0;)if(t.sqrTo(i,o),(e&1<0)t.mulTo(o,s,i);else{var u=i;i=o,o=u}return t.revert(i)},r.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=c(r));s>=0;)a>(a+=this.DB-t)):(r=this[s]>>(a-=t)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=c(r));return i?o:"0"},r.prototype.negate=function(){var e=n();return r.ZERO.subTo(this,e),e},r.prototype.abs=function(){return this.s<0?this.negate():this},r.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[r]-e[r]))return t;return 0},r.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+h(this[this.t-1]^this.s&this.DM)},r.prototype.mod=function(e){var t=n();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(r.ZERO)>0&&e.subTo(t,t),t},r.prototype.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new p(t):new d(t),this.exp(e,r)},r.ZERO=l(0),r.ONE=l(1),w.prototype.convert=S,w.prototype.revert=S,w.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},w.prototype.sqrTo=function(e,t){e.squareTo(t)},k.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=n();return e.copyTo(t),this.reduce(t),t},k.prototype.revert=function(e){return e},k.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)},k.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},k.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var E,A,x,I=[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,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],T=(1<<26)/I[I.length-1];function B(){!function(e){A[x++]^=255&e,A[x++]^=e>>8&255,A[x++]^=e>>16&255,A[x++]^=e>>24&255,x>=j&&(x-=j)}((new Date).getTime())}if(r.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},r.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),i=l(r),o=n(),s=n(),a="";for(this.divRemTo(i,o,s);o.signum()>0;)a=(r+s.intValue()).toString(e).substr(1)+a,o.divRemTo(i,o,s);return s.intValue().toString(e)+a},r.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var n=this.chunkSize(t),i=Math.pow(t,n),o=!1,s=0,a=0,u=0;u=n&&(this.dMultiply(i),this.dAddOffset(a,0),s=0,a=0))}s>0&&(this.dMultiply(Math.pow(t,s)),this.dAddOffset(a,0)),o&&r.ZERO.subTo(this,this)},r.prototype.fromNumber=function(e,t,n){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,n),this.testBit(e-1)||this.bitwiseTo(r.ONE.shiftLeft(e-1),g,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(r.ONE.shiftLeft(e-1),this);else{var i=new Array,o=7&e;i.length=1+(e>>3),t.nextBytes(i),o>0?i[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[r++]=n:n<-1&&(t[r++]=this.DV+n),t.t=r,t.clamp()},r.prototype.dMultiply=function(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},r.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}},r.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[--i]=0;for(n=r.t-this.t;i=0;)r[n]=0;for(n=Math.max(t-this.t,0);n0)if(0==t)r=this[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this[n])%e;return r},r.prototype.millerRabin=function(e){var t=this.subtract(r.ONE),i=t.getLowestSetBit();if(i<=0)return!1;var o=t.shiftRight(i);(e=e+1>>1)>I.length&&(e=I.length);for(var s=n(),a=0;a>24},r.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},r.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},r.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[e]&(1<>(n+=this.DB-8)):(r=this[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},r.prototype.equals=function(e){return 0==this.compareTo(e)},r.prototype.min=function(e){return this.compareTo(e)<0?this:e},r.prototype.max=function(e){return this.compareTo(e)>0?this:e},r.prototype.and=function(e){var t=n();return this.bitwiseTo(e,y,t),t},r.prototype.or=function(e){var t=n();return this.bitwiseTo(e,g,t),t},r.prototype.xor=function(e){var t=n();return this.bitwiseTo(e,m,t),t},r.prototype.andNot=function(e){var t=n();return this.bitwiseTo(e,b,t),t},r.prototype.not=function(){for(var e=n(),t=0;t=this.t?0!=this.s:0!=(this[t]&1<1){var y=n();for(i.sqrTo(a[1],y);u<=f;)a[u]=n(),i.mulTo(y,a[u-2],a[u]),u+=2}var g,m,b=e.t-1,v=!0,_=n();for(o=h(e[b])-1;b>=0;){for(o>=c?g=e[b]>>o-c&f:(g=(e[b]&(1<0&&(g|=e[b-1]>>this.DB+o-c)),u=r;0==(1&g);)g>>=1,--u;if((o-=u)<0&&(o+=this.DB,--b),v)a[g].copyTo(s),v=!1;else{for(;u>1;)i.sqrTo(s,_),i.sqrTo(_,s),u-=2;u>0?i.sqrTo(s,_):(m=s,s=_,_=m),i.mulTo(_,a[g],s)}for(;b>=0&&0==(e[b]&1<=0?(n.subTo(i,n),t&&o.subTo(a,o),s.subTo(u,s)):(i.subTo(n,i),t&&a.subTo(o,a),u.subTo(s,u))}return 0!=i.compareTo(r.ONE)?r.ZERO:u.compareTo(e)>=0?u.subtract(e):u.signum()<0?(u.addTo(e,u),u.signum()<0?u.add(e):u):u},r.prototype.pow=function(e){return this.exp(e,new w)},r.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},r.prototype.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r[0]<=I[I.length-1]){for(t=0;t>>8,A[x++]=255&C;x=0,B()}function R(){if(null==E){for(B(),(E=new L).init(A),x=0;xn)return r;do{t%2&&(r+=e),(t=N(t/2))&&(e+=e)}while(t);return r}function K(e){if("string"==typeof e)return e;if(F(e))return j?j.call(e):"";var t=e+"";return"0"==t&&1/e==-r?"-0":t}function D(e,t,r){var n=e.length;return r=void 0===r?n:r,!t&&r>=n?e:function(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Array(i);++n-1&&e%1==0&&e-1&&e%1==0&&e<=n}(e.length)&&!function(e){var t=A(e)?b.call(e):"";return t==s||t==a}(e)}(r)&&k(t,r.length):"string"==n&&t in r)&&function(e,t){return e===t||e!=e&&t!=t}(r[t],e)}function A(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function x(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&b.call(e)==u}function I(e){return e?(e=function(e){if("number"==typeof e)return e;if(x(e))return o;if(A(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=A(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(c,"");var r=l.test(e);return r||h.test(e)?d(e.slice(2),r?2:8):f.test(e)?o:+e}(e))===r||e===-r?(e<0?-1:1)*i:e==e?e:0:0===e?e:0}function T(e){return null==e?"":function(e){if("string"==typeof e)return e;if(x(e))return S?S.call(e):"";var t=e+"";return"0"==t&&1/e==-r?"-0":t}(e)}e.exports=function(e,t,r){return t=(r?E(e,t,r):void 0===t)?1:function(e){var t=I(e),r=t%1;return t==t?r?t-r:t:0}(t),function(e,t){var r="";if(!e||t<1||t>n)return r;do{t%2&&(r+=e),(t=_(t/2))&&(e+=e)}while(t);return r}(T(e),t)}}).call(this,r(7))},function(e,t,r){(function(e,r){var n=200,i="Expected a function",o="__lodash_hash_undefined__",s=1,a=2,u=1/0,c=9007199254740991,f=1.7976931348623157e308,l=NaN,h="[object Arguments]",p="[object Array]",d="[object Boolean]",y="[object Date]",g="[object Error]",m="[object Function]",b="[object GeneratorFunction]",v="[object Map]",_="[object Number]",w="[object Object]",S="[object Promise]",k="[object RegExp]",E="[object Set]",A="[object String]",x="[object Symbol]",I="[object WeakMap]",T="[object ArrayBuffer]",B="[object DataView]",C=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,P=/^\w*$/,O=/^\./,R=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,N=/^\s+|\s+$/g,L=/\\(\\)?/g,j=/^[-+]0x[0-9a-f]+$/i,M=/^0b[01]+$/i,K=/^\[object .+?Constructor\]$/,D=/^0o[0-7]+$/i,U=/^(?:0|[1-9]\d*)$/,F={};F["[object Float32Array]"]=F["[object Float64Array]"]=F["[object Int8Array]"]=F["[object Int16Array]"]=F["[object Int32Array]"]=F["[object Uint8Array]"]=F["[object Uint8ClampedArray]"]=F["[object Uint16Array]"]=F["[object Uint32Array]"]=!0,F[h]=F[p]=F[T]=F[d]=F[B]=F[y]=F[g]=F[m]=F[v]=F[_]=F[w]=F[k]=F[E]=F[A]=F[I]=!1;var q=parseInt,H="object"==typeof e&&e&&e.Object===Object&&e,z="object"==typeof self&&self&&self.Object===Object&&self,V=H||z||Function("return this")(),G="object"==typeof t&&t&&!t.nodeType&&t,W=G&&"object"==typeof r&&r&&!r.nodeType&&r,$=W&&W.exports===G&&H.process,Y=function(){try{return $&&$.binding("util")}catch(e){}}(),J=Y&&Y.isTypedArray;function X(e,t){for(var r=-1,n=e?e.length:0;++rc))return!1;var l=o.get(e);if(l&&o.get(t))return l==t;var h=-1,p=!0,d=i&s?new Ne:void 0;for(o.set(e,t),o.set(t,e);++h-1},Oe.prototype.set=function(e,t){var r=this.__data__,n=Me(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Re.prototype.clear=function(){this.__data__={hash:new Pe,map:new(be||Oe),string:new Pe}},Re.prototype.delete=function(e){return We(this,e).delete(e)},Re.prototype.get=function(e){return We(this,e).get(e)},Re.prototype.has=function(e){return We(this,e).has(e)},Re.prototype.set=function(e,t){return We(this,e).set(e,t),this},Ne.prototype.add=Ne.prototype.push=function(e){return this.__data__.set(e,o),this},Ne.prototype.has=function(e){return this.__data__.has(e)},Le.prototype.clear=function(){this.__data__=new Oe},Le.prototype.delete=function(e){return this.__data__.delete(e)},Le.prototype.get=function(e){return this.__data__.get(e)},Le.prototype.has=function(e){return this.__data__.has(e)},Le.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Oe){var i=r.__data__;if(!be||i.length-1&&e%1==0&&e-1?i[o?t[s]:s]:void 0}}(function(e,t,r){var n=e?e.length:0;if(!n)return-1;var i=null==r?0:function(e){var t=function(e){return e?(e=function(e){if("number"==typeof e)return e;if(pt(e))return l;if(lt(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=lt(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(N,"");var r=M.test(e);return r||D.test(e)?q(e.slice(2),r?2:8):j.test(e)?l:+e}(e))===u||e===-u?(e<0?-1:1)*f:e==e?e:0:0===e?e:0}(e),r=t%1;return t==t?r?t-r:t:0}(r);return i<0&&(i=ge(n+i,0)),function(e,t,r,n){for(var i=e.length,o=r+(n?1:-1);n?o--:++o-1&&e%1==0&&e<=c}function lt(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function ht(e){return!!e&&"object"==typeof e}function pt(e){return"symbol"==typeof e||ht(e)&&ce.call(e)==x}var dt=J?function(e){return function(t){return e(t)}}(J):function(e){return ht(e)&&ft(e.length)&&!!F[ce.call(e)]};function yt(e){return ut(e)?je(e):He(e)}function gt(e){return e}r.exports=nt}).call(this,r(7),r(27)(e))},function(e,t,r){"use strict";var n=r(139).sprintf,i=t.spanAllZeroes=function(e){return e.replace(/(0+)/g,'$1')};function o(e){return e.replace(/^(0+)/,'$1')}t.spanAll=function(e,t){return void 0===t&&(t=0),e.split("").map(function(e,r){return n('%s',e,r+t,i(e))}).join("")},t.spanLeadingZeroes=function(e){return e.split(":").map(function(e){return o(e)}).join(":")},t.simpleGroup=function(e,t){var r=e.split(":");return t||(t=0),r.map(function(e,r){return/group-v4/.test(e)?e:n('%s',r+t,o(e))}).join(":")}},function(e,t,r){"use strict";(function(t){const n=r(14),i=r(12),o=r(212),s=r(9),a=/^https?:\/\/[^/]+\/(ip(f|n)s)\/((\w+).*)/,u=/^\/(ip(f|n)s)\/((\w+).*)/,c=1,f=4,l=/^https?:\/\/([^/]+)\.(ip(?:f|n)s)\.[^/]+/;function h(e){try{return s.isCID(new s(e))}catch(e){return!1}}function p(e,t,r=c,n=f){const i=y(e);if(!i)return!1;const o=i.match(t);if(!o)return!1;if("ipfs"!==o[r])return!1;let s=o[n];return s&&t===l&&(s=s.toLowerCase()),h(s)}function d(e,t,r=c,n){const i=y(e);if(!i)return!1;const o=i.match(t);if(!o)return!1;if("ipns"!==o[r])return!1;if(n&&t===l){let e=o[n];return h(e=e.toLowerCase())}return!0}function y(e){return t.isBuffer(e)?n.encode(e):"string"==typeof e&&e}const g=e=>p(e,l,2,1),m=e=>d(e,l,2,1);e.exports={multihash:function(e){const r=y(e);try{const o=t.from(n.decode(r));return i.decode(o),!0}catch(e){return!1}},cid:h,base32cid:e=>"base32"===function(e){try{return o.isEncoded(e)}catch(e){return!1}}(e)&&h(e),ipfsSubdomain:g,ipnsSubdomain:m,subdomain:e=>g(e)||m(e),subdomainPattern:l,ipfsUrl:e=>p(e,a),ipnsUrl:e=>d(e,a),url:e=>p(e,a)||d(e,a),urlPattern:a,ipfsPath:e=>p(e,u),ipnsPath:e=>d(e,u),path:e=>p(e,u)||d(e,u),pathPattern:u,urlOrPath:e=>p(e,a)||d(e,a)||p(e,u)||d(e,u)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(14),i=r(978),o=r(51);function s(e){let r;if("string"==typeof e)r=e;else if(t.isBuffer(e))r=n.encode(e).toString();else if(i.isPeerId(e))r=e.toB58String();else{if(!o.isPeerInfo(e))throw new Error("not valid PeerId or PeerInfo, or B58Str");r=e.id.toB58String()}return r}e.exports=class{constructor(){this._peers={}}has(e){const t=s(e);return Boolean(this._peers[t])}put(e,t){const r=this._peers[e.id.toB58String()];if(!r||t)return this._peers[e.id.toB58String()]=e,e;e.multiaddrs.forEach(e=>r.multiaddrs.add(e));const n=e.isConnected();return n&&r.connect(n),e.protocols.forEach(e=>r.protocols.add(e)),!r.id.privKey&&e.id.privKey&&(r.id.privKey=e.id.privKey),!r.id.pubKey&&e.id.pubKey&&(r.id.pubKey=e.id.pubKey),r}get(e){const t=s(e),r=this._peers[t];if(r)return r;throw new Error("PeerInfo not found")}getAll(){return this._peers}getAllArray(){return Object.keys(this._peers).map(e=>this._peers[e])}getMultiaddrs(e){return this.get(e).multiaddrs.toArray()}remove(e){const t=s(e);this._peers[t]&&delete this._peers[t]}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(271),i=r(272)(),o=r(980),s={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"},a=(t,r,o)=>{n(i.subtle.sign({name:"HMAC"},t,r).then(t=>e.from(t)),o)};t.create=function(e,t,r){const u=s[e];n(i.subtle.importKey("raw",t,{name:"HMAC",hash:{name:u}},!1,["sign"]).then(t=>({digest(e,r){a(t,e,r)},length:o[e]})),r)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(12),i=r(985);function o(e,t,r,i){if("function"==typeof r&&(i=r,r=void 0),!i)throw new Error("Missing callback");o.digest(e,t,r,(e,o)=>{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){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(271),i=r(272)();function o(e){return Promise.all([i.subtle.exportKey("jwk",e.privateKey),i.subtle.exportKey("jwk",e.publicKey)])}t.utils=r(988),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(o).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"]);n(Promise.all([r,function(e){return i.subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}(e)]).then(e=>o({privateKey:e[0],publicKey:e[1]})).then(e=>({privateKey:e[0],publicKey:e[1]})),t)},t.getRandomValues=function(t){return e.from(i.getRandomValues(t))},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)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(15).bignum;t.toBase64=function(t,r){return t.toArrayLike(e,"be",r).toString("base64").replace(/(=*)$/,"").replace(/\+/g,"-").replace(/\//g,"_")},t.toBn=function(t){return new n(e.from(t,"base64"))}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(491);e.exports=function(e){if(!e||"number"!=typeof e)throw new Error("first argument must be a Number bigger than 0");return n.getRandomValues(new Uint8Array(e))}},function(e,t,r){!function(t,r){e.exports=r()}(0,function(){return 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.i=function(e){return e},r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get: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=32)}([function(e,t,r){"use strict";(function(e,n){var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=r(17),s=r(15),a=r(37),u=r(16),c=r(18),f={};t.clone=function(r,n){if("object"!==(void 0===r?"undefined":i(r))||null===r)return r;var o=(n=n||new Map).get(r);if(o)return o;var s=void 0,a=!1;if(Array.isArray(r))s=[],a=!0;else if(e.isBuffer(r))s=e.from(r);else if(r instanceof Date)s=new Date(r.getTime());else if(r instanceof RegExp)s=new RegExp(r);else{var u=Object.getPrototypeOf(r);u&&u.isImmutable?s=r:(s=Object.create(u),a=!0)}if(n.set(r,s),a)for(var c=Object.getOwnPropertyNames(r),f=0;f1||!n.part&&!l[A])return!1;return(!n.only||!f)&&E},t.flatten=function(e,r){for(var n=r||[],i=0;i1?r-1:0),i=1;i\?@\[\]\^`\{\|\}~\"\\]*$/.test(e),"Bad attribute value ("+e+")"),e.replace(/\\/g,"\\\\").replace(/\"/g,'\\"')},t.escapeHtml=function(e){return c.escapeHtml(e)},t.escapeJavaScript=function(e){return c.escapeJavaScript(e)},t.escapeJson=function(e){return c.escapeJson(e)},t.once=function(e){if(e._hoekOnce)return e;var t=!1,r=function(){if(!t){t=!0;for(var r=arguments.length,n=Array(r),i=0;i1;)y[d=h.shift()]||(y[d]={}),y=y[d];y[d=h.shift()]=t.reach(e,p,n)}return u},t.uniqueFilename=function(e,t){t=t?"."!==t[0]?"."+t:t:"",e=a.resolve(e);var r=[Date.now(),n.pid,s.randomBytes(8).toString("hex")].join("-")+t;return a.join(e,r)},t.stringify=function(){try{for(var e=arguments.length,t=Array(e),r=0;r4&&void 0!==arguments[4]?arguments[4]:this._flags;return u.create(e,t,r,n,i)},e.prototype.createOverrideError=function(e,t,r,n,i,o){return u.create(e,t,r,n,this._flags,i,o)},e.prototype.checkOptions=function(e){var t=r(21).options.validate(e);if(t.error)throw new Error(t.error.details[0].message)},e.prototype.clone=function(){var e=Object.create(Object.getPrototypeOf(this));e.isJoi=!0,e._currentJoi=this._currentJoi,e._type=this._type,e._settings=this._settings,e._baseType=this._baseType,e._valids=this._valids.slice(),e._invalids=this._invalids.slice(),e._tests=this._tests.slice(),e._refs=this._refs.slice(),e._flags=o.clone(this._flags),e._description=this._description,e._unit=this._unit,e._notes=this._notes.slice(),e._tags=this._tags.slice(),e._examples=this._examples.slice(),e._meta=this._meta.slice(),e._inner={};for(var t=Object.keys(this._inner),r=0;r=0?p[d[m]]={key:m,schema:p[d[m]].schema.concat(h[g].schema)}:p.push(h[g])}}else t._inner[f]=t._inner[f].concat(h);else t._inner[f]=h.slice()}}return t},e.prototype._test=function(e,t,r,n){var i=this.clone();return i._tests.push({func:r,name:e,arg:t,options:n}),i},e.prototype.options=function(e){o.assert(!e.context,"Cannot override context"),this.checkOptions(e);var t=this.clone();return t._settings=s.concat(t._settings,e),t},e.prototype.strict=function(e){var t=this.clone(),r=void 0!==e&&!e;return t._settings=s.concat(t._settings,{convert:r}),t},e.prototype.raw=function(e){var t=void 0===e||e;if(this._flags.raw===t)return this;var r=this.clone();return r._flags.raw=t,r},e.prototype.error=function(e){o.assert(e&&(e instanceof Error||"function"==typeof e),"Must provide a valid Error object or a function");var t=this.clone();return t._flags.error=e,t},e.prototype.allow=function(){for(var e=arguments.length,t=Array(e),r=0;r0,"description must be provided when default value is a function"));var r=this.clone();return r._flags.default=e,a.push(r._refs,e),r},e.prototype.empty=function(e){var t=this.clone();return void 0===e?delete t._flags.empty:t._flags.empty=f.schema(this._currentJoi,e),t},e.prototype.when=function(e,t){o.assert(t&&"object"===(void 0===t?"undefined":n(t)),"Invalid options"),o.assert(void 0!==t.then||void 0!==t.otherwise,'options must have at least one of "then" or "otherwise"');var i=t.hasOwnProperty("then")?this.concat(f.schema(this._currentJoi,t.then)):void 0,s=t.hasOwnProperty("otherwise")?this.concat(f.schema(this._currentJoi,t.otherwise)):void 0;c=c||r(10);var a={then:i,otherwise:s};Object.prototype.hasOwnProperty.call(t,"is")&&(a.is=t.is);var u=c.when(e,a);return u._flags.presence="ignore",u._baseType=this,u},e.prototype.description=function(e){o.assert(e&&"string"==typeof e,"Description must be a non-empty string");var t=this.clone();return t._description=e,t},e.prototype.notes=function(e){o.assert(e&&("string"==typeof e||Array.isArray(e)),"Notes must be a non-empty string or array");var t=this.clone();return t._notes=t._notes.concat(e),t},e.prototype.tags=function(e){o.assert(e&&("string"==typeof e||Array.isArray(e)),"Tags must be a non-empty string or array");var t=this.clone();return t._tags=t._tags.concat(e),t},e.prototype.meta=function(e){o.assert(void 0!==e,"Meta cannot be undefined");var t=this.clone();return t._meta=t._meta.concat(e),t},e.prototype.example=function(){o.assert(1===arguments.length,"Missing example");var e=arguments.length<=0?void 0:arguments[0],t=this.clone();return t._examples.push(e),t},e.prototype.unit=function(e){o.assert(e&&"string"==typeof e,"Unit name must be a non-empty string");var t=this.clone();return t._unit=e,t},e.prototype._prepareEmptyValue=function(e){return"string"==typeof e&&this._flags.trim?e.trim():e},e.prototype._validate=function(e,t,r,n){var i=this,c=e;t=t||{key:"",path:[],parent:null,reference:n},this._settings&&(r=s.concat(r,this._settings));var f=[],h=function(){var n=void 0;if(void 0!==e)n=i._flags.raw?c:e;else if(r.noDefaults)n=e;else if(a.isRef(i._flags.default))n=i._flags.default(t.parent,r);else if("function"!=typeof i._flags.default||i._flags.func&&!i._flags.default.description)n=o.clone(i._flags.default);else{var s=void 0;null!==t.parent&&i._flags.default.length>0&&(s=[o.clone(t.parent),r]);var u=l._try(i._flags.default,s);n=u.value,u.error&&f.push(i.createError("any.default",{error:u.error},t,r))}if(f.length&&"function"==typeof i._flags.error){var h=i._flags.error.call(i,f);f="string"==typeof h?[i.createOverrideError("override",{reason:f},t,r,h)]:[].concat(h).map(function(e){return e instanceof Error?e:i.createOverrideError(e.type||"override",e.context,t,r,e.message,e.template)})}return{value:i._flags.strip?void 0:n,finalValue:n,errors:f.length?f:null}};if(this._coerce){var p=this._coerce.call(this,e,t,r);if(p.errors)return e=p.value,f=f.concat(p.errors),h();e=p.value}this._flags.empty&&!this._flags.empty._validate(this._prepareEmptyValue(e),null,l.defaults).errors&&(e=void 0);var d=this._flags.presence||r.presence;if("optional"===d){if(void 0===e){if(!this._flags.hasOwnProperty("default")||void 0!==this._flags.default||"object"!==this._type)return h();e={}}}else{if("required"===d&&void 0===e)return f.push(this.createError("any.required",null,t,r)),h();if("forbidden"===d)return void 0===e?h():(f.push(this.createError("any.unknown",null,t,r)),h())}if(this._valids.has(e,t,r,this._flags.insensitive))return h();if(this._invalids.has(e,t,r,this._flags.insensitive)&&(f.push(this.createError(""===e?"any.empty":"any.invalid",{value:e,invalids:this._invalids.values({stripUndefined:!0})},t,r)),r.abortEarly||void 0===e))return h();if(this._base){var y=this._base.call(this,e,t,r);if(y.errors)return e=y.value,f=f.concat(y.errors),h();if(y.value!==e){if(e=y.value,this._valids.has(e,t,r,this._flags.insensitive))return h();if(this._invalids.has(e,t,r,this._flags.insensitive)&&(f.push(this.createError(""===e?"any.empty":"any.invalid",{value:e,invalids:this._invalids.values({stripUndefined:!0})},t,r)),r.abortEarly))return h()}}if(this._flags.allowOnly&&(f.push(this.createError("any.allowOnly",{value:e,valids:this._valids.values({stripUndefined:!0})},t,r)),r.abortEarly))return h();for(var g=0;g * @license MIT */ -var n=r(33),i=r(34),o=r(35);function s(){return u.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 d(e,t){if(u.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 U(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(e).length;default:if(n)return U(e).length;t=(""+t).toLowerCase(),n=!0}}function y(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=u.from(t,n)),u.isBuffer(t))return 0===t.length?-1:m(e,t,r,n,i);if("number"==typeof t)return t&=255,u.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,u=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,u/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,h=0;hi&&(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 E(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function A(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:c>223?3:c>191?2:1;if(i+l<=r)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&c)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=x)return String.fromCharCode.apply(String,e);for(var r="",n=0;nthis.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 B(this,t,r);case"utf8":case"utf-8":return A(this,t,r);case"ascii":return I(this,t,r);case"latin1":case"binary":return T(this,t,r);case"base64":return E(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}.apply(this,arguments)},u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),""},u.prototype.compare=function(e,t,r,n,i){if(!u.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(t>>>=0,r>>>=0,n>>>=0,i>>>=0,this===e)return 0;for(var o=i-n,s=r-t,a=Math.min(o,s),c=this.slice(n,i),f=e.slice(t,r),l=0;li)&&(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 b(this,e,t,r);case"utf8":case"utf-8":return v(this,e,t,r);case"ascii":return _(this,e,t,r);case"latin1":case"binary":return w(this,e,t,r);case"base64":return S(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}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var x=4096;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 O(e,t,r,n,i,o){if(!u.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 R(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 N(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 K(e,t,r,n,o){return o||L(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function j(e,t,r,n,o){return o||L(e,0,r,8),i.write(e,t,r,n,52,8),r+8}u.prototype.slice=function(e,t){var r,n=this.length;if(e=~~e,t=void 0===t?n:~~t,e<0?(e+=n)<0&&(e=0):e>n&&(e=n),t<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},u.prototype.readUInt8=function(e,t){return t||P(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return t||P(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return t||P(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return t||P(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return t||P(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||P(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},u.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||P(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},u.prototype.readInt8=function(e,t){return t||P(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){t||P(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(e,t){t||P(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(e,t){return t||P(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return t||P(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return t||P(e,4,this.length),i.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||P(e,4,this.length),i.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||P(e,8,this.length),i.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||P(e,8,this.length),i.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,r,n){e=+e,t|=0,r|=0,n||O(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},u.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):R(this,e,t,!0),t+2},u.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):R(this,e,t,!1),t+2},u.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):N(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):N(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);O(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},u.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);O(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},u.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):R(this,e,t,!0),t+2},u.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):R(this,e,t,!1),t+2},u.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):N(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):N(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,r){return K(this,e,t,!0,r)},u.prototype.writeFloatBE=function(e,t,r){return K(this,e,t,!1,r)},u.prototype.writeDoubleLE=function(e,t,r){return j(this,e,t,!0,r)},u.prototype.writeDoubleBE=function(e,t,r){return j(this,e,t,!1,r)},u.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||!u.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 F(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(M,"")).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(t,r(5))},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=r(0),o=r(1);t.schema=function(e,t){return void 0!==t&&null!==t&&"object"===(void 0===t?"undefined":n(t))?t.isJoi?t:Array.isArray(t)?e.alternatives().try(t):t instanceof RegExp?e.string().regex(t):t instanceof Date?e.date().valid(t):e.object().keys(t):"string"==typeof t?e.string().valid(t):"number"==typeof t?e.number().valid(t):"boolean"==typeof t?e.boolean().valid(t):o.isRef(t)?e.valid(t):(i.assert(null===t,"Invalid schema content:",t),e.valid(null))},t.ref=function(e){return o.isRef(e)?e:o.create(e)}},function(e,t){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};var i=r(0),o=r(20),s={annotations:Symbol("joi-annotations"),stringify:function(e,r){var i=void 0===e?"undefined":n(e);if(null===e)return"null";if("string"===i)return e;if(e instanceof t.Err||"function"===i||"symbol"===i)return e.toString();if("object"===i){if(Array.isArray(e)){for(var o="",a=0;a2&&"!"===t[0]&&"!"===t[1];if(c&&(t=t.slice(2)),!u&&!c){var f=i.reach(r,"key");t="string"==typeof f?f+t:i.reach(o.errors,"key")+t}return t.replace(/\{\{(\!?)([^}]+)\}\}/g,function(t,r,o){var a=i.reach(e.context,o),u=s.stringify(a,n);return r&&e.options.escapeHtml?i.escapeHtml(u):u})},e}(),t.create=function(e,r,n,i,o,s,a){return new t.Err(e,r,n,i,o,s,a)},t.process=function(e,t){if(!e||!e.length)return null;var r="",n=[],i=function e(t,i){for(var o=0;o0){var o=t.indexOf(this);~o?(t.length=o+1,e.length=o+1,e[o]=r):(t.push(this),e.push(r)),~t.indexOf(i)&&(i=function(r,n){return t[0]===n?"[Circular ~]":"[Circular ~."+e.slice(0,t.indexOf(n)).join(".")+"]"}.call(this,r,i))}else t.push(i);if(i){var a=i[s.annotations];if(a){if(Array.isArray(i)){for(var u=[],c=0;c=0;--u)for(var c=u+1,f=this.details[u],l=f.path,h=a,p=0;;++p){var d=l[p];if(h.isImmutable&&(h=h.clone()),!(p+11)for(var r=1;r0,"You need to provide at least one extension"),this.assert(d,t.extensionsSchema);var y=Object.create(this.any());n(y,this);for(var g=function(r){var c=d[r];"function"==typeof c&&(c=c(y)),e.assert(c,t.extensionSchema);var p=(c.base||e.any()).clone(),g=p.constructor,m=function(e){function t(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,e.call(this));return c.base&&n(r,p),r._type=c.name,c.language&&(r._settings=l.concat(r._settings,{language:function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}({},c.name,c.language)})),r}return i(t,e),t}(g);if(c.coerce&&(m.prototype._coerce=function(e,t,r){if(g.prototype._coerce){var n=g.prototype._coerce.call(this,e,t,r);if(n.errors)return n;e=n.value}var i=c.coerce.call(this,e,t,r);return i instanceof u.Err?{value:e,errors:i}:{value:i}}),c.pre&&(m.prototype._base=function(e,t,r){if(g.prototype._base){var n=g.prototype._base.call(this,e,t,r);if(n.errors)return n;e=n.value}var i=c.pre.call(this,e,t,r);return i instanceof u.Err?{value:e,errors:i}:{value:i}}),c.rules)for(var b=function(t){var r=c.rules[t],n=r.params?r.params instanceof s?r.params._inner.children.map(function(e){return e.key}):Object.keys(r.params):[],i=r.params?a.schema(e,r.params):null;m.prototype[r.name]=function(){for(var e=arguments.length,t=Array(e),a=0;an.length)throw new Error("Unexpected number of arguments");for(var u=!1,c={},l=0;l0&&void 0!==arguments[0]?arguments[0]:"javascript",t=["javascript","unix"];if(a.assert(t.includes(e),'"type" must be one of "'+t.join('", "')+'"'),this._flags.timestamp===e)return this;var r=this.clone();return r._flags.timestamp=e,r._flags.multiplier="unix"===e?1e3:1,r},t.prototype._isIsoDate=function(e){return u.isoDate.test(e)},t}(o),u.compare=function(e,t){return function(r){var n="now"===r,i=s.isRef(r);return n||i||(r=u.Date.toDate(r)),a.assert(r,"Invalid date format"),this._test(e,r,function(o,s,a){var c=void 0;if(n)c=Date.now();else if(i){if(!(c=u.Date.toDate(r(s.reference||s.parent,a))))return this.createError("date.ref",{ref:r.key},s,a);c=c.getTime()}else c=r.getTime();return t(o.getTime(),c)?o:this.createError("date."+e,{limit:new Date(c)},s,a)})}},u.Date.prototype.min=u.compare("min",function(e,t){return e>=t}),u.Date.prototype.max=u.compare("max",function(e,t){return e<=t}),u.Date.prototype.greater=u.compare("greater",function(e,t){return e>t}),u.Date.prototype.less=u.compare("less",function(e,t){return e=0,"limit must be a positive integer"),this._test("length",e,function(t,r,n){return Object.keys(t).length===e?t:this.createError("object.length",{limit:e},r,n)})},t.prototype.min=function(e){return o.assert(Number.isSafeInteger(e)&&e>=0,"limit must be a positive integer"),this._test("min",e,function(t,r,n){return Object.keys(t).length>=e?t:this.createError("object.min",{limit:e},r,n)})},t.prototype.max=function(e){return o.assert(Number.isSafeInteger(e)&&e>=0,"limit must be a positive integer"),this._test("max",e,function(t,r,n){return Object.keys(t).length<=e?t:this.createError("object.max",{limit:e},r,n)})},t.prototype.pattern=function e(t,r){var n=t instanceof RegExp;o.assert(n||t instanceof a,"pattern must be a regex or schema"),o.assert(void 0!==r,"Invalid rule"),n&&(t=new RegExp(t.source,t.ignoreCase?"i":void 0));try{r=c.schema(this._currentJoi,r)}catch(e){throw e.hasOwnProperty("path")&&(e.message=e.message+"("+e.path+")"),e}var i=this.clone();return n?i._inner.patterns.push({regex:t,rule:r}):i._inner.patterns.push({schema:t,rule:r}),i},t.prototype.schema=function(){return this._test("schema",null,function(e,t,r){return e instanceof a?e:this.createError("object.schema",null,t,r)})},t.prototype.with=function(e,t){return o.assert(2===arguments.length,"Invalid number of arguments, expected 2."),this._dependency("with",e,t)},t.prototype.without=function(e,t){return o.assert(2===arguments.length,"Invalid number of arguments, expected 2."),this._dependency("without",e,t)},t.prototype.xor=function(){for(var e=arguments.length,t=Array(e),r=0;r0,"expected at least one children");var i=f.groupChildren(e),s=void 0;if(""in i?(s=this[t].apply(this,r),delete i[""]):s=this.clone(),s._inner.children){n=n?n+".":"";for(var a=0;a0&&(t.renames=o.clone(this._inner.renames)),t},t.prototype.assert=function e(t,r,n){t=c.ref(t),o.assert(t.isContext||t.depth>1,"Cannot use assertions for root level references - use direct key rules instead"),n=n||"pass the assertion test";try{r=c.schema(this._currentJoi,r)}catch(e){throw e.hasOwnProperty("path")&&(e.message=e.message+"("+e.path+")"),e}var i=t.path[t.path.length-1],s=t.path.join(".");return this._test("assert",{schema:r,ref:t},function(e,a,u){if(!r._validate(t(e),null,u,e).errors)return e;var c=o.merge({},a);return c.key=i,c.path=t.path,this.createError("object.assert",{ref:s,message:n},c,u)})},t.prototype.type=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.name;o.assert("function"==typeof e,"type must be a constructor function");var r={name:t,ctor:e};return this._test("type",r,function(t,n,i){return t instanceof e?t:this.createError("object.type",{type:r.name},n,i)})},t}(a),f.safeParse=function(e){try{return JSON.parse(e)}catch(e){}return e},f.renameDefaults={alias:!1,multiple:!1,override:!1},f.groupChildren=function(e){e.sort();for(var t={},r=0;r=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}}),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),y(r)?n.showHidden=r:r&&t._extend(n,r),v(n.showHidden)&&(n.showHidden=!1),v(n.depth)&&(n.depth=2),v(n.colors)&&(n.colors=!1),v(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),f(n,e,n.depth)}function u(e,t){var r=a.styles[t];return r?"["+a.colors[r][0]+"m"+e+"["+a.colors[r][1]+"m":e}function c(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 b(i)||(i=f(e,i,n)),i}var o=l(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)),k(r)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return h(r);if(0===s.length){if(E(r)){var u=r.name?": "+r.name:"";return e.stylize("[Function"+u+"]","special")}if(_(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(S(r))return e.stylize(Date.prototype.toString.call(r),"date");if(k(r))return h(r)}var c,y="",g=!1,m=["{","}"];return d(r)&&(g=!0,m=["[","]"]),E(r)&&(y=" [Function"+(r.name?": "+r.name:"")+"]"),_(r)&&(y=" "+RegExp.prototype.toString.call(r)),S(r)&&(y=" "+Date.prototype.toUTCString.call(r)),k(r)&&(y=" "+h(r)),0!==s.length||g&&0!=r.length?n<0?_(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special"):(e.seen.push(r),c=g?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?r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}(c,y,m)):m[0]+y+m[1]}function l(e,t){if(v(t))return e.stylize("undefined","undefined");if(b(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}return m(t)?e.stylize(""+t,"number"):y(t)?e.stylize(""+t,"boolean"):g(t)?e.stylize("null","null"):void 0}function h(e){return"["+Error.prototype.toString.call(e)+"]"}function p(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),T(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=g(r)?f(e,u.value,null):f(e,u.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")),v(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 y(e){return"boolean"==typeof e}function g(e){return null===e}function m(e){return"number"==typeof e}function b(e){return"string"==typeof e}function v(e){return void 0===e}function _(e){return w(e)&&"[object RegExp]"===A(e)}function w(e){return"object"==typeof e&&null!==e}function S(e){return w(e)&&"[object Date]"===A(e)}function k(e){return w(e)&&("[object Error]"===A(e)||e instanceof Error)}function E(e){return"function"==typeof e}function A(e){return Object.prototype.toString.call(e)}function x(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(e){if(v(o)&&(o=n.env.NODE_DEBUG||""),e=e.toUpperCase(),!s[e])if(new RegExp("\\b"+e+"\\b","i").test(o)){var r=n.pid;s[e]=function(){var n=t.format.apply(t,arguments);console.error("%s %d: %s",e,r,n)}}else s[e]=function(){};return s[e]},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=y,t.isNull=g,t.isNullOrUndefined=function(e){return null==e},t.isNumber=m,t.isString=b,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=v,t.isRegExp=_,t.isObject=w,t.isDate=S,t.isError=k,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(40);var I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function T(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){console.log("%s - %s",function(){var e=new Date,t=[x(e.getHours()),x(e.getMinutes()),x(e.getSeconds())].join(":");return[e.getDate(),I[e.getMonth()],t].join(" ")}(),t.format.apply(t,arguments))},t.inherits=r(39),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}}).call(t,r(5),r(7))},function(e,t,r){"use strict";(function(t){ +var n=r(33),i=r(34),o=r(35);function s(){return u.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 d(e,t){if(u.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 U(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(e).length;default:if(n)return U(e).length;t=(""+t).toLowerCase(),n=!0}}function y(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=u.from(t,n)),u.isBuffer(t))return 0===t.length?-1:m(e,t,r,n,i);if("number"==typeof t)return t&=255,u.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,u=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,u/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var f=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var l=!0,h=0;hi&&(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 E(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function A(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:c>223?3:c>191?2:1;if(i+l<=r)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&c)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(e){var t=e.length;if(t<=x)return String.fromCharCode.apply(String,e);for(var r="",n=0;nthis.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 B(this,t,r);case"utf8":case"utf-8":return A(this,t,r);case"ascii":return I(this,t,r);case"latin1":case"binary":return T(this,t,r);case"base64":return E(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}.apply(this,arguments)},u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),""},u.prototype.compare=function(e,t,r,n,i){if(!u.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(t>>>=0,r>>>=0,n>>>=0,i>>>=0,this===e)return 0;for(var o=i-n,s=r-t,a=Math.min(o,s),c=this.slice(n,i),f=e.slice(t,r),l=0;li)&&(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 b(this,e,t,r);case"utf8":case"utf-8":return v(this,e,t,r);case"ascii":return _(this,e,t,r);case"latin1":case"binary":return w(this,e,t,r);case"base64":return S(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}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var x=4096;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 O(e,t,r,n,i,o){if(!u.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 R(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 N(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 j(e,t,r,n,o){return o||L(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function M(e,t,r,n,o){return o||L(e,0,r,8),i.write(e,t,r,n,52,8),r+8}u.prototype.slice=function(e,t){var r,n=this.length;if(e=~~e,t=void 0===t?n:~~t,e<0?(e+=n)<0&&(e=0):e>n&&(e=n),t<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},u.prototype.readUInt8=function(e,t){return t||P(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return t||P(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return t||P(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return t||P(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return t||P(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||P(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},u.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||P(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},u.prototype.readInt8=function(e,t){return t||P(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){t||P(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(e,t){t||P(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(e,t){return t||P(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return t||P(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return t||P(e,4,this.length),i.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||P(e,4,this.length),i.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||P(e,8,this.length),i.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||P(e,8,this.length),i.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,r,n){e=+e,t|=0,r|=0,n||O(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},u.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):R(this,e,t,!0),t+2},u.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):R(this,e,t,!1),t+2},u.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):N(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):N(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);O(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},u.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);O(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},u.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):R(this,e,t,!0),t+2},u.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):R(this,e,t,!1),t+2},u.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):N(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||O(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):N(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,r){return j(this,e,t,!0,r)},u.prototype.writeFloatBE=function(e,t,r){return j(this,e,t,!1,r)},u.prototype.writeDoubleLE=function(e,t,r){return M(this,e,t,!0,r)},u.prototype.writeDoubleBE=function(e,t,r){return M(this,e,t,!1,r)},u.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||!u.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 F(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(K,"")).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(t,r(5))},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=r(0),o=r(1);t.schema=function(e,t){return void 0!==t&&null!==t&&"object"===(void 0===t?"undefined":n(t))?t.isJoi?t:Array.isArray(t)?e.alternatives().try(t):t instanceof RegExp?e.string().regex(t):t instanceof Date?e.date().valid(t):e.object().keys(t):"string"==typeof t?e.string().valid(t):"number"==typeof t?e.number().valid(t):"boolean"==typeof t?e.boolean().valid(t):o.isRef(t)?e.valid(t):(i.assert(null===t,"Invalid schema content:",t),e.valid(null))},t.ref=function(e){return o.isRef(e)?e:o.create(e)}},function(e,t){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};var i=r(0),o=r(20),s={annotations:Symbol("joi-annotations"),stringify:function(e,r){var i=void 0===e?"undefined":n(e);if(null===e)return"null";if("string"===i)return e;if(e instanceof t.Err||"function"===i||"symbol"===i)return e.toString();if("object"===i){if(Array.isArray(e)){for(var o="",a=0;a2&&"!"===t[0]&&"!"===t[1];if(c&&(t=t.slice(2)),!u&&!c){var f=i.reach(r,"key");t="string"==typeof f?f+t:i.reach(o.errors,"key")+t}return t.replace(/\{\{(\!?)([^}]+)\}\}/g,function(t,r,o){var a=i.reach(e.context,o),u=s.stringify(a,n);return r&&e.options.escapeHtml?i.escapeHtml(u):u})},e}(),t.create=function(e,r,n,i,o,s,a){return new t.Err(e,r,n,i,o,s,a)},t.process=function(e,t){if(!e||!e.length)return null;var r="",n=[],i=function e(t,i){for(var o=0;o0){var o=t.indexOf(this);~o?(t.length=o+1,e.length=o+1,e[o]=r):(t.push(this),e.push(r)),~t.indexOf(i)&&(i=function(r,n){return t[0]===n?"[Circular ~]":"[Circular ~."+e.slice(0,t.indexOf(n)).join(".")+"]"}.call(this,r,i))}else t.push(i);if(i){var a=i[s.annotations];if(a){if(Array.isArray(i)){for(var u=[],c=0;c=0;--u)for(var c=u+1,f=this.details[u],l=f.path,h=a,p=0;;++p){var d=l[p];if(h.isImmutable&&(h=h.clone()),!(p+11)for(var r=1;r0,"You need to provide at least one extension"),this.assert(d,t.extensionsSchema);var y=Object.create(this.any());n(y,this);for(var g=function(r){var c=d[r];"function"==typeof c&&(c=c(y)),e.assert(c,t.extensionSchema);var p=(c.base||e.any()).clone(),g=p.constructor,m=function(e){function t(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var r=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,e.call(this));return c.base&&n(r,p),r._type=c.name,c.language&&(r._settings=l.concat(r._settings,{language:function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}({},c.name,c.language)})),r}return i(t,e),t}(g);if(c.coerce&&(m.prototype._coerce=function(e,t,r){if(g.prototype._coerce){var n=g.prototype._coerce.call(this,e,t,r);if(n.errors)return n;e=n.value}var i=c.coerce.call(this,e,t,r);return i instanceof u.Err?{value:e,errors:i}:{value:i}}),c.pre&&(m.prototype._base=function(e,t,r){if(g.prototype._base){var n=g.prototype._base.call(this,e,t,r);if(n.errors)return n;e=n.value}var i=c.pre.call(this,e,t,r);return i instanceof u.Err?{value:e,errors:i}:{value:i}}),c.rules)for(var b=function(t){var r=c.rules[t],n=r.params?r.params instanceof s?r.params._inner.children.map(function(e){return e.key}):Object.keys(r.params):[],i=r.params?a.schema(e,r.params):null;m.prototype[r.name]=function(){for(var e=arguments.length,t=Array(e),a=0;an.length)throw new Error("Unexpected number of arguments");for(var u=!1,c={},l=0;l0&&void 0!==arguments[0]?arguments[0]:"javascript",t=["javascript","unix"];if(a.assert(t.includes(e),'"type" must be one of "'+t.join('", "')+'"'),this._flags.timestamp===e)return this;var r=this.clone();return r._flags.timestamp=e,r._flags.multiplier="unix"===e?1e3:1,r},t.prototype._isIsoDate=function(e){return u.isoDate.test(e)},t}(o),u.compare=function(e,t){return function(r){var n="now"===r,i=s.isRef(r);return n||i||(r=u.Date.toDate(r)),a.assert(r,"Invalid date format"),this._test(e,r,function(o,s,a){var c=void 0;if(n)c=Date.now();else if(i){if(!(c=u.Date.toDate(r(s.reference||s.parent,a))))return this.createError("date.ref",{ref:r.key},s,a);c=c.getTime()}else c=r.getTime();return t(o.getTime(),c)?o:this.createError("date."+e,{limit:new Date(c)},s,a)})}},u.Date.prototype.min=u.compare("min",function(e,t){return e>=t}),u.Date.prototype.max=u.compare("max",function(e,t){return e<=t}),u.Date.prototype.greater=u.compare("greater",function(e,t){return e>t}),u.Date.prototype.less=u.compare("less",function(e,t){return e=0,"limit must be a positive integer"),this._test("length",e,function(t,r,n){return Object.keys(t).length===e?t:this.createError("object.length",{limit:e},r,n)})},t.prototype.min=function(e){return o.assert(Number.isSafeInteger(e)&&e>=0,"limit must be a positive integer"),this._test("min",e,function(t,r,n){return Object.keys(t).length>=e?t:this.createError("object.min",{limit:e},r,n)})},t.prototype.max=function(e){return o.assert(Number.isSafeInteger(e)&&e>=0,"limit must be a positive integer"),this._test("max",e,function(t,r,n){return Object.keys(t).length<=e?t:this.createError("object.max",{limit:e},r,n)})},t.prototype.pattern=function e(t,r){var n=t instanceof RegExp;o.assert(n||t instanceof a,"pattern must be a regex or schema"),o.assert(void 0!==r,"Invalid rule"),n&&(t=new RegExp(t.source,t.ignoreCase?"i":void 0));try{r=c.schema(this._currentJoi,r)}catch(e){throw e.hasOwnProperty("path")&&(e.message=e.message+"("+e.path+")"),e}var i=this.clone();return n?i._inner.patterns.push({regex:t,rule:r}):i._inner.patterns.push({schema:t,rule:r}),i},t.prototype.schema=function(){return this._test("schema",null,function(e,t,r){return e instanceof a?e:this.createError("object.schema",null,t,r)})},t.prototype.with=function(e,t){return o.assert(2===arguments.length,"Invalid number of arguments, expected 2."),this._dependency("with",e,t)},t.prototype.without=function(e,t){return o.assert(2===arguments.length,"Invalid number of arguments, expected 2."),this._dependency("without",e,t)},t.prototype.xor=function(){for(var e=arguments.length,t=Array(e),r=0;r0,"expected at least one children");var i=f.groupChildren(e),s=void 0;if(""in i?(s=this[t].apply(this,r),delete i[""]):s=this.clone(),s._inner.children){n=n?n+".":"";for(var a=0;a0&&(t.renames=o.clone(this._inner.renames)),t},t.prototype.assert=function e(t,r,n){t=c.ref(t),o.assert(t.isContext||t.depth>1,"Cannot use assertions for root level references - use direct key rules instead"),n=n||"pass the assertion test";try{r=c.schema(this._currentJoi,r)}catch(e){throw e.hasOwnProperty("path")&&(e.message=e.message+"("+e.path+")"),e}var i=t.path[t.path.length-1],s=t.path.join(".");return this._test("assert",{schema:r,ref:t},function(e,a,u){if(!r._validate(t(e),null,u,e).errors)return e;var c=o.merge({},a);return c.key=i,c.path=t.path,this.createError("object.assert",{ref:s,message:n},c,u)})},t.prototype.type=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.name;o.assert("function"==typeof e,"type must be a constructor function");var r={name:t,ctor:e};return this._test("type",r,function(t,n,i){return t instanceof e?t:this.createError("object.type",{type:r.name},n,i)})},t}(a),f.safeParse=function(e){try{return JSON.parse(e)}catch(e){}return e},f.renameDefaults={alias:!1,multiple:!1,override:!1},f.groupChildren=function(e){e.sort();for(var t={},r=0;r=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}}),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),y(r)?n.showHidden=r:r&&t._extend(n,r),v(n.showHidden)&&(n.showHidden=!1),v(n.depth)&&(n.depth=2),v(n.colors)&&(n.colors=!1),v(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),f(n,e,n.depth)}function u(e,t){var r=a.styles[t];return r?"["+a.colors[r][0]+"m"+e+"["+a.colors[r][1]+"m":e}function c(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 b(i)||(i=f(e,i,n)),i}var o=l(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)),k(r)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return h(r);if(0===s.length){if(E(r)){var u=r.name?": "+r.name:"";return e.stylize("[Function"+u+"]","special")}if(_(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(S(r))return e.stylize(Date.prototype.toString.call(r),"date");if(k(r))return h(r)}var c,y="",g=!1,m=["{","}"];return d(r)&&(g=!0,m=["[","]"]),E(r)&&(y=" [Function"+(r.name?": "+r.name:"")+"]"),_(r)&&(y=" "+RegExp.prototype.toString.call(r)),S(r)&&(y=" "+Date.prototype.toUTCString.call(r)),k(r)&&(y=" "+h(r)),0!==s.length||g&&0!=r.length?n<0?_(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special"):(e.seen.push(r),c=g?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?r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}(c,y,m)):m[0]+y+m[1]}function l(e,t){if(v(t))return e.stylize("undefined","undefined");if(b(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}return m(t)?e.stylize(""+t,"number"):y(t)?e.stylize(""+t,"boolean"):g(t)?e.stylize("null","null"):void 0}function h(e){return"["+Error.prototype.toString.call(e)+"]"}function p(e,t,r,n,i,o){var s,a,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(a=e.stylize("[Setter]","special")),T(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(u.value)<0?(a=g(r)?f(e,u.value,null):f(e,u.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")),v(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 y(e){return"boolean"==typeof e}function g(e){return null===e}function m(e){return"number"==typeof e}function b(e){return"string"==typeof e}function v(e){return void 0===e}function _(e){return w(e)&&"[object RegExp]"===A(e)}function w(e){return"object"==typeof e&&null!==e}function S(e){return w(e)&&"[object Date]"===A(e)}function k(e){return w(e)&&("[object Error]"===A(e)||e instanceof Error)}function E(e){return"function"==typeof e}function A(e){return Object.prototype.toString.call(e)}function x(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(e){if(v(o)&&(o=n.env.NODE_DEBUG||""),e=e.toUpperCase(),!s[e])if(new RegExp("\\b"+e+"\\b","i").test(o)){var r=n.pid;s[e]=function(){var n=t.format.apply(t,arguments);console.error("%s %d: %s",e,r,n)}}else s[e]=function(){};return s[e]},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=y,t.isNull=g,t.isNullOrUndefined=function(e){return null==e},t.isNumber=m,t.isString=b,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=v,t.isRegExp=_,t.isObject=w,t.isDate=S,t.isError=k,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(40);var I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function T(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){console.log("%s - %s",function(){var e=new Date,t=[x(e.getHours()),x(e.getMinutes()),x(e.getSeconds())].join(":");return[e.getDate(),I[e.getMonth()],t].join(" ")}(),t.format.apply(t,arguments))},t.inherits=r(39),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}}).call(t,r(5),r(7))},function(e,t,r){"use strict";(function(t){ /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */ -function n(e,t){if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i=0;c--)if(f[c]!==l[c])return!1;for(c=f.length-1;c>=0;c--)if(!b(e[u=f[c]],t[u],r,n))return!1;return!0}function w(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 s="string"==typeof n,a=!e&&o.isError(i),u=!e&&i&&!r;if((a&&s&&w(i,r)||u)&&g(i,r,"Got unwanted exception"+n),e&&i&&r&&!w(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 d(y(e.actual),128)+" "+e.operator+" "+d(y(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}}},o.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){b(e,t,!1)||g(e,t,r,"deepEqual",l.deepEqual)},l.deepStrictEqual=function(e,t,r){b(e,t,!0)||g(e,t,r,"deepStrictEqual",l.deepStrictEqual)},l.notDeepEqual=function(e,t,r){b(e,t,!1)&&g(e,t,r,"notDeepEqual",l.notDeepEqual)},l.notDeepStrictEqual=function e(t,r,n){b(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};var k=Object.keys||function(e){var t=[];for(var r in e)s.call(e,r)&&t.push(r);return t}}).call(t,r(5))},function(e,t,r){"use strict";(function(e){var r={};t.escapeJavaScript=function(e){if(!e)return"";for(var t="",n=0;n&\u2028\u2029]/g,function(e){return 60===(t=e.charCodeAt(0))?"\\u003c":62===t?"\\u003e":38===t?"\\u0026":8232===t?"\\u2028":"\\u2029"})},r.escapeJavaScriptChar=function(t){if(t>=256)return"\\u"+r.padLeft(""+t,4);var n=e.from(String.fromCharCode(t),"ascii").toString("hex");return"\\x"+r.padLeft(n,2)},r.escapeHtmlChar=function(t){var n=r.namedHtml[t];if(void 0!==n)return n;if(t>=256)return"&#"+t+";";var i=e.from(String.fromCharCode(t),"ascii").toString("hex");return"&#x"+r.padLeft(i,2)+";"},r.padLeft=function(e,t){for(;e.length=97||t>=65&&t<=90||t>=48&&t<=57||32===t||46===t||44===t||45===t||58===t||95===t)&&(e[t]=null);return e}()}).call(t,r(3).Buffer)},function(e,t,r){"use strict";(function(e){var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=r(38),o={hasOwn:Object.prototype.hasOwnProperty,indexOf:Array.prototype.indexOf,defaultThreshold:16,maxIPv6Groups:8,categories:{valid:1,dnsWarn:7,rfc5321:15,cfws:31,deprecated:63,rfc5322:127,error:255},diagnoses:{valid:0,rfc5321TLD:9,rfc5321TLDNumeric:10,rfc5321QuotedString:11,rfc5321AddressLiteral:12,cfwsComment:17,cfwsFWS:18,undesiredNonAscii:25,deprecatedLocalPart:33,deprecatedFWS:34,deprecatedQTEXT:35,deprecatedQP:36,deprecatedComment:37,deprecatedCTEXT:38,deprecatedIPv6:39,deprecatedCFWSNearAt:49,rfc5322Domain:65,rfc5322TooLong:66,rfc5322LocalTooLong:67,rfc5322DomainTooLong:68,rfc5322LabelTooLong:69,rfc5322DomainLiteral:70,rfc5322DomainLiteralOBSDText:71,rfc5322IPv6GroupCount:72,rfc5322IPv62x2xColon:73,rfc5322IPv6BadCharacter:74,rfc5322IPv6MaxGroups:75,rfc5322IPv6ColonStart:76,rfc5322IPv6ColonEnd:77,errExpectingDTEXT:129,errNoLocalPart:130,errNoDomain:131,errConsecutiveDots:132,errATEXTAfterCFWS:133,errATEXTAfterQS:134,errATEXTAfterDomainLiteral:135,errExpectingQPair:136,errExpectingATEXT:137,errExpectingQTEXT:138,errExpectingCTEXT:139,errBackslashEnd:140,errDotStart:141,errDotEnd:142,errDomainHyphenStart:143,errDomainHyphenEnd:144,errUnclosedQuotedString:145,errUnclosedComment:146,errUnclosedDomainLiteral:147,errFWSCRLFx2:148,errFWSCRLFEnd:149,errCRNoLF:150,errUnknownTLD:160,errDomainTooShort:161},components:{localpart:0,domain:1,literal:2,contextComment:3,contextFWS:4,contextQuotedString:5,contextQuotedPair:6}};o.specials=function(){var e='()<>[]:;@\\,."',t=new Array(256);t.fill(!1);for(var r=0;r=0?o.nulNormalize(e):e.normalize("NFC")},o.checkIpV6=function(e){return e.every(function(e){return o.regex.ipV6.test(e)})},o.validDomain=function(e,t){return t.tldBlacklist?Array.isArray(t.tldBlacklist)?-1===o.indexOf.call(t.tldBlacklist,e):!o.hasOwn.call(t.tldBlacklist,e):Array.isArray(t.tldWhitelist)?-1!==o.indexOf.call(t.tldWhitelist,e):o.hasOwn.call(t.tldWhitelist,e)},t.validate=o.validate=function(t,r,s){r=r||{},t=o.normalize(t),"function"==typeof r&&(s=r,r={}),"function"!=typeof s&&(s=null);var a=void 0,u=void 0;if("number"==typeof r.errorLevel?(a=!0,u=r.errorLevel):(a=!!r.errorLevel,u=o.diagnoses.valid),r.tldWhitelist)if("string"==typeof r.tldWhitelist)r.tldWhitelist=[r.tldWhitelist];else if("object"!==n(r.tldWhitelist))throw new TypeError("expected array or object tldWhitelist");if(r.tldBlacklist)if("string"==typeof r.tldBlacklist)r.tldBlacklist=[r.tldBlacklist];else if("object"!==n(r.tldBlacklist))throw new TypeError("expected array or object tldBlacklist");if(r.minDomainAtoms&&(r.minDomainAtoms!==(0|+r.minDomainAtoms)||r.minDomainAtoms<0))throw new TypeError("expected positive integer minDomainAtoms");var c=o.diagnoses.valid,f=function(e){e>c&&(c=e)};void 0!==r.allowUnicode&&!r.allowUnicode&&/[^\x00-\x7f]/.test(t)&&f(o.diagnoses.undesiredNonAscii);for(var l={now:o.components.localpart,prev:o.components.localpart,stack:[o.components.localpart]},h="",p={local:"",domain:""},d={locals:[""],domains:[""]},y=0,g=0,m=0,b=void 0,v=!1,_=!1,w=t.length,S=void 0,k=0;k64?f(o.diagnoses.rfc5322LocalTooLong):l.prev!==o.components.contextComment&&l.prev!==o.components.contextFWS||f(o.diagnoses.deprecatedCFWSNearAt),l.now=o.components.domain,l.stack[0]=o.components.domain,y=0,g=0,_=!1;break;default:if(_)switch(l.prev){case o.components.contextComment:case o.components.contextFWS:f(o.diagnoses.errATEXTAfterCFWS);break;case o.components.contextQuotedString:f(o.diagnoses.errATEXTAfterQS);break;default:throw new Error("more atext found where none is allowed, but unrecognized prev context: "+l.prev)}else l.prev=l.now,b=S.codePointAt(0),(o.specials(b)||o.c0Controls(b)||o.c1Controls(b))&&f(o.diagnoses.errExpectingATEXT),p.local+=S,d.locals[y]+=S,g+=e.byteLength(S,"utf8")}break;case o.components.domain:switch(S){case"(":0===g?f(0===y?o.diagnoses.deprecatedCFWSNearAt:o.diagnoses.deprecatedComment):(_=!0,f(o.diagnoses.cfwsComment)),l.stack.push(l.now),l.now=o.components.contextComment;break;case".":var E=i.encode(d.domains[y]).length;0===g?f(0===y?o.diagnoses.errDotStart:o.diagnoses.errConsecutiveDots):v?f(o.diagnoses.errDomainHyphenEnd):E>63&&f(o.diagnoses.rfc5322LabelTooLong),_=!1,g=0,++y,d.domains[y]="",p.domain+=S;break;case"[":0===p.domain.length?(_=!0,g+=e.byteLength(S,"utf8"),l.stack.push(l.now),l.now=o.components.literal,p.domain+=S,d.domains[y]+=S,p.literal=""):f(o.diagnoses.errExpectingATEXT);break;case"\r":if(w===++k||"\n"!==t[k]){f(o.diagnoses.errCRNoLF);break}case" ":case"\t":0===g?f(0===y?o.diagnoses.deprecatedCFWSNearAt:o.diagnoses.deprecatedFWS):(f(o.diagnoses.cfwsFWS),_=!0),l.stack.push(l.now),l.now=o.components.contextFWS,h=S;break;default:if(_)switch(l.prev){case o.components.contextComment:case o.components.contextFWS:f(o.diagnoses.errATEXTAfterCFWS);break;case o.components.literal:f(o.diagnoses.errATEXTAfterDomainLiteral);break;default:throw new Error("more atext found where none is allowed, but unrecognized prev context: "+l.prev)}b=S.codePointAt(0),v=!1,o.specials(b)||o.c0Controls(b)||o.c1Controls(b)?f(o.diagnoses.errExpectingATEXT):"-"===S?(0===g&&f(o.diagnoses.errDomainHyphenStart),v=!0):(b<48||b>122&&b<192||b>57&&b<65||b>90&&b<97)&&f(o.diagnoses.rfc5322Domain),p.domain+=S,d.domains[y]+=S,g+=e.byteLength(S,"utf8")}break;case o.components.literal:switch(S){case"]":if(cB?f(o.diagnoses.rfc5322IPv6MaxGroups):C.length===B&&f(o.diagnoses.deprecatedIPv6)):C.length!==B&&f(o.diagnoses.rfc5322IPv6GroupCount),":"===T[0]&&":"!==T[1]?f(o.diagnoses.rfc5322IPv6ColonStart):":"===T[T.length-1]&&":"!==T[T.length-2]?f(o.diagnoses.rfc5322IPv6ColonEnd):o.checkIpV6(C)?f(o.diagnoses.rfc5321AddressLiteral):f(o.diagnoses.rfc5322IPv6BadCharacter)}}else f(o.diagnoses.rfc5322DomainLiteral);p.domain+=S,d.domains[y]+=S,g+=e.byteLength(S,"utf8"),l.prev=l.now,l.now=l.stack.pop();break;case"\\":f(o.diagnoses.rfc5322DomainLiteralOBSDText),l.stack.push(l.now),l.now=o.components.contextQuotedPair;break;case"\r":if(w===++k||"\n"!==t[k]){f(o.diagnoses.errCRNoLF);break}case" ":case"\t":f(o.diagnoses.cfwsFWS),l.stack.push(l.now),l.now=o.components.contextFWS,h=S;break;default:if(127!==(b=S.codePointAt(0))&&o.c1Controls(b)||0===b||"["===S){f(o.diagnoses.errExpectingDTEXT);break}(o.c0Controls(b)||127===b)&&f(o.diagnoses.rfc5322DomainLiteralOBSDText),p.literal+=S,p.domain+=S,d.domains[y]+=S,g+=e.byteLength(S,"utf8")}break;case o.components.contextQuotedString:switch(S){case"\\":l.stack.push(l.now),l.now=o.components.contextQuotedPair;break;case"\r":if(w===++k||"\n"!==t[k]){f(o.diagnoses.errCRNoLF);break}case"\t":p.local+=" ",d.locals[y]+=" ",g+=e.byteLength(S,"utf8"),f(o.diagnoses.cfwsFWS),l.stack.push(l.now),l.now=o.components.contextFWS,h=S;break;case'"':p.local+=S,d.locals[y]+=S,g+=e.byteLength(S,"utf8"),l.prev=l.now,l.now=l.stack.pop();break;default:127!==(b=S.codePointAt(0))&&o.c1Controls(b)||0===b||10===b?f(o.diagnoses.errExpectingQTEXT):(o.c0Controls(b)||127===b)&&f(o.diagnoses.deprecatedQTEXT),p.local+=S,d.locals[y]+=S,g+=e.byteLength(S,"utf8")}break;case o.components.contextQuotedPair:127!==(b=S.codePointAt(0))&&o.c1Controls(b)?f(o.diagnoses.errExpectingQPair):(b<31&&9!==b||127===b)&&f(o.diagnoses.deprecatedQP),l.prev=l.now,l.now=l.stack.pop();var P="\\"+S;switch(l.now){case o.components.contextComment:break;case o.components.contextQuotedString:p.local+=P,d.locals[y]+=P,g+=2;break;case o.components.literal:p.domain+=P,d.domains[y]+=P,g+=2;break;default:throw new Error("quoted pair logic invoked in an invalid context: "+l.now)}break;case o.components.contextComment:switch(S){case"(":l.stack.push(l.now),l.now=o.components.contextComment;break;case")":l.prev=l.now,l.now=l.stack.pop();break;case"\\":l.stack.push(l.now),l.now=o.components.contextQuotedPair;break;case"\r":if(w===++k||"\n"!==t[k]){f(o.diagnoses.errCRNoLF);break}case" ":case"\t":f(o.diagnoses.cfwsFWS),l.stack.push(l.now),l.now=o.components.contextFWS,h=S;break;default:if(0===(b=S.codePointAt(0))||10===b||127!==b&&o.c1Controls(b)){f(o.diagnoses.errExpectingCTEXT);break}(o.c0Controls(b)||127===b)&&f(o.diagnoses.deprecatedCTEXT)}break;case o.components.contextFWS:if("\r"===h){if("\r"===S){f(o.diagnoses.errFWSCRLFx2);break}++m>1?f(o.diagnoses.deprecatedFWS):m=1}switch(S){case"\r":w!==++k&&"\n"===t[k]||f(o.diagnoses.errCRNoLF);break;case" ":case"\t":break;default:"\r"===h&&f(o.diagnoses.errFWSCRLFEnd),m=0,l.prev=l.now,l.now=l.stack.pop(),--k}h=S;break;default:throw new Error("unknown context: "+l.now)}if(c>o.categories.rfc5322)break}if(c255)f(o.diagnoses.rfc5322DomainTooLong);else if(e.byteLength(p.local,"utf8")+O+1>254)f(o.diagnoses.rfc5322TooLong);else if(g>63)f(o.diagnoses.rfc5322LabelTooLong);else if(r.minDomainAtoms&&d.domains.length0){var m=a.shift();if((y=m._validate(h,d,n)).errors){if(i.push(this.createError("array.ordered",{pos:l,reason:y.errors,value:h},{key:r.key,path:d.path},n)),n.abortEarly)return i}else if(m._flags.strip)c.fastSplice(e,l),--l,--f;else{if(!this._flags.sparse&&void 0===y.value){if(i.push(this.createError("array.sparse",null,{key:r.key,path:d.path,pos:l},n)),n.abortEarly)return i;continue}e[l]=y.value}continue}if(!this._inner.items.length){if(i.push(this.createError("array.orderedLength",{pos:l,limit:this._inner.ordereds.length},{key:r.key,path:d.path},n)),n.abortEarly)return i;continue}}for(var b=[],v=s.length,_=0;_=0||t,"limit must be a positive integer or reference"),this._test("min",e,function(r,n,i){var o=void 0;if(t){if(o=e(n.reference||n.parent,i),!(Number.isSafeInteger(o)&&o>=0))return this.createError("array.ref",{ref:e.key},n,i)}else o=e;return r.length>=o?r:this.createError("array.min",{limit:e,value:r},n,i)})},t.prototype.max=function(e){var t=a.isRef(e);return u.assert(Number.isSafeInteger(e)&&e>=0||t,"limit must be a positive integer or reference"),this._test("max",e,function(r,n,i){var o=void 0;if(t){if(o=e(n.reference||n.parent,i),!(Number.isSafeInteger(o)&&o>=0))return this.createError("array.ref",{ref:e.key},n,i)}else o=e;return r.length<=o?r:this.createError("array.max",{limit:e,value:r},n,i)})},t.prototype.length=function(e){var t=a.isRef(e);return u.assert(Number.isSafeInteger(e)&&e>=0||t,"limit must be a positive integer or reference"),this._test("length",e,function(r,n,i){var o=void 0;if(t){if(o=e(n.reference||n.parent,i),!(Number.isSafeInteger(o)&&o>=0))return this.createError("array.ref",{ref:e.key},n,i)}else o=e;return r.length===o?r:this.createError("array.length",{limit:e,value:r},n,i)})},t.prototype.unique=function(e){u.assert(void 0===e||"function"==typeof e||"string"==typeof e,"comparator must be a function or a string");var t={};return"string"==typeof e?t.path=e:"function"==typeof e&&(t.comparator=e),this._test("unique",t,function(e,r,i){for(var o={string:Object.create(null),number:Object.create(null),undefined:Object.create(null),boolean:Object.create(null),object:new Map,function:new Map,custom:new Map},s=t.comparator||u.deepEqual,a=0;a=0,"limit must be a positive integer"),this._test("min",e,function(t,r,n){return t.length>=e?t:this.createError("binary.min",{limit:e,value:t},r,n)})},r.prototype.max=function(e){return o.assert(Number.isSafeInteger(e)&&e>=0,"limit must be a positive integer"),this._test("max",e,function(t,r,n){return t.length<=e?t:this.createError("binary.max",{limit:e,value:t},r,n)})},r.prototype.length=function(e){return o.assert(Number.isSafeInteger(e)&&e>=0,"limit must be a positive integer"),this._test("length",e,function(t,r,n){return t.length===e?t:this.createError("binary.length",{limit:e,value:t},r,n)})},r}(i),e.exports=new s.Binary}).call(t,r(3).Buffer)},function(e,t,r){"use strict";function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):function(e,t){for(var r=Object.getOwnPropertyNames(t),n=0;n=0,"n must be a positive integer"),this._test("arity",e,function(t,r,n){return t.length===e?t:this.createError("function.arity",{n:e},r,n)})},t.prototype.minArity=function(e){return i.assert(Number.isSafeInteger(e)&&e>0,"n must be a strict positive integer"),this._test("minArity",e,function(t,r,n){return t.length>=e?t:this.createError("function.minArity",{n:e},r,n)})},t.prototype.maxArity=function(e){return i.assert(Number.isSafeInteger(e)&&e>=0,"n must be a positive integer"),this._test("maxArity",e,function(t,r,n){return t.length<=e?t:this.createError("function.maxArity",{n:e},r,n)})},t.prototype.ref=function(){return this._test("ref",null,function(e,t,r){return s.isRef(e)?e:this.createError("function.ref",null,t,r)})},t.prototype.class=function(){return this._test("class",null,function(e,t,r){return/^\s*class\s/.test(e.toString())?e:this.createError("function.class",null,t,r)})},t}(o.constructor),e.exports=new a.Func},function(e,t,r){"use strict";function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):function(e,t){for(var r=Object.getOwnPropertyNames(t),n=0;n0,"multiple must be greater than 0")),this._test("multiple",e,function(r,n,i){var o=t?e(n.reference||n.parent,i):e;return!t||"number"==typeof o&&isFinite(o)?r%o==0?r:this.createError("number.multiple",{multiple:e,value:r},n,i):this.createError("number.ref",{ref:e.key},n,i)})},t.prototype.integer=function(){return this._test("integer",void 0,function(e,t,r){return Number.isSafeInteger(e)?e:this.createError("number.integer",{value:e},t,r)})},t.prototype.negative=function(){return this._test("negative",void 0,function(e,t,r){return e<0?e:this.createError("number.negative",{value:e},t,r)})},t.prototype.positive=function(){return this._test("positive",void 0,function(e,t,r){return e>0?e:this.createError("number.positive",{value:e},t,r)})},t.prototype.precision=function(e){s.assert(Number.isSafeInteger(e),"limit must be an integer"),s.assert(!("precision"in this._flags),"precision already set");var t=this._test("precision",e,function(t,r,n){var i=t.toString().match(a.precisionRx);return Math.max((i[1]?i[1].length:0)-(i[2]?parseInt(i[2],10):0),0)<=e?t:this.createError("number.precision",{limit:e,value:t},r,n)});return t._flags.precision=e,t},t.prototype.port=function(){return this._test("port",void 0,function(e,t,r){return!Number.isSafeInteger(e)||e<0||e>65535?this.createError("number.port",{value:e},t,r):e})},t}(i),a.compare=function(e,t){return function(r){var n=o.isRef(r),i="number"==typeof r&&!isNaN(r);return s.assert(i||n,"limit must be a number or reference"),this._test(e,r,function(i,o,s){var a=void 0;if(n){if("number"!=typeof(a=r(o.reference||o.parent,s))||isNaN(a))return this.createError("number.ref",{ref:r.key},o,s)}else a=r;return t(i,a)?i:this.createError("number."+e,{limit:a,value:i},o,s)})}},a.Number.prototype.min=a.compare("min",function(e,t){return e>=t}),a.Number.prototype.max=a.compare("max",function(e,t){return e<=t}),a.Number.prototype.greater=a.compare("greater",function(e,t){return e>t}),a.Number.prototype.less=a.compare("less",function(e,t){return e9),o^=3}return i%10==0&&i>0?e:this.createError("string.creditCard",{value:e},t,r)})},t.prototype.regex=function(e,t){s.assert(e instanceof RegExp,"pattern must be a RegExp");var r={pattern:new RegExp(e.source,e.ignoreCase?"i":void 0)};"string"==typeof t?r.name=t:"object"===(void 0===t?"undefined":n(t))&&(r.invert=!!t.invert,t.name&&(r.name=t.name));var i=["string.regex",r.invert?".invert":"",r.name?".name":".base"].join("");return this._test("regex",r,function(e,t,n){return r.pattern.test(e)^r.invert?e:this.createError(i,{name:r.name,pattern:r.pattern,value:e},t,n)})},t.prototype.alphanum=function(){return this._test("alphanum",void 0,function(e,t,r){return/^[a-zA-Z0-9]+$/.test(e)?e:this.createError("string.alphanum",{value:e},t,r)})},t.prototype.token=function(){return this._test("token",void 0,function(e,t,r){return/^\w+$/.test(e)?e:this.createError("string.token",{value:e},t,r)})},t.prototype.email=function(e){return e&&(s.assert("object"===(void 0===e?"undefined":n(e)),"email options must be an object"),s.assert(void 0===e.checkDNS,"checkDNS option is not supported"),s.assert(void 0===e.tldWhitelist||"object"===n(e.tldWhitelist),"tldWhitelist must be an array or object"),s.assert(void 0===e.minDomainAtoms||Number.isSafeInteger(e.minDomainAtoms)&&e.minDomainAtoms>0,"minDomainAtoms must be a positive integer"),s.assert(void 0===e.errorLevel||"boolean"==typeof e.errorLevel||Number.isSafeInteger(e.errorLevel)&&e.errorLevel>=0,"errorLevel must be a non-negative integer or boolean")),this._test("email",e,function(t,n,i){a=a||r(19);try{var o=a.validate(t,e);if(!0===o||0===o)return t}catch(t){}return this.createError("string.email",{value:t},n,i)})},t.prototype.ip=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=p.ipRegex;s.assert("object"===(void 0===e?"undefined":n(e)),"options must be an object"),e.cidr?(s.assert("string"==typeof e.cidr,"cidr must be a string"),e.cidr=e.cidr.toLowerCase(),s.assert(s.contain(p.cidrPresences,e.cidr),"cidr must be one of "+p.cidrPresences.join(", ")),e.version||"optional"===e.cidr||(t=h.createIpRegex(["ipv4","ipv6","ipvfuture"],e.cidr))):e.cidr="optional";var r=void 0;if(e.version){Array.isArray(e.version)||(e.version=[e.version]),s.assert(e.version.length>=1,"version must have at least 1 version specified"),r=[];for(var i=0;i=1,"scheme must have at least 1 scheme specified");for(var a=0;a=1,"version must have at least 1 valid version specified");for(var r=new Set,n=0;n0&&void 0!==arguments[0]?arguments[0]:{};s.assert("object"===(void 0===e?"undefined":n(e)),"hex options must be an object"),s.assert(void 0===e.byteAligned||"boolean"==typeof e.byteAligned,"byteAligned must be boolean");var t=!0===e.byteAligned,r=/^[a-f0-9]+$/i,i=this._test("hex",r,function(e,n,i){return r.test(e)?t&&e.length%2!=0?this.createError("string.hexAlign",{value:e},n,i):e:this.createError("string.hex",{value:e},n,i)});return t&&(i._flags.byteAligned=!0),i},t.prototype.base64=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};s.assert("object"===(void 0===e?"undefined":n(e)),"base64 options must be an object"),s.assert(void 0===e.paddingRequired||"boolean"==typeof e.paddingRequired,"paddingRequired must be boolean");var t=(!1===e.paddingRequired?e.paddingRequired:(e.paddingRequired,1))?/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/:/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}(==)?|[A-Za-z0-9+\/]{3}=?)?$/;return this._test("base64",t,function(e,r,n){return t.test(e)?e:this.createError("string.base64",{value:e},r,n)})},t.prototype.hostname=function(){var e=/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/;return this._test("hostname",void 0,function(t,r,n){return t.length<=255&&e.test(t)||o.isIPv6(t)?t:this.createError("string.hostname",{value:t},r,n)})},t.prototype.normalize=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"NFC";s.assert(s.contain(p.normalizationForms,e),"normalization form must be one of "+p.normalizationForms.join(", "));var t=this._test("normalize",e,function(t,r,n){return n.convert||t===t.normalize(e)?t:this.createError("string.normalize",{value:t,form:e},r,n)});return t._flags.normalize=e,t},t.prototype.lowercase=function(){var e=this._test("lowercase",void 0,function(e,t,r){return r.convert||e===e.toLocaleLowerCase()?e:this.createError("string.lowercase",{value:e},t,r)});return e._flags.case="lower",e},t.prototype.uppercase=function(){var e=this._test("uppercase",void 0,function(e,t,r){return r.convert||e===e.toLocaleUpperCase()?e:this.createError("string.uppercase",{value:e},t,r)});return e._flags.case="upper",e},t.prototype.trim=function(){var e=this._test("trim",void 0,function(e,t,r){return r.convert||e===e.trim()?e:this.createError("string.trim",{value:e},t,r)});return e._flags.trim=!0,e},t.prototype.replace=function(e,t){"string"==typeof e&&(e=new RegExp(s.escapeRegex(e),"g")),s.assert(e instanceof RegExp,"pattern must be a RegExp"),s.assert("string"==typeof t,"replacement must be a String");var r=this.clone();return r._inner.replacements||(r._inner.replacements=[]),r._inner.replacements.push({pattern:e,replacement:t}),r},t.prototype.truncate=function(e){var t=void 0===e||!!e;if(this._flags.truncate===t)return this;var r=this.clone();return r._flags.truncate=t,r},t}(u),p.compare=function(e,r){return function(n,i){var o=c.isRef(n);return s.assert(Number.isSafeInteger(n)&&n>=0||o,"limit must be a positive integer or reference"),s.assert(!i||t.isEncoding(i),"Invalid encoding:",i),this._test(e,n,function(t,s,a){var u=void 0;if(o){if(u=n(s.reference||s.parent,a),!Number.isSafeInteger(u))return this.createError("string.ref",{ref:n.key},s,a)}else u=n;return r(t,u,i)?t:this.createError("string."+e,{limit:u,value:t,encoding:i},s,a)})}},p.String.prototype.min=p.compare("min",function(e,r,n){return(n?t.byteLength(e,n):e.length)>=r}),p.String.prototype.max=p.compare("max",function(e,r,n){return(n?t.byteLength(e,n):e.length)<=r}),p.String.prototype.length=p.compare("length",function(e,r,n){return(n?t.byteLength(e,n):e.length)===r}),p.String.prototype.uuid=p.String.prototype.guid,e.exports=new p.String}).call(t,r(3).Buffer)},function(e,t,r){"use strict";var n=r(14),i={Ip:{cidrs:{ipv4:{required:"\\/(?:"+n.ipv4Cidr+")",optional:"(?:\\/(?:"+n.ipv4Cidr+"))?",forbidden:""},ipv6:{required:"\\/"+n.ipv6Cidr,optional:"(?:\\/"+n.ipv6Cidr+")?",forbidden:""},ipvfuture:{required:"\\/"+n.ipv6Cidr,optional:"(?:\\/"+n.ipv6Cidr+")?",forbidden:""}},versions:{ipv4:n.IPv4address,ipv6:n.IPv6address,ipvfuture:n.IPvFuture}}};i.Ip.createIpRegex=function(e,t){for(var r=void 0,n=0;n0?u-4:u;var f=0;for(t=0;t>16&255,a[f++]=n>>8&255,a[f++]=255&n;return 2===s?(n=i[e.charCodeAt(t)]<<2|i[e.charCodeAt(t+1)]>>4,a[f++]=255&n):1===s&&(n=i[e.charCodeAt(t)]<<10|i[e.charCodeAt(t+1)]<<4|i[e.charCodeAt(t+2)]>>2,a[f++]=n>>8&255,a[f++]=255&n),a},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o="",s=[],a=0,u=r-i;au?u:a+16383));return 1===i?(t=e[r-1],o+=n[t>>2],o+=n[t<<4&63],o+="=="):2===i&&(t=(e[r-2]<<8)+e[r-1],o+=n[t>>10],o+=n[t>>4&63],o+=n[t<<2&63],o+="="),s.push(o),s.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function f(e){return n[e>>18&63]+n[e>>12&63]+n[e>>6&63]+n[63&e]}function l(e,t,r){for(var n,i=[],o=t;o>1,f=-7,l=r?i-1:0,h=r?-1:1,p=e[t+l];for(l+=h,o=p&(1<<-f)-1,p>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=h,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=h,f-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var s,a,u,c=8*o-i-1,f=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=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*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+p]=255&a,p+=d,a/=256,i-=8);for(s=s<0;e[r+p]=255&s,p+=d,s/=256,c-=8);e[r+p-d]|=128*y}},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t){e.exports={_args:[["joi@13.4.0","/Users/jeff/projects/joi-browser"]],_development:!0,_from:"joi@13.4.0",_id:"joi@13.4.0",_inBundle:!1,_integrity:"sha512-JuK4GjEu6j7zr9FuVe2MAseZ6si/8/HaY0qMAejfDFHp7jcH4OKE937mIHM5VT4xDS0q7lpQbszbxKV9rm0yUg==",_location:"/joi",_phantomChildren:{},_requested:{type:"version",registry:!0,raw:"joi@13.4.0",name:"joi",escapedName:"joi",rawSpec:"13.4.0",saveSpec:null,fetchSpec:"13.4.0"},_requiredBy:["#DEV:/"],_resolved:"https://registry.npmjs.org/joi/-/joi-13.4.0.tgz",_spec:"13.4.0",_where:"/Users/jeff/projects/joi-browser",bugs:{url:"https://github.com/hapijs/joi/issues"},dependencies:{hoek:"5.x.x",isemail:"3.x.x",topo:"3.x.x"},description:"Object schema validation",devDependencies:{code:"5.x.x",hapitoc:"1.x.x",lab:"15.x.x"},engines:{node:">=8.9.0"},homepage:"https://github.com/hapijs/joi",keywords:["hapi","schema","validation"],license:"BSD-3-Clause",main:"lib/index.js",name:"joi",repository:{type:"git",url:"git://github.com/hapijs/joi.git"},scripts:{test:"lab -t 100 -a code -L","test-cov-html":"lab -r html -o coverage.html -a code","test-debug":"lab -a code",toc:"hapitoc",version:"npm run toc && git add API.md README.md"},version:"13.4.0"}},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}var n=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,i=function(e){return n.exec(e).slice(1)};function o(e,t){if(e.filter)return e.filter(t);for(var r=[],n=0;n=-1&&!n;i--){var s=i>=0?arguments[i]:e.cwd();if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");s&&(t=s+"/"+t,n="/"===s.charAt(0))}return t=r(o(t.split("/"),function(e){return!!e}),!n).join("/"),(n?"/":"")+t||"."},t.normalize=function(e){var n=t.isAbsolute(e),i="/"===s(e,-1);return(e=r(o(e.split("/"),function(e){return!!e}),!n).join("/"))||n||(e="."),e&&i&&(e+="/"),(n?"/":"")+e},t.isAbsolute=function(e){return"/"===e.charAt(0)},t.join=function(){var e=Array.prototype.slice.call(arguments,0);return t.normalize(o(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,u=0;u= 0x80 (not a basic code point)","invalid-input":"Invalid input"},w=c-f,S=Math.floor,k=String.fromCharCode;function E(e){throw new RangeError(_[e])}function A(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}function x(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),n+A((e=e.replace(v,".")).split("."),t).join(".")}function I(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i65535&&(t+=k((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+k(e)}).join("")}function B(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:c}function C(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function P(e,t,r){var n=0;for(e=r?S(e/p):e>>1,e+=S(e/t);e>w*l>>1;n+=c)e=S(e/w);return S(n+(w+1)*e/(e+h))}function O(e){var t,r,n,i,o,s,a,h,p,m,b=[],v=e.length,_=0,w=y,k=d;for((r=e.lastIndexOf(g))<0&&(r=0),n=0;n=128&&E("not-basic"),b.push(e.charCodeAt(n));for(i=r>0?r+1:0;i=v&&E("invalid-input"),((h=B(e.charCodeAt(i++)))>=c||h>S((u-_)/s))&&E("overflow"),_+=h*s,!(h<(p=a<=k?f:a>=k+l?l:a-k));a+=c)s>S(u/(m=c-p))&&E("overflow"),s*=m;k=P(_-o,t=b.length+1,0==o),S(_/t)>u-w&&E("overflow"),w+=S(_/t),_%=t,b.splice(_++,0,w)}return T(b)}function R(e){var t,r,n,i,o,s,a,h,p,m,b,v,_,w,A,x=[];for(v=(e=I(e)).length,t=y,r=0,o=d,s=0;s=t&&bS((u-r)/(_=n+1))&&E("overflow"),r+=(a-t)*_,t=a,s=0;su&&E("overflow"),b==t){for(h=r,p=c;!(h<(m=p<=o?f:p>=o+l?l:p-o));p+=c)A=h-m,w=c-m,x.push(k(C(m+A%w,0))),h=S(A/w);x.push(k(C(h,0))),o=P(r,_,n==i),r=0,++n}++r,++t}return x.join("")}a={version:"1.4.1",ucs2:{decode:I,encode:T},decode:O,encode:R,toASCII:function(e){return x(e,function(e){return b.test(e)?"xn--"+R(e):e})},toUnicode:function(e){return x(e,function(e){return m.test(e)?O(e.slice(4).toLowerCase()):e})}},void 0===(i=function(){return a}.call(t,r,t,e))||(e.exports=i)}()}).call(t,r(41)(e),r(5))},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){e.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},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,r){"use strict";e.exports=r(1015)},function(e,t,r){"use strict";(function(e){const n=r(276),i=r(277)(),o=r(1022),s={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"},a=(t,r,o)=>{n(i.subtle.sign({name:"HMAC"},t,r).then(t=>e.from(t)),o)};t.create=function(e,t,r){const u=s[e];n(i.subtle.importKey("raw",t,{name:"HMAC",hash:{name:u}},!1,["sign"]).then(t=>({digest(e,r){a(t,e,r)},length:o[e]})),r)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(12),i=r(1027);function o(e,t,r,i){if("function"==typeof r&&(i=r,r=void 0),!i)throw new Error("Missing callback");o.digest(e,t,r,(e,o)=>{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){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(276),i=r(277)();function o(e){return Promise.all([i.subtle.exportKey("jwk",e.privateKey),i.subtle.exportKey("jwk",e.publicKey)])}t.utils=r(1030),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(o).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"]);n(Promise.all([r,function(e){return i.subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}(e)]).then(e=>o({privateKey:e[0],publicKey:e[1]})).then(e=>({privateKey:e[0],publicKey:e[1]})),t)},t.getRandomValues=function(t){return e.from(i.getRandomValues(t))},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)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(15).bignum;t.toBase64=function(t,r){return t.toArrayLike(e,"be",r).toString("base64").replace(/(=*)$/,"").replace(/\+/g,"-").replace(/\//g,"_")},t.toBn=function(t){return new n(e.from(t,"base64"))}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(502);e.exports=function(e){if(!e||"number"!=typeof e)throw new Error("first argument must be a Number bigger than 0");return n.getRandomValues(new Uint8Array(e))}},function(e,t,r){(function(t){var r="Expected a function",n=NaN,i="[object Symbol]",o=/^\s+|\s+$/g,s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt,f="object"==typeof t&&t&&t.Object===Object&&t,l="object"==typeof self&&self&&self.Object===Object&&self,h=f||l||Function("return this")(),p=Object.prototype.toString,d=Math.max,y=Math.min,g=function(){return h.Date.now()};function m(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function b(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&p.call(e)==i}(e))return n;if(m(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=m(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(o,"");var r=a.test(e);return r||u.test(e)?c(e.slice(2),r?2:8):s.test(e)?n:+e}e.exports=function(e,t,n){var i,o,s,a,u,c,f=0,l=!1,h=!1,p=!0;if("function"!=typeof e)throw new TypeError(r);function v(t){var r=i,n=o;return i=o=void 0,f=t,a=e.apply(n,r)}function _(e){var r=e-c;return void 0===c||r>=t||r<0||h&&e-f>=s}function w(){var e=g();if(_(e))return S(e);u=setTimeout(w,function(e){var r=t-(e-c);return h?y(r,s-(e-f)):r}(e))}function S(e){return u=void 0,p&&i?v(e):(i=o=void 0,a)}function k(){var e=g(),r=_(e);if(i=arguments,o=this,c=e,r){if(void 0===u)return function(e){return f=e,u=setTimeout(w,t),l?v(e):a}(c);if(h)return u=setTimeout(w,t),v(c)}return void 0===u&&(u=setTimeout(w,t)),a}return t=b(t)||0,m(n)&&(l=!!n.leading,s=(h="maxWait"in n)?d(b(n.maxWait)||0,t):s,p="trailing"in n?!!n.trailing:p),k.cancel=function(){void 0!==u&&clearTimeout(u),f=0,i=c=o=u=void 0},k.flush=function(){return void 0===u?a:S(g())},k}}).call(this,r(6))},function(e,t,r){"use strict";var n=r(1053);function i(e){return"function"==typeof e}function o(e,t){return t?function(r,n){var i=setTimeout(function(){e(new Error("pull-reader: read exceeded timeout"),n)},t);e(r,function(e,t){clearTimeout(i),n(e,t)})}:e}e.exports=function(e){var t,r,s,a,u,c=[],f=!1,l=n();function h(){for(;c.length;)if(null==c[0].length&&l.has(1))c.shift().cb(null,l.get());else if(l.has(c[0].length)){var e=c.shift();e.cb(null,l.get(e.length))}else if(1==s&&c[0].length&&l.length-1&&e%1==0&&e-1&&e%1==0&&e<=r}(e.length)&&!function(e){var t=function(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}(e)?f.call(e):"";return t==i||t==o}(e)}e.exports=function(e){return e?a(e,function(e){return b(e)?p(e):d(e)}(e)):[]}},function(e,t,r){"use strict";const n=Math.exp;e.exports=function(e){if("number"!=typeof e)throw new Error("must provide a timespan to the moving average constructor");if(e<=0)throw new Error("must provide a timespan > 0 to the moving average constructor");let t,r,i=0,o=0,s=0,a={};function u(t,r){return 1-n(-(t-r)/e)}return a.push=function(e,n){if(r){const a=u(e,r),c=n-t;t=a*n+(1-a)*t,i=(1-a)*(i+c*(a*c)),o=Math.sqrt(i),s=t+a*c}else t=n;r=e},a.movingAverage=function(){return t},a.variance=function(){return i},a.deviation=function(){return o},a.forecast=function(){return s},a}},function(e){e.exports={_from:"git://github.com/ipfs/js-ipfs.git#master",_id:"ipfs@0.30.1",_inBundle:!1,_integrity:"",_location:"/ipfs",_phantomChildren:{},_requested:{type:"git",raw:"git://github.com/ipfs/js-ipfs.git#master",rawSpec:"git://github.com/ipfs/js-ipfs.git#master",saveSpec:"git://github.com/ipfs/js-ipfs.git#master",fetchSpec:"git://github.com/ipfs/js-ipfs.git",gitCommittish:"master"},_requiredBy:["#USER","/"],_resolved:"git://github.com/ipfs/js-ipfs.git#bffe080cd6c3fa202ca0437f8abe38dca75e5903",_spec:"git://github.com/ipfs/js-ipfs.git#master",_where:"/Users/mitra/git/dweb-transports",bin:{jsipfs:"src/cli/bin.js"},browser:{"./src/core/components/init-assets.js":!1,"./src/core/runtime/config-nodejs.js":"./src/core/runtime/config-browser.js","./src/core/runtime/libp2p-nodejs.js":"./src/core/runtime/libp2p-browser.js","./src/core/runtime/preload-nodejs.js":"./src/core/runtime/preload-browser.js","./src/core/runtime/repo-nodejs.js":"./src/core/runtime/repo-browser.js","./src/core/runtime/dns-nodejs.js":"./src/core/runtime/dns-browser.js","./test/utils/create-repo-nodejs.js":"./test/utils/create-repo-browser.js",stream:"readable-stream",joi:"joi-browser"},bugs:{url:"https://github.com/ipfs/js-ipfs/issues"},bundleDependencies:!1,contributors:[{name:"Alan Shaw",email:"alan@tableflip.io"},{name:"Alex Potsides",email:"alex@achingbrain.net"},{name:"Andrew de Andrade",email:"andrew@deandrade.com.br"},{name:"Arpit Agarwal",email:"93arpit@gmail.com"},{name:"Arpit Agarwal",email:"atvanguard@users.noreply.github.com"},{name:"Bernard Mordan",email:"bernard@tableflip.io"},{name:"Brian Vander Schaaf",email:"bvs330@gmail.com"},{name:"Bruno Zell",email:"bruno.zzell@gmail.com"},{name:"CHEVALAY JOSSELIN",email:"josselin54.chevalay@gmail.com"},{name:"Caio Gondim",email:"me@caiogondim.com"},{name:"Christian Couder",email:"chriscool@tuxfamily.org"},{name:"Dafeng",email:"dfguo.joe@gmail.com"},{name:"Daniel J. O'Quinn",email:"danieljoquinn@gmail.com"},{name:"Daniela Borges Matos de Carvalho",email:"alunassertiva@gmail.com"},{name:"David Dias",email:"daviddias.p@gmail.com"},{name:"David da Silva",email:"dasilvacontin@gmail.com"},{name:"Diogo Silva",email:"fsdiogo@gmail.com"},{name:"Dmitriy Ryajov",email:"dryajov@gmail.com"},{name:"Dzmitry Das",email:"dbachko@gmail.com"},{name:"Enrico Marino",email:"enrico.marino@email.com"},{name:"Faheel Ahmad",email:"faheel@live.in"},{name:"Felix Yan",email:"felixonmars@archlinux.org"},{name:"Francisco Baio Dias",email:"xicombd@gmail.com"},{name:"Francisco Baio Dias",email:"francisco@typeform.com"},{name:"Friedel Ziegelmayer",email:"dignifiedquire@gmail.com"},{name:"Gar",email:"gar+gh@danger.computer"},{name:"Georgios Rassias",email:"georassias@gmail.com"},{name:"Gorka Ludlow",email:"gorka@aquigorka.com"},{name:"Greenkeeper",email:"support@greenkeeper.io"},{name:"Haad",email:"haadcode@users.noreply.github.com"},{name:"Haoliang Yu",email:"haoliangyu@users.noreply.github.com"},{name:"Harsh Vakharia",email:"harshjv@users.noreply.github.com"},{name:"Henrique Dias",email:"hacdias@gmail.com"},{name:"Henry Rodrick",email:"moshisushi@gmail.com"},{name:"Heo Sangmin",email:"heo@mapiacompany.com"},{name:"Jacob Heun",email:"jacobheun@gmail.com"},{name:"Jacob Heun",email:"jake@andyet.net"},{name:"Jade Meskill",email:"jade.meskill@gmail.com"},{name:"Johannes Wikner",email:"johannes.wikner@gmail.com"},{name:"Jon Schlinkert",email:"dev@sellside.com"},{name:"Jonathan",email:"jkrone@vt.edu"},{name:"João Antunes",email:"j.goncalo.antunes@gmail.com"},{name:"João Santos",email:"joaosantos15@users.noreply.github.com"},{name:"Kevin Wang",email:"kevin@fossa.io"},{name:"Lars Gierth",email:"larsg@systemli.org"},{name:"Lukas Drgon",email:"lukas.drgon@gmail.com"},{name:"Maciej Krüger",email:"mkg20001@gmail.com"},{name:"Marius Darila",email:"marius.darila@gmail.com"},{name:"Michelle Lee",email:"michelle@protocol.ai"},{name:"Mikeal Rogers",email:"mikeal.rogers@gmail.com"},{name:"Mithgol",email:"getgit@mithgol.ru"},{name:"My9Bot",email:"34904312+My9Bot@users.noreply.github.com"},{name:"Nuno Nogueira",email:"nunofmn@gmail.com"},{name:"Oskar Nyberg",email:"oskar@oskarnyberg.com"},{name:"Pascal Precht",email:"pascal.precht@googlemail.com"},{name:"Pau Ramon Revilla",email:"masylum@gmail.com"},{name:"Paulo Rodrigues",email:"me@paulogr.com"},{name:"Pedro Teixeira",email:"i@pgte.me"},{name:"RasmusErik Voel Jensen",email:"github@solsort.com"},{name:"Richard Littauer",email:"richard.littauer@gmail.com"},{name:"Richard Schneider",email:"makaretu@gmail.com"},{name:"Rob Brackett",email:"rob@robbrackett.com"},{name:"Rod Keys",email:"rod@zokos.com"},{name:"Sangwon Hong",email:"qpakzk@gmail.com"},{name:"Sid Harder",email:"sideharder@gmail.com"},{name:"SidHarder",email:"softwarenavigator@gmail.com"},{name:"Stephen Whitmore",email:"stephen.whitmore@gmail.com"},{name:"Stephen Whitmore",email:"noffle@users.noreply.github.com"},{name:"Terence Pae",email:"terencepae@gmail.com"},{name:"Uroš Jurglič",email:"jurglic@gmail.com"},{name:"Vasco Santos",email:"vasco.santos@ua.pt"},{name:"Vasco Santos",email:"vasco.santos@moxy.studio"},{name:"Volker Mische",email:"volker.mische@gmail.com"},{name:"Xiao Liang",email:"yxliang01@users.noreply.github.com"},{name:"Yahya",email:"ya7yaz@gmail.com"},{name:"bitspill",email:"bitspill+github@bitspill.net"},{name:"haad",email:"haad@headbanggames.com"},{name:"jbenet",email:"juan@benet.ai"},{name:"jonahweissman",email:"19804455+jonahweissman@users.noreply.github.com"},{name:"kevingzhang",email:"kevin.zhang.canada@gmail.com"},{name:"kumavis",email:"kumavis@users.noreply.github.com"},{name:"nginnever",email:"ginneversource@gmail.com"},{name:"npmcdn-to-unpkg-bot",email:"npmcdn-to-unpkg-bot@users.noreply.github.com"},{name:"seungwon-kang",email:"ksw3894@gmail.com"},{name:"tcme",email:"hi@this-connect.me"},{name:"Łukasz Magiera",email:"magik6k@users.noreply.github.com"},{name:"ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ",email:"victorbjelkholm@gmail.com"}],dependencies:{"@nodeutils/defaults-deep":"^1.1.0",async:"^2.6.1","big.js":"^5.1.2","binary-querystring":"~0.1.2",bl:"^2.0.1",boom:"^7.2.0",bs58:"^4.0.1",byteman:"^1.3.5",cids:"~0.5.3",debug:"^3.1.0","file-type":"^8.0.0",filesize:"^3.6.1",fnv1a:"^1.0.1","fsm-event":"^2.1.0","get-folder-size":"^2.0.0",glob:"^7.1.2",hapi:"^16.6.2","hapi-set-header":"^1.0.2",hoek:"^5.0.3","human-to-milliseconds":"^1.0.0","interface-datastore":"~0.4.2","ipfs-api":"^22.2.1","ipfs-bitswap":"~0.20.2","ipfs-block":"~0.7.1","ipfs-block-service":"~0.14.0","ipfs-http-response":"~0.1.2","ipfs-mfs":"~0.2.2","ipfs-multipart":"~0.1.0","ipfs-repo":"~0.22.1","ipfs-unixfs":"~0.1.15","ipfs-unixfs-engine":"~0.31.3",ipld:"~0.17.3","ipld-dag-cbor":"~0.12.1","ipld-dag-pb":"~0.14.5","is-ipfs":"~0.3.2","is-pull-stream":"~0.0.0","is-stream":"^1.1.0",joi:"^13.4.0","joi-browser":"^13.4.0","joi-multiaddr":"^2.0.0",libp2p:"~0.22.0","libp2p-bootstrap":"~0.9.3","libp2p-circuit":"~0.2.0","libp2p-floodsub":"~0.15.0","libp2p-kad-dht":"~0.10.0","libp2p-keychain":"~0.3.1","libp2p-mdns":"~0.12.0","libp2p-mplex":"~0.8.0","libp2p-secio":"~0.10.0","libp2p-tcp":"~0.12.0","libp2p-webrtc-star":"~0.15.3","libp2p-websocket-star":"~0.8.1","libp2p-websockets":"~0.12.0",lodash:"^4.17.10",mafmt:"^6.0.0","mime-types":"^2.1.18",mkdirp:"~0.5.1",multiaddr:"^5.0.0","multiaddr-to-uri":"^4.0.0",multibase:"~0.4.0",multihashes:"~0.4.13",once:"^1.4.0","path-exists":"^3.0.0","peer-book":"~0.8.0","peer-id":"~0.11.0","peer-info":"~0.14.1",progress:"^2.0.0","prom-client":"^11.1.1","prometheus-gc-stats":"~0.5.1","promisify-es6":"^1.0.3","pull-abortable":"^4.1.1","pull-defer":"~0.2.2","pull-file":"^1.1.0","pull-ndjson":"~0.1.1","pull-paramap":"^1.2.2","pull-pushable":"^2.2.0","pull-sort":"^1.0.1","pull-stream":"^3.6.8","pull-stream-to-stream":"^1.3.4","pull-zip":"^2.0.1","read-pkg-up":"^4.0.0","readable-stream":"2.3.6","stream-to-pull-stream":"^1.7.2","tar-stream":"^1.6.1",temp:"~0.8.3",through2:"^2.0.3","update-notifier":"^2.5.0",yargs:"^12.0.1","yargs-parser":"^10.1.0","yargs-promise":"^1.1.0"},deprecated:!1,description:"JavaScript implementation of the IPFS specification",devDependencies:{aegir:"^15.0.0","buffer-loader":"~0.0.1",chai:"^4.1.2",delay:"^3.0.0","detect-node":"^2.0.3","dir-compare":"^1.4.0","dirty-chai":"^2.0.1","eslint-plugin-react":"^7.10.0",execa:"~0.10.0","expose-loader":"~0.7.5","form-data":"^2.3.2",hat:"0.0.3","interface-ipfs-core":"~0.72.0","ipfsd-ctl":"~0.37.5",mocha:"^5.2.0",ncp:"^2.0.0",nexpect:"~0.5.0","pretty-bytes":"^5.1.0",qs:"^6.5.2","random-fs":"^1.0.3",rimraf:"^2.6.2","stream-to-promise":"^2.2.0","transform-loader":"~0.2.4"},engines:{node:">=6.0.0",npm:">=3.0.0"},homepage:"https://github.com/ipfs/js-ipfs#readme",keywords:["IPFS"],leadMaintainer:"Alan Shaw ",license:"MIT",main:"src/core/index.js",name:"ipfs",optionalDependencies:{"prom-client":"^11.1.1","prometheus-gc-stats":"~0.5.1"},repository:{type:"git",url:"git+https://github.com/ipfs/js-ipfs.git"},scripts:{benchmark:'echo "Error: no benchmarks yet" && exit 1',"benchmark:browser":'echo "Error: no benchmarks yet" && exit 1',"benchmark:node":'echo "Error: no benchmarks yet" && exit 1',"benchmark:node:core":'echo "Error: no benchmarks yet" && exit 1',"benchmark:node:http":'echo "Error: no benchmarks yet" && exit 1',build:"aegir build",coverage:"aegir coverage","coverage-publish":"aegir-coverage publish",lint:"aegir lint",release:"aegir release -t node -t browser","release-major":"aegir release --type major -t node -t browser","release-minor":"aegir release --type minor -t node -t browser",test:"aegir test -t node -t browser -t webworker --no-cors","test:bootstrapers":"IPFS_TEST=bootstrapers aegir test -t browser -f test/bootstrapers.js","test:browser":"aegir test -t browser --no-cors","test:node":"aegir test -t node","test:node:cli":"aegir test -t node -f test/cli/index.js","test:node:core":"aegir test -t node -f test/core/**/*.js","test:node:gateway":"aegir test -t node -f test/gateway/index.js","test:node:http":"aegir test -t node -f test/http-api/index.js","test:webworker":"aegir test -t webworker --no-cors"},version:"0.30.1"}},function(e,t,r){"use strict";const n=r(23),i=r(155).repoVersion;e.exports=function(e){return{init:(e,t,r)=>{},version:n(t=>{e._repo._isInitialized(r=>{if(r){return[/Key not found in database \[\/version\]/,/ENOENT/,/repo is not initialized yet/].some(e=>e.test(r.message))?t(null,i):t(r)}e._repo.version.get(t)})}),gc:n((e,t)=>{"function"==typeof e&&(t=e,e={}),t(new Error("Not implemented"))}),stat:n((t,r)=>{"function"==typeof t&&(r=t,t={}),e._repo.stat(t,(e,t)=>{if(e)return r(e);r(null,{numObjects:t.numObjects,repoSize:t.repoSize,repoPath:t.repoPath,version:t.version.toString(),storageMax:t.storageMax})})}),path:()=>e._repo.path}}},function(e,t,r){"use strict";e.exports=(()=>({Addresses:{Swarm:[],API:"",Gateway:""},Discovery:{MDNS:{Enabled:!1,Interval:10},webRTCStar:{Enabled:!0}},Bootstrap:["/dns4/ams-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd","/dns4/lon-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3","/dns4/sfo-3.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM","/dns4/sgp-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu","/dns4/nyc-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm","/dns4/nyc-2.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64","/dns4/wss0.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic","/dns4/wss1.bootstrap.libp2p.io/tcp/443/wss/ipfs/Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6","/dns4/node0.preload.ipfs.io/tcp/443/wss/ipfs/QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic","/dns4/node1.preload.ipfs.io/tcp/443/wss/ipfs/Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6"]}))},function(e,t,r){"use strict";const n=r(1081),i=r(78),o=r(62),s=r(1090),a=r(47).Connection,u=r(1092),c=r(1)("libp2p:websockets:dialer"),f=r(1093);e.exports=o(class{dial(e,t,r){"function"==typeof t&&(r=t,t={}),r=r||function(){};const i=u(e);c("dialing %s",i);const o=n(i,{binary:!0,onConnect:e=>{r(e)}}),s=new a(o);return s.getObservedAddrs=(t=>t(null,[e])),s.close=(e=>o.close(e)),s}createListener(e,t){return"function"==typeof e&&(t=e,e={}),f(e,t)}filter(e){return Array.isArray(e)||(e=[e]),e.filter(e=>!s(e.protoNames(),"p2p-circuit")&&(s(e.protoNames(),"ipfs")&&(e=e.decapsulate("ipfs")),i.WebSockets.matches(e)||i.WebSocketsSecure.matches(e)))}},{className:"WebSockets",symbolName:"@libp2p/js-libp2p-websockets/websockets"})},function(e,t,r){var n=r(1095),i=r(281),o=r(517),s=r(1)("socket.io-client");e.exports=t=u;var a=t.managers={};function u(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};var r,i=n(e),u=i.source,c=i.id,f=i.path,l=a[c]&&f in a[c].nsps;return t.forceNew||t["force new connection"]||!1===t.multiplex||l?(s("ignoring socket cache for %s",u),r=o(u,t)):(a[c]||(s("new io instance for %s",u),a[c]=o(u,t)),r=a[c]),i.query&&!t.query&&(t.query=i.query),r.socket(i.path,t)}t.protocol=i.protocol,t.connect=u,t.Manager=r(517),t.Socket=r(522)},function(e,t){var r=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,n=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];e.exports=function(e){var t=e,i=e.indexOf("["),o=e.indexOf("]");-1!=i&&-1!=o&&(e=e.substring(0,i)+e.substring(i,o).replace(/:/g,";")+e.substring(o,e.length));for(var s=r.exec(e||""),a={},u=14;u--;)a[n[u]]=s[u]||"";return-1!=i&&-1!=o&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a}},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t,r){(function(t){e.exports=function(e){return r&&t.Buffer.isBuffer(e)||n&&(e instanceof t.ArrayBuffer||i(e))};var r="function"==typeof t.Buffer&&"function"==typeof t.Buffer.isBuffer,n="function"==typeof t.ArrayBuffer,i=n&&"function"==typeof t.ArrayBuffer.isView?t.ArrayBuffer.isView:function(e){return e.buffer instanceof t.ArrayBuffer}}).call(this,r(6))},function(e,t,r){var n=r(1097),i=r(522),o=r(114),s=r(281),a=r(523),u=r(524),c=r(1)("socket.io-client:manager"),f=r(262),l=r(1112),h=Object.prototype.hasOwnProperty;function p(e,t){if(!(this instanceof p))return new p(e,t);e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.nsps={},this.subs=[],this.opts=t,this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor||.5),this.backoff=new l({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this.readyState="closed",this.uri=e,this.connecting=[],this.lastPing=null,this.encoding=!1,this.packetBuffer=[];var r=t.parser||s;this.encoder=new r.Encoder,this.decoder=new r.Decoder,this.autoConnect=!1!==t.autoConnect,this.autoConnect&&this.open()}e.exports=p,p.prototype.emitAll=function(){for(var e in this.emit.apply(this,arguments),this.nsps)h.call(this.nsps,e)&&this.nsps[e].emit.apply(this.nsps[e],arguments)},p.prototype.updateSocketIds=function(){for(var e in this.nsps)h.call(this.nsps,e)&&(this.nsps[e].id=this.generateId(e))},p.prototype.generateId=function(e){return("/"===e?"":e+"#")+this.engine.id},o(p.prototype),p.prototype.reconnection=function(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection},p.prototype.reconnectionAttempts=function(e){return arguments.length?(this._reconnectionAttempts=e,this):this._reconnectionAttempts},p.prototype.reconnectionDelay=function(e){return arguments.length?(this._reconnectionDelay=e,this.backoff&&this.backoff.setMin(e),this):this._reconnectionDelay},p.prototype.randomizationFactor=function(e){return arguments.length?(this._randomizationFactor=e,this.backoff&&this.backoff.setJitter(e),this):this._randomizationFactor},p.prototype.reconnectionDelayMax=function(e){return arguments.length?(this._reconnectionDelayMax=e,this.backoff&&this.backoff.setMax(e),this):this._reconnectionDelayMax},p.prototype.timeout=function(e){return arguments.length?(this._timeout=e,this):this._timeout},p.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()},p.prototype.open=p.prototype.connect=function(e,t){if(c("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;c("opening %s",this.uri),this.engine=n(this.uri,this.opts);var r=this.engine,i=this;this.readyState="opening",this.skipReconnect=!1;var o=a(r,"open",function(){i.onopen(),e&&e()}),s=a(r,"error",function(t){if(c("connect_error"),i.cleanup(),i.readyState="closed",i.emitAll("connect_error",t),e){var r=new Error("Connection error");r.data=t,e(r)}else i.maybeReconnectOnOpen()});if(!1!==this._timeout){var u=this._timeout;c("connect attempt will timeout after %d",u);var f=setTimeout(function(){c("connect attempt timed out after %d",u),o.destroy(),r.close(),r.emit("error","timeout"),i.emitAll("connect_timeout",u)},u);this.subs.push({destroy:function(){clearTimeout(f)}})}return this.subs.push(o),this.subs.push(s),this},p.prototype.onopen=function(){c("open"),this.cleanup(),this.readyState="open",this.emit("open");var e=this.engine;this.subs.push(a(e,"data",u(this,"ondata"))),this.subs.push(a(e,"ping",u(this,"onping"))),this.subs.push(a(e,"pong",u(this,"onpong"))),this.subs.push(a(e,"error",u(this,"onerror"))),this.subs.push(a(e,"close",u(this,"onclose"))),this.subs.push(a(this.decoder,"decoded",u(this,"ondecoded")))},p.prototype.onping=function(){this.lastPing=new Date,this.emitAll("ping")},p.prototype.onpong=function(){this.emitAll("pong",new Date-this.lastPing)},p.prototype.ondata=function(e){this.decoder.add(e)},p.prototype.ondecoded=function(e){this.emit("packet",e)},p.prototype.onerror=function(e){c("error",e),this.emitAll("error",e)},p.prototype.socket=function(e,t){var r=this.nsps[e];if(!r){r=new i(this,e,t),this.nsps[e]=r;var n=this;r.on("connecting",o),r.on("connect",function(){r.id=n.generateId(e)}),this.autoConnect&&o()}function o(){~f(n.connecting,r)||n.connecting.push(r)}return r},p.prototype.destroy=function(e){var t=f(this.connecting,e);~t&&this.connecting.splice(t,1),this.connecting.length||this.close()},p.prototype.packet=function(e){c("writing packet %j",e);var t=this;e.query&&0===e.type&&(e.nsp+="?"+e.query),t.encoding?t.packetBuffer.push(e):(t.encoding=!0,this.encoder.encode(e,function(r){for(var n=0;n0&&!this.encoding){var e=this.packetBuffer.shift();this.packet(e)}},p.prototype.cleanup=function(){c("cleanup");for(var e=this.subs.length,t=0;t=this._reconnectionAttempts)c("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var t=this.backoff.duration();c("will wait %dms before reconnect attempt",t),this.reconnecting=!0;var r=setTimeout(function(){e.skipReconnect||(c("attempting reconnect"),e.emitAll("reconnect_attempt",e.backoff.attempts),e.emitAll("reconnecting",e.backoff.attempts),e.skipReconnect||e.open(function(t){t?(c("reconnect attempt error"),e.reconnecting=!1,e.reconnect(),e.emitAll("reconnect_error",t.data)):(c("reconnect success"),e.onreconnect())}))},t);this.subs.push({destroy:function(){clearTimeout(r)}})}},p.prototype.onreconnect=function(){var e=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",e)}},function(e,t,r){(function(e){var n=r(282),i=r(1100),o=r(1108),s=r(1109);t.polling=function(t){var r=!1,s=!1,a=!1!==t.jsonp;if(e.location){var u="https:"===location.protocol,c=location.port;c||(c=u?443:80),r=t.hostname!==location.hostname||c!==t.port,s=t.secure!==u}if(t.xdomain=r,t.xscheme=s,"open"in new n(t)&&!t.forceJSONP)return new i(t);if(!a)throw new Error("JSONP disabled");return new o(t)},t.websocket=s}).call(this,r(6))},function(e,t,r){var n=r(283),i=r(189),o=r(115),s=r(190),a=r(521),u=r(1)("engine.io-client:polling");e.exports=f;var c=null!=new(r(282))({xdomain:!1}).responseType;function f(e){var t=e&&e.forceBase64;c&&!t||(this.supportsBinary=!1),n.call(this,e)}s(f,n),f.prototype.name="polling",f.prototype.doOpen=function(){this.poll()},f.prototype.pause=function(e){var t=this;function r(){u("paused"),t.readyState="paused",e()}if(this.readyState="pausing",this.polling||!this.writable){var n=0;this.polling&&(u("we are currently polling - waiting to pause"),n++,this.once("pollComplete",function(){u("pre-pause polling complete"),--n||r()})),this.writable||(u("we are currently writing - waiting to pause"),n++,this.once("drain",function(){u("pre-pause writing complete"),--n||r()}))}else r()},f.prototype.poll=function(){u("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},f.prototype.onData=function(e){var t=this;u("polling got data %s",e);o.decodePayload(e,this.socket.binaryType,function(e,r,n){if("opening"===t.readyState&&t.onOpen(),"close"===e.type)return t.onClose(),!1;t.onPacket(e)}),"closed"!==this.readyState&&(this.polling=!1,this.emit("pollComplete"),"open"===this.readyState?this.poll():u('ignoring poll - transport state "%s"',this.readyState))},f.prototype.doClose=function(){var e=this;function t(){u("writing close packet"),e.write([{type:"close"}])}"open"===this.readyState?(u("transport open - closing"),t()):(u("transport not open - deferring close"),this.once("open",t))},f.prototype.write=function(e){var t=this;this.writable=!1;var r=function(){t.writable=!0,t.emit("drain")};o.encodePayload(e,this.supportsBinary,function(e){t.doWrite(e,r)})},f.prototype.uri=function(){var e=this.query||{},t=this.secure?"https":"http",r="";return!1!==this.timestampRequests&&(e[this.timestampParam]=a()),this.supportsBinary||e.sid||(e.b64=1),e=i.encode(e),this.port&&("https"===t&&443!==Number(this.port)||"http"===t&&80!==Number(this.port))&&(r=":"+this.port),e.length&&(e="?"+e),t+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+r+this.path+e}},function(e,t,r){(function(t){var n=r(1102),i=Object.prototype.toString,o="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===i.call(Blob),s="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===i.call(File);e.exports=function e(r){if(!r||"object"!=typeof r)return!1;if(n(r)){for(var i=0,a=r.length;i0);return t}function f(){var e=c(+new Date);return e!==n?(a=0,n=e):e+"."+c(a++)}for(;u{n(i.subtle.sign({name:"HMAC"},t,r).then(t=>e.from(t)),o)};t.create=function(e,t,r){const u=s[e];n(i.subtle.importKey("raw",t,{name:"HMAC",hash:{name:u}},!1,["sign"]).then(t=>({digest(e,r){a(t,e,r)},length:o[e]})),r)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(12),i=r(1121);function o(e,t,r,i){if("function"==typeof r&&(i=r,r=void 0),!i)throw new Error("Missing callback");o.digest(e,t,r,(e,o)=>{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){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(284),i=r(285)();function o(e){return Promise.all([i.subtle.exportKey("jwk",e.privateKey),i.subtle.exportKey("jwk",e.publicKey)])}t.utils=r(1124),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(o).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"]);n(Promise.all([r,function(e){return i.subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}(e)]).then(e=>o({privateKey:e[0],publicKey:e[1]})).then(e=>({privateKey:e[0],publicKey:e[1]})),t)},t.getRandomValues=function(t){return e.from(i.getRandomValues(t))},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)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(15).bignum;t.toBase64=function(t,r){return t.toArrayLike(e,"be",r).toString("base64").replace(/(=*)$/,"").replace(/\+/g,"-").replace(/\//g,"_")},t.toBn=function(t){return new n(e.from(t,"base64"))}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(528);e.exports=function(e){if(!e||"number"!=typeof e)throw new Error("first argument must be a Number bigger than 0");return n.getRandomValues(new Uint8Array(e))}},function(e,t){e.exports=function(e){!function t(){var r=!0,n=!1;do{n=!0,r=!1,e.call(this,function(){n?r=!0:t()}),n=!1}while(r)}()}},function(e,t,r){"use strict";(function(n){const i=r(12),o=r(1135),s=r(17),a=r(4);class u{constructor(e,t,r){s(n.isBuffer(e),"invalid id provided"),t&&r&&s(t.public.bytes.equals(r.bytes),"inconsistent arguments"),this._id=e,this._idB58String=i.toB58String(this.id),this._privKey=t,this._pubKey=r}get id(){return this._id}set id(e){throw new Error("Id is immutable")}get privKey(){return this._privKey}set privKey(e){this._privKey=e}get pubKey(){return this._pubKey?this._pubKey:this._privKey?this._privKey.public:void 0}set pubKey(e){this._pubKey=e}marshalPubKey(){if(this.pubKey)return o.keys.marshalPublicKey(this.pubKey)}marshalPrivKey(){if(this.privKey)return o.keys.marshalPrivateKey(this.privKey)}toPrint(){return this.toJSON()}toJSON(){return{id:this.toB58String(),privKey:c(this.marshalPrivKey()),pubKey:c(this.marshalPubKey())}}toHexString(){return i.toHexString(this.id)}toBytes(){return this.id}toB58String(){return this._idB58String}isEqual(e){if(n.isBuffer(e))return this.id.equals(e);if(e.id)return this.id.equals(e.id);throw new Error("not valid Id")}isValid(e){this.privKey&&this.privKey.public&&this.privKey.public.bytes&&n.isBuffer(this.pubKey.bytes)&&this.privKey.public.bytes.equals(this.pubKey.bytes)?e():e(new Error("Keys not match"))}}function c(e){if(e)return e.toString("base64")}(t=e.exports=u).create=function(e,t){"function"==typeof e&&(t=e,e={}),(e=e||{}).bits=e.bits||2048,a([t=>o.keys.generateKeyPair("RSA",e.bits,t),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n))})},t.createFromHexString=function(e){return new u(i.fromHexString(e))},t.createFromBytes=function(e){return new u(e)},t.createFromB58String=function(e){return new u(i.fromB58String(e))},t.createFromPubKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r;try{let i=e;if("string"==typeof i&&(i=n.from(e,"base64")),!n.isBuffer(i))throw new Error("Supplied key is neither a base64 string nor a buffer");r=o.keys.unmarshalPublicKey(i)}catch(e){return t(e)}r.hash((e,n)=>{if(e)return t(e);t(null,new u(n,null,r))})},t.createFromPrivKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r=e;try{if("string"==typeof r&&(r=n.from(e,"base64")),!n.isBuffer(r))throw new Error("Supplied key is neither a base64 string nor a buffer")}catch(e){return t(e)}a([e=>o.keys.unmarshalPrivateKey(r,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n,n.public))})},t.createFromJSON=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r,s,c,f;try{r=i.fromB58String(e.id),s=e.privKey&&n.from(e.privKey,"base64"),c=e.pubKey&&n.from(e.pubKey,"base64"),f=c&&o.keys.unmarshalPublicKey(c)}catch(e){return t(e)}s?a([e=>o.keys.unmarshalPrivateKey(s,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)}),(e,t,r)=>{f?f.hash((n,i)=>{r(n,e,t,i)}):r(null,e,t)}],(e,n,i,o)=>e?t(e):f&&!n.equals(o)?t(new Error("Public and private key do not match")):r&&!n.equals(r)?t(new Error("Id and private key do not match")):void t(null,new u(r,i,f))):t(null,new u(r,null,f))},t.isPeerId=function(e){return Boolean("object"==typeof e&&e._id&&e._idB58String)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(287),i=r(288)(),o=r(1136),s={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"},a=(t,r,o)=>{n(i.subtle.sign({name:"HMAC"},t,r).then(t=>e.from(t)),o)};t.create=function(e,t,r){const u=s[e];n(i.subtle.importKey("raw",t,{name:"HMAC",hash:{name:u}},!1,["sign"]).then(t=>({digest(e,r){a(t,e,r)},length:o[e]})),r)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(12),i=r(1141);function o(e,t,r,i){if("function"==typeof r&&(i=r,r=void 0),!i)throw new Error("Missing callback");o.digest(e,t,r,(e,o)=>{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){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(287),i=r(288)();function o(e){return Promise.all([i.subtle.exportKey("jwk",e.privateKey),i.subtle.exportKey("jwk",e.publicKey)])}t.utils=r(1144),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(o).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"]);n(Promise.all([r,function(e){return i.subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}(e)]).then(e=>o({privateKey:e[0],publicKey:e[1]})).then(e=>({privateKey:e[0],publicKey:e[1]})),t)},t.getRandomValues=function(t){return e.from(i.getRandomValues(t))},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)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(15).bignum;t.toBase64=function(t,r){return t.toArrayLike(e,"be",r).toString("base64").replace(/(=*)$/,"").replace(/\+/g,"-").replace(/\//g,"_")},t.toBn=function(t){return new n(e.from(t,"base64"))}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(536);e.exports=function(e){if(!e||"number"!=typeof e)throw new Error("first argument must be a Number bigger than 0");return n.getRandomValues(new Uint8Array(e))}},function(e,t,r){"use strict";(function(n){const i=r(52),o=r(532),s=r(111),a=r(78);const u={string:e=>"string"==typeof e,object:e=>"object"==typeof e,multiaddr:e=>{if(u.string(e))try{return i(e),!0}catch(e){return!1}},function:e=>"function"==typeof e};function c(e,t){if(!Array.isArray(t))throw new Error("Data is not an array");e.forEach((e,r)=>{if(!u[e])throw console.error("Type %s does not exist",e),new Error("Type "+e+" does not exist");if(!u[e](t[r]))throw new Error("Data at index "+r+" is invalid for type "+e)})}(t=e.exports).cleanUrlSIO=function(e){const t=e.protos(),r=t[0].name,n=t[1].name,i=t[2].name,o=e.stringTuples(),s=o[1][1];if("tcp"!==n||"ws"!==i&&"wss"!==i)throw new Error("invalid multiaddr: "+e.toString());let a=o[0][1];"ip6"===r&&(a="["+a+"]");let u="ws"===i&&80===s||"wss"===i&&443===s?"":s;return("wss"===i?"https":"http")+"://"+a+(u?":"+u:"")},t.validate=c,t.Protocol=function(e){e||(e=(()=>{}));const t=this;t.requests={},t.addRequest=((e,r,n)=>{t.requests[e]={def:r,handle:n}}),t.handleSocket=(r=>{r.r={},Object.keys(t.requests).forEach(n=>{const i=t.requests[n];r.on(n,function(){const t=[...arguments];try{c(i.def,t),t.unshift(r),i.handle.apply(null,t)}catch(i){e(i),e("peer %s has sent invalid data for request %s",r.id||"",n,t)}})})})},t.getIdAndValidate=function(e,t,r){o.createFromPubKey(n.from(e,"hex"),(i,o)=>i?r(new Error("Crypto error")):o.toB58String()!==t?r(new Error("Id is not matching")):r(null,s.keys.unmarshalPublicKey(n.from(e,"hex"))))},t.validateMa=(e=>a.WebSocketStar.matches(i(e)))}).call(this,r(0).Buffer)},function(e,t,r){var n=r(1154),i=r(220),o=i;o.v1=n,o.v4=i,e.exports=o},function(e,t,r){"use strict";e.exports="/mplex/6.7.0"},function(e,t,r){(function(t){var n=r(30),i=r(193),o=r(1162),s=function(){},a=/^v?\.0/.test(t.version),u=function(e){return"function"==typeof e},c=function(e){return!!a&&!!o&&(e instanceof(o.ReadStream||s)||e instanceof(o.WriteStream||s))&&u(e.close)},f=function(e,t,r,o){o=n(o);var a=!1;e.on("close",function(){a=!0}),i(e,{readable:t,writable:r},function(e){if(e)return o(e);a=!0,o()});var f=!1;return function(t){if(!a&&!f)return f=!0,c(e)?e.close(s):function(e){return e.setHeader&&u(e.abort)}(e)?e.abort():u(e.destroy)?e.destroy():void o(t||new Error("stream was destroyed"))}},l=function(e){e()},h=function(e,t){return e.pipe(t)};e.exports=function(){var e,t=Array.prototype.slice.call(arguments),r=u(t[t.length-1]||s)&&t.pop()||s;if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new Error("pump requires two streams per minimum");var n=t.map(function(i,o){var s=o0,function(t){e||(e=t),t&&n.forEach(l),s||(n.forEach(l),r(e))})});return t.reduce(h)}}).call(this,r(7))},function(e,t,r){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(293),i=r(294)(),o=r(1169),s={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"},a=(t,r,o)=>{n(i.subtle.sign({name:"HMAC"},t,r).then(t=>e.from(t)),o)};t.create=function(e,t,r){const u=s[e];n(i.subtle.importKey("raw",t,{name:"HMAC",hash:{name:u}},!1,["sign"]).then(t=>({digest(e,r){a(t,e,r)},length:o[e]})),r)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(293),i=r(294)();function o(e){return Promise.all([i.subtle.exportKey("jwk",e.privateKey),i.subtle.exportKey("jwk",e.publicKey)])}t.utils=r(1174),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(o).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"]);n(Promise.all([r,function(e){return i.subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}(e)]).then(e=>o({privateKey:e[0],publicKey:e[1]})).then(e=>({privateKey:e[0],publicKey:e[1]})),t)},t.getRandomValues=function(t){return e.from(i.getRandomValues(t))},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)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(15).bignum;t.toBase64=function(t,r){return t.toArrayLike(e,"be",r).toString("base64").replace(/(=*)$/,"").replace(/\+/g,"-").replace(/\//g,"_")},t.toBn=function(t){return new n(e.from(t,"base64"))}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(545);e.exports=function(e){if(!e||"number"!=typeof e)throw new Error("first argument must be a Number bigger than 0");return n.getRandomValues(new Uint8Array(e))}},function(e,t,r){"use strict";(function(e){const n=r(297),i=r(298)(),o=r(1190),s={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"},a=(t,r,o)=>{n(i.subtle.sign({name:"HMAC"},t,r).then(t=>e.from(t)),o)};t.create=function(e,t,r){const u=s[e];n(i.subtle.importKey("raw",t,{name:"HMAC",hash:{name:u}},!1,["sign"]).then(t=>({digest(e,r){a(t,e,r)},length:o[e]})),r)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(12),i=r(1195);function o(e,t,r,i){if("function"==typeof r&&(i=r,r=void 0),!i)throw new Error("Missing callback");o.digest(e,t,r,(e,o)=>{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){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(297),i=r(298)();function o(e){return Promise.all([i.subtle.exportKey("jwk",e.privateKey),i.subtle.exportKey("jwk",e.publicKey)])}t.utils=r(1198),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(o).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"]);n(Promise.all([r,function(e){return i.subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}(e)]).then(e=>o({privateKey:e[0],publicKey:e[1]})).then(e=>({privateKey:e[0],publicKey:e[1]})),t)},t.getRandomValues=function(t){return e.from(i.getRandomValues(t))},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)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(15).bignum;t.toBase64=function(t,r){return t.toArrayLike(e,"be",r).toString("base64").replace(/(=*)$/,"").replace(/\+/g,"-").replace(/\//g,"_")},t.toBn=function(t){return new n(e.from(t,"base64"))}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(551);e.exports=function(e){if(!e||"number"!=typeof e)throw new Error("first argument must be a Number bigger than 0");return n.getRandomValues(new Uint8Array(e))}},function(e,t,r){"use strict";(function(e){const n=r(301),i=r(302)(),o=r(1217),s={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"},a=(t,r,o)=>{n(i.subtle.sign({name:"HMAC"},t,r).then(t=>e.from(t)),o)};t.create=function(e,t,r){const u=s[e];n(i.subtle.importKey("raw",t,{name:"HMAC",hash:{name:u}},!1,["sign"]).then(t=>({digest(e,r){a(t,e,r)},length:o[e]})),r)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(12),i=r(1222);function o(e,t,r,i){if("function"==typeof r&&(i=r,r=void 0),!i)throw new Error("Missing callback");o.digest(e,t,r,(e,o)=>{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){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(301),i=r(302)();function o(e){return Promise.all([i.subtle.exportKey("jwk",e.privateKey),i.subtle.exportKey("jwk",e.publicKey)])}t.utils=r(1225),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(o).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"]);n(Promise.all([r,function(e){return i.subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}(e)]).then(e=>o({privateKey:e[0],publicKey:e[1]})).then(e=>({privateKey:e[0],publicKey:e[1]})),t)},t.getRandomValues=function(t){return e.from(i.getRandomValues(t))},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)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(15).bignum;t.toBase64=function(t,r){return t.toArrayLike(e,"be",r).toString("base64").replace(/(=*)$/,"").replace(/\+/g,"-").replace(/\//g,"_")},t.toBn=function(t){return new n(e.from(t,"base64"))}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(557);e.exports=function(e){if(!e||"number"!=typeof e)throw new Error("first argument must be a Number bigger than 0");return n.getRandomValues(new Uint8Array(e))}},function(e,t,r){(function(t){var r="[object AsyncFunction]",n="[object Function]",i="[object GeneratorFunction]",o="[object Null]",s="[object Proxy]",a="[object Undefined]",u="object"==typeof t&&t&&t.Object===Object&&t,c="object"==typeof self&&self&&self.Object===Object&&self,f=u||c||Function("return this")(),l=Object.prototype,h=l.hasOwnProperty,p=l.toString,d=f.Symbol,y=d?d.toStringTag:void 0;function g(e){return null==e?void 0===e?a:o:y&&y in Object(e)?function(e){var t=h.call(e,y),r=e[y];try{e[y]=void 0;var n=!0}catch(e){}var i=p.call(e);return n&&(t?e[y]=r:delete e[y]),i}(e):function(e){return p.call(e)}(e)}e.exports=function(e){if(!function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}(e))return!1;var t=g(e);return t==n||t==i||t==r||t==s}}).call(this,r(6))},function(e,t,r){"use strict";(function(t){const n=r(100),i=r(53),o=r(195).writeEncoded;e.exports=function(e,r,s){const a=n({timeout:6e4},r),u=a.handshake;return s("writing multicodec: "+e),o(u,t.from(e+"\n"),r),i.decodeFromReader(u,(t,n)=>{if(t)return r(t);const i=n.toString().slice(0,-1);if(i!==e)return r(new Error(`"${e}" not supported`),u.rest());s("received ack: "+i),r(null,u.rest())}),a}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){return function(r,o,s,a){a=a||n.default;var u,c=!1;r(o,function(r,n,o){s(r,function(n,s){n?o(n):e(s)&&!u?(c=!0,u=t(!0,r),o(null,i.default)):o()})},function(e){e?a(e):a(null,c?u:t(!1))})}};var n=o(r(54)),i=o(r(216));function o(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default},function(e,t,r){"use strict";e.exports=function(e,t,r){r(null,e===t)}},function(e,t,r){"use strict";e.exports.PROTOCOL_ID="/multistream/1.0.0"},function(e,t,r){"use strict";e.exports=r(1239)},function(e,t,r){"use strict";(function(e){const n=r(307),i=r(308)(),o=r(1244),s={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"},a=(t,r,o)=>{n(i.subtle.sign({name:"HMAC"},t,r).then(t=>e.from(t)),o)};t.create=function(e,t,r){const u=s[e];n(i.subtle.importKey("raw",t,{name:"HMAC",hash:{name:u}},!1,["sign"]).then(t=>({digest(e,r){a(t,e,r)},length:o[e]})),r)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(12),i=r(1249);function o(e,t,r,i){if("function"==typeof r&&(i=r,r=void 0),!i)throw new Error("Missing callback");o.digest(e,t,r,(e,o)=>{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){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(307),i=r(308)();function o(e){return Promise.all([i.subtle.exportKey("jwk",e.privateKey),i.subtle.exportKey("jwk",e.publicKey)])}t.utils=r(1252),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(o).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"]);n(Promise.all([r,function(e){return i.subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}(e)]).then(e=>o({privateKey:e[0],publicKey:e[1]})).then(e=>({privateKey:e[0],publicKey:e[1]})),t)},t.getRandomValues=function(t){return e.from(i.getRandomValues(t))},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)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(15).bignum;t.toBase64=function(t,r){return t.toArrayLike(e,"be",r).toString("base64").replace(/(=*)$/,"").replace(/\+/g,"-").replace(/\//g,"_")},t.toBn=function(t){return new n(e.from(t,"base64"))}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(569);e.exports=function(e){if(!e||"number"!=typeof e)throw new Error("first argument must be a Number bigger than 0");return n.getRandomValues(new Uint8Array(e))}},function(e,t,r){(function(e,t){!function(e,r){"use strict";if(!e.setImmediate){var n,i=1,o={},s=!1,a=e.document,u=Object.getPrototypeOf&&Object.getPrototypeOf(e);u=u&&u.setTimeout?u:e,"[object process]"==={}.toString.call(e.process)?n=function(e){t.nextTick(function(){f(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}}()?function(){var t="setImmediate$"+Math.random()+"$",r=function(r){r.source===e&&"string"==typeof r.data&&0===r.data.indexOf(t)&&f(+r.data.slice(t.length))};e.addEventListener?e.addEventListener("message",r,!1):e.attachEvent("onmessage",r),n=function(r){e.postMessage(t+r,"*")}}():e.MessageChannel?function(){var e=new MessageChannel;e.port1.onmessage=function(e){f(e.data)},n=function(t){e.port2.postMessage(t)}}():a&&"onreadystatechange"in a.createElement("script")?function(){var e=a.documentElement;n=function(t){var r=a.createElement("script");r.onreadystatechange=function(){f(t),r.onreadystatechange=null,e.removeChild(r),r=null},e.appendChild(r)}}():n=function(e){setTimeout(f,0,e)},u.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r("function"==typeof r&&(i=r,r=void 0),n(()=>i()),t)}},function(e,t,r){"use strict";const n=r(1282),i=r(51),o=r(52);e.exports=function(e,t){let r;if(i.isPeerInfo(e))return e;if(o.isMultiaddr(e)){const o=e.getPeerId();try{r=t.get(o)}catch(e){r=new i(n.createFromB58String(o))}return r.multiaddrs.add(e),r}if(n.isPeerId(e)){const r=e.toB58String();try{return t.get(r)}catch(e){throw new Error("Couldnt get PeerInfo")}}throw new Error("peer type not recognized")}},function(e,t,r){"use strict";(function(e){const n=r(314),i=r(315)(),o=r(1284),s={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"},a=(t,r,o)=>{n(i.subtle.sign({name:"HMAC"},t,r).then(t=>e.from(t)),o)};t.create=function(e,t,r){const u=s[e];n(i.subtle.importKey("raw",t,{name:"HMAC",hash:{name:u}},!1,["sign"]).then(t=>({digest(e,r){a(t,e,r)},length:o[e]})),r)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(12),i=r(1289);function o(e,t,r,i){if("function"==typeof r&&(i=r,r=void 0),!i)throw new Error("Missing callback");o.digest(e,t,r,(e,o)=>{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){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(314),i=r(315)();function o(e){return Promise.all([i.subtle.exportKey("jwk",e.privateKey),i.subtle.exportKey("jwk",e.publicKey)])}t.utils=r(1292),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(o).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"]);n(Promise.all([r,function(e){return i.subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}(e)]).then(e=>o({privateKey:e[0],publicKey:e[1]})).then(e=>({privateKey:e[0],publicKey:e[1]})),t)},t.getRandomValues=function(t){return e.from(i.getRandomValues(t))},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)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(15).bignum;t.toBase64=function(t,r){return t.toArrayLike(e,"be",r).toString("base64").replace(/(=*)$/,"").replace(/\+/g,"-").replace(/\//g,"_")},t.toBn=function(t){return new n(e.from(t,"base64"))}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(581);e.exports=function(e){if(!e||"number"!=typeof e)throw new Error("first argument must be a Number bigger than 0");return n.getRandomValues(new Uint8Array(e))}},function(e,t,r){"use strict";const n=r(47).Connection,i=r(8);e.exports=((e,t,r,o)=>{const s=new Promise((e,t)=>{r.getPeerInfo((t,n)=>{if(!t&&n)return void e(n);const i=r.setPeerInfo;r.setPeerInfo=(t=>{i.call(r,t),e(t)})})}),a={source:i(r,o.incoming(e,t,s)),sink:i(o.outgoing(e,t,s),r)};return new n(a,r)})},function(e,t,r){var n=r(1314);e.exports=function(e,t,r){var i=null==e?void 0:n(e,t);return void 0===i?r:i}},function(e,t,r){(function(n){function i(){var e;try{e=t.storage.debug}catch(e){}return!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG),e}(t=e.exports=r(1344)).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var r=this.useColors;if(e[0]=(r?"%c":"")+this.namespace+(r?" %c":" ")+e[0]+(r?"%c ":" ")+"+"+t.humanize(this.diff),r){var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var i=0,o=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&"%c"===e&&(o=++i)}),e.splice(o,0,n)}},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=i,t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(i())}).call(this,r(7))},function(e,t,r){"use strict";const n=r(10),i=n(r(1354)),o=n(r(1355));(t=e.exports).rpc=i,t.td=o},function(e,t,r){"use strict";(function(e){const n=r(319),i=r(320)(),o=r(1361),s={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"},a=(t,r,o)=>{n(i.subtle.sign({name:"HMAC"},t,r).then(t=>e.from(t)),o)};t.create=function(e,t,r){const u=s[e];n(i.subtle.importKey("raw",t,{name:"HMAC",hash:{name:u}},!1,["sign"]).then(t=>({digest(e,r){a(t,e,r)},length:o[e]})),r)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(12),i=r(1366);function o(e,t,r,i){if("function"==typeof r&&(i=r,r=void 0),!i)throw new Error("Missing callback");o.digest(e,t,r,(e,o)=>{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){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(319),i=r(320)();function o(e){return Promise.all([i.subtle.exportKey("jwk",e.privateKey),i.subtle.exportKey("jwk",e.publicKey)])}t.utils=r(1369),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(o).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"]);n(Promise.all([r,function(e){return i.subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}(e)]).then(e=>o({privateKey:e[0],publicKey:e[1]})).then(e=>({privateKey:e[0],publicKey:e[1]})),t)},t.getRandomValues=function(t){return e.from(i.getRandomValues(t))},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)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(15).bignum;t.toBase64=function(t,r){return t.toArrayLike(e,"be",r).toString("base64").replace(/(=*)$/,"").replace(/\+/g,"-").replace(/\//g,"_")},t.toBn=function(t){return new n(e.from(t,"base64"))}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(591);e.exports=function(e){if(!e||"number"!=typeof e)throw new Error("first argument must be a Number bigger than 0");return n.getRandomValues(new Uint8Array(e))}},function(e,t,r){"use strict";var n=r(1377);e.exports=function(){var e={};return n.toArray(arguments).reverse().forEach(function(t){n.mergeWith(e,t,function(e,t){return n.isArray(t)?t:void 0})}),e}},function(e,t){e.exports=function(e){var t,r,n;function i(e){return r=e,function(e,i){n?t=[e,i]:r(e,i)}}return i.pause=function(){n||(n=!0,e&&e(n))},i.resume=function(){if(n&&(n=!1,e&&e(n),t)){var i=t;t=null,r(i[0],i[1])}},i}},function(e,t,r){"use strict";var n=e.exports=function(e){return null!==e&&"object"==typeof e&&"function"==typeof e.pipe};n.writable=function(e){return n(e)&&!1!==e.writable&&"function"==typeof e._write&&"object"==typeof e._writableState},n.readable=function(e){return n(e)&&!1!==e.readable&&"function"==typeof e._read&&"object"==typeof e._readableState},n.duplex=function(e){return n.writable(e)&&n.readable(e)},n.transform=function(e){return n.duplex(e)&&"function"==typeof e._transform&&"object"==typeof e._transformState}},function(e,t){function r(e){return"function"==typeof e}function n(e){return r(e)&&2===e.length}function i(e){return r(e)&&1===e.length}t.isDuplex=function(e){return"object"==typeof e&&n(e.source)&&i(e.sink)},t.isSource=n,t.isSink=i},function(e,t,r){"use strict";const n=r(200).OFFLINE_ERROR,i=r(23),o=r(3),s=r(122),a=r(9),u=r(110);function c(e){return Array.from(e).map(e=>({"/":e[1].cid.toBaseEncodedString()}))}e.exports=function(e){return{wantlist:i((t,r)=>{if(r||(r=t,t=void 0),!e.isOnline())return o(()=>r(new Error(n)));let i;if(t){try{t=u.createFromB58String(t)}catch(e){t=null}if(!t)return o(()=>r(new Error("Invalid peerId")));i=e._bitswap.wantlistForPeer(t)}else i=e._bitswap.getWantlist();return i=c(i),o(()=>r(null,{Keys:i}))}),stat:i(t=>{if(!e.isOnline())return o(()=>t(new Error(n)));const r=e._bitswap.stat().snapshot;t(null,{provideBufLen:parseInt(r.providesBufferLength.toString()),blocksReceived:new s(r.blocksReceived),wantlist:c(e._bitswap.getWantlist()),peers:e._bitswap.peers().map(e=>e.toB58String()),dupBlksReceived:new s(r.dupBlksReceived),dupDataReceived:new s(r.dupDataReceived),dataReceived:new s(r.dataReceived),blocksSent:new s(r.blocksSent),dataSent:new s(r.dataSent)})}),unwant:i((t,r)=>e.isOnline()?(Array.isArray(t)||(t=[t]),t=t.map(e=>a.isCID(e)?e:new a(e)),o(()=>r(null,e._bitswap.unwant(t)))):o(()=>r(new Error(n))))}}},function(e,t,r){"use strict";e.exports=r(1437)},function(e,t){e.exports={WORKER_REQUEST_READ_LOCK:"lock:worker:request-read",WORKER_RELEASE_READ_LOCK:"lock:worker:release-read",MASTER_GRANT_READ_LOCK:"lock:master:grant-read",WORKER_REQUEST_WRITE_LOCK:"lock:worker:request-write",WORKER_RELEASE_WRITE_LOCK:"lock:worker:release-write",MASTER_GRANT_WRITE_LOCK:"lock:master:grant-write"}},function(e,t){const r={},n=e=>{e.addEventListener("message",t=>{n.dispatchEvent("message",e,t)}),e.port&&e.port.addEventListener("message",t=>{n.dispatchEvent("message",e,t)})};n.addEventListener=((e,t)=>{r[e]||(r[e]=[]),r[e].push(t)}),n.removeEventListener=((e,t)=>{r[e]&&(r[e]=r[e].filter(e=>e===t))}),n.dispatchEvent=function(){const e=Array.prototype.slice.call(arguments),t=e.shift();r[t]&&r[t].forEach(t=>t.apply(null,e))},e.exports=n},function(e,t,r){"use strict";const n=r(4),{DAGNode:i}=r(45),o={format:"dag-pb",hashAlg:"sha2-256"};e.exports=((e,t,r,s,a)=>{s=Object.assign({},o,s),n([e=>i.create(t,r,e),(t,r)=>{e.dag.put(t,{format:s.format,hashAlg:s.hashAlg},e=>r(e,t))}],a)})},function(e,t,r){"use strict";e.exports=(e=>{return e(!0)})},function(e,t,r){"use strict";const n=r(64);e.exports=function(e,t){const r=(e=e.slice()).filter(e=>"function"==typeof e).pop(),i=Object.assign({},t,e.filter(e=>"object"==typeof e).pop()||{});return Array.isArray(e[0])&&(e=e[0]),{sources:e.filter(e=>"string"==typeof e).map(e=>({path:e=e.trim(),name:n.basename(e),dir:n.dirname(e)})),options:i,callback:r}}},function(e,t,r){"use strict";const n=r(9),i=r(1)("ipfs:mfs:utils:with-mfs-root"),o=r(4),{MFS_ROOT_KEY:s}=r(146);e.exports=((e,t)=>{const r=e._repo,a=r&&r.datastore;if(!r||!a)return t(new Error("Please run jsipfs init first"));o([e=>a.open(t=>e(t)),t=>{a.get(s,(u,c)=>{if(u&&u.notFound)return i("Creating new MFS root"),o([t=>e.files.add({path:"/"},t),([{hash:e}],t)=>t(null,new n(e)),(e,t)=>r.closed?a.open(r=>t(r,e)):t(null,e),(e,t)=>a.put(s,e.buffer,r=>t(r,e))],t);t(u,new n(c))})},(e,t)=>{i(`Fetched MFS root ${e.toBaseEncodedString()}`),t(null,e)}],t)})},function(e,t,r){"use strict";const{FILE_SEPARATOR:n}=r(146);e.exports=((e,t)=>{if(!(e=(e||"").trim()))return t(new Error("paths must not be empty"));if(e.substring(0,1)!==n)return t(new Error(`paths must start with a leading ${n}`));e.substring(e.length-n.length)===n&&(e=e.substring(0,e.length-n.length));const r=e.split(n).filter(Boolean),i=r.pop(),o=`${n}${r.join(n)}`;if("/ipfs"===e.substring(0,"/ipfs".length))return t(null,{type:"ifps",path:e.substring("/ipfs".length+1),directory:o,name:i});t(null,{type:"mfs",path:e||n,directory:o,name:i})})},function(e,t,r){"use strict";const n=r(36).unmarshal,{traverseTo:i,formatCid:o}=r(48),s=r(4),a=r(1)("ipfs:mfs:stat"),u={hash:!1,size:!1,withLocal:!1,cidBase:"base58btc"};e.exports=(e=>(function(t,r,c){"function"==typeof r&&(c=r,r={}),r=Object.assign({},u,r),a(`Fetching stats for ${t}`),s([r=>i(e,t,{withCreateHint:!1},r),({node:e},t)=>{if(r.hash)return t(null,{hash:o(e.multihash,r.cidBase)});if(r.size)return t(null,{size:e.size});const i=n(e.data);let s=e.links.length;"file"===i.type&&(s=i.blockSizes.length),t(null,{hash:o(e.multihash,r.cidBase),size:i.fileSize()||0,cumulativeSize:e.size,blocks:s,type:i.type,local:void 0,sizeLocal:void 0,withLocality:!1})}],c)}))},function(e,t,r){"use strict";const n=r(4),i=r(63),o=r(49),s=r(36),{traverseTo:a,addLink:u,updateTree:c,updateMfsRoot:f,toSourcesAndDestination:l}=r(48),h=r(607),p=r(1)("ipfs:mfs:cp"),d={parents:!1,flush:!0,format:"dag-pb",hashAlg:"sha2-256"};e.exports=(e=>(function(){const t=Array.from(arguments),{sources:r,destination:n,options:i,callback:o}=l(t,d);return r.length?n?(i.parents=i.p||i.parents,void a(e,n.path,{},(t,a)=>{if(t)return 1===r.length?(p("Only one source, copying to a file"),y(e,r.pop(),n,i,o)):(p("Multiple sources, copying to a directory"),g(e,r,n,i,o));if("directory"===s.unmarshal(a.node.data).type)return g(e,r,n,i,o);o(new Error("directory already has entry by that name"))})):o(new Error("Please supply a destination")):o(new Error("Please supply at least one source"))}));const y=(e,t,r,o,s)=>{n([n=>{i([r=>h(e)(t.path,o,r),t=>h(e)(r.path,o,e=>{if(!e)return t(new Error("directory already has entry by that name"));t()}),t=>a(e,r.dir,o,t)],n)},([t,i,o],s)=>{n([n=>u(e,{parent:o.node,child:{size:t.cumulativeSize,hash:t.hash},name:r.name},n),(t,r)=>{o.node=t,c(e,o,r)},(t,r)=>f(e,t.node.multihash,r)],s)}],e=>s(e))},g=(e,t,r,s,l)=>{n([n=>{o([r=>i(t.map(t=>r=>h(e)(t.path,s,r)),r),t=>a(e,r.path,Object.assign({},s,{createLastComponent:!0}),t)],n)},(o,a)=>{const l=o.pop(),p=o[0];n([n=>{i(t.map(t=>n=>{h(e)(`${r.path}/${t.name}`,s,e=>{if(!e)return n(new Error("directory already has entry by that name"));n()})}),e=>n(e))},r=>{n([e=>e(null,l.node)].concat(p.map((r,n)=>(i,o)=>u(e,{parent:i,child:{size:r.cumulativeSize,hash:r.hash},name:t[n].name},o))),r)},(t,r)=>{l.node=t,c(e,l,r)},(t,r)=>f(e,t.node.multihash,r)],a)}],e=>l(e))}},function(e,t,r){"use strict";const n=r(36),i=r(4),o=r(49),{DAGNode:s}=r(45),a=r(9),{traverseTo:u,updateTree:c,updateMfsRoot:f,toSources:l,FILE_SEPARATOR:h}=r(48),p={recursive:!1};e.exports=(e=>(function(){const t=Array.from(arguments),{sources:r,options:n,callback:i}=l(t,p);if(!r.length)return i(new Error("Please supply at least one path to remove"));o(r.map(t=>r=>d(e,t.path,n,r)),e=>i(e))}));const d=(e,t,r,o)=>{if(t===h)return o(new Error("Cannot delete root"));i([r=>u(e,t,{withCreateHint:!1},r),(o,u)=>{if("directory"===n.unmarshal(o.node.data).type&&!r.recursive)return u(new Error(`${t} is a directory, use -r to remove directories`));i([e=>s.rmLink(o.parent.node,o.name,e),(t,r)=>{e.dag.put(t,{cid:new a(t.hash||t.multihash)},e=>r(e,t))},(t,r)=>{o.parent.node=t,c(e,o.parent,r)},(t,r)=>f(e,t.node.multihash,r)],u)}],o)}},function(e,t,r){"use strict";const n=r(4),i=r(70),o=r(86),s=r(87),a=r(145).importer,{loadNode:u}=r(48);e.exports=((e,t,r,c)=>{n([n=>i(o([{content:i(t)}]),a(e.dag,{progress:r.progress,hashAlg:r.hashAlg,cidVersion:r.cidVersion,strategy:r.strategy,rawLeaves:r.rawLeaves,reduceSingleLeafToSelf:r.reduceSingleLeafToSelf,leafType:r.leafType}),s(n)),(t,r)=>u(e,t[0],r)],c)})},function(e,t,r){(function(t){var n=r(1470).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){(function(e,r){var n=200,i="__lodash_hash_undefined__",o=9007199254740991,s="[object Arguments]",a="[object Boolean]",u="[object Date]",c="[object Function]",f="[object GeneratorFunction]",l="[object Map]",h="[object Number]",p="[object Object]",d="[object Promise]",y="[object RegExp]",g="[object Set]",m="[object String]",b="[object Symbol]",v="[object WeakMap]",_="[object ArrayBuffer]",w="[object DataView]",S="[object Float32Array]",k="[object Float64Array]",E="[object Int8Array]",A="[object Int16Array]",x="[object Int32Array]",I="[object Uint8Array]",T="[object Uint8ClampedArray]",B="[object Uint16Array]",C="[object Uint32Array]",P=/\w*$/,O=/^\[object .+?Constructor\]$/,R=/^(?:0|[1-9]\d*)$/,N={};N[s]=N["[object Array]"]=N[_]=N[w]=N[a]=N[u]=N[S]=N[k]=N[E]=N[A]=N[x]=N[l]=N[h]=N[p]=N[y]=N[g]=N[m]=N[b]=N[I]=N[T]=N[B]=N[C]=!0,N["[object Error]"]=N[c]=N[v]=!1;var L="object"==typeof e&&e&&e.Object===Object&&e,K="object"==typeof self&&self&&self.Object===Object&&self,j=L||K||Function("return this")(),M="object"==typeof t&&t&&!t.nodeType&&t,D=M&&"object"==typeof r&&r&&!r.nodeType&&r,U=D&&D.exports===M;function F(e,t){return e.set(t[0],t[1]),e}function q(e,t){return e.add(t),e}function H(e,t,r,n){var i=-1,o=e?e.length:0;for(n&&o&&(r=e[++i]);++i-1},Te.prototype.set=function(e,t){var r=this.__data__,n=Re(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Be.prototype.clear=function(){this.__data__={hash:new Ie,map:new(ye||Te),string:new Ie}},Be.prototype.delete=function(e){return Me(this,e).delete(e)},Be.prototype.get=function(e){return Me(this,e).get(e)},Be.prototype.has=function(e){return Me(this,e).has(e)},Be.prototype.set=function(e,t){return Me(this,e).set(e,t),this},Ce.prototype.clear=function(){this.__data__=new Te},Ce.prototype.delete=function(e){return this.__data__.delete(e)},Ce.prototype.get=function(e){return this.__data__.get(e)},Ce.prototype.has=function(e){return this.__data__.has(e)},Ce.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Te){var i=r.__data__;if(!ye||i.length-1&&e%1==0&&e-1&&e%1==0&&e<=o}(e.length)&&!Je(e)}var Ye=he||function(){return!1};function Je(e){var t=Xe(e)?re.call(e):"";return t==c||t==f}function Xe(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Ze(e){return $e(e)?Pe(e):function(e){if(!ze(e))return pe(e);var t=[];for(var r in Object(e))te.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}r.exports=function(e){return Ne(e,!0,!0)}}).call(this,r(6),r(27)(e))},function(e,t,r){"use strict";e.exports="ipfs-pubsub-room/v2"},function(e,t,r){"use strict";(function(t){e.exports=(e=>{let r=e;return t.isBuffer(r)||(r=t.from(r)),r})}).call(this,r(0).Buffer)},function(e,t,r){(function(t){var n=r(5),i=r(22).Transform,o=r(1514);function s(e,t){if(!(this instanceof s))return new s(e,t);i.call(this),t||(t={}),"object"==typeof e&&(e=(t=e).size),this.size=e||512,t.nopad?this._zeroPadding=!1:this._zeroPadding=o(t.zeroPadding,!0),this._buffered=[],this._bufferedBytes=0}e.exports=s,n(s,i),s.prototype._transform=function(e,r,n){for(this._bufferedBytes+=e.length,this._buffered.push(e);this._bufferedBytes>=this.size;){var i=t.concat(this._buffered);this._bufferedBytes-=this.size,this.push(i.slice(0,this.size)),this._buffered=[i.slice(this.size,i.length)]}n()},s.prototype._flush=function(){if(this._bufferedBytes&&this._zeroPadding){var e=new t(this.size-this._bufferedBytes);e.fill(0),this._buffered.push(e),this.push(t.concat(this._buffered)),this._buffered=null}else this._bufferedBytes&&(this.push(t.concat(this._buffered)),this._buffered=null);this.push(null)}}).call(this,r(0).Buffer)},function(e,t,r){e.exports=o;var n=r(5),i=r(22);function o(e,t){var r=this;if(!(r instanceof o))return new o(e,t);i.Readable.call(r,t),r.destroyed=!1,r._drained=!1,r._forwarding=!1,r._current=null,r._toStreams2=t&&t.objectMode?s:a,"function"==typeof e?r._queue=e:(r._queue=e.map(r._toStreams2),r._queue.forEach(function(e){"function"!=typeof e&&r._attachErrorListener(e)})),r._next()}function s(e){return u(e,{objectMode:!0,highWaterMark:16})}function a(e){return u(e)}function u(e,t){if(!e||"function"==typeof e||e._readableState)return e;var r=new i.Readable(t).wrap(e);return e.destroy&&(r.destroy=e.destroy.bind(e)),r}n(o,i.Readable),o.obj=function(e){return new o(e,{objectMode:!0,highWaterMark:16})},o.prototype._read=function(){this._drained=!0,this._forward()},o.prototype._forward=function(){if(!this._forwarding&&this._drained&&this._current){var e;for(this._forwarding=!0;null!==(e=this._current.read());)this._drained=this.push(e);this._forwarding=!1}},o.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,this._current&&this._current.destroy&&this._current.destroy(),"function"!=typeof this._queue&&this._queue.forEach(function(e){e.destroy&&e.destroy()}),e&&this.emit("error",e),this.emit("close"))},o.prototype._next=function(){var e=this;if(e._current=null,"function"==typeof e._queue)e._queue(function(t,r){if(t)return e.destroy(t);r=e._toStreams2(r),e._attachErrorListener(r),e._gotNextStream(r)});else{var t=e._queue.shift();"function"==typeof t&&(t=e._toStreams2(t()),e._attachErrorListener(t)),e._gotNextStream(t)}},o.prototype._gotNextStream=function(e){var t=this;if(!e)return t.push(null),void t.destroy();function r(){t._forward()}function n(){e._readableState.ended||t.destroy()}t._current=e,t._forward(),e.on("readable",r),e.once("end",function i(){t._current=null,e.removeListener("readable",r),e.removeListener("end",i),e.removeListener("close",n),t._next()}),e.once("close",n)},o.prototype._attachErrorListener=function(e){var t=this;e&&e.once("error",function r(n){e.removeListener("error",r),t.destroy(n)})}},function(e,t,r){(function(t,n){var i=r(204),o=r(1524),s=r(95),a=r(1525),u=r(1529),c=r(64),f=r(148),l=r(205);function h(e){if("string"==typeof e&&/^(stream-)?magnet:/.test(e))return u(e);if("string"==typeof e&&(/^[a-f0-9]{40}$/i.test(e)||/^[a-z2-7]{32}$/i.test(e)))return u("magnet:?xt=urn:btih:"+e);if(t.isBuffer(e)&&20===e.length)return u("magnet:?xt=urn:btih:"+e.toString("hex"));if(t.isBuffer(e))return function(e){t.isBuffer(e)&&(e=i.decode(e)),d(e.info,"info"),d(e.info["name.utf-8"]||e.info.name,"info.name"),d(e.info["piece length"],"info['piece length']"),d(e.info.pieces,"info.pieces"),e.info.files?e.info.files.forEach(function(e){d("number"==typeof e.length,"info.files[0].length"),d(e["path.utf-8"]||e.path,"info.files[0].path")}):d("number"==typeof e.info.length,"info.length");var r={};r.info=e.info,r.infoBuffer=i.encode(e.info),r.infoHash=f.sync(r.infoBuffer),r.infoHashBuffer=t.from(r.infoHash,"hex"),r.name=(e.info["name.utf-8"]||e.info.name).toString(),void 0!==e.info.private&&(r.private=!!e.info.private),e["creation date"]&&(r.created=new Date(1e3*e["creation date"])),e["created by"]&&(r.createdBy=e["created by"].toString()),t.isBuffer(e.comment)&&(r.comment=e.comment.toString()),r.announce=[],Array.isArray(e["announce-list"])&&e["announce-list"].length>0?e["announce-list"].forEach(function(e){e.forEach(function(e){r.announce.push(e.toString())})}):e.announce&&r.announce.push(e.announce.toString()),t.isBuffer(e["url-list"])&&(e["url-list"]=e["url-list"].length>0?[e["url-list"]]:[]),r.urlList=(e["url-list"]||[]).map(function(e){return e.toString()}),l(r.announce),l(r.urlList);var n=e.info.files||[e.info];r.files=n.map(function(e,t){var i=[].concat(r.name,e["path.utf-8"]||e.path||[]).map(function(e){return e.toString()});return{path:c.join.apply(null,[c.sep].concat(i)).slice(1),name:i[i.length-1],length:e.length,offset:n.slice(0,t).reduce(p,0)}}),r.length=n.reduce(p,0);var o=r.files[r.files.length-1];return r.pieceLength=e.info["piece length"],r.lastPieceLength=(o.offset+o.length)%r.pieceLength||r.pieceLength,r.pieces=function(e){for(var t=[],r=0;re._pos){var o=r.substr(e._pos);if("x-user-defined"===e._charset){for(var s=new n(o.length),a=0;ae._pos&&(e.push(new n(new Uint8Array(c.result.slice(e._pos)))),e._pos=c.result.byteLength)},c.onload=function(){e.push(null)},c.readAsArrayBuffer(r)}e._xhr.readyState===u.DONE&&"ms-stream"!==e._mode&&e.push(null)}}).call(this,r(7),r(0).Buffer,r(6))},function(e,t,r){var n=r(0).Buffer;e.exports=function(e){if(e instanceof Uint8Array){if(0===e.byteOffset&&e.byteLength===e.buffer.byteLength)return e.buffer;if("function"==typeof e.buffer.slice)return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(n.isBuffer(e)){for(var t=new Uint8Array(e.length),r=e.length,i=0;inull!==e&&"object"==typeof e&&"function"==typeof e.pipe;function l(e,r){if(e=Object.assign({maxRedirects:10},"string"==typeof e?{url:e}:e),r=a(r),e.url){const{hostname:t,port:r,protocol:n,auth:i,path:o}=c.parse(e.url);delete e.url,t||r||n||i?Object.assign(e,{hostname:t,port:r,protocol:n,auth:i,path:o}):e.path=o}const n={"accept-encoding":"gzip, deflate"};let h;e.headers&&Object.keys(e.headers).forEach(t=>n[t.toLowerCase()]=e.headers[t]),e.headers=n,e.body?h=e.json&&!f(e.body)?JSON.stringify(e.body):e.body:e.form&&(h="string"==typeof e.form?e.form:u.stringify(e.form),e.headers["content-type"]="application/x-www-form-urlencoded"),delete e.body,delete e.form,h&&(e.method||(e.method="POST"),f(h)||(e.headers["content-length"]=t.byteLength(h)),e.json&&(e.headers["content-type"]="application/json")),e.json&&(e.headers.accept="application/json"),e.method&&(e.method=e.method.toUpperCase());const p=("https:"===e.protocol?s:o).request(e,t=>{if(t.statusCode>=300&&t.statusCode<400&&t.headers.location)return e.url=t.headers.location,delete e.headers.host,t.resume(),"POST"===e.method&&[301,302].includes(t.statusCode)&&(e.method="GET",delete e.headers["content-length"],delete e.headers["content-type"]),0==e.maxRedirects--?r(new Error("too many redirects")):l(e,r);const n="function"==typeof i&&"HEAD"!==e.method;r(null,n?i(t):t)});return p.on("timeout",()=>{p.abort(),r(new Error("Request timed out"))}),p.on("error",r),f(h)?h.on("error",r).pipe(p):p.end(h),p}l.concat=((e,t)=>l(e,(r,i)=>{if(r)return t(r);n(i,(r,n)=>{if(r)return t(r);if(e.json)try{n=JSON.parse(n.toString())}catch(r){return t(r,i,n)}t(null,i,n)})})),["get","post","put","patch","head","delete"].forEach(e=>{l[e]=((t,r)=>("string"==typeof t&&(t={url:t}),l(Object.assign({method:e.toUpperCase()},t),r)))})}).call(this,r(0).Buffer)},function(e,t,r){e.exports=u;var n=r(5),i=r(22),o=r(620),s="undefined"!=typeof window&&window.MediaSource,a=60;function u(e,t){var r=this;if(!(r instanceof u))return new u(e,t);if(!s)throw new Error("web browser lacks MediaSource support");t||(t={}),r._debug=t.debug,r._bufferDuration=t.bufferDuration||a,r._elem=e,r._mediaSource=new s,r._streams=[],r.detailedError=null,r._errorHandler=function(){r._elem.removeEventListener("error",r._errorHandler),r._streams.slice().forEach(function(e){e.destroy(r._elem.error)})},r._elem.addEventListener("error",r._errorHandler),r._elem.src=window.URL.createObjectURL(r._mediaSource)}function c(e,t){var r=this;if(i.Writable.call(r),r._wrapper=e,r._elem=e._elem,r._mediaSource=e._mediaSource,r._allStreams=e._streams,r._allStreams.push(r),r._bufferDuration=e._bufferDuration,r._sourceBuffer=null,r._debugBuffers=[],r._openHandler=function(){r._onSourceOpen()},r._flowHandler=function(){r._flow()},r._errorHandler=function(e){r.destroyed||r.emit("error",e)},"string"==typeof t)r._type=t,"open"===r._mediaSource.readyState?r._createSourceBuffer():r._mediaSource.addEventListener("sourceopen",r._openHandler);else if(null===t._sourceBuffer)t.destroy(),r._type=t._type,r._mediaSource.addEventListener("sourceopen",r._openHandler);else{if(!t._sourceBuffer)throw new Error("The argument to MediaElementWrapper.createWriteStream must be a string or a previous stream returned from that function");t.destroy(),r._type=t._type,r._sourceBuffer=t._sourceBuffer,r._debugBuffers=t._debugBuffers,r._sourceBuffer.addEventListener("updateend",r._flowHandler),r._sourceBuffer.addEventListener("error",r._errorHandler)}r._elem.addEventListener("timeupdate",r._flowHandler),r.on("error",function(e){r._wrapper.error(e)}),r.on("finish",function(){if(!r.destroyed&&(r._finished=!0,r._allStreams.every(function(e){return e._finished}))){r._wrapper._dumpDebugData();try{r._mediaSource.endOfStream()}catch(e){}}})}u.prototype.createWriteStream=function(e){return new c(this,e)},u.prototype.error=function(e){this.detailedError||(this.detailedError=e),this._dumpDebugData();try{this._mediaSource.endOfStream("decode")}catch(e){}},u.prototype._dumpDebugData=function(){this._debug&&(this._debug=!1,this._streams.forEach(function(e,t){!function(e,t){var r=document.createElement("a");r.href=window.URL.createObjectURL(new window.Blob(e)),r.download=t,r.click()}(e._debugBuffers,"mediasource-stream-"+t)}))},n(c,i.Writable),c.prototype._onSourceOpen=function(){this.destroyed||(this._mediaSource.removeEventListener("sourceopen",this._openHandler),this._createSourceBuffer())},c.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,this._allStreams.splice(this._allStreams.indexOf(this),1),this._mediaSource.removeEventListener("sourceopen",this._openHandler),this._elem.removeEventListener("timeupdate",this._flowHandler),this._sourceBuffer&&(this._sourceBuffer.removeEventListener("updateend",this._flowHandler),this._sourceBuffer.removeEventListener("error",this._errorHandler),"open"===this._mediaSource.readyState&&this._sourceBuffer.abort()),e&&this.emit("error",e),this.emit("close"))},c.prototype._createSourceBuffer=function(){if(!this.destroyed)if(s.isTypeSupported(this._type)){if(this._sourceBuffer=this._mediaSource.addSourceBuffer(this._type),this._sourceBuffer.addEventListener("updateend",this._flowHandler),this._sourceBuffer.addEventListener("error",this._errorHandler),this._cb){var e=this._cb;this._cb=null,e()}}else this.destroy(new Error("The provided type is not supported"))},c.prototype._write=function(e,t,r){var n=this;if(!n.destroyed)if(n._sourceBuffer){if(n._sourceBuffer.updating)return r(new Error("Cannot append buffer while source buffer updating"));var i=o(e);n._wrapper._debug&&n._debugBuffers.push(i);try{n._sourceBuffer.appendBuffer(i)}catch(e){return void n.destroy(e)}n._cb=r}else n._cb=function(i){if(i)return r(i);n._write(e,t,r)}},c.prototype._flow=function(){if(!this.destroyed&&this._sourceBuffer&&!this._sourceBuffer.updating&&!("open"===this._mediaSource.readyState&&this._getBufferDuration()>this._bufferDuration)&&this._cb){var e=this._cb;this._cb=null,e()}};c.prototype._getBufferDuration=function(){for(var e=this._sourceBuffer.buffered,t=this._elem.currentTime,r=-1,n=0;nt)break;(r>=0||t<=o)&&(r=o)}var s=r-t;return s<0&&(s=0),s}},function(e,t,r){var n=r(627);e.exports=function e(t,r,i){if("function"==typeof r)return e(t,null,r);n(t,r,function(e,t){if(e)return i(e);var r=URL.createObjectURL(t);i(null,r)})}},function(e,t,r){var n=r(30);e.exports=function e(t,r,i){if("function"==typeof r)return e(t,null,r);i=n(i);var o=[];t.on("data",function(e){o.push(e)}).on("end",function(){var e=r?new Blob(o,{type:r}):new Blob(o);i(null,e)}).on("error",i)}},function(e,t){e.exports=function(e,t){if(!(t>=e.length||t<0)){var r=e.pop();if(t=this._parserSize;){var n=1===this._buffer.length?this._buffer[0]:s.concat(this._buffer);this._bufferSize-=this._parserSize,this._buffer=this._bufferSize?[n.slice(this._parserSize)]:[],this._parser(n.slice(0,this._parserSize))}r(null)},k.prototype._callback=function(e,t,r){e&&(this._clearTimeout(),this.peerChoking||this._finished||this._updateTimeout(),e.callback(t,r))},k.prototype._clearTimeout=function(){this._timeout&&(clearTimeout(this._timeout),this._timeout=null)},k.prototype._updateTimeout=function(){var e=this;e._timeoutMs&&e.requests.length&&!e._timeout&&(e._timeout=setTimeout(function(){e._onTimeout()},e._timeoutMs),e._timeoutUnref&&e._timeout.unref&&e._timeout.unref())},k.prototype._parse=function(e,t){this._parserSize=e,this._parser=t},k.prototype._onMessageLength=function(e){var t=e.readUInt32BE(0);t>0?this._parse(t,this._onMessage):(this._onKeepAlive(),this._parse(4,this._onMessageLength))},k.prototype._onMessage=function(e){switch(this._parse(4,this._onMessageLength),e[0]){case 0:return this._onChoke();case 1:return this._onUnchoke();case 2:return this._onInterested();case 3:return this._onUninterested();case 4:return this._onHave(e.readUInt32BE(1));case 5:return this._onBitField(e.slice(1));case 6:return this._onRequest(e.readUInt32BE(1),e.readUInt32BE(5),e.readUInt32BE(9));case 7:return this._onPiece(e.readUInt32BE(1),e.readUInt32BE(5),e.slice(9));case 8:return this._onCancel(e.readUInt32BE(1),e.readUInt32BE(5),e.readUInt32BE(9));case 9:return this._onPort(e.readUInt16BE(1));case 20:return this._onExtended(e.readUInt8(1),e.slice(2));default:return this._debug("got unknown message"),this.emit("unknownmessage",e)}},k.prototype._parseHandshake=function(){var e=this;e._parse(1,function(t){var r=t.readUInt8(0);e._parse(r+48,function(t){var n=t.slice(0,r);if("BitTorrent protocol"!==n.toString())return e._debug("Error: wire not speaking BitTorrent protocol (%s)",n.toString()),void e.end();t=t.slice(r),e._onHandshake(t.slice(8,28),t.slice(28,48),{dht:!!(1&t[7]),extended:!!(16&t[5])}),e._parse(4,e._onMessageLength)})})},k.prototype._onFinish=function(){for(this._finished=!0,this.push(null);this.read(););for(clearInterval(this._keepAliveInterval),this._parse(Number.MAX_VALUE,function(){});this.peerRequests.length;)this.peerRequests.pop();for(;this.requests.length;)this._callback(this.requests.pop(),new Error("wire was closed"),null)},k.prototype._debug=function(){var e=[].slice.call(arguments);e[0]="["+this._debugId+"] "+e[0],a.apply(null,e)}},function(e,t,r){(function(e,t){!function(){var r;"undefined"!=typeof window&&(r=window),void 0!==e&&(r=e);var n=(r=r||{}).console||{log:function(){}};function i(e){return e.slice?i[t(e)]:function(r,n){e(r={exports:{}}),i[t(n)]=r.exports};function t(e){return e.split("/").slice(-1).toString().replace(".js","")}}var o=t;i(function(e){var t={fn:{is:function(e){return!!e&&"function"==typeof e}}};t.bi={is:function(e){return e instanceof Boolean||"boolean"==typeof e}},t.num={is:function(e){return!n(e)&&(e-parseFloat(e)+1>=0||1/0===e||-1/0===e)}},t.text={is:function(e){return"string"==typeof e}},t.text.ify=function(e){return t.text.is(e)?e:"undefined"!=typeof JSON?JSON.stringify(e):e&&e.toString?e.toString():e},t.text.random=function(e,t){var r="";for(e=e||24,t=t||"0123456789ABCDEFGHIJKLMNOPQRSTUVWXZabcdefghijklmnopqrstuvwxyz";e>0;)r+=t.charAt(Math.floor(Math.random()*t.length)),e--;return r},t.text.match=function(e,r){var n=!1;if(e=e||"",r=t.text.is(r)?{"=":r}:r||{},t.obj.has(r,"~")&&(e=e.toLowerCase(),r["="]=(r["="]||r["~"]).toLowerCase()),t.obj.has(r,"="))return e===r["="];if(t.obj.has(r,"*")){if(e.slice(0,r["*"].length)!==r["*"])return!1;n=!0,e=e.slice(r["*"].length)}if(t.obj.has(r,"!")){if(e.slice(-r["!"].length)!==r["!"])return!1;n=!0}if(t.obj.has(r,"+")&&t.list.map(t.list.is(r["+"])?r["+"]:[r["+"]],function(t){if(!(e.indexOf(t)>=0))return!0;n=!0}))return!1;if(t.obj.has(r,"-")&&t.list.map(t.list.is(r["-"])?r["-"]:[r["-"]],function(t){if(!(e.indexOf(t)<0))return!0;n=!0}))return!1;if(t.obj.has(r,">")){if(!(e>r[">"]))return!1;n=!0}if(t.obj.has(r,"<")){if(!(er?1:0:0}},t.list.map=function(e,t,r){return a(e,t,r)},t.list.index=1,t.obj={is:function(e){return!!e&&(e instanceof Object&&e.constructor===Object||"Object"===Object.prototype.toString.call(e).match(/^\[object (\w+)\]$/)[1])}},t.obj.put=function(e,t,r){return(e||{})[t]=r,e},t.obj.has=function(e,t){return e&&Object.prototype.hasOwnProperty.call(e,t)},t.obj.del=function(e,t){if(e)return e[t]=null,delete e[t],e},t.obj.as=function(e,t,r,n){return e[t]=e[t]||(n===r?{}:r)},t.obj.ify=function(e){if(o(e))return e;try{e=JSON.parse(e)}catch(t){e={}}return e},function(){var e;function r(t,r){s(this,r)&&e!==this[r]||(this[r]=t)}t.obj.to=function(e,t){return a(e,r,t=t||{}),t}}(),t.obj.copy=function(e){return e?JSON.parse(JSON.stringify(e)):e},function(){function e(e,t){var r=this.n;if(!r||!(t===r||o(r)&&s(r,t)))return!!t||void 0}t.obj.empty=function(t,r){return!t||!a(t,e,{n:r})}}(),function(){function e(t,r){if(2===arguments.length)return e.r=e.r||{},void(e.r[t]=r);e.r=e.r||[],e.r.push(t)}var i=Object.keys;t.obj.map=function(a,u,c){var f,l,h,p,d,y=0,g=r(u);if(e.r=null,i&&o(a)&&(p=i(a),d=!0),n(a)||p)for(l=(p||a).length;y",n.drift=0,n.is=function(e,t,r){var i=t&&e&&e[v]&&e[v][n._]||r;if(i)return m(i=i[t])?i:-1/0},n.lex=function(){return n().toString(36).replace(".","")},n.ify=function(e,t,i,o,s){if(!e||!e[v]){if(!s)return;e=r.soul.ify(e,s)}var a=h(e[v],n._);return f!==t&&t!==v&&(m(i)&&(a[t]=i),f!==o&&(e[t]=o)),e},n.to=function(e,t,i){var o=e[t];return d(o)&&(o=g(o)),n.ify(i,t,n.is(e,t),o,r.soul(e))},function(){function e(e,t){v!==t&&n.ify(this.o,t,this.s)}n.map=function(t,r,i){var o,s=d(s=t||r)?s:null;return t=b(t=t||r)?t:null,s&&!t?(r=m(r)?r:n(),s[v]=s[v]||{},y(s,e,{o:s,s:r}),s):(i=i||d(r)?r:o,r=m(r)?r:n(),function(n,s,a,u){if(!t)return e.call({o:a,s:r},n,s),n;t.call(i||this||{},n,s,a,u),p(a,s)&&o===a[s]||e.call({o:a,s:r},n,s)})}}();var f,l=t.obj,h=l.as,p=l.has,d=l.is,y=l.map,g=l.copy,m=t.num.is,b=t.fn.is,v=r._;e.exports=n})(i,"./state"),i(function(e){var t=i("./type"),r=i("./val"),n=i("./node"),o={};!function(){function e(e,r){if(!e||r!==n.soul(e)||!n.is(e,this.fn,this.as))return!0;this.cb&&(t.n=e,t.as=this.as,this.cb.call(t.as,e,r,t))}function t(e){e&&n.is(t.n,e,t.as)}o.is=function(t,r,n,i){return!(!t||!u(t)||l(t)||p(t,e,{cb:r,fn:n,as:i}))}}(),function(){function e(e,t){var o;return(o=function(e,t){for(var r,n=e.seen,i=n.length;i--;)if(r=n[i],t.obj===r.obj)return r;n.push(t)}(e,t))?o:(t.env=e,t.soul=a,n.ify(t.obj,i,t)&&(e.graph[r.rel.is(t.rel)]=t.node),t)}function i(t,i,o){var a,u,h=this,p=h.env;if(n._===i&&f(t,r.rel._))return o._;if(a=l(t,i,o,h,p)){if(i||(h.node=h.node||o||{},f(t,n._)&&n.soul(t)&&(h.node._=d(t._)),h.node=n.soul.ify(h.node,r.rel.is(h.rel)),h.rel=h.rel||r.rel.ify(n.soul(h.node))),(u=p.map)&&(u.call(p.as||{},t,i,o,h),f(o,i))){if(t=o[i],s===t)return void c(o,i);if(!(a=l(t,i,o,h,p)))return}if(!i)return h.node;if(!0===a)return t;if((u=e(p,{obj:t,path:h.path.concat(i)})).node)return u.rel}}function a(e){var t=this,i=r.link.is(t.rel),o=t.env.graph;t.rel=t.rel||r.rel.ify(e),t.rel[r.rel._]=e,t.node&&t.node[n._]&&(t.node[n._][r.rel._]=e),f(o,i)&&(o[e]=o[i],c(o,i))}function l(e,n,i,o,s){var a;return!!r.is(e)||(u(e)?1:(a=s.invalid)?l(e=a.call(s.as||{},e,n,i),n,i,o,s):(s.err="Invalid value at '"+o.path.concat(n).join(".")+"'!",void(t.list.is(e)&&(s.err+=" Use `.set(item)` instead of an Array."))))}o.ify=function(t,n,i){var o={path:[],obj:t};return n?"string"==typeof n?n={soul:n}:n instanceof Function&&(n.map=n):n={},n.soul&&(o.rel=r.rel.ify(n.soul)),n.graph=n.graph||{},n.seen=n.seen||[],n.as=n.as||i,e(n,o),n.root=o.node,n.graph}}(),o.node=function(e){var t=n.soul(e);if(t)return h({},t,e)},function(){function e(e,t){var i,s;if(n._!==t)(i=r.rel.is(e))?(s=this.opt.seen[i])?this.obj[t]=s:this.obj[t]=this.opt.seen[i]=o.to(this.graph,i,this.opt):this.obj[t]=e;else{if(l(e,r.rel._))return;this.obj[t]=d(e)}}o.to=function(t,r,n){if(t){var i={};return n=n||{seen:{}},p(t[r],e,{obj:i,graph:t,opt:n}),i}}}();t.fn.is;var s,a=t.obj,u=a.is,c=a.del,f=a.has,l=a.empty,h=a.put,p=a.map,d=a.copy;e.exports=o})(i,"./graph"),i(function(e){i("./onto"),e.exports=function(e,t){if(this.on){if(!(e instanceof Function)){if(!e||!t)return;var r=e["#"]||e,n=(this.tag||empty)[r];if(!n)return;return n=this.on(r,t),clearTimeout(n.err),!0}r=t&&t["#"]||Math.random().toString(36).slice(2);if(!e)return r;var i=this.on(r,e,t);return i.err=i.err||setTimeout(function(){i.next({err:"Error: No ACK received yet.",lack:!0}),i.off()},(this.opt||{}).lack||9e3),r}}})(i,"./ask"),i(function(e){var t=i("./type");var r=t.time.is;e.exports=function(e){var n={s:{}};return e=e||{max:1e3,age:9e3},n.check=function(e){var t;return!!(t=n.s[e])&&(t.pass?t.pass=!1:n.track(e))},n.track=function(i,o){var s=n.s[i]||(n.s[i]={});return s.was=r(),o&&(s.pass=!0),n.to||(n.to=setTimeout(function(){var i=r();t.obj.map(n.s,function(r,o){e.age>i-r.was||t.obj.del(n.s,o)}),n.to=null},e.age+9)),s},n}})(i,"./dup"),i(function(e){function t(e){return e instanceof t?(this._={gun:this,$:this}).$:this instanceof t?t.create(this._={gun:this,$:this,opt:e}):new t(e)}t.is=function(e){return e instanceof t||e&&e._&&e===e._.$||!1},t.version=.9,t.chain=t.prototype,t.chain.toJSON=function(){};var r=i("./type");r.obj.to(r,t),t.HAM=i("./HAM"),t.val=i("./val"),t.node=i("./node"),t.state=i("./state"),t.graph=i("./graph"),t.on=i("./onto"),t.ask=i("./ask"),t.dup=i("./dup"),function(){function e(r){var n,i,o=this,a=o.as,u=a.at||a,c=u.$;(i=r["#"])||(i=r["#"]=f(9)),(n=u.dup).check(i)?a.out===r.out&&(r.out=s,o.to.next(r)):(n.track(i),u.ask(r["@"],r)||(r.get&&t.on.get(r,c),r.put&&t.on.put(r,c)),o.to.next(r),a.out||(r.out=e,u.on("out",r)))}t.create=function(r){r.root=r.root||r,r.graph=r.graph||{},r.on=r.on||t.on,r.ask=r.ask||t.ask,r.dup=r.dup||t.dup();var n=r.$.opt(r.opt);return r.once||(r.on("in",e,r),r.on("out",e,{at:r,out:e}),t.on("create",r),r.on("create",r)),r.once=1,n}}(),function(){function e(e,r,n,i){var o=this,s=t.state.is(n,r);if(!s)return o.err="Error: No state on '"+r+"' in node '"+i+"'!";var a=o.graph[i]||v,u=t.state.is(a,r,!0),c=a[r],f=t.HAM(o.machine,s,u,e,c);f.incoming?(o.put[i]=t.state.to(n,r,o.put[i]),(o.diff||(o.diff={}))[i]=t.state.to(n,r,o.diff[i]),o.souls[i]=!0):f.defer&&(o.defer=s<(o.defer||1/0)?s:o.defer)}function r(e,t){var r=this,s=r.$._,a=(s.next||v)[t];if(!a){if(!(s.opt||v).super)return void(r.souls[t]=!1);a=r.$.get(t)._}var u=r.map[t]={put:e,get:t,$:a.$},c={ctx:r,msg:u};r.async=!!s.tag.node,r.ack&&(u["@"]=r.ack),y(e,n,c),r.async&&(r.and||s.on("node",function(e){this.to.next(e),e===r.map[e.get]&&(r.souls[e.get]=!1,y(e.put,i,e),y(r.souls,function(e){if(e)return e})||r.c||(r.c=1,this.off(),y(r.map,o,r)))}),r.and=!0,s.on("node",u))}function n(e,r){var n=this.ctx,i=n.graph,o=this.msg,s=o.get,a=o.put,u=o.$._;i[s]=t.state.to(a,r,i[s]),n.async||(u.put=t.state.to(a,r,u.put))}function i(e,r){var n=this.put,i=this.$._;i.put=t.state.to(n,r,i.put)}function o(e,t){e.$&&(this.cat.stop=this.stop,e.$._.on("in",e),this.cat.stop=null)}t.on.put=function(n,i){var a=i._,u={$:i,graph:a.graph,put:{},map:{},souls:{},machine:t.state(),ack:n["@"],cat:a,stop:{}};if(t.graph.is(n.put,null,e,u)||(u.err="Error: Invalid graph!"),u.err)return a.on("in",{"@":n["#"],err:t.log(u.err)});y(u.put,r,u),u.async||y(u.map,o,u),s!==u.defer&&setTimeout(function(){t.on.put(n,i)},u.defer-u.machine),u.diff&&a.on("put",d(n,{put:u.diff}))},t.on.get=function(e,r){var n=r._,i=e.get[m],o=n.graph[i],s=e.get[b],a=(n.next||(n.next={}))[i];if(!o||!a)return n.on("get",e);if(s){if(!p(o,s))return n.on("get",e);o=t.state.to(o,s)}else o=t.obj.copy(o);o=t.graph.node(o),a.ack,n.on("in",{"@":e["#"],how:"mem",put:o,$:r}),n.on("get",e)}}(),t.chain.opt=function(e){e=e||{};var r=this._,n=e.peers||e;return h(e)||(e={}),h(r.opt)||(r.opt=e),c(n)&&(n=[n]),a(n)&&(n=y(n,function(e,t,r){r(e,{url:e})}),h(r.opt.peers)||(r.opt.peers={}),r.opt.peers=d(n,r.opt.peers)),r.opt.peers=r.opt.peers||{},d(e,r.opt),t.on("opt",r),r.opt.uuid=r.opt.uuid||function(){return g()+f(12)},this};var s,a=t.list.is,u=t.text,c=u.is,f=u.random,l=t.obj,h=l.is,p=l.has,d=l.to,y=l.map,g=(l.copy,t.state.lex),m=t.val.rel._,b=".",v=(t.node._,t.val.link.is,{});n.debug=function(e,t){return n.debug.i&&e===n.debug.i&&n.debug.i++&&(n.log.apply(n,arguments)||t)},t.log=function(){return!t.log.off&&n.log.apply(n,arguments),[].slice.call(arguments).join(" ")},t.log.once=function(e,r,n){return(n=t.log.once)[e]=n[e]||0,n[e]++||t.log(r)},t.log.once("welcome","Hello wonderful person! :) Thanks for using GUN, feel free to ask for help on https://gitter.im/amark/gun and ask StackOverflow questions tagged with 'gun'!"),"undefined"!=typeof window&&(window.Gun=t);try{void 0!==o&&(o.exports=t)}catch(e){}e.exports=t})(i,"./root"),i(function(e){var t=i("./root");t.chain.back=function(e,i){if(-1===(e=e||1)||1/0===e)return this._.root.$;if(1===e)return(this._.back||this._).$;var o=this._;if("string"==typeof e&&(e=e.split(".")),e instanceof Array){for(var s=0,a=e.length,u=o;s .once, apologies unexpected."),this.once(e,r)},t.chain.once=function(e,r){var i=this,s=i._,a=s.put;if(0=(t.batch||1e3))return u();r||(r=setTimeout(u,t.wait||1))}),e.on("get",function(r){this.to.next(r);var n,i,o,a=r.get;function u(){if(a&&(n=a["#"])){var u=a["."];(i=s[n]||o)&&u&&(i=Gun.state.to(i,u)),(i||Gun.obj.empty(t.peers))&&e.on("in",{"@":r["#"],put:Gun.graph.node(i),how:"lS",lS:r.I})}}Gun.debug?setTimeout(u,1):u()});var a=function(e,t,r,n){s[n]=Gun.state.to(r,t,s[n])},u=function(a){var c;o=0,clearTimeout(r),r=!1;var f=i;i={},a&&(s=a);try{n.setItem(t.file,JSON.stringify(s))}catch(a){Gun.log(c=a||"localStorage failure"),e.on("localStorage:error",{err:c,file:t.file,flush:s,retry:u})}(c||Gun.obj.empty(t.peers))&&Gun.obj.map(f,function(t,r){e.on("in",{"@":r,err:c,ok:0})})}}})}})(i,"./adapters/localStorage"),i(function(e){var t=i("../type");function r(e){var i=function(){};return i.out=function(t){var r;if(this.to&&this.to.next(t),(r=t["@"])&&(r=e.dup.s[r])&&(r=r.it)&&r.mesh)return i.say(t,r.mesh.via),void(r["##"]=t["##"]);i.say(t)},i.hear=function(r,n){if(r){var o,s,a,u=e.dup,c=r[0];try{a=JSON.parse(r)}catch(e){}if("{"===c){if(!a)return;if(u.check(o=a["#"]))return;if(u.track(o,!0).it=a,(c=a["@"])&&a.put&&(c+=s=a["##"]||(a["##"]=i.hash(a)))!=o){if(u.check(c))return;(c=u.s)[s]=c[o]}return(a.mesh=function(){}).via=n,(c=a["><"])&&(a.mesh.to=t.obj.map(c.split(","),function(e,t,r){r(e,!0)})),void e.on("in",a)}if("["!==c);else{if(!a)return;for(var f,l=0;f=a[l++];)i.hear(f,n)}}},function(){function r(e,t){var r=t.wire;try{r.send?r.readyState===r.OPEN?r.send(e):(t.queue=t.queue||[]).push(e):t.say&&t.say(e)}catch(r){(t.queue=t.queue||[]).push(e)}}i.say=function(n,s){var a,u,c;s?(s.wire||e.opt.wire&&e.opt.wire(s))&&(u=n.mesh||o,s!==u.via&&((c=u.raw)||(c=i.raw(n)),(a=n["@"])&&(a=e.dup.s[a])&&(a=a.it)&&a.get&&a["##"]&&a["##"]===n["##"]||(a=u.to)&&(a[s.url]||a[s.id])||(s.batch?s.batch.push(c):(s.batch=[],setTimeout(function(){var e=s.batch;e&&(s.batch=null,e.length&&r(JSON.stringify(e),s))},e.opt.gap||e.opt.wait||1),r(c,s))))):t.obj.map(e.opt.peers,function(e){i.say(n,e)})}}(),function(){function o(e,r){var n;return r instanceof Object?(t.obj.map(Object.keys(r).sort(),s,{to:n={},on:r}),n):r}function s(e){this.to[e]=this.on[e]}i.raw=function(r){if(!r)return"";var s,c,f,l=e.dup,h=r.mesh||{};if(f=h.raw)return f;if("string"==typeof r)return r;r["@"]&&(f=r.put)&&((c=r["##"])||(s=a(f,o)||"",c=i.hash(r,s),r["##"]=c),(f=l.s)[c=r["@"]+c]=f[r["#"]],r["#"]=c||r["#"],s&&((r=t.obj.to(r)).put=u));var p=0,d=[];t.obj.map(e.opt.peers,function(e){if(d.push(e.url||e.id),++p>9)return!0}),r["><"]=d.join();var y=a(r);return n!==s&&(y=y.replace('"'+u+'"',s)),h&&(h.raw=y),y},i.hash=function(e,n){return r.hash(n||a(e.put,o)||"")||e["#"]||t.text.random(9)};var a=JSON.stringify,u=":])([:"}(),i.hi=function(r){e.on("hi",r);var n=r.queue;r.queue=[],t.obj.map(n,function(e){i.say(e,r)})},i}r.hash=function(e){if("string"!=typeof e)return{err:1};var t=0;if(!e.length)return t;for(var r=0,n=e.length;r= 0x80 (not a basic code point)","invalid-input":"Invalid input"},w=c-f,S=Math.floor,k=String.fromCharCode;function E(e){throw new RangeError(_[e])}function A(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}function x(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),n+A((e=e.replace(v,".")).split("."),t).join(".")}function I(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i65535&&(t+=k((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+k(e)}).join("")}function B(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:c}function C(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function P(e,t,r){var n=0;for(e=r?S(e/p):e>>1,e+=S(e/t);e>w*l>>1;n+=c)e=S(e/w);return S(n+(w+1)*e/(e+h))}function O(e){var t,r,n,i,o,s,a,h,p,m,b=[],v=e.length,_=0,w=y,k=d;for((r=e.lastIndexOf(g))<0&&(r=0),n=0;n=128&&E("not-basic"),b.push(e.charCodeAt(n));for(i=r>0?r+1:0;i=v&&E("invalid-input"),((h=B(e.charCodeAt(i++)))>=c||h>S((u-_)/s))&&E("overflow"),_+=h*s,!(h<(p=a<=k?f:a>=k+l?l:a-k));a+=c)s>S(u/(m=c-p))&&E("overflow"),s*=m;k=P(_-o,t=b.length+1,0==o),S(_/t)>u-w&&E("overflow"),w+=S(_/t),_%=t,b.splice(_++,0,w)}return T(b)}function R(e){var t,r,n,i,o,s,a,h,p,m,b,v,_,w,A,x=[];for(v=(e=I(e)).length,t=y,r=0,o=d,s=0;s=t&&bS((u-r)/(_=n+1))&&E("overflow"),r+=(a-t)*_,t=a,s=0;su&&E("overflow"),b==t){for(h=r,p=c;!(h<(m=p<=o?f:p>=o+l?l:p-o));p+=c)A=h-m,w=c-m,x.push(k(C(m+A%w,0))),h=S(A/w);x.push(k(C(h,0))),o=P(r,_,n==i),r=0,++n}++r,++t}return x.join("")}a={version:"1.4.1",ucs2:{decode:I,encode:T},decode:O,encode:R,toASCII:function(e){return x(e,function(e){return b.test(e)?"xn--"+R(e):e})},toUnicode:function(e){return x(e,function(e){return m.test(e)?O(e.slice(4).toLowerCase()):e})}},void 0===(i=function(){return a}.call(t,r,t,e))||(e.exports=i)}()}).call(this,r(27)(e),r(6))},function(e,t,r){"use strict";e.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},function(e,t,r){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.exports=function(e,t,r,o){t=t||"&",r=r||"=";var s={};if("string"!=typeof e||0===e.length)return s;var a=/\+/g;e=e.split(t);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var c=e.length;u>0&&c>u&&(c=u);for(var f=0;f=0?(l=y.substr(0,g),h=y.substr(g+1)):(l=y,h=""),p=decodeURIComponent(l),d=decodeURIComponent(h),n(s,p)?i(s[p])?s[p].push(d):s[p]=[s[p],d]:s[p]=d}return s};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},function(e,t,r){"use strict";var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};e.exports=function(e,t,r,a){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?o(s(e),function(s){var a=encodeURIComponent(n(s))+r;return i(e[s])?o(e[s],function(e){return a+encodeURIComponent(n(e))}).join(t):a+encodeURIComponent(n(e[s]))}).join(t):a?encodeURIComponent(n(a))+r+encodeURIComponent(n(e)):""};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function o(e,t){if(e.map)return e.map(t);for(var r=[],n=0;ns.parse(e)).find(e=>"https:"===e.protocol&&["gateway.dweb.me","dweb.me"].includes(e.host)&&(e.pathname.includes("/content/rawfetch")||e.pathname.includes("/contenthash/"))||"contenthash:"===e.protocol&&"contenthash"===e.pathname.split("/")[1]);return r||(r=`contenthash:/contenthash/${e.keypair.verifyexportmultihashsha256_58()}`),[r,r]}async p_f_createReadStream(e,{verbose:t=!1,wanturl:r=!1}={}){t&&console.log(this.name,"p_f_createreadstream",s.parse(e).href);try{let n=this;return r?e:function(r){return n.p_createReadStream(e,r,t)}}catch(t){throw console.warn(`p_f_createReadStream failed on ${s.parse(e).href} ${t.message}`),t}}async createReadStream(e,t,r){let n;r&&console.log(this.name,"createreadstream",s.parse(e).href,t);try{return n=new a.PassThrough,o.p_GET(this._url(e,servercommands.rawfetch),Object.assign({wantstream:!0},t)).then(e=>e.pipe(n)),n}catch(e){console.log(this.name,"createReadStream caught error",e),"function"==typeof n.destroy?n.destroy(e):n.emit("error",e)}}async p_createReadStream(e,t,r){r&&console.log(this.name,"createreadstream",s.parse(e).href,t);try{return await o.p_GET(this._url(e,servercommands.rawfetch),Object.assign({wantstream:!0},t))}catch(e){throw console.warn(this.name,"caught error",e),e}}async p_newdatabase(e,{verbose:t=!1}={}){e.hasOwnProperty("keypair")&&(e=e.keypair.signingexport());let r=`${this.urlbase}/getall/table/${encodeURIComponent(e)}`;return{publicurl:r,privateurl:r}}async p_newtable(e,t,{verbose:r=!1}={}){if(!e)throw new errors.CodingError("p_newtable currently requires a pubkey");let n=await this.p_newdatabase(e,{verbose:r});return{privateurl:`${n.privateurl}/${t}`,publicurl:`${n.publicurl}/${t}`}}async p_set(e,t,r,{verbose:n=!1}={}){if(!e||!t)throw new errors.CodingError("TransportHTTP.p_set: invalid parms",e,keyvalyes);if(n&&console.log("p_set",e,t,r),"string"==typeof t){let i=JSON.stringify([{key:t,value:r}]);await o.p_POST(this._url(e,servercommands.set),"application/json",i,n)}else{let r=JSON.stringify(Object.keys(t).map(e=>({key:e,value:t[e]})));await o.p_POST(this._url(e,servercommands.set),"application/json",r,n)}}_keyparm(e){return`key=${encodeURIComponent(e)}`}async p_get(e,t,{verbose:r=!1}={}){if(!e&&t)throw new errors.CodingError("TransportHTTP.p_get: requires url and at least one key");let n=Array.isArray(t)?t.map(e=>this._keyparm(e)).join("&"):this._keyparm(t),i=await o.p_GET(this._url(e,servercommands.get,n),{verbose:r});return Array.isArray(t)?i:i[t]}async p_delete(e,t,{verbose:r=!1}={}){if(!e&&t)throw new errors.CodingError("TransportHTTP.p_get: requires url and at least one key");let n=t.map(e=>this._keyparm(e)).join("&");await o.p_GET(this._url(e,servercommands.delete,n),{verbose:r})}async p_keys(e,{verbose:t=!1}={}){if(!e&&keys)throw new errors.CodingError("TransportHTTP.p_get: requires url and at least one key");return await o.p_GET(this._url(e,servercommands.keys),{verbose:t})}async p_getall(e,{verbose:t=!1}={}){if(!e&&keys)throw new errors.CodingError("TransportHTTP.p_get: requires url and at least one key");return await o.p_GET(this._url(e,servercommands.getall),{verbose:t})}p_info(e){return o.p_GET(`${this.urlbase}/info`,{verbose:e})}static async p_test(e={},t=!1){t&&console.log("TransportHTTP.test");try{let r=await this.p_setup(e,t);t&&console.log("HTTP connected");let i=await r.p_info(t);t&&console.log("TransportHTTP info=",i),i=await r.p_status(t),console.assert(i===n.STATUS_CONNECTED),await r.p_test_kvt("NACL%20VERIFY",t)}catch(e){throw console.log("Exception thrown in TransportHTTP.test:",e.message),e}}static async test(){return this}}i._transportclasses.HTTP=u,e.exports=u},function(e,t,r){"use strict";t.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){for(var t,r=c(e),n=r[0],s=r[1],a=new o(function(e,t,r){return 3*(t+r)/4-r}(0,n,s)),u=0,f=s>0?n-4:n,l=0;l>16&255,a[u++]=t>>8&255,a[u++]=255&t;return 2===s&&(t=i[e.charCodeAt(l)]<<2|i[e.charCodeAt(l+1)]>>4,a[u++]=255&t),1===s&&(t=i[e.charCodeAt(l)]<<10|i[e.charCodeAt(l+1)]<<4|i[e.charCodeAt(l+2)]>>2,a[u++]=t>>8&255,a[u++]=255&t),a},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o=[],s=0,a=r-i;sa?a:s+16383));return 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]+"=")),o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=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){return n[e>>18&63]+n[e>>12&63]+n[e>>6&63]+n[63&e]}function l(e,t,r){for(var n,i=[],o=t;o0?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=n.allocUnsafe(e>>>0),r=this.head,i=0;r;)o(r.data,t,i),i+=r.data.length,r=r.next;return t},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(t){function r(e){try{if(!t.localStorage)return!1}catch(e){return!1}var r=t.localStorage[e];return null!=r&&"true"===String(r).toLowerCase()}e.exports=function(e,t){if(r("noDeprecation"))return e;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}}}).call(this,r(6))},function(e,t,r){"use strict";e.exports=o;var n=r(337),i=r(117);function o(e){if(!(this instanceof o))return new o(e);n.call(this,e)}i.inherits=r(5),i.inherits(o,n),o.prototype._transform=function(e,t,r){r(null,e)}},function(e,t){},function(e,t,r){(function(t){const n=r(338),i=r(645),o=r(9),s=(r(36),r(33)),a=(r(22),r(79)),u=r(116),c=r(101),f=r(149),l={repo:"/tmp/dweb_ipfsv2700",config:{Bootstrap:["/dns4/dweb.me/tcp/4245/wss/ipfs/QmPNgKEjC7wkpu3aHUzKKhZmbEfiGzL5TP1L8zZoHJyXZW"]},EXPERIMENTAL:{pubsub:!0}};class h extends u{constructor(e,t){super(e,t),this.ipfs=void 0,this.options=e,this.name="IPFS",this.supportURLs=["ipfs"],this.supportFunctions=["fetch","store","createReadStream"],this.status=u.STATUS_LOADED}p_ipfsstart(e){const t=this;return new Promise((e,t)=>{this.ipfs=new i(this.options),this.ipfs.on("ready",()=>{e()}),this.ipfs.on("error",e=>t(e))}).then(()=>t.ipfs.version()).then(e=>console.log("IPFS READY",e)).catch(e=>{throw console.log("Error caught in p_ipfsstart"),e})}static setup0(e,t){const r=u.mergeoptions(l,e.ipfs);t&&console.log("IPFS loading options %o",r);const n=new h(r,t);return c.addtransport(n),n}async p_setup1(e,t){try{e&&console.log("IPFS starting and connecting"),this.status=u.STATUS_STARTING,t&&t(this),await this.p_ipfsstart(e),this.status=await this.p_status(e)}catch(e){console.error(this.name,"failed to connect",e),this.status=u.STATUS_FAILED}return t&&t(this),this}async p_status(e){return this.status=await this.ipfs.isOnline()?u.STATUS_CONNECTED:u.STATUS_FAILED,super.p_status(e)}static urlFrom(e){if(e instanceof o)return"ipfs:/ipfs/"+e.toBaseEncodedString();if("object"==typeof e&&e.hash)return"ipfs:/ipfs/"+e.hash;if("string"==typeof e)return"ipfs:/ipfs/"+e;throw new a.CodingError("TransportIPFS.urlFrom: Cant convert to url from",e)}static cidFrom(e){if(e instanceof o)return e;if("string"==typeof e&&(e=s.parse(e)),e&&e.pathname){const t=e.pathname.split("/");if(!["ipfs:","dweb:"].includes(e.protocol)||"ipfs"!==t[1]||t.length<3)throw new a.TransportError("TransportIPFS.cidFrom bad format for url should be dweb: or ipfs:/ipfs/...: "+e.href);if(t.length>3)throw new a.TransportError("TransportIPFS.cidFrom not supporting paths in url yet, should be dweb: or ipfs:/ipfs/...: "+e.href);return new o(t[2])}throw new a.CodingError("TransportIPFS.cidFrom: Cant convert url",e)}static _stringFrom(e){return e instanceof o?"/ipfs/"+e.toBaseEncodedString():"object"==typeof e&&e.path?e.path:void 0}static ipfsFrom(e){if((e=this._stringFrom(e)).indexOf("/ipfs/")>-1)return e.slice(e.indexOf("/ipfs/"));throw new a.CodingError(`TransportIPFS.ipfsFrom: Cant convert url ${e} into a path starting /ipfs/`)}static ipfsGatewayFrom(e){if((e=this._stringFrom(e)).indexOf("/ipfs/")>-1)return"https://ipfs.io"+e.slice(e.indexOf("/ipfs/"));throw new a.CodingError(`TransportIPFS.ipfsGatewayFrom: Cant convert url ${e} into a path starting /ipfs/`)}static multihashFrom(e){if(e instanceof o)return cid.toBaseEncodedString();if("object"==typeof e&&e.path&&(e=e.path),"string"==typeof e){const t=e.indexOf("/ipfs/");if(t>-1)return e.slice(t+6)}throw new a.CodingError(`Cant turn ${e} into a multihash`)}async p_rawfetch(e,{verbose:t=!1,timeoutMS:r=6e4,relay:i=!1}={}){if(t&&console.log("IPFS p_rawfetch",s.parse(e).href),!e)throw new a.CodingError("TransportIPFS.p_rawfetch: requires url");const o=h.cidFrom(e),u=h.ipfsFrom(e);try{const i=await f.p_timeout(this.ipfs.dag.get(o),r,"Timed out IPFS fetch of "+h._stringFrom(o));if(i.remainderPath.length)throw new a.TransportError("Not yet supporting paths in p_rawfetch");let c;return"DAGNode"===i.value.constructor.name?(t&&console.log("IPFS p_rawfetch looks like its a file",s.parse(e).href),c=await this.ipfs.files.cat(u)):c=i.value,t&&console.log(`IPFS fetched ${c.length} from ${u}`),c}catch(t){console.log("Caught misc error in TransportIPFS.p_rawfetch trying IPFS",t.message);try{let t=h.ipfsGatewayFrom(e);return await f.p_timeout(n.p_GET(t),r,"Timed out IPFS fetch of "+t)}catch(e){throw console.log("Caught misc error in TransportIPFS.p_rawfetch trying gateway",e.message),e}}}async p_rawstore(e,{verbose:r}){console.assert(e,"TransportIPFS.p_rawstore: requires data");const n=e instanceof t?e:new t(e),i=(await this.ipfs.files.add(n,{"cid-version":1,hashAlg:"sha2-256"}))[0];return h.urlFrom(i)}async p_f_createReadStream(e,{verbose:t=!1,wanturl:r=!1}={}){let n;t&&console.log(this.name,"p_f_createreadstream %o",e);try{let i=e.pathname.split("/ipfs/")[1];if(i.includes("/"))throw new CodingError("Should not be seeing URLS with a path here:"+e);let o=this;return r?e:function(e){t&&console.log("TransportIPFS createreadstream %o %o",i,e);const r=e?e.start:0,s=e&&e.end?r+e.end+1:void 0;return n&&n.destroy&&n.destroy(),(n=o.ipfs.files.catReadableStream(i,{offset:r,length:s&&s-r})).on("error",e=>console.error(e)),n}}catch(t){throw n&&n.destroy&&n.destroy(),console.log(`p_f_createReadStream failed on ${e} ${t.message}`),t}}static async p_test(e,t){t&&console.log("TransportIPFS.test");try{const r=await this.p_setup(e,t);t&&console.log(r.name,"setup");const n=await r.p_status(t);let i;console.assert(n===u.STATUS_CONNECTED);const o="The quick brown fox",s="ipfs:/ipfs/zdpuAscRnisRkYnEyJAp1LydQ3po25rCEDPPEDMymYRfN1yPK",a=await r.p_rawstore(o,{verbose:t});t&&console.log("rawstore returned",a);const c=h.cidFrom(a);console.assert(a===s,"url should match url from rawstore");a.split("/")[2];const f=h.urlFrom(c);console.assert(a===f,"Should round trip"),i=a;const l=await r.p_rawfetch(i,{verbose:t});return console.assert(l.toString()===o,"Should fetch block stored above"),r}catch(e){throw console.log("Exception thrown in TransportIPFS.test:",e.message),e}}}c._transportclasses.IPFS=h,e.exports=h}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(339),i=r(646),o=r(110),s=r(51),a=r(391),u=r(45),c=r(111),f=r(489),l=r(52),h=r(12),p=r(490),d=r(342),y=r(9),g=r(1),m=r(273),b=r(11),v=r(1004),_=r(1012),w=r(1013),S=r(1472),k=r(1473),E=r(1477);class A extends b{constructor(e){super(),this._options={init:!0,start:!0,EXPERIMENTAL:{},preload:{enabled:!0,addresses:["/dnsaddr/node0.preload.ipfs.io/https","/dnsaddr/node1.preload.ipfs.io/https"]}},e=v.validate(e||{}),m(this._options,e),!1===e.init&&(this._options.init=!1),!1!==e.start&&(this._options.start=!0),"string"==typeof e.repo||void 0===e.repo?this._repo=S(e.repo):this._repo=e.repo,this.log=g("jsipfs"),this.log.err=g("jsipfs:err"),this.types={Buffer:t,PeerId:o,PeerInfo:s,multiaddr:l,multibase:d,multihash:h,CID:y,dagPB:u,dagCBOR:a},this._peerInfoBook=new p,this._peerInfo=void 0,this._libp2pNode=void 0,this._bitswap=void 0,this._blockService=new n(this._repo),this._ipld=new i(this._blockService),this._pubsub=void 0,this._preload=k(this),this._mfsPreload=E(this),this.init=w.init(this),this.preStart=w.preStart(this),this.start=w.start(this),this.stop=w.stop(this),this.shutdown=this.stop,this.isOnline=w.isOnline(this),this.version=w.version(this),this.id=w.id(this),this.repo=w.repo(this),this.bootstrap=w.bootstrap(this),this.config=w.config(this),this.block=w.block(this),this.object=w.object(this),this.dag=w.dag(this),this.libp2p=w.libp2p(this),this.swarm=w.swarm(this),this.files=w.files(this),this.bitswap=w.bitswap(this),this.pin=w.pin(this),this.ping=w.ping(this),this.pingPullStream=w.pingPullStream(this),this.pingReadableStream=w.pingReadableStream(this),this.pubsub=w.pubsub(this),this.dht=w.dht(this),this.dns=w.dns(this),this.key=w.key(this),this.stats=w.stats(this),this._options.EXPERIMENTAL.pubsub&&this.log("EXPERIMENTAL pubsub is enabled"),this._options.EXPERIMENTAL.sharding&&this.log("EXPERIMENTAL sharding is enabled"),this._options.EXPERIMENTAL.dht&&this.log("EXPERIMENTAL Kademlia DHT is enabled"),this.state=r(1478)(this),this.ls=this.files.lsImmutable,this.lsReadableStream=this.files.lsReadableStreamImmutable,this.lsPullStream=this.files.lsPullStreamImmutable,this.util={crypto:c,isIPFS:f};const b=w.mfs(this);Object.keys(b).forEach(e=>{this.files[e]=b[e]}),_(this)}}(e.exports=A).createNode=(e=>new A(e))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(151),i=r(8),o=r(9),s=r(673),a=r(155),u=r(339),c=r(64).join,f=r(64).sep,l=r(224).source,h=r(225),p=r(80),d=r(49),y=r(4),g=r(35).MemoryDatastore,m=r(45),b=r(391),v=r(776),_=r(781),w=r(94).ethAccountSnapshot,S=r(94).ethBlock,k=r(94).ethBlockList,E=r(94).ethStateTrie,A=r(94).ethStorageTrie,x=r(94).ethTx,I=r(94).ethTxTrie,T=r(869),B=r(870);function C(){}class P{constructor(e){if(!e)throw new Error("Missing blockservice");this.bs=e,this.resolvers={},this.support={},this.support.add=((e,t,r)=>{if(this.resolvers[e])throw new Error('Resolver already exists for codec "'+e+'"');this.resolvers[e]={resolver:t,util:r}}),this.support.rm=(e=>{this.resolvers[e]&&delete this.resolvers[e]}),this.support.add(m.resolver.multicodec,m.resolver,m.util),this.support.add(b.resolver.multicodec,b.resolver,b.util),this.support.add(v.resolver.multicodec,v.resolver,v.util),this.support.add(_.resolver.multicodec,_.resolver,_.util),this.support.add(w.resolver.multicodec,w.resolver,w.util),this.support.add(S.resolver.multicodec,S.resolver,S.util),this.support.add(k.resolver.multicodec,k.resolver,k.util),this.support.add(E.resolver.multicodec,E.resolver,E.util),this.support.add(A.resolver.multicodec,A.resolver,A.util),this.support.add(x.resolver.multicodec,x.resolver,x.util),this.support.add(I.resolver.multicodec,I.resolver,I.util),this.support.add(T.resolver.multicodec,T.resolver,T.util),this.support.add(B.resolver.multicodec,B.resolver,B.util)}get(e,t,r,n){if("function"==typeof t&&(n=t,t=void 0),"function"==typeof r&&(n=r,r={}),"string"==typeof t&&(t=c("/",t).substr(1).split(f).join("/")),""===t||!t)return this._get(e,(e,t)=>{if(e)return n(e);n(null,{value:t,remainderPath:""})});let i;s(r=>{this.bs.get(e,(n,o)=>{if(n)return r(n);const s=this.resolvers[e.codec];if(!s)return r(new Error('No resolver found for codec "'+e.codec+'"'));s.resolver.resolve(o.data,t,(e,n)=>{if(e)return r(e);i=n.value,t=n.remainderPath,r()})})},()=>{const n=!t||""===t||"/"===t,s=i&&!i["/"];return!!(n&&s||r.localResolve)||(i&&(e=new o(i["/"])),!1)},(e,r)=>e?n(e):n(null,{value:i,remainderPath:t}))}getStream(e,t,r){const n=l();return this.get(e,t,r,(e,t)=>{if(e)return n.resolve(i.error(e));n.resolve(i.values([t]))}),n}put(e,t,r){if("function"==typeof t)return r=t,setImmediate(()=>r(new Error("IPLDResolver.put requires options")));if(r=r||C,t.cid&&o.isCID(t.cid))return this._put(t.cid,e,r);const n=this.resolvers[t.format];if(!n)return r(new Error('No resolver found for codec "'+t.format+'"'));n.util.cid(e,t,(t,n)=>{if(t)return r(t);this._put(n,e,r)})}treeStream(e,t,r){let n;if("object"==typeof t&&(r=t,t=void 0),!(r=r||{}).recursive){n=l();const t=this.resolvers[e.codec];if(!t)return n.abort(new Error('No resolver found for codec "'+e.codec+'"')),n;y([t=>this.bs.get(e,t),(e,r)=>t.resolver.tree(e.data,r)],(e,t)=>{if(e)return n.abort(e),n;n.resolve(i.values(t))})}return r.recursive&&(n=i(h.widthFirst({basePath:null,cid:e},e=>{if("string"==typeof e)return i.empty();const t=l(),r=e.cid,n=this.resolvers[r.codec];return n?(y([t=>this.bs.get(e.cid,t),(e,t)=>n.resolver.tree(e.data,(r,i)=>{if(r)return t(r);p(i,(t,r)=>{n.resolver.isLink(e.data,t,(e,n)=>{if(e)return r(e);r(null,{path:t,link:n})})},t)})],(r,n)=>{if(r)return t.abort(r),t;t.resolve(i.values(n.map(t=>{const r=e.basePath?e.basePath+"/"+t.path:t.path;return t.link?{basePath:r,cid:new o(t.link["/"])}:r})))}),t):(t.abort(new Error('No resolver found for codec "'+r.codec+'"')),t)}),i.map(e=>"string"==typeof e?e:e.basePath),i.filter(Boolean))),t?i(n,i.map(e=>{if(0===e.indexOf(t))return e.slice(t.length+1)}),i.filter(Boolean)):n}remove(e,t){this.bs.delete(e,t)}_get(e,t){const r=this.resolvers[e.codec];if(!r)return t(new Error('No resolver found for codec "'+e.codec+'"'));y([t=>this.bs.get(e,t),(e,t)=>{r?r.util.deserialize(e.data,(e,r)=>{if(e)return t(e);t(null,r)}):t(null,e.data)}],t)}_put(e,t,r){r=r||C;const i=this.resolvers[e.codec];if(!i)return r(new Error('No resolver found for codec "'+e.codec+'"'));y([e=>i.util.serialize(t,e),(t,r)=>this.bs.put(new n(t,e),r)],t=>{if(t)return r(t);r(null,e)})}}P.inMemory=function(e){const t=new a("in-memory",{storageBackends:{root:g,blocks:g,datastore:g},lock:"memory"}),r=new u(t);d([e=>t.init({},e),e=>t.open(e)],t=>{if(t)return e(t);e(null,new P(r))})},e.exports=P},function(e,t){e.exports=function e(t,o,s){o=o||[];for(var a=s=s||0;t>=i;)o[s++]=255&t|r,t/=128;for(;t&n;)o[s++]=255&t|r,t>>>=7;return o[s]=0|t,e.bytes=s-a+1,o};var r=128,n=-128,i=Math.pow(2,31)},function(e,t){e.exports=function e(t,i){var o,s=0,a=0,u=i=i||0,c=t.length;do{if(u>=c)throw e.bytes=0,new RangeError("Could not decode varint");o=t[u++],s+=a<28?(o&n)<=r);return e.bytes=u-i,s};var r=128,n=127},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),u=Math.pow(2,49),c=Math.pow(2,56),f=Math.pow(2,63);e.exports=function(e){return e(e[t[0]]=new n(t[0],t[1],t[2],t[3]),e),{}),f=u.reduce((e,t)=>(e[t[1]]=c[t[0]],e),{});e.exports={names:c,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";(function(t){e.exports=function(e){return{encode:e=>"string"==typeof e?t.from(e).toString("hex"):e.toString("hex"),decode(r){for(let t of r)if(e.indexOf(t)<0)throw new Error("invalid base16 character");return t.from(r,"hex")}}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){e.exports=function(e){return{encode:r=>(function(e,t){let r=e.byteLength,n=new Uint8Array(e),i=t.indexOf("=")===t.length-1;i&&(t=t.substring(0,t.length-2));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})("string"==typeof r?t.from(r):r,e),decode(t){for(let r of t)if(e.indexOf(r)<0)throw new Error("invalid base32 character");return function(e,t){let r=(e=e.replace(new RegExp("=","g"),"")).length,n=0,i=0,o=0,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)}}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){e.exports=function(e){const r=e.indexOf("=")>-1,n=e.indexOf("-")>-1&&e.indexOf("_")>-1;return{encode(e){let i="";i="string"==typeof e?t.from(e).toString("base64"):e.toString("base64"),n&&(i=(i=i.replace("+","-")).replace("/","_"));const o=i.indexOf("=");return o>0&&!r&&(i=i.substring(0,o)),i},decode(r){n&&(r=(r=r.replace("+","-")).replace("/","_"));for(let t of r)if(e.indexOf(t)<0)throw new Error("invalid base64 character");return t.from(r,"base64")}}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(n){const i=r(20),o=r(343),s=r(345),a=r(344);(t=e.exports).addPrefix=((e,t)=>{let r;if(n.isBuffer(e))r=a.varintBufferEncode(e);else{if(!o[e])throw new Error("multicodec not recognized");r=o[e]}return n.concat([r,t])}),t.rmPrefix=(e=>(i.decode(e),e.slice(i.decode.bytes))),t.getCodec=(e=>{const t=a.varintBufferDecode(e),r=s[t.toString("hex")];if(void 0===r)throw new Error("Code `0x"+t.toString("hex")+"` not found");return r}),t.getCodeVarint=(e=>{const t=o[e];if(void 0===t)throw new Error("Codec `"+e+"` not found");return t}),t.addCodec=((e,t)=>{o[e]=a.varintBufferEncode(t),s[t.toString("hex")]=e})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(12);var i={checkCIDComponents:function(e){if(null==e)return"null values are not valid CIDs";if(0!==e.version&&1!==e.version)return"Invalid version, must be a number equal to 1 or 0";if("string"!=typeof e.codec)return"codec must be string";if(!t.isBuffer(e.multihash))return"multihash must be a Buffer";try{n.validate(e.multihash)}catch(e){let t=e.message;return t||(t="Multihash validation failed"),t}}};e.exports=i}).call(this,r(0).Buffer)},function(e,t,r){"use strict";e.exports={keys:r(658),once:r(347),values:r(86),count:r(659),infinite:r(660),empty:r(661),error:r(662)}},function(e,t,r){"use strict";var n=r(86);e.exports=function(e){return n(Object.keys(e))}},function(e,t,r){"use strict";e.exports=function(e){var t=0;return e=e||1/0,function(r,n){return r?n&&n(r):t>e?n(!0):void n(null,t++)}}},function(e,t,r){"use strict";e.exports=function(e){return e=e||Math.random,function(t,r){return t?r&&r(t):r(null,e())}}},function(e,t,r){"use strict";e.exports=function(){return function(e,t){t(!0)}}},function(e,t,r){"use strict";e.exports=function(e){return function(t,r){r(e)}}},function(e,t,r){"use strict";e.exports={drain:r(118),onEnd:r(664),log:r(665),find:r(666),reduce:r(212),collect:r(87),concat:r(667)}},function(e,t,r){"use strict";var n=r(118);e.exports=function(e){return n(null,e)}},function(e,t,r){"use strict";var n=r(118);e.exports=function(e){return n(function(e){console.log(e)},e)}},function(e,t,r){"use strict";function n(e){return e}var i=r(119),o=r(118);e.exports=function(e,t){var r=!1;return t?e=i(e)||n:(t=e,e=n),o(function(n){if(e(n))return r=!0,t(null,n),!1},function(e){r||t(!0===e?null:e,null)})}},function(e,t,r){"use strict";var n=r(212);e.exports=function(e){return n(function(e,t){return e+t},"",e)}},function(e,t,r){"use strict";e.exports={map:r(348),asyncMap:r(153),filter:r(120),filterNot:r(669),through:r(350),take:r(670),unique:r(351),nonUnique:r(671),flatten:r(672)}},function(e,t,r){"use strict";var n=r(349),i=r(120);e.exports=function(e){return e=n(e),i(function(t){return!e(t)})}},function(e,t,r){"use strict";e.exports=function(e,t){var r=(t=t||{}).last||!1,n=!1;if("number"==typeof e){r=!0;var i=e;e=function(){return--i}}return function(t){function i(e){t(!0,function(t){r=!1,e(t||!0)})}return function(o,s){n&&!o?r?i(s):s(n):(n=o)?t(n,s):t(null,function(t,o){(n=n||t)?s(n):e(o)?s(null,o):(n=!0,r?s(null,o):i(s))})}}}},function(e,t,r){"use strict";var n=r(351);e.exports=function(e){return n(e,!0)}},function(e,t,r){"use strict";var n=r(86),i=r(347);e.exports=function(){return function(e){var t;return function(r,o){function s(){t(null,function(t,r){!0===t?a():t?e(!0,function(e){o(t)}):o(null,r)})}function a(){t=null,e(null,function(e,r){if(e)return o(e);Array.isArray(r)||r&&"object"==typeof r?r=n(r):"function"!=typeof r&&(r=i(r)),t=r,s()})}r?t?t(r,function(t){e(t||r,o)}):e(r,o):t?s():a()}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){(0,n.default)(e,function(){return!t.apply(this,arguments)},r)};var n=function(e){return e&&e.__esModule?e:{default:e}}(r(352));e.exports=t.default},function(e,t,r){var n=r(158),i=Object.prototype,o=i.hasOwnProperty,s=i.toString,a=n?n.toStringTag:void 0;e.exports=function(e){var t=o.call(e,a),r=e[a];try{e[a]=void 0;var n=!0}catch(e){}var i=s.call(e);return n&&(t?e[a]=r:delete e[a]),i}},function(e,t){var r=Object.prototype.toString;e.exports=function(e){return r.call(e)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){if((0,n.default)(e))return function(e){var t=-1,r=e.length;return function(){return++t({exists(t){e.has(o,t)},get(t){e.get(o,(e,r)=>{if(e)return t(e);t(null,parseInt(r.toString().trim(),10))})},set(r,n){e.put(o,t.from(String(r)),n)},check(e,t){this.get((r,n)=>r?t(r):(i("comparing version: %s and %s",n,e),n!==e?t(new Error(`version mismatch: expected v${e}, found v${n}`)):void t()))}}))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(8),i=r(3),o=r(221).asyncFilter,s=r(221).asyncSort,a=r(365);e.exports=class{constructor(){this.data={}}open(e){i(e)}put(e,t,r){this.data[e.toString()]=t,i(r)}get(e,t){this.has(e,(r,n)=>r?t(r):n?void t(null,this.data[e.toString()]):t(new Error("No value")))}has(e,t){i(()=>{t(null,void 0!==this.data[e.toString()])})}delete(e,t){delete this.data[e.toString()],i(()=>{t()})}batch(){let e=[],t=[];return{put(t,r){e.push([t,r])},delete(e){t.push(e)},commit:r=>{e.forEach(e=>{this.data[e[0].toString()]=e[1]}),e=[],t.forEach(e=>{delete this.data[e.toString()]}),t=[],i(r)}}}query(e){let t=[n.keys(this.data),n.map(e=>({key:new a(e),value:this.data[e]}))],r=[];if(null!=e.prefix){const t=e.prefix;r.push((e,r)=>r(null,e.key.toString().startsWith(t)))}if(null!=e.filters&&(r=r.concat(e.filters)),t=t.concat(r.map(e=>o(e))),null!=e.orders&&(t=t.concat(e.orders.map(e=>s(e)))),null!=e.offset){let r=0;t.push(n.filter(()=>r++>=e.offset))}return null!=e.limit&&t.push(n.take(e.limit)),!0===e.keysOnly&&t.push(n.map(e=>({key:e.key}))),n.apply(null,t)}close(e){i(e)}}},function(e,t,r){"use strict";const n=r(35).Key,i=r(162),o=r(4),s=r(702),a=r(703),u=r(704),c=r(2).Buffer,f=new n("config");e.exports=(e=>{const t=i(function(e,t){const i=e.key,s=e.value;i?o([e=>r.get(e),(e,t)=>t(null,a(e,i,s)),n],t):n(s,t)},1),r={get(t,r){"function"==typeof t&&(r=t,t=void 0),t||(t=void 0),e.get(f,(e,n)=>{if(e)return r(e);let i;try{i=JSON.parse(n.toString())}catch(e){return r(e)}if(void 0!==t&&!u(i,t))return r(new Error("Key "+t+" does not exist in config"));let o=void 0!==t?s(i,t):i;r(null,o)})},set(e,r,n){if("function"==typeof r)n=r,r=e,e=void 0;else if(!e||"string"!=typeof e)return n(new Error("Invalid key type"));if(void 0===r||c.isBuffer(r))return n(new Error("Invalid value type"));t.push({key:e,value:r},n)},exists(t){e.has(f,t)}};return r;function n(t,r){const n=c.from(JSON.stringify(t,null,2));e.put(f,n,r)}})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){if(null==t)t=1;else if(0===t)throw new Error("Concurrency must not be zero");var f=(0,c.default)(e),l=0,h=[],p=!1;function d(e,t,r){if(null!=r&&"function"!=typeof r)throw new Error("task callback must be a function");if(m.started=!0,(0,i.default)(e)||(e=[e]),0===e.length&&m.idle())return(0,a.default)(function(){m.drain()});for(var n=0,s=e.length;n0&&h.splice(s,1),o.callback.apply(o,arguments),null!=t&&m.error(t,o.data)}l<=m.concurrency-m.buffer&&m.unsaturated(),m.idle()&&m.drain(),m.process()}}var g=!1,m={_tasks:new u.default,concurrency:t,payload:r,saturated:o.default,unsaturated:o.default,buffer:t/4,empty:o.default,drain:o.default,error:o.default,started:!1,paused:!1,push:function(e,t){d(e,!1,t)},kill:function(){m.drain=o.default,m._tasks.empty()},unshift:function(e,t){d(e,!0,t)},remove:function(e){m._tasks.remove(e)},process:function(){if(!g){for(g=!0;!m.paused&&l-1},N.prototype.set=function(e,t){var r=this.__data__,n=K(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},L.prototype.clear=function(){this.__data__={hash:new R,map:new(B||N),string:new R}},L.prototype.delete=function(e){return D(this,e).delete(e)},L.prototype.get=function(e){return D(this,e).get(e)},L.prototype.has=function(e){return D(this,e).has(e)},L.prototype.set=function(e,t){return D(this,e).set(e,t),this};var F=H(function(e){e=function(e){return null==e?"":function(e){if("string"==typeof e)return e;if(W(e))return O?O.call(e):"";var t=e+"";return"0"==t&&1/e==-i?"-0":t}(e)}(e);var t=[];return f.test(e)&&t.push(""),e.replace(l,function(e,r,n,i){t.push(n?i.replace(h,"$1"):r||e)}),t});function q(e){if("string"==typeof e||W(e))return e;var t=e+"";return"0"==t&&1/e==-i?"-0":t}function H(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError(r);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var s=e.apply(this,r);return n.cache=o.set(i,s),s};return n.cache=new(H.Cache||L),n}function z(e,t){return e===t||e!=e&&t!=t}H.Cache=L;var V=Array.isArray;function G(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function W(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&A.call(e)==a}e.exports=function(e,t,r){var n=null==e?void 0:j(e,t);return void 0===n?r:n}}).call(this,r(6))},function(e,t,r){(function(t){var r="Expected a function",n="__lodash_hash_undefined__",i=1/0,o=9007199254740991,s="[object Function]",a="[object GeneratorFunction]",u="[object Symbol]",c=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,f=/^\w*$/,l=/^\./,h=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,p=/\\(\\)?/g,d=/^\[object .+?Constructor\]$/,y=/^(?:0|[1-9]\d*)$/,g="object"==typeof t&&t&&t.Object===Object&&t,m="object"==typeof self&&self&&self.Object===Object&&self,b=g||m||Function("return this")();var v,_=Array.prototype,w=Function.prototype,S=Object.prototype,k=b["__core-js_shared__"],E=(v=/[^.]+$/.exec(k&&k.keys&&k.keys.IE_PROTO||""))?"Symbol(src)_1."+v:"",A=w.toString,x=S.hasOwnProperty,I=S.toString,T=RegExp("^"+A.call(x).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),B=b.Symbol,C=_.splice,P=H(b,"Map"),O=H(Object,"create"),R=B?B.prototype:void 0,N=R?R.toString:void 0;function L(e){var t=-1,r=e?e.length:0;for(this.clear();++t-1&&e%1==0&&e-1},K.prototype.set=function(e,t){var r=this.__data__,n=D(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},j.prototype.clear=function(){this.__data__={hash:new L,map:new(P||K),string:new L}},j.prototype.delete=function(e){return q(this,e).delete(e)},j.prototype.get=function(e){return q(this,e).get(e)},j.prototype.has=function(e){return q(this,e).has(e)},j.prototype.set=function(e,t){return q(this,e).set(e,t),this};var G=$(function(e){e=function(e){return null==e?"":function(e){if("string"==typeof e)return e;if(Z(e))return N?N.call(e):"";var t=e+"";return"0"==t&&1/e==-i?"-0":t}(e)}(e);var t=[];return l.test(e)&&t.push(""),e.replace(h,function(e,r,n,i){t.push(n?i.replace(p,"$1"):r||e)}),t});function W(e){if("string"==typeof e||Z(e))return e;var t=e+"";return"0"==t&&1/e==-i?"-0":t}function $(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError(r);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var s=e.apply(this,r);return n.cache=o.set(i,s),s};return n.cache=new($.Cache||j),n}function Y(e,t){return e===t||e!=e&&t!=t}$.Cache=j;var J=Array.isArray;function X(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Z(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&I.call(e)==u}e.exports=function(e,t,r){return null==e?e:F(e,t,r)}}).call(this,r(6))},function(e,t,r){(function(t){var r="Expected a function",n="__lodash_hash_undefined__",i=1/0,o=9007199254740991,s="[object Arguments]",a="[object Function]",u="[object GeneratorFunction]",c="[object Symbol]",f=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,l=/^\w*$/,h=/^\./,p=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,d=/\\(\\)?/g,y=/^\[object .+?Constructor\]$/,g=/^(?:0|[1-9]\d*)$/,m="object"==typeof t&&t&&t.Object===Object&&t,b="object"==typeof self&&self&&self.Object===Object&&self,v=m||b||Function("return this")();var _,w=Array.prototype,S=Function.prototype,k=Object.prototype,E=v["__core-js_shared__"],A=(_=/[^.]+$/.exec(E&&E.keys&&E.keys.IE_PROTO||""))?"Symbol(src)_1."+_:"",x=S.toString,I=k.hasOwnProperty,T=k.toString,B=RegExp("^"+x.call(I).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),C=v.Symbol,P=k.propertyIsEnumerable,O=w.splice,R=z(v,"Map"),N=z(Object,"create"),L=C?C.prototype:void 0,K=L?L.toString:void 0;function j(e){var t=-1,r=e?e.length:0;for(this.clear();++t-1&&e%1==0&&e-1},M.prototype.set=function(e,t){var r=this.__data__,n=U(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},D.prototype.clear=function(){this.__data__={hash:new j,map:new(R||M),string:new j}},D.prototype.delete=function(e){return H(this,e).delete(e)},D.prototype.get=function(e){return H(this,e).get(e)},D.prototype.has=function(e){return H(this,e).has(e)},D.prototype.set=function(e,t){return H(this,e).set(e,t),this};var W=Y(function(e){e=function(e){return null==e?"":function(e){if("string"==typeof e)return e;if(ne(e))return K?K.call(e):"";var t=e+"";return"0"==t&&1/e==-i?"-0":t}(e)}(e);var t=[];return h.test(e)&&t.push(""),e.replace(p,function(e,r,n,i){t.push(n?i.replace(d,"$1"):r||e)}),t});function $(e){if("string"==typeof e||ne(e))return e;var t=e+"";return"0"==t&&1/e==-i?"-0":t}function Y(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError(r);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var s=e.apply(this,r);return n.cache=o.set(i,s),s};return n.cache=new(Y.Cache||D),n}function J(e,t){return e===t||e!=e&&t!=t}function X(e){return function(e){return re(e)&&function(e){return null!=e&&ee(e.length)&&!Q(e)}(e)}(e)&&I.call(e,"callee")&&(!P.call(e,"callee")||T.call(e)==s)}Y.Cache=D;var Z=Array.isArray;function Q(e){var t=te(e)?T.call(e):"";return t==a||t==u}function ee(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=o}function te(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function re(e){return!!e&&"object"==typeof e}function ne(e){return"symbol"==typeof e||re(e)&&T.call(e)==c}e.exports=function(e,t){return null!=e&&V(e,t,F)}}).call(this,r(6))},function(e,t,r){"use strict";const n=r(35).Key,i=r(2).Buffer,o=new n("api");e.exports=(e=>({get(t){e.get(o,(e,r)=>t(e,r&&r.toString()))},set(t,r){e.put(o,i.from(t.toString()),r)},delete(t){e.delete(o,t)}}))},function(e,t,r){"use strict";const n=r(707),i=n.ShardingDatastore,o=r(35).Key,s=r(714),a=r(151),u=r(3),c=r(371),f=r(9),l=r(8),h=e=>(e=>{const t=new s.Encoder;return new o("/"+t.write(e).finalize(),!1)})(e.buffer);e.exports=((e,t,r)=>{!function(e,t,r){if(t.sharding){const t=new n.shard.NextToLast(2);i.createOrOpen(e,t,r)}else u(()=>r(null,e))}(e,t,(e,t)=>{if(e)return r(e);r(null,function(e){return{query(t,r){l(e.query(t),l.collect(r))},get(t,r){if(!f.isCID(t))return u(()=>{r(new Error("Not a valid cid"))});const n=h(t);e.get(n,(e,n)=>{if(e)return r(e);r(null,new a(n,t))})},put(t,r){if(!a.isBlock(t))return u(()=>{r(new Error("invalid block"))});const n=h(t.cid);e.has(n,(i,o)=>i?r(i):o?r():void e.put(n,t.data,r))},putMany(t,r){const n=t.map(e=>({key:h(e.cid),block:e})),i=e.batch();c(n,(t,r)=>e.has(t.key,r),(e,t)=>{if(e)return r(e);t.forEach(e=>{i.put(e.key,e.block.data)}),i.commit(r)})},has(t,r){if(!f.isCID(t))return u(()=>{r(new Error("Not a valid cid"))});e.has(h(t),r)},delete(t,r){if(!f.isCID(t))return u(()=>{r(new Error("Not a valid cid"))});e.delete(h(t),r)},close(t){e.close(t)}}}(t))})})},function(e,t,r){"use strict";const n=r(163),i=r(708),o=r(710),s=r(712),a=r(713),u=r(369);t.KeytransformDatastore=n,t.ShardingDatastore=i,t.MountDatastore=o,t.TieredDatastore=s,t.NamespaceDatastore=a,t.shard=u},function(e,t,r){"use strict";(function(t){const n=r(4),i=r(63),o=r(35).Key,s=r(369),a=r(163),u=new o(s.SHARDING_FN),c=new o(s.README_FN);class f{constructor(e,t){this.child=new a(e,{convert:this._convertKey.bind(this),invert:this._invertKey.bind(this)}),this.shard=t}open(e){this.child.open(e)}_convertKey(e){const t=e.toString();return t===u.toString()||t===c.toString()?e:new o(this.shard.fun(t)).child(e)}_invertKey(e){const t=e.toString();return t===u.toString()||t===c.toString()?e:o.withNamespaces(e.list().slice(1))}static createOrOpen(e,t,r){f.create(e,t,t=>{if(t&&"datastore exists"!==t.message)return r(t);f.open(e,r)})}static open(e,t){n([t=>s.readShardFun("/",e,t),(t,r)=>{r(null,new f(e,t))}],t)}static create(e,r,n){e.has(u,(o,a)=>{if(o)return n(o);if(!a){const o="function"==typeof e.putRaw?e.putRaw.bind(e):e.put.bind(e);return i([e=>o(u,t.from(r.toString()+"\n"),e),e=>o(c,t.from(s.readme),e)],e=>n(e))}s.readShardFun("/",e,(e,t)=>{if(e)return n(e);const i=(t||"").toString(),o=r.toString();if(i!==o)return n(new Error(`specified fun ${o} does not match repo shard fun ${i}`));n(new Error("datastore exists"))})})}put(e,t,r){this.child.put(e,t,r)}get(e,t){this.child.get(e,t)}has(e,t){this.child.has(e,t)}delete(e,t){this.child.delete(e,t)}batch(){return this.child.batch()}query(e){const t={keysOnly:e.keysOnly,offset:e.offset,limit:e.limit,filters:[(e,t)=>t(null,e.key.toString()!==u.toString()),(e,t)=>t(null,e.key.toString()!==c.toString())]};if(null!=e.prefix&&t.filters.push((t,r)=>{r(null,this._invertKey(t.key).toString().startsWith(e.prefix))}),null!=e.filters){const r=e.filters.map(e=>(t,r)=>{e(Object.assign({},t,{key:this._invertKey(t.key)}),r)});t.filters=t.filters.concat(r)}return null!=e.orders&&(t.orders=e.orders.map(e=>(t,r)=>{t.forEach(e=>{e.key=this._invertKey(e.key)}),e(t,(e,t)=>{if(e)return r(e);t.forEach(e=>{e.key=this._convertKey(e.key)}),r(null,t)})})),this.child.query(t)}close(e){this.child.close(e)}}e.exports=f}).call(this,r(0).Buffer)},function(e,t,r){"use strict";e.exports="This is a repository of IPLD objects. Each IPLD object is in a single file,\nnamed .data. Where is the\n\"base32\" encoding of the CID (as specified in\nhttps://github.com/multiformats/multibase) without the 'B' prefix.\nAll the object files are placed in a tree of directories, based on a\nfunction of the CID. This is a form of sharding similar to\nthe objects directory in git repositories. Previously, we used\nprefixes, we now use the next-to-last two charters.\n func NextToLast(base32cid string) {\n nextToLastLen := 2\n offset := len(base32cid) - nextToLastLen - 1\n return str[offset : offset+nextToLastLen]\n }\nFor example, an object with a base58 CIDv1 of\n zb2rhYSxw4ZjuzgCnWSt19Q94ERaeFhu9uSqRgjSdx9bsgM6f\nhas a base32 CIDv1 of\n BAFKREIA22FLID5AJ2KU7URG47MDLROZIH6YF2KALU2PWEFPVI37YLKRSCA\nand will be placed at\n SC/AFKREIA22FLID5AJ2KU7URG47MDLROZIH6YF2KALU2PWEFPVI37YLKRSCA.data\nwith 'SC' being the last-to-next two characters and the 'B' at the\nbeginning of the CIDv1 string is the multibase prefix that is not\nstored in the filename.\n"},function(e,t,r){"use strict";const n=r(50),i=r(711),o=r(8),s=r(35).Key,a=r(35).utils,u=a.asyncFilter,c=a.asyncSort,f=a.replaceStartWith,l=r(163);e.exports=class{constructor(e){this.mounts=e.slice()}open(e){n(this.mounts,(e,t)=>{e.datastore.open(t)},e)}_lookup(e){for(let t of this.mounts)if(t.prefix.toString()===e.toString()||t.prefix.isAncestorOf(e)){const r=f(e.toString(),t.prefix.toString());return{datastore:t.datastore,mountpoint:t.prefix,rest:new s(r)}}}put(e,t,r){const n=this._lookup(e);null!=n?n.datastore.put(n.rest,t,r):r(new Error("No datastore mounted for this key"))}get(e,t){const r=this._lookup(e);null!=r?r.datastore.get(r.rest,t):t(new Error("No datastore mounted for this key"))}has(e,t){const r=this._lookup(e);null!=r?r.datastore.has(r.rest,t):t(null,!1)}delete(e,t){const r=this._lookup(e);null!=r?r.datastore.delete(r.rest,t):t(new Error("No datastore mounted for this key"))}close(e){n(this.mounts,(e,t)=>{e.datastore.close(t)},e)}batch(){const e={},t=t=>{const r=this._lookup(t);if(null==r)throw new Error("No datastore mounted for this key");const n=r.mountpoint.toString();return null==e[n]&&(e[n]=r.datastore.batch()),{batch:e[n],rest:r.rest}};return{put:(e,r)=>{const n=t(e);n.batch.put(n.rest,r)},delete:e=>{const r=t(e);r.batch.delete(r.rest)},commit:t=>{n(Object.keys(e),(t,r)=>{e[t].commit(r)},t)}}}query(e){const t=this.mounts.map(t=>{const r=new l(t.datastore,{convert:e=>{throw new Error("should never be called")},invert:e=>t.prefix.child(e)});let n;return null!=e.prefix&&(n=f(e.prefix,t.prefix.toString())),r.query({prefix:n,filters:e.filters,keysOnly:e.keysOnly})});let r=[i(t)];if(null!=e.filters&&(r=r.concat(e.filters.map(e=>u(e)))),null!=e.orders&&(r=r.concat(e.orders.map(e=>c(e)))),null!=e.offset){let t=0;r.push(o.filter(()=>t++>=e.offset))}return null!=e.limit&&r.push(o.take(e.limit)),o.apply(null,r)}}},function(e,t){e.exports=function(e){var t,r,n=!!e,i=(e||[]).map(s),o=0;function s(e){return{ready:!1,reading:!1,ended:!1,read:e,data:null}}function a(){if(r){!function(){for(var e=i.length;e--;)i[e].ended&&i.splice(e,1)}();var e=i.length,s=r;if(0===e&&(t||n))return r=null,void s(t||!0);for(var a=0;ai.length)throw new Error("this should never happen");if(!(r.reading||r.ended||r.ready)){r.reading=!0;var n=!0;r.read(t,function e(i,o){r.data=o,r.ready=!0,r.reading=!1,!0===i||t?r.ended=!0:i&&(t=r.ended=i),t&&!i&&r.read(t,e),n||a()}),n=!1}}(i[e]);a()}function c(e,n){t=t||e,r=n,u()}return c.add=function(e){if(!e)return n=!0,u();i.push(s(e)),u()},c.cap=function(e){c.add(null)},c}},function(e,t,r){"use strict";const n=r(50),i=r(37);e.exports=class{constructor(e){this.stores=e.slice()}open(e){n(this.stores,(e,t)=>{e.open(t)},e)}put(e,t,r){n(this.stores,(r,n)=>{r.put(e,t,n)},r)}get(e,t){const r=this.stores.length;let n=!1,o=0;i(()=>!n&&o{this.stores[o++].get(e,(e,r)=>{if(null==e)return n=!0,t(null,r);t()})},t)}has(e,t){const r=this.stores.length;let n=!1,o=0;i(()=>!n&&o{this.stores[o++].has(e,(e,r)=>{if(null==e)return n=!0,t(null,r);t()})},t)}delete(e,t){n(this.stores,(t,r)=>{t.delete(e,r)},t)}close(e){n(this.stores,(e,t)=>{e.close(t)},e)}batch(){const e=this.stores.map(e=>e.batch());return{put:(t,r)=>{e.forEach(e=>e.put(t,r))},delete:t=>{e.forEach(e=>e.delete(t))},commit:t=>{n(e,(e,t)=>{e.commit(t)},t)}}}query(e){return this.stores[this.stores.length-1].query(e)}}},function(e,t,r){"use strict";const n=r(35).Key,i=r(163);e.exports=class extends i{constructor(e,t){super(e,{convert:e=>t.child(e),invert(e){if("/"===t.toString())return e;if(!t.isAncestorOf(e))throw new Error(`Expected prefix: (${t.toString()}) in key: ${e.toString()}`);return new n(e.toString().slice(t.toString().length),!1)}}),this.prefix=t}query(e){return e.prefix&&"/"!==this.prefix.toString()?super.query(Object.assign({},e,{prefix:this.prefix.child(new n(e.prefix)).toString()})):super.query(e)}}},function(e,t,r){"use strict";var n=function(e,t){return t||(t={}),e.split("").forEach(function(e,r){e in t||(t[e]=r)}),t},i={alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",charmap:{0:14,1:8}};i.charmap=n(i.alphabet,i.charmap);var o={alphabet:"0123456789ABCDEFGHJKMNPQRSTVWXYZ",charmap:{O:0,I:1,L:1}};o.charmap=n(o.alphabet,o.charmap);var s={alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",charmap:{}};function a(e){if(this.buf=[],this.shift=8,this.carry=0,e){switch(e.type){case"rfc4648":this.charmap=t.rfc4648.charmap;break;case"crockford":this.charmap=t.crockford.charmap;break;case"base32hex":this.charmap=t.base32hex.charmap;break;default:throw new Error("invalid type")}e.charmap&&(this.charmap=e.charmap)}}function u(e){if(this.buf="",this.shift=3,this.carry=0,e){switch(e.type){case"rfc4648":this.alphabet=t.rfc4648.alphabet;break;case"crockford":this.alphabet=t.crockford.alphabet;break;case"base32hex":this.alphabet=t.base32hex.alphabet;break;default:throw new Error("invalid type")}e.alphabet?this.alphabet=e.alphabet:e.lc&&(this.alphabet=this.alphabet.toLowerCase())}}s.charmap=n(s.alphabet,s.charmap),a.prototype.charmap=i.charmap,a.prototype.write=function(e){var t=this.charmap,r=this.buf,n=this.shift,i=this.carry;return e.toUpperCase().split("").forEach(function(e){if("="!=e){var o=255&t[e];(n-=5)>0?i|=o<>-n),i=o<<(n+=8)&255):(r.push(i|o),n=8,i=0)}}),this.shift=n,this.carry=i,this},a.prototype.finalize=function(e){return e&&this.write(e),8!==this.shift&&0!==this.carry&&(this.buf.push(this.carry),this.shift=8,this.carry=0),this.buf},u.prototype.alphabet=i.alphabet,u.prototype.write=function(e){var t,r,n,i=this.shift,o=this.carry;for(n=0;n>i,this.buf+=this.alphabet[31&t],i>5&&(t=r>>(i-=5),this.buf+=this.alphabet[31&t]),o=r<<(i=5-i),i=8-i;return this.shift=i,this.carry=o,this},u.prototype.finalize=function(e){return e&&this.write(e),3!==this.shift&&(this.buf+=this.alphabet[31&this.carry],this.shift=3,this.carry=0),this.buf},t.encode=function(e,t){return new u(t).finalize(e)},t.decode=function(e,t){return new a(t).finalize(e)},t.Decoder=a,t.Encoder=u,t.charmap=n,t.crockford=o,t.rfc4648=i,t.base32hex=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,i){(0,n.default)(e,t,function(e,t){r(e,function(e,r){t(e,!r)})},i)};var n=function(e){return e&&e.__esModule?e:{default:e}}(r(716));e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,n){((0,i.default)(t)?function(e,t,r,n){var i=new Array(t.length);e(t,function(e,t,n){r(e,function(e,r){i[t]=!!r,n(e)})},function(e){if(e)return n(e);for(var r=[],o=0;o=0;c--)if(f[c]!==l[c])return!1;for(c=f.length-1;c>=0;c--)if(!b(e[u=f[c]],t[u],r,n))return!1;return!0}function w(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 s="string"==typeof n,a=!e&&o.isError(i),u=!e&&i&&!r;if((a&&s&&w(i,r)||u)&&g(i,r,"Got unwanted exception"+n),e&&i&&r&&!w(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 d(y(e.actual),128)+" "+e.operator+" "+d(y(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}}},o.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){b(e,t,!1)||g(e,t,r,"deepEqual",l.deepEqual)},l.deepStrictEqual=function(e,t,r){b(e,t,!0)||g(e,t,r,"deepStrictEqual",l.deepStrictEqual)},l.notDeepEqual=function(e,t,r){b(e,t,!1)&&g(e,t,r,"notDeepEqual",l.notDeepEqual)},l.notDeepStrictEqual=function e(t,r,n){b(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};var k=Object.keys||function(e){var t=[];for(var r in e)s.call(e,r)&&t.push(r);return t}}).call(t,r(5))},function(e,t,r){"use strict";(function(e){var r={};t.escapeJavaScript=function(e){if(!e)return"";for(var t="",n=0;n&\u2028\u2029]/g,function(e){return 60===(t=e.charCodeAt(0))?"\\u003c":62===t?"\\u003e":38===t?"\\u0026":8232===t?"\\u2028":"\\u2029"})},r.escapeJavaScriptChar=function(t){if(t>=256)return"\\u"+r.padLeft(""+t,4);var n=e.from(String.fromCharCode(t),"ascii").toString("hex");return"\\x"+r.padLeft(n,2)},r.escapeHtmlChar=function(t){var n=r.namedHtml[t];if(void 0!==n)return n;if(t>=256)return"&#"+t+";";var i=e.from(String.fromCharCode(t),"ascii").toString("hex");return"&#x"+r.padLeft(i,2)+";"},r.padLeft=function(e,t){for(;e.length=97||t>=65&&t<=90||t>=48&&t<=57||32===t||46===t||44===t||45===t||58===t||95===t)&&(e[t]=null);return e}()}).call(t,r(3).Buffer)},function(e,t,r){"use strict";(function(e){var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=r(38),o={hasOwn:Object.prototype.hasOwnProperty,indexOf:Array.prototype.indexOf,defaultThreshold:16,maxIPv6Groups:8,categories:{valid:1,dnsWarn:7,rfc5321:15,cfws:31,deprecated:63,rfc5322:127,error:255},diagnoses:{valid:0,rfc5321TLD:9,rfc5321TLDNumeric:10,rfc5321QuotedString:11,rfc5321AddressLiteral:12,cfwsComment:17,cfwsFWS:18,undesiredNonAscii:25,deprecatedLocalPart:33,deprecatedFWS:34,deprecatedQTEXT:35,deprecatedQP:36,deprecatedComment:37,deprecatedCTEXT:38,deprecatedIPv6:39,deprecatedCFWSNearAt:49,rfc5322Domain:65,rfc5322TooLong:66,rfc5322LocalTooLong:67,rfc5322DomainTooLong:68,rfc5322LabelTooLong:69,rfc5322DomainLiteral:70,rfc5322DomainLiteralOBSDText:71,rfc5322IPv6GroupCount:72,rfc5322IPv62x2xColon:73,rfc5322IPv6BadCharacter:74,rfc5322IPv6MaxGroups:75,rfc5322IPv6ColonStart:76,rfc5322IPv6ColonEnd:77,errExpectingDTEXT:129,errNoLocalPart:130,errNoDomain:131,errConsecutiveDots:132,errATEXTAfterCFWS:133,errATEXTAfterQS:134,errATEXTAfterDomainLiteral:135,errExpectingQPair:136,errExpectingATEXT:137,errExpectingQTEXT:138,errExpectingCTEXT:139,errBackslashEnd:140,errDotStart:141,errDotEnd:142,errDomainHyphenStart:143,errDomainHyphenEnd:144,errUnclosedQuotedString:145,errUnclosedComment:146,errUnclosedDomainLiteral:147,errFWSCRLFx2:148,errFWSCRLFEnd:149,errCRNoLF:150,errUnknownTLD:160,errDomainTooShort:161},components:{localpart:0,domain:1,literal:2,contextComment:3,contextFWS:4,contextQuotedString:5,contextQuotedPair:6}};o.specials=function(){var e='()<>[]:;@\\,."',t=new Array(256);t.fill(!1);for(var r=0;r=0?o.nulNormalize(e):e.normalize("NFC")},o.checkIpV6=function(e){return e.every(function(e){return o.regex.ipV6.test(e)})},o.validDomain=function(e,t){return t.tldBlacklist?Array.isArray(t.tldBlacklist)?-1===o.indexOf.call(t.tldBlacklist,e):!o.hasOwn.call(t.tldBlacklist,e):Array.isArray(t.tldWhitelist)?-1!==o.indexOf.call(t.tldWhitelist,e):o.hasOwn.call(t.tldWhitelist,e)},t.validate=o.validate=function(t,r,s){r=r||{},t=o.normalize(t),"function"==typeof r&&(s=r,r={}),"function"!=typeof s&&(s=null);var a=void 0,u=void 0;if("number"==typeof r.errorLevel?(a=!0,u=r.errorLevel):(a=!!r.errorLevel,u=o.diagnoses.valid),r.tldWhitelist)if("string"==typeof r.tldWhitelist)r.tldWhitelist=[r.tldWhitelist];else if("object"!==n(r.tldWhitelist))throw new TypeError("expected array or object tldWhitelist");if(r.tldBlacklist)if("string"==typeof r.tldBlacklist)r.tldBlacklist=[r.tldBlacklist];else if("object"!==n(r.tldBlacklist))throw new TypeError("expected array or object tldBlacklist");if(r.minDomainAtoms&&(r.minDomainAtoms!==(0|+r.minDomainAtoms)||r.minDomainAtoms<0))throw new TypeError("expected positive integer minDomainAtoms");var c=o.diagnoses.valid,f=function(e){e>c&&(c=e)};void 0!==r.allowUnicode&&!r.allowUnicode&&/[^\x00-\x7f]/.test(t)&&f(o.diagnoses.undesiredNonAscii);for(var l={now:o.components.localpart,prev:o.components.localpart,stack:[o.components.localpart]},h="",p={local:"",domain:""},d={locals:[""],domains:[""]},y=0,g=0,m=0,b=void 0,v=!1,_=!1,w=t.length,S=void 0,k=0;k64?f(o.diagnoses.rfc5322LocalTooLong):l.prev!==o.components.contextComment&&l.prev!==o.components.contextFWS||f(o.diagnoses.deprecatedCFWSNearAt),l.now=o.components.domain,l.stack[0]=o.components.domain,y=0,g=0,_=!1;break;default:if(_)switch(l.prev){case o.components.contextComment:case o.components.contextFWS:f(o.diagnoses.errATEXTAfterCFWS);break;case o.components.contextQuotedString:f(o.diagnoses.errATEXTAfterQS);break;default:throw new Error("more atext found where none is allowed, but unrecognized prev context: "+l.prev)}else l.prev=l.now,b=S.codePointAt(0),(o.specials(b)||o.c0Controls(b)||o.c1Controls(b))&&f(o.diagnoses.errExpectingATEXT),p.local+=S,d.locals[y]+=S,g+=e.byteLength(S,"utf8")}break;case o.components.domain:switch(S){case"(":0===g?f(0===y?o.diagnoses.deprecatedCFWSNearAt:o.diagnoses.deprecatedComment):(_=!0,f(o.diagnoses.cfwsComment)),l.stack.push(l.now),l.now=o.components.contextComment;break;case".":var E=i.encode(d.domains[y]).length;0===g?f(0===y?o.diagnoses.errDotStart:o.diagnoses.errConsecutiveDots):v?f(o.diagnoses.errDomainHyphenEnd):E>63&&f(o.diagnoses.rfc5322LabelTooLong),_=!1,g=0,++y,d.domains[y]="",p.domain+=S;break;case"[":0===p.domain.length?(_=!0,g+=e.byteLength(S,"utf8"),l.stack.push(l.now),l.now=o.components.literal,p.domain+=S,d.domains[y]+=S,p.literal=""):f(o.diagnoses.errExpectingATEXT);break;case"\r":if(w===++k||"\n"!==t[k]){f(o.diagnoses.errCRNoLF);break}case" ":case"\t":0===g?f(0===y?o.diagnoses.deprecatedCFWSNearAt:o.diagnoses.deprecatedFWS):(f(o.diagnoses.cfwsFWS),_=!0),l.stack.push(l.now),l.now=o.components.contextFWS,h=S;break;default:if(_)switch(l.prev){case o.components.contextComment:case o.components.contextFWS:f(o.diagnoses.errATEXTAfterCFWS);break;case o.components.literal:f(o.diagnoses.errATEXTAfterDomainLiteral);break;default:throw new Error("more atext found where none is allowed, but unrecognized prev context: "+l.prev)}b=S.codePointAt(0),v=!1,o.specials(b)||o.c0Controls(b)||o.c1Controls(b)?f(o.diagnoses.errExpectingATEXT):"-"===S?(0===g&&f(o.diagnoses.errDomainHyphenStart),v=!0):(b<48||b>122&&b<192||b>57&&b<65||b>90&&b<97)&&f(o.diagnoses.rfc5322Domain),p.domain+=S,d.domains[y]+=S,g+=e.byteLength(S,"utf8")}break;case o.components.literal:switch(S){case"]":if(cB?f(o.diagnoses.rfc5322IPv6MaxGroups):C.length===B&&f(o.diagnoses.deprecatedIPv6)):C.length!==B&&f(o.diagnoses.rfc5322IPv6GroupCount),":"===T[0]&&":"!==T[1]?f(o.diagnoses.rfc5322IPv6ColonStart):":"===T[T.length-1]&&":"!==T[T.length-2]?f(o.diagnoses.rfc5322IPv6ColonEnd):o.checkIpV6(C)?f(o.diagnoses.rfc5321AddressLiteral):f(o.diagnoses.rfc5322IPv6BadCharacter)}}else f(o.diagnoses.rfc5322DomainLiteral);p.domain+=S,d.domains[y]+=S,g+=e.byteLength(S,"utf8"),l.prev=l.now,l.now=l.stack.pop();break;case"\\":f(o.diagnoses.rfc5322DomainLiteralOBSDText),l.stack.push(l.now),l.now=o.components.contextQuotedPair;break;case"\r":if(w===++k||"\n"!==t[k]){f(o.diagnoses.errCRNoLF);break}case" ":case"\t":f(o.diagnoses.cfwsFWS),l.stack.push(l.now),l.now=o.components.contextFWS,h=S;break;default:if(127!==(b=S.codePointAt(0))&&o.c1Controls(b)||0===b||"["===S){f(o.diagnoses.errExpectingDTEXT);break}(o.c0Controls(b)||127===b)&&f(o.diagnoses.rfc5322DomainLiteralOBSDText),p.literal+=S,p.domain+=S,d.domains[y]+=S,g+=e.byteLength(S,"utf8")}break;case o.components.contextQuotedString:switch(S){case"\\":l.stack.push(l.now),l.now=o.components.contextQuotedPair;break;case"\r":if(w===++k||"\n"!==t[k]){f(o.diagnoses.errCRNoLF);break}case"\t":p.local+=" ",d.locals[y]+=" ",g+=e.byteLength(S,"utf8"),f(o.diagnoses.cfwsFWS),l.stack.push(l.now),l.now=o.components.contextFWS,h=S;break;case'"':p.local+=S,d.locals[y]+=S,g+=e.byteLength(S,"utf8"),l.prev=l.now,l.now=l.stack.pop();break;default:127!==(b=S.codePointAt(0))&&o.c1Controls(b)||0===b||10===b?f(o.diagnoses.errExpectingQTEXT):(o.c0Controls(b)||127===b)&&f(o.diagnoses.deprecatedQTEXT),p.local+=S,d.locals[y]+=S,g+=e.byteLength(S,"utf8")}break;case o.components.contextQuotedPair:127!==(b=S.codePointAt(0))&&o.c1Controls(b)?f(o.diagnoses.errExpectingQPair):(b<31&&9!==b||127===b)&&f(o.diagnoses.deprecatedQP),l.prev=l.now,l.now=l.stack.pop();var P="\\"+S;switch(l.now){case o.components.contextComment:break;case o.components.contextQuotedString:p.local+=P,d.locals[y]+=P,g+=2;break;case o.components.literal:p.domain+=P,d.domains[y]+=P,g+=2;break;default:throw new Error("quoted pair logic invoked in an invalid context: "+l.now)}break;case o.components.contextComment:switch(S){case"(":l.stack.push(l.now),l.now=o.components.contextComment;break;case")":l.prev=l.now,l.now=l.stack.pop();break;case"\\":l.stack.push(l.now),l.now=o.components.contextQuotedPair;break;case"\r":if(w===++k||"\n"!==t[k]){f(o.diagnoses.errCRNoLF);break}case" ":case"\t":f(o.diagnoses.cfwsFWS),l.stack.push(l.now),l.now=o.components.contextFWS,h=S;break;default:if(0===(b=S.codePointAt(0))||10===b||127!==b&&o.c1Controls(b)){f(o.diagnoses.errExpectingCTEXT);break}(o.c0Controls(b)||127===b)&&f(o.diagnoses.deprecatedCTEXT)}break;case o.components.contextFWS:if("\r"===h){if("\r"===S){f(o.diagnoses.errFWSCRLFx2);break}++m>1?f(o.diagnoses.deprecatedFWS):m=1}switch(S){case"\r":w!==++k&&"\n"===t[k]||f(o.diagnoses.errCRNoLF);break;case" ":case"\t":break;default:"\r"===h&&f(o.diagnoses.errFWSCRLFEnd),m=0,l.prev=l.now,l.now=l.stack.pop(),--k}h=S;break;default:throw new Error("unknown context: "+l.now)}if(c>o.categories.rfc5322)break}if(c255)f(o.diagnoses.rfc5322DomainTooLong);else if(e.byteLength(p.local,"utf8")+O+1>254)f(o.diagnoses.rfc5322TooLong);else if(g>63)f(o.diagnoses.rfc5322LabelTooLong);else if(r.minDomainAtoms&&d.domains.length0){var m=a.shift();if((y=m._validate(h,d,n)).errors){if(i.push(this.createError("array.ordered",{pos:l,reason:y.errors,value:h},{key:r.key,path:d.path},n)),n.abortEarly)return i}else if(m._flags.strip)c.fastSplice(e,l),--l,--f;else{if(!this._flags.sparse&&void 0===y.value){if(i.push(this.createError("array.sparse",null,{key:r.key,path:d.path,pos:l},n)),n.abortEarly)return i;continue}e[l]=y.value}continue}if(!this._inner.items.length){if(i.push(this.createError("array.orderedLength",{pos:l,limit:this._inner.ordereds.length},{key:r.key,path:d.path},n)),n.abortEarly)return i;continue}}for(var b=[],v=s.length,_=0;_=0||t,"limit must be a positive integer or reference"),this._test("min",e,function(r,n,i){var o=void 0;if(t){if(o=e(n.reference||n.parent,i),!(Number.isSafeInteger(o)&&o>=0))return this.createError("array.ref",{ref:e.key},n,i)}else o=e;return r.length>=o?r:this.createError("array.min",{limit:e,value:r},n,i)})},t.prototype.max=function(e){var t=a.isRef(e);return u.assert(Number.isSafeInteger(e)&&e>=0||t,"limit must be a positive integer or reference"),this._test("max",e,function(r,n,i){var o=void 0;if(t){if(o=e(n.reference||n.parent,i),!(Number.isSafeInteger(o)&&o>=0))return this.createError("array.ref",{ref:e.key},n,i)}else o=e;return r.length<=o?r:this.createError("array.max",{limit:e,value:r},n,i)})},t.prototype.length=function(e){var t=a.isRef(e);return u.assert(Number.isSafeInteger(e)&&e>=0||t,"limit must be a positive integer or reference"),this._test("length",e,function(r,n,i){var o=void 0;if(t){if(o=e(n.reference||n.parent,i),!(Number.isSafeInteger(o)&&o>=0))return this.createError("array.ref",{ref:e.key},n,i)}else o=e;return r.length===o?r:this.createError("array.length",{limit:e,value:r},n,i)})},t.prototype.unique=function(e){u.assert(void 0===e||"function"==typeof e||"string"==typeof e,"comparator must be a function or a string");var t={};return"string"==typeof e?t.path=e:"function"==typeof e&&(t.comparator=e),this._test("unique",t,function(e,r,i){for(var o={string:Object.create(null),number:Object.create(null),undefined:Object.create(null),boolean:Object.create(null),object:new Map,function:new Map,custom:new Map},s=t.comparator||u.deepEqual,a=0;a=0,"limit must be a positive integer"),this._test("min",e,function(t,r,n){return t.length>=e?t:this.createError("binary.min",{limit:e,value:t},r,n)})},r.prototype.max=function(e){return o.assert(Number.isSafeInteger(e)&&e>=0,"limit must be a positive integer"),this._test("max",e,function(t,r,n){return t.length<=e?t:this.createError("binary.max",{limit:e,value:t},r,n)})},r.prototype.length=function(e){return o.assert(Number.isSafeInteger(e)&&e>=0,"limit must be a positive integer"),this._test("length",e,function(t,r,n){return t.length===e?t:this.createError("binary.length",{limit:e,value:t},r,n)})},r}(i),e.exports=new s.Binary}).call(t,r(3).Buffer)},function(e,t,r){"use strict";function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):function(e,t){for(var r=Object.getOwnPropertyNames(t),n=0;n=0,"n must be a positive integer"),this._test("arity",e,function(t,r,n){return t.length===e?t:this.createError("function.arity",{n:e},r,n)})},t.prototype.minArity=function(e){return i.assert(Number.isSafeInteger(e)&&e>0,"n must be a strict positive integer"),this._test("minArity",e,function(t,r,n){return t.length>=e?t:this.createError("function.minArity",{n:e},r,n)})},t.prototype.maxArity=function(e){return i.assert(Number.isSafeInteger(e)&&e>=0,"n must be a positive integer"),this._test("maxArity",e,function(t,r,n){return t.length<=e?t:this.createError("function.maxArity",{n:e},r,n)})},t.prototype.ref=function(){return this._test("ref",null,function(e,t,r){return s.isRef(e)?e:this.createError("function.ref",null,t,r)})},t.prototype.class=function(){return this._test("class",null,function(e,t,r){return/^\s*class\s/.test(e.toString())?e:this.createError("function.class",null,t,r)})},t}(o.constructor),e.exports=new a.Func},function(e,t,r){"use strict";function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):function(e,t){for(var r=Object.getOwnPropertyNames(t),n=0;n0,"multiple must be greater than 0")),this._test("multiple",e,function(r,n,i){var o=t?e(n.reference||n.parent,i):e;return!t||"number"==typeof o&&isFinite(o)?r%o==0?r:this.createError("number.multiple",{multiple:e,value:r},n,i):this.createError("number.ref",{ref:e.key},n,i)})},t.prototype.integer=function(){return this._test("integer",void 0,function(e,t,r){return Number.isSafeInteger(e)?e:this.createError("number.integer",{value:e},t,r)})},t.prototype.negative=function(){return this._test("negative",void 0,function(e,t,r){return e<0?e:this.createError("number.negative",{value:e},t,r)})},t.prototype.positive=function(){return this._test("positive",void 0,function(e,t,r){return e>0?e:this.createError("number.positive",{value:e},t,r)})},t.prototype.precision=function(e){s.assert(Number.isSafeInteger(e),"limit must be an integer"),s.assert(!("precision"in this._flags),"precision already set");var t=this._test("precision",e,function(t,r,n){var i=t.toString().match(a.precisionRx);return Math.max((i[1]?i[1].length:0)-(i[2]?parseInt(i[2],10):0),0)<=e?t:this.createError("number.precision",{limit:e,value:t},r,n)});return t._flags.precision=e,t},t.prototype.port=function(){return this._test("port",void 0,function(e,t,r){return!Number.isSafeInteger(e)||e<0||e>65535?this.createError("number.port",{value:e},t,r):e})},t}(i),a.compare=function(e,t){return function(r){var n=o.isRef(r),i="number"==typeof r&&!isNaN(r);return s.assert(i||n,"limit must be a number or reference"),this._test(e,r,function(i,o,s){var a=void 0;if(n){if("number"!=typeof(a=r(o.reference||o.parent,s))||isNaN(a))return this.createError("number.ref",{ref:r.key},o,s)}else a=r;return t(i,a)?i:this.createError("number."+e,{limit:a,value:i},o,s)})}},a.Number.prototype.min=a.compare("min",function(e,t){return e>=t}),a.Number.prototype.max=a.compare("max",function(e,t){return e<=t}),a.Number.prototype.greater=a.compare("greater",function(e,t){return e>t}),a.Number.prototype.less=a.compare("less",function(e,t){return e9),o^=3}return i%10==0&&i>0?e:this.createError("string.creditCard",{value:e},t,r)})},t.prototype.regex=function(e,t){s.assert(e instanceof RegExp,"pattern must be a RegExp");var r={pattern:new RegExp(e.source,e.ignoreCase?"i":void 0)};"string"==typeof t?r.name=t:"object"===(void 0===t?"undefined":n(t))&&(r.invert=!!t.invert,t.name&&(r.name=t.name));var i=["string.regex",r.invert?".invert":"",r.name?".name":".base"].join("");return this._test("regex",r,function(e,t,n){return r.pattern.test(e)^r.invert?e:this.createError(i,{name:r.name,pattern:r.pattern,value:e},t,n)})},t.prototype.alphanum=function(){return this._test("alphanum",void 0,function(e,t,r){return/^[a-zA-Z0-9]+$/.test(e)?e:this.createError("string.alphanum",{value:e},t,r)})},t.prototype.token=function(){return this._test("token",void 0,function(e,t,r){return/^\w+$/.test(e)?e:this.createError("string.token",{value:e},t,r)})},t.prototype.email=function(e){return e&&(s.assert("object"===(void 0===e?"undefined":n(e)),"email options must be an object"),s.assert(void 0===e.checkDNS,"checkDNS option is not supported"),s.assert(void 0===e.tldWhitelist||"object"===n(e.tldWhitelist),"tldWhitelist must be an array or object"),s.assert(void 0===e.minDomainAtoms||Number.isSafeInteger(e.minDomainAtoms)&&e.minDomainAtoms>0,"minDomainAtoms must be a positive integer"),s.assert(void 0===e.errorLevel||"boolean"==typeof e.errorLevel||Number.isSafeInteger(e.errorLevel)&&e.errorLevel>=0,"errorLevel must be a non-negative integer or boolean")),this._test("email",e,function(t,n,i){a=a||r(19);try{var o=a.validate(t,e);if(!0===o||0===o)return t}catch(t){}return this.createError("string.email",{value:t},n,i)})},t.prototype.ip=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=p.ipRegex;s.assert("object"===(void 0===e?"undefined":n(e)),"options must be an object"),e.cidr?(s.assert("string"==typeof e.cidr,"cidr must be a string"),e.cidr=e.cidr.toLowerCase(),s.assert(s.contain(p.cidrPresences,e.cidr),"cidr must be one of "+p.cidrPresences.join(", ")),e.version||"optional"===e.cidr||(t=h.createIpRegex(["ipv4","ipv6","ipvfuture"],e.cidr))):e.cidr="optional";var r=void 0;if(e.version){Array.isArray(e.version)||(e.version=[e.version]),s.assert(e.version.length>=1,"version must have at least 1 version specified"),r=[];for(var i=0;i=1,"scheme must have at least 1 scheme specified");for(var a=0;a=1,"version must have at least 1 valid version specified");for(var r=new Set,n=0;n0&&void 0!==arguments[0]?arguments[0]:{};s.assert("object"===(void 0===e?"undefined":n(e)),"hex options must be an object"),s.assert(void 0===e.byteAligned||"boolean"==typeof e.byteAligned,"byteAligned must be boolean");var t=!0===e.byteAligned,r=/^[a-f0-9]+$/i,i=this._test("hex",r,function(e,n,i){return r.test(e)?t&&e.length%2!=0?this.createError("string.hexAlign",{value:e},n,i):e:this.createError("string.hex",{value:e},n,i)});return t&&(i._flags.byteAligned=!0),i},t.prototype.base64=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};s.assert("object"===(void 0===e?"undefined":n(e)),"base64 options must be an object"),s.assert(void 0===e.paddingRequired||"boolean"==typeof e.paddingRequired,"paddingRequired must be boolean");var t=(!1===e.paddingRequired?e.paddingRequired:(e.paddingRequired,1))?/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/:/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}(==)?|[A-Za-z0-9+\/]{3}=?)?$/;return this._test("base64",t,function(e,r,n){return t.test(e)?e:this.createError("string.base64",{value:e},r,n)})},t.prototype.hostname=function(){var e=/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/;return this._test("hostname",void 0,function(t,r,n){return t.length<=255&&e.test(t)||o.isIPv6(t)?t:this.createError("string.hostname",{value:t},r,n)})},t.prototype.normalize=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"NFC";s.assert(s.contain(p.normalizationForms,e),"normalization form must be one of "+p.normalizationForms.join(", "));var t=this._test("normalize",e,function(t,r,n){return n.convert||t===t.normalize(e)?t:this.createError("string.normalize",{value:t,form:e},r,n)});return t._flags.normalize=e,t},t.prototype.lowercase=function(){var e=this._test("lowercase",void 0,function(e,t,r){return r.convert||e===e.toLocaleLowerCase()?e:this.createError("string.lowercase",{value:e},t,r)});return e._flags.case="lower",e},t.prototype.uppercase=function(){var e=this._test("uppercase",void 0,function(e,t,r){return r.convert||e===e.toLocaleUpperCase()?e:this.createError("string.uppercase",{value:e},t,r)});return e._flags.case="upper",e},t.prototype.trim=function(){var e=this._test("trim",void 0,function(e,t,r){return r.convert||e===e.trim()?e:this.createError("string.trim",{value:e},t,r)});return e._flags.trim=!0,e},t.prototype.replace=function(e,t){"string"==typeof e&&(e=new RegExp(s.escapeRegex(e),"g")),s.assert(e instanceof RegExp,"pattern must be a RegExp"),s.assert("string"==typeof t,"replacement must be a String");var r=this.clone();return r._inner.replacements||(r._inner.replacements=[]),r._inner.replacements.push({pattern:e,replacement:t}),r},t.prototype.truncate=function(e){var t=void 0===e||!!e;if(this._flags.truncate===t)return this;var r=this.clone();return r._flags.truncate=t,r},t}(u),p.compare=function(e,r){return function(n,i){var o=c.isRef(n);return s.assert(Number.isSafeInteger(n)&&n>=0||o,"limit must be a positive integer or reference"),s.assert(!i||t.isEncoding(i),"Invalid encoding:",i),this._test(e,n,function(t,s,a){var u=void 0;if(o){if(u=n(s.reference||s.parent,a),!Number.isSafeInteger(u))return this.createError("string.ref",{ref:n.key},s,a)}else u=n;return r(t,u,i)?t:this.createError("string."+e,{limit:u,value:t,encoding:i},s,a)})}},p.String.prototype.min=p.compare("min",function(e,r,n){return(n?t.byteLength(e,n):e.length)>=r}),p.String.prototype.max=p.compare("max",function(e,r,n){return(n?t.byteLength(e,n):e.length)<=r}),p.String.prototype.length=p.compare("length",function(e,r,n){return(n?t.byteLength(e,n):e.length)===r}),p.String.prototype.uuid=p.String.prototype.guid,e.exports=new p.String}).call(t,r(3).Buffer)},function(e,t,r){"use strict";var n=r(14),i={Ip:{cidrs:{ipv4:{required:"\\/(?:"+n.ipv4Cidr+")",optional:"(?:\\/(?:"+n.ipv4Cidr+"))?",forbidden:""},ipv6:{required:"\\/"+n.ipv6Cidr,optional:"(?:\\/"+n.ipv6Cidr+")?",forbidden:""},ipvfuture:{required:"\\/"+n.ipv6Cidr,optional:"(?:\\/"+n.ipv6Cidr+")?",forbidden:""}},versions:{ipv4:n.IPv4address,ipv6:n.IPv6address,ipvfuture:n.IPvFuture}}};i.Ip.createIpRegex=function(e,t){for(var r=void 0,n=0;n0?u-4:u;var f=0;for(t=0;t>16&255,a[f++]=n>>8&255,a[f++]=255&n;return 2===s?(n=i[e.charCodeAt(t)]<<2|i[e.charCodeAt(t+1)]>>4,a[f++]=255&n):1===s&&(n=i[e.charCodeAt(t)]<<10|i[e.charCodeAt(t+1)]<<4|i[e.charCodeAt(t+2)]>>2,a[f++]=n>>8&255,a[f++]=255&n),a},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o="",s=[],a=0,u=r-i;au?u:a+16383));return 1===i?(t=e[r-1],o+=n[t>>2],o+=n[t<<4&63],o+="=="):2===i&&(t=(e[r-2]<<8)+e[r-1],o+=n[t>>10],o+=n[t>>4&63],o+=n[t<<2&63],o+="="),s.push(o),s.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function f(e){return n[e>>18&63]+n[e>>12&63]+n[e>>6&63]+n[63&e]}function l(e,t,r){for(var n,i=[],o=t;o>1,f=-7,l=r?i-1:0,h=r?-1:1,p=e[t+l];for(l+=h,o=p&(1<<-f)-1,p>>=-f,f+=a;f>0;o=256*o+e[t+l],l+=h,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+e[t+l],l+=h,f-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var s,a,u,c=8*o-i-1,f=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=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*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+p]=255&a,p+=d,a/=256,i-=8);for(s=s<0;e[r+p]=255&s,p+=d,s/=256,c-=8);e[r+p-d]|=128*y}},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t){e.exports={_args:[["joi@13.4.0","/Users/jeff/projects/joi-browser"]],_development:!0,_from:"joi@13.4.0",_id:"joi@13.4.0",_inBundle:!1,_integrity:"sha512-JuK4GjEu6j7zr9FuVe2MAseZ6si/8/HaY0qMAejfDFHp7jcH4OKE937mIHM5VT4xDS0q7lpQbszbxKV9rm0yUg==",_location:"/joi",_phantomChildren:{},_requested:{type:"version",registry:!0,raw:"joi@13.4.0",name:"joi",escapedName:"joi",rawSpec:"13.4.0",saveSpec:null,fetchSpec:"13.4.0"},_requiredBy:["#DEV:/"],_resolved:"https://registry.npmjs.org/joi/-/joi-13.4.0.tgz",_spec:"13.4.0",_where:"/Users/jeff/projects/joi-browser",bugs:{url:"https://github.com/hapijs/joi/issues"},dependencies:{hoek:"5.x.x",isemail:"3.x.x",topo:"3.x.x"},description:"Object schema validation",devDependencies:{code:"5.x.x",hapitoc:"1.x.x",lab:"15.x.x"},engines:{node:">=8.9.0"},homepage:"https://github.com/hapijs/joi",keywords:["hapi","schema","validation"],license:"BSD-3-Clause",main:"lib/index.js",name:"joi",repository:{type:"git",url:"git://github.com/hapijs/joi.git"},scripts:{test:"lab -t 100 -a code -L","test-cov-html":"lab -r html -o coverage.html -a code","test-debug":"lab -a code",toc:"hapitoc",version:"npm run toc && git add API.md README.md"},version:"13.4.0"}},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}var n=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,i=function(e){return n.exec(e).slice(1)};function o(e,t){if(e.filter)return e.filter(t);for(var r=[],n=0;n=-1&&!n;i--){var s=i>=0?arguments[i]:e.cwd();if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");s&&(t=s+"/"+t,n="/"===s.charAt(0))}return t=r(o(t.split("/"),function(e){return!!e}),!n).join("/"),(n?"/":"")+t||"."},t.normalize=function(e){var n=t.isAbsolute(e),i="/"===s(e,-1);return(e=r(o(e.split("/"),function(e){return!!e}),!n).join("/"))||n||(e="."),e&&i&&(e+="/"),(n?"/":"")+e},t.isAbsolute=function(e){return"/"===e.charAt(0)},t.join=function(){var e=Array.prototype.slice.call(arguments,0);return t.normalize(o(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,u=0;u= 0x80 (not a basic code point)","invalid-input":"Invalid input"},w=c-f,S=Math.floor,k=String.fromCharCode;function E(e){throw new RangeError(_[e])}function A(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}function x(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),n+A((e=e.replace(v,".")).split("."),t).join(".")}function I(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i65535&&(t+=k((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+k(e)}).join("")}function B(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:c}function C(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function P(e,t,r){var n=0;for(e=r?S(e/p):e>>1,e+=S(e/t);e>w*l>>1;n+=c)e=S(e/w);return S(n+(w+1)*e/(e+h))}function O(e){var t,r,n,i,o,s,a,h,p,m,b=[],v=e.length,_=0,w=y,k=d;for((r=e.lastIndexOf(g))<0&&(r=0),n=0;n=128&&E("not-basic"),b.push(e.charCodeAt(n));for(i=r>0?r+1:0;i=v&&E("invalid-input"),((h=B(e.charCodeAt(i++)))>=c||h>S((u-_)/s))&&E("overflow"),_+=h*s,!(h<(p=a<=k?f:a>=k+l?l:a-k));a+=c)s>S(u/(m=c-p))&&E("overflow"),s*=m;k=P(_-o,t=b.length+1,0==o),S(_/t)>u-w&&E("overflow"),w+=S(_/t),_%=t,b.splice(_++,0,w)}return T(b)}function R(e){var t,r,n,i,o,s,a,h,p,m,b,v,_,w,A,x=[];for(v=(e=I(e)).length,t=y,r=0,o=d,s=0;s=t&&bS((u-r)/(_=n+1))&&E("overflow"),r+=(a-t)*_,t=a,s=0;su&&E("overflow"),b==t){for(h=r,p=c;!(h<(m=p<=o?f:p>=o+l?l:p-o));p+=c)A=h-m,w=c-m,x.push(k(C(m+A%w,0))),h=S(A/w);x.push(k(C(h,0))),o=P(r,_,n==i),r=0,++n}++r,++t}return x.join("")}a={version:"1.4.1",ucs2:{decode:I,encode:T},decode:O,encode:R,toASCII:function(e){return x(e,function(e){return b.test(e)?"xn--"+R(e):e})},toUnicode:function(e){return x(e,function(e){return m.test(e)?O(e.slice(4).toLowerCase()):e})}},void 0===(i=function(){return a}.call(t,r,t,e))||(e.exports=i)}()}).call(t,r(41)(e),r(5))},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){e.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},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,r){"use strict";e.exports=r(1006)},function(e,t,r){"use strict";(function(e){const n=r(277),i=r(278)(),o=r(1013),s={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"},a=(t,r,o)=>{n(i.subtle.sign({name:"HMAC"},t,r).then(t=>e.from(t)),o)};t.create=function(e,t,r){const u=s[e];n(i.subtle.importKey("raw",t,{name:"HMAC",hash:{name:u}},!1,["sign"]).then(t=>({digest(e,r){a(t,e,r)},length:o[e]})),r)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(12),i=r(1018);function o(e,t,r,i){if("function"==typeof r&&(i=r,r=void 0),!i)throw new Error("Missing callback");o.digest(e,t,r,(e,o)=>{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){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(277),i=r(278)();function o(e){return Promise.all([i.subtle.exportKey("jwk",e.privateKey),i.subtle.exportKey("jwk",e.publicKey)])}t.utils=r(1021),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(o).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"]);n(Promise.all([r,function(e){return i.subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}(e)]).then(e=>o({privateKey:e[0],publicKey:e[1]})).then(e=>({privateKey:e[0],publicKey:e[1]})),t)},t.getRandomValues=function(t){return e.from(i.getRandomValues(t))},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)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(15).bignum;t.toBase64=function(t,r){return t.toArrayLike(e,"be",r).toString("base64").replace(/(=*)$/,"").replace(/\+/g,"-").replace(/\//g,"_")},t.toBn=function(t){return new n(e.from(t,"base64"))}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(499);e.exports=function(e){if(!e||"number"!=typeof e)throw new Error("first argument must be a Number bigger than 0");return n.getRandomValues(new Uint8Array(e))}},function(e,t,r){(function(t){var r="Expected a function",n=NaN,i="[object Symbol]",o=/^\s+|\s+$/g,s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt,f="object"==typeof t&&t&&t.Object===Object&&t,l="object"==typeof self&&self&&self.Object===Object&&self,h=f||l||Function("return this")(),p=Object.prototype.toString,d=Math.max,y=Math.min,g=function(){return h.Date.now()};function m(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function b(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&p.call(e)==i}(e))return n;if(m(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=m(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(o,"");var r=a.test(e);return r||u.test(e)?c(e.slice(2),r?2:8):s.test(e)?n:+e}e.exports=function(e,t,n){var i,o,s,a,u,c,f=0,l=!1,h=!1,p=!0;if("function"!=typeof e)throw new TypeError(r);function v(t){var r=i,n=o;return i=o=void 0,f=t,a=e.apply(n,r)}function _(e){var r=e-c;return void 0===c||r>=t||r<0||h&&e-f>=s}function w(){var e=g();if(_(e))return S(e);u=setTimeout(w,function(e){var r=t-(e-c);return h?y(r,s-(e-f)):r}(e))}function S(e){return u=void 0,p&&i?v(e):(i=o=void 0,a)}function k(){var e=g(),r=_(e);if(i=arguments,o=this,c=e,r){if(void 0===u)return function(e){return f=e,u=setTimeout(w,t),l?v(e):a}(c);if(h)return u=setTimeout(w,t),v(c)}return void 0===u&&(u=setTimeout(w,t)),a}return t=b(t)||0,m(n)&&(l=!!n.leading,s=(h="maxWait"in n)?d(b(n.maxWait)||0,t):s,p="trailing"in n?!!n.trailing:p),k.cancel=function(){void 0!==u&&clearTimeout(u),f=0,i=c=o=u=void 0},k.flush=function(){return void 0===u?a:S(g())},k}}).call(this,r(7))},function(e,t,r){"use strict";var n=r(1044);function i(e){return"function"==typeof e}function o(e,t){return t?function(r,n){var i=setTimeout(function(){e(new Error("pull-reader: read exceeded timeout"),n)},t);e(r,function(e,t){clearTimeout(i),n(e,t)})}:e}e.exports=function(e){var t,r,s,a,u,c=[],f=!1,l=n();function h(){for(;c.length;)if(null==c[0].length&&l.has(1))c.shift().cb(null,l.get());else if(l.has(c[0].length)){var e=c.shift();e.cb(null,l.get(e.length))}else if(1==s&&c[0].length&&l.length-1&&e%1==0&&e-1&&e%1==0&&e<=r}(e.length)&&!function(e){var t=function(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}(e)?f.call(e):"";return t==i||t==o}(e)}e.exports=function(e){return e?a(e,function(e){return b(e)?p(e):d(e)}(e)):[]}},function(e,t,r){"use strict";const n=Math.exp;e.exports=function(e){if("number"!=typeof e)throw new Error("must provide a timespan to the moving average constructor");if(e<=0)throw new Error("must provide a timespan > 0 to the moving average constructor");let t,r,i=0,o=0,s=0,a={};function u(t,r){return 1-n(-(t-r)/e)}return a.push=function(e,n){if(r){const a=u(e,r),c=n-t;t=a*n+(1-a)*t,i=(1-a)*(i+c*(a*c)),o=Math.sqrt(i),s=t+a*c}else t=n;r=e},a.movingAverage=function(){return t},a.variance=function(){return i},a.deviation=function(){return o},a.forecast=function(){return s},a}},function(e){e.exports={_from:"ipfs@0.31.1",_id:"ipfs@0.31.1",_inBundle:!1,_integrity:"sha512-xe0wUkDAvLlSrJyyFtZRdZNJvz0ikW93vRKe3Z/OWkoaaYkBhyWgrQY2v8w61JlWxVMnt7PMhMGzVZRPciL6Dw==",_location:"/ipfs",_phantomChildren:{},_requested:{type:"version",registry:!0,raw:"ipfs@0.31.1",name:"ipfs",escapedName:"ipfs",rawSpec:"0.31.1",saveSpec:null,fetchSpec:"0.31.1"},_requiredBy:["#USER","/"],_resolved:"https://registry.npmjs.org/ipfs/-/ipfs-0.31.1.tgz",_shasum:"b00127724b5b7ea6647128d1abbb1d5d485ea81c",_spec:"ipfs@0.31.1",_where:"/Users/mitra/git/dweb-transports",bin:{jsipfs:"src/cli/bin.js"},browser:{"./src/core/components/init-assets.js":!1,"./src/core/runtime/config-nodejs.js":"./src/core/runtime/config-browser.js","./src/core/runtime/libp2p-nodejs.js":"./src/core/runtime/libp2p-browser.js","./src/core/runtime/preload-nodejs.js":"./src/core/runtime/preload-browser.js","./src/core/runtime/repo-nodejs.js":"./src/core/runtime/repo-browser.js","./src/core/runtime/dns-nodejs.js":"./src/core/runtime/dns-browser.js","./test/utils/create-repo-nodejs.js":"./test/utils/create-repo-browser.js",stream:"readable-stream",joi:"joi-browser"},bugs:{url:"https://github.com/ipfs/js-ipfs/issues"},bundleDependencies:!1,contributors:[{name:"Alan Shaw",email:"alan@tableflip.io"},{name:"Alex Potsides",email:"alex@achingbrain.net"},{name:"Andrew de Andrade",email:"andrew@deandrade.com.br"},{name:"Arpit Agarwal",email:"93arpit@gmail.com"},{name:"Arpit Agarwal",email:"atvanguard@users.noreply.github.com"},{name:"Bernard Mordan",email:"bernard@tableflip.io"},{name:"Brian Vander Schaaf",email:"bvs330@gmail.com"},{name:"Bruno Zell",email:"bruno.zzell@gmail.com"},{name:"CHEVALAY JOSSELIN",email:"josselin54.chevalay@gmail.com"},{name:"Caio Gondim",email:"me@caiogondim.com"},{name:"Christian Couder",email:"chriscool@tuxfamily.org"},{name:"Dafeng",email:"dfguo.joe@gmail.com"},{name:"Daniel J. O'Quinn",email:"danieljoquinn@gmail.com"},{name:"Daniela Borges Matos de Carvalho",email:"alunassertiva@gmail.com"},{name:"David Dias",email:"daviddias.p@gmail.com"},{name:"David da Silva",email:"dasilvacontin@gmail.com"},{name:"Diogo Silva",email:"fsdiogo@gmail.com"},{name:"Dmitriy Ryajov",email:"dryajov@gmail.com"},{name:"Dzmitry Das",email:"dbachko@gmail.com"},{name:"Enrico Marino",email:"enrico.marino@email.com"},{name:"Faheel Ahmad",email:"faheel@live.in"},{name:"Felix Yan",email:"felixonmars@archlinux.org"},{name:"Francisco Baio Dias",email:"xicombd@gmail.com"},{name:"Francisco Baio Dias",email:"francisco@typeform.com"},{name:"Friedel Ziegelmayer",email:"dignifiedquire@gmail.com"},{name:"Gar",email:"gar+gh@danger.computer"},{name:"Georgios Rassias",email:"georassias@gmail.com"},{name:"Gorka Ludlow",email:"gorka@aquigorka.com"},{name:"Greenkeeper",email:"support@greenkeeper.io"},{name:"Haad",email:"haadcode@users.noreply.github.com"},{name:"Haoliang Yu",email:"haoliangyu@users.noreply.github.com"},{name:"Harsh Vakharia",email:"harshjv@users.noreply.github.com"},{name:"Henrique Dias",email:"hacdias@gmail.com"},{name:"Henry Rodrick",email:"moshisushi@gmail.com"},{name:"Heo Sangmin",email:"heo@mapiacompany.com"},{name:"Jacob Heun",email:"jacobheun@gmail.com"},{name:"Jacob Heun",email:"jake@andyet.net"},{name:"Jade Meskill",email:"jade.meskill@gmail.com"},{name:"Johannes Wikner",email:"johannes.wikner@gmail.com"},{name:"Jon Schlinkert",email:"dev@sellside.com"},{name:"Jonathan",email:"jkrone@vt.edu"},{name:"João Antunes",email:"j.goncalo.antunes@gmail.com"},{name:"João Santos",email:"joaosantos15@users.noreply.github.com"},{name:"Kevin Wang",email:"kevin@fossa.io"},{name:"Lars Gierth",email:"larsg@systemli.org"},{name:"Lukas Drgon",email:"lukas.drgon@gmail.com"},{name:"Maciej Krüger",email:"mkg20001@gmail.com"},{name:"Marius Darila",email:"marius.darila@gmail.com"},{name:"Michelle Lee",email:"michelle@protocol.ai"},{name:"Mikeal Rogers",email:"mikeal.rogers@gmail.com"},{name:"Mithgol",email:"getgit@mithgol.ru"},{name:"My9Bot",email:"34904312+My9Bot@users.noreply.github.com"},{name:"Nuno Nogueira",email:"nunofmn@gmail.com"},{name:"Oskar Nyberg",email:"oskar@oskarnyberg.com"},{name:"Pascal Precht",email:"pascal.precht@googlemail.com"},{name:"Pau Ramon Revilla",email:"masylum@gmail.com"},{name:"Paulo Rodrigues",email:"me@paulogr.com"},{name:"Pedro Teixeira",email:"i@pgte.me"},{name:"RasmusErik Voel Jensen",email:"github@solsort.com"},{name:"Richard Littauer",email:"richard.littauer@gmail.com"},{name:"Richard Schneider",email:"makaretu@gmail.com"},{name:"Rob Brackett",email:"rob@robbrackett.com"},{name:"Rod Keys",email:"rod@zokos.com"},{name:"Sangwon Hong",email:"qpakzk@gmail.com"},{name:"Sid Harder",email:"sideharder@gmail.com"},{name:"SidHarder",email:"softwarenavigator@gmail.com"},{name:"Stephen Whitmore",email:"stephen.whitmore@gmail.com"},{name:"Stephen Whitmore",email:"noffle@users.noreply.github.com"},{name:"Terence Pae",email:"terencepae@gmail.com"},{name:"Uroš Jurglič",email:"jurglic@gmail.com"},{name:"Vasco Santos",email:"vasco.santos@ua.pt"},{name:"Vasco Santos",email:"vasco.santos@moxy.studio"},{name:"Volker Mische",email:"volker.mische@gmail.com"},{name:"Xiao Liang",email:"yxliang01@users.noreply.github.com"},{name:"Yahya",email:"ya7yaz@gmail.com"},{name:"bitspill",email:"bitspill+github@bitspill.net"},{name:"haad",email:"haad@headbanggames.com"},{name:"jbenet",email:"juan@benet.ai"},{name:"jonahweissman",email:"19804455+jonahweissman@users.noreply.github.com"},{name:"kevingzhang",email:"kevin.zhang.canada@gmail.com"},{name:"kumavis",email:"kumavis@users.noreply.github.com"},{name:"nginnever",email:"ginneversource@gmail.com"},{name:"npmcdn-to-unpkg-bot",email:"npmcdn-to-unpkg-bot@users.noreply.github.com"},{name:"robbsolter",email:"35879806+robbsolter@users.noreply.github.com"},{name:"seungwon-kang",email:"ksw3894@gmail.com"},{name:"tcme",email:"hi@this-connect.me"},{name:"Łukasz Magiera",email:"magik6k@users.noreply.github.com"},{name:"ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ",email:"victorbjelkholm@gmail.com"}],dependencies:{"@nodeutils/defaults-deep":"^1.1.0",async:"^2.6.1","big.js":"^5.1.2","binary-querystring":"~0.1.2",bl:"^2.0.1",boom:"^7.2.0",bs58:"^4.0.1",byteman:"^1.3.5",cids:"~0.5.3",debug:"^3.1.0","file-type":"^8.1.0",filesize:"^3.6.1",fnv1a:"^1.0.1","fsm-event":"^2.1.0","get-folder-size":"^2.0.0",glob:"^7.1.2",hapi:"^16.6.2","hapi-set-header":"^1.0.2",hoek:"^5.0.3","human-to-milliseconds":"^1.0.0","interface-datastore":"~0.4.2","ipfs-api":"^22.2.4","ipfs-bitswap":"~0.20.3","ipfs-block":"~0.7.1","ipfs-block-service":"~0.14.0","ipfs-http-response":"~0.1.2","ipfs-mfs":"~0.2.3","ipfs-multipart":"~0.1.0","ipfs-repo":"~0.22.1","ipfs-unixfs":"~0.1.15","ipfs-unixfs-engine":"~0.31.3",ipld:"~0.17.3","ipld-dag-cbor":"~0.12.1","ipld-dag-pb":"~0.14.6","is-ipfs":"~0.4.2","is-pull-stream":"~0.0.0","is-stream":"^1.1.0",joi:"^13.4.0","joi-browser":"^13.4.0","joi-multiaddr":"^2.0.0",libp2p:"~0.23.0","libp2p-bootstrap":"~0.9.3","libp2p-circuit":"~0.2.0","libp2p-floodsub":"~0.15.0","libp2p-kad-dht":"~0.10.1","libp2p-keychain":"~0.3.1","libp2p-mdns":"~0.12.0","libp2p-mplex":"~0.8.0","libp2p-secio":"~0.10.0","libp2p-tcp":"~0.12.0","libp2p-webrtc-star":"~0.15.3","libp2p-websocket-star":"~0.8.1","libp2p-websockets":"~0.12.0",lodash:"^4.17.10",mafmt:"^6.0.0","mime-types":"^2.1.19",mkdirp:"~0.5.1",multiaddr:"^5.0.0","multiaddr-to-uri":"^4.0.0",multibase:"~0.4.0",multihashes:"~0.4.13",once:"^1.4.0","path-exists":"^3.0.0","peer-book":"~0.8.0","peer-id":"~0.11.0","peer-info":"~0.14.1",progress:"^2.0.0","prom-client":"^11.1.1","prometheus-gc-stats":"~0.5.1","promisify-es6":"^1.0.3","pull-abortable":"^4.1.1","pull-defer":"~0.2.2","pull-file":"^1.1.0","pull-ndjson":"~0.1.1","pull-paramap":"^1.2.2","pull-pushable":"^2.2.0","pull-sort":"^1.0.1","pull-stream":"^3.6.8","pull-stream-to-stream":"^1.3.4","pull-zip":"^2.0.1","read-pkg-up":"^4.0.0","readable-stream":"2.3.6","stream-to-pull-stream":"^1.7.2","tar-stream":"^1.6.1",temp:"~0.8.3",through2:"^2.0.3","update-notifier":"^2.5.0",yargs:"^12.0.1","yargs-parser":"^10.1.0","yargs-promise":"^1.1.0"},deprecated:!1,description:"JavaScript implementation of the IPFS specification",devDependencies:{aegir:"^15.1.0","buffer-loader":"~0.0.1",chai:"^4.1.2",delay:"^3.0.0","detect-node":"^2.0.3","dir-compare":"^1.4.0","dirty-chai":"^2.0.1","eslint-plugin-react":"^7.10.0",execa:"~0.10.0","expose-loader":"~0.7.5","form-data":"^2.3.2",hat:"0.0.3","interface-ipfs-core":"~0.72.1","ipfsd-ctl":"~0.38.0",mocha:"^5.2.0",ncp:"^2.0.0",nexpect:"~0.5.0","pretty-bytes":"^5.1.0",qs:"^6.5.2","random-fs":"^1.0.3",rimraf:"^2.6.2","stream-to-promise":"^2.2.0","transform-loader":"~0.2.4"},engines:{node:">=6.0.0",npm:">=3.0.0"},homepage:"https://github.com/ipfs/js-ipfs#readme",keywords:["IPFS"],leadMaintainer:"Alan Shaw ",license:"MIT",main:"src/core/index.js",name:"ipfs",optionalDependencies:{"prom-client":"^11.1.1","prometheus-gc-stats":"~0.5.1"},repository:{type:"git",url:"git+https://github.com/ipfs/js-ipfs.git"},scripts:{benchmark:'echo "Error: no benchmarks yet" && exit 1',"benchmark:browser":'echo "Error: no benchmarks yet" && exit 1',"benchmark:node":'echo "Error: no benchmarks yet" && exit 1',"benchmark:node:core":'echo "Error: no benchmarks yet" && exit 1',"benchmark:node:http":'echo "Error: no benchmarks yet" && exit 1',build:"aegir build",coverage:"aegir coverage","coverage-publish":"aegir-coverage publish",lint:"aegir lint",release:"aegir release -t node -t browser","release-major":"aegir release --type major -t node -t browser","release-minor":"aegir release --type minor -t node -t browser",test:"aegir test -t node -t browser -t webworker --no-cors","test:bootstrapers":"IPFS_TEST=bootstrapers aegir test -t browser -f test/bootstrapers.js","test:browser":"aegir test -t browser --no-cors","test:node":"aegir test -t node","test:node:cli":"aegir test -t node -f test/cli/index.js","test:node:core":"aegir test -t node -f test/core/**/*.js","test:node:gateway":"aegir test -t node -f test/gateway/index.js","test:node:http":"aegir test -t node -f test/http-api/index.js","test:webworker":"aegir test -t webworker --no-cors"},version:"0.31.1"}},function(e,t,r){"use strict";const n=r(23),i=r(155).repoVersion;e.exports=function(e){return{init:(e,t,r)=>{},version:n(t=>{e._repo._isInitialized(r=>{if(r){return[/Key not found in database \[\/version\]/,/ENOENT/,/repo is not initialized yet/].some(e=>e.test(r.message))?t(null,i):t(r)}e._repo.version.get(t)})}),gc:n((e,t)=>{"function"==typeof e&&(t=e,e={}),t(new Error("Not implemented"))}),stat:n((t,r)=>{"function"==typeof t&&(r=t,t={}),e._repo.stat(t,(e,t)=>{if(e)return r(e);r(null,{numObjects:t.numObjects,repoSize:t.repoSize,repoPath:t.repoPath,version:t.version.toString(),storageMax:t.storageMax})})}),path:()=>e._repo.path}}},function(e,t,r){"use strict";e.exports=(()=>({Addresses:{Swarm:[],API:"",Gateway:""},Discovery:{MDNS:{Enabled:!1,Interval:10},webRTCStar:{Enabled:!0}},Bootstrap:["/dns4/ams-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd","/dns4/lon-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3","/dns4/sfo-3.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM","/dns4/sgp-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu","/dns4/nyc-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm","/dns4/nyc-2.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64","/dns4/node0.preload.ipfs.io/tcp/443/wss/ipfs/QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic","/dns4/node1.preload.ipfs.io/tcp/443/wss/ipfs/Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6"]}))},function(e,t,r){"use strict";const n=r(1072),i=r(78),o=r(58),s=r(1081),a=r(47).Connection,u=r(1083),c=r(1)("libp2p:websockets:dialer"),f=r(1084);e.exports=o(class{dial(e,t,r){"function"==typeof t&&(r=t,t={}),r=r||function(){};const i=u(e);c("dialing %s",i);const o=n(i,{binary:!0,onConnect:e=>{r(e)}}),s=new a(o);return s.getObservedAddrs=(t=>t(null,[e])),s.close=(e=>o.close(e)),s}createListener(e,t){return"function"==typeof e&&(t=e,e={}),f(e,t)}filter(e){return Array.isArray(e)||(e=[e]),e.filter(e=>!s(e.protoNames(),"p2p-circuit")&&(s(e.protoNames(),"ipfs")&&(e=e.decapsulate("ipfs")),i.WebSockets.matches(e)||i.WebSocketsSecure.matches(e)))}},{className:"WebSockets",symbolName:"@libp2p/js-libp2p-websockets/websockets"})},function(e,t,r){var n=r(1086),i=r(282),o=r(514),s=r(1)("socket.io-client");e.exports=t=u;var a=t.managers={};function u(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};var r,i=n(e),u=i.source,c=i.id,f=i.path,l=a[c]&&f in a[c].nsps;return t.forceNew||t["force new connection"]||!1===t.multiplex||l?(s("ignoring socket cache for %s",u),r=o(u,t)):(a[c]||(s("new io instance for %s",u),a[c]=o(u,t)),r=a[c]),i.query&&!t.query&&(t.query=i.query),r.socket(i.path,t)}t.protocol=i.protocol,t.connect=u,t.Manager=r(514),t.Socket=r(519)},function(e,t){var r=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,n=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];e.exports=function(e){var t=e,i=e.indexOf("["),o=e.indexOf("]");-1!=i&&-1!=o&&(e=e.substring(0,i)+e.substring(i,o).replace(/:/g,";")+e.substring(o,e.length));for(var s=r.exec(e||""),a={},u=14;u--;)a[n[u]]=s[u]||"";return-1!=i&&-1!=o&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a}},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t,r){(function(t){e.exports=function(e){return r&&t.Buffer.isBuffer(e)||n&&(e instanceof t.ArrayBuffer||i(e))};var r="function"==typeof t.Buffer&&"function"==typeof t.Buffer.isBuffer,n="function"==typeof t.ArrayBuffer,i=n&&"function"==typeof t.ArrayBuffer.isView?t.ArrayBuffer.isView:function(e){return e.buffer instanceof t.ArrayBuffer}}).call(this,r(7))},function(e,t,r){var n=r(1088),i=r(519),o=r(114),s=r(282),a=r(520),u=r(521),c=r(1)("socket.io-client:manager"),f=r(263),l=r(1103),h=Object.prototype.hasOwnProperty;function p(e,t){if(!(this instanceof p))return new p(e,t);e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.nsps={},this.subs=[],this.opts=t,this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor||.5),this.backoff=new l({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this.readyState="closed",this.uri=e,this.connecting=[],this.lastPing=null,this.encoding=!1,this.packetBuffer=[];var r=t.parser||s;this.encoder=new r.Encoder,this.decoder=new r.Decoder,this.autoConnect=!1!==t.autoConnect,this.autoConnect&&this.open()}e.exports=p,p.prototype.emitAll=function(){for(var e in this.emit.apply(this,arguments),this.nsps)h.call(this.nsps,e)&&this.nsps[e].emit.apply(this.nsps[e],arguments)},p.prototype.updateSocketIds=function(){for(var e in this.nsps)h.call(this.nsps,e)&&(this.nsps[e].id=this.generateId(e))},p.prototype.generateId=function(e){return("/"===e?"":e+"#")+this.engine.id},o(p.prototype),p.prototype.reconnection=function(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection},p.prototype.reconnectionAttempts=function(e){return arguments.length?(this._reconnectionAttempts=e,this):this._reconnectionAttempts},p.prototype.reconnectionDelay=function(e){return arguments.length?(this._reconnectionDelay=e,this.backoff&&this.backoff.setMin(e),this):this._reconnectionDelay},p.prototype.randomizationFactor=function(e){return arguments.length?(this._randomizationFactor=e,this.backoff&&this.backoff.setJitter(e),this):this._randomizationFactor},p.prototype.reconnectionDelayMax=function(e){return arguments.length?(this._reconnectionDelayMax=e,this.backoff&&this.backoff.setMax(e),this):this._reconnectionDelayMax},p.prototype.timeout=function(e){return arguments.length?(this._timeout=e,this):this._timeout},p.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()},p.prototype.open=p.prototype.connect=function(e,t){if(c("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;c("opening %s",this.uri),this.engine=n(this.uri,this.opts);var r=this.engine,i=this;this.readyState="opening",this.skipReconnect=!1;var o=a(r,"open",function(){i.onopen(),e&&e()}),s=a(r,"error",function(t){if(c("connect_error"),i.cleanup(),i.readyState="closed",i.emitAll("connect_error",t),e){var r=new Error("Connection error");r.data=t,e(r)}else i.maybeReconnectOnOpen()});if(!1!==this._timeout){var u=this._timeout;c("connect attempt will timeout after %d",u);var f=setTimeout(function(){c("connect attempt timed out after %d",u),o.destroy(),r.close(),r.emit("error","timeout"),i.emitAll("connect_timeout",u)},u);this.subs.push({destroy:function(){clearTimeout(f)}})}return this.subs.push(o),this.subs.push(s),this},p.prototype.onopen=function(){c("open"),this.cleanup(),this.readyState="open",this.emit("open");var e=this.engine;this.subs.push(a(e,"data",u(this,"ondata"))),this.subs.push(a(e,"ping",u(this,"onping"))),this.subs.push(a(e,"pong",u(this,"onpong"))),this.subs.push(a(e,"error",u(this,"onerror"))),this.subs.push(a(e,"close",u(this,"onclose"))),this.subs.push(a(this.decoder,"decoded",u(this,"ondecoded")))},p.prototype.onping=function(){this.lastPing=new Date,this.emitAll("ping")},p.prototype.onpong=function(){this.emitAll("pong",new Date-this.lastPing)},p.prototype.ondata=function(e){this.decoder.add(e)},p.prototype.ondecoded=function(e){this.emit("packet",e)},p.prototype.onerror=function(e){c("error",e),this.emitAll("error",e)},p.prototype.socket=function(e,t){var r=this.nsps[e];if(!r){r=new i(this,e,t),this.nsps[e]=r;var n=this;r.on("connecting",o),r.on("connect",function(){r.id=n.generateId(e)}),this.autoConnect&&o()}function o(){~f(n.connecting,r)||n.connecting.push(r)}return r},p.prototype.destroy=function(e){var t=f(this.connecting,e);~t&&this.connecting.splice(t,1),this.connecting.length||this.close()},p.prototype.packet=function(e){c("writing packet %j",e);var t=this;e.query&&0===e.type&&(e.nsp+="?"+e.query),t.encoding?t.packetBuffer.push(e):(t.encoding=!0,this.encoder.encode(e,function(r){for(var n=0;n0&&!this.encoding){var e=this.packetBuffer.shift();this.packet(e)}},p.prototype.cleanup=function(){c("cleanup");for(var e=this.subs.length,t=0;t=this._reconnectionAttempts)c("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var t=this.backoff.duration();c("will wait %dms before reconnect attempt",t),this.reconnecting=!0;var r=setTimeout(function(){e.skipReconnect||(c("attempting reconnect"),e.emitAll("reconnect_attempt",e.backoff.attempts),e.emitAll("reconnecting",e.backoff.attempts),e.skipReconnect||e.open(function(t){t?(c("reconnect attempt error"),e.reconnecting=!1,e.reconnect(),e.emitAll("reconnect_error",t.data)):(c("reconnect success"),e.onreconnect())}))},t);this.subs.push({destroy:function(){clearTimeout(r)}})}},p.prototype.onreconnect=function(){var e=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",e)}},function(e,t,r){(function(e){var n=r(283),i=r(1091),o=r(1099),s=r(1100);t.polling=function(t){var r=!1,s=!1,a=!1!==t.jsonp;if(e.location){var u="https:"===location.protocol,c=location.port;c||(c=u?443:80),r=t.hostname!==location.hostname||c!==t.port,s=t.secure!==u}if(t.xdomain=r,t.xscheme=s,"open"in new n(t)&&!t.forceJSONP)return new i(t);if(!a)throw new Error("JSONP disabled");return new o(t)},t.websocket=s}).call(this,r(7))},function(e,t,r){var n=r(284),i=r(189),o=r(115),s=r(190),a=r(518),u=r(1)("engine.io-client:polling");e.exports=f;var c=null!=new(r(283))({xdomain:!1}).responseType;function f(e){var t=e&&e.forceBase64;c&&!t||(this.supportsBinary=!1),n.call(this,e)}s(f,n),f.prototype.name="polling",f.prototype.doOpen=function(){this.poll()},f.prototype.pause=function(e){var t=this;function r(){u("paused"),t.readyState="paused",e()}if(this.readyState="pausing",this.polling||!this.writable){var n=0;this.polling&&(u("we are currently polling - waiting to pause"),n++,this.once("pollComplete",function(){u("pre-pause polling complete"),--n||r()})),this.writable||(u("we are currently writing - waiting to pause"),n++,this.once("drain",function(){u("pre-pause writing complete"),--n||r()}))}else r()},f.prototype.poll=function(){u("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},f.prototype.onData=function(e){var t=this;u("polling got data %s",e);o.decodePayload(e,this.socket.binaryType,function(e,r,n){if("opening"===t.readyState&&t.onOpen(),"close"===e.type)return t.onClose(),!1;t.onPacket(e)}),"closed"!==this.readyState&&(this.polling=!1,this.emit("pollComplete"),"open"===this.readyState?this.poll():u('ignoring poll - transport state "%s"',this.readyState))},f.prototype.doClose=function(){var e=this;function t(){u("writing close packet"),e.write([{type:"close"}])}"open"===this.readyState?(u("transport open - closing"),t()):(u("transport not open - deferring close"),this.once("open",t))},f.prototype.write=function(e){var t=this;this.writable=!1;var r=function(){t.writable=!0,t.emit("drain")};o.encodePayload(e,this.supportsBinary,function(e){t.doWrite(e,r)})},f.prototype.uri=function(){var e=this.query||{},t=this.secure?"https":"http",r="";return!1!==this.timestampRequests&&(e[this.timestampParam]=a()),this.supportsBinary||e.sid||(e.b64=1),e=i.encode(e),this.port&&("https"===t&&443!==Number(this.port)||"http"===t&&80!==Number(this.port))&&(r=":"+this.port),e.length&&(e="?"+e),t+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+r+this.path+e}},function(e,t,r){(function(t){var n=r(1093),i=Object.prototype.toString,o="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===i.call(Blob),s="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===i.call(File);e.exports=function e(r){if(!r||"object"!=typeof r)return!1;if(n(r)){for(var i=0,a=r.length;i0);return t}function f(){var e=c(+new Date);return e!==n?(a=0,n=e):e+"."+c(a++)}for(;u{n(i.subtle.sign({name:"HMAC"},t,r).then(t=>e.from(t)),o)};t.create=function(e,t,r){const u=s[e];n(i.subtle.importKey("raw",t,{name:"HMAC",hash:{name:u}},!1,["sign"]).then(t=>({digest(e,r){a(t,e,r)},length:o[e]})),r)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(12),i=r(1112);function o(e,t,r,i){if("function"==typeof r&&(i=r,r=void 0),!i)throw new Error("Missing callback");o.digest(e,t,r,(e,o)=>{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){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(285),i=r(286)();function o(e){return Promise.all([i.subtle.exportKey("jwk",e.privateKey),i.subtle.exportKey("jwk",e.publicKey)])}t.utils=r(1115),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(o).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"]);n(Promise.all([r,function(e){return i.subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}(e)]).then(e=>o({privateKey:e[0],publicKey:e[1]})).then(e=>({privateKey:e[0],publicKey:e[1]})),t)},t.getRandomValues=function(t){return e.from(i.getRandomValues(t))},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)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(15).bignum;t.toBase64=function(t,r){return t.toArrayLike(e,"be",r).toString("base64").replace(/(=*)$/,"").replace(/\+/g,"-").replace(/\//g,"_")},t.toBn=function(t){return new n(e.from(t,"base64"))}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(525);e.exports=function(e){if(!e||"number"!=typeof e)throw new Error("first argument must be a Number bigger than 0");return n.getRandomValues(new Uint8Array(e))}},function(e,t){e.exports=function(e){!function t(){var r=!0,n=!1;do{n=!0,r=!1,e.call(this,function(){n?r=!0:t()}),n=!1}while(r)}()}},function(e,t,r){"use strict";(function(n){const i=r(12),o=r(1126),s=r(16),a=r(5);class u{constructor(e,t,r){s(n.isBuffer(e),"invalid id provided"),t&&r&&s(t.public.bytes.equals(r.bytes),"inconsistent arguments"),this._id=e,this._idB58String=i.toB58String(this.id),this._privKey=t,this._pubKey=r}get id(){return this._id}set id(e){throw new Error("Id is immutable")}get privKey(){return this._privKey}set privKey(e){this._privKey=e}get pubKey(){return this._pubKey?this._pubKey:this._privKey?this._privKey.public:void 0}set pubKey(e){this._pubKey=e}marshalPubKey(){if(this.pubKey)return o.keys.marshalPublicKey(this.pubKey)}marshalPrivKey(){if(this.privKey)return o.keys.marshalPrivateKey(this.privKey)}toPrint(){return this.toJSON()}toJSON(){return{id:this.toB58String(),privKey:c(this.marshalPrivKey()),pubKey:c(this.marshalPubKey())}}toHexString(){return i.toHexString(this.id)}toBytes(){return this.id}toB58String(){return this._idB58String}isEqual(e){if(n.isBuffer(e))return this.id.equals(e);if(e.id)return this.id.equals(e.id);throw new Error("not valid Id")}isValid(e){this.privKey&&this.privKey.public&&this.privKey.public.bytes&&n.isBuffer(this.pubKey.bytes)&&this.privKey.public.bytes.equals(this.pubKey.bytes)?e():e(new Error("Keys not match"))}}function c(e){if(e)return e.toString("base64")}(t=e.exports=u).create=function(e,t){"function"==typeof e&&(t=e,e={}),(e=e||{}).bits=e.bits||2048,a([t=>o.keys.generateKeyPair("RSA",e.bits,t),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n))})},t.createFromHexString=function(e){return new u(i.fromHexString(e))},t.createFromBytes=function(e){return new u(e)},t.createFromB58String=function(e){return new u(i.fromB58String(e))},t.createFromPubKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r;try{let i=e;if("string"==typeof i&&(i=n.from(e,"base64")),!n.isBuffer(i))throw new Error("Supplied key is neither a base64 string nor a buffer");r=o.keys.unmarshalPublicKey(i)}catch(e){return t(e)}r.hash((e,n)=>{if(e)return t(e);t(null,new u(n,null,r))})},t.createFromPrivKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r=e;try{if("string"==typeof r&&(r=n.from(e,"base64")),!n.isBuffer(r))throw new Error("Supplied key is neither a base64 string nor a buffer")}catch(e){return t(e)}a([e=>o.keys.unmarshalPrivateKey(r,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n,n.public))})},t.createFromJSON=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r,s,c,f;try{r=i.fromB58String(e.id),s=e.privKey&&n.from(e.privKey,"base64"),c=e.pubKey&&n.from(e.pubKey,"base64"),f=c&&o.keys.unmarshalPublicKey(c)}catch(e){return t(e)}s?a([e=>o.keys.unmarshalPrivateKey(s,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)}),(e,t,r)=>{f?f.hash((n,i)=>{r(n,e,t,i)}):r(null,e,t)}],(e,n,i,o)=>e?t(e):f&&!n.equals(o)?t(new Error("Public and private key do not match")):r&&!n.equals(r)?t(new Error("Id and private key do not match")):void t(null,new u(r,i,f))):t(null,new u(r,null,f))},t.isPeerId=function(e){return Boolean("object"==typeof e&&e._id&&e._idB58String)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(288),i=r(289)(),o=r(1127),s={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"},a=(t,r,o)=>{n(i.subtle.sign({name:"HMAC"},t,r).then(t=>e.from(t)),o)};t.create=function(e,t,r){const u=s[e];n(i.subtle.importKey("raw",t,{name:"HMAC",hash:{name:u}},!1,["sign"]).then(t=>({digest(e,r){a(t,e,r)},length:o[e]})),r)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(12),i=r(1132);function o(e,t,r,i){if("function"==typeof r&&(i=r,r=void 0),!i)throw new Error("Missing callback");o.digest(e,t,r,(e,o)=>{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){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(288),i=r(289)();function o(e){return Promise.all([i.subtle.exportKey("jwk",e.privateKey),i.subtle.exportKey("jwk",e.publicKey)])}t.utils=r(1135),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(o).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"]);n(Promise.all([r,function(e){return i.subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}(e)]).then(e=>o({privateKey:e[0],publicKey:e[1]})).then(e=>({privateKey:e[0],publicKey:e[1]})),t)},t.getRandomValues=function(t){return e.from(i.getRandomValues(t))},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)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(15).bignum;t.toBase64=function(t,r){return t.toArrayLike(e,"be",r).toString("base64").replace(/(=*)$/,"").replace(/\+/g,"-").replace(/\//g,"_")},t.toBn=function(t){return new n(e.from(t,"base64"))}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(533);e.exports=function(e){if(!e||"number"!=typeof e)throw new Error("first argument must be a Number bigger than 0");return n.getRandomValues(new Uint8Array(e))}},function(e,t,r){"use strict";(function(n){const i=r(52),o=r(529),s=r(111),a=r(78);const u={string:e=>"string"==typeof e,object:e=>"object"==typeof e,multiaddr:e=>{if(u.string(e))try{return i(e),!0}catch(e){return!1}},function:e=>"function"==typeof e};function c(e,t){if(!Array.isArray(t))throw new Error("Data is not an array");e.forEach((e,r)=>{if(!u[e])throw console.error("Type %s does not exist",e),new Error("Type "+e+" does not exist");if(!u[e](t[r]))throw new Error("Data at index "+r+" is invalid for type "+e)})}(t=e.exports).cleanUrlSIO=function(e){const t=e.protos(),r=t[0].name,n=t[1].name,i=t[2].name,o=e.stringTuples(),s=o[1][1];if("tcp"!==n||"ws"!==i&&"wss"!==i)throw new Error("invalid multiaddr: "+e.toString());let a=o[0][1];"ip6"===r&&(a="["+a+"]");let u="ws"===i&&80===s||"wss"===i&&443===s?"":s;return("wss"===i?"https":"http")+"://"+a+(u?":"+u:"")},t.validate=c,t.Protocol=function(e){e||(e=(()=>{}));const t=this;t.requests={},t.addRequest=((e,r,n)=>{t.requests[e]={def:r,handle:n}}),t.handleSocket=(r=>{r.r={},Object.keys(t.requests).forEach(n=>{const i=t.requests[n];r.on(n,function(){const t=[...arguments];try{c(i.def,t),t.unshift(r),i.handle.apply(null,t)}catch(i){e(i),e("peer %s has sent invalid data for request %s",r.id||"",n,t)}})})})},t.getIdAndValidate=function(e,t,r){o.createFromPubKey(n.from(e,"hex"),(i,o)=>i?r(new Error("Crypto error")):o.toB58String()!==t?r(new Error("Id is not matching")):r(null,s.keys.unmarshalPublicKey(n.from(e,"hex"))))},t.validateMa=(e=>a.WebSocketStar.matches(i(e)))}).call(this,r(0).Buffer)},function(e,t,r){var n=r(1145),i=r(221),o=i;o.v1=n,o.v4=i,e.exports=o},function(e,t,r){"use strict";e.exports="/mplex/6.7.0"},function(e,t,r){(function(t){var n=r(30),i=r(193),o=r(1153),s=function(){},a=/^v?\.0/.test(t.version),u=function(e){return"function"==typeof e},c=function(e){return!!a&&!!o&&(e instanceof(o.ReadStream||s)||e instanceof(o.WriteStream||s))&&u(e.close)},f=function(e,t,r,o){o=n(o);var a=!1;e.on("close",function(){a=!0}),i(e,{readable:t,writable:r},function(e){if(e)return o(e);a=!0,o()});var f=!1;return function(t){if(!a&&!f)return f=!0,c(e)?e.close(s):function(e){return e.setHeader&&u(e.abort)}(e)?e.abort():u(e.destroy)?e.destroy():void o(t||new Error("stream was destroyed"))}},l=function(e){e()},h=function(e,t){return e.pipe(t)};e.exports=function(){var e,t=Array.prototype.slice.call(arguments),r=u(t[t.length-1]||s)&&t.pop()||s;if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new Error("pump requires two streams per minimum");var n=t.map(function(i,o){var s=o0,function(t){e||(e=t),t&&n.forEach(l),s||(n.forEach(l),r(e))})});return t.reduce(h)}}).call(this,r(6))},function(e,t,r){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(294),i=r(295)(),o=r(1160),s={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"},a=(t,r,o)=>{n(i.subtle.sign({name:"HMAC"},t,r).then(t=>e.from(t)),o)};t.create=function(e,t,r){const u=s[e];n(i.subtle.importKey("raw",t,{name:"HMAC",hash:{name:u}},!1,["sign"]).then(t=>({digest(e,r){a(t,e,r)},length:o[e]})),r)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(294),i=r(295)();function o(e){return Promise.all([i.subtle.exportKey("jwk",e.privateKey),i.subtle.exportKey("jwk",e.publicKey)])}t.utils=r(1165),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(o).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"]);n(Promise.all([r,function(e){return i.subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}(e)]).then(e=>o({privateKey:e[0],publicKey:e[1]})).then(e=>({privateKey:e[0],publicKey:e[1]})),t)},t.getRandomValues=function(t){return e.from(i.getRandomValues(t))},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)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(15).bignum;t.toBase64=function(t,r){return t.toArrayLike(e,"be",r).toString("base64").replace(/(=*)$/,"").replace(/\+/g,"-").replace(/\//g,"_")},t.toBn=function(t){return new n(e.from(t,"base64"))}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(542);e.exports=function(e){if(!e||"number"!=typeof e)throw new Error("first argument must be a Number bigger than 0");return n.getRandomValues(new Uint8Array(e))}},function(e,t,r){"use strict";(function(e){const n=r(298),i=r(299)(),o=r(1181),s={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"},a=(t,r,o)=>{n(i.subtle.sign({name:"HMAC"},t,r).then(t=>e.from(t)),o)};t.create=function(e,t,r){const u=s[e];n(i.subtle.importKey("raw",t,{name:"HMAC",hash:{name:u}},!1,["sign"]).then(t=>({digest(e,r){a(t,e,r)},length:o[e]})),r)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(12),i=r(1186);function o(e,t,r,i){if("function"==typeof r&&(i=r,r=void 0),!i)throw new Error("Missing callback");o.digest(e,t,r,(e,o)=>{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){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(298),i=r(299)();function o(e){return Promise.all([i.subtle.exportKey("jwk",e.privateKey),i.subtle.exportKey("jwk",e.publicKey)])}t.utils=r(1189),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(o).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"]);n(Promise.all([r,function(e){return i.subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}(e)]).then(e=>o({privateKey:e[0],publicKey:e[1]})).then(e=>({privateKey:e[0],publicKey:e[1]})),t)},t.getRandomValues=function(t){return e.from(i.getRandomValues(t))},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)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(15).bignum;t.toBase64=function(t,r){return t.toArrayLike(e,"be",r).toString("base64").replace(/(=*)$/,"").replace(/\+/g,"-").replace(/\//g,"_")},t.toBn=function(t){return new n(e.from(t,"base64"))}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(548);e.exports=function(e){if(!e||"number"!=typeof e)throw new Error("first argument must be a Number bigger than 0");return n.getRandomValues(new Uint8Array(e))}},function(e,t,r){"use strict";(function(e){const n=r(302),i=r(303)(),o=r(1208),s={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"},a=(t,r,o)=>{n(i.subtle.sign({name:"HMAC"},t,r).then(t=>e.from(t)),o)};t.create=function(e,t,r){const u=s[e];n(i.subtle.importKey("raw",t,{name:"HMAC",hash:{name:u}},!1,["sign"]).then(t=>({digest(e,r){a(t,e,r)},length:o[e]})),r)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(12),i=r(1213);function o(e,t,r,i){if("function"==typeof r&&(i=r,r=void 0),!i)throw new Error("Missing callback");o.digest(e,t,r,(e,o)=>{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){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(302),i=r(303)();function o(e){return Promise.all([i.subtle.exportKey("jwk",e.privateKey),i.subtle.exportKey("jwk",e.publicKey)])}t.utils=r(1216),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(o).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"]);n(Promise.all([r,function(e){return i.subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}(e)]).then(e=>o({privateKey:e[0],publicKey:e[1]})).then(e=>({privateKey:e[0],publicKey:e[1]})),t)},t.getRandomValues=function(t){return e.from(i.getRandomValues(t))},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)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(15).bignum;t.toBase64=function(t,r){return t.toArrayLike(e,"be",r).toString("base64").replace(/(=*)$/,"").replace(/\+/g,"-").replace(/\//g,"_")},t.toBn=function(t){return new n(e.from(t,"base64"))}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(554);e.exports=function(e){if(!e||"number"!=typeof e)throw new Error("first argument must be a Number bigger than 0");return n.getRandomValues(new Uint8Array(e))}},function(e,t,r){(function(t){var r="[object AsyncFunction]",n="[object Function]",i="[object GeneratorFunction]",o="[object Null]",s="[object Proxy]",a="[object Undefined]",u="object"==typeof t&&t&&t.Object===Object&&t,c="object"==typeof self&&self&&self.Object===Object&&self,f=u||c||Function("return this")(),l=Object.prototype,h=l.hasOwnProperty,p=l.toString,d=f.Symbol,y=d?d.toStringTag:void 0;function g(e){return null==e?void 0===e?a:o:y&&y in Object(e)?function(e){var t=h.call(e,y),r=e[y];try{e[y]=void 0;var n=!0}catch(e){}var i=p.call(e);return n&&(t?e[y]=r:delete e[y]),i}(e):function(e){return p.call(e)}(e)}e.exports=function(e){if(!function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}(e))return!1;var t=g(e);return t==n||t==i||t==r||t==s}}).call(this,r(7))},function(e,t,r){"use strict";(function(t){const n=r(101),i=r(53),o=r(195).writeEncoded;e.exports=function(e,r,s){const a=n({timeout:6e4},r),u=a.handshake;return s("writing multicodec: "+e),o(u,t.from(e+"\n"),r),i.decodeFromReader(u,(t,n)=>{if(t)return r(t);const i=n.toString().slice(0,-1);if(i!==e)return r(new Error(`"${e}" not supported`),u.rest());s("received ack: "+i),r(null,u.rest())}),a}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){return function(r,o,s,a){a=a||n.default;var u,c=!1;r(o,function(r,n,o){s(r,function(n,s){n?o(n):e(s)&&!u?(c=!0,u=t(!0,r),o(null,i.default)):o()})},function(e){e?a(e):a(null,c?u:t(!1))})}};var n=o(r(54)),i=o(r(217));function o(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default},function(e,t,r){"use strict";e.exports=function(e,t,r){r(null,e===t)}},function(e,t,r){"use strict";e.exports.PROTOCOL_ID="/multistream/1.0.0"},function(e,t,r){"use strict";e.exports=r(1230)},function(e,t,r){"use strict";(function(e){const n=r(308),i=r(309)(),o=r(1235),s={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"},a=(t,r,o)=>{n(i.subtle.sign({name:"HMAC"},t,r).then(t=>e.from(t)),o)};t.create=function(e,t,r){const u=s[e];n(i.subtle.importKey("raw",t,{name:"HMAC",hash:{name:u}},!1,["sign"]).then(t=>({digest(e,r){a(t,e,r)},length:o[e]})),r)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(12),i=r(1240);function o(e,t,r,i){if("function"==typeof r&&(i=r,r=void 0),!i)throw new Error("Missing callback");o.digest(e,t,r,(e,o)=>{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){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(308),i=r(309)();function o(e){return Promise.all([i.subtle.exportKey("jwk",e.privateKey),i.subtle.exportKey("jwk",e.publicKey)])}t.utils=r(1243),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(o).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"]);n(Promise.all([r,function(e){return i.subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}(e)]).then(e=>o({privateKey:e[0],publicKey:e[1]})).then(e=>({privateKey:e[0],publicKey:e[1]})),t)},t.getRandomValues=function(t){return e.from(i.getRandomValues(t))},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)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(15).bignum;t.toBase64=function(t,r){return t.toArrayLike(e,"be",r).toString("base64").replace(/(=*)$/,"").replace(/\+/g,"-").replace(/\//g,"_")},t.toBn=function(t){return new n(e.from(t,"base64"))}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(566);e.exports=function(e){if(!e||"number"!=typeof e)throw new Error("first argument must be a Number bigger than 0");return n.getRandomValues(new Uint8Array(e))}},function(e,t,r){(function(e,t){!function(e,r){"use strict";if(!e.setImmediate){var n,i=1,o={},s=!1,a=e.document,u=Object.getPrototypeOf&&Object.getPrototypeOf(e);u=u&&u.setTimeout?u:e,"[object process]"==={}.toString.call(e.process)?n=function(e){t.nextTick(function(){f(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}}()?function(){var t="setImmediate$"+Math.random()+"$",r=function(r){r.source===e&&"string"==typeof r.data&&0===r.data.indexOf(t)&&f(+r.data.slice(t.length))};e.addEventListener?e.addEventListener("message",r,!1):e.attachEvent("onmessage",r),n=function(r){e.postMessage(t+r,"*")}}():e.MessageChannel?function(){var e=new MessageChannel;e.port1.onmessage=function(e){f(e.data)},n=function(t){e.port2.postMessage(t)}}():a&&"onreadystatechange"in a.createElement("script")?function(){var e=a.documentElement;n=function(t){var r=a.createElement("script");r.onreadystatechange=function(){f(t),r.onreadystatechange=null,e.removeChild(r),r=null},e.appendChild(r)}}():n=function(e){setTimeout(f,0,e)},u.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r("function"==typeof r&&(i=r,r=void 0),n(()=>i()),t)}},function(e,t,r){"use strict";const n=r(1273),i=r(51),o=r(52);e.exports=function(e,t){let r;if(i.isPeerInfo(e))return e;if(o.isMultiaddr(e)){const o=e.getPeerId();try{r=t.get(o)}catch(e){r=new i(n.createFromB58String(o))}return r.multiaddrs.add(e),r}if(n.isPeerId(e)){const r=e.toB58String();try{return t.get(r)}catch(e){throw new Error("Couldnt get PeerInfo")}}throw new Error("peer type not recognized")}},function(e,t,r){"use strict";(function(e){const n=r(315),i=r(316)(),o=r(1275),s={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"},a=(t,r,o)=>{n(i.subtle.sign({name:"HMAC"},t,r).then(t=>e.from(t)),o)};t.create=function(e,t,r){const u=s[e];n(i.subtle.importKey("raw",t,{name:"HMAC",hash:{name:u}},!1,["sign"]).then(t=>({digest(e,r){a(t,e,r)},length:o[e]})),r)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(12),i=r(1280);function o(e,t,r,i){if("function"==typeof r&&(i=r,r=void 0),!i)throw new Error("Missing callback");o.digest(e,t,r,(e,o)=>{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){"use strict";(function(e){const n=r(3);t.toCallback=(e=>(function(t,r){const i=(e,t)=>n(()=>{r(e,t)});let o;try{o=e(t)}catch(e){return void i(e)}i(null,o)})),t.toBuf=((t,r)=>n=>{let i=t(n,r);return e.from(i,"hex")}),t.fromString=((t,r)=>n=>{const i=e.isBuffer(n)?n.toString():n;return t(i,r)}),t.fromNumberTo32BitBuf=((t,r)=>n=>{let i=t(n,r);const o=new Array(4);for(let e=0;e<4;e++)o[e]=255&i,i>>=8;return e.from(o)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(315),i=r(316)();function o(e){return Promise.all([i.subtle.exportKey("jwk",e.privateKey),i.subtle.exportKey("jwk",e.publicKey)])}t.utils=r(1283),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(o).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"]);n(Promise.all([r,function(e){return i.subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}(e)]).then(e=>o({privateKey:e[0],publicKey:e[1]})).then(e=>({privateKey:e[0],publicKey:e[1]})),t)},t.getRandomValues=function(t){return e.from(i.getRandomValues(t))},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)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){const n=r(15).bignum;t.toBase64=function(t,r){return t.toArrayLike(e,"be",r).toString("base64").replace(/(=*)$/,"").replace(/\+/g,"-").replace(/\//g,"_")},t.toBn=function(t){return new n(e.from(t,"base64"))}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(578);e.exports=function(e){if(!e||"number"!=typeof e)throw new Error("first argument must be a Number bigger than 0");return n.getRandomValues(new Uint8Array(e))}},function(e,t,r){"use strict";const n=r(47).Connection,i=r(8);e.exports=((e,t,r,o)=>{const s=new Promise((e,t)=>{r.getPeerInfo((t,n)=>{if(!t&&n)return void e(n);const i=r.setPeerInfo;r.setPeerInfo=(t=>{i.call(r,t),e(t)})})}),a={source:i(r,o.incoming(e,t,s)),sink:i(o.outgoing(e,t,s),r)};return new n(a,r)})},function(e,t,r){var n=r(1305);e.exports=function(e,t,r){var i=null==e?void 0:n(e,t);return void 0===i?r:i}},function(e,t,r){(function(n){function i(){var e;try{e=t.storage.debug}catch(e){}return!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG),e}(t=e.exports=r(1335)).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var r=this.useColors;if(e[0]=(r?"%c":"")+this.namespace+(r?" %c":" ")+e[0]+(r?"%c ":" ")+"+"+t.humanize(this.diff),r){var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var i=0,o=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&"%c"===e&&(o=++i)}),e.splice(o,0,n)}},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=i,t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(i())}).call(this,r(6))},function(e,t,r){"use strict";const n=r(11),i=n(r(1345)),o=n(r(1346));(t=e.exports).rpc=i,t.td=o},function(e,t,r){"use strict";var n=r(1351);e.exports=function(){var e={};return n.toArray(arguments).reverse().forEach(function(t){n.mergeWith(e,t,function(e,t){return n.isArray(t)?t:void 0})}),e}},function(e,t){e.exports=function(e){var t,r,n;function i(e){return r=e,function(e,i){n?t=[e,i]:r(e,i)}}return i.pause=function(){n||(n=!0,e&&e(n))},i.resume=function(){if(n&&(n=!1,e&&e(n),t)){var i=t;t=null,r(i[0],i[1])}},i}},function(e,t,r){"use strict";var n=e.exports=function(e){return null!==e&&"object"==typeof e&&"function"==typeof e.pipe};n.writable=function(e){return n(e)&&!1!==e.writable&&"function"==typeof e._write&&"object"==typeof e._writableState},n.readable=function(e){return n(e)&&!1!==e.readable&&"function"==typeof e._read&&"object"==typeof e._readableState},n.duplex=function(e){return n.writable(e)&&n.readable(e)},n.transform=function(e){return n.duplex(e)&&"function"==typeof e._transform&&"object"==typeof e._transformState}},function(e,t){function r(e){return"function"==typeof e}function n(e){return r(e)&&2===e.length}function i(e){return r(e)&&1===e.length}t.isDuplex=function(e){return"object"==typeof e&&n(e.source)&&i(e.sink)},t.isSource=n,t.isSink=i},function(e,t,r){"use strict";const n=r(200).OFFLINE_ERROR,i=r(23),o=r(3),s=r(122),a=r(9),u=r(98);function c(e){return Array.from(e).map(e=>({"/":e[1].cid.toBaseEncodedString()}))}e.exports=function(e){return{wantlist:i((t,r)=>{if(r||(r=t,t=void 0),!e.isOnline())return o(()=>r(new Error(n)));let i;if(t){try{t=u.createFromB58String(t)}catch(e){t=null}if(!t)return o(()=>r(new Error("Invalid peerId")));i=e._bitswap.wantlistForPeer(t)}else i=e._bitswap.getWantlist();return i=c(i),o(()=>r(null,{Keys:i}))}),stat:i(t=>{if(!e.isOnline())return o(()=>t(new Error(n)));const r=e._bitswap.stat().snapshot;t(null,{provideBufLen:parseInt(r.providesBufferLength.toString()),blocksReceived:new s(r.blocksReceived),wantlist:c(e._bitswap.getWantlist()),peers:e._bitswap.peers().map(e=>e.toB58String()),dupBlksReceived:new s(r.dupBlksReceived),dupDataReceived:new s(r.dupDataReceived),dataReceived:new s(r.dataReceived),blocksSent:new s(r.blocksSent),dataSent:new s(r.dataSent)})}),unwant:i((t,r)=>e.isOnline()?(Array.isArray(t)||(t=[t]),t=t.map(e=>a.isCID(e)?e:new a(e)),o(()=>r(null,e._bitswap.unwant(t)))):o(()=>r(new Error(n))))}}},function(e,t,r){"use strict";e.exports=r(1411)},function(e,t){e.exports={WORKER_REQUEST_READ_LOCK:"lock:worker:request-read",WORKER_RELEASE_READ_LOCK:"lock:worker:release-read",MASTER_GRANT_READ_LOCK:"lock:master:grant-read",WORKER_REQUEST_WRITE_LOCK:"lock:worker:request-write",WORKER_RELEASE_WRITE_LOCK:"lock:worker:release-write",MASTER_GRANT_WRITE_LOCK:"lock:master:grant-write"}},function(e,t){const r={},n=e=>{e.addEventListener("message",t=>{n.dispatchEvent("message",e,t)}),e.port&&e.port.addEventListener("message",t=>{n.dispatchEvent("message",e,t)})};n.addEventListener=((e,t)=>{r[e]||(r[e]=[]),r[e].push(t)}),n.removeEventListener=((e,t)=>{r[e]&&(r[e]=r[e].filter(e=>e===t))}),n.dispatchEvent=function(){const e=Array.prototype.slice.call(arguments),t=e.shift();r[t]&&r[t].forEach(t=>t.apply(null,e))},e.exports=n},function(e,t,r){"use strict";const n=r(5),{DAGNode:i}=r(41),o={format:"dag-pb",hashAlg:"sha2-256"};e.exports=((e,t,r,s,a)=>{s=Object.assign({},o,s),n([e=>i.create(t,r,e),(t,r)=>{e.dag.put(t,{format:s.format,hashAlg:s.hashAlg},e=>r(e,t))}],a)})},function(e,t,r){"use strict";e.exports=(e=>{return e(!0)})},function(e,t,r){"use strict";const n=r(60);e.exports=function(e,t){const r=(e=e.slice()).filter(e=>"function"==typeof e).pop(),i=Object.assign({},t,e.filter(e=>"object"==typeof e).pop()||{});return Array.isArray(e[0])&&(e=e[0]),{sources:e.filter(e=>"string"==typeof e).map(e=>({path:e=e.trim(),name:n.basename(e),dir:n.dirname(e)})),options:i,callback:r}}},function(e,t,r){"use strict";const n=r(9),i=r(1)("ipfs:mfs:utils:with-mfs-root"),o=r(5),{MFS_ROOT_KEY:s}=r(146);e.exports=((e,t)=>{const r=e._repo,a=r&&r.datastore;if(!r||!a)return t(new Error("Please run jsipfs init first"));o([e=>a.open(t=>e(t)),t=>{a.get(s,(u,c)=>{if(u&&u.notFound)return i("Creating new MFS root"),o([t=>e.files.add({path:"/"},t),([{hash:e}],t)=>t(null,new n(e)),(e,t)=>r.closed?a.open(r=>t(r,e)):t(null,e),(e,t)=>a.put(s,e.buffer,r=>t(r,e))],t);t(u,new n(c))})},(e,t)=>{i(`Fetched MFS root ${e.toBaseEncodedString()}`),t(null,e)}],t)})},function(e,t,r){"use strict";const{FILE_SEPARATOR:n}=r(146);e.exports=((e,t)=>{if(!(e=(e||"").trim()))return t(new Error("paths must not be empty"));if(e.substring(0,1)!==n)return t(new Error(`paths must start with a leading ${n}`));e.substring(e.length-n.length)===n&&(e=e.substring(0,e.length-n.length));const r=e.split(n).filter(Boolean),i=r.pop(),o=`${n}${r.join(n)}`;if("/ipfs"===e.substring(0,"/ipfs".length))return t(null,{type:"ifps",path:e.substring("/ipfs".length+1),directory:o,name:i});t(null,{type:"mfs",path:e||n,directory:o,name:i})})},function(e,t,r){"use strict";const n=r(36).unmarshal,{traverseTo:i,formatCid:o}=r(48),s=r(5),a=r(1)("ipfs:mfs:stat"),u={hash:!1,size:!1,withLocal:!1,cidBase:"base58btc"};e.exports=(e=>(function(t,r,c){"function"==typeof r&&(c=r,r={}),r=Object.assign({},u,r),a(`Fetching stats for ${t}`),s([r=>i(e,t,{withCreateHint:!1},r),({node:e},t)=>{if(r.hash)return t(null,{hash:o(e.multihash,r.cidBase)});if(r.size)return t(null,{size:e.size});const i=n(e.data);let s=e.links.length;"file"===i.type&&(s=i.blockSizes.length),t(null,{hash:o(e.multihash,r.cidBase),size:i.fileSize()||0,cumulativeSize:e.size,blocks:s,type:i.type,local:void 0,sizeLocal:void 0,withLocality:!1})}],c)}))},function(e,t,r){"use strict";const n=r(5),i=r(59),o=r(49),s=r(36),{traverseTo:a,addLink:u,updateTree:c,updateMfsRoot:f,toSourcesAndDestination:l}=r(48),h=r(598),p=r(1)("ipfs:mfs:cp"),d={parents:!1,flush:!0,format:"dag-pb",hashAlg:"sha2-256"};e.exports=(e=>(function(){const t=Array.from(arguments),{sources:r,destination:n,options:i,callback:o}=l(t,d);return r.length?n?(i.parents=i.p||i.parents,void a(e,n.path,{},(t,a)=>{if(t)return 1===r.length?(p("Only one source, copying to a file"),y(e,r.pop(),n,i,o)):(p("Multiple sources, copying to a directory"),g(e,r,n,i,o));if("directory"===s.unmarshal(a.node.data).type)return g(e,r,n,i,o);o(new Error("directory already has entry by that name"))})):o(new Error("Please supply a destination")):o(new Error("Please supply at least one source"))}));const y=(e,t,r,o,s)=>{n([n=>{i([r=>h(e)(t.path,o,r),t=>h(e)(r.path,o,e=>{if(!e)return t(new Error("directory already has entry by that name"));t()}),t=>a(e,r.dir,o,t)],n)},([t,i,o],s)=>{n([n=>u(e,{parent:o.node,child:{size:t.cumulativeSize,hash:t.hash},name:r.name},n),(t,r)=>{o.node=t,c(e,o,r)},(t,r)=>f(e,t.node.multihash,r)],s)}],e=>s(e))},g=(e,t,r,s,l)=>{n([n=>{o([r=>i(t.map(t=>r=>h(e)(t.path,s,r)),r),t=>a(e,r.path,Object.assign({},s,{createLastComponent:!0}),t)],n)},(o,a)=>{const l=o.pop(),p=o[0];n([n=>{i(t.map(t=>n=>{h(e)(`${r.path}/${t.name}`,s,e=>{if(!e)return n(new Error("directory already has entry by that name"));n()})}),e=>n(e))},r=>{n([e=>e(null,l.node)].concat(p.map((r,n)=>(i,o)=>u(e,{parent:i,child:{size:r.cumulativeSize,hash:r.hash},name:t[n].name},o))),r)},(t,r)=>{l.node=t,c(e,l,r)},(t,r)=>f(e,t.node.multihash,r)],a)}],e=>l(e))}},function(e,t,r){"use strict";const n=r(36),i=r(5),o=r(49),{DAGNode:s}=r(41),a=r(9),{traverseTo:u,updateTree:c,updateMfsRoot:f,toSources:l,FILE_SEPARATOR:h}=r(48),p={recursive:!1};e.exports=(e=>(function(){const t=Array.from(arguments),{sources:r,options:n,callback:i}=l(t,p);if(!r.length)return i(new Error("Please supply at least one path to remove"));o(r.map(t=>r=>d(e,t.path,n,r)),e=>i(e))}));const d=(e,t,r,o)=>{if(t===h)return o(new Error("Cannot delete root"));i([r=>u(e,t,{withCreateHint:!1},r),(o,u)=>{if("directory"===n.unmarshal(o.node.data).type&&!r.recursive)return u(new Error(`${t} is a directory, use -r to remove directories`));i([e=>s.rmLink(o.parent.node,o.name,e),(t,r)=>{e.dag.put(t,{cid:new a(t.hash||t.multihash)},e=>r(e,t))},(t,r)=>{o.parent.node=t,c(e,o.parent,r)},(t,r)=>f(e,t.node.multihash,r)],u)}],o)}},function(e,t,r){"use strict";const n=r(5),i=r(70),o=r(86),s=r(87),a=r(145).importer,{loadNode:u}=r(48);e.exports=((e,t,r,c)=>{n([n=>i(o([{content:i(t)}]),a(e.dag,{progress:r.progress,hashAlg:r.hashAlg,cidVersion:r.cidVersion,strategy:r.strategy,rawLeaves:r.rawLeaves,reduceSingleLeafToSelf:r.reduceSingleLeafToSelf,leafType:r.leafType}),s(n)),(t,r)=>u(e,t[0],r)],c)})},function(e,t,r){(function(t){var n=r(1444).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){(function(e,r){var n=200,i="__lodash_hash_undefined__",o=9007199254740991,s="[object Arguments]",a="[object Boolean]",u="[object Date]",c="[object Function]",f="[object GeneratorFunction]",l="[object Map]",h="[object Number]",p="[object Object]",d="[object Promise]",y="[object RegExp]",g="[object Set]",m="[object String]",b="[object Symbol]",v="[object WeakMap]",_="[object ArrayBuffer]",w="[object DataView]",S="[object Float32Array]",k="[object Float64Array]",E="[object Int8Array]",A="[object Int16Array]",x="[object Int32Array]",I="[object Uint8Array]",T="[object Uint8ClampedArray]",B="[object Uint16Array]",C="[object Uint32Array]",P=/\w*$/,O=/^\[object .+?Constructor\]$/,R=/^(?:0|[1-9]\d*)$/,N={};N[s]=N["[object Array]"]=N[_]=N[w]=N[a]=N[u]=N[S]=N[k]=N[E]=N[A]=N[x]=N[l]=N[h]=N[p]=N[y]=N[g]=N[m]=N[b]=N[I]=N[T]=N[B]=N[C]=!0,N["[object Error]"]=N[c]=N[v]=!1;var L="object"==typeof e&&e&&e.Object===Object&&e,j="object"==typeof self&&self&&self.Object===Object&&self,M=L||j||Function("return this")(),K="object"==typeof t&&t&&!t.nodeType&&t,D=K&&"object"==typeof r&&r&&!r.nodeType&&r,U=D&&D.exports===K;function F(e,t){return e.set(t[0],t[1]),e}function q(e,t){return e.add(t),e}function H(e,t,r,n){var i=-1,o=e?e.length:0;for(n&&o&&(r=e[++i]);++i-1},Te.prototype.set=function(e,t){var r=this.__data__,n=Re(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Be.prototype.clear=function(){this.__data__={hash:new Ie,map:new(ye||Te),string:new Ie}},Be.prototype.delete=function(e){return Ke(this,e).delete(e)},Be.prototype.get=function(e){return Ke(this,e).get(e)},Be.prototype.has=function(e){return Ke(this,e).has(e)},Be.prototype.set=function(e,t){return Ke(this,e).set(e,t),this},Ce.prototype.clear=function(){this.__data__=new Te},Ce.prototype.delete=function(e){return this.__data__.delete(e)},Ce.prototype.get=function(e){return this.__data__.get(e)},Ce.prototype.has=function(e){return this.__data__.has(e)},Ce.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Te){var i=r.__data__;if(!ye||i.length-1&&e%1==0&&e-1&&e%1==0&&e<=o}(e.length)&&!Je(e)}var Ye=he||function(){return!1};function Je(e){var t=Xe(e)?re.call(e):"";return t==c||t==f}function Xe(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Ze(e){return $e(e)?Pe(e):function(e){if(!ze(e))return pe(e);var t=[];for(var r in Object(e))te.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}r.exports=function(e){return Ne(e,!0,!0)}}).call(this,r(7),r(27)(e))},function(e,t,r){"use strict";e.exports="ipfs-pubsub-room/v2"},function(e,t,r){"use strict";(function(t){e.exports=(e=>{let r=e;return t.isBuffer(r)||(r=t.from(r)),r})}).call(this,r(0).Buffer)},function(e,t,r){(function(t){var n=r(4),i=r(22).Transform,o=r(1488);function s(e,t){if(!(this instanceof s))return new s(e,t);i.call(this),t||(t={}),"object"==typeof e&&(e=(t=e).size),this.size=e||512,t.nopad?this._zeroPadding=!1:this._zeroPadding=o(t.zeroPadding,!0),this._buffered=[],this._bufferedBytes=0}e.exports=s,n(s,i),s.prototype._transform=function(e,r,n){for(this._bufferedBytes+=e.length,this._buffered.push(e);this._bufferedBytes>=this.size;){var i=t.concat(this._buffered);this._bufferedBytes-=this.size,this.push(i.slice(0,this.size)),this._buffered=[i.slice(this.size,i.length)]}n()},s.prototype._flush=function(){if(this._bufferedBytes&&this._zeroPadding){var e=new t(this.size-this._bufferedBytes);e.fill(0),this._buffered.push(e),this.push(t.concat(this._buffered)),this._buffered=null}else this._bufferedBytes&&(this.push(t.concat(this._buffered)),this._buffered=null);this.push(null)}}).call(this,r(0).Buffer)},function(e,t,r){e.exports=o;var n=r(4),i=r(22);function o(e,t){var r=this;if(!(r instanceof o))return new o(e,t);i.Readable.call(r,t),r.destroyed=!1,r._drained=!1,r._forwarding=!1,r._current=null,r._toStreams2=t&&t.objectMode?s:a,"function"==typeof e?r._queue=e:(r._queue=e.map(r._toStreams2),r._queue.forEach(function(e){"function"!=typeof e&&r._attachErrorListener(e)})),r._next()}function s(e){return u(e,{objectMode:!0,highWaterMark:16})}function a(e){return u(e)}function u(e,t){if(!e||"function"==typeof e||e._readableState)return e;var r=new i.Readable(t).wrap(e);return e.destroy&&(r.destroy=e.destroy.bind(e)),r}n(o,i.Readable),o.obj=function(e){return new o(e,{objectMode:!0,highWaterMark:16})},o.prototype._read=function(){this._drained=!0,this._forward()},o.prototype._forward=function(){if(!this._forwarding&&this._drained&&this._current){var e;for(this._forwarding=!0;null!==(e=this._current.read());)this._drained=this.push(e);this._forwarding=!1}},o.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,this._current&&this._current.destroy&&this._current.destroy(),"function"!=typeof this._queue&&this._queue.forEach(function(e){e.destroy&&e.destroy()}),e&&this.emit("error",e),this.emit("close"))},o.prototype._next=function(){var e=this;if(e._current=null,"function"==typeof e._queue)e._queue(function(t,r){if(t)return e.destroy(t);r=e._toStreams2(r),e._attachErrorListener(r),e._gotNextStream(r)});else{var t=e._queue.shift();"function"==typeof t&&(t=e._toStreams2(t()),e._attachErrorListener(t)),e._gotNextStream(t)}},o.prototype._gotNextStream=function(e){var t=this;if(!e)return t.push(null),void t.destroy();function r(){t._forward()}function n(){e._readableState.ended||t.destroy()}t._current=e,t._forward(),e.on("readable",r),e.once("end",function i(){t._current=null,e.removeListener("readable",r),e.removeListener("end",i),e.removeListener("close",n),t._next()}),e.once("close",n)},o.prototype._attachErrorListener=function(e){var t=this;e&&e.once("error",function r(n){e.removeListener("error",r),t.destroy(n)})}},function(e,t,r){(function(t,n){var i=r(204),o=r(1498),s=r(95),a=r(1499),u=r(1503),c=r(60),f=r(148),l=r(205);function h(e){if("string"==typeof e&&/^(stream-)?magnet:/.test(e))return u(e);if("string"==typeof e&&(/^[a-f0-9]{40}$/i.test(e)||/^[a-z2-7]{32}$/i.test(e)))return u("magnet:?xt=urn:btih:"+e);if(t.isBuffer(e)&&20===e.length)return u("magnet:?xt=urn:btih:"+e.toString("hex"));if(t.isBuffer(e))return function(e){t.isBuffer(e)&&(e=i.decode(e)),d(e.info,"info"),d(e.info["name.utf-8"]||e.info.name,"info.name"),d(e.info["piece length"],"info['piece length']"),d(e.info.pieces,"info.pieces"),e.info.files?e.info.files.forEach(function(e){d("number"==typeof e.length,"info.files[0].length"),d(e["path.utf-8"]||e.path,"info.files[0].path")}):d("number"==typeof e.info.length,"info.length");var r={};r.info=e.info,r.infoBuffer=i.encode(e.info),r.infoHash=f.sync(r.infoBuffer),r.infoHashBuffer=t.from(r.infoHash,"hex"),r.name=(e.info["name.utf-8"]||e.info.name).toString(),void 0!==e.info.private&&(r.private=!!e.info.private),e["creation date"]&&(r.created=new Date(1e3*e["creation date"])),e["created by"]&&(r.createdBy=e["created by"].toString()),t.isBuffer(e.comment)&&(r.comment=e.comment.toString()),r.announce=[],Array.isArray(e["announce-list"])&&e["announce-list"].length>0?e["announce-list"].forEach(function(e){e.forEach(function(e){r.announce.push(e.toString())})}):e.announce&&r.announce.push(e.announce.toString()),t.isBuffer(e["url-list"])&&(e["url-list"]=e["url-list"].length>0?[e["url-list"]]:[]),r.urlList=(e["url-list"]||[]).map(function(e){return e.toString()}),l(r.announce),l(r.urlList);var n=e.info.files||[e.info];r.files=n.map(function(e,t){var i=[].concat(r.name,e["path.utf-8"]||e.path||[]).map(function(e){return e.toString()});return{path:c.join.apply(null,[c.sep].concat(i)).slice(1),name:i[i.length-1],length:e.length,offset:n.slice(0,t).reduce(p,0)}}),r.length=n.reduce(p,0);var o=r.files[r.files.length-1];return r.pieceLength=e.info["piece length"],r.lastPieceLength=(o.offset+o.length)%r.pieceLength||r.pieceLength,r.pieces=function(e){for(var t=[],r=0;re._pos){var o=r.substr(e._pos);if("x-user-defined"===e._charset){for(var s=new n(o.length),a=0;ae._pos&&(e.push(new n(new Uint8Array(c.result.slice(e._pos)))),e._pos=c.result.byteLength)},c.onload=function(){e.push(null)},c.readAsArrayBuffer(r)}e._xhr.readyState===u.DONE&&"ms-stream"!==e._mode&&e.push(null)}}).call(this,r(6),r(0).Buffer,r(7))},function(e,t,r){var n=r(0).Buffer;e.exports=function(e){if(e instanceof Uint8Array){if(0===e.byteOffset&&e.byteLength===e.buffer.byteLength)return e.buffer;if("function"==typeof e.buffer.slice)return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(n.isBuffer(e)){for(var t=new Uint8Array(e.length),r=e.length,i=0;inull!==e&&"object"==typeof e&&"function"==typeof e.pipe;function l(e,r){if(e=Object.assign({maxRedirects:10},"string"==typeof e?{url:e}:e),r=a(r),e.url){const{hostname:t,port:r,protocol:n,auth:i,path:o}=c.parse(e.url);delete e.url,t||r||n||i?Object.assign(e,{hostname:t,port:r,protocol:n,auth:i,path:o}):e.path=o}const n={"accept-encoding":"gzip, deflate"};let h;e.headers&&Object.keys(e.headers).forEach(t=>n[t.toLowerCase()]=e.headers[t]),e.headers=n,e.body?h=e.json&&!f(e.body)?JSON.stringify(e.body):e.body:e.form&&(h="string"==typeof e.form?e.form:u.stringify(e.form),e.headers["content-type"]="application/x-www-form-urlencoded"),delete e.body,delete e.form,h&&(e.method||(e.method="POST"),f(h)||(e.headers["content-length"]=t.byteLength(h)),e.json&&(e.headers["content-type"]="application/json")),e.json&&(e.headers.accept="application/json"),e.method&&(e.method=e.method.toUpperCase());const p=("https:"===e.protocol?s:o).request(e,t=>{if(t.statusCode>=300&&t.statusCode<400&&t.headers.location)return e.url=t.headers.location,delete e.headers.host,t.resume(),"POST"===e.method&&[301,302].includes(t.statusCode)&&(e.method="GET",delete e.headers["content-length"],delete e.headers["content-type"]),0==e.maxRedirects--?r(new Error("too many redirects")):l(e,r);const n="function"==typeof i&&"HEAD"!==e.method;r(null,n?i(t):t)});return p.on("timeout",()=>{p.abort(),r(new Error("Request timed out"))}),p.on("error",r),f(h)?h.on("error",r).pipe(p):p.end(h),p}l.concat=((e,t)=>l(e,(r,i)=>{if(r)return t(r);n(i,(r,n)=>{if(r)return t(r);if(e.json)try{n=JSON.parse(n.toString())}catch(r){return t(r,i,n)}t(null,i,n)})})),["get","post","put","patch","head","delete"].forEach(e=>{l[e]=((t,r)=>("string"==typeof t&&(t={url:t}),l(Object.assign({method:e.toUpperCase()},t),r)))})}).call(this,r(0).Buffer)},function(e,t,r){e.exports=u;var n=r(4),i=r(22),o=r(611),s="undefined"!=typeof window&&window.MediaSource,a=60;function u(e,t){var r=this;if(!(r instanceof u))return new u(e,t);if(!s)throw new Error("web browser lacks MediaSource support");t||(t={}),r._debug=t.debug,r._bufferDuration=t.bufferDuration||a,r._elem=e,r._mediaSource=new s,r._streams=[],r.detailedError=null,r._errorHandler=function(){r._elem.removeEventListener("error",r._errorHandler),r._streams.slice().forEach(function(e){e.destroy(r._elem.error)})},r._elem.addEventListener("error",r._errorHandler),r._elem.src=window.URL.createObjectURL(r._mediaSource)}function c(e,t){var r=this;if(i.Writable.call(r),r._wrapper=e,r._elem=e._elem,r._mediaSource=e._mediaSource,r._allStreams=e._streams,r._allStreams.push(r),r._bufferDuration=e._bufferDuration,r._sourceBuffer=null,r._debugBuffers=[],r._openHandler=function(){r._onSourceOpen()},r._flowHandler=function(){r._flow()},r._errorHandler=function(e){r.destroyed||r.emit("error",e)},"string"==typeof t)r._type=t,"open"===r._mediaSource.readyState?r._createSourceBuffer():r._mediaSource.addEventListener("sourceopen",r._openHandler);else if(null===t._sourceBuffer)t.destroy(),r._type=t._type,r._mediaSource.addEventListener("sourceopen",r._openHandler);else{if(!t._sourceBuffer)throw new Error("The argument to MediaElementWrapper.createWriteStream must be a string or a previous stream returned from that function");t.destroy(),r._type=t._type,r._sourceBuffer=t._sourceBuffer,r._debugBuffers=t._debugBuffers,r._sourceBuffer.addEventListener("updateend",r._flowHandler),r._sourceBuffer.addEventListener("error",r._errorHandler)}r._elem.addEventListener("timeupdate",r._flowHandler),r.on("error",function(e){r._wrapper.error(e)}),r.on("finish",function(){if(!r.destroyed&&(r._finished=!0,r._allStreams.every(function(e){return e._finished}))){r._wrapper._dumpDebugData();try{r._mediaSource.endOfStream()}catch(e){}}})}u.prototype.createWriteStream=function(e){return new c(this,e)},u.prototype.error=function(e){this.detailedError||(this.detailedError=e),this._dumpDebugData();try{this._mediaSource.endOfStream("decode")}catch(e){}},u.prototype._dumpDebugData=function(){this._debug&&(this._debug=!1,this._streams.forEach(function(e,t){!function(e,t){var r=document.createElement("a");r.href=window.URL.createObjectURL(new window.Blob(e)),r.download=t,r.click()}(e._debugBuffers,"mediasource-stream-"+t)}))},n(c,i.Writable),c.prototype._onSourceOpen=function(){this.destroyed||(this._mediaSource.removeEventListener("sourceopen",this._openHandler),this._createSourceBuffer())},c.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,this._allStreams.splice(this._allStreams.indexOf(this),1),this._mediaSource.removeEventListener("sourceopen",this._openHandler),this._elem.removeEventListener("timeupdate",this._flowHandler),this._sourceBuffer&&(this._sourceBuffer.removeEventListener("updateend",this._flowHandler),this._sourceBuffer.removeEventListener("error",this._errorHandler),"open"===this._mediaSource.readyState&&this._sourceBuffer.abort()),e&&this.emit("error",e),this.emit("close"))},c.prototype._createSourceBuffer=function(){if(!this.destroyed)if(s.isTypeSupported(this._type)){if(this._sourceBuffer=this._mediaSource.addSourceBuffer(this._type),this._sourceBuffer.addEventListener("updateend",this._flowHandler),this._sourceBuffer.addEventListener("error",this._errorHandler),this._cb){var e=this._cb;this._cb=null,e()}}else this.destroy(new Error("The provided type is not supported"))},c.prototype._write=function(e,t,r){var n=this;if(!n.destroyed)if(n._sourceBuffer){if(n._sourceBuffer.updating)return r(new Error("Cannot append buffer while source buffer updating"));var i=o(e);n._wrapper._debug&&n._debugBuffers.push(i);try{n._sourceBuffer.appendBuffer(i)}catch(e){return void n.destroy(e)}n._cb=r}else n._cb=function(i){if(i)return r(i);n._write(e,t,r)}},c.prototype._flow=function(){if(!this.destroyed&&this._sourceBuffer&&!this._sourceBuffer.updating&&!("open"===this._mediaSource.readyState&&this._getBufferDuration()>this._bufferDuration)&&this._cb){var e=this._cb;this._cb=null,e()}};c.prototype._getBufferDuration=function(){for(var e=this._sourceBuffer.buffered,t=this._elem.currentTime,r=-1,n=0;nt)break;(r>=0||t<=o)&&(r=o)}var s=r-t;return s<0&&(s=0),s}},function(e,t,r){var n=r(618);e.exports=function e(t,r,i){if("function"==typeof r)return e(t,null,r);n(t,r,function(e,t){if(e)return i(e);var r=URL.createObjectURL(t);i(null,r)})}},function(e,t,r){var n=r(30);e.exports=function e(t,r,i){if("function"==typeof r)return e(t,null,r);i=n(i);var o=[];t.on("data",function(e){o.push(e)}).on("end",function(){var e=r?new Blob(o,{type:r}):new Blob(o);i(null,e)}).on("error",i)}},function(e,t){e.exports=function(e,t){if(!(t>=e.length||t<0)){var r=e.pop();if(t=this._parserSize;){var n=1===this._buffer.length?this._buffer[0]:s.concat(this._buffer);this._bufferSize-=this._parserSize,this._buffer=this._bufferSize?[n.slice(this._parserSize)]:[],this._parser(n.slice(0,this._parserSize))}r(null)},k.prototype._callback=function(e,t,r){e&&(this._clearTimeout(),this.peerChoking||this._finished||this._updateTimeout(),e.callback(t,r))},k.prototype._clearTimeout=function(){this._timeout&&(clearTimeout(this._timeout),this._timeout=null)},k.prototype._updateTimeout=function(){var e=this;e._timeoutMs&&e.requests.length&&!e._timeout&&(e._timeout=setTimeout(function(){e._onTimeout()},e._timeoutMs),e._timeoutUnref&&e._timeout.unref&&e._timeout.unref())},k.prototype._parse=function(e,t){this._parserSize=e,this._parser=t},k.prototype._onMessageLength=function(e){var t=e.readUInt32BE(0);t>0?this._parse(t,this._onMessage):(this._onKeepAlive(),this._parse(4,this._onMessageLength))},k.prototype._onMessage=function(e){switch(this._parse(4,this._onMessageLength),e[0]){case 0:return this._onChoke();case 1:return this._onUnchoke();case 2:return this._onInterested();case 3:return this._onUninterested();case 4:return this._onHave(e.readUInt32BE(1));case 5:return this._onBitField(e.slice(1));case 6:return this._onRequest(e.readUInt32BE(1),e.readUInt32BE(5),e.readUInt32BE(9));case 7:return this._onPiece(e.readUInt32BE(1),e.readUInt32BE(5),e.slice(9));case 8:return this._onCancel(e.readUInt32BE(1),e.readUInt32BE(5),e.readUInt32BE(9));case 9:return this._onPort(e.readUInt16BE(1));case 20:return this._onExtended(e.readUInt8(1),e.slice(2));default:return this._debug("got unknown message"),this.emit("unknownmessage",e)}},k.prototype._parseHandshake=function(){var e=this;e._parse(1,function(t){var r=t.readUInt8(0);e._parse(r+48,function(t){var n=t.slice(0,r);if("BitTorrent protocol"!==n.toString())return e._debug("Error: wire not speaking BitTorrent protocol (%s)",n.toString()),void e.end();t=t.slice(r),e._onHandshake(t.slice(8,28),t.slice(28,48),{dht:!!(1&t[7]),extended:!!(16&t[5])}),e._parse(4,e._onMessageLength)})})},k.prototype._onFinish=function(){for(this._finished=!0,this.push(null);this.read(););for(clearInterval(this._keepAliveInterval),this._parse(Number.MAX_VALUE,function(){});this.peerRequests.length;)this.peerRequests.pop();for(;this.requests.length;)this._callback(this.requests.pop(),new Error("wire was closed"),null)},k.prototype._debug=function(){var e=[].slice.call(arguments);e[0]="["+this._debugId+"] "+e[0],a.apply(null,e)}},function(e,t,r){(function(e,t){!function(){var r;"undefined"!=typeof window&&(r=window),void 0!==e&&(r=e);var n=(r=r||{}).console||{log:function(){}};function i(e){return e.slice?i[t(e)]:function(r,n){e(r={exports:{}}),i[t(n)]=r.exports};function t(e){return e.split("/").slice(-1).toString().replace(".js","")}}var o=t;i(function(e){var t={fn:{is:function(e){return!!e&&"function"==typeof e}}};t.bi={is:function(e){return e instanceof Boolean||"boolean"==typeof e}},t.num={is:function(e){return!n(e)&&(e-parseFloat(e)+1>=0||1/0===e||-1/0===e)}},t.text={is:function(e){return"string"==typeof e}},t.text.ify=function(e){return t.text.is(e)?e:"undefined"!=typeof JSON?JSON.stringify(e):e&&e.toString?e.toString():e},t.text.random=function(e,t){var r="";for(e=e||24,t=t||"0123456789ABCDEFGHIJKLMNOPQRSTUVWXZabcdefghijklmnopqrstuvwxyz";e>0;)r+=t.charAt(Math.floor(Math.random()*t.length)),e--;return r},t.text.match=function(e,r){var n=!1;if(e=e||"",r=t.text.is(r)?{"=":r}:r||{},t.obj.has(r,"~")&&(e=e.toLowerCase(),r["="]=(r["="]||r["~"]).toLowerCase()),t.obj.has(r,"="))return e===r["="];if(t.obj.has(r,"*")){if(e.slice(0,r["*"].length)!==r["*"])return!1;n=!0,e=e.slice(r["*"].length)}if(t.obj.has(r,"!")){if(e.slice(-r["!"].length)!==r["!"])return!1;n=!0}if(t.obj.has(r,"+")&&t.list.map(t.list.is(r["+"])?r["+"]:[r["+"]],function(t){if(!(e.indexOf(t)>=0))return!0;n=!0}))return!1;if(t.obj.has(r,"-")&&t.list.map(t.list.is(r["-"])?r["-"]:[r["-"]],function(t){if(!(e.indexOf(t)<0))return!0;n=!0}))return!1;if(t.obj.has(r,">")){if(!(e>r[">"]))return!1;n=!0}if(t.obj.has(r,"<")){if(!(er?1:0:0}},t.list.map=function(e,t,r){return a(e,t,r)},t.list.index=1,t.obj={is:function(e){return!!e&&(e instanceof Object&&e.constructor===Object||"Object"===Object.prototype.toString.call(e).match(/^\[object (\w+)\]$/)[1])}},t.obj.put=function(e,t,r){return(e||{})[t]=r,e},t.obj.has=function(e,t){return e&&Object.prototype.hasOwnProperty.call(e,t)},t.obj.del=function(e,t){if(e)return e[t]=null,delete e[t],e},t.obj.as=function(e,t,r,n){return e[t]=e[t]||(n===r?{}:r)},t.obj.ify=function(e){if(o(e))return e;try{e=JSON.parse(e)}catch(t){e={}}return e},function(){var e;function r(t,r){s(this,r)&&e!==this[r]||(this[r]=t)}t.obj.to=function(e,t){return a(e,r,t=t||{}),t}}(),t.obj.copy=function(e){return e?JSON.parse(JSON.stringify(e)):e},function(){function e(e,t){var r=this.n;if(!r||!(t===r||o(r)&&s(r,t)))return!!t||void 0}t.obj.empty=function(t,r){return!t||!a(t,e,{n:r})}}(),function(){function e(t,r){if(2===arguments.length)return e.r=e.r||{},void(e.r[t]=r);e.r=e.r||[],e.r.push(t)}var i=Object.keys;t.obj.map=function(a,u,c){var f,l,h,p,d,y=0,g=r(u);if(e.r=null,i&&o(a)&&(p=i(a),d=!0),n(a)||p)for(l=(p||a).length;y",n.drift=0,n.is=function(e,t,r){var i=t&&e&&e[v]&&e[v][n._]||r;if(i)return m(i=i[t])?i:-1/0},n.lex=function(){return n().toString(36).replace(".","")},n.ify=function(e,t,i,o,s){if(!e||!e[v]){if(!s)return;e=r.soul.ify(e,s)}var a=h(e[v],n._);return f!==t&&t!==v&&(m(i)&&(a[t]=i),f!==o&&(e[t]=o)),e},n.to=function(e,t,i){var o=e[t];return d(o)&&(o=g(o)),n.ify(i,t,n.is(e,t),o,r.soul(e))},function(){function e(e,t){v!==t&&n.ify(this.o,t,this.s)}n.map=function(t,r,i){var o,s=d(s=t||r)?s:null;return t=b(t=t||r)?t:null,s&&!t?(r=m(r)?r:n(),s[v]=s[v]||{},y(s,e,{o:s,s:r}),s):(i=i||d(r)?r:o,r=m(r)?r:n(),function(n,s,a,u){if(!t)return e.call({o:a,s:r},n,s),n;t.call(i||this||{},n,s,a,u),p(a,s)&&o===a[s]||e.call({o:a,s:r},n,s)})}}();var f,l=t.obj,h=l.as,p=l.has,d=l.is,y=l.map,g=l.copy,m=t.num.is,b=t.fn.is,v=r._;e.exports=n})(i,"./state"),i(function(e){var t=i("./type"),r=i("./val"),n=i("./node"),o={};!function(){function e(e,r){if(!e||r!==n.soul(e)||!n.is(e,this.fn,this.as))return!0;this.cb&&(t.n=e,t.as=this.as,this.cb.call(t.as,e,r,t))}function t(e){e&&n.is(t.n,e,t.as)}o.is=function(t,r,n,i){return!(!t||!u(t)||l(t)||p(t,e,{cb:r,fn:n,as:i}))}}(),function(){function e(e,t){var o;return(o=function(e,t){for(var r,n=e.seen,i=n.length;i--;)if(r=n[i],t.obj===r.obj)return r;n.push(t)}(e,t))?o:(t.env=e,t.soul=a,n.ify(t.obj,i,t)&&(e.graph[r.rel.is(t.rel)]=t.node),t)}function i(t,i,o){var a,u,h=this,p=h.env;if(n._===i&&f(t,r.rel._))return o._;if(a=l(t,i,o,h,p)){if(i||(h.node=h.node||o||{},f(t,n._)&&n.soul(t)&&(h.node._=d(t._)),h.node=n.soul.ify(h.node,r.rel.is(h.rel)),h.rel=h.rel||r.rel.ify(n.soul(h.node))),(u=p.map)&&(u.call(p.as||{},t,i,o,h),f(o,i))){if(t=o[i],s===t)return void c(o,i);if(!(a=l(t,i,o,h,p)))return}if(!i)return h.node;if(!0===a)return t;if((u=e(p,{obj:t,path:h.path.concat(i)})).node)return u.rel}}function a(e){var t=this,i=r.link.is(t.rel),o=t.env.graph;t.rel=t.rel||r.rel.ify(e),t.rel[r.rel._]=e,t.node&&t.node[n._]&&(t.node[n._][r.rel._]=e),f(o,i)&&(o[e]=o[i],c(o,i))}function l(e,n,i,o,s){var a;return!!r.is(e)||(u(e)?1:(a=s.invalid)?l(e=a.call(s.as||{},e,n,i),n,i,o,s):(s.err="Invalid value at '"+o.path.concat(n).join(".")+"'!",void(t.list.is(e)&&(s.err+=" Use `.set(item)` instead of an Array."))))}o.ify=function(t,n,i){var o={path:[],obj:t};return n?"string"==typeof n?n={soul:n}:n instanceof Function&&(n.map=n):n={},n.soul&&(o.rel=r.rel.ify(n.soul)),n.graph=n.graph||{},n.seen=n.seen||[],n.as=n.as||i,e(n,o),n.root=o.node,n.graph}}(),o.node=function(e){var t=n.soul(e);if(t)return h({},t,e)},function(){function e(e,t){var i,s;if(n._!==t)(i=r.rel.is(e))?(s=this.opt.seen[i])?this.obj[t]=s:this.obj[t]=this.opt.seen[i]=o.to(this.graph,i,this.opt):this.obj[t]=e;else{if(l(e,r.rel._))return;this.obj[t]=d(e)}}o.to=function(t,r,n){if(t){var i={};return n=n||{seen:{}},p(t[r],e,{obj:i,graph:t,opt:n}),i}}}();t.fn.is;var s,a=t.obj,u=a.is,c=a.del,f=a.has,l=a.empty,h=a.put,p=a.map,d=a.copy;e.exports=o})(i,"./graph"),i(function(e){i("./onto"),e.exports=function(e,t){if(this.on){if(!(e instanceof Function)){if(!e||!t)return;var r=e["#"]||e,n=(this.tag||empty)[r];if(!n)return;return n=this.on(r,t),clearTimeout(n.err),!0}r=t&&t["#"]||Math.random().toString(36).slice(2);if(!e)return r;var i=this.on(r,e,t);return i.err=i.err||setTimeout(function(){i.next({err:"Error: No ACK received yet.",lack:!0}),i.off()},(this.opt||{}).lack||9e3),r}}})(i,"./ask"),i(function(e){var t=i("./type");var r=t.time.is;e.exports=function(e){var n={s:{}};return e=e||{max:1e3,age:9e3},n.check=function(e){var t;return!!(t=n.s[e])&&(t.pass?t.pass=!1:n.track(e))},n.track=function(i,o){var s=n.s[i]||(n.s[i]={});return s.was=r(),o&&(s.pass=!0),n.to||(n.to=setTimeout(function(){var i=r();t.obj.map(n.s,function(r,o){e.age>i-r.was||t.obj.del(n.s,o)}),n.to=null},e.age+9)),s},n}})(i,"./dup"),i(function(e){function t(e){return e instanceof t?(this._={gun:this,$:this}).$:this instanceof t?t.create(this._={gun:this,$:this,opt:e}):new t(e)}t.is=function(e){return e instanceof t||e&&e._&&e===e._.$||!1},t.version=.9,t.chain=t.prototype,t.chain.toJSON=function(){};var r=i("./type");r.obj.to(r,t),t.HAM=i("./HAM"),t.val=i("./val"),t.node=i("./node"),t.state=i("./state"),t.graph=i("./graph"),t.on=i("./onto"),t.ask=i("./ask"),t.dup=i("./dup"),function(){function e(r){var n,i,o=this,a=o.as,u=a.at||a,c=u.$;(i=r["#"])||(i=r["#"]=f(9)),(n=u.dup).check(i)?a.out===r.out&&(r.out=s,o.to.next(r)):(n.track(i),u.ask(r["@"],r)||(r.get&&t.on.get(r,c),r.put&&t.on.put(r,c)),o.to.next(r),a.out||(r.out=e,u.on("out",r)))}t.create=function(r){r.root=r.root||r,r.graph=r.graph||{},r.on=r.on||t.on,r.ask=r.ask||t.ask,r.dup=r.dup||t.dup();var n=r.$.opt(r.opt);return r.once||(r.on("in",e,r),r.on("out",e,{at:r,out:e}),t.on("create",r),r.on("create",r)),r.once=1,n}}(),function(){function e(e,r,n,i){var o=this,s=t.state.is(n,r);if(!s)return o.err="Error: No state on '"+r+"' in node '"+i+"'!";var a=o.graph[i]||v,u=t.state.is(a,r,!0),c=a[r],f=t.HAM(o.machine,s,u,e,c);f.incoming?(o.put[i]=t.state.to(n,r,o.put[i]),(o.diff||(o.diff={}))[i]=t.state.to(n,r,o.diff[i]),o.souls[i]=!0):f.defer&&(o.defer=s<(o.defer||1/0)?s:o.defer)}function r(e,t){var r=this,s=r.$._,a=(s.next||v)[t];if(!a){if(!(s.opt||v).super)return void(r.souls[t]=!1);a=r.$.get(t)._}var u=r.map[t]={put:e,get:t,$:a.$},c={ctx:r,msg:u};r.async=!!s.tag.node,r.ack&&(u["@"]=r.ack),y(e,n,c),r.async&&(r.and||s.on("node",function(e){this.to.next(e),e===r.map[e.get]&&(r.souls[e.get]=!1,y(e.put,i,e),y(r.souls,function(e){if(e)return e})||r.c||(r.c=1,this.off(),y(r.map,o,r)))}),r.and=!0,s.on("node",u))}function n(e,r){var n=this.ctx,i=n.graph,o=this.msg,s=o.get,a=o.put,u=o.$._;i[s]=t.state.to(a,r,i[s]),n.async||(u.put=t.state.to(a,r,u.put))}function i(e,r){var n=this.put,i=this.$._;i.put=t.state.to(n,r,i.put)}function o(e,t){e.$&&(this.cat.stop=this.stop,e.$._.on("in",e),this.cat.stop=null)}t.on.put=function(n,i){var a=i._,u={$:i,graph:a.graph,put:{},map:{},souls:{},machine:t.state(),ack:n["@"],cat:a,stop:{}};if(t.graph.is(n.put,null,e,u)||(u.err="Error: Invalid graph!"),u.err)return a.on("in",{"@":n["#"],err:t.log(u.err)});y(u.put,r,u),u.async||y(u.map,o,u),s!==u.defer&&setTimeout(function(){t.on.put(n,i)},u.defer-u.machine),u.diff&&a.on("put",d(n,{put:u.diff}))},t.on.get=function(e,r){var n=r._,i=e.get[m],o=n.graph[i],s=e.get[b],a=(n.next||(n.next={}))[i];if(!o||!a)return n.on("get",e);if(s){if(!p(o,s))return n.on("get",e);o=t.state.to(o,s)}else o=t.obj.copy(o);o=t.graph.node(o),a.ack,n.on("in",{"@":e["#"],how:"mem",put:o,$:r}),n.on("get",e)}}(),t.chain.opt=function(e){e=e||{};var r=this._,n=e.peers||e;return h(e)||(e={}),h(r.opt)||(r.opt=e),c(n)&&(n=[n]),a(n)&&(n=y(n,function(e,t,r){r(e,{url:e})}),h(r.opt.peers)||(r.opt.peers={}),r.opt.peers=d(n,r.opt.peers)),r.opt.peers=r.opt.peers||{},d(e,r.opt),t.on("opt",r),r.opt.uuid=r.opt.uuid||function(){return g()+f(12)},this};var s,a=t.list.is,u=t.text,c=u.is,f=u.random,l=t.obj,h=l.is,p=l.has,d=l.to,y=l.map,g=(l.copy,t.state.lex),m=t.val.rel._,b=".",v=(t.node._,t.val.link.is,{});n.debug=function(e,t){return n.debug.i&&e===n.debug.i&&n.debug.i++&&(n.log.apply(n,arguments)||t)},t.log=function(){return!t.log.off&&n.log.apply(n,arguments),[].slice.call(arguments).join(" ")},t.log.once=function(e,r,n){return(n=t.log.once)[e]=n[e]||0,n[e]++||t.log(r)},t.log.once("welcome","Hello wonderful person! :) Thanks for using GUN, feel free to ask for help on https://gitter.im/amark/gun and ask StackOverflow questions tagged with 'gun'!"),"undefined"!=typeof window&&(window.Gun=t);try{void 0!==o&&(o.exports=t)}catch(e){}e.exports=t})(i,"./root"),i(function(e){var t=i("./root");t.chain.back=function(e,i){if(-1===(e=e||1)||1/0===e)return this._.root.$;if(1===e)return(this._.back||this._).$;var o=this._;if("string"==typeof e&&(e=e.split(".")),e instanceof Array){for(var s=0,a=e.length,u=o;s .once, apologies unexpected."),this.once(e,r)},t.chain.once=function(e,r){var i=this,s=i._,a=s.put;if(0=(t.batch||1e3))return u();r||(r=setTimeout(u,t.wait||1))}),e.on("get",function(r){this.to.next(r);var n,i,o,a=r.get;function u(){if(a&&(n=a["#"])){var u=a["."];(i=s[n]||o)&&u&&(i=Gun.state.to(i,u)),(i||Gun.obj.empty(t.peers))&&e.on("in",{"@":r["#"],put:Gun.graph.node(i),how:"lS",lS:r.I})}}Gun.debug?setTimeout(u,1):u()});var a=function(e,t,r,n){s[n]=Gun.state.to(r,t,s[n])},u=function(a){var c;o=0,clearTimeout(r),r=!1;var f=i;i={},a&&(s=a);try{n.setItem(t.file,JSON.stringify(s))}catch(a){Gun.log(c=a||"localStorage failure"),e.on("localStorage:error",{err:c,file:t.file,flush:s,retry:u})}(c||Gun.obj.empty(t.peers))&&Gun.obj.map(f,function(t,r){e.on("in",{"@":r,err:c,ok:0})})}}})}})(i,"./adapters/localStorage"),i(function(e){var t=i("../type");function r(e){var i=function(){};return i.out=function(t){var r;if(this.to&&this.to.next(t),(r=t["@"])&&(r=e.dup.s[r])&&(r=r.it)&&r.mesh)return i.say(t,r.mesh.via),void(r["##"]=t["##"]);i.say(t)},i.hear=function(r,n){if(r){var o,s,a,u=e.dup,c=r[0];try{a=JSON.parse(r)}catch(e){}if("{"===c){if(!a)return;if(u.check(o=a["#"]))return;if(u.track(o,!0).it=a,(c=a["@"])&&a.put&&(c+=s=a["##"]||(a["##"]=i.hash(a)))!=o){if(u.check(c))return;(c=u.s)[s]=c[o]}return(a.mesh=function(){}).via=n,(c=a["><"])&&(a.mesh.to=t.obj.map(c.split(","),function(e,t,r){r(e,!0)})),void e.on("in",a)}if("["!==c);else{if(!a)return;for(var f,l=0;f=a[l++];)i.hear(f,n)}}},function(){function r(e,t){var r=t.wire;try{r.send?r.readyState===r.OPEN?r.send(e):(t.queue=t.queue||[]).push(e):t.say&&t.say(e)}catch(r){(t.queue=t.queue||[]).push(e)}}i.say=function(n,s){var a,u,c;s?(s.wire||e.opt.wire&&e.opt.wire(s))&&(u=n.mesh||o,s!==u.via&&((c=u.raw)||(c=i.raw(n)),(a=n["@"])&&(a=e.dup.s[a])&&(a=a.it)&&a.get&&a["##"]&&a["##"]===n["##"]||(a=u.to)&&(a[s.url]||a[s.id])||(s.batch?s.batch.push(c):(s.batch=[],setTimeout(function(){var e=s.batch;e&&(s.batch=null,e.length&&r(JSON.stringify(e),s))},e.opt.gap||e.opt.wait||1),r(c,s))))):t.obj.map(e.opt.peers,function(e){i.say(n,e)})}}(),function(){function o(e,r){var n;return r instanceof Object?(t.obj.map(Object.keys(r).sort(),s,{to:n={},on:r}),n):r}function s(e){this.to[e]=this.on[e]}i.raw=function(r){if(!r)return"";var s,c,f,l=e.dup,h=r.mesh||{};if(f=h.raw)return f;if("string"==typeof r)return r;r["@"]&&(f=r.put)&&((c=r["##"])||(s=a(f,o)||"",c=i.hash(r,s),r["##"]=c),(f=l.s)[c=r["@"]+c]=f[r["#"]],r["#"]=c||r["#"],s&&((r=t.obj.to(r)).put=u));var p=0,d=[];t.obj.map(e.opt.peers,function(e){if(d.push(e.url||e.id),++p>9)return!0}),r["><"]=d.join();var y=a(r);return n!==s&&(y=y.replace('"'+u+'"',s)),h&&(h.raw=y),y},i.hash=function(e,n){return r.hash(n||a(e.put,o)||"")||e["#"]||t.text.random(9)};var a=JSON.stringify,u=":])([:"}(),i.hi=function(r){e.on("hi",r);var n=r.queue;r.queue=[],t.obj.map(n,function(e){i.say(e,r)})},i}r.hash=function(e){if("string"!=typeof e)return{err:1};var t=0;if(!e.length)return t;for(var r=0,n=e.length;r= 0x80 (not a basic code point)","invalid-input":"Invalid input"},w=c-f,S=Math.floor,k=String.fromCharCode;function E(e){throw new RangeError(_[e])}function A(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}function x(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),n+A((e=e.replace(v,".")).split("."),t).join(".")}function I(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i65535&&(t+=k((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+k(e)}).join("")}function B(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:c}function C(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function P(e,t,r){var n=0;for(e=r?S(e/p):e>>1,e+=S(e/t);e>w*l>>1;n+=c)e=S(e/w);return S(n+(w+1)*e/(e+h))}function O(e){var t,r,n,i,o,s,a,h,p,m,b=[],v=e.length,_=0,w=y,k=d;for((r=e.lastIndexOf(g))<0&&(r=0),n=0;n=128&&E("not-basic"),b.push(e.charCodeAt(n));for(i=r>0?r+1:0;i=v&&E("invalid-input"),((h=B(e.charCodeAt(i++)))>=c||h>S((u-_)/s))&&E("overflow"),_+=h*s,!(h<(p=a<=k?f:a>=k+l?l:a-k));a+=c)s>S(u/(m=c-p))&&E("overflow"),s*=m;k=P(_-o,t=b.length+1,0==o),S(_/t)>u-w&&E("overflow"),w+=S(_/t),_%=t,b.splice(_++,0,w)}return T(b)}function R(e){var t,r,n,i,o,s,a,h,p,m,b,v,_,w,A,x=[];for(v=(e=I(e)).length,t=y,r=0,o=d,s=0;s=t&&bS((u-r)/(_=n+1))&&E("overflow"),r+=(a-t)*_,t=a,s=0;su&&E("overflow"),b==t){for(h=r,p=c;!(h<(m=p<=o?f:p>=o+l?l:p-o));p+=c)A=h-m,w=c-m,x.push(k(C(m+A%w,0))),h=S(A/w);x.push(k(C(h,0))),o=P(r,_,n==i),r=0,++n}++r,++t}return x.join("")}a={version:"1.4.1",ucs2:{decode:I,encode:T},decode:O,encode:R,toASCII:function(e){return x(e,function(e){return b.test(e)?"xn--"+R(e):e})},toUnicode:function(e){return x(e,function(e){return m.test(e)?O(e.slice(4).toLowerCase()):e})}},void 0===(i=function(){return a}.call(t,r,t,e))||(e.exports=i)}()}).call(this,r(27)(e),r(7))},function(e,t,r){"use strict";e.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},function(e,t,r){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.exports=function(e,t,r,o){t=t||"&",r=r||"=";var s={};if("string"!=typeof e||0===e.length)return s;var a=/\+/g;e=e.split(t);var u=1e3;o&&"number"==typeof o.maxKeys&&(u=o.maxKeys);var c=e.length;u>0&&c>u&&(c=u);for(var f=0;f=0?(l=y.substr(0,g),h=y.substr(g+1)):(l=y,h=""),p=decodeURIComponent(l),d=decodeURIComponent(h),n(s,p)?i(s[p])?s[p].push(d):s[p]=[s[p],d]:s[p]=d}return s};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},function(e,t,r){"use strict";var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};e.exports=function(e,t,r,a){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?o(s(e),function(s){var a=encodeURIComponent(n(s))+r;return i(e[s])?o(e[s],function(e){return a+encodeURIComponent(n(e))}).join(t):a+encodeURIComponent(n(e[s]))}).join(t):a?encodeURIComponent(n(a))+r+encodeURIComponent(n(e)):""};var i=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function o(e,t){if(e.map)return e.map(t);for(var r=[],n=0;ns.parse(e)).find(e=>"https:"===e.protocol&&["gateway.dweb.me","dweb.me"].includes(e.host)&&(e.pathname.includes("/content/rawfetch")||e.pathname.includes("/contenthash/"))||"contenthash:"===e.protocol&&"contenthash"===e.pathname.split("/")[1]);return r||(r=`contenthash:/contenthash/${e.keypair.verifyexportmultihashsha256_58()}`),[r,r]}async p_f_createReadStream(e,{verbose:t=!1,wanturl:r=!1}={}){t&&console.log(this.name,"p_f_createreadstream",s.parse(e).href);try{let n=this;return r?e:function(r){return n.p_createReadStream(e,r,t)}}catch(t){throw console.warn(`p_f_createReadStream failed on ${s.parse(e).href} ${t.message}`),t}}async createReadStream(e,t,r){let n;r&&console.log(this.name,"createreadstream",s.parse(e).href,t);try{return n=new a.PassThrough,o.p_GET(this._url(e,servercommands.rawfetch),Object.assign({wantstream:!0},t)).then(e=>e.pipe(n)),n}catch(e){console.log(this.name,"createReadStream caught error",e),"function"==typeof n.destroy?n.destroy(e):n.emit("error",e)}}async p_createReadStream(e,t,r){r&&console.log(this.name,"createreadstream",s.parse(e).href,t);try{return await o.p_GET(this._url(e,servercommands.rawfetch),Object.assign({wantstream:!0},t))}catch(e){throw console.warn(this.name,"caught error",e),e}}async p_newdatabase(e,{verbose:t=!1}={}){e.hasOwnProperty("keypair")&&(e=e.keypair.signingexport());let r=`${this.urlbase}/getall/table/${encodeURIComponent(e)}`;return{publicurl:r,privateurl:r}}async p_newtable(e,t,{verbose:r=!1}={}){if(!e)throw new errors.CodingError("p_newtable currently requires a pubkey");let n=await this.p_newdatabase(e,{verbose:r});return{privateurl:`${n.privateurl}/${t}`,publicurl:`${n.publicurl}/${t}`}}async p_set(e,t,r,{verbose:n=!1}={}){if(!e||!t)throw new errors.CodingError("TransportHTTP.p_set: invalid parms",e,keyvalyes);if(n&&console.log("p_set",e,t,r),"string"==typeof t){let i=JSON.stringify([{key:t,value:r}]);await o.p_POST(this._url(e,servercommands.set),"application/json",i,n)}else{let r=JSON.stringify(Object.keys(t).map(e=>({key:e,value:t[e]})));await o.p_POST(this._url(e,servercommands.set),"application/json",r,n)}}_keyparm(e){return`key=${encodeURIComponent(e)}`}async p_get(e,t,{verbose:r=!1}={}){if(!e&&t)throw new errors.CodingError("TransportHTTP.p_get: requires url and at least one key");let n=Array.isArray(t)?t.map(e=>this._keyparm(e)).join("&"):this._keyparm(t),i=await o.p_GET(this._url(e,servercommands.get,n),{verbose:r});return Array.isArray(t)?i:i[t]}async p_delete(e,t,{verbose:r=!1}={}){if(!e&&t)throw new errors.CodingError("TransportHTTP.p_get: requires url and at least one key");let n=t.map(e=>this._keyparm(e)).join("&");await o.p_GET(this._url(e,servercommands.delete,n),{verbose:r})}async p_keys(e,{verbose:t=!1}={}){if(!e&&keys)throw new errors.CodingError("TransportHTTP.p_get: requires url and at least one key");return await o.p_GET(this._url(e,servercommands.keys),{verbose:t})}async p_getall(e,{verbose:t=!1}={}){if(!e&&keys)throw new errors.CodingError("TransportHTTP.p_get: requires url and at least one key");return await o.p_GET(this._url(e,servercommands.getall),{verbose:t})}p_info(e){return o.p_GET(`${this.urlbase}/info`,{verbose:e})}static async p_test(e={},t=!1){t&&console.log("TransportHTTP.test");try{let r=await this.p_setup(e,t);t&&console.log("HTTP connected");let i=await r.p_info(t);t&&console.log("TransportHTTP info=",i),i=await r.p_status(t),console.assert(i===n.STATUS_CONNECTED),await r.p_test_kvt("NACL%20VERIFY",t)}catch(e){throw console.log("Exception thrown in TransportHTTP.test:",e.message),e}}static async test(){return this}}i._transportclasses.HTTP=u,e.exports=u},function(e,t,r){"use strict";t.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){for(var t,r=c(e),n=r[0],s=r[1],a=new o(function(e,t,r){return 3*(t+r)/4-r}(0,n,s)),u=0,f=s>0?n-4:n,l=0;l>16&255,a[u++]=t>>8&255,a[u++]=255&t;return 2===s&&(t=i[e.charCodeAt(l)]<<2|i[e.charCodeAt(l+1)]>>4,a[u++]=255&t),1===s&&(t=i[e.charCodeAt(l)]<<10|i[e.charCodeAt(l+1)]<<4|i[e.charCodeAt(l+2)]>>2,a[u++]=t>>8&255,a[u++]=255&t),a},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o=[],s=0,a=r-i;sa?a:s+16383));return 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]+"=")),o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=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){return n[e>>18&63]+n[e>>12&63]+n[e>>6&63]+n[63&e]}function l(e,t,r){for(var n,i=[],o=t;o0?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=n.allocUnsafe(e>>>0),r=this.head,i=0;r;)o(r.data,t,i),i+=r.data.length,r=r.next;return t},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(t){function r(e){try{if(!t.localStorage)return!1}catch(e){return!1}var r=t.localStorage[e];return null!=r&&"true"===String(r).toLowerCase()}e.exports=function(e,t){if(r("noDeprecation"))return e;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}}}).call(this,r(7))},function(e,t,r){"use strict";e.exports=o;var n=r(335),i=r(117);function o(e){if(!(this instanceof o))return new o(e);n.call(this,e)}i.inherits=r(4),i.inherits(o,n),o.prototype._transform=function(e,t,r){r(null,e)}},function(e,t){},function(e,t,r){(function(t){const n=r(336),i=r(636),o=r(9),s=(r(36),r(33)),a=(r(22),r(79)),u=r(116),c=r(102),f=r(149),l={repo:"/tmp/dweb_ipfsv2700",config:{Bootstrap:["/dns4/dweb.me/tcp/4245/wss/ipfs/QmPNgKEjC7wkpu3aHUzKKhZmbEfiGzL5TP1L8zZoHJyXZW"]},EXPERIMENTAL:{pubsub:!0}};class h extends u{constructor(e,t){super(e,t),this.ipfs=void 0,this.options=e,this.name="IPFS",this.supportURLs=["ipfs"],this.supportFunctions=["fetch","store","createReadStream"],this.status=u.STATUS_LOADED}p_ipfsstart(e){const t=this;return new Promise((e,t)=>{this.ipfs=new i(this.options),this.ipfs.on("ready",()=>{e()}),this.ipfs.on("error",e=>t(e))}).then(()=>t.ipfs.version()).then(e=>console.log("IPFS READY",e)).catch(e=>{throw console.log("Error caught in p_ipfsstart"),e})}static setup0(e,t){const r=u.mergeoptions(l,e.ipfs);t&&console.log("IPFS loading options %o",r);const n=new h(r,t);return c.addtransport(n),n}async p_setup1(e,t){try{e&&console.log("IPFS starting and connecting"),this.status=u.STATUS_STARTING,t&&t(this),await this.p_ipfsstart(e),this.status=await this.p_status(e)}catch(e){console.error(this.name,"failed to connect",e),this.status=u.STATUS_FAILED}return t&&t(this),this}async p_status(e){return this.status=await this.ipfs.isOnline()?u.STATUS_CONNECTED:u.STATUS_FAILED,super.p_status(e)}static urlFrom(e){if(e instanceof o)return"ipfs:/ipfs/"+e.toBaseEncodedString();if("object"==typeof e&&e.hash)return"ipfs:/ipfs/"+e.hash;if("string"==typeof e)return"ipfs:/ipfs/"+e;throw new a.CodingError("TransportIPFS.urlFrom: Cant convert to url from",e)}static cidFrom(e){if(e instanceof o)return e;if("string"==typeof e&&(e=s.parse(e)),e&&e.pathname){const t=e.pathname.split("/");if(!["ipfs:","dweb:"].includes(e.protocol)||"ipfs"!==t[1]||t.length<3)throw new a.TransportError("TransportIPFS.cidFrom bad format for url should be dweb: or ipfs:/ipfs/...: "+e.href);if(t.length>3)throw new a.TransportError("TransportIPFS.cidFrom not supporting paths in url yet, should be dweb: or ipfs:/ipfs/...: "+e.href);return new o(t[2])}throw new a.CodingError("TransportIPFS.cidFrom: Cant convert url",e)}static _stringFrom(e){return e instanceof o?"/ipfs/"+e.toBaseEncodedString():"object"==typeof e&&e.path?e.path:void 0}static ipfsFrom(e){if((e=this._stringFrom(e)).indexOf("/ipfs/")>-1)return e.slice(e.indexOf("/ipfs/"));throw new a.CodingError(`TransportIPFS.ipfsFrom: Cant convert url ${e} into a path starting /ipfs/`)}static ipfsGatewayFrom(e){if((e=this._stringFrom(e)).indexOf("/ipfs/")>-1)return"https://ipfs.io"+e.slice(e.indexOf("/ipfs/"));throw new a.CodingError(`TransportIPFS.ipfsGatewayFrom: Cant convert url ${e} into a path starting /ipfs/`)}static multihashFrom(e){if(e instanceof o)return cid.toBaseEncodedString();if("object"==typeof e&&e.path&&(e=e.path),"string"==typeof e){const t=e.indexOf("/ipfs/");if(t>-1)return e.slice(t+6)}throw new a.CodingError(`Cant turn ${e} into a multihash`)}async p_rawfetch(e,{verbose:t=!1,timeoutMS:r=6e4,relay:i=!1}={}){if(t&&console.log("IPFS p_rawfetch",s.parse(e).href),!e)throw new a.CodingError("TransportIPFS.p_rawfetch: requires url");const o=h.cidFrom(e),u=h.ipfsFrom(e);try{const i=await f.p_timeout(this.ipfs.dag.get(o),r,"Timed out IPFS fetch of "+h._stringFrom(o));if(i.remainderPath.length)throw new a.TransportError("Not yet supporting paths in p_rawfetch");let c;return"DAGNode"===i.value.constructor.name?(t&&console.log("IPFS p_rawfetch looks like its a file",s.parse(e).href),c=await this.ipfs.files.cat(u)):c=i.value,t&&console.log(`IPFS fetched ${c.length} from ${u}`),c}catch(t){console.log("Caught misc error in TransportIPFS.p_rawfetch trying IPFS",t.message);try{let t=h.ipfsGatewayFrom(e);return await f.p_timeout(n.p_GET(t),r,"Timed out IPFS fetch of "+t)}catch(e){throw console.log("Caught misc error in TransportIPFS.p_rawfetch trying gateway",e.message),e}}}async p_rawstore(e,{verbose:r}){console.assert(e,"TransportIPFS.p_rawstore: requires data");const n=e instanceof t?e:new t(e),i=(await this.ipfs.files.add(n,{"cid-version":1,hashAlg:"sha2-256"}))[0];return h.urlFrom(i)}async p_f_createReadStream(e,{verbose:t=!1,wanturl:r=!1}={}){let n;t&&console.log(this.name,"p_f_createreadstream %o",e);try{let i=e.pathname.split("/ipfs/")[1];if(i.includes("/"))throw new CodingError("Should not be seeing URLS with a path here:"+e);let o=this;return r?e:function(e){t&&console.log("TransportIPFS createreadstream %o %o",i,e);const r=e?e.start:0,s=e&&e.end?r+e.end+1:void 0;return n&&n.destroy&&n.destroy(),(n=o.ipfs.files.catReadableStream(i,{offset:r,length:s&&s-r})).on("error",e=>console.error(e)),n}}catch(t){throw n&&n.destroy&&n.destroy(),console.log(`p_f_createReadStream failed on ${e} ${t.message}`),t}}static async p_test(e,t){t&&console.log("TransportIPFS.test");try{const r=await this.p_setup(e,t);t&&console.log(r.name,"setup");const n=await r.p_status(t);let i;console.assert(n===u.STATUS_CONNECTED);const o="The quick brown fox",s="ipfs:/ipfs/zdpuAscRnisRkYnEyJAp1LydQ3po25rCEDPPEDMymYRfN1yPK",a=await r.p_rawstore(o,{verbose:t});t&&console.log("rawstore returned",a);const c=h.cidFrom(a);console.assert(a===s,"url should match url from rawstore");a.split("/")[2];const f=h.urlFrom(c);console.assert(a===f,"Should round trip"),i=a;const l=await r.p_rawfetch(i,{verbose:t});return console.assert(l.toString()===o,"Should fetch block stored above"),r}catch(e){throw console.log("Exception thrown in TransportIPFS.test:",e.message),e}}}c._transportclasses.IPFS=h,e.exports=h}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(337),i=r(637),o=r(98),s=r(51),a=r(388),u=r(41),c=r(111),f=r(486),l=r(52),h=r(12),p=r(487),d=r(212),y=r(9),g=r(1),m=r(274),b=r(10),v=r(995),_=r(1003),w=r(1004),S=r(1446),k=r(1447),E=r(1451);class A extends b{constructor(e){super(),this._options={init:!0,start:!0,EXPERIMENTAL:{},preload:{enabled:!0,addresses:["/dnsaddr/node0.preload.ipfs.io/https","/dnsaddr/node1.preload.ipfs.io/https"]}},e=v.validate(e||{}),m(this._options,e),!1===e.init&&(this._options.init=!1),!1!==e.start&&(this._options.start=!0),"string"==typeof e.repo||void 0===e.repo?this._repo=S(e.repo):this._repo=e.repo,this.log=g("jsipfs"),this.log.err=g("jsipfs:err"),this.types={Buffer:t,PeerId:o,PeerInfo:s,multiaddr:l,multibase:d,multihash:h,CID:y,dagPB:u,dagCBOR:a},this._peerInfoBook=new p,this._peerInfo=void 0,this._libp2pNode=void 0,this._bitswap=void 0,this._blockService=new n(this._repo),this._ipld=new i(this._blockService),this._pubsub=void 0,this._preload=k(this),this._mfsPreload=E(this),this.init=w.init(this),this.preStart=w.preStart(this),this.start=w.start(this),this.stop=w.stop(this),this.shutdown=this.stop,this.isOnline=w.isOnline(this),this.version=w.version(this),this.id=w.id(this),this.repo=w.repo(this),this.bootstrap=w.bootstrap(this),this.config=w.config(this),this.block=w.block(this),this.object=w.object(this),this.dag=w.dag(this),this.libp2p=w.libp2p(this),this.swarm=w.swarm(this),this.files=w.files(this),this.bitswap=w.bitswap(this),this.pin=w.pin(this),this.ping=w.ping(this),this.pingPullStream=w.pingPullStream(this),this.pingReadableStream=w.pingReadableStream(this),this.pubsub=w.pubsub(this),this.dht=w.dht(this),this.dns=w.dns(this),this.key=w.key(this),this.stats=w.stats(this),this._options.EXPERIMENTAL.pubsub&&this.log("EXPERIMENTAL pubsub is enabled"),this._options.EXPERIMENTAL.sharding&&this.log("EXPERIMENTAL sharding is enabled"),this._options.EXPERIMENTAL.dht&&this.log("EXPERIMENTAL Kademlia DHT is enabled"),this.state=r(1452)(this),this.ls=this.files.lsImmutable,this.lsReadableStream=this.files.lsReadableStreamImmutable,this.lsPullStream=this.files.lsPullStreamImmutable,this.util={crypto:c,isIPFS:f};const b=w.mfs(this);Object.keys(b).forEach(e=>{this.files[e]=b[e]}),_(this)}}(e.exports=A).createNode=(e=>new A(e))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(151),i=r(8),o=r(9),s=r(664),a=r(155),u=r(337),c=r(60).join,f=r(60).sep,l=r(225).source,h=r(226),p=r(80),d=r(49),y=r(5),g=r(35).MemoryDatastore,m=r(41),b=r(388),v=r(767),_=r(772),w=r(94).ethAccountSnapshot,S=r(94).ethBlock,k=r(94).ethBlockList,E=r(94).ethStateTrie,A=r(94).ethStorageTrie,x=r(94).ethTx,I=r(94).ethTxTrie,T=r(860),B=r(861);function C(){}class P{constructor(e){if(!e)throw new Error("Missing blockservice");this.bs=e,this.resolvers={},this.support={},this.support.add=((e,t,r)=>{if(this.resolvers[e])throw new Error('Resolver already exists for codec "'+e+'"');this.resolvers[e]={resolver:t,util:r}}),this.support.rm=(e=>{this.resolvers[e]&&delete this.resolvers[e]}),this.support.add(m.resolver.multicodec,m.resolver,m.util),this.support.add(b.resolver.multicodec,b.resolver,b.util),this.support.add(v.resolver.multicodec,v.resolver,v.util),this.support.add(_.resolver.multicodec,_.resolver,_.util),this.support.add(w.resolver.multicodec,w.resolver,w.util),this.support.add(S.resolver.multicodec,S.resolver,S.util),this.support.add(k.resolver.multicodec,k.resolver,k.util),this.support.add(E.resolver.multicodec,E.resolver,E.util),this.support.add(A.resolver.multicodec,A.resolver,A.util),this.support.add(x.resolver.multicodec,x.resolver,x.util),this.support.add(I.resolver.multicodec,I.resolver,I.util),this.support.add(T.resolver.multicodec,T.resolver,T.util),this.support.add(B.resolver.multicodec,B.resolver,B.util)}get(e,t,r,n){if("function"==typeof t&&(n=t,t=void 0),"function"==typeof r&&(n=r,r={}),"string"==typeof t&&(t=c("/",t).substr(1).split(f).join("/")),""===t||!t)return this._get(e,(e,t)=>{if(e)return n(e);n(null,{value:t,remainderPath:""})});let i;s(r=>{this.bs.get(e,(n,o)=>{if(n)return r(n);const s=this.resolvers[e.codec];if(!s)return r(new Error('No resolver found for codec "'+e.codec+'"'));s.resolver.resolve(o.data,t,(e,n)=>{if(e)return r(e);i=n.value,t=n.remainderPath,r()})})},()=>{const n=!t||""===t||"/"===t,s=i&&!i["/"];return!!(n&&s||r.localResolve)||(i&&(e=new o(i["/"])),!1)},(e,r)=>e?n(e):n(null,{value:i,remainderPath:t}))}getStream(e,t,r){const n=l();return this.get(e,t,r,(e,t)=>{if(e)return n.resolve(i.error(e));n.resolve(i.values([t]))}),n}put(e,t,r){if("function"==typeof t)return r=t,setImmediate(()=>r(new Error("IPLDResolver.put requires options")));if(r=r||C,t.cid&&o.isCID(t.cid))return this._put(t.cid,e,r);const n=this.resolvers[t.format];if(!n)return r(new Error('No resolver found for codec "'+t.format+'"'));n.util.cid(e,t,(t,n)=>{if(t)return r(t);this._put(n,e,r)})}treeStream(e,t,r){let n;if("object"==typeof t&&(r=t,t=void 0),!(r=r||{}).recursive){n=l();const t=this.resolvers[e.codec];if(!t)return n.abort(new Error('No resolver found for codec "'+e.codec+'"')),n;y([t=>this.bs.get(e,t),(e,r)=>t.resolver.tree(e.data,r)],(e,t)=>{if(e)return n.abort(e),n;n.resolve(i.values(t))})}return r.recursive&&(n=i(h.widthFirst({basePath:null,cid:e},e=>{if("string"==typeof e)return i.empty();const t=l(),r=e.cid,n=this.resolvers[r.codec];return n?(y([t=>this.bs.get(e.cid,t),(e,t)=>n.resolver.tree(e.data,(r,i)=>{if(r)return t(r);p(i,(t,r)=>{n.resolver.isLink(e.data,t,(e,n)=>{if(e)return r(e);r(null,{path:t,link:n})})},t)})],(r,n)=>{if(r)return t.abort(r),t;t.resolve(i.values(n.map(t=>{const r=e.basePath?e.basePath+"/"+t.path:t.path;return t.link?{basePath:r,cid:new o(t.link["/"])}:r})))}),t):(t.abort(new Error('No resolver found for codec "'+r.codec+'"')),t)}),i.map(e=>"string"==typeof e?e:e.basePath),i.filter(Boolean))),t?i(n,i.map(e=>{if(0===e.indexOf(t))return e.slice(t.length+1)}),i.filter(Boolean)):n}remove(e,t){this.bs.delete(e,t)}_get(e,t){const r=this.resolvers[e.codec];if(!r)return t(new Error('No resolver found for codec "'+e.codec+'"'));y([t=>this.bs.get(e,t),(e,t)=>{r?r.util.deserialize(e.data,(e,r)=>{if(e)return t(e);t(null,r)}):t(null,e.data)}],t)}_put(e,t,r){r=r||C;const i=this.resolvers[e.codec];if(!i)return r(new Error('No resolver found for codec "'+e.codec+'"'));y([e=>i.util.serialize(t,e),(t,r)=>this.bs.put(new n(t,e),r)],t=>{if(t)return r(t);r(null,e)})}}P.inMemory=function(e){const t=new a("in-memory",{storageBackends:{root:g,blocks:g,datastore:g},lock:"memory"}),r=new u(t);d([e=>t.init({},e),e=>t.open(e)],t=>{if(t)return e(t);e(null,new P(r))})},e.exports=P},function(e,t){e.exports=function e(t,o,s){o=o||[];for(var a=s=s||0;t>=i;)o[s++]=255&t|r,t/=128;for(;t&n;)o[s++]=255&t|r,t>>>=7;return o[s]=0|t,e.bytes=s-a+1,o};var r=128,n=-128,i=Math.pow(2,31)},function(e,t){e.exports=function e(t,i){var o,s=0,a=0,u=i=i||0,c=t.length;do{if(u>=c)throw e.bytes=0,new RangeError("Could not decode varint");o=t[u++],s+=a<28?(o&n)<=r);return e.bytes=u-i,s};var r=128,n=127},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),u=Math.pow(2,49),c=Math.pow(2,56),f=Math.pow(2,63);e.exports=function(e){return e(e[t[0]]=new n(t[0],t[1],t[2],t[3]),e),{}),f=u.reduce((e,t)=>(e[t[1]]=c[t[0]],e),{});e.exports={names:c,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";(function(t){e.exports=function(e){return{encode:e=>"string"==typeof e?t.from(e).toString("hex"):e.toString("hex"),decode(r){for(let t of r)if(e.indexOf(t)<0)throw new Error("invalid base16 character");return t.from(r,"hex")}}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){e.exports=function(e){return{encode:r=>(function(e,t){let r=e.byteLength,n=new Uint8Array(e),i=t.indexOf("=")===t.length-1;i&&(t=t.substring(0,t.length-2));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})("string"==typeof r?t.from(r):r,e),decode(t){for(let r of t)if(e.indexOf(r)<0)throw new Error("invalid base32 character");return function(e,t){let r=(e=e.replace(new RegExp("=","g"),"")).length,n=0,i=0,o=0,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)}}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){e.exports=function(e){const r=e.indexOf("=")>-1,n=e.indexOf("-")>-1&&e.indexOf("_")>-1;return{encode(e){let i="";i="string"==typeof e?t.from(e).toString("base64"):e.toString("base64"),n&&(i=(i=i.replace("+","-")).replace("/","_"));const o=i.indexOf("=");return o>0&&!r&&(i=i.substring(0,o)),i},decode(r){n&&(r=(r=r.replace("+","-")).replace("/","_"));for(let t of r)if(e.indexOf(t)<0)throw new Error("invalid base64 character");return t.from(r,"base64")}}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(n){const i=r(20),o=r(340),s=r(342),a=r(341);(t=e.exports).addPrefix=((e,t)=>{let r;if(n.isBuffer(e))r=a.varintBufferEncode(e);else{if(!o[e])throw new Error("multicodec not recognized");r=o[e]}return n.concat([r,t])}),t.rmPrefix=(e=>(i.decode(e),e.slice(i.decode.bytes))),t.getCodec=(e=>{const t=a.varintBufferDecode(e),r=s[t.toString("hex")];if(void 0===r)throw new Error("Code `0x"+t.toString("hex")+"` not found");return r}),t.getCodeVarint=(e=>{const t=o[e];if(void 0===t)throw new Error("Codec `"+e+"` not found");return t}),t.addCodec=((e,t)=>{o[e]=a.varintBufferEncode(t),s[t.toString("hex")]=e})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(12);var i={checkCIDComponents:function(e){if(null==e)return"null values are not valid CIDs";if(0!==e.version&&1!==e.version)return"Invalid version, must be a number equal to 1 or 0";if("string"!=typeof e.codec)return"codec must be string";if(!t.isBuffer(e.multihash))return"multihash must be a Buffer";try{n.validate(e.multihash)}catch(e){let t=e.message;return t||(t="Multihash validation failed"),t}}};e.exports=i}).call(this,r(0).Buffer)},function(e,t,r){"use strict";e.exports={keys:r(649),once:r(344),values:r(86),count:r(650),infinite:r(651),empty:r(652),error:r(653)}},function(e,t,r){"use strict";var n=r(86);e.exports=function(e){return n(Object.keys(e))}},function(e,t,r){"use strict";e.exports=function(e){var t=0;return e=e||1/0,function(r,n){return r?n&&n(r):t>e?n(!0):void n(null,t++)}}},function(e,t,r){"use strict";e.exports=function(e){return e=e||Math.random,function(t,r){return t?r&&r(t):r(null,e())}}},function(e,t,r){"use strict";e.exports=function(){return function(e,t){t(!0)}}},function(e,t,r){"use strict";e.exports=function(e){return function(t,r){r(e)}}},function(e,t,r){"use strict";e.exports={drain:r(118),onEnd:r(655),log:r(656),find:r(657),reduce:r(213),collect:r(87),concat:r(658)}},function(e,t,r){"use strict";var n=r(118);e.exports=function(e){return n(null,e)}},function(e,t,r){"use strict";var n=r(118);e.exports=function(e){return n(function(e){console.log(e)},e)}},function(e,t,r){"use strict";function n(e){return e}var i=r(119),o=r(118);e.exports=function(e,t){var r=!1;return t?e=i(e)||n:(t=e,e=n),o(function(n){if(e(n))return r=!0,t(null,n),!1},function(e){r||t(!0===e?null:e,null)})}},function(e,t,r){"use strict";var n=r(213);e.exports=function(e){return n(function(e,t){return e+t},"",e)}},function(e,t,r){"use strict";e.exports={map:r(345),asyncMap:r(153),filter:r(120),filterNot:r(660),through:r(347),take:r(661),unique:r(348),nonUnique:r(662),flatten:r(663)}},function(e,t,r){"use strict";var n=r(346),i=r(120);e.exports=function(e){return e=n(e),i(function(t){return!e(t)})}},function(e,t,r){"use strict";e.exports=function(e,t){var r=(t=t||{}).last||!1,n=!1;if("number"==typeof e){r=!0;var i=e;e=function(){return--i}}return function(t){function i(e){t(!0,function(t){r=!1,e(t||!0)})}return function(o,s){n&&!o?r?i(s):s(n):(n=o)?t(n,s):t(null,function(t,o){(n=n||t)?s(n):e(o)?s(null,o):(n=!0,r?s(null,o):i(s))})}}}},function(e,t,r){"use strict";var n=r(348);e.exports=function(e){return n(e,!0)}},function(e,t,r){"use strict";var n=r(86),i=r(344);e.exports=function(){return function(e){var t;return function(r,o){function s(){t(null,function(t,r){!0===t?a():t?e(!0,function(e){o(t)}):o(null,r)})}function a(){t=null,e(null,function(e,r){if(e)return o(e);Array.isArray(r)||r&&"object"==typeof r?r=n(r):"function"!=typeof r&&(r=i(r)),t=r,s()})}r?t?t(r,function(t){e(t||r,o)}):e(r,o):t?s():a()}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){(0,n.default)(e,function(){return!t.apply(this,arguments)},r)};var n=function(e){return e&&e.__esModule?e:{default:e}}(r(349));e.exports=t.default},function(e,t,r){var n=r(158),i=Object.prototype,o=i.hasOwnProperty,s=i.toString,a=n?n.toStringTag:void 0;e.exports=function(e){var t=o.call(e,a),r=e[a];try{e[a]=void 0;var n=!0}catch(e){}var i=s.call(e);return n&&(t?e[a]=r:delete e[a]),i}},function(e,t){var r=Object.prototype.toString;e.exports=function(e){return r.call(e)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){if((0,n.default)(e))return function(e){var t=-1,r=e.length;return function(){return++t({exists(t){e.has(o,t)},get(t){e.get(o,(e,r)=>{if(e)return t(e);t(null,parseInt(r.toString().trim(),10))})},set(r,n){e.put(o,t.from(String(r)),n)},check(e,t){this.get((r,n)=>r?t(r):(i("comparing version: %s and %s",n,e),n!==e?t(new Error(`version mismatch: expected v${e}, found v${n}`)):void t()))}}))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(8),i=r(3),o=r(222).asyncFilter,s=r(222).asyncSort,a=r(362);e.exports=class{constructor(){this.data={}}open(e){i(e)}put(e,t,r){this.data[e.toString()]=t,i(r)}get(e,t){this.has(e,(r,n)=>r?t(r):n?void t(null,this.data[e.toString()]):t(new Error("No value")))}has(e,t){i(()=>{t(null,void 0!==this.data[e.toString()])})}delete(e,t){delete this.data[e.toString()],i(()=>{t()})}batch(){let e=[],t=[];return{put(t,r){e.push([t,r])},delete(e){t.push(e)},commit:r=>{e.forEach(e=>{this.data[e[0].toString()]=e[1]}),e=[],t.forEach(e=>{delete this.data[e.toString()]}),t=[],i(r)}}}query(e){let t=[n.keys(this.data),n.map(e=>({key:new a(e),value:this.data[e]}))],r=[];if(null!=e.prefix){const t=e.prefix;r.push((e,r)=>r(null,e.key.toString().startsWith(t)))}if(null!=e.filters&&(r=r.concat(e.filters)),t=t.concat(r.map(e=>o(e))),null!=e.orders&&(t=t.concat(e.orders.map(e=>s(e)))),null!=e.offset){let r=0;t.push(n.filter(()=>r++>=e.offset))}return null!=e.limit&&t.push(n.take(e.limit)),!0===e.keysOnly&&t.push(n.map(e=>({key:e.key}))),n.apply(null,t)}close(e){i(e)}}},function(e,t,r){"use strict";const n=r(35).Key,i=r(162),o=r(5),s=r(693),a=r(694),u=r(695),c=r(2).Buffer,f=new n("config");e.exports=(e=>{const t=i(function(e,t){const i=e.key,s=e.value;i?o([e=>r.get(e),(e,t)=>t(null,a(e,i,s)),n],t):n(s,t)},1),r={get(t,r){"function"==typeof t&&(r=t,t=void 0),t||(t=void 0),e.get(f,(e,n)=>{if(e)return r(e);let i;try{i=JSON.parse(n.toString())}catch(e){return r(e)}if(void 0!==t&&!u(i,t))return r(new Error("Key "+t+" does not exist in config"));let o=void 0!==t?s(i,t):i;r(null,o)})},set(e,r,n){if("function"==typeof r)n=r,r=e,e=void 0;else if(!e||"string"!=typeof e)return n(new Error("Invalid key type"));if(void 0===r||c.isBuffer(r))return n(new Error("Invalid value type"));t.push({key:e,value:r},n)},exists(t){e.has(f,t)}};return r;function n(t,r){const n=c.from(JSON.stringify(t,null,2));e.put(f,n,r)}})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){if(null==t)t=1;else if(0===t)throw new Error("Concurrency must not be zero");var f=(0,c.default)(e),l=0,h=[],p=!1;function d(e,t,r){if(null!=r&&"function"!=typeof r)throw new Error("task callback must be a function");if(m.started=!0,(0,i.default)(e)||(e=[e]),0===e.length&&m.idle())return(0,a.default)(function(){m.drain()});for(var n=0,s=e.length;n0&&h.splice(s,1),o.callback.apply(o,arguments),null!=t&&m.error(t,o.data)}l<=m.concurrency-m.buffer&&m.unsaturated(),m.idle()&&m.drain(),m.process()}}var g=!1,m={_tasks:new u.default,concurrency:t,payload:r,saturated:o.default,unsaturated:o.default,buffer:t/4,empty:o.default,drain:o.default,error:o.default,started:!1,paused:!1,push:function(e,t){d(e,!1,t)},kill:function(){m.drain=o.default,m._tasks.empty()},unshift:function(e,t){d(e,!0,t)},remove:function(e){m._tasks.remove(e)},process:function(){if(!g){for(g=!0;!m.paused&&l-1},N.prototype.set=function(e,t){var r=this.__data__,n=j(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},L.prototype.clear=function(){this.__data__={hash:new R,map:new(B||N),string:new R}},L.prototype.delete=function(e){return D(this,e).delete(e)},L.prototype.get=function(e){return D(this,e).get(e)},L.prototype.has=function(e){return D(this,e).has(e)},L.prototype.set=function(e,t){return D(this,e).set(e,t),this};var F=H(function(e){e=function(e){return null==e?"":function(e){if("string"==typeof e)return e;if(W(e))return O?O.call(e):"";var t=e+"";return"0"==t&&1/e==-i?"-0":t}(e)}(e);var t=[];return f.test(e)&&t.push(""),e.replace(l,function(e,r,n,i){t.push(n?i.replace(h,"$1"):r||e)}),t});function q(e){if("string"==typeof e||W(e))return e;var t=e+"";return"0"==t&&1/e==-i?"-0":t}function H(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError(r);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var s=e.apply(this,r);return n.cache=o.set(i,s),s};return n.cache=new(H.Cache||L),n}function z(e,t){return e===t||e!=e&&t!=t}H.Cache=L;var V=Array.isArray;function G(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function W(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&A.call(e)==a}e.exports=function(e,t,r){var n=null==e?void 0:M(e,t);return void 0===n?r:n}}).call(this,r(7))},function(e,t,r){(function(t){var r="Expected a function",n="__lodash_hash_undefined__",i=1/0,o=9007199254740991,s="[object Function]",a="[object GeneratorFunction]",u="[object Symbol]",c=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,f=/^\w*$/,l=/^\./,h=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,p=/\\(\\)?/g,d=/^\[object .+?Constructor\]$/,y=/^(?:0|[1-9]\d*)$/,g="object"==typeof t&&t&&t.Object===Object&&t,m="object"==typeof self&&self&&self.Object===Object&&self,b=g||m||Function("return this")();var v,_=Array.prototype,w=Function.prototype,S=Object.prototype,k=b["__core-js_shared__"],E=(v=/[^.]+$/.exec(k&&k.keys&&k.keys.IE_PROTO||""))?"Symbol(src)_1."+v:"",A=w.toString,x=S.hasOwnProperty,I=S.toString,T=RegExp("^"+A.call(x).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),B=b.Symbol,C=_.splice,P=H(b,"Map"),O=H(Object,"create"),R=B?B.prototype:void 0,N=R?R.toString:void 0;function L(e){var t=-1,r=e?e.length:0;for(this.clear();++t-1&&e%1==0&&e-1},j.prototype.set=function(e,t){var r=this.__data__,n=D(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},M.prototype.clear=function(){this.__data__={hash:new L,map:new(P||j),string:new L}},M.prototype.delete=function(e){return q(this,e).delete(e)},M.prototype.get=function(e){return q(this,e).get(e)},M.prototype.has=function(e){return q(this,e).has(e)},M.prototype.set=function(e,t){return q(this,e).set(e,t),this};var G=$(function(e){e=function(e){return null==e?"":function(e){if("string"==typeof e)return e;if(Z(e))return N?N.call(e):"";var t=e+"";return"0"==t&&1/e==-i?"-0":t}(e)}(e);var t=[];return l.test(e)&&t.push(""),e.replace(h,function(e,r,n,i){t.push(n?i.replace(p,"$1"):r||e)}),t});function W(e){if("string"==typeof e||Z(e))return e;var t=e+"";return"0"==t&&1/e==-i?"-0":t}function $(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError(r);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var s=e.apply(this,r);return n.cache=o.set(i,s),s};return n.cache=new($.Cache||M),n}function Y(e,t){return e===t||e!=e&&t!=t}$.Cache=M;var J=Array.isArray;function X(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Z(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&I.call(e)==u}e.exports=function(e,t,r){return null==e?e:F(e,t,r)}}).call(this,r(7))},function(e,t,r){(function(t){var r="Expected a function",n="__lodash_hash_undefined__",i=1/0,o=9007199254740991,s="[object Arguments]",a="[object Function]",u="[object GeneratorFunction]",c="[object Symbol]",f=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,l=/^\w*$/,h=/^\./,p=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,d=/\\(\\)?/g,y=/^\[object .+?Constructor\]$/,g=/^(?:0|[1-9]\d*)$/,m="object"==typeof t&&t&&t.Object===Object&&t,b="object"==typeof self&&self&&self.Object===Object&&self,v=m||b||Function("return this")();var _,w=Array.prototype,S=Function.prototype,k=Object.prototype,E=v["__core-js_shared__"],A=(_=/[^.]+$/.exec(E&&E.keys&&E.keys.IE_PROTO||""))?"Symbol(src)_1."+_:"",x=S.toString,I=k.hasOwnProperty,T=k.toString,B=RegExp("^"+x.call(I).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),C=v.Symbol,P=k.propertyIsEnumerable,O=w.splice,R=z(v,"Map"),N=z(Object,"create"),L=C?C.prototype:void 0,j=L?L.toString:void 0;function M(e){var t=-1,r=e?e.length:0;for(this.clear();++t-1&&e%1==0&&e-1},K.prototype.set=function(e,t){var r=this.__data__,n=U(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},D.prototype.clear=function(){this.__data__={hash:new M,map:new(R||K),string:new M}},D.prototype.delete=function(e){return H(this,e).delete(e)},D.prototype.get=function(e){return H(this,e).get(e)},D.prototype.has=function(e){return H(this,e).has(e)},D.prototype.set=function(e,t){return H(this,e).set(e,t),this};var W=Y(function(e){e=function(e){return null==e?"":function(e){if("string"==typeof e)return e;if(ne(e))return j?j.call(e):"";var t=e+"";return"0"==t&&1/e==-i?"-0":t}(e)}(e);var t=[];return h.test(e)&&t.push(""),e.replace(p,function(e,r,n,i){t.push(n?i.replace(d,"$1"):r||e)}),t});function $(e){if("string"==typeof e||ne(e))return e;var t=e+"";return"0"==t&&1/e==-i?"-0":t}function Y(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError(r);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var s=e.apply(this,r);return n.cache=o.set(i,s),s};return n.cache=new(Y.Cache||D),n}function J(e,t){return e===t||e!=e&&t!=t}function X(e){return function(e){return re(e)&&function(e){return null!=e&&ee(e.length)&&!Q(e)}(e)}(e)&&I.call(e,"callee")&&(!P.call(e,"callee")||T.call(e)==s)}Y.Cache=D;var Z=Array.isArray;function Q(e){var t=te(e)?T.call(e):"";return t==a||t==u}function ee(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=o}function te(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function re(e){return!!e&&"object"==typeof e}function ne(e){return"symbol"==typeof e||re(e)&&T.call(e)==c}e.exports=function(e,t){return null!=e&&V(e,t,F)}}).call(this,r(7))},function(e,t,r){"use strict";const n=r(35).Key,i=r(2).Buffer,o=new n("api");e.exports=(e=>({get(t){e.get(o,(e,r)=>t(e,r&&r.toString()))},set(t,r){e.put(o,i.from(t.toString()),r)},delete(t){e.delete(o,t)}}))},function(e,t,r){"use strict";const n=r(698),i=n.ShardingDatastore,o=r(35).Key,s=r(705),a=r(151),u=r(3),c=r(368),f=r(9),l=r(8),h=e=>(e=>{const t=new s.Encoder;return new o("/"+t.write(e).finalize(),!1)})(e.buffer);e.exports=((e,t,r)=>{!function(e,t,r){if(t.sharding){const t=new n.shard.NextToLast(2);i.createOrOpen(e,t,r)}else u(()=>r(null,e))}(e,t,(e,t)=>{if(e)return r(e);r(null,function(e){return{query(t,r){l(e.query(t),l.collect(r))},get(t,r){if(!f.isCID(t))return u(()=>{r(new Error("Not a valid cid"))});const n=h(t);e.get(n,(e,n)=>{if(e)return r(e);r(null,new a(n,t))})},put(t,r){if(!a.isBlock(t))return u(()=>{r(new Error("invalid block"))});const n=h(t.cid);e.has(n,(i,o)=>i?r(i):o?r():void e.put(n,t.data,r))},putMany(t,r){const n=t.map(e=>({key:h(e.cid),block:e})),i=e.batch();c(n,(t,r)=>e.has(t.key,r),(e,t)=>{if(e)return r(e);t.forEach(e=>{i.put(e.key,e.block.data)}),i.commit(r)})},has(t,r){if(!f.isCID(t))return u(()=>{r(new Error("Not a valid cid"))});e.has(h(t),r)},delete(t,r){if(!f.isCID(t))return u(()=>{r(new Error("Not a valid cid"))});e.delete(h(t),r)},close(t){e.close(t)}}}(t))})})},function(e,t,r){"use strict";const n=r(163),i=r(699),o=r(701),s=r(703),a=r(704),u=r(366);t.KeytransformDatastore=n,t.ShardingDatastore=i,t.MountDatastore=o,t.TieredDatastore=s,t.NamespaceDatastore=a,t.shard=u},function(e,t,r){"use strict";(function(t){const n=r(5),i=r(59),o=r(35).Key,s=r(366),a=r(163),u=new o(s.SHARDING_FN),c=new o(s.README_FN);class f{constructor(e,t){this.child=new a(e,{convert:this._convertKey.bind(this),invert:this._invertKey.bind(this)}),this.shard=t}open(e){this.child.open(e)}_convertKey(e){const t=e.toString();return t===u.toString()||t===c.toString()?e:new o(this.shard.fun(t)).child(e)}_invertKey(e){const t=e.toString();return t===u.toString()||t===c.toString()?e:o.withNamespaces(e.list().slice(1))}static createOrOpen(e,t,r){f.create(e,t,t=>{if(t&&"datastore exists"!==t.message)return r(t);f.open(e,r)})}static open(e,t){n([t=>s.readShardFun("/",e,t),(t,r)=>{r(null,new f(e,t))}],t)}static create(e,r,n){e.has(u,(o,a)=>{if(o)return n(o);if(!a){const o="function"==typeof e.putRaw?e.putRaw.bind(e):e.put.bind(e);return i([e=>o(u,t.from(r.toString()+"\n"),e),e=>o(c,t.from(s.readme),e)],e=>n(e))}s.readShardFun("/",e,(e,t)=>{if(e)return n(e);const i=(t||"").toString(),o=r.toString();if(i!==o)return n(new Error(`specified fun ${o} does not match repo shard fun ${i}`));n(new Error("datastore exists"))})})}put(e,t,r){this.child.put(e,t,r)}get(e,t){this.child.get(e,t)}has(e,t){this.child.has(e,t)}delete(e,t){this.child.delete(e,t)}batch(){return this.child.batch()}query(e){const t={keysOnly:e.keysOnly,offset:e.offset,limit:e.limit,filters:[(e,t)=>t(null,e.key.toString()!==u.toString()),(e,t)=>t(null,e.key.toString()!==c.toString())]};if(null!=e.prefix&&t.filters.push((t,r)=>{r(null,this._invertKey(t.key).toString().startsWith(e.prefix))}),null!=e.filters){const r=e.filters.map(e=>(t,r)=>{e(Object.assign({},t,{key:this._invertKey(t.key)}),r)});t.filters=t.filters.concat(r)}return null!=e.orders&&(t.orders=e.orders.map(e=>(t,r)=>{t.forEach(e=>{e.key=this._invertKey(e.key)}),e(t,(e,t)=>{if(e)return r(e);t.forEach(e=>{e.key=this._convertKey(e.key)}),r(null,t)})})),this.child.query(t)}close(e){this.child.close(e)}}e.exports=f}).call(this,r(0).Buffer)},function(e,t,r){"use strict";e.exports="This is a repository of IPLD objects. Each IPLD object is in a single file,\nnamed .data. Where is the\n\"base32\" encoding of the CID (as specified in\nhttps://github.com/multiformats/multibase) without the 'B' prefix.\nAll the object files are placed in a tree of directories, based on a\nfunction of the CID. This is a form of sharding similar to\nthe objects directory in git repositories. Previously, we used\nprefixes, we now use the next-to-last two charters.\n func NextToLast(base32cid string) {\n nextToLastLen := 2\n offset := len(base32cid) - nextToLastLen - 1\n return str[offset : offset+nextToLastLen]\n }\nFor example, an object with a base58 CIDv1 of\n zb2rhYSxw4ZjuzgCnWSt19Q94ERaeFhu9uSqRgjSdx9bsgM6f\nhas a base32 CIDv1 of\n BAFKREIA22FLID5AJ2KU7URG47MDLROZIH6YF2KALU2PWEFPVI37YLKRSCA\nand will be placed at\n SC/AFKREIA22FLID5AJ2KU7URG47MDLROZIH6YF2KALU2PWEFPVI37YLKRSCA.data\nwith 'SC' being the last-to-next two characters and the 'B' at the\nbeginning of the CIDv1 string is the multibase prefix that is not\nstored in the filename.\n"},function(e,t,r){"use strict";const n=r(50),i=r(702),o=r(8),s=r(35).Key,a=r(35).utils,u=a.asyncFilter,c=a.asyncSort,f=a.replaceStartWith,l=r(163);e.exports=class{constructor(e){this.mounts=e.slice()}open(e){n(this.mounts,(e,t)=>{e.datastore.open(t)},e)}_lookup(e){for(let t of this.mounts)if(t.prefix.toString()===e.toString()||t.prefix.isAncestorOf(e)){const r=f(e.toString(),t.prefix.toString());return{datastore:t.datastore,mountpoint:t.prefix,rest:new s(r)}}}put(e,t,r){const n=this._lookup(e);null!=n?n.datastore.put(n.rest,t,r):r(new Error("No datastore mounted for this key"))}get(e,t){const r=this._lookup(e);null!=r?r.datastore.get(r.rest,t):t(new Error("No datastore mounted for this key"))}has(e,t){const r=this._lookup(e);null!=r?r.datastore.has(r.rest,t):t(null,!1)}delete(e,t){const r=this._lookup(e);null!=r?r.datastore.delete(r.rest,t):t(new Error("No datastore mounted for this key"))}close(e){n(this.mounts,(e,t)=>{e.datastore.close(t)},e)}batch(){const e={},t=t=>{const r=this._lookup(t);if(null==r)throw new Error("No datastore mounted for this key");const n=r.mountpoint.toString();return null==e[n]&&(e[n]=r.datastore.batch()),{batch:e[n],rest:r.rest}};return{put:(e,r)=>{const n=t(e);n.batch.put(n.rest,r)},delete:e=>{const r=t(e);r.batch.delete(r.rest)},commit:t=>{n(Object.keys(e),(t,r)=>{e[t].commit(r)},t)}}}query(e){const t=this.mounts.map(t=>{const r=new l(t.datastore,{convert:e=>{throw new Error("should never be called")},invert:e=>t.prefix.child(e)});let n;return null!=e.prefix&&(n=f(e.prefix,t.prefix.toString())),r.query({prefix:n,filters:e.filters,keysOnly:e.keysOnly})});let r=[i(t)];if(null!=e.filters&&(r=r.concat(e.filters.map(e=>u(e)))),null!=e.orders&&(r=r.concat(e.orders.map(e=>c(e)))),null!=e.offset){let t=0;r.push(o.filter(()=>t++>=e.offset))}return null!=e.limit&&r.push(o.take(e.limit)),o.apply(null,r)}}},function(e,t){e.exports=function(e){var t,r,n=!!e,i=(e||[]).map(s),o=0;function s(e){return{ready:!1,reading:!1,ended:!1,read:e,data:null}}function a(){if(r){!function(){for(var e=i.length;e--;)i[e].ended&&i.splice(e,1)}();var e=i.length,s=r;if(0===e&&(t||n))return r=null,void s(t||!0);for(var a=0;ai.length)throw new Error("this should never happen");if(!(r.reading||r.ended||r.ready)){r.reading=!0;var n=!0;r.read(t,function e(i,o){r.data=o,r.ready=!0,r.reading=!1,!0===i||t?r.ended=!0:i&&(t=r.ended=i),t&&!i&&r.read(t,e),n||a()}),n=!1}}(i[e]);a()}function c(e,n){t=t||e,r=n,u()}return c.add=function(e){if(!e)return n=!0,u();i.push(s(e)),u()},c.cap=function(e){c.add(null)},c}},function(e,t,r){"use strict";const n=r(50),i=r(40);e.exports=class{constructor(e){this.stores=e.slice()}open(e){n(this.stores,(e,t)=>{e.open(t)},e)}put(e,t,r){n(this.stores,(r,n)=>{r.put(e,t,n)},r)}get(e,t){const r=this.stores.length;let n=!1,o=0;i(()=>!n&&o{this.stores[o++].get(e,(e,r)=>{if(null==e)return n=!0,t(null,r);t()})},t)}has(e,t){const r=this.stores.length;let n=!1,o=0;i(()=>!n&&o{this.stores[o++].has(e,(e,r)=>{if(null==e)return n=!0,t(null,r);t()})},t)}delete(e,t){n(this.stores,(t,r)=>{t.delete(e,r)},t)}close(e){n(this.stores,(e,t)=>{e.close(t)},e)}batch(){const e=this.stores.map(e=>e.batch());return{put:(t,r)=>{e.forEach(e=>e.put(t,r))},delete:t=>{e.forEach(e=>e.delete(t))},commit:t=>{n(e,(e,t)=>{e.commit(t)},t)}}}query(e){return this.stores[this.stores.length-1].query(e)}}},function(e,t,r){"use strict";const n=r(35).Key,i=r(163);e.exports=class extends i{constructor(e,t){super(e,{convert:e=>t.child(e),invert(e){if("/"===t.toString())return e;if(!t.isAncestorOf(e))throw new Error(`Expected prefix: (${t.toString()}) in key: ${e.toString()}`);return new n(e.toString().slice(t.toString().length),!1)}}),this.prefix=t}query(e){return e.prefix&&"/"!==this.prefix.toString()?super.query(Object.assign({},e,{prefix:this.prefix.child(new n(e.prefix)).toString()})):super.query(e)}}},function(e,t,r){"use strict";var n=function(e,t){return t||(t={}),e.split("").forEach(function(e,r){e in t||(t[e]=r)}),t},i={alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",charmap:{0:14,1:8}};i.charmap=n(i.alphabet,i.charmap);var o={alphabet:"0123456789ABCDEFGHJKMNPQRSTVWXYZ",charmap:{O:0,I:1,L:1}};o.charmap=n(o.alphabet,o.charmap);var s={alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",charmap:{}};function a(e){if(this.buf=[],this.shift=8,this.carry=0,e){switch(e.type){case"rfc4648":this.charmap=t.rfc4648.charmap;break;case"crockford":this.charmap=t.crockford.charmap;break;case"base32hex":this.charmap=t.base32hex.charmap;break;default:throw new Error("invalid type")}e.charmap&&(this.charmap=e.charmap)}}function u(e){if(this.buf="",this.shift=3,this.carry=0,e){switch(e.type){case"rfc4648":this.alphabet=t.rfc4648.alphabet;break;case"crockford":this.alphabet=t.crockford.alphabet;break;case"base32hex":this.alphabet=t.base32hex.alphabet;break;default:throw new Error("invalid type")}e.alphabet?this.alphabet=e.alphabet:e.lc&&(this.alphabet=this.alphabet.toLowerCase())}}s.charmap=n(s.alphabet,s.charmap),a.prototype.charmap=i.charmap,a.prototype.write=function(e){var t=this.charmap,r=this.buf,n=this.shift,i=this.carry;return e.toUpperCase().split("").forEach(function(e){if("="!=e){var o=255&t[e];(n-=5)>0?i|=o<>-n),i=o<<(n+=8)&255):(r.push(i|o),n=8,i=0)}}),this.shift=n,this.carry=i,this},a.prototype.finalize=function(e){return e&&this.write(e),8!==this.shift&&0!==this.carry&&(this.buf.push(this.carry),this.shift=8,this.carry=0),this.buf},u.prototype.alphabet=i.alphabet,u.prototype.write=function(e){var t,r,n,i=this.shift,o=this.carry;for(n=0;n>i,this.buf+=this.alphabet[31&t],i>5&&(t=r>>(i-=5),this.buf+=this.alphabet[31&t]),o=r<<(i=5-i),i=8-i;return this.shift=i,this.carry=o,this},u.prototype.finalize=function(e){return e&&this.write(e),3!==this.shift&&(this.buf+=this.alphabet[31&this.carry],this.shift=3,this.carry=0),this.buf},t.encode=function(e,t){return new u(t).finalize(e)},t.decode=function(e,t){return new a(t).finalize(e)},t.Decoder=a,t.Encoder=u,t.charmap=n,t.crockford=o,t.rfc4648=i,t.base32hex=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,i){(0,n.default)(e,t,function(e,t){r(e,function(e,r){t(e,!r)})},i)};var n=function(e){return e&&e.__esModule?e:{default:e}}(r(707));e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,n){((0,i.default)(t)?function(e,t,r,n){var i=new Array(t.length);e(t,function(e,t,n){r(e,function(e,r){i[t]=!!r,n(e)})},function(e){if(e)return n(e);for(var r=[],o=0;o * https://github.com/rvagg/prr * License: MIT */ -var r;r=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)}},void 0!==e&&e.exports?e.exports=r():this.prr=r()},function(e,t,r){"use strict";var n=r(223).AbstractLevelDOWN,i=r(223).AbstractChainedBatch,o=r(223).AbstractIterator,s=r(5),a=r(26),u=r(729),c=r(731).EncodingError;function f(e,t){if(!(this instanceof f))return new f(e,t);n.call(this,""),void 0===(t=t||{}).keyEncoding&&(t.keyEncoding="utf8"),void 0===t.valueEncoding&&(t.valueEncoding="utf8"),this.db=e,this.codec=new u(t)}function l(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 h(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._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 h(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 l(this,e)},f.prototype._setupIteratorOptions=function(e){return(e=a(e)).reverse=!!e.reverse,e.keys=!1!==e.keys,e.values=!1!==e.values,e.limit="limit"in e?e.limit:-1,e.keyAsBuffer=!1!==e.keyAsBuffer,e.valueAsBuffer=!1!==e.valueAsBuffer,e},f.prototype.approximateSize=function(e,t,r,n){return this.db.approximateSize(e,t,r,n)},s(l,o),l.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)})},l.prototype._end=function(e){this.it.end(e)},s(h,i),h.prototype._put=function(e,t){e=this.codec.encodeKey(e),t=this.codec.encodeValue(t),this.batch.put(e,t)},h.prototype._del=function(e){e=this.codec.encodeKey(e),this.batch.del(e)},h.prototype._clear=function(){this.batch.clear()},h.prototype._write=function(e,t){this.batch.write(e,t)}},function(e,t,r){(function(t,n){var i=r(26),o=r(378),s=r(379),a=Object.prototype.hasOwnProperty,u="start end gt gte lt lte".split(" ");function c(e){if(!arguments.length||void 0===e)throw new Error("constructor requires at least a location argument");if("string"!=typeof e)throw new Error("constructor requires a location string argument");this.location=e,this.status="new"}function f(e){return-1!==u.indexOf(e)}function l(e){return""===e||null==e||function(e){return n.isBuffer(e)&&0===e.length}(e)}c.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&&(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()})},c.prototype._open=function(e,r){t.nextTick(r)},c.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()})},c.prototype._close=function(e){t.nextTick(e)},c.prototype.get=function(e,r,n){if("function"==typeof r&&(n=r),"function"!=typeof n)throw new Error("get() requires a callback argument");var i=this._checkKey(e,"key");if(i)return t.nextTick(n,i);e=this._serializeKey(e),"object"!=typeof r&&(r={}),r.asBuffer=!1!==r.asBuffer,this._get(e,r,n)},c.prototype._get=function(e,r,n){t.nextTick(function(){n(new Error("NotFound"))})},c.prototype.put=function(e,r,n,i){if("function"==typeof n&&(i=n),"function"!=typeof i)throw new Error("put() requires a callback argument");var o=this._checkKey(e,"key");if(o)return t.nextTick(i,o);e=this._serializeKey(e),r=this._serializeValue(r),"object"!=typeof n&&(n={}),this._put(e,r,n,i)},c.prototype._put=function(e,r,n,i){t.nextTick(i)},c.prototype.del=function(e,r,n){if("function"==typeof r&&(n=r),"function"!=typeof n)throw new Error("del() requires a callback argument");var i=this._checkKey(e,"key");if(i)return t.nextTick(n,i);e=this._serializeKey(e),"object"!=typeof r&&(r={}),this._del(e,r,n)},c.prototype._del=function(e,r,n){t.nextTick(n)},c.prototype.batch=function(e,r,n){if(!arguments.length)return this._chainedBatch();if("function"==typeof r&&(n=r),"function"==typeof e&&(n=e),"function"!=typeof n)throw new Error("batch(array) requires a callback argument");if(!Array.isArray(e))return t.nextTick(n,new Error("batch(array) requires an array argument"));r&&"object"==typeof r||(r={});for(var o=new Array(e.length),s=0;s-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){(function(e){function r(e){return e}function n(t){return void 0===t||null===t||e.isBuffer(t)}t.utf8=t["utf-8"]={encode:function(e){return n(e)?e:String(e)},decode:r,buffer:!1,type:"utf8"},t.json={encode:JSON.stringify,decode:JSON.parse,buffer:!1,type:"json"},t.binary={encode:function(t){return n(t)?t:e.from(t)},decode:r,buffer:!0,type:"binary"},t.none={encode:r,decode:r,buffer:!1,type:"id"},t.id=t.none,["hex","ascii","base64","ucs2","ucs-2","utf16le","utf-16le"].forEach(function(r){t[r]={encode:function(t){return n(t)?t:e.from(t,r)},decode:function(e){return e.toString(r)},buffer:!0,type:r}})}).call(this,r(0).Buffer)},function(e,t,r){var n=r(376).create,i=n("LevelUPError"),o=n("NotFoundError",i);o.prototype.notFound=!0,o.prototype.status=404,e.exports={LevelUPError:i,InitializationError:n("InitializationError",i),OpenError:n("OpenError",i),ReadError:n("ReadError",i),WriteError:n("WriteError",i),NotFoundError:o,EncodingError:n("EncodingError",i)}},function(e,t,r){(function(t,n){e.exports=u;var i=r(380).AbstractLevelDOWN,o=r(104),s=r(734),a=r(26);function u(e){if(!(this instanceof u))return new u(e);i.call(this,e)}o.inherits(u,i),u.prototype._open=function(e,t){var r=this;if(this._idbOpts=a({storeName:this.location,keyEncoding:"none",valueEncoding:"none"},e),this._idbOpts.idb)i(this._idbOpts.idb);else{var n=indexedDB.open(this.location);n.onerror=function(e){t(e.target.error)},n.onsuccess=function(){i(n.result)}}function i(n){r._db=n;var i=r._db.objectStoreNames.contains(r._idbOpts.storeName);if(e.errorIfExists&&i)return r._db.close(),void t(new Error("store already exists"));if(!e.createIfMissing&&!i)return r._db.close(),void t(new Error("store does not exist"));if(e.createIfMissing&&!i){r._db.close();var o=indexedDB.open(r.location,r._db.version+1);return o.onerror=function(e){t(e.target.error)},o.onupgradeneeded=function(){o.result.createObjectStore(r._idbOpts.storeName,r._idbOpts)},void(o.onsuccess=function(){r._db=o.result,t(null,r)})}t(null,r)}},u.prototype._get=function(e,r,n){var i=e;"binary"!==(r=a(this._idbOpts,r)).keyEncoding||Array.isArray(e)||(e=Array.prototype.slice.call(e));var o=this._db.transaction(this._idbOpts.storeName),s=o.objectStore(this._idbOpts.storeName).openCursor(IDBKeyRange.only(e));o.onabort=function(){n(o.error)},s.onsuccess=function(){var e=s.result;if(e){var o=e.value;if(o instanceof Uint8Array&&(o=new t(o)),"binary"!==r.valueEncoding||t.isBuffer(o)||(o=new t(o)),r.asBuffer&&!t.isBuffer(o))if(null==o)o=new t(0);else if("string"==typeof o)o=new t(o);else if("boolean"==typeof o)o=new t(String(o));else if("number"==typeof o)o=new t(String(o));else if(Array.isArray(o))o=new t(String(o));else{if(!(o instanceof Uint8Array))return void n(new TypeError("can't coerce `"+o.constructor.name+"` into a Buffer"));o=new t(o)}n(null,o,i)}else n(new Error("NotFound"))}},u.prototype._del=function(e,t,r){"binary"!==(t=a(this._idbOpts,t)).keyEncoding||Array.isArray(e)||(e=Array.prototype.slice.call(e));var n="readwrite";!0===t.sync&&(n="readwriteflush");var i=this._db.transaction(this._idbOpts.storeName,n);i.objectStore(this._idbOpts.storeName).delete(e);i.onabort=function(){r(i.error)},i.oncomplete=function(){r()}},u.prototype._put=function(e,t,r,n){"binary"!==(r=a(this._idbOpts,r)).keyEncoding||Array.isArray(e)||(e=Array.prototype.slice.call(e));var i="readwrite";!0===r.sync&&(i="readwriteflush");var o=this._db.transaction(this._idbOpts.storeName,i);o.objectStore(this._idbOpts.storeName).put(t,e);o.onabort=function(){n(o.error)},o.oncomplete=function(){n()}},u.prototype._iterator=function(e){return new s(this,e)},u.prototype._batch=function(e,t,r){if(0===e.length)return n.nextTick(r);var i="readwrite";!0===t.sync&&(i="readwriteflush");var o=this._db.transaction(this._idbOpts.storeName,i),s=o.objectStore(this._idbOpts.storeName);o.onabort=function(){r(o.error)},o.oncomplete=function(){r()},e.forEach(function(e){"binary"!==a(t,e).keyEncoding||Array.isArray(e.key)||(e.key=Array.prototype.slice.call(e.key)),"del"===e.type?s.delete(e.key):s.put(e.value,e.key)})},u.prototype._close=function(e){this._db.close(),n.nextTick(e)},u.prototype._approximateSize=function(e,t,r){var i=new Error("Not implemented");if(!r)throw i;n.nextTick(function(){r(i)})},u.destroy=function(e,t){var r;if(null!=e&&"object"==typeof e)r=a({location:e.location,storeName:e.location},e._idbOpts);else{if("string"!=typeof e)throw new TypeError("location must be a string or an object");r={location:e,storeName:e}}if("string"!=typeof r.location)throw new TypeError("location must be a string");if("string"!=typeof r.storeName)throw new TypeError("db.storeName must be a string");var n=indexedDB.open(r.location);n.onerror=function(e){t(e.target.error)},n.onsuccess=function(){var e=n.result;function i(e){var r=indexedDB.deleteDatabase(e);r.onerror=function(e){t(e.target.error)},r.onsuccess=function(){t()}}if(e.close(),0!==e.objectStoreNames.length)if(e.objectStoreNames.contains(r.storeName)){var o=indexedDB.open(r.location,e.version+1);o.onerror=function(e){t(e.target.error)},o.onupgradeneeded=function(){(e=o.result).deleteObjectStore(r.storeName)},o.onsuccess=function(){(e=o.result).close(),0===e.objectStoreNames.length?i(r.location):t()}}else t();else i(r.location)}}}).call(this,r(0).Buffer,r(7))},function(e,t,r){var n=r(381);e.exports=function(e){return!(!e||"object"!=typeof e)&&Object.keys(n.prototype).filter(function(e){return"_"!=e[0]&&"approximateSize"!=e}).every(function(t){return"function"==typeof e[t]})}},function(e,t,r){(function(t,n){var i=r(104),o=r(380).AbstractIterator,s=r(735),a=r(736),u=r(90),c=r(26),f=u.Writable;function l(e,t){if(this._db=e._db,this._idbOpts=e._idbOpts,o.call(this,e),this._options=c({snapshot:!0},this._idbOpts,t),this._limit=this._options.limit,null!=this._limit&&-1!==this._limit||(this._limit=1/0),"number"!=typeof this._limit)throw new TypeError("options.limit must be a number");0!==this._limit&&(this._count=0,this._startCursor(this._options))}e.exports=l,i.inherits(l,o),l.prototype._startCursor=function(e){e=c(this._options,e);var t=this,r=null,n=s.lowerBound(e),i=s.upperBound(e),o=s.lowerBoundExclusive(e),u=s.upperBoundExclusive(e),l=e.reverse?"prev":"next";if(n&&("binary"!==e.keyEncoding||Array.isArray(n)||(n=Array.prototype.slice.call(n))),i&&("binary"!==e.keyEncoding||Array.isArray(i)||(i=Array.prototype.slice.call(i))),n&&i)try{r=IDBKeyRange.bound(n,i,o,u)}catch(e){return void(this._keyRangeError=!0)}else n?r=IDBKeyRange.lowerBound(n,o):i&&(r=IDBKeyRange.upperBound(i,u));this._reader=a(this._db,this._idbOpts.storeName,c(e,{range:r,direction:l})),this._reader.on("error",function(e){var r=t._callback;t._callback=!1,r?r(e):t._readNext=function(t){t(e)}}),this._reader.pipe(new f({objectMode:!0,write:function(e,r,n){if(t._count++>=t._limit)return t._reader.pause(),t._reader.unpipe(this),n(),void this.end();var i=t._callback;t._callback=!1,i?t._processItem(e,function(e,t,r){n(e),i(e,t,r)}):t._readNext=function(r){t._processItem(e,function(e,t,i){n(e),r(e,t,i)})}}})).on("finish",function(){var e=t._callback;t._callback=!1,e?e():t._readNext=function(e){e()}})},l.prototype._processItem=function(e,r){if("function"!=typeof r)throw new TypeError("cb must be a function");var n=e.key,i=e.value;if(i instanceof Uint8Array&&(i=new t(i)),"binary"===this._options.keyEncoding&&Array.isArray(n)&&(n=new t(n)),"binary"!==this._options.valueEncoding||t.isBuffer(i)||(i=new t(i)),this._options.keyAsBuffer&&!t.isBuffer(n))if(null==n)n=new t(0);else if("string"==typeof n)n=new t(n);else if("boolean"==typeof n)n=new t(String(n));else if("number"==typeof n)n=new t(String(n));else if(Array.isArray(n))n=new t(String(n));else{if(!(n instanceof Uint8Array))throw new TypeError("can't coerce `"+n.constructor.name+"` into a Buffer");n=new t(n)}if(this._options.valueAsBuffer&&!t.isBuffer(i))if(null==i)i=new t(0);else if("string"==typeof i)i=new t(i);else if("boolean"==typeof i)i=new t(String(i));else if("number"==typeof i)i=new t(String(i));else if(Array.isArray(i))i=new t(String(i));else{if(!(i instanceof Uint8Array))throw new TypeError("can't coerce `"+i.constructor.name+"` into a Buffer");i=new t(i)}r(null,n,i)},l.prototype._next=function(e){if(this._callback)throw new Error("callback already exists");if(this._keyRangeError||0===this._limit)e();else{var t=this._readNext;this._readNext=!1,t?n.nextTick(function(){t(e)}):this._callback=e}}}).call(this,r(0).Buffer,r(7))},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")},u=t.upperBoundInclusive=function(e){return!n(e,"lt")},c=t.lowerBoundExclusive=function(e){return!a(e)},f=t.upperBoundExclusive=function(e){return!u(e)},l=t.upperBoundKey=function(e){return i(e,"lt")||i(e,"lte")||i(e,"max")||(e.reverse?i(e,"start"):i(e,"end"))||void 0},h=t.upperBound=function(e,t){var r=l(e);return r?e[r]:t};function p(e){return e}t.start=function(e,t){return e.reverse?h(e,t):s(e,t)},t.end=function(e,t){return e.reverse?s(e,t):h(e,t)},t.startInclusive=function(e){return e.reverse?u(e):a(e)},t.endInclusive=function(e){return e.reverse?a(e):u(e)},t.toLtgt=function(e,r,i,o,s){r=r||{},i=i||p;var a=arguments.length>3,u=t.lowerBoundKey(e),c=t.upperBoundKey(e);return u?"gt"===u?r.gt=i(e.gt,!1):r.gte=i(e[u],!1):a&&(r.gte=i(o,!1)),c?"lt"===c?r.lt=i(e.lt,!0):r.lte=i(e[c],!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&&c(e)))return!1;var a,u=h(e);return!r(u)||!((a=i(n,u))>0||0===a&&f(e))},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";var n=r(90),i=r(26);e.exports=function(e,t,r){if("object"!=typeof e)throw new TypeError("db must be an object");if("string"!=typeof t)throw new TypeError("storeName must be a string");if(null==r&&(r={}),"object"!=typeof r)throw new TypeError("opts must be an object");var o=new n.Transform(i(r,{objectMode:!0,transform:function(e,t,r){r(null,e)}}));r=i({snapshot:!1},r);var s=null;return o._cursorsOpened=0,function n(){var i,a,u,c,f,l=r.direction||"next",h=r.range||{};i=h.lower,a=h.upper,u=!!h.lowerOpen,c=!!h.upperOpen,s&&("next"===l?(u=!0,i=s):(c=!0,a=s)),i&&a?f=IDBKeyRange.bound(i,a,u,c):i?f=IDBKeyRange.lowerBound(i,u):a&&(f=IDBKeyRange.upperBound(a,c));var p=e.transaction(t,"readonly"),d=p.objectStore(t);o._cursorsOpened++;var y=d.openCursor(f,r.direction);function g(e){try{e.continue()}catch(e){"TransactionInactiveError"!==e.name||r.snapshot?o.emit("error",e):n()}}y.onsuccess=function(){var e=y.result;if(e){s=e.key;var t=o.write({key:e.key,value:e.value});r.snapshot||t?g(e):o.once("drain",function(){g(e)})}else o.end()},p.onabort=function(){o.emit("error",p.error)},p.onerror=function(){o.emit("error",p.error)}}(),o}},function(e,t,r){e.exports=r(210)},function(e,t,r){e.exports=r(85)},function(e,t,r){e.exports=r(22).Transform},function(e,t,r){e.exports=r(22).PassThrough},function(e,t,r){"use strict";t.ERR_REPO_NOT_INITIALIZED="ERR_REPO_NOT_INITIALIZED"},function(e,t,r){"use strict";e.exports={repoVersion:6}},function(e,t){e.exports=function(){var e,t,r,n,i;function o(o){return i?i(o):(e=o,function(e,i){t?t(e,i):(n=e,r=i)})}return o.resolve=function(o){if(i)throw new Error("already resolved");if(!(i=o))throw new Error("resolve *must* be passed a transform stream");e&&(t=i(e),r&&t(n,r))},o}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,o){o=o||n.default,t=t||[];var s=[],a=0,u=(0,i.default)(r);e(t,function(e,t,r){var n=a++;u(e,function(e,t){s[n]=t,r(e)})},function(e){o(e,s)})};var n=o(r(54)),i=o(r(34));function o(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default},function(e,t,r){"use strict";(function(t){const n=r(38),i=r(39),o=r(387),s=r(748),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,128)),shake256:a(u(n.shake_256,256)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(750),dblSha2256:(e,r)=>{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>>>16}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[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 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[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 l(e,t){return 0==(t%=64)?e:t<32?[e[0]<>>32-t,e[1]<>>1]),[4283543511,3981806797]),[0,e[0]>>>1]),[3301882366,444984403]),[0,e[0]>>>1])}i.x86.hash32=function(e,t){e=e||"",t=t||0;for(var r=e.length%4,n=e.length-r,i=t,u=0,c=3432918353,f=461845907,l=0;l>>0},i.x86.hash128=function(e,t){e=e||"",t=t||0;for(var r=e.length%16,n=e.length-r,i=t,u=t,c=t,f=t,l=0,h=0,p=0,d=0,y=597399067,g=2869860233,m=951274213,b=2716044179,v=0;v>>0).toString(16)).slice(-8)+("00000000"+(u>>>0).toString(16)).slice(-8)+("00000000"+(c>>>0).toString(16)).slice(-8)+("00000000"+(f>>>0).toString(16)).slice(-8)},i.x64.hash128=function(e,t){e=e||"",t=t||0;for(var r=e.length%16,n=e.length-r,i=[0,t],o=[0,t],s=[0,0],a=[0,0],d=[2277735313,289559509],y=[1291169091,658871167],g=0;g>>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)},void 0!==e&&e.exports&&(t=e.exports=i),t.murmurHash3=i}()},function(e,t,r){"use strict";(function(t){const n=r(40),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;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(388);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):function(){var e,t=new s(function(t){e=t});return{resolver:e,promise:t}}();var t,r=!1,a=!1,u=[],c=!1;function f(e){u.length?(c=!0,u.shift()(e||!1)):c=!1}this.then=function(e,i){return new s(function(o){u.push(function(r){var s=a?e:i;if("function"==typeof s){function u(){var e;try{e=s(t)}catch(e){return o.reject(e),f()}o.fulfill(e),f(!0)}r?u():n(u)}else a?(o.fulfill(t),f(r)):(o.reject(t),f(r))}),r&&!c&&f()})},function(){function n(e){r||(r=!0,a=!1,t=e,f())}for(var s={fulfill:function e(o){r||(i(o)?o.then(e,n):(r=a=!0,t=o,f()))},reject:n},u=0;ui(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){var n=r(389);function i(e,t,r){var n=e[t]+e[r],i=e[t+1]+e[r+1];n>=4294967296&&i++,e[t]=n,e[t+1]=i}function o(e,t,r,n){var i=e[t]+r;r<0&&(i+=4294967296);var 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){var u=l[s],c=l[s+1],h=l[a],p=l[a+1];i(f,e,t),o(f,e,u,c);var d=f[n]^f[e],y=f[n+1]^f[e+1];f[n]=y,f[n+1]=d,i(f,r,n),d=f[t]^f[r],y=f[t+1]^f[r+1],f[t]=d>>>24^y<<8,f[t+1]=y>>>24^d<<8,i(f,e,t),o(f,e,h,p),d=f[n]^f[e],y=f[n+1]^f[e+1],f[n]=d>>>16^y<<16,f[n+1]=y>>>16^d<<16,i(f,r,n),d=f[t]^f[r],y=f[t+1]^f[r+1],f[t]=y>>>31^d<<1,f[t+1]=d>>>31^y<<1}var u=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,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,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),l=new Uint32Array(32);function h(e,t){var r=0;for(r=0;r<16;r++)f[r]=e.h[r],f[r+16]=u[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++)l[r]=s(e.b,4*r);for(r=0;r<12;r++)a(0,8,16,24,c[16*r+0],c[16*r+1]),a(2,10,18,26,c[16*r+2],c[16*r+3]),a(4,12,20,28,c[16*r+4],c[16*r+5]),a(6,14,22,30,c[16*r+6],c[16*r+7]),a(0,10,20,30,c[16*r+8],c[16*r+9]),a(2,12,22,24,c[16*r+10],c[16*r+11]),a(4,14,16,26,c[16*r+12],c[16*r+13]),a(6,8,18,28,c[16*r+14],c[16*r+15]);for(r=0;r<16;r++)e.h[r]=e.h[r]^f[r]^f[r+16]}function p(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");for(var r={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:e},n=0;n<16;n++)r.h[n]=u[n];var i=t?t.length:0;return r.h[0]^=16842752^i<<8^e,t&&(d(r,t),r.c=128),r}function d(e,t){for(var r=0;r>2]>>8*(3&r);return t}function g(e,t,r){r=r||64,e=n.normalizeInput(e);var i=p(r,t);return d(i,e),y(i)}e.exports={blake2b:g,blake2bHex:function(e,t,r){var i=g(e,t,r);return n.toHex(i)},blake2bInit:p,blake2bUpdate:d,blake2bFinal:y}},function(e,t,r){var n=r(389);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){c[e]=c[e]+c[t]+i,c[n]=s(c[n]^c[e],16),c[r]=c[r]+c[n],c[t]=s(c[t]^c[r],12),c[e]=c[e]+c[t]+o,c[n]=s(c[n]^c[e],8),c[r]=c[r]+c[n],c[t]=s(c[t]^c[r],7)}function s(e,t){return e>>>t^e<<32-t}var a=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,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]),c=new Uint32Array(16),f=new Uint32Array(16);function l(e,t){var r=0;for(r=0;r<8;r++)c[r]=e.h[r],c[r+8]=a[r];for(c[12]^=e.t,c[13]^=e.t/4294967296,t&&(c[14]=~c[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[u[16*r+0]],f[u[16*r+1]]),o(1,5,9,13,f[u[16*r+2]],f[u[16*r+3]]),o(2,6,10,14,f[u[16*r+4]],f[u[16*r+5]]),o(3,7,11,15,f[u[16*r+6]],f[u[16*r+7]]),o(0,5,10,15,f[u[16*r+8]],f[u[16*r+9]]),o(1,6,11,12,f[u[16*r+10]],f[u[16*r+11]]),o(2,7,8,13,f[u[16*r+12]],f[u[16*r+13]]),o(3,4,9,14,f[u[16*r+14]],f[u[16*r+15]]);for(r=0;r<8;r++)e.h[r]^=c[r]^c[r+8]}function h(e,t){if(!(e>0&&e<=32))throw new Error("Incorrect output length, should be in [1, 32]");var r=t?t.length:0;if(t&&!(r>0&&r<=32))throw new Error("Incorrect key length, should be in [1, 32]");var n={h:new Uint32Array(a),b:new Uint32Array(64),c:0,t:0,outlen:e};return n.h[0]^=16842752^r<<8^e,r>0&&(p(n,t),n.c=64),n}function p(e,t){for(var r=0;r>2]>>8*(3&r)&255;return t}function y(e,t,r){r=r||32,e=n.normalizeInput(e);var i=h(r,t);return p(i,e),d(i)}e.exports={blake2s:y,blake2sHex:function(e,t,r){var i=y(e,t,r);return n.toHex(i)},blake2sInit:h,blake2sUpdate:p,blake2sFinal:d}},function(e,t,r){ +var r;r=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)}},void 0!==e&&e.exports?e.exports=r():this.prr=r()},function(e,t,r){"use strict";var n=r(224).AbstractLevelDOWN,i=r(224).AbstractChainedBatch,o=r(224).AbstractIterator,s=r(4),a=r(26),u=r(720),c=r(722).EncodingError;function f(e,t){if(!(this instanceof f))return new f(e,t);n.call(this,""),void 0===(t=t||{}).keyEncoding&&(t.keyEncoding="utf8"),void 0===t.valueEncoding&&(t.valueEncoding="utf8"),this.db=e,this.codec=new u(t)}function l(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 h(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._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 h(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 l(this,e)},f.prototype._setupIteratorOptions=function(e){return(e=a(e)).reverse=!!e.reverse,e.keys=!1!==e.keys,e.values=!1!==e.values,e.limit="limit"in e?e.limit:-1,e.keyAsBuffer=!1!==e.keyAsBuffer,e.valueAsBuffer=!1!==e.valueAsBuffer,e},f.prototype.approximateSize=function(e,t,r,n){return this.db.approximateSize(e,t,r,n)},s(l,o),l.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)})},l.prototype._end=function(e){this.it.end(e)},s(h,i),h.prototype._put=function(e,t){e=this.codec.encodeKey(e),t=this.codec.encodeValue(t),this.batch.put(e,t)},h.prototype._del=function(e){e=this.codec.encodeKey(e),this.batch.del(e)},h.prototype._clear=function(){this.batch.clear()},h.prototype._write=function(e,t){this.batch.write(e,t)}},function(e,t,r){(function(t,n){var i=r(26),o=r(375),s=r(376),a=Object.prototype.hasOwnProperty,u="start end gt gte lt lte".split(" ");function c(e){if(!arguments.length||void 0===e)throw new Error("constructor requires at least a location argument");if("string"!=typeof e)throw new Error("constructor requires a location string argument");this.location=e,this.status="new"}function f(e){return-1!==u.indexOf(e)}function l(e){return""===e||null==e||function(e){return n.isBuffer(e)&&0===e.length}(e)}c.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&&(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()})},c.prototype._open=function(e,r){t.nextTick(r)},c.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()})},c.prototype._close=function(e){t.nextTick(e)},c.prototype.get=function(e,r,n){if("function"==typeof r&&(n=r),"function"!=typeof n)throw new Error("get() requires a callback argument");var i=this._checkKey(e,"key");if(i)return t.nextTick(n,i);e=this._serializeKey(e),"object"!=typeof r&&(r={}),r.asBuffer=!1!==r.asBuffer,this._get(e,r,n)},c.prototype._get=function(e,r,n){t.nextTick(function(){n(new Error("NotFound"))})},c.prototype.put=function(e,r,n,i){if("function"==typeof n&&(i=n),"function"!=typeof i)throw new Error("put() requires a callback argument");var o=this._checkKey(e,"key");if(o)return t.nextTick(i,o);e=this._serializeKey(e),r=this._serializeValue(r),"object"!=typeof n&&(n={}),this._put(e,r,n,i)},c.prototype._put=function(e,r,n,i){t.nextTick(i)},c.prototype.del=function(e,r,n){if("function"==typeof r&&(n=r),"function"!=typeof n)throw new Error("del() requires a callback argument");var i=this._checkKey(e,"key");if(i)return t.nextTick(n,i);e=this._serializeKey(e),"object"!=typeof r&&(r={}),this._del(e,r,n)},c.prototype._del=function(e,r,n){t.nextTick(n)},c.prototype.batch=function(e,r,n){if(!arguments.length)return this._chainedBatch();if("function"==typeof r&&(n=r),"function"==typeof e&&(n=e),"function"!=typeof n)throw new Error("batch(array) requires a callback argument");if(!Array.isArray(e))return t.nextTick(n,new Error("batch(array) requires an array argument"));r&&"object"==typeof r||(r={});for(var o=new Array(e.length),s=0;s-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){(function(e){function r(e){return e}function n(t){return void 0===t||null===t||e.isBuffer(t)}t.utf8=t["utf-8"]={encode:function(e){return n(e)?e:String(e)},decode:r,buffer:!1,type:"utf8"},t.json={encode:JSON.stringify,decode:JSON.parse,buffer:!1,type:"json"},t.binary={encode:function(t){return n(t)?t:e.from(t)},decode:r,buffer:!0,type:"binary"},t.none={encode:r,decode:r,buffer:!1,type:"id"},t.id=t.none,["hex","ascii","base64","ucs2","ucs-2","utf16le","utf-16le"].forEach(function(r){t[r]={encode:function(t){return n(t)?t:e.from(t,r)},decode:function(e){return e.toString(r)},buffer:!0,type:r}})}).call(this,r(0).Buffer)},function(e,t,r){var n=r(373).create,i=n("LevelUPError"),o=n("NotFoundError",i);o.prototype.notFound=!0,o.prototype.status=404,e.exports={LevelUPError:i,InitializationError:n("InitializationError",i),OpenError:n("OpenError",i),ReadError:n("ReadError",i),WriteError:n("WriteError",i),NotFoundError:o,EncodingError:n("EncodingError",i)}},function(e,t,r){(function(t,n){e.exports=u;var i=r(377).AbstractLevelDOWN,o=r(105),s=r(725),a=r(26);function u(e){if(!(this instanceof u))return new u(e);i.call(this,e)}o.inherits(u,i),u.prototype._open=function(e,t){var r=this;if(this._idbOpts=a({storeName:this.location,keyEncoding:"none",valueEncoding:"none"},e),this._idbOpts.idb)i(this._idbOpts.idb);else{var n=indexedDB.open(this.location);n.onerror=function(e){t(e.target.error)},n.onsuccess=function(){i(n.result)}}function i(n){r._db=n;var i=r._db.objectStoreNames.contains(r._idbOpts.storeName);if(e.errorIfExists&&i)return r._db.close(),void t(new Error("store already exists"));if(!e.createIfMissing&&!i)return r._db.close(),void t(new Error("store does not exist"));if(e.createIfMissing&&!i){r._db.close();var o=indexedDB.open(r.location,r._db.version+1);return o.onerror=function(e){t(e.target.error)},o.onupgradeneeded=function(){o.result.createObjectStore(r._idbOpts.storeName,r._idbOpts)},void(o.onsuccess=function(){r._db=o.result,t(null,r)})}t(null,r)}},u.prototype._get=function(e,r,n){var i=e;"binary"!==(r=a(this._idbOpts,r)).keyEncoding||Array.isArray(e)||(e=Array.prototype.slice.call(e));var o=this._db.transaction(this._idbOpts.storeName),s=o.objectStore(this._idbOpts.storeName).openCursor(IDBKeyRange.only(e));o.onabort=function(){n(o.error)},s.onsuccess=function(){var e=s.result;if(e){var o=e.value;if(o instanceof Uint8Array&&(o=new t(o)),"binary"!==r.valueEncoding||t.isBuffer(o)||(o=new t(o)),r.asBuffer&&!t.isBuffer(o))if(null==o)o=new t(0);else if("string"==typeof o)o=new t(o);else if("boolean"==typeof o)o=new t(String(o));else if("number"==typeof o)o=new t(String(o));else if(Array.isArray(o))o=new t(String(o));else{if(!(o instanceof Uint8Array))return void n(new TypeError("can't coerce `"+o.constructor.name+"` into a Buffer"));o=new t(o)}n(null,o,i)}else n(new Error("NotFound"))}},u.prototype._del=function(e,t,r){"binary"!==(t=a(this._idbOpts,t)).keyEncoding||Array.isArray(e)||(e=Array.prototype.slice.call(e));var n="readwrite";!0===t.sync&&(n="readwriteflush");var i=this._db.transaction(this._idbOpts.storeName,n);i.objectStore(this._idbOpts.storeName).delete(e);i.onabort=function(){r(i.error)},i.oncomplete=function(){r()}},u.prototype._put=function(e,t,r,n){"binary"!==(r=a(this._idbOpts,r)).keyEncoding||Array.isArray(e)||(e=Array.prototype.slice.call(e));var i="readwrite";!0===r.sync&&(i="readwriteflush");var o=this._db.transaction(this._idbOpts.storeName,i);o.objectStore(this._idbOpts.storeName).put(t,e);o.onabort=function(){n(o.error)},o.oncomplete=function(){n()}},u.prototype._iterator=function(e){return new s(this,e)},u.prototype._batch=function(e,t,r){if(0===e.length)return n.nextTick(r);var i="readwrite";!0===t.sync&&(i="readwriteflush");var o=this._db.transaction(this._idbOpts.storeName,i),s=o.objectStore(this._idbOpts.storeName);o.onabort=function(){r(o.error)},o.oncomplete=function(){r()},e.forEach(function(e){"binary"!==a(t,e).keyEncoding||Array.isArray(e.key)||(e.key=Array.prototype.slice.call(e.key)),"del"===e.type?s.delete(e.key):s.put(e.value,e.key)})},u.prototype._close=function(e){this._db.close(),n.nextTick(e)},u.prototype._approximateSize=function(e,t,r){var i=new Error("Not implemented");if(!r)throw i;n.nextTick(function(){r(i)})},u.destroy=function(e,t){var r;if(null!=e&&"object"==typeof e)r=a({location:e.location,storeName:e.location},e._idbOpts);else{if("string"!=typeof e)throw new TypeError("location must be a string or an object");r={location:e,storeName:e}}if("string"!=typeof r.location)throw new TypeError("location must be a string");if("string"!=typeof r.storeName)throw new TypeError("db.storeName must be a string");var n=indexedDB.open(r.location);n.onerror=function(e){t(e.target.error)},n.onsuccess=function(){var e=n.result;function i(e){var r=indexedDB.deleteDatabase(e);r.onerror=function(e){t(e.target.error)},r.onsuccess=function(){t()}}if(e.close(),0!==e.objectStoreNames.length)if(e.objectStoreNames.contains(r.storeName)){var o=indexedDB.open(r.location,e.version+1);o.onerror=function(e){t(e.target.error)},o.onupgradeneeded=function(){(e=o.result).deleteObjectStore(r.storeName)},o.onsuccess=function(){(e=o.result).close(),0===e.objectStoreNames.length?i(r.location):t()}}else t();else i(r.location)}}}).call(this,r(0).Buffer,r(6))},function(e,t,r){var n=r(378);e.exports=function(e){return!(!e||"object"!=typeof e)&&Object.keys(n.prototype).filter(function(e){return"_"!=e[0]&&"approximateSize"!=e}).every(function(t){return"function"==typeof e[t]})}},function(e,t,r){(function(t,n){var i=r(105),o=r(377).AbstractIterator,s=r(726),a=r(727),u=r(90),c=r(26),f=u.Writable;function l(e,t){if(this._db=e._db,this._idbOpts=e._idbOpts,o.call(this,e),this._options=c({snapshot:!0},this._idbOpts,t),this._limit=this._options.limit,null!=this._limit&&-1!==this._limit||(this._limit=1/0),"number"!=typeof this._limit)throw new TypeError("options.limit must be a number");0!==this._limit&&(this._count=0,this._startCursor(this._options))}e.exports=l,i.inherits(l,o),l.prototype._startCursor=function(e){e=c(this._options,e);var t=this,r=null,n=s.lowerBound(e),i=s.upperBound(e),o=s.lowerBoundExclusive(e),u=s.upperBoundExclusive(e),l=e.reverse?"prev":"next";if(n&&("binary"!==e.keyEncoding||Array.isArray(n)||(n=Array.prototype.slice.call(n))),i&&("binary"!==e.keyEncoding||Array.isArray(i)||(i=Array.prototype.slice.call(i))),n&&i)try{r=IDBKeyRange.bound(n,i,o,u)}catch(e){return void(this._keyRangeError=!0)}else n?r=IDBKeyRange.lowerBound(n,o):i&&(r=IDBKeyRange.upperBound(i,u));this._reader=a(this._db,this._idbOpts.storeName,c(e,{range:r,direction:l})),this._reader.on("error",function(e){var r=t._callback;t._callback=!1,r?r(e):t._readNext=function(t){t(e)}}),this._reader.pipe(new f({objectMode:!0,write:function(e,r,n){if(t._count++>=t._limit)return t._reader.pause(),t._reader.unpipe(this),n(),void this.end();var i=t._callback;t._callback=!1,i?t._processItem(e,function(e,t,r){n(e),i(e,t,r)}):t._readNext=function(r){t._processItem(e,function(e,t,i){n(e),r(e,t,i)})}}})).on("finish",function(){var e=t._callback;t._callback=!1,e?e():t._readNext=function(e){e()}})},l.prototype._processItem=function(e,r){if("function"!=typeof r)throw new TypeError("cb must be a function");var n=e.key,i=e.value;if(i instanceof Uint8Array&&(i=new t(i)),"binary"===this._options.keyEncoding&&Array.isArray(n)&&(n=new t(n)),"binary"!==this._options.valueEncoding||t.isBuffer(i)||(i=new t(i)),this._options.keyAsBuffer&&!t.isBuffer(n))if(null==n)n=new t(0);else if("string"==typeof n)n=new t(n);else if("boolean"==typeof n)n=new t(String(n));else if("number"==typeof n)n=new t(String(n));else if(Array.isArray(n))n=new t(String(n));else{if(!(n instanceof Uint8Array))throw new TypeError("can't coerce `"+n.constructor.name+"` into a Buffer");n=new t(n)}if(this._options.valueAsBuffer&&!t.isBuffer(i))if(null==i)i=new t(0);else if("string"==typeof i)i=new t(i);else if("boolean"==typeof i)i=new t(String(i));else if("number"==typeof i)i=new t(String(i));else if(Array.isArray(i))i=new t(String(i));else{if(!(i instanceof Uint8Array))throw new TypeError("can't coerce `"+i.constructor.name+"` into a Buffer");i=new t(i)}r(null,n,i)},l.prototype._next=function(e){if(this._callback)throw new Error("callback already exists");if(this._keyRangeError||0===this._limit)e();else{var t=this._readNext;this._readNext=!1,t?n.nextTick(function(){t(e)}):this._callback=e}}}).call(this,r(0).Buffer,r(6))},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")},u=t.upperBoundInclusive=function(e){return!n(e,"lt")},c=t.lowerBoundExclusive=function(e){return!a(e)},f=t.upperBoundExclusive=function(e){return!u(e)},l=t.upperBoundKey=function(e){return i(e,"lt")||i(e,"lte")||i(e,"max")||(e.reverse?i(e,"start"):i(e,"end"))||void 0},h=t.upperBound=function(e,t){var r=l(e);return r?e[r]:t};function p(e){return e}t.start=function(e,t){return e.reverse?h(e,t):s(e,t)},t.end=function(e,t){return e.reverse?s(e,t):h(e,t)},t.startInclusive=function(e){return e.reverse?u(e):a(e)},t.endInclusive=function(e){return e.reverse?a(e):u(e)},t.toLtgt=function(e,r,i,o,s){r=r||{},i=i||p;var a=arguments.length>3,u=t.lowerBoundKey(e),c=t.upperBoundKey(e);return u?"gt"===u?r.gt=i(e.gt,!1):r.gte=i(e[u],!1):a&&(r.gte=i(o,!1)),c?"lt"===c?r.lt=i(e.lt,!0):r.lte=i(e[c],!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&&c(e)))return!1;var a,u=h(e);return!r(u)||!((a=i(n,u))>0||0===a&&f(e))},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";var n=r(90),i=r(26);e.exports=function(e,t,r){if("object"!=typeof e)throw new TypeError("db must be an object");if("string"!=typeof t)throw new TypeError("storeName must be a string");if(null==r&&(r={}),"object"!=typeof r)throw new TypeError("opts must be an object");var o=new n.Transform(i(r,{objectMode:!0,transform:function(e,t,r){r(null,e)}}));r=i({snapshot:!1},r);var s=null;return o._cursorsOpened=0,function n(){var i,a,u,c,f,l=r.direction||"next",h=r.range||{};i=h.lower,a=h.upper,u=!!h.lowerOpen,c=!!h.upperOpen,s&&("next"===l?(u=!0,i=s):(c=!0,a=s)),i&&a?f=IDBKeyRange.bound(i,a,u,c):i?f=IDBKeyRange.lowerBound(i,u):a&&(f=IDBKeyRange.upperBound(a,c));var p=e.transaction(t,"readonly"),d=p.objectStore(t);o._cursorsOpened++;var y=d.openCursor(f,r.direction);function g(e){try{e.continue()}catch(e){"TransactionInactiveError"!==e.name||r.snapshot?o.emit("error",e):n()}}y.onsuccess=function(){var e=y.result;if(e){s=e.key;var t=o.write({key:e.key,value:e.value});r.snapshot||t?g(e):o.once("drain",function(){g(e)})}else o.end()},p.onabort=function(){o.emit("error",p.error)},p.onerror=function(){o.emit("error",p.error)}}(),o}},function(e,t,r){e.exports=r(210)},function(e,t,r){e.exports=r(85)},function(e,t,r){e.exports=r(22).Transform},function(e,t,r){e.exports=r(22).PassThrough},function(e,t,r){"use strict";t.ERR_REPO_NOT_INITIALIZED="ERR_REPO_NOT_INITIALIZED"},function(e,t,r){"use strict";e.exports={repoVersion:6}},function(e,t){e.exports=function(){var e,t,r,n,i;function o(o){return i?i(o):(e=o,function(e,i){t?t(e,i):(n=e,r=i)})}return o.resolve=function(o){if(i)throw new Error("already resolved");if(!(i=o))throw new Error("resolve *must* be passed a transform stream");e&&(t=i(e),r&&t(n,r))},o}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,o){o=o||n.default,t=t||[];var s=[],a=0,u=(0,i.default)(r);e(t,function(e,t,r){var n=a++;u(e,function(e,t){s[n]=t,r(e)})},function(e){o(e,s)})};var n=o(r(54)),i=o(r(34));function o(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default},function(e,t,r){"use strict";(function(t){const n=r(42),i=r(43),o=r(384),s=r(739),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,128)),shake256:a(u(n.shake_256,256)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(741),dblSha2256:(e,r)=>{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>>>16}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[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 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[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 l(e,t){return 0==(t%=64)?e:t<32?[e[0]<>>32-t,e[1]<>>1]),[4283543511,3981806797]),[0,e[0]>>>1]),[3301882366,444984403]),[0,e[0]>>>1])}i.x86.hash32=function(e,t){e=e||"",t=t||0;for(var r=e.length%4,n=e.length-r,i=t,u=0,c=3432918353,f=461845907,l=0;l>>0},i.x86.hash128=function(e,t){e=e||"",t=t||0;for(var r=e.length%16,n=e.length-r,i=t,u=t,c=t,f=t,l=0,h=0,p=0,d=0,y=597399067,g=2869860233,m=951274213,b=2716044179,v=0;v>>0).toString(16)).slice(-8)+("00000000"+(u>>>0).toString(16)).slice(-8)+("00000000"+(c>>>0).toString(16)).slice(-8)+("00000000"+(f>>>0).toString(16)).slice(-8)},i.x64.hash128=function(e,t){e=e||"",t=t||0;for(var r=e.length%16,n=e.length-r,i=[0,t],o=[0,t],s=[0,0],a=[0,0],d=[2277735313,289559509],y=[1291169091,658871167],g=0;g>>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)},void 0!==e&&e.exports&&(t=e.exports=i),t.murmurHash3=i}()},function(e,t,r){"use strict";(function(t){const n=r(44),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;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(385);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):function(){var e,t=new s(function(t){e=t});return{resolver:e,promise:t}}();var t,r=!1,a=!1,u=[],c=!1;function f(e){u.length?(c=!0,u.shift()(e||!1)):c=!1}this.then=function(e,i){return new s(function(o){u.push(function(r){var s=a?e:i;if("function"==typeof s){function u(){var e;try{e=s(t)}catch(e){return o.reject(e),f()}o.fulfill(e),f(!0)}r?u():n(u)}else a?(o.fulfill(t),f(r)):(o.reject(t),f(r))}),r&&!c&&f()})},function(){function n(e){r||(r=!0,a=!1,t=e,f())}for(var s={fulfill:function e(o){r||(i(o)?o.then(e,n):(r=a=!0,t=o,f()))},reject:n},u=0;ui(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){var n=r(386);function i(e,t,r){var n=e[t]+e[r],i=e[t+1]+e[r+1];n>=4294967296&&i++,e[t]=n,e[t+1]=i}function o(e,t,r,n){var i=e[t]+r;r<0&&(i+=4294967296);var 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){var u=l[s],c=l[s+1],h=l[a],p=l[a+1];i(f,e,t),o(f,e,u,c);var d=f[n]^f[e],y=f[n+1]^f[e+1];f[n]=y,f[n+1]=d,i(f,r,n),d=f[t]^f[r],y=f[t+1]^f[r+1],f[t]=d>>>24^y<<8,f[t+1]=y>>>24^d<<8,i(f,e,t),o(f,e,h,p),d=f[n]^f[e],y=f[n+1]^f[e+1],f[n]=d>>>16^y<<16,f[n+1]=y>>>16^d<<16,i(f,r,n),d=f[t]^f[r],y=f[t+1]^f[r+1],f[t]=y>>>31^d<<1,f[t+1]=d>>>31^y<<1}var u=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,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,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),l=new Uint32Array(32);function h(e,t){var r=0;for(r=0;r<16;r++)f[r]=e.h[r],f[r+16]=u[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++)l[r]=s(e.b,4*r);for(r=0;r<12;r++)a(0,8,16,24,c[16*r+0],c[16*r+1]),a(2,10,18,26,c[16*r+2],c[16*r+3]),a(4,12,20,28,c[16*r+4],c[16*r+5]),a(6,14,22,30,c[16*r+6],c[16*r+7]),a(0,10,20,30,c[16*r+8],c[16*r+9]),a(2,12,22,24,c[16*r+10],c[16*r+11]),a(4,14,16,26,c[16*r+12],c[16*r+13]),a(6,8,18,28,c[16*r+14],c[16*r+15]);for(r=0;r<16;r++)e.h[r]=e.h[r]^f[r]^f[r+16]}function p(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");for(var r={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:e},n=0;n<16;n++)r.h[n]=u[n];var i=t?t.length:0;return r.h[0]^=16842752^i<<8^e,t&&(d(r,t),r.c=128),r}function d(e,t){for(var r=0;r>2]>>8*(3&r);return t}function g(e,t,r){r=r||64,e=n.normalizeInput(e);var i=p(r,t);return d(i,e),y(i)}e.exports={blake2b:g,blake2bHex:function(e,t,r){var i=g(e,t,r);return n.toHex(i)},blake2bInit:p,blake2bUpdate:d,blake2bFinal:y}},function(e,t,r){var n=r(386);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){c[e]=c[e]+c[t]+i,c[n]=s(c[n]^c[e],16),c[r]=c[r]+c[n],c[t]=s(c[t]^c[r],12),c[e]=c[e]+c[t]+o,c[n]=s(c[n]^c[e],8),c[r]=c[r]+c[n],c[t]=s(c[t]^c[r],7)}function s(e,t){return e>>>t^e<<32-t}var a=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,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]),c=new Uint32Array(16),f=new Uint32Array(16);function l(e,t){var r=0;for(r=0;r<8;r++)c[r]=e.h[r],c[r+8]=a[r];for(c[12]^=e.t,c[13]^=e.t/4294967296,t&&(c[14]=~c[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[u[16*r+0]],f[u[16*r+1]]),o(1,5,9,13,f[u[16*r+2]],f[u[16*r+3]]),o(2,6,10,14,f[u[16*r+4]],f[u[16*r+5]]),o(3,7,11,15,f[u[16*r+6]],f[u[16*r+7]]),o(0,5,10,15,f[u[16*r+8]],f[u[16*r+9]]),o(1,6,11,12,f[u[16*r+10]],f[u[16*r+11]]),o(2,7,8,13,f[u[16*r+12]],f[u[16*r+13]]),o(3,4,9,14,f[u[16*r+14]],f[u[16*r+15]]);for(r=0;r<8;r++)e.h[r]^=c[r]^c[r+8]}function h(e,t){if(!(e>0&&e<=32))throw new Error("Incorrect output length, should be in [1, 32]");var r=t?t.length:0;if(t&&!(r>0&&r<=32))throw new Error("Incorrect key length, should be in [1, 32]");var n={h:new Uint32Array(a),b:new Uint32Array(64),c:0,t:0,outlen:e};return n.h[0]^=16842752^r<<8^e,r>0&&(p(n,t),n.c=64),n}function p(e,t){for(var r=0;r>2]>>8*(3&r)&255;return t}function y(e,t,r){r=r||32,e=n.normalizeInput(e);var i=h(r,t);return p(i,e),d(i)}e.exports={blake2s:y,blake2sHex:function(e,t,r){var i=y(e,t,r);return n.toHex(i)},blake2sInit:h,blake2sUpdate:p,blake2sFinal:d}},function(e,t,r){ //! stable.js 0.1.8, https://github.com/Two-Screen/stable //! © 2018 Angry Bytes and contributors. MIT licensed. -var n;n=function(){"use strict";var e=function(e,r){return t(e.slice(),r)};function t(e,t){"function"!=typeof t&&(t=function(e,t){return String(e).localeCompare(t)});var n=e.length;if(n<=1)return e;for(var i=new Array(n),o=1;oc&&(o=c),s>c&&(s=c),a=i,u=o;;)if(a"!==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=o(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")},a=function(e){for(var t={enums:[],messages:[],fields:[],extends:[],extensions:null};e.length;)switch(e[0]){case"map":case"repeated":case"optional":case"required":t.fields.push(s(e));break;case"enum":t.enums.push(d(e));break;case"message":t.messages.push(f(e));break;case"extensions":t.extensions=c(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=s(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":case"option":for(e.shift();";"!==e[0];)e.shift();break;default:e.unshift("optional"),t.fields.push(s(e))}return t},u=function(e){return{name:e[1],message:f(e)}},c=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}},f=function(e){e.shift();var t=1,r=[],n={name:e.shift(),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=a(r),n.enums=r.enums,n.messages=r.messages,n.fields=r.fields,n.extends=r.extends,n.extensions=r.extensions,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},h=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("="!==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=o(e)),e.shift(),{name:t,val:r}},d=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);r.values[n.name]=n.val}else t=y(e),r.options[t.name]=t.value}throw new Error("No closing tag for enum")},y=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},b=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=y(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(v(e));break;default:throw new Error("Unexpected token in service: "+e[0])}}throw new Error("No closing tag for service")},v=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=y(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=function(e){return e.trim()};return e.replace(/([;,{}()=:[\]<>]|\/\*|\*\/)/g," $1 ").split(/\n/).map(t).filter(Boolean).map(function(e){var t=e.indexOf("//");return t>-1?e.slice(0,t):e}).map(t).filter(Boolean).join("\n").split(/\s+|\n+/gm).filter(function(){var e=!1;return function(t){return"/*"===t?(e=!0,!1):"*/"===t?(e=!1,!1):!e}}())}},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.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},u=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},c=function(e){return function(t){return Array.isArray(t)?t.map(c(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.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(u(e,[]))}),t.push("}","")}(e,t)}),t.map(c("")).join("\n")}},function(e,t,r){"use strict";var n=r(759),i=r(761),o=r(762),s=r(763),a=r(20);e.exports=function(e,t){var r={},u={},c={},f=function(e,t){e.enums&&e.enums.forEach(function(e){e.id=t+(t?".":"")+e.name,u[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 l=function(e){var t=Object.keys(e.values||[]).map(function(t){return parseInt(e.values[t].value,10)});return n.make(0,function e(r,n,i){if(!t.length||-1===t.indexOf(r))throw new Error("Invalid enum value: "+r);return a.encode(r,n,i),e.bytes=a.encode.bytes,n},function e(r,n){var i=a.decode(r,n);if(!t.length||-1===t.indexOf(i))throw new Error("Invalid enum value: "+i);return e.bytes=a.decode.bytes,i},a.encodingLength)},h=function(e,t){e.messages.forEach(function(r){t[r.name]=p(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 p(t.type,e.id)}),a=s(e,n,r),u=o(e,p,n,r,a),c=i(e,p,n);return u.bytes=c.bytes=0,t.buffer=!0,t.encode=u,t.decode=c,t.encodingLength=a,t},p=function(e,i,o){if(t&&t[e])return t[e];if(n[e])return n[e];var s=(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]||u[t]},null);if(!1===o)return s;if(!s)throw new Error("Could not resolve "+e);return s.values?l(s):c[s.id]||h(s,c[s.id]={})};return(e.enums||[]).concat((e.messages||[]).map(function(e){return p(e.id)}))}},function(e,t,r){"use strict";var n,i,o,s=r(20),a=r(760),u=r(2).Buffer,c=function(e,t,r,n){return t.bytes=r.bytes=0,{type:e,encode:t,decode:r,encodingLength:n}};t.make=c,t.bytes=(n=function(e){return u.isBuffer(e)?e.length:u.byteLength(e)},c(2,i=function(e,t,r){var o=r,a=n(e);return s.encode(a,t,r),r+=s.encode.bytes,u.isBuffer(e)?e.copy(t,r):t.write(e,r,a),r+=a,i.bytes=r-o,t},o=function(e,t){var r=t,n=s.decode(e,t);t+=s.decode.bytes;var i=e.slice(t,t+n);return t+=i.length,o.bytes=t-r,i},function(e){var t=n(e);return s.encodingLength(t)+t})),t.string=function(){var e=function(t,r,n){var i=n,o=u.byteLength(t);return s.encode(o,r,n,"utf-8"),n+=s.encode.bytes,r.write(t,n,o),n+=o,e.bytes=n-i,r},t=function(e,r){var n=r,i=s.decode(e,r);r+=s.decode.bytes;var o=e.toString("utf-8",r,r+i);return r+=i,t.bytes=r-n,o};return c(2,e,t,function(e){var t=u.byteLength(e);return s.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 c(0,e,t,function(e){return 1})}(),t.int32=function(){var e=function(t,r){var n=s.decode(t,r);return e.bytes=s.decode.bytes,n>2147483647?n-4294967296:n};return c(0,s.encode,e,function(e){return s.encodingLength(e<0?e+4294967296:e)})}(),t.int64=function(){var e=function(t,r){var n=s.decode(t,r);if(n>=Math.pow(2,63)){for(var i=9;255===t[r+i-1];)i--;i=i||9;var o=u.allocUnsafe(i);t.copy(o,0,r,r+i),o[i-1]=127&o[i-1],n=-1*s.decode(o,0),e.bytes=10}else e.bytes=s.decode.bytes;return n},t=function(e,r,n){if(e<0){var i=n+9;for(s.encode(-1*e,r,n),r[n+=s.encode.bytes-1]=128|r[n];n=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){"use strict";var n=r(20),i=r(227).defined;var o=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)}},s=function(e,t){if(e.map)return{};if(e.repeated)return[];switch(e.type){case"string":return null!=t?t:"";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||0,10);default:return null}};e.exports=function(e,t,r){for(var a=[],u={},c=[],f=[],l=0;l-1&&delete r[u[f]];if(e.message){var l=n.decode(i,o);o+=n.decode.bytes;var h=e.decode(i,o,o+l);t.map?(r[a]=r[a]||{},r[a][h.key]=h.value):t.repeated?(r[a]=r[a]||[],r[a].push(h)):r[a]=h}else t.repeated?(r[a]=r[a]||[],r[a].push(e.decode(i,o))):r[a]=e.decode(i,o);return o+e.decode.bytes}return function t(l,h,p){if(null==h&&(h=0),null==p&&(p=l.length),!(p<=l.length&&h<=l.length))throw new Error("Decoded message is not valid");for(var d,g=h,m={};;){if(p<=h){var b,v,_="",w=0;for(w=0;w-1){S=!0;break}S||(b?d.repeated?m[_]=[]:(v=v&&b[v]?b[v].value:b[Object.keys(b)[0]].value,m[_]=parseInt(v||0,10)):m[_]=s(d,v))}return t.bytes=h-g,m}var A=n.decode(l,h);h+=n.decode.bytes;var x=u[A>>3];if(null!=x){var I=r[x];if((d=e.fields[x]).packed){var T=n.decode(l,h);for(T+=h+=n.decode.bytes;h-1){if(b)throw new Error("only one of the properties defined in oneof "+v+" can be set");b=!0}}for(m=0;me.name!==r);else{if(!t.isBuffer(r))return n(new Error("second arg needs to be a name or multihash"),null);u=u.filter(e=>!e.multihash.equals(r))}s(a,u,n)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";t.Diagnose=r(771),t.Decoder=r(393),t.Encoder=r(773),t.Simple=r(394),t.Tagged=r(395),t.decodeAll=t.Decoder.decodeAll,t.decodeFirst=t.Decoder.decodeFirst,t.diagnose=t.Diagnose.diagnose,t.encode=t.Encoder.encode,t.decode=t.Decoder.decode,t.leveldb={decode:t.Decoder.decodeAll,encode:t.Encoder.encode,buffer:!0,name:"cbor"}},function(e,t,r){"use strict";(function(t){const n=r(393),i=r(228);class o extends n{createTag(e,t){return`${e}(${t})`}createInt(e){return super.createInt(e).toString()}createInt32(e,t){return super.createInt32(e,t).toString()}createInt64(e,t,r,n){return super.createInt64(e,t,r,n).toString()}createInt32Neg(e,t){return super.createInt32Neg(e,t).toString()}createInt64Neg(e,t,r,n){return super.createInt64Neg(e,t,r,n).toString()}createTrue(){return"true"}createFalse(){return"false"}createFloat(e){const t=super.createFloat(e);return i.isNegativeZero(e)?"-0_1":`${t}_1`}createFloatSingle(e,t,r,n){return`${super.createFloatSingle(e,t,r,n)}_2`}createFloatDouble(e,t,r,n,i,o,s,a){return`${super.createFloatDouble(e,t,r,n,i,o,s,a)}_3`}createByteString(e,t){const r=e.join(", ");return-1===t?`(_ ${r})`:`h'${r}`}createByteStringFromHeap(e,r){return`h'${t.from(super.createByteStringFromHeap(e,r)).toString("hex")}'`}createInfinity(){return"Infinity_1"}createInfinityNeg(){return"-Infinity_1"}createNaN(){return"NaN_1"}createNaNNeg(){return"-NaN_1"}createNull(){return"null"}createUndefined(){return"undefined"}createSimpleUnassigned(e){return`simple(${e})`}createArray(e,t){const r=super.createArray(e,t);return-1===t?`[_ ${r.join(", ")}]`:`[${r.join(", ")}]`}createMap(e,t){const r=super.createMap(e),n=Array.from(r.keys()).reduce(s(r),"");return-1===t?`{_ ${n}}`:`{${n}}`}createObject(e,t){const r=super.createObject(e),n=Object.keys(r).reduce(s(r),"");return-1===t?`{_ ${n}}`:`{${n}}`}createUtf8String(e,t){const r=e.join(", ");return-1===t?`(_ ${r})`:`"${r}"`}createUtf8StringFromHeap(e,r){return`"${t.from(super.createUtf8StringFromHeap(e,r)).toString("utf8")}"`}static diagnose(e,r){return"string"==typeof e&&(e=t.from(e,r||"hex")),(new o).decodeFirst(e)}}function s(e){return(t,r)=>t?`${t}, ${r}: ${e[r]}`:`${r}: ${e[r]}`}e.exports=o}).call(this,r(0).Buffer)},function(e,t){e.exports=function(e,t,r){"use asm";var n=new e.Uint8Array(r);var i=t.pushInt;var o=t.pushInt32;var s=t.pushInt32Neg;var a=t.pushInt64;var u=t.pushInt64Neg;var c=t.pushFloat;var f=t.pushFloatSingle;var l=t.pushFloatDouble;var h=t.pushTrue;var p=t.pushFalse;var d=t.pushUndefined;var y=t.pushNull;var g=t.pushInfinity;var m=t.pushInfinityNeg;var b=t.pushNaN;var v=t.pushNaNNeg;var _=t.pushArrayStart;var w=t.pushArrayStartFixed;var S=t.pushArrayStartFixed32;var k=t.pushArrayStartFixed64;var E=t.pushObjectStart;var A=t.pushObjectStartFixed;var x=t.pushObjectStartFixed32;var I=t.pushObjectStartFixed64;var T=t.pushByteString;var B=t.pushByteStringStart;var C=t.pushUtf8String;var P=t.pushUtf8StringStart;var O=t.pushSimpleUnassigned;var R=t.pushTagStart;var N=t.pushTagStart4;var L=t.pushTagStart8;var K=t.pushTagUnassigned;var j=t.pushBreak;var M=e.Math.pow;var D=0;var U=0;var F=0;function q(e){e=e|0;D=0;U=e;while((D|0)<(U|0)){F=Je[n[D]&255](n[D]|0)|0;if((F|0)>0){break}}return F|0}function H(e){e=e|0;if(((D|0)+(e|0)|0)<(U|0)){return 0}return 1}function z(e){e=e|0;return n[e|0]<<8|n[e+1|0]|0}function V(e){e=e|0;return n[e|0]<<24|n[e+1|0]<<16|n[e+2|0]<<8|n[e+3|0]|0}function G(e){e=e|0;i(e|0);D=D+1|0;return 0}function W(e){e=e|0;if(H(1)|0){return 1}i(n[D+1|0]|0);D=D+2|0;return 0}function $(e){e=e|0;if(H(2)|0){return 1}i(z(D+1|0)|0);D=D+3|0;return 0}function Y(e){e=e|0;if(H(4)|0){return 1}o(z(D+1|0)|0,z(D+3|0)|0);D=D+5|0;return 0}function J(e){e=e|0;if(H(8)|0){return 1}a(z(D+1|0)|0,z(D+3|0)|0,z(D+5|0)|0,z(D+7|0)|0);D=D+9|0;return 0}function X(e){e=e|0;i(-1-(e-32|0)|0);D=D+1|0;return 0}function Z(e){e=e|0;if(H(1)|0){return 1}i(-1-(n[D+1|0]|0)|0);D=D+2|0;return 0}function Q(e){e=e|0;var t=0;if(H(2)|0){return 1}t=z(D+1|0)|0;i(-1-(t|0)|0);D=D+3|0;return 0}function ee(e){e=e|0;if(H(4)|0){return 1}s(z(D+1|0)|0,z(D+3|0)|0);D=D+5|0;return 0}function te(e){e=e|0;if(H(8)|0){return 1}u(z(D+1|0)|0,z(D+3|0)|0,z(D+5|0)|0,z(D+7|0)|0);D=D+9|0;return 0}function re(e){e=e|0;var t=0;var r=0;var n=0;n=e-64|0;if(H(n|0)|0){return 1}t=D+1|0;r=(D+1|0)+(n|0)|0;T(t|0,r|0);D=r|0;return 0}function ne(e){e=e|0;var t=0;var r=0;var i=0;if(H(1)|0){return 1}i=n[D+1|0]|0;t=D+2|0;r=(D+2|0)+(i|0)|0;if(H(i+1|0)|0){return 1}T(t|0,r|0);D=r|0;return 0}function ie(e){e=e|0;var t=0;var r=0;var n=0;if(H(2)|0){return 1}n=z(D+1|0)|0;t=D+3|0;r=(D+3|0)+(n|0)|0;if(H(n+2|0)|0){return 1}T(t|0,r|0);D=r|0;return 0}function oe(e){e=e|0;var t=0;var r=0;var n=0;if(H(4)|0){return 1}n=V(D+1|0)|0;t=D+5|0;r=(D+5|0)+(n|0)|0;if(H(n+4|0)|0){return 1}T(t|0,r|0);D=r|0;return 0}function se(e){e=e|0;return 1}function ae(e){e=e|0;B();D=D+1|0;return 0}function ue(e){e=e|0;var t=0;var r=0;var n=0;n=e-96|0;if(H(n|0)|0){return 1}t=D+1|0;r=(D+1|0)+(n|0)|0;C(t|0,r|0);D=r|0;return 0}function ce(e){e=e|0;var t=0;var r=0;var i=0;if(H(1)|0){return 1}i=n[D+1|0]|0;t=D+2|0;r=(D+2|0)+(i|0)|0;if(H(i+1|0)|0){return 1}C(t|0,r|0);D=r|0;return 0}function fe(e){e=e|0;var t=0;var r=0;var n=0;if(H(2)|0){return 1}n=z(D+1|0)|0;t=D+3|0;r=(D+3|0)+(n|0)|0;if(H(n+2|0)|0){return 1}C(t|0,r|0);D=r|0;return 0}function le(e){e=e|0;var t=0;var r=0;var n=0;if(H(4)|0){return 1}n=V(D+1|0)|0;t=D+5|0;r=(D+5|0)+(n|0)|0;if(H(n+4|0)|0){return 1}C(t|0,r|0);D=r|0;return 0}function he(e){e=e|0;return 1}function pe(e){e=e|0;P();D=D+1|0;return 0}function de(e){e=e|0;w(e-128|0);D=D+1|0;return 0}function ye(e){e=e|0;if(H(1)|0){return 1}w(n[D+1|0]|0);D=D+2|0;return 0}function ge(e){e=e|0;if(H(2)|0){return 1}w(z(D+1|0)|0);D=D+3|0;return 0}function me(e){e=e|0;if(H(4)|0){return 1}S(z(D+1|0)|0,z(D+3|0)|0);D=D+5|0;return 0}function be(e){e=e|0;if(H(8)|0){return 1}k(z(D+1|0)|0,z(D+3|0)|0,z(D+5|0)|0,z(D+7|0)|0);D=D+9|0;return 0}function ve(e){e=e|0;_();D=D+1|0;return 0}function _e(e){e=e|0;var t=0;t=e-160|0;if(H(t|0)|0){return 1}A(t|0);D=D+1|0;return 0}function we(e){e=e|0;if(H(1)|0){return 1}A(n[D+1|0]|0);D=D+2|0;return 0}function Se(e){e=e|0;if(H(2)|0){return 1}A(z(D+1|0)|0);D=D+3|0;return 0}function ke(e){e=e|0;if(H(4)|0){return 1}x(z(D+1|0)|0,z(D+3|0)|0);D=D+5|0;return 0}function Ee(e){e=e|0;if(H(8)|0){return 1}I(z(D+1|0)|0,z(D+3|0)|0,z(D+5|0)|0,z(D+7|0)|0);D=D+9|0;return 0}function Ae(e){e=e|0;E();D=D+1|0;return 0}function xe(e){e=e|0;R(e-192|0|0);D=D+1|0;return 0}function Ie(e){e|0;R(e|0);D=D+1|0;return 0}function Te(e){e|0;R(e|0);D=D+1|0;return 0}function Be(e){e|0;R(e|0);D=D+1|0;return 0}function Ce(e){e|0;R(e|0);D=D+1|0;return 0}function Pe(e){e=e|0;R(e-192|0|0);D=D+1|0;return 0}function Oe(e){e|0;R(e|0);D=D+1|0;return 0}function Re(e){e|0;R(e|0);D=D+1|0;return 0}function Ne(e){e|0;R(e|0);D=D+1|0;return 0}function Le(e){e=e|0;if(H(1)|0){return 1}R(n[D+1|0]|0);D=D+2|0;return 0}function Ke(e){e=e|0;if(H(2)|0){return 1}R(z(D+1|0)|0);D=D+3|0;return 0}function je(e){e=e|0;if(H(4)|0){return 1}N(z(D+1|0)|0,z(D+3|0)|0);D=D+5|0;return 0}function Me(e){e=e|0;if(H(8)|0){return 1}L(z(D+1|0)|0,z(D+3|0)|0,z(D+5|0)|0,z(D+7|0)|0);D=D+9|0;return 0}function De(e){e=e|0;O((e|0)-224|0);D=D+1|0;return 0}function Ue(e){e=e|0;p();D=D+1|0;return 0}function Fe(e){e=e|0;h();D=D+1|0;return 0}function qe(e){e=e|0;y();D=D+1|0;return 0}function He(e){e=e|0;d();D=D+1|0;return 0}function ze(e){e=e|0;if(H(1)|0){return 1}O(n[D+1|0]|0);D=D+2|0;return 0}function Ve(e){e=e|0;var t=0;var r=0;var i=1.0;var o=0.0;var s=0.0;var a=0.0;if(H(2)|0){return 1}t=n[D+1|0]|0;r=n[D+2|0]|0;if((t|0)&0x80){i=-1.0}o=+(((t|0)&0x7C)>>2);s=+(((t|0)&0x03)<<8|r);if(+o==0.0){c(+(+i*+5.9604644775390625e-8*+s))}else if(+o==31.0){if(+i==1.0){if(+s>0.0){b()}else{g()}}else{if(+s>0.0){v()}else{m()}}}else{c(+(+i*M(+2,+(+o-25.0))*+(1024.0+s)))}D=D+3|0;return 0}function Ge(e){e=e|0;if(H(4)|0){return 1}f(n[D+1|0]|0,n[D+2|0]|0,n[D+3|0]|0,n[D+4|0]|0);D=D+5|0;return 0}function We(e){e=e|0;if(H(8)|0){return 1}l(n[D+1|0]|0,n[D+2|0]|0,n[D+3|0]|0,n[D+4|0]|0,n[D+5|0]|0,n[D+6|0]|0,n[D+7|0]|0,n[D+8|0]|0);D=D+9|0;return 0}function $e(e){e=e|0;return 1}function Ye(e){e=e|0;j();D=D+1|0;return 0}var Je=[G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W,$,Y,J,$e,$e,$e,$e,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,Z,Q,ee,te,$e,$e,$e,$e,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,ne,ie,oe,se,$e,$e,$e,ae,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ce,fe,le,he,$e,$e,$e,pe,de,de,de,de,de,de,de,de,de,de,de,de,de,de,de,de,de,de,de,de,de,de,de,de,ye,ge,me,be,$e,$e,$e,ve,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,we,Se,ke,Ee,$e,$e,$e,Ae,xe,xe,xe,xe,xe,xe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Le,Ke,je,Me,$e,$e,$e,$e,De,De,De,De,De,De,De,De,De,De,De,De,De,De,De,De,De,De,De,De,Ue,Fe,qe,He,ze,Ve,Ge,We,$e,$e,$e,Ye];return{parse:q}}},function(e,t,r){"use strict";(function(t){const n=r(33),i=r(169),o=r(228),s=r(170),a=s.MT,u=s.NUMBYTES,c=s.SHIFT32,f=s.SYMS,l=s.TAG,h=s.MT.SIMPLE_FLOAT<<5|s.NUMBYTES.TWO,p=s.MT.SIMPLE_FLOAT<<5|s.NUMBYTES.FOUR,d=s.MT.SIMPLE_FLOAT<<5|s.NUMBYTES.EIGHT,y=s.MT.SIMPLE_FLOAT<<5|s.SIMPLE.TRUE,g=s.MT.SIMPLE_FLOAT<<5|s.SIMPLE.FALSE,m=s.MT.SIMPLE_FLOAT<<5|s.SIMPLE.UNDEFINED,b=s.MT.SIMPLE_FLOAT<<5|s.SIMPLE.NULL,v=new i("0x20000000000000"),_=t.from("f97e00","hex"),w=t.from("f9fc00","hex"),S=t.from("f97c00","hex");class k{constructor(e){e=e||{},this.streaming="function"==typeof e.stream,this.onData=e.stream,this.semanticTypes=[[n.Url,this._pushUrl],[i,this._pushBigNumber]];const t=e.genTypes||[],r=t.length;for(let e=0;e[t,e[t]]))}_pushRawMap(e,t){t=t.map(function(e){return e[0]=k.encode(e[0]),e}).sort(o.keySorter);for(var r=0;rt.length)throw new Error(r.INVALID_TARGET_OFFSET)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(n){const i=r(3),o=r(172).SmartBuffer,s=r(171);(t=e.exports).serialize=((e,t)=>{let r=[];r.push("tree "+s.cidToSha(e.tree["/"]).toString("hex")),e.parents.forEach(e=>{r.push("parent "+s.cidToSha(e["/"]).toString("hex"))}),r.push("author "+s.serializePersonLine(e.author)),r.push("committer "+s.serializePersonLine(e.committer)),e.encoding&&r.push("encoding "+e.encoding),e.signature&&(r.push("gpgsig -----BEGIN PGP SIGNATURE-----"),r.push(e.signature.text)),r.push(""),r.push(e.message);let n=r.join("\n"),a=new o;a.writeString("commit "),a.writeString(n.length.toString()),a.writeUInt8(0),a.writeString(n),i(()=>t(null,a.toBuffer()))}),t.deserialize=((e,t)=>{let r=e.toString().split("\n"),o={gitType:"commit",parents:[]};for(let e=0;et(new Error("Invalid commit line "+e))),o.message=r.slice(e+1).join("\n");break}let u=a[1],c=a[2];switch(u){case"tree":o.tree={"/":s.shaToCid(n.from(c,"hex"))};break;case"committer":o.committer=s.parsePersonLine(c);break;case"author":o.author=s.parsePersonLine(c);break;case"parent":o.parents.push({"/":s.shaToCid(n.from(c,"hex"))});break;case"gpgsig":{"-----BEGIN PGP SIGNATURE-----"!==c&&i(()=>t(new Error("Invalid commit line "+e))),o.signature={};let n=e;for(;et(null,o))})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(n){const i=r(3),o=r(172).SmartBuffer,s=r(171);(t=e.exports).serialize=((e,t)=>{let r=[];r.push("object "+s.cidToSha(e.object["/"]).toString("hex")),r.push("type "+e.type),r.push("tag "+e.tag),null!==e.tagger&&r.push("tagger "+s.serializePersonLine(e.tagger)),r.push(""),r.push(e.message);let n=r.join("\n"),a=new o;a.writeString("tag "),a.writeString(n.length.toString()),a.writeUInt8(0),a.writeString(n),i(()=>t(null,a.toBuffer()))}),t.deserialize=((e,t)=>{let r=e.toString().split("\n"),o={gitType:"tag"};for(let e=0;et(new Error("Invalid tag line "+e))),o.message=r.slice(e+1).join("\n");break}let u=a[1],c=a[2];switch(u){case"object":o.object={"/":s.shaToCid(n.from(c,"hex"))};break;case"tagger":o.tagger=s.parsePersonLine(c);break;case"tag":o.tag=c;break;case"type":o.type=c;break;default:o[u]=c}}i(()=>t(null,o))})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(3),i=r(172).SmartBuffer,o=r(171);(t=e.exports).serialize=((e,t)=>{let r=[];Object.keys(e).forEach(t=>{r.push([t,e[t]])}),r.sort((e,t)=>e[0]>t[0]?1:-1);let s=new i;r.forEach(e=>{s.writeStringNT(e[1].mode+" "+e[0]),s.writeBuffer(o.cidToSha(e[1].hash["/"]))});let a=new i;a.writeString("tree "),a.writeString(s.length.toString()),a.writeUInt8(0),a.writeBuffer(s.toBuffer()),n(()=>t(null,a.toBuffer()))}),t.deserialize=((e,t)=>{let r={},s=i.fromBuffer(e,"utf8");for(;;){let e=s.readStringNT();if(""===e)break;let i=s.readBuffer(o.SHA1_LENGTH),a=e.match(/^(\d+) (.+)$/);a||n(()=>t(new Error("invalid file mode/name"))),r[a[2]]&&n(()=>t(new Error("duplicate file in tree"))),r[a[2]]={mode:a[1],hash:{"/":o.shaToCid(i)}}}n(()=>t(null,r))})},function(e,t,r){"use strict";t.resolver=r(229),t.util=r(400)},function(e,t,r){var n=r(28),i=r(232);for(var o in i)n[o]=i[o];e.exports={bufferutils:r(407),Block:r(800),ECPair:r(239),ECSignature:r(243),HDNode:r(816),Transaction:r(238),TransactionBuilder:r(817),address:r(240),crypto:r(105),networks:r(124),opcodes:r(42),script:n}},function(e,t,r){(function(t){var n=r(231),i=r(402);function o(e){return t.isBuffer(e)}function s(e){return"string"==typeof e&&/^([0-9a-f]{2})+$/i.test(e)}function a(e,t){var r=e.toJSON();function n(n){if(!e(n))return!1;if(n.length===t)return!0;throw i.tfCustomError(r+"(Length: "+t+")",r+"(Length: "+n.length+")")}return n.toJSON=function(){return r},n}var u=a.bind(null,n.Array),c=a.bind(null,o),f=a.bind(null,s),l=a.bind(null,n.String),h=Math.pow(2,53)-1;var p={ArrayN:u,Buffer:o,BufferN:c,Finite:function(e){return"number"==typeof e&&isFinite(e)},Hex:s,HexN:f,Int8:function(e){return e<<24>>24===e},Int16:function(e){return e<<16>>16===e},Int32:function(e){return(0|e)===e},StringN:l,UInt8:function(e){return(255&e)===e},UInt16:function(e){return(65535&e)===e},UInt32:function(e){return e>>>0===e},UInt53:function(e){return"number"==typeof e&&e>=0&&e<=h&&Math.floor(e)===e}};for(var d in p)p[d].toJSON=function(e){return e}.bind(null,d);e.exports=p}).call(this,r(0).Buffer)},function(e,t,r){var n=r(42),i={};for(var o in n){i[n[o]]=o}e.exports=i},function(e,t,r){var n=r(2).Buffer,i=r(28),o=r(404),s=r(25),a=r(42);function u(e){return e===a.OP_0||i.isCanonicalSignature(e)}function c(e,t){var r=i.decompile(e);return!(r.length<2)&&r[0]===a.OP_0&&(t?r.slice(1).every(u):r.slice(1).every(i.isCanonicalSignature))}c.toJSON=function(){return"multisig input"};var f=n.allocUnsafe(0);function l(e,t){if(s([u],e),t){var r=o.decode(t);if(e.lengthr.pubKeys.length)throw new TypeError("Too many signatures provided")}return[].concat(f,e.map(function(e){return e===a.OP_0?f:e}))}function h(e,t){return s(s.Array,e),s(c,e,t),e.slice(1)}e.exports={check:c,decode:function(e,t){return h(i.decompile(e),t)},decodeStack:h,encode:function(e,t){return i.compile(l(e,t))},encodeStack:l}},function(e,t,r){var n=r(28),i=r(31),o=r(25),s=r(42);function a(e){var t=n.compile(e);return t.length>1&&t[0]===s.OP_RETURN}a.toJSON=function(){return"null data output"},e.exports={output:{check:a,decode:function(e){return o(a,e),e.slice(2)},encode:function(e){return o(i.Buffer,e),n.compile([s.OP_RETURN,e])}}}},function(e,t,r){var n=r(28),i=r(25);function o(e){var t=n.decompile(e);return 1===t.length&&n.isCanonicalSignature(t[0])}function s(e){return i(n.isCanonicalSignature,e),[e]}function a(e){return i(i.Array,e),i(o,e),e[0]}o.toJSON=function(){return"pubKey input"},e.exports={check:o,decode:function(e){return a(n.decompile(e))},decodeStack:a,encode:function(e){return n.compile(s(e))},encodeStack:s}},function(e,t,r){var n=r(28),i=r(25),o=r(42);function s(e){var t=n.decompile(e);return 2===t.length&&n.isCanonicalPubKey(t[0])&&t[1]===o.OP_CHECKSIG}s.toJSON=function(){return"pubKey output"},e.exports={check:s,decode:function(e){var t=n.decompile(e);return i(s,t),t[0]},encode:function(e){return i(n.isCanonicalPubKey,e),n.compile([e,o.OP_CHECKSIG])}}},function(e,t,r){var n=r(28),i=r(25);function o(e){var t=n.decompile(e);return 2===t.length&&n.isCanonicalSignature(t[0])&&n.isCanonicalPubKey(t[1])}function s(e,t){return i({signature:n.isCanonicalSignature,pubKey:n.isCanonicalPubKey},{signature:e,pubKey:t}),[e,t]}function a(e){return i(i.Array,e),i(o,e),{signature:e[0],pubKey:e[1]}}o.toJSON=function(){return"pubKeyHash input"},e.exports={check:o,decode:function(e){return a(n.decompile(e))},decodeStack:a,encode:function(e,t){return n.compile(s(e,t))},encodeStack:s}},function(e,t,r){var n=r(28),i=r(31),o=r(25),s=r(42);function a(e){var t=n.compile(e);return 25===t.length&&t[0]===s.OP_DUP&&t[1]===s.OP_HASH160&&20===t[2]&&t[23]===s.OP_EQUALVERIFY&&t[24]===s.OP_CHECKSIG}a.toJSON=function(){return"pubKeyHash output"},e.exports={check:a,decode:function(e){return o(a,e),e.slice(3,23)},encode:function(e){return o(i.Hash160bit,e),n.compile([s.OP_DUP,s.OP_HASH160,e,s.OP_EQUALVERIFY,s.OP_CHECKSIG])}}},function(e,t,r){e.exports={input:r(792),output:r(793)}},function(e,t,r){var n=r(2).Buffer,i=r(28),o=r(25),s=r(233),a=r(234),u=r(235),c=r(405),f=r(406);function l(e,t){var r=i.decompile(e);if(r.length<1)return!1;var o=r[r.length-1];if(!n.isBuffer(o))return!1;var l=i.decompile(i.compile(r.slice(0,-1))),h=i.decompile(o);return 0!==h.length&&!!i.isPushOnly(l)&&(1===r.length?f.check(h)||c.check(h):!(!u.input.check(l)||!u.output.check(h))||!(!s.input.check(l,t)||!s.output.check(h))||!(!a.input.check(l)||!a.output.check(h)))}function h(e,t){var r=i.compile(t);return[].concat(e,r)}function p(e){return o(o.Array,e),o(l,e),{redeemScriptStack:e.slice(0,-1),redeemScript:e[e.length-1]}}l.toJSON=function(){return"scriptHash input"},e.exports={check:l,decode:function(e){var t=p(i.decompile(e));return t.redeemScriptSig=i.compile(t.redeemScriptStack),delete t.redeemScriptStack,t},decodeStack:p,encode:function(e,t){var r=i.decompile(e);return i.compile(h(r,t))},encodeStack:h}},function(e,t,r){var n=r(28),i=r(31),o=r(25),s=r(42);function a(e){var t=n.compile(e);return 23===t.length&&t[0]===s.OP_HASH160&&20===t[1]&&t[22]===s.OP_EQUAL}a.toJSON=function(){return"scriptHash output"},e.exports={check:a,decode:function(e){return o(a,e),e.slice(2,22)},encode:function(e){return o(i.Hash160bit,e),n.compile([s.OP_HASH160,e,s.OP_EQUAL])}}},function(e,t,r){e.exports={input:r(795),output:r(405)}},function(e,t,r){var n=r(28),i=r(25);function o(e){return n.isCanonicalPubKey(e)&&33===e.length}function s(e){var t=n.decompile(e);return 2===t.length&&n.isCanonicalSignature(t[0])&&o(t[1])}s.toJSON=function(){return"witnessPubKeyHash input"},e.exports={check:s,decodeStack:function(e){return i(i.Array,e),i(s,e),{signature:e[0],pubKey:e[1]}},encodeStack:function(e,t){return i({signature:n.isCanonicalSignature,pubKey:o},{signature:e,pubKey:t}),[e,t]}}},function(e,t,r){e.exports={input:r(797),output:r(406)}},function(e,t,r){(function(t){var n=r(28),i=r(31),o=r(25),s=r(233),a=r(234),u=r(235);function c(e,r){if(o(i.Array,e),e.length<1)return!1;var c=e[e.length-1];if(!t.isBuffer(c))return!1;var f=n.decompile(c);if(0===f.length)return!1;var l=n.compile(e.slice(0,-1));return!(!u.input.check(l)||!u.output.check(f))||!(!s.input.check(l,r)||!s.output.check(f))||!(!a.input.check(l)||!a.output.check(f))}c.toJSON=function(){return"witnessScriptHash input"},e.exports={check:c,decodeStack:function(e){return o(o.Array,e),o(c,e),{witnessData:e.slice(0,-1),witnessScript:e[e.length-1]}},encodeStack:function(e,t){return o({witnessData:[i.Buffer],witnessScript:i.Buffer},{witnessData:e,witnessScript:t}),[].concat(e,t)}}}).call(this,r(0).Buffer)},function(e,t,r){e.exports={output:r(799)}},function(e,t,r){var n=r(2).Buffer,i=r(28),o=r(31),s=r(25),a=r(42),u=n.from("aa21a9ed","hex");function c(e){var t=i.compile(e);return t.length>37&&t[0]===a.OP_RETURN&&36===t[1]&&t.slice(2,6).equals(u)}c.toJSON=function(){return"Witness commitment output"},e.exports={check:c,decode:function(e){return s(c,e),i.decompile(e)[1].slice(4,36)},encode:function(e){s(o.Hash256bit,e);var t=n.allocUnsafe(36);return u.copy(t,0),e.copy(t,4),i.compile([a.OP_RETURN,t])}}},function(e,t,r){var n=r(2).Buffer,i=r(105),o=r(805),s=r(25),a=r(31),u=r(236),c=r(238);function f(){this.version=1,this.prevHash=null,this.merkleRoot=null,this.timestamp=0,this.bits=0,this.nonce=0}f.fromBuffer=function(e){if(e.length<80)throw new Error("Buffer too small (< 80 bytes)");var t=0;function r(r){return t+=r,e.slice(t-r,t)}function n(){var r=e.readUInt32LE(t);return t+=4,r}var i=new f;if(i.version=function(){var r=e.readInt32LE(t);return t+=4,r}(),i.prevHash=r(32),i.merkleRoot=r(32),i.timestamp=n(),i.bits=n(),i.nonce=n(),80===e.length)return i;function o(){var r=c.fromBuffer(e.slice(t),!0);return t+=r.byteLength(),r}var s=function(){var r=u.decode(e,t);return t+=u.decode.bytes,r}();i.transactions=[];for(var a=0;a>24)-3,r=8388607&e,i=n.alloc(32,0);return i.writeUInt32BE(r,28-t),i},f.calculateMerkleRoot=function(e){if(s([{getHash:a.Function}],e),0===e.length)throw TypeError("Cannot compute merkle root for zero transactions");var t=e.map(function(e){return e.getHash()});return o(t,i.hash256)},f.prototype.checkMerkleRoot=function(){if(!this.transactions)return!1;var e=f.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(e)},f.prototype.checkProofOfWork=function(){var e=this.getHash().reverse(),t=f.calculateTarget(this.bits);return e.compare(t)<=0},e.exports=f},function(e,t,r){var n=r(5),i=r(106),o=r(2).Buffer,s=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function u(){this.init(),this._w=a,i.call(this,64,56)}function c(e){return e<<5|e>>>27}function f(e){return e<<30|e>>>2}function l(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t=this._w,r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,a=0|this._e,u=0;u<16;++u)t[u]=e.readInt32BE(4*u);for(;u<80;++u)t[u]=t[u-3]^t[u-8]^t[u-14]^t[u-16];for(var h=0;h<80;++h){var p=~~(h/20),d=c(r)+l(p,n,i,o)+a+t[h]+s[p]|0;a=o,o=i,i=f(n),n=r,r=d}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0},u.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=u},function(e,t,r){var n=r(5),i=r(106),o=r(2).Buffer,s=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function u(){this.init(),this._w=a,i.call(this,64,56)}function c(e){return e<<1|e>>>31}function f(e){return e<<5|e>>>27}function l(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(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t=this._w,r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,a=0|this._e,u=0;u<16;++u)t[u]=e.readInt32BE(4*u);for(;u<80;++u)t[u]=c(t[u-3]^t[u-8]^t[u-14]^t[u-16]);for(var p=0;p<80;++p){var d=~~(p/20),y=f(r)+h(d,n,i,o)+a+t[p]+s[d]|0;a=o,o=i,i=l(n),n=r,r=y}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0},u.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=u},function(e,t,r){var n=r(5),i=r(411),o=r(106),s=r(2).Buffer,a=new Array(64);function u(){this.init(),this._w=a,o.call(this,64,56)}n(u,i),u.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},u.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=u},function(e,t,r){var n=r(5),i=r(412),o=r(106),s=r(2).Buffer,a=new Array(160);function u(){this.init(),this._w=a,o.call(this,128,112)}n(u,i),u.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},u.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=u},function(e,t,r){(function(t){e.exports=function(e,r){if(!Array.isArray(e))throw TypeError("Expected values Array");if("function"!=typeof r)throw TypeError("Expected digest Function");for(var n=e.length,i=e.concat();n>1;){for(var o=0,s=0;s>25;return(33554431&e)<<5^996825010&-(t>>0&1)^642813549&-(t>>1&1)^513874426&-(t>>2&1)^1027748829&-(t>>3&1)^705979059&-(t>>4&1)}function u(e){for(var t=1,r=0;r126)throw new Error("Invalid prefix ("+e+")");t=a(t)^n>>5}for(t=a(t),r=0;r=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<=t)throw new Error("Excess padding");if(i<t)throw new TypeError("Exceeds length limit");var r=e.toLowerCase(),n=e.toUpperCase();if(e!==r&&e!==n)throw new Error("Mixed-case string "+e);var o=(e=r).lastIndexOf("1");if(-1===o)throw new Error("No separator character for "+e);if(0===o)throw new Error("Missing prefix for "+e);var s=e.slice(0,o),c=e.slice(o+1);if(c.length<6)throw new Error("Data too short");for(var f=u(s),l=[],h=0;h=c.length||l.push(d)}if(1!==f)throw new Error("Invalid checksum for "+e);return{prefix:s,words:l}},encode:function(e,t,r){if(r=r||90,e.length+7+t.length>r)throw new TypeError("Exceeds length limit");for(var i=u(e=e.toLowerCase()),o=e+"1",s=0;s>5!=0)throw new Error("Non 5-bit word");i=a(i)^c,o+=n.charAt(c)}for(s=0;s<6;++s)i=a(i);for(i^=1,s=0;s<6;++s){var f=i>>5*(5-s)&31;o+=n.charAt(f)}return o},toWords:function(e){return c(e,8,5,!0)},fromWords:function(e){return c(e,5,8,!1)}}},function(e,t,r){"use strict";var n=r(14),i=r(2).Buffer;e.exports=function(e){function t(t){var r=t.slice(0,-4),n=t.slice(-4),i=e(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(t){var r=e(t);return n.encode(i.concat([t,r],t.length+4))},decode:function(e){var r=t(n.decode(e));if(!r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(e){var r=n.decodeUnsafe(e);if(r)return t(r)}}}},function(e,t,r){var n=r(2).Buffer,i=r(242),o=r(25),s=r(31),a=r(93),u=r(243),c=n.alloc(1,0),f=n.alloc(1,1),l=r(244).getCurveByName("secp256k1");function h(e,t,r){o(s.tuple(s.Hash256bit,s.Buffer256bit,s.Function),arguments);var u=n.alloc(32,0),h=n.alloc(32,1);u=i("sha256",u).update(h).update(c).update(t).update(e).digest(),h=i("sha256",u).update(h).digest(),u=i("sha256",u).update(h).update(f).update(t).update(e).digest(),h=i("sha256",u).update(h).digest(),h=i("sha256",u).update(h).digest();for(var p=a.fromBuffer(h);p.signum()<=0||p.compareTo(l.n)>=0||!r(p);)u=i("sha256",u).update(h).update(c).digest(),h=i("sha256",u).update(h).digest(),h=i("sha256",u).update(h).digest(),p=a.fromBuffer(h);return p}var p=l.n.shiftRight(1);e.exports={deterministicGenerateK:h,sign:function(e,t){o(s.tuple(s.Hash256bit,s.BigInt),arguments);var r,n,i=t.toBuffer(32),c=a.fromBuffer(e),f=l.n,d=l.G;return h(e,i,function(e){var i=d.multiply(e);return!l.isInfinity(i)&&0!==(r=i.affineX.mod(f)).signum()&&0!==(n=e.modInverse(f).multiply(c.add(t.multiply(r))).mod(f)).signum()}),n.compareTo(p)>0&&(n=f.subtract(n)),new u(r,n)},verify:function(e,t,r){o(s.tuple(s.Hash256bit,s.ECSignature,s.ECPoint),arguments);var n=l.n,i=l.G,u=t.r,c=t.s;if(u.signum()<=0||u.compareTo(n)>=0)return!1;if(c.signum()<=0||c.compareTo(n)>=0)return!1;var f=a.fromBuffer(e),h=c.modInverse(n),p=f.multiply(h).mod(n),d=u.multiply(h).mod(n),y=i.multiplyTwo(p,r,d);return!l.isInfinity(y)&&y.affineX.mod(n).equals(u)},__curve:l}},function(e,t,r){"use strict";var n=r(5),i=r(2).Buffer,o=r(92),s=i.alloc(128),a=64;function u(e,t){o.call(this,"digest"),"string"==typeof t&&(t=i.from(t)),this._alg=e,this._key=t,t.length>a?t=e(t):t.length64)throw new TypeError("Seed should be at most 512 bits");var r=s("sha512",d.MASTER_SECRET).update(e).digest(),n=r.slice(0,32),i=r.slice(32),o=f.fromBuffer(n);return new d(new l(o,null,{network:t}),i)},d.fromSeedHex=function(e,t){return d.fromSeedBuffer(n.from(e,"hex"),t)},d.fromBase58=function(e,t){var r=i.decode(e);if(78!==r.length)throw new Error("Invalid buffer length");var n,o=r.readUInt32BE(0);if(Array.isArray(t)){if(!(n=t.filter(function(e){return o===e.bip32.private||o===e.bip32.public}).pop()))throw new Error("Unknown network version")}else n=t||c.bitcoin;if(o!==n.bip32.private&&o!==n.bip32.public)throw new Error("Invalid network version");var s=r[4],a=r.readUInt32BE(5);if(0===s&&0!==a)throw new Error("Invalid parent fingerprint");var u=r.readUInt32BE(9);if(0===s&&0!==u)throw new Error("Invalid index");var y,g=r.slice(13,45);if(o===n.bip32.private){if(0!==r.readUInt8(45))throw new Error("Invalid private key");var m=f.fromBuffer(r.slice(46,78));y=new l(m,null,{network:n})}else{var b=h.Point.decodeFrom(p,r.slice(45,78));p.validate(b),y=new l(null,b,{network:n})}var v=new d(y,g);return v.depth=s,v.index=u,v.parentFingerprint=a,v},d.prototype.getAddress=function(){return this.keyPair.getAddress()},d.prototype.getIdentifier=function(){return o.hash160(this.keyPair.getPublicKeyBuffer())},d.prototype.getFingerprint=function(){return this.getIdentifier().slice(0,4)},d.prototype.getNetwork=function(){return this.keyPair.getNetwork()},d.prototype.getPublicKeyBuffer=function(){return this.keyPair.getPublicKeyBuffer()},d.prototype.neutered=function(){var e=new d(new l(null,this.keyPair.Q,{network:this.keyPair.network}),this.chainCode);return e.depth=this.depth,e.index=this.index,e.parentFingerprint=this.parentFingerprint,e},d.prototype.sign=function(e){return this.keyPair.sign(e)},d.prototype.verify=function(e,t){return this.keyPair.verify(e,t)},d.prototype.toBase58=function(e){if(void 0!==e)throw new TypeError("Unsupported argument in 2.0.0");var t=this.keyPair.network,r=this.isNeutered()?t.bip32.public:t.bip32.private,o=n.allocUnsafe(78);return o.writeUInt32BE(r,0),o.writeUInt8(this.depth,4),o.writeUInt32BE(this.parentFingerprint,5),o.writeUInt32BE(this.index,9),this.chainCode.copy(o,13),this.isNeutered()?this.keyPair.getPublicKeyBuffer().copy(o,45):(o.writeUInt8(0,45),this.keyPair.d.toBuffer(32).copy(o,46)),i.encode(o)},d.prototype.derive=function(e){a(u.UInt32,e);var t=e>=d.HIGHEST_BIT,r=n.allocUnsafe(37);if(t){if(this.isNeutered())throw new TypeError("Could not derive hardened child key");r[0]=0,this.keyPair.d.toBuffer(32).copy(r,1),r.writeUInt32BE(e,33)}else this.keyPair.getPublicKeyBuffer().copy(r,0),r.writeUInt32BE(e,33);var i,o=s("sha512",this.chainCode).update(r).digest(),c=o.slice(0,32),h=o.slice(32),y=f.fromBuffer(c);if(y.compareTo(p.n)>=0)return this.derive(e+1);if(this.isNeutered()){var g=p.G.multiply(y).add(this.keyPair.Q);if(p.isInfinity(g))return this.derive(e+1);i=new l(null,g,{network:this.keyPair.network})}else{var m=y.add(this.keyPair.d).mod(p.n);if(0===m.signum())return this.derive(e+1);i=new l(m,null,{network:this.keyPair.network})}var b=new d(i,h);return b.depth=this.depth+1,b.index=e,b.parentFingerprint=this.getFingerprint().readUInt32BE(0),b},d.prototype.deriveHardened=function(e){return a(u.UInt31,e),this.derive(e+d.HIGHEST_BIT)},d.prototype.isNeutered=function(){return!this.keyPair.d},d.prototype.derivePath=function(e){a(u.BIP32Path,e);var t=e.split("/");if("m"===t[0]){if(this.parentFingerprint)throw new Error("Not a master node");t=t.slice(1)}return t.reduce(function(e,t){var r;return"'"===t.slice(-1)?(r=parseInt(t.slice(0,-1),10),e.deriveHardened(r)):(r=parseInt(t,10),e.derive(r))},this)},e.exports=d},function(e,t,r){var n=r(2).Buffer,i=r(240),o=r(105),s=r(28),a=r(232),u=r(124),c=r(42),f=r(25),l=r(31),h=a.types,p=[a.types.P2PKH,a.types.P2PK,a.types.MULTISIG],d=p.concat([a.types.P2WPKH,a.types.P2WSH]),y=r(239),g=r(243),m=r(238);function b(e){return-1!==p.indexOf(e)}function v(e){return-1!==d.indexOf(e)}function _(e,t){if(0===e.length&&0===t.length)return{};var r,n,i,u,c,f,l,p,d,y,g=!1,m=!1,_=!1,w=s.decompile(e);a.classifyInput(w,!0)===h.P2SH&&(_=!0,c=w[w.length-1],p=a.classifyOutput(c),r=a.scriptHash.output.encode(o.hash160(c)),n=h.P2SH,u=c);var S=a.classifyWitness(t,!0);if(S===h.P2WSH){if(f=t[t.length-1],l=a.classifyOutput(f),m=!0,g=!0,0===e.length){if(r=a.witnessScriptHash.output.encode(o.sha256(f)),n=h.P2WSH,void 0!==c)throw new Error("Redeem script given when unnecessary")}else{if(!c)throw new Error("No redeemScript provided for P2WSH, but scriptSig non-empty");if(d=a.witnessScriptHash.output.encode(o.sha256(f)),!c.equals(d))throw new Error("Redeem script didn't match witnessScript")}if(!b(a.classifyOutput(f)))throw new Error("unsupported witness script");u=f,i=l,y=t.slice(0,-1)}else if(S===h.P2WPKH){g=!0;var k=t[t.length-1],E=o.hash160(k);if(0===e.length){if(r=a.witnessPubKeyHash.output.encode(E),n=h.P2WPKH,void 0!==c)throw new Error("Redeem script given when unnecessary")}else{if(!c)throw new Error("No redeemScript provided for P2WPKH, but scriptSig wasn't empty");if(d=a.witnessPubKeyHash.output.encode(E),!c.equals(d))throw new Error("Redeem script did not have the right witness program")}i=h.P2PKH,y=t}else if(c){if(!v(p))throw new Error("Bad redeemscript!");u=c,i=p,y=w.slice(0,-1)}else n=i=a.classifyInput(e),y=w;var A=function(e,t,r){var n=[],i=[];switch(e){case h.P2PKH:n=t.slice(1),i=t.slice(0,1);break;case h.P2PK:n[0]=r?a.pubKey.output.decode(r):void 0,i=t.slice(0,1);break;case h.MULTISIG:r&&(n=a.multisig.output.decode(r).pubKeys),i=t.slice(1).map(function(e){return 0===e.length?void 0:e})}return{pubKeys:n,signatures:i}}(i,y,u),x={pubKeys:A.pubKeys,signatures:A.signatures,prevOutScript:r,prevOutType:n,signType:i,signScript:u,witness:Boolean(g)};return _&&(x.redeemScript=c,x.redeemScriptType=p),m&&(x.witnessScript=f,x.witnessScriptType=l),x}function w(e,t,r){f(l.Buffer,e);var n=s.decompile(e);t||(t=a.classifyOutput(e));var i=[];switch(t){case h.P2PKH:if(!r)break;var u=n[2],c=o.hash160(r);u.equals(c)&&(i=[r]);break;case h.P2WPKH:if(!r)break;var p=n[1],d=o.hash160(r);p.equals(d)&&(i=[r]);break;case h.P2PK:i=n.slice(0,1);break;case h.MULTISIG:i=n.slice(1,-2);break;default:return{scriptType:t}}return{pubKeys:i,scriptType:t,signatures:i.map(function(){})}}function S(e,t){if(e.prevOutType){if(e.prevOutType!==h.P2SH)throw new Error("PrevOutScript must be P2SH");if(!s.decompile(e.prevOutScript)[1].equals(t))throw new Error("Inconsistent hash160(RedeemScript)")}}function k(e,t,r,n,i){var u,c,f,l,p,d,y,g,m,b=!1,v=!1,_=!1;if(r&&i){if(p=o.hash160(r),y=o.sha256(i),S(e,p),!r.equals(a.witnessScriptHash.output.encode(y)))throw new Error("Witness script inconsistent with redeem script");if(!(u=w(i,void 0,t)).pubKeys)throw new Error('WitnessScript not supported "'+s.toASM(r)+'"');c=a.types.P2SH,f=a.scriptHash.output.encode(p),b=v=_=!0,l=a.types.P2WSH,g=d=u.scriptType,m=i}else if(r){if(S(e,p=o.hash160(r)),!(u=w(r,void 0,t)).pubKeys)throw new Error('RedeemScript not supported "'+s.toASM(r)+'"');c=a.types.P2SH,f=a.scriptHash.output.encode(p),b=!0,m=r,v=(g=l=u.scriptType)===a.types.P2WPKH}else if(i){if(function(e,t){if(e.prevOutType){if(e.prevOutType!==h.P2WSH)throw new Error("PrevOutScript must be P2WSH");if(!s.decompile(e.prevOutScript)[1].equals(t))throw new Error("Inconsistent sha25(WitnessScript)")}}(e,y=o.sha256(i)),!(u=w(i,void 0,t)).pubKeys)throw new Error('WitnessScript not supported "'+s.toASM(r)+'"');c=a.types.P2WSH,f=a.witnessScriptHash.output.encode(y),v=_=!0,g=d=u.scriptType,m=i}else if(e.prevOutType){if(e.prevOutType===h.P2SH||e.prevOutType===h.P2WSH)throw new Error("PrevOutScript is "+e.prevOutType+", requires redeemScript");if(c=e.prevOutType,f=e.prevOutScript,!(u=w(e.prevOutScript,e.prevOutType,t)).pubKeys)return;v=e.prevOutType===h.P2WPKH,g=c,m=f}else u=w(f=a.pubKeyHash.output.encode(o.hash160(t)),h.P2PKH,t),v=!1,g=c=h.P2PKH,m=f;g===h.P2WPKH&&(m=a.pubKeyHash.output.encode(a.witnessPubKeyHash.output.decode(m))),b&&(e.redeemScript=r,e.redeemScriptType=l),_&&(e.witnessScript=i,e.witnessScriptType=d),e.pubKeys=u.pubKeys,e.signatures=u.signatures,e.signScript=m,e.signType=g,e.prevOutScript=f,e.prevOutType=c,e.witness=v}function E(e,t,r,i){if(e===h.P2PKH){if(1===t.length&&n.isBuffer(t[0])&&1===r.length)return a.pubKeyHash.input.encodeStack(t[0],r[0])}else if(e===h.P2PK){if(1===t.length&&n.isBuffer(t[0]))return a.pubKey.input.encodeStack(t[0])}else{if(e!==h.MULTISIG)throw new Error("Not yet supported");if(t.length>0)return t=t.map(function(e){return e||c.OP_0}),i||(t=t.filter(function(e){return e!==c.OP_0})),a.multisig.input.encodeStack(t)}if(!i)throw new Error("Not enough signatures provided");return[]}function A(e,t){this.prevTxMap={},this.network=e||u.bitcoin,this.maximumFeeRate=t||2500,this.inputs=[],this.tx=new m}function x(e){return void 0!==e.prevOutScript&&void 0!==e.signScript&&void 0!==e.pubKeys&&void 0!==e.signatures&&e.signatures.length===e.pubKeys.length&&e.pubKeys.length>0&&(!1===e.witness||!0===e.witness&&void 0!==e.value)}function I(e){return e.readUInt8(e.length-1)}A.prototype.setLockTime=function(e){if(f(l.UInt32,e),this.inputs.some(function(e){return!!e.signatures&&e.signatures.some(function(e){return e})}))throw new Error("No, this would invalidate signatures");this.tx.locktime=e},A.prototype.setVersion=function(e){f(l.UInt32,e),this.tx.version=e},A.fromTransaction=function(e,t){var r=new A(t);return r.setVersion(e.version),r.setLockTime(e.locktime),e.outs.forEach(function(e){r.addOutput(e.script,e.value)}),e.ins.forEach(function(e){r.__addInputUnsafe(e.hash,e.index,{sequence:e.sequence,script:e.script,witness:e.witness})}),r.inputs.forEach(function(t,r){!function(e,t,r){if(e.redeemScriptType===h.MULTISIG&&e.redeemScript&&e.pubKeys.length!==e.signatures.length){var n=e.signatures.concat();e.signatures=e.pubKeys.map(function(i){var o,s=y.fromPublicKeyBuffer(i);return n.some(function(i,a){if(!i)return!1;var u=g.parseScriptSignature(i),c=t.hashForSignature(r,e.redeemScript,u.hashType);return!!s.verify(c,u.signature)&&(n[a]=void 0,o=i,!0)}),o})}}(t,e,r)}),r},A.prototype.addInput=function(e,t,r,i){if(!this.__canModifyInputs())throw new Error("No, this would invalidate signatures");var o;if("string"==typeof e)e=n.from(e,"hex").reverse();else if(e instanceof m){var s=e.outs[t];i=s.script,o=s.value,e=e.getHash()}return this.__addInputUnsafe(e,t,{sequence:r,prevOutScript:i,value:o})},A.prototype.__addInputUnsafe=function(e,t,r){if(m.isCoinbaseHash(e))throw new Error("coinbase inputs not supported");var n=e.toString("hex")+":"+t;if(void 0!==this.prevTxMap[n])throw new Error("Duplicate TxOut: "+n);var i={};if(void 0!==r.script&&(i=_(r.script,r.witness||[])),void 0!==r.value&&(i.value=r.value),!i.prevOutScript&&r.prevOutScript){var o;if(!i.pubKeys&&!i.signatures){var s=w(r.prevOutScript);s.pubKeys&&(i.pubKeys=s.pubKeys,i.signatures=s.signatures),o=s.scriptType}i.prevOutScript=r.prevOutScript,i.prevOutType=o||a.classifyOutput(r.prevOutScript)}var u=this.tx.addInput(e,t,r.sequence,r.scriptSig);return this.inputs[u]=i,this.prevTxMap[n]=u,u},A.prototype.addOutput=function(e,t){if(!this.__canModifyOutputs())throw new Error("No, this would invalidate signatures");return"string"==typeof e&&(e=i.toOutputScript(e,this.network)),this.tx.addOutput(e,t)},A.prototype.build=function(){return this.__build(!1)},A.prototype.buildIncomplete=function(){return this.__build(!0)},A.prototype.__build=function(e){if(!e){if(!this.tx.ins.length)throw new Error("Transaction has no inputs");if(!this.tx.outs.length)throw new Error("Transaction has no outputs")}var t=this.tx.clone();if(this.inputs.forEach(function(r,n){if(!(r.witnessScriptType||r.redeemScriptType||r.prevOutType||e))throw new Error("Transaction is not complete");var i=function(e,t){var r=e.prevOutType,n=[],i=[];b(r)&&(n=E(r,e.signatures,e.pubKeys,t));var o=!1;if(r===a.types.P2SH){if(!t&&!v(e.redeemScriptType))throw new Error("Impossible to sign this type");b(e.redeemScriptType)&&(n=E(e.redeemScriptType,e.signatures,e.pubKeys,t)),e.redeemScriptType&&(o=!0,r=e.redeemScriptType)}switch(r){case a.types.P2WPKH:i=E(a.types.P2PKH,e.signatures,e.pubKeys,t);break;case a.types.P2WSH:if(!t&&!b(e.witnessScriptType))throw new Error("Impossible to sign this type");b(e.witnessScriptType)&&((i=E(e.witnessScriptType,e.signatures,e.pubKeys,t)).push(e.witnessScript),r=e.witnessScriptType)}return o&&n.push(e.redeemScript),{type:r,script:s.compile(n),witness:i}}(r,e);if(!e&&!b(i.type)&&i.type!==a.types.P2WPKH)throw new Error(i.type+" not supported");t.setInputScript(n,i.script),t.setWitness(n,i.witness)}),!e&&this.__overMaximumFees(t.virtualSize()))throw new Error("Transaction has absurd fees");return t},A.prototype.sign=function(e,t,r,i,o,s){if(t.network&&t.network!==this.network)throw new TypeError("Inconsistent network");if(!this.inputs[e])throw new Error("No input at index: "+e);i=i||m.SIGHASH_ALL;var a=this.inputs[e];if(void 0!==a.redeemScript&&r&&!a.redeemScript.equals(r))throw new Error("Inconsistent redeemScript");var u,c=t.publicKey||t.getPublicKeyBuffer();if(!x(a)){if(void 0!==o){if(void 0!==a.value&&a.value!==o)throw new Error("Input didn't match witnessValue");f(l.Satoshi,o),a.value=o}if(x(a)||k(a,c,r,0,s),!x(a))throw Error(a.prevOutType+" not supported")}if(u=a.witness?this.tx.hashForWitnessV0(e,a.signScript,a.value,i):this.tx.hashForSignature(e,a.signScript,i),!a.pubKeys.some(function(e,r){if(!c.equals(e))return!1;if(a.signatures[r])throw new Error("Signature already exists");if(33!==c.length&&a.signType===h.P2WPKH)throw new Error("BIP143 rejects uncompressed public keys in P2WPKH or P2WSH");var o=t.sign(u);return n.isBuffer(o)&&(o=g.fromRSBuffer(o)),a.signatures[r]=o.toScriptSignature(i),!0}))throw new Error("Key pair cannot sign for this input")},A.prototype.__canModifyInputs=function(){return this.inputs.every(function(e){return void 0===e.signatures||e.signatures.every(function(e){return!e||I(e)&m.SIGHASH_ANYONECANPAY})})},A.prototype.__canModifyOutputs=function(){var e=this.tx.ins.length,t=this.tx.outs.length;return this.inputs.every(function(r){return void 0===r.signatures||r.signatures.every(function(r){if(!r)return!0;var n=31&I(r);return n===m.SIGHASH_NONE||(n===m.SIGHASH_SINGLE?e<=t:void 0)})})},A.prototype.__overMaximumFees=function(e){return(this.inputs.reduce(function(e,t){return e+(t.value>>>0)},0)-this.tx.outs.reduce(function(e,t){return e+t.value},0))/e>this.maximumFeeRate},e.exports=A},function(e,t,r){const n=r(173),i=r(126),o=r(2).Buffer;var s=e.exports=function(e){var t=[{name:"nonce",default:o.alloc(0)},{name:"balance",default:o.alloc(0)},{name:"stateRoot",length:32,default:n.SHA3_RLP},{name:"codeHash",length:32,default:n.SHA3_NULL}];n.defineProperties(this,t,e)};s.prototype.serialize=function(){return i.encode(this.raw)},s.prototype.isContract=function(){return this.codeHash.toString("hex")!==n.SHA3_NULL_S},s.prototype.getCode=function(e,t){this.isContract()?e.getRaw(this.codeHash,t):t(null,o.alloc(0))},s.prototype.setCode=function(e,t,r){var i=this;this.codeHash=n.sha3(t),this.codeHash.toString("hex")!==n.SHA3_NULL_S?e.putRaw(this.codeHash,t,function(e){r(e,i.codeHash)}):r(null,o.alloc(0))},s.prototype.getStorage=function(e,t,r){var n=e.copy();n.root=this.stateRoot,n.get(t,r)},s.prototype.setStorage=function(e,t,r,n){var i=this,o=e.copy();o.root=i.stateRoot,o.put(t,r,function(e){if(e)return n();i.stateRoot=o.root,n()})},s.prototype.isEmpty=function(){return""===this.balance.toString("hex")&&""===this.nonce.toString("hex")&&this.stateRoot.toString("hex")===n.SHA3_RLP_S&&this.codeHash.toString("hex")===n.SHA3_NULL_S}},function(e,t,r){"use strict";e.exports=r(820)(r(823))},function(e,t,r){"use strict";var n=r(821),i=r(822);e.exports=function(e){var t=n(e),r=i(e);return function(e,n){switch("string"==typeof e?e.toLowerCase():e){case"keccak224":return new t(1152,448,null,224,n);case"keccak256":return new t(1088,512,null,256,n);case"keccak384":return new t(832,768,null,384,n);case"keccak512":return new t(576,1024,null,512,n);case"sha3-224":return new t(1152,448,6,224,n);case"sha3-256":return new t(1088,512,6,256,n);case"sha3-384":return new t(832,768,6,384,n);case"sha3-512":return new t(576,1024,6,512,n);case"shake128":return new r(1344,256,31,n);case"shake256":return new r(1088,512,31,n);default:throw new Error("Invald algorithm: "+e)}}}},function(e,t,r){"use strict";var n=r(2).Buffer,i=r(90).Transform,o=r(5);e.exports=function(e){function t(t,r,n,o,s){i.call(this,s),this._rate=t,this._capacity=r,this._delimitedSuffix=n,this._hashBitLength=o,this._options=s,this._state=new e,this._state.initialize(t,r),this._finalized=!1}return o(t,i),t.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(e){n=e}r(n)},t.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)},t.prototype.update=function(e,t){if(!n.isBuffer(e)&&"string"!=typeof e)throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Digest already called");return n.isBuffer(e)||(e=n.from(e,t)),this._state.absorb(e),this},t.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0,this._delimitedSuffix&&this._state.absorbLastFewBits(this._delimitedSuffix);var t=this._state.squeeze(this._hashBitLength/8);return void 0!==e&&(t=t.toString(e)),this._resetState(),t},t.prototype._resetState=function(){return this._state.initialize(this._rate,this._capacity),this},t.prototype._clone=function(){var e=new t(this._rate,this._capacity,this._delimitedSuffix,this._hashBitLength,this._options);return this._state.copy(e._state),e._finalized=this._finalized,e},t}},function(e,t,r){"use strict";var n=r(2).Buffer,i=r(90).Transform,o=r(5);e.exports=function(e){function t(t,r,n,o){i.call(this,o),this._rate=t,this._capacity=r,this._delimitedSuffix=n,this._options=o,this._state=new e,this._state.initialize(t,r),this._finalized=!1}return o(t,i),t.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(e){n=e}r(n)},t.prototype._flush=function(){},t.prototype._read=function(e){this.push(this.squeeze(e))},t.prototype.update=function(e,t){if(!n.isBuffer(e)&&"string"!=typeof e)throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Squeeze already called");return n.isBuffer(e)||(e=n.from(e,t)),this._state.absorb(e),this},t.prototype.squeeze=function(e,t){this._finalized||(this._finalized=!0,this._state.absorbLastFewBits(this._delimitedSuffix));var r=this._state.squeeze(e);return void 0!==t&&(r=r.toString(t)),r},t.prototype._resetState=function(){return this._state.initialize(this._rate,this._capacity),this},t.prototype._clone=function(){var e=new t(this._rate,this._capacity,this._delimitedSuffix,this._options);return this._state.copy(e._state),e._finalized=this._finalized,e},t}},function(e,t,r){"use strict";var n=r(2).Buffer,i=r(824);function o(){this.state=[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],this.blockSize=null,this.count=0,this.squeezing=!1}o.prototype.initialize=function(e,t){for(var r=0;r<50;++r)this.state[r]=0;this.blockSize=e/8,this.count=0,this.squeezing=!1},o.prototype.absorb=function(e){for(var t=0;t>>this.count%4*8&255,this.count+=1,this.count===this.blockSize&&(i.p1600(this.state),this.count=0);return t},o.prototype.copy=function(e){for(var t=0;t<50;++t)e.state[t]=this.state[t];e.blockSize=this.blockSize,e.count=this.count,e.squeezing=this.squeezing},e.exports=o},function(e,t,r){"use strict";var n=[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];t.p1600=function(e){for(var t=0;t<24;++t){var r=e[0]^e[10]^e[20]^e[30]^e[40],i=e[1]^e[11]^e[21]^e[31]^e[41],o=e[2]^e[12]^e[22]^e[32]^e[42],s=e[3]^e[13]^e[23]^e[33]^e[43],a=e[4]^e[14]^e[24]^e[34]^e[44],u=e[5]^e[15]^e[25]^e[35]^e[45],c=e[6]^e[16]^e[26]^e[36]^e[46],f=e[7]^e[17]^e[27]^e[37]^e[47],l=e[8]^e[18]^e[28]^e[38]^e[48],h=e[9]^e[19]^e[29]^e[39]^e[49],p=l^(o<<1|s>>>31),d=h^(s<<1|o>>>31),y=e[0]^p,g=e[1]^d,m=e[10]^p,b=e[11]^d,v=e[20]^p,_=e[21]^d,w=e[30]^p,S=e[31]^d,k=e[40]^p,E=e[41]^d;p=r^(a<<1|u>>>31),d=i^(u<<1|a>>>31);var A=e[2]^p,x=e[3]^d,I=e[12]^p,T=e[13]^d,B=e[22]^p,C=e[23]^d,P=e[32]^p,O=e[33]^d,R=e[42]^p,N=e[43]^d;p=o^(c<<1|f>>>31),d=s^(f<<1|c>>>31);var L=e[4]^p,K=e[5]^d,j=e[14]^p,M=e[15]^d,D=e[24]^p,U=e[25]^d,F=e[34]^p,q=e[35]^d,H=e[44]^p,z=e[45]^d;p=a^(l<<1|h>>>31),d=u^(h<<1|l>>>31);var V=e[6]^p,G=e[7]^d,W=e[16]^p,$=e[17]^d,Y=e[26]^p,J=e[27]^d,X=e[36]^p,Z=e[37]^d,Q=e[46]^p,ee=e[47]^d;p=c^(r<<1|i>>>31),d=f^(i<<1|r>>>31);var te=e[8]^p,re=e[9]^d,ne=e[18]^p,ie=e[19]^d,oe=e[28]^p,se=e[29]^d,ae=e[38]^p,ue=e[39]^d,ce=e[48]^p,fe=e[49]^d,le=y,he=g,pe=b<<4|m>>>28,de=m<<4|b>>>28,ye=v<<3|_>>>29,ge=_<<3|v>>>29,me=S<<9|w>>>23,be=w<<9|S>>>23,ve=k<<18|E>>>14,_e=E<<18|k>>>14,we=A<<1|x>>>31,Se=x<<1|A>>>31,ke=T<<12|I>>>20,Ee=I<<12|T>>>20,Ae=B<<10|C>>>22,xe=C<<10|B>>>22,Ie=O<<13|P>>>19,Te=P<<13|O>>>19,Be=R<<2|N>>>30,Ce=N<<2|R>>>30,Pe=K<<30|L>>>2,Oe=L<<30|K>>>2,Re=j<<6|M>>>26,Ne=M<<6|j>>>26,Le=U<<11|D>>>21,Ke=D<<11|U>>>21,je=F<<15|q>>>17,Me=q<<15|F>>>17,De=z<<29|H>>>3,Ue=H<<29|z>>>3,Fe=V<<28|G>>>4,qe=G<<28|V>>>4,He=$<<23|W>>>9,ze=W<<23|$>>>9,Ve=Y<<25|J>>>7,Ge=J<<25|Y>>>7,We=X<<21|Z>>>11,$e=Z<<21|X>>>11,Ye=ee<<24|Q>>>8,Je=Q<<24|ee>>>8,Xe=te<<27|re>>>5,Ze=re<<27|te>>>5,Qe=ne<<20|ie>>>12,et=ie<<20|ne>>>12,tt=se<<7|oe>>>25,rt=oe<<7|se>>>25,nt=ae<<8|ue>>>24,it=ue<<8|ae>>>24,ot=ce<<14|fe>>>18,st=fe<<14|ce>>>18;e[0]=le^~ke&Le,e[1]=he^~Ee&Ke,e[10]=Fe^~Qe&ye,e[11]=qe^~et&ge,e[20]=we^~Re&Ve,e[21]=Se^~Ne&Ge,e[30]=Xe^~pe&Ae,e[31]=Ze^~de&xe,e[40]=Pe^~He&tt,e[41]=Oe^~ze&rt,e[2]=ke^~Le&We,e[3]=Ee^~Ke&$e,e[12]=Qe^~ye&Ie,e[13]=et^~ge&Te,e[22]=Re^~Ve&nt,e[23]=Ne^~Ge&it,e[32]=pe^~Ae&je,e[33]=de^~xe&Me,e[42]=He^~tt&me,e[43]=ze^~rt&be,e[4]=Le^~We&ot,e[5]=Ke^~$e&st,e[14]=ye^~Ie&De,e[15]=ge^~Te&Ue,e[24]=Ve^~nt&ve,e[25]=Ge^~it&_e,e[34]=Ae^~je&Ye,e[35]=xe^~Me&Je,e[44]=tt^~me&Be,e[45]=rt^~be&Ce,e[6]=We^~ot&le,e[7]=$e^~st&he,e[16]=Ie^~De&Fe,e[17]=Te^~Ue&qe,e[26]=nt^~ve&we,e[27]=it^~_e&Se,e[36]=je^~Ye&Xe,e[37]=Me^~Je&Ze,e[46]=me^~Be&Pe,e[47]=be^~Ce&Oe,e[8]=ot^~le&ke,e[9]=st^~he&Ee,e[18]=De^~Fe&Qe,e[19]=Ue^~qe&et,e[28]=ve^~we&Re,e[29]=_e^~Se&Ne,e[38]=Ye^~Xe&pe,e[39]=Je^~Ze&de,e[48]=Be^~Pe&He,e[49]=Ce^~Oe&ze,e[0]^=n[2*t],e[1]^=n[2*t+1]}}},function(e,t,r){"use strict";e.exports=r(417)(r(828))},function(e,t,r){"use strict";(function(e){var r=Object.prototype.toString;t.isArray=function(e,t){if(!Array.isArray(e))throw TypeError(t)},t.isBoolean=function(e,t){if("[object Boolean]"!==r.call(e))throw TypeError(t)},t.isBuffer=function(t,r){if(!e.isBuffer(t))throw TypeError(r)},t.isFunction=function(e,t){if("[object Function]"!==r.call(e))throw TypeError(t)},t.isNumber=function(e,t){if("[object Number]"!==r.call(e))throw TypeError(t)},t.isObject=function(e,t){if("[object Object]"!==r.call(e))throw TypeError(t)},t.isBufferLength=function(e,t,r){if(e.length!==t)throw RangeError(r)},t.isBufferLength2=function(e,t,r,n){if(e.length!==t&&e.length!==r)throw RangeError(n)},t.isLengthGTZero=function(e,t){if(0===e.length)throw RangeError(t)},t.isNumberInInterval=function(e,t,r,n){if(e<=t||e>=r)throw RangeError(n)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";var n=r(2).Buffer,i=r(230),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,u=0;a>1&&0===s[u]&&!(128&s[u+1]);--a,++u);return i.encode(t.slice(o),s.slice(u))},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 u=o;if(o+=a,2===e[o++]){var c=e[o++];if(128&c){if(o+(s=c-128)>i)return;for(;s>0&&0===e[o];o+=1,s-=1);for(c=0;s>0;o+=1,s-=1)c=(c<<8)+e[o]}if(!(c>i-o)){var f=o;for(o+=c;a>0&&0===e[u];a-=1,u+=1);if(!(a>32)){var l=e.slice(u,u+a);for(l.copy(t,32-l.length);c>0&&0===e[f];c-=1,f+=1);if(!(c>32)){var h=e.slice(f,f+c);return h.copy(r,32-h.length),{r:t,s:r}}}}}}}}}},function(e,t,r){"use strict";var n=r(2).Buffer,i=r(123),o=r(55),s=r(56).ec,a=r(245),u=new s("secp256k1"),c=u.curve;function f(e){var t=e[0];switch(t){case 2:case 3:return 33!==e.length?null:function(e,t){var r=new o(t);if(r.cmp(c.p)>=0)return null;var n=(r=r.toRed(c.red)).redSqr().redIMul(r).redIAdd(c.b).redSqrt();return 3===e!==n.isOdd()&&(n=n.redNeg()),u.keyPair({pub:{x:r,y:n}})}(t,e.slice(1,33));case 4:case 6:case 7:return 65!==e.length?null:function(e,t,r){var n=new o(t),i=new o(r);if(n.cmp(c.p)>=0||i.cmp(c.p)>=0)return null;if(n=n.toRed(c.red),i=i.toRed(c.red),(6===e||7===e)&&i.isOdd()!==(7===e))return null;var s=n.redSqr().redIMul(n);return i.redSqr().redISub(s.redIAdd(c.b)).isZero()?u.keyPair({pub:{x:n,y:i}}):null}(t,e.slice(1,33),e.slice(33,65));default:return null}}t.privateKeyVerify=function(e){var t=new o(e);return t.cmp(c.n)<0&&!t.isZero()},t.privateKeyExport=function(e,t){var r=new o(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(a.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return n.from(u.keyFromPrivate(e).getPublic(t,!0))},t.privateKeyNegate=function(e){var t=new o(e);return t.isZero()?n.alloc(32):c.n.sub(t).umod(c.n).toArrayLike(n,"be",32)},t.privateKeyModInverse=function(e){var t=new o(e);if(t.cmp(c.n)>=0||t.isZero())throw new Error(a.EC_PRIVATE_KEY_RANGE_INVALID);return t.invm(c.n).toArrayLike(n,"be",32)},t.privateKeyTweakAdd=function(e,t){var r=new o(t);if(r.cmp(c.n)>=0)throw new Error(a.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(r.iadd(new o(e)),r.cmp(c.n)>=0&&r.isub(c.n),r.isZero())throw new Error(a.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return r.toArrayLike(n,"be",32)},t.privateKeyTweakMul=function(e,t){var r=new o(t);if(r.cmp(c.n)>=0||r.isZero())throw new Error(a.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return r.imul(new o(e)),r.cmp(c.n)&&(r=r.umod(c.n)),r.toArrayLike(n,"be",32)},t.publicKeyCreate=function(e,t){var r=new o(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(a.EC_PUBLIC_KEY_CREATE_FAIL);return n.from(u.keyFromPrivate(e).getPublic(t,!0))},t.publicKeyConvert=function(e,t){var r=f(e);if(null===r)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);return n.from(r.getPublic(t,!0))},t.publicKeyVerify=function(e){return null!==f(e)},t.publicKeyTweakAdd=function(e,t,r){var i=f(e);if(null===i)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new o(t)).cmp(c.n)>=0)throw new Error(a.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return n.from(c.g.mul(t).add(i.pub).encode(!0,r))},t.publicKeyTweakMul=function(e,t,r){var i=f(e);if(null===i)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new o(t)).cmp(c.n)>=0||t.isZero())throw new Error(a.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return n.from(i.pub.mul(t).encode(!0,r))},t.publicKeyCombine=function(e,t){for(var r=new Array(e.length),i=0;i=0||r.cmp(c.n)>=0)throw new Error(a.ECDSA_SIGNATURE_PARSE_FAIL);var i=n.from(e);return 1===r.cmp(u.nh)&&c.n.sub(r).toArrayLike(n,"be",32).copy(i,32),i},t.signatureExport=function(e){var t=e.slice(0,32),r=e.slice(32,64);if(new o(t).cmp(c.n)>=0||new o(r).cmp(c.n)>=0)throw new Error(a.ECDSA_SIGNATURE_PARSE_FAIL);return{r:t,s:r}},t.signatureImport=function(e){var t=new o(e.r);t.cmp(c.n)>=0&&(t=new o(0));var r=new o(e.s);return r.cmp(c.n)>=0&&(r=new o(0)),n.concat([t.toArrayLike(n,"be",32),r.toArrayLike(n,"be",32)])},t.sign=function(e,t,r,i){if("function"==typeof r){var s=r;r=function(r){var u=s(e,t,null,i,r);if(!n.isBuffer(u)||32!==u.length)throw new Error(a.ECDSA_SIGN_FAIL);return new o(u)}}var f=new o(t);if(f.cmp(c.n)>=0||f.isZero())throw new Error(a.ECDSA_SIGN_FAIL);var l=u.sign(e,t,{canonical:!0,k:r,pers:i});return{signature:n.concat([l.r.toArrayLike(n,"be",32),l.s.toArrayLike(n,"be",32)]),recovery:l.recoveryParam}},t.verify=function(e,t,r){var n={r:t.slice(0,32),s:t.slice(32,64)},i=new o(n.r),s=new o(n.s);if(i.cmp(c.n)>=0||s.cmp(c.n)>=0)throw new Error(a.ECDSA_SIGNATURE_PARSE_FAIL);if(1===s.cmp(u.nh)||i.isZero()||s.isZero())return!1;var l=f(r);if(null===l)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);return u.verify(e,n,{x:l.pub.x,y:l.pub.y})},t.recover=function(e,t,r,i){var s={r:t.slice(0,32),s:t.slice(32,64)},f=new o(s.r),l=new o(s.s);if(f.cmp(c.n)>=0||l.cmp(c.n)>=0)throw new Error(a.ECDSA_SIGNATURE_PARSE_FAIL);try{if(f.isZero()||l.isZero())throw new Error;var h=u.recoverPubKey(e,s,r);return n.from(h.encode(!0,i))}catch(e){throw new Error(a.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 i=f(e);if(null===i)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);var s=new o(t);if(s.cmp(c.n)>=0||s.isZero())throw new Error(a.ECDH_FAIL);return n.from(i.pub.mul(s).encode(!0,r))}},function(e,t){},function(e){e.exports={_from:"elliptic@^6.2.3",_id:"elliptic@6.4.0",_inBundle:!1,_integrity:"sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=",_location:"/elliptic",_phantomChildren:{},_requested:{type:"range",registry:!0,raw:"elliptic@^6.2.3",name:"elliptic",escapedName:"elliptic",rawSpec:"^6.2.3",saveSpec:null,fetchSpec:"^6.2.3"},_requiredBy:["/browserify-sign","/create-ecdh","/secp256k1"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz",_shasum:"cac9af8762c85836187003c8dfe193e5e2eae5df",_spec:"elliptic@^6.2.3",_where:"/Users/mitra/git/dweb-transports/node_modules/secp256k1",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},bundleDependencies:!1,dependencies:{"bn.js":"^4.4.0",brorand:"^1.0.1","hash.js":"^1.0.0","hmac-drbg":"^1.0.0",inherits:"^2.0.1","minimalistic-assert":"^1.0.0","minimalistic-crypto-utils":"^1.0.0"},deprecated:!1,description:"EC cryptography",devDependencies:{brfs:"^1.4.3",coveralls:"^2.11.3",grunt:"^0.4.5","grunt-browserify":"^5.0.0","grunt-cli":"^1.2.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^8.6.2",istanbul:"^0.4.2",jscs:"^2.9.0",jshint:"^2.6.0",mocha:"^2.1.0"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{jscs:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",jshint:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",lint:"npm run jscs && npm run jshint",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.4.0"}},function(e,t,r){"use strict";var n=t,i=r(55),o=r(81),s=r(418);n.assert=o,n.toArray=s.toArray,n.zero2=s.zero2,n.toHex=s.toHex,n.encode=s.encode,n.getNAF=function(e,t){for(var r=[],n=1<=0;){var o;if(i.isOdd()){var s=i.andln(n-1);o=s>(n>>1)-1?(n>>1)-s:s,i.isubn(o)}else o=0;r.push(o);for(var a=0!==i.cmpn(0)&&0===i.andln(n-1)?t+1:1,u=1;u0||t.cmpn(-i)>0;){var o,s,a,u=e.andln(3)+n&3,c=t.andln(3)+i&3;3===u&&(u=-1),3===c&&(c=-1),o=0==(1&u)?0:3!=(a=e.andln(7)+n&7)&&5!==a||2!==c?u:-u,r[0].push(o),s=0==(1&c)?0:3!=(a=t.andln(7)+i&7)&&5!==a||2!==u?c:-c,r[1].push(s),2*n===o+1&&(n=1-n),2*i===s+1&&(i=1-i),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){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;r0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function c(e,t){this.curve=e,this.type=t,this.precomputed=null}e.exports=u,u.prototype.point=function(){throw new Error("Not implemented")},u.prototype.validate=function(){throw new Error("Not implemented")},u.prototype._fixedNafMul=function(e,t){a(e.precomputed);var r=e._getDoubles(),n=o(t,1),i=(1<=u;t--)c=(c<<1)+n[t];s.push(c)}for(var f=this.jpoint(null,null,null),l=this.jpoint(null,null,null),h=i;h>0;h--){for(u=0;u=0;c--){for(t=0;c>=0&&0===s[c];c--)t++;if(c>=0&&t++,u=u.dblp(t),c<0)break;var f=s[c];a(0!==f),u="affine"===e.type?f>0?u.mixedAdd(i[f-1>>1]):u.mixedAdd(i[-f-1>>1].neg()):f>0?u.add(i[f-1>>1]):u.add(i[-f-1>>1].neg())}return"affine"===e.type?u.toP():u},u.prototype._wnafMulAdd=function(e,t,r,n,i){for(var a=this._wnafT1,u=this._wnafT2,c=this._wnafT3,f=0,l=0;l=1;l-=2){var p=l-1,d=l;if(1===a[p]&&1===a[d]){var y=[t[p],null,null,t[d]];0===t[p].y.cmp(t[d].y)?(y[1]=t[p].add(t[d]),y[2]=t[p].toJ().mixedAdd(t[d].neg())):0===t[p].y.cmp(t[d].y.redNeg())?(y[1]=t[p].toJ().mixedAdd(t[d]),y[2]=t[p].add(t[d].neg())):(y[1]=t[p].toJ().mixedAdd(t[d]),y[2]=t[p].toJ().mixedAdd(t[d].neg()));var g=[-3,-1,-5,-7,0,7,5,1,3],m=s(r[p],r[d]);f=Math.max(m[0].length,f),c[p]=new Array(f),c[d]=new Array(f);for(var b=0;b=0;l--){for(var k=0;l>=0;){var E=!0;for(b=0;b=0&&k++,w=w.dblp(k),l<0)break;for(b=0;b0?A=u[b][x-1>>1]:x<0&&(A=u[b][-x-1>>1].neg()),w="affine"===A.type?w.mixedAdd(A):w.add(A))}}for(l=0;l=Math.ceil((e.bitLength()+1)/t.step)},c.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i=0&&(s=t,a=r),n.negative&&(n=n.neg(),i=i.neg()),s.negative&&(s=s.neg(),a=a.neg()),[{a:n,b:i},{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),u=i.mul(r.b),c=o.mul(n.b);return{k1:e.sub(s).sub(a),k2:u.add(c).neg()}},c.prototype.pointFromX=function(e,t){(e=new o(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 i=n.fromRed().isOdd();return(t&&!i||!t&&i)&&(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":""},f.prototype.isInfinity=function(){return this.inf},f.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)},f.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)},f.prototype.getX=function(){return this.x.fromRed()},f.prototype.getY=function(){return this.y.fromRed()},f.prototype.mul=function(e){return e=new o(e,16),this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},f.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)},f.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)},f.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))},f.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},f.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},s(l,a.BasePoint),c.prototype.jpoint=function(e,t,r){return new l(this,e,t,r)},l.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)},l.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},l.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),u=o.redSub(s);if(0===a.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=a.redSqr(),f=c.redMul(a),l=n.redMul(c),h=u.redSqr().redIAdd(f).redISub(l).redISub(l),p=u.redMul(l.redISub(h)).redISub(o.redMul(f)),d=this.z.redMul(e.z).redMul(a);return this.curve.jpoint(h,p,d)},l.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 u=s.redSqr(),c=u.redMul(s),f=r.redMul(u),l=a.redSqr().redIAdd(c).redISub(f).redISub(f),h=a.redMul(f.redISub(l)).redISub(i.redMul(c)),p=this.z.redMul(s);return this.curve.jpoint(l,h,p)},l.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}return!1},l.prototype.inspect=function(){return this.isInfinity()?"":""},l.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},function(e,t,r){"use strict";var n=r(174),i=r(55),o=r(5),s=n.base,a=r(56).utils;function u(e){s.call(this,"mont",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function c(e,t,r){s.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(t,16),this.z=new i(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}o(u,s),e.exports=u,u.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)},o(c,s.BasePoint),u.prototype.decodePoint=function(e,t){return this.point(a.toArray(e,t),1)},u.prototype.point=function(e,t){return new c(this,e,t)},u.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()),u=t.x.redMul(o.redISub(s).redSqr());return this.curve.point(a,u)},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(174),i=r(56),o=r(55),s=r(5),a=n.base,u=i.utils.assert;function c(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,a.call(this,"edwards",e),this.a=new o(e.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new o(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new o(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),u(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}function f(e,t,r,n,i){a.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 o(t,16),this.y=new o(r,16),this.z=n?new o(n,16):this.curve.one,this.t=i&&new o(i,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()))))}s(c,a),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 o(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),n=this.c2.redSub(this.a.redMul(r)),i=this.one.redSub(this.c2.redMul(this.d).redMul(r)),s=n.redMul(i.redInvm()),a=s.redSqrt();if(0!==a.redSqr().redSub(s).cmp(this.zero))throw new Error("invalid point");var u=a.fromRed().isOdd();return(t&&!u||!t&&u)&&(a=a.redNeg()),this.point(e,a)},c.prototype.pointFromY=function(e,t){(e=new o(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),n=r.redSub(this.one),i=r.redMul(this.d).redAdd(this.one),s=n.redMul(i.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.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)},s(f,a.BasePoint),c.prototype.pointFromJSON=function(e){return f.fromJSON(this,e)},c.prototype.point=function(e,t,r,n){return new f(this,e,t,r,n)},f.fromJSON=function(e,t){return new f(e,t[0],t[1],t[2])},f.prototype.inspect=function(){return this.isInfinity()?"":""},f.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&0===this.y.cmp(this.z)},f.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),u=i.redMul(s),c=o.redMul(a),f=i.redMul(a),l=s.redMul(o);return this.curve.point(u,c,l,f)},f.prototype._projDbl=function(){var e,t,r,n=this.x.redAdd(this.y).redSqr(),i=this.x.redSqr(),o=this.y.redSqr();if(this.curve.twisted){var s=(c=this.curve._mulA(i)).redAdd(o);if(this.zOne)e=n.redSub(i).redSub(o).redMul(s.redSub(this.curve.two)),t=s.redMul(c.redSub(o)),r=s.redSqr().redSub(s).redSub(s);else{var a=this.z.redSqr(),u=s.redSub(a).redISub(a);e=n.redSub(i).redISub(o).redMul(u),t=s.redMul(c.redSub(o)),r=s.redMul(u)}}else{var c=i.redAdd(o);a=this.curve._mulC(this.c.redMul(this.z)).redSqr(),u=c.redSub(a).redSub(a);e=this.curve._mulC(n.redISub(c)).redMul(u),t=this.curve._mulC(c).redMul(i.redISub(o)),r=c.redMul(u)}return this.curve.point(e,t,r)},f.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},f.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),u=r.redAdd(t),c=o.redMul(s),f=a.redMul(u),l=o.redMul(u),h=s.redMul(a);return this.curve.point(c,f,h,l)},f.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),u=i.redSub(a),c=i.redAdd(a),f=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(s),l=n.redMul(u).redMul(f);return this.curve.twisted?(t=n.redMul(c).redMul(s.redSub(this.curve._mulA(o))),r=u.redMul(c)):(t=n.redMul(c).redMul(s.redSub(o)),r=this.curve._mulC(u).redMul(c)),this.curve.point(l,t,r)},f.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},f.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},f.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},f.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},f.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},f.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},f.prototype.getX=function(){return this.normalize(),this.x.fromRed()},f.prototype.getY=function(){return this.normalize(),this.y.fromRed()},f.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},f.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}return!1},f.prototype.toP=f.prototype.normalize,f.prototype.mixedAdd=f.prototype.add},function(e,t,r){"use strict";var n,i=t,o=r(246),s=r(56),a=s.utils.assert;function u(e){"short"===e.type?this.curve=new s.curve.short(e):"edwards"===e.type?this.curve=new s.curve.edwards(e):this.curve=new s.curve.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 c(e,t){Object.defineProperty(i,e,{configurable:!0,enumerable:!0,get:function(){var r=new u(t);return Object.defineProperty(i,e,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=u,c("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"]}),c("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"]}),c("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"]}),c("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"]}),c("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"]}),c("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"]}),c("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(845)}catch(e){n=void 0}c("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){"use strict";t.sha1=r(840),t.sha224=r(841),t.sha256=r(420),t.sha384=r(842),t.sha512=r(421)},function(e,t,r){"use strict";var n=r(71),i=r(125),o=r(419),s=n.rotl32,a=n.sum32,u=n.sum32_5,c=o.ft_1,f=i.BlockHash,l=[1518500249,1859775393,2400959708,3395469782];function h(){if(!(this instanceof h))return new h;f.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}n.inherits(h,f),e.exports=h,h.blockSize=512,h.outSize=160,h.hmacStrength=80,h.padLength=64,h.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 a.iaddn(1),this.keyFromPrivate(a)}},c.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},c.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),f=new i({hash:this.hash,entropy:a,nonce:c,pers:o.pers,persEnc:o.persEnc||"utf8"}),l=this.n.sub(new n(1)),h=0;;h++){var p=o.k?o.k(h):new n(f.generate(this.n.byteLength()));if(!((p=this._truncateToN(p,!0)).cmpn(1)<=0||p.cmp(l)>=0)){var d=this.g.mul(p);if(!d.isInfinity()){var y=d.getX(),g=y.umod(this.n);if(0!==g.cmpn(0)){var m=p.invm(this.n).mul(g.mul(t.getPrivate()).iadd(e));if(0!==(m=m.umod(this.n)).cmpn(0)){var b=(d.getY().isOdd()?1:0)|(0!==y.cmp(g)?2:0);return o.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),b^=1),new u({r:g,s:m,recoveryParam:b})}}}}}},c.prototype.verify=function(e,t,r,i){e=this._truncateToN(new n(e,16)),r=this.keyFromPublic(r,i);var o=(t=new u(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),f=c.mul(e).umod(this.n),l=c.mul(o).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(f,r.getPublic(),l)).isInfinity()&&a.eqXToP(o):!(a=this.g.mulAdd(f,r.getPublic(),l)).isInfinity()&&0===a.getX().umod(this.n).cmp(o)},c.prototype.recoverPubKey=function(e,t,r,i){s((3&r)===r,"The recovery param is more than two bits"),t=new u(t,i);var o=this.n,a=new n(e),c=t.r,f=t.s,l=1&r,h=r>>1;if(c.cmp(this.curve.p.umod(this.curve.n))>=0&&h)throw new Error("Unable to find sencond key candinate");c=h?this.curve.pointFromX(c.add(this.curve.n),l):this.curve.pointFromX(c,l);var p=t.r.invm(o),d=o.sub(a).mul(p).umod(o),y=f.mul(p).umod(o);return this.g.mulAdd(d,c,y)},c.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new u(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(246),i=r(418),o=r(81);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(55),i=r(56).utils,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(e,t){var r=e[t.place++];if(!(128&r))return r;for(var n=15&r,i=0,o=0,s=t.place;o>>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 function(){this.place=0};if(48!==e[r.place++])return!1;if(a(e,r)+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var o=a(e,r),s=e.slice(r.place,o+r.place);if(r.place+=o,2!==e[r.place++])return!1;var u=a(e,r);if(e.length!==u+r.place)return!1;var c=e.slice(r.place,u+r.place);return 0===s[0]&&128&s[1]&&(s=s.slice(1)),0===c[0]&&128&c[1]&&(c=c.slice(1)),this.r=new n(s),this.s=new n(c),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];c(n,t.length),(n=n.concat(t)).push(2),c(n,r.length);var o=n.concat(r),s=[48];return c(s,o.length),s=s.concat(o),i.encode(s,e)}},function(e,t,r){"use strict";var n=r(246),i=r(56),o=i.utils,s=o.assert,a=o.parseBytes,u=r(851),c=r(852);function f(e){if(s("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof f))return new f(e);e=i.curves[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()),u=n.add(s).umod(this.curve.n);return this.makeSignature({R:i,S:u,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;t=0})},intToBuffer:function(e){var r=s(e);return new t(o(r.slice(2)),"hex")},getBinarySize:function(e){if("string"!=typeof e)throw new Error("[ethjs-util] while getting binary size, method getBinarySize requires input 'str' to be type String, got '"+typeof e+"'.");return t.byteLength(e,"utf8")},isHexPrefixed:n,stripHexPrefix:i,padToEven:o,intToHex:s,fromAscii:function(e){for(var t="",r=0;r{const i=e.indexOf(t),o=i.toString();n.push({path:o,value:t}),f._mapFromEthObject(t,{},(e,t)=>{if(e)return r(e);t.forEach(e=>e.path=o+"/"+e.path),n=n.concat(t),r()})},e=>{if(e)return r(e);r(null,n)})}),h=l.util;h.serialize=o(e=>{const t=e.map(e=>e.raw);return s.encode(t)}),h.deserialize=o(e=>{return s.decode(e).map(e=>new a(e))}),h.cid=((e,t,r)=>{"function"==typeof t&&(r=t,t={});const i=(t=t||{}).hashAlg||"keccak-256";void 0===t.version||t.version;n([t=>h.serialize(e,t),(e,t)=>u.digest(e,i,t),o(e=>c("eth-block-list",e,t))],r)}),e.exports=l},function(e,t,r){"use strict";(function(t){const n=r(12),i=r(859);function o(e,t,r,i){if("function"==typeof r&&(i=r,r=void 0),!i)throw new Error("Missing callback");o.digest(e,t,r,(e,o)=>{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){"use strict";(function(t){const n=r(38),i=r(39),o=r(428),s=r(860),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,256)),shake256:a(u(n.shake_256,512)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(861),dblSha2256:(e,r)=>{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(40),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;function o(e){if(!i)throw new Error("Please use a browser with webcrypto support");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(41),i=r(428).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(416),i=r(247)("eth-state-trie",n);e.exports=i},function(e,t,r){(function(t){const n=r(126),i=r(173);function o(e,t,r){if(Array.isArray(e))this.parseNode(e);else if(this.type=e,"branch"===e){var n=t;this.raw=Array.apply(null,Array(17)),n&&n.forEach(function(e){this.set.apply(this,e)})}else this.raw=Array(2),this.setValue(r),this.setKey(t)}function s(e,t){return e.length%2?e.unshift(1):(e.unshift(0),e.unshift(0)),t&&(e[0]+=2),e}function a(e){return e[0]%2?e.slice(1):e.slice(2)}function u(e){return e[0]>1}function c(e){for(var r=new t(e),n=[],i=0;i>4,n[++o]=r[i]%16}return n}function f(e){for(var r=new t(e.length/2),n=0;n0){var r=this.raw.slice();this.v=this._chainId,this.r=0,this.s=0,t=this.raw,this.raw=r}else t=this.raw.slice(0,6);return n.rlphash(t)},e.prototype.getChainId=function(){return this._chainId},e.prototype.getSenderAddress=function(){if(this._from)return this._from;var e=this.getSenderPublicKey();return this._from=n.publicToAddress(e),this._from},e.prototype.getSenderPublicKey=function(){if(!(this._senderPubKey&&this._senderPubKey.length||this.verifySignature()))throw new Error("Invalid Signature");return this._senderPubKey},e.prototype.verifySignature=function(){var e=this.hash(!1);if(this._homestead&&1===new o(this.s).cmp(s))return!1;try{var t=n.bufferToInt(this.v);this._chainId>0&&(t-=2*this._chainId+8),this._senderPubKey=n.ecrecover(e,t,this.r,this.s)}catch(e){return!1}return!!this._senderPubKey},e.prototype.sign=function(e){var t=this.hash(!1),r=n.ecsign(t,e);this._chainId>0&&(r.v+=2*this._chainId+8),Object.assign(this,r)},e.prototype.getDataFee=function(){for(var e=this.raw[5],t=new o(0),r=0;r0&&t.push(["gas limit is too low. Need at least "+this.getBaseFee()]),void 0===e||!1===e?0===t.length:t.join(" ")},e}();e.exports=a}).call(this,r(0).Buffer)},function(e){e.exports={genesisGasLimit:{v:5e3,d:"Gas limit of the Genesis block."},genesisDifficulty:{v:17179869184,d:"Difficulty of the Genesis block."},genesisNonce:{v:"0x0000000000000042",d:"the geneis nonce"},genesisExtraData:{v:"0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",d:"extra data "},genesisHash:{v:"0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",d:"genesis hash"},genesisStateRoot:{v:"0xd7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544",d:"the genesis state root"},minGasLimit:{v:5e3,d:"Minimum the gas limit may ever be."},gasLimitBoundDivisor:{v:1024,d:"The bound divisor of the gas limit, used in update calculations."},minimumDifficulty:{v:131072,d:"The minimum that the difficulty may ever be."},difficultyBoundDivisor:{v:2048,d:"The bound divisor of the difficulty, used in the update calculations."},durationLimit:{v:13,d:"The decision boundary on the blocktime duration used to determine whether difficulty should go up or not."},maximumExtraDataSize:{v:32,d:"Maximum size extra data may be after Genesis."},epochDuration:{v:3e4,d:"Duration between proof-of-work epochs."},stackLimit:{v:1024,d:"Maximum size of VM stack allowed."},callCreateDepth:{v:1024,d:"Maximum depth of call/create stack."},tierStepGas:{v:[0,2,3,5,8,10,20],d:"Once per operation, for a selection of them."},expGas:{v:10,d:"Once per EXP instuction."},expByteGas:{v:10,d:"Times ceil(log256(exponent)) for the EXP instruction."},sha3Gas:{v:30,d:"Once per SHA3 operation."},sha3WordGas:{v:6,d:"Once per word of the SHA3 operation's data."},sloadGas:{v:50,d:"Once per SLOAD operation."},sstoreSetGas:{v:2e4,d:"Once per SSTORE operation if the zeroness changes from zero."},sstoreResetGas:{v:5e3,d:"Once per SSTORE operation if the zeroness does not change from zero."},sstoreRefundGas:{v:15e3,d:"Once per SSTORE operation if the zeroness changes to zero."},jumpdestGas:{v:1,d:"Refunded gas, once per SSTORE operation if the zeroness changes to zero."},logGas:{v:375,d:"Per LOG* operation."},logDataGas:{v:8,d:"Per byte in a LOG* operation's data."},logTopicGas:{v:375,d:"Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas."},createGas:{v:32e3,d:"Once per CREATE operation & contract-creation transaction."},callGas:{v:40,d:"Once per CALL operation & message call transaction."},callStipend:{v:2300,d:"Free gas given at beginning of call."},callValueTransferGas:{v:9e3,d:"Paid for CALL when the value transfor is non-zero."},callNewAccountGas:{v:25e3,d:"Paid for CALL when the destination address didn't exist prior."},suicideRefundGas:{v:24e3,d:"Refunded following a suicide operation."},memoryGas:{v:3,d:"Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL."},quadCoeffDiv:{v:512,d:"Divisor for the quadratic particle of the memory cost equation."},createDataGas:{v:200,d:""},txGas:{v:21e3,d:"Per transaction. NOTE: Not payable on data of calls between transactions."},txCreation:{v:32e3,d:"the cost of creating a contract via tx"},txDataZeroGas:{v:4,d:"Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions."},txDataNonZeroGas:{v:68,d:"Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions."},copyGas:{v:3,d:"Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added."},ecrecoverGas:{v:3e3,d:""},sha256Gas:{v:60,d:""},sha256WordGas:{v:12,d:""},ripemd160Gas:{v:600,d:""},ripemd160WordGas:{v:120,d:""},identityGas:{v:15,d:""},identityWordGas:{v:3,d:""},minerReward:{v:"5000000000000000000",d:"the amount a miner get rewarded for mining a block"},ommerReward:{v:"625000000000000000",d:"The amount of wei a miner of an uncle block gets for being inculded in the blockchain"},niblingReward:{v:"156250000000000000",d:"the amount a miner gets for inculding a uncle"},homeSteadForkNumber:{v:115e4,d:"the block that the Homestead fork started at"},homesteadRepriceForkNumber:{v:2463e3,d:"the block that the Homestead Reprice (EIP150) fork started at"},timebombPeriod:{v:1e5,d:"Exponential difficulty timebomb period"},freeBlockPeriod:{v:2}}},function(e,t,r){"use strict";const n=r(429),i=r(247)("eth-tx-trie",n);e.exports=i},function(e,t,r){"use strict";const n=r(9),i=r(65);e.exports={resolver:{multicodec:"raw",defaultHashAlg:"sha2-256",resolve:(e,t,r)=>{r(null,{value:e,remainderPath:""})},tree:(e,t,r)=>{"function"==typeof t&&(r=t),r(null,[])}},util:{deserialize:(e,t)=>{t(null,e)},serialize:(e,t)=>{t(null,e)},cid:(e,t,r)=>{"function"==typeof t&&(r=t,t={});const o=(t=t||{}).hashAlg||"sha2-256",s=void 0===t.version?1:t.version;i(e,o,(e,t)=>{if(e)return r(e);r(null,new n(s,"raw",t))})}}}},function(e,t,r){"use strict";t.resolver=r(248),t.util=r(430)},function(e,t,r){"use strict";(function(t,n){var i=e.exports;i.version="v"+r(872).version,i.versionGuard=function(e){if(void 0!==e);},i.versionGuard(t._bitcore),t._bitcore=i.version,i.crypto={},i.crypto.BN=r(32),i.crypto.ECDSA=r(431),i.crypto.Hash=r(43),i.crypto.Random=r(179),i.crypto.Point=r(108),i.crypto.Signature=r(67),i.encoding={},i.encoding.Base58=r(177),i.encoding.Base58Check=r(129),i.encoding.BufferReader=r(82),i.encoding.BufferWriter=r(57),i.encoding.Varint=r(900),i.util={},i.util.buffer=r(24),i.util.js=r(29),i.util.preconditions=r(21),i.errors=r(66),i.Address=r(97),i.Block=r(901),i.MerkleBlock=r(435),i.BlockHeader=r(180),i.HDPrivateKey=r(436),i.HDPublicKey=r(437),i.Networks=r(96),i.Opcode=r(249),i.PrivateKey=r(176),i.PublicKey=r(73),i.Script=r(68),i.Transaction=r(178),i.URI=r(903),i.Unit=r(252),i.deps={},i.deps.bnjs=r(74),i.deps.bs58=r(432),i.deps.Buffer=n,i.deps.elliptic=r(72),i.deps._=r(18),i._HDKeyCache=r(253),i.Transaction.sighash=r(83)}).call(this,r(6),r(0).Buffer)},function(e){e.exports={_from:"zcash-bitcore-lib@~0.13.20-rc3",_id:"zcash-bitcore-lib@0.13.20-rc3",_inBundle:!1,_integrity:"sha1-gToPVtz4t2vBQplRvqbRI2xQcAg=",_location:"/zcash-bitcore-lib",_phantomChildren:{},_requested:{type:"range",registry:!0,raw:"zcash-bitcore-lib@~0.13.20-rc3",name:"zcash-bitcore-lib",escapedName:"zcash-bitcore-lib",rawSpec:"~0.13.20-rc3",saveSpec:null,fetchSpec:"~0.13.20-rc3"},_requiredBy:["/ipld-zcash"],_resolved:"https://registry.npmjs.org/zcash-bitcore-lib/-/zcash-bitcore-lib-0.13.20-rc3.tgz",_shasum:"813a0f56dcf8b76bc1429951bea6d1236c507008",_shrinkwrap:{name:"bitcore",version:"0.13.19",dependencies:{"bn.js":{version:"2.0.4",from:"bn.js@=2.0.4",resolved:"https://registry.npmjs.org/bn.js/-/bn.js-2.0.4.tgz"},bs58:{version:"2.0.0",from:"bs58@=2.0.0",resolved:"https://registry.npmjs.org/bs58/-/bs58-2.0.0.tgz"},"buffer-compare":{version:"1.0.0",from:"buffer-compare@=1.0.0",resolved:"https://registry.npmjs.org/buffer-compare/-/buffer-compare-1.0.0.tgz"},elliptic:{version:"3.0.3",from:"elliptic@=3.0.3",resolved:"https://registry.npmjs.org/elliptic/-/elliptic-3.0.3.tgz",dependencies:{brorand:{version:"1.0.5",from:"brorand@^1.0.1",resolved:"https://registry.npmjs.org/brorand/-/brorand-1.0.5.tgz"},"hash.js":{version:"1.0.3",from:"hash.js@=1.0.3",resolved:"https://registry.npmjs.org/hash.js/-/hash.js-1.0.3.tgz"}}},inherits:{version:"2.0.1",from:"inherits@=2.0.1",resolved:"https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz"},lodash:{version:"3.10.1",from:"lodash@=3.10.1",resolved:"https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz"}}},_spec:"zcash-bitcore-lib@~0.13.20-rc3",_where:"/Users/mitra/git/dweb-transports/node_modules/ipld-zcash",author:{name:"BitPay",email:"dev@bitpay.com"},browser:{request:"browser-request"},bugs:{url:"https://github.com/bitmex/zcash-bitcore-lib/issues"},bundleDependencies:!1,contributors:[{name:"Daniel Cousens",email:"bitcoin@dcousens.com"},{name:"Esteban Ordano",email:"eordano@gmail.com"},{name:"Gordon Hall",email:"gordon@bitpay.com"},{name:"Jeff Garzik",email:"jgarzik@bitpay.com"},{name:"Kyle Drake",email:"kyle@kyledrake.net"},{name:"Manuel Araoz",email:"manuelaraoz@gmail.com"},{name:"Matias Alejo Garcia",email:"ematiu@gmail.com"},{name:"Ryan X. Charles",email:"ryanxcharles@gmail.com"},{name:"Stefan Thomas",email:"moon@justmoon.net"},{name:"Stephen Pair",email:"stephen@bitpay.com"},{name:"Wei Lu",email:"luwei.here@gmail.com"},{name:"Jack Grigg",email:"jack@z.cash"}],dependencies:{"bn.js":"=2.0.4",bs58:"=2.0.0","buffer-compare":"=1.0.0",elliptic:"=3.0.3",inherits:"=2.0.1",lodash:"=3.10.1"},deprecated:!1,description:"A pure and powerful JavaScript Zcash library.",devDependencies:{brfs:"^1.2.0",chai:"^1.10.0",gulp:"^3.8.10",sinon:"^1.13.0","zcash-bitcore-build":"^0.5.4"},homepage:"https://github.com/bitmex/zcash-bitcore-lib#readme",keywords:["zcash","transaction","address","p2p","ecies","cryptocurrency","blockchain","payment","bip21","bip32","bip37","bip69","bip70","multisig"],license:"MIT",main:"index.js",name:"zcash-bitcore-lib",repository:{type:"git",url:"git+https://github.com/bitmex/zcash-bitcore-lib.git"},scripts:{build:"gulp",coverage:"gulp coverage",lint:"gulp lint",test:"gulp test"},version:"0.13.20-rc3"}},function(e,t,r){"use strict";e.exports=[{name:"InvalidB58Char",message:"Invalid Base58 character: {0} in {1}"},{name:"InvalidB58Checksum",message:"Invalid Base58 checksum for {0}"},{name:"InvalidNetwork",message:"Invalid version for network: got {0}"},{name:"InvalidState",message:"Invalid state: {0}"},{name:"NotImplemented",message:"Function {0} was not implemented yet"},{name:"InvalidNetworkArgument",message:'Invalid network: must be "livenet" or "testnet", got {0}'},{name:"InvalidArgument",message:function(){return"Invalid Argument"+(arguments[0]?": "+arguments[0]:"")+(arguments[1]?" Documentation: http://bitcore.io/"+arguments[1]:"")}},{name:"AbstractMethodInvoked",message:"Abstract Method Invocation: {0}"},{name:"InvalidArgumentType",message:function(){return"Invalid Argument for "+arguments[2]+", expected "+arguments[1]+" but got "+typeof arguments[0]}},{name:"Unit",message:"Internal Error on Unit {0}",errors:[{name:"UnknownCode",message:"Unrecognized unit code: {0}"},{name:"InvalidRate",message:"Invalid exchange rate: {0}"}]},{name:"Transaction",message:"Internal Error on Transaction {0}",errors:[{name:"Input",message:"Internal Error on Input {0}",errors:[{name:"MissingScript",message:"Need a script to create an input"},{name:"UnsupportedScript",message:"Unsupported input script type: {0}"},{name:"MissingPreviousOutput",message:"No previous output information."}]},{name:"NeedMoreInfo",message:"{0}"},{name:"InvalidSorting",message:"The sorting function provided did not return the change output as one of the array elements"},{name:"InvalidOutputAmountSum",message:"{0}"},{name:"MissingSignatures",message:"Some inputs have not been fully signed"},{name:"InvalidIndex",message:"Invalid index: {0} is not between 0, {1}"},{name:"UnableToVerifySignature",message:"Unable to verify signature: {0}"},{name:"DustOutputs",message:"Dust amount detected in one output"},{name:"InvalidSatoshis",message:"Output satoshis are invalid"},{name:"FeeError",message:"Internal Error on Fee {0}",errors:[{name:"TooSmall",message:"Fee is too small: {0}"},{name:"TooLarge",message:"Fee is too large: {0}"},{name:"Different",message:"Unspent value is different from specified fee: {0}"}]},{name:"ChangeAddressMissing",message:"Change address is missing"},{name:"BlockHeightTooHigh",message:"Block Height can be at most 2^32 -1"},{name:"NLockTimeOutOfRange",message:"Block Height can only be between 0 and 499 999 999"},{name:"LockTimeTooEarly",message:"Lock Time can't be earlier than UNIX date 500 000 000"}]},{name:"Script",message:"Internal Error on Script {0}",errors:[{name:"UnrecognizedAddress",message:"Expected argument {0} to be an address"},{name:"CantDeriveAddress",message:"Can't derive address associated with script {0}, needs to be p2pkh in, p2pkh out, p2sh in, or p2sh out."},{name:"InvalidBuffer",message:"Invalid script buffer: can't parse valid script from given buffer {0}"}]},{name:"HDPrivateKey",message:"Internal Error on HDPrivateKey {0}",errors:[{name:"InvalidDerivationArgument",message:"Invalid derivation argument {0}, expected string, or number and boolean"},{name:"InvalidEntropyArgument",message:"Invalid entropy: must be an hexa string or binary buffer, got {0}",errors:[{name:"TooMuchEntropy",message:'Invalid entropy: more than 512 bits is non standard, got "{0}"'},{name:"NotEnoughEntropy",message:'Invalid entropy: at least 128 bits needed, got "{0}"'}]},{name:"InvalidLength",message:"Invalid length for xprivkey string in {0}"},{name:"InvalidPath",message:"Invalid derivation path: {0}"},{name:"UnrecognizedArgument",message:'Invalid argument: creating a HDPrivateKey requires a string, buffer, json or object, got "{0}"'}]},{name:"HDPublicKey",message:"Internal Error on HDPublicKey {0}",errors:[{name:"ArgumentIsPrivateExtended",message:"Argument is an extended private key: {0}"},{name:"InvalidDerivationArgument",message:"Invalid derivation argument: got {0}"},{name:"InvalidLength",message:'Invalid length for xpubkey: got "{0}"'},{name:"InvalidPath",message:'Invalid derivation path, it should look like: "m/1/100", got "{0}"'},{name:"InvalidIndexCantDeriveHardened",message:"Invalid argument: creating a hardened path requires an HDPrivateKey"},{name:"MustSupplyArgument",message:"Must supply an argument to create a HDPublicKey"},{name:"UnrecognizedArgument",message:"Invalid argument for creation, must be string, json, buffer, or object"}]}]},function(e){e.exports={_from:"elliptic@=3.0.3",_id:"elliptic@3.0.3",_inBundle:!1,_integrity:"sha1-hlybQgv75VAGuflp+XoNLESWZZU=",_location:"/zcash-bitcore-lib/elliptic",_phantomChildren:{inherits:"2.0.1"},_requested:{type:"version",registry:!0,raw:"elliptic@3.0.3",name:"elliptic",escapedName:"elliptic",rawSpec:"3.0.3",saveSpec:null,fetchSpec:"3.0.3"},_requiredBy:["/zcash-bitcore-lib"],_resolved:"http://registry.npmjs.org/elliptic/-/elliptic-3.0.3.tgz",_shasum:"865c9b420bfbe55006b9f969f97a0d2c44966595",_spec:"elliptic@3.0.3",_where:"/Users/mitra/git/dweb-transports/node_modules/zcash-bitcore-lib",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},bundleDependencies:!1,dependencies:{"bn.js":"^2.0.0",brorand:"^1.0.1","hash.js":"^1.0.0",inherits:"^2.0.1"},deprecated:!1,description:"EC cryptography",devDependencies:{browserify:"^3.44.2",jscs:"^1.11.3",jshint:"^2.6.0",mocha:"^2.1.0","uglify-js":"^2.4.13"},homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{test:"make lint && mocha --reporter=spec test/*-test.js"},version:"3.0.3"}},function(e,t,r){"use strict";var n=t;function i(e){return 1===e.length?"0"+e:e}function o(e){for(var t="",r=0;r>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},n.getNAF=function(e,t){for(var r=[],n=1<=0;){var o;if(i.isOdd()){var s=i.andln(n-1);o=s>(n>>1)-1?(n>>1)-s:s,i.isubn(o)}else o=0;r.push(o);for(var a=0!==i.cmpn(0)&&0===i.andln(n-1)?t+1:1,u=1;u0||t.cmpn(-i)>0;){var o,s,a,u=e.andln(3)+n&3,c=t.andln(3)+i&3;3===u&&(u=-1),3===c&&(c=-1),o=0==(1&u)?0:3!=(a=e.andln(7)+n&7)&&5!==a||2!==c?u:-u,r[0].push(o),s=0==(1&c)?0:3!=(a=t.andln(7)+i&7)&&5!==a||2!==u?c:-c,r[1].push(s),2*n===o+1&&(n=1-n),2*i===s+1&&(i=1-i),e.ishrn(1),t.ishrn(1)}return r}},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)},"object"==typeof window)window.crypto&&window.crypto.getRandomValues?i.prototype._rand=function(e){var t=new Uint8Array(e);return window.crypto.getRandomValues(t),t}:window.msCrypto&&window.msCrypto.getRandomValues?i.prototype._rand=function(e){var t=new Uint8Array(e);return window.msCrypto.getRandomValues(t),t}:i.prototype._rand=function(){throw new Error("Not implemented yet")};else try{var o=r(95);i.prototype._rand=function(e){return o.randomBytes(e)}}catch(e){i.prototype._rand=function(e){for(var t=new Uint8Array(e),r=0;r=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),this._update(r));for(var o=[];o.length>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function s(e){return 1===e.length?"0"+e:e}function a(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}function u(e,t){if(!e)throw new Error(t||"Assertion failed")}n.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){(e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e);for(var n=0;n>8,s=255&i;o?r.push(o,s):r.push(s)}else for(n=0;n>>0}return o},n.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},n.rotr32=function(e,t){return e>>>t|e<<32-t},n.rotl32=function(e,t){return e<>>32-t},n.sum32=function(e,t){return e+t>>>0},n.sum32_3=function(e,t,r){return e+t+r>>>0},n.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},n.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},n.assert=u,n.inherits=i,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 u=0,c=t;return u+=(c=c+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,u,c){var f=0,l=t;return f+=(l=l+n>>>0)>>0)>>0)>>0)>>0},t.sum64_5_lo=function(e,t,r,n,i,o,s,a,u,c){return t+n+o+a+c>>>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){var n=r(109).utils,i=n.assert;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{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;for(o=8;o>>3}function K(e){return s(e,17)^s(e,19)^e>>>10}function j(e,t,r,n){return 0===e?P(t,r,n):1===e||3===e?function(e,t,r){return e^t^r}(t,r,n):2===e?O(t,r,n):void 0}function M(e,t,r,n,i,o){var s=e&r^~e&i;return s<0&&(s+=4294967296),s}function D(e,t,r,n,i,o){var s=t&n^~t&o;return s<0&&(s+=4294967296),s}function U(e,t,r,n,i,o){var s=e&r^e&i^r&i;return s<0&&(s+=4294967296),s}function F(e,t,r,n,i,o){var s=t&n^t&o^n&o;return s<0&&(s+=4294967296),s}function q(e,t){var r=l(e,t,28)^l(t,e,2)^l(t,e,7);return r<0&&(r+=4294967296),r}function H(e,t){var r=h(e,t,28)^h(t,e,2)^h(t,e,7);return r<0&&(r+=4294967296),r}function z(e,t){var r=l(e,t,14)^l(e,t,18)^l(t,e,9);return r<0&&(r+=4294967296),r}function V(e,t){var r=h(e,t,14)^h(e,t,18)^h(t,e,9);return r<0&&(r+=4294967296),r}function G(e,t){var r=l(e,t,1)^l(e,t,8)^p(e,t,7);return r<0&&(r+=4294967296),r}function W(e,t){var r=h(e,t,1)^h(e,t,8)^d(e,t,7);return r<0&&(r+=4294967296),r}function $(e,t){var r=l(e,t,19)^l(t,e,29)^p(e,t,6);return r<0&&(r+=4294967296),r}function Y(e,t){var r=h(e,t,19)^h(t,e,29)^d(e,t,6);return r<0&&(r+=4294967296),r}i.inherits(x,S),t.sha256=x,x.blockSize=512,x.outSize=256,x.hmacStrength=192,x.padLength=64,x.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;t=a;t--)u=(u<<1)+n[t];s.push(u)}for(var c=this.jpoint(null,null,null),f=this.jpoint(null,null,null),l=i;l>0;l--){for(a=0;a=0;c--){for(t=0;c>=0&&0===s[c];c--)t++;if(c>=0&&t++,u=u.dblp(t),c<0)break;var f=s[c];a(0!==f),u="affine"===e.type?f>0?u.mixedAdd(i[f-1>>1]):u.mixedAdd(i[-f-1>>1].neg()):f>0?u.add(i[f-1>>1]):u.add(i[-f-1>>1].neg())}return"affine"===e.type?u.toP():u},u.prototype._wnafMulAdd=function(e,t,r,n){for(var i=this._wnafT1,a=this._wnafT2,u=this._wnafT3,c=0,f=0;f=1;f-=2){var h=f-1,p=f;if(1===i[h]&&1===i[p]){var d=[t[h],null,null,t[p]];0===t[h].y.cmp(t[p].y)?(d[1]=t[h].add(t[p]),d[2]=t[h].toJ().mixedAdd(t[p].neg())):0===t[h].y.cmp(t[p].y.redNeg())?(d[1]=t[h].toJ().mixedAdd(t[p]),d[2]=t[h].add(t[p].neg())):(d[1]=t[h].toJ().mixedAdd(t[p]),d[2]=t[h].toJ().mixedAdd(t[p].neg()));var y=[-3,-1,-5,-7,0,7,5,1,3],g=s(r[h],r[p]);c=Math.max(g[0].length,c),u[h]=new Array(c),u[p]=new Array(c);for(var m=0;m=0;f--){for(var S=0;f>=0;){var k=!0;for(m=0;m=0&&S++,_=_.dblp(S),f<0)break;for(m=0;m0?E=a[m][A-1>>1]:A<0&&(E=a[m][-A-1>>1].neg()),_="affine"===E.type?_.mixedAdd(E):_.add(E))}}for(f=0;f=0&&(s=t,a=r),n.sign&&(n=n.neg(),i=i.neg()),s.sign&&(s=s.neg(),a=a.neg()),[{a:n,b:i},{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),u=i.mul(r.b),c=o.mul(n.b);return{k1:e.sub(s).sub(a),k2:u.add(c).neg()}},c.prototype.pointFromX=function(e,t){(t=new o(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b).redSqrt(),n=r.fromRed().isOdd();return(e&&!n||!e&&n)&&(r=r.redNeg()),this.point(t,r)},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){for(var r=this._endoWnafT1,n=this._endoWnafT2,i=0;i":""},f.prototype.isInfinity=function(){return this.inf},f.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)},f.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)},f.prototype.getX=function(){return this.x.fromRed()},f.prototype.getY=function(){return this.y.fromRed()},f.prototype.mul=function(e){return e=new o(e,16),this.precomputed&&this.precomputed.doubles?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},f.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)},f.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))},f.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},f.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},s(l,a.BasePoint),c.prototype.jpoint=function(e,t,r){return new l(this,e,t,r)},l.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)},l.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},l.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),u=o.redSub(s);if(0===a.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=a.redSqr(),f=c.redMul(a),l=n.redMul(c),h=u.redSqr().redIAdd(f).redISub(l).redISub(l),p=u.redMul(l.redISub(h)).redISub(o.redMul(f)),d=this.z.redMul(e.z).redMul(a);return this.curve.jpoint(h,p,d)},l.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 u=s.redSqr(),c=u.redMul(s),f=r.redMul(u),l=a.redSqr().redIAdd(c).redISub(f).redISub(f),h=a.redMul(f.redISub(l)).redISub(i.redMul(c)),p=this.z.redMul(s);return this.curve.jpoint(l,h,p)},l.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r":""},l.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},function(e,t,r){"use strict";var n=r(175),i=r(74),o=r(75),s=n.base;function a(e){s.call(this,"mont",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function u(e,t,r){s.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(t,16),this.z=new i(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}o(a,s),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)},o(u,s.BasePoint),a.prototype.point=function(e,t){return new u(this,e,t)},a.prototype.pointFromJSON=function(e){return u.fromJSON(this,e)},u.prototype.precompute=function(){},u.fromJSON=function(e,t){return new u(e,t[0],t[1]||e.one)},u.prototype.inspect=function(){return this.isInfinity()?"":""},u.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},u.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)},u.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},u.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()),u=t.x.redMul(o.redISub(s).redSqr());return this.curve.point(a,u)},u.prototype.mul=function(e){for(var t=e.clone(),r=this,n=this.curve.point(null,null),i=[];0!==t.cmpn(0);t.ishrn(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},u.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},u.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},u.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},function(e,t,r){"use strict";var n=r(175),i=r(72),o=r(74),s=r(75),a=n.base,u=i.utils.assert;function c(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,a.call(this,"edwards",e),this.a=new o(e.a,16).mod(this.red.m).toRed(this.red),this.c=new o(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new o(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),u(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}function f(e,t,r,n,i){a.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 o(t,16),this.y=new o(r,16),this.z=n?new o(n,16):this.curve.one,this.t=i&&new o(i,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()))))}s(c,a),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){(t=new o(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr(),i=this.c2.redSub(this.a.redMul(r)),s=this.one.redSub(this.c2.redMul(this.d).redMul(r)),a=i.redMul(s.redInvm()).redSqrt(),u=a.fromRed().isOdd();return(e&&!u||!e&&u)&&(a=a.redNeg()),this.point(t,a,n.one)},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)},s(f,a.BasePoint),c.prototype.pointFromJSON=function(e){return f.fromJSON(this,e)},c.prototype.point=function(e,t,r,n){return new f(this,e,t,r,n)},f.fromJSON=function(e,t){return new f(e,t[0],t[1],t[2])},f.prototype.inspect=function(){return this.isInfinity()?"":""},f.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&0===this.y.cmp(this.z)},f.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),u=i.redMul(s),c=o.redMul(a),f=i.redMul(a),l=s.redMul(o);return this.curve.point(u,c,l,f)},f.prototype._projDbl=function(){var e,t,r,n=this.x.redAdd(this.y).redSqr(),i=this.x.redSqr(),o=this.y.redSqr();if(this.curve.twisted){var s=(c=this.curve._mulA(i)).redAdd(o);if(this.zOne)e=n.redSub(i).redSub(o).redMul(s.redSub(this.curve.two)),t=s.redMul(c.redSub(o)),r=s.redSqr().redSub(s).redSub(s);else{var a=this.z.redSqr(),u=s.redSub(a).redISub(a);e=n.redSub(i).redISub(o).redMul(u),t=s.redMul(c.redSub(o)),r=s.redMul(u)}}else{var c=i.redAdd(o);a=this.curve._mulC(this.c.redMul(this.z)).redSqr(),u=c.redSub(a).redSub(a);e=this.curve._mulC(n.redISub(c)).redMul(u),t=this.curve._mulC(c).redMul(i.redISub(o)),r=c.redMul(u)}return this.curve.point(e,t,r)},f.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},f.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),u=r.redAdd(t),c=o.redMul(s),f=a.redMul(u),l=o.redMul(u),h=s.redMul(a);return this.curve.point(c,f,h,l)},f.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),u=i.redSub(a),c=i.redAdd(a),f=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(s),l=n.redMul(u).redMul(f);return this.curve.twisted?(t=n.redMul(c).redMul(s.redSub(this.curve._mulA(o))),r=u.redMul(c)):(t=n.redMul(c).redMul(s.redSub(o)),r=this.curve._mulC(u).redMul(c)),this.curve.point(l,t,r)},f.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},f.prototype.mul=function(e){return this.precomputed&&this.precomputed.doubles?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},f.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2)},f.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},f.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},f.prototype.getX=function(){return this.normalize(),this.x.fromRed()},f.prototype.getY=function(){return this.normalize(),this.y.fromRed()},f.prototype.toP=f.prototype.normalize,f.prototype.mixedAdd=f.prototype.add},function(e,t,r){"use strict";var n,i=t,o=r(109),s=r(72),a=s.utils.assert;function u(e){"short"===e.type?this.curve=new s.curve.short(e):"edwards"===e.type?this.curve=new s.curve.edwards(e):this.curve=new s.curve.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 c(e,t){Object.defineProperty(i,e,{configurable:!0,enumerable:!0,get:function(){var r=new u(t);return Object.defineProperty(i,e,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=u,c("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"]}),c("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"]}),c("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"]}),c("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"0",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),c("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(888)}catch(e){n=void 0}c("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){e.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}},function(e,t,r){"use strict";var n=r(74),i=r(72),o=i.utils.assert,s=r(890),a=r(891);function u(e){if(!(this instanceof u))return new u(e);"string"==typeof e&&(o(i.curves.hasOwnProperty(e),"Unknown curve "+e),e=i.curves[e]),e instanceof i.curves.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.shrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}e.exports=u,u.prototype.keyPair=function(e){return new s(this,e)},u.prototype.keyFromPrivate=function(e,t){return s.fromPrivate(this,e,t)},u.prototype.keyFromPublic=function(e,t){return s.fromPublic(this,e,t)},u.prototype.genKeyPair=function(e){e||(e={});for(var t=new i.hmacDRBG({hash:this.hash,pers:e.pers,entropy:e.entropy||i.rand(this.hash.hmacStrength),nonce:this.n.toArray()}),r=this.n.byteLength(),o=this.n.sub(new n(2));;){var s=new n(t.generate(r));if(!(s.cmp(o)>0))return s.iaddn(1),this.keyFromPrivate(s)}},u.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.shrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},u.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(),u=t.getPrivate().toArray(),c=u.length;c<21;c++)u.unshift(0);var f=e.toArray();for(c=f.length;c=0)){var d=this.g.mul(p);if(!d.isInfinity()){var y=d.getX().mod(this.n);if(0!==y.cmpn(0)){var g=p.invm(this.n).mul(y.mul(t.getPrivate()).iadd(e)).mod(this.n);if(0!==g.cmpn(0))return o.canonical&&g.cmp(this.nh)>0&&(g=this.n.sub(g)),new a({r:y,s:g})}}}}},u.prototype.verify=function(e,t,r,i){e=this._truncateToN(new n(e,16)),r=this.keyFromPublic(r,i);var o=(t=new a(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 u=s.invm(this.n),c=u.mul(e).mod(this.n),f=u.mul(o).mod(this.n),l=this.g.mulAdd(c,r.getPublic(),f);return!l.isInfinity()&&0===l.getX().mod(this.n).cmp(o)}},function(e,t,r){"use strict";var n=r(74),i=r(72).utils;function o(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}e.exports=o,o.fromPublic=function(e,t,r){return t instanceof o?t:new o(e,{pub:t,pubEnc:r})},o.fromPrivate=function(e,t,r){return t instanceof o?t:new o(e,{priv:t,privEnc:r})},o.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(e,t){if(this.pub||(this.pub=this.ec.g.mul(this.priv)),"string"==typeof e&&(t=e,e=null),!t)return this.pub;for(var r=this.ec.curve.p.byteLength(),n=this.pub.getX().toArray(),o=n.length;o"}},function(e,t,r){"use strict";var n=r(74),i=r(72).utils,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))}e.exports=s,s.prototype._importDER=function(e,t){if((e=i.toArray(e,t)).length<6||48!==e[0]||2!==e[2])return!1;if(1+e[1]>e.length)return!1;var r=e[3];if(r>=128)return!1;if(4+r+2>=e.length)return!1;if(2!==e[4+r])return!1;var o=e[5+r];return!(o>=128||4+r+2+o>e.length||(this.r=new n(e.slice(4,4+r)),this.s=new n(e.slice(4+r+2,4+r+2+o)),0))},s.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r));var n=[48,t.length+r.length+4,2,t.length];return n=n.concat(t,[2,r.length],r),i.encode(n,e)}},function(e,t,r){"use strict";(function(t){var n=r(18),i=r(433),o=r(249),s=r(32),a=r(43),u=r(67),c=r(73),f=function e(t){if(!(this instanceof e))return new e(t);t?(this.initialize(),this.set(t)):this.initialize()};f.prototype.verify=function(e,t,o,s,a){var u,c=r(178);if(n.isUndefined(o)&&(o=new c),n.isUndefined(s)&&(s=0),n.isUndefined(a)&&(a=0),this.set({script:e,tx:o,nin:s,flags:a}),0!=(a&f.SCRIPT_VERIFY_SIGPUSHONLY)&&!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(!this.evaluate())return!1;a&f.SCRIPT_VERIFY_P2SH&&(u=this.stack.slice());var l=this.stack;if(this.initialize(),this.set({script:t,stack:l,tx:o,nin:s,flags:a}),!this.evaluate())return!1;if(0===this.stack.length)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_RESULT",!1;var h=this.stack[this.stack.length-1];if(!f.castToBool(h))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_STACK",!1;if(a&f.SCRIPT_VERIFY_P2SH&&t.isScriptHashOut()){if(!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(0===u.length)throw new Error("internal error - stack copy empty");var p=u[u.length-1],d=i.fromBuffer(p);return u.pop(),this.initialize(),this.set({script:d,stack:u,tx:o,nin:s,flags:a}),!(!this.evaluate()||(0===u.length?(this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_P2SH_STACK",1):!f.castToBool(u[u.length-1])&&(this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_P2SH_STACK",1)))}return!0},e.exports=f,f.prototype.initialize=function(e){this.stack=[],this.altstack=[],this.pc=0,this.pbegincodehash=0,this.nOpCount=0,this.vfExec=[],this.errstr="",this.flags=0},f.prototype.set=function(e){this.script=e.script||this.script,this.tx=e.tx||this.tx,this.nin=void 0!==e.nin?e.nin:this.nin,this.stack=e.stack||this.stack,this.altstack=e.altack||this.altstack,this.pc=void 0!==e.pc?e.pc:this.pc,this.pbegincodehash=void 0!==e.pbegincodehash?e.pbegincodehash:this.pbegincodehash,this.nOpCount=void 0!==e.nOpCount?e.nOpCount:this.nOpCount,this.vfExec=e.vfExec||this.vfExec,this.errstr=e.errstr||this.errstr,this.flags=void 0!==e.flags?e.flags:this.flags},f.true=new t([1]),f.false=new t([]),f.MAX_SCRIPT_ELEMENT_SIZE=520,f.LOCKTIME_THRESHOLD_BN=new s(f.LOCKTIME_THRESHOLD=5e8),f.SCRIPT_VERIFY_NONE=0,f.SCRIPT_VERIFY_P2SH=1,f.SCRIPT_VERIFY_STRICTENC=2,f.SCRIPT_VERIFY_DERSIG=4,f.SCRIPT_VERIFY_LOW_S=8,f.SCRIPT_VERIFY_NULLDUMMY=16,f.SCRIPT_VERIFY_SIGPUSHONLY=32,f.SCRIPT_VERIFY_MINIMALDATA=64,f.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS=128,f.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY=512,f.castToBool=function(e){for(var t=0;t1e4)return this.errstr="SCRIPT_ERR_SCRIPT_SIZE",!1;try{for(;this.pc1e3)return this.errstr="SCRIPT_ERR_STACK_SIZE",!1}catch(e){return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR: "+e,!1}return!(this.vfExec.length>0&&(this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",1))},f.prototype.checkLockTime=function(e){return!!(this.tx.nLockTime=f.LOCKTIME_THRESHOLD&&e.gte(f.LOCKTIME_THRESHOLD_BN))&&!e.gt(new s(this.tx.nLockTime))&&!!this.tx.inputs[this.nin].isFinal()},f.prototype.step=function(){var e,t,r,l,h,p,d,y,g,m,b,v,_,w,S,k,E,A=0!=(this.flags&f.SCRIPT_VERIFY_MINIMALDATA),x=-1===this.vfExec.indexOf(!1),I=this.script.chunks[this.pc];this.pc++;var T=I.opcodenum;if(n.isUndefined(T))return this.errstr="SCRIPT_ERR_UNDEFINED_OPCODE",!1;if(I.buf&&I.buf.length>f.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;if(T>o.OP_16&&++this.nOpCount>201)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;if(T===o.OP_CAT||T===o.OP_SUBSTR||T===o.OP_LEFT||T===o.OP_RIGHT||T===o.OP_INVERT||T===o.OP_AND||T===o.OP_OR||T===o.OP_XOR||T===o.OP_2MUL||T===o.OP_2DIV||T===o.OP_MUL||T===o.OP_DIV||T===o.OP_MOD||T===o.OP_LSHIFT||T===o.OP_RSHIFT)return this.errstr="SCRIPT_ERR_DISABLED_OPCODE",!1;if(x&&0<=T&&T<=o.OP_PUSHDATA4){if(A&&!this.script.checkMinimalPush(this.pc-1))return this.errstr="SCRIPT_ERR_MINIMALDATA",!1;if(I.buf){if(I.len!==I.buf.length)throw new Error("Length of push value not equal to length of data");this.stack.push(I.buf)}else this.stack.push(f.false)}else if(x||o.OP_IF<=T&&T<=o.OP_ENDIF)switch(T){case o.OP_1NEGATE:case o.OP_1:case o.OP_2:case o.OP_3:case o.OP_4:case o.OP_5:case o.OP_6:case o.OP_7:case o.OP_8:case o.OP_9:case o.OP_10:case o.OP_11:case o.OP_12:case o.OP_13:case o.OP_14:case o.OP_15:case o.OP_16:h=T-(o.OP_1-1),e=new s(h).toScriptNumBuffer(),this.stack.push(e);break;case o.OP_NOP:break;case o.OP_NOP2:case o.OP_CHECKLOCKTIMEVERIFY:if(!(this.flags&f.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)){if(this.flags&f.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var B=s.fromScriptNumBuffer(this.stack[this.stack.length-1],A,5);if(B.lt(new s(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(!this.checkLockTime(B))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case o.OP_NOP1:case o.OP_NOP3:case o.OP_NOP4:case o.OP_NOP5:case o.OP_NOP6:case o.OP_NOP7:case o.OP_NOP8:case o.OP_NOP9:case o.OP_NOP10:if(this.flags&f.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break;case o.OP_IF:case o.OP_NOTIF:if(k=!1,x){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;e=this.stack.pop(),k=f.castToBool(e),T===o.OP_NOTIF&&(k=!k)}this.vfExec.push(k);break;case o.OP_ELSE:if(0===this.vfExec.length)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec[this.vfExec.length-1]=!this.vfExec[this.vfExec.length-1];break;case o.OP_ENDIF:if(0===this.vfExec.length)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec.pop();break;case o.OP_VERIFY:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(e=this.stack[this.stack.length-1],!(k=f.castToBool(e)))return this.errstr="SCRIPT_ERR_VERIFY",!1;this.stack.pop();break;case o.OP_RETURN:return this.errstr="SCRIPT_ERR_OP_RETURN",!1;case o.OP_TOALTSTACK:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.altstack.push(this.stack.pop());break;case o.OP_FROMALTSTACK:if(this.altstack.length<1)return this.errstr="SCRIPT_ERR_INVALID_ALTSTACK_OPERATION",!1;this.stack.push(this.altstack.pop());break;case o.OP_2DROP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop(),this.stack.pop();break;case o.OP_2DUP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;t=this.stack[this.stack.length-2],r=this.stack[this.stack.length-1],this.stack.push(t),this.stack.push(r);break;case o.OP_3DUP:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;t=this.stack[this.stack.length-3],r=this.stack[this.stack.length-2];var C=this.stack[this.stack.length-1];this.stack.push(t),this.stack.push(r),this.stack.push(C);break;case o.OP_2OVER:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;t=this.stack[this.stack.length-4],r=this.stack[this.stack.length-3],this.stack.push(t),this.stack.push(r);break;case o.OP_2ROT:if(this.stack.length<6)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=this.stack.splice(this.stack.length-6,2),this.stack.push(l[0]),this.stack.push(l[1]);break;case o.OP_2SWAP:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=this.stack.splice(this.stack.length-4,2),this.stack.push(l[0]),this.stack.push(l[1]);break;case o.OP_IFDUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;e=this.stack[this.stack.length-1],(k=f.castToBool(e))&&this.stack.push(e);break;case o.OP_DEPTH:e=new s(this.stack.length).toScriptNumBuffer(),this.stack.push(e);break;case o.OP_DROP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop();break;case o.OP_DUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(this.stack[this.stack.length-1]);break;case o.OP_NIP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,1);break;case o.OP_OVER:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(this.stack[this.stack.length-2]);break;case o.OP_PICK:case o.OP_ROLL:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(e=this.stack[this.stack.length-1],h=(y=s.fromScriptNumBuffer(e,A)).toNumber(),this.stack.pop(),h<0||h>=this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;e=this.stack[this.stack.length-h-1],T===o.OP_ROLL&&this.stack.splice(this.stack.length-h-1,1),this.stack.push(e);break;case o.OP_ROT:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;p=this.stack[this.stack.length-3],d=this.stack[this.stack.length-2];var P=this.stack[this.stack.length-1];this.stack[this.stack.length-3]=d,this.stack[this.stack.length-2]=P,this.stack[this.stack.length-1]=p;break;case o.OP_SWAP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;p=this.stack[this.stack.length-2],d=this.stack[this.stack.length-1],this.stack[this.stack.length-2]=d,this.stack[this.stack.length-1]=p;break;case o.OP_TUCK:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,0,this.stack[this.stack.length-1]);break;case o.OP_SIZE:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;y=new s(this.stack[this.stack.length-1].length),this.stack.push(y.toScriptNumBuffer());break;case o.OP_EQUAL:case o.OP_EQUALVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;t=this.stack[this.stack.length-2],r=this.stack[this.stack.length-1];var O=t.toString("hex")===r.toString("hex");if(this.stack.pop(),this.stack.pop(),this.stack.push(O?f.true:f.false),T===o.OP_EQUALVERIFY){if(!O)return this.errstr="SCRIPT_ERR_EQUALVERIFY",!1;this.stack.pop()}break;case o.OP_1ADD:case o.OP_1SUB:case o.OP_NEGATE:case o.OP_ABS:case o.OP_NOT:case o.OP_0NOTEQUAL:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(e=this.stack[this.stack.length-1],y=s.fromScriptNumBuffer(e,A),T){case o.OP_1ADD:y=y.add(s.One);break;case o.OP_1SUB:y=y.sub(s.One);break;case o.OP_NEGATE:y=y.neg();break;case o.OP_ABS:y.cmp(s.Zero)<0&&(y=y.neg());break;case o.OP_NOT:y=new s((0===y.cmp(s.Zero))+0);break;case o.OP_0NOTEQUAL:y=new s((0!==y.cmp(s.Zero))+0)}this.stack.pop(),this.stack.push(y.toScriptNumBuffer());break;case o.OP_ADD:case o.OP_SUB:case o.OP_BOOLAND:case o.OP_BOOLOR:case o.OP_NUMEQUAL:case o.OP_NUMEQUALVERIFY:case o.OP_NUMNOTEQUAL:case o.OP_LESSTHAN:case o.OP_GREATERTHAN:case o.OP_LESSTHANOREQUAL:case o.OP_GREATERTHANOREQUAL:case o.OP_MIN:case o.OP_MAX:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(g=s.fromScriptNumBuffer(this.stack[this.stack.length-2],A),m=s.fromScriptNumBuffer(this.stack[this.stack.length-1],A),y=new s(0),T){case o.OP_ADD:y=g.add(m);break;case o.OP_SUB:y=g.sub(m);break;case o.OP_BOOLAND:y=new s((0!==g.cmp(s.Zero)&&0!==m.cmp(s.Zero))+0);break;case o.OP_BOOLOR:y=new s((0!==g.cmp(s.Zero)||0!==m.cmp(s.Zero))+0);break;case o.OP_NUMEQUAL:case o.OP_NUMEQUALVERIFY:y=new s((0===g.cmp(m))+0);break;case o.OP_NUMNOTEQUAL:y=new s((0!==g.cmp(m))+0);break;case o.OP_LESSTHAN:y=new s((g.cmp(m)<0)+0);break;case o.OP_GREATERTHAN:y=new s((g.cmp(m)>0)+0);break;case o.OP_LESSTHANOREQUAL:y=new s((g.cmp(m)<=0)+0);break;case o.OP_GREATERTHANOREQUAL:y=new s((g.cmp(m)>=0)+0);break;case o.OP_MIN:y=g.cmp(m)<0?g:m;break;case o.OP_MAX:y=g.cmp(m)>0?g:m}if(this.stack.pop(),this.stack.pop(),this.stack.push(y.toScriptNumBuffer()),T===o.OP_NUMEQUALVERIFY){if(!f.castToBool(this.stack[this.stack.length-1]))return this.errstr="SCRIPT_ERR_NUMEQUALVERIFY",!1;this.stack.pop()}break;case o.OP_WITHIN:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;g=s.fromScriptNumBuffer(this.stack[this.stack.length-3],A),m=s.fromScriptNumBuffer(this.stack[this.stack.length-2],A);var R=s.fromScriptNumBuffer(this.stack[this.stack.length-1],A);k=m.cmp(g)<=0&&g.cmp(R)<0,this.stack.pop(),this.stack.pop(),this.stack.pop(),this.stack.push(k?f.true:f.false);break;case o.OP_RIPEMD160:case o.OP_SHA1:case o.OP_SHA256:case o.OP_HASH160:case o.OP_HASH256:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var N;e=this.stack[this.stack.length-1],T===o.OP_RIPEMD160?N=a.ripemd160(e):T===o.OP_SHA1?N=a.sha1(e):T===o.OP_SHA256?N=a.sha256(e):T===o.OP_HASH160?N=a.sha256ripemd160(e):T===o.OP_HASH256&&(N=a.sha256sha256(e)),this.stack.pop(),this.stack.push(N);break;case o.OP_CODESEPARATOR:this.pbegincodehash=this.pc;break;case o.OP_CHECKSIG:case o.OP_CHECKSIGVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;b=this.stack[this.stack.length-2],v=this.stack[this.stack.length-1],_=(new i).set({chunks:this.script.chunks.slice(this.pbegincodehash)});var L=(new i).add(b);if(_.findAndDelete(L),!this.checkSignatureEncoding(b)||!this.checkPubkeyEncoding(v))return!1;try{w=u.fromTxFormat(b),S=c.fromBuffer(v,!1),E=this.tx.verifySignature(w,S,this.nin,_)}catch(A){E=!1}if(this.stack.pop(),this.stack.pop(),this.stack.push(E?f.true:f.false),T===o.OP_CHECKSIGVERIFY){if(!E)return this.errstr="SCRIPT_ERR_CHECKSIGVERIFY",!1;this.stack.pop()}break;case o.OP_CHECKMULTISIG:case o.OP_CHECKMULTISIGVERIFY:var K=1;if(this.stack.length20)return this.errstr="SCRIPT_ERR_PUBKEY_COUNT",!1;if(this.nOpCount+=j,this.nOpCount>201)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;var M=++K;if(K+=j,this.stack.lengthj)return this.errstr="SCRIPT_ERR_SIG_COUNT",!1;var U=++K;if(K+=D,this.stack.length0;){if(b=this.stack[this.stack.length-U],v=this.stack[this.stack.length-M],!this.checkSignatureEncoding(b)||!this.checkPubkeyEncoding(v))return!1;var q;try{w=u.fromTxFormat(b),S=c.fromBuffer(v,!1),q=this.tx.verifySignature(w,S,this.nin,_)}catch(A){q=!1}q&&(U++,D--),M++,D>--j&&(E=!1)}for(;K-- >1;)this.stack.pop();if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(this.flags&f.SCRIPT_VERIFY_NULLDUMMY&&this.stack[this.stack.length-1].length)return this.errstr="SCRIPT_ERR_SIG_NULLDUMMY",!1;if(this.stack.pop(),this.stack.push(E?f.true:f.false),T===o.OP_CHECKMULTISIGVERIFY){if(!E)return this.errstr="SCRIPT_ERR_CHECKMULTISIGVERIFY",!1;this.stack.pop()}break;default:return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}return!0}}).call(this,r(0).Buffer)},function(e,t){e.exports=function(e,t){for(var r=0,n=0;nt[n]?1:0);++n);return 0==r&&(t.length>e.length?r=-1:e.length>t.length&&(r=1)),r}},function(e,t,r){"use strict";var n=r(75),i=r(21),o=(r(24),r(130)),s=r(84),a=r(83),u=r(68),c=r(67),f=r(131);function l(){o.apply(this,arguments)}n(l,o),l.prototype.getSignatures=function(e,t,r,n){i.checkState(this.output instanceof s),n=n||c.SIGHASH_ALL;var o=t.toPublicKey();return o.toString()===this.output.script.getPublicKey().toString("hex")?[new f({publicKey:o,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:a.sign(e,t,n,r,this.output.script),sigtype:n})]:[]},l.prototype.addSignature=function(e,t){return i.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(u.buildPublicKeyIn(t.signature.toDER(),t.sigtype)),this},l.prototype.clearSignatures=function(){return this.setScript(u.empty()),this},l.prototype.isFullySigned=function(){return this.script.isPublicKeyIn()},l.SCRIPT_MAX_SIZE=73,l.prototype._estimateSize=function(){return l.SCRIPT_MAX_SIZE},e.exports=l},function(e,t,r){"use strict";var n=r(75),i=r(21),o=r(24),s=r(43),a=r(130),u=r(84),c=r(83),f=r(68),l=r(67),h=r(131);function p(){a.apply(this,arguments)}n(p,a),p.prototype.getSignatures=function(e,t,r,n,a){return i.checkState(this.output instanceof u),a=a||s.sha256ripemd160(t.publicKey.toBuffer()),n=n||l.SIGHASH_ALL,o.equals(a,this.output.script.getPublicKeyHash())?[new h({publicKey:t.publicKey,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:c.sign(e,t,n,r,this.output.script),sigtype:n})]:[]},p.prototype.addSignature=function(e,t){return i.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(f.buildPublicKeyHashIn(t.publicKey,t.signature.toDER(),t.sigtype)),this},p.prototype.clearSignatures=function(){return this.setScript(f.empty()),this},p.prototype.isFullySigned=function(){return this.script.isPublicKeyHashIn()},p.SCRIPT_MAX_SIZE=107,p.prototype._estimateSize=function(){return p.SCRIPT_MAX_SIZE},e.exports=p},function(e,t,r){"use strict";var n=r(18),i=r(75),o=(r(250),r(130)),s=r(84),a=r(21),u=r(68),c=r(67),f=r(83),l=(r(73),r(24)),h=r(131);function p(e,t,r,i){o.apply(this,arguments);var s=this;t=t||e.publicKeys,r=r||e.threshold,i=i||e.signatures,this.publicKeys=n.sortBy(t,function(e){return e.toString("hex")}),a.checkState(u.buildMultisigOut(this.publicKeys,r).equals(this.output.script),"Provided public keys don't match to the provided output script"),this.publicKeyIndex={},n.each(this.publicKeys,function(e,t){s.publicKeyIndex[e.toString()]=t}),this.threshold=r,this.signatures=i?this._deserializeSignatures(i):new Array(this.publicKeys.length)}i(p,o),p.prototype.toObject=function(){var e=o.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=n.map(this.publicKeys,function(e){return e.toString()}),e.signatures=this._serializeSignatures(),e},p.prototype._deserializeSignatures=function(e){return n.map(e,function(e){if(e)return new h(e)})},p.prototype._serializeSignatures=function(){return n.map(this.signatures,function(e){if(e)return e.toObject()})},p.prototype.getSignatures=function(e,t,r,i){a.checkState(this.output instanceof s),i=i||c.SIGHASH_ALL;var o=this,u=[];return n.each(this.publicKeys,function(n){n.toString()===t.publicKey.toString()&&u.push(new h({publicKey:t.publicKey,prevTxId:o.prevTxId,outputIndex:o.outputIndex,inputIndex:r,signature:f.sign(e,t,i,r,o.output.script),sigtype:i}))}),u},p.prototype.addSignature=function(e,t){return a.checkState(!this.isFullySigned(),"All needed signatures have already been added"),a.checkArgument(!n.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),a.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this},p.prototype._updateScript=function(){return this.setScript(u.buildMultisigIn(this.publicKeys,this.threshold,this._createSignatures())),this},p.prototype._createSignatures=function(){return n.map(n.filter(this.signatures,function(e){return!n.isUndefined(e)}),function(e){return l.concat([e.signature.toDER(),l.integerAsSingleByteBuffer(e.sigtype)])})},p.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()},p.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold},p.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()},p.prototype.countSignatures=function(){return n.reduce(this.signatures,function(e,t){return e+!!t},0)},p.prototype.publicKeysWithoutSignature=function(){var e=this;return n.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})},p.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,f.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script)},p.normalizeSignatures=function(e,t,r,n,i){return i.map(function(i){var o=null;return n=n.filter(function(n){if(o)return!0;var s=new h({signature:c.fromTxFormat(n),publicKey:i,prevTxId:t.prevTxId,outputIndex:t.outputIndex,inputIndex:r,sigtype:c.SIGHASH_ALL});return s.signature.nhashtype=s.sigtype,!f.verify(e,s.signature,s.publicKey,s.inputIndex,t.output.script)||(o=s,!1)}),o||null})},p.OPCODES_SIZE=1,p.SIGNATURE_SIZE=73,p.prototype._estimateSize=function(){return p.OPCODES_SIZE+this.threshold*p.SIGNATURE_SIZE},e.exports=p},function(e,t,r){"use strict";var n=r(18),i=r(75),o=r(130),s=r(84),a=r(21),u=r(68),c=r(67),f=r(83),l=(r(73),r(24)),h=r(131);function p(e,t,r,i){o.apply(this,arguments);var s=this;t=t||e.publicKeys,r=r||e.threshold,i=i||e.signatures,this.publicKeys=n.sortBy(t,function(e){return e.toString("hex")}),this.redeemScript=u.buildMultisigOut(this.publicKeys,r),a.checkState(u.buildScriptHashOut(this.redeemScript).equals(this.output.script),"Provided public keys don't hash to the provided output"),this.publicKeyIndex={},n.each(this.publicKeys,function(e,t){s.publicKeyIndex[e.toString()]=t}),this.threshold=r,this.signatures=i?this._deserializeSignatures(i):new Array(this.publicKeys.length)}i(p,o),p.prototype.toObject=function(){var e=o.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=n.map(this.publicKeys,function(e){return e.toString()}),e.signatures=this._serializeSignatures(),e},p.prototype._deserializeSignatures=function(e){return n.map(e,function(e){if(e)return new h(e)})},p.prototype._serializeSignatures=function(){return n.map(this.signatures,function(e){if(e)return e.toObject()})},p.prototype.getSignatures=function(e,t,r,i){a.checkState(this.output instanceof s),i=i||c.SIGHASH_ALL;var o=this,u=[];return n.each(this.publicKeys,function(n){n.toString()===t.publicKey.toString()&&u.push(new h({publicKey:t.publicKey,prevTxId:o.prevTxId,outputIndex:o.outputIndex,inputIndex:r,signature:f.sign(e,t,i,r,o.redeemScript),sigtype:i}))}),u},p.prototype.addSignature=function(e,t){return a.checkState(!this.isFullySigned(),"All needed signatures have already been added"),a.checkArgument(!n.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),a.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this},p.prototype._updateScript=function(){return this.setScript(u.buildP2SHMultisigIn(this.publicKeys,this.threshold,this._createSignatures(),{cachedMultisig:this.redeemScript})),this},p.prototype._createSignatures=function(){return n.map(n.filter(this.signatures,function(e){return!n.isUndefined(e)}),function(e){return l.concat([e.signature.toDER(),l.integerAsSingleByteBuffer(e.sigtype)])})},p.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()},p.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold},p.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()},p.prototype.countSignatures=function(){return n.reduce(this.signatures,function(e,t){return e+!!t},0)},p.prototype.publicKeysWithoutSignature=function(){var e=this;return n.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})},p.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,f.verify(e,t.signature,t.publicKey,t.inputIndex,this.redeemScript)},p.OPCODES_SIZE=7,p.SIGNATURE_SIZE=74,p.PUBKEY_SIZE=34,p.prototype._estimateSize=function(){return p.OPCODES_SIZE+this.threshold*p.SIGNATURE_SIZE+this.publicKeys.length*p.PUBKEY_SIZE},e.exports=p},function(e,t,r){"use strict";var n=r(18),i=r(21),o=r(32),s=r(0),a=r(57),u=r(24),c=r(29),f=r(899);function l(e){return this instanceof l?(this.nullifiers=[],this.commitments=[],this.ciphertexts=[],this.macs=[],e?this._fromObject(e):void 0):new l(e)}Object.defineProperty(l.prototype,"vpub_old",{configurable:!1,enumerable:!0,get:function(){return this._vpub_old},set:function(e){e instanceof o?(this._vpub_oldBN=e,this._vpub_old=e.toNumber()):n.isString(e)?(this._vpub_old=parseInt(e),this._vpub_oldBN=o.fromNumber(this._vpub_old)):(i.checkArgument(c.isNaturalNumber(e),"vpub_old is not a natural number"),this._vpub_oldBN=o.fromNumber(e),this._vpub_old=e),i.checkState(c.isNaturalNumber(this._vpub_old),"vpub_old is not a natural number")}}),Object.defineProperty(l.prototype,"vpub_new",{configurable:!1,enumerable:!0,get:function(){return this._vpub_new},set:function(e){e instanceof o?(this._vpub_newBN=e,this._vpub_new=e.toNumber()):n.isString(e)?(this._vpub_new=parseInt(e),this._vpub_newBN=o.fromNumber(this._vpub_new)):(i.checkArgument(c.isNaturalNumber(e),"vpub_new is not a natural number"),this._vpub_newBN=o.fromNumber(e),this._vpub_new=e),i.checkState(c.isNaturalNumber(this._vpub_new),"vpub_new is not a natural number")}}),l.fromObject=function(e){return i.checkArgument(n.isObject(e)),(new l)._fromObject(e)},l.prototype._fromObject=function(e){var t=[];n.each(e.nullifiers,function(e){t.push(u.reverse(new s.Buffer(e,"hex")))});var r=[];n.each(e.commitments,function(e){r.push(u.reverse(new s.Buffer(e,"hex")))});var i=[];n.each(e.ciphertexts,function(e){i.push(new s.Buffer(e,"hex"))});var o=[];return n.each(e.macs,function(e){o.push(u.reverse(new s.Buffer(e,"hex")))}),this.vpub_old=e.vpub_old,this.vpub_new=e.vpub_new,this.anchor=u.reverse(new s.Buffer(e.anchor,"hex")),this.nullifiers=t,this.commitments=r,this.ephemeralKey=u.reverse(new s.Buffer(e.ephemeralKey,"hex")),this.ciphertexts=i,this.randomSeed=u.reverse(new s.Buffer(e.randomSeed,"hex")),this.macs=o,this.proof=f.fromObject(e.proof),this},l.prototype.toObject=l.prototype.toJSON=function(){var e=[];n.each(this.nullifiers,function(t){e.push(u.reverse(t).toString("hex"))});var t=[];n.each(this.commitments,function(e){t.push(u.reverse(e).toString("hex"))});var r=[];n.each(this.ciphertexts,function(e){r.push(e.toString("hex"))});var i=[];return n.each(this.macs,function(e){i.push(u.reverse(e).toString("hex"))}),{vpub_old:this.vpub_old,vpub_new:this.vpub_new,anchor:u.reverse(this.anchor).toString("hex"),nullifiers:e,commitments:t,ephemeralKey:u.reverse(this.ephemeralKey).toString("hex"),ciphertexts:r,randomSeed:u.reverse(this.randomSeed).toString("hex"),macs:i,proof:this.proof.toObject()}},l.fromBufferReader=function(e){var t,r=new l;for(r.vpub_old=e.readUInt64LEBN(),r.vpub_new=e.readUInt64LEBN(),r.anchor=e.read(32),t=0;t<2;t++)r.nullifiers.push(e.read(32));for(t=0;t<2;t++)r.commitments.push(e.read(32));for(r.ephemeralKey=e.read(32),r.randomSeed=e.read(32),t=0;t<2;t++)r.macs.push(e.read(32));for(r.proof=f.fromBufferReader(e),t=0;t<2;t++)r.ciphertexts.push(e.read(601));return r},l.prototype.toBufferWriter=function(e){var t;for(e||(e=new a),e.writeUInt64LEBN(this._vpub_oldBN),e.writeUInt64LEBN(this._vpub_newBN),e.write(this.anchor),t=0;t<2;t++)e.write(this.nullifiers[t]);for(t=0;t<2;t++)e.write(this.commitments[t]);for(e.write(this.ephemeralKey),e.write(this.randomSeed),t=0;t<2;t++)e.write(this.macs[t]);for(this.proof.toBufferWriter(e),t=0;t<2;t++)e.write(this.ciphertexts[t]);return e},e.exports=l},function(e,t,r){"use strict";var n=r(21),i=r(0),o=r(57);function s(e){return this instanceof s?e?this._fromObject(e):void 0:new s(e)}function a(e){return this instanceof a?e?this._fromObject(e):void 0:new a(e)}function u(e){return this instanceof u?e?this._fromObject(e):void 0:new u(e)}s.fromObject=function(e){return n.checkArgument(_.isObject(e)),(new s)._fromObject(e)},s.prototype._fromObject=function(e){return this.y_lsb=e.y_lsb,this.x=new i.Buffer(e.x,"hex"),this},s.prototype.toObject=s.prototype.toJSON=function(){return{y_lsb:this.y_lsb,x:this.x.toString("hex")}},s.fromBufferReader=function(e){var t=new s,r=e.readUInt8();return t.y_lsb=1&r,t.x=e.read(32),t},s.prototype.toBufferWriter=function(e){return e||(e=new o),e.writeUInt8(2|this.y_lsb),e.write(this.x),e},a.fromObject=function(e){return n.checkArgument(_.isObject(e)),(new a)._fromObject(e)},a.prototype._fromObject=function(e){return this.y_gt=e.y_gt,this.x=new i.Buffer(e.x,"hex"),this},a.prototype.toObject=a.prototype.toJSON=function(){return{y_gt:this.y_gt,x:this.x.toString("hex")}},a.fromBufferReader=function(e){var t=new a,r=e.readUInt8();return t.y_gt=1&r,t.x=e.read(64),t},a.prototype.toBufferWriter=function(e){return e||(e=new o),e.writeUInt8(10|this.y_gt),e.write(this.x),e},u.fromObject=function(e){return n.checkArgument(_.isObject(e)),(new u)._fromObject(e)},u.prototype._fromObject=function(e){return this.g_A=s.fromObject(e.g_A),this.g_A_prime=s.fromObject(e.g_A_prime),this.g_B=a.fromObject(e.g_B),this.g_B_prime=s.fromObject(e.g_B_prime),this.g_C=s.fromObject(e.g_C),this.g_C_prime=s.fromObject(e.g_C_prime),this.g_K=s.fromObject(e.g_K),this.g_H=s.fromObject(e.g_H),this},u.prototype.toObject=u.prototype.toJSON=function(){return{g_A:this.g_A.toObject(),g_A_prime:this.g_A_prime.toObject(),g_B:this.g_B.toObject(),g_B_prime:this.g_B_prime.toObject(),g_C:this.g_C.toObject(),g_C_prime:this.g_C_prime.toObject(),g_K:this.g_K.toObject(),g_H:this.g_H.toObject()}},u.fromBufferReader=function(e){var t=new u;return t.g_A=s.fromBufferReader(e),t.g_A_prime=s.fromBufferReader(e),t.g_B=a.fromBufferReader(e),t.g_B_prime=s.fromBufferReader(e),t.g_C=s.fromBufferReader(e),t.g_C_prime=s.fromBufferReader(e),t.g_K=s.fromBufferReader(e),t.g_H=s.fromBufferReader(e),t},u.prototype.toBufferWriter=function(e){return e||(e=new o),this.g_A.toBufferWriter(e),this.g_A_prime.toBufferWriter(e),this.g_B.toBufferWriter(e),this.g_B_prime.toBufferWriter(e),this.g_C.toBufferWriter(e),this.g_C_prime.toBufferWriter(e),this.g_K.toBufferWriter(e),this.g_H.toBufferWriter(e),e},e.exports=u},function(e,t,r){"use strict";(function(t){var n=r(57),i=r(82),o=r(32),s=function e(r){if(!(this instanceof e))return new e(r);if(t.isBuffer(r))this.buf=r;else if("number"==typeof r){var n=r;this.fromNumber(n)}else if(r instanceof o){var i=r;this.fromBN(i)}else if(r){var s=r;this.set(s)}};s.prototype.set=function(e){return this.buf=e.buf||this.buf,this},s.prototype.fromString=function(e){return this.set({buf:new t(e,"hex")}),this},s.prototype.toString=function(){return this.buf.toString("hex")},s.prototype.fromBuffer=function(e){return this.buf=e,this},s.prototype.fromBufferReader=function(e){return this.buf=e.readVarintBuf(),this},s.prototype.fromBN=function(e){return this.buf=n().writeVarintBN(e).concat(),this},s.prototype.fromNumber=function(e){return this.buf=n().writeVarintNum(e).concat(),this},s.prototype.toBuffer=function(){return this.buf},s.prototype.toBN=function(){return i(this.buf).readVarintBN()},s.prototype.toNumber=function(){return i(this.buf).readVarintNum()},e.exports=s}).call(this,r(0).Buffer)},function(e,t,r){e.exports=r(902),e.exports.BlockHeader=r(180),e.exports.MerkleBlock=r(435)},function(e,t,r){"use strict";(function(t){var n=r(18),i=r(180),o=r(32),s=r(24),a=r(82),u=r(57),c=r(43),f=r(178),l=r(21);function h(e){return this instanceof h?(n.extend(this,h._from(e)),this):new h(e)}h.MAX_BLOCK_SIZE=1e6,h._from=function(e){var t={};if(s.isBuffer(e))t=h._fromBufferReader(a(e));else{if(!n.isObject(e))throw new TypeError("Unrecognized argument for Block");t=h._fromObject(e)}return t},h._fromObject=function(e){var t=[];return e.transactions.forEach(function(e){e instanceof f?t.push(e):t.push(f().fromObject(e))}),{header:i.fromObject(e.header),transactions:t}},h.fromObject=function(e){return new h(h._fromObject(e))},h._fromBufferReader=function(e){var t={};l.checkState(!e.finished(),"No block data received"),t.header=i.fromBufferReader(e);var r=e.readVarintNum();t.transactions=[];for(var n=0;n1;n=Math.floor((n+1)/2)){for(var i=0;i"},h.Values={START_OF_BLOCK:8,NULL_HASH:new t("0000000000000000000000000000000000000000000000000000000000000000","hex")},e.exports=h}).call(this,r(0).Buffer)},function(e,t,r){"use strict";var n=r(18),i=r(33),o=r(97),s=r(252),a=function(e,t){if(!(this instanceof a))return new a(e,t);if(this.extras={},this.knownParams=t||[],this.address=this.network=this.amount=this.message=null,"string"==typeof e){var r=a.parse(e);r.amount&&(r.amount=this._parseAmount(r.amount)),this._fromObject(r)}else{if("object"!=typeof e)throw new TypeError("Unrecognized data format.");this._fromObject(e)}};a.fromString=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return new a(e)},a.fromObject=function(e){return new a(e)},a.isValid=function(e,t){try{new a(e,t)}catch(e){return!1}return!0},a.parse=function(e){var t=i.parse(e,!0);if("zcash:"!==t.protocol)throw new TypeError("Invalid zcash URI");var r=/[^:]*:\/?\/?([^?]*)/.exec(e);return t.query.address=r&&r[1]||void 0,t.query},a.Members=["address","amount","message","label","r"],a.prototype._fromObject=function(e){if(!o.isValid(e.address))throw new TypeError("Invalid zcash address");for(var t in this.address=new o(e.address),this.network=this.address.network,this.amount=e.amount,e)if("address"!==t&&"amount"!==t){if(/^req-/.exec(t)&&-1===this.knownParams.indexOf(t))throw Error("Unknown required argument "+t);(a.Members.indexOf(t)>-1?this:this.extras)[t]=e[t]}},a.prototype._parseAmount=function(e){if(e=Number(e),isNaN(e))throw new TypeError("Invalid amount");return s.fromBTC(e).toSatoshis()},a.prototype.toObject=a.prototype.toJSON=function(){for(var e={},t=0;t"},e.exports=a},function(e,t,r){"use strict";e.exports={SHA1:20,SHA256:32,SHA512:64}},function(e,t,r){"use strict";const n=r(906),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(59);e.exports={createCipheriv:n.createCipheriv,createDecipheriv:n.createDecipheriv}},function(e,t,r){var n=r(439),i=r(443),o=r(2).Buffer,s=r(444),a=r(92),u=r(181),c=r(445);function f(e,t,r){a.call(this),this._cache=new h,this._cipher=new u.AES(t),this._prev=o.from(r),this._mode=e,this._autopadding=!0}r(5)(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 l=o.alloc(16,16);function h(){this.cache=o.allocUnsafe(0)}function p(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(l))throw this._cipher.scrub(),new Error("data not multiple of block length")},f.prototype.setAutoPadding=function(e){return this._autopadding=!!e,this},h.prototype.add=function(e){this.cache=o.concat([this.cache,e])},h.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},h.prototype.flush=function(){for(var e=16-this.cache.length,t=o.allocUnsafe(e),r=-1;++r>a%8,e._prev=o(e._prev,r?i:s);return u}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;e--)r[e]=r[e]>>>1|(1&r[e-1])<<31;r[0]=r[0]>>>1,t&&(r[0]=r[0]^225<<24)}this.state=o(n)},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){var n=r(443),i=r(2).Buffer,o=r(439),s=r(444),a=r(92),u=r(181),c=r(445);function f(e,t,r){a.call(this),this._cache=new l,this._last=void 0,this._cipher=new u.AES(t),this._prev=i.from(r),this._mode=e,this._autopadding=!0}function l(){this.cache=i.allocUnsafe(0)}function h(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(5)(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");for(var r=-1;++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},l.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=c(t,!1,r.key,r.iv);return h(e,n.key,n.iv)},t.createDecipheriv=h},function(e,t,r){"use strict";(function(n){const i=r(10)(r(256)),o=r(16);t=e.exports;const s={rsa:r(926),ed25519:r(940),secp256k1:r(61)(i,r(474))};function a(e){return void 0!==s[e.toLowerCase()]}t.supportedKeys=s,t.keysPBM=i,t.keyStretcher=r(953),t.generateEphemeralKeyPair=r(954),t.generateKeyPair=((e,t,r)=>{let 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)=>{let 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){(function(t){var r={};e.exports=r;var n={};r.encode=function(e,t,r){if("string"!=typeof t)throw new TypeError('"alphabet" must be a string.');if(void 0!==r&&"number"!=typeof r)throw new TypeError('"maxline" must be a number.');var n="";if(e instanceof Uint8Array){var i=0,o=t.length,s=t.charAt(0),a=[0];for(i=0;i0;)a.push(c%o),c=c/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 u="";for(r=0;0===e.at(r)&&r=0;--r)u+=t[o[r]];return u}(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(;l>0;)u.push(255&l),l>>=8}for(var h=0;e[h]===a&&h=i.Versions.TLS_1_1.minor&&u.output.putBytes(r),u.update(e.fragment),u.finish(a)&&(e.fragment=u.output,e.length=e.fragment.length(),o=!0),o}function a(e,t,r){if(!r){var n=e-t.length()%e;t.fillWithByte(n-1,n)}return!0}function u(e,t,r){var n=!0;if(r){for(var i=t.length(),o=t.last(),s=i-1-o;s=a?(e.fragment=s.output.getBytes(f-a),c=s.output.getBytes(a)):e.fragment=s.output.getBytes(),e.fragment=n.util.createBuffer(e.fragment),e.length=e.fragment.length();var l=t.macFunction(t.macKey,t.sequenceNumber,e);return t.updateSequenceNumber(),function(e,t,r){var i=n.hmac.create();return i.start("SHA1",e),i.update(t),t=i.digest().getBytes(),i.start(null,null),i.update(r),t===(r=i.digest().getBytes())}(t.macKey,c,l)&&o}},function(e,t,r){var n=r(13);r(458),e.exports=n.mgf=n.mgf||{},n.mgf.mgf1=n.mgf1},function(e,t,r){(function(t){var n=r(13);if(r(184),r(69),r(460),r(19),void 0===i)var i=n.jsbn.BigInteger;var o=n.util.ByteBuffer,s=void 0===t?Uint8Array:t;n.pki=n.pki||{},e.exports=n.pki.ed25519=n.ed25519=n.ed25519||{};var a=n.ed25519;function u(e){var r=e.message;if(r instanceof Uint8Array)return r;var n=e.encoding;if(void 0===r){if(!e.md)throw new TypeError('"options.message" or "options.md" not specified.');r=e.md.digest().getBytes(),n="binary"}if("string"==typeof r&&!n)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if("string"==typeof r){if(void 0!==t)return new t(r,n);r=new o(r,n)}else if(!(r instanceof o))throw new TypeError('"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.');for(var i=new s(r.length()),a=0;a=0};var c=R(),f=R([1]),l=R([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),h=R([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),p=R([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),d=R([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),y=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]),g=R([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function m(e,r){var i=n.md.sha512.create(),u=new o(e);i.update(u.getBytes(r),"binary");var c=i.digest().getBytes();if(void 0!==t)return new t(c,"binary");for(var f=new s(a.constants.HASH_BYTE_LENGTH),l=0;l<64;++l)f[l]=c.charCodeAt(l);return f}function b(e,t){var r,n,i,o;for(n=63;n>=32;--n){for(r=0,i=n-32,o=n-12;i>8,t[i]-=256*r;t[i]+=r,t[n]=0}for(r=0,i=0;i<32;++i)t[i]+=r-(t[31]>>4)*y[i],r=t[i]>>8,t[i]&=255;for(i=0;i<32;++i)t[i]-=r*y[i];for(n=0;n<32;++n)t[n+1]+=t[n]>>8,e[n]=255&t[n]}function v(e){for(var t=new Float64Array(64),r=0;r<64;++r)t[r]=e[r],e[r]=0;b(e,t)}function _(e,t){var r=R(),n=R(),i=R(),o=R(),s=R(),a=R(),u=R(),c=R(),f=R();L(r,e[1],e[0]),L(f,t[1],t[0]),j(r,r,f),N(n,e[0],e[1]),N(f,t[0],t[1]),j(n,n,f),j(i,e[3],t[3]),j(i,i,h),j(o,e[2],t[2]),N(o,o,o),L(s,n,r),L(a,o,i),N(u,o,i),N(c,n,r),j(e[0],s,a),j(e[1],c,u),j(e[2],u,a),j(e[3],s,c)}function w(e,t,r){for(var n=0;n<4;++n)O(e[n],t[n],r)}function S(e,t){var r=R(),n=R(),i=R();(function(e,t){var r,n=R();for(r=0;r<16;++r)n[r]=t[r];for(r=253;r>=0;--r)K(n,n),2!==r&&4!==r&&j(n,n,t);for(r=0;r<16;++r)e[r]=n[r]})(i,t[2]),j(r,t[0],i),j(n,t[1],i),k(e,n),e[31]^=I(r)<<7}function k(e,t){var r,n,i,o=R(),s=R();for(r=0;r<16;++r)s[r]=t[r];for(P(s),P(s),P(s),n=0;n<2;++n){for(o[0]=s[0]-65517,r=1;r<15;++r)o[r]=s[r]-65535-(o[r-1]>>16&1),o[r-1]&=65535;o[15]=s[15]-32767-(o[14]>>16&1),i=o[15]>>16&1,o[14]&=65535,O(s,o,1-i)}for(r=0;r<16;r++)e[2*r]=255&s[r],e[2*r+1]=s[r]>>8}function E(e,t){var r=R(),n=R(),i=R(),o=R(),s=R(),a=R(),u=R();return C(e[2],f),function(e,t){var r;for(r=0;r<16;++r)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}(e[1],t),K(i,e[1]),j(o,i,l),L(i,i,e[2]),N(o,e[2],o),K(s,o),K(a,s),j(u,a,s),j(r,u,i),j(r,r,o),function(e,t){var r,n=R();for(r=0;r<16;++r)n[r]=t[r];for(r=250;r>=0;--r)K(n,n),1!==r&&j(n,n,t);for(r=0;r<16;++r)e[r]=n[r]}(r,r),j(r,r,i),j(r,r,o),j(r,r,o),j(e[0],r,o),K(n,e[0]),j(n,n,o),A(n,i)&&j(e[0],e[0],g),K(n,e[0]),j(n,n,o),A(n,i)?-1:(I(e[0])===t[31]>>7&&L(e[0],c,e[0]),j(e[3],e[0],e[1]),0)}function A(e,t){var r=new s(32),n=new s(32);return k(r,e),k(n,t),x(r,0,n,0)}function x(e,t,r,n){return function(e,t,r,n,i){var o,s=0;for(o=0;o>>8)-1}(e,t,r,n,32)}function I(e){var t=new s(32);return k(t,e),1&t[0]}function T(e,t,r){var n,i;for(C(e[0],c),C(e[1],f),C(e[2],f),C(e[3],c),i=255;i>=0;--i)w(e,t,n=r[i/8|0]>>(7&i)&1),_(t,e),_(e,e),w(e,t,n)}function B(e,t){var r=[R(),R(),R(),R()];C(r[0],p),C(r[1],d),C(r[2],f),j(r[3],p,d),T(e,r,t)}function C(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function P(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 O(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 R(e){var t,r=new Float64Array(16);if(e)for(t=0;t0&&(s=n.util.fillString(String.fromCharCode(0),u)+s),{encapsulation:t.encrypt(s,"NONE"),key:e.generate(s,o)}},decrypt:function(t,r,n){var i=t.decrypt(r,"NONE");return e.generate(i,n)}}},n.kem.kdf1=function(e,t){o(this,e,0,t||e.digestLength)},n.kem.kdf2=function(e,t){o(this,e,1,t||e.digestLength)}},function(e,t,r){e.exports=r(77),r(258),r(134),r(451),r(460)},function(e,t,r){var n=r(13);r(98),r(76),r(182),r(99),r(112),r(457),r(69),r(19),r(260);var i=n.asn1,o=e.exports=n.pkcs7=n.pkcs7||{};function s(e){var t={},r=[];if(!i.validate(e,o.asn1.recipientInfoValidator,t,r)){var s=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw s.errors=r,s}return{version:t.version.charCodeAt(0),issuer:n.pki.RDNAttributesAsArray(t.issuer),serialNumber:n.util.createBuffer(t.serial).toHex(),encryptedContent:{algorithm:i.derToOid(t.encAlgorithm),parameter:t.encParameter.value,content:t.encKey}}}function a(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()),i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[n.pki.distinguishedNameToAsn1({attributes:e.issuer}),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.encryptedContent.algorithm).getBytes()),i.create(i.Class.UNIVERSAL,i.Type.NULL,!1,"")]),i.create(i.Class.UNIVERSAL,i.Type.OCTETSTRING,!1,e.encryptedContent.content)])}function u(e){var t=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,i.integerToDer(e.version).getBytes()),i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[n.pki.distinguishedNameToAsn1({attributes:e.issuer}),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.digestAlgorithm).getBytes()),i.create(i.Class.UNIVERSAL,i.Type.NULL,!1,"")])]);if(e.authenticatedAttributesAsn1&&t.value.push(e.authenticatedAttributesAsn1),t.value.push(i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(e.signatureAlgorithm).getBytes()),i.create(i.Class.UNIVERSAL,i.Type.NULL,!1,"")])),t.value.push(i.create(i.Class.UNIVERSAL,i.Type.OCTETSTRING,!1,e.signature)),e.unauthenticatedAttributes.length>0){for(var r=i.create(i.Class.CONTEXT_SPECIFIC,1,!0,[]),o=0;o=r&&s0&&s.value[0].value.push(i.create(i.Class.CONTEXT_SPECIFIC,0,!0,t)),o.length>0&&s.value[0].value.push(i.create(i.Class.CONTEXT_SPECIFIC,1,!0,o)),s.value[0].value.push(i.create(i.Class.UNIVERSAL,i.Type.SET,!0,e.signerInfos)),i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(e.type).getBytes()),s])},addSigner:function(t){var r=t.issuer,i=t.serialNumber;if(t.certificate){var o=t.certificate;"string"==typeof o&&(o=n.pki.certificateFromPem(o)),r=o.issuer.attributes,i=o.serialNumber}var s=t.key;if(!s)throw new Error("Could not add PKCS#7 signer; no private key specified.");"string"==typeof s&&(s=n.pki.privateKeyFromPem(s));var a=t.digestAlgorithm||n.pki.oids.sha1;switch(a){case n.pki.oids.sha1:case n.pki.oids.sha256:case n.pki.oids.sha384:case n.pki.oids.sha512:case n.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+a)}var u=t.authenticatedAttributes||[];if(u.length>0){for(var c=!1,f=!1,l=0;l="8"&&(r="00"+r);var i=n.util.hexToBytes(r);e.putInt32(i.length),e.putBytes(i)}function s(e,t){e.putInt32(t.length),e.putString(t)}function a(){for(var e=n.md.sha1.create(),t=arguments.length,r=0;r0&&(this.state=d[this.state].block)},y.prototype.unblock=function(e){return e=void 0===e?1:e,this.blocks-=e,0===this.blocks&&this.state!==h&&(this.state=c,g(this,0)),this.blocks},y.prototype.sleep=function(e){e=void 0===e?0:e,this.state=d[this.state].sleep;var t=this;this.timeoutId=setTimeout(function(){t.timeoutId=null,t.state=c,g(t,0)},e)},y.prototype.wait=function(e){e.wait(this)},y.prototype.wakeup=function(){this.state===l&&(cancelTimeout(this.timeoutId),this.timeoutId=null,this.state=c,g(this,0))},y.prototype.cancel=function(){this.state=d[this.state].cancel,this.permitsNeeded=0,null!==this.timeoutId&&(cancelTimeout(this.timeoutId),this.timeoutId=null),this.subtasks=[]},y.prototype.fail=function(e){if(this.error=!0,m(this,!0),e)e.error=this.error,e.swapTime=this.swapTime,e.userData=this.userData,g(e,0);else{if(null!==this.parent){for(var t=this.parent;null!==t.parent;)t.error=this.error,t.swapTime=this.swapTime,t.userData=this.userData,t=t.parent;m(t,!0)}this.failureCallback&&this.failureCallback(this)}};var g=function(e,t){var r=t>30||+new Date-e.swapTime>20,n=function(t){if(t++,e.state===c)if(r&&(e.swapTime=+new Date),e.subtasks.length>0){var n=e.subtasks.shift();n.error=e.error,n.swapTime=e.swapTime,n.userData=e.userData,n.run(n),n.error||g(n,t)}else m(e),e.error||null!==e.parent&&(e.parent.error=e.error,e.parent.swapTime=e.swapTime,e.parent.userData=e.userData,g(e.parent,t))};r?setTimeout(n,0):n(t)},m=function(e,t){e.state=h,delete o[e.id],null===e.parent&&(e.type in a?0===a[e.type].length?n.log.error(i,"[%s][%s] task queue empty [%s]",e.id,e.name,e.type):a[e.type][0]!==e?n.log.error(i,"[%s][%s] task not first in queue [%s]",e.id,e.name,e.type):(a[e.type].shift(),0===a[e.type].length?delete a[e.type]:a[e.type][0].start()):n.log.error(i,"[%s][%s] task queue missing [%s]",e.id,e.name,e.type),t||(e.error&&e.failureCallback?e.failureCallback(e):!e.error&&e.successCallback&&e.successCallback(e)))};e.exports=n.task=n.task||{},n.task.start=function(e){var t=new y({run:e.run,name:e.name||"?"});t.type=e.type,t.successCallback=e.success||null,t.failureCallback=e.failure||null,t.type in a?a[e.type].push(t):(a[t.type]=[t],function(e){e.error=!1,e.state=d[e.state].start,setTimeout(function(){e.state===c&&(e.swapTime=+new Date,e.run(e),g(e,0))},0)}(t))},n.task.cancel=function(e){e in a&&(a[e]=[a[e][0]])},n.task.createCondition=function(){var e={tasks:{},wait:function(t){t.id in e.tasks||(t.block(),e.tasks[t.id]=t)},notify:function(){var t=e.tasks;for(var r in e.tasks={},t)t[r].unblock()}};return e}},function(e,t,r){"use strict";const n=r(462),i=r(10),o=r(14),s=r(464),a=i(r(256)),u=r(16),c=r(3);class f{constructor(e){this._key=e}verify(e,t,r){h(r),s.hashAndVerify(this._key,t,e,r)}marshal(){return s.utils.jwkToPkix(this._key)}get bytes(){return a.PublicKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}encrypt(e){return this._key.encrypt(e,"RSAES-PKCS1-V1_5")}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(e),n(this.bytes,"sha2-256",e)}}class l{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return s.getRandomValues(new Uint8Array(16))}sign(e,t){h(t),s.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){s.decrypt(this._key,e,t)}marshal(){return s.utils.jwkToPkcs1(this._key)}get bytes(){return a.PrivateKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(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"),h(r),c(()=>{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 h(e){if("function"!=typeof e)throw new Error("callback is required")}e.exports={RsaPublicKey:f,RsaPrivateKey:l,unmarshalRsaPublicKey:function(e){const t=s.utils.pkixToJwk(e);return new f(t)},unmarshalRsaPrivateKey:function(e,t){const r=s.utils.pkcs1ToJwk(e);s.unmarshalPrivateKey(r,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},generateKeyPair:function(e,t){s.generateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},fromJwk:function(e,t){s.unmarshalPrivateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})}}},function(e,t,r){"use strict";(function(t){const n=r(38),i=r(39),o=r(463),s=r(928),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,256)),shake256:a(u(n.shake_256,512)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(929),dblSha2256:(e,r)=>{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(40),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;function o(e){if(!i)throw new Error("Please use a browser with webcrypto support");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(41),i=r(463).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(15),i=r(469),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())}),u=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()))}),c=n.define("RSAPublicKey",function(){this.seq().obj(this.key("algorithm").use(u),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=c.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 c.encode({algorithm:{algorithm:"rsa",none:null},subjectPublicKey:{data:f.encode({modulus:s(e.n),publicExponent:s(e.e)},"der")}},"der")}},function(e,t,r){"use strict";const n=r(15),i=r(5);function o(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}t.define=function(e,t){return new o(e,t)},o.prototype._createNamed=function(e){let t;try{t=r(932).runInThisContext("(function "+this.name+"(entity) {\n this._initNamed(entity);\n})")}catch(e){t=function(e){this._initNamed(e)}}return i(t,e),t.prototype._initNamed=function(t){e.call(this,t)},new t(this)},o.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(n.decoders[e])),this.decoders[e]},o.prototype.decode=function(e,t,r){return this._getDecoder(t).decode(e,r)},o.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(n.encoders[e])),this.encoders[e]},o.prototype.encode=function(e,t,r){return this._getEncoder(t).encode(e,r)}},function(module,exports,__webpack_require__){var indexOf=__webpack_require__(262),Object_keys=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var r in e)t.push(r);return t},forEach=function(e,t){if(e.forEach)return e.forEach(t);for(var r=0;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 l(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:u,Ed25519PrivateKey:c,unmarshalEd25519PrivateKey:function(e,t){try{e=l(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 c(r,n))},unmarshalEd25519PublicKey:function(e){return e=l(e,s.publicKeyLength),new u(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 c(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 c(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(60),i=r(3);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){},function(e,t,r){"use strict";(function(t){const n=r(38),i=r(39),o=r(471),s=r(944),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,256)),shake256:a(u(n.shake_256,512)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(945),dblSha2256:(e,r)=>{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(40),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;function o(e){if(!i)throw new Error("Please use a browser with webcrypto support");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(41),i=r(471).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(947),i=r(470),o=r(3),s="sha2-256";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));((e,r)=>o(()=>t(e,r)))(null,r)},privateKeyLength:32,hashAndSign:function(e,t,r){const a=(e,t)=>o(()=>r(e,t));i.digest(t,s,(t,r)=>{if(t)return a(t);try{const i=n.sign(r,e),o=n.signatureExport(i.signature);return a(null,o)}catch(t){a(t)}})},hashAndVerify:function(e,t,r,a){const u=(e,t)=>o(()=>a(e,t));i.digest(r,s,(r,i)=>{if(r)return u(r);try{t=n.signatureImport(t);const o=n.verify(i,t,e);return u(null,o)}catch(r){u(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(417)(r(948))},function(e,t,r){"use strict";var n=r(2).Buffer,i=r(123),o=r(949),s=r(245),a=r(185),u=r(472),c=r(952);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 c.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 c.mul(r).toPublicKey(t)},t.publicKeyConvert=function(e,t){var r=u.fromPublicKey(e);if(null===r)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return r.toPublicKey(t)},t.publicKeyVerify=function(e){return null!==u.fromPublicKey(e)},t.publicKeyTweakAdd=function(e,t,r){var n=u.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);return c.mul(t).add(n).toPublicKey(r)},t.publicKeyTweakMul=function(e,t,r){var n=u.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(d).ucmp(p.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 l=o;if(r>>1){if(l.ucmp(a.psn)>=0)break;l=o.add(a.n)}var h=n.concat([n.from([2+(1&r)]),l.toBuffer()]),p=u.fromPublicKey(h);if(null===p)break;var d=o.uinvm(),y=a.n.sub(a.fromBuffer(e)).umul(d).ureduce(),g=f.umul(d).ureduce();return u.fromECJPoint(c.mulAdd(y,p,g)).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=u.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";(function(t){var n=r(242),i=r(950),o=new t(0),s=new t([0]),a=new t([1]);function u(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)}u.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())},u.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.length>>13,p=0|s[1],d=8191&p,y=p>>>13,g=0|s[2],m=8191&g,b=g>>>13,v=0|s[3],_=8191&v,w=v>>>13,S=0|s[4],k=8191&S,E=S>>>13,A=0|s[5],x=8191&A,I=A>>>13,T=0|s[6],B=8191&T,C=T>>>13,P=0|s[7],O=8191&P,R=P>>>13,N=0|s[8],L=8191&N,K=N>>>13,j=0|s[9],M=8191&j,D=j>>>13,U=0|a[0],F=8191&U,q=U>>>13,H=0|a[1],z=8191&H,V=H>>>13,G=0|a[2],W=8191&G,$=G>>>13,Y=0|a[3],J=8191&Y,X=Y>>>13,Z=0|a[4],Q=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],ue=8191&ae,ce=ae>>>13,fe=0|a[8],le=8191&fe,he=fe>>>13,pe=0|a[9],de=8191&pe,ye=pe>>>13;r.length=19,n=Math.imul(l,F),i=Math.imul(l,q);var ge=c+n+((8191&(i+=Math.imul(h,F)))<<13);c=(o=Math.imul(h,q))+(i>>>13)+(ge>>>26),ge&=67108863,n=Math.imul(d,F),i=Math.imul(d,q),i+=Math.imul(y,F),o=Math.imul(y,q),n+=Math.imul(l,z),i+=Math.imul(l,V);var me=c+n+((8191&(i+=Math.imul(h,z)))<<13);c=(o+=Math.imul(h,V))+(i>>>13)+(me>>>26),me&=67108863,n=Math.imul(m,F),i=Math.imul(m,q),i+=Math.imul(b,F),o=Math.imul(b,q),n+=Math.imul(d,z),i+=Math.imul(d,V),i+=Math.imul(y,z),o+=Math.imul(y,V),n+=Math.imul(l,W),i+=Math.imul(l,$);var be=c+n+((8191&(i+=Math.imul(h,W)))<<13);c=(o+=Math.imul(h,$))+(i>>>13)+(be>>>26),be&=67108863,n=Math.imul(_,F),i=Math.imul(_,q),i+=Math.imul(w,F),o=Math.imul(w,q),n+=Math.imul(m,z),i+=Math.imul(m,V),i+=Math.imul(b,z),o+=Math.imul(b,V),n+=Math.imul(d,W),i+=Math.imul(d,$),i+=Math.imul(y,W),o+=Math.imul(y,$),n+=Math.imul(l,J),i+=Math.imul(l,X);var ve=c+n+((8191&(i+=Math.imul(h,J)))<<13);c=(o+=Math.imul(h,X))+(i>>>13)+(ve>>>26),ve&=67108863,n=Math.imul(k,F),i=Math.imul(k,q),i+=Math.imul(E,F),o=Math.imul(E,q),n+=Math.imul(_,z),i+=Math.imul(_,V),i+=Math.imul(w,z),o+=Math.imul(w,V),n+=Math.imul(m,W),i+=Math.imul(m,$),i+=Math.imul(b,W),o+=Math.imul(b,$),n+=Math.imul(d,J),i+=Math.imul(d,X),i+=Math.imul(y,J),o+=Math.imul(y,X),n+=Math.imul(l,Q),i+=Math.imul(l,ee);var _e=c+n+((8191&(i+=Math.imul(h,Q)))<<13);c=(o+=Math.imul(h,ee))+(i>>>13)+(_e>>>26),_e&=67108863,n=Math.imul(x,F),i=Math.imul(x,q),i+=Math.imul(I,F),o=Math.imul(I,q),n+=Math.imul(k,z),i+=Math.imul(k,V),i+=Math.imul(E,z),o+=Math.imul(E,V),n+=Math.imul(_,W),i+=Math.imul(_,$),i+=Math.imul(w,W),o+=Math.imul(w,$),n+=Math.imul(m,J),i+=Math.imul(m,X),i+=Math.imul(b,J),o+=Math.imul(b,X),n+=Math.imul(d,Q),i+=Math.imul(d,ee),i+=Math.imul(y,Q),o+=Math.imul(y,ee),n+=Math.imul(l,re),i+=Math.imul(l,ne);var we=c+n+((8191&(i+=Math.imul(h,re)))<<13);c=(o+=Math.imul(h,ne))+(i>>>13)+(we>>>26),we&=67108863,n=Math.imul(B,F),i=Math.imul(B,q),i+=Math.imul(C,F),o=Math.imul(C,q),n+=Math.imul(x,z),i+=Math.imul(x,V),i+=Math.imul(I,z),o+=Math.imul(I,V),n+=Math.imul(k,W),i+=Math.imul(k,$),i+=Math.imul(E,W),o+=Math.imul(E,$),n+=Math.imul(_,J),i+=Math.imul(_,X),i+=Math.imul(w,J),o+=Math.imul(w,X),n+=Math.imul(m,Q),i+=Math.imul(m,ee),i+=Math.imul(b,Q),o+=Math.imul(b,ee),n+=Math.imul(d,re),i+=Math.imul(d,ne),i+=Math.imul(y,re),o+=Math.imul(y,ne),n+=Math.imul(l,oe),i+=Math.imul(l,se);var Se=c+n+((8191&(i+=Math.imul(h,oe)))<<13);c=(o+=Math.imul(h,se))+(i>>>13)+(Se>>>26),Se&=67108863,n=Math.imul(O,F),i=Math.imul(O,q),i+=Math.imul(R,F),o=Math.imul(R,q),n+=Math.imul(B,z),i+=Math.imul(B,V),i+=Math.imul(C,z),o+=Math.imul(C,V),n+=Math.imul(x,W),i+=Math.imul(x,$),i+=Math.imul(I,W),o+=Math.imul(I,$),n+=Math.imul(k,J),i+=Math.imul(k,X),i+=Math.imul(E,J),o+=Math.imul(E,X),n+=Math.imul(_,Q),i+=Math.imul(_,ee),i+=Math.imul(w,Q),o+=Math.imul(w,ee),n+=Math.imul(m,re),i+=Math.imul(m,ne),i+=Math.imul(b,re),o+=Math.imul(b,ne),n+=Math.imul(d,oe),i+=Math.imul(d,se),i+=Math.imul(y,oe),o+=Math.imul(y,se),n+=Math.imul(l,ue),i+=Math.imul(l,ce);var ke=c+n+((8191&(i+=Math.imul(h,ue)))<<13);c=(o+=Math.imul(h,ce))+(i>>>13)+(ke>>>26),ke&=67108863,n=Math.imul(L,F),i=Math.imul(L,q),i+=Math.imul(K,F),o=Math.imul(K,q),n+=Math.imul(O,z),i+=Math.imul(O,V),i+=Math.imul(R,z),o+=Math.imul(R,V),n+=Math.imul(B,W),i+=Math.imul(B,$),i+=Math.imul(C,W),o+=Math.imul(C,$),n+=Math.imul(x,J),i+=Math.imul(x,X),i+=Math.imul(I,J),o+=Math.imul(I,X),n+=Math.imul(k,Q),i+=Math.imul(k,ee),i+=Math.imul(E,Q),o+=Math.imul(E,ee),n+=Math.imul(_,re),i+=Math.imul(_,ne),i+=Math.imul(w,re),o+=Math.imul(w,ne),n+=Math.imul(m,oe),i+=Math.imul(m,se),i+=Math.imul(b,oe),o+=Math.imul(b,se),n+=Math.imul(d,ue),i+=Math.imul(d,ce),i+=Math.imul(y,ue),o+=Math.imul(y,ce),n+=Math.imul(l,le),i+=Math.imul(l,he);var Ee=c+n+((8191&(i+=Math.imul(h,le)))<<13);c=(o+=Math.imul(h,he))+(i>>>13)+(Ee>>>26),Ee&=67108863,n=Math.imul(M,F),i=Math.imul(M,q),i+=Math.imul(D,F),o=Math.imul(D,q),n+=Math.imul(L,z),i+=Math.imul(L,V),i+=Math.imul(K,z),o+=Math.imul(K,V),n+=Math.imul(O,W),i+=Math.imul(O,$),i+=Math.imul(R,W),o+=Math.imul(R,$),n+=Math.imul(B,J),i+=Math.imul(B,X),i+=Math.imul(C,J),o+=Math.imul(C,X),n+=Math.imul(x,Q),i+=Math.imul(x,ee),i+=Math.imul(I,Q),o+=Math.imul(I,ee),n+=Math.imul(k,re),i+=Math.imul(k,ne),i+=Math.imul(E,re),o+=Math.imul(E,ne),n+=Math.imul(_,oe),i+=Math.imul(_,se),i+=Math.imul(w,oe),o+=Math.imul(w,se),n+=Math.imul(m,ue),i+=Math.imul(m,ce),i+=Math.imul(b,ue),o+=Math.imul(b,ce),n+=Math.imul(d,le),i+=Math.imul(d,he),i+=Math.imul(y,le),o+=Math.imul(y,he),n+=Math.imul(l,de),i+=Math.imul(l,ye);var Ae=c+n+((8191&(i+=Math.imul(h,de)))<<13);c=(o+=Math.imul(h,ye))+(i>>>13)+(Ae>>>26),Ae&=67108863,n=Math.imul(M,z),i=Math.imul(M,V),i+=Math.imul(D,z),o=Math.imul(D,V),n+=Math.imul(L,W),i+=Math.imul(L,$),i+=Math.imul(K,W),o+=Math.imul(K,$),n+=Math.imul(O,J),i+=Math.imul(O,X),i+=Math.imul(R,J),o+=Math.imul(R,X),n+=Math.imul(B,Q),i+=Math.imul(B,ee),i+=Math.imul(C,Q),o+=Math.imul(C,ee),n+=Math.imul(x,re),i+=Math.imul(x,ne),i+=Math.imul(I,re),o+=Math.imul(I,ne),n+=Math.imul(k,oe),i+=Math.imul(k,se),i+=Math.imul(E,oe),o+=Math.imul(E,se),n+=Math.imul(_,ue),i+=Math.imul(_,ce),i+=Math.imul(w,ue),o+=Math.imul(w,ce),n+=Math.imul(m,le),i+=Math.imul(m,he),i+=Math.imul(b,le),o+=Math.imul(b,he),n+=Math.imul(d,de),i+=Math.imul(d,ye);var xe=c+n+((8191&(i+=Math.imul(y,de)))<<13);c=(o+=Math.imul(y,ye))+(i>>>13)+(xe>>>26),xe&=67108863,n=Math.imul(M,W),i=Math.imul(M,$),i+=Math.imul(D,W),o=Math.imul(D,$),n+=Math.imul(L,J),i+=Math.imul(L,X),i+=Math.imul(K,J),o+=Math.imul(K,X),n+=Math.imul(O,Q),i+=Math.imul(O,ee),i+=Math.imul(R,Q),o+=Math.imul(R,ee),n+=Math.imul(B,re),i+=Math.imul(B,ne),i+=Math.imul(C,re),o+=Math.imul(C,ne),n+=Math.imul(x,oe),i+=Math.imul(x,se),i+=Math.imul(I,oe),o+=Math.imul(I,se),n+=Math.imul(k,ue),i+=Math.imul(k,ce),i+=Math.imul(E,ue),o+=Math.imul(E,ce),n+=Math.imul(_,le),i+=Math.imul(_,he),i+=Math.imul(w,le),o+=Math.imul(w,he),n+=Math.imul(m,de),i+=Math.imul(m,ye);var Ie=c+n+((8191&(i+=Math.imul(b,de)))<<13);c=(o+=Math.imul(b,ye))+(i>>>13)+(Ie>>>26),Ie&=67108863,n=Math.imul(M,J),i=Math.imul(M,X),i+=Math.imul(D,J),o=Math.imul(D,X),n+=Math.imul(L,Q),i+=Math.imul(L,ee),i+=Math.imul(K,Q),o+=Math.imul(K,ee),n+=Math.imul(O,re),i+=Math.imul(O,ne),i+=Math.imul(R,re),o+=Math.imul(R,ne),n+=Math.imul(B,oe),i+=Math.imul(B,se),i+=Math.imul(C,oe),o+=Math.imul(C,se),n+=Math.imul(x,ue),i+=Math.imul(x,ce),i+=Math.imul(I,ue),o+=Math.imul(I,ce),n+=Math.imul(k,le),i+=Math.imul(k,he),i+=Math.imul(E,le),o+=Math.imul(E,he),n+=Math.imul(_,de),i+=Math.imul(_,ye);var Te=c+n+((8191&(i+=Math.imul(w,de)))<<13);c=(o+=Math.imul(w,ye))+(i>>>13)+(Te>>>26),Te&=67108863,n=Math.imul(M,Q),i=Math.imul(M,ee),i+=Math.imul(D,Q),o=Math.imul(D,ee),n+=Math.imul(L,re),i+=Math.imul(L,ne),i+=Math.imul(K,re),o+=Math.imul(K,ne),n+=Math.imul(O,oe),i+=Math.imul(O,se),i+=Math.imul(R,oe),o+=Math.imul(R,se),n+=Math.imul(B,ue),i+=Math.imul(B,ce),i+=Math.imul(C,ue),o+=Math.imul(C,ce),n+=Math.imul(x,le),i+=Math.imul(x,he),i+=Math.imul(I,le),o+=Math.imul(I,he),n+=Math.imul(k,de),i+=Math.imul(k,ye);var Be=c+n+((8191&(i+=Math.imul(E,de)))<<13);c=(o+=Math.imul(E,ye))+(i>>>13)+(Be>>>26),Be&=67108863,n=Math.imul(M,re),i=Math.imul(M,ne),i+=Math.imul(D,re),o=Math.imul(D,ne),n+=Math.imul(L,oe),i+=Math.imul(L,se),i+=Math.imul(K,oe),o+=Math.imul(K,se),n+=Math.imul(O,ue),i+=Math.imul(O,ce),i+=Math.imul(R,ue),o+=Math.imul(R,ce),n+=Math.imul(B,le),i+=Math.imul(B,he),i+=Math.imul(C,le),o+=Math.imul(C,he),n+=Math.imul(x,de),i+=Math.imul(x,ye);var Ce=c+n+((8191&(i+=Math.imul(I,de)))<<13);c=(o+=Math.imul(I,ye))+(i>>>13)+(Ce>>>26),Ce&=67108863,n=Math.imul(M,oe),i=Math.imul(M,se),i+=Math.imul(D,oe),o=Math.imul(D,se),n+=Math.imul(L,ue),i+=Math.imul(L,ce),i+=Math.imul(K,ue),o+=Math.imul(K,ce),n+=Math.imul(O,le),i+=Math.imul(O,he),i+=Math.imul(R,le),o+=Math.imul(R,he),n+=Math.imul(B,de),i+=Math.imul(B,ye);var Pe=c+n+((8191&(i+=Math.imul(C,de)))<<13);c=(o+=Math.imul(C,ye))+(i>>>13)+(Pe>>>26),Pe&=67108863,n=Math.imul(M,ue),i=Math.imul(M,ce),i+=Math.imul(D,ue),o=Math.imul(D,ce),n+=Math.imul(L,le),i+=Math.imul(L,he),i+=Math.imul(K,le),o+=Math.imul(K,he),n+=Math.imul(O,de),i+=Math.imul(O,ye);var Oe=c+n+((8191&(i+=Math.imul(R,de)))<<13);c=(o+=Math.imul(R,ye))+(i>>>13)+(Oe>>>26),Oe&=67108863,n=Math.imul(M,le),i=Math.imul(M,he),i+=Math.imul(D,le),o=Math.imul(D,he),n+=Math.imul(L,de),i+=Math.imul(L,ye);var Re=c+n+((8191&(i+=Math.imul(K,de)))<<13);c=(o+=Math.imul(K,ye))+(i>>>13)+(Re>>>26),Re&=67108863,n=Math.imul(M,de),i=Math.imul(M,ye);var Ne=c+n+((8191&(i+=Math.imul(D,de)))<<13);return c=(o=Math.imul(D,ye))+(i>>>13)+(Ne>>>26),Ne&=67108863,u[0]=ge,u[1]=me,u[2]=be,u[3]=ve,u[4]=_e,u[5]=we,u[6]=Se,u[7]=ke,u[8]=Ee,u[9]=Ae,u[10]=xe,u[11]=Ie,u[12]=Te,u[13]=Be,u[14]=Ce,u[15]=Pe,u[16]=Oe,u[17]=Re,u[18]=Ne,0!==c&&(u[19]=c,r.length++),r}},function(e,t,r){"use strict";var n=r(2).Buffer,i=r(185),o=r(472),s=r(473);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=c;l--)f=(f<<1)+i[l];u.push(f)}for(var h=new s(null,null,null),p=new s(null,null,null),d=a;d>0;d--){for(var y=0;y=0;f--){for(var l=0;f>=0&&(c[0]=0|a[0][f],c[1]=0|a[1][f],0===c[0]&&0===c[1]);++l,--f);if(f>=0&&(l+=1),u=u.dblp(l),f<0)break;for(var h=0;h<2;h++){var p,d=c[h];0!==d&&(d>0?p=o[h][d>>1]:d<0&&(p=o[h][-d>>1].neg()),u=void 0===p.z?u.mixedAdd(p):u.add(p))}}return u},e.exports=new a},function(e,t,r){"use strict";(function(t){const n=r(37),i=r(438),o={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,cipherKeySize:32}};e.exports=((e,r,s,a)=>{const u=o[e];if(!u)return a(new Error("unkown cipherType passed"));if(!r)return a(new Error("unkown hashType passed"));const c=u.keySize,f=u.ivSize,l=t.from("key expansion"),h=2*(f+c+20);i.create(r,s,(e,r)=>{if(e)return a(e);r.digest(l,(e,i)=>{if(e)return a(e);let o=[],s=0;n(()=>s{if(t)return e(t);let a=n.length;s+a>h&&(a=h-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=h/2,n=t.concat(o),i=n.slice(0,r),s=n.slice(r,h),u=e=>({iv:e.slice(0,f),cipherKey:e.slice(f,f+c),macKey:e.slice(f+c)});a(null,{k1:u(i),k2:u(s)})})})})})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(955);e.exports=((e,t)=>{n.generateEphmeralKeyPair(e,t)})},function(e,t,r){"use strict";(function(e){const n=r(255)(),i=r(254),o=r(15).bignum,s=r(469),a=s.toBase64,u=s.toBn,c={"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 o=(o,s,a)=>{let u;"function"==typeof s&&(a=s,s=void 0),u=s?n.subtle.importKey("jwk",p(t,s),{name:"ECDH",namedCurve:t},!1,["deriveBits"]):Promise.resolve(r.privateKey);const f=Promise.all([n.subtle.importKey("jwk",h(t,o),{name:"ECDH",namedCurve:t},!1,[]),u]);i(f.then(e=>n.subtle.deriveBits({name:"ECDH",namedCurve:t,public:e[0]},e[1],c[t])).then(t=>e.from(t)),a)};return n.subtle.exportKey("jwk",r.publicKey).then(e=>({key:l(e),genSharedKey:o}))}),r)};const f={"P-256":32,"P-384":48,"P-521":66};function l(t){const r=f[t.crv];return e.concat([e.from([4]),u(t.x).toArrayLike(e,"be",r),u(t.y).toArrayLike(e,"be",r)],1+2*r)}function h(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}}function p(e,t){const r=h(e,t.public);return r.d=a(new o(t.private)),r}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(16),i={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};e.exports=function(e,t,r,o,s){const a=i[s];if(!a)throw new Error(`Hash '${s}' is unknown or not supported`);const u=n.pkcs5.pbkdf2(e,t,r,o,a);return n.util.encode64(u)}},function(e,t,r){"use strict";(function(n){const i=r(12),o=r(958),s=r(17),a=r(4);class u{constructor(e,t,r){s(n.isBuffer(e),"invalid id provided"),t&&r&&s(t.public.bytes.equals(r.bytes),"inconsistent arguments"),this._id=e,this._idB58String=i.toB58String(this.id),this._privKey=t,this._pubKey=r}get id(){return this._id}set id(e){throw new Error("Id is immutable")}get privKey(){return this._privKey}set privKey(e){this._privKey=e}get pubKey(){return this._pubKey?this._pubKey:this._privKey?this._privKey.public:void 0}set pubKey(e){this._pubKey=e}marshalPubKey(){if(this.pubKey)return o.keys.marshalPublicKey(this.pubKey)}marshalPrivKey(){if(this.privKey)return o.keys.marshalPrivateKey(this.privKey)}toPrint(){return this.toJSON()}toJSON(){return{id:this.toB58String(),privKey:c(this.marshalPrivKey()),pubKey:c(this.marshalPubKey())}}toHexString(){return i.toHexString(this.id)}toBytes(){return this.id}toB58String(){return this._idB58String}isEqual(e){if(n.isBuffer(e))return this.id.equals(e);if(e.id)return this.id.equals(e.id);throw new Error("not valid Id")}isValid(e){this.privKey&&this.privKey.public&&this.privKey.public.bytes&&n.isBuffer(this.pubKey.bytes)&&this.privKey.public.bytes.equals(this.pubKey.bytes)?e():e(new Error("Keys not match"))}}function c(e){if(e)return e.toString("base64")}(t=e.exports=u).create=function(e,t){"function"==typeof e&&(t=e,e={}),(e=e||{}).bits=e.bits||2048,a([t=>o.keys.generateKeyPair("RSA",e.bits,t),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n))})},t.createFromHexString=function(e){return new u(i.fromHexString(e))},t.createFromBytes=function(e){return new u(e)},t.createFromB58String=function(e){return new u(i.fromB58String(e))},t.createFromPubKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r;try{let i=e;if("string"==typeof i&&(i=n.from(e,"base64")),!n.isBuffer(i))throw new Error("Supplied key is neither a base64 string nor a buffer");r=o.keys.unmarshalPublicKey(i)}catch(e){return t(e)}r.hash((e,n)=>{if(e)return t(e);t(null,new u(n,null,r))})},t.createFromPrivKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r=e;try{if("string"==typeof r&&(r=n.from(e,"base64")),!n.isBuffer(r))throw new Error("Supplied key is neither a base64 string nor a buffer")}catch(e){return t(e)}a([e=>o.keys.unmarshalPrivateKey(r,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n,n.public))})},t.createFromJSON=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r,s,c,f;try{r=i.fromB58String(e.id),s=e.privKey&&n.from(e.privKey,"base64"),c=e.pubKey&&n.from(e.pubKey,"base64"),f=c&&o.keys.unmarshalPublicKey(c)}catch(e){return t(e)}s?a([e=>o.keys.unmarshalPrivateKey(s,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)}),(e,t,r)=>{f?f.hash((n,i)=>{r(n,e,t,i)}):r(null,e,t)}],(e,n,i,o)=>e?t(e):f&&!n.equals(o)?t(new Error("Public and private key do not match")):r&&!n.equals(r)?t(new Error("Id and private key do not match")):void t(null,new u(r,i,f))):t(null,new u(r,null,f))},t.isPeerId=function(e){return Boolean("object"==typeof e&&e._id&&e._idB58String)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(475),i=r(960),o=r(962);(t=e.exports).aes=i,t.hmac=n,t.keys=o,t.randomBytes=r(480),t.pbkdf2=r(973)},function(e,t,r){"use strict";e.exports={SHA1:20,SHA256:32,SHA512:64}},function(e,t,r){"use strict";const n=r(961),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(59);e.exports={createCipheriv:n.createCipheriv,createDecipheriv:n.createDecipheriv}},function(e,t,r){"use strict";(function(n){const i=r(10)(r(265)),o=r(16);t=e.exports;const s={rsa:r(963),ed25519:r(968),secp256k1:r(61)(i,r(480))};function a(e){return void 0!==s[e.toLowerCase()]}t.supportedKeys=s,t.keysPBM=i,t.keyStretcher=r(970),t.generateEphemeralKeyPair=r(971),t.generateKeyPair=((e,t,r)=>{let 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)=>{let 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){"use strict";const n=r(476),i=r(10),o=r(14),s=r(478),a=i(r(265)),u=r(16),c=r(3);class f{constructor(e){this._key=e}verify(e,t,r){h(r),s.hashAndVerify(this._key,t,e,r)}marshal(){return s.utils.jwkToPkix(this._key)}get bytes(){return a.PublicKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}encrypt(e){return this._key.encrypt(e,"RSAES-PKCS1-V1_5")}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(e),n(this.bytes,"sha2-256",e)}}class l{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return s.getRandomValues(new Uint8Array(16))}sign(e,t){h(t),s.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){s.decrypt(this._key,e,t)}marshal(){return s.utils.jwkToPkcs1(this._key)}get bytes(){return a.PrivateKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(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"),h(r),c(()=>{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 h(e){if("function"!=typeof e)throw new Error("callback is required")}e.exports={RsaPublicKey:f,RsaPrivateKey:l,unmarshalRsaPublicKey:function(e){const t=s.utils.pkixToJwk(e);return new f(t)},unmarshalRsaPrivateKey:function(e,t){const r=s.utils.pkcs1ToJwk(e);s.unmarshalPrivateKey(r,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},generateKeyPair:function(e,t){s.generateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},fromJwk:function(e,t){s.unmarshalPrivateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})}}},function(e,t,r){"use strict";(function(t){const n=r(38),i=r(39),o=r(477),s=r(965),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,256)),shake256:a(u(n.shake_256,512)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(966),dblSha2256:(e,r)=>{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(40),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;function o(e){if(!i)throw new Error("Please use a browser with webcrypto support");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(41),i=r(477).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(15),i=r(479),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())}),u=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()))}),c=n.define("RSAPublicKey",function(){this.seq().obj(this.key("algorithm").use(u),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=c.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 c.encode({algorithm:{algorithm:"rsa",none:null},subjectPublicKey:{data:f.encode({modulus:s(e.n),publicExponent:s(e.e)},"der")}},"der")}},function(e,t,r){"use strict";(function(t){const n=r(476),i=r(10),o=r(14),s=r(969),a=i(r(265));class u{constructor(e){this._key=l(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 c{constructor(e,t){this._key=l(e,s.privateKeyLength),this._publicKey=l(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 u(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 l(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:u,Ed25519PrivateKey:c,unmarshalEd25519PrivateKey:function(e,t){try{e=l(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 c(r,n))},unmarshalEd25519PublicKey:function(e){return e=l(e,s.publicKeyLength),new u(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 c(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 c(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(60),i=r(3);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){"use strict";(function(t){const n=r(37),i=r(475),o={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,cipherKeySize:32}};e.exports=((e,r,s,a)=>{const u=o[e];if(!u)return a(new Error("unkown cipherType passed"));if(!r)return a(new Error("unkown hashType passed"));const c=u.keySize,f=u.ivSize,l=t.from("key expansion"),h=2*(f+c+20);i.create(r,s,(e,r)=>{if(e)return a(e);r.digest(l,(e,i)=>{if(e)return a(e);let o=[],s=0;n(()=>s{if(t)return e(t);let a=n.length;s+a>h&&(a=h-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=h/2,n=t.concat(o),i=n.slice(0,r),s=n.slice(r,h),u=e=>({iv:e.slice(0,f),cipherKey:e.slice(f,f+c),macKey:e.slice(f+c)});a(null,{k1:u(i),k2:u(s)})})})})})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(972);e.exports=((e,t)=>{n.generateEphmeralKeyPair(e,t)})},function(e,t,r){"use strict";(function(e){const n=r(264)(),i=r(263),o=r(15).bignum,s=r(479),a=s.toBase64,u=s.toBn,c={"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 o=(o,s,a)=>{let u;"function"==typeof s&&(a=s,s=void 0),u=s?n.subtle.importKey("jwk",p(t,s),{name:"ECDH",namedCurve:t},!1,["deriveBits"]):Promise.resolve(r.privateKey);const f=Promise.all([n.subtle.importKey("jwk",h(t,o),{name:"ECDH",namedCurve:t},!1,[]),u]);i(f.then(e=>n.subtle.deriveBits({name:"ECDH",namedCurve:t,public:e[0]},e[1],c[t])).then(t=>e.from(t)),a)};return n.subtle.exportKey("jwk",r.publicKey).then(e=>({key:l(e),genSharedKey:o}))}),r)};const f={"P-256":32,"P-384":48,"P-521":66};function l(t){const r=f[t.crv];return e.concat([e.from([4]),u(t.x).toArrayLike(e,"be",r),u(t.y).toArrayLike(e,"be",r)],1+2*r)}function h(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}}function p(e,t){const r=h(e,t.public);return r.d=a(new o(t.private)),r}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(16),i={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};e.exports=function(e,t,r,o,s){const a=i[s];if(!a)throw new Error(`Hash '${s}' is unknown or not supported`);const u=n.pkcs5.pbkdf2(e,t,r,o,a);return n.util.encode64(u)}},function(e,t,r){"use strict";(function(t){const n=r(44),i=r(26),o=r(975),s=r(268),a=r(20),u=r(14),c=r(62),f=new Error("Sorry, Not Implemented Yet."),l=c.proto(function(e){if(!(this instanceof l))return new l(e);if(null==e&&(e=""),e instanceof t)this.buffer=o.fromBuffer(e);else if("string"==typeof e||e instanceof String)this.buffer=o.fromString(e);else{if(!(e.buffer&&e.protos&&e.protoCodes))throw new Error("addr must be a string, Buffer, or another Multiaddr");this.buffer=o.fromBuffer(e.buffer)}},{className:"Multiaddr",symbolName:"@multiformats/js-multiaddr/multiaddr"});l.prototype.toString=function(){return o.bufferToString(this.buffer)},l.prototype.toOptions=function(){const e={},t=this.toString().split("/");return e.family="ip4"===t[1]?"ipv4":"ipv6",e.host=t[2],e.transport=t[3],e.port=t[4],e},l.prototype.inspect=function(){return""},l.prototype.protos=function(){return n(this.protoCodes(),function(e){return i(s(e))})},l.prototype.protoCodes=function(){const e=[],t=this.buffer;let r=0;for(;r{if(e[0]===s.names.ipfs.code)return!0})[0][1],u.decode(e)}catch(t){e=null}return e},l.prototype.equals=function(e){return this.buffer.equals(e.buffer)},l.prototype.nodeAddress=function(){if(!this.isThinWaistAddress())throw new Error('Multiaddr must be "thin waist" address for nodeAddress.');const e=this.protoCodes(),t=this.toString().split("/").slice(1);return{family:41===e[0]?"IPv6":"IPv4",address:t[1],port:t[3]}},l.fromNodeAddress=function(e,t){if(!e)throw new Error("requires node address object");if(!t)throw new Error("requires transport protocol");const r="IPv6"===e.family?"ip6":"ip4";return l("/"+[r,e.address,t,e.port].join("/"))},l.prototype.isThinWaistAddress=function(e){const t=(e||this).protos();return!(2!==t.length||4!==t[0].code&&41!==t[0].code||6!==t[1].code&&17!==t[1].code)},l.prototype.fromStupidString=function(e){throw f},l.protocols=s,l.isName=function(e){return!!l.isMultiaddr(e)&&e.protos().some(e=>e.resolvable)},l.resolve=function(e,t){return l.isMultiaddr(e)&&l.isName(e)?t(new Error("not implemented yet")):t(new Error("not a valid name"))},e.exports=l}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(44),i=r(136),o=r(976),s=r(268),a=r(20);function u(e){const t=[],r=e.split("/").slice(1);if(1===r.length&&""===r[0])return[];for(let n=0;n=r.length)throw v("invalid address: "+e);t.push([i,r[n]])}else t.push([i])}return t}function c(e){const t=[];return n(e,function(e){const r=_(e);t.push(r.name),e.length>1&&t.push(e[1])}),"/"+t.join("/")}function f(e){return n(e,function(e){Array.isArray(e)||(e=[e]);const t=_(e);return e.length>1?[t.code,o.toBuffer(t.code,e[1])]:[t.code]})}function l(e){return n(e,function(e){const t=_(e);return e.length>1?[t.code,o.toString(t.code,e[1])]:[t.code]})}function h(e){return g(t.concat(n(e,function(e){const r=_(e);let n=t.from(a.encode(r.code));return e.length>1&&(n=t.concat([n,e[1]])),n})))}function p(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;return a.decode(t)+a.decode.bytes}function d(e){const t=[];let r=0;for(;re.length)throw v("Invalid address buffer: "+e.toString("hex"));t.push([n,u])}return t}function y(e){return h(f(u(e=b(e))))}function g(e){const r=m(e);if(r)throw r;return t.from(e)}function m(e){try{d(e)}catch(e){return e}}function b(e){return"/"+i(e.trim().split("/")).join("/")}function v(e){return new Error("Error parsing address: "+e)}function _(e){return s(e[0])}e.exports={stringToStringTuples:u,stringTuplesToString:c,tuplesToStringTuples:l,stringTuplesToTuples:f,bufferToTuples:d,tuplesToBuffer:h,bufferToString:function(e){return c(l(d(e)))},stringToBuffer:y,fromString:function(e){return y(e)},fromBuffer:g,validateBuffer:m,isValidBuffer:function(e){return void 0===m(e)},cleanPath:b,ParseError:v,protoFromTuple:_,sizeForAddr:p}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(137),i=r(138),o=r(268),s=r(14),a=r(20);function u(e,r){return r instanceof t?u.toString(e,r):u.toBuffer(e,r)}function c(e){if(!e.isValid())throw new Error("invalid ip address");return n.toBuffer(e.address)}e.exports=u,u.toString=function(e,t){switch((e=o(e)).code){case 4:case 41:return n.toString(t);case 6:case 17:case 33:case 132:return function(e){return e.readUInt16BE(0)}(t);case 54:case 55:case 56:return function(e){const t=a.decode(e);if((e=e.slice(a.decode.bytes)).length!==t)throw new Error("inconsistent lengths");return e.toString()}(t);case 421:return function(e){const t=a.decode(e),r=e.slice(a.decode.bytes);if(r.length!==t)throw new Error("inconsistent lengths");return s.encode(r)}(t);default:return t.toString("hex")}},u.toBuffer=function(e,r){switch((e=o(e)).code){case 4:return c(new i.Address4(r));case 41:return c(new i.Address6(r));case 6:case 17:case 33:case 132:return function(e){const r=t.alloc(2);return r.writeUInt16BE(e,0),r}(parseInt(r,10));case 54:case 55:case 56:return function(e){const r=t.from(e),n=t.from(a.encode(r.length));return t.concat([n,r])}(r);case 421:return function(e){const r=t.from(s.decode(e)),n=t.from(a.encode(r.length));return t.concat([n,r])}(r);default:return t.from(r,"hex")}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";var n=r(483).BigInteger,i=r(487),o=r(978),s=r(979),a=r(485),u=r(486),c=r(139).sprintf,f=r(266),l=r(267),h=r(482);function p(e){return(e=e.replace(/^(0{1,})([1-9]+)$/,'$1$2')).replace(/^(0{1,})(0)$/,'$1$2')}function d(e,t){this.groups=void 0===t?l.GROUPS:t,this.v4=!1,this.subnet="/128",this.subnetMask=128,this.zone="",this.address=e;var r=l.RE_SUBNET_STRING.exec(e);if(r){if(this.parsedSubnet=r[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet="/"+this.subnetMask,isNaN(this.subnetMask)||this.subnetMask<0||this.subnetMask>l.BITS)return this.valid=!1,void(this.error="Invalid subnet mask.");e=e.replace(l.RE_SUBNET_STRING,"")}else if(/\//.test(e))return this.valid=!1,void(this.error="Invalid subnet mask.");var n=l.RE_ZONE_STRING.exec(e);n&&(this.zone=n[0],e=e.replace(l.RE_ZONE_STRING,"")),this.addressMinusSuffix=e,this.parsedAddress=this.parse(this.addressMinusSuffix)}function y(e){return c("%04x",parseInt(e,16))}function g(e){return 255&e}s(d.prototype,r(980)),s(d.prototype,r(981)),s(d.prototype,r(982)),d.fromBigInteger=function(e){var t,r=a(e.toString(16),32,"0"),n=[];for(t=0;t65536)&&(r=null):r=null,{address:new d(t),port:r}},d.fromAddress4=function(e){e=new h(e);var t=l.BITS-(f.BITS-e.subnetMask);return new d("::ffff:"+e.correctForm()+"/"+t)},d.fromArpa=function(e){var t=e.replace(/(\.ip6\.arpa)?\.$/,"");if(63!==t.length)return{error:"Not Valid 'ip6.arpa' form",address:null};t=t.split(".").reverse();for(var r=7;r>0;r--){var n=4*r;t.splice(n,0,":")}return new d(t=t.join(""))},d.prototype.microsoftTranscription=function(){return c("%s.ipv6-literal.net",this.correctForm().replace(/:/g,"-"))},d.prototype.mask=function(e){return void 0===e&&(e=this.subnetMask),this.getBitsBase2(0,e)},d.prototype.possibleSubnets=function(e){void 0===e&&(e=128);var t=l.BITS-this.subnetMask-Math.abs(e-l.BITS);return t<0?"0":function(e){for(var t=/(\d+)(\d{3})/;t.test(e);)e=e.replace(t,"$1,$2");return e}(new n("2",10).pow(t).toString(10))},d.prototype.startAddress=function(){var e=new n(this.mask()+u(0,l.BITS-this.subnetMask),2);return d.fromBigInteger(e)},d.prototype.endAddress=function(){var e=new n(this.mask()+u(1,l.BITS-this.subnetMask),2);return d.fromBigInteger(e)},d.prototype.getScope=function(){var e=l.SCOPES[this.getBits(12,16)];return"Global unicast"===this.getType()&&"Link local"!==e&&(e="Global"),e},d.prototype.getType=function(){var e=this;return i(l.TYPES,function(t,r){return e.isInSubnet(new d(r))})||"Global unicast"},d.prototype.getBits=function(e,t){return new n(this.getBitsBase2(e,t),2)},d.prototype.getBitsBase2=function(e,t){return this.binaryZeroPad().slice(e,t)},d.prototype.getBitsBase16=function(e,t){var r=t-e;return r%4!=0?null:a(this.getBits(e,t).toString(16),r/4,"0")},d.prototype.getBitsPastSubnet=function(){return this.getBitsBase2(this.subnetMask,l.BITS)},d.prototype.reverseForm=function(e){e||(e={});var t=Math.floor(this.subnetMask/4),r=this.canonicalForm().replace(/:/g,"").split("").slice(0,t).reverse().join(".");return t>0?e.omitSuffix?r:c("%s.ip6.arpa.",r):e.omitSuffix?"":"ip6.arpa."},d.prototype.correctForm=function(){if(!this.parsedAddress)return null;var e,t=[],r=0,n=[];for(e=0;e0&&(r>1&&n.push([e-r,e-1]),r=0)}r>1&&n.push([this.parsedAddress.length-r,this.parsedAddress.length-1]);var s=n.map(function(e){return e[1]-e[0]+1});if(n.length>0){var a=s.indexOf(o(s));t=function(e,t){var r,n=[],i=[];for(r=0;rt[1]&&i.push(e[r]);return n.concat(["compact"]).concat(i)}(this.parsedAddress,n[a])}else t=this.parsedAddress;for(e=0;e1?"s":"",t.join("")),this.parseError=e.replace(l.RE_BAD_CHARACTERS,'$1'),null;var r=e.match(l.RE_BAD_ADDRESS);if(r)return this.valid=!1,this.error=c("Address failed regex: %s",r.join("")),this.parseError=e.replace(l.RE_BAD_ADDRESS,'$1'),null;var n=[],i=e.split("::");if(2===i.length){var o=i[0].split(":"),s=i[1].split(":");1===o.length&&""===o[0]&&(o=[]),1===s.length&&""===s[0]&&(s=[]);var a=this.groups-(o.length+s.length);if(!a)return this.valid=!1,this.error="Error parsing groups",null;this.elidedGroups=a,this.elisionBegin=o.length,this.elisionEnd=o.length+this.elidedGroups,o.forEach(function(e){n.push(e)});for(var u=0;u=0;o--)r=r.add(i.multiply(new n(e[o].toString(10),10))),i=i.multiply(t);return d.fromBigInteger(r)},e.exports=d},function(e,t){var r="[object Symbol]",n=Object.prototype.toString;function i(e,t){return e>t}function o(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&n.call(e)==r}function s(e){return e}e.exports=function(e){return e&&e.length?function(e,t,r){for(var n=-1,i=e.length;++n-1},ne.prototype.set=function(e,t){var r=this.__data__,n=ce(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},ie.prototype.clear=function(){this.size=0,this.__data__={hash:new re,map:new(Q||ne),string:new re}},ie.prototype.delete=function(e){var t=be(this,e).delete(e);return this.size-=t?1:0,t},ie.prototype.get=function(e){return be(this,e).get(e)},ie.prototype.has=function(e){return be(this,e).has(e)},ie.prototype.set=function(e,t){var r=be(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},oe.prototype.clear=function(){this.__data__=new ne,this.size=0},oe.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},oe.prototype.get=function(e){return this.__data__.get(e)},oe.prototype.has=function(e){return this.__data__.has(e)},oe.prototype.set=function(e,t){var r=this.__data__;if(r instanceof ne){var i=r.__data__;if(!Q||i.length-1&&e%1==0&&e0){if(++t>=o)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(Y?function(e,t){return Y(e,"toString",{configurable:!0,enumerable:!1,value:function(e){return function(){return e}}(t),writable:!0})}:Le);function ke(e,t){return e===t||e!=e&&t!=t}var Ee=pe(function(){return arguments}())?pe:function(e){return Pe(e)&&L.call(e,"callee")&&!G.call(e,"callee")},Ae=Array.isArray;function xe(e){return null!=e&&Be(e.length)&&!Te(e)}var Ie=J||function(){return!1};function Te(e){if(!Ce(e))return!1;var t=he(e);return t==f||t==l||t==c||t==d}function Be(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=a}function Ce(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Pe(e){return null!=e&&"object"==typeof e}var Oe=I?function(e){return function(t){return e(t)}}(I):function(e){return Pe(e)&&Be(e.length)&&!!b[he(e)]};function Re(e){return xe(e)?se(e,!0):ye(e)}var Ne=function(e){return me(function(t,r){var n=-1,i=r.length,o=i>1?r[i-1]:void 0,s=i>2?r[2]:void 0;for(o=e.length>3&&"function"==typeof o?(i--,o):void 0,s&&function(e,t,r){if(!Ce(r))return!1;var n=typeof t;return!!("number"==n?xe(r)&&_e(t,r.length):"string"==n&&t in r)&&ke(r[t],e)}(r[0],r[1],s)&&(o=i<3?void 0:o,i=1),t=Object(t);++n%2$s',e.prefix,t.call(this),e.className):o('%2$s',e.prefix,t.call(this))},t.group=function(){var e,t=this.address.match(n.RE_ADDRESS);if(t){var r=t[0].split(".");this.address=this.address.replace(n.RE_ADDRESS,o('%s.%s',r.slice(0,2).join("."),r.slice(2,4).join(".")))}if(0===this.elidedGroups)return i.simpleGroup(this.address);var s=[],a=this.address.split("::");a[0].length?s.push(i.simpleGroup(a[0])):s.push("");var u=["hover-group"];for(e=this.elisionBegin;e',u.join(" "))),a[1].length?s.push(i.simpleGroup(a[1],this.elisionEnd)):s.push(""),s.join(":")}},function(e,t,r){"use strict";var n=r(139).sprintf,i=r(267);function o(e){return n("(%s)",e.join("|"))}function s(e){return e.length<4?n("0{0,%d}%s",4-e.length,e):e}function a(e){var t=[];e.forEach(function(e,r){0===parseInt(e,16)&&t.push(r)});var r=t.map(function(t){return e.map(function(e,r){if(r===t){var n=0===r||r===i.GROUPS-1?":":"";return o([s(e),n])}return s(e)}).join(":")});return r.push(e.map(s).join(":")),o(r)}function u(e,t,r){var i=t?"":":",s=r?"":":",a=[];t||r||a.push("::"),t&&r&&a.push(""),(r&&!t||!r&&t)&&a.push(":"),a.push(n("%s(:0{1,4}){1,%d}",i,e-1)),a.push(n("(0{1,4}:){1,%d}%s",e-1,s)),a.push(n("(0{1,4}:){%d}0{1,4}",e-1));for(var u=1;u{if(t.equals(e))return this.add(e),this._observedMultiaddrs.splice(r,1),!0})||this._observedMultiaddrs.push(e)}toArray(){return this._multiaddrs.slice()}get size(){return this._multiaddrs.length}forEach(e){return this._multiaddrs.forEach(e)}filterBy(e){return"object"!=typeof e||"function"!=typeof e.matches||"function"!=typeof e.partialMatch||"function"!=typeof e.toString?[]:this._multiaddrs.filter(t=>e.matches(t))}has(e){return e=n(e),this._multiaddrs.some(t=>t.equals(e))}delete(e){e=n(e),this._multiaddrs.some((t,r)=>{if(t.equals(e))return this._multiaddrs.splice(r,1),!0})}replace(e,t){Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]),e.forEach(e=>this.delete(e)),t.forEach(e=>this.add(e))}clear(){this._multiaddrs=[]}distinct(){return i(this._multiaddrs,e=>[e.toOptions().port,e.toOptions().transport].join())}}},function(e,t,r){(function(e,r){var n=200,i="Expected a function",o="__lodash_hash_undefined__",s=1,a=2,u=1/0,c=9007199254740991,f="[object Arguments]",l="[object Array]",h="[object Boolean]",p="[object Date]",d="[object Error]",y="[object Function]",g="[object GeneratorFunction]",m="[object Map]",b="[object Number]",v="[object Object]",_="[object Promise]",w="[object RegExp]",S="[object Set]",k="[object String]",E="[object Symbol]",A="[object WeakMap]",x="[object ArrayBuffer]",I="[object DataView]",T=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,B=/^\w*$/,C=/^\./,P=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,O=/\\(\\)?/g,R=/^\[object .+?Constructor\]$/,N=/^(?:0|[1-9]\d*)$/,L={};L["[object Float32Array]"]=L["[object Float64Array]"]=L["[object Int8Array]"]=L["[object Int16Array]"]=L["[object Int32Array]"]=L["[object Uint8Array]"]=L["[object Uint8ClampedArray]"]=L["[object Uint16Array]"]=L["[object Uint32Array]"]=!0,L[f]=L[l]=L[x]=L[h]=L[I]=L[p]=L[d]=L[y]=L[m]=L[b]=L[v]=L[w]=L[S]=L[k]=L[A]=!1;var K="object"==typeof e&&e&&e.Object===Object&&e,j="object"==typeof self&&self&&self.Object===Object&&self,M=K||j||Function("return this")(),D="object"==typeof t&&t&&!t.nodeType&&t,U=D&&"object"==typeof r&&r&&!r.nodeType&&r,F=U&&U.exports===D&&K.process,q=function(){try{return F&&F.binding("util")}catch(e){}}(),H=q&&q.isTypedArray;function z(e,t){return!(!e||!e.length)&&function(e,t,r){if(t!=t)return function(e,t,r,n){for(var i=e.length,o=r+(n?1:-1);n?o--:++o-1}function V(e,t,r){for(var n=-1,i=e?e.length:0;++n-1},Te.prototype.set=function(e,t){var r=this.__data__,n=Re(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Be.prototype.clear=function(){this.__data__={hash:new Ie,map:new(de||Te),string:new Ie}},Be.prototype.delete=function(e){return ze(this,e).delete(e)},Be.prototype.get=function(e){return ze(this,e).get(e)},Be.prototype.has=function(e){return ze(this,e).has(e)},Be.prototype.set=function(e,t){return ze(this,e).set(e,t),this},Ce.prototype.add=Ce.prototype.push=function(e){return this.__data__.set(e,o),this},Ce.prototype.has=function(e){return this.__data__.has(e)},Pe.prototype.clear=function(){this.__data__=new Te},Pe.prototype.delete=function(e){return this.__data__.delete(e)},Pe.prototype.get=function(e){return this.__data__.get(e)},Pe.prototype.has=function(e){return this.__data__.has(e)},Pe.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Te){var i=r.__data__;if(!de||i.lengthc))return!1;var l=o.get(e);if(l&&o.get(t))return l==t;var h=-1,p=!0,d=i&s?new Ce:void 0;for(o.set(e,t),o.set(t,e);++h-1&&e%1==0&&e-1&&e%1==0&&e<=c}function at(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function ut(e){return!!e&&"object"==typeof e}function ct(e){return"symbol"==typeof e||ut(e)&&se.call(e)==E}var ft=H?function(e){return function(t){return e(t)}}(H):function(e){return ut(e)&&st(e.length)&&!!L[se.call(e)]};function lt(e){return it(e)?Oe(e):De(e)}function ht(e){return e}r.exports=function(e,t){return e&&e.length?function(e,t,r){var i=-1,o=z,s=e.length,a=!0,u=[],c=u;if(r)a=!1,o=V;else if(s>=n){var f=t?null:Fe(e);if(f)return X(f);a=!1,o=$,c=new Ce}else c=t?[]:u;e:for(;++i=r.length)throw v("invalid address: "+e);t.push([i,r[n]])}else t.push([i])}return t}function c(e){const t=[];return n(e,function(e){const r=_(e);t.push(r.name),e.length>1&&t.push(e[1])}),"/"+t.join("/")}function f(e){return n(e,function(e){Array.isArray(e)||(e=[e]);const t=_(e);return e.length>1?[t.code,o.toBuffer(t.code,e[1])]:[t.code]})}function l(e){return n(e,function(e){const t=_(e);return e.length>1?[t.code,o.toString(t.code,e[1])]:[t.code]})}function h(e){return g(t.concat(n(e,function(e){const r=_(e);let n=t.from(a.encode(r.code));return e.length>1&&(n=t.concat([n,e[1]])),n})))}function p(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;return a.decode(t)+a.decode.bytes}function d(e){const t=[];let r=0;for(;re.length)throw v("Invalid address buffer: "+e.toString("hex"));t.push([n,u])}return t}function y(e){return h(f(u(e=b(e))))}function g(e){const r=m(e);if(r)throw r;return t.from(e)}function m(e){try{d(e)}catch(e){return e}}function b(e){return"/"+i(e.trim().split("/")).join("/")}function v(e){return new Error("Error parsing address: "+e)}function _(e){return s(e[0])}e.exports={stringToStringTuples:u,stringTuplesToString:c,tuplesToStringTuples:l,stringTuplesToTuples:f,bufferToTuples:d,tuplesToBuffer:h,bufferToString:function(e){return c(l(d(e)))},stringToBuffer:y,fromString:function(e){return y(e)},fromBuffer:g,validateBuffer:m,isValidBuffer:function(e){return void 0===m(e)},cleanPath:b,ParseError:v,protoFromTuple:_,sizeForAddr:p}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(137),i=r(138),o=r(269),s=r(14),a=r(20);function u(e,r){return r instanceof t?u.toString(e,r):u.toBuffer(e,r)}function c(e){if(!e.isValid())throw new Error("invalid ip address");return n.toBuffer(e.address)}e.exports=u,u.toString=function(e,t){switch((e=o(e)).code){case 4:case 41:return n.toString(t);case 6:case 17:case 33:case 132:return function(e){return e.readUInt16BE(0)}(t);case 54:case 55:case 56:return function(e){const t=a.decode(e);if((e=e.slice(a.decode.bytes)).length!==t)throw new Error("inconsistent lengths");return e.toString()}(t);case 421:return function(e){const t=a.decode(e),r=e.slice(a.decode.bytes);if(r.length!==t)throw new Error("inconsistent lengths");return s.encode(r)}(t);default:return t.toString("hex")}},u.toBuffer=function(e,r){switch((e=o(e)).code){case 4:return c(new i.Address4(r));case 41:return c(new i.Address6(r));case 6:case 17:case 33:case 132:return function(e){const r=t.alloc(2);return r.writeUInt16BE(e,0),r}(parseInt(r,10));case 54:case 55:case 56:return function(e){const r=t.from(e),n=t.from(a.encode(r.length));return t.concat([n,r])}(r);case 421:return function(e){const r=t.from(s.decode(e)),n=t.from(a.encode(r.length));return t.concat([n,r])}(r);default:return t.from(r,"hex")}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(n){const i=r(12),o=r(988),s=r(17),a=r(4);class u{constructor(e,t,r){s(n.isBuffer(e),"invalid id provided"),t&&r&&s(t.public.bytes.equals(r.bytes),"inconsistent arguments"),this._id=e,this._idB58String=i.toB58String(this.id),this._privKey=t,this._pubKey=r}get id(){return this._id}set id(e){throw new Error("Id is immutable")}get privKey(){return this._privKey}set privKey(e){this._privKey=e}get pubKey(){return this._pubKey?this._pubKey:this._privKey?this._privKey.public:void 0}set pubKey(e){this._pubKey=e}marshalPubKey(){if(this.pubKey)return o.keys.marshalPublicKey(this.pubKey)}marshalPrivKey(){if(this.privKey)return o.keys.marshalPrivateKey(this.privKey)}toPrint(){return this.toJSON()}toJSON(){return{id:this.toB58String(),privKey:c(this.marshalPrivKey()),pubKey:c(this.marshalPubKey())}}toHexString(){return i.toHexString(this.id)}toBytes(){return this.id}toB58String(){return this._idB58String}isEqual(e){if(n.isBuffer(e))return this.id.equals(e);if(e.id)return this.id.equals(e.id);throw new Error("not valid Id")}isValid(e){this.privKey&&this.privKey.public&&this.privKey.public.bytes&&n.isBuffer(this.pubKey.bytes)&&this.privKey.public.bytes.equals(this.pubKey.bytes)?e():e(new Error("Keys not match"))}}function c(e){if(e)return e.toString("base64")}(t=e.exports=u).create=function(e,t){"function"==typeof e&&(t=e,e={}),(e=e||{}).bits=e.bits||2048,a([t=>o.keys.generateKeyPair("RSA",e.bits,t),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n))})},t.createFromHexString=function(e){return new u(i.fromHexString(e))},t.createFromBytes=function(e){return new u(e)},t.createFromB58String=function(e){return new u(i.fromB58String(e))},t.createFromPubKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r;try{let i=e;if("string"==typeof i&&(i=n.from(e,"base64")),!n.isBuffer(i))throw new Error("Supplied key is neither a base64 string nor a buffer");r=o.keys.unmarshalPublicKey(i)}catch(e){return t(e)}r.hash((e,n)=>{if(e)return t(e);t(null,new u(n,null,r))})},t.createFromPrivKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r=e;try{if("string"==typeof r&&(r=n.from(e,"base64")),!n.isBuffer(r))throw new Error("Supplied key is neither a base64 string nor a buffer")}catch(e){return t(e)}a([e=>o.keys.unmarshalPrivateKey(r,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n,n.public))})},t.createFromJSON=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r,s,c,f;try{r=i.fromB58String(e.id),s=e.privKey&&n.from(e.privKey,"base64"),c=e.pubKey&&n.from(e.pubKey,"base64"),f=c&&o.keys.unmarshalPublicKey(c)}catch(e){return t(e)}s?a([e=>o.keys.unmarshalPrivateKey(s,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)}),(e,t,r)=>{f?f.hash((n,i)=>{r(n,e,t,i)}):r(null,e,t)}],(e,n,i,o)=>e?t(e):f&&!n.equals(o)?t(new Error("Public and private key do not match")):r&&!n.equals(r)?t(new Error("Id and private key do not match")):void t(null,new u(r,i,f))):t(null,new u(r,null,f))},t.isPeerId=function(e){return Boolean("object"==typeof e&&e._id&&e._idB58String)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(491),i=r(990),o=r(992);(t=e.exports).aes=i,t.hmac=n,t.keys=o,t.randomBytes=r(496),t.pbkdf2=r(1003)},function(e,t,r){"use strict";e.exports={SHA1:20,SHA256:32,SHA512:64}},function(e,t,r){"use strict";const n=r(991),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(59);e.exports={createCipheriv:n.createCipheriv,createDecipheriv:n.createDecipheriv}},function(e,t,r){"use strict";(function(n){const i=r(10)(r(272)),o=r(16);t=e.exports;const s={rsa:r(993),ed25519:r(998),secp256k1:r(61)(i,r(496))};function a(e){return void 0!==s[e.toLowerCase()]}t.supportedKeys=s,t.keysPBM=i,t.keyStretcher=r(1e3),t.generateEphemeralKeyPair=r(1001),t.generateKeyPair=((e,t,r)=>{let 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)=>{let 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){"use strict";const n=r(492),i=r(10),o=r(14),s=r(494),a=i(r(272)),u=r(16),c=r(3);class f{constructor(e){this._key=e}verify(e,t,r){h(r),s.hashAndVerify(this._key,t,e,r)}marshal(){return s.utils.jwkToPkix(this._key)}get bytes(){return a.PublicKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}encrypt(e){return this._key.encrypt(e,"RSAES-PKCS1-V1_5")}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(e),n(this.bytes,"sha2-256",e)}}class l{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return s.getRandomValues(new Uint8Array(16))}sign(e,t){h(t),s.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){s.decrypt(this._key,e,t)}marshal(){return s.utils.jwkToPkcs1(this._key)}get bytes(){return a.PrivateKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(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"),h(r),c(()=>{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 h(e){if("function"!=typeof e)throw new Error("callback is required")}e.exports={RsaPublicKey:f,RsaPrivateKey:l,unmarshalRsaPublicKey:function(e){const t=s.utils.pkixToJwk(e);return new f(t)},unmarshalRsaPrivateKey:function(e,t){const r=s.utils.pkcs1ToJwk(e);s.unmarshalPrivateKey(r,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},generateKeyPair:function(e,t){s.generateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},fromJwk:function(e,t){s.unmarshalPrivateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})}}},function(e,t,r){"use strict";(function(t){const n=r(38),i=r(39),o=r(493),s=r(995),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,256)),shake256:a(u(n.shake_256,512)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(996),dblSha2256:(e,r)=>{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(40),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;function o(e){if(!i)throw new Error("Please use a browser with webcrypto support");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(41),i=r(493).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(15),i=r(495),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())}),u=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()))}),c=n.define("RSAPublicKey",function(){this.seq().obj(this.key("algorithm").use(u),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=c.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 c.encode({algorithm:{algorithm:"rsa",none:null},subjectPublicKey:{data:f.encode({modulus:s(e.n),publicExponent:s(e.e)},"der")}},"der")}},function(e,t,r){"use strict";(function(t){const n=r(492),i=r(10),o=r(14),s=r(999),a=i(r(272));class u{constructor(e){this._key=l(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 c{constructor(e,t){this._key=l(e,s.privateKeyLength),this._publicKey=l(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 u(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 l(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:u,Ed25519PrivateKey:c,unmarshalEd25519PrivateKey:function(e,t){try{e=l(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 c(r,n))},unmarshalEd25519PublicKey:function(e){return e=l(e,s.publicKeyLength),new u(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 c(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 c(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(60),i=r(3);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){"use strict";(function(t){const n=r(37),i=r(491),o={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,cipherKeySize:32}};e.exports=((e,r,s,a)=>{const u=o[e];if(!u)return a(new Error("unkown cipherType passed"));if(!r)return a(new Error("unkown hashType passed"));const c=u.keySize,f=u.ivSize,l=t.from("key expansion"),h=2*(f+c+20);i.create(r,s,(e,r)=>{if(e)return a(e);r.digest(l,(e,i)=>{if(e)return a(e);let o=[],s=0;n(()=>s{if(t)return e(t);let a=n.length;s+a>h&&(a=h-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=h/2,n=t.concat(o),i=n.slice(0,r),s=n.slice(r,h),u=e=>({iv:e.slice(0,f),cipherKey:e.slice(f,f+c),macKey:e.slice(f+c)});a(null,{k1:u(i),k2:u(s)})})})})})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(1002);e.exports=((e,t)=>{n.generateEphmeralKeyPair(e,t)})},function(e,t,r){"use strict";(function(e){const n=r(271)(),i=r(270),o=r(15).bignum,s=r(495),a=s.toBase64,u=s.toBn,c={"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 o=(o,s,a)=>{let u;"function"==typeof s&&(a=s,s=void 0),u=s?n.subtle.importKey("jwk",p(t,s),{name:"ECDH",namedCurve:t},!1,["deriveBits"]):Promise.resolve(r.privateKey);const f=Promise.all([n.subtle.importKey("jwk",h(t,o),{name:"ECDH",namedCurve:t},!1,[]),u]);i(f.then(e=>n.subtle.deriveBits({name:"ECDH",namedCurve:t,public:e[0]},e[1],c[t])).then(t=>e.from(t)),a)};return n.subtle.exportKey("jwk",r.publicKey).then(e=>({key:l(e),genSharedKey:o}))}),r)};const f={"P-256":32,"P-384":48,"P-521":66};function l(t){const r=f[t.crv];return e.concat([e.from([4]),u(t.x).toArrayLike(e,"be",r),u(t.y).toArrayLike(e,"be",r)],1+2*r)}function h(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}}function p(e,t){const r=h(e,t.public);return r.d=a(new o(t.private)),r}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(16),i={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};e.exports=function(e,t,r,o,s){const a=i[s];if(!a)throw new Error(`Hash '${s}' is unknown or not supported`);const u=n.pkcs5.pbkdf2(e,t,r,o,a);return n.util.encode64(u)}},function(e,t,r){"use strict";const n=r(497).extend(r(1005)),i=n.object().keys({repo:n.alternatives().try(n.object(),n.string()).allow(null),repoOwner:n.boolean().default(!0),preload:n.object().keys({enabled:n.boolean().default(!0),addresses:n.array().items(n.multiaddr().options({convert:!1}))}).allow(null),init:n.alternatives().try(n.boolean(),n.object().keys({bits:n.number().integer()})).allow(null),start:n.boolean(),pass:n.string().allow(""),relay:n.object().keys({enabled:n.boolean(),hop:n.object().keys({enabled:n.boolean(),active:n.boolean()}).allow(null)}).allow(null),EXPERIMENTAL:n.object().keys({pubsub:n.boolean(),sharding:n.boolean(),dht:n.boolean()}).allow(null),connectionManager:n.object().allow(null),config:n.object().keys({Addresses:n.object().keys({Swarm:n.array().items(n.multiaddr().options({convert:!1})),API:n.multiaddr().options({convert:!1}),Gateway:n.multiaddr().options({convert:!1})}).allow(null),Discovery:n.object().keys({MDNS:n.object().keys({Enabled:n.boolean(),Interval:n.number().integer()}).allow(null),webRTCStar:n.object().keys({Enabled:n.boolean()}).allow(null)}).allow(null),Bootstrap:n.array().items(n.multiaddr().IPFS().options({convert:!1}))}).allow(null),libp2p:n.object().keys({modules:n.object().allow(null)}).allow(null)}).options({allowUnknown:!0});e.exports.validate=(e=>n.attempt(e,i))},function(e,t,r){const n=r(1006),i=r(78);e.exports={name:"multiaddr",language:{invalid:"{{message}}",fmt:"must be in {{fmt}} format"},pre(e,t,r){if(null==e)return this.createError("multiaddr.invalid",{v:e,message:"addr must be a string, Buffer, or another Multiaddr"},t,r);let i;try{i=n(e)}catch(n){return this.createError("multiaddr.invalid",{v:e,message:n.message},t,r)}return r.convert?i:e},rules:Object.keys(i).map(e=>({name:e,validate(t,r,n,o){return i[e].matches(r)?r:this.createError("multiaddr.fmt",{v:r,fmt:e},n,o)}}))}},function(e,t,r){"use strict";(function(t){const n=r(44),i=r(26),o=r(1007),s=r(274),a=r(20),u=r(14),c=r(62),f=new Error("Sorry, Not Implemented Yet."),l=c.proto(function(e){if(!(this instanceof l))return new l(e);if(null==e&&(e=""),e instanceof t)this.buffer=o.fromBuffer(e);else if("string"==typeof e||e instanceof String)this.buffer=o.fromString(e);else{if(!(e.buffer&&e.protos&&e.protoCodes))throw new Error("addr must be a string, Buffer, or another Multiaddr");this.buffer=o.fromBuffer(e.buffer)}},{className:"Multiaddr",symbolName:"@multiformats/js-multiaddr/multiaddr"});l.prototype.toString=function(){return o.bufferToString(this.buffer)},l.prototype.toOptions=function(){const e={},t=this.toString().split("/");return e.family="ip4"===t[1]?"ipv4":"ipv6",e.host=t[2],e.transport=t[3],e.port=t[4],e},l.prototype.inspect=function(){return""},l.prototype.protos=function(){return n(this.protoCodes(),function(e){return i(s(e))})},l.prototype.protoCodes=function(){const e=[],t=this.buffer;let r=0;for(;r{if(e[0]===s.names.ipfs.code)return!0})[0][1],u.decode(e)}catch(t){e=null}return e},l.prototype.equals=function(e){return this.buffer.equals(e.buffer)},l.prototype.nodeAddress=function(){if(!this.isThinWaistAddress())throw new Error('Multiaddr must be "thin waist" address for nodeAddress.');const e=this.protoCodes(),t=this.toString().split("/").slice(1);return{family:41===e[0]?"IPv6":"IPv4",address:t[1],port:t[3]}},l.fromNodeAddress=function(e,t){if(!e)throw new Error("requires node address object");if(!t)throw new Error("requires transport protocol");const r="IPv6"===e.family?"ip6":"ip4";return l("/"+[r,e.address,t,e.port].join("/"))},l.prototype.isThinWaistAddress=function(e){const t=(e||this).protos();return!(2!==t.length||4!==t[0].code&&41!==t[0].code||6!==t[1].code&&17!==t[1].code)},l.prototype.fromStupidString=function(e){throw f},l.protocols=s,l.isName=function(e){return!!l.isMultiaddr(e)&&e.protos().some(e=>e.resolvable)},l.resolve=function(e,t){return l.isMultiaddr(e)&&l.isName(e)?t(new Error("not implemented yet")):t(new Error("not a valid name"))},e.exports=l}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(44),i=r(136),o=r(1008),s=r(274),a=r(20);function u(e){const t=[],r=e.split("/").slice(1);if(1===r.length&&""===r[0])return[];for(let n=0;n=r.length)throw v("invalid address: "+e);t.push([i,r[n]])}else t.push([i])}return t}function c(e){const t=[];return n(e,function(e){const r=_(e);t.push(r.name),e.length>1&&t.push(e[1])}),"/"+t.join("/")}function f(e){return n(e,function(e){Array.isArray(e)||(e=[e]);const t=_(e);return e.length>1?[t.code,o.toBuffer(t.code,e[1])]:[t.code]})}function l(e){return n(e,function(e){const t=_(e);return e.length>1?[t.code,o.toString(t.code,e[1])]:[t.code]})}function h(e){return g(t.concat(n(e,function(e){const r=_(e);let n=t.from(a.encode(r.code));return e.length>1&&(n=t.concat([n,e[1]])),n})))}function p(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;return a.decode(t)+a.decode.bytes}function d(e){const t=[];let r=0;for(;re.length)throw v("Invalid address buffer: "+e.toString("hex"));t.push([n,u])}return t}function y(e){return h(f(u(e=b(e))))}function g(e){const r=m(e);if(r)throw r;return t.from(e)}function m(e){try{d(e)}catch(e){return e}}function b(e){return"/"+i(e.trim().split("/")).join("/")}function v(e){return new Error("Error parsing address: "+e)}function _(e){return s(e[0])}e.exports={stringToStringTuples:u,stringTuplesToString:c,tuplesToStringTuples:l,stringTuplesToTuples:f,bufferToTuples:d,tuplesToBuffer:h,bufferToString:function(e){return c(l(d(e)))},stringToBuffer:y,fromString:function(e){return y(e)},fromBuffer:g,validateBuffer:m,isValidBuffer:function(e){return void 0===m(e)},cleanPath:b,ParseError:v,protoFromTuple:_,sizeForAddr:p}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(137),i=r(138),o=r(274),s=r(14),a=r(20);function u(e,r){return r instanceof t?u.toString(e,r):u.toBuffer(e,r)}function c(e){if(!e.isValid())throw new Error("invalid ip address");return n.toBuffer(e.address)}e.exports=u,u.toString=function(e,t){switch((e=o(e)).code){case 4:case 41:return n.toString(t);case 6:case 17:case 33:case 132:return function(e){return e.readUInt16BE(0)}(t);case 54:case 55:case 56:return function(e){const t=a.decode(e);if((e=e.slice(a.decode.bytes)).length!==t)throw new Error("inconsistent lengths");return e.toString()}(t);case 421:return function(e){const t=a.decode(e),r=e.slice(a.decode.bytes);if(r.length!==t)throw new Error("inconsistent lengths");return s.encode(r)}(t);default:return t.toString("hex")}},u.toBuffer=function(e,r){switch((e=o(e)).code){case 4:return c(new i.Address4(r));case 41:return c(new i.Address6(r));case 6:case 17:case 33:case 132:return function(e){const r=t.alloc(2);return r.writeUInt16BE(e,0),r}(parseInt(r,10));case 54:case 55:case 56:return function(e){const r=t.from(e),n=t.from(a.encode(r.length));return t.concat([n,r])}(r);case 421:return function(e){const r=t.from(s.decode(e)),n=t.from(a.encode(r.length));return t.concat([n,r])}(r);default:return t.from(r,"hex")}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(44),i=r(26),o=r(1010),s=r(275),a=r(20),u=r(14),c=r(62),f=new Error("Sorry, Not Implemented Yet."),l=c.proto(function(e){if(!(this instanceof l))return new l(e);if(null==e&&(e=""),e instanceof t)this.buffer=o.fromBuffer(e);else if("string"==typeof e||e instanceof String)this.buffer=o.fromString(e);else{if(!(e.buffer&&e.protos&&e.protoCodes))throw new Error("addr must be a string, Buffer, or another Multiaddr");this.buffer=o.fromBuffer(e.buffer)}},{className:"Multiaddr",symbolName:"@multiformats/js-multiaddr/multiaddr"});l.prototype.toString=function(){return o.bufferToString(this.buffer)},l.prototype.toOptions=function(){const e={},t=this.toString().split("/");return e.family="ip4"===t[1]?"ipv4":"ipv6",e.host=t[2],e.transport=t[3],e.port=t[4],e},l.prototype.inspect=function(){return""},l.prototype.protos=function(){return n(this.protoCodes(),function(e){return i(s(e))})},l.prototype.protoCodes=function(){const e=[],t=this.buffer;let r=0;for(;r{if(e[0]===s.names.ipfs.code)return!0})[0][1],u.decode(e)}catch(t){e=null}return e},l.prototype.equals=function(e){return this.buffer.equals(e.buffer)},l.prototype.nodeAddress=function(){if(!this.isThinWaistAddress())throw new Error('Multiaddr must be "thin waist" address for nodeAddress.');const e=this.protoCodes(),t=this.toString().split("/").slice(1);return{family:41===e[0]?"IPv6":"IPv4",address:t[1],port:t[3]}},l.fromNodeAddress=function(e,t){if(!e)throw new Error("requires node address object");if(!t)throw new Error("requires transport protocol");const r="IPv6"===e.family?"ip6":"ip4";return l("/"+[r,e.address,t,e.port].join("/"))},l.prototype.isThinWaistAddress=function(e){const t=(e||this).protos();return!(2!==t.length||4!==t[0].code&&41!==t[0].code||6!==t[1].code&&17!==t[1].code)},l.prototype.fromStupidString=function(e){throw f},l.protocols=s,l.isName=function(e){return!!l.isMultiaddr(e)&&e.protos().some(e=>e.resolvable)},l.resolve=function(e,t){return l.isMultiaddr(e)&&l.isName(e)?t(new Error("not implemented yet")):t(new Error("not a valid name"))},e.exports=l}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(44),i=r(136),o=r(1011),s=r(275),a=r(20);function u(e){const t=[],r=e.split("/").slice(1);if(1===r.length&&""===r[0])return[];for(let n=0;n=r.length)throw v("invalid address: "+e);t.push([i,r[n]])}else t.push([i])}return t}function c(e){const t=[];return n(e,function(e){const r=_(e);t.push(r.name),e.length>1&&t.push(e[1])}),"/"+t.join("/")}function f(e){return n(e,function(e){Array.isArray(e)||(e=[e]);const t=_(e);return e.length>1?[t.code,o.toBuffer(t.code,e[1])]:[t.code]})}function l(e){return n(e,function(e){const t=_(e);return e.length>1?[t.code,o.toString(t.code,e[1])]:[t.code]})}function h(e){return g(t.concat(n(e,function(e){const r=_(e);let n=t.from(a.encode(r.code));return e.length>1&&(n=t.concat([n,e[1]])),n})))}function p(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;return a.decode(t)+a.decode.bytes}function d(e){const t=[];let r=0;for(;re.length)throw v("Invalid address buffer: "+e.toString("hex"));t.push([n,u])}return t}function y(e){return h(f(u(e=b(e))))}function g(e){const r=m(e);if(r)throw r;return t.from(e)}function m(e){try{d(e)}catch(e){return e}}function b(e){return"/"+i(e.trim().split("/")).join("/")}function v(e){return new Error("Error parsing address: "+e)}function _(e){return s(e[0])}e.exports={stringToStringTuples:u,stringTuplesToString:c,tuplesToStringTuples:l,stringTuplesToTuples:f,bufferToTuples:d,tuplesToBuffer:h,bufferToString:function(e){return c(l(d(e)))},stringToBuffer:y,fromString:function(e){return y(e)},fromBuffer:g,validateBuffer:m,isValidBuffer:function(e){return void 0===m(e)},cleanPath:b,ParseError:v,protoFromTuple:_,sizeForAddr:p}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(137),i=r(138),o=r(275),s=r(14),a=r(20);function u(e,r){return r instanceof t?u.toString(e,r):u.toBuffer(e,r)}function c(e){if(!e.isValid())throw new Error("invalid ip address");return n.toBuffer(e.address)}e.exports=u,u.toString=function(e,t){switch((e=o(e)).code){case 4:case 41:return n.toString(t);case 6:case 17:case 33:case 132:return function(e){return e.readUInt16BE(0)}(t);case 54:case 55:case 56:return function(e){const t=a.decode(e);if((e=e.slice(a.decode.bytes)).length!==t)throw new Error("inconsistent lengths");return e.toString()}(t);case 421:return function(e){const t=a.decode(e),r=e.slice(a.decode.bytes);if(r.length!==t)throw new Error("inconsistent lengths");return s.encode(r)}(t);default:return t.toString("hex")}},u.toBuffer=function(e,r){switch((e=o(e)).code){case 4:return c(new i.Address4(r));case 41:return c(new i.Address6(r));case 6:case 17:case 33:case 132:return function(e){const r=t.alloc(2);return r.writeUInt16BE(e,0),r}(parseInt(r,10));case 54:case 55:case 56:return function(e){const r=t.from(e),n=t.from(a.encode(r.length));return t.concat([n,r])}(r);case 421:return function(e){const r=t.from(s.decode(e)),n=t.from(a.encode(r.length));return t.concat([n,r])}(r);default:return t.from(r,"hex")}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(4),i=r(155).errors;function o(e){return!(!e||e.code!==i.ERR_REPO_NOT_INITIALIZED&&!(e.message.match(/not found/)||e.message.match(/ENOENT/)||e.message.match(/No value/)))}e.exports=(e=>{e.log("booting");const t=e._options,r=t.init,i=t.start;n([t=>{if(!e._repo.closed)return t(null,!0);e._repo.open((e,r)=>o(e)?t(null,!1):e?t(e):void t(null,!0))},(n,i)=>{if(n)return e.init({repo:e._repo},e=>{if(e)return i(Object.assign(e,{emitted:!0}));i()});if(r){const r=Object.assign({bits:2048,pass:e._options.pass},"object"==typeof t.init?t.init:{});return e.init(r,e=>{if(e)return i(Object.assign(e,{emitted:!0}));i()})}i()},t=>{if(!i)return t();e.start(e=>{if(e)return t(Object.assign(e,{emitted:!0}));t()})}],t=>{t?t.emitted||e.emit("error",t):(e.log("booted"),e.emit("ready"))})})},function(e,t,r){"use strict";t.preStart=r(1014),t.start=r(1040),t.stop=r(1063),t.isOnline=r(1064),t.version=r(1065),t.id=r(1066),t.repo=r(510),t.init=r(1067),t.bootstrap=r(1069),t.config=r(1070),t.block=r(1071),t.object=r(1072),t.dag=r(1074),t.libp2p=r(1079),t.swarm=r(1378),t.ping=r(1381),t.pingPullStream=r(1382),t.pingReadableStream=r(1383),t.pin=r(1384),t.files=r(1388),t.bitswap=r(598),t.pubsub=r(1420),t.dht=r(1421),t.dns=r(1424),t.key=r(1426),t.stats=r(1427),t.mfs=r(1429)},function(e,t,r){"use strict";const n=r(110),i=r(51),o=r(52),s=r(4),a=r(498),u=r(273),c=r(1039);e.exports=function(e){return t=>{e.log("pre-start");const r=e._options.pass;s([t=>e._repo.config.get(t),(t,r)=>{if(!e._options.config)return r(null,t);u(t,e._options.config),e.config.replace(t,e=>{if(e)return r(e);r(null,t)})},(t,r)=>{if(t.Keychain)return r(null,t);t.Keychain=a.generateOptions(),e.config.set("Keychain",t.Keychain,n=>{e.log("using default keychain options"),r(n,t)})},(t,n)=>{if(e._keychain);else if(r){const n=Object.assign({passPhrase:r},t.Keychain);e._keychain=new a(e._repo.keys,n),e.log("keychain constructed")}else e._keychain=new c,e.log("no keychain, use --pass");n(null,t)},(e,t)=>{const r=e.Identity.PrivKey;n.createFromPrivKey(r,(r,n)=>{t(r,e,n)})},(t,n,i)=>{if(!r)return i(null,t,n);e._keychain.findKeyByName("self",r=>{if(r)return e.log('Creating "self" key'),e._keychain.importPeer("self",n,e=>i(e,t,n));i(null,t,n)})},(t,r,n)=>{e.log("peer created"),e._peerInfo=new i(r),t.Addresses&&t.Addresses.Swarm&&t.Addresses.Swarm.forEach(t=>{let r=o(t);r.getPeerId()&&(r=r.encapsulate("/ipfs/"+e._peerInfo.id.toB58String())),e._peerInfo.multiaddrs.add(r)}),n()},t=>e.pin._load(t)],t)}}},function(e,t,r){"use strict";const n=r(1016),i=r(1020),o=r(1021),s=r(35),a=r(8),u=r(1037),c="/pkcs8/",f="/info/",l={minKeyLength:14,minSaltLength:16,minIterationCount:1e3},h={dek:{keyLength:64,iterationCount:1e4,salt:"you should override this value with a crypto secure random number",hash:"sha2-512"}};function p(e){return!!e&&e===n(e.trim())}function d(e,t){const r=800*Math.random()+200;"string"==typeof t&&(t=new Error(t)),setTimeout(e,r,t,null)}function y(e){return new s.Key(c+e)}function g(e){return new s.Key(f+e)}e.exports=class{constructor(e,t){if(!e)throw new Error("store is required");this.store=e;const r=i(h,t);if(!r.passPhrase||r.passPhrase.length<20)throw new Error("passPhrase must be least 20 characters");if(r.dek.keyLengthn})}get cms(){return new u(this)}static generateOptions(){const e=Object.assign({},h),t=3*Math.ceil(l.minSaltLength/3);return e.dek.salt=o.randomBytes(t).toString("base64"),e}static get options(){return h}createKey(e,t,r,n){const i=this;if(!p(e)||"self"===e)return d(n,`Invalid key name '${e}'`);const s=y(e);i.store.has(s,(a,u)=>{if(a)return d(n,a);if(u)return d(n,`Key '${e}' already exists`);switch(t.toLowerCase()){case"rsa":if(r<2048)return d(n,`Invalid RSA key size ${r}`)}o.keys.generateKeyPair(t,r,(t,r)=>{if(t)return d(n,t);r.id((t,o)=>{if(t)return d(n,t);r.export(this._(),(t,r)=>{if(t)return d(n,t);const a={name:e,id:o},u=i.store.batch();u.put(s,r),u.put(g(e),JSON.stringify(a)),u.commit(e=>{if(e)return d(n,e);n(null,a)})})})})})}listKeys(e){const t={prefix:f};a(this.store.query(t),a.collect((t,r)=>{if(t)return d(e,t);const n=r.map(e=>JSON.parse(e.value));e(null,n)}))}findKeyById(e,t){this.listKeys((r,n)=>{if(r)return d(t,r);const i=n.find(t=>t.id===e);t(null,i)})}findKeyByName(e,t){if(!p(e))return d(t,`Invalid key name '${e}'`);const r=g(e);this.store.get(r,(r,n)=>{if(r)return d(t,`Key '${e}' does not exist. ${r.message}`);t(null,JSON.parse(n.toString()))})}removeKey(e,t){const r=this;if(!p(e)||"self"===e)return d(t,`Invalid key name '${e}'`);const n=y(e);r.findKeyByName(e,(i,o)=>{if(i)return d(t,i);const s=r.store.batch();s.delete(n),s.delete(g(e)),s.commit(e=>{if(e)return d(t,e);t(null,o)})})}renameKey(e,t,r){const n=this;if(!p(e)||"self"===e)return d(r,`Invalid old key name '${e}'`);if(!p(t)||"self"===t)return d(r,`Invalid new key name '${t}'`);const i=y(e),o=y(t),s=g(e),a=g(t);this.store.get(i,(u,c)=>{if(u)return d(r,`Key '${e}' does not exist. ${u.message}`);const f=c.toString();n.store.has(o,(e,u)=>e?d(r,e):u?d(r,`Key '${t}' already exists`):void n.store.get(s,(e,u)=>{if(e)return d(r,e);const c=JSON.parse(u.toString());c.name=t;const l=n.store.batch();l.put(o,f),l.put(a,JSON.stringify(c)),l.delete(i),l.delete(s),l.commit(e=>{if(e)return d(r,e);r(null,c)})}))})}exportKey(e,t,r){if(!p(e))return d(r,`Invalid key name '${e}'`);if(!t)return d(r,"Password is required");const n=y(e);this.store.get(n,(n,i)=>{if(n)return d(r,`Key '${e}' does not exist. ${n.message}`);const s=i.toString();o.keys.import(s,this._(),(e,n)=>{if(e)return d(r,e);n.export(t,r)})})}importKey(e,t,r,n){const i=this;if(!p(e)||"self"===e)return d(n,`Invalid key name '${e}'`);if(!t)return d(n,"PEM encoded key is required");const s=y(e);i.store.has(s,(a,u)=>a?d(n,a):u?d(n,`Key '${e}' already exists`):void o.keys.import(t,r,(t,r)=>{if(t)return d(n,"Cannot read the key, most likely the password is wrong");r.id((t,o)=>{if(t)return d(n,t);r.export(this._(),(t,r)=>{if(t)return d(n,t);const a={name:e,id:o},u=i.store.batch();u.put(s,r),u.put(g(e),JSON.stringify(a)),u.commit(e=>{if(e)return d(n,e);n(null,a)})})})}))}importPeer(e,t,r){const n=this;if(!p(e))return d(r,`Invalid key name '${e}'`);if(!t||!t.privKey)return d(r,"Peer.privKey is required");const i=t.privKey,o=y(e);n.store.has(o,(t,s)=>t?d(r,t):s?d(r,`Key '${e}' already exists`):void i.id((t,s)=>{if(t)return d(r,t);i.export(this._(),(t,i)=>{if(t)return d(r,t);const a={name:e,id:s},u=n.store.batch();u.put(o,i),u.put(g(e),JSON.stringify(a)),u.commit(e=>{if(e)return d(r,e);r(null,a)})})}))}_getPrivateKey(e,t){if(!p(e))return d(t,`Invalid key name '${e}'`);this.store.get(y(e),(r,n)=>{if(r)return d(t,`Key '${e}' does not exist. ${r.message}`);t(null,n.toString())})}}},function(e,t,r){"use strict";var n=r(1017),i=/[\/\?<>\\:\*\|":]/g,o=/[\x00-\x1f\x80-\x9f]/g,s=/^\.+$/,a=/^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i,u=/[\. ]+$/;function c(e,t){var r=e.replace(i,t).replace(o,t).replace(s,t).replace(a,t).replace(u,t);return n(r,255)}e.exports=function(e,t){var r=t&&t.replacement||"",n=c(e,r);return""===r?n:c(n,"")}},function(e,t,r){"use strict";var n=r(1018),i=r(1019);e.exports=n.bind(null,i)},function(e,t,r){"use strict";function n(e){return e>=55296&&e<=56319}function i(e){return e>=56320&&e<=57343}e.exports=function(e,t,r){if("string"!=typeof t)throw new Error("Input must be string");for(var o,s,a=t.length,u=0,c=0;cr)return t.slice(0,c-s.length+1)}return t}},function(e,t,r){"use strict";function n(e){return e>=55296&&e<=56319}function i(e){return e>=56320&&e<=57343}e.exports=function(e){if("string"!=typeof e)throw new Error("Input must be string");for(var t=e.length,r=0,o=null,s=null,a=0;a=128&&o<=2047?r+=2:o>=2048&&o<=65535&&(r+=3),s=o;return r}},function(e,t,r){"use strict";var n=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===i}(e)}(e)};var i="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function o(e,t){return t&&!0===t.clone&&n(e)?u(function(e){return Array.isArray(e)?[]:{}}(e),e,t):e}function s(e,t,r){var i=e.slice();return t.forEach(function(t,s){void 0===i[s]?i[s]=o(t,r):n(t)?i[s]=u(e[s],t,r):-1===e.indexOf(t)&&i.push(o(t,r))}),i}function a(e,t,r){var i={};return n(e)&&Object.keys(e).forEach(function(t){i[t]=o(e[t],r)}),Object.keys(t).forEach(function(s){n(t[s])&&e[s]?i[s]=u(e[s],t[s],r):i[s]=o(t[s],r)}),i}function u(e,t,r){var n=Array.isArray(t);return n===Array.isArray(e)?n?((r||{arrayMerge:s}).arrayMerge||s)(e,t,r):a(e,t,r):o(t,r)}u.all=function(e,t){if(!Array.isArray(e)||e.length<2)throw new Error("first argument should be an array with at least two elements");return e.reduce(function(e,r){return u(e,r,t)})};var c=u;e.exports=c},function(e,t,r){"use strict";const n=r(499),i=r(1023),o=r(1025);(t=e.exports).aes=i,t.hmac=n,t.keys=o,t.randomBytes=r(504),t.pbkdf2=r(1036)},function(e,t,r){"use strict";e.exports={SHA1:20,SHA256:32,SHA512:64}},function(e,t,r){"use strict";const n=r(1024),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(59);e.exports={createCipheriv:n.createCipheriv,createDecipheriv:n.createDecipheriv}},function(e,t,r){"use strict";(function(n){const i=r(10)(r(278)),o=r(16);t=e.exports;const s={rsa:r(1026),ed25519:r(1031),secp256k1:r(61)(i,r(504))};function a(e){return void 0!==s[e.toLowerCase()]}t.supportedKeys=s,t.keysPBM=i,t.keyStretcher=r(1033),t.generateEphemeralKeyPair=r(1034),t.generateKeyPair=((e,t,r)=>{let 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)=>{let 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){"use strict";const n=r(500),i=r(10),o=r(14),s=r(502),a=i(r(278)),u=r(16),c=r(3);class f{constructor(e){this._key=e}verify(e,t,r){h(r),s.hashAndVerify(this._key,t,e,r)}marshal(){return s.utils.jwkToPkix(this._key)}get bytes(){return a.PublicKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}encrypt(e){return this._key.encrypt(e,"RSAES-PKCS1-V1_5")}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(e),n(this.bytes,"sha2-256",e)}}class l{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return s.getRandomValues(new Uint8Array(16))}sign(e,t){h(t),s.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){s.decrypt(this._key,e,t)}marshal(){return s.utils.jwkToPkcs1(this._key)}get bytes(){return a.PrivateKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(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"),h(r),c(()=>{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 h(e){if("function"!=typeof e)throw new Error("callback is required")}e.exports={RsaPublicKey:f,RsaPrivateKey:l,unmarshalRsaPublicKey:function(e){const t=s.utils.pkixToJwk(e);return new f(t)},unmarshalRsaPrivateKey:function(e,t){const r=s.utils.pkcs1ToJwk(e);s.unmarshalPrivateKey(r,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},generateKeyPair:function(e,t){s.generateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},fromJwk:function(e,t){s.unmarshalPrivateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})}}},function(e,t,r){"use strict";(function(t){const n=r(38),i=r(39),o=r(501),s=r(1028),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,256)),shake256:a(u(n.shake_256,512)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(1029),dblSha2256:(e,r)=>{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(40),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;function o(e){if(!i)throw new Error("Please use a browser with webcrypto support");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(41),i=r(501).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(15),i=r(503),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())}),u=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()))}),c=n.define("RSAPublicKey",function(){this.seq().obj(this.key("algorithm").use(u),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=c.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 c.encode({algorithm:{algorithm:"rsa",none:null},subjectPublicKey:{data:f.encode({modulus:s(e.n),publicExponent:s(e.e)},"der")}},"der")}},function(e,t,r){"use strict";(function(t){const n=r(500),i=r(10),o=r(14),s=r(1032),a=i(r(278));class u{constructor(e){this._key=l(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 c{constructor(e,t){this._key=l(e,s.privateKeyLength),this._publicKey=l(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 u(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 l(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:u,Ed25519PrivateKey:c,unmarshalEd25519PrivateKey:function(e,t){try{e=l(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 c(r,n))},unmarshalEd25519PublicKey:function(e){return e=l(e,s.publicKeyLength),new u(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 c(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 c(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(60),i=r(3);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){"use strict";(function(t){const n=r(37),i=r(499),o={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,cipherKeySize:32}};e.exports=((e,r,s,a)=>{const u=o[e];if(!u)return a(new Error("unkown cipherType passed"));if(!r)return a(new Error("unkown hashType passed"));const c=u.keySize,f=u.ivSize,l=t.from("key expansion"),h=2*(f+c+20);i.create(r,s,(e,r)=>{if(e)return a(e);r.digest(l,(e,i)=>{if(e)return a(e);let o=[],s=0;n(()=>s{if(t)return e(t);let a=n.length;s+a>h&&(a=h-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=h/2,n=t.concat(o),i=n.slice(0,r),s=n.slice(r,h),u=e=>({iv:e.slice(0,f),cipherKey:e.slice(f,f+c),macKey:e.slice(f+c)});a(null,{k1:u(i),k2:u(s)})})})})})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(1035);e.exports=((e,t)=>{n.generateEphmeralKeyPair(e,t)})},function(e,t,r){"use strict";(function(e){const n=r(277)(),i=r(276),o=r(15).bignum,s=r(503),a=s.toBase64,u=s.toBn,c={"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 o=(o,s,a)=>{let u;"function"==typeof s&&(a=s,s=void 0),u=s?n.subtle.importKey("jwk",p(t,s),{name:"ECDH",namedCurve:t},!1,["deriveBits"]):Promise.resolve(r.privateKey);const f=Promise.all([n.subtle.importKey("jwk",h(t,o),{name:"ECDH",namedCurve:t},!1,[]),u]);i(f.then(e=>n.subtle.deriveBits({name:"ECDH",namedCurve:t,public:e[0]},e[1],c[t])).then(t=>e.from(t)),a)};return n.subtle.exportKey("jwk",r.publicKey).then(e=>({key:l(e),genSharedKey:o}))}),r)};const f={"P-256":32,"P-384":48,"P-521":66};function l(t){const r=f[t.crv];return e.concat([e.from([4]),u(t.x).toArrayLike(e,"be",r),u(t.y).toArrayLike(e,"be",r)],1+2*r)}function h(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}}function p(e,t){const r=h(e,t.public);return r.d=a(new o(t.private)),r}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(16),i={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};e.exports=function(e,t,r,o,s){const a=i[s];if(!a)throw new Error(`Hash '${s}' is unknown or not supported`);const u=n.pkcs5.pbkdf2(e,t,r,o,a);return n.util.encode64(u)}},function(e,t,r){"use strict";(function(t){const n=r(279),i=r(16),o=r(1038);e.exports=class{constructor(e){if(!e)throw new Error("keychain is required");this.keychain=e}encrypt(e,r,s){const a=this,u=(e,t)=>n.setImmediate(()=>s(e,t));if(!t.isBuffer(r))return u(new Error("Plain data must be a Buffer"));n.series([t=>a.keychain.findKeyByName(e,t),t=>a.keychain._getPrivateKey(e,t)],(e,n)=>{if(e)return u(e);let c=n[0],f=n[1];try{const n=i.pki.decryptRsaPrivateKey(f,a.keychain._());o.certificateForKey(c,n,(e,n)=>{if(e)return s(e);const o=i.pkcs7.createEnvelopedData();o.addRecipient(n),o.content=i.util.createBuffer(r),o.encrypt();const a=i.asn1.toDer(o.toAsn1()).getBytes();u(null,t.from(a,"binary"))})}catch(e){u(e)}})}decrypt(e,r){const o=(e,t)=>n.setImmediate(()=>r(e,t));if(!t.isBuffer(e))return o(new Error("CMS data is required"));const s=this;let a;try{const t=i.util.createBuffer(e.toString("binary")),r=i.asn1.fromDer(t);a=i.pkcs7.messageFromAsn1(r)}catch(e){return o(new Error("Invalid CMS: "+e.message))}const u=a.recipients.filter(e=>e.issuer.find(e=>"O"===e.shortName&&"ipfs"===e.value)).filter(e=>e.issuer.find(e=>"CN"===e.shortName)).map(e=>({recipient:e,keyId:e.issuer.find(e=>"CN"===e.shortName).value}));n.detect(u,(e,t)=>s.keychain.findKeyById(e.keyId,(e,r)=>t(null,!e&&r)),(e,r)=>{if(e)return o(e);if(!r){const t=u.map(e=>e.keyId);return(e=new Error("Decryption needs one of the key(s): "+t.join(", "))).missingKeys=t,o(e)}n.waterfall([e=>s.keychain.findKeyById(r.keyId,e),(e,t)=>s.keychain._getPrivateKey(e.name,t)],(e,n)=>{if(e)return o(e);const u=i.pki.decryptRsaPrivateKey(n,s.keychain._());a.decrypt(r.recipient,u),o(null,t.from(a.content.getBytes(),"binary"))})})}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(16).pki;e.exports.certificateForKey=((e,t,r)=>{const i=n.setRsaPublicKey(t.n,t.e),o=n.createCertificate();o.publicKey=i,o.serialNumber="01",o.validity.notBefore=new Date,o.validity.notAfter=new Date,o.validity.notAfter.setFullYear(o.validity.notBefore.getFullYear()+10);const s=[{name:"organizationName",value:"ipfs"},{shortName:"OU",value:"keystore"},{name:"commonName",value:e.id}];return o.setSubject(s),o.setIssuer(s),o.setExtensions([{name:"basicConstraints",cA:!0},{name:"keyUsage",keyCertSign:!0,digitalSignature:!0,nonRepudiation:!0,keyEncipherment:!0,dataEncipherment:!0},{name:"extKeyUsage",serverAuth:!0,clientAuth:!0,codeSigning:!0,emailProtection:!0,timeStamping:!0},{name:"nsCertType",client:!0,server:!0,email:!0,objsign:!0,sslCA:!0,emailCA:!0,objCA:!0}]),o.sign(t),r(null,o)})},function(e,t,r){"use strict";function n(){throw new Error("Key management requires '--pass ...' option")}e.exports=class{static get options(){n()}static generateOptions(){n()}createKey(){n()}listKeys(){n()}findKeyById(){n()}findKeyByName(){n()}renameKey(){n()}removeKey(){n()}exportKey(){n()}importKey(){n()}importPeer(){n()}get cms(){n()}}},function(e,t,r){"use strict";const n=r(49),i=r(1041),o=r(3),s=r(23);e.exports=(e=>s(t=>{const r=r=>{if(r)return o(()=>e.emit("error",r)),t(r);e.state.started(),o(()=>e.emit("start")),t()};if("stopped"!==e.state.state())return r(new Error(`Not able to start from state: ${e.state.state()}`));e.log("starting"),e.state.start(),n([t=>{e._repo.closed?e._repo.open(t):t()},t=>e.libp2p.start(t),t=>{e._bitswap=new i(e._libp2pNode,e._repo.blocks,{statsEnabled:!0}),e._bitswap.start(),e._blockService.setExchange(e._bitswap),e._preload.start(),e._mfsPreload.start(t)}],r)}))},function(e,t,r){"use strict";const n=r(4),i=r(371),o=r(50),s=r(49),a=r(80),u=r(1042),c=r(1050),f=r(1054),l=r(1060),h=r(113).logger,p=r(1061),d={statsEnabled:!1,statsComputeThrottleTimeout:1e3,statsComputeThrottleMaxQueueSize:1e3},y=["blocksReceived","dataReceived","dupBlksReceived","dupDataReceived","blocksSent","dataSent","providesBufferLength","wantListLength","peerCount"];e.exports=class{constructor(e,t,r){this._libp2p=e,this._log=h(this.peerInfo.id),this._options=Object.assign({},d,r),this._stats=new p(y,{enabled:this._options.statsEnabled,computeThrottleTimeout:this._options.statsComputeThrottleTimeout,computeThrottleMaxQueueSize:this._options.statsComputeThrottleMaxQueueSize}),this.network=new c(e,this,{},this._stats),this.blockstore=t,this.engine=new f(this.peerInfo.id,t,this.network,this._stats),this.wm=new u(this.peerInfo.id,this.network,this._stats),this.notifications=new l(this.peerInfo.id)}get peerInfo(){return this._libp2p.peerInfo}_receiveMessage(e,t,r){this.engine.messageReceived(e,t,n=>{if(n&&this._log("failed to receive message",t),0===t.blocks.size)return r();const i=Array.from(t.blocks.values()),s=i.filter(e=>this.wm.wantlist.contains(e.cid)).map(e=>e.cid);this.wm.cancelWants(s),o(i,(t,r)=>this._handleReceivedBlock(e,t,r),r)})}_handleReceivedBlock(e,t,r){this._log("received block"),n([e=>this.blockstore.has(t.cid,e),(r,n)=>{if(this._updateReceiveCounters(e.toB58String(),t,r),r)return n();this._putBlock(t,n)}],r)}_updateReceiveCounters(e,t,r){this._stats.push(e,"blocksReceived",1),this._stats.push(e,"dataReceived",t.data.length),r&&(this._stats.push(e,"dupBlksReceived",1),this._stats.push(e,"dupDataReceived",t.data.length))}_receiveError(e){this._log.error("ReceiveError: %s",e.message)}_onPeerConnected(e){this.wm.connected(e)}_onPeerDisconnected(e){this.wm.disconnected(e),this.engine.peerDisconnected(e),this._stats.disconnected(e)}_putBlock(e,t){this.blockstore.put(e,r=>{if(r)return t(r);this.notifications.hasBlock(e),this.network.provide(e.cid,e=>{e&&this._log.error("Failed to provide: %s",e.message)}),this.engine.receivedBlocks([e.cid]),t()})}enableStats(){this._stats.enable()}disableStats(){this._stats.disable()}wantlistForPeer(e){return this.engine.wantlistForPeer(e)}ledgerForPeer(e){return this.engine.ledgerForPeer(e)}get(e,t){this.getMany([e],(e,r)=>{if(e)return t(e);r&&r.length>0?t(null,r[0]):t()})}getMany(e,t){let r=e.length;const i=[];let o=!1;const s=(e,t)=>{i.push(e),this.notifications.wantBlock(e,r=>{this.wm.cancelWants([e]),t(null,r)},()=>{this.wm.cancelWants([e]),t(null,void 0)}),r||this.wm.wantBlocks(i)};a(e,(t,a)=>{n([e=>this.blockstore.has(t,e),(n,a)=>{if(r--,n)return r||this.wm.wantBlocks(i),this.blockstore.get(t,a);o||(o=!0,this.network.findAndConnect(e[0],e=>{e&&this._log.error(e)})),s(t,a)}],a)},t)}unwant(e){Array.isArray(e)||(e=[e]),this.wm.unwantBlocks(e),e.forEach(e=>this.notifications.unwantBlock(e))}cancelWants(e){Array.isArray(e)||(e=[e]),this.wm.cancelWants(e)}put(e,t){this._log("putting block"),n([t=>this.blockstore.has(e.cid,t),(t,r)=>{if(t)return r();this._putBlock(e,r)}],t)}putMany(e,t){n([t=>i(e,(e,t)=>{this.blockstore.has(e.cid,t)},t),(e,t)=>this.blockstore.putMany(e,r=>{if(r)return t(r);e.forEach(e=>{this.notifications.hasBlock(e),this.engine.receivedBlocks([e.cid]),this.network.provide(e.cid,e=>{e&&this._log.error("Failed to provide: %s",e.message)})}),t()})],t)}getWantlist(){return this.wm.wantlist.entries()}peers(){return this.engine.peers()}stat(){return this._stats}start(e){s([e=>this.wm.start(e),e=>this.network.start(e),e=>this.engine.start(e)],e)}stop(e){this._stats.stop(),s([e=>this.wm.stop(e),e=>this.network.stop(e),e=>this.engine.stop(e)],e)}}},function(e,t,r){"use strict";const n=r(3),i=r(186),o=r(187),s=r(280),a=r(1049),u=r(113).logger;e.exports=class{constructor(e,t,r){this.peers=new Map,this.wantlist=new o(r),this.network=t,this._stats=r,this._peerId=e,this._log=u(e,"want")}_addEntries(e,t,r){const n=e.map((e,r)=>new i.Entry(e,s.kMaxPriority-r,t));n.forEach(e=>{e.cancel?r?this.wantlist.removeForce(e.cid):this.wantlist.remove(e.cid):(this._log("adding to wl"),this.wantlist.add(e.cid,e.priority))});for(let e of this.peers.values())e.addEntries(n)}_startPeerHandler(e){let t=this.peers.get(e.toB58String());if(t)return void t.refcnt++;t=new a(this._peerId,e,this.network);const r=new i(!0);for(let e of this.wantlist.entries())r.addEntry(e[1].cid,e[1].priority);return t.addMessage(r),this.peers.set(e.toB58String(),t),t}_stopPeerHandler(e){const t=this.peers.get(e.toB58String());t&&(t.refcnt--,t.refcnt>0||this.peers.delete(e.toB58String()))}wantBlocks(e){this._addEntries(e,!1)}unwantBlocks(e){this._log("unwant blocks: %s",e.length),this._addEntries(e,!0,!0)}cancelWants(e){this._log("cancel wants: %s",e.length),this._addEntries(e,!0)}connectedPeers(){return Array.from(this.peers.keys())}connected(e){this._startPeerHandler(e)}disconnected(e){this._stopPeerHandler(e)}start(e){this.timer=setInterval(()=>{this._log("resend full-wantlist");const e=new i(!0);this.wantlist.forEach(t=>{e.addEntry(t.cid,t.priority)}),this.peers.forEach(t=>t.addMessage(e))},6e4),n(()=>e())}stop(e){this.peers.forEach(e=>this.disconnected(e.peerId)),clearInterval(this.timer),n(()=>e())}}},function(e,t,r){(function(e,r){var n=200,i="__lodash_hash_undefined__",o=1,s=2,a=9007199254740991,u="[object Arguments]",c="[object Array]",f="[object Boolean]",l="[object Date]",h="[object Error]",p="[object Function]",d="[object GeneratorFunction]",y="[object Map]",g="[object Number]",m="[object Object]",b="[object Promise]",v="[object RegExp]",_="[object Set]",w="[object String]",S="[object Symbol]",k="[object WeakMap]",E="[object ArrayBuffer]",A="[object DataView]",x=/^\[object .+?Constructor\]$/,I=/^(?:0|[1-9]\d*)$/,T={};T["[object Float32Array]"]=T["[object Float64Array]"]=T["[object Int8Array]"]=T["[object Int16Array]"]=T["[object Int32Array]"]=T["[object Uint8Array]"]=T["[object Uint8ClampedArray]"]=T["[object Uint16Array]"]=T["[object Uint32Array]"]=!0,T[u]=T[c]=T[E]=T[f]=T[A]=T[l]=T[h]=T[p]=T[y]=T[g]=T[m]=T[v]=T[_]=T[w]=T[k]=!1;var B="object"==typeof e&&e&&e.Object===Object&&e,C="object"==typeof self&&self&&self.Object===Object&&self,P=B||C||Function("return this")(),O="object"==typeof t&&t&&!t.nodeType&&t,R=O&&"object"==typeof r&&r&&!r.nodeType&&r,N=R&&R.exports===O&&B.process,L=function(){try{return N&&N.binding("util")}catch(e){}}(),K=L&&L.isTypedArray;function j(e,t){for(var r=-1,n=e?e.length:0;++rc))return!1;var l=a.get(e);if(l&&a.get(t))return l==t;var h=-1,p=!0,d=i&o?new be:void 0;for(a.set(e,t),a.set(t,e);++h-1},ge.prototype.set=function(e,t){var r=this.__data__,n=we(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},me.prototype.clear=function(){this.__data__={hash:new ye,map:new(ne||ge),string:new ye}},me.prototype.delete=function(e){return Ie(this,e).delete(e)},me.prototype.get=function(e){return Ie(this,e).get(e)},me.prototype.has=function(e){return Ie(this,e).has(e)},me.prototype.set=function(e,t){return Ie(this,e).set(e,t),this},be.prototype.add=be.prototype.push=function(e){return this.__data__.set(e,i),this},be.prototype.has=function(e){return this.__data__.has(e)},ve.prototype.clear=function(){this.__data__=new ge},ve.prototype.delete=function(e){return this.__data__.delete(e)},ve.prototype.get=function(e){return this.__data__.get(e)},ve.prototype.has=function(e){return this.__data__.has(e)},ve.prototype.set=function(e,t){var r=this.__data__;if(r instanceof ge){var i=r.__data__;if(!ne||i.length-1&&e%1==0&&e-1&&e%1==0&&e<=a}function je(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Me(e){return!!e&&"object"==typeof e}var De=K?function(e){return function(t){return e(t)}}(K):function(e){return Me(e)&&Ke(e.length)&&!!T[Y.call(e)]};function Ue(e){return Ne(e)?_e(e):Ee(e)}r.exports=function(e,t,r){var n=(r="function"==typeof r?r:void 0)?r(e,t):void 0;return void 0===n?Se(e,t,r):!!n}}).call(this,r(6),r(27)(e))},function(e,t,r){"use strict";(function(t){const n=r(20);e.exports=(e=>{if(!t.isBuffer(e))throw new Error("arg needs to be a buffer");let r=[];for(;e.length>0;){const t=n.decode(e);r.push(t),e=e.slice(n.decode.bytes)}return r})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";e.exports="\n message Message {\n message Wantlist {\n message Entry {\n // changed from string to bytes, it makes a difference in JavaScript\n optional bytes block = 1; // the block cid (cidV0 in bitswap 1.0.0, cidV1 in bitswap 1.1.0)\n optional int32 priority = 2; // the priority (normalized). default to 1\n optional bool cancel = 3; // whether this revokes an entry\n }\n\n repeated Entry entries = 1; // a list of wantlist entries\n optional bool full = 2; // whether this is the full wantlist. default to false\n }\n\n message Block {\n optional bytes prefix = 1; // CID prefix (cid version, multicodec and multihash prefix (type + length)\n optional bytes data = 2;\n }\n\n optional Wantlist wantlist = 1;\n repeated bytes blocks = 2; // used to send Blocks in bitswap 1.0.0\n repeated Block payload = 3; // used to send Blocks in bitswap 1.1.0\n }\n"},function(e,t,r){"use strict";const n=r(187).Entry,i=r(9),o=r(17);e.exports=class{constructor(e,t,r){o(i.isCID(e),"needs valid cid"),this.entry=new n(e,t),this.cancel=Boolean(r)}get cid(){return this.entry.cid}set cid(e){this.entry.cid=e}get priority(){return this.entry.priority}set priority(e){this.entry.priority=e}get[Symbol.toStringTag](){return`BitswapMessageEntry ${this.cid.toBaseEncodedString()} `}equals(e){return this.cancel===e.cancel&&this.entry.equals(e.entry)}}},function(e,t,r){(function(e,r){var n=200,i="Expected a function",o="__lodash_hash_undefined__",s=1,a=2,u=1/0,c=9007199254740991,f="[object Arguments]",l="[object Array]",h="[object Boolean]",p="[object Date]",d="[object Error]",y="[object Function]",g="[object GeneratorFunction]",m="[object Map]",b="[object Number]",v="[object Object]",_="[object Promise]",w="[object RegExp]",S="[object Set]",k="[object String]",E="[object Symbol]",A="[object WeakMap]",x="[object ArrayBuffer]",I="[object DataView]",T=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,B=/^\w*$/,C=/^\./,P=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,O=/\\(\\)?/g,R=/^\[object .+?Constructor\]$/,N=/^(?:0|[1-9]\d*)$/,L={};L["[object Float32Array]"]=L["[object Float64Array]"]=L["[object Int8Array]"]=L["[object Int16Array]"]=L["[object Int32Array]"]=L["[object Uint8Array]"]=L["[object Uint8ClampedArray]"]=L["[object Uint16Array]"]=L["[object Uint32Array]"]=!0,L[f]=L[l]=L[x]=L[h]=L[I]=L[p]=L[d]=L[y]=L[m]=L[b]=L[v]=L[w]=L[S]=L[k]=L[A]=!1;var K="object"==typeof e&&e&&e.Object===Object&&e,j="object"==typeof self&&self&&self.Object===Object&&self,M=K||j||Function("return this")(),D="object"==typeof t&&t&&!t.nodeType&&t,U=D&&"object"==typeof r&&r&&!r.nodeType&&r,F=U&&U.exports===D&&K.process,q=function(){try{return F&&F.binding("util")}catch(e){}}(),H=q&&q.isTypedArray;function z(e,t){for(var r=-1,n=e?e.length:0,i=Array(n);++r-1},Be.prototype.set=function(e,t){var r=this.__data__,n=Ne(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Ce.prototype.clear=function(){this.__data__={hash:new Te,map:new(ye||Be),string:new Te}},Ce.prototype.delete=function(e){return $e(this,e).delete(e)},Ce.prototype.get=function(e){return $e(this,e).get(e)},Ce.prototype.has=function(e){return $e(this,e).has(e)},Ce.prototype.set=function(e,t){return $e(this,e).set(e,t),this},Pe.prototype.add=Pe.prototype.push=function(e){return this.__data__.set(e,o),this},Pe.prototype.has=function(e){return this.__data__.has(e)},Oe.prototype.clear=function(){this.__data__=new Be},Oe.prototype.delete=function(e){return this.__data__.delete(e)},Oe.prototype.get=function(e){return this.__data__.get(e)},Oe.prototype.has=function(e){return this.__data__.has(e)},Oe.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Be){var i=r.__data__;if(!ye||i.length=a?u:u*("desc"==r[n]?-1:1)}return e.index-t.index}(e,t,r)})}function ze(e){return ft(e)?e:nt(e)}function Ve(e,t){if(e!==t){var r=void 0!==e,n=null===e,i=e==e,o=gt(e),s=void 0!==t,a=null===t,u=t==t,c=gt(t);if(!a&&!c&&!o&&e>t||o&&s&&u&&!a&&!c||n&&s&&u||!r&&u||!i)return 1;if(!n&&!o&&!c&&ec))return!1;var l=o.get(e);if(l&&o.get(t))return l==t;var h=-1,p=!0,d=i&s?new Pe:void 0;for(o.set(e,t),o.set(t,e);++h-1&&e%1==0&&e1&&Qe(e,t[0],t[1])?t=[]:r>2&&Qe(t[0],t[1],t[2])&&(t=[t[0]]),He(e,function e(t,r,n,i,o){var s=-1,a=t.length;for(n||(n=Xe),o||(o=[]);++s0&&n(u)?r>1?e(u,r-1,n,i,o):V(o,u):i||(o[o.length]=u)}return o}(t,1),[])});function at(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError(i);var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var s=e.apply(this,n);return r.cache=o.set(i,s),s};return r.cache=new(at.Cache||Ce),r}function ut(e,t){return e===t||e!=e&&t!=t}function ct(e){return function(e){return yt(e)&<(e)}(e)&&ie.call(e,"callee")&&(!ce.call(e,"callee")||oe.call(e)==f)}at.Cache=Ce;var ft=Array.isArray;function lt(e){return null!=e&&pt(e.length)&&!ht(e)}function ht(e){var t=dt(e)?oe.call(e):"";return t==y||t==g}function pt(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=c}function dt(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function yt(e){return!!e&&"object"==typeof e}function gt(e){return"symbol"==typeof e||yt(e)&&oe.call(e)==E}var mt=H?W(H):function(e){return yt(e)&&pt(e.length)&&!!L[oe.call(e)]};function bt(e){return lt(e)?Re(e):qe(e)}function vt(e){return e}r.exports=st}).call(this,r(6),r(27)(e))},function(e,t,r){"use strict";const n=r(17),i=r(9);e.exports=class{constructor(e,t){n(i.isCID(e),"must be valid CID"),this._refCounter=1,this.cid=e,this.priority=t||1}inc(){this._refCounter+=1}dec(){this._refCounter=Math.max(0,this._refCounter-1)}hasRefs(){return this._refCounter>0}get[Symbol.toStringTag](){return`WantlistEntry `}equals(e){return this._refCounter===e._refCounter&&this.cid.equals(e.cid)&&this.priority===e.priority}}},function(e,t,r){"use strict";const n=r(505),i=r(186),o=r(113).logger;e.exports=class{constructor(e,t,r){this.peerId=t,this.network=r,this.refcnt=1,this._entries=[],this._log=o(e,"msgqueue",t.toB58String().slice(0,8)),this.sendEntries=n(this._sendEntries.bind(this),200)}addMessage(e){e.empty||this.send(e)}addEntries(e){this._entries=this._entries.concat(e),this.sendEntries()}_sendEntries(){if(!this._entries.length)return;const e=new i(!1);this._entries.forEach(t=>{t.cancel?e.cancel(t.cid):e.addEntry(t.cid,t.priority)}),this._entries=[],this.addMessage(e)}send(e){this.network.connectTo(this.peerId,t=>{t?this._log.error("cant connect to peer %s: %s",this.peerId.toB58String(),t.message):(this._log("sending message"),this.network.sendMessage(this.peerId,e,e=>{e&&this._log.error("send error: %s",e.message)}))})}}},function(e,t,r){"use strict";const n=r(53),i=r(8),o=r(4),s=r(50),a=r(3),u=r(186),c=r(280),f=r(113).logger,l="/ipfs/bitswap/1.0.0",h="/ipfs/bitswap/1.1.0";function p(e,t,r){i(i.values([t]),n.encode(),e,i.onEnd(r))}e.exports=class{constructor(e,t,r,n){this._log=f(e.peerInfo.id,"network"),r=r||{},this.libp2p=e,this.bitswap=t,this.b100Only=r.b100Only||!1,this._stats=n,this._running=!1}start(e){this._running=!0,this._onPeerConnect=this._onPeerConnect.bind(this),this._onPeerDisconnect=this._onPeerDisconnect.bind(this),this._onConnection=this._onConnection.bind(this),this.libp2p.handle(l,this._onConnection),this.b100Only||this.libp2p.handle(h,this._onConnection),this.libp2p.on("peer:connect",this._onPeerConnect),this.libp2p.on("peer:disconnect",this._onPeerDisconnect),this.libp2p.peerBook.getAllArray().filter(e=>e.isConnected()).forEach(e=>this._onPeerConnect(e)),a(()=>e())}stop(e){this._running=!1,this.libp2p.unhandle(l),this.b100Only||this.libp2p.unhandle(h),this.libp2p.removeListener("peer:connect",this._onPeerConnect),this.libp2p.removeListener("peer:disconnect",this._onPeerDisconnect),a(()=>e())}_onConnection(e,t){this._running&&(this._log("incomming new bitswap connection: %s",e),i(t,n.decode(),i.asyncMap((e,t)=>u.deserialize(e,t)),i.asyncMap((e,r)=>{t.getPeerInfo((t,n)=>{if(t)return r(t);this.bitswap._receiveMessage(n.id,e,r)})}),i.onEnd(e=>{this._log("ending connection"),e&&this.bitswap._receiveError(e)})))}_onPeerConnect(e){this._running&&this.bitswap._onPeerConnected(e.id)}_onPeerDisconnect(e){this._running&&this.bitswap._onPeerDisconnected(e.id)}findProviders(e,t,r){this.libp2p.contentRouting.findProviders(e,c.providerRequestTimeout,r)}findAndConnect(e,t){o([t=>this.findProviders(e,c.maxProvidersPerRequest,t),(e,t)=>{this._log("connecting to providers",e.map(e=>e.id.toB58String())),s(e,(e,t)=>this.connectTo(e,t))}],t)}provide(e,t){this.libp2p.contentRouting.provide(e,t)}sendMessage(e,t,r){if(!this._running)return r(new Error("network isn't running"));const n=e.toB58String()?e.toB58String():e.id.toB58String();this._log("sendMessage to %s",n,t),this._dialPeer(e,(n,i,o)=>{if(n)return r(n);let s;switch(o){case l:s=t.serializeToBitswap100();break;case h:s=t.serializeToBitswap110();break;default:return r(new Error("Unkown protocol: "+o))}p(i,s,e=>{e&&this._log.error(e)}),r(),this._updateSentStats(e,t.blocks)})}connectTo(e,t){if(!this._running)return t(new Error("network isn't running"));this.libp2p.dial(e,t)}_dialPeer(e,t){this.libp2p.dialProtocol(e,h,(r,n)=>{r?this.libp2p.dialProtocol(e,l,(e,r)=>{if(e)return t(e);t(null,r,l)}):t(null,n,h)})}_updateSentStats(e,t){const r=e.toB58String();this._stats&&(t.forEach(e=>this._stats.push(r,"dataSent",e.data.length)),this._stats.push(r,"blocksSent",t.size))}}},function(e,t,r){"use strict";const n=r(2).Buffer;e.exports=function(e){e=Object.assign({fixed:!1},e||{});const t=r(20);let i=e.fixed?null:o(),s=0,a=!1;return r=>(u,c)=>{if(u&&(a=u),a)return c(a);r(null,(r,u)=>{if(r&&(a=r),a)return c(a);if(!n.isBuffer(u))return a=new Error("data must be a buffer"),c(a);let f;e.fixed?(f=n.alloc(4)).writeInt32BE(u.length,0):(t.encode(u.length,i,s),s+=t.encode.bytes,f=i.slice(s-t.encode.bytes,s),i.length-s<100&&(i=o(),s=0)),c(null,n.concat([f,u]))})}};const i=10240;function o(){return n.alloc(i)}},function(e,t,r){"use strict";const n=r(20),i=r(506),o=r(2).Buffer,s=r(46);t.decode=function(e){let t=new i,r=s(e=>{t.abort(e)});return n=>{return t(n),function n(){c(t,e,(e,t)=>{if(e)return r.end(e);r.push(t),n()})}(),r}},t.decodeFromReader=function(e,t,r){"function"==typeof t&&(r=t,t={}),c(e,t,function(e,t){if(e)return r(!0===e?new Error("Unexpected end of input from reader."):e);r(null,t)})};const a=e=>!(128&e),u=4194304;function c(e,t,r){(t=Object.assign({fixed:!1,maxLength:u},t||{})).fixed?function(e,t,r){e.read(4,(n,i)=>{if(n)return r(n);const o=i.readInt32BE(0);if(o>t)return r(new Error("size longer than max permitted length of "+t+"!"));f(e,o,r)})}(e,t.maxLength,r):function(e,t,r){let i=[];0===i.length&&function s(){e.read(1,(u,c)=>{if(u)return r(u);if(i.push(c),c&&!a(c[0]))return void s();const l=n.decode(o.concat(i));if(l>t)return r(new Error("size longer than max permitted length of "+t+"!"));f(e,l,(e,t)=>e?r(e):(i=[],t.length{if(e)return r(e);r(null,t)})}},function(e,t,r){(function(t){e.exports=function(){var e=[],r=0;return{length:r,data:this,add:function(n){if(!t.isBuffer(n))throw new Error("data must be a buffer, was: "+JSON.stringify(n));return this.length=r+=n.length,e.push(n),this},has:function(e){return null==e?r>0:r>=e},get:function(n){var i;if(null==n||n===r){r=0;var o=e;return e=[],1==o.length?o[0]:t.concat(o)}if(e.length>1&&n<=(i=e[0].length)){var s=e[0].slice(0,n);return n===i?e.shift():e[0]=e[0].slice(n,i),r-=n,s}if(ne+t.data.byteLength,0){if(s--,o.push(t),(n+=t.data.byteLength)>=b||0===s){n=0;const t=o.slice();o=[],this._sendSafeBlocks(e,t,e=>{e&&this._log("sendblock error: %s",e.message),r()})}else r()},r)}_sendSafeBlocks(e,t,r){const n=new d(!1);t.forEach(e=>n.addBlock(e)),this.network.sendMessage(e,n,r)}_processTasks(){if(!this._running||!this._tasks.length)return;const e=this._tasks;this._tasks=[];const t=e.map(e=>e.entry).map(e=>e.cid),r=c(t,(e,t)=>e.equals(t)),i=h(e,e=>e.target.toB58String());o([e=>a(r,(e,t)=>{this.blockstore.get(e,t)},e),(e,r)=>n(l(i),(r,n)=>{const i=r[0].target,o=t.map(t=>f(e,e=>e.cid.equals(t)));this._sendBlocks(i,o,e=>{e?this._log.error("should never happen: ",e):o.forEach(e=>this.messageSent(i,e)),n()})})],e=>{this._tasks=[],e&&this._log.error(e)})}wantlistForPeer(e){const t=e.toB58String();return this.ledgerMap.has(t)?this.ledgerMap.get(t).wantlist.sortedEntries():new Map}ledgerForPeer(e){const t=e.toB58String(),r=this.ledgerMap.get(t);return r?{peer:r.partner.toB58String(),value:r.debtRatio(),sent:r.accounting.bytesSent,recv:r.accounting.bytesRecv,exchanged:r.exchangeCount}:null}peers(){return Array.from(this.ledgerMap.values()).map(e=>e.partner)}receivedBlocks(e){e.length&&(this.ledgerMap.forEach(t=>{e.map(e=>t.wantlistContains(e)).filter(Boolean).forEach(e=>{this._tasks.push({entry:e,target:t.partner})})}),this._outbox())}messageReceived(e,t,r){const n=this._findOrCreate(e);if(t.empty)return r();if(t.full&&(n.wantlist=new y),this._processBlocks(t.blocks,n),0===t.wantlist.size)return r();let i=[],o=[];t.wantlist.forEach(e=>{e.cancel?(n.cancelWant(e.cid),i.push(e)):(n.wants(e.cid,e.priority),o.push(e))}),this._cancelWants(n,e,i),this._addWants(n,e,o,r)}_cancelWants(e,t,r){const n=t.toB58String();p(this._tasks,r,(e,t)=>{const r=e.target.toB58String()===n,i=e.entry.cid.equals(t.cid);return r&&i})}_addWants(e,t,r,i){n(r,(e,r)=>{this.blockstore.has(e.cid,(n,i)=>{n?this._log.error("failed existence check"):i&&this._tasks.push({entry:e.entry,target:t}),r()})},()=>{this._outbox(),i()})}_processBlocks(e,t,r){const n=[];e.forEach((e,r)=>{this._log("got block (%s bytes)",e.data.length),t.receivedBytes(e.data.length),n.push(e.cid)}),this.receivedBlocks(n)}messageSent(e,t){const r=this._findOrCreate(e);r.sentBytes(t?t.data.length:0),t&&t.cid&&r.wantlist.remove(t.cid)}numBytesSentTo(e){return this._findOrCreate(e).accounting.bytesSent}numBytesReceivedFrom(e){return this._findOrCreate(e).accounting.bytesRecv}peerDisconnected(e){}_findOrCreate(e){const t=e.toB58String();if(this.ledgerMap.has(t))return this.ledgerMap.get(t);const r=new g(e);return this.ledgerMap.set(t,r),this._stats&&this._stats.push(t,"peerCount",1),r}start(e){this._running=!0,s(()=>e())}stop(e){this._running=!1,s(()=>e())}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,s){(0,n.default)(t)(e,(0,i.default)((0,o.default)(r)),s)};var n=s(r(358)),i=s(r(364)),o=s(r(34));function s(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default},function(e,t,r){(function(t){var r=200,n="__lodash_hash_undefined__",i="[object Function]",o="[object GeneratorFunction]",s=/^\[object .+?Constructor\]$/,a="object"==typeof t&&t&&t.Object===Object&&t,u="object"==typeof self&&self&&self.Object===Object&&self,c=a||u||Function("return this")();function f(e,t){return!(!e||!e.length)&&function(e,t,r){if(t!=t)return function(e,t,r,n){for(var i=e.length,o=r+(n?1:-1);n?o--:++o-1}function l(e,t,r){for(var n=-1,i=e?e.length:0;++n-1},C.prototype.set=function(e,t){var r=this.__data__,n=R(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},P.prototype.clear=function(){this.__data__={hash:new B,map:new(x||C),string:new B}},P.prototype.delete=function(e){return K(this,e).delete(e)},P.prototype.get=function(e){return K(this,e).get(e)},P.prototype.has=function(e){return K(this,e).has(e)},P.prototype.set=function(e,t){return K(this,e).set(e,t),this},O.prototype.add=O.prototype.push=function(e){return this.__data__.set(e,n),this},O.prototype.has=function(e){return this.__data__.has(e)};var L=I&&1/d(new I([,-0]))[1]==1/0?function(e){return new I(e)}:function(){};function K(e,t){var r=e.__data__;return function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?r["string"==typeof t?"string":"hash"]:r.map}function j(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return N(r)?r:void 0}function M(e,t){return e===t||e!=e&&t!=t}function D(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}e.exports=function(e,t){return e&&e.length?function(e,t,n){var i=-1,o=f,s=e.length,a=!0,u=[],c=u;if(n)a=!1,o=l;else if(s>=r){var h=t?null:L(e);if(h)return d(h);a=!1,o=p,c=new O}else c=t?[]:u;e:for(;++i-1},Ae.prototype.set=function(e,t){var r=this.__data__,n=Ce(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},xe.prototype.clear=function(){this.__data__={hash:new Ee,map:new(le||Ae),string:new Ee}},xe.prototype.delete=function(e){return He(this,e).delete(e)},xe.prototype.get=function(e){return He(this,e).get(e)},xe.prototype.has=function(e){return He(this,e).has(e)},xe.prototype.set=function(e,t){return He(this,e).set(e,t),this},Ie.prototype.add=Ie.prototype.push=function(e){return this.__data__.set(e,o),this},Ie.prototype.has=function(e){return this.__data__.has(e)},Te.prototype.clear=function(){this.__data__=new Ae},Te.prototype.delete=function(e){return this.__data__.delete(e)},Te.prototype.get=function(e){return this.__data__.get(e)},Te.prototype.has=function(e){return this.__data__.has(e)},Te.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Ae){var i=r.__data__;if(!le||i.lengthc))return!1;var l=o.get(e);if(l&&o.get(t))return l==t;var h=-1,p=!0,d=i&s?new Ie:void 0;for(o.set(e,t),o.set(t,e);++h-1&&e%1==0&&e-1&&e%1==0&&e<=c}function at(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function ut(e){return!!e&&"object"==typeof e}function ct(e){return"symbol"==typeof e||ut(e)&&ne.call(e)==E}var ft=H?function(e){return function(t){return e(t)}}(H):function(e){return ut(e)&&st(e.length)&&!!L[ne.call(e)]};function lt(e){return it(e)?Be(e):De(e)}function ht(e){return e}r.exports=Qe}).call(this,r(6),r(27)(e))},function(e,t){function r(e,t,r){if(t!=t)return function(e,t,r,n){for(var i=e.length,o=r+(n?1:-1);n?o--:++o-1;)f!==e&&o.call(f,l,1),o.call(e,l,1);return e}e.exports=function(e,t,r){return e&&e.length&&t&&t.length?s(e,t,void 0,r):e}},function(e,t,r){"use strict";const n=r(187);e.exports=class{constructor(e){this.partner=e,this.wantlist=new n,this.exchangeCount=0,this.sentToPeer=new Map,this.accounting={bytesSent:0,bytesRecv:0}}sentBytes(e){this.exchangeCount++,this.lastExchange=(new Date).getTime(),this.accounting.bytesSent+=e}receivedBytes(e){this.exchangeCount++,this.lastExchange=(new Date).getTime(),this.accounting.bytesRecv+=e}wants(e,t){this.wantlist.add(e,t)}cancelWant(e){this.wantlist.remove(e)}wantlistContains(e){return this.wantlist.contains(e)}debtRatio(){return this.accounting.bytesSent/(this.accounting.bytesRecv+1)}}},function(e,t,r){"use strict";const n=r(11).EventEmitter,i=r(280),o=r(113).logger,s=e=>`unwant:${e}`,a=e=>`block:${e}`;e.exports=class extends n{constructor(e){super(),this.setMaxListeners(i.maxListeners),this._log=o(e,"notif"),this._unwantListeners={},this._blockListeners={}}hasBlock(e){const t=`block:${e.cid.buffer.toString()}`;this._log(t),this.emit(t,e)}wantBlock(e,t,r){const n=e.buffer.toString();this._log(`wantBlock:${n}`),this._unwantListeners[n]=(()=>{this._log(`manual unwant: ${n}`),this._cleanup(n),r()}),this._blockListeners[n]=(e=>{this._cleanup(n),t(e)}),this.once(s(n),this._unwantListeners[n]),this.once(a(n),this._blockListeners[n])}unwantBlock(e){const t=`unwant:${e.buffer.toString()}`;this._log(t),this.emit(t)}_cleanup(e){this._unwantListeners[e]&&(this.removeListener(s(e),this._unwantListeners[e]),delete this._unwantListeners[e]),this._blockListeners[e]&&(this.removeListener(a(e),this._blockListeners[e]),delete this._blockListeners[e])}}},function(e,t,r){"use strict";const n=r(11),i=r(1062),o={movingAverageIntervals:[6e4,3e5,9e5]};e.exports=class extends n{constructor(e,t){super();const r=Object.assign({},o,t);if("number"!=typeof r.computeThrottleTimeout)throw new Error("need computeThrottleTimeout");if("number"!=typeof r.computeThrottleMaxQueueSize)throw new Error("need computeThrottleMaxQueueSize");this._initialCounters=e,this._options=r,this._enabled=this._options.enabled,this._global=new i(e,r),this._global.on("update",e=>this.emit("update",e)),this._peers=new Map}enable(){this._enabled=!0,this._options.enabled=!0,this._global.enable()}disable(){this._enabled=!1,this._options.enabled=!1,this._global.disable()}stop(){this._enabled=!1,this._global.stop();for(let e of this._peers)e[1].stop()}get snapshot(){return this._global.snapshot}get movingAverages(){return this._global.movingAverages}forPeer(e){return e.toB58String&&(e=e.toB58String()),this._peers.get(e)}push(e,t,r){if(this._enabled&&(this._global.push(t,r),e)){let n=this._peers.get(e);n||(n=new i(this._initialCounters,this._options),this._peers.set(e,n)),n.push(t,r)}}disconnected(e){const t=e.toB58String(),r=this._peers.get(t);r&&(r.stop(),this._peers.delete(t))}}},function(e,t,r){"use strict";const n=r(11),i=r(122),o=r(508);e.exports=class extends n{constructor(e,t){super(),this._options=t,this._queue=[],this._stats={},this._frequencyLastTime=Date.now(),this._frequencyAccumulators={},this._movingAverages={},this._update=this._update.bind(this),e.forEach(e=>{this._stats[e]=i(0),this._movingAverages[e]={},this._options.movingAverageIntervals.forEach(t=>{(this._movingAverages[e][t]=o(t)).push(this._frequencyLastTime,0)})}),this._enabled=this._options.enabled}enable(){this._enabled=!0}disable(){this._disabled=!0}stop(){this._timeout&&clearTimeout(this._timeout)}get snapshot(){return Object.assign({},this._stats)}get movingAverages(){return Object.assign({},this._movingAverages)}push(e,t){this._enabled&&(this._queue.push([e,t,Date.now()]),this._resetComputeTimeout())}_resetComputeTimeout(){this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout(this._update,this._nextTimeout())}_nextTimeout(){const e=this._queue.length/this._options.computeThrottleMaxQueueSize;return Math.max(this._options.computeThrottleTimeout*(1-e),0)}_update(){if(this._timeout=null,this._queue.length){let e;for(;this._queue.length;){const t=e=this._queue.shift();this._applyOp(t)}this._updateFrequency(e[2]),this.emit("update",this._stats)}}_updateFrequency(e){const t=e-this._frequencyLastTime;Object.keys(this._stats).forEach(r=>{this._updateFrequencyFor(r,t,e)}),this._frequencyLastTime=e}_updateFrequencyFor(e,t,r){const n=this._frequencyAccumulators[e]||0;this._frequencyAccumulators[e]=0;const i=n/t*1e3;let s=this._movingAverages[e];s||(s=this._movingAverages[e]={}),this._options.movingAverageIntervals.forEach(e=>{let t=s[e];t||(t=s[e]=o(e)),t.push(r,i)})}_applyOp(e){const t=e[0],r=e[1];if("number"!=typeof r)throw new Error("invalid increment number:",r);let n;n=this._stats.hasOwnProperty(t)?this._stats[t]:this._stats[t]=i(0),this._stats[t]=n.plus(r),this._frequencyAccumulators[t]||(this._frequencyAccumulators[t]=0),this._frequencyAccumulators[t]+=r}}},function(e,t,r){"use strict";const n=r(49),i=r(23);e.exports=(e=>i(t=>{if(t=t||function(){},e.log("stop"),"stopped"===e.state.state())return t(new Error("Already stopped"));if("running"!==e.state.state())return t(new Error("Not able to stop from state: "+e.state.state()));e.state.stop(),e._blockService.unsetExchange(),e._bitswap.stop(),e._preload.stop(),n([t=>e._mfsPreload.stop(t),t=>e.libp2p.stop(t),t=>e._repo.close(t)],r=>{if(r)return e.emit("error",r),t(r);e.state.stopped(),e.emit("stop"),t()})}))},function(e,t,r){"use strict";e.exports=function(e){return()=>Boolean(e._bitswap&&e._libp2pNode&&e._libp2pNode.isStarted())}},function(e,t,r){"use strict";const n=r(509),i=r(23);e.exports=function(e){return i((t,r)=>{"function"==typeof t&&(r=t,t={}),e.repo.version((e,t)=>{e&&r(e),r(null,{version:n.version,repo:t,commit:""})})})}},function(e,t,r){"use strict";const n=r(23),i=r(3),o=r(509).version;e.exports=function(e){return n((t,r)=>{"function"==typeof t&&(r=t,t={}),i(()=>r(null,{id:e._peerInfo.id.toB58String(),publicKey:e._peerInfo.id.pubKey.bytes.toString("base64"),addresses:e._peerInfo.multiaddrs.toArray().map(e=>e.toString()).filter(e=>e.indexOf("ipfs")>=0).sort(),agentVersion:`js-ipfs/${o}`,protocolVersion:"9000"}))})}},function(e,t,r){"use strict";const n=r(110),i=r(4),o=r(63),s=r(23),a=r(511),u=r(498),c=r(1068);e.exports=function(e){return s((t,r)=>{"function"==typeof t&&(r=t,t={});const s=(t,n)=>{if(t)return e.emit("error",t),r(t);e.preStart(t=>{if(t)return e.emit("error",t),r(t);e.state.initialized(),e.emit("init"),r(null,n)})};if("uninitialized"!==e.state.state())return s(new Error("Not able to init from state: "+e.state.state()));if(e.state.init(),e.log("init"),t.repo)return e._repo=t.repo,s(null,!0);t.emptyRepo=t.emptyRepo||!1,t.bits=Number(t.bits)||2048,t.log=t.log||function(){};const f=a();let l;i([t=>e._repo.exists(t),(r,i)=>{if(e.log("repo exists?",r),!0===r)return i(new Error("repo already exists"));t.log(`generating ${t.bits}-bit RSA keypair...`,!1),e.log("generating peer id: %s bits",t.bits),n.create({bits:t.bits},i)},(r,n)=>{e.log("identity generated"),f.Identity={PeerID:r.toB58String(),PrivKey:r.privKey.bytes.toString("base64")},t.pass&&(l=r.privKey,f.Keychain=u.generateOptions()),t.log("done"),t.log("peer identity: "+f.Identity.PeerID),e._repo.init(f,n)},(t,r)=>e._repo.open(r),r=>{if(e.log("repo opened"),t.pass){e.log("creating keychain");const n=Object.assign({passPhrase:t.pass},f.Keychain);e._keychain=new u(e._repo.keys,n),e._keychain.importPeer("self",{privKey:l},r)}else r(null,!0)},(r,n)=>{if(t.emptyRepo)return n(null,!0);const i=[t=>e.object.new("unixfs-dir",t)];"function"==typeof c&&i.push(r=>c(e,t.log,r)),e.log("adding assets"),o(i,e=>{e?n(e):n(null,!0)})}],s)})}},function(e,t){},function(e,t,r){"use strict";const n=r(511),i=r(78).IPFS.matches,o=r(23);function s(e){try{return i(e)}catch(e){return!1}}function a(e){return new Error(`${e} is not a valid Multiaddr`)}e.exports=function(e){return{list:o(t=>{e._repo.config.get((e,r)=>{if(e)return t(e);t(null,{Peers:r.Bootstrap})})}),add:o((t,r,i)=>{if("function"==typeof r&&(i=r,r={default:!1}),t&&!s(t))return setImmediate(()=>i(a(t)));e._repo.config.get((o,s)=>{if(o)return i(o);r.default?s.Bootstrap=n().Bootstrap:t&&-1===s.Bootstrap.indexOf(t)&&s.Bootstrap.push(t),e._repo.config.set(s,e=>{if(e)return i(e);i(null,{Peers:r.default?n().Bootstrap:[t]})})})}),rm:o((t,r,n)=>{if("function"==typeof r&&(n=r,r={all:!1}),t&&!s(t))return setImmediate(()=>n(a(t)));e._repo.config.get((i,o)=>{if(i)return n(i);r.all?o.Bootstrap=[]:o.Bootstrap=o.Bootstrap.filter(e=>e!==t),e._repo.config.set(o,e=>{if(e)return n(e);const i=[];!r.all&&t&&i.push(t),n(null,{Peers:i})})})})}}},function(e,t,r){"use strict";const n=r(23);e.exports=function(e){return{get:n((t,r)=>("function"==typeof t&&(r=t,t=void 0),e._repo.config.get(t,r))),set:n((t,r,n)=>{e._repo.config.set(t,r,n)}),replace:n((t,r)=>{e._repo.config.set(t,r)})}}},function(e,t,r){"use strict";const n=r(151),i=r(12),o=r(65),s=r(9),a=r(4),u=r(23);function c(e){return s.isCID(e)?e:new s(e)}e.exports=function(e){return{get:u((t,r)=>{t=c(t),e._blockService.get(t,r)}),put:u((t,r,i)=>{if(i=i||function(){},"function"==typeof r&&(i=r,r={}),Array.isArray(t))return i(new Error("Array is not supported"));a([e=>{if(n.isBlock(t))return e(null,t);if(r.cid&&s.isCID(r.cid))return e(null,new n(t,r.cid));const i=r.mhtype||"sha2-256",a=r.format||"dag-pb",u=r.version||0;o(t,i,(r,i)=>{if(r)return e(r);e(null,new n(t,new s(u,a,i)))})},(t,n)=>e._blockService.put(t,i=>{if(i)return n(i);!1!==r.preload&&e._preload(t.cid),n(null,t)})],i)}),rm:u((t,r)=>{t=c(t),e._blockService.delete(t,r)}),stat:u((t,r)=>{t=c(t),e._blockService.get(t,(e,n)=>{if(e)return r(e);r(null,{key:i.toB58String(t.multihash),size:n.data.length})})})}}},function(e,t,r){"use strict";(function(t){const n=r(4),i=r(23),o=r(45),s=o.DAGNode,a=o.DAGLink,u=r(9),c=r(12),f=r(36),l=r(17);function h(e,r){if("string"==typeof e)return"base58"!==r&&r?t.from(e,r):e;if(t.isBuffer(e))return e;throw new Error("unsupported multihash")}function p(e,t,r){switch(t){case"json":return d(e,r);case"protobuf":return function(e,t){o.util.deserialize(e,t)}(e,r);default:r(new Error(`unkown encoding: ${t}`))}}function d(e,r){let n,i;try{const o=JSON.parse(e.toString());i=(o.Links||[]).map(e=>new a(e.Name||e.name,e.Size||e.size,c.fromB58String(e.Hash||e.hash||e.multihash))),n=t.from(o.Data)}catch(e){return r(new Error("failed to parse JSON: "+e))}s.create(n,i,r)}e.exports=function(e){function r(t){return(r,i,o)=>{"function"==typeof i&&(o=i,i={}),n([t=>{e.object.get(r,i,t)},(r,n)=>{t(r,(t,r)=>{if(t)return n(t);const o=new u(r.multihash);e._ipld.put(r,{cid:o},t=>{if(t)return n(t);!1!==i.preload&&e._preload(o),n(null,r)})})}],o)}}return{new:i((r,n,i)=>{let o;"function"==typeof r&&(i=r,r=void 0,n={}),"function"==typeof n&&(i=n,n={}),n=n||{},r?(l("unixfs-dir"===r,"unkown template"),o=new f("directory").marshal()):o=t.alloc(0),s.create(o,(t,r)=>{if(t)return i(t);const o=new u(r.multihash);e._ipld.put(r,{cid:o},t=>{if(t)return i(t);!1!==n.preload&&e._preload(o),i(null,r)})})}),put:i((r,n,i)=>{"function"==typeof n&&(i=n,n={});const o=n.enc;let a;if(t.isBuffer(r))o?p(r,o,(e,t)=>{if(e)return i(e);a=t,c()}):s.create(r,(e,t)=>{if(e)return i(e);a=t,c()});else if(r.multihash)a=r,c();else{if("object"!=typeof r)return i(new Error("obj not recognized"));s.create(r.Data,r.Links,(e,t)=>{if(e)return i(e);a=t,c()})}function c(){const t=new u(a.multihash);e._ipld.put(a,{cid:t},r=>{if(r)return i(r);!1!==n.preload&&e._preload(t),e.object.get(a.multihash,i)})}}),get:i((t,r,n)=>{let i;"function"==typeof r&&(n=r,r={});try{i=h(t,r.enc)}catch(t){return n(t)}let o=new u(i);1===r.cidVersion&&(o=o.toV1()),e._ipld.get(o,(e,t)=>{if(e)return n(e);const r=t.value;n(null,r)})}),data:i((t,r,n)=>{"function"==typeof r&&(n=r,r={}),e.object.get(t,r,(e,t)=>{if(e)return n(e);n(null,t.data)})}),links:i((t,r,n)=>{"function"==typeof r&&(n=r,r={}),e.object.get(t,r,(e,t)=>{if(e)return n(e);n(null,t.links)})}),stat:i((t,r,n)=>{"function"==typeof r&&(n=r,r={}),e.object.get(t,r,(e,t)=>{if(e)return n(e);o.util.serialize(t,(e,r)=>{if(e)return n(e);const i=r.length,o=t.links.reduce((e,t)=>e+t.size,0),s=t.toJSON();n(null,{Hash:s.multihash,NumLinks:t.links.length,BlockSize:i,LinksSize:i-t.data.length,DataSize:t.data.length,CumulativeSize:i+o})})})}),patch:i({addLink(e,t,n,i){r((e,r)=>{s.addLink(e,t,r)})(e,n,i)},rmLink(e,t,n,i){r((e,r)=>{a.isDAGLink(t)?t=t._name:t&&t.name&&(t=t.name),s.rmLink(e,t,r)})(e,n,i)},appendData(e,n,i,o){r((e,r)=>{const i=t.concat([e.data,n]);s.create(i,e.links,r)})(e,i,o)},setData(e,t,n,i){r((e,r)=>{s.create(t,e.links,r)})(e,n,i)}})}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";e.exports="message Data {\n enum DataType {\n Raw = 0;\n Directory = 1;\n File = 2;\n Metadata = 3;\n Symlink = 4;\n HAMTShard = 5;\n }\n\n required DataType Type = 1;\n optional bytes Data = 2;\n optional uint64 filesize = 3;\n repeated uint64 blocksizes = 4;\n\n optional uint64 hashType = 5;\n optional uint64 fanout = 6;\n}\n\nmessage Metadata {\n optional string MimeType = 1;\n}"},function(e,t,r){"use strict";(function(t){const n=r(23),i=r(9),o=r(8),s=r(80),a=r(1075);e.exports=function(e){return{put:n((t,r,n)=>{if("function"==typeof r)n=r;else{if(r.cid&&(r.format||r.hashAlg))return n(new Error("Can't put dag node. Please provide either `cid` OR `format` and `hashAlg` options."));if(r.format&&!r.hashAlg||!r.format&&r.hashAlg)return n(new Error("Can't put dag node. Please provide `format` AND `hashAlg` options."))}r=r.cid?r:Object.assign({},{format:"dag-cbor",hashAlg:"sha2-256"},r),e._ipld.put(t,r,(t,i)=>{if(t)return n(t);!1!==r.preload&&e._preload(i),n(null,i)})}),get:n((r,n,o,s)=>{if("function"==typeof n&&(s=n,n=void 0),"function"==typeof o&&(s=o,o={}),o=o||{},"string"==typeof r){const e=r.split("/");r=new i(e[0]),e.shift(),n=e.length>0?e.join("/"):"/"}else if(t.isBuffer(r))try{r=new i(r)}catch(r){return s(r)}e._ipld.get(r,n,o,s)}),tree:n((t,r,n,s)=>{if("object"==typeof r&&(s=n,n=r,r=void 0),"function"==typeof r&&(s=r,r=void 0),"function"==typeof n&&(s=n,n={}),n=n||{},"string"==typeof t){const e=t.split("/");t=new i(e[0]),e.shift(),r=e.length>0?e.join("/"):void 0}o(e._ipld.treeStream(t,r,n),o.collect(s))}),_getRecursive:n((t,r)=>{e.dag.get(new i(t),(t,n)=>{if(t)return r(t);s(n.value.links,(t,r)=>{e.dag._getRecursive(t.multihash,r)},(e,t)=>{if(e)return r(e);r(null,a([n.value,t]))})})})}}}).call(this,r(0).Buffer)},function(e,t,r){var n=r(1076),i=1/0;e.exports=function(e){return null!=e&&e.length?n(e,i):[]}},function(e,t,r){var n=r(1077),i=r(1078);e.exports=function e(t,r,o,s,a){var u=-1,c=t.length;for(o||(o=i),a||(a=[]);++u0&&o(f)?r>1?e(f,r-1,o,s,a):n(a,f):s||(a[a.length]=f)}return a}},function(e,t){e.exports=function(e,t){for(var r=-1,n=t.length,i=e.length;++r{e.config.get(function(r,i){if(r)return t(r);const a={peerInfo:e._peerInfo,peerBook:e._peerInfoBook,config:{peerDiscovery:{mdns:{enabled:o(e._options,"config.Discovery.MDNS.Enabled",o(i,"Discovery.MDNS.Enabled",!0))},webRTCStar:{enabled:o(e._options,"config.Discovery.webRTCStar.Enabled",o(i,"Discovery.webRTCStar.Enabled",!0))},bootstrap:{list:o(e._options,"config.Bootstrap",o(i,"Bootstrap",[]))}},relay:{enabled:o(e._options,"relay.enabled",o(i,"relay.enabled",!1)),hop:{enabled:o(e._options,"relay.hop.enabled",o(i,"relay.hop.enabled",!1)),active:o(e._options,"relay.hop.active",o(i,"relay.hop.active",!1))}},EXPERIMENTAL:{dht:o(e._options,"EXPERIMENTAL.dht",!1),pubsub:o(e._options,"EXPERIMENTAL.pubsub",!1)}},connectionManager:o(e._options,"connectionManager",o(i,"connectionManager",{}))},u=s(o(e._options,"libp2p",{}),a);e._libp2pNode=new n(u),e._libp2pNode.on("peer:discovery",t=>{const r=()=>{e._peerInfoBook.put(t),e._libp2pNode.dial(t,()=>{})};e.isOnline()?r():e._libp2pNode.once("start",r)}),e._libp2pNode.on("peer:connect",t=>{e._peerInfoBook.put(t)}),e._libp2pNode.start(r=>{if(r)return t(r);e._libp2pNode.peerInfo.multiaddrs.forEach(e=>{console.log("Swarm listening on",e.toString())}),t()})})}),stop:i(t=>{e._libp2pNode.stop(t)})}}},function(e,t,r){"use strict";const n=r(512),i=r(1094),o=r(1134),s=r(1155),a=r(1163),u=r(1187),c=r(1205),f=r(594);e.exports=class extends c{constructor(e){const t=new i({id:e.peerInfo.id}),r=new o({id:e.peerInfo.id}),c={modules:{transport:[n,t,r],streamMuxer:[s],connEncryption:[a],peerDiscovery:[t.discovery,r.discovery,u]},config:{peerDiscovery:{bootstrap:{enabled:!0},webRTCStar:{enabled:!0},websocketStar:{enabled:!0}},EXPERIMENTAL:{dht:!1,pubsub:!1}}};super(f(e,c))}}},function(e,t,r){"use strict";var n=r(1082),i=r(1084),o=r(1088);function s(e){return"function"==typeof e}e.exports=function(e,t){s(t)&&(t={onConnect:t});var r="undefined"==typeof window?{}:window.location,a=o(e,r),u=new n(a),c=i(u,t);return c.remoteAddress=a,c.close=function(e){s(e)&&u.addEventListener("close",e),u.close()},u.addEventListener("open",function(e){t&&s(t.onConnect)&&t.onConnect(null,c)}),c},e.exports.connect=e.exports},function(e,t,r){e.exports="undefined"==typeof WebSocket?r(1083):WebSocket},function(e,t){},function(e,t,r){var n=r(1085),i=r(1086);e.exports=function(e,t){var r=e.upgradeReq||{};return t&&t.binaryType?e.binaryType=t.binaryType:t&&t.binary&&(e.binaryType="arraybuffer"),{source:n(e,t&&t.onConnect),sink:i(e,t),headers:r.headers,url:r.url,upgrade:r.upgrade,method:r.method}}},function(e,t,r){var n=r(2).Buffer;e.exports=function(e,t){var r,i,o=[],s=!1;return e.addEventListener("message",function(e){var t=e.data;if(function(e){return e instanceof ArrayBuffer||null!=e&&null!=e.constructor&&"ArrayBuffer"===e.constructor.name&&"number"==typeof e.byteLength}(t)&&(t=n.from(t)),r)return r(null,t);o.push(t)}),e.addEventListener("close",function(e){i||r&&r(i=!0)}),e.addEventListener("error",function(e){i||(i=e,s||(s=!0,t&&t(e)),r&&r(i))}),e.addEventListener("open",function(e){s||i||(s=!0)}),function(t,n){if(r=null,i)return n(i);t?(r=n,e.close()):o.length>0?n(null,o.shift()):r=n}}},function(e,t,r){(function(t){var n=r(1087),i="undefined"!=typeof setImmediate?setImmediate:t.nextTick;e.exports=function(e,t){return function(r){var o=!1!==(t=t||{}).closeOnEnd,s="function"==typeof t?t:t.onClose;r(null,function t(a,u){a?o&&e.readyState<=1&&(s&&e.addEventListener("close",function(e){if(e.wasClean||1006===e.code)s();else{var t=new Error("ws error");t.event=e,s(t)}}),e.close()):n(e,function(n){if(n)return r(n,function(){});e.send(u),i(function(){r(null,t)})})})}}}).call(this,r(7))},function(e,t){e.exports=function(e,t){var r=e&&(e.removeEventListener||e.removeListener);function n(){"function"==typeof r&&(r.call(e,"open",i),r.call(e,"error",o))}function i(e){n(),t()}function o(e){n(),t(e)}return e.readyState>=2?t(!0):1===e.readyState?t():(e.addEventListener("open",i),void e.addEventListener("error",o))}},function(e,t,r){var n=r(1089),i={http:"ws",https:"wss"};e.exports=function(e,t){return n(e,t,i,"ws")}},function(e,t,r){var n=r(33);e.exports=function(e,t,r,i){var o;return r=r||{},o=(e=n.parse(e,!1,!0)).protocol?e.protocol:(r[o=t.protocol?t.protocol.replace(/:$/,""):"http"]||i||o)+":",e.host&&":"===e.host[0]&&(e.host=null),e.hostname?n.format({protocol:o,slashes:!0,hostname:e.hostname,port:e.port,pathname:e.pathname,search:e.search}):(e.host=t.host,e.port?n.format({protocol:o,slashes:!0,host:t.hostname+":"+e.port,port:e.port,pathname:e.pathname,search:e.search}):e.pathname?n.format({protocol:o,slashes:!0,host:e.host,pathname:e.pathname,search:e.search}):(e.pathname=t.pathname,e.search?n.format({protocol:o,slashes:!0,host:e.host,pathname:e.pathname,search:e.search}):(e.search=t.search,e.format(e))))}},function(e,t){var r=1/0,n=9007199254740991,i=1.7976931348623157e308,o=NaN,s="[object Arguments]",a="[object Function]",u="[object GeneratorFunction]",c="[object String]",f="[object Symbol]",l=/^\s+|\s+$/g,h=/^[-+]0x[0-9a-f]+$/i,p=/^0b[01]+$/i,d=/^0o[0-7]+$/i,y=/^(?:0|[1-9]\d*)$/,g=parseInt;function m(e){return e!=e}function b(e,t){return function(e,t){for(var r=-1,n=e?e.length:0,i=Array(n);++r-1&&e%1==0&&e-1&&e%1==0&&e<=n}(e.length)&&!function(e){var t=C(e)?w.call(e):"";return t==a||t==u}(e)}function C(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function P(e){return!!e&&"object"==typeof e}function O(e){return e?(e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||P(e)&&w.call(e)==f}(e))return o;if(C(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=C(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(l,"");var r=p.test(e);return r||d.test(e)?g(e.slice(2),r?2:8):h.test(e)?o:+e}(e))===r||e===-r?(e<0?-1:1)*i:e==e?e:0:0===e?e:0}e.exports=function(e,t,r,n){e=B(e)?e:function(e){return e?b(e,function(e){return B(e)?A(e):x(e)}(e)):[]}(e),r=r&&!n?function(e){var t=O(e),r=t%1;return t==t?r?t-r:t:0}(r):0;var i=e.length;return r<0&&(r=E(i+r,0)),function(e){return"string"==typeof e||!T(e)&&P(e)&&w.call(e)==c}(e)?r<=i&&e.indexOf(t,r)>-1:!!i&&function(e,t,r){if(t!=t)return function(e,t,r,n){for(var i=e.length,o=r+(n?1:-1);n?o--:++o-1}},function(e,t,r){"use strict";const n=r(386);e.exports=class{constructor(e,t){this.peerInfo=null,this.conn=n(),e?this.setInnerConn(e,t):t&&(this.info=t)}get source(){return this.conn.source}get sink(){return this.conn.sink}getPeerInfo(e){return this.info&&this.info.getPeerInfo?this.info.getPeerInfo(e):this.peerInfo?void e(null,this.peerInfo):e(new Error("Peer Info not set yet"))}setPeerInfo(e){if(this.info&&this.info.setPeerInfo)return this.info.setPeerInfo(e);this.peerInfo=e}getObservedAddrs(e){if(this.info&&this.info.getObservedAddrs)return this.info.getObservedAddrs(e);e(null,[])}setInnerConn(e,t){this.conn.resolve(e),this.info=t||e}}},function(e,t,r){"use strict";const n=r(1)("libp2p:websockets:dialer");e.exports=function(e){const t=e.toString().split("/");let r,i;try{r=e.protoNames().filter(e=>"ws"===e||"wss"===e)[0]}catch(e){throw n(e),new Error("Not a valid websocket address",e)}try{i=e.stringTuples().filter(t=>{if(t[0]===e.protos().filter(e=>"tcp"===e.name)[0].code)return!0})[0][1]}catch(e){n("No port, skipping")}return`${r}://${t[2]}${!i||80===i&&443===i?"":`:${i}`}`}},function(e,t,r){"use strict";e.exports=function(){throw new Error("WebSocket Servers can not be created in the browser!")}},function(e,t,r){"use strict";const n=r(1)("libp2p:webrtc-star"),i=r(52),o=r(78),s=r(62),a=r(513),u=r(11).EventEmitter,c=r(191),f=r(1114),l=r(51),h=r(47).Connection,p=r(192),d=r(30),y=r(3),g=r(1132),m=r(1133),b=m.cleanUrlSIO,v=m.cleanMultiaddr,_=d(()=>{}),w={transports:["websocket"],"force new connection":!0};e.exports=s(class{constructor(e){e=e||{},this.maSelf=void 0,this.sioOptions={transports:["websocket"],"force new connection":!0},e.wrtc&&(this.wrtc=e.wrtc),this.discovery=new u,this.discovery.tag="webRTCStar",this.discovery.start=(e=>{y(e)}),this.discovery.stop=(e=>{y(e)}),this.listenersRefs={},this._peerDiscovered=this._peerDiscovered.bind(this)}dial(e,t,r){"function"==typeof t&&(r=t,t={}),r=r?d(r):_;const n=(~~(1e9*Math.random())).toString(36)+Date.now(),i=this.listenersRefs[Object.keys(this.listenersRefs)[0]].io,o={initiator:!0,trickle:!1};this.wrtc&&(o.wrtc=this.wrtc);const s=new c(o),a=new h(p.duplex(s));let u=!1;return s.on("signal",t=>{i.emit("ss-handshake",{intentId:n,srcMultiaddr:this.maSelf.toString(),dstMultiaddr:e.toString(),signal:t})}),s.once("timeout",()=>r(new Error("timeout"))),s.once("error",e=>{u||r(e)}),i.on("ws-handshake",t=>{if(t.intentId===n&&t.err)return r(new Error(t.err));t.intentId===n&&t.answer&&(s.once("connect",()=>{u=!0,a.destroy=s.destroy.bind(s),s.once("close",()=>a.destroy()),a.getObservedAddrs=(t=>t(null,[e])),r(null,a)}),s.signal(t.signal))}),a}createListener(e,t){"function"==typeof e&&(t=e,e={});const r=new u;return r.listen=((e,i)=>{if(i=i?d(i):_,!g.support&&!this.wrtc)return y(()=>i(new Error("no WebRTC support")));this.maSelf=e;const o=b(e);n("Dialing to Signalling Server on: "+o),r.io=a.connect(o,w),r.io.once("connect_error",i),r.io.once("error",e=>{r.emit("error",e),r.emit("close")}),r.io.on("ws-handshake",function(e){if(e.answer||e.err)return;const n={trickle:!1};s.wrtc&&(n.wrtc=s.wrtc);const i=new c(n),o=new h(p.duplex(i));i.once("connect",()=>{o.getObservedAddrs=(t=>t(null,[e.srcMultiaddr])),r.emit("connection",o),t(o)}),i.once("signal",t=>{e.signal=t,e.answer=!0,r.io.emit("ss-handshake",e)}),i.signal(e.signal)}),r.io.on("ws-peer",this._peerDiscovered),r.io.on("connect",()=>{r.io.emit("ss-join",e.toString())}),r.io.once("connect",()=>{r.emit("listening"),i()});const s=this}),r.close=(e=>{e=e?d(e):_,r.io.emit("ss-leave"),y(()=>{r.emit("close"),e()})}),r.getAddrs=(e=>{y(()=>e(null,[this.maSelf]))}),this.listenersRefs[i.toString()]=r,r}filter(e){return Array.isArray(e)||(e=[e]),e.filter(e=>!(e.protoNames().indexOf("p2p-circuit")>-1)&&o.WebRTCStar.matches(e))}_peerDiscovered(e){n("Peer Discovered:",e);const t=(e=v(e)).split("/ipfs/"),r=t[t.length-1],o=f.createFromB58String(r),s=new l(o);s.multiaddrs.add(i(e)),this.discovery.emit("peer",s)}},{className:"WebRTCStar",symbolName:"@libp2p/js-libp2p-webrtc-star/webrtcstar"})},function(e,t,r){(function(t){var n=r(514),i=r(1)("socket.io-client:url");e.exports=function(e,r){var o=e;r=r||t.location,null==e&&(e=r.protocol+"//"+r.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?r.protocol+e:r.host+e),/^(https?|wss?):\/\//.test(e)||(i("protocol-less url %s",e),e=void 0!==r?r.protocol+"//"+e:"https://"+e),i("parse %s",e),o=n(e)),o.port||(/^(http|ws)$/.test(o.protocol)?o.port="80":/^(http|ws)s$/.test(o.protocol)&&(o.port="443")),o.path=o.path||"/";var s=-1!==o.host.indexOf(":")?"["+o.host+"]":o.host;return o.id=o.protocol+"://"+s+":"+o.port,o.href=o.protocol+"://"+s+(r&&r.port===o.port?"":":"+o.port),o}}).call(this,r(6))},function(e,t,r){(function(e){var n=r(515),i=r(516),o=Object.prototype.toString,s="function"==typeof e.Blob||"[object BlobConstructor]"===o.call(e.Blob),a="function"==typeof e.File||"[object FileConstructor]"===o.call(e.File);function u(e,t){if(!e)return e;if(i(e)){var r={_placeholder:!0,num:t.length};return t.push(e),r}if(n(e)){for(var o=new Array(e.length),s=0;s0&&(this.extraHeaders=r.extraHeaders),r.localAddress&&(this.localAddress=r.localAddress)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingIntervalTimer=null,this.pingTimeoutTimer=null,this.open()}e.exports=f,f.priorWebsocketSuccess=!1,i(f.prototype),f.protocol=a.protocol,f.Socket=f,f.Transport=r(283),f.transports=r(518),f.parser=r(115),f.prototype.createTransport=function(e){o('creating transport "%s"',e);var t=function(e){var t={};for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t}(this.query);t.EIO=a.protocol,t.transport=e;var r=this.transportOptions[e]||{};return this.id&&(t.sid=this.id),new n[e]({query:t,socket:this,agent:r.agent||this.agent,hostname:r.hostname||this.hostname,port:r.port||this.port,secure:r.secure||this.secure,path:r.path||this.path,forceJSONP:r.forceJSONP||this.forceJSONP,jsonp:r.jsonp||this.jsonp,forceBase64:r.forceBase64||this.forceBase64,enablesXDR:r.enablesXDR||this.enablesXDR,timestampRequests:r.timestampRequests||this.timestampRequests,timestampParam:r.timestampParam||this.timestampParam,policyPort:r.policyPort||this.policyPort,pfx:r.pfx||this.pfx,key:r.key||this.key,passphrase:r.passphrase||this.passphrase,cert:r.cert||this.cert,ca:r.ca||this.ca,ciphers:r.ciphers||this.ciphers,rejectUnauthorized:r.rejectUnauthorized||this.rejectUnauthorized,perMessageDeflate:r.perMessageDeflate||this.perMessageDeflate,extraHeaders:r.extraHeaders||this.extraHeaders,forceNode:r.forceNode||this.forceNode,localAddress:r.localAddress||this.localAddress,requestTimeout:r.requestTimeout||this.requestTimeout,protocols:r.protocols||void 0})},f.prototype.open=function(){var e;if(this.rememberUpgrade&&f.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length){var t=this;return void setTimeout(function(){t.emit("error","No transports available")},0)}e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)},f.prototype.setTransport=function(e){o("setting transport %s",e.name);var t=this;this.transport&&(o("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=e,e.on("drain",function(){t.onDrain()}).on("packet",function(e){t.onPacket(e)}).on("error",function(e){t.onError(e)}).on("close",function(){t.onClose("transport close")})},f.prototype.probe=function(e){o('probing transport "%s"',e);var t=this.createTransport(e,{probe:1}),r=!1,n=this;function i(){if(n.onlyBinaryUpgrades){var i=!this.supportsBinary&&n.transport.supportsBinary;r=r||i}r||(o('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",function(i){if(!r)if("pong"===i.type&&"probe"===i.data){if(o('probe transport "%s" pong',e),n.upgrading=!0,n.emit("upgrading",t),!t)return;f.priorWebsocketSuccess="websocket"===t.name,o('pausing current transport "%s"',n.transport.name),n.transport.pause(function(){r||"closed"!==n.readyState&&(o("changing transport and sending upgrade packet"),h(),n.setTransport(t),t.send([{type:"upgrade"}]),n.emit("upgrade",t),t=null,n.upgrading=!1,n.flush())})}else{o('probe transport "%s" failed',e);var s=new Error("probe error");s.transport=t.name,n.emit("upgradeError",s)}}))}function s(){r||(r=!0,h(),t.close(),t=null)}function a(r){var i=new Error("probe error: "+r);i.transport=t.name,s(),o('probe transport "%s" failed because of error: %s',e,r),n.emit("upgradeError",i)}function u(){a("transport closed")}function c(){a("socket closed")}function l(e){t&&e.name!==t.name&&(o('"%s" works - aborting "%s"',e.name,t.name),s())}function h(){t.removeListener("open",i),t.removeListener("error",a),t.removeListener("close",u),n.removeListener("close",c),n.removeListener("upgrading",l)}f.priorWebsocketSuccess=!1,t.once("open",i),t.once("error",a),t.once("close",u),this.once("close",c),this.once("upgrading",l),t.open()},f.prototype.onOpen=function(){if(o("socket open"),this.readyState="open",f.priorWebsocketSuccess="websocket"===this.transport.name,this.emit("open"),this.flush(),"open"===this.readyState&&this.upgrade&&this.transport.pause){o("starting upgrade probes");for(var e=0,t=this.upgrades.length;en&&(r=n),t>=n||t>=r||0===n)return new ArrayBuffer(0);for(var i=new Uint8Array(e),o=new Uint8Array(r-t),s=t,a=0;s=55296&&t<=56319&&i=55296&&e<=57343){if(t)throw Error("Lone surrogate U+"+e.toString(16).toUpperCase()+" is not a scalar value");return!1}return!0}function d(e,t){return l(e>>t&63|128)}function y(e,t){if(0==(4294967168&e))return l(e);var r="";return 0==(4294965248&e)?r=l(e>>6&31|192):0==(4294901760&e)?(p(e,t)||(e=65533),r=l(e>>12&15|224),r+=d(e,6)):0==(4292870144&e)&&(r=l(e>>18&7|240),r+=d(e,12),r+=d(e,6)),r+l(63&e|128)}function g(){if(f>=c)throw Error("Invalid byte index");var e=255&u[f];if(f++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function m(e){var t,r;if(f>c)throw Error("Invalid byte index");if(f==c)return!1;if(t=255&u[f],f++,0==(128&t))return t;if(192==(224&t)){if((r=(31&t)<<6|g())>=128)return r;throw Error("Invalid continuation byte")}if(224==(240&t)){if((r=(15&t)<<12|g()<<6|g())>=2048)return p(r,e)?r:65533;throw Error("Invalid continuation byte")}if(240==(248&t)&&(r=(7&t)<<18|g()<<12|g()<<6|g())>=65536&&r<=1114111)return r;throw Error("Invalid UTF-8 detected")}var b={version:"2.1.2",encode:function(e,t){for(var r=!1!==(t=t||{}).strict,n=h(e),i=n.length,o=-1,s="";++o65535&&(i+=l((t-=65536)>>>10&1023|55296),t=56320|1023&t),i+=l(t);return i}(i)}};void 0===(i=function(){return b}.call(t,r,t,e))||(e.exports=i)}()}).call(this,r(27)(e),r(6))},function(e,t){!function(){"use strict";for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=new Uint8Array(256),n=0;n>2],o+=e[(3&n[r])<<4|n[r+1]>>4],o+=e[(15&n[r+1])<<2|n[r+2]>>6],o+=e[63&n[r+2]];return i%3==2?o=o.substring(0,o.length-1)+"=":i%3==1&&(o=o.substring(0,o.length-2)+"=="),o},t.decode=function(e){var t,n,i,o,s,a=.75*e.length,u=e.length,c=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var f=new ArrayBuffer(a),l=new Uint8Array(f);for(t=0;t>4,l[c++]=(15&i)<<4|o>>2,l[c++]=(3&o)<<6|63&s;return f}}()},function(e,t,r){(function(t){var r=t.BlobBuilder||t.WebKitBlobBuilder||t.MSBlobBuilder||t.MozBlobBuilder,n=function(){try{return 2===new Blob(["hi"]).size}catch(e){return!1}}(),i=n&&function(){try{return 2===new Blob([new Uint8Array([1,2])]).size}catch(e){return!1}}(),o=r&&r.prototype.append&&r.prototype.getBlob;function s(e){for(var t=0;t';n=document.createElement(e)}catch(e){(n=document.createElement("iframe")).name=r.iframeId,n.src="javascript:0"}n.id=r.iframeId,r.form.appendChild(n),r.iframe=n}this.form.action=this.uri(),f(),e=e.replace(a,"\\\n"),this.area.value=e.replace(s,"\\n");try{this.form.submit()}catch(e){}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){"complete"===r.iframe.readyState&&c()}:this.iframe.onload=c}}).call(this,r(6))},function(e,t,r){(function(t){var n,i=r(283),o=r(115),s=r(189),a=r(190),u=r(521),c=r(1)("engine.io-client:websocket"),f=t.WebSocket||t.MozWebSocket;if("undefined"==typeof window)try{n=r(1110)}catch(e){}var l=f;function h(e){e&&e.forceBase64&&(this.supportsBinary=!1),this.perMessageDeflate=e.perMessageDeflate,this.usingBrowserWebSocket=f&&!e.forceNode,this.protocols=e.protocols,this.usingBrowserWebSocket||(l=n),i.call(this,e)}l||"undefined"!=typeof window||(l=n),e.exports=h,a(h,i),h.prototype.name="websocket",h.prototype.supportsBinary=!0,h.prototype.doOpen=function(){if(this.check()){var e=this.uri(),t=this.protocols,r={agent:this.agent,perMessageDeflate:this.perMessageDeflate};r.pfx=this.pfx,r.key=this.key,r.passphrase=this.passphrase,r.cert=this.cert,r.ca=this.ca,r.ciphers=this.ciphers,r.rejectUnauthorized=this.rejectUnauthorized,this.extraHeaders&&(r.headers=this.extraHeaders),this.localAddress&&(r.localAddress=this.localAddress);try{this.ws=this.usingBrowserWebSocket?t?new l(e,t):new l(e):new l(e,t,r)}catch(e){return this.emit("error",e)}void 0===this.ws.binaryType&&(this.supportsBinary=!1),this.ws.supports&&this.ws.supports.binary?(this.supportsBinary=!0,this.ws.binaryType="nodebuffer"):this.ws.binaryType="arraybuffer",this.addEventListeners()}},h.prototype.addEventListeners=function(){var e=this;this.ws.onopen=function(){e.onOpen()},this.ws.onclose=function(){e.onClose()},this.ws.onmessage=function(t){e.onData(t.data)},this.ws.onerror=function(t){e.onError("websocket error",t)}},h.prototype.write=function(e){var r=this;this.writable=!1;for(var n=e.length,i=0,s=n;i0&&e.jitter<=1?e.jitter:0,this.attempts=0}e.exports=r,r.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),r=Math.floor(t*this.jitter*e);e=0==(1&Math.floor(10*t))?e-r:e+r}return 0|Math.min(e,this.max)},r.prototype.reset=function(){this.attempts=0},r.prototype.setMin=function(e){this.ms=e},r.prototype.setMax=function(e){this.max=e},r.prototype.setJitter=function(e){this.jitter=e}},function(e,t){e.exports=function(){if("undefined"==typeof window)return null;var e={RTCPeerConnection:window.RTCPeerConnection||window.mozRTCPeerConnection||window.webkitRTCPeerConnection,RTCSessionDescription:window.RTCSessionDescription||window.mozRTCSessionDescription||window.webkitRTCSessionDescription,RTCIceCandidate:window.RTCIceCandidate||window.mozRTCIceCandidate||window.webkitRTCIceCandidate};return e.RTCPeerConnection?e:null}},function(e,t,r){"use strict";(function(n){const i=r(12),o=r(1115),s=r(17),a=r(4);class u{constructor(e,t,r){s(n.isBuffer(e),"invalid id provided"),t&&r&&s(t.public.bytes.equals(r.bytes),"inconsistent arguments"),this._id=e,this._idB58String=i.toB58String(this.id),this._privKey=t,this._pubKey=r}get id(){return this._id}set id(e){throw new Error("Id is immutable")}get privKey(){return this._privKey}set privKey(e){this._privKey=e}get pubKey(){return this._pubKey?this._pubKey:this._privKey?this._privKey.public:void 0}set pubKey(e){this._pubKey=e}marshalPubKey(){if(this.pubKey)return o.keys.marshalPublicKey(this.pubKey)}marshalPrivKey(){if(this.privKey)return o.keys.marshalPrivateKey(this.privKey)}toPrint(){return this.toJSON()}toJSON(){return{id:this.toB58String(),privKey:c(this.marshalPrivKey()),pubKey:c(this.marshalPubKey())}}toHexString(){return i.toHexString(this.id)}toBytes(){return this.id}toB58String(){return this._idB58String}isEqual(e){if(n.isBuffer(e))return this.id.equals(e);if(e.id)return this.id.equals(e.id);throw new Error("not valid Id")}isValid(e){this.privKey&&this.privKey.public&&this.privKey.public.bytes&&n.isBuffer(this.pubKey.bytes)&&this.privKey.public.bytes.equals(this.pubKey.bytes)?e():e(new Error("Keys not match"))}}function c(e){if(e)return e.toString("base64")}(t=e.exports=u).create=function(e,t){"function"==typeof e&&(t=e,e={}),(e=e||{}).bits=e.bits||2048,a([t=>o.keys.generateKeyPair("RSA",e.bits,t),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n))})},t.createFromHexString=function(e){return new u(i.fromHexString(e))},t.createFromBytes=function(e){return new u(e)},t.createFromB58String=function(e){return new u(i.fromB58String(e))},t.createFromPubKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r;try{let i=e;if("string"==typeof i&&(i=n.from(e,"base64")),!n.isBuffer(i))throw new Error("Supplied key is neither a base64 string nor a buffer");r=o.keys.unmarshalPublicKey(i)}catch(e){return t(e)}r.hash((e,n)=>{if(e)return t(e);t(null,new u(n,null,r))})},t.createFromPrivKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r=e;try{if("string"==typeof r&&(r=n.from(e,"base64")),!n.isBuffer(r))throw new Error("Supplied key is neither a base64 string nor a buffer")}catch(e){return t(e)}a([e=>o.keys.unmarshalPrivateKey(r,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n,n.public))})},t.createFromJSON=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r,s,c,f;try{r=i.fromB58String(e.id),s=e.privKey&&n.from(e.privKey,"base64"),c=e.pubKey&&n.from(e.pubKey,"base64"),f=c&&o.keys.unmarshalPublicKey(c)}catch(e){return t(e)}s?a([e=>o.keys.unmarshalPrivateKey(s,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)}),(e,t,r)=>{f?f.hash((n,i)=>{r(n,e,t,i)}):r(null,e,t)}],(e,n,i,o)=>e?t(e):f&&!n.equals(o)?t(new Error("Public and private key do not match")):r&&!n.equals(r)?t(new Error("Id and private key do not match")):void t(null,new u(r,i,f))):t(null,new u(r,null,f))},t.isPeerId=function(e){return Boolean("object"==typeof e&&e._id&&e._idB58String)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(525),i=r(1117),o=r(1119);(t=e.exports).aes=i,t.hmac=n,t.keys=o,t.randomBytes=r(530),t.pbkdf2=r(1130)},function(e,t,r){"use strict";e.exports={SHA1:20,SHA256:32,SHA512:64}},function(e,t,r){"use strict";const n=r(1118),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(59);e.exports={createCipheriv:n.createCipheriv,createDecipheriv:n.createDecipheriv}},function(e,t,r){"use strict";(function(n){const i=r(10)(r(286)),o=r(16);t=e.exports;const s={rsa:r(1120),ed25519:r(1125),secp256k1:r(61)(i,r(530))};function a(e){return void 0!==s[e.toLowerCase()]}t.supportedKeys=s,t.keysPBM=i,t.keyStretcher=r(1127),t.generateEphemeralKeyPair=r(1128),t.generateKeyPair=((e,t,r)=>{let 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)=>{let 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){"use strict";const n=r(526),i=r(10),o=r(14),s=r(528),a=i(r(286)),u=r(16),c=r(3);class f{constructor(e){this._key=e}verify(e,t,r){h(r),s.hashAndVerify(this._key,t,e,r)}marshal(){return s.utils.jwkToPkix(this._key)}get bytes(){return a.PublicKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}encrypt(e){return this._key.encrypt(e,"RSAES-PKCS1-V1_5")}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(e),n(this.bytes,"sha2-256",e)}}class l{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return s.getRandomValues(new Uint8Array(16))}sign(e,t){h(t),s.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){s.decrypt(this._key,e,t)}marshal(){return s.utils.jwkToPkcs1(this._key)}get bytes(){return a.PrivateKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(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"),h(r),c(()=>{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 h(e){if("function"!=typeof e)throw new Error("callback is required")}e.exports={RsaPublicKey:f,RsaPrivateKey:l,unmarshalRsaPublicKey:function(e){const t=s.utils.pkixToJwk(e);return new f(t)},unmarshalRsaPrivateKey:function(e,t){const r=s.utils.pkcs1ToJwk(e);s.unmarshalPrivateKey(r,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},generateKeyPair:function(e,t){s.generateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},fromJwk:function(e,t){s.unmarshalPrivateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})}}},function(e,t,r){"use strict";(function(t){const n=r(38),i=r(39),o=r(527),s=r(1122),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,256)),shake256:a(u(n.shake_256,512)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(1123),dblSha2256:(e,r)=>{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(40),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;function o(e){if(!i)throw new Error("Please use a browser with webcrypto support");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(41),i=r(527).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(15),i=r(529),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())}),u=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()))}),c=n.define("RSAPublicKey",function(){this.seq().obj(this.key("algorithm").use(u),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=c.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 c.encode({algorithm:{algorithm:"rsa",none:null},subjectPublicKey:{data:f.encode({modulus:s(e.n),publicExponent:s(e.e)},"der")}},"der")}},function(e,t,r){"use strict";(function(t){const n=r(526),i=r(10),o=r(14),s=r(1126),a=i(r(286));class u{constructor(e){this._key=l(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 c{constructor(e,t){this._key=l(e,s.privateKeyLength),this._publicKey=l(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 u(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 l(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:u,Ed25519PrivateKey:c,unmarshalEd25519PrivateKey:function(e,t){try{e=l(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 c(r,n))},unmarshalEd25519PublicKey:function(e){return e=l(e,s.publicKeyLength),new u(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 c(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 c(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(60),i=r(3);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){"use strict";(function(t){const n=r(37),i=r(525),o={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,cipherKeySize:32}};e.exports=((e,r,s,a)=>{const u=o[e];if(!u)return a(new Error("unkown cipherType passed"));if(!r)return a(new Error("unkown hashType passed"));const c=u.keySize,f=u.ivSize,l=t.from("key expansion"),h=2*(f+c+20);i.create(r,s,(e,r)=>{if(e)return a(e);r.digest(l,(e,i)=>{if(e)return a(e);let o=[],s=0;n(()=>s{if(t)return e(t);let a=n.length;s+a>h&&(a=h-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=h/2,n=t.concat(o),i=n.slice(0,r),s=n.slice(r,h),u=e=>({iv:e.slice(0,f),cipherKey:e.slice(f,f+c),macKey:e.slice(f+c)});a(null,{k1:u(i),k2:u(s)})})})})})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(1129);e.exports=((e,t)=>{n.generateEphmeralKeyPair(e,t)})},function(e,t,r){"use strict";(function(e){const n=r(285)(),i=r(284),o=r(15).bignum,s=r(529),a=s.toBase64,u=s.toBn,c={"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 o=(o,s,a)=>{let u;"function"==typeof s&&(a=s,s=void 0),u=s?n.subtle.importKey("jwk",p(t,s),{name:"ECDH",namedCurve:t},!1,["deriveBits"]):Promise.resolve(r.privateKey);const f=Promise.all([n.subtle.importKey("jwk",h(t,o),{name:"ECDH",namedCurve:t},!1,[]),u]);i(f.then(e=>n.subtle.deriveBits({name:"ECDH",namedCurve:t,public:e[0]},e[1],c[t])).then(t=>e.from(t)),a)};return n.subtle.exportKey("jwk",r.publicKey).then(e=>({key:l(e),genSharedKey:o}))}),r)};const f={"P-256":32,"P-384":48,"P-521":66};function l(t){const r=f[t.crv];return e.concat([e.from([4]),u(t.x).toArrayLike(e,"be",r),u(t.y).toArrayLike(e,"be",r)],1+2*r)}function h(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}}function p(e,t){const r=h(e,t.public);return r.d=a(new o(t.private)),r}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(16),i={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};e.exports=function(e,t,r,o,s){const a=i[s];if(!a)throw new Error(`Hash '${s}' is unknown or not supported`);const u=n.pkcs5.pbkdf2(e,t,r,o,a);return n.util.encode64(u)}},function(e,t){e.exports=function e(t,r){if(t&&r)return e(t)(r);if("function"!=typeof t)throw new TypeError("need wrapper function");return Object.keys(t).forEach(function(e){n[e]=t[e]}),n;function n(){for(var e=new Array(arguments.length),r=0;r=26||"moz"===r&&n>=33),c=self.AudioContext||self.webkitAudioContext,f=self.document&&document.createElement("video"),l=f&&f.canPlayType&&"probably"===f.canPlayType('video/webm; codecs="vp8", vorbis'),h=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.msGetUserMedia||navigator.mozGetUserMedia;e.exports={prefix:r,browserVersion:n,support:!!i&&!!h,supportRTCPeerConnection:!!i,supportVp8:l,supportGetUserMedia:!!h,supportDataChannel:!!(i&&i.prototype&&i.prototype.createDataChannel),supportWebAudio:!(!c||!c.prototype.createMediaStreamSource),supportMediaStream:!(!a||!a.prototype.removeTrack),supportScreenSharing:!!u,AudioContext:c,PeerConnection:i,SessionDescription:s,IceCandidate:o,MediaStream:a,getUserMedia:h}},function(e,t,r){"use strict";const n=r(52);(t=e.exports).cleanUrlSIO=function(e){const t=e.toString().split("/"),r=e.protos()[1].name,i=e.protos()[2].name,o=e.stringTuples()[1][1];if("tcp"!==r||"ws"!==i&&"wss"!==i)throw new Error("invalid multiaddr: "+e.toString());return n.isName(e)?"ws"===i?"http://"+t[2]+(80===o?"":":"+o):"wss"===i?"https://"+t[2]+(443===o?"":":"+o):void 0:"http://"+t[2]+":"+t[4]},t.cleanMultiaddr=function(e){const t="/libp2p-webrtc-star";if(-1!==e.indexOf(t)){e=e.substring(t.length,e.length);let r=n(e);const i=r.stringTuples().filter(e=>421===e[0])[0];e=(r=(r=(r=r.decapsulate("ipfs")).encapsulate("/p2p-webrtc-star")).encapsulate(`/ipfs/${i[1]}`)).toString()}return e}},function(e,t,r){"use strict";const n=r(1)("libp2p:websocket-star"),i=r(52),o=r(11).EventEmitter,s=r(532),a=r(51),u=r(47).Connection,c=r(3),f=r(539),l=r(1151),h=f.cleanUrlSIO,p=r(78),d=r(62);e.exports=d(class{constructor(e){e=e||{},this.id=e.id,this.flag=e.allowJoinWithDisabledChallenge,this.discovery=new o,this.discovery.tag="websocketStar",this.discovery.start=(e=>{c(e)}),this.discovery.stop=(e=>{c(e)}),this.listeners_list={},this._peerDiscovered=this._peerDiscovered.bind(this)}lazySetId(e){e&&(this.id=e,this.canCrypto=!0)}dial(e,t,r){let n;"function"==typeof t&&(r=t,t={});try{n=h(e)}catch(e){return r(e)}const i=this.listeners_list[n];return i?i.dial(e,t,r):(r(new Error("No listener for this server")),new u)}createListener(e,t){"function"==typeof e&&(t=e,e={});const r=new l({id:this.id,handler:t,listeners:this.listeners_list,flag:this.flag});return r.on("peer",this._peerDiscovered),r}filter(e){return Array.isArray(e)||(e=[e]),e.filter(e=>p.WebSocketStar.matches(e))}_peerDiscovered(e){n("Peer Discovered:",e);const t=e.split("/ipfs/").pop(),r=s.createFromB58String(t),o=new a(r);o.multiaddrs.add(i(e)),this.discovery.emit("peer",o)}},{className:"WebsocketStar",symbolName:"@libp2p/js-libp2p-websocket-star/websocketstar"})},function(e,t,r){"use strict";const n=r(533),i=r(1137),o=r(1139);(t=e.exports).aes=i,t.hmac=n,t.keys=o,t.randomBytes=r(538),t.pbkdf2=r(1150)},function(e,t,r){"use strict";e.exports={SHA1:20,SHA256:32,SHA512:64}},function(e,t,r){"use strict";const n=r(1138),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(59);e.exports={createCipheriv:n.createCipheriv,createDecipheriv:n.createDecipheriv}},function(e,t,r){"use strict";(function(n){const i=r(10)(r(289)),o=r(16);t=e.exports;const s={rsa:r(1140),ed25519:r(1145),secp256k1:r(61)(i,r(538))};function a(e){return void 0!==s[e.toLowerCase()]}t.supportedKeys=s,t.keysPBM=i,t.keyStretcher=r(1147),t.generateEphemeralKeyPair=r(1148),t.generateKeyPair=((e,t,r)=>{let 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)=>{let 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){"use strict";const n=r(534),i=r(10),o=r(14),s=r(536),a=i(r(289)),u=r(16),c=r(3);class f{constructor(e){this._key=e}verify(e,t,r){h(r),s.hashAndVerify(this._key,t,e,r)}marshal(){return s.utils.jwkToPkix(this._key)}get bytes(){return a.PublicKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}encrypt(e){return this._key.encrypt(e,"RSAES-PKCS1-V1_5")}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(e),n(this.bytes,"sha2-256",e)}}class l{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return s.getRandomValues(new Uint8Array(16))}sign(e,t){h(t),s.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){s.decrypt(this._key,e,t)}marshal(){return s.utils.jwkToPkcs1(this._key)}get bytes(){return a.PrivateKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(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"),h(r),c(()=>{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 h(e){if("function"!=typeof e)throw new Error("callback is required")}e.exports={RsaPublicKey:f,RsaPrivateKey:l,unmarshalRsaPublicKey:function(e){const t=s.utils.pkixToJwk(e);return new f(t)},unmarshalRsaPrivateKey:function(e,t){const r=s.utils.pkcs1ToJwk(e);s.unmarshalPrivateKey(r,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},generateKeyPair:function(e,t){s.generateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},fromJwk:function(e,t){s.unmarshalPrivateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})}}},function(e,t,r){"use strict";(function(t){const n=r(38),i=r(39),o=r(535),s=r(1142),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,256)),shake256:a(u(n.shake_256,512)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(1143),dblSha2256:(e,r)=>{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(40),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;function o(e){if(!i)throw new Error("Please use a browser with webcrypto support");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(41),i=r(535).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(15),i=r(537),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())}),u=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()))}),c=n.define("RSAPublicKey",function(){this.seq().obj(this.key("algorithm").use(u),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=c.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 c.encode({algorithm:{algorithm:"rsa",none:null},subjectPublicKey:{data:f.encode({modulus:s(e.n),publicExponent:s(e.e)},"der")}},"der")}},function(e,t,r){"use strict";(function(t){const n=r(534),i=r(10),o=r(14),s=r(1146),a=i(r(289));class u{constructor(e){this._key=l(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 c{constructor(e,t){this._key=l(e,s.privateKeyLength),this._publicKey=l(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 u(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 l(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:u,Ed25519PrivateKey:c,unmarshalEd25519PrivateKey:function(e,t){try{e=l(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 c(r,n))},unmarshalEd25519PublicKey:function(e){return e=l(e,s.publicKeyLength),new u(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 c(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 c(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(60),i=r(3);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){"use strict";(function(t){const n=r(37),i=r(533),o={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,cipherKeySize:32}};e.exports=((e,r,s,a)=>{const u=o[e];if(!u)return a(new Error("unkown cipherType passed"));if(!r)return a(new Error("unkown hashType passed"));const c=u.keySize,f=u.ivSize,l=t.from("key expansion"),h=2*(f+c+20);i.create(r,s,(e,r)=>{if(e)return a(e);r.digest(l,(e,i)=>{if(e)return a(e);let o=[],s=0;n(()=>s{if(t)return e(t);let a=n.length;s+a>h&&(a=h-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=h/2,n=t.concat(o),i=n.slice(0,r),s=n.slice(r,h),u=e=>({iv:e.slice(0,f),cipherKey:e.slice(f,f+c),macKey:e.slice(f+c)});a(null,{k1:u(i),k2:u(s)})})})})})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(1149);e.exports=((e,t)=>{n.generateEphmeralKeyPair(e,t)})},function(e,t,r){"use strict";(function(e){const n=r(288)(),i=r(287),o=r(15).bignum,s=r(537),a=s.toBase64,u=s.toBn,c={"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 o=(o,s,a)=>{let u;"function"==typeof s&&(a=s,s=void 0),u=s?n.subtle.importKey("jwk",p(t,s),{name:"ECDH",namedCurve:t},!1,["deriveBits"]):Promise.resolve(r.privateKey);const f=Promise.all([n.subtle.importKey("jwk",h(t,o),{name:"ECDH",namedCurve:t},!1,[]),u]);i(f.then(e=>n.subtle.deriveBits({name:"ECDH",namedCurve:t,public:e[0]},e[1],c[t])).then(t=>e.from(t)),a)};return n.subtle.exportKey("jwk",r.publicKey).then(e=>({key:l(e),genSharedKey:o}))}),r)};const f={"P-256":32,"P-384":48,"P-521":66};function l(t){const r=f[t.crv];return e.concat([e.from([4]),u(t.x).toArrayLike(e,"be",r),u(t.y).toArrayLike(e,"be",r)],1+2*r)}function h(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}}function p(e,t){const r=h(e,t.public);return r.d=a(new o(t.private)),r}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(16),i={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};e.exports=function(e,t,r,o,s){const a=i[s];if(!a)throw new Error(`Hash '${s}' is unknown or not supported`);const u=n.pkcs5.pbkdf2(e,t,r,o,a);return n.util.encode64(u)}},function(e,t,r){"use strict";(function(t){const n=r(1)("libp2p:websocket-star:listener"),i=r(52),o=r(513),s=r(1152),a=r(540),u=r(49),c=r(11).EventEmitter,f=r(47).Connection,l=r(30),h=r(3),p=r(539),d=p.cleanUrlSIO,y=r(111),g=l(()=>{}),m={transports:["websocket"],"force new connection":!0};e.exports=class extends c{constructor(e){super(),this.id=e.id,this.log=n.bind(n,"listener#offline"),this.canCrypto=Boolean(e.id),this._handler=e.handler||g,this.listeners_list=e.listeners||{},this.flag=e.flag}_up(e){if(e=e?l(e):g,this.io)return e();this.log=n.bind(n,"listener#"+this.server),this.log("dialing to signalling server");const t=this.io=o.connect(this.server,m);s(t,{codec:"buffer"}),t.once("error",e),t.once("connect_error",e),t.once("connect",e);const r=new p.Protocol(this.log);r.addRequest("ws-peer",["multiaddr"],(e,t)=>this.emit("peer",t)),r.addRequest("ss-incomming",["string","multiaddr","function"],this._incommingDial.bind(this)),r.handleSocket(t)}_down(){this.io&&(this.io.disconnect(),this.emit("close"),delete this.io)}_cryptoChallenge(e){if(!this.io)return e(new Error("Not connected"));const r=this.canCrypto?y.keys.marshalPublicKey(this.id.pubKey).toString("hex"):"",n=this.ma.toString();this.io.emit("ss-join",n,r,(r,n)=>{if(r)return e(r);if(n){if(!this.canCrypto)return this._down(),e(new Error("Can't sign cryptoChallenge: No id provided"));this.log("performing cryptoChallenge"),this.id.privKey.sign(t.from(n),(t,r)=>{if(t)return e(t);this.signature=r.toString("hex"),this._join(e)})}else{if(!this.flag)return this._down(),e(new Error('Tried to listen on a server with crypto challenge disabled!\n This is prohibited by default and can lead to security issues!\n Please set "allowJoinWithDisabledChallenge" to true in the constructor options (but only if you know what you are doing)!'));this.signature="_",e()}})}_crypto(e){if(e=e?l(e):g,this.log("joining"),!this.io)return e(new Error("Not connected"));this.signature?this._join((t,r)=>{if(r)return this.cryptoChallenge(e);e(t)}):this._cryptoChallenge(e)}_join(e){this.io.emit("ss-join",this.ma.toString(),this.signature,e)}_incommingDial(e,t,r,n){this.log("dial#"+t+" incomming from",r);const o=i(r),s=this.io.createSource(t+".dialer"),a=this.io.createSink(t+".listener");n();const u=new f({sink:a,source:s},{getObservedAddrs:e=>e(null,[o])});this.emit("connection",u),this._handler(u)}listen(e,t){this.ma=e,this.server=d(e),this.listeners_list[this.server]=this,t=t?l(t):g,u([e=>this._up(e),e=>this._crypto(e)],e=>{if(e)return this.log("error",e),e instanceof Error||(e=new Error(e)),this._down(),this.emit("error",e),this.emit("close"),t(e);this.log("success"),this.io.on("reconnect",()=>{this.signature=null,this._crypto(e=>{e?(this.log("reconnect error",e),this.emit("error",e)):this.log("reconnected")})}),this.emit("listening"),t()})}getAddrs(e){h(()=>e(null,this.ma?[this.ma]:[]))}close(e){e=e?l(e):g,this._down(),e()}dial(e,t,r){"function"==typeof t&&(r=t,t={});const o=i(e),s=new f(null),u=a(),c=this.log.bind(n,"dial#"+u);r=r?l(r):g;let h=this.io;if(!h)return r(new Error("Not listening"));const p=h.createSink(u+".dialer");return c("dialing",e.toString()),h.emit("ss-dial",this.ma.toString(),e.toString(),u,e=>{if(e)return r(e instanceof Error?e:new Error(e));c(e?"error: "+e.toString():"success");const t=h.createSource(u+".listener");s.setInnerConn({sink:p,source:t},{getObservedAddrs:e=>e(null,[o])}),r(null,s)}),s}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(1153),i=r(540),o=r(8),s=(e,t)=>"socket.io-pull-stream."+e+(t?"."+t:""),a=r(1)("socket.io-pull-stream");function u(e,t){if(null==t)return t;try{return e(t)}catch(e){return console.error("Codec Error"),console.error(e),!1}}const c={hex:{encode:e=>e.toString("hex"),decode:e=>t.from(e,"hex")},plain:{encode:e=>e,decode:e=>e},buffer:{encode:e=>t.from(e),decode:e=>t.from(e)}};function f(e){if(e||(e="plain"),"object"==typeof e)return e;const t=c[e];if(!t)throw new Error("Invalid codec "+e);return t}function l(e,t,r){const i=n(),o=e.sioplog.bind(e.sioplog,"source("+t+")"),a=f(r.codec).decode;function c(){e.removeAllListeners(s("error",t)),e.removeAllListeners(s("queue",t))}return o("create source"),e.emit(s("accept",t)),e.on(s("error",t),e=>{o(!0===e?"finish":"error"),c(),i.append({end:e})}),e.on(s("queue",t),e=>{o("queue data"),i.append({data:u(a,e)})}),e.once("disconnect",()=>{c(),i.append({end:!0})}),function(e,t){if(o("reading"),e)return t(e);i.get((e,r)=>e?t(e):r.end?(i.error(r.end),t(r.end)):t(null,r.data))}}function h(e,t,r){const i=n(),o=e.sioplog.bind(e.sioplog," sink("+t+")"),a=f(r.codec).encode;let c;function l(e){i.append({err:e}),c=e}return o("create sink"),e.once(s("accept",t),()=>{o("start transmission"),function r(){i.get((n,c)=>{let{data:f,err:l}=c||{};if(n&&(l=n),o("send",l&&!0===l?"finish":l?"error":f?"data":""),l&&!n&&i.error(l),l)return e.emit(s("error",t),l);f&&e.emit(s("queue",t),u(a,f)),r()})}()}),e.once("disconnect",()=>l(!0)),function(e){e(null,function t(r,n){return r?l(r):c?e(c,t):(i.append({data:n}),void e(null,t))})}}e.exports=function(e,t){e.createSink||(e.sioplog=e.id?a.bind(a,"["+e.id+"]"):a,e.createSink=((r,n)=>{r||(r=i());const o=h(e,r,t||n);return o.id=r,o}),e.createSource=((r,n)=>{const i=l(e,r,t||n);return i.id=r,i}),e.createProxy=((t,r,n)=>{o(e.createSource(t,n),r.createSink(t,n))}))}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(11).EventEmitter;e.exports=function(){const e=new n;let t,r=[];function i(){e.removeAllListeners("err"),e.removeAllListeners("data")}return{append:n=>{if(t)return t;r.push(n),e.emit("data")},prepend:e=>{if(t)return t;r.unshift(e)},error:r=>{t=r,e.emit("err",r)},get:n=>(i(),t?n(t):r.length?n(null,r.shift()):(e.once("err",e=>{i(),n(e)}),void e.once("data",()=>(i(),n(null,r.shift()))))),height:()=>r.length}}},function(e,t,r){var n,i,o=r(366),s=r(367),a=0,u=0;e.exports=function(e,t,r){var c=t&&r||0,f=t||[],l=(e=e||{}).node||n,h=void 0!==e.clockseq?e.clockseq:i;if(null==l||null==h){var p=o();null==l&&(l=n=[1|p[0],p[1],p[2],p[3],p[4],p[5]]),null==h&&(h=i=16383&(p[6]<<8|p[7]))}var d=void 0!==e.msecs?e.msecs:(new Date).getTime(),y=void 0!==e.nsecs?e.nsecs:u+1,g=d-a+(y-u)/1e4;if(g<0&&void 0===e.clockseq&&(h=h+1&16383),(g<0||d>a)&&void 0===e.nsecs&&(y=0),y>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");a=d,u=y,i=h;var m=(1e4*(268435455&(d+=122192928e5))+y)%4294967296;f[c++]=m>>>24&255,f[c++]=m>>>16&255,f[c++]=m>>>8&255,f[c++]=255&m;var b=d/4294967296*1e4&268435455;f[c++]=b>>>8&255,f[c++]=255&b,f[c++]=b>>>24&15|16,f[c++]=b>>>16&255,f[c++]=h>>>8|128,f[c++]=255&h;for(var v=0;v<6;++v)f[c+v]=l[v];return t||s(f)}},function(e,t,r){"use strict";const n=r(140),i=r(1156),o=r(541),s=r(1160),a=r(542);function u(e,t){const r=n(e);r.on("end",()=>r.destroy());const o=new i({halfOpen:!0,initiator:!t});return a(r,o,r),new s(e,o)}(t=e.exports=u).multicodec=o,t.dialer=(e=>u(e,!1)),t.listener=(e=>u(e,!0))},function(e,t,r){"use strict";(function(t){const n=r(22),i=r(20),o=r(1157),s=r(1),a=r(1159),u=t.from([0]),c=t.alloc(0);let f=t.alloc(10240),l=0;e.exports=class extends n.Duplex{constructor(e,r){super(),"function"==typeof e&&(r=e,e={}),e||(e={}),r&&this.on("stream",r),this.destroyed=!1,this.limit=e.limit||0,null==e.initiator&&(e.initiator=!0),this.initiator=e.initiator,this._corked=0,this._options=e,this._binaryName=Boolean(e.binaryName),this._local=[],this._remote=[],this._list=this._local,this._receiving=null,this._chunked=!1,this._state=0,this._type=0,this._channel=0,this._missing=0,this._message=null,this.log=s("mplex:main:"+Math.floor(1e5*Math.random())),this.log("construction");let n=100;this.limit&&(n=i.encodingLength(this.limit)),this._buf=t.alloc(n),this._ptr=0,this._awaitChannelDrains=0,this._onwritedrain=null,this._ondrain=[],this._finished=!1,this.once("finish",this._clear),this._nextId=this.initiator?0:1}_nextStreamId(){let e=this._nextId;return this._nextId+=2,e}createStream(e,t){if(this.destroyed)throw new Error("Multiplexer is destroyed");const r=this._nextStreamId();let n=this._name(e||r.toString());const i=Object.assign(this._options,t);this.log("createStream: %s",r,n.toString(),i);const o=new a(n,this,i);return this._addChannel(o,r,this._local)}receiveStream(e,t){if(this.destroyed)throw new Error("Multiplexer is destroyed");if(void 0===e||null===e)throw new Error("Name is needed when receiving a stream");const r=this._name(e);this.log("receiveStream: "+r.toString());const n=new a(r,this,Object.assign(this._options,t));if(this._receiving||(this._receiving={}),this._receiving[n.name])throw new Error("You are already receiving this stream");return this._receiving[n.name]=n,n}createSharedStream(e,t){return this.log("createSharedStream"),o(this.createStream(e,Object.assign(t,{lazy:!0})),this.receiveStream(e,t))}_name(e){return this._binaryName?t.isBuffer(e)?e:t.from(e):e.toString()}_send(e,r){const n=r?r.length:0,o=l;let s=!0;return this.log("_send",e,n),i.encode(e,f,l),l+=i.encode.bytes,i.encode(n,f,l),l+=i.encode.bytes,s=this.push(f.slice(o,l)),f.length-l<100&&(f=t.alloc(10240),l=0),r&&(s=this.push(r)),s}_addChannel(e,t,r){return this.log("_addChannel",t),r[t]=e,e.on("finalize",()=>{this.log("_remove channel",t),r[t]=null}),e.open(t,r===this._local),e}_writeVarint(e,t){for(;t>3,this._list=1&this._type?this._local:this._remote;const t=this._list.length>this._channel&&this._list[this._channel]&&this._list[this._channel].chunked;this._chunked=Boolean(1===this._type||2===this._type)&&t}else if(this._missing=i.decode(this._buf),this.limit&&this._missing>this.limit)return this._lengthError(e);return this._state++,this._ptr=0,t+1}}return e.length}_lengthError(e){return this.destroy(new Error("Incoming message is too big")),e.length}_writeMessage(e,r){const n=e.length-r,i=this._missing;if(!this._message){if(i<=n)return this._missing=0,this._push(e.slice(r,r+i)),r+i;if(this._chunked)return this._missing-=n,this._push(e.slice(r,e.length)),e.length;this._message=t.alloc(i)}return e.copy(this._message,this._ptr,r,r+i),i<=n?(this._missing=0,this._push(this._message),r+i):(this._missing-=n,this._ptr+=n,e.length)}_push(e){if(this.log("_push",e.length),this._missing||(this._ptr=0,this._state=0,this._message=null),0===this._type){if(this.log("open",this._channel),this.destroyed||this._finished)return;let t,r;return t=this._binaryName?e:e.toString()||this._channel.toString(),this.log("open name",t),void(this._receiving&&this._receiving[t]?(r=this._receiving[t],delete this._receiving[t],this._addChannel(r,this._channel,this._list)):(r=new a(t,this,this._options),this.emit("stream",this._addChannel(r,this._channel,this._list),r.name)))}const t=this._list[this._channel];if(t)switch(this._type){case 5:case 6:{const r=new Error(e.toString()||"Channel destroyed");return void t._destroy(r,!1)}case 3:case 4:return void t.push(null);case 1:case 2:t.push(e)||(this._awaitChannelDrains++,t._awaitDrain++)}}_onchanneldrain(e){if(this._awaitChannelDrains-=e,this._awaitChannelDrains)return;const t=this._onwritedrain;this._onwritedrain=null,t&&t()}_write(e,t,r){if(this.log("_write",e.length),this._finished)return void r();if(this._corked)return void this._onuncork(this._write.bind(this,e,t,r));if(e===u)return void this._finish(r);let n=0;for(;n{!1===this._writableState.prefinished&&(this._writableState.prefinished=!0),this.emit("prefinish"),this._onuncork(e)})}cork(){1==++this._corked&&this.emit("cork")}uncork(){this._corked&&0==--this._corked&&this.emit("uncork")}end(e,t,r){return this.log("end"),"function"==typeof e&&(r=e,e=void 0),"function"==typeof t&&(r=t,t=void 0),e&&this.write(e),this._writableState.ending||this.write(u),n.Writable.prototype.end.call(this,r)}_onuncork(e){this._corked?this.once("uncork",e):e()}_read(){for(;this._ondrain.length;)this._ondrain.shift()()}_clear(){if(this.log("_clear"),this._finished)return;this._finished=!0;const e=this._local.concat(this._remote);this._local=[],this._remote=[],e.forEach(function(e){e&&e._destroy(null,!1)}),this.push(null)}finalize(){this._clear()}destroy(e){if(this.log("destroy"),this.destroyed)this.log("already destroyed");else{var t=this._local.concat(this._remote);this.destroyed=!0,e&&this.emit("error",e),this.emit("close"),t.forEach(function(t){t&&t.emit("error",e||new Error("underlying socket has been closed"))}),this._clear()}}}}).call(this,r(0).Buffer)},function(e,t,r){(function(t,n){var i=r(22),o=r(193),s=r(5),a=r(1158),u=t.from&&t.from!==Uint8Array.from?t.from([0]):new t([0]),c=function(e,t){e._corked?e.once("uncork",t):t()},f=function(e,t){return function(r){r?function(e,t){e._autoDestroy&&e.destroy(t)}(e,"premature close"===r.message?null:r):t&&!e._ended&&e.end()}},l=function(e){return new i.Readable({objectMode:!0,highWaterMark:16}).wrap(e)},h=function(e,t,r){if(!(this instanceof h))return new h(e,t,r);i.Duplex.call(this,r),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!r||!1!==r.autoDestroy,this._forwardDestroy=!r||!1!==r.destroy,this._forwardEnd=!r||!1!==r.end,this._corked=1,this._ondrain=null,this._drained=!1,this._forwarding=!1,this._unwrite=null,this._unread=null,this._ended=!1,this.destroyed=!1,e&&this.setWritable(e),t&&this.setReadable(t)};s(h,i.Duplex),h.obj=function(e,t,r){return r||(r={}),r.objectMode=!0,r.highWaterMark=16,new h(e,t,r)},h.prototype.cork=function(){1==++this._corked&&this.emit("cork")},h.prototype.uncork=function(){this._corked&&0==--this._corked&&this.emit("uncork")},h.prototype.setWritable=function(e){if(this._unwrite&&this._unwrite(),this.destroyed)e&&e.destroy&&e.destroy();else if(null!==e&&!1!==e){var t=this,r=o(e,{writable:!0,readable:!1},f(this,this._forwardEnd)),i=function(){var e=t._ondrain;t._ondrain=null,e&&e()};this._unwrite&&n.nextTick(i),this._writable=e,this._writable.on("drain",i),this._unwrite=function(){t._writable.removeListener("drain",i),r()},this.uncork()}else this.end()},h.prototype.setReadable=function(e){if(this._unread&&this._unread(),this.destroyed)e&&e.destroy&&e.destroy();else{if(null===e||!1===e)return this.push(null),void this.resume();var t=this,r=o(e,{writable:!1,readable:!0},f(this)),n=function(){t._forward()},i=function(){t.push(null)};this._drained=!0,this._readable=e,this._readable2=e._readableState?e:l(e),this._readable2.on("readable",n),this._readable2.on("end",i),this._unread=function(){t._readable2.removeListener("readable",n),t._readable2.removeListener("end",i),r()},this._forward()}},h.prototype._read=function(){this._drained=!0,this._forward()},h.prototype._forward=function(){if(!this._forwarding&&this._readable2&&this._drained){var e;for(this._forwarding=!0;this._drained&&null!==(e=a(this._readable2));)this.destroyed||(this._drained=this.push(e));this._forwarding=!1}},h.prototype.destroy=function(e){if(!this.destroyed){this.destroyed=!0;var t=this;n.nextTick(function(){t._destroy(e)})}},h.prototype._destroy=function(e){if(e){var t=this._ondrain;this._ondrain=null,t?t(e):this.emit("error",e)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")},h.prototype._write=function(e,t,r){return this.destroyed?r():this._corked?c(this,this._write.bind(this,e,t,r)):e===u?this._finish(r):this._writable?void(!1===this._writable.write(e)?this._ondrain=r:r()):r()},h.prototype._finish=function(e){var t=this;this.emit("preend"),c(this,function(){!function(e,t){e?e._writableState&&e._writableState.finished?t():e._writableState?e.end(t):(e.end(),t()):t()}(t._forwardEnd&&t._writable,function(){!1===t._writableState.prefinished&&(t._writableState.prefinished=!0),t.emit("prefinish"),c(t,e)})})},h.prototype.end=function(e,t,r){return"function"==typeof e?this.end(null,null,e):"function"==typeof t?this.end(e,null,t):(this._ended=!0,e&&this.write(e),this._writableState.ending||this.write(u),i.Writable.prototype.end.call(this,r))},e.exports=h}).call(this,r(0).Buffer,r(7))},function(e,t){e.exports=function(e){var t=e._readableState;return t?t.objectMode?e.read():e.read(function(e){return e.buffer.length?e.buffer.head?e.buffer.head.data.length:e.buffer[0].length:e.length}(t)):null}},function(e,t,r){"use strict";(function(t){const n=r(22),i=r(1);e.exports=class extends n.Duplex{constructor(e,t,r){const n=Boolean(r.halfOpen);super({allowHalfOpen:n}),this.name=e,this.log=i("mplex:channel:"+this.name.toString()),this.channel=0,this.initiator=!1,this.chunked=Boolean(r.chunked),this.halfOpen=n,this.destroyed=!1,this.finalized=!1,this._multiplex=t,this._dataHeader=0,this._opened=!1,this._awaitDrain=0,this._lazy=Boolean(r.lazy);let o=!1,s=!1;this.log("open, halfOpen: "+this.halfOpen),this.once("end",()=>{this.log("end"),this._read(),this.destroyed||(s=!0,o?this._finalize():this.halfOpen||this.end())}),this.once("finish",function e(){if(!this.destroyed){if(!this._opened)return this.once("open",e);this._lazy&&this.initiator&&this._open(),this._multiplex._send(this.channel<<3|(this.initiator?4:3),null),o=!0,s&&this._finalize()}})}destroy(e){this._destroy(e,!0)}_destroy(e,r){if(this.log("_destroy:"+(r?"local":"remote")),this.destroyed)return void this.log("already destroyed");this.destroyed=!0;const n=this.listenerCount("error")>0;if(!e||r&&!n||this.emit("error",e),this.emit("close"),r&&this._opened){this._lazy&&this.initiator&&this._open();const r=e?t.from(e.message):null;try{this._multiplex._send(this.channel<<3|(this.initiator?6:5),r)}catch(e){}}this._finalize()}_finalize(){this.finalized||(this.finalized=!0,this.emit("finalize"))}_write(e,t,r){this.log("write: ",e.length),this._opened?this.destroyed?r():(this._lazy&&this.initiator&&this._open(),this._multiplex._send(this._dataHeader,e)?r():this._multiplex._ondrain.push(r)):this.once("open",()=>{this._write(e,t,r)})}_read(){if(this._awaitDrain){const e=this._awaitDrain;this._awaitDrain=0,this._multiplex._onchanneldrain(e)}}_open(){let e=null;t.isBuffer(this.name)?e=this.name:this.name!==this.channel.toString()&&(e=t.from(this.name)),this._lazy=!1,this._multiplex._send(this.channel<<3|0,e)}open(e,t){this.log("open: "+e),this.channel=e,this.initiator=t,this._dataHeader=e<<3|(t?2:1),this._opened=!0,!this._lazy&&this.initiator&&this._open(),this.emit("open")}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(11).EventEmitter,i=r(47).Connection,o=r(192),s=r(8),a=r(1161),u=r(3),c=r(541);function f(){}function l(e){return{source:s(e.source,a(e=>{if("Channel destroyed"!==e.message)return!1})),sink:e.sink}}e.exports=class extends n{constructor(e,t){super(),this.multiplex=t,this.conn=e,this.multicodec=c,t.on("close",()=>this.emit("close")),t.on("error",e=>this.emit("error",e)),t.on("stream",(e,t)=>{const r=new i(l(o.duplex(e)),this.conn);this.emit("stream",r)})}newStream(e){let t;e=e||f;try{t=this.multiplex.createStream()}catch(t){return u(()=>e(t))}const r=new i(l(o.duplex(t)),this.conn);return u(()=>e(null,r)),r}end(e){e=e||f,this.multiplex.once("close",e),this.multiplex.destroy()}}},function(e,t){e.exports=function(e){var t;return e=e||function(){},function(r){return function(n,i){r(n,function(r,n){if(t)return i(!0);if(r&&!0!==r){var o=e(r);return!1===o?i(r):o&&!0!==o?(t=!0,i(null,o)):i(!0)}i(r,n)})}}}},function(e,t){},function(e,t,r){"use strict";const n=r(8),i=r(47).Connection,o=r(17),s=r(51),a=r(1),u=r(30),c=a("libp2p:secio");c.error=a("libp2p:secio:error");const f=r(1164),l=r(1186);e.exports={tag:"/secio/1.0.0",encrypt(e,t,r,a){o(e,"no local private key provided"),o(t,"no connection for the handshake provided"),"function"==typeof r&&(a=r,r=void 0),a=u(a||function(e){e&&c.error(e)});const h=new l(e,r,3e5,a);const p=new i(void 0,t);return n(t,f(h,function(e){if(e)return a(e);t.getPeerInfo((e,r)=>{p.setInnerConn(new i(h.secure,t)),e&&p.setPeerInfo(new s(h.id.remote)),a()})}),t),p}}},function(e,t,r){"use strict";const n=r(49),i=r(1165),o=r(1183),s=r(1184);e.exports=function(e,t){return n([t=>i(e,t),t=>o(e,t),t=>s(e,t)],r=>{e.cleanSecrets(),r&&(!0===r&&(r=new Error("Stream ended prematurely")),e.shake.abort(r)),t(r)}),e.stream}},function(e,t,r){"use strict";const n=r(1),i=r(4),o=r(290),s=r(296),a=n("libp2p:secio");a.error=n("libp2p:secio:error"),e.exports=function(e,t){a("1. propose - start"),a("1. propose - writing proposal"),o.write(e,s.createProposal(e)),i([t=>o.read(e.shake,t),(t,r)=>{a("1. propose - reading proposal",t),s.identify(e,t,r)},t=>s.selectProtocols(e,t)],e=>{if(e)return t(e);a("1. propose - finish"),t()})}},function(e,t,r){"use strict";(function(t){const n=r(38),i=r(39),o=r(543),s=r(1167),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,256)),shake256:a(u(n.shake_256,512)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(1168),dblSha2256:(e,r)=>{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(40),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;function o(e){if(!i)throw new Error("Please use a browser with webcrypto support");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(41),i=r(543).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";e.exports={SHA1:20,SHA256:32,SHA512:64}},function(e,t,r){"use strict";const n=r(1171),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(59);e.exports={createCipheriv:n.createCipheriv,createDecipheriv:n.createDecipheriv}},function(e,t,r){"use strict";(function(n){const i=r(10)(r(295)),o=r(16);t=e.exports;const s={rsa:r(1173),ed25519:r(1175),secp256k1:r(61)(i,r(547))};function a(e){return void 0!==s[e.toLowerCase()]}t.supportedKeys=s,t.keysPBM=i,t.keyStretcher=r(1177),t.generateEphemeralKeyPair=r(1178),t.generateKeyPair=((e,t,r)=>{let 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)=>{let 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){"use strict";const n=r(291),i=r(10),o=r(14),s=r(545),a=i(r(295)),u=r(16),c=r(3);class f{constructor(e){this._key=e}verify(e,t,r){h(r),s.hashAndVerify(this._key,t,e,r)}marshal(){return s.utils.jwkToPkix(this._key)}get bytes(){return a.PublicKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}encrypt(e){return this._key.encrypt(e,"RSAES-PKCS1-V1_5")}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(e),n(this.bytes,"sha2-256",e)}}class l{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return s.getRandomValues(new Uint8Array(16))}sign(e,t){h(t),s.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){s.decrypt(this._key,e,t)}marshal(){return s.utils.jwkToPkcs1(this._key)}get bytes(){return a.PrivateKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(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"),h(r),c(()=>{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 h(e){if("function"!=typeof e)throw new Error("callback is required")}e.exports={RsaPublicKey:f,RsaPrivateKey:l,unmarshalRsaPublicKey:function(e){const t=s.utils.pkixToJwk(e);return new f(t)},unmarshalRsaPrivateKey:function(e,t){const r=s.utils.pkcs1ToJwk(e);s.unmarshalPrivateKey(r,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},generateKeyPair:function(e,t){s.generateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},fromJwk:function(e,t){s.unmarshalPrivateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})}}},function(e,t,r){"use strict";const n=r(15),i=r(546),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())}),u=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()))}),c=n.define("RSAPublicKey",function(){this.seq().obj(this.key("algorithm").use(u),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=c.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 c.encode({algorithm:{algorithm:"rsa",none:null},subjectPublicKey:{data:f.encode({modulus:s(e.n),publicExponent:s(e.e)},"der")}},"der")}},function(e,t,r){"use strict";(function(t){const n=r(291),i=r(10),o=r(14),s=r(1176),a=i(r(295));class u{constructor(e){this._key=l(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 c{constructor(e,t){this._key=l(e,s.privateKeyLength),this._publicKey=l(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 u(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 l(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:u,Ed25519PrivateKey:c,unmarshalEd25519PrivateKey:function(e,t){try{e=l(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 c(r,n))},unmarshalEd25519PublicKey:function(e){return e=l(e,s.publicKeyLength),new u(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 c(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 c(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(60),i=r(3);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){"use strict";(function(t){const n=r(37),i=r(544),o={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,cipherKeySize:32}};e.exports=((e,r,s,a)=>{const u=o[e];if(!u)return a(new Error("unkown cipherType passed"));if(!r)return a(new Error("unkown hashType passed"));const c=u.keySize,f=u.ivSize,l=t.from("key expansion"),h=2*(f+c+20);i.create(r,s,(e,r)=>{if(e)return a(e);r.digest(l,(e,i)=>{if(e)return a(e);let o=[],s=0;n(()=>s{if(t)return e(t);let a=n.length;s+a>h&&(a=h-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=h/2,n=t.concat(o),i=n.slice(0,r),s=n.slice(r,h),u=e=>({iv:e.slice(0,f),cipherKey:e.slice(f,f+c),macKey:e.slice(f+c)});a(null,{k1:u(i),k2:u(s)})})})})})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(1179);e.exports=((e,t)=>{n.generateEphmeralKeyPair(e,t)})},function(e,t,r){"use strict";(function(e){const n=r(294)(),i=r(293),o=r(15).bignum,s=r(546),a=s.toBase64,u=s.toBn,c={"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 o=(o,s,a)=>{let u;"function"==typeof s&&(a=s,s=void 0),u=s?n.subtle.importKey("jwk",p(t,s),{name:"ECDH",namedCurve:t},!1,["deriveBits"]):Promise.resolve(r.privateKey);const f=Promise.all([n.subtle.importKey("jwk",h(t,o),{name:"ECDH",namedCurve:t},!1,[]),u]);i(f.then(e=>n.subtle.deriveBits({name:"ECDH",namedCurve:t,public:e[0]},e[1],c[t])).then(t=>e.from(t)),a)};return n.subtle.exportKey("jwk",r.publicKey).then(e=>({key:l(e),genSharedKey:o}))}),r)};const f={"P-256":32,"P-384":48,"P-521":66};function l(t){const r=f[t.crv];return e.concat([e.from([4]),u(t.x).toArrayLike(e,"be",r),u(t.y).toArrayLike(e,"be",r)],1+2*r)}function h(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}}function p(e,t){const r=h(e,t.public);return r.d=a(new o(t.private)),r}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(16),i={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};e.exports=function(e,t,r,o,s){const a=i[s];if(!a)throw new Error(`Hash '${s}' is unknown or not supported`);const u=n.pkcs5.pbkdf2(e,t,r,o,a);return n.util.encode64(u)}},function(e,t,r){"use strict";(function(n){const i=r(12),o=r(292),s=r(17),a=r(4);class u{constructor(e,t,r){s(n.isBuffer(e),"invalid id provided"),t&&r&&s(t.public.bytes.equals(r.bytes),"inconsistent arguments"),this._id=e,this._idB58String=i.toB58String(this.id),this._privKey=t,this._pubKey=r}get id(){return this._id}set id(e){throw new Error("Id is immutable")}get privKey(){return this._privKey}set privKey(e){this._privKey=e}get pubKey(){return this._pubKey?this._pubKey:this._privKey?this._privKey.public:void 0}set pubKey(e){this._pubKey=e}marshalPubKey(){if(this.pubKey)return o.keys.marshalPublicKey(this.pubKey)}marshalPrivKey(){if(this.privKey)return o.keys.marshalPrivateKey(this.privKey)}toPrint(){return this.toJSON()}toJSON(){return{id:this.toB58String(),privKey:c(this.marshalPrivKey()),pubKey:c(this.marshalPubKey())}}toHexString(){return i.toHexString(this.id)}toBytes(){return this.id}toB58String(){return this._idB58String}isEqual(e){if(n.isBuffer(e))return this.id.equals(e);if(e.id)return this.id.equals(e.id);throw new Error("not valid Id")}isValid(e){this.privKey&&this.privKey.public&&this.privKey.public.bytes&&n.isBuffer(this.pubKey.bytes)&&this.privKey.public.bytes.equals(this.pubKey.bytes)?e():e(new Error("Keys not match"))}}function c(e){if(e)return e.toString("base64")}(t=e.exports=u).create=function(e,t){"function"==typeof e&&(t=e,e={}),(e=e||{}).bits=e.bits||2048,a([t=>o.keys.generateKeyPair("RSA",e.bits,t),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n))})},t.createFromHexString=function(e){return new u(i.fromHexString(e))},t.createFromBytes=function(e){return new u(e)},t.createFromB58String=function(e){return new u(i.fromB58String(e))},t.createFromPubKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r;try{let i=e;if("string"==typeof i&&(i=n.from(e,"base64")),!n.isBuffer(i))throw new Error("Supplied key is neither a base64 string nor a buffer");r=o.keys.unmarshalPublicKey(i)}catch(e){return t(e)}r.hash((e,n)=>{if(e)return t(e);t(null,new u(n,null,r))})},t.createFromPrivKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r=e;try{if("string"==typeof r&&(r=n.from(e,"base64")),!n.isBuffer(r))throw new Error("Supplied key is neither a base64 string nor a buffer")}catch(e){return t(e)}a([e=>o.keys.unmarshalPrivateKey(r,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n,n.public))})},t.createFromJSON=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r,s,c,f;try{r=i.fromB58String(e.id),s=e.privKey&&n.from(e.privKey,"base64"),c=e.pubKey&&n.from(e.pubKey,"base64"),f=c&&o.keys.unmarshalPublicKey(c)}catch(e){return t(e)}s?a([e=>o.keys.unmarshalPrivateKey(s,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)}),(e,t,r)=>{f?f.hash((n,i)=>{r(n,e,t,i)}):r(null,e,t)}],(e,n,i,o)=>e?t(e):f&&!n.equals(o)?t(new Error("Public and private key do not match")):r&&!n.equals(r)?t(new Error("Id and private key do not match")):void t(null,new u(r,i,f))):t(null,new u(r,null,f))},t.isPeerId=function(e){return Boolean("object"==typeof e&&e._id&&e._idB58String)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";e.exports="message Propose {\n optional bytes rand = 1;\n optional bytes pubkey = 2;\n optional string exchanges = 3;\n optional string ciphers = 4;\n optional string hashes = 5;\n}\n\nmessage Exchange {\n optional bytes epubkey = 1;\n optional bytes signature = 2;\n}"},function(e,t,r){"use strict";const n=r(1),i=r(4),o=r(290),s=r(296),a=n("libp2p:secio");a.error=n("libp2p:secio:error"),e.exports=function(e,t){a("2. exchange - start"),a("2. exchange - writing exchange"),i([t=>s.createExchange(e,t),(t,r)=>{o.write(e,t),o.read(e.shake,r)},(t,r)=>{a("2. exchange - reading exchange"),s.verify(e,t,r)},t=>s.generateKeys(e,t)],e=>{if(e)return t(e);a("2. exchange - finish"),t()})}},function(e,t,r){"use strict";const n=r(8),i=r(100),o=r(1),s=o("libp2p:secio");s.error=o("libp2p:secio:error");const a=r(1185),u=r(296);e.exports=function(e,t){s("3. finish - start");const r=e.protocols,o=e.shake.rest(),c=i({timeout:e.timeout},e=>{if(e)throw e});n(o,a.createUnboxStream(r.remote.cipher,r.remote.mac),c,a.createBoxStream(r.local.cipher,r.local.mac),o),c.handshake.write(e.proposal.in.rand),c.handshake.read(e.proposal.in.rand.length,(r,i)=>{const o=r=>{s.error(r),e.secure.resolve({source:n.error(r),sink(e){}}),t(r)};if(r)return o(r);try{u.verifyNonce(e,i)}catch(r){return o(r)}s("3. finish - finish"),e.secure.resolve(c.handshake.rest()),t()})}},function(e,t,r){"use strict";(function(e){const n=r(8),i=r(53),o={fixed:!0,bytes:4};function s(){return n.map(t=>"string"==typeof t?e.from(t,"utf-8"):t)}t.createBoxStream=((t,r)=>n(s(),n.asyncMap((n,i)=>{t.encrypt(n,(t,n)=>{if(t)return i(t);r.digest(n,(t,r)=>{if(t)return i(t);i(null,e.concat([n,r]))})})}),i.encode(o))),t.createUnboxStream=((e,t)=>n(s(),i.decode(o),n.asyncMap((r,n)=>{const i=r.length,o=t.length;if(it?n(t):u.equals(r)?void e.decrypt(a,(e,t)=>{if(e)return n(e);n(null,t)}):n(new Error(`MAC Invalid: ${u.toString("hex")} != ${r.toString("hex")}`)))})))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(100),i=r(224);e.exports=class{constructor(e,t,r,o){"function"==typeof r&&(o=r,r=void 0),this.setup(),this.id.local=e,this.id.remote=t,this.key.local=e.privKey,this.timeout=r||6e4,o=o||(()=>{}),this.secure=i.duplex(),this.stream=n({timeout:this.timeout},o),this.shake=this.stream.handshake,delete this.stream.handshake}setup(){this.id={local:null,remote:null},this.key={local:null,remote:null},this.shake=null,this.cleanSecrets()}cleanSecrets(){this.shared={},this.ephemeralKey={local:null,remote:null},this.proposal={in:null,out:null},this.proposalEncoded={in:null,out:null},this.protocols={local:null,remote:null},this.exchange={in:null,out:null}}}},function(e,t,r){"use strict";const n=r(1188),i=r(51),o=r(52),s=r(78),a=r(11).EventEmitter,u=r(1),c=r(3),f=u("libp2p:railing");f.error=u("libp2p:railing:error");(e.exports=class extends a{constructor(e){super(),this._list=e.list,this._interval=e.interval||1e4,this._timer=null}start(e){c(()=>e()),this._timer||(this._timer=setInterval(()=>{this._list.forEach(e=>{if(!function(e){try{return s.IPFS.matches(e)}catch(e){return!1}}(e))return f.error("Invalid multiaddr");const t=o(e),r=n.createFromB58String(t.getPeerId());i.create(r,(e,r)=>{if(e)return f.error("Invalid bootstrap peer id",e);r.multiaddrs.add(t),this.emit("peer",r)})})},this._interval))}stop(e){c(e),this._timer&&(clearInterval(this._timer),this._timer=null)}}).tag="bootstrap"},function(e,t,r){"use strict";(function(n){const i=r(12),o=r(1189),s=r(17),a=r(4);class u{constructor(e,t,r){s(n.isBuffer(e),"invalid id provided"),t&&r&&s(t.public.bytes.equals(r.bytes),"inconsistent arguments"),this._id=e,this._idB58String=i.toB58String(this.id),this._privKey=t,this._pubKey=r}get id(){return this._id}set id(e){throw new Error("Id is immutable")}get privKey(){return this._privKey}set privKey(e){this._privKey=e}get pubKey(){return this._pubKey?this._pubKey:this._privKey?this._privKey.public:void 0}set pubKey(e){this._pubKey=e}marshalPubKey(){if(this.pubKey)return o.keys.marshalPublicKey(this.pubKey)}marshalPrivKey(){if(this.privKey)return o.keys.marshalPrivateKey(this.privKey)}toPrint(){return this.toJSON()}toJSON(){return{id:this.toB58String(),privKey:c(this.marshalPrivKey()),pubKey:c(this.marshalPubKey())}}toHexString(){return i.toHexString(this.id)}toBytes(){return this.id}toB58String(){return this._idB58String}isEqual(e){if(n.isBuffer(e))return this.id.equals(e);if(e.id)return this.id.equals(e.id);throw new Error("not valid Id")}isValid(e){this.privKey&&this.privKey.public&&this.privKey.public.bytes&&n.isBuffer(this.pubKey.bytes)&&this.privKey.public.bytes.equals(this.pubKey.bytes)?e():e(new Error("Keys not match"))}}function c(e){if(e)return e.toString("base64")}(t=e.exports=u).create=function(e,t){"function"==typeof e&&(t=e,e={}),(e=e||{}).bits=e.bits||2048,a([t=>o.keys.generateKeyPair("RSA",e.bits,t),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n))})},t.createFromHexString=function(e){return new u(i.fromHexString(e))},t.createFromBytes=function(e){return new u(e)},t.createFromB58String=function(e){return new u(i.fromB58String(e))},t.createFromPubKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r;try{let i=e;if("string"==typeof i&&(i=n.from(e,"base64")),!n.isBuffer(i))throw new Error("Supplied key is neither a base64 string nor a buffer");r=o.keys.unmarshalPublicKey(i)}catch(e){return t(e)}r.hash((e,n)=>{if(e)return t(e);t(null,new u(n,null,r))})},t.createFromPrivKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r=e;try{if("string"==typeof r&&(r=n.from(e,"base64")),!n.isBuffer(r))throw new Error("Supplied key is neither a base64 string nor a buffer")}catch(e){return t(e)}a([e=>o.keys.unmarshalPrivateKey(r,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n,n.public))})},t.createFromJSON=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r,s,c,f;try{r=i.fromB58String(e.id),s=e.privKey&&n.from(e.privKey,"base64"),c=e.pubKey&&n.from(e.pubKey,"base64"),f=c&&o.keys.unmarshalPublicKey(c)}catch(e){return t(e)}s?a([e=>o.keys.unmarshalPrivateKey(s,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)}),(e,t,r)=>{f?f.hash((n,i)=>{r(n,e,t,i)}):r(null,e,t)}],(e,n,i,o)=>e?t(e):f&&!n.equals(o)?t(new Error("Public and private key do not match")):r&&!n.equals(r)?t(new Error("Id and private key do not match")):void t(null,new u(r,i,f))):t(null,new u(r,null,f))},t.isPeerId=function(e){return Boolean("object"==typeof e&&e._id&&e._idB58String)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(548),i=r(1191),o=r(1193);(t=e.exports).aes=i,t.hmac=n,t.keys=o,t.randomBytes=r(553),t.pbkdf2=r(1204)},function(e,t,r){"use strict";e.exports={SHA1:20,SHA256:32,SHA512:64}},function(e,t,r){"use strict";const n=r(1192),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(59);e.exports={createCipheriv:n.createCipheriv,createDecipheriv:n.createDecipheriv}},function(e,t,r){"use strict";(function(n){const i=r(10)(r(299)),o=r(16);t=e.exports;const s={rsa:r(1194),ed25519:r(1199),secp256k1:r(61)(i,r(553))};function a(e){return void 0!==s[e.toLowerCase()]}t.supportedKeys=s,t.keysPBM=i,t.keyStretcher=r(1201),t.generateEphemeralKeyPair=r(1202),t.generateKeyPair=((e,t,r)=>{let 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)=>{let 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){"use strict";const n=r(549),i=r(10),o=r(14),s=r(551),a=i(r(299)),u=r(16),c=r(3);class f{constructor(e){this._key=e}verify(e,t,r){h(r),s.hashAndVerify(this._key,t,e,r)}marshal(){return s.utils.jwkToPkix(this._key)}get bytes(){return a.PublicKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}encrypt(e){return this._key.encrypt(e,"RSAES-PKCS1-V1_5")}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(e),n(this.bytes,"sha2-256",e)}}class l{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return s.getRandomValues(new Uint8Array(16))}sign(e,t){h(t),s.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){s.decrypt(this._key,e,t)}marshal(){return s.utils.jwkToPkcs1(this._key)}get bytes(){return a.PrivateKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(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"),h(r),c(()=>{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 h(e){if("function"!=typeof e)throw new Error("callback is required")}e.exports={RsaPublicKey:f,RsaPrivateKey:l,unmarshalRsaPublicKey:function(e){const t=s.utils.pkixToJwk(e);return new f(t)},unmarshalRsaPrivateKey:function(e,t){const r=s.utils.pkcs1ToJwk(e);s.unmarshalPrivateKey(r,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},generateKeyPair:function(e,t){s.generateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},fromJwk:function(e,t){s.unmarshalPrivateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})}}},function(e,t,r){"use strict";(function(t){const n=r(38),i=r(39),o=r(550),s=r(1196),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,256)),shake256:a(u(n.shake_256,512)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(1197),dblSha2256:(e,r)=>{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(40),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;function o(e){if(!i)throw new Error("Please use a browser with webcrypto support");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(41),i=r(550).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(15),i=r(552),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())}),u=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()))}),c=n.define("RSAPublicKey",function(){this.seq().obj(this.key("algorithm").use(u),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=c.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 c.encode({algorithm:{algorithm:"rsa",none:null},subjectPublicKey:{data:f.encode({modulus:s(e.n),publicExponent:s(e.e)},"der")}},"der")}},function(e,t,r){"use strict";(function(t){const n=r(549),i=r(10),o=r(14),s=r(1200),a=i(r(299));class u{constructor(e){this._key=l(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 c{constructor(e,t){this._key=l(e,s.privateKeyLength),this._publicKey=l(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 u(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 l(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:u,Ed25519PrivateKey:c,unmarshalEd25519PrivateKey:function(e,t){try{e=l(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 c(r,n))},unmarshalEd25519PublicKey:function(e){return e=l(e,s.publicKeyLength),new u(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 c(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 c(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(60),i=r(3);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){"use strict";(function(t){const n=r(37),i=r(548),o={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,cipherKeySize:32}};e.exports=((e,r,s,a)=>{const u=o[e];if(!u)return a(new Error("unkown cipherType passed"));if(!r)return a(new Error("unkown hashType passed"));const c=u.keySize,f=u.ivSize,l=t.from("key expansion"),h=2*(f+c+20);i.create(r,s,(e,r)=>{if(e)return a(e);r.digest(l,(e,i)=>{if(e)return a(e);let o=[],s=0;n(()=>s{if(t)return e(t);let a=n.length;s+a>h&&(a=h-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=h/2,n=t.concat(o),i=n.slice(0,r),s=n.slice(r,h),u=e=>({iv:e.slice(0,f),cipherKey:e.slice(f,f+c),macKey:e.slice(f+c)});a(null,{k1:u(i),k2:u(s)})})})})})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(1203);e.exports=((e,t)=>{n.generateEphmeralKeyPair(e,t)})},function(e,t,r){"use strict";(function(e){const n=r(298)(),i=r(297),o=r(15).bignum,s=r(552),a=s.toBase64,u=s.toBn,c={"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 o=(o,s,a)=>{let u;"function"==typeof s&&(a=s,s=void 0),u=s?n.subtle.importKey("jwk",p(t,s),{name:"ECDH",namedCurve:t},!1,["deriveBits"]):Promise.resolve(r.privateKey);const f=Promise.all([n.subtle.importKey("jwk",h(t,o),{name:"ECDH",namedCurve:t},!1,[]),u]);i(f.then(e=>n.subtle.deriveBits({name:"ECDH",namedCurve:t,public:e[0]},e[1],c[t])).then(t=>e.from(t)),a)};return n.subtle.exportKey("jwk",r.publicKey).then(e=>({key:l(e),genSharedKey:o}))}),r)};const f={"P-256":32,"P-384":48,"P-521":66};function l(t){const r=f[t.crv];return e.concat([e.from([4]),u(t.x).toArrayLike(e,"be",r),u(t.y).toArrayLike(e,"be",r)],1+2*r)}function h(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}}function p(e,t){const r=h(e,t.public);return r.d=a(new o(t.private)),r}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(16),i={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};e.exports=function(e,t,r,o,s){const a=i[s];if(!a)throw new Error(`Hash '${s}' is unknown or not supported`);const u=n.pkcs5.pbkdf2(e,t,r,o,a);return n.util.encode64(u)}},function(e,t,r){"use strict";const n=r(11).EventEmitter,i=r(17),o=r(50),s=r(49),a=r(63),u=r(490),c=r(1206),f=r(1307),l=r(512),h=r(1311),p=r(1345),d=r(1346),y=r(1347),g=r(1348),m=r(1358),b=r(1376).validate;e.exports;const v="The libp2p node is not started yet";e.exports=class extends n{constructor(e){if(super(),e=b(e),this.peerInfo=e.peerInfo,this.peerBook=e.peerBook||new u,this._modules=e.modules,this._config=e.config,this._isStarted=!1,this._transport=[],this._discovery=[],this._switch=new c(this.peerInfo,this.peerBook,e.switch),this.stats=this._switch.stats,this.connectionManager=new h(this,e.connectionManager),this._modules.streamMuxer&&(this._modules.streamMuxer.forEach(e=>this._switch.connection.addStreamMuxer(e)),this._switch.connection.reuse(),this._switch.connection.enableCircuitRelay(this._config.relay),this._switch.on("peer-mux-established",e=>{this.emit("peer:connect",e),this.peerBook.put(e)}),this._switch.on("peer-mux-closed",e=>{this.emit("peer:disconnect",e)})),this._modules.connEncryption&&this._modules.connEncryption.forEach(e=>{this._switch.connection.crypto(e.tag,e.encrypt)}),this._config.EXPERIMENTAL.dht){const e=this._modules.dht;this._dht=new e(this._switch,{kBucketSize:this._config.dht.kBucketSize||20,datastore:y.datastore})}this._config.EXPERIMENTAL.pubsub&&(this.pubsub=g(this)),this.peerRouting=p(this),this.contentRouting=d(this),this.dht=y(this),this._getPeerInfo=m(this),f.mount(this._switch)}start(e){if(!this._modules.transport)return e(new Error("no transports were present"));let t;const r=[],n=[];this.peerInfo.multiaddrs.toArray().forEach(e=>{e.getPeerId()||(r.push(e),n.push(e.encapsulate("/ipfs/"+this.peerInfo.id.toB58String())))}),this.peerInfo.multiaddrs.replace(r,n);const i=this.peerInfo.multiaddrs.toArray();this._modules.transport.forEach(e=>{let r;(r="function"==typeof e?new e:e).filter(i).length>0?this._switch.transport.add(r.tag||r.constructor.name,r):l.isWebSockets(r)&&(t=r),this._transport.push(r)}),s([e=>this._switch.start(e),e=>{t&&this._switch.transport.add(t.tag||t.constructor.name,t),this._modules.peerDiscovery?o(this._modules.peerDiscovery,(e,t)=>{let r={};if(e.tag&&this._config.peerDiscovery&&this._config.peerDiscovery[e.tag]&&(r=this._config.peerDiscovery[e.tag]),null==r.enabled||r.enabled){let n;(n="function"==typeof e?new e(Object.assign({},r,{peerInfo:this.peerInfo})):e).on("peer",e=>this.emit("peer:discovery",e)),this._discovery.push(n),n.start(t)}else t()},e):e()},e=>{this._isStarted=!0,this._dht?this._dht.start(e):e()},e=>{this._floodSub?this._floodSub.start(e):e()},e=>{this.peerInfo.multiaddrs.toArray().forEach(e=>{e.toString().match(/\/p2p-circuit($|\/)/)||this._transport.find(t=>t.filter(e).length>0)||this.peerInfo.multiaddrs.delete(e)}),e()},e=>{this.emit("start"),e()}],e)}stop(e){s([e=>{if(this._modules.peerDiscovery)return a(this._discovery.map(e=>t=>e.stop(()=>{t()})),e);e()},e=>{if(this._floodSub)return this._floodSub.stop(e);e()},e=>{if(this._dht)return this._dht.stop(e);e()},e=>this._switch.stop(e),e=>{this.emit("stop"),e()}],t=>{this._isStarted=!1,e(t)})}isStarted(){return this._isStarted}dial(e,t){i(this.isStarted(),v),this._getPeerInfo(e,(e,r)=>{if(e)return t(e);this._switch.dial(r,e=>{if(e)return t(e);this.peerBook.put(r),t()})})}dialProtocol(e,t,r){i(this.isStarted(),v),"function"==typeof t&&(r=t,t=void 0),this._getPeerInfo(e,(e,n)=>{if(e)return r(e);this._switch.dial(n,t,(e,t)=>{if(e)return r(e);this.peerBook.put(n),r(null,t)})})}hangUp(e,t){i(this.isStarted(),v),this._getPeerInfo(e,(e,r)=>{if(e)return t(e);this._switch.hangUp(r,t)})}ping(e,t){if(!this.isStarted())return t(new Error(v));this._getPeerInfo(e,(e,r)=>{if(e)return t(e);t(null,new f(this._switch,r))})}handle(e,t,r){this._switch.handle(e,t,r)}unhandle(e){this._switch.unhandle(e)}}},function(e,t,r){"use strict";const n=r(11).EventEmitter,i=r(50),o=r(49),s=r(1207),a=r(1211),u=r(577),c=r(1299),f=r(1300),l=r(576),h=r(1301),p=r(1302),d=r(17),y=r(1306);e.exports=class extends n{constructor(e,t,r){super(),d(e,"You must provide a `peerInfo`"),d(t,"You must provide a `peerBook`"),this._peerInfo=e,this._peerBook=t,this._options=r||{},this.setMaxListeners(1/0),this.transports={},this.conns={},this.muxedConns={},this.protocols={},this.muxers={},this.identify=!1,this.crypto=l,this.protector=this._options.protector||null,this.transport=new s(this),this.connection=new a(this),this.observer=h(this),this.stats=p(this.observer,this._options.stats),this.protocolMuxer=f(this.protocols,this.observer),this.handle(this.crypto.tag,(e,t)=>{const r=this._peerInfo.id,n=this.crypto.encrypt(r,t,void 0,()=>{});return this.protocolMuxer(null)(n)}),this.dial=c(this)}availableTransports(e){const t=e.multiaddrs.toArray();return Object.keys(this.transports).filter(e=>this.transports[e].filter(t).length>0).sort(e=>"Circuit"===e?1:0)}start(e){i(this.availableTransports(this._peerInfo),(e,t)=>{this.transport.listen(e,{},null,t)},e)}stop(e){this.stats.stop(),o([e=>i(this.muxedConns,(e,t)=>{if(!e)return t();e.muxer.end(e=>{if(e&&"Fatal error: OK"!==e.message)return t(e);t()})},e),e=>{i(this.transports,(e,t)=>{i(e.listeners,(e,t)=>{e.close(t)},t)},e)}],e)}handle(e,t,r){this.protocols[e]={handlerFunc:t,matchFunc:r}}unhandle(e){this.protocols[e]&&delete this.protocols[e]}hangUp(e,t){const r=u(e,this.peerBook).id.toB58String();if(this.muxedConns[r]){const e=this.muxedConns[r].muxer;e.once("close",()=>{delete this.muxedConns[r],t()}),e.end()}else t()}hasTransports(){const e=Object.keys(this.transports).filter(e=>"Circuit"!==e);return e&&e.length>0}},e.exports.errors=y},function(e,t,r){"use strict";const n=r(63),i=r(30),o=r(1)("libp2p:switch:transport"),s=r(1208),a=8,u=3e4;class c{constructor(e){this.switch=e,this.dialer=new s(a,u)}add(e,t){if(o("adding %s",e),this.switch.transports[e])throw new Error("There is already a transport with this key");this.switch.transports[e]=t,this.switch.transports[e].listeners||(this.switch.transports[e].listeners=[])}dial(e,t,r){const n=this.switch.transports[e];let i=t.multiaddrs.toArray();Array.isArray(i)||(i=[i]),i=c.dialables(n,i),o("dialing %s",e,i.map(e=>e.toString())),this.dialer.dialMany(t.id,n,i,(e,n)=>{if(e)return r(e);t.connect(n.multiaddr),this.switch._peerBook.put(t),r(null,n.conn)})}listen(e,t,r,o){let s;r||(r=this.switch.protocolMuxer(e)),this.switch.protector&&(s=r,r=(e=>{const t=this.switch.protector.protect(e,()=>{s(t)})}));const a=this.switch.transports[e],u=c.dialables(a,this.switch._peerInfo.multiaddrs.distinct());a.listeners||(a.listeners=[]);let f=[];const l=u.map(e=>t=>{const n=i(t),o=a.createListener(r);o.once("error",n),o.listen(e,e=>{if(e)return n(e);o.removeListener("error",n),o.getAddrs((e,t)=>{if(e)return n(e);f=f.concat(t),a.listeners.push(o),n()})})});n(l,e=>{if(e)return o(e);this.switch._peerInfo.multiaddrs.replace(u,f),o()})}close(e,t){const r=this.switch.transports[e];if(!r)return t(new Error(`Trying to close non existing transport: ${e}`));n(r.listeners.map(e=>t=>{e.close(t)}),t)}static dialables(e,t){return e.filter(t)}}e.exports=c},function(e,t,r){"use strict";const n=r(80),i=r(1),o=r(30),s=i("libp2p:swarm:dialer"),a=r(1209);e.exports=class{constructor(e,t){s("create: %s peer limit, %s dial timeout",e,t),this.perPeerLimit=e,this.dialTimeout=t,this.queues=new Map}dialMany(e,t,r,i){s("dialMany:start");const a={cancel:!1};i=o(i),n(r,(r,n)=>{this.dialSingle(e,t,r,a,n)},(e,t)=>{if(e)return i(e);const r=t.filter(e=>e.conn);if(r.length>0)return s("dialMany:success"),i(null,r[0]);s("dialMany:error");const n=new Error("Failed to dial any provided address");return n.errors=t.filter(e=>e.error).map(e=>e.error),i(n)})}dialSingle(e,t,r,n,i){const o=e.toB58String();let u;s("dialSingle: %s:%s",o,r.toString()),this.queues.has(o)?u=this.queues.get(o):(u=new a(this.perPeerLimit,this.dialTimeout),this.queues.set(o,u)),u.push(t,r,n,i)}}},function(e,t,r){"use strict";const n=r(47).Connection,i=r(8),o=r(1210),s=r(162),a=r(1)("libp2p:swarm:dialer:queue");e.exports=class{constructor(e,t){this.dialTimeout=t,this.queue=s((e,t)=>{this._doWork(e.transport,e.addr,e.token,t)},e)}_doWork(e,t,r,o){a("work"),this._dialWithTimeout(e,t,(e,s)=>e?(a("work:error"),o(null,{error:e})):r.cancel?(a("work:cancel"),i(i.empty(),s),o(null,{cancel:!0})):(r.cancel=!0,a("work:success"),(new n).setInnerConn(s),void o(null,{multiaddr:t,conn:s})))}_dialWithTimeout(e,t,r){o(r=>{const n=e.dial(t,e=>{if(e)return r(e);r(null,n)})},this.dialTimeout)(r)}push(e,t,r,n){this.queue.push({transport:e,addr:t,token:r},n)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){var o=(0,i.default)(e);return(0,n.default)(function(n,i){var s,a=!1;n.push(function(){a||(i.apply(null,arguments),clearTimeout(s))}),s=setTimeout(function(){var t=e.name||"anonymous",n=new Error('Callback function "'+t+'" timed out.');n.code="ETIMEDOUT",r&&(n.info=r),a=!0,i(n)},t),o.apply(null,n)})};var n=o(r(353)),i=o(r(34));function o(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default},function(e,t,r){"use strict";const n=r(1212),i=r(304),o=r(4),s=r(1)("libp2p:switch:connection"),a=r(30),u=r(3),c=r(565),f=r(576);e.exports=class{constructor(e){this.switch=e}addStreamMuxer(e){this.switch.muxers[e.multicodec]=e,this.switch.handle(e.multicodec,(t,r)=>{const c=e.listener(r);return c.on("stream",this.switch.protocolMuxer(null)),this.switch.identify&&r.getPeerInfo((e,t)=>{!e&&t||s("crypto peerInfo wasnt found"),r.getPeerInfo=(e=>{const r=c.newStream(),s=new i.Dialer;e=a(e),o([e=>s.handle(r,e),e=>s.select(n.multicodec,e),(e,r)=>n.dialer(e,t,r),(e,t,r)=>{t.forEach(e=>{this.switch._peerInfo.multiaddrs.addSafe(e)}),r(null,e)}],(t,n)=>{if(t)return c.end(()=>{n&&u(()=>this.switch.emit("peer-mux-closed",n)),e(t,null)});n&&r.setPeerInfo(n),e(t,n)})}),r.getPeerInfo((e,t)=>{if(e)return s("identify not successful");const r=t.id.toB58String();this.switch.muxedConns[r]={muxer:c},t.multiaddrs.size>0?t.connect(t.multiaddrs.toArray()[0]):t.connect(`/ipfs/${r}`),t=this.switch._peerBook.put(t),c.on("close",()=>{delete this.switch.muxedConns[r],t.disconnect(),t=this.switch._peerBook.put(t),s(`closed connection to ${r}`),u(()=>this.switch.emit("peer-mux-closed",t))}),u(()=>this.switch.emit("peer-mux-established",t))})}),r})}crypto(e,t){e||t||(e=f.tag,t=f.encrypt),this.switch.unhandle(this.switch.crypto.tag),this.switch.handle(e,(e,r)=>{const n=this.switch._peerInfo.id,i=t(n,r,void 0,()=>{this.switch.protocolMuxer(null)(i)})}),this.switch.crypto={tag:e,encrypt:t}}enableCircuitRelay(e){(e=e||{}).enabled&&(e.hop||Object.assign(e,{hop:{enabled:!1,active:!1}}),this.switch.transport.add(c.tag,new c(this.switch,e)))}reuse(){this.switch.identify=!0,this.switch.handle(n.multicodec,(e,t)=>{n.listener(t,this.switch._peerInfo)})}}},function(e,t,r){"use strict";(t=e.exports).multicodec="/ipfs/id/1.0.0",t.listener=r(1213),t.dialer=r(1214),t.message=r(300)},function(e,t,r){"use strict";(function(t){const n=r(8),i=r(53),o=r(300);e.exports=((e,r)=>{e.getObservedAddrs((s,a)=>{if(s)return;a=a[0];let u=t.alloc(0);r.id.pubKey&&(u=r.id.pubKey.bytes);const c=o.encode({protocolVersion:"ipfs/0.1.0",agentVersion:"na",publicKey:u,listenAddrs:r.multiaddrs.toArray().map(e=>e.buffer),observedAddr:a?a.buffer:t.from("")});n(n.values([c]),i.encode(),e)})})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(51),i=r(1215),o=r(52),s=r(8),a=r(53),u=r(300);e.exports=((e,t,r)=>{"function"==typeof t&&(r=t,t=null,console.warn("WARNING: no expected peer info was given, identify will not be able to verify peer integrity")),s(e,a.decode(),s.take(1),s.collect((e,s)=>{if(e)return r(e);if(0===s.length)return r(new Error("conn was closed, did not receive data"));const a=u.decode(s[0]);i.createFromPubKey(a.publicKey,(e,i)=>{if(e)return r(e);const s=new n(i);if(t&&t.id.toB58String()!==i.toB58String())return r(new Error("invalid peer"));try{a.listenAddrs.map(o).forEach(e=>s.multiaddrs.add(e))}catch(e){return r(e)}let u;try{u=function(e){if(!function(e){return e.observedAddr&&e.observedAddr.length>0}(e))return[];let t=e.observedAddr;return Array.isArray(t)||(t=[t]),t.map(e=>o(e))}(a)}catch(e){return r(e)}r(null,s,u)})}))})},function(e,t,r){"use strict";(function(n){const i=r(12),o=r(1216),s=r(17),a=r(4);class u{constructor(e,t,r){s(n.isBuffer(e),"invalid id provided"),t&&r&&s(t.public.bytes.equals(r.bytes),"inconsistent arguments"),this._id=e,this._idB58String=i.toB58String(this.id),this._privKey=t,this._pubKey=r}get id(){return this._id}set id(e){throw new Error("Id is immutable")}get privKey(){return this._privKey}set privKey(e){this._privKey=e}get pubKey(){return this._pubKey?this._pubKey:this._privKey?this._privKey.public:void 0}set pubKey(e){this._pubKey=e}marshalPubKey(){if(this.pubKey)return o.keys.marshalPublicKey(this.pubKey)}marshalPrivKey(){if(this.privKey)return o.keys.marshalPrivateKey(this.privKey)}toPrint(){return this.toJSON()}toJSON(){return{id:this.toB58String(),privKey:c(this.marshalPrivKey()),pubKey:c(this.marshalPubKey())}}toHexString(){return i.toHexString(this.id)}toBytes(){return this.id}toB58String(){return this._idB58String}isEqual(e){if(n.isBuffer(e))return this.id.equals(e);if(e.id)return this.id.equals(e.id);throw new Error("not valid Id")}isValid(e){this.privKey&&this.privKey.public&&this.privKey.public.bytes&&n.isBuffer(this.pubKey.bytes)&&this.privKey.public.bytes.equals(this.pubKey.bytes)?e():e(new Error("Keys not match"))}}function c(e){if(e)return e.toString("base64")}(t=e.exports=u).create=function(e,t){"function"==typeof e&&(t=e,e={}),(e=e||{}).bits=e.bits||2048,a([t=>o.keys.generateKeyPair("RSA",e.bits,t),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n))})},t.createFromHexString=function(e){return new u(i.fromHexString(e))},t.createFromBytes=function(e){return new u(e)},t.createFromB58String=function(e){return new u(i.fromB58String(e))},t.createFromPubKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r;try{let i=e;if("string"==typeof i&&(i=n.from(e,"base64")),!n.isBuffer(i))throw new Error("Supplied key is neither a base64 string nor a buffer");r=o.keys.unmarshalPublicKey(i)}catch(e){return t(e)}r.hash((e,n)=>{if(e)return t(e);t(null,new u(n,null,r))})},t.createFromPrivKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r=e;try{if("string"==typeof r&&(r=n.from(e,"base64")),!n.isBuffer(r))throw new Error("Supplied key is neither a base64 string nor a buffer")}catch(e){return t(e)}a([e=>o.keys.unmarshalPrivateKey(r,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n,n.public))})},t.createFromJSON=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r,s,c,f;try{r=i.fromB58String(e.id),s=e.privKey&&n.from(e.privKey,"base64"),c=e.pubKey&&n.from(e.pubKey,"base64"),f=c&&o.keys.unmarshalPublicKey(c)}catch(e){return t(e)}s?a([e=>o.keys.unmarshalPrivateKey(s,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)}),(e,t,r)=>{f?f.hash((n,i)=>{r(n,e,t,i)}):r(null,e,t)}],(e,n,i,o)=>e?t(e):f&&!n.equals(o)?t(new Error("Public and private key do not match")):r&&!n.equals(r)?t(new Error("Id and private key do not match")):void t(null,new u(r,i,f))):t(null,new u(r,null,f))},t.isPeerId=function(e){return Boolean("object"==typeof e&&e._id&&e._idB58String)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(554),i=r(1218),o=r(1220);(t=e.exports).aes=i,t.hmac=n,t.keys=o,t.randomBytes=r(559),t.pbkdf2=r(1231)},function(e,t,r){"use strict";e.exports={SHA1:20,SHA256:32,SHA512:64}},function(e,t,r){"use strict";const n=r(1219),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(59);e.exports={createCipheriv:n.createCipheriv,createDecipheriv:n.createDecipheriv}},function(e,t,r){"use strict";(function(n){const i=r(10)(r(303)),o=r(16);t=e.exports;const s={rsa:r(1221),ed25519:r(1226),secp256k1:r(61)(i,r(559))};function a(e){return void 0!==s[e.toLowerCase()]}t.supportedKeys=s,t.keysPBM=i,t.keyStretcher=r(1228),t.generateEphemeralKeyPair=r(1229),t.generateKeyPair=((e,t,r)=>{let 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)=>{let 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){"use strict";const n=r(555),i=r(10),o=r(14),s=r(557),a=i(r(303)),u=r(16),c=r(3);class f{constructor(e){this._key=e}verify(e,t,r){h(r),s.hashAndVerify(this._key,t,e,r)}marshal(){return s.utils.jwkToPkix(this._key)}get bytes(){return a.PublicKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}encrypt(e){return this._key.encrypt(e,"RSAES-PKCS1-V1_5")}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(e),n(this.bytes,"sha2-256",e)}}class l{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return s.getRandomValues(new Uint8Array(16))}sign(e,t){h(t),s.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){s.decrypt(this._key,e,t)}marshal(){return s.utils.jwkToPkcs1(this._key)}get bytes(){return a.PrivateKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(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"),h(r),c(()=>{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 h(e){if("function"!=typeof e)throw new Error("callback is required")}e.exports={RsaPublicKey:f,RsaPrivateKey:l,unmarshalRsaPublicKey:function(e){const t=s.utils.pkixToJwk(e);return new f(t)},unmarshalRsaPrivateKey:function(e,t){const r=s.utils.pkcs1ToJwk(e);s.unmarshalPrivateKey(r,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},generateKeyPair:function(e,t){s.generateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},fromJwk:function(e,t){s.unmarshalPrivateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})}}},function(e,t,r){"use strict";(function(t){const n=r(38),i=r(39),o=r(556),s=r(1223),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,256)),shake256:a(u(n.shake_256,512)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(1224),dblSha2256:(e,r)=>{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(40),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;function o(e){if(!i)throw new Error("Please use a browser with webcrypto support");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(41),i=r(556).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(15),i=r(558),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())}),u=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()))}),c=n.define("RSAPublicKey",function(){this.seq().obj(this.key("algorithm").use(u),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=c.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 c.encode({algorithm:{algorithm:"rsa",none:null},subjectPublicKey:{data:f.encode({modulus:s(e.n),publicExponent:s(e.e)},"der")}},"der")}},function(e,t,r){"use strict";(function(t){const n=r(555),i=r(10),o=r(14),s=r(1227),a=i(r(303));class u{constructor(e){this._key=l(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 c{constructor(e,t){this._key=l(e,s.privateKeyLength),this._publicKey=l(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 u(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 l(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:u,Ed25519PrivateKey:c,unmarshalEd25519PrivateKey:function(e,t){try{e=l(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 c(r,n))},unmarshalEd25519PublicKey:function(e){return e=l(e,s.publicKeyLength),new u(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 c(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 c(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(60),i=r(3);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){"use strict";(function(t){const n=r(37),i=r(554),o={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,cipherKeySize:32}};e.exports=((e,r,s,a)=>{const u=o[e];if(!u)return a(new Error("unkown cipherType passed"));if(!r)return a(new Error("unkown hashType passed"));const c=u.keySize,f=u.ivSize,l=t.from("key expansion"),h=2*(f+c+20);i.create(r,s,(e,r)=>{if(e)return a(e);r.digest(l,(e,i)=>{if(e)return a(e);let o=[],s=0;n(()=>s{if(t)return e(t);let a=n.length;s+a>h&&(a=h-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=h/2,n=t.concat(o),i=n.slice(0,r),s=n.slice(r,h),u=e=>({iv:e.slice(0,f),cipherKey:e.slice(f,f+c),macKey:e.slice(f+c)});a(null,{k1:u(i),k2:u(s)})})})})})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(1230);e.exports=((e,t)=>{n.generateEphmeralKeyPair(e,t)})},function(e,t,r){"use strict";(function(e){const n=r(302)(),i=r(301),o=r(15).bignum,s=r(558),a=s.toBase64,u=s.toBn,c={"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 o=(o,s,a)=>{let u;"function"==typeof s&&(a=s,s=void 0),u=s?n.subtle.importKey("jwk",p(t,s),{name:"ECDH",namedCurve:t},!1,["deriveBits"]):Promise.resolve(r.privateKey);const f=Promise.all([n.subtle.importKey("jwk",h(t,o),{name:"ECDH",namedCurve:t},!1,[]),u]);i(f.then(e=>n.subtle.deriveBits({name:"ECDH",namedCurve:t,public:e[0]},e[1],c[t])).then(t=>e.from(t)),a)};return n.subtle.exportKey("jwk",r.publicKey).then(e=>({key:l(e),genSharedKey:o}))}),r)};const f={"P-256":32,"P-384":48,"P-521":66};function l(t){const r=f[t.crv];return e.concat([e.from([4]),u(t.x).toArrayLike(e,"be",r),u(t.y).toArrayLike(e,"be",r)],1+2*r)}function h(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}}function p(e,t){const r=h(e,t.public);return r.d=a(new o(t.private)),r}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(16),i={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};e.exports=function(e,t,r,o,s){const a=i[s];if(!a)throw new Error(`Hash '${s}' is unknown or not supported`);const u=n.pkcs5.pbkdf2(e,t,r,o,a);return n.util.encode64(u)}},function(e,t,r){"use strict";const n=r(8),i=r(560),o=r(17),s=r(561),a=r(1233),u=r(1235),c=r(563),f=r(195),l=r(47).Connection,h=r(564).PROTOCOL_ID;e.exports=class{constructor(){this.handlers={ls:{handlerFunc:(e,t)=>u(this,t),matchFunc:c}},this.log=f.log.listener()}handle(e,t){this.log("listener handle conn");const r=s(h,(r,i)=>{if(r)return t(r);const o=new l(i,e),s=a(o,this.handlers,this.log);n(o,s,o),t()},this.log);n(e,r,e)}addHandler(e,t,r){this.log("adding handler: "+e),o(i(t),"handler must be a function"),this.handlers[e]&&this.log("overwriting handler for "+e),r||(r=c),this.handlers[e]={handlerFunc:t,matchFunc:r}}}},function(e,t,r){"use strict";(function(t){const n=r(100),i=r(53),o=r(47).Connection,s=r(195).writeEncoded,a=r(1234);function u(e,t,r){const n=Object.keys(t);let i=!1;a(n,(r,n)=>{t[r].matchFunc(r,e,(e,t)=>{if(e)return n(e);t&&(i=r),n()})},e=>{if(e)return r(e);r(null,i)})}e.exports=function(e,r,a){const c=e=>{a.error(e)},f=n({timeout:6e4},c),l=f.handshake;return function n(){i.decodeFromReader(l,(i,f)=>{if(i)return c(i);a("received:",f.toString());const h=f.toString().slice(0,-1);u(h,r,(i,u)=>{if(i)return c(i);const p=u;if(p){a("send ack back of: "+h),s(l,f,c);const t=new o(l.rest(),e);r[p].handlerFunc(h,t)}else a("not supported protocol: "+h),s(l,t.from("na\n")),n()})})}(),f}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=s(r(562)),i=s(r(164)),o=s(r(305));function s(e){return e&&e.__esModule?e:{default:e}}t.default=(0,i.default)((0,n.default)(Boolean,o.default)),e.exports=t.default},function(e,t,r){"use strict";(function(t){const n=r(8),i=r(53),o=r(20);e.exports=function(e,r){const s=Object.keys(e.handlers).filter(e=>"ls"!==e),a=s.length,u=s.reduce((e,r)=>{const n=t.from(r+"\n");return e+o.encodingLength(n.length)},0),c=t.concat([t.from(o.encode(a)),t.from(o.encode(u)),t.from("\n")]),f=s.map(e=>t.from(e+"\n")),l=[c].concat(f);n(n.values(l),i.encode(),r)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(20),i=r(8),o=r(53),s=r(47).Connection,a=r(195),u=r(561),c=r(30),f=r(564).PROTOCOL_ID;function l(e){return e.toString().slice(0,-1)}e.exports=class{constructor(){this.conn=null,this.log=a.log.dialer()}handle(e,t){this.log("dialer handle conn"),t=c(t);const r=u(f,(r,n)=>{if(r)return t(r);this.log("handshake success"),this.conn=new s(n,e),t()},this.log);i(e,r,e)}select(e,t){if(this.log("dialer select "+e),t=c(t),!this.conn)return t(new Error("multistream handshake has not finalized yet"));const r=u(e,(e,r)=>{if(e)return this.conn=new s(r,this.conn),t(e);t(null,new s(r,this.conn))},this.log);i(this.conn,r,this.conn)}ls(e){e=c(e);const t=u("ls",(t,r)=>{if(t)return e(t);i(r,o.decode(),function(e){let t=0;return i.take(e=>(n.decode(e),t=n.decode(e,n.decode.bytes),!0))}(),i.map(l),i.collect((t,r)=>{if(t)return e(t);e(null,r.slice(1))}))},this.log);i(this.conn,t,this.conn)}}},function(e,t,r){"use strict";const n=r(1238);e.exports=function(e,t,r){const i=e.split("/"),o=t.split("/"),s=i[1],a=i[2],u=o[1],c=o[2];if(s!==u)return r(null,!1);r(null,n.satisfies(a,"~"+c))}},function(e,t,r){(function(r){var n;t=e.exports=$,n="object"==typeof r&&r.env&&r.env.NODE_DEBUG&&/\bsemver\b/i.test(r.env.NODE_DEBUG)?function(){var e=Array.prototype.slice.call(arguments,0);e.unshift("SEMVER"),console.log.apply(console,e)}:function(){},t.SEMVER_SPEC_VERSION="2.0.0";var i=256,o=Number.MAX_SAFE_INTEGER||9007199254740991,s=t.re=[],a=t.src=[],u=0,c=u++;a[c]="0|[1-9]\\d*";var f=u++;a[f]="[0-9]+";var l=u++;a[l]="\\d*[a-zA-Z-][a-zA-Z0-9-]*";var h=u++;a[h]="("+a[c]+")\\.("+a[c]+")\\.("+a[c]+")";var p=u++;a[p]="("+a[f]+")\\.("+a[f]+")\\.("+a[f]+")";var d=u++;a[d]="(?:"+a[c]+"|"+a[l]+")";var y=u++;a[y]="(?:"+a[f]+"|"+a[l]+")";var g=u++;a[g]="(?:-("+a[d]+"(?:\\."+a[d]+")*))";var m=u++;a[m]="(?:-?("+a[y]+"(?:\\."+a[y]+")*))";var b=u++;a[b]="[0-9A-Za-z-]+";var v=u++;a[v]="(?:\\+("+a[b]+"(?:\\."+a[b]+")*))";var _=u++,w="v?"+a[h]+a[g]+"?"+a[v]+"?";a[_]="^"+w+"$";var S="[v=\\s]*"+a[p]+a[m]+"?"+a[v]+"?",k=u++;a[k]="^"+S+"$";var E=u++;a[E]="((?:<|>)?=?)";var A=u++;a[A]=a[f]+"|x|X|\\*";var x=u++;a[x]=a[c]+"|x|X|\\*";var I=u++;a[I]="[v=\\s]*("+a[x]+")(?:\\.("+a[x]+")(?:\\.("+a[x]+")(?:"+a[g]+")?"+a[v]+"?)?)?";var T=u++;a[T]="[v=\\s]*("+a[A]+")(?:\\.("+a[A]+")(?:\\.("+a[A]+")(?:"+a[m]+")?"+a[v]+"?)?)?";var B=u++;a[B]="^"+a[E]+"\\s*"+a[I]+"$";var C=u++;a[C]="^"+a[E]+"\\s*"+a[T]+"$";var P=u++;a[P]="(?:^|[^\\d])(\\d{1,16})(?:\\.(\\d{1,16}))?(?:\\.(\\d{1,16}))?(?:$|[^\\d])";var O=u++;a[O]="(?:~>?)";var R=u++;a[R]="(\\s*)"+a[O]+"\\s+",s[R]=new RegExp(a[R],"g");var N=u++;a[N]="^"+a[O]+a[I]+"$";var L=u++;a[L]="^"+a[O]+a[T]+"$";var K=u++;a[K]="(?:\\^)";var j=u++;a[j]="(\\s*)"+a[K]+"\\s+",s[j]=new RegExp(a[j],"g");var M=u++;a[M]="^"+a[K]+a[I]+"$";var D=u++;a[D]="^"+a[K]+a[T]+"$";var U=u++;a[U]="^"+a[E]+"\\s*("+S+")$|^$";var F=u++;a[F]="^"+a[E]+"\\s*("+w+")$|^$";var q=u++;a[q]="(\\s*)"+a[E]+"\\s*("+S+"|"+a[I]+")",s[q]=new RegExp(a[q],"g");var H=u++;a[H]="^\\s*("+a[I]+")\\s+-\\s+("+a[I]+")\\s*$";var z=u++;a[z]="^\\s*("+a[T]+")\\s+-\\s+("+a[T]+")\\s*$";var V=u++;a[V]="(<|>)?=?\\s*\\*";for(var G=0;Gi)return null;if(!(t?s[k]:s[_]).test(e))return null;try{return new $(e,t)}catch(e){return null}}function $(e,t){if(e instanceof $){if(e.loose===t)return e;e=e.version}else if("string"!=typeof e)throw new TypeError("Invalid Version: "+e);if(e.length>i)throw new TypeError("version is longer than "+i+" characters");if(!(this instanceof $))return new $(e,t);n("SemVer",e,t),this.loose=t;var r=e.trim().match(t?s[k]:s[_]);if(!r)throw new TypeError("Invalid Version: "+e);if(this.raw=e,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>o||this.major<0)throw new TypeError("Invalid major version");if(this.minor>o||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>o||this.patch<0)throw new TypeError("Invalid patch version");r[4]?this.prerelease=r[4].split(".").map(function(e){if(/^[0-9]+$/.test(e)){var t=+e;if(t>=0&&t=0;)"number"==typeof this.prerelease[r]&&(this.prerelease[r]++,r=-2);-1===r&&this.prerelease.push(0)}t&&(this.prerelease[0]===t?isNaN(this.prerelease[1])&&(this.prerelease=[t,0]):this.prerelease=[t,0]);break;default:throw new Error("invalid increment argument: "+e)}return this.format(),this.raw=this.version,this},t.inc=function(e,t,r,n){"string"==typeof r&&(n=r,r=void 0);try{return new $(e,r).inc(t,n).version}catch(e){return null}},t.diff=function(e,t){if(ee(e,t))return null;var r=W(e),n=W(t);if(r.prerelease.length||n.prerelease.length){for(var i in r)if(("major"===i||"minor"===i||"patch"===i)&&r[i]!==n[i])return"pre"+i;return"prerelease"}for(var i in r)if(("major"===i||"minor"===i||"patch"===i)&&r[i]!==n[i])return i},t.compareIdentifiers=J;var Y=/^[0-9]+$/;function J(e,t){var r=Y.test(e),n=Y.test(t);return r&&n&&(e=+e,t=+t),r&&!n?-1:n&&!r?1:et?1:0}function X(e,t,r){return new $(e,r).compare(new $(t,r))}function Z(e,t,r){return X(e,t,r)>0}function Q(e,t,r){return X(e,t,r)<0}function ee(e,t,r){return 0===X(e,t,r)}function te(e,t,r){return 0!==X(e,t,r)}function re(e,t,r){return X(e,t,r)>=0}function ne(e,t,r){return X(e,t,r)<=0}function ie(e,t,r,n){var i;switch(t){case"===":"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),i=e===r;break;case"!==":"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),i=e!==r;break;case"":case"=":case"==":i=ee(e,r,n);break;case"!=":i=te(e,r,n);break;case">":i=Z(e,r,n);break;case">=":i=re(e,r,n);break;case"<":i=Q(e,r,n);break;case"<=":i=ne(e,r,n);break;default:throw new TypeError("Invalid operator: "+t)}return i}function oe(e,t){if(e instanceof oe){if(e.loose===t)return e;e=e.value}if(!(this instanceof oe))return new oe(e,t);n("comparator",e,t),this.loose=t,this.parse(e),this.semver===se?this.value="":this.value=this.operator+this.semver.version,n("comp",this)}t.rcompareIdentifiers=function(e,t){return J(t,e)},t.major=function(e,t){return new $(e,t).major},t.minor=function(e,t){return new $(e,t).minor},t.patch=function(e,t){return new $(e,t).patch},t.compare=X,t.compareLoose=function(e,t){return X(e,t,!0)},t.rcompare=function(e,t,r){return X(t,e,r)},t.sort=function(e,r){return e.sort(function(e,n){return t.compare(e,n,r)})},t.rsort=function(e,r){return e.sort(function(e,n){return t.rcompare(e,n,r)})},t.gt=Z,t.lt=Q,t.eq=ee,t.neq=te,t.gte=re,t.lte=ne,t.cmp=ie,t.Comparator=oe;var se={};function ae(e,t){if(e instanceof ae)return e.loose===t?e:new ae(e.raw,t);if(e instanceof oe)return new ae(e.value,t);if(!(this instanceof ae))return new ae(e,t);if(this.loose=t,this.raw=e,this.set=e.split(/\s*\|\|\s*/).map(function(e){return this.parseRange(e.trim())},this).filter(function(e){return e.length}),!this.set.length)throw new TypeError("Invalid SemVer Range: "+e);this.format()}function ue(e,t){return n("comp",e),e=function(e,t){return e.trim().split(/\s+/).map(function(e){return function(e,t){n("caret",e,t);var r=t?s[D]:s[M];return e.replace(r,function(t,r,i,o,s){var a;return n("caret",e,t,r,i,o,s),ce(r)?a="":ce(i)?a=">="+r+".0.0 <"+(+r+1)+".0.0":ce(o)?a="0"===r?">="+r+"."+i+".0 <"+r+"."+(+i+1)+".0":">="+r+"."+i+".0 <"+(+r+1)+".0.0":s?(n("replaceCaret pr",s),"-"!==s.charAt(0)&&(s="-"+s),a="0"===r?"0"===i?">="+r+"."+i+"."+o+s+" <"+r+"."+i+"."+(+o+1):">="+r+"."+i+"."+o+s+" <"+r+"."+(+i+1)+".0":">="+r+"."+i+"."+o+s+" <"+(+r+1)+".0.0"):(n("no pr"),a="0"===r?"0"===i?">="+r+"."+i+"."+o+" <"+r+"."+i+"."+(+o+1):">="+r+"."+i+"."+o+" <"+r+"."+(+i+1)+".0":">="+r+"."+i+"."+o+" <"+(+r+1)+".0.0"),n("caret return",a),a})}(e,t)}).join(" ")}(e,t),n("caret",e),e=function(e,t){return e.trim().split(/\s+/).map(function(e){return function(e,t){var r=t?s[L]:s[N];return e.replace(r,function(t,r,i,o,s){var a;return n("tilde",e,t,r,i,o,s),ce(r)?a="":ce(i)?a=">="+r+".0.0 <"+(+r+1)+".0.0":ce(o)?a=">="+r+"."+i+".0 <"+r+"."+(+i+1)+".0":s?(n("replaceTilde pr",s),"-"!==s.charAt(0)&&(s="-"+s),a=">="+r+"."+i+"."+o+s+" <"+r+"."+(+i+1)+".0"):a=">="+r+"."+i+"."+o+" <"+r+"."+(+i+1)+".0",n("tilde return",a),a})}(e,t)}).join(" ")}(e,t),n("tildes",e),e=function(e,t){return n("replaceXRanges",e,t),e.split(/\s+/).map(function(e){return function(e,t){e=e.trim();var r=t?s[C]:s[B];return e.replace(r,function(t,r,i,o,s,a){n("xRange",e,t,r,i,o,s,a);var u=ce(i),c=u||ce(o),f=c||ce(s);return"="===r&&f&&(r=""),u?t=">"===r||"<"===r?"<0.0.0":"*":r&&f?(c&&(o=0),f&&(s=0),">"===r?(r=">=",c?(i=+i+1,o=0,s=0):f&&(o=+o+1,s=0)):"<="===r&&(r="<",c?i=+i+1:o=+o+1),t=r+i+"."+o+"."+s):c?t=">="+i+".0.0 <"+(+i+1)+".0.0":f&&(t=">="+i+"."+o+".0 <"+i+"."+(+o+1)+".0"),n("xRange return",t),t})}(e,t)}).join(" ")}(e,t),n("xrange",e),e=function(e,t){return n("replaceStars",e,t),e.trim().replace(s[V],"")}(e,t),n("stars",e),e}function ce(e){return!e||"x"===e.toLowerCase()||"*"===e}function fe(e,t,r,n,i,o,s,a,u,c,f,l,h){return((t=ce(r)?"":ce(n)?">="+r+".0.0":ce(i)?">="+r+"."+n+".0":">="+t)+" "+(a=ce(u)?"":ce(c)?"<"+(+u+1)+".0.0":ce(f)?"<"+u+"."+(+c+1)+".0":l?"<="+u+"."+c+"."+f+"-"+l:"<="+a)).trim()}function le(e,t){for(var r=0;r0){var i=e[r].semver;if(i.major===t.major&&i.minor===t.minor&&i.patch===t.patch)return!0}return!1}return!0}function he(e,t,r){try{t=new ae(t,r)}catch(e){return!1}return t.test(e)}function pe(e,t,r,n){var i,o,s,a,u;switch(e=new $(e,n),t=new ae(t,n),r){case">":i=Z,o=ne,s=Q,a=">",u=">=";break;case"<":i=Q,o=re,s=Z,a="<",u="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(he(e,t,n))return!1;for(var c=0;c=0.0.0")),f=f||e,l=l||e,i(e.semver,f.semver,n)?f=e:s(e.semver,l.semver,n)&&(l=e)}),f.operator===a||f.operator===u)return!1;if((!l.operator||l.operator===a)&&o(e,l.semver))return!1;if(l.operator===u&&s(e,l.semver))return!1}return!0}oe.prototype.parse=function(e){var t=this.loose?s[U]:s[F],r=e.match(t);if(!r)throw new TypeError("Invalid comparator: "+e);this.operator=r[1],"="===this.operator&&(this.operator=""),r[2]?this.semver=new $(r[2],this.loose):this.semver=se},oe.prototype.toString=function(){return this.value},oe.prototype.test=function(e){return n("Comparator.test",e,this.loose),this.semver===se||("string"==typeof e&&(e=new $(e,this.loose)),ie(e,this.operator,this.semver,this.loose))},oe.prototype.intersects=function(e,t){if(!(e instanceof oe))throw new TypeError("a Comparator is required");var r;if(""===this.operator)return r=new ae(e.value,t),he(this.value,r,t);if(""===e.operator)return r=new ae(this.value,t),he(e.semver,r,t);var n=!(">="!==this.operator&&">"!==this.operator||">="!==e.operator&&">"!==e.operator),i=!("<="!==this.operator&&"<"!==this.operator||"<="!==e.operator&&"<"!==e.operator),o=this.semver.version===e.semver.version,s=!(">="!==this.operator&&"<="!==this.operator||">="!==e.operator&&"<="!==e.operator),a=ie(this.semver,"<",e.semver,t)&&(">="===this.operator||">"===this.operator)&&("<="===e.operator||"<"===e.operator),u=ie(this.semver,">",e.semver,t)&&("<="===this.operator||"<"===this.operator)&&(">="===e.operator||">"===e.operator);return n||i||o&&s||a||u},t.Range=ae,ae.prototype.format=function(){return this.range=this.set.map(function(e){return e.join(" ").trim()}).join("||").trim(),this.range},ae.prototype.toString=function(){return this.range},ae.prototype.parseRange=function(e){var t=this.loose;e=e.trim(),n("range",e,t);var r=t?s[z]:s[H];e=e.replace(r,fe),n("hyphen replace",e),e=e.replace(s[q],"$1$2$3"),n("comparator trim",e,s[q]),e=(e=(e=e.replace(s[R],"$1~")).replace(s[j],"$1^")).split(/\s+/).join(" ");var i=t?s[U]:s[F],o=e.split(" ").map(function(e){return ue(e,t)}).join(" ").split(/\s+/);return this.loose&&(o=o.filter(function(e){return!!e.match(i)})),o.map(function(e){return new oe(e,t)})},ae.prototype.intersects=function(e,t){if(!(e instanceof ae))throw new TypeError("a Range is required");return this.set.some(function(r){return r.every(function(r){return e.set.some(function(e){return e.every(function(e){return r.intersects(e,t)})})})})},t.toComparators=function(e,t){return new ae(e,t).set.map(function(e){return e.map(function(e){return e.value}).join(" ").trim().split(" ")})},ae.prototype.test=function(e){if(!e)return!1;"string"==typeof e&&(e=new $(e,this.loose));for(var t=0;t",r)},t.outside=pe,t.prerelease=function(e,t){var r=W(e,t);return r&&r.prerelease.length?r.prerelease:null},t.intersects=function(e,t,r){return e=new ae(e,r),t=new ae(t,r),e.intersects(t)},t.coerce=function(e){if(e instanceof $)return e;if("string"!=typeof e)return null;var t=e.match(s[P]);return null==t?null:W((t[1]||"0")+"."+(t[2]||"0")+"."+(t[3]||"0"))}}).call(this,r(7))},function(e,t,r){"use strict";const n=r(78),i=r(142),o=r(1242),s=r(143),a=r(1);a("libp2p:circuit:transportdialer").err=a("libp2p:circuit:error:transportdialer");const u=r(1260);e.exports=class{static get tag(){return"Circuit"}constructor(e,t){this.options=t||{},this.swarm=e,this.dialer=null,this.utils=s(e),this.peerInfo=this.swarm._peerInfo,this.relays=this.filter(this.peerInfo.multiaddrs.toArray()),0===this.relays.length&&this.peerInfo.multiaddrs.add(`/p2p-circuit/ipfs/${this.peerInfo.id.toB58String()}`),this.dialer=new o(e,t),this.swarm.on("peer-mux-established",this.dialer.canHop.bind(this.dialer)),this.swarm.on("peer-mux-closed",e=>{this.dialer.relayPeers.delete(e.id.toB58String())})}_dialSwarmRelays(){this.relays.forEach(e=>{e.toString().split("/p2p-circuit").filter(e=>e.length).forEach(e=>{this.dialer._dialRelay(this.utils.peerInfoFromMa(i(e)))})})}dial(e,t,r){return this.dialer.dial(e,t,r)}createListener(e,t){"function"==typeof e&&(t=e,e=this.options||{});const r=u(this.swarm,e,t);return r.on("listen",this._dialSwarmRelays.bind(this)),r}filter(e){return Array.isArray(e)||(e=[e]),e.filter(e=>n.Circuit.matches(e))}}},function(e,t,r){"use strict";(function(t){const n=r(44),i=r(136),o=r(1241),s=r(306),a=r(20);function u(e){const t=[],r=e.split("/").slice(1);if(1===r.length&&""===r[0])return[];for(let n=0;n=r.length)throw v("invalid address: "+e);t.push([i,r[n]])}else t.push([i])}return t}function c(e){const t=[];return n(e,function(e){const r=_(e);t.push(r.name),e.length>1&&t.push(e[1])}),"/"+t.join("/")}function f(e){return n(e,function(e){Array.isArray(e)||(e=[e]);const t=_(e);return e.length>1?[t.code,o.toBuffer(t.code,e[1])]:[t.code]})}function l(e){return n(e,function(e){const t=_(e);return e.length>1?[t.code,o.toString(t.code,e[1])]:[t.code]})}function h(e){return g(t.concat(n(e,function(e){const r=_(e);let n=t.from(a.encode(r.code));return e.length>1&&(n=t.concat([n,e[1]])),n})))}function p(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;return a.decode(t)+a.decode.bytes}function d(e){const t=[];let r=0;for(;re.length)throw v("Invalid address buffer: "+e.toString("hex"));t.push([n,u])}return t}function y(e){return h(f(u(e=b(e))))}function g(e){const r=m(e);if(r)throw r;return t.from(e)}function m(e){try{d(e)}catch(e){return e}}function b(e){return"/"+i(e.trim().split("/")).join("/")}function v(e){return new Error("Error parsing address: "+e)}function _(e){return s(e[0])}e.exports={stringToStringTuples:u,stringTuplesToString:c,tuplesToStringTuples:l,stringTuplesToTuples:f,bufferToTuples:d,tuplesToBuffer:h,bufferToString:function(e){return c(l(d(e)))},stringToBuffer:y,fromString:function(e){return y(e)},fromBuffer:g,validateBuffer:m,isValidBuffer:function(e){return void 0===m(e)},cleanPath:b,ParseError:v,protoFromTuple:_,sizeForAddr:p}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(137),i=r(138),o=r(306),s=r(14),a=r(20);function u(e,r){return r instanceof t?u.toString(e,r):u.toBuffer(e,r)}function c(e){if(!e.isValid())throw new Error("invalid ip address");return n.toBuffer(e.address)}e.exports=u,u.toString=function(e,t){switch((e=o(e)).code){case 4:case 41:return n.toString(t);case 6:case 17:case 33:case 132:return function(e){return e.readUInt16BE(0)}(t);case 54:case 55:case 56:return function(e){const t=a.decode(e);if((e=e.slice(a.decode.bytes)).length!==t)throw new Error("inconsistent lengths");return e.toString()}(t);case 421:return function(e){const t=a.decode(e),r=e.slice(a.decode.bytes);if(r.length!==t)throw new Error("inconsistent lengths");return s.encode(r)}(t);default:return t.toString("hex")}},u.toBuffer=function(e,r){switch((e=o(e)).code){case 4:return c(new i.Address4(r));case 41:return c(new i.Address6(r));case 6:case 17:case 33:case 132:return function(e){const r=t.alloc(2);return r.writeUInt16BE(e,0),r}(parseInt(r,10));case 54:case 55:case 56:return function(e){const r=t.from(e),n=t.from(a.encode(r.length));return t.concat([n,r])}(r);case 421:return function(e){const r=t.from(s.decode(e)),n=t.from(a.encode(r.length));return t.concat([n,r])}(r);default:return t.from(r,"hex")}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(47).Connection,i=r(560),o=r(142),s=r(30),a=r(4),u=r(143),c=r(310),f=r(196),l=r(1),h=l("libp2p:circuit:dialer");h.err=l("libp2p:circuit:error:dialer");const p=r(311),d=r(144);e.exports=class{constructor(e,t){this.swarm=e,this.relayPeers=new Map,this.options=t,this.utils=u(e)}dial(e,t){t=t||(()=>{});const r=e.toString();if(!r.includes("/p2p-circuit"))return h.err("invalid circuit address"),t(new Error("invalid circuit address"));const i=r.split("p2p-circuit"),s="/"===i[0]?null:o(i[0]),a=o(i[1]||i[0]),u=new n;return setImmediate(this._dialPeer.bind(this),a,s,(e,r)=>{if(e)return h.err(e),t(e);u.setInnerConn(r),t(null,u)}),u}canHop(e,t){if(t=s(t||(()=>{})),!this.relayPeers.get(this.utils.getB58String(e))){let r;a([t=>this._dialRelay(e,t),(e,t)=>{r=e,t()},e=>r.write(d.CircuitRelay.encode({type:d.CircuitRelay.Type.CAN_HOP}),e),e=>r.read(e),(t,r)=>{if(d.CircuitRelay.decode(t).code!==d.CircuitRelay.Status.SUCCESS)return h(`HOP not supported, skipping - ${this.utils.getB58String(e)}`);h(`HOP supported adding as relay - ${this.utils.getB58String(e)}`),this.relayPeers.set(this.utils.getB58String(e),e),r(null)}],t)}return t(null)}_dialPeer(e,t,r){if(i(t)&&(r=t,t=null),r||(r=(()=>{})),e=o(e),t)return this._negotiateRelay(t,e,(e,t)=>e?(h.err("An error has occurred negotiating the relay connection",e),r(e)):r(null,t));{const t=Array.from(this.relayPeers.values());let n=i=>{if(!i){let e="no relay peers were found or all relays failed to dial";return h.err(e),r(e)}return this._negotiateRelay(i,e,(e,i)=>{if(e)return h.err(e),n(t.shift());r(null,i)})};n(t.shift())}}_negotiateRelay(e,t,r){t=o(t);const i=this.swarm._peerInfo.multiaddrs.toArray();let s;a([t=>e instanceof n?t(null,new c(e)):this._dialRelay(this.utils.peerInfoFromMa(e),t),(e,t)=>{s=e,t(null)},e=>{h(`negotiating relay for peer ${t.getPeerId()}`),s.write(d.CircuitRelay.encode({type:d.CircuitRelay.Type.HOP,srcPeer:{id:this.swarm._peerInfo.id.id,addrs:i.map(e=>e.buffer)},dstPeer:{id:f.createFromB58String(t.getPeerId()).id,addrs:[t.buffer]}}),e)},e=>s.read(e),(e,t)=>{const r=d.CircuitRelay.decode(e);return r.type!==d.CircuitRelay.Type.STATUS?t(new Error("Got invalid message type - "+`expected ${d.CircuitRelay.Type.STATUS} got ${r.type}`)):r.code!==d.CircuitRelay.Status.SUCCESS?t(new Error(`Got ${r.code} error code trying to dial over relay`)):void t(null,new n(s.rest()))}],r)}_dialRelay(e,t){t=s(t||(()=>{})),this.swarm.dial(e,p.relay,s((e,r)=>{if(e)return h.err(e),t(e);t(null,new c(r))}))}}},function(e,t,r){"use strict";const n=r(566),i=r(1245),o=r(1247);(t=e.exports).aes=i,t.hmac=n,t.keys=o,t.randomBytes=r(571),t.pbkdf2=r(1258)},function(e,t,r){"use strict";e.exports={SHA1:20,SHA256:32,SHA512:64}},function(e,t,r){"use strict";const n=r(1246),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(59);e.exports={createCipheriv:n.createCipheriv,createDecipheriv:n.createDecipheriv}},function(e,t,r){"use strict";(function(n){const i=r(10)(r(309)),o=r(16);t=e.exports;const s={rsa:r(1248),ed25519:r(1253),secp256k1:r(61)(i,r(571))};function a(e){return void 0!==s[e.toLowerCase()]}t.supportedKeys=s,t.keysPBM=i,t.keyStretcher=r(1255),t.generateEphemeralKeyPair=r(1256),t.generateKeyPair=((e,t,r)=>{let 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)=>{let 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){"use strict";const n=r(567),i=r(10),o=r(14),s=r(569),a=i(r(309)),u=r(16),c=r(3);class f{constructor(e){this._key=e}verify(e,t,r){h(r),s.hashAndVerify(this._key,t,e,r)}marshal(){return s.utils.jwkToPkix(this._key)}get bytes(){return a.PublicKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}encrypt(e){return this._key.encrypt(e,"RSAES-PKCS1-V1_5")}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(e),n(this.bytes,"sha2-256",e)}}class l{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return s.getRandomValues(new Uint8Array(16))}sign(e,t){h(t),s.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){s.decrypt(this._key,e,t)}marshal(){return s.utils.jwkToPkcs1(this._key)}get bytes(){return a.PrivateKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(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"),h(r),c(()=>{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 h(e){if("function"!=typeof e)throw new Error("callback is required")}e.exports={RsaPublicKey:f,RsaPrivateKey:l,unmarshalRsaPublicKey:function(e){const t=s.utils.pkixToJwk(e);return new f(t)},unmarshalRsaPrivateKey:function(e,t){const r=s.utils.pkcs1ToJwk(e);s.unmarshalPrivateKey(r,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},generateKeyPair:function(e,t){s.generateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},fromJwk:function(e,t){s.unmarshalPrivateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})}}},function(e,t,r){"use strict";(function(t){const n=r(38),i=r(39),o=r(568),s=r(1250),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,256)),shake256:a(u(n.shake_256,512)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(1251),dblSha2256:(e,r)=>{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(40),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;function o(e){if(!i)throw new Error("Please use a browser with webcrypto support");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(41),i=r(568).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(15),i=r(570),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())}),u=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()))}),c=n.define("RSAPublicKey",function(){this.seq().obj(this.key("algorithm").use(u),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=c.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 c.encode({algorithm:{algorithm:"rsa",none:null},subjectPublicKey:{data:f.encode({modulus:s(e.n),publicExponent:s(e.e)},"der")}},"der")}},function(e,t,r){"use strict";(function(t){const n=r(567),i=r(10),o=r(14),s=r(1254),a=i(r(309));class u{constructor(e){this._key=l(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 c{constructor(e,t){this._key=l(e,s.privateKeyLength),this._publicKey=l(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 u(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 l(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:u,Ed25519PrivateKey:c,unmarshalEd25519PrivateKey:function(e,t){try{e=l(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 c(r,n))},unmarshalEd25519PublicKey:function(e){return e=l(e,s.publicKeyLength),new u(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 c(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 c(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(60),i=r(3);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){"use strict";(function(t){const n=r(37),i=r(566),o={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,cipherKeySize:32}};e.exports=((e,r,s,a)=>{const u=o[e];if(!u)return a(new Error("unkown cipherType passed"));if(!r)return a(new Error("unkown hashType passed"));const c=u.keySize,f=u.ivSize,l=t.from("key expansion"),h=2*(f+c+20);i.create(r,s,(e,r)=>{if(e)return a(e);r.digest(l,(e,i)=>{if(e)return a(e);let o=[],s=0;n(()=>s{if(t)return e(t);let a=n.length;s+a>h&&(a=h-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=h/2,n=t.concat(o),i=n.slice(0,r),s=n.slice(r,h),u=e=>({iv:e.slice(0,f),cipherKey:e.slice(f,f+c),macKey:e.slice(f+c)});a(null,{k1:u(i),k2:u(s)})})})})})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(1257);e.exports=((e,t)=>{n.generateEphmeralKeyPair(e,t)})},function(e,t,r){"use strict";(function(e){const n=r(308)(),i=r(307),o=r(15).bignum,s=r(570),a=s.toBase64,u=s.toBn,c={"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 o=(o,s,a)=>{let u;"function"==typeof s&&(a=s,s=void 0),u=s?n.subtle.importKey("jwk",p(t,s),{name:"ECDH",namedCurve:t},!1,["deriveBits"]):Promise.resolve(r.privateKey);const f=Promise.all([n.subtle.importKey("jwk",h(t,o),{name:"ECDH",namedCurve:t},!1,[]),u]);i(f.then(e=>n.subtle.deriveBits({name:"ECDH",namedCurve:t,public:e[0]},e[1],c[t])).then(t=>e.from(t)),a)};return n.subtle.exportKey("jwk",r.publicKey).then(e=>({key:l(e),genSharedKey:o}))}),r)};const f={"P-256":32,"P-384":48,"P-521":66};function l(t){const r=f[t.crv];return e.concat([e.from([4]),u(t.x).toArrayLike(e,"be",r),u(t.y).toArrayLike(e,"be",r)],1+2*r)}function h(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}}function p(e,t){const r=h(e,t.public);return r.d=a(new o(t.private)),r}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(16),i={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};e.exports=function(e,t,r,o,s){const a=i[s];if(!a)throw new Error(`Hash '${s}' is unknown or not supported`);const u=n.pkcs5.pbkdf2(e,t,r,o,a);return n.util.encode64(u)}},function(e,t,r){"use strict";e.exports="\nmessage CircuitRelay {\n\n enum Status {\n SUCCESS = 100;\n HOP_SRC_ADDR_TOO_LONG = 220;\n HOP_DST_ADDR_TOO_LONG = 221;\n HOP_SRC_MULTIADDR_INVALID = 250;\n HOP_DST_MULTIADDR_INVALID = 251;\n HOP_NO_CONN_TO_DST = 260;\n HOP_CANT_DIAL_DST = 261;\n HOP_CANT_OPEN_DST_STREAM = 262;\n HOP_CANT_SPEAK_RELAY = 270;\n HOP_CANT_RELAY_TO_SELF = 280;\n STOP_SRC_ADDR_TOO_LONG = 320;\n STOP_DST_ADDR_TOO_LONG = 321;\n STOP_SRC_MULTIADDR_INVALID = 350;\n STOP_DST_MULTIADDR_INVALID = 351;\n STOP_RELAY_REFUSED = 390;\n MALFORMED_MESSAGE = 400;\n }\n\n enum Type { // RPC identifier, either HOP, STOP or STATUS\n HOP = 1;\n STOP = 2;\n STATUS = 3;\n CAN_HOP = 4;\n }\n\n message Peer {\n required bytes id = 1; // peer id\n repeated bytes addrs = 2; // peer's known addresses\n }\n\n optional Type type = 1; // Type of the message\n\n optional Peer srcPeer = 2; // srcPeer and dstPeer are used when Type is HOP or STATUS\n optional Peer dstPeer = 3;\n\n optional Status code = 4; // Status code, used when Type is STATUS\n}\n"},function(e,t,r){"use strict";const n=r(3),i=r(311),o=r(11).EventEmitter,s=r(142),a=r(78),u=r(1261),c=r(1262),f=r(144),l=r(143),h=r(310),p=r(1),d=p("libp2p:circuit:listener");d.err=p("libp2p:circuit:error:listener"),e.exports=((e,t,r)=>{const p=new o,y=l(e);return p.stopHandler=new u(e),p.hopHandler=new c(e,t.hop),p.listen=((t,o)=>{o=o||(()=>{}),e.handle(i.relay,(e,t)=>{const n=new h(t);n.read((e,t)=>{if(e)return void d.err(e);let i=null;try{i=f.CircuitRelay.decode(t)}catch(e){return y.writeResponse(n,f.CircuitRelay.Status.MALFORMED_MESSAGE)}switch(i.type){case f.CircuitRelay.Type.CAN_HOP:case f.CircuitRelay.Type.HOP:return p.hopHandler.handle(i,n);case f.CircuitRelay.Type.STOP:return p.stopHandler.handle(i,n,r);default:return y.writeResponse(n,f.CircuitRelay.Status.INVALID_MSG_TYPE)}})}),n(()=>p.emit("listen")),o()}),p.close=(t=>{e.unhandle(i.stop),n(()=>p.emit("close")),t()}),p.getAddrs=(t=>{let r=e._peerInfo.multiaddrs.toArray(),n=r.filter(t=>a.Circuit.matches(t)&&!t.toString().includes(e._peerInfo.id.toB58String()));n.length&&(r=n);let i=[];r.forEach(t=>{const r=`/p2p-circuit/ipfs/${e._peerInfo.id.toB58String()}`;t.toString()!==r?a.Circuit.matches(t)?i.push(t.encapsulate(`/ipfs/${e._peerInfo.id.toB58String()}`)):t.getPeerId()?i.push(s("/p2p-circuit").encapsulate(t)):i.push(s("/p2p-circuit").encapsulate(`${t}/ipfs/${e._peerInfo.id.toB58String()}`)):i.push(s(r))}),t(null,i)}),p})},function(e,t,r){"use strict";const n=r(3),i=r(11).EventEmitter,o=r(47).Connection,s=r(143),a=r(51),u=r(196),c=r(144),f=r(49),l=r(1),h=l("libp2p:circuit:stop");h.err=l("libp2p:circuit:error:stop");function p(e){return"string"==typeof e?u.createFromB58String(e):u.createFromBytes(e)}e.exports=class extends i{constructor(e){super(),this.swarm=e,this.utils=s(e)}handle(e,t,r){r=r||(()=>{}),f([r=>this.utils.validateAddrs(e,t,c.CircuitRelay.Type.STOP,r),e=>this.utils.writeResponse(t,c.CircuitRelay.Status.Success,e)],i=>{if(i)return r(),h(i);const s=new a(p(e.srcPeer.id));e.srcPeer.addrs.forEach(e=>s.multiaddrs.add(e));const u=new o(t.rest());u.setPeerInfo(s),n(()=>this.emit("connection",u)),r(u)})}}},function(e,t,r){"use strict";r(572),r(2);const n=r(8),i=r(1),o=r(51),s=r(196),a=r(11).EventEmitter,u=r(30),c=r(143),f=r(310),l=r(1263),h=r(144),p=r(142),d=r(311),y=i("libp2p:swarm:circuit:relay");y.err=i("libp2p:swarm:circuit:error:relay");e.exports=class extends a{constructor(e,t){super(),this.swarm=e,this.peerInfo=this.swarm._peerInfo,this.utils=c(e),this.config=l({active:!1,enabled:!1},t,(e,t)=>void 0!==t&&t),this.active=this.config.active}handle(e,t){if(!this.config.enabled)return this.utils.writeResponse(t,h.CircuitRelay.Status.HOP_CANT_SPEAK_RELAY);if(e.type===h.CircuitRelay.Type.CAN_HOP)return this.utils.writeResponse(t,h.CircuitRelay.Status.SUCCESS);if(s.createFromBytes(e.dstPeer.id).toB58String()===this.peerInfo.id.toB58String())return this.utils.writeResponse(t,h.CircuitRelay.Status.HOP_CANT_RELAY_TO_SELF);const r=s.createFromBytes(e.dstPeer.id).toB58String();if(!e.dstPeer.addrs.length){const t=p(`/p2p-circuit/ipfs/${r}`).buffer;e.dstPeer.addrs.push(t)}this.utils.validateAddrs(e,t,h.CircuitRelay.Type.HOP,n=>{if(n)return y(n);let i;try{if(!(i=this.swarm._peerBook.get(r)).isConnected()&&!this.active)throw new Error("No Connection to peer")}catch(n){if(!this.active)return y.err(n),setImmediate(()=>this.emit("circuit:error",n)),this.utils.writeResponse(t,h.CircuitRelay.Status.HOP_NO_CONN_TO_DST)}return this._circuit(t.rest(),e,e=>{e&&(y.err(e),setImmediate(()=>this.emit("circuit:error",e))),setImmediate(()=>this.emit("circuit:success"))})})}_circuit(e,t,r){this._dialPeer(t.dstPeer,(i,o)=>{const s=new f(e);return i?(this.utils.writeResponse(s,h.CircuitRelay.Status.HOP_CANT_DIAL_DST),n(n.empty(),s.rest()),y.err(i),r(i)):this.utils.writeResponse(s,h.CircuitRelay.Status.SUCCESS,i=>{if(i)return y.err(i),r(i);const a=new f(o),u=Object.assign({},t,{type:h.CircuitRelay.Type.STOP});a.write(h.CircuitRelay.encode(u),t=>{if(t){const i=new f(e);return this.utils.writeResponse(i,h.CircuitRelay.Status.HOP_CANT_OPEN_DST_STREAM),n(n.empty(),i.rest()),y.err(t),r(t)}a.read((e,t)=>{if(e)return y.err(e),r(e);const i=h.CircuitRelay.decode(t),o=s.rest();i.code===h.CircuitRelay.Status.SUCCESS?(n(o,a.rest(),o),r()):n(n.empty(),o)})})})})}_dialPeer(e,t){const r=new o(s.createFromBytes(e.id));e.addrs.forEach(e=>r.multiaddrs.add(e)),this.swarm.dial(r,d.relay,u((e,r)=>{if(e)return y.err(e),t(e);t(null,r)}))}}},function(e,t,r){var n=r(1264),i=r(1271),o=r(1279),s=i(function(e,t,r,i){n(t,o(t),e,i)});e.exports=s},function(e,t,r){var n=r(1265),i=r(573);e.exports=function(e,t,r,o){var s=!r;r||(r={});for(var a=-1,u=t.length;++a1?r[o-1]:void 0,a=o>2?r[2]:void 0;for(s=e.length>3&&"function"==typeof s?(o--,s):void 0,a&&i(r[0],r[1],a)&&(s=o<3?void 0:s,o=1),t=Object(t);++n0){if(++t>=r)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}},function(e,t,r){var n=r(313),i=r(89),o=r(362),s=r(121);e.exports=function(e,t,r){if(!s(r))return!1;var a=typeof t;return!!("number"==a?i(r)&&o(t,r.length):"string"==a&&t in r)&&n(r[t],e)}},function(e,t,r){var n=r(360),i=r(1280),o=r(89);e.exports=function(e){return o(e)?n(e,!0):i(e)}},function(e,t,r){var n=r(121),i=r(363),o=r(1281),s=Object.prototype.hasOwnProperty;e.exports=function(e){if(!n(e))return o(e);var t=i(e),r=[];for(var a in e)("constructor"!=a||!t&&s.call(e,a))&&r.push(a);return r}},function(e,t){e.exports=function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}},function(e,t,r){"use strict";(function(n){const i=r(12),o=r(1283),s=r(17),a=r(4);class u{constructor(e,t,r){s(n.isBuffer(e),"invalid id provided"),t&&r&&s(t.public.bytes.equals(r.bytes),"inconsistent arguments"),this._id=e,this._idB58String=i.toB58String(this.id),this._privKey=t,this._pubKey=r}get id(){return this._id}set id(e){throw new Error("Id is immutable")}get privKey(){return this._privKey}set privKey(e){this._privKey=e}get pubKey(){return this._pubKey?this._pubKey:this._privKey?this._privKey.public:void 0}set pubKey(e){this._pubKey=e}marshalPubKey(){if(this.pubKey)return o.keys.marshalPublicKey(this.pubKey)}marshalPrivKey(){if(this.privKey)return o.keys.marshalPrivateKey(this.privKey)}toPrint(){return this.toJSON()}toJSON(){return{id:this.toB58String(),privKey:c(this.marshalPrivKey()),pubKey:c(this.marshalPubKey())}}toHexString(){return i.toHexString(this.id)}toBytes(){return this.id}toB58String(){return this._idB58String}isEqual(e){if(n.isBuffer(e))return this.id.equals(e);if(e.id)return this.id.equals(e.id);throw new Error("not valid Id")}isValid(e){this.privKey&&this.privKey.public&&this.privKey.public.bytes&&n.isBuffer(this.pubKey.bytes)&&this.privKey.public.bytes.equals(this.pubKey.bytes)?e():e(new Error("Keys not match"))}}function c(e){if(e)return e.toString("base64")}(t=e.exports=u).create=function(e,t){"function"==typeof e&&(t=e,e={}),(e=e||{}).bits=e.bits||2048,a([t=>o.keys.generateKeyPair("RSA",e.bits,t),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n))})},t.createFromHexString=function(e){return new u(i.fromHexString(e))},t.createFromBytes=function(e){return new u(e)},t.createFromB58String=function(e){return new u(i.fromB58String(e))},t.createFromPubKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r;try{let i=e;if("string"==typeof i&&(i=n.from(e,"base64")),!n.isBuffer(i))throw new Error("Supplied key is neither a base64 string nor a buffer");r=o.keys.unmarshalPublicKey(i)}catch(e){return t(e)}r.hash((e,n)=>{if(e)return t(e);t(null,new u(n,null,r))})},t.createFromPrivKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r=e;try{if("string"==typeof r&&(r=n.from(e,"base64")),!n.isBuffer(r))throw new Error("Supplied key is neither a base64 string nor a buffer")}catch(e){return t(e)}a([e=>o.keys.unmarshalPrivateKey(r,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n,n.public))})},t.createFromJSON=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r,s,c,f;try{r=i.fromB58String(e.id),s=e.privKey&&n.from(e.privKey,"base64"),c=e.pubKey&&n.from(e.pubKey,"base64"),f=c&&o.keys.unmarshalPublicKey(c)}catch(e){return t(e)}s?a([e=>o.keys.unmarshalPrivateKey(s,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)}),(e,t,r)=>{f?f.hash((n,i)=>{r(n,e,t,i)}):r(null,e,t)}],(e,n,i,o)=>e?t(e):f&&!n.equals(o)?t(new Error("Public and private key do not match")):r&&!n.equals(r)?t(new Error("Id and private key do not match")):void t(null,new u(r,i,f))):t(null,new u(r,null,f))},t.isPeerId=function(e){return Boolean("object"==typeof e&&e._id&&e._idB58String)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(578),i=r(1285),o=r(1287);(t=e.exports).aes=i,t.hmac=n,t.keys=o,t.randomBytes=r(583),t.pbkdf2=r(1298)},function(e,t,r){"use strict";e.exports={SHA1:20,SHA256:32,SHA512:64}},function(e,t,r){"use strict";const n=r(1286),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(59);e.exports={createCipheriv:n.createCipheriv,createDecipheriv:n.createDecipheriv}},function(e,t,r){"use strict";(function(n){const i=r(10)(r(316)),o=r(16);t=e.exports;const s={rsa:r(1288),ed25519:r(1293),secp256k1:r(61)(i,r(583))};function a(e){return void 0!==s[e.toLowerCase()]}t.supportedKeys=s,t.keysPBM=i,t.keyStretcher=r(1295),t.generateEphemeralKeyPair=r(1296),t.generateKeyPair=((e,t,r)=>{let 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)=>{let 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){"use strict";const n=r(579),i=r(10),o=r(14),s=r(581),a=i(r(316)),u=r(16),c=r(3);class f{constructor(e){this._key=e}verify(e,t,r){h(r),s.hashAndVerify(this._key,t,e,r)}marshal(){return s.utils.jwkToPkix(this._key)}get bytes(){return a.PublicKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}encrypt(e){return this._key.encrypt(e,"RSAES-PKCS1-V1_5")}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(e),n(this.bytes,"sha2-256",e)}}class l{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return s.getRandomValues(new Uint8Array(16))}sign(e,t){h(t),s.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){s.decrypt(this._key,e,t)}marshal(){return s.utils.jwkToPkcs1(this._key)}get bytes(){return a.PrivateKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(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"),h(r),c(()=>{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 h(e){if("function"!=typeof e)throw new Error("callback is required")}e.exports={RsaPublicKey:f,RsaPrivateKey:l,unmarshalRsaPublicKey:function(e){const t=s.utils.pkixToJwk(e);return new f(t)},unmarshalRsaPrivateKey:function(e,t){const r=s.utils.pkcs1ToJwk(e);s.unmarshalPrivateKey(r,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},generateKeyPair:function(e,t){s.generateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},fromJwk:function(e,t){s.unmarshalPrivateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})}}},function(e,t,r){"use strict";(function(t){const n=r(38),i=r(39),o=r(580),s=r(1290),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,256)),shake256:a(u(n.shake_256,512)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(1291),dblSha2256:(e,r)=>{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(40),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;function o(e){if(!i)throw new Error("Please use a browser with webcrypto support");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(41),i=r(580).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(15),i=r(582),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())}),u=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()))}),c=n.define("RSAPublicKey",function(){this.seq().obj(this.key("algorithm").use(u),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=c.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 c.encode({algorithm:{algorithm:"rsa",none:null},subjectPublicKey:{data:f.encode({modulus:s(e.n),publicExponent:s(e.e)},"der")}},"der")}},function(e,t,r){"use strict";(function(t){const n=r(579),i=r(10),o=r(14),s=r(1294),a=i(r(316));class u{constructor(e){this._key=l(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 c{constructor(e,t){this._key=l(e,s.privateKeyLength),this._publicKey=l(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 u(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 l(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:u,Ed25519PrivateKey:c,unmarshalEd25519PrivateKey:function(e,t){try{e=l(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 c(r,n))},unmarshalEd25519PublicKey:function(e){return e=l(e,s.publicKeyLength),new u(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 c(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 c(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(60),i=r(3);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){"use strict";(function(t){const n=r(37),i=r(578),o={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,cipherKeySize:32}};e.exports=((e,r,s,a)=>{const u=o[e];if(!u)return a(new Error("unkown cipherType passed"));if(!r)return a(new Error("unkown hashType passed"));const c=u.keySize,f=u.ivSize,l=t.from("key expansion"),h=2*(f+c+20);i.create(r,s,(e,r)=>{if(e)return a(e);r.digest(l,(e,i)=>{if(e)return a(e);let o=[],s=0;n(()=>s{if(t)return e(t);let a=n.length;s+a>h&&(a=h-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=h/2,n=t.concat(o),i=n.slice(0,r),s=n.slice(r,h),u=e=>({iv:e.slice(0,f),cipherKey:e.slice(f,f+c),macKey:e.slice(f+c)});a(null,{k1:u(i),k2:u(s)})})})})})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(1297);e.exports=((e,t)=>{n.generateEphmeralKeyPair(e,t)})},function(e,t,r){"use strict";(function(e){const n=r(315)(),i=r(314),o=r(15).bignum,s=r(582),a=s.toBase64,u=s.toBn,c={"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 o=(o,s,a)=>{let u;"function"==typeof s&&(a=s,s=void 0),u=s?n.subtle.importKey("jwk",p(t,s),{name:"ECDH",namedCurve:t},!1,["deriveBits"]):Promise.resolve(r.privateKey);const f=Promise.all([n.subtle.importKey("jwk",h(t,o),{name:"ECDH",namedCurve:t},!1,[]),u]);i(f.then(e=>n.subtle.deriveBits({name:"ECDH",namedCurve:t,public:e[0]},e[1],c[t])).then(t=>e.from(t)),a)};return n.subtle.exportKey("jwk",r.publicKey).then(e=>({key:l(e),genSharedKey:o}))}),r)};const f={"P-256":32,"P-384":48,"P-521":66};function l(t){const r=f[t.crv];return e.concat([e.from([4]),u(t.x).toArrayLike(e,"be",r),u(t.y).toArrayLike(e,"be",r)],1+2*r)}function h(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}}function p(e,t){const r=h(e,t.public);return r.d=a(new o(t.private)),r}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(16),i={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};e.exports=function(e,t,r,o,s){const a=i[s];if(!a)throw new Error(`Hash '${s}' is unknown or not supported`);const u=n.pkcs5.pbkdf2(e,t,r,o,a);return n.util.encode64(u)}},function(e,t,r){"use strict";const n=r(304),i=r(47).Connection,o=r(3),s=r(565),a=r(4),u=r(1)("libp2p:switch:dial"),c=r(577),f=r(584),l="Unexpected end of input from reader.";function h(e,t,r,n){e.select(t,(e,t)=>{if(!0===e)return n(new Error(l));r(e,t)})}function p(e,t,r,n){e.handle(t,e=>{if(!0===e)return n(new Error(l));r(e)})}class d{constructor(e,t,r,n,i){this.switch=e,this.peerInfo=t,this.ourPeerInfo=r,this.protocol=n,this.callback=i}dial(){const e=new i;return e.setPeerInfo(this.peerInfo),a([e=>{this._establishConnection(e)},(t,r)=>{if(t)return e.setPeerInfo(this.peerInfo),e.setInnerConn(t),r(null,e);r(null)}],(e,t)=>{if(e&&e.message===l||!0===e)return u("Connection dropped for %s",this.peerInfo.id.toB58String()),this.callback(null,null);this.callback(e,t)}),e}_establishConnection(e){const t=this.peerInfo.id.toB58String();if(u("dialing %s",t),t===this.ourPeerInfo.id.toB58String())return e(new Error("A node cannot dial itself"));a([e=>{this._createBaseConnection(t,e)},(e,r)=>{this._createMuxedConnection(e,t,r)},(e,t)=>{if(!this.protocol)return t();e.newStream?e.newStream((e,r)=>{if(e)return t(e);this._performProtocolHandshake(r,t)}):this._performProtocolHandshake(e,t)}],(t,r)=>{e(t,r)})}_createBaseConnection(e,t){const r=this.switch.conns[e];return this.switch.muxedConns[e]?t(null,null):r?(this.switch.conns[e]=void 0,t(null,r)):void a([e=>{this._attemptDial(e)},(e,t)=>{this._createPrivateConnection(e,t)},(e,t)=>{this._encryptConnection(e,t)}],(e,r)=>{if(e)return t(e);t(null,r)})}_createPrivateConnection(e,t){if(null===this.switch.protector)return t(null,e);const r=this.switch.protector.protect(e,e=>{if(e)return t(e);r.setPeerInfo(this.peerInfo),t(null,r)})}_createMuxedConnection(e,t,r){const n=this.switch.muxedConns[t];if(n)return r(null,n.muxer);e.setPeerInfo(this.peerInfo),this._attemptMuxerUpgrade(e,t,(n,i)=>n&&!this.protocol?(this.switch.conns[t]=e,r(null,null)):n?(u("muxer upgrade failed with error",n),r(null,e)):void r(null,i),r)}_attemptMuxerUpgrade(e,t,r,i){const s=Object.keys(this.switch.muxers);if(0===s.length)return r(new Error("no muxers available"));const a=new n.Dialer;p(a,e,e=>{if(e)return r(new Error("multistream not supported"));const n=e=>{u("selecting %s",e),h(a,e,(i,a)=>{if(i)return 0===s.length?r(new Error("could not upgrade to stream muxing")):n(s.shift());const c=f(null,e,a,this.switch.observer),l=this.switch.muxers[e].dialer(c);this.switch.muxedConns[t]={muxer:l},l.once("close",()=>{delete this.switch.muxedConns[t],this.peerInfo.disconnect(),this.switch._peerInfo.disconnect(),u(`closed connection to ${t}`),o(()=>this.switch.emit("peer-mux-closed",this.peerInfo))}),l.on("stream",e=>{e.setPeerInfo(this.peerInfo),this.switch.protocolMuxer(null)(e)}),o(()=>this.switch.emit("peer-mux-established",this.peerInfo)),r(null,l)},i)};n(s.shift())},i)}_attemptDial(e){if(!this.switch.hasTransports())return e(new Error("No transports registered, dial not possible"));const t=this.switch.availableTransports(this.peerInfo),r=Boolean(this.switch.transports[s.tag]);let n=!1;const i=o=>{let a=o;const c=this.peerInfo.id.toB58String();if(!a){if(!r){const t=`Circuit not enabled and all transports failed to dial peer ${c}!`;return e(new Error(t))}if(n)return e(new Error(`No available transports to dial peer ${c}!`));u("Falling back to dialing over circuit"),this.peerInfo.multiaddrs.add(`/p2p-circuit/ipfs/${c}`),n=!0,a=s.tag}u(`dialing transport ${a}`),this.switch.transport.dial(a,this.peerInfo,(r,n)=>{if(r)return u(r),i(t.shift());const o=f(a,null,n,this.switch.observer);e(null,o)})};i(t.shift())}_encryptConnection(e,t){const r=new n.Dialer;p(r,e,e=>{if(e)return t(e);const n=this.switch._peerInfo.id;u("selecting crypto: %s",this.switch.crypto.tag),h(r,this.switch.crypto.tag,(e,r)=>{if(e)return t(e);const i=f(null,this.switch.crypto.tag,r,this.switch.observer),o=this.switch.crypto.encrypt(n,i,this.peerInfo.id,e=>{if(e)return t(e);o.setPeerInfo(this.peerInfo),t(null,o)})},t)},t)}_performProtocolHandshake(e,t){this.protocol||t();const r=new n.Dialer;p(r,e,e=>{if(e)return t(e);h(r,this.protocol,(e,r)=>{if(e)return u("could not perform protocol handshake: ",e),t(e);const n=f(null,this.protocol,r,this.switch.observer);t(null,n)},t)},t)}}e.exports=function(e){return(t,r,n)=>{"function"==typeof r&&(n=r,r=null),n=n||function(){};const i=c(t,e._peerBook);return new d(e,i,e._peerInfo,r,n).dial()}}},function(e,t,r){"use strict";const n=r(304),i=r(584),o=r(1)("libp2p:switch:protocol-muxer");e.exports=function(e,t){return r=>s=>{const a=r?i(r,null,s,t):s,u=new n.Listener;Object.keys(e).forEach(r=>{if(!r)return;u.addHandler(r,(r,n)=>{o(`registering handler with protocol ${r}`);const s=e[r];if(s){const e=s&&s.handlerFunc;e&&e(s,i(null,r,n,t))}},e[r].matchFunc)}),u.handle(a,e=>{})}}},function(e,t,r){"use strict";const n=r(8),i=r(11);e.exports=(e=>{const t=Object.assign(new i,{incoming:r("in"),outgoing:r("out")});return e.on("peer-mux-established",e=>{t.emit("peer:connected",e.id.toB58String())}),e.on("peer-mux-closed",e=>{t.emit("peer:closed",e.id.toB58String())}),t;function r(e){return(t,r,i)=>n.map(n=>(o(i,t,r,e,n.length),n))}function o(e,r,n,i,o){e.then(e=>{if(e){const s=e.id.toB58String();setImmediate(()=>t.emit("message",s,r,n,i,o))}})}})},function(e,t,r){"use strict";const n=r(11),i=r(1303),o=r(1304),s={computeThrottleMaxQueueSize:1e3,computeThrottleTimeout:2e3,movingAverageIntervals:[6e4,3e5,9e5],maxOldPeersRetention:50},a=["dataReceived","dataSent"],u={in:"dataReceived",out:"dataSent"};e.exports=((e,t)=>{const r=Object.assign({},s,t),c=new i(a,r),f=Object.assign(new n,{stop:function(){c.stop();for(let e of h.values())e.stop();for(let e of p.values())e.stop()},global:c,peers:()=>Array.from(h.keys()),forPeer:e=>h.get(e)||l.get(e),transports:()=>Array.from(p.keys()),forTransport:e=>p.get(e),protocols:()=>Array.from(d.keys()),forProtocol:e=>d.get(e)});c.on("update",y);const l=o(r.maxOldPeersRetention),h=new Map,p=new Map,d=new Map;return e.on("message",(e,t,n,o,s)=>{const f=u[o];if(t){c.push(f,s);let t=h.get(e);t||((t=l.get(e))?l.delete(e):t=new i(a,r),t.on("update",y),t.start(),h.set(e,t)),t.push(f,s)}if(t){let e=p.get(t);e||((e=new i(a,r)).on("update",y),p.set(t,e)),e.push(f,s)}if(n){let e=d.get(n);e||((e=new i(a,r)).on("update",y),d.set(n,e)),e.push(f,s)}}),e.on("peer:closed",e=>{const t=h.get(e);t&&(t.removeListener("update",y),t.stop(),h.delete(e),l.set(e,t))}),f;function y(){f.emit("update")}})},function(e,t,r){"use strict";const n=r(11),i=r(122).Big,o=r(508);e.exports=class extends n{constructor(e,t){super(),this._options=t,this._queue=[],this._stats={},this._frequencyLastTime=Date.now(),this._frequencyAccumulators={},this._movingAverages={},this._update=this._update.bind(this),e.forEach(e=>{this._stats[e]=i(0),this._movingAverages[e]={},this._options.movingAverageIntervals.forEach(t=>{(this._movingAverages[e][t]=o(t)).push(this._frequencyLastTime,0)})})}start(){this._queue.length&&this._resetComputeTimeout()}stop(){this._timeout&&clearTimeout(this._timeout)}get snapshot(){return Object.assign({},this._stats)}get movingAverages(){return Object.assign({},this._movingAverages)}push(e,t){this._queue.push([e,t,Date.now()]),this._resetComputeTimeout()}_resetComputeTimeout(){this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout(this._update,this._nextTimeout())}_nextTimeout(){const e=this._queue.length/this._options.computeThrottleMaxQueueSize;return Math.max(this._options.computeThrottleTimeout*(1-e),0)}_update(){if(this._timeout=null,this._queue.length){let e;for(;this._queue.length;){const t=e=this._queue.shift();this._applyOp(t)}this._updateFrequency(e[2]),this.emit("update",this._stats)}}_updateFrequency(e){const t=e-this._frequencyLastTime;Object.keys(this._stats).forEach(r=>{this._updateFrequencyFor(r,t,e)}),this._frequencyLastTime=e}_updateFrequencyFor(e,t,r){const n=this._frequencyAccumulators[e]||0;this._frequencyAccumulators[e]=0;const i=n/t*1e3;let s=this._movingAverages[e];s||(s=this._movingAverages[e]={}),this._options.movingAverageIntervals.forEach(e=>{let t=s[e];t||(t=s[e]=o(e)),t.push(r,i)})}_applyOp(e){const t=e[0],r=e[1];if("number"!=typeof r)throw new Error("invalid increment number:",r);let n;n=this._stats.hasOwnProperty(t)?this._stats[t]:this._stats[t]=i(0),this._stats[t]=n.plus(r),this._frequencyAccumulators[t]||(this._frequencyAccumulators[t]=0),this._frequencyAccumulators[t]+=r}}},function(e,t,r){"use strict";const n=r(1305);e.exports=(e=>{const t=n(e);return t.delete=t.remove,t})},function(e,t){e.exports=function(e){if(!e)throw Error("hashlru must have a max value, of type number, greater than 0");var t=0,r=Object.create(null),n=Object.create(null);function i(i,o){r[i]=o,++t>=e&&(t=0,n=r,r=Object.create(null))}return{has:function(e){return void 0!==r[e]||void 0!==n[e]},remove:function(e){void 0!==r[e]&&(r[e]=void 0),void 0!==n[e]&&(n[e]=void 0)},get:function(e){var t=r[e];return void 0!==t?t:void 0!==(t=n[e])?(i(e,t),t):void 0},set:function(e,t){void 0!==r[e]?r[e]=t:i(e,t)},clear:function(){r=Object.create(null),n=Object.create(null)}}}},function(e,t,r){"use strict";e.exports.PROTECTOR_REQUIRED="No protector provided with private network enforced"},function(e,t,r){"use strict";const n=r(1308);(t=e.exports=r(1309)).mount=n.mount,t.unmount=n.unmount},function(e,t,r){"use strict";const n=r(8),i=r(100),o=r(317),s=o.PROTOCOL,a=o.PING_LENGTH,u=r(1),c=u("libp2p-ping");c.error=u("libp2p-ping:error"),(t=e.exports).mount=function(e){e.handle(s,(e,t)=>{const r=i({timeout:0}),o=r.handshake;n(t,r,t),function e(){o.read(a,(t,r)=>{if(!0!==t)return t?c.error(t):(o.write(r),e())})}()})},t.unmount=function(e){e.unhandle(s)}},function(e,t,r){"use strict";const n=r(11).EventEmitter,i=r(8),o=r(100),s=r(317),a=r(1310).rnd,u=r(1),c=u("libp2p-ping");c.error=u("libp2p-ping:error");const f=s.PROTOCOL,l=s.PING_LENGTH;e.exports=class extends n{constructor(e,t){super(),this._stopped=!1,this.peer=t,this.swarm=e}start(){c("dialing %s to %s",f,this.peer.id.toB58String()),this.swarm.dial(this.peer,f,(e,t)=>{if(e)return this.emit("error",e);const r=o({timeout:0});this.shake=r.handshake,i(r,t,r);const n=this;!function e(){let t=new Date,r=a(l);n.shake.write(r),n.shake.read(l,(i,o)=>{let s=new Date;if(i||!r.equals(o)){const e=new Error("Received wrong ping ack");return n.emit("error",e)}n.emit("ping",s-t),n._stopped||e()})}()})}stop(){!this._stopped&&this.shake&&(this._stopped=!0,i(i.empty(),this.shake.rest()))}}},function(e,t,r){"use strict";const n=r(111),i=r(317);e.exports.rnd=(e=>(e||(e=i.PING_LENGTH),n.randomBytes(e)))},function(e,t,r){"use strict";const n=r(11),i=r(1312).default,o=r(1)("libp2p:connection-manager"),s={maxPeers:1/0,minPeers:0,maxData:1/0,maxSentData:1/0,maxReceivedData:1/0,maxEventLoopDelay:1/0,pollInterval:2e3,movingAverageInterval:6e4,defaultPeerValue:1};function a(e,t){return e[1]-t[1]}function u(e){return e.name.toLowerCase()}e.exports=class extends n{constructor(e,t){if(super(),this._libp2p=e,this._options=Object.assign({},s,t),this._options.maxPeersPerProtocol=function(e){return e||(e={}),Object.keys(e).forEach(t=>{const r=e[t];delete e[t],e[t.toLowerCase()]=r}),e}(this._options.maxPeersPerProtocol),o("options: %j",this._options),this._stats=e.stats,t&&!this._stats)throw new Error("No libp2p.stats");this._peerValues=new Map,this._peers=new Map,this._peerProtocols=new Map,this._peerCountPerProtocol=new Map,this._onStatsUpdate=this._onStatsUpdate.bind(this),this._onPeerConnect=this._onPeerConnect.bind(this),this._onPeerDisconnect=this._onPeerDisconnect.bind(this),this._libp2p.isStarted()?this._onceStarted():this._libp2p.once("start",this._onceStarted.bind(this))}start(){this._stats.on("update",this._onStatsUpdate),this._libp2p.on("peer:connect",this._onPeerConnect),this._libp2p.on("peer:disconnect",this._onPeerDisconnect),this._latencyMonitor=new i({dataEmitIntervalMs:this._options.pollInterval}),this._onLatencyMeasure=this._onLatencyMeasure.bind(this),this._latencyMonitor.on("data",this._onLatencyMeasure)}stop(){this._stats.removeListener("update",this._onStatsUpdate),this._libp2p.removeListener("peer:connect",this._onPeerConnect),this._libp2p.removeListener("peer:disconnect",this._onPeerDisconnect),this._latencyMonitor.removeListener("data",this._onLatencyMeasure)}setPeerValue(e,t){if(t<0||t>1)throw new Error("value should be a number between 0 and 1");e.toB58String&&(e=e.toB58String()),this._peerValues.set(e,t)}_onceStarted(){this._peerId=this._libp2p.peerInfo.id.toB58String()}_onStatsUpdate(){const e=this._stats.global.movingAverages,t=e.dataReceived[this._options.movingAverageInterval].movingAverage();this._checkLimit("maxReceivedData",t);const r=e.dataSent[this._options.movingAverageInterval].movingAverage();this._checkLimit("maxSentData",r);const n=t+r;this._checkLimit("maxData",n),o("stats update",n)}_onPeerConnect(e){const t=e.id.toB58String();o("%s: connected to %s",this._peerId,t),this._peerValues.set(t,this._options.defaultPeerValue),this._peers.set(t,e),this.emit("connected",t),this._checkLimit("maxPeers",this._peers.size),function(e){const t=new Set;return e.multiaddrs.forEach(e=>{e.protos().map(u).forEach(e=>{t.add(e)})}),Array.from(t)}(e).forEach(e=>{this._peerCountPerProtocol[e]||(this._peerCountPerProtocol[e]=0),this._peerCountPerProtocol[e]++;let r=this._peerProtocols[t];r||(r=this._peerProtocols[t]=new Set),r.add(e),this._checkProtocolMaxPeersLimit(e,this._peerCountPerProtocol[e])})}_onPeerDisconnect(e){const t=e.id.toB58String();o("%s: disconnected from %s",this._peerId,t),this._peerValues.delete(t),this._peers.delete(t);const r=this._peerProtocols[t];r&&Array.from(r).forEach(e=>{this._peerCountPerProtocol[e]&&this._peerCountPerProtocol[e]--}),this.emit("disconnected",t)}_onLatencyMeasure(e){this._checkLimit("maxEventLoopDelay",e.avgMs)}_checkLimit(e,t){o("checking limit. current value of %s is %d",e,t),t>this._options[e]&&(o("%s: limit exceeded: %s, %d",this._peerId,e,t),this.emit("limit:exceeded",e,t),this._maybeDisconnectOne())}_checkProtocolMaxPeersLimit(e,t){o("checking protocol limit. current value of %s is %d",e,t),t>this._options.maxPeersPerProtocol[e]&&(o("%s: protocol max peers limit exceeded: %s, %d",this._peerId,e,t),this.emit("limit:exceeded",e,t),this._maybeDisconnectOne())}_maybeDisconnectOne(){if(this._options.minPeers{e&&this.emit("error",e)})}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=r(1313).default},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{},n=t.latencyCheckIntervalMs,i=t.dataEmitIntervalMs,s=t.asyncTestFn,u=t.latencyRandomPercentage;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r);var f=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(r.__proto__||Object.getPrototypeOf(r)).call(this)),l=f;return l.latencyCheckIntervalMs=n||500,l.latencyRandomPercentage=u||10,l._latecyCheckMultiply=l.latencyRandomPercentage/100*2*l.latencyCheckIntervalMs,l._latecyCheckSubtract=l._latecyCheckMultiply/2,l.dataEmitIntervalMs=null===i||0===i?void 0:i||5e3,c("latencyCheckIntervalMs: %s dataEmitIntervalMs: %s",l.latencyCheckIntervalMs,l.dataEmitIntervalMs),l.dataEmitIntervalMs?c("Expecting ~%s events per summary",l.latencyCheckIntervalMs/l.dataEmitIntervalMs):c("Not emitting summaries"),l.asyncTestFn=s,e&&e.hrtime?(c("Using process.hrtime for timing"),l.now=e.hrtime,l.getDeltaMS=function(e){var t=l.now(e);return 1e3*t[0]+t[1]/1e6}):"undefined"!=typeof window&&(0,o.default)(window,"performance.now")?(c("Using performance.now for timing"),l.now=window.performance.now.bind(window.performance),l.getDeltaMS=function(e){return Math.round(l.now()-e)}):(c("Using Date.now for timing"),l.now=Date.now,l.getDeltaMS=function(e){return l.now()-e}),l._latencyData=l._initLatencyData(),"undefined"!=typeof window&&(l._visibilityChangeEmitter=new a.default,l._visibilityChangeEmitter.on("visibilityChange",function(e){e?l._startTimers():(l._emitSummary(),l._stopTimers())})),l._visibilityChangeEmitter&&!l._visibilityChangeEmitter.isVisible()||l._startTimers(),f}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(r,i.default),n(r,[{key:"_startTimers",value:function(){var e=this;this._checkLatencyID||(this._checkLatency(),this.dataEmitIntervalMs&&(this._emitIntervalID=setInterval(function(){return e._emitSummary()},this.dataEmitIntervalMs),(0,s.default)(this._emitIntervalID.unref)&&this._emitIntervalID.unref()))}},{key:"_stopTimers",value:function(){this._checkLatencyID&&(clearTimeout(this._checkLatencyID),this._checkLatencyID=void 0),this._emitIntervalID&&(clearInterval(this._emitIntervalID),this._emitIntervalID=void 0)}},{key:"_emitSummary",value:function(){var e=this.getSummary();e.events>0&&this.emit("data",e)}},{key:"getSummary",value:function(){var e={events:this._latencyData.events,minMs:this._latencyData.minMs,maxMs:this._latencyData.maxMs,avgMs:this._latencyData.events?this._latencyData.totalMs/this._latencyData.events:Number.POSITIVE_INFINITY,lengthMs:this.getDeltaMS(this._latencyData.startTime)};return this._latencyData=this._initLatencyData(),c("Summary: %O",e),e}},{key:"_checkLatency",value:function(){var e=this,t=this,r=Math.random()*t._latecyCheckMultiply-t._latecyCheckSubtract,n={deltaOffset:Math.ceil(t.latencyCheckIntervalMs+r),startTime:t.now()},i=function(){if(e._checkLatencyID){var r=t.getDeltaMS(n.startTime)-n.deltaOffset;t._checkLatency(),t._latencyData.events++,t._latencyData.minMs=Math.min(t._latencyData.minMs,r),t._latencyData.maxMs=Math.max(t._latencyData.maxMs,r),t._latencyData.totalMs+=r,c("MS: %s Data: %O",r,t._latencyData)}};c("localData: %O",n),this._checkLatencyID=setTimeout(function(){t.asyncTestFn?(n.deltaOffset=0,n.startTime=t.now(),t.asyncTestFn(i)):(n.deltaOffset-=1,i())},n.deltaOffset),(0,s.default)(this._checkLatencyID.unref)&&this._checkLatencyID.unref()}},{key:"_initLatencyData",value:function(){return{startTime:this.now(),minMs:Number.POSITIVE_INFINITY,maxMs:Number.NEGATIVE_INFINITY,events:0,totalMs:0}}}]),r}();t.default=f}).call(this,r(7))},function(e,t,r){var n=r(1315),i=r(1342);e.exports=function(e,t){for(var r=0,o=(t=n(t,e)).length;null!=e&&r-1}},function(e,t,r){var n=r(198);e.exports=function(e,t){var r=this.__data__,i=n(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this}},function(e,t,r){var n=r(312)(r(159),"Map");e.exports=n},function(e,t,r){var n=r(199);e.exports=function(e){var t=n(this,e).delete(e);return this.size-=t?1:0,t}},function(e,t){e.exports=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}},function(e,t,r){var n=r(199);e.exports=function(e){return n(this,e).get(e)}},function(e,t,r){var n=r(199);e.exports=function(e){return n(this,e).has(e)}},function(e,t,r){var n=r(199);e.exports=function(e,t){var r=n(this,e),i=r.size;return r.set(e,t),this.size+=r.size==i?0:1,this}},function(e,t,r){var n=r(1341);e.exports=function(e){return null==e?"":n(e)}},function(e,t,r){var n=r(158),i=r(222),o=r(88),s=r(318),a=1/0,u=n?n.prototype:void 0,c=u?u.toString:void 0;e.exports=function e(t){if("string"==typeof t)return t;if(o(t))return i(t,e)+"";if(s(t))return c?c.call(t):"";var r=t+"";return"0"==r&&1/t==-a?"-0":r}},function(e,t,r){var n=r(318),i=1/0;e.exports=function(e){if("string"==typeof e||n(e))return e;var t=e+"";return"0"==t&&1/e==-i?"-0":t}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r({findPeer:(t,r)=>{if(!e._dht)return r(new Error("DHT is not available"));e._dht.findPeer(t,r)}}))},function(e,t,r){"use strict";e.exports=(e=>({findProviders:(t,r,n)=>{if(!e._dht)return n(new Error("DHT is not available"));e._dht.findProviders(t,r,n)},provide:(t,r)=>{if(!e._dht)return r(new Error("DHT is not available"));e._dht.provide(t,r)}}))},function(e,t,r){"use strict";e.exports=(e=>({put:(t,r,n)=>{if(!e._dht)return n(new Error("DHT is not available"));e._dht.put(t,r,n)},get:(t,r)=>{if(!e._dht)return r(new Error("DHT is not available"));e._dht.get(t,r)},getMany(t,r,n){if(!e._dht)return n(new Error("DHT is not available"));e._dht.getMany(t,r,n)}}))},function(e,t,r){"use strict";(function(t){const n=r(3),i=r(1349).NOT_STARTED_YET,o=r(1350);e.exports=(e=>{const r=new o(e);return e._floodSub=r,{subscribe:(t,o,s,a)=>{if("function"==typeof o&&(a=s,s=o,o={}),!e.isStarted()&&!r.started)return n(()=>a(new Error(i)));!function(e){0===r.listenerCount(t)&&r.subscribe(t),r.on(t,s),n(e)}(a)},unsubscribe:(t,n)=>{if(!e.isStarted()&&!r.started)throw new Error(i);r.removeListener(t,n),0===r.listenerCount(t)&&r.unsubscribe(t)},publish:(o,s,a)=>e.isStarted()||r.started?t.isBuffer(s)?(r.publish(o,s),void n(()=>a())):n(()=>a(new Error("data must be a Buffer"))):n(()=>a(new Error(i))),ls:t=>{if(!e.isStarted()&&!r.started)return n(()=>t(new Error(i)));const o=Array.from(r.subscriptions);n(()=>t(null,o))},peers:(t,o)=>{if(!e.isStarted()&&!r.started)return n(()=>o(new Error(i)));"function"==typeof t&&(o=t,t=null);const s=Array.from(r.peers.values()).filter(e=>!t||e.topics.has(t)).map(e=>e.info.id.toB58String());n(()=>o(null,s))},setMaxListeners:e=>r.setMaxListeners(e)}})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";t.NOT_STARTED_YET="The libp2p node is not started yet"},function(e,t,r){"use strict";const n=r(11),i=r(1351),o=r(507),s=r(8),a=r(53),u=r(17),c=r(50),f=r(1353),l=r(1356),h=r(587),p=r(1357),d=r(2).Buffer,y=p.log,g=p.multicodec,m=l.ensureArray,b=r(3);e.exports=class extends n{constructor(e){super(),this.libp2p=e,this.started=!1,this.cache=new i,this.peers=new Map,this.subscriptions=new Set,this._onConnection=this._onConnection.bind(this),this._dialPeer=this._dialPeer.bind(this)}_addPeer(e){const t=e.info.id.toB58String();let r=this.peers.get(t);return r||(y("new peer",t),this.peers.set(t,e),r=e,e.once("close",()=>this._removePeer(e))),++r._references,r}_removePeer(e){const t=e.info.id.toB58String();return y("remove",t,e._references),0==--e._references&&(y("delete peer",t),this.peers.delete(t)),e}_dialPeer(e,t){t=t||function(){};const r=e.id.toB58String(),n=this.peers.get(r);if(n&&n.isConnected)return b(()=>t());y("dialing %s",r),this.libp2p.dialProtocol(e,g,(r,n)=>{if(r)return y.err(r),t();this._onDial(e,n,t)})}_onDial(e,t,r){const n=e.id.toB58String();y("connected",n);const i=this._addPeer(new f(e));i.attachConnection(t),i.sendSubscriptions(this.subscriptions),b(()=>r())}_onConnection(e,t){t.getPeerInfo((e,r)=>{if(e)return y.err("Failed to identify incomming conn",e),s(s.empty(),t);const n=r.id.toB58String(),i=this._addPeer(new f(r));this._processConnection(n,t,i)})}_processConnection(e,t,r){s(t,a.decode(),s.map(e=>h.rpc.RPC.decode(e)),s.drain(t=>this._onRpc(e,t),t=>this._onConnectionEnd(e,r,t)))}_onRpc(e,t){if(!t)return;y("rpc from",e);const r=t.subscriptions,n=t.msgs;if(n&&n.length&&this._processRpcMessages(l.normalizeInRpcMessages(t.msgs)),r&&r.length){const t=this.peers.get(e);t&&t.updateSubscriptions(r)}}_processRpcMessages(e){e.forEach(e=>{const t=l.msgId(e.from,e.seqno.toString());this.cache.has(t)||(this.cache.put(t),this._emitMessages(e.topicIDs,[e]),this._forwardMessages(e.topicIDs,[e]))})}_onConnectionEnd(e,t,r){r&&"socket hang up"!==r.message&&y.err(r),y("connection ended",e,r?r.message:""),this._removePeer(t)}_emitMessages(e,t){e.forEach(e=>{this.subscriptions.has(e)&&t.forEach(t=>{this.emit(e,t)})})}_forwardMessages(e,t){this.peers.forEach(r=>{r.isWritable&&l.anyMatch(r.topics,e)&&(r.sendMessages(l.normalizeOutRpcMessages(t)),y("publish msgs on topics",e,r.info.id.toB58String()))})}start(e){if(this.started)return b(()=>e(new Error("already started")));this.libp2p.handle(g,this._onConnection),this.libp2p.on("peer:connect",this._dialPeer);const t=o(this.libp2p.peerBook.getAll());c(t,(e,t)=>this._dialPeer(e,t),t=>{b(()=>{this.started=!0,e(t)})})}stop(e){if(!this.started)return b(()=>e(new Error("not started yet")));this.libp2p.unhandle(g),this.libp2p.removeListener("peer:connect",this._dialPeer),y("stopping"),c(this.peers.values(),(e,t)=>e.close(t),t=>{if(t)return e(t);y("stopped"),this.peers=new Map,this.subscriptions=new Set,this.started=!1,e()})}publish(e,t){u(this.started,"FloodSub is not started"),y("publish",e,t),e=m(e),t=m(t);const r=this.libp2p.peerInfo.id.toB58String(),n=t.map(t=>{const n=l.randomSeqno();return this.cache.put(l.msgId(r,n)),{from:r,data:t,seqno:new d(n),topicIDs:e}});this._emitMessages(e,n),this._forwardMessages(e,n)}subscribe(e){function t(r){if(r&&r.isWritable)return r.sendSubscriptions(e);const n=()=>{r.removeListener("connection",n),t(r)};r.on("connection",n),r.once("close",()=>r.removeListener("connection",n))}u(this.started,"FloodSub is not started"),(e=m(e)).forEach(e=>this.subscriptions.add(e)),this.peers.forEach(e=>t(e))}unsubscribe(e){function t(r){r&&r.isWritable?r.sendUnsubscriptions(e):b(t.bind(r))}this.started&&((e=m(e)).forEach(e=>this.subscriptions.delete(e)),this.peers.forEach(e=>t(e)))}}},function(e,t,r){"use strict";const n=r(1352);e.exports=function e(t){if(!(this instanceof e))return new e(t);const r=(t=t||{}).validity||30,i=new Map,o=n(()=>{i.forEach((e,t)=>{const n=e.validity||r;(function(e){const t=(new Date).getTime()-e.getTime();return Math.floor(t/1e3)})(e.timestamp)>n&&i.delete(t)})},200);this.put=((e,t,r)=>{this.has(e)||i.set(e,{value:t,timestamp:new Date,validity:r}),o()}),this.get=(e=>{if(i.has(e))return i.get(e).value;throw new Error("key does not exist")}),this.has=(e=>i.has(e))}},function(e,t,r){(function(t){var r="Expected a function",n=NaN,i="[object Symbol]",o=/^\s+|\s+$/g,s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt,f="object"==typeof t&&t&&t.Object===Object&&t,l="object"==typeof self&&self&&self.Object===Object&&self,h=f||l||Function("return this")(),p=Object.prototype.toString,d=Math.max,y=Math.min,g=function(){return h.Date.now()};function m(e,t,n){var i,o,s,a,u,c,f=0,l=!1,h=!1,p=!0;if("function"!=typeof e)throw new TypeError(r);function m(t){var r=i,n=o;return i=o=void 0,f=t,a=e.apply(n,r)}function _(e){var r=e-c;return void 0===c||r>=t||r<0||h&&e-f>=s}function w(){var e=g();if(_(e))return S(e);u=setTimeout(w,function(e){var r=t-(e-c);return h?y(r,s-(e-f)):r}(e))}function S(e){return u=void 0,p&&i?m(e):(i=o=void 0,a)}function k(){var e=g(),r=_(e);if(i=arguments,o=this,c=e,r){if(void 0===u)return function(e){return f=e,u=setTimeout(w,t),l?m(e):a}(c);if(h)return u=setTimeout(w,t),m(c)}return void 0===u&&(u=setTimeout(w,t)),a}return t=v(t)||0,b(n)&&(l=!!n.leading,s=(h="maxWait"in n)?d(v(n.maxWait)||0,t):s,p="trailing"in n?!!n.trailing:p),k.cancel=function(){void 0!==u&&clearTimeout(u),f=0,i=c=o=u=void 0},k.flush=function(){return void 0===u?a:S(g())},k}function b(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function v(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&p.call(e)==i}(e))return n;if(b(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=b(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(o,"");var r=a.test(e);return r||u.test(e)?c(e.slice(2),r?2:8):s.test(e)?n:+e}e.exports=function(e,t,n){var i=!0,o=!0;if("function"!=typeof e)throw new TypeError(r);return b(n)&&(i="leading"in n?!!n.leading:i,o="trailing"in n?!!n.trailing:o),m(e,t,{leading:i,maxWait:t,trailing:o})}}).call(this,r(6))},function(e,t,r){"use strict";const n=r(53),i=r(46),o=r(8),s=r(3),a=r(11),u=r(587).rpc.RPC;e.exports=class extends a{constructor(e){super(),this.info=e,this.conn=null,this.topics=new Set,this.stream=null,this._references=0}get isConnected(){return Boolean(this.conn)}get isWritable(){return Boolean(this.stream)}write(e){if(!this.isWritable){const e=this.info.id.toB58String();throw new Error("No writable connection to "+e)}this.stream.push(e)}attachConnection(e){this.conn=e,this.stream=new i,o(this.stream,n.encode(),e,o.onEnd(()=>{this.conn=null,this.stream=null,this.emit("close")})),this.emit("connection")}_sendRawSubscriptions(e,t){if(0===e.size)return;const r=[];e.forEach(e=>{r.push({subscribe:t,topicCID:e})}),this.write(u.encode({subscriptions:r}))}sendSubscriptions(e){this._sendRawSubscriptions(e,!0)}sendUnsubscriptions(e){this._sendRawSubscriptions(e,!1)}sendMessages(e){this.write(u.encode({msgs:e}))}updateSubscriptions(e){e.forEach(e=>{e.subscribe?this.topics.add(e.topicCID):this.topics.delete(e.topicCID)})}close(e){this._references=1,this.stream&&this.stream.end(),s(()=>{this.conn=null,this.stream=null,this.emit("close"),e()})}}},function(e,t,r){"use strict";e.exports="\nmessage RPC {\n repeated SubOpts subscriptions = 1;\n repeated Message msgs = 2;\n\n message SubOpts {\n optional bool subscribe = 1; // subscribe or unsubcribe\n optional string topicCID = 2;\n }\n\n message Message {\n optional bytes from = 1;\n optional bytes data = 2;\n optional bytes seqno = 3;\n repeated string topicIDs = 4; \n }\n}"},function(e,t,r){"use strict";e.exports="\n// topicCID = cid(merkledag_protobuf(topicDescriptor)); (not the topic.name)\nmessage TopicDescriptor {\n optional string name = 1;\n optional AuthOpts auth = 2;\n optional EncOpts enc = 2;\n\n message AuthOpts {\n optional AuthMode mode = 1;\n repeated bytes keys = 2; // root keys to trust\n\n enum AuthMode {\n NONE = 0; // no authentication, anyone can publish\n KEY = 1; // only messages signed by keys in the topic descriptor are accepted\n WOT = 2; // web of trust, certificates can allow publisher set to grow\n }\n }\n\n message EncOpts {\n optional EncMode mode = 1;\n repeated bytes keyHashes = 2; // the hashes of the shared keys used (salted)\n\n enum EncMode {\n NONE = 0; // no encryption, anyone can read\n SHAREDKEY = 1; // messages are encrypted with shared key\n WOT = 2; // web of trust, certificates can allow publisher set to grow\n }\n }\n}"},function(e,t,r){"use strict";(function(n){const i=r(111),o=r(14);(t=e.exports).randomSeqno=(()=>i.randomBytes(20).toString("hex")),t.msgId=((e,t)=>e+t),t.anyMatch=((e,t)=>{let r;r=Array.isArray(t)?e=>t.indexOf(e)>-1:e=>t.has(e);for(let t of e)if(r(t))return!0;return!1}),t.ensureArray=(e=>Array.isArray(e)?e:[e]),t.normalizeInRpcMessages=(e=>e?e.map(e=>{const t=Object.assign({},e);return n.isBuffer(e.from)&&(t.from=o.encode(e.from)),t}):e),t.normalizeOutRpcMessages=(e=>e?e.map(e=>{const t=Object.assign({},e);return("string"==typeof e.from||e.from instanceof String)&&(t.from=o.decode(e.from)),t}):e)}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(1),i=n("libp2p:floodsub");i.err=n("libp2p:floodsub:error"),e.exports={log:i,multicodec:"/floodsub/1.0.0"}},function(e,t,r){"use strict";const n=r(1359),i=r(51),o=r(52);e.exports=(e=>(function(t,r){let s;if(i.isPeerInfo(t))s=t;else if(o.isMultiaddr(t)||"string"==typeof t){"string"==typeof t&&(t=o(t));const r=t.getPeerId();if(!r)throw new Error("peer multiaddr instance or string must include peerId");try{s=e.peerBook.get(r)}catch(e){s=new i(n.createFromB58String(r))}s.multiaddrs.add(t)}else{if(!n.isPeerId(t))return setImmediate(()=>r(new Error("peer type not recognized")));{const n=t.toB58String();try{s=e.peerBook.get(n)}catch(n){return e.peerRouting.findPeer(t,r)}}}setImmediate(()=>r(null,s))}))},function(e,t,r){"use strict";(function(n){const i=r(12),o=r(1360),s=r(17),a=r(4);class u{constructor(e,t,r){s(n.isBuffer(e),"invalid id provided"),t&&r&&s(t.public.bytes.equals(r.bytes),"inconsistent arguments"),this._id=e,this._idB58String=i.toB58String(this.id),this._privKey=t,this._pubKey=r}get id(){return this._id}set id(e){throw new Error("Id is immutable")}get privKey(){return this._privKey}set privKey(e){this._privKey=e}get pubKey(){return this._pubKey?this._pubKey:this._privKey?this._privKey.public:void 0}set pubKey(e){this._pubKey=e}marshalPubKey(){if(this.pubKey)return o.keys.marshalPublicKey(this.pubKey)}marshalPrivKey(){if(this.privKey)return o.keys.marshalPrivateKey(this.privKey)}toPrint(){return this.toJSON()}toJSON(){return{id:this.toB58String(),privKey:c(this.marshalPrivKey()),pubKey:c(this.marshalPubKey())}}toHexString(){return i.toHexString(this.id)}toBytes(){return this.id}toB58String(){return this._idB58String}isEqual(e){if(n.isBuffer(e))return this.id.equals(e);if(e.id)return this.id.equals(e.id);throw new Error("not valid Id")}isValid(e){this.privKey&&this.privKey.public&&this.privKey.public.bytes&&n.isBuffer(this.pubKey.bytes)&&this.privKey.public.bytes.equals(this.pubKey.bytes)?e():e(new Error("Keys not match"))}}function c(e){if(e)return e.toString("base64")}(t=e.exports=u).create=function(e,t){"function"==typeof e&&(t=e,e={}),(e=e||{}).bits=e.bits||2048,a([t=>o.keys.generateKeyPair("RSA",e.bits,t),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n))})},t.createFromHexString=function(e){return new u(i.fromHexString(e))},t.createFromBytes=function(e){return new u(e)},t.createFromB58String=function(e){return new u(i.fromB58String(e))},t.createFromPubKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r;try{let i=e;if("string"==typeof i&&(i=n.from(e,"base64")),!n.isBuffer(i))throw new Error("Supplied key is neither a base64 string nor a buffer");r=o.keys.unmarshalPublicKey(i)}catch(e){return t(e)}r.hash((e,n)=>{if(e)return t(e);t(null,new u(n,null,r))})},t.createFromPrivKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r=e;try{if("string"==typeof r&&(r=n.from(e,"base64")),!n.isBuffer(r))throw new Error("Supplied key is neither a base64 string nor a buffer")}catch(e){return t(e)}a([e=>o.keys.unmarshalPrivateKey(r,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n,n.public))})},t.createFromJSON=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r,s,c,f;try{r=i.fromB58String(e.id),s=e.privKey&&n.from(e.privKey,"base64"),c=e.pubKey&&n.from(e.pubKey,"base64"),f=c&&o.keys.unmarshalPublicKey(c)}catch(e){return t(e)}s?a([e=>o.keys.unmarshalPrivateKey(s,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)}),(e,t,r)=>{f?f.hash((n,i)=>{r(n,e,t,i)}):r(null,e,t)}],(e,n,i,o)=>e?t(e):f&&!n.equals(o)?t(new Error("Public and private key do not match")):r&&!n.equals(r)?t(new Error("Id and private key do not match")):void t(null,new u(r,i,f))):t(null,new u(r,null,f))},t.isPeerId=function(e){return Boolean("object"==typeof e&&e._id&&e._idB58String)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(588),i=r(1362),o=r(1364);(t=e.exports).aes=i,t.hmac=n,t.keys=o,t.randomBytes=r(593),t.pbkdf2=r(1375)},function(e,t,r){"use strict";e.exports={SHA1:20,SHA256:32,SHA512:64}},function(e,t,r){"use strict";const n=r(1363),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(59);e.exports={createCipheriv:n.createCipheriv,createDecipheriv:n.createDecipheriv}},function(e,t,r){"use strict";(function(n){const i=r(10)(r(321)),o=r(16);t=e.exports;const s={rsa:r(1365),ed25519:r(1370),secp256k1:r(61)(i,r(593))};function a(e){return void 0!==s[e.toLowerCase()]}t.supportedKeys=s,t.keysPBM=i,t.keyStretcher=r(1372),t.generateEphemeralKeyPair=r(1373),t.generateKeyPair=((e,t,r)=>{let 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)=>{let 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){"use strict";const n=r(589),i=r(10),o=r(14),s=r(591),a=i(r(321)),u=r(16),c=r(3);class f{constructor(e){this._key=e}verify(e,t,r){h(r),s.hashAndVerify(this._key,t,e,r)}marshal(){return s.utils.jwkToPkix(this._key)}get bytes(){return a.PublicKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}encrypt(e){return this._key.encrypt(e,"RSAES-PKCS1-V1_5")}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(e),n(this.bytes,"sha2-256",e)}}class l{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return s.getRandomValues(new Uint8Array(16))}sign(e,t){h(t),s.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){s.decrypt(this._key,e,t)}marshal(){return s.utils.jwkToPkcs1(this._key)}get bytes(){return a.PrivateKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(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"),h(r),c(()=>{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 h(e){if("function"!=typeof e)throw new Error("callback is required")}e.exports={RsaPublicKey:f,RsaPrivateKey:l,unmarshalRsaPublicKey:function(e){const t=s.utils.pkixToJwk(e);return new f(t)},unmarshalRsaPrivateKey:function(e,t){const r=s.utils.pkcs1ToJwk(e);s.unmarshalPrivateKey(r,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},generateKeyPair:function(e,t){s.generateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},fromJwk:function(e,t){s.unmarshalPrivateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})}}},function(e,t,r){"use strict";(function(t){const n=r(38),i=r(39),o=r(590),s=r(1367),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,256)),shake256:a(u(n.shake_256,512)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(1368),dblSha2256:(e,r)=>{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(40),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;function o(e){if(!i)throw new Error("Please use a browser with webcrypto support");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(41),i=r(590).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(15),i=r(592),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())}),u=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()))}),c=n.define("RSAPublicKey",function(){this.seq().obj(this.key("algorithm").use(u),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=c.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 c.encode({algorithm:{algorithm:"rsa",none:null},subjectPublicKey:{data:f.encode({modulus:s(e.n),publicExponent:s(e.e)},"der")}},"der")}},function(e,t,r){"use strict";(function(t){const n=r(589),i=r(10),o=r(14),s=r(1371),a=i(r(321));class u{constructor(e){this._key=l(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 c{constructor(e,t){this._key=l(e,s.privateKeyLength),this._publicKey=l(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 u(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 l(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:u,Ed25519PrivateKey:c,unmarshalEd25519PrivateKey:function(e,t){try{e=l(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 c(r,n))},unmarshalEd25519PublicKey:function(e){return e=l(e,s.publicKeyLength),new u(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 c(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 c(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(60),i=r(3);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){"use strict";(function(t){const n=r(37),i=r(588),o={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,cipherKeySize:32}};e.exports=((e,r,s,a)=>{const u=o[e];if(!u)return a(new Error("unkown cipherType passed"));if(!r)return a(new Error("unkown hashType passed"));const c=u.keySize,f=u.ivSize,l=t.from("key expansion"),h=2*(f+c+20);i.create(r,s,(e,r)=>{if(e)return a(e);r.digest(l,(e,i)=>{if(e)return a(e);let o=[],s=0;n(()=>s{if(t)return e(t);let a=n.length;s+a>h&&(a=h-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=h/2,n=t.concat(o),i=n.slice(0,r),s=n.slice(r,h),u=e=>({iv:e.slice(0,f),cipherKey:e.slice(f,f+c),macKey:e.slice(f+c)});a(null,{k1:u(i),k2:u(s)})})})})})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(1374);e.exports=((e,t)=>{n.generateEphmeralKeyPair(e,t)})},function(e,t,r){"use strict";(function(e){const n=r(320)(),i=r(319),o=r(15).bignum,s=r(592),a=s.toBase64,u=s.toBn,c={"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 o=(o,s,a)=>{let u;"function"==typeof s&&(a=s,s=void 0),u=s?n.subtle.importKey("jwk",p(t,s),{name:"ECDH",namedCurve:t},!1,["deriveBits"]):Promise.resolve(r.privateKey);const f=Promise.all([n.subtle.importKey("jwk",h(t,o),{name:"ECDH",namedCurve:t},!1,[]),u]);i(f.then(e=>n.subtle.deriveBits({name:"ECDH",namedCurve:t,public:e[0]},e[1],c[t])).then(t=>e.from(t)),a)};return n.subtle.exportKey("jwk",r.publicKey).then(e=>({key:l(e),genSharedKey:o}))}),r)};const f={"P-256":32,"P-384":48,"P-521":66};function l(t){const r=f[t.crv];return e.concat([e.from([4]),u(t.x).toArrayLike(e,"be",r),u(t.y).toArrayLike(e,"be",r)],1+2*r)}function h(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}}function p(e,t){const r=h(e,t.public);return r.d=a(new o(t.private)),r}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(16),i={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};e.exports=function(e,t,r,o,s){const a=i[s];if(!a)throw new Error(`Hash '${s}' is unknown or not supported`);const u=n.pkcs5.pbkdf2(e,t,r,o,a);return n.util.encode64(u)}},function(e,t,r){"use strict";const n=r(497),i=n.alternatives().try(n.func(),n.object()),o=n.object({connectionManager:n.object(),peerInfo:n.object().required(),peerBook:n.object(),modules:n.object().keys({transport:n.array().items(i).min(1).required(),streamMuxer:n.array().items(i).allow(null),connEncryption:n.array().items(i).allow(null),peerDiscovery:n.array().items(i).allow(null),dht:i.allow(null)}).required(),config:n.object().keys({peerDiscovery:n.object().allow(null),relay:n.object().keys({enabled:n.boolean().default(!1),hop:n.object().keys({enabled:n.boolean().default(!1),active:n.boolean().default(!1)})}).default(),dht:n.object().keys({kBucketSize:n.number().allow(null)}),EXPERIMENTAL:n.object().keys({dht:n.boolean().default(!1),pubsub:n.boolean().default(!1)}).default()}).default()});e.exports.validate=(e=>((e=n.attempt(e,o)).config.EXPERIMENTAL.dht&&n.assert(e.modules.dht,i.required()),e))},function(e,t,r){(function(e,n){var i; +var n;n=function(){"use strict";var e=function(e,r){return t(e.slice(),r)};function t(e,t){"function"!=typeof t&&(t=function(e,t){return String(e).localeCompare(t)});var n=e.length;if(n<=1)return e;for(var i=new Array(n),o=1;oc&&(o=c),s>c&&(s=c),a=i,u=o;;)if(a"!==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=o(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")},a=function(e){for(var t={enums:[],messages:[],fields:[],extends:[],extensions:null};e.length;)switch(e[0]){case"map":case"repeated":case"optional":case"required":t.fields.push(s(e));break;case"enum":t.enums.push(d(e));break;case"message":t.messages.push(f(e));break;case"extensions":t.extensions=c(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=s(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":case"option":for(e.shift();";"!==e[0];)e.shift();break;default:e.unshift("optional"),t.fields.push(s(e))}return t},u=function(e){return{name:e[1],message:f(e)}},c=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}},f=function(e){e.shift();var t=1,r=[],n={name:e.shift(),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=a(r),n.enums=r.enums,n.messages=r.messages,n.fields=r.fields,n.extends=r.extends,n.extensions=r.extensions,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},h=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("="!==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=o(e)),e.shift(),{name:t,val:r}},d=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);r.values[n.name]=n.val}else t=y(e),r.options[t.name]=t.value}throw new Error("No closing tag for enum")},y=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},b=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=y(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(v(e));break;default:throw new Error("Unexpected token in service: "+e[0])}}throw new Error("No closing tag for service")},v=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=y(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=function(e){return e.trim()};return e.replace(/([;,{}()=:[\]<>]|\/\*|\*\/)/g," $1 ").split(/\n/).map(t).filter(Boolean).map(function(e){var t=e.indexOf("//");return t>-1?e.slice(0,t):e}).map(t).filter(Boolean).join("\n").split(/\s+|\n+/gm).filter(function(){var e=!1;return function(t){return"/*"===t?(e=!0,!1):"*/"===t?(e=!1,!1):!e}}())}},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.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},u=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},c=function(e){return function(t){return Array.isArray(t)?t.map(c(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.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(u(e,[]))}),t.push("}","")}(e,t)}),t.map(c("")).join("\n")}},function(e,t,r){"use strict";var n=r(750),i=r(752),o=r(753),s=r(754),a=r(20);e.exports=function(e,t){var r={},u={},c={},f=function(e,t){e.enums&&e.enums.forEach(function(e){e.id=t+(t?".":"")+e.name,u[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 l=function(e){var t=Object.keys(e.values||[]).map(function(t){return parseInt(e.values[t].value,10)});return n.make(0,function e(r,n,i){if(!t.length||-1===t.indexOf(r))throw new Error("Invalid enum value: "+r);return a.encode(r,n,i),e.bytes=a.encode.bytes,n},function e(r,n){var i=a.decode(r,n);if(!t.length||-1===t.indexOf(i))throw new Error("Invalid enum value: "+i);return e.bytes=a.decode.bytes,i},a.encodingLength)},h=function(e,t){e.messages.forEach(function(r){t[r.name]=p(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 p(t.type,e.id)}),a=s(e,n,r),u=o(e,p,n,r,a),c=i(e,p,n);return u.bytes=c.bytes=0,t.buffer=!0,t.encode=u,t.decode=c,t.encodingLength=a,t},p=function(e,i,o){if(t&&t[e])return t[e];if(n[e])return n[e];var s=(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]||u[t]},null);if(!1===o)return s;if(!s)throw new Error("Could not resolve "+e);return s.values?l(s):c[s.id]||h(s,c[s.id]={})};return(e.enums||[]).concat((e.messages||[]).map(function(e){return p(e.id)}))}},function(e,t,r){"use strict";var n,i,o,s=r(20),a=r(751),u=r(2).Buffer,c=function(e,t,r,n){return t.bytes=r.bytes=0,{type:e,encode:t,decode:r,encodingLength:n}};t.make=c,t.bytes=(n=function(e){return u.isBuffer(e)?e.length:u.byteLength(e)},c(2,i=function(e,t,r){var o=r,a=n(e);return s.encode(a,t,r),r+=s.encode.bytes,u.isBuffer(e)?e.copy(t,r):t.write(e,r,a),r+=a,i.bytes=r-o,t},o=function(e,t){var r=t,n=s.decode(e,t);t+=s.decode.bytes;var i=e.slice(t,t+n);return t+=i.length,o.bytes=t-r,i},function(e){var t=n(e);return s.encodingLength(t)+t})),t.string=function(){var e=function(t,r,n){var i=n,o=u.byteLength(t);return s.encode(o,r,n,"utf-8"),n+=s.encode.bytes,r.write(t,n,o),n+=o,e.bytes=n-i,r},t=function(e,r){var n=r,i=s.decode(e,r);r+=s.decode.bytes;var o=e.toString("utf-8",r,r+i);return r+=i,t.bytes=r-n,o};return c(2,e,t,function(e){var t=u.byteLength(e);return s.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 c(0,e,t,function(e){return 1})}(),t.int32=function(){var e=function(t,r){var n=s.decode(t,r);return e.bytes=s.decode.bytes,n>2147483647?n-4294967296:n};return c(0,s.encode,e,function(e){return s.encodingLength(e<0?e+4294967296:e)})}(),t.int64=function(){var e=function(t,r){var n=s.decode(t,r);if(n>=Math.pow(2,63)){for(var i=9;255===t[r+i-1];)i--;i=i||9;var o=u.allocUnsafe(i);t.copy(o,0,r,r+i),o[i-1]=127&o[i-1],n=-1*s.decode(o,0),e.bytes=10}else e.bytes=s.decode.bytes;return n},t=function(e,r,n){if(e<0){var i=n+9;for(s.encode(-1*e,r,n),r[n+=s.encode.bytes-1]=128|r[n];n=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){"use strict";var n=r(20),i=r(228).defined;var o=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)}},s=function(e,t){if(e.map)return{};if(e.repeated)return[];switch(e.type){case"string":return null!=t?t:"";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||0,10);default:return null}};e.exports=function(e,t,r){for(var a=[],u={},c=[],f=[],l=0;l-1&&delete r[u[f]];if(e.message){var l=n.decode(i,o);o+=n.decode.bytes;var h=e.decode(i,o,o+l);t.map?(r[a]=r[a]||{},r[a][h.key]=h.value):t.repeated?(r[a]=r[a]||[],r[a].push(h)):r[a]=h}else t.repeated?(r[a]=r[a]||[],r[a].push(e.decode(i,o))):r[a]=e.decode(i,o);return o+e.decode.bytes}return function t(l,h,p){if(null==h&&(h=0),null==p&&(p=l.length),!(p<=l.length&&h<=l.length))throw new Error("Decoded message is not valid");for(var d,g=h,m={};;){if(p<=h){var b,v,_="",w=0;for(w=0;w-1){S=!0;break}S||(b?d.repeated?m[_]=[]:(v=v&&b[v]?b[v].value:b[Object.keys(b)[0]].value,m[_]=parseInt(v||0,10)):m[_]=s(d,v))}return t.bytes=h-g,m}var A=n.decode(l,h);h+=n.decode.bytes;var x=u[A>>3];if(null!=x){var I=r[x];if((d=e.fields[x]).packed){var T=n.decode(l,h);for(T+=h+=n.decode.bytes;h-1){if(b)throw new Error("only one of the properties defined in oneof "+v+" can be set");b=!0}}for(m=0;me.name!==r);else{if(!t.isBuffer(r))return n(new Error("second arg needs to be a name or multihash"),null);u=u.filter(e=>!e.multihash.equals(r))}s(a,u,n)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";t.Diagnose=r(762),t.Decoder=r(390),t.Encoder=r(764),t.Simple=r(391),t.Tagged=r(392),t.decodeAll=t.Decoder.decodeAll,t.decodeFirst=t.Decoder.decodeFirst,t.diagnose=t.Diagnose.diagnose,t.encode=t.Encoder.encode,t.decode=t.Decoder.decode,t.leveldb={decode:t.Decoder.decodeAll,encode:t.Encoder.encode,buffer:!0,name:"cbor"}},function(e,t,r){"use strict";(function(t){const n=r(390),i=r(229);class o extends n{createTag(e,t){return`${e}(${t})`}createInt(e){return super.createInt(e).toString()}createInt32(e,t){return super.createInt32(e,t).toString()}createInt64(e,t,r,n){return super.createInt64(e,t,r,n).toString()}createInt32Neg(e,t){return super.createInt32Neg(e,t).toString()}createInt64Neg(e,t,r,n){return super.createInt64Neg(e,t,r,n).toString()}createTrue(){return"true"}createFalse(){return"false"}createFloat(e){const t=super.createFloat(e);return i.isNegativeZero(e)?"-0_1":`${t}_1`}createFloatSingle(e,t,r,n){return`${super.createFloatSingle(e,t,r,n)}_2`}createFloatDouble(e,t,r,n,i,o,s,a){return`${super.createFloatDouble(e,t,r,n,i,o,s,a)}_3`}createByteString(e,t){const r=e.join(", ");return-1===t?`(_ ${r})`:`h'${r}`}createByteStringFromHeap(e,r){return`h'${t.from(super.createByteStringFromHeap(e,r)).toString("hex")}'`}createInfinity(){return"Infinity_1"}createInfinityNeg(){return"-Infinity_1"}createNaN(){return"NaN_1"}createNaNNeg(){return"-NaN_1"}createNull(){return"null"}createUndefined(){return"undefined"}createSimpleUnassigned(e){return`simple(${e})`}createArray(e,t){const r=super.createArray(e,t);return-1===t?`[_ ${r.join(", ")}]`:`[${r.join(", ")}]`}createMap(e,t){const r=super.createMap(e),n=Array.from(r.keys()).reduce(s(r),"");return-1===t?`{_ ${n}}`:`{${n}}`}createObject(e,t){const r=super.createObject(e),n=Object.keys(r).reduce(s(r),"");return-1===t?`{_ ${n}}`:`{${n}}`}createUtf8String(e,t){const r=e.join(", ");return-1===t?`(_ ${r})`:`"${r}"`}createUtf8StringFromHeap(e,r){return`"${t.from(super.createUtf8StringFromHeap(e,r)).toString("utf8")}"`}static diagnose(e,r){return"string"==typeof e&&(e=t.from(e,r||"hex")),(new o).decodeFirst(e)}}function s(e){return(t,r)=>t?`${t}, ${r}: ${e[r]}`:`${r}: ${e[r]}`}e.exports=o}).call(this,r(0).Buffer)},function(e,t){e.exports=function(e,t,r){"use asm";var n=new e.Uint8Array(r);var i=t.pushInt;var o=t.pushInt32;var s=t.pushInt32Neg;var a=t.pushInt64;var u=t.pushInt64Neg;var c=t.pushFloat;var f=t.pushFloatSingle;var l=t.pushFloatDouble;var h=t.pushTrue;var p=t.pushFalse;var d=t.pushUndefined;var y=t.pushNull;var g=t.pushInfinity;var m=t.pushInfinityNeg;var b=t.pushNaN;var v=t.pushNaNNeg;var _=t.pushArrayStart;var w=t.pushArrayStartFixed;var S=t.pushArrayStartFixed32;var k=t.pushArrayStartFixed64;var E=t.pushObjectStart;var A=t.pushObjectStartFixed;var x=t.pushObjectStartFixed32;var I=t.pushObjectStartFixed64;var T=t.pushByteString;var B=t.pushByteStringStart;var C=t.pushUtf8String;var P=t.pushUtf8StringStart;var O=t.pushSimpleUnassigned;var R=t.pushTagStart;var N=t.pushTagStart4;var L=t.pushTagStart8;var j=t.pushTagUnassigned;var M=t.pushBreak;var K=e.Math.pow;var D=0;var U=0;var F=0;function q(e){e=e|0;D=0;U=e;while((D|0)<(U|0)){F=Je[n[D]&255](n[D]|0)|0;if((F|0)>0){break}}return F|0}function H(e){e=e|0;if(((D|0)+(e|0)|0)<(U|0)){return 0}return 1}function z(e){e=e|0;return n[e|0]<<8|n[e+1|0]|0}function V(e){e=e|0;return n[e|0]<<24|n[e+1|0]<<16|n[e+2|0]<<8|n[e+3|0]|0}function G(e){e=e|0;i(e|0);D=D+1|0;return 0}function W(e){e=e|0;if(H(1)|0){return 1}i(n[D+1|0]|0);D=D+2|0;return 0}function $(e){e=e|0;if(H(2)|0){return 1}i(z(D+1|0)|0);D=D+3|0;return 0}function Y(e){e=e|0;if(H(4)|0){return 1}o(z(D+1|0)|0,z(D+3|0)|0);D=D+5|0;return 0}function J(e){e=e|0;if(H(8)|0){return 1}a(z(D+1|0)|0,z(D+3|0)|0,z(D+5|0)|0,z(D+7|0)|0);D=D+9|0;return 0}function X(e){e=e|0;i(-1-(e-32|0)|0);D=D+1|0;return 0}function Z(e){e=e|0;if(H(1)|0){return 1}i(-1-(n[D+1|0]|0)|0);D=D+2|0;return 0}function Q(e){e=e|0;var t=0;if(H(2)|0){return 1}t=z(D+1|0)|0;i(-1-(t|0)|0);D=D+3|0;return 0}function ee(e){e=e|0;if(H(4)|0){return 1}s(z(D+1|0)|0,z(D+3|0)|0);D=D+5|0;return 0}function te(e){e=e|0;if(H(8)|0){return 1}u(z(D+1|0)|0,z(D+3|0)|0,z(D+5|0)|0,z(D+7|0)|0);D=D+9|0;return 0}function re(e){e=e|0;var t=0;var r=0;var n=0;n=e-64|0;if(H(n|0)|0){return 1}t=D+1|0;r=(D+1|0)+(n|0)|0;T(t|0,r|0);D=r|0;return 0}function ne(e){e=e|0;var t=0;var r=0;var i=0;if(H(1)|0){return 1}i=n[D+1|0]|0;t=D+2|0;r=(D+2|0)+(i|0)|0;if(H(i+1|0)|0){return 1}T(t|0,r|0);D=r|0;return 0}function ie(e){e=e|0;var t=0;var r=0;var n=0;if(H(2)|0){return 1}n=z(D+1|0)|0;t=D+3|0;r=(D+3|0)+(n|0)|0;if(H(n+2|0)|0){return 1}T(t|0,r|0);D=r|0;return 0}function oe(e){e=e|0;var t=0;var r=0;var n=0;if(H(4)|0){return 1}n=V(D+1|0)|0;t=D+5|0;r=(D+5|0)+(n|0)|0;if(H(n+4|0)|0){return 1}T(t|0,r|0);D=r|0;return 0}function se(e){e=e|0;return 1}function ae(e){e=e|0;B();D=D+1|0;return 0}function ue(e){e=e|0;var t=0;var r=0;var n=0;n=e-96|0;if(H(n|0)|0){return 1}t=D+1|0;r=(D+1|0)+(n|0)|0;C(t|0,r|0);D=r|0;return 0}function ce(e){e=e|0;var t=0;var r=0;var i=0;if(H(1)|0){return 1}i=n[D+1|0]|0;t=D+2|0;r=(D+2|0)+(i|0)|0;if(H(i+1|0)|0){return 1}C(t|0,r|0);D=r|0;return 0}function fe(e){e=e|0;var t=0;var r=0;var n=0;if(H(2)|0){return 1}n=z(D+1|0)|0;t=D+3|0;r=(D+3|0)+(n|0)|0;if(H(n+2|0)|0){return 1}C(t|0,r|0);D=r|0;return 0}function le(e){e=e|0;var t=0;var r=0;var n=0;if(H(4)|0){return 1}n=V(D+1|0)|0;t=D+5|0;r=(D+5|0)+(n|0)|0;if(H(n+4|0)|0){return 1}C(t|0,r|0);D=r|0;return 0}function he(e){e=e|0;return 1}function pe(e){e=e|0;P();D=D+1|0;return 0}function de(e){e=e|0;w(e-128|0);D=D+1|0;return 0}function ye(e){e=e|0;if(H(1)|0){return 1}w(n[D+1|0]|0);D=D+2|0;return 0}function ge(e){e=e|0;if(H(2)|0){return 1}w(z(D+1|0)|0);D=D+3|0;return 0}function me(e){e=e|0;if(H(4)|0){return 1}S(z(D+1|0)|0,z(D+3|0)|0);D=D+5|0;return 0}function be(e){e=e|0;if(H(8)|0){return 1}k(z(D+1|0)|0,z(D+3|0)|0,z(D+5|0)|0,z(D+7|0)|0);D=D+9|0;return 0}function ve(e){e=e|0;_();D=D+1|0;return 0}function _e(e){e=e|0;var t=0;t=e-160|0;if(H(t|0)|0){return 1}A(t|0);D=D+1|0;return 0}function we(e){e=e|0;if(H(1)|0){return 1}A(n[D+1|0]|0);D=D+2|0;return 0}function Se(e){e=e|0;if(H(2)|0){return 1}A(z(D+1|0)|0);D=D+3|0;return 0}function ke(e){e=e|0;if(H(4)|0){return 1}x(z(D+1|0)|0,z(D+3|0)|0);D=D+5|0;return 0}function Ee(e){e=e|0;if(H(8)|0){return 1}I(z(D+1|0)|0,z(D+3|0)|0,z(D+5|0)|0,z(D+7|0)|0);D=D+9|0;return 0}function Ae(e){e=e|0;E();D=D+1|0;return 0}function xe(e){e=e|0;R(e-192|0|0);D=D+1|0;return 0}function Ie(e){e|0;R(e|0);D=D+1|0;return 0}function Te(e){e|0;R(e|0);D=D+1|0;return 0}function Be(e){e|0;R(e|0);D=D+1|0;return 0}function Ce(e){e|0;R(e|0);D=D+1|0;return 0}function Pe(e){e=e|0;R(e-192|0|0);D=D+1|0;return 0}function Oe(e){e|0;R(e|0);D=D+1|0;return 0}function Re(e){e|0;R(e|0);D=D+1|0;return 0}function Ne(e){e|0;R(e|0);D=D+1|0;return 0}function Le(e){e=e|0;if(H(1)|0){return 1}R(n[D+1|0]|0);D=D+2|0;return 0}function je(e){e=e|0;if(H(2)|0){return 1}R(z(D+1|0)|0);D=D+3|0;return 0}function Me(e){e=e|0;if(H(4)|0){return 1}N(z(D+1|0)|0,z(D+3|0)|0);D=D+5|0;return 0}function Ke(e){e=e|0;if(H(8)|0){return 1}L(z(D+1|0)|0,z(D+3|0)|0,z(D+5|0)|0,z(D+7|0)|0);D=D+9|0;return 0}function De(e){e=e|0;O((e|0)-224|0);D=D+1|0;return 0}function Ue(e){e=e|0;p();D=D+1|0;return 0}function Fe(e){e=e|0;h();D=D+1|0;return 0}function qe(e){e=e|0;y();D=D+1|0;return 0}function He(e){e=e|0;d();D=D+1|0;return 0}function ze(e){e=e|0;if(H(1)|0){return 1}O(n[D+1|0]|0);D=D+2|0;return 0}function Ve(e){e=e|0;var t=0;var r=0;var i=1.0;var o=0.0;var s=0.0;var a=0.0;if(H(2)|0){return 1}t=n[D+1|0]|0;r=n[D+2|0]|0;if((t|0)&0x80){i=-1.0}o=+(((t|0)&0x7C)>>2);s=+(((t|0)&0x03)<<8|r);if(+o==0.0){c(+(+i*+5.9604644775390625e-8*+s))}else if(+o==31.0){if(+i==1.0){if(+s>0.0){b()}else{g()}}else{if(+s>0.0){v()}else{m()}}}else{c(+(+i*K(+2,+(+o-25.0))*+(1024.0+s)))}D=D+3|0;return 0}function Ge(e){e=e|0;if(H(4)|0){return 1}f(n[D+1|0]|0,n[D+2|0]|0,n[D+3|0]|0,n[D+4|0]|0);D=D+5|0;return 0}function We(e){e=e|0;if(H(8)|0){return 1}l(n[D+1|0]|0,n[D+2|0]|0,n[D+3|0]|0,n[D+4|0]|0,n[D+5|0]|0,n[D+6|0]|0,n[D+7|0]|0,n[D+8|0]|0);D=D+9|0;return 0}function $e(e){e=e|0;return 1}function Ye(e){e=e|0;M();D=D+1|0;return 0}var Je=[G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,G,W,$,Y,J,$e,$e,$e,$e,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,Z,Q,ee,te,$e,$e,$e,$e,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,re,ne,ie,oe,se,$e,$e,$e,ae,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ue,ce,fe,le,he,$e,$e,$e,pe,de,de,de,de,de,de,de,de,de,de,de,de,de,de,de,de,de,de,de,de,de,de,de,de,ye,ge,me,be,$e,$e,$e,ve,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,_e,we,Se,ke,Ee,$e,$e,$e,Ae,xe,xe,xe,xe,xe,xe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Pe,Le,je,Me,Ke,$e,$e,$e,$e,De,De,De,De,De,De,De,De,De,De,De,De,De,De,De,De,De,De,De,De,Ue,Fe,qe,He,ze,Ve,Ge,We,$e,$e,$e,Ye];return{parse:q}}},function(e,t,r){"use strict";(function(t){const n=r(33),i=r(169),o=r(229),s=r(170),a=s.MT,u=s.NUMBYTES,c=s.SHIFT32,f=s.SYMS,l=s.TAG,h=s.MT.SIMPLE_FLOAT<<5|s.NUMBYTES.TWO,p=s.MT.SIMPLE_FLOAT<<5|s.NUMBYTES.FOUR,d=s.MT.SIMPLE_FLOAT<<5|s.NUMBYTES.EIGHT,y=s.MT.SIMPLE_FLOAT<<5|s.SIMPLE.TRUE,g=s.MT.SIMPLE_FLOAT<<5|s.SIMPLE.FALSE,m=s.MT.SIMPLE_FLOAT<<5|s.SIMPLE.UNDEFINED,b=s.MT.SIMPLE_FLOAT<<5|s.SIMPLE.NULL,v=new i("0x20000000000000"),_=t.from("f97e00","hex"),w=t.from("f9fc00","hex"),S=t.from("f97c00","hex");class k{constructor(e){e=e||{},this.streaming="function"==typeof e.stream,this.onData=e.stream,this.semanticTypes=[[n.Url,this._pushUrl],[i,this._pushBigNumber]];const t=e.genTypes||[],r=t.length;for(let e=0;e[t,e[t]]))}_pushRawMap(e,t){t=t.map(function(e){return e[0]=k.encode(e[0]),e}).sort(o.keySorter);for(var r=0;rt.length)throw new Error(r.INVALID_TARGET_OFFSET)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(n){const i=r(3),o=r(172).SmartBuffer,s=r(171);(t=e.exports).serialize=((e,t)=>{let r=[];r.push("tree "+s.cidToSha(e.tree["/"]).toString("hex")),e.parents.forEach(e=>{r.push("parent "+s.cidToSha(e["/"]).toString("hex"))}),r.push("author "+s.serializePersonLine(e.author)),r.push("committer "+s.serializePersonLine(e.committer)),e.encoding&&r.push("encoding "+e.encoding),e.signature&&(r.push("gpgsig -----BEGIN PGP SIGNATURE-----"),r.push(e.signature.text)),r.push(""),r.push(e.message);let n=r.join("\n"),a=new o;a.writeString("commit "),a.writeString(n.length.toString()),a.writeUInt8(0),a.writeString(n),i(()=>t(null,a.toBuffer()))}),t.deserialize=((e,t)=>{let r=e.toString().split("\n"),o={gitType:"commit",parents:[]};for(let e=0;et(new Error("Invalid commit line "+e))),o.message=r.slice(e+1).join("\n");break}let u=a[1],c=a[2];switch(u){case"tree":o.tree={"/":s.shaToCid(n.from(c,"hex"))};break;case"committer":o.committer=s.parsePersonLine(c);break;case"author":o.author=s.parsePersonLine(c);break;case"parent":o.parents.push({"/":s.shaToCid(n.from(c,"hex"))});break;case"gpgsig":{"-----BEGIN PGP SIGNATURE-----"!==c&&i(()=>t(new Error("Invalid commit line "+e))),o.signature={};let n=e;for(;et(null,o))})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(n){const i=r(3),o=r(172).SmartBuffer,s=r(171);(t=e.exports).serialize=((e,t)=>{let r=[];r.push("object "+s.cidToSha(e.object["/"]).toString("hex")),r.push("type "+e.type),r.push("tag "+e.tag),null!==e.tagger&&r.push("tagger "+s.serializePersonLine(e.tagger)),r.push(""),r.push(e.message);let n=r.join("\n"),a=new o;a.writeString("tag "),a.writeString(n.length.toString()),a.writeUInt8(0),a.writeString(n),i(()=>t(null,a.toBuffer()))}),t.deserialize=((e,t)=>{let r=e.toString().split("\n"),o={gitType:"tag"};for(let e=0;et(new Error("Invalid tag line "+e))),o.message=r.slice(e+1).join("\n");break}let u=a[1],c=a[2];switch(u){case"object":o.object={"/":s.shaToCid(n.from(c,"hex"))};break;case"tagger":o.tagger=s.parsePersonLine(c);break;case"tag":o.tag=c;break;case"type":o.type=c;break;default:o[u]=c}}i(()=>t(null,o))})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(3),i=r(172).SmartBuffer,o=r(171);(t=e.exports).serialize=((e,t)=>{let r=[];Object.keys(e).forEach(t=>{r.push([t,e[t]])}),r.sort((e,t)=>e[0]>t[0]?1:-1);let s=new i;r.forEach(e=>{s.writeStringNT(e[1].mode+" "+e[0]),s.writeBuffer(o.cidToSha(e[1].hash["/"]))});let a=new i;a.writeString("tree "),a.writeString(s.length.toString()),a.writeUInt8(0),a.writeBuffer(s.toBuffer()),n(()=>t(null,a.toBuffer()))}),t.deserialize=((e,t)=>{let r={},s=i.fromBuffer(e,"utf8");for(;;){let e=s.readStringNT();if(""===e)break;let i=s.readBuffer(o.SHA1_LENGTH),a=e.match(/^(\d+) (.+)$/);a||n(()=>t(new Error("invalid file mode/name"))),r[a[2]]&&n(()=>t(new Error("duplicate file in tree"))),r[a[2]]={mode:a[1],hash:{"/":o.shaToCid(i)}}}n(()=>t(null,r))})},function(e,t,r){"use strict";t.resolver=r(230),t.util=r(397)},function(e,t,r){var n=r(28),i=r(233);for(var o in i)n[o]=i[o];e.exports={bufferutils:r(404),Block:r(791),ECPair:r(240),ECSignature:r(244),HDNode:r(807),Transaction:r(239),TransactionBuilder:r(808),address:r(241),crypto:r(106),networks:r(124),opcodes:r(37),script:n}},function(e,t,r){(function(t){var n=r(232),i=r(399);function o(e){return t.isBuffer(e)}function s(e){return"string"==typeof e&&/^([0-9a-f]{2})+$/i.test(e)}function a(e,t){var r=e.toJSON();function n(n){if(!e(n))return!1;if(n.length===t)return!0;throw i.tfCustomError(r+"(Length: "+t+")",r+"(Length: "+n.length+")")}return n.toJSON=function(){return r},n}var u=a.bind(null,n.Array),c=a.bind(null,o),f=a.bind(null,s),l=a.bind(null,n.String),h=Math.pow(2,53)-1;var p={ArrayN:u,Buffer:o,BufferN:c,Finite:function(e){return"number"==typeof e&&isFinite(e)},Hex:s,HexN:f,Int8:function(e){return e<<24>>24===e},Int16:function(e){return e<<16>>16===e},Int32:function(e){return(0|e)===e},StringN:l,UInt8:function(e){return(255&e)===e},UInt16:function(e){return(65535&e)===e},UInt32:function(e){return e>>>0===e},UInt53:function(e){return"number"==typeof e&&e>=0&&e<=h&&Math.floor(e)===e}};for(var d in p)p[d].toJSON=function(e){return e}.bind(null,d);e.exports=p}).call(this,r(0).Buffer)},function(e,t,r){var n=r(37),i={};for(var o in n){i[n[o]]=o}e.exports=i},function(e,t,r){var n=r(2).Buffer,i=r(28),o=r(401),s=r(25),a=r(37);function u(e){return e===a.OP_0||i.isCanonicalSignature(e)}function c(e,t){var r=i.decompile(e);return!(r.length<2)&&r[0]===a.OP_0&&(t?r.slice(1).every(u):r.slice(1).every(i.isCanonicalSignature))}c.toJSON=function(){return"multisig input"};var f=n.allocUnsafe(0);function l(e,t){if(s([u],e),t){var r=o.decode(t);if(e.lengthr.pubKeys.length)throw new TypeError("Too many signatures provided")}return[].concat(f,e.map(function(e){return e===a.OP_0?f:e}))}function h(e,t){return s(s.Array,e),s(c,e,t),e.slice(1)}e.exports={check:c,decode:function(e,t){return h(i.decompile(e),t)},decodeStack:h,encode:function(e,t){return i.compile(l(e,t))},encodeStack:l}},function(e,t,r){var n=r(28),i=r(31),o=r(25),s=r(37);function a(e){var t=n.compile(e);return t.length>1&&t[0]===s.OP_RETURN}a.toJSON=function(){return"null data output"},e.exports={output:{check:a,decode:function(e){return o(a,e),e.slice(2)},encode:function(e){return o(i.Buffer,e),n.compile([s.OP_RETURN,e])}}}},function(e,t,r){var n=r(28),i=r(25);function o(e){var t=n.decompile(e);return 1===t.length&&n.isCanonicalSignature(t[0])}function s(e){return i(n.isCanonicalSignature,e),[e]}function a(e){return i(i.Array,e),i(o,e),e[0]}o.toJSON=function(){return"pubKey input"},e.exports={check:o,decode:function(e){return a(n.decompile(e))},decodeStack:a,encode:function(e){return n.compile(s(e))},encodeStack:s}},function(e,t,r){var n=r(28),i=r(25),o=r(37);function s(e){var t=n.decompile(e);return 2===t.length&&n.isCanonicalPubKey(t[0])&&t[1]===o.OP_CHECKSIG}s.toJSON=function(){return"pubKey output"},e.exports={check:s,decode:function(e){var t=n.decompile(e);return i(s,t),t[0]},encode:function(e){return i(n.isCanonicalPubKey,e),n.compile([e,o.OP_CHECKSIG])}}},function(e,t,r){var n=r(28),i=r(25);function o(e){var t=n.decompile(e);return 2===t.length&&n.isCanonicalSignature(t[0])&&n.isCanonicalPubKey(t[1])}function s(e,t){return i({signature:n.isCanonicalSignature,pubKey:n.isCanonicalPubKey},{signature:e,pubKey:t}),[e,t]}function a(e){return i(i.Array,e),i(o,e),{signature:e[0],pubKey:e[1]}}o.toJSON=function(){return"pubKeyHash input"},e.exports={check:o,decode:function(e){return a(n.decompile(e))},decodeStack:a,encode:function(e,t){return n.compile(s(e,t))},encodeStack:s}},function(e,t,r){var n=r(28),i=r(31),o=r(25),s=r(37);function a(e){var t=n.compile(e);return 25===t.length&&t[0]===s.OP_DUP&&t[1]===s.OP_HASH160&&20===t[2]&&t[23]===s.OP_EQUALVERIFY&&t[24]===s.OP_CHECKSIG}a.toJSON=function(){return"pubKeyHash output"},e.exports={check:a,decode:function(e){return o(a,e),e.slice(3,23)},encode:function(e){return o(i.Hash160bit,e),n.compile([s.OP_DUP,s.OP_HASH160,e,s.OP_EQUALVERIFY,s.OP_CHECKSIG])}}},function(e,t,r){e.exports={input:r(783),output:r(784)}},function(e,t,r){var n=r(2).Buffer,i=r(28),o=r(25),s=r(234),a=r(235),u=r(236),c=r(402),f=r(403);function l(e,t){var r=i.decompile(e);if(r.length<1)return!1;var o=r[r.length-1];if(!n.isBuffer(o))return!1;var l=i.decompile(i.compile(r.slice(0,-1))),h=i.decompile(o);return 0!==h.length&&!!i.isPushOnly(l)&&(1===r.length?f.check(h)||c.check(h):!(!u.input.check(l)||!u.output.check(h))||!(!s.input.check(l,t)||!s.output.check(h))||!(!a.input.check(l)||!a.output.check(h)))}function h(e,t){var r=i.compile(t);return[].concat(e,r)}function p(e){return o(o.Array,e),o(l,e),{redeemScriptStack:e.slice(0,-1),redeemScript:e[e.length-1]}}l.toJSON=function(){return"scriptHash input"},e.exports={check:l,decode:function(e){var t=p(i.decompile(e));return t.redeemScriptSig=i.compile(t.redeemScriptStack),delete t.redeemScriptStack,t},decodeStack:p,encode:function(e,t){var r=i.decompile(e);return i.compile(h(r,t))},encodeStack:h}},function(e,t,r){var n=r(28),i=r(31),o=r(25),s=r(37);function a(e){var t=n.compile(e);return 23===t.length&&t[0]===s.OP_HASH160&&20===t[1]&&t[22]===s.OP_EQUAL}a.toJSON=function(){return"scriptHash output"},e.exports={check:a,decode:function(e){return o(a,e),e.slice(2,22)},encode:function(e){return o(i.Hash160bit,e),n.compile([s.OP_HASH160,e,s.OP_EQUAL])}}},function(e,t,r){e.exports={input:r(786),output:r(402)}},function(e,t,r){var n=r(28),i=r(25);function o(e){return n.isCanonicalPubKey(e)&&33===e.length}function s(e){var t=n.decompile(e);return 2===t.length&&n.isCanonicalSignature(t[0])&&o(t[1])}s.toJSON=function(){return"witnessPubKeyHash input"},e.exports={check:s,decodeStack:function(e){return i(i.Array,e),i(s,e),{signature:e[0],pubKey:e[1]}},encodeStack:function(e,t){return i({signature:n.isCanonicalSignature,pubKey:o},{signature:e,pubKey:t}),[e,t]}}},function(e,t,r){e.exports={input:r(788),output:r(403)}},function(e,t,r){(function(t){var n=r(28),i=r(31),o=r(25),s=r(234),a=r(235),u=r(236);function c(e,r){if(o(i.Array,e),e.length<1)return!1;var c=e[e.length-1];if(!t.isBuffer(c))return!1;var f=n.decompile(c);if(0===f.length)return!1;var l=n.compile(e.slice(0,-1));return!(!u.input.check(l)||!u.output.check(f))||!(!s.input.check(l,r)||!s.output.check(f))||!(!a.input.check(l)||!a.output.check(f))}c.toJSON=function(){return"witnessScriptHash input"},e.exports={check:c,decodeStack:function(e){return o(o.Array,e),o(c,e),{witnessData:e.slice(0,-1),witnessScript:e[e.length-1]}},encodeStack:function(e,t){return o({witnessData:[i.Buffer],witnessScript:i.Buffer},{witnessData:e,witnessScript:t}),[].concat(e,t)}}}).call(this,r(0).Buffer)},function(e,t,r){e.exports={output:r(790)}},function(e,t,r){var n=r(2).Buffer,i=r(28),o=r(31),s=r(25),a=r(37),u=n.from("aa21a9ed","hex");function c(e){var t=i.compile(e);return t.length>37&&t[0]===a.OP_RETURN&&36===t[1]&&t.slice(2,6).equals(u)}c.toJSON=function(){return"Witness commitment output"},e.exports={check:c,decode:function(e){return s(c,e),i.decompile(e)[1].slice(4,36)},encode:function(e){s(o.Hash256bit,e);var t=n.allocUnsafe(36);return u.copy(t,0),e.copy(t,4),i.compile([a.OP_RETURN,t])}}},function(e,t,r){var n=r(2).Buffer,i=r(106),o=r(796),s=r(25),a=r(31),u=r(237),c=r(239);function f(){this.version=1,this.prevHash=null,this.merkleRoot=null,this.timestamp=0,this.bits=0,this.nonce=0}f.fromBuffer=function(e){if(e.length<80)throw new Error("Buffer too small (< 80 bytes)");var t=0;function r(r){return t+=r,e.slice(t-r,t)}function n(){var r=e.readUInt32LE(t);return t+=4,r}var i=new f;if(i.version=function(){var r=e.readInt32LE(t);return t+=4,r}(),i.prevHash=r(32),i.merkleRoot=r(32),i.timestamp=n(),i.bits=n(),i.nonce=n(),80===e.length)return i;function o(){var r=c.fromBuffer(e.slice(t),!0);return t+=r.byteLength(),r}var s=function(){var r=u.decode(e,t);return t+=u.decode.bytes,r}();i.transactions=[];for(var a=0;a>24)-3,r=8388607&e,i=n.alloc(32,0);return i.writeUInt32BE(r,28-t),i},f.calculateMerkleRoot=function(e){if(s([{getHash:a.Function}],e),0===e.length)throw TypeError("Cannot compute merkle root for zero transactions");var t=e.map(function(e){return e.getHash()});return o(t,i.hash256)},f.prototype.checkMerkleRoot=function(){if(!this.transactions)return!1;var e=f.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(e)},f.prototype.checkProofOfWork=function(){var e=this.getHash().reverse(),t=f.calculateTarget(this.bits);return e.compare(t)<=0},e.exports=f},function(e,t,r){var n=r(4),i=r(107),o=r(2).Buffer,s=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function u(){this.init(),this._w=a,i.call(this,64,56)}function c(e){return e<<5|e>>>27}function f(e){return e<<30|e>>>2}function l(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t=this._w,r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,a=0|this._e,u=0;u<16;++u)t[u]=e.readInt32BE(4*u);for(;u<80;++u)t[u]=t[u-3]^t[u-8]^t[u-14]^t[u-16];for(var h=0;h<80;++h){var p=~~(h/20),d=c(r)+l(p,n,i,o)+a+t[h]+s[p]|0;a=o,o=i,i=f(n),n=r,r=d}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0},u.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=u},function(e,t,r){var n=r(4),i=r(107),o=r(2).Buffer,s=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function u(){this.init(),this._w=a,i.call(this,64,56)}function c(e){return e<<1|e>>>31}function f(e){return e<<5|e>>>27}function l(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(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t=this._w,r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,a=0|this._e,u=0;u<16;++u)t[u]=e.readInt32BE(4*u);for(;u<80;++u)t[u]=c(t[u-3]^t[u-8]^t[u-14]^t[u-16]);for(var p=0;p<80;++p){var d=~~(p/20),y=f(r)+h(d,n,i,o)+a+t[p]+s[d]|0;a=o,o=i,i=l(n),n=r,r=y}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0},u.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=u},function(e,t,r){var n=r(4),i=r(408),o=r(107),s=r(2).Buffer,a=new Array(64);function u(){this.init(),this._w=a,o.call(this,64,56)}n(u,i),u.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},u.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=u},function(e,t,r){var n=r(4),i=r(409),o=r(107),s=r(2).Buffer,a=new Array(160);function u(){this.init(),this._w=a,o.call(this,128,112)}n(u,i),u.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},u.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=u},function(e,t,r){(function(t){e.exports=function(e,r){if(!Array.isArray(e))throw TypeError("Expected values Array");if("function"!=typeof r)throw TypeError("Expected digest Function");for(var n=e.length,i=e.concat();n>1;){for(var o=0,s=0;s>25;return(33554431&e)<<5^996825010&-(t>>0&1)^642813549&-(t>>1&1)^513874426&-(t>>2&1)^1027748829&-(t>>3&1)^705979059&-(t>>4&1)}function u(e){for(var t=1,r=0;r126)throw new Error("Invalid prefix ("+e+")");t=a(t)^n>>5}for(t=a(t),r=0;r=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<=t)throw new Error("Excess padding");if(i<t)throw new TypeError("Exceeds length limit");var r=e.toLowerCase(),n=e.toUpperCase();if(e!==r&&e!==n)throw new Error("Mixed-case string "+e);var o=(e=r).lastIndexOf("1");if(-1===o)throw new Error("No separator character for "+e);if(0===o)throw new Error("Missing prefix for "+e);var s=e.slice(0,o),c=e.slice(o+1);if(c.length<6)throw new Error("Data too short");for(var f=u(s),l=[],h=0;h=c.length||l.push(d)}if(1!==f)throw new Error("Invalid checksum for "+e);return{prefix:s,words:l}},encode:function(e,t,r){if(r=r||90,e.length+7+t.length>r)throw new TypeError("Exceeds length limit");for(var i=u(e=e.toLowerCase()),o=e+"1",s=0;s>5!=0)throw new Error("Non 5-bit word");i=a(i)^c,o+=n.charAt(c)}for(s=0;s<6;++s)i=a(i);for(i^=1,s=0;s<6;++s){var f=i>>5*(5-s)&31;o+=n.charAt(f)}return o},toWords:function(e){return c(e,8,5,!0)},fromWords:function(e){return c(e,5,8,!1)}}},function(e,t,r){"use strict";var n=r(14),i=r(2).Buffer;e.exports=function(e){function t(t){var r=t.slice(0,-4),n=t.slice(-4),i=e(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(t){var r=e(t);return n.encode(i.concat([t,r],t.length+4))},decode:function(e){var r=t(n.decode(e));if(!r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(e){var r=n.decodeUnsafe(e);if(r)return t(r)}}}},function(e,t,r){var n=r(2).Buffer,i=r(243),o=r(25),s=r(31),a=r(93),u=r(244),c=n.alloc(1,0),f=n.alloc(1,1),l=r(245).getCurveByName("secp256k1");function h(e,t,r){o(s.tuple(s.Hash256bit,s.Buffer256bit,s.Function),arguments);var u=n.alloc(32,0),h=n.alloc(32,1);u=i("sha256",u).update(h).update(c).update(t).update(e).digest(),h=i("sha256",u).update(h).digest(),u=i("sha256",u).update(h).update(f).update(t).update(e).digest(),h=i("sha256",u).update(h).digest(),h=i("sha256",u).update(h).digest();for(var p=a.fromBuffer(h);p.signum()<=0||p.compareTo(l.n)>=0||!r(p);)u=i("sha256",u).update(h).update(c).digest(),h=i("sha256",u).update(h).digest(),h=i("sha256",u).update(h).digest(),p=a.fromBuffer(h);return p}var p=l.n.shiftRight(1);e.exports={deterministicGenerateK:h,sign:function(e,t){o(s.tuple(s.Hash256bit,s.BigInt),arguments);var r,n,i=t.toBuffer(32),c=a.fromBuffer(e),f=l.n,d=l.G;return h(e,i,function(e){var i=d.multiply(e);return!l.isInfinity(i)&&0!==(r=i.affineX.mod(f)).signum()&&0!==(n=e.modInverse(f).multiply(c.add(t.multiply(r))).mod(f)).signum()}),n.compareTo(p)>0&&(n=f.subtract(n)),new u(r,n)},verify:function(e,t,r){o(s.tuple(s.Hash256bit,s.ECSignature,s.ECPoint),arguments);var n=l.n,i=l.G,u=t.r,c=t.s;if(u.signum()<=0||u.compareTo(n)>=0)return!1;if(c.signum()<=0||c.compareTo(n)>=0)return!1;var f=a.fromBuffer(e),h=c.modInverse(n),p=f.multiply(h).mod(n),d=u.multiply(h).mod(n),y=i.multiplyTwo(p,r,d);return!l.isInfinity(y)&&y.affineX.mod(n).equals(u)},__curve:l}},function(e,t,r){"use strict";var n=r(4),i=r(2).Buffer,o=r(92),s=i.alloc(128),a=64;function u(e,t){o.call(this,"digest"),"string"==typeof t&&(t=i.from(t)),this._alg=e,this._key=t,t.length>a?t=e(t):t.length64)throw new TypeError("Seed should be at most 512 bits");var r=s("sha512",d.MASTER_SECRET).update(e).digest(),n=r.slice(0,32),i=r.slice(32),o=f.fromBuffer(n);return new d(new l(o,null,{network:t}),i)},d.fromSeedHex=function(e,t){return d.fromSeedBuffer(n.from(e,"hex"),t)},d.fromBase58=function(e,t){var r=i.decode(e);if(78!==r.length)throw new Error("Invalid buffer length");var n,o=r.readUInt32BE(0);if(Array.isArray(t)){if(!(n=t.filter(function(e){return o===e.bip32.private||o===e.bip32.public}).pop()))throw new Error("Unknown network version")}else n=t||c.bitcoin;if(o!==n.bip32.private&&o!==n.bip32.public)throw new Error("Invalid network version");var s=r[4],a=r.readUInt32BE(5);if(0===s&&0!==a)throw new Error("Invalid parent fingerprint");var u=r.readUInt32BE(9);if(0===s&&0!==u)throw new Error("Invalid index");var y,g=r.slice(13,45);if(o===n.bip32.private){if(0!==r.readUInt8(45))throw new Error("Invalid private key");var m=f.fromBuffer(r.slice(46,78));y=new l(m,null,{network:n})}else{var b=h.Point.decodeFrom(p,r.slice(45,78));p.validate(b),y=new l(null,b,{network:n})}var v=new d(y,g);return v.depth=s,v.index=u,v.parentFingerprint=a,v},d.prototype.getAddress=function(){return this.keyPair.getAddress()},d.prototype.getIdentifier=function(){return o.hash160(this.keyPair.getPublicKeyBuffer())},d.prototype.getFingerprint=function(){return this.getIdentifier().slice(0,4)},d.prototype.getNetwork=function(){return this.keyPair.getNetwork()},d.prototype.getPublicKeyBuffer=function(){return this.keyPair.getPublicKeyBuffer()},d.prototype.neutered=function(){var e=new d(new l(null,this.keyPair.Q,{network:this.keyPair.network}),this.chainCode);return e.depth=this.depth,e.index=this.index,e.parentFingerprint=this.parentFingerprint,e},d.prototype.sign=function(e){return this.keyPair.sign(e)},d.prototype.verify=function(e,t){return this.keyPair.verify(e,t)},d.prototype.toBase58=function(e){if(void 0!==e)throw new TypeError("Unsupported argument in 2.0.0");var t=this.keyPair.network,r=this.isNeutered()?t.bip32.public:t.bip32.private,o=n.allocUnsafe(78);return o.writeUInt32BE(r,0),o.writeUInt8(this.depth,4),o.writeUInt32BE(this.parentFingerprint,5),o.writeUInt32BE(this.index,9),this.chainCode.copy(o,13),this.isNeutered()?this.keyPair.getPublicKeyBuffer().copy(o,45):(o.writeUInt8(0,45),this.keyPair.d.toBuffer(32).copy(o,46)),i.encode(o)},d.prototype.derive=function(e){a(u.UInt32,e);var t=e>=d.HIGHEST_BIT,r=n.allocUnsafe(37);if(t){if(this.isNeutered())throw new TypeError("Could not derive hardened child key");r[0]=0,this.keyPair.d.toBuffer(32).copy(r,1),r.writeUInt32BE(e,33)}else this.keyPair.getPublicKeyBuffer().copy(r,0),r.writeUInt32BE(e,33);var i,o=s("sha512",this.chainCode).update(r).digest(),c=o.slice(0,32),h=o.slice(32),y=f.fromBuffer(c);if(y.compareTo(p.n)>=0)return this.derive(e+1);if(this.isNeutered()){var g=p.G.multiply(y).add(this.keyPair.Q);if(p.isInfinity(g))return this.derive(e+1);i=new l(null,g,{network:this.keyPair.network})}else{var m=y.add(this.keyPair.d).mod(p.n);if(0===m.signum())return this.derive(e+1);i=new l(m,null,{network:this.keyPair.network})}var b=new d(i,h);return b.depth=this.depth+1,b.index=e,b.parentFingerprint=this.getFingerprint().readUInt32BE(0),b},d.prototype.deriveHardened=function(e){return a(u.UInt31,e),this.derive(e+d.HIGHEST_BIT)},d.prototype.isNeutered=function(){return!this.keyPair.d},d.prototype.derivePath=function(e){a(u.BIP32Path,e);var t=e.split("/");if("m"===t[0]){if(this.parentFingerprint)throw new Error("Not a master node");t=t.slice(1)}return t.reduce(function(e,t){var r;return"'"===t.slice(-1)?(r=parseInt(t.slice(0,-1),10),e.deriveHardened(r)):(r=parseInt(t,10),e.derive(r))},this)},e.exports=d},function(e,t,r){var n=r(2).Buffer,i=r(241),o=r(106),s=r(28),a=r(233),u=r(124),c=r(37),f=r(25),l=r(31),h=a.types,p=[a.types.P2PKH,a.types.P2PK,a.types.MULTISIG],d=p.concat([a.types.P2WPKH,a.types.P2WSH]),y=r(240),g=r(244),m=r(239);function b(e){return-1!==p.indexOf(e)}function v(e){return-1!==d.indexOf(e)}function _(e,t){if(0===e.length&&0===t.length)return{};var r,n,i,u,c,f,l,p,d,y,g=!1,m=!1,_=!1,w=s.decompile(e);a.classifyInput(w,!0)===h.P2SH&&(_=!0,c=w[w.length-1],p=a.classifyOutput(c),r=a.scriptHash.output.encode(o.hash160(c)),n=h.P2SH,u=c);var S=a.classifyWitness(t,!0);if(S===h.P2WSH){if(f=t[t.length-1],l=a.classifyOutput(f),m=!0,g=!0,0===e.length){if(r=a.witnessScriptHash.output.encode(o.sha256(f)),n=h.P2WSH,void 0!==c)throw new Error("Redeem script given when unnecessary")}else{if(!c)throw new Error("No redeemScript provided for P2WSH, but scriptSig non-empty");if(d=a.witnessScriptHash.output.encode(o.sha256(f)),!c.equals(d))throw new Error("Redeem script didn't match witnessScript")}if(!b(a.classifyOutput(f)))throw new Error("unsupported witness script");u=f,i=l,y=t.slice(0,-1)}else if(S===h.P2WPKH){g=!0;var k=t[t.length-1],E=o.hash160(k);if(0===e.length){if(r=a.witnessPubKeyHash.output.encode(E),n=h.P2WPKH,void 0!==c)throw new Error("Redeem script given when unnecessary")}else{if(!c)throw new Error("No redeemScript provided for P2WPKH, but scriptSig wasn't empty");if(d=a.witnessPubKeyHash.output.encode(E),!c.equals(d))throw new Error("Redeem script did not have the right witness program")}i=h.P2PKH,y=t}else if(c){if(!v(p))throw new Error("Bad redeemscript!");u=c,i=p,y=w.slice(0,-1)}else n=i=a.classifyInput(e),y=w;var A=function(e,t,r){var n=[],i=[];switch(e){case h.P2PKH:n=t.slice(1),i=t.slice(0,1);break;case h.P2PK:n[0]=r?a.pubKey.output.decode(r):void 0,i=t.slice(0,1);break;case h.MULTISIG:r&&(n=a.multisig.output.decode(r).pubKeys),i=t.slice(1).map(function(e){return 0===e.length?void 0:e})}return{pubKeys:n,signatures:i}}(i,y,u),x={pubKeys:A.pubKeys,signatures:A.signatures,prevOutScript:r,prevOutType:n,signType:i,signScript:u,witness:Boolean(g)};return _&&(x.redeemScript=c,x.redeemScriptType=p),m&&(x.witnessScript=f,x.witnessScriptType=l),x}function w(e,t,r){f(l.Buffer,e);var n=s.decompile(e);t||(t=a.classifyOutput(e));var i=[];switch(t){case h.P2PKH:if(!r)break;var u=n[2],c=o.hash160(r);u.equals(c)&&(i=[r]);break;case h.P2WPKH:if(!r)break;var p=n[1],d=o.hash160(r);p.equals(d)&&(i=[r]);break;case h.P2PK:i=n.slice(0,1);break;case h.MULTISIG:i=n.slice(1,-2);break;default:return{scriptType:t}}return{pubKeys:i,scriptType:t,signatures:i.map(function(){})}}function S(e,t){if(e.prevOutType){if(e.prevOutType!==h.P2SH)throw new Error("PrevOutScript must be P2SH");if(!s.decompile(e.prevOutScript)[1].equals(t))throw new Error("Inconsistent hash160(RedeemScript)")}}function k(e,t,r,n,i){var u,c,f,l,p,d,y,g,m,b=!1,v=!1,_=!1;if(r&&i){if(p=o.hash160(r),y=o.sha256(i),S(e,p),!r.equals(a.witnessScriptHash.output.encode(y)))throw new Error("Witness script inconsistent with redeem script");if(!(u=w(i,void 0,t)).pubKeys)throw new Error('WitnessScript not supported "'+s.toASM(r)+'"');c=a.types.P2SH,f=a.scriptHash.output.encode(p),b=v=_=!0,l=a.types.P2WSH,g=d=u.scriptType,m=i}else if(r){if(S(e,p=o.hash160(r)),!(u=w(r,void 0,t)).pubKeys)throw new Error('RedeemScript not supported "'+s.toASM(r)+'"');c=a.types.P2SH,f=a.scriptHash.output.encode(p),b=!0,m=r,v=(g=l=u.scriptType)===a.types.P2WPKH}else if(i){if(function(e,t){if(e.prevOutType){if(e.prevOutType!==h.P2WSH)throw new Error("PrevOutScript must be P2WSH");if(!s.decompile(e.prevOutScript)[1].equals(t))throw new Error("Inconsistent sha25(WitnessScript)")}}(e,y=o.sha256(i)),!(u=w(i,void 0,t)).pubKeys)throw new Error('WitnessScript not supported "'+s.toASM(r)+'"');c=a.types.P2WSH,f=a.witnessScriptHash.output.encode(y),v=_=!0,g=d=u.scriptType,m=i}else if(e.prevOutType){if(e.prevOutType===h.P2SH||e.prevOutType===h.P2WSH)throw new Error("PrevOutScript is "+e.prevOutType+", requires redeemScript");if(c=e.prevOutType,f=e.prevOutScript,!(u=w(e.prevOutScript,e.prevOutType,t)).pubKeys)return;v=e.prevOutType===h.P2WPKH,g=c,m=f}else u=w(f=a.pubKeyHash.output.encode(o.hash160(t)),h.P2PKH,t),v=!1,g=c=h.P2PKH,m=f;g===h.P2WPKH&&(m=a.pubKeyHash.output.encode(a.witnessPubKeyHash.output.decode(m))),b&&(e.redeemScript=r,e.redeemScriptType=l),_&&(e.witnessScript=i,e.witnessScriptType=d),e.pubKeys=u.pubKeys,e.signatures=u.signatures,e.signScript=m,e.signType=g,e.prevOutScript=f,e.prevOutType=c,e.witness=v}function E(e,t,r,i){if(e===h.P2PKH){if(1===t.length&&n.isBuffer(t[0])&&1===r.length)return a.pubKeyHash.input.encodeStack(t[0],r[0])}else if(e===h.P2PK){if(1===t.length&&n.isBuffer(t[0]))return a.pubKey.input.encodeStack(t[0])}else{if(e!==h.MULTISIG)throw new Error("Not yet supported");if(t.length>0)return t=t.map(function(e){return e||c.OP_0}),i||(t=t.filter(function(e){return e!==c.OP_0})),a.multisig.input.encodeStack(t)}if(!i)throw new Error("Not enough signatures provided");return[]}function A(e,t){this.prevTxMap={},this.network=e||u.bitcoin,this.maximumFeeRate=t||2500,this.inputs=[],this.tx=new m}function x(e){return void 0!==e.prevOutScript&&void 0!==e.signScript&&void 0!==e.pubKeys&&void 0!==e.signatures&&e.signatures.length===e.pubKeys.length&&e.pubKeys.length>0&&(!1===e.witness||!0===e.witness&&void 0!==e.value)}function I(e){return e.readUInt8(e.length-1)}A.prototype.setLockTime=function(e){if(f(l.UInt32,e),this.inputs.some(function(e){return!!e.signatures&&e.signatures.some(function(e){return e})}))throw new Error("No, this would invalidate signatures");this.tx.locktime=e},A.prototype.setVersion=function(e){f(l.UInt32,e),this.tx.version=e},A.fromTransaction=function(e,t){var r=new A(t);return r.setVersion(e.version),r.setLockTime(e.locktime),e.outs.forEach(function(e){r.addOutput(e.script,e.value)}),e.ins.forEach(function(e){r.__addInputUnsafe(e.hash,e.index,{sequence:e.sequence,script:e.script,witness:e.witness})}),r.inputs.forEach(function(t,r){!function(e,t,r){if(e.redeemScriptType===h.MULTISIG&&e.redeemScript&&e.pubKeys.length!==e.signatures.length){var n=e.signatures.concat();e.signatures=e.pubKeys.map(function(i){var o,s=y.fromPublicKeyBuffer(i);return n.some(function(i,a){if(!i)return!1;var u=g.parseScriptSignature(i),c=t.hashForSignature(r,e.redeemScript,u.hashType);return!!s.verify(c,u.signature)&&(n[a]=void 0,o=i,!0)}),o})}}(t,e,r)}),r},A.prototype.addInput=function(e,t,r,i){if(!this.__canModifyInputs())throw new Error("No, this would invalidate signatures");var o;if("string"==typeof e)e=n.from(e,"hex").reverse();else if(e instanceof m){var s=e.outs[t];i=s.script,o=s.value,e=e.getHash()}return this.__addInputUnsafe(e,t,{sequence:r,prevOutScript:i,value:o})},A.prototype.__addInputUnsafe=function(e,t,r){if(m.isCoinbaseHash(e))throw new Error("coinbase inputs not supported");var n=e.toString("hex")+":"+t;if(void 0!==this.prevTxMap[n])throw new Error("Duplicate TxOut: "+n);var i={};if(void 0!==r.script&&(i=_(r.script,r.witness||[])),void 0!==r.value&&(i.value=r.value),!i.prevOutScript&&r.prevOutScript){var o;if(!i.pubKeys&&!i.signatures){var s=w(r.prevOutScript);s.pubKeys&&(i.pubKeys=s.pubKeys,i.signatures=s.signatures),o=s.scriptType}i.prevOutScript=r.prevOutScript,i.prevOutType=o||a.classifyOutput(r.prevOutScript)}var u=this.tx.addInput(e,t,r.sequence,r.scriptSig);return this.inputs[u]=i,this.prevTxMap[n]=u,u},A.prototype.addOutput=function(e,t){if(!this.__canModifyOutputs())throw new Error("No, this would invalidate signatures");return"string"==typeof e&&(e=i.toOutputScript(e,this.network)),this.tx.addOutput(e,t)},A.prototype.build=function(){return this.__build(!1)},A.prototype.buildIncomplete=function(){return this.__build(!0)},A.prototype.__build=function(e){if(!e){if(!this.tx.ins.length)throw new Error("Transaction has no inputs");if(!this.tx.outs.length)throw new Error("Transaction has no outputs")}var t=this.tx.clone();if(this.inputs.forEach(function(r,n){if(!(r.witnessScriptType||r.redeemScriptType||r.prevOutType||e))throw new Error("Transaction is not complete");var i=function(e,t){var r=e.prevOutType,n=[],i=[];b(r)&&(n=E(r,e.signatures,e.pubKeys,t));var o=!1;if(r===a.types.P2SH){if(!t&&!v(e.redeemScriptType))throw new Error("Impossible to sign this type");b(e.redeemScriptType)&&(n=E(e.redeemScriptType,e.signatures,e.pubKeys,t)),e.redeemScriptType&&(o=!0,r=e.redeemScriptType)}switch(r){case a.types.P2WPKH:i=E(a.types.P2PKH,e.signatures,e.pubKeys,t);break;case a.types.P2WSH:if(!t&&!b(e.witnessScriptType))throw new Error("Impossible to sign this type");b(e.witnessScriptType)&&((i=E(e.witnessScriptType,e.signatures,e.pubKeys,t)).push(e.witnessScript),r=e.witnessScriptType)}return o&&n.push(e.redeemScript),{type:r,script:s.compile(n),witness:i}}(r,e);if(!e&&!b(i.type)&&i.type!==a.types.P2WPKH)throw new Error(i.type+" not supported");t.setInputScript(n,i.script),t.setWitness(n,i.witness)}),!e&&this.__overMaximumFees(t.virtualSize()))throw new Error("Transaction has absurd fees");return t},A.prototype.sign=function(e,t,r,i,o,s){if(t.network&&t.network!==this.network)throw new TypeError("Inconsistent network");if(!this.inputs[e])throw new Error("No input at index: "+e);i=i||m.SIGHASH_ALL;var a=this.inputs[e];if(void 0!==a.redeemScript&&r&&!a.redeemScript.equals(r))throw new Error("Inconsistent redeemScript");var u,c=t.publicKey||t.getPublicKeyBuffer();if(!x(a)){if(void 0!==o){if(void 0!==a.value&&a.value!==o)throw new Error("Input didn't match witnessValue");f(l.Satoshi,o),a.value=o}if(x(a)||k(a,c,r,0,s),!x(a))throw Error(a.prevOutType+" not supported")}if(u=a.witness?this.tx.hashForWitnessV0(e,a.signScript,a.value,i):this.tx.hashForSignature(e,a.signScript,i),!a.pubKeys.some(function(e,r){if(!c.equals(e))return!1;if(a.signatures[r])throw new Error("Signature already exists");if(33!==c.length&&a.signType===h.P2WPKH)throw new Error("BIP143 rejects uncompressed public keys in P2WPKH or P2WSH");var o=t.sign(u);return n.isBuffer(o)&&(o=g.fromRSBuffer(o)),a.signatures[r]=o.toScriptSignature(i),!0}))throw new Error("Key pair cannot sign for this input")},A.prototype.__canModifyInputs=function(){return this.inputs.every(function(e){return void 0===e.signatures||e.signatures.every(function(e){return!e||I(e)&m.SIGHASH_ANYONECANPAY})})},A.prototype.__canModifyOutputs=function(){var e=this.tx.ins.length,t=this.tx.outs.length;return this.inputs.every(function(r){return void 0===r.signatures||r.signatures.every(function(r){if(!r)return!0;var n=31&I(r);return n===m.SIGHASH_NONE||(n===m.SIGHASH_SINGLE?e<=t:void 0)})})},A.prototype.__overMaximumFees=function(e){return(this.inputs.reduce(function(e,t){return e+(t.value>>>0)},0)-this.tx.outs.reduce(function(e,t){return e+t.value},0))/e>this.maximumFeeRate},e.exports=A},function(e,t,r){const n=r(173),i=r(126),o=r(2).Buffer;var s=e.exports=function(e){var t=[{name:"nonce",default:o.alloc(0)},{name:"balance",default:o.alloc(0)},{name:"stateRoot",length:32,default:n.SHA3_RLP},{name:"codeHash",length:32,default:n.SHA3_NULL}];n.defineProperties(this,t,e)};s.prototype.serialize=function(){return i.encode(this.raw)},s.prototype.isContract=function(){return this.codeHash.toString("hex")!==n.SHA3_NULL_S},s.prototype.getCode=function(e,t){this.isContract()?e.getRaw(this.codeHash,t):t(null,o.alloc(0))},s.prototype.setCode=function(e,t,r){var i=this;this.codeHash=n.sha3(t),this.codeHash.toString("hex")!==n.SHA3_NULL_S?e.putRaw(this.codeHash,t,function(e){r(e,i.codeHash)}):r(null,o.alloc(0))},s.prototype.getStorage=function(e,t,r){var n=e.copy();n.root=this.stateRoot,n.get(t,r)},s.prototype.setStorage=function(e,t,r,n){var i=this,o=e.copy();o.root=i.stateRoot,o.put(t,r,function(e){if(e)return n();i.stateRoot=o.root,n()})},s.prototype.isEmpty=function(){return""===this.balance.toString("hex")&&""===this.nonce.toString("hex")&&this.stateRoot.toString("hex")===n.SHA3_RLP_S&&this.codeHash.toString("hex")===n.SHA3_NULL_S}},function(e,t,r){"use strict";e.exports=r(811)(r(814))},function(e,t,r){"use strict";var n=r(812),i=r(813);e.exports=function(e){var t=n(e),r=i(e);return function(e,n){switch("string"==typeof e?e.toLowerCase():e){case"keccak224":return new t(1152,448,null,224,n);case"keccak256":return new t(1088,512,null,256,n);case"keccak384":return new t(832,768,null,384,n);case"keccak512":return new t(576,1024,null,512,n);case"sha3-224":return new t(1152,448,6,224,n);case"sha3-256":return new t(1088,512,6,256,n);case"sha3-384":return new t(832,768,6,384,n);case"sha3-512":return new t(576,1024,6,512,n);case"shake128":return new r(1344,256,31,n);case"shake256":return new r(1088,512,31,n);default:throw new Error("Invald algorithm: "+e)}}}},function(e,t,r){"use strict";var n=r(2).Buffer,i=r(90).Transform,o=r(4);e.exports=function(e){function t(t,r,n,o,s){i.call(this,s),this._rate=t,this._capacity=r,this._delimitedSuffix=n,this._hashBitLength=o,this._options=s,this._state=new e,this._state.initialize(t,r),this._finalized=!1}return o(t,i),t.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(e){n=e}r(n)},t.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)},t.prototype.update=function(e,t){if(!n.isBuffer(e)&&"string"!=typeof e)throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Digest already called");return n.isBuffer(e)||(e=n.from(e,t)),this._state.absorb(e),this},t.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0,this._delimitedSuffix&&this._state.absorbLastFewBits(this._delimitedSuffix);var t=this._state.squeeze(this._hashBitLength/8);return void 0!==e&&(t=t.toString(e)),this._resetState(),t},t.prototype._resetState=function(){return this._state.initialize(this._rate,this._capacity),this},t.prototype._clone=function(){var e=new t(this._rate,this._capacity,this._delimitedSuffix,this._hashBitLength,this._options);return this._state.copy(e._state),e._finalized=this._finalized,e},t}},function(e,t,r){"use strict";var n=r(2).Buffer,i=r(90).Transform,o=r(4);e.exports=function(e){function t(t,r,n,o){i.call(this,o),this._rate=t,this._capacity=r,this._delimitedSuffix=n,this._options=o,this._state=new e,this._state.initialize(t,r),this._finalized=!1}return o(t,i),t.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(e){n=e}r(n)},t.prototype._flush=function(){},t.prototype._read=function(e){this.push(this.squeeze(e))},t.prototype.update=function(e,t){if(!n.isBuffer(e)&&"string"!=typeof e)throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Squeeze already called");return n.isBuffer(e)||(e=n.from(e,t)),this._state.absorb(e),this},t.prototype.squeeze=function(e,t){this._finalized||(this._finalized=!0,this._state.absorbLastFewBits(this._delimitedSuffix));var r=this._state.squeeze(e);return void 0!==t&&(r=r.toString(t)),r},t.prototype._resetState=function(){return this._state.initialize(this._rate,this._capacity),this},t.prototype._clone=function(){var e=new t(this._rate,this._capacity,this._delimitedSuffix,this._options);return this._state.copy(e._state),e._finalized=this._finalized,e},t}},function(e,t,r){"use strict";var n=r(2).Buffer,i=r(815);function o(){this.state=[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],this.blockSize=null,this.count=0,this.squeezing=!1}o.prototype.initialize=function(e,t){for(var r=0;r<50;++r)this.state[r]=0;this.blockSize=e/8,this.count=0,this.squeezing=!1},o.prototype.absorb=function(e){for(var t=0;t>>this.count%4*8&255,this.count+=1,this.count===this.blockSize&&(i.p1600(this.state),this.count=0);return t},o.prototype.copy=function(e){for(var t=0;t<50;++t)e.state[t]=this.state[t];e.blockSize=this.blockSize,e.count=this.count,e.squeezing=this.squeezing},e.exports=o},function(e,t,r){"use strict";var n=[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];t.p1600=function(e){for(var t=0;t<24;++t){var r=e[0]^e[10]^e[20]^e[30]^e[40],i=e[1]^e[11]^e[21]^e[31]^e[41],o=e[2]^e[12]^e[22]^e[32]^e[42],s=e[3]^e[13]^e[23]^e[33]^e[43],a=e[4]^e[14]^e[24]^e[34]^e[44],u=e[5]^e[15]^e[25]^e[35]^e[45],c=e[6]^e[16]^e[26]^e[36]^e[46],f=e[7]^e[17]^e[27]^e[37]^e[47],l=e[8]^e[18]^e[28]^e[38]^e[48],h=e[9]^e[19]^e[29]^e[39]^e[49],p=l^(o<<1|s>>>31),d=h^(s<<1|o>>>31),y=e[0]^p,g=e[1]^d,m=e[10]^p,b=e[11]^d,v=e[20]^p,_=e[21]^d,w=e[30]^p,S=e[31]^d,k=e[40]^p,E=e[41]^d;p=r^(a<<1|u>>>31),d=i^(u<<1|a>>>31);var A=e[2]^p,x=e[3]^d,I=e[12]^p,T=e[13]^d,B=e[22]^p,C=e[23]^d,P=e[32]^p,O=e[33]^d,R=e[42]^p,N=e[43]^d;p=o^(c<<1|f>>>31),d=s^(f<<1|c>>>31);var L=e[4]^p,j=e[5]^d,M=e[14]^p,K=e[15]^d,D=e[24]^p,U=e[25]^d,F=e[34]^p,q=e[35]^d,H=e[44]^p,z=e[45]^d;p=a^(l<<1|h>>>31),d=u^(h<<1|l>>>31);var V=e[6]^p,G=e[7]^d,W=e[16]^p,$=e[17]^d,Y=e[26]^p,J=e[27]^d,X=e[36]^p,Z=e[37]^d,Q=e[46]^p,ee=e[47]^d;p=c^(r<<1|i>>>31),d=f^(i<<1|r>>>31);var te=e[8]^p,re=e[9]^d,ne=e[18]^p,ie=e[19]^d,oe=e[28]^p,se=e[29]^d,ae=e[38]^p,ue=e[39]^d,ce=e[48]^p,fe=e[49]^d,le=y,he=g,pe=b<<4|m>>>28,de=m<<4|b>>>28,ye=v<<3|_>>>29,ge=_<<3|v>>>29,me=S<<9|w>>>23,be=w<<9|S>>>23,ve=k<<18|E>>>14,_e=E<<18|k>>>14,we=A<<1|x>>>31,Se=x<<1|A>>>31,ke=T<<12|I>>>20,Ee=I<<12|T>>>20,Ae=B<<10|C>>>22,xe=C<<10|B>>>22,Ie=O<<13|P>>>19,Te=P<<13|O>>>19,Be=R<<2|N>>>30,Ce=N<<2|R>>>30,Pe=j<<30|L>>>2,Oe=L<<30|j>>>2,Re=M<<6|K>>>26,Ne=K<<6|M>>>26,Le=U<<11|D>>>21,je=D<<11|U>>>21,Me=F<<15|q>>>17,Ke=q<<15|F>>>17,De=z<<29|H>>>3,Ue=H<<29|z>>>3,Fe=V<<28|G>>>4,qe=G<<28|V>>>4,He=$<<23|W>>>9,ze=W<<23|$>>>9,Ve=Y<<25|J>>>7,Ge=J<<25|Y>>>7,We=X<<21|Z>>>11,$e=Z<<21|X>>>11,Ye=ee<<24|Q>>>8,Je=Q<<24|ee>>>8,Xe=te<<27|re>>>5,Ze=re<<27|te>>>5,Qe=ne<<20|ie>>>12,et=ie<<20|ne>>>12,tt=se<<7|oe>>>25,rt=oe<<7|se>>>25,nt=ae<<8|ue>>>24,it=ue<<8|ae>>>24,ot=ce<<14|fe>>>18,st=fe<<14|ce>>>18;e[0]=le^~ke&Le,e[1]=he^~Ee&je,e[10]=Fe^~Qe&ye,e[11]=qe^~et&ge,e[20]=we^~Re&Ve,e[21]=Se^~Ne&Ge,e[30]=Xe^~pe&Ae,e[31]=Ze^~de&xe,e[40]=Pe^~He&tt,e[41]=Oe^~ze&rt,e[2]=ke^~Le&We,e[3]=Ee^~je&$e,e[12]=Qe^~ye&Ie,e[13]=et^~ge&Te,e[22]=Re^~Ve&nt,e[23]=Ne^~Ge&it,e[32]=pe^~Ae&Me,e[33]=de^~xe&Ke,e[42]=He^~tt&me,e[43]=ze^~rt&be,e[4]=Le^~We&ot,e[5]=je^~$e&st,e[14]=ye^~Ie&De,e[15]=ge^~Te&Ue,e[24]=Ve^~nt&ve,e[25]=Ge^~it&_e,e[34]=Ae^~Me&Ye,e[35]=xe^~Ke&Je,e[44]=tt^~me&Be,e[45]=rt^~be&Ce,e[6]=We^~ot&le,e[7]=$e^~st&he,e[16]=Ie^~De&Fe,e[17]=Te^~Ue&qe,e[26]=nt^~ve&we,e[27]=it^~_e&Se,e[36]=Me^~Ye&Xe,e[37]=Ke^~Je&Ze,e[46]=me^~Be&Pe,e[47]=be^~Ce&Oe,e[8]=ot^~le&ke,e[9]=st^~he&Ee,e[18]=De^~Fe&Qe,e[19]=Ue^~qe&et,e[28]=ve^~we&Re,e[29]=_e^~Se&Ne,e[38]=Ye^~Xe&pe,e[39]=Je^~Ze&de,e[48]=Be^~Pe&He,e[49]=Ce^~Oe&ze,e[0]^=n[2*t],e[1]^=n[2*t+1]}}},function(e,t,r){"use strict";e.exports=r(414)(r(819))},function(e,t,r){"use strict";(function(e){var r=Object.prototype.toString;t.isArray=function(e,t){if(!Array.isArray(e))throw TypeError(t)},t.isBoolean=function(e,t){if("[object Boolean]"!==r.call(e))throw TypeError(t)},t.isBuffer=function(t,r){if(!e.isBuffer(t))throw TypeError(r)},t.isFunction=function(e,t){if("[object Function]"!==r.call(e))throw TypeError(t)},t.isNumber=function(e,t){if("[object Number]"!==r.call(e))throw TypeError(t)},t.isObject=function(e,t){if("[object Object]"!==r.call(e))throw TypeError(t)},t.isBufferLength=function(e,t,r){if(e.length!==t)throw RangeError(r)},t.isBufferLength2=function(e,t,r,n){if(e.length!==t&&e.length!==r)throw RangeError(n)},t.isLengthGTZero=function(e,t){if(0===e.length)throw RangeError(t)},t.isNumberInInterval=function(e,t,r,n){if(e<=t||e>=r)throw RangeError(n)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";var n=r(2).Buffer,i=r(231),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,u=0;a>1&&0===s[u]&&!(128&s[u+1]);--a,++u);return i.encode(t.slice(o),s.slice(u))},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 u=o;if(o+=a,2===e[o++]){var c=e[o++];if(128&c){if(o+(s=c-128)>i)return;for(;s>0&&0===e[o];o+=1,s-=1);for(c=0;s>0;o+=1,s-=1)c=(c<<8)+e[o]}if(!(c>i-o)){var f=o;for(o+=c;a>0&&0===e[u];a-=1,u+=1);if(!(a>32)){var l=e.slice(u,u+a);for(l.copy(t,32-l.length);c>0&&0===e[f];c-=1,f+=1);if(!(c>32)){var h=e.slice(f,f+c);return h.copy(r,32-h.length),{r:t,s:r}}}}}}}}}},function(e,t,r){"use strict";var n=r(2).Buffer,i=r(123),o=r(55),s=r(56).ec,a=r(246),u=new s("secp256k1"),c=u.curve;function f(e){var t=e[0];switch(t){case 2:case 3:return 33!==e.length?null:function(e,t){var r=new o(t);if(r.cmp(c.p)>=0)return null;var n=(r=r.toRed(c.red)).redSqr().redIMul(r).redIAdd(c.b).redSqrt();return 3===e!==n.isOdd()&&(n=n.redNeg()),u.keyPair({pub:{x:r,y:n}})}(t,e.slice(1,33));case 4:case 6:case 7:return 65!==e.length?null:function(e,t,r){var n=new o(t),i=new o(r);if(n.cmp(c.p)>=0||i.cmp(c.p)>=0)return null;if(n=n.toRed(c.red),i=i.toRed(c.red),(6===e||7===e)&&i.isOdd()!==(7===e))return null;var s=n.redSqr().redIMul(n);return i.redSqr().redISub(s.redIAdd(c.b)).isZero()?u.keyPair({pub:{x:n,y:i}}):null}(t,e.slice(1,33),e.slice(33,65));default:return null}}t.privateKeyVerify=function(e){var t=new o(e);return t.cmp(c.n)<0&&!t.isZero()},t.privateKeyExport=function(e,t){var r=new o(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(a.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return n.from(u.keyFromPrivate(e).getPublic(t,!0))},t.privateKeyNegate=function(e){var t=new o(e);return t.isZero()?n.alloc(32):c.n.sub(t).umod(c.n).toArrayLike(n,"be",32)},t.privateKeyModInverse=function(e){var t=new o(e);if(t.cmp(c.n)>=0||t.isZero())throw new Error(a.EC_PRIVATE_KEY_RANGE_INVALID);return t.invm(c.n).toArrayLike(n,"be",32)},t.privateKeyTweakAdd=function(e,t){var r=new o(t);if(r.cmp(c.n)>=0)throw new Error(a.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(r.iadd(new o(e)),r.cmp(c.n)>=0&&r.isub(c.n),r.isZero())throw new Error(a.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return r.toArrayLike(n,"be",32)},t.privateKeyTweakMul=function(e,t){var r=new o(t);if(r.cmp(c.n)>=0||r.isZero())throw new Error(a.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return r.imul(new o(e)),r.cmp(c.n)&&(r=r.umod(c.n)),r.toArrayLike(n,"be",32)},t.publicKeyCreate=function(e,t){var r=new o(e);if(r.cmp(c.n)>=0||r.isZero())throw new Error(a.EC_PUBLIC_KEY_CREATE_FAIL);return n.from(u.keyFromPrivate(e).getPublic(t,!0))},t.publicKeyConvert=function(e,t){var r=f(e);if(null===r)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);return n.from(r.getPublic(t,!0))},t.publicKeyVerify=function(e){return null!==f(e)},t.publicKeyTweakAdd=function(e,t,r){var i=f(e);if(null===i)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new o(t)).cmp(c.n)>=0)throw new Error(a.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return n.from(c.g.mul(t).add(i.pub).encode(!0,r))},t.publicKeyTweakMul=function(e,t,r){var i=f(e);if(null===i)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new o(t)).cmp(c.n)>=0||t.isZero())throw new Error(a.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return n.from(i.pub.mul(t).encode(!0,r))},t.publicKeyCombine=function(e,t){for(var r=new Array(e.length),i=0;i=0||r.cmp(c.n)>=0)throw new Error(a.ECDSA_SIGNATURE_PARSE_FAIL);var i=n.from(e);return 1===r.cmp(u.nh)&&c.n.sub(r).toArrayLike(n,"be",32).copy(i,32),i},t.signatureExport=function(e){var t=e.slice(0,32),r=e.slice(32,64);if(new o(t).cmp(c.n)>=0||new o(r).cmp(c.n)>=0)throw new Error(a.ECDSA_SIGNATURE_PARSE_FAIL);return{r:t,s:r}},t.signatureImport=function(e){var t=new o(e.r);t.cmp(c.n)>=0&&(t=new o(0));var r=new o(e.s);return r.cmp(c.n)>=0&&(r=new o(0)),n.concat([t.toArrayLike(n,"be",32),r.toArrayLike(n,"be",32)])},t.sign=function(e,t,r,i){if("function"==typeof r){var s=r;r=function(r){var u=s(e,t,null,i,r);if(!n.isBuffer(u)||32!==u.length)throw new Error(a.ECDSA_SIGN_FAIL);return new o(u)}}var f=new o(t);if(f.cmp(c.n)>=0||f.isZero())throw new Error(a.ECDSA_SIGN_FAIL);var l=u.sign(e,t,{canonical:!0,k:r,pers:i});return{signature:n.concat([l.r.toArrayLike(n,"be",32),l.s.toArrayLike(n,"be",32)]),recovery:l.recoveryParam}},t.verify=function(e,t,r){var n={r:t.slice(0,32),s:t.slice(32,64)},i=new o(n.r),s=new o(n.s);if(i.cmp(c.n)>=0||s.cmp(c.n)>=0)throw new Error(a.ECDSA_SIGNATURE_PARSE_FAIL);if(1===s.cmp(u.nh)||i.isZero()||s.isZero())return!1;var l=f(r);if(null===l)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);return u.verify(e,n,{x:l.pub.x,y:l.pub.y})},t.recover=function(e,t,r,i){var s={r:t.slice(0,32),s:t.slice(32,64)},f=new o(s.r),l=new o(s.s);if(f.cmp(c.n)>=0||l.cmp(c.n)>=0)throw new Error(a.ECDSA_SIGNATURE_PARSE_FAIL);try{if(f.isZero()||l.isZero())throw new Error;var h=u.recoverPubKey(e,s,r);return n.from(h.encode(!0,i))}catch(e){throw new Error(a.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 i=f(e);if(null===i)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);var s=new o(t);if(s.cmp(c.n)>=0||s.isZero())throw new Error(a.ECDH_FAIL);return n.from(i.pub.mul(s).encode(!0,r))}},function(e,t){},function(e){e.exports={_from:"elliptic@^6.2.3",_id:"elliptic@6.4.0",_inBundle:!1,_integrity:"sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=",_location:"/elliptic",_phantomChildren:{},_requested:{type:"range",registry:!0,raw:"elliptic@^6.2.3",name:"elliptic",escapedName:"elliptic",rawSpec:"^6.2.3",saveSpec:null,fetchSpec:"^6.2.3"},_requiredBy:["/browserify-sign","/create-ecdh","/secp256k1"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz",_shasum:"cac9af8762c85836187003c8dfe193e5e2eae5df",_spec:"elliptic@^6.2.3",_where:"/Users/mitra/git/dweb-transports/node_modules/secp256k1",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},bundleDependencies:!1,dependencies:{"bn.js":"^4.4.0",brorand:"^1.0.1","hash.js":"^1.0.0","hmac-drbg":"^1.0.0",inherits:"^2.0.1","minimalistic-assert":"^1.0.0","minimalistic-crypto-utils":"^1.0.0"},deprecated:!1,description:"EC cryptography",devDependencies:{brfs:"^1.4.3",coveralls:"^2.11.3",grunt:"^0.4.5","grunt-browserify":"^5.0.0","grunt-cli":"^1.2.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^8.6.2",istanbul:"^0.4.2",jscs:"^2.9.0",jshint:"^2.6.0",mocha:"^2.1.0"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{jscs:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",jshint:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",lint:"npm run jscs && npm run jshint",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.4.0"}},function(e,t,r){"use strict";var n=t,i=r(55),o=r(81),s=r(415);n.assert=o,n.toArray=s.toArray,n.zero2=s.zero2,n.toHex=s.toHex,n.encode=s.encode,n.getNAF=function(e,t){for(var r=[],n=1<=0;){var o;if(i.isOdd()){var s=i.andln(n-1);o=s>(n>>1)-1?(n>>1)-s:s,i.isubn(o)}else o=0;r.push(o);for(var a=0!==i.cmpn(0)&&0===i.andln(n-1)?t+1:1,u=1;u0||t.cmpn(-i)>0;){var o,s,a,u=e.andln(3)+n&3,c=t.andln(3)+i&3;3===u&&(u=-1),3===c&&(c=-1),o=0==(1&u)?0:3!=(a=e.andln(7)+n&7)&&5!==a||2!==c?u:-u,r[0].push(o),s=0==(1&c)?0:3!=(a=t.andln(7)+i&7)&&5!==a||2!==u?c:-c,r[1].push(s),2*n===o+1&&(n=1-n),2*i===s+1&&(i=1-i),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){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;r0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function c(e,t){this.curve=e,this.type=t,this.precomputed=null}e.exports=u,u.prototype.point=function(){throw new Error("Not implemented")},u.prototype.validate=function(){throw new Error("Not implemented")},u.prototype._fixedNafMul=function(e,t){a(e.precomputed);var r=e._getDoubles(),n=o(t,1),i=(1<=u;t--)c=(c<<1)+n[t];s.push(c)}for(var f=this.jpoint(null,null,null),l=this.jpoint(null,null,null),h=i;h>0;h--){for(u=0;u=0;c--){for(t=0;c>=0&&0===s[c];c--)t++;if(c>=0&&t++,u=u.dblp(t),c<0)break;var f=s[c];a(0!==f),u="affine"===e.type?f>0?u.mixedAdd(i[f-1>>1]):u.mixedAdd(i[-f-1>>1].neg()):f>0?u.add(i[f-1>>1]):u.add(i[-f-1>>1].neg())}return"affine"===e.type?u.toP():u},u.prototype._wnafMulAdd=function(e,t,r,n,i){for(var a=this._wnafT1,u=this._wnafT2,c=this._wnafT3,f=0,l=0;l=1;l-=2){var p=l-1,d=l;if(1===a[p]&&1===a[d]){var y=[t[p],null,null,t[d]];0===t[p].y.cmp(t[d].y)?(y[1]=t[p].add(t[d]),y[2]=t[p].toJ().mixedAdd(t[d].neg())):0===t[p].y.cmp(t[d].y.redNeg())?(y[1]=t[p].toJ().mixedAdd(t[d]),y[2]=t[p].add(t[d].neg())):(y[1]=t[p].toJ().mixedAdd(t[d]),y[2]=t[p].toJ().mixedAdd(t[d].neg()));var g=[-3,-1,-5,-7,0,7,5,1,3],m=s(r[p],r[d]);f=Math.max(m[0].length,f),c[p]=new Array(f),c[d]=new Array(f);for(var b=0;b=0;l--){for(var k=0;l>=0;){var E=!0;for(b=0;b=0&&k++,w=w.dblp(k),l<0)break;for(b=0;b0?A=u[b][x-1>>1]:x<0&&(A=u[b][-x-1>>1].neg()),w="affine"===A.type?w.mixedAdd(A):w.add(A))}}for(l=0;l=Math.ceil((e.bitLength()+1)/t.step)},c.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i=0&&(s=t,a=r),n.negative&&(n=n.neg(),i=i.neg()),s.negative&&(s=s.neg(),a=a.neg()),[{a:n,b:i},{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),u=i.mul(r.b),c=o.mul(n.b);return{k1:e.sub(s).sub(a),k2:u.add(c).neg()}},c.prototype.pointFromX=function(e,t){(e=new o(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 i=n.fromRed().isOdd();return(t&&!i||!t&&i)&&(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":""},f.prototype.isInfinity=function(){return this.inf},f.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)},f.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)},f.prototype.getX=function(){return this.x.fromRed()},f.prototype.getY=function(){return this.y.fromRed()},f.prototype.mul=function(e){return e=new o(e,16),this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},f.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)},f.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)},f.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))},f.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},f.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},s(l,a.BasePoint),c.prototype.jpoint=function(e,t,r){return new l(this,e,t,r)},l.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)},l.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},l.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),u=o.redSub(s);if(0===a.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=a.redSqr(),f=c.redMul(a),l=n.redMul(c),h=u.redSqr().redIAdd(f).redISub(l).redISub(l),p=u.redMul(l.redISub(h)).redISub(o.redMul(f)),d=this.z.redMul(e.z).redMul(a);return this.curve.jpoint(h,p,d)},l.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 u=s.redSqr(),c=u.redMul(s),f=r.redMul(u),l=a.redSqr().redIAdd(c).redISub(f).redISub(f),h=a.redMul(f.redISub(l)).redISub(i.redMul(c)),p=this.z.redMul(s);return this.curve.jpoint(l,h,p)},l.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}return!1},l.prototype.inspect=function(){return this.isInfinity()?"":""},l.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},function(e,t,r){"use strict";var n=r(174),i=r(55),o=r(4),s=n.base,a=r(56).utils;function u(e){s.call(this,"mont",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function c(e,t,r){s.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(t,16),this.z=new i(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}o(u,s),e.exports=u,u.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)},o(c,s.BasePoint),u.prototype.decodePoint=function(e,t){return this.point(a.toArray(e,t),1)},u.prototype.point=function(e,t){return new c(this,e,t)},u.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()),u=t.x.redMul(o.redISub(s).redSqr());return this.curve.point(a,u)},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(174),i=r(56),o=r(55),s=r(4),a=n.base,u=i.utils.assert;function c(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,a.call(this,"edwards",e),this.a=new o(e.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new o(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new o(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),u(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}function f(e,t,r,n,i){a.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 o(t,16),this.y=new o(r,16),this.z=n?new o(n,16):this.curve.one,this.t=i&&new o(i,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()))))}s(c,a),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 o(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),n=this.c2.redSub(this.a.redMul(r)),i=this.one.redSub(this.c2.redMul(this.d).redMul(r)),s=n.redMul(i.redInvm()),a=s.redSqrt();if(0!==a.redSqr().redSub(s).cmp(this.zero))throw new Error("invalid point");var u=a.fromRed().isOdd();return(t&&!u||!t&&u)&&(a=a.redNeg()),this.point(e,a)},c.prototype.pointFromY=function(e,t){(e=new o(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),n=r.redSub(this.one),i=r.redMul(this.d).redAdd(this.one),s=n.redMul(i.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.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)},s(f,a.BasePoint),c.prototype.pointFromJSON=function(e){return f.fromJSON(this,e)},c.prototype.point=function(e,t,r,n){return new f(this,e,t,r,n)},f.fromJSON=function(e,t){return new f(e,t[0],t[1],t[2])},f.prototype.inspect=function(){return this.isInfinity()?"":""},f.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&0===this.y.cmp(this.z)},f.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),u=i.redMul(s),c=o.redMul(a),f=i.redMul(a),l=s.redMul(o);return this.curve.point(u,c,l,f)},f.prototype._projDbl=function(){var e,t,r,n=this.x.redAdd(this.y).redSqr(),i=this.x.redSqr(),o=this.y.redSqr();if(this.curve.twisted){var s=(c=this.curve._mulA(i)).redAdd(o);if(this.zOne)e=n.redSub(i).redSub(o).redMul(s.redSub(this.curve.two)),t=s.redMul(c.redSub(o)),r=s.redSqr().redSub(s).redSub(s);else{var a=this.z.redSqr(),u=s.redSub(a).redISub(a);e=n.redSub(i).redISub(o).redMul(u),t=s.redMul(c.redSub(o)),r=s.redMul(u)}}else{var c=i.redAdd(o);a=this.curve._mulC(this.c.redMul(this.z)).redSqr(),u=c.redSub(a).redSub(a);e=this.curve._mulC(n.redISub(c)).redMul(u),t=this.curve._mulC(c).redMul(i.redISub(o)),r=c.redMul(u)}return this.curve.point(e,t,r)},f.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},f.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),u=r.redAdd(t),c=o.redMul(s),f=a.redMul(u),l=o.redMul(u),h=s.redMul(a);return this.curve.point(c,f,h,l)},f.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),u=i.redSub(a),c=i.redAdd(a),f=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(s),l=n.redMul(u).redMul(f);return this.curve.twisted?(t=n.redMul(c).redMul(s.redSub(this.curve._mulA(o))),r=u.redMul(c)):(t=n.redMul(c).redMul(s.redSub(o)),r=this.curve._mulC(u).redMul(c)),this.curve.point(l,t,r)},f.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},f.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},f.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},f.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},f.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},f.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},f.prototype.getX=function(){return this.normalize(),this.x.fromRed()},f.prototype.getY=function(){return this.normalize(),this.y.fromRed()},f.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},f.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}return!1},f.prototype.toP=f.prototype.normalize,f.prototype.mixedAdd=f.prototype.add},function(e,t,r){"use strict";var n,i=t,o=r(247),s=r(56),a=s.utils.assert;function u(e){"short"===e.type?this.curve=new s.curve.short(e):"edwards"===e.type?this.curve=new s.curve.edwards(e):this.curve=new s.curve.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 c(e,t){Object.defineProperty(i,e,{configurable:!0,enumerable:!0,get:function(){var r=new u(t);return Object.defineProperty(i,e,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=u,c("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"]}),c("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"]}),c("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"]}),c("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"]}),c("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"]}),c("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"]}),c("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(836)}catch(e){n=void 0}c("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){"use strict";t.sha1=r(831),t.sha224=r(832),t.sha256=r(417),t.sha384=r(833),t.sha512=r(418)},function(e,t,r){"use strict";var n=r(71),i=r(125),o=r(416),s=n.rotl32,a=n.sum32,u=n.sum32_5,c=o.ft_1,f=i.BlockHash,l=[1518500249,1859775393,2400959708,3395469782];function h(){if(!(this instanceof h))return new h;f.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}n.inherits(h,f),e.exports=h,h.blockSize=512,h.outSize=160,h.hmacStrength=80,h.padLength=64,h.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 a.iaddn(1),this.keyFromPrivate(a)}},c.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},c.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),f=new i({hash:this.hash,entropy:a,nonce:c,pers:o.pers,persEnc:o.persEnc||"utf8"}),l=this.n.sub(new n(1)),h=0;;h++){var p=o.k?o.k(h):new n(f.generate(this.n.byteLength()));if(!((p=this._truncateToN(p,!0)).cmpn(1)<=0||p.cmp(l)>=0)){var d=this.g.mul(p);if(!d.isInfinity()){var y=d.getX(),g=y.umod(this.n);if(0!==g.cmpn(0)){var m=p.invm(this.n).mul(g.mul(t.getPrivate()).iadd(e));if(0!==(m=m.umod(this.n)).cmpn(0)){var b=(d.getY().isOdd()?1:0)|(0!==y.cmp(g)?2:0);return o.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),b^=1),new u({r:g,s:m,recoveryParam:b})}}}}}},c.prototype.verify=function(e,t,r,i){e=this._truncateToN(new n(e,16)),r=this.keyFromPublic(r,i);var o=(t=new u(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),f=c.mul(e).umod(this.n),l=c.mul(o).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(f,r.getPublic(),l)).isInfinity()&&a.eqXToP(o):!(a=this.g.mulAdd(f,r.getPublic(),l)).isInfinity()&&0===a.getX().umod(this.n).cmp(o)},c.prototype.recoverPubKey=function(e,t,r,i){s((3&r)===r,"The recovery param is more than two bits"),t=new u(t,i);var o=this.n,a=new n(e),c=t.r,f=t.s,l=1&r,h=r>>1;if(c.cmp(this.curve.p.umod(this.curve.n))>=0&&h)throw new Error("Unable to find sencond key candinate");c=h?this.curve.pointFromX(c.add(this.curve.n),l):this.curve.pointFromX(c,l);var p=t.r.invm(o),d=o.sub(a).mul(p).umod(o),y=f.mul(p).umod(o);return this.g.mulAdd(d,c,y)},c.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new u(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(247),i=r(415),o=r(81);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(55),i=r(56).utils,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(e,t){var r=e[t.place++];if(!(128&r))return r;for(var n=15&r,i=0,o=0,s=t.place;o>>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 function(){this.place=0};if(48!==e[r.place++])return!1;if(a(e,r)+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var o=a(e,r),s=e.slice(r.place,o+r.place);if(r.place+=o,2!==e[r.place++])return!1;var u=a(e,r);if(e.length!==u+r.place)return!1;var c=e.slice(r.place,u+r.place);return 0===s[0]&&128&s[1]&&(s=s.slice(1)),0===c[0]&&128&c[1]&&(c=c.slice(1)),this.r=new n(s),this.s=new n(c),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];c(n,t.length),(n=n.concat(t)).push(2),c(n,r.length);var o=n.concat(r),s=[48];return c(s,o.length),s=s.concat(o),i.encode(s,e)}},function(e,t,r){"use strict";var n=r(247),i=r(56),o=i.utils,s=o.assert,a=o.parseBytes,u=r(842),c=r(843);function f(e){if(s("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof f))return new f(e);e=i.curves[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()),u=n.add(s).umod(this.curve.n);return this.makeSignature({R:i,S:u,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;t=0})},intToBuffer:function(e){var r=s(e);return new t(o(r.slice(2)),"hex")},getBinarySize:function(e){if("string"!=typeof e)throw new Error("[ethjs-util] while getting binary size, method getBinarySize requires input 'str' to be type String, got '"+typeof e+"'.");return t.byteLength(e,"utf8")},isHexPrefixed:n,stripHexPrefix:i,padToEven:o,intToHex:s,fromAscii:function(e){for(var t="",r=0;r{const i=e.indexOf(t),o=i.toString();n.push({path:o,value:t}),f._mapFromEthObject(t,{},(e,t)=>{if(e)return r(e);t.forEach(e=>e.path=o+"/"+e.path),n=n.concat(t),r()})},e=>{if(e)return r(e);r(null,n)})}),h=l.util;h.serialize=o(e=>{const t=e.map(e=>e.raw);return s.encode(t)}),h.deserialize=o(e=>{return s.decode(e).map(e=>new a(e))}),h.cid=((e,t,r)=>{"function"==typeof t&&(r=t,t={});const i=(t=t||{}).hashAlg||"keccak-256";void 0===t.version||t.version;n([t=>h.serialize(e,t),(e,t)=>u.digest(e,i,t),o(e=>c("eth-block-list",e,t))],r)}),e.exports=l},function(e,t,r){"use strict";(function(t){const n=r(12),i=r(850);function o(e,t,r,i){if("function"==typeof r&&(i=r,r=void 0),!i)throw new Error("Missing callback");o.digest(e,t,r,(e,o)=>{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){"use strict";(function(t){const n=r(42),i=r(43),o=r(425),s=r(851),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,256)),shake256:a(u(n.shake_256,512)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(852),dblSha2256:(e,r)=>{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(44),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;function o(e){if(!i)throw new Error("Please use a browser with webcrypto support");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(45),i=r(425).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(413),i=r(248)("eth-state-trie",n);e.exports=i},function(e,t,r){(function(t){const n=r(126),i=r(173);function o(e,t,r){if(Array.isArray(e))this.parseNode(e);else if(this.type=e,"branch"===e){var n=t;this.raw=Array.apply(null,Array(17)),n&&n.forEach(function(e){this.set.apply(this,e)})}else this.raw=Array(2),this.setValue(r),this.setKey(t)}function s(e,t){return e.length%2?e.unshift(1):(e.unshift(0),e.unshift(0)),t&&(e[0]+=2),e}function a(e){return e[0]%2?e.slice(1):e.slice(2)}function u(e){return e[0]>1}function c(e){for(var r=new t(e),n=[],i=0;i>4,n[++o]=r[i]%16}return n}function f(e){for(var r=new t(e.length/2),n=0;n0){var r=this.raw.slice();this.v=this._chainId,this.r=0,this.s=0,t=this.raw,this.raw=r}else t=this.raw.slice(0,6);return n.rlphash(t)},e.prototype.getChainId=function(){return this._chainId},e.prototype.getSenderAddress=function(){if(this._from)return this._from;var e=this.getSenderPublicKey();return this._from=n.publicToAddress(e),this._from},e.prototype.getSenderPublicKey=function(){if(!(this._senderPubKey&&this._senderPubKey.length||this.verifySignature()))throw new Error("Invalid Signature");return this._senderPubKey},e.prototype.verifySignature=function(){var e=this.hash(!1);if(this._homestead&&1===new o(this.s).cmp(s))return!1;try{var t=n.bufferToInt(this.v);this._chainId>0&&(t-=2*this._chainId+8),this._senderPubKey=n.ecrecover(e,t,this.r,this.s)}catch(e){return!1}return!!this._senderPubKey},e.prototype.sign=function(e){var t=this.hash(!1),r=n.ecsign(t,e);this._chainId>0&&(r.v+=2*this._chainId+8),Object.assign(this,r)},e.prototype.getDataFee=function(){for(var e=this.raw[5],t=new o(0),r=0;r0&&t.push(["gas limit is too low. Need at least "+this.getBaseFee()]),void 0===e||!1===e?0===t.length:t.join(" ")},e}();e.exports=a}).call(this,r(0).Buffer)},function(e){e.exports={genesisGasLimit:{v:5e3,d:"Gas limit of the Genesis block."},genesisDifficulty:{v:17179869184,d:"Difficulty of the Genesis block."},genesisNonce:{v:"0x0000000000000042",d:"the geneis nonce"},genesisExtraData:{v:"0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",d:"extra data "},genesisHash:{v:"0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",d:"genesis hash"},genesisStateRoot:{v:"0xd7f8974fb5ac78d9ac099b9ad5018bedc2ce0a72dad1827a1709da30580f0544",d:"the genesis state root"},minGasLimit:{v:5e3,d:"Minimum the gas limit may ever be."},gasLimitBoundDivisor:{v:1024,d:"The bound divisor of the gas limit, used in update calculations."},minimumDifficulty:{v:131072,d:"The minimum that the difficulty may ever be."},difficultyBoundDivisor:{v:2048,d:"The bound divisor of the difficulty, used in the update calculations."},durationLimit:{v:13,d:"The decision boundary on the blocktime duration used to determine whether difficulty should go up or not."},maximumExtraDataSize:{v:32,d:"Maximum size extra data may be after Genesis."},epochDuration:{v:3e4,d:"Duration between proof-of-work epochs."},stackLimit:{v:1024,d:"Maximum size of VM stack allowed."},callCreateDepth:{v:1024,d:"Maximum depth of call/create stack."},tierStepGas:{v:[0,2,3,5,8,10,20],d:"Once per operation, for a selection of them."},expGas:{v:10,d:"Once per EXP instuction."},expByteGas:{v:10,d:"Times ceil(log256(exponent)) for the EXP instruction."},sha3Gas:{v:30,d:"Once per SHA3 operation."},sha3WordGas:{v:6,d:"Once per word of the SHA3 operation's data."},sloadGas:{v:50,d:"Once per SLOAD operation."},sstoreSetGas:{v:2e4,d:"Once per SSTORE operation if the zeroness changes from zero."},sstoreResetGas:{v:5e3,d:"Once per SSTORE operation if the zeroness does not change from zero."},sstoreRefundGas:{v:15e3,d:"Once per SSTORE operation if the zeroness changes to zero."},jumpdestGas:{v:1,d:"Refunded gas, once per SSTORE operation if the zeroness changes to zero."},logGas:{v:375,d:"Per LOG* operation."},logDataGas:{v:8,d:"Per byte in a LOG* operation's data."},logTopicGas:{v:375,d:"Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas."},createGas:{v:32e3,d:"Once per CREATE operation & contract-creation transaction."},callGas:{v:40,d:"Once per CALL operation & message call transaction."},callStipend:{v:2300,d:"Free gas given at beginning of call."},callValueTransferGas:{v:9e3,d:"Paid for CALL when the value transfor is non-zero."},callNewAccountGas:{v:25e3,d:"Paid for CALL when the destination address didn't exist prior."},suicideRefundGas:{v:24e3,d:"Refunded following a suicide operation."},memoryGas:{v:3,d:"Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL."},quadCoeffDiv:{v:512,d:"Divisor for the quadratic particle of the memory cost equation."},createDataGas:{v:200,d:""},txGas:{v:21e3,d:"Per transaction. NOTE: Not payable on data of calls between transactions."},txCreation:{v:32e3,d:"the cost of creating a contract via tx"},txDataZeroGas:{v:4,d:"Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions."},txDataNonZeroGas:{v:68,d:"Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions."},copyGas:{v:3,d:"Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added."},ecrecoverGas:{v:3e3,d:""},sha256Gas:{v:60,d:""},sha256WordGas:{v:12,d:""},ripemd160Gas:{v:600,d:""},ripemd160WordGas:{v:120,d:""},identityGas:{v:15,d:""},identityWordGas:{v:3,d:""},minerReward:{v:"5000000000000000000",d:"the amount a miner get rewarded for mining a block"},ommerReward:{v:"625000000000000000",d:"The amount of wei a miner of an uncle block gets for being inculded in the blockchain"},niblingReward:{v:"156250000000000000",d:"the amount a miner gets for inculding a uncle"},homeSteadForkNumber:{v:115e4,d:"the block that the Homestead fork started at"},homesteadRepriceForkNumber:{v:2463e3,d:"the block that the Homestead Reprice (EIP150) fork started at"},timebombPeriod:{v:1e5,d:"Exponential difficulty timebomb period"},freeBlockPeriod:{v:2}}},function(e,t,r){"use strict";const n=r(426),i=r(248)("eth-tx-trie",n);e.exports=i},function(e,t,r){"use strict";const n=r(9),i=r(61);e.exports={resolver:{multicodec:"raw",defaultHashAlg:"sha2-256",resolve:(e,t,r)=>{r(null,{value:e,remainderPath:""})},tree:(e,t,r)=>{"function"==typeof t&&(r=t),r(null,[])}},util:{deserialize:(e,t)=>{t(null,e)},serialize:(e,t)=>{t(null,e)},cid:(e,t,r)=>{"function"==typeof t&&(r=t,t={});const o=(t=t||{}).hashAlg||"sha2-256",s=void 0===t.version?1:t.version;i(e,o,(e,t)=>{if(e)return r(e);r(null,new n(s,"raw",t))})}}}},function(e,t,r){"use strict";t.resolver=r(249),t.util=r(427)},function(e,t,r){"use strict";(function(t,n){var i=e.exports;i.version="v"+r(863).version,i.versionGuard=function(e){if(void 0!==e);},i.versionGuard(t._bitcore),t._bitcore=i.version,i.crypto={},i.crypto.BN=r(32),i.crypto.ECDSA=r(428),i.crypto.Hash=r(38),i.crypto.Random=r(179),i.crypto.Point=r(109),i.crypto.Signature=r(63),i.encoding={},i.encoding.Base58=r(177),i.encoding.Base58Check=r(129),i.encoding.BufferReader=r(82),i.encoding.BufferWriter=r(57),i.encoding.Varint=r(891),i.util={},i.util.buffer=r(24),i.util.js=r(29),i.util.preconditions=r(21),i.errors=r(62),i.Address=r(97),i.Block=r(892),i.MerkleBlock=r(432),i.BlockHeader=r(180),i.HDPrivateKey=r(433),i.HDPublicKey=r(434),i.Networks=r(96),i.Opcode=r(250),i.PrivateKey=r(176),i.PublicKey=r(73),i.Script=r(64),i.Transaction=r(178),i.URI=r(894),i.Unit=r(253),i.deps={},i.deps.bnjs=r(74),i.deps.bs58=r(429),i.deps.Buffer=n,i.deps.elliptic=r(72),i.deps._=r(18),i._HDKeyCache=r(254),i.Transaction.sighash=r(83)}).call(this,r(7),r(0).Buffer)},function(e){e.exports={_from:"zcash-bitcore-lib@~0.13.20-rc3",_id:"zcash-bitcore-lib@0.13.20-rc3",_inBundle:!1,_integrity:"sha1-gToPVtz4t2vBQplRvqbRI2xQcAg=",_location:"/zcash-bitcore-lib",_phantomChildren:{},_requested:{type:"range",registry:!0,raw:"zcash-bitcore-lib@~0.13.20-rc3",name:"zcash-bitcore-lib",escapedName:"zcash-bitcore-lib",rawSpec:"~0.13.20-rc3",saveSpec:null,fetchSpec:"~0.13.20-rc3"},_requiredBy:["/ipld-zcash"],_resolved:"https://registry.npmjs.org/zcash-bitcore-lib/-/zcash-bitcore-lib-0.13.20-rc3.tgz",_shasum:"813a0f56dcf8b76bc1429951bea6d1236c507008",_shrinkwrap:{name:"bitcore",version:"0.13.19",dependencies:{"bn.js":{version:"2.0.4",from:"bn.js@=2.0.4",resolved:"https://registry.npmjs.org/bn.js/-/bn.js-2.0.4.tgz"},bs58:{version:"2.0.0",from:"bs58@=2.0.0",resolved:"https://registry.npmjs.org/bs58/-/bs58-2.0.0.tgz"},"buffer-compare":{version:"1.0.0",from:"buffer-compare@=1.0.0",resolved:"https://registry.npmjs.org/buffer-compare/-/buffer-compare-1.0.0.tgz"},elliptic:{version:"3.0.3",from:"elliptic@=3.0.3",resolved:"https://registry.npmjs.org/elliptic/-/elliptic-3.0.3.tgz",dependencies:{brorand:{version:"1.0.5",from:"brorand@^1.0.1",resolved:"https://registry.npmjs.org/brorand/-/brorand-1.0.5.tgz"},"hash.js":{version:"1.0.3",from:"hash.js@=1.0.3",resolved:"https://registry.npmjs.org/hash.js/-/hash.js-1.0.3.tgz"}}},inherits:{version:"2.0.1",from:"inherits@=2.0.1",resolved:"https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz"},lodash:{version:"3.10.1",from:"lodash@=3.10.1",resolved:"https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz"}}},_spec:"zcash-bitcore-lib@~0.13.20-rc3",_where:"/Users/mitra/git/dweb-transports/node_modules/ipld-zcash",author:{name:"BitPay",email:"dev@bitpay.com"},browser:{request:"browser-request"},bugs:{url:"https://github.com/bitmex/zcash-bitcore-lib/issues"},bundleDependencies:!1,contributors:[{name:"Daniel Cousens",email:"bitcoin@dcousens.com"},{name:"Esteban Ordano",email:"eordano@gmail.com"},{name:"Gordon Hall",email:"gordon@bitpay.com"},{name:"Jeff Garzik",email:"jgarzik@bitpay.com"},{name:"Kyle Drake",email:"kyle@kyledrake.net"},{name:"Manuel Araoz",email:"manuelaraoz@gmail.com"},{name:"Matias Alejo Garcia",email:"ematiu@gmail.com"},{name:"Ryan X. Charles",email:"ryanxcharles@gmail.com"},{name:"Stefan Thomas",email:"moon@justmoon.net"},{name:"Stephen Pair",email:"stephen@bitpay.com"},{name:"Wei Lu",email:"luwei.here@gmail.com"},{name:"Jack Grigg",email:"jack@z.cash"}],dependencies:{"bn.js":"=2.0.4",bs58:"=2.0.0","buffer-compare":"=1.0.0",elliptic:"=3.0.3",inherits:"=2.0.1",lodash:"=3.10.1"},deprecated:!1,description:"A pure and powerful JavaScript Zcash library.",devDependencies:{brfs:"^1.2.0",chai:"^1.10.0",gulp:"^3.8.10",sinon:"^1.13.0","zcash-bitcore-build":"^0.5.4"},homepage:"https://github.com/bitmex/zcash-bitcore-lib#readme",keywords:["zcash","transaction","address","p2p","ecies","cryptocurrency","blockchain","payment","bip21","bip32","bip37","bip69","bip70","multisig"],license:"MIT",main:"index.js",name:"zcash-bitcore-lib",repository:{type:"git",url:"git+https://github.com/bitmex/zcash-bitcore-lib.git"},scripts:{build:"gulp",coverage:"gulp coverage",lint:"gulp lint",test:"gulp test"},version:"0.13.20-rc3"}},function(e,t,r){"use strict";e.exports=[{name:"InvalidB58Char",message:"Invalid Base58 character: {0} in {1}"},{name:"InvalidB58Checksum",message:"Invalid Base58 checksum for {0}"},{name:"InvalidNetwork",message:"Invalid version for network: got {0}"},{name:"InvalidState",message:"Invalid state: {0}"},{name:"NotImplemented",message:"Function {0} was not implemented yet"},{name:"InvalidNetworkArgument",message:'Invalid network: must be "livenet" or "testnet", got {0}'},{name:"InvalidArgument",message:function(){return"Invalid Argument"+(arguments[0]?": "+arguments[0]:"")+(arguments[1]?" Documentation: http://bitcore.io/"+arguments[1]:"")}},{name:"AbstractMethodInvoked",message:"Abstract Method Invocation: {0}"},{name:"InvalidArgumentType",message:function(){return"Invalid Argument for "+arguments[2]+", expected "+arguments[1]+" but got "+typeof arguments[0]}},{name:"Unit",message:"Internal Error on Unit {0}",errors:[{name:"UnknownCode",message:"Unrecognized unit code: {0}"},{name:"InvalidRate",message:"Invalid exchange rate: {0}"}]},{name:"Transaction",message:"Internal Error on Transaction {0}",errors:[{name:"Input",message:"Internal Error on Input {0}",errors:[{name:"MissingScript",message:"Need a script to create an input"},{name:"UnsupportedScript",message:"Unsupported input script type: {0}"},{name:"MissingPreviousOutput",message:"No previous output information."}]},{name:"NeedMoreInfo",message:"{0}"},{name:"InvalidSorting",message:"The sorting function provided did not return the change output as one of the array elements"},{name:"InvalidOutputAmountSum",message:"{0}"},{name:"MissingSignatures",message:"Some inputs have not been fully signed"},{name:"InvalidIndex",message:"Invalid index: {0} is not between 0, {1}"},{name:"UnableToVerifySignature",message:"Unable to verify signature: {0}"},{name:"DustOutputs",message:"Dust amount detected in one output"},{name:"InvalidSatoshis",message:"Output satoshis are invalid"},{name:"FeeError",message:"Internal Error on Fee {0}",errors:[{name:"TooSmall",message:"Fee is too small: {0}"},{name:"TooLarge",message:"Fee is too large: {0}"},{name:"Different",message:"Unspent value is different from specified fee: {0}"}]},{name:"ChangeAddressMissing",message:"Change address is missing"},{name:"BlockHeightTooHigh",message:"Block Height can be at most 2^32 -1"},{name:"NLockTimeOutOfRange",message:"Block Height can only be between 0 and 499 999 999"},{name:"LockTimeTooEarly",message:"Lock Time can't be earlier than UNIX date 500 000 000"}]},{name:"Script",message:"Internal Error on Script {0}",errors:[{name:"UnrecognizedAddress",message:"Expected argument {0} to be an address"},{name:"CantDeriveAddress",message:"Can't derive address associated with script {0}, needs to be p2pkh in, p2pkh out, p2sh in, or p2sh out."},{name:"InvalidBuffer",message:"Invalid script buffer: can't parse valid script from given buffer {0}"}]},{name:"HDPrivateKey",message:"Internal Error on HDPrivateKey {0}",errors:[{name:"InvalidDerivationArgument",message:"Invalid derivation argument {0}, expected string, or number and boolean"},{name:"InvalidEntropyArgument",message:"Invalid entropy: must be an hexa string or binary buffer, got {0}",errors:[{name:"TooMuchEntropy",message:'Invalid entropy: more than 512 bits is non standard, got "{0}"'},{name:"NotEnoughEntropy",message:'Invalid entropy: at least 128 bits needed, got "{0}"'}]},{name:"InvalidLength",message:"Invalid length for xprivkey string in {0}"},{name:"InvalidPath",message:"Invalid derivation path: {0}"},{name:"UnrecognizedArgument",message:'Invalid argument: creating a HDPrivateKey requires a string, buffer, json or object, got "{0}"'}]},{name:"HDPublicKey",message:"Internal Error on HDPublicKey {0}",errors:[{name:"ArgumentIsPrivateExtended",message:"Argument is an extended private key: {0}"},{name:"InvalidDerivationArgument",message:"Invalid derivation argument: got {0}"},{name:"InvalidLength",message:'Invalid length for xpubkey: got "{0}"'},{name:"InvalidPath",message:'Invalid derivation path, it should look like: "m/1/100", got "{0}"'},{name:"InvalidIndexCantDeriveHardened",message:"Invalid argument: creating a hardened path requires an HDPrivateKey"},{name:"MustSupplyArgument",message:"Must supply an argument to create a HDPublicKey"},{name:"UnrecognizedArgument",message:"Invalid argument for creation, must be string, json, buffer, or object"}]}]},function(e){e.exports={_from:"elliptic@=3.0.3",_id:"elliptic@3.0.3",_inBundle:!1,_integrity:"sha1-hlybQgv75VAGuflp+XoNLESWZZU=",_location:"/zcash-bitcore-lib/elliptic",_phantomChildren:{inherits:"2.0.1"},_requested:{type:"version",registry:!0,raw:"elliptic@3.0.3",name:"elliptic",escapedName:"elliptic",rawSpec:"3.0.3",saveSpec:null,fetchSpec:"3.0.3"},_requiredBy:["/zcash-bitcore-lib"],_resolved:"http://registry.npmjs.org/elliptic/-/elliptic-3.0.3.tgz",_shasum:"865c9b420bfbe55006b9f969f97a0d2c44966595",_spec:"elliptic@3.0.3",_where:"/Users/mitra/git/dweb-transports/node_modules/zcash-bitcore-lib",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},bundleDependencies:!1,dependencies:{"bn.js":"^2.0.0",brorand:"^1.0.1","hash.js":"^1.0.0",inherits:"^2.0.1"},deprecated:!1,description:"EC cryptography",devDependencies:{browserify:"^3.44.2",jscs:"^1.11.3",jshint:"^2.6.0",mocha:"^2.1.0","uglify-js":"^2.4.13"},homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{test:"make lint && mocha --reporter=spec test/*-test.js"},version:"3.0.3"}},function(e,t,r){"use strict";var n=t;function i(e){return 1===e.length?"0"+e:e}function o(e){for(var t="",r=0;r>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},n.getNAF=function(e,t){for(var r=[],n=1<=0;){var o;if(i.isOdd()){var s=i.andln(n-1);o=s>(n>>1)-1?(n>>1)-s:s,i.isubn(o)}else o=0;r.push(o);for(var a=0!==i.cmpn(0)&&0===i.andln(n-1)?t+1:1,u=1;u0||t.cmpn(-i)>0;){var o,s,a,u=e.andln(3)+n&3,c=t.andln(3)+i&3;3===u&&(u=-1),3===c&&(c=-1),o=0==(1&u)?0:3!=(a=e.andln(7)+n&7)&&5!==a||2!==c?u:-u,r[0].push(o),s=0==(1&c)?0:3!=(a=t.andln(7)+i&7)&&5!==a||2!==u?c:-c,r[1].push(s),2*n===o+1&&(n=1-n),2*i===s+1&&(i=1-i),e.ishrn(1),t.ishrn(1)}return r}},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)},"object"==typeof window)window.crypto&&window.crypto.getRandomValues?i.prototype._rand=function(e){var t=new Uint8Array(e);return window.crypto.getRandomValues(t),t}:window.msCrypto&&window.msCrypto.getRandomValues?i.prototype._rand=function(e){var t=new Uint8Array(e);return window.msCrypto.getRandomValues(t),t}:i.prototype._rand=function(){throw new Error("Not implemented yet")};else try{var o=r(95);i.prototype._rand=function(e){return o.randomBytes(e)}}catch(e){i.prototype._rand=function(e){for(var t=new Uint8Array(e),r=0;r=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),this._update(r));for(var o=[];o.length>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function s(e){return 1===e.length?"0"+e:e}function a(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}function u(e,t){if(!e)throw new Error(t||"Assertion failed")}n.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){(e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e);for(var n=0;n>8,s=255&i;o?r.push(o,s):r.push(s)}else for(n=0;n>>0}return o},n.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},n.rotr32=function(e,t){return e>>>t|e<<32-t},n.rotl32=function(e,t){return e<>>32-t},n.sum32=function(e,t){return e+t>>>0},n.sum32_3=function(e,t,r){return e+t+r>>>0},n.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},n.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},n.assert=u,n.inherits=i,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 u=0,c=t;return u+=(c=c+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,u,c){var f=0,l=t;return f+=(l=l+n>>>0)>>0)>>0)>>0)>>0},t.sum64_5_lo=function(e,t,r,n,i,o,s,a,u,c){return t+n+o+a+c>>>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){var n=r(110).utils,i=n.assert;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{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;for(o=8;o>>3}function j(e){return s(e,17)^s(e,19)^e>>>10}function M(e,t,r,n){return 0===e?P(t,r,n):1===e||3===e?function(e,t,r){return e^t^r}(t,r,n):2===e?O(t,r,n):void 0}function K(e,t,r,n,i,o){var s=e&r^~e&i;return s<0&&(s+=4294967296),s}function D(e,t,r,n,i,o){var s=t&n^~t&o;return s<0&&(s+=4294967296),s}function U(e,t,r,n,i,o){var s=e&r^e&i^r&i;return s<0&&(s+=4294967296),s}function F(e,t,r,n,i,o){var s=t&n^t&o^n&o;return s<0&&(s+=4294967296),s}function q(e,t){var r=l(e,t,28)^l(t,e,2)^l(t,e,7);return r<0&&(r+=4294967296),r}function H(e,t){var r=h(e,t,28)^h(t,e,2)^h(t,e,7);return r<0&&(r+=4294967296),r}function z(e,t){var r=l(e,t,14)^l(e,t,18)^l(t,e,9);return r<0&&(r+=4294967296),r}function V(e,t){var r=h(e,t,14)^h(e,t,18)^h(t,e,9);return r<0&&(r+=4294967296),r}function G(e,t){var r=l(e,t,1)^l(e,t,8)^p(e,t,7);return r<0&&(r+=4294967296),r}function W(e,t){var r=h(e,t,1)^h(e,t,8)^d(e,t,7);return r<0&&(r+=4294967296),r}function $(e,t){var r=l(e,t,19)^l(t,e,29)^p(e,t,6);return r<0&&(r+=4294967296),r}function Y(e,t){var r=h(e,t,19)^h(t,e,29)^d(e,t,6);return r<0&&(r+=4294967296),r}i.inherits(x,S),t.sha256=x,x.blockSize=512,x.outSize=256,x.hmacStrength=192,x.padLength=64,x.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;t=a;t--)u=(u<<1)+n[t];s.push(u)}for(var c=this.jpoint(null,null,null),f=this.jpoint(null,null,null),l=i;l>0;l--){for(a=0;a=0;c--){for(t=0;c>=0&&0===s[c];c--)t++;if(c>=0&&t++,u=u.dblp(t),c<0)break;var f=s[c];a(0!==f),u="affine"===e.type?f>0?u.mixedAdd(i[f-1>>1]):u.mixedAdd(i[-f-1>>1].neg()):f>0?u.add(i[f-1>>1]):u.add(i[-f-1>>1].neg())}return"affine"===e.type?u.toP():u},u.prototype._wnafMulAdd=function(e,t,r,n){for(var i=this._wnafT1,a=this._wnafT2,u=this._wnafT3,c=0,f=0;f=1;f-=2){var h=f-1,p=f;if(1===i[h]&&1===i[p]){var d=[t[h],null,null,t[p]];0===t[h].y.cmp(t[p].y)?(d[1]=t[h].add(t[p]),d[2]=t[h].toJ().mixedAdd(t[p].neg())):0===t[h].y.cmp(t[p].y.redNeg())?(d[1]=t[h].toJ().mixedAdd(t[p]),d[2]=t[h].add(t[p].neg())):(d[1]=t[h].toJ().mixedAdd(t[p]),d[2]=t[h].toJ().mixedAdd(t[p].neg()));var y=[-3,-1,-5,-7,0,7,5,1,3],g=s(r[h],r[p]);c=Math.max(g[0].length,c),u[h]=new Array(c),u[p]=new Array(c);for(var m=0;m=0;f--){for(var S=0;f>=0;){var k=!0;for(m=0;m=0&&S++,_=_.dblp(S),f<0)break;for(m=0;m0?E=a[m][A-1>>1]:A<0&&(E=a[m][-A-1>>1].neg()),_="affine"===E.type?_.mixedAdd(E):_.add(E))}}for(f=0;f=0&&(s=t,a=r),n.sign&&(n=n.neg(),i=i.neg()),s.sign&&(s=s.neg(),a=a.neg()),[{a:n,b:i},{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),u=i.mul(r.b),c=o.mul(n.b);return{k1:e.sub(s).sub(a),k2:u.add(c).neg()}},c.prototype.pointFromX=function(e,t){(t=new o(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b).redSqrt(),n=r.fromRed().isOdd();return(e&&!n||!e&&n)&&(r=r.redNeg()),this.point(t,r)},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){for(var r=this._endoWnafT1,n=this._endoWnafT2,i=0;i":""},f.prototype.isInfinity=function(){return this.inf},f.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)},f.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)},f.prototype.getX=function(){return this.x.fromRed()},f.prototype.getY=function(){return this.y.fromRed()},f.prototype.mul=function(e){return e=new o(e,16),this.precomputed&&this.precomputed.doubles?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},f.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)},f.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))},f.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},f.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},s(l,a.BasePoint),c.prototype.jpoint=function(e,t,r){return new l(this,e,t,r)},l.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)},l.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},l.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),u=o.redSub(s);if(0===a.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=a.redSqr(),f=c.redMul(a),l=n.redMul(c),h=u.redSqr().redIAdd(f).redISub(l).redISub(l),p=u.redMul(l.redISub(h)).redISub(o.redMul(f)),d=this.z.redMul(e.z).redMul(a);return this.curve.jpoint(h,p,d)},l.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 u=s.redSqr(),c=u.redMul(s),f=r.redMul(u),l=a.redSqr().redIAdd(c).redISub(f).redISub(f),h=a.redMul(f.redISub(l)).redISub(i.redMul(c)),p=this.z.redMul(s);return this.curve.jpoint(l,h,p)},l.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r":""},l.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},function(e,t,r){"use strict";var n=r(175),i=r(74),o=r(75),s=n.base;function a(e){s.call(this,"mont",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function u(e,t,r){s.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(t,16),this.z=new i(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}o(a,s),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)},o(u,s.BasePoint),a.prototype.point=function(e,t){return new u(this,e,t)},a.prototype.pointFromJSON=function(e){return u.fromJSON(this,e)},u.prototype.precompute=function(){},u.fromJSON=function(e,t){return new u(e,t[0],t[1]||e.one)},u.prototype.inspect=function(){return this.isInfinity()?"":""},u.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},u.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)},u.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},u.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()),u=t.x.redMul(o.redISub(s).redSqr());return this.curve.point(a,u)},u.prototype.mul=function(e){for(var t=e.clone(),r=this,n=this.curve.point(null,null),i=[];0!==t.cmpn(0);t.ishrn(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},u.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},u.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},u.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},function(e,t,r){"use strict";var n=r(175),i=r(72),o=r(74),s=r(75),a=n.base,u=i.utils.assert;function c(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,a.call(this,"edwards",e),this.a=new o(e.a,16).mod(this.red.m).toRed(this.red),this.c=new o(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new o(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),u(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}function f(e,t,r,n,i){a.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 o(t,16),this.y=new o(r,16),this.z=n?new o(n,16):this.curve.one,this.t=i&&new o(i,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()))))}s(c,a),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){(t=new o(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr(),i=this.c2.redSub(this.a.redMul(r)),s=this.one.redSub(this.c2.redMul(this.d).redMul(r)),a=i.redMul(s.redInvm()).redSqrt(),u=a.fromRed().isOdd();return(e&&!u||!e&&u)&&(a=a.redNeg()),this.point(t,a,n.one)},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)},s(f,a.BasePoint),c.prototype.pointFromJSON=function(e){return f.fromJSON(this,e)},c.prototype.point=function(e,t,r,n){return new f(this,e,t,r,n)},f.fromJSON=function(e,t){return new f(e,t[0],t[1],t[2])},f.prototype.inspect=function(){return this.isInfinity()?"":""},f.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&0===this.y.cmp(this.z)},f.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),u=i.redMul(s),c=o.redMul(a),f=i.redMul(a),l=s.redMul(o);return this.curve.point(u,c,l,f)},f.prototype._projDbl=function(){var e,t,r,n=this.x.redAdd(this.y).redSqr(),i=this.x.redSqr(),o=this.y.redSqr();if(this.curve.twisted){var s=(c=this.curve._mulA(i)).redAdd(o);if(this.zOne)e=n.redSub(i).redSub(o).redMul(s.redSub(this.curve.two)),t=s.redMul(c.redSub(o)),r=s.redSqr().redSub(s).redSub(s);else{var a=this.z.redSqr(),u=s.redSub(a).redISub(a);e=n.redSub(i).redISub(o).redMul(u),t=s.redMul(c.redSub(o)),r=s.redMul(u)}}else{var c=i.redAdd(o);a=this.curve._mulC(this.c.redMul(this.z)).redSqr(),u=c.redSub(a).redSub(a);e=this.curve._mulC(n.redISub(c)).redMul(u),t=this.curve._mulC(c).redMul(i.redISub(o)),r=c.redMul(u)}return this.curve.point(e,t,r)},f.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},f.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),u=r.redAdd(t),c=o.redMul(s),f=a.redMul(u),l=o.redMul(u),h=s.redMul(a);return this.curve.point(c,f,h,l)},f.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),u=i.redSub(a),c=i.redAdd(a),f=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(s),l=n.redMul(u).redMul(f);return this.curve.twisted?(t=n.redMul(c).redMul(s.redSub(this.curve._mulA(o))),r=u.redMul(c)):(t=n.redMul(c).redMul(s.redSub(o)),r=this.curve._mulC(u).redMul(c)),this.curve.point(l,t,r)},f.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},f.prototype.mul=function(e){return this.precomputed&&this.precomputed.doubles?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},f.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2)},f.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},f.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},f.prototype.getX=function(){return this.normalize(),this.x.fromRed()},f.prototype.getY=function(){return this.normalize(),this.y.fromRed()},f.prototype.toP=f.prototype.normalize,f.prototype.mixedAdd=f.prototype.add},function(e,t,r){"use strict";var n,i=t,o=r(110),s=r(72),a=s.utils.assert;function u(e){"short"===e.type?this.curve=new s.curve.short(e):"edwards"===e.type?this.curve=new s.curve.edwards(e):this.curve=new s.curve.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 c(e,t){Object.defineProperty(i,e,{configurable:!0,enumerable:!0,get:function(){var r=new u(t);return Object.defineProperty(i,e,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=u,c("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"]}),c("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"]}),c("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"]}),c("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"0",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),c("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(879)}catch(e){n=void 0}c("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){e.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}},function(e,t,r){"use strict";var n=r(74),i=r(72),o=i.utils.assert,s=r(881),a=r(882);function u(e){if(!(this instanceof u))return new u(e);"string"==typeof e&&(o(i.curves.hasOwnProperty(e),"Unknown curve "+e),e=i.curves[e]),e instanceof i.curves.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.shrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}e.exports=u,u.prototype.keyPair=function(e){return new s(this,e)},u.prototype.keyFromPrivate=function(e,t){return s.fromPrivate(this,e,t)},u.prototype.keyFromPublic=function(e,t){return s.fromPublic(this,e,t)},u.prototype.genKeyPair=function(e){e||(e={});for(var t=new i.hmacDRBG({hash:this.hash,pers:e.pers,entropy:e.entropy||i.rand(this.hash.hmacStrength),nonce:this.n.toArray()}),r=this.n.byteLength(),o=this.n.sub(new n(2));;){var s=new n(t.generate(r));if(!(s.cmp(o)>0))return s.iaddn(1),this.keyFromPrivate(s)}},u.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.shrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},u.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(),u=t.getPrivate().toArray(),c=u.length;c<21;c++)u.unshift(0);var f=e.toArray();for(c=f.length;c=0)){var d=this.g.mul(p);if(!d.isInfinity()){var y=d.getX().mod(this.n);if(0!==y.cmpn(0)){var g=p.invm(this.n).mul(y.mul(t.getPrivate()).iadd(e)).mod(this.n);if(0!==g.cmpn(0))return o.canonical&&g.cmp(this.nh)>0&&(g=this.n.sub(g)),new a({r:y,s:g})}}}}},u.prototype.verify=function(e,t,r,i){e=this._truncateToN(new n(e,16)),r=this.keyFromPublic(r,i);var o=(t=new a(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 u=s.invm(this.n),c=u.mul(e).mod(this.n),f=u.mul(o).mod(this.n),l=this.g.mulAdd(c,r.getPublic(),f);return!l.isInfinity()&&0===l.getX().mod(this.n).cmp(o)}},function(e,t,r){"use strict";var n=r(74),i=r(72).utils;function o(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}e.exports=o,o.fromPublic=function(e,t,r){return t instanceof o?t:new o(e,{pub:t,pubEnc:r})},o.fromPrivate=function(e,t,r){return t instanceof o?t:new o(e,{priv:t,privEnc:r})},o.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(e,t){if(this.pub||(this.pub=this.ec.g.mul(this.priv)),"string"==typeof e&&(t=e,e=null),!t)return this.pub;for(var r=this.ec.curve.p.byteLength(),n=this.pub.getX().toArray(),o=n.length;o"}},function(e,t,r){"use strict";var n=r(74),i=r(72).utils,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))}e.exports=s,s.prototype._importDER=function(e,t){if((e=i.toArray(e,t)).length<6||48!==e[0]||2!==e[2])return!1;if(1+e[1]>e.length)return!1;var r=e[3];if(r>=128)return!1;if(4+r+2>=e.length)return!1;if(2!==e[4+r])return!1;var o=e[5+r];return!(o>=128||4+r+2+o>e.length||(this.r=new n(e.slice(4,4+r)),this.s=new n(e.slice(4+r+2,4+r+2+o)),0))},s.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r));var n=[48,t.length+r.length+4,2,t.length];return n=n.concat(t,[2,r.length],r),i.encode(n,e)}},function(e,t,r){"use strict";(function(t){var n=r(18),i=r(430),o=r(250),s=r(32),a=r(38),u=r(63),c=r(73),f=function e(t){if(!(this instanceof e))return new e(t);t?(this.initialize(),this.set(t)):this.initialize()};f.prototype.verify=function(e,t,o,s,a){var u,c=r(178);if(n.isUndefined(o)&&(o=new c),n.isUndefined(s)&&(s=0),n.isUndefined(a)&&(a=0),this.set({script:e,tx:o,nin:s,flags:a}),0!=(a&f.SCRIPT_VERIFY_SIGPUSHONLY)&&!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(!this.evaluate())return!1;a&f.SCRIPT_VERIFY_P2SH&&(u=this.stack.slice());var l=this.stack;if(this.initialize(),this.set({script:t,stack:l,tx:o,nin:s,flags:a}),!this.evaluate())return!1;if(0===this.stack.length)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_RESULT",!1;var h=this.stack[this.stack.length-1];if(!f.castToBool(h))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_STACK",!1;if(a&f.SCRIPT_VERIFY_P2SH&&t.isScriptHashOut()){if(!e.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(0===u.length)throw new Error("internal error - stack copy empty");var p=u[u.length-1],d=i.fromBuffer(p);return u.pop(),this.initialize(),this.set({script:d,stack:u,tx:o,nin:s,flags:a}),!(!this.evaluate()||(0===u.length?(this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_P2SH_STACK",1):!f.castToBool(u[u.length-1])&&(this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_P2SH_STACK",1)))}return!0},e.exports=f,f.prototype.initialize=function(e){this.stack=[],this.altstack=[],this.pc=0,this.pbegincodehash=0,this.nOpCount=0,this.vfExec=[],this.errstr="",this.flags=0},f.prototype.set=function(e){this.script=e.script||this.script,this.tx=e.tx||this.tx,this.nin=void 0!==e.nin?e.nin:this.nin,this.stack=e.stack||this.stack,this.altstack=e.altack||this.altstack,this.pc=void 0!==e.pc?e.pc:this.pc,this.pbegincodehash=void 0!==e.pbegincodehash?e.pbegincodehash:this.pbegincodehash,this.nOpCount=void 0!==e.nOpCount?e.nOpCount:this.nOpCount,this.vfExec=e.vfExec||this.vfExec,this.errstr=e.errstr||this.errstr,this.flags=void 0!==e.flags?e.flags:this.flags},f.true=new t([1]),f.false=new t([]),f.MAX_SCRIPT_ELEMENT_SIZE=520,f.LOCKTIME_THRESHOLD_BN=new s(f.LOCKTIME_THRESHOLD=5e8),f.SCRIPT_VERIFY_NONE=0,f.SCRIPT_VERIFY_P2SH=1,f.SCRIPT_VERIFY_STRICTENC=2,f.SCRIPT_VERIFY_DERSIG=4,f.SCRIPT_VERIFY_LOW_S=8,f.SCRIPT_VERIFY_NULLDUMMY=16,f.SCRIPT_VERIFY_SIGPUSHONLY=32,f.SCRIPT_VERIFY_MINIMALDATA=64,f.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS=128,f.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY=512,f.castToBool=function(e){for(var t=0;t1e4)return this.errstr="SCRIPT_ERR_SCRIPT_SIZE",!1;try{for(;this.pc1e3)return this.errstr="SCRIPT_ERR_STACK_SIZE",!1}catch(e){return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR: "+e,!1}return!(this.vfExec.length>0&&(this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",1))},f.prototype.checkLockTime=function(e){return!!(this.tx.nLockTime=f.LOCKTIME_THRESHOLD&&e.gte(f.LOCKTIME_THRESHOLD_BN))&&!e.gt(new s(this.tx.nLockTime))&&!!this.tx.inputs[this.nin].isFinal()},f.prototype.step=function(){var e,t,r,l,h,p,d,y,g,m,b,v,_,w,S,k,E,A=0!=(this.flags&f.SCRIPT_VERIFY_MINIMALDATA),x=-1===this.vfExec.indexOf(!1),I=this.script.chunks[this.pc];this.pc++;var T=I.opcodenum;if(n.isUndefined(T))return this.errstr="SCRIPT_ERR_UNDEFINED_OPCODE",!1;if(I.buf&&I.buf.length>f.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;if(T>o.OP_16&&++this.nOpCount>201)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;if(T===o.OP_CAT||T===o.OP_SUBSTR||T===o.OP_LEFT||T===o.OP_RIGHT||T===o.OP_INVERT||T===o.OP_AND||T===o.OP_OR||T===o.OP_XOR||T===o.OP_2MUL||T===o.OP_2DIV||T===o.OP_MUL||T===o.OP_DIV||T===o.OP_MOD||T===o.OP_LSHIFT||T===o.OP_RSHIFT)return this.errstr="SCRIPT_ERR_DISABLED_OPCODE",!1;if(x&&0<=T&&T<=o.OP_PUSHDATA4){if(A&&!this.script.checkMinimalPush(this.pc-1))return this.errstr="SCRIPT_ERR_MINIMALDATA",!1;if(I.buf){if(I.len!==I.buf.length)throw new Error("Length of push value not equal to length of data");this.stack.push(I.buf)}else this.stack.push(f.false)}else if(x||o.OP_IF<=T&&T<=o.OP_ENDIF)switch(T){case o.OP_1NEGATE:case o.OP_1:case o.OP_2:case o.OP_3:case o.OP_4:case o.OP_5:case o.OP_6:case o.OP_7:case o.OP_8:case o.OP_9:case o.OP_10:case o.OP_11:case o.OP_12:case o.OP_13:case o.OP_14:case o.OP_15:case o.OP_16:h=T-(o.OP_1-1),e=new s(h).toScriptNumBuffer(),this.stack.push(e);break;case o.OP_NOP:break;case o.OP_NOP2:case o.OP_CHECKLOCKTIMEVERIFY:if(!(this.flags&f.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)){if(this.flags&f.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var B=s.fromScriptNumBuffer(this.stack[this.stack.length-1],A,5);if(B.lt(new s(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(!this.checkLockTime(B))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case o.OP_NOP1:case o.OP_NOP3:case o.OP_NOP4:case o.OP_NOP5:case o.OP_NOP6:case o.OP_NOP7:case o.OP_NOP8:case o.OP_NOP9:case o.OP_NOP10:if(this.flags&f.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break;case o.OP_IF:case o.OP_NOTIF:if(k=!1,x){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;e=this.stack.pop(),k=f.castToBool(e),T===o.OP_NOTIF&&(k=!k)}this.vfExec.push(k);break;case o.OP_ELSE:if(0===this.vfExec.length)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec[this.vfExec.length-1]=!this.vfExec[this.vfExec.length-1];break;case o.OP_ENDIF:if(0===this.vfExec.length)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec.pop();break;case o.OP_VERIFY:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(e=this.stack[this.stack.length-1],!(k=f.castToBool(e)))return this.errstr="SCRIPT_ERR_VERIFY",!1;this.stack.pop();break;case o.OP_RETURN:return this.errstr="SCRIPT_ERR_OP_RETURN",!1;case o.OP_TOALTSTACK:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.altstack.push(this.stack.pop());break;case o.OP_FROMALTSTACK:if(this.altstack.length<1)return this.errstr="SCRIPT_ERR_INVALID_ALTSTACK_OPERATION",!1;this.stack.push(this.altstack.pop());break;case o.OP_2DROP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop(),this.stack.pop();break;case o.OP_2DUP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;t=this.stack[this.stack.length-2],r=this.stack[this.stack.length-1],this.stack.push(t),this.stack.push(r);break;case o.OP_3DUP:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;t=this.stack[this.stack.length-3],r=this.stack[this.stack.length-2];var C=this.stack[this.stack.length-1];this.stack.push(t),this.stack.push(r),this.stack.push(C);break;case o.OP_2OVER:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;t=this.stack[this.stack.length-4],r=this.stack[this.stack.length-3],this.stack.push(t),this.stack.push(r);break;case o.OP_2ROT:if(this.stack.length<6)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=this.stack.splice(this.stack.length-6,2),this.stack.push(l[0]),this.stack.push(l[1]);break;case o.OP_2SWAP:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=this.stack.splice(this.stack.length-4,2),this.stack.push(l[0]),this.stack.push(l[1]);break;case o.OP_IFDUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;e=this.stack[this.stack.length-1],(k=f.castToBool(e))&&this.stack.push(e);break;case o.OP_DEPTH:e=new s(this.stack.length).toScriptNumBuffer(),this.stack.push(e);break;case o.OP_DROP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop();break;case o.OP_DUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(this.stack[this.stack.length-1]);break;case o.OP_NIP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,1);break;case o.OP_OVER:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(this.stack[this.stack.length-2]);break;case o.OP_PICK:case o.OP_ROLL:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(e=this.stack[this.stack.length-1],h=(y=s.fromScriptNumBuffer(e,A)).toNumber(),this.stack.pop(),h<0||h>=this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;e=this.stack[this.stack.length-h-1],T===o.OP_ROLL&&this.stack.splice(this.stack.length-h-1,1),this.stack.push(e);break;case o.OP_ROT:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;p=this.stack[this.stack.length-3],d=this.stack[this.stack.length-2];var P=this.stack[this.stack.length-1];this.stack[this.stack.length-3]=d,this.stack[this.stack.length-2]=P,this.stack[this.stack.length-1]=p;break;case o.OP_SWAP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;p=this.stack[this.stack.length-2],d=this.stack[this.stack.length-1],this.stack[this.stack.length-2]=d,this.stack[this.stack.length-1]=p;break;case o.OP_TUCK:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,0,this.stack[this.stack.length-1]);break;case o.OP_SIZE:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;y=new s(this.stack[this.stack.length-1].length),this.stack.push(y.toScriptNumBuffer());break;case o.OP_EQUAL:case o.OP_EQUALVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;t=this.stack[this.stack.length-2],r=this.stack[this.stack.length-1];var O=t.toString("hex")===r.toString("hex");if(this.stack.pop(),this.stack.pop(),this.stack.push(O?f.true:f.false),T===o.OP_EQUALVERIFY){if(!O)return this.errstr="SCRIPT_ERR_EQUALVERIFY",!1;this.stack.pop()}break;case o.OP_1ADD:case o.OP_1SUB:case o.OP_NEGATE:case o.OP_ABS:case o.OP_NOT:case o.OP_0NOTEQUAL:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(e=this.stack[this.stack.length-1],y=s.fromScriptNumBuffer(e,A),T){case o.OP_1ADD:y=y.add(s.One);break;case o.OP_1SUB:y=y.sub(s.One);break;case o.OP_NEGATE:y=y.neg();break;case o.OP_ABS:y.cmp(s.Zero)<0&&(y=y.neg());break;case o.OP_NOT:y=new s((0===y.cmp(s.Zero))+0);break;case o.OP_0NOTEQUAL:y=new s((0!==y.cmp(s.Zero))+0)}this.stack.pop(),this.stack.push(y.toScriptNumBuffer());break;case o.OP_ADD:case o.OP_SUB:case o.OP_BOOLAND:case o.OP_BOOLOR:case o.OP_NUMEQUAL:case o.OP_NUMEQUALVERIFY:case o.OP_NUMNOTEQUAL:case o.OP_LESSTHAN:case o.OP_GREATERTHAN:case o.OP_LESSTHANOREQUAL:case o.OP_GREATERTHANOREQUAL:case o.OP_MIN:case o.OP_MAX:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(g=s.fromScriptNumBuffer(this.stack[this.stack.length-2],A),m=s.fromScriptNumBuffer(this.stack[this.stack.length-1],A),y=new s(0),T){case o.OP_ADD:y=g.add(m);break;case o.OP_SUB:y=g.sub(m);break;case o.OP_BOOLAND:y=new s((0!==g.cmp(s.Zero)&&0!==m.cmp(s.Zero))+0);break;case o.OP_BOOLOR:y=new s((0!==g.cmp(s.Zero)||0!==m.cmp(s.Zero))+0);break;case o.OP_NUMEQUAL:case o.OP_NUMEQUALVERIFY:y=new s((0===g.cmp(m))+0);break;case o.OP_NUMNOTEQUAL:y=new s((0!==g.cmp(m))+0);break;case o.OP_LESSTHAN:y=new s((g.cmp(m)<0)+0);break;case o.OP_GREATERTHAN:y=new s((g.cmp(m)>0)+0);break;case o.OP_LESSTHANOREQUAL:y=new s((g.cmp(m)<=0)+0);break;case o.OP_GREATERTHANOREQUAL:y=new s((g.cmp(m)>=0)+0);break;case o.OP_MIN:y=g.cmp(m)<0?g:m;break;case o.OP_MAX:y=g.cmp(m)>0?g:m}if(this.stack.pop(),this.stack.pop(),this.stack.push(y.toScriptNumBuffer()),T===o.OP_NUMEQUALVERIFY){if(!f.castToBool(this.stack[this.stack.length-1]))return this.errstr="SCRIPT_ERR_NUMEQUALVERIFY",!1;this.stack.pop()}break;case o.OP_WITHIN:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;g=s.fromScriptNumBuffer(this.stack[this.stack.length-3],A),m=s.fromScriptNumBuffer(this.stack[this.stack.length-2],A);var R=s.fromScriptNumBuffer(this.stack[this.stack.length-1],A);k=m.cmp(g)<=0&&g.cmp(R)<0,this.stack.pop(),this.stack.pop(),this.stack.pop(),this.stack.push(k?f.true:f.false);break;case o.OP_RIPEMD160:case o.OP_SHA1:case o.OP_SHA256:case o.OP_HASH160:case o.OP_HASH256:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var N;e=this.stack[this.stack.length-1],T===o.OP_RIPEMD160?N=a.ripemd160(e):T===o.OP_SHA1?N=a.sha1(e):T===o.OP_SHA256?N=a.sha256(e):T===o.OP_HASH160?N=a.sha256ripemd160(e):T===o.OP_HASH256&&(N=a.sha256sha256(e)),this.stack.pop(),this.stack.push(N);break;case o.OP_CODESEPARATOR:this.pbegincodehash=this.pc;break;case o.OP_CHECKSIG:case o.OP_CHECKSIGVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;b=this.stack[this.stack.length-2],v=this.stack[this.stack.length-1],_=(new i).set({chunks:this.script.chunks.slice(this.pbegincodehash)});var L=(new i).add(b);if(_.findAndDelete(L),!this.checkSignatureEncoding(b)||!this.checkPubkeyEncoding(v))return!1;try{w=u.fromTxFormat(b),S=c.fromBuffer(v,!1),E=this.tx.verifySignature(w,S,this.nin,_)}catch(A){E=!1}if(this.stack.pop(),this.stack.pop(),this.stack.push(E?f.true:f.false),T===o.OP_CHECKSIGVERIFY){if(!E)return this.errstr="SCRIPT_ERR_CHECKSIGVERIFY",!1;this.stack.pop()}break;case o.OP_CHECKMULTISIG:case o.OP_CHECKMULTISIGVERIFY:var j=1;if(this.stack.length20)return this.errstr="SCRIPT_ERR_PUBKEY_COUNT",!1;if(this.nOpCount+=M,this.nOpCount>201)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;var K=++j;if(j+=M,this.stack.lengthM)return this.errstr="SCRIPT_ERR_SIG_COUNT",!1;var U=++j;if(j+=D,this.stack.length0;){if(b=this.stack[this.stack.length-U],v=this.stack[this.stack.length-K],!this.checkSignatureEncoding(b)||!this.checkPubkeyEncoding(v))return!1;var q;try{w=u.fromTxFormat(b),S=c.fromBuffer(v,!1),q=this.tx.verifySignature(w,S,this.nin,_)}catch(A){q=!1}q&&(U++,D--),K++,D>--M&&(E=!1)}for(;j-- >1;)this.stack.pop();if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(this.flags&f.SCRIPT_VERIFY_NULLDUMMY&&this.stack[this.stack.length-1].length)return this.errstr="SCRIPT_ERR_SIG_NULLDUMMY",!1;if(this.stack.pop(),this.stack.push(E?f.true:f.false),T===o.OP_CHECKMULTISIGVERIFY){if(!E)return this.errstr="SCRIPT_ERR_CHECKMULTISIGVERIFY",!1;this.stack.pop()}break;default:return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}return!0}}).call(this,r(0).Buffer)},function(e,t){e.exports=function(e,t){for(var r=0,n=0;nt[n]?1:0);++n);return 0==r&&(t.length>e.length?r=-1:e.length>t.length&&(r=1)),r}},function(e,t,r){"use strict";var n=r(75),i=r(21),o=(r(24),r(130)),s=r(84),a=r(83),u=r(64),c=r(63),f=r(131);function l(){o.apply(this,arguments)}n(l,o),l.prototype.getSignatures=function(e,t,r,n){i.checkState(this.output instanceof s),n=n||c.SIGHASH_ALL;var o=t.toPublicKey();return o.toString()===this.output.script.getPublicKey().toString("hex")?[new f({publicKey:o,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:a.sign(e,t,n,r,this.output.script),sigtype:n})]:[]},l.prototype.addSignature=function(e,t){return i.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(u.buildPublicKeyIn(t.signature.toDER(),t.sigtype)),this},l.prototype.clearSignatures=function(){return this.setScript(u.empty()),this},l.prototype.isFullySigned=function(){return this.script.isPublicKeyIn()},l.SCRIPT_MAX_SIZE=73,l.prototype._estimateSize=function(){return l.SCRIPT_MAX_SIZE},e.exports=l},function(e,t,r){"use strict";var n=r(75),i=r(21),o=r(24),s=r(38),a=r(130),u=r(84),c=r(83),f=r(64),l=r(63),h=r(131);function p(){a.apply(this,arguments)}n(p,a),p.prototype.getSignatures=function(e,t,r,n,a){return i.checkState(this.output instanceof u),a=a||s.sha256ripemd160(t.publicKey.toBuffer()),n=n||l.SIGHASH_ALL,o.equals(a,this.output.script.getPublicKeyHash())?[new h({publicKey:t.publicKey,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:c.sign(e,t,n,r,this.output.script),sigtype:n})]:[]},p.prototype.addSignature=function(e,t){return i.checkState(this.isValidSignature(e,t),"Signature is invalid"),this.setScript(f.buildPublicKeyHashIn(t.publicKey,t.signature.toDER(),t.sigtype)),this},p.prototype.clearSignatures=function(){return this.setScript(f.empty()),this},p.prototype.isFullySigned=function(){return this.script.isPublicKeyHashIn()},p.SCRIPT_MAX_SIZE=107,p.prototype._estimateSize=function(){return p.SCRIPT_MAX_SIZE},e.exports=p},function(e,t,r){"use strict";var n=r(18),i=r(75),o=(r(251),r(130)),s=r(84),a=r(21),u=r(64),c=r(63),f=r(83),l=(r(73),r(24)),h=r(131);function p(e,t,r,i){o.apply(this,arguments);var s=this;t=t||e.publicKeys,r=r||e.threshold,i=i||e.signatures,this.publicKeys=n.sortBy(t,function(e){return e.toString("hex")}),a.checkState(u.buildMultisigOut(this.publicKeys,r).equals(this.output.script),"Provided public keys don't match to the provided output script"),this.publicKeyIndex={},n.each(this.publicKeys,function(e,t){s.publicKeyIndex[e.toString()]=t}),this.threshold=r,this.signatures=i?this._deserializeSignatures(i):new Array(this.publicKeys.length)}i(p,o),p.prototype.toObject=function(){var e=o.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=n.map(this.publicKeys,function(e){return e.toString()}),e.signatures=this._serializeSignatures(),e},p.prototype._deserializeSignatures=function(e){return n.map(e,function(e){if(e)return new h(e)})},p.prototype._serializeSignatures=function(){return n.map(this.signatures,function(e){if(e)return e.toObject()})},p.prototype.getSignatures=function(e,t,r,i){a.checkState(this.output instanceof s),i=i||c.SIGHASH_ALL;var o=this,u=[];return n.each(this.publicKeys,function(n){n.toString()===t.publicKey.toString()&&u.push(new h({publicKey:t.publicKey,prevTxId:o.prevTxId,outputIndex:o.outputIndex,inputIndex:r,signature:f.sign(e,t,i,r,o.output.script),sigtype:i}))}),u},p.prototype.addSignature=function(e,t){return a.checkState(!this.isFullySigned(),"All needed signatures have already been added"),a.checkArgument(!n.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),a.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this},p.prototype._updateScript=function(){return this.setScript(u.buildMultisigIn(this.publicKeys,this.threshold,this._createSignatures())),this},p.prototype._createSignatures=function(){return n.map(n.filter(this.signatures,function(e){return!n.isUndefined(e)}),function(e){return l.concat([e.signature.toDER(),l.integerAsSingleByteBuffer(e.sigtype)])})},p.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()},p.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold},p.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()},p.prototype.countSignatures=function(){return n.reduce(this.signatures,function(e,t){return e+!!t},0)},p.prototype.publicKeysWithoutSignature=function(){var e=this;return n.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})},p.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,f.verify(e,t.signature,t.publicKey,t.inputIndex,this.output.script)},p.normalizeSignatures=function(e,t,r,n,i){return i.map(function(i){var o=null;return n=n.filter(function(n){if(o)return!0;var s=new h({signature:c.fromTxFormat(n),publicKey:i,prevTxId:t.prevTxId,outputIndex:t.outputIndex,inputIndex:r,sigtype:c.SIGHASH_ALL});return s.signature.nhashtype=s.sigtype,!f.verify(e,s.signature,s.publicKey,s.inputIndex,t.output.script)||(o=s,!1)}),o||null})},p.OPCODES_SIZE=1,p.SIGNATURE_SIZE=73,p.prototype._estimateSize=function(){return p.OPCODES_SIZE+this.threshold*p.SIGNATURE_SIZE},e.exports=p},function(e,t,r){"use strict";var n=r(18),i=r(75),o=r(130),s=r(84),a=r(21),u=r(64),c=r(63),f=r(83),l=(r(73),r(24)),h=r(131);function p(e,t,r,i){o.apply(this,arguments);var s=this;t=t||e.publicKeys,r=r||e.threshold,i=i||e.signatures,this.publicKeys=n.sortBy(t,function(e){return e.toString("hex")}),this.redeemScript=u.buildMultisigOut(this.publicKeys,r),a.checkState(u.buildScriptHashOut(this.redeemScript).equals(this.output.script),"Provided public keys don't hash to the provided output"),this.publicKeyIndex={},n.each(this.publicKeys,function(e,t){s.publicKeyIndex[e.toString()]=t}),this.threshold=r,this.signatures=i?this._deserializeSignatures(i):new Array(this.publicKeys.length)}i(p,o),p.prototype.toObject=function(){var e=o.prototype.toObject.apply(this,arguments);return e.threshold=this.threshold,e.publicKeys=n.map(this.publicKeys,function(e){return e.toString()}),e.signatures=this._serializeSignatures(),e},p.prototype._deserializeSignatures=function(e){return n.map(e,function(e){if(e)return new h(e)})},p.prototype._serializeSignatures=function(){return n.map(this.signatures,function(e){if(e)return e.toObject()})},p.prototype.getSignatures=function(e,t,r,i){a.checkState(this.output instanceof s),i=i||c.SIGHASH_ALL;var o=this,u=[];return n.each(this.publicKeys,function(n){n.toString()===t.publicKey.toString()&&u.push(new h({publicKey:t.publicKey,prevTxId:o.prevTxId,outputIndex:o.outputIndex,inputIndex:r,signature:f.sign(e,t,i,r,o.redeemScript),sigtype:i}))}),u},p.prototype.addSignature=function(e,t){return a.checkState(!this.isFullySigned(),"All needed signatures have already been added"),a.checkArgument(!n.isUndefined(this.publicKeyIndex[t.publicKey.toString()]),"Signature has no matching public key"),a.checkState(this.isValidSignature(e,t)),this.signatures[this.publicKeyIndex[t.publicKey.toString()]]=t,this._updateScript(),this},p.prototype._updateScript=function(){return this.setScript(u.buildP2SHMultisigIn(this.publicKeys,this.threshold,this._createSignatures(),{cachedMultisig:this.redeemScript})),this},p.prototype._createSignatures=function(){return n.map(n.filter(this.signatures,function(e){return!n.isUndefined(e)}),function(e){return l.concat([e.signature.toDER(),l.integerAsSingleByteBuffer(e.sigtype)])})},p.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()},p.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold},p.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()},p.prototype.countSignatures=function(){return n.reduce(this.signatures,function(e,t){return e+!!t},0)},p.prototype.publicKeysWithoutSignature=function(){var e=this;return n.filter(this.publicKeys,function(t){return!e.signatures[e.publicKeyIndex[t.toString()]]})},p.prototype.isValidSignature=function(e,t){return t.signature.nhashtype=t.sigtype,f.verify(e,t.signature,t.publicKey,t.inputIndex,this.redeemScript)},p.OPCODES_SIZE=7,p.SIGNATURE_SIZE=74,p.PUBKEY_SIZE=34,p.prototype._estimateSize=function(){return p.OPCODES_SIZE+this.threshold*p.SIGNATURE_SIZE+this.publicKeys.length*p.PUBKEY_SIZE},e.exports=p},function(e,t,r){"use strict";var n=r(18),i=r(21),o=r(32),s=r(0),a=r(57),u=r(24),c=r(29),f=r(890);function l(e){return this instanceof l?(this.nullifiers=[],this.commitments=[],this.ciphertexts=[],this.macs=[],e?this._fromObject(e):void 0):new l(e)}Object.defineProperty(l.prototype,"vpub_old",{configurable:!1,enumerable:!0,get:function(){return this._vpub_old},set:function(e){e instanceof o?(this._vpub_oldBN=e,this._vpub_old=e.toNumber()):n.isString(e)?(this._vpub_old=parseInt(e),this._vpub_oldBN=o.fromNumber(this._vpub_old)):(i.checkArgument(c.isNaturalNumber(e),"vpub_old is not a natural number"),this._vpub_oldBN=o.fromNumber(e),this._vpub_old=e),i.checkState(c.isNaturalNumber(this._vpub_old),"vpub_old is not a natural number")}}),Object.defineProperty(l.prototype,"vpub_new",{configurable:!1,enumerable:!0,get:function(){return this._vpub_new},set:function(e){e instanceof o?(this._vpub_newBN=e,this._vpub_new=e.toNumber()):n.isString(e)?(this._vpub_new=parseInt(e),this._vpub_newBN=o.fromNumber(this._vpub_new)):(i.checkArgument(c.isNaturalNumber(e),"vpub_new is not a natural number"),this._vpub_newBN=o.fromNumber(e),this._vpub_new=e),i.checkState(c.isNaturalNumber(this._vpub_new),"vpub_new is not a natural number")}}),l.fromObject=function(e){return i.checkArgument(n.isObject(e)),(new l)._fromObject(e)},l.prototype._fromObject=function(e){var t=[];n.each(e.nullifiers,function(e){t.push(u.reverse(new s.Buffer(e,"hex")))});var r=[];n.each(e.commitments,function(e){r.push(u.reverse(new s.Buffer(e,"hex")))});var i=[];n.each(e.ciphertexts,function(e){i.push(new s.Buffer(e,"hex"))});var o=[];return n.each(e.macs,function(e){o.push(u.reverse(new s.Buffer(e,"hex")))}),this.vpub_old=e.vpub_old,this.vpub_new=e.vpub_new,this.anchor=u.reverse(new s.Buffer(e.anchor,"hex")),this.nullifiers=t,this.commitments=r,this.ephemeralKey=u.reverse(new s.Buffer(e.ephemeralKey,"hex")),this.ciphertexts=i,this.randomSeed=u.reverse(new s.Buffer(e.randomSeed,"hex")),this.macs=o,this.proof=f.fromObject(e.proof),this},l.prototype.toObject=l.prototype.toJSON=function(){var e=[];n.each(this.nullifiers,function(t){e.push(u.reverse(t).toString("hex"))});var t=[];n.each(this.commitments,function(e){t.push(u.reverse(e).toString("hex"))});var r=[];n.each(this.ciphertexts,function(e){r.push(e.toString("hex"))});var i=[];return n.each(this.macs,function(e){i.push(u.reverse(e).toString("hex"))}),{vpub_old:this.vpub_old,vpub_new:this.vpub_new,anchor:u.reverse(this.anchor).toString("hex"),nullifiers:e,commitments:t,ephemeralKey:u.reverse(this.ephemeralKey).toString("hex"),ciphertexts:r,randomSeed:u.reverse(this.randomSeed).toString("hex"),macs:i,proof:this.proof.toObject()}},l.fromBufferReader=function(e){var t,r=new l;for(r.vpub_old=e.readUInt64LEBN(),r.vpub_new=e.readUInt64LEBN(),r.anchor=e.read(32),t=0;t<2;t++)r.nullifiers.push(e.read(32));for(t=0;t<2;t++)r.commitments.push(e.read(32));for(r.ephemeralKey=e.read(32),r.randomSeed=e.read(32),t=0;t<2;t++)r.macs.push(e.read(32));for(r.proof=f.fromBufferReader(e),t=0;t<2;t++)r.ciphertexts.push(e.read(601));return r},l.prototype.toBufferWriter=function(e){var t;for(e||(e=new a),e.writeUInt64LEBN(this._vpub_oldBN),e.writeUInt64LEBN(this._vpub_newBN),e.write(this.anchor),t=0;t<2;t++)e.write(this.nullifiers[t]);for(t=0;t<2;t++)e.write(this.commitments[t]);for(e.write(this.ephemeralKey),e.write(this.randomSeed),t=0;t<2;t++)e.write(this.macs[t]);for(this.proof.toBufferWriter(e),t=0;t<2;t++)e.write(this.ciphertexts[t]);return e},e.exports=l},function(e,t,r){"use strict";var n=r(21),i=r(0),o=r(57);function s(e){return this instanceof s?e?this._fromObject(e):void 0:new s(e)}function a(e){return this instanceof a?e?this._fromObject(e):void 0:new a(e)}function u(e){return this instanceof u?e?this._fromObject(e):void 0:new u(e)}s.fromObject=function(e){return n.checkArgument(_.isObject(e)),(new s)._fromObject(e)},s.prototype._fromObject=function(e){return this.y_lsb=e.y_lsb,this.x=new i.Buffer(e.x,"hex"),this},s.prototype.toObject=s.prototype.toJSON=function(){return{y_lsb:this.y_lsb,x:this.x.toString("hex")}},s.fromBufferReader=function(e){var t=new s,r=e.readUInt8();return t.y_lsb=1&r,t.x=e.read(32),t},s.prototype.toBufferWriter=function(e){return e||(e=new o),e.writeUInt8(2|this.y_lsb),e.write(this.x),e},a.fromObject=function(e){return n.checkArgument(_.isObject(e)),(new a)._fromObject(e)},a.prototype._fromObject=function(e){return this.y_gt=e.y_gt,this.x=new i.Buffer(e.x,"hex"),this},a.prototype.toObject=a.prototype.toJSON=function(){return{y_gt:this.y_gt,x:this.x.toString("hex")}},a.fromBufferReader=function(e){var t=new a,r=e.readUInt8();return t.y_gt=1&r,t.x=e.read(64),t},a.prototype.toBufferWriter=function(e){return e||(e=new o),e.writeUInt8(10|this.y_gt),e.write(this.x),e},u.fromObject=function(e){return n.checkArgument(_.isObject(e)),(new u)._fromObject(e)},u.prototype._fromObject=function(e){return this.g_A=s.fromObject(e.g_A),this.g_A_prime=s.fromObject(e.g_A_prime),this.g_B=a.fromObject(e.g_B),this.g_B_prime=s.fromObject(e.g_B_prime),this.g_C=s.fromObject(e.g_C),this.g_C_prime=s.fromObject(e.g_C_prime),this.g_K=s.fromObject(e.g_K),this.g_H=s.fromObject(e.g_H),this},u.prototype.toObject=u.prototype.toJSON=function(){return{g_A:this.g_A.toObject(),g_A_prime:this.g_A_prime.toObject(),g_B:this.g_B.toObject(),g_B_prime:this.g_B_prime.toObject(),g_C:this.g_C.toObject(),g_C_prime:this.g_C_prime.toObject(),g_K:this.g_K.toObject(),g_H:this.g_H.toObject()}},u.fromBufferReader=function(e){var t=new u;return t.g_A=s.fromBufferReader(e),t.g_A_prime=s.fromBufferReader(e),t.g_B=a.fromBufferReader(e),t.g_B_prime=s.fromBufferReader(e),t.g_C=s.fromBufferReader(e),t.g_C_prime=s.fromBufferReader(e),t.g_K=s.fromBufferReader(e),t.g_H=s.fromBufferReader(e),t},u.prototype.toBufferWriter=function(e){return e||(e=new o),this.g_A.toBufferWriter(e),this.g_A_prime.toBufferWriter(e),this.g_B.toBufferWriter(e),this.g_B_prime.toBufferWriter(e),this.g_C.toBufferWriter(e),this.g_C_prime.toBufferWriter(e),this.g_K.toBufferWriter(e),this.g_H.toBufferWriter(e),e},e.exports=u},function(e,t,r){"use strict";(function(t){var n=r(57),i=r(82),o=r(32),s=function e(r){if(!(this instanceof e))return new e(r);if(t.isBuffer(r))this.buf=r;else if("number"==typeof r){var n=r;this.fromNumber(n)}else if(r instanceof o){var i=r;this.fromBN(i)}else if(r){var s=r;this.set(s)}};s.prototype.set=function(e){return this.buf=e.buf||this.buf,this},s.prototype.fromString=function(e){return this.set({buf:new t(e,"hex")}),this},s.prototype.toString=function(){return this.buf.toString("hex")},s.prototype.fromBuffer=function(e){return this.buf=e,this},s.prototype.fromBufferReader=function(e){return this.buf=e.readVarintBuf(),this},s.prototype.fromBN=function(e){return this.buf=n().writeVarintBN(e).concat(),this},s.prototype.fromNumber=function(e){return this.buf=n().writeVarintNum(e).concat(),this},s.prototype.toBuffer=function(){return this.buf},s.prototype.toBN=function(){return i(this.buf).readVarintBN()},s.prototype.toNumber=function(){return i(this.buf).readVarintNum()},e.exports=s}).call(this,r(0).Buffer)},function(e,t,r){e.exports=r(893),e.exports.BlockHeader=r(180),e.exports.MerkleBlock=r(432)},function(e,t,r){"use strict";(function(t){var n=r(18),i=r(180),o=r(32),s=r(24),a=r(82),u=r(57),c=r(38),f=r(178),l=r(21);function h(e){return this instanceof h?(n.extend(this,h._from(e)),this):new h(e)}h.MAX_BLOCK_SIZE=1e6,h._from=function(e){var t={};if(s.isBuffer(e))t=h._fromBufferReader(a(e));else{if(!n.isObject(e))throw new TypeError("Unrecognized argument for Block");t=h._fromObject(e)}return t},h._fromObject=function(e){var t=[];return e.transactions.forEach(function(e){e instanceof f?t.push(e):t.push(f().fromObject(e))}),{header:i.fromObject(e.header),transactions:t}},h.fromObject=function(e){return new h(h._fromObject(e))},h._fromBufferReader=function(e){var t={};l.checkState(!e.finished(),"No block data received"),t.header=i.fromBufferReader(e);var r=e.readVarintNum();t.transactions=[];for(var n=0;n1;n=Math.floor((n+1)/2)){for(var i=0;i"},h.Values={START_OF_BLOCK:8,NULL_HASH:new t("0000000000000000000000000000000000000000000000000000000000000000","hex")},e.exports=h}).call(this,r(0).Buffer)},function(e,t,r){"use strict";var n=r(18),i=r(33),o=r(97),s=r(253),a=function(e,t){if(!(this instanceof a))return new a(e,t);if(this.extras={},this.knownParams=t||[],this.address=this.network=this.amount=this.message=null,"string"==typeof e){var r=a.parse(e);r.amount&&(r.amount=this._parseAmount(r.amount)),this._fromObject(r)}else{if("object"!=typeof e)throw new TypeError("Unrecognized data format.");this._fromObject(e)}};a.fromString=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return new a(e)},a.fromObject=function(e){return new a(e)},a.isValid=function(e,t){try{new a(e,t)}catch(e){return!1}return!0},a.parse=function(e){var t=i.parse(e,!0);if("zcash:"!==t.protocol)throw new TypeError("Invalid zcash URI");var r=/[^:]*:\/?\/?([^?]*)/.exec(e);return t.query.address=r&&r[1]||void 0,t.query},a.Members=["address","amount","message","label","r"],a.prototype._fromObject=function(e){if(!o.isValid(e.address))throw new TypeError("Invalid zcash address");for(var t in this.address=new o(e.address),this.network=this.address.network,this.amount=e.amount,e)if("address"!==t&&"amount"!==t){if(/^req-/.exec(t)&&-1===this.knownParams.indexOf(t))throw Error("Unknown required argument "+t);(a.Members.indexOf(t)>-1?this:this.extras)[t]=e[t]}},a.prototype._parseAmount=function(e){if(e=Number(e),isNaN(e))throw new TypeError("Invalid amount");return s.fromBTC(e).toSatoshis()},a.prototype.toObject=a.prototype.toJSON=function(){for(var e={},t=0;t"},e.exports=a},function(e,t,r){"use strict";e.exports={SHA1:20,SHA256:32,SHA512:64}},function(e,t,r){"use strict";const n=r(897),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(66);e.exports={createCipheriv:n.createCipheriv,createDecipheriv:n.createDecipheriv}},function(e,t,r){var n=r(436),i=r(440),o=r(2).Buffer,s=r(441),a=r(92),u=r(181),c=r(442);function f(e,t,r){a.call(this),this._cache=new h,this._cipher=new u.AES(t),this._prev=o.from(r),this._mode=e,this._autopadding=!0}r(4)(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 l=o.alloc(16,16);function h(){this.cache=o.allocUnsafe(0)}function p(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(l))throw this._cipher.scrub(),new Error("data not multiple of block length")},f.prototype.setAutoPadding=function(e){return this._autopadding=!!e,this},h.prototype.add=function(e){this.cache=o.concat([this.cache,e])},h.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},h.prototype.flush=function(){for(var e=16-this.cache.length,t=o.allocUnsafe(e),r=-1;++r>a%8,e._prev=o(e._prev,r?i:s);return u}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;e--)r[e]=r[e]>>>1|(1&r[e-1])<<31;r[0]=r[0]>>>1,t&&(r[0]=r[0]^225<<24)}this.state=o(n)},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){var n=r(440),i=r(2).Buffer,o=r(436),s=r(441),a=r(92),u=r(181),c=r(442);function f(e,t,r){a.call(this),this._cache=new l,this._last=void 0,this._cipher=new u.AES(t),this._prev=i.from(r),this._mode=e,this._autopadding=!0}function l(){this.cache=i.allocUnsafe(0)}function h(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(4)(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");for(var r=-1;++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},l.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=c(t,!1,r.key,r.iv);return h(e,n.key,n.iv)},t.createDecipheriv=h},function(e,t,r){"use strict";(function(n){const i=r(11)(r(257)),o=r(17);t=e.exports;const s={rsa:r(917),ed25519:r(931),secp256k1:r(69)(i,r(471))};function a(e){return void 0!==s[e.toLowerCase()]}t.supportedKeys=s,t.keysPBM=i,t.keyStretcher=r(944),t.generateEphemeralKeyPair=r(945),t.generateKeyPair=((e,t,r)=>{let 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)=>{let 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){(function(t){var r={};e.exports=r;var n={};r.encode=function(e,t,r){if("string"!=typeof t)throw new TypeError('"alphabet" must be a string.');if(void 0!==r&&"number"!=typeof r)throw new TypeError('"maxline" must be a number.');var n="";if(e instanceof Uint8Array){var i=0,o=t.length,s=t.charAt(0),a=[0];for(i=0;i0;)a.push(c%o),c=c/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 u="";for(r=0;0===e.at(r)&&r=0;--r)u+=t[o[r]];return u}(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(;l>0;)u.push(255&l),l>>=8}for(var h=0;e[h]===a&&h=i.Versions.TLS_1_1.minor&&u.output.putBytes(r),u.update(e.fragment),u.finish(a)&&(e.fragment=u.output,e.length=e.fragment.length(),o=!0),o}function a(e,t,r){if(!r){var n=e-t.length()%e;t.fillWithByte(n-1,n)}return!0}function u(e,t,r){var n=!0;if(r){for(var i=t.length(),o=t.last(),s=i-1-o;s=a?(e.fragment=s.output.getBytes(f-a),c=s.output.getBytes(a)):e.fragment=s.output.getBytes(),e.fragment=n.util.createBuffer(e.fragment),e.length=e.fragment.length();var l=t.macFunction(t.macKey,t.sequenceNumber,e);return t.updateSequenceNumber(),function(e,t,r){var i=n.hmac.create();return i.start("SHA1",e),i.update(t),t=i.digest().getBytes(),i.start(null,null),i.update(r),t===(r=i.digest().getBytes())}(t.macKey,c,l)&&o}},function(e,t,r){var n=r(13);r(455),e.exports=n.mgf=n.mgf||{},n.mgf.mgf1=n.mgf1},function(e,t,r){(function(t){var n=r(13);if(r(184),r(67),r(457),r(19),void 0===i)var i=n.jsbn.BigInteger;var o=n.util.ByteBuffer,s=void 0===t?Uint8Array:t;n.pki=n.pki||{},e.exports=n.pki.ed25519=n.ed25519=n.ed25519||{};var a=n.ed25519;function u(e){var r=e.message;if(r instanceof Uint8Array)return r;var n=e.encoding;if(void 0===r){if(!e.md)throw new TypeError('"options.message" or "options.md" not specified.');r=e.md.digest().getBytes(),n="binary"}if("string"==typeof r&&!n)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if("string"==typeof r){if(void 0!==t)return new t(r,n);r=new o(r,n)}else if(!(r instanceof o))throw new TypeError('"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.');for(var i=new s(r.length()),a=0;a=0};var c=R(),f=R([1]),l=R([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),h=R([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),p=R([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),d=R([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),y=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]),g=R([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function m(e,r){var i=n.md.sha512.create(),u=new o(e);i.update(u.getBytes(r),"binary");var c=i.digest().getBytes();if(void 0!==t)return new t(c,"binary");for(var f=new s(a.constants.HASH_BYTE_LENGTH),l=0;l<64;++l)f[l]=c.charCodeAt(l);return f}function b(e,t){var r,n,i,o;for(n=63;n>=32;--n){for(r=0,i=n-32,o=n-12;i>8,t[i]-=256*r;t[i]+=r,t[n]=0}for(r=0,i=0;i<32;++i)t[i]+=r-(t[31]>>4)*y[i],r=t[i]>>8,t[i]&=255;for(i=0;i<32;++i)t[i]-=r*y[i];for(n=0;n<32;++n)t[n+1]+=t[n]>>8,e[n]=255&t[n]}function v(e){for(var t=new Float64Array(64),r=0;r<64;++r)t[r]=e[r],e[r]=0;b(e,t)}function _(e,t){var r=R(),n=R(),i=R(),o=R(),s=R(),a=R(),u=R(),c=R(),f=R();L(r,e[1],e[0]),L(f,t[1],t[0]),M(r,r,f),N(n,e[0],e[1]),N(f,t[0],t[1]),M(n,n,f),M(i,e[3],t[3]),M(i,i,h),M(o,e[2],t[2]),N(o,o,o),L(s,n,r),L(a,o,i),N(u,o,i),N(c,n,r),M(e[0],s,a),M(e[1],c,u),M(e[2],u,a),M(e[3],s,c)}function w(e,t,r){for(var n=0;n<4;++n)O(e[n],t[n],r)}function S(e,t){var r=R(),n=R(),i=R();(function(e,t){var r,n=R();for(r=0;r<16;++r)n[r]=t[r];for(r=253;r>=0;--r)j(n,n),2!==r&&4!==r&&M(n,n,t);for(r=0;r<16;++r)e[r]=n[r]})(i,t[2]),M(r,t[0],i),M(n,t[1],i),k(e,n),e[31]^=I(r)<<7}function k(e,t){var r,n,i,o=R(),s=R();for(r=0;r<16;++r)s[r]=t[r];for(P(s),P(s),P(s),n=0;n<2;++n){for(o[0]=s[0]-65517,r=1;r<15;++r)o[r]=s[r]-65535-(o[r-1]>>16&1),o[r-1]&=65535;o[15]=s[15]-32767-(o[14]>>16&1),i=o[15]>>16&1,o[14]&=65535,O(s,o,1-i)}for(r=0;r<16;r++)e[2*r]=255&s[r],e[2*r+1]=s[r]>>8}function E(e,t){var r=R(),n=R(),i=R(),o=R(),s=R(),a=R(),u=R();return C(e[2],f),function(e,t){var r;for(r=0;r<16;++r)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}(e[1],t),j(i,e[1]),M(o,i,l),L(i,i,e[2]),N(o,e[2],o),j(s,o),j(a,s),M(u,a,s),M(r,u,i),M(r,r,o),function(e,t){var r,n=R();for(r=0;r<16;++r)n[r]=t[r];for(r=250;r>=0;--r)j(n,n),1!==r&&M(n,n,t);for(r=0;r<16;++r)e[r]=n[r]}(r,r),M(r,r,i),M(r,r,o),M(r,r,o),M(e[0],r,o),j(n,e[0]),M(n,n,o),A(n,i)&&M(e[0],e[0],g),j(n,e[0]),M(n,n,o),A(n,i)?-1:(I(e[0])===t[31]>>7&&L(e[0],c,e[0]),M(e[3],e[0],e[1]),0)}function A(e,t){var r=new s(32),n=new s(32);return k(r,e),k(n,t),x(r,0,n,0)}function x(e,t,r,n){return function(e,t,r,n,i){var o,s=0;for(o=0;o>>8)-1}(e,t,r,n,32)}function I(e){var t=new s(32);return k(t,e),1&t[0]}function T(e,t,r){var n,i;for(C(e[0],c),C(e[1],f),C(e[2],f),C(e[3],c),i=255;i>=0;--i)w(e,t,n=r[i/8|0]>>(7&i)&1),_(t,e),_(e,e),w(e,t,n)}function B(e,t){var r=[R(),R(),R(),R()];C(r[0],p),C(r[1],d),C(r[2],f),M(r[3],p,d),T(e,r,t)}function C(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function P(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 O(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 R(e){var t,r=new Float64Array(16);if(e)for(t=0;t0&&(s=n.util.fillString(String.fromCharCode(0),u)+s),{encapsulation:t.encrypt(s,"NONE"),key:e.generate(s,o)}},decrypt:function(t,r,n){var i=t.decrypt(r,"NONE");return e.generate(i,n)}}},n.kem.kdf1=function(e,t){o(this,e,0,t||e.digestLength)},n.kem.kdf2=function(e,t){o(this,e,1,t||e.digestLength)}},function(e,t,r){e.exports=r(77),r(259),r(134),r(448),r(457)},function(e,t,r){var n=r(13);r(99),r(76),r(182),r(100),r(112),r(454),r(67),r(19),r(261);var i=n.asn1,o=e.exports=n.pkcs7=n.pkcs7||{};function s(e){var t={},r=[];if(!i.validate(e,o.asn1.recipientInfoValidator,t,r)){var s=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw s.errors=r,s}return{version:t.version.charCodeAt(0),issuer:n.pki.RDNAttributesAsArray(t.issuer),serialNumber:n.util.createBuffer(t.serial).toHex(),encryptedContent:{algorithm:i.derToOid(t.encAlgorithm),parameter:t.encParameter.value,content:t.encKey}}}function a(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()),i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[n.pki.distinguishedNameToAsn1({attributes:e.issuer}),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.encryptedContent.algorithm).getBytes()),i.create(i.Class.UNIVERSAL,i.Type.NULL,!1,"")]),i.create(i.Class.UNIVERSAL,i.Type.OCTETSTRING,!1,e.encryptedContent.content)])}function u(e){var t=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,i.integerToDer(e.version).getBytes()),i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[n.pki.distinguishedNameToAsn1({attributes:e.issuer}),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.digestAlgorithm).getBytes()),i.create(i.Class.UNIVERSAL,i.Type.NULL,!1,"")])]);if(e.authenticatedAttributesAsn1&&t.value.push(e.authenticatedAttributesAsn1),t.value.push(i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(e.signatureAlgorithm).getBytes()),i.create(i.Class.UNIVERSAL,i.Type.NULL,!1,"")])),t.value.push(i.create(i.Class.UNIVERSAL,i.Type.OCTETSTRING,!1,e.signature)),e.unauthenticatedAttributes.length>0){for(var r=i.create(i.Class.CONTEXT_SPECIFIC,1,!0,[]),o=0;o=r&&s0&&s.value[0].value.push(i.create(i.Class.CONTEXT_SPECIFIC,0,!0,t)),o.length>0&&s.value[0].value.push(i.create(i.Class.CONTEXT_SPECIFIC,1,!0,o)),s.value[0].value.push(i.create(i.Class.UNIVERSAL,i.Type.SET,!0,e.signerInfos)),i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(e.type).getBytes()),s])},addSigner:function(t){var r=t.issuer,i=t.serialNumber;if(t.certificate){var o=t.certificate;"string"==typeof o&&(o=n.pki.certificateFromPem(o)),r=o.issuer.attributes,i=o.serialNumber}var s=t.key;if(!s)throw new Error("Could not add PKCS#7 signer; no private key specified.");"string"==typeof s&&(s=n.pki.privateKeyFromPem(s));var a=t.digestAlgorithm||n.pki.oids.sha1;switch(a){case n.pki.oids.sha1:case n.pki.oids.sha256:case n.pki.oids.sha384:case n.pki.oids.sha512:case n.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+a)}var u=t.authenticatedAttributes||[];if(u.length>0){for(var c=!1,f=!1,l=0;l="8"&&(r="00"+r);var i=n.util.hexToBytes(r);e.putInt32(i.length),e.putBytes(i)}function s(e,t){e.putInt32(t.length),e.putString(t)}function a(){for(var e=n.md.sha1.create(),t=arguments.length,r=0;r0&&(this.state=d[this.state].block)},y.prototype.unblock=function(e){return e=void 0===e?1:e,this.blocks-=e,0===this.blocks&&this.state!==h&&(this.state=c,g(this,0)),this.blocks},y.prototype.sleep=function(e){e=void 0===e?0:e,this.state=d[this.state].sleep;var t=this;this.timeoutId=setTimeout(function(){t.timeoutId=null,t.state=c,g(t,0)},e)},y.prototype.wait=function(e){e.wait(this)},y.prototype.wakeup=function(){this.state===l&&(cancelTimeout(this.timeoutId),this.timeoutId=null,this.state=c,g(this,0))},y.prototype.cancel=function(){this.state=d[this.state].cancel,this.permitsNeeded=0,null!==this.timeoutId&&(cancelTimeout(this.timeoutId),this.timeoutId=null),this.subtasks=[]},y.prototype.fail=function(e){if(this.error=!0,m(this,!0),e)e.error=this.error,e.swapTime=this.swapTime,e.userData=this.userData,g(e,0);else{if(null!==this.parent){for(var t=this.parent;null!==t.parent;)t.error=this.error,t.swapTime=this.swapTime,t.userData=this.userData,t=t.parent;m(t,!0)}this.failureCallback&&this.failureCallback(this)}};var g=function(e,t){var r=t>30||+new Date-e.swapTime>20,n=function(t){if(t++,e.state===c)if(r&&(e.swapTime=+new Date),e.subtasks.length>0){var n=e.subtasks.shift();n.error=e.error,n.swapTime=e.swapTime,n.userData=e.userData,n.run(n),n.error||g(n,t)}else m(e),e.error||null!==e.parent&&(e.parent.error=e.error,e.parent.swapTime=e.swapTime,e.parent.userData=e.userData,g(e.parent,t))};r?setTimeout(n,0):n(t)},m=function(e,t){e.state=h,delete o[e.id],null===e.parent&&(e.type in a?0===a[e.type].length?n.log.error(i,"[%s][%s] task queue empty [%s]",e.id,e.name,e.type):a[e.type][0]!==e?n.log.error(i,"[%s][%s] task not first in queue [%s]",e.id,e.name,e.type):(a[e.type].shift(),0===a[e.type].length?delete a[e.type]:a[e.type][0].start()):n.log.error(i,"[%s][%s] task queue missing [%s]",e.id,e.name,e.type),t||(e.error&&e.failureCallback?e.failureCallback(e):!e.error&&e.successCallback&&e.successCallback(e)))};e.exports=n.task=n.task||{},n.task.start=function(e){var t=new y({run:e.run,name:e.name||"?"});t.type=e.type,t.successCallback=e.success||null,t.failureCallback=e.failure||null,t.type in a?a[e.type].push(t):(a[t.type]=[t],function(e){e.error=!1,e.state=d[e.state].start,setTimeout(function(){e.state===c&&(e.swapTime=+new Date,e.run(e),g(e,0))},0)}(t))},n.task.cancel=function(e){e in a&&(a[e]=[a[e][0]])},n.task.createCondition=function(){var e={tasks:{},wait:function(t){t.id in e.tasks||(t.block(),e.tasks[t.id]=t)},notify:function(){var t=e.tasks;for(var r in e.tasks={},t)t[r].unblock()}};return e}},function(e,t,r){"use strict";const n=r(459),i=r(11),o=r(14),s=r(461),a=i(r(257)),u=r(17),c=r(3);class f{constructor(e){this._key=e}verify(e,t,r){h(r),s.hashAndVerify(this._key,t,e,r)}marshal(){return s.utils.jwkToPkix(this._key)}get bytes(){return a.PublicKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}encrypt(e){return this._key.encrypt(e,"RSAES-PKCS1-V1_5")}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(e),n(this.bytes,"sha2-256",e)}}class l{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return s.getRandomValues(new Uint8Array(16))}sign(e,t){h(t),s.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){s.decrypt(this._key,e,t)}marshal(){return s.utils.jwkToPkcs1(this._key)}get bytes(){return a.PrivateKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(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"),h(r),c(()=>{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 h(e){if("function"!=typeof e)throw new Error("callback is required")}e.exports={RsaPublicKey:f,RsaPrivateKey:l,unmarshalRsaPublicKey:function(e){const t=s.utils.pkixToJwk(e);return new f(t)},unmarshalRsaPrivateKey:function(e,t){const r=s.utils.pkcs1ToJwk(e);s.unmarshalPrivateKey(r,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},generateKeyPair:function(e,t){s.generateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},fromJwk:function(e,t){s.unmarshalPrivateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})}}},function(e,t,r){"use strict";(function(t){const n=r(42),i=r(43),o=r(460),s=r(919),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,256)),shake256:a(u(n.shake_256,512)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(920),dblSha2256:(e,r)=>{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(44),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;function o(e){if(!i)throw new Error("Please use a browser with webcrypto support");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(45),i=r(460).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(15),i=r(466),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())}),u=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()))}),c=n.define("RSAPublicKey",function(){this.seq().obj(this.key("algorithm").use(u),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=c.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 c.encode({algorithm:{algorithm:"rsa",none:null},subjectPublicKey:{data:f.encode({modulus:s(e.n),publicExponent:s(e.e)},"der")}},"der")}},function(e,t,r){"use strict";const n=r(15),i=r(4);function o(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}t.define=function(e,t){return new o(e,t)},o.prototype._createNamed=function(e){let t;try{t=r(923).runInThisContext("(function "+this.name+"(entity) {\n this._initNamed(entity);\n})")}catch(e){t=function(e){this._initNamed(e)}}return i(t,e),t.prototype._initNamed=function(t){e.call(this,t)},new t(this)},o.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(n.decoders[e])),this.decoders[e]},o.prototype.decode=function(e,t,r){return this._getDecoder(t).decode(e,r)},o.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(n.encoders[e])),this.encoders[e]},o.prototype.encode=function(e,t,r){return this._getEncoder(t).encode(e,r)}},function(module,exports,__webpack_require__){var indexOf=__webpack_require__(263),Object_keys=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var r in e)t.push(r);return t},forEach=function(e,t){if(e.forEach)return e.forEach(t);for(var r=0;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 l(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:u,Ed25519PrivateKey:c,unmarshalEd25519PrivateKey:function(e,t){try{e=l(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 c(r,n))},unmarshalEd25519PublicKey:function(e){return e=l(e,s.publicKeyLength),new u(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 c(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 c(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(68),i=r(3);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){},function(e,t,r){"use strict";(function(t){const n=r(42),i=r(43),o=r(468),s=r(935),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,256)),shake256:a(u(n.shake_256,512)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(936),dblSha2256:(e,r)=>{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(44),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;function o(e){if(!i)throw new Error("Please use a browser with webcrypto support");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(45),i=r(468).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(938),i=r(467),o=r(3),s="sha2-256";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));((e,r)=>o(()=>t(e,r)))(null,r)},privateKeyLength:32,hashAndSign:function(e,t,r){const a=(e,t)=>o(()=>r(e,t));i.digest(t,s,(t,r)=>{if(t)return a(t);try{const i=n.sign(r,e),o=n.signatureExport(i.signature);return a(null,o)}catch(t){a(t)}})},hashAndVerify:function(e,t,r,a){const u=(e,t)=>o(()=>a(e,t));i.digest(r,s,(r,i)=>{if(r)return u(r);try{t=n.signatureImport(t);const o=n.verify(i,t,e);return u(null,o)}catch(r){u(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(414)(r(939))},function(e,t,r){"use strict";var n=r(2).Buffer,i=r(123),o=r(940),s=r(246),a=r(185),u=r(469),c=r(943);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 c.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 c.mul(r).toPublicKey(t)},t.publicKeyConvert=function(e,t){var r=u.fromPublicKey(e);if(null===r)throw new Error(s.EC_PUBLIC_KEY_PARSE_FAIL);return r.toPublicKey(t)},t.publicKeyVerify=function(e){return null!==u.fromPublicKey(e)},t.publicKeyTweakAdd=function(e,t,r){var n=u.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);return c.mul(t).add(n).toPublicKey(r)},t.publicKeyTweakMul=function(e,t,r){var n=u.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(d).ucmp(p.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 l=o;if(r>>1){if(l.ucmp(a.psn)>=0)break;l=o.add(a.n)}var h=n.concat([n.from([2+(1&r)]),l.toBuffer()]),p=u.fromPublicKey(h);if(null===p)break;var d=o.uinvm(),y=a.n.sub(a.fromBuffer(e)).umul(d).ureduce(),g=f.umul(d).ureduce();return u.fromECJPoint(c.mulAdd(y,p,g)).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=u.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";(function(t){var n=r(243),i=r(941),o=new t(0),s=new t([0]),a=new t([1]);function u(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)}u.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())},u.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.length>>13,p=0|s[1],d=8191&p,y=p>>>13,g=0|s[2],m=8191&g,b=g>>>13,v=0|s[3],_=8191&v,w=v>>>13,S=0|s[4],k=8191&S,E=S>>>13,A=0|s[5],x=8191&A,I=A>>>13,T=0|s[6],B=8191&T,C=T>>>13,P=0|s[7],O=8191&P,R=P>>>13,N=0|s[8],L=8191&N,j=N>>>13,M=0|s[9],K=8191&M,D=M>>>13,U=0|a[0],F=8191&U,q=U>>>13,H=0|a[1],z=8191&H,V=H>>>13,G=0|a[2],W=8191&G,$=G>>>13,Y=0|a[3],J=8191&Y,X=Y>>>13,Z=0|a[4],Q=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],ue=8191&ae,ce=ae>>>13,fe=0|a[8],le=8191&fe,he=fe>>>13,pe=0|a[9],de=8191&pe,ye=pe>>>13;r.length=19,n=Math.imul(l,F),i=Math.imul(l,q);var ge=c+n+((8191&(i+=Math.imul(h,F)))<<13);c=(o=Math.imul(h,q))+(i>>>13)+(ge>>>26),ge&=67108863,n=Math.imul(d,F),i=Math.imul(d,q),i+=Math.imul(y,F),o=Math.imul(y,q),n+=Math.imul(l,z),i+=Math.imul(l,V);var me=c+n+((8191&(i+=Math.imul(h,z)))<<13);c=(o+=Math.imul(h,V))+(i>>>13)+(me>>>26),me&=67108863,n=Math.imul(m,F),i=Math.imul(m,q),i+=Math.imul(b,F),o=Math.imul(b,q),n+=Math.imul(d,z),i+=Math.imul(d,V),i+=Math.imul(y,z),o+=Math.imul(y,V),n+=Math.imul(l,W),i+=Math.imul(l,$);var be=c+n+((8191&(i+=Math.imul(h,W)))<<13);c=(o+=Math.imul(h,$))+(i>>>13)+(be>>>26),be&=67108863,n=Math.imul(_,F),i=Math.imul(_,q),i+=Math.imul(w,F),o=Math.imul(w,q),n+=Math.imul(m,z),i+=Math.imul(m,V),i+=Math.imul(b,z),o+=Math.imul(b,V),n+=Math.imul(d,W),i+=Math.imul(d,$),i+=Math.imul(y,W),o+=Math.imul(y,$),n+=Math.imul(l,J),i+=Math.imul(l,X);var ve=c+n+((8191&(i+=Math.imul(h,J)))<<13);c=(o+=Math.imul(h,X))+(i>>>13)+(ve>>>26),ve&=67108863,n=Math.imul(k,F),i=Math.imul(k,q),i+=Math.imul(E,F),o=Math.imul(E,q),n+=Math.imul(_,z),i+=Math.imul(_,V),i+=Math.imul(w,z),o+=Math.imul(w,V),n+=Math.imul(m,W),i+=Math.imul(m,$),i+=Math.imul(b,W),o+=Math.imul(b,$),n+=Math.imul(d,J),i+=Math.imul(d,X),i+=Math.imul(y,J),o+=Math.imul(y,X),n+=Math.imul(l,Q),i+=Math.imul(l,ee);var _e=c+n+((8191&(i+=Math.imul(h,Q)))<<13);c=(o+=Math.imul(h,ee))+(i>>>13)+(_e>>>26),_e&=67108863,n=Math.imul(x,F),i=Math.imul(x,q),i+=Math.imul(I,F),o=Math.imul(I,q),n+=Math.imul(k,z),i+=Math.imul(k,V),i+=Math.imul(E,z),o+=Math.imul(E,V),n+=Math.imul(_,W),i+=Math.imul(_,$),i+=Math.imul(w,W),o+=Math.imul(w,$),n+=Math.imul(m,J),i+=Math.imul(m,X),i+=Math.imul(b,J),o+=Math.imul(b,X),n+=Math.imul(d,Q),i+=Math.imul(d,ee),i+=Math.imul(y,Q),o+=Math.imul(y,ee),n+=Math.imul(l,re),i+=Math.imul(l,ne);var we=c+n+((8191&(i+=Math.imul(h,re)))<<13);c=(o+=Math.imul(h,ne))+(i>>>13)+(we>>>26),we&=67108863,n=Math.imul(B,F),i=Math.imul(B,q),i+=Math.imul(C,F),o=Math.imul(C,q),n+=Math.imul(x,z),i+=Math.imul(x,V),i+=Math.imul(I,z),o+=Math.imul(I,V),n+=Math.imul(k,W),i+=Math.imul(k,$),i+=Math.imul(E,W),o+=Math.imul(E,$),n+=Math.imul(_,J),i+=Math.imul(_,X),i+=Math.imul(w,J),o+=Math.imul(w,X),n+=Math.imul(m,Q),i+=Math.imul(m,ee),i+=Math.imul(b,Q),o+=Math.imul(b,ee),n+=Math.imul(d,re),i+=Math.imul(d,ne),i+=Math.imul(y,re),o+=Math.imul(y,ne),n+=Math.imul(l,oe),i+=Math.imul(l,se);var Se=c+n+((8191&(i+=Math.imul(h,oe)))<<13);c=(o+=Math.imul(h,se))+(i>>>13)+(Se>>>26),Se&=67108863,n=Math.imul(O,F),i=Math.imul(O,q),i+=Math.imul(R,F),o=Math.imul(R,q),n+=Math.imul(B,z),i+=Math.imul(B,V),i+=Math.imul(C,z),o+=Math.imul(C,V),n+=Math.imul(x,W),i+=Math.imul(x,$),i+=Math.imul(I,W),o+=Math.imul(I,$),n+=Math.imul(k,J),i+=Math.imul(k,X),i+=Math.imul(E,J),o+=Math.imul(E,X),n+=Math.imul(_,Q),i+=Math.imul(_,ee),i+=Math.imul(w,Q),o+=Math.imul(w,ee),n+=Math.imul(m,re),i+=Math.imul(m,ne),i+=Math.imul(b,re),o+=Math.imul(b,ne),n+=Math.imul(d,oe),i+=Math.imul(d,se),i+=Math.imul(y,oe),o+=Math.imul(y,se),n+=Math.imul(l,ue),i+=Math.imul(l,ce);var ke=c+n+((8191&(i+=Math.imul(h,ue)))<<13);c=(o+=Math.imul(h,ce))+(i>>>13)+(ke>>>26),ke&=67108863,n=Math.imul(L,F),i=Math.imul(L,q),i+=Math.imul(j,F),o=Math.imul(j,q),n+=Math.imul(O,z),i+=Math.imul(O,V),i+=Math.imul(R,z),o+=Math.imul(R,V),n+=Math.imul(B,W),i+=Math.imul(B,$),i+=Math.imul(C,W),o+=Math.imul(C,$),n+=Math.imul(x,J),i+=Math.imul(x,X),i+=Math.imul(I,J),o+=Math.imul(I,X),n+=Math.imul(k,Q),i+=Math.imul(k,ee),i+=Math.imul(E,Q),o+=Math.imul(E,ee),n+=Math.imul(_,re),i+=Math.imul(_,ne),i+=Math.imul(w,re),o+=Math.imul(w,ne),n+=Math.imul(m,oe),i+=Math.imul(m,se),i+=Math.imul(b,oe),o+=Math.imul(b,se),n+=Math.imul(d,ue),i+=Math.imul(d,ce),i+=Math.imul(y,ue),o+=Math.imul(y,ce),n+=Math.imul(l,le),i+=Math.imul(l,he);var Ee=c+n+((8191&(i+=Math.imul(h,le)))<<13);c=(o+=Math.imul(h,he))+(i>>>13)+(Ee>>>26),Ee&=67108863,n=Math.imul(K,F),i=Math.imul(K,q),i+=Math.imul(D,F),o=Math.imul(D,q),n+=Math.imul(L,z),i+=Math.imul(L,V),i+=Math.imul(j,z),o+=Math.imul(j,V),n+=Math.imul(O,W),i+=Math.imul(O,$),i+=Math.imul(R,W),o+=Math.imul(R,$),n+=Math.imul(B,J),i+=Math.imul(B,X),i+=Math.imul(C,J),o+=Math.imul(C,X),n+=Math.imul(x,Q),i+=Math.imul(x,ee),i+=Math.imul(I,Q),o+=Math.imul(I,ee),n+=Math.imul(k,re),i+=Math.imul(k,ne),i+=Math.imul(E,re),o+=Math.imul(E,ne),n+=Math.imul(_,oe),i+=Math.imul(_,se),i+=Math.imul(w,oe),o+=Math.imul(w,se),n+=Math.imul(m,ue),i+=Math.imul(m,ce),i+=Math.imul(b,ue),o+=Math.imul(b,ce),n+=Math.imul(d,le),i+=Math.imul(d,he),i+=Math.imul(y,le),o+=Math.imul(y,he),n+=Math.imul(l,de),i+=Math.imul(l,ye);var Ae=c+n+((8191&(i+=Math.imul(h,de)))<<13);c=(o+=Math.imul(h,ye))+(i>>>13)+(Ae>>>26),Ae&=67108863,n=Math.imul(K,z),i=Math.imul(K,V),i+=Math.imul(D,z),o=Math.imul(D,V),n+=Math.imul(L,W),i+=Math.imul(L,$),i+=Math.imul(j,W),o+=Math.imul(j,$),n+=Math.imul(O,J),i+=Math.imul(O,X),i+=Math.imul(R,J),o+=Math.imul(R,X),n+=Math.imul(B,Q),i+=Math.imul(B,ee),i+=Math.imul(C,Q),o+=Math.imul(C,ee),n+=Math.imul(x,re),i+=Math.imul(x,ne),i+=Math.imul(I,re),o+=Math.imul(I,ne),n+=Math.imul(k,oe),i+=Math.imul(k,se),i+=Math.imul(E,oe),o+=Math.imul(E,se),n+=Math.imul(_,ue),i+=Math.imul(_,ce),i+=Math.imul(w,ue),o+=Math.imul(w,ce),n+=Math.imul(m,le),i+=Math.imul(m,he),i+=Math.imul(b,le),o+=Math.imul(b,he),n+=Math.imul(d,de),i+=Math.imul(d,ye);var xe=c+n+((8191&(i+=Math.imul(y,de)))<<13);c=(o+=Math.imul(y,ye))+(i>>>13)+(xe>>>26),xe&=67108863,n=Math.imul(K,W),i=Math.imul(K,$),i+=Math.imul(D,W),o=Math.imul(D,$),n+=Math.imul(L,J),i+=Math.imul(L,X),i+=Math.imul(j,J),o+=Math.imul(j,X),n+=Math.imul(O,Q),i+=Math.imul(O,ee),i+=Math.imul(R,Q),o+=Math.imul(R,ee),n+=Math.imul(B,re),i+=Math.imul(B,ne),i+=Math.imul(C,re),o+=Math.imul(C,ne),n+=Math.imul(x,oe),i+=Math.imul(x,se),i+=Math.imul(I,oe),o+=Math.imul(I,se),n+=Math.imul(k,ue),i+=Math.imul(k,ce),i+=Math.imul(E,ue),o+=Math.imul(E,ce),n+=Math.imul(_,le),i+=Math.imul(_,he),i+=Math.imul(w,le),o+=Math.imul(w,he),n+=Math.imul(m,de),i+=Math.imul(m,ye);var Ie=c+n+((8191&(i+=Math.imul(b,de)))<<13);c=(o+=Math.imul(b,ye))+(i>>>13)+(Ie>>>26),Ie&=67108863,n=Math.imul(K,J),i=Math.imul(K,X),i+=Math.imul(D,J),o=Math.imul(D,X),n+=Math.imul(L,Q),i+=Math.imul(L,ee),i+=Math.imul(j,Q),o+=Math.imul(j,ee),n+=Math.imul(O,re),i+=Math.imul(O,ne),i+=Math.imul(R,re),o+=Math.imul(R,ne),n+=Math.imul(B,oe),i+=Math.imul(B,se),i+=Math.imul(C,oe),o+=Math.imul(C,se),n+=Math.imul(x,ue),i+=Math.imul(x,ce),i+=Math.imul(I,ue),o+=Math.imul(I,ce),n+=Math.imul(k,le),i+=Math.imul(k,he),i+=Math.imul(E,le),o+=Math.imul(E,he),n+=Math.imul(_,de),i+=Math.imul(_,ye);var Te=c+n+((8191&(i+=Math.imul(w,de)))<<13);c=(o+=Math.imul(w,ye))+(i>>>13)+(Te>>>26),Te&=67108863,n=Math.imul(K,Q),i=Math.imul(K,ee),i+=Math.imul(D,Q),o=Math.imul(D,ee),n+=Math.imul(L,re),i+=Math.imul(L,ne),i+=Math.imul(j,re),o+=Math.imul(j,ne),n+=Math.imul(O,oe),i+=Math.imul(O,se),i+=Math.imul(R,oe),o+=Math.imul(R,se),n+=Math.imul(B,ue),i+=Math.imul(B,ce),i+=Math.imul(C,ue),o+=Math.imul(C,ce),n+=Math.imul(x,le),i+=Math.imul(x,he),i+=Math.imul(I,le),o+=Math.imul(I,he),n+=Math.imul(k,de),i+=Math.imul(k,ye);var Be=c+n+((8191&(i+=Math.imul(E,de)))<<13);c=(o+=Math.imul(E,ye))+(i>>>13)+(Be>>>26),Be&=67108863,n=Math.imul(K,re),i=Math.imul(K,ne),i+=Math.imul(D,re),o=Math.imul(D,ne),n+=Math.imul(L,oe),i+=Math.imul(L,se),i+=Math.imul(j,oe),o+=Math.imul(j,se),n+=Math.imul(O,ue),i+=Math.imul(O,ce),i+=Math.imul(R,ue),o+=Math.imul(R,ce),n+=Math.imul(B,le),i+=Math.imul(B,he),i+=Math.imul(C,le),o+=Math.imul(C,he),n+=Math.imul(x,de),i+=Math.imul(x,ye);var Ce=c+n+((8191&(i+=Math.imul(I,de)))<<13);c=(o+=Math.imul(I,ye))+(i>>>13)+(Ce>>>26),Ce&=67108863,n=Math.imul(K,oe),i=Math.imul(K,se),i+=Math.imul(D,oe),o=Math.imul(D,se),n+=Math.imul(L,ue),i+=Math.imul(L,ce),i+=Math.imul(j,ue),o+=Math.imul(j,ce),n+=Math.imul(O,le),i+=Math.imul(O,he),i+=Math.imul(R,le),o+=Math.imul(R,he),n+=Math.imul(B,de),i+=Math.imul(B,ye);var Pe=c+n+((8191&(i+=Math.imul(C,de)))<<13);c=(o+=Math.imul(C,ye))+(i>>>13)+(Pe>>>26),Pe&=67108863,n=Math.imul(K,ue),i=Math.imul(K,ce),i+=Math.imul(D,ue),o=Math.imul(D,ce),n+=Math.imul(L,le),i+=Math.imul(L,he),i+=Math.imul(j,le),o+=Math.imul(j,he),n+=Math.imul(O,de),i+=Math.imul(O,ye);var Oe=c+n+((8191&(i+=Math.imul(R,de)))<<13);c=(o+=Math.imul(R,ye))+(i>>>13)+(Oe>>>26),Oe&=67108863,n=Math.imul(K,le),i=Math.imul(K,he),i+=Math.imul(D,le),o=Math.imul(D,he),n+=Math.imul(L,de),i+=Math.imul(L,ye);var Re=c+n+((8191&(i+=Math.imul(j,de)))<<13);c=(o+=Math.imul(j,ye))+(i>>>13)+(Re>>>26),Re&=67108863,n=Math.imul(K,de),i=Math.imul(K,ye);var Ne=c+n+((8191&(i+=Math.imul(D,de)))<<13);return c=(o=Math.imul(D,ye))+(i>>>13)+(Ne>>>26),Ne&=67108863,u[0]=ge,u[1]=me,u[2]=be,u[3]=ve,u[4]=_e,u[5]=we,u[6]=Se,u[7]=ke,u[8]=Ee,u[9]=Ae,u[10]=xe,u[11]=Ie,u[12]=Te,u[13]=Be,u[14]=Ce,u[15]=Pe,u[16]=Oe,u[17]=Re,u[18]=Ne,0!==c&&(u[19]=c,r.length++),r}},function(e,t,r){"use strict";var n=r(2).Buffer,i=r(185),o=r(469),s=r(470);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=c;l--)f=(f<<1)+i[l];u.push(f)}for(var h=new s(null,null,null),p=new s(null,null,null),d=a;d>0;d--){for(var y=0;y=0;f--){for(var l=0;f>=0&&(c[0]=0|a[0][f],c[1]=0|a[1][f],0===c[0]&&0===c[1]);++l,--f);if(f>=0&&(l+=1),u=u.dblp(l),f<0)break;for(var h=0;h<2;h++){var p,d=c[h];0!==d&&(d>0?p=o[h][d>>1]:d<0&&(p=o[h][-d>>1].neg()),u=void 0===p.z?u.mixedAdd(p):u.add(p))}}return u},e.exports=new a},function(e,t,r){"use strict";(function(t){const n=r(40),i=r(435),o={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,cipherKeySize:32}};e.exports=((e,r,s,a)=>{const u=o[e];if(!u)return a(new Error("unkown cipherType passed"));if(!r)return a(new Error("unkown hashType passed"));const c=u.keySize,f=u.ivSize,l=t.from("key expansion"),h=2*(f+c+20);i.create(r,s,(e,r)=>{if(e)return a(e);r.digest(l,(e,i)=>{if(e)return a(e);let o=[],s=0;n(()=>s{if(t)return e(t);let a=n.length;s+a>h&&(a=h-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=h/2,n=t.concat(o),i=n.slice(0,r),s=n.slice(r,h),u=e=>({iv:e.slice(0,f),cipherKey:e.slice(f,f+c),macKey:e.slice(f+c)});a(null,{k1:u(i),k2:u(s)})})})})})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(946);e.exports=((e,t)=>{n.generateEphmeralKeyPair(e,t)})},function(e,t,r){"use strict";(function(e){const n=r(256)(),i=r(255),o=r(15).bignum,s=r(466),a=s.toBase64,u=s.toBn,c={"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 o=(o,s,a)=>{let u;"function"==typeof s&&(a=s,s=void 0),u=s?n.subtle.importKey("jwk",p(t,s),{name:"ECDH",namedCurve:t},!1,["deriveBits"]):Promise.resolve(r.privateKey);const f=Promise.all([n.subtle.importKey("jwk",h(t,o),{name:"ECDH",namedCurve:t},!1,[]),u]);i(f.then(e=>n.subtle.deriveBits({name:"ECDH",namedCurve:t,public:e[0]},e[1],c[t])).then(t=>e.from(t)),a)};return n.subtle.exportKey("jwk",r.publicKey).then(e=>({key:l(e),genSharedKey:o}))}),r)};const f={"P-256":32,"P-384":48,"P-521":66};function l(t){const r=f[t.crv];return e.concat([e.from([4]),u(t.x).toArrayLike(e,"be",r),u(t.y).toArrayLike(e,"be",r)],1+2*r)}function h(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}}function p(e,t){const r=h(e,t.public);return r.d=a(new o(t.private)),r}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(17),i={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};e.exports=function(e,t,r,o,s){const a=i[s];if(!a)throw new Error(`Hash '${s}' is unknown or not supported`);const u=n.pkcs5.pbkdf2(e,t,r,o,a);return n.util.encode64(u)}},function(e,t,r){"use strict";(function(n){const i=r(12),o=r(949),s=r(16),a=r(5);class u{constructor(e,t,r){s(n.isBuffer(e),"invalid id provided"),t&&r&&s(t.public.bytes.equals(r.bytes),"inconsistent arguments"),this._id=e,this._idB58String=i.toB58String(this.id),this._privKey=t,this._pubKey=r}get id(){return this._id}set id(e){throw new Error("Id is immutable")}get privKey(){return this._privKey}set privKey(e){this._privKey=e}get pubKey(){return this._pubKey?this._pubKey:this._privKey?this._privKey.public:void 0}set pubKey(e){this._pubKey=e}marshalPubKey(){if(this.pubKey)return o.keys.marshalPublicKey(this.pubKey)}marshalPrivKey(){if(this.privKey)return o.keys.marshalPrivateKey(this.privKey)}toPrint(){return this.toJSON()}toJSON(){return{id:this.toB58String(),privKey:c(this.marshalPrivKey()),pubKey:c(this.marshalPubKey())}}toHexString(){return i.toHexString(this.id)}toBytes(){return this.id}toB58String(){return this._idB58String}isEqual(e){if(n.isBuffer(e))return this.id.equals(e);if(e.id)return this.id.equals(e.id);throw new Error("not valid Id")}isValid(e){this.privKey&&this.privKey.public&&this.privKey.public.bytes&&n.isBuffer(this.pubKey.bytes)&&this.privKey.public.bytes.equals(this.pubKey.bytes)?e():e(new Error("Keys not match"))}}function c(e){if(e)return e.toString("base64")}(t=e.exports=u).create=function(e,t){"function"==typeof e&&(t=e,e={}),(e=e||{}).bits=e.bits||2048,a([t=>o.keys.generateKeyPair("RSA",e.bits,t),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n))})},t.createFromHexString=function(e){return new u(i.fromHexString(e))},t.createFromBytes=function(e){return new u(e)},t.createFromB58String=function(e){return new u(i.fromB58String(e))},t.createFromPubKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r;try{let i=e;if("string"==typeof i&&(i=n.from(e,"base64")),!n.isBuffer(i))throw new Error("Supplied key is neither a base64 string nor a buffer");r=o.keys.unmarshalPublicKey(i)}catch(e){return t(e)}r.hash((e,n)=>{if(e)return t(e);t(null,new u(n,null,r))})},t.createFromPrivKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r=e;try{if("string"==typeof r&&(r=n.from(e,"base64")),!n.isBuffer(r))throw new Error("Supplied key is neither a base64 string nor a buffer")}catch(e){return t(e)}a([e=>o.keys.unmarshalPrivateKey(r,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n,n.public))})},t.createFromJSON=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r,s,c,f;try{r=i.fromB58String(e.id),s=e.privKey&&n.from(e.privKey,"base64"),c=e.pubKey&&n.from(e.pubKey,"base64"),f=c&&o.keys.unmarshalPublicKey(c)}catch(e){return t(e)}s?a([e=>o.keys.unmarshalPrivateKey(s,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)}),(e,t,r)=>{f?f.hash((n,i)=>{r(n,e,t,i)}):r(null,e,t)}],(e,n,i,o)=>e?t(e):f&&!n.equals(o)?t(new Error("Public and private key do not match")):r&&!n.equals(r)?t(new Error("Id and private key do not match")):void t(null,new u(r,i,f))):t(null,new u(r,null,f))},t.isPeerId=function(e){return Boolean("object"==typeof e&&e._id&&e._idB58String)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(472),i=r(951),o=r(953);(t=e.exports).aes=i,t.hmac=n,t.keys=o,t.randomBytes=r(477),t.pbkdf2=r(964)},function(e,t,r){"use strict";e.exports={SHA1:20,SHA256:32,SHA512:64}},function(e,t,r){"use strict";const n=r(952),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(66);e.exports={createCipheriv:n.createCipheriv,createDecipheriv:n.createDecipheriv}},function(e,t,r){"use strict";(function(n){const i=r(11)(r(266)),o=r(17);t=e.exports;const s={rsa:r(954),ed25519:r(959),secp256k1:r(69)(i,r(477))};function a(e){return void 0!==s[e.toLowerCase()]}t.supportedKeys=s,t.keysPBM=i,t.keyStretcher=r(961),t.generateEphemeralKeyPair=r(962),t.generateKeyPair=((e,t,r)=>{let 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)=>{let 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){"use strict";const n=r(473),i=r(11),o=r(14),s=r(475),a=i(r(266)),u=r(17),c=r(3);class f{constructor(e){this._key=e}verify(e,t,r){h(r),s.hashAndVerify(this._key,t,e,r)}marshal(){return s.utils.jwkToPkix(this._key)}get bytes(){return a.PublicKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}encrypt(e){return this._key.encrypt(e,"RSAES-PKCS1-V1_5")}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(e),n(this.bytes,"sha2-256",e)}}class l{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return s.getRandomValues(new Uint8Array(16))}sign(e,t){h(t),s.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){s.decrypt(this._key,e,t)}marshal(){return s.utils.jwkToPkcs1(this._key)}get bytes(){return a.PrivateKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(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"),h(r),c(()=>{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 h(e){if("function"!=typeof e)throw new Error("callback is required")}e.exports={RsaPublicKey:f,RsaPrivateKey:l,unmarshalRsaPublicKey:function(e){const t=s.utils.pkixToJwk(e);return new f(t)},unmarshalRsaPrivateKey:function(e,t){const r=s.utils.pkcs1ToJwk(e);s.unmarshalPrivateKey(r,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},generateKeyPair:function(e,t){s.generateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},fromJwk:function(e,t){s.unmarshalPrivateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})}}},function(e,t,r){"use strict";(function(t){const n=r(42),i=r(43),o=r(474),s=r(956),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,256)),shake256:a(u(n.shake_256,512)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(957),dblSha2256:(e,r)=>{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(44),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;function o(e){if(!i)throw new Error("Please use a browser with webcrypto support");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(45),i=r(474).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(15),i=r(476),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())}),u=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()))}),c=n.define("RSAPublicKey",function(){this.seq().obj(this.key("algorithm").use(u),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=c.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 c.encode({algorithm:{algorithm:"rsa",none:null},subjectPublicKey:{data:f.encode({modulus:s(e.n),publicExponent:s(e.e)},"der")}},"der")}},function(e,t,r){"use strict";(function(t){const n=r(473),i=r(11),o=r(14),s=r(960),a=i(r(266));class u{constructor(e){this._key=l(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 c{constructor(e,t){this._key=l(e,s.privateKeyLength),this._publicKey=l(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 u(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 l(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:u,Ed25519PrivateKey:c,unmarshalEd25519PrivateKey:function(e,t){try{e=l(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 c(r,n))},unmarshalEd25519PublicKey:function(e){return e=l(e,s.publicKeyLength),new u(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 c(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 c(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(68),i=r(3);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){"use strict";(function(t){const n=r(40),i=r(472),o={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,cipherKeySize:32}};e.exports=((e,r,s,a)=>{const u=o[e];if(!u)return a(new Error("unkown cipherType passed"));if(!r)return a(new Error("unkown hashType passed"));const c=u.keySize,f=u.ivSize,l=t.from("key expansion"),h=2*(f+c+20);i.create(r,s,(e,r)=>{if(e)return a(e);r.digest(l,(e,i)=>{if(e)return a(e);let o=[],s=0;n(()=>s{if(t)return e(t);let a=n.length;s+a>h&&(a=h-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=h/2,n=t.concat(o),i=n.slice(0,r),s=n.slice(r,h),u=e=>({iv:e.slice(0,f),cipherKey:e.slice(f,f+c),macKey:e.slice(f+c)});a(null,{k1:u(i),k2:u(s)})})})})})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(963);e.exports=((e,t)=>{n.generateEphmeralKeyPair(e,t)})},function(e,t,r){"use strict";(function(e){const n=r(265)(),i=r(264),o=r(15).bignum,s=r(476),a=s.toBase64,u=s.toBn,c={"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 o=(o,s,a)=>{let u;"function"==typeof s&&(a=s,s=void 0),u=s?n.subtle.importKey("jwk",p(t,s),{name:"ECDH",namedCurve:t},!1,["deriveBits"]):Promise.resolve(r.privateKey);const f=Promise.all([n.subtle.importKey("jwk",h(t,o),{name:"ECDH",namedCurve:t},!1,[]),u]);i(f.then(e=>n.subtle.deriveBits({name:"ECDH",namedCurve:t,public:e[0]},e[1],c[t])).then(t=>e.from(t)),a)};return n.subtle.exportKey("jwk",r.publicKey).then(e=>({key:l(e),genSharedKey:o}))}),r)};const f={"P-256":32,"P-384":48,"P-521":66};function l(t){const r=f[t.crv];return e.concat([e.from([4]),u(t.x).toArrayLike(e,"be",r),u(t.y).toArrayLike(e,"be",r)],1+2*r)}function h(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}}function p(e,t){const r=h(e,t.public);return r.d=a(new o(t.private)),r}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(17),i={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};e.exports=function(e,t,r,o,s){const a=i[s];if(!a)throw new Error(`Hash '${s}' is unknown or not supported`);const u=n.pkcs5.pbkdf2(e,t,r,o,a);return n.util.encode64(u)}},function(e,t,r){"use strict";(function(t){const n=r(39),i=r(26),o=r(966),s=r(269),a=r(20),u=r(14),c=r(58),f=new Error("Sorry, Not Implemented Yet."),l=c.proto(function(e){if(!(this instanceof l))return new l(e);if(null==e&&(e=""),e instanceof t)this.buffer=o.fromBuffer(e);else if("string"==typeof e||e instanceof String)this.buffer=o.fromString(e);else{if(!(e.buffer&&e.protos&&e.protoCodes))throw new Error("addr must be a string, Buffer, or another Multiaddr");this.buffer=o.fromBuffer(e.buffer)}},{className:"Multiaddr",symbolName:"@multiformats/js-multiaddr/multiaddr"});l.prototype.toString=function(){return o.bufferToString(this.buffer)},l.prototype.toOptions=function(){const e={},t=this.toString().split("/");return e.family="ip4"===t[1]?"ipv4":"ipv6",e.host=t[2],e.transport=t[3],e.port=t[4],e},l.prototype.inspect=function(){return""},l.prototype.protos=function(){return n(this.protoCodes(),function(e){return i(s(e))})},l.prototype.protoCodes=function(){const e=[],t=this.buffer;let r=0;for(;r{if(e[0]===s.names.ipfs.code)return!0})[0][1],u.decode(e)}catch(t){e=null}return e},l.prototype.equals=function(e){return this.buffer.equals(e.buffer)},l.prototype.nodeAddress=function(){if(!this.isThinWaistAddress())throw new Error('Multiaddr must be "thin waist" address for nodeAddress.');const e=this.protoCodes(),t=this.toString().split("/").slice(1);return{family:41===e[0]?"IPv6":"IPv4",address:t[1],port:t[3]}},l.fromNodeAddress=function(e,t){if(!e)throw new Error("requires node address object");if(!t)throw new Error("requires transport protocol");const r="IPv6"===e.family?"ip6":"ip4";return l("/"+[r,e.address,t,e.port].join("/"))},l.prototype.isThinWaistAddress=function(e){const t=(e||this).protos();return!(2!==t.length||4!==t[0].code&&41!==t[0].code||6!==t[1].code&&17!==t[1].code)},l.prototype.fromStupidString=function(e){throw f},l.protocols=s,l.isName=function(e){return!!l.isMultiaddr(e)&&e.protos().some(e=>e.resolvable)},l.resolve=function(e,t){return l.isMultiaddr(e)&&l.isName(e)?t(new Error("not implemented yet")):t(new Error("not a valid name"))},e.exports=l}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(39),i=r(136),o=r(967),s=r(269),a=r(20);function u(e){const t=[],r=e.split("/").slice(1);if(1===r.length&&""===r[0])return[];for(let n=0;n=r.length)throw v("invalid address: "+e);t.push([i,r[n]])}else t.push([i])}return t}function c(e){const t=[];return n(e,function(e){const r=_(e);t.push(r.name),e.length>1&&t.push(e[1])}),"/"+t.join("/")}function f(e){return n(e,function(e){Array.isArray(e)||(e=[e]);const t=_(e);return e.length>1?[t.code,o.toBuffer(t.code,e[1])]:[t.code]})}function l(e){return n(e,function(e){const t=_(e);return e.length>1?[t.code,o.toString(t.code,e[1])]:[t.code]})}function h(e){return g(t.concat(n(e,function(e){const r=_(e);let n=t.from(a.encode(r.code));return e.length>1&&(n=t.concat([n,e[1]])),n})))}function p(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;return a.decode(t)+a.decode.bytes}function d(e){const t=[];let r=0;for(;re.length)throw v("Invalid address buffer: "+e.toString("hex"));t.push([n,u])}return t}function y(e){return h(f(u(e=b(e))))}function g(e){const r=m(e);if(r)throw r;return t.from(e)}function m(e){try{d(e)}catch(e){return e}}function b(e){return"/"+i(e.trim().split("/")).join("/")}function v(e){return new Error("Error parsing address: "+e)}function _(e){return s(e[0])}e.exports={stringToStringTuples:u,stringTuplesToString:c,tuplesToStringTuples:l,stringTuplesToTuples:f,bufferToTuples:d,tuplesToBuffer:h,bufferToString:function(e){return c(l(d(e)))},stringToBuffer:y,fromString:function(e){return y(e)},fromBuffer:g,validateBuffer:m,isValidBuffer:function(e){return void 0===m(e)},cleanPath:b,ParseError:v,protoFromTuple:_,sizeForAddr:p}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(137),i=r(138),o=r(269),s=r(14),a=r(20);function u(e,r){return r instanceof t?u.toString(e,r):u.toBuffer(e,r)}function c(e){if(!e.isValid())throw new Error("invalid ip address");return n.toBuffer(e.address)}e.exports=u,u.toString=function(e,t){switch((e=o(e)).code){case 4:case 41:return n.toString(t);case 6:case 17:case 33:case 132:return function(e){return e.readUInt16BE(0)}(t);case 54:case 55:case 56:return function(e){const t=a.decode(e);if((e=e.slice(a.decode.bytes)).length!==t)throw new Error("inconsistent lengths");return e.toString()}(t);case 421:return function(e){const t=a.decode(e),r=e.slice(a.decode.bytes);if(r.length!==t)throw new Error("inconsistent lengths");return s.encode(r)}(t);default:return t.toString("hex")}},u.toBuffer=function(e,r){switch((e=o(e)).code){case 4:return c(new i.Address4(r));case 41:return c(new i.Address6(r));case 6:case 17:case 33:case 132:return function(e){const r=t.alloc(2);return r.writeUInt16BE(e,0),r}(parseInt(r,10));case 54:case 55:case 56:return function(e){const r=t.from(e),n=t.from(a.encode(r.length));return t.concat([n,r])}(r);case 421:return function(e){const r=t.from(s.decode(e)),n=t.from(a.encode(r.length));return t.concat([n,r])}(r);default:return t.from(r,"hex")}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";var n=r(480).BigInteger,i=r(484),o=r(969),s=r(970),a=r(482),u=r(483),c=r(139).sprintf,f=r(267),l=r(268),h=r(479);function p(e){return(e=e.replace(/^(0{1,})([1-9]+)$/,'$1$2')).replace(/^(0{1,})(0)$/,'$1$2')}function d(e,t){this.groups=void 0===t?l.GROUPS:t,this.v4=!1,this.subnet="/128",this.subnetMask=128,this.zone="",this.address=e;var r=l.RE_SUBNET_STRING.exec(e);if(r){if(this.parsedSubnet=r[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet="/"+this.subnetMask,isNaN(this.subnetMask)||this.subnetMask<0||this.subnetMask>l.BITS)return this.valid=!1,void(this.error="Invalid subnet mask.");e=e.replace(l.RE_SUBNET_STRING,"")}else if(/\//.test(e))return this.valid=!1,void(this.error="Invalid subnet mask.");var n=l.RE_ZONE_STRING.exec(e);n&&(this.zone=n[0],e=e.replace(l.RE_ZONE_STRING,"")),this.addressMinusSuffix=e,this.parsedAddress=this.parse(this.addressMinusSuffix)}function y(e){return c("%04x",parseInt(e,16))}function g(e){return 255&e}s(d.prototype,r(971)),s(d.prototype,r(972)),s(d.prototype,r(973)),d.fromBigInteger=function(e){var t,r=a(e.toString(16),32,"0"),n=[];for(t=0;t65536)&&(r=null):r=null,{address:new d(t),port:r}},d.fromAddress4=function(e){e=new h(e);var t=l.BITS-(f.BITS-e.subnetMask);return new d("::ffff:"+e.correctForm()+"/"+t)},d.fromArpa=function(e){var t=e.replace(/(\.ip6\.arpa)?\.$/,"");if(63!==t.length)return{error:"Not Valid 'ip6.arpa' form",address:null};t=t.split(".").reverse();for(var r=7;r>0;r--){var n=4*r;t.splice(n,0,":")}return new d(t=t.join(""))},d.prototype.microsoftTranscription=function(){return c("%s.ipv6-literal.net",this.correctForm().replace(/:/g,"-"))},d.prototype.mask=function(e){return void 0===e&&(e=this.subnetMask),this.getBitsBase2(0,e)},d.prototype.possibleSubnets=function(e){void 0===e&&(e=128);var t=l.BITS-this.subnetMask-Math.abs(e-l.BITS);return t<0?"0":function(e){for(var t=/(\d+)(\d{3})/;t.test(e);)e=e.replace(t,"$1,$2");return e}(new n("2",10).pow(t).toString(10))},d.prototype.startAddress=function(){var e=new n(this.mask()+u(0,l.BITS-this.subnetMask),2);return d.fromBigInteger(e)},d.prototype.endAddress=function(){var e=new n(this.mask()+u(1,l.BITS-this.subnetMask),2);return d.fromBigInteger(e)},d.prototype.getScope=function(){var e=l.SCOPES[this.getBits(12,16)];return"Global unicast"===this.getType()&&"Link local"!==e&&(e="Global"),e},d.prototype.getType=function(){var e=this;return i(l.TYPES,function(t,r){return e.isInSubnet(new d(r))})||"Global unicast"},d.prototype.getBits=function(e,t){return new n(this.getBitsBase2(e,t),2)},d.prototype.getBitsBase2=function(e,t){return this.binaryZeroPad().slice(e,t)},d.prototype.getBitsBase16=function(e,t){var r=t-e;return r%4!=0?null:a(this.getBits(e,t).toString(16),r/4,"0")},d.prototype.getBitsPastSubnet=function(){return this.getBitsBase2(this.subnetMask,l.BITS)},d.prototype.reverseForm=function(e){e||(e={});var t=Math.floor(this.subnetMask/4),r=this.canonicalForm().replace(/:/g,"").split("").slice(0,t).reverse().join(".");return t>0?e.omitSuffix?r:c("%s.ip6.arpa.",r):e.omitSuffix?"":"ip6.arpa."},d.prototype.correctForm=function(){if(!this.parsedAddress)return null;var e,t=[],r=0,n=[];for(e=0;e0&&(r>1&&n.push([e-r,e-1]),r=0)}r>1&&n.push([this.parsedAddress.length-r,this.parsedAddress.length-1]);var s=n.map(function(e){return e[1]-e[0]+1});if(n.length>0){var a=s.indexOf(o(s));t=function(e,t){var r,n=[],i=[];for(r=0;rt[1]&&i.push(e[r]);return n.concat(["compact"]).concat(i)}(this.parsedAddress,n[a])}else t=this.parsedAddress;for(e=0;e1?"s":"",t.join("")),this.parseError=e.replace(l.RE_BAD_CHARACTERS,'$1'),null;var r=e.match(l.RE_BAD_ADDRESS);if(r)return this.valid=!1,this.error=c("Address failed regex: %s",r.join("")),this.parseError=e.replace(l.RE_BAD_ADDRESS,'$1'),null;var n=[],i=e.split("::");if(2===i.length){var o=i[0].split(":"),s=i[1].split(":");1===o.length&&""===o[0]&&(o=[]),1===s.length&&""===s[0]&&(s=[]);var a=this.groups-(o.length+s.length);if(!a)return this.valid=!1,this.error="Error parsing groups",null;this.elidedGroups=a,this.elisionBegin=o.length,this.elisionEnd=o.length+this.elidedGroups,o.forEach(function(e){n.push(e)});for(var u=0;u=0;o--)r=r.add(i.multiply(new n(e[o].toString(10),10))),i=i.multiply(t);return d.fromBigInteger(r)},e.exports=d},function(e,t){var r="[object Symbol]",n=Object.prototype.toString;function i(e,t){return e>t}function o(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&n.call(e)==r}function s(e){return e}e.exports=function(e){return e&&e.length?function(e,t,r){for(var n=-1,i=e.length;++n-1},ne.prototype.set=function(e,t){var r=this.__data__,n=ce(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},ie.prototype.clear=function(){this.size=0,this.__data__={hash:new re,map:new(Q||ne),string:new re}},ie.prototype.delete=function(e){var t=be(this,e).delete(e);return this.size-=t?1:0,t},ie.prototype.get=function(e){return be(this,e).get(e)},ie.prototype.has=function(e){return be(this,e).has(e)},ie.prototype.set=function(e,t){var r=be(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},oe.prototype.clear=function(){this.__data__=new ne,this.size=0},oe.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},oe.prototype.get=function(e){return this.__data__.get(e)},oe.prototype.has=function(e){return this.__data__.has(e)},oe.prototype.set=function(e,t){var r=this.__data__;if(r instanceof ne){var i=r.__data__;if(!Q||i.length-1&&e%1==0&&e0){if(++t>=o)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(Y?function(e,t){return Y(e,"toString",{configurable:!0,enumerable:!1,value:function(e){return function(){return e}}(t),writable:!0})}:Le);function ke(e,t){return e===t||e!=e&&t!=t}var Ee=pe(function(){return arguments}())?pe:function(e){return Pe(e)&&L.call(e,"callee")&&!G.call(e,"callee")},Ae=Array.isArray;function xe(e){return null!=e&&Be(e.length)&&!Te(e)}var Ie=J||function(){return!1};function Te(e){if(!Ce(e))return!1;var t=he(e);return t==f||t==l||t==c||t==d}function Be(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=a}function Ce(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Pe(e){return null!=e&&"object"==typeof e}var Oe=I?function(e){return function(t){return e(t)}}(I):function(e){return Pe(e)&&Be(e.length)&&!!b[he(e)]};function Re(e){return xe(e)?se(e,!0):ye(e)}var Ne=function(e){return me(function(t,r){var n=-1,i=r.length,o=i>1?r[i-1]:void 0,s=i>2?r[2]:void 0;for(o=e.length>3&&"function"==typeof o?(i--,o):void 0,s&&function(e,t,r){if(!Ce(r))return!1;var n=typeof t;return!!("number"==n?xe(r)&&_e(t,r.length):"string"==n&&t in r)&&ke(r[t],e)}(r[0],r[1],s)&&(o=i<3?void 0:o,i=1),t=Object(t);++n%2$s',e.prefix,t.call(this),e.className):o('%2$s',e.prefix,t.call(this))},t.group=function(){var e,t=this.address.match(n.RE_ADDRESS);if(t){var r=t[0].split(".");this.address=this.address.replace(n.RE_ADDRESS,o('%s.%s',r.slice(0,2).join("."),r.slice(2,4).join(".")))}if(0===this.elidedGroups)return i.simpleGroup(this.address);var s=[],a=this.address.split("::");a[0].length?s.push(i.simpleGroup(a[0])):s.push("");var u=["hover-group"];for(e=this.elisionBegin;e',u.join(" "))),a[1].length?s.push(i.simpleGroup(a[1],this.elisionEnd)):s.push(""),s.join(":")}},function(e,t,r){"use strict";var n=r(139).sprintf,i=r(268);function o(e){return n("(%s)",e.join("|"))}function s(e){return e.length<4?n("0{0,%d}%s",4-e.length,e):e}function a(e){var t=[];e.forEach(function(e,r){0===parseInt(e,16)&&t.push(r)});var r=t.map(function(t){return e.map(function(e,r){if(r===t){var n=0===r||r===i.GROUPS-1?":":"";return o([s(e),n])}return s(e)}).join(":")});return r.push(e.map(s).join(":")),o(r)}function u(e,t,r){var i=t?"":":",s=r?"":":",a=[];t||r||a.push("::"),t&&r&&a.push(""),(r&&!t||!r&&t)&&a.push(":"),a.push(n("%s(:0{1,4}){1,%d}",i,e-1)),a.push(n("(0{1,4}:){1,%d}%s",e-1,s)),a.push(n("(0{1,4}:){%d}0{1,4}",e-1));for(var u=1;u{if(t.equals(e))return this.add(e),this._observedMultiaddrs.splice(r,1),!0})||this._observedMultiaddrs.push(e)}toArray(){return this._multiaddrs.slice()}get size(){return this._multiaddrs.length}forEach(e){return this._multiaddrs.forEach(e)}filterBy(e){return"object"!=typeof e||"function"!=typeof e.matches||"function"!=typeof e.partialMatch||"function"!=typeof e.toString?[]:this._multiaddrs.filter(t=>e.matches(t))}has(e){return e=n(e),this._multiaddrs.some(t=>t.equals(e))}delete(e){e=n(e),this._multiaddrs.some((t,r)=>{if(t.equals(e))return this._multiaddrs.splice(r,1),!0})}replace(e,t){Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]),e.forEach(e=>this.delete(e)),t.forEach(e=>this.add(e))}clear(){this._multiaddrs=[]}distinct(){return i(this._multiaddrs,e=>[e.toOptions().port,e.toOptions().transport].join())}}},function(e,t,r){(function(e,r){var n=200,i="Expected a function",o="__lodash_hash_undefined__",s=1,a=2,u=1/0,c=9007199254740991,f="[object Arguments]",l="[object Array]",h="[object Boolean]",p="[object Date]",d="[object Error]",y="[object Function]",g="[object GeneratorFunction]",m="[object Map]",b="[object Number]",v="[object Object]",_="[object Promise]",w="[object RegExp]",S="[object Set]",k="[object String]",E="[object Symbol]",A="[object WeakMap]",x="[object ArrayBuffer]",I="[object DataView]",T=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,B=/^\w*$/,C=/^\./,P=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,O=/\\(\\)?/g,R=/^\[object .+?Constructor\]$/,N=/^(?:0|[1-9]\d*)$/,L={};L["[object Float32Array]"]=L["[object Float64Array]"]=L["[object Int8Array]"]=L["[object Int16Array]"]=L["[object Int32Array]"]=L["[object Uint8Array]"]=L["[object Uint8ClampedArray]"]=L["[object Uint16Array]"]=L["[object Uint32Array]"]=!0,L[f]=L[l]=L[x]=L[h]=L[I]=L[p]=L[d]=L[y]=L[m]=L[b]=L[v]=L[w]=L[S]=L[k]=L[A]=!1;var j="object"==typeof e&&e&&e.Object===Object&&e,M="object"==typeof self&&self&&self.Object===Object&&self,K=j||M||Function("return this")(),D="object"==typeof t&&t&&!t.nodeType&&t,U=D&&"object"==typeof r&&r&&!r.nodeType&&r,F=U&&U.exports===D&&j.process,q=function(){try{return F&&F.binding("util")}catch(e){}}(),H=q&&q.isTypedArray;function z(e,t){return!(!e||!e.length)&&function(e,t,r){if(t!=t)return function(e,t,r,n){for(var i=e.length,o=r+(n?1:-1);n?o--:++o-1}function V(e,t,r){for(var n=-1,i=e?e.length:0;++n-1},Te.prototype.set=function(e,t){var r=this.__data__,n=Re(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Be.prototype.clear=function(){this.__data__={hash:new Ie,map:new(de||Te),string:new Ie}},Be.prototype.delete=function(e){return ze(this,e).delete(e)},Be.prototype.get=function(e){return ze(this,e).get(e)},Be.prototype.has=function(e){return ze(this,e).has(e)},Be.prototype.set=function(e,t){return ze(this,e).set(e,t),this},Ce.prototype.add=Ce.prototype.push=function(e){return this.__data__.set(e,o),this},Ce.prototype.has=function(e){return this.__data__.has(e)},Pe.prototype.clear=function(){this.__data__=new Te},Pe.prototype.delete=function(e){return this.__data__.delete(e)},Pe.prototype.get=function(e){return this.__data__.get(e)},Pe.prototype.has=function(e){return this.__data__.has(e)},Pe.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Te){var i=r.__data__;if(!de||i.lengthc))return!1;var l=o.get(e);if(l&&o.get(t))return l==t;var h=-1,p=!0,d=i&s?new Ce:void 0;for(o.set(e,t),o.set(t,e);++h-1&&e%1==0&&e-1&&e%1==0&&e<=c}function at(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function ut(e){return!!e&&"object"==typeof e}function ct(e){return"symbol"==typeof e||ut(e)&&se.call(e)==E}var ft=H?function(e){return function(t){return e(t)}}(H):function(e){return ut(e)&&st(e.length)&&!!L[se.call(e)]};function lt(e){return it(e)?Oe(e):De(e)}function ht(e){return e}r.exports=function(e,t){return e&&e.length?function(e,t,r){var i=-1,o=z,s=e.length,a=!0,u=[],c=u;if(r)a=!1,o=V;else if(s>=n){var f=t?null:Fe(e);if(f)return X(f);a=!1,o=$,c=new Ce}else c=t?[]:u;e:for(;++i=r.length)throw v("invalid address: "+e);t.push([i,r[n]])}else t.push([i])}return t}function c(e){const t=[];return n(e,function(e){const r=_(e);t.push(r.name),e.length>1&&t.push(e[1])}),"/"+t.join("/")}function f(e){return n(e,function(e){Array.isArray(e)||(e=[e]);const t=_(e);return e.length>1?[t.code,o.toBuffer(t.code,e[1])]:[t.code]})}function l(e){return n(e,function(e){const t=_(e);return e.length>1?[t.code,o.toString(t.code,e[1])]:[t.code]})}function h(e){return g(t.concat(n(e,function(e){const r=_(e);let n=t.from(a.encode(r.code));return e.length>1&&(n=t.concat([n,e[1]])),n})))}function p(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;return a.decode(t)+a.decode.bytes}function d(e){const t=[];let r=0;for(;re.length)throw v("Invalid address buffer: "+e.toString("hex"));t.push([n,u])}return t}function y(e){return h(f(u(e=b(e))))}function g(e){const r=m(e);if(r)throw r;return t.from(e)}function m(e){try{d(e)}catch(e){return e}}function b(e){return"/"+i(e.trim().split("/")).join("/")}function v(e){return new Error("Error parsing address: "+e)}function _(e){return s(e[0])}e.exports={stringToStringTuples:u,stringTuplesToString:c,tuplesToStringTuples:l,stringTuplesToTuples:f,bufferToTuples:d,tuplesToBuffer:h,bufferToString:function(e){return c(l(d(e)))},stringToBuffer:y,fromString:function(e){return y(e)},fromBuffer:g,validateBuffer:m,isValidBuffer:function(e){return void 0===m(e)},cleanPath:b,ParseError:v,protoFromTuple:_,sizeForAddr:p}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(137),i=r(138),o=r(270),s=r(14),a=r(20);function u(e,r){return r instanceof t?u.toString(e,r):u.toBuffer(e,r)}function c(e){if(!e.isValid())throw new Error("invalid ip address");return n.toBuffer(e.address)}e.exports=u,u.toString=function(e,t){switch((e=o(e)).code){case 4:case 41:return n.toString(t);case 6:case 17:case 33:case 132:return function(e){return e.readUInt16BE(0)}(t);case 54:case 55:case 56:return function(e){const t=a.decode(e);if((e=e.slice(a.decode.bytes)).length!==t)throw new Error("inconsistent lengths");return e.toString()}(t);case 421:return function(e){const t=a.decode(e),r=e.slice(a.decode.bytes);if(r.length!==t)throw new Error("inconsistent lengths");return s.encode(r)}(t);default:return t.toString("hex")}},u.toBuffer=function(e,r){switch((e=o(e)).code){case 4:return c(new i.Address4(r));case 41:return c(new i.Address6(r));case 6:case 17:case 33:case 132:return function(e){const r=t.alloc(2);return r.writeUInt16BE(e,0),r}(parseInt(r,10));case 54:case 55:case 56:return function(e){const r=t.from(e),n=t.from(a.encode(r.length));return t.concat([n,r])}(r);case 421:return function(e){const r=t.from(s.decode(e)),n=t.from(a.encode(r.length));return t.concat([n,r])}(r);default:return t.from(r,"hex")}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(n){const i=r(12),o=r(979),s=r(16),a=r(5);class u{constructor(e,t,r){s(n.isBuffer(e),"invalid id provided"),t&&r&&s(t.public.bytes.equals(r.bytes),"inconsistent arguments"),this._id=e,this._idB58String=i.toB58String(this.id),this._privKey=t,this._pubKey=r}get id(){return this._id}set id(e){throw new Error("Id is immutable")}get privKey(){return this._privKey}set privKey(e){this._privKey=e}get pubKey(){return this._pubKey?this._pubKey:this._privKey?this._privKey.public:void 0}set pubKey(e){this._pubKey=e}marshalPubKey(){if(this.pubKey)return o.keys.marshalPublicKey(this.pubKey)}marshalPrivKey(){if(this.privKey)return o.keys.marshalPrivateKey(this.privKey)}toPrint(){return this.toJSON()}toJSON(){return{id:this.toB58String(),privKey:c(this.marshalPrivKey()),pubKey:c(this.marshalPubKey())}}toHexString(){return i.toHexString(this.id)}toBytes(){return this.id}toB58String(){return this._idB58String}isEqual(e){if(n.isBuffer(e))return this.id.equals(e);if(e.id)return this.id.equals(e.id);throw new Error("not valid Id")}isValid(e){this.privKey&&this.privKey.public&&this.privKey.public.bytes&&n.isBuffer(this.pubKey.bytes)&&this.privKey.public.bytes.equals(this.pubKey.bytes)?e():e(new Error("Keys not match"))}}function c(e){if(e)return e.toString("base64")}(t=e.exports=u).create=function(e,t){"function"==typeof e&&(t=e,e={}),(e=e||{}).bits=e.bits||2048,a([t=>o.keys.generateKeyPair("RSA",e.bits,t),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n))})},t.createFromHexString=function(e){return new u(i.fromHexString(e))},t.createFromBytes=function(e){return new u(e)},t.createFromB58String=function(e){return new u(i.fromB58String(e))},t.createFromPubKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r;try{let i=e;if("string"==typeof i&&(i=n.from(e,"base64")),!n.isBuffer(i))throw new Error("Supplied key is neither a base64 string nor a buffer");r=o.keys.unmarshalPublicKey(i)}catch(e){return t(e)}r.hash((e,n)=>{if(e)return t(e);t(null,new u(n,null,r))})},t.createFromPrivKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r=e;try{if("string"==typeof r&&(r=n.from(e,"base64")),!n.isBuffer(r))throw new Error("Supplied key is neither a base64 string nor a buffer")}catch(e){return t(e)}a([e=>o.keys.unmarshalPrivateKey(r,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n,n.public))})},t.createFromJSON=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r,s,c,f;try{r=i.fromB58String(e.id),s=e.privKey&&n.from(e.privKey,"base64"),c=e.pubKey&&n.from(e.pubKey,"base64"),f=c&&o.keys.unmarshalPublicKey(c)}catch(e){return t(e)}s?a([e=>o.keys.unmarshalPrivateKey(s,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)}),(e,t,r)=>{f?f.hash((n,i)=>{r(n,e,t,i)}):r(null,e,t)}],(e,n,i,o)=>e?t(e):f&&!n.equals(o)?t(new Error("Public and private key do not match")):r&&!n.equals(r)?t(new Error("Id and private key do not match")):void t(null,new u(r,i,f))):t(null,new u(r,null,f))},t.isPeerId=function(e){return Boolean("object"==typeof e&&e._id&&e._idB58String)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(488),i=r(981),o=r(983);(t=e.exports).aes=i,t.hmac=n,t.keys=o,t.randomBytes=r(493),t.pbkdf2=r(994)},function(e,t,r){"use strict";e.exports={SHA1:20,SHA256:32,SHA512:64}},function(e,t,r){"use strict";const n=r(982),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(66);e.exports={createCipheriv:n.createCipheriv,createDecipheriv:n.createDecipheriv}},function(e,t,r){"use strict";(function(n){const i=r(11)(r(273)),o=r(17);t=e.exports;const s={rsa:r(984),ed25519:r(989),secp256k1:r(69)(i,r(493))};function a(e){return void 0!==s[e.toLowerCase()]}t.supportedKeys=s,t.keysPBM=i,t.keyStretcher=r(991),t.generateEphemeralKeyPair=r(992),t.generateKeyPair=((e,t,r)=>{let 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)=>{let 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){"use strict";const n=r(489),i=r(11),o=r(14),s=r(491),a=i(r(273)),u=r(17),c=r(3);class f{constructor(e){this._key=e}verify(e,t,r){h(r),s.hashAndVerify(this._key,t,e,r)}marshal(){return s.utils.jwkToPkix(this._key)}get bytes(){return a.PublicKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}encrypt(e){return this._key.encrypt(e,"RSAES-PKCS1-V1_5")}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(e),n(this.bytes,"sha2-256",e)}}class l{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return s.getRandomValues(new Uint8Array(16))}sign(e,t){h(t),s.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){s.decrypt(this._key,e,t)}marshal(){return s.utils.jwkToPkcs1(this._key)}get bytes(){return a.PrivateKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(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"),h(r),c(()=>{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 h(e){if("function"!=typeof e)throw new Error("callback is required")}e.exports={RsaPublicKey:f,RsaPrivateKey:l,unmarshalRsaPublicKey:function(e){const t=s.utils.pkixToJwk(e);return new f(t)},unmarshalRsaPrivateKey:function(e,t){const r=s.utils.pkcs1ToJwk(e);s.unmarshalPrivateKey(r,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},generateKeyPair:function(e,t){s.generateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},fromJwk:function(e,t){s.unmarshalPrivateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})}}},function(e,t,r){"use strict";(function(t){const n=r(42),i=r(43),o=r(490),s=r(986),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,256)),shake256:a(u(n.shake_256,512)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(987),dblSha2256:(e,r)=>{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(44),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;function o(e){if(!i)throw new Error("Please use a browser with webcrypto support");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(45),i=r(490).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(15),i=r(492),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())}),u=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()))}),c=n.define("RSAPublicKey",function(){this.seq().obj(this.key("algorithm").use(u),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=c.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 c.encode({algorithm:{algorithm:"rsa",none:null},subjectPublicKey:{data:f.encode({modulus:s(e.n),publicExponent:s(e.e)},"der")}},"der")}},function(e,t,r){"use strict";(function(t){const n=r(489),i=r(11),o=r(14),s=r(990),a=i(r(273));class u{constructor(e){this._key=l(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 c{constructor(e,t){this._key=l(e,s.privateKeyLength),this._publicKey=l(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 u(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 l(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:u,Ed25519PrivateKey:c,unmarshalEd25519PrivateKey:function(e,t){try{e=l(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 c(r,n))},unmarshalEd25519PublicKey:function(e){return e=l(e,s.publicKeyLength),new u(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 c(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 c(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(68),i=r(3);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){"use strict";(function(t){const n=r(40),i=r(488),o={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,cipherKeySize:32}};e.exports=((e,r,s,a)=>{const u=o[e];if(!u)return a(new Error("unkown cipherType passed"));if(!r)return a(new Error("unkown hashType passed"));const c=u.keySize,f=u.ivSize,l=t.from("key expansion"),h=2*(f+c+20);i.create(r,s,(e,r)=>{if(e)return a(e);r.digest(l,(e,i)=>{if(e)return a(e);let o=[],s=0;n(()=>s{if(t)return e(t);let a=n.length;s+a>h&&(a=h-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=h/2,n=t.concat(o),i=n.slice(0,r),s=n.slice(r,h),u=e=>({iv:e.slice(0,f),cipherKey:e.slice(f,f+c),macKey:e.slice(f+c)});a(null,{k1:u(i),k2:u(s)})})})})})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(993);e.exports=((e,t)=>{n.generateEphmeralKeyPair(e,t)})},function(e,t,r){"use strict";(function(e){const n=r(272)(),i=r(271),o=r(15).bignum,s=r(492),a=s.toBase64,u=s.toBn,c={"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 o=(o,s,a)=>{let u;"function"==typeof s&&(a=s,s=void 0),u=s?n.subtle.importKey("jwk",p(t,s),{name:"ECDH",namedCurve:t},!1,["deriveBits"]):Promise.resolve(r.privateKey);const f=Promise.all([n.subtle.importKey("jwk",h(t,o),{name:"ECDH",namedCurve:t},!1,[]),u]);i(f.then(e=>n.subtle.deriveBits({name:"ECDH",namedCurve:t,public:e[0]},e[1],c[t])).then(t=>e.from(t)),a)};return n.subtle.exportKey("jwk",r.publicKey).then(e=>({key:l(e),genSharedKey:o}))}),r)};const f={"P-256":32,"P-384":48,"P-521":66};function l(t){const r=f[t.crv];return e.concat([e.from([4]),u(t.x).toArrayLike(e,"be",r),u(t.y).toArrayLike(e,"be",r)],1+2*r)}function h(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}}function p(e,t){const r=h(e,t.public);return r.d=a(new o(t.private)),r}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(17),i={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};e.exports=function(e,t,r,o,s){const a=i[s];if(!a)throw new Error(`Hash '${s}' is unknown or not supported`);const u=n.pkcs5.pbkdf2(e,t,r,o,a);return n.util.encode64(u)}},function(e,t,r){"use strict";const n=r(494).extend(r(996)),i=n.object().keys({repo:n.alternatives().try(n.object(),n.string()).allow(null),repoOwner:n.boolean().default(!0),preload:n.object().keys({enabled:n.boolean().default(!0),addresses:n.array().items(n.multiaddr().options({convert:!1}))}).allow(null),init:n.alternatives().try(n.boolean(),n.object().keys({bits:n.number().integer()})).allow(null),start:n.boolean(),pass:n.string().allow(""),relay:n.object().keys({enabled:n.boolean(),hop:n.object().keys({enabled:n.boolean(),active:n.boolean()}).allow(null)}).allow(null),EXPERIMENTAL:n.object().keys({pubsub:n.boolean(),sharding:n.boolean(),dht:n.boolean()}).allow(null),connectionManager:n.object().allow(null),config:n.object().keys({Addresses:n.object().keys({Swarm:n.array().items(n.multiaddr().options({convert:!1})),API:n.multiaddr().options({convert:!1}),Gateway:n.multiaddr().options({convert:!1})}).allow(null),Discovery:n.object().keys({MDNS:n.object().keys({Enabled:n.boolean(),Interval:n.number().integer()}).allow(null),webRTCStar:n.object().keys({Enabled:n.boolean()}).allow(null)}).allow(null),Bootstrap:n.array().items(n.multiaddr().IPFS().options({convert:!1}))}).allow(null),libp2p:n.object().keys({modules:n.object().allow(null)}).allow(null)}).options({allowUnknown:!0});e.exports.validate=(e=>n.attempt(e,i))},function(e,t,r){const n=r(997),i=r(78);e.exports={name:"multiaddr",language:{invalid:"{{message}}",fmt:"must be in {{fmt}} format"},pre(e,t,r){if(null==e)return this.createError("multiaddr.invalid",{v:e,message:"addr must be a string, Buffer, or another Multiaddr"},t,r);let i;try{i=n(e)}catch(n){return this.createError("multiaddr.invalid",{v:e,message:n.message},t,r)}return r.convert?i:e},rules:Object.keys(i).map(e=>({name:e,validate(t,r,n,o){return i[e].matches(r)?r:this.createError("multiaddr.fmt",{v:r,fmt:e},n,o)}}))}},function(e,t,r){"use strict";(function(t){const n=r(39),i=r(26),o=r(998),s=r(275),a=r(20),u=r(14),c=r(58),f=new Error("Sorry, Not Implemented Yet."),l=c.proto(function(e){if(!(this instanceof l))return new l(e);if(null==e&&(e=""),e instanceof t)this.buffer=o.fromBuffer(e);else if("string"==typeof e||e instanceof String)this.buffer=o.fromString(e);else{if(!(e.buffer&&e.protos&&e.protoCodes))throw new Error("addr must be a string, Buffer, or another Multiaddr");this.buffer=o.fromBuffer(e.buffer)}},{className:"Multiaddr",symbolName:"@multiformats/js-multiaddr/multiaddr"});l.prototype.toString=function(){return o.bufferToString(this.buffer)},l.prototype.toOptions=function(){const e={},t=this.toString().split("/");return e.family="ip4"===t[1]?"ipv4":"ipv6",e.host=t[2],e.transport=t[3],e.port=t[4],e},l.prototype.inspect=function(){return""},l.prototype.protos=function(){return n(this.protoCodes(),function(e){return i(s(e))})},l.prototype.protoCodes=function(){const e=[],t=this.buffer;let r=0;for(;r{if(e[0]===s.names.ipfs.code)return!0})[0][1],u.decode(e)}catch(t){e=null}return e},l.prototype.equals=function(e){return this.buffer.equals(e.buffer)},l.prototype.nodeAddress=function(){if(!this.isThinWaistAddress())throw new Error('Multiaddr must be "thin waist" address for nodeAddress.');const e=this.protoCodes(),t=this.toString().split("/").slice(1);return{family:41===e[0]?"IPv6":"IPv4",address:t[1],port:t[3]}},l.fromNodeAddress=function(e,t){if(!e)throw new Error("requires node address object");if(!t)throw new Error("requires transport protocol");const r="IPv6"===e.family?"ip6":"ip4";return l("/"+[r,e.address,t,e.port].join("/"))},l.prototype.isThinWaistAddress=function(e){const t=(e||this).protos();return!(2!==t.length||4!==t[0].code&&41!==t[0].code||6!==t[1].code&&17!==t[1].code)},l.prototype.fromStupidString=function(e){throw f},l.protocols=s,l.isName=function(e){return!!l.isMultiaddr(e)&&e.protos().some(e=>e.resolvable)},l.resolve=function(e,t){return l.isMultiaddr(e)&&l.isName(e)?t(new Error("not implemented yet")):t(new Error("not a valid name"))},e.exports=l}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(39),i=r(136),o=r(999),s=r(275),a=r(20);function u(e){const t=[],r=e.split("/").slice(1);if(1===r.length&&""===r[0])return[];for(let n=0;n=r.length)throw v("invalid address: "+e);t.push([i,r[n]])}else t.push([i])}return t}function c(e){const t=[];return n(e,function(e){const r=_(e);t.push(r.name),e.length>1&&t.push(e[1])}),"/"+t.join("/")}function f(e){return n(e,function(e){Array.isArray(e)||(e=[e]);const t=_(e);return e.length>1?[t.code,o.toBuffer(t.code,e[1])]:[t.code]})}function l(e){return n(e,function(e){const t=_(e);return e.length>1?[t.code,o.toString(t.code,e[1])]:[t.code]})}function h(e){return g(t.concat(n(e,function(e){const r=_(e);let n=t.from(a.encode(r.code));return e.length>1&&(n=t.concat([n,e[1]])),n})))}function p(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;return a.decode(t)+a.decode.bytes}function d(e){const t=[];let r=0;for(;re.length)throw v("Invalid address buffer: "+e.toString("hex"));t.push([n,u])}return t}function y(e){return h(f(u(e=b(e))))}function g(e){const r=m(e);if(r)throw r;return t.from(e)}function m(e){try{d(e)}catch(e){return e}}function b(e){return"/"+i(e.trim().split("/")).join("/")}function v(e){return new Error("Error parsing address: "+e)}function _(e){return s(e[0])}e.exports={stringToStringTuples:u,stringTuplesToString:c,tuplesToStringTuples:l,stringTuplesToTuples:f,bufferToTuples:d,tuplesToBuffer:h,bufferToString:function(e){return c(l(d(e)))},stringToBuffer:y,fromString:function(e){return y(e)},fromBuffer:g,validateBuffer:m,isValidBuffer:function(e){return void 0===m(e)},cleanPath:b,ParseError:v,protoFromTuple:_,sizeForAddr:p}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(137),i=r(138),o=r(275),s=r(14),a=r(20);function u(e,r){return r instanceof t?u.toString(e,r):u.toBuffer(e,r)}function c(e){if(!e.isValid())throw new Error("invalid ip address");return n.toBuffer(e.address)}e.exports=u,u.toString=function(e,t){switch((e=o(e)).code){case 4:case 41:return n.toString(t);case 6:case 17:case 33:case 132:return function(e){return e.readUInt16BE(0)}(t);case 54:case 55:case 56:return function(e){const t=a.decode(e);if((e=e.slice(a.decode.bytes)).length!==t)throw new Error("inconsistent lengths");return e.toString()}(t);case 421:return function(e){const t=a.decode(e),r=e.slice(a.decode.bytes);if(r.length!==t)throw new Error("inconsistent lengths");return s.encode(r)}(t);default:return t.toString("hex")}},u.toBuffer=function(e,r){switch((e=o(e)).code){case 4:return c(new i.Address4(r));case 41:return c(new i.Address6(r));case 6:case 17:case 33:case 132:return function(e){const r=t.alloc(2);return r.writeUInt16BE(e,0),r}(parseInt(r,10));case 54:case 55:case 56:return function(e){const r=t.from(e),n=t.from(a.encode(r.length));return t.concat([n,r])}(r);case 421:return function(e){const r=t.from(s.decode(e)),n=t.from(a.encode(r.length));return t.concat([n,r])}(r);default:return t.from(r,"hex")}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(39),i=r(26),o=r(1001),s=r(276),a=r(20),u=r(14),c=r(58),f=new Error("Sorry, Not Implemented Yet."),l=c.proto(function(e){if(!(this instanceof l))return new l(e);if(null==e&&(e=""),e instanceof t)this.buffer=o.fromBuffer(e);else if("string"==typeof e||e instanceof String)this.buffer=o.fromString(e);else{if(!(e.buffer&&e.protos&&e.protoCodes))throw new Error("addr must be a string, Buffer, or another Multiaddr");this.buffer=o.fromBuffer(e.buffer)}},{className:"Multiaddr",symbolName:"@multiformats/js-multiaddr/multiaddr"});l.prototype.toString=function(){return o.bufferToString(this.buffer)},l.prototype.toOptions=function(){const e={},t=this.toString().split("/");return e.family="ip4"===t[1]?"ipv4":"ipv6",e.host=t[2],e.transport=t[3],e.port=t[4],e},l.prototype.inspect=function(){return""},l.prototype.protos=function(){return n(this.protoCodes(),function(e){return i(s(e))})},l.prototype.protoCodes=function(){const e=[],t=this.buffer;let r=0;for(;r{if(e[0]===s.names.ipfs.code)return!0})[0][1],u.decode(e)}catch(t){e=null}return e},l.prototype.equals=function(e){return this.buffer.equals(e.buffer)},l.prototype.nodeAddress=function(){if(!this.isThinWaistAddress())throw new Error('Multiaddr must be "thin waist" address for nodeAddress.');const e=this.protoCodes(),t=this.toString().split("/").slice(1);return{family:41===e[0]?"IPv6":"IPv4",address:t[1],port:t[3]}},l.fromNodeAddress=function(e,t){if(!e)throw new Error("requires node address object");if(!t)throw new Error("requires transport protocol");const r="IPv6"===e.family?"ip6":"ip4";return l("/"+[r,e.address,t,e.port].join("/"))},l.prototype.isThinWaistAddress=function(e){const t=(e||this).protos();return!(2!==t.length||4!==t[0].code&&41!==t[0].code||6!==t[1].code&&17!==t[1].code)},l.prototype.fromStupidString=function(e){throw f},l.protocols=s,l.isName=function(e){return!!l.isMultiaddr(e)&&e.protos().some(e=>e.resolvable)},l.resolve=function(e,t){return l.isMultiaddr(e)&&l.isName(e)?t(new Error("not implemented yet")):t(new Error("not a valid name"))},e.exports=l}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(39),i=r(136),o=r(1002),s=r(276),a=r(20);function u(e){const t=[],r=e.split("/").slice(1);if(1===r.length&&""===r[0])return[];for(let n=0;n=r.length)throw v("invalid address: "+e);t.push([i,r[n]])}else t.push([i])}return t}function c(e){const t=[];return n(e,function(e){const r=_(e);t.push(r.name),e.length>1&&t.push(e[1])}),"/"+t.join("/")}function f(e){return n(e,function(e){Array.isArray(e)||(e=[e]);const t=_(e);return e.length>1?[t.code,o.toBuffer(t.code,e[1])]:[t.code]})}function l(e){return n(e,function(e){const t=_(e);return e.length>1?[t.code,o.toString(t.code,e[1])]:[t.code]})}function h(e){return g(t.concat(n(e,function(e){const r=_(e);let n=t.from(a.encode(r.code));return e.length>1&&(n=t.concat([n,e[1]])),n})))}function p(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;return a.decode(t)+a.decode.bytes}function d(e){const t=[];let r=0;for(;re.length)throw v("Invalid address buffer: "+e.toString("hex"));t.push([n,u])}return t}function y(e){return h(f(u(e=b(e))))}function g(e){const r=m(e);if(r)throw r;return t.from(e)}function m(e){try{d(e)}catch(e){return e}}function b(e){return"/"+i(e.trim().split("/")).join("/")}function v(e){return new Error("Error parsing address: "+e)}function _(e){return s(e[0])}e.exports={stringToStringTuples:u,stringTuplesToString:c,tuplesToStringTuples:l,stringTuplesToTuples:f,bufferToTuples:d,tuplesToBuffer:h,bufferToString:function(e){return c(l(d(e)))},stringToBuffer:y,fromString:function(e){return y(e)},fromBuffer:g,validateBuffer:m,isValidBuffer:function(e){return void 0===m(e)},cleanPath:b,ParseError:v,protoFromTuple:_,sizeForAddr:p}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(137),i=r(138),o=r(276),s=r(14),a=r(20);function u(e,r){return r instanceof t?u.toString(e,r):u.toBuffer(e,r)}function c(e){if(!e.isValid())throw new Error("invalid ip address");return n.toBuffer(e.address)}e.exports=u,u.toString=function(e,t){switch((e=o(e)).code){case 4:case 41:return n.toString(t);case 6:case 17:case 33:case 132:return function(e){return e.readUInt16BE(0)}(t);case 54:case 55:case 56:return function(e){const t=a.decode(e);if((e=e.slice(a.decode.bytes)).length!==t)throw new Error("inconsistent lengths");return e.toString()}(t);case 421:return function(e){const t=a.decode(e),r=e.slice(a.decode.bytes);if(r.length!==t)throw new Error("inconsistent lengths");return s.encode(r)}(t);default:return t.toString("hex")}},u.toBuffer=function(e,r){switch((e=o(e)).code){case 4:return c(new i.Address4(r));case 41:return c(new i.Address6(r));case 6:case 17:case 33:case 132:return function(e){const r=t.alloc(2);return r.writeUInt16BE(e,0),r}(parseInt(r,10));case 54:case 55:case 56:return function(e){const r=t.from(e),n=t.from(a.encode(r.length));return t.concat([n,r])}(r);case 421:return function(e){const r=t.from(s.decode(e)),n=t.from(a.encode(r.length));return t.concat([n,r])}(r);default:return t.from(r,"hex")}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(5),i=r(155).errors;function o(e){return!(!e||e.code!==i.ERR_REPO_NOT_INITIALIZED&&!(e.message.match(/not found/)||e.message.match(/ENOENT/)||e.message.match(/No value/)))}e.exports=(e=>{e.log("booting");const t=e._options,r=t.init,i=t.start;n([t=>{if(!e._repo.closed)return t(null,!0);e._repo.open((e,r)=>o(e)?t(null,!1):e?t(e):void t(null,!0))},(n,i)=>{if(n)return e.init({repo:e._repo},e=>{if(e)return i(Object.assign(e,{emitted:!0}));i()});if(r){const r=Object.assign({bits:2048,pass:e._options.pass},"object"==typeof t.init?t.init:{});return e.init(r,e=>{if(e)return i(Object.assign(e,{emitted:!0}));i()})}i()},t=>{if(!i)return t();e.start(e=>{if(e)return t(Object.assign(e,{emitted:!0}));t()})}],t=>{t?t.emitted||e.emit("error",t):(e.log("booted"),e.emit("ready"))})})},function(e,t,r){"use strict";t.preStart=r(1005),t.start=r(1031),t.stop=r(1054),t.isOnline=r(1055),t.version=r(1056),t.id=r(1057),t.repo=r(507),t.init=r(1058),t.bootstrap=r(1060),t.config=r(1061),t.block=r(1062),t.object=r(1063),t.dag=r(1065),t.libp2p=r(1070),t.swarm=r(1352),t.ping=r(1355),t.pingPullStream=r(1356),t.pingReadableStream=r(1357),t.pin=r(1358),t.files=r(1362),t.bitswap=r(589),t.pubsub=r(1394),t.dht=r(1395),t.dns=r(1398),t.key=r(1400),t.stats=r(1401),t.mfs=r(1403)},function(e,t,r){"use strict";const n=r(98),i=r(51),o=r(52),s=r(5),a=r(495),u=r(274),c=r(1030);e.exports=function(e){return t=>{e.log("pre-start");const r=e._options.pass;s([t=>e._repo.config.get(t),(t,r)=>{if(!e._options.config)return r(null,t);u(t,e._options.config),e.config.replace(t,e=>{if(e)return r(e);r(null,t)})},(t,r)=>{if(t.Keychain)return r(null,t);t.Keychain=a.generateOptions(),e.config.set("Keychain",t.Keychain,n=>{e.log("using default keychain options"),r(n,t)})},(t,n)=>{if(e._keychain);else if(r){const n=Object.assign({passPhrase:r},t.Keychain);e._keychain=new a(e._repo.keys,n),e.log("keychain constructed")}else e._keychain=new c,e.log("no keychain, use --pass");n(null,t)},(e,t)=>{const r=e.Identity.PrivKey;n.createFromPrivKey(r,(r,n)=>{t(r,e,n)})},(t,n,i)=>{if(!r)return i(null,t,n);e._keychain.findKeyByName("self",r=>{if(r)return e.log('Creating "self" key'),e._keychain.importPeer("self",n,e=>i(e,t,n));i(null,t,n)})},(t,r,n)=>{e.log("peer created"),e._peerInfo=new i(r),t.Addresses&&t.Addresses.Swarm&&t.Addresses.Swarm.forEach(t=>{let r=o(t);r.getPeerId()&&(r=r.encapsulate("/ipfs/"+e._peerInfo.id.toB58String())),e._peerInfo.multiaddrs.add(r)}),n()},t=>e.pin._load(t)],t)}}},function(e,t,r){"use strict";const n=r(1007),i=r(1011),o=r(1012),s=r(35),a=r(8),u=r(1028),c="/pkcs8/",f="/info/",l={minKeyLength:14,minSaltLength:16,minIterationCount:1e3},h={dek:{keyLength:64,iterationCount:1e4,salt:"you should override this value with a crypto secure random number",hash:"sha2-512"}};function p(e){return!!e&&e===n(e.trim())}function d(e,t){const r=800*Math.random()+200;"string"==typeof t&&(t=new Error(t)),setTimeout(e,r,t,null)}function y(e){return new s.Key(c+e)}function g(e){return new s.Key(f+e)}e.exports=class{constructor(e,t){if(!e)throw new Error("store is required");this.store=e;const r=i(h,t);if(!r.passPhrase||r.passPhrase.length<20)throw new Error("passPhrase must be least 20 characters");if(r.dek.keyLengthn})}get cms(){return new u(this)}static generateOptions(){const e=Object.assign({},h),t=3*Math.ceil(l.minSaltLength/3);return e.dek.salt=o.randomBytes(t).toString("base64"),e}static get options(){return h}createKey(e,t,r,n){const i=this;if(!p(e)||"self"===e)return d(n,`Invalid key name '${e}'`);const s=y(e);i.store.has(s,(a,u)=>{if(a)return d(n,a);if(u)return d(n,`Key '${e}' already exists`);switch(t.toLowerCase()){case"rsa":if(r<2048)return d(n,`Invalid RSA key size ${r}`)}o.keys.generateKeyPair(t,r,(t,r)=>{if(t)return d(n,t);r.id((t,o)=>{if(t)return d(n,t);r.export(this._(),(t,r)=>{if(t)return d(n,t);const a={name:e,id:o},u=i.store.batch();u.put(s,r),u.put(g(e),JSON.stringify(a)),u.commit(e=>{if(e)return d(n,e);n(null,a)})})})})})}listKeys(e){const t={prefix:f};a(this.store.query(t),a.collect((t,r)=>{if(t)return d(e,t);const n=r.map(e=>JSON.parse(e.value));e(null,n)}))}findKeyById(e,t){this.listKeys((r,n)=>{if(r)return d(t,r);const i=n.find(t=>t.id===e);t(null,i)})}findKeyByName(e,t){if(!p(e))return d(t,`Invalid key name '${e}'`);const r=g(e);this.store.get(r,(r,n)=>{if(r)return d(t,`Key '${e}' does not exist. ${r.message}`);t(null,JSON.parse(n.toString()))})}removeKey(e,t){const r=this;if(!p(e)||"self"===e)return d(t,`Invalid key name '${e}'`);const n=y(e);r.findKeyByName(e,(i,o)=>{if(i)return d(t,i);const s=r.store.batch();s.delete(n),s.delete(g(e)),s.commit(e=>{if(e)return d(t,e);t(null,o)})})}renameKey(e,t,r){const n=this;if(!p(e)||"self"===e)return d(r,`Invalid old key name '${e}'`);if(!p(t)||"self"===t)return d(r,`Invalid new key name '${t}'`);const i=y(e),o=y(t),s=g(e),a=g(t);this.store.get(i,(u,c)=>{if(u)return d(r,`Key '${e}' does not exist. ${u.message}`);const f=c.toString();n.store.has(o,(e,u)=>e?d(r,e):u?d(r,`Key '${t}' already exists`):void n.store.get(s,(e,u)=>{if(e)return d(r,e);const c=JSON.parse(u.toString());c.name=t;const l=n.store.batch();l.put(o,f),l.put(a,JSON.stringify(c)),l.delete(i),l.delete(s),l.commit(e=>{if(e)return d(r,e);r(null,c)})}))})}exportKey(e,t,r){if(!p(e))return d(r,`Invalid key name '${e}'`);if(!t)return d(r,"Password is required");const n=y(e);this.store.get(n,(n,i)=>{if(n)return d(r,`Key '${e}' does not exist. ${n.message}`);const s=i.toString();o.keys.import(s,this._(),(e,n)=>{if(e)return d(r,e);n.export(t,r)})})}importKey(e,t,r,n){const i=this;if(!p(e)||"self"===e)return d(n,`Invalid key name '${e}'`);if(!t)return d(n,"PEM encoded key is required");const s=y(e);i.store.has(s,(a,u)=>a?d(n,a):u?d(n,`Key '${e}' already exists`):void o.keys.import(t,r,(t,r)=>{if(t)return d(n,"Cannot read the key, most likely the password is wrong");r.id((t,o)=>{if(t)return d(n,t);r.export(this._(),(t,r)=>{if(t)return d(n,t);const a={name:e,id:o},u=i.store.batch();u.put(s,r),u.put(g(e),JSON.stringify(a)),u.commit(e=>{if(e)return d(n,e);n(null,a)})})})}))}importPeer(e,t,r){const n=this;if(!p(e))return d(r,`Invalid key name '${e}'`);if(!t||!t.privKey)return d(r,"Peer.privKey is required");const i=t.privKey,o=y(e);n.store.has(o,(t,s)=>t?d(r,t):s?d(r,`Key '${e}' already exists`):void i.id((t,s)=>{if(t)return d(r,t);i.export(this._(),(t,i)=>{if(t)return d(r,t);const a={name:e,id:s},u=n.store.batch();u.put(o,i),u.put(g(e),JSON.stringify(a)),u.commit(e=>{if(e)return d(r,e);r(null,a)})})}))}_getPrivateKey(e,t){if(!p(e))return d(t,`Invalid key name '${e}'`);this.store.get(y(e),(r,n)=>{if(r)return d(t,`Key '${e}' does not exist. ${r.message}`);t(null,n.toString())})}}},function(e,t,r){"use strict";var n=r(1008),i=/[\/\?<>\\:\*\|":]/g,o=/[\x00-\x1f\x80-\x9f]/g,s=/^\.+$/,a=/^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i,u=/[\. ]+$/;function c(e,t){var r=e.replace(i,t).replace(o,t).replace(s,t).replace(a,t).replace(u,t);return n(r,255)}e.exports=function(e,t){var r=t&&t.replacement||"",n=c(e,r);return""===r?n:c(n,"")}},function(e,t,r){"use strict";var n=r(1009),i=r(1010);e.exports=n.bind(null,i)},function(e,t,r){"use strict";function n(e){return e>=55296&&e<=56319}function i(e){return e>=56320&&e<=57343}e.exports=function(e,t,r){if("string"!=typeof t)throw new Error("Input must be string");for(var o,s,a=t.length,u=0,c=0;cr)return t.slice(0,c-s.length+1)}return t}},function(e,t,r){"use strict";function n(e){return e>=55296&&e<=56319}function i(e){return e>=56320&&e<=57343}e.exports=function(e){if("string"!=typeof e)throw new Error("Input must be string");for(var t=e.length,r=0,o=null,s=null,a=0;a=128&&o<=2047?r+=2:o>=2048&&o<=65535&&(r+=3),s=o;return r}},function(e,t,r){"use strict";var n=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===i}(e)}(e)};var i="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function o(e,t){return t&&!0===t.clone&&n(e)?u(function(e){return Array.isArray(e)?[]:{}}(e),e,t):e}function s(e,t,r){var i=e.slice();return t.forEach(function(t,s){void 0===i[s]?i[s]=o(t,r):n(t)?i[s]=u(e[s],t,r):-1===e.indexOf(t)&&i.push(o(t,r))}),i}function a(e,t,r){var i={};return n(e)&&Object.keys(e).forEach(function(t){i[t]=o(e[t],r)}),Object.keys(t).forEach(function(s){n(t[s])&&e[s]?i[s]=u(e[s],t[s],r):i[s]=o(t[s],r)}),i}function u(e,t,r){var n=Array.isArray(t);return n===Array.isArray(e)?n?((r||{arrayMerge:s}).arrayMerge||s)(e,t,r):a(e,t,r):o(t,r)}u.all=function(e,t){if(!Array.isArray(e)||e.length<2)throw new Error("first argument should be an array with at least two elements");return e.reduce(function(e,r){return u(e,r,t)})};var c=u;e.exports=c},function(e,t,r){"use strict";const n=r(496),i=r(1014),o=r(1016);(t=e.exports).aes=i,t.hmac=n,t.keys=o,t.randomBytes=r(501),t.pbkdf2=r(1027)},function(e,t,r){"use strict";e.exports={SHA1:20,SHA256:32,SHA512:64}},function(e,t,r){"use strict";const n=r(1015),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(66);e.exports={createCipheriv:n.createCipheriv,createDecipheriv:n.createDecipheriv}},function(e,t,r){"use strict";(function(n){const i=r(11)(r(279)),o=r(17);t=e.exports;const s={rsa:r(1017),ed25519:r(1022),secp256k1:r(69)(i,r(501))};function a(e){return void 0!==s[e.toLowerCase()]}t.supportedKeys=s,t.keysPBM=i,t.keyStretcher=r(1024),t.generateEphemeralKeyPair=r(1025),t.generateKeyPair=((e,t,r)=>{let 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)=>{let 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){"use strict";const n=r(497),i=r(11),o=r(14),s=r(499),a=i(r(279)),u=r(17),c=r(3);class f{constructor(e){this._key=e}verify(e,t,r){h(r),s.hashAndVerify(this._key,t,e,r)}marshal(){return s.utils.jwkToPkix(this._key)}get bytes(){return a.PublicKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}encrypt(e){return this._key.encrypt(e,"RSAES-PKCS1-V1_5")}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(e),n(this.bytes,"sha2-256",e)}}class l{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return s.getRandomValues(new Uint8Array(16))}sign(e,t){h(t),s.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){s.decrypt(this._key,e,t)}marshal(){return s.utils.jwkToPkcs1(this._key)}get bytes(){return a.PrivateKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(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"),h(r),c(()=>{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 h(e){if("function"!=typeof e)throw new Error("callback is required")}e.exports={RsaPublicKey:f,RsaPrivateKey:l,unmarshalRsaPublicKey:function(e){const t=s.utils.pkixToJwk(e);return new f(t)},unmarshalRsaPrivateKey:function(e,t){const r=s.utils.pkcs1ToJwk(e);s.unmarshalPrivateKey(r,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},generateKeyPair:function(e,t){s.generateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},fromJwk:function(e,t){s.unmarshalPrivateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})}}},function(e,t,r){"use strict";(function(t){const n=r(42),i=r(43),o=r(498),s=r(1019),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,256)),shake256:a(u(n.shake_256,512)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(1020),dblSha2256:(e,r)=>{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(44),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;function o(e){if(!i)throw new Error("Please use a browser with webcrypto support");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(45),i=r(498).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(15),i=r(500),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())}),u=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()))}),c=n.define("RSAPublicKey",function(){this.seq().obj(this.key("algorithm").use(u),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=c.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 c.encode({algorithm:{algorithm:"rsa",none:null},subjectPublicKey:{data:f.encode({modulus:s(e.n),publicExponent:s(e.e)},"der")}},"der")}},function(e,t,r){"use strict";(function(t){const n=r(497),i=r(11),o=r(14),s=r(1023),a=i(r(279));class u{constructor(e){this._key=l(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 c{constructor(e,t){this._key=l(e,s.privateKeyLength),this._publicKey=l(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 u(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 l(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:u,Ed25519PrivateKey:c,unmarshalEd25519PrivateKey:function(e,t){try{e=l(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 c(r,n))},unmarshalEd25519PublicKey:function(e){return e=l(e,s.publicKeyLength),new u(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 c(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 c(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(68),i=r(3);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){"use strict";(function(t){const n=r(40),i=r(496),o={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,cipherKeySize:32}};e.exports=((e,r,s,a)=>{const u=o[e];if(!u)return a(new Error("unkown cipherType passed"));if(!r)return a(new Error("unkown hashType passed"));const c=u.keySize,f=u.ivSize,l=t.from("key expansion"),h=2*(f+c+20);i.create(r,s,(e,r)=>{if(e)return a(e);r.digest(l,(e,i)=>{if(e)return a(e);let o=[],s=0;n(()=>s{if(t)return e(t);let a=n.length;s+a>h&&(a=h-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=h/2,n=t.concat(o),i=n.slice(0,r),s=n.slice(r,h),u=e=>({iv:e.slice(0,f),cipherKey:e.slice(f,f+c),macKey:e.slice(f+c)});a(null,{k1:u(i),k2:u(s)})})})})})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(1026);e.exports=((e,t)=>{n.generateEphmeralKeyPair(e,t)})},function(e,t,r){"use strict";(function(e){const n=r(278)(),i=r(277),o=r(15).bignum,s=r(500),a=s.toBase64,u=s.toBn,c={"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 o=(o,s,a)=>{let u;"function"==typeof s&&(a=s,s=void 0),u=s?n.subtle.importKey("jwk",p(t,s),{name:"ECDH",namedCurve:t},!1,["deriveBits"]):Promise.resolve(r.privateKey);const f=Promise.all([n.subtle.importKey("jwk",h(t,o),{name:"ECDH",namedCurve:t},!1,[]),u]);i(f.then(e=>n.subtle.deriveBits({name:"ECDH",namedCurve:t,public:e[0]},e[1],c[t])).then(t=>e.from(t)),a)};return n.subtle.exportKey("jwk",r.publicKey).then(e=>({key:l(e),genSharedKey:o}))}),r)};const f={"P-256":32,"P-384":48,"P-521":66};function l(t){const r=f[t.crv];return e.concat([e.from([4]),u(t.x).toArrayLike(e,"be",r),u(t.y).toArrayLike(e,"be",r)],1+2*r)}function h(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}}function p(e,t){const r=h(e,t.public);return r.d=a(new o(t.private)),r}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(17),i={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};e.exports=function(e,t,r,o,s){const a=i[s];if(!a)throw new Error(`Hash '${s}' is unknown or not supported`);const u=n.pkcs5.pbkdf2(e,t,r,o,a);return n.util.encode64(u)}},function(e,t,r){"use strict";(function(t){const n=r(280),i=r(17),o=r(1029);e.exports=class{constructor(e){if(!e)throw new Error("keychain is required");this.keychain=e}encrypt(e,r,s){const a=this,u=(e,t)=>n.setImmediate(()=>s(e,t));if(!t.isBuffer(r))return u(new Error("Plain data must be a Buffer"));n.series([t=>a.keychain.findKeyByName(e,t),t=>a.keychain._getPrivateKey(e,t)],(e,n)=>{if(e)return u(e);let c=n[0],f=n[1];try{const n=i.pki.decryptRsaPrivateKey(f,a.keychain._());o.certificateForKey(c,n,(e,n)=>{if(e)return s(e);const o=i.pkcs7.createEnvelopedData();o.addRecipient(n),o.content=i.util.createBuffer(r),o.encrypt();const a=i.asn1.toDer(o.toAsn1()).getBytes();u(null,t.from(a,"binary"))})}catch(e){u(e)}})}decrypt(e,r){const o=(e,t)=>n.setImmediate(()=>r(e,t));if(!t.isBuffer(e))return o(new Error("CMS data is required"));const s=this;let a;try{const t=i.util.createBuffer(e.toString("binary")),r=i.asn1.fromDer(t);a=i.pkcs7.messageFromAsn1(r)}catch(e){return o(new Error("Invalid CMS: "+e.message))}const u=a.recipients.filter(e=>e.issuer.find(e=>"O"===e.shortName&&"ipfs"===e.value)).filter(e=>e.issuer.find(e=>"CN"===e.shortName)).map(e=>({recipient:e,keyId:e.issuer.find(e=>"CN"===e.shortName).value}));n.detect(u,(e,t)=>s.keychain.findKeyById(e.keyId,(e,r)=>t(null,!e&&r)),(e,r)=>{if(e)return o(e);if(!r){const t=u.map(e=>e.keyId);return(e=new Error("Decryption needs one of the key(s): "+t.join(", "))).missingKeys=t,o(e)}n.waterfall([e=>s.keychain.findKeyById(r.keyId,e),(e,t)=>s.keychain._getPrivateKey(e.name,t)],(e,n)=>{if(e)return o(e);const u=i.pki.decryptRsaPrivateKey(n,s.keychain._());a.decrypt(r.recipient,u),o(null,t.from(a.content.getBytes(),"binary"))})})}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(17).pki;e.exports.certificateForKey=((e,t,r)=>{const i=n.setRsaPublicKey(t.n,t.e),o=n.createCertificate();o.publicKey=i,o.serialNumber="01",o.validity.notBefore=new Date,o.validity.notAfter=new Date,o.validity.notAfter.setFullYear(o.validity.notBefore.getFullYear()+10);const s=[{name:"organizationName",value:"ipfs"},{shortName:"OU",value:"keystore"},{name:"commonName",value:e.id}];return o.setSubject(s),o.setIssuer(s),o.setExtensions([{name:"basicConstraints",cA:!0},{name:"keyUsage",keyCertSign:!0,digitalSignature:!0,nonRepudiation:!0,keyEncipherment:!0,dataEncipherment:!0},{name:"extKeyUsage",serverAuth:!0,clientAuth:!0,codeSigning:!0,emailProtection:!0,timeStamping:!0},{name:"nsCertType",client:!0,server:!0,email:!0,objsign:!0,sslCA:!0,emailCA:!0,objCA:!0}]),o.sign(t),r(null,o)})},function(e,t,r){"use strict";function n(){throw new Error("Key management requires '--pass ...' option")}e.exports=class{static get options(){n()}static generateOptions(){n()}createKey(){n()}listKeys(){n()}findKeyById(){n()}findKeyByName(){n()}renameKey(){n()}removeKey(){n()}exportKey(){n()}importKey(){n()}importPeer(){n()}get cms(){n()}}},function(e,t,r){"use strict";const n=r(49),i=r(1032),o=r(3),s=r(23);e.exports=(e=>s(t=>{const r=r=>{if(r)return o(()=>e.emit("error",r)),t(r);e.state.started(),o(()=>e.emit("start")),t()};if("stopped"!==e.state.state())return r(new Error(`Not able to start from state: ${e.state.state()}`));e.log("starting"),e.state.start(),n([t=>{e._repo.closed?e._repo.open(t):t()},t=>e.libp2p.start(t),t=>{e._bitswap=new i(e._libp2pNode,e._repo.blocks,{statsEnabled:!0}),e._bitswap.start(),e._blockService.setExchange(e._bitswap),e._preload.start(),e._mfsPreload.start(t)}],r)}))},function(e,t,r){"use strict";const n=r(5),i=r(368),o=r(50),s=r(49),a=r(80),u=r(1033),c=r(1041),f=r(1045),l=r(1051),h=r(113).logger,p=r(1052),d={statsEnabled:!1,statsComputeThrottleTimeout:1e3,statsComputeThrottleMaxQueueSize:1e3},y=["blocksReceived","dataReceived","dupBlksReceived","dupDataReceived","blocksSent","dataSent","providesBufferLength","wantListLength","peerCount"];e.exports=class{constructor(e,t,r){this._libp2p=e,this._log=h(this.peerInfo.id),this._options=Object.assign({},d,r),this._stats=new p(y,{enabled:this._options.statsEnabled,computeThrottleTimeout:this._options.statsComputeThrottleTimeout,computeThrottleMaxQueueSize:this._options.statsComputeThrottleMaxQueueSize}),this.network=new c(e,this,{},this._stats),this.blockstore=t,this.engine=new f(this.peerInfo.id,t,this.network,this._stats),this.wm=new u(this.peerInfo.id,this.network,this._stats),this.notifications=new l(this.peerInfo.id)}get peerInfo(){return this._libp2p.peerInfo}_receiveMessage(e,t,r){this.engine.messageReceived(e,t,n=>{if(n&&this._log("failed to receive message",t),0===t.blocks.size)return r();const i=Array.from(t.blocks.values()),s=i.filter(e=>this.wm.wantlist.contains(e.cid)).map(e=>e.cid);this.wm.cancelWants(s),o(i,(t,r)=>this._handleReceivedBlock(e,t,r),r)})}_handleReceivedBlock(e,t,r){this._log("received block"),n([e=>this.blockstore.has(t.cid,e),(r,n)=>{if(this._updateReceiveCounters(e.toB58String(),t,r),r)return n();this._putBlock(t,n)}],r)}_updateReceiveCounters(e,t,r){this._stats.push(e,"blocksReceived",1),this._stats.push(e,"dataReceived",t.data.length),r&&(this._stats.push(e,"dupBlksReceived",1),this._stats.push(e,"dupDataReceived",t.data.length))}_receiveError(e){this._log.error("ReceiveError: %s",e.message)}_onPeerConnected(e){this.wm.connected(e)}_onPeerDisconnected(e){this.wm.disconnected(e),this.engine.peerDisconnected(e),this._stats.disconnected(e)}_putBlock(e,t){this.blockstore.put(e,r=>{if(r)return t(r);this.notifications.hasBlock(e),this.network.provide(e.cid,e=>{e&&this._log.error("Failed to provide: %s",e.message)}),this.engine.receivedBlocks([e.cid]),t()})}enableStats(){this._stats.enable()}disableStats(){this._stats.disable()}wantlistForPeer(e){return this.engine.wantlistForPeer(e)}ledgerForPeer(e){return this.engine.ledgerForPeer(e)}get(e,t){this.getMany([e],(e,r)=>{if(e)return t(e);r&&r.length>0?t(null,r[0]):t()})}getMany(e,t){let r=e.length;const i=[];let o=!1;const s=(e,t)=>{i.push(e),this.notifications.wantBlock(e,r=>{this.wm.cancelWants([e]),t(null,r)},()=>{this.wm.cancelWants([e]),t(null,void 0)}),r||this.wm.wantBlocks(i)};a(e,(t,a)=>{n([e=>this.blockstore.has(t,e),(n,a)=>{if(r--,n)return r||this.wm.wantBlocks(i),this.blockstore.get(t,a);o||(o=!0,this.network.findAndConnect(e[0],e=>{e&&this._log.error(e)})),s(t,a)}],a)},t)}unwant(e){Array.isArray(e)||(e=[e]),this.wm.unwantBlocks(e),e.forEach(e=>this.notifications.unwantBlock(e))}cancelWants(e){Array.isArray(e)||(e=[e]),this.wm.cancelWants(e)}put(e,t){this._log("putting block"),n([t=>this.blockstore.has(e.cid,t),(t,r)=>{if(t)return r();this._putBlock(e,r)}],t)}putMany(e,t){n([t=>i(e,(e,t)=>{this.blockstore.has(e.cid,t)},t),(e,t)=>this.blockstore.putMany(e,r=>{if(r)return t(r);e.forEach(e=>{this.notifications.hasBlock(e),this.engine.receivedBlocks([e.cid]),this.network.provide(e.cid,e=>{e&&this._log.error("Failed to provide: %s",e.message)})}),t()})],t)}getWantlist(){return this.wm.wantlist.entries()}peers(){return this.engine.peers()}stat(){return this._stats}start(e){s([e=>this.wm.start(e),e=>this.network.start(e),e=>this.engine.start(e)],e)}stop(e){this._stats.stop(),s([e=>this.wm.stop(e),e=>this.network.stop(e),e=>this.engine.stop(e)],e)}}},function(e,t,r){"use strict";const n=r(3),i=r(186),o=r(187),s=r(281),a=r(1040),u=r(113).logger;e.exports=class{constructor(e,t,r){this.peers=new Map,this.wantlist=new o(r),this.network=t,this._stats=r,this._peerId=e,this._log=u(e,"want")}_addEntries(e,t,r){const n=e.map((e,r)=>new i.Entry(e,s.kMaxPriority-r,t));n.forEach(e=>{e.cancel?r?this.wantlist.removeForce(e.cid):this.wantlist.remove(e.cid):(this._log("adding to wl"),this.wantlist.add(e.cid,e.priority))});for(let e of this.peers.values())e.addEntries(n)}_startPeerHandler(e){let t=this.peers.get(e.toB58String());if(t)return void t.refcnt++;t=new a(this._peerId,e,this.network);const r=new i(!0);for(let e of this.wantlist.entries())r.addEntry(e[1].cid,e[1].priority);return t.addMessage(r),this.peers.set(e.toB58String(),t),t}_stopPeerHandler(e){const t=this.peers.get(e.toB58String());t&&(t.refcnt--,t.refcnt>0||this.peers.delete(e.toB58String()))}wantBlocks(e){this._addEntries(e,!1)}unwantBlocks(e){this._log("unwant blocks: %s",e.length),this._addEntries(e,!0,!0)}cancelWants(e){this._log("cancel wants: %s",e.length),this._addEntries(e,!0)}connectedPeers(){return Array.from(this.peers.keys())}connected(e){this._startPeerHandler(e)}disconnected(e){this._stopPeerHandler(e)}start(e){this.timer=setInterval(()=>{this._log("resend full-wantlist");const e=new i(!0);this.wantlist.forEach(t=>{e.addEntry(t.cid,t.priority)}),this.peers.forEach(t=>t.addMessage(e))},6e4),n(()=>e())}stop(e){this.peers.forEach(e=>this.disconnected(e.peerId)),clearInterval(this.timer),n(()=>e())}}},function(e,t,r){(function(e,r){var n=200,i="__lodash_hash_undefined__",o=1,s=2,a=9007199254740991,u="[object Arguments]",c="[object Array]",f="[object Boolean]",l="[object Date]",h="[object Error]",p="[object Function]",d="[object GeneratorFunction]",y="[object Map]",g="[object Number]",m="[object Object]",b="[object Promise]",v="[object RegExp]",_="[object Set]",w="[object String]",S="[object Symbol]",k="[object WeakMap]",E="[object ArrayBuffer]",A="[object DataView]",x=/^\[object .+?Constructor\]$/,I=/^(?:0|[1-9]\d*)$/,T={};T["[object Float32Array]"]=T["[object Float64Array]"]=T["[object Int8Array]"]=T["[object Int16Array]"]=T["[object Int32Array]"]=T["[object Uint8Array]"]=T["[object Uint8ClampedArray]"]=T["[object Uint16Array]"]=T["[object Uint32Array]"]=!0,T[u]=T[c]=T[E]=T[f]=T[A]=T[l]=T[h]=T[p]=T[y]=T[g]=T[m]=T[v]=T[_]=T[w]=T[k]=!1;var B="object"==typeof e&&e&&e.Object===Object&&e,C="object"==typeof self&&self&&self.Object===Object&&self,P=B||C||Function("return this")(),O="object"==typeof t&&t&&!t.nodeType&&t,R=O&&"object"==typeof r&&r&&!r.nodeType&&r,N=R&&R.exports===O&&B.process,L=function(){try{return N&&N.binding("util")}catch(e){}}(),j=L&&L.isTypedArray;function M(e,t){for(var r=-1,n=e?e.length:0;++rc))return!1;var l=a.get(e);if(l&&a.get(t))return l==t;var h=-1,p=!0,d=i&o?new be:void 0;for(a.set(e,t),a.set(t,e);++h-1},ge.prototype.set=function(e,t){var r=this.__data__,n=we(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},me.prototype.clear=function(){this.__data__={hash:new ye,map:new(ne||ge),string:new ye}},me.prototype.delete=function(e){return Ie(this,e).delete(e)},me.prototype.get=function(e){return Ie(this,e).get(e)},me.prototype.has=function(e){return Ie(this,e).has(e)},me.prototype.set=function(e,t){return Ie(this,e).set(e,t),this},be.prototype.add=be.prototype.push=function(e){return this.__data__.set(e,i),this},be.prototype.has=function(e){return this.__data__.has(e)},ve.prototype.clear=function(){this.__data__=new ge},ve.prototype.delete=function(e){return this.__data__.delete(e)},ve.prototype.get=function(e){return this.__data__.get(e)},ve.prototype.has=function(e){return this.__data__.has(e)},ve.prototype.set=function(e,t){var r=this.__data__;if(r instanceof ge){var i=r.__data__;if(!ne||i.length-1&&e%1==0&&e-1&&e%1==0&&e<=a}function Me(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Ke(e){return!!e&&"object"==typeof e}var De=j?function(e){return function(t){return e(t)}}(j):function(e){return Ke(e)&&je(e.length)&&!!T[Y.call(e)]};function Ue(e){return Ne(e)?_e(e):Ee(e)}r.exports=function(e,t,r){var n=(r="function"==typeof r?r:void 0)?r(e,t):void 0;return void 0===n?Se(e,t,r):!!n}}).call(this,r(7),r(27)(e))},function(e,t,r){"use strict";(function(t){const n=r(20);e.exports=(e=>{if(!t.isBuffer(e))throw new Error("arg needs to be a buffer");let r=[];for(;e.length>0;){const t=n.decode(e);r.push(t),e=e.slice(n.decode.bytes)}return r})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";e.exports="\n message Message {\n message Wantlist {\n message Entry {\n // changed from string to bytes, it makes a difference in JavaScript\n optional bytes block = 1; // the block cid (cidV0 in bitswap 1.0.0, cidV1 in bitswap 1.1.0)\n optional int32 priority = 2; // the priority (normalized). default to 1\n optional bool cancel = 3; // whether this revokes an entry\n }\n\n repeated Entry entries = 1; // a list of wantlist entries\n optional bool full = 2; // whether this is the full wantlist. default to false\n }\n\n message Block {\n optional bytes prefix = 1; // CID prefix (cid version, multicodec and multihash prefix (type + length)\n optional bytes data = 2;\n }\n\n optional Wantlist wantlist = 1;\n repeated bytes blocks = 2; // used to send Blocks in bitswap 1.0.0\n repeated Block payload = 3; // used to send Blocks in bitswap 1.1.0\n }\n"},function(e,t,r){"use strict";const n=r(187).Entry,i=r(9),o=r(16);e.exports=class{constructor(e,t,r){o(i.isCID(e),"needs valid cid"),this.entry=new n(e,t),this.cancel=Boolean(r)}get cid(){return this.entry.cid}set cid(e){this.entry.cid=e}get priority(){return this.entry.priority}set priority(e){this.entry.priority=e}get[Symbol.toStringTag](){return`BitswapMessageEntry ${this.cid.toBaseEncodedString()} `}equals(e){return this.cancel===e.cancel&&this.entry.equals(e.entry)}}},function(e,t,r){(function(e,r){var n=200,i="Expected a function",o="__lodash_hash_undefined__",s=1,a=2,u=1/0,c=9007199254740991,f="[object Arguments]",l="[object Array]",h="[object Boolean]",p="[object Date]",d="[object Error]",y="[object Function]",g="[object GeneratorFunction]",m="[object Map]",b="[object Number]",v="[object Object]",_="[object Promise]",w="[object RegExp]",S="[object Set]",k="[object String]",E="[object Symbol]",A="[object WeakMap]",x="[object ArrayBuffer]",I="[object DataView]",T=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,B=/^\w*$/,C=/^\./,P=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,O=/\\(\\)?/g,R=/^\[object .+?Constructor\]$/,N=/^(?:0|[1-9]\d*)$/,L={};L["[object Float32Array]"]=L["[object Float64Array]"]=L["[object Int8Array]"]=L["[object Int16Array]"]=L["[object Int32Array]"]=L["[object Uint8Array]"]=L["[object Uint8ClampedArray]"]=L["[object Uint16Array]"]=L["[object Uint32Array]"]=!0,L[f]=L[l]=L[x]=L[h]=L[I]=L[p]=L[d]=L[y]=L[m]=L[b]=L[v]=L[w]=L[S]=L[k]=L[A]=!1;var j="object"==typeof e&&e&&e.Object===Object&&e,M="object"==typeof self&&self&&self.Object===Object&&self,K=j||M||Function("return this")(),D="object"==typeof t&&t&&!t.nodeType&&t,U=D&&"object"==typeof r&&r&&!r.nodeType&&r,F=U&&U.exports===D&&j.process,q=function(){try{return F&&F.binding("util")}catch(e){}}(),H=q&&q.isTypedArray;function z(e,t){for(var r=-1,n=e?e.length:0,i=Array(n);++r-1},Be.prototype.set=function(e,t){var r=this.__data__,n=Ne(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Ce.prototype.clear=function(){this.__data__={hash:new Te,map:new(ye||Be),string:new Te}},Ce.prototype.delete=function(e){return $e(this,e).delete(e)},Ce.prototype.get=function(e){return $e(this,e).get(e)},Ce.prototype.has=function(e){return $e(this,e).has(e)},Ce.prototype.set=function(e,t){return $e(this,e).set(e,t),this},Pe.prototype.add=Pe.prototype.push=function(e){return this.__data__.set(e,o),this},Pe.prototype.has=function(e){return this.__data__.has(e)},Oe.prototype.clear=function(){this.__data__=new Be},Oe.prototype.delete=function(e){return this.__data__.delete(e)},Oe.prototype.get=function(e){return this.__data__.get(e)},Oe.prototype.has=function(e){return this.__data__.has(e)},Oe.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Be){var i=r.__data__;if(!ye||i.length=a?u:u*("desc"==r[n]?-1:1)}return e.index-t.index}(e,t,r)})}function ze(e){return ft(e)?e:nt(e)}function Ve(e,t){if(e!==t){var r=void 0!==e,n=null===e,i=e==e,o=gt(e),s=void 0!==t,a=null===t,u=t==t,c=gt(t);if(!a&&!c&&!o&&e>t||o&&s&&u&&!a&&!c||n&&s&&u||!r&&u||!i)return 1;if(!n&&!o&&!c&&ec))return!1;var l=o.get(e);if(l&&o.get(t))return l==t;var h=-1,p=!0,d=i&s?new Pe:void 0;for(o.set(e,t),o.set(t,e);++h-1&&e%1==0&&e1&&Qe(e,t[0],t[1])?t=[]:r>2&&Qe(t[0],t[1],t[2])&&(t=[t[0]]),He(e,function e(t,r,n,i,o){var s=-1,a=t.length;for(n||(n=Xe),o||(o=[]);++s0&&n(u)?r>1?e(u,r-1,n,i,o):V(o,u):i||(o[o.length]=u)}return o}(t,1),[])});function at(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError(i);var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var s=e.apply(this,n);return r.cache=o.set(i,s),s};return r.cache=new(at.Cache||Ce),r}function ut(e,t){return e===t||e!=e&&t!=t}function ct(e){return function(e){return yt(e)&<(e)}(e)&&ie.call(e,"callee")&&(!ce.call(e,"callee")||oe.call(e)==f)}at.Cache=Ce;var ft=Array.isArray;function lt(e){return null!=e&&pt(e.length)&&!ht(e)}function ht(e){var t=dt(e)?oe.call(e):"";return t==y||t==g}function pt(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=c}function dt(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function yt(e){return!!e&&"object"==typeof e}function gt(e){return"symbol"==typeof e||yt(e)&&oe.call(e)==E}var mt=H?W(H):function(e){return yt(e)&&pt(e.length)&&!!L[oe.call(e)]};function bt(e){return lt(e)?Re(e):qe(e)}function vt(e){return e}r.exports=st}).call(this,r(7),r(27)(e))},function(e,t,r){"use strict";const n=r(16),i=r(9);e.exports=class{constructor(e,t){n(i.isCID(e),"must be valid CID"),this._refCounter=1,this.cid=e,this.priority=t||1}inc(){this._refCounter+=1}dec(){this._refCounter=Math.max(0,this._refCounter-1)}hasRefs(){return this._refCounter>0}get[Symbol.toStringTag](){return`WantlistEntry `}equals(e){return this._refCounter===e._refCounter&&this.cid.equals(e.cid)&&this.priority===e.priority}}},function(e,t,r){"use strict";const n=r(502),i=r(186),o=r(113).logger;e.exports=class{constructor(e,t,r){this.peerId=t,this.network=r,this.refcnt=1,this._entries=[],this._log=o(e,"msgqueue",t.toB58String().slice(0,8)),this.sendEntries=n(this._sendEntries.bind(this),200)}addMessage(e){e.empty||this.send(e)}addEntries(e){this._entries=this._entries.concat(e),this.sendEntries()}_sendEntries(){if(!this._entries.length)return;const e=new i(!1);this._entries.forEach(t=>{t.cancel?e.cancel(t.cid):e.addEntry(t.cid,t.priority)}),this._entries=[],this.addMessage(e)}send(e){this.network.connectTo(this.peerId,t=>{t?this._log.error("cant connect to peer %s: %s",this.peerId.toB58String(),t.message):(this._log("sending message"),this.network.sendMessage(this.peerId,e,e=>{e&&this._log.error("send error: %s",e.message)}))})}}},function(e,t,r){"use strict";const n=r(53),i=r(8),o=r(5),s=r(50),a=r(3),u=r(186),c=r(281),f=r(113).logger,l="/ipfs/bitswap/1.0.0",h="/ipfs/bitswap/1.1.0";function p(e,t,r){i(i.values([t]),n.encode(),e,i.onEnd(r))}e.exports=class{constructor(e,t,r,n){this._log=f(e.peerInfo.id,"network"),r=r||{},this.libp2p=e,this.bitswap=t,this.b100Only=r.b100Only||!1,this._stats=n,this._running=!1}start(e){this._running=!0,this._onPeerConnect=this._onPeerConnect.bind(this),this._onPeerDisconnect=this._onPeerDisconnect.bind(this),this._onConnection=this._onConnection.bind(this),this.libp2p.handle(l,this._onConnection),this.b100Only||this.libp2p.handle(h,this._onConnection),this.libp2p.on("peer:connect",this._onPeerConnect),this.libp2p.on("peer:disconnect",this._onPeerDisconnect),this.libp2p.peerBook.getAllArray().filter(e=>e.isConnected()).forEach(e=>this._onPeerConnect(e)),a(()=>e())}stop(e){this._running=!1,this.libp2p.unhandle(l),this.b100Only||this.libp2p.unhandle(h),this.libp2p.removeListener("peer:connect",this._onPeerConnect),this.libp2p.removeListener("peer:disconnect",this._onPeerDisconnect),a(()=>e())}_onConnection(e,t){this._running&&(this._log("incomming new bitswap connection: %s",e),i(t,n.decode(),i.asyncMap((e,t)=>u.deserialize(e,t)),i.asyncMap((e,r)=>{t.getPeerInfo((t,n)=>{if(t)return r(t);this.bitswap._receiveMessage(n.id,e,r)})}),i.onEnd(e=>{this._log("ending connection"),e&&this.bitswap._receiveError(e)})))}_onPeerConnect(e){this._running&&this.bitswap._onPeerConnected(e.id)}_onPeerDisconnect(e){this._running&&this.bitswap._onPeerDisconnected(e.id)}findProviders(e,t,r){this.libp2p.contentRouting.findProviders(e,c.providerRequestTimeout,r)}findAndConnect(e,t){o([t=>this.findProviders(e,c.maxProvidersPerRequest,t),(e,t)=>{this._log("connecting to providers",e.map(e=>e.id.toB58String())),s(e,(e,t)=>this.connectTo(e,t))}],t)}provide(e,t){this.libp2p.contentRouting.provide(e,t)}sendMessage(e,t,r){if(!this._running)return r(new Error("network isn't running"));const n=e.toB58String()?e.toB58String():e.id.toB58String();this._log("sendMessage to %s",n,t),this._dialPeer(e,(n,i,o)=>{if(n)return r(n);let s;switch(o){case l:s=t.serializeToBitswap100();break;case h:s=t.serializeToBitswap110();break;default:return r(new Error("Unkown protocol: "+o))}p(i,s,e=>{e&&this._log.error(e)}),r(),this._updateSentStats(e,t.blocks)})}connectTo(e,t){if(!this._running)return t(new Error("network isn't running"));this.libp2p.dial(e,t)}_dialPeer(e,t){this.libp2p.dialProtocol(e,h,(r,n)=>{r?this.libp2p.dialProtocol(e,l,(e,r)=>{if(e)return t(e);t(null,r,l)}):t(null,n,h)})}_updateSentStats(e,t){const r=e.toB58String();this._stats&&(t.forEach(e=>this._stats.push(r,"dataSent",e.data.length)),this._stats.push(r,"blocksSent",t.size))}}},function(e,t,r){"use strict";const n=r(2).Buffer;e.exports=function(e){e=Object.assign({fixed:!1},e||{});const t=r(20);let i=e.fixed?null:o(),s=0,a=!1;return r=>(u,c)=>{if(u&&(a=u),a)return c(a);r(null,(r,u)=>{if(r&&(a=r),a)return c(a);if(!n.isBuffer(u))return a=new Error("data must be a buffer"),c(a);let f;e.fixed?(f=n.alloc(4)).writeInt32BE(u.length,0):(t.encode(u.length,i,s),s+=t.encode.bytes,f=i.slice(s-t.encode.bytes,s),i.length-s<100&&(i=o(),s=0)),c(null,n.concat([f,u]))})}};const i=10240;function o(){return n.alloc(i)}},function(e,t,r){"use strict";const n=r(20),i=r(503),o=r(2).Buffer,s=r(46);t.decode=function(e){let t=new i,r=s(e=>{t.abort(e)});return n=>{return t(n),function n(){c(t,e,(e,t)=>{if(e)return r.end(e);r.push(t),n()})}(),r}},t.decodeFromReader=function(e,t,r){"function"==typeof t&&(r=t,t={}),c(e,t,function(e,t){if(e)return r(!0===e?new Error("Unexpected end of input from reader."):e);r(null,t)})};const a=e=>!(128&e),u=4194304;function c(e,t,r){(t=Object.assign({fixed:!1,maxLength:u},t||{})).fixed?function(e,t,r){e.read(4,(n,i)=>{if(n)return r(n);const o=i.readInt32BE(0);if(o>t)return r(new Error("size longer than max permitted length of "+t+"!"));f(e,o,r)})}(e,t.maxLength,r):function(e,t,r){let i=[];0===i.length&&function s(){e.read(1,(u,c)=>{if(u)return r(u);if(i.push(c),c&&!a(c[0]))return void s();const l=n.decode(o.concat(i));if(l>t)return r(new Error("size longer than max permitted length of "+t+"!"));f(e,l,(e,t)=>e?r(e):(i=[],t.length{if(e)return r(e);r(null,t)})}},function(e,t,r){(function(t){e.exports=function(){var e=[],r=0;return{length:r,data:this,add:function(n){if(!t.isBuffer(n))throw new Error("data must be a buffer, was: "+JSON.stringify(n));return this.length=r+=n.length,e.push(n),this},has:function(e){return null==e?r>0:r>=e},get:function(n){var i;if(null==n||n===r){r=0;var o=e;return e=[],1==o.length?o[0]:t.concat(o)}if(e.length>1&&n<=(i=e[0].length)){var s=e[0].slice(0,n);return n===i?e.shift():e[0]=e[0].slice(n,i),r-=n,s}if(ne+t.data.byteLength,0){if(s--,o.push(t),(n+=t.data.byteLength)>=b||0===s){n=0;const t=o.slice();o=[],this._sendSafeBlocks(e,t,e=>{e&&this._log("sendblock error: %s",e.message),r()})}else r()},r)}_sendSafeBlocks(e,t,r){const n=new d(!1);t.forEach(e=>n.addBlock(e)),this.network.sendMessage(e,n,r)}_processTasks(){if(!this._running||!this._tasks.length)return;const e=this._tasks;this._tasks=[];const t=e.map(e=>e.entry).map(e=>e.cid),r=c(t,(e,t)=>e.equals(t)),i=h(e,e=>e.target.toB58String());o([e=>a(r,(e,t)=>{this.blockstore.get(e,t)},e),(e,r)=>n(l(i),(r,n)=>{const i=r[0].target,o=t.map(t=>f(e,e=>e.cid.equals(t)));this._sendBlocks(i,o,e=>{e?this._log.error("should never happen: ",e):o.forEach(e=>this.messageSent(i,e)),n()})})],e=>{this._tasks=[],e&&this._log.error(e)})}wantlistForPeer(e){const t=e.toB58String();return this.ledgerMap.has(t)?this.ledgerMap.get(t).wantlist.sortedEntries():new Map}ledgerForPeer(e){const t=e.toB58String(),r=this.ledgerMap.get(t);return r?{peer:r.partner.toB58String(),value:r.debtRatio(),sent:r.accounting.bytesSent,recv:r.accounting.bytesRecv,exchanged:r.exchangeCount}:null}peers(){return Array.from(this.ledgerMap.values()).map(e=>e.partner)}receivedBlocks(e){e.length&&(this.ledgerMap.forEach(t=>{e.map(e=>t.wantlistContains(e)).filter(Boolean).forEach(e=>{this._tasks.push({entry:e,target:t.partner})})}),this._outbox())}messageReceived(e,t,r){const n=this._findOrCreate(e);if(t.empty)return r();if(t.full&&(n.wantlist=new y),this._processBlocks(t.blocks,n),0===t.wantlist.size)return r();let i=[],o=[];t.wantlist.forEach(e=>{e.cancel?(n.cancelWant(e.cid),i.push(e)):(n.wants(e.cid,e.priority),o.push(e))}),this._cancelWants(n,e,i),this._addWants(n,e,o,r)}_cancelWants(e,t,r){const n=t.toB58String();p(this._tasks,r,(e,t)=>{const r=e.target.toB58String()===n,i=e.entry.cid.equals(t.cid);return r&&i})}_addWants(e,t,r,i){n(r,(e,r)=>{this.blockstore.has(e.cid,(n,i)=>{n?this._log.error("failed existence check"):i&&this._tasks.push({entry:e.entry,target:t}),r()})},()=>{this._outbox(),i()})}_processBlocks(e,t,r){const n=[];e.forEach((e,r)=>{this._log("got block (%s bytes)",e.data.length),t.receivedBytes(e.data.length),n.push(e.cid)}),this.receivedBlocks(n)}messageSent(e,t){const r=this._findOrCreate(e);r.sentBytes(t?t.data.length:0),t&&t.cid&&r.wantlist.remove(t.cid)}numBytesSentTo(e){return this._findOrCreate(e).accounting.bytesSent}numBytesReceivedFrom(e){return this._findOrCreate(e).accounting.bytesRecv}peerDisconnected(e){}_findOrCreate(e){const t=e.toB58String();if(this.ledgerMap.has(t))return this.ledgerMap.get(t);const r=new g(e);return this.ledgerMap.set(t,r),this._stats&&this._stats.push(t,"peerCount",1),r}start(e){this._running=!0,s(()=>e())}stop(e){this._running=!1,s(()=>e())}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,s){(0,n.default)(t)(e,(0,i.default)((0,o.default)(r)),s)};var n=s(r(355)),i=s(r(361)),o=s(r(34));function s(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default},function(e,t,r){(function(t){var r=200,n="__lodash_hash_undefined__",i="[object Function]",o="[object GeneratorFunction]",s=/^\[object .+?Constructor\]$/,a="object"==typeof t&&t&&t.Object===Object&&t,u="object"==typeof self&&self&&self.Object===Object&&self,c=a||u||Function("return this")();function f(e,t){return!(!e||!e.length)&&function(e,t,r){if(t!=t)return function(e,t,r,n){for(var i=e.length,o=r+(n?1:-1);n?o--:++o-1}function l(e,t,r){for(var n=-1,i=e?e.length:0;++n-1},C.prototype.set=function(e,t){var r=this.__data__,n=R(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},P.prototype.clear=function(){this.__data__={hash:new B,map:new(x||C),string:new B}},P.prototype.delete=function(e){return j(this,e).delete(e)},P.prototype.get=function(e){return j(this,e).get(e)},P.prototype.has=function(e){return j(this,e).has(e)},P.prototype.set=function(e,t){return j(this,e).set(e,t),this},O.prototype.add=O.prototype.push=function(e){return this.__data__.set(e,n),this},O.prototype.has=function(e){return this.__data__.has(e)};var L=I&&1/d(new I([,-0]))[1]==1/0?function(e){return new I(e)}:function(){};function j(e,t){var r=e.__data__;return function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?r["string"==typeof t?"string":"hash"]:r.map}function M(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return N(r)?r:void 0}function K(e,t){return e===t||e!=e&&t!=t}function D(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}e.exports=function(e,t){return e&&e.length?function(e,t,n){var i=-1,o=f,s=e.length,a=!0,u=[],c=u;if(n)a=!1,o=l;else if(s>=r){var h=t?null:L(e);if(h)return d(h);a=!1,o=p,c=new O}else c=t?[]:u;e:for(;++i-1},Ae.prototype.set=function(e,t){var r=this.__data__,n=Ce(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},xe.prototype.clear=function(){this.__data__={hash:new Ee,map:new(le||Ae),string:new Ee}},xe.prototype.delete=function(e){return He(this,e).delete(e)},xe.prototype.get=function(e){return He(this,e).get(e)},xe.prototype.has=function(e){return He(this,e).has(e)},xe.prototype.set=function(e,t){return He(this,e).set(e,t),this},Ie.prototype.add=Ie.prototype.push=function(e){return this.__data__.set(e,o),this},Ie.prototype.has=function(e){return this.__data__.has(e)},Te.prototype.clear=function(){this.__data__=new Ae},Te.prototype.delete=function(e){return this.__data__.delete(e)},Te.prototype.get=function(e){return this.__data__.get(e)},Te.prototype.has=function(e){return this.__data__.has(e)},Te.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Ae){var i=r.__data__;if(!le||i.lengthc))return!1;var l=o.get(e);if(l&&o.get(t))return l==t;var h=-1,p=!0,d=i&s?new Ie:void 0;for(o.set(e,t),o.set(t,e);++h-1&&e%1==0&&e-1&&e%1==0&&e<=c}function at(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function ut(e){return!!e&&"object"==typeof e}function ct(e){return"symbol"==typeof e||ut(e)&&ne.call(e)==E}var ft=H?function(e){return function(t){return e(t)}}(H):function(e){return ut(e)&&st(e.length)&&!!L[ne.call(e)]};function lt(e){return it(e)?Be(e):De(e)}function ht(e){return e}r.exports=Qe}).call(this,r(7),r(27)(e))},function(e,t){function r(e,t,r){if(t!=t)return function(e,t,r,n){for(var i=e.length,o=r+(n?1:-1);n?o--:++o-1;)f!==e&&o.call(f,l,1),o.call(e,l,1);return e}e.exports=function(e,t,r){return e&&e.length&&t&&t.length?s(e,t,void 0,r):e}},function(e,t,r){"use strict";const n=r(187);e.exports=class{constructor(e){this.partner=e,this.wantlist=new n,this.exchangeCount=0,this.sentToPeer=new Map,this.accounting={bytesSent:0,bytesRecv:0}}sentBytes(e){this.exchangeCount++,this.lastExchange=(new Date).getTime(),this.accounting.bytesSent+=e}receivedBytes(e){this.exchangeCount++,this.lastExchange=(new Date).getTime(),this.accounting.bytesRecv+=e}wants(e,t){this.wantlist.add(e,t)}cancelWant(e){this.wantlist.remove(e)}wantlistContains(e){return this.wantlist.contains(e)}debtRatio(){return this.accounting.bytesSent/(this.accounting.bytesRecv+1)}}},function(e,t,r){"use strict";const n=r(10).EventEmitter,i=r(281),o=r(113).logger,s=e=>`unwant:${e}`,a=e=>`block:${e}`;e.exports=class extends n{constructor(e){super(),this.setMaxListeners(i.maxListeners),this._log=o(e,"notif"),this._unwantListeners={},this._blockListeners={}}hasBlock(e){const t=`block:${e.cid.buffer.toString()}`;this._log(t),this.emit(t,e)}wantBlock(e,t,r){const n=e.buffer.toString();this._log(`wantBlock:${n}`),this._unwantListeners[n]=(()=>{this._log(`manual unwant: ${n}`),this._cleanup(n),r()}),this._blockListeners[n]=(e=>{this._cleanup(n),t(e)}),this.once(s(n),this._unwantListeners[n]),this.once(a(n),this._blockListeners[n])}unwantBlock(e){const t=`unwant:${e.buffer.toString()}`;this._log(t),this.emit(t)}_cleanup(e){this._unwantListeners[e]&&(this.removeListener(s(e),this._unwantListeners[e]),delete this._unwantListeners[e]),this._blockListeners[e]&&(this.removeListener(a(e),this._blockListeners[e]),delete this._blockListeners[e])}}},function(e,t,r){"use strict";const n=r(10),i=r(1053),o={movingAverageIntervals:[6e4,3e5,9e5]};e.exports=class extends n{constructor(e,t){super();const r=Object.assign({},o,t);if("number"!=typeof r.computeThrottleTimeout)throw new Error("need computeThrottleTimeout");if("number"!=typeof r.computeThrottleMaxQueueSize)throw new Error("need computeThrottleMaxQueueSize");this._initialCounters=e,this._options=r,this._enabled=this._options.enabled,this._global=new i(e,r),this._global.on("update",e=>this.emit("update",e)),this._peers=new Map}enable(){this._enabled=!0,this._options.enabled=!0,this._global.enable()}disable(){this._enabled=!1,this._options.enabled=!1,this._global.disable()}stop(){this._enabled=!1,this._global.stop();for(let e of this._peers)e[1].stop()}get snapshot(){return this._global.snapshot}get movingAverages(){return this._global.movingAverages}forPeer(e){return e.toB58String&&(e=e.toB58String()),this._peers.get(e)}push(e,t,r){if(this._enabled&&(this._global.push(t,r),e)){let n=this._peers.get(e);n||(n=new i(this._initialCounters,this._options),this._peers.set(e,n)),n.push(t,r)}}disconnected(e){const t=e.toB58String(),r=this._peers.get(t);r&&(r.stop(),this._peers.delete(t))}}},function(e,t,r){"use strict";const n=r(10),i=r(122),o=r(505);e.exports=class extends n{constructor(e,t){super(),this._options=t,this._queue=[],this._stats={},this._frequencyLastTime=Date.now(),this._frequencyAccumulators={},this._movingAverages={},this._update=this._update.bind(this),e.forEach(e=>{this._stats[e]=i(0),this._movingAverages[e]={},this._options.movingAverageIntervals.forEach(t=>{(this._movingAverages[e][t]=o(t)).push(this._frequencyLastTime,0)})}),this._enabled=this._options.enabled}enable(){this._enabled=!0}disable(){this._disabled=!0}stop(){this._timeout&&clearTimeout(this._timeout)}get snapshot(){return Object.assign({},this._stats)}get movingAverages(){return Object.assign({},this._movingAverages)}push(e,t){this._enabled&&(this._queue.push([e,t,Date.now()]),this._resetComputeTimeout())}_resetComputeTimeout(){this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout(this._update,this._nextTimeout())}_nextTimeout(){const e=this._queue.length/this._options.computeThrottleMaxQueueSize;return Math.max(this._options.computeThrottleTimeout*(1-e),0)}_update(){if(this._timeout=null,this._queue.length){let e;for(;this._queue.length;){const t=e=this._queue.shift();this._applyOp(t)}this._updateFrequency(e[2]),this.emit("update",this._stats)}}_updateFrequency(e){const t=e-this._frequencyLastTime;Object.keys(this._stats).forEach(r=>{this._updateFrequencyFor(r,t,e)}),this._frequencyLastTime=e}_updateFrequencyFor(e,t,r){const n=this._frequencyAccumulators[e]||0;this._frequencyAccumulators[e]=0;const i=n/t*1e3;let s=this._movingAverages[e];s||(s=this._movingAverages[e]={}),this._options.movingAverageIntervals.forEach(e=>{let t=s[e];t||(t=s[e]=o(e)),t.push(r,i)})}_applyOp(e){const t=e[0],r=e[1];if("number"!=typeof r)throw new Error("invalid increment number:",r);let n;n=this._stats.hasOwnProperty(t)?this._stats[t]:this._stats[t]=i(0),this._stats[t]=n.plus(r),this._frequencyAccumulators[t]||(this._frequencyAccumulators[t]=0),this._frequencyAccumulators[t]+=r}}},function(e,t,r){"use strict";const n=r(49),i=r(23);e.exports=(e=>i(t=>{if(t=t||function(){},e.log("stop"),"stopped"===e.state.state())return t(new Error("Already stopped"));if("running"!==e.state.state())return t(new Error("Not able to stop from state: "+e.state.state()));e.state.stop(),e._blockService.unsetExchange(),e._bitswap.stop(),e._preload.stop(),n([t=>e._mfsPreload.stop(t),t=>e.libp2p.stop(t),t=>e._repo.close(t)],r=>{if(r)return e.emit("error",r),t(r);e.state.stopped(),e.emit("stop"),t()})}))},function(e,t,r){"use strict";e.exports=function(e){return()=>Boolean(e._bitswap&&e._libp2pNode&&e._libp2pNode.isStarted())}},function(e,t,r){"use strict";const n=r(506),i=r(23);e.exports=function(e){return i((t,r)=>{"function"==typeof t&&(r=t,t={}),e.repo.version((e,t)=>{e&&r(e),r(null,{version:n.version,repo:t,commit:""})})})}},function(e,t,r){"use strict";const n=r(23),i=r(3),o=r(506).version;e.exports=function(e){return n((t,r)=>{"function"==typeof t&&(r=t,t={}),i(()=>r(null,{id:e._peerInfo.id.toB58String(),publicKey:e._peerInfo.id.pubKey.bytes.toString("base64"),addresses:e._peerInfo.multiaddrs.toArray().map(e=>e.toString()).filter(e=>e.indexOf("ipfs")>=0).sort(),agentVersion:`js-ipfs/${o}`,protocolVersion:"9000"}))})}},function(e,t,r){"use strict";const n=r(98),i=r(5),o=r(59),s=r(23),a=r(508),u=r(495),c=r(1059);e.exports=function(e){return s((t,r)=>{"function"==typeof t&&(r=t,t={});const s=(t,n)=>{if(t)return e.emit("error",t),r(t);e.preStart(t=>{if(t)return e.emit("error",t),r(t);e.state.initialized(),e.emit("init"),r(null,n)})};if("uninitialized"!==e.state.state())return s(new Error("Not able to init from state: "+e.state.state()));if(e.state.init(),e.log("init"),t.repo)return e._repo=t.repo,s(null,!0);t.emptyRepo=t.emptyRepo||!1,t.bits=Number(t.bits)||2048,t.log=t.log||function(){};const f=a();let l;i([t=>e._repo.exists(t),(r,i)=>{if(e.log("repo exists?",r),!0===r)return i(new Error("repo already exists"));t.log(`generating ${t.bits}-bit RSA keypair...`,!1),e.log("generating peer id: %s bits",t.bits),n.create({bits:t.bits},i)},(r,n)=>{e.log("identity generated"),f.Identity={PeerID:r.toB58String(),PrivKey:r.privKey.bytes.toString("base64")},t.pass&&(l=r.privKey,f.Keychain=u.generateOptions()),t.log("done"),t.log("peer identity: "+f.Identity.PeerID),e._repo.init(f,n)},(t,r)=>e._repo.open(r),r=>{if(e.log("repo opened"),t.pass){e.log("creating keychain");const n=Object.assign({passPhrase:t.pass},f.Keychain);e._keychain=new u(e._repo.keys,n),e._keychain.importPeer("self",{privKey:l},r)}else r(null,!0)},(r,n)=>{if(t.emptyRepo)return n(null,!0);const i=[t=>e.object.new("unixfs-dir",t)];"function"==typeof c&&i.push(r=>c(e,t.log,r)),e.log("adding assets"),o(i,e=>{e?n(e):n(null,!0)})}],s)})}},function(e,t){},function(e,t,r){"use strict";const n=r(508),i=r(78).IPFS.matches,o=r(23);function s(e){try{return i(e)}catch(e){return!1}}function a(e){return new Error(`${e} is not a valid Multiaddr`)}e.exports=function(e){return{list:o(t=>{e._repo.config.get((e,r)=>{if(e)return t(e);t(null,{Peers:r.Bootstrap})})}),add:o((t,r,i)=>{if("function"==typeof r&&(i=r,r={default:!1}),t&&!s(t))return setImmediate(()=>i(a(t)));e._repo.config.get((o,s)=>{if(o)return i(o);r.default?s.Bootstrap=n().Bootstrap:t&&-1===s.Bootstrap.indexOf(t)&&s.Bootstrap.push(t),e._repo.config.set(s,e=>{if(e)return i(e);i(null,{Peers:r.default?n().Bootstrap:[t]})})})}),rm:o((t,r,n)=>{if("function"==typeof r&&(n=r,r={all:!1}),t&&!s(t))return setImmediate(()=>n(a(t)));e._repo.config.get((i,o)=>{if(i)return n(i);r.all?o.Bootstrap=[]:o.Bootstrap=o.Bootstrap.filter(e=>e!==t),e._repo.config.set(o,e=>{if(e)return n(e);const i=[];!r.all&&t&&i.push(t),n(null,{Peers:i})})})})}}},function(e,t,r){"use strict";const n=r(23);e.exports=function(e){return{get:n((t,r)=>("function"==typeof t&&(r=t,t=void 0),e._repo.config.get(t,r))),set:n((t,r,n)=>{e._repo.config.set(t,r,n)}),replace:n((t,r)=>{e._repo.config.set(t,r)})}}},function(e,t,r){"use strict";const n=r(151),i=r(12),o=r(61),s=r(9),a=r(5),u=r(23);function c(e){return s.isCID(e)?e:new s(e)}e.exports=function(e){return{get:u((t,r,n)=>{"function"==typeof r&&(n=r,r={}),r=r||{},t=c(t),!1!==r.preload&&e._preload(t),e._blockService.get(t,n)}),put:u((t,r,i)=>{if(i=i||function(){},"function"==typeof r&&(i=r,r={}),Array.isArray(t))return i(new Error("Array is not supported"));a([e=>{if(n.isBlock(t))return e(null,t);if(r.cid&&s.isCID(r.cid))return e(null,new n(t,r.cid));const i=r.mhtype||"sha2-256",a=r.format||"dag-pb",u=r.version||0;o(t,i,(r,i)=>{if(r)return e(r);e(null,new n(t,new s(u,a,i)))})},(t,n)=>e._blockService.put(t,i=>{if(i)return n(i);!1!==r.preload&&e._preload(t.cid),n(null,t)})],i)}),rm:u((t,r)=>{t=c(t),e._blockService.delete(t,r)}),stat:u((t,r,n)=>{"function"==typeof r&&(n=r,r={}),t=c(t),!1!==r.preload&&e._preload(t),e._blockService.get(t,(e,r)=>{if(e)return n(e);n(null,{key:i.toB58String(t.multihash),size:r.data.length})})})}}},function(e,t,r){"use strict";(function(t){const n=r(5),i=r(3),o=r(23),s=r(41),a=s.DAGNode,u=s.DAGLink,c=r(9),f=r(12),l=r(36);function h(e,r){if("string"==typeof e)return"base58"!==r&&r?t.from(e,r):e;if(t.isBuffer(e))return e;throw new Error("unsupported multihash")}function p(e,t,r){switch(t){case"json":return d(e,r);case"protobuf":return function(e,t){s.util.deserialize(e,t)}(e,r);default:r(new Error(`unkown encoding: ${t}`))}}function d(e,r){let n,i;try{const o=JSON.parse(e.toString());i=(o.Links||[]).map(e=>new u(e.Name||e.name,e.Size||e.size,f.fromB58String(e.Hash||e.hash||e.multihash))),n=t.from(o.Data)}catch(e){return r(new Error("failed to parse JSON: "+e))}a.create(n,i,r)}e.exports=function(e){function r(t){return(r,i,o)=>{"function"==typeof i&&(o=i,i={}),n([t=>{e.object.get(r,i,t)},(r,n)=>{t(r,(t,r)=>{if(t)return n(t);const o=new c(r.multihash);e._ipld.put(r,{cid:o},t=>{if(t)return n(t);!1!==i.preload&&e._preload(o),n(null,r)})})}],o)}}return{new:o((r,n,o)=>{let s;if("function"==typeof r&&(o=r,r=void 0,n={}),"function"==typeof n&&(o=n,n={}),n=n||{},r){if("unixfs-dir"!==r)return i(()=>o(new Error("unknown template")));s=new l("directory").marshal()}else s=t.alloc(0);a.create(s,(t,r)=>{if(t)return o(t);const i=new c(r.multihash);e._ipld.put(r,{cid:i},t=>{if(t)return o(t);!1!==n.preload&&e._preload(i),o(null,r)})})}),put:o((r,n,i)=>{"function"==typeof n&&(i=n,n={});const o=n.enc;let s;if(t.isBuffer(r))o?p(r,o,(e,t)=>{if(e)return i(e);s=t,u()}):a.create(r,(e,t)=>{if(e)return i(e);s=t,u()});else if(r.multihash)s=r,u();else{if("object"!=typeof r)return i(new Error("obj not recognized"));a.create(r.Data,r.Links,(e,t)=>{if(e)return i(e);s=t,u()})}function u(){const t=new c(s.multihash);e._ipld.put(s,{cid:t},r=>{if(r)return i(r);!1!==n.preload&&e._preload(t),e.object.get(s.multihash,i)})}}),get:o((t,r,n)=>{let i;"function"==typeof r&&(n=r,r={});try{i=h(t,r.enc)}catch(t){return n(t)}let o=new c(i);1===r.cidVersion&&(o=o.toV1()),!1!==r.preload&&e._preload(o),e._ipld.get(o,(e,t)=>{if(e)return n(e);const r=t.value;n(null,r)})}),data:o((t,r,n)=>{"function"==typeof r&&(n=r,r={}),e.object.get(t,r,(e,t)=>{if(e)return n(e);n(null,t.data)})}),links:o((t,r,n)=>{"function"==typeof r&&(n=r,r={}),e.object.get(t,r,(e,t)=>{if(e)return n(e);n(null,t.links)})}),stat:o((t,r,n)=>{"function"==typeof r&&(n=r,r={}),e.object.get(t,r,(e,t)=>{if(e)return n(e);s.util.serialize(t,(e,r)=>{if(e)return n(e);const i=r.length,o=t.links.reduce((e,t)=>e+t.size,0),s=t.toJSON();n(null,{Hash:s.multihash,NumLinks:t.links.length,BlockSize:i,LinksSize:i-t.data.length,DataSize:t.data.length,CumulativeSize:i+o})})})}),patch:o({addLink(e,t,n,i){r((e,r)=>{a.addLink(e,t,r)})(e,n,i)},rmLink(e,t,n,i){r((e,r)=>{u.isDAGLink(t)?t=t._name:t&&t.name&&(t=t.name),a.rmLink(e,t,r)})(e,n,i)},appendData(e,n,i,o){r((e,r)=>{const i=t.concat([e.data,n]);a.create(i,e.links,r)})(e,i,o)},setData(e,t,n,i){r((e,r)=>{a.create(t,e.links,r)})(e,n,i)}})}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";e.exports="message Data {\n enum DataType {\n Raw = 0;\n Directory = 1;\n File = 2;\n Metadata = 3;\n Symlink = 4;\n HAMTShard = 5;\n }\n\n required DataType Type = 1;\n optional bytes Data = 2;\n optional uint64 filesize = 3;\n repeated uint64 blocksizes = 4;\n\n optional uint64 hashType = 5;\n optional uint64 fanout = 6;\n}\n\nmessage Metadata {\n optional string MimeType = 1;\n}"},function(e,t,r){"use strict";(function(t){const n=r(23),i=r(9),o=r(8),s=r(80),a=r(1066);e.exports=function(e){return{put:n((t,r,n)=>{if("function"==typeof r)n=r;else{if(r.cid&&(r.format||r.hashAlg))return n(new Error("Can't put dag node. Please provide either `cid` OR `format` and `hashAlg` options."));if(r.format&&!r.hashAlg||!r.format&&r.hashAlg)return n(new Error("Can't put dag node. Please provide `format` AND `hashAlg` options."))}r=r.cid?r:Object.assign({},{format:"dag-cbor",hashAlg:"sha2-256"},r),e._ipld.put(t,r,(t,i)=>{if(t)return n(t);!1!==r.preload&&e._preload(i),n(null,i)})}),get:n((r,n,o,s)=>{if("function"==typeof n&&(s=n,n=void 0),"function"==typeof o&&(s=o,o={}),o=o||{},"string"==typeof r){const e=r.split("/");r=new i(e[0]),e.shift(),n=e.length>0?e.join("/"):"/"}else if(t.isBuffer(r))try{r=new i(r)}catch(r){return s(r)}!1!==o.preload&&e._preload(r),e._ipld.get(r,n,o,s)}),tree:n((t,r,n,s)=>{if("object"==typeof r&&(s=n,n=r,r=void 0),"function"==typeof r&&(s=r,r=void 0),"function"==typeof n&&(s=n,n={}),n=n||{},"string"==typeof t){const e=t.split("/");t=new i(e[0]),e.shift(),r=e.length>0?e.join("/"):void 0}!1!==n.preload&&e._preload(t),o(e._ipld.treeStream(t,r,n),o.collect(s))}),_getRecursive:n((t,r,n)=>{"function"==typeof r&&(n=r,r={}),r=r||{},e.dag.get(new i(t),"",r,(t,r)=>{if(t)return n(t);s(r.value.links,(t,r)=>{e.dag._getRecursive(t.multihash,r)},(e,t)=>{if(e)return n(e);n(null,a([r.value,t]))})})})}}}).call(this,r(0).Buffer)},function(e,t,r){var n=r(1067),i=1/0;e.exports=function(e){return null!=e&&e.length?n(e,i):[]}},function(e,t,r){var n=r(1068),i=r(1069);e.exports=function e(t,r,o,s,a){var u=-1,c=t.length;for(o||(o=i),a||(a=[]);++u0&&o(f)?r>1?e(f,r-1,o,s,a):n(a,f):s||(a[a.length]=f)}return a}},function(e,t){e.exports=function(e,t){for(var r=-1,n=t.length,i=e.length;++r{e.config.get(function(r,i){if(r)return t(r);const a={peerInfo:e._peerInfo,peerBook:e._peerInfoBook,config:{peerDiscovery:{mdns:{enabled:o(e._options,"config.Discovery.MDNS.Enabled",o(i,"Discovery.MDNS.Enabled",!0))},webRTCStar:{enabled:o(e._options,"config.Discovery.webRTCStar.Enabled",o(i,"Discovery.webRTCStar.Enabled",!0))},bootstrap:{list:o(e._options,"config.Bootstrap",o(i,"Bootstrap",[]))}},relay:{enabled:o(e._options,"relay.enabled",o(i,"relay.enabled",!1)),hop:{enabled:o(e._options,"relay.hop.enabled",o(i,"relay.hop.enabled",!1)),active:o(e._options,"relay.hop.active",o(i,"relay.hop.active",!1))}},EXPERIMENTAL:{dht:o(e._options,"EXPERIMENTAL.dht",!1),pubsub:o(e._options,"EXPERIMENTAL.pubsub",!1)}},connectionManager:o(e._options,"connectionManager",o(i,"connectionManager",{}))},u=s(o(e._options,"libp2p",{}),a);e._libp2pNode=new n(u),e._libp2pNode.on("peer:discovery",t=>{const r=()=>{e._peerInfoBook.put(t),e._libp2pNode.dial(t,()=>{})};e.isOnline()?r():e._libp2pNode.once("start",r)}),e._libp2pNode.on("peer:connect",t=>{e._peerInfoBook.put(t)}),e._libp2pNode.start(r=>{if(r)return t(r);e._libp2pNode.peerInfo.multiaddrs.forEach(e=>{console.log("Swarm listening on",e.toString())}),t()})})}),stop:i(t=>{e._libp2pNode.stop(t)})}}},function(e,t,r){"use strict";const n=r(509),i=r(1085),o=r(1125),s=r(1146),a=r(1154),u=r(1178),c=r(1196),f=r(585);e.exports=class extends c{constructor(e){const t=new i({id:e.peerInfo.id}),r=new o({id:e.peerInfo.id}),c={modules:{transport:[n,t,r],streamMuxer:[s],connEncryption:[a],peerDiscovery:[t.discovery,r.discovery,u]},config:{peerDiscovery:{bootstrap:{enabled:!0},webRTCStar:{enabled:!0},websocketStar:{enabled:!0}},EXPERIMENTAL:{dht:!1,pubsub:!1}}};super(f(e,c))}}},function(e,t,r){"use strict";var n=r(1073),i=r(1075),o=r(1079);function s(e){return"function"==typeof e}e.exports=function(e,t){s(t)&&(t={onConnect:t});var r="undefined"==typeof window?{}:window.location,a=o(e,r),u=new n(a),c=i(u,t);return c.remoteAddress=a,c.close=function(e){s(e)&&u.addEventListener("close",e),u.close()},u.addEventListener("open",function(e){t&&s(t.onConnect)&&t.onConnect(null,c)}),c},e.exports.connect=e.exports},function(e,t,r){e.exports="undefined"==typeof WebSocket?r(1074):WebSocket},function(e,t){},function(e,t,r){var n=r(1076),i=r(1077);e.exports=function(e,t){var r=e.upgradeReq||{};return t&&t.binaryType?e.binaryType=t.binaryType:t&&t.binary&&(e.binaryType="arraybuffer"),{source:n(e,t&&t.onConnect),sink:i(e,t),headers:r.headers,url:r.url,upgrade:r.upgrade,method:r.method}}},function(e,t,r){var n=r(2).Buffer;e.exports=function(e,t){var r,i,o=[],s=!1;return e.addEventListener("message",function(e){var t=e.data;if(function(e){return e instanceof ArrayBuffer||null!=e&&null!=e.constructor&&"ArrayBuffer"===e.constructor.name&&"number"==typeof e.byteLength}(t)&&(t=n.from(t)),r)return r(null,t);o.push(t)}),e.addEventListener("close",function(e){i||r&&r(i=!0)}),e.addEventListener("error",function(e){i||(i=e,s||(s=!0,t&&t(e)),r&&r(i))}),e.addEventListener("open",function(e){s||i||(s=!0)}),function(t,n){if(r=null,i)return n(i);t?(r=n,e.close()):o.length>0?n(null,o.shift()):r=n}}},function(e,t,r){(function(t){var n=r(1078),i="undefined"!=typeof setImmediate?setImmediate:t.nextTick;e.exports=function(e,t){return function(r){var o=!1!==(t=t||{}).closeOnEnd,s="function"==typeof t?t:t.onClose;r(null,function t(a,u){a?o&&e.readyState<=1&&(s&&e.addEventListener("close",function(e){if(e.wasClean||1006===e.code)s();else{var t=new Error("ws error");t.event=e,s(t)}}),e.close()):n(e,function(n){if(n)return r(n,function(){});e.send(u),i(function(){r(null,t)})})})}}}).call(this,r(6))},function(e,t){e.exports=function(e,t){var r=e&&(e.removeEventListener||e.removeListener);function n(){"function"==typeof r&&(r.call(e,"open",i),r.call(e,"error",o))}function i(e){n(),t()}function o(e){n(),t(e)}return e.readyState>=2?t(!0):1===e.readyState?t():(e.addEventListener("open",i),void e.addEventListener("error",o))}},function(e,t,r){var n=r(1080),i={http:"ws",https:"wss"};e.exports=function(e,t){return n(e,t,i,"ws")}},function(e,t,r){var n=r(33);e.exports=function(e,t,r,i){var o;return r=r||{},o=(e=n.parse(e,!1,!0)).protocol?e.protocol:(r[o=t.protocol?t.protocol.replace(/:$/,""):"http"]||i||o)+":",e.host&&":"===e.host[0]&&(e.host=null),e.hostname?n.format({protocol:o,slashes:!0,hostname:e.hostname,port:e.port,pathname:e.pathname,search:e.search}):(e.host=t.host,e.port?n.format({protocol:o,slashes:!0,host:t.hostname+":"+e.port,port:e.port,pathname:e.pathname,search:e.search}):e.pathname?n.format({protocol:o,slashes:!0,host:e.host,pathname:e.pathname,search:e.search}):(e.pathname=t.pathname,e.search?n.format({protocol:o,slashes:!0,host:e.host,pathname:e.pathname,search:e.search}):(e.search=t.search,e.format(e))))}},function(e,t){var r=1/0,n=9007199254740991,i=1.7976931348623157e308,o=NaN,s="[object Arguments]",a="[object Function]",u="[object GeneratorFunction]",c="[object String]",f="[object Symbol]",l=/^\s+|\s+$/g,h=/^[-+]0x[0-9a-f]+$/i,p=/^0b[01]+$/i,d=/^0o[0-7]+$/i,y=/^(?:0|[1-9]\d*)$/,g=parseInt;function m(e){return e!=e}function b(e,t){return function(e,t){for(var r=-1,n=e?e.length:0,i=Array(n);++r-1&&e%1==0&&e-1&&e%1==0&&e<=n}(e.length)&&!function(e){var t=C(e)?w.call(e):"";return t==a||t==u}(e)}function C(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function P(e){return!!e&&"object"==typeof e}function O(e){return e?(e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||P(e)&&w.call(e)==f}(e))return o;if(C(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=C(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(l,"");var r=p.test(e);return r||d.test(e)?g(e.slice(2),r?2:8):h.test(e)?o:+e}(e))===r||e===-r?(e<0?-1:1)*i:e==e?e:0:0===e?e:0}e.exports=function(e,t,r,n){e=B(e)?e:function(e){return e?b(e,function(e){return B(e)?A(e):x(e)}(e)):[]}(e),r=r&&!n?function(e){var t=O(e),r=t%1;return t==t?r?t-r:t:0}(r):0;var i=e.length;return r<0&&(r=E(i+r,0)),function(e){return"string"==typeof e||!T(e)&&P(e)&&w.call(e)==c}(e)?r<=i&&e.indexOf(t,r)>-1:!!i&&function(e,t,r){if(t!=t)return function(e,t,r,n){for(var i=e.length,o=r+(n?1:-1);n?o--:++o-1}},function(e,t,r){"use strict";const n=r(383);e.exports=class{constructor(e,t){this.peerInfo=null,this.conn=n(),e?this.setInnerConn(e,t):t&&(this.info=t)}get source(){return this.conn.source}get sink(){return this.conn.sink}getPeerInfo(e){return this.info&&this.info.getPeerInfo?this.info.getPeerInfo(e):this.peerInfo?void e(null,this.peerInfo):e(new Error("Peer Info not set yet"))}setPeerInfo(e){if(this.info&&this.info.setPeerInfo)return this.info.setPeerInfo(e);this.peerInfo=e}getObservedAddrs(e){if(this.info&&this.info.getObservedAddrs)return this.info.getObservedAddrs(e);e(null,[])}setInnerConn(e,t){this.conn.resolve(e),this.info=t||e}}},function(e,t,r){"use strict";const n=r(1)("libp2p:websockets:dialer");e.exports=function(e){const t=e.toString().split("/");let r,i;try{r=e.protoNames().filter(e=>"ws"===e||"wss"===e)[0]}catch(e){throw n(e),new Error("Not a valid websocket address",e)}try{i=e.stringTuples().filter(t=>{if(t[0]===e.protos().filter(e=>"tcp"===e.name)[0].code)return!0})[0][1]}catch(e){n("No port, skipping")}return`${r}://${t[2]}${!i||80===i&&443===i?"":`:${i}`}`}},function(e,t,r){"use strict";e.exports=function(){throw new Error("WebSocket Servers can not be created in the browser!")}},function(e,t,r){"use strict";const n=r(1)("libp2p:webrtc-star"),i=r(52),o=r(78),s=r(58),a=r(510),u=r(10).EventEmitter,c=r(191),f=r(1105),l=r(51),h=r(47).Connection,p=r(192),d=r(30),y=r(3),g=r(1123),m=r(1124),b=m.cleanUrlSIO,v=m.cleanMultiaddr,_=d(()=>{}),w={transports:["websocket"],"force new connection":!0};e.exports=s(class{constructor(e){e=e||{},this.maSelf=void 0,this.sioOptions={transports:["websocket"],"force new connection":!0},e.wrtc&&(this.wrtc=e.wrtc),this.discovery=new u,this.discovery.tag="webRTCStar",this.discovery.start=(e=>{y(e)}),this.discovery.stop=(e=>{y(e)}),this.listenersRefs={},this._peerDiscovered=this._peerDiscovered.bind(this)}dial(e,t,r){"function"==typeof t&&(r=t,t={}),r=r?d(r):_;const n=(~~(1e9*Math.random())).toString(36)+Date.now(),i=this.listenersRefs[Object.keys(this.listenersRefs)[0]].io,o={initiator:!0,trickle:!1};this.wrtc&&(o.wrtc=this.wrtc);const s=new c(o),a=new h(p.duplex(s));let u=!1;return s.on("signal",t=>{i.emit("ss-handshake",{intentId:n,srcMultiaddr:this.maSelf.toString(),dstMultiaddr:e.toString(),signal:t})}),s.once("timeout",()=>r(new Error("timeout"))),s.once("error",e=>{u||r(e)}),i.on("ws-handshake",t=>{if(t.intentId===n&&t.err)return r(new Error(t.err));t.intentId===n&&t.answer&&(s.once("connect",()=>{u=!0,a.destroy=s.destroy.bind(s),s.once("close",()=>a.destroy()),a.getObservedAddrs=(t=>t(null,[e])),r(null,a)}),s.signal(t.signal))}),a}createListener(e,t){"function"==typeof e&&(t=e,e={});const r=new u;return r.listen=((e,i)=>{if(i=i?d(i):_,!g.support&&!this.wrtc)return y(()=>i(new Error("no WebRTC support")));this.maSelf=e;const o=b(e);n("Dialing to Signalling Server on: "+o),r.io=a.connect(o,w),r.io.once("connect_error",i),r.io.once("error",e=>{r.emit("error",e),r.emit("close")}),r.io.on("ws-handshake",function(e){if(e.answer||e.err)return;const n={trickle:!1};s.wrtc&&(n.wrtc=s.wrtc);const i=new c(n),o=new h(p.duplex(i));i.once("connect",()=>{o.getObservedAddrs=(t=>t(null,[e.srcMultiaddr])),r.emit("connection",o),t(o)}),i.once("signal",t=>{e.signal=t,e.answer=!0,r.io.emit("ss-handshake",e)}),i.signal(e.signal)}),r.io.on("ws-peer",this._peerDiscovered),r.io.on("connect",()=>{r.io.emit("ss-join",e.toString())}),r.io.once("connect",()=>{r.emit("listening"),i()});const s=this}),r.close=(e=>{e=e?d(e):_,r.io.emit("ss-leave"),y(()=>{r.emit("close"),e()})}),r.getAddrs=(e=>{y(()=>e(null,[this.maSelf]))}),this.listenersRefs[i.toString()]=r,r}filter(e){return Array.isArray(e)||(e=[e]),e.filter(e=>!(e.protoNames().indexOf("p2p-circuit")>-1)&&o.WebRTCStar.matches(e))}_peerDiscovered(e){n("Peer Discovered:",e);const t=(e=v(e)).split("/ipfs/"),r=t[t.length-1],o=f.createFromB58String(r),s=new l(o);s.multiaddrs.add(i(e)),this.discovery.emit("peer",s)}},{className:"WebRTCStar",symbolName:"@libp2p/js-libp2p-webrtc-star/webrtcstar"})},function(e,t,r){(function(t){var n=r(511),i=r(1)("socket.io-client:url");e.exports=function(e,r){var o=e;r=r||t.location,null==e&&(e=r.protocol+"//"+r.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?r.protocol+e:r.host+e),/^(https?|wss?):\/\//.test(e)||(i("protocol-less url %s",e),e=void 0!==r?r.protocol+"//"+e:"https://"+e),i("parse %s",e),o=n(e)),o.port||(/^(http|ws)$/.test(o.protocol)?o.port="80":/^(http|ws)s$/.test(o.protocol)&&(o.port="443")),o.path=o.path||"/";var s=-1!==o.host.indexOf(":")?"["+o.host+"]":o.host;return o.id=o.protocol+"://"+s+":"+o.port,o.href=o.protocol+"://"+s+(r&&r.port===o.port?"":":"+o.port),o}}).call(this,r(7))},function(e,t,r){(function(e){var n=r(512),i=r(513),o=Object.prototype.toString,s="function"==typeof e.Blob||"[object BlobConstructor]"===o.call(e.Blob),a="function"==typeof e.File||"[object FileConstructor]"===o.call(e.File);function u(e,t){if(!e)return e;if(i(e)){var r={_placeholder:!0,num:t.length};return t.push(e),r}if(n(e)){for(var o=new Array(e.length),s=0;s0&&(this.extraHeaders=r.extraHeaders),r.localAddress&&(this.localAddress=r.localAddress)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingIntervalTimer=null,this.pingTimeoutTimer=null,this.open()}e.exports=f,f.priorWebsocketSuccess=!1,i(f.prototype),f.protocol=a.protocol,f.Socket=f,f.Transport=r(284),f.transports=r(515),f.parser=r(115),f.prototype.createTransport=function(e){o('creating transport "%s"',e);var t=function(e){var t={};for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t}(this.query);t.EIO=a.protocol,t.transport=e;var r=this.transportOptions[e]||{};return this.id&&(t.sid=this.id),new n[e]({query:t,socket:this,agent:r.agent||this.agent,hostname:r.hostname||this.hostname,port:r.port||this.port,secure:r.secure||this.secure,path:r.path||this.path,forceJSONP:r.forceJSONP||this.forceJSONP,jsonp:r.jsonp||this.jsonp,forceBase64:r.forceBase64||this.forceBase64,enablesXDR:r.enablesXDR||this.enablesXDR,timestampRequests:r.timestampRequests||this.timestampRequests,timestampParam:r.timestampParam||this.timestampParam,policyPort:r.policyPort||this.policyPort,pfx:r.pfx||this.pfx,key:r.key||this.key,passphrase:r.passphrase||this.passphrase,cert:r.cert||this.cert,ca:r.ca||this.ca,ciphers:r.ciphers||this.ciphers,rejectUnauthorized:r.rejectUnauthorized||this.rejectUnauthorized,perMessageDeflate:r.perMessageDeflate||this.perMessageDeflate,extraHeaders:r.extraHeaders||this.extraHeaders,forceNode:r.forceNode||this.forceNode,localAddress:r.localAddress||this.localAddress,requestTimeout:r.requestTimeout||this.requestTimeout,protocols:r.protocols||void 0})},f.prototype.open=function(){var e;if(this.rememberUpgrade&&f.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length){var t=this;return void setTimeout(function(){t.emit("error","No transports available")},0)}e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)},f.prototype.setTransport=function(e){o("setting transport %s",e.name);var t=this;this.transport&&(o("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=e,e.on("drain",function(){t.onDrain()}).on("packet",function(e){t.onPacket(e)}).on("error",function(e){t.onError(e)}).on("close",function(){t.onClose("transport close")})},f.prototype.probe=function(e){o('probing transport "%s"',e);var t=this.createTransport(e,{probe:1}),r=!1,n=this;function i(){if(n.onlyBinaryUpgrades){var i=!this.supportsBinary&&n.transport.supportsBinary;r=r||i}r||(o('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",function(i){if(!r)if("pong"===i.type&&"probe"===i.data){if(o('probe transport "%s" pong',e),n.upgrading=!0,n.emit("upgrading",t),!t)return;f.priorWebsocketSuccess="websocket"===t.name,o('pausing current transport "%s"',n.transport.name),n.transport.pause(function(){r||"closed"!==n.readyState&&(o("changing transport and sending upgrade packet"),h(),n.setTransport(t),t.send([{type:"upgrade"}]),n.emit("upgrade",t),t=null,n.upgrading=!1,n.flush())})}else{o('probe transport "%s" failed',e);var s=new Error("probe error");s.transport=t.name,n.emit("upgradeError",s)}}))}function s(){r||(r=!0,h(),t.close(),t=null)}function a(r){var i=new Error("probe error: "+r);i.transport=t.name,s(),o('probe transport "%s" failed because of error: %s',e,r),n.emit("upgradeError",i)}function u(){a("transport closed")}function c(){a("socket closed")}function l(e){t&&e.name!==t.name&&(o('"%s" works - aborting "%s"',e.name,t.name),s())}function h(){t.removeListener("open",i),t.removeListener("error",a),t.removeListener("close",u),n.removeListener("close",c),n.removeListener("upgrading",l)}f.priorWebsocketSuccess=!1,t.once("open",i),t.once("error",a),t.once("close",u),this.once("close",c),this.once("upgrading",l),t.open()},f.prototype.onOpen=function(){if(o("socket open"),this.readyState="open",f.priorWebsocketSuccess="websocket"===this.transport.name,this.emit("open"),this.flush(),"open"===this.readyState&&this.upgrade&&this.transport.pause){o("starting upgrade probes");for(var e=0,t=this.upgrades.length;en&&(r=n),t>=n||t>=r||0===n)return new ArrayBuffer(0);for(var i=new Uint8Array(e),o=new Uint8Array(r-t),s=t,a=0;s=55296&&t<=56319&&i=55296&&e<=57343){if(t)throw Error("Lone surrogate U+"+e.toString(16).toUpperCase()+" is not a scalar value");return!1}return!0}function d(e,t){return l(e>>t&63|128)}function y(e,t){if(0==(4294967168&e))return l(e);var r="";return 0==(4294965248&e)?r=l(e>>6&31|192):0==(4294901760&e)?(p(e,t)||(e=65533),r=l(e>>12&15|224),r+=d(e,6)):0==(4292870144&e)&&(r=l(e>>18&7|240),r+=d(e,12),r+=d(e,6)),r+l(63&e|128)}function g(){if(f>=c)throw Error("Invalid byte index");var e=255&u[f];if(f++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function m(e){var t,r;if(f>c)throw Error("Invalid byte index");if(f==c)return!1;if(t=255&u[f],f++,0==(128&t))return t;if(192==(224&t)){if((r=(31&t)<<6|g())>=128)return r;throw Error("Invalid continuation byte")}if(224==(240&t)){if((r=(15&t)<<12|g()<<6|g())>=2048)return p(r,e)?r:65533;throw Error("Invalid continuation byte")}if(240==(248&t)&&(r=(7&t)<<18|g()<<12|g()<<6|g())>=65536&&r<=1114111)return r;throw Error("Invalid UTF-8 detected")}var b={version:"2.1.2",encode:function(e,t){for(var r=!1!==(t=t||{}).strict,n=h(e),i=n.length,o=-1,s="";++o65535&&(i+=l((t-=65536)>>>10&1023|55296),t=56320|1023&t),i+=l(t);return i}(i)}};void 0===(i=function(){return b}.call(t,r,t,e))||(e.exports=i)}()}).call(this,r(27)(e),r(7))},function(e,t){!function(){"use strict";for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=new Uint8Array(256),n=0;n>2],o+=e[(3&n[r])<<4|n[r+1]>>4],o+=e[(15&n[r+1])<<2|n[r+2]>>6],o+=e[63&n[r+2]];return i%3==2?o=o.substring(0,o.length-1)+"=":i%3==1&&(o=o.substring(0,o.length-2)+"=="),o},t.decode=function(e){var t,n,i,o,s,a=.75*e.length,u=e.length,c=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var f=new ArrayBuffer(a),l=new Uint8Array(f);for(t=0;t>4,l[c++]=(15&i)<<4|o>>2,l[c++]=(3&o)<<6|63&s;return f}}()},function(e,t,r){(function(t){var r=t.BlobBuilder||t.WebKitBlobBuilder||t.MSBlobBuilder||t.MozBlobBuilder,n=function(){try{return 2===new Blob(["hi"]).size}catch(e){return!1}}(),i=n&&function(){try{return 2===new Blob([new Uint8Array([1,2])]).size}catch(e){return!1}}(),o=r&&r.prototype.append&&r.prototype.getBlob;function s(e){for(var t=0;t';n=document.createElement(e)}catch(e){(n=document.createElement("iframe")).name=r.iframeId,n.src="javascript:0"}n.id=r.iframeId,r.form.appendChild(n),r.iframe=n}this.form.action=this.uri(),f(),e=e.replace(a,"\\\n"),this.area.value=e.replace(s,"\\n");try{this.form.submit()}catch(e){}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){"complete"===r.iframe.readyState&&c()}:this.iframe.onload=c}}).call(this,r(7))},function(e,t,r){(function(t){var n,i=r(284),o=r(115),s=r(189),a=r(190),u=r(518),c=r(1)("engine.io-client:websocket"),f=t.WebSocket||t.MozWebSocket;if("undefined"==typeof window)try{n=r(1101)}catch(e){}var l=f;function h(e){e&&e.forceBase64&&(this.supportsBinary=!1),this.perMessageDeflate=e.perMessageDeflate,this.usingBrowserWebSocket=f&&!e.forceNode,this.protocols=e.protocols,this.usingBrowserWebSocket||(l=n),i.call(this,e)}l||"undefined"!=typeof window||(l=n),e.exports=h,a(h,i),h.prototype.name="websocket",h.prototype.supportsBinary=!0,h.prototype.doOpen=function(){if(this.check()){var e=this.uri(),t=this.protocols,r={agent:this.agent,perMessageDeflate:this.perMessageDeflate};r.pfx=this.pfx,r.key=this.key,r.passphrase=this.passphrase,r.cert=this.cert,r.ca=this.ca,r.ciphers=this.ciphers,r.rejectUnauthorized=this.rejectUnauthorized,this.extraHeaders&&(r.headers=this.extraHeaders),this.localAddress&&(r.localAddress=this.localAddress);try{this.ws=this.usingBrowserWebSocket?t?new l(e,t):new l(e):new l(e,t,r)}catch(e){return this.emit("error",e)}void 0===this.ws.binaryType&&(this.supportsBinary=!1),this.ws.supports&&this.ws.supports.binary?(this.supportsBinary=!0,this.ws.binaryType="nodebuffer"):this.ws.binaryType="arraybuffer",this.addEventListeners()}},h.prototype.addEventListeners=function(){var e=this;this.ws.onopen=function(){e.onOpen()},this.ws.onclose=function(){e.onClose()},this.ws.onmessage=function(t){e.onData(t.data)},this.ws.onerror=function(t){e.onError("websocket error",t)}},h.prototype.write=function(e){var r=this;this.writable=!1;for(var n=e.length,i=0,s=n;i0&&e.jitter<=1?e.jitter:0,this.attempts=0}e.exports=r,r.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),r=Math.floor(t*this.jitter*e);e=0==(1&Math.floor(10*t))?e-r:e+r}return 0|Math.min(e,this.max)},r.prototype.reset=function(){this.attempts=0},r.prototype.setMin=function(e){this.ms=e},r.prototype.setMax=function(e){this.max=e},r.prototype.setJitter=function(e){this.jitter=e}},function(e,t){e.exports=function(){if("undefined"==typeof window)return null;var e={RTCPeerConnection:window.RTCPeerConnection||window.mozRTCPeerConnection||window.webkitRTCPeerConnection,RTCSessionDescription:window.RTCSessionDescription||window.mozRTCSessionDescription||window.webkitRTCSessionDescription,RTCIceCandidate:window.RTCIceCandidate||window.mozRTCIceCandidate||window.webkitRTCIceCandidate};return e.RTCPeerConnection?e:null}},function(e,t,r){"use strict";(function(n){const i=r(12),o=r(1106),s=r(16),a=r(5);class u{constructor(e,t,r){s(n.isBuffer(e),"invalid id provided"),t&&r&&s(t.public.bytes.equals(r.bytes),"inconsistent arguments"),this._id=e,this._idB58String=i.toB58String(this.id),this._privKey=t,this._pubKey=r}get id(){return this._id}set id(e){throw new Error("Id is immutable")}get privKey(){return this._privKey}set privKey(e){this._privKey=e}get pubKey(){return this._pubKey?this._pubKey:this._privKey?this._privKey.public:void 0}set pubKey(e){this._pubKey=e}marshalPubKey(){if(this.pubKey)return o.keys.marshalPublicKey(this.pubKey)}marshalPrivKey(){if(this.privKey)return o.keys.marshalPrivateKey(this.privKey)}toPrint(){return this.toJSON()}toJSON(){return{id:this.toB58String(),privKey:c(this.marshalPrivKey()),pubKey:c(this.marshalPubKey())}}toHexString(){return i.toHexString(this.id)}toBytes(){return this.id}toB58String(){return this._idB58String}isEqual(e){if(n.isBuffer(e))return this.id.equals(e);if(e.id)return this.id.equals(e.id);throw new Error("not valid Id")}isValid(e){this.privKey&&this.privKey.public&&this.privKey.public.bytes&&n.isBuffer(this.pubKey.bytes)&&this.privKey.public.bytes.equals(this.pubKey.bytes)?e():e(new Error("Keys not match"))}}function c(e){if(e)return e.toString("base64")}(t=e.exports=u).create=function(e,t){"function"==typeof e&&(t=e,e={}),(e=e||{}).bits=e.bits||2048,a([t=>o.keys.generateKeyPair("RSA",e.bits,t),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n))})},t.createFromHexString=function(e){return new u(i.fromHexString(e))},t.createFromBytes=function(e){return new u(e)},t.createFromB58String=function(e){return new u(i.fromB58String(e))},t.createFromPubKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r;try{let i=e;if("string"==typeof i&&(i=n.from(e,"base64")),!n.isBuffer(i))throw new Error("Supplied key is neither a base64 string nor a buffer");r=o.keys.unmarshalPublicKey(i)}catch(e){return t(e)}r.hash((e,n)=>{if(e)return t(e);t(null,new u(n,null,r))})},t.createFromPrivKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r=e;try{if("string"==typeof r&&(r=n.from(e,"base64")),!n.isBuffer(r))throw new Error("Supplied key is neither a base64 string nor a buffer")}catch(e){return t(e)}a([e=>o.keys.unmarshalPrivateKey(r,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n,n.public))})},t.createFromJSON=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r,s,c,f;try{r=i.fromB58String(e.id),s=e.privKey&&n.from(e.privKey,"base64"),c=e.pubKey&&n.from(e.pubKey,"base64"),f=c&&o.keys.unmarshalPublicKey(c)}catch(e){return t(e)}s?a([e=>o.keys.unmarshalPrivateKey(s,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)}),(e,t,r)=>{f?f.hash((n,i)=>{r(n,e,t,i)}):r(null,e,t)}],(e,n,i,o)=>e?t(e):f&&!n.equals(o)?t(new Error("Public and private key do not match")):r&&!n.equals(r)?t(new Error("Id and private key do not match")):void t(null,new u(r,i,f))):t(null,new u(r,null,f))},t.isPeerId=function(e){return Boolean("object"==typeof e&&e._id&&e._idB58String)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(522),i=r(1108),o=r(1110);(t=e.exports).aes=i,t.hmac=n,t.keys=o,t.randomBytes=r(527),t.pbkdf2=r(1121)},function(e,t,r){"use strict";e.exports={SHA1:20,SHA256:32,SHA512:64}},function(e,t,r){"use strict";const n=r(1109),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(66);e.exports={createCipheriv:n.createCipheriv,createDecipheriv:n.createDecipheriv}},function(e,t,r){"use strict";(function(n){const i=r(11)(r(287)),o=r(17);t=e.exports;const s={rsa:r(1111),ed25519:r(1116),secp256k1:r(69)(i,r(527))};function a(e){return void 0!==s[e.toLowerCase()]}t.supportedKeys=s,t.keysPBM=i,t.keyStretcher=r(1118),t.generateEphemeralKeyPair=r(1119),t.generateKeyPair=((e,t,r)=>{let 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)=>{let 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){"use strict";const n=r(523),i=r(11),o=r(14),s=r(525),a=i(r(287)),u=r(17),c=r(3);class f{constructor(e){this._key=e}verify(e,t,r){h(r),s.hashAndVerify(this._key,t,e,r)}marshal(){return s.utils.jwkToPkix(this._key)}get bytes(){return a.PublicKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}encrypt(e){return this._key.encrypt(e,"RSAES-PKCS1-V1_5")}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(e),n(this.bytes,"sha2-256",e)}}class l{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return s.getRandomValues(new Uint8Array(16))}sign(e,t){h(t),s.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){s.decrypt(this._key,e,t)}marshal(){return s.utils.jwkToPkcs1(this._key)}get bytes(){return a.PrivateKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(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"),h(r),c(()=>{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 h(e){if("function"!=typeof e)throw new Error("callback is required")}e.exports={RsaPublicKey:f,RsaPrivateKey:l,unmarshalRsaPublicKey:function(e){const t=s.utils.pkixToJwk(e);return new f(t)},unmarshalRsaPrivateKey:function(e,t){const r=s.utils.pkcs1ToJwk(e);s.unmarshalPrivateKey(r,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},generateKeyPair:function(e,t){s.generateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},fromJwk:function(e,t){s.unmarshalPrivateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})}}},function(e,t,r){"use strict";(function(t){const n=r(42),i=r(43),o=r(524),s=r(1113),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,256)),shake256:a(u(n.shake_256,512)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(1114),dblSha2256:(e,r)=>{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(44),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;function o(e){if(!i)throw new Error("Please use a browser with webcrypto support");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(45),i=r(524).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(15),i=r(526),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())}),u=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()))}),c=n.define("RSAPublicKey",function(){this.seq().obj(this.key("algorithm").use(u),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=c.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 c.encode({algorithm:{algorithm:"rsa",none:null},subjectPublicKey:{data:f.encode({modulus:s(e.n),publicExponent:s(e.e)},"der")}},"der")}},function(e,t,r){"use strict";(function(t){const n=r(523),i=r(11),o=r(14),s=r(1117),a=i(r(287));class u{constructor(e){this._key=l(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 c{constructor(e,t){this._key=l(e,s.privateKeyLength),this._publicKey=l(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 u(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 l(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:u,Ed25519PrivateKey:c,unmarshalEd25519PrivateKey:function(e,t){try{e=l(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 c(r,n))},unmarshalEd25519PublicKey:function(e){return e=l(e,s.publicKeyLength),new u(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 c(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 c(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(68),i=r(3);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){"use strict";(function(t){const n=r(40),i=r(522),o={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,cipherKeySize:32}};e.exports=((e,r,s,a)=>{const u=o[e];if(!u)return a(new Error("unkown cipherType passed"));if(!r)return a(new Error("unkown hashType passed"));const c=u.keySize,f=u.ivSize,l=t.from("key expansion"),h=2*(f+c+20);i.create(r,s,(e,r)=>{if(e)return a(e);r.digest(l,(e,i)=>{if(e)return a(e);let o=[],s=0;n(()=>s{if(t)return e(t);let a=n.length;s+a>h&&(a=h-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=h/2,n=t.concat(o),i=n.slice(0,r),s=n.slice(r,h),u=e=>({iv:e.slice(0,f),cipherKey:e.slice(f,f+c),macKey:e.slice(f+c)});a(null,{k1:u(i),k2:u(s)})})})})})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(1120);e.exports=((e,t)=>{n.generateEphmeralKeyPair(e,t)})},function(e,t,r){"use strict";(function(e){const n=r(286)(),i=r(285),o=r(15).bignum,s=r(526),a=s.toBase64,u=s.toBn,c={"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 o=(o,s,a)=>{let u;"function"==typeof s&&(a=s,s=void 0),u=s?n.subtle.importKey("jwk",p(t,s),{name:"ECDH",namedCurve:t},!1,["deriveBits"]):Promise.resolve(r.privateKey);const f=Promise.all([n.subtle.importKey("jwk",h(t,o),{name:"ECDH",namedCurve:t},!1,[]),u]);i(f.then(e=>n.subtle.deriveBits({name:"ECDH",namedCurve:t,public:e[0]},e[1],c[t])).then(t=>e.from(t)),a)};return n.subtle.exportKey("jwk",r.publicKey).then(e=>({key:l(e),genSharedKey:o}))}),r)};const f={"P-256":32,"P-384":48,"P-521":66};function l(t){const r=f[t.crv];return e.concat([e.from([4]),u(t.x).toArrayLike(e,"be",r),u(t.y).toArrayLike(e,"be",r)],1+2*r)}function h(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}}function p(e,t){const r=h(e,t.public);return r.d=a(new o(t.private)),r}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(17),i={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};e.exports=function(e,t,r,o,s){const a=i[s];if(!a)throw new Error(`Hash '${s}' is unknown or not supported`);const u=n.pkcs5.pbkdf2(e,t,r,o,a);return n.util.encode64(u)}},function(e,t){e.exports=function e(t,r){if(t&&r)return e(t)(r);if("function"!=typeof t)throw new TypeError("need wrapper function");return Object.keys(t).forEach(function(e){n[e]=t[e]}),n;function n(){for(var e=new Array(arguments.length),r=0;r=26||"moz"===r&&n>=33),c=self.AudioContext||self.webkitAudioContext,f=self.document&&document.createElement("video"),l=f&&f.canPlayType&&"probably"===f.canPlayType('video/webm; codecs="vp8", vorbis'),h=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.msGetUserMedia||navigator.mozGetUserMedia;e.exports={prefix:r,browserVersion:n,support:!!i&&!!h,supportRTCPeerConnection:!!i,supportVp8:l,supportGetUserMedia:!!h,supportDataChannel:!!(i&&i.prototype&&i.prototype.createDataChannel),supportWebAudio:!(!c||!c.prototype.createMediaStreamSource),supportMediaStream:!(!a||!a.prototype.removeTrack),supportScreenSharing:!!u,AudioContext:c,PeerConnection:i,SessionDescription:s,IceCandidate:o,MediaStream:a,getUserMedia:h}},function(e,t,r){"use strict";const n=r(52);(t=e.exports).cleanUrlSIO=function(e){const t=e.toString().split("/"),r=e.protos()[1].name,i=e.protos()[2].name,o=e.stringTuples()[1][1];if("tcp"!==r||"ws"!==i&&"wss"!==i)throw new Error("invalid multiaddr: "+e.toString());return n.isName(e)?"ws"===i?"http://"+t[2]+(80===o?"":":"+o):"wss"===i?"https://"+t[2]+(443===o?"":":"+o):void 0:"http://"+t[2]+":"+t[4]},t.cleanMultiaddr=function(e){const t="/libp2p-webrtc-star";if(-1!==e.indexOf(t)){e=e.substring(t.length,e.length);let r=n(e);const i=r.stringTuples().filter(e=>421===e[0])[0];e=(r=(r=(r=r.decapsulate("ipfs")).encapsulate("/p2p-webrtc-star")).encapsulate(`/ipfs/${i[1]}`)).toString()}return e}},function(e,t,r){"use strict";const n=r(1)("libp2p:websocket-star"),i=r(52),o=r(10).EventEmitter,s=r(529),a=r(51),u=r(47).Connection,c=r(3),f=r(536),l=r(1142),h=f.cleanUrlSIO,p=r(78),d=r(58);e.exports=d(class{constructor(e){e=e||{},this.id=e.id,this.flag=e.allowJoinWithDisabledChallenge,this.discovery=new o,this.discovery.tag="websocketStar",this.discovery.start=(e=>{c(e)}),this.discovery.stop=(e=>{c(e)}),this.listeners_list={},this._peerDiscovered=this._peerDiscovered.bind(this)}lazySetId(e){e&&(this.id=e,this.canCrypto=!0)}dial(e,t,r){let n;"function"==typeof t&&(r=t,t={});try{n=h(e)}catch(e){return r(e)}const i=this.listeners_list[n];return i?i.dial(e,t,r):(r(new Error("No listener for this server")),new u)}createListener(e,t){"function"==typeof e&&(t=e,e={});const r=new l({id:this.id,handler:t,listeners:this.listeners_list,flag:this.flag});return r.on("peer",this._peerDiscovered),r}filter(e){return Array.isArray(e)||(e=[e]),e.filter(e=>p.WebSocketStar.matches(e))}_peerDiscovered(e){n("Peer Discovered:",e);const t=e.split("/ipfs/").pop(),r=s.createFromB58String(t),o=new a(r);o.multiaddrs.add(i(e)),this.discovery.emit("peer",o)}},{className:"WebsocketStar",symbolName:"@libp2p/js-libp2p-websocket-star/websocketstar"})},function(e,t,r){"use strict";const n=r(530),i=r(1128),o=r(1130);(t=e.exports).aes=i,t.hmac=n,t.keys=o,t.randomBytes=r(535),t.pbkdf2=r(1141)},function(e,t,r){"use strict";e.exports={SHA1:20,SHA256:32,SHA512:64}},function(e,t,r){"use strict";const n=r(1129),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(66);e.exports={createCipheriv:n.createCipheriv,createDecipheriv:n.createDecipheriv}},function(e,t,r){"use strict";(function(n){const i=r(11)(r(290)),o=r(17);t=e.exports;const s={rsa:r(1131),ed25519:r(1136),secp256k1:r(69)(i,r(535))};function a(e){return void 0!==s[e.toLowerCase()]}t.supportedKeys=s,t.keysPBM=i,t.keyStretcher=r(1138),t.generateEphemeralKeyPair=r(1139),t.generateKeyPair=((e,t,r)=>{let 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)=>{let 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){"use strict";const n=r(531),i=r(11),o=r(14),s=r(533),a=i(r(290)),u=r(17),c=r(3);class f{constructor(e){this._key=e}verify(e,t,r){h(r),s.hashAndVerify(this._key,t,e,r)}marshal(){return s.utils.jwkToPkix(this._key)}get bytes(){return a.PublicKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}encrypt(e){return this._key.encrypt(e,"RSAES-PKCS1-V1_5")}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(e),n(this.bytes,"sha2-256",e)}}class l{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return s.getRandomValues(new Uint8Array(16))}sign(e,t){h(t),s.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){s.decrypt(this._key,e,t)}marshal(){return s.utils.jwkToPkcs1(this._key)}get bytes(){return a.PrivateKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(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"),h(r),c(()=>{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 h(e){if("function"!=typeof e)throw new Error("callback is required")}e.exports={RsaPublicKey:f,RsaPrivateKey:l,unmarshalRsaPublicKey:function(e){const t=s.utils.pkixToJwk(e);return new f(t)},unmarshalRsaPrivateKey:function(e,t){const r=s.utils.pkcs1ToJwk(e);s.unmarshalPrivateKey(r,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},generateKeyPair:function(e,t){s.generateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},fromJwk:function(e,t){s.unmarshalPrivateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})}}},function(e,t,r){"use strict";(function(t){const n=r(42),i=r(43),o=r(532),s=r(1133),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,256)),shake256:a(u(n.shake_256,512)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(1134),dblSha2256:(e,r)=>{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(44),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;function o(e){if(!i)throw new Error("Please use a browser with webcrypto support");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(45),i=r(532).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(15),i=r(534),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())}),u=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()))}),c=n.define("RSAPublicKey",function(){this.seq().obj(this.key("algorithm").use(u),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=c.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 c.encode({algorithm:{algorithm:"rsa",none:null},subjectPublicKey:{data:f.encode({modulus:s(e.n),publicExponent:s(e.e)},"der")}},"der")}},function(e,t,r){"use strict";(function(t){const n=r(531),i=r(11),o=r(14),s=r(1137),a=i(r(290));class u{constructor(e){this._key=l(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 c{constructor(e,t){this._key=l(e,s.privateKeyLength),this._publicKey=l(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 u(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 l(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:u,Ed25519PrivateKey:c,unmarshalEd25519PrivateKey:function(e,t){try{e=l(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 c(r,n))},unmarshalEd25519PublicKey:function(e){return e=l(e,s.publicKeyLength),new u(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 c(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 c(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(68),i=r(3);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){"use strict";(function(t){const n=r(40),i=r(530),o={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,cipherKeySize:32}};e.exports=((e,r,s,a)=>{const u=o[e];if(!u)return a(new Error("unkown cipherType passed"));if(!r)return a(new Error("unkown hashType passed"));const c=u.keySize,f=u.ivSize,l=t.from("key expansion"),h=2*(f+c+20);i.create(r,s,(e,r)=>{if(e)return a(e);r.digest(l,(e,i)=>{if(e)return a(e);let o=[],s=0;n(()=>s{if(t)return e(t);let a=n.length;s+a>h&&(a=h-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=h/2,n=t.concat(o),i=n.slice(0,r),s=n.slice(r,h),u=e=>({iv:e.slice(0,f),cipherKey:e.slice(f,f+c),macKey:e.slice(f+c)});a(null,{k1:u(i),k2:u(s)})})})})})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(1140);e.exports=((e,t)=>{n.generateEphmeralKeyPair(e,t)})},function(e,t,r){"use strict";(function(e){const n=r(289)(),i=r(288),o=r(15).bignum,s=r(534),a=s.toBase64,u=s.toBn,c={"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 o=(o,s,a)=>{let u;"function"==typeof s&&(a=s,s=void 0),u=s?n.subtle.importKey("jwk",p(t,s),{name:"ECDH",namedCurve:t},!1,["deriveBits"]):Promise.resolve(r.privateKey);const f=Promise.all([n.subtle.importKey("jwk",h(t,o),{name:"ECDH",namedCurve:t},!1,[]),u]);i(f.then(e=>n.subtle.deriveBits({name:"ECDH",namedCurve:t,public:e[0]},e[1],c[t])).then(t=>e.from(t)),a)};return n.subtle.exportKey("jwk",r.publicKey).then(e=>({key:l(e),genSharedKey:o}))}),r)};const f={"P-256":32,"P-384":48,"P-521":66};function l(t){const r=f[t.crv];return e.concat([e.from([4]),u(t.x).toArrayLike(e,"be",r),u(t.y).toArrayLike(e,"be",r)],1+2*r)}function h(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}}function p(e,t){const r=h(e,t.public);return r.d=a(new o(t.private)),r}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(17),i={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};e.exports=function(e,t,r,o,s){const a=i[s];if(!a)throw new Error(`Hash '${s}' is unknown or not supported`);const u=n.pkcs5.pbkdf2(e,t,r,o,a);return n.util.encode64(u)}},function(e,t,r){"use strict";(function(t){const n=r(1)("libp2p:websocket-star:listener"),i=r(52),o=r(510),s=r(1143),a=r(537),u=r(49),c=r(10).EventEmitter,f=r(47).Connection,l=r(30),h=r(3),p=r(536),d=p.cleanUrlSIO,y=r(111),g=l(()=>{}),m={transports:["websocket"],"force new connection":!0};e.exports=class extends c{constructor(e){super(),this.id=e.id,this.log=n.bind(n,"listener#offline"),this.canCrypto=Boolean(e.id),this._handler=e.handler||g,this.listeners_list=e.listeners||{},this.flag=e.flag}_up(e){if(e=e?l(e):g,this.io)return e();this.log=n.bind(n,"listener#"+this.server),this.log("dialing to signalling server");const t=this.io=o.connect(this.server,m);s(t,{codec:"buffer"}),t.once("error",e),t.once("connect_error",e),t.once("connect",e);const r=new p.Protocol(this.log);r.addRequest("ws-peer",["multiaddr"],(e,t)=>this.emit("peer",t)),r.addRequest("ss-incomming",["string","multiaddr","function"],this._incommingDial.bind(this)),r.handleSocket(t)}_down(){this.io&&(this.io.disconnect(),this.emit("close"),delete this.io)}_cryptoChallenge(e){if(!this.io)return e(new Error("Not connected"));const r=this.canCrypto?y.keys.marshalPublicKey(this.id.pubKey).toString("hex"):"",n=this.ma.toString();this.io.emit("ss-join",n,r,(r,n)=>{if(r)return e(r);if(n){if(!this.canCrypto)return this._down(),e(new Error("Can't sign cryptoChallenge: No id provided"));this.log("performing cryptoChallenge"),this.id.privKey.sign(t.from(n),(t,r)=>{if(t)return e(t);this.signature=r.toString("hex"),this._join(e)})}else{if(!this.flag)return this._down(),e(new Error('Tried to listen on a server with crypto challenge disabled!\n This is prohibited by default and can lead to security issues!\n Please set "allowJoinWithDisabledChallenge" to true in the constructor options (but only if you know what you are doing)!'));this.signature="_",e()}})}_crypto(e){if(e=e?l(e):g,this.log("joining"),!this.io)return e(new Error("Not connected"));this.signature?this._join((t,r)=>{if(r)return this.cryptoChallenge(e);e(t)}):this._cryptoChallenge(e)}_join(e){this.io.emit("ss-join",this.ma.toString(),this.signature,e)}_incommingDial(e,t,r,n){this.log("dial#"+t+" incomming from",r);const o=i(r),s=this.io.createSource(t+".dialer"),a=this.io.createSink(t+".listener");n();const u=new f({sink:a,source:s},{getObservedAddrs:e=>e(null,[o])});this.emit("connection",u),this._handler(u)}listen(e,t){this.ma=e,this.server=d(e),this.listeners_list[this.server]=this,t=t?l(t):g,u([e=>this._up(e),e=>this._crypto(e)],e=>{if(e)return this.log("error",e),e instanceof Error||(e=new Error(e)),this._down(),this.emit("error",e),this.emit("close"),t(e);this.log("success"),this.io.on("reconnect",()=>{this.signature=null,this._crypto(e=>{e?(this.log("reconnect error",e),this.emit("error",e)):this.log("reconnected")})}),this.emit("listening"),t()})}getAddrs(e){h(()=>e(null,this.ma?[this.ma]:[]))}close(e){e=e?l(e):g,this._down(),e()}dial(e,t,r){"function"==typeof t&&(r=t,t={});const o=i(e),s=new f(null),u=a(),c=this.log.bind(n,"dial#"+u);r=r?l(r):g;let h=this.io;if(!h)return r(new Error("Not listening"));const p=h.createSink(u+".dialer");return c("dialing",e.toString()),h.emit("ss-dial",this.ma.toString(),e.toString(),u,e=>{if(e)return r(e instanceof Error?e:new Error(e));c(e?"error: "+e.toString():"success");const t=h.createSource(u+".listener");s.setInnerConn({sink:p,source:t},{getObservedAddrs:e=>e(null,[o])}),r(null,s)}),s}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(1144),i=r(537),o=r(8),s=(e,t)=>"socket.io-pull-stream."+e+(t?"."+t:""),a=r(1)("socket.io-pull-stream");function u(e,t){if(null==t)return t;try{return e(t)}catch(e){return console.error("Codec Error"),console.error(e),!1}}const c={hex:{encode:e=>e.toString("hex"),decode:e=>t.from(e,"hex")},plain:{encode:e=>e,decode:e=>e},buffer:{encode:e=>t.from(e),decode:e=>t.from(e)}};function f(e){if(e||(e="plain"),"object"==typeof e)return e;const t=c[e];if(!t)throw new Error("Invalid codec "+e);return t}function l(e,t,r){const i=n(),o=e.sioplog.bind(e.sioplog,"source("+t+")"),a=f(r.codec).decode;function c(){e.removeAllListeners(s("error",t)),e.removeAllListeners(s("queue",t))}return o("create source"),e.emit(s("accept",t)),e.on(s("error",t),e=>{o(!0===e?"finish":"error"),c(),i.append({end:e})}),e.on(s("queue",t),e=>{o("queue data"),i.append({data:u(a,e)})}),e.once("disconnect",()=>{c(),i.append({end:!0})}),function(e,t){if(o("reading"),e)return t(e);i.get((e,r)=>e?t(e):r.end?(i.error(r.end),t(r.end)):t(null,r.data))}}function h(e,t,r){const i=n(),o=e.sioplog.bind(e.sioplog," sink("+t+")"),a=f(r.codec).encode;let c;function l(e){i.append({err:e}),c=e}return o("create sink"),e.once(s("accept",t),()=>{o("start transmission"),function r(){i.get((n,c)=>{let{data:f,err:l}=c||{};if(n&&(l=n),o("send",l&&!0===l?"finish":l?"error":f?"data":""),l&&!n&&i.error(l),l)return e.emit(s("error",t),l);f&&e.emit(s("queue",t),u(a,f)),r()})}()}),e.once("disconnect",()=>l(!0)),function(e){e(null,function t(r,n){return r?l(r):c?e(c,t):(i.append({data:n}),void e(null,t))})}}e.exports=function(e,t){e.createSink||(e.sioplog=e.id?a.bind(a,"["+e.id+"]"):a,e.createSink=((r,n)=>{r||(r=i());const o=h(e,r,t||n);return o.id=r,o}),e.createSource=((r,n)=>{const i=l(e,r,t||n);return i.id=r,i}),e.createProxy=((t,r,n)=>{o(e.createSource(t,n),r.createSink(t,n))}))}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(10).EventEmitter;e.exports=function(){const e=new n;let t,r=[];function i(){e.removeAllListeners("err"),e.removeAllListeners("data")}return{append:n=>{if(t)return t;r.push(n),e.emit("data")},prepend:e=>{if(t)return t;r.unshift(e)},error:r=>{t=r,e.emit("err",r)},get:n=>(i(),t?n(t):r.length?n(null,r.shift()):(e.once("err",e=>{i(),n(e)}),void e.once("data",()=>(i(),n(null,r.shift()))))),height:()=>r.length}}},function(e,t,r){var n,i,o=r(363),s=r(364),a=0,u=0;e.exports=function(e,t,r){var c=t&&r||0,f=t||[],l=(e=e||{}).node||n,h=void 0!==e.clockseq?e.clockseq:i;if(null==l||null==h){var p=o();null==l&&(l=n=[1|p[0],p[1],p[2],p[3],p[4],p[5]]),null==h&&(h=i=16383&(p[6]<<8|p[7]))}var d=void 0!==e.msecs?e.msecs:(new Date).getTime(),y=void 0!==e.nsecs?e.nsecs:u+1,g=d-a+(y-u)/1e4;if(g<0&&void 0===e.clockseq&&(h=h+1&16383),(g<0||d>a)&&void 0===e.nsecs&&(y=0),y>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");a=d,u=y,i=h;var m=(1e4*(268435455&(d+=122192928e5))+y)%4294967296;f[c++]=m>>>24&255,f[c++]=m>>>16&255,f[c++]=m>>>8&255,f[c++]=255&m;var b=d/4294967296*1e4&268435455;f[c++]=b>>>8&255,f[c++]=255&b,f[c++]=b>>>24&15|16,f[c++]=b>>>16&255,f[c++]=h>>>8|128,f[c++]=255&h;for(var v=0;v<6;++v)f[c+v]=l[v];return t||s(f)}},function(e,t,r){"use strict";const n=r(140),i=r(1147),o=r(538),s=r(1151),a=r(539);function u(e,t){const r=n(e);r.on("end",()=>r.destroy());const o=new i({halfOpen:!0,initiator:!t});return a(r,o,r),new s(e,o)}(t=e.exports=u).multicodec=o,t.dialer=(e=>u(e,!1)),t.listener=(e=>u(e,!0))},function(e,t,r){"use strict";(function(t){const n=r(22),i=r(20),o=r(1148),s=r(1),a=r(1150),u=t.from([0]),c=t.alloc(0);let f=t.alloc(10240),l=0;e.exports=class extends n.Duplex{constructor(e,r){super(),"function"==typeof e&&(r=e,e={}),e||(e={}),r&&this.on("stream",r),this.destroyed=!1,this.limit=e.limit||0,null==e.initiator&&(e.initiator=!0),this.initiator=e.initiator,this._corked=0,this._options=e,this._binaryName=Boolean(e.binaryName),this._local=[],this._remote=[],this._list=this._local,this._receiving=null,this._chunked=!1,this._state=0,this._type=0,this._channel=0,this._missing=0,this._message=null,this.log=s("mplex:main:"+Math.floor(1e5*Math.random())),this.log("construction");let n=100;this.limit&&(n=i.encodingLength(this.limit)),this._buf=t.alloc(n),this._ptr=0,this._awaitChannelDrains=0,this._onwritedrain=null,this._ondrain=[],this._finished=!1,this.once("finish",this._clear),this._nextId=this.initiator?0:1}_nextStreamId(){let e=this._nextId;return this._nextId+=2,e}createStream(e,t){if(this.destroyed)throw new Error("Multiplexer is destroyed");const r=this._nextStreamId();let n=this._name(e||r.toString());const i=Object.assign(this._options,t);this.log("createStream: %s",r,n.toString(),i);const o=new a(n,this,i);return this._addChannel(o,r,this._local)}receiveStream(e,t){if(this.destroyed)throw new Error("Multiplexer is destroyed");if(void 0===e||null===e)throw new Error("Name is needed when receiving a stream");const r=this._name(e);this.log("receiveStream: "+r.toString());const n=new a(r,this,Object.assign(this._options,t));if(this._receiving||(this._receiving={}),this._receiving[n.name])throw new Error("You are already receiving this stream");return this._receiving[n.name]=n,n}createSharedStream(e,t){return this.log("createSharedStream"),o(this.createStream(e,Object.assign(t,{lazy:!0})),this.receiveStream(e,t))}_name(e){return this._binaryName?t.isBuffer(e)?e:t.from(e):e.toString()}_send(e,r){const n=r?r.length:0,o=l;let s=!0;return this.log("_send",e,n),i.encode(e,f,l),l+=i.encode.bytes,i.encode(n,f,l),l+=i.encode.bytes,s=this.push(f.slice(o,l)),f.length-l<100&&(f=t.alloc(10240),l=0),r&&(s=this.push(r)),s}_addChannel(e,t,r){return this.log("_addChannel",t),r[t]=e,e.on("finalize",()=>{this.log("_remove channel",t),r[t]=null}),e.open(t,r===this._local),e}_writeVarint(e,t){for(;t>3,this._list=1&this._type?this._local:this._remote;const t=this._list.length>this._channel&&this._list[this._channel]&&this._list[this._channel].chunked;this._chunked=Boolean(1===this._type||2===this._type)&&t}else if(this._missing=i.decode(this._buf),this.limit&&this._missing>this.limit)return this._lengthError(e);return this._state++,this._ptr=0,t+1}}return e.length}_lengthError(e){return this.destroy(new Error("Incoming message is too big")),e.length}_writeMessage(e,r){const n=e.length-r,i=this._missing;if(!this._message){if(i<=n)return this._missing=0,this._push(e.slice(r,r+i)),r+i;if(this._chunked)return this._missing-=n,this._push(e.slice(r,e.length)),e.length;this._message=t.alloc(i)}return e.copy(this._message,this._ptr,r,r+i),i<=n?(this._missing=0,this._push(this._message),r+i):(this._missing-=n,this._ptr+=n,e.length)}_push(e){if(this.log("_push",e.length),this._missing||(this._ptr=0,this._state=0,this._message=null),0===this._type){if(this.log("open",this._channel),this.destroyed||this._finished)return;let t,r;return t=this._binaryName?e:e.toString()||this._channel.toString(),this.log("open name",t),void(this._receiving&&this._receiving[t]?(r=this._receiving[t],delete this._receiving[t],this._addChannel(r,this._channel,this._list)):(r=new a(t,this,this._options),this.emit("stream",this._addChannel(r,this._channel,this._list),r.name)))}const t=this._list[this._channel];if(t)switch(this._type){case 5:case 6:{const r=new Error(e.toString()||"Channel destroyed");return void t._destroy(r,!1)}case 3:case 4:return void t.push(null);case 1:case 2:t.push(e)||(this._awaitChannelDrains++,t._awaitDrain++)}}_onchanneldrain(e){if(this._awaitChannelDrains-=e,this._awaitChannelDrains)return;const t=this._onwritedrain;this._onwritedrain=null,t&&t()}_write(e,t,r){if(this.log("_write",e.length),this._finished)return void r();if(this._corked)return void this._onuncork(this._write.bind(this,e,t,r));if(e===u)return void this._finish(r);let n=0;for(;n{!1===this._writableState.prefinished&&(this._writableState.prefinished=!0),this.emit("prefinish"),this._onuncork(e)})}cork(){1==++this._corked&&this.emit("cork")}uncork(){this._corked&&0==--this._corked&&this.emit("uncork")}end(e,t,r){return this.log("end"),"function"==typeof e&&(r=e,e=void 0),"function"==typeof t&&(r=t,t=void 0),e&&this.write(e),this._writableState.ending||this.write(u),n.Writable.prototype.end.call(this,r)}_onuncork(e){this._corked?this.once("uncork",e):e()}_read(){for(;this._ondrain.length;)this._ondrain.shift()()}_clear(){if(this.log("_clear"),this._finished)return;this._finished=!0;const e=this._local.concat(this._remote);this._local=[],this._remote=[],e.forEach(function(e){e&&e._destroy(null,!1)}),this.push(null)}finalize(){this._clear()}destroy(e){if(this.log("destroy"),this.destroyed)this.log("already destroyed");else{var t=this._local.concat(this._remote);this.destroyed=!0,e&&this.emit("error",e),this.emit("close"),t.forEach(function(t){t&&t.emit("error",e||new Error("underlying socket has been closed"))}),this._clear()}}}}).call(this,r(0).Buffer)},function(e,t,r){(function(t,n){var i=r(22),o=r(193),s=r(4),a=r(1149),u=t.from&&t.from!==Uint8Array.from?t.from([0]):new t([0]),c=function(e,t){e._corked?e.once("uncork",t):t()},f=function(e,t){return function(r){r?function(e,t){e._autoDestroy&&e.destroy(t)}(e,"premature close"===r.message?null:r):t&&!e._ended&&e.end()}},l=function(e){return new i.Readable({objectMode:!0,highWaterMark:16}).wrap(e)},h=function(e,t,r){if(!(this instanceof h))return new h(e,t,r);i.Duplex.call(this,r),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!r||!1!==r.autoDestroy,this._forwardDestroy=!r||!1!==r.destroy,this._forwardEnd=!r||!1!==r.end,this._corked=1,this._ondrain=null,this._drained=!1,this._forwarding=!1,this._unwrite=null,this._unread=null,this._ended=!1,this.destroyed=!1,e&&this.setWritable(e),t&&this.setReadable(t)};s(h,i.Duplex),h.obj=function(e,t,r){return r||(r={}),r.objectMode=!0,r.highWaterMark=16,new h(e,t,r)},h.prototype.cork=function(){1==++this._corked&&this.emit("cork")},h.prototype.uncork=function(){this._corked&&0==--this._corked&&this.emit("uncork")},h.prototype.setWritable=function(e){if(this._unwrite&&this._unwrite(),this.destroyed)e&&e.destroy&&e.destroy();else if(null!==e&&!1!==e){var t=this,r=o(e,{writable:!0,readable:!1},f(this,this._forwardEnd)),i=function(){var e=t._ondrain;t._ondrain=null,e&&e()};this._unwrite&&n.nextTick(i),this._writable=e,this._writable.on("drain",i),this._unwrite=function(){t._writable.removeListener("drain",i),r()},this.uncork()}else this.end()},h.prototype.setReadable=function(e){if(this._unread&&this._unread(),this.destroyed)e&&e.destroy&&e.destroy();else{if(null===e||!1===e)return this.push(null),void this.resume();var t=this,r=o(e,{writable:!1,readable:!0},f(this)),n=function(){t._forward()},i=function(){t.push(null)};this._drained=!0,this._readable=e,this._readable2=e._readableState?e:l(e),this._readable2.on("readable",n),this._readable2.on("end",i),this._unread=function(){t._readable2.removeListener("readable",n),t._readable2.removeListener("end",i),r()},this._forward()}},h.prototype._read=function(){this._drained=!0,this._forward()},h.prototype._forward=function(){if(!this._forwarding&&this._readable2&&this._drained){var e;for(this._forwarding=!0;this._drained&&null!==(e=a(this._readable2));)this.destroyed||(this._drained=this.push(e));this._forwarding=!1}},h.prototype.destroy=function(e){if(!this.destroyed){this.destroyed=!0;var t=this;n.nextTick(function(){t._destroy(e)})}},h.prototype._destroy=function(e){if(e){var t=this._ondrain;this._ondrain=null,t?t(e):this.emit("error",e)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")},h.prototype._write=function(e,t,r){return this.destroyed?r():this._corked?c(this,this._write.bind(this,e,t,r)):e===u?this._finish(r):this._writable?void(!1===this._writable.write(e)?this._ondrain=r:r()):r()},h.prototype._finish=function(e){var t=this;this.emit("preend"),c(this,function(){!function(e,t){e?e._writableState&&e._writableState.finished?t():e._writableState?e.end(t):(e.end(),t()):t()}(t._forwardEnd&&t._writable,function(){!1===t._writableState.prefinished&&(t._writableState.prefinished=!0),t.emit("prefinish"),c(t,e)})})},h.prototype.end=function(e,t,r){return"function"==typeof e?this.end(null,null,e):"function"==typeof t?this.end(e,null,t):(this._ended=!0,e&&this.write(e),this._writableState.ending||this.write(u),i.Writable.prototype.end.call(this,r))},e.exports=h}).call(this,r(0).Buffer,r(6))},function(e,t){e.exports=function(e){var t=e._readableState;return t?t.objectMode?e.read():e.read(function(e){return e.buffer.length?e.buffer.head?e.buffer.head.data.length:e.buffer[0].length:e.length}(t)):null}},function(e,t,r){"use strict";(function(t){const n=r(22),i=r(1);e.exports=class extends n.Duplex{constructor(e,t,r){const n=Boolean(r.halfOpen);super({allowHalfOpen:n}),this.name=e,this.log=i("mplex:channel:"+this.name.toString()),this.channel=0,this.initiator=!1,this.chunked=Boolean(r.chunked),this.halfOpen=n,this.destroyed=!1,this.finalized=!1,this._multiplex=t,this._dataHeader=0,this._opened=!1,this._awaitDrain=0,this._lazy=Boolean(r.lazy);let o=!1,s=!1;this.log("open, halfOpen: "+this.halfOpen),this.once("end",()=>{this.log("end"),this._read(),this.destroyed||(s=!0,o?this._finalize():this.halfOpen||this.end())}),this.once("finish",function e(){if(!this.destroyed){if(!this._opened)return this.once("open",e);this._lazy&&this.initiator&&this._open(),this._multiplex._send(this.channel<<3|(this.initiator?4:3),null),o=!0,s&&this._finalize()}})}destroy(e){this._destroy(e,!0)}_destroy(e,r){if(this.log("_destroy:"+(r?"local":"remote")),this.destroyed)return void this.log("already destroyed");this.destroyed=!0;const n=this.listenerCount("error")>0;if(!e||r&&!n||this.emit("error",e),this.emit("close"),r&&this._opened){this._lazy&&this.initiator&&this._open();const r=e?t.from(e.message):null;try{this._multiplex._send(this.channel<<3|(this.initiator?6:5),r)}catch(e){}}this._finalize()}_finalize(){this.finalized||(this.finalized=!0,this.emit("finalize"))}_write(e,t,r){this.log("write: ",e.length),this._opened?this.destroyed?r():(this._lazy&&this.initiator&&this._open(),this._multiplex._send(this._dataHeader,e)?r():this._multiplex._ondrain.push(r)):this.once("open",()=>{this._write(e,t,r)})}_read(){if(this._awaitDrain){const e=this._awaitDrain;this._awaitDrain=0,this._multiplex._onchanneldrain(e)}}_open(){let e=null;t.isBuffer(this.name)?e=this.name:this.name!==this.channel.toString()&&(e=t.from(this.name)),this._lazy=!1,this._multiplex._send(this.channel<<3|0,e)}open(e,t){this.log("open: "+e),this.channel=e,this.initiator=t,this._dataHeader=e<<3|(t?2:1),this._opened=!0,!this._lazy&&this.initiator&&this._open(),this.emit("open")}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(10).EventEmitter,i=r(47).Connection,o=r(192),s=r(8),a=r(1152),u=r(3),c=r(538);function f(){}function l(e){return{source:s(e.source,a(e=>{if("Channel destroyed"!==e.message)return!1})),sink:e.sink}}e.exports=class extends n{constructor(e,t){super(),this.multiplex=t,this.conn=e,this.multicodec=c,t.on("close",()=>this.emit("close")),t.on("error",e=>this.emit("error",e)),t.on("stream",(e,t)=>{const r=new i(l(o.duplex(e)),this.conn);this.emit("stream",r)})}newStream(e){let t;e=e||f;try{t=this.multiplex.createStream()}catch(t){return u(()=>e(t))}const r=new i(l(o.duplex(t)),this.conn);return u(()=>e(null,r)),r}end(e){e=e||f,this.multiplex.once("close",e),this.multiplex.destroy()}}},function(e,t){e.exports=function(e){var t;return e=e||function(){},function(r){return function(n,i){r(n,function(r,n){if(t)return i(!0);if(r&&!0!==r){var o=e(r);return!1===o?i(r):o&&!0!==o?(t=!0,i(null,o)):i(!0)}i(r,n)})}}}},function(e,t){},function(e,t,r){"use strict";const n=r(8),i=r(47).Connection,o=r(16),s=r(51),a=r(1),u=r(30),c=a("libp2p:secio");c.error=a("libp2p:secio:error");const f=r(1155),l=r(1177);e.exports={tag:"/secio/1.0.0",encrypt(e,t,r,a){o(e,"no local private key provided"),o(t,"no connection for the handshake provided"),"function"==typeof r&&(a=r,r=void 0),a=u(a||function(e){e&&c.error(e)});const h=new l(e,r,3e5,a);const p=new i(void 0,t);return n(t,f(h,function(e){if(e)return a(e);t.getPeerInfo((e,r)=>{p.setInnerConn(new i(h.secure,t)),e&&p.setPeerInfo(new s(h.id.remote)),a()})}),t),p}}},function(e,t,r){"use strict";const n=r(49),i=r(1156),o=r(1174),s=r(1175);e.exports=function(e,t){return n([t=>i(e,t),t=>o(e,t),t=>s(e,t)],r=>{e.cleanSecrets(),r&&(!0===r&&(r=new Error("Stream ended prematurely")),e.shake.abort(r)),t(r)}),e.stream}},function(e,t,r){"use strict";const n=r(1),i=r(5),o=r(291),s=r(297),a=n("libp2p:secio");a.error=n("libp2p:secio:error"),e.exports=function(e,t){a("1. propose - start"),a("1. propose - writing proposal"),o.write(e,s.createProposal(e)),i([t=>o.read(e.shake,t),(t,r)=>{a("1. propose - reading proposal",t),s.identify(e,t,r)},t=>s.selectProtocols(e,t)],e=>{if(e)return t(e);a("1. propose - finish"),t()})}},function(e,t,r){"use strict";(function(t){const n=r(42),i=r(43),o=r(540),s=r(1158),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,256)),shake256:a(u(n.shake_256,512)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(1159),dblSha2256:(e,r)=>{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(44),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;function o(e){if(!i)throw new Error("Please use a browser with webcrypto support");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(45),i=r(540).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";e.exports={SHA1:20,SHA256:32,SHA512:64}},function(e,t,r){"use strict";const n=r(1162),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(66);e.exports={createCipheriv:n.createCipheriv,createDecipheriv:n.createDecipheriv}},function(e,t,r){"use strict";(function(n){const i=r(11)(r(296)),o=r(17);t=e.exports;const s={rsa:r(1164),ed25519:r(1166),secp256k1:r(69)(i,r(544))};function a(e){return void 0!==s[e.toLowerCase()]}t.supportedKeys=s,t.keysPBM=i,t.keyStretcher=r(1168),t.generateEphemeralKeyPair=r(1169),t.generateKeyPair=((e,t,r)=>{let 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)=>{let 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){"use strict";const n=r(292),i=r(11),o=r(14),s=r(542),a=i(r(296)),u=r(17),c=r(3);class f{constructor(e){this._key=e}verify(e,t,r){h(r),s.hashAndVerify(this._key,t,e,r)}marshal(){return s.utils.jwkToPkix(this._key)}get bytes(){return a.PublicKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}encrypt(e){return this._key.encrypt(e,"RSAES-PKCS1-V1_5")}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(e),n(this.bytes,"sha2-256",e)}}class l{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return s.getRandomValues(new Uint8Array(16))}sign(e,t){h(t),s.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){s.decrypt(this._key,e,t)}marshal(){return s.utils.jwkToPkcs1(this._key)}get bytes(){return a.PrivateKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(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"),h(r),c(()=>{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 h(e){if("function"!=typeof e)throw new Error("callback is required")}e.exports={RsaPublicKey:f,RsaPrivateKey:l,unmarshalRsaPublicKey:function(e){const t=s.utils.pkixToJwk(e);return new f(t)},unmarshalRsaPrivateKey:function(e,t){const r=s.utils.pkcs1ToJwk(e);s.unmarshalPrivateKey(r,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},generateKeyPair:function(e,t){s.generateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},fromJwk:function(e,t){s.unmarshalPrivateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})}}},function(e,t,r){"use strict";const n=r(15),i=r(543),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())}),u=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()))}),c=n.define("RSAPublicKey",function(){this.seq().obj(this.key("algorithm").use(u),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=c.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 c.encode({algorithm:{algorithm:"rsa",none:null},subjectPublicKey:{data:f.encode({modulus:s(e.n),publicExponent:s(e.e)},"der")}},"der")}},function(e,t,r){"use strict";(function(t){const n=r(292),i=r(11),o=r(14),s=r(1167),a=i(r(296));class u{constructor(e){this._key=l(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 c{constructor(e,t){this._key=l(e,s.privateKeyLength),this._publicKey=l(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 u(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 l(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:u,Ed25519PrivateKey:c,unmarshalEd25519PrivateKey:function(e,t){try{e=l(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 c(r,n))},unmarshalEd25519PublicKey:function(e){return e=l(e,s.publicKeyLength),new u(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 c(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 c(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(68),i=r(3);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){"use strict";(function(t){const n=r(40),i=r(541),o={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,cipherKeySize:32}};e.exports=((e,r,s,a)=>{const u=o[e];if(!u)return a(new Error("unkown cipherType passed"));if(!r)return a(new Error("unkown hashType passed"));const c=u.keySize,f=u.ivSize,l=t.from("key expansion"),h=2*(f+c+20);i.create(r,s,(e,r)=>{if(e)return a(e);r.digest(l,(e,i)=>{if(e)return a(e);let o=[],s=0;n(()=>s{if(t)return e(t);let a=n.length;s+a>h&&(a=h-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=h/2,n=t.concat(o),i=n.slice(0,r),s=n.slice(r,h),u=e=>({iv:e.slice(0,f),cipherKey:e.slice(f,f+c),macKey:e.slice(f+c)});a(null,{k1:u(i),k2:u(s)})})})})})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(1170);e.exports=((e,t)=>{n.generateEphmeralKeyPair(e,t)})},function(e,t,r){"use strict";(function(e){const n=r(295)(),i=r(294),o=r(15).bignum,s=r(543),a=s.toBase64,u=s.toBn,c={"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 o=(o,s,a)=>{let u;"function"==typeof s&&(a=s,s=void 0),u=s?n.subtle.importKey("jwk",p(t,s),{name:"ECDH",namedCurve:t},!1,["deriveBits"]):Promise.resolve(r.privateKey);const f=Promise.all([n.subtle.importKey("jwk",h(t,o),{name:"ECDH",namedCurve:t},!1,[]),u]);i(f.then(e=>n.subtle.deriveBits({name:"ECDH",namedCurve:t,public:e[0]},e[1],c[t])).then(t=>e.from(t)),a)};return n.subtle.exportKey("jwk",r.publicKey).then(e=>({key:l(e),genSharedKey:o}))}),r)};const f={"P-256":32,"P-384":48,"P-521":66};function l(t){const r=f[t.crv];return e.concat([e.from([4]),u(t.x).toArrayLike(e,"be",r),u(t.y).toArrayLike(e,"be",r)],1+2*r)}function h(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}}function p(e,t){const r=h(e,t.public);return r.d=a(new o(t.private)),r}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(17),i={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};e.exports=function(e,t,r,o,s){const a=i[s];if(!a)throw new Error(`Hash '${s}' is unknown or not supported`);const u=n.pkcs5.pbkdf2(e,t,r,o,a);return n.util.encode64(u)}},function(e,t,r){"use strict";(function(n){const i=r(12),o=r(293),s=r(16),a=r(5);class u{constructor(e,t,r){s(n.isBuffer(e),"invalid id provided"),t&&r&&s(t.public.bytes.equals(r.bytes),"inconsistent arguments"),this._id=e,this._idB58String=i.toB58String(this.id),this._privKey=t,this._pubKey=r}get id(){return this._id}set id(e){throw new Error("Id is immutable")}get privKey(){return this._privKey}set privKey(e){this._privKey=e}get pubKey(){return this._pubKey?this._pubKey:this._privKey?this._privKey.public:void 0}set pubKey(e){this._pubKey=e}marshalPubKey(){if(this.pubKey)return o.keys.marshalPublicKey(this.pubKey)}marshalPrivKey(){if(this.privKey)return o.keys.marshalPrivateKey(this.privKey)}toPrint(){return this.toJSON()}toJSON(){return{id:this.toB58String(),privKey:c(this.marshalPrivKey()),pubKey:c(this.marshalPubKey())}}toHexString(){return i.toHexString(this.id)}toBytes(){return this.id}toB58String(){return this._idB58String}isEqual(e){if(n.isBuffer(e))return this.id.equals(e);if(e.id)return this.id.equals(e.id);throw new Error("not valid Id")}isValid(e){this.privKey&&this.privKey.public&&this.privKey.public.bytes&&n.isBuffer(this.pubKey.bytes)&&this.privKey.public.bytes.equals(this.pubKey.bytes)?e():e(new Error("Keys not match"))}}function c(e){if(e)return e.toString("base64")}(t=e.exports=u).create=function(e,t){"function"==typeof e&&(t=e,e={}),(e=e||{}).bits=e.bits||2048,a([t=>o.keys.generateKeyPair("RSA",e.bits,t),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n))})},t.createFromHexString=function(e){return new u(i.fromHexString(e))},t.createFromBytes=function(e){return new u(e)},t.createFromB58String=function(e){return new u(i.fromB58String(e))},t.createFromPubKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r;try{let i=e;if("string"==typeof i&&(i=n.from(e,"base64")),!n.isBuffer(i))throw new Error("Supplied key is neither a base64 string nor a buffer");r=o.keys.unmarshalPublicKey(i)}catch(e){return t(e)}r.hash((e,n)=>{if(e)return t(e);t(null,new u(n,null,r))})},t.createFromPrivKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r=e;try{if("string"==typeof r&&(r=n.from(e,"base64")),!n.isBuffer(r))throw new Error("Supplied key is neither a base64 string nor a buffer")}catch(e){return t(e)}a([e=>o.keys.unmarshalPrivateKey(r,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n,n.public))})},t.createFromJSON=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r,s,c,f;try{r=i.fromB58String(e.id),s=e.privKey&&n.from(e.privKey,"base64"),c=e.pubKey&&n.from(e.pubKey,"base64"),f=c&&o.keys.unmarshalPublicKey(c)}catch(e){return t(e)}s?a([e=>o.keys.unmarshalPrivateKey(s,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)}),(e,t,r)=>{f?f.hash((n,i)=>{r(n,e,t,i)}):r(null,e,t)}],(e,n,i,o)=>e?t(e):f&&!n.equals(o)?t(new Error("Public and private key do not match")):r&&!n.equals(r)?t(new Error("Id and private key do not match")):void t(null,new u(r,i,f))):t(null,new u(r,null,f))},t.isPeerId=function(e){return Boolean("object"==typeof e&&e._id&&e._idB58String)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";e.exports="message Propose {\n optional bytes rand = 1;\n optional bytes pubkey = 2;\n optional string exchanges = 3;\n optional string ciphers = 4;\n optional string hashes = 5;\n}\n\nmessage Exchange {\n optional bytes epubkey = 1;\n optional bytes signature = 2;\n}"},function(e,t,r){"use strict";const n=r(1),i=r(5),o=r(291),s=r(297),a=n("libp2p:secio");a.error=n("libp2p:secio:error"),e.exports=function(e,t){a("2. exchange - start"),a("2. exchange - writing exchange"),i([t=>s.createExchange(e,t),(t,r)=>{o.write(e,t),o.read(e.shake,r)},(t,r)=>{a("2. exchange - reading exchange"),s.verify(e,t,r)},t=>s.generateKeys(e,t)],e=>{if(e)return t(e);a("2. exchange - finish"),t()})}},function(e,t,r){"use strict";const n=r(8),i=r(101),o=r(1),s=o("libp2p:secio");s.error=o("libp2p:secio:error");const a=r(1176),u=r(297);e.exports=function(e,t){s("3. finish - start");const r=e.protocols,o=e.shake.rest(),c=i({timeout:e.timeout},e=>{if(e)throw e});n(o,a.createUnboxStream(r.remote.cipher,r.remote.mac),c,a.createBoxStream(r.local.cipher,r.local.mac),o),c.handshake.write(e.proposal.in.rand),c.handshake.read(e.proposal.in.rand.length,(r,i)=>{const o=r=>{s.error(r),e.secure.resolve({source:n.error(r),sink(e){}}),t(r)};if(r)return o(r);try{u.verifyNonce(e,i)}catch(r){return o(r)}s("3. finish - finish"),e.secure.resolve(c.handshake.rest()),t()})}},function(e,t,r){"use strict";(function(e){const n=r(8),i=r(53),o={fixed:!0,bytes:4};function s(){return n.map(t=>"string"==typeof t?e.from(t,"utf-8"):t)}t.createBoxStream=((t,r)=>n(s(),n.asyncMap((n,i)=>{t.encrypt(n,(t,n)=>{if(t)return i(t);r.digest(n,(t,r)=>{if(t)return i(t);i(null,e.concat([n,r]))})})}),i.encode(o))),t.createUnboxStream=((e,t)=>n(s(),i.decode(o),n.asyncMap((r,n)=>{const i=r.length,o=t.length;if(it?n(t):u.equals(r)?void e.decrypt(a,(e,t)=>{if(e)return n(e);n(null,t)}):n(new Error(`MAC Invalid: ${u.toString("hex")} != ${r.toString("hex")}`)))})))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(101),i=r(225);e.exports=class{constructor(e,t,r,o){"function"==typeof r&&(o=r,r=void 0),this.setup(),this.id.local=e,this.id.remote=t,this.key.local=e.privKey,this.timeout=r||6e4,o=o||(()=>{}),this.secure=i.duplex(),this.stream=n({timeout:this.timeout},o),this.shake=this.stream.handshake,delete this.stream.handshake}setup(){this.id={local:null,remote:null},this.key={local:null,remote:null},this.shake=null,this.cleanSecrets()}cleanSecrets(){this.shared={},this.ephemeralKey={local:null,remote:null},this.proposal={in:null,out:null},this.proposalEncoded={in:null,out:null},this.protocols={local:null,remote:null},this.exchange={in:null,out:null}}}},function(e,t,r){"use strict";const n=r(1179),i=r(51),o=r(52),s=r(78),a=r(10).EventEmitter,u=r(1),c=r(3),f=u("libp2p:railing");f.error=u("libp2p:railing:error");(e.exports=class extends a{constructor(e){super(),this._list=e.list,this._interval=e.interval||1e4,this._timer=null}start(e){c(()=>e()),this._timer||(this._timer=setInterval(()=>{this._list.forEach(e=>{if(!function(e){try{return s.IPFS.matches(e)}catch(e){return!1}}(e))return f.error("Invalid multiaddr");const t=o(e),r=n.createFromB58String(t.getPeerId());i.create(r,(e,r)=>{if(e)return f.error("Invalid bootstrap peer id",e);r.multiaddrs.add(t),this.emit("peer",r)})})},this._interval))}stop(e){c(e),this._timer&&(clearInterval(this._timer),this._timer=null)}}).tag="bootstrap"},function(e,t,r){"use strict";(function(n){const i=r(12),o=r(1180),s=r(16),a=r(5);class u{constructor(e,t,r){s(n.isBuffer(e),"invalid id provided"),t&&r&&s(t.public.bytes.equals(r.bytes),"inconsistent arguments"),this._id=e,this._idB58String=i.toB58String(this.id),this._privKey=t,this._pubKey=r}get id(){return this._id}set id(e){throw new Error("Id is immutable")}get privKey(){return this._privKey}set privKey(e){this._privKey=e}get pubKey(){return this._pubKey?this._pubKey:this._privKey?this._privKey.public:void 0}set pubKey(e){this._pubKey=e}marshalPubKey(){if(this.pubKey)return o.keys.marshalPublicKey(this.pubKey)}marshalPrivKey(){if(this.privKey)return o.keys.marshalPrivateKey(this.privKey)}toPrint(){return this.toJSON()}toJSON(){return{id:this.toB58String(),privKey:c(this.marshalPrivKey()),pubKey:c(this.marshalPubKey())}}toHexString(){return i.toHexString(this.id)}toBytes(){return this.id}toB58String(){return this._idB58String}isEqual(e){if(n.isBuffer(e))return this.id.equals(e);if(e.id)return this.id.equals(e.id);throw new Error("not valid Id")}isValid(e){this.privKey&&this.privKey.public&&this.privKey.public.bytes&&n.isBuffer(this.pubKey.bytes)&&this.privKey.public.bytes.equals(this.pubKey.bytes)?e():e(new Error("Keys not match"))}}function c(e){if(e)return e.toString("base64")}(t=e.exports=u).create=function(e,t){"function"==typeof e&&(t=e,e={}),(e=e||{}).bits=e.bits||2048,a([t=>o.keys.generateKeyPair("RSA",e.bits,t),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n))})},t.createFromHexString=function(e){return new u(i.fromHexString(e))},t.createFromBytes=function(e){return new u(e)},t.createFromB58String=function(e){return new u(i.fromB58String(e))},t.createFromPubKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r;try{let i=e;if("string"==typeof i&&(i=n.from(e,"base64")),!n.isBuffer(i))throw new Error("Supplied key is neither a base64 string nor a buffer");r=o.keys.unmarshalPublicKey(i)}catch(e){return t(e)}r.hash((e,n)=>{if(e)return t(e);t(null,new u(n,null,r))})},t.createFromPrivKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r=e;try{if("string"==typeof r&&(r=n.from(e,"base64")),!n.isBuffer(r))throw new Error("Supplied key is neither a base64 string nor a buffer")}catch(e){return t(e)}a([e=>o.keys.unmarshalPrivateKey(r,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n,n.public))})},t.createFromJSON=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r,s,c,f;try{r=i.fromB58String(e.id),s=e.privKey&&n.from(e.privKey,"base64"),c=e.pubKey&&n.from(e.pubKey,"base64"),f=c&&o.keys.unmarshalPublicKey(c)}catch(e){return t(e)}s?a([e=>o.keys.unmarshalPrivateKey(s,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)}),(e,t,r)=>{f?f.hash((n,i)=>{r(n,e,t,i)}):r(null,e,t)}],(e,n,i,o)=>e?t(e):f&&!n.equals(o)?t(new Error("Public and private key do not match")):r&&!n.equals(r)?t(new Error("Id and private key do not match")):void t(null,new u(r,i,f))):t(null,new u(r,null,f))},t.isPeerId=function(e){return Boolean("object"==typeof e&&e._id&&e._idB58String)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(545),i=r(1182),o=r(1184);(t=e.exports).aes=i,t.hmac=n,t.keys=o,t.randomBytes=r(550),t.pbkdf2=r(1195)},function(e,t,r){"use strict";e.exports={SHA1:20,SHA256:32,SHA512:64}},function(e,t,r){"use strict";const n=r(1183),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(66);e.exports={createCipheriv:n.createCipheriv,createDecipheriv:n.createDecipheriv}},function(e,t,r){"use strict";(function(n){const i=r(11)(r(300)),o=r(17);t=e.exports;const s={rsa:r(1185),ed25519:r(1190),secp256k1:r(69)(i,r(550))};function a(e){return void 0!==s[e.toLowerCase()]}t.supportedKeys=s,t.keysPBM=i,t.keyStretcher=r(1192),t.generateEphemeralKeyPair=r(1193),t.generateKeyPair=((e,t,r)=>{let 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)=>{let 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){"use strict";const n=r(546),i=r(11),o=r(14),s=r(548),a=i(r(300)),u=r(17),c=r(3);class f{constructor(e){this._key=e}verify(e,t,r){h(r),s.hashAndVerify(this._key,t,e,r)}marshal(){return s.utils.jwkToPkix(this._key)}get bytes(){return a.PublicKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}encrypt(e){return this._key.encrypt(e,"RSAES-PKCS1-V1_5")}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(e),n(this.bytes,"sha2-256",e)}}class l{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return s.getRandomValues(new Uint8Array(16))}sign(e,t){h(t),s.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){s.decrypt(this._key,e,t)}marshal(){return s.utils.jwkToPkcs1(this._key)}get bytes(){return a.PrivateKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(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"),h(r),c(()=>{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 h(e){if("function"!=typeof e)throw new Error("callback is required")}e.exports={RsaPublicKey:f,RsaPrivateKey:l,unmarshalRsaPublicKey:function(e){const t=s.utils.pkixToJwk(e);return new f(t)},unmarshalRsaPrivateKey:function(e,t){const r=s.utils.pkcs1ToJwk(e);s.unmarshalPrivateKey(r,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},generateKeyPair:function(e,t){s.generateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},fromJwk:function(e,t){s.unmarshalPrivateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})}}},function(e,t,r){"use strict";(function(t){const n=r(42),i=r(43),o=r(547),s=r(1187),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,256)),shake256:a(u(n.shake_256,512)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(1188),dblSha2256:(e,r)=>{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(44),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;function o(e){if(!i)throw new Error("Please use a browser with webcrypto support");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(45),i=r(547).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(15),i=r(549),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())}),u=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()))}),c=n.define("RSAPublicKey",function(){this.seq().obj(this.key("algorithm").use(u),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=c.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 c.encode({algorithm:{algorithm:"rsa",none:null},subjectPublicKey:{data:f.encode({modulus:s(e.n),publicExponent:s(e.e)},"der")}},"der")}},function(e,t,r){"use strict";(function(t){const n=r(546),i=r(11),o=r(14),s=r(1191),a=i(r(300));class u{constructor(e){this._key=l(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 c{constructor(e,t){this._key=l(e,s.privateKeyLength),this._publicKey=l(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 u(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 l(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:u,Ed25519PrivateKey:c,unmarshalEd25519PrivateKey:function(e,t){try{e=l(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 c(r,n))},unmarshalEd25519PublicKey:function(e){return e=l(e,s.publicKeyLength),new u(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 c(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 c(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(68),i=r(3);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){"use strict";(function(t){const n=r(40),i=r(545),o={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,cipherKeySize:32}};e.exports=((e,r,s,a)=>{const u=o[e];if(!u)return a(new Error("unkown cipherType passed"));if(!r)return a(new Error("unkown hashType passed"));const c=u.keySize,f=u.ivSize,l=t.from("key expansion"),h=2*(f+c+20);i.create(r,s,(e,r)=>{if(e)return a(e);r.digest(l,(e,i)=>{if(e)return a(e);let o=[],s=0;n(()=>s{if(t)return e(t);let a=n.length;s+a>h&&(a=h-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=h/2,n=t.concat(o),i=n.slice(0,r),s=n.slice(r,h),u=e=>({iv:e.slice(0,f),cipherKey:e.slice(f,f+c),macKey:e.slice(f+c)});a(null,{k1:u(i),k2:u(s)})})})})})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(1194);e.exports=((e,t)=>{n.generateEphmeralKeyPair(e,t)})},function(e,t,r){"use strict";(function(e){const n=r(299)(),i=r(298),o=r(15).bignum,s=r(549),a=s.toBase64,u=s.toBn,c={"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 o=(o,s,a)=>{let u;"function"==typeof s&&(a=s,s=void 0),u=s?n.subtle.importKey("jwk",p(t,s),{name:"ECDH",namedCurve:t},!1,["deriveBits"]):Promise.resolve(r.privateKey);const f=Promise.all([n.subtle.importKey("jwk",h(t,o),{name:"ECDH",namedCurve:t},!1,[]),u]);i(f.then(e=>n.subtle.deriveBits({name:"ECDH",namedCurve:t,public:e[0]},e[1],c[t])).then(t=>e.from(t)),a)};return n.subtle.exportKey("jwk",r.publicKey).then(e=>({key:l(e),genSharedKey:o}))}),r)};const f={"P-256":32,"P-384":48,"P-521":66};function l(t){const r=f[t.crv];return e.concat([e.from([4]),u(t.x).toArrayLike(e,"be",r),u(t.y).toArrayLike(e,"be",r)],1+2*r)}function h(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}}function p(e,t){const r=h(e,t.public);return r.d=a(new o(t.private)),r}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(17),i={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};e.exports=function(e,t,r,o,s){const a=i[s];if(!a)throw new Error(`Hash '${s}' is unknown or not supported`);const u=n.pkcs5.pbkdf2(e,t,r,o,a);return n.util.encode64(u)}},function(e,t,r){"use strict";(function(t){const n=r(10).EventEmitter,i=r(16),o=r(50),s=r(49),a=r(59),u=r(487),c=r(1197),f=r(1298),l=r(509),h=r(1302),p=r(1336),d=r(1337),y=r(1338),g=r(1339),m=r(1349),b=r(1350).validate;e.exports;const v="The libp2p node is not started yet";e.exports=class extends n{constructor(e){if(super(),e=b(e),this.peerInfo=e.peerInfo,this.peerBook=e.peerBook||new u,this._modules=e.modules,this._config=e.config,this._isStarted=!1,this._transport=[],this._discovery=[],this._switch=new c(this.peerInfo,this.peerBook,e.switch),this.stats=this._switch.stats,this.connectionManager=new h(this,e.connectionManager),this._modules.streamMuxer&&(this._modules.streamMuxer.forEach(e=>this._switch.connection.addStreamMuxer(e)),this._switch.connection.reuse(),this._switch.connection.enableCircuitRelay(this._config.relay),this._switch.on("peer-mux-established",e=>{this.emit("peer:connect",e),this.peerBook.put(e)}),this._switch.on("peer-mux-closed",e=>{this.emit("peer:disconnect",e)})),this._modules.connEncryption&&this._modules.connEncryption.forEach(e=>{this._switch.connection.crypto(e.tag,e.encrypt)}),this._modules.connProtector)this._switch.protector=this._modules.connProtector;else if(t.env.LIBP2P_FORCE_PNET)throw new Error("Private network is enforced, but no protector was provided");if(this._config.EXPERIMENTAL.dht){const e=this._modules.dht;this._dht=new e(this._switch,{kBucketSize:this._config.dht.kBucketSize||20,datastore:y.datastore})}this._config.EXPERIMENTAL.pubsub&&(this.pubsub=g(this)),this.peerRouting=p(this),this.contentRouting=d(this),this.dht=y(this),this._getPeerInfo=m(this),f.mount(this._switch)}start(e){if(!this._modules.transport)return e(new Error("no transports were present"));let t;const r=[],n=[];this.peerInfo.multiaddrs.toArray().forEach(e=>{e.getPeerId()||(r.push(e),n.push(e.encapsulate("/ipfs/"+this.peerInfo.id.toB58String())))}),this.peerInfo.multiaddrs.replace(r,n);const i=this.peerInfo.multiaddrs.toArray();this._modules.transport.forEach(e=>{let r;(r="function"==typeof e?new e:e).filter(i).length>0?this._switch.transport.add(r.tag||r.constructor.name,r):l.isWebSockets(r)&&(t=r),this._transport.push(r)}),s([e=>{this.connectionManager.start(),this._switch.start(e)},e=>{t&&this._switch.transport.add(t.tag||t.constructor.name,t),this._modules.peerDiscovery?o(this._modules.peerDiscovery,(e,t)=>{let r={};if(e.tag&&this._config.peerDiscovery&&this._config.peerDiscovery[e.tag]&&(r=this._config.peerDiscovery[e.tag]),null==r.enabled||r.enabled){let n;(n="function"==typeof e?new e(Object.assign({},r,{peerInfo:this.peerInfo})):e).on("peer",e=>this.emit("peer:discovery",e)),this._discovery.push(n),n.start(t)}else t()},e):e()},e=>{this._isStarted=!0,this._dht?this._dht.start(e):e()},e=>{this._floodSub?this._floodSub.start(e):e()},e=>{this.peerInfo.multiaddrs.toArray().forEach(e=>{e.toString().match(/\/p2p-circuit($|\/)/)||this._transport.find(t=>t.filter(e).length>0)||this.peerInfo.multiaddrs.delete(e)}),e()},e=>{this.emit("start"),e()}],e)}stop(e){s([e=>{if(this._modules.peerDiscovery)return a(this._discovery.map(e=>t=>e.stop(()=>{t()})),e);e()},e=>{if(this._floodSub)return this._floodSub.stop(e);e()},e=>{if(this._dht)return this._dht.stop(e);e()},e=>{this.connectionManager.stop(),this._switch.stop(e)},e=>{this.emit("stop"),e()}],t=>{this._isStarted=!1,e(t)})}isStarted(){return this._isStarted}dial(e,t){i(this.isStarted(),v),this._getPeerInfo(e,(e,r)=>{if(e)return t(e);this._switch.dial(r,e=>{if(e)return t(e);this.peerBook.put(r),t()})})}dialProtocol(e,t,r){i(this.isStarted(),v),"function"==typeof t&&(r=t,t=void 0),this._getPeerInfo(e,(e,n)=>{if(e)return r(e);this._switch.dial(n,t,(e,t)=>{if(e)return r(e);this.peerBook.put(n),r(null,t)})})}hangUp(e,t){i(this.isStarted(),v),this._getPeerInfo(e,(e,r)=>{if(e)return t(e);this._switch.hangUp(r,t)})}ping(e,t){if(!this.isStarted())return t(new Error(v));this._getPeerInfo(e,(e,r)=>{if(e)return t(e);t(null,new f(this._switch,r))})}handle(e,t,r){this._switch.handle(e,t,r)}unhandle(e){this._switch.unhandle(e)}}}).call(this,r(6))},function(e,t,r){"use strict";const n=r(10).EventEmitter,i=r(50),o=r(49),s=r(1198),a=r(1202),u=r(574),c=r(1290),f=r(1291),l=r(573),h=r(1292),p=r(1293),d=r(16),y=r(1297);e.exports=class extends n{constructor(e,t,r){super(),d(e,"You must provide a `peerInfo`"),d(t,"You must provide a `peerBook`"),this._peerInfo=e,this._peerBook=t,this._options=r||{},this.setMaxListeners(1/0),this.transports={},this.conns={},this.muxedConns={},this.protocols={},this.muxers={},this.identify=!1,this.crypto=l,this.protector=this._options.protector||null,this.transport=new s(this),this.connection=new a(this),this.observer=h(this),this.stats=p(this.observer,this._options.stats),this.protocolMuxer=f(this.protocols,this.observer),this.handle(this.crypto.tag,(e,t)=>{const r=this._peerInfo.id,n=this.crypto.encrypt(r,t,void 0,()=>{});return this.protocolMuxer(null)(n)}),this.dial=c(this)}availableTransports(e){const t=e.multiaddrs.toArray();return Object.keys(this.transports).filter(e=>this.transports[e].filter(t).length>0).sort(e=>"Circuit"===e?1:0)}start(e){i(this.availableTransports(this._peerInfo),(e,t)=>{this.transport.listen(e,{},null,t)},e)}stop(e){this.stats.stop(),o([e=>i(this.muxedConns,(e,t)=>{if(!e)return t();e.muxer.end(e=>{if(e&&"Fatal error: OK"!==e.message)return t(e);t()})},e),e=>{i(this.transports,(e,t)=>{i(e.listeners,(e,t)=>{e.close(t)},t)},e)}],e)}handle(e,t,r){this.protocols[e]={handlerFunc:t,matchFunc:r}}unhandle(e){this.protocols[e]&&delete this.protocols[e]}hangUp(e,t){const r=u(e,this.peerBook).id.toB58String();if(this.muxedConns[r]){const e=this.muxedConns[r].muxer;e.once("close",()=>{delete this.muxedConns[r],t()}),e.end()}else t()}hasTransports(){const e=Object.keys(this.transports).filter(e=>"Circuit"!==e);return e&&e.length>0}},e.exports.errors=y},function(e,t,r){"use strict";const n=r(59),i=r(30),o=r(1)("libp2p:switch:transport"),s=r(1199),a=8,u=3e4;class c{constructor(e){this.switch=e,this.dialer=new s(a,u)}add(e,t){if(o("adding %s",e),this.switch.transports[e])throw new Error("There is already a transport with this key");this.switch.transports[e]=t,this.switch.transports[e].listeners||(this.switch.transports[e].listeners=[])}dial(e,t,r){const n=this.switch.transports[e];let i=t.multiaddrs.toArray();Array.isArray(i)||(i=[i]),i=c.dialables(n,i),o("dialing %s",e,i.map(e=>e.toString())),this.dialer.dialMany(t.id,n,i,(e,n)=>{if(e)return r(e);t.connect(n.multiaddr),this.switch._peerBook.put(t),r(null,n.conn)})}listen(e,t,r,o){let s;r||(r=this.switch.protocolMuxer(e)),this.switch.protector&&(s=r,r=(e=>{const t=this.switch.protector.protect(e,()=>{s(t)})}));const a=this.switch.transports[e],u=c.dialables(a,this.switch._peerInfo.multiaddrs.distinct());a.listeners||(a.listeners=[]);let f=[];const l=u.map(e=>t=>{const n=i(t),o=a.createListener(r);o.once("error",n),o.listen(e,e=>{if(e)return n(e);o.removeListener("error",n),o.getAddrs((e,t)=>{if(e)return n(e);f=f.concat(t),a.listeners.push(o),n()})})});n(l,e=>{if(e)return o(e);this.switch._peerInfo.multiaddrs.replace(u,f),o()})}close(e,t){const r=this.switch.transports[e];if(!r)return t(new Error(`Trying to close non existing transport: ${e}`));n(r.listeners.map(e=>t=>{e.close(t)}),t)}static dialables(e,t){return e.filter(t)}}e.exports=c},function(e,t,r){"use strict";const n=r(80),i=r(1),o=r(30),s=i("libp2p:swarm:dialer"),a=r(1200);e.exports=class{constructor(e,t){s("create: %s peer limit, %s dial timeout",e,t),this.perPeerLimit=e,this.dialTimeout=t,this.queues=new Map}dialMany(e,t,r,i){s("dialMany:start");const a={cancel:!1};i=o(i),n(r,(r,n)=>{this.dialSingle(e,t,r,a,n)},(e,t)=>{if(e)return i(e);const r=t.filter(e=>e.conn);if(r.length>0)return s("dialMany:success"),i(null,r[0]);s("dialMany:error");const n=new Error("Failed to dial any provided address");return n.errors=t.filter(e=>e.error).map(e=>e.error),i(n)})}dialSingle(e,t,r,n,i){const o=e.toB58String();let u;s("dialSingle: %s:%s",o,r.toString()),this.queues.has(o)?u=this.queues.get(o):(u=new a(this.perPeerLimit,this.dialTimeout),this.queues.set(o,u)),u.push(t,r,n,i)}}},function(e,t,r){"use strict";const n=r(47).Connection,i=r(8),o=r(1201),s=r(162),a=r(1)("libp2p:swarm:dialer:queue");e.exports=class{constructor(e,t){this.dialTimeout=t,this.queue=s((e,t)=>{this._doWork(e.transport,e.addr,e.token,t)},e)}_doWork(e,t,r,o){a("work"),this._dialWithTimeout(e,t,(e,s)=>e?(a("work:error"),o(null,{error:e})):r.cancel?(a("work:cancel"),i(i.empty(),s),o(null,{cancel:!0})):(r.cancel=!0,a("work:success"),(new n).setInnerConn(s),void o(null,{multiaddr:t,conn:s})))}_dialWithTimeout(e,t,r){o(r=>{const n=e.dial(t,e=>{if(e)return r(e);r(null,n)})},this.dialTimeout)(r)}push(e,t,r,n){this.queue.push({transport:e,addr:t,token:r},n)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){var o=(0,i.default)(e);return(0,n.default)(function(n,i){var s,a=!1;n.push(function(){a||(i.apply(null,arguments),clearTimeout(s))}),s=setTimeout(function(){var t=e.name||"anonymous",n=new Error('Callback function "'+t+'" timed out.');n.code="ETIMEDOUT",r&&(n.info=r),a=!0,i(n)},t),o.apply(null,n)})};var n=o(r(350)),i=o(r(34));function o(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default},function(e,t,r){"use strict";const n=r(1203),i=r(305),o=r(5),s=r(1)("libp2p:switch:connection"),a=r(30),u=r(3),c=r(562),f=r(573);e.exports=class{constructor(e){this.switch=e}addStreamMuxer(e){this.switch.muxers[e.multicodec]=e,this.switch.handle(e.multicodec,(t,r)=>{const c=e.listener(r);return c.on("stream",this.switch.protocolMuxer(null)),this.switch.identify&&r.getPeerInfo((e,t)=>{!e&&t||s("crypto peerInfo wasnt found"),r.getPeerInfo=(e=>{const r=c.newStream(),s=new i.Dialer;e=a(e),o([e=>s.handle(r,e),e=>s.select(n.multicodec,e),(e,r)=>n.dialer(e,t,r),(e,t,r)=>{t.forEach(e=>{this.switch._peerInfo.multiaddrs.addSafe(e)}),r(null,e)}],(t,n)=>{if(t)return c.end(()=>{n&&u(()=>this.switch.emit("peer-mux-closed",n)),e(t,null)});n&&r.setPeerInfo(n),e(t,n)})}),r.getPeerInfo((e,t)=>{if(e)return s("identify not successful");const r=t.id.toB58String();this.switch.muxedConns[r]={muxer:c},t.multiaddrs.size>0?t.connect(t.multiaddrs.toArray()[0]):t.connect(`/ipfs/${r}`),t=this.switch._peerBook.put(t),c.on("close",()=>{delete this.switch.muxedConns[r],t.disconnect(),t=this.switch._peerBook.put(t),s(`closed connection to ${r}`),u(()=>this.switch.emit("peer-mux-closed",t))}),u(()=>this.switch.emit("peer-mux-established",t))})}),r})}crypto(e,t){e||t||(e=f.tag,t=f.encrypt),this.switch.unhandle(this.switch.crypto.tag),this.switch.handle(e,(e,r)=>{const n=this.switch._peerInfo.id,i=t(n,r,void 0,()=>{this.switch.protocolMuxer(null)(i)})}),this.switch.crypto={tag:e,encrypt:t}}enableCircuitRelay(e){(e=e||{}).enabled&&(e.hop||Object.assign(e,{hop:{enabled:!1,active:!1}}),this.switch.transport.add(c.tag,new c(this.switch,e)))}reuse(){this.switch.identify=!0,this.switch.handle(n.multicodec,(e,t)=>{n.listener(t,this.switch._peerInfo)})}}},function(e,t,r){"use strict";(t=e.exports).multicodec="/ipfs/id/1.0.0",t.listener=r(1204),t.dialer=r(1205),t.message=r(301)},function(e,t,r){"use strict";(function(t){const n=r(8),i=r(53),o=r(301);e.exports=((e,r)=>{e.getObservedAddrs((s,a)=>{if(s)return;a=a[0];let u=t.alloc(0);r.id.pubKey&&(u=r.id.pubKey.bytes);const c=o.encode({protocolVersion:"ipfs/0.1.0",agentVersion:"na",publicKey:u,listenAddrs:r.multiaddrs.toArray().map(e=>e.buffer),observedAddr:a?a.buffer:t.from("")});n(n.values([c]),i.encode(),e)})})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(51),i=r(1206),o=r(52),s=r(8),a=r(53),u=r(301);e.exports=((e,t,r)=>{"function"==typeof t&&(r=t,t=null,console.warn("WARNING: no expected peer info was given, identify will not be able to verify peer integrity")),s(e,a.decode(),s.take(1),s.collect((e,s)=>{if(e)return r(e);if(0===s.length)return r(new Error("conn was closed, did not receive data"));const a=u.decode(s[0]);i.createFromPubKey(a.publicKey,(e,i)=>{if(e)return r(e);const s=new n(i);if(t&&t.id.toB58String()!==i.toB58String())return r(new Error("invalid peer"));try{a.listenAddrs.map(o).forEach(e=>s.multiaddrs.add(e))}catch(e){return r(e)}let u;try{u=function(e){if(!function(e){return e.observedAddr&&e.observedAddr.length>0}(e))return[];let t=e.observedAddr;return Array.isArray(t)||(t=[t]),t.map(e=>o(e))}(a)}catch(e){return r(e)}r(null,s,u)})}))})},function(e,t,r){"use strict";(function(n){const i=r(12),o=r(1207),s=r(16),a=r(5);class u{constructor(e,t,r){s(n.isBuffer(e),"invalid id provided"),t&&r&&s(t.public.bytes.equals(r.bytes),"inconsistent arguments"),this._id=e,this._idB58String=i.toB58String(this.id),this._privKey=t,this._pubKey=r}get id(){return this._id}set id(e){throw new Error("Id is immutable")}get privKey(){return this._privKey}set privKey(e){this._privKey=e}get pubKey(){return this._pubKey?this._pubKey:this._privKey?this._privKey.public:void 0}set pubKey(e){this._pubKey=e}marshalPubKey(){if(this.pubKey)return o.keys.marshalPublicKey(this.pubKey)}marshalPrivKey(){if(this.privKey)return o.keys.marshalPrivateKey(this.privKey)}toPrint(){return this.toJSON()}toJSON(){return{id:this.toB58String(),privKey:c(this.marshalPrivKey()),pubKey:c(this.marshalPubKey())}}toHexString(){return i.toHexString(this.id)}toBytes(){return this.id}toB58String(){return this._idB58String}isEqual(e){if(n.isBuffer(e))return this.id.equals(e);if(e.id)return this.id.equals(e.id);throw new Error("not valid Id")}isValid(e){this.privKey&&this.privKey.public&&this.privKey.public.bytes&&n.isBuffer(this.pubKey.bytes)&&this.privKey.public.bytes.equals(this.pubKey.bytes)?e():e(new Error("Keys not match"))}}function c(e){if(e)return e.toString("base64")}(t=e.exports=u).create=function(e,t){"function"==typeof e&&(t=e,e={}),(e=e||{}).bits=e.bits||2048,a([t=>o.keys.generateKeyPair("RSA",e.bits,t),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n))})},t.createFromHexString=function(e){return new u(i.fromHexString(e))},t.createFromBytes=function(e){return new u(e)},t.createFromB58String=function(e){return new u(i.fromB58String(e))},t.createFromPubKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r;try{let i=e;if("string"==typeof i&&(i=n.from(e,"base64")),!n.isBuffer(i))throw new Error("Supplied key is neither a base64 string nor a buffer");r=o.keys.unmarshalPublicKey(i)}catch(e){return t(e)}r.hash((e,n)=>{if(e)return t(e);t(null,new u(n,null,r))})},t.createFromPrivKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r=e;try{if("string"==typeof r&&(r=n.from(e,"base64")),!n.isBuffer(r))throw new Error("Supplied key is neither a base64 string nor a buffer")}catch(e){return t(e)}a([e=>o.keys.unmarshalPrivateKey(r,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n,n.public))})},t.createFromJSON=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r,s,c,f;try{r=i.fromB58String(e.id),s=e.privKey&&n.from(e.privKey,"base64"),c=e.pubKey&&n.from(e.pubKey,"base64"),f=c&&o.keys.unmarshalPublicKey(c)}catch(e){return t(e)}s?a([e=>o.keys.unmarshalPrivateKey(s,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)}),(e,t,r)=>{f?f.hash((n,i)=>{r(n,e,t,i)}):r(null,e,t)}],(e,n,i,o)=>e?t(e):f&&!n.equals(o)?t(new Error("Public and private key do not match")):r&&!n.equals(r)?t(new Error("Id and private key do not match")):void t(null,new u(r,i,f))):t(null,new u(r,null,f))},t.isPeerId=function(e){return Boolean("object"==typeof e&&e._id&&e._idB58String)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(551),i=r(1209),o=r(1211);(t=e.exports).aes=i,t.hmac=n,t.keys=o,t.randomBytes=r(556),t.pbkdf2=r(1222)},function(e,t,r){"use strict";e.exports={SHA1:20,SHA256:32,SHA512:64}},function(e,t,r){"use strict";const n=r(1210),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(66);e.exports={createCipheriv:n.createCipheriv,createDecipheriv:n.createDecipheriv}},function(e,t,r){"use strict";(function(n){const i=r(11)(r(304)),o=r(17);t=e.exports;const s={rsa:r(1212),ed25519:r(1217),secp256k1:r(69)(i,r(556))};function a(e){return void 0!==s[e.toLowerCase()]}t.supportedKeys=s,t.keysPBM=i,t.keyStretcher=r(1219),t.generateEphemeralKeyPair=r(1220),t.generateKeyPair=((e,t,r)=>{let 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)=>{let 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){"use strict";const n=r(552),i=r(11),o=r(14),s=r(554),a=i(r(304)),u=r(17),c=r(3);class f{constructor(e){this._key=e}verify(e,t,r){h(r),s.hashAndVerify(this._key,t,e,r)}marshal(){return s.utils.jwkToPkix(this._key)}get bytes(){return a.PublicKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}encrypt(e){return this._key.encrypt(e,"RSAES-PKCS1-V1_5")}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(e),n(this.bytes,"sha2-256",e)}}class l{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return s.getRandomValues(new Uint8Array(16))}sign(e,t){h(t),s.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){s.decrypt(this._key,e,t)}marshal(){return s.utils.jwkToPkcs1(this._key)}get bytes(){return a.PrivateKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(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"),h(r),c(()=>{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 h(e){if("function"!=typeof e)throw new Error("callback is required")}e.exports={RsaPublicKey:f,RsaPrivateKey:l,unmarshalRsaPublicKey:function(e){const t=s.utils.pkixToJwk(e);return new f(t)},unmarshalRsaPrivateKey:function(e,t){const r=s.utils.pkcs1ToJwk(e);s.unmarshalPrivateKey(r,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},generateKeyPair:function(e,t){s.generateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},fromJwk:function(e,t){s.unmarshalPrivateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})}}},function(e,t,r){"use strict";(function(t){const n=r(42),i=r(43),o=r(553),s=r(1214),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,256)),shake256:a(u(n.shake_256,512)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(1215),dblSha2256:(e,r)=>{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(44),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;function o(e){if(!i)throw new Error("Please use a browser with webcrypto support");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(45),i=r(553).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(15),i=r(555),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())}),u=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()))}),c=n.define("RSAPublicKey",function(){this.seq().obj(this.key("algorithm").use(u),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=c.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 c.encode({algorithm:{algorithm:"rsa",none:null},subjectPublicKey:{data:f.encode({modulus:s(e.n),publicExponent:s(e.e)},"der")}},"der")}},function(e,t,r){"use strict";(function(t){const n=r(552),i=r(11),o=r(14),s=r(1218),a=i(r(304));class u{constructor(e){this._key=l(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 c{constructor(e,t){this._key=l(e,s.privateKeyLength),this._publicKey=l(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 u(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 l(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:u,Ed25519PrivateKey:c,unmarshalEd25519PrivateKey:function(e,t){try{e=l(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 c(r,n))},unmarshalEd25519PublicKey:function(e){return e=l(e,s.publicKeyLength),new u(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 c(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 c(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(68),i=r(3);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){"use strict";(function(t){const n=r(40),i=r(551),o={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,cipherKeySize:32}};e.exports=((e,r,s,a)=>{const u=o[e];if(!u)return a(new Error("unkown cipherType passed"));if(!r)return a(new Error("unkown hashType passed"));const c=u.keySize,f=u.ivSize,l=t.from("key expansion"),h=2*(f+c+20);i.create(r,s,(e,r)=>{if(e)return a(e);r.digest(l,(e,i)=>{if(e)return a(e);let o=[],s=0;n(()=>s{if(t)return e(t);let a=n.length;s+a>h&&(a=h-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=h/2,n=t.concat(o),i=n.slice(0,r),s=n.slice(r,h),u=e=>({iv:e.slice(0,f),cipherKey:e.slice(f,f+c),macKey:e.slice(f+c)});a(null,{k1:u(i),k2:u(s)})})})})})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(1221);e.exports=((e,t)=>{n.generateEphmeralKeyPair(e,t)})},function(e,t,r){"use strict";(function(e){const n=r(303)(),i=r(302),o=r(15).bignum,s=r(555),a=s.toBase64,u=s.toBn,c={"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 o=(o,s,a)=>{let u;"function"==typeof s&&(a=s,s=void 0),u=s?n.subtle.importKey("jwk",p(t,s),{name:"ECDH",namedCurve:t},!1,["deriveBits"]):Promise.resolve(r.privateKey);const f=Promise.all([n.subtle.importKey("jwk",h(t,o),{name:"ECDH",namedCurve:t},!1,[]),u]);i(f.then(e=>n.subtle.deriveBits({name:"ECDH",namedCurve:t,public:e[0]},e[1],c[t])).then(t=>e.from(t)),a)};return n.subtle.exportKey("jwk",r.publicKey).then(e=>({key:l(e),genSharedKey:o}))}),r)};const f={"P-256":32,"P-384":48,"P-521":66};function l(t){const r=f[t.crv];return e.concat([e.from([4]),u(t.x).toArrayLike(e,"be",r),u(t.y).toArrayLike(e,"be",r)],1+2*r)}function h(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}}function p(e,t){const r=h(e,t.public);return r.d=a(new o(t.private)),r}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(17),i={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};e.exports=function(e,t,r,o,s){const a=i[s];if(!a)throw new Error(`Hash '${s}' is unknown or not supported`);const u=n.pkcs5.pbkdf2(e,t,r,o,a);return n.util.encode64(u)}},function(e,t,r){"use strict";const n=r(8),i=r(557),o=r(16),s=r(558),a=r(1224),u=r(1226),c=r(560),f=r(195),l=r(47).Connection,h=r(561).PROTOCOL_ID;e.exports=class{constructor(){this.handlers={ls:{handlerFunc:(e,t)=>u(this,t),matchFunc:c}},this.log=f.log.listener()}handle(e,t){this.log("listener handle conn");const r=s(h,(r,i)=>{if(r)return t(r);const o=new l(i,e),s=a(o,this.handlers,this.log);n(o,s,o),t()},this.log);n(e,r,e)}addHandler(e,t,r){this.log("adding handler: "+e),o(i(t),"handler must be a function"),this.handlers[e]&&this.log("overwriting handler for "+e),r||(r=c),this.handlers[e]={handlerFunc:t,matchFunc:r}}}},function(e,t,r){"use strict";(function(t){const n=r(101),i=r(53),o=r(47).Connection,s=r(195).writeEncoded,a=r(1225);function u(e,t,r){const n=Object.keys(t);let i=!1;a(n,(r,n)=>{t[r].matchFunc(r,e,(e,t)=>{if(e)return n(e);t&&(i=r),n()})},e=>{if(e)return r(e);r(null,i)})}e.exports=function(e,r,a){const c=e=>{a.error(e)},f=n({timeout:6e4},c),l=f.handshake;return function n(){i.decodeFromReader(l,(i,f)=>{if(i)return c(i);a("received:",f.toString());const h=f.toString().slice(0,-1);u(h,r,(i,u)=>{if(i)return c(i);const p=u;if(p){a("send ack back of: "+h),s(l,f,c);const t=new o(l.rest(),e);r[p].handlerFunc(h,t)}else a("not supported protocol: "+h),s(l,t.from("na\n")),n()})})}(),f}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=s(r(559)),i=s(r(164)),o=s(r(306));function s(e){return e&&e.__esModule?e:{default:e}}t.default=(0,i.default)((0,n.default)(Boolean,o.default)),e.exports=t.default},function(e,t,r){"use strict";(function(t){const n=r(8),i=r(53),o=r(20);e.exports=function(e,r){const s=Object.keys(e.handlers).filter(e=>"ls"!==e),a=s.length,u=s.reduce((e,r)=>{const n=t.from(r+"\n");return e+o.encodingLength(n.length)},0),c=t.concat([t.from(o.encode(a)),t.from(o.encode(u)),t.from("\n")]),f=s.map(e=>t.from(e+"\n")),l=[c].concat(f);n(n.values(l),i.encode(),r)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(20),i=r(8),o=r(53),s=r(47).Connection,a=r(195),u=r(558),c=r(30),f=r(561).PROTOCOL_ID;function l(e){return e.toString().slice(0,-1)}e.exports=class{constructor(){this.conn=null,this.log=a.log.dialer()}handle(e,t){this.log("dialer handle conn"),t=c(t);const r=u(f,(r,n)=>{if(r)return t(r);this.log("handshake success"),this.conn=new s(n,e),t()},this.log);i(e,r,e)}select(e,t){if(this.log("dialer select "+e),t=c(t),!this.conn)return t(new Error("multistream handshake has not finalized yet"));const r=u(e,(e,r)=>{if(e)return this.conn=new s(r,this.conn),t(e);t(null,new s(r,this.conn))},this.log);i(this.conn,r,this.conn)}ls(e){e=c(e);const t=u("ls",(t,r)=>{if(t)return e(t);i(r,o.decode(),function(e){let t=0;return i.take(e=>(n.decode(e),t=n.decode(e,n.decode.bytes),!0))}(),i.map(l),i.collect((t,r)=>{if(t)return e(t);e(null,r.slice(1))}))},this.log);i(this.conn,t,this.conn)}}},function(e,t,r){"use strict";const n=r(1229);e.exports=function(e,t,r){const i=e.split("/"),o=t.split("/"),s=i[1],a=i[2],u=o[1],c=o[2];if(s!==u)return r(null,!1);r(null,n.satisfies(a,"~"+c))}},function(e,t,r){(function(r){var n;t=e.exports=$,n="object"==typeof r&&r.env&&r.env.NODE_DEBUG&&/\bsemver\b/i.test(r.env.NODE_DEBUG)?function(){var e=Array.prototype.slice.call(arguments,0);e.unshift("SEMVER"),console.log.apply(console,e)}:function(){},t.SEMVER_SPEC_VERSION="2.0.0";var i=256,o=Number.MAX_SAFE_INTEGER||9007199254740991,s=t.re=[],a=t.src=[],u=0,c=u++;a[c]="0|[1-9]\\d*";var f=u++;a[f]="[0-9]+";var l=u++;a[l]="\\d*[a-zA-Z-][a-zA-Z0-9-]*";var h=u++;a[h]="("+a[c]+")\\.("+a[c]+")\\.("+a[c]+")";var p=u++;a[p]="("+a[f]+")\\.("+a[f]+")\\.("+a[f]+")";var d=u++;a[d]="(?:"+a[c]+"|"+a[l]+")";var y=u++;a[y]="(?:"+a[f]+"|"+a[l]+")";var g=u++;a[g]="(?:-("+a[d]+"(?:\\."+a[d]+")*))";var m=u++;a[m]="(?:-?("+a[y]+"(?:\\."+a[y]+")*))";var b=u++;a[b]="[0-9A-Za-z-]+";var v=u++;a[v]="(?:\\+("+a[b]+"(?:\\."+a[b]+")*))";var _=u++,w="v?"+a[h]+a[g]+"?"+a[v]+"?";a[_]="^"+w+"$";var S="[v=\\s]*"+a[p]+a[m]+"?"+a[v]+"?",k=u++;a[k]="^"+S+"$";var E=u++;a[E]="((?:<|>)?=?)";var A=u++;a[A]=a[f]+"|x|X|\\*";var x=u++;a[x]=a[c]+"|x|X|\\*";var I=u++;a[I]="[v=\\s]*("+a[x]+")(?:\\.("+a[x]+")(?:\\.("+a[x]+")(?:"+a[g]+")?"+a[v]+"?)?)?";var T=u++;a[T]="[v=\\s]*("+a[A]+")(?:\\.("+a[A]+")(?:\\.("+a[A]+")(?:"+a[m]+")?"+a[v]+"?)?)?";var B=u++;a[B]="^"+a[E]+"\\s*"+a[I]+"$";var C=u++;a[C]="^"+a[E]+"\\s*"+a[T]+"$";var P=u++;a[P]="(?:^|[^\\d])(\\d{1,16})(?:\\.(\\d{1,16}))?(?:\\.(\\d{1,16}))?(?:$|[^\\d])";var O=u++;a[O]="(?:~>?)";var R=u++;a[R]="(\\s*)"+a[O]+"\\s+",s[R]=new RegExp(a[R],"g");var N=u++;a[N]="^"+a[O]+a[I]+"$";var L=u++;a[L]="^"+a[O]+a[T]+"$";var j=u++;a[j]="(?:\\^)";var M=u++;a[M]="(\\s*)"+a[j]+"\\s+",s[M]=new RegExp(a[M],"g");var K=u++;a[K]="^"+a[j]+a[I]+"$";var D=u++;a[D]="^"+a[j]+a[T]+"$";var U=u++;a[U]="^"+a[E]+"\\s*("+S+")$|^$";var F=u++;a[F]="^"+a[E]+"\\s*("+w+")$|^$";var q=u++;a[q]="(\\s*)"+a[E]+"\\s*("+S+"|"+a[I]+")",s[q]=new RegExp(a[q],"g");var H=u++;a[H]="^\\s*("+a[I]+")\\s+-\\s+("+a[I]+")\\s*$";var z=u++;a[z]="^\\s*("+a[T]+")\\s+-\\s+("+a[T]+")\\s*$";var V=u++;a[V]="(<|>)?=?\\s*\\*";for(var G=0;Gi)return null;if(!(t?s[k]:s[_]).test(e))return null;try{return new $(e,t)}catch(e){return null}}function $(e,t){if(e instanceof $){if(e.loose===t)return e;e=e.version}else if("string"!=typeof e)throw new TypeError("Invalid Version: "+e);if(e.length>i)throw new TypeError("version is longer than "+i+" characters");if(!(this instanceof $))return new $(e,t);n("SemVer",e,t),this.loose=t;var r=e.trim().match(t?s[k]:s[_]);if(!r)throw new TypeError("Invalid Version: "+e);if(this.raw=e,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>o||this.major<0)throw new TypeError("Invalid major version");if(this.minor>o||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>o||this.patch<0)throw new TypeError("Invalid patch version");r[4]?this.prerelease=r[4].split(".").map(function(e){if(/^[0-9]+$/.test(e)){var t=+e;if(t>=0&&t=0;)"number"==typeof this.prerelease[r]&&(this.prerelease[r]++,r=-2);-1===r&&this.prerelease.push(0)}t&&(this.prerelease[0]===t?isNaN(this.prerelease[1])&&(this.prerelease=[t,0]):this.prerelease=[t,0]);break;default:throw new Error("invalid increment argument: "+e)}return this.format(),this.raw=this.version,this},t.inc=function(e,t,r,n){"string"==typeof r&&(n=r,r=void 0);try{return new $(e,r).inc(t,n).version}catch(e){return null}},t.diff=function(e,t){if(ee(e,t))return null;var r=W(e),n=W(t);if(r.prerelease.length||n.prerelease.length){for(var i in r)if(("major"===i||"minor"===i||"patch"===i)&&r[i]!==n[i])return"pre"+i;return"prerelease"}for(var i in r)if(("major"===i||"minor"===i||"patch"===i)&&r[i]!==n[i])return i},t.compareIdentifiers=J;var Y=/^[0-9]+$/;function J(e,t){var r=Y.test(e),n=Y.test(t);return r&&n&&(e=+e,t=+t),r&&!n?-1:n&&!r?1:et?1:0}function X(e,t,r){return new $(e,r).compare(new $(t,r))}function Z(e,t,r){return X(e,t,r)>0}function Q(e,t,r){return X(e,t,r)<0}function ee(e,t,r){return 0===X(e,t,r)}function te(e,t,r){return 0!==X(e,t,r)}function re(e,t,r){return X(e,t,r)>=0}function ne(e,t,r){return X(e,t,r)<=0}function ie(e,t,r,n){var i;switch(t){case"===":"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),i=e===r;break;case"!==":"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),i=e!==r;break;case"":case"=":case"==":i=ee(e,r,n);break;case"!=":i=te(e,r,n);break;case">":i=Z(e,r,n);break;case">=":i=re(e,r,n);break;case"<":i=Q(e,r,n);break;case"<=":i=ne(e,r,n);break;default:throw new TypeError("Invalid operator: "+t)}return i}function oe(e,t){if(e instanceof oe){if(e.loose===t)return e;e=e.value}if(!(this instanceof oe))return new oe(e,t);n("comparator",e,t),this.loose=t,this.parse(e),this.semver===se?this.value="":this.value=this.operator+this.semver.version,n("comp",this)}t.rcompareIdentifiers=function(e,t){return J(t,e)},t.major=function(e,t){return new $(e,t).major},t.minor=function(e,t){return new $(e,t).minor},t.patch=function(e,t){return new $(e,t).patch},t.compare=X,t.compareLoose=function(e,t){return X(e,t,!0)},t.rcompare=function(e,t,r){return X(t,e,r)},t.sort=function(e,r){return e.sort(function(e,n){return t.compare(e,n,r)})},t.rsort=function(e,r){return e.sort(function(e,n){return t.rcompare(e,n,r)})},t.gt=Z,t.lt=Q,t.eq=ee,t.neq=te,t.gte=re,t.lte=ne,t.cmp=ie,t.Comparator=oe;var se={};function ae(e,t){if(e instanceof ae)return e.loose===t?e:new ae(e.raw,t);if(e instanceof oe)return new ae(e.value,t);if(!(this instanceof ae))return new ae(e,t);if(this.loose=t,this.raw=e,this.set=e.split(/\s*\|\|\s*/).map(function(e){return this.parseRange(e.trim())},this).filter(function(e){return e.length}),!this.set.length)throw new TypeError("Invalid SemVer Range: "+e);this.format()}function ue(e,t){return n("comp",e),e=function(e,t){return e.trim().split(/\s+/).map(function(e){return function(e,t){n("caret",e,t);var r=t?s[D]:s[K];return e.replace(r,function(t,r,i,o,s){var a;return n("caret",e,t,r,i,o,s),ce(r)?a="":ce(i)?a=">="+r+".0.0 <"+(+r+1)+".0.0":ce(o)?a="0"===r?">="+r+"."+i+".0 <"+r+"."+(+i+1)+".0":">="+r+"."+i+".0 <"+(+r+1)+".0.0":s?(n("replaceCaret pr",s),"-"!==s.charAt(0)&&(s="-"+s),a="0"===r?"0"===i?">="+r+"."+i+"."+o+s+" <"+r+"."+i+"."+(+o+1):">="+r+"."+i+"."+o+s+" <"+r+"."+(+i+1)+".0":">="+r+"."+i+"."+o+s+" <"+(+r+1)+".0.0"):(n("no pr"),a="0"===r?"0"===i?">="+r+"."+i+"."+o+" <"+r+"."+i+"."+(+o+1):">="+r+"."+i+"."+o+" <"+r+"."+(+i+1)+".0":">="+r+"."+i+"."+o+" <"+(+r+1)+".0.0"),n("caret return",a),a})}(e,t)}).join(" ")}(e,t),n("caret",e),e=function(e,t){return e.trim().split(/\s+/).map(function(e){return function(e,t){var r=t?s[L]:s[N];return e.replace(r,function(t,r,i,o,s){var a;return n("tilde",e,t,r,i,o,s),ce(r)?a="":ce(i)?a=">="+r+".0.0 <"+(+r+1)+".0.0":ce(o)?a=">="+r+"."+i+".0 <"+r+"."+(+i+1)+".0":s?(n("replaceTilde pr",s),"-"!==s.charAt(0)&&(s="-"+s),a=">="+r+"."+i+"."+o+s+" <"+r+"."+(+i+1)+".0"):a=">="+r+"."+i+"."+o+" <"+r+"."+(+i+1)+".0",n("tilde return",a),a})}(e,t)}).join(" ")}(e,t),n("tildes",e),e=function(e,t){return n("replaceXRanges",e,t),e.split(/\s+/).map(function(e){return function(e,t){e=e.trim();var r=t?s[C]:s[B];return e.replace(r,function(t,r,i,o,s,a){n("xRange",e,t,r,i,o,s,a);var u=ce(i),c=u||ce(o),f=c||ce(s);return"="===r&&f&&(r=""),u?t=">"===r||"<"===r?"<0.0.0":"*":r&&f?(c&&(o=0),f&&(s=0),">"===r?(r=">=",c?(i=+i+1,o=0,s=0):f&&(o=+o+1,s=0)):"<="===r&&(r="<",c?i=+i+1:o=+o+1),t=r+i+"."+o+"."+s):c?t=">="+i+".0.0 <"+(+i+1)+".0.0":f&&(t=">="+i+"."+o+".0 <"+i+"."+(+o+1)+".0"),n("xRange return",t),t})}(e,t)}).join(" ")}(e,t),n("xrange",e),e=function(e,t){return n("replaceStars",e,t),e.trim().replace(s[V],"")}(e,t),n("stars",e),e}function ce(e){return!e||"x"===e.toLowerCase()||"*"===e}function fe(e,t,r,n,i,o,s,a,u,c,f,l,h){return((t=ce(r)?"":ce(n)?">="+r+".0.0":ce(i)?">="+r+"."+n+".0":">="+t)+" "+(a=ce(u)?"":ce(c)?"<"+(+u+1)+".0.0":ce(f)?"<"+u+"."+(+c+1)+".0":l?"<="+u+"."+c+"."+f+"-"+l:"<="+a)).trim()}function le(e,t){for(var r=0;r0){var i=e[r].semver;if(i.major===t.major&&i.minor===t.minor&&i.patch===t.patch)return!0}return!1}return!0}function he(e,t,r){try{t=new ae(t,r)}catch(e){return!1}return t.test(e)}function pe(e,t,r,n){var i,o,s,a,u;switch(e=new $(e,n),t=new ae(t,n),r){case">":i=Z,o=ne,s=Q,a=">",u=">=";break;case"<":i=Q,o=re,s=Z,a="<",u="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(he(e,t,n))return!1;for(var c=0;c=0.0.0")),f=f||e,l=l||e,i(e.semver,f.semver,n)?f=e:s(e.semver,l.semver,n)&&(l=e)}),f.operator===a||f.operator===u)return!1;if((!l.operator||l.operator===a)&&o(e,l.semver))return!1;if(l.operator===u&&s(e,l.semver))return!1}return!0}oe.prototype.parse=function(e){var t=this.loose?s[U]:s[F],r=e.match(t);if(!r)throw new TypeError("Invalid comparator: "+e);this.operator=r[1],"="===this.operator&&(this.operator=""),r[2]?this.semver=new $(r[2],this.loose):this.semver=se},oe.prototype.toString=function(){return this.value},oe.prototype.test=function(e){return n("Comparator.test",e,this.loose),this.semver===se||("string"==typeof e&&(e=new $(e,this.loose)),ie(e,this.operator,this.semver,this.loose))},oe.prototype.intersects=function(e,t){if(!(e instanceof oe))throw new TypeError("a Comparator is required");var r;if(""===this.operator)return r=new ae(e.value,t),he(this.value,r,t);if(""===e.operator)return r=new ae(this.value,t),he(e.semver,r,t);var n=!(">="!==this.operator&&">"!==this.operator||">="!==e.operator&&">"!==e.operator),i=!("<="!==this.operator&&"<"!==this.operator||"<="!==e.operator&&"<"!==e.operator),o=this.semver.version===e.semver.version,s=!(">="!==this.operator&&"<="!==this.operator||">="!==e.operator&&"<="!==e.operator),a=ie(this.semver,"<",e.semver,t)&&(">="===this.operator||">"===this.operator)&&("<="===e.operator||"<"===e.operator),u=ie(this.semver,">",e.semver,t)&&("<="===this.operator||"<"===this.operator)&&(">="===e.operator||">"===e.operator);return n||i||o&&s||a||u},t.Range=ae,ae.prototype.format=function(){return this.range=this.set.map(function(e){return e.join(" ").trim()}).join("||").trim(),this.range},ae.prototype.toString=function(){return this.range},ae.prototype.parseRange=function(e){var t=this.loose;e=e.trim(),n("range",e,t);var r=t?s[z]:s[H];e=e.replace(r,fe),n("hyphen replace",e),e=e.replace(s[q],"$1$2$3"),n("comparator trim",e,s[q]),e=(e=(e=e.replace(s[R],"$1~")).replace(s[M],"$1^")).split(/\s+/).join(" ");var i=t?s[U]:s[F],o=e.split(" ").map(function(e){return ue(e,t)}).join(" ").split(/\s+/);return this.loose&&(o=o.filter(function(e){return!!e.match(i)})),o.map(function(e){return new oe(e,t)})},ae.prototype.intersects=function(e,t){if(!(e instanceof ae))throw new TypeError("a Range is required");return this.set.some(function(r){return r.every(function(r){return e.set.some(function(e){return e.every(function(e){return r.intersects(e,t)})})})})},t.toComparators=function(e,t){return new ae(e,t).set.map(function(e){return e.map(function(e){return e.value}).join(" ").trim().split(" ")})},ae.prototype.test=function(e){if(!e)return!1;"string"==typeof e&&(e=new $(e,this.loose));for(var t=0;t",r)},t.outside=pe,t.prerelease=function(e,t){var r=W(e,t);return r&&r.prerelease.length?r.prerelease:null},t.intersects=function(e,t,r){return e=new ae(e,r),t=new ae(t,r),e.intersects(t)},t.coerce=function(e){if(e instanceof $)return e;if("string"!=typeof e)return null;var t=e.match(s[P]);return null==t?null:W((t[1]||"0")+"."+(t[2]||"0")+"."+(t[3]||"0"))}}).call(this,r(6))},function(e,t,r){"use strict";const n=r(78),i=r(142),o=r(1233),s=r(143),a=r(1);a("libp2p:circuit:transportdialer").err=a("libp2p:circuit:error:transportdialer");const u=r(1251);e.exports=class{static get tag(){return"Circuit"}constructor(e,t){this.options=t||{},this.swarm=e,this.dialer=null,this.utils=s(e),this.peerInfo=this.swarm._peerInfo,this.relays=this.filter(this.peerInfo.multiaddrs.toArray()),0===this.relays.length&&this.peerInfo.multiaddrs.add(`/p2p-circuit/ipfs/${this.peerInfo.id.toB58String()}`),this.dialer=new o(e,t),this.swarm.on("peer-mux-established",this.dialer.canHop.bind(this.dialer)),this.swarm.on("peer-mux-closed",e=>{this.dialer.relayPeers.delete(e.id.toB58String())})}_dialSwarmRelays(){this.relays.forEach(e=>{e.toString().split("/p2p-circuit").filter(e=>e.length).forEach(e=>{this.dialer._dialRelay(this.utils.peerInfoFromMa(i(e)))})})}dial(e,t,r){return this.dialer.dial(e,t,r)}createListener(e,t){"function"==typeof e&&(t=e,e=this.options||{});const r=u(this.swarm,e,t);return r.on("listen",this._dialSwarmRelays.bind(this)),r}filter(e){return Array.isArray(e)||(e=[e]),e.filter(e=>n.Circuit.matches(e))}}},function(e,t,r){"use strict";(function(t){const n=r(39),i=r(136),o=r(1232),s=r(307),a=r(20);function u(e){const t=[],r=e.split("/").slice(1);if(1===r.length&&""===r[0])return[];for(let n=0;n=r.length)throw v("invalid address: "+e);t.push([i,r[n]])}else t.push([i])}return t}function c(e){const t=[];return n(e,function(e){const r=_(e);t.push(r.name),e.length>1&&t.push(e[1])}),"/"+t.join("/")}function f(e){return n(e,function(e){Array.isArray(e)||(e=[e]);const t=_(e);return e.length>1?[t.code,o.toBuffer(t.code,e[1])]:[t.code]})}function l(e){return n(e,function(e){const t=_(e);return e.length>1?[t.code,o.toString(t.code,e[1])]:[t.code]})}function h(e){return g(t.concat(n(e,function(e){const r=_(e);let n=t.from(a.encode(r.code));return e.length>1&&(n=t.concat([n,e[1]])),n})))}function p(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;return a.decode(t)+a.decode.bytes}function d(e){const t=[];let r=0;for(;re.length)throw v("Invalid address buffer: "+e.toString("hex"));t.push([n,u])}return t}function y(e){return h(f(u(e=b(e))))}function g(e){const r=m(e);if(r)throw r;return t.from(e)}function m(e){try{d(e)}catch(e){return e}}function b(e){return"/"+i(e.trim().split("/")).join("/")}function v(e){return new Error("Error parsing address: "+e)}function _(e){return s(e[0])}e.exports={stringToStringTuples:u,stringTuplesToString:c,tuplesToStringTuples:l,stringTuplesToTuples:f,bufferToTuples:d,tuplesToBuffer:h,bufferToString:function(e){return c(l(d(e)))},stringToBuffer:y,fromString:function(e){return y(e)},fromBuffer:g,validateBuffer:m,isValidBuffer:function(e){return void 0===m(e)},cleanPath:b,ParseError:v,protoFromTuple:_,sizeForAddr:p}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(137),i=r(138),o=r(307),s=r(14),a=r(20);function u(e,r){return r instanceof t?u.toString(e,r):u.toBuffer(e,r)}function c(e){if(!e.isValid())throw new Error("invalid ip address");return n.toBuffer(e.address)}e.exports=u,u.toString=function(e,t){switch((e=o(e)).code){case 4:case 41:return n.toString(t);case 6:case 17:case 33:case 132:return function(e){return e.readUInt16BE(0)}(t);case 54:case 55:case 56:return function(e){const t=a.decode(e);if((e=e.slice(a.decode.bytes)).length!==t)throw new Error("inconsistent lengths");return e.toString()}(t);case 421:return function(e){const t=a.decode(e),r=e.slice(a.decode.bytes);if(r.length!==t)throw new Error("inconsistent lengths");return s.encode(r)}(t);default:return t.toString("hex")}},u.toBuffer=function(e,r){switch((e=o(e)).code){case 4:return c(new i.Address4(r));case 41:return c(new i.Address6(r));case 6:case 17:case 33:case 132:return function(e){const r=t.alloc(2);return r.writeUInt16BE(e,0),r}(parseInt(r,10));case 54:case 55:case 56:return function(e){const r=t.from(e),n=t.from(a.encode(r.length));return t.concat([n,r])}(r);case 421:return function(e){const r=t.from(s.decode(e)),n=t.from(a.encode(r.length));return t.concat([n,r])}(r);default:return t.from(r,"hex")}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(47).Connection,i=r(557),o=r(142),s=r(30),a=r(5),u=r(143),c=r(311),f=r(196),l=r(1),h=l("libp2p:circuit:dialer");h.err=l("libp2p:circuit:error:dialer");const p=r(312),d=r(144);e.exports=class{constructor(e,t){this.swarm=e,this.relayPeers=new Map,this.options=t,this.utils=u(e)}dial(e,t){t=t||(()=>{});const r=e.toString();if(!r.includes("/p2p-circuit"))return h.err("invalid circuit address"),t(new Error("invalid circuit address"));const i=r.split("p2p-circuit"),s="/"===i[0]?null:o(i[0]),a=o(i[1]||i[0]),u=new n;return setImmediate(this._dialPeer.bind(this),a,s,(e,r)=>{if(e)return h.err(e),t(e);u.setInnerConn(r),t(null,u)}),u}canHop(e,t){if(t=s(t||(()=>{})),!this.relayPeers.get(this.utils.getB58String(e))){let r;a([t=>this._dialRelay(e,t),(e,t)=>{r=e,t()},e=>r.write(d.CircuitRelay.encode({type:d.CircuitRelay.Type.CAN_HOP}),e),e=>r.read(e),(t,r)=>{if(d.CircuitRelay.decode(t).code!==d.CircuitRelay.Status.SUCCESS)return h(`HOP not supported, skipping - ${this.utils.getB58String(e)}`);h(`HOP supported adding as relay - ${this.utils.getB58String(e)}`),this.relayPeers.set(this.utils.getB58String(e),e),r(null)}],t)}return t(null)}_dialPeer(e,t,r){if(i(t)&&(r=t,t=null),r||(r=(()=>{})),e=o(e),t)return this._negotiateRelay(t,e,(e,t)=>e?(h.err("An error has occurred negotiating the relay connection",e),r(e)):r(null,t));{const t=Array.from(this.relayPeers.values());let n=i=>{if(!i){let e="no relay peers were found or all relays failed to dial";return h.err(e),r(e)}return this._negotiateRelay(i,e,(e,i)=>{if(e)return h.err(e),n(t.shift());r(null,i)})};n(t.shift())}}_negotiateRelay(e,t,r){t=o(t);const i=this.swarm._peerInfo.multiaddrs.toArray();let s;a([t=>e instanceof n?t(null,new c(e)):this._dialRelay(this.utils.peerInfoFromMa(e),t),(e,t)=>{s=e,t(null)},e=>{h(`negotiating relay for peer ${t.getPeerId()}`),s.write(d.CircuitRelay.encode({type:d.CircuitRelay.Type.HOP,srcPeer:{id:this.swarm._peerInfo.id.id,addrs:i.map(e=>e.buffer)},dstPeer:{id:f.createFromB58String(t.getPeerId()).id,addrs:[t.buffer]}}),e)},e=>s.read(e),(e,t)=>{const r=d.CircuitRelay.decode(e);return r.type!==d.CircuitRelay.Type.STATUS?t(new Error("Got invalid message type - "+`expected ${d.CircuitRelay.Type.STATUS} got ${r.type}`)):r.code!==d.CircuitRelay.Status.SUCCESS?t(new Error(`Got ${r.code} error code trying to dial over relay`)):void t(null,new n(s.rest()))}],r)}_dialRelay(e,t){t=s(t||(()=>{})),this.swarm.dial(e,p.relay,s((e,r)=>{if(e)return h.err(e),t(e);t(null,new c(r))}))}}},function(e,t,r){"use strict";const n=r(563),i=r(1236),o=r(1238);(t=e.exports).aes=i,t.hmac=n,t.keys=o,t.randomBytes=r(568),t.pbkdf2=r(1249)},function(e,t,r){"use strict";e.exports={SHA1:20,SHA256:32,SHA512:64}},function(e,t,r){"use strict";const n=r(1237),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(66);e.exports={createCipheriv:n.createCipheriv,createDecipheriv:n.createDecipheriv}},function(e,t,r){"use strict";(function(n){const i=r(11)(r(310)),o=r(17);t=e.exports;const s={rsa:r(1239),ed25519:r(1244),secp256k1:r(69)(i,r(568))};function a(e){return void 0!==s[e.toLowerCase()]}t.supportedKeys=s,t.keysPBM=i,t.keyStretcher=r(1246),t.generateEphemeralKeyPair=r(1247),t.generateKeyPair=((e,t,r)=>{let 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)=>{let 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){"use strict";const n=r(564),i=r(11),o=r(14),s=r(566),a=i(r(310)),u=r(17),c=r(3);class f{constructor(e){this._key=e}verify(e,t,r){h(r),s.hashAndVerify(this._key,t,e,r)}marshal(){return s.utils.jwkToPkix(this._key)}get bytes(){return a.PublicKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}encrypt(e){return this._key.encrypt(e,"RSAES-PKCS1-V1_5")}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(e),n(this.bytes,"sha2-256",e)}}class l{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return s.getRandomValues(new Uint8Array(16))}sign(e,t){h(t),s.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){s.decrypt(this._key,e,t)}marshal(){return s.utils.jwkToPkcs1(this._key)}get bytes(){return a.PrivateKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(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"),h(r),c(()=>{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 h(e){if("function"!=typeof e)throw new Error("callback is required")}e.exports={RsaPublicKey:f,RsaPrivateKey:l,unmarshalRsaPublicKey:function(e){const t=s.utils.pkixToJwk(e);return new f(t)},unmarshalRsaPrivateKey:function(e,t){const r=s.utils.pkcs1ToJwk(e);s.unmarshalPrivateKey(r,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},generateKeyPair:function(e,t){s.generateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},fromJwk:function(e,t){s.unmarshalPrivateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})}}},function(e,t,r){"use strict";(function(t){const n=r(42),i=r(43),o=r(565),s=r(1241),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,256)),shake256:a(u(n.shake_256,512)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(1242),dblSha2256:(e,r)=>{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(44),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;function o(e){if(!i)throw new Error("Please use a browser with webcrypto support");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(45),i=r(565).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(15),i=r(567),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())}),u=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()))}),c=n.define("RSAPublicKey",function(){this.seq().obj(this.key("algorithm").use(u),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=c.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 c.encode({algorithm:{algorithm:"rsa",none:null},subjectPublicKey:{data:f.encode({modulus:s(e.n),publicExponent:s(e.e)},"der")}},"der")}},function(e,t,r){"use strict";(function(t){const n=r(564),i=r(11),o=r(14),s=r(1245),a=i(r(310));class u{constructor(e){this._key=l(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 c{constructor(e,t){this._key=l(e,s.privateKeyLength),this._publicKey=l(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 u(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 l(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:u,Ed25519PrivateKey:c,unmarshalEd25519PrivateKey:function(e,t){try{e=l(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 c(r,n))},unmarshalEd25519PublicKey:function(e){return e=l(e,s.publicKeyLength),new u(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 c(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 c(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(68),i=r(3);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){"use strict";(function(t){const n=r(40),i=r(563),o={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,cipherKeySize:32}};e.exports=((e,r,s,a)=>{const u=o[e];if(!u)return a(new Error("unkown cipherType passed"));if(!r)return a(new Error("unkown hashType passed"));const c=u.keySize,f=u.ivSize,l=t.from("key expansion"),h=2*(f+c+20);i.create(r,s,(e,r)=>{if(e)return a(e);r.digest(l,(e,i)=>{if(e)return a(e);let o=[],s=0;n(()=>s{if(t)return e(t);let a=n.length;s+a>h&&(a=h-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=h/2,n=t.concat(o),i=n.slice(0,r),s=n.slice(r,h),u=e=>({iv:e.slice(0,f),cipherKey:e.slice(f,f+c),macKey:e.slice(f+c)});a(null,{k1:u(i),k2:u(s)})})})})})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(1248);e.exports=((e,t)=>{n.generateEphmeralKeyPair(e,t)})},function(e,t,r){"use strict";(function(e){const n=r(309)(),i=r(308),o=r(15).bignum,s=r(567),a=s.toBase64,u=s.toBn,c={"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 o=(o,s,a)=>{let u;"function"==typeof s&&(a=s,s=void 0),u=s?n.subtle.importKey("jwk",p(t,s),{name:"ECDH",namedCurve:t},!1,["deriveBits"]):Promise.resolve(r.privateKey);const f=Promise.all([n.subtle.importKey("jwk",h(t,o),{name:"ECDH",namedCurve:t},!1,[]),u]);i(f.then(e=>n.subtle.deriveBits({name:"ECDH",namedCurve:t,public:e[0]},e[1],c[t])).then(t=>e.from(t)),a)};return n.subtle.exportKey("jwk",r.publicKey).then(e=>({key:l(e),genSharedKey:o}))}),r)};const f={"P-256":32,"P-384":48,"P-521":66};function l(t){const r=f[t.crv];return e.concat([e.from([4]),u(t.x).toArrayLike(e,"be",r),u(t.y).toArrayLike(e,"be",r)],1+2*r)}function h(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}}function p(e,t){const r=h(e,t.public);return r.d=a(new o(t.private)),r}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(17),i={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};e.exports=function(e,t,r,o,s){const a=i[s];if(!a)throw new Error(`Hash '${s}' is unknown or not supported`);const u=n.pkcs5.pbkdf2(e,t,r,o,a);return n.util.encode64(u)}},function(e,t,r){"use strict";e.exports="\nmessage CircuitRelay {\n\n enum Status {\n SUCCESS = 100;\n HOP_SRC_ADDR_TOO_LONG = 220;\n HOP_DST_ADDR_TOO_LONG = 221;\n HOP_SRC_MULTIADDR_INVALID = 250;\n HOP_DST_MULTIADDR_INVALID = 251;\n HOP_NO_CONN_TO_DST = 260;\n HOP_CANT_DIAL_DST = 261;\n HOP_CANT_OPEN_DST_STREAM = 262;\n HOP_CANT_SPEAK_RELAY = 270;\n HOP_CANT_RELAY_TO_SELF = 280;\n STOP_SRC_ADDR_TOO_LONG = 320;\n STOP_DST_ADDR_TOO_LONG = 321;\n STOP_SRC_MULTIADDR_INVALID = 350;\n STOP_DST_MULTIADDR_INVALID = 351;\n STOP_RELAY_REFUSED = 390;\n MALFORMED_MESSAGE = 400;\n }\n\n enum Type { // RPC identifier, either HOP, STOP or STATUS\n HOP = 1;\n STOP = 2;\n STATUS = 3;\n CAN_HOP = 4;\n }\n\n message Peer {\n required bytes id = 1; // peer id\n repeated bytes addrs = 2; // peer's known addresses\n }\n\n optional Type type = 1; // Type of the message\n\n optional Peer srcPeer = 2; // srcPeer and dstPeer are used when Type is HOP or STATUS\n optional Peer dstPeer = 3;\n\n optional Status code = 4; // Status code, used when Type is STATUS\n}\n"},function(e,t,r){"use strict";const n=r(3),i=r(312),o=r(10).EventEmitter,s=r(142),a=r(78),u=r(1252),c=r(1253),f=r(144),l=r(143),h=r(311),p=r(1),d=p("libp2p:circuit:listener");d.err=p("libp2p:circuit:error:listener"),e.exports=((e,t,r)=>{const p=new o,y=l(e);return p.stopHandler=new u(e),p.hopHandler=new c(e,t.hop),p.listen=((t,o)=>{o=o||(()=>{}),e.handle(i.relay,(e,t)=>{const n=new h(t);n.read((e,t)=>{if(e)return void d.err(e);let i=null;try{i=f.CircuitRelay.decode(t)}catch(e){return y.writeResponse(n,f.CircuitRelay.Status.MALFORMED_MESSAGE)}switch(i.type){case f.CircuitRelay.Type.CAN_HOP:case f.CircuitRelay.Type.HOP:return p.hopHandler.handle(i,n);case f.CircuitRelay.Type.STOP:return p.stopHandler.handle(i,n,r);default:return y.writeResponse(n,f.CircuitRelay.Status.INVALID_MSG_TYPE)}})}),n(()=>p.emit("listen")),o()}),p.close=(t=>{e.unhandle(i.stop),n(()=>p.emit("close")),t()}),p.getAddrs=(t=>{let r=e._peerInfo.multiaddrs.toArray(),n=r.filter(t=>a.Circuit.matches(t)&&!t.toString().includes(e._peerInfo.id.toB58String()));n.length&&(r=n);let i=[];r.forEach(t=>{const r=`/p2p-circuit/ipfs/${e._peerInfo.id.toB58String()}`;t.toString()!==r?a.Circuit.matches(t)?i.push(t.encapsulate(`/ipfs/${e._peerInfo.id.toB58String()}`)):t.getPeerId()?i.push(s("/p2p-circuit").encapsulate(t)):i.push(s("/p2p-circuit").encapsulate(`${t}/ipfs/${e._peerInfo.id.toB58String()}`)):i.push(s(r))}),t(null,i)}),p})},function(e,t,r){"use strict";const n=r(3),i=r(10).EventEmitter,o=r(47).Connection,s=r(143),a=r(51),u=r(196),c=r(144),f=r(49),l=r(1),h=l("libp2p:circuit:stop");h.err=l("libp2p:circuit:error:stop");function p(e){return"string"==typeof e?u.createFromB58String(e):u.createFromBytes(e)}e.exports=class extends i{constructor(e){super(),this.swarm=e,this.utils=s(e)}handle(e,t,r){r=r||(()=>{}),f([r=>this.utils.validateAddrs(e,t,c.CircuitRelay.Type.STOP,r),e=>this.utils.writeResponse(t,c.CircuitRelay.Status.Success,e)],i=>{if(i)return r(),h(i);const s=new a(p(e.srcPeer.id));e.srcPeer.addrs.forEach(e=>s.multiaddrs.add(e));const u=new o(t.rest());u.setPeerInfo(s),n(()=>this.emit("connection",u)),r(u)})}}},function(e,t,r){"use strict";r(569),r(2);const n=r(8),i=r(1),o=r(51),s=r(196),a=r(10).EventEmitter,u=r(30),c=r(143),f=r(311),l=r(1254),h=r(144),p=r(142),d=r(312),y=i("libp2p:swarm:circuit:relay");y.err=i("libp2p:swarm:circuit:error:relay");e.exports=class extends a{constructor(e,t){super(),this.swarm=e,this.peerInfo=this.swarm._peerInfo,this.utils=c(e),this.config=l({active:!1,enabled:!1},t,(e,t)=>void 0!==t&&t),this.active=this.config.active}handle(e,t){if(!this.config.enabled)return this.utils.writeResponse(t,h.CircuitRelay.Status.HOP_CANT_SPEAK_RELAY);if(e.type===h.CircuitRelay.Type.CAN_HOP)return this.utils.writeResponse(t,h.CircuitRelay.Status.SUCCESS);if(s.createFromBytes(e.dstPeer.id).toB58String()===this.peerInfo.id.toB58String())return this.utils.writeResponse(t,h.CircuitRelay.Status.HOP_CANT_RELAY_TO_SELF);const r=s.createFromBytes(e.dstPeer.id).toB58String();if(!e.dstPeer.addrs.length){const t=p(`/p2p-circuit/ipfs/${r}`).buffer;e.dstPeer.addrs.push(t)}this.utils.validateAddrs(e,t,h.CircuitRelay.Type.HOP,n=>{if(n)return y(n);let i;try{if(!(i=this.swarm._peerBook.get(r)).isConnected()&&!this.active)throw new Error("No Connection to peer")}catch(n){if(!this.active)return y.err(n),setImmediate(()=>this.emit("circuit:error",n)),this.utils.writeResponse(t,h.CircuitRelay.Status.HOP_NO_CONN_TO_DST)}return this._circuit(t.rest(),e,e=>{e&&(y.err(e),setImmediate(()=>this.emit("circuit:error",e))),setImmediate(()=>this.emit("circuit:success"))})})}_circuit(e,t,r){this._dialPeer(t.dstPeer,(i,o)=>{const s=new f(e);return i?(this.utils.writeResponse(s,h.CircuitRelay.Status.HOP_CANT_DIAL_DST),n(n.empty(),s.rest()),y.err(i),r(i)):this.utils.writeResponse(s,h.CircuitRelay.Status.SUCCESS,i=>{if(i)return y.err(i),r(i);const a=new f(o),u=Object.assign({},t,{type:h.CircuitRelay.Type.STOP});a.write(h.CircuitRelay.encode(u),t=>{if(t){const i=new f(e);return this.utils.writeResponse(i,h.CircuitRelay.Status.HOP_CANT_OPEN_DST_STREAM),n(n.empty(),i.rest()),y.err(t),r(t)}a.read((e,t)=>{if(e)return y.err(e),r(e);const i=h.CircuitRelay.decode(t),o=s.rest();i.code===h.CircuitRelay.Status.SUCCESS?(n(o,a.rest(),o),r()):n(n.empty(),o)})})})})}_dialPeer(e,t){const r=new o(s.createFromBytes(e.id));e.addrs.forEach(e=>r.multiaddrs.add(e)),this.swarm.dial(r,d.relay,u((e,r)=>{if(e)return y.err(e),t(e);t(null,r)}))}}},function(e,t,r){var n=r(1255),i=r(1262),o=r(1270),s=i(function(e,t,r,i){n(t,o(t),e,i)});e.exports=s},function(e,t,r){var n=r(1256),i=r(570);e.exports=function(e,t,r,o){var s=!r;r||(r={});for(var a=-1,u=t.length;++a1?r[o-1]:void 0,a=o>2?r[2]:void 0;for(s=e.length>3&&"function"==typeof s?(o--,s):void 0,a&&i(r[0],r[1],a)&&(s=o<3?void 0:s,o=1),t=Object(t);++n0){if(++t>=r)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}},function(e,t,r){var n=r(314),i=r(89),o=r(359),s=r(121);e.exports=function(e,t,r){if(!s(r))return!1;var a=typeof t;return!!("number"==a?i(r)&&o(t,r.length):"string"==a&&t in r)&&n(r[t],e)}},function(e,t,r){var n=r(357),i=r(1271),o=r(89);e.exports=function(e){return o(e)?n(e,!0):i(e)}},function(e,t,r){var n=r(121),i=r(360),o=r(1272),s=Object.prototype.hasOwnProperty;e.exports=function(e){if(!n(e))return o(e);var t=i(e),r=[];for(var a in e)("constructor"!=a||!t&&s.call(e,a))&&r.push(a);return r}},function(e,t){e.exports=function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}},function(e,t,r){"use strict";(function(n){const i=r(12),o=r(1274),s=r(16),a=r(5);class u{constructor(e,t,r){s(n.isBuffer(e),"invalid id provided"),t&&r&&s(t.public.bytes.equals(r.bytes),"inconsistent arguments"),this._id=e,this._idB58String=i.toB58String(this.id),this._privKey=t,this._pubKey=r}get id(){return this._id}set id(e){throw new Error("Id is immutable")}get privKey(){return this._privKey}set privKey(e){this._privKey=e}get pubKey(){return this._pubKey?this._pubKey:this._privKey?this._privKey.public:void 0}set pubKey(e){this._pubKey=e}marshalPubKey(){if(this.pubKey)return o.keys.marshalPublicKey(this.pubKey)}marshalPrivKey(){if(this.privKey)return o.keys.marshalPrivateKey(this.privKey)}toPrint(){return this.toJSON()}toJSON(){return{id:this.toB58String(),privKey:c(this.marshalPrivKey()),pubKey:c(this.marshalPubKey())}}toHexString(){return i.toHexString(this.id)}toBytes(){return this.id}toB58String(){return this._idB58String}isEqual(e){if(n.isBuffer(e))return this.id.equals(e);if(e.id)return this.id.equals(e.id);throw new Error("not valid Id")}isValid(e){this.privKey&&this.privKey.public&&this.privKey.public.bytes&&n.isBuffer(this.pubKey.bytes)&&this.privKey.public.bytes.equals(this.pubKey.bytes)?e():e(new Error("Keys not match"))}}function c(e){if(e)return e.toString("base64")}(t=e.exports=u).create=function(e,t){"function"==typeof e&&(t=e,e={}),(e=e||{}).bits=e.bits||2048,a([t=>o.keys.generateKeyPair("RSA",e.bits,t),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n))})},t.createFromHexString=function(e){return new u(i.fromHexString(e))},t.createFromBytes=function(e){return new u(e)},t.createFromB58String=function(e){return new u(i.fromB58String(e))},t.createFromPubKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r;try{let i=e;if("string"==typeof i&&(i=n.from(e,"base64")),!n.isBuffer(i))throw new Error("Supplied key is neither a base64 string nor a buffer");r=o.keys.unmarshalPublicKey(i)}catch(e){return t(e)}r.hash((e,n)=>{if(e)return t(e);t(null,new u(n,null,r))})},t.createFromPrivKey=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r=e;try{if("string"==typeof r&&(r=n.from(e,"base64")),!n.isBuffer(r))throw new Error("Supplied key is neither a base64 string nor a buffer")}catch(e){return t(e)}a([e=>o.keys.unmarshalPrivateKey(r,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)})],(e,r,n)=>{if(e)return t(e);t(null,new u(r,n,n.public))})},t.createFromJSON=function(e,t){if("function"!=typeof t)throw new Error("callback is required");let r,s,c,f;try{r=i.fromB58String(e.id),s=e.privKey&&n.from(e.privKey,"base64"),c=e.pubKey&&n.from(e.pubKey,"base64"),f=c&&o.keys.unmarshalPublicKey(c)}catch(e){return t(e)}s?a([e=>o.keys.unmarshalPrivateKey(s,e),(e,t)=>e.public.hash((r,n)=>{t(r,n,e)}),(e,t,r)=>{f?f.hash((n,i)=>{r(n,e,t,i)}):r(null,e,t)}],(e,n,i,o)=>e?t(e):f&&!n.equals(o)?t(new Error("Public and private key do not match")):r&&!n.equals(r)?t(new Error("Id and private key do not match")):void t(null,new u(r,i,f))):t(null,new u(r,null,f))},t.isPeerId=function(e){return Boolean("object"==typeof e&&e._id&&e._idB58String)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(575),i=r(1276),o=r(1278);(t=e.exports).aes=i,t.hmac=n,t.keys=o,t.randomBytes=r(580),t.pbkdf2=r(1289)},function(e,t,r){"use strict";e.exports={SHA1:20,SHA256:32,SHA512:64}},function(e,t,r){"use strict";const n=r(1277),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(66);e.exports={createCipheriv:n.createCipheriv,createDecipheriv:n.createDecipheriv}},function(e,t,r){"use strict";(function(n){const i=r(11)(r(317)),o=r(17);t=e.exports;const s={rsa:r(1279),ed25519:r(1284),secp256k1:r(69)(i,r(580))};function a(e){return void 0!==s[e.toLowerCase()]}t.supportedKeys=s,t.keysPBM=i,t.keyStretcher=r(1286),t.generateEphemeralKeyPair=r(1287),t.generateKeyPair=((e,t,r)=>{let 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)=>{let 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){"use strict";const n=r(576),i=r(11),o=r(14),s=r(578),a=i(r(317)),u=r(17),c=r(3);class f{constructor(e){this._key=e}verify(e,t,r){h(r),s.hashAndVerify(this._key,t,e,r)}marshal(){return s.utils.jwkToPkix(this._key)}get bytes(){return a.PublicKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}encrypt(e){return this._key.encrypt(e,"RSAES-PKCS1-V1_5")}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(e),n(this.bytes,"sha2-256",e)}}class l{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return s.getRandomValues(new Uint8Array(16))}sign(e,t){h(t),s.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){s.decrypt(this._key,e,t)}marshal(){return s.utils.jwkToPkcs1(this._key)}get bytes(){return a.PrivateKey.encode({Type:a.KeyType.RSA,Data:this.marshal()})}equals(e){return this.bytes.equals(e.bytes)}hash(e){h(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"),h(r),c(()=>{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 h(e){if("function"!=typeof e)throw new Error("callback is required")}e.exports={RsaPublicKey:f,RsaPrivateKey:l,unmarshalRsaPublicKey:function(e){const t=s.utils.pkixToJwk(e);return new f(t)},unmarshalRsaPrivateKey:function(e,t){const r=s.utils.pkcs1ToJwk(e);s.unmarshalPrivateKey(r,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},generateKeyPair:function(e,t){s.generateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})},fromJwk:function(e,t){s.unmarshalPrivateKey(e,(e,r)=>{if(e)return t(e);t(null,new l(r.privateKey,r.publicKey))})}}},function(e,t,r){"use strict";(function(t){const n=r(42),i=r(43),o=r(577),s=r(1281),a=o.toCallback,u=o.toBuf,c=o.fromString,f=o.fromNumberTo32BitBuf;e.exports={sha1:s.sha1,sha2256:s.sha2256,sha2512:s.sha2512,sha3512:a(u(n.sha3_512)),sha3384:a(u(n.sha3_384)),sha3256:a(u(n.sha3_256)),sha3224:a(u(n.sha3_224)),shake128:a(u(n.shake_128,256)),shake256:a(u(n.shake_256,512)),keccak224:a(u(n.keccak_224)),keccak256:a(u(n.keccak_256)),keccak384:a(u(n.keccak_384)),keccak512:a(u(n.keccak_512)),murmur3128:a(u(c(i.x64.hash128))),murmur332:a(f(c(i.x86.hash32))),addBlake:r(1282),dblSha2256:(e,r)=>{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(44),i=self.crypto?self.crypto.subtle||self.crypto.webkitSubtle:self.msCrypto?self.msCrypto.subtle:void 0;function o(e){if(!i)throw new Error("Please use a browser with webcrypto support");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(45),i=r(577).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(15),i=r(579),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())}),u=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()))}),c=n.define("RSAPublicKey",function(){this.seq().obj(this.key("algorithm").use(u),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=c.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 c.encode({algorithm:{algorithm:"rsa",none:null},subjectPublicKey:{data:f.encode({modulus:s(e.n),publicExponent:s(e.e)},"der")}},"der")}},function(e,t,r){"use strict";(function(t){const n=r(576),i=r(11),o=r(14),s=r(1285),a=i(r(317));class u{constructor(e){this._key=l(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 c{constructor(e,t){this._key=l(e,s.privateKeyLength),this._publicKey=l(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 u(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 l(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:u,Ed25519PrivateKey:c,unmarshalEd25519PrivateKey:function(e,t){try{e=l(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 c(r,n))},unmarshalEd25519PublicKey:function(e){return e=l(e,s.publicKeyLength),new u(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 c(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 c(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(68),i=r(3);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){"use strict";(function(t){const n=r(40),i=r(575),o={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,cipherKeySize:32}};e.exports=((e,r,s,a)=>{const u=o[e];if(!u)return a(new Error("unkown cipherType passed"));if(!r)return a(new Error("unkown hashType passed"));const c=u.keySize,f=u.ivSize,l=t.from("key expansion"),h=2*(f+c+20);i.create(r,s,(e,r)=>{if(e)return a(e);r.digest(l,(e,i)=>{if(e)return a(e);let o=[],s=0;n(()=>s{if(t)return e(t);let a=n.length;s+a>h&&(a=h-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=h/2,n=t.concat(o),i=n.slice(0,r),s=n.slice(r,h),u=e=>({iv:e.slice(0,f),cipherKey:e.slice(f,f+c),macKey:e.slice(f+c)});a(null,{k1:u(i),k2:u(s)})})})})})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(1288);e.exports=((e,t)=>{n.generateEphmeralKeyPair(e,t)})},function(e,t,r){"use strict";(function(e){const n=r(316)(),i=r(315),o=r(15).bignum,s=r(579),a=s.toBase64,u=s.toBn,c={"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 o=(o,s,a)=>{let u;"function"==typeof s&&(a=s,s=void 0),u=s?n.subtle.importKey("jwk",p(t,s),{name:"ECDH",namedCurve:t},!1,["deriveBits"]):Promise.resolve(r.privateKey);const f=Promise.all([n.subtle.importKey("jwk",h(t,o),{name:"ECDH",namedCurve:t},!1,[]),u]);i(f.then(e=>n.subtle.deriveBits({name:"ECDH",namedCurve:t,public:e[0]},e[1],c[t])).then(t=>e.from(t)),a)};return n.subtle.exportKey("jwk",r.publicKey).then(e=>({key:l(e),genSharedKey:o}))}),r)};const f={"P-256":32,"P-384":48,"P-521":66};function l(t){const r=f[t.crv];return e.concat([e.from([4]),u(t.x).toArrayLike(e,"be",r),u(t.y).toArrayLike(e,"be",r)],1+2*r)}function h(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}}function p(e,t){const r=h(e,t.public);return r.d=a(new o(t.private)),r}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(17),i={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};e.exports=function(e,t,r,o,s){const a=i[s];if(!a)throw new Error(`Hash '${s}' is unknown or not supported`);const u=n.pkcs5.pbkdf2(e,t,r,o,a);return n.util.encode64(u)}},function(e,t,r){"use strict";const n=r(305),i=r(47).Connection,o=r(3),s=r(562),a=r(5),u=r(1)("libp2p:switch:dial"),c=r(574),f=r(581),l="Unexpected end of input from reader.";function h(e,t,r,n){e.select(t,(e,t)=>{if(!0===e)return n(new Error(l));r(e,t)})}function p(e,t,r,n){e.handle(t,e=>{if(!0===e)return n(new Error(l));r(e)})}class d{constructor(e,t,r,n,i){this.switch=e,this.peerInfo=t,this.ourPeerInfo=r,this.protocol=n,this.callback=i}dial(){const e=new i;return e.setPeerInfo(this.peerInfo),a([e=>{this._establishConnection(e)},(t,r)=>{if(t)return e.setPeerInfo(this.peerInfo),e.setInnerConn(t),r(null,e);r(null)}],(e,t)=>{if(e&&e.message===l||!0===e)return u("Connection dropped for %s",this.peerInfo.id.toB58String()),this.callback(null,null);this.callback(e,t)}),e}_establishConnection(e){const t=this.peerInfo.id.toB58String();if(u("dialing %s",t),t===this.ourPeerInfo.id.toB58String())return e(new Error("A node cannot dial itself"));a([e=>{this._createBaseConnection(t,e)},(e,r)=>{this._createMuxedConnection(e,t,r)},(e,t)=>{if(!this.protocol)return t();e.newStream?e.newStream((e,r)=>{if(e)return t(e);this._performProtocolHandshake(r,t)}):this._performProtocolHandshake(e,t)}],(t,r)=>{e(t,r)})}_createBaseConnection(e,t){const r=this.switch.conns[e];return this.switch.muxedConns[e]?t(null,null):r?(this.switch.conns[e]=void 0,t(null,r)):void a([e=>{this._attemptDial(e)},(e,t)=>{this._createPrivateConnection(e,t)},(e,t)=>{this._encryptConnection(e,t)}],(e,r)=>{if(e)return t(e);t(null,r)})}_createPrivateConnection(e,t){if(null===this.switch.protector)return t(null,e);const r=this.switch.protector.protect(e,e=>{if(e)return t(e);r.setPeerInfo(this.peerInfo),t(null,r)})}_createMuxedConnection(e,t,r){const n=this.switch.muxedConns[t];if(n)return r(null,n.muxer);e.setPeerInfo(this.peerInfo),this._attemptMuxerUpgrade(e,t,(n,i)=>n&&!this.protocol?(this.switch.conns[t]=e,r(null,null)):n?(u("muxer upgrade failed with error",n),r(null,e)):void r(null,i),r)}_attemptMuxerUpgrade(e,t,r,i){const s=Object.keys(this.switch.muxers);if(0===s.length)return r(new Error("no muxers available"));const a=new n.Dialer;p(a,e,e=>{if(e)return r(new Error("multistream not supported"));const n=e=>{u("selecting %s",e),h(a,e,(i,a)=>{if(i)return 0===s.length?r(new Error("could not upgrade to stream muxing")):n(s.shift());const c=f(null,e,a,this.switch.observer),l=this.switch.muxers[e].dialer(c);this.switch.muxedConns[t]={muxer:l},l.once("close",()=>{delete this.switch.muxedConns[t],this.peerInfo.disconnect(),this.switch._peerInfo.disconnect(),u(`closed connection to ${t}`),o(()=>this.switch.emit("peer-mux-closed",this.peerInfo))}),l.on("stream",e=>{e.setPeerInfo(this.peerInfo),this.switch.protocolMuxer(null)(e)}),o(()=>this.switch.emit("peer-mux-established",this.peerInfo)),r(null,l)},i)};n(s.shift())},i)}_attemptDial(e){if(!this.switch.hasTransports())return e(new Error("No transports registered, dial not possible"));const t=this.switch.availableTransports(this.peerInfo),r=Boolean(this.switch.transports[s.tag]);let n=!1;const i=o=>{let a=o;const c=this.peerInfo.id.toB58String();if(!a){if(!r){const t=`Circuit not enabled and all transports failed to dial peer ${c}!`;return e(new Error(t))}if(n)return e(new Error(`No available transports to dial peer ${c}!`));u("Falling back to dialing over circuit"),this.peerInfo.multiaddrs.add(`/p2p-circuit/ipfs/${c}`),n=!0,a=s.tag}u(`dialing transport ${a}`),this.switch.transport.dial(a,this.peerInfo,(r,n)=>{if(r)return u(r),i(t.shift());const o=f(a,null,n,this.switch.observer);e(null,o)})};i(t.shift())}_encryptConnection(e,t){const r=new n.Dialer;p(r,e,e=>{if(e)return t(e);const n=this.switch._peerInfo.id;u("selecting crypto: %s",this.switch.crypto.tag),h(r,this.switch.crypto.tag,(e,r)=>{if(e)return t(e);const i=f(null,this.switch.crypto.tag,r,this.switch.observer),o=this.switch.crypto.encrypt(n,i,this.peerInfo.id,e=>{if(e)return t(e);o.setPeerInfo(this.peerInfo),t(null,o)})},t)},t)}_performProtocolHandshake(e,t){this.protocol||t();const r=new n.Dialer;p(r,e,e=>{if(e)return t(e);h(r,this.protocol,(e,r)=>{if(e)return u("could not perform protocol handshake: ",e),t(e);const n=f(null,this.protocol,r,this.switch.observer);t(null,n)},t)},t)}}e.exports=function(e){return(t,r,n)=>{"function"==typeof r&&(n=r,r=null),n=n||function(){};const i=c(t,e._peerBook);return new d(e,i,e._peerInfo,r,n).dial()}}},function(e,t,r){"use strict";const n=r(305),i=r(581),o=r(1)("libp2p:switch:protocol-muxer");e.exports=function(e,t){return r=>s=>{const a=r?i(r,null,s,t):s,u=new n.Listener;Object.keys(e).forEach(r=>{if(!r)return;u.addHandler(r,(r,n)=>{o(`registering handler with protocol ${r}`);const s=e[r];if(s){const e=s&&s.handlerFunc;e&&e(s,i(null,r,n,t))}},e[r].matchFunc)}),u.handle(a,e=>{})}}},function(e,t,r){"use strict";const n=r(8),i=r(10);e.exports=(e=>{const t=Object.assign(new i,{incoming:r("in"),outgoing:r("out")});return e.on("peer-mux-established",e=>{t.emit("peer:connected",e.id.toB58String())}),e.on("peer-mux-closed",e=>{t.emit("peer:closed",e.id.toB58String())}),t;function r(e){return(t,r,i)=>n.map(n=>(o(i,t,r,e,n.length),n))}function o(e,r,n,i,o){e.then(e=>{if(e){const s=e.id.toB58String();setImmediate(()=>t.emit("message",s,r,n,i,o))}})}})},function(e,t,r){"use strict";const n=r(10),i=r(1294),o=r(1295),s={computeThrottleMaxQueueSize:1e3,computeThrottleTimeout:2e3,movingAverageIntervals:[6e4,3e5,9e5],maxOldPeersRetention:50},a=["dataReceived","dataSent"],u={in:"dataReceived",out:"dataSent"};e.exports=((e,t)=>{const r=Object.assign({},s,t),c=new i(a,r),f=Object.assign(new n,{stop:function(){c.stop();for(let e of h.values())e.stop();for(let e of p.values())e.stop()},global:c,peers:()=>Array.from(h.keys()),forPeer:e=>h.get(e)||l.get(e),transports:()=>Array.from(p.keys()),forTransport:e=>p.get(e),protocols:()=>Array.from(d.keys()),forProtocol:e=>d.get(e)});c.on("update",y);const l=o(r.maxOldPeersRetention),h=new Map,p=new Map,d=new Map;return e.on("message",(e,t,n,o,s)=>{const f=u[o];if(t){c.push(f,s);let t=h.get(e);t||((t=l.get(e))?l.delete(e):t=new i(a,r),t.on("update",y),t.start(),h.set(e,t)),t.push(f,s)}if(t){let e=p.get(t);e||((e=new i(a,r)).on("update",y),p.set(t,e)),e.push(f,s)}if(n){let e=d.get(n);e||((e=new i(a,r)).on("update",y),d.set(n,e)),e.push(f,s)}}),e.on("peer:closed",e=>{const t=h.get(e);t&&(t.removeListener("update",y),t.stop(),h.delete(e),l.set(e,t))}),f;function y(){f.emit("update")}})},function(e,t,r){"use strict";const n=r(10),i=r(122).Big,o=r(505);e.exports=class extends n{constructor(e,t){super(),this._options=t,this._queue=[],this._stats={},this._frequencyLastTime=Date.now(),this._frequencyAccumulators={},this._movingAverages={},this._update=this._update.bind(this),e.forEach(e=>{this._stats[e]=i(0),this._movingAverages[e]={},this._options.movingAverageIntervals.forEach(t=>{(this._movingAverages[e][t]=o(t)).push(this._frequencyLastTime,0)})})}start(){this._queue.length&&this._resetComputeTimeout()}stop(){this._timeout&&clearTimeout(this._timeout)}get snapshot(){return Object.assign({},this._stats)}get movingAverages(){return Object.assign({},this._movingAverages)}push(e,t){this._queue.push([e,t,Date.now()]),this._resetComputeTimeout()}_resetComputeTimeout(){this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout(this._update,this._nextTimeout())}_nextTimeout(){const e=this._queue.length/this._options.computeThrottleMaxQueueSize;return Math.max(this._options.computeThrottleTimeout*(1-e),0)}_update(){if(this._timeout=null,this._queue.length){let e;for(;this._queue.length;){const t=e=this._queue.shift();this._applyOp(t)}this._updateFrequency(e[2]),this.emit("update",this._stats)}}_updateFrequency(e){const t=e-this._frequencyLastTime;Object.keys(this._stats).forEach(r=>{this._updateFrequencyFor(r,t,e)}),this._frequencyLastTime=e}_updateFrequencyFor(e,t,r){const n=this._frequencyAccumulators[e]||0;this._frequencyAccumulators[e]=0;const i=n/t*1e3;let s=this._movingAverages[e];s||(s=this._movingAverages[e]={}),this._options.movingAverageIntervals.forEach(e=>{let t=s[e];t||(t=s[e]=o(e)),t.push(r,i)})}_applyOp(e){const t=e[0],r=e[1];if("number"!=typeof r)throw new Error("invalid increment number:",r);let n;n=this._stats.hasOwnProperty(t)?this._stats[t]:this._stats[t]=i(0),this._stats[t]=n.plus(r),this._frequencyAccumulators[t]||(this._frequencyAccumulators[t]=0),this._frequencyAccumulators[t]+=r}}},function(e,t,r){"use strict";const n=r(1296);e.exports=(e=>{const t=n(e);return t.delete=t.remove,t})},function(e,t){e.exports=function(e){if(!e)throw Error("hashlru must have a max value, of type number, greater than 0");var t=0,r=Object.create(null),n=Object.create(null);function i(i,o){r[i]=o,++t>=e&&(t=0,n=r,r=Object.create(null))}return{has:function(e){return void 0!==r[e]||void 0!==n[e]},remove:function(e){void 0!==r[e]&&(r[e]=void 0),void 0!==n[e]&&(n[e]=void 0)},get:function(e){var t=r[e];return void 0!==t?t:void 0!==(t=n[e])?(i(e,t),t):void 0},set:function(e,t){void 0!==r[e]?r[e]=t:i(e,t)},clear:function(){r=Object.create(null),n=Object.create(null)}}}},function(e,t,r){"use strict";e.exports.PROTECTOR_REQUIRED="No protector provided with private network enforced"},function(e,t,r){"use strict";const n=r(1299);(t=e.exports=r(1300)).mount=n.mount,t.unmount=n.unmount},function(e,t,r){"use strict";const n=r(8),i=r(101),o=r(318),s=o.PROTOCOL,a=o.PING_LENGTH,u=r(1),c=u("libp2p-ping");c.error=u("libp2p-ping:error"),(t=e.exports).mount=function(e){e.handle(s,(e,t)=>{const r=i({timeout:0}),o=r.handshake;n(t,r,t),function e(){o.read(a,(t,r)=>{if(!0!==t)return t?c.error(t):(o.write(r),e())})}()})},t.unmount=function(e){e.unhandle(s)}},function(e,t,r){"use strict";const n=r(10).EventEmitter,i=r(8),o=r(101),s=r(318),a=r(1301).rnd,u=r(1),c=u("libp2p-ping");c.error=u("libp2p-ping:error");const f=s.PROTOCOL,l=s.PING_LENGTH;e.exports=class extends n{constructor(e,t){super(),this._stopped=!1,this.peer=t,this.swarm=e}start(){c("dialing %s to %s",f,this.peer.id.toB58String()),this.swarm.dial(this.peer,f,(e,t)=>{if(e)return this.emit("error",e);const r=o({timeout:0});this.shake=r.handshake,i(r,t,r);const n=this;!function e(){let t=new Date,r=a(l);n.shake.write(r),n.shake.read(l,(i,o)=>{let s=new Date;if(i||!r.equals(o)){const e=new Error("Received wrong ping ack");return n.emit("error",e)}n.emit("ping",s-t),n._stopped||e()})}()})}stop(){!this._stopped&&this.shake&&(this._stopped=!0,i(i.empty(),this.shake.rest()))}}},function(e,t,r){"use strict";const n=r(111),i=r(318);e.exports.rnd=(e=>(e||(e=i.PING_LENGTH),n.randomBytes(e)))},function(e,t,r){"use strict";const n=r(10),i=r(1303).default,o=r(1)("libp2p:connection-manager"),s={maxPeers:1/0,minPeers:0,maxData:1/0,maxSentData:1/0,maxReceivedData:1/0,maxEventLoopDelay:1/0,pollInterval:2e3,movingAverageInterval:6e4,defaultPeerValue:1};function a(e,t){return e[1]-t[1]}function u(e){return e.name.toLowerCase()}e.exports=class extends n{constructor(e,t){if(super(),this._libp2p=e,this._options=Object.assign({},s,t),this._options.maxPeersPerProtocol=function(e){return e||(e={}),Object.keys(e).forEach(t=>{const r=e[t];delete e[t],e[t.toLowerCase()]=r}),e}(this._options.maxPeersPerProtocol),o("options: %j",this._options),this._stats=e.stats,t&&!this._stats)throw new Error("No libp2p.stats");this._peerValues=new Map,this._peers=new Map,this._peerProtocols=new Map,this._peerCountPerProtocol=new Map,this._onStatsUpdate=this._onStatsUpdate.bind(this),this._onPeerConnect=this._onPeerConnect.bind(this),this._onPeerDisconnect=this._onPeerDisconnect.bind(this),this._libp2p.isStarted()?this._onceStarted():this._libp2p.once("start",this._onceStarted.bind(this))}start(){this._stats.on("update",this._onStatsUpdate),this._libp2p.on("peer:connect",this._onPeerConnect),this._libp2p.on("peer:disconnect",this._onPeerDisconnect),this._latencyMonitor=new i({dataEmitIntervalMs:this._options.pollInterval}),this._onLatencyMeasure=this._onLatencyMeasure.bind(this),this._latencyMonitor.on("data",this._onLatencyMeasure)}stop(){this._stats.removeListener("update",this._onStatsUpdate),this._libp2p.removeListener("peer:connect",this._onPeerConnect),this._libp2p.removeListener("peer:disconnect",this._onPeerDisconnect),this._latencyMonitor.removeListener("data",this._onLatencyMeasure)}setPeerValue(e,t){if(t<0||t>1)throw new Error("value should be a number between 0 and 1");e.toB58String&&(e=e.toB58String()),this._peerValues.set(e,t)}_onceStarted(){this._peerId=this._libp2p.peerInfo.id.toB58String()}_onStatsUpdate(){const e=this._stats.global.movingAverages,t=e.dataReceived[this._options.movingAverageInterval].movingAverage();this._checkLimit("maxReceivedData",t);const r=e.dataSent[this._options.movingAverageInterval].movingAverage();this._checkLimit("maxSentData",r);const n=t+r;this._checkLimit("maxData",n),o("stats update",n)}_onPeerConnect(e){const t=e.id.toB58String();o("%s: connected to %s",this._peerId,t),this._peerValues.set(t,this._options.defaultPeerValue),this._peers.set(t,e),this.emit("connected",t),this._checkLimit("maxPeers",this._peers.size),function(e){const t=new Set;return e.multiaddrs.forEach(e=>{e.protos().map(u).forEach(e=>{t.add(e)})}),Array.from(t)}(e).forEach(e=>{this._peerCountPerProtocol[e]||(this._peerCountPerProtocol[e]=0),this._peerCountPerProtocol[e]++;let r=this._peerProtocols[t];r||(r=this._peerProtocols[t]=new Set),r.add(e),this._checkProtocolMaxPeersLimit(e,this._peerCountPerProtocol[e])})}_onPeerDisconnect(e){const t=e.id.toB58String();o("%s: disconnected from %s",this._peerId,t),this._peerValues.delete(t),this._peers.delete(t);const r=this._peerProtocols[t];r&&Array.from(r).forEach(e=>{this._peerCountPerProtocol[e]&&this._peerCountPerProtocol[e]--}),this.emit("disconnected",t)}_onLatencyMeasure(e){this._checkLimit("maxEventLoopDelay",e.avgMs)}_checkLimit(e,t){o("checking limit. current value of %s is %d",e,t),t>this._options[e]&&(o("%s: limit exceeded: %s, %d",this._peerId,e,t),this.emit("limit:exceeded",e,t),this._maybeDisconnectOne())}_checkProtocolMaxPeersLimit(e,t){o("checking protocol limit. current value of %s is %d",e,t),t>this._options.maxPeersPerProtocol[e]&&(o("%s: protocol max peers limit exceeded: %s, %d",this._peerId,e,t),this.emit("limit:exceeded",e,t),this._maybeDisconnectOne())}_maybeDisconnectOne(){if(this._options.minPeers{e&&this.emit("error",e)})}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=r(1304).default},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{},n=t.latencyCheckIntervalMs,i=t.dataEmitIntervalMs,s=t.asyncTestFn,u=t.latencyRandomPercentage;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r);var f=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(r.__proto__||Object.getPrototypeOf(r)).call(this)),l=f;return l.latencyCheckIntervalMs=n||500,l.latencyRandomPercentage=u||10,l._latecyCheckMultiply=l.latencyRandomPercentage/100*2*l.latencyCheckIntervalMs,l._latecyCheckSubtract=l._latecyCheckMultiply/2,l.dataEmitIntervalMs=null===i||0===i?void 0:i||5e3,c("latencyCheckIntervalMs: %s dataEmitIntervalMs: %s",l.latencyCheckIntervalMs,l.dataEmitIntervalMs),l.dataEmitIntervalMs?c("Expecting ~%s events per summary",l.latencyCheckIntervalMs/l.dataEmitIntervalMs):c("Not emitting summaries"),l.asyncTestFn=s,e&&e.hrtime?(c("Using process.hrtime for timing"),l.now=e.hrtime,l.getDeltaMS=function(e){var t=l.now(e);return 1e3*t[0]+t[1]/1e6}):"undefined"!=typeof window&&(0,o.default)(window,"performance.now")?(c("Using performance.now for timing"),l.now=window.performance.now.bind(window.performance),l.getDeltaMS=function(e){return Math.round(l.now()-e)}):(c("Using Date.now for timing"),l.now=Date.now,l.getDeltaMS=function(e){return l.now()-e}),l._latencyData=l._initLatencyData(),"undefined"!=typeof window&&(l._visibilityChangeEmitter=new a.default,l._visibilityChangeEmitter.on("visibilityChange",function(e){e?l._startTimers():(l._emitSummary(),l._stopTimers())})),l._visibilityChangeEmitter&&!l._visibilityChangeEmitter.isVisible()||l._startTimers(),f}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(r,i.default),n(r,[{key:"_startTimers",value:function(){var e=this;this._checkLatencyID||(this._checkLatency(),this.dataEmitIntervalMs&&(this._emitIntervalID=setInterval(function(){return e._emitSummary()},this.dataEmitIntervalMs),(0,s.default)(this._emitIntervalID.unref)&&this._emitIntervalID.unref()))}},{key:"_stopTimers",value:function(){this._checkLatencyID&&(clearTimeout(this._checkLatencyID),this._checkLatencyID=void 0),this._emitIntervalID&&(clearInterval(this._emitIntervalID),this._emitIntervalID=void 0)}},{key:"_emitSummary",value:function(){var e=this.getSummary();e.events>0&&this.emit("data",e)}},{key:"getSummary",value:function(){var e={events:this._latencyData.events,minMs:this._latencyData.minMs,maxMs:this._latencyData.maxMs,avgMs:this._latencyData.events?this._latencyData.totalMs/this._latencyData.events:Number.POSITIVE_INFINITY,lengthMs:this.getDeltaMS(this._latencyData.startTime)};return this._latencyData=this._initLatencyData(),c("Summary: %O",e),e}},{key:"_checkLatency",value:function(){var e=this,t=this,r=Math.random()*t._latecyCheckMultiply-t._latecyCheckSubtract,n={deltaOffset:Math.ceil(t.latencyCheckIntervalMs+r),startTime:t.now()},i=function(){if(e._checkLatencyID){var r=t.getDeltaMS(n.startTime)-n.deltaOffset;t._checkLatency(),t._latencyData.events++,t._latencyData.minMs=Math.min(t._latencyData.minMs,r),t._latencyData.maxMs=Math.max(t._latencyData.maxMs,r),t._latencyData.totalMs+=r,c("MS: %s Data: %O",r,t._latencyData)}};c("localData: %O",n),this._checkLatencyID=setTimeout(function(){t.asyncTestFn?(n.deltaOffset=0,n.startTime=t.now(),t.asyncTestFn(i)):(n.deltaOffset-=1,i())},n.deltaOffset),(0,s.default)(this._checkLatencyID.unref)&&this._checkLatencyID.unref()}},{key:"_initLatencyData",value:function(){return{startTime:this.now(),minMs:Number.POSITIVE_INFINITY,maxMs:Number.NEGATIVE_INFINITY,events:0,totalMs:0}}}]),r}();t.default=f}).call(this,r(6))},function(e,t,r){var n=r(1306),i=r(1333);e.exports=function(e,t){for(var r=0,o=(t=n(t,e)).length;null!=e&&r-1}},function(e,t,r){var n=r(198);e.exports=function(e,t){var r=this.__data__,i=n(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this}},function(e,t,r){var n=r(313)(r(159),"Map");e.exports=n},function(e,t,r){var n=r(199);e.exports=function(e){var t=n(this,e).delete(e);return this.size-=t?1:0,t}},function(e,t){e.exports=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}},function(e,t,r){var n=r(199);e.exports=function(e){return n(this,e).get(e)}},function(e,t,r){var n=r(199);e.exports=function(e){return n(this,e).has(e)}},function(e,t,r){var n=r(199);e.exports=function(e,t){var r=n(this,e),i=r.size;return r.set(e,t),this.size+=r.size==i?0:1,this}},function(e,t,r){var n=r(1332);e.exports=function(e){return null==e?"":n(e)}},function(e,t,r){var n=r(158),i=r(223),o=r(88),s=r(319),a=1/0,u=n?n.prototype:void 0,c=u?u.toString:void 0;e.exports=function e(t){if("string"==typeof t)return t;if(o(t))return i(t,e)+"";if(s(t))return c?c.call(t):"";var r=t+"";return"0"==r&&1/t==-a?"-0":r}},function(e,t,r){var n=r(319),i=1/0;e.exports=function(e){if("string"==typeof e||n(e))return e;var t=e+"";return"0"==t&&1/e==-i?"-0":t}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r({findPeer:(t,r)=>{if(!e._dht)return r(new Error("DHT is not available"));e._dht.findPeer(t,r)}}))},function(e,t,r){"use strict";e.exports=(e=>({findProviders:(t,r,n)=>{if(!e._dht)return n(new Error("DHT is not available"));e._dht.findProviders(t,r,n)},provide:(t,r)=>{if(!e._dht)return r(new Error("DHT is not available"));e._dht.provide(t,r)}}))},function(e,t,r){"use strict";e.exports=(e=>({put:(t,r,n)=>{if(!e._dht)return n(new Error("DHT is not available"));e._dht.put(t,r,n)},get:(t,r)=>{if(!e._dht)return r(new Error("DHT is not available"));e._dht.get(t,r)},getMany(t,r,n){if(!e._dht)return n(new Error("DHT is not available"));e._dht.getMany(t,r,n)}}))},function(e,t,r){"use strict";(function(t){const n=r(3),i=r(1340).NOT_STARTED_YET,o=r(1341);e.exports=(e=>{const r=new o(e);return e._floodSub=r,{subscribe:(t,o,s,a)=>{if("function"==typeof o&&(a=s,s=o,o={}),!e.isStarted()&&!r.started)return n(()=>a(new Error(i)));!function(e){0===r.listenerCount(t)&&r.subscribe(t),r.on(t,s),n(e)}(a)},unsubscribe:(t,n)=>{if(!e.isStarted()&&!r.started)throw new Error(i);r.removeListener(t,n),0===r.listenerCount(t)&&r.unsubscribe(t)},publish:(o,s,a)=>e.isStarted()||r.started?t.isBuffer(s)?(r.publish(o,s),void n(()=>a())):n(()=>a(new Error("data must be a Buffer"))):n(()=>a(new Error(i))),ls:t=>{if(!e.isStarted()&&!r.started)return n(()=>t(new Error(i)));const o=Array.from(r.subscriptions);n(()=>t(null,o))},peers:(t,o)=>{if(!e.isStarted()&&!r.started)return n(()=>o(new Error(i)));"function"==typeof t&&(o=t,t=null);const s=Array.from(r.peers.values()).filter(e=>!t||e.topics.has(t)).map(e=>e.info.id.toB58String());n(()=>o(null,s))},setMaxListeners:e=>r.setMaxListeners(e)}})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";t.NOT_STARTED_YET="The libp2p node is not started yet"},function(e,t,r){"use strict";const n=r(10),i=r(1342),o=r(504),s=r(8),a=r(53),u=r(16),c=r(50),f=r(1344),l=r(1347),h=r(584),p=r(1348),d=r(2).Buffer,y=p.log,g=p.multicodec,m=l.ensureArray,b=r(3);e.exports=class extends n{constructor(e){super(),this.libp2p=e,this.started=!1,this.cache=new i,this.peers=new Map,this.subscriptions=new Set,this._onConnection=this._onConnection.bind(this),this._dialPeer=this._dialPeer.bind(this)}_addPeer(e){const t=e.info.id.toB58String();let r=this.peers.get(t);return r||(y("new peer",t),this.peers.set(t,e),r=e,e.once("close",()=>this._removePeer(e))),++r._references,r}_removePeer(e){const t=e.info.id.toB58String();return y("remove",t,e._references),0==--e._references&&(y("delete peer",t),this.peers.delete(t)),e}_dialPeer(e,t){t=t||function(){};const r=e.id.toB58String(),n=this.peers.get(r);if(n&&n.isConnected)return b(()=>t());y("dialing %s",r),this.libp2p.dialProtocol(e,g,(r,n)=>{if(r)return y.err(r),t();this._onDial(e,n,t)})}_onDial(e,t,r){const n=e.id.toB58String();y("connected",n);const i=this._addPeer(new f(e));i.attachConnection(t),i.sendSubscriptions(this.subscriptions),b(()=>r())}_onConnection(e,t){t.getPeerInfo((e,r)=>{if(e)return y.err("Failed to identify incomming conn",e),s(s.empty(),t);const n=r.id.toB58String(),i=this._addPeer(new f(r));this._processConnection(n,t,i)})}_processConnection(e,t,r){s(t,a.decode(),s.map(e=>h.rpc.RPC.decode(e)),s.drain(t=>this._onRpc(e,t),t=>this._onConnectionEnd(e,r,t)))}_onRpc(e,t){if(!t)return;y("rpc from",e);const r=t.subscriptions,n=t.msgs;if(n&&n.length&&this._processRpcMessages(l.normalizeInRpcMessages(t.msgs)),r&&r.length){const t=this.peers.get(e);t&&t.updateSubscriptions(r)}}_processRpcMessages(e){e.forEach(e=>{const t=l.msgId(e.from,e.seqno.toString());this.cache.has(t)||(this.cache.put(t),this._emitMessages(e.topicIDs,[e]),this._forwardMessages(e.topicIDs,[e]))})}_onConnectionEnd(e,t,r){r&&"socket hang up"!==r.message&&y.err(r),y("connection ended",e,r?r.message:""),this._removePeer(t)}_emitMessages(e,t){e.forEach(e=>{this.subscriptions.has(e)&&t.forEach(t=>{this.emit(e,t)})})}_forwardMessages(e,t){this.peers.forEach(r=>{r.isWritable&&l.anyMatch(r.topics,e)&&(r.sendMessages(l.normalizeOutRpcMessages(t)),y("publish msgs on topics",e,r.info.id.toB58String()))})}start(e){if(this.started)return b(()=>e(new Error("already started")));this.libp2p.handle(g,this._onConnection),this.libp2p.on("peer:connect",this._dialPeer);const t=o(this.libp2p.peerBook.getAll());c(t,(e,t)=>this._dialPeer(e,t),t=>{b(()=>{this.started=!0,e(t)})})}stop(e){if(!this.started)return b(()=>e(new Error("not started yet")));this.libp2p.unhandle(g),this.libp2p.removeListener("peer:connect",this._dialPeer),y("stopping"),c(this.peers.values(),(e,t)=>e.close(t),t=>{if(t)return e(t);y("stopped"),this.peers=new Map,this.subscriptions=new Set,this.started=!1,e()})}publish(e,t){u(this.started,"FloodSub is not started"),y("publish",e,t),e=m(e),t=m(t);const r=this.libp2p.peerInfo.id.toB58String(),n=t.map(t=>{const n=l.randomSeqno();return this.cache.put(l.msgId(r,n)),{from:r,data:t,seqno:new d(n),topicIDs:e}});this._emitMessages(e,n),this._forwardMessages(e,n)}subscribe(e){function t(r){if(r&&r.isWritable)return r.sendSubscriptions(e);const n=()=>{r.removeListener("connection",n),t(r)};r.on("connection",n),r.once("close",()=>r.removeListener("connection",n))}u(this.started,"FloodSub is not started"),(e=m(e)).forEach(e=>this.subscriptions.add(e)),this.peers.forEach(e=>t(e))}unsubscribe(e){function t(r){r&&r.isWritable?r.sendUnsubscriptions(e):b(t.bind(r))}this.started&&((e=m(e)).forEach(e=>this.subscriptions.delete(e)),this.peers.forEach(e=>t(e)))}}},function(e,t,r){"use strict";const n=r(1343);e.exports=function e(t){if(!(this instanceof e))return new e(t);const r=(t=t||{}).validity||30,i=new Map,o=n(()=>{i.forEach((e,t)=>{const n=e.validity||r;(function(e){const t=(new Date).getTime()-e.getTime();return Math.floor(t/1e3)})(e.timestamp)>n&&i.delete(t)})},200);this.put=((e,t,r)=>{this.has(e)||i.set(e,{value:t,timestamp:new Date,validity:r}),o()}),this.get=(e=>{if(i.has(e))return i.get(e).value;throw new Error("key does not exist")}),this.has=(e=>i.has(e))}},function(e,t,r){(function(t){var r="Expected a function",n=NaN,i="[object Symbol]",o=/^\s+|\s+$/g,s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt,f="object"==typeof t&&t&&t.Object===Object&&t,l="object"==typeof self&&self&&self.Object===Object&&self,h=f||l||Function("return this")(),p=Object.prototype.toString,d=Math.max,y=Math.min,g=function(){return h.Date.now()};function m(e,t,n){var i,o,s,a,u,c,f=0,l=!1,h=!1,p=!0;if("function"!=typeof e)throw new TypeError(r);function m(t){var r=i,n=o;return i=o=void 0,f=t,a=e.apply(n,r)}function _(e){var r=e-c;return void 0===c||r>=t||r<0||h&&e-f>=s}function w(){var e=g();if(_(e))return S(e);u=setTimeout(w,function(e){var r=t-(e-c);return h?y(r,s-(e-f)):r}(e))}function S(e){return u=void 0,p&&i?m(e):(i=o=void 0,a)}function k(){var e=g(),r=_(e);if(i=arguments,o=this,c=e,r){if(void 0===u)return function(e){return f=e,u=setTimeout(w,t),l?m(e):a}(c);if(h)return u=setTimeout(w,t),m(c)}return void 0===u&&(u=setTimeout(w,t)),a}return t=v(t)||0,b(n)&&(l=!!n.leading,s=(h="maxWait"in n)?d(v(n.maxWait)||0,t):s,p="trailing"in n?!!n.trailing:p),k.cancel=function(){void 0!==u&&clearTimeout(u),f=0,i=c=o=u=void 0},k.flush=function(){return void 0===u?a:S(g())},k}function b(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function v(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&p.call(e)==i}(e))return n;if(b(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=b(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(o,"");var r=a.test(e);return r||u.test(e)?c(e.slice(2),r?2:8):s.test(e)?n:+e}e.exports=function(e,t,n){var i=!0,o=!0;if("function"!=typeof e)throw new TypeError(r);return b(n)&&(i="leading"in n?!!n.leading:i,o="trailing"in n?!!n.trailing:o),m(e,t,{leading:i,maxWait:t,trailing:o})}}).call(this,r(7))},function(e,t,r){"use strict";const n=r(53),i=r(46),o=r(8),s=r(3),a=r(10),u=r(584).rpc.RPC;e.exports=class extends a{constructor(e){super(),this.info=e,this.conn=null,this.topics=new Set,this.stream=null,this._references=0}get isConnected(){return Boolean(this.conn)}get isWritable(){return Boolean(this.stream)}write(e){if(!this.isWritable){const e=this.info.id.toB58String();throw new Error("No writable connection to "+e)}this.stream.push(e)}attachConnection(e){this.conn=e,this.stream=new i,o(this.stream,n.encode(),e,o.onEnd(()=>{this.conn=null,this.stream=null,this.emit("close")})),this.emit("connection")}_sendRawSubscriptions(e,t){if(0===e.size)return;const r=[];e.forEach(e=>{r.push({subscribe:t,topicCID:e})}),this.write(u.encode({subscriptions:r}))}sendSubscriptions(e){this._sendRawSubscriptions(e,!0)}sendUnsubscriptions(e){this._sendRawSubscriptions(e,!1)}sendMessages(e){this.write(u.encode({msgs:e}))}updateSubscriptions(e){e.forEach(e=>{e.subscribe?this.topics.add(e.topicCID):this.topics.delete(e.topicCID)})}close(e){this._references=1,this.stream&&this.stream.end(),s(()=>{this.conn=null,this.stream=null,this.emit("close"),e()})}}},function(e,t,r){"use strict";e.exports="\nmessage RPC {\n repeated SubOpts subscriptions = 1;\n repeated Message msgs = 2;\n\n message SubOpts {\n optional bool subscribe = 1; // subscribe or unsubcribe\n optional string topicCID = 2;\n }\n\n message Message {\n optional bytes from = 1;\n optional bytes data = 2;\n optional bytes seqno = 3;\n repeated string topicIDs = 4; \n }\n}"},function(e,t,r){"use strict";e.exports="\n// topicCID = cid(merkledag_protobuf(topicDescriptor)); (not the topic.name)\nmessage TopicDescriptor {\n optional string name = 1;\n optional AuthOpts auth = 2;\n optional EncOpts enc = 2;\n\n message AuthOpts {\n optional AuthMode mode = 1;\n repeated bytes keys = 2; // root keys to trust\n\n enum AuthMode {\n NONE = 0; // no authentication, anyone can publish\n KEY = 1; // only messages signed by keys in the topic descriptor are accepted\n WOT = 2; // web of trust, certificates can allow publisher set to grow\n }\n }\n\n message EncOpts {\n optional EncMode mode = 1;\n repeated bytes keyHashes = 2; // the hashes of the shared keys used (salted)\n\n enum EncMode {\n NONE = 0; // no encryption, anyone can read\n SHAREDKEY = 1; // messages are encrypted with shared key\n WOT = 2; // web of trust, certificates can allow publisher set to grow\n }\n }\n}"},function(e,t,r){"use strict";(function(n){const i=r(111),o=r(14);(t=e.exports).randomSeqno=(()=>i.randomBytes(20).toString("hex")),t.msgId=((e,t)=>e+t),t.anyMatch=((e,t)=>{let r;r=Array.isArray(t)?e=>t.indexOf(e)>-1:e=>t.has(e);for(let t of e)if(r(t))return!0;return!1}),t.ensureArray=(e=>Array.isArray(e)?e:[e]),t.normalizeInRpcMessages=(e=>e?e.map(e=>{const t=Object.assign({},e);return n.isBuffer(e.from)&&(t.from=o.encode(e.from)),t}):e),t.normalizeOutRpcMessages=(e=>e?e.map(e=>{const t=Object.assign({},e);return("string"==typeof e.from||e.from instanceof String)&&(t.from=o.decode(e.from)),t}):e)}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(1),i=n("libp2p:floodsub");i.err=n("libp2p:floodsub:error"),e.exports={log:i,multicodec:"/floodsub/1.0.0"}},function(e,t,r){"use strict";const n=r(98),i=r(51),o=r(52);e.exports=(e=>(function(t,r){let s;if(i.isPeerInfo(t))s=t;else if(o.isMultiaddr(t)||"string"==typeof t){"string"==typeof t&&(t=o(t));const r=t.getPeerId();if(!r)throw new Error("peer multiaddr instance or string must include peerId");try{s=e.peerBook.get(r)}catch(e){s=new i(n.createFromB58String(r))}s.multiaddrs.add(t)}else{if(!n.isPeerId(t))return setImmediate(()=>r(new Error("peer type not recognized")));{const n=t.toB58String();try{s=e.peerBook.get(n)}catch(n){return e.peerRouting.findPeer(t,r)}}}setImmediate(()=>r(null,s))}))},function(e,t,r){"use strict";const n=r(494),i=n.alternatives().try(n.func(),n.object()),o=n.object({connectionManager:n.object(),peerInfo:n.object().required(),peerBook:n.object(),modules:n.object().keys({transport:n.array().items(i).min(1).required(),streamMuxer:n.array().items(i).allow(null),connEncryption:n.array().items(i).allow(null),connProtector:n.object().keys({protect:n.func().required()}).unknown(),peerDiscovery:n.array().items(i).allow(null),dht:i.allow(null)}).required(),config:n.object().keys({peerDiscovery:n.object().allow(null),relay:n.object().keys({enabled:n.boolean().default(!1),hop:n.object().keys({enabled:n.boolean().default(!1),active:n.boolean().default(!1)})}).default(),dht:n.object().keys({kBucketSize:n.number().allow(null)}),EXPERIMENTAL:n.object().keys({dht:n.boolean().default(!1),pubsub:n.boolean().default(!1)}).default()}).default()});e.exports.validate=(e=>((e=n.attempt(e,o)).config.EXPERIMENTAL.dht&&n.assert(e.modules.dht,i.required()),e))},function(e,t,r){(function(e,n){var i; /** * @license * Lodash @@ -144,4 +144,4 @@ var n;n=function(){"use strict";var e=function(e,r){return t(e.slice(),r)};funct * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */ -(function(){var o,s=200,a="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",u="Expected a function",c="__lodash_hash_undefined__",f=500,l="__lodash_placeholder__",h=1,p=2,d=4,y=1,g=2,m=1,b=2,v=4,_=8,w=16,S=32,k=64,E=128,A=256,x=512,I=30,T="...",B=800,C=16,P=1,O=2,R=1/0,N=9007199254740991,L=1.7976931348623157e308,K=NaN,j=4294967295,M=j-1,D=j>>>1,U=[["ary",E],["bind",m],["bindKey",b],["curry",_],["curryRight",w],["flip",x],["partial",S],["partialRight",k],["rearg",A]],F="[object Arguments]",q="[object Array]",H="[object AsyncFunction]",z="[object Boolean]",V="[object Date]",G="[object DOMException]",W="[object Error]",$="[object Function]",Y="[object GeneratorFunction]",J="[object Map]",X="[object Number]",Z="[object Null]",Q="[object Object]",ee="[object Promise]",te="[object Proxy]",re="[object RegExp]",ne="[object Set]",ie="[object String]",oe="[object Symbol]",se="[object Undefined]",ae="[object WeakMap]",ue="[object WeakSet]",ce="[object ArrayBuffer]",fe="[object DataView]",le="[object Float32Array]",he="[object Float64Array]",pe="[object Int8Array]",de="[object Int16Array]",ye="[object Int32Array]",ge="[object Uint8Array]",me="[object Uint8ClampedArray]",be="[object Uint16Array]",ve="[object Uint32Array]",_e=/\b__p \+= '';/g,we=/\b(__p \+=) '' \+/g,Se=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ke=/&(?:amp|lt|gt|quot|#39);/g,Ee=/[&<>"']/g,Ae=RegExp(ke.source),xe=RegExp(Ee.source),Ie=/<%-([\s\S]+?)%>/g,Te=/<%([\s\S]+?)%>/g,Be=/<%=([\s\S]+?)%>/g,Ce=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Pe=/^\w*$/,Oe=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Re=/[\\^$.*+?()[\]{}|]/g,Ne=RegExp(Re.source),Le=/^\s+|\s+$/g,Ke=/^\s+/,je=/\s+$/,Me=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,De=/\{\n\/\* \[wrapped with (.+)\] \*/,Ue=/,? & /,Fe=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,qe=/\\(\\)?/g,He=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ze=/\w*$/,Ve=/^[-+]0x[0-9a-f]+$/i,Ge=/^0b[01]+$/i,We=/^\[object .+?Constructor\]$/,$e=/^0o[0-7]+$/i,Ye=/^(?:0|[1-9]\d*)$/,Je=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Xe=/($^)/,Ze=/['\n\r\u2028\u2029\\]/g,Qe="\\ud800-\\udfff",et="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",tt="a-z\\xdf-\\xf6\\xf8-\\xff",rt="A-Z\\xc0-\\xd6\\xd8-\\xde",nt="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",it="["+nt+"]",ot="["+et+"]",st="\\d+",at="["+tt+"]",ut="[^"+Qe+nt+st+"\\u2700-\\u27bf"+tt+rt+"]",ct="\\ud83c[\\udffb-\\udfff]",ft="[^\\ud800-\\udfff]",lt="(?:\\ud83c[\\udde6-\\uddff]){2}",ht="[\\ud800-\\udbff][\\udc00-\\udfff]",pt="["+rt+"]",dt="(?:"+at+"|"+ut+")",yt="(?:"+pt+"|"+ut+")",gt="(?:['’](?:d|ll|m|re|s|t|ve))?",mt="(?:['’](?:D|LL|M|RE|S|T|VE))?",bt="(?:"+ot+"|"+ct+")?",vt="[\\ufe0e\\ufe0f]?",_t=vt+bt+"(?:\\u200d(?:"+[ft,lt,ht].join("|")+")"+vt+bt+")*",wt="(?:"+["[\\u2700-\\u27bf]",lt,ht].join("|")+")"+_t,St="(?:"+[ft+ot+"?",ot,lt,ht,"[\\ud800-\\udfff]"].join("|")+")",kt=RegExp("['’]","g"),Et=RegExp(ot,"g"),At=RegExp(ct+"(?="+ct+")|"+St+_t,"g"),xt=RegExp([pt+"?"+at+"+"+gt+"(?="+[it,pt,"$"].join("|")+")",yt+"+"+mt+"(?="+[it,pt+dt,"$"].join("|")+")",pt+"?"+dt+"+"+gt,pt+"+"+mt,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",st,wt].join("|"),"g"),It=RegExp("[\\u200d"+Qe+et+"\\ufe0e\\ufe0f]"),Tt=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Bt=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Ct=-1,Pt={};Pt[le]=Pt[he]=Pt[pe]=Pt[de]=Pt[ye]=Pt[ge]=Pt[me]=Pt[be]=Pt[ve]=!0,Pt[F]=Pt[q]=Pt[ce]=Pt[z]=Pt[fe]=Pt[V]=Pt[W]=Pt[$]=Pt[J]=Pt[X]=Pt[Q]=Pt[re]=Pt[ne]=Pt[ie]=Pt[ae]=!1;var Ot={};Ot[F]=Ot[q]=Ot[ce]=Ot[fe]=Ot[z]=Ot[V]=Ot[le]=Ot[he]=Ot[pe]=Ot[de]=Ot[ye]=Ot[J]=Ot[X]=Ot[Q]=Ot[re]=Ot[ne]=Ot[ie]=Ot[oe]=Ot[ge]=Ot[me]=Ot[be]=Ot[ve]=!0,Ot[W]=Ot[$]=Ot[ae]=!1;var Rt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Nt=parseFloat,Lt=parseInt,Kt="object"==typeof e&&e&&e.Object===Object&&e,jt="object"==typeof self&&self&&self.Object===Object&&self,Mt=Kt||jt||Function("return this")(),Dt="object"==typeof t&&t&&!t.nodeType&&t,Ut=Dt&&"object"==typeof n&&n&&!n.nodeType&&n,Ft=Ut&&Ut.exports===Dt,qt=Ft&&Kt.process,Ht=function(){try{return Ut&&Ut.require&&Ut.require("util").types||qt&&qt.binding&&qt.binding("util")}catch(e){}}(),zt=Ht&&Ht.isArrayBuffer,Vt=Ht&&Ht.isDate,Gt=Ht&&Ht.isMap,Wt=Ht&&Ht.isRegExp,$t=Ht&&Ht.isSet,Yt=Ht&&Ht.isTypedArray;function Jt(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}function Xt(e,t,r,n){for(var i=-1,o=null==e?0:e.length;++i-1}function rr(e,t,r){for(var n=-1,i=null==e?0:e.length;++n-1;);return r}function Ar(e,t){for(var r=e.length;r--&&hr(t,e[r],0)>-1;);return r}var xr=mr({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),Ir=mr({"&":"&","<":"<",">":">",'"':""","'":"'"});function Tr(e){return"\\"+Rt[e]}function Br(e){return It.test(e)}function Cr(e){return Tt.test(e)}function Pr(e){var t=-1,r=Array(e.size);return e.forEach(function(e,n){r[++t]=[n,e]}),r}function Or(e,t){return function(r){return e(t(r))}}function Rr(e,t){for(var r=-1,n=e.length,i=0,o=[];++r",""":'"',"'":"'"});function Dr(e){return e.match(xt)||[]}var Ur=function e(t){var r,n=(t=null==t?Mt:Ur.defaults(Mt.Object(),t,Ur.pick(Mt,Bt))).Array,i=t.Date,Fe=t.Error,Qe=t.Function,et=t.Math,tt=t.Object,rt=t.RegExp,nt=t.String,it=t.TypeError,ot=n.prototype,st=Qe.prototype,at=tt.prototype,ut=t["__core-js_shared__"],ct=st.toString,ft=at.hasOwnProperty,lt=0,ht=(r=/[^.]+$/.exec(ut&&ut.keys&&ut.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",pt=at.toString,dt=ct.call(tt),yt=Mt._,gt=rt("^"+ct.call(ft).replace(Re,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),mt=Ft?t.Buffer:o,bt=t.Symbol,vt=t.Uint8Array,_t=mt?mt.allocUnsafe:o,wt=Or(tt.getPrototypeOf,tt),St=tt.create,At=at.propertyIsEnumerable,xt=ot.splice,It=bt?bt.isConcatSpreadable:o,Tt=bt?bt.iterator:o,Rt=bt?bt.toStringTag:o,Kt=function(){try{var e=Do(tt,"defineProperty");return e({},"",{}),e}catch(e){}}(),jt=t.clearTimeout!==Mt.clearTimeout&&t.clearTimeout,Dt=i&&i.now!==Mt.Date.now&&i.now,Ut=t.setTimeout!==Mt.setTimeout&&t.setTimeout,qt=et.ceil,Ht=et.floor,ur=tt.getOwnPropertySymbols,mr=mt?mt.isBuffer:o,Fr=t.isFinite,qr=ot.join,Hr=Or(tt.keys,tt),zr=et.max,Vr=et.min,Gr=i.now,Wr=t.parseInt,$r=et.random,Yr=ot.reverse,Jr=Do(t,"DataView"),Xr=Do(t,"Map"),Zr=Do(t,"Promise"),Qr=Do(t,"Set"),en=Do(t,"WeakMap"),tn=Do(tt,"create"),rn=en&&new en,nn={},on=hs(Jr),sn=hs(Xr),an=hs(Zr),un=hs(Qr),cn=hs(en),fn=bt?bt.prototype:o,ln=fn?fn.valueOf:o,hn=fn?fn.toString:o;function pn(e){if(Ba(e)&&!ba(e)&&!(e instanceof mn)){if(e instanceof gn)return e;if(ft.call(e,"__wrapped__"))return ps(e)}return new gn(e)}var dn=function(){function e(){}return function(t){if(!Ta(t))return{};if(St)return St(t);e.prototype=t;var r=new e;return e.prototype=o,r}}();function yn(){}function gn(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=o}function mn(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=j,this.__views__=[]}function bn(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t=t?e:t)),e}function Rn(e,t,r,n,i,s){var a,u=t&h,c=t&p,f=t&d;if(r&&(a=i?r(e,n,i,s):r(e)),a!==o)return a;if(!Ta(e))return e;var l=ba(e);if(l){if(a=function(e){var t=e.length,r=new e.constructor(t);return t&&"string"==typeof e[0]&&ft.call(e,"index")&&(r.index=e.index,r.input=e.input),r}(e),!u)return Zi(e,a)}else{var y=qo(e),g=y==$||y==Y;if(Sa(e))return Gi(e,u);if(y==Q||y==F||g&&!i){if(a=c||g?{}:zo(e),!u)return c?function(e,t){return Qi(e,Fo(e),t)}(e,function(e,t){return e&&Qi(t,su(t),e)}(a,e)):function(e,t){return Qi(e,Uo(e),t)}(e,Bn(a,e))}else{if(!Ot[y])return i?e:{};a=function(e,t,r){var n=e.constructor;switch(t){case ce:return Wi(e);case z:case V:return new n(+e);case fe:return function(e,t){var r=t?Wi(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}(e,r);case le:case he:case pe:case de:case ye:case ge:case me:case be:case ve:return $i(e,r);case J:return new n;case X:case ie:return new n(e);case re:return function(e){var t=new e.constructor(e.source,ze.exec(e));return t.lastIndex=e.lastIndex,t}(e);case ne:return new n;case oe:return function(e){return ln?tt(ln.call(e)):{}}(e)}}(e,y,u)}}s||(s=new Sn);var m=s.get(e);if(m)return m;if(s.set(e,a),Na(e))return e.forEach(function(n){a.add(Rn(n,t,r,n,e,s))}),a;if(Ca(e))return e.forEach(function(n,i){a.set(i,Rn(n,t,r,i,e,s))}),a;var b=l?o:(f?c?Oo:Po:c?su:ou)(e);return Zt(b||e,function(n,i){b&&(n=e[i=n]),xn(a,i,Rn(n,t,r,i,e,s))}),a}function Nn(e,t,r){var n=r.length;if(null==e)return!n;for(e=tt(e);n--;){var i=r[n],s=t[i],a=e[i];if(a===o&&!(i in e)||!s(a))return!1}return!0}function Ln(e,t,r){if("function"!=typeof e)throw new it(u);return os(function(){e.apply(o,r)},t)}function Kn(e,t,r,n){var i=-1,o=tr,a=!0,u=e.length,c=[],f=t.length;if(!u)return c;r&&(t=nr(t,wr(r))),n?(o=rr,a=!1):t.length>=s&&(o=kr,a=!1,t=new wn(t));e:for(;++i-1},vn.prototype.set=function(e,t){var r=this.__data__,n=In(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},_n.prototype.clear=function(){this.size=0,this.__data__={hash:new bn,map:new(Xr||vn),string:new bn}},_n.prototype.delete=function(e){var t=jo(this,e).delete(e);return this.size-=t?1:0,t},_n.prototype.get=function(e){return jo(this,e).get(e)},_n.prototype.has=function(e){return jo(this,e).has(e)},_n.prototype.set=function(e,t){var r=jo(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},wn.prototype.add=wn.prototype.push=function(e){return this.__data__.set(e,c),this},wn.prototype.has=function(e){return this.__data__.has(e)},Sn.prototype.clear=function(){this.__data__=new vn,this.size=0},Sn.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},Sn.prototype.get=function(e){return this.__data__.get(e)},Sn.prototype.has=function(e){return this.__data__.has(e)},Sn.prototype.set=function(e,t){var r=this.__data__;if(r instanceof vn){var n=r.__data__;if(!Xr||n.length0&&r(a)?t>1?qn(a,t-1,r,n,i):ir(i,a):n||(i[i.length]=a)}return i}var Hn=no(),zn=no(!0);function Vn(e,t){return e&&Hn(e,t,ou)}function Gn(e,t){return e&&zn(e,t,ou)}function Wn(e,t){return er(t,function(t){return Aa(e[t])})}function $n(e,t){for(var r=0,n=(t=qi(t,e)).length;null!=e&&rt}function Zn(e,t){return null!=e&&ft.call(e,t)}function Qn(e,t){return null!=e&&t in tt(e)}function ei(e,t,r){for(var i=r?rr:tr,s=e[0].length,a=e.length,u=a,c=n(a),f=1/0,l=[];u--;){var h=e[u];u&&t&&(h=nr(h,wr(t))),f=Vr(h.length,f),c[u]=!r&&(t||s>=120&&h.length>=120)?new wn(u&&h):o}h=e[0];var p=-1,d=c[0];e:for(;++p=a?u:u*("desc"==r[n]?-1:1)}return e.index-t.index}(e,t,r)})}function gi(e,t,r){for(var n=-1,i=t.length,o={};++n-1;)a!==e&&xt.call(a,u,1),xt.call(e,u,1);return e}function bi(e,t){for(var r=e?t.length:0,n=r-1;r--;){var i=t[r];if(r==n||i!==o){var o=i;Go(i)?xt.call(e,i,1):Ni(e,i)}}return e}function vi(e,t){return e+Ht($r()*(t-e+1))}function _i(e,t,r,i){for(var o=-1,s=zr(qt((t-e)/(r||1)),0),a=n(s);s--;)a[i?s:++o]=e,e+=r;return a}function wi(e,t){var r="";if(!e||t<1||t>N)return r;do{t%2&&(r+=e),(t=Ht(t/2))&&(e+=e)}while(t);return r}function Si(e,t){return ss(ts(e,t,Pu),e+"")}function ki(e,t,r,n){if(!Ta(e))return e;for(var i=-1,s=(t=qi(t,e)).length,a=s-1,u=e;null!=u&&++io?0:o+t),(r=r>o?o:r)<0&&(r+=o),o=t>r?0:r-t>>>0,t>>>=0;for(var s=n(o);++i>>1,s=e[o];null!==s&&!Ka(s)&&(r?s<=t:s=s){var f=t?null:wo(e);if(f)return Lr(f);a=!1,i=kr,c=new wn}else c=t?[]:u;e:for(;++n=n?e:xi(e,t,r)}var Vi=jt||function(e){return Mt.clearTimeout(e)};function Gi(e,t){if(t)return e.slice();var r=e.length,n=_t?_t(r):new e.constructor(r);return e.copy(n),n}function Wi(e){var t=new e.constructor(e.byteLength);return new vt(t).set(new vt(e)),t}function $i(e,t){var r=t?Wi(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}function Yi(e,t){if(e!==t){var r=e!==o,n=null===e,i=e==e,s=Ka(e),a=t!==o,u=null===t,c=t==t,f=Ka(t);if(!u&&!f&&!s&&e>t||s&&a&&c&&!u&&!f||n&&a&&c||!r&&c||!i)return 1;if(!n&&!s&&!f&&e1?r[i-1]:o,a=i>2?r[2]:o;for(s=e.length>3&&"function"==typeof s?(i--,s):o,a&&Wo(r[0],r[1],a)&&(s=i<3?o:s,i=1),t=tt(t);++n-1?i[s?t[a]:a]:o}}function co(e){return Co(function(t){var r=t.length,n=r,i=gn.prototype.thru;for(e&&t.reverse();n--;){var s=t[n];if("function"!=typeof s)throw new it(u);if(i&&!a&&"wrapper"==No(s))var a=new gn([],!0)}for(n=a?n:r;++n1&&b.reverse(),h&&fu))return!1;var f=s.get(e);if(f&&s.get(t))return f==t;var l=-1,h=!0,p=r&g?new wn:o;for(s.set(e,t),s.set(t,e);++l-1&&e%1==0&&e1?"& ":"")+t[n],t=t.join(r>2?", ":" "),e.replace(Me,"{\n/* [wrapped with "+t+"] */\n")}(n,function(e,t){return Zt(U,function(r){var n="_."+r[0];t&r[1]&&!tr(e,n)&&e.push(n)}),e.sort()}(function(e){var t=e.match(De);return t?t[1].split(Ue):[]}(n),r)))}function us(e){var t=0,r=0;return function(){var n=Gr(),i=C-(n-r);if(r=n,i>0){if(++t>=B)return arguments[0]}else t=0;return e.apply(o,arguments)}}function cs(e,t){var r=-1,n=e.length,i=n-1;for(t=t===o?n:t;++r1?e[t-1]:o;return Rs(e,r="function"==typeof r?(e.pop(),r):o)});function Us(e){var t=pn(e);return t.__chain__=!0,t}function Fs(e,t){return t(e)}var qs=Co(function(e){var t=e.length,r=t?e[0]:0,n=this.__wrapped__,i=function(t){return Pn(t,e)};return!(t>1||this.__actions__.length)&&n instanceof mn&&Go(r)?((n=n.slice(r,+r+(t?1:0))).__actions__.push({func:Fs,args:[i],thisArg:o}),new gn(n,this.__chain__).thru(function(e){return t&&!e.length&&e.push(o),e})):this.thru(i)});var Hs=eo(function(e,t,r){ft.call(e,r)?++e[r]:Cn(e,r,1)});var zs=uo(ms),Vs=uo(bs);function Gs(e,t){return(ba(e)?Zt:jn)(e,Ko(t,3))}function Ws(e,t){return(ba(e)?function(e,t){for(var r=null==e?0:e.length;r--&&!1!==t(e[r],r,e););return e}:Mn)(e,Ko(t,3))}var $s=eo(function(e,t,r){ft.call(e,r)?e[r].push(t):Cn(e,r,[t])});var Ys=Si(function(e,t,r){var i=-1,o="function"==typeof t,s=_a(e)?n(e.length):[];return jn(e,function(e){s[++i]=o?Jt(t,e,r):ti(e,t,r)}),s}),Js=eo(function(e,t,r){Cn(e,r,t)});function Xs(e,t){return(ba(e)?nr:fi)(e,Ko(t,3))}var Zs=eo(function(e,t,r){e[r?0:1].push(t)},function(){return[[],[]]});var Qs=Si(function(e,t){if(null==e)return[];var r=t.length;return r>1&&Wo(e,t[0],t[1])?t=[]:r>2&&Wo(t[0],t[1],t[2])&&(t=[t[0]]),yi(e,qn(t,1),[])}),ea=Dt||function(){return Mt.Date.now()};function ta(e,t,r){return t=r?o:t,t=e&&null==t?e.length:t,ko(e,E,o,o,o,o,t)}function ra(e,t){var r;if("function"!=typeof t)throw new it(u);return e=qa(e),function(){return--e>0&&(r=t.apply(this,arguments)),e<=1&&(t=o),r}}var na=Si(function(e,t,r){var n=m;if(r.length){var i=Rr(r,Lo(na));n|=S}return ko(e,n,t,r,i)}),ia=Si(function(e,t,r){var n=m|b;if(r.length){var i=Rr(r,Lo(ia));n|=S}return ko(t,n,e,r,i)});function oa(e,t,r){var n,i,s,a,c,f,l=0,h=!1,p=!1,d=!0;if("function"!=typeof e)throw new it(u);function y(t){var r=n,s=i;return n=i=o,l=t,a=e.apply(s,r)}function g(e){var r=e-f;return f===o||r>=t||r<0||p&&e-l>=s}function m(){var e=ea();if(g(e))return b(e);c=os(m,function(e){var r=t-(e-f);return p?Vr(r,s-(e-l)):r}(e))}function b(e){return c=o,d&&n?y(e):(n=i=o,a)}function v(){var e=ea(),r=g(e);if(n=arguments,i=this,f=e,r){if(c===o)return function(e){return l=e,c=os(m,t),h?y(e):a}(f);if(p)return c=os(m,t),y(f)}return c===o&&(c=os(m,t)),a}return t=za(t)||0,Ta(r)&&(h=!!r.leading,s=(p="maxWait"in r)?zr(za(r.maxWait)||0,t):s,d="trailing"in r?!!r.trailing:d),v.cancel=function(){c!==o&&Vi(c),l=0,n=f=i=c=o},v.flush=function(){return c===o?a:b(ea())},v}var sa=Si(function(e,t){return Ln(e,1,t)}),aa=Si(function(e,t,r){return Ln(e,za(t)||0,r)});function ua(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new it(u);var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var s=e.apply(this,n);return r.cache=o.set(i,s)||o,s};return r.cache=new(ua.Cache||_n),r}function ca(e){if("function"!=typeof e)throw new it(u);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}ua.Cache=_n;var fa=Hi(function(e,t){var r=(t=1==t.length&&ba(t[0])?nr(t[0],wr(Ko())):nr(qn(t,1),wr(Ko()))).length;return Si(function(n){for(var i=-1,o=Vr(n.length,r);++i=t}),ma=ri(function(){return arguments}())?ri:function(e){return Ba(e)&&ft.call(e,"callee")&&!At.call(e,"callee")},ba=n.isArray,va=zt?wr(zt):function(e){return Ba(e)&&Jn(e)==ce};function _a(e){return null!=e&&Ia(e.length)&&!Aa(e)}function wa(e){return Ba(e)&&_a(e)}var Sa=mr||zu,ka=Vt?wr(Vt):function(e){return Ba(e)&&Jn(e)==V};function Ea(e){if(!Ba(e))return!1;var t=Jn(e);return t==W||t==G||"string"==typeof e.message&&"string"==typeof e.name&&!Oa(e)}function Aa(e){if(!Ta(e))return!1;var t=Jn(e);return t==$||t==Y||t==H||t==te}function xa(e){return"number"==typeof e&&e==qa(e)}function Ia(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=N}function Ta(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Ba(e){return null!=e&&"object"==typeof e}var Ca=Gt?wr(Gt):function(e){return Ba(e)&&qo(e)==J};function Pa(e){return"number"==typeof e||Ba(e)&&Jn(e)==X}function Oa(e){if(!Ba(e)||Jn(e)!=Q)return!1;var t=wt(e);if(null===t)return!0;var r=ft.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&ct.call(r)==dt}var Ra=Wt?wr(Wt):function(e){return Ba(e)&&Jn(e)==re};var Na=$t?wr($t):function(e){return Ba(e)&&qo(e)==ne};function La(e){return"string"==typeof e||!ba(e)&&Ba(e)&&Jn(e)==ie}function Ka(e){return"symbol"==typeof e||Ba(e)&&Jn(e)==oe}var ja=Yt?wr(Yt):function(e){return Ba(e)&&Ia(e.length)&&!!Pt[Jn(e)]};var Ma=bo(ci),Da=bo(function(e,t){return e<=t});function Ua(e){if(!e)return[];if(_a(e))return La(e)?jr(e):Zi(e);if(Tt&&e[Tt])return function(e){for(var t,r=[];!(t=e.next()).done;)r.push(t.value);return r}(e[Tt]());var t=qo(e);return(t==J?Pr:t==ne?Lr:du)(e)}function Fa(e){return e?(e=za(e))===R||e===-R?(e<0?-1:1)*L:e==e?e:0:0===e?e:0}function qa(e){var t=Fa(e),r=t%1;return t==t?r?t-r:t:0}function Ha(e){return e?On(qa(e),0,j):0}function za(e){if("number"==typeof e)return e;if(Ka(e))return K;if(Ta(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Ta(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(Le,"");var r=Ge.test(e);return r||$e.test(e)?Lt(e.slice(2),r?2:8):Ve.test(e)?K:+e}function Va(e){return Qi(e,su(e))}function Ga(e){return null==e?"":Oi(e)}var Wa=to(function(e,t){if(Xo(t)||_a(t))Qi(t,ou(t),e);else for(var r in t)ft.call(t,r)&&xn(e,r,t[r])}),$a=to(function(e,t){Qi(t,su(t),e)}),Ya=to(function(e,t,r,n){Qi(t,su(t),e,n)}),Ja=to(function(e,t,r,n){Qi(t,ou(t),e,n)}),Xa=Co(Pn);var Za=Si(function(e,t){e=tt(e);var r=-1,n=t.length,i=n>2?t[2]:o;for(i&&Wo(t[0],t[1],i)&&(n=1);++r1),t}),Qi(e,Oo(e),r),n&&(r=Rn(r,h|p|d,xo));for(var i=t.length;i--;)Ni(r,t[i]);return r});var fu=Co(function(e,t){return null==e?{}:function(e,t){return gi(e,t,function(t,r){return tu(e,r)})}(e,t)});function lu(e,t){if(null==e)return{};var r=nr(Oo(e),function(e){return[e]});return t=Ko(t),gi(e,r,function(e,r){return t(e,r[0])})}var hu=So(ou),pu=So(su);function du(e){return null==e?[]:Sr(e,ou(e))}var yu=oo(function(e,t,r){return t=t.toLowerCase(),e+(r?gu(t):t)});function gu(e){return Eu(Ga(e).toLowerCase())}function mu(e){return(e=Ga(e))&&e.replace(Je,xr).replace(Et,"")}var bu=oo(function(e,t,r){return e+(r?"-":"")+t.toLowerCase()}),vu=oo(function(e,t,r){return e+(r?" ":"")+t.toLowerCase()}),_u=io("toLowerCase");var wu=oo(function(e,t,r){return e+(r?"_":"")+t.toLowerCase()});var Su=oo(function(e,t,r){return e+(r?" ":"")+Eu(t)});var ku=oo(function(e,t,r){return e+(r?" ":"")+t.toUpperCase()}),Eu=io("toUpperCase");function Au(e,t,r){return e=Ga(e),(t=r?o:t)===o?Cr(e)?Dr(e):cr(e):e.match(t)||[]}var xu=Si(function(e,t){try{return Jt(e,o,t)}catch(e){return Ea(e)?e:new Fe(e)}}),Iu=Co(function(e,t){return Zt(t,function(t){t=ls(t),Cn(e,t,na(e[t],e))}),e});function Tu(e){return function(){return e}}var Bu=co(),Cu=co(!0);function Pu(e){return e}function Ou(e){return si("function"==typeof e?e:Rn(e,h))}var Ru=Si(function(e,t){return function(r){return ti(r,e,t)}}),Nu=Si(function(e,t){return function(r){return ti(e,r,t)}});function Lu(e,t,r){var n=ou(t),i=Wn(t,n);null!=r||Ta(t)&&(i.length||!n.length)||(r=t,t=e,e=this,i=Wn(t,ou(t)));var o=!(Ta(r)&&"chain"in r&&!r.chain),s=Aa(e);return Zt(i,function(r){var n=t[r];e[r]=n,s&&(e.prototype[r]=function(){var t=this.__chain__;if(o||t){var r=e(this.__wrapped__);return(r.__actions__=Zi(this.__actions__)).push({func:n,args:arguments,thisArg:e}),r.__chain__=t,r}return n.apply(e,ir([this.value()],arguments))})}),e}function Ku(){}var ju=po(nr),Mu=po(Qt),Du=po(ar);function Uu(e){return $o(e)?gr(ls(e)):function(e){return function(t){return $n(t,e)}}(e)}var Fu=mo(),qu=mo(!0);function Hu(){return[]}function zu(){return!1}var Vu=ho(function(e,t){return e+t},0),Gu=_o("ceil"),Wu=ho(function(e,t){return e/t},1),$u=_o("floor");var Yu,Ju=ho(function(e,t){return e*t},1),Xu=_o("round"),Zu=ho(function(e,t){return e-t},0);return pn.after=function(e,t){if("function"!=typeof t)throw new it(u);return e=qa(e),function(){if(--e<1)return t.apply(this,arguments)}},pn.ary=ta,pn.assign=Wa,pn.assignIn=$a,pn.assignInWith=Ya,pn.assignWith=Ja,pn.at=Xa,pn.before=ra,pn.bind=na,pn.bindAll=Iu,pn.bindKey=ia,pn.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return ba(e)?e:[e]},pn.chain=Us,pn.chunk=function(e,t,r){t=(r?Wo(e,t,r):t===o)?1:zr(qa(t),0);var i=null==e?0:e.length;if(!i||t<1)return[];for(var s=0,a=0,u=n(qt(i/t));si?0:i+r),(n=n===o||n>i?i:qa(n))<0&&(n+=i),n=r>n?0:Ha(n);r>>0)?(e=Ga(e))&&("string"==typeof t||null!=t&&!Ra(t))&&!(t=Oi(t))&&Br(e)?zi(jr(e),0,r):e.split(t,r):[]},pn.spread=function(e,t){if("function"!=typeof e)throw new it(u);return t=null==t?0:zr(qa(t),0),Si(function(r){var n=r[t],i=zi(r,0,t);return n&&ir(i,n),Jt(e,this,i)})},pn.tail=function(e){var t=null==e?0:e.length;return t?xi(e,1,t):[]},pn.take=function(e,t,r){return e&&e.length?xi(e,0,(t=r||t===o?1:qa(t))<0?0:t):[]},pn.takeRight=function(e,t,r){var n=null==e?0:e.length;return n?xi(e,(t=n-(t=r||t===o?1:qa(t)))<0?0:t,n):[]},pn.takeRightWhile=function(e,t){return e&&e.length?Ki(e,Ko(t,3),!1,!0):[]},pn.takeWhile=function(e,t){return e&&e.length?Ki(e,Ko(t,3)):[]},pn.tap=function(e,t){return t(e),e},pn.throttle=function(e,t,r){var n=!0,i=!0;if("function"!=typeof e)throw new it(u);return Ta(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),oa(e,t,{leading:n,maxWait:t,trailing:i})},pn.thru=Fs,pn.toArray=Ua,pn.toPairs=hu,pn.toPairsIn=pu,pn.toPath=function(e){return ba(e)?nr(e,ls):Ka(e)?[e]:Zi(fs(Ga(e)))},pn.toPlainObject=Va,pn.transform=function(e,t,r){var n=ba(e),i=n||Sa(e)||ja(e);if(t=Ko(t,4),null==r){var o=e&&e.constructor;r=i?n?new o:[]:Ta(e)&&Aa(o)?dn(wt(e)):{}}return(i?Zt:Vn)(e,function(e,n,i){return t(r,e,n,i)}),r},pn.unary=function(e){return ta(e,1)},pn.union=Bs,pn.unionBy=Cs,pn.unionWith=Ps,pn.uniq=function(e){return e&&e.length?Ri(e):[]},pn.uniqBy=function(e,t){return e&&e.length?Ri(e,Ko(t,2)):[]},pn.uniqWith=function(e,t){return t="function"==typeof t?t:o,e&&e.length?Ri(e,o,t):[]},pn.unset=function(e,t){return null==e||Ni(e,t)},pn.unzip=Os,pn.unzipWith=Rs,pn.update=function(e,t,r){return null==e?e:Li(e,t,Fi(r))},pn.updateWith=function(e,t,r,n){return n="function"==typeof n?n:o,null==e?e:Li(e,t,Fi(r),n)},pn.values=du,pn.valuesIn=function(e){return null==e?[]:Sr(e,su(e))},pn.without=Ns,pn.words=Au,pn.wrap=function(e,t){return la(Fi(t),e)},pn.xor=Ls,pn.xorBy=Ks,pn.xorWith=js,pn.zip=Ms,pn.zipObject=function(e,t){return Di(e||[],t||[],xn)},pn.zipObjectDeep=function(e,t){return Di(e||[],t||[],ki)},pn.zipWith=Ds,pn.entries=hu,pn.entriesIn=pu,pn.extend=$a,pn.extendWith=Ya,Lu(pn,pn),pn.add=Vu,pn.attempt=xu,pn.camelCase=yu,pn.capitalize=gu,pn.ceil=Gu,pn.clamp=function(e,t,r){return r===o&&(r=t,t=o),r!==o&&(r=(r=za(r))==r?r:0),t!==o&&(t=(t=za(t))==t?t:0),On(za(e),t,r)},pn.clone=function(e){return Rn(e,d)},pn.cloneDeep=function(e){return Rn(e,h|d)},pn.cloneDeepWith=function(e,t){return Rn(e,h|d,t="function"==typeof t?t:o)},pn.cloneWith=function(e,t){return Rn(e,d,t="function"==typeof t?t:o)},pn.conformsTo=function(e,t){return null==t||Nn(e,t,ou(t))},pn.deburr=mu,pn.defaultTo=function(e,t){return null==e||e!=e?t:e},pn.divide=Wu,pn.endsWith=function(e,t,r){e=Ga(e),t=Oi(t);var n=e.length,i=r=r===o?n:On(qa(r),0,n);return(r-=t.length)>=0&&e.slice(r,i)==t},pn.eq=da,pn.escape=function(e){return(e=Ga(e))&&xe.test(e)?e.replace(Ee,Ir):e},pn.escapeRegExp=function(e){return(e=Ga(e))&&Ne.test(e)?e.replace(Re,"\\$&"):e},pn.every=function(e,t,r){var n=ba(e)?Qt:Dn;return r&&Wo(e,t,r)&&(t=o),n(e,Ko(t,3))},pn.find=zs,pn.findIndex=ms,pn.findKey=function(e,t){return fr(e,Ko(t,3),Vn)},pn.findLast=Vs,pn.findLastIndex=bs,pn.findLastKey=function(e,t){return fr(e,Ko(t,3),Gn)},pn.floor=$u,pn.forEach=Gs,pn.forEachRight=Ws,pn.forIn=function(e,t){return null==e?e:Hn(e,Ko(t,3),su)},pn.forInRight=function(e,t){return null==e?e:zn(e,Ko(t,3),su)},pn.forOwn=function(e,t){return e&&Vn(e,Ko(t,3))},pn.forOwnRight=function(e,t){return e&&Gn(e,Ko(t,3))},pn.get=eu,pn.gt=ya,pn.gte=ga,pn.has=function(e,t){return null!=e&&Ho(e,t,Zn)},pn.hasIn=tu,pn.head=_s,pn.identity=Pu,pn.includes=function(e,t,r,n){e=_a(e)?e:du(e),r=r&&!n?qa(r):0;var i=e.length;return r<0&&(r=zr(i+r,0)),La(e)?r<=i&&e.indexOf(t,r)>-1:!!i&&hr(e,t,r)>-1},pn.indexOf=function(e,t,r){var n=null==e?0:e.length;if(!n)return-1;var i=null==r?0:qa(r);return i<0&&(i=zr(n+i,0)),hr(e,t,i)},pn.inRange=function(e,t,r){return t=Fa(t),r===o?(r=t,t=0):r=Fa(r),function(e,t,r){return e>=Vr(t,r)&&e=-N&&e<=N},pn.isSet=Na,pn.isString=La,pn.isSymbol=Ka,pn.isTypedArray=ja,pn.isUndefined=function(e){return e===o},pn.isWeakMap=function(e){return Ba(e)&&qo(e)==ae},pn.isWeakSet=function(e){return Ba(e)&&Jn(e)==ue},pn.join=function(e,t){return null==e?"":qr.call(e,t)},pn.kebabCase=bu,pn.last=Es,pn.lastIndexOf=function(e,t,r){var n=null==e?0:e.length;if(!n)return-1;var i=n;return r!==o&&(i=(i=qa(r))<0?zr(n+i,0):Vr(i,n-1)),t==t?function(e,t,r){for(var n=r+1;n--;)if(e[n]===t)return n;return n}(e,t,i):lr(e,dr,i,!0)},pn.lowerCase=vu,pn.lowerFirst=_u,pn.lt=Ma,pn.lte=Da,pn.max=function(e){return e&&e.length?Un(e,Pu,Xn):o},pn.maxBy=function(e,t){return e&&e.length?Un(e,Ko(t,2),Xn):o},pn.mean=function(e){return yr(e,Pu)},pn.meanBy=function(e,t){return yr(e,Ko(t,2))},pn.min=function(e){return e&&e.length?Un(e,Pu,ci):o},pn.minBy=function(e,t){return e&&e.length?Un(e,Ko(t,2),ci):o},pn.stubArray=Hu,pn.stubFalse=zu,pn.stubObject=function(){return{}},pn.stubString=function(){return""},pn.stubTrue=function(){return!0},pn.multiply=Ju,pn.nth=function(e,t){return e&&e.length?di(e,qa(t)):o},pn.noConflict=function(){return Mt._===this&&(Mt._=yt),this},pn.noop=Ku,pn.now=ea,pn.pad=function(e,t,r){e=Ga(e);var n=(t=qa(t))?Kr(e):0;if(!t||n>=t)return e;var i=(t-n)/2;return yo(Ht(i),r)+e+yo(qt(i),r)},pn.padEnd=function(e,t,r){e=Ga(e);var n=(t=qa(t))?Kr(e):0;return t&&nt){var n=e;e=t,t=n}if(r||e%1||t%1){var i=$r();return Vr(e+i*(t-e+Nt("1e-"+((i+"").length-1))),t)}return vi(e,t)},pn.reduce=function(e,t,r){var n=ba(e)?or:br,i=arguments.length<3;return n(e,Ko(t,4),r,i,jn)},pn.reduceRight=function(e,t,r){var n=ba(e)?sr:br,i=arguments.length<3;return n(e,Ko(t,4),r,i,Mn)},pn.repeat=function(e,t,r){return t=(r?Wo(e,t,r):t===o)?1:qa(t),wi(Ga(e),t)},pn.replace=function(){var e=arguments,t=Ga(e[0]);return e.length<3?t:t.replace(e[1],e[2])},pn.result=function(e,t,r){var n=-1,i=(t=qi(t,e)).length;for(i||(i=1,e=o);++nN)return[];var r=j,n=Vr(e,j);t=Ko(t),e-=j;for(var i=_r(n,t);++r=s)return e;var u=r-Kr(n);if(u<1)return n;var c=a?zi(a,0,u).join(""):e.slice(0,u);if(i===o)return c+n;if(a&&(u+=c.length-u),Ra(i)){if(e.slice(u).search(i)){var f,l=c;for(i.global||(i=rt(i.source,Ga(ze.exec(i))+"g")),i.lastIndex=0;f=i.exec(l);)var h=f.index;c=c.slice(0,h===o?u:h)}}else if(e.indexOf(Oi(i),u)!=u){var p=c.lastIndexOf(i);p>-1&&(c=c.slice(0,p))}return c+n},pn.unescape=function(e){return(e=Ga(e))&&Ae.test(e)?e.replace(ke,Mr):e},pn.uniqueId=function(e){var t=++lt;return Ga(e)+t},pn.upperCase=ku,pn.upperFirst=Eu,pn.each=Gs,pn.eachRight=Ws,pn.first=_s,Lu(pn,(Yu={},Vn(pn,function(e,t){ft.call(pn.prototype,t)||(Yu[t]=e)}),Yu),{chain:!1}),pn.VERSION="4.17.10",Zt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){pn[e].placeholder=pn}),Zt(["drop","take"],function(e,t){mn.prototype[e]=function(r){r=r===o?1:zr(qa(r),0);var n=this.__filtered__&&!t?new mn(this):this.clone();return n.__filtered__?n.__takeCount__=Vr(r,n.__takeCount__):n.__views__.push({size:Vr(r,j),type:e+(n.__dir__<0?"Right":"")}),n},mn.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}}),Zt(["filter","map","takeWhile"],function(e,t){var r=t+1,n=r==P||3==r;mn.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:Ko(e,3),type:r}),t.__filtered__=t.__filtered__||n,t}}),Zt(["head","last"],function(e,t){var r="take"+(t?"Right":"");mn.prototype[e]=function(){return this[r](1).value()[0]}}),Zt(["initial","tail"],function(e,t){var r="drop"+(t?"":"Right");mn.prototype[e]=function(){return this.__filtered__?new mn(this):this[r](1)}}),mn.prototype.compact=function(){return this.filter(Pu)},mn.prototype.find=function(e){return this.filter(e).head()},mn.prototype.findLast=function(e){return this.reverse().find(e)},mn.prototype.invokeMap=Si(function(e,t){return"function"==typeof e?new mn(this):this.map(function(r){return ti(r,e,t)})}),mn.prototype.reject=function(e){return this.filter(ca(Ko(e)))},mn.prototype.slice=function(e,t){e=qa(e);var r=this;return r.__filtered__&&(e>0||t<0)?new mn(r):(e<0?r=r.takeRight(-e):e&&(r=r.drop(e)),t!==o&&(r=(t=qa(t))<0?r.dropRight(-t):r.take(t-e)),r)},mn.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},mn.prototype.toArray=function(){return this.take(j)},Vn(mn.prototype,function(e,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),n=/^(?:head|last)$/.test(t),i=pn[n?"take"+("last"==t?"Right":""):t],s=n||/^find/.test(t);i&&(pn.prototype[t]=function(){var t=this.__wrapped__,a=n?[1]:arguments,u=t instanceof mn,c=a[0],f=u||ba(t),l=function(e){var t=i.apply(pn,ir([e],a));return n&&h?t[0]:t};f&&r&&"function"==typeof c&&1!=c.length&&(u=f=!1);var h=this.__chain__,p=!!this.__actions__.length,d=s&&!h,y=u&&!p;if(!s&&f){t=y?t:new mn(this);var g=e.apply(t,a);return g.__actions__.push({func:Fs,args:[l],thisArg:o}),new gn(g,h)}return d&&y?e.apply(this,a):(g=this.thru(l),d?n?g.value()[0]:g.value():g)})}),Zt(["pop","push","shift","sort","splice","unshift"],function(e){var t=ot[e],r=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",n=/^(?:pop|shift)$/.test(e);pn.prototype[e]=function(){var e=arguments;if(n&&!this.__chain__){var i=this.value();return t.apply(ba(i)?i:[],e)}return this[r](function(r){return t.apply(ba(r)?r:[],e)})}}),Vn(mn.prototype,function(e,t){var r=pn[t];if(r){var n=r.name+"";(nn[n]||(nn[n]=[])).push({name:t,func:r})}}),nn[fo(o,b).name]=[{name:"wrapper",func:o}],mn.prototype.clone=function(){var e=new mn(this.__wrapped__);return e.__actions__=Zi(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Zi(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Zi(this.__views__),e},mn.prototype.reverse=function(){if(this.__filtered__){var e=new mn(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},mn.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,r=ba(e),n=t<0,i=r?e.length:0,o=function(e,t,r){for(var n=-1,i=r.length;++n=this.__values__.length;return{done:e,value:e?o:this.__values__[this.__index__++]}},pn.prototype.plant=function(e){for(var t,r=this;r instanceof yn;){var n=ps(r);n.__index__=0,n.__values__=o,t?i.__wrapped__=n:t=n;var i=n;r=r.__wrapped__}return i.__wrapped__=e,t},pn.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof mn){var t=e;return this.__actions__.length&&(t=new mn(this)),(t=t.reverse()).__actions__.push({func:Fs,args:[Ts],thisArg:o}),new gn(t,this.__chain__)}return this.thru(Ts)},pn.prototype.toJSON=pn.prototype.valueOf=pn.prototype.value=function(){return ji(this.__wrapped__,this.__actions__)},pn.prototype.first=pn.prototype.head,Tt&&(pn.prototype[Tt]=function(){return this}),pn}();Mt._=Ur,(i=function(){return Ur}.call(t,r,t,n))===o||(n.exports=i)}).call(this)}).call(this,r(6),r(27)(e))},function(e,t,r){"use strict";const n=r(52),i=r(23),o=r(1379),s=r(200).OFFLINE_ERROR;e.exports=function(e){return{peers:i((t,r)=>{if("function"==typeof t&&(r=t,t={}),!e.isOnline())return r(new Error(s));const n=t.v||t.verbose,i=[];o(e._peerInfoBook.getAll()).forEach(e=>{const t=e.isConnected();if(!t)return;const r={addr:t,peer:e.id};n&&(r.latency="unknown"),i.push(r)}),r(null,i)}),addrs:i(t=>{if(!e.isOnline())return t(new Error(s));t(null,o(e._peerInfoBook.getAll()))}),localAddrs:i(t=>{if(!e.isOnline())return t(new Error(s));t(null,e._libp2pNode.peerInfo.multiaddrs.toArray())}),connect:i((t,r)=>{if(!e.isOnline())return r(new Error(s));"string"==typeof t&&(t=n(t)),e._libp2pNode.dial(t,r)}),disconnect:i((t,r)=>{if(!e.isOnline())return r(new Error(s));"string"==typeof t&&(t=n(t)),e._libp2pNode.hangUp(t,r)}),filters:i(e=>e(new Error("Not implemented")))}}},function(e,t,r){var n=r(1380),i=r(359);e.exports=function(e){return null==e?[]:n(e,i(e))}},function(e,t,r){var n=r(222);e.exports=function(e,t){return n(t,function(t){return e[t]})}},function(e,t,r){"use strict";const n=r(23),i=r(70);e.exports=function(e){return n((t,r,n)=>{i(e.pingPullStream(t,r),i.collect(n))})}},function(e,t,r){"use strict";const n=r(1),i=r(200).OFFLINE_ERROR,o=r(110),s=r(8),a=r(46),u=r(4),c=n("jsipfs:pingPullStream");function f(e){return Object.assign({success:!0,time:0,text:""},e)}c.error=n("jsipfs:pingPullStream:error"),e.exports=function(e){return(t,r)=>{if(!e.isOnline())return s.error(new Error(i));r=Object.assign({count:10},r);const n=a();return u([r=>(function(e,t,r,n){let i;try{i=e.peerBook.get(r)}catch(i){c("Peer not found in peer book, trying peer routing"),t.push(f({text:`Looking up peer ${r}`}));try{r=o.createFromB58String(r)}catch(e){return n(Object.assign(e,{message:`failed to parse peer address '${r}': input isn't valid multihash`}))}return e.peerRouting.findPeer(r,n)}n(null,i)})(e._libp2pNode,n,t,r),(t,i)=>(function(e,t,r,n,i){e.ping(n,(e,o)=>{if(e)return i(e);c("Got peer",n);let s=0,a=0;return t.push(f({text:`PING ${n.id.toB58String()}`})),o.on("ping",e=>{if(t.push(f({time:e})),a+=e,++s>=r){const e=a/r;o.stop(),t.push(f({text:`Average latency: ${e}ms`})),t.end()}}),o.on("error",e=>{c.error(e),o.stop(),t.push(f({success:!1,text:e.toString()})),t.end(e)}),o.start(),i()})})(e._libp2pNode,n,r.count,t,i)],e=>{e&&(c.error(e),n.push(f({success:!1,text:e.toString()})),n.end(e))}),n}}},function(e,t,r){"use strict";const n=r(140);e.exports=function(e){return(t,r)=>n.source(e.pingPullStream(t,r))}},function(e,t,r){"use strict";(function(t){const n=r(23),{DAGNode:i,DAGLink:o}=r(45),s=r(9),a=r(279),{Key:u}=r(35),c=r(1385),{resolvePath:f}=r(200),l=300,h=new u("/local/pins");function p(e){return new s(e).toBaseEncodedString()}e.exports=(e=>{const r=e._repo,u=e.dag,d=c(u),y={direct:"direct",recursive:"recursive",indirect:"indirect",all:"all"};let g=new Set,m=new Set;const b=()=>Array.from(g).map(e=>new s(e).buffer),v=()=>Array.from(m).map(e=>new s(e).buffer);function _(n){let c,f,l;a.series([e=>a.waterfall([e=>d.storeSet(b(),e),(e,t)=>o.create(y.direct,e.size,e.multihash,t),(e,t)=>{c=e,t(null)}],e),e=>a.waterfall([e=>d.storeSet(v(),e),(e,t)=>o.create(y.recursive,e.size,e.multihash,t),(e,t)=>{f=e,t(null)}],e),e=>i.create(t.alloc(0),(t,r)=>{if(t)return e(t);u.put(r,{cid:new s(r.multihash),preload:!1},e)}),e=>i.create(t.alloc(0),[c,f],(t,r)=>{if(t)return e(t);l=r,u.put(l,{cid:new s(l.multihash),preload:!1},e)}),e=>r.closed?r.open(e):e(null,null),e=>r.datastore.put(h,l.multihash,e)],(t,r)=>t?n(t):(e.log(`Flushed pins with root: ${l}`),n(null,l)))}const w={add:n((t,r,n)=>{"function"==typeof r&&(n=r,r=null);const i=!r||r.recursive;f(e.object,t,(e,t)=>{if(e)return n(e);a.map(t,(e,t)=>{const r=p(e);if(i){if(m.has(r))return t(null,r);u._getRecursive(r,e=>e?t(e):t(null,r))}else{if(m.has(r))return t(new Error(`${r} already pinned recursively`));if(g.has(r))return t(null,r);u.get(new s(e),e=>e?t(e):t(null,r))}},(e,t)=>{if(e)return n(e);const r=i?m:g;t.forEach(e=>r.add(e)),_((e,r)=>e?n(e):n(null,t.map(e=>({hash:e}))))})})}),rm:n((t,r,n)=>{let i=!0;"function"==typeof r?n=r:r&&!1===r.recursive&&(i=!1),f(e.object,t,(t,r)=>{if(t)return n(t);a.map(r,(e,t)=>{w._isPinnedWithType(e,y.all,(r,n)=>{if(r)return t(r);const{pinned:o,reason:s}=n,a=p(e);if(!o)return t(new Error(`${a} is not pinned`));switch(s){case y.recursive:return i?t(null,a):t(new Error(`${a} is pinned recursively`));case y.direct:return t(null,a);default:return t(new Error(`${a} is pinned indirectly under ${s}`))}})},(t,r)=>{if(t)return n(t);r.forEach(e=>{i&&m.has(e)?m.delete(e):g.delete(e)}),_((t,i)=>t?n(t):(e.log(`Removed pins: ${r}`),n(null,r.map(e=>({hash:e})))))})})}),ls:n((t,r,n)=>{let i=y.all;if("function"==typeof t&&(n=t,r=null,t=null),"function"==typeof r&&(n=r),t&&t.type&&(r=t,t=null),r&&r.type&&(i=r.type.toLowerCase()),!y[i])return n(new Error(`Invalid type '${i}', must be one of {direct, indirect, recursive, all}`));if(t)f(e.object,t,(e,t)=>{if(e)return n(e);a.mapSeries(t,(e,t)=>{w._isPinnedWithType(e,y.all,(r,n)=>{if(r)return t(r);const{pinned:i,reason:o}=n,s=p(e);if(!i)return t(new Error(`Path ${s} is not pinned`));switch(o){case y.direct:case y.recursive:return t(null,{hash:s,type:o});default:return t(null,{hash:s,type:`${y.indirect} through ${o}`})}})},n)});else{let e=[];if(i!==y.direct&&i!==y.all||(e=e.concat(Array.from(g).map(e=>({type:y.direct,hash:e})))),i!==y.recursive&&i!==y.all||(e=e.concat(Array.from(m).map(e=>({type:y.recursive,hash:e})))),i!==y.indirect&&i!==y.all)return n(null,e);!function(e){const t=new Set;a.eachLimit(v(),l,(e,r)=>{u._getRecursive(e,(e,n)=>{if(e)return r(e);n.map(({multihash:e})=>p(e)).filter(e=>!m.has(e)).forEach(e=>t.add(e)),r()})},r=>{if(r)return e(r);e(null,Array.from(t))})}((t,r)=>t?n(t):(e=e.filter(({hash:e})=>!r.includes(e)||r.includes(e)&&!g.has(e)).concat(r.map(e=>({type:y.indirect,hash:e}))),n(null,e)))}}),_isPinnedWithType:n((e,t,r)=>{const n=p(e),{recursive:i,direct:o,all:c}=y;if((t===i||t===c)&&m.has(n))return r(null,{pinned:!0,reason:i});if(t===i)return r(null,{pinned:!1});if((t===o||t===c)&&g.has(n))return r(null,{pinned:!0,reason:o});if(t===o)return r(null,{pinned:!1});let f;a.someLimit(v(),l,(t,r)=>{u.get(new s(t),(t,n)=>{if(t)return r(t);d.hasDescendant(n.value,e,(e,t)=>{t&&(f=p(n.value.multihash)),r(e,t)})})},(e,t)=>e?r(e):r(null,{pinned:t,reason:f}))}),_load:n(t=>{a.waterfall([e=>r.closed?r.datastore.open(e):e(null,null),(e,t)=>r.datastore.has(h,t),(e,t)=>e?t():t(new Error("No pins to load")),e=>r.datastore.get(h,e),(e,t)=>u.get(new s(e),t)],(r,n)=>{if(r)return"No pins to load"===r.message?(e.log("No pins to load"),t()):t(r);a.parallel([e=>d.loadSet(n.value,y.recursive,e),e=>d.loadSet(n.value,y.direct,e)],(r,n)=>{if(r)return t(r);const[i,o]=n;return g=new Set(o.map(p)),m=new Set(i.map(p)),e.log("Loaded pins from the datastore"),t(null)})})})};return w})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(12),i=r(9),o=r(10),s=r(1386),a=r(20),{DAGNode:u,DAGLink:c}=r(45),f=r(279),l=r(1387),h=n.fromB58String("QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n"),p=256,d=8192,y=o(l);function g(e){return new i(e).toBaseEncodedString()}function m(e,r){const n=t.alloc(4);n.writeUInt32LE(e,0);const i=t.concat([n,t.from(g(r))]);return s(i.toString("binary"))}e.exports=function(e){const r={hasDescendant:(r,n,o)=>{const s={};return(i.isCID(n)||t.isBuffer(n))&&(n=g(n)),function t(r,i){f.some(r.links,({multihash:r},i)=>{const o=g(r);return o===n?i(null,!0):o in s?i(null,!1):(s[o]=!0,void e.get(r,(e,r)=>{if(e)return i(e);t(r.value,i)}))},i)}(r,o)},storeSet:(t,n)=>{const o=t.map(e=>({key:e,data:null}));r.storeItems(o,(t,r)=>{if(t)return n(t);const o={cid:new i(r.multihash),preload:!1};e.put(r,o,(e,t)=>{if(e)return n(e);n(null,r)})})},storeItems:(r,n)=>{return function r(n,o,s){const l=y.Set.encode({version:1,fanout:p,seed:o}),g=t.concat([t.from(a.encode(l.length)),l]),b=[];for(let e=0;e({link:new c("",1,e.key),data:e.data||t.alloc(0)})).sort((e,r)=>t.compare(e.link.multihash,r.link.multihash)),r=b.concat(e.map(e=>e.link)),i=t.concat([g].concat(e.map(e=>e.data)));u.create(i,r,(e,t)=>e?s(e):s(null,t))}else{const e=n.reduce((e,t)=>{const r=m(o,t.key)%p;return e[r]=r in e?e[r].concat([t]):[t],e},{});f.eachOf(e,(e,t,n)=>{r(e,o+1,(e,r)=>v(e,r,t,n))},e=>{if(e)return s(e);u.create(g,b,(e,t)=>e?s(e):s(null,t))})}function v(t,r,n,o){if(t)return o(t);const s={cid:new i(r._multihash),preload:!1};e.put(r,s,e=>{if(e)return o(e);b[n]=new c("",r.size,r.multihash),o(null)})}}(r,0,n)},loadSet:(t,n,i)=>{const o=t.links.find(e=>e.name===n);if(!o)return i(new Error("No link found with name "+n));e.get(o.multihash,(e,t)=>{if(e)return i(e);const n=[];r.walkItems(t.value,e=>n.push(e.multihash),e=>e?i(e):i(null,n))})},walkItems:(t,n,i)=>{let o;try{o=function(e){const t=e.data,r=a.decode(t),n=a.decode.bytes;if(n<=0)throw new Error("Invalid Set header length");if(n+r>t.length)throw new Error("Impossibly large set header length");const i=t.slice(n,r+n),o=y.Set.decode(i);if(1!==o.version)throw new Error(`Unsupported Set version: ${o.version}`);if(o.fanout>e.links.length)throw new Error("Impossibly large fanout");return{header:o,data:t.slice(r+n)}}(t)}catch(e){return i(e)}f.eachOf(t.links,(t,i,s)=>{if(i{if(e)return s(e);r.walkItems(t.value,n,s)})}else n(t,i,o.data);s(null)},i)}};return r}}).call(this,r(0).Buffer)},function(e,t){function r(e){for(var t=r.BASE,n=0,i=e.length;n>>0}r.BASE=2166136261,e.exports=r},function(e,t,r){"use strict";e.exports='\n syntax = "proto2";\n\n package ipfs.pin;\n\n option go_package = "pb";\n\n message Set {\n optional uint32 version = 1;\n optional uint32 fanout = 2;\n optional fixed32 seed = 3;\n }\n'},function(e,t,r){"use strict";(function(t,n){const i=r(145),o=i.importer,s=i.exporter,a=r(23),u=r(8),c=r(1419),f=r(46),l=r(140),h=r(192),p=r(224),d=r(4),y=r(596),g=r(597).isSource,m=r(22).Duplex,b=r(0).Buffer,v=r(9),_=r(12).toB58String,w="wrapper/";function S(){}function k(e,t,r,n){t=t||{};let i=new v(r.multihash);1===t.cidVersion&&(i=i.toV1()),d([n=>t.onlyHash?n(null,r):e.object.get(r.multihash,t,n),(e,n)=>{const o=i.toBaseEncodedString();n(null,{path:t.wrapWithDirectory?r.path.substring(w.length):r.path||o,hash:o,size:e.size})}],n)}function E(e,r){return Array.isArray(r)||(r=[r]),r.map(r=>{if(t.isBuffer(r)&&(r={path:"",content:u.values([r])}),y.readable(r)&&(r={path:"",content:h.source(r)}),g(r)&&(r={path:"",content:r}),r&&r.content&&"function"!=typeof r.content&&(t.isBuffer(r.content)&&(r.content=u.values([r.content])),y.readable(r.content)&&(r.content=h.source(r.content))),e.wrapWithDirectory&&!r.path)throw new Error("Must provide a path when wrapping with a directory");return e.wrapWithDirectory&&(r.path=w+r.path),r})}function A(e){return t.isBuffer(e)&&(e=_(e)),v.isCID(e)&&(e=e.toBaseEncodedString()),0===e.indexOf("/ipfs/")&&(e=e.substring("/ipfs/".length)),"/"===e.charAt(e.length-1)&&(e=e.substring(0,e.length-1)),e}e.exports=function(e){function r(t){const r=Object.assign({},{shardSplitThreshold:e._options.EXPERIMENTAL.sharding?1e3:1/0},t);r.hashAlg&&1!==r.cidVersion&&(r.cidVersion=1);let n=0;const i=r.progress||S;return r.progress=(e=>{i(n+=e)}),u(u.map(E.bind(null,r)),u.flatten(),o(e._ipld,r),u.asyncMap(k.bind(null,e,r)),u.map(function(e,t,r){return(t.wrapWithDirectory?""===r.path:!r.path.includes("/"))&&!t.onlyHash&&!1!==t.preload&&e._preload(r.hash),r}.bind(null,e,r)),u.asyncMap(function(e,t,r,n){const i=!("pin"in t)||t.pin,o=!r.path.includes("/");if(i&&o&&!t.onlyHash&&!t.hashAlg)return e.pin.add(r.hash,e=>n(e,r));n(null,r)}.bind(null,e,r)))}function i(t,r){if("function"==typeof t)throw new Error("You must supply an ipfsPath");const n=A((t=A(t)).split("/").slice(1).join("/")),i=e=>n&&e.path===n||e.path===t,o=p.source();return u(s(t,e._ipld,r),u.collect((e,t)=>{if(e)return o.abort(e);if(t&&t.length>1&&(t=t.filter(i)),!t||!t.length)return o.abort(new Error("No such file"));const r=t[0],n=r.content;if(!n&&"dir"===r.type)return o.abort(new Error("this dag node is a directory"));o.resolve(n)})),o}function h(t,r){const i=A(t),o=r&&r.recursive,a=i.split("/").length,c=o?n.Infinity:a,f=Object.assign({},{maxDepth:c},r);return u(s(t,e._ipld,f),u.filter(e=>o?e.depth>=a:e.depth===a),u.map(e=>{const t=new v(e.hash);return delete(e=Object.assign({},e,{hash:t.toBaseEncodedString()})).content,e}))}return{add:(()=>{const e=a((e,n={},i)=>{if("function"==typeof n?(i=n,n={}):i&&"function"==typeof i||(i=S),!(t.isBuffer(e)||y.readable(e)||Array.isArray(e)||b.isBuffer(e)||"object"==typeof e||g(e)))return i(new Error("first arg must be a buffer, readable stream, pull stream, an object or array of objects"));n.hashAlg&&1!==n.cidVersion&&(n.cidVersion=1),u(u.values([e]),r(n),c((e,t)=>e.patht.path?-1:0),u.collect(i))});return function(){const t=Array.from(arguments);return 1===t.length&&g(t[0])&&t.push({}),e.apply(null,t)}})(),addReadableStream:e=>{e=e||{};const t=f(),n=new class extends m{constructor(e,t,r){super(Object.assign({objectMode:!0},r)),this._pullStream=e,this._pushable=t,this._waitingPullFlush=[]}_read(){this._pullStream(null,(e,t)=>{for(;this._waitingPullFlush.length;)this._waitingPullFlush.shift()();e?e instanceof Error&&this.emit("error",e):this.push(t)})}_write(e,t,r){this._waitingPullFlush.push(r),this._pushable.push(e)}}(u(t,r(e)),t);return n.once("finish",()=>t.end()),n},addPullStream:r,cat:a((e,r,n)=>{if("function"==typeof r&&(n=r,r={}),"function"!=typeof n)throw new Error("Please supply a callback to ipfs.files.cat");u(i(e,r),u.collect((e,r)=>{if(e)return n(e);n(null,t.concat(r))}))}),catReadableStream:(e,t)=>l.source(i(e,t)),catPullStream:(e,t)=>i(e,t),get:a((r,n,i)=>{if("function"==typeof n&&(i=n,n={}),"function"!=typeof i)throw new Error("Please supply a callback to ipfs.files.get");u(s(r,e._ipld,n),u.asyncMap((e,r)=>{e.content?u(e.content,u.collect((n,i)=>{if(n)return r(n);e.content=t.concat(i),r(null,e)})):r(null,e)}),u.collect(i))}),getReadableStream:(t,r)=>l.source(u(s(t,e._ipld,r),u.map(e=>(e.content&&(e.content=l.source(e.content),e.content.pause()),e)))),getPullStream:(t,r)=>s(t,e._ipld,r),lsImmutable:a((e,t,r)=>{"function"==typeof t&&(r=t,t={}),u(h(e,t),u.collect((e,t)=>{e?r(e):r(null,t)}))}),lsReadableStreamImmutable:(e,t)=>l.source(h(e,t)),lsPullStreamImmutable:h}}}).call(this,r(0).Buffer,r(6))},function(e,t,r){"use strict";(function(t){const n=r(595),i=r(8),o=r(201),s=r(46),a=r(17),u=r(3),c=r(1391),f=r(1400),l={fixed:r(1409)},h={chunker:"fixed",rawLeaves:!1,hashOnly:!1,cidVersion:0,hash:null,leafType:"file",hashAlg:"sha2-256"};e.exports=function(e,r){const p=Object.assign({},h,r);p.cidVersion=p.cidVersion||0,p.cidVersion>0&&void 0===r.rawLeaves&&(p.rawLeaves=!0),r&&void 0!==r.hash&&void 0===r.rawLeaves&&(p.rawLeaves=!0);const d=l[p.chunker];a(d,"Unknkown chunker named "+p.chunker);let y=0;const g=[],m={sink:o((e,t)=>{y+=e.length,e.forEach(e=>m.source.push(e)),u(t)},null,1,e=>m.source.end(e)),source:s()},b=c(d,e,p),v=f(e,p),_=v.stream(),w=n(()=>{});return i(m,w,b,i.map(e=>(--y||t.nextTick(()=>{for(;g.length;)g.shift()()}),e)),_),{sink:m.sink,source:_.source,flush:function(e){function t(){v.flush((t,r)=>{if(t)return _.source.end(t),void e(t);w.resume(),e(null,r)})}w.pause(),y?g.push(t):t()}}}}).call(this,r(7))},function(e,t){e.exports=function(e){var t=!1,r=0;return function(){if(r=!0,!t){for(t=!0;r;)r=!1,e();t=!1}}}},function(e,t,r){"use strict";const n=r(17),i=r(1392),o=r(1393),s={flat:r(1395),balanced:r(1396),trickle:r(1398)},a={strategy:"balanced",highWaterMark:100,reduceSingleLeafToSelf:!0};e.exports=function(e,t,r){n(e,"Missing chunker creator function"),n(t,"Missing IPLD");const u=Object.assign({},a,r),c=u.strategy,f=s[c];n(f,"Unknown importer build strategy name: "+c);const l=o(e,t,f,u);return i(l,t,u)}},function(e,t,r){"use strict";const n=r(46),i=r(201);e.exports=function(e,t,r){const o=n(),s=i(e(o),null,r.highWaterMark,e=>o.end(e));return{source:o,sink:s}}},function(e,t,r){"use strict";(function(t){const n=r(273),i=r(36),o=r(8),s=r(202),a=r(63),u=r(4),c=r(45),f=r(9),l=r(65),h=r(1394),p=c.DAGNode,d={chunkerOptions:{maxChunkSize:262144},rawLeaves:!1,hashAlg:"sha2-256",leafType:"file",cidVersion:0};e.exports=function(e,r,c,y){const g=n({},d,y);return g.cidVersion=g.cidVersion||g.cidVersion,g.hashAlg=g.hashAlg||d.hashAlg,"sha2-256"!==g.hashAlg&&(g.cidVersion=1),function(e){return function(t,n){a(t.map(t=>n=>{if(!t.content)return function(e,t){const n=new i("directory");u([e=>p.create(n.marshal(),[],g.hashAlg,e),(e,t)=>{if(g.onlyHash)return t(null,e);e.cid=new f(g.cidVersion,"dag-pb",e.multihash),r.put(e,{cid:e.cid},r=>t(r,e))}],(r,n)=>{if(r)return t(r);t(null,{path:e.path,multihash:n.cid.buffer,size:n.size})})}(t,(t,r)=>{if(t)return n(t);r&&e.push(r),n()});m(t,(t,r)=>{if(t)return n(t);r&&e.push(r),n()})}),n)}};function m(n,a){if(t.isBuffer(n.content)&&(n.content=o.values([n.content])),"function"!=typeof n.content)return a(new Error("invalid content"));const u=c(h(n,r,g),g);let d,y=0;o(n.content,e(g.chunkerOptions),o.map(e=>(g.progress&&"function"==typeof g.progress&&g.progress(e.byteLength),t.from(e))),o.asyncMap((e,t)=>{if(g.rawLeaves)return l(e,g.hashAlg,(r,n)=>r?t(r):t(null,{multihash:n,size:e.length,leafSize:e.length,cid:new f(1,"raw",n),data:e}));const r=new i(g.leafType,e);p.create(r.marshal(),[],g.hashAlg,(e,n)=>{if(e)return t(e);t(null,{multihash:n.multihash,size:n.size,leafSize:r.fileSize(),cid:new f(g.cidVersion,"dag-pb",n.multihash),data:n})})}),o.asyncMap((e,t)=>{if(g.onlyHash)return t(null,e);r.put(e.data,{cid:e.cid},r=>t(r,e))}),o.map(e=>({path:n.path,multihash:e.cid.buffer,size:e.size,leafSize:e.leafSize,name:"",cid:e.cid})),s(function(e){y++,d&&this.queue(d),d=e},function(){d&&(1===y&&(d.single=!0),this.queue(d)),this.queue(null)}),u,o.collect((e,t)=>{e?a(e):a(null,t[0])}))}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(4),i=r(45),o=r(36),s=r(9),a=i.DAGLink,u=i.DAGNode;e.exports=function(e,t,r){return function(i,c){if(1===i.length&&i[0].single&&r.reduceSingleLeafToSelf){const a=i[0];return"file"!==r.leafType||r.rawLeaves?n([e=>t.get(a.cid,e),(e,t)=>{const n=e.value.data,i=new o("file",n);u.create(i.marshal(),[],r.hashAlg,(e,r)=>{t(e,{DAGNode:r,fileNode:i})})},(e,n)=>{if(r.onlyHash)return n(null,e);let i=new s(e.DAGNode.multihash);1===r.cidVersion&&(i=i.toV1()),t.put(e.DAGNode,{cid:i},t=>n(t,e))},(t,r)=>{r(null,{path:e.path,multihash:t.DAGNode.multihash,size:t.DAGNode.size,leafSize:t.fileNode.fileSize(),name:a.name})}],c):c(null,{path:e.path,multihash:a.multihash,size:a.size,leafSize:a.leafSize,name:a.name})}const f=new o("file"),l=i.map(e=>{f.addBlockSize(e.leafSize);let t=e.cid;return t||(t=new s(r.cidVersion,"dag-pb",e.multihash)),new a(e.name,e.size,t.buffer)});n([e=>u.create(f.marshal(),l,r.hashAlg,e),(e,n)=>{const i=new s(r.cidVersion,"dag-pb",e.multihash);if(r.onlyHash)return n(null,{node:e,cid:i});t.put(e,{cid:i},t=>n(t,{node:e,cid:i}))}],(t,r)=>{if(t)return c(t);c(null,{name:"",path:e.path,multihash:r.cid.buffer,size:r.node.size,leafSize:f.fileSize()})})}}},function(e,t,r){"use strict";const n=r(8),i=r(46),o=r(194),s=r(322);e.exports=function(e,t){const r=o(),a=r.source,u=i();return n(a,s(1/0),n.asyncMap(e),n.collect((e,t)=>{e?u.end(e):1===t.length?(u.push(t[0]),u.end()):t.length>1?u.end(new Error("expected a maximum of 1 roots and got "+t.length)):u.end()})),{sink:r.sink,source:u}}},function(e,t,r){"use strict";const n=r(1397),i={maxChildrenPerNode:174};e.exports=function(e,t){const r=Object.assign({},i,t);return n(e,r)}},function(e,t,r){"use strict";const n=r(8),i=r(46),o=r(194),s=r(322);e.exports=function(e,t){const r=o(),a=r.source,u=i();return function r(i,o){let a=i;Array.isArray(a)&&(a=n.values(a)),n(a,s(t.maxChildrenPerNode),n.asyncMap(e),n.collect(function(e,t){e?o(e):t.length>1?r(t,o):o(null,t)}))}(a,(e,t)=>{e?u.end(e):1===t.length?(u.push(t[0]),u.end()):t.length>1?u.end(new Error("expected a maximum of 1 roots and got "+t.length)):u.end()}),{sink:r.sink,source:u}}},function(e,t,r){"use strict";const n=r(1399),i={maxChildrenPerNode:174,layerRepeat:4};e.exports=function(e,t){const r=Object.assign({},i,t);return n(e,r)}},function(e,t,r){"use strict";const n=r(8),i=r(46),o=r(322),s=r(194),a=r(202),u=r(201),c=r(595);e.exports=function(e,t){const r=s(),f=i(),l=c(()=>{});let h=0;return n(r.source,l,function(r,s){let c,f=0,d=0,y=!1;const g=i();return{source:g,sink:u(function(t,s){let u=!1;const f=t[0];d&&!c&&(c=i(),n(c,p(r+1,d-1),a(function(e){this.queue(e)},function(e){e?this.emit("error",e):(u||(u=!0,h++,l.pause()),this.queue(null))}),o(1/0),n.asyncMap(e),n.collect((e,t)=>{h--,e?g.end(e):(t.forEach(e=>{g.push(e)}),m())}))),c?c.push(f):(g.push(f),m()),s()},null,1,function(e){e?g.end(e):c?y||(y=!0,c.end()):g.end()})};function m(){c=null,f++,(0===d&&f===t.maxChildrenPerNode||d>0&&f===t.layerRepeat)&&(f=0,d++),(!y&&s>=0&&d>s||y&&!h)&&(y=!0,g.end()),h||l.resume()}}(0,-1),o(1/0),n.asyncMap(e),n.collect((e,t)=>{e?f.end(e):1===t.length?(f.push(t[0]),f.end()):t.length>1?f.end(new Error("expected a maximum of 1 roots and got "+t.length)):f.end()})),{sink:r.sink,source:f};function p(r,s){let c=0,f=0,d,y=!1;const g=i();return{source:g,sink:u(m,null,1,v)};function m(t,s){let u=!1;const c=t[0];f&&!d&&(d=i(),n(d,p(r+1,f-1),a(function(e){this.queue(e)},function(e){e?this.emit("error",e):(u||(u=!0,h++,l.pause()),this.queue(null))}),o(1/0),n.asyncMap(e),n.collect((e,t)=>{h--,e?g.end(e):(t.forEach(e=>{g.push(e)}),b())}))),d?d.push(c):(g.push(c),b()),s()}function b(){d=null,c++,(0===f&&c===t.maxChildrenPerNode||f>0&&c===t.layerRepeat)&&(c=0,f++),(!y&&s>=0&&f>s||y&&!h)&&(y=!0,g.end()),h||l.resume()}function v(e){e?g.end(e):d?y||(y=!0,d.end()):g.end()}}}},function(e,t,r){"use strict";(function(t){const n=r(188),i=r(215),o=r(4),s=r(162),a=r(201),u=r(46),c=r(1401),f=r(1402),l=r(323);e.exports=function(e,r){const d=Object.assign({},h,r),y=s(function(e,t){const r=e.args.concat(function(){e.cb.apply(null,arguments),t()});e.fn.apply(null,r)},1);let g=function(){const e=a(function(e,r){n(e,(e,r)=>{y.push({fn:b,args:[e],cb:n=>{n?r(n):(t.push(e),r())}})},r)},null,1,function(e){v(r=>{t.end(r||e)})}),t=u();return{sink:e,source:t}}(),m=c({path:"",root:!0,dir:!0,dirty:!1,flat:!0},d);return{flush:v,stream:function(){return g}};function b(e,t){const r=(e.path||"").split("/").filter(p);let n=m;const s=r.length-1;let a="";i(r,(t,r,i)=>{a&&(a+="/"),a+=t;const u=r===s;n.dirty=!0,n.multihash=null,n.size=null,u?o([r=>n.put(t,e,r),e=>f(null,n,d.shardSplitThreshold,d,e),(e,t)=>{m=e,t()}],i):n.get(t,(e,r)=>{if(e)return void i(e);let o=r;o&&o instanceof l||(o=c({dir:!0,parent:n,parentKey:t,path:a,dirty:!0,flat:!0},d));const s=n;n=o,s.put(t,o,i)})},t)}function v(e){y.push({fn:_,args:["",m],cb:(t,r)=>{t?e(t):e(null,r&&r.multihash)}})}function _(e,r,n){if(r.dir){if(r.root&&r.childCount()>1&&!d.wrap)return void n(new Error("detected more than one root"));r.eachChildSeries((t,r,n)=>{_(e?e+"/"+t:t,r,n)},t=>{t?n(t):w(e,r,n)})}else t.nextTick(n)}function w(t,r,n){!r.root||d.wrap?r.dirty?(r.dirty=!1,r.flush(t,e,g.source,(e,t)=>{e?n(e):n(null,t)})):n(null,r.multihash):r.onlyChild((e,t)=>{e?n(e):n(null,t)})}};const h={wrap:!1,shardSplitThreshold:1e3,onlyHash:!1};function p(e){return Boolean(e)}}).call(this,r(7))},function(e,t,r){"use strict";(function(t){const n=r(188),i=r(4),o=r(9),s=r(45),a=r(36),u=s.DAGLink,c=s.DAGNode,f=r(323);class l extends f{constructor(e,t){super(e,t),this._children={}}put(e,r,n){this.multihash=void 0,this.size=void 0,this._children[e]=r,t.nextTick(n)}get(e,r){t.nextTick(()=>r(null,this._children[e]))}childCount(){return Object.keys(this._children).length}directChildrenCount(){return this.childCount()}onlyChild(e){t.nextTick(()=>e(null,this._children[Object.keys(this._children)[0]]))}eachChildSeries(e,t){n(Object.keys(this._children),(t,r)=>{e(t,this._children[t],r)},t)}flush(e,t,r,n){const s=Object.keys(this._children).map(e=>{const t=this._children[e];return new u(e,t.size,t.multihash)}),f=new a("directory"),l=this._options;i([e=>c.create(f.marshal(),s,l.hashAlg,e),(e,r)=>{if(l.onlyHash)return r(null,e);let n=new o(e.multihash);1===l.cidVersion&&(n=n.toV1()),t.put(e,{cid:n},t=>r(t,e))},(t,n)=>{this.multihash=t.multihash,this.size=t.size;const i={path:e,multihash:t.multihash,size:t.size};r.push(i),n(null,t)}],n)}}e.exports=function(e,t){return new l(e,t)}}).call(this,r(7))},function(e,t,r){"use strict";const n=r(4),i=r(1403);function o(e,t,r,n){e.flat&&e.directChildrenCount()>=t?function(e,t,r){const n=i({root:e.root,dir:!0,parent:e.parent,parentKey:e.parentKey,path:e.path,dirty:e.dirty,flat:!1},t);e.eachChildSeries((e,t,r)=>{n.put(e,t,r)},e=>{e?r(e):r(e,n)})}(e,r,n):n(null,e)}e.exports=function e(t,r,i,s,a){o(r,i,s,(o,u)=>{if(o)return void a(o);const c=u.parent;c?n([e=>{u!==r?(t&&(t.parent=u),c.put(u.parentKey,u,e)):e()},t=>{c?e(u,c,i,s,t):t(null,u)}],a):a(null,u)})}},function(e,t,r){"use strict";(function(t){const n=r(370),i=r(37),o=r(4),s=r(9),a=r(45),u=r(36),c=a.DAGLink,f=a.DAGNode,l=r(65),h=r(323),p=r(1404),d=function(e,r){l(e,"murmur3-128",(e,n)=>{if(e)r(e);else{const e=n.slice(2,10),i=e.length,o=t.alloc(i);for(let t=0;t{e?n(e):(this.multihash=t.multihash,this.size=t.size),n(null,t)})}}function m(e,r,a,l,h,d){const y=r._children;let g=0;const b=[];function v(t,r,i){const o=n(r.toString(16).toUpperCase(),2,"0");if(p.isBucket(t))m(e,t,a,l,null,(e,t)=>{e?i(e):(b.push(new c(o,t.size,t.multihash)),i())});else{const e=t.value,r=o+t.key;b.push(new c(r,e.size,e.multihash)),i()}}function _(n){const i=t.from(y.bitField().reverse()),c=new u("hamt-sharded-directory",i);c.fanout=r.tableSize(),c.hashType=e.hashFn.code,o([t=>f.create(c.marshal(),n,e.hashAlg,t),(t,r)=>{if(e.onlyHash)return r(null,t);let n=new s(t.multihash);1===e.cidVersion&&(n=n.toV1()),l.put(t,{cid:n},e=>r(e,t))},(e,t)=>{const r={path:a,multihash:e.multihash,size:e.size};h&&h.push(r),t(null,e)}],d)}i(()=>g{const t=y.get(g);t?v(t,g,t=>{g++,e(t)}):(g++,e())},e=>{e?d(e):_(b)})}e.exports=function(e,t){return new g(e,t)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(1405);e.exports=function(e){return new n(e)},e.exports.isBucket=n.isBucket},function(e,t,r){"use strict";(function(t){const n=r(1406),i=r(80),o=r(188),s=r(1407),a={bits:8};class u{constructor(e,t,r){if(this._options=Object.assign({},a,e),this._popCount=0,this._parent=t,this._posAtParent=r,!this._options.hashFn)throw new Error("please define an options.hashFn");this._options.hash||(this._options.hash=s(this._options.hashFn)),this._children=new n}static isBucket(e){return e instanceof u}put(e,t,r){this._findNewBucketAndPos(e,(n,i)=>{n?r(n):(i.bucket._putAt(i,e,t),r())})}get(e,t){this._findChild(e,(e,r)=>{e?t(e):t(null,r&&r.value)})}del(e,t){this._findPlace(e,(r,n)=>{if(r)return void t(r);const i=n.bucket._at(n.pos);i&&i.key===e&&n.bucket._delAt(n.pos),t(null)})}leafCount(){this._children.reduce((e,t)=>t instanceof u?e+t.leafCount():e+1,0)}childrenCount(){return this._children.length}onlyChild(e){t.nextTick(()=>e(null,this._children.get(0)))}eachLeafSeries(e,t){o(this._children.compactArray(),(t,r)=>{t instanceof u?t.eachLeafSeries(e,r):e(t.key,t.value,r)},t)}serialize(e,t){return t(this._children.reduce((r,n,i)=>(n&&(n instanceof u?r.push(n.serialize(e,t)):r.push(e(n,i))),r),[]))}asyncTransform(e,t,r){!function e(t,r,n,o){i(t._children.compactArray(),(i,o)=>{i instanceof u?e(i,r,n,o):r(i,(e,r)=>{e?o(e):o(null,{bitField:t._children.bitField(),children:r})})},(e,t)=>{e?o(e):n(t,o)})}(this,e,t,r)}toJSON(){return this.serialize(f,l)}prettyPrint(){return JSON.stringify(this.toJSON(),null," ")}tableSize(){return Math.pow(2,this._options.bits)}_findChild(e,t){this._findPlace(e,(r,n)=>{if(r)return void t(r);const i=n.bucket._at(n.pos);i&&i.key===e?t(null,i):t(null,void 0)})}_findPlace(e,t){const r=this._options.hash(e);r.take(this._options.bits,(e,n)=>{if(e)return void t(e);const i=this._children.get(n);if(i instanceof u)i._findPlace(r,t);else{t(null,{bucket:this,pos:n,hash:r})}})}_findNewBucketAndPos(e,t){this._findPlace(e,(r,n)=>{if(r)return void t(r);const i=n.bucket._at(n.pos);if(i&&i.key!==e){const e=new u(this._options,n.bucket,n.pos);n.bucket._putObjectAt(n.pos,e),e._findPlace(i.hash,(r,o)=>{r?t(r):(o.bucket._putAt(o,i.key,i.value),e._findNewBucketAndPos(n.hash,t))})}else t(null,n)})}_putAt(e,t,r){this._putObjectAt(e.pos,{key:t,value:r,hash:e.hash})}_putObjectAt(e,t){this._children.get(e)||this._popCount++,this._children.set(e,t)}_delAt(e){this._children.get(e)&&this._popCount--,this._children.unset(e),this._level()}_level(){if(this._parent&&this._popCount<=1)if(1===this._popCount){const e=this._children.find(c);if(!(e instanceof u)){const t=e.hash;t.untake(this._options.bits);const r={pos:this._posAtParent,hash:t};this._parent._putAt(r,e.key,e.value)}}else this._parent._delAt(this._posAtParent)}_at(e){return this._children.get(e)}}function c(e){return Boolean(e)}function f(e,t){return e.key}function l(e){return e}e.exports=u}).call(this,r(7))},function(e,t,r){"use strict";function n(e,t){return e+i(t)}function i(e){let t=e;return 16843009*((t=(858993459&(t-=t>>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135)>>24}function o(e,t){return e[0]-t[0]}function s(e){return e[1]}e.exports=class{constructor(){this._bitArrays=[],this._data=[],this._length=0,this._changedLength=!1,this._changedData=!1}set(e,t){let r=this._internalPositionFor(e,!1);if(void 0===t)-1!==r&&(this._unsetInternalPos(r),this._unsetBit(e),this._changedLength=!0,this._changedData=!0);else{let n=!1;-1===r?(r=this._data.length,this._setBit(e),this._changedData=!0):n=!0,this._setInternalPos(r,e,t,n),this._changedLength=!0}}unset(e){this.set(e,void 0)}get(e){this._sortData();const t=this._internalPositionFor(e,!0);if(-1!==t)return this._data[t][1]}push(e){return this.set(this.length,e),this.length}get length(){if(this._sortData(),this._changedLength){const e=this._data[this._data.length-1];this._length=e?e[0]+1:0,this._changedLength=!1}return this._length}forEach(e){let t=0;for(;t=this._bitArrays.length)return-1;const o=this._bitArrays[r],s=e-7*r;return(o&1<0?this._bitArrays.slice(0,r).reduce(n,0)+i(o&~(4294967295<=t)i.push(o);else if(i[0][0]<=t)i.unshift(o);else{const e=Math.round(i.length/2);this._data=i.slice(0,e).concat(o).concat(i.slice(e))}else this._data.push(o);this._changedData=!0,this._changedLength=!0}}_unsetInternalPos(e){this._data.splice(e,1)}_sortData(){this._changedData&&this._data.sort(o)}bitField(){const e=[];let t,r=8,n=0,i=0;const o=this._bitArrays.slice();for(;o.length||n;){0===n&&(t=o.shift(),n=7);const s=Math.min(n,r);i|=(t&~(255<>>=s,n-=s,(r-=s)&&(n||o.length)||(e.push(i),i=0,r=8)}for(var s=e.length-1;s>0;s--){if(0!==e[s])break;e.pop()}return e}compactArray(){return this._sortData(),this._data.map(s)}}},function(e,t,r){"use strict";(function(t,n){const i=r(37),o=r(1408);e.exports=function(e){return function(t){return t instanceof s?t:new s(t,e)}};class s{constructor(e,r){if("string"!=typeof e&&!t.isBuffer(e))throw new Error("can only hash strings or buffers");this._value=e,this._hashFn=r,this._depth=-1,this._availableBits=0,this._currentBufferIndex=0,this._buffers=[]}take(e,t){let r=e;i(()=>this._availableBits{this._produceMoreBits(e)},e=>{if(e)return void t(e);let o=0;i(()=>r>0,e=>{const t=this._buffers[this._currentBufferIndex],n=Math.min(t.availableBits(),r),i=t.take(n);o=(o<{e?t(e):n.nextTick(()=>t(null,o))})})}untake(e){let t=e;for(;t>0;){const e=this._buffers[this._currentBufferIndex],r=Math.min(e.totalBits()-e.availableBits(),t);e.untake(r),t-=r,this._availableBits+=r,this._currentBufferIndex>0&&e.totalBits()===e.availableBits()&&(this._depth--,this._currentBufferIndex--)}}_produceMoreBits(e){this._depth++;const t=this._depth?this._value+this._depth:this._value;this._hashFn(t,(t,r)=>{if(t)return void e(t);const n=new o(r);this._buffers.push(n),this._availableBits+=n.availableBits(),e()})}}}).call(this,r(0).Buffer,r(7))},function(e,t,r){"use strict";const n=[255,254,252,248,240,224,192,128],i=[1,3,7,15,31,63,127,255];function o(e,t,r){return(e&s(t,r))>>>t}function s(e,t){return n[e]&i[Math.min(t+e-1,7)]}e.exports=class{constructor(e){this._value=e,this._currentBytePos=e.length-1,this._currentBitPos=7}availableBits(){return this._currentBitPos+1+8*this._currentBytePos}totalBits(){return 8*this._value.length}take(e){let t=e,r=0;for(;t&&this._haveBits();){const e=this._value[this._currentBytePos],n=this._currentBitPos+1,i=Math.min(n,t);r=(r<7;)this._currentBitPos-=8,this._currentBytePos+=1}_haveBits(){return this._currentBytePos>=0}}},function(e,t,r){"use strict";const n=r(1410);e.exports=(e=>{let t="number"==typeof e?e:e.maxChunkSize;return n(t,{zeroPadding:!1,emitEmpty:!0})})},function(e,t,r){"use strict";(function(t){var n=r(202);function i(e){return 1===e.length?e[0]:t.concat(e)}function o(e,t,r){return 0===t&&r===e.length?e:e.slice(t,r)}e.exports=function(e,r){var s;r||(r={}),"object"==typeof e&&(e=(r=e).size),e=e||512,s=!r.nopad&&(void 0===r.zeroPadding||r.zeroPadding);var a=[],u=0,c=0,f=!1;return n(function(r){for("number"==typeof r&&(r=t.from([r])),u+=r.length,a.push(r);u>=e;){for(var n,s,l,h=0,p=[],d=0;h0&&(a[0]=a[0].slice(c)),this.queue(i(a)),a=null)}this.queue(null)})}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(8),i=r(9),o=r(1412).createResolver;function s(e){let r=e,n="/";if(t.isBuffer(e)&&(r=new i(e).toBaseEncodedString()),"string"==typeof e){0===e.indexOf("/ipfs/")&&(e=r=e.substring(6));const t=e.indexOf("/");t>0&&(r=e.substring(0,t),n=e.substring(t))}else i.isCID(r)&&(r=r.toBaseEncodedString());return{base:r=new i(r).toBaseEncodedString(),rest:n.split("/").filter(Boolean)}}const a={maxDepth:1/0,offset:void 0,length:void 0};e.exports=((e,t,r)=>{let u;r=Object.assign({},a,r);try{u=s(e)}catch(e){return n.error(e)}const c=function(e){return e.reduce((e,t)=>(e.length&&(e+="/"),e+t),"")}([u.base].concat(u.rest.slice(0,u.rest.length-1))).length;return n(n.values([{multihash:new i(u.base),name:u.base,path:u.base,pathRest:u.rest,depth:0}]),o(t,r),n.filter(Boolean),n.map(e=>({depth:e.depth,name:e.name,path:function(e){if(!u.rest.length)return e.path;let t=e.path.substring(c);return"/"===t.charAt(0)&&(t=t.substring(1)),t||(t=u.rest[u.rest.length-1]||u.base),t}(e),size:e.size,hash:e.hash||e.multihash,content:e.content,type:e.type})))})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(36),i=r(8),o=r(324),s=r(9),a={directory:r(1414),"hamt-sharded-directory":r(1415),file:r(1417),object:r(1418)};function u(e){return t.isBuffer(e.data)?n.unmarshal(e.data).type:"object"}function c(e){return e}e.exports=Object.assign({createResolver:function e(t,r,n,f){return n||(n=0),n>r.maxDepth?i.map(c):i(o((e,n)=>"number"!=typeof e.depth?i.error(new Error("no depth")):e.object?n(null,l(e.object,e,r.offset,r.length)):void t.get(new s(e.multihash),(t,i)=>{if(t)return n(t);n(null,l(i.value,e,r.offset,r.length))})),i.flatten(),i.filter(Boolean),i.filter(e=>e.depth<=r.maxDepth));function l(e,r,n,i){return h(e,r.name,r.path,r.pathRest,r.size,t,r.parent||f,r.depth,n,i)}function h(t,n,o,s,c,f,l,h,p,d){const y=u(t),g=a[y];return g?g(t,n,o,s,e(f,r,h,t),c,f,l,h,p,d):i.error(new Error("Unkown node type "+y))}},typeOf:u},a)}).call(this,r(0).Buffer)},function(e,t){e.exports=function(e){var t=!1,r=0;return function(){if(r=!0,!t){for(t=!0;r;)r=!1,e();t=!1}}}},function(e,t,r){"use strict";const n=r(8),i=r(141);e.exports=function(e,t,r,o,s,a,u,c,f){const l=o[0],h={name:t,depth:f,path:r,hash:e.multihash,size:e.size,type:"dir"},p=[n(n.values(e.links),n.map(e=>({depth:f+1,size:e.size,name:e.name,path:r+"/"+e.name,multihash:e.multihash,linkName:e.name,pathRest:o.slice(1),type:"dir"})),n.filter(e=>void 0===l||e.linkName===l),s)];return o.length||p.unshift(n.values([h])),i(p)}},function(e,t,r){"use strict";const n=r(8),i=r(141),o=r(1416);e.exports=function(e,t,r,s,a,u,c,f,l){let h;f&&f.path===r||(h={name:t,depth:l,path:r,hash:o(e.multihash),size:e.size,type:"dir"});const p=[n(n.values(e.links),n.map(e=>{const t=e.name.substring(2),n=t?r+"/"+t:r;let i=!0;return t&&s.length&&(i=t===s[0]),i?{depth:l+1,name:t,path:n,multihash:e.multihash,pathRest:t?s.slice(1):s,parent:h||f}:""}),n.filter(Boolean),a)];return s.length||p.unshift(n.values([h])),i(p)}},function(e,t,r){"use strict";(function(t){const n=r(12);e.exports=(e=>t.isBuffer(e)?n.toB58String(e):e)}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(225),i=r(36),o=r(9),s=r(8),a=r(324);function u(e,r,u,f,l){if(f===u||0===l)return s.once(t.alloc(0));const h=f+l;let p=0;return s(n.depthFirst({node:r,start:0,end:u},function({node:r}){if(t.isBuffer(r))return s.empty();const n=i.unmarshal(r.data);Boolean(n.data&&n.data.length)&&r.links.length&&(p+=n.data.length);const u=r.links.map((e,t)=>{const r={link:e,start:p,end:p+n.blockSizes[t]};return p=r.end,r}).filter(e=>f>=e.start&&fe.start&&h<=e.end||fe.end);return u.length&&(p=u[0].start),s(s.values(u),a((t,r)=>{e.get(new o(t.link.multihash),(e,n)=>r(e,{start:t.start,end:t.end,node:n&&n.value,size:t.size}))}))}),s.map(function({node:e,start:r}){try{if(t.isBuffer(e))return c(e,r,f,h);const n=i.unmarshal(e.data);return n.data?c(n.data,r,f,h):t.alloc(0)}catch(e){throw new Error(`Failed to unmarshal node - ${e.message}`)}}),s.filter(Boolean))}function c(e,r,n,i){const o=e.length;return n>=r+o?t.alloc(0):(i-rr&&n{const y=o[0];if(void 0!==y&&y!==n)return s.empty();const g=i.unmarshal(e.data),m=c||g.fileSize();if(p<0)return s.error(new Error("Offset must be greater than 0"));if(p>m)return s.error(new Error("Offset must be less than the file size"));if(d<0)return s.error(new Error("Length must be greater than or equal to 0"));if(0===d)return s.once(t.alloc(0));p||(p=0),(!d||p+d>m)&&(d=m-p);const b=u(f,e,m,p,d);return s.values([{depth:h,content:b,name:r,path:n,hash:e.multihash,size:m,type:"file"}])})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(9),i=r(8);e.exports=((e,t,r,o,s,a,u,c,f)=>{let l;if(o.length){const t=o[0],a=r+"/"+t;if(!(l=e[t]))return i.error("not found");const u=n.isCID(l);return i(i.values([{depth:f,name:t,path:a,pathRest:o.slice(1),multihash:u&&l,object:!u&&l,parent:c}]),s)}return i.error(new Error("invalid node type"))})},function(e,t,r){var n=r(161),i=r(8);e.exports=function(e){var t=n(),r=i.collect(function(r,n){t.resolve(i.values(n.sort(e)))});return function(e){return r(e),t}}},function(e,t,r){"use strict";const n=r(23),i=r(3);e.exports=function(e){return{subscribe:(t,r,n,i)=>{if("function"==typeof n&&(i=n,n={}),!i)return new Promise((i,o)=>{e._libp2pNode.pubsub.subscribe(t,n,r,e=>{if(e)return o(e);i()})});e._libp2pNode.pubsub.subscribe(t,n,r,i)},unsubscribe:(t,r,n)=>{if(e._libp2pNode.pubsub.unsubscribe(t,r),!n)return Promise.resolve();i(()=>n())},publish:n((t,r,n)=>{e._libp2pNode.pubsub.publish(t,r,n)}),ls:n(t=>{e._libp2pNode.pubsub.ls(t)}),peers:n((t,r)=>{e._libp2pNode.pubsub.peers(t,r)}),setMaxListeners(t){e._libp2pNode.pubsub.setMaxListeners(t)}}}},function(e,t,r){"use strict";(function(t){const n=r(23),i=r(1422),o=r(110),s=r(9),a=r(50);e.exports=(e=>({get:n((r,n,i)=>{if(!t.isBuffer(r))return i(new Error("Not valid key"));"function"==typeof n&&(i=n,n={}),e._libp2pNode.dht.get(r,n.timeout,i)}),put:n((r,n,i)=>{if(!t.isBuffer(r))return i(new Error("Not valid key"));e._libp2pNode.dht.put(r,n,i)}),findprovs:n((t,r)=>{"string"==typeof t&&(t=new s(t)),e._libp2pNode.contentRouting.findProviders(t,r)}),findpeer:n((t,r)=>{"string"==typeof t&&(t=o.createFromB58String(t)),e._libp2pNode.peerRouting.findPeer(t,(e,t)=>{if(e)return r(e);const n=[{Responses:[{ID:t.id.toB58String(),Addresses:t.multiaddrs.toArray().map(e=>e.toString())}]}];r(null,n)})}),provide:n((t,r,n)=>{Array.isArray(t)||(t=[t]),"function"==typeof r&&(n=r,r={}),i(t,(t,r)=>{e._repo.blocks.has(t,r)},(i,o)=>i?n(i):o?void(r.recursive||a(t,(t,r)=>{e._libp2pNode.contentRouting.provide(t,r)},n)):n(new Error("block(s) not found locally, cannot provide")))}),query:n((t,r)=>{"string"==typeof t&&(t=o.createFromB58String(t)),e._libp2pNode._dht.getClosestPeers(t.toBytes(),(e,t)=>{if(e)return r(e);r(null,t.map(e=>({ID:e.toB58String()})))})})}))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=s(r(562)),i=s(r(164)),o=s(r(1423));function s(e){return e&&e.__esModule?e:{default:e}}t.default=(0,i.default)((0,n.default)(o.default,o.default)),e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return!e},e.exports=t.default},function(e,t,r){"use strict";const n=r(1425),i=r(23);e.exports=(()=>i((e,t,r)=>{if("string"!=typeof e)return r(new Error("Invalid arguments, domain must be a string"));"function"==typeof t&&(r=t,t={}),n(e,t,r)}))},function(e,t,r){"use strict";e.exports=((e,t,r)=>{let n=`https://ipfs.io/api/v0/dns?arg=${e=encodeURIComponent(e)}`;for(const e in t)n+=`&${e}=${t[e]}`;self.fetch(n,{mode:"cors"}).then(e=>e.json()).then(e=>e.Path?r(null,e.Path):r(new Error(e.Message))).catch(e=>{r(e)})})},function(e,t,r){"use strict";const n=r(23);e.exports=function(e){return{gen:n((t,r,n)=>{e._keychain.createKey(t,r.type,r.size,n)}),info:n((t,r)=>{e._keychain.findKeyByName(t,r)}),list:n(t=>{e._keychain.listKeys(t)}),rm:n((t,r)=>{e._keychain.removeKey(t,r)}),rename:n((t,r,n)=>{e._keychain.renameKey(t,r,(e,r)=>{if(e)return n(e);const i={was:t,now:r.name,id:r.id,overwrite:!1};n(null,i)})}),import:n((t,r,n,i)=>{e._keychain.importKey(t,r,n,i)}),export:n((t,r,n)=>{e._keychain.exportKey(t,r,n)})}}},function(e,t,r){"use strict";const n=r(23),i=r(122),o=r(46),s=r(1428),a=r(140);function u(e,t){return new Promise((r,n)=>{let o;(o=t.peer?e._libp2pNode.stats.forPeer(t.peer):t.proto?e._libp2pNode.stats.forProtocol(t.proto):e._libp2pNode.stats.global)?r({totalIn:o.snapshot.dataReceived,totalOut:o.snapshot.dataSent,rateIn:new i(o.movingAverages.dataReceived[6e4].movingAverage()/60),rateOut:new i(o.movingAverages.dataSent[6e4].movingAverage()/60)}):r({totalIn:new i(0),totalOut:new i(0),rateIn:new i(0),rateOut:new i(0)})})}e.exports=function(e){const t=t=>{t=t||{};let r=null,n=o(!0,()=>{r&&clearInterval(r)});return t.poll?s(t.interval||"1s",(i,o)=>{if(i)throw i;r=setInterval(()=>{u(e,t).then(e=>n.push(e)).catch(e=>n.end(e))},o)}):u(e,t).then(e=>{n.push(e),n.end()}).catch(e=>n.end(e)),n.source};return{bitswap:r(598)(e).stat,repo:r(510)(e).stat,bw:n((t,r)=>{"function"==typeof t&&(r=t,t={}),u(e,t).then(e=>r(null,e)).catch(e=>r(e))}),bwReadableStream:e=>a.source(t(e)),bwPullStream:t}}},function(e,t,r){"use strict";const n=r(23),i=/^((\d+(\.\d+)*)(ns|ms|us|µs|m|s|h))+$/,o=/((\d+(\.\d+)*)(ns|ms|us|µs|m|s|h))/g,s=/(ns|ms|us|µs|m|s|h)/g,a={ns:1e-6,us:.001,"µs":.001,ms:1,s:1e3,m:6e4,h:36e5};e.exports=n(function(e,t){return"string"!=typeof e?t(new Error("the first argument must be a string")):i.test(e)?void t(null,e.match(o).reduce((e,t)=>e+function(e){let t=e.match(s)[0];return e=e.substring(0,e.length-t.length),parseFloat(e)*a[t]}(t),0)):t(new Error("invalid time"))})},function(e,t,r){"use strict";const n=r(23),i=r(1430);e.exports=(e=>{const t=Object.assign({},e);return t.dag=Object.assign({},e.dag,{put:n((t,r,n)=>("function"==typeof r&&(n=r,r={}),r=Object.assign({},r,{preload:!1}),e.dag.put(t,r,n)))}),i(t,t._options)})},function(e,t,r){"use strict";e.exports=r(1431)},function(e,t,r){"use strict";const n=r(23),{createLock:i}=r(48),o={ls:r(1458),read:r(1459),readPullStream:r(326),readReadableStream:r(1460),stat:r(607)},s={cp:r(608),flush:r(1461),mkdir:r(1462),mv:r(1463),rm:r(609),write:r(1464)},a=(e,t,r,i)=>{Object.keys(r).forEach(o=>{r.hasOwnProperty(o)&&(t[o]=n(i(r[o](e))))})},u={repoOwner:!0};e.exports=((e,t)=>{const{repoOwner:r}=Object.assign({},u||{},t),n=i(r),c={};return a(e,c,o,e=>n.readLock(e)),a(e,c,s,e=>n.writeLock(e)),c})},function(e,t,r){"use strict";(function(t){e.exports=(e=>{let r=t.alloc(0);const n=(i,o)=>{e(null,(e,s)=>{if(e)return!0===e?o(null,r):o(e);if((r=t.concat([r,s])).length{let t=0;return n(e=>{t+=e.length},()=>{e(t)})})},function(e,t,r){"use strict";const n=r(1435),i=r(1)("ipfs:mfs:lock");e.exports=(e=>{const t=n({singleProcess:e}),r=(e,r,n,o)=>{i(`Queuing ${e} operation`),t[`${e}Lock`](()=>new Promise((t,o)=>{n.push((r,n)=>{if(i(`${e} operation callback invoked${r?" with error":""}`),r)return o(r);t(n)}),i(`Starting ${e} operation`),r.apply(null,n)})).then(t=>{i(`Finished ${e} operation`);const r=o;o=null,r(null,t)}).catch(t=>{if(i(`Finished ${e} operation with error`),o)return o(t);throw i(`Callback already invoked for ${e} operation`),t})};return{readLock:e=>(function(){const t=Array.from(arguments);let n=t.pop();r("read",e,t,n)}),writeLock:e=>(function(){const t=Array.from(arguments);let n=t.pop();r("write",e,t,n)})}})},function(e,t,r){(function(t){const n=r(1436),i=r(1446),o=r(1447),{timeout:s}=r(1448),a=r(601),u={};let c;const f={concurrency:1/0,timeout:846e5,global:t,singleProcess:!1};e.exports=((e,t)=>(t||(t={}),"object"==typeof e&&(t=e,e="lock"),e||(e="lock"),t=Object.assign({},f,t),c||(c=n(t)||i(t)).isWorker||(c.on("requestReadLock",(e,t)=>{u[e]&&u[e].readLock(t)}),c.on("requestWriteLock",(e,t)=>{u[e]&&u[e].writeLock(t)})),u[e]||(u[e]=((e,t)=>{if(c.isWorker)return{readLock:c.readLock(e,t),writeLock:c.writeLock(e,t)};const r=new o({concurrency:1});let n=null;return{readLock:e=>{if(!n){const e=n=new o({concurrency:t.concurrency,autoStart:!1});r.add(()=>(e.start(),e.onIdle().then(()=>{n===e&&(n=null)})))}return n.add(()=>s(e(),t.timeout))},writeLock:e=>(n=null,r.add(()=>s(e(),t.timeout)))}})(e,t)),u[e])),e.exports.Worker=function(e,r){let n;r=r||t.Worker;try{n=new r(e)}catch(t){t.message.includes("not a constructor")&&(n=r(e))}if(!n)throw new Error("Could not create Worker from",r);return a(n),n}}).call(this,r(6))},function(e,t,r){(function(t){const n=r(11).EventEmitter,i=r(599),{WORKER_REQUEST_READ_LOCK:o,WORKER_RELEASE_READ_LOCK:s,MASTER_GRANT_READ_LOCK:a,WORKER_REQUEST_WRITE_LOCK:u,WORKER_RELEASE_WRITE_LOCK:c,MASTER_GRANT_WRITE_LOCK:f}=r(600);let l;const h=(e,t,r,n,i)=>(o,s)=>{s&&s.type===r&&e.emit(t,s.name,()=>(o.send({type:i,name:s.name,identifier:s.identifier}),new Promise(e=>{const t=r=>{r&&r.type===n&&r.identifier===s.identifier&&(o.removeListener("message",t),e())};o.on("message",t)})))},p=(e,r,n,o)=>s=>{const a=i.generate();return t.send({type:r,identifier:a,name:e}),new Promise((r,i)=>{const u=c=>{if(c&&c.type===n&&c.identifier===a){t.removeListener("message",u);let n=null;s().catch(e=>{n=e}).then(s=>{if(t.send({type:o,identifier:a,name:e}),n)return i(n);r(s)})}};t.on("message",u)})};e.exports=(e=>{try{if(l=r(1445),!Object.keys(l).length)return}catch(e){return}if(l.isMaster||e.singleProcess){const e=new n;return l.on("message",h(e,"requestReadLock",o,s,a)),l.on("message",h(e,"requestWriteLock",u,c,f)),e}return{isWorker:!0,readLock:(e,t)=>p(e,o,a,s),writeLock:(e,t)=>p(e,u,f,c)}})}).call(this,r(7))},function(e,t,r){"use strict";var n=r(203),i=r(1439),o=r(1443),s=r(1444)||0;function a(){return i(s)}e.exports=a,e.exports.generate=a,e.exports.seed=function(t){return n.seed(t),e.exports},e.exports.worker=function(t){return s=t,e.exports},e.exports.characters=function(e){return void 0!==e&&n.characters(e),n.shuffled()},e.exports.isValid=o},function(e,t,r){"use strict";var n=1;e.exports={nextValue:function(){return(n=(9301*n+49297)%233280)/233280},seed:function(e){n=e}}},function(e,t,r){"use strict";var n,i,o=r(1440),s=(r(203),1459707606518),a=6;e.exports=function(e){var t="",r=Math.floor(.001*(Date.now()-s));return r===i?n++:(n=0,i=r),t+=o(a),t+=o(e),n>0&&(t+=o(n)),t+o(r)}},function(e,t,r){"use strict";var n=r(203),i=r(1441),o=r(1442);e.exports=function(e){for(var t,r=0,s="";!t;)s+=o(i,n.get(),1),t=e(o,s)=>{if(!s||!s.data||s.data.type!==r)return;const a={type:s.data.type,name:s.data.name,identifier:s.data.identifier};e.emit(t,a.name,()=>(o.postMessage({type:i,name:a.name,identifier:a.identifier}),new Promise(e=>{const t=r=>{if(!r||!r.data)return;const i={type:r.data.type,name:r.data.name,identifier:r.data.identifier};i&&i.type===n&&i.identifier===a.identifier&&(o.removeEventListener("message",t),e())};o.addEventListener("message",t)})))},p=(e,t,r,n,o)=>s=>{const a=i.generate();return e.postMessage({type:r,identifier:a,name:t}),new Promise((r,i)=>{const u=c=>{if(!c||!c.data)return;const f={type:c.data.type,identifier:c.data.identifier};if(f&&f.type===n&&f.identifier===a){let n;e.removeEventListener("message",u),s().catch(e=>{n=e}).then(s=>(e.postMessage({type:o,identifier:a,name:t}),n?i(n):r(s)))}};e.addEventListener("message",u)})},d={global:t,singleProcess:!1};e.exports=(e=>{if(!!(e=Object.assign({},d,e)).global.document||e.singleProcess){const e=new n;return l.addEventListener("message",h(e,"requestReadLock",o,s,a)),l.addEventListener("message",h(e,"requestWriteLock",u,c,f)),e}return{isWorker:!0,readLock:(e,t)=>p(t.global,e,o,a,s),writeLock:(e,t)=>p(t.global,e,u,f,c)}})}).call(this,r(6))},function(e,t,r){"use strict";class n{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 n=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}(this._queue,r,(e,t)=>t.priority-e.priority);this._queue.splice(n,0,r)}dequeue(){return this._queue.shift().run}get size(){return this._queue.length}}e.exports=class{constructor(e){if(!("number"==typeof(e=Object.assign({concurrency:1/0,autoStart:!0,queueClass:n},e)).concurrency&&e.concurrency>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e.concurrency}\` (${typeof e.concurrency})`);this.queue=new e.queueClass,this._queueClass=e.queueClass,this._pendingCount=0,this._concurrency=e.concurrency,this._isPaused=!1===e.autoStart,this._resolveEmpty=(()=>{}),this._resolveIdle=(()=>{})}_next(){this._pendingCount--,this.queue.size>0?this._isPaused||this.queue.dequeue()():(this._resolveEmpty(),this._resolveEmpty=(()=>{}),0===this._pendingCount&&(this._resolveIdle(),this._resolveIdle=(()=>{})))}add(e,t){return new Promise((r,n)=>{const i=()=>{this._pendingCount++;try{Promise.resolve(e()).then(e=>{r(e),this._next()},e=>{n(e),this._next()})}catch(e){n(e),this._next()}};!this._isPaused&&this._pendingCountthis.add(e,t)))}start(){if(this._isPaused)for(this._isPaused=!1;this.queue.size>0&&this._pendingCount{const t=this._resolveEmpty;this._resolveEmpty=(()=>{t(),e()})})}onIdle(){return 0===this._pendingCount?Promise.resolve():new Promise(e=>{const t=this._resolveIdle;this._resolveIdle=(()=>{t(),e()})})}get size(){return this.queue.size}get pending(){return this._pendingCount}get isPaused(){return this._isPaused}}},function(e,t,r){"use strict";var n;e.exports.timeout=function(e,t){var r,i=new n;return Promise.race([e,new Promise(function(e,n){r=setTimeout(function(){n(i)},t)})]).then(function(e){return clearTimeout(r),e},function(e){throw clearTimeout(r),e})};(n=e.exports.TimeoutError=function(){Error.call(this),this.stack=Error().stack,this.message="Timeout"}).prototype=Object.create(Error.prototype),n.prototype.name="TimeoutError"},function(e,t,r){"use strict";(function(t){const n=r(9);e.exports=((e,r)=>(t.isBuffer(e)&&(e=new n(e)),"base58btc"===r?e.toBaseEncodedString():e.toV1().toBaseEncodedString(r)))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(153),i=r(603);e.exports=(e=>{let t=0;return n((r,n)=>{t>e&&i(n),t+r.length>e&&(r=r.slice(0,e-t)),t+=r.length,n(null,r)})})},function(e,t,r){"use strict";const n=r(4),i=r(9),o=r(1)("ipfs:mfs:utils:load-node");e.exports=((e,t,r)=>{const s=t&&(t.multihash||t.hash);if(!s)return o("No multihash passed so cannot load DAGNode"),r();const a=new i(s);o(`Loading DAGNode for child ${a.toBaseEncodedString()}`),n([t=>e.dag.get(a,t),(e,t)=>t(null,e.value)],r)})},function(e,t,r){"use strict";const n=r(604);e.exports=function(e,t){const{sources:r,options:i,callback:o}=n(e,t);return{sources:r,destination:r.pop(),options:i,callback:o}}},function(e,t,r){"use strict";const n=r(9),i=r(1)("ipfs:mfs:utils:traverse-to"),o=r(36),s=r(4),a=r(1454),u=r(605),c=r(606),f=r(325),{FILE_SEPARATOR:l}=r(146),h=r(602),p={parents:!1,flush:!0,createLastComponent:!1,withCreateHint:!0},d=(e,t,r,n)=>{i("IPFS",t),s([r=>e.dag.get(t.path,r),(e,r)=>r(null,{name:t.name,node:e&&e.value,parent:null})],n)},y=(e,t,r,c)=>{s([t=>u(e,t),(u,c)=>{const p=t.path.split(l).filter(Boolean),d=[];s([t=>e.dag.get(u,t),(u,c)=>{const y=u.value;d.push({name:l,node:y,parent:null}),a(p.map((e,t)=>({pathSegment:e,index:t})),{name:l,node:y,parent:null},(a,{pathSegment:u,index:c},l)=>{const y=a.node.links.find(e=>e.name===u);if(!y){const y=c===p.length-1;if(i(`index ${c} pathSegments.length ${p.length} pathSegment ${u} lastComponent ${y}`,r),y&&!r.createLastComponent)return l(new Error(`Path ${t.path} did not exist`));if(!y&&!r.parents){let e=`Cannot find ${t.path} - ${u} did not exist`;return r.withCreateHint&&(e+=": Try again with the --parents flag to create it"),l(new Error(e))}return i(`Adding empty directory '${u}' to parent ${a.name}`),s([t=>h(e,new o("directory").marshal(),[],r,t),(t,i)=>{f(e,{parent:a.node,child:t,name:u,flush:r.flush},(e,r)=>{a.node=r,i(e,{name:u,node:t,cid:new n(t.multihash),parent:a})})}],(e,t)=>{d.push(t),l(e,t)})}let g=y.hash||y.multihash;const m=new n(g);e.dag.get(m,(e,t)=>{if(e)return l(e);const r=t.value,n={name:u,node:r,parent:a};d.push(n),l(null,n)})},c)}],c)}],c)};e.exports=((e,t,r,n)=>{r=Object.assign({},p,r),i("Traversing to",t),s([e=>c(t,e),(t,n)=>"mfs"===t.type?y(e,t,r,n):d(e,t,r,n)],n)})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,a){a=(0,o.default)(a||i.default);var u=(0,s.default)(r);(0,n.default)(e,function(e,r,n){u(t,e,function(e,r){t=r,n(e)})},function(e){a(e,t)})};var n=a(r(215)),i=a(r(54)),o=a(r(156)),s=a(r(34));function a(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default},function(e,t,r){"use strict";const n=r(1)("ipfs:mfs:utils:update-mfs:root"),i=r(4),o=r(9),{MFS_ROOT_KEY:s}=r(146);e.exports=((e,t,r)=>{const a=e._repo,u=a&&a.datastore;if(!a||!u)return r(new Error("Please run jsipfs init first"));const c=new o(t);n(`New MFS root will be ${c.toBaseEncodedString()}`),i([e=>{if(a.closed)return n("Opening datastore"),u.open(t=>e(t));n("Datastore was already open"),e()},e=>u.put(s,c.buffer,t=>e(t))],e=>r(e,c))})},function(e,t,r){"use strict";const n=r(352),i=r(325);e.exports=((e,t,r)=>{n(r=>{if(!t.parent){const e=t;return t=null,r(null,e)}i(e,{parent:t.parent.node,child:t.node,name:t.name,flush:!0},(e,n)=>{t.parent.node=n;const i=t;t=t.parent,r(e,i)})},()=>Boolean(t),r)})},function(e,t,r){"use strict";(function(t){e.exports=((e=1/0,r=4096)=>{let n=0;return(i,o)=>{if(i)return o&&o(i);if(n>=e)return o(!0);let s=r;n+s>e&&(s=e-n),n+=s,o(null,t.alloc(s,0))}})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(4),i=r(80),o=r(36),{traverseTo:s,loadNode:a,formatCid:u,FILE_SEPARATOR:c,FILE_TYPES:f}=r(48),l={long:!1,cidBase:"base58btc"};e.exports=(e=>(function(t,r,h){"function"==typeof t&&(h=t,t=c,r={}),"function"==typeof r&&(h=r,r={}),(r=Object.assign({},l,r)).long=r.l||r.long,n([r=>s(e,t,{},r),(t,s)=>{const c=o.unmarshal(t.node.data);"directory"===c.type?i(t.node.links,(t,i)=>{n([r=>a(e,t,r),(e,n)=>{const i=o.unmarshal(e.data);n(null,{name:t.name,type:i.type,hash:u(e.multihash,r.cidBase),size:i.fileSize()||0})}],i)},s):s(null,[{name:t.name,type:c.type,hash:u(t.node.multihash,r.cidBase),size:c.fileSize()||0}])},(e,t)=>t(null,e.map(e=>(f.hasOwnProperty(e.type)&&(e.type=f[e.type]),r.long||(e.type=0,e.size=0,e.hash=""),e))),(e,t)=>{if(r.long)return t(null,e.sort((e,t)=>t.name.localeCompare(e.name)));t(null,e)}],h)}))},function(e,t,r){"use strict";(function(t){const n=r(70),i=r(87),o=r(4),s=r(326);e.exports=(e=>(function(r,a,u){"function"==typeof a&&(u=a,a={}),o([t=>s(e)(r,a,t),(e,t)=>n(e,i(t)),(e,r)=>{r(null,t.concat(e))}],u)}))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(4),i=r(326),o=r(140);e.exports=(e=>(function(t,r,s){"function"==typeof r&&(s=r,r={}),n([n=>i(e)(t,r,n),(e,t)=>t(null,o.source(e))],s)}))},function(e,t,r){"use strict";const n=r(4),{traverseTo:i,FILE_SEPARATOR:o}=r(48),s={};e.exports=(e=>(function(t,r,a){"function"==typeof r&&(a=r,r={}),"function"==typeof t&&(a=t,r={},t=o),t||(t=o),r=Object.assign({},s,r),n([r=>i(e,t,{},r),(e,t)=>{t()}],a)}))},function(e,t,r){"use strict";const n=r(4),i=r(1)("ipfs:mfs:mkdir"),{updateMfsRoot:o,updateTree:s,traverseTo:a,FILE_SEPARATOR:u}=r(48),c={parents:!1,hash:void 0,cidVersion:0};e.exports=(e=>(function(t,r,f){return"function"==typeof r&&(f=r,r={}),(r=Object.assign({},c,r)).parents=r.p||r.parents,r.cidVersion=r.cidVersion||0,t?(t=t.trim())===u?f(r.parents?null:new Error(`cannot create directory '${u}': Already exists`)):(i(`Creating ${t}`),void n([r=>{a(e,t,{parents:!1,createLastComponent:!1},e=>e?e.message.includes("did not exist")?(i(`${t} did not exist`),r()):r(e):(i(`${t} already exists`),r(new Error("file already exists"))))},n=>a(e,t,{parents:r.parents,flush:r.flush,createLastComponent:!0},n),(t,r)=>s(e,t,r),(t,r)=>o(e,t.node.multihash,r)],e=>{e&&e.message.includes("file already exists")&&r.parents&&(e=null),f(e)})):f(new Error("no path given to Mkdir"))}))},function(e,t,r){"use strict";const n=r(49),{toSources:i}=r(48),o=r(608),s=r(609),a={parents:!1,recursive:!1,flush:!0,format:"dag-pb",hashAlg:"sha2-256"};e.exports=(e=>(function(){let t=Array.from(arguments);Array.isArray(t[0])&&(t=t[0].concat(t.slice(1)));const{sources:r,options:u,callback:c}=i(t,a),f=r.map(e=>e.path).concat(u),l=r.slice(0,-1).map(e=>e.path).concat(Object.assign(u,{recursive:!0}));n([t=>o(e).apply(null,f.concat(t)),t=>s(e).apply(null,l.concat(t))],c)}))},function(e,t,r){"use strict";(function(t,n){const i=r(23),o=r(9),s=r(4),a=r(63),{updateMfsRoot:u,validatePath:c,traverseTo:f,addLink:l,updateTree:h,limitStreamBytes:p}=r(48),d=r(86),y=r(1)("ipfs:mfs:write"),g=r(610),m=r(1465),b=r(192),v=r(596),_=r(1468),w=r(597),S=r(141),k=r(70),E=r(1471),A={offset:0,length:void 0,create:!1,truncate:!1,rawLeaves:!1,reduceSingleLeafToSelf:!1,cidVersion:0,hashAlg:"sha2-256",format:"dag-pb",parents:!1,progress:void 0,strategy:"trickle",flush:!0,leafType:"raw"},x=(e,r,i)=>e?t.isBuffer(e)?(y("Content was a buffer"),r.length=r.length||e.length,i(null,d([e]))):"string"==typeof e||e instanceof String?(y("Content was a path"),s([t=>r.length?t(null,{size:r.length}):E.stat(e,t),(t,n)=>{r.length=t.size,n(null,b.source(E.createReadStream(e)))}],i)):(n.Blob&&e instanceof n.Blob&&(y("Content was an HTML5 Blob"),r.length=r.length||e.size,e=_(e)),v(e)?(y("Content was a Node stream"),i(null,b.source(e))):w.isSource(e)?(y("Content was a pull-stream"),i(null,e)):void i(new Error(`Don't know how to convert ${e} into a pull stream source`))):i(new Error("paths must start with a leading /"));e.exports=function(e){return i((t,r,n,i)=>("function"==typeof n&&(i=n,n={}),(n=Object.assign({},A,n)).offset<0?i(new Error("cannot have negative write offset")):n.length<0?i(new Error("cannot have negative byte count")):0!==n.length||n.truncate?(n.length||(n.length=1/0),n.cidVersion=n.cidVersion||0,void s([e=>{a([e=>x(r,n,e),e=>c(t,e)],e)},([t,r],i)=>{s([i=>f(e,r.directory,Object.assign({},n,{createLastComponent:n.parents}),(e,r)=>i(e,t,r)),(t,i,o)=>{I(e,n,r,t,i,o)}],i)}],e=>i(e))):i()))};const I=(e,r,n,i,a,c)=>{s([s=>{const u=a.node.links.reduce((e,t)=>t.name===n.name?t:e,null);if(u){const t=new o(u.multihash);y(`Updating linked DAGNode ${t.toBaseEncodedString()}`),m(e,t,i,r,s)}else{if(!r.create)return s(new Error("file does not exist"));r.offset&&(r.length+=r.offset,i=S([d([t.alloc(r.offset,0)]),i])),i=k(i,p(r.length)),y("Importing file",n.name),g(e,i,r,s)}},(t,i)=>l(e,{parent:a.node,name:n.name,child:{multihash:t.multihash||t.hash,size:t.size},flush:r.flush},(e,t)=>{a.node=t,i(e)}),t=>h(e,a,t),(t,r)=>u(e,t.node.multihash,r)],c)}}).call(this,r(0).Buffer,r(6))},function(e,t,r){"use strict";const n=r(36),{unmarshal:i}=n,o=r(70),s=r(141),a=r(87),u=r(46),c=r(348),f=r(120),l=r(4),h=r(63),p=r(1)("ipfs:mfs:write:update-node"),{limitStreamBytes:d,countStreamBytes:y,createNode:g,zeros:m,loadNode:b}=r(48),v=r(610),_=r(1466),w=r(1467),{DAGLink:S}=r(45);e.exports=((e,t,r,n,k)=>{let E=n.offset||0,A=E,x=E+n.length,I=A;l([r=>b(e,t,r),(b,k)=>{const T=i(b.data).fileSize();p(`Updating bytes ${A}-${x} of ${T} bytes from ${t.toBaseEncodedString()} with source`);let B=0;A>T&&(p(`Adding ${B=A-T} 0s to the start of the block`),r=s([m(B),r]));const C=u(),P=u();o(r,f(Boolean),d(n.length+B),y(e=>{x===1/0&&(x=E+e)}),c(e=>{p(`Writing ${e.length} at ${I} of ${T}`),IT?(C.push(e.slice(0,T-I)),P.push(e.slice(T-I))):C.push(e):P.push(e),I+=e.length}),a(e=>{C.end(e),P.end()})),l([t=>{h([t=>_(e,b,T,A,x,C,n,t),t=>v(e,P,n,t)],t)},([t,r],o)=>{const s=i((t=t||b).data),a=i(r.data);if(a.fileSize()){const i=t.links;return a.data&&a.data.length?(p("New data was found on appended node"),r.links&&r.links.length&&p("New data was also found on appended node children"),s.addBlockSize(a.fileSize()),i.push(new S("",r.size,r.multihash))):r.links&&r.links.length&&(p("New data required multiple DAGNodes"),r.links.forEach((e,t)=>{s.addBlockSize(a.blockSizes[t]),i.push(e)})),g(e,s.marshal(),i,n,o)}o(null,t)},(t,r)=>{if(n.truncate)return w(e,t,x,n,r);r(null,t)}],k)}],k)})},function(e,t,r){"use strict";(function(t){const n=r(4),i=r(70),o=r(86),s=r(153),a=r(120),u=r(87),c=r(324),f=r(1)("ipfs:mfs:write:update-tree"),l=r(36),h=r(9),{unmarshal:p}=l,{leafFirst:d}=r(225),{DAGLink:y}=r(45),{createNode:g,loadNode:m,bufferPullStreamSource:b}=r(48);e.exports=((e,r,v,_,w,S,k,E)=>{let A=0;function x({node:t}){const r=p(t.data);f(`Node links ${t.links.length}${r.blockSizes.length?`, block sizes ${r.blockSizes.join(", ")}`:""} with ${r.data?`${r.data.length} bytes of`:"no"} data`);const n={node:t},s=t.links.map((e,t)=>{const i={parent:n,link:e,index:t,nodeStart:A,nodeEnd:A+r.blockSizes[t]};return A=i.nodeEnd,i}).filter((e,t)=>(f("child.nodeStart",e.nodeStart,"child.nodeEnd",e.nodeEnd,"streamStart",_,"streamEnd",w),_>=e.nodeStart&&_e.nodeStart&&w<=e.nodeEnd||_e.nodeEnd));return s.length?(A=s[0].nodeStart,f(`Updating links with index(es) ${s.map(e=>e.index).join(",")}`)):f("No links to update"),i(o(s),c((t,r)=>{m(e,t.link,(e,n)=>{r(e,Object.assign({},t,{node:n}))})}))}function I(r){const i=b(r);return({parent:r,link:o,nodeStart:s,node:a,index:u},c)=>{if(!a||!a.data)return c();const f=p(a.data);if(!f||!f.data||!f.data.length)return c();n([e=>i(f.data.length,e),(e,r)=>{const n=_-s;let i=w-_;f.data.lengthg(e,t,[],k,r),(e,t)=>{t(null,{parent:r,index:u,multihash:e.multihash,size:e.size})}],c)}}n([t=>i(d({parent:null,link:null,index:null,node:r,nodeStart:A,nodeEnd:v},x),c(I(S)),a(Boolean),s((t,r)=>{if(!t.parent||void 0===t.index)return r(null,t);const i=t.parent.node.links.map((e,r)=>r===t.index?new y("",t.size,t.multihash):e);n([r=>g(e,t.parent.node.data,i,k,r),(e,r)=>{t.parent.node=e,r(null,t)}],r)}),u((e,r)=>{let n;if(!e&&r&&r.length){for(n=r[0];n.parent;)n=n.parent;n.node&&(n=n.node),f(`Updated root is ${new h(n.multihash).toBaseEncodedString()}`)}t(e,n)})),(t,r)=>m(e,t,r)],E)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(145).exporter,i=r(145).importer,o=r(70),s=r(86),a=r(153),u=r(87),c=r(1)("ipfs:mfs:write:truncate-node"),{loadNode:f}=r(48);e.exports=((e,t,r,l,h)=>{c(`Truncating ${t.multihash} to ${r} bytes`),o(n(t.multihash,e.dag,{offset:0,length:r}),a((t,r)=>{o(s([{content:t.content}]),i(e.dag,{progress:l.progress,hashAlg:l.hash,cidVersion:l.cidVersion,strategy:l.strategy,rawLeaves:l.rawLeaves,reduceSingleLeafToSelf:l.reduceSingleLeafToSelf,leafType:l.leafType}),u(r))}),a((t,r)=>f(e,t[0],r)),u((e,t)=>{h(e,t.pop())}))})},function(e,t,r){var n=r(1469),i=r(611);e.exports=function(e,t){var r=(t=t||{}).offset||0,o=t.chunkSize||1048576,s=new FileReader(e),a=n(function(t,n){if(r>=e.size)return n(null,null);s.onloadend=function(e){var t=e.target.result;t instanceof ArrayBuffer&&(t=i(new Uint8Array(e.target.result))),n(null,t)};var a=r+o,u=e.slice(r,a);s.readAsArrayBuffer(u),r=a});return a.name=e.name,a.size=e.size,a.type=e.type,a.lastModified=e.lastModified,s.onerror=function(e){a.destroy(e)},a}},function(e,t,r){(function(t){var n=r(22).Readable,i=r(5);e.exports=s,s.ctor=a,s.obj=function(e,t){return("function"==typeof e||Array.isArray(e))&&(t=e,e={}),(e=c(e)).objectMode=!0,e.highWaterMark=16,s(e,t)};var o=a();function s(e,t){("object"!=typeof e||Array.isArray(e))&&(t=e,e={});var r=new o(e);return r._from=Array.isArray(t)?function(e){return e=e.slice(),function(t,r){var n=null,i=e.length?e.shift():null;i instanceof Error&&(n=i,i=null),r(n,i)}}(t):t||u,r}function a(e,r){function o(t){if(!(this instanceof o))return new o(t);this._reading=!1,this._callback=function(e,t){if(!r.destroyed){if(e)return r.destroy(e);if(null===t)return r.push(null);r._reading=!1,r.push(t)&&r._read(i)}},this.destroyed=!1,n.call(this,t||e);var r=this,i=this._readableState.highWaterMark}return"function"==typeof e&&(r=e,e={}),e=c(e),i(o,n),o.prototype._from=r||u,o.prototype._read=function(e){this._reading||this.destroyed||(this._reading=!0,this._from(e,this._callback))},o.prototype.destroy=function(e){if(!this.destroyed){this.destroyed=!0;var r=this;t.nextTick(function(){e&&r.emit("error",e),r.emit("close")})}},o}function u(){}function c(e){return e||{}}}).call(this,r(7))},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){},function(e,t,r){"use strict";const n=r(155);e.exports=(e=>{return new n(e||"ipfs")})},function(e,t,r){"use strict";const n=r(3),i=r(1474),o=r(1475),s=r(1),a=r(9),u=r(1476),c=s("jsipfs:preload");c.error=s("jsipfs:preload:error");const f=e=>{e&&c.error(e)};function l(e){return e.endsWith("http")||e.endsWith("https")||(e+="/http"),o(e)}e.exports=(e=>{const t=e._options.preload||{};if(t.enabled=Boolean(t.enabled),t.addresses=t.addresses||[],!t.enabled||!t.addresses.length)return(e,t)=>{t&&n(()=>t())};let r=!0,o=[];const s=t.addresses.map(l),h=(e,t)=>{if(t=t||f,"string"!=typeof e)try{e=new a(e).toBaseEncodedString()}catch(e){return n(()=>t(e))}const l=Array.from(s);let h;const p=Date.now();i({times:l.length},t=>{if(r)return t(new Error(`preload aborted for ${e}`));o=o.filter(e=>e!==h);const n=l.shift();h=u(`${n}/api/v0/refs?r=true&arg=${e}`,t),o=o.concat(h)},r=>{if(o=o.filter(e=>e!==h),r)return t(r);c(`preloaded ${e} in ${Date.now()-p}ms`),t()})};return h.start=(()=>{r=!1}),h.stop=(()=>{r=!0,c(`canceling ${o.length} pending preload request(s)`),o.forEach(e=>e.cancel()),o=[]}),h})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){var s=5,a=0,u={times:s,intervalFunc:(0,i.default)(a)};if(arguments.length<3&&"function"==typeof e?(r=t||n.default,t=e):(function(e,t){if("object"==typeof t)e.times=+t.times||s,e.intervalFunc="function"==typeof t.interval?t.interval:(0,i.default)(+t.interval||a),e.errorFilter=t.errorFilter;else{if("number"!=typeof t&&"string"!=typeof t)throw new Error("Invalid arguments for async.retry");e.times=+t||s}}(u,e),r=r||n.default),"function"!=typeof t)throw new Error("Invalid arguments for async.retry");var c=(0,o.default)(t),f=1;!function e(){c(function(t){t&&f++t,o={ip4:i,ip6:i,tcp:(e,t,r,n)=>n.some(e=>["http","https","ws","wss"].includes(e.protocol))?`${e}:${t}`:`tcp://${e}:${t}`,udp:(e,t)=>`udp://${e}:${t}`,dnsaddr:i,dns4:i,dns6:i,ipfs:(e,t)=>`${e}/ipfs/${t}`,p2p:(e,t)=>`${e}/p2p/${t}`,http:e=>`http://${e}`,https:e=>`https://${e}`,ws:e=>`ws://${e}`,wss:e=>`wss://${e}`,"p2p-websocket-star":e=>`${e}/p2p-websocket-star`,"p2p-webrtc-star":e=>`${e}/p2p-webrtc-star`,"p2p-webrtc-direct":e=>`${e}/p2p-webrtc-direct`};e.exports=(e=>n(e).stringTuples().map(e=>({protocol:n.protocols.codes[e[0]].name,content:e[1]})).reduce((e,t,r,n)=>{const i=o[t.protocol];if(!i)throw new Error(`Unsupported protocol ${t.protocol}`);return i(e,t.content,r,n)},""))},function(e,t,r){"use strict";const n=r(1),i=n("jsipfs:preload");i.error=n("jsipfs:preload:error"),e.exports=function(e,t){i(e);const r=new self.XMLHttpRequest;return r.open("HEAD",e),r.onreadystatechange=function(){if(this.readyState===this.DONE)return this.status<200||this.status>=300?(i.error("failed to preload",e,this.status,this.statusText),t(new Error(`failed to preload ${e}`))):void t()},r.send(),{cancel:()=>{r.abort(),t(new Error("request aborted"))}}}},function(e,t,r){"use strict";const n=r(1),i=n("jsipfs:mfs-preload");i.error=n("jsipfs:mfs-preload:error"),e.exports=((e,t)=>{let r,n;(t=t||{}).interval=t.interval||3e4;const o=()=>{e.files.stat("/",(s,a)=>s?(n=setTimeout(o,t.interval),i.error("failed to stat MFS root for preload",s)):r!==a.hash?(i(`preloading updated MFS root ${r} -> ${a.hash}`),e._preload(a.hash,e=>{if(n=setTimeout(o,t.interval),e)return i.error(`failed to preload MFS root ${a.hash}`,e);r=a.hash})):void(n=setTimeout(o,t.interval)))};return{start(s){e.files.stat("/",(e,a)=>{if(e)return s(e);r=a.hash,i(`monitoring MFS root ${r}`),n=setTimeout(o,t.interval),s()})},stop(e){clearTimeout(n),e()}}})},function(e,t,r){"use strict";const n=r(1),i=n("jsipfs:state");i.error=n("jsipfs:state:error");const o=r(1479);e.exports=(e=>{const t=o("uninitialized",{uninitialized:{init:"initializing",initialized:"stopped"},initializing:{initialized:"stopped"},stopped:{start:"starting"},starting:{started:"running"},running:{stop:"stopping"},stopping:{stopped:"stopped"}});return t.on("error",e=>i.error(e)),t.on("done",()=>i("-> "+t._state)),t.init=(()=>{t("init")}),t.initialized=(()=>{t("initialized")}),t.stop=(()=>{t("stop")}),t.stopped=(()=>{t("stopped")}),t.start=(()=>{t("start")}),t.started=(()=>{t("started")}),t.state=(()=>t._state),t})},function(e,t,r){const n=r(11).EventEmitter,i=r(17),o=r(1480);e.exports=function(e,t){"object"==typeof e&&(t=e,e="START"),i.equal(typeof e,"string"),i.equal(typeof t,"object"),i.ok(t[e],"invalid starting state "+e),i.ok(o.validate(t));const r=new n;return s._graph=o.reachable(t),s._emitter=r,s._events=t,s._state=e,s.emit=s,s.on=function(e,t){r.on(e,t)},s;function s(e){const t=s._events[s._state][e];if(!function(e,t,r){if(!t)return!1;if(!e)return!0;const n=r[e];return!(!n||!n[t])&&1===n[t].length}(s._state,t,s._graph)){const t="invalid transition: "+s._state+" -> "+e;return r.emit("error",t)}const n=s._state+":leave",i=t+":enter";return s._state?void(r._events[n]?r.emit(n,o):o()):o();function o(){r._events[i]?r.emit(i,a):a()}function a(){s._state=t,r.emit(t),r.emit("done")}}}},function(e,t){function r(e,t){for(var r in e){t(e[r],r,e)}}function n(e){return Object.keys(e).sort()}function i(e,t){return~e.indexOf(t)}function o(e,t){return e.filter(function(e){return i(t,e)})}function s(e,t){return e.filter(function(e){return!i(t,e)}).concat(t.filter(function(t){return!i(e,t)})).sort()}t.validate=function(e){Object.keys(e);return r(e,function(t,n){r(t,function(t,r){if(!e[t])throw new Error("invalid transition from state:"+n+" to state:"+t+" on event:"+r)})}),!0};var a=t.reachable=function(e){var t={},n=!1;do{n=!1,r(e,function(e,i){var o=t[i]=t[i]||{};r(e,function(e,t){o[e]||(o[e]=[t],n=!0)}),r(e,function(e,i){r(t[e],function(e,t){o[t]||(o[t]=[i].concat(e),n=!0)})})})}while(n);return t};t.terminal=t.deadlock=function(e){var t=[];return r(e,function(e,r){(function(e){for(var t in e)return!1;return!0})(e)&&t.push(r)}),t};t.livelock=function(e,t){var n=[];return r(a(e),function(e,o){i(t,o)||r(t,function(t){e[t]||i(n,o)||n.push(o)})}),n.sort()};function u(e){var t=[];return r(e,function(e,n){r(e,function(e,r){i(t,r)||t.push(r)})}),t.sort()}t.combine=function(e,t,r,i){var a={},c=s(u(e),u(t));return function r(i,s){var u,f=i+"-"+s;a[f]||(a[f]={}),u=a[f];var l=n(e[i]),h=n(t[s]);return o(l,h).forEach(function(n){u[n]=e[i][n]+"-"+t[s][n],a[u[n]]||r(e[i][n],t[s][n])}),o(c,l).forEach(function(t){u[t]=e[i][t]+"-"+s,a[u[t]]||r(e[i][t],s)}),o(c,h).forEach(function(e){u[e]=i+"-"+t[s][e],a[u[e]]||r(i,t[s][e])}),a[f]}(r,i),a}},function(e,t,r){const n=r(33),i=r(1482);r(1492)(i),r(1494)(i),r(1495)(i),r(1497)(i),r(1498)(i),r(1508)(i);const o=r(79),s=r(116),a=r(101),u=r(149);let c={db:{name:"indexeddb"},connector:{name:"ipfs"}};class f extends s{constructor(e,t){super(e,t),this.options=e,this.name="YJS",this.supportURLs=["yjs"],this.supportFunctions=["fetch","add","list","listmonitor","newlisturls","connection","get","set","getall","keys","newdatabase","newtable","monitor"],this.status=s.STATUS_LOADED}async p__y(e,t,r){"string"!=typeof e&&(e=e.href),console.assert(e.startsWith("yjs:/yjs/"));try{if(this.yarrays[e])return r&&console.log("Found Y for",e),this.yarrays[e];{let n=s.mergeoptions(this.options,{connector:{room:e}},t);return r&&console.log("Creating Y for",e),this.yarrays[e]=await i(n)}}catch(e){throw console.log("Failed to initialize Y"),e}}async p__yarray(e,t){return this.p__y(e,{share:{array:"Array"}})}async p_connection(e,t){return this.p__y(e,{share:{map:"Map"}})}static setup0(e,t){let r=s.mergeoptions(c,e.yjs);t&&console.log("YJS options %o",r);let n=new f(r,t);return a.addtransport(n),n}async p_setup2(e,t){try{this.status=s.STATUS_STARTING,t&&t(this),this.options.connector.ipfs=a.ipfs(e).ipfs,this.yarrays={},await this.p_status(e)}catch(e){console.error(this.name,"failed to start",e),this.status=s.STATUS_FAILED}return t&&t(this),this}async p_status(e){return this.status=await this.options.connector.ipfs.isOnline()?s.STATUS_CONNECTED:s.STATUS_FAILED,super.p_status(e)}async p_rawlist(e,{verbose:t=!1}={}){try{let r=(await this.p__yarray(e,t)).share.array.toArray();return t&&console.log("p_rawlist found",...u.consolearr(r)),r}catch(e){throw console.log("TransportYJS.p_rawlist failed",e.message),e}}listmonitor(e,t,{verbose:r=!1,current:n=!1}={}){let i=this.yarrays["string"==typeof e?e:e.href];console.assert(i,"Should always exist before calling listmonitor - async call p__yarray(url) to create"),n&&i.share.array.toArray.map(t),i.share.array.observe(e=>{"insert"===e.type&&(r&&console.log("resources inserted",e.values),e.values.map(t))})}rawreverse(){throw new o.ToBeImplementedError("Undefined function TransportYJS.rawreverse")}async p_rawadd(e,t,{verbose:r=!1}={}){console.assert(e&&t.urls.length&&t.signature&&t.signedby.length,"TransportYJS.p_rawadd args",e,t),r&&console.log("TransportYJS.p_rawadd","string"==typeof e?e:e.href,t);let n=t.preflight(Object.assign({},t));(await this.p__yarray(e,r)).share.array.push([n])}p_newlisturls(e,{verbose:t=!1}={}){let r=e._publicurls.map(e=>n.parse(e)).find(e=>"ipfs"===e.protocol&&e.pathname.includes("/ipfs/")||"yjs:"===e.protocol);return r||(r=`yjs:/yjs/${e.keypair.verifyexportmultihashsha256_58()}`),[r,r]}async p_newdatabase(e,{verbose:t=!1}={}){e.hasOwnProperty("keypair")&&(e=e.keypair.signingexport());let r=`yjs:/yjs/${encodeURIComponent(e)}`;return{publicurl:r,privateurl:r}}async p_newtable(e,t,{verbose:r=!1}={}){if(!e)throw new o.CodingError("p_newtable currently requires a pubkey");let n=await this.p_newdatabase(e,{verbose:r});return{privateurl:`${n.privateurl}/${t}`,publicurl:`${n.publicurl}/${t}`}}async p_set(e,t,r,{verbose:n=!1}={}){let i=await this.p_connection(e,n);"string"==typeof t?i.share.map.set(t,JSON.stringify(r)):Object.keys(t).map(e=>i.share.map.set(e,t[e]))}_p_get(e,t,{verbose:r=!1}={}){if(Array.isArray(t))return t.reduce(function(t,r){let n=e.share.map.get(r);return t[r]="string"==typeof n?JSON.parse(n):n,t},{});{let r=e.share.map.get(t);return"string"==typeof r?JSON.parse(r):r}}async p_get(e,t,{verbose:r=!1}={}){return this._p_get(await this.p_connection(e,r),t,{verbose:r})}async p_delete(e,t,{verbose:r=!1}={}){let n=await this.p_connection(e,r);"string"==typeof t?n.share.map.delete(t):t.map(e=>n.share.map.delete(e))}async p_keys(e,{verbose:t=!1}={}){return(await this.p_connection(e,t)).share.map.keys()}async p_getall(e,{verbose:t=!1}={}){let r=await this.p_connection(e,t),n=r.share.map.keys();return this._p_get(r,n,{verbose:t})}async p_rawfetch(e,{verbose:t=!1}={}){return{table:"keyvaluetable",_map:await this.p_getall(e,{verbose:t})}}async monitor(e,t,{verbose:r=!1,current:n=!1}={}){e="string"==typeof e?e:e.href;let i=this.yarrays[e];if(!i)throw new o.CodingError("Should always exist before calling monitor - async call p__yarray(url) to create");n&&i.share.map.keys().forEach(e=>{let r=i.share.map.get[e];t({type:"set",key:e,value:"string"==typeof r?JSON.parse(r):r})}),i.share.map.observe(n=>{if(["add","update"].includes(n.type)&&(r&&console.log("YJS monitor:",e,n.type,n.name,n.value),"update"!==n.type||n.oldValue!==n.value)){let e={type:{add:"set",update:"set",delete:"delete"}[n.type],value:JSON.parse(n.value),key:n.name};t(e)}})}static async p_test(e={},t=!1){t&&console.log("TransportHTTP.test");try{let r=await this.p_setup(e,t);t&&console.log("HTTP connected");let n=await r.p_info(t);t&&console.log("TransportHTTP info=",n),n=await r.p_status(t),console.assert(n===s.STATUS_CONNECTED),await r.p_test_kvt("NACL%20VERIFY",t)}catch(e){throw console.log("Exception thrown in TransportHTTP.test:",e.message),e}}}f.Y=i,a._transportclasses.YJS=f,e.exports=f},function(e,t,r){"use strict";r(1483)(i),r(1484)(i),r(1485)(i),r(1486)(i),r(1487)(i),r(1488)(i),i.debug=r(1489);var n={};function i(e){e.hasOwnProperty("sourceDir")&&(i.sourceDir=e.sourceDir),e.types=null!=e.types?e.types:[];var t=[e.db.name,e.connector.name].concat(e.types);for(var r in e.share)t.push(e.share[r]);return new Promise(function(r,n){null==e?n("An options object is expected! "):null==e.connector?n("You must specify a connector! (missing connector property)"):null==e.connector.name?n("You must specify connector name! (missing connector.name property)"):null==e.db?n("You must specify a database! (missing db property)"):null==e.connector.name?n("You must specify db name! (missing db.name property)"):((e=i.utils.copyObject(e)).connector=i.utils.copyObject(e.connector),e.db=i.utils.copyObject(e.db),e.share=i.utils.copyObject(e.share),setTimeout(function(){i.requestModules(t).then(function(){var t=new o(e);t.db.whenUserIdSet(function(){t.init(function(){r(t)})})}).catch(n)},0))})}e.exports=i,i.requiringModules=n,i.extend=function(e,t){if(2===arguments.length&&"string"==typeof e)t instanceof i.utils.CustomTypeDefinition?i[e]=t.parseArguments:i[e]=t,null!=n[e]&&(n[e].resolve(),delete n[e]);else for(var r=0;r{})}userLeft(e){if(null!=this.connections[e])for(var t of(this.log("User left: %s",e),delete this.connections[e],e===this.currentSyncTarget&&(this.currentSyncTarget=null,this.findNextSyncTarget()),this.syncingClients=this.syncingClients.filter(function(t){return t!==e}),this.userEventListeners))t({action:"userLeft",user:e})}userJoined(e,t){if(null==t)throw new Error("You must specify the role of the joined user!");if(null!=this.connections[e])throw new Error("This user already joined!");for(var r of(this.log("User joined: %s",e),this.connections[e]={isSynced:!1,role:t},this.userEventListeners))r({action:"userJoined",user:e,role:t});null==this.currentSyncTarget&&this.findNextSyncTarget()}whenSynced(e){this.isSynced?e():this.whenSyncedListeners.push(e)}findNextSyncTarget(){if(null==this.currentSyncTarget){var e=null;for(var t in this.connections)if(!this.connections[t].isSynced){e=t;break}var r=this;null!=e?(this.currentSyncTarget=e,this.y.db.requestTransaction(function*(){var t={type:"sync step 1",stateSet:yield*this.getStateSet(),deleteSet:yield*this.getDeleteSet(),protocolVersion:r.protocolVersion,auth:r.authInfo};r.send(e,t)})):r.isSynced||this.y.db.requestTransaction(function*(){if(!r.isSynced){for(var e of(r.isSynced=!0,yield*this.garbageCollectAfterSync(),r.whenSyncedListeners))e();r.whenSyncedListeners=[]}})}}send(e,t){this.log("Send '%s' to %s",t.type,e),this.logMessage("Message: %j",t)}broadcast(e){this.log("Broadcast '%s'",e.type),this.logMessage("Message: %j",e)}broadcastOps(t){t=t.map(function(t){return e.Struct[t.struct].encode(t)});var r=this;function n(){r.broadcastOpBuffer.length>0&&(r.broadcast({type:"update",ops:r.broadcastOpBuffer}),r.broadcastOpBuffer=[])}0===this.broadcastOpBuffer.length?(this.broadcastOpBuffer=t,this.y.db.transactionInProgress?this.y.db.whenTransactionsFinished().then(n):setTimeout(n,0)):this.broadcastOpBuffer=this.broadcastOpBuffer.concat(t)}receiveMessage(e,t){if(e===this.userId)return Promise.resolve();if(this.log("Receive '%s' from %s",t.type,e),this.logMessage("Message: %j",t),null!=t.protocolVersion&&t.protocolVersion!==this.protocolVersion)return this.log(`You tried to sync with a yjs instance that has a different protocol version\n (You: ${this.protocolVersion}, Client: ${t.protocolVersion}).\n The sync was stopped. You need to upgrade your dependencies (especially Yjs & the Connector)!\n `),this.send(e,{type:"sync stop",protocolVersion:this.protocolVersion}),Promise.reject("Incompatible protocol version");if(null!=t.auth&&null!=this.connections[e]){var n=this.checkAuth(t.auth,this.y,e);this.connections[e].auth=n,n.then(t=>{for(var r of this.userEventListeners)r({action:"userAuthenticated",user:e,auth:t})})}else null!=this.connections[e]&&null==this.connections[e].auth&&(this.connections[e].auth=this.checkAuth(null,this.y,e));return null!=this.connections[e]&&null!=this.connections[e].auth?this.connections[e].auth.then(n=>{if("sync step 1"===t.type&&function(e){return"read"===e||"write"===e}(n)){let i=this,o=t;this.y.db.requestTransaction(function*(){var t=yield*this.getStateSet();r(n)&&(yield*this.applyDeleteSet(o.deleteSet));var s={type:"sync step 2",stateSet:t,deleteSet:yield*this.getDeleteSet(),protocolVersion:this.protocolVersion,auth:this.authInfo};s.os=yield*this.getOperations(o.stateSet),i.send(e,s),this.forwardToSyncingClients?(i.syncingClients.push(e),setTimeout(function(){i.syncingClients=i.syncingClients.filter(function(t){return t!==e}),i.send(e,{type:"sync done"})},5e3)):i.send(e,{type:"sync done"})})}else if("sync step 2"===t.type&&r(n)){var i=this.y.db,o={};o.promise=new Promise(function(e){o.resolve=e}),this.syncStep2=o.promise;let e=t;i.requestTransaction(function*(){yield*this.applyDeleteSet(e.deleteSet),null!=e.osUntransformed?yield*this.applyOperationsUntransformed(e.osUntransformed,e.stateSet):this.store.apply(e.os),o.resolve()})}else if("sync done"===t.type){var s=this;this.syncStep2.then(function(){s._setSyncedWith(e)})}else if("update"===t.type&&r(n)){if(this.forwardToSyncingClients)for(var a of this.syncingClients)this.send(a,t);if(this.y.db.forwardAppliedOperations){var u=t.ops.filter(function(e){return"Delete"===e.struct});u.length>0&&this.broadcastOps(u)}this.y.db.apply(t.ops)}}):Promise.reject("Unable to deliver message")}_setSyncedWith(e){var t=this.connections[e];null!=t&&(t.isSynced=!0),e===this.currentSyncTarget&&(this.currentSyncTarget=null,this.findNextSyncTarget())}parseMessageFromXml(e){function t(e){for(var n of e.children)return"true"===n.getAttribute("isArray")?t(n):r(n)}function r(e){var n={};for(var i in e.attrs){var o=e.attrs[i],s=parseInt(o,10);isNaN(s)||""+s!==o?n[i]=o:n[i]=s}for(var a in e.children){var u=a.name;"true"===a.getAttribute("isArray")?n[u]=t(a):n[u]=r(a)}return n}r(e)}encodeMessageToXml(e,t){function r(e,t){for(var i in t){var o=t[i];null==i||(o.constructor===Object?r(e.c(i),o):o.constructor===Array?n(e.c(i),o):e.setAttribute(i,o))}}function n(e,t){for(var i of(e.setAttribute("isArray","true"),t))i.constructor===Object?r(e.c("array-element"),i):n(e.c("array-element"),i)}if(t.constructor===Object)r(e.c("y",{xmlns:"http://y.ninja/connector-stanza"}),t);else{if(t.constructor!==Array)throw new Error("I can't encode this json!");n(e.c("y",{xmlns:"http://y.ninja/connector-stanza"}),t)}}}}},function(e,t,r){"use strict";e.exports=function(e){e.AbstractDatabase=class{constructor(e,t){this.y=e,this.dbOpts=t;var r,n=this;this.userId=null,this.userIdPromise=new Promise(function(e){r=e}),this.userIdPromise.resolve=r,this.forwardAppliedOperations=!1,this.listenersById={},this.listenersByIdExecuteNow=[],this.listenersByIdRequestPending=!1,this.initializedTypes={},this.waitingTransactions=[],this.transactionInProgress=!1,this.transactionIsFlushed=!1,"undefined"!=typeof YConcurrency_TestingMode&&(this.executeOrder=[]),this.gc1=[],this.gc2=[],this.garbageCollect=function e(){return n.whenTransactionsFinished().then(function(){return n.gc1.length>0||n.gc2.length>0?(n.y.connector.isSynced||console.warn("gc should be empty when not synced!"),new Promise(t=>{n.requestTransaction(function*(){if(null!=n.y.connector&&n.y.connector.isSynced){for(var r=0;r0&&(n.gcInterval=setTimeout(e,n.gcTimeout)),t()})})):(n.gcTimeout>0&&(n.gcInterval=setTimeout(e,n.gcTimeout)),Promise.resolve())})},this.startGarbageCollector(),this.repairCheckInterval=t.repairCheckInterval?t.repairCheckInterval:6e3,this.opsReceivedTimestamp=new Date,this.startRepairCheck()}startGarbageCollector(){this.gc=null==this.dbOpts.gc||this.dbOpts.gc,this.gc?this.gcTimeout=this.dbOpts.gcTimeout?this.dbOpts.gcTimeout:5e4:this.gcTimeout=-1,this.gcTimeout>0&&this.garbageCollect()}startRepairCheck(){var e=this;this.repairCheckInterval>0&&(this.repairCheckIntervalHandler=setInterval(function(){new Date-e.opsReceivedTimestamp>e.repairCheckInterval&&Object.keys(e.listenersById).length>0&&(e.listenersById={},e.opsReceivedTimestamp=new Date,e.y.connector.repair())},this.repairCheckInterval))}stopRepairCheck(){clearInterval(this.repairCheckIntervalHandler)}queueGarbageCollector(e){this.y.connector.isSynced&&this.gc&&this.gc1.push(e)}emptyGarbageCollector(){return new Promise(e=>{var t=()=>{this.gc1.length>0||this.gc2.length>0?this.garbageCollect().then(t):e()};setTimeout(t,0)})}addToDebug(){if("undefined"!=typeof YConcurrency_TestingMode){var e=Array.prototype.map.call(arguments,function(e){return"string"==typeof e?e:JSON.stringify(e)}).join("").replace(/"/g,"'").replace(/,/g,", ").replace(/:/g,": ");this.executeOrder.push(e)}}getDebugData(){console.log(this.executeOrder.join("\n"))}stopGarbageCollector(){var e=this;return this.gc=!1,this.gcTimeout=-1,new Promise(function(t){e.requestTransaction(function*(){var r=e.gc1.concat(e.gc2);e.gc1=[],e.gc2=[];for(var n=0;n1&&(e=yield*this.getInsertionCleanStart([e.id[0],e.id[1]+1]),r=!0),r)return e.gc=!0,yield*this.setOperation(e),this.store.queueGarbageCollector(e.id),!0}return!1}removeFromGarbageCollector(t){function r(r){return!e.utils.compareIds(r,t.id)}this.gc1=this.gc1.filter(r),this.gc2=this.gc2.filter(r),delete t.gc}destroyTypes(){for(var e in this.initializedTypes){var t=this.initializedTypes[e];null!=t._destroy?t._destroy():console.error("The type you included does not provide destroy functionality, it will remain in memory (updating your packages will help).")}}*destroy(){clearInterval(this.gcInterval),this.gcInterval=null,this.stopRepairCheck()}setUserId(e){if(!this.userIdPromise.inProgress){this.userIdPromise.inProgress=!0;var t=this;t.requestTransaction(function*(){t.userId=e;var r=yield*this.getState(e);t.opClock=r.clock,t.userIdPromise.resolve(e)})}return this.userIdPromise}whenUserIdSet(e){this.userIdPromise.then(e)}getNextOpId(e){if(null==e)throw new Error("getNextOpId expects the number of created ids to create!");if(null==this.userId)throw new Error("OperationStore not yet initialized!");var t=[this.userId,this.opClock];return this.opClock+=e,t}apply(t){this.opsReceivedTimestamp=new Date;for(var r=0;r0){let r={op:t,missing:e.length};for(let t=0;t{this.transact(this.getNextRequest())},0))}getType(e){return this.initializedTypes[JSON.stringify(e)]}*initType(t,r){var n=JSON.stringify(t),i=this.store.initializedTypes[n];if(null==i){var o=yield*this.getOperation(t);null!=o&&(i=yield*e[o.type].typeDefinition.initType.call(this,this.store,o,r),this.store.initializedTypes[n]=i)}return i}createType(t,r){var n=t[0].struct;r=r||this.getNextOpId(1);var i=e.Struct[n].create(r);i.type=t[0].name,this.requestTransaction(function*(){"_"===i.id[0]?yield*this.setOperation(i):yield*this.applyCreatedOperations([i])});var o=e[i.type].typeDefinition.createType(this,i,t[1]);return this.initializedTypes[JSON.stringify(i.id)]=o,o}}}},function(e,t,r){"use strict";e.exports=function(e){e.Transaction=class{*applyCreatedOperations(t){for(var r=[],n=0;n0&&this.store.y.connector.broadcastOps(r)}*deleteList(e){for(;null!=e;){if(!(e=yield*this.getOperation(e)).gc){e.gc=!0,e.deleted=!0,yield*this.setOperation(e);var t=null!=e.content?e.content.length:1;yield*this.markDeleted(e.id,t),null!=e.opContent&&(yield*this.deleteOperation(e.opContent)),this.store.queueGarbageCollector(e.id)}e=e.right}}*deleteOperation(e,t,r){for(null==t&&(t=1),yield*this.markDeleted(e,t);t>0;){var n=!1,i=yield*this.os.findWithUpperBound([e[0],e[1]+t-1]),o=null!=i&&null!=i.content?i.content.length:1;if(null==i||i.id[0]!==e[0]||i.id[1]+o<=e[1]?(i=null,t=0):(i.deleted||(i.id[1]e[1]+t&&(o=(i=yield*this.getInsertionCleanEnd([e[0],e[1]+t-1])).content.length)),t=i.id[1]-e[1]),null!=i){if(!i.deleted){if(n=!0,i.deleted=!0,null!=i.start&&(yield*this.deleteList(i.start)),null!=i.map)for(var s in i.map)yield*this.deleteList(i.map[s]);if(null!=i.opContent&&(yield*this.deleteOperation(i.opContent)),null!=i.requires)for(var a=0;a0))return r;if(r.gc){if(!((n=r.id[1]+r.len-e[1])=i.id[1])for(n=r.id[1]+r.len-i.id[1];n>=0;){if(i.gc){r.len-=n,n>=i.len&&(n-=i.len)>0&&(yield*this.ds.put(r),yield*this.markDeleted([i.id[0],i.id[1]+i.len],n));break}if(!(n>i.len)){r.len+=i.len-n,yield*this.ds.delete(i.id);break}var o=yield*this.ds.findNext(i.id);if(yield*this.ds.delete(i.id),null==o||r.id[0]!==o.id[0])break;i=o,n=r.id[1]+r.len-i.id[1]}return yield*this.ds.put(r),r}*garbageCollectAfterSync(){(this.store.gc1.length>0||this.store.gc2.length>0)&&console.warn("gc should be empty after sync"),this.store.gc&&(yield*this.os.iterate(this,null,null,function*(e){if(e.gc&&(delete e.gc,yield*this.setOperation(e)),null!=e.parent&&(yield*this.isDeleted(e.parent))){if(e.gc=!0,!e.deleted&&(yield*this.markDeleted(e.id,null!=e.content?e.content.length:1),e.deleted=!0,null!=e.opContent&&(yield*this.deleteOperation(e.opContent)),null!=e.requires))for(var t=0;t0){for(var c=r.left,f=null;null!=c&&!(f=yield*this.getInsertion(c)).deleted;)c=f.left;for(var l in r.originOf){var h=yield*this.getOperation(r.originOf[l]);null!=h&&(h.origin=c,yield*this.setOperation(h))}null!=c&&(null==f.originOf?f.originOf=r.originOf:f.originOf=r.originOf.concat(f.originOf),yield*this.setOperation(f))}}if(null!=r.origin){var p=yield*this.getInsertion(r.origin);p.originOf=p.originOf.filter(function(r){return!e.utils.compareIds(t,r)}),yield*this.setOperation(p)}if(null!=r.parent&&(n=yield*this.getOperation(r.parent)),null!=n){var d=!1;null!=r.parentSub?e.utils.compareIds(n.map[r.parentSub],r.id)&&(d=!0,null!=r.right?n.map[r.parentSub]=r.right:delete n.map[r.parentSub]):(e.utils.compareIds(n.start,r.id)&&(d=!0,n.start=r.right),e.utils.matchesId(r,n.end)&&(d=!0,n.end=r.left)),d&&(yield*this.setOperation(n))}yield*this.removeOperation(r.id)}}*checkDeleteStoreForState(e){var t=yield*this.ds.findWithUpperBound([e.user,e.clock]);null!=t&&t.id[0]===e.user&&t.gc&&(e.clock=Math.max(e.clock,t.id[1]+t.len))}*updateState(e){var t=yield*this.getState(e);yield*this.checkDeleteStoreForState(t);for(var r=yield*this.getInsertion([e,t.clock]),n=null!=r&&null!=r.content?r.content.length:1;null!=r&&e===r.id[0]&&r.id[1]<=t.clock&&r.id[1]+n>t.clock;)t.clock+=n,yield*this.checkDeleteStoreForState(t),n=null!=(r=yield*this.os.findNext(r.id))&&null!=r.content?r.content.length:1;yield*this.setState(t)}*applyDeleteSet(e){var t=[];for(var r in e){var n=e[r],i=0,o=n[i];for(yield*this.ds.iterate(this,[r,0],[r,Number.MAX_VALUE],function*(e){for(;null!=o;){var s=0;if(e.id[1]+e.len<=o[0])break;o[0]=a[1];){var c=yield*this.os.findWithUpperBound([a[0],u-1]);if(null==c)break;var f=null!=c.content?c.content.length:1;if(c.id[0]!==a[0]||c.id[1]+f<=a[1])break;c.id[1]+f>a[1]+a[2]&&(c=yield*this.getInsertionCleanEnd([a[0],a[1]+a[2]-1])),c.id[1]1){var i=n[0],o=e.Struct[i].create(t);return o.type=n[1],yield*this.setOperation(o),o}return console.error("Unexpected case. How can this happen?"),null}*removeOperation(e){yield*this.os.delete(e)}*setState(e){var t={id:[e.user],clock:e.clock};yield*this.ss.put(t)}*getState(e){var t=yield*this.ss.find([e]),r=null==t?null:t.clock;return null==r&&(r=0),{user:e,clock:r}}*getStateVector(){var e=[];return yield*this.ss.iterate(this,null,null,function*(t){e.push({user:t.id[0],clock:t.clock})}),e}*getStateSet(){var e={};return yield*this.ss.iterate(this,null,null,function*(t){e[t.id[0]]=t.clock}),e}*getOperations(t){null==t&&(t={});var r=[],n=yield*this.getStateVector();for(var i of n){var o=i.user;if("_"!==o){var s=t[o]||0;if(s>0){var a=yield*this.getInsertion([o,s]);null!=a&&(s=a.id[1],t[o]=s)}yield*this.os.iterate(this,[o,s],[o,Number.MAX_VALUE],function*(n){if("Insert"!==(n=e.Struct[n.struct].encode(n)).struct)r.push(n);else if(null==n.right||n.right[1]<(t[n.right[0]]||0))for(var i=n,o=[n],s=n.right;;){if(null==i.left){n.left=null,r.push(n),e.utils.compareIds(i.id,n.id)||((i=e.Struct[n.struct].encode(i)).right=o[o.length-1].id,r.push(i));break}for(i=yield*this.getInsertion(i.left);o.length>0&&e.utils.matchesId(i,o[o.length-1].origin);)o.pop();if(i.id[1]<(t[i.id[0]]||0)){n.left=e.utils.getLastId(i),r.push(n);break}if(e.utils.matchesId(i,n.origin))n.left=n.origin,r.push(n),(n=e.Struct[n.struct].encode(i)).right=s,o.length>0&&console.log("This should not happen .. :( please report this"),o=[n];else{var a=e.Struct[n.struct].encode(i);a.right=o[o.length-1].id,a.left=a.origin,r.push(a),o.push(i)}}})}}return r.reverse()}*getOperationsUntransformed(){var e=[];return yield*this.os.iterate(this,null,null,function*(t){"_"!==t.id[0]&&e.push(t)}),{untransformed:e}}*applyOperationsUntransformed(t,r){for(var n=t.untransformed,i=0;i1&&(l=yield*this.getInsertionCleanEnd(l.id)),this.store.removeFromGarbageCollector(l)),yield*this.setOperation(l)),null!=r.parentSub?(null==f&&(a.map[r.parentSub]=r.id,yield*this.setOperation(a)),null!=r.right&&(yield*this.deleteOperation(r.right,1,!0)),null!=r.left&&(yield*this.deleteOperation(r.id,1,!0))):null!=l&&null!=f||(null==l&&(a.end=e.utils.getLastId(r)),null==f&&(a.start=r.id),yield*this.setOperation(a)),n=0;n=0&&null!=n.right;)n=yield*this.getOperation(n.right);return r},map:function*(e,t){e=e.start;for(var r=[];null!=e;){var n=yield*this.getOperation(e);n.deleted||r.push(t(n)),e=n.right}return r}},Map:{create:function(e){return{id:e,map:{},struct:"Map"}},encode:function(e){var t={struct:"Map",type:e.type,id:e.id,map:{}};return null!=e.requires&&(t.requires=e.requires),null!=e.info&&(t.info=e.info),t},requiredOps:function(){return[]},execute:function*(){},get:function*(e,t){var r=e.map[t];if(null!=r){var n=yield*this.getOperation(r);return null==n||n.deleted?void 0:null==n.opContent?n.content[0]:yield*this.getType(n.opContent)}}}};e.Struct=t}},function(e,t,r){"use strict";e.exports=function(e){e.utils={},e.utils.bubbleEvent=function(e,t){for(e.eventHandler.callEventListeners(t),t.path=[];null!=e&&null!=e._deepEventHandler;){e._deepEventHandler.callEventListeners(t);var r=null;null!=e._parent&&(r=e.os.getType(e._parent)),null!=r&&null!=r._getPathToChild?(t.path=[r._getPathToChild(e._model)].concat(t.path),e=r):e=null}};class t{constructor(){this.eventListeners=[]}destroy(){this.eventListeners=null}addEventListener(e){this.eventListeners.push(e)}removeEventListener(e){this.eventListeners=this.eventListeners.filter(function(t){return e!==t})}removeAllEventListeners(){this.eventListeners=[]}callEventListeners(e){for(var t=0;t0&&this.awaiting--,0===this.awaiting&&this.waiting.length>0){for(let r=0;r0;)for(var n=0;n=0;o--){let t=this.waiting[o];"Insert"===t.struct&&(e.utils.matchesId(t,i.left)?(t.right=i.id,i.left=t.left):e.utils.compareIds(t.id,i.right)&&(t.left=e.utils.getLastId(i),i.right=t.right))}}this._tryCallEvents(t)}awaitedDeletes(t,r){for(var n=this.waiting.splice(this.waiting.length-t),i=0;i0&&this.awaiting--,0===this.awaiting&&this.waiting.length>0){var t=[],r=[];this.waiting.forEach(function(e){"Delete"===e.struct?r.push(e):t.push(e)}),(t=function(t){for(var r=[];t.length>0;)for(var n=0;n=e.id[1]&&t[1]=0;r--)if((n=this.readBuffer[r]).id[1]===e[1]&&n.id[0]===e[0]){for(;r=0;r--)if((n=this.writeBuffer[r]).id[1]===e[1]&&n.id[0]===e[0]){i=n;break}if(r<0&&void 0===t&&(i=yield*super.find(e)),null!=i){for(r=0;r=0;t--)if((r=this.writeBuffer[t]).id[1]===n[1]&&r.id[0]===n[0]){for(;t>t/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e)}}},function(e,t,r){"use strict";e.exports=function(e){var t={users:{},buffers:{},removeUser:function(e){for(var t in this.users)this.users[t].userLeft(e);delete this.users[e],delete this.buffers[e]},addUser:function(e){for(var t in this.users[e.userId]=e,this.buffers[e.userId]={},this.users)if(t!==e.userId){var r=this.users[t];r.userJoined(e.userId,"master"),e.userJoined(r.userId,"master")}},whenTransactionsFinished:function(){var e=this;return new Promise(function(t,r){setTimeout(function(){var n=[];for(var i in e.users)n.push(e.users[i].y.db.whenTransactionsFinished());Promise.all(n).then(t,r)},10)})},flushOne:function(){var e=[];for(var r in t.buffers){let i=t.buffers[r];var n=!1;for(let e in i)if(i[e].length>0){n=!0;break}n&&e.push(r)}if(e.length>0){var i=getRandom(e);let r=t.buffers[i],n=getRandom(Object.keys(r));var o=r[n].shift();0===r[n].length&&delete r[n];var s=t.users[i];return s.receiveMessage(o[0],o[1]).then(function(){return s.y.db.whenTransactionsFinished()},function(){})}return!1},flushAll:function(){return new Promise(function(e){t.whenTransactionsFinished().then(function r(){var n=t.flushOne();if(n){for(;n;)n=t.flushOne();t.whenTransactionsFinished().then(r)}else(n=t.flushOne())?n.then(function(){t.whenTransactionsFinished().then(r)}):e()})})}};e.utils.globalRoom=t;var r=0;e.Test=class extends e.AbstractConnector{constructor(e,n){if(void 0===n)throw new Error("Options must not be undefined!");n.role="master",n.forwardToSyncingClients=!1,super(e,n),this.setUserId(r+++"").then(()=>{t.addUser(this)}),this.globalRoom=t,this.syncingClientDuration=0}receiveMessage(e,t){return super.receiveMessage(e,JSON.parse(JSON.stringify(t)))}send(e,r){var n=t.buffers[e];null!=n&&(null==n[this.userId]&&(n[this.userId]=[]),n[this.userId].push(JSON.parse(JSON.stringify([this.userId,r]))))}broadcast(e){for(var r in t.buffers){var n=t.buffers[r];null==n[this.userId]&&(n[this.userId]=[]),n[this.userId].push(JSON.parse(JSON.stringify([this.userId,e])))}}isDisconnected(){return null==t.users[this.userId]}reconnect(){return this.isDisconnected()&&(t.addUser(this),super.reconnect()),e.utils.globalRoom.flushAll()}disconnect(){var e=Promise.resolve();this.isDisconnected()||(t.removeUser(this.userId),e=super.disconnect());var r=this;return e.then(function(){return r.y.db.whenTransactionsFinished()})}flush(){var e=this;return async(function*(){for(var r=t.buffers[e.userId];Object.keys(r).length>0;){var n=getRandom(Object.keys(r)),i=r[n].shift();0===r[n].length&&delete r[n],yield this.receiveMessage(i[0],i[1])}yield e.whenTransactionsFinished()})}}}},function(e,t,r){(function(n){function i(){var e;try{e=t.storage.debug}catch(e){}return!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG),e}(t=e.exports=r(1490)).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var r=this.useColors;if(e[0]=(r?"%c":"")+this.namespace+(r?" %c":" ")+e[0]+(r?"%c ":" ")+"+"+t.humanize(this.diff),r){var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var i=0,o=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&"%c"===e&&(o=++i)}),e.splice(o,0,n)}},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=i,t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(i())}).call(this,r(7))},function(e,t,r){var n;function i(e){function r(){if(r.enabled){var e=r,i=+new Date,o=i-(n||i);e.diff=o,e.prev=n,e.curr=i,n=i;for(var s=new Array(arguments.length),a=0;a0||this.store.gc2.length>0)&&console.warn("GC1|2 not empty!",this.store.gc1,this.store.gc2),"{}"!==JSON.stringify(this.store.listenersById)&&console.warn("listenersById not empty!"),"[]"!==JSON.stringify(this.store.listenersByIdExecuteNow)&&console.warn("listenersByIdExecuteNow not empty!"),this.store.transactionInProgress&&console.warn("Transaction still in progress!")},!0)}transact(e){for(var r=new t(this);null!==e;){for(var n=e.call(r),i=n.next();!i.done;)i=n.next(i.value);e=this.getNextRequest()}}*destroy(){yield*super.destroy(),delete this.os,delete this.ss,delete this.ds}})}e.exports=n,"undefined"!=typeof Y&&n(Y)},function(e,t,r){"use strict";e.exports=function(e){class t{constructor(e){if(this.val=e,this.color=!0,this._left=null,this._right=null,this._parent=null,null===e.id)throw new Error("You must define id!")}isRed(){return this.color}isBlack(){return!this.color}redden(){return this.color=!0,this}blacken(){return this.color=!1,this}get grandparent(){return this.parent.parent}get parent(){return this._parent}get sibling(){return this===this.parent.left?this.parent.right:this.parent.left}get left(){return this._left}get right(){return this._right}set left(e){null!==e&&(e._parent=this),this._left=e}set right(e){null!==e&&(e._parent=this),this._right=e}rotateLeft(e){var t=this.parent,r=this.right,n=this.right.left;if(r.left=this,this.right=n,null===t)e.root=r,r._parent=null;else if(t.left===this)t.left=r;else{if(t.right!==this)throw new Error("The elements are wrongly connected!");t.right=r}}next(){if(null!==this.right){for(var e=this.right;null!==e.left;)e=e.left;return e}for(var t=this;null!==t.parent&&t!==t.parent.left;)t=t.parent;return t.parent}prev(){if(null!==this.left){for(var e=this.left;null!==e.right;)e=e.right;return e}for(var t=this;null!==t.parent&&t!==t.parent.right;)t=t.parent;return t.parent}rotateRight(e){var t=this.parent,r=this.left,n=this.left.right;if(r.right=this,this.left=n,null===t)e.root=r,r._parent=null;else if(t.left===this)t.left=r;else{if(t.right!==this)throw new Error("The elements are wrongly connected!");t.right=r}}getUncle(){return this.parent===this.parent.parent.left?this.parent.parent.right:this.parent.parent.left}}e.utils.RBTree=class{constructor(){this.root=null,this.length=0}*findNext(e){return yield*this.findWithLowerBound([e[0],e[1]+1])}*findPrev(e){return yield*this.findWithUpperBound([e[0],e[1]-1])}findNodeWithLowerBound(t){if(void 0===t)throw new Error("You must define from!");var r=this.root;if(null===r)return null;for(;;)if(null!==t&&!e.utils.smaller(t,r.val.id)||null===r.left){if(null===t||!e.utils.smaller(r.val.id,t))return r;if(null===r.right)return r.next();r=r.right}else r=r.left}findNodeWithUpperBound(t){if(void 0===t)throw new Error("You must define from!");var r=this.root;if(null===r)return null;for(;;)if(null!==t&&!e.utils.smaller(r.val.id,t)||null===r.right){if(null===t||!e.utils.smaller(t,r.val.id))return r;if(null===r.left)return r.prev();r=r.left}else r=r.right}findSmallestNode(){for(var e=this.root;null!=e&&null!=e.left;)e=e.left;return e}*findWithLowerBound(e){var t=this.findNodeWithLowerBound(e);return null==t?null:t.val}*findWithUpperBound(e){var t=this.findNodeWithUpperBound(e);return null==t?null:t.val}*iterate(t,r,n,i){var o;for(o=null===r?this.findSmallestNode():this.findNodeWithLowerBound(r);null!==o&&(null===n||e.utils.smaller(o.val.id,n)||e.utils.compareIds(o.val.id,n));)yield*i.call(t,o.val),o=o.next();return!0}*logTable(e,t,r){null==r&&(r=function(){return!0}),null==e&&(e=null),null==t&&(t=null);var n=[];yield*this.iterate(this,e,t,function*(e){if(r(e)){var t={};for(var i in e)"object"==typeof e[i]?t[i]=JSON.stringify(e[i]):t[i]=e[i];n.push(t)}}),null!=console.table&&console.table(n)}*find(e){var t;return(t=this.findNode(e))?t.val:null}findNode(t){if(null==t||t.constructor!==Array)throw new Error("Expect id to be an array!");var r=this.root;if(null===r)return!1;for(;;){if(null===r)return!1;if(e.utils.smaller(t,r.val.id))r=r.left;else{if(!e.utils.smaller(r.val.id,t))return r;r=r.right}}}*delete(e){if(null==e||e.constructor!==Array)throw new Error("id is expected to be an Array!");var r=this.findNode(e);if(null!=r){if(this.length--,null!==r.left&&null!==r.right){for(var n=r.left;null!==n.right;)n=n.right;r.val=n.val,r=n}var i,o=r.left||r.right;if(null===o?(i=!0,(o=new t({id:0})).blacken(),r.right=o):i=!1,null!==r.parent){if(r.parent.left===r)r.parent.left=o;else{if(r.parent.right!==r)throw new Error("Impossible!");r.parent.right=o}if(r.isBlack()&&(o.isRed()?o.blacken():this._fixDelete(o)),this.root.blacken(),i)if(o.parent.left===o)o.parent.left=null;else{if(o.parent.right!==o)throw new Error("Impossible #3");o.parent.right=null}}else i?this.root=null:(this.root=o,o.blacken(),o._parent=null)}}_fixDelete(e){function t(e){return null===e||e.isBlack()}function r(e){return null!==e&&e.isRed()}if(null!==e.parent){var n=e.sibling;if(r(n)){if(e.parent.redden(),n.blacken(),e===e.parent.left)e.parent.rotateLeft(this);else{if(e!==e.parent.right)throw new Error("Impossible #2");e.parent.rotateRight(this)}n=e.sibling}e.parent.isBlack()&&n.isBlack()&&t(n.left)&&t(n.right)?(n.redden(),this._fixDelete(e.parent)):e.parent.isRed()&&n.isBlack()&&t(n.left)&&t(n.right)?(n.redden(),e.parent.blacken()):(e===e.parent.left&&n.isBlack()&&r(n.left)&&t(n.right)?(n.redden(),n.left.blacken(),n.rotateRight(this),n=e.sibling):e===e.parent.right&&n.isBlack()&&r(n.right)&&t(n.left)&&(n.redden(),n.right.blacken(),n.rotateLeft(this),n=e.sibling),n.color=e.parent.color,e.parent.blacken(),e===e.parent.left?(n.right.blacken(),e.parent.rotateLeft(this)):(n.left.blacken(),e.parent.rotateRight(this)))}}*put(r){if(null==r||null==r.id||r.id.constructor!==Array)throw new Error("v is expected to have an id property which is an Array!");var n=new t(r);if(null!==this.root){for(var i=this.root;;)if(e.utils.smaller(n.val.id,i.val.id)){if(null===i.left){i.left=n;break}i=i.left}else{if(!e.utils.smaller(i.val.id,n.val.id))return i.val=n.val,i;if(null===i.right){i.right=n;break}i=i.right}this._fixInsert(n)}else this.root=n;return this.length++,this.root.blacken(),n}_fixInsert(e){if(null!==e.parent){if(!e.parent.isBlack()){var t=e.getUncle();null!==t&&t.isRed()?(e.parent.blacken(),t.blacken(),e.grandparent.redden(),this._fixInsert(e.grandparent)):(e===e.parent.right&&e.parent===e.grandparent.left?(e.parent.rotateLeft(this),e=e.left):e===e.parent.left&&e.parent===e.grandparent.right&&(e.parent.rotateRight(this),e=e.right),e.parent.blacken(),e.grandparent.redden(),e===e.parent.left?e.grandparent.rotateRight(this):e.grandparent.rotateLeft(this))}}else e.blacken()}*flush(){}}}},function(e,t,r){"use strict";function n(e){class t extends e.utils.CustomType{constructor(t,r,n){super(),this.os=t,this._model=r,this._content=n,this._parent=null,this._deepEventHandler=new e.utils.EventListenerHandler,this.eventHandler=new e.utils.EventHandler(t=>{if("Insert"===t.struct){if(this._content.some(function(r){return e.utils.compareIds(r.id,t.id)}))return;let o;if(null===t.left)o=0;else if((o=1+this._content.findIndex(function(r){return e.utils.compareIds(r.id,t.left)}))<=0)throw new Error("Unexpected operation!");var r,n;if(t.hasOwnProperty("opContent")){this._content.splice(o,0,{id:t.id,type:t.opContent}),n=1;let e=this.os.getType(t.opContent);e._parent=this._model,r=[e]}else{var i=t.content.map(function(e,r){return{id:[t.id[0],t.id[1]+r],val:e}});i.length<3e4?this._content.splice.apply(this._content,[o,0].concat(i)):this._content=this._content.slice(0,o).concat(i).concat(this._content.slice(o)),r=t.content,n=t.content.length}e.utils.bubbleEvent(this,{type:"insert",object:this,index:o,values:r,length:n})}else{if("Delete"!==t.struct)throw new Error("Unexpected struct!");for(var o=0;o0;o++){var s=this._content[o];if(e.utils.inDeletionRange(t,s.id)){var a;for(a=1;anull!=e.val?e.val:this.os.getType(e.type));e.utils.bubbleEvent(this,{type:"delete",object:this,index:o,values:n,_content:r,length:a})}}}})}_getPathToChild(t){return this._content.findIndex(r=>null!=r.type&&e.utils.compareIds(r.type,t))}_destroy(){this.eventHandler.destroy(),this.eventHandler=null,this._content=null,this._model=null,this._parent=null,this.os=null}get length(){return this._content.length}get(e){if(null==e||"number"!=typeof e)throw new Error("pos must be a number!");if(!(e>=this._content.length))return null==this._content[e].type?this._content[e].val:this.os.getType(this._content[e].type)}toArray(){return this._content.map((e,t)=>null!=e.type?this.os.getType(e.type):e.val)}push(e){return this.insert(this._content.length,e)}insert(t,r){if("number"!=typeof t)throw new Error("pos must be a number!");if(!Array.isArray(r))throw new Error("contents must be an Array of objects!");if(0!==r.length){if(t>this._content.length||t<0)throw new Error("This position exceeds the range of the array!");for(var n=0===t?null:this._content[t-1].id,i=[],o=n,s=0;s0){s--;break}break}c.push(f)}if(c.length>0)u.content=c,u.id=this.os.getNextOpId(c.length);else{var l=this.os.getNextOpId(1);this.os.createType(a,l),u.opContent=l,u.id=this.os.getNextOpId(1)}i.push(u),o=u.id}var h=this.eventHandler;this.os.requestTransaction(function*(){var e;e=null!=n?(yield*this.getInsertionCleanEnd(n)).right:(yield*this.getOperation(i[0].parent)).start;for(var t=0;tthis._content.length||t<0||r<0)throw new Error("The deletion range exceeds the range of the array!");if(0!==r){for(var n=this.eventHandler,i=[],o=0;othis._content.length||e<0||t<0)throw new Error("The deletion range exceeds the range of the array!");if(0!==t)if(this._content.length>e+t&&""===this._content[e+t].val&&2===this._content[e+t-1].val.length){let r=this._content[e+t-1].val[0];super.delete(e,t+1),super.insert(e,[r])}else if(e>0&&""===this._content[e].val&&2===this._content[e-1].val.length){let r=this._content[e-1].val[1];super.delete(e-1,t+1),super.insert(e-1,[r])}else super.delete(e,t)}unbindAll(){this.unbindTextareaAll(),this.unbindAceAll(),this.unbindCodeMirrorAll(),this.unbindMonacoAll()}unbindMonaco(e){var t=this.monacoInstances.findIndex(function(t){return t.editor===e});if(t>=0){var r=this.monacoInstances[t];this.unobserve(r.yCallback),r.disposeBinding(),this.monacoInstances.splice(t,1)}}unbindMonacoAll(){for(let e=this.monacoInstances.length-1;e>=0;e--)this.unbindMonaco(this.monacoInstances[e].editor)}bindMonaco(e,t){var r=this;t=t||{};var n=!0;function o(e){if(n){n=!1;try{e()}catch(e){throw n=!0,new Error(e)}n=!0}}function s(e){o(function(){for(var t=0,n=1;n0&&r.delete(i,e.rangeLength),r.insert(i,e.text)})}e.setValue(this.toString());var a=e.onDidChangeModelContent(s).dispose;function u(t){o(function(){let r=e.model.getPositionAt(t.index);var n,o;"insert"===t.type?(n=r,o=t.values.join("")):"delete"===t.type&&(n=e.model.modifyPosition(r,t.length),o="");var s={startLineNumber:r.lineNumber,startColumn:r.column,endLineNumber:n.lineNumber,endColumn:n.column},a={major:i.major,minor:i.minor++};e.executeEdits("Yjs",[{id:a,range:s,text:o,forceMoveMarkers:!0}])})}this.observe(u),this.monacoInstances.push({editor:e,yCallback:u,monacoCallback:s,disposeBinding:a})}unbindCodeMirror(e){var t=this.codeMirrorInstances.findIndex(function(t){return t.editor===e});if(t>=0){var r=this.codeMirrorInstances[t];this.unobserve(r.yCallback),r.editor.off("changes",r.codeMirrorCallback),this.codeMirrorInstances.splice(t,1)}}unbindCodeMirrorAll(){for(let e=this.codeMirrorInstances.length-1;e>=0;e--)this.unbindCodeMirror(this.codeMirrorInstances[e].editor)}bindCodeMirror(e,t){var r=this;t=t||{};var n=!0;function i(e){if(n){n=!1;try{e()}catch(e){throw n=!0,new Error(e)}n=!0}}function o(t,n){i(function(){for(var t=0;t0){for(var s=0,a=0;a=0){var r=this.aceInstances[t];this.unobserve(r.yCallback),r.editor.off("change",r.aceCallback),this.aceInstances.splice(t,1)}}unbindAceAll(){for(let e=this.aceInstances.length-1;e>=0;e--)this.unbindAce(this.aceInstances[e].editor)}bindAce(e,t){var r=this;t=t||{};var n,i=!0;function o(e){if(i){i=!1;try{e()}catch(e){throw i=!0,new Error(e)}i=!0}}function s(t){o(function(){var n,i,o=e.getSession().getDocument();"insert"===t.action?(n=o.positionToIndex(t.start,0),r.insert(n,t.lines.join("\n"))):"remove"===t.action&&(n=o.positionToIndex(t.start,0),i=t.lines.join("\n").length,r.delete(n,i))})}e.setValue(this.toString()),e.on("change",s),e.selection.clearSelection(),n="undefined"!=typeof ace&&null==t.aceClass?ace:t.aceClass;var a=(t.aceRequire||n.require)("ace/range").Range;function u(t){var r=e.getSession().getDocument();o(function(){if("insert"===t.type){let e=r.indexToPosition(t.index,0);r.insert(e,t.values.join(""))}else if("delete"===t.type){let n=r.indexToPosition(t.index,0),i=r.indexToPosition(t.index+t.length,0);var e=new a(n.row,n.column,i.row,i.column);r.remove(e)}})}this.observe(u),this.aceInstances.push({editor:e,yCallback:u,aceCallback:s})}bind(){var e=arguments[0];e instanceof Element?this.bindTextarea.apply(this,arguments):null!=e&&null!=e.session&&null!=e.getSession&&null!=e.setValue?this.bindAce.apply(this,arguments):null!=e&&null!=e.posFromIndex&&null!=e.replaceRange?this.bindCodeMirror.apply(this,arguments):null!=e&&null!=e.onDidChangeModelContent?this.bindMonaco.apply(this,arguments):console.error("Cannot bind, unsupported editor!")}unbindTextarea(e){var t=this.textfields.findIndex(function(t){return t.editor===e});if(t>=0){var r=this.textfields[t];this.unobserve(r.yCallback),r.editor.removeEventListener("input",r.eventListener),this.textfields.splice(t,1)}}unbindTextareaAll(){for(let e=this.textfields.length-1;e>=0;e--)this.unbindTextarea(this.textfields[e].editor)}bindTextarea(e,t){null==(t=t||window).getSelection&&(t=window);for(var r=0;r{var t;if("insert"===e.type){t=e.index;var r=s(function(e){return e<=t?e:e+=1});a(r)}else"delete"===e.type&&(t=e.index,r=s(function(e){return en.length&&(r.right=n.length),r.left=Math.min(r.left,r.right);var i=document.createRange();i.setStart(n,r.left),i.setEnd(n,r.right);var o=t.getSelection();o.removeAllRanges(),o.addRange(i)}},u=function(t){e.innerText=t},c=function(){return e.innerText}),u(this.toString()),this.observe(l);var h=function(){o(function(){for(var e=s(function(e){return e}),t=f.toString(),r=c(),i=n(t,r,e.left),o=0,a=0;a0&&n.splice(o+2,0,[a[0],u]),g(n,o,3)}return e}(u,r)),y(u)}function s(e,t){var s;if(!e)return[[n,t]];if(!t)return[[r,e]];var u=e.length>t.length?e:t,c=e.length>t.length?t:e,f=u.indexOf(c);if(-1!=f)return s=[[n,u.substring(0,f)],[i,c],[n,u.substring(f+c.length)]],e.length>t.length&&(s[0][0]=s[2][0]=r),s;if(1==c.length)return[[r,e],[n,t]];var h=l(e,t);if(h){var p=h[0],d=h[1],y=h[2],g=h[3],m=h[4],b=o(p,y),v=o(d,g);return b.concat([[i,m]],v)}return a(e,t)}function a(e,t){for(var i=e.length,o=t.length,s=Math.ceil((i+o)/2),a=s,c=2*s,f=new Array(c),l=new Array(c),h=0;hi)g+=2;else if(S>o)y+=2;else if(d){if((A=a+p-_)>=0&&A=(E=i-l[A]))return u(e,t,I,S)}}for(var k=-v+m;k<=v-b;k+=2){for(var E,A=a+k,x=(E=k==-v||k!=v&&l[A-1]i)b+=2;else if(x>o)m+=2;else if(!d){if((w=a+p-k)>=0&&w=(E=i-E))return u(e,t,I,S)}}}}return[[r,e],[n,t]]}function u(e,t,r,n){var i=e.substring(0,r),s=t.substring(0,n),a=e.substring(r),u=t.substring(n),c=o(i,s),f=o(a,u);return c.concat(f)}function c(e,t){if(!e||!t||e.charAt(0)!=t.charAt(0))return 0;for(var r=0,n=Math.min(e.length,t.length),i=n,o=0;rt.length?e:t,n=e.length>t.length?t:e;if(r.length<4||2*n.length=e.length?[n,i,o,s,l]:null}var o,s,a,u,l,h=i(r,n,Math.ceil(r.length/4)),p=i(r,n,Math.ceil(r.length/2));return h||p?(o=p?h&&h[4].length>p[4].length?h:p:h,e.length>t.length?(s=o[0],a=o[1],u=o[2],l=o[3]):(u=o[0],l=o[1],s=o[2],a=o[3]),[s,a,u,l,o[4]]):null}function h(e){e.push([i,""]);for(var t,o=0,s=0,a=0,u="",l="";o1?(0!==s&&0!==a&&(0!==(t=c(l,u))&&(o-s-a>0&&e[o-s-a-1][0]==i?e[o-s-a-1][1]+=l.substring(0,t):(e.splice(0,0,[i,l.substring(0,t)]),o++),l=l.substring(t),u=u.substring(t)),0!==(t=f(l,u))&&(e[o][1]=l.substring(l.length-t)+e[o][1],l=l.substring(0,l.length-t),u=u.substring(0,u.length-t))),0===s?e.splice(o-a,s+a,[n,l]):0===a?e.splice(o-s,s+a,[r,u]):e.splice(o-s-a,s+a,[r,u],[n,l]),o=o-s-a+(s?1:0)+(a?1:0)+1):0!==o&&e[o-1][0]==i?(e[o-1][1]+=e[o][1],e.splice(o,1)):o++,a=0,s=0,u="",l=""}""===e[e.length-1][1]&&e.pop();var p=!1;for(o=1;o=56320&&e.charCodeAt(0)<=57343},s=function(e){return e.charCodeAt(e.length-1)>=55296&&e.charCodeAt(e.length-1)<=56319},a=2;a0&&u.push(e[a]);return u}function g(e,t,r){for(var n=t+r-1;n>=0&&n>=t-1;n--)if(n+1{var r,n="Delete"===t.struct?t.key:t.parentSub;if(r=null!=this.opContents[n]?this.os.getType(this.opContents[n]):this.contents[n],"Insert"===t.struct){var i;null!==t.left||e.utils.compareIds(t.id,this.map[n])||(null!=t.opContent?((i=this.os.getType(t.opContent))._parent=this._model,delete this.contents[n],t.deleted?delete this.opContents[n]:this.opContents[n]=t.opContent):(i=t.content[0],delete this.opContents[n],t.deleted?delete this.contents[n]:this.contents[n]=t.content[0]),this.map[n]=t.id,void 0===r?e.utils.bubbleEvent(this,{name:n,object:this,type:"add",value:i}):e.utils.bubbleEvent(this,{name:n,object:this,oldValue:r,type:"update",value:i}))}else{if("Delete"!==t.struct)throw new Error("Unexpected Operation!");e.utils.compareIds(this.map[n],t.target)&&(delete this.opContents[n],delete this.contents[n],e.utils.bubbleEvent(this,{name:n,object:this,oldValue:r,type:"delete"}))}})}_getPathToChild(t){return Object.keys(this.opContents).find(r=>e.utils.compareIds(this.opContents[r],t))}_destroy(){this.eventHandler.destroy(),this.eventHandler=null,this.contents=null,this.opContents=null,this._model=null,this._parent=null,this.os=null,this.map=null}get(e){if(null==e||"string"!=typeof e)throw new Error("You must specify a key (as string)!");return null==this.opContents[e]?this.contents[e]:this.os.getType(this.opContents[e])}keys(){return Object.keys(this.contents).concat(Object.keys(this.opContents))}keysPrimitives(){return Object.keys(this.contents)}keysTypes(){return Object.keys(this.opContents)}getPrimitive(t){if(null==t)return e.utils.copyObject(this.contents);if("string"!=typeof t)throw new Error("Key is expected to be a string!");return this.contents[t]}getType(e){if(null==e||"string"!=typeof e)throw new Error("You must specify a key (as string)!");return null!=this.opContents[e]?this.os.getType(this.opContents[e]):null}delete(t){var r=this.map[t];if(null!=r){var n={target:r,struct:"Delete"},i=this.eventHandler,o=e.utils.copyObject(n);o.key=t,this.os.requestTransaction(function*(){yield*i.awaitOps(this,this.applyCreatedOperations,[[n]])}),i.awaitAndPrematurelyCall([o])}}set(t,r){var n=this.map[t]||null,i={id:this.os.getNextOpId(1),left:null,right:n,origin:null,parent:this._model,parentSub:t,struct:"Insert"},o=this.eventHandler,s=e.utils.isTypeDefinition(r);if(!1!==s){var a=this.os.createType(s);return i.opContent=a._model,this.os.requestTransaction(function*(){yield*o.awaitOps(this,this.applyCreatedOperations,[[i]])}),o.awaitAndPrematurelyCall([i]),a}return i.content=[r],this.os.requestTransaction(function*(){yield*o.awaitOps(this,this.applyCreatedOperations,[[i]])}),o.awaitAndPrematurelyCall([i]),r}observe(e){this.eventHandler.addEventListener(e)}observeDeep(e){this._deepEventHandler.addEventListener(e)}unobserve(e){this.eventHandler.removeEventListener(e)}unobserveDeep(e){this._deepEventHandler.removeEventListener(e)}observePath(r,n){var i,o=this;if(r.length<1)return n(this),function(){};if(1===r.length)return i=r[0],n(o.get(i)),this.observe(function(e){e.name===i&&n(o.get(i))}),function(){o.unobserve(n)};var s,a=function(){var i=o.get(r[0]);i instanceof t||(i=o.set(r[0],e.Map)),s=i.observePath(r.slice(1),n)},u=function(e){e.name===r[0]&&(null!=s&&s(),"add"!==e.type&&"update"!==e.type||a())};return o.observe(u),a(),function(){null!=s&&s(),o.unobserve(u)}}*_changed(e,t){if("Delete"===t.struct){if(null==t.key){var r=yield*e.getOperation(t.target);t.key=r.parentSub}}else null!=t.opContent&&(yield*e.store.initType.call(e,t.opContent));this.eventHandler.receivedOp(t)}}e.extend("Map",new e.utils.CustomTypeDefinition({name:"Map",class:t,struct:"Map",initType:function*(e,r){var n={},i={},o=r.map;for(var s in o){var a=yield*this.getOperation(o[s]);a.deleted||(null!=a.opContent?(i[s]=a.opContent,(yield*this.store.initType.call(this,a.opContent))._parent=r.id):n[s]=a.content[0])}return new t(e,r,n,i)},createType:function(e,r){return new t(e,r,{},{})}}))}e.exports=n,"undefined"!=typeof Y&&n(Y)},function(e,t,r){"use strict";const n=r(1)("y-ipfs-connector"),i=r(11),o=r(1499),s=r(162),a=r(2).Buffer,u=r(1506),c=r(1507);function f(e){e.extend("ipfs",class extends e.AbstractConnector{constructor(e,t){if(void 0===t)throw new Error("Options must not be undefined!");if(null==t.room)throw new Error("You must define a room name!");if(!t.ipfs)throw new Error("You must define a started IPFS object inside options");t.role||(t.role="master"),super(e,t),this._yConnectorOptions=t,this.ipfs=t.ipfs;const r=this.ipfsPubSubTopic="y-ipfs:rooms:"+t.room;this.roomEmitter=t.roomEmitter||new i,this.roomEmitter.peers=(()=>this._room.getPeers()),this.roomEmitter.id=(()=>r),this._receiveQueue=s(this._processQueue.bind(this),1),this._room=o(this.ipfs,r),this._room.setMaxListeners(1/0),this._room.on("error",e=>{console.error(e)}),this._room.on("message",e=>{if(this.ipfs._peerInfo&&e.from===this.ipfs._peerInfo.id.toB58String())return;const r=()=>{let r;r=this._yConnectorOptions.decode?this._yConnectorOptions.decode(e.data):c(e.data);const n=()=>{const t=c(r.payload);this.roomEmitter.emit("received message",e.from,t),null!==t.type&&this._queueReceiveMessage(e.from,t)};if(t.verifySignature){const i=r.signature&&a.from(r.signature,"base64");t.verifySignature.call(null,e.from,a.from(r.payload),i,(t,r)=>{t?console.error("Error verifying signature from peer "+e.from+". Discarding message.",t):r?n():console.error("Invalid signature from peer "+e.from+". Discarding message.")})}else n()};if(this._room.hasPeer(e.from))r();else{const t=n=>{n===e.from&&(this._room.removeListener("peer joined",t),r())};this._room.on("peer joined",t)}}),this._room.on("peer joined",e=>{this.roomEmitter.emit("peer joined",e),this.userJoined(e,"master")}),this._room.on("peer left",e=>{this.roomEmitter.emit("peer left",e),this.userLeft(e)}),this.ipfs.isOnline()?this._start():this.ipfs.once("ready",this._start.bind(this))}_queueReceiveMessage(e,t){this._receiveQueue.push({from:e,message:t})}_processQueue(e,t){const r=e.from,n=e.message;r===this._ipfsUserId?t():this._room.hasPeer(r)?(this.receiveMessage(r,n),t()):(this._receiveQueue.unshift(e),setTimeout(t,500))}_start(){const e=this.ipfs._peerInfo.id.toB58String();this._ipfsUserId=e,this.setUserId(e)}disconnect(){n("disconnect"),this._room.leave(),super.disconnect()}send(e,t){this._encodeMessage(t,(r,n)=>{if(r)throw r;this._yConnectorOptions.encode&&(n=this._yConnectorOptions.encode(n)),this._room.sendTo(e,n),this.roomEmitter.emit("sent message",e,t)})}broadcast(e){this._encodeMessage(e,(t,r)=>{if(t)throw t;this._yConnectorOptions.encode&&(r=this._yConnectorOptions.encode(r)),this._room.broadcast(r),this.roomEmitter.emit("sent message","broadcast",e)})}isDisconnected(){return!1}_encodeMessage(e,t){const r=function(e){return JSON.stringify(e)}(e);this._yConnectorOptions.sign?this._yConnectorOptions.sign(a.from(r),(e,n)=>{if(e)return t(e);const i=n.toString("base64");t(null,u({signature:i,payload:r}))}):t(null,u({payload:r}))}})}e.exports=f,"undefined"!=typeof Y&&f(Y)},function(e,t,r){"use strict";(function(t){const n=r(1500),i=r(11),o=r(1502),s=r(612),a=r(613),u=r(1503),c=r(614),f=r(1505),l={pollInterval:1e3};e.exports=((e,t,r)=>new h(e,t,r));class h extends i{constructor(e,t,r){if(super(),this._ipfs=e,this._topic=t,this._options=Object.assign({},s(l),s(r)),this._peers=[],this._connections={},this._handleDirectMessage=this._handleDirectMessage.bind(this),!this._ipfs.pubsub)throw new Error("This IPFS node does not have pubsub.");this._ipfs.isOnline()?this._start():this._ipfs.on("ready",this._start.bind(this)),this._ipfs.on("stop",this.leave.bind(this))}getPeers(){return this._peers.slice(0)}hasPeer(e){return this._peers.indexOf(e)>=0}leave(){return new Promise((e,t)=>{o.clearInterval(this._interval),Object.keys(this._connections).forEach(e=>{this._connections[e].stop()}),f.emitter.removeListener(this._topic,this._handleDirectMessage),this.once("stopped",()=>e()),this.emit("stopping")})}broadcast(e){let t=c(e);this._ipfs.pubsub.publish(this._topic,t,e=>{e&&this.emit("error",e)})}sendTo(e,r){let n=this._connections[e];n||((n=new u(e,this._ipfs,this)).on("error",e=>this.emit("error",e)),this._connections[e]=n,n.once("disconnect",()=>{delete this._connections[e],this._peers=this._peers.filter(t=>t!==e),this.emit("peer left",e)}));const i=t.from([0]),o={to:e,from:this._ipfs._peerInfo.id.toB58String(),data:t.from(r).toString("hex"),seqno:i.toString("hex"),topicIDs:[this._topic],topicCIDs:[this._topic]};n.push(t.from(JSON.stringify(o)))}_start(){this._interval=o.setInterval(this._pollPeers.bind(this),this._options.pollInterval);const e=this._onMessage.bind(this);this._ipfs.pubsub.subscribe(this._topic,e,{},e=>{e?this.emit("error",e):this.emit("subscribed",this._topic)}),this.once("stopping",()=>{this._ipfs.pubsub.unsubscribe(this._topic,e,e=>{e?this.emit("error",e):this.emit("stopped")})}),this._ipfs._libp2pNode.handle(a,f.handler),f.emitter.on(this._topic,this._handleDirectMessage)}_pollPeers(){this._ipfs.pubsub.peers(this._topic,(e,t)=>{if(e)return void this.emit("error",e);const r=t.sort();this._emitChanges(r)&&(this._peers=r)})}_emitChanges(e){const t=n(this._peers,e);return t.added.forEach(e=>this.emit("peer joined",e)),t.removed.forEach(e=>this.emit("peer left",e)),t.added.length>0||t.removed.length>0}_onMessage(e){this.emit("message",e)}_handleDirectMessage(e){if(e.to===this._ipfs._peerInfo.id.toB58String()){const t=Object.assign({},e);delete t.to,this.emit("message",t)}}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(612),i=r(1)("hyperdiff"),o=r(1501),s=e=>-1!==e;function a(e,t){return e.indexOf(t)}function u(e,t,r){return e.findIndex(function(e){return function(e,t,r){return r.every(r=>t[r]===e[r])}(e,t,r)})}function c(e,t){return{first:e,second:n(t)}}function f(e,t){return t?u:a}e.exports=function(e,t,r){const n=r?[].concat(r):[],{first:a,second:u}=c(e,t),l=f(0,r);i("preconditions first=%j second=%j findIndex=%s",a,u,l.name);const h=a.reduce(function(e,t,r){const a=l(u,t,n),c=s(a)?"common":"removed";return e[c].push(t),o(u,a),i("index=%s value=%s collection=%s",r,t,c),e},{common:[],removed:[]});return h.added=u,i("added=%j removed=%j common%j",h.added,h.removed,h.common),h}},function(e,t,r){(function(t){var r="Expected a function",n="__lodash_hash_undefined__",i=1/0,o=9007199254740991,s="[object Arguments]",a="[object Function]",u="[object GeneratorFunction]",c="[object Symbol]",f=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,l=/^\w*$/,h=/^\./,p=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,d=/\\(\\)?/g,y=/^\[object .+?Constructor\]$/,g=/^(?:0|[1-9]\d*)$/,m="object"==typeof t&&t&&t.Object===Object&&t,b="object"==typeof self&&self&&self.Object===Object&&self,v=m||b||Function("return this")();function _(e,t){for(var r=-1,n=t.length,i=e.length;++rt||o&&s&&u&&!a&&!c||n&&s&&u||!r&&u||!i)return 1;if(!n&&!o&&!c&&e-1&&e%1==0&&e<=o}(e.length)&&!ae(e)}(e)}(e)&&T.call(e,"callee")&&(!O.call(e,"callee")||B.call(e)==s)}(e)||!!(N&&e&&e[N])}function X(e,t){return!!(t=null==t?o:t)&&("number"==typeof e||g.test(e))&&e>-1&&e%1==0&&ei?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Array(i);++n-1},F.prototype.set=function(e,t){var r=this.__data__,n=H(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},q.prototype.clear=function(){this.__data__={hash:new U,map:new(K||F),string:new U}},q.prototype.delete=function(e){return $(this,e).delete(e)},q.prototype.get=function(e){return $(this,e).get(e)},q.prototype.has=function(e){return $(this,e).has(e)},q.prototype.set=function(e,t){return $(this,e).set(e,t),this};var ee=ie(function(e){e=function(e){return null==e?"":function(e){if("string"==typeof e)return e;if(fe(e))return D?D.call(e):"";var t=e+"";return"0"==t&&1/e==-i?"-0":t}(e)}(e);var t=[];return h.test(e)&&t.push(""),e.replace(p,function(e,r,n,i){t.push(n?i.replace(d,"$1"):r||e)}),t});function te(e){if("string"==typeof e||fe(e))return e;var t=e+"";return"0"==t&&1/e==-i?"-0":t}function re(e){var t=e?e.length:0;return t?e[t-1]:void 0}var ne=function(e,t){return t=L(void 0===t?e.length-1:t,0),function(){for(var r=arguments,n=-1,i=L(r.length-t,0),o=Array(i);++n0&&n(u)?r>1?e(u,r-1,n,i,o):_(o,u):i||(o[o.length]=u)}return o}(t,1);var r=e?e.length:0,n=function(e,t){for(var r=-1,n=null==e,i=t.length,o=Array(i);++r=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},r(572),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";const n=r(11),i=r(8),o=r(46),s=r(613),a=r(614),u=r(1504);e.exports=class extends n{constructor(e,t,r){super(),this._id=e,this._ipfs=t,this._room=r,this._connection=null,this._connecting=!1}push(e){this._connection?this._connection.push(a(e)):(this.once("connect",()=>this.push(e)),this._connecting||this._getConnection())}stop(){this._connection&&this._connection.end()}_getConnection(){this._connecting=!0,this._getPeerAddresses(this._id,(e,t)=>{e?this.emit("error",e):t.length?this._ipfs._libp2pNode.dialProtocol(t[0],s,(e,t)=>{if(e)return void this.emit("disconnect");this._connecting=!1;const r=o();this._connection=r,i(r,t,i.onEnd(()=>{delete this._connection,this.emit("disconnect")})),this.emit("connect",r)}):this.emit("disconnect")})}_getPeerAddresses(e,t){this._ipfs.swarm.peers((r,n)=>{r?t(r):t(null,n.filter(t=>u(t.peer)===e).map(e=>e.peer))})}}},function(e,t,r){"use strict";e.exports=(e=>(e.id&&"function"==typeof e.id.toB58String&&(e=e.id),e.toB58String()))},function(e,t,r){"use strict";(function(t){const n=r(8),i=new(r(11));e.exports={handler:function(e,r){r.getPeerInfo((e,o)=>{if(e)return void console.log(e);const s=o.id.toB58String();n(r,n.map(e=>{let r;try{r=JSON.parse(e.toString())}catch(e){return void i.emit("warning",e.message)}if(s!==r.from)return void i.emit("warning","no peerid match "+r.from);const n=r.topicIDs;if(Array.isArray(n))return r.data=t.from(r.data,"hex"),r.seqno=t.from(r.seqno,"hex"),n.forEach(e=>{i.emit(e,r)}),r;i.emit("warning","no topic IDs")}),n.onEnd(()=>{}))})},emitter:i}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){e.exports=(e=>t.from(JSON.stringify(e)))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";e.exports=(e=>{const t=e.toString();let r;try{r=JSON.parse(t)}catch(e){throw console.error("Failed parsing",t),e}return r})},function(e,t,r){"use strict";function n(e){return e?(e^16*Math.random()>>e/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,n)}function i(e){e.requestModules(["memory"]).then(function(){e.utils.createStoreClone=function(e){return class extends e{constructor(){super(...arguments),this.buffer=[],this._copyTo=null}copyTo(e){return this._copyTo=e,this}*put(e,t){t||this.buffer.push(this._copyTo.put(e)),yield*super.put(e)}*delete(e){this.buffer.push(this._copyTo.delete(e)),yield*super.delete(e)}*flush(){yield*super.flush();for(var e=0;e{this.webtorrent=new n(this.options),this.webtorrent.once("ready",()=>{console.log("WEBTORRENT READY"),e()}),this.webtorrent.once("error",e=>t(e)),this.webtorrent.on("warning",e=>{console.warn("WebTorrent Torrent WARNING: "+e.message)})})}static setup0(e,t){let r=a.mergeoptions(c,e.webtorrent);t&&console.log("WebTorrent options %o",r);let n=new f(r,t);return u.addtransport(n),n}async p_setup1(e,t){try{this.status=a.STATUS_STARTING,t&&t(this),await this.p_webtorrentstart(e),await this.p_status(e)}catch(e){console.error(this.name,"failed to connect",e),this.status=a.STATUS_FAILED}return t&&t(this),this}async p_status(e){return this.webtorrent&&this.webtorrent.ready?this.status=a.STATUS_CONNECTED:this.webtorrent?this.status=a.STATUS_STARTING:this.status=a.STATUS_FAILED,super.p_status(e)}webtorrentparseurl(e){if(!e)throw new s.CodingError("TransportWEBTORRENT.p_rawfetch: requires url");const t="string"==typeof e?e:e.href,r=t.indexOf("/");if(-1===r)throw new s.CodingError("TransportWEBTORRENT.p_rawfetch: invalid url - missing path component. Should look like magnet:xyzabc/path/to/file");return{torrentId:t.slice(0,r),path:t.slice(r+1)}}async p_webtorrentadd(e){return new Promise((t,r)=>{let n=this.webtorrent.get(e);n||((n=this.webtorrent.add(e)).once("error",e=>{r(new s.TransportError("Torrent encountered a fatal error "+e.message))}),n.on("warning",e=>{console.warn("WebTorrent Torrent WARNING: "+e.message+" ("+n.name+")")})),n.ready?t(n):n.once("ready",()=>{t(n)})})}webtorrentfindfile(e,t){const r=e.name+"/"+t,n=e.files.find(e=>e.path===r);if(!n)throw new s.TransportError("Requested file ("+t+") not found within torrent ");return n}p_rawfetch(e,{verbose:t=!1}={}){return new Promise((r,n)=>{t&&console.log("WebTorrent p_rawfetch",e);const{torrentId:i,path:o}=this.webtorrentparseurl(e);this.p_webtorrentadd(i).then(e=>{e.deselect(0,e.pieces.length-1,!1),this.webtorrentfindfile(e,o).getBuffer((t,i)=>{if(t)return n(new s.TransportError("Torrent encountered a fatal error "+t.message+" ("+e.name+")"));r(i)})}).catch(e=>n(e))})}async _p_fileTorrentFromUrl(e){try{const{torrentId:t,path:r}=this.webtorrentparseurl(e),n=await this.p_webtorrentadd(t);n.deselect(0,n.pieces.length-1,!1);const i=this.webtorrentfindfile(n,r);return"undefined"!=typeof window&&(window.WEBTORRENT_TORRENT=n,window.WEBTORRENT_FILE=i,n.once("close",()=>{window.WEBTORRENT_TORRENT=null,window.WEBTORRENT_FILE=null})),i}catch(t){throw console.log(`p_fileFrom failed on ${e} ${t.message}`),t}}async p_f_createReadStream(e,{verbose:t=!1,wanturl:r=!1}={}){t&&console.log(this.name,"p_f_createreadstream",o.parse(e).href);try{let n=await this._p_fileTorrentFromUrl(e),i=this;return r?e:function(e){return i.createReadStream(n,e,t)}}catch(t){throw console.log(`p_f_createReadStream failed on ${e} ${t.message}`),t}}createReadStream(e,t,r){let n;r&&console.log(this.name,"createreadstream",e.name,t);try{return n=new i.PassThrough,e.createReadStream(t).pipe(n),n}catch(e){console.log("TransportWEBTORRENT caught error",e),"function"==typeof n.destroy?n.destroy(e):n.emit("error",e)}}async p_createReadableStream(e,t,r){let n=await this._p_fileTorrentFromUrl(e);return new ReadableStream({start(r){console.log("start",e,t);const i=n.createReadStream(t);i.on("data",e=>{r.enqueue(e)}),i.on("end",()=>{r.close()})},cancel(r){throw new s.TransportError(`cancelled ${e}, ${t} ${r}`)}})}static async p_test(e,r){try{let i=await this.p_setup(e,r);r&&console.log(i.name,"setup");let o=await i.p_status(r);console.assert(o===a.STATUS_CONNECTED);let s="magnet:?xt=urn:btih:dd8255ecdc7ca55fb0bbf81323d87062db1f6d1c&dn=Big+Buck+Bunny&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fbig-buck-bunny.torrent/Big Buck Bunny.en.srt",u=await i.p_rawfetch(s,{verbose:r});n(u=u.toString());const c=await i.createReadStream(s,r),f=[];function n(e){console.assert(-1!==e.indexOf("00:00:02,000 --\x3e 00:00:05,000"),"Should fetch 'Big Buck Bunny.en.srt' from the torrent"),console.assert(e.length,129,"'Big Buck Bunny.en.srt' was "+e.length)}c.on("data",e=>{f.push(e)}),c.on("end",()=>{n(t.concat(f).toString())})}catch(e){throw console.log("Exception thrown in TransportWEBTORRENT.p_test:",e.message),e}}}u._transportclasses.WEBTORRENT=f,e.exports=f}).call(this,r(0).Buffer)},function(e,t,r){(function(t,n){e.exports=A;var i=r(2).Buffer,o=r(327),s=r(1511),a=r(1)("webtorrent"),u=r(1522),c=r(11).EventEmitter,f=r(26),l=r(5),h=r(1523),p=r(147),d=r(617),y=r(64),g=r(191),m=r(107),b=r(329),v=r(1532),_=r(1533),w=r(1534),S=r(331).version,k=S.match(/([0-9]+)/g).slice(0,2).map(function(e){return v(2,e)}).join(""),E="-WW"+k+"-";function A(e){var r=this;if(!(r instanceof A))return new A(e);function o(){r.destroyed||(r.ready=!0,r.emit("ready"))}c.call(r),e||(e={}),"string"==typeof e.peerId?r.peerId=e.peerId:i.isBuffer(e.peerId)?r.peerId=e.peerId.toString("hex"):r.peerId=i.from(E+m(9).toString("base64")).toString("hex"),r.peerIdBuffer=i.from(r.peerId,"hex"),"string"==typeof e.nodeId?r.nodeId=e.nodeId:i.isBuffer(e.nodeId)?r.nodeId=e.nodeId.toString("hex"):r.nodeId=m(20).toString("hex"),r.nodeIdBuffer=i.from(r.nodeId,"hex"),r._debugId=r.peerId.toString("hex").substring(0,7),r.destroyed=!1,r.listening=!1,r.torrentPort=e.torrentPort||0,r.dhtPort=e.dhtPort||0,r.tracker=void 0!==e.tracker?e.tracker:{},r.torrents=[],r.maxConns=Number(e.maxConns)||55,r._debug("new webtorrent (peerId %s, nodeId %s, port %s)",r.peerId,r.nodeId,r.torrentPort),r.tracker&&("object"!=typeof r.tracker&&(r.tracker={}),e.rtcConfig&&(console.warn("WebTorrent: opts.rtcConfig is deprecated. Use opts.tracker.rtcConfig instead"),r.tracker.rtcConfig=e.rtcConfig),e.wrtc&&(console.warn("WebTorrent: opts.wrtc is deprecated. Use opts.tracker.wrtc instead"),r.tracker.wrtc=e.wrtc),t.WRTC&&!r.tracker.wrtc&&(r.tracker.wrtc=t.WRTC)),"function"==typeof _?r._tcpPool=new _(r):n.nextTick(function(){r._onListening()}),r._downloadSpeed=b(),r._uploadSpeed=b(),!1!==e.dht&&"function"==typeof u?(r.dht=new u(f({nodeId:r.nodeId},e.dht)),r.dht.once("error",function(e){r._destroy(e)}),r.dht.once("listening",function(){var e=r.dht.address();e&&(r.dhtPort=e.port)}),r.dht.setMaxListeners(0),r.dht.listen(r.dhtPort)):r.dht=!1,r.enableWebSeeds=!1!==e.webSeeds,"function"==typeof h&&null!=e.blocklist?h(e.blocklist,{headers:{"user-agent":"WebTorrent/"+S+" (https://webtorrent.io)"}},function(e,t){if(e)return r.error("Failed to load blocklist: "+e.message);r.blocked=t,o()}):n.nextTick(o)}l(A,c),A.WEBRTC_SUPPORT=g.WEBRTC_SUPPORT,A.VERSION=S,Object.defineProperty(A.prototype,"downloadSpeed",{get:function(){return this._downloadSpeed()}}),Object.defineProperty(A.prototype,"uploadSpeed",{get:function(){return this._uploadSpeed()}}),Object.defineProperty(A.prototype,"progress",{get:function(){var e=this.torrents.filter(function(e){return 1!==e.progress});return e.reduce(function(e,t){return e+t.downloaded},0)/(e.reduce(function(e,t){return e+(t.length||0)},0)||1)}}),Object.defineProperty(A.prototype,"ratio",{get:function(){return this.torrents.reduce(function(e,t){return e+t.uploaded},0)/(this.torrents.reduce(function(e,t){return e+t.received},0)||1)}}),A.prototype.get=function(e){var t,r,n=this.torrents.length;if(e instanceof w){for(t=0;t1?o=t.path[0]:t.path[0]!==o&&(o=null)}}),e=e.filter(function(e){if("string"==typeof e)return!0;var t=e.path[e.path.length-1];return S(t)&&d.not(t)}),o&&e.forEach(function(e){var r=(t.isBuffer(e)||I(e))&&!e.path;"string"==typeof e||r||e.path.shift()}),!r.name&&o&&(r.name=o),r.name||e.some(function(e){return"string"==typeof e?(r.name=u.basename(e),!0):e.unknownName?void 0:(r.name=e.path[e.path.length-1],!0)}),r.name||(r.name="Unnamed Torrent "+Date.now());var s=e.reduce(function(e,t){return e+Number("string"==typeof t)},0),a=1===e.length;if(1===e.length&&"string"==typeof e[0]){if("function"!=typeof h.stat)throw new Error("filesystem paths do not work in the browser");p(e[0],function(e,t){if(e)return i(e);a=t,c()})}else n.nextTick(function(){c()});function c(){m(e.map(function(e){return function(r){var n={};if(x(e))n.getStream=function(e){return function(){return new f(e)}}(e),n.length=e.size;else if(t.isBuffer(e))n.getStream=function(e){return function(){var t=new v.PassThrough;return t.end(e),t}}(e),n.length=e.length;else{if(!I(e)){if("string"==typeof e){if("function"!=typeof h.stat)throw new Error("filesystem paths do not work in the browser");return void function(e,t,r){!function e(t,r,n){h.stat(t,function(i,o){if(i)return n(i);o.isDirectory()?h.readdir(t,function(i,o){if(i)return n(i);m(o.filter(S).filter(d.not).map(function(n){return function(i){e(u.join(t,n),r,i)}}),n)}):o.isFile()&&r(t,n)})}(e,w,function(n,i){if(n)return r(n);i=Array.isArray(i)?l(i):[i],e=u.normalize(e),t&&(e=e.slice(0,e.lastIndexOf(u.sep)+1)),e[e.length-1]!==u.sep&&(e+=u.sep),i.forEach(function(t){t.getStream=function(e){return function(){return h.createReadStream(e)}}(t.path),t.path=t.path.replace(e,"").split(u.sep)}),r(null,i)})}(e,s>1||a,r)}throw new Error("invalid input type")}n.getStream=function(e,t){return function(){var r=new v.Transform;return r._transform=function(e,r,n){t.length+=e.length,this.push(e),n()},e.pipe(r),r}}(e,n),n.length=0}n.path=e.path,r(null,n)}}),function(e,t){if(e)return i(e);t=l(t),i(null,t,a)})}}function w(e,t){t=g(t),h.stat(e,function(r,n){if(r)return t(r);var i={length:n.size,path:e};t(null,i)})}function S(e){return"."!==e[0]}function k(e,r,n){n=g(n);var i=[],o=0,a=e.map(function(e){return e.getStream}),u=0,c=0,f=!1,l=new y(a),h=new s(r,{zeroPadding:!1});function p(e){o+=e.length;var t=c;b(e,function(e){i[t]=e,u-=1,_()}),u+=1,c+=1}function d(){f=!0,_()}function m(e){v(),n(e)}function v(){l.removeListener("error",m),h.removeListener("data",p),h.removeListener("end",d),h.removeListener("error",m)}function _(){f&&0===u&&(v(),n(null,t.from(i.join(""),"hex"),o))}l.on("error",m),l.pipe(h).on("data",p).on("end",d).on("error",m)}function E(t,r,n){var s=r.announceList;s||("string"==typeof r.announce?s=[[r.announce]]:Array.isArray(r.announce)&&(s=r.announce.map(function(e){return[e]}))),s||(s=[]),i.WEBTORRENT_ANNOUNCE&&("string"==typeof i.WEBTORRENT_ANNOUNCE?s.push([[i.WEBTORRENT_ANNOUNCE]]):Array.isArray(i.WEBTORRENT_ANNOUNCE)&&(s=s.concat(i.WEBTORRENT_ANNOUNCE.map(function(e){return[e]})))),void 0===r.announce&&void 0===r.announceList&&(s=s.concat(e.exports.announceList)),"string"==typeof r.urlList&&(r.urlList=[r.urlList]);var u={info:{name:r.name},"creation date":Math.ceil((Number(r.creationDate)||Date.now())/1e3),encoding:"UTF-8"};0!==s.length&&(u.announce=s[0][0],u["announce-list"]=s),void 0!==r.comment&&(u.comment=r.comment),void 0!==r.createdBy&&(u["created by"]=r.createdBy),void 0!==r.private&&(u.info.private=Number(r.private)),void 0!==r.sslCert&&(u.info["ssl-cert"]=r.sslCert),void 0!==r.urlList&&(u["url-list"]=r.urlList);var c=r.pieceLength||a(t.reduce(A,0));u.info["piece length"]=c,k(t,c,function(e,i,s){if(e)return n(e);u.info.pieces=i,t.forEach(function(e){delete e.getStream}),r.singleFileTorrent?u.info.length=s:u.info.files=t,n(null,o.encode(u))})}function A(e,t){return e+t.length}function x(e){return"undefined"!=typeof Blob&&e instanceof Blob}function I(e){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}}).call(this,r(0).Buffer,r(7),r(6))},function(e,t,r){var n=r(2).Buffer;function i(e,t,r){var o=[],s=null;return i._encode(o,e),s=n.concat(o),i.bytes=s.length,n.isBuffer(t)?(s.copy(t,r),t):s}i.bytes=-1,i._floatConversionDetected=!1,i.getType=function(e){return n.isBuffer(e)?"buffer":Array.isArray(e)?"array":ArrayBuffer.isView(e)?"arraybufferview":e instanceof Number?"number":e instanceof Boolean?"boolean":e instanceof ArrayBuffer?"arraybuffer":typeof e},i._encode=function(e,t){if(null!=t)switch(i.getType(t)){case"buffer":i.buffer(e,t);break;case"object":i.dict(e,t);break;case"array":i.list(e,t);break;case"string":i.string(e,t);break;case"number":case"boolean":i.number(e,t);break;case"arraybufferview":i.buffer(e,n.from(t.buffer,t.byteOffset,t.byteLength));break;case"arraybuffer":i.buffer(e,n.from(t))}};var o=n.from("e"),s=n.from("d"),a=n.from("l");i.buffer=function(e,t){e.push(new n(t.length+":"),t)},i.string=function(e,t){e.push(n.from(n.byteLength(t)+":"+t))},i.number=function(e,t){var r=2147483648,o=(t/r<<0)*r+(t%r<<0);e.push(n.from("i"+o+"e")),o===t||i._floatConversionDetected||(i._floatConversionDetected=!0,console.warn('WARNING: Possible data corruption detected with value "'+t+'":','Bencoding only defines support for integers, value was converted to "'+o+'"'),console.trace())},i.dict=function(e,t){e.push(s);for(var r,n=0,a=Object.keys(t).sort(),u=a.length;n=48)n=10*n+(s-48);else if(o!==t||43!==s){if(o!==t||45!==s){if(46===s)break;throw new Error("not a number: buffer["+o+"] = "+s)}i=-1}}return n*i}function n(e,r,i,o){return null==e||0===e.length?null:("number"!=typeof r&&null==o&&(o=r,r=void 0),"number"!=typeof i&&null==o&&(o=i,i=void 0),n.position=0,n.encoding=o||null,n.data=t.isBuffer(e)?e.slice(r,i):new t(e),n.bytes=n.data.length,n.next())}n.bytes=0,n.position=0,n.data=null,n.encoding=null,n.next=function(){switch(n.data[n.position]){case 100:return n.dictionary();case 108:return n.list();case 105:return n.integer();default:return n.buffer()}},n.find=function(e){for(var t=n.position,r=n.data.length,i=n.data;t>1)]-e)<0?u=i+1:s>0&&(c=i-1),(s=r(s))this._size&&(n=this._size),r===this._size)return this.destroy(),void this.push(null);t.onload=function(){e._offset=n,e.push(o(t.result))},t.onerror=function(){e.emit("error",t.error)},t.readAsArrayBuffer(this._file.slice(r,n))}else this.once("_ready",this._read.bind(this))},s.prototype.destroy=function(){if(this._file=null,this.reader){this.reader.onload=null,this.reader.onerror=null;try{this.reader.abort()}catch(e){}}this.reader=null}},function(e,t){e.exports=function(e,t){return(t="number"==typeof t?t:1/0)?function e(r,n){return r.reduce(function(r,i){return Array.isArray(i)&&nt.re.test(e)),t.not=(e=>!t.is(e))},function(e,t,r){!function(t,r){e.exports=r()}("undefined"!=typeof self&&self,function(){return 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,{configurable:!1,enumerable:!0,get: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=3)}([function(e,t,r){var n=r(5),i=r(1),o=i.toHex,s=i.ceilHeapSize,a=r(6),u=function(e){for(e+=9;e%64>0;e+=1);return e},c=function(e,t){var r=new Int32Array(e,t+320,5),n=new Int32Array(5),i=new DataView(n.buffer);return i.setInt32(0,r[0],!1),i.setInt32(4,r[1],!1),i.setInt32(8,r[2],!1),i.setInt32(12,r[3],!1),i.setInt32(16,r[4],!1),n},f=function(){function e(t){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),(t=t||65536)%64>0)throw new Error("Chunk size must be a multiple of 128 bit");this._offset=0,this._maxChunkLen=t,this._padMaxChunkLen=u(t),this._heap=new ArrayBuffer(s(this._padMaxChunkLen+320+20)),this._h32=new Int32Array(this._heap),this._h8=new Int8Array(this._heap),this._core=new n({Int32Array:Int32Array},{},this._heap)}return e.prototype._initState=function(e,t){this._offset=0;var r=new Int32Array(e,t+320,5);r[0]=1732584193,r[1]=-271733879,r[2]=-1732584194,r[3]=271733878,r[4]=-1009589776},e.prototype._padChunk=function(e,t){var r=u(e),n=new Int32Array(this._heap,0,r>>2);return function(e,t){var r=new Uint8Array(e.buffer),n=t%4,i=t-n;switch(n){case 0:r[i+3]=0;case 1:r[i+2]=0;case 2:r[i+1]=0;case 3:r[i+0]=0}for(var o=1+(t>>2);o>2]|=128<<24-(t%4<<3),e[14+(2+(t>>2)&-16)]=r/(1<<29)|0,e[15+(2+(t>>2)&-16)]=r<<3}(n,e,t),r},e.prototype._write=function(e,t,r,n){a(e,this._h8,this._h32,t,r,n||0)},e.prototype._coreCall=function(e,t,r,n,i){var o=r;this._write(e,t,r),i&&(o=this._padChunk(r,n)),this._core.hash(o,this._padMaxChunkLen)},e.prototype.rawDigest=function(e){var t=e.byteLength||e.length||e.size||0;this._initState(this._heap,this._padMaxChunkLen);var r=0,n=this._maxChunkLen;for(r=0;t>r+n;r+=n)this._coreCall(e,r,n,t,!1);return this._coreCall(e,r,t-r,t,!0),c(this._heap,this._padMaxChunkLen)},e.prototype.digest=function(e){return o(this.rawDigest(e).buffer)},e.prototype.digestFromString=function(e){return this.digest(e)},e.prototype.digestFromBuffer=function(e){return this.digest(e)},e.prototype.digestFromArrayBuffer=function(e){return this.digest(e)},e.prototype.resetState=function(){return this._initState(this._heap,this._padMaxChunkLen),this},e.prototype.append=function(e){var t=0,r=e.byteLength||e.length||e.size||0,n=this._offset%this._maxChunkLen,i=void 0;for(this._offset+=r;t0},!1)}function c(e,t){for(var r={main:[t]},n={main:[]},i={main:{}};u(r);)for(var o=Object.keys(r),s=0;s>2]|0;a=n[t+324>>2]|0;c=n[t+328>>2]|0;l=n[t+332>>2]|0;p=n[t+336>>2]|0;for(r=0;(r|0)<(e|0);r=r+64|0){s=o;u=a;f=c;h=l;d=p;for(i=0;(i|0)<64;i=i+4|0){g=n[r+i>>2]|0;y=((o<<5|o>>>27)+(a&c|~a&l)|0)+((g+p|0)+1518500249|0)|0;p=l;l=c;c=a<<30|a>>>2;a=o;o=y;n[e+i>>2]=g}for(i=e+64|0;(i|0)<(e+80|0);i=i+4|0){g=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;y=((o<<5|o>>>27)+(a&c|~a&l)|0)+((g+p|0)+1518500249|0)|0;p=l;l=c;c=a<<30|a>>>2;a=o;o=y;n[i>>2]=g}for(i=e+80|0;(i|0)<(e+160|0);i=i+4|0){g=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;y=((o<<5|o>>>27)+(a^c^l)|0)+((g+p|0)+1859775393|0)|0;p=l;l=c;c=a<<30|a>>>2;a=o;o=y;n[i>>2]=g}for(i=e+160|0;(i|0)<(e+240|0);i=i+4|0){g=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;y=((o<<5|o>>>27)+(a&c|a&l|c&l)|0)+((g+p|0)-1894007588|0)|0;p=l;l=c;c=a<<30|a>>>2;a=o;o=y;n[i>>2]=g}for(i=e+240|0;(i|0)<(e+320|0);i=i+4|0){g=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;y=((o<<5|o>>>27)+(a^c^l)|0)+((g+p|0)-899497514|0)|0;p=l;l=c;c=a<<30|a>>>2;a=o;o=y;n[i>>2]=g}o=o+s|0;a=a+u|0;c=c+f|0;l=l+h|0;p=p+d|0}n[t+320>>2]=o;n[t+324>>2]=a;n[t+328>>2]=c;n[t+332>>2]=l;n[t+336>>2]=p}return{hash:i}}},function(e,t){var r=this,n=void 0;"undefined"!=typeof self&&void 0!==self.FileReaderSync&&(n=new self.FileReaderSync);var i=function(e,t,r,n,i,o){var s=void 0,a=o%4,u=(i+a)%4,c=i-u;switch(a){case 0:t[o]=e[n+3];case 1:t[o+1-(a<<1)|0]=e[n+2];case 2:t[o+2-(a<<1)|0]=e[n+1];case 3:t[o+3-(a<<1)|0]=e[n]}if(!(i>2|0]=e[n+s]<<24|e[n+s+1]<<16|e[n+s+2]<<8|e[n+s+3];switch(u){case 3:t[o+c+1|0]=e[n+c+2];case 2:t[o+c+2|0]=e[n+c+1];case 1:t[o+c+3|0]=e[n+c]}}},o=function(e,t,r,i,o,s){var a=void 0,u=s%4,c=(o+u)%4,f=o-c,l=new Uint8Array(n.readAsArrayBuffer(e.slice(i,i+o)));switch(u){case 0:t[s]=l[3];case 1:t[s+1-(u<<1)|0]=l[2];case 2:t[s+2-(u<<1)|0]=l[1];case 3:t[s+3-(u<<1)|0]=l[0]}if(!(o>2|0]=l[a]<<24|l[a+1]<<16|l[a+2]<<8|l[a+3];switch(c){case 3:t[s+f+1|0]=l[f+2];case 2:t[s+f+2|0]=l[f+1];case 1:t[s+f+3|0]=l[f]}}};e.exports=function(e,t,n,s,a,u){if("string"==typeof e)return function(e,t,r,n,i,o){var s=void 0,a=o%4,u=(i+a)%4,c=i-u;switch(a){case 0:t[o]=e.charCodeAt(n+3);case 1:t[o+1-(a<<1)|0]=e.charCodeAt(n+2);case 2:t[o+2-(a<<1)|0]=e.charCodeAt(n+1);case 3:t[o+3-(a<<1)|0]=e.charCodeAt(n)}if(!(i>2]=e.charCodeAt(n+s)<<24|e.charCodeAt(n+s+1)<<16|e.charCodeAt(n+s+2)<<8|e.charCodeAt(n+s+3);switch(u){case 3:t[o+c+1|0]=e.charCodeAt(n+c+2);case 2:t[o+c+2|0]=e.charCodeAt(n+c+1);case 1:t[o+c+3|0]=e.charCodeAt(n+c)}}}(e,t,n,s,a,u);if(e instanceof Array)return i(e,t,n,s,a,u);if(r&&r.Buffer&&r.Buffer.isBuffer(e))return i(e,t,n,s,a,u);if(e instanceof ArrayBuffer)return i(new Uint8Array(e),t,n,s,a,u);if(e.buffer instanceof ArrayBuffer)return i(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),t,n,s,a,u);if(e instanceof Blob)return o(e,t,n,s,a,u);throw new Error("Unsupported data type.")}},function(e,t,r){var n=r(0),i=r(1).toHex,o=function(){function e(){(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this._rusha=new n,this._rusha.resetState()}return e.prototype.update=function(e){return this._rusha.append(e),this},e.prototype.digest=function(e){var t=this._rusha.rawEnd().buffer;if(!e)return t;if("hex"===e)return i(t);throw new Error("unsupported digest encoding")},e}();e.exports=function(){return new o}}])})},function(e,t){},function(e,t){},function(e,t,r){(function(t){e.exports=function(e,r){if("undefined"==typeof Blob||!(e instanceof Blob))throw new Error("first argument must be a Blob");if("function"!=typeof r)throw new Error("second argument must be a function");var n=new FileReader;n.addEventListener("loadend",function e(i){n.removeEventListener("loadend",e,!1),i.error?r(i.error):r(null,t.from(n.result))},!1),n.readAsArrayBuffer(e)}}).call(this,r(0).Buffer)},function(e,t,r){(function(t){e.exports=l;const n=r(327),i=r(1526),o=r(328),s=r(621),a=r(30),u=r(209),c=r(33),f=e=>null!==e&&"object"==typeof e&&"function"==typeof e.pipe;function l(e,r){if(e=Object.assign({maxRedirects:10},"string"==typeof e?{url:e}:e),r=a(r),e.url){const{hostname:t,port:r,protocol:n,auth:i,path:o}=c.parse(e.url);delete e.url,t||r||n||i?Object.assign(e,{hostname:t,port:r,protocol:n,auth:i,path:o}):e.path=o}const n={"accept-encoding":"gzip, deflate"};let h;e.headers&&Object.keys(e.headers).forEach(t=>n[t.toLowerCase()]=e.headers[t]),e.headers=n,e.body?h=e.json&&!f(e.body)?JSON.stringify(e.body):e.body:e.form&&(h="string"==typeof e.form?e.form:u.stringify(e.form),e.headers["content-type"]="application/x-www-form-urlencoded"),delete e.body,delete e.form,h&&(e.method||(e.method="POST"),f(h)||(e.headers["content-length"]=t.byteLength(h)),e.json&&(e.headers["content-type"]="application/json")),e.json&&(e.headers.accept="application/json"),e.method&&(e.method=e.method.toUpperCase());const p=("https:"===e.protocol?s:o).request(e,t=>{if(t.statusCode>=300&&t.statusCode<400&&t.headers.location)return e.url=t.headers.location,delete e.headers.host,t.resume(),"POST"===e.method&&[301,302].includes(t.statusCode)&&(e.method="GET",delete e.headers["content-length"],delete e.headers["content-type"]),0==e.maxRedirects--?r(new Error("too many redirects")):l(e,r);const n="function"==typeof i&&"HEAD"!==e.method;r(null,n?i(t):t)});return p.on("timeout",()=>{p.abort(),r(new Error("Request timed out"))}),p.on("error",r),f(h)?h.on("error",r).pipe(p):p.end(h),p}l.concat=((e,t)=>l(e,(r,i)=>{if(r)return t(r);n(i,(r,n)=>{if(r)return t(r);if(e.json)try{n=JSON.parse(n.toString())}catch(r){return t(r,i,n)}t(null,i,n)})})),["get","post","put","patch","head","delete"].forEach(e=>{l[e]=((t,r)=>("string"==typeof t&&(t={url:t}),l(Object.assign({method:e.toUpperCase()},t),r)))})}).call(this,r(0).Buffer)},function(e,t){},function(e,t,r){(function(t,n,i){var o=r(618),s=r(5),a=r(619),u=r(22),c=r(620),f=a.IncomingMessage,l=a.readyStates;var h=e.exports=function(e){var r,n=this;u.Writable.call(n),n._opts=e,n._body=[],n._headers={},e.auth&&n.setHeader("Authorization","Basic "+new t(e.auth).toString("base64")),Object.keys(e.headers).forEach(function(t){n.setHeader(t,e.headers[t])});var i=!0;if("disable-fetch"===e.mode||"requestTimeout"in e&&!o.abortController)i=!1,r=!0;else if("prefer-streaming"===e.mode)r=!1;else if("allow-wrong-content-type"===e.mode)r=!o.overrideMimeType;else{if(e.mode&&"default"!==e.mode&&"prefer-fast"!==e.mode)throw new Error("Invalid value for opts.mode");r=!0}n._mode=function(e,t){return o.fetch&&t?"fetch":o.mozchunkedarraybuffer?"moz-chunked-arraybuffer":o.msstream?"ms-stream":o.arraybuffer&&e?"arraybuffer":o.vbArray&&e?"text:vbarray":"text"}(r,i),n._fetchTimer=null,n.on("finish",function(){n._onFinish()})};s(h,u.Writable),h.prototype.setHeader=function(e,t){var r=e.toLowerCase();-1===p.indexOf(r)&&(this._headers[r]={name:e,value:t})},h.prototype.getHeader=function(e){var t=this._headers[e.toLowerCase()];return t?t.value:null},h.prototype.removeHeader=function(e){delete this._headers[e.toLowerCase()]},h.prototype._onFinish=function(){var e=this;if(!e._destroyed){var r=e._opts,s=e._headers,a=null;"GET"!==r.method&&"HEAD"!==r.method&&(a=o.arraybuffer?c(t.concat(e._body)):o.blobConstructor?new n.Blob(e._body.map(function(e){return c(e)}),{type:(s["content-type"]||{}).value||""}):t.concat(e._body).toString());var u=[];if(Object.keys(s).forEach(function(e){var t=s[e].name,r=s[e].value;Array.isArray(r)?r.forEach(function(e){u.push([t,e])}):u.push([t,r])}),"fetch"===e._mode){var f=null;if(o.abortController){var h=new AbortController;f=h.signal,e._fetchAbortController=h,"requestTimeout"in r&&0!==r.requestTimeout&&(e._fetchTimer=n.setTimeout(function(){e.emit("requestTimeout"),e._fetchAbortController&&e._fetchAbortController.abort()},r.requestTimeout))}n.fetch(e._opts.url,{method:e._opts.method,headers:u,body:a||void 0,mode:"cors",credentials:r.withCredentials?"include":"same-origin",signal:f}).then(function(t){e._fetchResponse=t,e._connect()},function(t){n.clearTimeout(e._fetchTimer),e._destroyed||e.emit("error",t)})}else{var p=e._xhr=new n.XMLHttpRequest;try{p.open(e._opts.method,e._opts.url,!0)}catch(t){return void i.nextTick(function(){e.emit("error",t)})}"responseType"in p&&(p.responseType=e._mode.split(":")[0]),"withCredentials"in p&&(p.withCredentials=!!r.withCredentials),"text"===e._mode&&"overrideMimeType"in p&&p.overrideMimeType("text/plain; charset=x-user-defined"),"requestTimeout"in r&&(p.timeout=r.requestTimeout,p.ontimeout=function(){e.emit("requestTimeout")}),u.forEach(function(e){p.setRequestHeader(e[0],e[1])}),e._response=null,p.onreadystatechange=function(){switch(p.readyState){case l.LOADING:case l.DONE:e._onXHRProgress()}},"moz-chunked-arraybuffer"===e._mode&&(p.onprogress=function(){e._onXHRProgress()}),p.onerror=function(){e._destroyed||e.emit("error",new Error("XHR error"))};try{p.send(a)}catch(t){return void i.nextTick(function(){e.emit("error",t)})}}}},h.prototype._onXHRProgress=function(){(function(e){try{var t=e.status;return null!==t&&0!==t}catch(e){return!1}})(this._xhr)&&!this._destroyed&&(this._response||this._connect(),this._response._onXHRProgress())},h.prototype._connect=function(){var e=this;e._destroyed||(e._response=new f(e._xhr,e._fetchResponse,e._mode,e._fetchTimer),e._response.on("error",function(t){e.emit("error",t)}),e.emit("response",e._response))},h.prototype._write=function(e,t,r){this._body.push(e),r()},h.prototype.abort=h.prototype.destroy=function(){this._destroyed=!0,n.clearTimeout(this._fetchTimer),this._response&&(this._response._destroyed=!0),this._xhr?this._xhr.abort():this._fetchAbortController&&this._fetchAbortController.abort()},h.prototype.end=function(e,t,r){"function"==typeof e&&(r=e,e=void 0),u.Writable.prototype.end.call(this,e,t,r)},h.prototype.flushHeaders=function(){},h.prototype.setTimeout=function(){},h.prototype.setNoDelay=function(){},h.prototype.setSocketKeepAlive=function(){};var p=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"]}).call(this,r(0).Buffer,r(6),r(7))},function(e,t){e.exports={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"}},function(e,t,r){e.exports=a,e.exports.decode=a,e.exports.encode=function(e){(e=o(e)).infoHashBuffer&&(e.xt="urn:btih:"+e.infoHashBuffer.toString("hex")),e.infoHash&&(e.xt="urn:btih:"+e.infoHash),e.name&&(e.dn=e.name),e.keywords&&(e.kt=e.keywords),e.announce&&(e.tr=e.announce),e.urlList&&(e.ws=e.urlList,delete e.as);var t="magnet:?";return Object.keys(e).filter(function(e){return 2===e.length}).forEach(function(r,n){(Array.isArray(e[r])?e[r]:[e[r]]).forEach(function(e,i){!(n>0||i>0)||"kt"===r&&0!==i||(t+="&"),"dn"===r&&(e=encodeURIComponent(e).replace(/%20/g,"+")),"tr"!==r&&"xs"!==r&&"as"!==r&&"ws"!==r||(e=encodeURIComponent(e)),"kt"===r&&(e=encodeURIComponent(e)),t+="kt"===r&&i>0?"+"+e:r+"="+e})}),t};var n=r(1530),i=r(2).Buffer,o=r(26),s=r(205);function a(e){var t,r={},o=e.split("magnet:?")[1];return(o&&o.length>=0?o.split("&"):[]).forEach(function(e){var t=e.split("=");if(2===t.length){var n=t[0],i=t[1];if("dn"===n&&(i=decodeURIComponent(i).replace(/\+/g," ")),"tr"!==n&&"xs"!==n&&"as"!==n&&"ws"!==n||(i=decodeURIComponent(i)),"kt"===n&&(i=decodeURIComponent(i).split("+")),"ix"===n&&(i=Number(i)),r[n])if(Array.isArray(r[n]))r[n].push(i);else{var o=r[n];r[n]=[o,i]}else r[n]=i}}),r.xt&&(Array.isArray(r.xt)?r.xt:[r.xt]).forEach(function(e){if(t=e.match(/^urn:btih:(.{40})/))r.infoHash=t[1].toLowerCase();else if(t=e.match(/^urn:btih:(.{32})/)){var o=n.decode(t[1]);r.infoHash=i.from(o,"binary").toString("hex")}}),r.infoHash&&(r.infoHashBuffer=i.from(r.infoHash,"hex")),r.dn&&(r.name=r.dn),r.kt&&(r.keywords=r.kt),"string"==typeof r.tr?r.announce=[r.tr]:Array.isArray(r.tr)?r.announce=r.tr:r.announce=[],r.urlList=[],("string"==typeof r.as||Array.isArray(r.as))&&(r.urlList=r.urlList.concat(r.as)),("string"==typeof r.ws||Array.isArray(r.ws))&&(r.urlList=r.urlList.concat(r.ws)),s(r.announce),s(r.urlList),r}},function(e,t,r){var n=r(1531);t.encode=n.encode,t.decode=n.decode},function(e,t,r){"use strict";(function(e){var r=[255,255,26,27,28,29,30,31,255,255,255,255,255,255,255,255,255,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,255,255,255,255,255,255,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,255,255,255,255,255];t.encode=function(t){e.isBuffer(t)||(t=new e(t));for(var r=0,n=0,i=0,o=0,s=new e(8*function(e){var t=Math.floor(e.length/5);return e.length%5==0?t:t+1}(t));r3?(o=(o=a&255>>i)<<(i=(i+5)%8)|(r+1>8-i,r++):(o=a>>8-(i+5)&31,0==(i=(i+5)%8)&&r++),s[n]="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".charCodeAt(o),n++}for(r=n;r>>(i=(i+5)%8),a[s]=n,s++,n=255&o<<8-i)}return a.slice(0,s)}}).call(this,r(0).Buffer)},function(e,t){e.exports=function e(t,r,n){return void 0===r?function(r,n){return e(t,r,n)}:(void 0===n&&(n="0"),(t-=r.toString().length)>0?new Array(t+(/\./.test(r)?2:1)).join(n)+r:r+"")}},function(e,t){},function(e,t,r){(function(t,n){e.exports=F;var i,o=r(1535),s=r(206),a=r(1536),u=r(1)("webtorrent:torrent"),c=r(1537),f=r(11).EventEmitter,l=r(26),h=r(623),p=r(95),d=r(1547),y=r(624),g=r(1549),m=r(5),b=r(616),v=r(1550),_=r(1551),w=r(147),S=r(1552),k=r(617),E=r(64),A=r(1553),x=r(542),I=r(1554),T=r(148),B=r(329),C=r(205),P=r(1555),O=r(1556),R=r(1557),N=r(1578),L=r(1580),K=r(1581),j=5e3,M=3*A.BLOCK_LENGTH,D=[1e3,5e3,15e3],U="WebTorrent/"+r(331).version+" (https://webtorrent.io)";try{i=E.join(p.statSync("/tmp")&&"/tmp","webtorrent")}catch(e){i=E.join("function"==typeof _.tmpdir?_.tmpdir():"/","webtorrent")}function F(e,t,r){f.call(this),this._debugId="unknown infohash",this.client=t,this.announce=r.announce,this.urlList=r.urlList,this.path=r.path,this._store=r.store||d,this._getAnnounceOpts=r.getAnnounceOpts,this.strategy=r.strategy||"sequential",this.maxWebConns=r.maxWebConns||4,this._rechokeNumSlots=!1===r.uploads||0===r.uploads?0:+r.uploads||10,this._rechokeOptimisticWire=null,this._rechokeOptimisticTime=0,this._rechokeIntervalId=null,this.ready=!1,this.destroyed=!1,this.paused=!1,this.done=!1,this.metadata=null,this.store=null,this.files=[],this.pieces=[],this._amInterested=!1,this._selections=[],this._critical=[],this.wires=[],this._queue=[],this._peers={},this._peersLength=0,this.received=0,this.uploaded=0,this._downloadSpeed=B(),this._uploadSpeed=B(),this._servers=[],this._xsRequests=[],this._fileModtimes=r.fileModtimes,null!==e&&this._onTorrentId(e),this._debug("new torrent")}function q(e,t){return 2+Math.ceil(t*e.downloadSpeed()/A.BLOCK_LENGTH)}function H(){}m(F,f),Object.defineProperty(F.prototype,"timeRemaining",{get:function(){return this.done?0:0===this.downloadSpeed?1/0:(this.length-this.downloaded)/this.downloadSpeed*1e3}}),Object.defineProperty(F.prototype,"downloaded",{get:function(){if(!this.bitfield)return 0;for(var e=0,t=0,r=this.pieces.length;t65536)return n._debug("ignoring invalid PORT from peer");n._debug("port: %s (from %s)",t,r),n.client.dht.addNode({host:e.remoteAddress,port:t})}}),e.on("timeout",function(){n._debug("wire timeout (%s)",r),e.destroy()}),e.setTimeout(3e4,!0),e.setKeepAlive(!0),e.use(P(n.metadata)),e.ut_metadata.on("warning",function(e){n._debug("ut_metadata warning: %s",e.message)}),n.metadata||(e.ut_metadata.on("metadata",function(e){n._debug("got metadata via ut_metadata"),n._onMetadata(e)}),e.ut_metadata.fetch()),"function"!=typeof O||n.private||(e.use(O()),e.ut_pex.on("peer",function(e){n.done||(n._debug("ut_pex: got peer: %s (from %s)",e,r),n.addPeer(e))}),e.ut_pex.on("dropped",function(e){var t=n._peers[e];t&&!t.connected&&(n._debug("ut_pex: dropped peer: %s (from %s)",e,r),n.removePeer(e))}),e.once("close",function(){e.ut_pex.reset()})),n.emit("wire",e,r),n.metadata&&t.nextTick(function(){n._onWireWithMetadata(e)})},F.prototype._onWireWithMetadata=function(e){var t,r=this,n=null;function i(){r.destroyed||e.destroyed||(r._numQueued>2*(r._numConns-r.numPeers)&&e.amInterested?e.destroy():(n=setTimeout(i,j)).unref&&n.unref())}function o(){if(e.peerPieces.buffer.length===r.bitfield.buffer.length){for(t=0;t131072)return e.destroy();r.pieces[t]||r.store.get(t,{offset:n,length:i},o)}),e.bitfield(r.bitfield),e.interested(),e.peerExtensions.dht&&r.client.dht&&r.client.dht.listening&&e.port(r.client.dht.address().port),"webSeed"!==e.type&&(n=setTimeout(i,j)).unref&&n.unref(),e.isSeeder=!1,o()},F.prototype._updateSelections=function(){var e=this;e.ready&&!e.destroyed&&(t.nextTick(function(){e._gcSelections()}),e._updateInterest(),e._update())},F.prototype._gcSelections=function(){for(var e=0;e=o.from+o.offset;--n)if(e.peerPieces.get(n)&&t._request(e,n,!1))return}}();var r=q(e,.5);if(!(e.requests.length>=r)){var n=q(e,1);s(!1)||s(!0)}}function i(t,r,n,i){return function(o){return o>=t&&o<=r&&!(o in n)&&e.peerPieces.get(o)&&(!i||i(o))}}function o(e){for(var r=e,n=e;n=n)return!0;for(var s=function(){var r=e.downloadSpeed()||1;if(r>M)return function(){return!0};var n=Math.max(1,e.requests.length)*A.BLOCK_LENGTH/r,i=10,o=0;return function(e){if(!i||t.bitfield.get(e))return!0;for(var s=t.pieces[e].missing;o0))return i--,!1}return!0}}(),a=0;a0?e._rechokeOptimisticTime-=1:e._rechokeOptimisticWire=null;var t=[];e.wires.forEach(function(r){r.isSeeder||r===e._rechokeOptimisticWire||t.push({wire:r,downloadSpeed:r.downloadSpeed(),uploadSpeed:r.uploadSpeed(),salt:Math.random(),isChoked:!0})}),t.sort(function(e,t){return e.downloadSpeed!==t.downloadSpeed?t.downloadSpeed-e.downloadSpeed:e.uploadSpeed!==t.uploadSpeed?t.uploadSpeed-e.uploadSpeed:e.wire.amChoking!==t.wire.amChoking?e.wire.amChoking?1:-1:e.salt-t.salt});for(var r=0,n=0;n=M||2*u>r||u>s||(i=a,s=u)}}if(!i)return!1;for(o=0;o=(s?Math.min(function(e,t,r){return 1+Math.ceil(t*e.downloadSpeed()/r)}(e,1,i.pieceLength),i.maxWebConns):q(e,1)))return!1;var a=i.pieces[r],u=s?a.reserveRemaining():a.reserve();if(-1===u&&n&&i._hotswap(e,r)&&(u=s?a.reserveRemaining():a.reserve()),-1===u)return!1;var c=i._reservations[r];c||(c=i._reservations[r]=[]);var f=c.indexOf(null);-1===f&&(f=c.length),c[f]=e;var l=a.chunkOffset(u),h=s?a.chunkLengthRemaining(u):a.chunkLength(u);function p(){t.nextTick(function(){i._update()})}return e.request(r,l,h,function t(n,o){if(!i.destroyed){if(!i.ready)return i.once("ready",function(){t(n,o)});if(c[f]===e&&(c[f]=null),a!==i.pieces[r])return p();if(n)return i._debug("error getting piece %s (offset: %s length: %s) from %s: %s",r,l,h,e.remoteAddress+":"+e.remotePort,n.message),s?a.cancelRemaining(u):a.cancel(u),void p();if(i._debug("got piece %s (offset: %s length: %s) from %s",r,l,h,e.remoteAddress+":"+e.remotePort),!a.set(u,o,e))return p();var d=a.flush();T(d,function(e){if(!i.destroyed){if(e===i._hashes[r]){if(!i.pieces[r])return;i._debug("piece verified %s",r),i.pieces[r]=null,i._reservations[r]=null,i.bitfield.set(r,!0),i.store.put(r,d),i.wires.forEach(function(e){e.have(r)}),i._checkDone()&&!i.destroyed&&i.discovery.complete()}else i.pieces[r]=new A(a.length),i.emit("warning",new Error("Piece "+r+" failed verification"));p()}})}}),!0},F.prototype._checkDone=function(){var e=this;if(!e.destroyed){e.files.forEach(function(t){if(!t.done){for(var r=t._startPiece;r<=t._endPiece;++r)if(!e.bitfield.get(r))return;t.done=!0,t.emit("done"),e._debug("file done: "+t.name)}});for(var t=!0,r=0;r=e.client.maxConns)){this._debug("drain (%s queued, %s/%s peers)",e._numQueued,e.numPeers,e.client.maxConns);var t=e._queue.shift();if(t){this._debug("tcp connect attempt to %s",t.addr);var r=o(t.addr),n={host:r[0],port:r[1]},i=t.conn=v.connect(n);i.once("connect",function(){t.onConnect()}),i.once("error",function(e){t.destroy(e)}),t.startConnectTimeout(),i.on("close",function(){if(!e.destroyed)if(t.retries>=D.length)e._debug("conn %s closed: will not re-add (max %s attempts)",t.addr,D.length);else{var r=D[t.retries];e._debug("conn %s closed: will re-add to queue in %sms (attempt %s)",t.addr,r,t.retries+1);var n=setTimeout(function(){var r=e._addPeer(t.addr);r&&(r.retries=t.retries+1)},r);n.unref&&n.unref()}})}}},F.prototype._validAddr=function(e){var t;try{t=o(e)}catch(e){return!1}var r=t[0],n=t[1];return n>0&&n<65535&&!("127.0.0.1"===r&&n===this.client.torrentPort)}}).call(this,r(7),r(6))},function(e,t){var r=/^\[?([^\]]+)\]?:(\d+)$/,n={},i=0;e.exports=function(t){if(1e5===i&&e.exports.reset(),!n[t]){var o=r.exec(t);if(!o)throw new Error("invalid addr: "+t);n[t]=[o[1],Number(o[2])],i+=1}return n[t]},e.exports.reset=function(){n={},i=0}},function(e,t,r){e.exports=s;var n=r(615),i=r(5),o=r(22);function s(e,t,r){var i=this;if(!(i instanceof s))return new s(e,t,r);if(o.Writable.call(i,r),r||(r={}),!e||!e.put||!e.get)throw new Error("First argument must be an abstract-chunk-store compliant store");if(!(t=Number(t)))throw new Error("Second argument must be a chunk length");i._blockstream=new n(t,{zeroPadding:!1}),i._blockstream.on("data",function(t){i.destroyed||(e.put(a,t),a+=1)}).on("error",function(e){i.destroy(e)});var a=0;i.on("finish",function(){this._blockstream.end()})}i(s,o.Writable),s.prototype._write=function(e,t,r){this._blockstream.write(e,t,r)},s.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e),this.emit("close"))}},function(e,t,r){(function(t){e.exports=f;var n=r(1)("torrent-discovery"),i=r(1538),o=r(11).EventEmitter,s=r(26),a=r(5),u=r(147),c=r(1539);function f(e){var r=this;if(!(r instanceof f))return new f(e);if(o.call(r),!e.peerId)throw new Error("Option `peerId` is required");if(!e.infoHash)throw new Error("Option `infoHash` is required");if(!t.browser&&!e.port)throw new Error("Option `port` is required");function n(e,t){var n=new i(t);return n.on("warning",r._onWarning),n.on("error",r._onError),n.listen(e),r._internalDHT=!0,n}r.peerId="string"==typeof e.peerId?e.peerId:e.peerId.toString("hex"),r.infoHash="string"==typeof e.infoHash?e.infoHash.toLowerCase():e.infoHash.toString("hex"),r._port=e.port,r._userAgent=e.userAgent,r.destroyed=!1,r._announce=e.announce||[],r._intervalMs=e.intervalMs||9e5,r._trackerOpts=null,r._dhtAnnouncing=!1,r._dhtTimeout=!1,r._internalDHT=!1,r._onWarning=function(e){r.emit("warning",e)},r._onError=function(e){r.emit("error",e)},r._onDHTPeer=function(e,t){t.toString("hex")===r.infoHash&&r.emit("peer",e.host+":"+e.port,"dht")},r._onTrackerPeer=function(e){r.emit("peer",e,"tracker")},r._onTrackerAnnounce=function(){r.emit("trackerAnnounce")},!1===e.tracker?r.tracker=null:e.tracker&&"object"==typeof e.tracker?(r._trackerOpts=s(e.tracker),r.tracker=r._createTracker()):r.tracker=r._createTracker(),!1===e.dht||"function"!=typeof i?r.dht=null:e.dht&&"function"==typeof e.dht.addNode?r.dht=e.dht:e.dht&&"object"==typeof e.dht?r.dht=n(e.dhtPort,e.dht):r.dht=n(e.dhtPort),r.dht&&(r.dht.on("peer",r._onDHTPeer),r._dhtAnnounce())}a(f,o),f.prototype.updatePort=function(e){var t=this;e!==t._port&&(t._port=e,t.dht&&t._dhtAnnounce(),t.tracker&&(t.tracker.stop(),t.tracker.destroy(function(){t.tracker=t._createTracker()})))},f.prototype.complete=function(e){this.tracker&&this.tracker.complete(e)},f.prototype.destroy=function(e){var t=this;if(!t.destroyed){t.destroyed=!0,clearTimeout(t._dhtTimeout);var r=[];t.tracker&&(t.tracker.stop(),t.tracker.removeListener("warning",t._onWarning),t.tracker.removeListener("error",t._onError),t.tracker.removeListener("peer",t._onTrackerPeer),t.tracker.removeListener("update",t._onTrackerAnnounce),r.push(function(e){t.tracker.destroy(e)})),t.dht&&t.dht.removeListener("peer",t._onDHTPeer),t._internalDHT&&(t.dht.removeListener("warning",t._onWarning),t.dht.removeListener("error",t._onError),r.push(function(e){t.dht.destroy(e)})),u(r,e),t.dht=null,t.tracker=null,t._announce=null}},f.prototype._createTracker=function(){var e=s(this._trackerOpts,{infoHash:this.infoHash,announce:this._announce,peerId:this.peerId,port:this._port,userAgent:this._userAgent}),t=new c(e);return t.on("warning",this._onWarning),t.on("error",this._onError),t.on("peer",this._onTrackerPeer),t.on("update",this._onTrackerAnnounce),t.setInterval(this._intervalMs),t.start(),t},f.prototype._dhtAnnounce=function(){var e=this;e._dhtAnnouncing||(n("dht announce"),e._dhtAnnouncing=!0,clearTimeout(e._dhtTimeout),e.dht.announce(e.infoHash,e._port,function(t){e._dhtAnnouncing=!1,n("dht announce complete"),t&&e.emit("warning",t),e.emit("dhtAnnounce"),e.destroyed||(e._dhtTimeout=setTimeout(function(){e._dhtAnnounce()},e._intervalMs+Math.floor(Math.random()*e._intervalMs/5)),e._dhtTimeout.unref&&e._dhtTimeout.unref())}))}}).call(this,r(7))},function(e,t){},function(e,t,r){(function(t){e.exports=m;var n=r(2).Buffer,i=r(1)("bittorrent-tracker:client"),o=r(11).EventEmitter,s=r(26),a=r(5),u=r(30),c=r(147),f=r(191),l=r(205),h=r(33),p=r(622),d=r(1541),y=r(1542),g=r(1543);function m(e){var r=this;if(!(r instanceof m))return new m(e);if(o.call(r),e||(e={}),!e.peerId)throw new Error("Option `peerId` is required");if(!e.infoHash)throw new Error("Option `infoHash` is required");if(!e.announce)throw new Error("Option `announce` is required");if(!t.browser&&!e.port)throw new Error("Option `port` is required");r.peerId="string"==typeof e.peerId?e.peerId:e.peerId.toString("hex"),r._peerIdBuffer=n.from(r.peerId,"hex"),r._peerIdBinary=r._peerIdBuffer.toString("binary"),r.infoHash="string"==typeof e.infoHash?e.infoHash.toLowerCase():e.infoHash.toString("hex"),r._infoHashBuffer=n.from(r.infoHash,"hex"),r._infoHashBinary=r._infoHashBuffer.toString("binary"),i("new client %s",r.infoHash),r.destroyed=!1,r._port=e.port,r._getAnnounceOpts=e.getAnnounceOpts,r._rtcConfig=e.rtcConfig,r._userAgent=e.userAgent,r._wrtc="function"==typeof e.wrtc?e.wrtc():e.wrtc;var s="string"==typeof e.announce?[e.announce]:null==e.announce?[]:e.announce;s=s.map(function(e){return"/"===(e=e.toString())[e.length-1]&&(e=e.substring(0,e.length-1)),e}),s=l(s);var a=!1!==r._wrtc&&(!!r._wrtc||f.WEBRTC_SUPPORT);function u(e){t.nextTick(function(){r.emit("warning",e)})}r._trackers=s.map(function(e){var t=h.parse(e).protocol;return"http:"!==t&&"https:"!==t||"function"!=typeof d?"udp:"===t&&"function"==typeof y?new y(r,e):"ws:"!==t&&"wss:"!==t||!a?(u(new Error("Unsupported tracker protocol: "+e)),null):"ws:"===t&&"undefined"!=typeof window&&"https:"===window.location.protocol?(u(new Error("Unsupported tracker protocol: "+e)),null):new g(r,e):new d(r,e)}).filter(Boolean)}a(m,o),m.scrape=function(e,t){if(t=u(t),!e.infoHash)throw new Error("Option `infoHash` is required");if(!e.announce)throw new Error("Option `announce` is required");var r=new m(s(e,{infoHash:Array.isArray(e.infoHash)?e.infoHash[0]:e.infoHash,peerId:n.from("01234567890123456789"),port:6881}));r.once("error",t),r.once("warning",t);var i=Array.isArray(e.infoHash)?e.infoHash.length:1,o={};return r.on("scrape",function(e){if(i-=1,o[e.infoHash]=e,0===i){r.destroy();var n=Object.keys(o);1===n.length?t(null,o[n[0]]):t(null,o)}}),e.infoHash=Array.isArray(e.infoHash)?e.infoHash.map(function(e){return n.from(e,"hex")}):n.from(e.infoHash,"hex"),r.scrape({infoHash:e.infoHash}),r},m.prototype.start=function(e){i("send `start`"),(e=this._defaultAnnounceOpts(e)).event="started",this._announce(e),this._trackers.forEach(function(e){e.setInterval()})},m.prototype.stop=function(e){i("send `stop`"),(e=this._defaultAnnounceOpts(e)).event="stopped",this._announce(e)},m.prototype.complete=function(e){i("send `complete`"),e||(e={}),(e=this._defaultAnnounceOpts(e)).event="completed",this._announce(e)},m.prototype.update=function(e){i("send `update`"),(e=this._defaultAnnounceOpts(e)).event&&delete e.event,this._announce(e)},m.prototype._announce=function(e){this._trackers.forEach(function(t){t.announce(e)})},m.prototype.scrape=function(e){i("send `scrape`"),e||(e={}),this._trackers.forEach(function(t){t.scrape(e)})},m.prototype.setInterval=function(e){i("setInterval %d",e),this._trackers.forEach(function(t){t.setInterval(e)})},m.prototype.destroy=function(e){if(!this.destroyed){this.destroyed=!0,i("destroy");var t=this._trackers.map(function(e){return function(t){e.destroy(t)}});c(t,e),this._trackers=[],this._getAnnounceOpts=null}},m.prototype._defaultAnnounceOpts=function(e){return e||(e={}),null==e.numwant&&(e.numwant=p.DEFAULT_ANNOUNCE_PEERS),null==e.uploaded&&(e.uploaded=0),null==e.downloaded&&(e.downloaded=0),this._getAnnounceOpts&&(e=s(e,this._getAnnounceOpts())),e}}).call(this,r(7))},function(e,t){},function(e,t){},function(e,t){},function(e,t,r){e.exports=p;var n=r(1)("bittorrent-tracker:websocket-tracker"),i=r(26),o=r(5),s=r(191),a=r(107),u=r(1544),c=r(622),f=r(1546),l={},h=5e4;function p(e,t,r){f.call(this,e,t),n("new websocket tracker %s",t),this.peers={},this.socket=null,this.reconnecting=!1,this.retries=0,this.reconnectTimer=null,this.expectingResponse=!1,this._openSocket()}function d(){}o(p,f),p.prototype.DEFAULT_ANNOUNCE_INTERVAL=3e4,p.prototype.announce=function(e){var t=this;if(!t.destroyed&&!t.reconnecting)if(t.socket.connected){var r=i(e,{action:"announce",info_hash:t.client._infoHashBinary,peer_id:t.client._peerIdBinary});if(t._trackerId&&(r.trackerid=t._trackerId),"stopped"===e.event||"completed"===e.event)t._send(r);else{var n=Math.min(e.numwant,10);t._generateOffers(n,function(e){r.numwant=n,r.offers=e,t._send(r)})}}else t.socket.once("connect",function(){t.announce(e)})},p.prototype.scrape=function(e){var t=this;if(!t.destroyed&&!t.reconnecting)if(t.socket.connected){var r={action:"scrape",info_hash:Array.isArray(e.infoHash)&&e.infoHash.length>0?e.infoHash.map(function(e){return e.toString("binary")}):e.infoHash&&e.infoHash.toString("binary")||t.client._infoHashBinary};t._send(r)}else t.socket.once("connect",function(){t.scrape(e)})},p.prototype.destroy=function(e){if(e||(e=d),this.destroyed)return e(null);for(var t in this.destroyed=!0,clearInterval(this.interval),clearTimeout(this.reconnectTimer),this.peers){var r=this.peers[t];clearTimeout(r.trackerTimeout),r.destroy()}if(this.peers=null,this.socket&&(this.socket.removeListener("connect",this._onSocketConnectBound),this.socket.removeListener("data",this._onSocketDataBound),this.socket.removeListener("close",this._onSocketCloseBound),this.socket.removeListener("error",this._onSocketErrorBound),this.socket=null),this._onSocketConnectBound=null,this._onSocketErrorBound=null,this._onSocketDataBound=null,this._onSocketCloseBound=null,l[this.announceUrl]&&(l[this.announceUrl].consumers-=1),l[this.announceUrl].consumers>0)return e();var n=l[this.announceUrl];if(delete l[this.announceUrl],n.on("error",d),n.once("close",e),!this.expectingResponse)return o();var i=setTimeout(o,c.DESTROY_TIMEOUT);function o(){i&&(clearTimeout(i),i=null),n.removeListener("data",o),n.destroy(),n=null}n.once("data",o)},p.prototype._openSocket=function(){var e=this;e.destroyed=!1,e.peers||(e.peers={}),e._onSocketConnectBound=function(){e._onSocketConnect()},e._onSocketErrorBound=function(t){e._onSocketError(t)},e._onSocketDataBound=function(t){e._onSocketData(t)},e._onSocketCloseBound=function(){e._onSocketClose()},e.socket=l[e.announceUrl],e.socket?l[e.announceUrl].consumers+=1:(e.socket=l[e.announceUrl]=new u(e.announceUrl),e.socket.consumers=1,e.socket.once("connect",e._onSocketConnectBound)),e.socket.on("data",e._onSocketDataBound),e.socket.once("close",e._onSocketCloseBound),e.socket.once("error",e._onSocketErrorBound)},p.prototype._onSocketConnect=function(){this.destroyed||this.reconnecting&&(this.reconnecting=!1,this.retries=0,this.announce(this.client._defaultAnnounceOpts()))},p.prototype._onSocketData=function(e){if(!this.destroyed){this.expectingResponse=!1;try{e=JSON.parse(e)}catch(e){return void this.client.emit("warning",new Error("Invalid tracker response"))}"announce"===e.action?this._onAnnounceResponse(e):"scrape"===e.action?this._onScrapeResponse(e):this._onSocketError(new Error("invalid action in WS response: "+e.action))}},p.prototype._onAnnounceResponse=function(e){var t=this;if(e.info_hash===t.client._infoHashBinary){if(!e.peer_id||e.peer_id!==t.client._peerIdBinary){n("received %s from %s for %s",JSON.stringify(e),t.announceUrl,t.client.infoHash);var r=e["failure reason"];if(r)return t.client.emit("warning",new Error(r));var i=e["warning message"];i&&t.client.emit("warning",new Error(i));var o=e.interval||e["min interval"];o&&t.setInterval(1e3*o);var s,a=e["tracker id"];if(a&&(t._trackerId=a),null!=e.complete){var u=Object.assign({},e,{announce:t.announceUrl,infoHash:c.binaryToHex(e.info_hash)});t.client.emit("update",u)}if(e.offer&&e.peer_id&&(n("creating peer (from remote offer)"),(s=t._createPeer()).id=c.binaryToHex(e.peer_id),s.once("signal",function(r){var n={action:"announce",info_hash:t.client._infoHashBinary,peer_id:t.client._peerIdBinary,to_peer_id:e.peer_id,answer:r,offer_id:e.offer_id};t._trackerId&&(n.trackerid=t._trackerId),t._send(n)}),s.signal(e.offer),t.client.emit("peer",s)),e.answer&&e.peer_id){var f=c.binaryToHex(e.offer_id);(s=t.peers[f])?(s.id=c.binaryToHex(e.peer_id),s.signal(e.answer),t.client.emit("peer",s),clearTimeout(s.trackerTimeout),s.trackerTimeout=null,delete t.peers[f]):n("got unexpected answer: "+JSON.stringify(e.answer))}}}else n("ignoring websocket data from %s for %s (looking for %s: reused socket)",t.announceUrl,c.binaryToHex(e.info_hash),t.client.infoHash)},p.prototype._onScrapeResponse=function(e){var t=this;e=e.files||{};var r=Object.keys(e);0!==r.length?r.forEach(function(r){var n=Object.assign(e[r],{announce:t.announceUrl,infoHash:c.binaryToHex(r)});t.client.emit("scrape",n)}):t.client.emit("warning",new Error("invalid scrape response"))},p.prototype._onSocketClose=function(){this.destroyed||(this.destroy(),this._startReconnectTimer())},p.prototype._onSocketError=function(e){this.destroyed||(this.destroy(),this.client.emit("warning",e),this._startReconnectTimer())},p.prototype._startReconnectTimer=function(){var e=this,t=Math.floor(3e4*Math.random())+Math.min(15e3*Math.pow(2,e.retries),18e5);e.reconnecting=!0,clearTimeout(e.reconnectTimer),e.reconnectTimer=setTimeout(function(){e.retries++,e._openSocket()},t),e.reconnectTimer.unref&&e.reconnectTimer.unref(),n("reconnecting socket in %s ms",t)},p.prototype._send=function(e){if(!this.destroyed){this.expectingResponse=!0;var t=JSON.stringify(e);n("send %s",t),this.socket.send(t)}},p.prototype._generateOffers=function(e,t){var r=this,i=[];n("generating %s offers",e);for(var o=0;o65536?(this._debug("start backpressure: bufferedAmount %d",this._ws.bufferedAmount),this._cb=r):r(null)}else this._debug("write before connect"),this._chunk=e,this._cb=r},f.prototype._onFinish=function(){var e=this;function t(){setTimeout(function(){e.destroy()},1e3)}e.destroyed||(e.connected?t():e.once("connect",t))},f.prototype._onMessage=function(e){if(!this.destroyed){var t=e.data;t instanceof ArrayBuffer&&(t=n.from(t)),this.push(t)}},f.prototype._onOpen=function(){var e=this;if(!e.connected&&!e.destroyed){if(e.connected=!0,e._chunk){try{e.send(e._chunk)}catch(t){return e.destroy(t)}e._chunk=null,e._debug('sent chunk from "write before connect"');var t=e._cb;e._cb=null,t(null)}"function"!=typeof u&&(e._interval=setInterval(function(){e._onInterval()},150),e._interval.unref&&e._interval.unref()),e._debug("connect"),e.emit("connect")}},f.prototype._onInterval=function(){if(this._cb&&this._ws&&!(this._ws.bufferedAmount>65536)){this._debug("ending backpressure: bufferedAmount %d",this._ws.bufferedAmount);var e=this._cb;this._cb=null,e(null)}},f.prototype._onClose=function(){this.destroyed||(this._debug("on close"),this.destroy())},f.prototype._debug=function(){var e=[].slice.call(arguments);e[0]="["+this._id+"] "+e[0],i.apply(null,e)}}).call(this,r(7))},function(e,t){},function(e,t,r){e.exports=i;var n=r(11).EventEmitter;function i(e,t){n.call(this),this.client=e,this.announceUrl=t,this.interval=null,this.destroyed=!1}r(5)(i,n),i.prototype.setInterval=function(e){var t=this;null==e&&(e=t.DEFAULT_ANNOUNCE_INTERVAL),clearInterval(t.interval),e&&(t.interval=setInterval(function(){t.announce(t.client._defaultAnnounceOpts())},e),t.interval.unref&&t.interval.unref())}},function(e,t,r){(function(t){function r(e,t){if(!(this instanceof r))return new r(e,t);if(t||(t={}),this.chunkLength=Number(e),!this.chunkLength)throw new Error("First argument must be a chunk length");this.chunks=[],this.closed=!1,this.length=Number(t.length)||1/0,this.length!==1/0&&(this.lastChunkLength=this.length%this.chunkLength||this.chunkLength,this.lastChunkIndex=Math.ceil(this.length/this.chunkLength)-1)}function n(e,r,n){t.nextTick(function(){e&&e(r,n)})}e.exports=r,r.prototype.put=function(e,t,r){if(this.closed)return n(r,new Error("Storage is closed"));var i=e===this.lastChunkIndex;return i&&t.length!==this.lastChunkLength?n(r,new Error("Last chunk length must be "+this.lastChunkLength)):i||t.length===this.chunkLength?(this.chunks[e]=t,void n(r,null)):n(r,new Error("Chunk length must be "+this.chunkLength))},r.prototype.get=function(e,t,r){if("function"==typeof t)return this.get(e,null,t);if(this.closed)return n(r,new Error("Storage is closed"));var i=this.chunks[e];if(!i){var o=new Error("Chunk not found");return o.notFound=!0,n(r,o)}if(!t)return n(r,null,i);var s=t.offset||0,a=t.length||i.length-s;n(r,null,i.slice(s,a+s))},r.prototype.close=r.prototype.destroy=function(e){if(this.closed)return n(e,new Error("Storage is closed"));this.closed=!0,this.chunks=null,n(e,null)}}).call(this,r(7))},function(e,t){},function(e,t,r){(function(t){function r(e){if(!(this instanceof r))return new r(e);if(this.store=e,this.chunkLength=e.chunkLength,!this.store||!this.store.get||!this.store.put)throw new Error("First argument must be abstract-chunk-store compliant");this.mem=[]}function n(e,r,n){t.nextTick(function(){e&&e(r,n)})}e.exports=r,r.prototype.put=function(e,t,r){var n=this;n.mem[e]=t,n.store.put(e,t,function(t){n.mem[e]=null,r&&r(t)})},r.prototype.get=function(e,t,r){if("function"==typeof t)return this.get(e,null,t);var i=t&&t.offset||0,o=t&&t.length&&i+t.length,s=this.mem[e];if(s)return n(r,null,t?s.slice(i,o):s);this.store.get(e,t,r)},r.prototype.close=function(e){this.store.close(e)},r.prototype.destroy=function(e){this.store.destroy(e)}}).call(this,r(7))},function(e,t){},function(e,t){},function(e,t,r){(function(t){e.exports=function(e,r,n){if("number"!=typeof r)throw new Error("second argument must be a Number");var i,o,s,a,u,c=!0;function f(e){function r(){n&&n(e,i),n=null}c?t.nextTick(r):r()}function l(t,r,n){if(i[t]=n,r&&(u=!0),0==--s||r)f(r);else if(!u&&hthis._metadataSize&&(r=this._metadataSize);var n=this.metadata.slice(t,r);this._data(e,n,this._metadataSize)}else this._reject(e)},t.prototype._onData=function(e,t,r){t.length>16384||(t.copy(this.metadata,16384*e),this._bitfield.set(e),this._checkDone())},t.prototype._onReject=function(e){this._remainingRejects>0&&this._fetching?(this._request(e),this._remainingRejects-=1):this.emit("warning",new Error('Peer sent "reject" too much'))},t.prototype._requestPieces=function(){this.metadata=o.alloc(this._metadataSize);for(var e=0;e0?this._requestPieces():this.emit("warning",new Error("Peer sent invalid metadata"))},t}},function(e,t){},function(e,t,r){(function(t){e.exports=p;var n=r(193),i=r(11).EventEmitter,o=r(1558),s=r(5),a=r(64),u=r(1559),c=r(22),f=r(627),l=r(626),h=r(1577);function p(e,t){i.call(this),this._torrent=e,this._destroyed=!1,this.name=t.name,this.path=t.path,this.length=t.length,this.offset=t.offset,this.done=!1;var r=t.offset,n=r+t.length-1;this._startPiece=r/this._torrent.pieceLength|0,this._endPiece=n/this._torrent.pieceLength|0,0===this.length&&(this.done=!0,this.emit("done"))}s(p,i),Object.defineProperty(p.prototype,"downloaded",{get:function(){if(!this._torrent.bitfield)return 0;for(var e=0,t=this._startPiece;t<=this._endPiece;++t)if(this._torrent.bitfield.get(t))e+=t===this._endPiece?this._torrent.lastPieceLength:this._torrent.pieceLength;else{var r=this._torrent.pieces[t];e+=r.length-r.missing}return e}}),Object.defineProperty(p.prototype,"progress",{get:function(){return this.length?this.downloaded/this.length:0}}),p.prototype.select=function(e){0!==this.length&&this._torrent.select(this._startPiece,this._endPiece,e)},p.prototype.deselect=function(){0!==this.length&&this._torrent.deselect(this._startPiece,this._endPiece,!1)},p.prototype.createReadStream=function(e){var r=this;if(0===this.length){var i=new c.PassThrough;return t.nextTick(function(){i.end()}),i}var s=new o(r,e);return r._torrent.select(s._startPiece,s._endPiece,!0,function(){s._notify()}),n(s,function(){r._destroyed||r._torrent.destroyed||r._torrent.deselect(s._startPiece,s._endPiece,!0)}),s},p.prototype.getBuffer=function(e){h(this.createReadStream(),this.length,e)},p.prototype.getBlob=function(e){if("undefined"==typeof window)throw new Error("browser-only method");f(this.createReadStream(),this._getMimeType(),e)},p.prototype.getBlobURL=function(e){if("undefined"==typeof window)throw new Error("browser-only method");l(this.createReadStream(),this._getMimeType(),e)},p.prototype.appendTo=function(e,t,r){if("undefined"==typeof window)throw new Error("browser-only method");u.append(this,e,t,r)},p.prototype.renderTo=function(e,t,r){if("undefined"==typeof window)throw new Error("browser-only method");u.render(this,e,t,r)},p.prototype._getMimeType=function(){return u.mime[a.extname(this.name).toLowerCase()]},p.prototype._destroy=function(){this._destroyed=!0,this._torrent=null}}).call(this,r(7))},function(e,t,r){e.exports=s;var n=r(1)("webtorrent:file-stream"),i=r(5),o=r(22);function s(e,t){o.Readable.call(this,t),this.destroyed=!1,this._torrent=e._torrent;var r=t&&t.start||0,n=t&&t.end&&t.end=0?function(){var i=f.indexOf(m)>=0?"video":"audio";function s(){n("Use MediaSource API for "+e.name),p(),y.addEventListener("error",h),y.addEventListener("loadstart",w),y.addEventListener("canplay",S);var t=new o(y).createWriteStream(_(e.name));e.createReadStream().pipe(t),v&&(y.currentTime=v)}function a(){n("Use Blob URL for "+e.name),p(),y.addEventListener("error",E),y.addEventListener("loadstart",w),y.addEventListener("canplay",S),b(e,function(e,t){if(e)return E(e);y.src=t,v&&(y.currentTime=v)})}function l(e){n("videostream error: fallback to MediaSource API: %o",e.message||e),y.removeEventListener("error",l),y.removeEventListener("canplay",S),s()}function h(t){if(n("MediaSource API error: fallback to Blob URL: %o",t.message||t),"number"==typeof e.length&&e.length>r.maxBlobLength)return n("File length too large for Blob URL approach: %d (max: %d)",e.length,r.maxBlobLength),E(new Error("File length too large for Blob URL approach: "+e.length+" (max: "+r.maxBlobLength+")"));y.removeEventListener("error",h),y.removeEventListener("canplay",S),a()}function p(){y||(y=t(i)).addEventListener("progress",function(){v=y.currentTime})}g?c.indexOf(m)>=0?(n("Use `videostream` package for "+e.name),p(),y.addEventListener("error",l),y.addEventListener("loadstart",w),y.addEventListener("canplay",S),u(e,y)):s():a()}():h.indexOf(m)>=0?(y=t("audio"),b(e,function(e,t){if(e)return E(e);y.addEventListener("error",E),y.addEventListener("loadstart",w),y.addEventListener("canplay",S),y.src=t})):p.indexOf(m)>=0?(y=t("img"),b(e,function(t,r){if(t)return E(t);y.src=r,y.alt=e.name,a(null,y)})):d.indexOf(m)>=0?k():function(){n('Unknown file extension "%s" - will attempt to render into iframe',m);var t="";e.createReadStream({start:0,end:1e3}).setEncoding("utf8").on("data",function(e){t+=e}).on("end",function(){i(t)?(n('File extension "%s" appears ascii, so will render.',m),k()):(n('File extension "%s" appears non-ascii, will not render.',m),a(new Error('Unsupported file type "'+m+'": Cannot append to DOM')))}).on("error",a)}()}function b(e,r){var n=s.extname(e.name).toLowerCase();a(e.createReadStream(),t.mime[n],r)}function v(e){if(null==e)throw new Error("file cannot be null or undefined");if("string"!=typeof e.name)throw new Error("missing or invalid file.name property");if("function"!=typeof e.createReadStream)throw new Error("missing or invalid file.createReadStream property")}function _(e){return{".m4a":'audio/mp4; codecs="mp4a.40.5"',".m4v":'video/mp4; codecs="avc1.640029, mp4a.40.5"',".mkv":'video/webm; codecs="avc1.640029, mp4a.40.5"',".mp3":"audio/mpeg",".mp4":'video/mp4; codecs="avc1.640029, mp4a.40.5"',".webm":'video/webm; codecs="vorbis, vp8"'}[s.extname(e).toLowerCase()]}function w(e){null==e.autoplay&&(e.autoplay=!1),null==e.muted&&(e.muted=!1),null==e.controls&&(e.controls=!0),null==e.maxBlobLength&&(e.maxBlobLength=y)}},function(e){e.exports={".3gp":"video/3gpp",".aac":"audio/aac",".aif":"audio/x-aiff",".aiff":"audio/x-aiff",".atom":"application/atom+xml",".avi":"video/x-msvideo",".bmp":"image/bmp",".bz2":"application/x-bzip2",".conf":"text/plain",".css":"text/css",".csv":"text/plain",".diff":"text/x-diff",".doc":"application/msword",".flv":"video/x-flv",".gif":"image/gif",".gz":"application/x-gzip",".htm":"text/html",".html":"text/html",".ico":"image/vnd.microsoft.icon",".ics":"text/calendar",".iso":"application/octet-stream",".jar":"application/java-archive",".jpeg":"image/jpeg",".jpg":"image/jpeg",".js":"application/javascript",".json":"application/json",".less":"text/css",".log":"text/plain",".m3u":"audio/x-mpegurl",".m4a":"audio/mp4",".m4v":"video/mp4",".manifest":"text/cache-manifest",".markdown":"text/x-markdown",".mathml":"application/mathml+xml",".md":"text/x-markdown",".mid":"audio/midi",".midi":"audio/midi",".mov":"video/quicktime",".mp3":"audio/mpeg",".mp4":"video/mp4",".mp4v":"video/mp4",".mpeg":"video/mpeg",".mpg":"video/mpeg",".odp":"application/vnd.oasis.opendocument.presentation",".ods":"application/vnd.oasis.opendocument.spreadsheet",".odt":"application/vnd.oasis.opendocument.text",".oga":"audio/ogg",".ogg":"application/ogg",".pdf":"application/pdf",".png":"image/png",".pps":"application/vnd.ms-powerpoint",".ppt":"application/vnd.ms-powerpoint",".ps":"application/postscript",".psd":"image/vnd.adobe.photoshop",".qt":"video/quicktime",".rar":"application/x-rar-compressed",".rdf":"application/rdf+xml",".rss":"application/rss+xml",".rtf":"application/rtf",".svg":"image/svg+xml",".svgz":"image/svg+xml",".swf":"application/x-shockwave-flash",".tar":"application/x-tar",".tbz":"application/x-bzip-compressed-tar",".text":"text/plain",".tif":"image/tiff",".tiff":"image/tiff",".torrent":"application/x-bittorrent",".ttf":"application/x-font-ttf",".txt":"text/plain",".wav":"audio/wav",".webm":"video/webm",".wma":"audio/x-ms-wma",".wmv":"video/x-ms-wmv",".xls":"application/vnd.ms-excel",".xml":"application/xml",".yaml":"text/yaml",".yml":"text/yaml",".zip":"application/zip"}},function(e,t){e.exports=function(e){for(var t=0,r=e.length;t127)return!1;return!0}},function(e,t,r){var n=r(625),i=r(1563),o=r(1565);function s(e,t,r){var i=this;if(!(this instanceof s))return new s(e,t,r);r=r||{},i.detailedError=null,i._elem=t,i._elemWrapper=new n(t),i._waitingFired=!1,i._trackMeta=null,i._file=e,i._tracks=null,"none"!==i._elem.preload&&i._createMuxer(),i._onError=function(e){i.detailedError=i._elemWrapper.detailedError,i.destroy()},i._onWaiting=function(){i._waitingFired=!0,i._muxer?i._tracks&&i._pump():i._createMuxer()},i._elem.addEventListener("waiting",i._onWaiting),i._elem.addEventListener("error",i._onError)}e.exports=s,s.prototype._createMuxer=function(){var e=this;e._muxer=new o(e._file),e._muxer.on("ready",function(t){e._tracks=t.map(function(t){var r=e._elemWrapper.createWriteStream(t.mime);r.on("error",function(t){e._elemWrapper.error(t)});var n={muxed:null,mediaSource:r,initFlushed:!1,onInitFlushed:null};return r.write(t.init,function(e){n.initFlushed=!0,n.onInitFlushed&&n.onInitFlushed(e)}),n}),(e._waitingFired||"auto"===e._elem.preload)&&e._pump()}),e._muxer.on("error",function(t){e._elemWrapper.error(t)})},s.prototype._pump=function(){var e=this,t=e._muxer.seek(e._elem.currentTime,!e._tracks);e._tracks.forEach(function(r,n){var o=function(){r.muxed&&(r.muxed.destroy(),r.mediaSource=e._elemWrapper.createWriteStream(r.mediaSource),r.mediaSource.on("error",function(t){e._elemWrapper.error(t)})),r.muxed=t[n],i(r.muxed,r.mediaSource)};r.initFlushed?o():r.onInitFlushed=function(t){t?e._elemWrapper.error(t):o()}})},s.prototype.destroy=function(){this.destroyed||(this.destroyed=!0,this._elem.removeEventListener("waiting",this._onWaiting),this._elem.removeEventListener("error",this._onError),this._tracks&&this._tracks.forEach(function(e){e.muxed&&e.muxed.destroy()}),this._elem.src="")}},function(e,t,r){var n=r(30),i=r(193),o=r(1564),s=function(){},a=function(e){return"function"==typeof e},u=function(e){return!!o&&(e instanceof(o.ReadStream||s)||e instanceof(o.WriteStream||s))&&a(e.close)},c=function(e,t,r,o){o=n(o);var c=!1;e.on("close",function(){c=!0}),i(e,{readable:t,writable:r},function(e){if(e)return o(e);c=!0,o()});var f=!1;return function(t){if(!c&&!f)return f=!0,u(e)?e.close(s):function(e){return e.setHeader&&a(e.abort)}(e)?e.abort():a(e.destroy)?e.destroy():void o(t||new Error("stream was destroyed"))}},f=function(e){e()},l=function(e,t){return e.pipe(t)};e.exports=function(){var e,t=Array.prototype.slice.call(arguments),r=a(t[t.length-1]||s)&&t.pop()||s;if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new Error("pump requires two streams per minimum");var n=t.map(function(i,o){var s=o0,function(t){e||(e=t),t&&n.forEach(f),s||(n.forEach(f),r(e))})});return t.reduce(l)}},function(e,t){},function(e,t,r){(function(t){var n=r(1566),i=r(11).EventEmitter,o=r(5),s=r(1567),a=r(207),u=r(1576);function c(e){i.call(this),this._tracks=[],this._fragmentSequence=1,this._file=e,this._decoder=null,this._findMoov(0)}function f(e,t){this._entries=e,this._countName=t||"count",this._index=0,this._offset=0,this.value=this._entries[0]}e.exports=c,o(c,i),c.prototype._findMoov=function(e){var t=this;t._decoder&&t._decoder.destroy(),t._decoder=s.decode();var r=t._file.createReadStream({start:e});r.pipe(t._decoder),t._decoder.once("box",function(n){"moov"===n.type?t._decoder.decode(function(e){r.destroy();try{t._processMoov(e)}catch(e){e.message="Cannot parse mp4 file: "+e.message,t.emit("error",e)}}):(r.destroy(),t._findMoov(e+n.length))})},f.prototype.inc=function(){this._offset++,this._offset>=this._entries[this._index][this._countName]&&(this._index++,this._offset=0),this.value=this._entries[this._index]},c.prototype._processMoov=function(e){var r=e.traks;this._tracks=[],this._hasVideo=!1,this._hasAudio=!1;for(var n=0;n=u.stsz.entries.length)break;if(g+=k,++d>=S.samplesPerChunk){d=0,g=0,y++;var I=u.stsc.entries[m+1];I&&y+1>=I.firstChunk&&m++}b+=E,v.inc(),_&&_.inc(),x&&w++}s.mdia.mdhd.duration=0,s.tkhd.duration=0;var T=S.sampleDescriptionId,B={type:"moov",mvhd:e.mvhd,traks:[{tkhd:s.tkhd,mdia:{mdhd:s.mdia.mdhd,hdlr:s.mdia.hdlr,elng:s.mdia.elng,minf:{vmhd:s.mdia.minf.vmhd,smhd:s.mdia.minf.smhd,dinf:s.mdia.minf.dinf,stbl:{stsd:u.stsd,stts:{version:0,flags:0,entries:[]},ctts:{version:0,flags:0,entries:[]},stsc:{version:0,flags:0,entries:[]},stsz:{version:0,flags:0,entries:[]},stco:{version:0,flags:0,entries:[]},stss:{version:0,flags:0,entries:[]}}}}}],mvex:{mehd:{fragmentDuration:e.mvhd.duration},trexs:[{trackId:s.tkhd.trackId,defaultSampleDescriptionIndex:T,defaultSampleDuration:0,defaultSampleSize:0,defaultSampleFlags:0}]}};this._tracks.push({trackId:s.tkhd.trackId,timeScale:s.mdia.mdhd.timeScale,samples:h,currSample:null,currTime:null,moov:B,mime:o})}if(0!==this._tracks.length){e.mvhd.duration=0,this._ftyp={type:"ftyp",brand:"iso5",brandVersion:0,compatibleBrands:["iso5"]};var C=a.encode(this._ftyp),P=this._tracks.map(function(e){var r=a.encode(e.moov);return{mime:e.mime,init:t.concat([C,r])}});this.emit("ready",P)}else this.emit("error",new Error("no playable tracks"))},c.prototype.seek=function(e){var t=this;if(!t._tracks)throw new Error("Not ready yet; wait for 'ready' event");t._fileStream&&(t._fileStream.destroy(),t._fileStream=null);var r=-1;if(t._tracks.map(function(n,i){n.outStream&&n.outStream.destroy(),n.inStream&&(n.inStream.destroy(),n.inStream=null);var o=n.outStream=s.encode(),a=t._generateFragment(i,e);if(!a)return o.finalize();(-1===r||a.ranges[0].start=0){var n=t._fileStream=t._file.createReadStream({start:r});t._tracks.forEach(function(e){e.inStream=new u(r,{highWaterMark:1e7}),n.pipe(e.inStream)})}return t._tracks.map(function(e){return e.outStream})},c.prototype._findSampleBefore=function(e,t){var r=this._tracks[e],i=Math.floor(r.timeScale*t),o=n(r.samples,i,function(e,t){return e.dts+e.presentationOffset-t});for(-1===o?o=0:o<0&&(o=-o-2);!r.samples[o].sync;)o--;return o};c.prototype._generateFragment=function(e,t){var r,n=this._tracks[e];if((r=void 0!==t?this._findSampleBefore(e,t):n.currSample)>=n.samples.length)return null;for(var i=n.samples[r].dts,o=0,s=[],a=r;a=1*n.timeScale)break;o+=u.size;var c=s.length-1;c<0||s[c].end!==u.offset?s.push({start:u.offset,end:u.offset+u.size}):s[c].end+=u.size}return n.currSample=a,{moof:this._generateMoof(e,r,a),ranges:s,length:o}},c.prototype._generateMoof=function(e,t,r){for(var n=this._tracks[e],i=[],o=t;o=e.length)throw new RangeError("invalid lower bound");if(void 0===i)i=e.length-1;else if((i|=0)=e.length)throw new RangeError("invalid upper bound");for(;n<=i;)if((s=+r(e[o=n+(i-n>>1)],t,o,e))<0)n=o+1;else{if(!(s>0))return o;i=o-1}return~n}},function(e,t,r){t.decode=r(1568),t.encode=r(1575)},function(e,t,r){(function(t){var n=r(22),i=r(5),o=r(1569),s=r(207),a=r(208),u=a(0);function c(){if(!(this instanceof c))return new c;n.Writable.call(this),this.destroyed=!1,this._pending=0,this._missing=0,this._buf=null,this._str=null,this._cb=null,this._ondrain=null,this._writeBuffer=null,this._writeCb=null,this._ondrain=null,this._kick()}function f(e){this._parent=e,this.destroyed=!1,n.PassThrough.call(this)}e.exports=c,i(c,n.Writable),c.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e),this.emit("close"))},c.prototype._write=function(e,t,r){if(!this.destroyed){for(var n=!this._str||!this._str._writableState.needDrain;e.length&&!this.destroyed;){if(!this._missing)return this._writeBuffer=e,void(this._writeCb=r);var i=e.lengthe.length)throw new RangeError("Out of range index");return r>>>=0,(n=void 0===n?e.length:n>>>0)>r&&e.fill(t,r,n),e}e.exports=function(e,i,o,s,a){if(r)return e.fill(i,o,s,a);if("number"==typeof i)return n(e,i,o,s);if("string"==typeof i){if("string"==typeof o?(a=o,o=0,s=e.length):"string"==typeof s&&(a=s,s=e.length),void 0!==a&&"string"!=typeof a)throw new TypeError("encoding must be a string");if("latin1"===a&&(a="binary"),"string"==typeof a&&!t.isEncoding(a))throw new TypeError("Unknown encoding: "+a);if(""===i)return n(e,0,o,s);if(function(e){return 1===e.length&&e.charCodeAt(0)<256}(i))return n(e,i.charCodeAt(0),o,s);i=new t(i,a)}return t.isBuffer(i)?function(e,t,r,n){if(r<0||n>e.length)throw new RangeError("Out of range index");if(n<=r)return e;r>>>=0,n=void 0===n?e.length:n>>>0;for(var i=r,o=t.length;i<=n-o;)t.copy(e,i),i+=o;return i!==n&&t.copy(e,i,0,n-i),e}(e,i,o,s):n(e,0,o,s)}}).call(this,r(0).Buffer)},function(e,t,r){(function(t){e.exports=function(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative');return t.allocUnsafe?t.allocUnsafe(e):new t(e)}}).call(this,r(0).Buffer)},function(e,t,r){var n=r(207),i=r(1574),o=r(208),s=r(330),a=20828448e5;function u(e,t,r){for(var n=t;n=8;){var u=n.decode(e,a,i);s.children.push(u),s[u.type]=u,a+=u.length}return s},t.VisualSampleEntry.encodingLength=function(e){var t=78;return(e.children||[]).forEach(function(e){t+=n.encodingLength(e)}),t},t.avcC={},t.avcC.encode=function(e,r,n){r=r?r.slice(n):o(e.buffer.length),e.buffer.copy(r),t.avcC.encode.bytes=e.buffer.length},t.avcC.decode=function(e,t,r){return{mimeCodec:(e=e.slice(t,r)).toString("hex",1,4),buffer:s(e)}},t.avcC.encodingLength=function(e){return e.buffer.length},t.mp4a=t.AudioSampleEntry={},t.AudioSampleEntry.encode=function(e,r,i){u(r=r?r.slice(i):o(t.AudioSampleEntry.encodingLength(e)),0,6),r.writeUInt16BE(e.dataReferenceIndex||0,6),u(r,8,16),r.writeUInt16BE(e.channelCount||2,16),r.writeUInt16BE(e.sampleSize||16,18),u(r,20,24),r.writeUInt32BE(e.sampleRate||0,24);var s=28;(e.children||[]).forEach(function(e){n.encode(e,r,s),s+=n.encode.bytes}),t.AudioSampleEntry.encode.bytes=s},t.AudioSampleEntry.decode=function(e,t,r){for(var i=r-t,o={dataReferenceIndex:(e=e.slice(t,r)).readUInt16BE(6),channelCount:e.readUInt16BE(16),sampleSize:e.readUInt16BE(18),sampleRate:e.readUInt32BE(24),children:[]},s=28;i-s>=8;){var a=n.decode(e,s,i);o.children.push(a),o[a.type]=a,s+=a.length}return o},t.AudioSampleEntry.encodingLength=function(e){var t=28;return(e.children||[]).forEach(function(e){t+=n.encodingLength(e)}),t},t.esds={},t.esds.encode=function(e,r,n){r=r?r.slice(n):o(e.buffer.length),e.buffer.copy(r,0),t.esds.encode.bytes=e.buffer.length},t.esds.decode=function(e,t,r){e=e.slice(t,r);var n=i.Descriptor.decode(e,0,e.length),o=("ESDescriptor"===n.tagName?n:{}).DecoderConfigDescriptor||{},a=o.oti||0,u=o.DecoderSpecificInfo,c=u?(248&u.buffer.readUInt8(0))>>3:0,f=null;return a&&(f=a.toString(16),c&&(f+="."+c)),{mimeCodec:f,buffer:s(e.slice(0))}},t.esds.encodingLength=function(e){return e.buffer.length},t.stsz={},t.stsz.encode=function(e,r,n){var i=e.entries||[];(r=r?r.slice(n):o(t.stsz.encodingLength(e))).writeUInt32BE(0,0),r.writeUInt32BE(i.length,4);for(var s=0;s=e.length)return this._position+=e.length,r(null);if(a>e.length){this._position+=e.length,i=0===s?e:e.slice(s),n=o.stream.write(i)&&n;break}this._position+=a,i=0===s&&a===e.length?e:e.slice(s,a),n=o.stream.write(i)&&n,o.last&&o.stream.end(),e=e.slice(a),this._queue.shift()}n?r(null):o.stream.once("drain",r.bind(null,null))},o.prototype.slice=function(e){var t=this;if(t.destroyed)return null;e instanceof Array||(e=[e]);var r=new i.PassThrough;return e.forEach(function(n,i){t._queue.push({start:n.start,end:n.end,stream:r,last:i===e.length-1})}),t._buffer&&t._write(t._buffer,null,t._cb),r},o.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e))}},function(e,t,r){(function(t){var n=r(30);e.exports=function(e,r,i){i=n(i);var o=t.alloc(r),s=0;e.on("data",function(e){e.copy(o,s),s+=e.length}).on("end",function(){i(null,o)}).on("error",i)}}).call(this,r(0).Buffer)},function(e,t,r){var n=r(628),i=r(1)("webtorrent:peer"),o=r(629),s=r(1579);function a(e,t){this.id=e,this.type=t,i("new Peer %s",e),this.addr=null,this.conn=null,this.swarm=null,this.wire=null,this.connected=!1,this.destroyed=!1,this.timeout=null,this.retries=0,this.sentHandshake=!1}function u(){}t.createWebRTCPeer=function(e,t){var r=new a(e.id,"webrtc");return r.conn=e,r.swarm=t,r.conn.connected?r.onConnect():(r.conn.once("connect",function(){r.onConnect()}),r.conn.once("error",function(e){r.destroy(e)}),r.startConnectTimeout()),r},t.createTCPIncomingPeer=function(e){var t=e.remoteAddress+":"+e.remotePort,r=new a(t,"tcpIncoming");return r.conn=e,r.addr=t,r.onConnect(),r},t.createTCPOutgoingPeer=function(e,t){var r=new a(e,"tcpOutgoing");return r.addr=e,r.swarm=t,r},t.createWebSeedPeer=function(e,t){var r=new a(e,"webSeed");return r.swarm=t,r.conn=new s(e,t),r.onConnect(),r},a.prototype.onConnect=function(){var e=this;if(!e.destroyed){e.connected=!0,i("Peer %s connected",e.id),clearTimeout(e.connectTimeout);var t=e.conn;t.once("end",function(){e.destroy()}),t.once("close",function(){e.destroy()}),t.once("finish",function(){e.destroy()}),t.once("error",function(t){e.destroy(t)});var r=e.wire=new o;r.type=e.type,r.once("end",function(){e.destroy()}),r.once("close",function(){e.destroy()}),r.once("finish",function(){e.destroy()}),r.once("error",function(t){e.destroy(t)}),r.once("handshake",function(t,r){e.onHandshake(t,r)}),e.startHandshakeTimeout(),t.pipe(r).pipe(t),e.swarm&&!e.sentHandshake&&e.handshake()}},a.prototype.onHandshake=function(e,t){if(this.swarm&&!this.destroyed){if(this.swarm.destroyed)return this.destroy(new Error("swarm already destroyed"));if(e!==this.swarm.infoHash)return this.destroy(new Error("unexpected handshake info hash for this swarm"));if(t===this.swarm.peerId)return this.destroy(new Error("refusing to connect to ourselves"));i("Peer %s got handshake %s",this.id,e),clearTimeout(this.handshakeTimeout),this.retries=0;var r=this.addr;!r&&this.conn.remoteAddress&&this.conn.remotePort&&(r=this.conn.remoteAddress+":"+this.conn.remotePort),this.swarm._onWire(this.wire,r),this.swarm&&!this.swarm.destroyed&&(this.sentHandshake||this.handshake())}},a.prototype.handshake=function(){var e={dht:!this.swarm.private&&!!this.swarm.client.dht};this.wire.handshake(this.swarm.infoHash,this.swarm.client.peerId,e),this.sentHandshake=!0},a.prototype.startConnectTimeout=function(){var e=this;clearTimeout(e.connectTimeout),e.connectTimeout=setTimeout(function(){e.destroy(new Error("connect timeout"))},"webrtc"===e.type?25e3:5e3),e.connectTimeout.unref&&e.connectTimeout.unref()},a.prototype.startHandshakeTimeout=function(){var e=this;clearTimeout(e.handshakeTimeout),e.handshakeTimeout=setTimeout(function(){e.destroy(new Error("handshake timeout"))},25e3),e.handshakeTimeout.unref&&e.handshakeTimeout.unref()},a.prototype.destroy=function(e){if(!this.destroyed){this.destroyed=!0,this.connected=!1,i("destroy %s (error: %s)",this.id,e&&(e.message||e)),clearTimeout(this.connectTimeout),clearTimeout(this.handshakeTimeout);var t=this.swarm,r=this.conn,o=this.wire;this.swarm=null,this.conn=null,this.wire=null,t&&o&&n(t.wires,t.wires.indexOf(o)),r&&(r.on("error",u),r.destroy()),o&&o.destroy(),t&&t.removePeer(this.id)}}},function(e,t,r){e.exports=l;var n=r(206),i=r(2).Buffer,o=r(1)("webtorrent:webconn"),s=r(624),a=r(5),u=r(148),c=r(629),f=r(331).version;function l(e,t){c.call(this),this.url=e,this.webPeerId=u.sync(e),this._torrent=t,this._init()}a(l,c),l.prototype._init=function(){var e=this;e.setKeepAlive(!0),e.once("handshake",function(t,r){if(!e.destroyed){e.handshake(t,e.webPeerId);for(var i=e._torrent.pieces.length,o=new n(i),s=0;s<=i;s++)o.set(s,!0);e.bitfield(o)}}),e.once("interested",function(){o("interested"),e.unchoke()}),e.on("uninterested",function(){o("uninterested")}),e.on("choke",function(){o("choke")}),e.on("unchoke",function(){o("unchoke")}),e.on("bitfield",function(){o("bitfield")}),e.on("request",function(t,r,n,i){o("request pieceIndex=%d offset=%d length=%d",t,r,n),e.httpRequest(t,r,n,i)})},l.prototype.httpRequest=function(e,t,r,n){var a,u=this,c=e*u._torrent.pieceLength+t,l=c+r-1,h=u._torrent.files;if(h.length<=1)a=[{url:u.url,start:c,end:l}];else{var p=h.filter(function(e){return e.offset<=l&&e.offset+e.length>c});if(p.length<1)return n(new Error("Could not find file corresponnding to web seed range request"));a=p.map(function(e){var t=e.offset+e.length-1;return{url:u.url+("/"===u.url[u.url.length-1]?"":"/")+e.path,fileOffsetInRange:Math.max(e.offset-c,0),start:Math.max(c-e.offset,0),end:Math.min(t,l-e.offset)}})}var d,y=0,g=!1;a.length>1&&(d=i.alloc(r)),a.forEach(function(i){var u=i.url,c=i.start,l=i.end;o("Requesting url=%s pieceIndex=%d offset=%d length=%d start=%d end=%d",u,e,t,r,c,l);var h={url:u,method:"GET",headers:{"user-agent":"WebTorrent/"+f+" (https://webtorrent.io)",range:"bytes="+c+"-"+l}};function p(e,t){if(e.statusCode<200||e.statusCode>=300)return g=!0,n(new Error("Unexpected HTTP status code "+e.statusCode));o("Got data of length %d",t.length),1===a.length?n(null,t):(t.copy(d,i.fileOffsetInRange),++y===a.length&&n(null,d))}s.concat(h,function(e,t,r){if(!g)return e?"undefined"==typeof window||u.startsWith(window.location.origin+"/")?(g=!0,n(e)):s.head(u,function(t,r){if(!g){if(t)return g=!0,n(t);if(r.statusCode<200||r.statusCode>=300)return g=!0,n(new Error("Unexpected HTTP status code "+r.statusCode));if(r.url===u)return g=!0,n(e);h.url=r.url,s.concat(h,function(e,t,r){if(!g)return e?(g=!0,n(e)):void p(t,r)})}}):void p(t,r)})})},l.prototype.destroy=function(){c.prototype.destroy.call(this),this._torrent=null}},function(e,t){function r(e){var t=this;t._torrent=e,t._numPieces=e.pieces.length,t._pieces=[],t._onWire=function(e){t.recalculate(),t._initWire(e)},t._onWireHave=function(e){t._pieces[e]+=1},t._onWireBitfield=function(){t.recalculate()},t._torrent.wires.forEach(function(e){t._initWire(e)}),t._torrent.on("wire",t._onWire),t.recalculate()}function n(){return!0}e.exports=r,r.prototype.getRarestPiece=function(e){e||(e=n);for(var t=[],r=1/0,i=0;i0?t[Math.random()*t.length|0]:-1},r.prototype.destroy=function(){var e=this;e._torrent.removeListener("wire",e._onWire),e._torrent.wires.forEach(function(t){e._cleanupWireEvents(t)}),e._torrent=null,e._pieces=null,e._onWire=null,e._onWireHave=null,e._onWireBitfield=null},r.prototype._initWire=function(e){var t=this;e._onClose=function(){t._cleanupWireEvents(e);for(var r=0;re.includes("ipfs/zb2")))throw new o.TransportError("GUN retrieving legacy data at: "+e.href);return s}async p_rawlist(e,{verbose:t=!1}={}){try{let r=this.connection(e,t),n=await this._p_once(r),i=n?Object.keys(n).filter(e=>"_"!==e).sort().map(e=>n[e]):[];return t&&console.log("GUN.p_rawlist found",...u.consolearr(i)),i}catch(e){throw console.log("TransportGUN.p_rawlist failed",e.message),e}}listmonitor(e,t,{verbose:r=!1,current:n=!1}={}){let i=this.connection(e,r);n?i.map().on((e,r)=>t("set",r,JSON.parse(e))):i.once(e=>{this.monitored=e?Object.keys(e):[],i.map().on((e,r)=>{this.monitored.includes(r)||"_"===r||(this.monitored.push(r),t(JSON.parse(e)))})})}async p_rawadd(e,t,{verbose:r=!1}={}){console.assert(e&&t.urls.length&&t.signature&&t.signedby.length,"TransportGUN.p_rawadd args",e,t),r&&console.log("TransportGUN.p_rawadd","string"==typeof e?e:e.href,t),this.connection(e,r).set(JSON.stringify(t.preflight(Object.assign({},t))))}async p_newlisturls(e,{verbose:t=!1}={}){let r=await this._p_newgun(e,{verbose:t});return[r,r]}async _p_newgun(e,{verbose:t=!1}={}){return e.hasOwnProperty("keypair")&&(e=e.keypair.signingexport()),`gun:/gun/${encodeURIComponent(e)}`}async p_newdatabase(e,{verbose:t=!1}={}){let r=await this._p_newgun(e,{verbose:t});return{publicurl:r,privateurl:r}}async p_newtable(e,t,{verbose:r=!1}={}){if(!e)throw new o.CodingError("p_newtable currently requires a pubkey");let n=await this.p_newdatabase(e,{verbose:r});return{privateurl:`${n.privateurl}/${t}`,publicurl:`${n.publicurl}/${t}`}}async p_set(e,t,r,{verbose:n=!1}={}){let i=this.connection(e,n);"string"==typeof t?i.path(t).put(JSON.stringify(r)):(console.assert(!Array.isArray(t),"TransportGUN - shouldnt be passsing an array as the keyvalues"),i.put(Object.keys(t).reduce(function(e,r){return e[r]=JSON.stringify(t[r]),e},{})))}async p_get(e,t,{verbose:r=!1}={}){let n=this.connection(e,r);if(Array.isArray(t))throw new o.ToBeImplementedError("p_get(url, [keys]) isn't supported - because of ambiguity better to explicitly loop on set of keys or use getall and filter");{let e=await this._p_once(n.get(t));return"string"==typeof e?JSON.parse(e):e}}async p_delete(e,t,{verbose:r=!1}={}){let n=this.connection(e,r);"string"==typeof t?n.path(t).put(null):t.map(e=>n.path(e).put(null))}_p_once(e){return new Promise((t,r)=>e.once(t))}async p_keys(e,{verbose:t=!1}={}){let r=await this._p_once(this.connection(e,t));return Object.keys(r).filter(e=>"_"!==e&&null!==r[e])}async p_getall(e,{verbose:t=!1}={}){let r=await this._p_once(this.connection(e,t));return Object.keys(r).filter(e=>"_"!==e&&null!==r[e]).reduce(function(e,t){return e[t]=JSON.parse(r[t]),e},{})}async monitor(e,t,{verbose:r=!1,current:n=!1}={}){let i=this.connection(e,r);n?i.map().on((e,r)=>t("set",r,JSON.parse(e))):i.once(e=>{this.monitored=Object.assign({},e),i.map().on((e,r)=>{e!==this.monitored[r]&&"_"!==r&&(this.monitored[r]=e,t("set",r,JSON.parse(e)))})})}static async p_test(e){e&&console.log("TransportGUN.test");try{let t=this.setup0({},e);await t.p_setup1(e),await t.p_setup2(e),t.p_test_kvt("gun:/gun/NACL",{verbose:e})}catch(e){throw console.log("Exception thrown in TransportGUN.test:",e.message),e}}static async demo_bugs(){let e=new i;e.get("foo").get("bar").put("baz"),console.log("Expect {bar: 'baz'} but get {_:..., bar: 'baz'}"),e.get("foo").once(e=>console.log(e)),e.get("zip").get("bar").set("alice"),console.log("Expect {12345: 'alice'} but get {_:..., 12345: 'alice'}"),e.get("foo").once(e=>console.log(e))}}a._transportclasses.GUN=f,e.exports=f}).call(this,r(7))},function(e,t,r){("undefined"!=typeof window?window.Gun:r(630)).chain.path=function(e,t){var r,n=this;if("string"==typeof e){if(1===(r=e.split(t||".")).length)return this.get(e);e=r}if(e instanceof Array){if(e.length>1){n=this;for(var i=0,o=e.length;i>>1,U=[["ary",E],["bind",m],["bindKey",b],["curry",_],["curryRight",w],["flip",x],["partial",S],["partialRight",k],["rearg",A]],F="[object Arguments]",q="[object Array]",H="[object AsyncFunction]",z="[object Boolean]",V="[object Date]",G="[object DOMException]",W="[object Error]",$="[object Function]",Y="[object GeneratorFunction]",J="[object Map]",X="[object Number]",Z="[object Null]",Q="[object Object]",ee="[object Promise]",te="[object Proxy]",re="[object RegExp]",ne="[object Set]",ie="[object String]",oe="[object Symbol]",se="[object Undefined]",ae="[object WeakMap]",ue="[object WeakSet]",ce="[object ArrayBuffer]",fe="[object DataView]",le="[object Float32Array]",he="[object Float64Array]",pe="[object Int8Array]",de="[object Int16Array]",ye="[object Int32Array]",ge="[object Uint8Array]",me="[object Uint8ClampedArray]",be="[object Uint16Array]",ve="[object Uint32Array]",_e=/\b__p \+= '';/g,we=/\b(__p \+=) '' \+/g,Se=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ke=/&(?:amp|lt|gt|quot|#39);/g,Ee=/[&<>"']/g,Ae=RegExp(ke.source),xe=RegExp(Ee.source),Ie=/<%-([\s\S]+?)%>/g,Te=/<%([\s\S]+?)%>/g,Be=/<%=([\s\S]+?)%>/g,Ce=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Pe=/^\w*$/,Oe=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Re=/[\\^$.*+?()[\]{}|]/g,Ne=RegExp(Re.source),Le=/^\s+|\s+$/g,je=/^\s+/,Me=/\s+$/,Ke=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,De=/\{\n\/\* \[wrapped with (.+)\] \*/,Ue=/,? & /,Fe=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,qe=/\\(\\)?/g,He=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ze=/\w*$/,Ve=/^[-+]0x[0-9a-f]+$/i,Ge=/^0b[01]+$/i,We=/^\[object .+?Constructor\]$/,$e=/^0o[0-7]+$/i,Ye=/^(?:0|[1-9]\d*)$/,Je=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Xe=/($^)/,Ze=/['\n\r\u2028\u2029\\]/g,Qe="\\ud800-\\udfff",et="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",tt="a-z\\xdf-\\xf6\\xf8-\\xff",rt="A-Z\\xc0-\\xd6\\xd8-\\xde",nt="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",it="["+nt+"]",ot="["+et+"]",st="\\d+",at="["+tt+"]",ut="[^"+Qe+nt+st+"\\u2700-\\u27bf"+tt+rt+"]",ct="\\ud83c[\\udffb-\\udfff]",ft="[^\\ud800-\\udfff]",lt="(?:\\ud83c[\\udde6-\\uddff]){2}",ht="[\\ud800-\\udbff][\\udc00-\\udfff]",pt="["+rt+"]",dt="(?:"+at+"|"+ut+")",yt="(?:"+pt+"|"+ut+")",gt="(?:['’](?:d|ll|m|re|s|t|ve))?",mt="(?:['’](?:D|LL|M|RE|S|T|VE))?",bt="(?:"+ot+"|"+ct+")?",vt="[\\ufe0e\\ufe0f]?",_t=vt+bt+"(?:\\u200d(?:"+[ft,lt,ht].join("|")+")"+vt+bt+")*",wt="(?:"+["[\\u2700-\\u27bf]",lt,ht].join("|")+")"+_t,St="(?:"+[ft+ot+"?",ot,lt,ht,"[\\ud800-\\udfff]"].join("|")+")",kt=RegExp("['’]","g"),Et=RegExp(ot,"g"),At=RegExp(ct+"(?="+ct+")|"+St+_t,"g"),xt=RegExp([pt+"?"+at+"+"+gt+"(?="+[it,pt,"$"].join("|")+")",yt+"+"+mt+"(?="+[it,pt+dt,"$"].join("|")+")",pt+"?"+dt+"+"+gt,pt+"+"+mt,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",st,wt].join("|"),"g"),It=RegExp("[\\u200d"+Qe+et+"\\ufe0e\\ufe0f]"),Tt=/[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Bt=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Ct=-1,Pt={};Pt[le]=Pt[he]=Pt[pe]=Pt[de]=Pt[ye]=Pt[ge]=Pt[me]=Pt[be]=Pt[ve]=!0,Pt[F]=Pt[q]=Pt[ce]=Pt[z]=Pt[fe]=Pt[V]=Pt[W]=Pt[$]=Pt[J]=Pt[X]=Pt[Q]=Pt[re]=Pt[ne]=Pt[ie]=Pt[ae]=!1;var Ot={};Ot[F]=Ot[q]=Ot[ce]=Ot[fe]=Ot[z]=Ot[V]=Ot[le]=Ot[he]=Ot[pe]=Ot[de]=Ot[ye]=Ot[J]=Ot[X]=Ot[Q]=Ot[re]=Ot[ne]=Ot[ie]=Ot[oe]=Ot[ge]=Ot[me]=Ot[be]=Ot[ve]=!0,Ot[W]=Ot[$]=Ot[ae]=!1;var Rt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Nt=parseFloat,Lt=parseInt,jt="object"==typeof e&&e&&e.Object===Object&&e,Mt="object"==typeof self&&self&&self.Object===Object&&self,Kt=jt||Mt||Function("return this")(),Dt="object"==typeof t&&t&&!t.nodeType&&t,Ut=Dt&&"object"==typeof n&&n&&!n.nodeType&&n,Ft=Ut&&Ut.exports===Dt,qt=Ft&&jt.process,Ht=function(){try{return Ut&&Ut.require&&Ut.require("util").types||qt&&qt.binding&&qt.binding("util")}catch(e){}}(),zt=Ht&&Ht.isArrayBuffer,Vt=Ht&&Ht.isDate,Gt=Ht&&Ht.isMap,Wt=Ht&&Ht.isRegExp,$t=Ht&&Ht.isSet,Yt=Ht&&Ht.isTypedArray;function Jt(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}function Xt(e,t,r,n){for(var i=-1,o=null==e?0:e.length;++i-1}function rr(e,t,r){for(var n=-1,i=null==e?0:e.length;++n-1;);return r}function Ar(e,t){for(var r=e.length;r--&&hr(t,e[r],0)>-1;);return r}var xr=mr({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),Ir=mr({"&":"&","<":"<",">":">",'"':""","'":"'"});function Tr(e){return"\\"+Rt[e]}function Br(e){return It.test(e)}function Cr(e){return Tt.test(e)}function Pr(e){var t=-1,r=Array(e.size);return e.forEach(function(e,n){r[++t]=[n,e]}),r}function Or(e,t){return function(r){return e(t(r))}}function Rr(e,t){for(var r=-1,n=e.length,i=0,o=[];++r",""":'"',"'":"'"});function Dr(e){return e.match(xt)||[]}var Ur=function e(t){var r,n=(t=null==t?Kt:Ur.defaults(Kt.Object(),t,Ur.pick(Kt,Bt))).Array,i=t.Date,Fe=t.Error,Qe=t.Function,et=t.Math,tt=t.Object,rt=t.RegExp,nt=t.String,it=t.TypeError,ot=n.prototype,st=Qe.prototype,at=tt.prototype,ut=t["__core-js_shared__"],ct=st.toString,ft=at.hasOwnProperty,lt=0,ht=(r=/[^.]+$/.exec(ut&&ut.keys&&ut.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",pt=at.toString,dt=ct.call(tt),yt=Kt._,gt=rt("^"+ct.call(ft).replace(Re,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),mt=Ft?t.Buffer:o,bt=t.Symbol,vt=t.Uint8Array,_t=mt?mt.allocUnsafe:o,wt=Or(tt.getPrototypeOf,tt),St=tt.create,At=at.propertyIsEnumerable,xt=ot.splice,It=bt?bt.isConcatSpreadable:o,Tt=bt?bt.iterator:o,Rt=bt?bt.toStringTag:o,jt=function(){try{var e=Do(tt,"defineProperty");return e({},"",{}),e}catch(e){}}(),Mt=t.clearTimeout!==Kt.clearTimeout&&t.clearTimeout,Dt=i&&i.now!==Kt.Date.now&&i.now,Ut=t.setTimeout!==Kt.setTimeout&&t.setTimeout,qt=et.ceil,Ht=et.floor,ur=tt.getOwnPropertySymbols,mr=mt?mt.isBuffer:o,Fr=t.isFinite,qr=ot.join,Hr=Or(tt.keys,tt),zr=et.max,Vr=et.min,Gr=i.now,Wr=t.parseInt,$r=et.random,Yr=ot.reverse,Jr=Do(t,"DataView"),Xr=Do(t,"Map"),Zr=Do(t,"Promise"),Qr=Do(t,"Set"),en=Do(t,"WeakMap"),tn=Do(tt,"create"),rn=en&&new en,nn={},on=hs(Jr),sn=hs(Xr),an=hs(Zr),un=hs(Qr),cn=hs(en),fn=bt?bt.prototype:o,ln=fn?fn.valueOf:o,hn=fn?fn.toString:o;function pn(e){if(Ba(e)&&!ba(e)&&!(e instanceof mn)){if(e instanceof gn)return e;if(ft.call(e,"__wrapped__"))return ps(e)}return new gn(e)}var dn=function(){function e(){}return function(t){if(!Ta(t))return{};if(St)return St(t);e.prototype=t;var r=new e;return e.prototype=o,r}}();function yn(){}function gn(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=o}function mn(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=M,this.__views__=[]}function bn(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t=t?e:t)),e}function Rn(e,t,r,n,i,s){var a,u=t&h,c=t&p,f=t&d;if(r&&(a=i?r(e,n,i,s):r(e)),a!==o)return a;if(!Ta(e))return e;var l=ba(e);if(l){if(a=function(e){var t=e.length,r=new e.constructor(t);return t&&"string"==typeof e[0]&&ft.call(e,"index")&&(r.index=e.index,r.input=e.input),r}(e),!u)return Zi(e,a)}else{var y=qo(e),g=y==$||y==Y;if(Sa(e))return Gi(e,u);if(y==Q||y==F||g&&!i){if(a=c||g?{}:zo(e),!u)return c?function(e,t){return Qi(e,Fo(e),t)}(e,function(e,t){return e&&Qi(t,su(t),e)}(a,e)):function(e,t){return Qi(e,Uo(e),t)}(e,Bn(a,e))}else{if(!Ot[y])return i?e:{};a=function(e,t,r){var n=e.constructor;switch(t){case ce:return Wi(e);case z:case V:return new n(+e);case fe:return function(e,t){var r=t?Wi(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}(e,r);case le:case he:case pe:case de:case ye:case ge:case me:case be:case ve:return $i(e,r);case J:return new n;case X:case ie:return new n(e);case re:return function(e){var t=new e.constructor(e.source,ze.exec(e));return t.lastIndex=e.lastIndex,t}(e);case ne:return new n;case oe:return function(e){return ln?tt(ln.call(e)):{}}(e)}}(e,y,u)}}s||(s=new Sn);var m=s.get(e);if(m)return m;if(s.set(e,a),Na(e))return e.forEach(function(n){a.add(Rn(n,t,r,n,e,s))}),a;if(Ca(e))return e.forEach(function(n,i){a.set(i,Rn(n,t,r,i,e,s))}),a;var b=l?o:(f?c?Oo:Po:c?su:ou)(e);return Zt(b||e,function(n,i){b&&(n=e[i=n]),xn(a,i,Rn(n,t,r,i,e,s))}),a}function Nn(e,t,r){var n=r.length;if(null==e)return!n;for(e=tt(e);n--;){var i=r[n],s=t[i],a=e[i];if(a===o&&!(i in e)||!s(a))return!1}return!0}function Ln(e,t,r){if("function"!=typeof e)throw new it(u);return os(function(){e.apply(o,r)},t)}function jn(e,t,r,n){var i=-1,o=tr,a=!0,u=e.length,c=[],f=t.length;if(!u)return c;r&&(t=nr(t,wr(r))),n?(o=rr,a=!1):t.length>=s&&(o=kr,a=!1,t=new wn(t));e:for(;++i-1},vn.prototype.set=function(e,t){var r=this.__data__,n=In(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},_n.prototype.clear=function(){this.size=0,this.__data__={hash:new bn,map:new(Xr||vn),string:new bn}},_n.prototype.delete=function(e){var t=Mo(this,e).delete(e);return this.size-=t?1:0,t},_n.prototype.get=function(e){return Mo(this,e).get(e)},_n.prototype.has=function(e){return Mo(this,e).has(e)},_n.prototype.set=function(e,t){var r=Mo(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},wn.prototype.add=wn.prototype.push=function(e){return this.__data__.set(e,c),this},wn.prototype.has=function(e){return this.__data__.has(e)},Sn.prototype.clear=function(){this.__data__=new vn,this.size=0},Sn.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},Sn.prototype.get=function(e){return this.__data__.get(e)},Sn.prototype.has=function(e){return this.__data__.has(e)},Sn.prototype.set=function(e,t){var r=this.__data__;if(r instanceof vn){var n=r.__data__;if(!Xr||n.length0&&r(a)?t>1?qn(a,t-1,r,n,i):ir(i,a):n||(i[i.length]=a)}return i}var Hn=no(),zn=no(!0);function Vn(e,t){return e&&Hn(e,t,ou)}function Gn(e,t){return e&&zn(e,t,ou)}function Wn(e,t){return er(t,function(t){return Aa(e[t])})}function $n(e,t){for(var r=0,n=(t=qi(t,e)).length;null!=e&&rt}function Zn(e,t){return null!=e&&ft.call(e,t)}function Qn(e,t){return null!=e&&t in tt(e)}function ei(e,t,r){for(var i=r?rr:tr,s=e[0].length,a=e.length,u=a,c=n(a),f=1/0,l=[];u--;){var h=e[u];u&&t&&(h=nr(h,wr(t))),f=Vr(h.length,f),c[u]=!r&&(t||s>=120&&h.length>=120)?new wn(u&&h):o}h=e[0];var p=-1,d=c[0];e:for(;++p=a?u:u*("desc"==r[n]?-1:1)}return e.index-t.index}(e,t,r)})}function gi(e,t,r){for(var n=-1,i=t.length,o={};++n-1;)a!==e&&xt.call(a,u,1),xt.call(e,u,1);return e}function bi(e,t){for(var r=e?t.length:0,n=r-1;r--;){var i=t[r];if(r==n||i!==o){var o=i;Go(i)?xt.call(e,i,1):Ni(e,i)}}return e}function vi(e,t){return e+Ht($r()*(t-e+1))}function _i(e,t,r,i){for(var o=-1,s=zr(qt((t-e)/(r||1)),0),a=n(s);s--;)a[i?s:++o]=e,e+=r;return a}function wi(e,t){var r="";if(!e||t<1||t>N)return r;do{t%2&&(r+=e),(t=Ht(t/2))&&(e+=e)}while(t);return r}function Si(e,t){return ss(ts(e,t,Pu),e+"")}function ki(e,t,r,n){if(!Ta(e))return e;for(var i=-1,s=(t=qi(t,e)).length,a=s-1,u=e;null!=u&&++io?0:o+t),(r=r>o?o:r)<0&&(r+=o),o=t>r?0:r-t>>>0,t>>>=0;for(var s=n(o);++i>>1,s=e[o];null!==s&&!ja(s)&&(r?s<=t:s=s){var f=t?null:wo(e);if(f)return Lr(f);a=!1,i=kr,c=new wn}else c=t?[]:u;e:for(;++n=n?e:xi(e,t,r)}var Vi=Mt||function(e){return Kt.clearTimeout(e)};function Gi(e,t){if(t)return e.slice();var r=e.length,n=_t?_t(r):new e.constructor(r);return e.copy(n),n}function Wi(e){var t=new e.constructor(e.byteLength);return new vt(t).set(new vt(e)),t}function $i(e,t){var r=t?Wi(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}function Yi(e,t){if(e!==t){var r=e!==o,n=null===e,i=e==e,s=ja(e),a=t!==o,u=null===t,c=t==t,f=ja(t);if(!u&&!f&&!s&&e>t||s&&a&&c&&!u&&!f||n&&a&&c||!r&&c||!i)return 1;if(!n&&!s&&!f&&e1?r[i-1]:o,a=i>2?r[2]:o;for(s=e.length>3&&"function"==typeof s?(i--,s):o,a&&Wo(r[0],r[1],a)&&(s=i<3?o:s,i=1),t=tt(t);++n-1?i[s?t[a]:a]:o}}function co(e){return Co(function(t){var r=t.length,n=r,i=gn.prototype.thru;for(e&&t.reverse();n--;){var s=t[n];if("function"!=typeof s)throw new it(u);if(i&&!a&&"wrapper"==No(s))var a=new gn([],!0)}for(n=a?n:r;++n1&&b.reverse(),h&&fu))return!1;var f=s.get(e);if(f&&s.get(t))return f==t;var l=-1,h=!0,p=r&g?new wn:o;for(s.set(e,t),s.set(t,e);++l-1&&e%1==0&&e1?"& ":"")+t[n],t=t.join(r>2?", ":" "),e.replace(Ke,"{\n/* [wrapped with "+t+"] */\n")}(n,function(e,t){return Zt(U,function(r){var n="_."+r[0];t&r[1]&&!tr(e,n)&&e.push(n)}),e.sort()}(function(e){var t=e.match(De);return t?t[1].split(Ue):[]}(n),r)))}function us(e){var t=0,r=0;return function(){var n=Gr(),i=C-(n-r);if(r=n,i>0){if(++t>=B)return arguments[0]}else t=0;return e.apply(o,arguments)}}function cs(e,t){var r=-1,n=e.length,i=n-1;for(t=t===o?n:t;++r1?e[t-1]:o;return Rs(e,r="function"==typeof r?(e.pop(),r):o)});function Us(e){var t=pn(e);return t.__chain__=!0,t}function Fs(e,t){return t(e)}var qs=Co(function(e){var t=e.length,r=t?e[0]:0,n=this.__wrapped__,i=function(t){return Pn(t,e)};return!(t>1||this.__actions__.length)&&n instanceof mn&&Go(r)?((n=n.slice(r,+r+(t?1:0))).__actions__.push({func:Fs,args:[i],thisArg:o}),new gn(n,this.__chain__).thru(function(e){return t&&!e.length&&e.push(o),e})):this.thru(i)});var Hs=eo(function(e,t,r){ft.call(e,r)?++e[r]:Cn(e,r,1)});var zs=uo(ms),Vs=uo(bs);function Gs(e,t){return(ba(e)?Zt:Mn)(e,jo(t,3))}function Ws(e,t){return(ba(e)?function(e,t){for(var r=null==e?0:e.length;r--&&!1!==t(e[r],r,e););return e}:Kn)(e,jo(t,3))}var $s=eo(function(e,t,r){ft.call(e,r)?e[r].push(t):Cn(e,r,[t])});var Ys=Si(function(e,t,r){var i=-1,o="function"==typeof t,s=_a(e)?n(e.length):[];return Mn(e,function(e){s[++i]=o?Jt(t,e,r):ti(e,t,r)}),s}),Js=eo(function(e,t,r){Cn(e,r,t)});function Xs(e,t){return(ba(e)?nr:fi)(e,jo(t,3))}var Zs=eo(function(e,t,r){e[r?0:1].push(t)},function(){return[[],[]]});var Qs=Si(function(e,t){if(null==e)return[];var r=t.length;return r>1&&Wo(e,t[0],t[1])?t=[]:r>2&&Wo(t[0],t[1],t[2])&&(t=[t[0]]),yi(e,qn(t,1),[])}),ea=Dt||function(){return Kt.Date.now()};function ta(e,t,r){return t=r?o:t,t=e&&null==t?e.length:t,ko(e,E,o,o,o,o,t)}function ra(e,t){var r;if("function"!=typeof t)throw new it(u);return e=qa(e),function(){return--e>0&&(r=t.apply(this,arguments)),e<=1&&(t=o),r}}var na=Si(function(e,t,r){var n=m;if(r.length){var i=Rr(r,Lo(na));n|=S}return ko(e,n,t,r,i)}),ia=Si(function(e,t,r){var n=m|b;if(r.length){var i=Rr(r,Lo(ia));n|=S}return ko(t,n,e,r,i)});function oa(e,t,r){var n,i,s,a,c,f,l=0,h=!1,p=!1,d=!0;if("function"!=typeof e)throw new it(u);function y(t){var r=n,s=i;return n=i=o,l=t,a=e.apply(s,r)}function g(e){var r=e-f;return f===o||r>=t||r<0||p&&e-l>=s}function m(){var e=ea();if(g(e))return b(e);c=os(m,function(e){var r=t-(e-f);return p?Vr(r,s-(e-l)):r}(e))}function b(e){return c=o,d&&n?y(e):(n=i=o,a)}function v(){var e=ea(),r=g(e);if(n=arguments,i=this,f=e,r){if(c===o)return function(e){return l=e,c=os(m,t),h?y(e):a}(f);if(p)return c=os(m,t),y(f)}return c===o&&(c=os(m,t)),a}return t=za(t)||0,Ta(r)&&(h=!!r.leading,s=(p="maxWait"in r)?zr(za(r.maxWait)||0,t):s,d="trailing"in r?!!r.trailing:d),v.cancel=function(){c!==o&&Vi(c),l=0,n=f=i=c=o},v.flush=function(){return c===o?a:b(ea())},v}var sa=Si(function(e,t){return Ln(e,1,t)}),aa=Si(function(e,t,r){return Ln(e,za(t)||0,r)});function ua(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new it(u);var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var s=e.apply(this,n);return r.cache=o.set(i,s)||o,s};return r.cache=new(ua.Cache||_n),r}function ca(e){if("function"!=typeof e)throw new it(u);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}ua.Cache=_n;var fa=Hi(function(e,t){var r=(t=1==t.length&&ba(t[0])?nr(t[0],wr(jo())):nr(qn(t,1),wr(jo()))).length;return Si(function(n){for(var i=-1,o=Vr(n.length,r);++i=t}),ma=ri(function(){return arguments}())?ri:function(e){return Ba(e)&&ft.call(e,"callee")&&!At.call(e,"callee")},ba=n.isArray,va=zt?wr(zt):function(e){return Ba(e)&&Jn(e)==ce};function _a(e){return null!=e&&Ia(e.length)&&!Aa(e)}function wa(e){return Ba(e)&&_a(e)}var Sa=mr||zu,ka=Vt?wr(Vt):function(e){return Ba(e)&&Jn(e)==V};function Ea(e){if(!Ba(e))return!1;var t=Jn(e);return t==W||t==G||"string"==typeof e.message&&"string"==typeof e.name&&!Oa(e)}function Aa(e){if(!Ta(e))return!1;var t=Jn(e);return t==$||t==Y||t==H||t==te}function xa(e){return"number"==typeof e&&e==qa(e)}function Ia(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=N}function Ta(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Ba(e){return null!=e&&"object"==typeof e}var Ca=Gt?wr(Gt):function(e){return Ba(e)&&qo(e)==J};function Pa(e){return"number"==typeof e||Ba(e)&&Jn(e)==X}function Oa(e){if(!Ba(e)||Jn(e)!=Q)return!1;var t=wt(e);if(null===t)return!0;var r=ft.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&ct.call(r)==dt}var Ra=Wt?wr(Wt):function(e){return Ba(e)&&Jn(e)==re};var Na=$t?wr($t):function(e){return Ba(e)&&qo(e)==ne};function La(e){return"string"==typeof e||!ba(e)&&Ba(e)&&Jn(e)==ie}function ja(e){return"symbol"==typeof e||Ba(e)&&Jn(e)==oe}var Ma=Yt?wr(Yt):function(e){return Ba(e)&&Ia(e.length)&&!!Pt[Jn(e)]};var Ka=bo(ci),Da=bo(function(e,t){return e<=t});function Ua(e){if(!e)return[];if(_a(e))return La(e)?Mr(e):Zi(e);if(Tt&&e[Tt])return function(e){for(var t,r=[];!(t=e.next()).done;)r.push(t.value);return r}(e[Tt]());var t=qo(e);return(t==J?Pr:t==ne?Lr:du)(e)}function Fa(e){return e?(e=za(e))===R||e===-R?(e<0?-1:1)*L:e==e?e:0:0===e?e:0}function qa(e){var t=Fa(e),r=t%1;return t==t?r?t-r:t:0}function Ha(e){return e?On(qa(e),0,M):0}function za(e){if("number"==typeof e)return e;if(ja(e))return j;if(Ta(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Ta(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(Le,"");var r=Ge.test(e);return r||$e.test(e)?Lt(e.slice(2),r?2:8):Ve.test(e)?j:+e}function Va(e){return Qi(e,su(e))}function Ga(e){return null==e?"":Oi(e)}var Wa=to(function(e,t){if(Xo(t)||_a(t))Qi(t,ou(t),e);else for(var r in t)ft.call(t,r)&&xn(e,r,t[r])}),$a=to(function(e,t){Qi(t,su(t),e)}),Ya=to(function(e,t,r,n){Qi(t,su(t),e,n)}),Ja=to(function(e,t,r,n){Qi(t,ou(t),e,n)}),Xa=Co(Pn);var Za=Si(function(e,t){e=tt(e);var r=-1,n=t.length,i=n>2?t[2]:o;for(i&&Wo(t[0],t[1],i)&&(n=1);++r1),t}),Qi(e,Oo(e),r),n&&(r=Rn(r,h|p|d,xo));for(var i=t.length;i--;)Ni(r,t[i]);return r});var fu=Co(function(e,t){return null==e?{}:function(e,t){return gi(e,t,function(t,r){return tu(e,r)})}(e,t)});function lu(e,t){if(null==e)return{};var r=nr(Oo(e),function(e){return[e]});return t=jo(t),gi(e,r,function(e,r){return t(e,r[0])})}var hu=So(ou),pu=So(su);function du(e){return null==e?[]:Sr(e,ou(e))}var yu=oo(function(e,t,r){return t=t.toLowerCase(),e+(r?gu(t):t)});function gu(e){return Eu(Ga(e).toLowerCase())}function mu(e){return(e=Ga(e))&&e.replace(Je,xr).replace(Et,"")}var bu=oo(function(e,t,r){return e+(r?"-":"")+t.toLowerCase()}),vu=oo(function(e,t,r){return e+(r?" ":"")+t.toLowerCase()}),_u=io("toLowerCase");var wu=oo(function(e,t,r){return e+(r?"_":"")+t.toLowerCase()});var Su=oo(function(e,t,r){return e+(r?" ":"")+Eu(t)});var ku=oo(function(e,t,r){return e+(r?" ":"")+t.toUpperCase()}),Eu=io("toUpperCase");function Au(e,t,r){return e=Ga(e),(t=r?o:t)===o?Cr(e)?Dr(e):cr(e):e.match(t)||[]}var xu=Si(function(e,t){try{return Jt(e,o,t)}catch(e){return Ea(e)?e:new Fe(e)}}),Iu=Co(function(e,t){return Zt(t,function(t){t=ls(t),Cn(e,t,na(e[t],e))}),e});function Tu(e){return function(){return e}}var Bu=co(),Cu=co(!0);function Pu(e){return e}function Ou(e){return si("function"==typeof e?e:Rn(e,h))}var Ru=Si(function(e,t){return function(r){return ti(r,e,t)}}),Nu=Si(function(e,t){return function(r){return ti(e,r,t)}});function Lu(e,t,r){var n=ou(t),i=Wn(t,n);null!=r||Ta(t)&&(i.length||!n.length)||(r=t,t=e,e=this,i=Wn(t,ou(t)));var o=!(Ta(r)&&"chain"in r&&!r.chain),s=Aa(e);return Zt(i,function(r){var n=t[r];e[r]=n,s&&(e.prototype[r]=function(){var t=this.__chain__;if(o||t){var r=e(this.__wrapped__);return(r.__actions__=Zi(this.__actions__)).push({func:n,args:arguments,thisArg:e}),r.__chain__=t,r}return n.apply(e,ir([this.value()],arguments))})}),e}function ju(){}var Mu=po(nr),Ku=po(Qt),Du=po(ar);function Uu(e){return $o(e)?gr(ls(e)):function(e){return function(t){return $n(t,e)}}(e)}var Fu=mo(),qu=mo(!0);function Hu(){return[]}function zu(){return!1}var Vu=ho(function(e,t){return e+t},0),Gu=_o("ceil"),Wu=ho(function(e,t){return e/t},1),$u=_o("floor");var Yu,Ju=ho(function(e,t){return e*t},1),Xu=_o("round"),Zu=ho(function(e,t){return e-t},0);return pn.after=function(e,t){if("function"!=typeof t)throw new it(u);return e=qa(e),function(){if(--e<1)return t.apply(this,arguments)}},pn.ary=ta,pn.assign=Wa,pn.assignIn=$a,pn.assignInWith=Ya,pn.assignWith=Ja,pn.at=Xa,pn.before=ra,pn.bind=na,pn.bindAll=Iu,pn.bindKey=ia,pn.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return ba(e)?e:[e]},pn.chain=Us,pn.chunk=function(e,t,r){t=(r?Wo(e,t,r):t===o)?1:zr(qa(t),0);var i=null==e?0:e.length;if(!i||t<1)return[];for(var s=0,a=0,u=n(qt(i/t));si?0:i+r),(n=n===o||n>i?i:qa(n))<0&&(n+=i),n=r>n?0:Ha(n);r>>0)?(e=Ga(e))&&("string"==typeof t||null!=t&&!Ra(t))&&!(t=Oi(t))&&Br(e)?zi(Mr(e),0,r):e.split(t,r):[]},pn.spread=function(e,t){if("function"!=typeof e)throw new it(u);return t=null==t?0:zr(qa(t),0),Si(function(r){var n=r[t],i=zi(r,0,t);return n&&ir(i,n),Jt(e,this,i)})},pn.tail=function(e){var t=null==e?0:e.length;return t?xi(e,1,t):[]},pn.take=function(e,t,r){return e&&e.length?xi(e,0,(t=r||t===o?1:qa(t))<0?0:t):[]},pn.takeRight=function(e,t,r){var n=null==e?0:e.length;return n?xi(e,(t=n-(t=r||t===o?1:qa(t)))<0?0:t,n):[]},pn.takeRightWhile=function(e,t){return e&&e.length?ji(e,jo(t,3),!1,!0):[]},pn.takeWhile=function(e,t){return e&&e.length?ji(e,jo(t,3)):[]},pn.tap=function(e,t){return t(e),e},pn.throttle=function(e,t,r){var n=!0,i=!0;if("function"!=typeof e)throw new it(u);return Ta(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),oa(e,t,{leading:n,maxWait:t,trailing:i})},pn.thru=Fs,pn.toArray=Ua,pn.toPairs=hu,pn.toPairsIn=pu,pn.toPath=function(e){return ba(e)?nr(e,ls):ja(e)?[e]:Zi(fs(Ga(e)))},pn.toPlainObject=Va,pn.transform=function(e,t,r){var n=ba(e),i=n||Sa(e)||Ma(e);if(t=jo(t,4),null==r){var o=e&&e.constructor;r=i?n?new o:[]:Ta(e)&&Aa(o)?dn(wt(e)):{}}return(i?Zt:Vn)(e,function(e,n,i){return t(r,e,n,i)}),r},pn.unary=function(e){return ta(e,1)},pn.union=Bs,pn.unionBy=Cs,pn.unionWith=Ps,pn.uniq=function(e){return e&&e.length?Ri(e):[]},pn.uniqBy=function(e,t){return e&&e.length?Ri(e,jo(t,2)):[]},pn.uniqWith=function(e,t){return t="function"==typeof t?t:o,e&&e.length?Ri(e,o,t):[]},pn.unset=function(e,t){return null==e||Ni(e,t)},pn.unzip=Os,pn.unzipWith=Rs,pn.update=function(e,t,r){return null==e?e:Li(e,t,Fi(r))},pn.updateWith=function(e,t,r,n){return n="function"==typeof n?n:o,null==e?e:Li(e,t,Fi(r),n)},pn.values=du,pn.valuesIn=function(e){return null==e?[]:Sr(e,su(e))},pn.without=Ns,pn.words=Au,pn.wrap=function(e,t){return la(Fi(t),e)},pn.xor=Ls,pn.xorBy=js,pn.xorWith=Ms,pn.zip=Ks,pn.zipObject=function(e,t){return Di(e||[],t||[],xn)},pn.zipObjectDeep=function(e,t){return Di(e||[],t||[],ki)},pn.zipWith=Ds,pn.entries=hu,pn.entriesIn=pu,pn.extend=$a,pn.extendWith=Ya,Lu(pn,pn),pn.add=Vu,pn.attempt=xu,pn.camelCase=yu,pn.capitalize=gu,pn.ceil=Gu,pn.clamp=function(e,t,r){return r===o&&(r=t,t=o),r!==o&&(r=(r=za(r))==r?r:0),t!==o&&(t=(t=za(t))==t?t:0),On(za(e),t,r)},pn.clone=function(e){return Rn(e,d)},pn.cloneDeep=function(e){return Rn(e,h|d)},pn.cloneDeepWith=function(e,t){return Rn(e,h|d,t="function"==typeof t?t:o)},pn.cloneWith=function(e,t){return Rn(e,d,t="function"==typeof t?t:o)},pn.conformsTo=function(e,t){return null==t||Nn(e,t,ou(t))},pn.deburr=mu,pn.defaultTo=function(e,t){return null==e||e!=e?t:e},pn.divide=Wu,pn.endsWith=function(e,t,r){e=Ga(e),t=Oi(t);var n=e.length,i=r=r===o?n:On(qa(r),0,n);return(r-=t.length)>=0&&e.slice(r,i)==t},pn.eq=da,pn.escape=function(e){return(e=Ga(e))&&xe.test(e)?e.replace(Ee,Ir):e},pn.escapeRegExp=function(e){return(e=Ga(e))&&Ne.test(e)?e.replace(Re,"\\$&"):e},pn.every=function(e,t,r){var n=ba(e)?Qt:Dn;return r&&Wo(e,t,r)&&(t=o),n(e,jo(t,3))},pn.find=zs,pn.findIndex=ms,pn.findKey=function(e,t){return fr(e,jo(t,3),Vn)},pn.findLast=Vs,pn.findLastIndex=bs,pn.findLastKey=function(e,t){return fr(e,jo(t,3),Gn)},pn.floor=$u,pn.forEach=Gs,pn.forEachRight=Ws,pn.forIn=function(e,t){return null==e?e:Hn(e,jo(t,3),su)},pn.forInRight=function(e,t){return null==e?e:zn(e,jo(t,3),su)},pn.forOwn=function(e,t){return e&&Vn(e,jo(t,3))},pn.forOwnRight=function(e,t){return e&&Gn(e,jo(t,3))},pn.get=eu,pn.gt=ya,pn.gte=ga,pn.has=function(e,t){return null!=e&&Ho(e,t,Zn)},pn.hasIn=tu,pn.head=_s,pn.identity=Pu,pn.includes=function(e,t,r,n){e=_a(e)?e:du(e),r=r&&!n?qa(r):0;var i=e.length;return r<0&&(r=zr(i+r,0)),La(e)?r<=i&&e.indexOf(t,r)>-1:!!i&&hr(e,t,r)>-1},pn.indexOf=function(e,t,r){var n=null==e?0:e.length;if(!n)return-1;var i=null==r?0:qa(r);return i<0&&(i=zr(n+i,0)),hr(e,t,i)},pn.inRange=function(e,t,r){return t=Fa(t),r===o?(r=t,t=0):r=Fa(r),function(e,t,r){return e>=Vr(t,r)&&e=-N&&e<=N},pn.isSet=Na,pn.isString=La,pn.isSymbol=ja,pn.isTypedArray=Ma,pn.isUndefined=function(e){return e===o},pn.isWeakMap=function(e){return Ba(e)&&qo(e)==ae},pn.isWeakSet=function(e){return Ba(e)&&Jn(e)==ue},pn.join=function(e,t){return null==e?"":qr.call(e,t)},pn.kebabCase=bu,pn.last=Es,pn.lastIndexOf=function(e,t,r){var n=null==e?0:e.length;if(!n)return-1;var i=n;return r!==o&&(i=(i=qa(r))<0?zr(n+i,0):Vr(i,n-1)),t==t?function(e,t,r){for(var n=r+1;n--;)if(e[n]===t)return n;return n}(e,t,i):lr(e,dr,i,!0)},pn.lowerCase=vu,pn.lowerFirst=_u,pn.lt=Ka,pn.lte=Da,pn.max=function(e){return e&&e.length?Un(e,Pu,Xn):o},pn.maxBy=function(e,t){return e&&e.length?Un(e,jo(t,2),Xn):o},pn.mean=function(e){return yr(e,Pu)},pn.meanBy=function(e,t){return yr(e,jo(t,2))},pn.min=function(e){return e&&e.length?Un(e,Pu,ci):o},pn.minBy=function(e,t){return e&&e.length?Un(e,jo(t,2),ci):o},pn.stubArray=Hu,pn.stubFalse=zu,pn.stubObject=function(){return{}},pn.stubString=function(){return""},pn.stubTrue=function(){return!0},pn.multiply=Ju,pn.nth=function(e,t){return e&&e.length?di(e,qa(t)):o},pn.noConflict=function(){return Kt._===this&&(Kt._=yt),this},pn.noop=ju,pn.now=ea,pn.pad=function(e,t,r){e=Ga(e);var n=(t=qa(t))?jr(e):0;if(!t||n>=t)return e;var i=(t-n)/2;return yo(Ht(i),r)+e+yo(qt(i),r)},pn.padEnd=function(e,t,r){e=Ga(e);var n=(t=qa(t))?jr(e):0;return t&&nt){var n=e;e=t,t=n}if(r||e%1||t%1){var i=$r();return Vr(e+i*(t-e+Nt("1e-"+((i+"").length-1))),t)}return vi(e,t)},pn.reduce=function(e,t,r){var n=ba(e)?or:br,i=arguments.length<3;return n(e,jo(t,4),r,i,Mn)},pn.reduceRight=function(e,t,r){var n=ba(e)?sr:br,i=arguments.length<3;return n(e,jo(t,4),r,i,Kn)},pn.repeat=function(e,t,r){return t=(r?Wo(e,t,r):t===o)?1:qa(t),wi(Ga(e),t)},pn.replace=function(){var e=arguments,t=Ga(e[0]);return e.length<3?t:t.replace(e[1],e[2])},pn.result=function(e,t,r){var n=-1,i=(t=qi(t,e)).length;for(i||(i=1,e=o);++nN)return[];var r=M,n=Vr(e,M);t=jo(t),e-=M;for(var i=_r(n,t);++r=s)return e;var u=r-jr(n);if(u<1)return n;var c=a?zi(a,0,u).join(""):e.slice(0,u);if(i===o)return c+n;if(a&&(u+=c.length-u),Ra(i)){if(e.slice(u).search(i)){var f,l=c;for(i.global||(i=rt(i.source,Ga(ze.exec(i))+"g")),i.lastIndex=0;f=i.exec(l);)var h=f.index;c=c.slice(0,h===o?u:h)}}else if(e.indexOf(Oi(i),u)!=u){var p=c.lastIndexOf(i);p>-1&&(c=c.slice(0,p))}return c+n},pn.unescape=function(e){return(e=Ga(e))&&Ae.test(e)?e.replace(ke,Kr):e},pn.uniqueId=function(e){var t=++lt;return Ga(e)+t},pn.upperCase=ku,pn.upperFirst=Eu,pn.each=Gs,pn.eachRight=Ws,pn.first=_s,Lu(pn,(Yu={},Vn(pn,function(e,t){ft.call(pn.prototype,t)||(Yu[t]=e)}),Yu),{chain:!1}),pn.VERSION="4.17.10",Zt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){pn[e].placeholder=pn}),Zt(["drop","take"],function(e,t){mn.prototype[e]=function(r){r=r===o?1:zr(qa(r),0);var n=this.__filtered__&&!t?new mn(this):this.clone();return n.__filtered__?n.__takeCount__=Vr(r,n.__takeCount__):n.__views__.push({size:Vr(r,M),type:e+(n.__dir__<0?"Right":"")}),n},mn.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}}),Zt(["filter","map","takeWhile"],function(e,t){var r=t+1,n=r==P||3==r;mn.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:jo(e,3),type:r}),t.__filtered__=t.__filtered__||n,t}}),Zt(["head","last"],function(e,t){var r="take"+(t?"Right":"");mn.prototype[e]=function(){return this[r](1).value()[0]}}),Zt(["initial","tail"],function(e,t){var r="drop"+(t?"":"Right");mn.prototype[e]=function(){return this.__filtered__?new mn(this):this[r](1)}}),mn.prototype.compact=function(){return this.filter(Pu)},mn.prototype.find=function(e){return this.filter(e).head()},mn.prototype.findLast=function(e){return this.reverse().find(e)},mn.prototype.invokeMap=Si(function(e,t){return"function"==typeof e?new mn(this):this.map(function(r){return ti(r,e,t)})}),mn.prototype.reject=function(e){return this.filter(ca(jo(e)))},mn.prototype.slice=function(e,t){e=qa(e);var r=this;return r.__filtered__&&(e>0||t<0)?new mn(r):(e<0?r=r.takeRight(-e):e&&(r=r.drop(e)),t!==o&&(r=(t=qa(t))<0?r.dropRight(-t):r.take(t-e)),r)},mn.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},mn.prototype.toArray=function(){return this.take(M)},Vn(mn.prototype,function(e,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),n=/^(?:head|last)$/.test(t),i=pn[n?"take"+("last"==t?"Right":""):t],s=n||/^find/.test(t);i&&(pn.prototype[t]=function(){var t=this.__wrapped__,a=n?[1]:arguments,u=t instanceof mn,c=a[0],f=u||ba(t),l=function(e){var t=i.apply(pn,ir([e],a));return n&&h?t[0]:t};f&&r&&"function"==typeof c&&1!=c.length&&(u=f=!1);var h=this.__chain__,p=!!this.__actions__.length,d=s&&!h,y=u&&!p;if(!s&&f){t=y?t:new mn(this);var g=e.apply(t,a);return g.__actions__.push({func:Fs,args:[l],thisArg:o}),new gn(g,h)}return d&&y?e.apply(this,a):(g=this.thru(l),d?n?g.value()[0]:g.value():g)})}),Zt(["pop","push","shift","sort","splice","unshift"],function(e){var t=ot[e],r=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",n=/^(?:pop|shift)$/.test(e);pn.prototype[e]=function(){var e=arguments;if(n&&!this.__chain__){var i=this.value();return t.apply(ba(i)?i:[],e)}return this[r](function(r){return t.apply(ba(r)?r:[],e)})}}),Vn(mn.prototype,function(e,t){var r=pn[t];if(r){var n=r.name+"";(nn[n]||(nn[n]=[])).push({name:t,func:r})}}),nn[fo(o,b).name]=[{name:"wrapper",func:o}],mn.prototype.clone=function(){var e=new mn(this.__wrapped__);return e.__actions__=Zi(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Zi(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Zi(this.__views__),e},mn.prototype.reverse=function(){if(this.__filtered__){var e=new mn(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},mn.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,r=ba(e),n=t<0,i=r?e.length:0,o=function(e,t,r){for(var n=-1,i=r.length;++n=this.__values__.length;return{done:e,value:e?o:this.__values__[this.__index__++]}},pn.prototype.plant=function(e){for(var t,r=this;r instanceof yn;){var n=ps(r);n.__index__=0,n.__values__=o,t?i.__wrapped__=n:t=n;var i=n;r=r.__wrapped__}return i.__wrapped__=e,t},pn.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof mn){var t=e;return this.__actions__.length&&(t=new mn(this)),(t=t.reverse()).__actions__.push({func:Fs,args:[Ts],thisArg:o}),new gn(t,this.__chain__)}return this.thru(Ts)},pn.prototype.toJSON=pn.prototype.valueOf=pn.prototype.value=function(){return Mi(this.__wrapped__,this.__actions__)},pn.prototype.first=pn.prototype.head,Tt&&(pn.prototype[Tt]=function(){return this}),pn}();Kt._=Ur,(i=function(){return Ur}.call(t,r,t,n))===o||(n.exports=i)}).call(this)}).call(this,r(7),r(27)(e))},function(e,t,r){"use strict";const n=r(52),i=r(23),o=r(1353),s=r(200).OFFLINE_ERROR;e.exports=function(e){return{peers:i((t,r)=>{if("function"==typeof t&&(r=t,t={}),!e.isOnline())return r(new Error(s));const n=t.v||t.verbose,i=[];o(e._peerInfoBook.getAll()).forEach(e=>{const t=e.isConnected();if(!t)return;const r={addr:t,peer:e.id};n&&(r.latency="unknown"),i.push(r)}),r(null,i)}),addrs:i(t=>{if(!e.isOnline())return t(new Error(s));t(null,o(e._peerInfoBook.getAll()))}),localAddrs:i(t=>{if(!e.isOnline())return t(new Error(s));t(null,e._libp2pNode.peerInfo.multiaddrs.toArray())}),connect:i((t,r)=>{if(!e.isOnline())return r(new Error(s));"string"==typeof t&&(t=n(t)),e._libp2pNode.dial(t,r)}),disconnect:i((t,r)=>{if(!e.isOnline())return r(new Error(s));"string"==typeof t&&(t=n(t)),e._libp2pNode.hangUp(t,r)}),filters:i(e=>e(new Error("Not implemented")))}}},function(e,t,r){var n=r(1354),i=r(356);e.exports=function(e){return null==e?[]:n(e,i(e))}},function(e,t,r){var n=r(223);e.exports=function(e,t){return n(t,function(t){return e[t]})}},function(e,t,r){"use strict";const n=r(23),i=r(70);e.exports=function(e){return n((t,r,n)=>{i(e.pingPullStream(t,r),i.collect(n))})}},function(e,t,r){"use strict";const n=r(1),i=r(200).OFFLINE_ERROR,o=r(98),s=r(8),a=r(46),u=r(5),c=n("jsipfs:pingPullStream");function f(e){return Object.assign({success:!0,time:0,text:""},e)}c.error=n("jsipfs:pingPullStream:error"),e.exports=function(e){return(t,r)=>{if(!e.isOnline())return s.error(new Error(i));r=Object.assign({count:10},r);const n=a();return u([r=>(function(e,t,r,n){let i;try{i=e.peerBook.get(r)}catch(i){c("Peer not found in peer book, trying peer routing"),t.push(f({text:`Looking up peer ${r}`}));try{r=o.createFromB58String(r)}catch(e){return n(Object.assign(e,{message:`failed to parse peer address '${r}': input isn't valid multihash`}))}return e.peerRouting.findPeer(r,n)}n(null,i)})(e._libp2pNode,n,t,r),(t,i)=>(function(e,t,r,n,i){e.ping(n,(e,o)=>{if(e)return i(e);c("Got peer",n);let s=0,a=0;return t.push(f({text:`PING ${n.id.toB58String()}`})),o.on("ping",e=>{if(t.push(f({time:e})),a+=e,++s>=r){const e=a/r;o.stop(),t.push(f({text:`Average latency: ${e}ms`})),t.end()}}),o.on("error",e=>{c.error(e),o.stop(),t.push(f({success:!1,text:e.toString()})),t.end(e)}),o.start(),i()})})(e._libp2pNode,n,r.count,t,i)],e=>{e&&(c.error(e),n.push(f({success:!1,text:e.toString()})),n.end(e))}),n}}},function(e,t,r){"use strict";const n=r(140);e.exports=function(e){return(t,r)=>n.source(e.pingPullStream(t,r))}},function(e,t,r){"use strict";(function(t){const n=r(23),{DAGNode:i,DAGLink:o}=r(41),s=r(9),a=r(280),{Key:u}=r(35),c=r(1359),{resolvePath:f}=r(200),l=300,h=new u("/local/pins");function p(e){return new s(e).toBaseEncodedString()}e.exports=(e=>{const r=e._repo,u=e.dag,d=c(u),y={direct:"direct",recursive:"recursive",indirect:"indirect",all:"all"};let g=new Set,m=new Set;const b=()=>Array.from(g).map(e=>new s(e).buffer),v=()=>Array.from(m).map(e=>new s(e).buffer);function _(n){let c,f,l;a.series([e=>a.waterfall([e=>d.storeSet(b(),e),(e,t)=>o.create(y.direct,e.size,e.multihash,t),(e,t)=>{c=e,t(null)}],e),e=>a.waterfall([e=>d.storeSet(v(),e),(e,t)=>o.create(y.recursive,e.size,e.multihash,t),(e,t)=>{f=e,t(null)}],e),e=>i.create(t.alloc(0),(t,r)=>{if(t)return e(t);u.put(r,{cid:new s(r.multihash),preload:!1},e)}),e=>i.create(t.alloc(0),[c,f],(t,r)=>{if(t)return e(t);l=r,u.put(l,{cid:new s(l.multihash),preload:!1},e)}),e=>r.closed?r.open(e):e(null,null),e=>r.datastore.put(h,l.multihash,e)],(t,r)=>t?n(t):(e.log(`Flushed pins with root: ${l}`),n(null,l)))}const w={add:n((t,r,n)=>{"function"==typeof r&&(n=r,r=null);const i=!r||r.recursive;f(e.object,t,(e,t)=>{if(e)return n(e);a.map(t,(e,t)=>{const r=p(e);if(i){if(m.has(r))return t(null,r);u._getRecursive(r,e=>e?t(e):t(null,r))}else{if(m.has(r))return t(new Error(`${r} already pinned recursively`));if(g.has(r))return t(null,r);u.get(new s(e),e=>e?t(e):t(null,r))}},(e,t)=>{if(e)return n(e);const r=i?m:g;t.forEach(e=>r.add(e)),_((e,r)=>e?n(e):n(null,t.map(e=>({hash:e}))))})})}),rm:n((t,r,n)=>{let i=!0;"function"==typeof r?n=r:r&&!1===r.recursive&&(i=!1),f(e.object,t,(t,r)=>{if(t)return n(t);a.map(r,(e,t)=>{w._isPinnedWithType(e,y.all,(r,n)=>{if(r)return t(r);const{pinned:o,reason:s}=n,a=p(e);if(!o)return t(new Error(`${a} is not pinned`));switch(s){case y.recursive:return i?t(null,a):t(new Error(`${a} is pinned recursively`));case y.direct:return t(null,a);default:return t(new Error(`${a} is pinned indirectly under ${s}`))}})},(t,r)=>{if(t)return n(t);r.forEach(e=>{i&&m.has(e)?m.delete(e):g.delete(e)}),_((t,i)=>t?n(t):(e.log(`Removed pins: ${r}`),n(null,r.map(e=>({hash:e})))))})})}),ls:n((t,r,n)=>{let i=y.all;if("function"==typeof t&&(n=t,r=null,t=null),"function"==typeof r&&(n=r),t&&t.type&&(r=t,t=null),r&&r.type&&(i=r.type.toLowerCase()),!y[i])return n(new Error(`Invalid type '${i}', must be one of {direct, indirect, recursive, all}`));if(t)f(e.object,t,(e,t)=>{if(e)return n(e);a.mapSeries(t,(e,t)=>{w._isPinnedWithType(e,y.all,(r,n)=>{if(r)return t(r);const{pinned:i,reason:o}=n,s=p(e);if(!i)return t(new Error(`Path ${s} is not pinned`));switch(o){case y.direct:case y.recursive:return t(null,{hash:s,type:o});default:return t(null,{hash:s,type:`${y.indirect} through ${o}`})}})},n)});else{let e=[];if(i!==y.direct&&i!==y.all||(e=e.concat(Array.from(g).map(e=>({type:y.direct,hash:e})))),i!==y.recursive&&i!==y.all||(e=e.concat(Array.from(m).map(e=>({type:y.recursive,hash:e})))),i!==y.indirect&&i!==y.all)return n(null,e);!function(e){const t=new Set;a.eachLimit(v(),l,(e,r)=>{u._getRecursive(e,(e,n)=>{if(e)return r(e);n.map(({multihash:e})=>p(e)).filter(e=>!m.has(e)).forEach(e=>t.add(e)),r()})},r=>{if(r)return e(r);e(null,Array.from(t))})}((t,r)=>t?n(t):(e=e.filter(({hash:e})=>!r.includes(e)||r.includes(e)&&!g.has(e)).concat(r.map(e=>({type:y.indirect,hash:e}))),n(null,e)))}}),_isPinnedWithType:n((e,t,r)=>{const n=p(e),{recursive:i,direct:o,all:c}=y;if((t===i||t===c)&&m.has(n))return r(null,{pinned:!0,reason:i});if(t===i)return r(null,{pinned:!1});if((t===o||t===c)&&g.has(n))return r(null,{pinned:!0,reason:o});if(t===o)return r(null,{pinned:!1});let f;a.someLimit(v(),l,(t,r)=>{u.get(new s(t),(t,n)=>{if(t)return r(t);d.hasDescendant(n.value,e,(e,t)=>{t&&(f=p(n.value.multihash)),r(e,t)})})},(e,t)=>e?r(e):r(null,{pinned:t,reason:f}))}),_load:n(t=>{a.waterfall([e=>r.closed?r.datastore.open(e):e(null,null),(e,t)=>r.datastore.has(h,t),(e,t)=>e?t():t(new Error("No pins to load")),e=>r.datastore.get(h,e),(e,t)=>u.get(new s(e),"",{preload:!1},t)],(r,n)=>{if(r)return"No pins to load"===r.message?(e.log("No pins to load"),t()):t(r);a.parallel([e=>d.loadSet(n.value,y.recursive,e),e=>d.loadSet(n.value,y.direct,e)],(r,n)=>{if(r)return t(r);const[i,o]=n;return g=new Set(o.map(p)),m=new Set(i.map(p)),e.log("Loaded pins from the datastore"),t(null)})})})};return w})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(12),i=r(9),o=r(11),s=r(1360),a=r(20),{DAGNode:u,DAGLink:c}=r(41),f=r(280),l=r(1361),h=n.fromB58String("QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n"),p=256,d=8192,y=o(l);function g(e){return new i(e).toBaseEncodedString()}function m(e,r){const n=t.alloc(4);n.writeUInt32LE(e,0);const i=t.concat([n,t.from(g(r))]);return s(i.toString("binary"))}e.exports=function(e){const r={hasDescendant:(r,n,o)=>{const s={};return(i.isCID(n)||t.isBuffer(n))&&(n=g(n)),function t(r,i){f.some(r.links,({multihash:r},i)=>{const o=g(r);return o===n?i(null,!0):o in s?i(null,!1):(s[o]=!0,void e.get(r,"",{preload:!1},(e,r)=>{if(e)return i(e);t(r.value,i)}))},i)}(r,o)},storeSet:(t,n)=>{const o=t.map(e=>({key:e,data:null}));r.storeItems(o,(t,r)=>{if(t)return n(t);const o={cid:new i(r.multihash),preload:!1};e.put(r,o,(e,t)=>{if(e)return n(e);n(null,r)})})},storeItems:(r,n)=>{return function r(n,o,s){const l=y.Set.encode({version:1,fanout:p,seed:o}),g=t.concat([t.from(a.encode(l.length)),l]),b=[];for(let e=0;e({link:new c("",1,e.key),data:e.data||t.alloc(0)})).sort((e,r)=>t.compare(e.link.multihash,r.link.multihash)),r=b.concat(e.map(e=>e.link)),i=t.concat([g].concat(e.map(e=>e.data)));u.create(i,r,(e,t)=>e?s(e):s(null,t))}else{const e=n.reduce((e,t)=>{const r=m(o,t.key)%p;return e[r]=r in e?e[r].concat([t]):[t],e},{});f.eachOf(e,(e,t,n)=>{r(e,o+1,(e,r)=>v(e,r,t,n))},e=>{if(e)return s(e);u.create(g,b,(e,t)=>e?s(e):s(null,t))})}function v(t,r,n,o){if(t)return o(t);const s={cid:new i(r._multihash),preload:!1};e.put(r,s,e=>{if(e)return o(e);b[n]=new c("",r.size,r.multihash),o(null)})}}(r,0,n)},loadSet:(t,n,i)=>{const o=t.links.find(e=>e.name===n);if(!o)return i(new Error("No link found with name "+n));e.get(o.multihash,"",{preload:!1},(e,t)=>{if(e)return i(e);const n=[];r.walkItems(t.value,e=>n.push(e.multihash),e=>e?i(e):i(null,n))})},walkItems:(t,n,i)=>{let o;try{o=function(e){const t=e.data,r=a.decode(t),n=a.decode.bytes;if(n<=0)throw new Error("Invalid Set header length");if(n+r>t.length)throw new Error("Impossibly large set header length");const i=t.slice(n,r+n),o=y.Set.decode(i);if(1!==o.version)throw new Error(`Unsupported Set version: ${o.version}`);if(o.fanout>e.links.length)throw new Error("Impossibly large fanout");return{header:o,data:t.slice(r+n)}}(t)}catch(e){return i(e)}f.eachOf(t.links,(t,i,s)=>{if(i{if(e)return s(e);r.walkItems(t.value,n,s)})}else n(t,i,o.data);s(null)},i)}};return r}}).call(this,r(0).Buffer)},function(e,t){function r(e){for(var t=r.BASE,n=0,i=e.length;n>>0}r.BASE=2166136261,e.exports=r},function(e,t,r){"use strict";e.exports='\n syntax = "proto2";\n\n package ipfs.pin;\n\n option go_package = "pb";\n\n message Set {\n optional uint32 version = 1;\n optional uint32 fanout = 2;\n optional fixed32 seed = 3;\n }\n'},function(e,t,r){"use strict";(function(t,n){const i=r(145),o=i.importer,s=i.exporter,a=r(23),u=r(8),c=r(1393),f=r(46),l=r(140),h=r(192),p=r(225),d=r(5),y=r(587),g=r(588).isSource,m=r(22).Duplex,b=r(0).Buffer,v=r(9),_=r(12).toB58String,w="wrapper/";function S(){}function k(e,t,r,n){t=t||{};let i=new v(r.multihash);1===t.cidVersion&&(i=i.toV1()),d([n=>t.onlyHash?n(null,r):e.object.get(r.multihash,t,n),(e,n)=>{const o=i.toBaseEncodedString();n(null,{path:t.wrapWithDirectory?r.path.substring(w.length):r.path||o,hash:o,size:e.size})}],n)}function E(e,r){return Array.isArray(r)||(r=[r]),r.map(r=>{if(t.isBuffer(r)&&(r={path:"",content:u.values([r])}),y.readable(r)&&(r={path:"",content:h.source(r)}),g(r)&&(r={path:"",content:r}),r&&r.content&&"function"!=typeof r.content&&(t.isBuffer(r.content)&&(r.content=u.values([r.content])),y.readable(r.content)&&(r.content=h.source(r.content))),e.wrapWithDirectory&&!r.path)throw new Error("Must provide a path when wrapping with a directory");return e.wrapWithDirectory&&(r.path=w+r.path),r})}function A(e){return t.isBuffer(e)&&(e=_(e)),v.isCID(e)&&(e=e.toBaseEncodedString()),0===e.indexOf("/ipfs/")&&(e=e.substring("/ipfs/".length)),"/"===e.charAt(e.length-1)&&(e=e.substring(0,e.length-1)),e}e.exports=function(e){function r(t){const r=Object.assign({},{shardSplitThreshold:e._options.EXPERIMENTAL.sharding?1e3:1/0},t);r.hashAlg&&1!==r.cidVersion&&(r.cidVersion=1);let n=0;const i=r.progress||S;return r.progress=(e=>{i(n+=e)}),u(u.map(E.bind(null,r)),u.flatten(),o(e._ipld,r),u.asyncMap(k.bind(null,e,r)),u.map(function(e,t,r){return(t.wrapWithDirectory?""===r.path:!r.path.includes("/"))&&!t.onlyHash&&!1!==t.preload&&e._preload(r.hash),r}.bind(null,e,r)),u.asyncMap(function(e,t,r,n){const i=!("pin"in t)||t.pin,o=!r.path.includes("/");if(i&&o&&!t.onlyHash&&!t.hashAlg)return e.pin.add(r.hash,e=>n(e,r));n(null,r)}.bind(null,e,r)))}function i(t,r){if("function"==typeof t)throw new Error("You must supply an ipfsPath");r=r||{};const n=(t=A(t)).split("/"),i=A(n.slice(1).join("/")),o=e=>i&&e.path===i||e.path===t;!1!==r.preload&&e._preload(n[0]);const a=p.source();return u(s(t,e._ipld,r),u.collect((e,t)=>{if(e)return a.abort(e);if(t&&t.length>1&&(t=t.filter(o)),!t||!t.length)return a.abort(new Error("No such file"));const r=t[0],n=r.content;if(!n&&"dir"===r.type)return a.abort(new Error("this dag node is a directory"));a.resolve(n)})),a}function h(t,r){r=r||{};const i=A(t),o=r.recursive,a=i.split("/"),c=a.length,f=o?n.Infinity:c;return r.maxDepth=r.maxDepth||f,!1!==r.preload&&e._preload(a[0]),u(s(t,e._ipld,r),u.filter(e=>o?e.depth>=c:e.depth===c),u.map(e=>{const t=new v(e.hash);return delete(e=Object.assign({},e,{hash:t.toBaseEncodedString()})).content,e}))}return{add:(()=>{const e=a((e,n={},i)=>{if("function"==typeof n?(i=n,n={}):i&&"function"==typeof i||(i=S),!(t.isBuffer(e)||y.readable(e)||Array.isArray(e)||b.isBuffer(e)||"object"==typeof e||g(e)))return i(new Error("first arg must be a buffer, readable stream, pull stream, an object or array of objects"));n.hashAlg&&1!==n.cidVersion&&(n.cidVersion=1),u(u.values([e]),r(n),c((e,t)=>e.patht.path?-1:0),u.collect(i))});return function(){const t=Array.from(arguments);return 1===t.length&&g(t[0])&&t.push({}),e.apply(null,t)}})(),addReadableStream:e=>{e=e||{};const t=f(),n=new class extends m{constructor(e,t,r){super(Object.assign({objectMode:!0},r)),this._pullStream=e,this._pushable=t,this._waitingPullFlush=[]}_read(){this._pullStream(null,(e,t)=>{for(;this._waitingPullFlush.length;)this._waitingPullFlush.shift()();e?e instanceof Error&&this.emit("error",e):this.push(t)})}_write(e,t,r){this._waitingPullFlush.push(r),this._pushable.push(e)}}(u(t,r(e)),t);return n.once("finish",()=>t.end()),n},addPullStream:r,cat:a((e,r,n)=>{if("function"==typeof r&&(n=r,r={}),"function"!=typeof n)throw new Error("Please supply a callback to ipfs.files.cat");u(i(e,r),u.collect((e,r)=>{if(e)return n(e);n(null,t.concat(r))}))}),catReadableStream:(e,t)=>l.source(i(e,t)),catPullStream:(e,t)=>i(e,t),get:a((r,n,i)=>{if("function"==typeof n&&(i=n,n={}),!1!==(n=n||{}).preload){const t=A(r).split("/");e._preload(t[0])}u(s(r,e._ipld,n),u.asyncMap((e,r)=>{e.content?u(e.content,u.collect((n,i)=>{if(n)return r(n);e.content=t.concat(i),r(null,e)})):r(null,e)}),u.collect(i))}),getReadableStream:(t,r)=>{if(!1!==(r=r||{}).preload){const r=A(t).split("/");e._preload(r[0])}return l.source(u(s(t,e._ipld,r),u.map(e=>(e.content&&(e.content=l.source(e.content),e.content.pause()),e))))},getPullStream:(t,r)=>{if(!1!==(r=r||{}).preload){const r=A(t).split("/");e._preload(r[0])}return s(t,e._ipld,r)},lsImmutable:a((t,r,n)=>{if("function"==typeof r&&(n=r,r={}),!1!==(r=r||{}).preload){const r=A(t).split("/");e._preload(r[0])}u(h(t,r),u.collect((e,t)=>{e?n(e):n(null,t)}))}),lsReadableStreamImmutable:(t,r)=>{if(!1!==(r=r||{}).preload){const r=A(t).split("/");e._preload(r[0])}return l.source(h(t,r))},lsPullStreamImmutable:h}}}).call(this,r(0).Buffer,r(7))},function(e,t,r){"use strict";(function(t){const n=r(586),i=r(8),o=r(201),s=r(46),a=r(16),u=r(3),c=r(1365),f=r(1374),l={fixed:r(1383)},h={chunker:"fixed",rawLeaves:!1,hashOnly:!1,cidVersion:0,hash:null,leafType:"file",hashAlg:"sha2-256"};e.exports=function(e,r){const p=Object.assign({},h,r);p.cidVersion=p.cidVersion||0,p.cidVersion>0&&void 0===r.rawLeaves&&(p.rawLeaves=!0),r&&void 0!==r.hash&&void 0===r.rawLeaves&&(p.rawLeaves=!0);const d=l[p.chunker];a(d,"Unknkown chunker named "+p.chunker);let y=0;const g=[],m={sink:o((e,t)=>{y+=e.length,e.forEach(e=>m.source.push(e)),u(t)},null,1,e=>m.source.end(e)),source:s()},b=c(d,e,p),v=f(e,p),_=v.stream(),w=n(()=>{});return i(m,w,b,i.map(e=>(--y||t.nextTick(()=>{for(;g.length;)g.shift()()}),e)),_),{sink:m.sink,source:_.source,flush:function(e){function t(){v.flush((t,r)=>{if(t)return _.source.end(t),void e(t);w.resume(),e(null,r)})}w.pause(),y?g.push(t):t()}}}}).call(this,r(6))},function(e,t){e.exports=function(e){var t=!1,r=0;return function(){if(r=!0,!t){for(t=!0;r;)r=!1,e();t=!1}}}},function(e,t,r){"use strict";const n=r(16),i=r(1366),o=r(1367),s={flat:r(1369),balanced:r(1370),trickle:r(1372)},a={strategy:"balanced",highWaterMark:100,reduceSingleLeafToSelf:!0};e.exports=function(e,t,r){n(e,"Missing chunker creator function"),n(t,"Missing IPLD");const u=Object.assign({},a,r),c=u.strategy,f=s[c];n(f,"Unknown importer build strategy name: "+c);const l=o(e,t,f,u);return i(l,t,u)}},function(e,t,r){"use strict";const n=r(46),i=r(201);e.exports=function(e,t,r){const o=n(),s=i(e(o),null,r.highWaterMark,e=>o.end(e));return{source:o,sink:s}}},function(e,t,r){"use strict";(function(t){const n=r(274),i=r(36),o=r(8),s=r(202),a=r(59),u=r(5),c=r(41),f=r(9),l=r(61),h=r(1368),p=c.DAGNode,d={chunkerOptions:{maxChunkSize:262144},rawLeaves:!1,hashAlg:"sha2-256",leafType:"file",cidVersion:0};e.exports=function(e,r,c,y){const g=n({},d,y);return g.cidVersion=g.cidVersion||g.cidVersion,g.hashAlg=g.hashAlg||d.hashAlg,"sha2-256"!==g.hashAlg&&(g.cidVersion=1),function(e){return function(t,n){a(t.map(t=>n=>{if(!t.content)return function(e,t){const n=new i("directory");u([e=>p.create(n.marshal(),[],g.hashAlg,e),(e,t)=>{if(g.onlyHash)return t(null,e);e.cid=new f(g.cidVersion,"dag-pb",e.multihash),r.put(e,{cid:e.cid},r=>t(r,e))}],(r,n)=>{if(r)return t(r);t(null,{path:e.path,multihash:n.cid.buffer,size:n.size})})}(t,(t,r)=>{if(t)return n(t);r&&e.push(r),n()});m(t,(t,r)=>{if(t)return n(t);r&&e.push(r),n()})}),n)}};function m(n,a){if(t.isBuffer(n.content)&&(n.content=o.values([n.content])),"function"!=typeof n.content)return a(new Error("invalid content"));const u=c(h(n,r,g),g);let d,y=0;o(n.content,e(g.chunkerOptions),o.map(e=>(g.progress&&"function"==typeof g.progress&&g.progress(e.byteLength),t.from(e))),o.asyncMap((e,t)=>{if(g.rawLeaves)return l(e,g.hashAlg,(r,n)=>r?t(r):t(null,{multihash:n,size:e.length,leafSize:e.length,cid:new f(1,"raw",n),data:e}));const r=new i(g.leafType,e);p.create(r.marshal(),[],g.hashAlg,(e,n)=>{if(e)return t(e);t(null,{multihash:n.multihash,size:n.size,leafSize:r.fileSize(),cid:new f(g.cidVersion,"dag-pb",n.multihash),data:n})})}),o.asyncMap((e,t)=>{if(g.onlyHash)return t(null,e);r.put(e.data,{cid:e.cid},r=>t(r,e))}),o.map(e=>({path:n.path,multihash:e.cid.buffer,size:e.size,leafSize:e.leafSize,name:"",cid:e.cid})),s(function(e){y++,d&&this.queue(d),d=e},function(){d&&(1===y&&(d.single=!0),this.queue(d)),this.queue(null)}),u,o.collect((e,t)=>{e?a(e):a(null,t[0])}))}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(5),i=r(41),o=r(36),s=r(9),a=i.DAGLink,u=i.DAGNode;e.exports=function(e,t,r){return function(i,c){if(1===i.length&&i[0].single&&r.reduceSingleLeafToSelf){const a=i[0];return"file"!==r.leafType||r.rawLeaves?n([e=>t.get(a.cid,e),(e,t)=>{const n=e.value.data,i=new o("file",n);u.create(i.marshal(),[],r.hashAlg,(e,r)=>{t(e,{DAGNode:r,fileNode:i})})},(e,n)=>{if(r.onlyHash)return n(null,e);let i=new s(e.DAGNode.multihash);1===r.cidVersion&&(i=i.toV1()),t.put(e.DAGNode,{cid:i},t=>n(t,e))},(t,r)=>{r(null,{path:e.path,multihash:t.DAGNode.multihash,size:t.DAGNode.size,leafSize:t.fileNode.fileSize(),name:a.name})}],c):c(null,{path:e.path,multihash:a.multihash,size:a.size,leafSize:a.leafSize,name:a.name})}const f=new o("file"),l=i.map(e=>{f.addBlockSize(e.leafSize);let t=e.cid;return t||(t=new s(r.cidVersion,"dag-pb",e.multihash)),new a(e.name,e.size,t.buffer)});n([e=>u.create(f.marshal(),l,r.hashAlg,e),(e,n)=>{const i=new s(r.cidVersion,"dag-pb",e.multihash);if(r.onlyHash)return n(null,{node:e,cid:i});t.put(e,{cid:i},t=>n(t,{node:e,cid:i}))}],(t,r)=>{if(t)return c(t);c(null,{name:"",path:e.path,multihash:r.cid.buffer,size:r.node.size,leafSize:f.fileSize()})})}}},function(e,t,r){"use strict";const n=r(8),i=r(46),o=r(194),s=r(320);e.exports=function(e,t){const r=o(),a=r.source,u=i();return n(a,s(1/0),n.asyncMap(e),n.collect((e,t)=>{e?u.end(e):1===t.length?(u.push(t[0]),u.end()):t.length>1?u.end(new Error("expected a maximum of 1 roots and got "+t.length)):u.end()})),{sink:r.sink,source:u}}},function(e,t,r){"use strict";const n=r(1371),i={maxChildrenPerNode:174};e.exports=function(e,t){const r=Object.assign({},i,t);return n(e,r)}},function(e,t,r){"use strict";const n=r(8),i=r(46),o=r(194),s=r(320);e.exports=function(e,t){const r=o(),a=r.source,u=i();return function r(i,o){let a=i;Array.isArray(a)&&(a=n.values(a)),n(a,s(t.maxChildrenPerNode),n.asyncMap(e),n.collect(function(e,t){e?o(e):t.length>1?r(t,o):o(null,t)}))}(a,(e,t)=>{e?u.end(e):1===t.length?(u.push(t[0]),u.end()):t.length>1?u.end(new Error("expected a maximum of 1 roots and got "+t.length)):u.end()}),{sink:r.sink,source:u}}},function(e,t,r){"use strict";const n=r(1373),i={maxChildrenPerNode:174,layerRepeat:4};e.exports=function(e,t){const r=Object.assign({},i,t);return n(e,r)}},function(e,t,r){"use strict";const n=r(8),i=r(46),o=r(320),s=r(194),a=r(202),u=r(201),c=r(586);e.exports=function(e,t){const r=s(),f=i(),l=c(()=>{});let h=0;return n(r.source,l,function(r,s){let c,f=0,d=0,y=!1;const g=i();return{source:g,sink:u(function(t,s){let u=!1;const f=t[0];d&&!c&&(c=i(),n(c,p(r+1,d-1),a(function(e){this.queue(e)},function(e){e?this.emit("error",e):(u||(u=!0,h++,l.pause()),this.queue(null))}),o(1/0),n.asyncMap(e),n.collect((e,t)=>{h--,e?g.end(e):(t.forEach(e=>{g.push(e)}),m())}))),c?c.push(f):(g.push(f),m()),s()},null,1,function(e){e?g.end(e):c?y||(y=!0,c.end()):g.end()})};function m(){c=null,f++,(0===d&&f===t.maxChildrenPerNode||d>0&&f===t.layerRepeat)&&(f=0,d++),(!y&&s>=0&&d>s||y&&!h)&&(y=!0,g.end()),h||l.resume()}}(0,-1),o(1/0),n.asyncMap(e),n.collect((e,t)=>{e?f.end(e):1===t.length?(f.push(t[0]),f.end()):t.length>1?f.end(new Error("expected a maximum of 1 roots and got "+t.length)):f.end()})),{sink:r.sink,source:f};function p(r,s){let c=0,f=0,d,y=!1;const g=i();return{source:g,sink:u(m,null,1,v)};function m(t,s){let u=!1;const c=t[0];f&&!d&&(d=i(),n(d,p(r+1,f-1),a(function(e){this.queue(e)},function(e){e?this.emit("error",e):(u||(u=!0,h++,l.pause()),this.queue(null))}),o(1/0),n.asyncMap(e),n.collect((e,t)=>{h--,e?g.end(e):(t.forEach(e=>{g.push(e)}),b())}))),d?d.push(c):(g.push(c),b()),s()}function b(){d=null,c++,(0===f&&c===t.maxChildrenPerNode||f>0&&c===t.layerRepeat)&&(c=0,f++),(!y&&s>=0&&f>s||y&&!h)&&(y=!0,g.end()),h||l.resume()}function v(e){e?g.end(e):d?y||(y=!0,d.end()):g.end()}}}},function(e,t,r){"use strict";(function(t){const n=r(188),i=r(216),o=r(5),s=r(162),a=r(201),u=r(46),c=r(1375),f=r(1376),l=r(321);e.exports=function(e,r){const d=Object.assign({},h,r),y=s(function(e,t){const r=e.args.concat(function(){e.cb.apply(null,arguments),t()});e.fn.apply(null,r)},1);let g=function(){const e=a(function(e,r){n(e,(e,r)=>{y.push({fn:b,args:[e],cb:n=>{n?r(n):(t.push(e),r())}})},r)},null,1,function(e){v(r=>{t.end(r||e)})}),t=u();return{sink:e,source:t}}(),m=c({path:"",root:!0,dir:!0,dirty:!1,flat:!0},d);return{flush:v,stream:function(){return g}};function b(e,t){const r=(e.path||"").split("/").filter(p);let n=m;const s=r.length-1;let a="";i(r,(t,r,i)=>{a&&(a+="/"),a+=t;const u=r===s;n.dirty=!0,n.multihash=null,n.size=null,u?o([r=>n.put(t,e,r),e=>f(null,n,d.shardSplitThreshold,d,e),(e,t)=>{m=e,t()}],i):n.get(t,(e,r)=>{if(e)return void i(e);let o=r;o&&o instanceof l||(o=c({dir:!0,parent:n,parentKey:t,path:a,dirty:!0,flat:!0},d));const s=n;n=o,s.put(t,o,i)})},t)}function v(e){y.push({fn:_,args:["",m],cb:(t,r)=>{t?e(t):e(null,r&&r.multihash)}})}function _(e,r,n){if(r.dir){if(r.root&&r.childCount()>1&&!d.wrap)return void n(new Error("detected more than one root"));r.eachChildSeries((t,r,n)=>{_(e?e+"/"+t:t,r,n)},t=>{t?n(t):w(e,r,n)})}else t.nextTick(n)}function w(t,r,n){!r.root||d.wrap?r.dirty?(r.dirty=!1,r.flush(t,e,g.source,(e,t)=>{e?n(e):n(null,t)})):n(null,r.multihash):r.onlyChild((e,t)=>{e?n(e):n(null,t)})}};const h={wrap:!1,shardSplitThreshold:1e3,onlyHash:!1};function p(e){return Boolean(e)}}).call(this,r(6))},function(e,t,r){"use strict";(function(t){const n=r(188),i=r(5),o=r(9),s=r(41),a=r(36),u=s.DAGLink,c=s.DAGNode,f=r(321);class l extends f{constructor(e,t){super(e,t),this._children={}}put(e,r,n){this.multihash=void 0,this.size=void 0,this._children[e]=r,t.nextTick(n)}get(e,r){t.nextTick(()=>r(null,this._children[e]))}childCount(){return Object.keys(this._children).length}directChildrenCount(){return this.childCount()}onlyChild(e){t.nextTick(()=>e(null,this._children[Object.keys(this._children)[0]]))}eachChildSeries(e,t){n(Object.keys(this._children),(t,r)=>{e(t,this._children[t],r)},t)}flush(e,t,r,n){const s=Object.keys(this._children).map(e=>{const t=this._children[e];return new u(e,t.size,t.multihash)}),f=new a("directory"),l=this._options;i([e=>c.create(f.marshal(),s,l.hashAlg,e),(e,r)=>{if(l.onlyHash)return r(null,e);let n=new o(e.multihash);1===l.cidVersion&&(n=n.toV1()),t.put(e,{cid:n},t=>r(t,e))},(t,n)=>{this.multihash=t.multihash,this.size=t.size;const i={path:e,multihash:t.multihash,size:t.size};r.push(i),n(null,t)}],n)}}e.exports=function(e,t){return new l(e,t)}}).call(this,r(6))},function(e,t,r){"use strict";const n=r(5),i=r(1377);function o(e,t,r,n){e.flat&&e.directChildrenCount()>=t?function(e,t,r){const n=i({root:e.root,dir:!0,parent:e.parent,parentKey:e.parentKey,path:e.path,dirty:e.dirty,flat:!1},t);e.eachChildSeries((e,t,r)=>{n.put(e,t,r)},e=>{e?r(e):r(e,n)})}(e,r,n):n(null,e)}e.exports=function e(t,r,i,s,a){o(r,i,s,(o,u)=>{if(o)return void a(o);const c=u.parent;c?n([e=>{u!==r?(t&&(t.parent=u),c.put(u.parentKey,u,e)):e()},t=>{c?e(u,c,i,s,t):t(null,u)}],a):a(null,u)})}},function(e,t,r){"use strict";(function(t){const n=r(367),i=r(40),o=r(5),s=r(9),a=r(41),u=r(36),c=a.DAGLink,f=a.DAGNode,l=r(61),h=r(321),p=r(1378),d=function(e,r){l(e,"murmur3-128",(e,n)=>{if(e)r(e);else{const e=n.slice(2,10),i=e.length,o=t.alloc(i);for(let t=0;t{e?n(e):(this.multihash=t.multihash,this.size=t.size),n(null,t)})}}function m(e,r,a,l,h,d){const y=r._children;let g=0;const b=[];function v(t,r,i){const o=n(r.toString(16).toUpperCase(),2,"0");if(p.isBucket(t))m(e,t,a,l,null,(e,t)=>{e?i(e):(b.push(new c(o,t.size,t.multihash)),i())});else{const e=t.value,r=o+t.key;b.push(new c(r,e.size,e.multihash)),i()}}function _(n){const i=t.from(y.bitField().reverse()),c=new u("hamt-sharded-directory",i);c.fanout=r.tableSize(),c.hashType=e.hashFn.code,o([t=>f.create(c.marshal(),n,e.hashAlg,t),(t,r)=>{if(e.onlyHash)return r(null,t);let n=new s(t.multihash);1===e.cidVersion&&(n=n.toV1()),l.put(t,{cid:n},e=>r(e,t))},(e,t)=>{const r={path:a,multihash:e.multihash,size:e.size};h&&h.push(r),t(null,e)}],d)}i(()=>g{const t=y.get(g);t?v(t,g,t=>{g++,e(t)}):(g++,e())},e=>{e?d(e):_(b)})}e.exports=function(e,t){return new g(e,t)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(1379);e.exports=function(e){return new n(e)},e.exports.isBucket=n.isBucket},function(e,t,r){"use strict";(function(t){const n=r(1380),i=r(80),o=r(188),s=r(1381),a={bits:8};class u{constructor(e,t,r){if(this._options=Object.assign({},a,e),this._popCount=0,this._parent=t,this._posAtParent=r,!this._options.hashFn)throw new Error("please define an options.hashFn");this._options.hash||(this._options.hash=s(this._options.hashFn)),this._children=new n}static isBucket(e){return e instanceof u}put(e,t,r){this._findNewBucketAndPos(e,(n,i)=>{n?r(n):(i.bucket._putAt(i,e,t),r())})}get(e,t){this._findChild(e,(e,r)=>{e?t(e):t(null,r&&r.value)})}del(e,t){this._findPlace(e,(r,n)=>{if(r)return void t(r);const i=n.bucket._at(n.pos);i&&i.key===e&&n.bucket._delAt(n.pos),t(null)})}leafCount(){this._children.reduce((e,t)=>t instanceof u?e+t.leafCount():e+1,0)}childrenCount(){return this._children.length}onlyChild(e){t.nextTick(()=>e(null,this._children.get(0)))}eachLeafSeries(e,t){o(this._children.compactArray(),(t,r)=>{t instanceof u?t.eachLeafSeries(e,r):e(t.key,t.value,r)},t)}serialize(e,t){return t(this._children.reduce((r,n,i)=>(n&&(n instanceof u?r.push(n.serialize(e,t)):r.push(e(n,i))),r),[]))}asyncTransform(e,t,r){!function e(t,r,n,o){i(t._children.compactArray(),(i,o)=>{i instanceof u?e(i,r,n,o):r(i,(e,r)=>{e?o(e):o(null,{bitField:t._children.bitField(),children:r})})},(e,t)=>{e?o(e):n(t,o)})}(this,e,t,r)}toJSON(){return this.serialize(f,l)}prettyPrint(){return JSON.stringify(this.toJSON(),null," ")}tableSize(){return Math.pow(2,this._options.bits)}_findChild(e,t){this._findPlace(e,(r,n)=>{if(r)return void t(r);const i=n.bucket._at(n.pos);i&&i.key===e?t(null,i):t(null,void 0)})}_findPlace(e,t){const r=this._options.hash(e);r.take(this._options.bits,(e,n)=>{if(e)return void t(e);const i=this._children.get(n);if(i instanceof u)i._findPlace(r,t);else{t(null,{bucket:this,pos:n,hash:r})}})}_findNewBucketAndPos(e,t){this._findPlace(e,(r,n)=>{if(r)return void t(r);const i=n.bucket._at(n.pos);if(i&&i.key!==e){const e=new u(this._options,n.bucket,n.pos);n.bucket._putObjectAt(n.pos,e),e._findPlace(i.hash,(r,o)=>{r?t(r):(o.bucket._putAt(o,i.key,i.value),e._findNewBucketAndPos(n.hash,t))})}else t(null,n)})}_putAt(e,t,r){this._putObjectAt(e.pos,{key:t,value:r,hash:e.hash})}_putObjectAt(e,t){this._children.get(e)||this._popCount++,this._children.set(e,t)}_delAt(e){this._children.get(e)&&this._popCount--,this._children.unset(e),this._level()}_level(){if(this._parent&&this._popCount<=1)if(1===this._popCount){const e=this._children.find(c);if(!(e instanceof u)){const t=e.hash;t.untake(this._options.bits);const r={pos:this._posAtParent,hash:t};this._parent._putAt(r,e.key,e.value)}}else this._parent._delAt(this._posAtParent)}_at(e){return this._children.get(e)}}function c(e){return Boolean(e)}function f(e,t){return e.key}function l(e){return e}e.exports=u}).call(this,r(6))},function(e,t,r){"use strict";function n(e,t){return e+i(t)}function i(e){let t=e;return 16843009*((t=(858993459&(t-=t>>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135)>>24}function o(e,t){return e[0]-t[0]}function s(e){return e[1]}e.exports=class{constructor(){this._bitArrays=[],this._data=[],this._length=0,this._changedLength=!1,this._changedData=!1}set(e,t){let r=this._internalPositionFor(e,!1);if(void 0===t)-1!==r&&(this._unsetInternalPos(r),this._unsetBit(e),this._changedLength=!0,this._changedData=!0);else{let n=!1;-1===r?(r=this._data.length,this._setBit(e),this._changedData=!0):n=!0,this._setInternalPos(r,e,t,n),this._changedLength=!0}}unset(e){this.set(e,void 0)}get(e){this._sortData();const t=this._internalPositionFor(e,!0);if(-1!==t)return this._data[t][1]}push(e){return this.set(this.length,e),this.length}get length(){if(this._sortData(),this._changedLength){const e=this._data[this._data.length-1];this._length=e?e[0]+1:0,this._changedLength=!1}return this._length}forEach(e){let t=0;for(;t=this._bitArrays.length)return-1;const o=this._bitArrays[r],s=e-7*r;return(o&1<0?this._bitArrays.slice(0,r).reduce(n,0)+i(o&~(4294967295<=t)i.push(o);else if(i[0][0]<=t)i.unshift(o);else{const e=Math.round(i.length/2);this._data=i.slice(0,e).concat(o).concat(i.slice(e))}else this._data.push(o);this._changedData=!0,this._changedLength=!0}}_unsetInternalPos(e){this._data.splice(e,1)}_sortData(){this._changedData&&this._data.sort(o)}bitField(){const e=[];let t,r=8,n=0,i=0;const o=this._bitArrays.slice();for(;o.length||n;){0===n&&(t=o.shift(),n=7);const s=Math.min(n,r);i|=(t&~(255<>>=s,n-=s,(r-=s)&&(n||o.length)||(e.push(i),i=0,r=8)}for(var s=e.length-1;s>0;s--){if(0!==e[s])break;e.pop()}return e}compactArray(){return this._sortData(),this._data.map(s)}}},function(e,t,r){"use strict";(function(t,n){const i=r(40),o=r(1382);e.exports=function(e){return function(t){return t instanceof s?t:new s(t,e)}};class s{constructor(e,r){if("string"!=typeof e&&!t.isBuffer(e))throw new Error("can only hash strings or buffers");this._value=e,this._hashFn=r,this._depth=-1,this._availableBits=0,this._currentBufferIndex=0,this._buffers=[]}take(e,t){let r=e;i(()=>this._availableBits{this._produceMoreBits(e)},e=>{if(e)return void t(e);let o=0;i(()=>r>0,e=>{const t=this._buffers[this._currentBufferIndex],n=Math.min(t.availableBits(),r),i=t.take(n);o=(o<{e?t(e):n.nextTick(()=>t(null,o))})})}untake(e){let t=e;for(;t>0;){const e=this._buffers[this._currentBufferIndex],r=Math.min(e.totalBits()-e.availableBits(),t);e.untake(r),t-=r,this._availableBits+=r,this._currentBufferIndex>0&&e.totalBits()===e.availableBits()&&(this._depth--,this._currentBufferIndex--)}}_produceMoreBits(e){this._depth++;const t=this._depth?this._value+this._depth:this._value;this._hashFn(t,(t,r)=>{if(t)return void e(t);const n=new o(r);this._buffers.push(n),this._availableBits+=n.availableBits(),e()})}}}).call(this,r(0).Buffer,r(6))},function(e,t,r){"use strict";const n=[255,254,252,248,240,224,192,128],i=[1,3,7,15,31,63,127,255];function o(e,t,r){return(e&s(t,r))>>>t}function s(e,t){return n[e]&i[Math.min(t+e-1,7)]}e.exports=class{constructor(e){this._value=e,this._currentBytePos=e.length-1,this._currentBitPos=7}availableBits(){return this._currentBitPos+1+8*this._currentBytePos}totalBits(){return 8*this._value.length}take(e){let t=e,r=0;for(;t&&this._haveBits();){const e=this._value[this._currentBytePos],n=this._currentBitPos+1,i=Math.min(n,t);r=(r<7;)this._currentBitPos-=8,this._currentBytePos+=1}_haveBits(){return this._currentBytePos>=0}}},function(e,t,r){"use strict";const n=r(1384);e.exports=(e=>{let t="number"==typeof e?e:e.maxChunkSize;return n(t,{zeroPadding:!1,emitEmpty:!0})})},function(e,t,r){"use strict";(function(t){var n=r(202);function i(e){return 1===e.length?e[0]:t.concat(e)}function o(e,t,r){return 0===t&&r===e.length?e:e.slice(t,r)}e.exports=function(e,r){var s;r||(r={}),"object"==typeof e&&(e=(r=e).size),e=e||512,s=!r.nopad&&(void 0===r.zeroPadding||r.zeroPadding);var a=[],u=0,c=0,f=!1;return n(function(r){for("number"==typeof r&&(r=t.from([r])),u+=r.length,a.push(r);u>=e;){for(var n,s,l,h=0,p=[],d=0;h0&&(a[0]=a[0].slice(c)),this.queue(i(a)),a=null)}this.queue(null)})}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(8),i=r(9),o=r(1386).createResolver;function s(e){let r=e,n="/";if(t.isBuffer(e)&&(r=new i(e).toBaseEncodedString()),"string"==typeof e){0===e.indexOf("/ipfs/")&&(e=r=e.substring(6));const t=e.indexOf("/");t>0&&(r=e.substring(0,t),n=e.substring(t))}else i.isCID(r)&&(r=r.toBaseEncodedString());return{base:r=new i(r).toBaseEncodedString(),rest:n.split("/").filter(Boolean)}}const a={maxDepth:1/0,offset:void 0,length:void 0};e.exports=((e,t,r)=>{let u;r=Object.assign({},a,r);try{u=s(e)}catch(e){return n.error(e)}const c=function(e){return e.reduce((e,t)=>(e.length&&(e+="/"),e+t),"")}([u.base].concat(u.rest.slice(0,u.rest.length-1))).length;return n(n.values([{multihash:new i(u.base),name:u.base,path:u.base,pathRest:u.rest,depth:0}]),o(t,r),n.filter(Boolean),n.map(e=>({depth:e.depth,name:e.name,path:function(e){if(!u.rest.length)return e.path;let t=e.path.substring(c);return"/"===t.charAt(0)&&(t=t.substring(1)),t||(t=u.rest[u.rest.length-1]||u.base),t}(e),size:e.size,hash:e.hash||e.multihash,content:e.content,type:e.type})))})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(36),i=r(8),o=r(322),s=r(9),a={directory:r(1388),"hamt-sharded-directory":r(1389),file:r(1391),object:r(1392)};function u(e){return t.isBuffer(e.data)?n.unmarshal(e.data).type:"object"}function c(e){return e}e.exports=Object.assign({createResolver:function e(t,r,n,f){return n||(n=0),n>r.maxDepth?i.map(c):i(o((e,n)=>"number"!=typeof e.depth?i.error(new Error("no depth")):e.object?n(null,l(e.object,e,r.offset,r.length)):void t.get(new s(e.multihash),(t,i)=>{if(t)return n(t);n(null,l(i.value,e,r.offset,r.length))})),i.flatten(),i.filter(Boolean),i.filter(e=>e.depth<=r.maxDepth));function l(e,r,n,i){return h(e,r.name,r.path,r.pathRest,r.size,t,r.parent||f,r.depth,n,i)}function h(t,n,o,s,c,f,l,h,p,d){const y=u(t),g=a[y];return g?g(t,n,o,s,e(f,r,h,t),c,f,l,h,p,d):i.error(new Error("Unkown node type "+y))}},typeOf:u},a)}).call(this,r(0).Buffer)},function(e,t){e.exports=function(e){var t=!1,r=0;return function(){if(r=!0,!t){for(t=!0;r;)r=!1,e();t=!1}}}},function(e,t,r){"use strict";const n=r(8),i=r(141);e.exports=function(e,t,r,o,s,a,u,c,f){const l=o[0],h={name:t,depth:f,path:r,hash:e.multihash,size:e.size,type:"dir"},p=[n(n.values(e.links),n.map(e=>({depth:f+1,size:e.size,name:e.name,path:r+"/"+e.name,multihash:e.multihash,linkName:e.name,pathRest:o.slice(1),type:"dir"})),n.filter(e=>void 0===l||e.linkName===l),s)];return o.length||p.unshift(n.values([h])),i(p)}},function(e,t,r){"use strict";const n=r(8),i=r(141),o=r(1390);e.exports=function(e,t,r,s,a,u,c,f,l){let h;f&&f.path===r||(h={name:t,depth:l,path:r,hash:o(e.multihash),size:e.size,type:"dir"});const p=[n(n.values(e.links),n.map(e=>{const t=e.name.substring(2),n=t?r+"/"+t:r;let i=!0;return t&&s.length&&(i=t===s[0]),i?{depth:l+1,name:t,path:n,multihash:e.multihash,pathRest:t?s.slice(1):s,parent:h||f}:""}),n.filter(Boolean),a)];return s.length||p.unshift(n.values([h])),i(p)}},function(e,t,r){"use strict";(function(t){const n=r(12);e.exports=(e=>t.isBuffer(e)?n.toB58String(e):e)}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){const n=r(226),i=r(36),o=r(9),s=r(8),a=r(322);function u(e,r,u,f,l){if(f===u||0===l)return s.once(t.alloc(0));const h=f+l;let p=0;return s(n.depthFirst({node:r,start:0,end:u},function({node:r}){if(t.isBuffer(r))return s.empty();const n=i.unmarshal(r.data);Boolean(n.data&&n.data.length)&&r.links.length&&(p+=n.data.length);const u=r.links.map((e,t)=>{const r={link:e,start:p,end:p+n.blockSizes[t]};return p=r.end,r}).filter(e=>f>=e.start&&fe.start&&h<=e.end||fe.end);return u.length&&(p=u[0].start),s(s.values(u),a((t,r)=>{e.get(new o(t.link.multihash),(e,n)=>r(e,{start:t.start,end:t.end,node:n&&n.value,size:t.size}))}))}),s.map(function({node:e,start:r}){try{if(t.isBuffer(e))return c(e,r,f,h);const n=i.unmarshal(e.data);return n.data?c(n.data,r,f,h):t.alloc(0)}catch(e){throw new Error(`Failed to unmarshal node - ${e.message}`)}}),s.filter(Boolean))}function c(e,r,n,i){const o=e.length;return n>=r+o?t.alloc(0):(i-rr&&n{const y=o[0];if(void 0!==y&&y!==n)return s.empty();const g=i.unmarshal(e.data),m=c||g.fileSize();if(p<0)return s.error(new Error("Offset must be greater than 0"));if(p>m)return s.error(new Error("Offset must be less than the file size"));if(d<0)return s.error(new Error("Length must be greater than or equal to 0"));if(0===d)return s.once(t.alloc(0));p||(p=0),(!d||p+d>m)&&(d=m-p);const b=u(f,e,m,p,d);return s.values([{depth:h,content:b,name:r,path:n,hash:e.multihash,size:m,type:"file"}])})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(9),i=r(8);e.exports=((e,t,r,o,s,a,u,c,f)=>{let l;if(o.length){const t=o[0],a=r+"/"+t;if(!(l=e[t]))return i.error("not found");const u=n.isCID(l);return i(i.values([{depth:f,name:t,path:a,pathRest:o.slice(1),multihash:u&&l,object:!u&&l,parent:c}]),s)}return i.error(new Error("invalid node type"))})},function(e,t,r){var n=r(161),i=r(8);e.exports=function(e){var t=n(),r=i.collect(function(r,n){t.resolve(i.values(n.sort(e)))});return function(e){return r(e),t}}},function(e,t,r){"use strict";const n=r(23),i=r(3);e.exports=function(e){return{subscribe:(t,r,n,i)=>{if("function"==typeof n&&(i=n,n={}),!i)return new Promise((i,o)=>{e._libp2pNode.pubsub.subscribe(t,n,r,e=>{if(e)return o(e);i()})});e._libp2pNode.pubsub.subscribe(t,n,r,i)},unsubscribe:(t,r,n)=>{if(e._libp2pNode.pubsub.unsubscribe(t,r),!n)return Promise.resolve();i(()=>n())},publish:n((t,r,n)=>{e._libp2pNode.pubsub.publish(t,r,n)}),ls:n(t=>{e._libp2pNode.pubsub.ls(t)}),peers:n((t,r)=>{e._libp2pNode.pubsub.peers(t,r)}),setMaxListeners(t){e._libp2pNode.pubsub.setMaxListeners(t)}}}},function(e,t,r){"use strict";(function(t){const n=r(23),i=r(1396),o=r(98),s=r(9),a=r(50);e.exports=(e=>({get:n((r,n,i)=>{if(!t.isBuffer(r))return i(new Error("Not valid key"));"function"==typeof n&&(i=n,n={}),e._libp2pNode.dht.get(r,n.timeout,i)}),put:n((r,n,i)=>{if(!t.isBuffer(r))return i(new Error("Not valid key"));e._libp2pNode.dht.put(r,n,i)}),findprovs:n((t,r)=>{"string"==typeof t&&(t=new s(t)),e._libp2pNode.contentRouting.findProviders(t,r)}),findpeer:n((t,r)=>{"string"==typeof t&&(t=o.createFromB58String(t)),e._libp2pNode.peerRouting.findPeer(t,(e,t)=>{if(e)return r(e);const n=[{Responses:[{ID:t.id.toB58String(),Addresses:t.multiaddrs.toArray().map(e=>e.toString())}]}];r(null,n)})}),provide:n((t,r,n)=>{Array.isArray(t)||(t=[t]),"function"==typeof r&&(n=r,r={}),i(t,(t,r)=>{e._repo.blocks.has(t,r)},(i,o)=>i?n(i):o?void(r.recursive||a(t,(t,r)=>{e._libp2pNode.contentRouting.provide(t,r)},n)):n(new Error("block(s) not found locally, cannot provide")))}),query:n((t,r)=>{"string"==typeof t&&(t=o.createFromB58String(t)),e._libp2pNode._dht.getClosestPeers(t.toBytes(),(e,t)=>{if(e)return r(e);r(null,t.map(e=>({ID:e.toB58String()})))})})}))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=s(r(559)),i=s(r(164)),o=s(r(1397));function s(e){return e&&e.__esModule?e:{default:e}}t.default=(0,i.default)((0,n.default)(o.default,o.default)),e.exports=t.default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return!e},e.exports=t.default},function(e,t,r){"use strict";const n=r(1399),i=r(23);e.exports=(()=>i((e,t,r)=>{if("string"!=typeof e)return r(new Error("Invalid arguments, domain must be a string"));"function"==typeof t&&(r=t,t={}),n(e,t,r)}))},function(e,t,r){"use strict";e.exports=((e,t,r)=>{let n=`https://ipfs.io/api/v0/dns?arg=${e=encodeURIComponent(e)}`;for(const e in t)n+=`&${e}=${t[e]}`;self.fetch(n,{mode:"cors"}).then(e=>e.json()).then(e=>e.Path?r(null,e.Path):r(new Error(e.Message))).catch(e=>{r(e)})})},function(e,t,r){"use strict";const n=r(23);e.exports=function(e){return{gen:n((t,r,n)=>{e._keychain.createKey(t,r.type,r.size,n)}),info:n((t,r)=>{e._keychain.findKeyByName(t,r)}),list:n(t=>{e._keychain.listKeys(t)}),rm:n((t,r)=>{e._keychain.removeKey(t,r)}),rename:n((t,r,n)=>{e._keychain.renameKey(t,r,(e,r)=>{if(e)return n(e);const i={was:t,now:r.name,id:r.id,overwrite:!1};n(null,i)})}),import:n((t,r,n,i)=>{e._keychain.importKey(t,r,n,i)}),export:n((t,r,n)=>{e._keychain.exportKey(t,r,n)})}}},function(e,t,r){"use strict";const n=r(23),i=r(122),o=r(46),s=r(1402),a=r(140);function u(e,t){return new Promise((r,n)=>{let o;(o=t.peer?e._libp2pNode.stats.forPeer(t.peer):t.proto?e._libp2pNode.stats.forProtocol(t.proto):e._libp2pNode.stats.global)?r({totalIn:o.snapshot.dataReceived,totalOut:o.snapshot.dataSent,rateIn:new i(o.movingAverages.dataReceived[6e4].movingAverage()/60),rateOut:new i(o.movingAverages.dataSent[6e4].movingAverage()/60)}):r({totalIn:new i(0),totalOut:new i(0),rateIn:new i(0),rateOut:new i(0)})})}e.exports=function(e){const t=t=>{t=t||{};let r=null,n=o(!0,()=>{r&&clearInterval(r)});return t.poll?s(t.interval||"1s",(i,o)=>{if(i)throw i;r=setInterval(()=>{u(e,t).then(e=>n.push(e)).catch(e=>n.end(e))},o)}):u(e,t).then(e=>{n.push(e),n.end()}).catch(e=>n.end(e)),n.source};return{bitswap:r(589)(e).stat,repo:r(507)(e).stat,bw:n((t,r)=>{"function"==typeof t&&(r=t,t={}),u(e,t).then(e=>r(null,e)).catch(e=>r(e))}),bwReadableStream:e=>a.source(t(e)),bwPullStream:t}}},function(e,t,r){"use strict";const n=r(23),i=/^((\d+(\.\d+)*)(ns|ms|us|µs|m|s|h))+$/,o=/((\d+(\.\d+)*)(ns|ms|us|µs|m|s|h))/g,s=/(ns|ms|us|µs|m|s|h)/g,a={ns:1e-6,us:.001,"µs":.001,ms:1,s:1e3,m:6e4,h:36e5};e.exports=n(function(e,t){return"string"!=typeof e?t(new Error("the first argument must be a string")):i.test(e)?void t(null,e.match(o).reduce((e,t)=>e+function(e){let t=e.match(s)[0];return e=e.substring(0,e.length-t.length),parseFloat(e)*a[t]}(t),0)):t(new Error("invalid time"))})},function(e,t,r){"use strict";const n=r(23),i=r(1404);e.exports=(e=>{const t=Object.assign({},e);return t.dag=Object.assign({},e.dag,{get:n((t,r,n,i)=>("function"==typeof r&&(i=r,r=void 0),"function"==typeof n&&(i=n,n={}),n=Object.assign({},n,{preload:!1}),e.dag.get(t,r,n,i))),put:n((t,r,n)=>("function"==typeof r&&(n=r,r={}),r=Object.assign({},r,{preload:!1}),e.dag.put(t,r,n)))}),i(t,t._options)})},function(e,t,r){"use strict";e.exports=r(1405)},function(e,t,r){"use strict";const n=r(23),{createLock:i}=r(48),o={ls:r(1432),read:r(1433),readPullStream:r(324),readReadableStream:r(1434),stat:r(598)},s={cp:r(599),flush:r(1435),mkdir:r(1436),mv:r(1437),rm:r(600),write:r(1438)},a=(e,t,r,i)=>{Object.keys(r).forEach(o=>{r.hasOwnProperty(o)&&(t[o]=n(i(r[o](e))))})},u={repoOwner:!0};e.exports=((e,t)=>{const{repoOwner:r}=Object.assign({},u||{},t),n=i(r),c={};return a(e,c,o,e=>n.readLock(e)),a(e,c,s,e=>n.writeLock(e)),c})},function(e,t,r){"use strict";(function(t){e.exports=(e=>{let r=t.alloc(0);const n=(i,o)=>{e(null,(e,s)=>{if(e)return!0===e?o(null,r):o(e);if((r=t.concat([r,s])).length{let t=0;return n(e=>{t+=e.length},()=>{e(t)})})},function(e,t,r){"use strict";const n=r(1409),i=r(1)("ipfs:mfs:lock");e.exports=(e=>{const t=n({singleProcess:e}),r=(e,r,n,o)=>{i(`Queuing ${e} operation`),t[`${e}Lock`](()=>new Promise((t,o)=>{n.push((r,n)=>{if(i(`${e} operation callback invoked${r?" with error":""}`),r)return o(r);t(n)}),i(`Starting ${e} operation`),r.apply(null,n)})).then(t=>{i(`Finished ${e} operation`);const r=o;o=null,r(null,t)}).catch(t=>{if(i(`Finished ${e} operation with error`),o)return o(t);throw i(`Callback already invoked for ${e} operation`),t})};return{readLock:e=>(function(){const t=Array.from(arguments);let n=t.pop();r("read",e,t,n)}),writeLock:e=>(function(){const t=Array.from(arguments);let n=t.pop();r("write",e,t,n)})}})},function(e,t,r){(function(t){const n=r(1410),i=r(1420),o=r(1421),{timeout:s}=r(1422),a=r(592),u={};let c;const f={concurrency:1/0,timeout:846e5,global:t,singleProcess:!1};e.exports=((e,t)=>(t||(t={}),"object"==typeof e&&(t=e,e="lock"),e||(e="lock"),t=Object.assign({},f,t),c||(c=n(t)||i(t)).isWorker||(c.on("requestReadLock",(e,t)=>{u[e]&&u[e].readLock(t)}),c.on("requestWriteLock",(e,t)=>{u[e]&&u[e].writeLock(t)})),u[e]||(u[e]=((e,t)=>{if(c.isWorker)return{readLock:c.readLock(e,t),writeLock:c.writeLock(e,t)};const r=new o({concurrency:1});let n=null;return{readLock:e=>{if(!n){const e=n=new o({concurrency:t.concurrency,autoStart:!1});r.add(()=>(e.start(),e.onIdle().then(()=>{n===e&&(n=null)})))}return n.add(()=>s(e(),t.timeout))},writeLock:e=>(n=null,r.add(()=>s(e(),t.timeout)))}})(e,t)),u[e])),e.exports.Worker=function(e,r){let n;r=r||t.Worker;try{n=new r(e)}catch(t){t.message.includes("not a constructor")&&(n=r(e))}if(!n)throw new Error("Could not create Worker from",r);return a(n),n}}).call(this,r(7))},function(e,t,r){(function(t){const n=r(10).EventEmitter,i=r(590),{WORKER_REQUEST_READ_LOCK:o,WORKER_RELEASE_READ_LOCK:s,MASTER_GRANT_READ_LOCK:a,WORKER_REQUEST_WRITE_LOCK:u,WORKER_RELEASE_WRITE_LOCK:c,MASTER_GRANT_WRITE_LOCK:f}=r(591);let l;const h=(e,t,r,n,i)=>(o,s)=>{s&&s.type===r&&e.emit(t,s.name,()=>(o.send({type:i,name:s.name,identifier:s.identifier}),new Promise(e=>{const t=r=>{r&&r.type===n&&r.identifier===s.identifier&&(o.removeListener("message",t),e())};o.on("message",t)})))},p=(e,r,n,o)=>s=>{const a=i.generate();return t.send({type:r,identifier:a,name:e}),new Promise((r,i)=>{const u=c=>{if(c&&c.type===n&&c.identifier===a){t.removeListener("message",u);let n=null;s().catch(e=>{n=e}).then(s=>{if(t.send({type:o,identifier:a,name:e}),n)return i(n);r(s)})}};t.on("message",u)})};e.exports=(e=>{try{if(l=r(1419),!Object.keys(l).length)return}catch(e){return}if(l.isMaster||e.singleProcess){const e=new n;return l.on("message",h(e,"requestReadLock",o,s,a)),l.on("message",h(e,"requestWriteLock",u,c,f)),e}return{isWorker:!0,readLock:(e,t)=>p(e,o,a,s),writeLock:(e,t)=>p(e,u,f,c)}})}).call(this,r(6))},function(e,t,r){"use strict";var n=r(203),i=r(1413),o=r(1417),s=r(1418)||0;function a(){return i(s)}e.exports=a,e.exports.generate=a,e.exports.seed=function(t){return n.seed(t),e.exports},e.exports.worker=function(t){return s=t,e.exports},e.exports.characters=function(e){return void 0!==e&&n.characters(e),n.shuffled()},e.exports.isValid=o},function(e,t,r){"use strict";var n=1;e.exports={nextValue:function(){return(n=(9301*n+49297)%233280)/233280},seed:function(e){n=e}}},function(e,t,r){"use strict";var n,i,o=r(1414),s=(r(203),1459707606518),a=6;e.exports=function(e){var t="",r=Math.floor(.001*(Date.now()-s));return r===i?n++:(n=0,i=r),t+=o(a),t+=o(e),n>0&&(t+=o(n)),t+o(r)}},function(e,t,r){"use strict";var n=r(203),i=r(1415),o=r(1416);e.exports=function(e){for(var t,r=0,s="";!t;)s+=o(i,n.get(),1),t=e(o,s)=>{if(!s||!s.data||s.data.type!==r)return;const a={type:s.data.type,name:s.data.name,identifier:s.data.identifier};e.emit(t,a.name,()=>(o.postMessage({type:i,name:a.name,identifier:a.identifier}),new Promise(e=>{const t=r=>{if(!r||!r.data)return;const i={type:r.data.type,name:r.data.name,identifier:r.data.identifier};i&&i.type===n&&i.identifier===a.identifier&&(o.removeEventListener("message",t),e())};o.addEventListener("message",t)})))},p=(e,t,r,n,o)=>s=>{const a=i.generate();return e.postMessage({type:r,identifier:a,name:t}),new Promise((r,i)=>{const u=c=>{if(!c||!c.data)return;const f={type:c.data.type,identifier:c.data.identifier};if(f&&f.type===n&&f.identifier===a){let n;e.removeEventListener("message",u),s().catch(e=>{n=e}).then(s=>(e.postMessage({type:o,identifier:a,name:t}),n?i(n):r(s)))}};e.addEventListener("message",u)})},d={global:t,singleProcess:!1};e.exports=(e=>{if(!!(e=Object.assign({},d,e)).global.document||e.singleProcess){const e=new n;return l.addEventListener("message",h(e,"requestReadLock",o,s,a)),l.addEventListener("message",h(e,"requestWriteLock",u,c,f)),e}return{isWorker:!0,readLock:(e,t)=>p(t.global,e,o,a,s),writeLock:(e,t)=>p(t.global,e,u,f,c)}})}).call(this,r(7))},function(e,t,r){"use strict";class n{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 n=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}(this._queue,r,(e,t)=>t.priority-e.priority);this._queue.splice(n,0,r)}dequeue(){return this._queue.shift().run}get size(){return this._queue.length}}e.exports=class{constructor(e){if(!("number"==typeof(e=Object.assign({concurrency:1/0,autoStart:!0,queueClass:n},e)).concurrency&&e.concurrency>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e.concurrency}\` (${typeof e.concurrency})`);this.queue=new e.queueClass,this._queueClass=e.queueClass,this._pendingCount=0,this._concurrency=e.concurrency,this._isPaused=!1===e.autoStart,this._resolveEmpty=(()=>{}),this._resolveIdle=(()=>{})}_next(){this._pendingCount--,this.queue.size>0?this._isPaused||this.queue.dequeue()():(this._resolveEmpty(),this._resolveEmpty=(()=>{}),0===this._pendingCount&&(this._resolveIdle(),this._resolveIdle=(()=>{})))}add(e,t){return new Promise((r,n)=>{const i=()=>{this._pendingCount++;try{Promise.resolve(e()).then(e=>{r(e),this._next()},e=>{n(e),this._next()})}catch(e){n(e),this._next()}};!this._isPaused&&this._pendingCountthis.add(e,t)))}start(){if(this._isPaused)for(this._isPaused=!1;this.queue.size>0&&this._pendingCount{const t=this._resolveEmpty;this._resolveEmpty=(()=>{t(),e()})})}onIdle(){return 0===this._pendingCount?Promise.resolve():new Promise(e=>{const t=this._resolveIdle;this._resolveIdle=(()=>{t(),e()})})}get size(){return this.queue.size}get pending(){return this._pendingCount}get isPaused(){return this._isPaused}}},function(e,t,r){"use strict";var n;e.exports.timeout=function(e,t){var r,i=new n;return Promise.race([e,new Promise(function(e,n){r=setTimeout(function(){n(i)},t)})]).then(function(e){return clearTimeout(r),e},function(e){throw clearTimeout(r),e})};(n=e.exports.TimeoutError=function(){Error.call(this),this.stack=Error().stack,this.message="Timeout"}).prototype=Object.create(Error.prototype),n.prototype.name="TimeoutError"},function(e,t,r){"use strict";(function(t){const n=r(9);e.exports=((e,r)=>(t.isBuffer(e)&&(e=new n(e)),"base58btc"===r?e.toBaseEncodedString():e.toV1().toBaseEncodedString(r)))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(153),i=r(594);e.exports=(e=>{let t=0;return n((r,n)=>{t>e&&i(n),t+r.length>e&&(r=r.slice(0,e-t)),t+=r.length,n(null,r)})})},function(e,t,r){"use strict";const n=r(5),i=r(9),o=r(1)("ipfs:mfs:utils:load-node");e.exports=((e,t,r)=>{const s=t&&(t.multihash||t.hash);if(!s)return o("No multihash passed so cannot load DAGNode"),r();const a=new i(s);o(`Loading DAGNode for child ${a.toBaseEncodedString()}`),n([t=>e.dag.get(a,t),(e,t)=>t(null,e.value)],r)})},function(e,t,r){"use strict";const n=r(595);e.exports=function(e,t){const{sources:r,options:i,callback:o}=n(e,t);return{sources:r,destination:r.pop(),options:i,callback:o}}},function(e,t,r){"use strict";const n=r(9),i=r(1)("ipfs:mfs:utils:traverse-to"),o=r(36),s=r(5),a=r(1428),u=r(596),c=r(597),f=r(323),{FILE_SEPARATOR:l}=r(146),h=r(593),p={parents:!1,flush:!0,createLastComponent:!1,withCreateHint:!0},d=(e,t,r,n)=>{i("IPFS",t),s([r=>e.dag.get(t.path,r),(e,r)=>r(null,{name:t.name,node:e&&e.value,parent:null})],n)},y=(e,t,r,c)=>{s([t=>u(e,t),(u,c)=>{const p=t.path.split(l).filter(Boolean),d=[];s([t=>e.dag.get(u,t),(u,c)=>{const y=u.value;d.push({name:l,node:y,parent:null}),a(p.map((e,t)=>({pathSegment:e,index:t})),{name:l,node:y,parent:null},(a,{pathSegment:u,index:c},l)=>{const y=a.node.links.find(e=>e.name===u);if(!y){const y=c===p.length-1;if(i(`index ${c} pathSegments.length ${p.length} pathSegment ${u} lastComponent ${y}`,r),y&&!r.createLastComponent)return l(new Error(`Path ${t.path} did not exist`));if(!y&&!r.parents){let e=`Cannot find ${t.path} - ${u} did not exist`;return r.withCreateHint&&(e+=": Try again with the --parents flag to create it"),l(new Error(e))}return i(`Adding empty directory '${u}' to parent ${a.name}`),s([t=>h(e,new o("directory").marshal(),[],r,t),(t,i)=>{f(e,{parent:a.node,child:t,name:u,flush:r.flush},(e,r)=>{a.node=r,i(e,{name:u,node:t,cid:new n(t.multihash),parent:a})})}],(e,t)=>{d.push(t),l(e,t)})}let g=y.hash||y.multihash;const m=new n(g);e.dag.get(m,(e,t)=>{if(e)return l(e);const r=t.value,n={name:u,node:r,parent:a};d.push(n),l(null,n)})},c)}],c)}],c)};e.exports=((e,t,r,n)=>{r=Object.assign({},p,r),i("Traversing to",t),s([e=>c(t,e),(t,n)=>"mfs"===t.type?y(e,t,r,n):d(e,t,r,n)],n)})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,a){a=(0,o.default)(a||i.default);var u=(0,s.default)(r);(0,n.default)(e,function(e,r,n){u(t,e,function(e,r){t=r,n(e)})},function(e){a(e,t)})};var n=a(r(216)),i=a(r(54)),o=a(r(156)),s=a(r(34));function a(e){return e&&e.__esModule?e:{default:e}}e.exports=t.default},function(e,t,r){"use strict";const n=r(1)("ipfs:mfs:utils:update-mfs:root"),i=r(5),o=r(9),{MFS_ROOT_KEY:s}=r(146);e.exports=((e,t,r)=>{const a=e._repo,u=a&&a.datastore;if(!a||!u)return r(new Error("Please run jsipfs init first"));const c=new o(t);n(`New MFS root will be ${c.toBaseEncodedString()}`),i([e=>{if(a.closed)return n("Opening datastore"),u.open(t=>e(t));n("Datastore was already open"),e()},e=>u.put(s,c.buffer,t=>e(t))],e=>r(e,c))})},function(e,t,r){"use strict";const n=r(349),i=r(323);e.exports=((e,t,r)=>{n(r=>{if(!t.parent){const e=t;return t=null,r(null,e)}i(e,{parent:t.parent.node,child:t.node,name:t.name,flush:!0},(e,n)=>{t.parent.node=n;const i=t;t=t.parent,r(e,i)})},()=>Boolean(t),r)})},function(e,t,r){"use strict";(function(t){e.exports=((e=1/0,r=4096)=>{let n=0;return(i,o)=>{if(i)return o&&o(i);if(n>=e)return o(!0);let s=r;n+s>e&&(s=e-n),n+=s,o(null,t.alloc(s,0))}})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(5),i=r(80),o=r(36),{traverseTo:s,loadNode:a,formatCid:u,FILE_SEPARATOR:c,FILE_TYPES:f}=r(48),l={long:!1,cidBase:"base58btc"};e.exports=(e=>(function(t,r,h){"function"==typeof t&&(h=t,t=c,r={}),"function"==typeof r&&(h=r,r={}),(r=Object.assign({},l,r)).long=r.l||r.long,n([r=>s(e,t,{},r),(t,s)=>{const c=o.unmarshal(t.node.data);"directory"===c.type?i(t.node.links,(t,i)=>{n([r=>a(e,t,r),(e,n)=>{const i=o.unmarshal(e.data);n(null,{name:t.name,type:i.type,hash:u(e.multihash,r.cidBase),size:i.fileSize()||0})}],i)},s):s(null,[{name:t.name,type:c.type,hash:u(t.node.multihash,r.cidBase),size:c.fileSize()||0}])},(e,t)=>t(null,e.map(e=>(f.hasOwnProperty(e.type)&&(e.type=f[e.type]),r.long||(e.type=0,e.size=0,e.hash=""),e))),(e,t)=>{if(r.long)return t(null,e.sort((e,t)=>t.name.localeCompare(e.name)));t(null,e)}],h)}))},function(e,t,r){"use strict";(function(t){const n=r(70),i=r(87),o=r(5),s=r(324);e.exports=(e=>(function(r,a,u){"function"==typeof a&&(u=a,a={}),o([t=>s(e)(r,a,t),(e,t)=>n(e,i(t)),(e,r)=>{r(null,t.concat(e))}],u)}))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(5),i=r(324),o=r(140);e.exports=(e=>(function(t,r,s){"function"==typeof r&&(s=r,r={}),n([n=>i(e)(t,r,n),(e,t)=>t(null,o.source(e))],s)}))},function(e,t,r){"use strict";const n=r(5),{traverseTo:i,FILE_SEPARATOR:o}=r(48),s={};e.exports=(e=>(function(t,r,a){"function"==typeof r&&(a=r,r={}),"function"==typeof t&&(a=t,r={},t=o),t||(t=o),r=Object.assign({},s,r),n([r=>i(e,t,{},r),(e,t)=>{t()}],a)}))},function(e,t,r){"use strict";const n=r(5),i=r(1)("ipfs:mfs:mkdir"),{updateMfsRoot:o,updateTree:s,traverseTo:a,FILE_SEPARATOR:u}=r(48),c={parents:!1,hash:void 0,cidVersion:0};e.exports=(e=>(function(t,r,f){return"function"==typeof r&&(f=r,r={}),(r=Object.assign({},c,r)).parents=r.p||r.parents,r.cidVersion=r.cidVersion||0,t?(t=t.trim())===u?f(r.parents?null:new Error(`cannot create directory '${u}': Already exists`)):(i(`Creating ${t}`),void n([r=>{a(e,t,{parents:!1,createLastComponent:!1},e=>e?e.message.includes("did not exist")?(i(`${t} did not exist`),r()):r(e):(i(`${t} already exists`),r(new Error("file already exists"))))},n=>a(e,t,{parents:r.parents,flush:r.flush,createLastComponent:!0},n),(t,r)=>s(e,t,r),(t,r)=>o(e,t.node.multihash,r)],e=>{e&&e.message.includes("file already exists")&&r.parents&&(e=null),f(e)})):f(new Error("no path given to Mkdir"))}))},function(e,t,r){"use strict";const n=r(49),{toSources:i}=r(48),o=r(599),s=r(600),a={parents:!1,recursive:!1,flush:!0,format:"dag-pb",hashAlg:"sha2-256"};e.exports=(e=>(function(){let t=Array.from(arguments);Array.isArray(t[0])&&(t=t[0].concat(t.slice(1)));const{sources:r,options:u,callback:c}=i(t,a),f=r.map(e=>e.path).concat(u),l=r.slice(0,-1).map(e=>e.path).concat(Object.assign(u,{recursive:!0}));n([t=>o(e).apply(null,f.concat(t)),t=>s(e).apply(null,l.concat(t))],c)}))},function(e,t,r){"use strict";(function(t,n){const i=r(23),o=r(9),s=r(5),a=r(59),{updateMfsRoot:u,validatePath:c,traverseTo:f,addLink:l,updateTree:h,limitStreamBytes:p}=r(48),d=r(86),y=r(1)("ipfs:mfs:write"),g=r(601),m=r(1439),b=r(192),v=r(587),_=r(1442),w=r(588),S=r(141),k=r(70),E=r(1445),A={offset:0,length:void 0,create:!1,truncate:!1,rawLeaves:!1,reduceSingleLeafToSelf:!1,cidVersion:0,hashAlg:"sha2-256",format:"dag-pb",parents:!1,progress:void 0,strategy:"trickle",flush:!0,leafType:"raw"},x=(e,r,i)=>e?t.isBuffer(e)?(y("Content was a buffer"),r.length=r.length||e.length,i(null,d([e]))):"string"==typeof e||e instanceof String?(y("Content was a path"),s([t=>r.length?t(null,{size:r.length}):E.stat(e,t),(t,n)=>{r.length=t.size,n(null,b.source(E.createReadStream(e)))}],i)):(n.Blob&&e instanceof n.Blob&&(y("Content was an HTML5 Blob"),r.length=r.length||e.size,e=_(e)),v(e)?(y("Content was a Node stream"),i(null,b.source(e))):w.isSource(e)?(y("Content was a pull-stream"),i(null,e)):void i(new Error(`Don't know how to convert ${e} into a pull stream source`))):i(new Error("paths must start with a leading /"));e.exports=function(e){return i((t,r,n,i)=>("function"==typeof n&&(i=n,n={}),(n=Object.assign({},A,n)).offset<0?i(new Error("cannot have negative write offset")):n.length<0?i(new Error("cannot have negative byte count")):0!==n.length||n.truncate?(n.length||(n.length=1/0),n.cidVersion=n.cidVersion||0,void s([e=>{a([e=>x(r,n,e),e=>c(t,e)],e)},([t,r],i)=>{s([i=>f(e,r.directory,Object.assign({},n,{createLastComponent:n.parents}),(e,r)=>i(e,t,r)),(t,i,o)=>{I(e,n,r,t,i,o)}],i)}],e=>i(e))):i()))};const I=(e,r,n,i,a,c)=>{s([s=>{const u=a.node.links.reduce((e,t)=>t.name===n.name?t:e,null);if(u){const t=new o(u.multihash);y(`Updating linked DAGNode ${t.toBaseEncodedString()}`),m(e,t,i,r,s)}else{if(!r.create)return s(new Error("file does not exist"));r.offset&&(r.length+=r.offset,i=S([d([t.alloc(r.offset,0)]),i])),i=k(i,p(r.length)),y("Importing file",n.name),g(e,i,r,s)}},(t,i)=>l(e,{parent:a.node,name:n.name,child:{multihash:t.multihash||t.hash,size:t.size},flush:r.flush},(e,t)=>{a.node=t,i(e)}),t=>h(e,a,t),(t,r)=>u(e,t.node.multihash,r)],c)}}).call(this,r(0).Buffer,r(7))},function(e,t,r){"use strict";const n=r(36),{unmarshal:i}=n,o=r(70),s=r(141),a=r(87),u=r(46),c=r(345),f=r(120),l=r(5),h=r(59),p=r(1)("ipfs:mfs:write:update-node"),{limitStreamBytes:d,countStreamBytes:y,createNode:g,zeros:m,loadNode:b}=r(48),v=r(601),_=r(1440),w=r(1441),{DAGLink:S}=r(41);e.exports=((e,t,r,n,k)=>{let E=n.offset||0,A=E,x=E+n.length,I=A;l([r=>b(e,t,r),(b,k)=>{const T=i(b.data).fileSize();p(`Updating bytes ${A}-${x} of ${T} bytes from ${t.toBaseEncodedString()} with source`);let B=0;A>T&&(p(`Adding ${B=A-T} 0s to the start of the block`),r=s([m(B),r]));const C=u(),P=u();o(r,f(Boolean),d(n.length+B),y(e=>{x===1/0&&(x=E+e)}),c(e=>{p(`Writing ${e.length} at ${I} of ${T}`),IT?(C.push(e.slice(0,T-I)),P.push(e.slice(T-I))):C.push(e):P.push(e),I+=e.length}),a(e=>{C.end(e),P.end()})),l([t=>{h([t=>_(e,b,T,A,x,C,n,t),t=>v(e,P,n,t)],t)},([t,r],o)=>{const s=i((t=t||b).data),a=i(r.data);if(a.fileSize()){const i=t.links;return a.data&&a.data.length?(p("New data was found on appended node"),r.links&&r.links.length&&p("New data was also found on appended node children"),s.addBlockSize(a.fileSize()),i.push(new S("",r.size,r.multihash))):r.links&&r.links.length&&(p("New data required multiple DAGNodes"),r.links.forEach((e,t)=>{s.addBlockSize(a.blockSizes[t]),i.push(e)})),g(e,s.marshal(),i,n,o)}o(null,t)},(t,r)=>{if(n.truncate)return w(e,t,x,n,r);r(null,t)}],k)}],k)})},function(e,t,r){"use strict";(function(t){const n=r(5),i=r(70),o=r(86),s=r(153),a=r(120),u=r(87),c=r(322),f=r(1)("ipfs:mfs:write:update-tree"),l=r(36),h=r(9),{unmarshal:p}=l,{leafFirst:d}=r(226),{DAGLink:y}=r(41),{createNode:g,loadNode:m,bufferPullStreamSource:b}=r(48);e.exports=((e,r,v,_,w,S,k,E)=>{let A=0;function x({node:t}){const r=p(t.data);f(`Node links ${t.links.length}${r.blockSizes.length?`, block sizes ${r.blockSizes.join(", ")}`:""} with ${r.data?`${r.data.length} bytes of`:"no"} data`);const n={node:t},s=t.links.map((e,t)=>{const i={parent:n,link:e,index:t,nodeStart:A,nodeEnd:A+r.blockSizes[t]};return A=i.nodeEnd,i}).filter((e,t)=>(f("child.nodeStart",e.nodeStart,"child.nodeEnd",e.nodeEnd,"streamStart",_,"streamEnd",w),_>=e.nodeStart&&_e.nodeStart&&w<=e.nodeEnd||_e.nodeEnd));return s.length?(A=s[0].nodeStart,f(`Updating links with index(es) ${s.map(e=>e.index).join(",")}`)):f("No links to update"),i(o(s),c((t,r)=>{m(e,t.link,(e,n)=>{r(e,Object.assign({},t,{node:n}))})}))}function I(r){const i=b(r);return({parent:r,link:o,nodeStart:s,node:a,index:u},c)=>{if(!a||!a.data)return c();const f=p(a.data);if(!f||!f.data||!f.data.length)return c();n([e=>i(f.data.length,e),(e,r)=>{const n=_-s;let i=w-_;f.data.lengthg(e,t,[],k,r),(e,t)=>{t(null,{parent:r,index:u,multihash:e.multihash,size:e.size})}],c)}}n([t=>i(d({parent:null,link:null,index:null,node:r,nodeStart:A,nodeEnd:v},x),c(I(S)),a(Boolean),s((t,r)=>{if(!t.parent||void 0===t.index)return r(null,t);const i=t.parent.node.links.map((e,r)=>r===t.index?new y("",t.size,t.multihash):e);n([r=>g(e,t.parent.node.data,i,k,r),(e,r)=>{t.parent.node=e,r(null,t)}],r)}),u((e,r)=>{let n;if(!e&&r&&r.length){for(n=r[0];n.parent;)n=n.parent;n.node&&(n=n.node),f(`Updated root is ${new h(n.multihash).toBaseEncodedString()}`)}t(e,n)})),(t,r)=>m(e,t,r)],E)})}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(145).exporter,i=r(145).importer,o=r(70),s=r(86),a=r(153),u=r(87),c=r(1)("ipfs:mfs:write:truncate-node"),{loadNode:f}=r(48);e.exports=((e,t,r,l,h)=>{c(`Truncating ${t.multihash} to ${r} bytes`),o(n(t.multihash,e.dag,{offset:0,length:r}),a((t,r)=>{o(s([{content:t.content}]),i(e.dag,{progress:l.progress,hashAlg:l.hash,cidVersion:l.cidVersion,strategy:l.strategy,rawLeaves:l.rawLeaves,reduceSingleLeafToSelf:l.reduceSingleLeafToSelf,leafType:l.leafType}),u(r))}),a((t,r)=>f(e,t[0],r)),u((e,t)=>{h(e,t.pop())}))})},function(e,t,r){var n=r(1443),i=r(602);e.exports=function(e,t){var r=(t=t||{}).offset||0,o=t.chunkSize||1048576,s=new FileReader(e),a=n(function(t,n){if(r>=e.size)return n(null,null);s.onloadend=function(e){var t=e.target.result;t instanceof ArrayBuffer&&(t=i(new Uint8Array(e.target.result))),n(null,t)};var a=r+o,u=e.slice(r,a);s.readAsArrayBuffer(u),r=a});return a.name=e.name,a.size=e.size,a.type=e.type,a.lastModified=e.lastModified,s.onerror=function(e){a.destroy(e)},a}},function(e,t,r){(function(t){var n=r(22).Readable,i=r(4);e.exports=s,s.ctor=a,s.obj=function(e,t){return("function"==typeof e||Array.isArray(e))&&(t=e,e={}),(e=c(e)).objectMode=!0,e.highWaterMark=16,s(e,t)};var o=a();function s(e,t){("object"!=typeof e||Array.isArray(e))&&(t=e,e={});var r=new o(e);return r._from=Array.isArray(t)?function(e){return e=e.slice(),function(t,r){var n=null,i=e.length?e.shift():null;i instanceof Error&&(n=i,i=null),r(n,i)}}(t):t||u,r}function a(e,r){function o(t){if(!(this instanceof o))return new o(t);this._reading=!1,this._callback=function(e,t){if(!r.destroyed){if(e)return r.destroy(e);if(null===t)return r.push(null);r._reading=!1,r.push(t)&&r._read(i)}},this.destroyed=!1,n.call(this,t||e);var r=this,i=this._readableState.highWaterMark}return"function"==typeof e&&(r=e,e={}),e=c(e),i(o,n),o.prototype._from=r||u,o.prototype._read=function(e){this._reading||this.destroyed||(this._reading=!0,this._from(e,this._callback))},o.prototype.destroy=function(e){if(!this.destroyed){this.destroyed=!0;var r=this;t.nextTick(function(){e&&r.emit("error",e),r.emit("close")})}},o}function u(){}function c(e){return e||{}}}).call(this,r(6))},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){},function(e,t,r){"use strict";const n=r(155);e.exports=(e=>{return new n(e||"ipfs")})},function(e,t,r){"use strict";const n=r(3),i=r(1448),o=r(1449),s=r(1),a=r(9),u=r(1450),c=s("jsipfs:preload");c.error=s("jsipfs:preload:error");const f=e=>{e&&c.error(e)};function l(e){return e.endsWith("http")||e.endsWith("https")||(e+="/http"),o(e)}e.exports=(e=>{const t=e._options.preload||{};if(t.enabled=Boolean(t.enabled),t.addresses=t.addresses||[],!t.enabled||!t.addresses.length)return(e,t)=>{t&&n(()=>t())};let r=!0,o=[];const s=t.addresses.map(l),h=(e,t)=>{if(t=t||f,"string"!=typeof e)try{e=new a(e).toBaseEncodedString()}catch(e){return n(()=>t(e))}const l=Array.from(s);let h;const p=Date.now();i({times:l.length},t=>{if(r)return t(new Error(`preload aborted for ${e}`));o=o.filter(e=>e!==h);const n=l.shift();h=u(`${n}/api/v0/refs?r=true&arg=${e}`,t),o=o.concat(h)},r=>{if(o=o.filter(e=>e!==h),r)return t(r);c(`preloaded ${e} in ${Date.now()-p}ms`),t()})};return h.start=(()=>{r=!1}),h.stop=(()=>{r=!0,c(`canceling ${o.length} pending preload request(s)`),o.forEach(e=>e.cancel()),o=[]}),h})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){var s=5,a=0,u={times:s,intervalFunc:(0,i.default)(a)};if(arguments.length<3&&"function"==typeof e?(r=t||n.default,t=e):(function(e,t){if("object"==typeof t)e.times=+t.times||s,e.intervalFunc="function"==typeof t.interval?t.interval:(0,i.default)(+t.interval||a),e.errorFilter=t.errorFilter;else{if("number"!=typeof t&&"string"!=typeof t)throw new Error("Invalid arguments for async.retry");e.times=+t||s}}(u,e),r=r||n.default),"function"!=typeof t)throw new Error("Invalid arguments for async.retry");var c=(0,o.default)(t),f=1;!function e(){c(function(t){t&&f++t,o={ip4:i,ip6:i,tcp:(e,t,r,n)=>n.some(e=>["http","https","ws","wss"].includes(e.protocol))?`${e}:${t}`:`tcp://${e}:${t}`,udp:(e,t)=>`udp://${e}:${t}`,dnsaddr:i,dns4:i,dns6:i,ipfs:(e,t)=>`${e}/ipfs/${t}`,p2p:(e,t)=>`${e}/p2p/${t}`,http:e=>`http://${e}`,https:e=>`https://${e}`,ws:e=>`ws://${e}`,wss:e=>`wss://${e}`,"p2p-websocket-star":e=>`${e}/p2p-websocket-star`,"p2p-webrtc-star":e=>`${e}/p2p-webrtc-star`,"p2p-webrtc-direct":e=>`${e}/p2p-webrtc-direct`};e.exports=(e=>n(e).stringTuples().map(e=>({protocol:n.protocols.codes[e[0]].name,content:e[1]})).reduce((e,t,r,n)=>{const i=o[t.protocol];if(!i)throw new Error(`Unsupported protocol ${t.protocol}`);return i(e,t.content,r,n)},""))},function(e,t,r){"use strict";const n=r(1),i=n("jsipfs:preload");i.error=n("jsipfs:preload:error"),e.exports=function(e,t){i(e);const r=new AbortController,n=r.signal;return fetch(e,{signal:n}).then(t=>{if(!t.ok)throw i.error("failed to preload",e,t.status,t.statusText),new Error(`failed to preload ${e}`);return t.text()}).then(()=>t()).catch(t),{cancel:()=>r.abort()}}},function(e,t,r){"use strict";const n=r(1),i=n("jsipfs:mfs-preload");i.error=n("jsipfs:mfs-preload:error"),e.exports=((e,t)=>{let r,n;(t=t||{}).interval=t.interval||3e4;const o=()=>{e.files.stat("/",(s,a)=>s?(n=setTimeout(o,t.interval),i.error("failed to stat MFS root for preload",s)):r!==a.hash?(i(`preloading updated MFS root ${r} -> ${a.hash}`),e._preload(a.hash,e=>{if(n=setTimeout(o,t.interval),e)return i.error(`failed to preload MFS root ${a.hash}`,e);r=a.hash})):void(n=setTimeout(o,t.interval)))};return{start(s){e.files.stat("/",(e,a)=>{if(e)return s(e);r=a.hash,i(`monitoring MFS root ${r}`),n=setTimeout(o,t.interval),s()})},stop(e){clearTimeout(n),e()}}})},function(e,t,r){"use strict";const n=r(1),i=n("jsipfs:state");i.error=n("jsipfs:state:error");const o=r(1453);e.exports=(e=>{const t=o("uninitialized",{uninitialized:{init:"initializing",initialized:"stopped"},initializing:{initialized:"stopped"},stopped:{start:"starting"},starting:{started:"running"},running:{stop:"stopping"},stopping:{stopped:"stopped"}});return t.on("error",e=>i.error(e)),t.on("done",()=>i("-> "+t._state)),t.init=(()=>{t("init")}),t.initialized=(()=>{t("initialized")}),t.stop=(()=>{t("stop")}),t.stopped=(()=>{t("stopped")}),t.start=(()=>{t("start")}),t.started=(()=>{t("started")}),t.state=(()=>t._state),t})},function(e,t,r){const n=r(10).EventEmitter,i=r(16),o=r(1454);e.exports=function(e,t){"object"==typeof e&&(t=e,e="START"),i.equal(typeof e,"string"),i.equal(typeof t,"object"),i.ok(t[e],"invalid starting state "+e),i.ok(o.validate(t));const r=new n;return s._graph=o.reachable(t),s._emitter=r,s._events=t,s._state=e,s.emit=s,s.on=function(e,t){r.on(e,t)},s;function s(e){const t=s._events[s._state][e];if(!function(e,t,r){if(!t)return!1;if(!e)return!0;const n=r[e];return!(!n||!n[t])&&1===n[t].length}(s._state,t,s._graph)){const t="invalid transition: "+s._state+" -> "+e;return r.emit("error",t)}const n=s._state+":leave",i=t+":enter";return s._state?void(r._events[n]?r.emit(n,o):o()):o();function o(){r._events[i]?r.emit(i,a):a()}function a(){s._state=t,r.emit(t),r.emit("done")}}}},function(e,t){function r(e,t){for(var r in e){t(e[r],r,e)}}function n(e){return Object.keys(e).sort()}function i(e,t){return~e.indexOf(t)}function o(e,t){return e.filter(function(e){return i(t,e)})}function s(e,t){return e.filter(function(e){return!i(t,e)}).concat(t.filter(function(t){return!i(e,t)})).sort()}t.validate=function(e){Object.keys(e);return r(e,function(t,n){r(t,function(t,r){if(!e[t])throw new Error("invalid transition from state:"+n+" to state:"+t+" on event:"+r)})}),!0};var a=t.reachable=function(e){var t={},n=!1;do{n=!1,r(e,function(e,i){var o=t[i]=t[i]||{};r(e,function(e,t){o[e]||(o[e]=[t],n=!0)}),r(e,function(e,i){r(t[e],function(e,t){o[t]||(o[t]=[i].concat(e),n=!0)})})})}while(n);return t};t.terminal=t.deadlock=function(e){var t=[];return r(e,function(e,r){(function(e){for(var t in e)return!1;return!0})(e)&&t.push(r)}),t};t.livelock=function(e,t){var n=[];return r(a(e),function(e,o){i(t,o)||r(t,function(t){e[t]||i(n,o)||n.push(o)})}),n.sort()};function u(e){var t=[];return r(e,function(e,n){r(e,function(e,r){i(t,r)||t.push(r)})}),t.sort()}t.combine=function(e,t,r,i){var a={},c=s(u(e),u(t));return function r(i,s){var u,f=i+"-"+s;a[f]||(a[f]={}),u=a[f];var l=n(e[i]),h=n(t[s]);return o(l,h).forEach(function(n){u[n]=e[i][n]+"-"+t[s][n],a[u[n]]||r(e[i][n],t[s][n])}),o(c,l).forEach(function(t){u[t]=e[i][t]+"-"+s,a[u[t]]||r(e[i][t],s)}),o(c,h).forEach(function(e){u[e]=i+"-"+t[s][e],a[u[e]]||r(i,t[s][e])}),a[f]}(r,i),a}},function(e,t,r){const n=r(33),i=r(1456);r(1466)(i),r(1468)(i),r(1469)(i),r(1471)(i),r(1472)(i),r(1482)(i);const o=r(79),s=r(116),a=r(102),u=r(149);let c={db:{name:"indexeddb"},connector:{name:"ipfs"}};class f extends s{constructor(e,t){super(e,t),this.options=e,this.name="YJS",this.supportURLs=["yjs"],this.supportFunctions=["fetch","add","list","listmonitor","newlisturls","connection","get","set","getall","keys","newdatabase","newtable","monitor"],this.status=s.STATUS_LOADED}async p__y(e,t,r){"string"!=typeof e&&(e=e.href),console.assert(e.startsWith("yjs:/yjs/"));try{if(this.yarrays[e])return r&&console.log("Found Y for",e),this.yarrays[e];{let n=s.mergeoptions(this.options,{connector:{room:e}},t);return r&&console.log("Creating Y for",e),this.yarrays[e]=await i(n)}}catch(e){throw console.log("Failed to initialize Y"),e}}async p__yarray(e,t){return this.p__y(e,{share:{array:"Array"}})}async p_connection(e,t){return this.p__y(e,{share:{map:"Map"}})}static setup0(e,t){let r=s.mergeoptions(c,e.yjs);t&&console.log("YJS options %o",r);let n=new f(r,t);return a.addtransport(n),n}async p_setup2(e,t){try{this.status=s.STATUS_STARTING,t&&t(this),this.options.connector.ipfs=a.ipfs(e).ipfs,this.yarrays={},await this.p_status(e)}catch(e){console.error(this.name,"failed to start",e),this.status=s.STATUS_FAILED}return t&&t(this),this}async p_status(e){return this.status=await this.options.connector.ipfs.isOnline()?s.STATUS_CONNECTED:s.STATUS_FAILED,super.p_status(e)}async p_rawlist(e,{verbose:t=!1}={}){try{let r=(await this.p__yarray(e,t)).share.array.toArray();return t&&console.log("p_rawlist found",...u.consolearr(r)),r}catch(e){throw console.log("TransportYJS.p_rawlist failed",e.message),e}}listmonitor(e,t,{verbose:r=!1,current:n=!1}={}){let i=this.yarrays["string"==typeof e?e:e.href];console.assert(i,"Should always exist before calling listmonitor - async call p__yarray(url) to create"),n&&i.share.array.toArray.map(t),i.share.array.observe(e=>{"insert"===e.type&&(r&&console.log("resources inserted",e.values),e.values.map(t))})}rawreverse(){throw new o.ToBeImplementedError("Undefined function TransportYJS.rawreverse")}async p_rawadd(e,t,{verbose:r=!1}={}){console.assert(e&&t.urls.length&&t.signature&&t.signedby.length,"TransportYJS.p_rawadd args",e,t),r&&console.log("TransportYJS.p_rawadd","string"==typeof e?e:e.href,t);let n=t.preflight(Object.assign({},t));(await this.p__yarray(e,r)).share.array.push([n])}p_newlisturls(e,{verbose:t=!1}={}){let r=e._publicurls.map(e=>n.parse(e)).find(e=>"ipfs"===e.protocol&&e.pathname.includes("/ipfs/")||"yjs:"===e.protocol);return r||(r=`yjs:/yjs/${e.keypair.verifyexportmultihashsha256_58()}`),[r,r]}async p_newdatabase(e,{verbose:t=!1}={}){e.hasOwnProperty("keypair")&&(e=e.keypair.signingexport());let r=`yjs:/yjs/${encodeURIComponent(e)}`;return{publicurl:r,privateurl:r}}async p_newtable(e,t,{verbose:r=!1}={}){if(!e)throw new o.CodingError("p_newtable currently requires a pubkey");let n=await this.p_newdatabase(e,{verbose:r});return{privateurl:`${n.privateurl}/${t}`,publicurl:`${n.publicurl}/${t}`}}async p_set(e,t,r,{verbose:n=!1}={}){let i=await this.p_connection(e,n);"string"==typeof t?i.share.map.set(t,JSON.stringify(r)):Object.keys(t).map(e=>i.share.map.set(e,t[e]))}_p_get(e,t,{verbose:r=!1}={}){if(Array.isArray(t))return t.reduce(function(t,r){let n=e.share.map.get(r);return t[r]="string"==typeof n?JSON.parse(n):n,t},{});{let r=e.share.map.get(t);return"string"==typeof r?JSON.parse(r):r}}async p_get(e,t,{verbose:r=!1}={}){return this._p_get(await this.p_connection(e,r),t,{verbose:r})}async p_delete(e,t,{verbose:r=!1}={}){let n=await this.p_connection(e,r);"string"==typeof t?n.share.map.delete(t):t.map(e=>n.share.map.delete(e))}async p_keys(e,{verbose:t=!1}={}){return(await this.p_connection(e,t)).share.map.keys()}async p_getall(e,{verbose:t=!1}={}){let r=await this.p_connection(e,t),n=r.share.map.keys();return this._p_get(r,n,{verbose:t})}async p_rawfetch(e,{verbose:t=!1}={}){return{table:"keyvaluetable",_map:await this.p_getall(e,{verbose:t})}}async monitor(e,t,{verbose:r=!1,current:n=!1}={}){e="string"==typeof e?e:e.href;let i=this.yarrays[e];if(!i)throw new o.CodingError("Should always exist before calling monitor - async call p__yarray(url) to create");n&&i.share.map.keys().forEach(e=>{let r=i.share.map.get[e];t({type:"set",key:e,value:"string"==typeof r?JSON.parse(r):r})}),i.share.map.observe(n=>{if(["add","update"].includes(n.type)&&(r&&console.log("YJS monitor:",e,n.type,n.name,n.value),"update"!==n.type||n.oldValue!==n.value)){let e={type:{add:"set",update:"set",delete:"delete"}[n.type],value:JSON.parse(n.value),key:n.name};t(e)}})}static async p_test(e={},t=!1){t&&console.log("TransportHTTP.test");try{let r=await this.p_setup(e,t);t&&console.log("HTTP connected");let n=await r.p_info(t);t&&console.log("TransportHTTP info=",n),n=await r.p_status(t),console.assert(n===s.STATUS_CONNECTED),await r.p_test_kvt("NACL%20VERIFY",t)}catch(e){throw console.log("Exception thrown in TransportHTTP.test:",e.message),e}}}f.Y=i,a._transportclasses.YJS=f,e.exports=f},function(e,t,r){"use strict";r(1457)(i),r(1458)(i),r(1459)(i),r(1460)(i),r(1461)(i),r(1462)(i),i.debug=r(1463);var n={};function i(e){e.hasOwnProperty("sourceDir")&&(i.sourceDir=e.sourceDir),e.types=null!=e.types?e.types:[];var t=[e.db.name,e.connector.name].concat(e.types);for(var r in e.share)t.push(e.share[r]);return new Promise(function(r,n){null==e?n("An options object is expected! "):null==e.connector?n("You must specify a connector! (missing connector property)"):null==e.connector.name?n("You must specify connector name! (missing connector.name property)"):null==e.db?n("You must specify a database! (missing db property)"):null==e.connector.name?n("You must specify db name! (missing db.name property)"):((e=i.utils.copyObject(e)).connector=i.utils.copyObject(e.connector),e.db=i.utils.copyObject(e.db),e.share=i.utils.copyObject(e.share),setTimeout(function(){i.requestModules(t).then(function(){var t=new o(e);t.db.whenUserIdSet(function(){t.init(function(){r(t)})})}).catch(n)},0))})}e.exports=i,i.requiringModules=n,i.extend=function(e,t){if(2===arguments.length&&"string"==typeof e)t instanceof i.utils.CustomTypeDefinition?i[e]=t.parseArguments:i[e]=t,null!=n[e]&&(n[e].resolve(),delete n[e]);else for(var r=0;r{})}userLeft(e){if(null!=this.connections[e])for(var t of(this.log("User left: %s",e),delete this.connections[e],e===this.currentSyncTarget&&(this.currentSyncTarget=null,this.findNextSyncTarget()),this.syncingClients=this.syncingClients.filter(function(t){return t!==e}),this.userEventListeners))t({action:"userLeft",user:e})}userJoined(e,t){if(null==t)throw new Error("You must specify the role of the joined user!");if(null!=this.connections[e])throw new Error("This user already joined!");for(var r of(this.log("User joined: %s",e),this.connections[e]={isSynced:!1,role:t},this.userEventListeners))r({action:"userJoined",user:e,role:t});null==this.currentSyncTarget&&this.findNextSyncTarget()}whenSynced(e){this.isSynced?e():this.whenSyncedListeners.push(e)}findNextSyncTarget(){if(null==this.currentSyncTarget){var e=null;for(var t in this.connections)if(!this.connections[t].isSynced){e=t;break}var r=this;null!=e?(this.currentSyncTarget=e,this.y.db.requestTransaction(function*(){var t={type:"sync step 1",stateSet:yield*this.getStateSet(),deleteSet:yield*this.getDeleteSet(),protocolVersion:r.protocolVersion,auth:r.authInfo};r.send(e,t)})):r.isSynced||this.y.db.requestTransaction(function*(){if(!r.isSynced){for(var e of(r.isSynced=!0,yield*this.garbageCollectAfterSync(),r.whenSyncedListeners))e();r.whenSyncedListeners=[]}})}}send(e,t){this.log("Send '%s' to %s",t.type,e),this.logMessage("Message: %j",t)}broadcast(e){this.log("Broadcast '%s'",e.type),this.logMessage("Message: %j",e)}broadcastOps(t){t=t.map(function(t){return e.Struct[t.struct].encode(t)});var r=this;function n(){r.broadcastOpBuffer.length>0&&(r.broadcast({type:"update",ops:r.broadcastOpBuffer}),r.broadcastOpBuffer=[])}0===this.broadcastOpBuffer.length?(this.broadcastOpBuffer=t,this.y.db.transactionInProgress?this.y.db.whenTransactionsFinished().then(n):setTimeout(n,0)):this.broadcastOpBuffer=this.broadcastOpBuffer.concat(t)}receiveMessage(e,t){if(e===this.userId)return Promise.resolve();if(this.log("Receive '%s' from %s",t.type,e),this.logMessage("Message: %j",t),null!=t.protocolVersion&&t.protocolVersion!==this.protocolVersion)return this.log(`You tried to sync with a yjs instance that has a different protocol version\n (You: ${this.protocolVersion}, Client: ${t.protocolVersion}).\n The sync was stopped. You need to upgrade your dependencies (especially Yjs & the Connector)!\n `),this.send(e,{type:"sync stop",protocolVersion:this.protocolVersion}),Promise.reject("Incompatible protocol version");if(null!=t.auth&&null!=this.connections[e]){var n=this.checkAuth(t.auth,this.y,e);this.connections[e].auth=n,n.then(t=>{for(var r of this.userEventListeners)r({action:"userAuthenticated",user:e,auth:t})})}else null!=this.connections[e]&&null==this.connections[e].auth&&(this.connections[e].auth=this.checkAuth(null,this.y,e));return null!=this.connections[e]&&null!=this.connections[e].auth?this.connections[e].auth.then(n=>{if("sync step 1"===t.type&&function(e){return"read"===e||"write"===e}(n)){let i=this,o=t;this.y.db.requestTransaction(function*(){var t=yield*this.getStateSet();r(n)&&(yield*this.applyDeleteSet(o.deleteSet));var s={type:"sync step 2",stateSet:t,deleteSet:yield*this.getDeleteSet(),protocolVersion:this.protocolVersion,auth:this.authInfo};s.os=yield*this.getOperations(o.stateSet),i.send(e,s),this.forwardToSyncingClients?(i.syncingClients.push(e),setTimeout(function(){i.syncingClients=i.syncingClients.filter(function(t){return t!==e}),i.send(e,{type:"sync done"})},5e3)):i.send(e,{type:"sync done"})})}else if("sync step 2"===t.type&&r(n)){var i=this.y.db,o={};o.promise=new Promise(function(e){o.resolve=e}),this.syncStep2=o.promise;let e=t;i.requestTransaction(function*(){yield*this.applyDeleteSet(e.deleteSet),null!=e.osUntransformed?yield*this.applyOperationsUntransformed(e.osUntransformed,e.stateSet):this.store.apply(e.os),o.resolve()})}else if("sync done"===t.type){var s=this;this.syncStep2.then(function(){s._setSyncedWith(e)})}else if("update"===t.type&&r(n)){if(this.forwardToSyncingClients)for(var a of this.syncingClients)this.send(a,t);if(this.y.db.forwardAppliedOperations){var u=t.ops.filter(function(e){return"Delete"===e.struct});u.length>0&&this.broadcastOps(u)}this.y.db.apply(t.ops)}}):Promise.reject("Unable to deliver message")}_setSyncedWith(e){var t=this.connections[e];null!=t&&(t.isSynced=!0),e===this.currentSyncTarget&&(this.currentSyncTarget=null,this.findNextSyncTarget())}parseMessageFromXml(e){function t(e){for(var n of e.children)return"true"===n.getAttribute("isArray")?t(n):r(n)}function r(e){var n={};for(var i in e.attrs){var o=e.attrs[i],s=parseInt(o,10);isNaN(s)||""+s!==o?n[i]=o:n[i]=s}for(var a in e.children){var u=a.name;"true"===a.getAttribute("isArray")?n[u]=t(a):n[u]=r(a)}return n}r(e)}encodeMessageToXml(e,t){function r(e,t){for(var i in t){var o=t[i];null==i||(o.constructor===Object?r(e.c(i),o):o.constructor===Array?n(e.c(i),o):e.setAttribute(i,o))}}function n(e,t){for(var i of(e.setAttribute("isArray","true"),t))i.constructor===Object?r(e.c("array-element"),i):n(e.c("array-element"),i)}if(t.constructor===Object)r(e.c("y",{xmlns:"http://y.ninja/connector-stanza"}),t);else{if(t.constructor!==Array)throw new Error("I can't encode this json!");n(e.c("y",{xmlns:"http://y.ninja/connector-stanza"}),t)}}}}},function(e,t,r){"use strict";e.exports=function(e){e.AbstractDatabase=class{constructor(e,t){this.y=e,this.dbOpts=t;var r,n=this;this.userId=null,this.userIdPromise=new Promise(function(e){r=e}),this.userIdPromise.resolve=r,this.forwardAppliedOperations=!1,this.listenersById={},this.listenersByIdExecuteNow=[],this.listenersByIdRequestPending=!1,this.initializedTypes={},this.waitingTransactions=[],this.transactionInProgress=!1,this.transactionIsFlushed=!1,"undefined"!=typeof YConcurrency_TestingMode&&(this.executeOrder=[]),this.gc1=[],this.gc2=[],this.garbageCollect=function e(){return n.whenTransactionsFinished().then(function(){return n.gc1.length>0||n.gc2.length>0?(n.y.connector.isSynced||console.warn("gc should be empty when not synced!"),new Promise(t=>{n.requestTransaction(function*(){if(null!=n.y.connector&&n.y.connector.isSynced){for(var r=0;r0&&(n.gcInterval=setTimeout(e,n.gcTimeout)),t()})})):(n.gcTimeout>0&&(n.gcInterval=setTimeout(e,n.gcTimeout)),Promise.resolve())})},this.startGarbageCollector(),this.repairCheckInterval=t.repairCheckInterval?t.repairCheckInterval:6e3,this.opsReceivedTimestamp=new Date,this.startRepairCheck()}startGarbageCollector(){this.gc=null==this.dbOpts.gc||this.dbOpts.gc,this.gc?this.gcTimeout=this.dbOpts.gcTimeout?this.dbOpts.gcTimeout:5e4:this.gcTimeout=-1,this.gcTimeout>0&&this.garbageCollect()}startRepairCheck(){var e=this;this.repairCheckInterval>0&&(this.repairCheckIntervalHandler=setInterval(function(){new Date-e.opsReceivedTimestamp>e.repairCheckInterval&&Object.keys(e.listenersById).length>0&&(e.listenersById={},e.opsReceivedTimestamp=new Date,e.y.connector.repair())},this.repairCheckInterval))}stopRepairCheck(){clearInterval(this.repairCheckIntervalHandler)}queueGarbageCollector(e){this.y.connector.isSynced&&this.gc&&this.gc1.push(e)}emptyGarbageCollector(){return new Promise(e=>{var t=()=>{this.gc1.length>0||this.gc2.length>0?this.garbageCollect().then(t):e()};setTimeout(t,0)})}addToDebug(){if("undefined"!=typeof YConcurrency_TestingMode){var e=Array.prototype.map.call(arguments,function(e){return"string"==typeof e?e:JSON.stringify(e)}).join("").replace(/"/g,"'").replace(/,/g,", ").replace(/:/g,": ");this.executeOrder.push(e)}}getDebugData(){console.log(this.executeOrder.join("\n"))}stopGarbageCollector(){var e=this;return this.gc=!1,this.gcTimeout=-1,new Promise(function(t){e.requestTransaction(function*(){var r=e.gc1.concat(e.gc2);e.gc1=[],e.gc2=[];for(var n=0;n1&&(e=yield*this.getInsertionCleanStart([e.id[0],e.id[1]+1]),r=!0),r)return e.gc=!0,yield*this.setOperation(e),this.store.queueGarbageCollector(e.id),!0}return!1}removeFromGarbageCollector(t){function r(r){return!e.utils.compareIds(r,t.id)}this.gc1=this.gc1.filter(r),this.gc2=this.gc2.filter(r),delete t.gc}destroyTypes(){for(var e in this.initializedTypes){var t=this.initializedTypes[e];null!=t._destroy?t._destroy():console.error("The type you included does not provide destroy functionality, it will remain in memory (updating your packages will help).")}}*destroy(){clearInterval(this.gcInterval),this.gcInterval=null,this.stopRepairCheck()}setUserId(e){if(!this.userIdPromise.inProgress){this.userIdPromise.inProgress=!0;var t=this;t.requestTransaction(function*(){t.userId=e;var r=yield*this.getState(e);t.opClock=r.clock,t.userIdPromise.resolve(e)})}return this.userIdPromise}whenUserIdSet(e){this.userIdPromise.then(e)}getNextOpId(e){if(null==e)throw new Error("getNextOpId expects the number of created ids to create!");if(null==this.userId)throw new Error("OperationStore not yet initialized!");var t=[this.userId,this.opClock];return this.opClock+=e,t}apply(t){this.opsReceivedTimestamp=new Date;for(var r=0;r0){let r={op:t,missing:e.length};for(let t=0;t{this.transact(this.getNextRequest())},0))}getType(e){return this.initializedTypes[JSON.stringify(e)]}*initType(t,r){var n=JSON.stringify(t),i=this.store.initializedTypes[n];if(null==i){var o=yield*this.getOperation(t);null!=o&&(i=yield*e[o.type].typeDefinition.initType.call(this,this.store,o,r),this.store.initializedTypes[n]=i)}return i}createType(t,r){var n=t[0].struct;r=r||this.getNextOpId(1);var i=e.Struct[n].create(r);i.type=t[0].name,this.requestTransaction(function*(){"_"===i.id[0]?yield*this.setOperation(i):yield*this.applyCreatedOperations([i])});var o=e[i.type].typeDefinition.createType(this,i,t[1]);return this.initializedTypes[JSON.stringify(i.id)]=o,o}}}},function(e,t,r){"use strict";e.exports=function(e){e.Transaction=class{*applyCreatedOperations(t){for(var r=[],n=0;n0&&this.store.y.connector.broadcastOps(r)}*deleteList(e){for(;null!=e;){if(!(e=yield*this.getOperation(e)).gc){e.gc=!0,e.deleted=!0,yield*this.setOperation(e);var t=null!=e.content?e.content.length:1;yield*this.markDeleted(e.id,t),null!=e.opContent&&(yield*this.deleteOperation(e.opContent)),this.store.queueGarbageCollector(e.id)}e=e.right}}*deleteOperation(e,t,r){for(null==t&&(t=1),yield*this.markDeleted(e,t);t>0;){var n=!1,i=yield*this.os.findWithUpperBound([e[0],e[1]+t-1]),o=null!=i&&null!=i.content?i.content.length:1;if(null==i||i.id[0]!==e[0]||i.id[1]+o<=e[1]?(i=null,t=0):(i.deleted||(i.id[1]e[1]+t&&(o=(i=yield*this.getInsertionCleanEnd([e[0],e[1]+t-1])).content.length)),t=i.id[1]-e[1]),null!=i){if(!i.deleted){if(n=!0,i.deleted=!0,null!=i.start&&(yield*this.deleteList(i.start)),null!=i.map)for(var s in i.map)yield*this.deleteList(i.map[s]);if(null!=i.opContent&&(yield*this.deleteOperation(i.opContent)),null!=i.requires)for(var a=0;a0))return r;if(r.gc){if(!((n=r.id[1]+r.len-e[1])=i.id[1])for(n=r.id[1]+r.len-i.id[1];n>=0;){if(i.gc){r.len-=n,n>=i.len&&(n-=i.len)>0&&(yield*this.ds.put(r),yield*this.markDeleted([i.id[0],i.id[1]+i.len],n));break}if(!(n>i.len)){r.len+=i.len-n,yield*this.ds.delete(i.id);break}var o=yield*this.ds.findNext(i.id);if(yield*this.ds.delete(i.id),null==o||r.id[0]!==o.id[0])break;i=o,n=r.id[1]+r.len-i.id[1]}return yield*this.ds.put(r),r}*garbageCollectAfterSync(){(this.store.gc1.length>0||this.store.gc2.length>0)&&console.warn("gc should be empty after sync"),this.store.gc&&(yield*this.os.iterate(this,null,null,function*(e){if(e.gc&&(delete e.gc,yield*this.setOperation(e)),null!=e.parent&&(yield*this.isDeleted(e.parent))){if(e.gc=!0,!e.deleted&&(yield*this.markDeleted(e.id,null!=e.content?e.content.length:1),e.deleted=!0,null!=e.opContent&&(yield*this.deleteOperation(e.opContent)),null!=e.requires))for(var t=0;t0){for(var c=r.left,f=null;null!=c&&!(f=yield*this.getInsertion(c)).deleted;)c=f.left;for(var l in r.originOf){var h=yield*this.getOperation(r.originOf[l]);null!=h&&(h.origin=c,yield*this.setOperation(h))}null!=c&&(null==f.originOf?f.originOf=r.originOf:f.originOf=r.originOf.concat(f.originOf),yield*this.setOperation(f))}}if(null!=r.origin){var p=yield*this.getInsertion(r.origin);p.originOf=p.originOf.filter(function(r){return!e.utils.compareIds(t,r)}),yield*this.setOperation(p)}if(null!=r.parent&&(n=yield*this.getOperation(r.parent)),null!=n){var d=!1;null!=r.parentSub?e.utils.compareIds(n.map[r.parentSub],r.id)&&(d=!0,null!=r.right?n.map[r.parentSub]=r.right:delete n.map[r.parentSub]):(e.utils.compareIds(n.start,r.id)&&(d=!0,n.start=r.right),e.utils.matchesId(r,n.end)&&(d=!0,n.end=r.left)),d&&(yield*this.setOperation(n))}yield*this.removeOperation(r.id)}}*checkDeleteStoreForState(e){var t=yield*this.ds.findWithUpperBound([e.user,e.clock]);null!=t&&t.id[0]===e.user&&t.gc&&(e.clock=Math.max(e.clock,t.id[1]+t.len))}*updateState(e){var t=yield*this.getState(e);yield*this.checkDeleteStoreForState(t);for(var r=yield*this.getInsertion([e,t.clock]),n=null!=r&&null!=r.content?r.content.length:1;null!=r&&e===r.id[0]&&r.id[1]<=t.clock&&r.id[1]+n>t.clock;)t.clock+=n,yield*this.checkDeleteStoreForState(t),n=null!=(r=yield*this.os.findNext(r.id))&&null!=r.content?r.content.length:1;yield*this.setState(t)}*applyDeleteSet(e){var t=[];for(var r in e){var n=e[r],i=0,o=n[i];for(yield*this.ds.iterate(this,[r,0],[r,Number.MAX_VALUE],function*(e){for(;null!=o;){var s=0;if(e.id[1]+e.len<=o[0])break;o[0]=a[1];){var c=yield*this.os.findWithUpperBound([a[0],u-1]);if(null==c)break;var f=null!=c.content?c.content.length:1;if(c.id[0]!==a[0]||c.id[1]+f<=a[1])break;c.id[1]+f>a[1]+a[2]&&(c=yield*this.getInsertionCleanEnd([a[0],a[1]+a[2]-1])),c.id[1]1){var i=n[0],o=e.Struct[i].create(t);return o.type=n[1],yield*this.setOperation(o),o}return console.error("Unexpected case. How can this happen?"),null}*removeOperation(e){yield*this.os.delete(e)}*setState(e){var t={id:[e.user],clock:e.clock};yield*this.ss.put(t)}*getState(e){var t=yield*this.ss.find([e]),r=null==t?null:t.clock;return null==r&&(r=0),{user:e,clock:r}}*getStateVector(){var e=[];return yield*this.ss.iterate(this,null,null,function*(t){e.push({user:t.id[0],clock:t.clock})}),e}*getStateSet(){var e={};return yield*this.ss.iterate(this,null,null,function*(t){e[t.id[0]]=t.clock}),e}*getOperations(t){null==t&&(t={});var r=[],n=yield*this.getStateVector();for(var i of n){var o=i.user;if("_"!==o){var s=t[o]||0;if(s>0){var a=yield*this.getInsertion([o,s]);null!=a&&(s=a.id[1],t[o]=s)}yield*this.os.iterate(this,[o,s],[o,Number.MAX_VALUE],function*(n){if("Insert"!==(n=e.Struct[n.struct].encode(n)).struct)r.push(n);else if(null==n.right||n.right[1]<(t[n.right[0]]||0))for(var i=n,o=[n],s=n.right;;){if(null==i.left){n.left=null,r.push(n),e.utils.compareIds(i.id,n.id)||((i=e.Struct[n.struct].encode(i)).right=o[o.length-1].id,r.push(i));break}for(i=yield*this.getInsertion(i.left);o.length>0&&e.utils.matchesId(i,o[o.length-1].origin);)o.pop();if(i.id[1]<(t[i.id[0]]||0)){n.left=e.utils.getLastId(i),r.push(n);break}if(e.utils.matchesId(i,n.origin))n.left=n.origin,r.push(n),(n=e.Struct[n.struct].encode(i)).right=s,o.length>0&&console.log("This should not happen .. :( please report this"),o=[n];else{var a=e.Struct[n.struct].encode(i);a.right=o[o.length-1].id,a.left=a.origin,r.push(a),o.push(i)}}})}}return r.reverse()}*getOperationsUntransformed(){var e=[];return yield*this.os.iterate(this,null,null,function*(t){"_"!==t.id[0]&&e.push(t)}),{untransformed:e}}*applyOperationsUntransformed(t,r){for(var n=t.untransformed,i=0;i1&&(l=yield*this.getInsertionCleanEnd(l.id)),this.store.removeFromGarbageCollector(l)),yield*this.setOperation(l)),null!=r.parentSub?(null==f&&(a.map[r.parentSub]=r.id,yield*this.setOperation(a)),null!=r.right&&(yield*this.deleteOperation(r.right,1,!0)),null!=r.left&&(yield*this.deleteOperation(r.id,1,!0))):null!=l&&null!=f||(null==l&&(a.end=e.utils.getLastId(r)),null==f&&(a.start=r.id),yield*this.setOperation(a)),n=0;n=0&&null!=n.right;)n=yield*this.getOperation(n.right);return r},map:function*(e,t){e=e.start;for(var r=[];null!=e;){var n=yield*this.getOperation(e);n.deleted||r.push(t(n)),e=n.right}return r}},Map:{create:function(e){return{id:e,map:{},struct:"Map"}},encode:function(e){var t={struct:"Map",type:e.type,id:e.id,map:{}};return null!=e.requires&&(t.requires=e.requires),null!=e.info&&(t.info=e.info),t},requiredOps:function(){return[]},execute:function*(){},get:function*(e,t){var r=e.map[t];if(null!=r){var n=yield*this.getOperation(r);return null==n||n.deleted?void 0:null==n.opContent?n.content[0]:yield*this.getType(n.opContent)}}}};e.Struct=t}},function(e,t,r){"use strict";e.exports=function(e){e.utils={},e.utils.bubbleEvent=function(e,t){for(e.eventHandler.callEventListeners(t),t.path=[];null!=e&&null!=e._deepEventHandler;){e._deepEventHandler.callEventListeners(t);var r=null;null!=e._parent&&(r=e.os.getType(e._parent)),null!=r&&null!=r._getPathToChild?(t.path=[r._getPathToChild(e._model)].concat(t.path),e=r):e=null}};class t{constructor(){this.eventListeners=[]}destroy(){this.eventListeners=null}addEventListener(e){this.eventListeners.push(e)}removeEventListener(e){this.eventListeners=this.eventListeners.filter(function(t){return e!==t})}removeAllEventListeners(){this.eventListeners=[]}callEventListeners(e){for(var t=0;t0&&this.awaiting--,0===this.awaiting&&this.waiting.length>0){for(let r=0;r0;)for(var n=0;n=0;o--){let t=this.waiting[o];"Insert"===t.struct&&(e.utils.matchesId(t,i.left)?(t.right=i.id,i.left=t.left):e.utils.compareIds(t.id,i.right)&&(t.left=e.utils.getLastId(i),i.right=t.right))}}this._tryCallEvents(t)}awaitedDeletes(t,r){for(var n=this.waiting.splice(this.waiting.length-t),i=0;i0&&this.awaiting--,0===this.awaiting&&this.waiting.length>0){var t=[],r=[];this.waiting.forEach(function(e){"Delete"===e.struct?r.push(e):t.push(e)}),(t=function(t){for(var r=[];t.length>0;)for(var n=0;n=e.id[1]&&t[1]=0;r--)if((n=this.readBuffer[r]).id[1]===e[1]&&n.id[0]===e[0]){for(;r=0;r--)if((n=this.writeBuffer[r]).id[1]===e[1]&&n.id[0]===e[0]){i=n;break}if(r<0&&void 0===t&&(i=yield*super.find(e)),null!=i){for(r=0;r=0;t--)if((r=this.writeBuffer[t]).id[1]===n[1]&&r.id[0]===n[0]){for(;t>t/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e)}}},function(e,t,r){"use strict";e.exports=function(e){var t={users:{},buffers:{},removeUser:function(e){for(var t in this.users)this.users[t].userLeft(e);delete this.users[e],delete this.buffers[e]},addUser:function(e){for(var t in this.users[e.userId]=e,this.buffers[e.userId]={},this.users)if(t!==e.userId){var r=this.users[t];r.userJoined(e.userId,"master"),e.userJoined(r.userId,"master")}},whenTransactionsFinished:function(){var e=this;return new Promise(function(t,r){setTimeout(function(){var n=[];for(var i in e.users)n.push(e.users[i].y.db.whenTransactionsFinished());Promise.all(n).then(t,r)},10)})},flushOne:function(){var e=[];for(var r in t.buffers){let i=t.buffers[r];var n=!1;for(let e in i)if(i[e].length>0){n=!0;break}n&&e.push(r)}if(e.length>0){var i=getRandom(e);let r=t.buffers[i],n=getRandom(Object.keys(r));var o=r[n].shift();0===r[n].length&&delete r[n];var s=t.users[i];return s.receiveMessage(o[0],o[1]).then(function(){return s.y.db.whenTransactionsFinished()},function(){})}return!1},flushAll:function(){return new Promise(function(e){t.whenTransactionsFinished().then(function r(){var n=t.flushOne();if(n){for(;n;)n=t.flushOne();t.whenTransactionsFinished().then(r)}else(n=t.flushOne())?n.then(function(){t.whenTransactionsFinished().then(r)}):e()})})}};e.utils.globalRoom=t;var r=0;e.Test=class extends e.AbstractConnector{constructor(e,n){if(void 0===n)throw new Error("Options must not be undefined!");n.role="master",n.forwardToSyncingClients=!1,super(e,n),this.setUserId(r+++"").then(()=>{t.addUser(this)}),this.globalRoom=t,this.syncingClientDuration=0}receiveMessage(e,t){return super.receiveMessage(e,JSON.parse(JSON.stringify(t)))}send(e,r){var n=t.buffers[e];null!=n&&(null==n[this.userId]&&(n[this.userId]=[]),n[this.userId].push(JSON.parse(JSON.stringify([this.userId,r]))))}broadcast(e){for(var r in t.buffers){var n=t.buffers[r];null==n[this.userId]&&(n[this.userId]=[]),n[this.userId].push(JSON.parse(JSON.stringify([this.userId,e])))}}isDisconnected(){return null==t.users[this.userId]}reconnect(){return this.isDisconnected()&&(t.addUser(this),super.reconnect()),e.utils.globalRoom.flushAll()}disconnect(){var e=Promise.resolve();this.isDisconnected()||(t.removeUser(this.userId),e=super.disconnect());var r=this;return e.then(function(){return r.y.db.whenTransactionsFinished()})}flush(){var e=this;return async(function*(){for(var r=t.buffers[e.userId];Object.keys(r).length>0;){var n=getRandom(Object.keys(r)),i=r[n].shift();0===r[n].length&&delete r[n],yield this.receiveMessage(i[0],i[1])}yield e.whenTransactionsFinished()})}}}},function(e,t,r){(function(n){function i(){var e;try{e=t.storage.debug}catch(e){}return!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG),e}(t=e.exports=r(1464)).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var r=this.useColors;if(e[0]=(r?"%c":"")+this.namespace+(r?" %c":" ")+e[0]+(r?"%c ":" ")+"+"+t.humanize(this.diff),r){var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var i=0,o=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&"%c"===e&&(o=++i)}),e.splice(o,0,n)}},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=i,t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type)||"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(i())}).call(this,r(6))},function(e,t,r){var n;function i(e){function r(){if(r.enabled){var e=r,i=+new Date,o=i-(n||i);e.diff=o,e.prev=n,e.curr=i,n=i;for(var s=new Array(arguments.length),a=0;a0||this.store.gc2.length>0)&&console.warn("GC1|2 not empty!",this.store.gc1,this.store.gc2),"{}"!==JSON.stringify(this.store.listenersById)&&console.warn("listenersById not empty!"),"[]"!==JSON.stringify(this.store.listenersByIdExecuteNow)&&console.warn("listenersByIdExecuteNow not empty!"),this.store.transactionInProgress&&console.warn("Transaction still in progress!")},!0)}transact(e){for(var r=new t(this);null!==e;){for(var n=e.call(r),i=n.next();!i.done;)i=n.next(i.value);e=this.getNextRequest()}}*destroy(){yield*super.destroy(),delete this.os,delete this.ss,delete this.ds}})}e.exports=n,"undefined"!=typeof Y&&n(Y)},function(e,t,r){"use strict";e.exports=function(e){class t{constructor(e){if(this.val=e,this.color=!0,this._left=null,this._right=null,this._parent=null,null===e.id)throw new Error("You must define id!")}isRed(){return this.color}isBlack(){return!this.color}redden(){return this.color=!0,this}blacken(){return this.color=!1,this}get grandparent(){return this.parent.parent}get parent(){return this._parent}get sibling(){return this===this.parent.left?this.parent.right:this.parent.left}get left(){return this._left}get right(){return this._right}set left(e){null!==e&&(e._parent=this),this._left=e}set right(e){null!==e&&(e._parent=this),this._right=e}rotateLeft(e){var t=this.parent,r=this.right,n=this.right.left;if(r.left=this,this.right=n,null===t)e.root=r,r._parent=null;else if(t.left===this)t.left=r;else{if(t.right!==this)throw new Error("The elements are wrongly connected!");t.right=r}}next(){if(null!==this.right){for(var e=this.right;null!==e.left;)e=e.left;return e}for(var t=this;null!==t.parent&&t!==t.parent.left;)t=t.parent;return t.parent}prev(){if(null!==this.left){for(var e=this.left;null!==e.right;)e=e.right;return e}for(var t=this;null!==t.parent&&t!==t.parent.right;)t=t.parent;return t.parent}rotateRight(e){var t=this.parent,r=this.left,n=this.left.right;if(r.right=this,this.left=n,null===t)e.root=r,r._parent=null;else if(t.left===this)t.left=r;else{if(t.right!==this)throw new Error("The elements are wrongly connected!");t.right=r}}getUncle(){return this.parent===this.parent.parent.left?this.parent.parent.right:this.parent.parent.left}}e.utils.RBTree=class{constructor(){this.root=null,this.length=0}*findNext(e){return yield*this.findWithLowerBound([e[0],e[1]+1])}*findPrev(e){return yield*this.findWithUpperBound([e[0],e[1]-1])}findNodeWithLowerBound(t){if(void 0===t)throw new Error("You must define from!");var r=this.root;if(null===r)return null;for(;;)if(null!==t&&!e.utils.smaller(t,r.val.id)||null===r.left){if(null===t||!e.utils.smaller(r.val.id,t))return r;if(null===r.right)return r.next();r=r.right}else r=r.left}findNodeWithUpperBound(t){if(void 0===t)throw new Error("You must define from!");var r=this.root;if(null===r)return null;for(;;)if(null!==t&&!e.utils.smaller(r.val.id,t)||null===r.right){if(null===t||!e.utils.smaller(t,r.val.id))return r;if(null===r.left)return r.prev();r=r.left}else r=r.right}findSmallestNode(){for(var e=this.root;null!=e&&null!=e.left;)e=e.left;return e}*findWithLowerBound(e){var t=this.findNodeWithLowerBound(e);return null==t?null:t.val}*findWithUpperBound(e){var t=this.findNodeWithUpperBound(e);return null==t?null:t.val}*iterate(t,r,n,i){var o;for(o=null===r?this.findSmallestNode():this.findNodeWithLowerBound(r);null!==o&&(null===n||e.utils.smaller(o.val.id,n)||e.utils.compareIds(o.val.id,n));)yield*i.call(t,o.val),o=o.next();return!0}*logTable(e,t,r){null==r&&(r=function(){return!0}),null==e&&(e=null),null==t&&(t=null);var n=[];yield*this.iterate(this,e,t,function*(e){if(r(e)){var t={};for(var i in e)"object"==typeof e[i]?t[i]=JSON.stringify(e[i]):t[i]=e[i];n.push(t)}}),null!=console.table&&console.table(n)}*find(e){var t;return(t=this.findNode(e))?t.val:null}findNode(t){if(null==t||t.constructor!==Array)throw new Error("Expect id to be an array!");var r=this.root;if(null===r)return!1;for(;;){if(null===r)return!1;if(e.utils.smaller(t,r.val.id))r=r.left;else{if(!e.utils.smaller(r.val.id,t))return r;r=r.right}}}*delete(e){if(null==e||e.constructor!==Array)throw new Error("id is expected to be an Array!");var r=this.findNode(e);if(null!=r){if(this.length--,null!==r.left&&null!==r.right){for(var n=r.left;null!==n.right;)n=n.right;r.val=n.val,r=n}var i,o=r.left||r.right;if(null===o?(i=!0,(o=new t({id:0})).blacken(),r.right=o):i=!1,null!==r.parent){if(r.parent.left===r)r.parent.left=o;else{if(r.parent.right!==r)throw new Error("Impossible!");r.parent.right=o}if(r.isBlack()&&(o.isRed()?o.blacken():this._fixDelete(o)),this.root.blacken(),i)if(o.parent.left===o)o.parent.left=null;else{if(o.parent.right!==o)throw new Error("Impossible #3");o.parent.right=null}}else i?this.root=null:(this.root=o,o.blacken(),o._parent=null)}}_fixDelete(e){function t(e){return null===e||e.isBlack()}function r(e){return null!==e&&e.isRed()}if(null!==e.parent){var n=e.sibling;if(r(n)){if(e.parent.redden(),n.blacken(),e===e.parent.left)e.parent.rotateLeft(this);else{if(e!==e.parent.right)throw new Error("Impossible #2");e.parent.rotateRight(this)}n=e.sibling}e.parent.isBlack()&&n.isBlack()&&t(n.left)&&t(n.right)?(n.redden(),this._fixDelete(e.parent)):e.parent.isRed()&&n.isBlack()&&t(n.left)&&t(n.right)?(n.redden(),e.parent.blacken()):(e===e.parent.left&&n.isBlack()&&r(n.left)&&t(n.right)?(n.redden(),n.left.blacken(),n.rotateRight(this),n=e.sibling):e===e.parent.right&&n.isBlack()&&r(n.right)&&t(n.left)&&(n.redden(),n.right.blacken(),n.rotateLeft(this),n=e.sibling),n.color=e.parent.color,e.parent.blacken(),e===e.parent.left?(n.right.blacken(),e.parent.rotateLeft(this)):(n.left.blacken(),e.parent.rotateRight(this)))}}*put(r){if(null==r||null==r.id||r.id.constructor!==Array)throw new Error("v is expected to have an id property which is an Array!");var n=new t(r);if(null!==this.root){for(var i=this.root;;)if(e.utils.smaller(n.val.id,i.val.id)){if(null===i.left){i.left=n;break}i=i.left}else{if(!e.utils.smaller(i.val.id,n.val.id))return i.val=n.val,i;if(null===i.right){i.right=n;break}i=i.right}this._fixInsert(n)}else this.root=n;return this.length++,this.root.blacken(),n}_fixInsert(e){if(null!==e.parent){if(!e.parent.isBlack()){var t=e.getUncle();null!==t&&t.isRed()?(e.parent.blacken(),t.blacken(),e.grandparent.redden(),this._fixInsert(e.grandparent)):(e===e.parent.right&&e.parent===e.grandparent.left?(e.parent.rotateLeft(this),e=e.left):e===e.parent.left&&e.parent===e.grandparent.right&&(e.parent.rotateRight(this),e=e.right),e.parent.blacken(),e.grandparent.redden(),e===e.parent.left?e.grandparent.rotateRight(this):e.grandparent.rotateLeft(this))}}else e.blacken()}*flush(){}}}},function(e,t,r){"use strict";function n(e){class t extends e.utils.CustomType{constructor(t,r,n){super(),this.os=t,this._model=r,this._content=n,this._parent=null,this._deepEventHandler=new e.utils.EventListenerHandler,this.eventHandler=new e.utils.EventHandler(t=>{if("Insert"===t.struct){if(this._content.some(function(r){return e.utils.compareIds(r.id,t.id)}))return;let o;if(null===t.left)o=0;else if((o=1+this._content.findIndex(function(r){return e.utils.compareIds(r.id,t.left)}))<=0)throw new Error("Unexpected operation!");var r,n;if(t.hasOwnProperty("opContent")){this._content.splice(o,0,{id:t.id,type:t.opContent}),n=1;let e=this.os.getType(t.opContent);e._parent=this._model,r=[e]}else{var i=t.content.map(function(e,r){return{id:[t.id[0],t.id[1]+r],val:e}});i.length<3e4?this._content.splice.apply(this._content,[o,0].concat(i)):this._content=this._content.slice(0,o).concat(i).concat(this._content.slice(o)),r=t.content,n=t.content.length}e.utils.bubbleEvent(this,{type:"insert",object:this,index:o,values:r,length:n})}else{if("Delete"!==t.struct)throw new Error("Unexpected struct!");for(var o=0;o0;o++){var s=this._content[o];if(e.utils.inDeletionRange(t,s.id)){var a;for(a=1;anull!=e.val?e.val:this.os.getType(e.type));e.utils.bubbleEvent(this,{type:"delete",object:this,index:o,values:n,_content:r,length:a})}}}})}_getPathToChild(t){return this._content.findIndex(r=>null!=r.type&&e.utils.compareIds(r.type,t))}_destroy(){this.eventHandler.destroy(),this.eventHandler=null,this._content=null,this._model=null,this._parent=null,this.os=null}get length(){return this._content.length}get(e){if(null==e||"number"!=typeof e)throw new Error("pos must be a number!");if(!(e>=this._content.length))return null==this._content[e].type?this._content[e].val:this.os.getType(this._content[e].type)}toArray(){return this._content.map((e,t)=>null!=e.type?this.os.getType(e.type):e.val)}push(e){return this.insert(this._content.length,e)}insert(t,r){if("number"!=typeof t)throw new Error("pos must be a number!");if(!Array.isArray(r))throw new Error("contents must be an Array of objects!");if(0!==r.length){if(t>this._content.length||t<0)throw new Error("This position exceeds the range of the array!");for(var n=0===t?null:this._content[t-1].id,i=[],o=n,s=0;s0){s--;break}break}c.push(f)}if(c.length>0)u.content=c,u.id=this.os.getNextOpId(c.length);else{var l=this.os.getNextOpId(1);this.os.createType(a,l),u.opContent=l,u.id=this.os.getNextOpId(1)}i.push(u),o=u.id}var h=this.eventHandler;this.os.requestTransaction(function*(){var e;e=null!=n?(yield*this.getInsertionCleanEnd(n)).right:(yield*this.getOperation(i[0].parent)).start;for(var t=0;tthis._content.length||t<0||r<0)throw new Error("The deletion range exceeds the range of the array!");if(0!==r){for(var n=this.eventHandler,i=[],o=0;othis._content.length||e<0||t<0)throw new Error("The deletion range exceeds the range of the array!");if(0!==t)if(this._content.length>e+t&&""===this._content[e+t].val&&2===this._content[e+t-1].val.length){let r=this._content[e+t-1].val[0];super.delete(e,t+1),super.insert(e,[r])}else if(e>0&&""===this._content[e].val&&2===this._content[e-1].val.length){let r=this._content[e-1].val[1];super.delete(e-1,t+1),super.insert(e-1,[r])}else super.delete(e,t)}unbindAll(){this.unbindTextareaAll(),this.unbindAceAll(),this.unbindCodeMirrorAll(),this.unbindMonacoAll()}unbindMonaco(e){var t=this.monacoInstances.findIndex(function(t){return t.editor===e});if(t>=0){var r=this.monacoInstances[t];this.unobserve(r.yCallback),r.disposeBinding(),this.monacoInstances.splice(t,1)}}unbindMonacoAll(){for(let e=this.monacoInstances.length-1;e>=0;e--)this.unbindMonaco(this.monacoInstances[e].editor)}bindMonaco(e,t){var r=this;t=t||{};var n=!0;function o(e){if(n){n=!1;try{e()}catch(e){throw n=!0,new Error(e)}n=!0}}function s(e){o(function(){for(var t=0,n=1;n0&&r.delete(i,e.rangeLength),r.insert(i,e.text)})}e.setValue(this.toString());var a=e.onDidChangeModelContent(s).dispose;function u(t){o(function(){let r=e.model.getPositionAt(t.index);var n,o;"insert"===t.type?(n=r,o=t.values.join("")):"delete"===t.type&&(n=e.model.modifyPosition(r,t.length),o="");var s={startLineNumber:r.lineNumber,startColumn:r.column,endLineNumber:n.lineNumber,endColumn:n.column},a={major:i.major,minor:i.minor++};e.executeEdits("Yjs",[{id:a,range:s,text:o,forceMoveMarkers:!0}])})}this.observe(u),this.monacoInstances.push({editor:e,yCallback:u,monacoCallback:s,disposeBinding:a})}unbindCodeMirror(e){var t=this.codeMirrorInstances.findIndex(function(t){return t.editor===e});if(t>=0){var r=this.codeMirrorInstances[t];this.unobserve(r.yCallback),r.editor.off("changes",r.codeMirrorCallback),this.codeMirrorInstances.splice(t,1)}}unbindCodeMirrorAll(){for(let e=this.codeMirrorInstances.length-1;e>=0;e--)this.unbindCodeMirror(this.codeMirrorInstances[e].editor)}bindCodeMirror(e,t){var r=this;t=t||{};var n=!0;function i(e){if(n){n=!1;try{e()}catch(e){throw n=!0,new Error(e)}n=!0}}function o(t,n){i(function(){for(var t=0;t0){for(var s=0,a=0;a=0){var r=this.aceInstances[t];this.unobserve(r.yCallback),r.editor.off("change",r.aceCallback),this.aceInstances.splice(t,1)}}unbindAceAll(){for(let e=this.aceInstances.length-1;e>=0;e--)this.unbindAce(this.aceInstances[e].editor)}bindAce(e,t){var r=this;t=t||{};var n,i=!0;function o(e){if(i){i=!1;try{e()}catch(e){throw i=!0,new Error(e)}i=!0}}function s(t){o(function(){var n,i,o=e.getSession().getDocument();"insert"===t.action?(n=o.positionToIndex(t.start,0),r.insert(n,t.lines.join("\n"))):"remove"===t.action&&(n=o.positionToIndex(t.start,0),i=t.lines.join("\n").length,r.delete(n,i))})}e.setValue(this.toString()),e.on("change",s),e.selection.clearSelection(),n="undefined"!=typeof ace&&null==t.aceClass?ace:t.aceClass;var a=(t.aceRequire||n.require)("ace/range").Range;function u(t){var r=e.getSession().getDocument();o(function(){if("insert"===t.type){let e=r.indexToPosition(t.index,0);r.insert(e,t.values.join(""))}else if("delete"===t.type){let n=r.indexToPosition(t.index,0),i=r.indexToPosition(t.index+t.length,0);var e=new a(n.row,n.column,i.row,i.column);r.remove(e)}})}this.observe(u),this.aceInstances.push({editor:e,yCallback:u,aceCallback:s})}bind(){var e=arguments[0];e instanceof Element?this.bindTextarea.apply(this,arguments):null!=e&&null!=e.session&&null!=e.getSession&&null!=e.setValue?this.bindAce.apply(this,arguments):null!=e&&null!=e.posFromIndex&&null!=e.replaceRange?this.bindCodeMirror.apply(this,arguments):null!=e&&null!=e.onDidChangeModelContent?this.bindMonaco.apply(this,arguments):console.error("Cannot bind, unsupported editor!")}unbindTextarea(e){var t=this.textfields.findIndex(function(t){return t.editor===e});if(t>=0){var r=this.textfields[t];this.unobserve(r.yCallback),r.editor.removeEventListener("input",r.eventListener),this.textfields.splice(t,1)}}unbindTextareaAll(){for(let e=this.textfields.length-1;e>=0;e--)this.unbindTextarea(this.textfields[e].editor)}bindTextarea(e,t){null==(t=t||window).getSelection&&(t=window);for(var r=0;r{var t;if("insert"===e.type){t=e.index;var r=s(function(e){return e<=t?e:e+=1});a(r)}else"delete"===e.type&&(t=e.index,r=s(function(e){return en.length&&(r.right=n.length),r.left=Math.min(r.left,r.right);var i=document.createRange();i.setStart(n,r.left),i.setEnd(n,r.right);var o=t.getSelection();o.removeAllRanges(),o.addRange(i)}},u=function(t){e.innerText=t},c=function(){return e.innerText}),u(this.toString()),this.observe(l);var h=function(){o(function(){for(var e=s(function(e){return e}),t=f.toString(),r=c(),i=n(t,r,e.left),o=0,a=0;a0&&n.splice(o+2,0,[a[0],u]),g(n,o,3)}return e}(u,r)),y(u)}function s(e,t){var s;if(!e)return[[n,t]];if(!t)return[[r,e]];var u=e.length>t.length?e:t,c=e.length>t.length?t:e,f=u.indexOf(c);if(-1!=f)return s=[[n,u.substring(0,f)],[i,c],[n,u.substring(f+c.length)]],e.length>t.length&&(s[0][0]=s[2][0]=r),s;if(1==c.length)return[[r,e],[n,t]];var h=l(e,t);if(h){var p=h[0],d=h[1],y=h[2],g=h[3],m=h[4],b=o(p,y),v=o(d,g);return b.concat([[i,m]],v)}return a(e,t)}function a(e,t){for(var i=e.length,o=t.length,s=Math.ceil((i+o)/2),a=s,c=2*s,f=new Array(c),l=new Array(c),h=0;hi)g+=2;else if(S>o)y+=2;else if(d){if((A=a+p-_)>=0&&A=(E=i-l[A]))return u(e,t,I,S)}}for(var k=-v+m;k<=v-b;k+=2){for(var E,A=a+k,x=(E=k==-v||k!=v&&l[A-1]i)b+=2;else if(x>o)m+=2;else if(!d){if((w=a+p-k)>=0&&w=(E=i-E))return u(e,t,I,S)}}}}return[[r,e],[n,t]]}function u(e,t,r,n){var i=e.substring(0,r),s=t.substring(0,n),a=e.substring(r),u=t.substring(n),c=o(i,s),f=o(a,u);return c.concat(f)}function c(e,t){if(!e||!t||e.charAt(0)!=t.charAt(0))return 0;for(var r=0,n=Math.min(e.length,t.length),i=n,o=0;rt.length?e:t,n=e.length>t.length?t:e;if(r.length<4||2*n.length=e.length?[n,i,o,s,l]:null}var o,s,a,u,l,h=i(r,n,Math.ceil(r.length/4)),p=i(r,n,Math.ceil(r.length/2));return h||p?(o=p?h&&h[4].length>p[4].length?h:p:h,e.length>t.length?(s=o[0],a=o[1],u=o[2],l=o[3]):(u=o[0],l=o[1],s=o[2],a=o[3]),[s,a,u,l,o[4]]):null}function h(e){e.push([i,""]);for(var t,o=0,s=0,a=0,u="",l="";o1?(0!==s&&0!==a&&(0!==(t=c(l,u))&&(o-s-a>0&&e[o-s-a-1][0]==i?e[o-s-a-1][1]+=l.substring(0,t):(e.splice(0,0,[i,l.substring(0,t)]),o++),l=l.substring(t),u=u.substring(t)),0!==(t=f(l,u))&&(e[o][1]=l.substring(l.length-t)+e[o][1],l=l.substring(0,l.length-t),u=u.substring(0,u.length-t))),0===s?e.splice(o-a,s+a,[n,l]):0===a?e.splice(o-s,s+a,[r,u]):e.splice(o-s-a,s+a,[r,u],[n,l]),o=o-s-a+(s?1:0)+(a?1:0)+1):0!==o&&e[o-1][0]==i?(e[o-1][1]+=e[o][1],e.splice(o,1)):o++,a=0,s=0,u="",l=""}""===e[e.length-1][1]&&e.pop();var p=!1;for(o=1;o=56320&&e.charCodeAt(0)<=57343},s=function(e){return e.charCodeAt(e.length-1)>=55296&&e.charCodeAt(e.length-1)<=56319},a=2;a0&&u.push(e[a]);return u}function g(e,t,r){for(var n=t+r-1;n>=0&&n>=t-1;n--)if(n+1{var r,n="Delete"===t.struct?t.key:t.parentSub;if(r=null!=this.opContents[n]?this.os.getType(this.opContents[n]):this.contents[n],"Insert"===t.struct){var i;null!==t.left||e.utils.compareIds(t.id,this.map[n])||(null!=t.opContent?((i=this.os.getType(t.opContent))._parent=this._model,delete this.contents[n],t.deleted?delete this.opContents[n]:this.opContents[n]=t.opContent):(i=t.content[0],delete this.opContents[n],t.deleted?delete this.contents[n]:this.contents[n]=t.content[0]),this.map[n]=t.id,void 0===r?e.utils.bubbleEvent(this,{name:n,object:this,type:"add",value:i}):e.utils.bubbleEvent(this,{name:n,object:this,oldValue:r,type:"update",value:i}))}else{if("Delete"!==t.struct)throw new Error("Unexpected Operation!");e.utils.compareIds(this.map[n],t.target)&&(delete this.opContents[n],delete this.contents[n],e.utils.bubbleEvent(this,{name:n,object:this,oldValue:r,type:"delete"}))}})}_getPathToChild(t){return Object.keys(this.opContents).find(r=>e.utils.compareIds(this.opContents[r],t))}_destroy(){this.eventHandler.destroy(),this.eventHandler=null,this.contents=null,this.opContents=null,this._model=null,this._parent=null,this.os=null,this.map=null}get(e){if(null==e||"string"!=typeof e)throw new Error("You must specify a key (as string)!");return null==this.opContents[e]?this.contents[e]:this.os.getType(this.opContents[e])}keys(){return Object.keys(this.contents).concat(Object.keys(this.opContents))}keysPrimitives(){return Object.keys(this.contents)}keysTypes(){return Object.keys(this.opContents)}getPrimitive(t){if(null==t)return e.utils.copyObject(this.contents);if("string"!=typeof t)throw new Error("Key is expected to be a string!");return this.contents[t]}getType(e){if(null==e||"string"!=typeof e)throw new Error("You must specify a key (as string)!");return null!=this.opContents[e]?this.os.getType(this.opContents[e]):null}delete(t){var r=this.map[t];if(null!=r){var n={target:r,struct:"Delete"},i=this.eventHandler,o=e.utils.copyObject(n);o.key=t,this.os.requestTransaction(function*(){yield*i.awaitOps(this,this.applyCreatedOperations,[[n]])}),i.awaitAndPrematurelyCall([o])}}set(t,r){var n=this.map[t]||null,i={id:this.os.getNextOpId(1),left:null,right:n,origin:null,parent:this._model,parentSub:t,struct:"Insert"},o=this.eventHandler,s=e.utils.isTypeDefinition(r);if(!1!==s){var a=this.os.createType(s);return i.opContent=a._model,this.os.requestTransaction(function*(){yield*o.awaitOps(this,this.applyCreatedOperations,[[i]])}),o.awaitAndPrematurelyCall([i]),a}return i.content=[r],this.os.requestTransaction(function*(){yield*o.awaitOps(this,this.applyCreatedOperations,[[i]])}),o.awaitAndPrematurelyCall([i]),r}observe(e){this.eventHandler.addEventListener(e)}observeDeep(e){this._deepEventHandler.addEventListener(e)}unobserve(e){this.eventHandler.removeEventListener(e)}unobserveDeep(e){this._deepEventHandler.removeEventListener(e)}observePath(r,n){var i,o=this;if(r.length<1)return n(this),function(){};if(1===r.length)return i=r[0],n(o.get(i)),this.observe(function(e){e.name===i&&n(o.get(i))}),function(){o.unobserve(n)};var s,a=function(){var i=o.get(r[0]);i instanceof t||(i=o.set(r[0],e.Map)),s=i.observePath(r.slice(1),n)},u=function(e){e.name===r[0]&&(null!=s&&s(),"add"!==e.type&&"update"!==e.type||a())};return o.observe(u),a(),function(){null!=s&&s(),o.unobserve(u)}}*_changed(e,t){if("Delete"===t.struct){if(null==t.key){var r=yield*e.getOperation(t.target);t.key=r.parentSub}}else null!=t.opContent&&(yield*e.store.initType.call(e,t.opContent));this.eventHandler.receivedOp(t)}}e.extend("Map",new e.utils.CustomTypeDefinition({name:"Map",class:t,struct:"Map",initType:function*(e,r){var n={},i={},o=r.map;for(var s in o){var a=yield*this.getOperation(o[s]);a.deleted||(null!=a.opContent?(i[s]=a.opContent,(yield*this.store.initType.call(this,a.opContent))._parent=r.id):n[s]=a.content[0])}return new t(e,r,n,i)},createType:function(e,r){return new t(e,r,{},{})}}))}e.exports=n,"undefined"!=typeof Y&&n(Y)},function(e,t,r){"use strict";const n=r(1)("y-ipfs-connector"),i=r(10),o=r(1473),s=r(162),a=r(2).Buffer,u=r(1480),c=r(1481);function f(e){e.extend("ipfs",class extends e.AbstractConnector{constructor(e,t){if(void 0===t)throw new Error("Options must not be undefined!");if(null==t.room)throw new Error("You must define a room name!");if(!t.ipfs)throw new Error("You must define a started IPFS object inside options");t.role||(t.role="master"),super(e,t),this._yConnectorOptions=t,this.ipfs=t.ipfs;const r=this.ipfsPubSubTopic="y-ipfs:rooms:"+t.room;this.roomEmitter=t.roomEmitter||new i,this.roomEmitter.peers=(()=>this._room.getPeers()),this.roomEmitter.id=(()=>r),this._receiveQueue=s(this._processQueue.bind(this),1),this._room=o(this.ipfs,r),this._room.setMaxListeners(1/0),this._room.on("error",e=>{console.error(e)}),this._room.on("message",e=>{if(this.ipfs._peerInfo&&e.from===this.ipfs._peerInfo.id.toB58String())return;const r=()=>{let r;r=this._yConnectorOptions.decode?this._yConnectorOptions.decode(e.data):c(e.data);const n=()=>{const t=c(r.payload);this.roomEmitter.emit("received message",e.from,t),null!==t.type&&this._queueReceiveMessage(e.from,t)};if(t.verifySignature){const i=r.signature&&a.from(r.signature,"base64");t.verifySignature.call(null,e.from,a.from(r.payload),i,(t,r)=>{t?console.error("Error verifying signature from peer "+e.from+". Discarding message.",t):r?n():console.error("Invalid signature from peer "+e.from+". Discarding message.")})}else n()};if(this._room.hasPeer(e.from))r();else{const t=n=>{n===e.from&&(this._room.removeListener("peer joined",t),r())};this._room.on("peer joined",t)}}),this._room.on("peer joined",e=>{this.roomEmitter.emit("peer joined",e),this.userJoined(e,"master")}),this._room.on("peer left",e=>{this.roomEmitter.emit("peer left",e),this.userLeft(e)}),this.ipfs.isOnline()?this._start():this.ipfs.once("ready",this._start.bind(this))}_queueReceiveMessage(e,t){this._receiveQueue.push({from:e,message:t})}_processQueue(e,t){const r=e.from,n=e.message;r===this._ipfsUserId?t():this._room.hasPeer(r)?(this.receiveMessage(r,n),t()):(this._receiveQueue.unshift(e),setTimeout(t,500))}_start(){const e=this.ipfs._peerInfo.id.toB58String();this._ipfsUserId=e,this.setUserId(e)}disconnect(){n("disconnect"),this._room.leave(),super.disconnect()}send(e,t){this._encodeMessage(t,(r,n)=>{if(r)throw r;this._yConnectorOptions.encode&&(n=this._yConnectorOptions.encode(n)),this._room.sendTo(e,n),this.roomEmitter.emit("sent message",e,t)})}broadcast(e){this._encodeMessage(e,(t,r)=>{if(t)throw t;this._yConnectorOptions.encode&&(r=this._yConnectorOptions.encode(r)),this._room.broadcast(r),this.roomEmitter.emit("sent message","broadcast",e)})}isDisconnected(){return!1}_encodeMessage(e,t){const r=function(e){return JSON.stringify(e)}(e);this._yConnectorOptions.sign?this._yConnectorOptions.sign(a.from(r),(e,n)=>{if(e)return t(e);const i=n.toString("base64");t(null,u({signature:i,payload:r}))}):t(null,u({payload:r}))}})}e.exports=f,"undefined"!=typeof Y&&f(Y)},function(e,t,r){"use strict";(function(t){const n=r(1474),i=r(10),o=r(1476),s=r(603),a=r(604),u=r(1477),c=r(605),f=r(1479),l={pollInterval:1e3};e.exports=((e,t,r)=>new h(e,t,r));class h extends i{constructor(e,t,r){if(super(),this._ipfs=e,this._topic=t,this._options=Object.assign({},s(l),s(r)),this._peers=[],this._connections={},this._handleDirectMessage=this._handleDirectMessage.bind(this),!this._ipfs.pubsub)throw new Error("This IPFS node does not have pubsub.");this._ipfs.isOnline()?this._start():this._ipfs.on("ready",this._start.bind(this)),this._ipfs.on("stop",this.leave.bind(this))}getPeers(){return this._peers.slice(0)}hasPeer(e){return this._peers.indexOf(e)>=0}leave(){return new Promise((e,t)=>{o.clearInterval(this._interval),Object.keys(this._connections).forEach(e=>{this._connections[e].stop()}),f.emitter.removeListener(this._topic,this._handleDirectMessage),this.once("stopped",()=>e()),this.emit("stopping")})}broadcast(e){let t=c(e);this._ipfs.pubsub.publish(this._topic,t,e=>{e&&this.emit("error",e)})}sendTo(e,r){let n=this._connections[e];n||((n=new u(e,this._ipfs,this)).on("error",e=>this.emit("error",e)),this._connections[e]=n,n.once("disconnect",()=>{delete this._connections[e],this._peers=this._peers.filter(t=>t!==e),this.emit("peer left",e)}));const i=t.from([0]),o={to:e,from:this._ipfs._peerInfo.id.toB58String(),data:t.from(r).toString("hex"),seqno:i.toString("hex"),topicIDs:[this._topic],topicCIDs:[this._topic]};n.push(t.from(JSON.stringify(o)))}_start(){this._interval=o.setInterval(this._pollPeers.bind(this),this._options.pollInterval);const e=this._onMessage.bind(this);this._ipfs.pubsub.subscribe(this._topic,e,{},e=>{e?this.emit("error",e):this.emit("subscribed",this._topic)}),this.once("stopping",()=>{this._ipfs.pubsub.unsubscribe(this._topic,e,e=>{e?this.emit("error",e):this.emit("stopped")})}),this._ipfs._libp2pNode.handle(a,f.handler),f.emitter.on(this._topic,this._handleDirectMessage)}_pollPeers(){this._ipfs.pubsub.peers(this._topic,(e,t)=>{if(e)return void this.emit("error",e);const r=t.sort();this._emitChanges(r)&&(this._peers=r)})}_emitChanges(e){const t=n(this._peers,e);return t.added.forEach(e=>this.emit("peer joined",e)),t.removed.forEach(e=>this.emit("peer left",e)),t.added.length>0||t.removed.length>0}_onMessage(e){this.emit("message",e)}_handleDirectMessage(e){if(e.to===this._ipfs._peerInfo.id.toB58String()){const t=Object.assign({},e);delete t.to,this.emit("message",t)}}}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";const n=r(603),i=r(1)("hyperdiff"),o=r(1475),s=e=>-1!==e;function a(e,t){return e.indexOf(t)}function u(e,t,r){return e.findIndex(function(e){return function(e,t,r){return r.every(r=>t[r]===e[r])}(e,t,r)})}function c(e,t){return{first:e,second:n(t)}}function f(e,t){return t?u:a}e.exports=function(e,t,r){const n=r?[].concat(r):[],{first:a,second:u}=c(e,t),l=f(0,r);i("preconditions first=%j second=%j findIndex=%s",a,u,l.name);const h=a.reduce(function(e,t,r){const a=l(u,t,n),c=s(a)?"common":"removed";return e[c].push(t),o(u,a),i("index=%s value=%s collection=%s",r,t,c),e},{common:[],removed:[]});return h.added=u,i("added=%j removed=%j common%j",h.added,h.removed,h.common),h}},function(e,t,r){(function(t){var r="Expected a function",n="__lodash_hash_undefined__",i=1/0,o=9007199254740991,s="[object Arguments]",a="[object Function]",u="[object GeneratorFunction]",c="[object Symbol]",f=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,l=/^\w*$/,h=/^\./,p=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,d=/\\(\\)?/g,y=/^\[object .+?Constructor\]$/,g=/^(?:0|[1-9]\d*)$/,m="object"==typeof t&&t&&t.Object===Object&&t,b="object"==typeof self&&self&&self.Object===Object&&self,v=m||b||Function("return this")();function _(e,t){for(var r=-1,n=t.length,i=e.length;++rt||o&&s&&u&&!a&&!c||n&&s&&u||!r&&u||!i)return 1;if(!n&&!o&&!c&&e-1&&e%1==0&&e<=o}(e.length)&&!ae(e)}(e)}(e)&&T.call(e,"callee")&&(!O.call(e,"callee")||B.call(e)==s)}(e)||!!(N&&e&&e[N])}function X(e,t){return!!(t=null==t?o:t)&&("number"==typeof e||g.test(e))&&e>-1&&e%1==0&&ei?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var o=Array(i);++n-1},F.prototype.set=function(e,t){var r=this.__data__,n=H(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},q.prototype.clear=function(){this.__data__={hash:new U,map:new(j||F),string:new U}},q.prototype.delete=function(e){return $(this,e).delete(e)},q.prototype.get=function(e){return $(this,e).get(e)},q.prototype.has=function(e){return $(this,e).has(e)},q.prototype.set=function(e,t){return $(this,e).set(e,t),this};var ee=ie(function(e){e=function(e){return null==e?"":function(e){if("string"==typeof e)return e;if(fe(e))return D?D.call(e):"";var t=e+"";return"0"==t&&1/e==-i?"-0":t}(e)}(e);var t=[];return h.test(e)&&t.push(""),e.replace(p,function(e,r,n,i){t.push(n?i.replace(d,"$1"):r||e)}),t});function te(e){if("string"==typeof e||fe(e))return e;var t=e+"";return"0"==t&&1/e==-i?"-0":t}function re(e){var t=e?e.length:0;return t?e[t-1]:void 0}var ne=function(e,t){return t=L(void 0===t?e.length-1:t,0),function(){for(var r=arguments,n=-1,i=L(r.length-t,0),o=Array(i);++n0&&n(u)?r>1?e(u,r-1,n,i,o):_(o,u):i||(o[o.length]=u)}return o}(t,1);var r=e?e.length:0,n=function(e,t){for(var r=-1,n=null==e,i=t.length,o=Array(i);++r=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},r(569),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(7))},function(e,t,r){"use strict";const n=r(10),i=r(8),o=r(46),s=r(604),a=r(605),u=r(1478);e.exports=class extends n{constructor(e,t,r){super(),this._id=e,this._ipfs=t,this._room=r,this._connection=null,this._connecting=!1}push(e){this._connection?this._connection.push(a(e)):(this.once("connect",()=>this.push(e)),this._connecting||this._getConnection())}stop(){this._connection&&this._connection.end()}_getConnection(){this._connecting=!0,this._getPeerAddresses(this._id,(e,t)=>{e?this.emit("error",e):t.length?this._ipfs._libp2pNode.dialProtocol(t[0],s,(e,t)=>{if(e)return void this.emit("disconnect");this._connecting=!1;const r=o();this._connection=r,i(r,t,i.onEnd(()=>{delete this._connection,this.emit("disconnect")})),this.emit("connect",r)}):this.emit("disconnect")})}_getPeerAddresses(e,t){this._ipfs.swarm.peers((r,n)=>{r?t(r):t(null,n.filter(t=>u(t.peer)===e).map(e=>e.peer))})}}},function(e,t,r){"use strict";e.exports=(e=>(e.id&&"function"==typeof e.id.toB58String&&(e=e.id),e.toB58String()))},function(e,t,r){"use strict";(function(t){const n=r(8),i=new(r(10));e.exports={handler:function(e,r){r.getPeerInfo((e,o)=>{if(e)return void console.log(e);const s=o.id.toB58String();n(r,n.map(e=>{let r;try{r=JSON.parse(e.toString())}catch(e){return void i.emit("warning",e.message)}if(s!==r.from)return void i.emit("warning","no peerid match "+r.from);const n=r.topicIDs;if(Array.isArray(n))return r.data=t.from(r.data,"hex"),r.seqno=t.from(r.seqno,"hex"),n.forEach(e=>{i.emit(e,r)}),r;i.emit("warning","no topic IDs")}),n.onEnd(()=>{}))})},emitter:i}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){e.exports=(e=>t.from(JSON.stringify(e)))}).call(this,r(0).Buffer)},function(e,t,r){"use strict";e.exports=(e=>{const t=e.toString();let r;try{r=JSON.parse(t)}catch(e){throw console.error("Failed parsing",t),e}return r})},function(e,t,r){"use strict";function n(e){return e?(e^16*Math.random()>>e/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,n)}function i(e){e.requestModules(["memory"]).then(function(){e.utils.createStoreClone=function(e){return class extends e{constructor(){super(...arguments),this.buffer=[],this._copyTo=null}copyTo(e){return this._copyTo=e,this}*put(e,t){t||this.buffer.push(this._copyTo.put(e)),yield*super.put(e)}*delete(e){this.buffer.push(this._copyTo.delete(e)),yield*super.delete(e)}*flush(){yield*super.flush();for(var e=0;e{this.webtorrent=new n(this.options),this.webtorrent.once("ready",()=>{console.log("WEBTORRENT READY"),e()}),this.webtorrent.once("error",e=>t(e)),this.webtorrent.on("warning",e=>{console.warn("WebTorrent Torrent WARNING: "+e.message)})})}static setup0(e,t){let r=a.mergeoptions(c,e.webtorrent);t&&console.log("WebTorrent options %o",r);let n=new f(r,t);return u.addtransport(n),n}async p_setup1(e,t){try{this.status=a.STATUS_STARTING,t&&t(this),await this.p_webtorrentstart(e),await this.p_status(e)}catch(e){console.error(this.name,"failed to connect",e),this.status=a.STATUS_FAILED}return t&&t(this),this}async p_status(e){return this.webtorrent&&this.webtorrent.ready?this.status=a.STATUS_CONNECTED:this.webtorrent?this.status=a.STATUS_STARTING:this.status=a.STATUS_FAILED,super.p_status(e)}webtorrentparseurl(e){if(!e)throw new s.CodingError("TransportWEBTORRENT.p_rawfetch: requires url");const t="string"==typeof e?e:e.href,r=t.indexOf("/");if(-1===r)throw new s.CodingError("TransportWEBTORRENT.p_rawfetch: invalid url - missing path component. Should look like magnet:xyzabc/path/to/file");return{torrentId:t.slice(0,r),path:t.slice(r+1)}}async p_webtorrentadd(e){return new Promise((t,r)=>{let n=this.webtorrent.get(e);n||((n=this.webtorrent.add(e)).once("error",e=>{r(new s.TransportError("Torrent encountered a fatal error "+e.message))}),n.on("warning",e=>{console.warn("WebTorrent Torrent WARNING: "+e.message+" ("+n.name+")")})),n.ready?t(n):n.once("ready",()=>{t(n)})})}webtorrentfindfile(e,t){const r=e.name+"/"+t,n=e.files.find(e=>e.path===r);if(!n)throw new s.TransportError("Requested file ("+t+") not found within torrent ");return n}p_rawfetch(e,{verbose:t=!1}={}){return new Promise((r,n)=>{t&&console.log("WebTorrent p_rawfetch",e);const{torrentId:i,path:o}=this.webtorrentparseurl(e);this.p_webtorrentadd(i).then(e=>{e.deselect(0,e.pieces.length-1,!1),this.webtorrentfindfile(e,o).getBuffer((t,i)=>{if(t)return n(new s.TransportError("Torrent encountered a fatal error "+t.message+" ("+e.name+")"));r(i)})}).catch(e=>n(e))})}async _p_fileTorrentFromUrl(e){try{const{torrentId:t,path:r}=this.webtorrentparseurl(e),n=await this.p_webtorrentadd(t);n.deselect(0,n.pieces.length-1,!1);const i=this.webtorrentfindfile(n,r);return"undefined"!=typeof window&&(window.WEBTORRENT_TORRENT=n,window.WEBTORRENT_FILE=i,n.once("close",()=>{window.WEBTORRENT_TORRENT=null,window.WEBTORRENT_FILE=null})),i}catch(t){throw console.log(`p_fileFrom failed on ${e} ${t.message}`),t}}async p_f_createReadStream(e,{verbose:t=!1,wanturl:r=!1}={}){t&&console.log(this.name,"p_f_createreadstream",o.parse(e).href);try{let n=await this._p_fileTorrentFromUrl(e),i=this;return r?e:function(e){return i.createReadStream(n,e,t)}}catch(t){throw console.log(`p_f_createReadStream failed on ${e} ${t.message}`),t}}createReadStream(e,t,r){let n;r&&console.log(this.name,"createreadstream",e.name,t);try{return n=new i.PassThrough,e.createReadStream(t).pipe(n),n}catch(e){console.log("TransportWEBTORRENT caught error",e),"function"==typeof n.destroy?n.destroy(e):n.emit("error",e)}}async p_createReadableStream(e,t,r){let n=await this._p_fileTorrentFromUrl(e);return new ReadableStream({start(r){console.log("start",e,t);const i=n.createReadStream(t);i.on("data",e=>{r.enqueue(e)}),i.on("end",()=>{r.close()})},cancel(r){throw new s.TransportError(`cancelled ${e}, ${t} ${r}`)}})}static async p_test(e,r){try{let i=await this.p_setup(e,r);r&&console.log(i.name,"setup");let o=await i.p_status(r);console.assert(o===a.STATUS_CONNECTED);let s="magnet:?xt=urn:btih:dd8255ecdc7ca55fb0bbf81323d87062db1f6d1c&dn=Big+Buck+Bunny&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fbig-buck-bunny.torrent/Big Buck Bunny.en.srt",u=await i.p_rawfetch(s,{verbose:r});n(u=u.toString());const c=await i.createReadStream(s,r),f=[];function n(e){console.assert(-1!==e.indexOf("00:00:02,000 --\x3e 00:00:05,000"),"Should fetch 'Big Buck Bunny.en.srt' from the torrent"),console.assert(e.length,129,"'Big Buck Bunny.en.srt' was "+e.length)}c.on("data",e=>{f.push(e)}),c.on("end",()=>{n(t.concat(f).toString())})}catch(e){throw console.log("Exception thrown in TransportWEBTORRENT.p_test:",e.message),e}}}u._transportclasses.WEBTORRENT=f,e.exports=f}).call(this,r(0).Buffer)},function(e,t,r){(function(t,n){e.exports=A;var i=r(2).Buffer,o=r(325),s=r(1485),a=r(1)("webtorrent"),u=r(1496),c=r(10).EventEmitter,f=r(26),l=r(4),h=r(1497),p=r(147),d=r(608),y=r(60),g=r(191),m=r(108),b=r(327),v=r(1506),_=r(1507),w=r(1508),S=r(329).version,k=S.match(/([0-9]+)/g).slice(0,2).map(function(e){return v(2,e)}).join(""),E="-WW"+k+"-";function A(e){var r=this;if(!(r instanceof A))return new A(e);function o(){r.destroyed||(r.ready=!0,r.emit("ready"))}c.call(r),e||(e={}),"string"==typeof e.peerId?r.peerId=e.peerId:i.isBuffer(e.peerId)?r.peerId=e.peerId.toString("hex"):r.peerId=i.from(E+m(9).toString("base64")).toString("hex"),r.peerIdBuffer=i.from(r.peerId,"hex"),"string"==typeof e.nodeId?r.nodeId=e.nodeId:i.isBuffer(e.nodeId)?r.nodeId=e.nodeId.toString("hex"):r.nodeId=m(20).toString("hex"),r.nodeIdBuffer=i.from(r.nodeId,"hex"),r._debugId=r.peerId.toString("hex").substring(0,7),r.destroyed=!1,r.listening=!1,r.torrentPort=e.torrentPort||0,r.dhtPort=e.dhtPort||0,r.tracker=void 0!==e.tracker?e.tracker:{},r.torrents=[],r.maxConns=Number(e.maxConns)||55,r._debug("new webtorrent (peerId %s, nodeId %s, port %s)",r.peerId,r.nodeId,r.torrentPort),r.tracker&&("object"!=typeof r.tracker&&(r.tracker={}),e.rtcConfig&&(console.warn("WebTorrent: opts.rtcConfig is deprecated. Use opts.tracker.rtcConfig instead"),r.tracker.rtcConfig=e.rtcConfig),e.wrtc&&(console.warn("WebTorrent: opts.wrtc is deprecated. Use opts.tracker.wrtc instead"),r.tracker.wrtc=e.wrtc),t.WRTC&&!r.tracker.wrtc&&(r.tracker.wrtc=t.WRTC)),"function"==typeof _?r._tcpPool=new _(r):n.nextTick(function(){r._onListening()}),r._downloadSpeed=b(),r._uploadSpeed=b(),!1!==e.dht&&"function"==typeof u?(r.dht=new u(f({nodeId:r.nodeId},e.dht)),r.dht.once("error",function(e){r._destroy(e)}),r.dht.once("listening",function(){var e=r.dht.address();e&&(r.dhtPort=e.port)}),r.dht.setMaxListeners(0),r.dht.listen(r.dhtPort)):r.dht=!1,r.enableWebSeeds=!1!==e.webSeeds,"function"==typeof h&&null!=e.blocklist?h(e.blocklist,{headers:{"user-agent":"WebTorrent/"+S+" (https://webtorrent.io)"}},function(e,t){if(e)return r.error("Failed to load blocklist: "+e.message);r.blocked=t,o()}):n.nextTick(o)}l(A,c),A.WEBRTC_SUPPORT=g.WEBRTC_SUPPORT,A.VERSION=S,Object.defineProperty(A.prototype,"downloadSpeed",{get:function(){return this._downloadSpeed()}}),Object.defineProperty(A.prototype,"uploadSpeed",{get:function(){return this._uploadSpeed()}}),Object.defineProperty(A.prototype,"progress",{get:function(){var e=this.torrents.filter(function(e){return 1!==e.progress});return e.reduce(function(e,t){return e+t.downloaded},0)/(e.reduce(function(e,t){return e+(t.length||0)},0)||1)}}),Object.defineProperty(A.prototype,"ratio",{get:function(){return this.torrents.reduce(function(e,t){return e+t.uploaded},0)/(this.torrents.reduce(function(e,t){return e+t.received},0)||1)}}),A.prototype.get=function(e){var t,r,n=this.torrents.length;if(e instanceof w){for(t=0;t1?o=t.path[0]:t.path[0]!==o&&(o=null)}}),e=e.filter(function(e){if("string"==typeof e)return!0;var t=e.path[e.path.length-1];return S(t)&&d.not(t)}),o&&e.forEach(function(e){var r=(t.isBuffer(e)||I(e))&&!e.path;"string"==typeof e||r||e.path.shift()}),!r.name&&o&&(r.name=o),r.name||e.some(function(e){return"string"==typeof e?(r.name=u.basename(e),!0):e.unknownName?void 0:(r.name=e.path[e.path.length-1],!0)}),r.name||(r.name="Unnamed Torrent "+Date.now());var s=e.reduce(function(e,t){return e+Number("string"==typeof t)},0),a=1===e.length;if(1===e.length&&"string"==typeof e[0]){if("function"!=typeof h.stat)throw new Error("filesystem paths do not work in the browser");p(e[0],function(e,t){if(e)return i(e);a=t,c()})}else n.nextTick(function(){c()});function c(){m(e.map(function(e){return function(r){var n={};if(x(e))n.getStream=function(e){return function(){return new f(e)}}(e),n.length=e.size;else if(t.isBuffer(e))n.getStream=function(e){return function(){var t=new v.PassThrough;return t.end(e),t}}(e),n.length=e.length;else{if(!I(e)){if("string"==typeof e){if("function"!=typeof h.stat)throw new Error("filesystem paths do not work in the browser");return void function(e,t,r){!function e(t,r,n){h.stat(t,function(i,o){if(i)return n(i);o.isDirectory()?h.readdir(t,function(i,o){if(i)return n(i);m(o.filter(S).filter(d.not).map(function(n){return function(i){e(u.join(t,n),r,i)}}),n)}):o.isFile()&&r(t,n)})}(e,w,function(n,i){if(n)return r(n);i=Array.isArray(i)?l(i):[i],e=u.normalize(e),t&&(e=e.slice(0,e.lastIndexOf(u.sep)+1)),e[e.length-1]!==u.sep&&(e+=u.sep),i.forEach(function(t){t.getStream=function(e){return function(){return h.createReadStream(e)}}(t.path),t.path=t.path.replace(e,"").split(u.sep)}),r(null,i)})}(e,s>1||a,r)}throw new Error("invalid input type")}n.getStream=function(e,t){return function(){var r=new v.Transform;return r._transform=function(e,r,n){t.length+=e.length,this.push(e),n()},e.pipe(r),r}}(e,n),n.length=0}n.path=e.path,r(null,n)}}),function(e,t){if(e)return i(e);t=l(t),i(null,t,a)})}}function w(e,t){t=g(t),h.stat(e,function(r,n){if(r)return t(r);var i={length:n.size,path:e};t(null,i)})}function S(e){return"."!==e[0]}function k(e,r,n){n=g(n);var i=[],o=0,a=e.map(function(e){return e.getStream}),u=0,c=0,f=!1,l=new y(a),h=new s(r,{zeroPadding:!1});function p(e){o+=e.length;var t=c;b(e,function(e){i[t]=e,u-=1,_()}),u+=1,c+=1}function d(){f=!0,_()}function m(e){v(),n(e)}function v(){l.removeListener("error",m),h.removeListener("data",p),h.removeListener("end",d),h.removeListener("error",m)}function _(){f&&0===u&&(v(),n(null,t.from(i.join(""),"hex"),o))}l.on("error",m),l.pipe(h).on("data",p).on("end",d).on("error",m)}function E(t,r,n){var s=r.announceList;s||("string"==typeof r.announce?s=[[r.announce]]:Array.isArray(r.announce)&&(s=r.announce.map(function(e){return[e]}))),s||(s=[]),i.WEBTORRENT_ANNOUNCE&&("string"==typeof i.WEBTORRENT_ANNOUNCE?s.push([[i.WEBTORRENT_ANNOUNCE]]):Array.isArray(i.WEBTORRENT_ANNOUNCE)&&(s=s.concat(i.WEBTORRENT_ANNOUNCE.map(function(e){return[e]})))),void 0===r.announce&&void 0===r.announceList&&(s=s.concat(e.exports.announceList)),"string"==typeof r.urlList&&(r.urlList=[r.urlList]);var u={info:{name:r.name},"creation date":Math.ceil((Number(r.creationDate)||Date.now())/1e3),encoding:"UTF-8"};0!==s.length&&(u.announce=s[0][0],u["announce-list"]=s),void 0!==r.comment&&(u.comment=r.comment),void 0!==r.createdBy&&(u["created by"]=r.createdBy),void 0!==r.private&&(u.info.private=Number(r.private)),void 0!==r.sslCert&&(u.info["ssl-cert"]=r.sslCert),void 0!==r.urlList&&(u["url-list"]=r.urlList);var c=r.pieceLength||a(t.reduce(A,0));u.info["piece length"]=c,k(t,c,function(e,i,s){if(e)return n(e);u.info.pieces=i,t.forEach(function(e){delete e.getStream}),r.singleFileTorrent?u.info.length=s:u.info.files=t,n(null,o.encode(u))})}function A(e,t){return e+t.length}function x(e){return"undefined"!=typeof Blob&&e instanceof Blob}function I(e){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}}).call(this,r(0).Buffer,r(6),r(7))},function(e,t,r){var n=r(2).Buffer;function i(e,t,r){var o=[],s=null;return i._encode(o,e),s=n.concat(o),i.bytes=s.length,n.isBuffer(t)?(s.copy(t,r),t):s}i.bytes=-1,i._floatConversionDetected=!1,i.getType=function(e){return n.isBuffer(e)?"buffer":Array.isArray(e)?"array":ArrayBuffer.isView(e)?"arraybufferview":e instanceof Number?"number":e instanceof Boolean?"boolean":e instanceof ArrayBuffer?"arraybuffer":typeof e},i._encode=function(e,t){if(null!=t)switch(i.getType(t)){case"buffer":i.buffer(e,t);break;case"object":i.dict(e,t);break;case"array":i.list(e,t);break;case"string":i.string(e,t);break;case"number":case"boolean":i.number(e,t);break;case"arraybufferview":i.buffer(e,n.from(t.buffer,t.byteOffset,t.byteLength));break;case"arraybuffer":i.buffer(e,n.from(t))}};var o=n.from("e"),s=n.from("d"),a=n.from("l");i.buffer=function(e,t){e.push(new n(t.length+":"),t)},i.string=function(e,t){e.push(n.from(n.byteLength(t)+":"+t))},i.number=function(e,t){var r=2147483648,o=(t/r<<0)*r+(t%r<<0);e.push(n.from("i"+o+"e")),o===t||i._floatConversionDetected||(i._floatConversionDetected=!0,console.warn('WARNING: Possible data corruption detected with value "'+t+'":','Bencoding only defines support for integers, value was converted to "'+o+'"'),console.trace())},i.dict=function(e,t){e.push(s);for(var r,n=0,a=Object.keys(t).sort(),u=a.length;n=48)n=10*n+(s-48);else if(o!==t||43!==s){if(o!==t||45!==s){if(46===s)break;throw new Error("not a number: buffer["+o+"] = "+s)}i=-1}}return n*i}function n(e,r,i,o){return null==e||0===e.length?null:("number"!=typeof r&&null==o&&(o=r,r=void 0),"number"!=typeof i&&null==o&&(o=i,i=void 0),n.position=0,n.encoding=o||null,n.data=t.isBuffer(e)?e.slice(r,i):new t(e),n.bytes=n.data.length,n.next())}n.bytes=0,n.position=0,n.data=null,n.encoding=null,n.next=function(){switch(n.data[n.position]){case 100:return n.dictionary();case 108:return n.list();case 105:return n.integer();default:return n.buffer()}},n.find=function(e){for(var t=n.position,r=n.data.length,i=n.data;t>1)]-e)<0?u=i+1:s>0&&(c=i-1),(s=r(s))this._size&&(n=this._size),r===this._size)return this.destroy(),void this.push(null);t.onload=function(){e._offset=n,e.push(o(t.result))},t.onerror=function(){e.emit("error",t.error)},t.readAsArrayBuffer(this._file.slice(r,n))}else this.once("_ready",this._read.bind(this))},s.prototype.destroy=function(){if(this._file=null,this.reader){this.reader.onload=null,this.reader.onerror=null;try{this.reader.abort()}catch(e){}}this.reader=null}},function(e,t){e.exports=function(e,t){return(t="number"==typeof t?t:1/0)?function e(r,n){return r.reduce(function(r,i){return Array.isArray(i)&&nt.re.test(e)),t.not=(e=>!t.is(e))},function(e,t,r){!function(t,r){e.exports=r()}("undefined"!=typeof self&&self,function(){return 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,{configurable:!1,enumerable:!0,get: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=3)}([function(e,t,r){var n=r(5),i=r(1),o=i.toHex,s=i.ceilHeapSize,a=r(6),u=function(e){for(e+=9;e%64>0;e+=1);return e},c=function(e,t){var r=new Int32Array(e,t+320,5),n=new Int32Array(5),i=new DataView(n.buffer);return i.setInt32(0,r[0],!1),i.setInt32(4,r[1],!1),i.setInt32(8,r[2],!1),i.setInt32(12,r[3],!1),i.setInt32(16,r[4],!1),n},f=function(){function e(t){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),(t=t||65536)%64>0)throw new Error("Chunk size must be a multiple of 128 bit");this._offset=0,this._maxChunkLen=t,this._padMaxChunkLen=u(t),this._heap=new ArrayBuffer(s(this._padMaxChunkLen+320+20)),this._h32=new Int32Array(this._heap),this._h8=new Int8Array(this._heap),this._core=new n({Int32Array:Int32Array},{},this._heap)}return e.prototype._initState=function(e,t){this._offset=0;var r=new Int32Array(e,t+320,5);r[0]=1732584193,r[1]=-271733879,r[2]=-1732584194,r[3]=271733878,r[4]=-1009589776},e.prototype._padChunk=function(e,t){var r=u(e),n=new Int32Array(this._heap,0,r>>2);return function(e,t){var r=new Uint8Array(e.buffer),n=t%4,i=t-n;switch(n){case 0:r[i+3]=0;case 1:r[i+2]=0;case 2:r[i+1]=0;case 3:r[i+0]=0}for(var o=1+(t>>2);o>2]|=128<<24-(t%4<<3),e[14+(2+(t>>2)&-16)]=r/(1<<29)|0,e[15+(2+(t>>2)&-16)]=r<<3}(n,e,t),r},e.prototype._write=function(e,t,r,n){a(e,this._h8,this._h32,t,r,n||0)},e.prototype._coreCall=function(e,t,r,n,i){var o=r;this._write(e,t,r),i&&(o=this._padChunk(r,n)),this._core.hash(o,this._padMaxChunkLen)},e.prototype.rawDigest=function(e){var t=e.byteLength||e.length||e.size||0;this._initState(this._heap,this._padMaxChunkLen);var r=0,n=this._maxChunkLen;for(r=0;t>r+n;r+=n)this._coreCall(e,r,n,t,!1);return this._coreCall(e,r,t-r,t,!0),c(this._heap,this._padMaxChunkLen)},e.prototype.digest=function(e){return o(this.rawDigest(e).buffer)},e.prototype.digestFromString=function(e){return this.digest(e)},e.prototype.digestFromBuffer=function(e){return this.digest(e)},e.prototype.digestFromArrayBuffer=function(e){return this.digest(e)},e.prototype.resetState=function(){return this._initState(this._heap,this._padMaxChunkLen),this},e.prototype.append=function(e){var t=0,r=e.byteLength||e.length||e.size||0,n=this._offset%this._maxChunkLen,i=void 0;for(this._offset+=r;t0},!1)}function c(e,t){for(var r={main:[t]},n={main:[]},i={main:{}};u(r);)for(var o=Object.keys(r),s=0;s>2]|0;a=n[t+324>>2]|0;c=n[t+328>>2]|0;l=n[t+332>>2]|0;p=n[t+336>>2]|0;for(r=0;(r|0)<(e|0);r=r+64|0){s=o;u=a;f=c;h=l;d=p;for(i=0;(i|0)<64;i=i+4|0){g=n[r+i>>2]|0;y=((o<<5|o>>>27)+(a&c|~a&l)|0)+((g+p|0)+1518500249|0)|0;p=l;l=c;c=a<<30|a>>>2;a=o;o=y;n[e+i>>2]=g}for(i=e+64|0;(i|0)<(e+80|0);i=i+4|0){g=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;y=((o<<5|o>>>27)+(a&c|~a&l)|0)+((g+p|0)+1518500249|0)|0;p=l;l=c;c=a<<30|a>>>2;a=o;o=y;n[i>>2]=g}for(i=e+80|0;(i|0)<(e+160|0);i=i+4|0){g=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;y=((o<<5|o>>>27)+(a^c^l)|0)+((g+p|0)+1859775393|0)|0;p=l;l=c;c=a<<30|a>>>2;a=o;o=y;n[i>>2]=g}for(i=e+160|0;(i|0)<(e+240|0);i=i+4|0){g=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;y=((o<<5|o>>>27)+(a&c|a&l|c&l)|0)+((g+p|0)-1894007588|0)|0;p=l;l=c;c=a<<30|a>>>2;a=o;o=y;n[i>>2]=g}for(i=e+240|0;(i|0)<(e+320|0);i=i+4|0){g=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;y=((o<<5|o>>>27)+(a^c^l)|0)+((g+p|0)-899497514|0)|0;p=l;l=c;c=a<<30|a>>>2;a=o;o=y;n[i>>2]=g}o=o+s|0;a=a+u|0;c=c+f|0;l=l+h|0;p=p+d|0}n[t+320>>2]=o;n[t+324>>2]=a;n[t+328>>2]=c;n[t+332>>2]=l;n[t+336>>2]=p}return{hash:i}}},function(e,t){var r=this,n=void 0;"undefined"!=typeof self&&void 0!==self.FileReaderSync&&(n=new self.FileReaderSync);var i=function(e,t,r,n,i,o){var s=void 0,a=o%4,u=(i+a)%4,c=i-u;switch(a){case 0:t[o]=e[n+3];case 1:t[o+1-(a<<1)|0]=e[n+2];case 2:t[o+2-(a<<1)|0]=e[n+1];case 3:t[o+3-(a<<1)|0]=e[n]}if(!(i>2|0]=e[n+s]<<24|e[n+s+1]<<16|e[n+s+2]<<8|e[n+s+3];switch(u){case 3:t[o+c+1|0]=e[n+c+2];case 2:t[o+c+2|0]=e[n+c+1];case 1:t[o+c+3|0]=e[n+c]}}},o=function(e,t,r,i,o,s){var a=void 0,u=s%4,c=(o+u)%4,f=o-c,l=new Uint8Array(n.readAsArrayBuffer(e.slice(i,i+o)));switch(u){case 0:t[s]=l[3];case 1:t[s+1-(u<<1)|0]=l[2];case 2:t[s+2-(u<<1)|0]=l[1];case 3:t[s+3-(u<<1)|0]=l[0]}if(!(o>2|0]=l[a]<<24|l[a+1]<<16|l[a+2]<<8|l[a+3];switch(c){case 3:t[s+f+1|0]=l[f+2];case 2:t[s+f+2|0]=l[f+1];case 1:t[s+f+3|0]=l[f]}}};e.exports=function(e,t,n,s,a,u){if("string"==typeof e)return function(e,t,r,n,i,o){var s=void 0,a=o%4,u=(i+a)%4,c=i-u;switch(a){case 0:t[o]=e.charCodeAt(n+3);case 1:t[o+1-(a<<1)|0]=e.charCodeAt(n+2);case 2:t[o+2-(a<<1)|0]=e.charCodeAt(n+1);case 3:t[o+3-(a<<1)|0]=e.charCodeAt(n)}if(!(i>2]=e.charCodeAt(n+s)<<24|e.charCodeAt(n+s+1)<<16|e.charCodeAt(n+s+2)<<8|e.charCodeAt(n+s+3);switch(u){case 3:t[o+c+1|0]=e.charCodeAt(n+c+2);case 2:t[o+c+2|0]=e.charCodeAt(n+c+1);case 1:t[o+c+3|0]=e.charCodeAt(n+c)}}}(e,t,n,s,a,u);if(e instanceof Array)return i(e,t,n,s,a,u);if(r&&r.Buffer&&r.Buffer.isBuffer(e))return i(e,t,n,s,a,u);if(e instanceof ArrayBuffer)return i(new Uint8Array(e),t,n,s,a,u);if(e.buffer instanceof ArrayBuffer)return i(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),t,n,s,a,u);if(e instanceof Blob)return o(e,t,n,s,a,u);throw new Error("Unsupported data type.")}},function(e,t,r){var n=r(0),i=r(1).toHex,o=function(){function e(){(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this._rusha=new n,this._rusha.resetState()}return e.prototype.update=function(e){return this._rusha.append(e),this},e.prototype.digest=function(e){var t=this._rusha.rawEnd().buffer;if(!e)return t;if("hex"===e)return i(t);throw new Error("unsupported digest encoding")},e}();e.exports=function(){return new o}}])})},function(e,t){},function(e,t){},function(e,t,r){(function(t){e.exports=function(e,r){if("undefined"==typeof Blob||!(e instanceof Blob))throw new Error("first argument must be a Blob");if("function"!=typeof r)throw new Error("second argument must be a function");var n=new FileReader;n.addEventListener("loadend",function e(i){n.removeEventListener("loadend",e,!1),i.error?r(i.error):r(null,t.from(n.result))},!1),n.readAsArrayBuffer(e)}}).call(this,r(0).Buffer)},function(e,t,r){(function(t){e.exports=l;const n=r(325),i=r(1500),o=r(326),s=r(612),a=r(30),u=r(209),c=r(33),f=e=>null!==e&&"object"==typeof e&&"function"==typeof e.pipe;function l(e,r){if(e=Object.assign({maxRedirects:10},"string"==typeof e?{url:e}:e),r=a(r),e.url){const{hostname:t,port:r,protocol:n,auth:i,path:o}=c.parse(e.url);delete e.url,t||r||n||i?Object.assign(e,{hostname:t,port:r,protocol:n,auth:i,path:o}):e.path=o}const n={"accept-encoding":"gzip, deflate"};let h;e.headers&&Object.keys(e.headers).forEach(t=>n[t.toLowerCase()]=e.headers[t]),e.headers=n,e.body?h=e.json&&!f(e.body)?JSON.stringify(e.body):e.body:e.form&&(h="string"==typeof e.form?e.form:u.stringify(e.form),e.headers["content-type"]="application/x-www-form-urlencoded"),delete e.body,delete e.form,h&&(e.method||(e.method="POST"),f(h)||(e.headers["content-length"]=t.byteLength(h)),e.json&&(e.headers["content-type"]="application/json")),e.json&&(e.headers.accept="application/json"),e.method&&(e.method=e.method.toUpperCase());const p=("https:"===e.protocol?s:o).request(e,t=>{if(t.statusCode>=300&&t.statusCode<400&&t.headers.location)return e.url=t.headers.location,delete e.headers.host,t.resume(),"POST"===e.method&&[301,302].includes(t.statusCode)&&(e.method="GET",delete e.headers["content-length"],delete e.headers["content-type"]),0==e.maxRedirects--?r(new Error("too many redirects")):l(e,r);const n="function"==typeof i&&"HEAD"!==e.method;r(null,n?i(t):t)});return p.on("timeout",()=>{p.abort(),r(new Error("Request timed out"))}),p.on("error",r),f(h)?h.on("error",r).pipe(p):p.end(h),p}l.concat=((e,t)=>l(e,(r,i)=>{if(r)return t(r);n(i,(r,n)=>{if(r)return t(r);if(e.json)try{n=JSON.parse(n.toString())}catch(r){return t(r,i,n)}t(null,i,n)})})),["get","post","put","patch","head","delete"].forEach(e=>{l[e]=((t,r)=>("string"==typeof t&&(t={url:t}),l(Object.assign({method:e.toUpperCase()},t),r)))})}).call(this,r(0).Buffer)},function(e,t){},function(e,t,r){(function(t,n,i){var o=r(609),s=r(4),a=r(610),u=r(22),c=r(611),f=a.IncomingMessage,l=a.readyStates;var h=e.exports=function(e){var r,n=this;u.Writable.call(n),n._opts=e,n._body=[],n._headers={},e.auth&&n.setHeader("Authorization","Basic "+new t(e.auth).toString("base64")),Object.keys(e.headers).forEach(function(t){n.setHeader(t,e.headers[t])});var i=!0;if("disable-fetch"===e.mode||"requestTimeout"in e&&!o.abortController)i=!1,r=!0;else if("prefer-streaming"===e.mode)r=!1;else if("allow-wrong-content-type"===e.mode)r=!o.overrideMimeType;else{if(e.mode&&"default"!==e.mode&&"prefer-fast"!==e.mode)throw new Error("Invalid value for opts.mode");r=!0}n._mode=function(e,t){return o.fetch&&t?"fetch":o.mozchunkedarraybuffer?"moz-chunked-arraybuffer":o.msstream?"ms-stream":o.arraybuffer&&e?"arraybuffer":o.vbArray&&e?"text:vbarray":"text"}(r,i),n._fetchTimer=null,n.on("finish",function(){n._onFinish()})};s(h,u.Writable),h.prototype.setHeader=function(e,t){var r=e.toLowerCase();-1===p.indexOf(r)&&(this._headers[r]={name:e,value:t})},h.prototype.getHeader=function(e){var t=this._headers[e.toLowerCase()];return t?t.value:null},h.prototype.removeHeader=function(e){delete this._headers[e.toLowerCase()]},h.prototype._onFinish=function(){var e=this;if(!e._destroyed){var r=e._opts,s=e._headers,a=null;"GET"!==r.method&&"HEAD"!==r.method&&(a=o.arraybuffer?c(t.concat(e._body)):o.blobConstructor?new n.Blob(e._body.map(function(e){return c(e)}),{type:(s["content-type"]||{}).value||""}):t.concat(e._body).toString());var u=[];if(Object.keys(s).forEach(function(e){var t=s[e].name,r=s[e].value;Array.isArray(r)?r.forEach(function(e){u.push([t,e])}):u.push([t,r])}),"fetch"===e._mode){var f=null;if(o.abortController){var h=new AbortController;f=h.signal,e._fetchAbortController=h,"requestTimeout"in r&&0!==r.requestTimeout&&(e._fetchTimer=n.setTimeout(function(){e.emit("requestTimeout"),e._fetchAbortController&&e._fetchAbortController.abort()},r.requestTimeout))}n.fetch(e._opts.url,{method:e._opts.method,headers:u,body:a||void 0,mode:"cors",credentials:r.withCredentials?"include":"same-origin",signal:f}).then(function(t){e._fetchResponse=t,e._connect()},function(t){n.clearTimeout(e._fetchTimer),e._destroyed||e.emit("error",t)})}else{var p=e._xhr=new n.XMLHttpRequest;try{p.open(e._opts.method,e._opts.url,!0)}catch(t){return void i.nextTick(function(){e.emit("error",t)})}"responseType"in p&&(p.responseType=e._mode.split(":")[0]),"withCredentials"in p&&(p.withCredentials=!!r.withCredentials),"text"===e._mode&&"overrideMimeType"in p&&p.overrideMimeType("text/plain; charset=x-user-defined"),"requestTimeout"in r&&(p.timeout=r.requestTimeout,p.ontimeout=function(){e.emit("requestTimeout")}),u.forEach(function(e){p.setRequestHeader(e[0],e[1])}),e._response=null,p.onreadystatechange=function(){switch(p.readyState){case l.LOADING:case l.DONE:e._onXHRProgress()}},"moz-chunked-arraybuffer"===e._mode&&(p.onprogress=function(){e._onXHRProgress()}),p.onerror=function(){e._destroyed||e.emit("error",new Error("XHR error"))};try{p.send(a)}catch(t){return void i.nextTick(function(){e.emit("error",t)})}}}},h.prototype._onXHRProgress=function(){(function(e){try{var t=e.status;return null!==t&&0!==t}catch(e){return!1}})(this._xhr)&&!this._destroyed&&(this._response||this._connect(),this._response._onXHRProgress())},h.prototype._connect=function(){var e=this;e._destroyed||(e._response=new f(e._xhr,e._fetchResponse,e._mode,e._fetchTimer),e._response.on("error",function(t){e.emit("error",t)}),e.emit("response",e._response))},h.prototype._write=function(e,t,r){this._body.push(e),r()},h.prototype.abort=h.prototype.destroy=function(){this._destroyed=!0,n.clearTimeout(this._fetchTimer),this._response&&(this._response._destroyed=!0),this._xhr?this._xhr.abort():this._fetchAbortController&&this._fetchAbortController.abort()},h.prototype.end=function(e,t,r){"function"==typeof e&&(r=e,e=void 0),u.Writable.prototype.end.call(this,e,t,r)},h.prototype.flushHeaders=function(){},h.prototype.setTimeout=function(){},h.prototype.setNoDelay=function(){},h.prototype.setSocketKeepAlive=function(){};var p=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"]}).call(this,r(0).Buffer,r(7),r(6))},function(e,t){e.exports={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"}},function(e,t,r){e.exports=a,e.exports.decode=a,e.exports.encode=function(e){(e=o(e)).infoHashBuffer&&(e.xt="urn:btih:"+e.infoHashBuffer.toString("hex")),e.infoHash&&(e.xt="urn:btih:"+e.infoHash),e.name&&(e.dn=e.name),e.keywords&&(e.kt=e.keywords),e.announce&&(e.tr=e.announce),e.urlList&&(e.ws=e.urlList,delete e.as);var t="magnet:?";return Object.keys(e).filter(function(e){return 2===e.length}).forEach(function(r,n){(Array.isArray(e[r])?e[r]:[e[r]]).forEach(function(e,i){!(n>0||i>0)||"kt"===r&&0!==i||(t+="&"),"dn"===r&&(e=encodeURIComponent(e).replace(/%20/g,"+")),"tr"!==r&&"xs"!==r&&"as"!==r&&"ws"!==r||(e=encodeURIComponent(e)),"kt"===r&&(e=encodeURIComponent(e)),t+="kt"===r&&i>0?"+"+e:r+"="+e})}),t};var n=r(1504),i=r(2).Buffer,o=r(26),s=r(205);function a(e){var t,r={},o=e.split("magnet:?")[1];return(o&&o.length>=0?o.split("&"):[]).forEach(function(e){var t=e.split("=");if(2===t.length){var n=t[0],i=t[1];if("dn"===n&&(i=decodeURIComponent(i).replace(/\+/g," ")),"tr"!==n&&"xs"!==n&&"as"!==n&&"ws"!==n||(i=decodeURIComponent(i)),"kt"===n&&(i=decodeURIComponent(i).split("+")),"ix"===n&&(i=Number(i)),r[n])if(Array.isArray(r[n]))r[n].push(i);else{var o=r[n];r[n]=[o,i]}else r[n]=i}}),r.xt&&(Array.isArray(r.xt)?r.xt:[r.xt]).forEach(function(e){if(t=e.match(/^urn:btih:(.{40})/))r.infoHash=t[1].toLowerCase();else if(t=e.match(/^urn:btih:(.{32})/)){var o=n.decode(t[1]);r.infoHash=i.from(o,"binary").toString("hex")}}),r.infoHash&&(r.infoHashBuffer=i.from(r.infoHash,"hex")),r.dn&&(r.name=r.dn),r.kt&&(r.keywords=r.kt),"string"==typeof r.tr?r.announce=[r.tr]:Array.isArray(r.tr)?r.announce=r.tr:r.announce=[],r.urlList=[],("string"==typeof r.as||Array.isArray(r.as))&&(r.urlList=r.urlList.concat(r.as)),("string"==typeof r.ws||Array.isArray(r.ws))&&(r.urlList=r.urlList.concat(r.ws)),s(r.announce),s(r.urlList),r}},function(e,t,r){var n=r(1505);t.encode=n.encode,t.decode=n.decode},function(e,t,r){"use strict";(function(e){var r=[255,255,26,27,28,29,30,31,255,255,255,255,255,255,255,255,255,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,255,255,255,255,255,255,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,255,255,255,255,255];t.encode=function(t){e.isBuffer(t)||(t=new e(t));for(var r=0,n=0,i=0,o=0,s=new e(8*function(e){var t=Math.floor(e.length/5);return e.length%5==0?t:t+1}(t));r3?(o=(o=a&255>>i)<<(i=(i+5)%8)|(r+1>8-i,r++):(o=a>>8-(i+5)&31,0==(i=(i+5)%8)&&r++),s[n]="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".charCodeAt(o),n++}for(r=n;r>>(i=(i+5)%8),a[s]=n,s++,n=255&o<<8-i)}return a.slice(0,s)}}).call(this,r(0).Buffer)},function(e,t){e.exports=function e(t,r,n){return void 0===r?function(r,n){return e(t,r,n)}:(void 0===n&&(n="0"),(t-=r.toString().length)>0?new Array(t+(/\./.test(r)?2:1)).join(n)+r:r+"")}},function(e,t){},function(e,t,r){(function(t,n){e.exports=F;var i,o=r(1509),s=r(206),a=r(1510),u=r(1)("webtorrent:torrent"),c=r(1511),f=r(10).EventEmitter,l=r(26),h=r(614),p=r(95),d=r(1521),y=r(615),g=r(1523),m=r(4),b=r(607),v=r(1524),_=r(1525),w=r(147),S=r(1526),k=r(608),E=r(60),A=r(1527),x=r(539),I=r(1528),T=r(148),B=r(327),C=r(205),P=r(1529),O=r(1530),R=r(1531),N=r(1552),L=r(1554),j=r(1555),M=5e3,K=3*A.BLOCK_LENGTH,D=[1e3,5e3,15e3],U="WebTorrent/"+r(329).version+" (https://webtorrent.io)";try{i=E.join(p.statSync("/tmp")&&"/tmp","webtorrent")}catch(e){i=E.join("function"==typeof _.tmpdir?_.tmpdir():"/","webtorrent")}function F(e,t,r){f.call(this),this._debugId="unknown infohash",this.client=t,this.announce=r.announce,this.urlList=r.urlList,this.path=r.path,this._store=r.store||d,this._getAnnounceOpts=r.getAnnounceOpts,this.strategy=r.strategy||"sequential",this.maxWebConns=r.maxWebConns||4,this._rechokeNumSlots=!1===r.uploads||0===r.uploads?0:+r.uploads||10,this._rechokeOptimisticWire=null,this._rechokeOptimisticTime=0,this._rechokeIntervalId=null,this.ready=!1,this.destroyed=!1,this.paused=!1,this.done=!1,this.metadata=null,this.store=null,this.files=[],this.pieces=[],this._amInterested=!1,this._selections=[],this._critical=[],this.wires=[],this._queue=[],this._peers={},this._peersLength=0,this.received=0,this.uploaded=0,this._downloadSpeed=B(),this._uploadSpeed=B(),this._servers=[],this._xsRequests=[],this._fileModtimes=r.fileModtimes,null!==e&&this._onTorrentId(e),this._debug("new torrent")}function q(e,t){return 2+Math.ceil(t*e.downloadSpeed()/A.BLOCK_LENGTH)}function H(){}m(F,f),Object.defineProperty(F.prototype,"timeRemaining",{get:function(){return this.done?0:0===this.downloadSpeed?1/0:(this.length-this.downloaded)/this.downloadSpeed*1e3}}),Object.defineProperty(F.prototype,"downloaded",{get:function(){if(!this.bitfield)return 0;for(var e=0,t=0,r=this.pieces.length;t65536)return n._debug("ignoring invalid PORT from peer");n._debug("port: %s (from %s)",t,r),n.client.dht.addNode({host:e.remoteAddress,port:t})}}),e.on("timeout",function(){n._debug("wire timeout (%s)",r),e.destroy()}),e.setTimeout(3e4,!0),e.setKeepAlive(!0),e.use(P(n.metadata)),e.ut_metadata.on("warning",function(e){n._debug("ut_metadata warning: %s",e.message)}),n.metadata||(e.ut_metadata.on("metadata",function(e){n._debug("got metadata via ut_metadata"),n._onMetadata(e)}),e.ut_metadata.fetch()),"function"!=typeof O||n.private||(e.use(O()),e.ut_pex.on("peer",function(e){n.done||(n._debug("ut_pex: got peer: %s (from %s)",e,r),n.addPeer(e))}),e.ut_pex.on("dropped",function(e){var t=n._peers[e];t&&!t.connected&&(n._debug("ut_pex: dropped peer: %s (from %s)",e,r),n.removePeer(e))}),e.once("close",function(){e.ut_pex.reset()})),n.emit("wire",e,r),n.metadata&&t.nextTick(function(){n._onWireWithMetadata(e)})},F.prototype._onWireWithMetadata=function(e){var t,r=this,n=null;function i(){r.destroyed||e.destroyed||(r._numQueued>2*(r._numConns-r.numPeers)&&e.amInterested?e.destroy():(n=setTimeout(i,M)).unref&&n.unref())}function o(){if(e.peerPieces.buffer.length===r.bitfield.buffer.length){for(t=0;t131072)return e.destroy();r.pieces[t]||r.store.get(t,{offset:n,length:i},o)}),e.bitfield(r.bitfield),e.interested(),e.peerExtensions.dht&&r.client.dht&&r.client.dht.listening&&e.port(r.client.dht.address().port),"webSeed"!==e.type&&(n=setTimeout(i,M)).unref&&n.unref(),e.isSeeder=!1,o()},F.prototype._updateSelections=function(){var e=this;e.ready&&!e.destroyed&&(t.nextTick(function(){e._gcSelections()}),e._updateInterest(),e._update())},F.prototype._gcSelections=function(){for(var e=0;e=o.from+o.offset;--n)if(e.peerPieces.get(n)&&t._request(e,n,!1))return}}();var r=q(e,.5);if(!(e.requests.length>=r)){var n=q(e,1);s(!1)||s(!0)}}function i(t,r,n,i){return function(o){return o>=t&&o<=r&&!(o in n)&&e.peerPieces.get(o)&&(!i||i(o))}}function o(e){for(var r=e,n=e;n=n)return!0;for(var s=function(){var r=e.downloadSpeed()||1;if(r>K)return function(){return!0};var n=Math.max(1,e.requests.length)*A.BLOCK_LENGTH/r,i=10,o=0;return function(e){if(!i||t.bitfield.get(e))return!0;for(var s=t.pieces[e].missing;o0))return i--,!1}return!0}}(),a=0;a0?e._rechokeOptimisticTime-=1:e._rechokeOptimisticWire=null;var t=[];e.wires.forEach(function(r){r.isSeeder||r===e._rechokeOptimisticWire||t.push({wire:r,downloadSpeed:r.downloadSpeed(),uploadSpeed:r.uploadSpeed(),salt:Math.random(),isChoked:!0})}),t.sort(function(e,t){return e.downloadSpeed!==t.downloadSpeed?t.downloadSpeed-e.downloadSpeed:e.uploadSpeed!==t.uploadSpeed?t.uploadSpeed-e.uploadSpeed:e.wire.amChoking!==t.wire.amChoking?e.wire.amChoking?1:-1:e.salt-t.salt});for(var r=0,n=0;n=K||2*u>r||u>s||(i=a,s=u)}}if(!i)return!1;for(o=0;o=(s?Math.min(function(e,t,r){return 1+Math.ceil(t*e.downloadSpeed()/r)}(e,1,i.pieceLength),i.maxWebConns):q(e,1)))return!1;var a=i.pieces[r],u=s?a.reserveRemaining():a.reserve();if(-1===u&&n&&i._hotswap(e,r)&&(u=s?a.reserveRemaining():a.reserve()),-1===u)return!1;var c=i._reservations[r];c||(c=i._reservations[r]=[]);var f=c.indexOf(null);-1===f&&(f=c.length),c[f]=e;var l=a.chunkOffset(u),h=s?a.chunkLengthRemaining(u):a.chunkLength(u);function p(){t.nextTick(function(){i._update()})}return e.request(r,l,h,function t(n,o){if(!i.destroyed){if(!i.ready)return i.once("ready",function(){t(n,o)});if(c[f]===e&&(c[f]=null),a!==i.pieces[r])return p();if(n)return i._debug("error getting piece %s (offset: %s length: %s) from %s: %s",r,l,h,e.remoteAddress+":"+e.remotePort,n.message),s?a.cancelRemaining(u):a.cancel(u),void p();if(i._debug("got piece %s (offset: %s length: %s) from %s",r,l,h,e.remoteAddress+":"+e.remotePort),!a.set(u,o,e))return p();var d=a.flush();T(d,function(e){if(!i.destroyed){if(e===i._hashes[r]){if(!i.pieces[r])return;i._debug("piece verified %s",r),i.pieces[r]=null,i._reservations[r]=null,i.bitfield.set(r,!0),i.store.put(r,d),i.wires.forEach(function(e){e.have(r)}),i._checkDone()&&!i.destroyed&&i.discovery.complete()}else i.pieces[r]=new A(a.length),i.emit("warning",new Error("Piece "+r+" failed verification"));p()}})}}),!0},F.prototype._checkDone=function(){var e=this;if(!e.destroyed){e.files.forEach(function(t){if(!t.done){for(var r=t._startPiece;r<=t._endPiece;++r)if(!e.bitfield.get(r))return;t.done=!0,t.emit("done"),e._debug("file done: "+t.name)}});for(var t=!0,r=0;r=e.client.maxConns)){this._debug("drain (%s queued, %s/%s peers)",e._numQueued,e.numPeers,e.client.maxConns);var t=e._queue.shift();if(t){this._debug("tcp connect attempt to %s",t.addr);var r=o(t.addr),n={host:r[0],port:r[1]},i=t.conn=v.connect(n);i.once("connect",function(){t.onConnect()}),i.once("error",function(e){t.destroy(e)}),t.startConnectTimeout(),i.on("close",function(){if(!e.destroyed)if(t.retries>=D.length)e._debug("conn %s closed: will not re-add (max %s attempts)",t.addr,D.length);else{var r=D[t.retries];e._debug("conn %s closed: will re-add to queue in %sms (attempt %s)",t.addr,r,t.retries+1);var n=setTimeout(function(){var r=e._addPeer(t.addr);r&&(r.retries=t.retries+1)},r);n.unref&&n.unref()}})}}},F.prototype._validAddr=function(e){var t;try{t=o(e)}catch(e){return!1}var r=t[0],n=t[1];return n>0&&n<65535&&!("127.0.0.1"===r&&n===this.client.torrentPort)}}).call(this,r(6),r(7))},function(e,t){var r=/^\[?([^\]]+)\]?:(\d+)$/,n={},i=0;e.exports=function(t){if(1e5===i&&e.exports.reset(),!n[t]){var o=r.exec(t);if(!o)throw new Error("invalid addr: "+t);n[t]=[o[1],Number(o[2])],i+=1}return n[t]},e.exports.reset=function(){n={},i=0}},function(e,t,r){e.exports=s;var n=r(606),i=r(4),o=r(22);function s(e,t,r){var i=this;if(!(i instanceof s))return new s(e,t,r);if(o.Writable.call(i,r),r||(r={}),!e||!e.put||!e.get)throw new Error("First argument must be an abstract-chunk-store compliant store");if(!(t=Number(t)))throw new Error("Second argument must be a chunk length");i._blockstream=new n(t,{zeroPadding:!1}),i._blockstream.on("data",function(t){i.destroyed||(e.put(a,t),a+=1)}).on("error",function(e){i.destroy(e)});var a=0;i.on("finish",function(){this._blockstream.end()})}i(s,o.Writable),s.prototype._write=function(e,t,r){this._blockstream.write(e,t,r)},s.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e),this.emit("close"))}},function(e,t,r){(function(t){e.exports=f;var n=r(1)("torrent-discovery"),i=r(1512),o=r(10).EventEmitter,s=r(26),a=r(4),u=r(147),c=r(1513);function f(e){var r=this;if(!(r instanceof f))return new f(e);if(o.call(r),!e.peerId)throw new Error("Option `peerId` is required");if(!e.infoHash)throw new Error("Option `infoHash` is required");if(!t.browser&&!e.port)throw new Error("Option `port` is required");function n(e,t){var n=new i(t);return n.on("warning",r._onWarning),n.on("error",r._onError),n.listen(e),r._internalDHT=!0,n}r.peerId="string"==typeof e.peerId?e.peerId:e.peerId.toString("hex"),r.infoHash="string"==typeof e.infoHash?e.infoHash.toLowerCase():e.infoHash.toString("hex"),r._port=e.port,r._userAgent=e.userAgent,r.destroyed=!1,r._announce=e.announce||[],r._intervalMs=e.intervalMs||9e5,r._trackerOpts=null,r._dhtAnnouncing=!1,r._dhtTimeout=!1,r._internalDHT=!1,r._onWarning=function(e){r.emit("warning",e)},r._onError=function(e){r.emit("error",e)},r._onDHTPeer=function(e,t){t.toString("hex")===r.infoHash&&r.emit("peer",e.host+":"+e.port,"dht")},r._onTrackerPeer=function(e){r.emit("peer",e,"tracker")},r._onTrackerAnnounce=function(){r.emit("trackerAnnounce")},!1===e.tracker?r.tracker=null:e.tracker&&"object"==typeof e.tracker?(r._trackerOpts=s(e.tracker),r.tracker=r._createTracker()):r.tracker=r._createTracker(),!1===e.dht||"function"!=typeof i?r.dht=null:e.dht&&"function"==typeof e.dht.addNode?r.dht=e.dht:e.dht&&"object"==typeof e.dht?r.dht=n(e.dhtPort,e.dht):r.dht=n(e.dhtPort),r.dht&&(r.dht.on("peer",r._onDHTPeer),r._dhtAnnounce())}a(f,o),f.prototype.updatePort=function(e){var t=this;e!==t._port&&(t._port=e,t.dht&&t._dhtAnnounce(),t.tracker&&(t.tracker.stop(),t.tracker.destroy(function(){t.tracker=t._createTracker()})))},f.prototype.complete=function(e){this.tracker&&this.tracker.complete(e)},f.prototype.destroy=function(e){var t=this;if(!t.destroyed){t.destroyed=!0,clearTimeout(t._dhtTimeout);var r=[];t.tracker&&(t.tracker.stop(),t.tracker.removeListener("warning",t._onWarning),t.tracker.removeListener("error",t._onError),t.tracker.removeListener("peer",t._onTrackerPeer),t.tracker.removeListener("update",t._onTrackerAnnounce),r.push(function(e){t.tracker.destroy(e)})),t.dht&&t.dht.removeListener("peer",t._onDHTPeer),t._internalDHT&&(t.dht.removeListener("warning",t._onWarning),t.dht.removeListener("error",t._onError),r.push(function(e){t.dht.destroy(e)})),u(r,e),t.dht=null,t.tracker=null,t._announce=null}},f.prototype._createTracker=function(){var e=s(this._trackerOpts,{infoHash:this.infoHash,announce:this._announce,peerId:this.peerId,port:this._port,userAgent:this._userAgent}),t=new c(e);return t.on("warning",this._onWarning),t.on("error",this._onError),t.on("peer",this._onTrackerPeer),t.on("update",this._onTrackerAnnounce),t.setInterval(this._intervalMs),t.start(),t},f.prototype._dhtAnnounce=function(){var e=this;e._dhtAnnouncing||(n("dht announce"),e._dhtAnnouncing=!0,clearTimeout(e._dhtTimeout),e.dht.announce(e.infoHash,e._port,function(t){e._dhtAnnouncing=!1,n("dht announce complete"),t&&e.emit("warning",t),e.emit("dhtAnnounce"),e.destroyed||(e._dhtTimeout=setTimeout(function(){e._dhtAnnounce()},e._intervalMs+Math.floor(Math.random()*e._intervalMs/5)),e._dhtTimeout.unref&&e._dhtTimeout.unref())}))}}).call(this,r(6))},function(e,t){},function(e,t,r){(function(t){e.exports=m;var n=r(2).Buffer,i=r(1)("bittorrent-tracker:client"),o=r(10).EventEmitter,s=r(26),a=r(4),u=r(30),c=r(147),f=r(191),l=r(205),h=r(33),p=r(613),d=r(1515),y=r(1516),g=r(1517);function m(e){var r=this;if(!(r instanceof m))return new m(e);if(o.call(r),e||(e={}),!e.peerId)throw new Error("Option `peerId` is required");if(!e.infoHash)throw new Error("Option `infoHash` is required");if(!e.announce)throw new Error("Option `announce` is required");if(!t.browser&&!e.port)throw new Error("Option `port` is required");r.peerId="string"==typeof e.peerId?e.peerId:e.peerId.toString("hex"),r._peerIdBuffer=n.from(r.peerId,"hex"),r._peerIdBinary=r._peerIdBuffer.toString("binary"),r.infoHash="string"==typeof e.infoHash?e.infoHash.toLowerCase():e.infoHash.toString("hex"),r._infoHashBuffer=n.from(r.infoHash,"hex"),r._infoHashBinary=r._infoHashBuffer.toString("binary"),i("new client %s",r.infoHash),r.destroyed=!1,r._port=e.port,r._getAnnounceOpts=e.getAnnounceOpts,r._rtcConfig=e.rtcConfig,r._userAgent=e.userAgent,r._wrtc="function"==typeof e.wrtc?e.wrtc():e.wrtc;var s="string"==typeof e.announce?[e.announce]:null==e.announce?[]:e.announce;s=s.map(function(e){return"/"===(e=e.toString())[e.length-1]&&(e=e.substring(0,e.length-1)),e}),s=l(s);var a=!1!==r._wrtc&&(!!r._wrtc||f.WEBRTC_SUPPORT);function u(e){t.nextTick(function(){r.emit("warning",e)})}r._trackers=s.map(function(e){var t=h.parse(e).protocol;return"http:"!==t&&"https:"!==t||"function"!=typeof d?"udp:"===t&&"function"==typeof y?new y(r,e):"ws:"!==t&&"wss:"!==t||!a?(u(new Error("Unsupported tracker protocol: "+e)),null):"ws:"===t&&"undefined"!=typeof window&&"https:"===window.location.protocol?(u(new Error("Unsupported tracker protocol: "+e)),null):new g(r,e):new d(r,e)}).filter(Boolean)}a(m,o),m.scrape=function(e,t){if(t=u(t),!e.infoHash)throw new Error("Option `infoHash` is required");if(!e.announce)throw new Error("Option `announce` is required");var r=new m(s(e,{infoHash:Array.isArray(e.infoHash)?e.infoHash[0]:e.infoHash,peerId:n.from("01234567890123456789"),port:6881}));r.once("error",t),r.once("warning",t);var i=Array.isArray(e.infoHash)?e.infoHash.length:1,o={};return r.on("scrape",function(e){if(i-=1,o[e.infoHash]=e,0===i){r.destroy();var n=Object.keys(o);1===n.length?t(null,o[n[0]]):t(null,o)}}),e.infoHash=Array.isArray(e.infoHash)?e.infoHash.map(function(e){return n.from(e,"hex")}):n.from(e.infoHash,"hex"),r.scrape({infoHash:e.infoHash}),r},m.prototype.start=function(e){i("send `start`"),(e=this._defaultAnnounceOpts(e)).event="started",this._announce(e),this._trackers.forEach(function(e){e.setInterval()})},m.prototype.stop=function(e){i("send `stop`"),(e=this._defaultAnnounceOpts(e)).event="stopped",this._announce(e)},m.prototype.complete=function(e){i("send `complete`"),e||(e={}),(e=this._defaultAnnounceOpts(e)).event="completed",this._announce(e)},m.prototype.update=function(e){i("send `update`"),(e=this._defaultAnnounceOpts(e)).event&&delete e.event,this._announce(e)},m.prototype._announce=function(e){this._trackers.forEach(function(t){t.announce(e)})},m.prototype.scrape=function(e){i("send `scrape`"),e||(e={}),this._trackers.forEach(function(t){t.scrape(e)})},m.prototype.setInterval=function(e){i("setInterval %d",e),this._trackers.forEach(function(t){t.setInterval(e)})},m.prototype.destroy=function(e){if(!this.destroyed){this.destroyed=!0,i("destroy");var t=this._trackers.map(function(e){return function(t){e.destroy(t)}});c(t,e),this._trackers=[],this._getAnnounceOpts=null}},m.prototype._defaultAnnounceOpts=function(e){return e||(e={}),null==e.numwant&&(e.numwant=p.DEFAULT_ANNOUNCE_PEERS),null==e.uploaded&&(e.uploaded=0),null==e.downloaded&&(e.downloaded=0),this._getAnnounceOpts&&(e=s(e,this._getAnnounceOpts())),e}}).call(this,r(6))},function(e,t){},function(e,t){},function(e,t){},function(e,t,r){e.exports=p;var n=r(1)("bittorrent-tracker:websocket-tracker"),i=r(26),o=r(4),s=r(191),a=r(108),u=r(1518),c=r(613),f=r(1520),l={},h=5e4;function p(e,t,r){f.call(this,e,t),n("new websocket tracker %s",t),this.peers={},this.socket=null,this.reconnecting=!1,this.retries=0,this.reconnectTimer=null,this.expectingResponse=!1,this._openSocket()}function d(){}o(p,f),p.prototype.DEFAULT_ANNOUNCE_INTERVAL=3e4,p.prototype.announce=function(e){var t=this;if(!t.destroyed&&!t.reconnecting)if(t.socket.connected){var r=i(e,{action:"announce",info_hash:t.client._infoHashBinary,peer_id:t.client._peerIdBinary});if(t._trackerId&&(r.trackerid=t._trackerId),"stopped"===e.event||"completed"===e.event)t._send(r);else{var n=Math.min(e.numwant,10);t._generateOffers(n,function(e){r.numwant=n,r.offers=e,t._send(r)})}}else t.socket.once("connect",function(){t.announce(e)})},p.prototype.scrape=function(e){var t=this;if(!t.destroyed&&!t.reconnecting)if(t.socket.connected){var r={action:"scrape",info_hash:Array.isArray(e.infoHash)&&e.infoHash.length>0?e.infoHash.map(function(e){return e.toString("binary")}):e.infoHash&&e.infoHash.toString("binary")||t.client._infoHashBinary};t._send(r)}else t.socket.once("connect",function(){t.scrape(e)})},p.prototype.destroy=function(e){if(e||(e=d),this.destroyed)return e(null);for(var t in this.destroyed=!0,clearInterval(this.interval),clearTimeout(this.reconnectTimer),this.peers){var r=this.peers[t];clearTimeout(r.trackerTimeout),r.destroy()}if(this.peers=null,this.socket&&(this.socket.removeListener("connect",this._onSocketConnectBound),this.socket.removeListener("data",this._onSocketDataBound),this.socket.removeListener("close",this._onSocketCloseBound),this.socket.removeListener("error",this._onSocketErrorBound),this.socket=null),this._onSocketConnectBound=null,this._onSocketErrorBound=null,this._onSocketDataBound=null,this._onSocketCloseBound=null,l[this.announceUrl]&&(l[this.announceUrl].consumers-=1),l[this.announceUrl].consumers>0)return e();var n=l[this.announceUrl];if(delete l[this.announceUrl],n.on("error",d),n.once("close",e),!this.expectingResponse)return o();var i=setTimeout(o,c.DESTROY_TIMEOUT);function o(){i&&(clearTimeout(i),i=null),n.removeListener("data",o),n.destroy(),n=null}n.once("data",o)},p.prototype._openSocket=function(){var e=this;e.destroyed=!1,e.peers||(e.peers={}),e._onSocketConnectBound=function(){e._onSocketConnect()},e._onSocketErrorBound=function(t){e._onSocketError(t)},e._onSocketDataBound=function(t){e._onSocketData(t)},e._onSocketCloseBound=function(){e._onSocketClose()},e.socket=l[e.announceUrl],e.socket?l[e.announceUrl].consumers+=1:(e.socket=l[e.announceUrl]=new u(e.announceUrl),e.socket.consumers=1,e.socket.once("connect",e._onSocketConnectBound)),e.socket.on("data",e._onSocketDataBound),e.socket.once("close",e._onSocketCloseBound),e.socket.once("error",e._onSocketErrorBound)},p.prototype._onSocketConnect=function(){this.destroyed||this.reconnecting&&(this.reconnecting=!1,this.retries=0,this.announce(this.client._defaultAnnounceOpts()))},p.prototype._onSocketData=function(e){if(!this.destroyed){this.expectingResponse=!1;try{e=JSON.parse(e)}catch(e){return void this.client.emit("warning",new Error("Invalid tracker response"))}"announce"===e.action?this._onAnnounceResponse(e):"scrape"===e.action?this._onScrapeResponse(e):this._onSocketError(new Error("invalid action in WS response: "+e.action))}},p.prototype._onAnnounceResponse=function(e){var t=this;if(e.info_hash===t.client._infoHashBinary){if(!e.peer_id||e.peer_id!==t.client._peerIdBinary){n("received %s from %s for %s",JSON.stringify(e),t.announceUrl,t.client.infoHash);var r=e["failure reason"];if(r)return t.client.emit("warning",new Error(r));var i=e["warning message"];i&&t.client.emit("warning",new Error(i));var o=e.interval||e["min interval"];o&&t.setInterval(1e3*o);var s,a=e["tracker id"];if(a&&(t._trackerId=a),null!=e.complete){var u=Object.assign({},e,{announce:t.announceUrl,infoHash:c.binaryToHex(e.info_hash)});t.client.emit("update",u)}if(e.offer&&e.peer_id&&(n("creating peer (from remote offer)"),(s=t._createPeer()).id=c.binaryToHex(e.peer_id),s.once("signal",function(r){var n={action:"announce",info_hash:t.client._infoHashBinary,peer_id:t.client._peerIdBinary,to_peer_id:e.peer_id,answer:r,offer_id:e.offer_id};t._trackerId&&(n.trackerid=t._trackerId),t._send(n)}),s.signal(e.offer),t.client.emit("peer",s)),e.answer&&e.peer_id){var f=c.binaryToHex(e.offer_id);(s=t.peers[f])?(s.id=c.binaryToHex(e.peer_id),s.signal(e.answer),t.client.emit("peer",s),clearTimeout(s.trackerTimeout),s.trackerTimeout=null,delete t.peers[f]):n("got unexpected answer: "+JSON.stringify(e.answer))}}}else n("ignoring websocket data from %s for %s (looking for %s: reused socket)",t.announceUrl,c.binaryToHex(e.info_hash),t.client.infoHash)},p.prototype._onScrapeResponse=function(e){var t=this;e=e.files||{};var r=Object.keys(e);0!==r.length?r.forEach(function(r){var n=Object.assign(e[r],{announce:t.announceUrl,infoHash:c.binaryToHex(r)});t.client.emit("scrape",n)}):t.client.emit("warning",new Error("invalid scrape response"))},p.prototype._onSocketClose=function(){this.destroyed||(this.destroy(),this._startReconnectTimer())},p.prototype._onSocketError=function(e){this.destroyed||(this.destroy(),this.client.emit("warning",e),this._startReconnectTimer())},p.prototype._startReconnectTimer=function(){var e=this,t=Math.floor(3e4*Math.random())+Math.min(15e3*Math.pow(2,e.retries),18e5);e.reconnecting=!0,clearTimeout(e.reconnectTimer),e.reconnectTimer=setTimeout(function(){e.retries++,e._openSocket()},t),e.reconnectTimer.unref&&e.reconnectTimer.unref(),n("reconnecting socket in %s ms",t)},p.prototype._send=function(e){if(!this.destroyed){this.expectingResponse=!0;var t=JSON.stringify(e);n("send %s",t),this.socket.send(t)}},p.prototype._generateOffers=function(e,t){var r=this,i=[];n("generating %s offers",e);for(var o=0;o65536?(this._debug("start backpressure: bufferedAmount %d",this._ws.bufferedAmount),this._cb=r):r(null)}else this._debug("write before connect"),this._chunk=e,this._cb=r},f.prototype._onFinish=function(){var e=this;function t(){setTimeout(function(){e.destroy()},1e3)}e.destroyed||(e.connected?t():e.once("connect",t))},f.prototype._onMessage=function(e){if(!this.destroyed){var t=e.data;t instanceof ArrayBuffer&&(t=n.from(t)),this.push(t)}},f.prototype._onOpen=function(){var e=this;if(!e.connected&&!e.destroyed){if(e.connected=!0,e._chunk){try{e.send(e._chunk)}catch(t){return e.destroy(t)}e._chunk=null,e._debug('sent chunk from "write before connect"');var t=e._cb;e._cb=null,t(null)}"function"!=typeof u&&(e._interval=setInterval(function(){e._onInterval()},150),e._interval.unref&&e._interval.unref()),e._debug("connect"),e.emit("connect")}},f.prototype._onInterval=function(){if(this._cb&&this._ws&&!(this._ws.bufferedAmount>65536)){this._debug("ending backpressure: bufferedAmount %d",this._ws.bufferedAmount);var e=this._cb;this._cb=null,e(null)}},f.prototype._onClose=function(){this.destroyed||(this._debug("on close"),this.destroy())},f.prototype._debug=function(){var e=[].slice.call(arguments);e[0]="["+this._id+"] "+e[0],i.apply(null,e)}}).call(this,r(6))},function(e,t){},function(e,t,r){e.exports=i;var n=r(10).EventEmitter;function i(e,t){n.call(this),this.client=e,this.announceUrl=t,this.interval=null,this.destroyed=!1}r(4)(i,n),i.prototype.setInterval=function(e){var t=this;null==e&&(e=t.DEFAULT_ANNOUNCE_INTERVAL),clearInterval(t.interval),e&&(t.interval=setInterval(function(){t.announce(t.client._defaultAnnounceOpts())},e),t.interval.unref&&t.interval.unref())}},function(e,t,r){(function(t){function r(e,t){if(!(this instanceof r))return new r(e,t);if(t||(t={}),this.chunkLength=Number(e),!this.chunkLength)throw new Error("First argument must be a chunk length");this.chunks=[],this.closed=!1,this.length=Number(t.length)||1/0,this.length!==1/0&&(this.lastChunkLength=this.length%this.chunkLength||this.chunkLength,this.lastChunkIndex=Math.ceil(this.length/this.chunkLength)-1)}function n(e,r,n){t.nextTick(function(){e&&e(r,n)})}e.exports=r,r.prototype.put=function(e,t,r){if(this.closed)return n(r,new Error("Storage is closed"));var i=e===this.lastChunkIndex;return i&&t.length!==this.lastChunkLength?n(r,new Error("Last chunk length must be "+this.lastChunkLength)):i||t.length===this.chunkLength?(this.chunks[e]=t,void n(r,null)):n(r,new Error("Chunk length must be "+this.chunkLength))},r.prototype.get=function(e,t,r){if("function"==typeof t)return this.get(e,null,t);if(this.closed)return n(r,new Error("Storage is closed"));var i=this.chunks[e];if(!i){var o=new Error("Chunk not found");return o.notFound=!0,n(r,o)}if(!t)return n(r,null,i);var s=t.offset||0,a=t.length||i.length-s;n(r,null,i.slice(s,a+s))},r.prototype.close=r.prototype.destroy=function(e){if(this.closed)return n(e,new Error("Storage is closed"));this.closed=!0,this.chunks=null,n(e,null)}}).call(this,r(6))},function(e,t){},function(e,t,r){(function(t){function r(e){if(!(this instanceof r))return new r(e);if(this.store=e,this.chunkLength=e.chunkLength,!this.store||!this.store.get||!this.store.put)throw new Error("First argument must be abstract-chunk-store compliant");this.mem=[]}function n(e,r,n){t.nextTick(function(){e&&e(r,n)})}e.exports=r,r.prototype.put=function(e,t,r){var n=this;n.mem[e]=t,n.store.put(e,t,function(t){n.mem[e]=null,r&&r(t)})},r.prototype.get=function(e,t,r){if("function"==typeof t)return this.get(e,null,t);var i=t&&t.offset||0,o=t&&t.length&&i+t.length,s=this.mem[e];if(s)return n(r,null,t?s.slice(i,o):s);this.store.get(e,t,r)},r.prototype.close=function(e){this.store.close(e)},r.prototype.destroy=function(e){this.store.destroy(e)}}).call(this,r(6))},function(e,t){},function(e,t){},function(e,t,r){(function(t){e.exports=function(e,r,n){if("number"!=typeof r)throw new Error("second argument must be a Number");var i,o,s,a,u,c=!0;function f(e){function r(){n&&n(e,i),n=null}c?t.nextTick(r):r()}function l(t,r,n){if(i[t]=n,r&&(u=!0),0==--s||r)f(r);else if(!u&&hthis._metadataSize&&(r=this._metadataSize);var n=this.metadata.slice(t,r);this._data(e,n,this._metadataSize)}else this._reject(e)},t.prototype._onData=function(e,t,r){t.length>16384||(t.copy(this.metadata,16384*e),this._bitfield.set(e),this._checkDone())},t.prototype._onReject=function(e){this._remainingRejects>0&&this._fetching?(this._request(e),this._remainingRejects-=1):this.emit("warning",new Error('Peer sent "reject" too much'))},t.prototype._requestPieces=function(){this.metadata=o.alloc(this._metadataSize);for(var e=0;e0?this._requestPieces():this.emit("warning",new Error("Peer sent invalid metadata"))},t}},function(e,t){},function(e,t,r){(function(t){e.exports=p;var n=r(193),i=r(10).EventEmitter,o=r(1532),s=r(4),a=r(60),u=r(1533),c=r(22),f=r(618),l=r(617),h=r(1551);function p(e,t){i.call(this),this._torrent=e,this._destroyed=!1,this.name=t.name,this.path=t.path,this.length=t.length,this.offset=t.offset,this.done=!1;var r=t.offset,n=r+t.length-1;this._startPiece=r/this._torrent.pieceLength|0,this._endPiece=n/this._torrent.pieceLength|0,0===this.length&&(this.done=!0,this.emit("done"))}s(p,i),Object.defineProperty(p.prototype,"downloaded",{get:function(){if(!this._torrent.bitfield)return 0;for(var e=0,t=this._startPiece;t<=this._endPiece;++t)if(this._torrent.bitfield.get(t))e+=t===this._endPiece?this._torrent.lastPieceLength:this._torrent.pieceLength;else{var r=this._torrent.pieces[t];e+=r.length-r.missing}return e}}),Object.defineProperty(p.prototype,"progress",{get:function(){return this.length?this.downloaded/this.length:0}}),p.prototype.select=function(e){0!==this.length&&this._torrent.select(this._startPiece,this._endPiece,e)},p.prototype.deselect=function(){0!==this.length&&this._torrent.deselect(this._startPiece,this._endPiece,!1)},p.prototype.createReadStream=function(e){var r=this;if(0===this.length){var i=new c.PassThrough;return t.nextTick(function(){i.end()}),i}var s=new o(r,e);return r._torrent.select(s._startPiece,s._endPiece,!0,function(){s._notify()}),n(s,function(){r._destroyed||r._torrent.destroyed||r._torrent.deselect(s._startPiece,s._endPiece,!0)}),s},p.prototype.getBuffer=function(e){h(this.createReadStream(),this.length,e)},p.prototype.getBlob=function(e){if("undefined"==typeof window)throw new Error("browser-only method");f(this.createReadStream(),this._getMimeType(),e)},p.prototype.getBlobURL=function(e){if("undefined"==typeof window)throw new Error("browser-only method");l(this.createReadStream(),this._getMimeType(),e)},p.prototype.appendTo=function(e,t,r){if("undefined"==typeof window)throw new Error("browser-only method");u.append(this,e,t,r)},p.prototype.renderTo=function(e,t,r){if("undefined"==typeof window)throw new Error("browser-only method");u.render(this,e,t,r)},p.prototype._getMimeType=function(){return u.mime[a.extname(this.name).toLowerCase()]},p.prototype._destroy=function(){this._destroyed=!0,this._torrent=null}}).call(this,r(6))},function(e,t,r){e.exports=s;var n=r(1)("webtorrent:file-stream"),i=r(4),o=r(22);function s(e,t){o.Readable.call(this,t),this.destroyed=!1,this._torrent=e._torrent;var r=t&&t.start||0,n=t&&t.end&&t.end=0?function(){var i=f.indexOf(m)>=0?"video":"audio";function s(){n("Use MediaSource API for "+e.name),p(),y.addEventListener("error",h),y.addEventListener("loadstart",w),y.addEventListener("canplay",S);var t=new o(y).createWriteStream(_(e.name));e.createReadStream().pipe(t),v&&(y.currentTime=v)}function a(){n("Use Blob URL for "+e.name),p(),y.addEventListener("error",E),y.addEventListener("loadstart",w),y.addEventListener("canplay",S),b(e,function(e,t){if(e)return E(e);y.src=t,v&&(y.currentTime=v)})}function l(e){n("videostream error: fallback to MediaSource API: %o",e.message||e),y.removeEventListener("error",l),y.removeEventListener("canplay",S),s()}function h(t){if(n("MediaSource API error: fallback to Blob URL: %o",t.message||t),"number"==typeof e.length&&e.length>r.maxBlobLength)return n("File length too large for Blob URL approach: %d (max: %d)",e.length,r.maxBlobLength),E(new Error("File length too large for Blob URL approach: "+e.length+" (max: "+r.maxBlobLength+")"));y.removeEventListener("error",h),y.removeEventListener("canplay",S),a()}function p(){y||(y=t(i)).addEventListener("progress",function(){v=y.currentTime})}g?c.indexOf(m)>=0?(n("Use `videostream` package for "+e.name),p(),y.addEventListener("error",l),y.addEventListener("loadstart",w),y.addEventListener("canplay",S),u(e,y)):s():a()}():h.indexOf(m)>=0?(y=t("audio"),b(e,function(e,t){if(e)return E(e);y.addEventListener("error",E),y.addEventListener("loadstart",w),y.addEventListener("canplay",S),y.src=t})):p.indexOf(m)>=0?(y=t("img"),b(e,function(t,r){if(t)return E(t);y.src=r,y.alt=e.name,a(null,y)})):d.indexOf(m)>=0?k():function(){n('Unknown file extension "%s" - will attempt to render into iframe',m);var t="";e.createReadStream({start:0,end:1e3}).setEncoding("utf8").on("data",function(e){t+=e}).on("end",function(){i(t)?(n('File extension "%s" appears ascii, so will render.',m),k()):(n('File extension "%s" appears non-ascii, will not render.',m),a(new Error('Unsupported file type "'+m+'": Cannot append to DOM')))}).on("error",a)}()}function b(e,r){var n=s.extname(e.name).toLowerCase();a(e.createReadStream(),t.mime[n],r)}function v(e){if(null==e)throw new Error("file cannot be null or undefined");if("string"!=typeof e.name)throw new Error("missing or invalid file.name property");if("function"!=typeof e.createReadStream)throw new Error("missing or invalid file.createReadStream property")}function _(e){return{".m4a":'audio/mp4; codecs="mp4a.40.5"',".m4v":'video/mp4; codecs="avc1.640029, mp4a.40.5"',".mkv":'video/webm; codecs="avc1.640029, mp4a.40.5"',".mp3":"audio/mpeg",".mp4":'video/mp4; codecs="avc1.640029, mp4a.40.5"',".webm":'video/webm; codecs="vorbis, vp8"'}[s.extname(e).toLowerCase()]}function w(e){null==e.autoplay&&(e.autoplay=!1),null==e.muted&&(e.muted=!1),null==e.controls&&(e.controls=!0),null==e.maxBlobLength&&(e.maxBlobLength=y)}},function(e){e.exports={".3gp":"video/3gpp",".aac":"audio/aac",".aif":"audio/x-aiff",".aiff":"audio/x-aiff",".atom":"application/atom+xml",".avi":"video/x-msvideo",".bmp":"image/bmp",".bz2":"application/x-bzip2",".conf":"text/plain",".css":"text/css",".csv":"text/plain",".diff":"text/x-diff",".doc":"application/msword",".flv":"video/x-flv",".gif":"image/gif",".gz":"application/x-gzip",".htm":"text/html",".html":"text/html",".ico":"image/vnd.microsoft.icon",".ics":"text/calendar",".iso":"application/octet-stream",".jar":"application/java-archive",".jpeg":"image/jpeg",".jpg":"image/jpeg",".js":"application/javascript",".json":"application/json",".less":"text/css",".log":"text/plain",".m3u":"audio/x-mpegurl",".m4a":"audio/mp4",".m4v":"video/mp4",".manifest":"text/cache-manifest",".markdown":"text/x-markdown",".mathml":"application/mathml+xml",".md":"text/x-markdown",".mid":"audio/midi",".midi":"audio/midi",".mov":"video/quicktime",".mp3":"audio/mpeg",".mp4":"video/mp4",".mp4v":"video/mp4",".mpeg":"video/mpeg",".mpg":"video/mpeg",".odp":"application/vnd.oasis.opendocument.presentation",".ods":"application/vnd.oasis.opendocument.spreadsheet",".odt":"application/vnd.oasis.opendocument.text",".oga":"audio/ogg",".ogg":"application/ogg",".pdf":"application/pdf",".png":"image/png",".pps":"application/vnd.ms-powerpoint",".ppt":"application/vnd.ms-powerpoint",".ps":"application/postscript",".psd":"image/vnd.adobe.photoshop",".qt":"video/quicktime",".rar":"application/x-rar-compressed",".rdf":"application/rdf+xml",".rss":"application/rss+xml",".rtf":"application/rtf",".svg":"image/svg+xml",".svgz":"image/svg+xml",".swf":"application/x-shockwave-flash",".tar":"application/x-tar",".tbz":"application/x-bzip-compressed-tar",".text":"text/plain",".tif":"image/tiff",".tiff":"image/tiff",".torrent":"application/x-bittorrent",".ttf":"application/x-font-ttf",".txt":"text/plain",".wav":"audio/wav",".webm":"video/webm",".wma":"audio/x-ms-wma",".wmv":"video/x-ms-wmv",".xls":"application/vnd.ms-excel",".xml":"application/xml",".yaml":"text/yaml",".yml":"text/yaml",".zip":"application/zip"}},function(e,t){e.exports=function(e){for(var t=0,r=e.length;t127)return!1;return!0}},function(e,t,r){var n=r(616),i=r(1537),o=r(1539);function s(e,t,r){var i=this;if(!(this instanceof s))return new s(e,t,r);r=r||{},i.detailedError=null,i._elem=t,i._elemWrapper=new n(t),i._waitingFired=!1,i._trackMeta=null,i._file=e,i._tracks=null,"none"!==i._elem.preload&&i._createMuxer(),i._onError=function(e){i.detailedError=i._elemWrapper.detailedError,i.destroy()},i._onWaiting=function(){i._waitingFired=!0,i._muxer?i._tracks&&i._pump():i._createMuxer()},i._elem.addEventListener("waiting",i._onWaiting),i._elem.addEventListener("error",i._onError)}e.exports=s,s.prototype._createMuxer=function(){var e=this;e._muxer=new o(e._file),e._muxer.on("ready",function(t){e._tracks=t.map(function(t){var r=e._elemWrapper.createWriteStream(t.mime);r.on("error",function(t){e._elemWrapper.error(t)});var n={muxed:null,mediaSource:r,initFlushed:!1,onInitFlushed:null};return r.write(t.init,function(e){n.initFlushed=!0,n.onInitFlushed&&n.onInitFlushed(e)}),n}),(e._waitingFired||"auto"===e._elem.preload)&&e._pump()}),e._muxer.on("error",function(t){e._elemWrapper.error(t)})},s.prototype._pump=function(){var e=this,t=e._muxer.seek(e._elem.currentTime,!e._tracks);e._tracks.forEach(function(r,n){var o=function(){r.muxed&&(r.muxed.destroy(),r.mediaSource=e._elemWrapper.createWriteStream(r.mediaSource),r.mediaSource.on("error",function(t){e._elemWrapper.error(t)})),r.muxed=t[n],i(r.muxed,r.mediaSource)};r.initFlushed?o():r.onInitFlushed=function(t){t?e._elemWrapper.error(t):o()}})},s.prototype.destroy=function(){this.destroyed||(this.destroyed=!0,this._elem.removeEventListener("waiting",this._onWaiting),this._elem.removeEventListener("error",this._onError),this._tracks&&this._tracks.forEach(function(e){e.muxed&&e.muxed.destroy()}),this._elem.src="")}},function(e,t,r){var n=r(30),i=r(193),o=r(1538),s=function(){},a=function(e){return"function"==typeof e},u=function(e){return!!o&&(e instanceof(o.ReadStream||s)||e instanceof(o.WriteStream||s))&&a(e.close)},c=function(e,t,r,o){o=n(o);var c=!1;e.on("close",function(){c=!0}),i(e,{readable:t,writable:r},function(e){if(e)return o(e);c=!0,o()});var f=!1;return function(t){if(!c&&!f)return f=!0,u(e)?e.close(s):function(e){return e.setHeader&&a(e.abort)}(e)?e.abort():a(e.destroy)?e.destroy():void o(t||new Error("stream was destroyed"))}},f=function(e){e()},l=function(e,t){return e.pipe(t)};e.exports=function(){var e,t=Array.prototype.slice.call(arguments),r=a(t[t.length-1]||s)&&t.pop()||s;if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new Error("pump requires two streams per minimum");var n=t.map(function(i,o){var s=o0,function(t){e||(e=t),t&&n.forEach(f),s||(n.forEach(f),r(e))})});return t.reduce(l)}},function(e,t){},function(e,t,r){(function(t){var n=r(1540),i=r(10).EventEmitter,o=r(4),s=r(1541),a=r(207),u=r(1550);function c(e){i.call(this),this._tracks=[],this._fragmentSequence=1,this._file=e,this._decoder=null,this._findMoov(0)}function f(e,t){this._entries=e,this._countName=t||"count",this._index=0,this._offset=0,this.value=this._entries[0]}e.exports=c,o(c,i),c.prototype._findMoov=function(e){var t=this;t._decoder&&t._decoder.destroy(),t._decoder=s.decode();var r=t._file.createReadStream({start:e});r.pipe(t._decoder),t._decoder.once("box",function(n){"moov"===n.type?t._decoder.decode(function(e){r.destroy();try{t._processMoov(e)}catch(e){e.message="Cannot parse mp4 file: "+e.message,t.emit("error",e)}}):(r.destroy(),t._findMoov(e+n.length))})},f.prototype.inc=function(){this._offset++,this._offset>=this._entries[this._index][this._countName]&&(this._index++,this._offset=0),this.value=this._entries[this._index]},c.prototype._processMoov=function(e){var r=e.traks;this._tracks=[],this._hasVideo=!1,this._hasAudio=!1;for(var n=0;n=u.stsz.entries.length)break;if(g+=k,++d>=S.samplesPerChunk){d=0,g=0,y++;var I=u.stsc.entries[m+1];I&&y+1>=I.firstChunk&&m++}b+=E,v.inc(),_&&_.inc(),x&&w++}s.mdia.mdhd.duration=0,s.tkhd.duration=0;var T=S.sampleDescriptionId,B={type:"moov",mvhd:e.mvhd,traks:[{tkhd:s.tkhd,mdia:{mdhd:s.mdia.mdhd,hdlr:s.mdia.hdlr,elng:s.mdia.elng,minf:{vmhd:s.mdia.minf.vmhd,smhd:s.mdia.minf.smhd,dinf:s.mdia.minf.dinf,stbl:{stsd:u.stsd,stts:{version:0,flags:0,entries:[]},ctts:{version:0,flags:0,entries:[]},stsc:{version:0,flags:0,entries:[]},stsz:{version:0,flags:0,entries:[]},stco:{version:0,flags:0,entries:[]},stss:{version:0,flags:0,entries:[]}}}}}],mvex:{mehd:{fragmentDuration:e.mvhd.duration},trexs:[{trackId:s.tkhd.trackId,defaultSampleDescriptionIndex:T,defaultSampleDuration:0,defaultSampleSize:0,defaultSampleFlags:0}]}};this._tracks.push({trackId:s.tkhd.trackId,timeScale:s.mdia.mdhd.timeScale,samples:h,currSample:null,currTime:null,moov:B,mime:o})}if(0!==this._tracks.length){e.mvhd.duration=0,this._ftyp={type:"ftyp",brand:"iso5",brandVersion:0,compatibleBrands:["iso5"]};var C=a.encode(this._ftyp),P=this._tracks.map(function(e){var r=a.encode(e.moov);return{mime:e.mime,init:t.concat([C,r])}});this.emit("ready",P)}else this.emit("error",new Error("no playable tracks"))},c.prototype.seek=function(e){var t=this;if(!t._tracks)throw new Error("Not ready yet; wait for 'ready' event");t._fileStream&&(t._fileStream.destroy(),t._fileStream=null);var r=-1;if(t._tracks.map(function(n,i){n.outStream&&n.outStream.destroy(),n.inStream&&(n.inStream.destroy(),n.inStream=null);var o=n.outStream=s.encode(),a=t._generateFragment(i,e);if(!a)return o.finalize();(-1===r||a.ranges[0].start=0){var n=t._fileStream=t._file.createReadStream({start:r});t._tracks.forEach(function(e){e.inStream=new u(r,{highWaterMark:1e7}),n.pipe(e.inStream)})}return t._tracks.map(function(e){return e.outStream})},c.prototype._findSampleBefore=function(e,t){var r=this._tracks[e],i=Math.floor(r.timeScale*t),o=n(r.samples,i,function(e,t){return e.dts+e.presentationOffset-t});for(-1===o?o=0:o<0&&(o=-o-2);!r.samples[o].sync;)o--;return o};c.prototype._generateFragment=function(e,t){var r,n=this._tracks[e];if((r=void 0!==t?this._findSampleBefore(e,t):n.currSample)>=n.samples.length)return null;for(var i=n.samples[r].dts,o=0,s=[],a=r;a=1*n.timeScale)break;o+=u.size;var c=s.length-1;c<0||s[c].end!==u.offset?s.push({start:u.offset,end:u.offset+u.size}):s[c].end+=u.size}return n.currSample=a,{moof:this._generateMoof(e,r,a),ranges:s,length:o}},c.prototype._generateMoof=function(e,t,r){for(var n=this._tracks[e],i=[],o=t;o=e.length)throw new RangeError("invalid lower bound");if(void 0===i)i=e.length-1;else if((i|=0)=e.length)throw new RangeError("invalid upper bound");for(;n<=i;)if((s=+r(e[o=n+(i-n>>1)],t,o,e))<0)n=o+1;else{if(!(s>0))return o;i=o-1}return~n}},function(e,t,r){t.decode=r(1542),t.encode=r(1549)},function(e,t,r){(function(t){var n=r(22),i=r(4),o=r(1543),s=r(207),a=r(208),u=a(0);function c(){if(!(this instanceof c))return new c;n.Writable.call(this),this.destroyed=!1,this._pending=0,this._missing=0,this._buf=null,this._str=null,this._cb=null,this._ondrain=null,this._writeBuffer=null,this._writeCb=null,this._ondrain=null,this._kick()}function f(e){this._parent=e,this.destroyed=!1,n.PassThrough.call(this)}e.exports=c,i(c,n.Writable),c.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e),this.emit("close"))},c.prototype._write=function(e,t,r){if(!this.destroyed){for(var n=!this._str||!this._str._writableState.needDrain;e.length&&!this.destroyed;){if(!this._missing)return this._writeBuffer=e,void(this._writeCb=r);var i=e.lengthe.length)throw new RangeError("Out of range index");return r>>>=0,(n=void 0===n?e.length:n>>>0)>r&&e.fill(t,r,n),e}e.exports=function(e,i,o,s,a){if(r)return e.fill(i,o,s,a);if("number"==typeof i)return n(e,i,o,s);if("string"==typeof i){if("string"==typeof o?(a=o,o=0,s=e.length):"string"==typeof s&&(a=s,s=e.length),void 0!==a&&"string"!=typeof a)throw new TypeError("encoding must be a string");if("latin1"===a&&(a="binary"),"string"==typeof a&&!t.isEncoding(a))throw new TypeError("Unknown encoding: "+a);if(""===i)return n(e,0,o,s);if(function(e){return 1===e.length&&e.charCodeAt(0)<256}(i))return n(e,i.charCodeAt(0),o,s);i=new t(i,a)}return t.isBuffer(i)?function(e,t,r,n){if(r<0||n>e.length)throw new RangeError("Out of range index");if(n<=r)return e;r>>>=0,n=void 0===n?e.length:n>>>0;for(var i=r,o=t.length;i<=n-o;)t.copy(e,i),i+=o;return i!==n&&t.copy(e,i,0,n-i),e}(e,i,o,s):n(e,0,o,s)}}).call(this,r(0).Buffer)},function(e,t,r){(function(t){e.exports=function(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative');return t.allocUnsafe?t.allocUnsafe(e):new t(e)}}).call(this,r(0).Buffer)},function(e,t,r){var n=r(207),i=r(1548),o=r(208),s=r(328),a=20828448e5;function u(e,t,r){for(var n=t;n=8;){var u=n.decode(e,a,i);s.children.push(u),s[u.type]=u,a+=u.length}return s},t.VisualSampleEntry.encodingLength=function(e){var t=78;return(e.children||[]).forEach(function(e){t+=n.encodingLength(e)}),t},t.avcC={},t.avcC.encode=function(e,r,n){r=r?r.slice(n):o(e.buffer.length),e.buffer.copy(r),t.avcC.encode.bytes=e.buffer.length},t.avcC.decode=function(e,t,r){return{mimeCodec:(e=e.slice(t,r)).toString("hex",1,4),buffer:s(e)}},t.avcC.encodingLength=function(e){return e.buffer.length},t.mp4a=t.AudioSampleEntry={},t.AudioSampleEntry.encode=function(e,r,i){u(r=r?r.slice(i):o(t.AudioSampleEntry.encodingLength(e)),0,6),r.writeUInt16BE(e.dataReferenceIndex||0,6),u(r,8,16),r.writeUInt16BE(e.channelCount||2,16),r.writeUInt16BE(e.sampleSize||16,18),u(r,20,24),r.writeUInt32BE(e.sampleRate||0,24);var s=28;(e.children||[]).forEach(function(e){n.encode(e,r,s),s+=n.encode.bytes}),t.AudioSampleEntry.encode.bytes=s},t.AudioSampleEntry.decode=function(e,t,r){for(var i=r-t,o={dataReferenceIndex:(e=e.slice(t,r)).readUInt16BE(6),channelCount:e.readUInt16BE(16),sampleSize:e.readUInt16BE(18),sampleRate:e.readUInt32BE(24),children:[]},s=28;i-s>=8;){var a=n.decode(e,s,i);o.children.push(a),o[a.type]=a,s+=a.length}return o},t.AudioSampleEntry.encodingLength=function(e){var t=28;return(e.children||[]).forEach(function(e){t+=n.encodingLength(e)}),t},t.esds={},t.esds.encode=function(e,r,n){r=r?r.slice(n):o(e.buffer.length),e.buffer.copy(r,0),t.esds.encode.bytes=e.buffer.length},t.esds.decode=function(e,t,r){e=e.slice(t,r);var n=i.Descriptor.decode(e,0,e.length),o=("ESDescriptor"===n.tagName?n:{}).DecoderConfigDescriptor||{},a=o.oti||0,u=o.DecoderSpecificInfo,c=u?(248&u.buffer.readUInt8(0))>>3:0,f=null;return a&&(f=a.toString(16),c&&(f+="."+c)),{mimeCodec:f,buffer:s(e.slice(0))}},t.esds.encodingLength=function(e){return e.buffer.length},t.stsz={},t.stsz.encode=function(e,r,n){var i=e.entries||[];(r=r?r.slice(n):o(t.stsz.encodingLength(e))).writeUInt32BE(0,0),r.writeUInt32BE(i.length,4);for(var s=0;s=e.length)return this._position+=e.length,r(null);if(a>e.length){this._position+=e.length,i=0===s?e:e.slice(s),n=o.stream.write(i)&&n;break}this._position+=a,i=0===s&&a===e.length?e:e.slice(s,a),n=o.stream.write(i)&&n,o.last&&o.stream.end(),e=e.slice(a),this._queue.shift()}n?r(null):o.stream.once("drain",r.bind(null,null))},o.prototype.slice=function(e){var t=this;if(t.destroyed)return null;e instanceof Array||(e=[e]);var r=new i.PassThrough;return e.forEach(function(n,i){t._queue.push({start:n.start,end:n.end,stream:r,last:i===e.length-1})}),t._buffer&&t._write(t._buffer,null,t._cb),r},o.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e))}},function(e,t,r){(function(t){var n=r(30);e.exports=function(e,r,i){i=n(i);var o=t.alloc(r),s=0;e.on("data",function(e){e.copy(o,s),s+=e.length}).on("end",function(){i(null,o)}).on("error",i)}}).call(this,r(0).Buffer)},function(e,t,r){var n=r(619),i=r(1)("webtorrent:peer"),o=r(620),s=r(1553);function a(e,t){this.id=e,this.type=t,i("new Peer %s",e),this.addr=null,this.conn=null,this.swarm=null,this.wire=null,this.connected=!1,this.destroyed=!1,this.timeout=null,this.retries=0,this.sentHandshake=!1}function u(){}t.createWebRTCPeer=function(e,t){var r=new a(e.id,"webrtc");return r.conn=e,r.swarm=t,r.conn.connected?r.onConnect():(r.conn.once("connect",function(){r.onConnect()}),r.conn.once("error",function(e){r.destroy(e)}),r.startConnectTimeout()),r},t.createTCPIncomingPeer=function(e){var t=e.remoteAddress+":"+e.remotePort,r=new a(t,"tcpIncoming");return r.conn=e,r.addr=t,r.onConnect(),r},t.createTCPOutgoingPeer=function(e,t){var r=new a(e,"tcpOutgoing");return r.addr=e,r.swarm=t,r},t.createWebSeedPeer=function(e,t){var r=new a(e,"webSeed");return r.swarm=t,r.conn=new s(e,t),r.onConnect(),r},a.prototype.onConnect=function(){var e=this;if(!e.destroyed){e.connected=!0,i("Peer %s connected",e.id),clearTimeout(e.connectTimeout);var t=e.conn;t.once("end",function(){e.destroy()}),t.once("close",function(){e.destroy()}),t.once("finish",function(){e.destroy()}),t.once("error",function(t){e.destroy(t)});var r=e.wire=new o;r.type=e.type,r.once("end",function(){e.destroy()}),r.once("close",function(){e.destroy()}),r.once("finish",function(){e.destroy()}),r.once("error",function(t){e.destroy(t)}),r.once("handshake",function(t,r){e.onHandshake(t,r)}),e.startHandshakeTimeout(),t.pipe(r).pipe(t),e.swarm&&!e.sentHandshake&&e.handshake()}},a.prototype.onHandshake=function(e,t){if(this.swarm&&!this.destroyed){if(this.swarm.destroyed)return this.destroy(new Error("swarm already destroyed"));if(e!==this.swarm.infoHash)return this.destroy(new Error("unexpected handshake info hash for this swarm"));if(t===this.swarm.peerId)return this.destroy(new Error("refusing to connect to ourselves"));i("Peer %s got handshake %s",this.id,e),clearTimeout(this.handshakeTimeout),this.retries=0;var r=this.addr;!r&&this.conn.remoteAddress&&this.conn.remotePort&&(r=this.conn.remoteAddress+":"+this.conn.remotePort),this.swarm._onWire(this.wire,r),this.swarm&&!this.swarm.destroyed&&(this.sentHandshake||this.handshake())}},a.prototype.handshake=function(){var e={dht:!this.swarm.private&&!!this.swarm.client.dht};this.wire.handshake(this.swarm.infoHash,this.swarm.client.peerId,e),this.sentHandshake=!0},a.prototype.startConnectTimeout=function(){var e=this;clearTimeout(e.connectTimeout),e.connectTimeout=setTimeout(function(){e.destroy(new Error("connect timeout"))},"webrtc"===e.type?25e3:5e3),e.connectTimeout.unref&&e.connectTimeout.unref()},a.prototype.startHandshakeTimeout=function(){var e=this;clearTimeout(e.handshakeTimeout),e.handshakeTimeout=setTimeout(function(){e.destroy(new Error("handshake timeout"))},25e3),e.handshakeTimeout.unref&&e.handshakeTimeout.unref()},a.prototype.destroy=function(e){if(!this.destroyed){this.destroyed=!0,this.connected=!1,i("destroy %s (error: %s)",this.id,e&&(e.message||e)),clearTimeout(this.connectTimeout),clearTimeout(this.handshakeTimeout);var t=this.swarm,r=this.conn,o=this.wire;this.swarm=null,this.conn=null,this.wire=null,t&&o&&n(t.wires,t.wires.indexOf(o)),r&&(r.on("error",u),r.destroy()),o&&o.destroy(),t&&t.removePeer(this.id)}}},function(e,t,r){e.exports=l;var n=r(206),i=r(2).Buffer,o=r(1)("webtorrent:webconn"),s=r(615),a=r(4),u=r(148),c=r(620),f=r(329).version;function l(e,t){c.call(this),this.url=e,this.webPeerId=u.sync(e),this._torrent=t,this._init()}a(l,c),l.prototype._init=function(){var e=this;e.setKeepAlive(!0),e.once("handshake",function(t,r){if(!e.destroyed){e.handshake(t,e.webPeerId);for(var i=e._torrent.pieces.length,o=new n(i),s=0;s<=i;s++)o.set(s,!0);e.bitfield(o)}}),e.once("interested",function(){o("interested"),e.unchoke()}),e.on("uninterested",function(){o("uninterested")}),e.on("choke",function(){o("choke")}),e.on("unchoke",function(){o("unchoke")}),e.on("bitfield",function(){o("bitfield")}),e.on("request",function(t,r,n,i){o("request pieceIndex=%d offset=%d length=%d",t,r,n),e.httpRequest(t,r,n,i)})},l.prototype.httpRequest=function(e,t,r,n){var a,u=this,c=e*u._torrent.pieceLength+t,l=c+r-1,h=u._torrent.files;if(h.length<=1)a=[{url:u.url,start:c,end:l}];else{var p=h.filter(function(e){return e.offset<=l&&e.offset+e.length>c});if(p.length<1)return n(new Error("Could not find file corresponnding to web seed range request"));a=p.map(function(e){var t=e.offset+e.length-1;return{url:u.url+("/"===u.url[u.url.length-1]?"":"/")+e.path,fileOffsetInRange:Math.max(e.offset-c,0),start:Math.max(c-e.offset,0),end:Math.min(t,l-e.offset)}})}var d,y=0,g=!1;a.length>1&&(d=i.alloc(r)),a.forEach(function(i){var u=i.url,c=i.start,l=i.end;o("Requesting url=%s pieceIndex=%d offset=%d length=%d start=%d end=%d",u,e,t,r,c,l);var h={url:u,method:"GET",headers:{"user-agent":"WebTorrent/"+f+" (https://webtorrent.io)",range:"bytes="+c+"-"+l}};function p(e,t){if(e.statusCode<200||e.statusCode>=300)return g=!0,n(new Error("Unexpected HTTP status code "+e.statusCode));o("Got data of length %d",t.length),1===a.length?n(null,t):(t.copy(d,i.fileOffsetInRange),++y===a.length&&n(null,d))}s.concat(h,function(e,t,r){if(!g)return e?"undefined"==typeof window||u.startsWith(window.location.origin+"/")?(g=!0,n(e)):s.head(u,function(t,r){if(!g){if(t)return g=!0,n(t);if(r.statusCode<200||r.statusCode>=300)return g=!0,n(new Error("Unexpected HTTP status code "+r.statusCode));if(r.url===u)return g=!0,n(e);h.url=r.url,s.concat(h,function(e,t,r){if(!g)return e?(g=!0,n(e)):void p(t,r)})}}):void p(t,r)})})},l.prototype.destroy=function(){c.prototype.destroy.call(this),this._torrent=null}},function(e,t){function r(e){var t=this;t._torrent=e,t._numPieces=e.pieces.length,t._pieces=[],t._onWire=function(e){t.recalculate(),t._initWire(e)},t._onWireHave=function(e){t._pieces[e]+=1},t._onWireBitfield=function(){t.recalculate()},t._torrent.wires.forEach(function(e){t._initWire(e)}),t._torrent.on("wire",t._onWire),t.recalculate()}function n(){return!0}e.exports=r,r.prototype.getRarestPiece=function(e){e||(e=n);for(var t=[],r=1/0,i=0;i0?t[Math.random()*t.length|0]:-1},r.prototype.destroy=function(){var e=this;e._torrent.removeListener("wire",e._onWire),e._torrent.wires.forEach(function(t){e._cleanupWireEvents(t)}),e._torrent=null,e._pieces=null,e._onWire=null,e._onWireHave=null,e._onWireBitfield=null},r.prototype._initWire=function(e){var t=this;e._onClose=function(){t._cleanupWireEvents(e);for(var r=0;re.includes("ipfs/zb2")))throw new o.TransportError("GUN retrieving legacy data at: "+e.href);return s}async p_rawlist(e,{verbose:t=!1}={}){try{let r=this.connection(e,t),n=await this._p_once(r),i=n?Object.keys(n).filter(e=>"_"!==e).sort().map(e=>n[e]):[];return t&&console.log("GUN.p_rawlist found",...u.consolearr(i)),i}catch(e){throw console.log("TransportGUN.p_rawlist failed",e.message),e}}listmonitor(e,t,{verbose:r=!1,current:n=!1}={}){let i=this.connection(e,r);n?i.map().on((e,r)=>t("set",r,JSON.parse(e))):i.once(e=>{this.monitored=e?Object.keys(e):[],i.map().on((e,r)=>{this.monitored.includes(r)||"_"===r||(this.monitored.push(r),t(JSON.parse(e)))})})}async p_rawadd(e,t,{verbose:r=!1}={}){console.assert(e&&t.urls.length&&t.signature&&t.signedby.length,"TransportGUN.p_rawadd args",e,t),r&&console.log("TransportGUN.p_rawadd","string"==typeof e?e:e.href,t),this.connection(e,r).set(JSON.stringify(t.preflight(Object.assign({},t))))}async p_newlisturls(e,{verbose:t=!1}={}){let r=await this._p_newgun(e,{verbose:t});return[r,r]}async _p_newgun(e,{verbose:t=!1}={}){return e.hasOwnProperty("keypair")&&(e=e.keypair.signingexport()),`gun:/gun/${encodeURIComponent(e)}`}async p_newdatabase(e,{verbose:t=!1}={}){let r=await this._p_newgun(e,{verbose:t});return{publicurl:r,privateurl:r}}async p_newtable(e,t,{verbose:r=!1}={}){if(!e)throw new o.CodingError("p_newtable currently requires a pubkey");let n=await this.p_newdatabase(e,{verbose:r});return{privateurl:`${n.privateurl}/${t}`,publicurl:`${n.publicurl}/${t}`}}async p_set(e,t,r,{verbose:n=!1}={}){let i=this.connection(e,n);"string"==typeof t?i.path(t).put(JSON.stringify(r)):(console.assert(!Array.isArray(t),"TransportGUN - shouldnt be passsing an array as the keyvalues"),i.put(Object.keys(t).reduce(function(e,r){return e[r]=JSON.stringify(t[r]),e},{})))}async p_get(e,t,{verbose:r=!1}={}){let n=this.connection(e,r);if(Array.isArray(t))throw new o.ToBeImplementedError("p_get(url, [keys]) isn't supported - because of ambiguity better to explicitly loop on set of keys or use getall and filter");{let e=await this._p_once(n.get(t));return"string"==typeof e?JSON.parse(e):e}}async p_delete(e,t,{verbose:r=!1}={}){let n=this.connection(e,r);"string"==typeof t?n.path(t).put(null):t.map(e=>n.path(e).put(null))}_p_once(e){return new Promise((t,r)=>e.once(t))}async p_keys(e,{verbose:t=!1}={}){let r=await this._p_once(this.connection(e,t));return Object.keys(r).filter(e=>"_"!==e&&null!==r[e])}async p_getall(e,{verbose:t=!1}={}){let r=await this._p_once(this.connection(e,t));return Object.keys(r).filter(e=>"_"!==e&&null!==r[e]).reduce(function(e,t){return e[t]=JSON.parse(r[t]),e},{})}async monitor(e,t,{verbose:r=!1,current:n=!1}={}){let i=this.connection(e,r);n?i.map().on((e,r)=>t("set",r,JSON.parse(e))):i.once(e=>{this.monitored=Object.assign({},e),i.map().on((e,r)=>{e!==this.monitored[r]&&"_"!==r&&(this.monitored[r]=e,t("set",r,JSON.parse(e)))})})}static async p_test(e){e&&console.log("TransportGUN.test");try{let t=this.setup0({},e);await t.p_setup1(e),await t.p_setup2(e),t.p_test_kvt("gun:/gun/NACL",{verbose:e})}catch(e){throw console.log("Exception thrown in TransportGUN.test:",e.message),e}}static async demo_bugs(){let e=new i;e.get("foo").get("bar").put("baz"),console.log("Expect {bar: 'baz'} but get {_:..., bar: 'baz'}"),e.get("foo").once(e=>console.log(e)),e.get("zip").get("bar").set("alice"),console.log("Expect {12345: 'alice'} but get {_:..., 12345: 'alice'}"),e.get("foo").once(e=>console.log(e))}}a._transportclasses.GUN=f,e.exports=f}).call(this,r(6))},function(e,t,r){("undefined"!=typeof window?window.Gun:r(621)).chain.path=function(e,t){var r,n=this;if("string"==typeof e){if(1===(r=e.split(t||".")).length)return this.get(e);e=r}if(e instanceof Array){if(e.length>1){n=this;for(var i=0,o=e.length;i