edge-currency-plugins 3.0.0 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/android/src/main/assets/edge-currency-plugins/edge-currency-plugins.js +6 -6
- package/lib/common/utxobased/db/Models/ProcessorTransaction.js +1 -0
- package/lib/common/utxobased/db/types.js +4 -0
- package/lib/common/utxobased/engine/UtxoEngine.js +5 -1
- package/lib/common/utxobased/engine/UtxoEngineState.js +2 -1
- package/lib/common/utxobased/network/blockbookApi.js +8 -2
- package/lib/react-native.js +1 -1
- package/lib/src/common/utxobased/db/types.d.ts +7 -3
- package/lib/src/common/utxobased/keymanager/utxopicker/types.d.ts +1 -1
- package/lib/src/common/utxobased/network/blockbookApi.d.ts +1 -1
- package/lib/src/react-native.d.ts +1 -1
- package/package.json +1 -1
|
@@ -36,7 +36,7 @@ Please explicitly pass a 2048 word array explicitly.`;function A(e,r,n,i,f){retu
|
|
|
36
36
|
*/var S=T(7526),y=T(251),p=T(4634);x.Buffer=l,x.SlowBuffer=U,x.INSPECT_MAX_BYTES=50,l.TYPED_ARRAY_SUPPORT=T.g.TYPED_ARRAY_SUPPORT!==void 0?T.g.TYPED_ARRAY_SUPPORT:I(),x.kMaxLength=o();function I(){try{var ce=new Uint8Array(1);return ce.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},ce.foo()===42&&typeof ce.subarray=="function"&&ce.subarray(1,1).byteLength===0}catch{return!1}}function o(){return l.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function m(ce,te){if(o()<te)throw new RangeError("Invalid typed array length");return l.TYPED_ARRAY_SUPPORT?(ce=new Uint8Array(te),ce.__proto__=l.prototype):(ce===null&&(ce=new l(te)),ce.length=te),ce}function l(ce,te,le){if(!l.TYPED_ARRAY_SUPPORT&&!(this instanceof l))return new l(ce,te,le);if(typeof ce=="number"){if(typeof te=="string")throw new Error("If encoding is specified then the first argument must be a string");return d(this,ce)}return g(this,ce,te,le)}l.poolSize=8192,l._augment=function(ce){return ce.__proto__=l.prototype,ce};function g(ce,te,le,ge){if(typeof te=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&te instanceof ArrayBuffer?b(ce,te,le,ge):typeof te=="string"?A(ce,te,le):k(ce,te)}l.from=function(ce,te,le){return g(null,ce,te,le)},l.TYPED_ARRAY_SUPPORT&&(l.prototype.__proto__=Uint8Array.prototype,l.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&l[Symbol.species]===l&&Object.defineProperty(l,Symbol.species,{value:null,configurable:!0}));function M(ce){if(typeof ce!="number")throw new TypeError('"size" argument must be a number');if(ce<0)throw new RangeError('"size" argument must not be negative')}function E(ce,te,le,ge){return M(te),te<=0?m(ce,te):le!==void 0?typeof ge=="string"?m(ce,te).fill(le,ge):m(ce,te).fill(le):m(ce,te)}l.alloc=function(ce,te,le){return E(null,ce,te,le)};function d(ce,te){if(M(te),ce=m(ce,te<0?0:B(te)|0),!l.TYPED_ARRAY_SUPPORT)for(var le=0;le<te;++le)ce[le]=0;return ce}l.allocUnsafe=function(ce){return d(null,ce)},l.allocUnsafeSlow=function(ce){return d(null,ce)};function A(ce,te,le){if((typeof le!="string"||le==="")&&(le="utf8"),!l.isEncoding(le))throw new TypeError('"encoding" must be a valid string encoding');var ge=C(te,le)|0;ce=m(ce,ge);var Pe=ce.write(te,le);return Pe!==ge&&(ce=ce.slice(0,Pe)),ce}function v(ce,te){var le=te.length<0?0:B(te.length)|0;ce=m(ce,le);for(var ge=0;ge<le;ge+=1)ce[ge]=te[ge]&255;return ce}function b(ce,te,le,ge){if(te.byteLength,le<0||te.byteLength<le)throw new RangeError("'offset' is out of bounds");if(te.byteLength<le+(ge||0))throw new RangeError("'length' is out of bounds");return le===void 0&&ge===void 0?te=new Uint8Array(te):ge===void 0?te=new Uint8Array(te,le):te=new Uint8Array(te,le,ge),l.TYPED_ARRAY_SUPPORT?(ce=te,ce.__proto__=l.prototype):ce=v(ce,te),ce}function k(ce,te){if(l.isBuffer(te)){var le=B(te.length)|0;return ce=m(ce,le),ce.length===0||te.copy(ce,0,0,le),ce}if(te){if(typeof ArrayBuffer<"u"&&te.buffer instanceof ArrayBuffer||"length"in te)return typeof te.length!="number"||Ge(te.length)?m(ce,0):v(ce,te);if(te.type==="Buffer"&&p(te.data))return v(ce,te.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function B(ce){if(ce>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return ce|0}function U(ce){return+ce!=ce&&(ce=0),l.alloc(+ce)}l.isBuffer=function(te){return!!(te!=null&&te._isBuffer)},l.compare=function(te,le){if(!l.isBuffer(te)||!l.isBuffer(le))throw new TypeError("Arguments must be Buffers");if(te===le)return 0;for(var ge=te.length,Pe=le.length,lt=0,Le=Math.min(ge,Pe);lt<Le;++lt)if(te[lt]!==le[lt]){ge=te[lt],Pe=le[lt];break}return ge<Pe?-1:Pe<ge?1:0},l.isEncoding=function(te){switch(String(te).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},l.concat=function(te,le){if(!p(te))throw new TypeError('"list" argument must be an Array of Buffers');if(te.length===0)return l.alloc(0);var ge;if(le===void 0)for(le=0,ge=0;ge<te.length;++ge)le+=te[ge].length;var Pe=l.allocUnsafe(le),lt=0;for(ge=0;ge<te.length;++ge){var Le=te[ge];if(!l.isBuffer(Le))throw new TypeError('"list" argument must be an Array of Buffers');Le.copy(Pe,lt),lt+=Le.length}return Pe};function C(ce,te){if(l.isBuffer(ce))return ce.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(ce)||ce instanceof ArrayBuffer))return ce.byteLength;typeof ce!="string"&&(ce=""+ce);var le=ce.length;if(le===0)return 0;for(var ge=!1;;)switch(te){case"ascii":case"latin1":case"binary":return le;case"utf8":case"utf-8":case void 0:return ue(ce).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return le*2;case"hex":return le>>>1;case"base64":return J(ce).length;default:if(ge)return ue(ce).length;te=(""+te).toLowerCase(),ge=!0}}l.byteLength=C;function L(ce,te,le){var ge=!1;if((te===void 0||te<0)&&(te=0),te>this.length||((le===void 0||le>this.length)&&(le=this.length),le<=0)||(le>>>=0,te>>>=0,le<=te))return"";for(ce||(ce="utf8");;)switch(ce){case"hex":return s(this,te,le);case"utf8":case"utf-8":return n(this,te,le);case"ascii":return c(this,te,le);case"latin1":case"binary":return h(this,te,le);case"base64":return r(this,te,le);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t(this,te,le);default:if(ge)throw new TypeError("Unknown encoding: "+ce);ce=(ce+"").toLowerCase(),ge=!0}}l.prototype._isBuffer=!0;function N(ce,te,le){var ge=ce[te];ce[te]=ce[le],ce[le]=ge}l.prototype.swap16=function(){var te=this.length;if(te%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var le=0;le<te;le+=2)N(this,le,le+1);return this},l.prototype.swap32=function(){var te=this.length;if(te%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var le=0;le<te;le+=4)N(this,le,le+3),N(this,le+1,le+2);return this},l.prototype.swap64=function(){var te=this.length;if(te%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var le=0;le<te;le+=8)N(this,le,le+7),N(this,le+1,le+6),N(this,le+2,le+5),N(this,le+3,le+4);return this},l.prototype.toString=function(){var te=this.length|0;return te===0?"":arguments.length===0?n(this,0,te):L.apply(this,arguments)},l.prototype.equals=function(te){if(!l.isBuffer(te))throw new TypeError("Argument must be a Buffer");return this===te?!0:l.compare(this,te)===0},l.prototype.inspect=function(){var te="",le=x.INSPECT_MAX_BYTES;return this.length>0&&(te=this.toString("hex",0,le).match(/.{2}/g).join(" "),this.length>le&&(te+=" ... ")),"<Buffer "+te+">"},l.prototype.compare=function(te,le,ge,Pe,lt){if(!l.isBuffer(te))throw new TypeError("Argument must be a Buffer");if(le===void 0&&(le=0),ge===void 0&&(ge=te?te.length:0),Pe===void 0&&(Pe=0),lt===void 0&&(lt=this.length),le<0||ge>te.length||Pe<0||lt>this.length)throw new RangeError("out of range index");if(Pe>=lt&&le>=ge)return 0;if(Pe>=lt)return-1;if(le>=ge)return 1;if(le>>>=0,ge>>>=0,Pe>>>=0,lt>>>=0,this===te)return 0;for(var Le=lt-Pe,ze=ge-le,kt=Math.min(Le,ze),ae=this.slice(Pe,lt),he=te.slice(le,ge),je=0;je<kt;++je)if(ae[je]!==he[je]){Le=ae[je],ze=he[je];break}return Le<ze?-1:ze<Le?1:0};function j(ce,te,le,ge,Pe){if(ce.length===0)return-1;if(typeof le=="string"?(ge=le,le=0):le>2147483647?le=2147483647:le<-2147483648&&(le=-2147483648),le=+le,isNaN(le)&&(le=Pe?0:ce.length-1),le<0&&(le=ce.length+le),le>=ce.length){if(Pe)return-1;le=ce.length-1}else if(le<0)if(Pe)le=0;else return-1;if(typeof te=="string"&&(te=l.from(te,ge)),l.isBuffer(te))return te.length===0?-1:K(ce,te,le,ge,Pe);if(typeof te=="number")return te=te&255,l.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?Pe?Uint8Array.prototype.indexOf.call(ce,te,le):Uint8Array.prototype.lastIndexOf.call(ce,te,le):K(ce,[te],le,ge,Pe);throw new TypeError("val must be string, number or Buffer")}function K(ce,te,le,ge,Pe){var lt=1,Le=ce.length,ze=te.length;if(ge!==void 0&&(ge=String(ge).toLowerCase(),ge==="ucs2"||ge==="ucs-2"||ge==="utf16le"||ge==="utf-16le")){if(ce.length<2||te.length<2)return-1;lt=2,Le/=2,ze/=2,le/=2}function kt(Ce,ut){return lt===1?Ce[ut]:Ce.readUInt16BE(ut*lt)}var ae;if(Pe){var he=-1;for(ae=le;ae<Le;ae++)if(kt(ce,ae)===kt(te,he===-1?0:ae-he)){if(he===-1&&(he=ae),ae-he+1===ze)return he*lt}else he!==-1&&(ae-=ae-he),he=-1}else for(le+ze>Le&&(le=Le-ze),ae=le;ae>=0;ae--){for(var je=!0,Ie=0;Ie<ze;Ie++)if(kt(ce,ae+Ie)!==kt(te,Ie)){je=!1;break}if(je)return ae}return-1}l.prototype.includes=function(te,le,ge){return this.indexOf(te,le,ge)!==-1},l.prototype.indexOf=function(te,le,ge){return j(this,te,le,ge,!0)},l.prototype.lastIndexOf=function(te,le,ge){return j(this,te,le,ge,!1)};function $(ce,te,le,ge){le=Number(le)||0;var Pe=ce.length-le;ge?(ge=Number(ge),ge>Pe&&(ge=Pe)):ge=Pe;var lt=te.length;if(lt%2!==0)throw new TypeError("Invalid hex string");ge>lt/2&&(ge=lt/2);for(var Le=0;Le<ge;++Le){var ze=parseInt(te.substr(Le*2,2),16);if(isNaN(ze))return Le;ce[le+Le]=ze}return Le}function Q(ce,te,le,ge){return pe(ue(te,ce.length-le),ce,le,ge)}function Y(ce,te,le,ge){return pe(be(te),ce,le,ge)}function ee(ce,te,le,ge){return Y(ce,te,le,ge)}function u(ce,te,le,ge){return pe(J(te),ce,le,ge)}function e(ce,te,le,ge){return pe(ie(te,ce.length-le),ce,le,ge)}l.prototype.write=function(te,le,ge,Pe){if(le===void 0)Pe="utf8",ge=this.length,le=0;else if(ge===void 0&&typeof le=="string")Pe=le,ge=this.length,le=0;else if(isFinite(le))le=le|0,isFinite(ge)?(ge=ge|0,Pe===void 0&&(Pe="utf8")):(Pe=ge,ge=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var lt=this.length-le;if((ge===void 0||ge>lt)&&(ge=lt),te.length>0&&(ge<0||le<0)||le>this.length)throw new RangeError("Attempt to write outside buffer bounds");Pe||(Pe="utf8");for(var Le=!1;;)switch(Pe){case"hex":return $(this,te,le,ge);case"utf8":case"utf-8":return Q(this,te,le,ge);case"ascii":return Y(this,te,le,ge);case"latin1":case"binary":return ee(this,te,le,ge);case"base64":return u(this,te,le,ge);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e(this,te,le,ge);default:if(Le)throw new TypeError("Unknown encoding: "+Pe);Pe=(""+Pe).toLowerCase(),Le=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function r(ce,te,le){return te===0&&le===ce.length?S.fromByteArray(ce):S.fromByteArray(ce.slice(te,le))}function n(ce,te,le){le=Math.min(ce.length,le);for(var ge=[],Pe=te;Pe<le;){var lt=ce[Pe],Le=null,ze=lt>239?4:lt>223?3:lt>191?2:1;if(Pe+ze<=le){var kt,ae,he,je;switch(ze){case 1:lt<128&&(Le=lt);break;case 2:kt=ce[Pe+1],(kt&192)===128&&(je=(lt&31)<<6|kt&63,je>127&&(Le=je));break;case 3:kt=ce[Pe+1],ae=ce[Pe+2],(kt&192)===128&&(ae&192)===128&&(je=(lt&15)<<12|(kt&63)<<6|ae&63,je>2047&&(je<55296||je>57343)&&(Le=je));break;case 4:kt=ce[Pe+1],ae=ce[Pe+2],he=ce[Pe+3],(kt&192)===128&&(ae&192)===128&&(he&192)===128&&(je=(lt&15)<<18|(kt&63)<<12|(ae&63)<<6|he&63,je>65535&&je<1114112&&(Le=je))}}Le===null?(Le=65533,ze=1):Le>65535&&(Le-=65536,ge.push(Le>>>10&1023|55296),Le=56320|Le&1023),ge.push(Le),Pe+=ze}return f(ge)}var i=4096;function f(ce){var te=ce.length;if(te<=i)return String.fromCharCode.apply(String,ce);for(var le="",ge=0;ge<te;)le+=String.fromCharCode.apply(String,ce.slice(ge,ge+=i));return le}function c(ce,te,le){var ge="";le=Math.min(ce.length,le);for(var Pe=te;Pe<le;++Pe)ge+=String.fromCharCode(ce[Pe]&127);return ge}function h(ce,te,le){var ge="";le=Math.min(ce.length,le);for(var Pe=te;Pe<le;++Pe)ge+=String.fromCharCode(ce[Pe]);return ge}function s(ce,te,le){var ge=ce.length;(!te||te<0)&&(te=0),(!le||le<0||le>ge)&&(le=ge);for(var Pe="",lt=te;lt<le;++lt)Pe+=oe(ce[lt]);return Pe}function t(ce,te,le){for(var ge=ce.slice(te,le),Pe="",lt=0;lt<ge.length;lt+=2)Pe+=String.fromCharCode(ge[lt]+ge[lt+1]*256);return Pe}l.prototype.slice=function(te,le){var ge=this.length;te=~~te,le=le===void 0?ge:~~le,te<0?(te+=ge,te<0&&(te=0)):te>ge&&(te=ge),le<0?(le+=ge,le<0&&(le=0)):le>ge&&(le=ge),le<te&&(le=te);var Pe;if(l.TYPED_ARRAY_SUPPORT)Pe=this.subarray(te,le),Pe.__proto__=l.prototype;else{var lt=le-te;Pe=new l(lt,void 0);for(var Le=0;Le<lt;++Le)Pe[Le]=this[Le+te]}return Pe};function a(ce,te,le){if(ce%1!==0||ce<0)throw new RangeError("offset is not uint");if(ce+te>le)throw new RangeError("Trying to access beyond buffer length")}l.prototype.readUIntLE=function(te,le,ge){te=te|0,le=le|0,ge||a(te,le,this.length);for(var Pe=this[te],lt=1,Le=0;++Le<le&&(lt*=256);)Pe+=this[te+Le]*lt;return Pe},l.prototype.readUIntBE=function(te,le,ge){te=te|0,le=le|0,ge||a(te,le,this.length);for(var Pe=this[te+--le],lt=1;le>0&&(lt*=256);)Pe+=this[te+--le]*lt;return Pe},l.prototype.readUInt8=function(te,le){return le||a(te,1,this.length),this[te]},l.prototype.readUInt16LE=function(te,le){return le||a(te,2,this.length),this[te]|this[te+1]<<8},l.prototype.readUInt16BE=function(te,le){return le||a(te,2,this.length),this[te]<<8|this[te+1]},l.prototype.readUInt32LE=function(te,le){return le||a(te,4,this.length),(this[te]|this[te+1]<<8|this[te+2]<<16)+this[te+3]*16777216},l.prototype.readUInt32BE=function(te,le){return le||a(te,4,this.length),this[te]*16777216+(this[te+1]<<16|this[te+2]<<8|this[te+3])},l.prototype.readIntLE=function(te,le,ge){te=te|0,le=le|0,ge||a(te,le,this.length);for(var Pe=this[te],lt=1,Le=0;++Le<le&&(lt*=256);)Pe+=this[te+Le]*lt;return lt*=128,Pe>=lt&&(Pe-=Math.pow(2,8*le)),Pe},l.prototype.readIntBE=function(te,le,ge){te=te|0,le=le|0,ge||a(te,le,this.length);for(var Pe=le,lt=1,Le=this[te+--Pe];Pe>0&&(lt*=256);)Le+=this[te+--Pe]*lt;return lt*=128,Le>=lt&&(Le-=Math.pow(2,8*le)),Le},l.prototype.readInt8=function(te,le){return le||a(te,1,this.length),this[te]&128?(255-this[te]+1)*-1:this[te]},l.prototype.readInt16LE=function(te,le){le||a(te,2,this.length);var ge=this[te]|this[te+1]<<8;return ge&32768?ge|4294901760:ge},l.prototype.readInt16BE=function(te,le){le||a(te,2,this.length);var ge=this[te+1]|this[te]<<8;return ge&32768?ge|4294901760:ge},l.prototype.readInt32LE=function(te,le){return le||a(te,4,this.length),this[te]|this[te+1]<<8|this[te+2]<<16|this[te+3]<<24},l.prototype.readInt32BE=function(te,le){return le||a(te,4,this.length),this[te]<<24|this[te+1]<<16|this[te+2]<<8|this[te+3]},l.prototype.readFloatLE=function(te,le){return le||a(te,4,this.length),y.read(this,te,!0,23,4)},l.prototype.readFloatBE=function(te,le){return le||a(te,4,this.length),y.read(this,te,!1,23,4)},l.prototype.readDoubleLE=function(te,le){return le||a(te,8,this.length),y.read(this,te,!0,52,8)},l.prototype.readDoubleBE=function(te,le){return le||a(te,8,this.length),y.read(this,te,!1,52,8)};function w(ce,te,le,ge,Pe,lt){if(!l.isBuffer(ce))throw new TypeError('"buffer" argument must be a Buffer instance');if(te>Pe||te<lt)throw new RangeError('"value" argument is out of bounds');if(le+ge>ce.length)throw new RangeError("Index out of range")}l.prototype.writeUIntLE=function(te,le,ge,Pe){if(te=+te,le=le|0,ge=ge|0,!Pe){var lt=Math.pow(2,8*ge)-1;w(this,te,le,ge,lt,0)}var Le=1,ze=0;for(this[le]=te&255;++ze<ge&&(Le*=256);)this[le+ze]=te/Le&255;return le+ge},l.prototype.writeUIntBE=function(te,le,ge,Pe){if(te=+te,le=le|0,ge=ge|0,!Pe){var lt=Math.pow(2,8*ge)-1;w(this,te,le,ge,lt,0)}var Le=ge-1,ze=1;for(this[le+Le]=te&255;--Le>=0&&(ze*=256);)this[le+Le]=te/ze&255;return le+ge},l.prototype.writeUInt8=function(te,le,ge){return te=+te,le=le|0,ge||w(this,te,le,1,255,0),l.TYPED_ARRAY_SUPPORT||(te=Math.floor(te)),this[le]=te&255,le+1};function D(ce,te,le,ge){te<0&&(te=65535+te+1);for(var Pe=0,lt=Math.min(ce.length-le,2);Pe<lt;++Pe)ce[le+Pe]=(te&255<<8*(ge?Pe:1-Pe))>>>(ge?Pe:1-Pe)*8}l.prototype.writeUInt16LE=function(te,le,ge){return te=+te,le=le|0,ge||w(this,te,le,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[le]=te&255,this[le+1]=te>>>8):D(this,te,le,!0),le+2},l.prototype.writeUInt16BE=function(te,le,ge){return te=+te,le=le|0,ge||w(this,te,le,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[le]=te>>>8,this[le+1]=te&255):D(this,te,le,!1),le+2};function Z(ce,te,le,ge){te<0&&(te=4294967295+te+1);for(var Pe=0,lt=Math.min(ce.length-le,4);Pe<lt;++Pe)ce[le+Pe]=te>>>(ge?Pe:3-Pe)*8&255}l.prototype.writeUInt32LE=function(te,le,ge){return te=+te,le=le|0,ge||w(this,te,le,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[le+3]=te>>>24,this[le+2]=te>>>16,this[le+1]=te>>>8,this[le]=te&255):Z(this,te,le,!0),le+4},l.prototype.writeUInt32BE=function(te,le,ge){return te=+te,le=le|0,ge||w(this,te,le,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[le]=te>>>24,this[le+1]=te>>>16,this[le+2]=te>>>8,this[le+3]=te&255):Z(this,te,le,!1),le+4},l.prototype.writeIntLE=function(te,le,ge,Pe){if(te=+te,le=le|0,!Pe){var lt=Math.pow(2,8*ge-1);w(this,te,le,ge,lt-1,-lt)}var Le=0,ze=1,kt=0;for(this[le]=te&255;++Le<ge&&(ze*=256);)te<0&&kt===0&&this[le+Le-1]!==0&&(kt=1),this[le+Le]=(te/ze>>0)-kt&255;return le+ge},l.prototype.writeIntBE=function(te,le,ge,Pe){if(te=+te,le=le|0,!Pe){var lt=Math.pow(2,8*ge-1);w(this,te,le,ge,lt-1,-lt)}var Le=ge-1,ze=1,kt=0;for(this[le+Le]=te&255;--Le>=0&&(ze*=256);)te<0&&kt===0&&this[le+Le+1]!==0&&(kt=1),this[le+Le]=(te/ze>>0)-kt&255;return le+ge},l.prototype.writeInt8=function(te,le,ge){return te=+te,le=le|0,ge||w(this,te,le,1,127,-128),l.TYPED_ARRAY_SUPPORT||(te=Math.floor(te)),te<0&&(te=255+te+1),this[le]=te&255,le+1},l.prototype.writeInt16LE=function(te,le,ge){return te=+te,le=le|0,ge||w(this,te,le,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[le]=te&255,this[le+1]=te>>>8):D(this,te,le,!0),le+2},l.prototype.writeInt16BE=function(te,le,ge){return te=+te,le=le|0,ge||w(this,te,le,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[le]=te>>>8,this[le+1]=te&255):D(this,te,le,!1),le+2},l.prototype.writeInt32LE=function(te,le,ge){return te=+te,le=le|0,ge||w(this,te,le,4,2147483647,-2147483648),l.TYPED_ARRAY_SUPPORT?(this[le]=te&255,this[le+1]=te>>>8,this[le+2]=te>>>16,this[le+3]=te>>>24):Z(this,te,le,!0),le+4},l.prototype.writeInt32BE=function(te,le,ge){return te=+te,le=le|0,ge||w(this,te,le,4,2147483647,-2147483648),te<0&&(te=4294967295+te+1),l.TYPED_ARRAY_SUPPORT?(this[le]=te>>>24,this[le+1]=te>>>16,this[le+2]=te>>>8,this[le+3]=te&255):Z(this,te,le,!1),le+4};function F(ce,te,le,ge,Pe,lt){if(le+ge>ce.length)throw new RangeError("Index out of range");if(le<0)throw new RangeError("Index out of range")}function V(ce,te,le,ge,Pe){return Pe||F(ce,te,le,4,34028234663852886e22,-34028234663852886e22),y.write(ce,te,le,ge,23,4),le+4}l.prototype.writeFloatLE=function(te,le,ge){return V(this,te,le,!0,ge)},l.prototype.writeFloatBE=function(te,le,ge){return V(this,te,le,!1,ge)};function q(ce,te,le,ge,Pe){return Pe||F(ce,te,le,8,17976931348623157e292,-17976931348623157e292),y.write(ce,te,le,ge,52,8),le+8}l.prototype.writeDoubleLE=function(te,le,ge){return q(this,te,le,!0,ge)},l.prototype.writeDoubleBE=function(te,le,ge){return q(this,te,le,!1,ge)},l.prototype.copy=function(te,le,ge,Pe){if(ge||(ge=0),!Pe&&Pe!==0&&(Pe=this.length),le>=te.length&&(le=te.length),le||(le=0),Pe>0&&Pe<ge&&(Pe=ge),Pe===ge||te.length===0||this.length===0)return 0;if(le<0)throw new RangeError("targetStart out of bounds");if(ge<0||ge>=this.length)throw new RangeError("sourceStart out of bounds");if(Pe<0)throw new RangeError("sourceEnd out of bounds");Pe>this.length&&(Pe=this.length),te.length-le<Pe-ge&&(Pe=te.length-le+ge);var lt=Pe-ge,Le;if(this===te&&ge<le&&le<Pe)for(Le=lt-1;Le>=0;--Le)te[Le+le]=this[Le+ge];else if(lt<1e3||!l.TYPED_ARRAY_SUPPORT)for(Le=0;Le<lt;++Le)te[Le+le]=this[Le+ge];else Uint8Array.prototype.set.call(te,this.subarray(ge,ge+lt),le);return lt},l.prototype.fill=function(te,le,ge,Pe){if(typeof te=="string"){if(typeof le=="string"?(Pe=le,le=0,ge=this.length):typeof ge=="string"&&(Pe=ge,ge=this.length),te.length===1){var lt=te.charCodeAt(0);lt<256&&(te=lt)}if(Pe!==void 0&&typeof Pe!="string")throw new TypeError("encoding must be a string");if(typeof Pe=="string"&&!l.isEncoding(Pe))throw new TypeError("Unknown encoding: "+Pe)}else typeof te=="number"&&(te=te&255);if(le<0||this.length<le||this.length<ge)throw new RangeError("Out of range index");if(ge<=le)return this;le=le>>>0,ge=ge===void 0?this.length:ge>>>0,te||(te=0);var Le;if(typeof te=="number")for(Le=le;Le<ge;++Le)this[Le]=te;else{var ze=l.isBuffer(te)?te:ue(new l(te,Pe).toString()),kt=ze.length;for(Le=0;Le<ge-le;++Le)this[Le+le]=ze[Le%kt]}return this};var re=/[^+\/0-9A-Za-z-_]/g;function G(ce){if(ce=H(ce).replace(re,""),ce.length<2)return"";for(;ce.length%4!==0;)ce=ce+"=";return ce}function H(ce){return ce.trim?ce.trim():ce.replace(/^\s+|\s+$/g,"")}function oe(ce){return ce<16?"0"+ce.toString(16):ce.toString(16)}function ue(ce,te){te=te||1/0;for(var le,ge=ce.length,Pe=null,lt=[],Le=0;Le<ge;++Le){if(le=ce.charCodeAt(Le),le>55295&&le<57344){if(!Pe){if(le>56319){(te-=3)>-1&<.push(239,191,189);continue}else if(Le+1===ge){(te-=3)>-1&<.push(239,191,189);continue}Pe=le;continue}if(le<56320){(te-=3)>-1&<.push(239,191,189),Pe=le;continue}le=(Pe-55296<<10|le-56320)+65536}else Pe&&(te-=3)>-1&<.push(239,191,189);if(Pe=null,le<128){if((te-=1)<0)break;lt.push(le)}else if(le<2048){if((te-=2)<0)break;lt.push(le>>6|192,le&63|128)}else if(le<65536){if((te-=3)<0)break;lt.push(le>>12|224,le>>6&63|128,le&63|128)}else if(le<1114112){if((te-=4)<0)break;lt.push(le>>18|240,le>>12&63|128,le>>6&63|128,le&63|128)}else throw new Error("Invalid code point")}return lt}function be(ce){for(var te=[],le=0;le<ce.length;++le)te.push(ce.charCodeAt(le)&255);return te}function ie(ce,te){for(var le,ge,Pe,lt=[],Le=0;Le<ce.length&&!((te-=2)<0);++Le)le=ce.charCodeAt(Le),ge=le>>8,Pe=le%256,lt.push(Pe),lt.push(ge);return lt}function J(ce){return S.toByteArray(G(ce))}function pe(ce,te,le,ge){for(var Pe=0;Pe<ge&&!(Pe+le>=te.length||Pe>=ce.length);++Pe)te[Pe+le]=ce[Pe];return Pe}function Ge(ce){return ce!==ce}},6168:(fe,x,T)=>{var S=T(2861).Buffer,y=T(8310).Transform,p=T(3141).I,I=T(6698);function o(m){y.call(this),this.hashMode=typeof m=="string",this.hashMode?this[m]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}I(o,y),o.prototype.update=function(m,l,g){typeof m=="string"&&(m=S.from(m,l));var M=this._update(m);return this.hashMode?this:(g&&(M=this._toString(M,g)),M)},o.prototype.setAutoPadding=function(){},o.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},o.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},o.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},o.prototype._transform=function(m,l,g){var M;try{this.hashMode?this._update(m):this.push(this._update(m))}catch(E){M=E}finally{g(M)}},o.prototype._flush=function(m){var l;try{this.push(this.__final())}catch(g){l=g}m(l)},o.prototype._finalOrDigest=function(m){var l=this.__final()||S.alloc(0);return m&&(l=this._toString(l,m,!0)),l},o.prototype._toString=function(m,l,g){if(this._decoder||(this._decoder=new p(l),this._encoding=l),this._encoding!==l)throw new Error("can't switch encodings");var M=this._decoder.write(m);return g&&(M+=this._decoder.end()),M},fe.exports=o},5622:(fe,x,T)=>{var S=T(8287).Buffer;function y(U){return Array.isArray?Array.isArray(U):B(U)==="[object Array]"}x.isArray=y;function p(U){return typeof U=="boolean"}x.isBoolean=p;function I(U){return U===null}x.isNull=I;function o(U){return U==null}x.isNullOrUndefined=o;function m(U){return typeof U=="number"}x.isNumber=m;function l(U){return typeof U=="string"}x.isString=l;function g(U){return typeof U=="symbol"}x.isSymbol=g;function M(U){return U===void 0}x.isUndefined=M;function E(U){return B(U)==="[object RegExp]"}x.isRegExp=E;function d(U){return typeof U=="object"&&U!==null}x.isObject=d;function A(U){return B(U)==="[object Date]"}x.isDate=A;function v(U){return B(U)==="[object Error]"||U instanceof Error}x.isError=v;function b(U){return typeof U=="function"}x.isFunction=b;function k(U){return U===null||typeof U=="boolean"||typeof U=="number"||typeof U=="string"||typeof U=="symbol"||typeof U>"u"}x.isPrimitive=k,x.isBuffer=S.isBuffer;function B(U){return Object.prototype.toString.call(U)}},1324:(fe,x,T)=>{var S=T(8287).Buffer,y=T(6729),p=T(2801);fe.exports=function(g){return new o(g)};var I={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};I.p224=I.secp224r1,I.p256=I.secp256r1=I.prime256v1,I.p192=I.secp192r1=I.prime192v1,I.p384=I.secp384r1,I.p521=I.secp521r1;function o(l){this.curveType=I[l],this.curveType||(this.curveType={name:l}),this.curve=new y.ec(this.curveType.name),this.keys=void 0}o.prototype.generateKeys=function(l,g){return this.keys=this.curve.genKeyPair(),this.getPublicKey(l,g)},o.prototype.computeSecret=function(l,g,M){g=g||"utf8",S.isBuffer(l)||(l=new S(l,g));var E=this.curve.keyFromPublic(l).getPublic(),d=E.mul(this.keys.getPrivate()).getX();return m(d,M,this.curveType.byteLength)},o.prototype.getPublicKey=function(l,g){var M=this.keys.getPublic(g==="compressed",!0);return g==="hybrid"&&(M[M.length-1]%2?M[0]=7:M[0]=6),m(M,l)},o.prototype.getPrivateKey=function(l){return m(this.keys.getPrivate(),l)},o.prototype.setPublicKey=function(l,g){return g=g||"utf8",S.isBuffer(l)||(l=new S(l,g)),this.keys._importPublic(l),this},o.prototype.setPrivateKey=function(l,g){g=g||"utf8",S.isBuffer(l)||(l=new S(l,g));var M=new p(l);return M=M.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(M),this};function m(l,g,M){Array.isArray(l)||(l=l.toArray());var E=new S(l);if(M&&E.length<M){var d=new S(M-E.length);d.fill(0),E=S.concat([d,E])}return g?E.toString(g):E}},2801:function(fe,x,T){fe=T.nmd(fe),function(S,y){"use strict";function p(u,e){if(!u)throw new Error(e||"Assertion failed")}function I(u,e){u.super_=e;var r=function(){};r.prototype=e.prototype,u.prototype=new r,u.prototype.constructor=u}function o(u,e,r){if(o.isBN(u))return u;this.negative=0,this.words=null,this.length=0,this.red=null,u!==null&&((e==="le"||e==="be")&&(r=e,e=10),this._init(u||0,e||10,r||"be"))}typeof S=="object"?S.exports=o:y.BN=o,o.BN=o,o.wordSize=26;var m;try{typeof window<"u"&&typeof window.Buffer<"u"?m=window.Buffer:m=T(7965).Buffer}catch{}o.isBN=function(e){return e instanceof o?!0:e!==null&&typeof e=="object"&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,r){return e.cmp(r)>0?e:r},o.min=function(e,r){return e.cmp(r)<0?e:r},o.prototype._init=function(e,r,n){if(typeof e=="number")return this._initNumber(e,r,n);if(typeof e=="object")return this._initArray(e,r,n);r==="hex"&&(r=16),p(r===(r|0)&&r>=2&&r<=36),e=e.toString().replace(/\s+/g,"");var i=0;e[0]==="-"&&(i++,this.negative=1),i<e.length&&(r===16?this._parseHex(e,i,n):(this._parseBase(e,r,i),n==="le"&&this._initArray(this.toArray(),r,n)))},o.prototype._initNumber=function(e,r,n){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[e&67108863],this.length=1):e<4503599627370496?(this.words=[e&67108863,e/67108864&67108863],this.length=2):(p(e<9007199254740992),this.words=[e&67108863,e/67108864&67108863,1],this.length=3),n==="le"&&this._initArray(this.toArray(),r,n)},o.prototype._initArray=function(e,r,n){if(p(typeof e.length=="number"),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<this.length;i++)this.words[i]=0;var f,c,h=0;if(n==="be")for(i=e.length-1,f=0;i>=0;i-=3)c=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[f]|=c<<h&67108863,this.words[f+1]=c>>>26-h&67108863,h+=24,h>=26&&(h-=26,f++);else if(n==="le")for(i=0,f=0;i<e.length;i+=3)c=e[i]|e[i+1]<<8|e[i+2]<<16,this.words[f]|=c<<h&67108863,this.words[f+1]=c>>>26-h&67108863,h+=24,h>=26&&(h-=26,f++);return this.strip()};function l(u,e){var r=u.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function g(u,e,r){var n=l(u,r);return r-1>=e&&(n|=l(u,r-1)<<4),n}o.prototype._parseHex=function(e,r,n){this.length=Math.ceil((e.length-r)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var f=0,c=0,h;if(n==="be")for(i=e.length-1;i>=r;i-=2)h=g(e,r,i)<<f,this.words[c]|=h&67108863,f>=18?(f-=18,c+=1,this.words[c]|=h>>>26):f+=8;else{var s=e.length-r;for(i=s%2===0?r+1:r;i<e.length;i+=2)h=g(e,r,i)<<f,this.words[c]|=h&67108863,f>=18?(f-=18,c+=1,this.words[c]|=h>>>26):f+=8}this.strip()};function M(u,e,r,n){for(var i=0,f=Math.min(u.length,r),c=e;c<f;c++){var h=u.charCodeAt(c)-48;i*=n,h>=49?i+=h-49+10:h>=17?i+=h-17+10:i+=h}return i}o.prototype._parseBase=function(e,r,n){this.words=[0],this.length=1;for(var i=0,f=1;f<=67108863;f*=r)i++;i--,f=f/r|0;for(var c=e.length-n,h=c%i,s=Math.min(c,c-h)+n,t=0,a=n;a<s;a+=i)t=M(e,a,a+i,r),this.imuln(f),this.words[0]+t<67108864?this.words[0]+=t:this._iaddn(t);if(h!==0){var w=1;for(t=M(e,a,e.length,r),a=0;a<h;a++)w*=r;this.imuln(w),this.words[0]+t<67108864?this.words[0]+=t:this._iaddn(t)}this.strip()},o.prototype.copy=function(e){e.words=new Array(this.length);for(var r=0;r<this.length;r++)e.words[r]=this.words[r];e.length=this.length,e.negative=this.negative,e.red=this.red},o.prototype.clone=function(){var e=new o(null);return this.copy(e),e},o.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},o.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},o.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var E=["","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"],d=[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],A=[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];o.prototype.toString=function(e,r){e=e||10,r=r|0||1;var n;if(e===16||e==="hex"){n="";for(var i=0,f=0,c=0;c<this.length;c++){var h=this.words[c],s=((h<<i|f)&16777215).toString(16);f=h>>>24-i&16777215,f!==0||c!==this.length-1?n=E[6-s.length]+s+n:n=s+n,i+=2,i>=26&&(i-=26,c--)}for(f!==0&&(n=f.toString(16)+n);n.length%r!==0;)n="0"+n;return this.negative!==0&&(n="-"+n),n}if(e===(e|0)&&e>=2&&e<=36){var t=d[e],a=A[e];n="";var w=this.clone();for(w.negative=0;!w.isZero();){var D=w.modn(a).toString(e);w=w.idivn(a),w.isZero()?n=D+n:n=E[t-D.length]+D+n}for(this.isZero()&&(n="0"+n);n.length%r!==0;)n="0"+n;return this.negative!==0&&(n="-"+n),n}p(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return this.length===2?e+=this.words[1]*67108864:this.length===3&&this.words[2]===1?e+=4503599627370496+this.words[1]*67108864:this.length>2&&p(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,r){return p(typeof m<"u"),this.toArrayLike(m,e,r)},o.prototype.toArray=function(e,r){return this.toArrayLike(Array,e,r)},o.prototype.toArrayLike=function(e,r,n){var i=this.byteLength(),f=n||Math.max(1,i);p(i<=f,"byte array longer than desired length"),p(f>0,"Requested array length <= 0"),this.strip();var c=r==="le",h=new e(f),s,t,a=this.clone();if(c){for(t=0;!a.isZero();t++)s=a.andln(255),a.iushrn(8),h[t]=s;for(;t<f;t++)h[t]=0}else{for(t=0;t<f-i;t++)h[t]=0;for(t=0;!a.isZero();t++)s=a.andln(255),a.iushrn(8),h[f-t-1]=s}return h},Math.clz32?o.prototype._countBits=function(e){return 32-Math.clz32(e)}:o.prototype._countBits=function(e){var r=e,n=0;return r>=4096&&(n+=13,r>>>=13),r>=64&&(n+=7,r>>>=7),r>=8&&(n+=4,r>>>=4),r>=2&&(n+=2,r>>>=2),n+r},o.prototype._zeroBits=function(e){if(e===0)return 26;var r=e,n=0;return r&8191||(n+=13,r>>>=13),r&127||(n+=7,r>>>=7),r&15||(n+=4,r>>>=4),r&3||(n+=2,r>>>=2),r&1||n++,n},o.prototype.bitLength=function(){var e=this.words[this.length-1],r=this._countBits(e);return(this.length-1)*26+r};function v(u){for(var e=new Array(u.bitLength()),r=0;r<e.length;r++){var n=r/26|0,i=r%26;e[r]=(u.words[n]&1<<i)>>>i}return e}o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,r=0;r<this.length;r++){var n=this._zeroBits(this.words[r]);if(e+=n,n!==26)break}return e},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(e){return this.negative!==0?this.abs().inotn(e).iaddn(1):this.clone()},o.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return this.negative!==0},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]|e.words[r];return this.strip()},o.prototype.ior=function(e){return p((this.negative|e.negative)===0),this.iuor(e)},o.prototype.or=function(e){return this.length>e.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 r;this.length>e.length?r=e:r=this;for(var n=0;n<r.length;n++)this.words[n]=this.words[n]&e.words[n];return this.length=r.length,this.strip()},o.prototype.iand=function(e){return p((this.negative|e.negative)===0),this.iuand(e)},o.prototype.and=function(e){return this.length>e.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 r,n;this.length>e.length?(r=this,n=e):(r=e,n=this);for(var i=0;i<n.length;i++)this.words[i]=r.words[i]^n.words[i];if(this!==r)for(;i<r.length;i++)this.words[i]=r.words[i];return this.length=r.length,this.strip()},o.prototype.ixor=function(e){return p((this.negative|e.negative)===0),this.iuxor(e)},o.prototype.xor=function(e){return this.length>e.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){p(typeof e=="number"&&e>=0);var r=Math.ceil(e/26)|0,n=e%26;this._expand(r),n>0&&r--;for(var i=0;i<r;i++)this.words[i]=~this.words[i]&67108863;return n>0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,r){p(typeof e=="number"&&e>=0);var n=e/26|0,i=e%26;return this._expand(n+1),r?this.words[n]=this.words[n]|1<<i:this.words[n]=this.words[n]&~(1<<i),this.strip()},o.prototype.iadd=function(e){var r;if(this.negative!==0&&e.negative===0)return this.negative=0,r=this.isub(e),this.negative^=1,this._normSign();if(this.negative===0&&e.negative!==0)return e.negative=0,r=this.isub(e),e.negative=1,r._normSign();var n,i;this.length>e.length?(n=this,i=e):(n=e,i=this);for(var f=0,c=0;c<i.length;c++)r=(n.words[c]|0)+(i.words[c]|0)+f,this.words[c]=r&67108863,f=r>>>26;for(;f!==0&&c<n.length;c++)r=(n.words[c]|0)+f,this.words[c]=r&67108863,f=r>>>26;if(this.length=n.length,f!==0)this.words[this.length]=f,this.length++;else if(n!==this)for(;c<n.length;c++)this.words[c]=n.words[c];return this},o.prototype.add=function(e){var r;return e.negative!==0&&this.negative===0?(e.negative=0,r=this.sub(e),e.negative^=1,r):e.negative===0&&this.negative!==0?(this.negative=0,r=e.sub(this),this.negative=1,r):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(e.negative!==0){e.negative=0;var r=this.iadd(e);return e.negative=1,r._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var n=this.cmp(e);if(n===0)return this.negative=0,this.length=1,this.words[0]=0,this;var i,f;n>0?(i=this,f=e):(i=e,f=this);for(var c=0,h=0;h<f.length;h++)r=(i.words[h]|0)-(f.words[h]|0)+c,c=r>>26,this.words[h]=r&67108863;for(;c!==0&&h<i.length;h++)r=(i.words[h]|0)+c,c=r>>26,this.words[h]=r&67108863;if(c===0&&h<i.length&&i!==this)for(;h<i.length;h++)this.words[h]=i.words[h];return this.length=Math.max(this.length,h),i!==this&&(this.negative=1),this.strip()},o.prototype.sub=function(e){return this.clone().isub(e)};function b(u,e,r){r.negative=e.negative^u.negative;var n=u.length+e.length|0;r.length=n,n=n-1|0;var i=u.words[0]|0,f=e.words[0]|0,c=i*f,h=c&67108863,s=c/67108864|0;r.words[0]=h;for(var t=1;t<n;t++){for(var a=s>>>26,w=s&67108863,D=Math.min(t,e.length-1),Z=Math.max(0,t-u.length+1);Z<=D;Z++){var F=t-Z|0;i=u.words[F]|0,f=e.words[Z]|0,c=i*f+w,a+=c/67108864|0,w=c&67108863}r.words[t]=w|0,s=a|0}return s!==0?r.words[t]=s|0:r.length--,r.strip()}var k=function(e,r,n){var i=e.words,f=r.words,c=n.words,h=0,s,t,a,w=i[0]|0,D=w&8191,Z=w>>>13,F=i[1]|0,V=F&8191,q=F>>>13,re=i[2]|0,G=re&8191,H=re>>>13,oe=i[3]|0,ue=oe&8191,be=oe>>>13,ie=i[4]|0,J=ie&8191,pe=ie>>>13,Ge=i[5]|0,ce=Ge&8191,te=Ge>>>13,le=i[6]|0,ge=le&8191,Pe=le>>>13,lt=i[7]|0,Le=lt&8191,ze=lt>>>13,kt=i[8]|0,ae=kt&8191,he=kt>>>13,je=i[9]|0,Ie=je&8191,Ce=je>>>13,ut=f[0]|0,De=ut&8191,ye=ut>>>13,we=f[1]|0,ve=we&8191,Ee=we>>>13,rt=f[2]|0,Fe=rt&8191,He=rt>>>13,yt=f[3]|0,Ke=yt&8191,Ze=yt>>>13,At=f[4]|0,Ve=At&8191,tt=At>>>13,qt=f[5]|0,et=qt&8191,st=qt>>>13,rr=f[6]|0,at=rr&8191,ft=rr>>>13,Qe=f[7]|0,xe=Qe&8191,Oe=Qe>>>13,ht=f[8]|0,Ne=ht&8191,qe=ht>>>13,Dt=f[9]|0,Xe=Dt&8191,ot=Dt>>>13;n.negative=e.negative^r.negative,n.length=19,s=Math.imul(D,De),t=Math.imul(D,ye),t=t+Math.imul(Z,De)|0,a=Math.imul(Z,ye);var Gt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,s=Math.imul(V,De),t=Math.imul(V,ye),t=t+Math.imul(q,De)|0,a=Math.imul(q,ye),s=s+Math.imul(D,ve)|0,t=t+Math.imul(D,Ee)|0,t=t+Math.imul(Z,ve)|0,a=a+Math.imul(Z,Ee)|0;var xt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(xt>>>26)|0,xt&=67108863,s=Math.imul(G,De),t=Math.imul(G,ye),t=t+Math.imul(H,De)|0,a=Math.imul(H,ye),s=s+Math.imul(V,ve)|0,t=t+Math.imul(V,Ee)|0,t=t+Math.imul(q,ve)|0,a=a+Math.imul(q,Ee)|0,s=s+Math.imul(D,Fe)|0,t=t+Math.imul(D,He)|0,t=t+Math.imul(Z,Fe)|0,a=a+Math.imul(Z,He)|0;var gt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(gt>>>26)|0,gt&=67108863,s=Math.imul(ue,De),t=Math.imul(ue,ye),t=t+Math.imul(be,De)|0,a=Math.imul(be,ye),s=s+Math.imul(G,ve)|0,t=t+Math.imul(G,Ee)|0,t=t+Math.imul(H,ve)|0,a=a+Math.imul(H,Ee)|0,s=s+Math.imul(V,Fe)|0,t=t+Math.imul(V,He)|0,t=t+Math.imul(q,Fe)|0,a=a+Math.imul(q,He)|0,s=s+Math.imul(D,Ke)|0,t=t+Math.imul(D,Ze)|0,t=t+Math.imul(Z,Ke)|0,a=a+Math.imul(Z,Ze)|0;var bt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(bt>>>26)|0,bt&=67108863,s=Math.imul(J,De),t=Math.imul(J,ye),t=t+Math.imul(pe,De)|0,a=Math.imul(pe,ye),s=s+Math.imul(ue,ve)|0,t=t+Math.imul(ue,Ee)|0,t=t+Math.imul(be,ve)|0,a=a+Math.imul(be,Ee)|0,s=s+Math.imul(G,Fe)|0,t=t+Math.imul(G,He)|0,t=t+Math.imul(H,Fe)|0,a=a+Math.imul(H,He)|0,s=s+Math.imul(V,Ke)|0,t=t+Math.imul(V,Ze)|0,t=t+Math.imul(q,Ke)|0,a=a+Math.imul(q,Ze)|0,s=s+Math.imul(D,Ve)|0,t=t+Math.imul(D,tt)|0,t=t+Math.imul(Z,Ve)|0,a=a+Math.imul(Z,tt)|0;var Tt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,s=Math.imul(ce,De),t=Math.imul(ce,ye),t=t+Math.imul(te,De)|0,a=Math.imul(te,ye),s=s+Math.imul(J,ve)|0,t=t+Math.imul(J,Ee)|0,t=t+Math.imul(pe,ve)|0,a=a+Math.imul(pe,Ee)|0,s=s+Math.imul(ue,Fe)|0,t=t+Math.imul(ue,He)|0,t=t+Math.imul(be,Fe)|0,a=a+Math.imul(be,He)|0,s=s+Math.imul(G,Ke)|0,t=t+Math.imul(G,Ze)|0,t=t+Math.imul(H,Ke)|0,a=a+Math.imul(H,Ze)|0,s=s+Math.imul(V,Ve)|0,t=t+Math.imul(V,tt)|0,t=t+Math.imul(q,Ve)|0,a=a+Math.imul(q,tt)|0,s=s+Math.imul(D,et)|0,t=t+Math.imul(D,st)|0,t=t+Math.imul(Z,et)|0,a=a+Math.imul(Z,st)|0;var Ct=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,s=Math.imul(ge,De),t=Math.imul(ge,ye),t=t+Math.imul(Pe,De)|0,a=Math.imul(Pe,ye),s=s+Math.imul(ce,ve)|0,t=t+Math.imul(ce,Ee)|0,t=t+Math.imul(te,ve)|0,a=a+Math.imul(te,Ee)|0,s=s+Math.imul(J,Fe)|0,t=t+Math.imul(J,He)|0,t=t+Math.imul(pe,Fe)|0,a=a+Math.imul(pe,He)|0,s=s+Math.imul(ue,Ke)|0,t=t+Math.imul(ue,Ze)|0,t=t+Math.imul(be,Ke)|0,a=a+Math.imul(be,Ze)|0,s=s+Math.imul(G,Ve)|0,t=t+Math.imul(G,tt)|0,t=t+Math.imul(H,Ve)|0,a=a+Math.imul(H,tt)|0,s=s+Math.imul(V,et)|0,t=t+Math.imul(V,st)|0,t=t+Math.imul(q,et)|0,a=a+Math.imul(q,st)|0,s=s+Math.imul(D,at)|0,t=t+Math.imul(D,ft)|0,t=t+Math.imul(Z,at)|0,a=a+Math.imul(Z,ft)|0;var Xt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Xt>>>26)|0,Xt&=67108863,s=Math.imul(Le,De),t=Math.imul(Le,ye),t=t+Math.imul(ze,De)|0,a=Math.imul(ze,ye),s=s+Math.imul(ge,ve)|0,t=t+Math.imul(ge,Ee)|0,t=t+Math.imul(Pe,ve)|0,a=a+Math.imul(Pe,Ee)|0,s=s+Math.imul(ce,Fe)|0,t=t+Math.imul(ce,He)|0,t=t+Math.imul(te,Fe)|0,a=a+Math.imul(te,He)|0,s=s+Math.imul(J,Ke)|0,t=t+Math.imul(J,Ze)|0,t=t+Math.imul(pe,Ke)|0,a=a+Math.imul(pe,Ze)|0,s=s+Math.imul(ue,Ve)|0,t=t+Math.imul(ue,tt)|0,t=t+Math.imul(be,Ve)|0,a=a+Math.imul(be,tt)|0,s=s+Math.imul(G,et)|0,t=t+Math.imul(G,st)|0,t=t+Math.imul(H,et)|0,a=a+Math.imul(H,st)|0,s=s+Math.imul(V,at)|0,t=t+Math.imul(V,ft)|0,t=t+Math.imul(q,at)|0,a=a+Math.imul(q,ft)|0,s=s+Math.imul(D,xe)|0,t=t+Math.imul(D,Oe)|0,t=t+Math.imul(Z,xe)|0,a=a+Math.imul(Z,Oe)|0;var Yt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Yt>>>26)|0,Yt&=67108863,s=Math.imul(ae,De),t=Math.imul(ae,ye),t=t+Math.imul(he,De)|0,a=Math.imul(he,ye),s=s+Math.imul(Le,ve)|0,t=t+Math.imul(Le,Ee)|0,t=t+Math.imul(ze,ve)|0,a=a+Math.imul(ze,Ee)|0,s=s+Math.imul(ge,Fe)|0,t=t+Math.imul(ge,He)|0,t=t+Math.imul(Pe,Fe)|0,a=a+Math.imul(Pe,He)|0,s=s+Math.imul(ce,Ke)|0,t=t+Math.imul(ce,Ze)|0,t=t+Math.imul(te,Ke)|0,a=a+Math.imul(te,Ze)|0,s=s+Math.imul(J,Ve)|0,t=t+Math.imul(J,tt)|0,t=t+Math.imul(pe,Ve)|0,a=a+Math.imul(pe,tt)|0,s=s+Math.imul(ue,et)|0,t=t+Math.imul(ue,st)|0,t=t+Math.imul(be,et)|0,a=a+Math.imul(be,st)|0,s=s+Math.imul(G,at)|0,t=t+Math.imul(G,ft)|0,t=t+Math.imul(H,at)|0,a=a+Math.imul(H,ft)|0,s=s+Math.imul(V,xe)|0,t=t+Math.imul(V,Oe)|0,t=t+Math.imul(q,xe)|0,a=a+Math.imul(q,Oe)|0,s=s+Math.imul(D,Ne)|0,t=t+Math.imul(D,qe)|0,t=t+Math.imul(Z,Ne)|0,a=a+Math.imul(Z,qe)|0;var ar=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(ar>>>26)|0,ar&=67108863,s=Math.imul(Ie,De),t=Math.imul(Ie,ye),t=t+Math.imul(Ce,De)|0,a=Math.imul(Ce,ye),s=s+Math.imul(ae,ve)|0,t=t+Math.imul(ae,Ee)|0,t=t+Math.imul(he,ve)|0,a=a+Math.imul(he,Ee)|0,s=s+Math.imul(Le,Fe)|0,t=t+Math.imul(Le,He)|0,t=t+Math.imul(ze,Fe)|0,a=a+Math.imul(ze,He)|0,s=s+Math.imul(ge,Ke)|0,t=t+Math.imul(ge,Ze)|0,t=t+Math.imul(Pe,Ke)|0,a=a+Math.imul(Pe,Ze)|0,s=s+Math.imul(ce,Ve)|0,t=t+Math.imul(ce,tt)|0,t=t+Math.imul(te,Ve)|0,a=a+Math.imul(te,tt)|0,s=s+Math.imul(J,et)|0,t=t+Math.imul(J,st)|0,t=t+Math.imul(pe,et)|0,a=a+Math.imul(pe,st)|0,s=s+Math.imul(ue,at)|0,t=t+Math.imul(ue,ft)|0,t=t+Math.imul(be,at)|0,a=a+Math.imul(be,ft)|0,s=s+Math.imul(G,xe)|0,t=t+Math.imul(G,Oe)|0,t=t+Math.imul(H,xe)|0,a=a+Math.imul(H,Oe)|0,s=s+Math.imul(V,Ne)|0,t=t+Math.imul(V,qe)|0,t=t+Math.imul(q,Ne)|0,a=a+Math.imul(q,qe)|0,s=s+Math.imul(D,Xe)|0,t=t+Math.imul(D,ot)|0,t=t+Math.imul(Z,Xe)|0,a=a+Math.imul(Z,ot)|0;var or=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(or>>>26)|0,or&=67108863,s=Math.imul(Ie,ve),t=Math.imul(Ie,Ee),t=t+Math.imul(Ce,ve)|0,a=Math.imul(Ce,Ee),s=s+Math.imul(ae,Fe)|0,t=t+Math.imul(ae,He)|0,t=t+Math.imul(he,Fe)|0,a=a+Math.imul(he,He)|0,s=s+Math.imul(Le,Ke)|0,t=t+Math.imul(Le,Ze)|0,t=t+Math.imul(ze,Ke)|0,a=a+Math.imul(ze,Ze)|0,s=s+Math.imul(ge,Ve)|0,t=t+Math.imul(ge,tt)|0,t=t+Math.imul(Pe,Ve)|0,a=a+Math.imul(Pe,tt)|0,s=s+Math.imul(ce,et)|0,t=t+Math.imul(ce,st)|0,t=t+Math.imul(te,et)|0,a=a+Math.imul(te,st)|0,s=s+Math.imul(J,at)|0,t=t+Math.imul(J,ft)|0,t=t+Math.imul(pe,at)|0,a=a+Math.imul(pe,ft)|0,s=s+Math.imul(ue,xe)|0,t=t+Math.imul(ue,Oe)|0,t=t+Math.imul(be,xe)|0,a=a+Math.imul(be,Oe)|0,s=s+Math.imul(G,Ne)|0,t=t+Math.imul(G,qe)|0,t=t+Math.imul(H,Ne)|0,a=a+Math.imul(H,qe)|0,s=s+Math.imul(V,Xe)|0,t=t+Math.imul(V,ot)|0,t=t+Math.imul(q,Xe)|0,a=a+Math.imul(q,ot)|0;var sr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(sr>>>26)|0,sr&=67108863,s=Math.imul(Ie,Fe),t=Math.imul(Ie,He),t=t+Math.imul(Ce,Fe)|0,a=Math.imul(Ce,He),s=s+Math.imul(ae,Ke)|0,t=t+Math.imul(ae,Ze)|0,t=t+Math.imul(he,Ke)|0,a=a+Math.imul(he,Ze)|0,s=s+Math.imul(Le,Ve)|0,t=t+Math.imul(Le,tt)|0,t=t+Math.imul(ze,Ve)|0,a=a+Math.imul(ze,tt)|0,s=s+Math.imul(ge,et)|0,t=t+Math.imul(ge,st)|0,t=t+Math.imul(Pe,et)|0,a=a+Math.imul(Pe,st)|0,s=s+Math.imul(ce,at)|0,t=t+Math.imul(ce,ft)|0,t=t+Math.imul(te,at)|0,a=a+Math.imul(te,ft)|0,s=s+Math.imul(J,xe)|0,t=t+Math.imul(J,Oe)|0,t=t+Math.imul(pe,xe)|0,a=a+Math.imul(pe,Oe)|0,s=s+Math.imul(ue,Ne)|0,t=t+Math.imul(ue,qe)|0,t=t+Math.imul(be,Ne)|0,a=a+Math.imul(be,qe)|0,s=s+Math.imul(G,Xe)|0,t=t+Math.imul(G,ot)|0,t=t+Math.imul(H,Xe)|0,a=a+Math.imul(H,ot)|0;var $t=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+($t>>>26)|0,$t&=67108863,s=Math.imul(Ie,Ke),t=Math.imul(Ie,Ze),t=t+Math.imul(Ce,Ke)|0,a=Math.imul(Ce,Ze),s=s+Math.imul(ae,Ve)|0,t=t+Math.imul(ae,tt)|0,t=t+Math.imul(he,Ve)|0,a=a+Math.imul(he,tt)|0,s=s+Math.imul(Le,et)|0,t=t+Math.imul(Le,st)|0,t=t+Math.imul(ze,et)|0,a=a+Math.imul(ze,st)|0,s=s+Math.imul(ge,at)|0,t=t+Math.imul(ge,ft)|0,t=t+Math.imul(Pe,at)|0,a=a+Math.imul(Pe,ft)|0,s=s+Math.imul(ce,xe)|0,t=t+Math.imul(ce,Oe)|0,t=t+Math.imul(te,xe)|0,a=a+Math.imul(te,Oe)|0,s=s+Math.imul(J,Ne)|0,t=t+Math.imul(J,qe)|0,t=t+Math.imul(pe,Ne)|0,a=a+Math.imul(pe,qe)|0,s=s+Math.imul(ue,Xe)|0,t=t+Math.imul(ue,ot)|0,t=t+Math.imul(be,Xe)|0,a=a+Math.imul(be,ot)|0;var nr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(nr>>>26)|0,nr&=67108863,s=Math.imul(Ie,Ve),t=Math.imul(Ie,tt),t=t+Math.imul(Ce,Ve)|0,a=Math.imul(Ce,tt),s=s+Math.imul(ae,et)|0,t=t+Math.imul(ae,st)|0,t=t+Math.imul(he,et)|0,a=a+Math.imul(he,st)|0,s=s+Math.imul(Le,at)|0,t=t+Math.imul(Le,ft)|0,t=t+Math.imul(ze,at)|0,a=a+Math.imul(ze,ft)|0,s=s+Math.imul(ge,xe)|0,t=t+Math.imul(ge,Oe)|0,t=t+Math.imul(Pe,xe)|0,a=a+Math.imul(Pe,Oe)|0,s=s+Math.imul(ce,Ne)|0,t=t+Math.imul(ce,qe)|0,t=t+Math.imul(te,Ne)|0,a=a+Math.imul(te,qe)|0,s=s+Math.imul(J,Xe)|0,t=t+Math.imul(J,ot)|0,t=t+Math.imul(pe,Xe)|0,a=a+Math.imul(pe,ot)|0;var fr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(fr>>>26)|0,fr&=67108863,s=Math.imul(Ie,et),t=Math.imul(Ie,st),t=t+Math.imul(Ce,et)|0,a=Math.imul(Ce,st),s=s+Math.imul(ae,at)|0,t=t+Math.imul(ae,ft)|0,t=t+Math.imul(he,at)|0,a=a+Math.imul(he,ft)|0,s=s+Math.imul(Le,xe)|0,t=t+Math.imul(Le,Oe)|0,t=t+Math.imul(ze,xe)|0,a=a+Math.imul(ze,Oe)|0,s=s+Math.imul(ge,Ne)|0,t=t+Math.imul(ge,qe)|0,t=t+Math.imul(Pe,Ne)|0,a=a+Math.imul(Pe,qe)|0,s=s+Math.imul(ce,Xe)|0,t=t+Math.imul(ce,ot)|0,t=t+Math.imul(te,Xe)|0,a=a+Math.imul(te,ot)|0;var lr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(lr>>>26)|0,lr&=67108863,s=Math.imul(Ie,at),t=Math.imul(Ie,ft),t=t+Math.imul(Ce,at)|0,a=Math.imul(Ce,ft),s=s+Math.imul(ae,xe)|0,t=t+Math.imul(ae,Oe)|0,t=t+Math.imul(he,xe)|0,a=a+Math.imul(he,Oe)|0,s=s+Math.imul(Le,Ne)|0,t=t+Math.imul(Le,qe)|0,t=t+Math.imul(ze,Ne)|0,a=a+Math.imul(ze,qe)|0,s=s+Math.imul(ge,Xe)|0,t=t+Math.imul(ge,ot)|0,t=t+Math.imul(Pe,Xe)|0,a=a+Math.imul(Pe,ot)|0;var dr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(dr>>>26)|0,dr&=67108863,s=Math.imul(Ie,xe),t=Math.imul(Ie,Oe),t=t+Math.imul(Ce,xe)|0,a=Math.imul(Ce,Oe),s=s+Math.imul(ae,Ne)|0,t=t+Math.imul(ae,qe)|0,t=t+Math.imul(he,Ne)|0,a=a+Math.imul(he,qe)|0,s=s+Math.imul(Le,Xe)|0,t=t+Math.imul(Le,ot)|0,t=t+Math.imul(ze,Xe)|0,a=a+Math.imul(ze,ot)|0;var cr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(cr>>>26)|0,cr&=67108863,s=Math.imul(Ie,Ne),t=Math.imul(Ie,qe),t=t+Math.imul(Ce,Ne)|0,a=Math.imul(Ce,qe),s=s+Math.imul(ae,Xe)|0,t=t+Math.imul(ae,ot)|0,t=t+Math.imul(he,Xe)|0,a=a+Math.imul(he,ot)|0;var gr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(gr>>>26)|0,gr&=67108863,s=Math.imul(Ie,Xe),t=Math.imul(Ie,ot),t=t+Math.imul(Ce,Xe)|0,a=Math.imul(Ce,ot);var pr=(h+s|0)+((t&8191)<<13)|0;return h=(a+(t>>>13)|0)+(pr>>>26)|0,pr&=67108863,c[0]=Gt,c[1]=xt,c[2]=gt,c[3]=bt,c[4]=Tt,c[5]=Ct,c[6]=Xt,c[7]=Yt,c[8]=ar,c[9]=or,c[10]=sr,c[11]=$t,c[12]=nr,c[13]=fr,c[14]=lr,c[15]=dr,c[16]=cr,c[17]=gr,c[18]=pr,h!==0&&(c[19]=h,n.length++),n};Math.imul||(k=b);function B(u,e,r){r.negative=e.negative^u.negative,r.length=u.length+e.length;for(var n=0,i=0,f=0;f<r.length-1;f++){var c=i;i=0;for(var h=n&67108863,s=Math.min(f,e.length-1),t=Math.max(0,f-u.length+1);t<=s;t++){var a=f-t,w=u.words[a]|0,D=e.words[t]|0,Z=w*D,F=Z&67108863;c=c+(Z/67108864|0)|0,F=F+h|0,h=F&67108863,c=c+(F>>>26)|0,i+=c>>>26,c&=67108863}r.words[f]=h,n=c,c=i}return n!==0?r.words[f]=n:r.length--,r.strip()}function U(u,e,r){var n=new C;return n.mulp(u,e,r)}o.prototype.mulTo=function(e,r){var n,i=this.length+e.length;return this.length===10&&e.length===10?n=k(this,e,r):i<63?n=b(this,e,r):i<1024?n=B(this,e,r):n=U(this,e,r),n};function C(u,e){this.x=u,this.y=e}C.prototype.makeRBT=function(e){for(var r=new Array(e),n=o.prototype._countBits(e)-1,i=0;i<e;i++)r[i]=this.revBin(i,n,e);return r},C.prototype.revBin=function(e,r,n){if(e===0||e===n-1)return e;for(var i=0,f=0;f<r;f++)i|=(e&1)<<r-f-1,e>>=1;return i},C.prototype.permute=function(e,r,n,i,f,c){for(var h=0;h<c;h++)i[h]=r[e[h]],f[h]=n[e[h]]},C.prototype.transform=function(e,r,n,i,f,c){this.permute(c,e,r,n,i,f);for(var h=1;h<f;h<<=1)for(var s=h<<1,t=Math.cos(2*Math.PI/s),a=Math.sin(2*Math.PI/s),w=0;w<f;w+=s)for(var D=t,Z=a,F=0;F<h;F++){var V=n[w+F],q=i[w+F],re=n[w+F+h],G=i[w+F+h],H=D*re-Z*G;G=D*G+Z*re,re=H,n[w+F]=V+re,i[w+F]=q+G,n[w+F+h]=V-re,i[w+F+h]=q-G,F!==s&&(H=t*D-a*Z,Z=t*Z+a*D,D=H)}},C.prototype.guessLen13b=function(e,r){var n=Math.max(r,e)|1,i=n&1,f=0;for(n=n/2|0;n;n=n>>>1)f++;return 1<<f+1+i},C.prototype.conjugate=function(e,r,n){if(!(n<=1))for(var i=0;i<n/2;i++){var f=e[i];e[i]=e[n-i-1],e[n-i-1]=f,f=r[i],r[i]=-r[n-i-1],r[n-i-1]=-f}},C.prototype.normalize13b=function(e,r){for(var n=0,i=0;i<r/2;i++){var f=Math.round(e[2*i+1]/r)*8192+Math.round(e[2*i]/r)+n;e[i]=f&67108863,f<67108864?n=0:n=f/67108864|0}return e},C.prototype.convert13b=function(e,r,n,i){for(var f=0,c=0;c<r;c++)f=f+(e[c]|0),n[2*c]=f&8191,f=f>>>13,n[2*c+1]=f&8191,f=f>>>13;for(c=2*r;c<i;++c)n[c]=0;p(f===0),p((f&-8192)===0)},C.prototype.stub=function(e){for(var r=new Array(e),n=0;n<e;n++)r[n]=0;return r},C.prototype.mulp=function(e,r,n){var i=2*this.guessLen13b(e.length,r.length),f=this.makeRBT(i),c=this.stub(i),h=new Array(i),s=new Array(i),t=new Array(i),a=new Array(i),w=new Array(i),D=new Array(i),Z=n.words;Z.length=i,this.convert13b(e.words,e.length,h,i),this.convert13b(r.words,r.length,a,i),this.transform(h,c,s,t,i,f),this.transform(a,c,w,D,i,f);for(var F=0;F<i;F++){var V=s[F]*w[F]-t[F]*D[F];t[F]=s[F]*D[F]+t[F]*w[F],s[F]=V}return this.conjugate(s,t,i),this.transform(s,t,Z,c,i,f),this.conjugate(Z,c,i),this.normalize13b(Z,i),n.negative=e.negative^r.negative,n.length=e.length+r.length,n.strip()},o.prototype.mul=function(e){var r=new o(null);return r.words=new Array(this.length+e.length),this.mulTo(e,r)},o.prototype.mulf=function(e){var r=new o(null);return r.words=new Array(this.length+e.length),U(this,e,r)},o.prototype.imul=function(e){return this.clone().mulTo(e,this)},o.prototype.imuln=function(e){p(typeof e=="number"),p(e<67108864);for(var r=0,n=0;n<this.length;n++){var i=(this.words[n]|0)*e,f=(i&67108863)+(r&67108863);r>>=26,r+=i/67108864|0,r+=f>>>26,this.words[n]=f&67108863}return r!==0&&(this.words[n]=r,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 r=v(e);if(r.length===0)return new o(1);for(var n=this,i=0;i<r.length&&r[i]===0;i++,n=n.sqr());if(++i<r.length)for(var f=n.sqr();i<r.length;i++,f=f.sqr())r[i]!==0&&(n=n.mul(f));return n},o.prototype.iushln=function(e){p(typeof e=="number"&&e>=0);var r=e%26,n=(e-r)/26,i=67108863>>>26-r<<26-r,f;if(r!==0){var c=0;for(f=0;f<this.length;f++){var h=this.words[f]&i,s=(this.words[f]|0)-h<<r;this.words[f]=s|c,c=h>>>26-r}c&&(this.words[f]=c,this.length++)}if(n!==0){for(f=this.length-1;f>=0;f--)this.words[f+n]=this.words[f];for(f=0;f<n;f++)this.words[f]=0;this.length+=n}return this.strip()},o.prototype.ishln=function(e){return p(this.negative===0),this.iushln(e)},o.prototype.iushrn=function(e,r,n){p(typeof e=="number"&&e>=0);var i;r?i=(r-r%26)/26:i=0;var f=e%26,c=Math.min((e-f)/26,this.length),h=67108863^67108863>>>f<<f,s=n;if(i-=c,i=Math.max(0,i),s){for(var t=0;t<c;t++)s.words[t]=this.words[t];s.length=c}if(c!==0)if(this.length>c)for(this.length-=c,t=0;t<this.length;t++)this.words[t]=this.words[t+c];else this.words[0]=0,this.length=1;var a=0;for(t=this.length-1;t>=0&&(a!==0||t>=i);t--){var w=this.words[t]|0;this.words[t]=a<<26-f|w>>>f,a=w&h}return s&&a!==0&&(s.words[s.length++]=a),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,r,n){return p(this.negative===0),this.iushrn(e,r,n)},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){p(typeof e=="number"&&e>=0);var r=e%26,n=(e-r)/26,i=1<<r;if(this.length<=n)return!1;var f=this.words[n];return!!(f&i)},o.prototype.imaskn=function(e){p(typeof e=="number"&&e>=0);var r=e%26,n=(e-r)/26;if(p(this.negative===0,"imaskn works only with positive numbers"),this.length<=n)return this;if(r!==0&&n++,this.length=Math.min(n,this.length),r!==0){var i=67108863^67108863>>>r<<r;this.words[this.length-1]&=i}return this.strip()},o.prototype.maskn=function(e){return this.clone().imaskn(e)},o.prototype.iaddn=function(e){return p(typeof e=="number"),p(e<67108864),e<0?this.isubn(-e):this.negative!==0?this.length===1&&(this.words[0]|0)<e?(this.words[0]=e-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this):this._iaddn(e)},o.prototype._iaddn=function(e){this.words[0]+=e;for(var r=0;r<this.length&&this.words[r]>=67108864;r++)this.words[r]-=67108864,r===this.length-1?this.words[r+1]=1:this.words[r+1]++;return this.length=Math.max(this.length,r+1),this},o.prototype.isubn=function(e){if(p(typeof e=="number"),p(e<67108864),e<0)return this.iaddn(-e);if(this.negative!==0)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var r=0;r<this.length&&this.words[r]<0;r++)this.words[r]+=67108864,this.words[r+1]-=1;return this.strip()},o.prototype.addn=function(e){return this.clone().iaddn(e)},o.prototype.subn=function(e){return this.clone().isubn(e)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(e,r,n){var i=e.length+n,f;this._expand(i);var c,h=0;for(f=0;f<e.length;f++){c=(this.words[f+n]|0)+h;var s=(e.words[f]|0)*r;c-=s&67108863,h=(c>>26)-(s/67108864|0),this.words[f+n]=c&67108863}for(;f<this.length-n;f++)c=(this.words[f+n]|0)+h,h=c>>26,this.words[f+n]=c&67108863;if(h===0)return this.strip();for(p(h===-1),h=0,f=0;f<this.length;f++)c=-(this.words[f]|0)+h,h=c>>26,this.words[f]=c&67108863;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,r){var n=this.length-e.length,i=this.clone(),f=e,c=f.words[f.length-1]|0,h=this._countBits(c);n=26-h,n!==0&&(f=f.ushln(n),i.iushln(n),c=f.words[f.length-1]|0);var s=i.length-f.length,t;if(r!=="mod"){t=new o(null),t.length=s+1,t.words=new Array(t.length);for(var a=0;a<t.length;a++)t.words[a]=0}var w=i.clone()._ishlnsubmul(f,1,s);w.negative===0&&(i=w,t&&(t.words[s]=1));for(var D=s-1;D>=0;D--){var Z=(i.words[f.length+D]|0)*67108864+(i.words[f.length+D-1]|0);for(Z=Math.min(Z/c|0,67108863),i._ishlnsubmul(f,Z,D);i.negative!==0;)Z--,i.negative=0,i._ishlnsubmul(f,1,D),i.isZero()||(i.negative^=1);t&&(t.words[D]=Z)}return t&&t.strip(),i.strip(),r!=="div"&&n!==0&&i.iushrn(n),{div:t||null,mod:i}},o.prototype.divmod=function(e,r,n){if(p(!e.isZero()),this.isZero())return{div:new o(0),mod:new o(0)};var i,f,c;return this.negative!==0&&e.negative===0?(c=this.neg().divmod(e,r),r!=="mod"&&(i=c.div.neg()),r!=="div"&&(f=c.mod.neg(),n&&f.negative!==0&&f.iadd(e)),{div:i,mod:f}):this.negative===0&&e.negative!==0?(c=this.divmod(e.neg(),r),r!=="mod"&&(i=c.div.neg()),{div:i,mod:c.mod}):this.negative&e.negative?(c=this.neg().divmod(e.neg(),r),r!=="div"&&(f=c.mod.neg(),n&&f.negative!==0&&f.isub(e)),{div:c.div,mod:f}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:e.length===1?r==="div"?{div:this.divn(e.words[0]),mod:null}:r==="mod"?{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,r)},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 r=this.divmod(e);if(r.mod.isZero())return r.div;var n=r.div.negative!==0?r.mod.isub(e):r.mod,i=e.ushrn(1),f=e.andln(1),c=n.cmp(i);return c<0||f===1&&c===0?r.div:r.div.negative!==0?r.div.isubn(1):r.div.iaddn(1)},o.prototype.modn=function(e){p(e<=67108863);for(var r=(1<<26)%e,n=0,i=this.length-1;i>=0;i--)n=(r*n+(this.words[i]|0))%e;return n},o.prototype.idivn=function(e){p(e<=67108863);for(var r=0,n=this.length-1;n>=0;n--){var i=(this.words[n]|0)+r*67108864;this.words[n]=i/e|0,r=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){p(e.negative===0),p(!e.isZero());var r=this,n=e.clone();r.negative!==0?r=r.umod(e):r=r.clone();for(var i=new o(1),f=new o(0),c=new o(0),h=new o(1),s=0;r.isEven()&&n.isEven();)r.iushrn(1),n.iushrn(1),++s;for(var t=n.clone(),a=r.clone();!r.isZero();){for(var w=0,D=1;!(r.words[0]&D)&&w<26;++w,D<<=1);if(w>0)for(r.iushrn(w);w-- >0;)(i.isOdd()||f.isOdd())&&(i.iadd(t),f.isub(a)),i.iushrn(1),f.iushrn(1);for(var Z=0,F=1;!(n.words[0]&F)&&Z<26;++Z,F<<=1);if(Z>0)for(n.iushrn(Z);Z-- >0;)(c.isOdd()||h.isOdd())&&(c.iadd(t),h.isub(a)),c.iushrn(1),h.iushrn(1);r.cmp(n)>=0?(r.isub(n),i.isub(c),f.isub(h)):(n.isub(r),c.isub(i),h.isub(f))}return{a:c,b:h,gcd:n.iushln(s)}},o.prototype._invmp=function(e){p(e.negative===0),p(!e.isZero());var r=this,n=e.clone();r.negative!==0?r=r.umod(e):r=r.clone();for(var i=new o(1),f=new o(0),c=n.clone();r.cmpn(1)>0&&n.cmpn(1)>0;){for(var h=0,s=1;!(r.words[0]&s)&&h<26;++h,s<<=1);if(h>0)for(r.iushrn(h);h-- >0;)i.isOdd()&&i.iadd(c),i.iushrn(1);for(var t=0,a=1;!(n.words[0]&a)&&t<26;++t,a<<=1);if(t>0)for(n.iushrn(t);t-- >0;)f.isOdd()&&f.iadd(c),f.iushrn(1);r.cmp(n)>=0?(r.isub(n),i.isub(f)):(n.isub(r),f.isub(i))}var w;return r.cmpn(1)===0?w=i:w=f,w.cmpn(0)<0&&w.iadd(e),w},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var r=this.clone(),n=e.clone();r.negative=0,n.negative=0;for(var i=0;r.isEven()&&n.isEven();i++)r.iushrn(1),n.iushrn(1);do{for(;r.isEven();)r.iushrn(1);for(;n.isEven();)n.iushrn(1);var f=r.cmp(n);if(f<0){var c=r;r=n,n=c}else if(f===0||n.cmpn(1)===0)break;r.isub(n)}while(!0);return n.iushln(i)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return(this.words[0]&1)===0},o.prototype.isOdd=function(){return(this.words[0]&1)===1},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){p(typeof e=="number");var r=e%26,n=(e-r)/26,i=1<<r;if(this.length<=n)return this._expand(n+1),this.words[n]|=i,this;for(var f=i,c=n;f!==0&&c<this.length;c++){var h=this.words[c]|0;h+=f,f=h>>>26,h&=67108863,this.words[c]=h}return f!==0&&(this.words[c]=f,this.length++),this},o.prototype.isZero=function(){return this.length===1&&this.words[0]===0},o.prototype.cmpn=function(e){var r=e<0;if(this.negative!==0&&!r)return-1;if(this.negative===0&&r)return 1;this.strip();var n;if(this.length>1)n=1;else{r&&(e=-e),p(e<=67108863,"Number is too big");var i=this.words[0]|0;n=i===e?0:i<e?-1:1}return this.negative!==0?-n|0:n},o.prototype.cmp=function(e){if(this.negative!==0&&e.negative===0)return-1;if(this.negative===0&&e.negative!==0)return 1;var r=this.ucmp(e);return this.negative!==0?-r|0:r},o.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length<e.length)return-1;for(var r=0,n=this.length-1;n>=0;n--){var i=this.words[n]|0,f=e.words[n]|0;if(i!==f){i<f?r=-1:i>f&&(r=1);break}}return r},o.prototype.gtn=function(e){return this.cmpn(e)===1},o.prototype.gt=function(e){return this.cmp(e)===1},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 this.cmpn(e)===-1},o.prototype.lt=function(e){return this.cmp(e)===-1},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 this.cmpn(e)===0},o.prototype.eq=function(e){return this.cmp(e)===0},o.red=function(e){return new Y(e)},o.prototype.toRed=function(e){return p(!this.red,"Already a number in reduction context"),p(this.negative===0,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return p(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 p(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return p(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return p(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return p(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return p(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return p(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return p(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return p(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return p(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return p(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return p(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return p(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return p(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return p(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var L={k256:null,p224:null,p192:null,p25519:null};function N(u,e){this.name=u,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}N.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},N.prototype.ireduce=function(e){var r=e,n;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),n=r.bitLength();while(n>this.n);var i=n<this.n?-1:r.ucmp(this.p);return i===0?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):r.strip!==void 0?r.strip():r._strip(),r},N.prototype.split=function(e,r){e.iushrn(this.n,0,r)},N.prototype.imulK=function(e){return e.imul(this.k)};function j(){N.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}I(j,N),j.prototype.split=function(e,r){for(var n=4194303,i=Math.min(e.length,9),f=0;f<i;f++)r.words[f]=e.words[f];if(r.length=i,e.length<=9){e.words[0]=0,e.length=1;return}var c=e.words[9];for(r.words[r.length++]=c&n,f=10;f<e.length;f++){var h=e.words[f]|0;e.words[f-10]=(h&n)<<4|c>>>22,c=h}c>>>=22,e.words[f-10]=c,c===0&&e.length>10?e.length-=10:e.length-=9},j.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var r=0,n=0;n<e.length;n++){var i=e.words[n]|0;r+=i*977,e.words[n]=r&67108863,r=i*64+(r/67108864|0)}return e.words[e.length-1]===0&&(e.length--,e.words[e.length-1]===0&&e.length--),e};function K(){N.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}I(K,N);function $(){N.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}I($,N);function Q(){N.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}I(Q,N),Q.prototype.imulK=function(e){for(var r=0,n=0;n<e.length;n++){var i=(e.words[n]|0)*19+r,f=i&67108863;i>>>=26,e.words[n]=f,r=i}return r!==0&&(e.words[e.length++]=r),e},o._prime=function(e){if(L[e])return L[e];var r;if(e==="k256")r=new j;else if(e==="p224")r=new K;else if(e==="p192")r=new $;else if(e==="p25519")r=new Q;else throw new Error("Unknown prime "+e);return L[e]=r,r};function Y(u){if(typeof u=="string"){var e=o._prime(u);this.m=e.p,this.prime=e}else p(u.gtn(1),"modulus must be greater than 1"),this.m=u,this.prime=null}Y.prototype._verify1=function(e){p(e.negative===0,"red works only with positives"),p(e.red,"red works only with red numbers")},Y.prototype._verify2=function(e,r){p((e.negative|r.negative)===0,"red works only with positives"),p(e.red&&e.red===r.red,"red works only with red numbers")},Y.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},Y.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},Y.prototype.add=function(e,r){this._verify2(e,r);var n=e.add(r);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},Y.prototype.iadd=function(e,r){this._verify2(e,r);var n=e.iadd(r);return n.cmp(this.m)>=0&&n.isub(this.m),n},Y.prototype.sub=function(e,r){this._verify2(e,r);var n=e.sub(r);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},Y.prototype.isub=function(e,r){this._verify2(e,r);var n=e.isub(r);return n.cmpn(0)<0&&n.iadd(this.m),n},Y.prototype.shl=function(e,r){return this._verify1(e),this.imod(e.ushln(r))},Y.prototype.imul=function(e,r){return this._verify2(e,r),this.imod(e.imul(r))},Y.prototype.mul=function(e,r){return this._verify2(e,r),this.imod(e.mul(r))},Y.prototype.isqr=function(e){return this.imul(e,e.clone())},Y.prototype.sqr=function(e){return this.mul(e,e)},Y.prototype.sqrt=function(e){if(e.isZero())return e.clone();var r=this.m.andln(3);if(p(r%2===1),r===3){var n=this.m.add(new o(1)).iushrn(2);return this.pow(e,n)}for(var i=this.m.subn(1),f=0;!i.isZero()&&i.andln(1)===0;)f++,i.iushrn(1);p(!i.isZero());var c=new o(1).toRed(this),h=c.redNeg(),s=this.m.subn(1).iushrn(1),t=this.m.bitLength();for(t=new o(2*t*t).toRed(this);this.pow(t,s).cmp(h)!==0;)t.redIAdd(h);for(var a=this.pow(t,i),w=this.pow(e,i.addn(1).iushrn(1)),D=this.pow(e,i),Z=f;D.cmp(c)!==0;){for(var F=D,V=0;F.cmp(c)!==0;V++)F=F.redSqr();p(V<Z);var q=this.pow(a,new o(1).iushln(Z-V-1));w=w.redMul(q),a=q.redSqr(),D=D.redMul(a),Z=V}return w},Y.prototype.invm=function(e){var r=e._invmp(this.m);return r.negative!==0?(r.negative=0,this.imod(r).redNeg()):this.imod(r)},Y.prototype.pow=function(e,r){if(r.isZero())return new o(1).toRed(this);if(r.cmpn(1)===0)return e.clone();var n=4,i=new Array(1<<n);i[0]=new o(1).toRed(this),i[1]=e;for(var f=2;f<i.length;f++)i[f]=this.mul(i[f-1],e);var c=i[0],h=0,s=0,t=r.bitLength()%26;for(t===0&&(t=26),f=r.length-1;f>=0;f--){for(var a=r.words[f],w=t-1;w>=0;w--){var D=a>>w&1;if(c!==i[0]&&(c=this.sqr(c)),D===0&&h===0){s=0;continue}h<<=1,h|=D,s++,!(s!==n&&(f!==0||w!==0))&&(c=this.mul(c,i[h]),s=0,h=0)}t=26}return c},Y.prototype.convertTo=function(e){var r=e.umod(this.m);return r===e?r.clone():r},Y.prototype.convertFrom=function(e){var r=e.clone();return r.red=null,r},o.mont=function(e){return new ee(e)};function ee(u){Y.call(this,u),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)}I(ee,Y),ee.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},ee.prototype.convertFrom=function(e){var r=this.imod(e.mul(this.rinv));return r.red=null,r},ee.prototype.imul=function(e,r){if(e.isZero()||r.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(r),i=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),f=n.isub(i).iushrn(this.shift),c=f;return f.cmp(this.m)>=0?c=f.isub(this.m):f.cmpn(0)<0&&(c=f.iadd(this.m)),c._forceRed(this)},ee.prototype.mul=function(e,r){if(e.isZero()||r.isZero())return new o(0)._forceRed(this);var n=e.mul(r),i=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),f=n.isub(i).iushrn(this.shift),c=f;return f.cmp(this.m)>=0?c=f.isub(this.m):f.cmpn(0)<0&&(c=f.iadd(this.m)),c._forceRed(this)},ee.prototype.invm=function(e){var r=this.imod(e._invmp(this.m).mul(this.r2));return r._forceRed(this)}}(fe,this)},7108:(fe,x,T)=>{"use strict";var S=T(6698),y=T(8276),p=T(6011),I=T(2802),o=T(6168);function m(l){o.call(this,"digest"),this._hash=l}S(m,o),m.prototype._update=function(l){this._hash.update(l)},m.prototype._final=function(){return this._hash.digest()},fe.exports=function(g){return g=g.toLowerCase(),g==="md5"?new y:g==="rmd160"||g==="ripemd160"?new p:new m(I(g))}},320:(fe,x,T)=>{var S=T(8276);fe.exports=function(y){return new S().update(y).digest()}},3507:(fe,x,T)=>{"use strict";var S=T(6698),y=T(1800),p=T(6168),I=T(2861).Buffer,o=T(320),m=T(6011),l=T(2802),g=I.alloc(128);function M(E,d){p.call(this,"digest"),typeof d=="string"&&(d=I.from(d));var A=E==="sha512"||E==="sha384"?128:64;if(this._alg=E,this._key=d,d.length>A){var v=E==="rmd160"?new m:l(E);d=v.update(d).digest()}else d.length<A&&(d=I.concat([d,g],A));for(var b=this._ipad=I.allocUnsafe(A),k=this._opad=I.allocUnsafe(A),B=0;B<A;B++)b[B]=d[B]^54,k[B]=d[B]^92;this._hash=E==="rmd160"?new m:l(E),this._hash.update(b)}S(M,p),M.prototype._update=function(E){this._hash.update(E)},M.prototype._final=function(){var E=this._hash.digest(),d=this._alg==="rmd160"?new m:l(this._alg);return d.update(this._opad).update(E).digest()},fe.exports=function(d,A){return d=d.toLowerCase(),d==="rmd160"||d==="ripemd160"?new M("rmd160",A):d==="md5"?new y(o,A):new M(d,A)}},1800:(fe,x,T)=>{"use strict";var S=T(6698),y=T(2861).Buffer,p=T(6168),I=y.alloc(128),o=64;function m(l,g){p.call(this,"digest"),typeof g=="string"&&(g=y.from(g)),this._alg=l,this._key=g,g.length>o?g=l(g):g.length<o&&(g=y.concat([g,I],o));for(var M=this._ipad=y.allocUnsafe(o),E=this._opad=y.allocUnsafe(o),d=0;d<o;d++)M[d]=g[d]^54,E[d]=g[d]^92;this._hash=[M]}S(m,p),m.prototype._update=function(l){this._hash.push(l)},m.prototype._final=function(){var l=this._alg(y.concat(this._hash));return this._alg(y.concat([this._opad,l]))},fe.exports=m},4945:function(fe,x){var T=typeof self<"u"?self:this,S=function(){function p(){this.fetch=!1,this.DOMException=T.DOMException}return p.prototype=T,new p}();(function(p){var I=function(o){var m={searchParams:"URLSearchParams"in p,iterable:"Symbol"in p&&"iterator"in Symbol,blob:"FileReader"in p&&"Blob"in p&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in p,arrayBuffer:"ArrayBuffer"in p};function l(r){return r&&DataView.prototype.isPrototypeOf(r)}if(m.arrayBuffer)var g=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],M=ArrayBuffer.isView||function(r){return r&&g.indexOf(Object.prototype.toString.call(r))>-1};function E(r){if(typeof r!="string"&&(r=String(r)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(r))throw new TypeError("Invalid character in header field name");return r.toLowerCase()}function d(r){return typeof r!="string"&&(r=String(r)),r}function A(r){var n={next:function(){var i=r.shift();return{done:i===void 0,value:i}}};return m.iterable&&(n[Symbol.iterator]=function(){return n}),n}function v(r){this.map={},r instanceof v?r.forEach(function(n,i){this.append(i,n)},this):Array.isArray(r)?r.forEach(function(n){this.append(n[0],n[1])},this):r&&Object.getOwnPropertyNames(r).forEach(function(n){this.append(n,r[n])},this)}v.prototype.append=function(r,n){r=E(r),n=d(n);var i=this.map[r];this.map[r]=i?i+", "+n:n},v.prototype.delete=function(r){delete this.map[E(r)]},v.prototype.get=function(r){return r=E(r),this.has(r)?this.map[r]:null},v.prototype.has=function(r){return this.map.hasOwnProperty(E(r))},v.prototype.set=function(r,n){this.map[E(r)]=d(n)},v.prototype.forEach=function(r,n){for(var i in this.map)this.map.hasOwnProperty(i)&&r.call(n,this.map[i],i,this)},v.prototype.keys=function(){var r=[];return this.forEach(function(n,i){r.push(i)}),A(r)},v.prototype.values=function(){var r=[];return this.forEach(function(n){r.push(n)}),A(r)},v.prototype.entries=function(){var r=[];return this.forEach(function(n,i){r.push([i,n])}),A(r)},m.iterable&&(v.prototype[Symbol.iterator]=v.prototype.entries);function b(r){if(r.bodyUsed)return Promise.reject(new TypeError("Already read"));r.bodyUsed=!0}function k(r){return new Promise(function(n,i){r.onload=function(){n(r.result)},r.onerror=function(){i(r.error)}})}function B(r){var n=new FileReader,i=k(n);return n.readAsArrayBuffer(r),i}function U(r){var n=new FileReader,i=k(n);return n.readAsText(r),i}function C(r){for(var n=new Uint8Array(r),i=new Array(n.length),f=0;f<n.length;f++)i[f]=String.fromCharCode(n[f]);return i.join("")}function L(r){if(r.slice)return r.slice(0);var n=new Uint8Array(r.byteLength);return n.set(new Uint8Array(r)),n.buffer}function N(){return this.bodyUsed=!1,this._initBody=function(r){this._bodyInit=r,r?typeof r=="string"?this._bodyText=r:m.blob&&Blob.prototype.isPrototypeOf(r)?this._bodyBlob=r:m.formData&&FormData.prototype.isPrototypeOf(r)?this._bodyFormData=r:m.searchParams&&URLSearchParams.prototype.isPrototypeOf(r)?this._bodyText=r.toString():m.arrayBuffer&&m.blob&&l(r)?(this._bodyArrayBuffer=L(r.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):m.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(r)||M(r))?this._bodyArrayBuffer=L(r):this._bodyText=r=Object.prototype.toString.call(r):this._bodyText="",this.headers.get("content-type")||(typeof r=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):m.searchParams&&URLSearchParams.prototype.isPrototypeOf(r)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},m.blob&&(this.blob=function(){var r=b(this);if(r)return r;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?b(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(B)}),this.text=function(){var r=b(this);if(r)return r;if(this._bodyBlob)return U(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(C(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},m.formData&&(this.formData=function(){return this.text().then(Q)}),this.json=function(){return this.text().then(JSON.parse)},this}var j=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function K(r){var n=r.toUpperCase();return j.indexOf(n)>-1?n:r}function $(r,n){n=n||{};var i=n.body;if(r instanceof $){if(r.bodyUsed)throw new TypeError("Already read");this.url=r.url,this.credentials=r.credentials,n.headers||(this.headers=new v(r.headers)),this.method=r.method,this.mode=r.mode,this.signal=r.signal,!i&&r._bodyInit!=null&&(i=r._bodyInit,r.bodyUsed=!0)}else this.url=String(r);if(this.credentials=n.credentials||this.credentials||"same-origin",(n.headers||!this.headers)&&(this.headers=new v(n.headers)),this.method=K(n.method||this.method||"GET"),this.mode=n.mode||this.mode||null,this.signal=n.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}$.prototype.clone=function(){return new $(this,{body:this._bodyInit})};function Q(r){var n=new FormData;return r.trim().split("&").forEach(function(i){if(i){var f=i.split("="),c=f.shift().replace(/\+/g," "),h=f.join("=").replace(/\+/g," ");n.append(decodeURIComponent(c),decodeURIComponent(h))}}),n}function Y(r){var n=new v,i=r.replace(/\r?\n[\t ]+/g," ");return i.split(/\r?\n/).forEach(function(f){var c=f.split(":"),h=c.shift().trim();if(h){var s=c.join(":").trim();n.append(h,s)}}),n}N.call($.prototype);function ee(r,n){n||(n={}),this.type="default",this.status=n.status===void 0?200:n.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in n?n.statusText:"OK",this.headers=new v(n.headers),this.url=n.url||"",this._initBody(r)}N.call(ee.prototype),ee.prototype.clone=function(){return new ee(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new v(this.headers),url:this.url})},ee.error=function(){var r=new ee(null,{status:0,statusText:""});return r.type="error",r};var u=[301,302,303,307,308];ee.redirect=function(r,n){if(u.indexOf(n)===-1)throw new RangeError("Invalid status code");return new ee(null,{status:n,headers:{location:r}})},o.DOMException=p.DOMException;try{new o.DOMException}catch{o.DOMException=function(n,i){this.message=n,this.name=i;var f=Error(n);this.stack=f.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function e(r,n){return new Promise(function(i,f){var c=new $(r,n);if(c.signal&&c.signal.aborted)return f(new o.DOMException("Aborted","AbortError"));var h=new XMLHttpRequest;function s(){h.abort()}h.onload=function(){var t={status:h.status,statusText:h.statusText,headers:Y(h.getAllResponseHeaders()||"")};t.url="responseURL"in h?h.responseURL:t.headers.get("X-Request-URL");var a="response"in h?h.response:h.responseText;i(new ee(a,t))},h.onerror=function(){f(new TypeError("Network request failed"))},h.ontimeout=function(){f(new TypeError("Network request failed"))},h.onabort=function(){f(new o.DOMException("Aborted","AbortError"))},h.open(c.method,c.url,!0),c.credentials==="include"?h.withCredentials=!0:c.credentials==="omit"&&(h.withCredentials=!1),"responseType"in h&&m.blob&&(h.responseType="blob"),c.headers.forEach(function(t,a){h.setRequestHeader(a,t)}),c.signal&&(c.signal.addEventListener("abort",s),h.onreadystatechange=function(){h.readyState===4&&c.signal.removeEventListener("abort",s)}),h.send(typeof c._bodyInit>"u"?null:c._bodyInit)})}return e.polyfill=!0,p.fetch||(p.fetch=e,p.Headers=v,p.Request=$,p.Response=ee),o.Headers=v,o.Request=$,o.Response=ee,o.fetch=e,Object.defineProperty(o,"__esModule",{value:!0}),o}({})})(S),S.fetch.ponyfill=!0,delete S.fetch.polyfill;var y=S;x=y.fetch,x.default=y.fetch,x.fetch=y.fetch,x.Headers=y.Headers,x.Request=y.Request,x.Response=y.Response,fe.exports=x},1565:(fe,x,T)=>{"use strict";x.randomBytes=x.rng=x.pseudoRandomBytes=x.prng=T(3209),x.createHash=x.Hash=T(7108),x.createHmac=x.Hmac=T(3507);var S=T(5715),y=Object.keys(S),p=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(y);x.getHashes=function(){return p};var I=T(8396);x.pbkdf2=I.pbkdf2,x.pbkdf2Sync=I.pbkdf2Sync;var o=T(125);x.Cipher=o.Cipher,x.createCipher=o.createCipher,x.Cipheriv=o.Cipheriv,x.createCipheriv=o.createCipheriv,x.Decipher=o.Decipher,x.createDecipher=o.createDecipher,x.Decipheriv=o.Decipheriv,x.createDecipheriv=o.createDecipheriv,x.getCiphers=o.getCiphers,x.listCiphers=o.listCiphers;var m=T(5380);x.DiffieHellmanGroup=m.DiffieHellmanGroup,x.createDiffieHellmanGroup=m.createDiffieHellmanGroup,x.getDiffieHellman=m.getDiffieHellman,x.createDiffieHellman=m.createDiffieHellman,x.DiffieHellman=m.DiffieHellman;var l=T(20);x.createSign=l.createSign,x.Sign=l.Sign,x.createVerify=l.createVerify,x.Verify=l.Verify,x.createECDH=T(1324);var g=T(7168);x.publicEncrypt=g.publicEncrypt,x.privateEncrypt=g.privateEncrypt,x.publicDecrypt=g.publicDecrypt,x.privateDecrypt=g.privateDecrypt;var M=T(6983);x.randomFill=M.randomFill,x.randomFillSync=M.randomFillSync,x.createCredentials=function(){throw new Error(["sorry, createCredentials is not implemented yet","we accept pull requests","https://github.com/crypto-browserify/crypto-browserify"].join(`
|
|
37
37
|
`))},x.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}},8330:fe=>{fe.exports=[{code:"AED",number:"784",digits:2,currency:"UAE Dirham",countries:["United Arab Emirates (The)"]},{code:"AFN",number:"971",digits:2,currency:"Afghani",countries:["Afghanistan"]},{code:"ALL",number:"008",digits:2,currency:"Lek",countries:["Albania"]},{code:"AMD",number:"051",digits:2,currency:"Armenian Dram",countries:["Armenia"]},{code:"ANG",number:"532",digits:2,currency:"Netherlands Antillean Guilder",countries:["Cura\xE7Ao","Sint Maarten (Dutch Part)"]},{code:"AOA",number:"973",digits:2,currency:"Kwanza",countries:["Angola"]},{code:"ARS",number:"032",digits:2,currency:"Argentine Peso",countries:["Argentina"]},{code:"AUD",number:"036",digits:2,currency:"Australian Dollar",countries:["Australia","Christmas Island","Cocos (Keeling) Islands (The)","Heard Island And Mcdonald Islands","Kiribati","Nauru","Norfolk Island","Tuvalu"]},{code:"AWG",number:"533",digits:2,currency:"Aruban Florin",countries:["Aruba"]},{code:"AZN",number:"944",digits:2,currency:"Azerbaijan Manat",countries:["Azerbaijan"]},{code:"BAM",number:"977",digits:2,currency:"Convertible Mark",countries:["Bosnia And Herzegovina"]},{code:"BBD",number:"052",digits:2,currency:"Barbados Dollar",countries:["Barbados"]},{code:"BDT",number:"050",digits:2,currency:"Taka",countries:["Bangladesh"]},{code:"BGN",number:"975",digits:2,currency:"Bulgarian Lev",countries:["Bulgaria"]},{code:"BHD",number:"048",digits:3,currency:"Bahraini Dinar",countries:["Bahrain"]},{code:"BIF",number:"108",digits:0,currency:"Burundi Franc",countries:["Burundi"]},{code:"BMD",number:"060",digits:2,currency:"Bermudian Dollar",countries:["Bermuda"]},{code:"BND",number:"096",digits:2,currency:"Brunei Dollar",countries:["Brunei Darussalam"]},{code:"BOB",number:"068",digits:2,currency:"Boliviano",countries:["Bolivia (Plurinational State Of)"]},{code:"BOV",number:"984",digits:2,currency:"Mvdol",countries:["Bolivia (Plurinational State Of)"]},{code:"BRL",number:"986",digits:2,currency:"Brazilian Real",countries:["Brazil"]},{code:"BSD",number:"044",digits:2,currency:"Bahamian Dollar",countries:["Bahamas (The)"]},{code:"BTN",number:"064",digits:2,currency:"Ngultrum",countries:["Bhutan"]},{code:"BWP",number:"072",digits:2,currency:"Pula",countries:["Botswana"]},{code:"BYN",number:"933",digits:2,currency:"Belarusian Ruble",countries:["Belarus"]},{code:"BZD",number:"084",digits:2,currency:"Belize Dollar",countries:["Belize"]},{code:"CAD",number:"124",digits:2,currency:"Canadian Dollar",countries:["Canada"]},{code:"CDF",number:"976",digits:2,currency:"Congolese Franc",countries:["Congo (The Democratic Republic Of The)"]},{code:"CHE",number:"947",digits:2,currency:"WIR Euro",countries:["Switzerland"]},{code:"CHF",number:"756",digits:2,currency:"Swiss Franc",countries:["Liechtenstein","Switzerland"]},{code:"CHW",number:"948",digits:2,currency:"WIR Franc",countries:["Switzerland"]},{code:"CLF",number:"990",digits:4,currency:"Unidad de Fomento",countries:["Chile"]},{code:"CLP",number:"152",digits:0,currency:"Chilean Peso",countries:["Chile"]},{code:"CNY",number:"156",digits:2,currency:"Yuan Renminbi",countries:["China"]},{code:"COP",number:"170",digits:2,currency:"Colombian Peso",countries:["Colombia"]},{code:"COU",number:"970",digits:2,currency:"Unidad de Valor Real",countries:["Colombia"]},{code:"CRC",number:"188",digits:2,currency:"Costa Rican Colon",countries:["Costa Rica"]},{code:"CUC",number:"931",digits:2,currency:"Peso Convertible",countries:["Cuba"]},{code:"CUP",number:"192",digits:2,currency:"Cuban Peso",countries:["Cuba"]},{code:"CVE",number:"132",digits:2,currency:"Cabo Verde Escudo",countries:["Cabo Verde"]},{code:"CZK",number:"203",digits:2,currency:"Czech Koruna",countries:["Czechia"]},{code:"DJF",number:"262",digits:0,currency:"Djibouti Franc",countries:["Djibouti"]},{code:"DKK",number:"208",digits:2,currency:"Danish Krone",countries:["Denmark","Faroe Islands (The)","Greenland"]},{code:"DOP",number:"214",digits:2,currency:"Dominican Peso",countries:["Dominican Republic (The)"]},{code:"DZD",number:"012",digits:2,currency:"Algerian Dinar",countries:["Algeria"]},{code:"EGP",number:"818",digits:2,currency:"Egyptian Pound",countries:["Egypt"]},{code:"ERN",number:"232",digits:2,currency:"Nakfa",countries:["Eritrea"]},{code:"ETB",number:"230",digits:2,currency:"Ethiopian Birr",countries:["Ethiopia"]},{code:"EUR",number:"978",digits:2,currency:"Euro",countries:["Andorra","Austria","Belgium","Cyprus","Estonia","European Union","Finland","France","French Guiana","French Southern Territories (The)","Germany","Greece","Guadeloupe","Holy See (The)","Ireland","Italy","Latvia","Lithuania","Luxembourg","Malta","Martinique","Mayotte","Monaco","Montenegro","Netherlands (The)","Portugal","R\xE9union","Saint Barth\xE9lemy","Saint Martin (French Part)","Saint Pierre And Miquelon","San Marino","Slovakia","Slovenia","Spain","\xC5land Islands"]},{code:"FJD",number:"242",digits:2,currency:"Fiji Dollar",countries:["Fiji"]},{code:"FKP",number:"238",digits:2,currency:"Falkland Islands Pound",countries:["Falkland Islands (The) [Malvinas]"]},{code:"GBP",number:"826",digits:2,currency:"Pound Sterling",countries:["Guernsey","Isle Of Man","Jersey","United Kingdom Of Great Britain And Northern Ireland (The)"]},{code:"GEL",number:"981",digits:2,currency:"Lari",countries:["Georgia"]},{code:"GHS",number:"936",digits:2,currency:"Ghana Cedi",countries:["Ghana"]},{code:"GIP",number:"292",digits:2,currency:"Gibraltar Pound",countries:["Gibraltar"]},{code:"GMD",number:"270",digits:2,currency:"Dalasi",countries:["Gambia (The)"]},{code:"GNF",number:"324",digits:0,currency:"Guinean Franc",countries:["Guinea"]},{code:"GTQ",number:"320",digits:2,currency:"Quetzal",countries:["Guatemala"]},{code:"GYD",number:"328",digits:2,currency:"Guyana Dollar",countries:["Guyana"]},{code:"HKD",number:"344",digits:2,currency:"Hong Kong Dollar",countries:["Hong Kong"]},{code:"HNL",number:"340",digits:2,currency:"Lempira",countries:["Honduras"]},{code:"HRK",number:"191",digits:2,currency:"Kuna",countries:["Croatia"]},{code:"HTG",number:"332",digits:2,currency:"Gourde",countries:["Haiti"]},{code:"HUF",number:"348",digits:2,currency:"Forint",countries:["Hungary"]},{code:"IDR",number:"360",digits:2,currency:"Rupiah",countries:["Indonesia"]},{code:"ILS",number:"376",digits:2,currency:"New Israeli Sheqel",countries:["Israel"]},{code:"INR",number:"356",digits:2,currency:"Indian Rupee",countries:["Bhutan","India"]},{code:"IQD",number:"368",digits:3,currency:"Iraqi Dinar",countries:["Iraq"]},{code:"IRR",number:"364",digits:2,currency:"Iranian Rial",countries:["Iran (Islamic Republic Of)"]},{code:"ISK",number:"352",digits:0,currency:"Iceland Krona",countries:["Iceland"]},{code:"JMD",number:"388",digits:2,currency:"Jamaican Dollar",countries:["Jamaica"]},{code:"JOD",number:"400",digits:3,currency:"Jordanian Dinar",countries:["Jordan"]},{code:"JPY",number:"392",digits:0,currency:"Yen",countries:["Japan"]},{code:"KES",number:"404",digits:2,currency:"Kenyan Shilling",countries:["Kenya"]},{code:"KGS",number:"417",digits:2,currency:"Som",countries:["Kyrgyzstan"]},{code:"KHR",number:"116",digits:2,currency:"Riel",countries:["Cambodia"]},{code:"KMF",number:"174",digits:0,currency:"Comorian Franc ",countries:["Comoros (The)"]},{code:"KPW",number:"408",digits:2,currency:"North Korean Won",countries:["Korea (The Democratic People's Republic Of)"]},{code:"KRW",number:"410",digits:0,currency:"Won",countries:["Korea (The Republic Of)"]},{code:"KWD",number:"414",digits:3,currency:"Kuwaiti Dinar",countries:["Kuwait"]},{code:"KYD",number:"136",digits:2,currency:"Cayman Islands Dollar",countries:["Cayman Islands (The)"]},{code:"KZT",number:"398",digits:2,currency:"Tenge",countries:["Kazakhstan"]},{code:"LAK",number:"418",digits:2,currency:"Lao Kip",countries:["Lao People's Democratic Republic (The)"]},{code:"LBP",number:"422",digits:2,currency:"Lebanese Pound",countries:["Lebanon"]},{code:"LKR",number:"144",digits:2,currency:"Sri Lanka Rupee",countries:["Sri Lanka"]},{code:"LRD",number:"430",digits:2,currency:"Liberian Dollar",countries:["Liberia"]},{code:"LSL",number:"426",digits:2,currency:"Loti",countries:["Lesotho"]},{code:"LYD",number:"434",digits:3,currency:"Libyan Dinar",countries:["Libya"]},{code:"MAD",number:"504",digits:2,currency:"Moroccan Dirham",countries:["Morocco","Western Sahara"]},{code:"MDL",number:"498",digits:2,currency:"Moldovan Leu",countries:["Moldova (The Republic Of)"]},{code:"MGA",number:"969",digits:2,currency:"Malagasy Ariary",countries:["Madagascar"]},{code:"MKD",number:"807",digits:2,currency:"Denar",countries:["Macedonia (The Former Yugoslav Republic Of)"]},{code:"MMK",number:"104",digits:2,currency:"Kyat",countries:["Myanmar"]},{code:"MNT",number:"496",digits:2,currency:"Tugrik",countries:["Mongolia"]},{code:"MOP",number:"446",digits:2,currency:"Pataca",countries:["Macao"]},{code:"MRU",number:"929",digits:2,currency:"Ouguiya",countries:["Mauritania"]},{code:"MUR",number:"480",digits:2,currency:"Mauritius Rupee",countries:["Mauritius"]},{code:"MVR",number:"462",digits:2,currency:"Rufiyaa",countries:["Maldives"]},{code:"MWK",number:"454",digits:2,currency:"Malawi Kwacha",countries:["Malawi"]},{code:"MXN",number:"484",digits:2,currency:"Mexican Peso",countries:["Mexico"]},{code:"MXV",number:"979",digits:2,currency:"Mexican Unidad de Inversion (UDI)",countries:["Mexico"]},{code:"MYR",number:"458",digits:2,currency:"Malaysian Ringgit",countries:["Malaysia"]},{code:"MZN",number:"943",digits:2,currency:"Mozambique Metical",countries:["Mozambique"]},{code:"NAD",number:"516",digits:2,currency:"Namibia Dollar",countries:["Namibia"]},{code:"NGN",number:"566",digits:2,currency:"Naira",countries:["Nigeria"]},{code:"NIO",number:"558",digits:2,currency:"Cordoba Oro",countries:["Nicaragua"]},{code:"NOK",number:"578",digits:2,currency:"Norwegian Krone",countries:["Bouvet Island","Norway","Svalbard And Jan Mayen"]},{code:"NPR",number:"524",digits:2,currency:"Nepalese Rupee",countries:["Nepal"]},{code:"NZD",number:"554",digits:2,currency:"New Zealand Dollar",countries:["Cook Islands (The)","New Zealand","Niue","Pitcairn","Tokelau"]},{code:"OMR",number:"512",digits:3,currency:"Rial Omani",countries:["Oman"]},{code:"PAB",number:"590",digits:2,currency:"Balboa",countries:["Panama"]},{code:"PEN",number:"604",digits:2,currency:"Sol",countries:["Peru"]},{code:"PGK",number:"598",digits:2,currency:"Kina",countries:["Papua New Guinea"]},{code:"PHP",number:"608",digits:2,currency:"Philippine Piso",countries:["Philippines (The)"]},{code:"PKR",number:"586",digits:2,currency:"Pakistan Rupee",countries:["Pakistan"]},{code:"PLN",number:"985",digits:2,currency:"Zloty",countries:["Poland"]},{code:"PYG",number:"600",digits:0,currency:"Guarani",countries:["Paraguay"]},{code:"QAR",number:"634",digits:2,currency:"Qatari Rial",countries:["Qatar"]},{code:"RON",number:"946",digits:2,currency:"Romanian Leu",countries:["Romania"]},{code:"RSD",number:"941",digits:2,currency:"Serbian Dinar",countries:["Serbia"]},{code:"RUB",number:"643",digits:2,currency:"Russian Ruble",countries:["Russian Federation (The)"]},{code:"RWF",number:"646",digits:0,currency:"Rwanda Franc",countries:["Rwanda"]},{code:"SAR",number:"682",digits:2,currency:"Saudi Riyal",countries:["Saudi Arabia"]},{code:"SBD",number:"090",digits:2,currency:"Solomon Islands Dollar",countries:["Solomon Islands"]},{code:"SCR",number:"690",digits:2,currency:"Seychelles Rupee",countries:["Seychelles"]},{code:"SDG",number:"938",digits:2,currency:"Sudanese Pound",countries:["Sudan (The)"]},{code:"SEK",number:"752",digits:2,currency:"Swedish Krona",countries:["Sweden"]},{code:"SGD",number:"702",digits:2,currency:"Singapore Dollar",countries:["Singapore"]},{code:"SHP",number:"654",digits:2,currency:"Saint Helena Pound",countries:["Saint Helena, Ascension And Tristan Da Cunha"]},{code:"SLL",number:"694",digits:2,currency:"Leone",countries:["Sierra Leone"]},{code:"SOS",number:"706",digits:2,currency:"Somali Shilling",countries:["Somalia"]},{code:"SRD",number:"968",digits:2,currency:"Surinam Dollar",countries:["Suriname"]},{code:"SSP",number:"728",digits:2,currency:"South Sudanese Pound",countries:["South Sudan"]},{code:"STN",number:"930",digits:2,currency:"Dobra",countries:["Sao Tome And Principe"]},{code:"SVC",number:"222",digits:2,currency:"El Salvador Colon",countries:["El Salvador"]},{code:"SYP",number:"760",digits:2,currency:"Syrian Pound",countries:["Syrian Arab Republic"]},{code:"SZL",number:"748",digits:2,currency:"Lilangeni",countries:["Swaziland"]},{code:"THB",number:"764",digits:2,currency:"Baht",countries:["Thailand"]},{code:"TJS",number:"972",digits:2,currency:"Somoni",countries:["Tajikistan"]},{code:"TMT",number:"934",digits:2,currency:"Turkmenistan New Manat",countries:["Turkmenistan"]},{code:"TND",number:"788",digits:3,currency:"Tunisian Dinar",countries:["Tunisia"]},{code:"TOP",number:"776",digits:2,currency:"Pa'anga",countries:["Tonga"]},{code:"TRY",number:"949",digits:2,currency:"Turkish Lira",countries:["Turkey"]},{code:"TTD",number:"780",digits:2,currency:"Trinidad and Tobago Dollar",countries:["Trinidad And Tobago"]},{code:"TWD",number:"901",digits:2,currency:"New Taiwan Dollar",countries:["Taiwan (Province Of China)"]},{code:"TZS",number:"834",digits:2,currency:"Tanzanian Shilling",countries:["Tanzania, United Republic Of"]},{code:"UAH",number:"980",digits:2,currency:"Hryvnia",countries:["Ukraine"]},{code:"UGX",number:"800",digits:0,currency:"Uganda Shilling",countries:["Uganda"]},{code:"USD",number:"840",digits:2,currency:"US Dollar",countries:["American Samoa","Bonaire, Sint Eustatius And Saba","British Indian Ocean Territory (The)","Ecuador","El Salvador","Guam","Haiti","Marshall Islands (The)","Micronesia (Federated States Of)","Northern Mariana Islands (The)","Palau","Panama","Puerto Rico","Timor-Leste","Turks And Caicos Islands (The)","United States Minor Outlying Islands (The)","United States Of America (The)","Virgin Islands (British)","Virgin Islands (U.S.)"]},{code:"USN",number:"997",digits:2,currency:"US Dollar (Next day)",countries:["United States Of America (The)"]},{code:"UYI",number:"940",digits:0,currency:"Uruguay Peso en Unidades Indexadas (URUIURUI)",countries:["Uruguay"]},{code:"UYU",number:"858",digits:2,currency:"Peso Uruguayo",countries:["Uruguay"]},{code:"UZS",number:"860",digits:2,currency:"Uzbekistan Sum",countries:["Uzbekistan"]},{code:"VEF",number:"937",digits:2,currency:"Bol\xEDvar",countries:["Venezuela (Bolivarian Republic Of)"]},{code:"VND",number:"704",digits:0,currency:"Dong",countries:["Viet Nam"]},{code:"VUV",number:"548",digits:0,currency:"Vatu",countries:["Vanuatu"]},{code:"WST",number:"882",digits:2,currency:"Tala",countries:["Samoa"]},{code:"XAF",number:"950",digits:0,currency:"CFA Franc BEAC",countries:["Cameroon","Central African Republic (The)","Chad","Congo (The)","Equatorial Guinea","Gabon"]},{code:"XAG",number:"961",digits:0,currency:"Silver",countries:[]},{code:"XAU",number:"959",digits:0,currency:"Gold",countries:[]},{code:"XBA",number:"955",digits:0,currency:"Bond Markets Unit European Composite Unit (EURCO)",countries:[]},{code:"XBB",number:"956",digits:0,currency:"Bond Markets Unit European Monetary Unit (E.M.U.-6)",countries:[]},{code:"XBC",number:"957",digits:0,currency:"Bond Markets Unit European Unit of Account 9 (E.U.A.-9)",countries:[]},{code:"XBD",number:"958",digits:0,currency:"Bond Markets Unit European Unit of Account 17 (E.U.A.-17)",countries:[]},{code:"XCD",number:"951",digits:2,currency:"East Caribbean Dollar",countries:["Anguilla","Antigua And Barbuda","Dominica","Grenada","Montserrat","Saint Kitts And Nevis","Saint Lucia","Saint Vincent And The Grenadines"]},{code:"XDR",number:"960",digits:0,currency:"SDR (Special Drawing Right)",countries:["International Monetary Fund (Imf) "]},{code:"XOF",number:"952",digits:0,currency:"CFA Franc BCEAO",countries:["Benin","Burkina Faso","C\xF4te d'Ivoire","Guinea-Bissau","Mali","Niger (The)","Senegal","Togo"]},{code:"XPD",number:"964",digits:0,currency:"Palladium",countries:[]},{code:"XPF",number:"953",digits:0,currency:"CFP Franc",countries:["French Polynesia","New Caledonia","Wallis And Futuna"]},{code:"XPT",number:"962",digits:0,currency:"Platinum",countries:[]},{code:"XSU",number:"994",digits:0,currency:"Sucre",countries:['Sistema Unitario De Compensacion Regional De Pagos "Sucre"']},{code:"XTS",number:"963",digits:0,currency:"Codes specifically reserved for testing purposes",countries:[]},{code:"XUA",number:"965",digits:0,currency:"ADB Unit of Account",countries:["Member Countries Of The African Development Bank Group"]},{code:"XXX",number:"999",digits:0,currency:"The codes assigned for transactions where no currency is involved",countries:[]},{code:"YER",number:"886",digits:2,currency:"Yemeni Rial",countries:["Yemen"]},{code:"ZAR",number:"710",digits:2,currency:"Rand",countries:["Lesotho","Namibia","South Africa"]},{code:"ZMW",number:"967",digits:2,currency:"Zambian Kwacha",countries:["Zambia"]},{code:"ZWL",number:"932",digits:2,currency:"Zimbabwe Dollar",countries:["Zimbabwe"]}]},5817:(fe,x,T)=>{var S=T(6341),y=T(726),p=T(8330),I=function(E){return E=E.toUpperCase(),S(p,function(d){return d.code===E})},o=function(E){return E=E.toLowerCase(),p.filter(function(d){return(d.countries.map(function(A){return A.toLowerCase()})||[]).indexOf(E)>-1})},m=function(E){return S(p,function(d){return d.number===String(E)})},l=function(){return p.map(function(E){return E.code})},g=function(){var E=p.map(function(d){return d.number});return E.filter(function(d){if(d)return d})},M=function(){var E=p.filter(function(d){return d.countries}).map(function(d){return d.countries});return y(Array.prototype.concat.apply([],E))};x.code=I,x.country=o,x.number=m,x.codes=l,x.numbers=g,x.countries=M},9560:(fe,x,T)=>{"use strict";x.utils=T(7626),x.Cipher=T(2808),x.DES=T(2211),x.CBC=T(3389),x.EDE=T(5279)},3389:(fe,x,T)=>{"use strict";var S=T(3349),y=T(6698),p={};function I(m){S.equal(m.length,8,"Invalid IV length"),this.iv=new Array(8);for(var l=0;l<this.iv.length;l++)this.iv[l]=m[l]}function o(m){function l(d){m.call(this,d),this._cbcInit()}y(l,m);for(var g=Object.keys(p),M=0;M<g.length;M++){var E=g[M];l.prototype[E]=p[E]}return l.create=function(A){return new l(A)},l}x.instantiate=o,p._cbcInit=function(){var l=new I(this.options.iv);this._cbcState=l},p._update=function(l,g,M,E){var d=this._cbcState,A=this.constructor.super_.prototype,v=d.iv;if(this.type==="encrypt"){for(var b=0;b<this.blockSize;b++)v[b]^=l[g+b];A._update.call(this,v,0,M,E);for(var b=0;b<this.blockSize;b++)v[b]=M[E+b]}else{A._update.call(this,l,g,M,E);for(var b=0;b<this.blockSize;b++)M[E+b]^=v[b];for(var b=0;b<this.blockSize;b++)v[b]=l[g+b]}}},2808:(fe,x,T)=>{"use strict";var S=T(3349);function y(p){this.options=p,this.type=this.options.type,this.blockSize=8,this._init(),this.buffer=new Array(this.blockSize),this.bufferOff=0}fe.exports=y,y.prototype._init=function(){},y.prototype.update=function(I){return I.length===0?[]:this.type==="decrypt"?this._updateDecrypt(I):this._updateEncrypt(I)},y.prototype._buffer=function(I,o){for(var m=Math.min(this.buffer.length-this.bufferOff,I.length-o),l=0;l<m;l++)this.buffer[this.bufferOff+l]=I[o+l];return this.bufferOff+=m,m},y.prototype._flushBuffer=function(I,o){return this._update(this.buffer,0,I,o),this.bufferOff=0,this.blockSize},y.prototype._updateEncrypt=function(I){var o=0,m=0,l=(this.bufferOff+I.length)/this.blockSize|0,g=new Array(l*this.blockSize);this.bufferOff!==0&&(o+=this._buffer(I,o),this.bufferOff===this.buffer.length&&(m+=this._flushBuffer(g,m)));for(var M=I.length-(I.length-o)%this.blockSize;o<M;o+=this.blockSize)this._update(I,o,g,m),m+=this.blockSize;for(;o<I.length;o++,this.bufferOff++)this.buffer[this.bufferOff]=I[o];return g},y.prototype._updateDecrypt=function(I){for(var o=0,m=0,l=Math.ceil((this.bufferOff+I.length)/this.blockSize)-1,g=new Array(l*this.blockSize);l>0;l--)o+=this._buffer(I,o),m+=this._flushBuffer(g,m);return o+=this._buffer(I,o),g},y.prototype.final=function(I){var o;I&&(o=this.update(I));var m;return this.type==="encrypt"?m=this._finalEncrypt():m=this._finalDecrypt(),o?o.concat(m):m},y.prototype._pad=function(I,o){if(o===0)return!1;for(;o<I.length;)I[o++]=0;return!0},y.prototype._finalEncrypt=function(){if(!this._pad(this.buffer,this.bufferOff))return[];var I=new Array(this.blockSize);return this._update(this.buffer,0,I,0),I},y.prototype._unpad=function(I){return I},y.prototype._finalDecrypt=function(){S.equal(this.bufferOff,this.blockSize,"Not enough data to decrypt");var I=new Array(this.blockSize);return this._flushBuffer(I,0),this._unpad(I)}},2211:(fe,x,T)=>{"use strict";var S=T(3349),y=T(6698),p=T(7626),I=T(2808);function o(){this.tmp=new Array(2),this.keys=null}function m(g){I.call(this,g);var M=new o;this._desState=M,this.deriveKeys(M,g.key)}y(m,I),fe.exports=m,m.create=function(M){return new m(M)};var l=[1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1];m.prototype.deriveKeys=function(M,E){M.keys=new Array(32),S.equal(E.length,this.blockSize,"Invalid key length");var d=p.readUInt32BE(E,0),A=p.readUInt32BE(E,4);p.pc1(d,A,M.tmp,0),d=M.tmp[0],A=M.tmp[1];for(var v=0;v<M.keys.length;v+=2){var b=l[v>>>1];d=p.r28shl(d,b),A=p.r28shl(A,b),p.pc2(d,A,M.keys,v)}},m.prototype._update=function(M,E,d,A){var v=this._desState,b=p.readUInt32BE(M,E),k=p.readUInt32BE(M,E+4);p.ip(b,k,v.tmp,0),b=v.tmp[0],k=v.tmp[1],this.type==="encrypt"?this._encrypt(v,b,k,v.tmp,0):this._decrypt(v,b,k,v.tmp,0),b=v.tmp[0],k=v.tmp[1],p.writeUInt32BE(d,b,A),p.writeUInt32BE(d,k,A+4)},m.prototype._pad=function(M,E){for(var d=M.length-E,A=E;A<M.length;A++)M[A]=d;return!0},m.prototype._unpad=function(M){for(var E=M[M.length-1],d=M.length-E;d<M.length;d++)S.equal(M[d],E);return M.slice(0,M.length-E)},m.prototype._encrypt=function(M,E,d,A,v){for(var b=E,k=d,B=0;B<M.keys.length;B+=2){var U=M.keys[B],C=M.keys[B+1];p.expand(k,M.tmp,0),U^=M.tmp[0],C^=M.tmp[1];var L=p.substitute(U,C),N=p.permute(L),j=k;k=(b^N)>>>0,b=j}p.rip(k,b,A,v)},m.prototype._decrypt=function(M,E,d,A,v){for(var b=d,k=E,B=M.keys.length-2;B>=0;B-=2){var U=M.keys[B],C=M.keys[B+1];p.expand(b,M.tmp,0),U^=M.tmp[0],C^=M.tmp[1];var L=p.substitute(U,C),N=p.permute(L),j=b;b=(k^N)>>>0,k=j}p.rip(b,k,A,v)}},5279:(fe,x,T)=>{"use strict";var S=T(3349),y=T(6698),p=T(2808),I=T(2211);function o(l,g){S.equal(g.length,24,"Invalid key length");var M=g.slice(0,8),E=g.slice(8,16),d=g.slice(16,24);l==="encrypt"?this.ciphers=[I.create({type:"encrypt",key:M}),I.create({type:"decrypt",key:E}),I.create({type:"encrypt",key:d})]:this.ciphers=[I.create({type:"decrypt",key:d}),I.create({type:"encrypt",key:E}),I.create({type:"decrypt",key:M})]}function m(l){p.call(this,l);var g=new o(this.type,this.options.key);this._edeState=g}y(m,p),fe.exports=m,m.create=function(g){return new m(g)},m.prototype._update=function(g,M,E,d){var A=this._edeState;A.ciphers[0]._update(g,M,E,d),A.ciphers[1]._update(E,d,E,d),A.ciphers[2]._update(E,d,E,d)},m.prototype._pad=I.prototype._pad,m.prototype._unpad=I.prototype._unpad},7626:(fe,x)=>{"use strict";x.readUInt32BE=function(I,o){var m=I[0+o]<<24|I[1+o]<<16|I[2+o]<<8|I[3+o];return m>>>0},x.writeUInt32BE=function(I,o,m){I[0+m]=o>>>24,I[1+m]=o>>>16&255,I[2+m]=o>>>8&255,I[3+m]=o&255},x.ip=function(I,o,m,l){for(var g=0,M=0,E=6;E>=0;E-=2){for(var d=0;d<=24;d+=8)g<<=1,g|=o>>>d+E&1;for(var d=0;d<=24;d+=8)g<<=1,g|=I>>>d+E&1}for(var E=6;E>=0;E-=2){for(var d=1;d<=25;d+=8)M<<=1,M|=o>>>d+E&1;for(var d=1;d<=25;d+=8)M<<=1,M|=I>>>d+E&1}m[l+0]=g>>>0,m[l+1]=M>>>0},x.rip=function(I,o,m,l){for(var g=0,M=0,E=0;E<4;E++)for(var d=24;d>=0;d-=8)g<<=1,g|=o>>>d+E&1,g<<=1,g|=I>>>d+E&1;for(var E=4;E<8;E++)for(var d=24;d>=0;d-=8)M<<=1,M|=o>>>d+E&1,M<<=1,M|=I>>>d+E&1;m[l+0]=g>>>0,m[l+1]=M>>>0},x.pc1=function(I,o,m,l){for(var g=0,M=0,E=7;E>=5;E--){for(var d=0;d<=24;d+=8)g<<=1,g|=o>>d+E&1;for(var d=0;d<=24;d+=8)g<<=1,g|=I>>d+E&1}for(var d=0;d<=24;d+=8)g<<=1,g|=o>>d+E&1;for(var E=1;E<=3;E++){for(var d=0;d<=24;d+=8)M<<=1,M|=o>>d+E&1;for(var d=0;d<=24;d+=8)M<<=1,M|=I>>d+E&1}for(var d=0;d<=24;d+=8)M<<=1,M|=I>>d+E&1;m[l+0]=g>>>0,m[l+1]=M>>>0},x.r28shl=function(I,o){return I<<o&268435455|I>>>28-o};var T=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];x.pc2=function(I,o,m,l){for(var g=0,M=0,E=T.length>>>1,d=0;d<E;d++)g<<=1,g|=I>>>T[d]&1;for(var d=E;d<T.length;d++)M<<=1,M|=o>>>T[d]&1;m[l+0]=g>>>0,m[l+1]=M>>>0},x.expand=function(I,o,m){var l=0,g=0;l=(I&1)<<5|I>>>27;for(var M=23;M>=15;M-=4)l<<=6,l|=I>>>M&63;for(var M=11;M>=3;M-=4)g|=I>>>M&63,g<<=6;g|=(I&31)<<1|I>>>31,o[m+0]=l>>>0,o[m+1]=g>>>0};var S=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];x.substitute=function(I,o){for(var m=0,l=0;l<4;l++){var g=I>>>18-l*6&63,M=S[l*64+g];m<<=4,m|=M}for(var l=0;l<4;l++){var g=o>>>18-l*6&63,M=S[4*64+l*64+g];m<<=4,m|=M}return m>>>0};var y=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];x.permute=function(I){for(var o=0,m=0;m<y.length;m++)o<<=1,o|=I>>>y[m]&1;return o>>>0},x.padSplit=function(I,o,m){for(var l=I.toString(2);l.length<o;)l="0"+l;for(var g=[],M=0;M<o;M+=m)g.push(l.slice(M,M+m));return g.join(" ")}},5380:(fe,x,T)=>{var S=T(8287).Buffer,y=T(4934),p=T(3241),I=T(4910);function o(g){var M=new S(p[g].prime,"hex"),E=new S(p[g].gen,"hex");return new I(M,E)}var m={binary:!0,hex:!0,base64:!0};function l(g,M,E,d){return S.isBuffer(M)||m[M]===void 0?l(g,"binary",M,E):(M=M||"binary",d=d||"binary",E=E||new S([2]),S.isBuffer(E)||(E=new S(E,d)),typeof g=="number"?new I(y(g,E),E,!0):(S.isBuffer(g)||(g=new S(g,M)),new I(g,E,!0)))}x.DiffieHellmanGroup=x.createDiffieHellmanGroup=x.getDiffieHellman=o,x.createDiffieHellman=x.DiffieHellman=l},4910:(fe,x,T)=>{var S=T(8287).Buffer,y=T(6473),p=T(2244),I=new p,o=new y(24),m=new y(11),l=new y(10),g=new y(3),M=new y(7),E=T(4934),d=T(3209);fe.exports=B;function A(C,L){return L=L||"utf8",S.isBuffer(C)||(C=new S(C,L)),this._pub=new y(C),this}function v(C,L){return L=L||"utf8",S.isBuffer(C)||(C=new S(C,L)),this._priv=new y(C),this}var b={};function k(C,L){var N=L.toString("hex"),j=[N,C.toString(16)].join("_");if(j in b)return b[j];var K=0;if(C.isEven()||!E.simpleSieve||!E.fermatTest(C)||!I.test(C))return K+=1,N==="02"||N==="05"?K+=8:K+=4,b[j]=K,K;I.test(C.shrn(1))||(K+=2);var $;switch(N){case"02":C.mod(o).cmp(m)&&(K+=8);break;case"05":$=C.mod(l),$.cmp(g)&&$.cmp(M)&&(K+=8);break;default:K+=4}return b[j]=K,K}function B(C,L,N){this.setGenerator(L),this.__prime=new y(C),this._prime=y.mont(this.__prime),this._primeLen=C.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,N?(this.setPublicKey=A,this.setPrivateKey=v):this._primeCode=8}Object.defineProperty(B.prototype,"verifyError",{enumerable:!0,get:function(){return typeof this._primeCode!="number"&&(this._primeCode=k(this.__prime,this.__gen)),this._primeCode}}),B.prototype.generateKeys=function(){return this._priv||(this._priv=new y(d(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},B.prototype.computeSecret=function(C){C=new y(C),C=C.toRed(this._prime);var L=C.redPow(this._priv).fromRed(),N=new S(L.toArray()),j=this.getPrime();if(N.length<j.length){var K=new S(j.length-N.length);K.fill(0),N=S.concat([K,N])}return N},B.prototype.getPublicKey=function(L){return U(this._pub,L)},B.prototype.getPrivateKey=function(L){return U(this._priv,L)},B.prototype.getPrime=function(C){return U(this.__prime,C)},B.prototype.getGenerator=function(C){return U(this._gen,C)},B.prototype.setGenerator=function(C,L){return L=L||"utf8",S.isBuffer(C)||(C=new S(C,L)),this.__gen=C,this._gen=new y(C),this};function U(C,L){var N=new S(C.toArray());return L?N.toString(L):N}},4934:(fe,x,T)=>{var S=T(3209);fe.exports=j,j.simpleSieve=L,j.fermatTest=N;var y=T(6473),p=new y(24),I=T(2244),o=new I,m=new y(1),l=new y(2),g=new y(5),M=new y(16),E=new y(8),d=new y(10),A=new y(3),v=new y(7),b=new y(11),k=new y(4),B=new y(12),U=null;function C(){if(U!==null)return U;var K=1048576,$=[];$[0]=2;for(var Q=1,Y=3;Y<K;Y+=2){for(var ee=Math.ceil(Math.sqrt(Y)),u=0;u<Q&&$[u]<=ee&&Y%$[u]!==0;u++);Q!==u&&$[u]<=ee||($[Q++]=Y)}return U=$,$}function L(K){for(var $=C(),Q=0;Q<$.length;Q++)if(K.modn($[Q])===0)return K.cmpn($[Q])===0;return!0}function N(K){var $=y.mont(K);return l.toRed($).redPow(K.subn(1)).fromRed().cmpn(1)===0}function j(K,$){if(K<16)return $===2||$===5?new y([140,123]):new y([140,39]);$=new y($);for(var Q,Y;;){for(Q=new y(S(Math.ceil(K/8)));Q.bitLength()>K;)Q.ishrn(1);if(Q.isEven()&&Q.iadd(m),Q.testn(1)||Q.iadd(l),$.cmp(l)){if(!$.cmp(g))for(;Q.mod(d).cmp(A);)Q.iadd(k)}else for(;Q.mod(p).cmp(b);)Q.iadd(k);if(Y=Q.shrn(1),L(Y)&&L(Q)&&N(Y)&&N(Q)&&o.test(Y)&&o.test(Q))return Q}}},6473:function(fe,x,T){fe=T.nmd(fe),function(S,y){"use strict";function p(u,e){if(!u)throw new Error(e||"Assertion failed")}function I(u,e){u.super_=e;var r=function(){};r.prototype=e.prototype,u.prototype=new r,u.prototype.constructor=u}function o(u,e,r){if(o.isBN(u))return u;this.negative=0,this.words=null,this.length=0,this.red=null,u!==null&&((e==="le"||e==="be")&&(r=e,e=10),this._init(u||0,e||10,r||"be"))}typeof S=="object"?S.exports=o:y.BN=o,o.BN=o,o.wordSize=26;var m;try{typeof window<"u"&&typeof window.Buffer<"u"?m=window.Buffer:m=T(6089).Buffer}catch{}o.isBN=function(e){return e instanceof o?!0:e!==null&&typeof e=="object"&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,r){return e.cmp(r)>0?e:r},o.min=function(e,r){return e.cmp(r)<0?e:r},o.prototype._init=function(e,r,n){if(typeof e=="number")return this._initNumber(e,r,n);if(typeof e=="object")return this._initArray(e,r,n);r==="hex"&&(r=16),p(r===(r|0)&&r>=2&&r<=36),e=e.toString().replace(/\s+/g,"");var i=0;e[0]==="-"&&(i++,this.negative=1),i<e.length&&(r===16?this._parseHex(e,i,n):(this._parseBase(e,r,i),n==="le"&&this._initArray(this.toArray(),r,n)))},o.prototype._initNumber=function(e,r,n){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[e&67108863],this.length=1):e<4503599627370496?(this.words=[e&67108863,e/67108864&67108863],this.length=2):(p(e<9007199254740992),this.words=[e&67108863,e/67108864&67108863,1],this.length=3),n==="le"&&this._initArray(this.toArray(),r,n)},o.prototype._initArray=function(e,r,n){if(p(typeof e.length=="number"),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<this.length;i++)this.words[i]=0;var f,c,h=0;if(n==="be")for(i=e.length-1,f=0;i>=0;i-=3)c=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[f]|=c<<h&67108863,this.words[f+1]=c>>>26-h&67108863,h+=24,h>=26&&(h-=26,f++);else if(n==="le")for(i=0,f=0;i<e.length;i+=3)c=e[i]|e[i+1]<<8|e[i+2]<<16,this.words[f]|=c<<h&67108863,this.words[f+1]=c>>>26-h&67108863,h+=24,h>=26&&(h-=26,f++);return this.strip()};function l(u,e){var r=u.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function g(u,e,r){var n=l(u,r);return r-1>=e&&(n|=l(u,r-1)<<4),n}o.prototype._parseHex=function(e,r,n){this.length=Math.ceil((e.length-r)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var f=0,c=0,h;if(n==="be")for(i=e.length-1;i>=r;i-=2)h=g(e,r,i)<<f,this.words[c]|=h&67108863,f>=18?(f-=18,c+=1,this.words[c]|=h>>>26):f+=8;else{var s=e.length-r;for(i=s%2===0?r+1:r;i<e.length;i+=2)h=g(e,r,i)<<f,this.words[c]|=h&67108863,f>=18?(f-=18,c+=1,this.words[c]|=h>>>26):f+=8}this.strip()};function M(u,e,r,n){for(var i=0,f=Math.min(u.length,r),c=e;c<f;c++){var h=u.charCodeAt(c)-48;i*=n,h>=49?i+=h-49+10:h>=17?i+=h-17+10:i+=h}return i}o.prototype._parseBase=function(e,r,n){this.words=[0],this.length=1;for(var i=0,f=1;f<=67108863;f*=r)i++;i--,f=f/r|0;for(var c=e.length-n,h=c%i,s=Math.min(c,c-h)+n,t=0,a=n;a<s;a+=i)t=M(e,a,a+i,r),this.imuln(f),this.words[0]+t<67108864?this.words[0]+=t:this._iaddn(t);if(h!==0){var w=1;for(t=M(e,a,e.length,r),a=0;a<h;a++)w*=r;this.imuln(w),this.words[0]+t<67108864?this.words[0]+=t:this._iaddn(t)}this.strip()},o.prototype.copy=function(e){e.words=new Array(this.length);for(var r=0;r<this.length;r++)e.words[r]=this.words[r];e.length=this.length,e.negative=this.negative,e.red=this.red},o.prototype.clone=function(){var e=new o(null);return this.copy(e),e},o.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},o.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},o.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var E=["","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"],d=[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],A=[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];o.prototype.toString=function(e,r){e=e||10,r=r|0||1;var n;if(e===16||e==="hex"){n="";for(var i=0,f=0,c=0;c<this.length;c++){var h=this.words[c],s=((h<<i|f)&16777215).toString(16);f=h>>>24-i&16777215,f!==0||c!==this.length-1?n=E[6-s.length]+s+n:n=s+n,i+=2,i>=26&&(i-=26,c--)}for(f!==0&&(n=f.toString(16)+n);n.length%r!==0;)n="0"+n;return this.negative!==0&&(n="-"+n),n}if(e===(e|0)&&e>=2&&e<=36){var t=d[e],a=A[e];n="";var w=this.clone();for(w.negative=0;!w.isZero();){var D=w.modn(a).toString(e);w=w.idivn(a),w.isZero()?n=D+n:n=E[t-D.length]+D+n}for(this.isZero()&&(n="0"+n);n.length%r!==0;)n="0"+n;return this.negative!==0&&(n="-"+n),n}p(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return this.length===2?e+=this.words[1]*67108864:this.length===3&&this.words[2]===1?e+=4503599627370496+this.words[1]*67108864:this.length>2&&p(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,r){return p(typeof m<"u"),this.toArrayLike(m,e,r)},o.prototype.toArray=function(e,r){return this.toArrayLike(Array,e,r)},o.prototype.toArrayLike=function(e,r,n){var i=this.byteLength(),f=n||Math.max(1,i);p(i<=f,"byte array longer than desired length"),p(f>0,"Requested array length <= 0"),this.strip();var c=r==="le",h=new e(f),s,t,a=this.clone();if(c){for(t=0;!a.isZero();t++)s=a.andln(255),a.iushrn(8),h[t]=s;for(;t<f;t++)h[t]=0}else{for(t=0;t<f-i;t++)h[t]=0;for(t=0;!a.isZero();t++)s=a.andln(255),a.iushrn(8),h[f-t-1]=s}return h},Math.clz32?o.prototype._countBits=function(e){return 32-Math.clz32(e)}:o.prototype._countBits=function(e){var r=e,n=0;return r>=4096&&(n+=13,r>>>=13),r>=64&&(n+=7,r>>>=7),r>=8&&(n+=4,r>>>=4),r>=2&&(n+=2,r>>>=2),n+r},o.prototype._zeroBits=function(e){if(e===0)return 26;var r=e,n=0;return r&8191||(n+=13,r>>>=13),r&127||(n+=7,r>>>=7),r&15||(n+=4,r>>>=4),r&3||(n+=2,r>>>=2),r&1||n++,n},o.prototype.bitLength=function(){var e=this.words[this.length-1],r=this._countBits(e);return(this.length-1)*26+r};function v(u){for(var e=new Array(u.bitLength()),r=0;r<e.length;r++){var n=r/26|0,i=r%26;e[r]=(u.words[n]&1<<i)>>>i}return e}o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,r=0;r<this.length;r++){var n=this._zeroBits(this.words[r]);if(e+=n,n!==26)break}return e},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(e){return this.negative!==0?this.abs().inotn(e).iaddn(1):this.clone()},o.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return this.negative!==0},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]|e.words[r];return this.strip()},o.prototype.ior=function(e){return p((this.negative|e.negative)===0),this.iuor(e)},o.prototype.or=function(e){return this.length>e.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 r;this.length>e.length?r=e:r=this;for(var n=0;n<r.length;n++)this.words[n]=this.words[n]&e.words[n];return this.length=r.length,this.strip()},o.prototype.iand=function(e){return p((this.negative|e.negative)===0),this.iuand(e)},o.prototype.and=function(e){return this.length>e.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 r,n;this.length>e.length?(r=this,n=e):(r=e,n=this);for(var i=0;i<n.length;i++)this.words[i]=r.words[i]^n.words[i];if(this!==r)for(;i<r.length;i++)this.words[i]=r.words[i];return this.length=r.length,this.strip()},o.prototype.ixor=function(e){return p((this.negative|e.negative)===0),this.iuxor(e)},o.prototype.xor=function(e){return this.length>e.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){p(typeof e=="number"&&e>=0);var r=Math.ceil(e/26)|0,n=e%26;this._expand(r),n>0&&r--;for(var i=0;i<r;i++)this.words[i]=~this.words[i]&67108863;return n>0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,r){p(typeof e=="number"&&e>=0);var n=e/26|0,i=e%26;return this._expand(n+1),r?this.words[n]=this.words[n]|1<<i:this.words[n]=this.words[n]&~(1<<i),this.strip()},o.prototype.iadd=function(e){var r;if(this.negative!==0&&e.negative===0)return this.negative=0,r=this.isub(e),this.negative^=1,this._normSign();if(this.negative===0&&e.negative!==0)return e.negative=0,r=this.isub(e),e.negative=1,r._normSign();var n,i;this.length>e.length?(n=this,i=e):(n=e,i=this);for(var f=0,c=0;c<i.length;c++)r=(n.words[c]|0)+(i.words[c]|0)+f,this.words[c]=r&67108863,f=r>>>26;for(;f!==0&&c<n.length;c++)r=(n.words[c]|0)+f,this.words[c]=r&67108863,f=r>>>26;if(this.length=n.length,f!==0)this.words[this.length]=f,this.length++;else if(n!==this)for(;c<n.length;c++)this.words[c]=n.words[c];return this},o.prototype.add=function(e){var r;return e.negative!==0&&this.negative===0?(e.negative=0,r=this.sub(e),e.negative^=1,r):e.negative===0&&this.negative!==0?(this.negative=0,r=e.sub(this),this.negative=1,r):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(e.negative!==0){e.negative=0;var r=this.iadd(e);return e.negative=1,r._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var n=this.cmp(e);if(n===0)return this.negative=0,this.length=1,this.words[0]=0,this;var i,f;n>0?(i=this,f=e):(i=e,f=this);for(var c=0,h=0;h<f.length;h++)r=(i.words[h]|0)-(f.words[h]|0)+c,c=r>>26,this.words[h]=r&67108863;for(;c!==0&&h<i.length;h++)r=(i.words[h]|0)+c,c=r>>26,this.words[h]=r&67108863;if(c===0&&h<i.length&&i!==this)for(;h<i.length;h++)this.words[h]=i.words[h];return this.length=Math.max(this.length,h),i!==this&&(this.negative=1),this.strip()},o.prototype.sub=function(e){return this.clone().isub(e)};function b(u,e,r){r.negative=e.negative^u.negative;var n=u.length+e.length|0;r.length=n,n=n-1|0;var i=u.words[0]|0,f=e.words[0]|0,c=i*f,h=c&67108863,s=c/67108864|0;r.words[0]=h;for(var t=1;t<n;t++){for(var a=s>>>26,w=s&67108863,D=Math.min(t,e.length-1),Z=Math.max(0,t-u.length+1);Z<=D;Z++){var F=t-Z|0;i=u.words[F]|0,f=e.words[Z]|0,c=i*f+w,a+=c/67108864|0,w=c&67108863}r.words[t]=w|0,s=a|0}return s!==0?r.words[t]=s|0:r.length--,r.strip()}var k=function(e,r,n){var i=e.words,f=r.words,c=n.words,h=0,s,t,a,w=i[0]|0,D=w&8191,Z=w>>>13,F=i[1]|0,V=F&8191,q=F>>>13,re=i[2]|0,G=re&8191,H=re>>>13,oe=i[3]|0,ue=oe&8191,be=oe>>>13,ie=i[4]|0,J=ie&8191,pe=ie>>>13,Ge=i[5]|0,ce=Ge&8191,te=Ge>>>13,le=i[6]|0,ge=le&8191,Pe=le>>>13,lt=i[7]|0,Le=lt&8191,ze=lt>>>13,kt=i[8]|0,ae=kt&8191,he=kt>>>13,je=i[9]|0,Ie=je&8191,Ce=je>>>13,ut=f[0]|0,De=ut&8191,ye=ut>>>13,we=f[1]|0,ve=we&8191,Ee=we>>>13,rt=f[2]|0,Fe=rt&8191,He=rt>>>13,yt=f[3]|0,Ke=yt&8191,Ze=yt>>>13,At=f[4]|0,Ve=At&8191,tt=At>>>13,qt=f[5]|0,et=qt&8191,st=qt>>>13,rr=f[6]|0,at=rr&8191,ft=rr>>>13,Qe=f[7]|0,xe=Qe&8191,Oe=Qe>>>13,ht=f[8]|0,Ne=ht&8191,qe=ht>>>13,Dt=f[9]|0,Xe=Dt&8191,ot=Dt>>>13;n.negative=e.negative^r.negative,n.length=19,s=Math.imul(D,De),t=Math.imul(D,ye),t=t+Math.imul(Z,De)|0,a=Math.imul(Z,ye);var Gt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,s=Math.imul(V,De),t=Math.imul(V,ye),t=t+Math.imul(q,De)|0,a=Math.imul(q,ye),s=s+Math.imul(D,ve)|0,t=t+Math.imul(D,Ee)|0,t=t+Math.imul(Z,ve)|0,a=a+Math.imul(Z,Ee)|0;var xt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(xt>>>26)|0,xt&=67108863,s=Math.imul(G,De),t=Math.imul(G,ye),t=t+Math.imul(H,De)|0,a=Math.imul(H,ye),s=s+Math.imul(V,ve)|0,t=t+Math.imul(V,Ee)|0,t=t+Math.imul(q,ve)|0,a=a+Math.imul(q,Ee)|0,s=s+Math.imul(D,Fe)|0,t=t+Math.imul(D,He)|0,t=t+Math.imul(Z,Fe)|0,a=a+Math.imul(Z,He)|0;var gt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(gt>>>26)|0,gt&=67108863,s=Math.imul(ue,De),t=Math.imul(ue,ye),t=t+Math.imul(be,De)|0,a=Math.imul(be,ye),s=s+Math.imul(G,ve)|0,t=t+Math.imul(G,Ee)|0,t=t+Math.imul(H,ve)|0,a=a+Math.imul(H,Ee)|0,s=s+Math.imul(V,Fe)|0,t=t+Math.imul(V,He)|0,t=t+Math.imul(q,Fe)|0,a=a+Math.imul(q,He)|0,s=s+Math.imul(D,Ke)|0,t=t+Math.imul(D,Ze)|0,t=t+Math.imul(Z,Ke)|0,a=a+Math.imul(Z,Ze)|0;var bt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(bt>>>26)|0,bt&=67108863,s=Math.imul(J,De),t=Math.imul(J,ye),t=t+Math.imul(pe,De)|0,a=Math.imul(pe,ye),s=s+Math.imul(ue,ve)|0,t=t+Math.imul(ue,Ee)|0,t=t+Math.imul(be,ve)|0,a=a+Math.imul(be,Ee)|0,s=s+Math.imul(G,Fe)|0,t=t+Math.imul(G,He)|0,t=t+Math.imul(H,Fe)|0,a=a+Math.imul(H,He)|0,s=s+Math.imul(V,Ke)|0,t=t+Math.imul(V,Ze)|0,t=t+Math.imul(q,Ke)|0,a=a+Math.imul(q,Ze)|0,s=s+Math.imul(D,Ve)|0,t=t+Math.imul(D,tt)|0,t=t+Math.imul(Z,Ve)|0,a=a+Math.imul(Z,tt)|0;var Tt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,s=Math.imul(ce,De),t=Math.imul(ce,ye),t=t+Math.imul(te,De)|0,a=Math.imul(te,ye),s=s+Math.imul(J,ve)|0,t=t+Math.imul(J,Ee)|0,t=t+Math.imul(pe,ve)|0,a=a+Math.imul(pe,Ee)|0,s=s+Math.imul(ue,Fe)|0,t=t+Math.imul(ue,He)|0,t=t+Math.imul(be,Fe)|0,a=a+Math.imul(be,He)|0,s=s+Math.imul(G,Ke)|0,t=t+Math.imul(G,Ze)|0,t=t+Math.imul(H,Ke)|0,a=a+Math.imul(H,Ze)|0,s=s+Math.imul(V,Ve)|0,t=t+Math.imul(V,tt)|0,t=t+Math.imul(q,Ve)|0,a=a+Math.imul(q,tt)|0,s=s+Math.imul(D,et)|0,t=t+Math.imul(D,st)|0,t=t+Math.imul(Z,et)|0,a=a+Math.imul(Z,st)|0;var Ct=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,s=Math.imul(ge,De),t=Math.imul(ge,ye),t=t+Math.imul(Pe,De)|0,a=Math.imul(Pe,ye),s=s+Math.imul(ce,ve)|0,t=t+Math.imul(ce,Ee)|0,t=t+Math.imul(te,ve)|0,a=a+Math.imul(te,Ee)|0,s=s+Math.imul(J,Fe)|0,t=t+Math.imul(J,He)|0,t=t+Math.imul(pe,Fe)|0,a=a+Math.imul(pe,He)|0,s=s+Math.imul(ue,Ke)|0,t=t+Math.imul(ue,Ze)|0,t=t+Math.imul(be,Ke)|0,a=a+Math.imul(be,Ze)|0,s=s+Math.imul(G,Ve)|0,t=t+Math.imul(G,tt)|0,t=t+Math.imul(H,Ve)|0,a=a+Math.imul(H,tt)|0,s=s+Math.imul(V,et)|0,t=t+Math.imul(V,st)|0,t=t+Math.imul(q,et)|0,a=a+Math.imul(q,st)|0,s=s+Math.imul(D,at)|0,t=t+Math.imul(D,ft)|0,t=t+Math.imul(Z,at)|0,a=a+Math.imul(Z,ft)|0;var Xt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Xt>>>26)|0,Xt&=67108863,s=Math.imul(Le,De),t=Math.imul(Le,ye),t=t+Math.imul(ze,De)|0,a=Math.imul(ze,ye),s=s+Math.imul(ge,ve)|0,t=t+Math.imul(ge,Ee)|0,t=t+Math.imul(Pe,ve)|0,a=a+Math.imul(Pe,Ee)|0,s=s+Math.imul(ce,Fe)|0,t=t+Math.imul(ce,He)|0,t=t+Math.imul(te,Fe)|0,a=a+Math.imul(te,He)|0,s=s+Math.imul(J,Ke)|0,t=t+Math.imul(J,Ze)|0,t=t+Math.imul(pe,Ke)|0,a=a+Math.imul(pe,Ze)|0,s=s+Math.imul(ue,Ve)|0,t=t+Math.imul(ue,tt)|0,t=t+Math.imul(be,Ve)|0,a=a+Math.imul(be,tt)|0,s=s+Math.imul(G,et)|0,t=t+Math.imul(G,st)|0,t=t+Math.imul(H,et)|0,a=a+Math.imul(H,st)|0,s=s+Math.imul(V,at)|0,t=t+Math.imul(V,ft)|0,t=t+Math.imul(q,at)|0,a=a+Math.imul(q,ft)|0,s=s+Math.imul(D,xe)|0,t=t+Math.imul(D,Oe)|0,t=t+Math.imul(Z,xe)|0,a=a+Math.imul(Z,Oe)|0;var Yt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Yt>>>26)|0,Yt&=67108863,s=Math.imul(ae,De),t=Math.imul(ae,ye),t=t+Math.imul(he,De)|0,a=Math.imul(he,ye),s=s+Math.imul(Le,ve)|0,t=t+Math.imul(Le,Ee)|0,t=t+Math.imul(ze,ve)|0,a=a+Math.imul(ze,Ee)|0,s=s+Math.imul(ge,Fe)|0,t=t+Math.imul(ge,He)|0,t=t+Math.imul(Pe,Fe)|0,a=a+Math.imul(Pe,He)|0,s=s+Math.imul(ce,Ke)|0,t=t+Math.imul(ce,Ze)|0,t=t+Math.imul(te,Ke)|0,a=a+Math.imul(te,Ze)|0,s=s+Math.imul(J,Ve)|0,t=t+Math.imul(J,tt)|0,t=t+Math.imul(pe,Ve)|0,a=a+Math.imul(pe,tt)|0,s=s+Math.imul(ue,et)|0,t=t+Math.imul(ue,st)|0,t=t+Math.imul(be,et)|0,a=a+Math.imul(be,st)|0,s=s+Math.imul(G,at)|0,t=t+Math.imul(G,ft)|0,t=t+Math.imul(H,at)|0,a=a+Math.imul(H,ft)|0,s=s+Math.imul(V,xe)|0,t=t+Math.imul(V,Oe)|0,t=t+Math.imul(q,xe)|0,a=a+Math.imul(q,Oe)|0,s=s+Math.imul(D,Ne)|0,t=t+Math.imul(D,qe)|0,t=t+Math.imul(Z,Ne)|0,a=a+Math.imul(Z,qe)|0;var ar=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(ar>>>26)|0,ar&=67108863,s=Math.imul(Ie,De),t=Math.imul(Ie,ye),t=t+Math.imul(Ce,De)|0,a=Math.imul(Ce,ye),s=s+Math.imul(ae,ve)|0,t=t+Math.imul(ae,Ee)|0,t=t+Math.imul(he,ve)|0,a=a+Math.imul(he,Ee)|0,s=s+Math.imul(Le,Fe)|0,t=t+Math.imul(Le,He)|0,t=t+Math.imul(ze,Fe)|0,a=a+Math.imul(ze,He)|0,s=s+Math.imul(ge,Ke)|0,t=t+Math.imul(ge,Ze)|0,t=t+Math.imul(Pe,Ke)|0,a=a+Math.imul(Pe,Ze)|0,s=s+Math.imul(ce,Ve)|0,t=t+Math.imul(ce,tt)|0,t=t+Math.imul(te,Ve)|0,a=a+Math.imul(te,tt)|0,s=s+Math.imul(J,et)|0,t=t+Math.imul(J,st)|0,t=t+Math.imul(pe,et)|0,a=a+Math.imul(pe,st)|0,s=s+Math.imul(ue,at)|0,t=t+Math.imul(ue,ft)|0,t=t+Math.imul(be,at)|0,a=a+Math.imul(be,ft)|0,s=s+Math.imul(G,xe)|0,t=t+Math.imul(G,Oe)|0,t=t+Math.imul(H,xe)|0,a=a+Math.imul(H,Oe)|0,s=s+Math.imul(V,Ne)|0,t=t+Math.imul(V,qe)|0,t=t+Math.imul(q,Ne)|0,a=a+Math.imul(q,qe)|0,s=s+Math.imul(D,Xe)|0,t=t+Math.imul(D,ot)|0,t=t+Math.imul(Z,Xe)|0,a=a+Math.imul(Z,ot)|0;var or=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(or>>>26)|0,or&=67108863,s=Math.imul(Ie,ve),t=Math.imul(Ie,Ee),t=t+Math.imul(Ce,ve)|0,a=Math.imul(Ce,Ee),s=s+Math.imul(ae,Fe)|0,t=t+Math.imul(ae,He)|0,t=t+Math.imul(he,Fe)|0,a=a+Math.imul(he,He)|0,s=s+Math.imul(Le,Ke)|0,t=t+Math.imul(Le,Ze)|0,t=t+Math.imul(ze,Ke)|0,a=a+Math.imul(ze,Ze)|0,s=s+Math.imul(ge,Ve)|0,t=t+Math.imul(ge,tt)|0,t=t+Math.imul(Pe,Ve)|0,a=a+Math.imul(Pe,tt)|0,s=s+Math.imul(ce,et)|0,t=t+Math.imul(ce,st)|0,t=t+Math.imul(te,et)|0,a=a+Math.imul(te,st)|0,s=s+Math.imul(J,at)|0,t=t+Math.imul(J,ft)|0,t=t+Math.imul(pe,at)|0,a=a+Math.imul(pe,ft)|0,s=s+Math.imul(ue,xe)|0,t=t+Math.imul(ue,Oe)|0,t=t+Math.imul(be,xe)|0,a=a+Math.imul(be,Oe)|0,s=s+Math.imul(G,Ne)|0,t=t+Math.imul(G,qe)|0,t=t+Math.imul(H,Ne)|0,a=a+Math.imul(H,qe)|0,s=s+Math.imul(V,Xe)|0,t=t+Math.imul(V,ot)|0,t=t+Math.imul(q,Xe)|0,a=a+Math.imul(q,ot)|0;var sr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(sr>>>26)|0,sr&=67108863,s=Math.imul(Ie,Fe),t=Math.imul(Ie,He),t=t+Math.imul(Ce,Fe)|0,a=Math.imul(Ce,He),s=s+Math.imul(ae,Ke)|0,t=t+Math.imul(ae,Ze)|0,t=t+Math.imul(he,Ke)|0,a=a+Math.imul(he,Ze)|0,s=s+Math.imul(Le,Ve)|0,t=t+Math.imul(Le,tt)|0,t=t+Math.imul(ze,Ve)|0,a=a+Math.imul(ze,tt)|0,s=s+Math.imul(ge,et)|0,t=t+Math.imul(ge,st)|0,t=t+Math.imul(Pe,et)|0,a=a+Math.imul(Pe,st)|0,s=s+Math.imul(ce,at)|0,t=t+Math.imul(ce,ft)|0,t=t+Math.imul(te,at)|0,a=a+Math.imul(te,ft)|0,s=s+Math.imul(J,xe)|0,t=t+Math.imul(J,Oe)|0,t=t+Math.imul(pe,xe)|0,a=a+Math.imul(pe,Oe)|0,s=s+Math.imul(ue,Ne)|0,t=t+Math.imul(ue,qe)|0,t=t+Math.imul(be,Ne)|0,a=a+Math.imul(be,qe)|0,s=s+Math.imul(G,Xe)|0,t=t+Math.imul(G,ot)|0,t=t+Math.imul(H,Xe)|0,a=a+Math.imul(H,ot)|0;var $t=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+($t>>>26)|0,$t&=67108863,s=Math.imul(Ie,Ke),t=Math.imul(Ie,Ze),t=t+Math.imul(Ce,Ke)|0,a=Math.imul(Ce,Ze),s=s+Math.imul(ae,Ve)|0,t=t+Math.imul(ae,tt)|0,t=t+Math.imul(he,Ve)|0,a=a+Math.imul(he,tt)|0,s=s+Math.imul(Le,et)|0,t=t+Math.imul(Le,st)|0,t=t+Math.imul(ze,et)|0,a=a+Math.imul(ze,st)|0,s=s+Math.imul(ge,at)|0,t=t+Math.imul(ge,ft)|0,t=t+Math.imul(Pe,at)|0,a=a+Math.imul(Pe,ft)|0,s=s+Math.imul(ce,xe)|0,t=t+Math.imul(ce,Oe)|0,t=t+Math.imul(te,xe)|0,a=a+Math.imul(te,Oe)|0,s=s+Math.imul(J,Ne)|0,t=t+Math.imul(J,qe)|0,t=t+Math.imul(pe,Ne)|0,a=a+Math.imul(pe,qe)|0,s=s+Math.imul(ue,Xe)|0,t=t+Math.imul(ue,ot)|0,t=t+Math.imul(be,Xe)|0,a=a+Math.imul(be,ot)|0;var nr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(nr>>>26)|0,nr&=67108863,s=Math.imul(Ie,Ve),t=Math.imul(Ie,tt),t=t+Math.imul(Ce,Ve)|0,a=Math.imul(Ce,tt),s=s+Math.imul(ae,et)|0,t=t+Math.imul(ae,st)|0,t=t+Math.imul(he,et)|0,a=a+Math.imul(he,st)|0,s=s+Math.imul(Le,at)|0,t=t+Math.imul(Le,ft)|0,t=t+Math.imul(ze,at)|0,a=a+Math.imul(ze,ft)|0,s=s+Math.imul(ge,xe)|0,t=t+Math.imul(ge,Oe)|0,t=t+Math.imul(Pe,xe)|0,a=a+Math.imul(Pe,Oe)|0,s=s+Math.imul(ce,Ne)|0,t=t+Math.imul(ce,qe)|0,t=t+Math.imul(te,Ne)|0,a=a+Math.imul(te,qe)|0,s=s+Math.imul(J,Xe)|0,t=t+Math.imul(J,ot)|0,t=t+Math.imul(pe,Xe)|0,a=a+Math.imul(pe,ot)|0;var fr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(fr>>>26)|0,fr&=67108863,s=Math.imul(Ie,et),t=Math.imul(Ie,st),t=t+Math.imul(Ce,et)|0,a=Math.imul(Ce,st),s=s+Math.imul(ae,at)|0,t=t+Math.imul(ae,ft)|0,t=t+Math.imul(he,at)|0,a=a+Math.imul(he,ft)|0,s=s+Math.imul(Le,xe)|0,t=t+Math.imul(Le,Oe)|0,t=t+Math.imul(ze,xe)|0,a=a+Math.imul(ze,Oe)|0,s=s+Math.imul(ge,Ne)|0,t=t+Math.imul(ge,qe)|0,t=t+Math.imul(Pe,Ne)|0,a=a+Math.imul(Pe,qe)|0,s=s+Math.imul(ce,Xe)|0,t=t+Math.imul(ce,ot)|0,t=t+Math.imul(te,Xe)|0,a=a+Math.imul(te,ot)|0;var lr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(lr>>>26)|0,lr&=67108863,s=Math.imul(Ie,at),t=Math.imul(Ie,ft),t=t+Math.imul(Ce,at)|0,a=Math.imul(Ce,ft),s=s+Math.imul(ae,xe)|0,t=t+Math.imul(ae,Oe)|0,t=t+Math.imul(he,xe)|0,a=a+Math.imul(he,Oe)|0,s=s+Math.imul(Le,Ne)|0,t=t+Math.imul(Le,qe)|0,t=t+Math.imul(ze,Ne)|0,a=a+Math.imul(ze,qe)|0,s=s+Math.imul(ge,Xe)|0,t=t+Math.imul(ge,ot)|0,t=t+Math.imul(Pe,Xe)|0,a=a+Math.imul(Pe,ot)|0;var dr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(dr>>>26)|0,dr&=67108863,s=Math.imul(Ie,xe),t=Math.imul(Ie,Oe),t=t+Math.imul(Ce,xe)|0,a=Math.imul(Ce,Oe),s=s+Math.imul(ae,Ne)|0,t=t+Math.imul(ae,qe)|0,t=t+Math.imul(he,Ne)|0,a=a+Math.imul(he,qe)|0,s=s+Math.imul(Le,Xe)|0,t=t+Math.imul(Le,ot)|0,t=t+Math.imul(ze,Xe)|0,a=a+Math.imul(ze,ot)|0;var cr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(cr>>>26)|0,cr&=67108863,s=Math.imul(Ie,Ne),t=Math.imul(Ie,qe),t=t+Math.imul(Ce,Ne)|0,a=Math.imul(Ce,qe),s=s+Math.imul(ae,Xe)|0,t=t+Math.imul(ae,ot)|0,t=t+Math.imul(he,Xe)|0,a=a+Math.imul(he,ot)|0;var gr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(gr>>>26)|0,gr&=67108863,s=Math.imul(Ie,Xe),t=Math.imul(Ie,ot),t=t+Math.imul(Ce,Xe)|0,a=Math.imul(Ce,ot);var pr=(h+s|0)+((t&8191)<<13)|0;return h=(a+(t>>>13)|0)+(pr>>>26)|0,pr&=67108863,c[0]=Gt,c[1]=xt,c[2]=gt,c[3]=bt,c[4]=Tt,c[5]=Ct,c[6]=Xt,c[7]=Yt,c[8]=ar,c[9]=or,c[10]=sr,c[11]=$t,c[12]=nr,c[13]=fr,c[14]=lr,c[15]=dr,c[16]=cr,c[17]=gr,c[18]=pr,h!==0&&(c[19]=h,n.length++),n};Math.imul||(k=b);function B(u,e,r){r.negative=e.negative^u.negative,r.length=u.length+e.length;for(var n=0,i=0,f=0;f<r.length-1;f++){var c=i;i=0;for(var h=n&67108863,s=Math.min(f,e.length-1),t=Math.max(0,f-u.length+1);t<=s;t++){var a=f-t,w=u.words[a]|0,D=e.words[t]|0,Z=w*D,F=Z&67108863;c=c+(Z/67108864|0)|0,F=F+h|0,h=F&67108863,c=c+(F>>>26)|0,i+=c>>>26,c&=67108863}r.words[f]=h,n=c,c=i}return n!==0?r.words[f]=n:r.length--,r.strip()}function U(u,e,r){var n=new C;return n.mulp(u,e,r)}o.prototype.mulTo=function(e,r){var n,i=this.length+e.length;return this.length===10&&e.length===10?n=k(this,e,r):i<63?n=b(this,e,r):i<1024?n=B(this,e,r):n=U(this,e,r),n};function C(u,e){this.x=u,this.y=e}C.prototype.makeRBT=function(e){for(var r=new Array(e),n=o.prototype._countBits(e)-1,i=0;i<e;i++)r[i]=this.revBin(i,n,e);return r},C.prototype.revBin=function(e,r,n){if(e===0||e===n-1)return e;for(var i=0,f=0;f<r;f++)i|=(e&1)<<r-f-1,e>>=1;return i},C.prototype.permute=function(e,r,n,i,f,c){for(var h=0;h<c;h++)i[h]=r[e[h]],f[h]=n[e[h]]},C.prototype.transform=function(e,r,n,i,f,c){this.permute(c,e,r,n,i,f);for(var h=1;h<f;h<<=1)for(var s=h<<1,t=Math.cos(2*Math.PI/s),a=Math.sin(2*Math.PI/s),w=0;w<f;w+=s)for(var D=t,Z=a,F=0;F<h;F++){var V=n[w+F],q=i[w+F],re=n[w+F+h],G=i[w+F+h],H=D*re-Z*G;G=D*G+Z*re,re=H,n[w+F]=V+re,i[w+F]=q+G,n[w+F+h]=V-re,i[w+F+h]=q-G,F!==s&&(H=t*D-a*Z,Z=t*Z+a*D,D=H)}},C.prototype.guessLen13b=function(e,r){var n=Math.max(r,e)|1,i=n&1,f=0;for(n=n/2|0;n;n=n>>>1)f++;return 1<<f+1+i},C.prototype.conjugate=function(e,r,n){if(!(n<=1))for(var i=0;i<n/2;i++){var f=e[i];e[i]=e[n-i-1],e[n-i-1]=f,f=r[i],r[i]=-r[n-i-1],r[n-i-1]=-f}},C.prototype.normalize13b=function(e,r){for(var n=0,i=0;i<r/2;i++){var f=Math.round(e[2*i+1]/r)*8192+Math.round(e[2*i]/r)+n;e[i]=f&67108863,f<67108864?n=0:n=f/67108864|0}return e},C.prototype.convert13b=function(e,r,n,i){for(var f=0,c=0;c<r;c++)f=f+(e[c]|0),n[2*c]=f&8191,f=f>>>13,n[2*c+1]=f&8191,f=f>>>13;for(c=2*r;c<i;++c)n[c]=0;p(f===0),p((f&-8192)===0)},C.prototype.stub=function(e){for(var r=new Array(e),n=0;n<e;n++)r[n]=0;return r},C.prototype.mulp=function(e,r,n){var i=2*this.guessLen13b(e.length,r.length),f=this.makeRBT(i),c=this.stub(i),h=new Array(i),s=new Array(i),t=new Array(i),a=new Array(i),w=new Array(i),D=new Array(i),Z=n.words;Z.length=i,this.convert13b(e.words,e.length,h,i),this.convert13b(r.words,r.length,a,i),this.transform(h,c,s,t,i,f),this.transform(a,c,w,D,i,f);for(var F=0;F<i;F++){var V=s[F]*w[F]-t[F]*D[F];t[F]=s[F]*D[F]+t[F]*w[F],s[F]=V}return this.conjugate(s,t,i),this.transform(s,t,Z,c,i,f),this.conjugate(Z,c,i),this.normalize13b(Z,i),n.negative=e.negative^r.negative,n.length=e.length+r.length,n.strip()},o.prototype.mul=function(e){var r=new o(null);return r.words=new Array(this.length+e.length),this.mulTo(e,r)},o.prototype.mulf=function(e){var r=new o(null);return r.words=new Array(this.length+e.length),U(this,e,r)},o.prototype.imul=function(e){return this.clone().mulTo(e,this)},o.prototype.imuln=function(e){p(typeof e=="number"),p(e<67108864);for(var r=0,n=0;n<this.length;n++){var i=(this.words[n]|0)*e,f=(i&67108863)+(r&67108863);r>>=26,r+=i/67108864|0,r+=f>>>26,this.words[n]=f&67108863}return r!==0&&(this.words[n]=r,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 r=v(e);if(r.length===0)return new o(1);for(var n=this,i=0;i<r.length&&r[i]===0;i++,n=n.sqr());if(++i<r.length)for(var f=n.sqr();i<r.length;i++,f=f.sqr())r[i]!==0&&(n=n.mul(f));return n},o.prototype.iushln=function(e){p(typeof e=="number"&&e>=0);var r=e%26,n=(e-r)/26,i=67108863>>>26-r<<26-r,f;if(r!==0){var c=0;for(f=0;f<this.length;f++){var h=this.words[f]&i,s=(this.words[f]|0)-h<<r;this.words[f]=s|c,c=h>>>26-r}c&&(this.words[f]=c,this.length++)}if(n!==0){for(f=this.length-1;f>=0;f--)this.words[f+n]=this.words[f];for(f=0;f<n;f++)this.words[f]=0;this.length+=n}return this.strip()},o.prototype.ishln=function(e){return p(this.negative===0),this.iushln(e)},o.prototype.iushrn=function(e,r,n){p(typeof e=="number"&&e>=0);var i;r?i=(r-r%26)/26:i=0;var f=e%26,c=Math.min((e-f)/26,this.length),h=67108863^67108863>>>f<<f,s=n;if(i-=c,i=Math.max(0,i),s){for(var t=0;t<c;t++)s.words[t]=this.words[t];s.length=c}if(c!==0)if(this.length>c)for(this.length-=c,t=0;t<this.length;t++)this.words[t]=this.words[t+c];else this.words[0]=0,this.length=1;var a=0;for(t=this.length-1;t>=0&&(a!==0||t>=i);t--){var w=this.words[t]|0;this.words[t]=a<<26-f|w>>>f,a=w&h}return s&&a!==0&&(s.words[s.length++]=a),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,r,n){return p(this.negative===0),this.iushrn(e,r,n)},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){p(typeof e=="number"&&e>=0);var r=e%26,n=(e-r)/26,i=1<<r;if(this.length<=n)return!1;var f=this.words[n];return!!(f&i)},o.prototype.imaskn=function(e){p(typeof e=="number"&&e>=0);var r=e%26,n=(e-r)/26;if(p(this.negative===0,"imaskn works only with positive numbers"),this.length<=n)return this;if(r!==0&&n++,this.length=Math.min(n,this.length),r!==0){var i=67108863^67108863>>>r<<r;this.words[this.length-1]&=i}return this.strip()},o.prototype.maskn=function(e){return this.clone().imaskn(e)},o.prototype.iaddn=function(e){return p(typeof e=="number"),p(e<67108864),e<0?this.isubn(-e):this.negative!==0?this.length===1&&(this.words[0]|0)<e?(this.words[0]=e-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this):this._iaddn(e)},o.prototype._iaddn=function(e){this.words[0]+=e;for(var r=0;r<this.length&&this.words[r]>=67108864;r++)this.words[r]-=67108864,r===this.length-1?this.words[r+1]=1:this.words[r+1]++;return this.length=Math.max(this.length,r+1),this},o.prototype.isubn=function(e){if(p(typeof e=="number"),p(e<67108864),e<0)return this.iaddn(-e);if(this.negative!==0)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var r=0;r<this.length&&this.words[r]<0;r++)this.words[r]+=67108864,this.words[r+1]-=1;return this.strip()},o.prototype.addn=function(e){return this.clone().iaddn(e)},o.prototype.subn=function(e){return this.clone().isubn(e)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(e,r,n){var i=e.length+n,f;this._expand(i);var c,h=0;for(f=0;f<e.length;f++){c=(this.words[f+n]|0)+h;var s=(e.words[f]|0)*r;c-=s&67108863,h=(c>>26)-(s/67108864|0),this.words[f+n]=c&67108863}for(;f<this.length-n;f++)c=(this.words[f+n]|0)+h,h=c>>26,this.words[f+n]=c&67108863;if(h===0)return this.strip();for(p(h===-1),h=0,f=0;f<this.length;f++)c=-(this.words[f]|0)+h,h=c>>26,this.words[f]=c&67108863;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,r){var n=this.length-e.length,i=this.clone(),f=e,c=f.words[f.length-1]|0,h=this._countBits(c);n=26-h,n!==0&&(f=f.ushln(n),i.iushln(n),c=f.words[f.length-1]|0);var s=i.length-f.length,t;if(r!=="mod"){t=new o(null),t.length=s+1,t.words=new Array(t.length);for(var a=0;a<t.length;a++)t.words[a]=0}var w=i.clone()._ishlnsubmul(f,1,s);w.negative===0&&(i=w,t&&(t.words[s]=1));for(var D=s-1;D>=0;D--){var Z=(i.words[f.length+D]|0)*67108864+(i.words[f.length+D-1]|0);for(Z=Math.min(Z/c|0,67108863),i._ishlnsubmul(f,Z,D);i.negative!==0;)Z--,i.negative=0,i._ishlnsubmul(f,1,D),i.isZero()||(i.negative^=1);t&&(t.words[D]=Z)}return t&&t.strip(),i.strip(),r!=="div"&&n!==0&&i.iushrn(n),{div:t||null,mod:i}},o.prototype.divmod=function(e,r,n){if(p(!e.isZero()),this.isZero())return{div:new o(0),mod:new o(0)};var i,f,c;return this.negative!==0&&e.negative===0?(c=this.neg().divmod(e,r),r!=="mod"&&(i=c.div.neg()),r!=="div"&&(f=c.mod.neg(),n&&f.negative!==0&&f.iadd(e)),{div:i,mod:f}):this.negative===0&&e.negative!==0?(c=this.divmod(e.neg(),r),r!=="mod"&&(i=c.div.neg()),{div:i,mod:c.mod}):this.negative&e.negative?(c=this.neg().divmod(e.neg(),r),r!=="div"&&(f=c.mod.neg(),n&&f.negative!==0&&f.isub(e)),{div:c.div,mod:f}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:e.length===1?r==="div"?{div:this.divn(e.words[0]),mod:null}:r==="mod"?{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,r)},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 r=this.divmod(e);if(r.mod.isZero())return r.div;var n=r.div.negative!==0?r.mod.isub(e):r.mod,i=e.ushrn(1),f=e.andln(1),c=n.cmp(i);return c<0||f===1&&c===0?r.div:r.div.negative!==0?r.div.isubn(1):r.div.iaddn(1)},o.prototype.modn=function(e){p(e<=67108863);for(var r=(1<<26)%e,n=0,i=this.length-1;i>=0;i--)n=(r*n+(this.words[i]|0))%e;return n},o.prototype.idivn=function(e){p(e<=67108863);for(var r=0,n=this.length-1;n>=0;n--){var i=(this.words[n]|0)+r*67108864;this.words[n]=i/e|0,r=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){p(e.negative===0),p(!e.isZero());var r=this,n=e.clone();r.negative!==0?r=r.umod(e):r=r.clone();for(var i=new o(1),f=new o(0),c=new o(0),h=new o(1),s=0;r.isEven()&&n.isEven();)r.iushrn(1),n.iushrn(1),++s;for(var t=n.clone(),a=r.clone();!r.isZero();){for(var w=0,D=1;!(r.words[0]&D)&&w<26;++w,D<<=1);if(w>0)for(r.iushrn(w);w-- >0;)(i.isOdd()||f.isOdd())&&(i.iadd(t),f.isub(a)),i.iushrn(1),f.iushrn(1);for(var Z=0,F=1;!(n.words[0]&F)&&Z<26;++Z,F<<=1);if(Z>0)for(n.iushrn(Z);Z-- >0;)(c.isOdd()||h.isOdd())&&(c.iadd(t),h.isub(a)),c.iushrn(1),h.iushrn(1);r.cmp(n)>=0?(r.isub(n),i.isub(c),f.isub(h)):(n.isub(r),c.isub(i),h.isub(f))}return{a:c,b:h,gcd:n.iushln(s)}},o.prototype._invmp=function(e){p(e.negative===0),p(!e.isZero());var r=this,n=e.clone();r.negative!==0?r=r.umod(e):r=r.clone();for(var i=new o(1),f=new o(0),c=n.clone();r.cmpn(1)>0&&n.cmpn(1)>0;){for(var h=0,s=1;!(r.words[0]&s)&&h<26;++h,s<<=1);if(h>0)for(r.iushrn(h);h-- >0;)i.isOdd()&&i.iadd(c),i.iushrn(1);for(var t=0,a=1;!(n.words[0]&a)&&t<26;++t,a<<=1);if(t>0)for(n.iushrn(t);t-- >0;)f.isOdd()&&f.iadd(c),f.iushrn(1);r.cmp(n)>=0?(r.isub(n),i.isub(f)):(n.isub(r),f.isub(i))}var w;return r.cmpn(1)===0?w=i:w=f,w.cmpn(0)<0&&w.iadd(e),w},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var r=this.clone(),n=e.clone();r.negative=0,n.negative=0;for(var i=0;r.isEven()&&n.isEven();i++)r.iushrn(1),n.iushrn(1);do{for(;r.isEven();)r.iushrn(1);for(;n.isEven();)n.iushrn(1);var f=r.cmp(n);if(f<0){var c=r;r=n,n=c}else if(f===0||n.cmpn(1)===0)break;r.isub(n)}while(!0);return n.iushln(i)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return(this.words[0]&1)===0},o.prototype.isOdd=function(){return(this.words[0]&1)===1},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){p(typeof e=="number");var r=e%26,n=(e-r)/26,i=1<<r;if(this.length<=n)return this._expand(n+1),this.words[n]|=i,this;for(var f=i,c=n;f!==0&&c<this.length;c++){var h=this.words[c]|0;h+=f,f=h>>>26,h&=67108863,this.words[c]=h}return f!==0&&(this.words[c]=f,this.length++),this},o.prototype.isZero=function(){return this.length===1&&this.words[0]===0},o.prototype.cmpn=function(e){var r=e<0;if(this.negative!==0&&!r)return-1;if(this.negative===0&&r)return 1;this.strip();var n;if(this.length>1)n=1;else{r&&(e=-e),p(e<=67108863,"Number is too big");var i=this.words[0]|0;n=i===e?0:i<e?-1:1}return this.negative!==0?-n|0:n},o.prototype.cmp=function(e){if(this.negative!==0&&e.negative===0)return-1;if(this.negative===0&&e.negative!==0)return 1;var r=this.ucmp(e);return this.negative!==0?-r|0:r},o.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length<e.length)return-1;for(var r=0,n=this.length-1;n>=0;n--){var i=this.words[n]|0,f=e.words[n]|0;if(i!==f){i<f?r=-1:i>f&&(r=1);break}}return r},o.prototype.gtn=function(e){return this.cmpn(e)===1},o.prototype.gt=function(e){return this.cmp(e)===1},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 this.cmpn(e)===-1},o.prototype.lt=function(e){return this.cmp(e)===-1},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 this.cmpn(e)===0},o.prototype.eq=function(e){return this.cmp(e)===0},o.red=function(e){return new Y(e)},o.prototype.toRed=function(e){return p(!this.red,"Already a number in reduction context"),p(this.negative===0,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return p(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 p(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return p(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return p(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return p(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return p(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return p(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return p(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return p(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return p(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return p(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return p(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return p(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return p(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return p(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var L={k256:null,p224:null,p192:null,p25519:null};function N(u,e){this.name=u,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}N.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},N.prototype.ireduce=function(e){var r=e,n;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),n=r.bitLength();while(n>this.n);var i=n<this.n?-1:r.ucmp(this.p);return i===0?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):r.strip!==void 0?r.strip():r._strip(),r},N.prototype.split=function(e,r){e.iushrn(this.n,0,r)},N.prototype.imulK=function(e){return e.imul(this.k)};function j(){N.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}I(j,N),j.prototype.split=function(e,r){for(var n=4194303,i=Math.min(e.length,9),f=0;f<i;f++)r.words[f]=e.words[f];if(r.length=i,e.length<=9){e.words[0]=0,e.length=1;return}var c=e.words[9];for(r.words[r.length++]=c&n,f=10;f<e.length;f++){var h=e.words[f]|0;e.words[f-10]=(h&n)<<4|c>>>22,c=h}c>>>=22,e.words[f-10]=c,c===0&&e.length>10?e.length-=10:e.length-=9},j.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var r=0,n=0;n<e.length;n++){var i=e.words[n]|0;r+=i*977,e.words[n]=r&67108863,r=i*64+(r/67108864|0)}return e.words[e.length-1]===0&&(e.length--,e.words[e.length-1]===0&&e.length--),e};function K(){N.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}I(K,N);function $(){N.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}I($,N);function Q(){N.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}I(Q,N),Q.prototype.imulK=function(e){for(var r=0,n=0;n<e.length;n++){var i=(e.words[n]|0)*19+r,f=i&67108863;i>>>=26,e.words[n]=f,r=i}return r!==0&&(e.words[e.length++]=r),e},o._prime=function(e){if(L[e])return L[e];var r;if(e==="k256")r=new j;else if(e==="p224")r=new K;else if(e==="p192")r=new $;else if(e==="p25519")r=new Q;else throw new Error("Unknown prime "+e);return L[e]=r,r};function Y(u){if(typeof u=="string"){var e=o._prime(u);this.m=e.p,this.prime=e}else p(u.gtn(1),"modulus must be greater than 1"),this.m=u,this.prime=null}Y.prototype._verify1=function(e){p(e.negative===0,"red works only with positives"),p(e.red,"red works only with red numbers")},Y.prototype._verify2=function(e,r){p((e.negative|r.negative)===0,"red works only with positives"),p(e.red&&e.red===r.red,"red works only with red numbers")},Y.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},Y.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},Y.prototype.add=function(e,r){this._verify2(e,r);var n=e.add(r);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},Y.prototype.iadd=function(e,r){this._verify2(e,r);var n=e.iadd(r);return n.cmp(this.m)>=0&&n.isub(this.m),n},Y.prototype.sub=function(e,r){this._verify2(e,r);var n=e.sub(r);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},Y.prototype.isub=function(e,r){this._verify2(e,r);var n=e.isub(r);return n.cmpn(0)<0&&n.iadd(this.m),n},Y.prototype.shl=function(e,r){return this._verify1(e),this.imod(e.ushln(r))},Y.prototype.imul=function(e,r){return this._verify2(e,r),this.imod(e.imul(r))},Y.prototype.mul=function(e,r){return this._verify2(e,r),this.imod(e.mul(r))},Y.prototype.isqr=function(e){return this.imul(e,e.clone())},Y.prototype.sqr=function(e){return this.mul(e,e)},Y.prototype.sqrt=function(e){if(e.isZero())return e.clone();var r=this.m.andln(3);if(p(r%2===1),r===3){var n=this.m.add(new o(1)).iushrn(2);return this.pow(e,n)}for(var i=this.m.subn(1),f=0;!i.isZero()&&i.andln(1)===0;)f++,i.iushrn(1);p(!i.isZero());var c=new o(1).toRed(this),h=c.redNeg(),s=this.m.subn(1).iushrn(1),t=this.m.bitLength();for(t=new o(2*t*t).toRed(this);this.pow(t,s).cmp(h)!==0;)t.redIAdd(h);for(var a=this.pow(t,i),w=this.pow(e,i.addn(1).iushrn(1)),D=this.pow(e,i),Z=f;D.cmp(c)!==0;){for(var F=D,V=0;F.cmp(c)!==0;V++)F=F.redSqr();p(V<Z);var q=this.pow(a,new o(1).iushln(Z-V-1));w=w.redMul(q),a=q.redSqr(),D=D.redMul(a),Z=V}return w},Y.prototype.invm=function(e){var r=e._invmp(this.m);return r.negative!==0?(r.negative=0,this.imod(r).redNeg()):this.imod(r)},Y.prototype.pow=function(e,r){if(r.isZero())return new o(1).toRed(this);if(r.cmpn(1)===0)return e.clone();var n=4,i=new Array(1<<n);i[0]=new o(1).toRed(this),i[1]=e;for(var f=2;f<i.length;f++)i[f]=this.mul(i[f-1],e);var c=i[0],h=0,s=0,t=r.bitLength()%26;for(t===0&&(t=26),f=r.length-1;f>=0;f--){for(var a=r.words[f],w=t-1;w>=0;w--){var D=a>>w&1;if(c!==i[0]&&(c=this.sqr(c)),D===0&&h===0){s=0;continue}h<<=1,h|=D,s++,!(s!==n&&(f!==0||w!==0))&&(c=this.mul(c,i[h]),s=0,h=0)}t=26}return c},Y.prototype.convertTo=function(e){var r=e.umod(this.m);return r===e?r.clone():r},Y.prototype.convertFrom=function(e){var r=e.clone();return r.red=null,r},o.mont=function(e){return new ee(e)};function ee(u){Y.call(this,u),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)}I(ee,Y),ee.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},ee.prototype.convertFrom=function(e){var r=this.imod(e.mul(this.rinv));return r.red=null,r},ee.prototype.imul=function(e,r){if(e.isZero()||r.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(r),i=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),f=n.isub(i).iushrn(this.shift),c=f;return f.cmp(this.m)>=0?c=f.isub(this.m):f.cmpn(0)<0&&(c=f.iadd(this.m)),c._forceRed(this)},ee.prototype.mul=function(e,r){if(e.isZero()||r.isZero())return new o(0)._forceRed(this);var n=e.mul(r),i=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),f=n.isub(i).iushrn(this.shift),c=f;return f.cmp(this.m)>=0?c=f.isub(this.m):f.cmpn(0)<0&&(c=f.iadd(this.m)),c._forceRed(this)},ee.prototype.invm=function(e){var r=this.imod(e._invmp(this.m).mul(this.r2));return r._forceRed(this)}}(fe,this)},9939:(fe,x,T)=>{"use strict";var S;S={value:!0};var y=T(1024);function p(F){throw new Error("makeNodeDisklet is not available on this platform")}function I(){throw new Error("makeReactNativeDisklet is not available on this platform")}function o(F,V,q,re,G,H,oe){try{var ue=F[H](oe),be=ue.value}catch(ie){q(ie);return}ue.done?V(be):Promise.resolve(be).then(re,G)}function m(F){return function(){var V=this,q=arguments;return new Promise(function(re,G){var H=F.apply(V,q);function oe(be){o(H,re,G,oe,ue,"next",be)}function ue(be){o(H,re,G,oe,ue,"throw",be)}oe(void 0)})}}function l(){return l=Object.assign||function(F){for(var V=1;V<arguments.length;V++){var q=arguments[V];for(var re in q)Object.prototype.hasOwnProperty.call(q,re)&&(F[re]=q[re])}return F},l.apply(this,arguments)}function g(F){if(/^\//.test(F))throw new Error("Absolute paths are not supported");for(var V=F.split("/"),q=0,re=0;q<V.length;){var G=V[q++];if(G===".."?re--:G!=="."&&G!==""&&(V[re++]=G),re<0)throw new Error("Path would escape folder")}return V.slice(0,re).join("/")}function M(F){return F===""?F:F+"/"}function E(F){for(var V=[],q=0;q<F.length;++q){var re=F.key(q);re!=null&&V.push(re)}return V}function d(F,V){F===void 0&&(F=window.localStorage),V===void 0&&(V={});var q=V.prefix!=null?M(V.prefix):"/";return{delete:function(G){var H=g(G);F.getItem(q+H)!=null&&F.removeItem(q+H);for(var oe=M(H),ue=0,be=E(F);ue<be.length;ue++){var ie=be[ue];ie.indexOf(q+oe)===0&&F.removeItem(ie)}return Promise.resolve()},getData:function(G){return this.getText(G).then(function(H){return y.base64.parse(H)})},getText:function(G){var H=g(G),oe=F.getItem(q+H);return oe==null?Promise.reject(new Error('Cannot load "'+H+'"')):Promise.resolve(oe)},list:function(G){return m(function*(){G===void 0&&(G="");var H=g(G),oe={};F.getItem(q+H)!=null&&(oe[H]="file");for(var ue=M(H),be=0,ie=E(F);be<ie.length;be++){var J=ie[be];if(J.indexOf(q+ue)===0){var pe=J.indexOf("/",q.length+ue.length);pe<0?oe[J.slice(q.length)]="file":oe[J.slice(q.length,pe)]="folder"}}return Promise.resolve(oe)})()},setData:function(G,H){return this.setText(G,y.base64.stringify(H))},setText:function(G,H){return typeof H!="string"?Promise.reject(new TypeError("setText expects a string")):(F.setItem(q+g(G),H),Promise.resolve())}}}function A(F){return F===void 0&&(F={}),{delete:function(q){var re=g(q);F["/"+re]!=null&&delete F["/"+re];for(var G=M(re),H=0,oe=Object.keys(F);H<oe.length;H++){var ue=oe[H];ue.indexOf("/"+G)===0&&delete F[ue]}return Promise.resolve()},getData:function(q){var re=g(q),G=F["/"+re];return G==null?Promise.reject(new Error('Cannot load "'+re+'"')):typeof G=="string"?Promise.reject(new Error('"'+re+'" is a text file.')):Promise.resolve(G)},getText:function(q){var re=g(q),G=F["/"+re];return G==null?Promise.reject(new Error('Cannot load "'+re+'"')):typeof G!="string"?Promise.reject(new Error('"'+re+'" is a binary file.')):Promise.resolve(G)},list:function(q){return m(function*(){q===void 0&&(q="");var re=g(q),G={};F["/"+re]!=null&&(G[re]="file");for(var H=M(re),oe=0,ue=Object.keys(F);oe<ue.length;oe++){var be=ue[oe];if(be.indexOf("/"+H)===0){var ie=be.indexOf("/",1+H.length);ie<0?G[be.slice(1)]="file":G[be.slice(1,ie)]="folder"}}return Promise.resolve(G)})()},setData:function(q,re){var G=re,H=Uint8Array.from(G);return F["/"+g(q)]=H,Promise.resolve()},setText:function(q,re){return typeof re!="string"?Promise.reject(new TypeError("setText expects a string")):(F["/"+g(q)]=re,Promise.resolve())}}}var v=function(){function F(q,re){this._disklet=q,this._path=re}var V=F.prototype;return V.delete=function(){return this._disklet.delete(this._path)},V.getData=function(){return this._disklet.getData(this._path)},V.getText=function(){return this._disklet.getText(this._path)},V.setData=function(re){return this._disklet.setData(this._path,re)},V.setText=function(re){return this._disklet.setText(this._path,re)},F}(),b=function(){function F(q,re){this._disklet=q,this._path=re}var V=F.prototype;return V.delete=function(){return this._disklet.delete(this._path)},V.file=function(re){return new v(this._disklet,this._path+"/"+re)},V.folder=function(re){return new F(this._disklet,this._path+"/"+re)},V.listFiles=function(){return this._disklet.list(this._path).then(function(re){return Object.keys(re).filter(function(G){return re[G]==="file"}).map(function(G){return G.replace(/^.*\//,"")})})},V.listFolders=function(){return this._disklet.list(this._path).then(function(re){return Object.keys(re).filter(function(G){return re[G]==="folder"}).map(function(G){return G.replace(/^.*\//,"")})})},F}();function k(F){return new b(F,".")}function B(F,V){for(var q=0,re=0;q<V.length;){var G=V[q++];if(G===".."?re--:G!=="."&&G!==""&&(V[re++]=G),re<0)throw new Error("Path would escape folder")}for(q=0;q<re;++q)F=F.folder(V[q]);return F}function U(F,V){var q=V.split("/"),re=q.pop();if(re==null)throw new Error("Empty path");return B(F,q).file(re)}function C(F,V){var q=V.split("/");return B(F,q)}function L(F,V){return F.listFiles().then(function(q){return Promise.all(q.map(function(re){return V(F.file(re),re,F)}))})}function N(F,V){return F.listFolders().then(function(q){return Promise.all(q.map(function(re){return V(F.folder(re),re,F)}))})}function j(F,V){function q(re,G,H){return Promise.all([L(re,function(oe,ue){return G(oe,H+ue,re)}),N(re,function(oe,ue){return q(oe,G,H+ue+"/")})]).then(function(oe){var ue=oe[0],be=oe[1];return ue.concat.apply(ue,be)})}return q(F,V,"")}function K(F,V){console.log(V+' "'+F+'"')}function $(F,V,q){var re=q.callback,G=re===void 0?K:re,H=q.verbose,oe=H===void 0?!1:H;(oe||/set|delete/.test(V))&&G(F,V)}var Q=function(){function F(q,re,G){this._file=q,this._path=re,this._opts=G}var V=F.prototype;return V.delete=function(){return $(this._path,"delete file",this._opts),this._file.delete()},V.getData=function(){return $(this._path,"get data",this._opts),this._file.getData()},V.getText=function(){return $(this._path,"get text",this._opts),this._file.getText()},V.setData=function(re){return $(this._path,"set data",this._opts),this._file.setData(re)},V.setText=function(re){return $(this._path,"set text",this._opts),this._file.setText(re)},V.getPath=function(){return this._path},F}(),Y=function(){function F(q,re,G){this._folder=q,this._path=re,this._opts=G}var V=F.prototype;return V.delete=function(){return $(this._path,"delete folder",this._opts),this._folder.delete()},V.file=function(re){return new Q(this._folder.file(re),this._path+re,this._opts)},V.folder=function(re){return new F(this._folder.folder(re),this._path+re+"/",this._opts)},V.listFiles=function(){return $(this._path,"list files",this._opts),this._folder.listFiles()},V.listFolders=function(){return $(this._path,"list folders",this._opts),this._folder.listFolders()},F}();function ee(F,V){return V===void 0&&(V={}),new Y(F,"",V)}function u(F,V){var q={},re=[];return F.forEach(function(G){/\._x_$/.test(G)?q[G]=!0:(q[G+"._x_"]=!0,re.push(G))}),V.forEach(function(G){q[G+"._x_"]||re.push(G)}),re}var e=function(){function F(q,re,G){this._master=q,this._fallback=re,this._whiteout=G}var V=F.prototype;return V.delete=function(){return Promise.all([this._whiteout.setData([]),this._master.delete().catch(function(re){return null})])},V.getData=function(){var re=this;return this._master.getData().catch(function(G){return re._whiteout.getData().then(function(H){throw new Error("File has been deleted")},function(H){return re._fallback.getData()})})},V.getText=function(){var re=this;return this._master.getText().catch(function(G){return re._whiteout.getData().then(function(H){throw new Error("File has been deleted")},function(H){return re._fallback.getText()})})},V.setData=function(re){return this._master.setData(re)},V.setText=function(re){return this._master.setText(re)},V.getPath=function(){throw new Error("Cannot call getPath on a Union Folder")},F}(),r=function(){function F(q,re){this._master=q,this._fallback=re}var V=F.prototype;return V.delete=function(){return Promise.all([L(this,function(re){return re.delete()}),N(this,function(re){return re.delete()})]).then(function(){})},V.file=function(re){return new e(this._master.file(re),this._fallback.file(re),this._master.file(re+"._x_"))},V.folder=function(re){return new F(this._master.folder(re),this._fallback.folder(re))},V.listFiles=function(){return Promise.all([this._master.listFiles(),this._fallback.listFiles()]).then(function(re){return u(re[0],re[1])})},V.listFolders=function(){return Promise.all([this._master.listFolders(),this._fallback.listFolders()]).then(function(re){return u(re[0],re[1])})},F}();function n(F,V){return new r(F,V)}function i(F,V){return F.list(V).then(function(q){return Promise.all(Object.keys(q).filter(function(re){return q[re]==="folder"}).map(function(re){return i(F,re)})).then(function(re){return l.apply(void 0,[q].concat(re))})})}function f(F){return Object.keys(F).filter(function(V){return F[V]==="file"})}function c(F){return Object.keys(F).filter(function(V){return F[V]==="folder"})}function h(F,V){V===void 0&&(V={});var q=V,re=q.callback,G=re===void 0?function(be,ie){console.log(ie+' "'+be+'"')}:re,H=q.verbose,oe=H===void 0?!1:H,ue=function(ie,J){(oe||/set|delete/.test(ie))&&G(J,ie)};return{delete:function(ie){return ue("delete",g(ie)),F.delete(ie)},getData:function(ie){return ue("get data",g(ie)),F.getData(ie)},getText:function(ie){return ue("get text",g(ie)),F.getText(ie)},list:function(ie){return ue("list",ie!=null?g(ie):""),F.list(ie)},setData:function(ie,J){return ue("set data",g(ie)),F.setData(ie,J)},setText:function(ie,J){return ue("set text",g(ie)),F.setText(ie,J)}}}function s(F,V){return{delete:function(re){return Promise.all([F.delete(re),V.delete(re)])},getData:function(re){return F.getData(re).catch(function(G){return V.getData(re)})},getText:function(re){return F.getText(re).catch(function(G){return V.getText(re)})},list:function(re){return Promise.all([F.list(re),V.list(re)]).then(function(G){var H=G[0],oe=G[1];return l(oe,H)})},setData:function(re,G){return F.setData(re,G)},setText:function(re,G){return F.setText(re,G)}}}function t(F,V){var q=M(g(V));return{delete:function(G){return F.delete(q+G)},getData:function(G){return F.getData(q+G)},getText:function(G){return F.getText(q+G)},list:function(G){return G===void 0&&(G="."),F.list(q+G).then(function(H){var oe={};for(var ue in H)oe[ue.replace(q,"")]=H[ue];return oe})},setData:function(G,H){return F.setData(q+G,H)},setText:function(G,H){return F.setText(q+G,H)}}}function a(F,V){return k(d(F,V))}function w(F){return k(A(F))}function D(F){return k(p())}function Z(){return k(I())}S=i,S=k,S=f,S=c,S=U,S=C,S=h,S=d,S=a,S=ee,x.cQ=A,S=w,S=p,S=D,S=I,S=Z,S=n,S=j,S=L,S=N,S=s,x.my=t},3835:(fe,x,T)=>{const S=T(5364),y="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";fe.exports=S(y)},8212:(fe,x,T)=>{"use strict";var S=T(3835);fe.exports=function(y){function p(l){var g=Uint8Array.from(l),M=y(g),E=g.length+4,d=new Uint8Array(E);return d.set(g,0),d.set(M.subarray(0,4),g.length),S.encode(d,E)}function I(l){var g=l.slice(0,-4),M=l.slice(-4),E=y(g);if(!(M[0]^E[0]|M[1]^E[1]|M[2]^E[2]|M[3]^E[3]))return g}function o(l){var g=S.decodeUnsafe(l);if(g)return I(g)}function m(l){var g=S.decode(l),M=I(g,y);if(!M)throw new Error("Invalid checksum");return M}return{encode:p,decode:m,decodeUnsafe:o}}},2577:(fe,x,T)=>{"use strict";var{sha256:S}=T(2623),y=T(8212);function p(I){return S(S(I))}fe.exports=y(p)},5170:(fe,x,T)=>{"use strict";var S=T(8287).Buffer;Object.defineProperty(x,"__esModule",{value:!0}),x.ECPairFactory=x.networks=void 0;const y=T(2577),p=T(5249);x.networks=p;const I=T(953),o=T(3209),m=T(7513),l=T(709),g=I.typeforce.maybe(I.typeforce.compile({compressed:I.maybe(I.Boolean),network:I.maybe(I.Network)})),M=d=>d.length===32?d:d.slice(1,33);function E(d){(0,l.testEcc)(d);function A(L){return d.isPoint(L)}function v(L,N){if(I.typeforce(I.Buffer256bit,L),!d.isPrivate(L))throw new TypeError("Private key not in range [1, n)");return I.typeforce(g,N),new C(L,void 0,N)}function b(L,N){return I.typeforce(d.isPoint,L),I.typeforce(g,N),new C(void 0,L,N)}function k(L,N,j=y.decode){const K=S.from(j(L));if(N<256){if(K.length===33)return{version:K[0],privateKey:K.slice(1,33),compressed:!1};if(K.length!==34)throw new Error("Invalid WIF length");if(K[33]!==1)throw new Error("Invalid compression flag");return{version:K[0],privateKey:K.slice(1,33),compressed:!0}}if(K.length===34)return{version:K.readUInt16LE(1),privateKey:K.slice(2,34),compressed:!1};if(K.length!==35)throw new Error("Invalid WIF length");if(K[34]!==1)throw new Error("Invalid compression flag");return{version:K.readUInt16LE(1),privateKey:K.slice(2,34),compressed:!0}}function B(L,N,j){const K=!I.Array(N)&&typeof N<"u",$=K?k(L,N.wif,j):m.decode(L),Q=$.version;if(I.Array(N)){if(N=N.filter(Y=>Q===Y.wif).pop(),!N)throw new Error("Unknown network version")}else if(N=N||p.bitcoin,Q!==N.wif)throw new Error("Invalid network version");return v($.privateKey,{compressed:$.compressed,network:N})}function U(L){I.typeforce(g,L),L===void 0&&(L={});const N=L.rng||o;let j;do j=N(32),I.typeforce(I.Buffer256bit,j);while(!d.isPrivate(j));return v(j,L)}class C{constructor(N,j,K){Ho(this,"__D");Ho(this,"__Q");Ho(this,"compressed");Ho(this,"network");Ho(this,"lowR");this.__D=N,this.__Q=j,this.lowR=!1,K===void 0&&(K={}),this.compressed=K.compressed===void 0?!0:K.compressed,this.network=K.network||p.bitcoin,j!==void 0&&(this.__Q=S.from(d.pointCompress(j,this.compressed)))}get privateKey(){return this.__D}get publicKey(){if(!this.__Q){const N=d.pointFromScalar(this.__D,this.compressed);this.__Q=S.from(N)}return this.__Q}toWIF(N){if(!this.__D)throw new Error("Missing private key");return N!=null?N(this.network.wif,this.__D,this.compressed):m.encode(this.network.wif,this.__D,this.compressed)}tweak(N){return this.privateKey?this.tweakFromPrivateKey(N):this.tweakFromPublicKey(N)}sign(N,j){if(!this.__D)throw new Error("Missing private key");if(j===void 0&&(j=this.lowR),j===!1)return S.from(d.sign(N,this.__D));{let K=d.sign(N,this.__D);const $=S.alloc(32,0);let Q=0;for(;K[0]>127;)Q++,$.writeUIntLE(Q,0,6),K=d.sign(N,this.__D,$);return S.from(K)}}signSchnorr(N){if(!this.privateKey)throw new Error("Missing private key");if(!d.signSchnorr)throw new Error("signSchnorr not supported by ecc library");return S.from(d.signSchnorr(N,this.privateKey))}verify(N,j){return d.verify(N,this.publicKey,j)}verifySchnorr(N,j){if(!d.verifySchnorr)throw new Error("verifySchnorr not supported by ecc library");return d.verifySchnorr(N,this.publicKey.subarray(1,33),j)}tweakFromPublicKey(N){const j=M(this.publicKey),K=d.xOnlyPointAddTweak(j,N);if(!K||K.xOnlyPubkey===null)throw new Error("Cannot tweak public key!");const $=S.from([K.parity===0?2:3]);return b(S.concat([$,K.xOnlyPubkey]),{network:this.network,compressed:this.compressed})}tweakFromPrivateKey(N){const K=this.publicKey[0]===3||this.publicKey[0]===4&&(this.publicKey[64]&1)===1?d.privateNegate(this.privateKey):this.privateKey,$=d.privateAdd(K,N);if(!$)throw new Error("Invalid tweaked private key!");return v(S.from($),{network:this.network,compressed:this.compressed})}}return{isPoint:A,fromPrivateKey:v,fromPublicKey:b,fromWIF:B,makeRandom:U}}x.ECPairFactory=E},8700:(fe,x,T)=>{"use strict";var S;S={value:!0},S=x.dg=S=void 0;var y=T(5170);S={enumerable:!0,get:function(){return y.ECPairFactory}},Object.defineProperty(x,"dg",{enumerable:!0,get:function(){return y.ECPairFactory}}),S={enumerable:!0,get:function(){return y.networks}}},5249:(fe,x)=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0}),x.testnet=x.bitcoin=void 0,x.bitcoin={messagePrefix:`Bitcoin Signed Message:
|
|
38
38
|
`,bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},x.testnet={messagePrefix:`Bitcoin Signed Message:
|
|
39
|
-
`,bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239}},709:(fe,x,T)=>{"use strict";var S=T(8287).Buffer;Object.defineProperty(x,"__esModule",{value:!0}),x.testEcc=void 0;const y=o=>S.from(o,"hex");function p(o){I(o.isPoint(y("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),I(!o.isPoint(y("030000000000000000000000000000000000000000000000000000000000000005"))),I(o.isPrivate(y("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),I(o.isPrivate(y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),I(!o.isPrivate(y("0000000000000000000000000000000000000000000000000000000000000000"))),I(!o.isPrivate(y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),I(!o.isPrivate(y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),I(S.from(o.privateAdd(y("0000000000000000000000000000000000000000000000000000000000000001"),y("0000000000000000000000000000000000000000000000000000000000000000"))).equals(y("0000000000000000000000000000000000000000000000000000000000000001"))),I(o.privateAdd(y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),y("0000000000000000000000000000000000000000000000000000000000000003"))===null),I(S.from(o.privateAdd(y("e211078564db65c3ce7704f08262b1f38f1ef412ad15b5ac2d76657a63b2c500"),y("b51fbb69051255d1becbd683de5848242a89c229348dd72896a87ada94ae8665"))).equals(y("9730c2ee69edbb958d42db7460bafa18fef9d955325aec99044c81c8282b0a24"))),I(S.from(o.privateNegate(y("0000000000000000000000000000000000000000000000000000000000000001"))).equals(y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),I(S.from(o.privateNegate(y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"))).equals(y("0000000000000000000000000000000000000000000000000000000000000003"))),I(S.from(o.privateNegate(y("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(y("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792"))),I(S.from(o.pointCompress(y("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!0)).equals(y("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),I(S.from(o.pointCompress(y("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!1)).equals(y("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),I(S.from(o.pointCompress(y("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!0)).equals(y("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),I(S.from(o.pointCompress(y("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!1)).equals(y("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),I(S.from(o.pointFromScalar(y("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(y("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),I(o.xOnlyPointAddTweak(y("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))===null);let m=o.xOnlyPointAddTweak(y("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),y("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));I(S.from(m.xOnlyPubkey).equals(y("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&m.parity===1),m=o.xOnlyPointAddTweak(y("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),y("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47")),I(S.from(m.xOnlyPubkey).equals(y("9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"))&&m.parity===0),I(S.from(o.sign(y("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))).equals(y("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),I(o.verify(y("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),y("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),y("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),o.signSchnorr&&I(S.from(o.signSchnorr(y("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),y("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),y("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906"))).equals(y("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),o.verifySchnorr&&I(o.verifySchnorr(y("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),y("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),y("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}x.testEcc=p;function I(o){if(!o)throw new Error("ecc library invalid")}},953:(fe,x,T)=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0}),x.maybe=x.Boolean=x.Array=x.Buffer256bit=x.Network=x.typeforce=void 0,x.typeforce=T(8676),x.Network=x.typeforce.compile({messagePrefix:x.typeforce.oneOf(x.typeforce.Buffer,x.typeforce.String),bip32:{public:x.typeforce.UInt32,private:x.typeforce.UInt32},pubKeyHash:x.typeforce.UInt8,scriptHash:x.typeforce.UInt8,wif:x.typeforce.UInt8}),x.Buffer256bit=x.typeforce.BufferN(32),x.Array=x.typeforce.Array,x.Boolean=x.typeforce.Boolean,x.maybe=x.typeforce.maybe},8405:(fe,x,T)=>{"use strict";var S;S={value:!0};var y=T(4319),p=T(3812),I=T(9983),o=T(9796),m=T(9495),l=T(9977),g=T(5364),M=T(3836),E=T(7952),d=T(9112),A=T(1407),v=T(6833),b=T(5043),k=T(5817),B=T(6729),U=T(420),C=T(3303),L=T(1565),N=T(3092);function j(_){return _&&typeof _=="object"&&"default"in _?_:{default:_}}var K=j(I),$=j(g),Q=j(M),Y=j(E),ee=j(B),u=j(L),e=j(N);function r(_,P,W,X,ne,se){return new Promise((de,Be)=>{const Ae=[];for(let Ue=0;Ue<_.length;++Ue)Ae[Ue]=_[Ue];K.default(Ae,P,W,X,ne,se,(Ue,$e,nt)=>{if(Ue!=null)return Be(Ue);if(nt!=null)return de(Uint8Array.from(nt))})})}function n(){let _=0;return P=>{const W=new Uint8Array(P);for(let X=0;X<P;++X)_=5*_+3&255,W[X]=_;return W}}const i=()=>Promise.reject(new Error("Fake network error"));function f(){return{random:n(),scrypt:r,disklet:p.makeMemoryDisklet(),fetch:i,fetchCors:i}}class c{getFirstWalletInfo(P){return this.allKeys.find(X=>X.type===P)}getWalletInfo(P){return this.allKeys.find(X=>X.id===P)}listWalletIds(){return this.allKeys.map(P=>P.id)}}y.shareData(c.prototype,"AccountSync");function h(_){const P=_.length<10,W=!/[0-9]/.test(_),X=!/[a-z]/.test(_),ne=!/[A-Z]/.test(_),se=(/[0-9]/.test(_)?10:0)+(/[A-Z]/.test(_)?26:0)+(/[a-z]/.test(_)?26:0)+(/[^0-9A-Za-z]/.test(_)?30:0);return{secondsToCrack:Math.pow(se,_.length)/1e6,tooShort:P,noNumber:W,noLowerCase:X,noUpperCase:ne,passed:_.length>=16||!(P||W||ne||X)}}y.shareData({checkPasswordRules:h});function s(_){const P=_.toLowerCase().replace(/[ \f\r\n\t\v]+/g," ").replace(/ $/,"").replace(/^ /,"");for(let W=0;W<P.length;++W){const X=P.charCodeAt(W);if(X<32||X>126)throw new Error("Bad characters in username")}return P}y.shareData({fixUsername:s});function t(_){let P,W=!1;const X={next:async()=>{if(P==null&&(P=await this.$internalStreamTransactions(_)),!W){const ne=await P.next();if(!ne.done)return ne;y.close(P),W=!0}return{done:!0,value:void 0}},return:async()=>(P!=null&&!W&&(y.close(P),W=!0),{done:!0,value:void 0}),[Symbol.asyncIterator]:()=>X};return X}y.shareData({streamTransactions:t},"CurrencyWalletSync");const a=l.asCodec(_=>o.base16.parse(l.asString(_)),_=>o.base16.stringify(_).toLowerCase()),w=l.asCodec(_=>o.base32.parse(l.asString(_),{loose:!0}),_=>o.base32.stringify(_,{pad:!1})),D=l.asCodec(_=>o.base64.parse(l.asString(_)),_=>o.base64.stringify(_)),Z=l.asObject({voucherId:l.asString,activates:l.asDate,created:l.asDate,ip:l.asString,ipDescription:l.asString,deviceDescription:l.asOptional(l.asString)}),F=l.asObject({encryptionType:l.asNumber,data_base64:D,iv_hex:a}),V=l.asObject({salt_hex:a,n:l.asNumber,r:l.asNumber,p:l.asNumber}),q=l.asObject({loginRequest:l.asOptional(l.asObject({appId:l.asString}).withRest),publicKey:D,timeout:l.asOptional(l.asNumber)}).withRest,re=l.asObject({publicKey:D,box:F}),G=l.asArray(D),H=l.asObject({data:l.asUnknown,challengeId:l.asOptional(l.asString),deviceDescription:l.asOptional(l.asString),otp:l.asOptional(l.asString),syncToken:l.asOptional(l.asString),voucherId:l.asOptional(l.asString),voucherAuth:l.asOptional(D),loginId:l.asOptional(D),loginAuth:l.asOptional(D),userId:l.asOptional(D),passwordAuth:l.asOptional(D),pin2Id:l.asOptional(D),pin2Auth:l.asOptional(D),recovery2Id:l.asOptional(D),recovery2Auth:l.asOptional(G),loginIds:l.asOptional(l.asArray(D)),otpResetAuth:l.asOptional(l.asString),did:l.asOptional(l.asString),l1:l.asOptional(D),lp1:l.asOptional(D),lpin1:l.asOptional(D),lra1:l.asOptional(D),recoveryAuth:l.asOptional(D)}),oe=l.asObject({results:l.asOptional(l.asUnknown),status_code:l.asNumber,message:l.asString}),ue=l.asObject({otpTimeout:l.asOptional(l.asNumber,7*24*60*60),otpKey:w}),be=l.asObject({passwordAuth:D,passwordAuthBox:F,passwordAuthSnrp:V,passwordBox:F,passwordKeySnrp:V}),ie=l.asObject({pin2Id:D}),J=l.asObject({pin2Id:l.asOptional(D),pin2Auth:l.asOptional(D),pin2Box:l.asOptional(F),pin2KeyBox:l.asOptional(F),pin2TextBox:F}),pe=l.asObject({recovery2Id:D}),Ge=l.asObject({recovery2Id:D,recovery2Auth:G,recovery2Box:F,recovery2KeyBox:F,question2Box:F}),ce=l.asObject({loginAuthBox:F,loginAuth:D}),te=l.asObject({userId:D,userTextBox:F}),le=l.asObject({approvedVouchers:l.asOptional(l.asArray(l.asString)),rejectedVouchers:l.asOptional(l.asArray(l.asString))}),ge=l.asObject({keyBoxes:l.asArray(F),newSyncKeys:l.asOptional(l.asArray(l.asString),()=>[])}),Pe=l.asObject({appId:l.asString,loginId:D,parentBox:l.asOptional(F)}),lt=l.asObject({challengeId:l.asString,challengeUri:l.asString}),Le=l.asObject({request:q,replies:l.asArray(re)}),ze=l.asValue(!0),kt=l.asObject({appId:l.asString,created:l.asDate,loginId:D,syncToken:l.asOptional(l.asString),children:l.asOptional(l.asArray(_=>kt(_))),parentBox:l.asOptional(F),otpKey:l.asOptional(l.asEither(ze,w)),otpResetDate:l.asOptional(l.asDate),otpTimeout:l.asOptional(l.asNumber),passwordAuthBox:l.asOptional(F),passwordAuthSnrp:l.asOptional(V),passwordBox:l.asOptional(l.asEither(ze,F)),passwordKeySnrp:l.asOptional(V),pin2Box:l.asOptional(l.asEither(ze,F)),pin2KeyBox:l.asOptional(F),pin2TextBox:l.asOptional(F),question2Box:l.asOptional(F),recovery2Box:l.asOptional(l.asEither(ze,F)),recovery2KeyBox:l.asOptional(F),loginAuthBox:l.asOptional(F),userId:l.asOptional(D),userTextBox:l.asOptional(F),pendingVouchers:l.asOptional(l.asArray(Z),()=>[]),keyBoxes:l.asOptional(l.asArray(F)),mnemonicBox:l.asOptional(F),rootKeyBox:l.asOptional(F),syncKeyBox:l.asOptional(F)}),ae=l.asArray(l.asObject({loginId:D,otpResetPending:l.asOptional(l.asBoolean,!1),pendingVouchers:l.asOptional(l.asArray(Z),()=>[]),recovery2Corrupt:l.asOptional(l.asBoolean,!1)})),he=l.asObject({login_id:l.asOptional(D),otp_reset_auth:l.asOptional(l.asString),otp_timeout_date:l.asOptional(l.asDate),reason:l.asOptional(l.asValue("ip","otp"),"otp"),voucher_activates:l.asOptional(l.asDate),voucher_auth:l.asOptional(D),voucher_id:l.asOptional(l.asString)}),je=l.asObject({otpResetDate:l.asDate}),Ie=l.asObject({wait_seconds:l.asOptional(l.asNumber)}),Ce=l.asObject({question2Box:F}),ut=l.asObject({loginId:D,passwordAuthSnrp:l.asOptional(V),questionBox:l.asOptional(F),questionKeySnrp:l.asOptional(V),recoveryAuthSnrp:l.asOptional(V)}),De=l.uncleaner(F),ye=l.uncleaner(re),we=l.uncleaner(q),ve=l.uncleaner(H),Ee=l.uncleaner(oe),rt=l.uncleaner(ue),Fe=l.uncleaner(be),He=l.uncleaner(ie),yt=l.uncleaner(J),Ke=l.uncleaner(pe),Ze=l.uncleaner(Ge),At=l.uncleaner(ce),Ve=l.uncleaner(te),tt=l.uncleaner(le),qt=l.uncleaner(ge),et=l.uncleaner(Pe),st=l.uncleaner(lt),rr=l.uncleaner(Le),at=l.uncleaner(kt),ft=l.uncleaner(ae),Qe=l.uncleaner(he),xe=l.uncleaner(je),Oe=l.uncleaner(Ie),ht=l.uncleaner(Ce),Ne=l.uncleaner(ut),qe=l.asObject(F),Dt=l.asObject({loginId:D,voucherAuth:D,voucherId:l.asString,created:l.asDate,activates:l.asDate,status:l.asValue("pending","approved","rejected"),ip:l.asString,ipDescription:l.asString,deviceDescription:l.asOptional(l.asString)}),Xe=l.asObject({appId:l.asString,created:l.asOptional(l.asDate,()=>new Date),loginId:D,children:l.asOptional(l.asArray(_=>Xe(_)),()=>[]),parentBox:l.asOptional(F),parentId:()=>{},otpKey:l.asOptional(w),otpResetAuth:l.asOptional(l.asString),otpResetDate:l.asOptional(l.asDate),otpTimeout:l.asOptional(l.asNumber),passwordAuth:l.asOptional(D),passwordAuthBox:l.asOptional(F),passwordAuthSnrp:l.asOptional(V),passwordBox:l.asOptional(F),passwordKeySnrp:l.asOptional(V),pin2Id:l.asOptional(D),pin2Auth:l.asOptional(D),pin2Box:l.asOptional(F),pin2KeyBox:l.asOptional(F),pin2TextBox:l.asOptional(F),recovery2Id:l.asOptional(D),recovery2Auth:l.asOptional(G),question2Box:l.asOptional(F),recovery2Box:l.asOptional(F),recovery2KeyBox:l.asOptional(F),loginAuth:l.asOptional(D),loginAuthBox:l.asOptional(F),userId:l.asOptional(D),userTextBox:l.asOptional(F),keyBoxes:l.asOptional(l.asArray(F),()=>[]),mnemonicBox:l.asOptional(F),rootKeyBox:l.asOptional(F),syncKeyBox:l.asOptional(F),vouchers:l.asOptional(l.asArray(Dt),()=>[]),pinBox:l.asOptional(F),pinId:l.asOptional(l.asString),pinKeyBox:l.asOptional(F)}),ot=l.uncleaner(Xe),Gt=l.uncleaner(qe),xt=$.default("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),gt={parse(_){return xt.decode(_)},stringify(_){return xt.encode(_)}},bt={parse(_){const P=encodeURI(_),W=new Uint8Array(P.length);let X=0;for(let ne=0;ne<P.length;++ne){const se=P.charCodeAt(ne);se===37?(W[X++]=parseInt(P.slice(ne+1,ne+3),16),ne+=2):W[X++]=se}return W.subarray(0,X)},stringify(_){let P="";for(let W=0;W<_.length;++W){const X=_[W];P+="%"+(X>>4).toString(16)+(X&15).toString(16)}return decodeURIComponent(P)}};function Tt(_){const P=new URL(_);if(!(P.protocol==="http:"&&P.hostname==="localhost")&&!(P.protocol==="https:"&&(P.hostname==="localhost"||/^([A-Za-z0-9_-]+\.)*edge(test)?\.app$/.test(P.hostname))))throw new Error(`Only *.edge.app or localhost are valid login domain names, not ${P.hostname}`)}function Ct(_,P="Login requires a CAPTCHA"){if(!(this instanceof Ct))throw new TypeError("Class constructor ChallengeError cannot be invoked without 'new'");var W;function X(ne){return W=new Error(ne),Object.defineProperty(W,"constructor",{value:Ct,configurable:!0,writable:!0}),W}return X(P),W.name="ChallengeError",W.challengeId=_.challengeId,W.challengeUri=_.challengeUri,W}function Xt(_="Please send a larger amount"){if(!(this instanceof Xt))throw new TypeError("Class constructor DustSpendError cannot be invoked without 'new'");var P;function W(X){return P=new Error(X),Object.defineProperty(P,"constructor",{value:Xt,configurable:!0,writable:!0}),P}return W(_),P.name="DustSpendError",P}function Yt(_){if(!(this instanceof Yt))throw new TypeError("Class constructor InsufficientFundsError cannot be invoked without 'new'");var P;function W(se){return P=new Error(se),Object.defineProperty(P,"constructor",{value:Yt,configurable:!0,writable:!0}),P}const{tokenId:X=null,networkFee:ne}=_!=null?_:{};return W(`Insufficient ${X!=null?X:"funds"}`),P.tokenId=X,P.networkFee=ne,P.name="InsufficientFundsError",P}function ar(_="Cannot reach the network"){if(!(this instanceof ar))throw new TypeError("Class constructor NetworkError cannot be invoked without 'new'");var P;function W(X){return P=new Error(X),Object.defineProperty(P,"constructor",{value:ar,configurable:!0,writable:!0}),P}return W(_),P.name="NetworkError",P}function or(_="Unable to create zero-amount transaction."){if(!(this instanceof or))throw new TypeError("Class constructor NoAmountSpecifiedError cannot be invoked without 'new'");var P;function W(X){return P=new Error(X),Object.defineProperty(P,"constructor",{value:or,configurable:!0,writable:!0}),P}return W(_),P.name="NoAmountSpecifiedError",P}function sr(_="The application is too old. Please upgrade."){if(!(this instanceof sr))throw new TypeError("Class constructor ObsoleteApiError cannot be invoked without 'new'");var P;function W(X){return P=new Error(X),Object.defineProperty(P,"constructor",{value:sr,configurable:!0,writable:!0}),P}return W(_),P.name="ObsoleteApiError",P}function $t(_,P="Invalid OTP token"){if(!(this instanceof $t))throw new TypeError("Class constructor OtpError cannot be invoked without 'new'");var W;function X(se){return W=new Error(se),Object.defineProperty(W,"constructor",{value:$t,configurable:!0,writable:!0}),W}X(P),W.name="OtpError",W.reason="otp";const ne=l.asMaybe(he)(_);if(ne!=null)return ne.login_id!=null&&(W.loginId=o.base64.stringify(ne.login_id)),W.resetToken=ne.otp_reset_auth,W.reason=ne.reason,W.resetDate=ne.otp_timeout_date,W.voucherActivates=ne.voucher_activates,ne.voucher_auth!=null&&(W.voucherAuth=o.base64.stringify(ne.voucher_auth)),W.voucherId=ne.voucher_id,W}function nr(_,P="Invalid password"){if(!(this instanceof nr))throw new TypeError("Class constructor PasswordError cannot be invoked without 'new'");var W;function X(se){return W=new Error(se),Object.defineProperty(W,"constructor",{value:nr,configurable:!0,writable:!0}),W}X(P),W.name="PasswordError";const ne=l.asMaybe(Ie)(_);if(ne!=null)return W.wait=ne.wait_seconds,W}function fr(_="Not enough confirmed funds"){if(!(this instanceof fr))throw new TypeError("Class constructor PendingFundsError cannot be invoked without 'new'");var P;function W(X){return P=new Error(X),Object.defineProperty(P,"constructor",{value:fr,configurable:!0,writable:!0}),P}return W(_),P.name="PendingFundsError",P}function lr(_="Wallets can not be the same currency"){if(!(this instanceof lr))throw new TypeError("Class constructor SameCurrencyError cannot be invoked without 'new'");var P;function W(X){return P=new Error(X),Object.defineProperty(P,"constructor",{value:lr,configurable:!0,writable:!0}),P}return W(_),P.name="SameCurrencyError",P}function dr(_="Spending to self"){if(!(this instanceof dr))throw new TypeError("Class constructor SpendToSelfError cannot be invoked without 'new'");var P;function W(X){return P=new Error(X),Object.defineProperty(P,"constructor",{value:dr,configurable:!0,writable:!0}),P}return W(_),P.name="SpendToSelfError",P}function cr(_,P,W="from"){if(!(this instanceof cr))throw new TypeError("Class constructor SwapAboveLimitError cannot be invoked without 'new'");var X;function ne(se){return X=new Error(se),Object.defineProperty(X,"constructor",{value:cr,configurable:!0,writable:!0}),X}return ne("Amount is too high"),X.name="SwapAboveLimitError",X.pluginId=_.pluginId,X.nativeMax=P,X.direction=W,X}function gr(_,P,W="from"){if(!(this instanceof gr))throw new TypeError("Class constructor SwapBelowLimitError cannot be invoked without 'new'");var X;function ne(se){return X=new Error(se),Object.defineProperty(X,"constructor",{value:gr,configurable:!0,writable:!0}),X}return ne("Amount is too low"),X.name="SwapBelowLimitError",X.pluginId=_.pluginId,X.nativeMin=P,X.direction=W,X}function pr(_,P){if(!(this instanceof pr))throw new TypeError("Class constructor SwapCurrencyError cannot be invoked without 'new'");var W;function X(Ye){return W=new Error(Ye),Object.defineProperty(W,"constructor",{value:pr,configurable:!0,writable:!0}),W}const{fromWallet:ne,toWallet:se,fromTokenId:de,toTokenId:Be}=P,Ae=ne.currencyConfig.currencyInfo.pluginId,Ue=se.currencyConfig.currencyInfo.pluginId,$e=`${Ae}:${String(de)}`,nt=`${Ue}:${String(Be)}`;return X(`${_.displayName} does not support ${$e} to ${nt}`),W.name="SwapCurrencyError",W.pluginId=_.pluginId,W.fromTokenId=de!=null?de:null,W.toTokenId=Be!=null?Be:null,W}function dn(_,P){if(!(this instanceof dn))throw new TypeError("Class constructor SwapPermissionError cannot be invoked without 'new'");var W;function X(ne){return W=new Error(ne),Object.defineProperty(W,"constructor",{value:dn,configurable:!0,writable:!0}),W}return P!=null?X(P):X("You are not allowed to make this trade"),W.name="SwapPermissionError",W.pluginId=_.pluginId,W.reason=P,W}function Jr(_="Invalid username"){if(!(this instanceof Jr))throw new TypeError("Class constructor UsernameError cannot be invoked without 'new'");var P;function W(X){return P=new Error(X),Object.defineProperty(P,"constructor",{value:Jr,configurable:!0,writable:!0}),P}return W(_),P.name="UsernameError",P}function Ur(_){return function(W){if(W instanceof Error&&W.name===_)return W}}const Mn=Ur("ChallengeError"),Kn=Ur("DustSpendError"),Xn=Ur("InsufficientFundsError"),On=Ur("NetworkError"),zo=Ur("NoAmountSpecifiedError"),ao=Ur("ObsoleteApiError"),di=Ur("OtpError"),Zn=Ur("PasswordError"),Bn=Ur("PendingFundsError"),so=Ur("SameCurrencyError"),Yn=Ur("SpendToSelfError"),pi=Ur("SwapAboveLimitError"),$n=Ur("SwapBelowLimitError"),fo=Ur("SwapCurrencyError"),yn=Ur("SwapPermissionError"),In=Ur("UsernameError");function Ni(_,P){const W=Y.default.hmac(Y.default.sha1,P);return Uint8Array.from(W.update(_).digest())}function fn(_,P){const W=Y.default.hmac(Y.default.sha256,P);return Uint8Array.from(W.update(_).digest())}function tn(_){const P=Y.default.sha256();return Uint8Array.from(P.update(_).digest())}function Cr(_,P){const W=_.length;if(W!==P.length)return!1;let X=0;for(let ne=0;ne<W;++ne)X|=_[ne]^P[ne];return X===0}const Rn=Q.default.ModeOfOperation.cbc;function bn(_,P){const W=Qr(_,P);return W[W.length-1]===0?bt.stringify(W.subarray(0,-1)):bt.stringify(W)}function Qr(_,P){if(_.encryptionType!==0)throw new Error("Unknown encryption type");const W=_.iv_hex,X=_.data_base64,se=new Rn(P,W).decrypt(X),de=1,Be=se[0],Ae=de+Be+4,Ue=se[Ae-4]<<24|se[Ae-3]<<16|se[Ae-2]<<8|se[Ae-1],$e=Ae+Ue+1,nt=se[$e-1],Ye=$e+nt,vt=Ye+32,Et=tn(se.subarray(0,Ye));if(!Cr(Et,se.subarray(Ye,vt)))throw new Error("Invalid checksum");const mt=uo(vt);if(!Cr(mt,se.subarray(vt)))throw new Error("Invalid PKCS7 padding");return se.subarray(Ae,Ae+Ue)}function rn(_,P,W){const ne=_.random(1)[0]&31,se=1+ne+4,de=P.length,Be=se+de+1,Ae=_.random(1)[0]&31,Ue=Be+Ae,$e=Ue+32,nt=uo($e),Ye=new Uint8Array($e+nt.length);Ye.set(nt,$e),Ye[0]=ne,Ye.set(_.random(ne),1),Ye[se-4]=de>>24&255,Ye[se-3]=de>>16&255,Ye[se-2]=de>>8&255,Ye[se-1]=de&255,Ye.set(P,se),Ye[Be-1]=Ae,Ye.set(_.random(Ae),Be),Ye.set(tn(Ye.subarray(0,Ue)),Ue);const vt=_.random(16),mt=new Rn(W,vt).encrypt(Ye);return{encryptionType:0,iv_hex:vt,data_base64:mt}}function uo(_){const P=new Uint8Array(16-(_&15));for(let W=0;W<P.length;++W)P[W]=P.length;return P}function Jn(..._){return[].concat(..._.filter(W=>W!=null))}function Ko(_,P){for(const W of Object.keys(P))Object.defineProperty(_,W,{writable:!0,configurable:!0,value:P[W]});return _}function Fr(_){const P=l.uncleaner(_);return{async load(W,X){try{return _(JSON.parse(await W.getText(X)))}catch{}},async save(W,X,ne){await W.setText(X,JSON.stringify(P(ne)))}}}const Cn=_=>{if(_==null||typeof _!="object")throw new TypeError("Expected a JSON object");return _};function lo(_,P,W){return function(){let ne="";for(let se=0;se<arguments.length;++se){const de=arguments[se];se>0&&(ne+=" "),typeof de=="string"?ne+=de:de instanceof Error?ne+=String(de):ne+=JSON.stringify(de,null,2)}_({message:ne,source:W,time:new Date,type:P})}}function jo(_){const P=_.time.toISOString().replace(/.*(\d\d-\d\d)T(\d\d:\d\d:\d\d).*/,"$1 $2");console.info(`${P} ${_.source}: ${_.message}`)}function Wo(_,P){function W(X){const{sources:ne,defaultLogLevel:se}=P(),de=ne[X.source]!=null?ne[X.source]:se;switch(X.type){case"info":de==="info"&&_.onLog(X);break;case"warn":(de==="info"||de==="warn")&&_.onLog(X);break;case"error":de!=="silent"&&_.onLog(X);break}}return{..._,onLog:W}}function co(_,P){const{onLog:W,crashReporter:X}=_;return Ko(lo(W,"info",P),{breadcrumb(ne,se){const de=new Date;X!=null?X.logBreadcrumb({message:ne,metadata:se,source:P,time:de}):(ne=`${ne} ${JSON.stringify(se,null,2)}`,W({message:ne,source:P,time:de,type:"warn"}))},crash(ne,se){const de=new Date;if(X!=null)X.logCrash({error:ne,metadata:se,source:P,time:de});else{const Be=`${String(ne)} ${JSON.stringify(se,null,2)}`;W({message:Be,source:P,time:de,type:"error"})}},warn:lo(W,"warn",P),error:lo(W,"error",P)})}function Ca(_){return new Promise(P=>setTimeout(()=>P(_),_))}function Go(_){for(let P=_.length-1;P>0;P--){const W=Math.floor(Math.random()*(P+1));[_[P],_[W]]=[_[W],_[P]]}return _}const Li=l.asObject({dataKey:D,syncKey:D}),vi=l.uncleaner(Li);function Vo(_){const{io:P}=_.props;return{dataKey:P.random(32),syncKey:P.random(20)}}function Fa(_,P,W){const X={delete(ne){return W.delete(ne)},async getData(ne){const se=await W.getText(ne),de=F(JSON.parse(se));return Qr(de,P)},async getText(ne){const se=await W.getText(ne),de=F(JSON.parse(se));return bn(de,P)},list(ne){return W.list(ne)},setData(ne,se){return W.setText(ne,JSON.stringify(De(rn(_,Uint8Array.from(se),P))))},setText(ne,se){return this.setData(ne,bt.parse(se))}};return y.bridgifyObject(X),X}function Rf(_,P){return _.storageWallets[P].lastChanges}function zr(_,P){return _.storageWallets[P].paths.disklet}function ho(_,P){return _.storageWallets[P].localDisklet}function Cf(_,P,W){return Fa(W,_.storageWallets[P].paths.dataKey,_.storageWallets[P].localDisklet)}function mi(_,P,W){const X=_.storageWallets[P].paths.dataKey;return gt.stringify(fn(bt.parse(W),X))}const qo=l.asObject({multiplier:l.asString,name:l.asString,symbol:l.asOptional(l.asString)}),Ff=l.asObject({currencyCode:l.asString,denominations:l.asArray(qo),displayName:l.asString,networkLocation:l.asOptional(Cn)}),Nf=l.asObject({enabled:l.asOptional(l.asBoolean,!0)}).withRest,Lf=l.asObject({SortIndex:l.asOptional(l.asNumber,0),Archived:l.asOptional(l.asBoolean,!1),BitcoinSeed:a,MK:a,SyncKey:a}).withRest,Df=l.asObject({id:l.asString,archived:l.asOptional(l.asBoolean),deleted:l.asOptional(l.asBoolean),hidden:l.asOptional(l.asBoolean),migratedFromWalletId:l.asOptional(l.asString),sortIndex:l.asOptional(l.asNumber)}),Na=l.asObject({userSettings:l.asOptional(l.asObject(Cn),()=>({})),swapSettings:l.asOptional(l.asObject(Nf),()=>({}))}).withRest,Uf=l.asObject({customTokens:l.asArray(l.asObject({contractAddress:l.asString,currencyCode:l.asString,currencyName:l.asString,denomination:l.asString,denominations:l.asArray(qo),isVisible:l.asOptional(l.asBoolean,!0),multiplier:l.asString,walletType:l.asOptional(l.asString,"wallet:ethereum")}))}),Hf=l.asObject({customTokens:l.asObject(l.asObject(Ff))}),zf=Fr(Lf),La=Fr(Df),gi=Fr(Na),Da=Na({}),Di="PluginSettings.json";function Ua(_,P){for(const W of Object.keys(P))if(_[W]!==P[W])return!0;return!1}async function Kf(_){const P=[],W={},X=p.justFiles(await _.list("Wallets"));return await Promise.all(X.map(async ne=>{const se=await zf.load(_,ne);if(se==null)return;const de={...vi({dataKey:se.MK,syncKey:se.SyncKey}),bitcoinKey:o.base64.stringify(se.BitcoinSeed),format:"bip32"},Be=Ui("wallet:bitcoin",de,se.MK);P.push(Be),W[Be.id]={archived:se.Archived,deleted:!1,hidden:!1,migratedFromWalletId:void 0,sortIndex:se.SortIndex}})),{walletInfos:P,walletStates:W}}async function jf(_){const P={},W=p.justFiles(await _.list("Keys"));return await Promise.all(W.map(async X=>{const ne=await La.load(_,X);if(ne==null)return;const{id:se,archived:de,deleted:Be,hidden:Ae,migratedFromWalletId:Ue,sortIndex:$e}=ne;P[se]={archived:de,deleted:Be,hidden:Ae,sortIndex:$e,migratedFromWalletId:Ue}})),P}async function Xo(_,P){const W=_.props.state.accounts[P],{accountWalletInfo:X,accountWalletInfos:ne}=W,se=await Promise.all(ne.map($e=>Kf(zr(_.props.state,$e.id)))),de=await jf(zr(_.props.state,X.id)),Be=[];for(const $e of se)Be.push(...$e.walletInfos);const Ae=se.map($e=>$e.walletStates),Ue=Object.assign({},...Ae,de);_.props.dispatch({type:"ACCOUNT_KEYS_LOADED",payload:{accountId:P,legacyWalletInfos:Be,walletStates:Ue}})}async function Zo(_,P,W){const{accountWalletInfo:X,walletStates:ne}=_.props.state.accounts[P],se=zr(_.props.state,X.id),de={};for(const Ae of Object.keys(W))ne[Ae]==null?de[Ae]=W[Ae]:Ua(ne[Ae],W[Ae])&&(de[Ae]={...ne[Ae],...W[Ae]});const Be=Object.keys(de);Be.length<1||(await Promise.all(Be.map(async Ae=>{const{archived:Ue,deleted:$e,hidden:nt,migratedFromWalletId:Ye,sortIndex:vt}=de[Ae],Et=mi(_.props.state,X.id,Ae);await La.save(se,`Keys/${Et}.json`,{archived:Ue,deleted:$e,hidden:nt,id:Ae,migratedFromWalletId:Ye,sortIndex:vt})})),_.props.dispatch({type:"ACCOUNT_CHANGED_WALLET_STATES",payload:{accountId:P,walletStates:{...ne,...de}}}))}async function Ha(_,P,W,X){var Be;const{accountWalletInfo:ne}=_.props.state.accounts[P],se=zr(_.props.state,ne.id),de=(Be=await gi.load(se,Di))!=null?Be:Da;await gi.save(se,Di,{...de,userSettings:{..._.props.state.accounts[P].userSettings,[W]:X}}),_.props.dispatch({type:"ACCOUNT_PLUGIN_SETTINGS_CHANGED",payload:{accountId:P,pluginId:W,userSettings:{...X}}})}async function Wf(_,P,W,X){var Be;const{accountWalletInfo:ne}=_.props.state.accounts[P],se=zr(_.props.state,ne.id),de=(Be=await gi.load(se,Di))!=null?Be:Da;await gi.save(se,Di,{...de,swapSettings:{..._.props.state.accounts[P].swapSettings,[W]:X}}),_.props.dispatch({type:"ACCOUNT_SWAP_SETTINGS_CHANGED",payload:{accountId:P,pluginId:W,swapSettings:X}})}async function za(_,P){const{accountWalletInfo:W}=_.props.state.accounts[P],X=zr(_.props.state,W.id),ne=await gi.load(X,Di),{userSettings:se,swapSettings:de}=ne!=null?ne:{userSettings:{},swapSettings:{}};_.props.dispatch({type:"ACCOUNT_PLUGIN_SETTINGS_LOADED",payload:{accountId:P,userSettings:se,swapSettings:de}})}function Ka(_,P,W){for(const X of _.denominations)if(X.name===W)return X.multiplier;for(const X of Object.keys(P)){const ne=P[X];for(const se of ne.denominations)if(se.name===W)return se.multiplier}return"1"}function ja(_,P){return _.waitFor(X=>{if(X.state.currency.wallets[P]==null)throw new Error(`Wallet id ${P} does not exist in this account`);const{engineFailure:ne}=X.state.currency.wallets[P];if(ne!=null)throw ne;if(X.output.currency.wallets[P]!=null)return X.output.currency.wallets[P].walletApi})}function yi(_,P){const W=po(_,P);if(W==null)throw new Error(`Cannot find a currency plugin for wallet type ${P}`);return W}function po(_,P){return Object.keys(_).find(W=>_[W].currencyInfo.walletType===P)}function Fn(_,P){const{dispatch:W,state:X}=_.props,ne=X.plugins.currencyTools[P];if(ne!=null)return ne;const de=X.plugins.currency[P].makeCurrencyTools();return W({type:"CURRENCY_TOOLS_LOADED",payload:{pluginId:P,tools:de}}),de}async function Wa(_){await _.waitFor(P=>{const{init:W,locked:X}=P.state.plugins;if(!X)return;const{currency:ne,swap:se}=P.state.plugins,de=[];for(const Be of Object.keys(W))W[Be]!==!1&&W[Be]!=null&&ne[Be]==null&&se[Be]==null&&de.push(Be);if(de.length>0)throw new Error("The following plugins are missing or failed to load: "+de.join(", "));return!0})}const Ga=l.asObject({id:l.asString,keys:Cn,type:l.asString}),Gf=l.uncleaner(Ga);function Vf(_,P){return _.find(W=>W.type===P)}function vo(_){return _===""?"account-repo:co.airbitz.wallet":`account-repo:${_}`}function Ui(_,P,W){const X=fn(bt.parse(_),W!=null?W:Li(P).dataKey);return{id:o.base64.stringify(X),type:_,keys:P}}function bi(_,P,W){const{io:X}=_.props,ne=W.map(de=>rn(X,bt.parse(JSON.stringify(Gf(de))),P.loginKey)),se=[];for(const de of W){const Be=l.asMaybe(Li)(de.keys);Be!=null&&se.push(o.base16.stringify(Be.syncKey).toLowerCase())}return{serverPath:"/v2/login/keys",server:qt({keyBoxes:ne,newSyncKeys:se}),stash:{keyBoxes:ne},login:{keyInfos:W},loginId:P.loginId}}function Yo(_){const P=[],W={};for(const X of _){const{id:ne,type:se,keys:de}=X;if(ne==null||o.base64.parse(ne).length!==32)throw new Error(`Key integrity violation: invalid id ${ne}`);if(W[ne]!=null){const Be=P[W[ne]];if(Be.type!==se)throw new Error(`Key integrity violation for ${ne}: type ${se} does not match ${Be.type}`);for(const Ae of Object.keys(de))if(Be.keys[Ae]!=null&&Be.keys[Ae]!==de[Ae])throw new Error(`Key integrity violation for ${ne}: ${Ae} keys do not match`);P[W[ne]]={id:ne,type:se,keys:{...Be.keys,...de}}}else W[ne]=P.length,P.push(X)}return P}function qf(_,P=[]){const W={},X=[];for(const se of P)X.push(se),W[se.id]==null?W[se.id]=[_.appId]:W[se.id].push(_.appId);function ne(se){for(const de of se.keyInfos)X.push(de),W[de.id]==null?W[de.id]=[se.appId]:W[de.id].push(se.appId);for(const de of se.children)ne(de)}return ne(_),{appIdMap:W,walletInfos:Yo(X)}}function Va(_){const{id:P,keys:W,type:X}=_,ne={"wallet:bitcoin-bip44":{format:"bip44",coinType:0},"wallet:bitcoin-bip49":{format:"bip49",coinType:0},"wallet:bitcoincash-bip32":{format:"bip32"},"wallet:bitcoincash-bip44":{format:"bip44",coinType:145},"wallet:bitcoincash-bip44-testnet":{format:"bip44",coinType:1},"wallet:bitcoin-bip44-testnet":{format:"bip44",coinType:1},"wallet:bitcoin-bip49-testnet":{format:"bip49",coinType:1},"wallet:dash-bip44":{format:"bip44",coinType:5},"wallet:dogecoin-bip44":{format:"bip44",coinType:3},"wallet:litecoin-bip44":{format:"bip44",coinType:2},"wallet:litecoin-bip49":{format:"bip49",coinType:2},"wallet:feathercoin-bip49":{format:"bip49",coinType:8},"wallet:feathercoin-bip44":{format:"bip44",coinType:8},"wallet:qtum-bip44":{format:"bip44",coinType:2301},"wallet:ufo-bip49":{format:"bip49",coinType:202},"wallet:ufo-bip84":{format:"bip84",coinType:202},"wallet:zcoin-bip44":{format:"bip44",coinType:136},"wallet:bitcoin-testnet":{format:"bip32"},"wallet:bitcoin":{format:"bip32"},"wallet:bitcoincash-testnet":{format:"bip32"},"wallet:litecoin":{format:"bip32",coinType:2},"wallet:zcoin":{format:"bip32",coinType:136}};return ne[X]!=null?{id:P,keys:{...ne[X],...W},type:X.replace(/-bip[0-9]+/,"")}:_}async function mo(_,P,W){const{importText:X,keyOptions:ne,keys:se}=W;function de(Ue,$e){return $e!=null&&(Ue={...Ue,imported:$e}),Va(Ui(P,{...vi(Vo(_)),...Ue}))}if(se!=null)return de(se);const Be=yi(_.props.state.plugins.currency,P),Ae=await Fn(_,Be);if(X!=null){if(Ae.importPrivateKey==null)throw new Error("This wallet does not support importing keys");return de(await Ae.importPrivateKey(X,ne),!0)}return de(await Ae.createPrivateKey(P,ne),!1)}async function qa(_,P,W,X){const{enabledTokenIds:ne,fiatCurrencyCode:se,migratedFromWalletId:de,name:Be}=X,Ae=await ja(_,W);return de!=null&&await Zo(_,P,{[W]:{migratedFromWalletId:de}}),Be!=null&&await Ae.renameWallet(Be),se!=null&&await Ae.setFiatCurrencyCode(se),ne!=null&&ne.length>0&&await Ae.changeEnabledTokenIds(ne),Ae}function Xa(_,P,W=new Error(`Timeout of ${P}ms exceeded`)){return new Promise((X,ne)=>{const se=setTimeout(()=>ne(W),P);_.then(de=>{clearTimeout(se),X(de)},de=>{clearTimeout(se),ne(de)})})}function Za(_,P){return new Promise((W,X)=>{let ne=!1;const se=[],de=[];let Be=setTimeout(()=>{Be=void 0,se.length>0&&(ne=!0,W({results:se,errors:de}))},P);function Ae(){const Ue=se.length+de.length===_.length;Ue&&Be!=null&&clearTimeout(Be),(Ue||Be==null)&&(ne=!0,se.length>0?W({results:se,errors:de}):X(de))}Ae();for(const Ue of _)Ue.then($e=>{ne||(se.push($e),Ae())},$e=>{ne||(de.push($e),Ae())})})}function Xf(_){const P=oe(_);switch(P.status_code){case 0:return P.results;case 2:throw new Jr("Account already exists on server");case 3:throw new Jr("Account does not exist on server");case 4:case 5:throw new nr(P.results);case 6:throw new Error("Invalid API key");case 8:throw new $t(P.results);case 1e3:throw new sr;case 1:case 7:case 9:case 10:case 11:default:{const W=l.asMaybe(lt)(P.results);throw W!=null?new Ct(W):new Error(`Server error: ${P.message}`)}}}function en(_,P,W,X){const{state:ne,io:se,log:de}=_.props,{apiKey:Be,serverUri:Ae}=ne.login,Ue={method:P,headers:{"content-type":"application/json",accept:"application/json",authorization:`Token ${Be===""?"4248c1bf41e53b840a5fdb2c872dd3ade525e66d":Be}`}};P!=="GET"&&X!=null&&(Ue.body=JSON.stringify(ve(X)));const $e=Date.now(),nt=`${Ae}${W}`;return Xa(se.fetch(nt,Ue),3e4).then(Ye=>{const vt=Date.now()-$e;return de(`${P} ${nt} returned ${Ye.status} in ${vt}ms`),Ye.json().then(Xf,()=>{throw new Error(`Invalid reply JSON, HTTP status ${Ye.status}`)})},Ye=>{const vt=Date.now()-$e;throw de.error(`${P} ${nt} failed in ${vt}ms, ${String(Ye)}`),new ar(`Could not reach the auth server: ${W}`)})}function $o(_,P){const{io:W}=_.props,{loginId:X,loginKey:ne}=P,se=W.random(32),de=rn(W,se,ne);return{login:{loginAuth:se},loginId:X,server:At({loginAuth:se,loginAuthBox:de}),serverPath:"/v2/login/secret",stash:{loginAuthBox:de}}}function Zf(_,P=2e3){return _.props.output.scrypt.makeSnrp(P)}async function wi(_,P,W){return typeof P=="string"&&(P=bt.parse(P)),(await _.props.output.scrypt.timeScrypt(P,W)).hash}const Qn={salt_hex:Uint8Array.from([181,134,95,251,159,167,179,191,228,178,56,77,71,206,131,30,226,42,74,157,92,52,199,239,125,33,70,124,199,88,248,27]),n:16384,r:1,p:1};function Ya(_){return{username:_,appId:"",loginId:new Uint8Array(0),pendingVouchers:[]}}function go(_,P){const{stashes:W}=_.props.state.login;for(const X of W)if(X.username===P)return X}function En(_,P){const{stashes:W}=_.props.state.login;for(const X of W){const ne=Sn(X,se=>Cr(se.loginId,P));if(ne!=null)return{stashTree:X,stash:ne}}throw new Error(`Cannot find stash ${o.base64.stringify(P)}`)}const yo={};function Hi(_,P){return yo[P]==null&&(yo[P]=wi(_,P,Qn)),yo[P]}async function Yf(_,P){const W=[],X=await _.list("logins").then(p.justFiles);for(const ne of X)try{W.push(xi(JSON.parse(await _.getText(ne))))}catch(se){P.error(`Could not load ${ne}: ${String(se)}`)}return W}async function $a(_,P){const{dispatch:W,io:X}=_.props,ne=await X.disklet.list("logins").then(p.justFiles);for(const se of ne)try{const de=xi(JSON.parse(await X.disklet.getText(se)));Cr(de.loginId,P)&&await X.disklet.delete(se)}catch{}W({type:"LOGIN_STASH_DELETED",payload:P})}async function Nn(_,P){const{dispatch:W,io:X}=_.props,{appId:ne,loginId:se}=P;if(ne!=="")throw new Error("Cannot save a login without an appId.");if(se==null||se.length!==32)throw new Error("Invalid loginId");await X.disklet.setText(`logins/${gt.stringify(se)}.json`,JSON.stringify(Ja(P))),W({type:"LOGIN_STASH_SAVED",payload:P})}const $f=_=>s(l.asString(_)),xi=l.asObject({appId:l.asString,created:l.asOptional(l.asDate),lastLogin:l.asOptional(l.asDate),loginId:D,otpKey:l.asOptional(w),otpResetDate:l.asOptional(l.asDate),otpTimeout:l.asOptional(l.asNumber),pendingVouchers:l.asOptional(l.asArray(Z),()=>[]),voucherId:l.asOptional(l.asString),voucherAuth:l.asOptional(D),loginAuthBox:l.asOptional(F),parentBox:l.asOptional(F),passwordAuthBox:l.asOptional(F),passwordAuthSnrp:l.asOptional(V),passwordBox:l.asOptional(F),passwordKeySnrp:l.asOptional(V),pin2Key:l.asOptional(l.asCodec(_=>{const P=l.asString(_);return _.slice(-1)!=="="?gt.parse(P):o.base64.parse(P)},_=>o.base64.stringify(_))),pin2TextBox:l.asOptional(F),recovery2Key:l.asOptional(D),userId:l.asOptional(D),username:l.asOptional($f),children:l.asOptional(l.asArray(_=>xi(_))),keyBoxes:l.asOptional(l.asArray(F)),mnemonicBox:l.asOptional(F),rootKeyBox:l.asOptional(F),syncKeyBox:l.asOptional(F)}),Ja=l.uncleaner(xi);function Hc(_){const P=Math.floor(_/4294967296);return new Uint8Array([P>>24&255,P>>16&255,P>>8&255,P&255,_>>24&255,_>>16&255,_>>8&255,_&255])}function bo(_,P,W){const X=Ni(Hc(P),_),ne=X[19]&15,de=((X[ne]&127)<<24|X[ne+1]<<16|X[ne+2]<<8|X[ne+3]).toString();return(Array(W).join("0")+de).slice(-W)}function zi(_,P=Date.now()/1e3){return bo(_,P/30,6)}function Qa(_,P,W={}){const{now:X=Date.now()/1e3,spread:ne=1}=W,se=X/30;if(P===bo(_,se,6))return!0;for(let de=1;de<=ne;++de)if(P===bo(_,se-de,6)||P===bo(_,se+de,6))return!0;return!1}function wo(_){if(_.otpKey!=null)return zi(_.otpKey)}function es(_,P){const{otp:W,otpKey:X}=P;if(W!=null)return W;if(X!=null)return zi(o.base32.parse(X,{loose:!0}));if(_.otpKey!=null)return zi(_.otpKey)}async function Jf(_,P,W){const{loginTree:X}=_.props.state.accounts[P],{otpKey:ne=_.props.io.random(10)}=X,se={serverPath:"/v2/login/otp",server:rt({otpKey:ne,otpTimeout:W}),stash:{otpKey:ne,otpResetDate:void 0,otpTimeout:W},login:{otpKey:ne,otpResetDate:void 0,otpTimeout:W},loginId:X.loginId};await nn(_,X,se)}async function Qf(_,P){const{loginTree:W}=_.props.state.accounts[P],X={serverMethod:"DELETE",serverPath:"/v2/login/otp",stash:{otpKey:void 0,otpResetDate:void 0,otpTimeout:void 0},login:{otpKey:void 0,otpResetDate:void 0,otpTimeout:void 0},loginId:W.loginId};await nn(_,W,X)}async function eu(_,P){const{loginTree:W}=_.props.state.accounts[P],{otpTimeout:X,otpKey:ne}=W;if(X==null||ne==null)throw new Error("Cannot cancel 2FA reset: 2FA is not enabled.");const se={serverPath:"/v2/login/otp",server:rt({otpTimeout:X,otpKey:ne}),stash:{otpResetDate:void 0},login:{otpResetDate:void 0},loginId:W.loginId};await nn(_,W,se)}async function tu(_,P,W){const X={userId:await Hi(_,P),otpResetAuth:W},ne=await en(_,"DELETE","/v2/login/otp",X),{otpResetDate:se}=je(ne);return se}async function Ki(_,P,W){if(_.props.state.accounts[P]==null)return;const{login:X}=_.props.state.accounts[P],{userId:ne,passwordAuth:se}=X,{stashTree:de,stash:Be}=En(_,X.loginId);if(se==null||ne==null)throw new Error("Cannot repair OTP: There is no password on this account");const Ae={userId:ne,passwordAuth:se,otp:zi(W)},Ue={now:de.lastLogin};await Wi(_,de,Be,Ue,Ae,async()=>X.loginKey)}function Sn(_,P){if(P(_))return _;const W=_;if(W.children!=null)for(const X of W.children){const ne=Sn(X,P);if(ne!=null)return ne}}function Mi(_,P,W,X){if(P(_))return W(_);const ne=_.children!=null?_.children.map(se=>Mi(se,P,W,X)):[];return X(_,ne)}function xo(_,P,W){const{children:X=[]}=_,{appId:ne,created:se,loginId:de,loginAuthBox:Be,userId:Ae,otpKey:Ue,otpResetDate:$e,otpTimeout:nt,pendingVouchers:Ye,parentBox:vt,passwordAuthBox:Et,passwordAuthSnrp:mt,passwordBox:Mt,passwordKeySnrp:Ot,pin2TextBox:Vt,children:Zt=[],keyBoxes:ir=[],mnemonicBox:vr,rootKeyBox:yr,syncKeyBox:Pr,syncToken:kr}=W,Ar={appId:ne,created:se,loginId:de,loginAuthBox:Be,userId:Ae,otpKey:Ue===!0?_.otpKey:Ue,otpResetDate:$e,otpTimeout:nt,pendingVouchers:Ye,parentBox:vt,passwordAuthBox:Et,passwordAuthSnrp:mt,passwordBox:Mt===!0?_.passwordBox:Mt,passwordKeySnrp:Ot,pin2TextBox:Vt,keyBoxes:ir,mnemonicBox:vr,rootKeyBox:yr,syncKeyBox:Pr,syncToken:kr};_.lastLogin!=null&&(Ar.lastLogin=_.lastLogin),_.username!=null&&(Ar.username=_.username),_.userId!=null&&Ar.userId==null&&(Ar.userId=_.userId),W.pin2KeyBox!=null&&(Ar.pin2Key=Qr(W.pin2KeyBox,P)),W.recovery2KeyBox!=null&&(Ar.recovery2Key=Qr(W.recovery2KeyBox,P)),Zt.sort((_r,Lr)=>_r.created.valueOf()-Lr.created.valueOf()),Ar.children=Zt.map(_r=>{const{appId:Lr,loginId:Vr,parentBox:on}=_r;if(on==null)throw new Error("Key integrity violation: No parentBox on child login.");const kn=Qr(on,P),mn=X.find(Kr=>Cr(Kr.loginId,Vr)),Ln=mn!=null?mn:{appId:Lr,loginId:Vr,pendingVouchers:[]};return xo(Ln,kn,_r)});for(const{loginId:_r}of X)if(Zt.find(Vr=>Cr(Vr.loginId,_r))==null)throw new Error("The server has lost children!");return Ar}function Ei(_,P,W){return Mi(_,X=>X.appId===W.appId,X=>xo(X,P,W),(X,ne)=>({...X,children:ne}))}function ts(_,P){const{appId:W,created:X,lastLogin:ne=new Date,loginId:se,otpKey:de,otpResetDate:Be,otpTimeout:Ae,pendingVouchers:Ue,userId:$e,username:nt,children:Ye=[],keyBoxes:vt=[]}=_,Et={appId:W,created:X,isRoot:_.parentBox==null,lastLogin:ne,loginId:se,loginKey:P,otpKey:de,otpResetDate:Be,otpTimeout:Ae,pendingVouchers:Ue,userId:$e,username:nt,children:[],keyInfos:[]};if(_.loginAuthBox!=null&&(Et.loginAuth=Qr(_.loginAuthBox,P)),_.passwordAuthBox!=null&&(Et.userId==null&&(Et.userId=se),Et.passwordAuth=Qr(_.passwordAuthBox,P)),Et.loginAuth==null&&Et.passwordAuth==null)throw new Error("No server authentication methods on login");Et.pin2Key=_.pin2Key,_.pin2TextBox!=null&&(Et.pin=bn(_.pin2TextBox,P)),Et.recovery2Key=_.recovery2Key;const mt=[],{mnemonicBox:Mt,rootKeyBox:Ot}=_;if(Mt!=null&&Ot!=null){const Zt=Qr(Ot,P),ir=fn(Zt,bt.parse("infoKey")),vr={mnemonic:bn(Mt,ir),rootKey:o.base64.stringify(Zt)};mt.push(Ui("wallet:bitid",vr,Zt))}if(_.syncKeyBox!=null){const Zt=Qr(_.syncKeyBox,P),ir=vo(Et.appId),vr=vi({dataKey:P,syncKey:Zt});mt.push(Ui(ir,vr,P))}const Vt=vt.map(Zt=>Ga(JSON.parse(bn(Zt,P))));return Et.keyInfos=Yo([...mt,...Vt]).map(Zt=>Va(Zt)),Et.children=Ye.map(Zt=>{if(Zt.parentBox==null)throw new Error("Key integrity violation: No parentBox on child login.");const ir=Qr(Zt.parentBox,P);return ts(Zt,ir)}),Et}function ji(_,P,W=""){return Mi(_,X=>X.appId===W,X=>ts(X,P),(X,ne)=>{const{appId:se,lastLogin:de=new Date,loginId:Be,pendingVouchers:Ae,username:Ue}=X;return{appId:se,children:ne,isRoot:X.parentBox==null,keyInfos:[],lastLogin:de,loginId:Be,loginKey:void 0,pendingVouchers:Ae,username:Ue}})}function ei(_,P){return Mi(_,W=>W.appId===P,W=>W,(W,X)=>{const{appId:ne,loginId:se,username:de}=W;return{appId:ne,children:X,loginId:se,pendingVouchers:[],username:de}})}async function Wi(_,P,W,X,ne,se){const{now:de=new Date}=X,{deviceDescription:Be}=_.props.state.login,Ae={challengeId:X.challengeId,otp:es(W,X),voucherId:W.voucherId,voucherAuth:W.voucherAuth,...ne};Be!=null&&(Ae.deviceDescription=Be);let Ue=kt(await en(_,"POST","/v2/login",Ae).catch(nt=>{const Ye=di(nt);throw Ye!=null&&(W.loginId.length===0&&Ye.loginId!=null||Ye.voucherId!=null&&Ye.voucherAuth!=null)&&(Ye.loginId!=null&&(W.loginId=o.base64.parse(Ye.loginId)),Ye.voucherAuth!=null&&(W.voucherId=Ye.voucherId,W.voucherAuth=o.base64.parse(Ye.voucherAuth)),P.lastLogin=de,Nn(_,P).catch(()=>{})),nt}));const $e=await se(Ue);if(P=Ei(P,$e,Ue),P.lastLogin=de,await Nn(_,P),Ue.loginAuthBox==null){const{loginId:nt}=Ue,{stash:Ye,stashTree:vt}=En(_,nt),Et=$o(_,{loginId:nt,loginKey:$e}),mt={...ne,otp:es(Ye,X),data:Et.server};Ue=kt(await en(_,"POST",Et.serverPath,mt)),await Nn(_,Ei(vt,$e,Ue))}return ji(P,$e,W.appId)}async function nn(_,P,W){const{loginId:X,serverMethod:ne="POST",serverPath:se}=W,de=Sn(P,nt=>Cr(nt.loginId,X));if(de==null)throw new Error("Cannot apply kit: missing login");const{stashTree:Be}=En(_,X),Ae=Si(Be,de);Ae.data=W.server,await en(_,ne,se,Ae);const Ue=Mi(P,nt=>Cr(nt.loginId,X),nt=>({...nt,...W.login,children:Jn(nt.children,W.login.children),keyInfos:Yo(Jn(nt.keyInfos,W.login.keyInfos))}),(nt,Ye)=>({...nt,children:Ye})),$e=Mi(Be,nt=>Cr(nt.loginId,X),nt=>({...nt,...W.stash,children:Jn(nt.children,W.stash.children),keyBoxes:Jn(nt.keyBoxes,W.stash.keyBoxes)}),(nt,Ye)=>({...nt,children:Ye}));return await Nn(_,$e),Ue}async function Jo(_,P,W){for(const X of W)X!=null&&await nn(_,P,X)}async function pn(_,P,W){const{stashTree:X,stash:ne}=En(_,W.loginId),{syncToken:se}=ne;if(se!=null)try{const Ae=await en(_,"POST","/v2/sync",{loginId:ne.loginId,syncToken:se});if(l.asBoolean(Ae))return P}catch{}const de=Si(X,W),Be={now:X.lastLogin};return await Wi(_,X,ne,Be,de,async()=>W.loginKey)}function Si(_,P){const W=Sn(_,$e=>$e.appId===P.appId),{syncToken:X,voucherAuth:ne,voucherId:se}=W!=null?W:{syncToken:void 0,voucherAuth:void 0,voucherId:void 0},{loginId:de,userId:Be,loginAuth:Ae,passwordAuth:Ue}=P;if(Ae!=null)return{loginId:de,loginAuth:Ae,otp:wo(P),syncToken:X,voucherAuth:ne,voucherId:se};if(Ue!=null&&Be!=null)return{userId:Be,passwordAuth:Ue,otp:wo(P),syncToken:X,voucherAuth:ne,voucherId:se};throw new Error("No server authentication methods available")}const Qo="client.json",rs=Fr(l.asObject({clientId:D})),ns="infoCache.json",is=l.asObject({corePlugins:l.asObject(Cn),syncServers:l.asArray(l.asString)}),ea=Fr(is);async function ru(_,P){const W=[],X=await _.disklet.list("Accounts").then(p.justFolders);for(const ne of X){const se=p.navigateDisklet(_.disklet,ne),[de,Be,Ae,Ue,$e,nt]=await Promise.all([await as.load(se,"CarePackage.json"),await nu.load(se,"LoginPackage.json"),await iu.load(se,"OtpKey.json"),await ss.load(se,"Pin2Key.json"),await fs.load(se,"Recovery2Key.json"),await ou.load(se,"UserName.json")]);if(nt==null)continue;const Ye=s(nt.userName);if(P.has(Ye))continue;const Et={appId:"",loginId:await _.scrypt(bt.parse(Ye),Qn.salt_hex,Qn.n,Qn.r,Qn.p,32),pendingVouchers:[],username:Ye};de!=null&&Be!=null&&(Et.passwordKeySnrp=de.SNRP2,Et.passwordBox=Be.EMK_LP2,Et.syncKeyBox=Be.ESyncKey,Et.passwordAuthBox=Be.ELP1),Ae!=null&&(Et.otpKey=Ae.TOTP),Ue!=null&&(Et.pin2Key=Ue.pin2Key),$e!=null&&(Et.recovery2Key=$e.recovery2Key),W.push(Et)}return W}const os=l.asCodec(_=>gt.parse(l.asString(_)),_=>gt.stringify(_)),as=Fr(l.asObject({SNRP2:V,SNRP3:l.asOptional(V),SNRP4:l.asOptional(V),ERQ:l.asOptional(F)})),nu=Fr(l.asObject({EMK_LP2:F,EMK_LRA3:l.asOptional(F),ESyncKey:F,ELP1:F})),iu=Fr(l.asObject({TOTP:w})),ss=Fr(l.asObject({pin2Key:os})),fs=Fr(l.asObject({recovery2Key:os})),ou=Fr(l.asObject({userName:l.asString})),us={};let ta=!1;const ra=[],ls=[];function au(_){if(ta)throw new Error("The Edge core plugin list has already been locked");for(const P of Object.keys(_))us[P]=_[P];for(const P of ra)P(_)}function cs(){ta=!0;for(const _ of ls)_()}function su(_,P,W,X,ne){const{io:se,nativeIo:de}=_,Be={...se,console};function Ae($e){var Ye,vt;const nt={};for(const Et of Object.keys($e)){const mt=$e[Et],Mt=co(W,Et),Ot=X[Et];if(!(Ot===!1||Ot==null))try{if(typeof mt=="function"){const Vt={infoPayload:(vt=(Ye=P.corePlugins)==null?void 0:Ye[Et])!=null?vt:{},initOptions:typeof Ot=="object"?Ot:{},io:Be,log:Mt,nativeIo:de,pluginDisklet:p.navigateDisklet(se.disklet,"plugins/"+Et)};nt[Et]=mt(Vt)}else if(typeof mt=="object"&&mt!=null)nt[Et]=mt;else throw new TypeError(`Plugins must be functions or objects, got ${typeof mt}`)}catch(Vt){Mt.error(Vt)}}ne({type:"CORE_PLUGINS_ADDED",payload:nt})}function Ue(){ne({type:"CORE_PLUGINS_LOCKED",payload:X})}return Ae(us),ta&&Ue(),ra.push(Ae),ls.push(Ue),()=>{}}function ki(_,P,W={}){const{onError:X=()=>{}}=W;let ne=!1,se;function de(){se=void 0,Ae.started&&(ne=!0,new Promise(Ue=>Ue(_())).catch(X).then(Be,Be))}function Be(){ne=!1,Ae.started&&(se=setTimeout(de,P))}const Ae={started:!1,setDelay(Ue){P=Ue},start(Ue={}){const{wait:$e=!1}=Ue;Ae.started=!0,!ne&&se==null&&($e?Be():de())},stop(){Ae.started=!1,se!=null&&(clearTimeout(se),se=void 0)}};return Ae}const hs=100;function Mo(_,P){return p.navigateDisklet(_.disklet,"local/"+gt.stringify(o.base64.parse(P)))}function Eo(_,P){const{dataKey:W,syncKey:X}=P,ne=p.navigateDisklet(_.disklet,"repos/"+gt.stringify(tn(tn(X)))),se=p.navigateDisklet(ne,"changes"),de=p.navigateDisklet(ne,"data"),Be=Fa(_,W,p.mergeDisklets(se,de));return{dataKey:W,syncKey:X,baseDisklet:ne,changesDisklet:se,dataDisklet:de,disklet:Be}}function fu(_){const P={lastSync:0,lastHash:void 0};return _.baseDisklet.getText("status.json").then(W=>({lastSync:0,...JSON.parse(W)})).catch(()=>P)}async function ds(_,P){await Promise.all(Object.keys(P).map(W=>{const X=P[W];return X!=null?_.setText(W,JSON.stringify(De(X))):_.delete(W)}))}async function na(_,P,W){var nt;const{changesDisklet:X,dataDisklet:ne,syncKey:se}=P,de=await ps(X).then(Ye=>Promise.all(Ye.map(async vt=>({path:vt,box:F(JSON.parse(await X.getText(vt)))})))),Be=o.base16.stringify(se).toLowerCase(),Ae=await(()=>{if(de.length===0)return _.readRepo(Be,W.lastHash);const Ye={};for(const vt of de)Ye[vt.path]=De(vt.box);return _.updateRepo(Be,W.lastHash,{changes:Ye})})(),{hash:Ue}=Ae,$e={};for(const Ye of Object.keys((nt=Ae.changes)!=null?nt:{})){const vt=Ae.changes[Ye];$e[Ye]=vt==null?null:F(vt)}return await ds(ne,$e),await Promise.all(de.map(Ye=>X.delete(Ye.path))),W.lastSync=Date.now()/1e3,Ue!=null&&(W.lastHash=Ue),await P.baseDisklet.setText("status.json",JSON.stringify(W)),{status:W,changes:$e}}async function ps(_,P="",W=hs){const X=await _.list(P),ne=Object.keys(X).filter(de=>X[de]==="file"),se=Object.keys(X).filter(de=>X[de]==="folder");for(const de of se){if(ne.length>=W)break;const Be=W-ne.length,Ae=await ps(_,de,Be);ne.push(...Ae.slice(0,Be))}return ne}async function vs(_,P){const{dispatch:W,io:X,onError:ne}=_.props,se=Li(P.keys),de=Eo(X,se),Be=Mo(X,P.id);y.bridgifyObject(Be);const Ae=await fu(de);W({type:"STORAGE_WALLET_ADDED",payload:{id:P.id,initialState:{localDisklet:Be,paths:de,status:Ae,lastChanges:[]}}});const Ue=Gi(_,P.id);Ae.lastSync>0?Ue.catch($e=>{const{syncKey:nt}=P.keys,{lastHash:Ye}=Ae;_.props.log.error(`Could not sync ${String(nt)} with last hash ${String(Ye)}: ${String($e)}`),ne($e)}):await Ue}function Gi(_,P){const{dispatch:W,syncClient:X,state:ne}=_.props,{paths:se,status:de}=ne.storageWallets[P];return na(X,se,{...de}).then(({changes:Be,status:Ae})=>(W({type:"STORAGE_WALLET_SYNCED",payload:{id:P,changes:Object.keys(Be),status:Ae}}),Object.keys(Be)))}const ia=Fr(Hf),uu=Fr(Uf),So="CustomTokens.json",lu="Settings.json",ms=l.asMaybe(l.asObject({contractAddress:l.asString}));async function gs(_,P,W){const X=await Fn(_,P);if(X.getTokenId!=null)return await X.getTokenId(W);const ne=du(_,P);if(ne==null)throw new Error("A wallet must exist before adding tokens to a legacy currency plugin");if(ne.addCustomToken==null)throw new Error(`${P} doesn't support tokens`);const se=aa(W);if(se==null)throw new Error("A token must have a contract address to be added to a legacy currency plugin");return await ne.addCustomToken({...se,...W}),oa(se.contractAddress)}function oa(_){return _.toLowerCase().replace(/^0x/,"")}function ys(_){const P={};for(const W of _){const{contractAddress:X}=W;X!=null&&(P[oa(X)]={currencyCode:W.currencyCode,denominations:W.denominations,displayName:W.currencyName,networkLocation:{contractAddress:W.contractAddress}})}return P}function cu(_){const{currencyCode:P,displayName:W,denominations:X,networkLocation:ne}=_,se=ms(ne);return{currencyCode:P,currencyName:W,denominations:X,contractAddress:se==null?void 0:se.contractAddress}}function bs(_={}){const P=[];for(const W of Object.keys(_))P.push(cu(_[W]));return P}function aa(_){const{currencyCode:P,displayName:W,denominations:X,networkLocation:ne}=_,se=ms(ne);if(se!=null)return{currencyCode:P,currencyName:W,multiplier:X[0].multiplier,contractAddress:se.contractAddress}}async function hu(_,P){const{dispatch:W,state:X}=_.props;await Promise.all(Object.keys(X.plugins.currency).map(async ne=>{var Be;const se=X.plugins.currency[ne],de=se.getBuiltinTokens==null?ys((Be=se.currencyInfo.metaTokens)!=null?Be:[]):await se.getBuiltinTokens();W({type:"ACCOUNT_BUILTIN_TOKENS_LOADED",payload:{accountId:P,pluginId:ne,tokens:de}})}))}function du(_,P){for(const W of Object.keys(_.props.state.currency.wallets)){const X=_.props.output.currency.wallets[W];if((X==null?void 0:X.engine)!=null&&_.props.state.currency.wallets[W].pluginId===P)return X.engine}}async function ws(_,P){const{state:W}=_.props,{accountWalletInfo:X}=W.accounts[P],ne=zr(W,X.id),se=await uu.load(ne,lu);if(se==null)return{};const de={};for(const Be of se.customTokens){if(!Be.isVisible)continue;const Ae=po(W.plugins.currency,Be.walletType);if(Ae==null)continue;de[Ae]==null&&(de[Ae]={});const Ue=oa(Be.contractAddress);de[Ae][Ue]={currencyCode:Be.currencyCode,denominations:Be.denominations,displayName:Be.currencyName,networkLocation:{contractAddress:Be.contractAddress}}}return de}async function pu(_,P){const{dispatch:W,state:X}=_.props,{accountWalletInfo:ne}=X.accounts[P],se=zr(X,ne.id),de=await ia.load(se,So);if(de!=null){const{customTokens:Be}=de;W({type:"ACCOUNT_CUSTOM_TOKENS_LOADED",payload:{accountId:P,customTokens:Be}})}else{const Be=await ws(_,P);W({type:"ACCOUNT_CUSTOM_TOKENS_LOADED",payload:{accountId:P,customTokens:Be}})}}async function vu(_,P){const{state:W}=_.props,{accountWalletInfo:X}=W.accounts[P],ne=zr(W,X.id),{customTokens:se}=_.props.state.accounts[P],de=await ia.load(ne,So);await ia.save(ne,So,{...de,customTokens:se})}function jn(_){const{currencyInfo:P,allTokens:W}=_;let X=_.tokenId;X===void 0&&_.currencyCode!=null&&_.currencyCode!==P.currencyCode&&(X=Object.keys(W).find(se=>W[se].currencyCode===_.currencyCode));const{currencyCode:ne}=X==null?P:W[X];return{currencyCode:ne,tokenId:X!=null?X:null}}function xs(_,P){const{id:W,type:X,keys:ne}=P;return{id:W,type:X,keys:ne,get disklet(){return zr(_.props.state,W)},get localDisklet(){return ho(_.props.state,W)},async sync(){await Gi(_,W)}}}const mu={"[object Float32Array]":!0,"[object Float64Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Int8Array]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0};function gu(_,P,W){if(W==="[object Object]"){if(Object.getPrototypeOf(_)!==Object.getPrototypeOf(P))return!1;const ne=Object.getOwnPropertyNames(_);if(ne.length!==Object.getOwnPropertyNames(P).length)return!1;for(const se of ne)if(!Object.prototype.hasOwnProperty.call(P,se)||!Vi(_[se],P[se]))return!1;return!0}if(W==="[object Array]"){if(_.length!==P.length)return!1;for(let X=0;X<_.length;++X)if(!Vi(_[X],P[X]))return!1;return!0}if(W==="[object Date]")return _.getTime()===P.getTime();if(W==="[object Map]")return Ms(_,P);if(mu[W]){if(_.length!==P.length)return!1;for(let X=0;X<_.length;++X)if(_[X]!==P[X])return!1;return!0}return!1}function Ms(_,P){if(_.size!==P.size)return!1;for(const[W,X]of _)if(!P.has(W)||P.get(W)!==X)return!1;return!0}function Vi(_,P){if(_===P)return!0;if(typeof _!="object"||typeof P!="object")return!1;const W=Object.prototype.toString.call(_);return W!==Object.prototype.toString.call(P)?!1:gu(_,P,W)}let Es=500,sa=3;const _i=[];function yu(){sa=99,Es=1}function ti(_){_i.length<=0&&Ss();let P=!1;for(const W of _i)if(W.id===_.id&&W.action===_.action){W.updateFunc=_.updateFunc,P=!0;break}P||_i.push(_)}function Ss(){setTimeout(()=>{const _=Math.min(sa,_i.length);for(let P=0;P<_;P++){const W=_i.shift();W!=null&&W.updateFunc()}_i.length>0&&Ss()},Es)}function zc(_){const P=l.asObject(_);return l.asCodec(W=>{const X=P(W),ne=new Map;for(const se of Object.keys(X))ne.set(se,X[se]);return ne},W=>{const X={};return W.forEach((ne,se)=>{X[se]=ne}),P(X)})}function bu(_){const P=l.asObject(_);return l.asCodec(W=>{const X=P(W),ne=new Map;for(const se of Object.keys(X))ne.set(se===""?null:se,X[se]);return ne},W=>{const X={};return W.forEach((ne,se)=>{X[se==null?"":se]=ne}),P(X)})}const wu=_=>{const P=xu(_),{exchangeAmount:W={}}=P;for(const X of Object.keys(W))String(W[X]).includes("e")&&delete W[X];return P};function ks(_,P){var de,Be,Ae,Ue,$e,nt;const W={exchangeAmount:{}},{exchangeAmount:X={}}=W,ne=(de=_.exchangeAmount)!=null?de:{},se=(Be=P.exchangeAmount)!=null?Be:{};for(const Ye of Object.keys(ne))se[Ye]!==null&&(X[Ye]=ne[Ye]);for(const Ye of Object.keys(se)){const vt=se[Ye];vt!=null&&(X[Ye]=vt)}return P.bizId!==null&&(W.bizId=(Ae=P.bizId)!=null?Ae:_.bizId),P.category!==null&&(W.category=(Ue=P.category)!=null?Ue:_.category),P.name!==null&&(W.name=($e=P.name)!=null?$e:_.name),P.notes!==null&&(W.notes=(nt=P.notes)!=null?nt:_.notes),W}const xu=l.asObject({bizId:l.asOptional(l.asNumber),category:l.asOptional(l.asString),exchangeAmount:l.asOptional(l.asObject(l.asNumber)),name:l.asOptional(l.asString),notes:l.asOptional(l.asString)}),_s=l.asValue("high","standard","low"),Is=l.asObject({orderId:l.asOptional(l.asString),orderUri:l.asOptional(l.asString),isEstimate:l.asBoolean,plugin:l.asObject({pluginId:l.asString,displayName:l.asString,supportEmail:l.asOptional(l.asString)}),payoutAddress:l.asString,payoutCurrencyCode:l.asString,payoutNativeAmount:l.asString,payoutWalletId:l.asString,refundAddress:l.asOptional(l.asString)});function fa(_){const P=l.asString(_);if(!/^\d+$/.test(P))throw new Error("Expected an integer string");return P}const As=l.asEither(l.asString,l.asNull),qi=l.asObject({pluginId:l.asString,tokenId:As,nativeAmount:l.asOptional(fa)}),Mu=l.asObject({fiatCurrencyCode:l.asString,fiatAmount:l.asString}),Ts=l.asObject({pluginId:l.asString,displayName:l.asString,isDex:l.asOptional(l.asBoolean),orderUri:l.asOptional(l.asString),supportEmail:l.asString}),Eu=l.asObject({actionType:l.asValue("swap"),swapInfo:Ts,orderId:l.asOptional(l.asString),orderUri:l.asOptional(l.asString),isEstimate:l.asOptional(l.asBoolean),canBePartial:l.asOptional(l.asBoolean),fromAsset:qi,toAsset:qi,payoutWalletId:l.asString,payoutAddress:l.asString,refundAddress:l.asOptional(l.asString)}),Kc=l.asObject({actionType:l.asValue("stake"),pluginId:l.asString,stakeAssets:l.asArray(qi)}),Su=l.asObject({actionType:l.asValue("fiat"),orderId:l.asString,orderUri:l.asOptional(l.asString),isEstimate:l.asBoolean,fiatPlugin:l.asObject({providerId:l.asString,providerDisplayName:l.asString,supportEmail:l.asOptional(l.asString)}),payinAddress:l.asOptional(l.asString),payoutAddress:l.asOptional(l.asString),fiatAsset:Mu,cryptoAsset:qi}),Ps=l.asObject({actionType:l.asValue("tokenApproval"),tokenApproved:qi,tokenContractAddress:l.asString,contractAddress:l.asString}),ua=l.asEither(Eu,Kc,Su,Ps),ku=l.asValue("claim","claimOrder","stake","stakeNetworkFee","stakeOrder","unstake","unstakeNetworkFee","unstakeOrder","swap","swapNetworkFee","swapOrderPost","swapOrderFill","swapOrderCancel","buy","sell","sellNetworkFee","tokenApproval","transfer","transferNetworkFee"),Os=l.asObject({assetActionType:ku}),_u=l.asArray(l.asString),Iu=l.asObject({enabledTokenIds:l.asArray(l.asString),detectedTokenIds:l.asArray(l.asString)}),la=l.asObject({assetAction:l.asOptional(Os),metadata:wu,nativeAmount:l.asOptional(l.asString),providerFeeSent:l.asOptional(l.asString)}),Au=l.asObject({txid:l.asString,internal:l.asBoolean,creationDate:l.asNumber,currencies:zc(la),tokens:l.asOptional(bu(la),()=>new Map),deviceDescription:l.asOptional(l.asString),feeRateRequested:l.asOptional(l.asEither(_s,Cn)),feeRateUsed:l.asOptional(Cn),payees:l.asOptional(l.asArray(l.asObject({address:l.asString,amount:l.asString,currency:l.asString,tag:l.asOptional(l.asString)}))),savedAction:l.asOptional(ua),secret:l.asOptional(l.asString),swap:l.asOptional(Is)}),Tu=l.asObject({airbitzFeeWanted:l.asNumber,meta:l.asObject({amountFeeAirBitzSatoshi:l.asNumber,balance:l.asNumber,fee:l.asNumber,amountCurrency:l.asNumber,bizId:l.asNumber,category:l.asString,name:l.asString,notes:l.asString,attributes:l.asNumber,amountSatoshi:l.asNumber,amountFeeMinersSatoshi:l.asNumber,airbitzFee:l.asNumber}),ntxid:l.asString,state:l.asObject({creationDate:l.asNumber,internal:l.asBoolean,malleableTxId:l.asString})}),Bs=l.asObject({seq:l.asNumber,address:l.asString,state:l.asObject({recycleable:l.asOptional(l.asBoolean,!0),creationDate:l.asOptional(l.asNumber,0)}),meta:l.asObject({amountSatoshi:l.asOptional(l.asNumber,0)}).withRest}),Pu=l.asObject(l.asObject({timestamp:l.asNumber,txidHash:l.asString})),Ou=l.asObject({walletInfo:l.asObject({id:l.asString,keys:Cn,type:l.asString})}),Rs=l.asObject({fiat:l.asOptional(l.asString),num:l.asOptional(l.asNumber)}),Bu=l.asObject({walletName:l.asEither(l.asString,l.asNull)}),ko=Qn;function _o(_,P){return _+P}async function Ru(_,P,W,X){const{now:ne=new Date}=X,{passwordBox:se,passwordKeySnrp:de,username:Be}=P;if(se==null||de==null||Be==null)throw new Error("Missing data for offline password login");const Ae=_o(Be,W),Ue=await wi(_,Ae,de),$e=Qr(se,Ue),nt=ji(P,$e);P.lastLogin=ne,Nn(_,P).catch(()=>{});const{log:Ye}=_.props;return pn(_,nt,nt).catch(vt=>Ye.error(vt)),nt}async function Cu(_,P,W,X){const{username:ne}=P;if(ne==null)throw new Error("Password login requires a username");const se=_o(ne,W),[de,Be]=await Promise.all([Hi(_,ne),wi(_,se,ko)]);return await Wi(_,P,P,X,{userId:de,passwordAuth:Be},async Ue=>{const{passwordBox:$e,passwordKeySnrp:nt}=Ue;if($e==null||$e===!0||nt==null)throw new Error("Missing data for online password login");const Ye=await wi(_,se,nt);return Qr($e,Ye)})}async function Fu(_,P,W,X){return await Ru(_,P,W,X).catch(()=>Cu(_,P,W,X))}async function Cs(_,P,W){const X=_.props.state.accounts[P],{loginTree:ne}=X,{username:se}=X.stashTree;if(se==null)throw new Error("Password login requires a username");const de=await Io(_,ne,se,W);await nn(_,ne,de)}async function Nu(_,P,W){const{username:X,passwordAuth:ne}=P;if(X==null||ne==null)return!1;const se=_o(X,W),de=await wi(_,se,ko);for(let Be=0;Be<ne.length;++Be)if(de[Be]!==ne[Be])return!1;return!0}async function Lu(_,P){const{loginTree:W}=_.props.state.accounts[P],X={serverMethod:"DELETE",serverPath:"/v2/login/password",stash:{passwordAuthSnrp:void 0,passwordBox:void 0,passwordKeySnrp:void 0},login:{passwordAuth:void 0},loginId:W.loginId};W.loginAuth!=null&&(X.stash.passwordAuthBox=void 0,X.login.passwordAuth=void 0),await nn(_,W,X)}function Io(_,P,W,X){const ne=_o(W,X),{io:se}=_.props,de=Zf(_).then(Ae=>wi(_,ne,Ae).then(Ue=>{const $e=rn(se,P.loginKey,Ue);return{passwordKeySnrp:Ae,passwordBox:$e}})),Be=wi(_,ne,ko).then(Ae=>{const Ue=rn(se,Ae,P.loginKey);return{passwordAuth:Ae,passwordAuthBox:Ue}});return Promise.all([de,Be]).then(Ae=>{const[{passwordKeySnrp:Ue,passwordBox:$e},{passwordAuth:nt,passwordAuthBox:Ye}]=Ae;return{serverPath:"/v2/login/password",server:Fe({passwordAuth:nt,passwordAuthSnrp:ko,passwordKeySnrp:Ue,passwordBox:$e,passwordAuthBox:Ye}),stash:{passwordKeySnrp:Ue,passwordBox:$e,passwordAuthBox:Ye},login:{passwordAuth:nt},loginId:P.loginId}})}function Ao(_,P){const W=P==null?Uint8Array.from([0]):bt.parse(P);return fn(W,_)}function ca(_,P){return fn(bt.parse(P),_)}function To(_,P){if(_.pin2Key!=null)return _;const W=Sn(_,X=>X.appId===P);if((W==null?void 0:W.pin2Key)!=null)return W}async function Du(_,P,W,X,ne){const se=To(W,P);if(se==null||se.pin2Key==null)throw new Error("PIN login is not enabled for this account on this device");const{pin2Key:de}=se,Be={pin2Id:Ao(de,W.username),pin2Auth:ca(de,X)};return await Wi(_,W,se,ne,Be,async Ae=>{if(Ae.pin2Box==null||Ae.pin2Box===!0)throw new Error("Missing data for PIN v2 login");return Qr(Ae.pin2Box,de)})}async function jc(_,P,W){const X=_.props.state.accounts[P],{loginTree:ne}=X,{username:se}=X.stashTree;let{pin:de,enableLogin:Be}=W;if(Be==null&&(Be=ne.pin2Key!=null||de!=null&&ne.pin==null),de==null&&(de=ne.pin),de==null){if(Be)throw new Error("Please change your PIN in the settings area above before enabling.");await Jo(_,ne,da(ne));return}const Ae=Fs(_,ne,se,de,Be);await Jo(_,ne,Ae)}async function Uu(_,P,W){const{appId:X,loginId:ne,username:se}=P;if(se==null)return!1;const{stashTree:de}=En(_,ne),Be=To(de,X);if(Be==null||Be.pin2Key==null)throw new Error("No PIN set locally for this account");const{pin2Key:Ae}=Be,Ue={pin2Id:Ao(Ae,se),pin2Auth:ca(Ae,W),otp:wo(P)};return await en(_,"POST","/v2/login",Ue).then($e=>!0,$e=>!1)}async function Hu(_,P){const{loginTree:W}=_.props.state.accounts[P],X=da(W);await Jo(_,W,X)}function Fs(_,P,W,X,ne){const se=[ha(_,P,W,X,ne)];for(const de of P.children)se.push(...Fs(_,de,W,X,ne));return se}function zu(_,P){const{loginId:W,pin2Key:X}=_;if(X!=null)return{login:{},loginId:W,server:He({pin2Id:Ao(X,P)}),serverPath:"",stash:{}}}function ha(_,P,W,X,ne){const{io:se}=_.props,de=rn(se,bt.parse(X),P.loginKey);if(ne){const{loginId:Be,loginKey:Ae,pin2Key:Ue=se.random(32)}=P,$e=rn(se,Ae,Ue),nt=rn(se,Ue,Ae);return{serverPath:"/v2/login/pin2",server:yt({pin2Id:Ao(Ue,W),pin2Auth:ca(Ue,X),pin2Box:$e,pin2KeyBox:nt,pin2TextBox:de}),stash:{pin2Key:Ue,pin2TextBox:de},login:{pin2Key:Ue,pin:X},loginId:Be}}else return{serverPath:"/v2/login/pin2",server:yt({pin2Id:void 0,pin2Auth:void 0,pin2Box:void 0,pin2KeyBox:void 0,pin2TextBox:de}),stash:{pin2Key:void 0,pin2TextBox:de},login:{pin2Key:void 0,pin:X},loginId:P.loginId}}function da(_){const P=[Ku(_)];for(const W of _.children)P.push(...da(W));return P}function Ku(_){return{serverMethod:"DELETE",serverPath:"/v2/login/pin2",server:void 0,stash:{pin2Key:void 0},login:{pin2Key:void 0},loginId:_.loginId}}function Xi(_,P){return fn(bt.parse(P),_)}function Ns(_,P){return P.map(W=>fn(bt.parse(W),_))}async function ju(_,P,W,X,ne){const{username:se}=P;if(se==null)throw new Error("Recovery login requires a username");const de={recovery2Id:Xi(W,se),recovery2Auth:Ns(W,X)};return await Wi(_,P,P,ne,de,async Be=>{if(Be.recovery2Box==null||Be.recovery2Box===!0)throw new Error("Missing data for recovery v2 login");return Qr(Be.recovery2Box,W)})}async function Ls(_,P,W){const X={recovery2Id:Xi(P,W)},ne=await en(_,"POST","/v2/login",X),{question2Box:se}=Ce(ne);if(se==null)throw new Error("Login has no recovery questions");return Ds(JSON.parse(bn(se,P)))}async function Wu(_,P,W,X){const ne=_.props.state.accounts[P],{loginTree:se}=ne,{username:de}=ne.stashTree;if(de==null)throw new Error("Recovery login requires a username");const Be=Vu(_,se,de,W,X);await nn(_,se,Be)}async function Wc(_,P){const{loginTree:W}=_.props.state.accounts[P],X={serverMethod:"DELETE",serverPath:"/v2/login/recovery2",stash:{recovery2Key:void 0},login:{recovery2Key:void 0},loginId:W.loginId};await nn(_,W,X)}function Gu(_,P){const{loginId:W,recovery2Key:X}=_;if(X!=null)return{login:{},loginId:W,server:Ke({recovery2Id:Xi(X,P)}),serverPath:"",stash:{}}}function Vu(_,P,W,X,ne){const{io:se}=_.props;if(!Array.isArray(X))throw new TypeError("Questions must be an array of strings");if(!Array.isArray(ne))throw new TypeError("Answers must be an array of strings");const{loginId:de,loginKey:Be,recovery2Key:Ae=se.random(32)}=P,Ue=rn(se,bt.parse(JSON.stringify(qu(X))),Ae),$e=rn(se,Be,Ae),nt=rn(se,Ae,Be);return{serverPath:"/v2/login/recovery2",server:Ze({recovery2Id:Xi(Ae,W),recovery2Auth:Ns(Ae,ne),recovery2Box:$e,recovery2KeyBox:nt,question2Box:Ue}),stash:{recovery2Key:Ae},login:{recovery2Key:Ae},loginId:de}}const Ds=l.asArray(l.asString),qu=l.uncleaner(Ds);async function Us(_,P,W){const{loginTree:X}=_.props.state.accounts[P];function ne(de){const Be=[Xu(_,de,W)];for(const Ae of de.children)Be.push(...ne(Ae));return Be}const se=await Promise.all(ne(X));await Jo(_,X,se)}async function Xu(_,P,W){const{password:X,username:ne}=W,{isRoot:se,loginId:de,passwordAuth:Be}=P;if(Be!=null&&X==null)throw new Error("A password is required to change the username");const Ae=zu(P,ne),Ue=Gu(P,ne);let $e,nt;if(X!=null&&($e=await Io(_,P,ne,X)),se&&(nt=await Hs(_,P,ne)),!($e==null&&Ae==null&&Ue==null&&nt==null))return{login:{...$e==null?void 0:$e.login,...Ae==null?void 0:Ae.login,...Ue==null?void 0:Ue.login,...nt==null?void 0:nt.login},loginId:de,server:{...$e==null?void 0:$e.server,...Ae==null?void 0:Ae.server,...Ue==null?void 0:Ue.server,...nt==null?void 0:nt.server},serverPath:"/v2/login/username",stash:{...$e==null?void 0:$e.stash,...Ae==null?void 0:Ae.stash,...Ue==null?void 0:Ue.stash,...nt==null?void 0:nt.stash}}}async function Hs(_,P,W){const{io:X}=_.props,{loginId:ne,loginKey:se}=P,de=await Hi(_,W);return{login:{userId:de,username:W},loginId:ne,server:Ve({userId:de,userTextBox:rn(X,bt.parse(W),se)}),serverPath:"",stash:{userId:de,username:W}}}async function zs(_,P){const X={userId:await Hi(_,P)};return await en(_,"POST","/v2/login",X).then(ne=>!1).catch(ne=>{if(In(ne)!=null)return!0;throw ne})}async function Ks(_,P,W,X){const{keyInfo:ne,password:se,pin:de,username:Be}=X,{io:Ae}=_.props,Ue=P==null,$e=Ae.random(32),nt=Ae.random(32),Ye={appId:W,lastLogin:new Date,loginId:$e,loginKey:nt,isRoot:Ue,pendingVouchers:[],children:[],keyInfos:[]},vt=$o(_,Ye);let Et,mt,Mt,Ot,Vt;return ne!=null&&(Et=bi(_,Ye,[ne])),P!=null&&(mt=rn(Ae,nt,P.loginKey)),se!=null&&Be!=null&&(Mt=await Io(_,Ye,Be,se)),de!=null&&(Ot=ha(_,Ye,Be,de,!0)),Ue&&Be!=null&&(Vt=await Hs(_,Ye,Be)),{loginId:$e,serverPath:"/v2/login/create",server:{...et({appId:W,loginId:$e,parentBox:mt}),...Et==null?void 0:Et.server,...Mt==null?void 0:Mt.server,...Ot==null?void 0:Ot.server,...vt.server,...Vt==null?void 0:Vt.server},stash:{appId:W,loginId:$e,parentBox:mt,...Et==null?void 0:Et.stash,...Mt==null?void 0:Mt.stash,...Ot==null?void 0:Ot.stash,...vt.stash,...Vt==null?void 0:Vt.stash},login:{appId:W,loginId:$e,loginKey:nt,keyInfos:[],...Et==null?void 0:Et.login,...Mt==null?void 0:Mt.login,...Ot==null?void 0:Ot.login,...vt.login,...Vt==null?void 0:Vt.login}}}async function Zu(_,P,W){const{now:X=new Date}=P,ne=await Ks(_,void 0,"",W),se={data:ne.server};return await en(_,"POST",ne.serverPath,se),ne.stash.lastLogin=X,await Nn(_,ne.stash),ne.login}function pa(_){if(_==null||_.loginKey==null)throw new Error("Incomplete login")}function Po(_,P){const W=Sn(_,X=>X.appId===P);if(W==null)throw new Error(`Internal error: cannot find login for ${P}`);return W}async function Gc(_,P,W,X){pa(W);const ne={pin:P.pin,username:P.username};ne.keyInfo=Ui(vo(X),vi(Vo(_)));const se=await Ks(_,W,X,ne),de={serverPath:se.serverPath,server:se.server,login:{children:[se.login]},stash:{children:[se.stash]},loginId:W.loginId};return await nn(_,P,de)}async function js(_,P,W){const X=vo(W),ne=Sn(P,se=>se.appId===W);if(ne==null)return await Gc(_,P,P,W);if(Vf(ne.keyInfos,X)==null){pa(ne);const se=Ui(X,vi(Vo(_))),de=bi(_,ne,[se]);return await nn(_,P,de)}return P}async function ri(_,P,W,X,ne){const{pauseWallets:se=!1}=ne,{log:de}=_.props;de.warn(`Login: decrypted keys for user ${o.base64.stringify(W.loginId)}`),W=await js(_,W,P),de.warn("Login: account exists for appId");const Be=W.loginKey!=null;return _.props.dispatch({type:"LOGIN",payload:{appId:P,hasRootKey:Be,loginKey:Be?W.loginKey:Po(W,P).loginKey,loginType:X,pauseWallets:se,rootLoginId:W.loginId}}),await Yu(_,_.props.state.lastAccountId)}function Yu(_,P){return _.waitFor(X=>{const ne=X.state.accounts[P];if(ne.loadFailure!=null)throw ne.loadFailure;const se=X.output.accounts[P];if((se==null?void 0:se.accountApi)!=null)return se.accountApi})}const $u=ee.default.ec,va=new $u("secp256k1");function Ws(_,P){const W=_.derive(va.keyFromPublic(P).getPublic()).toArray("be");return fn(Uint8Array.from([0,0,0,1,...W]),bt.parse("dataKey"))}function Gs(_,P){const{publicKey:W}=P,X=Ws(_,W);return JSON.parse(bn(P.box,X))}function Ju(_,P,W){const X=va.genKeyPair({entropy:_.random(32)}),ne=Ws(X,P);return{publicKey:Uint8Array.from(X.getPublic().encodeCompressed()),box:rn(_,bt.parse(JSON.stringify(W)),ne)}}async function Vs(_,P,W=1e3){const{io:X}=_.props,{timeout:ne=600}=P,se=va.genKeyPair({entropy:X.random(32)}),de=Uint8Array.from(se.getPublic().encodeCompressed()),Be=gt.stringify(tn(tn(de)).slice(0,10)),Ae={data:we({...P,publicKey:de,timeout:ne})};await en(_,"PUT",`/v2/lobby/${Be}`,Ae);const[Ue,$e]=U.makeEvents(),nt=[],vt=ki(async()=>{const Et=Le(await en(_,"GET","/v2/lobby/"+Be));for(;nt.length<Et.replies.length;){const mt=Et.replies[nt.length],Mt=Gs(se,mt);$e("reply",Mt),nt.push(Mt)}},W,{onError(Et){$e("error",Et)}});return vt.start({wait:!1}),{close:vt.stop,lobbyId:Be,on:Ue,replies:nt}}async function ma(_,P){const W=Le(await en(_,"GET","/v2/lobby/"+P)),{publicKey:X}=W.request,ne=tn(tn(X)),se=gt.parse(P);if(!Cr(se,ne.subarray(0,se.length)))throw new Error("Lobby ECDH integrity error");return W.request}async function qs(_,P,W,X){const{io:ne}=_.props,{publicKey:se}=W,de={data:ye(Ju(ne,se,X))};await en(_,"POST","/v2/lobby/"+P,de)}const Xs=l.asObject({appId:l.asString,loginKey:D,loginStash:xi});async function Zs(_,P,W,X){const{now:ne=new Date}=X,{loginKey:se,loginStash:de}=P,Be=Sn(de,nt=>nt.appId===W);if(Be==null)throw new Error(`Cannot find requested appId: "${W}"`);try{const nt=En(_,Be.loginId);Be.voucherId=nt.stash.voucherId,Be.voucherAuth=nt.stash.voucherAuth}catch{}de.lastLogin=ne,await Nn(_,de);const Ae=ji(de,se,W),Ue=Sn(Ae,nt=>nt.appId===W);if(Ue==null)throw new Error(`Cannot find requested appId: "${W}"`);const $e=await pn(_,Ae,Ue);return await ri(_,W,$e,"edgeLogin",X)}async function Qu(_,P,W={}){function X(Ue){for(const $e of Be)$e();Ae.state="error",Ae.error=Ue,y.update(Ae),y.close(Ae)}async function ne(Ue){for(const vt of Be)vt();const $e=Xs(Ue),{username:nt}=$e.loginStash;Ae.state="started",Ae.username=nt,y.update(Ae);const Ye=await Zs(_,$e,P,W);Ae.state="done",Ae.account=Ye,y.update(Ae),y.close(Ae)}async function se(){for(const Ue of Be)Ue();Ae.state="closed",y.update(Ae),y.close(Ae)}const de=await Vs(_,{loginRequest:{appId:P}}),Be=[de.close,de.on("error",X),de.on("reply",Ue=>{ne(Ue).catch(X)})],Ae={id:de.lobbyId,cancelRequest:se,watch:y.watchMethod,state:"pending",account:void 0,error:void 0,username:void 0};return y.bridgifyObject(Ae)}const el=l.uncleaner(Xs),tl=l.asObject({appName:l.asString,darkImageUrl:l.asOptional(l.asString),lightImageUrl:l.asOptional(l.asString),imageUrl:l.asOptional(l.asString)});async function Ys(_,P){try{const[W]=Go(_.props.state.infoServers),X=`${W}/v1/appIdInfo/${P}`,ne=await _.props.io.fetch(X);if(ne.status===404)return{appName:P};if(!ne.ok)throw new Error(`Fetching ${X} returned ${ne.status}`);const se=tl(await ne.json());return se.lightImageUrl==null&&(se.lightImageUrl=se.imageUrl),se.darkImageUrl==null&&(se.darkImageUrl=se.imageUrl),se}catch(W){return _.props.onError(W),{appName:P}}}async function rl(_,P,W,X,ne){const{login:se,loginTree:de}=_.props.state.accounts[P];await pn(_,de,se);const Be=await js(_,de,W),Ae=Po(Be,W);if(Ae==null)throw new Error("Failed to create the requested login object");const{stashTree:Ue}=En(_,de.loginId),$e=ei(Ue,W),nt=el({appId:W,loginKey:Ae.loginKey,loginStash:$e});await qs(_,X,ne,nt);let Ye;const vt=_.props.output.accounts[P].accountApi;vt!=null&&vt.on("close",()=>{Ye!=null&&clearTimeout(Ye)}),Ye=setTimeout(()=>{Ye=void 0,pn(_,Be,Ae).then(()=>{Ye=setTimeout(()=>{Ye=void 0,pn(_,Be,Ae).catch(Et=>_.props.onError(Et))},2e4)}).catch(Et=>_.props.onError(Et))},1e4)}async function nl(_,P,W){const X=await ma(_,W);let ne;X.loginRequest!=null&&(ne=await $s(_,P,W,X,X.loginRequest.appId));const se={loginRequest:ne};return y.bridgifyObject(se),se}async function $s(_,P,W,X,ne){const se=await Ys(_,ne),de={appId:ne,displayName:se.appName,displayImageDarkUrl:se.darkImageUrl,displayImageLightUrl:se.lightImageUrl,approve(){return rl(_,P,ne,W,X)},async close(){y.close(de)}};return y.bridgifyObject(de),de}function Js(_){const P={};for(const W of Object.keys(_)){const X=_[W];P[X.currencyCode]=W}return P}function il(_={},P={},W,X){var Be;const ne=Js(_),se=Js(P),de=[];for(const Ae of X){const Ue=(Be=se[Ae])!=null?Be:ne[Ae];Ue!=null&&de.push(Ue)}return de}function ga(_={},P={},W,X){var se;const ne=[];for(const de of X){const Be=(se=P[de])!=null?se:_[de];Be!=null&&ne.push(Be.currencyCode)}return ne}function ni(_,P=[]){const W=new Set(P),X=[];for(const ne of _)W.has(ne)||(W.add(ne),X.push(ne));return X}const Qs="Currency.json",ya="fixedLegacyFileNames.json",ol="EnabledTokens.json",al="Tokens.json",ef="WalletName.json",sl=Fr(Bs),tf=Fr(Pu),fl=Fr(_u),ba=Fr(Tu),rf=Fr(Iu),wa=Fr(Au),xa=Fr(Rs),nf=Fr(Bu);async function ul(_,P,W){const{state:X,walletId:ne}=_.props,se=zr(X,ne);await rf.save(se,al,{detectedTokenIds:P,enabledTokenIds:W})}function of(_,P,W){const X={creationDate:_.state.creationDate,currencies:new Map,tokens:new Map,internal:_.state.internal,txid:_.state.malleableTxId},ne={};return ne[W]=_.meta.amountCurrency,X.currencies.set(P,{metadata:{bizId:_.meta.bizId,category:_.meta.category,exchangeAmount:ne,name:_.meta.name,notes:_.meta.notes},providerFeeSent:_.meta.amountFeeAirBitzSatoshi.toFixed()}),X}function af(_,P,W,X){const ne=mi(_,P,X);return{fileName:`${W.toFixed(0)}-${ne}.json`,txidHash:ne}}async function Vc(_,P){const{dispatch:W,state:X,walletId:ne}=_.props,se=zr(X,ne);await nf.save(se,ef,{walletName:P}),W({type:"CURRENCY_WALLET_NAME_CHANGED",payload:{name:P,walletId:ne}})}async function ll(_,P){const{dispatch:W,state:X,walletId:ne}=_.props,se=zr(X,ne);if(!/^iso:/.test(P))throw new TypeError("Fiat currency codes must start with `iso:`");await xa.save(se,Qs,{fiat:P,num:void 0}),W({type:"CURRENCY_WALLET_FIAT_CHANGED",payload:{fiatCurrencyCode:P,walletId:ne}})}async function sf(_){const{dispatch:P,state:W,walletId:X}=_.props,ne=zr(W,X),se=await xa.load(ne,Qs);let de="iso:USD";if(se!=null){if(se.fiat!=null)de=se.fiat;else if(se.num!=null){const Be=k.number(`000${se.num}`.slice(-3));Be!=null&&(de=`iso:${Be.code}`)}}P({type:"CURRENCY_WALLET_FIAT_CHANGED",payload:{fiatCurrencyCode:de,walletId:X}})}async function ff(_){const{dispatch:P,state:W,walletId:X}=_.props,ne=zr(W,X),se=await nf.load(ne,ef);let de=null;if(se==null||se.walletName==null){const{appIds:Be=[]}=_.props.walletState.walletInfo,Ae=Be.find(Ue=>Ue!=="");if(Ae!=null){const{appName:Ue}=await Ys(Wn(_),Ae);de=Ue}}else de=se.walletName;P({type:"CURRENCY_WALLET_NAME_CHANGED",payload:{name:typeof de=="string"?de:null,walletId:X}})}async function uf(_){const{dispatch:P,state:W,walletId:X}=_.props,ne=zr(W,X),se=await rf.load(ne,al);if(se!=null){P({type:"CURRENCY_WALLET_LOADED_TOKEN_FILE",payload:{walletId:_.props.walletId,...se}});return}const de=await fl.load(ne,ol);if(de!=null){const{accountId:Be,currencyInfo:Ae,pluginId:Ue}=_.props.walletState,$e=_.props.state.accounts[Be],nt=il($e.builtinTokens[Ue],$e.customTokens[Ue],Ae,de);P({type:"CURRENCY_WALLET_LOADED_TOKEN_FILE",payload:{walletId:_.props.walletId,detectedTokenIds:[],enabledTokenIds:nt}})}}async function lf(_,P){const{dispatch:W,walletId:X}=_.props,ne=zr(_.props.state,X),se=_.props.walletState.currencyInfo.currencyCode,de=_.props.walletState.fileNames,Be=_.props.walletState.fiat,Ae={};return await Promise.all(P.map(async Ue=>{if(de[Ue]==null)return;const $e=`Transactions/${de[Ue].fileName}`,nt=await ba.load(ne,$e);nt!=null&&(Ae[Ue]=of(nt,se,Be))})),await Promise.all(P.map(async Ue=>{if(de[Ue]==null)return;const $e=`transaction/${de[Ue].fileName}`,nt=await wa.load(ne,$e);nt!=null&&(Ae[Ue]=nt)})),W({type:"CURRENCY_WALLET_FILES_LOADED",payload:{files:Ae,walletId:X}}),Ae}async function cl(_,P,W){var Ue;const X=ho(_,P),ne=(Ue=await tf.load(X,ya))!=null?Ue:{},se=p.justFiles(await W.list()),de={},Be=[];for(let $e=0;$e<se.length;$e++){const nt=se[$e],Ye=ne[nt];if(Ye!=null){const{timestamp:vt,txidHash:Et}=Ye;de[Et]={creationDate:vt,fileName:nt}}else Be.push(nt)}const Ae=Be.map(async $e=>{const nt=await ba.load(W,$e);if(nt==null)return;const{creationDate:Ye,malleableTxId:vt}=nt.state,Et=$e,mt=mi(_,P,vt);de[mt]={creationDate:Ye,fileName:Et},ne[Et]={timestamp:Ye,txidHash:mt}});return Ae.length>0&&(await Promise.all(Ae),await tf.save(X,ya,ne).catch(()=>{})),de}async function cf(_){const{dispatch:P,state:W,walletId:X}=_.props,ne=zr(W,X),se=await cl(W,X,p.navigateDisklet(ne,"Transactions")),de=await p.navigateDisklet(ne,"transaction").list();for(const Be of p.justFiles(de)){const Ue=Be.split(".json")[0].split("-"),[$e,nt]=Ue,Ye=parseInt($e);(se[nt]==null||Ye<se[nt].creationDate)&&(se[nt]={creationDate:Ye,fileName:Be})}P({type:"CURRENCY_WALLET_FILE_NAMES_LOADED",payload:{txFileNames:se,walletId:X}})}async function Ma(_){var Be;const{state:P,walletId:W}=_.props,X=zr(P,W),ne=[],se=p.justFiles(await X.list("Addresses"));await Promise.all(se.map(async Ae=>{const Ue=await sl.load(X,Ae);Ue!=null&&(Ue.address===""||Ue.state.recycleable||ne.push(Ue.address))}));const de=(Be=_.props.walletOutput)==null?void 0:Be.engine;de!=null&&await de.addGapLimitAddresses(ne)}async function hf(_,P,W,X,ne,se,de){var _r,Lr,Vr;const{dispatch:Be,state:Ae,walletId:Ue}=_.props,$e=zr(Ae,Ue),{accountId:nt,currencyInfo:Ye,pluginId:vt}=_.props.walletState,Et=_.props.state.accounts[nt].allTokens[vt],{currencyCode:mt}=W==null?Ye:Et[W],Mt=_.props.walletState.txs[P];if(Mt==null)throw new Error(`Setting metatdata for missing tx ${P}`);const Ot=_.props.walletState.files,Vt=Object.keys(Ot).find(on=>Ot[on].txid===P),Zt=Vt!=null?Ot[Vt]:void 0,{creationDate:ir=Math.min(Mt.date,Date.now()/1e3)}=Zt!=null?Zt:{},vr={...Zt,creationDate:ir,currencies:new Map((_r=Zt==null?void 0:Zt.currencies)!=null?_r:[]),internal:!0,tokens:new Map((Lr=Zt==null?void 0:Zt.tokens)!=null?Lr:[]),txid:P},yr={metadata:{},...vr.currencies.get(mt),...vr.tokens.get(W)};vr.tokens.set(W,yr),vr.currencies.delete(mt),ne!=null&&(yr.metadata=ks((Vr=yr.metadata)!=null?Vr:{},ne)),se!=null&&(yr.assetAction=se),de!=null&&(vr.savedAction=de);const{fileName:Pr,txidHash:kr}=af(Ae,Ue,ir,P);Be({type:"CURRENCY_WALLET_FILE_CHANGED",payload:{creationDate:ir,fileName:Pr,json:vr,txid:P,txidHash:kr,walletId:Ue}}),await wa.save($e,"transaction/"+Pr,vr);const Ar=Ea(_,Mt,vr,W);X.onTransactionsChanged([Ar])}async function df(_,P){const{dispatch:W,state:X,walletId:ne}=_.props,{assetAction:se,savedAction:de,spendTargets:Be,swapData:Ae,tokenId:Ue,txid:$e}=P,nt=zr(X,ne),Ye=Date.now()/1e3,{metadata:vt={},nativeAmount:Et}=P,mt={txid:$e,internal:!0,creationDate:Ye,currencies:new Map,tokens:new Map,savedAction:de,swap:Ae};mt.tokens.set(Ue,{assetAction:se,metadata:vt,nativeAmount:Et}),P.networkFeeOption!=null&&(mt.feeRateRequested=P.networkFeeOption==="custom"?P.requestedCustomFee:P.networkFeeOption),mt.feeRateUsed=P.feeRateUsed,Be!=null&&(mt.payees=Be.map(Vt=>({currency:Vt.currencyCode,address:Vt.publicAddress,amount:Vt.nativeAmount,tag:Vt.memo})),P.deviceDescription!=null&&(mt.deviceDescription=P.deviceDescription)),typeof P.txSecret=="string"&&(mt.secret=P.txSecret);const{fileName:Mt,txidHash:Ot}=af(X,ne,Ye,$e);W({type:"CURRENCY_WALLET_FILE_CHANGED",payload:{creationDate:Ye,fileName:Mt,json:mt,txid:$e,txidHash:Ot,walletId:ne}}),await wa.save(nt,"transaction/"+Mt,mt)}const Ii=[],hl=C.buildReducer({accountId(_,P,W){if(_!=null)return _;for(const X of Object.keys(W.root.accounts)){const ne=W.root.accounts[X];for(const se of Object.keys(ne.walletInfos))if(se===W.id)return X}throw new Error(`Cannot find account for walletId ${W.id}`)},allEnabledTokenIds:C.memoizeReducer(_=>_.root.accounts[_.self.accountId].alwaysEnabledTokenIds[_.self.pluginId],_=>_.self.enabledTokenIds,(_=[],P=[])=>ni([..._,...P])),pluginId:C.memoizeReducer(_=>_.root.login.walletInfos[_.id].type,_=>_.root.plugins.currency,(_,P)=>yi(P,_)),paused(_,P,W){return _==null?W.root.accounts[W.self.accountId].pauseWallets:P.type==="CURRENCY_WALLET_CHANGED_PAUSED"?P.payload.paused:_},currencyInfo(_,P,W){if(_!=null)return _;const{pluginId:X}=W.self;return W.root.plugins.currency[X].currencyInfo},detectedTokenIds:un((_=Ii,P)=>{if(P.type==="CURRENCY_WALLET_LOADED_TOKEN_FILE")return P.payload.detectedTokenIds;if(P.type==="CURRENCY_ENGINE_DETECTED_TOKENS"){const{detectedTokenIds:W}=P.payload;return ni([..._,...W])}else if(P.type==="CURRENCY_ENGINE_CLEARED")return[];return _}),enabledTokenIds:un((_=Ii,P)=>{if(P.type==="CURRENCY_WALLET_LOADED_TOKEN_FILE")return P.payload.enabledTokenIds;if(P.type==="CURRENCY_WALLET_ENABLED_TOKENS_CHANGED")return P.payload.enabledTokenIds;if(P.type==="CURRENCY_ENGINE_DETECTED_TOKENS"){const{enablingTokenIds:W}=P.payload;return ni([..._,...W])}return _}),engineFailure(_=null,P){if(P.type==="CURRENCY_ENGINE_FAILED"){const{error:W}=P.payload;return W instanceof Error?W:new Error(String(W))}return _},engineStarted(_=!1,P){return P.type==="CURRENCY_ENGINE_STARTED"?!0:P.type==="CURRENCY_ENGINE_STOPPED"?!1:_},fiat(_="",P){return P.type==="CURRENCY_WALLET_FIAT_CHANGED"?P.payload.fiatCurrencyCode:_},fiatLoaded(_=!1,P){return P.type==="CURRENCY_WALLET_FIAT_CHANGED"?!0:_},files(_={},P){switch(P.type){case"CURRENCY_WALLET_FILE_CHANGED":{const{json:W,txidHash:X}=P.payload,ne={..._};return ne[X]=W,ne}case"CURRENCY_WALLET_FILES_LOADED":{const{files:W}=P.payload;return{..._,...W}}}return _},fileNames(_={},P){switch(P.type){case"CURRENCY_WALLET_FILE_NAMES_LOADED":{const{txFileNames:W}=P.payload;return{..._,...W}}case"CURRENCY_WALLET_FILE_CHANGED":{const{fileName:W,creationDate:X,txidHash:ne}=P.payload;return(_[ne]==null||X<_[ne].creationDate)&&(_[ne]={creationDate:X,fileName:W}),_}}return _},syncRatio(_=0,P){switch(P.type){case"CURRENCY_ENGINE_CHANGED_SYNC_RATIO":return P.payload.ratio;case"CURRENCY_ENGINE_CLEARED":return 0}return _},balanceMap(_=new Map,P){if(P.type==="CURRENCY_ENGINE_CHANGED_BALANCE"){const{balance:W,tokenId:X}=P.payload,ne=new Map(_);return ne.set(X,W),ne}return _},balances:C.memoizeReducer(_=>_.self.balanceMap,_=>_.self.currencyInfo,_=>_.root.accounts[_.self.accountId].allTokens[_.self.pluginId],(_,P,W)=>{const X={};for(const ne of _.keys()){const se=_.get(ne),{currencyCode:de}=ne==null?P:W[ne];se!=null&&(X[de]=se)}return X}),height(_=0,P){return P.type==="CURRENCY_ENGINE_CHANGED_HEIGHT"?P.payload.height:_},name(_=null,P){return P.type==="CURRENCY_WALLET_NAME_CHANGED"?P.payload.name:_},nameLoaded(_=!1,P){return P.type==="CURRENCY_WALLET_NAME_CHANGED"?!0:_},sortedTxidHashes:C.memoizeReducer(_=>_.self.txidHashes,_=>Object.keys(_).sort((P,W)=>_[P].date>_[W].date?-1:_[P].date<_[W].date?1:0)),stakingStatus(_={stakedAmounts:[]},P){return P.type==="CURRENCY_ENGINE_CHANGED_STAKING"?P.payload.stakingStatus:_},txidHashes(_={},P){switch(P.type){case"CURRENCY_ENGINE_CHANGED_TXS":return dl(_,P.payload.txidHashes);case"CURRENCY_WALLET_FILE_NAMES_LOADED":{const{txFileNames:W}=P.payload,X={};for(const ne of Object.keys(W))X[ne]={date:W[ne].creationDate};return dl(_,X)}}return _},txs(_={},P,W){switch(P.type){case"CHANGE_MERGE_TX":{const{tx:X}=P.payload,ne={..._};return ne[X.txid]=X,ne}case"CURRENCY_ENGINE_CHANGED_TXS":{const{txs:X}=P.payload,ne={..._};for(const se of X)ne[se.txid]=Oo(se,ne[se.txid]);return ne}case"CURRENCY_ENGINE_CLEARED":return{}}return _},unactivatedTokenIds(_=[],P){switch(P.type){case"CURRENCY_ENGINE_CHANGED_UNACTIVATED_TOKEN_IDS":return P.payload.unactivatedTokenIds;case"CURRENCY_ENGINE_CLEARED":return[]}return _},gotTxs(_=new Set,P){switch(P.type){case"CURRENCY_ENGINE_GOT_TXS":{const{tokenId:W}=P.payload,X=new Set(_);return X.add(W),X}case"CURRENCY_ENGINE_CLEARED":return new Set;default:return _}},walletInfo(_,P,W){return W.root.login.walletInfos[W.id]},publicWalletInfo(_=null,P){return P.type==="CURRENCY_WALLET_PUBLIC_INFO"?P.payload.walletInfo:_}});function dl(_,P){var X;const W={..._};for(const ne of Object.keys(P)){const se=W[ne],de=P[ne];W[ne]=se==null?de:{date:Math.min(de.date,se.date),txid:(X=de.txid)!=null?X:se.txid}}return W}const qc=C.filterReducer(hl,(_,P)=>/^CURRENCY_/.test(_.type)&&"payload"in _&&typeof _.payload=="object"&&"walletId"in _.payload&&_.payload.walletId===P.id?_:{type:"UPDATE_NEXT"});function Oo(_,P){var se,de,Be,Ae,Ue;const{isSend:W=b.lt(_.nativeAmount,"0"),tokenId:X=null}=_,ne={chainAssetAction:new Map((se=P==null?void 0:P.chainAssetAction)!=null?se:[]),blockHeight:_.blockHeight,chainAction:_.chainAction,confirmations:(de=_.confirmations)!=null?de:"unconfirmed",date:_.date,isSend:W,memos:_.memos,nativeAmount:new Map((Be=P==null?void 0:P.nativeAmount)!=null?Be:[]),networkFee:new Map((Ae=P==null?void 0:P.networkFee)!=null?Ae:[]),otherParams:_.otherParams,ourReceiveAddresses:_.ourReceiveAddresses,signedTx:_.signedTx,txid:_.txid};return ne.nativeAmount.set(X,_.nativeAmount),ne.networkFee.set(X,(Ue=_.networkFee)!=null?Ue:"0"),_.parentNetworkFee!=null&&ne.networkFee.set(null,String(_.parentNetworkFee)),_.chainAssetAction!=null&&ne.chainAssetAction.set(X,_.chainAssetAction),ne}function un(_){return(P,W)=>{const X=_(P,W);return X===P?P:(X.sort((ne,se)=>ne===se?0:ne>se?1:-1),P==null||!Vi(X,P)?X:P)}}let Wt=5e3;function pl(_,P){const{log:W,walletId:X}=_.props;let ne=!1,se=0,de=[];return Be=>{if(ne)W(`throttledTxCallback delay, walletId: ${X}`),de.push(...Be);else{const Ae=Date.now();Ae-se>Wt?(se=Ae,P(Be)):(W(`throttledTxCallback delay, walletId: ${X}`),ne=!0,de=Be,setTimeout(()=>{se=Date.now(),P(de),ne=!1,de=[]},Wt))}}}function vl(_){const{walletId:P}=_.props;P==="narfavJN4rp9ZzYigcRj1i0vrU2OAGGp4+KksAksj54="&&(Wt=25,yu());const W=pl(_,se=>{var de;((de=_.props.walletOutput)==null?void 0:de.walletApi)!=null&&y.emit(_.props.walletOutput.walletApi,"transactionsChanged",se)}),X=pl(_,se=>{var de;((de=_.props.walletOutput)==null?void 0:de.walletApi)!=null&&y.emit(_.props.walletOutput.walletApi,"newTransactions",se)}),ne={onAddressesChecked(se){ti({id:P,action:"onAddressesChecked",updateFunc:()=>{_.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_SYNC_RATIO",payload:{ratio:se,walletId:P}})}})},onNewTokens(se){ti({id:P,action:"onNewTokens",updateFunc:()=>{var Ue,$e;const{detectedTokenIds:de,enabledTokenIds:Be}=_.props.walletState,Ae=ni(se,[...de,...Be]);if(_.props.dispatch({type:"CURRENCY_ENGINE_DETECTED_TOKENS",payload:{detectedTokenIds:se,enablingTokenIds:Ae,walletId:P}}),Ae.length>0){const nt=($e=(Ue=_.props)==null?void 0:Ue.walletOutput)==null?void 0:$e.walletApi;nt!=null&&y.emit(nt,"enabledDetectedTokens",Ae)}}})},onUnactivatedTokenIdsChanged(se){ti({id:P,action:"onUnactivatedTokenIdsChanged",updateFunc:()=>{_.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_UNACTIVATED_TOKEN_IDS",payload:{unactivatedTokenIds:se,walletId:P}})}})},onBalanceChanged(se,de){const{accountId:Be,currencyInfo:Ae,pluginId:Ue}=_.props.walletState,$e=_.props.state.accounts[Be].allTokens[Ue];if(se===Ae.currencyCode)ne.onTokenBalanceChanged(null,de);else{const{tokenId:nt}=jn({allTokens:$e,currencyInfo:Ae,currencyCode:se});nt!=null&&ne.onTokenBalanceChanged(nt,de)}},onTokenBalanceChanged(se,de){const Be=l.asMaybe(fa)(de);if(Be==null){_.props.onError(new Error(`Plugin sent bogus balance for ${String(se)}: "${de}"`));return}ti({id:`${P}==${String(se)}`,action:"onTokenBalanceChanged",updateFunc:()=>{_.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_BALANCE",payload:{balance:Be,tokenId:se,walletId:P}})}})},onBlockHeightChanged(se){ti({id:P,action:"onBlockHeightChanged",updateFunc:()=>{const{txs:de}=_.props.walletState;for(const Be of Object.keys(de)){const Ae=de[Be];if(gl(Ae.confirmations)){const{requiredConfirmations:Ue}=_.props.walletState.currencyInfo,{height:$e}=_.props.walletState;Ae.confirmations=yl(Ae,$e,Ue);const nt=mi(_.props.state,P,Ae.txid),{files:Ye}=_.props.walletState,vt=Ea(_,Ae,Ye[nt],null);_.props.dispatch({type:"CHANGE_MERGE_TX",payload:{tx:Ae}}),W([vt])}}_.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_HEIGHT",payload:{height:se,walletId:P}})}})},onStakingStatusChanged(se){ti({id:P,action:"onStakingStatusChanged",updateFunc:()=>{_.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_STAKING",payload:{stakingStatus:se,walletId:P}})}})},onTransactionsChanged(se){const{accountId:de,currencyInfo:Be,pluginId:Ae}=_.props.walletState,Ue=_.props.state.accounts[de].allTokens[Ae];if(se==null)return;for(const Mt of se){if(typeof Mt.txid!="string"||typeof Mt.date!="number"||typeof Mt.networkFee!="string"||typeof Mt.blockHeight!="number"||typeof Mt.nativeAmount!="string"||typeof Mt.ourReceiveAddresses!="object"){_.props.onError(new Error(`Plugin sent bogus tx: ${JSON.stringify(Mt,null,2)}`));return}if(Mt.isSend==null&&(Mt.isSend=b.lt(Mt.nativeAmount,"0")),Mt.memos==null&&(Mt.memos=[]),Mt.tokenId===void 0){const{tokenId:Ot}=jn({allTokens:Ue,currencyInfo:Be,currencyCode:Mt.currencyCode});Mt.tokenId=Ot!=null?Ot:null}}const{state:$e}=_.props,{fileNames:nt,txs:Ye}=_.props.walletState,vt={},Et=[],mt=[];for(const Mt of se){const{txid:Ot}=Mt;if(gl(Mt.confirmations)){const{requiredConfirmations:Pr}=_.props.walletState.currencyInfo,{height:kr}=_.props.walletState;Mt.confirmations=yl(Mt,kr,Pr)}const Vt=Oo(Mt,Ye[Ot]);if(Vi(Vt,Ye[Ot])&&Mt.metadata==null)continue;const Zt=mi($e,P,Ot),ir=Mt.isSend?!1:nt[Zt]==null;ir&&df(_,Mt).catch(Pr=>_.props.onError(Pr));const{files:vr}=_.props.walletState,yr=Ea(_,Vt,vr[Zt],Mt.tokenId);ir?mt.push(yr):vr[Zt]!=null&&Et.push(yr),vt[Zt]={date:yr.date,txid:Ot}}_.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_TXS",payload:{txs:se,walletId:P,txidHashes:vt}}),Et.length>0&&W(Et),mt.length>0&&X(mt)},onAddressChanged(){_.props.walletOutput.walletApi!=null&&y.emit(_.props.walletOutput.walletApi,"addressChanged",void 0)},onWcNewContractCall(se){_.props.walletOutput.walletApi!=null&&y.emit(_.props.walletOutput.walletApi,"wcNewContractCall",se)},onTxidsChanged(){}};return ne}function ml(_){const{walletId:P}=_.props;let W;async function X(se){const de=Rf(se.state,P);de!==W&&(W=de,await uf(_),await sf(_),await ff(_),await cf(_),await Ma(_))}function ne(){_.nextProps().then(X).then(ne,se=>{v.isPixieShutdownError(se)||(_.props.onError(se),ne())})}ne()}const gl=_=>_!=="confirmed"&&_!=="dropped"&&_!=="failed",yl=(_,P,W=1)=>{if(_.blockHeight>0){const X=1+P-_.blockHeight;return X<=0?"syncing":X>=W?"confirmed":X}return _.blockHeight<0?"dropped":"unconfirmed"};function Xc(_,P=new Date(0),W=new Date){return _.date*1e3>=P.valueOf()&&_.date*1e3<W.valueOf()}function Zc(_,P,W){var Be;const X=_.props.state.currency;if(W==null||W==="")return!0;let ne=W.toLowerCase().replace(".","").replace(",","");for(let Ae=0;Ae<ne.length;Ae++)if(ne[Ae]!=="0"){ne=ne.substring(Ae);break}function se(Ae){return!(Ae==null||typeof Ae!="string"&&typeof Ae!="number"||!Ae.toString().toLowerCase().replace(".","").replace(",","").includes(ne))}if(se(P.nativeAmount))return!0;if(P.metadata!=null){const{category:Ae="",name:Ue="",notes:$e="",exchangeAmount:nt={}}=P.metadata,Ye=P.walletId!=null?X.wallets[P.walletId]:void 0;if(se(Ae)||se(Ue)||se($e)||Ye!=null&&se(nt[Ye.fiat]))return!0}if(P.swapData!=null){const{displayName:Ae="",pluginId:Ue=""}=P.swapData.plugin;if(se(Ae)||se(Ue))return!0}const de=(Be=P.savedAction)!=null?Be:P.chainAction;if(de!=null&&de.actionType==="swap"){const{pluginId:Ae}=de.toAsset,{pluginId:Ue}=de.fromAsset,{displayName:$e,supportEmail:nt}=de.swapInfo;if(se(Ue)||se(Ae)||se($e)||se(nt))return!0}if(P.spendTargets!=null)for(const Ae of P.spendTargets){const{publicAddress:Ue="",memo:$e=""}=Ae;if(se(Ue)||se($e))return!0}if(P.ourReceiveAddresses.length>0){for(const Ae of P.ourReceiveAddresses)if(se(Ae))return!0}return!!se(P.txid)}function bl(_,P){var se,de,Be;const W=[],{memoType:X}=P;if(X==="hex"||X==="number"||X==="text")for(const Ae of _.spendTargets)Ae.memo!=null?W.push({type:X,value:Ae.memo}):Ae.uniqueIdentifier!=null?W.push({type:X,value:Ae.uniqueIdentifier}):typeof((se=Ae.otherParams)==null?void 0:se.uniqueIdentifier)=="string"&&W.push({type:X,value:Ae.otherParams.uniqueIdentifier});for(const Ae of W)Ae.type==="hex"&&(Ae.value=Ae.value.replace(/^0x/i,""));const ne={..._,spendTargets:_.spendTargets.map(Ae=>({...Ae,memo:void 0,uniqueIdentifier:void 0})),memos:(de=_.memos)!=null?de:W};if(((Be=ne.memos)==null?void 0:Be.length)===1&&ne.spendTargets.length>=1){const[Ae]=ne.memos;if(Ae.type===P.memoType){const[Ue]=ne.spendTargets;Ue.memo=Ae.value,Ue.uniqueIdentifier=Ae.value,Ue.otherParams={...Ue.otherParams,uniqueIdenfitifer:Ae.value}}}return ne}const Yc={bizId:0,category:"",exchangeAmount:{},name:"",notes:""};function $c(_,P,W,X){const ne=Wn(_),{accountId:se,pluginId:de,walletInfo:Be}=_.props.walletState,Ae=_.props.state.plugins.currency[de],{unsafeBroadcastTx:Ue=!1,unsafeMakeSpend:$e=!1}=Ae.currencyInfo,nt=xs(ne,Be),Ye=vl(_);let vt={};P.otherMethods!=null&&(vt=P.otherMethods,y.bridgifyObject(vt));const Et={on:y.onMethod,watch:y.watchMethod,get disklet(){return nt.disklet},get id(){return nt.id},get localDisklet(){return nt.localDisklet},publicWalletInfo:X,async sync(){await nt.sync()},get type(){return nt.type},get name(){return _.props.walletState.name},async renameWallet(mt){await Vc(_,mt)},get fiatCurrencyCode(){return _.props.walletState.fiat},async setFiatCurrencyCode(mt){await ll(_,mt)},get currencyConfig(){const{accountApi:mt}=_.props.output.accounts[se];return mt.currencyConfig[de]},get currencyInfo(){return Ae.currencyInfo},async denominationToNative(mt,Mt){const Ot=Ka(Ae.currencyInfo,_.props.state.accounts[se].allTokens[de],Mt);return b.mul(mt,Ot)},async nativeToDenomination(mt,Mt){const Ot=Ka(Ae.currencyInfo,_.props.state.accounts[se].allTokens[de],Mt);return b.div(mt,Ot,Ot.length)},get balances(){return _.props.walletState.balances},get balanceMap(){return _.props.walletState.balanceMap},get blockHeight(){const{skipBlockHeight:mt}=_.props.state;return mt?0:_.props.walletState.height},get syncRatio(){return _.props.walletState.syncRatio},get unactivatedTokenIds(){return _.props.walletState.unactivatedTokenIds},async changePaused(mt){_.props.dispatch({type:"CURRENCY_WALLET_CHANGED_PAUSED",payload:{walletId:_.props.walletId,paused:mt}})},get paused(){return _.props.walletState.paused},async changeEnabledTokenIds(mt){var kr;const{dispatch:Mt,walletId:Ot,walletState:Vt}=_.props,{accountId:Zt,pluginId:ir}=Vt,yr=(kr=_.props.state.accounts[Zt].allTokens[ir])!=null?kr:{},Pr=mt.filter(Ar=>yr[Ar]!=null);Mt({type:"CURRENCY_WALLET_ENABLED_TOKENS_CHANGED",payload:{walletId:Ot,enabledTokenIds:Pr}})},get detectedTokenIds(){return _.props.walletState.detectedTokenIds},get enabledTokenIds(){return _.props.walletState.enabledTokenIds},async getNumTransactions(mt){const Mt=jn({allTokens:_.props.state.accounts[se].allTokens[de],currencyInfo:Ae.currencyInfo,tokenId:mt.tokenId});return P.getNumTransactions(Mt)},async $internalStreamTransactions(mt){const{afterDate:Mt,batchSize:Ot=10,beforeDate:Vt,firstBatchSize:Zt=Ot,searchString:ir,tokenId:vr=null}=mt,{currencyCode:yr}=vr==null?this.currencyInfo:this.currencyConfig.allTokens[vr],Pr={currencyCode:yr,tokenId:vr};let kr=_.props.walletState;if(!kr.gotTxs.has(vr)){const Ln=await P.getTransactions(Pr);Ye.onTransactionsChanged(Ln),_.props.dispatch({type:"CURRENCY_ENGINE_GOT_TXS",payload:{walletId:_.props.walletId,tokenId:vr}}),kr=_.props.walletState}const{files:Ar,sortedTxidHashes:_r,txidHashes:Lr,txs:Vr}=kr;let on=0,kn=!0,mn=0;return y.bridgifyObject({async next(){var $i,Gn;const Ln=kn?Zt:Ot,Kr=[];for(;on<_r.length&&Kr.length<Ln;){if(on>=mn){const Yl=_r.slice(mn,mn+Ln).filter(Jl=>Ar[Jl]==null),$l=await lf(_,Yl);Object.assign(Ar,$l),mn=mn+Ln}const oi=_r[on++],ai=Ar[oi],Co=(Gn=ai==null?void 0:ai.txid)!=null?Gn:($i=Lr[oi])==null?void 0:$i.txid;if(Co==null)continue;const si=Vr[Co];if(si==null||!(si.nativeAmount.has(vr)||si.networkFee.has(vr)))continue;const Ta=Ea(_,si,ai,vr);Zc(ne,Ta,ir)&&Xc(Ta,Mt,Vt)&&Kr.push(Ta)}return kn=!1,{done:Kr.length===0,value:Kr}}})},async getTransactions(mt){const{endDate:Mt,startDate:Ot,searchString:Vt}=mt,Zt=jn({allTokens:_.props.state.accounts[se].allTokens[de],currencyInfo:Ae.currencyInfo,tokenId:mt.tokenId}),ir=await Et.$internalStreamTransactions({...Zt,afterDate:Ot,beforeDate:Mt,searchString:Vt}),vr=[];for(;;){const yr=await ir.next();if(yr.done)return vr;vr.push(...yr.value)}},streamTransactions:t,async getReceiveAddress(mt){const Mt=jn({allTokens:_.props.state.accounts[se].allTokens[de],currencyInfo:Ae.currencyInfo,tokenId:mt.tokenId});return{...await P.getFreshAddress({...Mt,forceIndex:mt.forceIndex}),nativeAmount:"0",metadata:Yc}},async lockReceiveAddress(mt){},async saveReceiveAddress(mt){},async broadcastTx(mt){const Mt=Ue?Be.keys:void 0;return await P.broadcastTx(mt,{privateKeys:Mt})},async getMaxSpendable(mt){mt=bl(mt,Ae.currencyInfo);const Mt=jn({allTokens:_.props.state.accounts[se].allTokens[de],currencyInfo:Ae.currencyInfo,tokenId:mt.tokenId});if(typeof P.getMaxSpendable=="function"){const yr=$e?Be.keys:void 0;return await P.getMaxSpendable({...mt,...Mt},{privateKeys:yr})}const{networkFeeOption:Ot,customNetworkFee:Vt}=mt,Zt=P.getBalance(Mt),ir=mt.spendTargets.map(yr=>({...yr,nativeAmount:"0"}));function vr(yr,Pr){const kr=b.sub(Pr,yr);if(b.lte(kr,"1"))return Promise.resolve(yr);const Ar=b.add(yr,b.div(kr,"2"));ir[0].nativeAmount=Ar;const _r=$e?Be.keys:void 0;return P.makeSpend({...Mt,spendTargets:ir,networkFeeOption:Ot,customNetworkFee:Vt},{privateKeys:_r}).then(()=>vr(Ar,Pr)).catch(()=>vr(yr,Ar))}return await vr("0",b.add(Zt,"1"))},async getPaymentProtocolInfo(mt){if(P.getPaymentProtocolInfo==null)throw new Error("'getPaymentProtocolInfo' is not implemented on wallets of this type");return await P.getPaymentProtocolInfo(mt)},async makeSpend(mt){mt=bl(mt,Ae.currencyInfo);const{assetAction:Mt,customNetworkFee:Ot,memos:Vt,metadata:Zt,networkFeeOption:ir="standard",noUnconfirmed:vr=!1,otherParams:yr,pendingTxs:Pr,rbfTxid:kr,savedAction:Ar,skipChecks:_r,spendTargets:Lr=[],swapData:Vr}=mt,on=jn({allTokens:_.props.state.accounts[se].allTokens[de],currencyInfo:Ae.currencyInfo,tokenId:mt.tokenId}),kn=[],mn=[];for(const $i of Lr){const{memo:Gn,publicAddress:oi,nativeAmount:ai="0",otherParams:Co={}}=$i;oi!=null&&(kn.push({memo:Gn,nativeAmount:ai,otherParams:Co,publicAddress:oi,uniqueIdentifier:Gn}),mn.push({currencyCode:on.currencyCode,memo:Gn,nativeAmount:ai,publicAddress:oi,uniqueIdentifier:Gn}))}if(mt.privateKeys!=null)throw new TypeError("Only sweepPrivateKeys takes private keys");const Ln=$e?Be.keys:void 0,Kr=await P.makeSpend({...on,customNetworkFee:Ot,memos:Vt,metadata:Zt,networkFeeOption:ir,noUnconfirmed:vr,otherParams:yr,pendingTxs:Pr,rbfTxid:kr,skipChecks:_r,spendTargets:kn},{privateKeys:Ln});return Kr.networkFeeOption=ir,Kr.requestedCustomFee=Ot,Kr.spendTargets=mn,Kr.currencyCode=on.currencyCode,Kr.tokenId=on.tokenId,Zt!=null&&(Kr.metadata=Zt),Vr!=null&&(Kr.swapData=Is(Vr)),Ar!=null&&(Kr.savedAction=ua(Ar)),Mt!=null&&(Kr.assetAction=Os(Mt)),_.props.state.login.deviceDescription!=null&&(Kr.deviceDescription=_.props.state.login.deviceDescription),Kr},async saveTx(mt){await df(_,mt),await P.saveTx(mt),Ye.onTransactionsChanged([mt])},async saveTxAction(mt){const{txid:Mt,tokenId:Ot,assetAction:Vt,savedAction:Zt}=mt;await hf(_,Mt,Ot,Ye,void 0,Vt,Zt)},async saveTxMetadata(mt){const{txid:Mt,tokenId:Ot,metadata:Vt}=mt;await hf(_,Mt,Ot,Ye,Vt)},async signMessage(mt,Mt={}){if(P.signMessage==null)throw new Error(`${de} doesn't support signing messages`);const Ot=Be.keys;return await P.signMessage(mt,Ot,Mt)},async signTx(mt){const Mt=Be.keys;return await P.signTx(mt,Mt)},async sweepPrivateKeys(mt){if(P.sweepPrivateKeys==null)throw new Error("Sweeping this currency is not supported.");return await P.sweepPrivateKeys(mt)},async accelerate(mt){return P.accelerate==null?null:await P.accelerate(mt)},get stakingStatus(){return _.props.walletState.stakingStatus},async dumpData(){return await P.dumpData()},async resyncBlockchain(){ne.props.dispatch({type:"CURRENCY_ENGINE_CLEARED",payload:{walletId:_.props.walletId}}),await P.resyncBlockchain()},async encodeUri(mt){return await W.encodeUri(mt,bs(_.props.state.accounts[se].customTokens[de]))},async parseUri(mt,Mt){var Vt;const Ot=await W.parseUri(mt,Mt,bs(_.props.state.accounts[se].customTokens[de]));if(Ot.tokenId===void 0){const{tokenId:Zt=null}=jn({allTokens:_.props.state.accounts[se].allTokens[de],currencyInfo:Ae.currencyInfo,currencyCode:(Vt=Ot.currencyCode)!=null?Vt:Mt});Ot.tokenId=Zt}return Ot},otherMethods:vt};return y.bridgifyObject(Et),Et}function Ea(_,P,W,X){var Ye,vt,Et,mt,Mt,Ot,Vt,Zt,ir,vr,yr,Pr;const ne=_.props.walletId,{accountId:se,currencyInfo:de,pluginId:Be}=_.props.walletState,Ae=_.props.state.accounts[se].allTokens[Be],{currencyCode:Ue}=X==null?de:Ae[X],$e=de.currencyCode,nt={chainAction:P.chainAction,chainAssetAction:P.chainAssetAction.get(X),blockHeight:P.blockHeight,confirmations:P.confirmations,currencyCode:Ue,date:P.date,isSend:P.isSend,memos:P.memos,metadata:{},nativeAmount:(Ye=P.nativeAmount.get(X))!=null?Ye:"0",networkFee:(vt=P.networkFee.get(X))!=null?vt:"0",otherParams:{...P.otherParams},ourReceiveAddresses:P.ourReceiveAddresses,parentNetworkFee:(Et=P.networkFee.get(null))!=null?Et:"0",signedTx:P.signedTx,tokenId:X,txid:P.txid,walletId:ne};if(W!=null){W.creationDate<nt.date&&(nt.date=W.creationDate),nt.metadata=ks((Vt=(Ot=(mt=W.tokens.get(null))==null?void 0:mt.metadata)!=null?Ot:(Mt=W.currencies.get($e))==null?void 0:Mt.metadata)!=null?Vt:{},(yr=(vr=(Zt=W.tokens.get(X))==null?void 0:Zt.metadata)!=null?vr:(ir=W.currencies.get(Ue))==null?void 0:ir.metadata)!=null?yr:{}),W.feeRateRequested!=null&&(typeof W.feeRateRequested=="string"?nt.networkFeeOption=W.feeRateRequested:(nt.networkFeeOption="custom",nt.requestedCustomFee=W.feeRateRequested)),nt.feeRateUsed=W.feeRateUsed,W.payees!=null&&(nt.spendTargets=W.payees.map(Ar=>({currencyCode:Ar.currency,memo:Ar.tag,nativeAmount:Ar.amount,publicAddress:Ar.address,uniqueIdentifier:Ar.tag})));const kr=(Pr=W.tokens.get(X))==null?void 0:Pr.assetAction;kr!=null&&(nt.assetAction=kr),W.savedAction!=null&&(nt.savedAction=W.savedAction),W.swap!=null&&(nt.swapData=W.swap),W.secret!=null&&(nt.txSecret=W.secret),W.deviceDescription!=null&&(nt.deviceDescription=W.deviceDescription)}return nt}const wl="publicKey.json",xl=Fr(Ou),Jc=v.combinePixies({engine:_=>async()=>{var Ue,$e;const{state:P,walletId:W,walletState:X}=_.props,{accountId:ne,pluginId:se,walletInfo:de}=X,Be=P.plugins.currency[se],{currencyCode:Ae}=Be.currencyInfo;try{const nt=Wn(_);await vs(nt,de);const{state:Ye}=_.props,vt=ho(Ye,de.id),Et=Cf(Ye,de.id,_.props.io);await cf(_);const mt=await Fn(nt,se),Mt=await pf(de,vt,mt);_.props.dispatch({type:"CURRENCY_WALLET_PUBLIC_INFO",payload:{walletInfo:Mt,walletId:W}}),await uf(_);const Ot=Ye.accounts[ne],Vt=await Be.makeCurrencyEngine(Mt,{callbacks:vl(_),log:co(_.props.logBackend,`${se}-${de.id.slice(0,2)}`),walletLocalDisklet:vt,walletLocalEncryptedDisklet:Et,customTokens:(Ue=Ot.customTokens[se])!=null?Ue:{},enabledTokenIds:_.props.walletState.allEnabledTokenIds,userSettings:($e=Ot.userSettings[se])!=null?$e:{}});_.onOutput(Vt);const Zt={currencyCode:Ae,tokenId:null},ir=l.asMaybe(fa)(Vt.getBalance(Zt));ir!=null&&_.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_BALANCE",payload:{balance:ir,tokenId:null,walletId:W}});const vr=Vt.getBlockHeight();_.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_HEIGHT",payload:{height:vr,walletId:W}}),Vt.getStakingStatus!=null&&await Vt.getStakingStatus().then(yr=>{_.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_STAKING",payload:{stakingStatus:yr,walletId:W}})},yr=>_.props.onError(yr)),await sf(_),await ff(_),await Ma(_)}catch(nt){_.props.onError(nt),_.props.dispatch({type:"CURRENCY_ENGINE_FAILED",payload:{error:nt,walletId:W}})}return ml(_),await v.stopUpdates},walletApi:_=>async()=>{const{walletOutput:P,walletState:W}=_.props;if(P==null)return;const{engine:X}=P,{nameLoaded:ne,pluginId:se,publicWalletInfo:de}=W;if(X==null||de==null||!ne)return;const Be=await Fn(Wn(_),se),Ae=$c(_,X,Be,de);return _.onOutput(Ae),await v.stopUpdates},engineStarted:v.filterPixie(_=>{let P,W;return{update(){const{log:X,walletId:ne,walletOutput:se,walletState:de}=_.props,{currencyInfo:Be,walletInfo:Ae,publicWalletInfo:Ue}=de;if(se==null)return;const{engine:$e,walletApi:nt}=se;if(!(nt==null||!de.fiatLoaded||de.engineStarted)&&$e!=null&&P==null&&(X(`${ne} startEngine`),_.props.dispatch({type:"CURRENCY_ENGINE_STARTED",payload:{walletId:ne}}),P=Promise.resolve().then(()=>$e.startEngine()).catch(Ye=>_.props.onError(Ye)),$e.syncNetwork!=null)){const vt=Be.unsafeSyncNetwork===!0&&Ue!=null?Ae.keys:void 0;W=ki(async()=>{if($e.syncNetwork!=null){const mt=await $e.syncNetwork({privateKeys:vt});W.setDelay(mt)}else W.stop()},1e4,{onError:mt=>{X.error(mt)}}),W.start({wait:!1})}},destroy(){const{log:X,walletId:ne,walletOutput:se}=_.props;if(se==null)return;const{engine:de}=se;de!=null&&P!=null&&(X(`${ne} killEngine`),P.then(()=>de.killEngine()).catch(Be=>_.props.onError(Be)).then(()=>_.props.dispatch({type:"CURRENCY_ENGINE_STOPPED",payload:{walletId:ne}})).catch(()=>{})),W!=null&&W.stop()}}},_=>_.state.paused||_.walletState.paused?void 0:_),syncTimer:v.filterPixie(_=>{async function P(){const{walletId:X}=_.props;await Gi(Wn(_),X)}const W=ki(P,30*1e3);return{update(){const{state:X,walletId:ne,walletOutput:se}=_.props;se!=null&&X.storageWallets[ne]!=null&&X.storageWallets[ne].status.lastSync>0&&W.start({wait:!0})},destroy(){W.stop()}}},_=>_.state.paused||_.walletState.paused?void 0:_),tokenSaver(_){let P=Ii,W=Ii;return async function(){const{detectedTokenIds:ne,enabledTokenIds:se}=_.props.walletState,de=ne!==P||se!==W,Be=ne!=null&&se!=null;de&&Be&&(await ul(_,ne,se).catch(Ae=>_.props.onError(Ae)),await Ca(100)),P=ne,W=se}},watcher(_){let P,W={},X={},ne=Ii;return async()=>{var Mt,Ot;const{state:se,walletState:de,walletOutput:Be}=_.props;if(de==null||Be==null)return;const{engine:Ae,walletApi:Ue}=Be,{accountId:$e,pluginId:nt}=de,Ye=se.accounts[$e];P!==de&&Ue!=null&&y.update(Ue),P=de;const vt=(Mt=Ye.userSettings[nt])!=null?Mt:W;W!==vt&&Ae!=null&&await Ae.changeUserSettings(vt),W=vt;const Et=(Ot=Ye.customTokens[nt])!=null?Ot:X;if(X!==Et&&Ae!=null){if(Ae.changeCustomTokens!=null)await Ae.changeCustomTokens(Et);else if(Ae.addCustomToken!=null)for(const Vt of Object.keys(Et)){const Zt=Et[Vt];if(Zt===X[Vt])continue;const ir=aa(Zt);ir!=null&&await Ae.addCustomToken({...ir,...Zt}).catch(vr=>_.props.onError(vr))}}X=Et;const{allEnabledTokenIds:mt}=de;if(ne!==mt&&Ae!=null){if(Ae.changeEnabledTokenIds!=null)await Ae.changeEnabledTokenIds(mt).catch(Vt=>_.props.onError(Vt));else if(Ae.disableTokens!=null&&Ae.enableTokens!=null){const Vt=ga(Ye.builtinTokens[nt],Ye.customTokens[nt],de.currencyInfo,ni(ne,mt)),Zt=ga(Ye.builtinTokens[nt],Ye.customTokens[nt],de.currencyInfo,ni(mt,ne));await Ae.disableTokens(Vt).catch(ir=>_.props.onError(ir)),await Ae.enableTokens(Zt).catch(ir=>_.props.onError(ir))}}ne=mt}}});async function pf(_,P,W){const X=await xl.load(P,wl);if(X!=null&&(W.checkPublicKey==null||await W.checkPublicKey(X.walletInfo.keys)))return X.walletInfo;let ne={};try{ne=await W.derivePublicKey(_)}catch{}const se={id:_.id,type:_.type,keys:ne};return Object.keys(ne).length>0&&await xl.save(P,wl,{walletInfo:se}),se}async function Qc(_,P){const{stashTree:W}=En(_,P.loginId);await en(_,"POST","/v2/login/delete",Si(W,P))}async function e0(_,P,W){const{allWalletInfosFull:X}=_.props.state.accounts[P],ne=X.find(Ae=>Ae.id===W);if(ne==null)throw new Error(`Invalid wallet id ${W}`);const se=po(_.props.state.plugins.currency,ne.type);if(se==null)return[];const de=await Fn(_,se);return de.getSplittableTypes==null?[]:(await de.getSplittableTypes(ne)).filter(Ae=>{const Ue=Ml(ne,Ae),$e=X.find(nt=>nt.id===Ue.id);return $e==null||$e.archived||$e.deleted})}function Ml(_,P){const{id:W,type:X,keys:ne}=_,se=l.asMaybe(Li)(ne);if(se==null)throw new Error(`Wallet ${W} is not a splittable type`);const{dataKey:de,syncKey:Be}=se,Ae=vf(fn(bt.parse(X),de),fn(bt.parse(P),de)),Ue=vf(o.base64.parse(W),Ae),$e=vf(Be,Ae.subarray(0,Be.length)),nt=X.replace(/wallet:/,"").replace("-",""),Ye=P.replace(/wallet:/,"").replace("-",""),vt=vi({dataKey:de,syncKey:$e});for(const Et of Object.keys(ne)){const mt=Et===nt+"Key"?Ye+"Key":Et;vt[mt]==null&&(vt[mt]=ne[Et])}return{id:o.base64.stringify(Ue),keys:vt,type:P}}async function t0(_,P,W,X){const ne=_.props.state.accounts[P],{allWalletInfosFull:se,login:de,loginTree:Be}=ne,Ae=se.find(vt=>vt.id===W);if(Ae==null)throw new Error(`Invalid wallet id ${W}`);if(X==="wallet:bitcoincash"&&Ae.type==="wallet:bitcoin"&&Ae.keys.format==="bip49")throw new Error("Cannot split segwit-format Bitcoin wallets to Bitcoin Cash");const Ue=X==="wallet:bitcoinsv"&&Ae.type==="wallet:bitcoincash";if(Ue){const vt=_.props.output.currency.wallets[W].walletApi;if(vt==null)throw new Error("Missing Wallet");await r0(vt)}const $e=Ml(Ae,X),nt=se.find(vt=>vt.id===$e.id);if(nt!=null){if(nt.archived||nt.deleted){const vt={};return vt[$e.id]={archived:!1,deleted:!1,migratedFromWalletId:void 0},await Zo(_,P,vt),Ae.id}if(Ue)return $e.id;throw new Error("This wallet has already been split")}const Ye=bi(_,de,[$e]);await nn(_,Be,Ye);try{const vt=await ja(_,$e.id),Et=_.props.output.currency.wallets[W].walletApi;Et!=null&&(Et.name!=null&&await vt.renameWallet(Et.name),Et.fiatCurrencyCode!=null&&await vt.setFiatCurrencyCode(Et.fiatCurrencyCode))}catch(vt){_.props.onError(vt)}return $e.id}async function r0(_){const P={currencyCode:"BCH",tokenId:null},W={...P,spendTargets:[{nativeAmount:"10000",otherParams:{script:{type:"replayProtection"}},publicAddress:""}],metadata:{},networkFeeOption:"high"},X=await _.makeSpend(W),ne=await _.signTx(X),se=await _.broadcastTx(ne);await _.saveTx(se);const{publicAddress:de}=await _.getReceiveAddress(P),Be={...P,metadata:{name:"Replay Protection Tx",notes:"This transaction is to protect your BCH wallet from unintentionally spending BSV funds. Please wait for the transaction to confirm before making additional transactions using this BCH wallet."},networkFeeOption:"high",spendTargets:[{publicAddress:de,nativeAmount:"0"}]},Ae=await _.getMaxSpendable(Be);Be.spendTargets[0].nativeAmount=Ae;const Ue=await _.makeSpend(Be),$e=await _.signTx(Ue),nt=await _.broadcastTx($e);await _.saveTx(nt)}function vf(_,P){if(_.length!==P.length)throw new Error(`Array lengths do not match: ${_.length}, ${P.length}`);const W=new Uint8Array(_.length);for(let X=0;X<_.length;++X)W[X]=_[X]^P[X];return W}async function El(_,P,W){const{stashTree:X}=En(_,P.loginId),ne=await en(_,"POST","/v2/login/vouchers",{...Si(X,P),data:tt(W)}),se=Ei(X,P.loginKey,kt(ne));return await Nn(_,se)}async function Sl(_,P,W,X={}){var Vt,Zt;const{disabled:ne={},noResponseMs:se,preferPluginId:de,promoCodes:Be={},slowResponseMs:Ae=2e4}=X,{log:Ue,state:$e}=_.props,nt=$e.accounts[P],{swapSettings:Ye,userSettings:vt}=nt,Et=$e.plugins.swap;Ue.warn("Requesting swap quotes for: ",{...W,fromWallet:W.fromWallet.id,toWallet:W.toWallet.id},{preferPluginId:de,promoCodes:Be});const mt=new Set,Mt=[];for(const ir of Object.keys(Et)){const{enabled:vr=!0}=Ye[ir]!=null?Ye[ir]:{};!vr||ne[ir]||(mt.add(ir),Mt.push(Et[ir].fetchSwapQuote(W,vt[ir],{infoPayload:(Zt=(Vt=$e.infoCache.corePlugins)==null?void 0:Vt[ir])!=null?Zt:{},promoCode:Be[ir]}).then(yr=>{var Lr;const{fromWallet:Pr,toWallet:kr,...Ar}=(Lr=yr.request)!=null?Lr:{},_r={...yr,request:Ar};return mt.delete(ir),Ue.warn(`${ir} gave swap quote:`,_r),yr},yr=>{throw mt.delete(ir),Ue.warn(`${ir} gave swap error: ${String(yr)}`),yr})))}const Ot=Za(Mt,Ae).then(({results:ir,errors:vr})=>{for(const Pr of mt)Ue.warn(`${Pr} gave swap timeout`);const yr=i0(ir,X);return Ue.warn(`${Mt.length} swap quotes requested, ${ir.length} resolved, ${vr.length} failed, sorted ${yr.map(Pr=>Pr.pluginId).join(", ")}.`),ir.map(Pr=>n0(Et,W,Pr))},ir=>{throw Ue.warn(`All ${Mt.length} swap quotes rejected.`),o0(ir)});return se==null?await Ot:await Xa(Ot,se)}function n0(_,P,W){var ne,se;const X=y.bridgifyObject({canBePartial:W.canBePartial,expirationDate:W.expirationDate,fromNativeAmount:W.fromNativeAmount,isEstimate:W.isEstimate,maxFulfillmentSeconds:W.maxFulfillmentSeconds,networkFee:W.networkFee,pluginId:W.pluginId,request:(ne=W.request)!=null?ne:P,swapInfo:(se=W.swapInfo)!=null?se:_[W.pluginId].swapInfo,toNativeAmount:W.toNativeAmount,async approve(de){return await W.approve(de)},async close(){await W.close(),y.close(X)}});return X}function i0(_,P){const{preferPluginId:W,preferType:X,promoCodes:ne}=P;return _.sort((se,de)=>{if(se.pluginId==="transfer")return-1;if(de.pluginId==="transfer")return 1;if(se.pluginId===W)return-1;if(de.pluginId===W)return 1;if(X!=null){const nt=se.swapInfo.isDex===!0&&X==="DEX"||se.swapInfo.isDex!==!0&&X==="CEX",Ye=de.swapInfo.isDex===!0&&X==="DEX"||de.swapInfo.isDex!==!0&&X==="CEX";if(nt&&!Ye)return-1;if(!nt&&Ye)return 1}if(ne!=null){const nt=ne[se.pluginId]!=null,Ye=ne[de.pluginId]!=null;if(nt&&!Ye)return-1;if(!nt&&Ye)return 1}const{isEstimate:Be=!0}=se,{isEstimate:Ae=!0}=de;if(!Be&&Ae)return-1;if(Be&&!Ae)return 1;const Ue=Number(se.toNativeAmount)/Number(se.fromNativeAmount),$e=Number(de.toNativeAmount)/Number(de.fromNativeAmount);return Ue>$e?-1:$e>Ue?1:0})}function o0(_){return _.reduce((P,W)=>{const X=kl(P)-kl(W);if(X>0)return P;if(X<0)return W;const ne=$n(P),se=$n(W);if(ne!=null&&se!=null)return b.lt(ne.nativeMin,se.nativeMin)?ne:se;const de=pi(P),Be=pi(W);return de!=null&&Be!=null?b.gt(de.nativeMax,Be.nativeMax)?de:Be:P})}function kl(_){return _==null?0:Xn(_)!=null||Bn(_)!=null?6:$n(_)!=null?5:pi(_)!=null?4:yn(_)!=null?3:fo(_)!=null?2:1}const mf=Fr(l.asObject({name:l.asString})),gf=Fr(l.asObject({key:l.asString,data:l.asString}));function a0(_,P){const{accountWalletInfo:W}=_.props.state.accounts[P],X=zr(_.props.state,W.id),ne=Ae=>mi(_.props.state,W.id,Ae),se=Ae=>`Plugins/${ne(Ae)}`,de=(Ae,Ue)=>`${se(Ae)}/${ne(Ue)}.json`,Be={async deleteItem(Ae,Ue){await X.delete(de(Ae,Ue))},async deleteStore(Ae){await X.delete(se(Ae))},async listItemIds(Ae){const Ue=[],$e=p.justFiles(await X.list(se(Ae)));return await Promise.all($e.map(async nt=>{const Ye=await gf.load(X,nt);Ye!=null&&Ue.push(Ye.key)})),Ue},async listStoreIds(){const Ae=[],Ue=p.justFolders(await X.list("Plugins"));return await Promise.all(Ue.map(async $e=>{const nt=await mf.load(X,`${$e}/Name.json`);nt!=null&&Ae.push(nt.name)})),Ae},async getItem(Ae,Ue){const $e=await gf.load(X,de(Ae,Ue));if($e==null)throw new Error(`No item named "${Ue}"`);return $e.data},async setItem(Ae,Ue,$e){const nt=`${se(Ae)}/Name.json`,Ye=await mf.load(X,nt);if(Ye==null)await mf.save(X,nt,{name:Ae});else if(Ye.name!==Ae)throw new Error(`Warning: folder name doesn't match for ${Ae}`);await gf.save(X,de(Ae,Ue),{key:Ue,data:$e})}};return y.bridgifyObject(Be),Be}const s0={},f0=[];class u0 extends y.Bridgeable{constructor(P,W,X){super(),this._ai=P,this._accountId=W,this._pluginId=X;const{otherMethods:ne}=P.props.state.plugins.currency[X];ne!=null?(y.bridgifyObject(ne),this.otherMethods=ne):this.otherMethods={}}get currencyInfo(){return this._ai.props.state.plugins.currency[this._pluginId].currencyInfo}get allTokens(){const{state:P}=this._ai.props,{_accountId:W,_pluginId:X}=this;return P.accounts[W].allTokens[X]}get builtinTokens(){const{state:P}=this._ai.props,{_accountId:W,_pluginId:X}=this;return P.accounts[W].builtinTokens[X]}get customTokens(){var ne;const{state:P}=this._ai.props,{_accountId:W,_pluginId:X}=this;return(ne=P.accounts[W].customTokens[X])!=null?ne:s0}async addCustomToken(P){const{_accountId:W,_ai:X,_pluginId:ne}=this,se=await gs(X,ne,P);return X.props.dispatch({type:"ACCOUNT_CUSTOM_TOKEN_ADDED",payload:{accountId:W,pluginId:ne,tokenId:se,token:P}}),se}async changeCustomToken(P,W){const{_accountId:X,_ai:ne,_pluginId:se}=this;if(ne.props.state.accounts[X].customTokens[se][P]==null)throw new Error(`There is no token with id "${P}"`);const Be=await gs(ne,se,W);if(ne.props.dispatch({type:"ACCOUNT_CUSTOM_TOKEN_ADDED",payload:{accountId:X,pluginId:se,tokenId:Be,token:W}}),Be!==P){const{wallets:Ae}=ne.props.state.currency;for(const Ue of Object.keys(Ae)){const $e=Ae[Ue];$e.accountId!==X||$e.pluginId!==se||!$e.enabledTokenIds.includes(P)||ne.props.dispatch({type:"CURRENCY_WALLET_ENABLED_TOKENS_CHANGED",payload:{walletId:Ue,enabledTokenIds:ni([...$e.enabledTokenIds,Be],[P])}})}ne.props.dispatch({type:"ACCOUNT_CUSTOM_TOKEN_REMOVED",payload:{accountId:X,pluginId:se,tokenId:P}})}}async removeCustomToken(P){const{_accountId:W,_ai:X,_pluginId:ne}=this;X.props.dispatch({type:"ACCOUNT_CUSTOM_TOKEN_REMOVED",payload:{accountId:W,pluginId:ne,tokenId:P}})}get alwaysEnabledTokenIds(){var ne;const{state:P}=this._ai.props,{_accountId:W,_pluginId:X}=this;return(ne=P.accounts[W].alwaysEnabledTokenIds[X])!=null?ne:f0}async changeAlwaysEnabledTokenIds(P){const{_accountId:W,_ai:X,_pluginId:ne}=this;X.props.dispatch({type:"ACCOUNT_ALWAYS_ENABLED_TOKENS_CHANGED",payload:{accountId:W,pluginId:ne,tokenIds:P}})}get userSettings(){return this._ai.props.state.accounts[this._accountId].userSettings[this._pluginId]}async changeUserSettings(P){await Ha(this._ai,this._accountId,this._pluginId,P)}async importKey(P,W={}){const X=await Fn(this._ai,this._pluginId);if(X.importPrivateKey==null)throw new Error("This wallet does not support importing keys");return{...await X.importPrivateKey(P,W.keyOptions),imported:!0}}}class l0 extends y.Bridgeable{constructor(P,W,X){super(),this._ai=P,this._accountId=W,this._pluginId=X}get enabled(){const{swapSettings:P}=this._ai.props.state.accounts[this._accountId],{enabled:W=!0}=P[this._pluginId]!=null?P[this._pluginId]:{};return W}get needsActivation(){var ne,se;const P=this._ai.props.state.plugins.swap[this._pluginId];if(P.checkSettings==null)return!1;const X=(ne=this._ai.props.state.accounts[this._accountId].userSettings[this._pluginId])!=null?ne:{};return(se=P.checkSettings(X).needsActivation)!=null?se:!1}get swapInfo(){return this._ai.props.state.plugins.swap[this._pluginId].swapInfo}get userSettings(){return this._ai.props.state.accounts[this._accountId].userSettings[this._pluginId]}async changeEnabled(P){const W=this._ai.props.state.accounts[this._accountId];return await Wf(this._ai,this._accountId,this._pluginId,{...W.swapSettings[this._pluginId],enabled:P})}async changeUserSettings(P){await Ha(this._ai,this._accountId,this._pluginId,P)}}function c0(_,P){let W=_.props.state.accounts[P];const X=()=>{const Ye=_.props.state.accounts[P];return Ye!=null&&(W=Ye),W},{accountWalletInfo:ne,loginType:se}=X(),de={};for(const Ye of Object.keys(_.props.state.plugins.currency)){const vt=new u0(_,P,Ye);de[Ye]=vt}const Be={};for(const Ye of Object.keys(_.props.state.plugins.swap)){const vt=new l0(_,P,Ye);Be[Ye]=vt}const Ae=a0(_,P),Ue=xs(_,ne);function $e(){if(_.props.state.hideKeys)throw new Error("Not available when `hideKeys` is enabled")}const nt={on:y.onMethod,watch:y.watchMethod,get id(){return Ue.id},get type(){return Ue.type},get disklet(){return $e(),Ue.disklet},get localDisklet(){return $e(),Ue.localDisklet},async sync(){await Ue.sync()},get appId(){return X().login.appId},get created(){return X().login.created},async getLoginKey(){return $e(),gt.stringify(X().login.loginKey)},get lastLogin(){return X().login.lastLogin},get loggedIn(){return _.props.state.accounts[P]!=null},get recoveryKey(){$e();const{login:Ye}=X();return Ye.recovery2Key!=null?gt.stringify(Ye.recovery2Key):void 0},get rootLoginId(){$e();const{loginTree:Ye}=X();return gt.stringify(Ye.loginId)},get username(){const{loginTree:Ye}=X();return Ye.username},get currencyConfig(){return de},get swapConfig(){return Be},get dataStore(){return Ae},get edgeLogin(){const{loginTree:Ye}=X();return Ye.loginKey==null},keyLogin:se==="keyLogin",newAccount:se==="newAccount",passwordLogin:se==="passwordLogin",pinLogin:se==="pinLogin",recoveryLogin:se==="recoveryLogin",async changePassword(Ye){$e(),await Cs(_,P,Ye)},async changePin(Ye){$e(),await jc(_,P,Ye);const{login:vt}=X();return vt.pin2Key!=null?gt.stringify(vt.pin2Key):""},async changeRecovery(Ye,vt){$e(),await Wu(_,P,Ye,vt);const{loginTree:Et}=X();if(Et.recovery2Key==null)throw new Error("Missing recoveryKey");return gt.stringify(Et.recovery2Key)},async changeUsername(Ye){$e(),Ye.username=s(Ye.username),await Us(_,P,Ye)},async checkPassword(Ye){$e();const{loginTree:vt}=X();return await Nu(_,vt,Ye)},async checkPin(Ye){$e();const{login:vt,loginTree:Et}=X();return vt.pin!=null?Ye===vt.pin:await Uu(_,Et,Ye)},async getPin(){var Et;const{login:Ye,loginTree:vt}=X();return(Et=Ye.pin)!=null?Et:vt.pin},async deletePassword(){$e(),await Lu(_,P)},async deletePin(){$e(),await Hu(_,P)},async deleteRecovery(){$e(),await Wc(_,P)},get otpKey(){$e();const{loginTree:Ye}=X();return Ye.otpKey!=null?o.base32.stringify(Ye.otpKey,{pad:!1}):void 0},get otpResetDate(){$e();const{loginTree:Ye}=X();return Ye.otpResetDate},async cancelOtpReset(){$e(),await eu(_,P)},async enableOtp(Ye=7*24*60*60){$e(),await Jf(_,P,Ye)},async disableOtp(){$e(),await Qf(_,P)},async repairOtp(Ye){$e(),await Ki(_,P,o.base32.parse(Ye,{loose:!0}))},get pendingVouchers(){const{login:Ye}=X();return Ye.pendingVouchers},async approveVoucher(Ye){const{loginTree:vt}=X();return await El(_,vt,{approvedVouchers:[Ye]})},async rejectVoucher(Ye){const{loginTree:vt}=X();return await El(_,vt,{rejectedVouchers:[Ye]})},async fetchLobby(Ye){return $e(),await nl(_,P,Ye)},async deleteRemoteAccount(){const{loginTree:Ye}=X();await Qc(_,Ye)},async logout(){_.props.dispatch({type:"LOGOUT",payload:{accountId:P}})},get allKeys(){return _.props.state.accounts[P].allWalletInfosClean},async changeWalletStates(Ye){await Zo(_,P,Ye)},async createWallet(Ye,vt){const{login:Et,loginTree:mt}=X(),Mt=await mo(_,Ye,{keys:vt});return await nn(_,mt,bi(_,Et,[Mt])),Mt.id},getFirstWalletInfo:c.prototype.getFirstWalletInfo,getWalletInfo:c.prototype.getWalletInfo,listWalletIds:c.prototype.listWalletIds,async splitWalletInfo(Ye,vt){return await t0(_,P,Ye,vt)},async listSplittableWalletTypes(Ye){return await e0(_,P,Ye)},async getDisplayPrivateKey(Ye){const vt=Sa(_,P,Ye),Et=yi(_.props.state.plugins.currency,vt.type),mt=await Fn(_,Et);if(mt.getDisplayPrivateKey!=null)return await mt.getDisplayPrivateKey(vt);const{engine:Mt}=_.props.output.currency.wallets[Ye];if(Mt==null||Mt.getDisplayPrivateSeed==null)throw new Error("Wallet has not yet loaded");const Ot=await Mt.getDisplayPrivateSeed(vt.keys);if(Ot==null)throw new Error("The engine failed to return a key");return Ot},async getDisplayPublicKey(Ye){const vt=Sa(_,P,Ye),Et=yi(_.props.state.plugins.currency,vt.type),mt=await Fn(_,Et);if(mt.getDisplayPublicKey!=null){const Vt=Mo(_.props.io,Ye),Zt=await pf(vt,Vt,mt);return await mt.getDisplayPublicKey(Zt)}const{engine:Mt}=_.props.output.currency.wallets[Ye];if(Mt==null||Mt.getDisplayPublicSeed==null)throw new Error("Wallet has not yet loaded");const Ot=await Mt.getDisplayPublicSeed();if(Ot==null)throw new Error("The engine failed to return a key");return Ot},async getRawPrivateKey(Ye){return Sa(_,P,Ye).keys},async getRawPublicKey(Ye){const vt=Sa(_,P,Ye),Et=yi(_.props.state.plugins.currency,vt.type),mt=await Fn(_,Et),Mt=Mo(_.props.io,Ye);return(await pf(vt,Mt,mt)).keys},get activeWalletIds(){return _.props.state.accounts[P].activeWalletIds},get archivedWalletIds(){return _.props.state.accounts[P].archivedWalletIds},get hiddenWalletIds(){return _.props.state.accounts[P].hiddenWalletIds},get currencyWallets(){return _.props.output.accounts[P].currencyWallets},get currencyWalletErrors(){return _.props.state.accounts[P].currencyWalletErrors},async createCurrencyWallet(Ye,vt={}){const{login:Et,loginTree:mt}=X(),Mt=await mo(_,Ye,vt);return await nn(_,mt,bi(_,Et,[Mt])),await qa(_,P,Mt.id,vt)},async createCurrencyWallets(Ye){const{login:vt,loginTree:Et}=X(),mt=await Promise.all(Ye.map(async Mt=>await mo(_,Mt.walletType,Mt)));return await nn(_,Et,bi(_,vt,mt)),await Promise.all(mt.map(async(Mt,Ot)=>await h0(qa(_,P,Mt.id,Ye[Ot]))))},async waitForCurrencyWallet(Ye){return await new Promise((vt,Et)=>{const mt=()=>{const Vt=this.currencyWallets[Ye];Vt!=null&&(vt(Vt),Mt());const Zt=this.currencyWalletErrors[Ye];Zt!=null&&(Et(Zt),Mt())},Mt=()=>{for(const Vt of Ot)Vt()},Ot=[this.watch("currencyWallets",mt),this.watch("currencyWalletErrors",mt)];mt()})},async waitForAllWallets(){return await new Promise((Ye,vt)=>{const Et=()=>{if(this.activeWalletIds.find(Ot=>this.currencyWallets[Ot]==null&&this.currencyWalletErrors[Ot]==null)==null){for(const Ot of mt)Ot();Ye()}},mt=[this.watch("activeWalletIds",Et),this.watch("currencyWallets",Et),this.watch("currencyWalletErrors",Et)];Et()})},async getActivationAssets({activateWalletId:Ye,activateTokenIds:vt}){const{currencyWallets:Et}=_.props.output.accounts[P],mt=_.props.output.currency.wallets[Ye],{engine:Mt}=mt;if(Mt==null)throw new Error(`Invalid wallet: ${Ye} not found`);if(Mt.engineGetActivationAssets==null)throw new Error(`getActivationAssets unsupported by walletId ${Ye}`);const Ot=await Mt.engineGetActivationAssets({currencyWallets:Et,activateTokenIds:vt});return Ot.assetOptions.forEach(Vt=>{var Zt;return Vt.tokenId=(Zt=Vt.tokenId)!=null?Zt:null}),Ot},async activateWallet(Ye){var yr;const{activateWalletId:vt,activateTokenIds:Et,paymentInfo:mt}=Ye,{currencyWallets:Mt}=_.props.output.accounts[P],Ot=_.props.output.currency.wallets[vt],{engine:Vt}=Ot;if(Vt==null)throw new Error(`Invalid wallet: ${vt} not found`);if(Vt.engineActivateWallet==null)throw new Error(`activateWallet unsupported by walletId ${vt}`);const Zt=(yr=mt==null?void 0:mt.walletId)!=null?yr:"",ir=Mt[Zt];if(ir==null)throw new Error(`No wallet for walletId ${Zt}`);const vr=await Vt.engineActivateWallet({activateTokenIds:Et,paymentInfo:mt!=null?{wallet:ir,tokenId:mt.tokenId}:void 0,paymentTokenId:mt==null?void 0:mt.tokenId,paymentWallet:ir});return vr.networkFee.tokenId===void 0&&(vr.networkFee.tokenId=null),y.bridgifyObject(vr)},async fetchSwapQuote(Ye,vt){const[Et,...mt]=await Sl(_,P,Ye,vt);for(const Mt of mt)Mt.close().catch(()=>{});if(Et==null)throw new Error("No swap providers enabled");return Et},async fetchSwapQuotes(Ye,vt){return await Sl(_,P,Ye,vt)}};return y.bridgifyObject(nt),nt}function Sa(_,P,W){const ne=_.props.state.accounts[P].allWalletInfosFull.find(se=>se.id===W);if(ne==null)throw new Error(`Invalid wallet: ${W} not found`);return ne}async function h0(_){try{return{ok:!0,result:await _}}catch(P){return{ok:!1,error:P}}}const yf={},d0=C.buildReducer({accountWalletInfo:C.memoizeReducer(_=>_.self.appId,_=>_.self.login,(_,P)=>{const W=vo(_),X=Vf(P.keyInfos,W);if(X==null)throw new Error(`Cannot find a "${W}" repo`);return X}),accountWalletInfos:C.memoizeReducer(_=>_.self.appId,_=>_.self.login,(_,P)=>{const W=[vo(_)];return _===""&&W.push("account:repo:co.airbitz.wallet",""),P.keyInfos.filter(X=>W.includes(X.type))}),allWalletInfosFull:C.memoizeReducer(_=>_.self.login,_=>_.self.legacyWalletInfos,_=>_.self.walletStates,(_,P,W)=>{const X=qf(_,P),{walletInfos:ne,appIdMap:se}=X;return ne.map(de=>({appId:v0(se[de.id]),appIds:se[de.id],archived:!1,deleted:!1,hidden:!1,sortIndex:ne.length,...W[de.id],...de}))}),allWalletInfosClean:C.memoizeReducer(_=>_.self.allWalletInfosFull,_=>_.map(P=>({...P,keys:{}}))),currencyWalletErrors(_={},P,W,X){var Ae;const{activeWalletIds:ne}=W.self,se=W.root.currency.wallets;let de=ne!==((Ae=X.self)==null?void 0:Ae.activeWalletIds);const Be={};for(const Ue of ne){const $e=se[Ue].engineFailure;$e!=null&&(Be[Ue]=$e),Be[Ue]!==_[Ue]&&(de=!0)}return de?Be:_},currencyWalletIds:C.memoizeReducer(_=>_.self.walletInfos,_=>_.root.plugins.currency,(_,P)=>Object.keys(_).filter(W=>{const X=_[W],ne=po(P,X.type);return!X.deleted&&ne!=null}).sort((W,X)=>{const ne=_[W],se=_[X];return ne.sortIndex-se.sortIndex})),activeWalletIds:C.memoizeReducer(_=>_.self.walletInfos,_=>_.self.currencyWalletIds,_=>_.self.keysLoaded,(_,P,W)=>W?P.filter(X=>!_[X].archived):[]),archivedWalletIds:C.memoizeReducer(_=>_.self.walletInfos,_=>_.self.currencyWalletIds,_=>_.self.keysLoaded,(_,P,W)=>W?P.filter(X=>_[X].archived):[]),hiddenWalletIds:C.memoizeReducer(_=>_.self.walletInfos,_=>_.self.currencyWalletIds,_=>_.self.keysLoaded,(_,P,W)=>W?P.filter(X=>_[X].hidden):[]),keysLoaded(_=!1,P){return P.type==="ACCOUNT_KEYS_LOADED"?!0:_},legacyWalletInfos(_=[],P){return P.type==="ACCOUNT_KEYS_LOADED"?P.payload.legacyWalletInfos:_},walletInfos:C.memoizeReducer(_=>_.self.allWalletInfosFull,_=>{const P={};for(const W of _)P[W.id]=W;return P}),walletStates(_={},P){return P.type==="ACCOUNT_CHANGED_WALLET_STATES"||P.type==="ACCOUNT_KEYS_LOADED"?P.payload.walletStates:_},pauseWallets(_=!1,P){return P.type==="LOGIN"?P.payload.pauseWallets:_},appId(_="",P){return P.type==="LOGIN"?P.payload.appId:_},hasRootKey(_=!0,P){return P.type==="LOGIN"?P.payload.hasRootKey:_},loadFailure(_=null,P){if(P.type==="ACCOUNT_LOAD_FAILED"){const{error:W}=P.payload;return W instanceof Error?W:new Error(String(W))}return _},login:C.memoizeReducer(_=>_.self.appId,_=>_.self.loginTree,(_,P)=>Po(P,_)),loginKey(_=new Uint8Array(0),P){return P.type==="LOGIN"?P.payload.loginKey:_},loginTree:C.memoizeReducer(_=>_.self.appId,_=>_.self.loginKey,_=>_.self.hasRootKey,_=>_.self.stashTree,(_,P,W,X)=>ji(X,P,W?"":_)),loginType(_="newAccount",P){return P.type==="LOGIN"?P.payload.loginType:_},rootLoginId(_=new Uint8Array(0),P){return P.type==="LOGIN"?P.payload.rootLoginId:_},stashTree:C.memoizeReducer(_=>_.self.rootLoginId,_=>_.root.login.stashes,(_,P)=>{for(const W of P)if(Cr(W.loginId,_))return W;throw new Error("There is no stash")}),allTokens(_={},P,W,X){const{builtinTokens:ne,customTokens:se}=W.self;if(X.self==null||ne!==X.self.builtinTokens||se!==X.self.customTokens){const de={..._};for(const Be of Object.keys(W.root.plugins.currency))(X.self==null||ne[Be]!==X.self.builtinTokens[Be]||se[Be]!==X.self.customTokens[Be])&&(de[Be]={...se[Be],...ne[Be]});return de}return _},builtinTokens(_={},P){switch(P.type){case"ACCOUNT_BUILTIN_TOKENS_LOADED":{const{pluginId:W,tokens:X}=P.payload;return{..._,[W]:X}}}return _},customTokens(_=yf,P){var W,X;switch(P.type){case"ACCOUNT_CUSTOM_TOKENS_LOADED":{const{customTokens:ne}=P.payload;return ne}case"ACCOUNT_CUSTOM_TOKEN_ADDED":{const{pluginId:ne,tokenId:se,token:de}=P.payload,Be=(W=_[ne])!=null?W:{};if(Vi(Be[se],de))return _;const Ae={...Be,[se]:de};return{..._,[ne]:Ae}}case"ACCOUNT_CUSTOM_TOKEN_REMOVED":{const{pluginId:ne,tokenId:se}=P.payload,de=(X=_[ne])!=null?X:{};if(de[se]==null)return _;const{[se]:Be,...Ae}=de;return{..._,[ne]:Ae}}}return _},alwaysEnabledTokenIds(_={},P){switch(P.type){case"ACCOUNT_ALWAYS_ENABLED_TOKENS_CHANGED":{const{pluginId:W,tokenIds:X}=P.payload;return{..._,[W]:X}}}return _},swapSettings(_={},P){switch(P.type){case"ACCOUNT_PLUGIN_SETTINGS_LOADED":return P.payload.swapSettings;case"ACCOUNT_SWAP_SETTINGS_CHANGED":{const{pluginId:W,swapSettings:X}=P.payload,ne={..._};return ne[W]=X,ne}}return _},userSettings(_={},P){switch(P.type){case"ACCOUNT_PLUGIN_SETTINGS_CHANGED":{const{pluginId:W,userSettings:X}=P.payload,ne={..._};return ne[W]=X,ne}case"ACCOUNT_PLUGIN_SETTINGS_LOADED":return P.payload.userSettings}return _}}),p0=C.filterReducer(d0,(_,P)=>/^ACCOUNT_/.test(_.type)&&"payload"in _&&typeof _.payload=="object"&&"accountId"in _.payload&&_.payload.accountId===P.id||_.type==="LOGIN"&&P.root.lastAccountId===P.id?_:{type:"UPDATE_NEXT"});function v0(_){return _[_.length-1]}const m0=v.combinePixies({accountApi(_){return{destroy(){const P=_.props;P.state={accounts:{}};const{accountOutput:W}=_.props;if(W==null)return;const{accountApi:X}=W;if(X==null)return;y.update(X),y.close(X),y.close(X.dataStore);const{currencyConfig:ne,swapConfig:se}=X;for(const de of Object.keys(ne))y.close(ne[de]);for(const de of Object.keys(se))y.close(se[de])},async update(){const P=Wn(_),{accountId:W,accountState:X,log:ne}=_.props,{accountWalletInfos:se}=X;async function de(){await Promise.all([Xo(P,W),pu(P,W),za(P,W)])}try{await Wa(P),await hu(P,W),ne.warn("Login: currency plugins exist"),await Promise.all(se.map(Be=>vs(P,Be))),ne.warn("Login: synced account repos"),await de(),ne.warn("Login: loaded files"),_.onOutput(c0(P,W)),ne.warn("Login: complete")}catch(Be){_.props.dispatch({type:"ACCOUNT_LOAD_FAILED",payload:{accountId:W,error:Be}})}return await v.stopUpdates}}},syncTimer:v.filterPixie(_=>{async function P(){const se=Wn(_),{accountId:de,accountState:Be}=_.props,{accountWalletInfos:Ae}=Be;if(_.props.state.accounts[de]==null)return;const Ue=await Promise.all(Ae.map(nt=>Gi(se,nt.id))),$e=[];for(const nt of Ue)$e.push(...nt);$e.length>0&&await Promise.all([za(se,de),Xo(se,de)])}async function W(){const se=Wn(_),{accountId:de}=_.props;if(_.props.state.accounts[de]==null)return;const{login:Be,loginTree:Ae}=_.props.state.accounts[de];await pn(se,Ae,Be)}const X=ki(P,30*1e3),ne=ki(W,30*1e3,{onError(se){const de=di(se);de!=null&&_.props.onError(de)}});return{update(){var se;((se=_.props.accountOutput)==null?void 0:se.accountApi)!=null&&(X.start({wait:!0}),ne.start({wait:!0}))},destroy(){X.stop(),ne.stop()}}},_=>_.state.paused?void 0:_),tokenSaver(_){let P=yf;return async function(){const{accountId:X,accountState:ne}=_.props,{customTokens:se}=ne;se!==P&&P!==yf&&(await vu(Wn(_),X).catch(de=>_.props.onError(de)),await Ca(100)),P=se}},watcher(_){let P;return()=>{const{accountState:W,accountOutput:X}=_.props;if(W==null||X==null)return;const{accountApi:ne}=X;if(ne!=null&&y.update(ne),P!==W&&(P=W,ne!=null)){const{currencyConfig:se,swapConfig:de}=ne;for(const Be of Object.keys(se))y.update(se[Be]);for(const Be of Object.keys(de))y.update(de[Be])}}},currencyWallets(_){let P;return()=>{var Ue;const{accountOutput:W,accountState:X}=_.props,{activeWalletIds:ne}=X;let se=P!==ne;P=ne;let de={};(W==null?void 0:W.currencyWallets)!=null&&(de=W.currencyWallets);const Be={},{wallets:Ae}=_.props.output.currency;for(const $e of ne){const nt=(Ue=Ae[$e])==null?void 0:Ue.walletApi;nt!==de[$e]&&(se=!0),nt!=null&&(Be[$e]=nt)}se&&_.onOutput(Be)}}}),g0=v.mapPixie(m0,_=>_.state.accountIds,(_,P)=>({..._,accountId:P,accountState:_.state.accounts[P],accountOutput:_.output.accounts[P]}));async function y0(_){const{stashes:P}=_.props.state.login,W={},X=[];for(const Be of P){const{loginId:Ae,username:Ue}=Be;Ue!=null&&(W[o.base64.stringify(Ae)]=Ue,X.push(Ae))}const se=await en(_,"POST","/v2/messages",{loginIds:X}),de=[];for(const Be of ae(se)){const{loginId:Ae,...Ue}=Be,$e=o.base64.stringify(Ae),nt=W[$e];nt!=null&&de.push({...Ue,loginId:$e,username:nt})}return de}class b0 extends y.Bridgeable{constructor(P){super(),this._lobby=P,this._cleanups=[P.close,P.on("reply",W=>y.update(this,"replies")),P.on("error",W=>y.emit(this,"error",W))]}get lobbyId(){return this._lobby.lobbyId}get replies(){return this._lobby.replies}close(){this._cleanups.forEach(P=>P()),y.close(this)}}class w0 extends y.Bridgeable{constructor(P){super(),this._ai=P}authRequest(P,W,X){return en(this._ai,P,W,X)}hashUsername(P){return Hi(this._ai,P)}async makeLobby(P,W=1e3){const X=await Vs(this._ai,P,W);return new b0(X)}fetchLobbyRequest(P){return ma(this._ai,P)}async sendLobbyReply(P,W,X){await qs(this._ai,P,W,X)}async syncRepo(P){const{io:W,syncClient:X}=this._ai.props,ne=Eo(W,{dataKey:new Uint8Array(0),syncKey:P});return await na(X,ne,{lastSync:0,lastHash:void 0})}async getRepoDisklet(P,W){const{io:X}=this._ai.props,ne=Eo(X,{dataKey:W,syncKey:P});return y.bridgifyObject(ne.disklet),ne.disklet}}function x0(_){const P=_.props.state.login.appId,W=gt.stringify(_.props.state.login.clientId),X=new w0(_);let ne;const se={on:y.onMethod,watch:y.watchMethod,appId:P,clientId:W,async close(){_.props.close()},$internalStuff:X,fixUsername:s,get localUsers(){return _.props.state.login.localUsers},async forgetAccount(de){const Be=gt.parse(de);for(const Ae of _.props.state.accountIds){const Ue=_.props.state.accounts[Ae];if(Cr(Ue.stashTree.loginId,Be))throw new Error("Cannot remove logged-in user")}await $a(_,Be)},async usernameAvailable(de){return de=s(de),await zs(_,de)},async createAccount(de){de.username!=null&&(de.username=s(de.username));const Be=await Zu(_,de,de);return await ri(_,P,Be,"newAccount",de)},async loginWithKey(de,Be,Ae={}){const{now:Ue=new Date,useLoginId:$e=!1}=Ae,nt=$e?En(_,gt.parse(de)).stashTree:go(_,s(de));if(nt==null)throw new Error("User does not exist on this device");const Ye=ji(nt,gt.parse(Be),P);return nt.lastLogin=Ue,Nn(_,nt).catch(()=>{}),pn(_,Ye,Po(Ye,P)).catch(vt=>_.props.onError(vt)),await ri(_,P,Ye,"keyLogin",Ae)},async loginWithPassword(de,Be,Ae={}){de=s(de);const Ue=go(_,de),$e=await Fu(_,Ue!=null?Ue:Ya(de),Be,Ae);return await ri(_,P,$e,"passwordLogin",Ae)},checkPasswordRules:h,async loginWithPIN(de,Be,Ae={}){const{useLoginId:Ue=!1}=Ae,$e=Ue?En(_,gt.parse(de)).stashTree:go(_,s(de));if($e==null)throw new Error("User does not exist on this device");const nt=await Du(_,P,$e,Be,Ae);return await ri(_,P,nt,"pinLogin",Ae)},async loginWithRecovery2(de,Be,Ae,Ue={}){Be=s(Be);const $e=go(_,Be),nt=await ju(_,$e!=null?$e:Ya(Be),gt.parse(de),Ae,Ue);return await ri(_,P,nt,"recoveryLogin",Ue)},async fetchRecovery2Questions(de,Be){return Be=s(Be),await Ls(_,gt.parse(de),Be)},async requestEdgeLogin(de){return await Qu(_,P,de)},async requestOtpReset(de,Be){return de=s(de),await tu(_,de,Be)},async fetchLoginMessages(){return await y0(_)},get paused(){return _.props.state.paused},async changePaused(de,Be={}){const{secondsDelay:Ae=0}=Be;ne!=null&&(clearTimeout(ne),ne=void 0),_.props.state.paused!==de&&(Ae===0?_.props.dispatch({type:"PAUSE",payload:de}):ne=setTimeout(()=>{ne=void 0,_.props.dispatch({type:"PAUSE",payload:de})},Ae*1e3))},get logSettings(){return _.props.state.logSettings},async changeLogSettings(de){const Be={..._.props.state.logSettings,...de};_.props.dispatch({type:"CHANGE_LOG_SETTINGS",payload:Be})}};return y.bridgifyObject(se),se}const M0=v.combinePixies({api(_){return{destroy(){y.close(_.props.output.context.api)},update(){return _.onOutput(x0(_)),v.stopUpdates}}},watcher(_){let P,W,X;return()=>{(P!==_.props.state.login.localUsers||W!==_.props.state.paused||X!==_.props.state.logSettings)&&(P=_.props.state.login.localUsers,W=_.props.state.paused,X=_.props.state.logSettings,_.props.output.context.api!=null&&y.update(_.props.output.context.api))}},infoFetcher:v.filterPixie(_=>{async function P(){const{dispatch:X,io:ne}=_.props,[se]=Go(_.props.state.infoServers),de=await fetch(`${se}/v1/coreRollup`,{headers:{accept:"application/json"}});if(!de.ok)return;const Be=await de.json(),Ae=is(Be);X({type:"INFO_CACHE_FETCHED",payload:Ae}),await ea.save(ne.disklet,ns,Ae)}const W=ki(P,10*60*1e3);return W.start(),{update(){},destroy(){W.stop()}}},_=>_.state.paused?void 0:_)});function bf(_,P){if(typeof _!="object"||typeof P!="object"||_==null||P==null)return _===P;const W=Array.isArray(_),X=Array.isArray(P);if(W!==X)return!1;if(W){if(_.length!==P.length)return!1;for(let de=0;de<_.length;++de)if(!bf(_[de],P[de]))return!1;return!0}const ne=Object.getOwnPropertyNames(_).filter(de=>_[de]!==void 0),se=Object.getOwnPropertyNames(P).filter(de=>P[de]!==void 0);if(ne.length!==se.length)return!1;for(const de of ne)if(!Object.prototype.hasOwnProperty.call(P,de)||!bf(_[de],P[de]))return!1;return!0}const E0=v.combinePixies({wallets:v.mapPixie(Jc,_=>_.state.currency.currencyWalletIds,(_,P)=>({..._,walletId:P,walletState:_.state.currency.wallets[P],walletOutput:_.output.currency.wallets[P]})),pluginUpdater(_){let P;return async()=>{var ne,se,de,Be;const{infoCache:W,plugins:X}=_.props.state;if(P!==W){if(P!=null)for(const Ae of Object.keys(X.currency)){const Ue=X.currency[Ae],$e=(se=(ne=W.corePlugins)==null?void 0:ne[Ae])!=null?se:{},nt=(Be=(de=P.corePlugins)==null?void 0:de[Ae])!=null?Be:{};Ue.updateInfoPayload!=null&&!bf(nt,$e)&&await Ue.updateInfoPayload($e)}P=W}}}});function S0(_){let P=Promise.resolve();return function(...X){const ne=()=>_.apply(this,X),se=P.then(ne,ne);return P=se,se}}function k0(_,P,W){const X={salt_hex:_,n:16384,r:8,p:1};if(P===0)return X.n=131072,X.r=8,X.p=64,X;let ne=P;const se=8,Be=8-se,Ae=P/se;let Ue=(W-ne)/Ae;Ue=Ue>0?Ue:0,Ue>Be&&(Ue=Be),Ue=Math.floor(Ue),X.r=se+Ue,ne+=Ue*Ae;let $e=14,nt=(W-ne)/ne;nt=nt>0?nt:0,nt>3&&(nt=3),nt=Math.floor(nt),$e+=nt>=0?nt:0,ne+=nt*ne,X.n=Math.pow(2,$e);let Ye=(W-ne)/ne;return Ye=Ye>0?Ye:0,Ye>64&&(Ye=64),Ye=Math.floor(Ye),X.p=Ye>=1?Ye:1,ne+=Ye*ne,X}const _0=v.combinePixies({makeSnrp:_=>()=>{const{io:P,log:W}=_.props;let X;async function ne(se){X==null&&(X=_.props.output.scrypt.timeScrypt(bt.parse("1reallyJunkiePasswordToCheck"),{salt_hex:o.base16.parse("b5865ffb9fa7b3bfe4b2384d47ce831ee22a4a9d5c34c7ef7d21467cc758f81b"),n:16384,r:8,p:1}).then(Ae=>Ae.time));const de=await X,Be=k0(P.random(32),de,se);return W(`snrp for ${se}ms target: ${Be.n} ${Be.r} ${Be.p} based on ${de}ms benchmark`),Be}return _.onOutput(ne),v.stopUpdates},timeScrypt:_=>()=>{const{io:P,log:W}=_.props,X=typeof window<"u"&&window.performance!=null&&typeof window.performance.now=="function"?()=>window.performance.now():()=>Date.now();function ne(se,de,Be=32){const Ae=de.salt_hex,Ue=X();return W(`starting scrypt n=${de.n} r=${de.r} p=${de.p}`),P.scrypt(se,Ae,de.n,de.r,de.p,Be).then($e=>{const nt=X()-Ue;return W(`finished scrypt n=${de.n} r=${de.r} p=${de.p} in ${nt}ms`),{hash:$e,time:nt}})}return _.onOutput(S0(ne)),v.stopUpdates}}),Wn=_=>_,I0=v.combinePixies({accounts:g0,context:M0,currency:E0,scrypt:_0}),A0=C.buildReducer({currencyWalletIds(_,P,W){if(W.accountIds.length===1){const ne=W.accountIds[0];return W.accounts[ne].activeWalletIds}const X=[];for(const ne of W.accountIds)X.push(...W.accounts[ne].activeWalletIds);return X},wallets:C.mapReducer(qc,_=>_.currency.currencyWalletIds)}),T0=new Uint8Array(0),P0=C.buildReducer({apiKey(_="",P){return P.type==="INIT"?P.payload.apiKey:_},appId(_="",P){return P.type==="INIT"?P.payload.appId:_},clientId(_=T0,P){return P.type==="INIT"?P.payload.clientId:_},deviceDescription(_=null,P){return P.type==="INIT"?P.payload.deviceDescription:_},localUsers:C.memoizeReducer(_=>_.login.appId,_=>_.login.stashes,(_,P)=>{const W=[];for(const X of P){const{lastLogin:ne,loginId:se,recovery2Key:de,username:Be}=X,Ae=Sn(X,nt=>nt.appId===_),Ue=Ae!=null&&(Ae.passwordAuthBox!=null||Ae.loginAuthBox!=null),$e=To(X,_);W.push({keyLoginEnabled:Ue,lastLogin:ne,loginId:gt.stringify(se),pinLoginEnabled:$e!=null,recovery2Key:de!=null?gt.stringify(de):void 0,username:Be,voucherId:Ae!=null?Ae.voucherId:void 0})}return W}),serverUri(_="",P){return P.type==="INIT"?P.payload.authServer:_},stashes(_=[],P){switch(P.type){case"INIT":return P.payload.stashes;case"LOGIN_STASH_DELETED":{const W=P.payload;return _.filter(X=>!Cr(X.loginId,W))}case"LOGIN_STASH_SAVED":{const W=P.payload,X=_.filter(ne=>!Cr(ne.loginId,W.loginId));return X.unshift(W),X}}return _},walletInfos(_,P,W){if(W.accountIds.length===1){const ne=W.accountIds[0];return W.accounts[ne].walletInfos}const X={};for(const ne of W.accountIds){const se=W.accounts[ne];for(const de of Object.keys(se.walletInfos)){const Be=se.walletInfos[de];X[de]=Be}}return X}}),O0={init:{},locked:!1,currency:{},swap:{},currencyTools:{}},B0=(_=O0,P)=>{switch(P.type){case"CORE_PLUGINS_ADDED":{const W={..._,currency:{..._.currency},swap:{..._.swap}};for(const X of Object.keys(P.payload)){const ne=P.payload[X];if(ne==null){W.init={...W.init,[X]:!1};continue}"currencyInfo"in ne&&(W.currency[X]=ne),"swapInfo"in ne&&(W.swap[X]=ne)}return W}case"CORE_PLUGINS_LOCKED":return{..._,locked:!0};case"CURRENCY_TOOLS_LOADED":{const W={..._.currencyTools};return W[P.payload.pluginId]=P.payload.tools,{..._,currencyTools:W}}case"INIT":return{..._,init:P.payload.pluginsInit}}return _},_l=A.combineReducers({lastChanges(_=[],P){if(P.type==="STORAGE_WALLET_SYNCED"){const{changes:W}=P.payload;return W.length>0?W:_}return _},localDisklet(_=null){return _},paths(_=null){return _},status(_={lastSync:0,lastHash:void 0},P){return P.type==="STORAGE_WALLET_SYNCED"?P.payload.status:_}}),R0=function(P={},W){switch(W.type){case"STORAGE_WALLET_ADDED":{const{id:X,initialState:ne}=W.payload,se={...P};return se[X]=_l(ne,{type:"UPDATE_NEXT"}),se}case"STORAGE_WALLET_SYNCED":{const{id:X}=W.payload;if(P[X]!=null){const ne={...P};return ne[X]=_l(P[X],W),ne}return P}}return P},Il={sources:{},defaultLogLevel:"warn"},C0=C.buildReducer({accountCount(_=0,P){return P.type==="LOGIN"?_+1:_},accountIds(_=[],P,W){switch(P.type){case"LOGIN":return[..._,W.lastAccountId];case"LOGOUT":{const{accountId:X}=P.payload,ne=_.filter(se=>se!==X);if(ne.length===_.length)throw new Error(`Login ${X} does not exist`);return ne}case"CLOSE":return[]}return _},accounts:C.mapReducer(p0,_=>_.accountIds),hideKeys(_=!0,P){return P.type==="INIT"?P.payload.hideKeys:_},infoCache(_={},P){switch(P.type){case"INIT":return P.payload.infoCache;case"INFO_CACHE_FETCHED":return P.payload}return _},infoServers(_=[],P){return P.type==="INIT"?P.payload.infoServers:_},lastAccountId(_,P,W){return`login${W.accountCount}`},logSettings(_=Il,P){switch(P.type){case"INIT":return P.payload.logSettings;case"CHANGE_LOG_SETTINGS":return P.payload}return _},paused(_=!1,P){return P.type==="PAUSE"?P.payload:_},ready(_=!1,P){return P.type==="INIT"?!0:_},skipBlockHeight(_=!1,P){return P.type==="INIT"?P.payload.skipBlockHeight:_},syncServers(_=[],P){return P.type==="INIT"?P.payload.syncServers:_},currency:A0,login:P0,plugins:B0,storageWallets:R0});let wf=[];const F0=typeof window=="object"&&window.__REDUX_DEVTOOLS_EXTENSION__!=null?window.__REDUX_DEVTOOLS_EXTENSION__({name:"core"}):void 0;async function Al(_,P,W){const{io:X}=_,{airbitzSupport:ne=!1,apiKey:se,appId:de="",authServer:Be="https://login.edge.app/api",deviceDescription:Ae=null,hideKeys:Ue=!1,infoServer:$e,plugins:nt={},skipBlockHeight:Ye=!1,syncServer:vt}=W,Et=typeof $e=="string"?[$e]:$e!=null&&$e.length>0?$e:["https://info-eu1.edge.app","https://info-us1.edge.app"],mt=typeof vt=="string"?[vt]:vt!=null&&vt.length>0?vt:["https://sync-us1.edge.app","https://sync-us2.edge.app","https://sync-us3.edge.app","https://sync-us4.edge.app","https://sync-us5.edge.app","https://sync-us6.edge.app","https://sync-eu.edge.app"],Mt={...Il,...W.logSettings};if(se==null)throw new Error("No API key provided");Tt(Be),Et.map(_r=>Tt(_r)),mt.map(_r=>Tt(_r));const Ot=A.createStore(C0,F0);P=Wo(P,()=>{const _r=Ot.getState();return _r.ready?_r.logSettings:Mt});const Vt=co(P,"edge-core");let[Zt,ir={},vr]=await Promise.all([rs.load(X.disklet,Qo),ea.load(X.disklet,ns),Yf(X.disklet,Vt)]);if(ne){const _r=new Set;for(const{username:Vr}of vr)Vr!=null&&_r.add(Vr);const Lr=await ru(X,_r);vr.push(...Lr)}Zt==null&&(Zt={clientId:X.random(16)},await rs.save(X.disklet,Qo,Zt)),Ot.dispatch({type:"INIT",payload:{apiKey:se,appId:de,authServer:Be,infoCache:ir,infoServers:Et,syncServers:mt,clientId:Zt.clientId,deviceDescription:Ae,hideKeys:Ue,logSettings:Mt,pluginsInit:nt,skipBlockHeight:Ye,stashes:vr}}),su(_,ir,P,nt,Ot.dispatch);const yr=d.makeSyncClient({log:Vt,fetch:X.fetch,edgeServers:{infoServers:Et,syncServers:mt}}),Pr={output:{}},kr=v.attachPixie(Ot,v.filterPixie(I0,_r=>({..._r,close(){kr(),Ot.dispatch({type:"CLOSE"})},io:X,log:Vt,logBackend:P,onError:Lr=>{var Vr;((Vr=Pr.output.context)==null?void 0:Vr.api)!=null&&y.emit(Pr.output.context.api,"error",Lr)},syncClient:yr})),_r=>Vt.error(_r),_r=>Pr.output=_r),Ar=Pr.output.context.api;return wf.push(Ar),Ar}function N0(){for(const _ of wf)_.close().catch(()=>{});wf=[]}class L0{constructor(){this.lobbies=new Map,this.logins=[],this.repos=new Map}getLoginById(P){return this.logins.find(W=>Cr(W.loginId,P))}getLoginByUserId(P){return this.logins.find(W=>W.userId==null?Cr(W.loginId,P):Cr(W.userId,P))}getLoginByPin2Id(P){return this.logins.find(W=>W.pin2Id!=null&&Cr(W.pin2Id,P))}getLoginByRecovery2Id(P){return this.logins.find(W=>W.recovery2Id!=null&&Cr(W.recovery2Id,P))}getLoginsByParent(P){return this.logins.filter(W=>W.parentId===P.loginId)}insertLogin(P){this.logins.push(P)}setupLogin(P){const{children:W,...X}=P;this.insertLogin(X);for(const ne of W)ne.parentId=P.loginId,this.setupLogin(ne)}setupRepo(P,W){this.repos.set(P,W)}dumpLogin(P){const W=X=>({...X,children:this.getLoginsByParent(X).map(ne=>W(ne))});return W(P)}}function Bo(_,P){const W=_.getLoginsByParent(P).map(X=>Bo(_,X));return{appId:P.appId,created:P.created,loginId:P.loginId,children:W,parentBox:P.parentBox,passwordAuthBox:P.passwordAuthBox,passwordAuthSnrp:P.passwordAuthSnrp,passwordBox:P.passwordBox,passwordKeySnrp:P.passwordKeySnrp,pin2Box:P.pin2Box,pin2KeyBox:P.pin2KeyBox,pin2TextBox:P.pin2TextBox,question2Box:P.question2Box,recovery2Box:P.recovery2Box,recovery2KeyBox:P.recovery2KeyBox,otpKey:P.otpKey,otpResetDate:P.otpResetDate,otpTimeout:P.otpTimeout,pendingVouchers:Tl(P),loginAuthBox:P.loginAuthBox,userId:P.userId,userTextBox:P.userTextBox,keyBoxes:P.keyBoxes,mnemonicBox:P.mnemonicBox,rootKeyBox:P.rootKeyBox,syncKeyBox:P.syncKeyBox}}function Tl(_){return _.vouchers.filter(P=>P.status==="pending").map(P=>({activates:P.activates,created:P.created,deviceDescription:P.deviceDescription,ip:P.ip,ipDescription:P.ipDescription,voucherId:P.voucherId}))}const Ir={success:{code:0,httpStatus:200,message:"Success"},error:{code:1,httpStatus:503,message:"Error"},accountExists:{code:2,httpStatus:401,message:"Account already exists"},noAccount:{code:3,httpStatus:401,message:"No account"},invalidPassword:{code:4,httpStatus:401,message:"Invalid Password"},invalidAnswers:{code:5,httpStatus:401,message:"Invalid Answers"},invalidApiKey:{code:6,httpStatus:401,message:"Invalid API Key"},invalidOtp:{code:8,httpStatus:401,message:"Invalid OTP"},conflict:{code:10,httpStatus:409,message:"Conflicting change"},obsolete:{code:1e3,httpStatus:410,message:"Obsolete API"},created:{code:0,httpStatus:201,message:"Account created"},invalidRequest:{code:1,httpStatus:401,message:"Invalid request"},notFound:{code:1,httpStatus:404,message:"Not found"},noLobby:{code:3,httpStatus:404,message:"Not found"},invalidAppId:{code:10,httpStatus:401,message:"A login with the same appId already exists"}};function ln(_,P){try{return[_(P),{status:200}]}catch(W){return[void 0,Er(Ir.invalidRequest,`Invalid request: ${String(W)}`)]}}function Zi(_,P={}){const{status:W=200,headers:X={}}=P;return{status:W,headers:{"content-type":"application/json",...X},body:JSON.stringify(_)}}function Er(_=Ir.success,P=_.message){const{code:W,httpStatus:X}=_,ne=Ee({status_code:W,message:P});return Zi(ne,{status:X})}function An(_,P=Ir.success,W=P.message){const{code:X,httpStatus:ne}=P,se=Ee({status_code:X,message:W,results:_});return Zi(se,{status:ne})}function D0(_,P={}){const{reason:W="otp",voucher:X}=P;return An(Qe({login_id:_.loginId,otp_reset_auth:_.otpResetAuth,otp_timeout_date:_.otpResetDate,reason:W,voucher_auth:X==null?void 0:X.voucherAuth,voucher_activates:X==null?void 0:X.activates,voucher_id:X==null?void 0:X.voucherId}),Ir.invalidOtp)}function Yi(_){return An(Oe({wait_seconds:_}),Ir.invalidPassword)}const Nr=_=>async P=>{const{json:W}=P,[X,ne]=ln(H,W);return X==null?ne:await _({...P,body:X,payload:X.data})},ka=_=>async P=>{const{body:W,login:X}=P,{otp:ne,voucherAuth:se,voucherId:de}=W,{otpKey:Be}=X;if(Be==null)return await _(P);if(ne!=null&&Qa(Be,ne,{spread:2}))return await _(P);if(se!=null&&de!=null){const Ue=X.vouchers.find($e=>$e.voucherId===de);if(Ue!=null&&Ue.status==="approved"&&Cr(se,Ue.voucherAuth))return await _(P)}X.otpResetAuth="Super secret reset token";const Ae={activates:new Date("2020-01-01T00:00:00Z"),created:new Date("2020-01-08T00:00:00Z"),deviceDescription:"A phone",ip:"localhost",ipDescription:"here",loginId:X.loginId,status:"pending",voucherAuth:Uint8Array.from([170,187]),voucherId:`voucher-${X.vouchers.length}`};return X.vouchers.push(Ae),D0(X,{voucher:Ae})},U0=_=>Er(Ir.invalidRequest),vn=(_,P=U0)=>W=>{const{db:X,body:ne}=W,{loginAuth:se,loginId:de,passwordAuth:Be,pin2Auth:Ae,pin2Id:Ue,recovery2Auth:$e,recovery2Id:nt,userId:Ye}=ne;if(de!=null&&se!=null){const vt=X.getLoginById(de);return vt==null?Er(Ir.noAccount):vt.loginAuth==null||!Cr(se,vt.loginAuth)?Yi(0):ka(_)({...W,login:vt})}if(Ye!=null&&Be!=null){const vt=X.getLoginByUserId(Ye);return vt==null?Er(Ir.noAccount):vt.passwordAuth==null||!Cr(Be,vt.passwordAuth)?Yi(0):ka(_)({...W,login:vt})}if(Ue!=null&&Ae!=null){const vt=X.getLoginByPin2Id(Ue);return vt==null?Er(Ir.noAccount):vt.pin2Auth==null||!Cr(Ae,vt.pin2Auth)?Yi(0):ka(_)({...W,login:vt})}if(nt!=null&&$e!=null){const vt=X.getLoginByRecovery2Id(nt);if(vt==null)return Er(Ir.noAccount);const Et=vt.recovery2Auth,mt=$e;if(Et==null||mt.length!==Et.length)return Yi(0);for(let Mt=0;Mt<mt.length;++Mt)if(!Cr(mt[Mt],Et[Mt]))return Yi(0);return ka(_)({...W,login:vt})}return P(W)},Pl=vn(_=>{const{db:P,login:W}=_;return An(at(Bo(P,W)))},_=>{const{db:P,json:W}=_,X=H(W),{userId:ne,passwordAuth:se,recovery2Id:de,recovery2Auth:Be}=X;if(ne!=null&&se==null){const Ae=P.getLoginByUserId(ne);if(Ae==null)return Er(Ir.noAccount);const{loginId:Ue,passwordAuthSnrp:$e=Qn}=Ae;return An(Ne({loginId:Ue,passwordAuthSnrp:$e}))}if(de!=null&&Be==null){const Ae=P.getLoginByRecovery2Id(de);if(Ae==null)return Er(Ir.noAccount);const{question2Box:Ue}=Ae;return Ue==null?Er(Ir.noAccount):An(ht({question2Box:Ue}))}return Er(Ir.invalidRequest)});function Ol(_,P){const{db:W,json:X}=_,ne=new Date,[se,de]=ln(H,X);if(se==null)return de;const[Be,Ae]=ln(Pe,se.data);if(Be==null)return Ae;const[Ue,$e]=ln(ce,se.data);if(Ue==null)return $e;if(W.getLoginById(Be.loginId)!=null)return Er(Ir.accountExists);const nt=l.asMaybe(ge,()=>({newSyncKeys:[],keyBoxes:[]}))(se.data);for(const vt of nt.newSyncKeys)W.repos.set(vt,{});const Ye={...Be,...Ue,created:ne,keyBoxes:nt.keyBoxes,vouchers:[],...l.asMaybe(ue)(se.data),...l.asMaybe(be)(se.data),...l.asMaybe(J)(se.data),...l.asMaybe(Ge)(se.data),...l.asMaybe(te)(se.data)};if(P!=null){if(W.getLoginsByParent(P).find(mt=>mt.appId===Be.appId)!=null)return Er(Ir.invalidAppId);Ye.parentId=P.loginId}return W.insertLogin(Ye),Er(Ir.created,"Account created")}const Bl=vn(_=>Ol(_,_.login),_=>Ol(_)),H0=vn(_=>{const{db:P,login:W,payload:X}=_,[ne,se]=ln(ge,X);if(ne==null)return se;for(const de of ne.newSyncKeys)P.repos.set(de,{});return W.keyBoxes=Jn(W.keyBoxes,ne.keyBoxes),Er()}),Rl=vn(_=>{const{login:P,payload:W}=_,[X,ne]=ln(ue,W);return X==null?ne:(P.otpKey=X.otpKey,P.otpTimeout=X.otpTimeout,P.otpResetDate=void 0,Er())}),z0=vn(_=>{const{login:P}=_;return P.otpKey=void 0,P.otpResetAuth=void 0,P.otpResetDate=void 0,P.otpTimeout=void 0,Er()},_=>{const{db:P,json:W}=_,X=H(W);if(X.userId==null||X.otpResetAuth==null)return Er(Ir.invalidRequest);const ne=P.getLoginByUserId(X.userId);if(ne==null)return Er(Ir.noAccount);if(X.otpResetAuth!==ne.otpResetAuth)return Yi(0);const{otpKey:se,otpTimeout:de}=ne;return se==null||de==null?Er(Ir.invalidRequest,"OTP not setup for this account."):(ne.otpResetDate==null&&(ne.otpResetDate=new Date(Date.now()+1e3*de)),An(xe({otpResetDate:ne.otpResetDate})))}),K0=vn(_=>{const{login:P}=_;return P.passwordAuth=void 0,P.passwordAuthBox=void 0,P.passwordAuthSnrp=void 0,P.passwordBox=void 0,P.passwordKeySnrp=void 0,Er()}),Cl=vn(_=>{const{login:P,payload:W}=_,[X,ne]=ln(be,W);return X==null?ne:(P.passwordAuth=X.passwordAuth,P.passwordAuthBox=X.passwordAuthBox,P.passwordAuthSnrp=X.passwordAuthSnrp,P.passwordBox=X.passwordBox,P.passwordKeySnrp=X.passwordKeySnrp,Er())}),j0=vn(_=>{const{login:P}=_;return P.pin2Auth=void 0,P.pin2Box=void 0,P.pin2Id=void 0,P.pin2KeyBox=void 0,P.pin2TextBox=void 0,Er()}),Fl=vn(_=>{const{login:P,payload:W}=_,[X,ne]=ln(J,W);return X==null?ne:(P.pin2Auth=X.pin2Auth,P.pin2Box=X.pin2Box,P.pin2Id=X.pin2Id,P.pin2KeyBox=X.pin2KeyBox,P.pin2TextBox=X.pin2TextBox,Er())}),W0=vn(_=>{const{login:P}=_;return P.question2Box=void 0,P.recovery2Auth=void 0,P.recovery2Box=void 0,P.recovery2Id=void 0,P.recovery2KeyBox=void 0,Er()}),xf=vn(_=>{const{login:P,payload:W}=_,[X,ne]=ln(Ge,W);return X==null?ne:(P.question2Box=X.question2Box,P.recovery2Auth=X.recovery2Auth,P.recovery2Box=X.recovery2Box,P.recovery2Id=X.recovery2Id,P.recovery2KeyBox=X.recovery2KeyBox,Er())}),Nl=vn(_=>{const{db:P,login:W,payload:X}=_,[ne,se]=ln(ce,X);return ne==null?se:W.loginAuth!=null?Er(Ir.conflict,"The secret-key login is already configured"):(W.loginAuth=ne.loginAuth,W.loginAuthBox=ne.loginAuthBox,An(at(Bo(P,W))))}),Ll=vn(async _=>{const{db:P,login:W,payload:X}=_,ne=l.asMaybe(be)(X),se=l.asMaybe(ie)(X),de=l.asMaybe(pe)(X),Be=l.asMaybe(te)(X);if(W.passwordAuth!=null&&ne==null)return Er(Ir.invalidRequest,"Missing password payload");if(W.pin2Auth!=null&&se==null)return Er(Ir.invalidRequest,"Missing pin2Id payload");if(W.recovery2Auth!=null&&de==null)return Er(Ir.invalidRequest,"Missing recovery2Id payload");if(W.parentBox==null&&Be==null)return Er(Ir.invalidRequest,"Missing username payload");if(ne!=null&&(W.passwordAuth=ne.passwordAuth,W.passwordAuthBox=ne.passwordAuthBox,W.passwordAuthSnrp=ne.passwordAuthSnrp,W.passwordBox=ne.passwordBox,W.passwordKeySnrp=ne.passwordKeySnrp),se!=null){if(W.pin2Auth==null)return Er(Ir.invalidRequest,"Login lacks pin2");if(P.getLoginByPin2Id(se.pin2Id)!=null)return Er(Ir.conflict);W.pin2Id=se.pin2Id}if(de!=null){if(W.recovery2Auth==null)return Er(Ir.invalidRequest,"Login lacks recovery2");if(P.getLoginByRecovery2Id(de.recovery2Id)!=null)return Er(Ir.conflict);W.recovery2Id=de.recovery2Id}if(Be!=null){if(W.parentBox!=null)return Er(Ir.invalidRequest,"Only top-level logins can have usernames");if(P.getLoginByUserId(Be.userId)!=null)return Er(Ir.conflict);W.userId=Be.userId,W.userTextBox=Be.userTextBox}return An(at(Bo(P,W)))}),Dl=vn(async _=>{const{db:P,login:W,payload:X}=_,[ne,se]=ln(le,X);if(ne==null)return se;const{approvedVouchers:de=[],rejectedVouchers:Be=[]}=ne,Ae={};for(const Ue of de)Ae[Ue]="approved";for(const Ue of Be)Ae[Ue]="rejected";for(const Ue of W.vouchers)Ae[Ue.voucherId]!=null&&(Ue.status=Ae[Ue.voucherId]);return An(at(Bo(P,W)))}),Gr=_=>Er(Ir.noLobby,`Cannot find lobby ${_.lobbyId}`),Ro=(_,P=Gr)=>W=>{const{db:X,path:ne}=W,se=ne.split("/")[4],de=X.lobbies.get(se);return de!=null?_({...W,lobby:de,lobbyId:se}):P({...W,lobbyId:se})},Ul=Ro(_=>Er(Ir.accountExists,`Lobby ${_.lobbyId} already exists.`),_=>{const{db:P,json:W,lobbyId:X}=_,[ne,se]=ln(H,W);if(ne==null)return se;const[de,Be]=ln(q,ne.data);if(de==null)return Be;const{timeout:Ae=600}=de,Ue=new Date(Date.now()+1e3*Ae).toISOString();return P.lobbies.set(X,{request:de,replies:[],expires:Ue}),Er()}),Hl=Ro(_=>{const{json:P,lobby:W}=_,[X,ne]=ln(H,P);if(X==null)return ne;const[se,de]=ln(re,X.data);return se==null?de:(W.replies.push(se),Er())}),Mf=Ro(_=>{const{lobby:P}=_;return An(rr(P))}),zl=Ro(_=>{const{db:P,lobbyId:W}=_;return P.lobbies.delete(W),Er()}),Kl=_=>{const{db:P,json:W}=_,[X,ne]=ln(H,W);if(X==null)return ne;const{loginIds:se}=X;if(se==null)return Er(Ir.invalidRequest);const de=[];for(const Be of se){const Ae=P.getLoginById(Be);Ae!=null&&de.push({loginId:Be,otpResetPending:Ae.otpResetDate!=null,pendingVouchers:Tl(Ae),recovery2Corrupt:!1})}return An(ft(de))},_a=_=>P=>{const{db:W,path:X}=P,se=X.split("/")[4],de=W.repos.get(se);return de==null?Zi({msg:"Hash not found"},{status:404}):_({...P,repo:de})},jl=_a(_=>{const{repo:P}=_;return Zi({changes:Gt(P)})}),Wl=_a(_=>{const{json:P,repo:W}=_,{changes:X}=Gl(P);for(const ne of Object.keys(X))W[ne]=X[ne];return Zi({changes:Gt(W),hash:"1111111111111111111111111111111111111111"})}),Gl=l.asObject({changes:l.asObject(F)}),ii=_=>Zi({infoServers:["https://info-fake1.edge.app"],syncServers:["https://sync-fake1.edge.app","https://sync-fake2.edge.app","https://sync-fake3.edge.app"]}),Sr=m.pickPath({"/api/v2/login/?":m.pickMethod({GET:Nr(Pl),POST:Nr(Pl)}),"/api/v2/login/create/?":m.pickMethod({POST:Nr(Bl),PUT:Nr(Bl)}),"/api/v2/login/keys/?":m.pickMethod({POST:Nr(H0)}),"/api/v2/login/otp/?":m.pickMethod({DELETE:Nr(z0),POST:Nr(Rl),PUT:Nr(Rl)}),"/api/v2/login/password/?":m.pickMethod({DELETE:Nr(K0),POST:Nr(Cl),PUT:Nr(Cl)}),"/api/v2/login/pin2/?":m.pickMethod({DELETE:Nr(j0),POST:Nr(Fl),PUT:Nr(Fl)}),"/api/v2/login/recovery2/?":m.pickMethod({DELETE:Nr(W0),POST:Nr(xf),PUT:Nr(xf)}),"/api/v2/login/secret/?":m.pickMethod({POST:Nr(Nl)}),"/api/v2/login/username/?":m.pickMethod({POST:Nr(Ll)}),"/api/v2/login/vouchers/?":m.pickMethod({POST:Nr(Dl)}),"/api/v2/messages/?":m.pickMethod({POST:Nr(Kl)}),"/api/v2/lobby/[^/]+/?":m.pickMethod({DELETE:Nr(zl),GET:Nr(Mf),POST:Nr(Hl),PUT:Nr(Ul)}),"/api/v2/store/[^/]+/?":m.pickMethod({GET:jl,POST:Wl}),"/v1/edgeServers":m.pickMethod({GET:ii})},_=>Er(Ir.notFound,`Unknown API endpoint ${_.path}`));function Ai(_){const W=Ko(X=>{if(W.offline)throw new Error("Fake network error");const ne=X.body.byteLength>0?JSON.parse(bt.stringify(new Uint8Array(X.body))):{};return Sr({...X,db:_,json:ne})},{offline:!1});return W}async function wn(_,P){const{lastLogin:W,server:X}=P,ne=o.base64.parse(P.loginId),se=o.base64.parse(P.loginKey),de=P.username==null?void 0:s(P.username),Be=Ei({appId:"",lastLogin:W,loginId:ne,pendingVouchers:[],username:de},se,kt(X)),Ae=`logins/${gt.stringify(ne)}.json`;await _.disklet.setText(Ae,JSON.stringify(Ja(Be))).catch(()=>{})}async function Vl(_,P,W){const X=Eo(_,{dataKey:new Uint8Array(0),syncKey:P});await ds(X.dataDisklet,W),await X.baseDisklet.setText("status.json",JSON.stringify({lastSync:1,lastHash:null}))}function ql(_,P,W){const{io:X,nativeIo:ne}=_,se=new L0,de=Ai(se);for(const Ue of W){se.setupLogin(Xe(Ue.server));for(const $e of Object.keys(Ue.repos))se.setupRepo($e,qe(Ue.repos[$e]))}const Be=[],Ae={async close(){await Promise.all(Be.map(Ue=>Ue.close())),y.close(Ae)},async makeEdgeContext(Ue){const{allowNetworkAccess:$e=!1,cleanDevice:nt=!1,extraFiles:Ye={}}=Ue,vt=m.makeFetchFunction(de),Et=$e?(Ot,Vt)=>{try{Tt(Ot)}catch{return X.fetch(Ot,Vt)}return vt(Ot,Vt)}:vt,mt={...X,disklet:p.makeMemoryDisklet(),fetch:Et};if(!nt)for(const Ot of W){await wn(mt,Ot);for(const Vt of Object.keys(Ot.repos))await Vl(mt,o.base16.parse(Vt),qe(Ot.repos[Vt]))}if(Ye!=null)for(const Ot of Object.keys(Ye))await mt.disklet.setText(Ot,Ye[Ot]);const Mt=await Al({io:mt,nativeIo:ne},P,{...Ue});return Be.push(Mt),Mt},async goOffline(Ue=!0){de.offline=Ue},async dumpFakeUser(Ue){if(Ue.appId!=="")throw new Error("Only root logins are dumpable.");const $e=gt.parse(Ue.rootLoginId),nt=gt.parse(await Ue.getLoginKey()),Ye=se.getLoginById($e);if(Ye==null)throw new Error(`Cannot find user ${Ue.rootLoginId}`);const vt=[];for(const mt of Ue.allKeys){const Mt=await Ue.getRawPrivateKey(mt.id);Mt.syncKey!=null&&vt.push(o.base16.stringify(o.base64.parse(Mt.syncKey)).toLowerCase())}const Et={};for(const mt of vt){const Mt=se.repos.get(mt);Mt!=null&&(Et[mt]=Gt(Mt))}return{lastLogin:Ue.lastLogin,loginId:o.base64.stringify($e),loginKey:o.base64.stringify(nt),repos:Et,server:ot(se.dumpLogin(Ye)),username:Ue.username}}};return y.bridgifyObject(Ae),Ae}const Ia=["allKeys","displayPrivateSeed","displayPublicSeed","keys","otpKey","loginKey","publicWalletInfo","recoveryKey"];function Aa(_){return{random(P){return Uint8Array.from(u.default.randomBytes(P))},scrypt:r,disklet:p.makeNodeDisklet(_),fetch:e.default,fetchCors:e.default}}function Xl(_){const{crashReporter:P,onLog:W=jo,path:X="./edge"}=_;return Al({io:Aa(X),nativeIo:{}},{crashReporter:P,onLog:W},_)}function Zl(_=[],P={}){const{crashReporter:W,onLog:X=jo}=P;return Promise.resolve(y.makeLocalBridge(ql({io:Aa("."),nativeIo:{}},{crashReporter:W,onLog:X},_),{cloneMessage:ne=>JSON.parse(JSON.stringify(ne)),hideProperties:Ia}))}x.WK=Ct,x.DE=Xt,x.k5=Yt,x.Dr=ar,x.ef=or,x.GY=sr,x.WM=$t,x.Kz=nr,x.uX=fr,x.IK=lr,x.gw=dr,x.WU=cr,x.G8=gr,x.xQ=pr,x.D7=dn,x.hi=Jr,x.mJ=au,x.zU=a,x.dq=w,x.m$=D,x.MU=lt,x.ID=ue,x.k0=be,x.D4=ie,x.kL=J,x.jx=pe,x.A_=Ge,x.v1=ce,x.TL=te,x.Og=le,x.ft=ge,x.KU=Pe,x.ZU=F,x.ye=re,x.Xj=q,x.Rn=Xe,x.bo=Z,x.KL=qe,x.rW=V,x.U3=Dt,x.$Y=Le,x.EJ=kt,x.XY=H,x.v7=oe,x.up=Mn,x.h=Kn,x.Cx=Xn,x.Zz=On,x.CU=zo,x.ib=ao,x.eT=di,x._0=Zn,x.UR=Bn,x.Up=so,x.y0=Yn,x.A2=pi,x.ql=$n,x.FX=fo,x.Jr=yn,x.zS=In,x.pK=ae,x.ud=he,x.Zk=je,x.Mf=Ie,x.U0=G,x.CX=Ce,x.l4=ut,x.gU=N0,x.M3=cs,x.Xv=Xl,x.vN=Zl,x.g_=f,x.BN=Aa,x.Jv=st,x.T0=rt,x.z8=Fe,x.Gt=He,x.Fm=yt,x.b4=Ke,x.N2=Ze,x.K8=At,x.gB=Ve,x.bd=tt,x.GG=qt,x.V$=et,x.CC=De,x.dT=ye,x.uT=we,x._j=ot,x.p4=Gt,x.W0=rr,x.zk=at,x.AB=ve,x.sn=Ee,x._u=ft,x.Py=Qe,x.iu=xe,x.l7=Oe,x.JU=ht,x.O6=Ne},5043:function(fe,x,T){"use strict";var S=this&&this.__importDefault||function(Q){return Q&&Q.__esModule?Q:{default:Q}};Object.defineProperty(x,"__esModule",{value:!0}),x.abs=x.toFixed=x.log10=x.max=x.min=x.eq=x.lte=x.gte=x.lt=x.gt=x.div=x.mul=x.sub=x.add=void 0;const y=S(T(4101));function p(Q){return!!(Q.startsWith("0x")||Q.startsWith("-0x")||Q.toLowerCase().includes("a")||Q.toLowerCase().includes("b")||Q.toLowerCase().includes("c")||Q.toLowerCase().includes("d")||Q.toLowerCase().includes("e")||Q.toLowerCase().includes("f"))}function I(Q){return Q.replace("0x","")}function o(Q,Y){let ee=Q;for(let u=0;u<Y;u++)ee+="0";return ee}function m(Q){let Y=Q.replace(/^0+/,"");return Y=Y.replace(/^\.+/,"0."),Y.includes(".")&&(Y=Y.replace(/0+$/,""),Y=Y.replace(/\.+$/,""),Y===""&&(Y="0")),Y===""&&(Y="0"),Y}function l(Q,Y){if(Y===0)return Q;let ee=!1;Q.slice(0,1)==="-"&&(ee=!0,Q=Q.slice(1));let u;return Y>Q.length?u="0."+o("",Y-Q.length)+Q:u=Q.substr(0,Q.length-Y)+"."+Q.substr(Q.length-Y,Q.length),u=m(u),ee&&(u=`-${u}`),u}function g(Q,Y,ee){let u=Q,e=Y;M(u,e);let r=u.indexOf("."),n=e.indexOf(".");const i=p(u),f=p(e);if(r!==-1&&(u=m(u),r=u.indexOf(".")),n!==-1&&(e=m(e),n=e.indexOf(".")),r!==-1||n!==-1||typeof ee=="number"){if(i||f)throw new Error("Cannot operate on base16 float values");let c=0,h=0;r!==-1&&(c=u.length-r-1),n!==-1&&(h=e.length-n-1);const s=c>h?c:h;let t=0;return typeof ee=="number"&&(t=ee),u=o(u.replace(".",""),s+t-c),e=o(e.replace(".",""),s-h),{x:u,y:e,shift:s}}else return{x:u,y:e,shift:0}}function M(...Q){for(const Y of Q){if(Y.split(".").length-1>1)throw new Error("Invalid number: more than one decimal point");if(Y.split("-").length-1>1)throw new Error("Invalid number: more than one negative sign")}}function E(Q,Y,ee=10){if(ee!==10&&ee!==16)throw new Error("Unsupported base");let{x:u,y:e,shift:r}=g(Q,Y);const n=p(u)?16:10,i=p(e)?16:10;u=I(u),e=I(e);const f=new y.default(u,n),c=new y.default(e,i);let h=f.add(c).toString(ee);return h=l(h,r),ee===10?h:"0x"+h}x.add=E;function d(Q,Y,ee=10){if(ee!==10&&ee!==16)throw new Error("Unsupported base");let{x:u,y:e,shift:r}=g(Q,Y);const n=p(u)?16:10,i=p(e)?16:10;u=I(u),e=I(e);const f=new y.default(u,n),c=new y.default(e,i);let h=f.mul(c).toString(ee);return h=l(h,r*2),ee===10?h:"0x"+h}x.mul=d;function A(Q,Y,ee=10){if(ee!==10&&ee!==16)throw new Error("Unsupported base");let{x:u,y:e,shift:r}=g(Q,Y);const n=p(u)?16:10,i=p(e)?16:10;u=I(u),e=I(e);const f=new y.default(u,n),c=new y.default(e,i);let h=f.sub(c).toString(ee);return h=l(h,r),ee===10?h:"0x"+h}x.sub=A;function v(Q,Y,ee=0,u=10){if(u!==10&&ee>0)throw new Error("Cannot operate on floating point hex values");if(u!==10&&u!==16)throw new Error("Unsupported base");let{x:e,y:r}=g(Q,Y,ee);const n=p(e)?16:10,i=p(r)?16:10;e=I(e),r=I(r);const f=new y.default(e,n),c=new y.default(r,i);let h=f.div(c).toString(u);return h=l(h,ee),u===10?h:"0x"+h}x.div=v;function b(Q,Y){let{x:ee,y:u}=g(Q,Y);const e=p(ee)?16:10,r=p(u)?16:10;ee=I(ee),u=I(u);const n=new y.default(ee,e),i=new y.default(u,r);return n.lt(i)}x.lt=b;function k(Q,Y){let{x:ee,y:u}=g(Q,Y);const e=p(ee)?16:10,r=p(u)?16:10;ee=I(ee),u=I(u);const n=new y.default(ee,e),i=new y.default(u,r);return n.lte(i)}x.lte=k;function B(Q,Y){let{x:ee,y:u}=g(Q,Y);const e=p(ee)?16:10,r=p(u)?16:10;ee=I(ee),u=I(u);const n=new y.default(ee,e),i=new y.default(u,r);return n.gt(i)}x.gt=B;function U(Q,Y){let{x:ee,y:u}=g(Q,Y);const e=p(ee)?16:10,r=p(u)?16:10;ee=I(ee),u=I(u);const n=new y.default(ee,e),i=new y.default(u,r);return n.gte(i)}x.gte=U;function C(Q,Y){let{x:ee,y:u}=g(Q,Y);const e=p(ee)?16:10,r=p(u)?16:10;ee=I(ee),u=I(u);const n=new y.default(ee,e),i=new y.default(u,r);return n.eq(i)}x.eq=C;function L(Q,Y,ee=10){let{x:u,y:e,shift:r}=g(Q,Y);const n=p(u)?16:10,i=p(e)?16:10;u=I(u),e=I(e);const f=new y.default(u,n),c=new y.default(e,i);let h;return f.lte(c)?h=f.toString(ee):h=c.toString(ee),h=l(h,r),ee===10?h:"0x"+h}x.min=L;function N(Q,Y=10){if(Y!==10&&Y!==16)throw new Error("Unsupported base");let{x:ee,shift:u}=g(Q,"0");const e=p(Q)?16:10;ee=I(ee);let n=new y.default(ee,e).abs().toString(Y);return n=l(n,u),Y===10?n:"0x"+n}x.abs=N;function j(Q,Y,ee=10){let{x:u,y:e,shift:r}=g(Q,Y);const n=p(u)?16:10,i=p(e)?16:10;u=I(u),e=I(e);const f=new y.default(u,n),c=new y.default(e,i);let h;return f.gte(c)?h=f.toString(ee):h=c.toString(ee),h=l(h,r),ee===10?h:"0x"+h}x.max=j;function K(Q,Y=2,ee=8){M(Q);let u=!1,e="",r=Q;r.includes("-")&&(u=!0,r=r.replace(/^-+/,"")),r=m(r);const n=r.indexOf(".");if(n===-1)e=r+"."+o("",Y);else{const i=r.length-n-1;i>ee?e=r.substr(0,r.length-(i-ee)):i<Y?e=r+o("",Y-i):e=r}return e=e.replace(/\.+$/,""),u&&(e="-"+e),e}x.toFixed=K;function $(Q){if(Q.match(/^[0-1]+$/g)===null)throw new Error("InvalidLogInputValue: Must be a power of 10");if(!Q.startsWith("1"))throw new Error("InvalidLogInputValue: Must not have leading zeros");if((Q.match(/1/g)||[]).length>1)throw new Error("InvalidLogInputValue: Must be power of 10.");return(Q.match(/0/g)||[]).length}x.log10=$},4101:function(fe,x,T){fe=T.nmd(fe),function(S,y){"use strict";function p(u,e){if(!u)throw new Error(e||"Assertion failed")}function I(u,e){u.super_=e;var r=function(){};r.prototype=e.prototype,u.prototype=new r,u.prototype.constructor=u}function o(u,e,r){if(o.isBN(u))return u;this.negative=0,this.words=null,this.length=0,this.red=null,u!==null&&((e==="le"||e==="be")&&(r=e,e=10),this._init(u||0,e||10,r||"be"))}typeof S=="object"?S.exports=o:y.BN=o,o.BN=o,o.wordSize=26;var m;try{typeof window<"u"&&typeof window.Buffer<"u"?m=window.Buffer:m=T(2689).Buffer}catch{}o.isBN=function(e){return e instanceof o?!0:e!==null&&typeof e=="object"&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,r){return e.cmp(r)>0?e:r},o.min=function(e,r){return e.cmp(r)<0?e:r},o.prototype._init=function(e,r,n){if(typeof e=="number")return this._initNumber(e,r,n);if(typeof e=="object")return this._initArray(e,r,n);r==="hex"&&(r=16),p(r===(r|0)&&r>=2&&r<=36),e=e.toString().replace(/\s+/g,"");var i=0;e[0]==="-"&&(i++,this.negative=1),i<e.length&&(r===16?this._parseHex(e,i,n):(this._parseBase(e,r,i),n==="le"&&this._initArray(this.toArray(),r,n)))},o.prototype._initNumber=function(e,r,n){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[e&67108863],this.length=1):e<4503599627370496?(this.words=[e&67108863,e/67108864&67108863],this.length=2):(p(e<9007199254740992),this.words=[e&67108863,e/67108864&67108863,1],this.length=3),n==="le"&&this._initArray(this.toArray(),r,n)},o.prototype._initArray=function(e,r,n){if(p(typeof e.length=="number"),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<this.length;i++)this.words[i]=0;var f,c,h=0;if(n==="be")for(i=e.length-1,f=0;i>=0;i-=3)c=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[f]|=c<<h&67108863,this.words[f+1]=c>>>26-h&67108863,h+=24,h>=26&&(h-=26,f++);else if(n==="le")for(i=0,f=0;i<e.length;i+=3)c=e[i]|e[i+1]<<8|e[i+2]<<16,this.words[f]|=c<<h&67108863,this.words[f+1]=c>>>26-h&67108863,h+=24,h>=26&&(h-=26,f++);return this.strip()};function l(u,e){var r=u.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function g(u,e,r){var n=l(u,r);return r-1>=e&&(n|=l(u,r-1)<<4),n}o.prototype._parseHex=function(e,r,n){this.length=Math.ceil((e.length-r)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var f=0,c=0,h;if(n==="be")for(i=e.length-1;i>=r;i-=2)h=g(e,r,i)<<f,this.words[c]|=h&67108863,f>=18?(f-=18,c+=1,this.words[c]|=h>>>26):f+=8;else{var s=e.length-r;for(i=s%2===0?r+1:r;i<e.length;i+=2)h=g(e,r,i)<<f,this.words[c]|=h&67108863,f>=18?(f-=18,c+=1,this.words[c]|=h>>>26):f+=8}this.strip()};function M(u,e,r,n){for(var i=0,f=Math.min(u.length,r),c=e;c<f;c++){var h=u.charCodeAt(c)-48;i*=n,h>=49?i+=h-49+10:h>=17?i+=h-17+10:i+=h}return i}o.prototype._parseBase=function(e,r,n){this.words=[0],this.length=1;for(var i=0,f=1;f<=67108863;f*=r)i++;i--,f=f/r|0;for(var c=e.length-n,h=c%i,s=Math.min(c,c-h)+n,t=0,a=n;a<s;a+=i)t=M(e,a,a+i,r),this.imuln(f),this.words[0]+t<67108864?this.words[0]+=t:this._iaddn(t);if(h!==0){var w=1;for(t=M(e,a,e.length,r),a=0;a<h;a++)w*=r;this.imuln(w),this.words[0]+t<67108864?this.words[0]+=t:this._iaddn(t)}this.strip()},o.prototype.copy=function(e){e.words=new Array(this.length);for(var r=0;r<this.length;r++)e.words[r]=this.words[r];e.length=this.length,e.negative=this.negative,e.red=this.red},o.prototype.clone=function(){var e=new o(null);return this.copy(e),e},o.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},o.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},o.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var E=["","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"],d=[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],A=[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];o.prototype.toString=function(e,r){e=e||10,r=r|0||1;var n;if(e===16||e==="hex"){n="";for(var i=0,f=0,c=0;c<this.length;c++){var h=this.words[c],s=((h<<i|f)&16777215).toString(16);f=h>>>24-i&16777215,f!==0||c!==this.length-1?n=E[6-s.length]+s+n:n=s+n,i+=2,i>=26&&(i-=26,c--)}for(f!==0&&(n=f.toString(16)+n);n.length%r!==0;)n="0"+n;return this.negative!==0&&(n="-"+n),n}if(e===(e|0)&&e>=2&&e<=36){var t=d[e],a=A[e];n="";var w=this.clone();for(w.negative=0;!w.isZero();){var D=w.modn(a).toString(e);w=w.idivn(a),w.isZero()?n=D+n:n=E[t-D.length]+D+n}for(this.isZero()&&(n="0"+n);n.length%r!==0;)n="0"+n;return this.negative!==0&&(n="-"+n),n}p(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return this.length===2?e+=this.words[1]*67108864:this.length===3&&this.words[2]===1?e+=4503599627370496+this.words[1]*67108864:this.length>2&&p(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,r){return p(typeof m<"u"),this.toArrayLike(m,e,r)},o.prototype.toArray=function(e,r){return this.toArrayLike(Array,e,r)},o.prototype.toArrayLike=function(e,r,n){var i=this.byteLength(),f=n||Math.max(1,i);p(i<=f,"byte array longer than desired length"),p(f>0,"Requested array length <= 0"),this.strip();var c=r==="le",h=new e(f),s,t,a=this.clone();if(c){for(t=0;!a.isZero();t++)s=a.andln(255),a.iushrn(8),h[t]=s;for(;t<f;t++)h[t]=0}else{for(t=0;t<f-i;t++)h[t]=0;for(t=0;!a.isZero();t++)s=a.andln(255),a.iushrn(8),h[f-t-1]=s}return h},Math.clz32?o.prototype._countBits=function(e){return 32-Math.clz32(e)}:o.prototype._countBits=function(e){var r=e,n=0;return r>=4096&&(n+=13,r>>>=13),r>=64&&(n+=7,r>>>=7),r>=8&&(n+=4,r>>>=4),r>=2&&(n+=2,r>>>=2),n+r},o.prototype._zeroBits=function(e){if(e===0)return 26;var r=e,n=0;return r&8191||(n+=13,r>>>=13),r&127||(n+=7,r>>>=7),r&15||(n+=4,r>>>=4),r&3||(n+=2,r>>>=2),r&1||n++,n},o.prototype.bitLength=function(){var e=this.words[this.length-1],r=this._countBits(e);return(this.length-1)*26+r};function v(u){for(var e=new Array(u.bitLength()),r=0;r<e.length;r++){var n=r/26|0,i=r%26;e[r]=(u.words[n]&1<<i)>>>i}return e}o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,r=0;r<this.length;r++){var n=this._zeroBits(this.words[r]);if(e+=n,n!==26)break}return e},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(e){return this.negative!==0?this.abs().inotn(e).iaddn(1):this.clone()},o.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return this.negative!==0},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]|e.words[r];return this.strip()},o.prototype.ior=function(e){return p((this.negative|e.negative)===0),this.iuor(e)},o.prototype.or=function(e){return this.length>e.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 r;this.length>e.length?r=e:r=this;for(var n=0;n<r.length;n++)this.words[n]=this.words[n]&e.words[n];return this.length=r.length,this.strip()},o.prototype.iand=function(e){return p((this.negative|e.negative)===0),this.iuand(e)},o.prototype.and=function(e){return this.length>e.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 r,n;this.length>e.length?(r=this,n=e):(r=e,n=this);for(var i=0;i<n.length;i++)this.words[i]=r.words[i]^n.words[i];if(this!==r)for(;i<r.length;i++)this.words[i]=r.words[i];return this.length=r.length,this.strip()},o.prototype.ixor=function(e){return p((this.negative|e.negative)===0),this.iuxor(e)},o.prototype.xor=function(e){return this.length>e.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){p(typeof e=="number"&&e>=0);var r=Math.ceil(e/26)|0,n=e%26;this._expand(r),n>0&&r--;for(var i=0;i<r;i++)this.words[i]=~this.words[i]&67108863;return n>0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,r){p(typeof e=="number"&&e>=0);var n=e/26|0,i=e%26;return this._expand(n+1),r?this.words[n]=this.words[n]|1<<i:this.words[n]=this.words[n]&~(1<<i),this.strip()},o.prototype.iadd=function(e){var r;if(this.negative!==0&&e.negative===0)return this.negative=0,r=this.isub(e),this.negative^=1,this._normSign();if(this.negative===0&&e.negative!==0)return e.negative=0,r=this.isub(e),e.negative=1,r._normSign();var n,i;this.length>e.length?(n=this,i=e):(n=e,i=this);for(var f=0,c=0;c<i.length;c++)r=(n.words[c]|0)+(i.words[c]|0)+f,this.words[c]=r&67108863,f=r>>>26;for(;f!==0&&c<n.length;c++)r=(n.words[c]|0)+f,this.words[c]=r&67108863,f=r>>>26;if(this.length=n.length,f!==0)this.words[this.length]=f,this.length++;else if(n!==this)for(;c<n.length;c++)this.words[c]=n.words[c];return this},o.prototype.add=function(e){var r;return e.negative!==0&&this.negative===0?(e.negative=0,r=this.sub(e),e.negative^=1,r):e.negative===0&&this.negative!==0?(this.negative=0,r=e.sub(this),this.negative=1,r):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(e.negative!==0){e.negative=0;var r=this.iadd(e);return e.negative=1,r._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var n=this.cmp(e);if(n===0)return this.negative=0,this.length=1,this.words[0]=0,this;var i,f;n>0?(i=this,f=e):(i=e,f=this);for(var c=0,h=0;h<f.length;h++)r=(i.words[h]|0)-(f.words[h]|0)+c,c=r>>26,this.words[h]=r&67108863;for(;c!==0&&h<i.length;h++)r=(i.words[h]|0)+c,c=r>>26,this.words[h]=r&67108863;if(c===0&&h<i.length&&i!==this)for(;h<i.length;h++)this.words[h]=i.words[h];return this.length=Math.max(this.length,h),i!==this&&(this.negative=1),this.strip()},o.prototype.sub=function(e){return this.clone().isub(e)};function b(u,e,r){r.negative=e.negative^u.negative;var n=u.length+e.length|0;r.length=n,n=n-1|0;var i=u.words[0]|0,f=e.words[0]|0,c=i*f,h=c&67108863,s=c/67108864|0;r.words[0]=h;for(var t=1;t<n;t++){for(var a=s>>>26,w=s&67108863,D=Math.min(t,e.length-1),Z=Math.max(0,t-u.length+1);Z<=D;Z++){var F=t-Z|0;i=u.words[F]|0,f=e.words[Z]|0,c=i*f+w,a+=c/67108864|0,w=c&67108863}r.words[t]=w|0,s=a|0}return s!==0?r.words[t]=s|0:r.length--,r.strip()}var k=function(e,r,n){var i=e.words,f=r.words,c=n.words,h=0,s,t,a,w=i[0]|0,D=w&8191,Z=w>>>13,F=i[1]|0,V=F&8191,q=F>>>13,re=i[2]|0,G=re&8191,H=re>>>13,oe=i[3]|0,ue=oe&8191,be=oe>>>13,ie=i[4]|0,J=ie&8191,pe=ie>>>13,Ge=i[5]|0,ce=Ge&8191,te=Ge>>>13,le=i[6]|0,ge=le&8191,Pe=le>>>13,lt=i[7]|0,Le=lt&8191,ze=lt>>>13,kt=i[8]|0,ae=kt&8191,he=kt>>>13,je=i[9]|0,Ie=je&8191,Ce=je>>>13,ut=f[0]|0,De=ut&8191,ye=ut>>>13,we=f[1]|0,ve=we&8191,Ee=we>>>13,rt=f[2]|0,Fe=rt&8191,He=rt>>>13,yt=f[3]|0,Ke=yt&8191,Ze=yt>>>13,At=f[4]|0,Ve=At&8191,tt=At>>>13,qt=f[5]|0,et=qt&8191,st=qt>>>13,rr=f[6]|0,at=rr&8191,ft=rr>>>13,Qe=f[7]|0,xe=Qe&8191,Oe=Qe>>>13,ht=f[8]|0,Ne=ht&8191,qe=ht>>>13,Dt=f[9]|0,Xe=Dt&8191,ot=Dt>>>13;n.negative=e.negative^r.negative,n.length=19,s=Math.imul(D,De),t=Math.imul(D,ye),t=t+Math.imul(Z,De)|0,a=Math.imul(Z,ye);var Gt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,s=Math.imul(V,De),t=Math.imul(V,ye),t=t+Math.imul(q,De)|0,a=Math.imul(q,ye),s=s+Math.imul(D,ve)|0,t=t+Math.imul(D,Ee)|0,t=t+Math.imul(Z,ve)|0,a=a+Math.imul(Z,Ee)|0;var xt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(xt>>>26)|0,xt&=67108863,s=Math.imul(G,De),t=Math.imul(G,ye),t=t+Math.imul(H,De)|0,a=Math.imul(H,ye),s=s+Math.imul(V,ve)|0,t=t+Math.imul(V,Ee)|0,t=t+Math.imul(q,ve)|0,a=a+Math.imul(q,Ee)|0,s=s+Math.imul(D,Fe)|0,t=t+Math.imul(D,He)|0,t=t+Math.imul(Z,Fe)|0,a=a+Math.imul(Z,He)|0;var gt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(gt>>>26)|0,gt&=67108863,s=Math.imul(ue,De),t=Math.imul(ue,ye),t=t+Math.imul(be,De)|0,a=Math.imul(be,ye),s=s+Math.imul(G,ve)|0,t=t+Math.imul(G,Ee)|0,t=t+Math.imul(H,ve)|0,a=a+Math.imul(H,Ee)|0,s=s+Math.imul(V,Fe)|0,t=t+Math.imul(V,He)|0,t=t+Math.imul(q,Fe)|0,a=a+Math.imul(q,He)|0,s=s+Math.imul(D,Ke)|0,t=t+Math.imul(D,Ze)|0,t=t+Math.imul(Z,Ke)|0,a=a+Math.imul(Z,Ze)|0;var bt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(bt>>>26)|0,bt&=67108863,s=Math.imul(J,De),t=Math.imul(J,ye),t=t+Math.imul(pe,De)|0,a=Math.imul(pe,ye),s=s+Math.imul(ue,ve)|0,t=t+Math.imul(ue,Ee)|0,t=t+Math.imul(be,ve)|0,a=a+Math.imul(be,Ee)|0,s=s+Math.imul(G,Fe)|0,t=t+Math.imul(G,He)|0,t=t+Math.imul(H,Fe)|0,a=a+Math.imul(H,He)|0,s=s+Math.imul(V,Ke)|0,t=t+Math.imul(V,Ze)|0,t=t+Math.imul(q,Ke)|0,a=a+Math.imul(q,Ze)|0,s=s+Math.imul(D,Ve)|0,t=t+Math.imul(D,tt)|0,t=t+Math.imul(Z,Ve)|0,a=a+Math.imul(Z,tt)|0;var Tt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,s=Math.imul(ce,De),t=Math.imul(ce,ye),t=t+Math.imul(te,De)|0,a=Math.imul(te,ye),s=s+Math.imul(J,ve)|0,t=t+Math.imul(J,Ee)|0,t=t+Math.imul(pe,ve)|0,a=a+Math.imul(pe,Ee)|0,s=s+Math.imul(ue,Fe)|0,t=t+Math.imul(ue,He)|0,t=t+Math.imul(be,Fe)|0,a=a+Math.imul(be,He)|0,s=s+Math.imul(G,Ke)|0,t=t+Math.imul(G,Ze)|0,t=t+Math.imul(H,Ke)|0,a=a+Math.imul(H,Ze)|0,s=s+Math.imul(V,Ve)|0,t=t+Math.imul(V,tt)|0,t=t+Math.imul(q,Ve)|0,a=a+Math.imul(q,tt)|0,s=s+Math.imul(D,et)|0,t=t+Math.imul(D,st)|0,t=t+Math.imul(Z,et)|0,a=a+Math.imul(Z,st)|0;var Ct=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,s=Math.imul(ge,De),t=Math.imul(ge,ye),t=t+Math.imul(Pe,De)|0,a=Math.imul(Pe,ye),s=s+Math.imul(ce,ve)|0,t=t+Math.imul(ce,Ee)|0,t=t+Math.imul(te,ve)|0,a=a+Math.imul(te,Ee)|0,s=s+Math.imul(J,Fe)|0,t=t+Math.imul(J,He)|0,t=t+Math.imul(pe,Fe)|0,a=a+Math.imul(pe,He)|0,s=s+Math.imul(ue,Ke)|0,t=t+Math.imul(ue,Ze)|0,t=t+Math.imul(be,Ke)|0,a=a+Math.imul(be,Ze)|0,s=s+Math.imul(G,Ve)|0,t=t+Math.imul(G,tt)|0,t=t+Math.imul(H,Ve)|0,a=a+Math.imul(H,tt)|0,s=s+Math.imul(V,et)|0,t=t+Math.imul(V,st)|0,t=t+Math.imul(q,et)|0,a=a+Math.imul(q,st)|0,s=s+Math.imul(D,at)|0,t=t+Math.imul(D,ft)|0,t=t+Math.imul(Z,at)|0,a=a+Math.imul(Z,ft)|0;var Xt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Xt>>>26)|0,Xt&=67108863,s=Math.imul(Le,De),t=Math.imul(Le,ye),t=t+Math.imul(ze,De)|0,a=Math.imul(ze,ye),s=s+Math.imul(ge,ve)|0,t=t+Math.imul(ge,Ee)|0,t=t+Math.imul(Pe,ve)|0,a=a+Math.imul(Pe,Ee)|0,s=s+Math.imul(ce,Fe)|0,t=t+Math.imul(ce,He)|0,t=t+Math.imul(te,Fe)|0,a=a+Math.imul(te,He)|0,s=s+Math.imul(J,Ke)|0,t=t+Math.imul(J,Ze)|0,t=t+Math.imul(pe,Ke)|0,a=a+Math.imul(pe,Ze)|0,s=s+Math.imul(ue,Ve)|0,t=t+Math.imul(ue,tt)|0,t=t+Math.imul(be,Ve)|0,a=a+Math.imul(be,tt)|0,s=s+Math.imul(G,et)|0,t=t+Math.imul(G,st)|0,t=t+Math.imul(H,et)|0,a=a+Math.imul(H,st)|0,s=s+Math.imul(V,at)|0,t=t+Math.imul(V,ft)|0,t=t+Math.imul(q,at)|0,a=a+Math.imul(q,ft)|0,s=s+Math.imul(D,xe)|0,t=t+Math.imul(D,Oe)|0,t=t+Math.imul(Z,xe)|0,a=a+Math.imul(Z,Oe)|0;var Yt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Yt>>>26)|0,Yt&=67108863,s=Math.imul(ae,De),t=Math.imul(ae,ye),t=t+Math.imul(he,De)|0,a=Math.imul(he,ye),s=s+Math.imul(Le,ve)|0,t=t+Math.imul(Le,Ee)|0,t=t+Math.imul(ze,ve)|0,a=a+Math.imul(ze,Ee)|0,s=s+Math.imul(ge,Fe)|0,t=t+Math.imul(ge,He)|0,t=t+Math.imul(Pe,Fe)|0,a=a+Math.imul(Pe,He)|0,s=s+Math.imul(ce,Ke)|0,t=t+Math.imul(ce,Ze)|0,t=t+Math.imul(te,Ke)|0,a=a+Math.imul(te,Ze)|0,s=s+Math.imul(J,Ve)|0,t=t+Math.imul(J,tt)|0,t=t+Math.imul(pe,Ve)|0,a=a+Math.imul(pe,tt)|0,s=s+Math.imul(ue,et)|0,t=t+Math.imul(ue,st)|0,t=t+Math.imul(be,et)|0,a=a+Math.imul(be,st)|0,s=s+Math.imul(G,at)|0,t=t+Math.imul(G,ft)|0,t=t+Math.imul(H,at)|0,a=a+Math.imul(H,ft)|0,s=s+Math.imul(V,xe)|0,t=t+Math.imul(V,Oe)|0,t=t+Math.imul(q,xe)|0,a=a+Math.imul(q,Oe)|0,s=s+Math.imul(D,Ne)|0,t=t+Math.imul(D,qe)|0,t=t+Math.imul(Z,Ne)|0,a=a+Math.imul(Z,qe)|0;var ar=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(ar>>>26)|0,ar&=67108863,s=Math.imul(Ie,De),t=Math.imul(Ie,ye),t=t+Math.imul(Ce,De)|0,a=Math.imul(Ce,ye),s=s+Math.imul(ae,ve)|0,t=t+Math.imul(ae,Ee)|0,t=t+Math.imul(he,ve)|0,a=a+Math.imul(he,Ee)|0,s=s+Math.imul(Le,Fe)|0,t=t+Math.imul(Le,He)|0,t=t+Math.imul(ze,Fe)|0,a=a+Math.imul(ze,He)|0,s=s+Math.imul(ge,Ke)|0,t=t+Math.imul(ge,Ze)|0,t=t+Math.imul(Pe,Ke)|0,a=a+Math.imul(Pe,Ze)|0,s=s+Math.imul(ce,Ve)|0,t=t+Math.imul(ce,tt)|0,t=t+Math.imul(te,Ve)|0,a=a+Math.imul(te,tt)|0,s=s+Math.imul(J,et)|0,t=t+Math.imul(J,st)|0,t=t+Math.imul(pe,et)|0,a=a+Math.imul(pe,st)|0,s=s+Math.imul(ue,at)|0,t=t+Math.imul(ue,ft)|0,t=t+Math.imul(be,at)|0,a=a+Math.imul(be,ft)|0,s=s+Math.imul(G,xe)|0,t=t+Math.imul(G,Oe)|0,t=t+Math.imul(H,xe)|0,a=a+Math.imul(H,Oe)|0,s=s+Math.imul(V,Ne)|0,t=t+Math.imul(V,qe)|0,t=t+Math.imul(q,Ne)|0,a=a+Math.imul(q,qe)|0,s=s+Math.imul(D,Xe)|0,t=t+Math.imul(D,ot)|0,t=t+Math.imul(Z,Xe)|0,a=a+Math.imul(Z,ot)|0;var or=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(or>>>26)|0,or&=67108863,s=Math.imul(Ie,ve),t=Math.imul(Ie,Ee),t=t+Math.imul(Ce,ve)|0,a=Math.imul(Ce,Ee),s=s+Math.imul(ae,Fe)|0,t=t+Math.imul(ae,He)|0,t=t+Math.imul(he,Fe)|0,a=a+Math.imul(he,He)|0,s=s+Math.imul(Le,Ke)|0,t=t+Math.imul(Le,Ze)|0,t=t+Math.imul(ze,Ke)|0,a=a+Math.imul(ze,Ze)|0,s=s+Math.imul(ge,Ve)|0,t=t+Math.imul(ge,tt)|0,t=t+Math.imul(Pe,Ve)|0,a=a+Math.imul(Pe,tt)|0,s=s+Math.imul(ce,et)|0,t=t+Math.imul(ce,st)|0,t=t+Math.imul(te,et)|0,a=a+Math.imul(te,st)|0,s=s+Math.imul(J,at)|0,t=t+Math.imul(J,ft)|0,t=t+Math.imul(pe,at)|0,a=a+Math.imul(pe,ft)|0,s=s+Math.imul(ue,xe)|0,t=t+Math.imul(ue,Oe)|0,t=t+Math.imul(be,xe)|0,a=a+Math.imul(be,Oe)|0,s=s+Math.imul(G,Ne)|0,t=t+Math.imul(G,qe)|0,t=t+Math.imul(H,Ne)|0,a=a+Math.imul(H,qe)|0,s=s+Math.imul(V,Xe)|0,t=t+Math.imul(V,ot)|0,t=t+Math.imul(q,Xe)|0,a=a+Math.imul(q,ot)|0;var sr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(sr>>>26)|0,sr&=67108863,s=Math.imul(Ie,Fe),t=Math.imul(Ie,He),t=t+Math.imul(Ce,Fe)|0,a=Math.imul(Ce,He),s=s+Math.imul(ae,Ke)|0,t=t+Math.imul(ae,Ze)|0,t=t+Math.imul(he,Ke)|0,a=a+Math.imul(he,Ze)|0,s=s+Math.imul(Le,Ve)|0,t=t+Math.imul(Le,tt)|0,t=t+Math.imul(ze,Ve)|0,a=a+Math.imul(ze,tt)|0,s=s+Math.imul(ge,et)|0,t=t+Math.imul(ge,st)|0,t=t+Math.imul(Pe,et)|0,a=a+Math.imul(Pe,st)|0,s=s+Math.imul(ce,at)|0,t=t+Math.imul(ce,ft)|0,t=t+Math.imul(te,at)|0,a=a+Math.imul(te,ft)|0,s=s+Math.imul(J,xe)|0,t=t+Math.imul(J,Oe)|0,t=t+Math.imul(pe,xe)|0,a=a+Math.imul(pe,Oe)|0,s=s+Math.imul(ue,Ne)|0,t=t+Math.imul(ue,qe)|0,t=t+Math.imul(be,Ne)|0,a=a+Math.imul(be,qe)|0,s=s+Math.imul(G,Xe)|0,t=t+Math.imul(G,ot)|0,t=t+Math.imul(H,Xe)|0,a=a+Math.imul(H,ot)|0;var $t=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+($t>>>26)|0,$t&=67108863,s=Math.imul(Ie,Ke),t=Math.imul(Ie,Ze),t=t+Math.imul(Ce,Ke)|0,a=Math.imul(Ce,Ze),s=s+Math.imul(ae,Ve)|0,t=t+Math.imul(ae,tt)|0,t=t+Math.imul(he,Ve)|0,a=a+Math.imul(he,tt)|0,s=s+Math.imul(Le,et)|0,t=t+Math.imul(Le,st)|0,t=t+Math.imul(ze,et)|0,a=a+Math.imul(ze,st)|0,s=s+Math.imul(ge,at)|0,t=t+Math.imul(ge,ft)|0,t=t+Math.imul(Pe,at)|0,a=a+Math.imul(Pe,ft)|0,s=s+Math.imul(ce,xe)|0,t=t+Math.imul(ce,Oe)|0,t=t+Math.imul(te,xe)|0,a=a+Math.imul(te,Oe)|0,s=s+Math.imul(J,Ne)|0,t=t+Math.imul(J,qe)|0,t=t+Math.imul(pe,Ne)|0,a=a+Math.imul(pe,qe)|0,s=s+Math.imul(ue,Xe)|0,t=t+Math.imul(ue,ot)|0,t=t+Math.imul(be,Xe)|0,a=a+Math.imul(be,ot)|0;var nr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(nr>>>26)|0,nr&=67108863,s=Math.imul(Ie,Ve),t=Math.imul(Ie,tt),t=t+Math.imul(Ce,Ve)|0,a=Math.imul(Ce,tt),s=s+Math.imul(ae,et)|0,t=t+Math.imul(ae,st)|0,t=t+Math.imul(he,et)|0,a=a+Math.imul(he,st)|0,s=s+Math.imul(Le,at)|0,t=t+Math.imul(Le,ft)|0,t=t+Math.imul(ze,at)|0,a=a+Math.imul(ze,ft)|0,s=s+Math.imul(ge,xe)|0,t=t+Math.imul(ge,Oe)|0,t=t+Math.imul(Pe,xe)|0,a=a+Math.imul(Pe,Oe)|0,s=s+Math.imul(ce,Ne)|0,t=t+Math.imul(ce,qe)|0,t=t+Math.imul(te,Ne)|0,a=a+Math.imul(te,qe)|0,s=s+Math.imul(J,Xe)|0,t=t+Math.imul(J,ot)|0,t=t+Math.imul(pe,Xe)|0,a=a+Math.imul(pe,ot)|0;var fr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(fr>>>26)|0,fr&=67108863,s=Math.imul(Ie,et),t=Math.imul(Ie,st),t=t+Math.imul(Ce,et)|0,a=Math.imul(Ce,st),s=s+Math.imul(ae,at)|0,t=t+Math.imul(ae,ft)|0,t=t+Math.imul(he,at)|0,a=a+Math.imul(he,ft)|0,s=s+Math.imul(Le,xe)|0,t=t+Math.imul(Le,Oe)|0,t=t+Math.imul(ze,xe)|0,a=a+Math.imul(ze,Oe)|0,s=s+Math.imul(ge,Ne)|0,t=t+Math.imul(ge,qe)|0,t=t+Math.imul(Pe,Ne)|0,a=a+Math.imul(Pe,qe)|0,s=s+Math.imul(ce,Xe)|0,t=t+Math.imul(ce,ot)|0,t=t+Math.imul(te,Xe)|0,a=a+Math.imul(te,ot)|0;var lr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(lr>>>26)|0,lr&=67108863,s=Math.imul(Ie,at),t=Math.imul(Ie,ft),t=t+Math.imul(Ce,at)|0,a=Math.imul(Ce,ft),s=s+Math.imul(ae,xe)|0,t=t+Math.imul(ae,Oe)|0,t=t+Math.imul(he,xe)|0,a=a+Math.imul(he,Oe)|0,s=s+Math.imul(Le,Ne)|0,t=t+Math.imul(Le,qe)|0,t=t+Math.imul(ze,Ne)|0,a=a+Math.imul(ze,qe)|0,s=s+Math.imul(ge,Xe)|0,t=t+Math.imul(ge,ot)|0,t=t+Math.imul(Pe,Xe)|0,a=a+Math.imul(Pe,ot)|0;var dr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(dr>>>26)|0,dr&=67108863,s=Math.imul(Ie,xe),t=Math.imul(Ie,Oe),t=t+Math.imul(Ce,xe)|0,a=Math.imul(Ce,Oe),s=s+Math.imul(ae,Ne)|0,t=t+Math.imul(ae,qe)|0,t=t+Math.imul(he,Ne)|0,a=a+Math.imul(he,qe)|0,s=s+Math.imul(Le,Xe)|0,t=t+Math.imul(Le,ot)|0,t=t+Math.imul(ze,Xe)|0,a=a+Math.imul(ze,ot)|0;var cr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(cr>>>26)|0,cr&=67108863,s=Math.imul(Ie,Ne),t=Math.imul(Ie,qe),t=t+Math.imul(Ce,Ne)|0,a=Math.imul(Ce,qe),s=s+Math.imul(ae,Xe)|0,t=t+Math.imul(ae,ot)|0,t=t+Math.imul(he,Xe)|0,a=a+Math.imul(he,ot)|0;var gr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(gr>>>26)|0,gr&=67108863,s=Math.imul(Ie,Xe),t=Math.imul(Ie,ot),t=t+Math.imul(Ce,Xe)|0,a=Math.imul(Ce,ot);var pr=(h+s|0)+((t&8191)<<13)|0;return h=(a+(t>>>13)|0)+(pr>>>26)|0,pr&=67108863,c[0]=Gt,c[1]=xt,c[2]=gt,c[3]=bt,c[4]=Tt,c[5]=Ct,c[6]=Xt,c[7]=Yt,c[8]=ar,c[9]=or,c[10]=sr,c[11]=$t,c[12]=nr,c[13]=fr,c[14]=lr,c[15]=dr,c[16]=cr,c[17]=gr,c[18]=pr,h!==0&&(c[19]=h,n.length++),n};Math.imul||(k=b);function B(u,e,r){r.negative=e.negative^u.negative,r.length=u.length+e.length;for(var n=0,i=0,f=0;f<r.length-1;f++){var c=i;i=0;for(var h=n&67108863,s=Math.min(f,e.length-1),t=Math.max(0,f-u.length+1);t<=s;t++){var a=f-t,w=u.words[a]|0,D=e.words[t]|0,Z=w*D,F=Z&67108863;c=c+(Z/67108864|0)|0,F=F+h|0,h=F&67108863,c=c+(F>>>26)|0,i+=c>>>26,c&=67108863}r.words[f]=h,n=c,c=i}return n!==0?r.words[f]=n:r.length--,r.strip()}function U(u,e,r){var n=new C;return n.mulp(u,e,r)}o.prototype.mulTo=function(e,r){var n,i=this.length+e.length;return this.length===10&&e.length===10?n=k(this,e,r):i<63?n=b(this,e,r):i<1024?n=B(this,e,r):n=U(this,e,r),n};function C(u,e){this.x=u,this.y=e}C.prototype.makeRBT=function(e){for(var r=new Array(e),n=o.prototype._countBits(e)-1,i=0;i<e;i++)r[i]=this.revBin(i,n,e);return r},C.prototype.revBin=function(e,r,n){if(e===0||e===n-1)return e;for(var i=0,f=0;f<r;f++)i|=(e&1)<<r-f-1,e>>=1;return i},C.prototype.permute=function(e,r,n,i,f,c){for(var h=0;h<c;h++)i[h]=r[e[h]],f[h]=n[e[h]]},C.prototype.transform=function(e,r,n,i,f,c){this.permute(c,e,r,n,i,f);for(var h=1;h<f;h<<=1)for(var s=h<<1,t=Math.cos(2*Math.PI/s),a=Math.sin(2*Math.PI/s),w=0;w<f;w+=s)for(var D=t,Z=a,F=0;F<h;F++){var V=n[w+F],q=i[w+F],re=n[w+F+h],G=i[w+F+h],H=D*re-Z*G;G=D*G+Z*re,re=H,n[w+F]=V+re,i[w+F]=q+G,n[w+F+h]=V-re,i[w+F+h]=q-G,F!==s&&(H=t*D-a*Z,Z=t*Z+a*D,D=H)}},C.prototype.guessLen13b=function(e,r){var n=Math.max(r,e)|1,i=n&1,f=0;for(n=n/2|0;n;n=n>>>1)f++;return 1<<f+1+i},C.prototype.conjugate=function(e,r,n){if(!(n<=1))for(var i=0;i<n/2;i++){var f=e[i];e[i]=e[n-i-1],e[n-i-1]=f,f=r[i],r[i]=-r[n-i-1],r[n-i-1]=-f}},C.prototype.normalize13b=function(e,r){for(var n=0,i=0;i<r/2;i++){var f=Math.round(e[2*i+1]/r)*8192+Math.round(e[2*i]/r)+n;e[i]=f&67108863,f<67108864?n=0:n=f/67108864|0}return e},C.prototype.convert13b=function(e,r,n,i){for(var f=0,c=0;c<r;c++)f=f+(e[c]|0),n[2*c]=f&8191,f=f>>>13,n[2*c+1]=f&8191,f=f>>>13;for(c=2*r;c<i;++c)n[c]=0;p(f===0),p((f&-8192)===0)},C.prototype.stub=function(e){for(var r=new Array(e),n=0;n<e;n++)r[n]=0;return r},C.prototype.mulp=function(e,r,n){var i=2*this.guessLen13b(e.length,r.length),f=this.makeRBT(i),c=this.stub(i),h=new Array(i),s=new Array(i),t=new Array(i),a=new Array(i),w=new Array(i),D=new Array(i),Z=n.words;Z.length=i,this.convert13b(e.words,e.length,h,i),this.convert13b(r.words,r.length,a,i),this.transform(h,c,s,t,i,f),this.transform(a,c,w,D,i,f);for(var F=0;F<i;F++){var V=s[F]*w[F]-t[F]*D[F];t[F]=s[F]*D[F]+t[F]*w[F],s[F]=V}return this.conjugate(s,t,i),this.transform(s,t,Z,c,i,f),this.conjugate(Z,c,i),this.normalize13b(Z,i),n.negative=e.negative^r.negative,n.length=e.length+r.length,n.strip()},o.prototype.mul=function(e){var r=new o(null);return r.words=new Array(this.length+e.length),this.mulTo(e,r)},o.prototype.mulf=function(e){var r=new o(null);return r.words=new Array(this.length+e.length),U(this,e,r)},o.prototype.imul=function(e){return this.clone().mulTo(e,this)},o.prototype.imuln=function(e){p(typeof e=="number"),p(e<67108864);for(var r=0,n=0;n<this.length;n++){var i=(this.words[n]|0)*e,f=(i&67108863)+(r&67108863);r>>=26,r+=i/67108864|0,r+=f>>>26,this.words[n]=f&67108863}return r!==0&&(this.words[n]=r,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 r=v(e);if(r.length===0)return new o(1);for(var n=this,i=0;i<r.length&&r[i]===0;i++,n=n.sqr());if(++i<r.length)for(var f=n.sqr();i<r.length;i++,f=f.sqr())r[i]!==0&&(n=n.mul(f));return n},o.prototype.iushln=function(e){p(typeof e=="number"&&e>=0);var r=e%26,n=(e-r)/26,i=67108863>>>26-r<<26-r,f;if(r!==0){var c=0;for(f=0;f<this.length;f++){var h=this.words[f]&i,s=(this.words[f]|0)-h<<r;this.words[f]=s|c,c=h>>>26-r}c&&(this.words[f]=c,this.length++)}if(n!==0){for(f=this.length-1;f>=0;f--)this.words[f+n]=this.words[f];for(f=0;f<n;f++)this.words[f]=0;this.length+=n}return this.strip()},o.prototype.ishln=function(e){return p(this.negative===0),this.iushln(e)},o.prototype.iushrn=function(e,r,n){p(typeof e=="number"&&e>=0);var i;r?i=(r-r%26)/26:i=0;var f=e%26,c=Math.min((e-f)/26,this.length),h=67108863^67108863>>>f<<f,s=n;if(i-=c,i=Math.max(0,i),s){for(var t=0;t<c;t++)s.words[t]=this.words[t];s.length=c}if(c!==0)if(this.length>c)for(this.length-=c,t=0;t<this.length;t++)this.words[t]=this.words[t+c];else this.words[0]=0,this.length=1;var a=0;for(t=this.length-1;t>=0&&(a!==0||t>=i);t--){var w=this.words[t]|0;this.words[t]=a<<26-f|w>>>f,a=w&h}return s&&a!==0&&(s.words[s.length++]=a),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,r,n){return p(this.negative===0),this.iushrn(e,r,n)},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){p(typeof e=="number"&&e>=0);var r=e%26,n=(e-r)/26,i=1<<r;if(this.length<=n)return!1;var f=this.words[n];return!!(f&i)},o.prototype.imaskn=function(e){p(typeof e=="number"&&e>=0);var r=e%26,n=(e-r)/26;if(p(this.negative===0,"imaskn works only with positive numbers"),this.length<=n)return this;if(r!==0&&n++,this.length=Math.min(n,this.length),r!==0){var i=67108863^67108863>>>r<<r;this.words[this.length-1]&=i}return this.strip()},o.prototype.maskn=function(e){return this.clone().imaskn(e)},o.prototype.iaddn=function(e){return p(typeof e=="number"),p(e<67108864),e<0?this.isubn(-e):this.negative!==0?this.length===1&&(this.words[0]|0)<e?(this.words[0]=e-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this):this._iaddn(e)},o.prototype._iaddn=function(e){this.words[0]+=e;for(var r=0;r<this.length&&this.words[r]>=67108864;r++)this.words[r]-=67108864,r===this.length-1?this.words[r+1]=1:this.words[r+1]++;return this.length=Math.max(this.length,r+1),this},o.prototype.isubn=function(e){if(p(typeof e=="number"),p(e<67108864),e<0)return this.iaddn(-e);if(this.negative!==0)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var r=0;r<this.length&&this.words[r]<0;r++)this.words[r]+=67108864,this.words[r+1]-=1;return this.strip()},o.prototype.addn=function(e){return this.clone().iaddn(e)},o.prototype.subn=function(e){return this.clone().isubn(e)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(e,r,n){var i=e.length+n,f;this._expand(i);var c,h=0;for(f=0;f<e.length;f++){c=(this.words[f+n]|0)+h;var s=(e.words[f]|0)*r;c-=s&67108863,h=(c>>26)-(s/67108864|0),this.words[f+n]=c&67108863}for(;f<this.length-n;f++)c=(this.words[f+n]|0)+h,h=c>>26,this.words[f+n]=c&67108863;if(h===0)return this.strip();for(p(h===-1),h=0,f=0;f<this.length;f++)c=-(this.words[f]|0)+h,h=c>>26,this.words[f]=c&67108863;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,r){var n=this.length-e.length,i=this.clone(),f=e,c=f.words[f.length-1]|0,h=this._countBits(c);n=26-h,n!==0&&(f=f.ushln(n),i.iushln(n),c=f.words[f.length-1]|0);var s=i.length-f.length,t;if(r!=="mod"){t=new o(null),t.length=s+1,t.words=new Array(t.length);for(var a=0;a<t.length;a++)t.words[a]=0}var w=i.clone()._ishlnsubmul(f,1,s);w.negative===0&&(i=w,t&&(t.words[s]=1));for(var D=s-1;D>=0;D--){var Z=(i.words[f.length+D]|0)*67108864+(i.words[f.length+D-1]|0);for(Z=Math.min(Z/c|0,67108863),i._ishlnsubmul(f,Z,D);i.negative!==0;)Z--,i.negative=0,i._ishlnsubmul(f,1,D),i.isZero()||(i.negative^=1);t&&(t.words[D]=Z)}return t&&t.strip(),i.strip(),r!=="div"&&n!==0&&i.iushrn(n),{div:t||null,mod:i}},o.prototype.divmod=function(e,r,n){if(p(!e.isZero()),this.isZero())return{div:new o(0),mod:new o(0)};var i,f,c;return this.negative!==0&&e.negative===0?(c=this.neg().divmod(e,r),r!=="mod"&&(i=c.div.neg()),r!=="div"&&(f=c.mod.neg(),n&&f.negative!==0&&f.iadd(e)),{div:i,mod:f}):this.negative===0&&e.negative!==0?(c=this.divmod(e.neg(),r),r!=="mod"&&(i=c.div.neg()),{div:i,mod:c.mod}):this.negative&e.negative?(c=this.neg().divmod(e.neg(),r),r!=="div"&&(f=c.mod.neg(),n&&f.negative!==0&&f.isub(e)),{div:c.div,mod:f}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:e.length===1?r==="div"?{div:this.divn(e.words[0]),mod:null}:r==="mod"?{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,r)},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 r=this.divmod(e);if(r.mod.isZero())return r.div;var n=r.div.negative!==0?r.mod.isub(e):r.mod,i=e.ushrn(1),f=e.andln(1),c=n.cmp(i);return c<0||f===1&&c===0?r.div:r.div.negative!==0?r.div.isubn(1):r.div.iaddn(1)},o.prototype.modn=function(e){p(e<=67108863);for(var r=(1<<26)%e,n=0,i=this.length-1;i>=0;i--)n=(r*n+(this.words[i]|0))%e;return n},o.prototype.idivn=function(e){p(e<=67108863);for(var r=0,n=this.length-1;n>=0;n--){var i=(this.words[n]|0)+r*67108864;this.words[n]=i/e|0,r=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){p(e.negative===0),p(!e.isZero());var r=this,n=e.clone();r.negative!==0?r=r.umod(e):r=r.clone();for(var i=new o(1),f=new o(0),c=new o(0),h=new o(1),s=0;r.isEven()&&n.isEven();)r.iushrn(1),n.iushrn(1),++s;for(var t=n.clone(),a=r.clone();!r.isZero();){for(var w=0,D=1;!(r.words[0]&D)&&w<26;++w,D<<=1);if(w>0)for(r.iushrn(w);w-- >0;)(i.isOdd()||f.isOdd())&&(i.iadd(t),f.isub(a)),i.iushrn(1),f.iushrn(1);for(var Z=0,F=1;!(n.words[0]&F)&&Z<26;++Z,F<<=1);if(Z>0)for(n.iushrn(Z);Z-- >0;)(c.isOdd()||h.isOdd())&&(c.iadd(t),h.isub(a)),c.iushrn(1),h.iushrn(1);r.cmp(n)>=0?(r.isub(n),i.isub(c),f.isub(h)):(n.isub(r),c.isub(i),h.isub(f))}return{a:c,b:h,gcd:n.iushln(s)}},o.prototype._invmp=function(e){p(e.negative===0),p(!e.isZero());var r=this,n=e.clone();r.negative!==0?r=r.umod(e):r=r.clone();for(var i=new o(1),f=new o(0),c=n.clone();r.cmpn(1)>0&&n.cmpn(1)>0;){for(var h=0,s=1;!(r.words[0]&s)&&h<26;++h,s<<=1);if(h>0)for(r.iushrn(h);h-- >0;)i.isOdd()&&i.iadd(c),i.iushrn(1);for(var t=0,a=1;!(n.words[0]&a)&&t<26;++t,a<<=1);if(t>0)for(n.iushrn(t);t-- >0;)f.isOdd()&&f.iadd(c),f.iushrn(1);r.cmp(n)>=0?(r.isub(n),i.isub(f)):(n.isub(r),f.isub(i))}var w;return r.cmpn(1)===0?w=i:w=f,w.cmpn(0)<0&&w.iadd(e),w},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var r=this.clone(),n=e.clone();r.negative=0,n.negative=0;for(var i=0;r.isEven()&&n.isEven();i++)r.iushrn(1),n.iushrn(1);do{for(;r.isEven();)r.iushrn(1);for(;n.isEven();)n.iushrn(1);var f=r.cmp(n);if(f<0){var c=r;r=n,n=c}else if(f===0||n.cmpn(1)===0)break;r.isub(n)}while(!0);return n.iushln(i)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return(this.words[0]&1)===0},o.prototype.isOdd=function(){return(this.words[0]&1)===1},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){p(typeof e=="number");var r=e%26,n=(e-r)/26,i=1<<r;if(this.length<=n)return this._expand(n+1),this.words[n]|=i,this;for(var f=i,c=n;f!==0&&c<this.length;c++){var h=this.words[c]|0;h+=f,f=h>>>26,h&=67108863,this.words[c]=h}return f!==0&&(this.words[c]=f,this.length++),this},o.prototype.isZero=function(){return this.length===1&&this.words[0]===0},o.prototype.cmpn=function(e){var r=e<0;if(this.negative!==0&&!r)return-1;if(this.negative===0&&r)return 1;this.strip();var n;if(this.length>1)n=1;else{r&&(e=-e),p(e<=67108863,"Number is too big");var i=this.words[0]|0;n=i===e?0:i<e?-1:1}return this.negative!==0?-n|0:n},o.prototype.cmp=function(e){if(this.negative!==0&&e.negative===0)return-1;if(this.negative===0&&e.negative!==0)return 1;var r=this.ucmp(e);return this.negative!==0?-r|0:r},o.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length<e.length)return-1;for(var r=0,n=this.length-1;n>=0;n--){var i=this.words[n]|0,f=e.words[n]|0;if(i!==f){i<f?r=-1:i>f&&(r=1);break}}return r},o.prototype.gtn=function(e){return this.cmpn(e)===1},o.prototype.gt=function(e){return this.cmp(e)===1},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 this.cmpn(e)===-1},o.prototype.lt=function(e){return this.cmp(e)===-1},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 this.cmpn(e)===0},o.prototype.eq=function(e){return this.cmp(e)===0},o.red=function(e){return new Y(e)},o.prototype.toRed=function(e){return p(!this.red,"Already a number in reduction context"),p(this.negative===0,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return p(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 p(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return p(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return p(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return p(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return p(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return p(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return p(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return p(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return p(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return p(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return p(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return p(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return p(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return p(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var L={k256:null,p224:null,p192:null,p25519:null};function N(u,e){this.name=u,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}N.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},N.prototype.ireduce=function(e){var r=e,n;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),n=r.bitLength();while(n>this.n);var i=n<this.n?-1:r.ucmp(this.p);return i===0?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):r.strip!==void 0?r.strip():r._strip(),r},N.prototype.split=function(e,r){e.iushrn(this.n,0,r)},N.prototype.imulK=function(e){return e.imul(this.k)};function j(){N.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}I(j,N),j.prototype.split=function(e,r){for(var n=4194303,i=Math.min(e.length,9),f=0;f<i;f++)r.words[f]=e.words[f];if(r.length=i,e.length<=9){e.words[0]=0,e.length=1;return}var c=e.words[9];for(r.words[r.length++]=c&n,f=10;f<e.length;f++){var h=e.words[f]|0;e.words[f-10]=(h&n)<<4|c>>>22,c=h}c>>>=22,e.words[f-10]=c,c===0&&e.length>10?e.length-=10:e.length-=9},j.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var r=0,n=0;n<e.length;n++){var i=e.words[n]|0;r+=i*977,e.words[n]=r&67108863,r=i*64+(r/67108864|0)}return e.words[e.length-1]===0&&(e.length--,e.words[e.length-1]===0&&e.length--),e};function K(){N.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}I(K,N);function $(){N.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}I($,N);function Q(){N.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}I(Q,N),Q.prototype.imulK=function(e){for(var r=0,n=0;n<e.length;n++){var i=(e.words[n]|0)*19+r,f=i&67108863;i>>>=26,e.words[n]=f,r=i}return r!==0&&(e.words[e.length++]=r),e},o._prime=function(e){if(L[e])return L[e];var r;if(e==="k256")r=new j;else if(e==="p224")r=new K;else if(e==="p192")r=new $;else if(e==="p25519")r=new Q;else throw new Error("Unknown prime "+e);return L[e]=r,r};function Y(u){if(typeof u=="string"){var e=o._prime(u);this.m=e.p,this.prime=e}else p(u.gtn(1),"modulus must be greater than 1"),this.m=u,this.prime=null}Y.prototype._verify1=function(e){p(e.negative===0,"red works only with positives"),p(e.red,"red works only with red numbers")},Y.prototype._verify2=function(e,r){p((e.negative|r.negative)===0,"red works only with positives"),p(e.red&&e.red===r.red,"red works only with red numbers")},Y.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},Y.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},Y.prototype.add=function(e,r){this._verify2(e,r);var n=e.add(r);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},Y.prototype.iadd=function(e,r){this._verify2(e,r);var n=e.iadd(r);return n.cmp(this.m)>=0&&n.isub(this.m),n},Y.prototype.sub=function(e,r){this._verify2(e,r);var n=e.sub(r);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},Y.prototype.isub=function(e,r){this._verify2(e,r);var n=e.isub(r);return n.cmpn(0)<0&&n.iadd(this.m),n},Y.prototype.shl=function(e,r){return this._verify1(e),this.imod(e.ushln(r))},Y.prototype.imul=function(e,r){return this._verify2(e,r),this.imod(e.imul(r))},Y.prototype.mul=function(e,r){return this._verify2(e,r),this.imod(e.mul(r))},Y.prototype.isqr=function(e){return this.imul(e,e.clone())},Y.prototype.sqr=function(e){return this.mul(e,e)},Y.prototype.sqrt=function(e){if(e.isZero())return e.clone();var r=this.m.andln(3);if(p(r%2===1),r===3){var n=this.m.add(new o(1)).iushrn(2);return this.pow(e,n)}for(var i=this.m.subn(1),f=0;!i.isZero()&&i.andln(1)===0;)f++,i.iushrn(1);p(!i.isZero());var c=new o(1).toRed(this),h=c.redNeg(),s=this.m.subn(1).iushrn(1),t=this.m.bitLength();for(t=new o(2*t*t).toRed(this);this.pow(t,s).cmp(h)!==0;)t.redIAdd(h);for(var a=this.pow(t,i),w=this.pow(e,i.addn(1).iushrn(1)),D=this.pow(e,i),Z=f;D.cmp(c)!==0;){for(var F=D,V=0;F.cmp(c)!==0;V++)F=F.redSqr();p(V<Z);var q=this.pow(a,new o(1).iushln(Z-V-1));w=w.redMul(q),a=q.redSqr(),D=D.redMul(a),Z=V}return w},Y.prototype.invm=function(e){var r=e._invmp(this.m);return r.negative!==0?(r.negative=0,this.imod(r).redNeg()):this.imod(r)},Y.prototype.pow=function(e,r){if(r.isZero())return new o(1).toRed(this);if(r.cmpn(1)===0)return e.clone();var n=4,i=new Array(1<<n);i[0]=new o(1).toRed(this),i[1]=e;for(var f=2;f<i.length;f++)i[f]=this.mul(i[f-1],e);var c=i[0],h=0,s=0,t=r.bitLength()%26;for(t===0&&(t=26),f=r.length-1;f>=0;f--){for(var a=r.words[f],w=t-1;w>=0;w--){var D=a>>w&1;if(c!==i[0]&&(c=this.sqr(c)),D===0&&h===0){s=0;continue}h<<=1,h|=D,s++,!(s!==n&&(f!==0||w!==0))&&(c=this.mul(c,i[h]),s=0,h=0)}t=26}return c},Y.prototype.convertTo=function(e){var r=e.umod(this.m);return r===e?r.clone():r},Y.prototype.convertFrom=function(e){var r=e.clone();return r.red=null,r},o.mont=function(e){return new ee(e)};function ee(u){Y.call(this,u),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)}I(ee,Y),ee.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},ee.prototype.convertFrom=function(e){var r=this.imod(e.mul(this.rinv));return r.red=null,r},ee.prototype.imul=function(e,r){if(e.isZero()||r.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(r),i=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),f=n.isub(i).iushrn(this.shift),c=f;return f.cmp(this.m)>=0?c=f.isub(this.m):f.cmpn(0)<0&&(c=f.iadd(this.m)),c._forceRed(this)},ee.prototype.mul=function(e,r){if(e.isZero()||r.isZero())return new o(0)._forceRed(this);var n=e.mul(r),i=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),f=n.isub(i).iushrn(this.shift),c=f;return f.cmp(this.m)>=0?c=f.isub(this.m):f.cmpn(0)<0&&(c=f.iadd(this.m)),c._forceRed(this)},ee.prototype.invm=function(e){var r=this.imod(e._invmp(this.m).mul(this.r2));return r._forceRed(this)}}(fe,this)},3812:(fe,x,T)=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});var S=T(6213);function y(F){throw new Error("makeNodeDisklet is not available on this platform")}function p(){throw new Error("makeReactNativeDisklet is not available on this platform")}function I(F,V,q,re,G,H,oe){try{var ue=F[H](oe),be=ue.value}catch(ie){q(ie);return}ue.done?V(be):Promise.resolve(be).then(re,G)}function o(F){return function(){var V=this,q=arguments;return new Promise(function(re,G){var H=F.apply(V,q);function oe(be){I(H,re,G,oe,ue,"next",be)}function ue(be){I(H,re,G,oe,ue,"throw",be)}oe(void 0)})}}function m(){return m=Object.assign||function(F){for(var V=1;V<arguments.length;V++){var q=arguments[V];for(var re in q)Object.prototype.hasOwnProperty.call(q,re)&&(F[re]=q[re])}return F},m.apply(this,arguments)}function l(F){if(/^\//.test(F))throw new Error("Absolute paths are not supported");for(var V=F.split("/"),q=0,re=0;q<V.length;){var G=V[q++];if(G===".."?re--:G!=="."&&G!==""&&(V[re++]=G),re<0)throw new Error("Path would escape folder")}return V.slice(0,re).join("/")}function g(F){return F===""?F:F+"/"}function M(F){for(var V=[],q=0;q<F.length;++q){var re=F.key(q);re!=null&&V.push(re)}return V}function E(F,V){F===void 0&&(F=window.localStorage),V===void 0&&(V={});var q=V.prefix!=null?g(V.prefix):"/";return{delete:function(G){var H=l(G);F.getItem(q+H)!=null&&F.removeItem(q+H);for(var oe=g(H),ue=0,be=M(F);ue<be.length;ue++){var ie=be[ue];ie.indexOf(q+oe)===0&&F.removeItem(ie)}return Promise.resolve()},getData:function(G){return this.getText(G).then(function(H){return S.base64.parse(H)})},getText:function(G){var H=l(G),oe=F.getItem(q+H);return oe==null?Promise.reject(new Error('Cannot load "'+H+'"')):Promise.resolve(oe)},list:function(G){return o(function*(){G===void 0&&(G="");var H=l(G),oe={};F.getItem(q+H)!=null&&(oe[H]="file");for(var ue=g(H),be=0,ie=M(F);be<ie.length;be++){var J=ie[be];if(J.indexOf(q+ue)===0){var pe=J.indexOf("/",q.length+ue.length);pe<0?oe[J.slice(q.length)]="file":oe[J.slice(q.length,pe)]="folder"}}return oe})()},setData:function(G,H){return this.setText(G,S.base64.stringify(H))},setText:function(G,H){return typeof H!="string"?Promise.reject(new TypeError("setText expects a string")):(F.setItem(q+l(G),H),Promise.resolve())}}}function d(F){return F===void 0&&(F={}),{delete:function(q){var re=l(q);F["/"+re]!=null&&delete F["/"+re];for(var G=g(re),H=0,oe=Object.keys(F);H<oe.length;H++){var ue=oe[H];ue.indexOf("/"+G)===0&&delete F[ue]}return Promise.resolve()},getData:function(q){var re=l(q),G=F["/"+re];return G==null?Promise.reject(new Error('Cannot load "'+re+'"')):typeof G=="string"?Promise.reject(new Error('"'+re+'" is a text file.')):Promise.resolve(G)},getText:function(q){var re=l(q),G=F["/"+re];return G==null?Promise.reject(new Error('Cannot load "'+re+'"')):typeof G!="string"?Promise.reject(new Error('"'+re+'" is a binary file.')):Promise.resolve(G)},list:function(q){return o(function*(){q===void 0&&(q="");var re=l(q),G={};F["/"+re]!=null&&(G[re]="file");for(var H=g(re),oe=0,ue=Object.keys(F);oe<ue.length;oe++){var be=ue[oe];if(be.indexOf("/"+H)===0){var ie=be.indexOf("/",1+H.length);ie<0?G[be.slice(1)]="file":G[be.slice(1,ie)]="folder"}}return G})()},setData:function(q,re){var G=re,H=Uint8Array.from(G);return F["/"+l(q)]=H,Promise.resolve()},setText:function(q,re){return typeof re!="string"?Promise.reject(new TypeError("setText expects a string")):(F["/"+l(q)]=re,Promise.resolve())}}}var A=function(){function F(q,re){this._disklet=q,this._path=re}var V=F.prototype;return V.delete=function(){return this._disklet.delete(this._path)},V.getData=function(){return this._disklet.getData(this._path)},V.getText=function(){return this._disklet.getText(this._path)},V.setData=function(re){return this._disklet.setData(this._path,re)},V.setText=function(re){return this._disklet.setText(this._path,re)},F}(),v=function(){function F(q,re){this._disklet=q,this._path=re}var V=F.prototype;return V.delete=function(){return this._disklet.delete(this._path)},V.file=function(re){return new A(this._disklet,this._path+"/"+re)},V.folder=function(re){return new F(this._disklet,this._path+"/"+re)},V.listFiles=function(){return this._disklet.list(this._path).then(function(re){return Object.keys(re).filter(function(G){return re[G]==="file"}).map(function(G){return G.replace(/^.*\//,"")})})},V.listFolders=function(){return this._disklet.list(this._path).then(function(re){return Object.keys(re).filter(function(G){return re[G]==="folder"}).map(function(G){return G.replace(/^.*\//,"")})})},F}();function b(F){return new v(F,".")}function k(F,V){for(var q=0,re=0;q<V.length;){var G=V[q++];if(G===".."?re--:G!=="."&&G!==""&&(V[re++]=G),re<0)throw new Error("Path would escape folder")}for(q=0;q<re;++q)F=F.folder(V[q]);return F}function B(F,V){var q=V.split("/"),re=q.pop();if(re==null)throw new Error("Empty path");return k(F,q).file(re)}function U(F,V){var q=V.split("/");return k(F,q)}function C(F,V){return F.listFiles().then(function(q){return Promise.all(q.map(function(re){return V(F.file(re),re,F)}))})}function L(F,V){return F.listFolders().then(function(q){return Promise.all(q.map(function(re){return V(F.folder(re),re,F)}))})}function N(F,V){function q(re,G,H){return Promise.all([C(re,function(oe,ue){return G(oe,H+ue,re)}),L(re,function(oe,ue){return q(oe,G,H+ue+"/")})]).then(function(oe){var ue=oe[0],be=oe[1];return ue.concat.apply(ue,be)})}return q(F,V,"")}function j(F,V){console.log(V+' "'+F+'"')}function K(F,V,q){var re=q.callback,G=re===void 0?j:re,H=q.verbose,oe=H===void 0?!1:H;(oe||/set|delete/.test(V))&&G(F,V)}var $=function(){function F(q,re,G){this._file=q,this._path=re,this._opts=G}var V=F.prototype;return V.delete=function(){return K(this._path,"delete file",this._opts),this._file.delete()},V.getData=function(){return K(this._path,"get data",this._opts),this._file.getData()},V.getText=function(){return K(this._path,"get text",this._opts),this._file.getText()},V.setData=function(re){return K(this._path,"set data",this._opts),this._file.setData(re)},V.setText=function(re){return K(this._path,"set text",this._opts),this._file.setText(re)},V.getPath=function(){return this._path},F}(),Q=function(){function F(q,re,G){this._folder=q,this._path=re,this._opts=G}var V=F.prototype;return V.delete=function(){return K(this._path,"delete folder",this._opts),this._folder.delete()},V.file=function(re){return new $(this._folder.file(re),this._path+re,this._opts)},V.folder=function(re){return new F(this._folder.folder(re),this._path+re+"/",this._opts)},V.listFiles=function(){return K(this._path,"list files",this._opts),this._folder.listFiles()},V.listFolders=function(){return K(this._path,"list folders",this._opts),this._folder.listFolders()},F}();function Y(F,V){return V===void 0&&(V={}),new Q(F,"",V)}function ee(F,V){var q={},re=[];return F.forEach(function(G){/\._x_$/.test(G)?q[G]=!0:(q[G+"._x_"]=!0,re.push(G))}),V.forEach(function(G){q[G+"._x_"]||re.push(G)}),re}var u=function(){function F(q,re,G){this._master=q,this._fallback=re,this._whiteout=G}var V=F.prototype;return V.delete=function(){return Promise.all([this._whiteout.setData([]),this._master.delete().catch(function(re){return null})])},V.getData=function(){var re=this;return this._master.getData().catch(function(G){return re._whiteout.getData().then(function(H){throw new Error("File has been deleted")},function(H){return re._fallback.getData()})})},V.getText=function(){var re=this;return this._master.getText().catch(function(G){return re._whiteout.getData().then(function(H){throw new Error("File has been deleted")},function(H){return re._fallback.getText()})})},V.setData=function(re){return this._master.setData(re)},V.setText=function(re){return this._master.setText(re)},V.getPath=function(){throw new Error("Cannot call getPath on a Union Folder")},F}(),e=function(){function F(q,re){this._master=q,this._fallback=re}var V=F.prototype;return V.delete=function(){return Promise.all([C(this,function(re){return re.delete()}),L(this,function(re){return re.delete()})]).then(function(){})},V.file=function(re){return new u(this._master.file(re),this._fallback.file(re),this._master.file(re+"._x_"))},V.folder=function(re){return new F(this._master.folder(re),this._fallback.folder(re))},V.listFiles=function(){return Promise.all([this._master.listFiles(),this._fallback.listFiles()]).then(function(re){return ee(re[0],re[1])})},V.listFolders=function(){return Promise.all([this._master.listFolders(),this._fallback.listFolders()]).then(function(re){return ee(re[0],re[1])})},F}();function r(F,V){return new e(F,V)}function n(F,V){var q=g(l(V));return{delete:function(G){return F.delete(q+G)},getData:function(G){return F.getData(q+G)},getText:function(G){return F.getText(q+G)},list:function(G){return G===void 0&&(G="."),F.list(q+G).then(function(H){var oe={};for(var ue in H)oe[ue.replace(q,"")]=H[ue];return oe})},setData:function(G,H){return F.setData(q+G,H)},setText:function(G,H){return F.setText(q+G,H)}}}function i(F){var V={};return F.list().then(function(q){return Promise.all(Object.keys(q).map(function(re){var G=q[re];return G==="folder"?i(n(F,re)).then(function(H){V[re]=H}):F.getText(re).then(function(H){V[re]=JSON.parse(H)})})).then(function(){return V})})}function f(F,V){return F.list(V).then(function(q){return Promise.all(Object.keys(q).filter(function(re){return q[re]==="folder"}).map(function(re){return f(F,re)})).then(function(re){return m.apply(void 0,[q].concat(re))})})}function c(F){return Object.keys(F).filter(function(V){return F[V]==="file"})}function h(F){return Object.keys(F).filter(function(V){return F[V]==="folder"})}function s(F,V){V===void 0&&(V={});var q=V,re=q.callback,G=re===void 0?function(be,ie){console.log(ie+' "'+be+'"')}:re,H=q.verbose,oe=H===void 0?!1:H,ue=function(ie,J){(oe||/set|delete/.test(ie))&&G(J,ie)};return{delete:function(ie){return ue("delete",l(ie)),F.delete(ie)},getData:function(ie){return ue("get data",l(ie)),F.getData(ie)},getText:function(ie){return ue("get text",l(ie)),F.getText(ie)},list:function(ie){return ue("list",ie!=null?l(ie):""),F.list(ie)},setData:function(ie,J){return ue("set data",l(ie)),F.setData(ie,J)},setText:function(ie,J){return ue("set text",l(ie)),F.setText(ie,J)}}}function t(F,V){return{delete:function(re){return Promise.all([F.delete(re),V.delete(re)])},getData:function(re){return F.getData(re).catch(function(G){return V.getData(re)})},getText:function(re){return F.getText(re).catch(function(G){return V.getText(re)})},list:function(re){return Promise.all([F.list(re),V.list(re)]).then(function(G){var H=G[0],oe=G[1];return m(oe,H)})},setData:function(re,G){return F.setData(re,G)},setText:function(re,G){return F.setText(re,G)}}}function a(F,V){return b(E(F,V))}function w(F){return b(d(F))}function D(F){return b(y())}function Z(){return b(p())}x.deepList=f,x.downgradeDisklet=b,x.dumpData=i,x.justFiles=c,x.justFolders=h,x.locateFile=B,x.locateFolder=U,x.logDisklet=s,x.makeLocalStorageDisklet=E,x.makeLocalStorageFolder=a,x.makeLoggedFolder=Y,x.makeMemoryDisklet=d,x.makeMemoryFolder=w,x.makeNodeDisklet=y,x.makeNodeFolder=D,x.makeReactNativeDisklet=p,x.makeReactNativeFolder=Z,x.makeUnionFolder=r,x.mapAllFiles=N,x.mapFiles=C,x.mapFolders=L,x.mergeDisklets=t,x.navigateDisklet=n},6213:(fe,x)=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});function T(v,b,k){var B;if(k===void 0&&(k={}),!b.codes){b.codes={};for(var U=0;U<b.chars.length;++U)b.codes[b.chars[U]]=U}if(!k.loose&&v.length*b.bits&7)throw new SyntaxError("Invalid padding");for(var C=v.length;v[C-1]==="=";)if(--C,!k.loose&&!((v.length-C)*b.bits&7))throw new SyntaxError("Invalid padding");for(var L=new((B=k.out)!=null?B:Uint8Array)(C*b.bits/8|0),N=0,j=0,K=0,$=0;$<C;++$){var Q=b.codes[v[$]];if(Q===void 0)throw new SyntaxError("Invalid character "+v[$]);j=j<<b.bits|Q,N+=b.bits,N>=8&&(N-=8,L[K++]=255&j>>N)}if(N>=b.bits||255&j<<8-N)throw new SyntaxError("Unexpected end of data");return L}function S(v,b,k){k===void 0&&(k={});for(var B=k,U=B.pad,C=U===void 0?!0:U,L=(1<<b.bits)-1,N="",j=0,K=0,$=0;$<v.length;++$)for(K=K<<8|255&v[$],j+=8;j>b.bits;)j-=b.bits,N+=b.chars[L&K>>j];if(j&&(N+=b.chars[L&K<<b.bits-j]),C)for(;N.length*b.bits&7;)N+="=";return N}var y={chars:"0123456789ABCDEF",bits:4},p={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bits:5},I={chars:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bits:5},o={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bits:6},m={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bits:6},l={parse:function(b,k){return T(b.toUpperCase(),y,k)},stringify:function(b,k){return S(b,y,k)}},g={parse:function(b,k){return k===void 0&&(k={}),T(k.loose?b.toUpperCase().replace(/0/g,"O").replace(/1/g,"L").replace(/8/g,"B"):b,p,k)},stringify:function(b,k){return S(b,p,k)}},M={parse:function(b,k){return T(b,I,k)},stringify:function(b,k){return S(b,I,k)}},E={parse:function(b,k){return T(b,o,k)},stringify:function(b,k){return S(b,o,k)}},d={parse:function(b,k){return T(b,m,k)},stringify:function(b,k){return S(b,m,k)}},A={parse:T,stringify:S};x.base16=l,x.base32=g,x.base32hex=M,x.base64=E,x.base64url=d,x.codec=A},3689:(fe,x,T)=>{"use strict";var S;S={value:!0};var y=T(9977),p=T(9796);const I=y.asCodec(xt=>p.base16.parse(y.asString(xt)),xt=>p.base16.stringify(xt).toLowerCase()),o=y.asCodec(xt=>p.base32.parse(y.asString(xt),{loose:!0}),xt=>p.base32.stringify(xt,{pad:!1})),m=y.asCodec(xt=>p.base64.parse(y.asString(xt)),xt=>p.base64.stringify(xt)),l=y.asObject({voucherId:y.asString,activates:y.asDate,created:y.asDate,ip:y.asString,ipDescription:y.asString,deviceDescription:y.asOptional(y.asString)}),g=y.asObject({encryptionType:y.asNumber,data_base64:m,iv_hex:I}),M=y.asObject({salt_hex:I,n:y.asNumber,r:y.asNumber,p:y.asNumber}),E=y.asObject({loginRequest:y.asOptional(y.asObject({appId:y.asString}).withRest),publicKey:m,timeout:y.asOptional(y.asNumber)}).withRest,d=y.asObject({publicKey:m,box:g}),A=y.asArray(m),v=y.asObject({data:y.asUnknown,challengeId:y.asOptional(y.asString),deviceDescription:y.asOptional(y.asString),otp:y.asOptional(y.asString),syncToken:y.asOptional(y.asString),voucherId:y.asOptional(y.asString),voucherAuth:y.asOptional(m),loginId:y.asOptional(m),loginAuth:y.asOptional(m),userId:y.asOptional(m),passwordAuth:y.asOptional(m),pin2Id:y.asOptional(m),pin2Auth:y.asOptional(m),recovery2Id:y.asOptional(m),recovery2Auth:y.asOptional(A),loginIds:y.asOptional(y.asArray(m)),otpResetAuth:y.asOptional(y.asString),did:y.asOptional(y.asString),l1:y.asOptional(m),lp1:y.asOptional(m),lpin1:y.asOptional(m),lra1:y.asOptional(m),recoveryAuth:y.asOptional(m)}),b=y.asObject({results:y.asOptional(y.asUnknown),status_code:y.asNumber,message:y.asString}),k=y.asObject({otpTimeout:y.asOptional(y.asNumber,7*24*60*60),otpKey:o}),B=y.asObject({passwordAuth:m,passwordAuthBox:g,passwordAuthSnrp:M,passwordBox:g,passwordKeySnrp:M}),U=y.asObject({pin2Id:m}),C=y.asObject({pin2Id:y.asOptional(m),pin2Auth:y.asOptional(m),pin2Box:y.asOptional(g),pin2KeyBox:y.asOptional(g),pin2TextBox:g}),L=y.asObject({recovery2Id:m}),N=y.asObject({recovery2Id:m,recovery2Auth:A,recovery2Box:g,recovery2KeyBox:g,question2Box:g}),j=y.asObject({loginAuthBox:g,loginAuth:m}),K=y.asObject({userId:m,userTextBox:g}),$=y.asObject({approvedVouchers:y.asOptional(y.asArray(y.asString)),rejectedVouchers:y.asOptional(y.asArray(y.asString))}),Q=y.asObject({keyBoxes:y.asArray(g),newSyncKeys:y.asOptional(y.asArray(y.asString),()=>[])}),Y=y.asObject({appId:y.asString,loginId:m,parentBox:y.asOptional(g)}),ee=y.asObject({challengeId:y.asString,challengeUri:y.asString}),u=y.asObject({request:E,replies:y.asArray(d)}),e=y.asValue(!0),r=y.asObject({appId:y.asString,created:y.asDate,loginId:m,syncToken:y.asOptional(y.asString),children:y.asOptional(y.asArray(xt=>r(xt))),parentBox:y.asOptional(g),otpKey:y.asOptional(y.asEither(e,o)),otpResetDate:y.asOptional(y.asDate),otpTimeout:y.asOptional(y.asNumber),passwordAuthBox:y.asOptional(g),passwordAuthSnrp:y.asOptional(M),passwordBox:y.asOptional(y.asEither(e,g)),passwordKeySnrp:y.asOptional(M),pin2Box:y.asOptional(y.asEither(e,g)),pin2KeyBox:y.asOptional(g),pin2TextBox:y.asOptional(g),question2Box:y.asOptional(g),recovery2Box:y.asOptional(y.asEither(e,g)),recovery2KeyBox:y.asOptional(g),loginAuthBox:y.asOptional(g),userId:y.asOptional(m),userTextBox:y.asOptional(g),pendingVouchers:y.asOptional(y.asArray(l),()=>[]),keyBoxes:y.asOptional(y.asArray(g)),mnemonicBox:y.asOptional(g),rootKeyBox:y.asOptional(g),syncKeyBox:y.asOptional(g)}),n=y.asArray(y.asObject({loginId:m,otpResetPending:y.asOptional(y.asBoolean,!1),pendingVouchers:y.asOptional(y.asArray(l),()=>[]),recovery2Corrupt:y.asOptional(y.asBoolean,!1)})),i=y.asObject({login_id:y.asOptional(m),otp_reset_auth:y.asOptional(y.asString),otp_timeout_date:y.asOptional(y.asDate),reason:y.asOptional(y.asValue("ip","otp"),"otp"),voucher_activates:y.asOptional(y.asDate),voucher_auth:y.asOptional(m),voucher_id:y.asOptional(y.asString)}),f=y.asObject({otpResetDate:y.asDate}),c=y.asObject({wait_seconds:y.asOptional(y.asNumber)}),h=y.asObject({question2Box:g}),s=y.asObject({loginId:m,passwordAuthSnrp:y.asOptional(M),questionBox:y.asOptional(g),questionKeySnrp:y.asOptional(M),recoveryAuthSnrp:y.asOptional(M)}),t=y.uncleaner(g),a=y.uncleaner(d),w=y.uncleaner(E),D=y.uncleaner(v),Z=y.uncleaner(b),F=y.uncleaner(k),V=y.uncleaner(B),q=y.uncleaner(U),re=y.uncleaner(C),G=y.uncleaner(L),H=y.uncleaner(N),oe=y.uncleaner(j),ue=y.uncleaner(K),be=y.uncleaner($),ie=y.uncleaner(Q),J=y.uncleaner(Y),pe=y.uncleaner(ee),Ge=y.uncleaner(u),ce=y.uncleaner(r),te=y.uncleaner(n),le=y.uncleaner(i),ge=y.uncleaner(f),Pe=y.uncleaner(c),lt=y.uncleaner(h),Le=y.uncleaner(s);function ze(xt,gt="Login requires a CAPTCHA"){if(!(this instanceof ze))throw new TypeError("Class constructor ChallengeError cannot be invoked without 'new'");var bt;function Tt(Ct){return bt=new Error(Ct),Object.defineProperty(bt,"constructor",{value:ze,configurable:!0,writable:!0}),bt}return Tt(gt),bt.name="ChallengeError",bt.challengeId=xt.challengeId,bt.challengeUri=xt.challengeUri,bt}function kt(xt="Please send a larger amount"){if(!(this instanceof kt))throw new TypeError("Class constructor DustSpendError cannot be invoked without 'new'");var gt;function bt(Tt){return gt=new Error(Tt),Object.defineProperty(gt,"constructor",{value:kt,configurable:!0,writable:!0}),gt}return bt(xt),gt.name="DustSpendError",gt}function ae(xt){if(!(this instanceof ae))throw new TypeError("Class constructor InsufficientFundsError cannot be invoked without 'new'");var gt;function bt(Xt){return gt=new Error(Xt),Object.defineProperty(gt,"constructor",{value:ae,configurable:!0,writable:!0}),gt}const{tokenId:Tt=null,networkFee:Ct}=xt!=null?xt:{};return bt(`Insufficient ${Tt!=null?Tt:"funds"}`),gt.tokenId=Tt,gt.networkFee=Ct,gt.name="InsufficientFundsError",gt}function he(xt="Cannot reach the network"){if(!(this instanceof he))throw new TypeError("Class constructor NetworkError cannot be invoked without 'new'");var gt;function bt(Tt){return gt=new Error(Tt),Object.defineProperty(gt,"constructor",{value:he,configurable:!0,writable:!0}),gt}return bt(xt),gt.name="NetworkError",gt}function je(xt="Unable to create zero-amount transaction."){if(!(this instanceof je))throw new TypeError("Class constructor NoAmountSpecifiedError cannot be invoked without 'new'");var gt;function bt(Tt){return gt=new Error(Tt),Object.defineProperty(gt,"constructor",{value:je,configurable:!0,writable:!0}),gt}return bt(xt),gt.name="NoAmountSpecifiedError",gt}function Ie(xt="The application is too old. Please upgrade."){if(!(this instanceof Ie))throw new TypeError("Class constructor ObsoleteApiError cannot be invoked without 'new'");var gt;function bt(Tt){return gt=new Error(Tt),Object.defineProperty(gt,"constructor",{value:Ie,configurable:!0,writable:!0}),gt}return bt(xt),gt.name="ObsoleteApiError",gt}function Ce(xt,gt="Invalid OTP token"){if(!(this instanceof Ce))throw new TypeError("Class constructor OtpError cannot be invoked without 'new'");var bt;function Tt(Xt){return bt=new Error(Xt),Object.defineProperty(bt,"constructor",{value:Ce,configurable:!0,writable:!0}),bt}Tt(gt),bt.name="OtpError",bt.reason="otp";const Ct=y.asMaybe(i)(xt);if(Ct!=null)return Ct.login_id!=null&&(bt.loginId=p.base64.stringify(Ct.login_id)),bt.resetToken=Ct.otp_reset_auth,bt.reason=Ct.reason,bt.resetDate=Ct.otp_timeout_date,bt.voucherActivates=Ct.voucher_activates,Ct.voucher_auth!=null&&(bt.voucherAuth=p.base64.stringify(Ct.voucher_auth)),bt.voucherId=Ct.voucher_id,bt}function ut(xt,gt="Invalid password"){if(!(this instanceof ut))throw new TypeError("Class constructor PasswordError cannot be invoked without 'new'");var bt;function Tt(Xt){return bt=new Error(Xt),Object.defineProperty(bt,"constructor",{value:ut,configurable:!0,writable:!0}),bt}Tt(gt),bt.name="PasswordError";const Ct=y.asMaybe(c)(xt);if(Ct!=null)return bt.wait=Ct.wait_seconds,bt}function De(xt="Not enough confirmed funds"){if(!(this instanceof De))throw new TypeError("Class constructor PendingFundsError cannot be invoked without 'new'");var gt;function bt(Tt){return gt=new Error(Tt),Object.defineProperty(gt,"constructor",{value:De,configurable:!0,writable:!0}),gt}return bt(xt),gt.name="PendingFundsError",gt}function ye(xt="Wallets can not be the same currency"){if(!(this instanceof ye))throw new TypeError("Class constructor SameCurrencyError cannot be invoked without 'new'");var gt;function bt(Tt){return gt=new Error(Tt),Object.defineProperty(gt,"constructor",{value:ye,configurable:!0,writable:!0}),gt}return bt(xt),gt.name="SameCurrencyError",gt}function we(xt="Spending to self"){if(!(this instanceof we))throw new TypeError("Class constructor SpendToSelfError cannot be invoked without 'new'");var gt;function bt(Tt){return gt=new Error(Tt),Object.defineProperty(gt,"constructor",{value:we,configurable:!0,writable:!0}),gt}return bt(xt),gt.name="SpendToSelfError",gt}function ve(xt,gt,bt="from"){if(!(this instanceof ve))throw new TypeError("Class constructor SwapAboveLimitError cannot be invoked without 'new'");var Tt;function Ct(Xt){return Tt=new Error(Xt),Object.defineProperty(Tt,"constructor",{value:ve,configurable:!0,writable:!0}),Tt}return Ct("Amount is too high"),Tt.name="SwapAboveLimitError",Tt.pluginId=xt.pluginId,Tt.nativeMax=gt,Tt.direction=bt,Tt}function Ee(xt,gt,bt="from"){if(!(this instanceof Ee))throw new TypeError("Class constructor SwapBelowLimitError cannot be invoked without 'new'");var Tt;function Ct(Xt){return Tt=new Error(Xt),Object.defineProperty(Tt,"constructor",{value:Ee,configurable:!0,writable:!0}),Tt}return Ct("Amount is too low"),Tt.name="SwapBelowLimitError",Tt.pluginId=xt.pluginId,Tt.nativeMin=gt,Tt.direction=bt,Tt}function rt(xt,gt){if(!(this instanceof rt))throw new TypeError("Class constructor SwapCurrencyError cannot be invoked without 'new'");var bt;function Tt(fr){return bt=new Error(fr),Object.defineProperty(bt,"constructor",{value:rt,configurable:!0,writable:!0}),bt}const{fromWallet:Ct,toWallet:Xt,fromTokenId:Yt,toTokenId:ar}=gt,or=Ct.currencyConfig.currencyInfo.pluginId,sr=Xt.currencyConfig.currencyInfo.pluginId,$t=`${or}:${String(Yt)}`,nr=`${sr}:${String(ar)}`;return Tt(`${xt.displayName} does not support ${$t} to ${nr}`),bt.name="SwapCurrencyError",bt.pluginId=xt.pluginId,bt.fromTokenId=Yt!=null?Yt:null,bt.toTokenId=ar!=null?ar:null,bt}function Fe(xt,gt){if(!(this instanceof Fe))throw new TypeError("Class constructor SwapPermissionError cannot be invoked without 'new'");var bt;function Tt(Ct){return bt=new Error(Ct),Object.defineProperty(bt,"constructor",{value:Fe,configurable:!0,writable:!0}),bt}return gt!=null?Tt(gt):Tt("You are not allowed to make this trade"),bt.name="SwapPermissionError",bt.pluginId=xt.pluginId,bt.reason=gt,bt}function He(xt="Invalid username"){if(!(this instanceof He))throw new TypeError("Class constructor UsernameError cannot be invoked without 'new'");var gt;function bt(Tt){return gt=new Error(Tt),Object.defineProperty(gt,"constructor",{value:He,configurable:!0,writable:!0}),gt}return bt(xt),gt.name="UsernameError",gt}function yt(xt){return function(bt){if(bt instanceof Error&&bt.name===xt)return bt}}const Ke=yt("ChallengeError"),Ze=yt("DustSpendError"),At=yt("InsufficientFundsError"),Ve=yt("NetworkError"),tt=yt("NoAmountSpecifiedError"),qt=yt("ObsoleteApiError"),et=yt("OtpError"),st=yt("PasswordError"),rr=yt("PendingFundsError"),at=yt("SameCurrencyError"),ft=yt("SpendToSelfError"),Qe=yt("SwapAboveLimitError"),xe=yt("SwapBelowLimitError"),Oe=yt("SwapCurrencyError"),ht=yt("SwapPermissionError"),Ne=yt("UsernameError"),qe=y.asObject(g),Dt=y.asObject({loginId:m,voucherAuth:m,voucherId:y.asString,created:y.asDate,activates:y.asDate,status:y.asValue("pending","approved","rejected"),ip:y.asString,ipDescription:y.asString,deviceDescription:y.asOptional(y.asString)}),Xe=y.asObject({appId:y.asString,created:y.asOptional(y.asDate,()=>new Date),loginId:m,children:y.asOptional(y.asArray(xt=>Xe(xt)),()=>[]),parentBox:y.asOptional(g),parentId:()=>{},otpKey:y.asOptional(o),otpResetAuth:y.asOptional(y.asString),otpResetDate:y.asOptional(y.asDate),otpTimeout:y.asOptional(y.asNumber),passwordAuth:y.asOptional(m),passwordAuthBox:y.asOptional(g),passwordAuthSnrp:y.asOptional(M),passwordBox:y.asOptional(g),passwordKeySnrp:y.asOptional(M),pin2Id:y.asOptional(m),pin2Auth:y.asOptional(m),pin2Box:y.asOptional(g),pin2KeyBox:y.asOptional(g),pin2TextBox:y.asOptional(g),recovery2Id:y.asOptional(m),recovery2Auth:y.asOptional(A),question2Box:y.asOptional(g),recovery2Box:y.asOptional(g),recovery2KeyBox:y.asOptional(g),loginAuth:y.asOptional(m),loginAuthBox:y.asOptional(g),userId:y.asOptional(m),userTextBox:y.asOptional(g),keyBoxes:y.asOptional(y.asArray(g),()=>[]),mnemonicBox:y.asOptional(g),rootKeyBox:y.asOptional(g),syncKeyBox:y.asOptional(g),vouchers:y.asOptional(y.asArray(Dt),()=>[]),pinBox:y.asOptional(g),pinId:y.asOptional(y.asString),pinKeyBox:y.asOptional(g)}),ot=y.uncleaner(Xe),Gt=y.uncleaner(qe);x.WK=ze,x.DE=kt,x.k5=ae,x.Dr=he,x.ef=je,x.GY=Ie,x.WM=Ce,x.Kz=ut,x.uX=De,x.IK=ye,x.gw=we,x.WU=ve,x.G8=Ee,x.xQ=rt,x.D7=Fe,x.hi=He,x.zU=I,x.dq=o,x.m$=m,x.MU=ee,x.ID=k,x.k0=B,x.D4=U,x.kL=C,x.jx=L,x.A_=N,x.v1=j,x.TL=K,x.Og=$,x.ft=Q,x.KU=Y,x.ZU=g,x.ye=d,x.Xj=E,x.Rn=Xe,x.bo=l,x.KL=qe,x.rW=M,x.U3=Dt,x.$Y=u,x.EJ=r,x.XY=v,x.v7=b,x.up=Ke,x.h=Ze,x.Cx=At,x.Zz=Ve,x.CU=tt,x.ib=qt,x.eT=et,x._0=st,x.UR=rr,x.Up=at,x.y0=ft,x.A2=Qe,x.ql=xe,x.FX=Oe,x.Jr=ht,x.zS=Ne,x.pK=n,x.ud=i,x.Zk=f,x.Mf=c,x.U0=A,x.CX=h,x.l4=s,x.Jv=pe,x.T0=F,x.z8=V,x.Gt=q,x.Fm=re,x.b4=G,x.N2=H,x.K8=oe,x.gB=ue,x.bd=be,x.GG=ie,x.V$=J,x.CC=t,x.dT=a,x.uT=w,x._j=ot,x.p4=Gt,x.W0=Ge,x.zk=ce,x.AB=D,x.sn=Z,x._u=te,x.Py=le,x.iu=ge,x.l7=Pe,x.JU=lt,x.O6=Le},9112:(fe,x,T)=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});var S=T(9977),y=T(4945),p=T(1395),I=T(7952),o=T(1024);function m(V){return V&&typeof V=="object"&&"default"in V?V:{default:V}}var l=m(y),g=m(p),M=m(I);function E(V){if(/^\//.test(V))throw new Error("Absolute paths are not supported");const q=V.split("/");let re=0,G=0;for(;re<q.length;){const H=q[re++];if(H===".."?G--:H!=="."&&H!==""&&(q[G++]=H),G<0)throw new Error("Path would escape folder");if(G===0&&re===q.length)throw new Error("Path would evaluate to empty file name")}return q.slice(0,G).join("/")}const d=/^[a-z0-9-_.]+(\/+[a-z0-9-_.]+)*$/i,A=/^[a-f0-9]{40}$/,v=S.asObject({infoServers:S.asOptional(S.asArray(S.asString)),syncServers:S.asOptional(S.asArray(S.asString))}),b=V=>{const q=S.asString(V);if(q==="")throw new TypeError("Expected non empty string");return q},k=V=>{const q=S.asString(V);try{if(d.test(q))return E(q)}catch{}throw new Error(`Invalid path '${q}'`)},B=V=>{const q=S.asString(V);if(!A.test(q))throw new TypeError(`Invalid sync key '${q}'`);return q},U=S.asObject({iv_hex:S.asString,encryptionType:S.asNumber,data_base64:S.asString}),C=S.asObject({success:S.asValue(!1),message:S.asString,stack:S.asOptional(S.asString)}),L=S.asEither(U,S.asNull),N=S.asObject(L),j=S.asObject({syncKey:B,hash:S.asOptional(b)}),K=S.asObject({hash:S.asOptional(S.asString),changes:N}),$=S.asObject({syncKey:B,hash:S.asOptional(b)}),Q=S.asObject({changes:N}),Y=S.asObject({hash:S.asString,changes:N}),ee=S.asObject({syncKey:B}),u=S.asUndefined,e=()=>{};async function r(V,q,re={}){const{log:G=e,fetch:H=l.default}=re,{method:oe,url:ue,body:be,numbUrl:ie=ue,headers:J={}}=V,pe=Date.now(),Ge=await H(ue,{method:oe,headers:{"Content-Type":"application/json",...J},body:JSON.stringify(be)}),ce=Date.now()-pe;G(`${oe} ${ie} returned ${Ge.status} in ${ce}ms`);const te=await Ge.text();if(!Ge.ok)throw new Error(`Failed request ${oe} ${ie} failed ${Ge.status}: ${te}`);const le=S.asMaybe(C)(te);if(le!=null)throw new Error(`Failed request ${oe} ${ie} failed ${Ge.status}: ${le.message}`);return q(te.trim()!==""?JSON.parse(te):void 0)}const n=g.default("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),i=V=>{const q=o.base16.parse(V),re=f(f(q));return n.encode(re)};function f(V){const q=M.default.sha256();return Uint8Array.from(q.update(V).digest())}function c(V){for(let q=V.length-1;q>0;q--){const re=Math.floor(Math.random()*(q+1));[V[q],V[re]]=[V[re],V[q]]}return V}class h extends Error{constructor(q="Cannot reach the network"){super(q),this.name="NetworkError"}}function s(V,q){let re=Date.now()+q,G=V(void 0);return{get:()=>((Date.now()>re||G==null)&&(re=Date.now()+q,G=V(G)),G)}}function t(V,q){return V!=null?V:q()}const a={infoServers:["https://info-eu1.edge.app","https://info-us1.edge.app"],syncServers:["https://sync-us1.edge.app","https://sync-us2.edge.app","https://sync-us3.edge.app","https://sync-us4.edge.app","https://sync-us5.edge.app","https://sync-us6.edge.app","https://sync-eu.edge.app"]};function w(V={}){const{log:q=()=>{}}=V,re={...a,...V.edgeServers},{edgeServersCacheTTL:G=6e5}=V,H=s((oe={current:re})=>(oe.current.infoServers.length>0&&D(oe.current.infoServers,V).then(ue=>oe.current={...oe.current,...ue,infoServers:t(ue.infoServers,()=>a.infoServers)}).catch(async ue=>{q(String(ue))}),oe),G);return{async getEdgeServers(){const{current:oe}=await H.get();return oe}}}async function D(V,q={}){const{log:re=e,fetch:G=l.default}=q;let H=new Error("No info servers");for(const oe of V){const[ue,be]=["GET","/v1/edgeServers"],ie=Date.now(),J=`${oe}${be}`;try{const pe=await G(J,{method:ue,headers:{"Content-Type":"application/json"}}).catch(lt=>{const Le=Date.now()-ie,ze=`${ue} ${J} failed in ${Le}ms, ${String(lt)}`;throw re(ze),new h(ze)}),{ok:Ge,status:ce}=pe,te=Date.now()-ie,le=`${ue} ${J} returned ${ce} in ${te}ms`;if(!Ge)throw re(le),new h(le);re(le);const ge=await pe.text(),Pe=JSON.parse(ge);return v(Pe)}catch(pe){H=pe;continue}}throw H}function Z(V,q){return V!=null?V:q()}function F(V={}){const q=w(V);async function re(){const{syncServers:G}=await q.getEdgeServers();return c(G)}return{async createRepo(G,H){const oe=await re();let ue=new Error(`Failed to create repo ${G}: empty sync server list`);for(const be of oe){const ie=`${be}/api/v2/store/${G}`,J=ie.replace(G,`<${i(G)}>`);try{return await r({method:"PUT",url:ie,numbUrl:J,headers:H!=null?{"X-API-Key":H}:{}},u,V)}catch(pe){ue=pe}}throw ue},async readRepo(G,H){const oe=await re();let ue=new Error(`Failed to read repo ${G}: empty sync server list`);for(const be of oe){const ie=`${be}/api/v2/store/${G}/${Z(H,()=>"")}`,J=ie.replace(G,`<${i(G)}>`);try{return await r({method:"GET",url:ie,numbUrl:J},K,V)}catch(pe){ue=pe}}throw ue},async updateRepo(G,H,oe){const ue=await re();let be=new Error(`Failed to update repo ${G}: empty sync server list`);for(const ie of ue){const J=`${ie}/api/v2/store/${G}/${Z(H,()=>"")}`,pe=J.replace(G,`<${i(G)}>`);try{return await r({method:"POST",url:J,numbUrl:pe,body:oe},Y,V)}catch(Ge){be=Ge}}throw be}}}x.asChangeSet=N,x.asEdgeBox=U,x.asEdgeServers=v,x.asFileChange=L,x.asGetStoreParams=j,x.asGetStoreResponse=K,x.asNonEmptyString=b,x.asPath=k,x.asPostStoreBody=Q,x.asPostStoreParams=$,x.asPostStoreResponse=Y,x.asPutStoreParams=ee,x.asPutStoreResponse=u,x.asServerErrorResponse=C,x.asSyncKey=B,x.makeSyncClient=F,x.syncKeyToRepoId=i},1395:fe=>{fe.exports=function(T){for(var S={},y=T.length,p=T.charAt(0),I=0;I<T.length;I++)S[T.charAt(I)]=I;function o(g){if(g.length===0)return"";for(var M=[0],E=0;E<g.length;++E){for(var d=0,A=g[E];d<M.length;++d)A+=M[d]<<8,M[d]=A%y,A=A/y|0;for(;A>0;)M.push(A%y),A=A/y|0}for(var v="",b=0;g[b]===0&&b<g.length-1;++b)v+=T[0];for(var k=M.length-1;k>=0;--k)v+=T[M[k]];return v}function m(g){if(g.length===0)return[];for(var M=[0],E=0;E<g.length;E++){var d=S[g[E]];if(d===void 0)return;for(var A=0,v=d;A<M.length;++A)v+=M[A]*y,M[A]=v&255,v>>=8;for(;v>0;)M.push(v&255),v>>=8}for(var b=0;g[b]===p&&b<g.length-1;++b)M.push(0);return M.reverse()}function l(g){var M=m(g);if(M)return M;throw new Error("Non-base"+y+" character")}return{encode:o,decodeUnsafe:m,decode:l}}},6729:(fe,x,T)=>{"use strict";var S=x;S.version=T(1636).rE,S.utils=T(7011),S.rand=T(5037),S.curve=T(894),S.curves=T(480),S.ec=T(7447),S.eddsa=T(8650)},6677:(fe,x,T)=>{"use strict";var S=T(8490),y=T(7011),p=y.getNAF,I=y.getJSF,o=y.assert;function m(g,M){this.type=g,this.p=new S(M.p,16),this.red=M.prime?S.red(M.prime):S.mont(this.p),this.zero=new S(0).toRed(this.red),this.one=new S(1).toRed(this.red),this.two=new S(2).toRed(this.red),this.n=M.n&&new S(M.n,16),this.g=M.g&&this.pointFromJSON(M.g,M.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var E=this.n&&this.p.div(this.n);!E||E.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}fe.exports=m,m.prototype.point=function(){throw new Error("Not implemented")},m.prototype.validate=function(){throw new Error("Not implemented")},m.prototype._fixedNafMul=function(M,E){o(M.precomputed);var d=M._getDoubles(),A=p(E,1,this._bitLength),v=(1<<d.step+1)-(d.step%2===0?2:1);v/=3;var b=[],k,B;for(k=0;k<A.length;k+=d.step){B=0;for(var U=k+d.step-1;U>=k;U--)B=(B<<1)+A[U];b.push(B)}for(var C=this.jpoint(null,null,null),L=this.jpoint(null,null,null),N=v;N>0;N--){for(k=0;k<b.length;k++)B=b[k],B===N?L=L.mixedAdd(d.points[k]):B===-N&&(L=L.mixedAdd(d.points[k].neg()));C=C.add(L)}return C.toP()},m.prototype._wnafMul=function(M,E){var d=4,A=M._getNAFPoints(d);d=A.wnd;for(var v=A.points,b=p(E,d,this._bitLength),k=this.jpoint(null,null,null),B=b.length-1;B>=0;B--){for(var U=0;B>=0&&b[B]===0;B--)U++;if(B>=0&&U++,k=k.dblp(U),B<0)break;var C=b[B];o(C!==0),M.type==="affine"?C>0?k=k.mixedAdd(v[C-1>>1]):k=k.mixedAdd(v[-C-1>>1].neg()):C>0?k=k.add(v[C-1>>1]):k=k.add(v[-C-1>>1].neg())}return M.type==="affine"?k.toP():k},m.prototype._wnafMulAdd=function(M,E,d,A,v){var b=this._wnafT1,k=this._wnafT2,B=this._wnafT3,U=0,C,L,N;for(C=0;C<A;C++){N=E[C];var j=N._getNAFPoints(M);b[C]=j.wnd,k[C]=j.points}for(C=A-1;C>=1;C-=2){var K=C-1,$=C;if(b[K]!==1||b[$]!==1){B[K]=p(d[K],b[K],this._bitLength),B[$]=p(d[$],b[$],this._bitLength),U=Math.max(B[K].length,U),U=Math.max(B[$].length,U);continue}var Q=[E[K],null,null,E[$]];E[K].y.cmp(E[$].y)===0?(Q[1]=E[K].add(E[$]),Q[2]=E[K].toJ().mixedAdd(E[$].neg())):E[K].y.cmp(E[$].y.redNeg())===0?(Q[1]=E[K].toJ().mixedAdd(E[$]),Q[2]=E[K].add(E[$].neg())):(Q[1]=E[K].toJ().mixedAdd(E[$]),Q[2]=E[K].toJ().mixedAdd(E[$].neg()));var Y=[-3,-1,-5,-7,0,7,5,1,3],ee=I(d[K],d[$]);for(U=Math.max(ee[0].length,U),B[K]=new Array(U),B[$]=new Array(U),L=0;L<U;L++){var u=ee[0][L]|0,e=ee[1][L]|0;B[K][L]=Y[(u+1)*3+(e+1)],B[$][L]=0,k[K]=Q}}var r=this.jpoint(null,null,null),n=this._wnafT4;for(C=U;C>=0;C--){for(var i=0;C>=0;){var f=!0;for(L=0;L<A;L++)n[L]=B[L][C]|0,n[L]!==0&&(f=!1);if(!f)break;i++,C--}if(C>=0&&i++,r=r.dblp(i),C<0)break;for(L=0;L<A;L++){var c=n[L];c!==0&&(c>0?N=k[L][c-1>>1]:c<0&&(N=k[L][-c-1>>1].neg()),N.type==="affine"?r=r.mixedAdd(N):r=r.add(N))}}for(C=0;C<A;C++)k[C]=null;return v?r:r.toP()};function l(g,M){this.curve=g,this.type=M,this.precomputed=null}m.BasePoint=l,l.prototype.eq=function(){throw new Error("Not implemented")},l.prototype.validate=function(){return this.curve.validate(this)},m.prototype.decodePoint=function(M,E){M=y.toArray(M,E);var d=this.p.byteLength();if((M[0]===4||M[0]===6||M[0]===7)&&M.length-1===2*d){M[0]===6?o(M[M.length-1]%2===0):M[0]===7&&o(M[M.length-1]%2===1);var A=this.point(M.slice(1,1+d),M.slice(1+d,1+2*d));return A}else if((M[0]===2||M[0]===3)&&M.length-1===d)return this.pointFromX(M.slice(1,1+d),M[0]===3);throw new Error("Unknown point format")},l.prototype.encodeCompressed=function(M){return this.encode(M,!0)},l.prototype._encode=function(M){var E=this.curve.p.byteLength(),d=this.getX().toArray("be",E);return M?[this.getY().isEven()?2:3].concat(d):[4].concat(d,this.getY().toArray("be",E))},l.prototype.encode=function(M,E){return y.encode(this._encode(E),M)},l.prototype.precompute=function(M){if(this.precomputed)return this;var E={doubles:null,naf:null,beta:null};return E.naf=this._getNAFPoints(8),E.doubles=this._getDoubles(4,M),E.beta=this._getBeta(),this.precomputed=E,this},l.prototype._hasDoubles=function(M){if(!this.precomputed)return!1;var E=this.precomputed.doubles;return E?E.points.length>=Math.ceil((M.bitLength()+1)/E.step):!1},l.prototype._getDoubles=function(M,E){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var d=[this],A=this,v=0;v<E;v+=M){for(var b=0;b<M;b++)A=A.dbl();d.push(A)}return{step:M,points:d}},l.prototype._getNAFPoints=function(M){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var E=[this],d=(1<<M)-1,A=d===1?null:this.dbl(),v=1;v<d;v++)E[v]=E[v-1].add(A);return{wnd:M,points:E}},l.prototype._getBeta=function(){return null},l.prototype.dblp=function(M){for(var E=this,d=0;d<M;d++)E=E.dbl();return E}},1298:(fe,x,T)=>{"use strict";var S=T(7011),y=T(8490),p=T(6698),I=T(6677),o=S.assert;function m(g){this.twisted=(g.a|0)!==1,this.mOneA=this.twisted&&(g.a|0)===-1,this.extended=this.mOneA,I.call(this,"edwards",g),this.a=new y(g.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new y(g.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new y(g.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),o(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(g.c|0)===1}p(m,I),fe.exports=m,m.prototype._mulA=function(M){return this.mOneA?M.redNeg():this.a.redMul(M)},m.prototype._mulC=function(M){return this.oneC?M:this.c.redMul(M)},m.prototype.jpoint=function(M,E,d,A){return this.point(M,E,d,A)},m.prototype.pointFromX=function(M,E){M=new y(M,16),M.red||(M=M.toRed(this.red));var d=M.redSqr(),A=this.c2.redSub(this.a.redMul(d)),v=this.one.redSub(this.c2.redMul(this.d).redMul(d)),b=A.redMul(v.redInvm()),k=b.redSqrt();if(k.redSqr().redSub(b).cmp(this.zero)!==0)throw new Error("invalid point");var B=k.fromRed().isOdd();return(E&&!B||!E&&B)&&(k=k.redNeg()),this.point(M,k)},m.prototype.pointFromY=function(M,E){M=new y(M,16),M.red||(M=M.toRed(this.red));var d=M.redSqr(),A=d.redSub(this.c2),v=d.redMul(this.d).redMul(this.c2).redSub(this.a),b=A.redMul(v.redInvm());if(b.cmp(this.zero)===0){if(E)throw new Error("invalid point");return this.point(this.zero,M)}var k=b.redSqrt();if(k.redSqr().redSub(b).cmp(this.zero)!==0)throw new Error("invalid point");return k.fromRed().isOdd()!==E&&(k=k.redNeg()),this.point(k,M)},m.prototype.validate=function(M){if(M.isInfinity())return!0;M.normalize();var E=M.x.redSqr(),d=M.y.redSqr(),A=E.redMul(this.a).redAdd(d),v=this.c2.redMul(this.one.redAdd(this.d.redMul(E).redMul(d)));return A.cmp(v)===0};function l(g,M,E,d,A){I.BasePoint.call(this,g,"projective"),M===null&&E===null&&d===null?(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 y(M,16),this.y=new y(E,16),this.z=d?new y(d,16):this.curve.one,this.t=A&&new y(A,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()))))}p(l,I.BasePoint),m.prototype.pointFromJSON=function(M){return l.fromJSON(this,M)},m.prototype.point=function(M,E,d,A){return new l(this,M,E,d,A)},l.fromJSON=function(M,E){return new l(M,E[0],E[1],E[2])},l.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},l.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},l.prototype._extDbl=function(){var M=this.x.redSqr(),E=this.y.redSqr(),d=this.z.redSqr();d=d.redIAdd(d);var A=this.curve._mulA(M),v=this.x.redAdd(this.y).redSqr().redISub(M).redISub(E),b=A.redAdd(E),k=b.redSub(d),B=A.redSub(E),U=v.redMul(k),C=b.redMul(B),L=v.redMul(B),N=k.redMul(b);return this.curve.point(U,C,N,L)},l.prototype._projDbl=function(){var M=this.x.redAdd(this.y).redSqr(),E=this.x.redSqr(),d=this.y.redSqr(),A,v,b,k,B,U;if(this.curve.twisted){k=this.curve._mulA(E);var C=k.redAdd(d);this.zOne?(A=M.redSub(E).redSub(d).redMul(C.redSub(this.curve.two)),v=C.redMul(k.redSub(d)),b=C.redSqr().redSub(C).redSub(C)):(B=this.z.redSqr(),U=C.redSub(B).redISub(B),A=M.redSub(E).redISub(d).redMul(U),v=C.redMul(k.redSub(d)),b=C.redMul(U))}else k=E.redAdd(d),B=this.curve._mulC(this.z).redSqr(),U=k.redSub(B).redSub(B),A=this.curve._mulC(M.redISub(k)).redMul(U),v=this.curve._mulC(k).redMul(E.redISub(d)),b=k.redMul(U);return this.curve.point(A,v,b)},l.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},l.prototype._extAdd=function(M){var E=this.y.redSub(this.x).redMul(M.y.redSub(M.x)),d=this.y.redAdd(this.x).redMul(M.y.redAdd(M.x)),A=this.t.redMul(this.curve.dd).redMul(M.t),v=this.z.redMul(M.z.redAdd(M.z)),b=d.redSub(E),k=v.redSub(A),B=v.redAdd(A),U=d.redAdd(E),C=b.redMul(k),L=B.redMul(U),N=b.redMul(U),j=k.redMul(B);return this.curve.point(C,L,j,N)},l.prototype._projAdd=function(M){var E=this.z.redMul(M.z),d=E.redSqr(),A=this.x.redMul(M.x),v=this.y.redMul(M.y),b=this.curve.d.redMul(A).redMul(v),k=d.redSub(b),B=d.redAdd(b),U=this.x.redAdd(this.y).redMul(M.x.redAdd(M.y)).redISub(A).redISub(v),C=E.redMul(k).redMul(U),L,N;return this.curve.twisted?(L=E.redMul(B).redMul(v.redSub(this.curve._mulA(A))),N=k.redMul(B)):(L=E.redMul(B).redMul(v.redSub(A)),N=this.curve._mulC(k).redMul(B)),this.curve.point(C,L,N)},l.prototype.add=function(M){return this.isInfinity()?M:M.isInfinity()?this:this.curve.extended?this._extAdd(M):this._projAdd(M)},l.prototype.mul=function(M){return this._hasDoubles(M)?this.curve._fixedNafMul(this,M):this.curve._wnafMul(this,M)},l.prototype.mulAdd=function(M,E,d){return this.curve._wnafMulAdd(1,[this,E],[M,d],2,!1)},l.prototype.jmulAdd=function(M,E,d){return this.curve._wnafMulAdd(1,[this,E],[M,d],2,!0)},l.prototype.normalize=function(){if(this.zOne)return this;var M=this.z.redInvm();return this.x=this.x.redMul(M),this.y=this.y.redMul(M),this.t&&(this.t=this.t.redMul(M)),this.z=this.curve.one,this.zOne=!0,this},l.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},l.prototype.getX=function(){return this.normalize(),this.x.fromRed()},l.prototype.getY=function(){return this.normalize(),this.y.fromRed()},l.prototype.eq=function(M){return this===M||this.getX().cmp(M.getX())===0&&this.getY().cmp(M.getY())===0},l.prototype.eqXToP=function(M){var E=M.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(E)===0)return!0;for(var d=M.clone(),A=this.curve.redN.redMul(this.z);;){if(d.iadd(this.curve.n),d.cmp(this.curve.p)>=0)return!1;if(E.redIAdd(A),this.x.cmp(E)===0)return!0}},l.prototype.toP=l.prototype.normalize,l.prototype.mixedAdd=l.prototype.add},894:(fe,x,T)=>{"use strict";var S=x;S.base=T(6677),S.short=T(9188),S.mont=T(370),S.edwards=T(1298)},370:(fe,x,T)=>{"use strict";var S=T(8490),y=T(6698),p=T(6677),I=T(7011);function o(l){p.call(this,"mont",l),this.a=new S(l.a,16).toRed(this.red),this.b=new S(l.b,16).toRed(this.red),this.i4=new S(4).toRed(this.red).redInvm(),this.two=new S(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}y(o,p),fe.exports=o,o.prototype.validate=function(g){var M=g.normalize().x,E=M.redSqr(),d=E.redMul(M).redAdd(E.redMul(this.a)).redAdd(M),A=d.redSqrt();return A.redSqr().cmp(d)===0};function m(l,g,M){p.BasePoint.call(this,l,"projective"),g===null&&M===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new S(g,16),this.z=new S(M,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}y(m,p.BasePoint),o.prototype.decodePoint=function(g,M){return this.point(I.toArray(g,M),1)},o.prototype.point=function(g,M){return new m(this,g,M)},o.prototype.pointFromJSON=function(g){return m.fromJSON(this,g)},m.prototype.precompute=function(){},m.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},m.fromJSON=function(g,M){return new m(g,M[0],M[1]||g.one)},m.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},m.prototype.isInfinity=function(){return this.z.cmpn(0)===0},m.prototype.dbl=function(){var g=this.x.redAdd(this.z),M=g.redSqr(),E=this.x.redSub(this.z),d=E.redSqr(),A=M.redSub(d),v=M.redMul(d),b=A.redMul(d.redAdd(this.curve.a24.redMul(A)));return this.curve.point(v,b)},m.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},m.prototype.diffAdd=function(g,M){var E=this.x.redAdd(this.z),d=this.x.redSub(this.z),A=g.x.redAdd(g.z),v=g.x.redSub(g.z),b=v.redMul(E),k=A.redMul(d),B=M.z.redMul(b.redAdd(k).redSqr()),U=M.x.redMul(b.redISub(k).redSqr());return this.curve.point(B,U)},m.prototype.mul=function(g){for(var M=g.clone(),E=this,d=this.curve.point(null,null),A=this,v=[];M.cmpn(0)!==0;M.iushrn(1))v.push(M.andln(1));for(var b=v.length-1;b>=0;b--)v[b]===0?(E=E.diffAdd(d,A),d=d.dbl()):(d=E.diffAdd(d,A),E=E.dbl());return d},m.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},m.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},m.prototype.eq=function(g){return this.getX().cmp(g.getX())===0},m.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},m.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},9188:(fe,x,T)=>{"use strict";var S=T(7011),y=T(8490),p=T(6698),I=T(6677),o=S.assert;function m(M){I.call(this,"short",M),this.a=new y(M.a,16).toRed(this.red),this.b=new y(M.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(M),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}p(m,I),fe.exports=m,m.prototype._getEndomorphism=function(E){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var d,A;if(E.beta)d=new y(E.beta,16).toRed(this.red);else{var v=this._getEndoRoots(this.p);d=v[0].cmp(v[1])<0?v[0]:v[1],d=d.toRed(this.red)}if(E.lambda)A=new y(E.lambda,16);else{var b=this._getEndoRoots(this.n);this.g.mul(b[0]).x.cmp(this.g.x.redMul(d))===0?A=b[0]:(A=b[1],o(this.g.mul(A).x.cmp(this.g.x.redMul(d))===0))}var k;return E.basis?k=E.basis.map(function(B){return{a:new y(B.a,16),b:new y(B.b,16)}}):k=this._getEndoBasis(A),{beta:d,lambda:A,basis:k}}},m.prototype._getEndoRoots=function(E){var d=E===this.p?this.red:y.mont(E),A=new y(2).toRed(d).redInvm(),v=A.redNeg(),b=new y(3).toRed(d).redNeg().redSqrt().redMul(A),k=v.redAdd(b).fromRed(),B=v.redSub(b).fromRed();return[k,B]},m.prototype._getEndoBasis=function(E){for(var d=this.n.ushrn(Math.floor(this.n.bitLength()/2)),A=E,v=this.n.clone(),b=new y(1),k=new y(0),B=new y(0),U=new y(1),C,L,N,j,K,$,Q,Y=0,ee,u;A.cmpn(0)!==0;){var e=v.div(A);ee=v.sub(e.mul(A)),u=B.sub(e.mul(b));var r=U.sub(e.mul(k));if(!N&&ee.cmp(d)<0)C=Q.neg(),L=b,N=ee.neg(),j=u;else if(N&&++Y===2)break;Q=ee,v=A,A=ee,B=b,b=u,U=k,k=r}K=ee.neg(),$=u;var n=N.sqr().add(j.sqr()),i=K.sqr().add($.sqr());return i.cmp(n)>=0&&(K=C,$=L),N.negative&&(N=N.neg(),j=j.neg()),K.negative&&(K=K.neg(),$=$.neg()),[{a:N,b:j},{a:K,b:$}]},m.prototype._endoSplit=function(E){var d=this.endo.basis,A=d[0],v=d[1],b=v.b.mul(E).divRound(this.n),k=A.b.neg().mul(E).divRound(this.n),B=b.mul(A.a),U=k.mul(v.a),C=b.mul(A.b),L=k.mul(v.b),N=E.sub(B).sub(U),j=C.add(L).neg();return{k1:N,k2:j}},m.prototype.pointFromX=function(E,d){E=new y(E,16),E.red||(E=E.toRed(this.red));var A=E.redSqr().redMul(E).redIAdd(E.redMul(this.a)).redIAdd(this.b),v=A.redSqrt();if(v.redSqr().redSub(A).cmp(this.zero)!==0)throw new Error("invalid point");var b=v.fromRed().isOdd();return(d&&!b||!d&&b)&&(v=v.redNeg()),this.point(E,v)},m.prototype.validate=function(E){if(E.inf)return!0;var d=E.x,A=E.y,v=this.a.redMul(d),b=d.redSqr().redMul(d).redIAdd(v).redIAdd(this.b);return A.redSqr().redISub(b).cmpn(0)===0},m.prototype._endoWnafMulAdd=function(E,d,A){for(var v=this._endoWnafT1,b=this._endoWnafT2,k=0;k<E.length;k++){var B=this._endoSplit(d[k]),U=E[k],C=U._getBeta();B.k1.negative&&(B.k1.ineg(),U=U.neg(!0)),B.k2.negative&&(B.k2.ineg(),C=C.neg(!0)),v[k*2]=U,v[k*2+1]=C,b[k*2]=B.k1,b[k*2+1]=B.k2}for(var L=this._wnafMulAdd(1,v,b,k*2,A),N=0;N<k*2;N++)v[N]=null,b[N]=null;return L};function l(M,E,d,A){I.BasePoint.call(this,M,"affine"),E===null&&d===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new y(E,16),this.y=new y(d,16),A&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}p(l,I.BasePoint),m.prototype.point=function(E,d,A){return new l(this,E,d,A)},m.prototype.pointFromJSON=function(E,d){return l.fromJSON(this,E,d)},l.prototype._getBeta=function(){if(this.curve.endo){var E=this.precomputed;if(E&&E.beta)return E.beta;var d=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(E){var A=this.curve,v=function(b){return A.point(b.x.redMul(A.endo.beta),b.y)};E.beta=d,d.precomputed={beta:null,naf:E.naf&&{wnd:E.naf.wnd,points:E.naf.points.map(v)},doubles:E.doubles&&{step:E.doubles.step,points:E.doubles.points.map(v)}}}return d}},l.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},l.fromJSON=function(E,d,A){typeof d=="string"&&(d=JSON.parse(d));var v=E.point(d[0],d[1],A);if(!d[2])return v;function b(B){return E.point(B[0],B[1],A)}var k=d[2];return v.precomputed={beta:null,doubles:k.doubles&&{step:k.doubles.step,points:[v].concat(k.doubles.points.map(b))},naf:k.naf&&{wnd:k.naf.wnd,points:[v].concat(k.naf.points.map(b))}},v},l.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},l.prototype.isInfinity=function(){return this.inf},l.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(this.x.cmp(E.x)===0)return this.curve.point(null,null);var d=this.y.redSub(E.y);d.cmpn(0)!==0&&(d=d.redMul(this.x.redSub(E.x).redInvm()));var A=d.redSqr().redISub(this.x).redISub(E.x),v=d.redMul(this.x.redSub(A)).redISub(this.y);return this.curve.point(A,v)},l.prototype.dbl=function(){if(this.inf)return this;var E=this.y.redAdd(this.y);if(E.cmpn(0)===0)return this.curve.point(null,null);var d=this.curve.a,A=this.x.redSqr(),v=E.redInvm(),b=A.redAdd(A).redIAdd(A).redIAdd(d).redMul(v),k=b.redSqr().redISub(this.x.redAdd(this.x)),B=b.redMul(this.x.redSub(k)).redISub(this.y);return this.curve.point(k,B)},l.prototype.getX=function(){return this.x.fromRed()},l.prototype.getY=function(){return this.y.fromRed()},l.prototype.mul=function(E){return E=new y(E,16),this.isInfinity()?this:this._hasDoubles(E)?this.curve._fixedNafMul(this,E):this.curve.endo?this.curve._endoWnafMulAdd([this],[E]):this.curve._wnafMul(this,E)},l.prototype.mulAdd=function(E,d,A){var v=[this,d],b=[E,A];return this.curve.endo?this.curve._endoWnafMulAdd(v,b):this.curve._wnafMulAdd(1,v,b,2)},l.prototype.jmulAdd=function(E,d,A){var v=[this,d],b=[E,A];return this.curve.endo?this.curve._endoWnafMulAdd(v,b,!0):this.curve._wnafMulAdd(1,v,b,2,!0)},l.prototype.eq=function(E){return this===E||this.inf===E.inf&&(this.inf||this.x.cmp(E.x)===0&&this.y.cmp(E.y)===0)},l.prototype.neg=function(E){if(this.inf)return this;var d=this.curve.point(this.x,this.y.redNeg());if(E&&this.precomputed){var A=this.precomputed,v=function(b){return b.neg()};d.precomputed={naf:A.naf&&{wnd:A.naf.wnd,points:A.naf.points.map(v)},doubles:A.doubles&&{step:A.doubles.step,points:A.doubles.points.map(v)}}}return d},l.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var E=this.curve.jpoint(this.x,this.y,this.curve.one);return E};function g(M,E,d,A){I.BasePoint.call(this,M,"jacobian"),E===null&&d===null&&A===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new y(0)):(this.x=new y(E,16),this.y=new y(d,16),this.z=new y(A,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}p(g,I.BasePoint),m.prototype.jpoint=function(E,d,A){return new g(this,E,d,A)},g.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var E=this.z.redInvm(),d=E.redSqr(),A=this.x.redMul(d),v=this.y.redMul(d).redMul(E);return this.curve.point(A,v)},g.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},g.prototype.add=function(E){if(this.isInfinity())return E;if(E.isInfinity())return this;var d=E.z.redSqr(),A=this.z.redSqr(),v=this.x.redMul(d),b=E.x.redMul(A),k=this.y.redMul(d.redMul(E.z)),B=E.y.redMul(A.redMul(this.z)),U=v.redSub(b),C=k.redSub(B);if(U.cmpn(0)===0)return C.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var L=U.redSqr(),N=L.redMul(U),j=v.redMul(L),K=C.redSqr().redIAdd(N).redISub(j).redISub(j),$=C.redMul(j.redISub(K)).redISub(k.redMul(N)),Q=this.z.redMul(E.z).redMul(U);return this.curve.jpoint(K,$,Q)},g.prototype.mixedAdd=function(E){if(this.isInfinity())return E.toJ();if(E.isInfinity())return this;var d=this.z.redSqr(),A=this.x,v=E.x.redMul(d),b=this.y,k=E.y.redMul(d).redMul(this.z),B=A.redSub(v),U=b.redSub(k);if(B.cmpn(0)===0)return U.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var C=B.redSqr(),L=C.redMul(B),N=A.redMul(C),j=U.redSqr().redIAdd(L).redISub(N).redISub(N),K=U.redMul(N.redISub(j)).redISub(b.redMul(L)),$=this.z.redMul(B);return this.curve.jpoint(j,K,$)},g.prototype.dblp=function(E){if(E===0)return this;if(this.isInfinity())return this;if(!E)return this.dbl();var d;if(this.curve.zeroA||this.curve.threeA){var A=this;for(d=0;d<E;d++)A=A.dbl();return A}var v=this.curve.a,b=this.curve.tinv,k=this.x,B=this.y,U=this.z,C=U.redSqr().redSqr(),L=B.redAdd(B);for(d=0;d<E;d++){var N=k.redSqr(),j=L.redSqr(),K=j.redSqr(),$=N.redAdd(N).redIAdd(N).redIAdd(v.redMul(C)),Q=k.redMul(j),Y=$.redSqr().redISub(Q.redAdd(Q)),ee=Q.redISub(Y),u=$.redMul(ee);u=u.redIAdd(u).redISub(K);var e=L.redMul(U);d+1<E&&(C=C.redMul(K)),k=Y,U=e,L=u}return this.curve.jpoint(k,L.redMul(b),U)},g.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},g.prototype._zeroDbl=function(){var E,d,A;if(this.zOne){var v=this.x.redSqr(),b=this.y.redSqr(),k=b.redSqr(),B=this.x.redAdd(b).redSqr().redISub(v).redISub(k);B=B.redIAdd(B);var U=v.redAdd(v).redIAdd(v),C=U.redSqr().redISub(B).redISub(B),L=k.redIAdd(k);L=L.redIAdd(L),L=L.redIAdd(L),E=C,d=U.redMul(B.redISub(C)).redISub(L),A=this.y.redAdd(this.y)}else{var N=this.x.redSqr(),j=this.y.redSqr(),K=j.redSqr(),$=this.x.redAdd(j).redSqr().redISub(N).redISub(K);$=$.redIAdd($);var Q=N.redAdd(N).redIAdd(N),Y=Q.redSqr(),ee=K.redIAdd(K);ee=ee.redIAdd(ee),ee=ee.redIAdd(ee),E=Y.redISub($).redISub($),d=Q.redMul($.redISub(E)).redISub(ee),A=this.y.redMul(this.z),A=A.redIAdd(A)}return this.curve.jpoint(E,d,A)},g.prototype._threeDbl=function(){var E,d,A;if(this.zOne){var v=this.x.redSqr(),b=this.y.redSqr(),k=b.redSqr(),B=this.x.redAdd(b).redSqr().redISub(v).redISub(k);B=B.redIAdd(B);var U=v.redAdd(v).redIAdd(v).redIAdd(this.curve.a),C=U.redSqr().redISub(B).redISub(B);E=C;var L=k.redIAdd(k);L=L.redIAdd(L),L=L.redIAdd(L),d=U.redMul(B.redISub(C)).redISub(L),A=this.y.redAdd(this.y)}else{var N=this.z.redSqr(),j=this.y.redSqr(),K=this.x.redMul(j),$=this.x.redSub(N).redMul(this.x.redAdd(N));$=$.redAdd($).redIAdd($);var Q=K.redIAdd(K);Q=Q.redIAdd(Q);var Y=Q.redAdd(Q);E=$.redSqr().redISub(Y),A=this.y.redAdd(this.z).redSqr().redISub(j).redISub(N);var ee=j.redSqr();ee=ee.redIAdd(ee),ee=ee.redIAdd(ee),ee=ee.redIAdd(ee),d=$.redMul(Q.redISub(E)).redISub(ee)}return this.curve.jpoint(E,d,A)},g.prototype._dbl=function(){var E=this.curve.a,d=this.x,A=this.y,v=this.z,b=v.redSqr().redSqr(),k=d.redSqr(),B=A.redSqr(),U=k.redAdd(k).redIAdd(k).redIAdd(E.redMul(b)),C=d.redAdd(d);C=C.redIAdd(C);var L=C.redMul(B),N=U.redSqr().redISub(L.redAdd(L)),j=L.redISub(N),K=B.redSqr();K=K.redIAdd(K),K=K.redIAdd(K),K=K.redIAdd(K);var $=U.redMul(j).redISub(K),Q=A.redAdd(A).redMul(v);return this.curve.jpoint(N,$,Q)},g.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var E=this.x.redSqr(),d=this.y.redSqr(),A=this.z.redSqr(),v=d.redSqr(),b=E.redAdd(E).redIAdd(E),k=b.redSqr(),B=this.x.redAdd(d).redSqr().redISub(E).redISub(v);B=B.redIAdd(B),B=B.redAdd(B).redIAdd(B),B=B.redISub(k);var U=B.redSqr(),C=v.redIAdd(v);C=C.redIAdd(C),C=C.redIAdd(C),C=C.redIAdd(C);var L=b.redIAdd(B).redSqr().redISub(k).redISub(U).redISub(C),N=d.redMul(L);N=N.redIAdd(N),N=N.redIAdd(N);var j=this.x.redMul(U).redISub(N);j=j.redIAdd(j),j=j.redIAdd(j);var K=this.y.redMul(L.redMul(C.redISub(L)).redISub(B.redMul(U)));K=K.redIAdd(K),K=K.redIAdd(K),K=K.redIAdd(K);var $=this.z.redAdd(B).redSqr().redISub(A).redISub(U);return this.curve.jpoint(j,K,$)},g.prototype.mul=function(E,d){return E=new y(E,d),this.curve._wnafMul(this,E)},g.prototype.eq=function(E){if(E.type==="affine")return this.eq(E.toJ());if(this===E)return!0;var d=this.z.redSqr(),A=E.z.redSqr();if(this.x.redMul(A).redISub(E.x.redMul(d)).cmpn(0)!==0)return!1;var v=d.redMul(this.z),b=A.redMul(E.z);return this.y.redMul(b).redISub(E.y.redMul(v)).cmpn(0)===0},g.prototype.eqXToP=function(E){var d=this.z.redSqr(),A=E.toRed(this.curve.red).redMul(d);if(this.x.cmp(A)===0)return!0;for(var v=E.clone(),b=this.curve.redN.redMul(d);;){if(v.iadd(this.curve.n),v.cmp(this.curve.p)>=0)return!1;if(A.redIAdd(b),this.x.cmp(A)===0)return!0}},g.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},g.prototype.isInfinity=function(){return this.z.cmpn(0)===0}},480:(fe,x,T)=>{"use strict";var S=x,y=T(7952),p=T(894),I=T(7011),o=I.assert;function m(M){M.type==="short"?this.curve=new p.short(M):M.type==="edwards"?this.curve=new p.edwards(M):this.curve=new p.mont(M),this.g=this.curve.g,this.n=this.curve.n,this.hash=M.hash,o(this.g.validate(),"Invalid curve"),o(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}S.PresetCurve=m;function l(M,E){Object.defineProperty(S,M,{configurable:!0,enumerable:!0,get:function(){var d=new m(E);return Object.defineProperty(S,M,{configurable:!0,enumerable:!0,value:d}),d}})}l("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:y.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),l("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:y.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),l("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:y.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),l("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:y.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"]}),l("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:y.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"]}),l("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:y.sha256,gRed:!1,g:["9"]}),l("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:y.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var g;try{g=T(4011)}catch{g=void 0}l("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:y.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",g]})},7447:(fe,x,T)=>{"use strict";var S=T(8490),y=T(2723),p=T(7011),I=T(480),o=T(5037),m=p.assert,l=T(1200),g=T(8545);function M(E){if(!(this instanceof M))return new M(E);typeof E=="string"&&(m(Object.prototype.hasOwnProperty.call(I,E),"Unknown curve "+E),E=I[E]),E instanceof I.PresetCurve&&(E={curve:E}),this.curve=E.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(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}fe.exports=M,M.prototype.keyPair=function(d){return new l(this,d)},M.prototype.keyFromPrivate=function(d,A){return l.fromPrivate(this,d,A)},M.prototype.keyFromPublic=function(d,A){return l.fromPublic(this,d,A)},M.prototype.genKeyPair=function(d){d||(d={});for(var A=new y({hash:this.hash,pers:d.pers,persEnc:d.persEnc||"utf8",entropy:d.entropy||o(this.hash.hmacStrength),entropyEnc:d.entropy&&d.entropyEnc||"utf8",nonce:this.n.toArray()}),v=this.n.byteLength(),b=this.n.sub(new S(2));;){var k=new S(A.generate(v));if(!(k.cmp(b)>0))return k.iaddn(1),this.keyFromPrivate(k)}},M.prototype._truncateToN=function(d,A){var v=d.byteLength()*8-this.n.bitLength();return v>0&&(d=d.ushrn(v)),!A&&d.cmp(this.n)>=0?d.sub(this.n):d},M.prototype.sign=function(d,A,v,b){typeof v=="object"&&(b=v,v=null),b||(b={}),A=this.keyFromPrivate(A,v),d=this._truncateToN(new S(d,16));for(var k=this.n.byteLength(),B=A.getPrivate().toArray("be",k),U=d.toArray("be",k),C=new y({hash:this.hash,entropy:B,nonce:U,pers:b.pers,persEnc:b.persEnc||"utf8"}),L=this.n.sub(new S(1)),N=0;;N++){var j=b.k?b.k(N):new S(C.generate(this.n.byteLength()));if(j=this._truncateToN(j,!0),!(j.cmpn(1)<=0||j.cmp(L)>=0)){var K=this.g.mul(j);if(!K.isInfinity()){var $=K.getX(),Q=$.umod(this.n);if(Q.cmpn(0)!==0){var Y=j.invm(this.n).mul(Q.mul(A.getPrivate()).iadd(d));if(Y=Y.umod(this.n),Y.cmpn(0)!==0){var ee=(K.getY().isOdd()?1:0)|($.cmp(Q)!==0?2:0);return b.canonical&&Y.cmp(this.nh)>0&&(Y=this.n.sub(Y),ee^=1),new g({r:Q,s:Y,recoveryParam:ee})}}}}}},M.prototype.verify=function(d,A,v,b){d=this._truncateToN(new S(d,16)),v=this.keyFromPublic(v,b),A=new g(A,"hex");var k=A.r,B=A.s;if(k.cmpn(1)<0||k.cmp(this.n)>=0||B.cmpn(1)<0||B.cmp(this.n)>=0)return!1;var U=B.invm(this.n),C=U.mul(d).umod(this.n),L=U.mul(k).umod(this.n),N;return this.curve._maxwellTrick?(N=this.g.jmulAdd(C,v.getPublic(),L),N.isInfinity()?!1:N.eqXToP(k)):(N=this.g.mulAdd(C,v.getPublic(),L),N.isInfinity()?!1:N.getX().umod(this.n).cmp(k)===0)},M.prototype.recoverPubKey=function(E,d,A,v){m((3&A)===A,"The recovery param is more than two bits"),d=new g(d,v);var b=this.n,k=new S(E),B=d.r,U=d.s,C=A&1,L=A>>1;if(B.cmp(this.curve.p.umod(this.curve.n))>=0&&L)throw new Error("Unable to find sencond key candinate");L?B=this.curve.pointFromX(B.add(this.curve.n),C):B=this.curve.pointFromX(B,C);var N=d.r.invm(b),j=b.sub(k).mul(N).umod(b),K=U.mul(N).umod(b);return this.g.mulAdd(j,B,K)},M.prototype.getKeyRecoveryParam=function(E,d,A,v){if(d=new g(d,v),d.recoveryParam!==null)return d.recoveryParam;for(var b=0;b<4;b++){var k;try{k=this.recoverPubKey(E,d,b)}catch{continue}if(k.eq(A))return b}throw new Error("Unable to find valid recovery factor")}},1200:(fe,x,T)=>{"use strict";var S=T(8490),y=T(7011),p=y.assert;function I(o,m){this.ec=o,this.priv=null,this.pub=null,m.priv&&this._importPrivate(m.priv,m.privEnc),m.pub&&this._importPublic(m.pub,m.pubEnc)}fe.exports=I,I.fromPublic=function(m,l,g){return l instanceof I?l:new I(m,{pub:l,pubEnc:g})},I.fromPrivate=function(m,l,g){return l instanceof I?l:new I(m,{priv:l,privEnc:g})},I.prototype.validate=function(){var m=this.getPublic();return m.isInfinity()?{result:!1,reason:"Invalid public key"}:m.validate()?m.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"}},I.prototype.getPublic=function(m,l){return typeof m=="string"&&(l=m,m=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),l?this.pub.encode(l,m):this.pub},I.prototype.getPrivate=function(m){return m==="hex"?this.priv.toString(16,2):this.priv},I.prototype._importPrivate=function(m,l){this.priv=new S(m,l||16),this.priv=this.priv.umod(this.ec.curve.n)},I.prototype._importPublic=function(m,l){if(m.x||m.y){this.ec.curve.type==="mont"?p(m.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&p(m.x&&m.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(m.x,m.y);return}this.pub=this.ec.curve.decodePoint(m,l)},I.prototype.derive=function(m){return m.validate()||p(m.validate(),"public point not validated"),m.mul(this.priv).getX()},I.prototype.sign=function(m,l,g){return this.ec.sign(m,this,l,g)},I.prototype.verify=function(m,l){return this.ec.verify(m,l,this)},I.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"}},8545:(fe,x,T)=>{"use strict";var S=T(8490),y=T(7011),p=y.assert;function I(M,E){if(M instanceof I)return M;this._importDER(M,E)||(p(M.r&&M.s,"Signature without r or s"),this.r=new S(M.r,16),this.s=new S(M.s,16),M.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=M.recoveryParam)}fe.exports=I;function o(){this.place=0}function m(M,E){var d=M[E.place++];if(!(d&128))return d;var A=d&15;if(A===0||A>4)return!1;for(var v=0,b=0,k=E.place;b<A;b++,k++)v<<=8,v|=M[k],v>>>=0;return v<=127?!1:(E.place=k,v)}function l(M){for(var E=0,d=M.length-1;!M[E]&&!(M[E+1]&128)&&E<d;)E++;return E===0?M:M.slice(E)}I.prototype._importDER=function(E,d){E=y.toArray(E,d);var A=new o;if(E[A.place++]!==48)return!1;var v=m(E,A);if(v===!1||v+A.place!==E.length||E[A.place++]!==2)return!1;var b=m(E,A);if(b===!1)return!1;var k=E.slice(A.place,b+A.place);if(A.place+=b,E[A.place++]!==2)return!1;var B=m(E,A);if(B===!1||E.length!==B+A.place)return!1;var U=E.slice(A.place,B+A.place);if(k[0]===0)if(k[1]&128)k=k.slice(1);else return!1;if(U[0]===0)if(U[1]&128)U=U.slice(1);else return!1;return this.r=new S(k),this.s=new S(U),this.recoveryParam=null,!0};function g(M,E){if(E<128){M.push(E);return}var d=1+(Math.log(E)/Math.LN2>>>3);for(M.push(d|128);--d;)M.push(E>>>(d<<3)&255);M.push(E)}I.prototype.toDER=function(E){var d=this.r.toArray(),A=this.s.toArray();for(d[0]&128&&(d=[0].concat(d)),A[0]&128&&(A=[0].concat(A)),d=l(d),A=l(A);!A[0]&&!(A[1]&128);)A=A.slice(1);var v=[2];g(v,d.length),v=v.concat(d),v.push(2),g(v,A.length);var b=v.concat(A),k=[48];return g(k,b.length),k=k.concat(b),y.encode(k,E)}},8650:(fe,x,T)=>{"use strict";var S=T(7952),y=T(480),p=T(7011),I=p.assert,o=p.parseBytes,m=T(6661),l=T(220);function g(M){if(I(M==="ed25519","only tested with ed25519 so far"),!(this instanceof g))return new g(M);M=y[M].curve,this.curve=M,this.g=M.g,this.g.precompute(M.n.bitLength()+1),this.pointClass=M.point().constructor,this.encodingLength=Math.ceil(M.n.bitLength()/8),this.hash=S.sha512}fe.exports=g,g.prototype.sign=function(E,d){E=o(E);var A=this.keyFromSecret(d),v=this.hashInt(A.messagePrefix(),E),b=this.g.mul(v),k=this.encodePoint(b),B=this.hashInt(k,A.pubBytes(),E).mul(A.priv()),U=v.add(B).umod(this.curve.n);return this.makeSignature({R:b,S:U,Rencoded:k})},g.prototype.verify=function(E,d,A){E=o(E),d=this.makeSignature(d);var v=this.keyFromPublic(A),b=this.hashInt(d.Rencoded(),v.pubBytes(),E),k=this.g.mul(d.S()),B=d.R().add(v.pub().mul(b));return B.eq(k)},g.prototype.hashInt=function(){for(var E=this.hash(),d=0;d<arguments.length;d++)E.update(arguments[d]);return p.intFromLE(E.digest()).umod(this.curve.n)},g.prototype.keyFromPublic=function(E){return m.fromPublic(this,E)},g.prototype.keyFromSecret=function(E){return m.fromSecret(this,E)},g.prototype.makeSignature=function(E){return E instanceof l?E:new l(this,E)},g.prototype.encodePoint=function(E){var d=E.getY().toArray("le",this.encodingLength);return d[this.encodingLength-1]|=E.getX().isOdd()?128:0,d},g.prototype.decodePoint=function(E){E=p.parseBytes(E);var d=E.length-1,A=E.slice(0,d).concat(E[d]&-129),v=(E[d]&128)!==0,b=p.intFromLE(A);return this.curve.pointFromY(b,v)},g.prototype.encodeInt=function(E){return E.toArray("le",this.encodingLength)},g.prototype.decodeInt=function(E){return p.intFromLE(E)},g.prototype.isPoint=function(E){return E instanceof this.pointClass}},6661:(fe,x,T)=>{"use strict";var S=T(7011),y=S.assert,p=S.parseBytes,I=S.cachedProperty;function o(m,l){this.eddsa=m,this._secret=p(l.secret),m.isPoint(l.pub)?this._pub=l.pub:this._pubBytes=p(l.pub)}o.fromPublic=function(l,g){return g instanceof o?g:new o(l,{pub:g})},o.fromSecret=function(l,g){return g instanceof o?g:new o(l,{secret:g})},o.prototype.secret=function(){return this._secret},I(o,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),I(o,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),I(o,"privBytes",function(){var l=this.eddsa,g=this.hash(),M=l.encodingLength-1,E=g.slice(0,l.encodingLength);return E[0]&=248,E[M]&=127,E[M]|=64,E}),I(o,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),I(o,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),I(o,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),o.prototype.sign=function(l){return y(this._secret,"KeyPair can only verify"),this.eddsa.sign(l,this)},o.prototype.verify=function(l,g){return this.eddsa.verify(l,g,this)},o.prototype.getSecret=function(l){return y(this._secret,"KeyPair is public only"),S.encode(this.secret(),l)},o.prototype.getPublic=function(l){return S.encode(this.pubBytes(),l)},fe.exports=o},220:(fe,x,T)=>{"use strict";var S=T(8490),y=T(7011),p=y.assert,I=y.cachedProperty,o=y.parseBytes;function m(l,g){this.eddsa=l,typeof g!="object"&&(g=o(g)),Array.isArray(g)&&(g={R:g.slice(0,l.encodingLength),S:g.slice(l.encodingLength)}),p(g.R&&g.S,"Signature without R or S"),l.isPoint(g.R)&&(this._R=g.R),g.S instanceof S&&(this._S=g.S),this._Rencoded=Array.isArray(g.R)?g.R:g.Rencoded,this._Sencoded=Array.isArray(g.S)?g.S:g.Sencoded}I(m,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),I(m,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),I(m,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),I(m,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),m.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},m.prototype.toHex=function(){return y.encode(this.toBytes(),"hex").toUpperCase()},fe.exports=m},4011:fe=>{fe.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"]]}}},7011:(fe,x,T)=>{"use strict";var S=x,y=T(8490),p=T(3349),I=T(4367);S.assert=p,S.toArray=I.toArray,S.zero2=I.zero2,S.toHex=I.toHex,S.encode=I.encode;function o(E,d,A){var v=new Array(Math.max(E.bitLength(),A)+1);v.fill(0);for(var b=1<<d+1,k=E.clone(),B=0;B<v.length;B++){var U,C=k.andln(b-1);k.isOdd()?(C>(b>>1)-1?U=(b>>1)-C:U=C,k.isubn(U)):U=0,v[B]=U,k.iushrn(1)}return v}S.getNAF=o;function m(E,d){var A=[[],[]];E=E.clone(),d=d.clone();for(var v=0,b=0,k;E.cmpn(-v)>0||d.cmpn(-b)>0;){var B=E.andln(3)+v&3,U=d.andln(3)+b&3;B===3&&(B=-1),U===3&&(U=-1);var C;B&1?(k=E.andln(7)+v&7,(k===3||k===5)&&U===2?C=-B:C=B):C=0,A[0].push(C);var L;U&1?(k=d.andln(7)+b&7,(k===3||k===5)&&B===2?L=-U:L=U):L=0,A[1].push(L),2*v===C+1&&(v=1-v),2*b===L+1&&(b=1-b),E.iushrn(1),d.iushrn(1)}return A}S.getJSF=m;function l(E,d,A){var v="_"+d;E.prototype[d]=function(){return this[v]!==void 0?this[v]:this[v]=A.call(this)}}S.cachedProperty=l;function g(E){return typeof E=="string"?S.toArray(E,"hex"):E}S.parseBytes=g;function M(E){return new y(E,"hex","le")}S.intFromLE=M},8490:function(fe,x,T){fe=T.nmd(fe),function(S,y){"use strict";function p(u,e){if(!u)throw new Error(e||"Assertion failed")}function I(u,e){u.super_=e;var r=function(){};r.prototype=e.prototype,u.prototype=new r,u.prototype.constructor=u}function o(u,e,r){if(o.isBN(u))return u;this.negative=0,this.words=null,this.length=0,this.red=null,u!==null&&((e==="le"||e==="be")&&(r=e,e=10),this._init(u||0,e||10,r||"be"))}typeof S=="object"?S.exports=o:y.BN=o,o.BN=o,o.wordSize=26;var m;try{typeof window<"u"&&typeof window.Buffer<"u"?m=window.Buffer:m=T(9368).Buffer}catch{}o.isBN=function(e){return e instanceof o?!0:e!==null&&typeof e=="object"&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,r){return e.cmp(r)>0?e:r},o.min=function(e,r){return e.cmp(r)<0?e:r},o.prototype._init=function(e,r,n){if(typeof e=="number")return this._initNumber(e,r,n);if(typeof e=="object")return this._initArray(e,r,n);r==="hex"&&(r=16),p(r===(r|0)&&r>=2&&r<=36),e=e.toString().replace(/\s+/g,"");var i=0;e[0]==="-"&&(i++,this.negative=1),i<e.length&&(r===16?this._parseHex(e,i,n):(this._parseBase(e,r,i),n==="le"&&this._initArray(this.toArray(),r,n)))},o.prototype._initNumber=function(e,r,n){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[e&67108863],this.length=1):e<4503599627370496?(this.words=[e&67108863,e/67108864&67108863],this.length=2):(p(e<9007199254740992),this.words=[e&67108863,e/67108864&67108863,1],this.length=3),n==="le"&&this._initArray(this.toArray(),r,n)},o.prototype._initArray=function(e,r,n){if(p(typeof e.length=="number"),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<this.length;i++)this.words[i]=0;var f,c,h=0;if(n==="be")for(i=e.length-1,f=0;i>=0;i-=3)c=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[f]|=c<<h&67108863,this.words[f+1]=c>>>26-h&67108863,h+=24,h>=26&&(h-=26,f++);else if(n==="le")for(i=0,f=0;i<e.length;i+=3)c=e[i]|e[i+1]<<8|e[i+2]<<16,this.words[f]|=c<<h&67108863,this.words[f+1]=c>>>26-h&67108863,h+=24,h>=26&&(h-=26,f++);return this.strip()};function l(u,e){var r=u.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function g(u,e,r){var n=l(u,r);return r-1>=e&&(n|=l(u,r-1)<<4),n}o.prototype._parseHex=function(e,r,n){this.length=Math.ceil((e.length-r)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var f=0,c=0,h;if(n==="be")for(i=e.length-1;i>=r;i-=2)h=g(e,r,i)<<f,this.words[c]|=h&67108863,f>=18?(f-=18,c+=1,this.words[c]|=h>>>26):f+=8;else{var s=e.length-r;for(i=s%2===0?r+1:r;i<e.length;i+=2)h=g(e,r,i)<<f,this.words[c]|=h&67108863,f>=18?(f-=18,c+=1,this.words[c]|=h>>>26):f+=8}this.strip()};function M(u,e,r,n){for(var i=0,f=Math.min(u.length,r),c=e;c<f;c++){var h=u.charCodeAt(c)-48;i*=n,h>=49?i+=h-49+10:h>=17?i+=h-17+10:i+=h}return i}o.prototype._parseBase=function(e,r,n){this.words=[0],this.length=1;for(var i=0,f=1;f<=67108863;f*=r)i++;i--,f=f/r|0;for(var c=e.length-n,h=c%i,s=Math.min(c,c-h)+n,t=0,a=n;a<s;a+=i)t=M(e,a,a+i,r),this.imuln(f),this.words[0]+t<67108864?this.words[0]+=t:this._iaddn(t);if(h!==0){var w=1;for(t=M(e,a,e.length,r),a=0;a<h;a++)w*=r;this.imuln(w),this.words[0]+t<67108864?this.words[0]+=t:this._iaddn(t)}this.strip()},o.prototype.copy=function(e){e.words=new Array(this.length);for(var r=0;r<this.length;r++)e.words[r]=this.words[r];e.length=this.length,e.negative=this.negative,e.red=this.red},o.prototype.clone=function(){var e=new o(null);return this.copy(e),e},o.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},o.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},o.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var E=["","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"],d=[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],A=[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];o.prototype.toString=function(e,r){e=e||10,r=r|0||1;var n;if(e===16||e==="hex"){n="";for(var i=0,f=0,c=0;c<this.length;c++){var h=this.words[c],s=((h<<i|f)&16777215).toString(16);f=h>>>24-i&16777215,f!==0||c!==this.length-1?n=E[6-s.length]+s+n:n=s+n,i+=2,i>=26&&(i-=26,c--)}for(f!==0&&(n=f.toString(16)+n);n.length%r!==0;)n="0"+n;return this.negative!==0&&(n="-"+n),n}if(e===(e|0)&&e>=2&&e<=36){var t=d[e],a=A[e];n="";var w=this.clone();for(w.negative=0;!w.isZero();){var D=w.modn(a).toString(e);w=w.idivn(a),w.isZero()?n=D+n:n=E[t-D.length]+D+n}for(this.isZero()&&(n="0"+n);n.length%r!==0;)n="0"+n;return this.negative!==0&&(n="-"+n),n}p(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return this.length===2?e+=this.words[1]*67108864:this.length===3&&this.words[2]===1?e+=4503599627370496+this.words[1]*67108864:this.length>2&&p(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,r){return p(typeof m<"u"),this.toArrayLike(m,e,r)},o.prototype.toArray=function(e,r){return this.toArrayLike(Array,e,r)},o.prototype.toArrayLike=function(e,r,n){var i=this.byteLength(),f=n||Math.max(1,i);p(i<=f,"byte array longer than desired length"),p(f>0,"Requested array length <= 0"),this.strip();var c=r==="le",h=new e(f),s,t,a=this.clone();if(c){for(t=0;!a.isZero();t++)s=a.andln(255),a.iushrn(8),h[t]=s;for(;t<f;t++)h[t]=0}else{for(t=0;t<f-i;t++)h[t]=0;for(t=0;!a.isZero();t++)s=a.andln(255),a.iushrn(8),h[f-t-1]=s}return h},Math.clz32?o.prototype._countBits=function(e){return 32-Math.clz32(e)}:o.prototype._countBits=function(e){var r=e,n=0;return r>=4096&&(n+=13,r>>>=13),r>=64&&(n+=7,r>>>=7),r>=8&&(n+=4,r>>>=4),r>=2&&(n+=2,r>>>=2),n+r},o.prototype._zeroBits=function(e){if(e===0)return 26;var r=e,n=0;return r&8191||(n+=13,r>>>=13),r&127||(n+=7,r>>>=7),r&15||(n+=4,r>>>=4),r&3||(n+=2,r>>>=2),r&1||n++,n},o.prototype.bitLength=function(){var e=this.words[this.length-1],r=this._countBits(e);return(this.length-1)*26+r};function v(u){for(var e=new Array(u.bitLength()),r=0;r<e.length;r++){var n=r/26|0,i=r%26;e[r]=(u.words[n]&1<<i)>>>i}return e}o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,r=0;r<this.length;r++){var n=this._zeroBits(this.words[r]);if(e+=n,n!==26)break}return e},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(e){return this.negative!==0?this.abs().inotn(e).iaddn(1):this.clone()},o.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return this.negative!==0},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]|e.words[r];return this.strip()},o.prototype.ior=function(e){return p((this.negative|e.negative)===0),this.iuor(e)},o.prototype.or=function(e){return this.length>e.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 r;this.length>e.length?r=e:r=this;for(var n=0;n<r.length;n++)this.words[n]=this.words[n]&e.words[n];return this.length=r.length,this.strip()},o.prototype.iand=function(e){return p((this.negative|e.negative)===0),this.iuand(e)},o.prototype.and=function(e){return this.length>e.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 r,n;this.length>e.length?(r=this,n=e):(r=e,n=this);for(var i=0;i<n.length;i++)this.words[i]=r.words[i]^n.words[i];if(this!==r)for(;i<r.length;i++)this.words[i]=r.words[i];return this.length=r.length,this.strip()},o.prototype.ixor=function(e){return p((this.negative|e.negative)===0),this.iuxor(e)},o.prototype.xor=function(e){return this.length>e.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){p(typeof e=="number"&&e>=0);var r=Math.ceil(e/26)|0,n=e%26;this._expand(r),n>0&&r--;for(var i=0;i<r;i++)this.words[i]=~this.words[i]&67108863;return n>0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,r){p(typeof e=="number"&&e>=0);var n=e/26|0,i=e%26;return this._expand(n+1),r?this.words[n]=this.words[n]|1<<i:this.words[n]=this.words[n]&~(1<<i),this.strip()},o.prototype.iadd=function(e){var r;if(this.negative!==0&&e.negative===0)return this.negative=0,r=this.isub(e),this.negative^=1,this._normSign();if(this.negative===0&&e.negative!==0)return e.negative=0,r=this.isub(e),e.negative=1,r._normSign();var n,i;this.length>e.length?(n=this,i=e):(n=e,i=this);for(var f=0,c=0;c<i.length;c++)r=(n.words[c]|0)+(i.words[c]|0)+f,this.words[c]=r&67108863,f=r>>>26;for(;f!==0&&c<n.length;c++)r=(n.words[c]|0)+f,this.words[c]=r&67108863,f=r>>>26;if(this.length=n.length,f!==0)this.words[this.length]=f,this.length++;else if(n!==this)for(;c<n.length;c++)this.words[c]=n.words[c];return this},o.prototype.add=function(e){var r;return e.negative!==0&&this.negative===0?(e.negative=0,r=this.sub(e),e.negative^=1,r):e.negative===0&&this.negative!==0?(this.negative=0,r=e.sub(this),this.negative=1,r):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(e.negative!==0){e.negative=0;var r=this.iadd(e);return e.negative=1,r._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var n=this.cmp(e);if(n===0)return this.negative=0,this.length=1,this.words[0]=0,this;var i,f;n>0?(i=this,f=e):(i=e,f=this);for(var c=0,h=0;h<f.length;h++)r=(i.words[h]|0)-(f.words[h]|0)+c,c=r>>26,this.words[h]=r&67108863;for(;c!==0&&h<i.length;h++)r=(i.words[h]|0)+c,c=r>>26,this.words[h]=r&67108863;if(c===0&&h<i.length&&i!==this)for(;h<i.length;h++)this.words[h]=i.words[h];return this.length=Math.max(this.length,h),i!==this&&(this.negative=1),this.strip()},o.prototype.sub=function(e){return this.clone().isub(e)};function b(u,e,r){r.negative=e.negative^u.negative;var n=u.length+e.length|0;r.length=n,n=n-1|0;var i=u.words[0]|0,f=e.words[0]|0,c=i*f,h=c&67108863,s=c/67108864|0;r.words[0]=h;for(var t=1;t<n;t++){for(var a=s>>>26,w=s&67108863,D=Math.min(t,e.length-1),Z=Math.max(0,t-u.length+1);Z<=D;Z++){var F=t-Z|0;i=u.words[F]|0,f=e.words[Z]|0,c=i*f+w,a+=c/67108864|0,w=c&67108863}r.words[t]=w|0,s=a|0}return s!==0?r.words[t]=s|0:r.length--,r.strip()}var k=function(e,r,n){var i=e.words,f=r.words,c=n.words,h=0,s,t,a,w=i[0]|0,D=w&8191,Z=w>>>13,F=i[1]|0,V=F&8191,q=F>>>13,re=i[2]|0,G=re&8191,H=re>>>13,oe=i[3]|0,ue=oe&8191,be=oe>>>13,ie=i[4]|0,J=ie&8191,pe=ie>>>13,Ge=i[5]|0,ce=Ge&8191,te=Ge>>>13,le=i[6]|0,ge=le&8191,Pe=le>>>13,lt=i[7]|0,Le=lt&8191,ze=lt>>>13,kt=i[8]|0,ae=kt&8191,he=kt>>>13,je=i[9]|0,Ie=je&8191,Ce=je>>>13,ut=f[0]|0,De=ut&8191,ye=ut>>>13,we=f[1]|0,ve=we&8191,Ee=we>>>13,rt=f[2]|0,Fe=rt&8191,He=rt>>>13,yt=f[3]|0,Ke=yt&8191,Ze=yt>>>13,At=f[4]|0,Ve=At&8191,tt=At>>>13,qt=f[5]|0,et=qt&8191,st=qt>>>13,rr=f[6]|0,at=rr&8191,ft=rr>>>13,Qe=f[7]|0,xe=Qe&8191,Oe=Qe>>>13,ht=f[8]|0,Ne=ht&8191,qe=ht>>>13,Dt=f[9]|0,Xe=Dt&8191,ot=Dt>>>13;n.negative=e.negative^r.negative,n.length=19,s=Math.imul(D,De),t=Math.imul(D,ye),t=t+Math.imul(Z,De)|0,a=Math.imul(Z,ye);var Gt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,s=Math.imul(V,De),t=Math.imul(V,ye),t=t+Math.imul(q,De)|0,a=Math.imul(q,ye),s=s+Math.imul(D,ve)|0,t=t+Math.imul(D,Ee)|0,t=t+Math.imul(Z,ve)|0,a=a+Math.imul(Z,Ee)|0;var xt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(xt>>>26)|0,xt&=67108863,s=Math.imul(G,De),t=Math.imul(G,ye),t=t+Math.imul(H,De)|0,a=Math.imul(H,ye),s=s+Math.imul(V,ve)|0,t=t+Math.imul(V,Ee)|0,t=t+Math.imul(q,ve)|0,a=a+Math.imul(q,Ee)|0,s=s+Math.imul(D,Fe)|0,t=t+Math.imul(D,He)|0,t=t+Math.imul(Z,Fe)|0,a=a+Math.imul(Z,He)|0;var gt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(gt>>>26)|0,gt&=67108863,s=Math.imul(ue,De),t=Math.imul(ue,ye),t=t+Math.imul(be,De)|0,a=Math.imul(be,ye),s=s+Math.imul(G,ve)|0,t=t+Math.imul(G,Ee)|0,t=t+Math.imul(H,ve)|0,a=a+Math.imul(H,Ee)|0,s=s+Math.imul(V,Fe)|0,t=t+Math.imul(V,He)|0,t=t+Math.imul(q,Fe)|0,a=a+Math.imul(q,He)|0,s=s+Math.imul(D,Ke)|0,t=t+Math.imul(D,Ze)|0,t=t+Math.imul(Z,Ke)|0,a=a+Math.imul(Z,Ze)|0;var bt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(bt>>>26)|0,bt&=67108863,s=Math.imul(J,De),t=Math.imul(J,ye),t=t+Math.imul(pe,De)|0,a=Math.imul(pe,ye),s=s+Math.imul(ue,ve)|0,t=t+Math.imul(ue,Ee)|0,t=t+Math.imul(be,ve)|0,a=a+Math.imul(be,Ee)|0,s=s+Math.imul(G,Fe)|0,t=t+Math.imul(G,He)|0,t=t+Math.imul(H,Fe)|0,a=a+Math.imul(H,He)|0,s=s+Math.imul(V,Ke)|0,t=t+Math.imul(V,Ze)|0,t=t+Math.imul(q,Ke)|0,a=a+Math.imul(q,Ze)|0,s=s+Math.imul(D,Ve)|0,t=t+Math.imul(D,tt)|0,t=t+Math.imul(Z,Ve)|0,a=a+Math.imul(Z,tt)|0;var Tt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,s=Math.imul(ce,De),t=Math.imul(ce,ye),t=t+Math.imul(te,De)|0,a=Math.imul(te,ye),s=s+Math.imul(J,ve)|0,t=t+Math.imul(J,Ee)|0,t=t+Math.imul(pe,ve)|0,a=a+Math.imul(pe,Ee)|0,s=s+Math.imul(ue,Fe)|0,t=t+Math.imul(ue,He)|0,t=t+Math.imul(be,Fe)|0,a=a+Math.imul(be,He)|0,s=s+Math.imul(G,Ke)|0,t=t+Math.imul(G,Ze)|0,t=t+Math.imul(H,Ke)|0,a=a+Math.imul(H,Ze)|0,s=s+Math.imul(V,Ve)|0,t=t+Math.imul(V,tt)|0,t=t+Math.imul(q,Ve)|0,a=a+Math.imul(q,tt)|0,s=s+Math.imul(D,et)|0,t=t+Math.imul(D,st)|0,t=t+Math.imul(Z,et)|0,a=a+Math.imul(Z,st)|0;var Ct=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,s=Math.imul(ge,De),t=Math.imul(ge,ye),t=t+Math.imul(Pe,De)|0,a=Math.imul(Pe,ye),s=s+Math.imul(ce,ve)|0,t=t+Math.imul(ce,Ee)|0,t=t+Math.imul(te,ve)|0,a=a+Math.imul(te,Ee)|0,s=s+Math.imul(J,Fe)|0,t=t+Math.imul(J,He)|0,t=t+Math.imul(pe,Fe)|0,a=a+Math.imul(pe,He)|0,s=s+Math.imul(ue,Ke)|0,t=t+Math.imul(ue,Ze)|0,t=t+Math.imul(be,Ke)|0,a=a+Math.imul(be,Ze)|0,s=s+Math.imul(G,Ve)|0,t=t+Math.imul(G,tt)|0,t=t+Math.imul(H,Ve)|0,a=a+Math.imul(H,tt)|0,s=s+Math.imul(V,et)|0,t=t+Math.imul(V,st)|0,t=t+Math.imul(q,et)|0,a=a+Math.imul(q,st)|0,s=s+Math.imul(D,at)|0,t=t+Math.imul(D,ft)|0,t=t+Math.imul(Z,at)|0,a=a+Math.imul(Z,ft)|0;var Xt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Xt>>>26)|0,Xt&=67108863,s=Math.imul(Le,De),t=Math.imul(Le,ye),t=t+Math.imul(ze,De)|0,a=Math.imul(ze,ye),s=s+Math.imul(ge,ve)|0,t=t+Math.imul(ge,Ee)|0,t=t+Math.imul(Pe,ve)|0,a=a+Math.imul(Pe,Ee)|0,s=s+Math.imul(ce,Fe)|0,t=t+Math.imul(ce,He)|0,t=t+Math.imul(te,Fe)|0,a=a+Math.imul(te,He)|0,s=s+Math.imul(J,Ke)|0,t=t+Math.imul(J,Ze)|0,t=t+Math.imul(pe,Ke)|0,a=a+Math.imul(pe,Ze)|0,s=s+Math.imul(ue,Ve)|0,t=t+Math.imul(ue,tt)|0,t=t+Math.imul(be,Ve)|0,a=a+Math.imul(be,tt)|0,s=s+Math.imul(G,et)|0,t=t+Math.imul(G,st)|0,t=t+Math.imul(H,et)|0,a=a+Math.imul(H,st)|0,s=s+Math.imul(V,at)|0,t=t+Math.imul(V,ft)|0,t=t+Math.imul(q,at)|0,a=a+Math.imul(q,ft)|0,s=s+Math.imul(D,xe)|0,t=t+Math.imul(D,Oe)|0,t=t+Math.imul(Z,xe)|0,a=a+Math.imul(Z,Oe)|0;var Yt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Yt>>>26)|0,Yt&=67108863,s=Math.imul(ae,De),t=Math.imul(ae,ye),t=t+Math.imul(he,De)|0,a=Math.imul(he,ye),s=s+Math.imul(Le,ve)|0,t=t+Math.imul(Le,Ee)|0,t=t+Math.imul(ze,ve)|0,a=a+Math.imul(ze,Ee)|0,s=s+Math.imul(ge,Fe)|0,t=t+Math.imul(ge,He)|0,t=t+Math.imul(Pe,Fe)|0,a=a+Math.imul(Pe,He)|0,s=s+Math.imul(ce,Ke)|0,t=t+Math.imul(ce,Ze)|0,t=t+Math.imul(te,Ke)|0,a=a+Math.imul(te,Ze)|0,s=s+Math.imul(J,Ve)|0,t=t+Math.imul(J,tt)|0,t=t+Math.imul(pe,Ve)|0,a=a+Math.imul(pe,tt)|0,s=s+Math.imul(ue,et)|0,t=t+Math.imul(ue,st)|0,t=t+Math.imul(be,et)|0,a=a+Math.imul(be,st)|0,s=s+Math.imul(G,at)|0,t=t+Math.imul(G,ft)|0,t=t+Math.imul(H,at)|0,a=a+Math.imul(H,ft)|0,s=s+Math.imul(V,xe)|0,t=t+Math.imul(V,Oe)|0,t=t+Math.imul(q,xe)|0,a=a+Math.imul(q,Oe)|0,s=s+Math.imul(D,Ne)|0,t=t+Math.imul(D,qe)|0,t=t+Math.imul(Z,Ne)|0,a=a+Math.imul(Z,qe)|0;var ar=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(ar>>>26)|0,ar&=67108863,s=Math.imul(Ie,De),t=Math.imul(Ie,ye),t=t+Math.imul(Ce,De)|0,a=Math.imul(Ce,ye),s=s+Math.imul(ae,ve)|0,t=t+Math.imul(ae,Ee)|0,t=t+Math.imul(he,ve)|0,a=a+Math.imul(he,Ee)|0,s=s+Math.imul(Le,Fe)|0,t=t+Math.imul(Le,He)|0,t=t+Math.imul(ze,Fe)|0,a=a+Math.imul(ze,He)|0,s=s+Math.imul(ge,Ke)|0,t=t+Math.imul(ge,Ze)|0,t=t+Math.imul(Pe,Ke)|0,a=a+Math.imul(Pe,Ze)|0,s=s+Math.imul(ce,Ve)|0,t=t+Math.imul(ce,tt)|0,t=t+Math.imul(te,Ve)|0,a=a+Math.imul(te,tt)|0,s=s+Math.imul(J,et)|0,t=t+Math.imul(J,st)|0,t=t+Math.imul(pe,et)|0,a=a+Math.imul(pe,st)|0,s=s+Math.imul(ue,at)|0,t=t+Math.imul(ue,ft)|0,t=t+Math.imul(be,at)|0,a=a+Math.imul(be,ft)|0,s=s+Math.imul(G,xe)|0,t=t+Math.imul(G,Oe)|0,t=t+Math.imul(H,xe)|0,a=a+Math.imul(H,Oe)|0,s=s+Math.imul(V,Ne)|0,t=t+Math.imul(V,qe)|0,t=t+Math.imul(q,Ne)|0,a=a+Math.imul(q,qe)|0,s=s+Math.imul(D,Xe)|0,t=t+Math.imul(D,ot)|0,t=t+Math.imul(Z,Xe)|0,a=a+Math.imul(Z,ot)|0;var or=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(or>>>26)|0,or&=67108863,s=Math.imul(Ie,ve),t=Math.imul(Ie,Ee),t=t+Math.imul(Ce,ve)|0,a=Math.imul(Ce,Ee),s=s+Math.imul(ae,Fe)|0,t=t+Math.imul(ae,He)|0,t=t+Math.imul(he,Fe)|0,a=a+Math.imul(he,He)|0,s=s+Math.imul(Le,Ke)|0,t=t+Math.imul(Le,Ze)|0,t=t+Math.imul(ze,Ke)|0,a=a+Math.imul(ze,Ze)|0,s=s+Math.imul(ge,Ve)|0,t=t+Math.imul(ge,tt)|0,t=t+Math.imul(Pe,Ve)|0,a=a+Math.imul(Pe,tt)|0,s=s+Math.imul(ce,et)|0,t=t+Math.imul(ce,st)|0,t=t+Math.imul(te,et)|0,a=a+Math.imul(te,st)|0,s=s+Math.imul(J,at)|0,t=t+Math.imul(J,ft)|0,t=t+Math.imul(pe,at)|0,a=a+Math.imul(pe,ft)|0,s=s+Math.imul(ue,xe)|0,t=t+Math.imul(ue,Oe)|0,t=t+Math.imul(be,xe)|0,a=a+Math.imul(be,Oe)|0,s=s+Math.imul(G,Ne)|0,t=t+Math.imul(G,qe)|0,t=t+Math.imul(H,Ne)|0,a=a+Math.imul(H,qe)|0,s=s+Math.imul(V,Xe)|0,t=t+Math.imul(V,ot)|0,t=t+Math.imul(q,Xe)|0,a=a+Math.imul(q,ot)|0;var sr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(sr>>>26)|0,sr&=67108863,s=Math.imul(Ie,Fe),t=Math.imul(Ie,He),t=t+Math.imul(Ce,Fe)|0,a=Math.imul(Ce,He),s=s+Math.imul(ae,Ke)|0,t=t+Math.imul(ae,Ze)|0,t=t+Math.imul(he,Ke)|0,a=a+Math.imul(he,Ze)|0,s=s+Math.imul(Le,Ve)|0,t=t+Math.imul(Le,tt)|0,t=t+Math.imul(ze,Ve)|0,a=a+Math.imul(ze,tt)|0,s=s+Math.imul(ge,et)|0,t=t+Math.imul(ge,st)|0,t=t+Math.imul(Pe,et)|0,a=a+Math.imul(Pe,st)|0,s=s+Math.imul(ce,at)|0,t=t+Math.imul(ce,ft)|0,t=t+Math.imul(te,at)|0,a=a+Math.imul(te,ft)|0,s=s+Math.imul(J,xe)|0,t=t+Math.imul(J,Oe)|0,t=t+Math.imul(pe,xe)|0,a=a+Math.imul(pe,Oe)|0,s=s+Math.imul(ue,Ne)|0,t=t+Math.imul(ue,qe)|0,t=t+Math.imul(be,Ne)|0,a=a+Math.imul(be,qe)|0,s=s+Math.imul(G,Xe)|0,t=t+Math.imul(G,ot)|0,t=t+Math.imul(H,Xe)|0,a=a+Math.imul(H,ot)|0;var $t=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+($t>>>26)|0,$t&=67108863,s=Math.imul(Ie,Ke),t=Math.imul(Ie,Ze),t=t+Math.imul(Ce,Ke)|0,a=Math.imul(Ce,Ze),s=s+Math.imul(ae,Ve)|0,t=t+Math.imul(ae,tt)|0,t=t+Math.imul(he,Ve)|0,a=a+Math.imul(he,tt)|0,s=s+Math.imul(Le,et)|0,t=t+Math.imul(Le,st)|0,t=t+Math.imul(ze,et)|0,a=a+Math.imul(ze,st)|0,s=s+Math.imul(ge,at)|0,t=t+Math.imul(ge,ft)|0,t=t+Math.imul(Pe,at)|0,a=a+Math.imul(Pe,ft)|0,s=s+Math.imul(ce,xe)|0,t=t+Math.imul(ce,Oe)|0,t=t+Math.imul(te,xe)|0,a=a+Math.imul(te,Oe)|0,s=s+Math.imul(J,Ne)|0,t=t+Math.imul(J,qe)|0,t=t+Math.imul(pe,Ne)|0,a=a+Math.imul(pe,qe)|0,s=s+Math.imul(ue,Xe)|0,t=t+Math.imul(ue,ot)|0,t=t+Math.imul(be,Xe)|0,a=a+Math.imul(be,ot)|0;var nr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(nr>>>26)|0,nr&=67108863,s=Math.imul(Ie,Ve),t=Math.imul(Ie,tt),t=t+Math.imul(Ce,Ve)|0,a=Math.imul(Ce,tt),s=s+Math.imul(ae,et)|0,t=t+Math.imul(ae,st)|0,t=t+Math.imul(he,et)|0,a=a+Math.imul(he,st)|0,s=s+Math.imul(Le,at)|0,t=t+Math.imul(Le,ft)|0,t=t+Math.imul(ze,at)|0,a=a+Math.imul(ze,ft)|0,s=s+Math.imul(ge,xe)|0,t=t+Math.imul(ge,Oe)|0,t=t+Math.imul(Pe,xe)|0,a=a+Math.imul(Pe,Oe)|0,s=s+Math.imul(ce,Ne)|0,t=t+Math.imul(ce,qe)|0,t=t+Math.imul(te,Ne)|0,a=a+Math.imul(te,qe)|0,s=s+Math.imul(J,Xe)|0,t=t+Math.imul(J,ot)|0,t=t+Math.imul(pe,Xe)|0,a=a+Math.imul(pe,ot)|0;var fr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(fr>>>26)|0,fr&=67108863,s=Math.imul(Ie,et),t=Math.imul(Ie,st),t=t+Math.imul(Ce,et)|0,a=Math.imul(Ce,st),s=s+Math.imul(ae,at)|0,t=t+Math.imul(ae,ft)|0,t=t+Math.imul(he,at)|0,a=a+Math.imul(he,ft)|0,s=s+Math.imul(Le,xe)|0,t=t+Math.imul(Le,Oe)|0,t=t+Math.imul(ze,xe)|0,a=a+Math.imul(ze,Oe)|0,s=s+Math.imul(ge,Ne)|0,t=t+Math.imul(ge,qe)|0,t=t+Math.imul(Pe,Ne)|0,a=a+Math.imul(Pe,qe)|0,s=s+Math.imul(ce,Xe)|0,t=t+Math.imul(ce,ot)|0,t=t+Math.imul(te,Xe)|0,a=a+Math.imul(te,ot)|0;var lr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(lr>>>26)|0,lr&=67108863,s=Math.imul(Ie,at),t=Math.imul(Ie,ft),t=t+Math.imul(Ce,at)|0,a=Math.imul(Ce,ft),s=s+Math.imul(ae,xe)|0,t=t+Math.imul(ae,Oe)|0,t=t+Math.imul(he,xe)|0,a=a+Math.imul(he,Oe)|0,s=s+Math.imul(Le,Ne)|0,t=t+Math.imul(Le,qe)|0,t=t+Math.imul(ze,Ne)|0,a=a+Math.imul(ze,qe)|0,s=s+Math.imul(ge,Xe)|0,t=t+Math.imul(ge,ot)|0,t=t+Math.imul(Pe,Xe)|0,a=a+Math.imul(Pe,ot)|0;var dr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(dr>>>26)|0,dr&=67108863,s=Math.imul(Ie,xe),t=Math.imul(Ie,Oe),t=t+Math.imul(Ce,xe)|0,a=Math.imul(Ce,Oe),s=s+Math.imul(ae,Ne)|0,t=t+Math.imul(ae,qe)|0,t=t+Math.imul(he,Ne)|0,a=a+Math.imul(he,qe)|0,s=s+Math.imul(Le,Xe)|0,t=t+Math.imul(Le,ot)|0,t=t+Math.imul(ze,Xe)|0,a=a+Math.imul(ze,ot)|0;var cr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(cr>>>26)|0,cr&=67108863,s=Math.imul(Ie,Ne),t=Math.imul(Ie,qe),t=t+Math.imul(Ce,Ne)|0,a=Math.imul(Ce,qe),s=s+Math.imul(ae,Xe)|0,t=t+Math.imul(ae,ot)|0,t=t+Math.imul(he,Xe)|0,a=a+Math.imul(he,ot)|0;var gr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(gr>>>26)|0,gr&=67108863,s=Math.imul(Ie,Xe),t=Math.imul(Ie,ot),t=t+Math.imul(Ce,Xe)|0,a=Math.imul(Ce,ot);var pr=(h+s|0)+((t&8191)<<13)|0;return h=(a+(t>>>13)|0)+(pr>>>26)|0,pr&=67108863,c[0]=Gt,c[1]=xt,c[2]=gt,c[3]=bt,c[4]=Tt,c[5]=Ct,c[6]=Xt,c[7]=Yt,c[8]=ar,c[9]=or,c[10]=sr,c[11]=$t,c[12]=nr,c[13]=fr,c[14]=lr,c[15]=dr,c[16]=cr,c[17]=gr,c[18]=pr,h!==0&&(c[19]=h,n.length++),n};Math.imul||(k=b);function B(u,e,r){r.negative=e.negative^u.negative,r.length=u.length+e.length;for(var n=0,i=0,f=0;f<r.length-1;f++){var c=i;i=0;for(var h=n&67108863,s=Math.min(f,e.length-1),t=Math.max(0,f-u.length+1);t<=s;t++){var a=f-t,w=u.words[a]|0,D=e.words[t]|0,Z=w*D,F=Z&67108863;c=c+(Z/67108864|0)|0,F=F+h|0,h=F&67108863,c=c+(F>>>26)|0,i+=c>>>26,c&=67108863}r.words[f]=h,n=c,c=i}return n!==0?r.words[f]=n:r.length--,r.strip()}function U(u,e,r){var n=new C;return n.mulp(u,e,r)}o.prototype.mulTo=function(e,r){var n,i=this.length+e.length;return this.length===10&&e.length===10?n=k(this,e,r):i<63?n=b(this,e,r):i<1024?n=B(this,e,r):n=U(this,e,r),n};function C(u,e){this.x=u,this.y=e}C.prototype.makeRBT=function(e){for(var r=new Array(e),n=o.prototype._countBits(e)-1,i=0;i<e;i++)r[i]=this.revBin(i,n,e);return r},C.prototype.revBin=function(e,r,n){if(e===0||e===n-1)return e;for(var i=0,f=0;f<r;f++)i|=(e&1)<<r-f-1,e>>=1;return i},C.prototype.permute=function(e,r,n,i,f,c){for(var h=0;h<c;h++)i[h]=r[e[h]],f[h]=n[e[h]]},C.prototype.transform=function(e,r,n,i,f,c){this.permute(c,e,r,n,i,f);for(var h=1;h<f;h<<=1)for(var s=h<<1,t=Math.cos(2*Math.PI/s),a=Math.sin(2*Math.PI/s),w=0;w<f;w+=s)for(var D=t,Z=a,F=0;F<h;F++){var V=n[w+F],q=i[w+F],re=n[w+F+h],G=i[w+F+h],H=D*re-Z*G;G=D*G+Z*re,re=H,n[w+F]=V+re,i[w+F]=q+G,n[w+F+h]=V-re,i[w+F+h]=q-G,F!==s&&(H=t*D-a*Z,Z=t*Z+a*D,D=H)}},C.prototype.guessLen13b=function(e,r){var n=Math.max(r,e)|1,i=n&1,f=0;for(n=n/2|0;n;n=n>>>1)f++;return 1<<f+1+i},C.prototype.conjugate=function(e,r,n){if(!(n<=1))for(var i=0;i<n/2;i++){var f=e[i];e[i]=e[n-i-1],e[n-i-1]=f,f=r[i],r[i]=-r[n-i-1],r[n-i-1]=-f}},C.prototype.normalize13b=function(e,r){for(var n=0,i=0;i<r/2;i++){var f=Math.round(e[2*i+1]/r)*8192+Math.round(e[2*i]/r)+n;e[i]=f&67108863,f<67108864?n=0:n=f/67108864|0}return e},C.prototype.convert13b=function(e,r,n,i){for(var f=0,c=0;c<r;c++)f=f+(e[c]|0),n[2*c]=f&8191,f=f>>>13,n[2*c+1]=f&8191,f=f>>>13;for(c=2*r;c<i;++c)n[c]=0;p(f===0),p((f&-8192)===0)},C.prototype.stub=function(e){for(var r=new Array(e),n=0;n<e;n++)r[n]=0;return r},C.prototype.mulp=function(e,r,n){var i=2*this.guessLen13b(e.length,r.length),f=this.makeRBT(i),c=this.stub(i),h=new Array(i),s=new Array(i),t=new Array(i),a=new Array(i),w=new Array(i),D=new Array(i),Z=n.words;Z.length=i,this.convert13b(e.words,e.length,h,i),this.convert13b(r.words,r.length,a,i),this.transform(h,c,s,t,i,f),this.transform(a,c,w,D,i,f);for(var F=0;F<i;F++){var V=s[F]*w[F]-t[F]*D[F];t[F]=s[F]*D[F]+t[F]*w[F],s[F]=V}return this.conjugate(s,t,i),this.transform(s,t,Z,c,i,f),this.conjugate(Z,c,i),this.normalize13b(Z,i),n.negative=e.negative^r.negative,n.length=e.length+r.length,n.strip()},o.prototype.mul=function(e){var r=new o(null);return r.words=new Array(this.length+e.length),this.mulTo(e,r)},o.prototype.mulf=function(e){var r=new o(null);return r.words=new Array(this.length+e.length),U(this,e,r)},o.prototype.imul=function(e){return this.clone().mulTo(e,this)},o.prototype.imuln=function(e){p(typeof e=="number"),p(e<67108864);for(var r=0,n=0;n<this.length;n++){var i=(this.words[n]|0)*e,f=(i&67108863)+(r&67108863);r>>=26,r+=i/67108864|0,r+=f>>>26,this.words[n]=f&67108863}return r!==0&&(this.words[n]=r,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 r=v(e);if(r.length===0)return new o(1);for(var n=this,i=0;i<r.length&&r[i]===0;i++,n=n.sqr());if(++i<r.length)for(var f=n.sqr();i<r.length;i++,f=f.sqr())r[i]!==0&&(n=n.mul(f));return n},o.prototype.iushln=function(e){p(typeof e=="number"&&e>=0);var r=e%26,n=(e-r)/26,i=67108863>>>26-r<<26-r,f;if(r!==0){var c=0;for(f=0;f<this.length;f++){var h=this.words[f]&i,s=(this.words[f]|0)-h<<r;this.words[f]=s|c,c=h>>>26-r}c&&(this.words[f]=c,this.length++)}if(n!==0){for(f=this.length-1;f>=0;f--)this.words[f+n]=this.words[f];for(f=0;f<n;f++)this.words[f]=0;this.length+=n}return this.strip()},o.prototype.ishln=function(e){return p(this.negative===0),this.iushln(e)},o.prototype.iushrn=function(e,r,n){p(typeof e=="number"&&e>=0);var i;r?i=(r-r%26)/26:i=0;var f=e%26,c=Math.min((e-f)/26,this.length),h=67108863^67108863>>>f<<f,s=n;if(i-=c,i=Math.max(0,i),s){for(var t=0;t<c;t++)s.words[t]=this.words[t];s.length=c}if(c!==0)if(this.length>c)for(this.length-=c,t=0;t<this.length;t++)this.words[t]=this.words[t+c];else this.words[0]=0,this.length=1;var a=0;for(t=this.length-1;t>=0&&(a!==0||t>=i);t--){var w=this.words[t]|0;this.words[t]=a<<26-f|w>>>f,a=w&h}return s&&a!==0&&(s.words[s.length++]=a),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,r,n){return p(this.negative===0),this.iushrn(e,r,n)},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){p(typeof e=="number"&&e>=0);var r=e%26,n=(e-r)/26,i=1<<r;if(this.length<=n)return!1;var f=this.words[n];return!!(f&i)},o.prototype.imaskn=function(e){p(typeof e=="number"&&e>=0);var r=e%26,n=(e-r)/26;if(p(this.negative===0,"imaskn works only with positive numbers"),this.length<=n)return this;if(r!==0&&n++,this.length=Math.min(n,this.length),r!==0){var i=67108863^67108863>>>r<<r;this.words[this.length-1]&=i}return this.strip()},o.prototype.maskn=function(e){return this.clone().imaskn(e)},o.prototype.iaddn=function(e){return p(typeof e=="number"),p(e<67108864),e<0?this.isubn(-e):this.negative!==0?this.length===1&&(this.words[0]|0)<e?(this.words[0]=e-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this):this._iaddn(e)},o.prototype._iaddn=function(e){this.words[0]+=e;for(var r=0;r<this.length&&this.words[r]>=67108864;r++)this.words[r]-=67108864,r===this.length-1?this.words[r+1]=1:this.words[r+1]++;return this.length=Math.max(this.length,r+1),this},o.prototype.isubn=function(e){if(p(typeof e=="number"),p(e<67108864),e<0)return this.iaddn(-e);if(this.negative!==0)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var r=0;r<this.length&&this.words[r]<0;r++)this.words[r]+=67108864,this.words[r+1]-=1;return this.strip()},o.prototype.addn=function(e){return this.clone().iaddn(e)},o.prototype.subn=function(e){return this.clone().isubn(e)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(e,r,n){var i=e.length+n,f;this._expand(i);var c,h=0;for(f=0;f<e.length;f++){c=(this.words[f+n]|0)+h;var s=(e.words[f]|0)*r;c-=s&67108863,h=(c>>26)-(s/67108864|0),this.words[f+n]=c&67108863}for(;f<this.length-n;f++)c=(this.words[f+n]|0)+h,h=c>>26,this.words[f+n]=c&67108863;if(h===0)return this.strip();for(p(h===-1),h=0,f=0;f<this.length;f++)c=-(this.words[f]|0)+h,h=c>>26,this.words[f]=c&67108863;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,r){var n=this.length-e.length,i=this.clone(),f=e,c=f.words[f.length-1]|0,h=this._countBits(c);n=26-h,n!==0&&(f=f.ushln(n),i.iushln(n),c=f.words[f.length-1]|0);var s=i.length-f.length,t;if(r!=="mod"){t=new o(null),t.length=s+1,t.words=new Array(t.length);for(var a=0;a<t.length;a++)t.words[a]=0}var w=i.clone()._ishlnsubmul(f,1,s);w.negative===0&&(i=w,t&&(t.words[s]=1));for(var D=s-1;D>=0;D--){var Z=(i.words[f.length+D]|0)*67108864+(i.words[f.length+D-1]|0);for(Z=Math.min(Z/c|0,67108863),i._ishlnsubmul(f,Z,D);i.negative!==0;)Z--,i.negative=0,i._ishlnsubmul(f,1,D),i.isZero()||(i.negative^=1);t&&(t.words[D]=Z)}return t&&t.strip(),i.strip(),r!=="div"&&n!==0&&i.iushrn(n),{div:t||null,mod:i}},o.prototype.divmod=function(e,r,n){if(p(!e.isZero()),this.isZero())return{div:new o(0),mod:new o(0)};var i,f,c;return this.negative!==0&&e.negative===0?(c=this.neg().divmod(e,r),r!=="mod"&&(i=c.div.neg()),r!=="div"&&(f=c.mod.neg(),n&&f.negative!==0&&f.iadd(e)),{div:i,mod:f}):this.negative===0&&e.negative!==0?(c=this.divmod(e.neg(),r),r!=="mod"&&(i=c.div.neg()),{div:i,mod:c.mod}):this.negative&e.negative?(c=this.neg().divmod(e.neg(),r),r!=="div"&&(f=c.mod.neg(),n&&f.negative!==0&&f.isub(e)),{div:c.div,mod:f}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:e.length===1?r==="div"?{div:this.divn(e.words[0]),mod:null}:r==="mod"?{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,r)},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 r=this.divmod(e);if(r.mod.isZero())return r.div;var n=r.div.negative!==0?r.mod.isub(e):r.mod,i=e.ushrn(1),f=e.andln(1),c=n.cmp(i);return c<0||f===1&&c===0?r.div:r.div.negative!==0?r.div.isubn(1):r.div.iaddn(1)},o.prototype.modn=function(e){p(e<=67108863);for(var r=(1<<26)%e,n=0,i=this.length-1;i>=0;i--)n=(r*n+(this.words[i]|0))%e;return n},o.prototype.idivn=function(e){p(e<=67108863);for(var r=0,n=this.length-1;n>=0;n--){var i=(this.words[n]|0)+r*67108864;this.words[n]=i/e|0,r=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){p(e.negative===0),p(!e.isZero());var r=this,n=e.clone();r.negative!==0?r=r.umod(e):r=r.clone();for(var i=new o(1),f=new o(0),c=new o(0),h=new o(1),s=0;r.isEven()&&n.isEven();)r.iushrn(1),n.iushrn(1),++s;for(var t=n.clone(),a=r.clone();!r.isZero();){for(var w=0,D=1;!(r.words[0]&D)&&w<26;++w,D<<=1);if(w>0)for(r.iushrn(w);w-- >0;)(i.isOdd()||f.isOdd())&&(i.iadd(t),f.isub(a)),i.iushrn(1),f.iushrn(1);for(var Z=0,F=1;!(n.words[0]&F)&&Z<26;++Z,F<<=1);if(Z>0)for(n.iushrn(Z);Z-- >0;)(c.isOdd()||h.isOdd())&&(c.iadd(t),h.isub(a)),c.iushrn(1),h.iushrn(1);r.cmp(n)>=0?(r.isub(n),i.isub(c),f.isub(h)):(n.isub(r),c.isub(i),h.isub(f))}return{a:c,b:h,gcd:n.iushln(s)}},o.prototype._invmp=function(e){p(e.negative===0),p(!e.isZero());var r=this,n=e.clone();r.negative!==0?r=r.umod(e):r=r.clone();for(var i=new o(1),f=new o(0),c=n.clone();r.cmpn(1)>0&&n.cmpn(1)>0;){for(var h=0,s=1;!(r.words[0]&s)&&h<26;++h,s<<=1);if(h>0)for(r.iushrn(h);h-- >0;)i.isOdd()&&i.iadd(c),i.iushrn(1);for(var t=0,a=1;!(n.words[0]&a)&&t<26;++t,a<<=1);if(t>0)for(n.iushrn(t);t-- >0;)f.isOdd()&&f.iadd(c),f.iushrn(1);r.cmp(n)>=0?(r.isub(n),i.isub(f)):(n.isub(r),f.isub(i))}var w;return r.cmpn(1)===0?w=i:w=f,w.cmpn(0)<0&&w.iadd(e),w},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var r=this.clone(),n=e.clone();r.negative=0,n.negative=0;for(var i=0;r.isEven()&&n.isEven();i++)r.iushrn(1),n.iushrn(1);do{for(;r.isEven();)r.iushrn(1);for(;n.isEven();)n.iushrn(1);var f=r.cmp(n);if(f<0){var c=r;r=n,n=c}else if(f===0||n.cmpn(1)===0)break;r.isub(n)}while(!0);return n.iushln(i)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return(this.words[0]&1)===0},o.prototype.isOdd=function(){return(this.words[0]&1)===1},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){p(typeof e=="number");var r=e%26,n=(e-r)/26,i=1<<r;if(this.length<=n)return this._expand(n+1),this.words[n]|=i,this;for(var f=i,c=n;f!==0&&c<this.length;c++){var h=this.words[c]|0;h+=f,f=h>>>26,h&=67108863,this.words[c]=h}return f!==0&&(this.words[c]=f,this.length++),this},o.prototype.isZero=function(){return this.length===1&&this.words[0]===0},o.prototype.cmpn=function(e){var r=e<0;if(this.negative!==0&&!r)return-1;if(this.negative===0&&r)return 1;this.strip();var n;if(this.length>1)n=1;else{r&&(e=-e),p(e<=67108863,"Number is too big");var i=this.words[0]|0;n=i===e?0:i<e?-1:1}return this.negative!==0?-n|0:n},o.prototype.cmp=function(e){if(this.negative!==0&&e.negative===0)return-1;if(this.negative===0&&e.negative!==0)return 1;var r=this.ucmp(e);return this.negative!==0?-r|0:r},o.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length<e.length)return-1;for(var r=0,n=this.length-1;n>=0;n--){var i=this.words[n]|0,f=e.words[n]|0;if(i!==f){i<f?r=-1:i>f&&(r=1);break}}return r},o.prototype.gtn=function(e){return this.cmpn(e)===1},o.prototype.gt=function(e){return this.cmp(e)===1},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 this.cmpn(e)===-1},o.prototype.lt=function(e){return this.cmp(e)===-1},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 this.cmpn(e)===0},o.prototype.eq=function(e){return this.cmp(e)===0},o.red=function(e){return new Y(e)},o.prototype.toRed=function(e){return p(!this.red,"Already a number in reduction context"),p(this.negative===0,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return p(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 p(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return p(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return p(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return p(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return p(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return p(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return p(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return p(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return p(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return p(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return p(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return p(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return p(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return p(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var L={k256:null,p224:null,p192:null,p25519:null};function N(u,e){this.name=u,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}N.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},N.prototype.ireduce=function(e){var r=e,n;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),n=r.bitLength();while(n>this.n);var i=n<this.n?-1:r.ucmp(this.p);return i===0?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):r.strip!==void 0?r.strip():r._strip(),r},N.prototype.split=function(e,r){e.iushrn(this.n,0,r)},N.prototype.imulK=function(e){return e.imul(this.k)};function j(){N.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}I(j,N),j.prototype.split=function(e,r){for(var n=4194303,i=Math.min(e.length,9),f=0;f<i;f++)r.words[f]=e.words[f];if(r.length=i,e.length<=9){e.words[0]=0,e.length=1;return}var c=e.words[9];for(r.words[r.length++]=c&n,f=10;f<e.length;f++){var h=e.words[f]|0;e.words[f-10]=(h&n)<<4|c>>>22,c=h}c>>>=22,e.words[f-10]=c,c===0&&e.length>10?e.length-=10:e.length-=9},j.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var r=0,n=0;n<e.length;n++){var i=e.words[n]|0;r+=i*977,e.words[n]=r&67108863,r=i*64+(r/67108864|0)}return e.words[e.length-1]===0&&(e.length--,e.words[e.length-1]===0&&e.length--),e};function K(){N.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}I(K,N);function $(){N.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}I($,N);function Q(){N.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}I(Q,N),Q.prototype.imulK=function(e){for(var r=0,n=0;n<e.length;n++){var i=(e.words[n]|0)*19+r,f=i&67108863;i>>>=26,e.words[n]=f,r=i}return r!==0&&(e.words[e.length++]=r),e},o._prime=function(e){if(L[e])return L[e];var r;if(e==="k256")r=new j;else if(e==="p224")r=new K;else if(e==="p192")r=new $;else if(e==="p25519")r=new Q;else throw new Error("Unknown prime "+e);return L[e]=r,r};function Y(u){if(typeof u=="string"){var e=o._prime(u);this.m=e.p,this.prime=e}else p(u.gtn(1),"modulus must be greater than 1"),this.m=u,this.prime=null}Y.prototype._verify1=function(e){p(e.negative===0,"red works only with positives"),p(e.red,"red works only with red numbers")},Y.prototype._verify2=function(e,r){p((e.negative|r.negative)===0,"red works only with positives"),p(e.red&&e.red===r.red,"red works only with red numbers")},Y.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},Y.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},Y.prototype.add=function(e,r){this._verify2(e,r);var n=e.add(r);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},Y.prototype.iadd=function(e,r){this._verify2(e,r);var n=e.iadd(r);return n.cmp(this.m)>=0&&n.isub(this.m),n},Y.prototype.sub=function(e,r){this._verify2(e,r);var n=e.sub(r);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},Y.prototype.isub=function(e,r){this._verify2(e,r);var n=e.isub(r);return n.cmpn(0)<0&&n.iadd(this.m),n},Y.prototype.shl=function(e,r){return this._verify1(e),this.imod(e.ushln(r))},Y.prototype.imul=function(e,r){return this._verify2(e,r),this.imod(e.imul(r))},Y.prototype.mul=function(e,r){return this._verify2(e,r),this.imod(e.mul(r))},Y.prototype.isqr=function(e){return this.imul(e,e.clone())},Y.prototype.sqr=function(e){return this.mul(e,e)},Y.prototype.sqrt=function(e){if(e.isZero())return e.clone();var r=this.m.andln(3);if(p(r%2===1),r===3){var n=this.m.add(new o(1)).iushrn(2);return this.pow(e,n)}for(var i=this.m.subn(1),f=0;!i.isZero()&&i.andln(1)===0;)f++,i.iushrn(1);p(!i.isZero());var c=new o(1).toRed(this),h=c.redNeg(),s=this.m.subn(1).iushrn(1),t=this.m.bitLength();for(t=new o(2*t*t).toRed(this);this.pow(t,s).cmp(h)!==0;)t.redIAdd(h);for(var a=this.pow(t,i),w=this.pow(e,i.addn(1).iushrn(1)),D=this.pow(e,i),Z=f;D.cmp(c)!==0;){for(var F=D,V=0;F.cmp(c)!==0;V++)F=F.redSqr();p(V<Z);var q=this.pow(a,new o(1).iushln(Z-V-1));w=w.redMul(q),a=q.redSqr(),D=D.redMul(a),Z=V}return w},Y.prototype.invm=function(e){var r=e._invmp(this.m);return r.negative!==0?(r.negative=0,this.imod(r).redNeg()):this.imod(r)},Y.prototype.pow=function(e,r){if(r.isZero())return new o(1).toRed(this);if(r.cmpn(1)===0)return e.clone();var n=4,i=new Array(1<<n);i[0]=new o(1).toRed(this),i[1]=e;for(var f=2;f<i.length;f++)i[f]=this.mul(i[f-1],e);var c=i[0],h=0,s=0,t=r.bitLength()%26;for(t===0&&(t=26),f=r.length-1;f>=0;f--){for(var a=r.words[f],w=t-1;w>=0;w--){var D=a>>w&1;if(c!==i[0]&&(c=this.sqr(c)),D===0&&h===0){s=0;continue}h<<=1,h|=D,s++,!(s!==n&&(f!==0||w!==0))&&(c=this.mul(c,i[h]),s=0,h=0)}t=26}return c},Y.prototype.convertTo=function(e){var r=e.umod(this.m);return r===e?r.clone():r},Y.prototype.convertFrom=function(e){var r=e.clone();return r.red=null,r},o.mont=function(e){return new ee(e)};function ee(u){Y.call(this,u),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)}I(ee,Y),ee.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},ee.prototype.convertFrom=function(e){var r=this.imod(e.mul(this.rinv));return r.red=null,r},ee.prototype.imul=function(e,r){if(e.isZero()||r.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(r),i=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),f=n.isub(i).iushrn(this.shift),c=f;return f.cmp(this.m)>=0?c=f.isub(this.m):f.cmpn(0)<0&&(c=f.iadd(this.m)),c._forceRed(this)},ee.prototype.mul=function(e,r){if(e.isZero()||r.isZero())return new o(0)._forceRed(this);var n=e.mul(r),i=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),f=n.isub(i).iushrn(this.shift),c=f;return f.cmp(this.m)>=0?c=f.isub(this.m):f.cmpn(0)<0&&(c=f.iadd(this.m)),c._forceRed(this)},ee.prototype.invm=function(e){var r=this.imod(e._invmp(this.m).mul(this.r2));return r._forceRed(this)}}(fe,this)},7007:fe=>{"use strict";var x=typeof Reflect=="object"?Reflect:null,T=x&&typeof x.apply=="function"?x.apply:function(N,j,K){return Function.prototype.apply.call(N,j,K)},S;x&&typeof x.ownKeys=="function"?S=x.ownKeys:Object.getOwnPropertySymbols?S=function(N){return Object.getOwnPropertyNames(N).concat(Object.getOwnPropertySymbols(N))}:S=function(N){return Object.getOwnPropertyNames(N)};function y(L){console&&console.warn&&console.warn(L)}var p=Number.isNaN||function(N){return N!==N};function I(){I.init.call(this)}fe.exports=I,fe.exports.once=B,I.EventEmitter=I,I.prototype._events=void 0,I.prototype._eventsCount=0,I.prototype._maxListeners=void 0;var o=10;function m(L){if(typeof L!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof L)}Object.defineProperty(I,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(L){if(typeof L!="number"||L<0||p(L))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+L+".");o=L}}),I.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},I.prototype.setMaxListeners=function(N){if(typeof N!="number"||N<0||p(N))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+N+".");return this._maxListeners=N,this};function l(L){return L._maxListeners===void 0?I.defaultMaxListeners:L._maxListeners}I.prototype.getMaxListeners=function(){return l(this)},I.prototype.emit=function(N){for(var j=[],K=1;K<arguments.length;K++)j.push(arguments[K]);var $=N==="error",Q=this._events;if(Q!==void 0)$=$&&Q.error===void 0;else if(!$)return!1;if($){var Y;if(j.length>0&&(Y=j[0]),Y instanceof Error)throw Y;var ee=new Error("Unhandled error."+(Y?" ("+Y.message+")":""));throw ee.context=Y,ee}var u=Q[N];if(u===void 0)return!1;if(typeof u=="function")T(u,this,j);else for(var e=u.length,r=v(u,e),K=0;K<e;++K)T(r[K],this,j);return!0};function g(L,N,j,K){var $,Q,Y;if(m(j),Q=L._events,Q===void 0?(Q=L._events=Object.create(null),L._eventsCount=0):(Q.newListener!==void 0&&(L.emit("newListener",N,j.listener?j.listener:j),Q=L._events),Y=Q[N]),Y===void 0)Y=Q[N]=j,++L._eventsCount;else if(typeof Y=="function"?Y=Q[N]=K?[j,Y]:[Y,j]:K?Y.unshift(j):Y.push(j),$=l(L),$>0&&Y.length>$&&!Y.warned){Y.warned=!0;var ee=new Error("Possible EventEmitter memory leak detected. "+Y.length+" "+String(N)+" listeners added. Use emitter.setMaxListeners() to increase limit");ee.name="MaxListenersExceededWarning",ee.emitter=L,ee.type=N,ee.count=Y.length,y(ee)}return L}I.prototype.addListener=function(N,j){return g(this,N,j,!1)},I.prototype.on=I.prototype.addListener,I.prototype.prependListener=function(N,j){return g(this,N,j,!0)};function M(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function E(L,N,j){var K={fired:!1,wrapFn:void 0,target:L,type:N,listener:j},$=M.bind(K);return $.listener=j,K.wrapFn=$,$}I.prototype.once=function(N,j){return m(j),this.on(N,E(this,N,j)),this},I.prototype.prependOnceListener=function(N,j){return m(j),this.prependListener(N,E(this,N,j)),this},I.prototype.removeListener=function(N,j){var K,$,Q,Y,ee;if(m(j),$=this._events,$===void 0)return this;if(K=$[N],K===void 0)return this;if(K===j||K.listener===j)--this._eventsCount===0?this._events=Object.create(null):(delete $[N],$.removeListener&&this.emit("removeListener",N,K.listener||j));else if(typeof K!="function"){for(Q=-1,Y=K.length-1;Y>=0;Y--)if(K[Y]===j||K[Y].listener===j){ee=K[Y].listener,Q=Y;break}if(Q<0)return this;Q===0?K.shift():b(K,Q),K.length===1&&($[N]=K[0]),$.removeListener!==void 0&&this.emit("removeListener",N,ee||j)}return this},I.prototype.off=I.prototype.removeListener,I.prototype.removeAllListeners=function(N){var j,K,$;if(K=this._events,K===void 0)return this;if(K.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):K[N]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete K[N]),this;if(arguments.length===0){var Q=Object.keys(K),Y;for($=0;$<Q.length;++$)Y=Q[$],Y!=="removeListener"&&this.removeAllListeners(Y);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(j=K[N],typeof j=="function")this.removeListener(N,j);else if(j!==void 0)for($=j.length-1;$>=0;$--)this.removeListener(N,j[$]);return this};function d(L,N,j){var K=L._events;if(K===void 0)return[];var $=K[N];return $===void 0?[]:typeof $=="function"?j?[$.listener||$]:[$]:j?k($):v($,$.length)}I.prototype.listeners=function(N){return d(this,N,!0)},I.prototype.rawListeners=function(N){return d(this,N,!1)},I.listenerCount=function(L,N){return typeof L.listenerCount=="function"?L.listenerCount(N):A.call(L,N)},I.prototype.listenerCount=A;function A(L){var N=this._events;if(N!==void 0){var j=N[L];if(typeof j=="function")return 1;if(j!==void 0)return j.length}return 0}I.prototype.eventNames=function(){return this._eventsCount>0?S(this._events):[]};function v(L,N){for(var j=new Array(N),K=0;K<N;++K)j[K]=L[K];return j}function b(L,N){for(;N+1<L.length;N++)L[N]=L[N+1];L.pop()}function k(L){for(var N=new Array(L.length),j=0;j<N.length;++j)N[j]=L[j].listener||L[j];return N}function B(L,N){return new Promise(function(j,K){function $(Y){L.removeListener(N,Q),K(Y)}function Q(){typeof L.removeListener=="function"&&L.removeListener("error",$),j([].slice.call(arguments))}C(L,N,Q,{once:!0}),N!=="error"&&U(L,$,{once:!0})})}function U(L,N,j){typeof L.on=="function"&&C(L,"error",N,j)}function C(L,N,j,K){if(typeof L.on=="function")K.once?L.once(N,j):L.on(N,j);else if(typeof L.addEventListener=="function")L.addEventListener(N,function $(Q){K.once&&L.removeEventListener(N,$),j(Q)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof L)}},8078:(fe,x,T)=>{var S=T(2861).Buffer,y=T(8276);function p(I,o,m,l){if(S.isBuffer(I)||(I=S.from(I,"binary")),o&&(S.isBuffer(o)||(o=S.from(o,"binary")),o.length!==8))throw new RangeError("salt should be Buffer with 8 byte length");for(var g=m/8,M=S.alloc(g),E=S.alloc(l||0),d=S.alloc(0);g>0||l>0;){var A=new y;A.update(d),A.update(I),o&&A.update(o),d=A.digest();var v=0;if(g>0){var b=M.length-g;v=Math.min(g,d.length),d.copy(M,b,0,v),g-=v}if(v<d.length&&l>0){var k=E.length-l,B=Math.min(l,d.length-v);d.copy(E,k,v,v+B),l-=B}}return d.fill(0),{key:M,iv:E}}fe.exports=p},6341:fe=>{function x(S){return S}function T(S,I,o){for(var I=I||x,o=o||S,m,l=0,g=S.length;l<g;l+=1)if(m=I.call(o,S[l],l))return S[l]}fe.exports=T},8036:(fe,x,T)=>{"use strict";var S=T(2110),y=T(5174),p=fe.exports;fe.exports.groestl512=function(I,o,m){return S(I,o,m)},fe.exports.groestl=function(I,o,m){var l=S(I,o,2);return l=l.slice(0,8),m===2?l:m===1?y.int32Buffer2Bytes(l):y.int32ArrayToHexString(l)},fe.exports.groestl_2=function(I,o,m){var l=S(I,o,2);return l=S(l,2,2),l=l.slice(0,8),m===2?l:m===1?y.int32Buffer2Bytes(l):y.int32ArrayToHexString(l)}},2110:(fe,x,T)=>{var S=T(7749),y=T(5174),p=y.bytes2Int64Buffer(y.b64Decode("xjL0pfSXpcb4b5eEl+uE+O5esJmwx5nu9nqMjYz3jfb/6BcNF+UN/9YK3L3ct73W3hbIscinsd6RbfxU/DlUkWCQ8FDwwFBgAgcFAwUEAwLOLuCp4IepzlbRh32HrH1W58wrGSvVGee1E6ZipnFitU18MeYxmuZN7Fm1mrXDmuyPQM9FzwVFjx+jvJ28Pp0fiUnAQMAJQIn6aJKHku+H+u/QPxU/xRXvspQm6yZ/67KOzkDJQAfJjvvmHQsd7Qv7QW4v7C+C7EGzGqlnqX1ns19DHP0cvv1fRWAl6iWK6kUj+dq/2ka/I1NRAvcCpvdT5EWhlqHTluSbdu1b7S1bm3UoXcJd6sJ14cUkHCTZHOE91Omu6XquPUzyvmq+mGpMbILuWu7YWmx+vcNBw/xBfvXzBgIG8QL1g1LRT9EdT4NojORc5NBcaFFWB/QHovRR0Y1cNFy5NNH54RgIGOkI+eJMrpOu35Piqz6Vc5VNc6til/VT9cRTYiprQT9BVD8qCBwUDBQQDAiVY/ZS9jFSlUbpr2WvjGVGnX/iXuIhXp0wSHgoeGAoMDfP+KH4bqE3ChsRDxEUDwov68S1xF61Lw4VGwkbHAkOJH5aNlpINiQbrbabtjabG9+YRz1HpT3fzadqJmqBJs1O9btpu5xpTn8zTM1M/s1/6lC6n7rPn+oSPy0bLSQbEh2kuZ65Op4dWMScdJywdFg0RnIucmguNDZBdy13bC023BHNss2jsty0nSnuKXPutFtNFvsWtvtbpKUB9gFT9qR2oddN1+xNdrcUo2GjdWG3fTRJzkn6zn1S3417jaR7Ut2fQj5CoT7dXs2TcZO8cV4TsaKXoiaXE6aiBPUEV/WmuQG4aLhpaLkAAAAAAAAAAMG1dCx0mSzBQOCgYKCAYEDjwiEfId0f43k6Q8hD8sh5tpos7Sx37bbUDdm+2bO+1I1HykbKAUaNZxdw2XDO2Wdyr91L3eRLcpTted55M96UmP9n1Gcr1JiwkyPoI3vosIVb3kreEUqFuwa9a71ta7vFu34qfpEqxU97NOU0nuVP7dc6FjrBFu2G0lTFVBfFhpr4YtdiL9eaZpn/Vf/MVWYRtqeUpyKUEYrASs9KD8+K6dkwEDDJEOkEDgoGCggGBP5mmIGY54H+oKsL8Atb8KB4tMxEzPBEeCXw1brVSrolS3U+4z6W40uirA7zDl/zol1EGf4Zuv5dgNtbwFsbwIAFgIWKhQqKBT/T7K3sfq0/If7fvN9CvCFwqNhI2OBIcPH9DAQM+QTxYxl633rG32N3L1jBWO7Bd68wn3WfRXWvQuelY6WEY0IgcFAwUEAwIOXLLhou0Rrl/e8SDhLhDv2/CLdtt2Vtv4FV1EzUGUyBGCQ8FDwwFBgmeV81X0w1JsOycS9xnS/DvoY44Thn4b41yP2i/WqiNYjHT8xPC8yILmVLOUtcOS6TavlX+T1Xk1VYDfINqvJV/GGdgp3jgvx6s8lHyfRHesgn76zvi6zIuogy5zJv57oyT30rfWQrMuZCpJWk15XmwDv7oPuboMAZqrOYszKYGZ72aNFoJ9GeoyKBf4Fdf6NE7qpmqohmRFTWgn6CqH5UO93mq+Z2qzsLlZ6DnhaDC4zJRcpFA8qMx7x7KXuVKcdrBW7TbtbTayhsRDxEUDwopyyLeYtVeae8gT3iPWPivBYxJx0nLB0WrTeadppBdq3blk07Ta0722Se+lb6yFZkdKbSTtLoTnQUNiIeIigeFJLkdtt2P9uSDBIeCh4YCgxI/LRstJBsSLiPN+Q3a+S4n3jnXeclXZ+9D7JusmFuvUNpKu8qhu9DxDXxpvGTpsQ52uOo43KoOTHG96T3YqQx04pZN1m9N9PydIaLhv+L8tWDVjJWsTLVi07FQ8UNQ4tuhetZ69xZbtoYwrfCr7faAY6PjI8CjAGxHaxkrHlksZzxbdJtI9KcSXI74DuS4EnYH8e0x6u02Ky5FfoVQ/qs8/oJBwn9B/PPoG8lb4Ulz8og6q/qj6/K9H2JjonzjvRHZyDpII7pRxA4KBgoIBgQbwtk1WTe1W/wc4OIg/uI8Er7sW+xlG9KXMqWcpa4clw4VGwkbHAkOFdfCPEIrvFXcyFSx1Lmx3OXZPNR8zVRl8uuZSNljSPLoSWEfIRZfKHoV7+cv8uc6D5dYyFjfCE+lup83Xw33ZZhHn/cf8LcYQ2ckYaRGoYND5uUhZQehQ/gS6uQq9uQ4Hy6xkLG+EJ8cSZXxFfixHHMKeWq5YOqzJDjc9hzO9iQBgkPBQ8MBQb39AMBA/UB9xwqNhI2OBIcwjz+o/6fo8Jqi+Ff4dRfaq6+EPkQR/muaQJr0GvS0GkXv6iRqC6RF5lx6FjoKViZOlNpJ2l0Jzon99C50E65J9mRSDhIqTjZ6941EzXNE+sr5c6zzlazKyJ3VTNVRDMi0gTWu9a/u9KpOZBwkElwqQeHgImADokHM8Hyp/JmpzMt7MG2wVq2LTxaZiJmeCI8Fbitkq0qkhXJqWAgYIkgyYdc20nbFUmHqrAa/xpP/6pQ2Ih4iKB4UKUrjnqOUXqlA4mKj4oGjwNZShP4E7L4WQmSm4CbEoAJGiM5Fzk0FxplEHXadcraZdeEUzFTtTHXhNVRxlETxoTQA9O407u40ILcXsNeH8OCKeLLsMtSsClaw5l3mbR3Wh4tMxEzPBEeez1Gy0b2y3uotx/8H0v8qG0MYdZh2tZtLGJOOk5YOiw=")),I=y.bytes2Int64Buffer(y.b64Decode("xsYy9KX0l6X4+G+XhJfrhO7uXrCZsMeZ9vZ6jI2M943//+gXDRflDdbWCty93Le93t4WyLHIp7GRkW38VPw5VGBgkPBQ8MBQAgIHBQMFBAPOzi7gqeCHqVZW0Yd9h6x95+fMKxkr1Rm1tROmYqZxYk1NfDHmMZrm7OxZtZq1w5qPj0DPRc8FRR8fo7ydvD6diYlJwEDACUD6+miSh5Lvh+/v0D8VP8UVsrKUJusmf+uOjs5AyUAHyfv75h0LHe0LQUFuL+wvguyzsxqpZ6l9Z19fQxz9HL79RUVgJeoliuojI/nav9pGv1NTUQL3Aqb35ORFoZah05abm3btW+0tW3V1KF3CXerC4eHFJBwk2Rw9PdTprul6rkxM8r5qvphqbGyC7lru2Fp+fr3DQcP8QfX18wYCBvECg4NS0U/RHU9oaIzkXOTQXFFRVgf0B6L00dGNXDRcuTT5+eEYCBjpCOLiTK6Trt+Tq6s+lXOVTXNiYpf1U/XEUyoqa0E/QVQ/CAgcFAwUEAyVlWP2UvYxUkZG6a9lr4xlnZ1/4l7iIV4wMEh4KHhgKDc3z/ih+G6hCgobEQ8RFA8vL+vEtcRetQ4OFRsJGxwJJCR+WjZaSDYbG622m7Y2m9/fmEc9R6U9zc2naiZqgSZOTvW7abucaX9/M0zNTP7N6upQup+6z58SEj8tGy0kGx0dpLmeuTqeWFjEnHScsHQ0NEZyLnJoLjY2QXctd2wt3NwRzbLNo7K0tJ0p7ilz7ltbTRb7Frb7pKSlAfYBU/Z2dqHXTdfsTbe3FKNho3VhfX00Sc5J+s5SUt+Ne42ke93dn0I+QqE+Xl7Nk3GTvHETE7Gil6Iml6amogT1BFf1ubkBuGi4aWgAAAAAAAAAAMHBtXQsdJksQEDgoGCggGDj48IhHyHdH3l5OkPIQ/LItraaLO0sd+3U1A3Zvtmzvo2NR8pGygFGZ2cXcNlwztlycq/dS93kS5SU7XneeTPemJj/Z9RnK9SwsJMj6CN76IWFW95K3hFKu7sGvWu9bWvFxbt+Kn6RKk9PezTlNJ7l7e3XOhY6wRaGhtJUxVQXxZqa+GLXYi/XZmaZ/1X/zFUREbanlKcilIqKwErPSg/P6enZMBAwyRAEBA4KBgoIBv7+ZpiBmOeBoKCrC/ALW/B4eLTMRMzwRCUl8NW61Uq6S0t1PuM+luOioqwO8w5f811dRBn+Gbr+gIDbW8BbG8AFBYCFioUKij8/0+yt7H6tISH+37zfQrxwcKjYSNjgSPHx/QwEDPkEY2MZet96xt93dy9YwVjuwa+vMJ91n0V1QkLnpWOlhGMgIHBQMFBAMOXlyy4aLtEa/f3vEg4S4Q6/vwi3bbdlbYGBVdRM1BlMGBgkPBQ8MBQmJnlfNV9MNcPDsnEvcZ0vvr6GOOE4Z+E1Ncj9ov1qooiIx0/MTwvMLi5lSzlLXDmTk2r5V/k9V1VVWA3yDary/PxhnYKd44J6erPJR8n0R8jIJ++s74usurqIMucyb+cyMk99K31kK+bmQqSVpNeVwMA7+6D7m6AZGaqzmLMymJ6e9mjRaCfRo6MigX+BXX9ERO6qZqqIZlRU1oJ+gqh+Ozvd5qvmdqsLC5Weg54Wg4yMyUXKRQPKx8e8eyl7lSlrawVu027W0ygobEQ8RFA8p6csi3mLVXm8vIE94j1j4hYWMScdJywdra03mnaaQXbb25ZNO02tO2RknvpW+shWdHSm0k7S6E4UFDYiHiIoHpKS5Hbbdj/bDAwSHgoeGApISPy0bLSQbLi4jzfkN2vkn594513nJV29vQ+ybrJhbkNDaSrvKobvxMQ18abxk6Y5OdrjqONyqDExxvek92Kk09OKWTdZvTfy8nSGi4b/i9XVg1YyVrEyi4tOxUPFDUNuboXrWevcWdraGMK3wq+3AQGOj4yPAoyxsR2sZKx5ZJyc8W3SbSPSSUlyO+A7kuDY2B/HtMertKysuRX6FUP68/P6CQcJ/QfPz6BvJW+FJcrKIOqv6o+v9PR9iY6J845HR2cg6SCO6RAQOCgYKCAYb28LZNVk3tXw8HODiIP7iEpK+7FvsZRvXFzKlnKWuHI4OFRsJGxwJFdXXwjxCK7xc3MhUsdS5seXl2TzUfM1UcvLrmUjZY0joaElhHyEWXzo6Fe/nL/LnD4+XWMhY3whlpbqfN18N91hYR5/3H/C3A0NnJGGkRqGDw+blIWUHoXg4EurkKvbkHx8usZCxvhCcXEmV8RX4sTMzCnlquWDqpCQ43PYczvYBgYJDwUPDAX39/QDAQP1ARwcKjYSNjgSwsI8/qP+n6NqaovhX+HUX66uvhD5EEf5aWkCa9Br0tAXF7+okagukZmZcehY6ClYOjpTaSdpdCcnJ/fQudBOudnZkUg4SKk46+veNRM1zRMrK+XOs85WsyIid1UzVUQz0tIE1rvWv7upqTmQcJBJcAcHh4CJgA6JMzPB8qfyZqctLezBtsFatjw8WmYiZngiFRW4rZKtKpLJyalgIGCJIIeHXNtJ2xVJqqqwGv8aT/9QUNiIeIigeKWlK456jlF6AwOJio+KBo9ZWUoT+BOy+AkJkpuAmxKAGhojORc5NBdlZRB12nXK2tfXhFMxU7UxhITVUcZRE8bQ0APTuNO7uIKC3F7DXh/DKSniy7DLUrBaWsOZd5m0dx4eLTMRMzwRe3s9RstG9suoqLcf/B9L/G1tDGHWYdrWLCxiTjpOWDo=")),o=y.bytes2Int64Buffer(y.b64Decode("pcbGMvSl9JeE+Phvl4SX65nu7l6wmbDHjfb2eoyNjPcN///oFw0X5b3W1grcvdy3sd7eFsixyKdUkZFt/FT8OVBgYJDwUPDAAwICBwUDBQSpzs4u4Kngh31WVtGHfYesGefnzCsZK9VitbUTpmKmceZNTXwx5jGamuzsWbWatcNFj49Az0XPBZ0fH6O8nbw+QImJScBAwAmH+vpokoeS7xXv79A/FT/F67KylCbrJn/Jjo7OQMlABwv7++YdCx3t7EFBbi/sL4Jns7MaqWepff1fX0Mc/Ry+6kVFYCXqJYq/IyP52r/aRvdTU1EC9wKmluTkRaGWodNbm5t27VvtLcJ1dShdwl3qHOHhxSQcJNmuPT3U6a7pempMTPK+ar6YWmxsgu5a7thBfn69w0HD/AL19fMGAgbxT4ODUtFP0R1caGiM5Fzk0PRRUVYH9AeiNNHRjVw0XLkI+fnhGAgY6ZPi4kyuk67fc6urPpVzlU1TYmKX9VP1xD8qKmtBP0FUDAgIHBQMFBBSlZVj9lL2MWVGRumvZa+MXp2df+Je4iEoMDBIeCh4YKE3N8/4ofhuDwoKGxEPERS1Ly/rxLXEXgkODhUbCRscNiQkflo2WkibGxuttpu2Nj3f35hHPUelJs3Np2omaoFpTk71u2m7nM1/fzNMzUz+n+rqULqfus8bEhI/LRstJJ4dHaS5nrk6dFhYxJx0nLAuNDRGci5yaC02NkF3LXdsstzcEc2yzaPutLSdKe4pc/tbW00W+xa29qSkpQH2AVNNdnah103X7GG3txSjYaN1zn19NEnOSfp7UlLfjXuNpD7d3Z9CPkKhcV5ezZNxk7yXExOxopeiJvWmpqIE9QRXaLm5AbhouGkAAAAAAAAAACzBwbV0LHSZYEBA4KBgoIAf4+PCIR8h3ch5eTpDyEPy7ba2miztLHe+1NQN2b7Zs0aNjUfKRsoB2WdnF3DZcM5LcnKv3Uvd5N6UlO153nkz1JiY/2fUZyvosLCTI+gje0qFhVveSt4Ra7u7Br1rvW0qxcW7fip+keVPT3s05TSeFu3t1zoWOsHFhobSVMVUF9eamvhi12IvVWZmmf9V/8yUERG2p5SnIs+KisBKz0oPEOnp2TAQMMkGBAQOCgYKCIH+/maYgZjn8KCgqwvwC1tEeHi0zETM8LolJfDVutVK40tLdT7jPpbzoqKsDvMOX/5dXUQZ/hm6wICA21vAWxuKBQWAhYqFCq0/P9Psrex+vCEh/t+830JIcHCo2EjY4ATx8f0MBAz532NjGXrfesbBd3cvWMFY7nWvrzCfdZ9FY0JC56VjpYQwICBwUDBQQBrl5csuGi7RDv397xIOEuFtv78It223ZUyBgVXUTNQZFBgYJDwUPDA1JiZ5XzVfTC/Dw7JxL3Gd4b6+hjjhOGeiNTXI/aL9asyIiMdPzE8LOS4uZUs5S1xXk5Nq+Vf5PfJVVVgN8g2qgvz8YZ2CneNHenqzyUfJ9KzIyCfvrO+L57q6iDLnMm8rMjJPfSt9ZJXm5kKklaTXoMDAO/ug+5uYGRmqs5izMtGenvZo0Wgnf6OjIoF/gV1mRETuqmaqiH5UVNaCfoKoqzs73ear5naDCwuVnoOeFsqMjMlFykUDKcfHvHspe5XTa2sFbtNu1jwoKGxEPERQeaenLIt5i1XivLyBPeI9Yx0WFjEnHScsdq2tN5p2mkE729uWTTtNrVZkZJ76VvrITnR0ptJO0ugeFBQ2Ih4iKNuSkuR223Y/CgwMEh4KHhhsSEj8tGy0kOS4uI835DdrXZ+feOdd5yVuvb0Psm6yYe9DQ2kq7yqGpsTENfGm8ZOoOTna46jjcqQxMcb3pPdiN9PTilk3Wb2L8vJ0houG/zLV1YNWMlaxQ4uLTsVDxQ1Zbm6F61nr3Lfa2hjCt8KvjAEBjo+MjwJksbEdrGSsedKcnPFt0m0j4ElJcjvgO5K02Ngfx7THq/qsrLkV+hVDB/Pz+gkHCf0lz8+gbyVvha/KyiDqr+qPjvT0fYmOifPpR0dnIOkgjhgQEDgoGCgg1W9vC2TVZN6I8PBzg4iD+29KSvuxb7GUclxcypZylrgkODhUbCRscPFXV18I8Qiux3NzIVLHUuZRl5dk81HzNSPLy65lI2WNfKGhJYR8hFmc6OhXv5y/yyE+Pl1jIWN83ZaW6nzdfDfcYWEef9x/woYNDZyRhpEahQ8Pm5SFlB6Q4OBLq5Cr20J8fLrGQsb4xHFxJlfEV+KqzMwp5arlg9iQkONz2HM7BQYGCQ8FDwwB9/f0AwED9RIcHCo2EjY4o8LCPP6j/p9famqL4V/h1Pmurr4Q+RBH0GlpAmvQa9KRFxe/qJGoLliZmXHoWOgpJzo6U2knaXS5Jyf30LnQTjjZ2ZFIOEipE+vr3jUTNc2zKyvlzrPOVjMiIndVM1VEu9LSBNa71r9wqak5kHCQSYkHB4eAiYAOpzMzwfKn8ma2LS3swbbBWiI8PFpmImZ4khUVuK2SrSogycmpYCBgiUmHh1zbSdsV/6qqsBr/Gk94UFDYiHiIoHqlpSuOeo5RjwMDiYqPigb4WVlKE/gTsoAJCZKbgJsSFxoaIzkXOTTaZWUQddp1yjHX14RTMVO1xoSE1VHGURO40NAD07jTu8OCgtxew14fsCkp4suwy1J3WlrDmXeZtBEeHi0zETM8y3t7PUbLRvb8qKi3H/wfS9ZtbQxh1mHaOiwsYk46Tlg=")),m=y.bytes2Int64Buffer(y.b64Decode("l6XGxjL0pfTrhPj4b5eEl8eZ7u5esJmw94329nqMjYzlDf//6BcNF7e91tYK3L3cp7He3hbIscg5VJGRbfxU/MBQYGCQ8FDwBAMCAgcFAwWHqc7OLuCp4Kx9VlbRh32H1Rnn58wrGStxYrW1E6ZipprmTU18MeYxw5rs7Fm1mrUFRY+PQM9Fzz6dHx+jvJ28CUCJiUnAQMDvh/r6aJKHksUV7+/QPxU/f+uyspQm6yYHyY6OzkDJQO0L+/vmHQsdguxBQW4v7C99Z7OzGqlnqb79X19DHP0ciupFRWAl6iVGvyMj+dq/2qb3U1NRAvcC05bk5EWhlqEtW5ubdu1b7erCdXUoXcJd2Rzh4cUkHCR6rj091Omu6ZhqTEzyvmq+2FpsbILuWu78QX5+vcNBw/EC9fXzBgIGHU+Dg1LRT9HQXGhojORc5KL0UVFWB/QHuTTR0Y1cNFzpCPn54RgIGN+T4uJMrpOuTXOrqz6Vc5XEU2Jil/VT9VQ/KiprQT9BEAwICBwUDBQxUpWVY/ZS9oxlRkbpr2WvIV6dnX/iXuJgKDAwSHgoeG6hNzfP+KH4FA8KChsRDxFetS8v68S1xBwJDg4VGwkbSDYkJH5aNlo2mxsbrbabtqU939+YRz1HgSbNzadqJmqcaU5O9btpu/7Nf38zTM1Mz5/q6lC6n7okGxISPy0bLTqeHR2kuZ65sHRYWMScdJxoLjQ0RnIucmwtNjZBdy13o7Lc3BHNss1z7rS0nSnuKbb7W1tNFvsWU/akpKUB9gHsTXZ2oddN13Vht7cUo2Gj+s59fTRJzkmke1JS3417jaE+3d2fQj5CvHFeXs2TcZMmlxMTsaKXolf1pqaiBPUEaWi5uQG4aLgAAAAAAAAAAJkswcG1dCx0gGBAQOCgYKDdH+PjwiEfIfLIeXk6Q8hDd+22tpos7SyzvtTUDdm+2QFGjY1HykbKztlnZxdw2XDkS3Jyr91L3TPelJTted55K9SYmP9n1Gd76LCwkyPoIxFKhYVb3krebWu7uwa9a72RKsXFu34qfp7lT097NOU0wRbt7dc6FjoXxYaG0lTFVC/Xmpr4YtdizFVmZpn/Vf8ilBERtqeUpw/PiorASs9KyRDp6dkwEDAIBgQEDgoGCueB/v5mmIGYW/CgoKsL8AvwRHh4tMxEzEq6JSXw1brVluNLS3U+4z5f86KirA7zDrr+XV1EGf4ZG8CAgNtbwFsKigUFgIWKhX6tPz/T7K3sQrwhIf7fvN/gSHBwqNhI2PkE8fH9DAQMxt9jYxl633ruwXd3L1jBWEV1r68wn3WfhGNCQuelY6VAMCAgcFAwUNEa5eXLLhou4Q79/e8SDhJlbb+/CLdttxlMgYFV1EzUMBQYGCQ8FDxMNSYmeV81X50vw8OycS9xZ+G+voY44ThqojU1yP2i/QvMiIjHT8xPXDkuLmVLOUs9V5OTavlX+aryVVVYDfIN44L8/GGdgp30R3p6s8lHyYusyMgn76zvb+e6uogy5zJkKzIyT30rfdeV5uZCpJWkm6DAwDv7oPsymBkZqrOYsyfRnp72aNFoXX+joyKBf4GIZkRE7qpmqqh+VFTWgn6Cdqs7O93mq+YWgwsLlZ6DngPKjIzJRcpFlSnHx7x7KXvW02trBW7TblA8KChsRDxEVXmnpyyLeYtj4ry8gT3iPSwdFhYxJx0nQXatrTeadpqtO9vblk07TchWZGSe+lb66E50dKbSTtIoHhQUNiIeIj/bkpLkdtt2GAoMDBIeCh6QbEhI/LRstGvkuLiPN+Q3JV2fn3jnXedhbr29D7JusobvQ0NpKu8qk6bExDXxpvFyqDk52uOo42KkMTHG96T3vTfT04pZN1n/i/LydIaLhrEy1dWDVjJWDUOLi07FQ8XcWW5uhetZ66+32toYwrfCAowBAY6PjI95ZLGxHaxkrCPSnJzxbdJtkuBJSXI74DurtNjYH8e0x0P6rKy5FfoV/Qfz8/oJBwmFJc/PoG8lb4+vysog6q/q84709H2JjomO6UdHZyDpICAYEBA4KBgo3tVvbwtk1WT7iPDwc4OIg5RvSkr7sW+xuHJcXMqWcpZwJDg4VGwkbK7xV1dfCPEI5sdzcyFSx1I1UZeXZPNR840jy8uuZSNlWXyhoSWEfITLnOjoV7+cv3whPj5dYyFjN92Wlup83XzC3GFhHn/cfxqGDQ2ckYaRHoUPD5uUhZTbkODgS6uQq/hCfHy6xkLG4sRxcSZXxFeDqszMKeWq5TvYkJDjc9hzDAUGBgkPBQ/1Aff39AMBAzgSHBwqNhI2n6PCwjz+o/7UX2pqi+Ff4Uf5rq6+EPkQ0tBpaQJr0GsukRcXv6iRqClYmZlx6FjodCc6OlNpJ2lOuScn99C50Kk42dmRSDhIzRPr6941EzVWsysr5c6zzkQzIiJ3VTNVv7vS0gTWu9ZJcKmpOZBwkA6JBweHgImAZqczM8Hyp/Jati0t7MG2wXgiPDxaZiJmKpIVFbitkq2JIMnJqWAgYBVJh4dc20nbT/+qqrAa/xqgeFBQ2Ih4iFF6paUrjnqOBo8DA4mKj4qy+FlZShP4ExKACQmSm4CbNBcaGiM5FznK2mVlEHXadbUx19eEUzFTE8aEhNVRxlG7uNDQA9O40x/DgoLcXsNeUrApKeLLsMu0d1paw5l3mTwRHh4tMxEz9st7ez1Gy0ZL/Kiotx/8H9rWbW0MYdZhWDosLGJOOk4=")),l=y.bytes2Int64Buffer(y.b64Decode("9JelxsYy9KWX64T4+G+XhLDHme7uXrCZjPeN9vZ6jI0X5Q3//+gXDdy3vdbWCty9yKex3t4WyLH8OVSRkW38VPDAUGBgkPBQBQQDAgIHBQPgh6nOzi7gqYesfVZW0Yd9K9UZ5+fMKxmmcWK1tROmYjGa5k1NfDHmtcOa7OxZtZrPBUWPj0DPRbw+nR8fo7ydwAlAiYlJwECS74f6+miShz/FFe/v0D8VJn/rsrKUJutAB8mOjs5AyR3tC/v75h0LL4LsQUFuL+ypfWezsxqpZxy+/V9fQxz9JYrqRUVgJeraRr8jI/navwKm91NTUQL3odOW5ORFoZbtLVubm3btW13qwnV1KF3CJNkc4eHFJBzpeq49PdTprr6YakxM8r5q7thabGyC7lrD/EF+fr3DQQbxAvX18wYC0R1Pg4NS0U/k0FxoaIzkXAei9FFRVgf0XLk00dGNXDQY6Qj5+eEYCK7fk+LiTK6TlU1zq6s+lXP1xFNiYpf1U0FUPyoqa0E/FBAMCAgcFAz2MVKVlWP2Uq+MZUZG6a9l4iFenZ1/4l54YCgwMEh4KPhuoTc3z/ihERQPCgobEQ/EXrUvL+vEtRscCQ4OFRsJWkg2JCR+Wja2NpsbG622m0elPd/fmEc9aoEmzc2naia7nGlOTvW7aUz+zX9/M0zNus+f6upQup8tJBsSEj8tG7k6nh0dpLmenLB0WFjEnHRyaC40NEZyLndsLTY2QXctzaOy3NwRzbIpc+60tJ0p7ha2+1tbTRb7AVP2pKSlAfbX7E12dqHXTaN1Ybe3FKNhSfrOfX00Sc6NpHtSUt+Ne0KhPt3dn0I+k7xxXl7Nk3GiJpcTE7GilwRX9aamogT1uGloubkBuGgAAAAAAAAAAHSZLMHBtXQsoIBgQEDgoGAh3R/j48IhH0PyyHl5OkPILHfttraaLO3Zs77U1A3ZvsoBRo2NR8pGcM7ZZ2cXcNnd5Etycq/dS3kz3pSU7XneZyvUmJj/Z9Qje+iwsJMj6N4RSoWFW95KvW1ru7sGvWt+kSrFxbt+KjSe5U9PezTlOsEW7e3XOhZUF8WGhtJUxWIv15qa+GLX/8xVZmaZ/1WnIpQREbanlEoPz4qKwErPMMkQ6enZMBAKCAYEBA4KBpjngf7+ZpiBC1vwoKCrC/DM8ER4eLTMRNVKuiUl8NW6PpbjS0t1PuMOX/OioqwO8xm6/l1dRBn+WxvAgIDbW8CFCooFBYCFiux+rT8/0+yt30K8ISH+37zY4EhwcKjYSAz5BPHx/QwEesbfY2MZet9Y7sF3dy9YwZ9Fda+vMJ91pYRjQkLnpWNQQDAgIHBQMC7RGuXlyy4aEuEO/f3vEg63ZW2/vwi3bdQZTIGBVdRMPDAUGBgkPBRfTDUmJnlfNXGdL8PDsnEvOGfhvr6GOOH9aqI1Ncj9ok8LzIiIx0/MS1w5Li5lSzn5PVeTk2r5Vw2q8lVVWA3yneOC/PxhnYLJ9Ed6erPJR++LrMjIJ++sMm/nurqIMud9ZCsyMk99K6TXlebmQqSV+5ugwMA7+6CzMpgZGaqzmGgn0Z6e9mjRgV1/o6MigX+qiGZERO6qZoKoflRU1oJ+5narOzvd5queFoMLC5Weg0UDyoyMyUXKe5Upx8e8eylu1tNrawVu00RQPCgobEQ8i1V5p6csi3k9Y+K8vIE94icsHRYWMScdmkF2ra03mnZNrTvb25ZNO/rIVmRknvpW0uhOdHSm0k4iKB4UFDYiHnY/25KS5HbbHhgKDAwSHgq0kGxISPy0bDdr5Li4jzfk5yVdn594512yYW69vQ+ybiqG70NDaSrv8ZOmxMQ18abjcqg5OdrjqPdipDExxvekWb0309OKWTeG/4vy8nSGi1axMtXVg1YyxQ1Di4tOxUPr3FluboXrWcKvt9raGMK3jwKMAQGOj4yseWSxsR2sZG0j0pyc8W3SO5LgSUlyO+DHq7TY2B/HtBVD+qysuRX6Cf0H8/P6CQdvhSXPz6BvJeqPr8rKIOqvifOO9PR9iY4gjulHR2cg6SggGBAQOCgYZN7Vb28LZNWD+4jw8HODiLGUb0pK+7FvlrhyXFzKlnJscCQ4OFRsJAiu8VdXXwjxUubHc3MhUsfzNVGXl2TzUWWNI8vLrmUjhFl8oaElhHy/y5zo6Fe/nGN8IT4+XWMhfDfdlpbqfN1/wtxhYR5/3JEahg0NnJGGlB6FDw+blIWr25Dg4EurkMb4Qnx8usZCV+LEcXEmV8Tlg6rMzCnlqnM72JCQ43PYDwwFBgYJDwUD9QH39/QDATY4EhwcKjYS/p+jwsI8/qPh1F9qaovhXxBH+a6uvhD5a9LQaWkCa9CoLpEXF7+okegpWJmZcehYaXQnOjpTaSfQTrknJ/fQuUipONnZkUg4Nc0T6+veNRPOVrMrK+XOs1VEMyIid1Uz1r+70tIE1ruQSXCpqTmQcIAOiQcHh4CJ8manMzPB8qfBWrYtLezBtmZ4Ijw8WmYirSqSFRW4rZJgiSDJyalgINsVSYeHXNtJGk//qqqwGv+IoHhQUNiIeI5ReqWlK456igaPAwOJio8TsvhZWUoT+JsSgAkJkpuAOTQXGhojORd1ytplZRB12lO1MdfXhFMxURPGhITVUcbTu7jQ0APTuF4fw4KC3F7Dy1KwKSniy7CZtHdaWsOZdzM8ER4eLTMRRvbLe3s9RssfS/yoqLcf/GHa1m1tDGHWTlg6LCxiTjo=")),g=y.bytes2Int64Buffer(y.b64Decode("pfSXpcbGMvSEl+uE+Phvl5mwx5nu7l6wjYz3jfb2eowNF+UN///oF73ct73W1grcscinsd7eFshU/DlUkZFt/FDwwFBgYJDwAwUEAwICBwWp4Iepzs4u4H2HrH1WVtGHGSvVGefnzCtipnFitbUTpuYxmuZNTXwxmrXDmuzsWbVFzwVFj49Az528Pp0fH6O8QMAJQImJScCHku+H+vpokhU/xRXv79A/6yZ/67KylCbJQAfJjo7OQAsd7Qv7++Yd7C+C7EFBbi9nqX1ns7Maqf0cvv1fX0Mc6iWK6kVFYCW/2ka/IyP52vcCpvdTU1EClqHTluTkRaFb7S1bm5t27cJd6sJ1dShdHCTZHOHhxSSu6XquPT3U6Wq+mGpMTPK+Wu7YWmxsgu5Bw/xBfn69wwIG8QL19fMGT9EdT4ODUtFc5NBcaGiM5PQHovRRUVYHNFy5NNHRjVwIGOkI+fnhGJOu35Pi4kyuc5VNc6urPpVT9cRTYmKX9T9BVD8qKmtBDBQQDAgIHBRS9jFSlZVj9mWvjGVGRumvXuIhXp2df+IoeGAoMDBIeKH4bqE3N8/4DxEUDwoKGxG1xF61Ly/rxAkbHAkODhUbNlpINiQkflqbtjabGxuttj1HpT3f35hHJmqBJs3Np2ppu5xpTk71u81M/s1/fzNMn7rPn+rqULobLSQbEhI/LZ65Op4dHaS5dJywdFhYxJwucmguNDRGci13bC02NkF3ss2jstzcEc3uKXPutLSdKfsWtvtbW00W9gFT9qSkpQFN1+xNdnah12GjdWG3txSjzkn6zn19NEl7jaR7UlLfjT5CoT7d3Z9CcZO8cV5ezZOXoiaXExOxovUEV/WmpqIEaLhpaLm5AbgAAAAAAAAAACx0mSzBwbV0YKCAYEBA4KAfId0f4+PCIchD8sh5eTpD7Sx37ba2miy+2bO+1NQN2UbKAUaNjUfK2XDO2WdnF3BL3eRLcnKv3d55M96UlO151Gcr1JiY/2foI3vosLCTI0reEUqFhVvea71ta7u7Br0qfpEqxcW7fuU0nuVPT3s0FjrBFu3t1zrFVBfFhobSVNdiL9eamvhiVf/MVWZmmf+UpyKUERG2p89KD8+KisBKEDDJEOnp2TAGCggGBAQOCoGY54H+/maY8Atb8KCgqwtEzPBEeHi0zLrVSrolJfDV4z6W40tLdT7zDl/zoqKsDv4Zuv5dXUQZwFsbwICA21uKhQqKBQWAha3sfq0/P9PsvN9CvCEh/t9I2OBIcHCo2AQM+QTx8f0M33rG32NjGXrBWO7Bd3cvWHWfRXWvrzCfY6WEY0JC56UwUEAwICBwUBou0Rrl5csuDhLhDv397xJtt2Vtv78It0zUGUyBgVXUFDwwFBgYJDw1X0w1JiZ5Xy9xnS/Dw7Jx4Thn4b6+hjii/WqiNTXI/cxPC8yIiMdPOUtcOS4uZUtX+T1Xk5Nq+fINqvJVVVgNgp3jgvz8YZ1HyfRHenqzyazvi6zIyCfv5zJv57q6iDIrfWQrMjJPfZWk15Xm5kKkoPuboMDAO/uYszKYGRmqs9FoJ9GenvZof4Fdf6OjIoFmqohmRETuqn6CqH5UVNaCq+Z2qzs73eaDnhaDCwuVnspFA8qMjMlFKXuVKcfHvHvTbtbTa2sFbjxEUDwoKGxEeYtVeaenLIviPWPivLyBPR0nLB0WFjEndppBdq2tN5o7Ta0729uWTVb6yFZkZJ76TtLoTnR0ptIeIigeFBQ2Itt2P9uSkuR2Ch4YCgwMEh5stJBsSEj8tOQ3a+S4uI83XeclXZ+feOdusmFuvb0Psu8qhu9DQ2kqpvGTpsTENfGo43KoOTna46T3YqQxMcb3N1m9N9PTilmLhv+L8vJ0hjJWsTLV1YNWQ8UNQ4uLTsVZ69xZbm6F67fCr7fa2hjCjI8CjAEBjo9krHlksbEdrNJtI9KcnPFt4DuS4ElJcju0x6u02Ngfx/oVQ/qsrLkVBwn9B/Pz+gklb4Ulz8+gb6/qj6/KyiDqjonzjvT0fYnpII7pR0dnIBgoIBgQEDgo1WTe1W9vC2SIg/uI8PBzg2+xlG9KSvuxcpa4clxcypYkbHAkODhUbPEIrvFXV18Ix1Lmx3NzIVJR8zVRl5dk8yNljSPLy65lfIRZfKGhJYScv8uc6OhXvyFjfCE+Pl1j3Xw33ZaW6nzcf8LcYWEef4aRGoYNDZyRhZQehQ8Pm5SQq9uQ4OBLq0LG+EJ8fLrGxFfixHFxJleq5YOqzMwp5dhzO9iQkONzBQ8MBQYGCQ8BA/UB9/f0AxI2OBIcHCo2o/6fo8LCPP5f4dRfamqL4fkQR/murr4Q0GvS0GlpAmuRqC6RFxe/qFjoKViZmXHoJ2l0Jzo6U2m50E65Jyf30DhIqTjZ2ZFIEzXNE+vr3jWzzlazKyvlzjNVRDMiIndVu9a/u9LSBNZwkElwqak5kImADokHB4eAp/JmpzMzwfK2wVq2LS3swSJmeCI8PFpmkq0qkhUVuK0gYIkgycmpYEnbFUmHh1zb/xpP/6qqsBp4iKB4UFDYiHqOUXqlpSuOj4oGjwMDiYr4E7L4WVlKE4CbEoAJCZKbFzk0FxoaIznadcraZWUQdTFTtTHX14RTxlETxoSE1VG407u40NAD08NeH8OCgtxesMtSsCkp4st3mbR3WlrDmREzPBEeHi0zy0b2y3t7PUb8H0v8qKi3H9Zh2tZtbQxhOk5YOiwsYk4=")),M=y.bytes2Int64Buffer(y.b64Decode("9KX0l6XGxjKXhJfrhPj4b7CZsMeZ7u5ejI2M94329noXDRflDf//6Ny93Le91tYKyLHIp7He3hb8VPw5VJGRbfBQ8MBQYGCQBQMFBAMCAgfgqeCHqc7OLod9h6x9VlbRKxkr1Rnn58ymYqZxYrW1EzHmMZrmTU18tZq1w5rs7FnPRc8FRY+PQLydvD6dHx+jwEDACUCJiUmSh5Lvh/r6aD8VP8UV7+/QJusmf+uyspRAyUAHyY6Ozh0LHe0L+/vmL+wvguxBQW6pZ6l9Z7OzGhz9HL79X19DJeoliupFRWDav9pGvyMj+QL3Aqb3U1NRoZah05bk5EXtW+0tW5ubdl3CXerCdXUoJBwk2Rzh4cXprul6rj091L5qvphqTEzy7lru2FpsbILDQcP8QX5+vQYCBvEC9fXz0U/RHU+Dg1LkXOTQXGhojAf0B6L0UVFWXDRcuTTR0Y0YCBjpCPn54a6Trt+T4uJMlXOVTXOrqz71U/XEU2Jil0E/QVQ/KiprFAwUEAwICBz2UvYxUpWVY69lr4xlRkbp4l7iIV6dnX94KHhgKDAwSPih+G6hNzfPEQ8RFA8KChvEtcRetS8v6xsJGxwJDg4VWjZaSDYkJH62m7Y2mxsbrUc9R6U939+YaiZqgSbNzae7abucaU5O9UzNTP7Nf38zup+6z5/q6lAtGy0kGxISP7meuTqeHR2knHScsHRYWMRyLnJoLjQ0Rnctd2wtNjZBzbLNo7Lc3BEp7ilz7rS0nRb7Frb7W1tNAfYBU/akpKXXTdfsTXZ2oaNho3Vht7cUSc5J+s59fTSNe42ke1JS30I+QqE+3d2fk3GTvHFeXs2il6ImlxMTsQT1BFf1pqaiuGi4aWi5uQEAAAAAAAAAAHQsdJkswcG1oGCggGBAQOAhHyHdH+PjwkPIQ/LIeXk6LO0sd+22tprZvtmzvtTUDcpGygFGjY1HcNlwztlnZxfdS93kS3Jyr3neeTPelJTtZ9RnK9SYmP8j6CN76LCwk95K3hFKhYVbvWu9bWu7uwZ+Kn6RKsXFuzTlNJ7lT097OhY6wRbt7ddUxVQXxYaG0mLXYi/Xmpr4/1X/zFVmZpmnlKcilBERtkrPSg/PiorAMBAwyRDp6dkKBgoIBgQEDpiBmOeB/v5mC/ALW/CgoKvMRMzwRHh4tNW61Uq6JSXwPuM+luNLS3UO8w5f86KirBn+Gbr+XV1EW8BbG8CAgNuFioUKigUFgOyt7H6tPz/T37zfQrwhIf7YSNjgSHBwqAwEDPkE8fH9et96xt9jYxlYwVjuwXd3L591n0V1r68wpWOlhGNCQudQMFBAMCAgcC4aLtEa5eXLEg4S4Q79/e+3bbdlbb+/CNRM1BlMgYFVPBQ8MBQYGCRfNV9MNSYmeXEvcZ0vw8OyOOE4Z+G+vob9ov1qojU1yE/MTwvMiIjHSzlLXDkuLmX5V/k9V5OTag3yDaryVVVYnYKd44L8/GHJR8n0R3p6s++s74usyMgnMucyb+e6uoh9K31kKzIyT6SVpNeV5uZC+6D7m6DAwDuzmLMymBkZqmjRaCfRnp72gX+BXX+joyKqZqqIZkRE7oJ+gqh+VFTW5qvmdqs7O92eg54WgwsLlUXKRQPKjIzJeyl7lSnHx7xu027W02trBUQ8RFA8KChsi3mLVXmnpyw94j1j4ry8gScdJywdFhYxmnaaQXatrTdNO02tO9vblvpW+shWZGSe0k7S6E50dKYiHiIoHhQUNnbbdj/bkpLkHgoeGAoMDBK0bLSQbEhI/DfkN2vkuLiP513nJV2fn3iybrJhbr29DyrvKobvQ0Np8abxk6bExDXjqONyqDk52vek92KkMTHGWTdZvTfT04qGi4b/i/LydFYyVrEy1dWDxUPFDUOLi07rWevcWW5uhcK3wq+32toYj4yPAowBAY6sZKx5ZLGxHW3SbSPSnJzxO+A7kuBJSXLHtMertNjYHxX6FUP6rKy5CQcJ/Qfz8/pvJW+FJc/PoOqv6o+vysogiY6J84709H0g6SCO6UdHZygYKCAYEBA4ZNVk3tVvbwuDiIP7iPDwc7FvsZRvSkr7lnKWuHJcXMpsJGxwJDg4VAjxCK7xV1dfUsdS5sdzcyHzUfM1UZeXZGUjZY0jy8uuhHyEWXyhoSW/nL/LnOjoV2MhY3whPj5dfN18N92Wlup/3H/C3GFhHpGGkRqGDQ2clIWUHoUPD5urkKvbkODgS8ZCxvhCfHy6V8RX4sRxcSblquWDqszMKXPYczvYkJDjDwUPDAUGBgkDAQP1Aff39DYSNjgSHBwq/qP+n6PCwjzhX+HUX2pqixD5EEf5rq6+a9Br0tBpaQKokagukRcXv+hY6ClYmZlxaSdpdCc6OlPQudBOuScn90g4SKk42dmRNRM1zRPr697Os85Wsysr5VUzVUQzIiJ31rvWv7vS0gSQcJBJcKmpOYCJgA6JBweH8qfyZqczM8HBtsFati0t7GYiZngiPDxarZKtKpIVFbhgIGCJIMnJqdtJ2xVJh4dcGv8aT/+qqrCIeIigeFBQ2I56jlF6paUrio+KBo8DA4kT+BOy+FlZSpuAmxKACQmSORc5NBcaGiN12nXK2mVlEFMxU7Ux19eEUcZRE8aEhNXTuNO7uNDQA17DXh/DgoLcy7DLUrApKeKZd5m0d1pawzMRMzwRHh4tRstG9st7ez0f/B9L/Kiot2HWYdrWbW0MTjpOWDosLGI=")),E=y.bytes2Int64Buffer(y.b64Decode("MvSl9JelxsZvl4SX64T4+F6wmbDHme7ueoyNjPeN9vboFw0X5Q3//wrcvdy3vdbWFsixyKex3t5t/FT8OVSRkZDwUPDAUGBgBwUDBQQDAgIu4Kngh6nOztGHfYesfVZWzCsZK9UZ5+cTpmKmcWK1tXwx5jGa5k1NWbWatcOa7OxAz0XPBUWPj6O8nbw+nR8fScBAwAlAiYlokoeS74f6+tA/FT/FFe/vlCbrJn/rsrLOQMlAB8mOjuYdCx3tC/v7bi/sL4LsQUEaqWepfWezs0Mc/Ry+/V9fYCXqJYrqRUX52r/aRr8jI1EC9wKm91NTRaGWodOW5OR27VvtLVubmyhdwl3qwnV1xSQcJNkc4eHU6a7peq49PfK+ar6YakxMgu5a7thabGy9w0HD/EF+fvMGAgbxAvX1UtFP0R1Pg4OM5Fzk0FxoaFYH9Aei9FFRjVw0XLk00dHhGAgY6Qj5+Uyuk67fk+LiPpVzlU1zq6uX9VP1xFNiYmtBP0FUPyoqHBQMFBAMCAhj9lL2MVKVlemvZa+MZUZGf+Je4iFenZ1IeCh4YCgwMM/4ofhuoTc3GxEPERQPCgrrxLXEXrUvLxUbCRscCQ4Oflo2Wkg2JCSttpu2NpsbG5hHPUelPd/fp2omaoEmzc31u2m7nGlOTjNMzUz+zX9/ULqfus+f6uo/LRstJBsSEqS5nrk6nh0dxJx0nLB0WFhGci5yaC40NEF3LXdsLTY2Ec2yzaOy3NydKe4pc+60tE0W+xa2+1tbpQH2AVP2pKSh103X7E12dhSjYaN1Ybe3NEnOSfrOfX3fjXuNpHtSUp9CPkKhPt3dzZNxk7xxXl6xopeiJpcTE6IE9QRX9aamAbhouGloubkAAAAAAAAAALV0LHSZLMHB4KBgoIBgQEDCIR8h3R/j4zpDyEPyyHl5miztLHfttrYN2b7Zs77U1EfKRsoBRo2NF3DZcM7ZZ2ev3Uvd5Etycu153nkz3pSU/2fUZyvUmJiTI+gje+iwsFveSt4RSoWFBr1rvW1ru7u7fip+kSrFxXs05TSe5U9P1zoWOsEW7e3SVMVUF8WGhvhi12Iv15qamf9V/8xVZma2p5SnIpQREcBKz0oPz4qK2TAQMMkQ6ekOCgYKCAYEBGaYgZjngf7+qwvwC1vwoKC0zETM8ER4ePDVutVKuiUldT7jPpbjS0usDvMOX/OiokQZ/hm6/l1d21vAWxvAgICAhYqFCooFBdPsrex+rT8//t+830K8ISGo2EjY4EhwcP0MBAz5BPHxGXrfesbfY2MvWMFY7sF3dzCfdZ9Fda+v56VjpYRjQkJwUDBQQDAgIMsuGi7RGuXl7xIOEuEO/f0It223ZW2/v1XUTNQZTIGBJDwUPDAUGBh5XzVfTDUmJrJxL3GdL8PDhjjhOGfhvr7I/aL9aqI1NcdPzE8LzIiIZUs5S1w5Li5q+Vf5PVeTk1gN8g2q8lVVYZ2CneOC/PyzyUfJ9Ed6eifvrO+LrMjIiDLnMm/nurpPfSt9ZCsyMkKklaTXlebmO/ug+5ugwMCqs5izMpgZGfZo0Wgn0Z6eIoF/gV1/o6PuqmaqiGZERNaCfoKoflRU3ear5narOzuVnoOeFoMLC8lFykUDyoyMvHspe5Upx8cFbtNu1tNra2xEPERQPCgoLIt5i1V5p6eBPeI9Y+K8vDEnHScsHRYWN5p2mkF2ra2WTTtNrTvb2576VvrIVmRkptJO0uhOdHQ2Ih4iKB4UFOR223Y/25KSEh4KHhgKDAz8tGy0kGxISI835Ddr5Li4eOdd5yVdn58Psm6yYW69vWkq7yqG70NDNfGm8ZOmxMTa46jjcqg5Ocb3pPdipDExilk3Wb0309N0houG/4vy8oNWMlaxMtXVTsVDxQ1Di4uF61nr3FlubhjCt8Kvt9rajo+MjwKMAQEdrGSseWSxsfFt0m0j0pyccjvgO5LgSUkfx7THq7TY2LkV+hVD+qys+gkHCf0H8/OgbyVvhSXPzyDqr+qPr8rKfYmOifOO9PRnIOkgjulHRzgoGCggGBAQC2TVZN7Vb29zg4iD+4jw8Puxb7GUb0pKypZylrhyXFxUbCRscCQ4OF8I8Qiu8VdXIVLHUubHc3Nk81HzNVGXl65lI2WNI8vLJYR8hFl8oaFXv5y/y5zo6F1jIWN8IT4+6nzdfDfdlpYef9x/wtxhYZyRhpEahg0Nm5SFlB6FDw9Lq5Cr25Dg4LrGQsb4Qnx8JlfEV+LEcXEp5arlg6rMzONz2HM72JCQCQ8FDwwFBgb0AwED9QH39yo2EjY4EhwcPP6j/p+jwsKL4V/h1F9qar4Q+RBH+a6uAmvQa9LQaWm/qJGoLpEXF3HoWOgpWJmZU2knaXQnOjr30LnQTrknJ5FIOEipONnZ3jUTNc0T6+vlzrPOVrMrK3dVM1VEMyIiBNa71r+70tI5kHCQSXCpqYeAiYAOiQcHwfKn8manMzPswbbBWrYtLVpmImZ4Ijw8uK2SrSqSFRWpYCBgiSDJyVzbSdsVSYeHsBr/Gk//qqrYiHiIoHhQUCuOeo5ReqWliYqPigaPAwNKE/gTsvhZWZKbgJsSgAkJIzkXOTQXGhoQddp1ytplZYRTMVO1MdfX1VHGURPGhIQD07jTu7jQ0Nxew14fw4KC4suwy1KwKSnDmXeZtHdaWi0zETM8ER4ePUbLRvbLe3u3H/wfS/yoqAxh1mHa1m1tYk46Tlg6LCw=")),d=function(L,N){if(L===7)return N.lo&255;var j=(7-L)*8;if(j>=32)return N.hi>>>j-32&255;var K=32-j,$=this.hi<<K>>>K;return(N.lo>>>j|$<<K)&255},A=[S.u(0,0),S.u(0,16),S.u(0,32),S.u(0,48),S.u(0,64),S.u(0,80),S.u(0,96),S.u(0,112),S.u(0,128),S.u(0,144),S.u(0,160),S.u(0,176),S.u(0,192),S.u(0,208),S.u(0,224),S.u(0,240)],v=[S.u(4294967295,4294967295),S.u(4294967295,4294967279),S.u(4294967295,4294967263),S.u(4294967295,4294967247),S.u(4294967295,4294967231),S.u(4294967295,4294967215),S.u(4294967295,4294967199),S.u(4294967295,4294967183),S.u(4294967295,4294967167),S.u(4294967295,4294967151),S.u(4294967295,4294967135),S.u(4294967295,4294967119),S.u(4294967295,4294967103),S.u(4294967295,4294967087),S.u(4294967295,4294967071),S.u(4294967295,4294967055)],b=[S.u(0,0),S.u(0,1),S.u(0,2),S.u(0,3),S.u(0,4),S.u(0,5),S.u(0,6),S.u(0,7),S.u(0,8),S.u(0,9),S.u(0,10),S.u(0,11),S.u(0,12),S.u(0,13)],k=function(L,N){for(var j=new Array(16),K=new Array(16),$=0;$<16;$++)K[$]=L[$],j[$]=K[$].xor(N[$]);for(var Q=new Array(16),Y=0;Y<14;Y++){for(var ee=0;ee<16;ee++)j[ee].setxor64(A[ee].plus(b[Y]).setShiftLeft(56));for(var $=0;$<16;$++)Q[$]=S.xor64(p[d(0,j[$])],I[d(1,j[$+1&15])],o[d(2,j[$+2&15])],m[d(3,j[$+3&15])],l[d(4,j[$+4&15])],g[d(5,j[$+5&15])],M[d(6,j[$+6&15])],E[d(7,j[$+11&15])]);var u=j;j=Q,Q=u}for(var Y=0;Y<14;Y++){for(var ee=0;ee<16;ee++)K[ee].setxor64(b[Y],v[ee]);for(var $=0;$<16;$++)Q[$]=S.xor64(p[d(0,K[$+1&15])],I[d(1,K[$+3&15])],o[d(2,K[$+5&15])],m[d(3,K[$+11&15])],l[d(4,K[$+0&15])],g[d(5,K[$+2&15])],M[d(6,K[$+4&15])],E[d(7,K[$+6&15])]);var u=K;K=Q,Q=u}for(var $=0;$<16;$++)N[$].setxor64(j[$],K[$])},B=function(L){var N=new Array(16);S.bufferInsert64(N,0,L,16);for(var j=new Array(16),K=0;K<14;K++){for(var $=0;$<16;$++)N[$].setxor64(A[$].plus(b[K]).setShiftLeft(56));for(var Q=0;Q<16;Q++)j[Q]=S.xor64(p[d(0,N[Q])],I[d(1,N[Q+1&15])],o[d(2,N[Q+2&15])],m[d(3,N[Q+3&15])],l[d(4,N[Q+4&15])],g[d(5,N[Q+5&15])],M[d(6,N[Q+6&15])],E[d(7,N[Q+11&15])]);var Y=N;N=j,j=Y}for(var Q=0;Q<16;Q++)L[Q].setxor64(N[Q])},U=function(L,N,j){var K,$,Q=new Array(16);if(K=L.buffer,$=L.ptr,j<L.buffer.length-$){S.bufferInsert(K,$,N,N.length),$+=N.length,L.ptr=$;return}for(S.bufferInsert(Q,0,L.state,16);j>0;){var Y=L.buffer.length-$;if(Y>j&&(Y=j),S.bufferInsert(K,$,N,Y),$+=Y,N=N.slice(Y),j-=Y,$===L.buffer.length){var ee=y.bytes2Int64Buffer(K);k(ee,Q),L.count.addOne(),$=0}}L.state=Q,L.ptr=$},C=function(L){var N=L.buffer,j=L.ptr,K=new Array(136),$=N.length,Q,Y;K[0]=128,j<120?(Q=128-j,Y=L.count.plus(S.u(0,1))):(Q=256-j,Y=L.count.plus(S.u(0,2))),S.bufferSet(K,1,0,Q-9),y.bufferEncode64(K,Q-8,Y),U(L,K,Q),B(L.state);for(var ee=new Array(16),u=0,e=8;u<8;u++,e++)ee[2*u]=L.state[e].hi,ee[2*u+1]=L.state[e].lo;return ee};fe.exports=function(L,N,j){var K;N===1?K=L:N===2?K=y.int32Buffer2Bytes(L):K=y.string2bytes(L);var $={};$.state=new Array(16);for(var Q=0;Q<15;Q++)$.state[Q]=new S.u64(0,0);$.state[15]=new S.u64(0,512),$.ptr=0,$.count=new S.u64(0,0),$.buffer=new Array(128),U($,K,K.length);var Y=C($,0,0),ee;return j===2?ee=Y:j===1?ee=y.int32Buffer2Bytes(Y):ee=y.int32ArrayToHexString(Y),ee}},5174:(fe,x,T)=>{"use strict";var S=T(7749);fe.exports.int8ArrayToHexString=function(I){for(var o="",m=0;m<I.length;m++)I[m]<16?o+="0"+I[m].toString(16):o+=I[m].toString(16);return o},fe.exports.int32ArrayToHexString=function(I){for(var o="",m=I.length,l=0;l<m;l++){var g=I[l];g<0&&(g=4294967295+I[l]+1);for(var M=g.toString(16),E=8;M.length<E;)M="0"+M;o+=M}return o},fe.exports.hex2string=function(I){for(var o=[],m=I.length,l=0;l<m;l+=2)o.push(String.fromCharCode(parseInt(I.substring(l,l+2),16)));return o.join("")},fe.exports.hex2bytes=function(I){for(var o=[],m=I.length,l=0;l<m;l+=2)o.push(parseInt(I.substring(l,l+2),16));return o},fe.exports.string2bytes=function(p){for(var I=p.length,o=new Array(I),m=0;m<I;)o[m]=p.charCodeAt(m),m++;return o},fe.exports.bytes2Int32Buffer=function(p){if(!p)return[];for(var I=p.length?(p.length-1>>>2)+1:0,o=new Array(I),m=0;m<I;)o[m]=p[m*4]<<24|p[m*4+1]<<16|p[m*4+2]<<8|p[m*4+3],m++;return o},fe.exports.bytes2Int64Buffer=function(p){if(!p)return[];for(var I=p.length?(p.length-1>>>3)+1:0,o=new Array(I),m=0;m<I;)o[m]=new S.u64(p[m*8]<<24|p[m*8+1]<<16|p[m*8+2]<<8|p[m*8+3],p[m*8+4]<<24|p[m*8+5]<<16|p[m*8+6]<<8|p[m*8+7]),m++;return o},fe.exports.bytes2Int64BufferLeAligned=function(p){if(!p)return[];for(var I=p.length?(p.length-1>>>3)+1:0,o=new Array(I),m=0;m<I;)o[m]=new S.u64(p[m*8+7]<<24|p[m*8+6]<<16|p[m*8+5]<<8|p[m*8+4],p[m*8+3]<<24|p[m*8+2]<<16|p[m*8+1]<<8|p[m*8]),m++;return o},fe.exports.bufferEncode64leAligned=function(p,I,o){p[I+7]=o.hi>>>24,p[I+6]=o.hi>>>16&255,p[I+5]=o.hi>>>8&255,p[I+4]=o.hi&255,p[I+3]=o.lo>>>24,p[I+2]=o.lo>>>16&255,p[I+1]=o.lo>>>8&255,p[I+0]=o.lo&255},fe.exports.bufferEncode64=function(p,I,o){p[I]=o.hi>>>24,p[I+1]=o.hi>>>16&255,p[I+2]=o.hi>>>8&255,p[I+3]=o.hi&255,p[I+4]=o.lo>>>24,p[I+5]=o.lo>>>16&255,p[I+6]=o.lo>>>8&255,p[I+7]=o.lo&255},fe.exports.int32Buffer2Bytes=function(p){for(var I=new Array(p.length),o=p.length,m=0;m<o;)I[m*4]=(p[m]&4278190080)>>>24,I[m*4+1]=(p[m]&16711680)>>>16,I[m*4+2]=(p[m]&65280)>>>8,I[m*4+3]=p[m]&255,m++;return I},fe.exports.string2Int32Buffer=function(p){return this.bytes2Int32Buffer(this.string2bytes(p))};var y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";fe.exports.b64Encode=function(p){for(var I="",o,m,l,g,M,E,d,A=0;A<p.length;)o=p[A++],m=p[A++],l=p[A++],g=o>>2,M=(o&3)<<4|m>>4,E=(m&15)<<2|l>>6,d=l&63,isNaN(m)?E=d=64:isNaN(l)&&(d=64),I+=y.charAt(g)+y.charAt(M)+y.charAt(E)+y.charAt(d);return I},fe.exports.b64Decode=function(p){var I=[],o,m,l,g,M,E,d,A=0;for(p=p.replace(/[^A-Za-z0-9\+\/\=]/g,"");A<p.length;)g=y.indexOf(p.charAt(A++)),M=y.indexOf(p.charAt(A++)),E=y.indexOf(p.charAt(A++)),d=y.indexOf(p.charAt(A++)),o=g<<2|M>>4,m=(M&15)<<4|E>>2,l=(E&3)<<6|d,I.push(o),E!=64&&I.push(m),d!=64&&I.push(l);return I}},7749:fe=>{"use strict";function x(y,p){this.hi=y>>>0,this.lo=p>>>0}x.prototype.set=function(y){this.lo=y.lo,this.hi=y.hi},x.prototype.add=function(y){var p,I,o,m;return p=(this.lo&65535)+(y.lo&65535),I=(this.lo>>>16)+(y.lo>>>16)+(p>>>16),o=(this.hi&65535)+(y.hi&65535)+(I>>>16),m=(this.hi>>>16)+(y.hi>>>16)+(o>>>16),this.lo=I<<16|p&65535,this.hi=m<<16|o&65535,this},x.prototype.addOne=function(){this.lo===-1||this.lo===4294967295?(this.lo=0,this.hi++):this.lo++},x.prototype.plus=function(y){var p=new x(0,0),I,o,m,l;return I=(this.lo&65535)+(y.lo&65535),o=(this.lo>>>16)+(y.lo>>>16)+(I>>>16),m=(this.hi&65535)+(y.hi&65535)+(o>>>16),l=(this.hi>>>16)+(y.hi>>>16)+(m>>>16),p.lo=o<<16|I&65535,p.hi=l<<16|m&65535,p},x.prototype.not=function(){return new x(~this.hi,~this.lo)},x.prototype.one=function(){return new x(0,1)},x.prototype.zero=function(){return new x(0,0)},x.prototype.neg=function(){return this.not().plus(this.one())},x.prototype.minus=function(y){return this.plus(y.neg())},x.prototype.isZero=function(){return this.lo===0&&this.hi===0};function T(y){return(y&&y.__isLong__)===!0}function S(y){if(isNaN(y)||!isFinite(y))return this.zero();var p=1;return new x(y%p|0,y/p|0)}x.prototype.multiply=function(y){if(this.isZero())return this.zero();if(T(y)||(y=S(y)),y.isZero())return this.zero();var p=this.hi>>>16,I=this.hi&65535,o=this.lo>>>16,m=this.lo&65535,l=y.hi>>>16,g=y.hi&65535,M=y.lo>>>16,E=y.lo&65535,d=0,A=0,v=0,b=0;return b+=m*E,v+=b>>>16,b&=65535,v+=o*E,A+=v>>>16,v&=65535,v+=m*M,A+=v>>>16,v&=65535,A+=I*E,d+=A>>>16,A&=65535,A+=o*M,d+=A>>>16,A&=65535,A+=m*g,d+=A>>>16,A&=65535,d+=p*E+I*M+o*g+m*l,d&=65535,new x(d<<16|A,v<<16|b)},x.prototype.shiftLeft=function(y){y=y%64;var p=new x(0,0);if(y===0)return this.clone();if(y>31)p.lo=0,p.hi=this.lo<<y-32;else{var I=this.lo>>>32-y;p.lo=this.lo<<y,p.hi=this.hi<<y|I}return p},x.prototype.setShiftLeft=function(y){if(y===0)return this;if(y>63&&(y=y%64),y>31)this.hi=this.lo<<y-32,this.lo=0;else{var p=this.lo>>>32-y;this.lo<<=y,this.hi=this.hi<<y|p}return this},x.prototype.shiftRight=function(y){y=y%64;var p=new x(0,0);if(y===0)return this.clone();if(y>=32)p.hi=0,p.lo=this.hi>>>y-32;else{var I=32-y,o=this.hi<<I>>>I;p.hi=this.hi>>>y,p.lo=this.lo>>>y|o<<I}return p},x.prototype.rotateLeft=function(y){if(y>32)return this.rotateRight(64-y);var p=new x(0,0);return y===0?(p.lo=this.lo>>>0,p.hi=this.hi>>>0):y===32?(p.lo=this.hi,p.hi=this.lo):(p.lo=this.lo<<y|this.hi>>>32-y,p.hi=this.hi<<y|this.lo>>>32-y),p},x.prototype.setRotateLeft=function(y){if(y>32)return this.setRotateRight(64-y);var p;return y===0?this:(y===32?(p=this.lo,this.lo=this.hi,this.hi=p):(p=this.hi<<y|this.lo>>>32-y,this.lo=this.lo<<y|this.hi>>>32-y,this.hi=p),this)},x.prototype.rotateRight=function(y){if(y>32)return this.rotateLeft(64-y);var p=new x(0,0);return y===0?(p.lo=this.lo>>>0,p.hi=this.hi>>>0):y===32?(p.lo=this.hi,p.hi=this.lo):(p.lo=this.hi<<32-y|this.lo>>>y,p.hi=this.lo<<32-y|this.hi>>>y),p},x.prototype.setFlip=function(){var y;return y=this.lo,this.lo=this.hi,this.hi=y,this},x.prototype.setRotateRight=function(y){if(y>32)return this.setRotateLeft(64-y);if(y===0)return this;if(y===32){var p;p=this.lo,this.lo=this.hi,this.hi=p}else p=this.lo<<32-y|this.hi>>>y,this.lo=this.hi<<32-y|this.lo>>>y,this.hi=p;return this},x.prototype.xor=function(y){var p=new x(0,0);return p.hi=this.hi^y.hi,p.lo=this.lo^y.lo,p},x.prototype.setxorOne=function(y){return this.hi^=y.hi,this.lo^=y.lo,this},x.prototype.and=function(y){var p=new x(0,0);return p.hi=this.hi&y.hi,p.lo=this.lo&y.lo,p},x.prototype.clone=function(){return new x(this.hi,this.lo)},x.prototype.setxor64=function(){for(var y=arguments,p=y.length;p--;)this.hi^=y[p].hi,this.lo^=y[p].lo;return this},fe.exports.u64=x,fe.exports.u=function(y,p){return new x(y,p)},fe.exports.xor64=function(){var y=arguments,p=y[0].hi,I=y[0].lo,o=y.length-1;do p^=y[o].hi,I^=y[o].lo,o--;while(o>0);return new this.u64(p,I)},fe.exports.clone64Array=function(y){for(var p=0,I=y.length,o=new Array(I);p<I;)o[p]=y[p],p++;return o},fe.exports.t32=function(y){return y&4294967295},fe.exports.rotl32=function(y,p){return(y<<p|y>>>32-p)&4294967295},fe.exports.rotr32=function(y,p){return this.rotl32(y,32-p)},fe.exports.swap32=function(y){return(y&255)<<24|(y&65280)<<8|y>>>8&65280|y>>>24&255},fe.exports.swap32Array=function(y){for(var p=0,I=y.length,o=new Array(p);p<I;)o[p]=this.swap32(y[p]),p++;return o},fe.exports.xnd64=function(y,p,I){return new this.u64(y.hi^~p.hi&I.hi,y.lo^~p.lo&I.lo)},fe.exports.bufferInsert=function(y,p,I,o,m){m=m|0;for(var l=0;l<o;)y[l+p]=I[l+m],l++},fe.exports.bufferInsert64=function(y,p,I,o){for(var m=0;m<o;)y[m+p]=I[m].clone(),m++},fe.exports.bufferInsertBackwards=function(y,p,I,o){for(var m=0;m<o;)y[m+p]=I[o-1-m],m++},fe.exports.bufferSet=function(y,p,I,o){for(var m=0;m<o;)y[m+p]=I,m++},fe.exports.bufferXORInsert=function(y,p,I,o,m){for(var l=0;l<m;)y[l+p]^=I[l+o],l++},fe.exports.xORTable=function(y,p,I,o){for(var m=0;m<o;)y[m]=p[m]^I[m],m++}},4729:(fe,x,T)=>{"use strict";var S=T(2861).Buffer,y=T(1603).Transform,p=T(6698);function I(m,l){if(!S.isBuffer(m)&&typeof m!="string")throw new TypeError(l+" must be a string or a buffer")}function o(m){y.call(this),this._block=S.allocUnsafe(m),this._blockSize=m,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}p(o,y),o.prototype._transform=function(m,l,g){var M=null;try{this.update(m,l)}catch(E){M=E}g(M)},o.prototype._flush=function(m){var l=null;try{this.push(this.digest())}catch(g){l=g}m(l)},o.prototype.update=function(m,l){if(I(m,"Data"),this._finalized)throw new Error("Digest already called");S.isBuffer(m)||(m=S.from(m,l));for(var g=this._block,M=0;this._blockOffset+m.length-M>=this._blockSize;){for(var E=this._blockOffset;E<this._blockSize;)g[E++]=m[M++];this._update(),this._blockOffset=0}for(;M<m.length;)g[this._blockOffset++]=m[M++];for(var d=0,A=m.length*8;A>0;++d)this._length[d]+=A,A=this._length[d]/4294967296|0,A>0&&(this._length[d]-=4294967296*A);return this},o.prototype._update=function(){throw new Error("_update is not implemented")},o.prototype.digest=function(m){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var l=this._digest();m!==void 0&&(l=l.toString(m)),this._block.fill(0),this._blockOffset=0;for(var g=0;g<4;++g)this._length[g]=0;return l},o.prototype._digest=function(){throw new Error("_digest is not implemented")},fe.exports=o},2260:fe=>{"use strict";function x(m,l){m.prototype=Object.create(l.prototype),m.prototype.constructor=m,m.__proto__=l}var T={};function S(m,l,g){g||(g=Error);function M(d,A,v){return typeof l=="string"?l:l(d,A,v)}var E=function(d){x(A,d);function A(v,b,k){return d.call(this,M(v,b,k))||this}return A}(g);E.prototype.name=g.name,E.prototype.code=m,T[m]=E}function y(m,l){if(Array.isArray(m)){var g=m.length;return m=m.map(function(M){return String(M)}),g>2?"one of ".concat(l," ").concat(m.slice(0,g-1).join(", "),", or ")+m[g-1]:g===2?"one of ".concat(l," ").concat(m[0]," or ").concat(m[1]):"of ".concat(l," ").concat(m[0])}else return"of ".concat(l," ").concat(String(m))}function p(m,l,g){return m.substr(!g||g<0?0:+g,l.length)===l}function I(m,l,g){return(g===void 0||g>m.length)&&(g=m.length),m.substring(g-l.length,g)===l}function o(m,l,g){return typeof g!="number"&&(g=0),g+l.length>m.length?!1:m.indexOf(l,g)!==-1}S("ERR_INVALID_OPT_VALUE",function(m,l){return'The value "'+l+'" is invalid for option "'+m+'"'},TypeError),S("ERR_INVALID_ARG_TYPE",function(m,l,g){var M;typeof l=="string"&&p(l,"not ")?(M="must not be",l=l.replace(/^not /,"")):M="must be";var E;if(I(m," argument"))E="The ".concat(m," ").concat(M," ").concat(y(l,"type"));else{var d=o(m,".")?"property":"argument";E='The "'.concat(m,'" ').concat(d," ").concat(M," ").concat(y(l,"type"))}return E+=". Received type ".concat(typeof g),E},TypeError),S("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),S("ERR_METHOD_NOT_IMPLEMENTED",function(m){return"The "+m+" method is not implemented"}),S("ERR_STREAM_PREMATURE_CLOSE","Premature close"),S("ERR_STREAM_DESTROYED",function(m){return"Cannot call "+m+" after a stream was destroyed"}),S("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),S("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),S("ERR_STREAM_WRITE_AFTER_END","write after end"),S("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),S("ERR_UNKNOWN_ENCODING",function(m){return"Unknown encoding: "+m},TypeError),S("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),fe.exports.F=T},2818:(fe,x,T)=>{"use strict";var S=T(5606),y=Object.keys||function(d){var A=[];for(var v in d)A.push(v);return A};fe.exports=g;var p=T(6736),I=T(2192);T(6698)(g,p);for(var o=y(I.prototype),m=0;m<o.length;m++){var l=o[m];g.prototype[l]||(g.prototype[l]=I.prototype[l])}function g(d){if(!(this instanceof g))return new g(d);p.call(this,d),I.call(this,d),this.allowHalfOpen=!0,d&&(d.readable===!1&&(this.readable=!1),d.writable===!1&&(this.writable=!1),d.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",M)))}Object.defineProperty(g.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(g.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(g.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function M(){this._writableState.ended||S.nextTick(E,this)}function E(d){d.end()}Object.defineProperty(g.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(A){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=A,this._writableState.destroyed=A)}})},5860:(fe,x,T)=>{"use strict";fe.exports=y;var S=T(3054);T(6698)(y,S);function y(p){if(!(this instanceof y))return new y(p);S.call(this,p)}y.prototype._transform=function(p,I,o){o(null,p)}},6736:(fe,x,T)=>{"use strict";var S=T(5606);fe.exports=e;var y;e.ReadableState=u;var p=T(7007).EventEmitter,I=function(J,pe){return J.listeners(pe).length},o=T(1181),m=T(8287).Buffer,l=T.g.Uint8Array||function(){};function g(ie){return m.from(ie)}function M(ie){return m.isBuffer(ie)||ie instanceof l}var E=T(2382),d;E&&E.debuglog?d=E.debuglog("stream"):d=function(){};var A=T(2389),v=T(1468),b=T(8775),k=b.getHighWaterMark,B=T(2260).F,U=B.ERR_INVALID_ARG_TYPE,C=B.ERR_STREAM_PUSH_AFTER_EOF,L=B.ERR_METHOD_NOT_IMPLEMENTED,N=B.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,j,K,$;T(6698)(e,o);var Q=v.errorOrDestroy,Y=["error","close","destroy","pause","resume"];function ee(ie,J,pe){if(typeof ie.prependListener=="function")return ie.prependListener(J,pe);!ie._events||!ie._events[J]?ie.on(J,pe):Array.isArray(ie._events[J])?ie._events[J].unshift(pe):ie._events[J]=[pe,ie._events[J]]}function u(ie,J,pe){y=y||T(2818),ie=ie||{},typeof pe!="boolean"&&(pe=J instanceof y),this.objectMode=!!ie.objectMode,pe&&(this.objectMode=this.objectMode||!!ie.readableObjectMode),this.highWaterMark=k(this,ie,"readableHighWaterMark",pe),this.buffer=new A,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=ie.emitClose!==!1,this.autoDestroy=!!ie.autoDestroy,this.destroyed=!1,this.defaultEncoding=ie.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,ie.encoding&&(j||(j=T(3141).I),this.decoder=new j(ie.encoding),this.encoding=ie.encoding)}function e(ie){if(y=y||T(2818),!(this instanceof e))return new e(ie);var J=this instanceof y;this._readableState=new u(ie,this,J),this.readable=!0,ie&&(typeof ie.read=="function"&&(this._read=ie.read),typeof ie.destroy=="function"&&(this._destroy=ie.destroy)),o.call(this)}Object.defineProperty(e.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(J){this._readableState&&(this._readableState.destroyed=J)}}),e.prototype.destroy=v.destroy,e.prototype._undestroy=v.undestroy,e.prototype._destroy=function(ie,J){J(ie)},e.prototype.push=function(ie,J){var pe=this._readableState,Ge;return pe.objectMode?Ge=!0:typeof ie=="string"&&(J=J||pe.defaultEncoding,J!==pe.encoding&&(ie=m.from(ie,J),J=""),Ge=!0),r(this,ie,J,!1,Ge)},e.prototype.unshift=function(ie){return r(this,ie,null,!0,!1)};function r(ie,J,pe,Ge,ce){d("readableAddChunk",J);var te=ie._readableState;if(J===null)te.reading=!1,s(ie,te);else{var le;if(ce||(le=i(te,J)),le)Q(ie,le);else if(te.objectMode||J&&J.length>0)if(typeof J!="string"&&!te.objectMode&&Object.getPrototypeOf(J)!==m.prototype&&(J=g(J)),Ge)te.endEmitted?Q(ie,new N):n(ie,te,J,!0);else if(te.ended)Q(ie,new C);else{if(te.destroyed)return!1;te.reading=!1,te.decoder&&!pe?(J=te.decoder.write(J),te.objectMode||J.length!==0?n(ie,te,J,!1):w(ie,te)):n(ie,te,J,!1)}else Ge||(te.reading=!1,w(ie,te))}return!te.ended&&(te.length<te.highWaterMark||te.length===0)}function n(ie,J,pe,Ge){J.flowing&&J.length===0&&!J.sync?(J.awaitDrain=0,ie.emit("data",pe)):(J.length+=J.objectMode?1:pe.length,Ge?J.buffer.unshift(pe):J.buffer.push(pe),J.needReadable&&t(ie)),w(ie,J)}function i(ie,J){var pe;return!M(J)&&typeof J!="string"&&J!==void 0&&!ie.objectMode&&(pe=new U("chunk",["string","Buffer","Uint8Array"],J)),pe}e.prototype.isPaused=function(){return this._readableState.flowing===!1},e.prototype.setEncoding=function(ie){j||(j=T(3141).I);var J=new j(ie);this._readableState.decoder=J,this._readableState.encoding=this._readableState.decoder.encoding;for(var pe=this._readableState.buffer.head,Ge="";pe!==null;)Ge+=J.write(pe.data),pe=pe.next;return this._readableState.buffer.clear(),Ge!==""&&this._readableState.buffer.push(Ge),this._readableState.length=Ge.length,this};var f=1073741824;function c(ie){return ie>=f?ie=f:(ie--,ie|=ie>>>1,ie|=ie>>>2,ie|=ie>>>4,ie|=ie>>>8,ie|=ie>>>16,ie++),ie}function h(ie,J){return ie<=0||J.length===0&&J.ended?0:J.objectMode?1:ie!==ie?J.flowing&&J.length?J.buffer.head.data.length:J.length:(ie>J.highWaterMark&&(J.highWaterMark=c(ie)),ie<=J.length?ie:J.ended?J.length:(J.needReadable=!0,0))}e.prototype.read=function(ie){d("read",ie),ie=parseInt(ie,10);var J=this._readableState,pe=ie;if(ie!==0&&(J.emittedReadable=!1),ie===0&&J.needReadable&&((J.highWaterMark!==0?J.length>=J.highWaterMark:J.length>0)||J.ended))return d("read: emitReadable",J.length,J.ended),J.length===0&&J.ended?oe(this):t(this),null;if(ie=h(ie,J),ie===0&&J.ended)return J.length===0&&oe(this),null;var Ge=J.needReadable;d("need readable",Ge),(J.length===0||J.length-ie<J.highWaterMark)&&(Ge=!0,d("length less than watermark",Ge)),J.ended||J.reading?(Ge=!1,d("reading or ended",Ge)):Ge&&(d("do read"),J.reading=!0,J.sync=!0,J.length===0&&(J.needReadable=!0),this._read(J.highWaterMark),J.sync=!1,J.reading||(ie=h(pe,J)));var ce;return ie>0?ce=H(ie,J):ce=null,ce===null?(J.needReadable=J.length<=J.highWaterMark,ie=0):(J.length-=ie,J.awaitDrain=0),J.length===0&&(J.ended||(J.needReadable=!0),pe!==ie&&J.ended&&oe(this)),ce!==null&&this.emit("data",ce),ce};function s(ie,J){if(d("onEofChunk"),!J.ended){if(J.decoder){var pe=J.decoder.end();pe&&pe.length&&(J.buffer.push(pe),J.length+=J.objectMode?1:pe.length)}J.ended=!0,J.sync?t(ie):(J.needReadable=!1,J.emittedReadable||(J.emittedReadable=!0,a(ie)))}}function t(ie){var J=ie._readableState;d("emitReadable",J.needReadable,J.emittedReadable),J.needReadable=!1,J.emittedReadable||(d("emitReadable",J.flowing),J.emittedReadable=!0,S.nextTick(a,ie))}function a(ie){var J=ie._readableState;d("emitReadable_",J.destroyed,J.length,J.ended),!J.destroyed&&(J.length||J.ended)&&(ie.emit("readable"),J.emittedReadable=!1),J.needReadable=!J.flowing&&!J.ended&&J.length<=J.highWaterMark,G(ie)}function w(ie,J){J.readingMore||(J.readingMore=!0,S.nextTick(D,ie,J))}function D(ie,J){for(;!J.reading&&!J.ended&&(J.length<J.highWaterMark||J.flowing&&J.length===0);){var pe=J.length;if(d("maybeReadMore read 0"),ie.read(0),pe===J.length)break}J.readingMore=!1}e.prototype._read=function(ie){Q(this,new L("_read()"))},e.prototype.pipe=function(ie,J){var pe=this,Ge=this._readableState;switch(Ge.pipesCount){case 0:Ge.pipes=ie;break;case 1:Ge.pipes=[Ge.pipes,ie];break;default:Ge.pipes.push(ie);break}Ge.pipesCount+=1,d("pipe count=%d opts=%j",Ge.pipesCount,J);var ce=(!J||J.end!==!1)&&ie!==S.stdout&&ie!==S.stderr,te=ce?ge:je;Ge.endEmitted?S.nextTick(te):pe.once("end",te),ie.on("unpipe",le);function le(Ie,Ce){d("onunpipe"),Ie===pe&&Ce&&Ce.hasUnpiped===!1&&(Ce.hasUnpiped=!0,Le())}function ge(){d("onend"),ie.end()}var Pe=Z(pe);ie.on("drain",Pe);var lt=!1;function Le(){d("cleanup"),ie.removeListener("close",ae),ie.removeListener("finish",he),ie.removeListener("drain",Pe),ie.removeListener("error",kt),ie.removeListener("unpipe",le),pe.removeListener("end",ge),pe.removeListener("end",je),pe.removeListener("data",ze),lt=!0,Ge.awaitDrain&&(!ie._writableState||ie._writableState.needDrain)&&Pe()}pe.on("data",ze);function ze(Ie){d("ondata");var Ce=ie.write(Ie);d("dest.write",Ce),Ce===!1&&((Ge.pipesCount===1&&Ge.pipes===ie||Ge.pipesCount>1&&be(Ge.pipes,ie)!==-1)&&!lt&&(d("false write response, pause",Ge.awaitDrain),Ge.awaitDrain++),pe.pause())}function kt(Ie){d("onerror",Ie),je(),ie.removeListener("error",kt),I(ie,"error")===0&&Q(ie,Ie)}ee(ie,"error",kt);function ae(){ie.removeListener("finish",he),je()}ie.once("close",ae);function he(){d("onfinish"),ie.removeListener("close",ae),je()}ie.once("finish",he);function je(){d("unpipe"),pe.unpipe(ie)}return ie.emit("pipe",pe),Ge.flowing||(d("pipe resume"),pe.resume()),ie};function Z(ie){return function(){var pe=ie._readableState;d("pipeOnDrain",pe.awaitDrain),pe.awaitDrain&&pe.awaitDrain--,pe.awaitDrain===0&&I(ie,"data")&&(pe.flowing=!0,G(ie))}}e.prototype.unpipe=function(ie){var J=this._readableState,pe={hasUnpiped:!1};if(J.pipesCount===0)return this;if(J.pipesCount===1)return ie&&ie!==J.pipes?this:(ie||(ie=J.pipes),J.pipes=null,J.pipesCount=0,J.flowing=!1,ie&&ie.emit("unpipe",this,pe),this);if(!ie){var Ge=J.pipes,ce=J.pipesCount;J.pipes=null,J.pipesCount=0,J.flowing=!1;for(var te=0;te<ce;te++)Ge[te].emit("unpipe",this,{hasUnpiped:!1});return this}var le=be(J.pipes,ie);return le===-1?this:(J.pipes.splice(le,1),J.pipesCount-=1,J.pipesCount===1&&(J.pipes=J.pipes[0]),ie.emit("unpipe",this,pe),this)},e.prototype.on=function(ie,J){var pe=o.prototype.on.call(this,ie,J),Ge=this._readableState;return ie==="data"?(Ge.readableListening=this.listenerCount("readable")>0,Ge.flowing!==!1&&this.resume()):ie==="readable"&&!Ge.endEmitted&&!Ge.readableListening&&(Ge.readableListening=Ge.needReadable=!0,Ge.flowing=!1,Ge.emittedReadable=!1,d("on readable",Ge.length,Ge.reading),Ge.length?t(this):Ge.reading||S.nextTick(V,this)),pe},e.prototype.addListener=e.prototype.on,e.prototype.removeListener=function(ie,J){var pe=o.prototype.removeListener.call(this,ie,J);return ie==="readable"&&S.nextTick(F,this),pe},e.prototype.removeAllListeners=function(ie){var J=o.prototype.removeAllListeners.apply(this,arguments);return(ie==="readable"||ie===void 0)&&S.nextTick(F,this),J};function F(ie){var J=ie._readableState;J.readableListening=ie.listenerCount("readable")>0,J.resumeScheduled&&!J.paused?J.flowing=!0:ie.listenerCount("data")>0&&ie.resume()}function V(ie){d("readable nexttick read 0"),ie.read(0)}e.prototype.resume=function(){var ie=this._readableState;return ie.flowing||(d("resume"),ie.flowing=!ie.readableListening,q(this,ie)),ie.paused=!1,this};function q(ie,J){J.resumeScheduled||(J.resumeScheduled=!0,S.nextTick(re,ie,J))}function re(ie,J){d("resume",J.reading),J.reading||ie.read(0),J.resumeScheduled=!1,ie.emit("resume"),G(ie),J.flowing&&!J.reading&&ie.read(0)}e.prototype.pause=function(){return d("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(d("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function G(ie){var J=ie._readableState;for(d("flow",J.flowing);J.flowing&&ie.read()!==null;);}e.prototype.wrap=function(ie){var J=this,pe=this._readableState,Ge=!1;ie.on("end",function(){if(d("wrapped end"),pe.decoder&&!pe.ended){var le=pe.decoder.end();le&&le.length&&J.push(le)}J.push(null)}),ie.on("data",function(le){if(d("wrapped data"),pe.decoder&&(le=pe.decoder.write(le)),!(pe.objectMode&&le==null)&&!(!pe.objectMode&&(!le||!le.length))){var ge=J.push(le);ge||(Ge=!0,ie.pause())}});for(var ce in ie)this[ce]===void 0&&typeof ie[ce]=="function"&&(this[ce]=function(ge){return function(){return ie[ge].apply(ie,arguments)}}(ce));for(var te=0;te<Y.length;te++)ie.on(Y[te],this.emit.bind(this,Y[te]));return this._read=function(le){d("wrapped _read",le),Ge&&(Ge=!1,ie.resume())},this},typeof Symbol=="function"&&(e.prototype[Symbol.asyncIterator]=function(){return K===void 0&&(K=T(4743)),K(this)}),Object.defineProperty(e.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(e.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(e.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(J){this._readableState&&(this._readableState.flowing=J)}}),e._fromList=H,Object.defineProperty(e.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function H(ie,J){if(J.length===0)return null;var pe;return J.objectMode?pe=J.buffer.shift():!ie||ie>=J.length?(J.decoder?pe=J.buffer.join(""):J.buffer.length===1?pe=J.buffer.first():pe=J.buffer.concat(J.length),J.buffer.clear()):pe=J.buffer.consume(ie,J.decoder),pe}function oe(ie){var J=ie._readableState;d("endReadable",J.endEmitted),J.endEmitted||(J.ended=!0,S.nextTick(ue,J,ie))}function ue(ie,J){if(d("endReadableNT",ie.endEmitted,ie.length),!ie.endEmitted&&ie.length===0&&(ie.endEmitted=!0,J.readable=!1,J.emit("end"),ie.autoDestroy)){var pe=J._writableState;(!pe||pe.autoDestroy&&pe.finished)&&J.destroy()}}typeof Symbol=="function"&&(e.from=function(ie,J){return $===void 0&&($=T(5049)),$(e,ie,J)});function be(ie,J){for(var pe=0,Ge=ie.length;pe<Ge;pe++)if(ie[pe]===J)return pe;return-1}},3054:(fe,x,T)=>{"use strict";fe.exports=g;var S=T(2260).F,y=S.ERR_METHOD_NOT_IMPLEMENTED,p=S.ERR_MULTIPLE_CALLBACK,I=S.ERR_TRANSFORM_ALREADY_TRANSFORMING,o=S.ERR_TRANSFORM_WITH_LENGTH_0,m=T(2818);T(6698)(g,m);function l(d,A){var v=this._transformState;v.transforming=!1;var b=v.writecb;if(b===null)return this.emit("error",new p);v.writechunk=null,v.writecb=null,A!=null&&this.push(A),b(d);var k=this._readableState;k.reading=!1,(k.needReadable||k.length<k.highWaterMark)&&this._read(k.highWaterMark)}function g(d){if(!(this instanceof g))return new g(d);m.call(this,d),this._transformState={afterTransform:l.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,d&&(typeof d.transform=="function"&&(this._transform=d.transform),typeof d.flush=="function"&&(this._flush=d.flush)),this.on("prefinish",M)}function M(){var d=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(A,v){E(d,A,v)}):E(this,null,null)}g.prototype.push=function(d,A){return this._transformState.needTransform=!1,m.prototype.push.call(this,d,A)},g.prototype._transform=function(d,A,v){v(new y("_transform()"))},g.prototype._write=function(d,A,v){var b=this._transformState;if(b.writecb=v,b.writechunk=d,b.writeencoding=A,!b.transforming){var k=this._readableState;(b.needTransform||k.needReadable||k.length<k.highWaterMark)&&this._read(k.highWaterMark)}},g.prototype._read=function(d){var A=this._transformState;A.writechunk!==null&&!A.transforming?(A.transforming=!0,this._transform(A.writechunk,A.writeencoding,A.afterTransform)):A.needTransform=!0},g.prototype._destroy=function(d,A){m.prototype._destroy.call(this,d,function(v){A(v)})};function E(d,A,v){if(A)return d.emit("error",A);if(v!=null&&d.push(v),d._writableState.length)throw new o;if(d._transformState.transforming)throw new I;return d.push(null)}},2192:(fe,x,T)=>{"use strict";var S=T(5606);fe.exports=u;function y(G,H,oe){this.chunk=G,this.encoding=H,this.callback=oe,this.next=null}function p(G){var H=this;this.next=null,this.entry=null,this.finish=function(){re(H,G)}}var I;u.WritableState=Y;var o={deprecate:T(4643)},m=T(1181),l=T(8287).Buffer,g=T.g.Uint8Array||function(){};function M(G){return l.from(G)}function E(G){return l.isBuffer(G)||G instanceof g}var d=T(1468),A=T(8775),v=A.getHighWaterMark,b=T(2260).F,k=b.ERR_INVALID_ARG_TYPE,B=b.ERR_METHOD_NOT_IMPLEMENTED,U=b.ERR_MULTIPLE_CALLBACK,C=b.ERR_STREAM_CANNOT_PIPE,L=b.ERR_STREAM_DESTROYED,N=b.ERR_STREAM_NULL_VALUES,j=b.ERR_STREAM_WRITE_AFTER_END,K=b.ERR_UNKNOWN_ENCODING,$=d.errorOrDestroy;T(6698)(u,m);function Q(){}function Y(G,H,oe){I=I||T(2818),G=G||{},typeof oe!="boolean"&&(oe=H instanceof I),this.objectMode=!!G.objectMode,oe&&(this.objectMode=this.objectMode||!!G.writableObjectMode),this.highWaterMark=v(this,G,"writableHighWaterMark",oe),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var ue=G.decodeStrings===!1;this.decodeStrings=!ue,this.defaultEncoding=G.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(be){s(H,be)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=G.emitClose!==!1,this.autoDestroy=!!G.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new p(this)}Y.prototype.getBuffer=function(){for(var H=this.bufferedRequest,oe=[];H;)oe.push(H),H=H.next;return oe},function(){try{Object.defineProperty(Y.prototype,"buffer",{get:o.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}();var ee;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(ee=Function.prototype[Symbol.hasInstance],Object.defineProperty(u,Symbol.hasInstance,{value:function(H){return ee.call(this,H)?!0:this!==u?!1:H&&H._writableState instanceof Y}})):ee=function(H){return H instanceof this};function u(G){I=I||T(2818);var H=this instanceof I;if(!H&&!ee.call(u,this))return new u(G);this._writableState=new Y(G,this,H),this.writable=!0,G&&(typeof G.write=="function"&&(this._write=G.write),typeof G.writev=="function"&&(this._writev=G.writev),typeof G.destroy=="function"&&(this._destroy=G.destroy),typeof G.final=="function"&&(this._final=G.final)),m.call(this)}u.prototype.pipe=function(){$(this,new C)};function e(G,H){var oe=new j;$(G,oe),S.nextTick(H,oe)}function r(G,H,oe,ue){var be;return oe===null?be=new N:typeof oe!="string"&&!H.objectMode&&(be=new k("chunk",["string","Buffer"],oe)),be?($(G,be),S.nextTick(ue,be),!1):!0}u.prototype.write=function(G,H,oe){var ue=this._writableState,be=!1,ie=!ue.objectMode&&E(G);return ie&&!l.isBuffer(G)&&(G=M(G)),typeof H=="function"&&(oe=H,H=null),ie?H="buffer":H||(H=ue.defaultEncoding),typeof oe!="function"&&(oe=Q),ue.ending?e(this,oe):(ie||r(this,ue,G,oe))&&(ue.pendingcb++,be=i(this,ue,ie,G,H,oe)),be},u.prototype.cork=function(){this._writableState.corked++},u.prototype.uncork=function(){var G=this._writableState;G.corked&&(G.corked--,!G.writing&&!G.corked&&!G.bufferProcessing&&G.bufferedRequest&&w(this,G))},u.prototype.setDefaultEncoding=function(H){if(typeof H=="string"&&(H=H.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((H+"").toLowerCase())>-1))throw new K(H);return this._writableState.defaultEncoding=H,this},Object.defineProperty(u.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function n(G,H,oe){return!G.objectMode&&G.decodeStrings!==!1&&typeof H=="string"&&(H=l.from(H,oe)),H}Object.defineProperty(u.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function i(G,H,oe,ue,be,ie){if(!oe){var J=n(H,ue,be);ue!==J&&(oe=!0,be="buffer",ue=J)}var pe=H.objectMode?1:ue.length;H.length+=pe;var Ge=H.length<H.highWaterMark;if(Ge||(H.needDrain=!0),H.writing||H.corked){var ce=H.lastBufferedRequest;H.lastBufferedRequest={chunk:ue,encoding:be,isBuf:oe,callback:ie,next:null},ce?ce.next=H.lastBufferedRequest:H.bufferedRequest=H.lastBufferedRequest,H.bufferedRequestCount+=1}else f(G,H,!1,pe,ue,be,ie);return Ge}function f(G,H,oe,ue,be,ie,J){H.writelen=ue,H.writecb=J,H.writing=!0,H.sync=!0,H.destroyed?H.onwrite(new L("write")):oe?G._writev(be,H.onwrite):G._write(be,ie,H.onwrite),H.sync=!1}function c(G,H,oe,ue,be){--H.pendingcb,oe?(S.nextTick(be,ue),S.nextTick(V,G,H),G._writableState.errorEmitted=!0,$(G,ue)):(be(ue),G._writableState.errorEmitted=!0,$(G,ue),V(G,H))}function h(G){G.writing=!1,G.writecb=null,G.length-=G.writelen,G.writelen=0}function s(G,H){var oe=G._writableState,ue=oe.sync,be=oe.writecb;if(typeof be!="function")throw new U;if(h(oe),H)c(G,oe,ue,H,be);else{var ie=D(oe)||G.destroyed;!ie&&!oe.corked&&!oe.bufferProcessing&&oe.bufferedRequest&&w(G,oe),ue?S.nextTick(t,G,oe,ie,be):t(G,oe,ie,be)}}function t(G,H,oe,ue){oe||a(G,H),H.pendingcb--,ue(),V(G,H)}function a(G,H){H.length===0&&H.needDrain&&(H.needDrain=!1,G.emit("drain"))}function w(G,H){H.bufferProcessing=!0;var oe=H.bufferedRequest;if(G._writev&&oe&&oe.next){var ue=H.bufferedRequestCount,be=new Array(ue),ie=H.corkedRequestsFree;ie.entry=oe;for(var J=0,pe=!0;oe;)be[J]=oe,oe.isBuf||(pe=!1),oe=oe.next,J+=1;be.allBuffers=pe,f(G,H,!0,H.length,be,"",ie.finish),H.pendingcb++,H.lastBufferedRequest=null,ie.next?(H.corkedRequestsFree=ie.next,ie.next=null):H.corkedRequestsFree=new p(H),H.bufferedRequestCount=0}else{for(;oe;){var Ge=oe.chunk,ce=oe.encoding,te=oe.callback,le=H.objectMode?1:Ge.length;if(f(G,H,!1,le,Ge,ce,te),oe=oe.next,H.bufferedRequestCount--,H.writing)break}oe===null&&(H.lastBufferedRequest=null)}H.bufferedRequest=oe,H.bufferProcessing=!1}u.prototype._write=function(G,H,oe){oe(new B("_write()"))},u.prototype._writev=null,u.prototype.end=function(G,H,oe){var ue=this._writableState;return typeof G=="function"?(oe=G,G=null,H=null):typeof H=="function"&&(oe=H,H=null),G!=null&&this.write(G,H),ue.corked&&(ue.corked=1,this.uncork()),ue.ending||q(this,ue,oe),this},Object.defineProperty(u.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function D(G){return G.ending&&G.length===0&&G.bufferedRequest===null&&!G.finished&&!G.writing}function Z(G,H){G._final(function(oe){H.pendingcb--,oe&&$(G,oe),H.prefinished=!0,G.emit("prefinish"),V(G,H)})}function F(G,H){!H.prefinished&&!H.finalCalled&&(typeof G._final=="function"&&!H.destroyed?(H.pendingcb++,H.finalCalled=!0,S.nextTick(Z,G,H)):(H.prefinished=!0,G.emit("prefinish")))}function V(G,H){var oe=D(H);if(oe&&(F(G,H),H.pendingcb===0&&(H.finished=!0,G.emit("finish"),H.autoDestroy))){var ue=G._readableState;(!ue||ue.autoDestroy&&ue.endEmitted)&&G.destroy()}return oe}function q(G,H,oe){H.ending=!0,V(G,H),oe&&(H.finished?S.nextTick(oe):G.once("finish",oe)),H.ended=!0,G.writable=!1}function re(G,H,oe){var ue=G.entry;for(G.entry=null;ue;){var be=ue.callback;H.pendingcb--,be(oe),ue=ue.next}H.corkedRequestsFree.next=G}Object.defineProperty(u.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(H){this._writableState&&(this._writableState.destroyed=H)}}),u.prototype.destroy=d.destroy,u.prototype._undestroy=d.undestroy,u.prototype._destroy=function(G,H){H(G)}},4743:(fe,x,T)=>{"use strict";var S=T(5606),y;function p(L,N,j){return N in L?Object.defineProperty(L,N,{value:j,enumerable:!0,configurable:!0,writable:!0}):L[N]=j,L}var I=T(5826),o=Symbol("lastResolve"),m=Symbol("lastReject"),l=Symbol("error"),g=Symbol("ended"),M=Symbol("lastPromise"),E=Symbol("handlePromise"),d=Symbol("stream");function A(L,N){return{value:L,done:N}}function v(L){var N=L[o];if(N!==null){var j=L[d].read();j!==null&&(L[M]=null,L[o]=null,L[m]=null,N(A(j,!1)))}}function b(L){S.nextTick(v,L)}function k(L,N){return function(j,K){L.then(function(){if(N[g]){j(A(void 0,!0));return}N[E](j,K)},K)}}var B=Object.getPrototypeOf(function(){}),U=Object.setPrototypeOf((y={get stream(){return this[d]},next:function(){var N=this,j=this[l];if(j!==null)return Promise.reject(j);if(this[g])return Promise.resolve(A(void 0,!0));if(this[d].destroyed)return new Promise(function(Y,ee){S.nextTick(function(){N[l]?ee(N[l]):Y(A(void 0,!0))})});var K=this[M],$;if(K)$=new Promise(k(K,this));else{var Q=this[d].read();if(Q!==null)return Promise.resolve(A(Q,!1));$=new Promise(this[E])}return this[M]=$,$}},p(y,Symbol.asyncIterator,function(){return this}),p(y,"return",function(){var N=this;return new Promise(function(j,K){N[d].destroy(null,function($){if($){K($);return}j(A(void 0,!0))})})}),y),B),C=function(N){var j,K=Object.create(U,(j={},p(j,d,{value:N,writable:!0}),p(j,o,{value:null,writable:!0}),p(j,m,{value:null,writable:!0}),p(j,l,{value:null,writable:!0}),p(j,g,{value:N._readableState.endEmitted,writable:!0}),p(j,E,{value:function(Q,Y){var ee=K[d].read();ee?(K[M]=null,K[o]=null,K[m]=null,Q(A(ee,!1))):(K[o]=Q,K[m]=Y)},writable:!0}),j));return K[M]=null,I(N,function($){if($&&$.code!=="ERR_STREAM_PREMATURE_CLOSE"){var Q=K[m];Q!==null&&(K[M]=null,K[o]=null,K[m]=null,Q($)),K[l]=$;return}var Y=K[o];Y!==null&&(K[M]=null,K[o]=null,K[m]=null,Y(A(void 0,!0))),K[g]=!0}),N.on("readable",b.bind(null,K)),K};fe.exports=C},2389:(fe,x,T)=>{"use strict";function S(v,b){var k=Object.keys(v);if(Object.getOwnPropertySymbols){var B=Object.getOwnPropertySymbols(v);b&&(B=B.filter(function(U){return Object.getOwnPropertyDescriptor(v,U).enumerable})),k.push.apply(k,B)}return k}function y(v){for(var b=1;b<arguments.length;b++){var k=arguments[b]!=null?arguments[b]:{};b%2?S(Object(k),!0).forEach(function(B){p(v,B,k[B])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(k)):S(Object(k)).forEach(function(B){Object.defineProperty(v,B,Object.getOwnPropertyDescriptor(k,B))})}return v}function p(v,b,k){return b in v?Object.defineProperty(v,b,{value:k,enumerable:!0,configurable:!0,writable:!0}):v[b]=k,v}function I(v,b){if(!(v instanceof b))throw new TypeError("Cannot call a class as a function")}function o(v,b){for(var k=0;k<b.length;k++){var B=b[k];B.enumerable=B.enumerable||!1,B.configurable=!0,"value"in B&&(B.writable=!0),Object.defineProperty(v,B.key,B)}}function m(v,b,k){return b&&o(v.prototype,b),k&&o(v,k),v}var l=T(8287),g=l.Buffer,M=T(8460),E=M.inspect,d=E&&E.custom||"inspect";function A(v,b,k){g.prototype.copy.call(v,b,k)}fe.exports=function(){function v(){I(this,v),this.head=null,this.tail=null,this.length=0}return m(v,[{key:"push",value:function(k){var B={data:k,next:null};this.length>0?this.tail.next=B:this.head=B,this.tail=B,++this.length}},{key:"unshift",value:function(k){var B={data:k,next:this.head};this.length===0&&(this.tail=B),this.head=B,++this.length}},{key:"shift",value:function(){if(this.length!==0){var k=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,k}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(k){if(this.length===0)return"";for(var B=this.head,U=""+B.data;B=B.next;)U+=k+B.data;return U}},{key:"concat",value:function(k){if(this.length===0)return g.alloc(0);for(var B=g.allocUnsafe(k>>>0),U=this.head,C=0;U;)A(U.data,B,C),C+=U.data.length,U=U.next;return B}},{key:"consume",value:function(k,B){var U;return k<this.head.data.length?(U=this.head.data.slice(0,k),this.head.data=this.head.data.slice(k)):k===this.head.data.length?U=this.shift():U=B?this._getString(k):this._getBuffer(k),U}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(k){var B=this.head,U=1,C=B.data;for(k-=C.length;B=B.next;){var L=B.data,N=k>L.length?L.length:k;if(N===L.length?C+=L:C+=L.slice(0,k),k-=N,k===0){N===L.length?(++U,B.next?this.head=B.next:this.head=this.tail=null):(this.head=B,B.data=L.slice(N));break}++U}return this.length-=U,C}},{key:"_getBuffer",value:function(k){var B=g.allocUnsafe(k),U=this.head,C=1;for(U.data.copy(B),k-=U.data.length;U=U.next;){var L=U.data,N=k>L.length?L.length:k;if(L.copy(B,B.length-k,0,N),k-=N,k===0){N===L.length?(++C,U.next?this.head=U.next:this.head=this.tail=null):(this.head=U,U.data=L.slice(N));break}++C}return this.length-=C,B}},{key:d,value:function(k,B){return E(this,y({},B,{depth:0,customInspect:!1}))}}]),v}()},1468:(fe,x,T)=>{"use strict";var S=T(5606);function y(g,M){var E=this,d=this._readableState&&this._readableState.destroyed,A=this._writableState&&this._writableState.destroyed;return d||A?(M?M(g):g&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,S.nextTick(m,this,g)):S.nextTick(m,this,g)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(g||null,function(v){!M&&v?E._writableState?E._writableState.errorEmitted?S.nextTick(I,E):(E._writableState.errorEmitted=!0,S.nextTick(p,E,v)):S.nextTick(p,E,v):M?(S.nextTick(I,E),M(v)):S.nextTick(I,E)}),this)}function p(g,M){m(g,M),I(g)}function I(g){g._writableState&&!g._writableState.emitClose||g._readableState&&!g._readableState.emitClose||g.emit("close")}function o(){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.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function m(g,M){g.emit("error",M)}function l(g,M){var E=g._readableState,d=g._writableState;E&&E.autoDestroy||d&&d.autoDestroy?g.destroy(M):g.emit("error",M)}fe.exports={destroy:y,undestroy:o,errorOrDestroy:l}},5826:(fe,x,T)=>{"use strict";var S=T(2260).F.ERR_STREAM_PREMATURE_CLOSE;function y(m){var l=!1;return function(){if(!l){l=!0;for(var g=arguments.length,M=new Array(g),E=0;E<g;E++)M[E]=arguments[E];m.apply(this,M)}}}function p(){}function I(m){return m.setHeader&&typeof m.abort=="function"}function o(m,l,g){if(typeof l=="function")return o(m,null,l);l||(l={}),g=y(g||p);var M=l.readable||l.readable!==!1&&m.readable,E=l.writable||l.writable!==!1&&m.writable,d=function(){m.writable||v()},A=m._writableState&&m._writableState.finished,v=function(){E=!1,A=!0,M||g.call(m)},b=m._readableState&&m._readableState.endEmitted,k=function(){M=!1,b=!0,E||g.call(m)},B=function(N){g.call(m,N)},U=function(){var N;if(M&&!b)return(!m._readableState||!m._readableState.ended)&&(N=new S),g.call(m,N);if(E&&!A)return(!m._writableState||!m._writableState.ended)&&(N=new S),g.call(m,N)},C=function(){m.req.on("finish",v)};return I(m)?(m.on("complete",v),m.on("abort",U),m.req?C():m.on("request",C)):E&&!m._writableState&&(m.on("end",d),m.on("close",d)),m.on("end",k),m.on("finish",v),l.error!==!1&&m.on("error",B),m.on("close",U),function(){m.removeListener("complete",v),m.removeListener("abort",U),m.removeListener("request",C),m.req&&m.req.removeListener("finish",v),m.removeListener("end",d),m.removeListener("close",d),m.removeListener("finish",v),m.removeListener("end",k),m.removeListener("error",B),m.removeListener("close",U)}}fe.exports=o},5049:fe=>{fe.exports=function(){throw new Error("Readable.from is not available in the browser")}},9434:(fe,x,T)=>{"use strict";var S;function y(v){var b=!1;return function(){b||(b=!0,v.apply(void 0,arguments))}}var p=T(2260).F,I=p.ERR_MISSING_ARGS,o=p.ERR_STREAM_DESTROYED;function m(v){if(v)throw v}function l(v){return v.setHeader&&typeof v.abort=="function"}function g(v,b,k,B){B=y(B);var U=!1;v.on("close",function(){U=!0}),S===void 0&&(S=T(5826)),S(v,{readable:b,writable:k},function(L){if(L)return B(L);U=!0,B()});var C=!1;return function(L){if(!U&&!C){if(C=!0,l(v))return v.abort();if(typeof v.destroy=="function")return v.destroy();B(L||new o("pipe"))}}}function M(v){v()}function E(v,b){return v.pipe(b)}function d(v){return!v.length||typeof v[v.length-1]!="function"?m:v.pop()}function A(){for(var v=arguments.length,b=new Array(v),k=0;k<v;k++)b[k]=arguments[k];var B=d(b);if(Array.isArray(b[0])&&(b=b[0]),b.length<2)throw new I("streams");var U,C=b.map(function(L,N){var j=N<b.length-1,K=N>0;return g(L,j,K,function($){U||(U=$),$&&C.forEach(M),!j&&(C.forEach(M),B(U))})});return b.reduce(E)}fe.exports=A},8775:(fe,x,T)=>{"use strict";var S=T(2260).F.ERR_INVALID_OPT_VALUE;function y(I,o,m){return I.highWaterMark!=null?I.highWaterMark:o?I[m]:null}function p(I,o,m,l){var g=y(o,l,m);if(g!=null){if(!(isFinite(g)&&Math.floor(g)===g)||g<0){var M=l?m:"highWaterMark";throw new S(M,g)}return Math.floor(g)}return I.objectMode?16:16384}fe.exports={getHighWaterMark:p}},1181:(fe,x,T)=>{fe.exports=T(7007).EventEmitter},1603:(fe,x,T)=>{x=fe.exports=T(6736),x.Stream=x,x.Readable=x,x.Writable=T(2192),x.Duplex=T(2818),x.Transform=T(3054),x.PassThrough=T(5860),x.finished=T(5826),x.pipeline=T(9434)},7952:(fe,x,T)=>{var S=x;S.utils=T(7426),S.common=T(6166),S.sha=T(6229),S.ripemd=T(6784),S.hmac=T(8948),S.sha1=S.sha.sha1,S.sha256=S.sha.sha256,S.sha224=S.sha.sha224,S.sha384=S.sha.sha384,S.sha512=S.sha.sha512,S.ripemd160=S.ripemd.ripemd160},6166:(fe,x,T)=>{"use strict";var S=T(7426),y=T(3349);function p(){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}x.BlockHash=p,p.prototype.update=function(o,m){if(o=S.toArray(o,m),this.pending?this.pending=this.pending.concat(o):this.pending=o,this.pendingTotal+=o.length,this.pending.length>=this._delta8){o=this.pending;var l=o.length%this._delta8;this.pending=o.slice(o.length-l,o.length),this.pending.length===0&&(this.pending=null),o=S.join32(o,0,o.length-l,this.endian);for(var g=0;g<o.length;g+=this._delta32)this._update(o,g,g+this._delta32)}return this},p.prototype.digest=function(o){return this.update(this._pad()),y(this.pending===null),this._digest(o)},p.prototype._pad=function(){var o=this.pendingTotal,m=this._delta8,l=m-(o+this.padLength)%m,g=new Array(l+this.padLength);g[0]=128;for(var M=1;M<l;M++)g[M]=0;if(o<<=3,this.endian==="big"){for(var E=8;E<this.padLength;E++)g[M++]=0;g[M++]=0,g[M++]=0,g[M++]=0,g[M++]=0,g[M++]=o>>>24&255,g[M++]=o>>>16&255,g[M++]=o>>>8&255,g[M++]=o&255}else for(g[M++]=o&255,g[M++]=o>>>8&255,g[M++]=o>>>16&255,g[M++]=o>>>24&255,g[M++]=0,g[M++]=0,g[M++]=0,g[M++]=0,E=8;E<this.padLength;E++)g[M++]=0;return g}},8948:(fe,x,T)=>{"use strict";var S=T(7426),y=T(3349);function p(I,o,m){if(!(this instanceof p))return new p(I,o,m);this.Hash=I,this.blockSize=I.blockSize/8,this.outSize=I.outSize/8,this.inner=null,this.outer=null,this._init(S.toArray(o,m))}fe.exports=p,p.prototype._init=function(o){o.length>this.blockSize&&(o=new this.Hash().update(o).digest()),y(o.length<=this.blockSize);for(var m=o.length;m<this.blockSize;m++)o.push(0);for(m=0;m<o.length;m++)o[m]^=54;for(this.inner=new this.Hash().update(o),m=0;m<o.length;m++)o[m]^=106;this.outer=new this.Hash().update(o)},p.prototype.update=function(o,m){return this.inner.update(o,m),this},p.prototype.digest=function(o){return this.outer.update(this.inner.digest()),this.outer.digest(o)}},6784:(fe,x,T)=>{"use strict";var S=T(7426),y=T(6166),p=S.rotl32,I=S.sum32,o=S.sum32_3,m=S.sum32_4,l=y.BlockHash;function g(){if(!(this instanceof g))return new g;l.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}S.inherits(g,l),x.ripemd160=g,g.blockSize=512,g.outSize=160,g.hmacStrength=192,g.padLength=64,g.prototype._update=function(U,C){for(var L=this.h[0],N=this.h[1],j=this.h[2],K=this.h[3],$=this.h[4],Q=L,Y=N,ee=j,u=K,e=$,r=0;r<80;r++){var n=I(p(m(L,M(r,N,j,K),U[A[r]+C],E(r)),b[r]),$);L=$,$=K,K=p(j,10),j=N,N=n,n=I(p(m(Q,M(79-r,Y,ee,u),U[v[r]+C],d(r)),k[r]),e),Q=e,e=u,u=p(ee,10),ee=Y,Y=n}n=o(this.h[1],j,u),this.h[1]=o(this.h[2],K,e),this.h[2]=o(this.h[3],$,Q),this.h[3]=o(this.h[4],L,Y),this.h[4]=o(this.h[0],N,ee),this.h[0]=n},g.prototype._digest=function(U){return U==="hex"?S.toHex32(this.h,"little"):S.split32(this.h,"little")};function M(B,U,C,L){return B<=15?U^C^L:B<=31?U&C|~U&L:B<=47?(U|~C)^L:B<=63?U&L|C&~L:U^(C|~L)}function E(B){return B<=15?0:B<=31?1518500249:B<=47?1859775393:B<=63?2400959708:2840853838}function d(B){return B<=15?1352829926:B<=31?1548603684:B<=47?1836072691:B<=63?2053994217:0}var 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],v=[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],b=[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],k=[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]},6229:(fe,x,T)=>{"use strict";x.sha1=T(3917),x.sha224=T(7714),x.sha256=T(2287),x.sha384=T(1911),x.sha512=T(7766)},3917:(fe,x,T)=>{"use strict";var S=T(7426),y=T(6166),p=T(6225),I=S.rotl32,o=S.sum32,m=S.sum32_5,l=p.ft_1,g=y.BlockHash,M=[1518500249,1859775393,2400959708,3395469782];function E(){if(!(this instanceof E))return new E;g.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}S.inherits(E,g),fe.exports=E,E.blockSize=512,E.outSize=160,E.hmacStrength=80,E.padLength=64,E.prototype._update=function(A,v){for(var b=this.W,k=0;k<16;k++)b[k]=A[v+k];for(;k<b.length;k++)b[k]=I(b[k-3]^b[k-8]^b[k-14]^b[k-16],1);var B=this.h[0],U=this.h[1],C=this.h[2],L=this.h[3],N=this.h[4];for(k=0;k<b.length;k++){var j=~~(k/20),K=m(I(B,5),l(j,U,C,L),N,b[k],M[j]);N=L,L=C,C=I(U,30),U=B,B=K}this.h[0]=o(this.h[0],B),this.h[1]=o(this.h[1],U),this.h[2]=o(this.h[2],C),this.h[3]=o(this.h[3],L),this.h[4]=o(this.h[4],N)},E.prototype._digest=function(A){return A==="hex"?S.toHex32(this.h,"big"):S.split32(this.h,"big")}},7714:(fe,x,T)=>{"use strict";var S=T(7426),y=T(2287);function p(){if(!(this instanceof p))return new p;y.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}S.inherits(p,y),fe.exports=p,p.blockSize=512,p.outSize=224,p.hmacStrength=192,p.padLength=64,p.prototype._digest=function(o){return o==="hex"?S.toHex32(this.h.slice(0,7),"big"):S.split32(this.h.slice(0,7),"big")}},2287:(fe,x,T)=>{"use strict";var S=T(7426),y=T(6166),p=T(6225),I=T(3349),o=S.sum32,m=S.sum32_4,l=S.sum32_5,g=p.ch32,M=p.maj32,E=p.s0_256,d=p.s1_256,A=p.g0_256,v=p.g1_256,b=y.BlockHash,k=[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;b.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=k,this.W=new Array(64)}S.inherits(B,b),fe.exports=B,B.blockSize=512,B.outSize=256,B.hmacStrength=192,B.padLength=64,B.prototype._update=function(C,L){for(var N=this.W,j=0;j<16;j++)N[j]=C[L+j];for(;j<N.length;j++)N[j]=m(v(N[j-2]),N[j-7],A(N[j-15]),N[j-16]);var K=this.h[0],$=this.h[1],Q=this.h[2],Y=this.h[3],ee=this.h[4],u=this.h[5],e=this.h[6],r=this.h[7];for(I(this.k.length===N.length),j=0;j<N.length;j++){var n=l(r,d(ee),g(ee,u,e),this.k[j],N[j]),i=o(E(K),M(K,$,Q));r=e,e=u,u=ee,ee=o(Y,n),Y=Q,Q=$,$=K,K=o(n,i)}this.h[0]=o(this.h[0],K),this.h[1]=o(this.h[1],$),this.h[2]=o(this.h[2],Q),this.h[3]=o(this.h[3],Y),this.h[4]=o(this.h[4],ee),this.h[5]=o(this.h[5],u),this.h[6]=o(this.h[6],e),this.h[7]=o(this.h[7],r)},B.prototype._digest=function(C){return C==="hex"?S.toHex32(this.h,"big"):S.split32(this.h,"big")}},1911:(fe,x,T)=>{"use strict";var S=T(7426),y=T(7766);function p(){if(!(this instanceof p))return new p;y.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}S.inherits(p,y),fe.exports=p,p.blockSize=1024,p.outSize=384,p.hmacStrength=192,p.padLength=128,p.prototype._digest=function(o){return o==="hex"?S.toHex32(this.h.slice(0,12),"big"):S.split32(this.h.slice(0,12),"big")}},7766:(fe,x,T)=>{"use strict";var S=T(7426),y=T(6166),p=T(3349),I=S.rotr64_hi,o=S.rotr64_lo,m=S.shr64_hi,l=S.shr64_lo,g=S.sum64,M=S.sum64_hi,E=S.sum64_lo,d=S.sum64_4_hi,A=S.sum64_4_lo,v=S.sum64_5_hi,b=S.sum64_5_lo,k=y.BlockHash,B=[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];function U(){if(!(this instanceof U))return new U;k.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=B,this.W=new Array(160)}S.inherits(U,k),fe.exports=U,U.blockSize=1024,U.outSize=512,U.hmacStrength=192,U.padLength=128,U.prototype._prepareBlock=function(i,f){for(var c=this.W,h=0;h<32;h++)c[h]=i[f+h];for(;h<c.length;h+=2){var s=e(c[h-4],c[h-3]),t=r(c[h-4],c[h-3]),a=c[h-14],w=c[h-13],D=ee(c[h-30],c[h-29]),Z=u(c[h-30],c[h-29]),F=c[h-32],V=c[h-31];c[h]=d(s,t,a,w,D,Z,F,V),c[h+1]=A(s,t,a,w,D,Z,F,V)}},U.prototype._update=function(i,f){this._prepareBlock(i,f);var c=this.W,h=this.h[0],s=this.h[1],t=this.h[2],a=this.h[3],w=this.h[4],D=this.h[5],Z=this.h[6],F=this.h[7],V=this.h[8],q=this.h[9],re=this.h[10],G=this.h[11],H=this.h[12],oe=this.h[13],ue=this.h[14],be=this.h[15];p(this.k.length===c.length);for(var ie=0;ie<c.length;ie+=2){var J=ue,pe=be,Ge=Q(V,q),ce=Y(V,q),te=C(V,q,re,G,H,oe),le=L(V,q,re,G,H,oe),ge=this.k[ie],Pe=this.k[ie+1],lt=c[ie],Le=c[ie+1],ze=v(J,pe,Ge,ce,te,le,ge,Pe,lt,Le),kt=b(J,pe,Ge,ce,te,le,ge,Pe,lt,Le);J=K(h,s),pe=$(h,s),Ge=N(h,s,t,a,w,D),ce=j(h,s,t,a,w,D);var ae=M(J,pe,Ge,ce),he=E(J,pe,Ge,ce);ue=H,be=oe,H=re,oe=G,re=V,G=q,V=M(Z,F,ze,kt),q=E(F,F,ze,kt),Z=w,F=D,w=t,D=a,t=h,a=s,h=M(ze,kt,ae,he),s=E(ze,kt,ae,he)}g(this.h,0,h,s),g(this.h,2,t,a),g(this.h,4,w,D),g(this.h,6,Z,F),g(this.h,8,V,q),g(this.h,10,re,G),g(this.h,12,H,oe),g(this.h,14,ue,be)},U.prototype._digest=function(i){return i==="hex"?S.toHex32(this.h,"big"):S.split32(this.h,"big")};function C(n,i,f,c,h){var s=n&f^~n&h;return s<0&&(s+=4294967296),s}function L(n,i,f,c,h,s){var t=i&c^~i&s;return t<0&&(t+=4294967296),t}function N(n,i,f,c,h){var s=n&f^n&h^f&h;return s<0&&(s+=4294967296),s}function j(n,i,f,c,h,s){var t=i&c^i&s^c&s;return t<0&&(t+=4294967296),t}function K(n,i){var f=I(n,i,28),c=I(i,n,2),h=I(i,n,7),s=f^c^h;return s<0&&(s+=4294967296),s}function $(n,i){var f=o(n,i,28),c=o(i,n,2),h=o(i,n,7),s=f^c^h;return s<0&&(s+=4294967296),s}function Q(n,i){var f=I(n,i,14),c=I(n,i,18),h=I(i,n,9),s=f^c^h;return s<0&&(s+=4294967296),s}function Y(n,i){var f=o(n,i,14),c=o(n,i,18),h=o(i,n,9),s=f^c^h;return s<0&&(s+=4294967296),s}function ee(n,i){var f=I(n,i,1),c=I(n,i,8),h=m(n,i,7),s=f^c^h;return s<0&&(s+=4294967296),s}function u(n,i){var f=o(n,i,1),c=o(n,i,8),h=l(n,i,7),s=f^c^h;return s<0&&(s+=4294967296),s}function e(n,i){var f=I(n,i,19),c=I(i,n,29),h=m(n,i,6),s=f^c^h;return s<0&&(s+=4294967296),s}function r(n,i){var f=o(n,i,19),c=o(i,n,29),h=l(n,i,6),s=f^c^h;return s<0&&(s+=4294967296),s}},6225:(fe,x,T)=>{"use strict";var S=T(7426),y=S.rotr32;function p(d,A,v,b){if(d===0)return I(A,v,b);if(d===1||d===3)return m(A,v,b);if(d===2)return o(A,v,b)}x.ft_1=p;function I(d,A,v){return d&A^~d&v}x.ch32=I;function o(d,A,v){return d&A^d&v^A&v}x.maj32=o;function m(d,A,v){return d^A^v}x.p32=m;function l(d){return y(d,2)^y(d,13)^y(d,22)}x.s0_256=l;function g(d){return y(d,6)^y(d,11)^y(d,25)}x.s1_256=g;function M(d){return y(d,7)^y(d,18)^d>>>3}x.g0_256=M;function E(d){return y(d,17)^y(d,19)^d>>>10}x.g1_256=E},7426:(fe,x,T)=>{"use strict";var S=T(3349),y=T(6698);x.inherits=y;function p(r,n){return(r.charCodeAt(n)&64512)!==55296||n<0||n+1>=r.length?!1:(r.charCodeAt(n+1)&64512)===56320}function I(r,n){if(Array.isArray(r))return r.slice();if(!r)return[];var i=[];if(typeof r=="string")if(n){if(n==="hex")for(r=r.replace(/[^a-z0-9]+/ig,""),r.length%2!==0&&(r="0"+r),c=0;c<r.length;c+=2)i.push(parseInt(r[c]+r[c+1],16))}else for(var f=0,c=0;c<r.length;c++){var h=r.charCodeAt(c);h<128?i[f++]=h:h<2048?(i[f++]=h>>6|192,i[f++]=h&63|128):p(r,c)?(h=65536+((h&1023)<<10)+(r.charCodeAt(++c)&1023),i[f++]=h>>18|240,i[f++]=h>>12&63|128,i[f++]=h>>6&63|128,i[f++]=h&63|128):(i[f++]=h>>12|224,i[f++]=h>>6&63|128,i[f++]=h&63|128)}else for(c=0;c<r.length;c++)i[c]=r[c]|0;return i}x.toArray=I;function o(r){for(var n="",i=0;i<r.length;i++)n+=g(r[i].toString(16));return n}x.toHex=o;function m(r){var n=r>>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24;return n>>>0}x.htonl=m;function l(r,n){for(var i="",f=0;f<r.length;f++){var c=r[f];n==="little"&&(c=m(c)),i+=M(c.toString(16))}return i}x.toHex32=l;function g(r){return r.length===1?"0"+r:r}x.zero2=g;function M(r){return r.length===7?"0"+r:r.length===6?"00"+r:r.length===5?"000"+r:r.length===4?"0000"+r:r.length===3?"00000"+r:r.length===2?"000000"+r:r.length===1?"0000000"+r:r}x.zero8=M;function E(r,n,i,f){var c=i-n;S(c%4===0);for(var h=new Array(c/4),s=0,t=n;s<h.length;s++,t+=4){var a;f==="big"?a=r[t]<<24|r[t+1]<<16|r[t+2]<<8|r[t+3]:a=r[t+3]<<24|r[t+2]<<16|r[t+1]<<8|r[t],h[s]=a>>>0}return h}x.join32=E;function d(r,n){for(var i=new Array(r.length*4),f=0,c=0;f<r.length;f++,c+=4){var h=r[f];n==="big"?(i[c]=h>>>24,i[c+1]=h>>>16&255,i[c+2]=h>>>8&255,i[c+3]=h&255):(i[c+3]=h>>>24,i[c+2]=h>>>16&255,i[c+1]=h>>>8&255,i[c]=h&255)}return i}x.split32=d;function A(r,n){return r>>>n|r<<32-n}x.rotr32=A;function v(r,n){return r<<n|r>>>32-n}x.rotl32=v;function b(r,n){return r+n>>>0}x.sum32=b;function k(r,n,i){return r+n+i>>>0}x.sum32_3=k;function B(r,n,i,f){return r+n+i+f>>>0}x.sum32_4=B;function U(r,n,i,f,c){return r+n+i+f+c>>>0}x.sum32_5=U;function C(r,n,i,f){var c=r[n],h=r[n+1],s=f+h>>>0,t=(s<f?1:0)+i+c;r[n]=t>>>0,r[n+1]=s}x.sum64=C;function L(r,n,i,f){var c=n+f>>>0,h=(c<n?1:0)+r+i;return h>>>0}x.sum64_hi=L;function N(r,n,i,f){var c=n+f;return c>>>0}x.sum64_lo=N;function j(r,n,i,f,c,h,s,t){var a=0,w=n;w=w+f>>>0,a+=w<n?1:0,w=w+h>>>0,a+=w<h?1:0,w=w+t>>>0,a+=w<t?1:0;var D=r+i+c+s+a;return D>>>0}x.sum64_4_hi=j;function K(r,n,i,f,c,h,s,t){var a=n+f+h+t;return a>>>0}x.sum64_4_lo=K;function $(r,n,i,f,c,h,s,t,a,w){var D=0,Z=n;Z=Z+f>>>0,D+=Z<n?1:0,Z=Z+h>>>0,D+=Z<h?1:0,Z=Z+t>>>0,D+=Z<t?1:0,Z=Z+w>>>0,D+=Z<w?1:0;var F=r+i+c+s+a+D;return F>>>0}x.sum64_5_hi=$;function Q(r,n,i,f,c,h,s,t,a,w){var D=n+f+h+t+w;return D>>>0}x.sum64_5_lo=Q;function Y(r,n,i){var f=n<<32-i|r>>>i;return f>>>0}x.rotr64_hi=Y;function ee(r,n,i){var f=r<<32-i|n>>>i;return f>>>0}x.rotr64_lo=ee;function u(r,n,i){return r>>>i}x.shr64_hi=u;function e(r,n,i){var f=r<<32-i|n>>>i;return f>>>0}x.shr64_lo=e},2723:(fe,x,T)=>{"use strict";var S=T(7952),y=T(4367),p=T(3349);function I(o){if(!(this instanceof I))return new I(o);this.hash=o.hash,this.predResist=!!o.predResist,this.outLen=this.hash.outSize,this.minEntropy=o.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var m=y.toArray(o.entropy,o.entropyEnc||"hex"),l=y.toArray(o.nonce,o.nonceEnc||"hex"),g=y.toArray(o.pers,o.persEnc||"hex");p(m.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(m,l,g)}fe.exports=I,I.prototype._init=function(m,l,g){var M=m.concat(l).concat(g);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var E=0;E<this.V.length;E++)this.K[E]=0,this.V[E]=1;this._update(M),this._reseed=1,this.reseedInterval=281474976710656},I.prototype._hmac=function(){return new S.hmac(this.hash,this.K)},I.prototype._update=function(m){var l=this._hmac().update(this.V).update([0]);m&&(l=l.update(m)),this.K=l.digest(),this.V=this._hmac().update(this.V).digest(),m&&(this.K=this._hmac().update(this.V).update([1]).update(m).digest(),this.V=this._hmac().update(this.V).digest())},I.prototype.reseed=function(m,l,g,M){typeof l!="string"&&(M=g,g=l,l=null),m=y.toArray(m,l),g=y.toArray(g,M),p(m.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(m.concat(g||[])),this._reseed=1},I.prototype.generate=function(m,l,g,M){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof l!="string"&&(M=g,g=l,l=null),g&&(g=y.toArray(g,M||"hex"),this._update(g));for(var E=[];E.length<m;)this.V=this._hmac().update(this.V).digest(),E=E.concat(this.V);var d=E.slice(0,m);return this._update(g),this._reseed++,y.encode(d,l)}},251:(fe,x)=>{/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */x.read=function(T,S,y,p,I){var o,m,l=I*8-p-1,g=(1<<l)-1,M=g>>1,E=-7,d=y?I-1:0,A=y?-1:1,v=T[S+d];for(d+=A,o=v&(1<<-E)-1,v>>=-E,E+=l;E>0;o=o*256+T[S+d],d+=A,E-=8);for(m=o&(1<<-E)-1,o>>=-E,E+=p;E>0;m=m*256+T[S+d],d+=A,E-=8);if(o===0)o=1-M;else{if(o===g)return m?NaN:(v?-1:1)*(1/0);m=m+Math.pow(2,p),o=o-M}return(v?-1:1)*m*Math.pow(2,o-p)},x.write=function(T,S,y,p,I,o){var m,l,g,M=o*8-I-1,E=(1<<M)-1,d=E>>1,A=I===23?Math.pow(2,-24)-Math.pow(2,-77):0,v=p?0:o-1,b=p?1:-1,k=S<0||S===0&&1/S<0?1:0;for(S=Math.abs(S),isNaN(S)||S===1/0?(l=isNaN(S)?1:0,m=E):(m=Math.floor(Math.log(S)/Math.LN2),S*(g=Math.pow(2,-m))<1&&(m--,g*=2),m+d>=1?S+=A/g:S+=A*Math.pow(2,1-d),S*g>=2&&(m++,g/=2),m+d>=E?(l=0,m=E):m+d>=1?(l=(S*g-1)*Math.pow(2,I),m=m+d):(l=S*Math.pow(2,d-1)*Math.pow(2,I),m=0));I>=8;T[y+v]=l&255,v+=b,l/=256,I-=8);for(m=m<<I|l,M+=I;M>0;T[y+v]=m&255,v+=b,m/=256,M-=8);T[y+v-b]|=k*128}},6698:fe=>{typeof Object.create=="function"?fe.exports=function(T,S){S&&(T.super_=S,T.prototype=Object.create(S.prototype,{constructor:{value:T,enumerable:!1,writable:!0,configurable:!0}}))}:fe.exports=function(T,S){if(S){T.super_=S;var y=function(){};y.prototype=S.prototype,T.prototype=new y,T.prototype.constructor=T}}},4634:fe=>{var x={}.toString;fe.exports=Array.isArray||function(T){return x.call(T)=="[object Array]"}},1176:(fe,x,T)=>{var S=T(5606);/**
|
|
39
|
+
`,bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239}},709:(fe,x,T)=>{"use strict";var S=T(8287).Buffer;Object.defineProperty(x,"__esModule",{value:!0}),x.testEcc=void 0;const y=o=>S.from(o,"hex");function p(o){I(o.isPoint(y("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),I(!o.isPoint(y("030000000000000000000000000000000000000000000000000000000000000005"))),I(o.isPrivate(y("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),I(o.isPrivate(y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),I(!o.isPrivate(y("0000000000000000000000000000000000000000000000000000000000000000"))),I(!o.isPrivate(y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),I(!o.isPrivate(y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),I(S.from(o.privateAdd(y("0000000000000000000000000000000000000000000000000000000000000001"),y("0000000000000000000000000000000000000000000000000000000000000000"))).equals(y("0000000000000000000000000000000000000000000000000000000000000001"))),I(o.privateAdd(y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),y("0000000000000000000000000000000000000000000000000000000000000003"))===null),I(S.from(o.privateAdd(y("e211078564db65c3ce7704f08262b1f38f1ef412ad15b5ac2d76657a63b2c500"),y("b51fbb69051255d1becbd683de5848242a89c229348dd72896a87ada94ae8665"))).equals(y("9730c2ee69edbb958d42db7460bafa18fef9d955325aec99044c81c8282b0a24"))),I(S.from(o.privateNegate(y("0000000000000000000000000000000000000000000000000000000000000001"))).equals(y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),I(S.from(o.privateNegate(y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"))).equals(y("0000000000000000000000000000000000000000000000000000000000000003"))),I(S.from(o.privateNegate(y("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(y("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792"))),I(S.from(o.pointCompress(y("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!0)).equals(y("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),I(S.from(o.pointCompress(y("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!1)).equals(y("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),I(S.from(o.pointCompress(y("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!0)).equals(y("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),I(S.from(o.pointCompress(y("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!1)).equals(y("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),I(S.from(o.pointFromScalar(y("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(y("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),I(o.xOnlyPointAddTweak(y("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))===null);let m=o.xOnlyPointAddTweak(y("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),y("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));I(S.from(m.xOnlyPubkey).equals(y("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&m.parity===1),m=o.xOnlyPointAddTweak(y("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),y("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47")),I(S.from(m.xOnlyPubkey).equals(y("9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"))&&m.parity===0),I(S.from(o.sign(y("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))).equals(y("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),I(o.verify(y("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),y("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),y("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),o.signSchnorr&&I(S.from(o.signSchnorr(y("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),y("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),y("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906"))).equals(y("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),o.verifySchnorr&&I(o.verifySchnorr(y("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),y("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),y("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}x.testEcc=p;function I(o){if(!o)throw new Error("ecc library invalid")}},953:(fe,x,T)=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0}),x.maybe=x.Boolean=x.Array=x.Buffer256bit=x.Network=x.typeforce=void 0,x.typeforce=T(8676),x.Network=x.typeforce.compile({messagePrefix:x.typeforce.oneOf(x.typeforce.Buffer,x.typeforce.String),bip32:{public:x.typeforce.UInt32,private:x.typeforce.UInt32},pubKeyHash:x.typeforce.UInt8,scriptHash:x.typeforce.UInt8,wif:x.typeforce.UInt8}),x.Buffer256bit=x.typeforce.BufferN(32),x.Array=x.typeforce.Array,x.Boolean=x.typeforce.Boolean,x.maybe=x.typeforce.maybe},8405:(fe,x,T)=>{"use strict";var S;S={value:!0};var y=T(4319),p=T(3812),I=T(9983),o=T(9796),m=T(9495),l=T(9977),g=T(5364),M=T(3836),E=T(7952),d=T(9112),A=T(1407),v=T(6833),b=T(5043),k=T(5817),B=T(6729),U=T(420),C=T(3303),L=T(1565),N=T(3092);function j(_){return _&&typeof _=="object"&&"default"in _?_:{default:_}}var K=j(I),$=j(g),Q=j(M),Y=j(E),ee=j(B),u=j(L),e=j(N);function r(_,P,W,X,ne,se){return new Promise((de,Be)=>{const Ae=[];for(let Ue=0;Ue<_.length;++Ue)Ae[Ue]=_[Ue];K.default(Ae,P,W,X,ne,se,(Ue,$e,nt)=>{if(Ue!=null)return Be(Ue);if(nt!=null)return de(Uint8Array.from(nt))})})}function n(){let _=0;return P=>{const W=new Uint8Array(P);for(let X=0;X<P;++X)_=5*_+3&255,W[X]=_;return W}}const i=()=>Promise.reject(new Error("Fake network error"));function f(){return{random:n(),scrypt:r,disklet:p.makeMemoryDisklet(),fetch:i,fetchCors:i}}class c{getFirstWalletInfo(P){return this.allKeys.find(X=>X.type===P)}getWalletInfo(P){return this.allKeys.find(X=>X.id===P)}listWalletIds(){return this.allKeys.map(P=>P.id)}}y.shareData(c.prototype,"AccountSync");function h(_){const P=_.length<10,W=!/[0-9]/.test(_),X=!/[a-z]/.test(_),ne=!/[A-Z]/.test(_),se=(/[0-9]/.test(_)?10:0)+(/[A-Z]/.test(_)?26:0)+(/[a-z]/.test(_)?26:0)+(/[^0-9A-Za-z]/.test(_)?30:0);return{secondsToCrack:Math.pow(se,_.length)/1e6,tooShort:P,noNumber:W,noLowerCase:X,noUpperCase:ne,passed:_.length>=16||!(P||W||ne||X)}}y.shareData({checkPasswordRules:h});function s(_){const P=_.toLowerCase().replace(/[ \f\r\n\t\v]+/g," ").replace(/ $/,"").replace(/^ /,"");for(let W=0;W<P.length;++W){const X=P.charCodeAt(W);if(X<32||X>126)throw new Error("Bad characters in username")}return P}y.shareData({fixUsername:s});function t(_){let P,W=!1;const X={next:async()=>{if(P==null&&(P=await this.$internalStreamTransactions(_)),!W){const ne=await P.next();if(!ne.done)return ne;y.close(P),W=!0}return{done:!0,value:void 0}},return:async()=>(P!=null&&!W&&(y.close(P),W=!0),{done:!0,value:void 0}),[Symbol.asyncIterator]:()=>X};return X}y.shareData({streamTransactions:t},"CurrencyWalletSync");const a=l.asCodec(_=>o.base16.parse(l.asString(_)),_=>o.base16.stringify(_).toLowerCase()),w=l.asCodec(_=>o.base32.parse(l.asString(_),{loose:!0}),_=>o.base32.stringify(_,{pad:!1})),D=l.asCodec(_=>o.base64.parse(l.asString(_)),_=>o.base64.stringify(_)),Z=l.asObject({voucherId:l.asString,activates:l.asDate,created:l.asDate,ip:l.asString,ipDescription:l.asString,deviceDescription:l.asOptional(l.asString)}),F=l.asObject({encryptionType:l.asNumber,data_base64:D,iv_hex:a}),V=l.asObject({salt_hex:a,n:l.asNumber,r:l.asNumber,p:l.asNumber}),q=l.asObject({loginRequest:l.asOptional(l.asObject({appId:l.asString}).withRest),publicKey:D,timeout:l.asOptional(l.asNumber)}).withRest,re=l.asObject({publicKey:D,box:F}),G=l.asArray(D),H=l.asObject({data:l.asUnknown,challengeId:l.asOptional(l.asString),deviceDescription:l.asOptional(l.asString),otp:l.asOptional(l.asString),syncToken:l.asOptional(l.asString),voucherId:l.asOptional(l.asString),voucherAuth:l.asOptional(D),loginId:l.asOptional(D),loginAuth:l.asOptional(D),userId:l.asOptional(D),passwordAuth:l.asOptional(D),pin2Id:l.asOptional(D),pin2Auth:l.asOptional(D),recovery2Id:l.asOptional(D),recovery2Auth:l.asOptional(G),loginIds:l.asOptional(l.asArray(D)),otpResetAuth:l.asOptional(l.asString),did:l.asOptional(l.asString),l1:l.asOptional(D),lp1:l.asOptional(D),lpin1:l.asOptional(D),lra1:l.asOptional(D),recoveryAuth:l.asOptional(D)}),oe=l.asObject({results:l.asOptional(l.asUnknown),status_code:l.asNumber,message:l.asString}),ue=l.asObject({otpTimeout:l.asOptional(l.asNumber,7*24*60*60),otpKey:w}),be=l.asObject({passwordAuth:D,passwordAuthBox:F,passwordAuthSnrp:V,passwordBox:F,passwordKeySnrp:V}),ie=l.asObject({pin2Id:D}),J=l.asObject({pin2Id:l.asOptional(D),pin2Auth:l.asOptional(D),pin2Box:l.asOptional(F),pin2KeyBox:l.asOptional(F),pin2TextBox:F}),pe=l.asObject({recovery2Id:D}),Ge=l.asObject({recovery2Id:D,recovery2Auth:G,recovery2Box:F,recovery2KeyBox:F,question2Box:F}),ce=l.asObject({loginAuthBox:F,loginAuth:D}),te=l.asObject({userId:D,userTextBox:F}),le=l.asObject({approvedVouchers:l.asOptional(l.asArray(l.asString)),rejectedVouchers:l.asOptional(l.asArray(l.asString))}),ge=l.asObject({keyBoxes:l.asArray(F),newSyncKeys:l.asOptional(l.asArray(l.asString),()=>[])}),Pe=l.asObject({appId:l.asString,loginId:D,parentBox:l.asOptional(F)}),lt=l.asObject({challengeId:l.asString,challengeUri:l.asString}),Le=l.asObject({request:q,replies:l.asArray(re)}),ze=l.asValue(!0),kt=l.asObject({appId:l.asString,created:l.asDate,loginId:D,syncToken:l.asOptional(l.asString),children:l.asOptional(l.asArray(_=>kt(_))),parentBox:l.asOptional(F),otpKey:l.asOptional(l.asEither(ze,w)),otpResetDate:l.asOptional(l.asDate),otpTimeout:l.asOptional(l.asNumber),passwordAuthBox:l.asOptional(F),passwordAuthSnrp:l.asOptional(V),passwordBox:l.asOptional(l.asEither(ze,F)),passwordKeySnrp:l.asOptional(V),pin2Box:l.asOptional(l.asEither(ze,F)),pin2KeyBox:l.asOptional(F),pin2TextBox:l.asOptional(F),question2Box:l.asOptional(F),recovery2Box:l.asOptional(l.asEither(ze,F)),recovery2KeyBox:l.asOptional(F),loginAuthBox:l.asOptional(F),userId:l.asOptional(D),userTextBox:l.asOptional(F),pendingVouchers:l.asOptional(l.asArray(Z),()=>[]),keyBoxes:l.asOptional(l.asArray(F)),mnemonicBox:l.asOptional(F),rootKeyBox:l.asOptional(F),syncKeyBox:l.asOptional(F)}),ae=l.asArray(l.asObject({loginId:D,otpResetPending:l.asOptional(l.asBoolean,!1),pendingVouchers:l.asOptional(l.asArray(Z),()=>[]),recovery2Corrupt:l.asOptional(l.asBoolean,!1)})),he=l.asObject({login_id:l.asOptional(D),otp_reset_auth:l.asOptional(l.asString),otp_timeout_date:l.asOptional(l.asDate),reason:l.asOptional(l.asValue("ip","otp"),"otp"),voucher_activates:l.asOptional(l.asDate),voucher_auth:l.asOptional(D),voucher_id:l.asOptional(l.asString)}),je=l.asObject({otpResetDate:l.asDate}),Ie=l.asObject({wait_seconds:l.asOptional(l.asNumber)}),Ce=l.asObject({question2Box:F}),ut=l.asObject({loginId:D,passwordAuthSnrp:l.asOptional(V),questionBox:l.asOptional(F),questionKeySnrp:l.asOptional(V),recoveryAuthSnrp:l.asOptional(V)}),De=l.uncleaner(F),ye=l.uncleaner(re),we=l.uncleaner(q),ve=l.uncleaner(H),Ee=l.uncleaner(oe),rt=l.uncleaner(ue),Fe=l.uncleaner(be),He=l.uncleaner(ie),yt=l.uncleaner(J),Ke=l.uncleaner(pe),Ze=l.uncleaner(Ge),At=l.uncleaner(ce),Ve=l.uncleaner(te),tt=l.uncleaner(le),qt=l.uncleaner(ge),et=l.uncleaner(Pe),st=l.uncleaner(lt),rr=l.uncleaner(Le),at=l.uncleaner(kt),ft=l.uncleaner(ae),Qe=l.uncleaner(he),xe=l.uncleaner(je),Oe=l.uncleaner(Ie),ht=l.uncleaner(Ce),Ne=l.uncleaner(ut),qe=l.asObject(F),Dt=l.asObject({loginId:D,voucherAuth:D,voucherId:l.asString,created:l.asDate,activates:l.asDate,status:l.asValue("pending","approved","rejected"),ip:l.asString,ipDescription:l.asString,deviceDescription:l.asOptional(l.asString)}),Xe=l.asObject({appId:l.asString,created:l.asOptional(l.asDate,()=>new Date),loginId:D,children:l.asOptional(l.asArray(_=>Xe(_)),()=>[]),parentBox:l.asOptional(F),parentId:()=>{},otpKey:l.asOptional(w),otpResetAuth:l.asOptional(l.asString),otpResetDate:l.asOptional(l.asDate),otpTimeout:l.asOptional(l.asNumber),passwordAuth:l.asOptional(D),passwordAuthBox:l.asOptional(F),passwordAuthSnrp:l.asOptional(V),passwordBox:l.asOptional(F),passwordKeySnrp:l.asOptional(V),pin2Id:l.asOptional(D),pin2Auth:l.asOptional(D),pin2Box:l.asOptional(F),pin2KeyBox:l.asOptional(F),pin2TextBox:l.asOptional(F),recovery2Id:l.asOptional(D),recovery2Auth:l.asOptional(G),question2Box:l.asOptional(F),recovery2Box:l.asOptional(F),recovery2KeyBox:l.asOptional(F),loginAuth:l.asOptional(D),loginAuthBox:l.asOptional(F),userId:l.asOptional(D),userTextBox:l.asOptional(F),keyBoxes:l.asOptional(l.asArray(F),()=>[]),mnemonicBox:l.asOptional(F),rootKeyBox:l.asOptional(F),syncKeyBox:l.asOptional(F),vouchers:l.asOptional(l.asArray(Dt),()=>[]),pinBox:l.asOptional(F),pinId:l.asOptional(l.asString),pinKeyBox:l.asOptional(F)}),ot=l.uncleaner(Xe),Gt=l.uncleaner(qe),xt=$.default("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),gt={parse(_){return xt.decode(_)},stringify(_){return xt.encode(_)}},bt={parse(_){const P=encodeURI(_),W=new Uint8Array(P.length);let X=0;for(let ne=0;ne<P.length;++ne){const se=P.charCodeAt(ne);se===37?(W[X++]=parseInt(P.slice(ne+1,ne+3),16),ne+=2):W[X++]=se}return W.subarray(0,X)},stringify(_){let P="";for(let W=0;W<_.length;++W){const X=_[W];P+="%"+(X>>4).toString(16)+(X&15).toString(16)}return decodeURIComponent(P)}};function Tt(_){const P=new URL(_);if(!(P.protocol==="http:"&&P.hostname==="localhost")&&!(P.protocol==="https:"&&(P.hostname==="localhost"||/^([A-Za-z0-9_-]+\.)*edge(test)?\.app$/.test(P.hostname))))throw new Error(`Only *.edge.app or localhost are valid login domain names, not ${P.hostname}`)}function Ct(_,P="Login requires a CAPTCHA"){if(!(this instanceof Ct))throw new TypeError("Class constructor ChallengeError cannot be invoked without 'new'");var W;function X(ne){return W=new Error(ne),Object.defineProperty(W,"constructor",{value:Ct,configurable:!0,writable:!0}),W}return X(P),W.name="ChallengeError",W.challengeId=_.challengeId,W.challengeUri=_.challengeUri,W}function Xt(_="Please send a larger amount"){if(!(this instanceof Xt))throw new TypeError("Class constructor DustSpendError cannot be invoked without 'new'");var P;function W(X){return P=new Error(X),Object.defineProperty(P,"constructor",{value:Xt,configurable:!0,writable:!0}),P}return W(_),P.name="DustSpendError",P}function Yt(_){if(!(this instanceof Yt))throw new TypeError("Class constructor InsufficientFundsError cannot be invoked without 'new'");var P;function W(se){return P=new Error(se),Object.defineProperty(P,"constructor",{value:Yt,configurable:!0,writable:!0}),P}const{tokenId:X=null,networkFee:ne}=_!=null?_:{};return W(`Insufficient ${X!=null?X:"funds"}`),P.tokenId=X,P.networkFee=ne,P.name="InsufficientFundsError",P}function ar(_="Cannot reach the network"){if(!(this instanceof ar))throw new TypeError("Class constructor NetworkError cannot be invoked without 'new'");var P;function W(X){return P=new Error(X),Object.defineProperty(P,"constructor",{value:ar,configurable:!0,writable:!0}),P}return W(_),P.name="NetworkError",P}function or(_="Unable to create zero-amount transaction."){if(!(this instanceof or))throw new TypeError("Class constructor NoAmountSpecifiedError cannot be invoked without 'new'");var P;function W(X){return P=new Error(X),Object.defineProperty(P,"constructor",{value:or,configurable:!0,writable:!0}),P}return W(_),P.name="NoAmountSpecifiedError",P}function sr(_="The application is too old. Please upgrade."){if(!(this instanceof sr))throw new TypeError("Class constructor ObsoleteApiError cannot be invoked without 'new'");var P;function W(X){return P=new Error(X),Object.defineProperty(P,"constructor",{value:sr,configurable:!0,writable:!0}),P}return W(_),P.name="ObsoleteApiError",P}function $t(_,P="Invalid OTP token"){if(!(this instanceof $t))throw new TypeError("Class constructor OtpError cannot be invoked without 'new'");var W;function X(se){return W=new Error(se),Object.defineProperty(W,"constructor",{value:$t,configurable:!0,writable:!0}),W}X(P),W.name="OtpError",W.reason="otp";const ne=l.asMaybe(he)(_);if(ne!=null)return ne.login_id!=null&&(W.loginId=o.base64.stringify(ne.login_id)),W.resetToken=ne.otp_reset_auth,W.reason=ne.reason,W.resetDate=ne.otp_timeout_date,W.voucherActivates=ne.voucher_activates,ne.voucher_auth!=null&&(W.voucherAuth=o.base64.stringify(ne.voucher_auth)),W.voucherId=ne.voucher_id,W}function nr(_,P="Invalid password"){if(!(this instanceof nr))throw new TypeError("Class constructor PasswordError cannot be invoked without 'new'");var W;function X(se){return W=new Error(se),Object.defineProperty(W,"constructor",{value:nr,configurable:!0,writable:!0}),W}X(P),W.name="PasswordError";const ne=l.asMaybe(Ie)(_);if(ne!=null)return W.wait=ne.wait_seconds,W}function fr(_="Not enough confirmed funds"){if(!(this instanceof fr))throw new TypeError("Class constructor PendingFundsError cannot be invoked without 'new'");var P;function W(X){return P=new Error(X),Object.defineProperty(P,"constructor",{value:fr,configurable:!0,writable:!0}),P}return W(_),P.name="PendingFundsError",P}function lr(_="Wallets can not be the same currency"){if(!(this instanceof lr))throw new TypeError("Class constructor SameCurrencyError cannot be invoked without 'new'");var P;function W(X){return P=new Error(X),Object.defineProperty(P,"constructor",{value:lr,configurable:!0,writable:!0}),P}return W(_),P.name="SameCurrencyError",P}function dr(_="Spending to self"){if(!(this instanceof dr))throw new TypeError("Class constructor SpendToSelfError cannot be invoked without 'new'");var P;function W(X){return P=new Error(X),Object.defineProperty(P,"constructor",{value:dr,configurable:!0,writable:!0}),P}return W(_),P.name="SpendToSelfError",P}function cr(_,P,W="from"){if(!(this instanceof cr))throw new TypeError("Class constructor SwapAboveLimitError cannot be invoked without 'new'");var X;function ne(se){return X=new Error(se),Object.defineProperty(X,"constructor",{value:cr,configurable:!0,writable:!0}),X}return ne("Amount is too high"),X.name="SwapAboveLimitError",X.pluginId=_.pluginId,X.nativeMax=P,X.direction=W,X}function gr(_,P,W="from"){if(!(this instanceof gr))throw new TypeError("Class constructor SwapBelowLimitError cannot be invoked without 'new'");var X;function ne(se){return X=new Error(se),Object.defineProperty(X,"constructor",{value:gr,configurable:!0,writable:!0}),X}return ne("Amount is too low"),X.name="SwapBelowLimitError",X.pluginId=_.pluginId,X.nativeMin=P,X.direction=W,X}function pr(_,P){if(!(this instanceof pr))throw new TypeError("Class constructor SwapCurrencyError cannot be invoked without 'new'");var W;function X(Ye){return W=new Error(Ye),Object.defineProperty(W,"constructor",{value:pr,configurable:!0,writable:!0}),W}const{fromWallet:ne,toWallet:se,fromTokenId:de,toTokenId:Be}=P,Ae=ne.currencyConfig.currencyInfo.pluginId,Ue=se.currencyConfig.currencyInfo.pluginId,$e=`${Ae}:${String(de)}`,nt=`${Ue}:${String(Be)}`;return X(`${_.displayName} does not support ${$e} to ${nt}`),W.name="SwapCurrencyError",W.pluginId=_.pluginId,W.fromTokenId=de!=null?de:null,W.toTokenId=Be!=null?Be:null,W}function dn(_,P){if(!(this instanceof dn))throw new TypeError("Class constructor SwapPermissionError cannot be invoked without 'new'");var W;function X(ne){return W=new Error(ne),Object.defineProperty(W,"constructor",{value:dn,configurable:!0,writable:!0}),W}return P!=null?X(P):X("You are not allowed to make this trade"),W.name="SwapPermissionError",W.pluginId=_.pluginId,W.reason=P,W}function Jr(_="Invalid username"){if(!(this instanceof Jr))throw new TypeError("Class constructor UsernameError cannot be invoked without 'new'");var P;function W(X){return P=new Error(X),Object.defineProperty(P,"constructor",{value:Jr,configurable:!0,writable:!0}),P}return W(_),P.name="UsernameError",P}function Ur(_){return function(W){if(W instanceof Error&&W.name===_)return W}}const Mn=Ur("ChallengeError"),Kn=Ur("DustSpendError"),Xn=Ur("InsufficientFundsError"),On=Ur("NetworkError"),zo=Ur("NoAmountSpecifiedError"),ao=Ur("ObsoleteApiError"),di=Ur("OtpError"),Zn=Ur("PasswordError"),Bn=Ur("PendingFundsError"),so=Ur("SameCurrencyError"),Yn=Ur("SpendToSelfError"),pi=Ur("SwapAboveLimitError"),$n=Ur("SwapBelowLimitError"),fo=Ur("SwapCurrencyError"),yn=Ur("SwapPermissionError"),In=Ur("UsernameError");function Ni(_,P){const W=Y.default.hmac(Y.default.sha1,P);return Uint8Array.from(W.update(_).digest())}function fn(_,P){const W=Y.default.hmac(Y.default.sha256,P);return Uint8Array.from(W.update(_).digest())}function tn(_){const P=Y.default.sha256();return Uint8Array.from(P.update(_).digest())}function Cr(_,P){const W=_.length;if(W!==P.length)return!1;let X=0;for(let ne=0;ne<W;++ne)X|=_[ne]^P[ne];return X===0}const Rn=Q.default.ModeOfOperation.cbc;function bn(_,P){const W=Qr(_,P);return W[W.length-1]===0?bt.stringify(W.subarray(0,-1)):bt.stringify(W)}function Qr(_,P){if(_.encryptionType!==0)throw new Error("Unknown encryption type");const W=_.iv_hex,X=_.data_base64,se=new Rn(P,W).decrypt(X),de=1,Be=se[0],Ae=de+Be+4,Ue=se[Ae-4]<<24|se[Ae-3]<<16|se[Ae-2]<<8|se[Ae-1],$e=Ae+Ue+1,nt=se[$e-1],Ye=$e+nt,vt=Ye+32,Et=tn(se.subarray(0,Ye));if(!Cr(Et,se.subarray(Ye,vt)))throw new Error("Invalid checksum");const mt=uo(vt);if(!Cr(mt,se.subarray(vt)))throw new Error("Invalid PKCS7 padding");return se.subarray(Ae,Ae+Ue)}function rn(_,P,W){const ne=_.random(1)[0]&31,se=1+ne+4,de=P.length,Be=se+de+1,Ae=_.random(1)[0]&31,Ue=Be+Ae,$e=Ue+32,nt=uo($e),Ye=new Uint8Array($e+nt.length);Ye.set(nt,$e),Ye[0]=ne,Ye.set(_.random(ne),1),Ye[se-4]=de>>24&255,Ye[se-3]=de>>16&255,Ye[se-2]=de>>8&255,Ye[se-1]=de&255,Ye.set(P,se),Ye[Be-1]=Ae,Ye.set(_.random(Ae),Be),Ye.set(tn(Ye.subarray(0,Ue)),Ue);const vt=_.random(16),mt=new Rn(W,vt).encrypt(Ye);return{encryptionType:0,iv_hex:vt,data_base64:mt}}function uo(_){const P=new Uint8Array(16-(_&15));for(let W=0;W<P.length;++W)P[W]=P.length;return P}function Jn(..._){return[].concat(..._.filter(W=>W!=null))}function Ko(_,P){for(const W of Object.keys(P))Object.defineProperty(_,W,{writable:!0,configurable:!0,value:P[W]});return _}function Fr(_){const P=l.uncleaner(_);return{async load(W,X){try{return _(JSON.parse(await W.getText(X)))}catch{}},async save(W,X,ne){await W.setText(X,JSON.stringify(P(ne)))}}}const Cn=_=>{if(_==null||typeof _!="object")throw new TypeError("Expected a JSON object");return _};function lo(_,P,W){return function(){let ne="";for(let se=0;se<arguments.length;++se){const de=arguments[se];se>0&&(ne+=" "),typeof de=="string"?ne+=de:de instanceof Error?ne+=String(de):ne+=JSON.stringify(de,null,2)}_({message:ne,source:W,time:new Date,type:P})}}function jo(_){const P=_.time.toISOString().replace(/.*(\d\d-\d\d)T(\d\d:\d\d:\d\d).*/,"$1 $2");console.info(`${P} ${_.source}: ${_.message}`)}function Wo(_,P){function W(X){const{sources:ne,defaultLogLevel:se}=P(),de=ne[X.source]!=null?ne[X.source]:se;switch(X.type){case"info":de==="info"&&_.onLog(X);break;case"warn":(de==="info"||de==="warn")&&_.onLog(X);break;case"error":de!=="silent"&&_.onLog(X);break}}return{..._,onLog:W}}function co(_,P){const{onLog:W,crashReporter:X}=_;return Ko(lo(W,"info",P),{breadcrumb(ne,se){const de=new Date;X!=null?X.logBreadcrumb({message:ne,metadata:se,source:P,time:de}):(ne=`${ne} ${JSON.stringify(se,null,2)}`,W({message:ne,source:P,time:de,type:"warn"}))},crash(ne,se){const de=new Date;if(X!=null)X.logCrash({error:ne,metadata:se,source:P,time:de});else{const Be=`${String(ne)} ${JSON.stringify(se,null,2)}`;W({message:Be,source:P,time:de,type:"error"})}},warn:lo(W,"warn",P),error:lo(W,"error",P)})}function Ca(_){return new Promise(P=>setTimeout(()=>P(_),_))}function Go(_){for(let P=_.length-1;P>0;P--){const W=Math.floor(Math.random()*(P+1));[_[P],_[W]]=[_[W],_[P]]}return _}const Li=l.asObject({dataKey:D,syncKey:D}),vi=l.uncleaner(Li);function Vo(_){const{io:P}=_.props;return{dataKey:P.random(32),syncKey:P.random(20)}}function Fa(_,P,W){const X={delete(ne){return W.delete(ne)},async getData(ne){const se=await W.getText(ne),de=F(JSON.parse(se));return Qr(de,P)},async getText(ne){const se=await W.getText(ne),de=F(JSON.parse(se));return bn(de,P)},list(ne){return W.list(ne)},setData(ne,se){return W.setText(ne,JSON.stringify(De(rn(_,Uint8Array.from(se),P))))},setText(ne,se){return this.setData(ne,bt.parse(se))}};return y.bridgifyObject(X),X}function Rf(_,P){return _.storageWallets[P].lastChanges}function Kr(_,P){return _.storageWallets[P].paths.disklet}function ho(_,P){return _.storageWallets[P].localDisklet}function Cf(_,P,W){return Fa(W,_.storageWallets[P].paths.dataKey,_.storageWallets[P].localDisklet)}function mi(_,P,W){const X=_.storageWallets[P].paths.dataKey;return gt.stringify(fn(bt.parse(W),X))}const qo=l.asObject({multiplier:l.asString,name:l.asString,symbol:l.asOptional(l.asString)}),Ff=l.asObject({currencyCode:l.asString,denominations:l.asArray(qo),displayName:l.asString,networkLocation:l.asOptional(Cn)}),Nf=l.asObject({enabled:l.asOptional(l.asBoolean,!0)}).withRest,Lf=l.asObject({SortIndex:l.asOptional(l.asNumber,0),Archived:l.asOptional(l.asBoolean,!1),BitcoinSeed:a,MK:a,SyncKey:a}).withRest,Df=l.asObject({id:l.asString,archived:l.asOptional(l.asBoolean),deleted:l.asOptional(l.asBoolean),hidden:l.asOptional(l.asBoolean),migratedFromWalletId:l.asOptional(l.asString),sortIndex:l.asOptional(l.asNumber)}),Na=l.asObject({userSettings:l.asOptional(l.asObject(Cn),()=>({})),swapSettings:l.asOptional(l.asObject(Nf),()=>({}))}).withRest,Uf=l.asObject({customTokens:l.asArray(l.asObject({contractAddress:l.asString,currencyCode:l.asString,currencyName:l.asString,denomination:l.asString,denominations:l.asArray(qo),isVisible:l.asOptional(l.asBoolean,!0),multiplier:l.asString,walletType:l.asOptional(l.asString,"wallet:ethereum")}))}),Hf=l.asObject({customTokens:l.asObject(l.asObject(Ff))}),zf=Fr(Lf),La=Fr(Df),gi=Fr(Na),Da=Na({}),Di="PluginSettings.json";function Ua(_,P){for(const W of Object.keys(P))if(_[W]!==P[W])return!0;return!1}async function Kf(_){const P=[],W={},X=p.justFiles(await _.list("Wallets"));return await Promise.all(X.map(async ne=>{const se=await zf.load(_,ne);if(se==null)return;const de={...vi({dataKey:se.MK,syncKey:se.SyncKey}),bitcoinKey:o.base64.stringify(se.BitcoinSeed),format:"bip32"},Be=Ui("wallet:bitcoin",de,se.MK);P.push(Be),W[Be.id]={archived:se.Archived,deleted:!1,hidden:!1,migratedFromWalletId:void 0,sortIndex:se.SortIndex}})),{walletInfos:P,walletStates:W}}async function jf(_){const P={},W=p.justFiles(await _.list("Keys"));return await Promise.all(W.map(async X=>{const ne=await La.load(_,X);if(ne==null)return;const{id:se,archived:de,deleted:Be,hidden:Ae,migratedFromWalletId:Ue,sortIndex:$e}=ne;P[se]={archived:de,deleted:Be,hidden:Ae,sortIndex:$e,migratedFromWalletId:Ue}})),P}async function Xo(_,P){const W=_.props.state.accounts[P],{accountWalletInfo:X,accountWalletInfos:ne}=W,se=await Promise.all(ne.map($e=>Kf(Kr(_.props.state,$e.id)))),de=await jf(Kr(_.props.state,X.id)),Be=[];for(const $e of se)Be.push(...$e.walletInfos);const Ae=se.map($e=>$e.walletStates),Ue=Object.assign({},...Ae,de);_.props.dispatch({type:"ACCOUNT_KEYS_LOADED",payload:{accountId:P,legacyWalletInfos:Be,walletStates:Ue}})}async function Zo(_,P,W){const{accountWalletInfo:X,walletStates:ne}=_.props.state.accounts[P],se=Kr(_.props.state,X.id),de={};for(const Ae of Object.keys(W))ne[Ae]==null?de[Ae]=W[Ae]:Ua(ne[Ae],W[Ae])&&(de[Ae]={...ne[Ae],...W[Ae]});const Be=Object.keys(de);Be.length<1||(await Promise.all(Be.map(async Ae=>{const{archived:Ue,deleted:$e,hidden:nt,migratedFromWalletId:Ye,sortIndex:vt}=de[Ae],Et=mi(_.props.state,X.id,Ae);await La.save(se,`Keys/${Et}.json`,{archived:Ue,deleted:$e,hidden:nt,id:Ae,migratedFromWalletId:Ye,sortIndex:vt})})),_.props.dispatch({type:"ACCOUNT_CHANGED_WALLET_STATES",payload:{accountId:P,walletStates:{...ne,...de}}}))}async function Ha(_,P,W,X){var Be;const{accountWalletInfo:ne}=_.props.state.accounts[P],se=Kr(_.props.state,ne.id),de=(Be=await gi.load(se,Di))!=null?Be:Da;await gi.save(se,Di,{...de,userSettings:{..._.props.state.accounts[P].userSettings,[W]:X}}),_.props.dispatch({type:"ACCOUNT_PLUGIN_SETTINGS_CHANGED",payload:{accountId:P,pluginId:W,userSettings:{...X}}})}async function Wf(_,P,W,X){var Be;const{accountWalletInfo:ne}=_.props.state.accounts[P],se=Kr(_.props.state,ne.id),de=(Be=await gi.load(se,Di))!=null?Be:Da;await gi.save(se,Di,{...de,swapSettings:{..._.props.state.accounts[P].swapSettings,[W]:X}}),_.props.dispatch({type:"ACCOUNT_SWAP_SETTINGS_CHANGED",payload:{accountId:P,pluginId:W,swapSettings:X}})}async function za(_,P){const{accountWalletInfo:W}=_.props.state.accounts[P],X=Kr(_.props.state,W.id),ne=await gi.load(X,Di),{userSettings:se,swapSettings:de}=ne!=null?ne:{userSettings:{},swapSettings:{}};_.props.dispatch({type:"ACCOUNT_PLUGIN_SETTINGS_LOADED",payload:{accountId:P,userSettings:se,swapSettings:de}})}function Ka(_,P,W){for(const X of _.denominations)if(X.name===W)return X.multiplier;for(const X of Object.keys(P)){const ne=P[X];for(const se of ne.denominations)if(se.name===W)return se.multiplier}return"1"}function ja(_,P){return _.waitFor(X=>{if(X.state.currency.wallets[P]==null)throw new Error(`Wallet id ${P} does not exist in this account`);const{engineFailure:ne}=X.state.currency.wallets[P];if(ne!=null)throw ne;if(X.output.currency.wallets[P]!=null)return X.output.currency.wallets[P].walletApi})}function yi(_,P){const W=po(_,P);if(W==null)throw new Error(`Cannot find a currency plugin for wallet type ${P}`);return W}function po(_,P){return Object.keys(_).find(W=>_[W].currencyInfo.walletType===P)}function Fn(_,P){const{dispatch:W,state:X}=_.props,ne=X.plugins.currencyTools[P];if(ne!=null)return ne;const de=X.plugins.currency[P].makeCurrencyTools();return W({type:"CURRENCY_TOOLS_LOADED",payload:{pluginId:P,tools:de}}),de}async function Wa(_){await _.waitFor(P=>{const{init:W,locked:X}=P.state.plugins;if(!X)return;const{currency:ne,swap:se}=P.state.plugins,de=[];for(const Be of Object.keys(W))W[Be]!==!1&&W[Be]!=null&&ne[Be]==null&&se[Be]==null&&de.push(Be);if(de.length>0)throw new Error("The following plugins are missing or failed to load: "+de.join(", "));return!0})}const Ga=l.asObject({id:l.asString,keys:Cn,type:l.asString}),Gf=l.uncleaner(Ga);function Vf(_,P){return _.find(W=>W.type===P)}function vo(_){return _===""?"account-repo:co.airbitz.wallet":`account-repo:${_}`}function Ui(_,P,W){const X=fn(bt.parse(_),W!=null?W:Li(P).dataKey);return{id:o.base64.stringify(X),type:_,keys:P}}function bi(_,P,W){const{io:X}=_.props,ne=W.map(de=>rn(X,bt.parse(JSON.stringify(Gf(de))),P.loginKey)),se=[];for(const de of W){const Be=l.asMaybe(Li)(de.keys);Be!=null&&se.push(o.base16.stringify(Be.syncKey).toLowerCase())}return{serverPath:"/v2/login/keys",server:qt({keyBoxes:ne,newSyncKeys:se}),stash:{keyBoxes:ne},login:{keyInfos:W},loginId:P.loginId}}function Yo(_){const P=[],W={};for(const X of _){const{id:ne,type:se,keys:de}=X;if(ne==null||o.base64.parse(ne).length!==32)throw new Error(`Key integrity violation: invalid id ${ne}`);if(W[ne]!=null){const Be=P[W[ne]];if(Be.type!==se)throw new Error(`Key integrity violation for ${ne}: type ${se} does not match ${Be.type}`);for(const Ae of Object.keys(de))if(Be.keys[Ae]!=null&&Be.keys[Ae]!==de[Ae])throw new Error(`Key integrity violation for ${ne}: ${Ae} keys do not match`);P[W[ne]]={id:ne,type:se,keys:{...Be.keys,...de}}}else W[ne]=P.length,P.push(X)}return P}function qf(_,P=[]){const W={},X=[];for(const se of P)X.push(se),W[se.id]==null?W[se.id]=[_.appId]:W[se.id].push(_.appId);function ne(se){for(const de of se.keyInfos)X.push(de),W[de.id]==null?W[de.id]=[se.appId]:W[de.id].push(se.appId);for(const de of se.children)ne(de)}return ne(_),{appIdMap:W,walletInfos:Yo(X)}}function Va(_){const{id:P,keys:W,type:X}=_,ne={"wallet:bitcoin-bip44":{format:"bip44",coinType:0},"wallet:bitcoin-bip49":{format:"bip49",coinType:0},"wallet:bitcoincash-bip32":{format:"bip32"},"wallet:bitcoincash-bip44":{format:"bip44",coinType:145},"wallet:bitcoincash-bip44-testnet":{format:"bip44",coinType:1},"wallet:bitcoin-bip44-testnet":{format:"bip44",coinType:1},"wallet:bitcoin-bip49-testnet":{format:"bip49",coinType:1},"wallet:dash-bip44":{format:"bip44",coinType:5},"wallet:dogecoin-bip44":{format:"bip44",coinType:3},"wallet:litecoin-bip44":{format:"bip44",coinType:2},"wallet:litecoin-bip49":{format:"bip49",coinType:2},"wallet:feathercoin-bip49":{format:"bip49",coinType:8},"wallet:feathercoin-bip44":{format:"bip44",coinType:8},"wallet:qtum-bip44":{format:"bip44",coinType:2301},"wallet:ufo-bip49":{format:"bip49",coinType:202},"wallet:ufo-bip84":{format:"bip84",coinType:202},"wallet:zcoin-bip44":{format:"bip44",coinType:136},"wallet:bitcoin-testnet":{format:"bip32"},"wallet:bitcoin":{format:"bip32"},"wallet:bitcoincash-testnet":{format:"bip32"},"wallet:litecoin":{format:"bip32",coinType:2},"wallet:zcoin":{format:"bip32",coinType:136}};return ne[X]!=null?{id:P,keys:{...ne[X],...W},type:X.replace(/-bip[0-9]+/,"")}:_}async function mo(_,P,W){const{importText:X,keyOptions:ne,keys:se}=W;function de(Ue,$e){return $e!=null&&(Ue={...Ue,imported:$e}),Va(Ui(P,{...vi(Vo(_)),...Ue}))}if(se!=null)return de(se);const Be=yi(_.props.state.plugins.currency,P),Ae=await Fn(_,Be);if(X!=null){if(Ae.importPrivateKey==null)throw new Error("This wallet does not support importing keys");return de(await Ae.importPrivateKey(X,ne),!0)}return de(await Ae.createPrivateKey(P,ne),!1)}async function qa(_,P,W,X){const{enabledTokenIds:ne,fiatCurrencyCode:se,migratedFromWalletId:de,name:Be}=X,Ae=await ja(_,W);return de!=null&&await Zo(_,P,{[W]:{migratedFromWalletId:de}}),Be!=null&&await Ae.renameWallet(Be),se!=null&&await Ae.setFiatCurrencyCode(se),ne!=null&&ne.length>0&&await Ae.changeEnabledTokenIds(ne),Ae}function Xa(_,P,W=new Error(`Timeout of ${P}ms exceeded`)){return new Promise((X,ne)=>{const se=setTimeout(()=>ne(W),P);_.then(de=>{clearTimeout(se),X(de)},de=>{clearTimeout(se),ne(de)})})}function Za(_,P){return new Promise((W,X)=>{let ne=!1;const se=[],de=[];let Be=setTimeout(()=>{Be=void 0,se.length>0&&(ne=!0,W({results:se,errors:de}))},P);function Ae(){const Ue=se.length+de.length===_.length;Ue&&Be!=null&&clearTimeout(Be),(Ue||Be==null)&&(ne=!0,se.length>0?W({results:se,errors:de}):X(de))}Ae();for(const Ue of _)Ue.then($e=>{ne||(se.push($e),Ae())},$e=>{ne||(de.push($e),Ae())})})}function Xf(_){const P=oe(_);switch(P.status_code){case 0:return P.results;case 2:throw new Jr("Account already exists on server");case 3:throw new Jr("Account does not exist on server");case 4:case 5:throw new nr(P.results);case 6:throw new Error("Invalid API key");case 8:throw new $t(P.results);case 1e3:throw new sr;case 1:case 7:case 9:case 10:case 11:default:{const W=l.asMaybe(lt)(P.results);throw W!=null?new Ct(W):new Error(`Server error: ${P.message}`)}}}function en(_,P,W,X){const{state:ne,io:se,log:de}=_.props,{apiKey:Be,serverUri:Ae}=ne.login,Ue={method:P,headers:{"content-type":"application/json",accept:"application/json",authorization:`Token ${Be===""?"4248c1bf41e53b840a5fdb2c872dd3ade525e66d":Be}`}};P!=="GET"&&X!=null&&(Ue.body=JSON.stringify(ve(X)));const $e=Date.now(),nt=`${Ae}${W}`;return Xa(se.fetch(nt,Ue),3e4).then(Ye=>{const vt=Date.now()-$e;return de(`${P} ${nt} returned ${Ye.status} in ${vt}ms`),Ye.json().then(Xf,()=>{throw new Error(`Invalid reply JSON, HTTP status ${Ye.status}`)})},Ye=>{const vt=Date.now()-$e;throw de.error(`${P} ${nt} failed in ${vt}ms, ${String(Ye)}`),new ar(`Could not reach the auth server: ${W}`)})}function $o(_,P){const{io:W}=_.props,{loginId:X,loginKey:ne}=P,se=W.random(32),de=rn(W,se,ne);return{login:{loginAuth:se},loginId:X,server:At({loginAuth:se,loginAuthBox:de}),serverPath:"/v2/login/secret",stash:{loginAuthBox:de}}}function Zf(_,P=2e3){return _.props.output.scrypt.makeSnrp(P)}async function wi(_,P,W){return typeof P=="string"&&(P=bt.parse(P)),(await _.props.output.scrypt.timeScrypt(P,W)).hash}const Qn={salt_hex:Uint8Array.from([181,134,95,251,159,167,179,191,228,178,56,77,71,206,131,30,226,42,74,157,92,52,199,239,125,33,70,124,199,88,248,27]),n:16384,r:1,p:1};function Ya(_){return{username:_,appId:"",loginId:new Uint8Array(0),pendingVouchers:[]}}function go(_,P){const{stashes:W}=_.props.state.login;for(const X of W)if(X.username===P)return X}function En(_,P){const{stashes:W}=_.props.state.login;for(const X of W){const ne=Sn(X,se=>Cr(se.loginId,P));if(ne!=null)return{stashTree:X,stash:ne}}throw new Error(`Cannot find stash ${o.base64.stringify(P)}`)}const yo={};function Hi(_,P){return yo[P]==null&&(yo[P]=wi(_,P,Qn)),yo[P]}async function Yf(_,P){const W=[],X=await _.list("logins").then(p.justFiles);for(const ne of X)try{W.push(xi(JSON.parse(await _.getText(ne))))}catch(se){P.error(`Could not load ${ne}: ${String(se)}`)}return W}async function $a(_,P){const{dispatch:W,io:X}=_.props,ne=await X.disklet.list("logins").then(p.justFiles);for(const se of ne)try{const de=xi(JSON.parse(await X.disklet.getText(se)));Cr(de.loginId,P)&&await X.disklet.delete(se)}catch{}W({type:"LOGIN_STASH_DELETED",payload:P})}async function Nn(_,P){const{dispatch:W,io:X}=_.props,{appId:ne,loginId:se}=P;if(ne!=="")throw new Error("Cannot save a login without an appId.");if(se==null||se.length!==32)throw new Error("Invalid loginId");await X.disklet.setText(`logins/${gt.stringify(se)}.json`,JSON.stringify(Ja(P))),W({type:"LOGIN_STASH_SAVED",payload:P})}const $f=_=>s(l.asString(_)),xi=l.asObject({appId:l.asString,created:l.asOptional(l.asDate),lastLogin:l.asOptional(l.asDate),loginId:D,otpKey:l.asOptional(w),otpResetDate:l.asOptional(l.asDate),otpTimeout:l.asOptional(l.asNumber),pendingVouchers:l.asOptional(l.asArray(Z),()=>[]),voucherId:l.asOptional(l.asString),voucherAuth:l.asOptional(D),loginAuthBox:l.asOptional(F),parentBox:l.asOptional(F),passwordAuthBox:l.asOptional(F),passwordAuthSnrp:l.asOptional(V),passwordBox:l.asOptional(F),passwordKeySnrp:l.asOptional(V),pin2Key:l.asOptional(l.asCodec(_=>{const P=l.asString(_);return _.slice(-1)!=="="?gt.parse(P):o.base64.parse(P)},_=>o.base64.stringify(_))),pin2TextBox:l.asOptional(F),recovery2Key:l.asOptional(D),userId:l.asOptional(D),username:l.asOptional($f),children:l.asOptional(l.asArray(_=>xi(_))),keyBoxes:l.asOptional(l.asArray(F)),mnemonicBox:l.asOptional(F),rootKeyBox:l.asOptional(F),syncKeyBox:l.asOptional(F)}),Ja=l.uncleaner(xi);function Hc(_){const P=Math.floor(_/4294967296);return new Uint8Array([P>>24&255,P>>16&255,P>>8&255,P&255,_>>24&255,_>>16&255,_>>8&255,_&255])}function bo(_,P,W){const X=Ni(Hc(P),_),ne=X[19]&15,de=((X[ne]&127)<<24|X[ne+1]<<16|X[ne+2]<<8|X[ne+3]).toString();return(Array(W).join("0")+de).slice(-W)}function zi(_,P=Date.now()/1e3){return bo(_,P/30,6)}function Qa(_,P,W={}){const{now:X=Date.now()/1e3,spread:ne=1}=W,se=X/30;if(P===bo(_,se,6))return!0;for(let de=1;de<=ne;++de)if(P===bo(_,se-de,6)||P===bo(_,se+de,6))return!0;return!1}function wo(_){if(_.otpKey!=null)return zi(_.otpKey)}function es(_,P){const{otp:W,otpKey:X}=P;if(W!=null)return W;if(X!=null)return zi(o.base32.parse(X,{loose:!0}));if(_.otpKey!=null)return zi(_.otpKey)}async function Jf(_,P,W){const{loginTree:X}=_.props.state.accounts[P],{otpKey:ne=_.props.io.random(10)}=X,se={serverPath:"/v2/login/otp",server:rt({otpKey:ne,otpTimeout:W}),stash:{otpKey:ne,otpResetDate:void 0,otpTimeout:W},login:{otpKey:ne,otpResetDate:void 0,otpTimeout:W},loginId:X.loginId};await nn(_,X,se)}async function Qf(_,P){const{loginTree:W}=_.props.state.accounts[P],X={serverMethod:"DELETE",serverPath:"/v2/login/otp",stash:{otpKey:void 0,otpResetDate:void 0,otpTimeout:void 0},login:{otpKey:void 0,otpResetDate:void 0,otpTimeout:void 0},loginId:W.loginId};await nn(_,W,X)}async function eu(_,P){const{loginTree:W}=_.props.state.accounts[P],{otpTimeout:X,otpKey:ne}=W;if(X==null||ne==null)throw new Error("Cannot cancel 2FA reset: 2FA is not enabled.");const se={serverPath:"/v2/login/otp",server:rt({otpTimeout:X,otpKey:ne}),stash:{otpResetDate:void 0},login:{otpResetDate:void 0},loginId:W.loginId};await nn(_,W,se)}async function tu(_,P,W){const X={userId:await Hi(_,P),otpResetAuth:W},ne=await en(_,"DELETE","/v2/login/otp",X),{otpResetDate:se}=je(ne);return se}async function Ki(_,P,W){if(_.props.state.accounts[P]==null)return;const{login:X}=_.props.state.accounts[P],{userId:ne,passwordAuth:se}=X,{stashTree:de,stash:Be}=En(_,X.loginId);if(se==null||ne==null)throw new Error("Cannot repair OTP: There is no password on this account");const Ae={userId:ne,passwordAuth:se,otp:zi(W)},Ue={now:de.lastLogin};await Wi(_,de,Be,Ue,Ae,async()=>X.loginKey)}function Sn(_,P){if(P(_))return _;const W=_;if(W.children!=null)for(const X of W.children){const ne=Sn(X,P);if(ne!=null)return ne}}function Mi(_,P,W,X){if(P(_))return W(_);const ne=_.children!=null?_.children.map(se=>Mi(se,P,W,X)):[];return X(_,ne)}function xo(_,P,W){const{children:X=[]}=_,{appId:ne,created:se,loginId:de,loginAuthBox:Be,userId:Ae,otpKey:Ue,otpResetDate:$e,otpTimeout:nt,pendingVouchers:Ye,parentBox:vt,passwordAuthBox:Et,passwordAuthSnrp:mt,passwordBox:Mt,passwordKeySnrp:Ot,pin2TextBox:Vt,children:Zt=[],keyBoxes:ir=[],mnemonicBox:vr,rootKeyBox:br,syncKeyBox:Pr,syncToken:kr}=W,Ar={appId:ne,created:se,loginId:de,loginAuthBox:Be,userId:Ae,otpKey:Ue===!0?_.otpKey:Ue,otpResetDate:$e,otpTimeout:nt,pendingVouchers:Ye,parentBox:vt,passwordAuthBox:Et,passwordAuthSnrp:mt,passwordBox:Mt===!0?_.passwordBox:Mt,passwordKeySnrp:Ot,pin2TextBox:Vt,keyBoxes:ir,mnemonicBox:vr,rootKeyBox:br,syncKeyBox:Pr,syncToken:kr};_.lastLogin!=null&&(Ar.lastLogin=_.lastLogin),_.username!=null&&(Ar.username=_.username),_.userId!=null&&Ar.userId==null&&(Ar.userId=_.userId),W.pin2KeyBox!=null&&(Ar.pin2Key=Qr(W.pin2KeyBox,P)),W.recovery2KeyBox!=null&&(Ar.recovery2Key=Qr(W.recovery2KeyBox,P)),Zt.sort((_r,Lr)=>_r.created.valueOf()-Lr.created.valueOf()),Ar.children=Zt.map(_r=>{const{appId:Lr,loginId:Vr,parentBox:on}=_r;if(on==null)throw new Error("Key integrity violation: No parentBox on child login.");const kn=Qr(on,P),mn=X.find(jr=>Cr(jr.loginId,Vr)),Ln=mn!=null?mn:{appId:Lr,loginId:Vr,pendingVouchers:[]};return xo(Ln,kn,_r)});for(const{loginId:_r}of X)if(Zt.find(Vr=>Cr(Vr.loginId,_r))==null)throw new Error("The server has lost children!");return Ar}function Ei(_,P,W){return Mi(_,X=>X.appId===W.appId,X=>xo(X,P,W),(X,ne)=>({...X,children:ne}))}function ts(_,P){const{appId:W,created:X,lastLogin:ne=new Date,loginId:se,otpKey:de,otpResetDate:Be,otpTimeout:Ae,pendingVouchers:Ue,userId:$e,username:nt,children:Ye=[],keyBoxes:vt=[]}=_,Et={appId:W,created:X,isRoot:_.parentBox==null,lastLogin:ne,loginId:se,loginKey:P,otpKey:de,otpResetDate:Be,otpTimeout:Ae,pendingVouchers:Ue,userId:$e,username:nt,children:[],keyInfos:[]};if(_.loginAuthBox!=null&&(Et.loginAuth=Qr(_.loginAuthBox,P)),_.passwordAuthBox!=null&&(Et.userId==null&&(Et.userId=se),Et.passwordAuth=Qr(_.passwordAuthBox,P)),Et.loginAuth==null&&Et.passwordAuth==null)throw new Error("No server authentication methods on login");Et.pin2Key=_.pin2Key,_.pin2TextBox!=null&&(Et.pin=bn(_.pin2TextBox,P)),Et.recovery2Key=_.recovery2Key;const mt=[],{mnemonicBox:Mt,rootKeyBox:Ot}=_;if(Mt!=null&&Ot!=null){const Zt=Qr(Ot,P),ir=fn(Zt,bt.parse("infoKey")),vr={mnemonic:bn(Mt,ir),rootKey:o.base64.stringify(Zt)};mt.push(Ui("wallet:bitid",vr,Zt))}if(_.syncKeyBox!=null){const Zt=Qr(_.syncKeyBox,P),ir=vo(Et.appId),vr=vi({dataKey:P,syncKey:Zt});mt.push(Ui(ir,vr,P))}const Vt=vt.map(Zt=>Ga(JSON.parse(bn(Zt,P))));return Et.keyInfos=Yo([...mt,...Vt]).map(Zt=>Va(Zt)),Et.children=Ye.map(Zt=>{if(Zt.parentBox==null)throw new Error("Key integrity violation: No parentBox on child login.");const ir=Qr(Zt.parentBox,P);return ts(Zt,ir)}),Et}function ji(_,P,W=""){return Mi(_,X=>X.appId===W,X=>ts(X,P),(X,ne)=>{const{appId:se,lastLogin:de=new Date,loginId:Be,pendingVouchers:Ae,username:Ue}=X;return{appId:se,children:ne,isRoot:X.parentBox==null,keyInfos:[],lastLogin:de,loginId:Be,loginKey:void 0,pendingVouchers:Ae,username:Ue}})}function ei(_,P){return Mi(_,W=>W.appId===P,W=>W,(W,X)=>{const{appId:ne,loginId:se,username:de}=W;return{appId:ne,children:X,loginId:se,pendingVouchers:[],username:de}})}async function Wi(_,P,W,X,ne,se){const{now:de=new Date}=X,{deviceDescription:Be}=_.props.state.login,Ae={challengeId:X.challengeId,otp:es(W,X),voucherId:W.voucherId,voucherAuth:W.voucherAuth,...ne};Be!=null&&(Ae.deviceDescription=Be);let Ue=kt(await en(_,"POST","/v2/login",Ae).catch(nt=>{const Ye=di(nt);throw Ye!=null&&(W.loginId.length===0&&Ye.loginId!=null||Ye.voucherId!=null&&Ye.voucherAuth!=null)&&(Ye.loginId!=null&&(W.loginId=o.base64.parse(Ye.loginId)),Ye.voucherAuth!=null&&(W.voucherId=Ye.voucherId,W.voucherAuth=o.base64.parse(Ye.voucherAuth)),P.lastLogin=de,Nn(_,P).catch(()=>{})),nt}));const $e=await se(Ue);if(P=Ei(P,$e,Ue),P.lastLogin=de,await Nn(_,P),Ue.loginAuthBox==null){const{loginId:nt}=Ue,{stash:Ye,stashTree:vt}=En(_,nt),Et=$o(_,{loginId:nt,loginKey:$e}),mt={...ne,otp:es(Ye,X),data:Et.server};Ue=kt(await en(_,"POST",Et.serverPath,mt)),await Nn(_,Ei(vt,$e,Ue))}return ji(P,$e,W.appId)}async function nn(_,P,W){const{loginId:X,serverMethod:ne="POST",serverPath:se}=W,de=Sn(P,nt=>Cr(nt.loginId,X));if(de==null)throw new Error("Cannot apply kit: missing login");const{stashTree:Be}=En(_,X),Ae=Si(Be,de);Ae.data=W.server,await en(_,ne,se,Ae);const Ue=Mi(P,nt=>Cr(nt.loginId,X),nt=>({...nt,...W.login,children:Jn(nt.children,W.login.children),keyInfos:Yo(Jn(nt.keyInfos,W.login.keyInfos))}),(nt,Ye)=>({...nt,children:Ye})),$e=Mi(Be,nt=>Cr(nt.loginId,X),nt=>({...nt,...W.stash,children:Jn(nt.children,W.stash.children),keyBoxes:Jn(nt.keyBoxes,W.stash.keyBoxes)}),(nt,Ye)=>({...nt,children:Ye}));return await Nn(_,$e),Ue}async function Jo(_,P,W){for(const X of W)X!=null&&await nn(_,P,X)}async function pn(_,P,W){const{stashTree:X,stash:ne}=En(_,W.loginId),{syncToken:se}=ne;if(se!=null)try{const Ae=await en(_,"POST","/v2/sync",{loginId:ne.loginId,syncToken:se});if(l.asBoolean(Ae))return P}catch{}const de=Si(X,W),Be={now:X.lastLogin};return await Wi(_,X,ne,Be,de,async()=>W.loginKey)}function Si(_,P){const W=Sn(_,$e=>$e.appId===P.appId),{syncToken:X,voucherAuth:ne,voucherId:se}=W!=null?W:{syncToken:void 0,voucherAuth:void 0,voucherId:void 0},{loginId:de,userId:Be,loginAuth:Ae,passwordAuth:Ue}=P;if(Ae!=null)return{loginId:de,loginAuth:Ae,otp:wo(P),syncToken:X,voucherAuth:ne,voucherId:se};if(Ue!=null&&Be!=null)return{userId:Be,passwordAuth:Ue,otp:wo(P),syncToken:X,voucherAuth:ne,voucherId:se};throw new Error("No server authentication methods available")}const Qo="client.json",rs=Fr(l.asObject({clientId:D})),ns="infoCache.json",is=l.asObject({corePlugins:l.asObject(Cn),syncServers:l.asArray(l.asString)}),ea=Fr(is);async function ru(_,P){const W=[],X=await _.disklet.list("Accounts").then(p.justFolders);for(const ne of X){const se=p.navigateDisklet(_.disklet,ne),[de,Be,Ae,Ue,$e,nt]=await Promise.all([await as.load(se,"CarePackage.json"),await nu.load(se,"LoginPackage.json"),await iu.load(se,"OtpKey.json"),await ss.load(se,"Pin2Key.json"),await fs.load(se,"Recovery2Key.json"),await ou.load(se,"UserName.json")]);if(nt==null)continue;const Ye=s(nt.userName);if(P.has(Ye))continue;const Et={appId:"",loginId:await _.scrypt(bt.parse(Ye),Qn.salt_hex,Qn.n,Qn.r,Qn.p,32),pendingVouchers:[],username:Ye};de!=null&&Be!=null&&(Et.passwordKeySnrp=de.SNRP2,Et.passwordBox=Be.EMK_LP2,Et.syncKeyBox=Be.ESyncKey,Et.passwordAuthBox=Be.ELP1),Ae!=null&&(Et.otpKey=Ae.TOTP),Ue!=null&&(Et.pin2Key=Ue.pin2Key),$e!=null&&(Et.recovery2Key=$e.recovery2Key),W.push(Et)}return W}const os=l.asCodec(_=>gt.parse(l.asString(_)),_=>gt.stringify(_)),as=Fr(l.asObject({SNRP2:V,SNRP3:l.asOptional(V),SNRP4:l.asOptional(V),ERQ:l.asOptional(F)})),nu=Fr(l.asObject({EMK_LP2:F,EMK_LRA3:l.asOptional(F),ESyncKey:F,ELP1:F})),iu=Fr(l.asObject({TOTP:w})),ss=Fr(l.asObject({pin2Key:os})),fs=Fr(l.asObject({recovery2Key:os})),ou=Fr(l.asObject({userName:l.asString})),us={};let ta=!1;const ra=[],ls=[];function au(_){if(ta)throw new Error("The Edge core plugin list has already been locked");for(const P of Object.keys(_))us[P]=_[P];for(const P of ra)P(_)}function cs(){ta=!0;for(const _ of ls)_()}function su(_,P,W,X,ne){const{io:se,nativeIo:de}=_,Be={...se,console};function Ae($e){var Ye,vt;const nt={};for(const Et of Object.keys($e)){const mt=$e[Et],Mt=co(W,Et),Ot=X[Et];if(!(Ot===!1||Ot==null))try{if(typeof mt=="function"){const Vt={infoPayload:(vt=(Ye=P.corePlugins)==null?void 0:Ye[Et])!=null?vt:{},initOptions:typeof Ot=="object"?Ot:{},io:Be,log:Mt,nativeIo:de,pluginDisklet:p.navigateDisklet(se.disklet,"plugins/"+Et)};nt[Et]=mt(Vt)}else if(typeof mt=="object"&&mt!=null)nt[Et]=mt;else throw new TypeError(`Plugins must be functions or objects, got ${typeof mt}`)}catch(Vt){Mt.error(Vt)}}ne({type:"CORE_PLUGINS_ADDED",payload:nt})}function Ue(){ne({type:"CORE_PLUGINS_LOCKED",payload:X})}return Ae(us),ta&&Ue(),ra.push(Ae),ls.push(Ue),()=>{}}function ki(_,P,W={}){const{onError:X=()=>{}}=W;let ne=!1,se;function de(){se=void 0,Ae.started&&(ne=!0,new Promise(Ue=>Ue(_())).catch(X).then(Be,Be))}function Be(){ne=!1,Ae.started&&(se=setTimeout(de,P))}const Ae={started:!1,setDelay(Ue){P=Ue},start(Ue={}){const{wait:$e=!1}=Ue;Ae.started=!0,!ne&&se==null&&($e?Be():de())},stop(){Ae.started=!1,se!=null&&(clearTimeout(se),se=void 0)}};return Ae}const hs=100;function Mo(_,P){return p.navigateDisklet(_.disklet,"local/"+gt.stringify(o.base64.parse(P)))}function Eo(_,P){const{dataKey:W,syncKey:X}=P,ne=p.navigateDisklet(_.disklet,"repos/"+gt.stringify(tn(tn(X)))),se=p.navigateDisklet(ne,"changes"),de=p.navigateDisklet(ne,"data"),Be=Fa(_,W,p.mergeDisklets(se,de));return{dataKey:W,syncKey:X,baseDisklet:ne,changesDisklet:se,dataDisklet:de,disklet:Be}}function fu(_){const P={lastSync:0,lastHash:void 0};return _.baseDisklet.getText("status.json").then(W=>({lastSync:0,...JSON.parse(W)})).catch(()=>P)}async function ds(_,P){await Promise.all(Object.keys(P).map(W=>{const X=P[W];return X!=null?_.setText(W,JSON.stringify(De(X))):_.delete(W)}))}async function na(_,P,W){var nt;const{changesDisklet:X,dataDisklet:ne,syncKey:se}=P,de=await ps(X).then(Ye=>Promise.all(Ye.map(async vt=>({path:vt,box:F(JSON.parse(await X.getText(vt)))})))),Be=o.base16.stringify(se).toLowerCase(),Ae=await(()=>{if(de.length===0)return _.readRepo(Be,W.lastHash);const Ye={};for(const vt of de)Ye[vt.path]=De(vt.box);return _.updateRepo(Be,W.lastHash,{changes:Ye})})(),{hash:Ue}=Ae,$e={};for(const Ye of Object.keys((nt=Ae.changes)!=null?nt:{})){const vt=Ae.changes[Ye];$e[Ye]=vt==null?null:F(vt)}return await ds(ne,$e),await Promise.all(de.map(Ye=>X.delete(Ye.path))),W.lastSync=Date.now()/1e3,Ue!=null&&(W.lastHash=Ue),await P.baseDisklet.setText("status.json",JSON.stringify(W)),{status:W,changes:$e}}async function ps(_,P="",W=hs){const X=await _.list(P),ne=Object.keys(X).filter(de=>X[de]==="file"),se=Object.keys(X).filter(de=>X[de]==="folder");for(const de of se){if(ne.length>=W)break;const Be=W-ne.length,Ae=await ps(_,de,Be);ne.push(...Ae.slice(0,Be))}return ne}async function vs(_,P){const{dispatch:W,io:X,onError:ne}=_.props,se=Li(P.keys),de=Eo(X,se),Be=Mo(X,P.id);y.bridgifyObject(Be);const Ae=await fu(de);W({type:"STORAGE_WALLET_ADDED",payload:{id:P.id,initialState:{localDisklet:Be,paths:de,status:Ae,lastChanges:[]}}});const Ue=Gi(_,P.id);Ae.lastSync>0?Ue.catch($e=>{const{syncKey:nt}=P.keys,{lastHash:Ye}=Ae;_.props.log.error(`Could not sync ${String(nt)} with last hash ${String(Ye)}: ${String($e)}`),ne($e)}):await Ue}function Gi(_,P){const{dispatch:W,syncClient:X,state:ne}=_.props,{paths:se,status:de}=ne.storageWallets[P];return na(X,se,{...de}).then(({changes:Be,status:Ae})=>(W({type:"STORAGE_WALLET_SYNCED",payload:{id:P,changes:Object.keys(Be),status:Ae}}),Object.keys(Be)))}const ia=Fr(Hf),uu=Fr(Uf),So="CustomTokens.json",lu="Settings.json",ms=l.asMaybe(l.asObject({contractAddress:l.asString}));async function gs(_,P,W){const X=await Fn(_,P);if(X.getTokenId!=null)return await X.getTokenId(W);const ne=du(_,P);if(ne==null)throw new Error("A wallet must exist before adding tokens to a legacy currency plugin");if(ne.addCustomToken==null)throw new Error(`${P} doesn't support tokens`);const se=aa(W);if(se==null)throw new Error("A token must have a contract address to be added to a legacy currency plugin");return await ne.addCustomToken({...se,...W}),oa(se.contractAddress)}function oa(_){return _.toLowerCase().replace(/^0x/,"")}function ys(_){const P={};for(const W of _){const{contractAddress:X}=W;X!=null&&(P[oa(X)]={currencyCode:W.currencyCode,denominations:W.denominations,displayName:W.currencyName,networkLocation:{contractAddress:W.contractAddress}})}return P}function cu(_){const{currencyCode:P,displayName:W,denominations:X,networkLocation:ne}=_,se=ms(ne);return{currencyCode:P,currencyName:W,denominations:X,contractAddress:se==null?void 0:se.contractAddress}}function bs(_={}){const P=[];for(const W of Object.keys(_))P.push(cu(_[W]));return P}function aa(_){const{currencyCode:P,displayName:W,denominations:X,networkLocation:ne}=_,se=ms(ne);if(se!=null)return{currencyCode:P,currencyName:W,multiplier:X[0].multiplier,contractAddress:se.contractAddress}}async function hu(_,P){const{dispatch:W,state:X}=_.props;await Promise.all(Object.keys(X.plugins.currency).map(async ne=>{var Be;const se=X.plugins.currency[ne],de=se.getBuiltinTokens==null?ys((Be=se.currencyInfo.metaTokens)!=null?Be:[]):await se.getBuiltinTokens();W({type:"ACCOUNT_BUILTIN_TOKENS_LOADED",payload:{accountId:P,pluginId:ne,tokens:de}})}))}function du(_,P){for(const W of Object.keys(_.props.state.currency.wallets)){const X=_.props.output.currency.wallets[W];if((X==null?void 0:X.engine)!=null&&_.props.state.currency.wallets[W].pluginId===P)return X.engine}}async function ws(_,P){const{state:W}=_.props,{accountWalletInfo:X}=W.accounts[P],ne=Kr(W,X.id),se=await uu.load(ne,lu);if(se==null)return{};const de={};for(const Be of se.customTokens){if(!Be.isVisible)continue;const Ae=po(W.plugins.currency,Be.walletType);if(Ae==null)continue;de[Ae]==null&&(de[Ae]={});const Ue=oa(Be.contractAddress);de[Ae][Ue]={currencyCode:Be.currencyCode,denominations:Be.denominations,displayName:Be.currencyName,networkLocation:{contractAddress:Be.contractAddress}}}return de}async function pu(_,P){const{dispatch:W,state:X}=_.props,{accountWalletInfo:ne}=X.accounts[P],se=Kr(X,ne.id),de=await ia.load(se,So);if(de!=null){const{customTokens:Be}=de;W({type:"ACCOUNT_CUSTOM_TOKENS_LOADED",payload:{accountId:P,customTokens:Be}})}else{const Be=await ws(_,P);W({type:"ACCOUNT_CUSTOM_TOKENS_LOADED",payload:{accountId:P,customTokens:Be}})}}async function vu(_,P){const{state:W}=_.props,{accountWalletInfo:X}=W.accounts[P],ne=Kr(W,X.id),{customTokens:se}=_.props.state.accounts[P],de=await ia.load(ne,So);await ia.save(ne,So,{...de,customTokens:se})}function jn(_){const{currencyInfo:P,allTokens:W}=_;let X=_.tokenId;X===void 0&&_.currencyCode!=null&&_.currencyCode!==P.currencyCode&&(X=Object.keys(W).find(se=>W[se].currencyCode===_.currencyCode));const{currencyCode:ne}=X==null?P:W[X];return{currencyCode:ne,tokenId:X!=null?X:null}}function xs(_,P){const{id:W,type:X,keys:ne}=P;return{id:W,type:X,keys:ne,get disklet(){return Kr(_.props.state,W)},get localDisklet(){return ho(_.props.state,W)},async sync(){await Gi(_,W)}}}const mu={"[object Float32Array]":!0,"[object Float64Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Int8Array]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0};function gu(_,P,W){if(W==="[object Object]"){if(Object.getPrototypeOf(_)!==Object.getPrototypeOf(P))return!1;const ne=Object.getOwnPropertyNames(_);if(ne.length!==Object.getOwnPropertyNames(P).length)return!1;for(const se of ne)if(!Object.prototype.hasOwnProperty.call(P,se)||!Vi(_[se],P[se]))return!1;return!0}if(W==="[object Array]"){if(_.length!==P.length)return!1;for(let X=0;X<_.length;++X)if(!Vi(_[X],P[X]))return!1;return!0}if(W==="[object Date]")return _.getTime()===P.getTime();if(W==="[object Map]")return Ms(_,P);if(mu[W]){if(_.length!==P.length)return!1;for(let X=0;X<_.length;++X)if(_[X]!==P[X])return!1;return!0}return!1}function Ms(_,P){if(_.size!==P.size)return!1;for(const[W,X]of _)if(!P.has(W)||P.get(W)!==X)return!1;return!0}function Vi(_,P){if(_===P)return!0;if(typeof _!="object"||typeof P!="object")return!1;const W=Object.prototype.toString.call(_);return W!==Object.prototype.toString.call(P)?!1:gu(_,P,W)}let Es=500,sa=3;const _i=[];function yu(){sa=99,Es=1}function ti(_){_i.length<=0&&Ss();let P=!1;for(const W of _i)if(W.id===_.id&&W.action===_.action){W.updateFunc=_.updateFunc,P=!0;break}P||_i.push(_)}function Ss(){setTimeout(()=>{const _=Math.min(sa,_i.length);for(let P=0;P<_;P++){const W=_i.shift();W!=null&&W.updateFunc()}_i.length>0&&Ss()},Es)}function zc(_){const P=l.asObject(_);return l.asCodec(W=>{const X=P(W),ne=new Map;for(const se of Object.keys(X))ne.set(se,X[se]);return ne},W=>{const X={};return W.forEach((ne,se)=>{X[se]=ne}),P(X)})}function bu(_){const P=l.asObject(_);return l.asCodec(W=>{const X=P(W),ne=new Map;for(const se of Object.keys(X))ne.set(se===""?null:se,X[se]);return ne},W=>{const X={};return W.forEach((ne,se)=>{X[se==null?"":se]=ne}),P(X)})}const wu=_=>{const P=xu(_),{exchangeAmount:W={}}=P;for(const X of Object.keys(W))String(W[X]).includes("e")&&delete W[X];return P};function ks(_,P){var de,Be,Ae,Ue,$e,nt;const W={exchangeAmount:{}},{exchangeAmount:X={}}=W,ne=(de=_.exchangeAmount)!=null?de:{},se=(Be=P.exchangeAmount)!=null?Be:{};for(const Ye of Object.keys(ne))se[Ye]!==null&&(X[Ye]=ne[Ye]);for(const Ye of Object.keys(se)){const vt=se[Ye];vt!=null&&(X[Ye]=vt)}return P.bizId!==null&&(W.bizId=(Ae=P.bizId)!=null?Ae:_.bizId),P.category!==null&&(W.category=(Ue=P.category)!=null?Ue:_.category),P.name!==null&&(W.name=($e=P.name)!=null?$e:_.name),P.notes!==null&&(W.notes=(nt=P.notes)!=null?nt:_.notes),W}const xu=l.asObject({bizId:l.asOptional(l.asNumber),category:l.asOptional(l.asString),exchangeAmount:l.asOptional(l.asObject(l.asNumber)),name:l.asOptional(l.asString),notes:l.asOptional(l.asString)}),_s=l.asValue("high","standard","low"),Is=l.asObject({orderId:l.asOptional(l.asString),orderUri:l.asOptional(l.asString),isEstimate:l.asBoolean,plugin:l.asObject({pluginId:l.asString,displayName:l.asString,supportEmail:l.asOptional(l.asString)}),payoutAddress:l.asString,payoutCurrencyCode:l.asString,payoutNativeAmount:l.asString,payoutWalletId:l.asString,refundAddress:l.asOptional(l.asString)});function fa(_){const P=l.asString(_);if(!/^\d+$/.test(P))throw new Error("Expected an integer string");return P}const As=l.asEither(l.asString,l.asNull),qi=l.asObject({pluginId:l.asString,tokenId:As,nativeAmount:l.asOptional(fa)}),Mu=l.asObject({fiatCurrencyCode:l.asString,fiatAmount:l.asString}),Ts=l.asObject({pluginId:l.asString,displayName:l.asString,isDex:l.asOptional(l.asBoolean),orderUri:l.asOptional(l.asString),supportEmail:l.asString}),Eu=l.asObject({actionType:l.asValue("swap"),swapInfo:Ts,orderId:l.asOptional(l.asString),orderUri:l.asOptional(l.asString),isEstimate:l.asOptional(l.asBoolean),canBePartial:l.asOptional(l.asBoolean),fromAsset:qi,toAsset:qi,payoutWalletId:l.asString,payoutAddress:l.asString,refundAddress:l.asOptional(l.asString)}),Kc=l.asObject({actionType:l.asValue("stake"),pluginId:l.asString,stakeAssets:l.asArray(qi)}),Su=l.asObject({actionType:l.asValue("fiat"),orderId:l.asString,orderUri:l.asOptional(l.asString),isEstimate:l.asBoolean,fiatPlugin:l.asObject({providerId:l.asString,providerDisplayName:l.asString,supportEmail:l.asOptional(l.asString)}),payinAddress:l.asOptional(l.asString),payoutAddress:l.asOptional(l.asString),fiatAsset:Mu,cryptoAsset:qi}),Ps=l.asObject({actionType:l.asValue("tokenApproval"),tokenApproved:qi,tokenContractAddress:l.asString,contractAddress:l.asString}),ua=l.asEither(Eu,Kc,Su,Ps),ku=l.asValue("claim","claimOrder","stake","stakeNetworkFee","stakeOrder","unstake","unstakeNetworkFee","unstakeOrder","swap","swapNetworkFee","swapOrderPost","swapOrderFill","swapOrderCancel","buy","sell","sellNetworkFee","tokenApproval","transfer","transferNetworkFee"),Os=l.asObject({assetActionType:ku}),_u=l.asArray(l.asString),Iu=l.asObject({enabledTokenIds:l.asArray(l.asString),detectedTokenIds:l.asArray(l.asString)}),la=l.asObject({assetAction:l.asOptional(Os),metadata:wu,nativeAmount:l.asOptional(l.asString),providerFeeSent:l.asOptional(l.asString)}),Au=l.asObject({txid:l.asString,internal:l.asBoolean,creationDate:l.asNumber,currencies:zc(la),tokens:l.asOptional(bu(la),()=>new Map),deviceDescription:l.asOptional(l.asString),feeRateRequested:l.asOptional(l.asEither(_s,Cn)),feeRateUsed:l.asOptional(Cn),payees:l.asOptional(l.asArray(l.asObject({address:l.asString,amount:l.asString,currency:l.asString,tag:l.asOptional(l.asString)}))),savedAction:l.asOptional(ua),secret:l.asOptional(l.asString),swap:l.asOptional(Is)}),Tu=l.asObject({airbitzFeeWanted:l.asNumber,meta:l.asObject({amountFeeAirBitzSatoshi:l.asNumber,balance:l.asNumber,fee:l.asNumber,amountCurrency:l.asNumber,bizId:l.asNumber,category:l.asString,name:l.asString,notes:l.asString,attributes:l.asNumber,amountSatoshi:l.asNumber,amountFeeMinersSatoshi:l.asNumber,airbitzFee:l.asNumber}),ntxid:l.asString,state:l.asObject({creationDate:l.asNumber,internal:l.asBoolean,malleableTxId:l.asString})}),Bs=l.asObject({seq:l.asNumber,address:l.asString,state:l.asObject({recycleable:l.asOptional(l.asBoolean,!0),creationDate:l.asOptional(l.asNumber,0)}),meta:l.asObject({amountSatoshi:l.asOptional(l.asNumber,0)}).withRest}),Pu=l.asObject(l.asObject({timestamp:l.asNumber,txidHash:l.asString})),Ou=l.asObject({walletInfo:l.asObject({id:l.asString,keys:Cn,type:l.asString})}),Rs=l.asObject({fiat:l.asOptional(l.asString),num:l.asOptional(l.asNumber)}),Bu=l.asObject({walletName:l.asEither(l.asString,l.asNull)}),ko=Qn;function _o(_,P){return _+P}async function Ru(_,P,W,X){const{now:ne=new Date}=X,{passwordBox:se,passwordKeySnrp:de,username:Be}=P;if(se==null||de==null||Be==null)throw new Error("Missing data for offline password login");const Ae=_o(Be,W),Ue=await wi(_,Ae,de),$e=Qr(se,Ue),nt=ji(P,$e);P.lastLogin=ne,Nn(_,P).catch(()=>{});const{log:Ye}=_.props;return pn(_,nt,nt).catch(vt=>Ye.error(vt)),nt}async function Cu(_,P,W,X){const{username:ne}=P;if(ne==null)throw new Error("Password login requires a username");const se=_o(ne,W),[de,Be]=await Promise.all([Hi(_,ne),wi(_,se,ko)]);return await Wi(_,P,P,X,{userId:de,passwordAuth:Be},async Ue=>{const{passwordBox:$e,passwordKeySnrp:nt}=Ue;if($e==null||$e===!0||nt==null)throw new Error("Missing data for online password login");const Ye=await wi(_,se,nt);return Qr($e,Ye)})}async function Fu(_,P,W,X){return await Ru(_,P,W,X).catch(()=>Cu(_,P,W,X))}async function Cs(_,P,W){const X=_.props.state.accounts[P],{loginTree:ne}=X,{username:se}=X.stashTree;if(se==null)throw new Error("Password login requires a username");const de=await Io(_,ne,se,W);await nn(_,ne,de)}async function Nu(_,P,W){const{username:X,passwordAuth:ne}=P;if(X==null||ne==null)return!1;const se=_o(X,W),de=await wi(_,se,ko);for(let Be=0;Be<ne.length;++Be)if(de[Be]!==ne[Be])return!1;return!0}async function Lu(_,P){const{loginTree:W}=_.props.state.accounts[P],X={serverMethod:"DELETE",serverPath:"/v2/login/password",stash:{passwordAuthSnrp:void 0,passwordBox:void 0,passwordKeySnrp:void 0},login:{passwordAuth:void 0},loginId:W.loginId};W.loginAuth!=null&&(X.stash.passwordAuthBox=void 0,X.login.passwordAuth=void 0),await nn(_,W,X)}function Io(_,P,W,X){const ne=_o(W,X),{io:se}=_.props,de=Zf(_).then(Ae=>wi(_,ne,Ae).then(Ue=>{const $e=rn(se,P.loginKey,Ue);return{passwordKeySnrp:Ae,passwordBox:$e}})),Be=wi(_,ne,ko).then(Ae=>{const Ue=rn(se,Ae,P.loginKey);return{passwordAuth:Ae,passwordAuthBox:Ue}});return Promise.all([de,Be]).then(Ae=>{const[{passwordKeySnrp:Ue,passwordBox:$e},{passwordAuth:nt,passwordAuthBox:Ye}]=Ae;return{serverPath:"/v2/login/password",server:Fe({passwordAuth:nt,passwordAuthSnrp:ko,passwordKeySnrp:Ue,passwordBox:$e,passwordAuthBox:Ye}),stash:{passwordKeySnrp:Ue,passwordBox:$e,passwordAuthBox:Ye},login:{passwordAuth:nt},loginId:P.loginId}})}function Ao(_,P){const W=P==null?Uint8Array.from([0]):bt.parse(P);return fn(W,_)}function ca(_,P){return fn(bt.parse(P),_)}function To(_,P){if(_.pin2Key!=null)return _;const W=Sn(_,X=>X.appId===P);if((W==null?void 0:W.pin2Key)!=null)return W}async function Du(_,P,W,X,ne){const se=To(W,P);if(se==null||se.pin2Key==null)throw new Error("PIN login is not enabled for this account on this device");const{pin2Key:de}=se,Be={pin2Id:Ao(de,W.username),pin2Auth:ca(de,X)};return await Wi(_,W,se,ne,Be,async Ae=>{if(Ae.pin2Box==null||Ae.pin2Box===!0)throw new Error("Missing data for PIN v2 login");return Qr(Ae.pin2Box,de)})}async function jc(_,P,W){const X=_.props.state.accounts[P],{loginTree:ne}=X,{username:se}=X.stashTree;let{pin:de,enableLogin:Be}=W;if(Be==null&&(Be=ne.pin2Key!=null||de!=null&&ne.pin==null),de==null&&(de=ne.pin),de==null){if(Be)throw new Error("Please change your PIN in the settings area above before enabling.");await Jo(_,ne,da(ne));return}const Ae=Fs(_,ne,se,de,Be);await Jo(_,ne,Ae)}async function Uu(_,P,W){const{appId:X,loginId:ne,username:se}=P;if(se==null)return!1;const{stashTree:de}=En(_,ne),Be=To(de,X);if(Be==null||Be.pin2Key==null)throw new Error("No PIN set locally for this account");const{pin2Key:Ae}=Be,Ue={pin2Id:Ao(Ae,se),pin2Auth:ca(Ae,W),otp:wo(P)};return await en(_,"POST","/v2/login",Ue).then($e=>!0,$e=>!1)}async function Hu(_,P){const{loginTree:W}=_.props.state.accounts[P],X=da(W);await Jo(_,W,X)}function Fs(_,P,W,X,ne){const se=[ha(_,P,W,X,ne)];for(const de of P.children)se.push(...Fs(_,de,W,X,ne));return se}function zu(_,P){const{loginId:W,pin2Key:X}=_;if(X!=null)return{login:{},loginId:W,server:He({pin2Id:Ao(X,P)}),serverPath:"",stash:{}}}function ha(_,P,W,X,ne){const{io:se}=_.props,de=rn(se,bt.parse(X),P.loginKey);if(ne){const{loginId:Be,loginKey:Ae,pin2Key:Ue=se.random(32)}=P,$e=rn(se,Ae,Ue),nt=rn(se,Ue,Ae);return{serverPath:"/v2/login/pin2",server:yt({pin2Id:Ao(Ue,W),pin2Auth:ca(Ue,X),pin2Box:$e,pin2KeyBox:nt,pin2TextBox:de}),stash:{pin2Key:Ue,pin2TextBox:de},login:{pin2Key:Ue,pin:X},loginId:Be}}else return{serverPath:"/v2/login/pin2",server:yt({pin2Id:void 0,pin2Auth:void 0,pin2Box:void 0,pin2KeyBox:void 0,pin2TextBox:de}),stash:{pin2Key:void 0,pin2TextBox:de},login:{pin2Key:void 0,pin:X},loginId:P.loginId}}function da(_){const P=[Ku(_)];for(const W of _.children)P.push(...da(W));return P}function Ku(_){return{serverMethod:"DELETE",serverPath:"/v2/login/pin2",server:void 0,stash:{pin2Key:void 0},login:{pin2Key:void 0},loginId:_.loginId}}function Xi(_,P){return fn(bt.parse(P),_)}function Ns(_,P){return P.map(W=>fn(bt.parse(W),_))}async function ju(_,P,W,X,ne){const{username:se}=P;if(se==null)throw new Error("Recovery login requires a username");const de={recovery2Id:Xi(W,se),recovery2Auth:Ns(W,X)};return await Wi(_,P,P,ne,de,async Be=>{if(Be.recovery2Box==null||Be.recovery2Box===!0)throw new Error("Missing data for recovery v2 login");return Qr(Be.recovery2Box,W)})}async function Ls(_,P,W){const X={recovery2Id:Xi(P,W)},ne=await en(_,"POST","/v2/login",X),{question2Box:se}=Ce(ne);if(se==null)throw new Error("Login has no recovery questions");return Ds(JSON.parse(bn(se,P)))}async function Wu(_,P,W,X){const ne=_.props.state.accounts[P],{loginTree:se}=ne,{username:de}=ne.stashTree;if(de==null)throw new Error("Recovery login requires a username");const Be=Vu(_,se,de,W,X);await nn(_,se,Be)}async function Wc(_,P){const{loginTree:W}=_.props.state.accounts[P],X={serverMethod:"DELETE",serverPath:"/v2/login/recovery2",stash:{recovery2Key:void 0},login:{recovery2Key:void 0},loginId:W.loginId};await nn(_,W,X)}function Gu(_,P){const{loginId:W,recovery2Key:X}=_;if(X!=null)return{login:{},loginId:W,server:Ke({recovery2Id:Xi(X,P)}),serverPath:"",stash:{}}}function Vu(_,P,W,X,ne){const{io:se}=_.props;if(!Array.isArray(X))throw new TypeError("Questions must be an array of strings");if(!Array.isArray(ne))throw new TypeError("Answers must be an array of strings");const{loginId:de,loginKey:Be,recovery2Key:Ae=se.random(32)}=P,Ue=rn(se,bt.parse(JSON.stringify(qu(X))),Ae),$e=rn(se,Be,Ae),nt=rn(se,Ae,Be);return{serverPath:"/v2/login/recovery2",server:Ze({recovery2Id:Xi(Ae,W),recovery2Auth:Ns(Ae,ne),recovery2Box:$e,recovery2KeyBox:nt,question2Box:Ue}),stash:{recovery2Key:Ae},login:{recovery2Key:Ae},loginId:de}}const Ds=l.asArray(l.asString),qu=l.uncleaner(Ds);async function Us(_,P,W){const{loginTree:X}=_.props.state.accounts[P];function ne(de){const Be=[Xu(_,de,W)];for(const Ae of de.children)Be.push(...ne(Ae));return Be}const se=await Promise.all(ne(X));await Jo(_,X,se)}async function Xu(_,P,W){const{password:X,username:ne}=W,{isRoot:se,loginId:de,passwordAuth:Be}=P;if(Be!=null&&X==null)throw new Error("A password is required to change the username");const Ae=zu(P,ne),Ue=Gu(P,ne);let $e,nt;if(X!=null&&($e=await Io(_,P,ne,X)),se&&(nt=await Hs(_,P,ne)),!($e==null&&Ae==null&&Ue==null&&nt==null))return{login:{...$e==null?void 0:$e.login,...Ae==null?void 0:Ae.login,...Ue==null?void 0:Ue.login,...nt==null?void 0:nt.login},loginId:de,server:{...$e==null?void 0:$e.server,...Ae==null?void 0:Ae.server,...Ue==null?void 0:Ue.server,...nt==null?void 0:nt.server},serverPath:"/v2/login/username",stash:{...$e==null?void 0:$e.stash,...Ae==null?void 0:Ae.stash,...Ue==null?void 0:Ue.stash,...nt==null?void 0:nt.stash}}}async function Hs(_,P,W){const{io:X}=_.props,{loginId:ne,loginKey:se}=P,de=await Hi(_,W);return{login:{userId:de,username:W},loginId:ne,server:Ve({userId:de,userTextBox:rn(X,bt.parse(W),se)}),serverPath:"",stash:{userId:de,username:W}}}async function zs(_,P){const X={userId:await Hi(_,P)};return await en(_,"POST","/v2/login",X).then(ne=>!1).catch(ne=>{if(In(ne)!=null)return!0;throw ne})}async function Ks(_,P,W,X){const{keyInfo:ne,password:se,pin:de,username:Be}=X,{io:Ae}=_.props,Ue=P==null,$e=Ae.random(32),nt=Ae.random(32),Ye={appId:W,lastLogin:new Date,loginId:$e,loginKey:nt,isRoot:Ue,pendingVouchers:[],children:[],keyInfos:[]},vt=$o(_,Ye);let Et,mt,Mt,Ot,Vt;return ne!=null&&(Et=bi(_,Ye,[ne])),P!=null&&(mt=rn(Ae,nt,P.loginKey)),se!=null&&Be!=null&&(Mt=await Io(_,Ye,Be,se)),de!=null&&(Ot=ha(_,Ye,Be,de,!0)),Ue&&Be!=null&&(Vt=await Hs(_,Ye,Be)),{loginId:$e,serverPath:"/v2/login/create",server:{...et({appId:W,loginId:$e,parentBox:mt}),...Et==null?void 0:Et.server,...Mt==null?void 0:Mt.server,...Ot==null?void 0:Ot.server,...vt.server,...Vt==null?void 0:Vt.server},stash:{appId:W,loginId:$e,parentBox:mt,...Et==null?void 0:Et.stash,...Mt==null?void 0:Mt.stash,...Ot==null?void 0:Ot.stash,...vt.stash,...Vt==null?void 0:Vt.stash},login:{appId:W,loginId:$e,loginKey:nt,keyInfos:[],...Et==null?void 0:Et.login,...Mt==null?void 0:Mt.login,...Ot==null?void 0:Ot.login,...vt.login,...Vt==null?void 0:Vt.login}}}async function Zu(_,P,W){const{now:X=new Date}=P,ne=await Ks(_,void 0,"",W),se={data:ne.server};return await en(_,"POST",ne.serverPath,se),ne.stash.lastLogin=X,await Nn(_,ne.stash),ne.login}function pa(_){if(_==null||_.loginKey==null)throw new Error("Incomplete login")}function Po(_,P){const W=Sn(_,X=>X.appId===P);if(W==null)throw new Error(`Internal error: cannot find login for ${P}`);return W}async function Gc(_,P,W,X){pa(W);const ne={pin:P.pin,username:P.username};ne.keyInfo=Ui(vo(X),vi(Vo(_)));const se=await Ks(_,W,X,ne),de={serverPath:se.serverPath,server:se.server,login:{children:[se.login]},stash:{children:[se.stash]},loginId:W.loginId};return await nn(_,P,de)}async function js(_,P,W){const X=vo(W),ne=Sn(P,se=>se.appId===W);if(ne==null)return await Gc(_,P,P,W);if(Vf(ne.keyInfos,X)==null){pa(ne);const se=Ui(X,vi(Vo(_))),de=bi(_,ne,[se]);return await nn(_,P,de)}return P}async function ri(_,P,W,X,ne){const{pauseWallets:se=!1}=ne,{log:de}=_.props;de.warn(`Login: decrypted keys for user ${o.base64.stringify(W.loginId)}`),W=await js(_,W,P),de.warn("Login: account exists for appId");const Be=W.loginKey!=null;return _.props.dispatch({type:"LOGIN",payload:{appId:P,hasRootKey:Be,loginKey:Be?W.loginKey:Po(W,P).loginKey,loginType:X,pauseWallets:se,rootLoginId:W.loginId}}),await Yu(_,_.props.state.lastAccountId)}function Yu(_,P){return _.waitFor(X=>{const ne=X.state.accounts[P];if(ne.loadFailure!=null)throw ne.loadFailure;const se=X.output.accounts[P];if((se==null?void 0:se.accountApi)!=null)return se.accountApi})}const $u=ee.default.ec,va=new $u("secp256k1");function Ws(_,P){const W=_.derive(va.keyFromPublic(P).getPublic()).toArray("be");return fn(Uint8Array.from([0,0,0,1,...W]),bt.parse("dataKey"))}function Gs(_,P){const{publicKey:W}=P,X=Ws(_,W);return JSON.parse(bn(P.box,X))}function Ju(_,P,W){const X=va.genKeyPair({entropy:_.random(32)}),ne=Ws(X,P);return{publicKey:Uint8Array.from(X.getPublic().encodeCompressed()),box:rn(_,bt.parse(JSON.stringify(W)),ne)}}async function Vs(_,P,W=1e3){const{io:X}=_.props,{timeout:ne=600}=P,se=va.genKeyPair({entropy:X.random(32)}),de=Uint8Array.from(se.getPublic().encodeCompressed()),Be=gt.stringify(tn(tn(de)).slice(0,10)),Ae={data:we({...P,publicKey:de,timeout:ne})};await en(_,"PUT",`/v2/lobby/${Be}`,Ae);const[Ue,$e]=U.makeEvents(),nt=[],vt=ki(async()=>{const Et=Le(await en(_,"GET","/v2/lobby/"+Be));for(;nt.length<Et.replies.length;){const mt=Et.replies[nt.length],Mt=Gs(se,mt);$e("reply",Mt),nt.push(Mt)}},W,{onError(Et){$e("error",Et)}});return vt.start({wait:!1}),{close:vt.stop,lobbyId:Be,on:Ue,replies:nt}}async function ma(_,P){const W=Le(await en(_,"GET","/v2/lobby/"+P)),{publicKey:X}=W.request,ne=tn(tn(X)),se=gt.parse(P);if(!Cr(se,ne.subarray(0,se.length)))throw new Error("Lobby ECDH integrity error");return W.request}async function qs(_,P,W,X){const{io:ne}=_.props,{publicKey:se}=W,de={data:ye(Ju(ne,se,X))};await en(_,"POST","/v2/lobby/"+P,de)}const Xs=l.asObject({appId:l.asString,loginKey:D,loginStash:xi});async function Zs(_,P,W,X){const{now:ne=new Date}=X,{loginKey:se,loginStash:de}=P,Be=Sn(de,nt=>nt.appId===W);if(Be==null)throw new Error(`Cannot find requested appId: "${W}"`);try{const nt=En(_,Be.loginId);Be.voucherId=nt.stash.voucherId,Be.voucherAuth=nt.stash.voucherAuth}catch{}de.lastLogin=ne,await Nn(_,de);const Ae=ji(de,se,W),Ue=Sn(Ae,nt=>nt.appId===W);if(Ue==null)throw new Error(`Cannot find requested appId: "${W}"`);const $e=await pn(_,Ae,Ue);return await ri(_,W,$e,"edgeLogin",X)}async function Qu(_,P,W={}){function X(Ue){for(const $e of Be)$e();Ae.state="error",Ae.error=Ue,y.update(Ae),y.close(Ae)}async function ne(Ue){for(const vt of Be)vt();const $e=Xs(Ue),{username:nt}=$e.loginStash;Ae.state="started",Ae.username=nt,y.update(Ae);const Ye=await Zs(_,$e,P,W);Ae.state="done",Ae.account=Ye,y.update(Ae),y.close(Ae)}async function se(){for(const Ue of Be)Ue();Ae.state="closed",y.update(Ae),y.close(Ae)}const de=await Vs(_,{loginRequest:{appId:P}}),Be=[de.close,de.on("error",X),de.on("reply",Ue=>{ne(Ue).catch(X)})],Ae={id:de.lobbyId,cancelRequest:se,watch:y.watchMethod,state:"pending",account:void 0,error:void 0,username:void 0};return y.bridgifyObject(Ae)}const el=l.uncleaner(Xs),tl=l.asObject({appName:l.asString,darkImageUrl:l.asOptional(l.asString),lightImageUrl:l.asOptional(l.asString),imageUrl:l.asOptional(l.asString)});async function Ys(_,P){try{const[W]=Go(_.props.state.infoServers),X=`${W}/v1/appIdInfo/${P}`,ne=await _.props.io.fetch(X);if(ne.status===404)return{appName:P};if(!ne.ok)throw new Error(`Fetching ${X} returned ${ne.status}`);const se=tl(await ne.json());return se.lightImageUrl==null&&(se.lightImageUrl=se.imageUrl),se.darkImageUrl==null&&(se.darkImageUrl=se.imageUrl),se}catch(W){return _.props.onError(W),{appName:P}}}async function rl(_,P,W,X,ne){const{login:se,loginTree:de}=_.props.state.accounts[P];await pn(_,de,se);const Be=await js(_,de,W),Ae=Po(Be,W);if(Ae==null)throw new Error("Failed to create the requested login object");const{stashTree:Ue}=En(_,de.loginId),$e=ei(Ue,W),nt=el({appId:W,loginKey:Ae.loginKey,loginStash:$e});await qs(_,X,ne,nt);let Ye;const vt=_.props.output.accounts[P].accountApi;vt!=null&&vt.on("close",()=>{Ye!=null&&clearTimeout(Ye)}),Ye=setTimeout(()=>{Ye=void 0,pn(_,Be,Ae).then(()=>{Ye=setTimeout(()=>{Ye=void 0,pn(_,Be,Ae).catch(Et=>_.props.onError(Et))},2e4)}).catch(Et=>_.props.onError(Et))},1e4)}async function nl(_,P,W){const X=await ma(_,W);let ne;X.loginRequest!=null&&(ne=await $s(_,P,W,X,X.loginRequest.appId));const se={loginRequest:ne};return y.bridgifyObject(se),se}async function $s(_,P,W,X,ne){const se=await Ys(_,ne),de={appId:ne,displayName:se.appName,displayImageDarkUrl:se.darkImageUrl,displayImageLightUrl:se.lightImageUrl,approve(){return rl(_,P,ne,W,X)},async close(){y.close(de)}};return y.bridgifyObject(de),de}function Js(_){const P={};for(const W of Object.keys(_)){const X=_[W];P[X.currencyCode]=W}return P}function il(_={},P={},W,X){var Be;const ne=Js(_),se=Js(P),de=[];for(const Ae of X){const Ue=(Be=se[Ae])!=null?Be:ne[Ae];Ue!=null&&de.push(Ue)}return de}function ga(_={},P={},W,X){var se;const ne=[];for(const de of X){const Be=(se=P[de])!=null?se:_[de];Be!=null&&ne.push(Be.currencyCode)}return ne}function ni(_,P=[]){const W=new Set(P),X=[];for(const ne of _)W.has(ne)||(W.add(ne),X.push(ne));return X}const Qs="Currency.json",ya="fixedLegacyFileNames.json",ol="EnabledTokens.json",al="Tokens.json",ef="WalletName.json",sl=Fr(Bs),tf=Fr(Pu),fl=Fr(_u),ba=Fr(Tu),rf=Fr(Iu),wa=Fr(Au),xa=Fr(Rs),nf=Fr(Bu);async function ul(_,P,W){const{state:X,walletId:ne}=_.props,se=Kr(X,ne);await rf.save(se,al,{detectedTokenIds:P,enabledTokenIds:W})}function of(_,P,W){const X={creationDate:_.state.creationDate,currencies:new Map,tokens:new Map,internal:_.state.internal,txid:_.state.malleableTxId},ne={};return ne[W]=_.meta.amountCurrency,X.currencies.set(P,{metadata:{bizId:_.meta.bizId,category:_.meta.category,exchangeAmount:ne,name:_.meta.name,notes:_.meta.notes},providerFeeSent:_.meta.amountFeeAirBitzSatoshi.toFixed()}),X}function af(_,P,W,X){const ne=mi(_,P,X);return{fileName:`${W.toFixed(0)}-${ne}.json`,txidHash:ne}}async function Vc(_,P){const{dispatch:W,state:X,walletId:ne}=_.props,se=Kr(X,ne);await nf.save(se,ef,{walletName:P}),W({type:"CURRENCY_WALLET_NAME_CHANGED",payload:{name:P,walletId:ne}})}async function ll(_,P){const{dispatch:W,state:X,walletId:ne}=_.props,se=Kr(X,ne);if(!/^iso:/.test(P))throw new TypeError("Fiat currency codes must start with `iso:`");await xa.save(se,Qs,{fiat:P,num:void 0}),W({type:"CURRENCY_WALLET_FIAT_CHANGED",payload:{fiatCurrencyCode:P,walletId:ne}})}async function sf(_){const{dispatch:P,state:W,walletId:X}=_.props,ne=Kr(W,X),se=await xa.load(ne,Qs);let de="iso:USD";if(se!=null){if(se.fiat!=null)de=se.fiat;else if(se.num!=null){const Be=k.number(`000${se.num}`.slice(-3));Be!=null&&(de=`iso:${Be.code}`)}}P({type:"CURRENCY_WALLET_FIAT_CHANGED",payload:{fiatCurrencyCode:de,walletId:X}})}async function ff(_){const{dispatch:P,state:W,walletId:X}=_.props,ne=Kr(W,X),se=await nf.load(ne,ef);let de=null;if(se==null||se.walletName==null){const{appIds:Be=[]}=_.props.walletState.walletInfo,Ae=Be.find(Ue=>Ue!=="");if(Ae!=null){const{appName:Ue}=await Ys(Wn(_),Ae);de=Ue}}else de=se.walletName;P({type:"CURRENCY_WALLET_NAME_CHANGED",payload:{name:typeof de=="string"?de:null,walletId:X}})}async function uf(_){const{dispatch:P,state:W,walletId:X}=_.props,ne=Kr(W,X),se=await rf.load(ne,al);if(se!=null){P({type:"CURRENCY_WALLET_LOADED_TOKEN_FILE",payload:{walletId:_.props.walletId,...se}});return}const de=await fl.load(ne,ol);if(de!=null){const{accountId:Be,currencyInfo:Ae,pluginId:Ue}=_.props.walletState,$e=_.props.state.accounts[Be],nt=il($e.builtinTokens[Ue],$e.customTokens[Ue],Ae,de);P({type:"CURRENCY_WALLET_LOADED_TOKEN_FILE",payload:{walletId:_.props.walletId,detectedTokenIds:[],enabledTokenIds:nt}})}}async function lf(_,P){const{dispatch:W,walletId:X}=_.props,ne=Kr(_.props.state,X),se=_.props.walletState.currencyInfo.currencyCode,de=_.props.walletState.fileNames,Be=_.props.walletState.fiat,Ae={};return await Promise.all(P.map(async Ue=>{if(de[Ue]==null)return;const $e=`Transactions/${de[Ue].fileName}`,nt=await ba.load(ne,$e);nt!=null&&(Ae[Ue]=of(nt,se,Be))})),await Promise.all(P.map(async Ue=>{if(de[Ue]==null)return;const $e=`transaction/${de[Ue].fileName}`,nt=await wa.load(ne,$e);nt!=null&&(Ae[Ue]=nt)})),W({type:"CURRENCY_WALLET_FILES_LOADED",payload:{files:Ae,walletId:X}}),Ae}async function cl(_,P,W){var Ue;const X=ho(_,P),ne=(Ue=await tf.load(X,ya))!=null?Ue:{},se=p.justFiles(await W.list()),de={},Be=[];for(let $e=0;$e<se.length;$e++){const nt=se[$e],Ye=ne[nt];if(Ye!=null){const{timestamp:vt,txidHash:Et}=Ye;de[Et]={creationDate:vt,fileName:nt}}else Be.push(nt)}const Ae=Be.map(async $e=>{const nt=await ba.load(W,$e);if(nt==null)return;const{creationDate:Ye,malleableTxId:vt}=nt.state,Et=$e,mt=mi(_,P,vt);de[mt]={creationDate:Ye,fileName:Et},ne[Et]={timestamp:Ye,txidHash:mt}});return Ae.length>0&&(await Promise.all(Ae),await tf.save(X,ya,ne).catch(()=>{})),de}async function cf(_){const{dispatch:P,state:W,walletId:X}=_.props,ne=Kr(W,X),se=await cl(W,X,p.navigateDisklet(ne,"Transactions")),de=await p.navigateDisklet(ne,"transaction").list();for(const Be of p.justFiles(de)){const Ue=Be.split(".json")[0].split("-"),[$e,nt]=Ue,Ye=parseInt($e);(se[nt]==null||Ye<se[nt].creationDate)&&(se[nt]={creationDate:Ye,fileName:Be})}P({type:"CURRENCY_WALLET_FILE_NAMES_LOADED",payload:{txFileNames:se,walletId:X}})}async function Ma(_){var Be;const{state:P,walletId:W}=_.props,X=Kr(P,W),ne=[],se=p.justFiles(await X.list("Addresses"));await Promise.all(se.map(async Ae=>{const Ue=await sl.load(X,Ae);Ue!=null&&(Ue.address===""||Ue.state.recycleable||ne.push(Ue.address))}));const de=(Be=_.props.walletOutput)==null?void 0:Be.engine;de!=null&&await de.addGapLimitAddresses(ne)}async function hf(_,P,W,X,ne,se,de){var _r,Lr,Vr;const{dispatch:Be,state:Ae,walletId:Ue}=_.props,$e=Kr(Ae,Ue),{accountId:nt,currencyInfo:Ye,pluginId:vt}=_.props.walletState,Et=_.props.state.accounts[nt].allTokens[vt],{currencyCode:mt}=W==null?Ye:Et[W],Mt=_.props.walletState.txs[P];if(Mt==null)throw new Error(`Setting metatdata for missing tx ${P}`);const Ot=_.props.walletState.files,Vt=Object.keys(Ot).find(on=>Ot[on].txid===P),Zt=Vt!=null?Ot[Vt]:void 0,{creationDate:ir=Math.min(Mt.date,Date.now()/1e3)}=Zt!=null?Zt:{},vr={...Zt,creationDate:ir,currencies:new Map((_r=Zt==null?void 0:Zt.currencies)!=null?_r:[]),internal:!0,tokens:new Map((Lr=Zt==null?void 0:Zt.tokens)!=null?Lr:[]),txid:P},br={metadata:{},...vr.currencies.get(mt),...vr.tokens.get(W)};vr.tokens.set(W,br),vr.currencies.delete(mt),ne!=null&&(br.metadata=ks((Vr=br.metadata)!=null?Vr:{},ne)),se!=null&&(br.assetAction=se),de!=null&&(vr.savedAction=de);const{fileName:Pr,txidHash:kr}=af(Ae,Ue,ir,P);Be({type:"CURRENCY_WALLET_FILE_CHANGED",payload:{creationDate:ir,fileName:Pr,json:vr,txid:P,txidHash:kr,walletId:Ue}}),await wa.save($e,"transaction/"+Pr,vr);const Ar=Ea(_,Mt,vr,W);X.onTransactionsChanged([Ar])}async function df(_,P){const{dispatch:W,state:X,walletId:ne}=_.props,{assetAction:se,savedAction:de,spendTargets:Be,swapData:Ae,tokenId:Ue,txid:$e}=P,nt=Kr(X,ne),Ye=Date.now()/1e3,{metadata:vt={},nativeAmount:Et}=P,mt={txid:$e,internal:!0,creationDate:Ye,currencies:new Map,tokens:new Map,savedAction:de,swap:Ae};mt.tokens.set(Ue,{assetAction:se,metadata:vt,nativeAmount:Et}),P.networkFeeOption!=null&&(mt.feeRateRequested=P.networkFeeOption==="custom"?P.requestedCustomFee:P.networkFeeOption),mt.feeRateUsed=P.feeRateUsed,Be!=null&&(mt.payees=Be.map(Vt=>({currency:Vt.currencyCode,address:Vt.publicAddress,amount:Vt.nativeAmount,tag:Vt.memo})),P.deviceDescription!=null&&(mt.deviceDescription=P.deviceDescription)),typeof P.txSecret=="string"&&(mt.secret=P.txSecret);const{fileName:Mt,txidHash:Ot}=af(X,ne,Ye,$e);W({type:"CURRENCY_WALLET_FILE_CHANGED",payload:{creationDate:Ye,fileName:Mt,json:mt,txid:$e,txidHash:Ot,walletId:ne}}),await wa.save(nt,"transaction/"+Mt,mt)}const Ii=[],hl=C.buildReducer({accountId(_,P,W){if(_!=null)return _;for(const X of Object.keys(W.root.accounts)){const ne=W.root.accounts[X];for(const se of Object.keys(ne.walletInfos))if(se===W.id)return X}throw new Error(`Cannot find account for walletId ${W.id}`)},allEnabledTokenIds:C.memoizeReducer(_=>_.root.accounts[_.self.accountId].alwaysEnabledTokenIds[_.self.pluginId],_=>_.self.enabledTokenIds,(_=[],P=[])=>ni([..._,...P])),pluginId:C.memoizeReducer(_=>_.root.login.walletInfos[_.id].type,_=>_.root.plugins.currency,(_,P)=>yi(P,_)),paused(_,P,W){return _==null?W.root.accounts[W.self.accountId].pauseWallets:P.type==="CURRENCY_WALLET_CHANGED_PAUSED"?P.payload.paused:_},currencyInfo(_,P,W){if(_!=null)return _;const{pluginId:X}=W.self;return W.root.plugins.currency[X].currencyInfo},detectedTokenIds:un((_=Ii,P)=>{if(P.type==="CURRENCY_WALLET_LOADED_TOKEN_FILE")return P.payload.detectedTokenIds;if(P.type==="CURRENCY_ENGINE_DETECTED_TOKENS"){const{detectedTokenIds:W}=P.payload;return ni([..._,...W])}else if(P.type==="CURRENCY_ENGINE_CLEARED")return[];return _}),enabledTokenIds:un((_=Ii,P)=>{if(P.type==="CURRENCY_WALLET_LOADED_TOKEN_FILE")return P.payload.enabledTokenIds;if(P.type==="CURRENCY_WALLET_ENABLED_TOKENS_CHANGED")return P.payload.enabledTokenIds;if(P.type==="CURRENCY_ENGINE_DETECTED_TOKENS"){const{enablingTokenIds:W}=P.payload;return ni([..._,...W])}return _}),engineFailure(_=null,P){if(P.type==="CURRENCY_ENGINE_FAILED"){const{error:W}=P.payload;return W instanceof Error?W:new Error(String(W))}return _},engineStarted(_=!1,P){return P.type==="CURRENCY_ENGINE_STARTED"?!0:P.type==="CURRENCY_ENGINE_STOPPED"?!1:_},fiat(_="",P){return P.type==="CURRENCY_WALLET_FIAT_CHANGED"?P.payload.fiatCurrencyCode:_},fiatLoaded(_=!1,P){return P.type==="CURRENCY_WALLET_FIAT_CHANGED"?!0:_},files(_={},P){switch(P.type){case"CURRENCY_WALLET_FILE_CHANGED":{const{json:W,txidHash:X}=P.payload,ne={..._};return ne[X]=W,ne}case"CURRENCY_WALLET_FILES_LOADED":{const{files:W}=P.payload;return{..._,...W}}}return _},fileNames(_={},P){switch(P.type){case"CURRENCY_WALLET_FILE_NAMES_LOADED":{const{txFileNames:W}=P.payload;return{..._,...W}}case"CURRENCY_WALLET_FILE_CHANGED":{const{fileName:W,creationDate:X,txidHash:ne}=P.payload;return(_[ne]==null||X<_[ne].creationDate)&&(_[ne]={creationDate:X,fileName:W}),_}}return _},syncRatio(_=0,P){switch(P.type){case"CURRENCY_ENGINE_CHANGED_SYNC_RATIO":return P.payload.ratio;case"CURRENCY_ENGINE_CLEARED":return 0}return _},balanceMap(_=new Map,P){if(P.type==="CURRENCY_ENGINE_CHANGED_BALANCE"){const{balance:W,tokenId:X}=P.payload,ne=new Map(_);return ne.set(X,W),ne}return _},balances:C.memoizeReducer(_=>_.self.balanceMap,_=>_.self.currencyInfo,_=>_.root.accounts[_.self.accountId].allTokens[_.self.pluginId],(_,P,W)=>{const X={};for(const ne of _.keys()){const se=_.get(ne),{currencyCode:de}=ne==null?P:W[ne];se!=null&&(X[de]=se)}return X}),height(_=0,P){return P.type==="CURRENCY_ENGINE_CHANGED_HEIGHT"?P.payload.height:_},name(_=null,P){return P.type==="CURRENCY_WALLET_NAME_CHANGED"?P.payload.name:_},nameLoaded(_=!1,P){return P.type==="CURRENCY_WALLET_NAME_CHANGED"?!0:_},sortedTxidHashes:C.memoizeReducer(_=>_.self.txidHashes,_=>Object.keys(_).sort((P,W)=>_[P].date>_[W].date?-1:_[P].date<_[W].date?1:0)),stakingStatus(_={stakedAmounts:[]},P){return P.type==="CURRENCY_ENGINE_CHANGED_STAKING"?P.payload.stakingStatus:_},txidHashes(_={},P){switch(P.type){case"CURRENCY_ENGINE_CHANGED_TXS":return dl(_,P.payload.txidHashes);case"CURRENCY_WALLET_FILE_NAMES_LOADED":{const{txFileNames:W}=P.payload,X={};for(const ne of Object.keys(W))X[ne]={date:W[ne].creationDate};return dl(_,X)}}return _},txs(_={},P,W){switch(P.type){case"CHANGE_MERGE_TX":{const{tx:X}=P.payload,ne={..._};return ne[X.txid]=X,ne}case"CURRENCY_ENGINE_CHANGED_TXS":{const{txs:X}=P.payload,ne={..._};for(const se of X)ne[se.txid]=Oo(se,ne[se.txid]);return ne}case"CURRENCY_ENGINE_CLEARED":return{}}return _},unactivatedTokenIds(_=[],P){switch(P.type){case"CURRENCY_ENGINE_CHANGED_UNACTIVATED_TOKEN_IDS":return P.payload.unactivatedTokenIds;case"CURRENCY_ENGINE_CLEARED":return[]}return _},gotTxs(_=new Set,P){switch(P.type){case"CURRENCY_ENGINE_GOT_TXS":{const{tokenId:W}=P.payload,X=new Set(_);return X.add(W),X}case"CURRENCY_ENGINE_CLEARED":return new Set;default:return _}},walletInfo(_,P,W){return W.root.login.walletInfos[W.id]},publicWalletInfo(_=null,P){return P.type==="CURRENCY_WALLET_PUBLIC_INFO"?P.payload.walletInfo:_}});function dl(_,P){var X;const W={..._};for(const ne of Object.keys(P)){const se=W[ne],de=P[ne];W[ne]=se==null?de:{date:Math.min(de.date,se.date),txid:(X=de.txid)!=null?X:se.txid}}return W}const qc=C.filterReducer(hl,(_,P)=>/^CURRENCY_/.test(_.type)&&"payload"in _&&typeof _.payload=="object"&&"walletId"in _.payload&&_.payload.walletId===P.id?_:{type:"UPDATE_NEXT"});function Oo(_,P){var se,de,Be,Ae,Ue;const{isSend:W=b.lt(_.nativeAmount,"0"),tokenId:X=null}=_,ne={chainAssetAction:new Map((se=P==null?void 0:P.chainAssetAction)!=null?se:[]),blockHeight:_.blockHeight,chainAction:_.chainAction,confirmations:(de=_.confirmations)!=null?de:"unconfirmed",date:_.date,isSend:W,memos:_.memos,nativeAmount:new Map((Be=P==null?void 0:P.nativeAmount)!=null?Be:[]),networkFee:new Map((Ae=P==null?void 0:P.networkFee)!=null?Ae:[]),otherParams:_.otherParams,ourReceiveAddresses:_.ourReceiveAddresses,signedTx:_.signedTx,txid:_.txid};return ne.nativeAmount.set(X,_.nativeAmount),ne.networkFee.set(X,(Ue=_.networkFee)!=null?Ue:"0"),_.parentNetworkFee!=null&&ne.networkFee.set(null,String(_.parentNetworkFee)),_.chainAssetAction!=null&&ne.chainAssetAction.set(X,_.chainAssetAction),ne}function un(_){return(P,W)=>{const X=_(P,W);return X===P?P:(X.sort((ne,se)=>ne===se?0:ne>se?1:-1),P==null||!Vi(X,P)?X:P)}}let Wt=5e3;function pl(_,P){const{log:W,walletId:X}=_.props;let ne=!1,se=0,de=[];return Be=>{if(ne)W(`throttledTxCallback delay, walletId: ${X}`),de.push(...Be);else{const Ae=Date.now();Ae-se>Wt?(se=Ae,P(Be)):(W(`throttledTxCallback delay, walletId: ${X}`),ne=!0,de=Be,setTimeout(()=>{se=Date.now(),P(de),ne=!1,de=[]},Wt))}}}function vl(_){const{walletId:P}=_.props;P==="narfavJN4rp9ZzYigcRj1i0vrU2OAGGp4+KksAksj54="&&(Wt=25,yu());const W=pl(_,se=>{var de;((de=_.props.walletOutput)==null?void 0:de.walletApi)!=null&&y.emit(_.props.walletOutput.walletApi,"transactionsChanged",se)}),X=pl(_,se=>{var de;((de=_.props.walletOutput)==null?void 0:de.walletApi)!=null&&y.emit(_.props.walletOutput.walletApi,"newTransactions",se)}),ne={onAddressesChecked(se){ti({id:P,action:"onAddressesChecked",updateFunc:()=>{_.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_SYNC_RATIO",payload:{ratio:se,walletId:P}})}})},onNewTokens(se){ti({id:P,action:"onNewTokens",updateFunc:()=>{var Ue,$e;const{detectedTokenIds:de,enabledTokenIds:Be}=_.props.walletState,Ae=ni(se,[...de,...Be]);if(_.props.dispatch({type:"CURRENCY_ENGINE_DETECTED_TOKENS",payload:{detectedTokenIds:se,enablingTokenIds:Ae,walletId:P}}),Ae.length>0){const nt=($e=(Ue=_.props)==null?void 0:Ue.walletOutput)==null?void 0:$e.walletApi;nt!=null&&y.emit(nt,"enabledDetectedTokens",Ae)}}})},onUnactivatedTokenIdsChanged(se){ti({id:P,action:"onUnactivatedTokenIdsChanged",updateFunc:()=>{_.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_UNACTIVATED_TOKEN_IDS",payload:{unactivatedTokenIds:se,walletId:P}})}})},onBalanceChanged(se,de){const{accountId:Be,currencyInfo:Ae,pluginId:Ue}=_.props.walletState,$e=_.props.state.accounts[Be].allTokens[Ue];if(se===Ae.currencyCode)ne.onTokenBalanceChanged(null,de);else{const{tokenId:nt}=jn({allTokens:$e,currencyInfo:Ae,currencyCode:se});nt!=null&&ne.onTokenBalanceChanged(nt,de)}},onTokenBalanceChanged(se,de){const Be=l.asMaybe(fa)(de);if(Be==null){_.props.onError(new Error(`Plugin sent bogus balance for ${String(se)}: "${de}"`));return}ti({id:`${P}==${String(se)}`,action:"onTokenBalanceChanged",updateFunc:()=>{_.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_BALANCE",payload:{balance:Be,tokenId:se,walletId:P}})}})},onBlockHeightChanged(se){ti({id:P,action:"onBlockHeightChanged",updateFunc:()=>{const{txs:de}=_.props.walletState;for(const Be of Object.keys(de)){const Ae=de[Be];if(gl(Ae.confirmations)){const{requiredConfirmations:Ue}=_.props.walletState.currencyInfo,{height:$e}=_.props.walletState;Ae.confirmations=yl(Ae,$e,Ue);const nt=mi(_.props.state,P,Ae.txid),{files:Ye}=_.props.walletState,vt=Ea(_,Ae,Ye[nt],null);_.props.dispatch({type:"CHANGE_MERGE_TX",payload:{tx:Ae}}),W([vt])}}_.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_HEIGHT",payload:{height:se,walletId:P}})}})},onStakingStatusChanged(se){ti({id:P,action:"onStakingStatusChanged",updateFunc:()=>{_.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_STAKING",payload:{stakingStatus:se,walletId:P}})}})},onTransactionsChanged(se){const{accountId:de,currencyInfo:Be,pluginId:Ae}=_.props.walletState,Ue=_.props.state.accounts[de].allTokens[Ae];if(se==null)return;for(const Mt of se){if(typeof Mt.txid!="string"||typeof Mt.date!="number"||typeof Mt.networkFee!="string"||typeof Mt.blockHeight!="number"||typeof Mt.nativeAmount!="string"||typeof Mt.ourReceiveAddresses!="object"){_.props.onError(new Error(`Plugin sent bogus tx: ${JSON.stringify(Mt,null,2)}`));return}if(Mt.isSend==null&&(Mt.isSend=b.lt(Mt.nativeAmount,"0")),Mt.memos==null&&(Mt.memos=[]),Mt.tokenId===void 0){const{tokenId:Ot}=jn({allTokens:Ue,currencyInfo:Be,currencyCode:Mt.currencyCode});Mt.tokenId=Ot!=null?Ot:null}}const{state:$e}=_.props,{fileNames:nt,txs:Ye}=_.props.walletState,vt={},Et=[],mt=[];for(const Mt of se){const{txid:Ot}=Mt;if(gl(Mt.confirmations)){const{requiredConfirmations:Pr}=_.props.walletState.currencyInfo,{height:kr}=_.props.walletState;Mt.confirmations=yl(Mt,kr,Pr)}const Vt=Oo(Mt,Ye[Ot]);if(Vi(Vt,Ye[Ot])&&Mt.metadata==null)continue;const Zt=mi($e,P,Ot),ir=Mt.isSend?!1:nt[Zt]==null;ir&&df(_,Mt).catch(Pr=>_.props.onError(Pr));const{files:vr}=_.props.walletState,br=Ea(_,Vt,vr[Zt],Mt.tokenId);ir?mt.push(br):vr[Zt]!=null&&Et.push(br),vt[Zt]={date:br.date,txid:Ot}}_.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_TXS",payload:{txs:se,walletId:P,txidHashes:vt}}),Et.length>0&&W(Et),mt.length>0&&X(mt)},onAddressChanged(){_.props.walletOutput.walletApi!=null&&y.emit(_.props.walletOutput.walletApi,"addressChanged",void 0)},onWcNewContractCall(se){_.props.walletOutput.walletApi!=null&&y.emit(_.props.walletOutput.walletApi,"wcNewContractCall",se)},onTxidsChanged(){}};return ne}function ml(_){const{walletId:P}=_.props;let W;async function X(se){const de=Rf(se.state,P);de!==W&&(W=de,await uf(_),await sf(_),await ff(_),await cf(_),await Ma(_))}function ne(){_.nextProps().then(X).then(ne,se=>{v.isPixieShutdownError(se)||(_.props.onError(se),ne())})}ne()}const gl=_=>_!=="confirmed"&&_!=="dropped"&&_!=="failed",yl=(_,P,W=1)=>{if(_.blockHeight>0){const X=1+P-_.blockHeight;return X<=0?"syncing":X>=W?"confirmed":X}return _.blockHeight<0?"dropped":"unconfirmed"};function Xc(_,P=new Date(0),W=new Date){return _.date*1e3>=P.valueOf()&&_.date*1e3<W.valueOf()}function Zc(_,P,W){var Be;const X=_.props.state.currency;if(W==null||W==="")return!0;let ne=W.toLowerCase().replace(".","").replace(",","");for(let Ae=0;Ae<ne.length;Ae++)if(ne[Ae]!=="0"){ne=ne.substring(Ae);break}function se(Ae){return!(Ae==null||typeof Ae!="string"&&typeof Ae!="number"||!Ae.toString().toLowerCase().replace(".","").replace(",","").includes(ne))}if(se(P.nativeAmount))return!0;if(P.metadata!=null){const{category:Ae="",name:Ue="",notes:$e="",exchangeAmount:nt={}}=P.metadata,Ye=P.walletId!=null?X.wallets[P.walletId]:void 0;if(se(Ae)||se(Ue)||se($e)||Ye!=null&&se(nt[Ye.fiat]))return!0}if(P.swapData!=null){const{displayName:Ae="",pluginId:Ue=""}=P.swapData.plugin;if(se(Ae)||se(Ue))return!0}const de=(Be=P.savedAction)!=null?Be:P.chainAction;if(de!=null&&de.actionType==="swap"){const{pluginId:Ae}=de.toAsset,{pluginId:Ue}=de.fromAsset,{displayName:$e,supportEmail:nt}=de.swapInfo;if(se(Ue)||se(Ae)||se($e)||se(nt))return!0}if(P.spendTargets!=null)for(const Ae of P.spendTargets){const{publicAddress:Ue="",memo:$e=""}=Ae;if(se(Ue)||se($e))return!0}if(P.ourReceiveAddresses.length>0){for(const Ae of P.ourReceiveAddresses)if(se(Ae))return!0}return!!se(P.txid)}function bl(_,P){var se,de,Be;const W=[],{memoType:X}=P;if(X==="hex"||X==="number"||X==="text")for(const Ae of _.spendTargets)Ae.memo!=null?W.push({type:X,value:Ae.memo}):Ae.uniqueIdentifier!=null?W.push({type:X,value:Ae.uniqueIdentifier}):typeof((se=Ae.otherParams)==null?void 0:se.uniqueIdentifier)=="string"&&W.push({type:X,value:Ae.otherParams.uniqueIdentifier});for(const Ae of W)Ae.type==="hex"&&(Ae.value=Ae.value.replace(/^0x/i,""));const ne={..._,spendTargets:_.spendTargets.map(Ae=>({...Ae,memo:void 0,uniqueIdentifier:void 0})),memos:(de=_.memos)!=null?de:W};if(((Be=ne.memos)==null?void 0:Be.length)===1&&ne.spendTargets.length>=1){const[Ae]=ne.memos;if(Ae.type===P.memoType){const[Ue]=ne.spendTargets;Ue.memo=Ae.value,Ue.uniqueIdentifier=Ae.value,Ue.otherParams={...Ue.otherParams,uniqueIdenfitifer:Ae.value}}}return ne}const Yc={bizId:0,category:"",exchangeAmount:{},name:"",notes:""};function $c(_,P,W,X){const ne=Wn(_),{accountId:se,pluginId:de,walletInfo:Be}=_.props.walletState,Ae=_.props.state.plugins.currency[de],{unsafeBroadcastTx:Ue=!1,unsafeMakeSpend:$e=!1}=Ae.currencyInfo,nt=xs(ne,Be),Ye=vl(_);let vt={};P.otherMethods!=null&&(vt=P.otherMethods,y.bridgifyObject(vt));const Et={on:y.onMethod,watch:y.watchMethod,get disklet(){return nt.disklet},get id(){return nt.id},get localDisklet(){return nt.localDisklet},publicWalletInfo:X,async sync(){await nt.sync()},get type(){return nt.type},get name(){return _.props.walletState.name},async renameWallet(mt){await Vc(_,mt)},get fiatCurrencyCode(){return _.props.walletState.fiat},async setFiatCurrencyCode(mt){await ll(_,mt)},get currencyConfig(){const{accountApi:mt}=_.props.output.accounts[se];return mt.currencyConfig[de]},get currencyInfo(){return Ae.currencyInfo},async denominationToNative(mt,Mt){const Ot=Ka(Ae.currencyInfo,_.props.state.accounts[se].allTokens[de],Mt);return b.mul(mt,Ot)},async nativeToDenomination(mt,Mt){const Ot=Ka(Ae.currencyInfo,_.props.state.accounts[se].allTokens[de],Mt);return b.div(mt,Ot,Ot.length)},get balances(){return _.props.walletState.balances},get balanceMap(){return _.props.walletState.balanceMap},get blockHeight(){const{skipBlockHeight:mt}=_.props.state;return mt?0:_.props.walletState.height},get syncRatio(){return _.props.walletState.syncRatio},get unactivatedTokenIds(){return _.props.walletState.unactivatedTokenIds},async changePaused(mt){_.props.dispatch({type:"CURRENCY_WALLET_CHANGED_PAUSED",payload:{walletId:_.props.walletId,paused:mt}})},get paused(){return _.props.walletState.paused},async changeEnabledTokenIds(mt){var kr;const{dispatch:Mt,walletId:Ot,walletState:Vt}=_.props,{accountId:Zt,pluginId:ir}=Vt,br=(kr=_.props.state.accounts[Zt].allTokens[ir])!=null?kr:{},Pr=mt.filter(Ar=>br[Ar]!=null);Mt({type:"CURRENCY_WALLET_ENABLED_TOKENS_CHANGED",payload:{walletId:Ot,enabledTokenIds:Pr}})},get detectedTokenIds(){return _.props.walletState.detectedTokenIds},get enabledTokenIds(){return _.props.walletState.enabledTokenIds},async getNumTransactions(mt){const Mt=jn({allTokens:_.props.state.accounts[se].allTokens[de],currencyInfo:Ae.currencyInfo,tokenId:mt.tokenId});return P.getNumTransactions(Mt)},async $internalStreamTransactions(mt){const{afterDate:Mt,batchSize:Ot=10,beforeDate:Vt,firstBatchSize:Zt=Ot,searchString:ir,tokenId:vr=null}=mt,{currencyCode:br}=vr==null?this.currencyInfo:this.currencyConfig.allTokens[vr],Pr={currencyCode:br,tokenId:vr};let kr=_.props.walletState;if(!kr.gotTxs.has(vr)){const Ln=await P.getTransactions(Pr);Ye.onTransactionsChanged(Ln),_.props.dispatch({type:"CURRENCY_ENGINE_GOT_TXS",payload:{walletId:_.props.walletId,tokenId:vr}}),kr=_.props.walletState}const{files:Ar,sortedTxidHashes:_r,txidHashes:Lr,txs:Vr}=kr;let on=0,kn=!0,mn=0;return y.bridgifyObject({async next(){var $i,Gn;const Ln=kn?Zt:Ot,jr=[];for(;on<_r.length&&jr.length<Ln;){if(on>=mn){const Yl=_r.slice(mn,mn+Ln).filter(Jl=>Ar[Jl]==null),$l=await lf(_,Yl);Object.assign(Ar,$l),mn=mn+Ln}const oi=_r[on++],ai=Ar[oi],Co=(Gn=ai==null?void 0:ai.txid)!=null?Gn:($i=Lr[oi])==null?void 0:$i.txid;if(Co==null)continue;const si=Vr[Co];if(si==null||!(si.nativeAmount.has(vr)||si.networkFee.has(vr)))continue;const Ta=Ea(_,si,ai,vr);Zc(ne,Ta,ir)&&Xc(Ta,Mt,Vt)&&jr.push(Ta)}return kn=!1,{done:jr.length===0,value:jr}}})},async getTransactions(mt){const{endDate:Mt,startDate:Ot,searchString:Vt}=mt,Zt=jn({allTokens:_.props.state.accounts[se].allTokens[de],currencyInfo:Ae.currencyInfo,tokenId:mt.tokenId}),ir=await Et.$internalStreamTransactions({...Zt,afterDate:Ot,beforeDate:Mt,searchString:Vt}),vr=[];for(;;){const br=await ir.next();if(br.done)return vr;vr.push(...br.value)}},streamTransactions:t,async getReceiveAddress(mt){const Mt=jn({allTokens:_.props.state.accounts[se].allTokens[de],currencyInfo:Ae.currencyInfo,tokenId:mt.tokenId});return{...await P.getFreshAddress({...Mt,forceIndex:mt.forceIndex}),nativeAmount:"0",metadata:Yc}},async lockReceiveAddress(mt){},async saveReceiveAddress(mt){},async broadcastTx(mt){const Mt=Ue?Be.keys:void 0;return await P.broadcastTx(mt,{privateKeys:Mt})},async getMaxSpendable(mt){mt=bl(mt,Ae.currencyInfo);const Mt=jn({allTokens:_.props.state.accounts[se].allTokens[de],currencyInfo:Ae.currencyInfo,tokenId:mt.tokenId});if(typeof P.getMaxSpendable=="function"){const br=$e?Be.keys:void 0;return await P.getMaxSpendable({...mt,...Mt},{privateKeys:br})}const{networkFeeOption:Ot,customNetworkFee:Vt}=mt,Zt=P.getBalance(Mt),ir=mt.spendTargets.map(br=>({...br,nativeAmount:"0"}));function vr(br,Pr){const kr=b.sub(Pr,br);if(b.lte(kr,"1"))return Promise.resolve(br);const Ar=b.add(br,b.div(kr,"2"));ir[0].nativeAmount=Ar;const _r=$e?Be.keys:void 0;return P.makeSpend({...Mt,spendTargets:ir,networkFeeOption:Ot,customNetworkFee:Vt},{privateKeys:_r}).then(()=>vr(Ar,Pr)).catch(()=>vr(br,Ar))}return await vr("0",b.add(Zt,"1"))},async getPaymentProtocolInfo(mt){if(P.getPaymentProtocolInfo==null)throw new Error("'getPaymentProtocolInfo' is not implemented on wallets of this type");return await P.getPaymentProtocolInfo(mt)},async makeSpend(mt){mt=bl(mt,Ae.currencyInfo);const{assetAction:Mt,customNetworkFee:Ot,memos:Vt,metadata:Zt,networkFeeOption:ir="standard",noUnconfirmed:vr=!1,otherParams:br,pendingTxs:Pr,rbfTxid:kr,savedAction:Ar,skipChecks:_r,spendTargets:Lr=[],swapData:Vr}=mt,on=jn({allTokens:_.props.state.accounts[se].allTokens[de],currencyInfo:Ae.currencyInfo,tokenId:mt.tokenId}),kn=[],mn=[];for(const $i of Lr){const{memo:Gn,publicAddress:oi,nativeAmount:ai="0",otherParams:Co={}}=$i;oi!=null&&(kn.push({memo:Gn,nativeAmount:ai,otherParams:Co,publicAddress:oi,uniqueIdentifier:Gn}),mn.push({currencyCode:on.currencyCode,memo:Gn,nativeAmount:ai,publicAddress:oi,uniqueIdentifier:Gn}))}if(mt.privateKeys!=null)throw new TypeError("Only sweepPrivateKeys takes private keys");const Ln=$e?Be.keys:void 0,jr=await P.makeSpend({...on,customNetworkFee:Ot,memos:Vt,metadata:Zt,networkFeeOption:ir,noUnconfirmed:vr,otherParams:br,pendingTxs:Pr,rbfTxid:kr,skipChecks:_r,spendTargets:kn},{privateKeys:Ln});return jr.networkFeeOption=ir,jr.requestedCustomFee=Ot,jr.spendTargets=mn,jr.currencyCode=on.currencyCode,jr.tokenId=on.tokenId,Zt!=null&&(jr.metadata=Zt),Vr!=null&&(jr.swapData=Is(Vr)),Ar!=null&&(jr.savedAction=ua(Ar)),Mt!=null&&(jr.assetAction=Os(Mt)),_.props.state.login.deviceDescription!=null&&(jr.deviceDescription=_.props.state.login.deviceDescription),jr},async saveTx(mt){await df(_,mt),await P.saveTx(mt),Ye.onTransactionsChanged([mt])},async saveTxAction(mt){const{txid:Mt,tokenId:Ot,assetAction:Vt,savedAction:Zt}=mt;await hf(_,Mt,Ot,Ye,void 0,Vt,Zt)},async saveTxMetadata(mt){const{txid:Mt,tokenId:Ot,metadata:Vt}=mt;await hf(_,Mt,Ot,Ye,Vt)},async signMessage(mt,Mt={}){if(P.signMessage==null)throw new Error(`${de} doesn't support signing messages`);const Ot=Be.keys;return await P.signMessage(mt,Ot,Mt)},async signTx(mt){const Mt=Be.keys;return await P.signTx(mt,Mt)},async sweepPrivateKeys(mt){if(P.sweepPrivateKeys==null)throw new Error("Sweeping this currency is not supported.");return await P.sweepPrivateKeys(mt)},async accelerate(mt){return P.accelerate==null?null:await P.accelerate(mt)},get stakingStatus(){return _.props.walletState.stakingStatus},async dumpData(){return await P.dumpData()},async resyncBlockchain(){ne.props.dispatch({type:"CURRENCY_ENGINE_CLEARED",payload:{walletId:_.props.walletId}}),await P.resyncBlockchain()},async encodeUri(mt){return await W.encodeUri(mt,bs(_.props.state.accounts[se].customTokens[de]))},async parseUri(mt,Mt){var Vt;const Ot=await W.parseUri(mt,Mt,bs(_.props.state.accounts[se].customTokens[de]));if(Ot.tokenId===void 0){const{tokenId:Zt=null}=jn({allTokens:_.props.state.accounts[se].allTokens[de],currencyInfo:Ae.currencyInfo,currencyCode:(Vt=Ot.currencyCode)!=null?Vt:Mt});Ot.tokenId=Zt}return Ot},otherMethods:vt};return y.bridgifyObject(Et),Et}function Ea(_,P,W,X){var Ye,vt,Et,mt,Mt,Ot,Vt,Zt,ir,vr,br,Pr;const ne=_.props.walletId,{accountId:se,currencyInfo:de,pluginId:Be}=_.props.walletState,Ae=_.props.state.accounts[se].allTokens[Be],{currencyCode:Ue}=X==null?de:Ae[X],$e=de.currencyCode,nt={chainAction:P.chainAction,chainAssetAction:P.chainAssetAction.get(X),blockHeight:P.blockHeight,confirmations:P.confirmations,currencyCode:Ue,date:P.date,isSend:P.isSend,memos:P.memos,metadata:{},nativeAmount:(Ye=P.nativeAmount.get(X))!=null?Ye:"0",networkFee:(vt=P.networkFee.get(X))!=null?vt:"0",otherParams:{...P.otherParams},ourReceiveAddresses:P.ourReceiveAddresses,parentNetworkFee:(Et=P.networkFee.get(null))!=null?Et:"0",signedTx:P.signedTx,tokenId:X,txid:P.txid,walletId:ne};if(W!=null){W.creationDate<nt.date&&(nt.date=W.creationDate),nt.metadata=ks((Vt=(Ot=(mt=W.tokens.get(null))==null?void 0:mt.metadata)!=null?Ot:(Mt=W.currencies.get($e))==null?void 0:Mt.metadata)!=null?Vt:{},(br=(vr=(Zt=W.tokens.get(X))==null?void 0:Zt.metadata)!=null?vr:(ir=W.currencies.get(Ue))==null?void 0:ir.metadata)!=null?br:{}),W.feeRateRequested!=null&&(typeof W.feeRateRequested=="string"?nt.networkFeeOption=W.feeRateRequested:(nt.networkFeeOption="custom",nt.requestedCustomFee=W.feeRateRequested)),nt.feeRateUsed=W.feeRateUsed,W.payees!=null&&(nt.spendTargets=W.payees.map(Ar=>({currencyCode:Ar.currency,memo:Ar.tag,nativeAmount:Ar.amount,publicAddress:Ar.address,uniqueIdentifier:Ar.tag})));const kr=(Pr=W.tokens.get(X))==null?void 0:Pr.assetAction;kr!=null&&(nt.assetAction=kr),W.savedAction!=null&&(nt.savedAction=W.savedAction),W.swap!=null&&(nt.swapData=W.swap),W.secret!=null&&(nt.txSecret=W.secret),W.deviceDescription!=null&&(nt.deviceDescription=W.deviceDescription)}return nt}const wl="publicKey.json",xl=Fr(Ou),Jc=v.combinePixies({engine:_=>async()=>{var Ue,$e;const{state:P,walletId:W,walletState:X}=_.props,{accountId:ne,pluginId:se,walletInfo:de}=X,Be=P.plugins.currency[se],{currencyCode:Ae}=Be.currencyInfo;try{const nt=Wn(_);await vs(nt,de);const{state:Ye}=_.props,vt=ho(Ye,de.id),Et=Cf(Ye,de.id,_.props.io);await cf(_);const mt=await Fn(nt,se),Mt=await pf(de,vt,mt);_.props.dispatch({type:"CURRENCY_WALLET_PUBLIC_INFO",payload:{walletInfo:Mt,walletId:W}}),await uf(_);const Ot=Ye.accounts[ne],Vt=await Be.makeCurrencyEngine(Mt,{callbacks:vl(_),log:co(_.props.logBackend,`${se}-${de.id.slice(0,2)}`),walletLocalDisklet:vt,walletLocalEncryptedDisklet:Et,customTokens:(Ue=Ot.customTokens[se])!=null?Ue:{},enabledTokenIds:_.props.walletState.allEnabledTokenIds,userSettings:($e=Ot.userSettings[se])!=null?$e:{}});_.onOutput(Vt);const Zt={currencyCode:Ae,tokenId:null},ir=l.asMaybe(fa)(Vt.getBalance(Zt));ir!=null&&_.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_BALANCE",payload:{balance:ir,tokenId:null,walletId:W}});const vr=Vt.getBlockHeight();_.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_HEIGHT",payload:{height:vr,walletId:W}}),Vt.getStakingStatus!=null&&await Vt.getStakingStatus().then(br=>{_.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_STAKING",payload:{stakingStatus:br,walletId:W}})},br=>_.props.onError(br)),await sf(_),await ff(_),await Ma(_)}catch(nt){_.props.onError(nt),_.props.dispatch({type:"CURRENCY_ENGINE_FAILED",payload:{error:nt,walletId:W}})}return ml(_),await v.stopUpdates},walletApi:_=>async()=>{const{walletOutput:P,walletState:W}=_.props;if(P==null)return;const{engine:X}=P,{nameLoaded:ne,pluginId:se,publicWalletInfo:de}=W;if(X==null||de==null||!ne)return;const Be=await Fn(Wn(_),se),Ae=$c(_,X,Be,de);return _.onOutput(Ae),await v.stopUpdates},engineStarted:v.filterPixie(_=>{let P,W;return{update(){const{log:X,walletId:ne,walletOutput:se,walletState:de}=_.props,{currencyInfo:Be,walletInfo:Ae,publicWalletInfo:Ue}=de;if(se==null)return;const{engine:$e,walletApi:nt}=se;if(!(nt==null||!de.fiatLoaded||de.engineStarted)&&$e!=null&&P==null&&(X(`${ne} startEngine`),_.props.dispatch({type:"CURRENCY_ENGINE_STARTED",payload:{walletId:ne}}),P=Promise.resolve().then(()=>$e.startEngine()).catch(Ye=>_.props.onError(Ye)),$e.syncNetwork!=null)){const vt=Be.unsafeSyncNetwork===!0&&Ue!=null?Ae.keys:void 0;W=ki(async()=>{if($e.syncNetwork!=null){const mt=await $e.syncNetwork({privateKeys:vt});W.setDelay(mt)}else W.stop()},1e4,{onError:mt=>{X.error(mt)}}),W.start({wait:!1})}},destroy(){const{log:X,walletId:ne,walletOutput:se}=_.props;if(se==null)return;const{engine:de}=se;de!=null&&P!=null&&(X(`${ne} killEngine`),P.then(()=>de.killEngine()).catch(Be=>_.props.onError(Be)).then(()=>_.props.dispatch({type:"CURRENCY_ENGINE_STOPPED",payload:{walletId:ne}})).catch(()=>{})),W!=null&&W.stop()}}},_=>_.state.paused||_.walletState.paused?void 0:_),syncTimer:v.filterPixie(_=>{async function P(){const{walletId:X}=_.props;await Gi(Wn(_),X)}const W=ki(P,30*1e3);return{update(){const{state:X,walletId:ne,walletOutput:se}=_.props;se!=null&&X.storageWallets[ne]!=null&&X.storageWallets[ne].status.lastSync>0&&W.start({wait:!0})},destroy(){W.stop()}}},_=>_.state.paused||_.walletState.paused?void 0:_),tokenSaver(_){let P=Ii,W=Ii;return async function(){const{detectedTokenIds:ne,enabledTokenIds:se}=_.props.walletState,de=ne!==P||se!==W,Be=ne!=null&&se!=null;de&&Be&&(await ul(_,ne,se).catch(Ae=>_.props.onError(Ae)),await Ca(100)),P=ne,W=se}},watcher(_){let P,W={},X={},ne=Ii;return async()=>{var Mt,Ot;const{state:se,walletState:de,walletOutput:Be}=_.props;if(de==null||Be==null)return;const{engine:Ae,walletApi:Ue}=Be,{accountId:$e,pluginId:nt}=de,Ye=se.accounts[$e];P!==de&&Ue!=null&&y.update(Ue),P=de;const vt=(Mt=Ye.userSettings[nt])!=null?Mt:W;W!==vt&&Ae!=null&&await Ae.changeUserSettings(vt),W=vt;const Et=(Ot=Ye.customTokens[nt])!=null?Ot:X;if(X!==Et&&Ae!=null){if(Ae.changeCustomTokens!=null)await Ae.changeCustomTokens(Et);else if(Ae.addCustomToken!=null)for(const Vt of Object.keys(Et)){const Zt=Et[Vt];if(Zt===X[Vt])continue;const ir=aa(Zt);ir!=null&&await Ae.addCustomToken({...ir,...Zt}).catch(vr=>_.props.onError(vr))}}X=Et;const{allEnabledTokenIds:mt}=de;if(ne!==mt&&Ae!=null){if(Ae.changeEnabledTokenIds!=null)await Ae.changeEnabledTokenIds(mt).catch(Vt=>_.props.onError(Vt));else if(Ae.disableTokens!=null&&Ae.enableTokens!=null){const Vt=ga(Ye.builtinTokens[nt],Ye.customTokens[nt],de.currencyInfo,ni(ne,mt)),Zt=ga(Ye.builtinTokens[nt],Ye.customTokens[nt],de.currencyInfo,ni(mt,ne));await Ae.disableTokens(Vt).catch(ir=>_.props.onError(ir)),await Ae.enableTokens(Zt).catch(ir=>_.props.onError(ir))}}ne=mt}}});async function pf(_,P,W){const X=await xl.load(P,wl);if(X!=null&&(W.checkPublicKey==null||await W.checkPublicKey(X.walletInfo.keys)))return X.walletInfo;let ne={};try{ne=await W.derivePublicKey(_)}catch{}const se={id:_.id,type:_.type,keys:ne};return Object.keys(ne).length>0&&await xl.save(P,wl,{walletInfo:se}),se}async function Qc(_,P){const{stashTree:W}=En(_,P.loginId);await en(_,"POST","/v2/login/delete",Si(W,P))}async function e0(_,P,W){const{allWalletInfosFull:X}=_.props.state.accounts[P],ne=X.find(Ae=>Ae.id===W);if(ne==null)throw new Error(`Invalid wallet id ${W}`);const se=po(_.props.state.plugins.currency,ne.type);if(se==null)return[];const de=await Fn(_,se);return de.getSplittableTypes==null?[]:(await de.getSplittableTypes(ne)).filter(Ae=>{const Ue=Ml(ne,Ae),$e=X.find(nt=>nt.id===Ue.id);return $e==null||$e.archived||$e.deleted})}function Ml(_,P){const{id:W,type:X,keys:ne}=_,se=l.asMaybe(Li)(ne);if(se==null)throw new Error(`Wallet ${W} is not a splittable type`);const{dataKey:de,syncKey:Be}=se,Ae=vf(fn(bt.parse(X),de),fn(bt.parse(P),de)),Ue=vf(o.base64.parse(W),Ae),$e=vf(Be,Ae.subarray(0,Be.length)),nt=X.replace(/wallet:/,"").replace("-",""),Ye=P.replace(/wallet:/,"").replace("-",""),vt=vi({dataKey:de,syncKey:$e});for(const Et of Object.keys(ne)){const mt=Et===nt+"Key"?Ye+"Key":Et;vt[mt]==null&&(vt[mt]=ne[Et])}return{id:o.base64.stringify(Ue),keys:vt,type:P}}async function t0(_,P,W,X){const ne=_.props.state.accounts[P],{allWalletInfosFull:se,login:de,loginTree:Be}=ne,Ae=se.find(vt=>vt.id===W);if(Ae==null)throw new Error(`Invalid wallet id ${W}`);if(X==="wallet:bitcoincash"&&Ae.type==="wallet:bitcoin"&&Ae.keys.format==="bip49")throw new Error("Cannot split segwit-format Bitcoin wallets to Bitcoin Cash");const Ue=X==="wallet:bitcoinsv"&&Ae.type==="wallet:bitcoincash";if(Ue){const vt=_.props.output.currency.wallets[W].walletApi;if(vt==null)throw new Error("Missing Wallet");await r0(vt)}const $e=Ml(Ae,X),nt=se.find(vt=>vt.id===$e.id);if(nt!=null){if(nt.archived||nt.deleted){const vt={};return vt[$e.id]={archived:!1,deleted:!1,migratedFromWalletId:void 0},await Zo(_,P,vt),Ae.id}if(Ue)return $e.id;throw new Error("This wallet has already been split")}const Ye=bi(_,de,[$e]);await nn(_,Be,Ye);try{const vt=await ja(_,$e.id),Et=_.props.output.currency.wallets[W].walletApi;Et!=null&&(Et.name!=null&&await vt.renameWallet(Et.name),Et.fiatCurrencyCode!=null&&await vt.setFiatCurrencyCode(Et.fiatCurrencyCode))}catch(vt){_.props.onError(vt)}return $e.id}async function r0(_){const P={currencyCode:"BCH",tokenId:null},W={...P,spendTargets:[{nativeAmount:"10000",otherParams:{script:{type:"replayProtection"}},publicAddress:""}],metadata:{},networkFeeOption:"high"},X=await _.makeSpend(W),ne=await _.signTx(X),se=await _.broadcastTx(ne);await _.saveTx(se);const{publicAddress:de}=await _.getReceiveAddress(P),Be={...P,metadata:{name:"Replay Protection Tx",notes:"This transaction is to protect your BCH wallet from unintentionally spending BSV funds. Please wait for the transaction to confirm before making additional transactions using this BCH wallet."},networkFeeOption:"high",spendTargets:[{publicAddress:de,nativeAmount:"0"}]},Ae=await _.getMaxSpendable(Be);Be.spendTargets[0].nativeAmount=Ae;const Ue=await _.makeSpend(Be),$e=await _.signTx(Ue),nt=await _.broadcastTx($e);await _.saveTx(nt)}function vf(_,P){if(_.length!==P.length)throw new Error(`Array lengths do not match: ${_.length}, ${P.length}`);const W=new Uint8Array(_.length);for(let X=0;X<_.length;++X)W[X]=_[X]^P[X];return W}async function El(_,P,W){const{stashTree:X}=En(_,P.loginId),ne=await en(_,"POST","/v2/login/vouchers",{...Si(X,P),data:tt(W)}),se=Ei(X,P.loginKey,kt(ne));return await Nn(_,se)}async function Sl(_,P,W,X={}){var Vt,Zt;const{disabled:ne={},noResponseMs:se,preferPluginId:de,promoCodes:Be={},slowResponseMs:Ae=2e4}=X,{log:Ue,state:$e}=_.props,nt=$e.accounts[P],{swapSettings:Ye,userSettings:vt}=nt,Et=$e.plugins.swap;Ue.warn("Requesting swap quotes for: ",{...W,fromWallet:W.fromWallet.id,toWallet:W.toWallet.id},{preferPluginId:de,promoCodes:Be});const mt=new Set,Mt=[];for(const ir of Object.keys(Et)){const{enabled:vr=!0}=Ye[ir]!=null?Ye[ir]:{};!vr||ne[ir]||(mt.add(ir),Mt.push(Et[ir].fetchSwapQuote(W,vt[ir],{infoPayload:(Zt=(Vt=$e.infoCache.corePlugins)==null?void 0:Vt[ir])!=null?Zt:{},promoCode:Be[ir]}).then(br=>{var Lr;const{fromWallet:Pr,toWallet:kr,...Ar}=(Lr=br.request)!=null?Lr:{},_r={...br,request:Ar};return mt.delete(ir),Ue.warn(`${ir} gave swap quote:`,_r),br},br=>{throw mt.delete(ir),Ue.warn(`${ir} gave swap error: ${String(br)}`),br})))}const Ot=Za(Mt,Ae).then(({results:ir,errors:vr})=>{for(const Pr of mt)Ue.warn(`${Pr} gave swap timeout`);const br=i0(ir,X);return Ue.warn(`${Mt.length} swap quotes requested, ${ir.length} resolved, ${vr.length} failed, sorted ${br.map(Pr=>Pr.pluginId).join(", ")}.`),ir.map(Pr=>n0(Et,W,Pr))},ir=>{throw Ue.warn(`All ${Mt.length} swap quotes rejected.`),o0(ir)});return se==null?await Ot:await Xa(Ot,se)}function n0(_,P,W){var ne,se;const X=y.bridgifyObject({canBePartial:W.canBePartial,expirationDate:W.expirationDate,fromNativeAmount:W.fromNativeAmount,isEstimate:W.isEstimate,maxFulfillmentSeconds:W.maxFulfillmentSeconds,networkFee:W.networkFee,pluginId:W.pluginId,request:(ne=W.request)!=null?ne:P,swapInfo:(se=W.swapInfo)!=null?se:_[W.pluginId].swapInfo,toNativeAmount:W.toNativeAmount,async approve(de){return await W.approve(de)},async close(){await W.close(),y.close(X)}});return X}function i0(_,P){const{preferPluginId:W,preferType:X,promoCodes:ne}=P;return _.sort((se,de)=>{if(se.pluginId==="transfer")return-1;if(de.pluginId==="transfer")return 1;if(se.pluginId===W)return-1;if(de.pluginId===W)return 1;if(X!=null){const nt=se.swapInfo.isDex===!0&&X==="DEX"||se.swapInfo.isDex!==!0&&X==="CEX",Ye=de.swapInfo.isDex===!0&&X==="DEX"||de.swapInfo.isDex!==!0&&X==="CEX";if(nt&&!Ye)return-1;if(!nt&&Ye)return 1}if(ne!=null){const nt=ne[se.pluginId]!=null,Ye=ne[de.pluginId]!=null;if(nt&&!Ye)return-1;if(!nt&&Ye)return 1}const{isEstimate:Be=!0}=se,{isEstimate:Ae=!0}=de;if(!Be&&Ae)return-1;if(Be&&!Ae)return 1;const Ue=Number(se.toNativeAmount)/Number(se.fromNativeAmount),$e=Number(de.toNativeAmount)/Number(de.fromNativeAmount);return Ue>$e?-1:$e>Ue?1:0})}function o0(_){return _.reduce((P,W)=>{const X=kl(P)-kl(W);if(X>0)return P;if(X<0)return W;const ne=$n(P),se=$n(W);if(ne!=null&&se!=null)return b.lt(ne.nativeMin,se.nativeMin)?ne:se;const de=pi(P),Be=pi(W);return de!=null&&Be!=null?b.gt(de.nativeMax,Be.nativeMax)?de:Be:P})}function kl(_){return _==null?0:Xn(_)!=null||Bn(_)!=null?6:$n(_)!=null?5:pi(_)!=null?4:yn(_)!=null?3:fo(_)!=null?2:1}const mf=Fr(l.asObject({name:l.asString})),gf=Fr(l.asObject({key:l.asString,data:l.asString}));function a0(_,P){const{accountWalletInfo:W}=_.props.state.accounts[P],X=Kr(_.props.state,W.id),ne=Ae=>mi(_.props.state,W.id,Ae),se=Ae=>`Plugins/${ne(Ae)}`,de=(Ae,Ue)=>`${se(Ae)}/${ne(Ue)}.json`,Be={async deleteItem(Ae,Ue){await X.delete(de(Ae,Ue))},async deleteStore(Ae){await X.delete(se(Ae))},async listItemIds(Ae){const Ue=[],$e=p.justFiles(await X.list(se(Ae)));return await Promise.all($e.map(async nt=>{const Ye=await gf.load(X,nt);Ye!=null&&Ue.push(Ye.key)})),Ue},async listStoreIds(){const Ae=[],Ue=p.justFolders(await X.list("Plugins"));return await Promise.all(Ue.map(async $e=>{const nt=await mf.load(X,`${$e}/Name.json`);nt!=null&&Ae.push(nt.name)})),Ae},async getItem(Ae,Ue){const $e=await gf.load(X,de(Ae,Ue));if($e==null)throw new Error(`No item named "${Ue}"`);return $e.data},async setItem(Ae,Ue,$e){const nt=`${se(Ae)}/Name.json`,Ye=await mf.load(X,nt);if(Ye==null)await mf.save(X,nt,{name:Ae});else if(Ye.name!==Ae)throw new Error(`Warning: folder name doesn't match for ${Ae}`);await gf.save(X,de(Ae,Ue),{key:Ue,data:$e})}};return y.bridgifyObject(Be),Be}const s0={},f0=[];class u0 extends y.Bridgeable{constructor(P,W,X){super(),this._ai=P,this._accountId=W,this._pluginId=X;const{otherMethods:ne}=P.props.state.plugins.currency[X];ne!=null?(y.bridgifyObject(ne),this.otherMethods=ne):this.otherMethods={}}get currencyInfo(){return this._ai.props.state.plugins.currency[this._pluginId].currencyInfo}get allTokens(){const{state:P}=this._ai.props,{_accountId:W,_pluginId:X}=this;return P.accounts[W].allTokens[X]}get builtinTokens(){const{state:P}=this._ai.props,{_accountId:W,_pluginId:X}=this;return P.accounts[W].builtinTokens[X]}get customTokens(){var ne;const{state:P}=this._ai.props,{_accountId:W,_pluginId:X}=this;return(ne=P.accounts[W].customTokens[X])!=null?ne:s0}async addCustomToken(P){const{_accountId:W,_ai:X,_pluginId:ne}=this,se=await gs(X,ne,P);return X.props.dispatch({type:"ACCOUNT_CUSTOM_TOKEN_ADDED",payload:{accountId:W,pluginId:ne,tokenId:se,token:P}}),se}async changeCustomToken(P,W){const{_accountId:X,_ai:ne,_pluginId:se}=this;if(ne.props.state.accounts[X].customTokens[se][P]==null)throw new Error(`There is no token with id "${P}"`);const Be=await gs(ne,se,W);if(ne.props.dispatch({type:"ACCOUNT_CUSTOM_TOKEN_ADDED",payload:{accountId:X,pluginId:se,tokenId:Be,token:W}}),Be!==P){const{wallets:Ae}=ne.props.state.currency;for(const Ue of Object.keys(Ae)){const $e=Ae[Ue];$e.accountId!==X||$e.pluginId!==se||!$e.enabledTokenIds.includes(P)||ne.props.dispatch({type:"CURRENCY_WALLET_ENABLED_TOKENS_CHANGED",payload:{walletId:Ue,enabledTokenIds:ni([...$e.enabledTokenIds,Be],[P])}})}ne.props.dispatch({type:"ACCOUNT_CUSTOM_TOKEN_REMOVED",payload:{accountId:X,pluginId:se,tokenId:P}})}}async removeCustomToken(P){const{_accountId:W,_ai:X,_pluginId:ne}=this;X.props.dispatch({type:"ACCOUNT_CUSTOM_TOKEN_REMOVED",payload:{accountId:W,pluginId:ne,tokenId:P}})}get alwaysEnabledTokenIds(){var ne;const{state:P}=this._ai.props,{_accountId:W,_pluginId:X}=this;return(ne=P.accounts[W].alwaysEnabledTokenIds[X])!=null?ne:f0}async changeAlwaysEnabledTokenIds(P){const{_accountId:W,_ai:X,_pluginId:ne}=this;X.props.dispatch({type:"ACCOUNT_ALWAYS_ENABLED_TOKENS_CHANGED",payload:{accountId:W,pluginId:ne,tokenIds:P}})}get userSettings(){return this._ai.props.state.accounts[this._accountId].userSettings[this._pluginId]}async changeUserSettings(P){await Ha(this._ai,this._accountId,this._pluginId,P)}async importKey(P,W={}){const X=await Fn(this._ai,this._pluginId);if(X.importPrivateKey==null)throw new Error("This wallet does not support importing keys");return{...await X.importPrivateKey(P,W.keyOptions),imported:!0}}}class l0 extends y.Bridgeable{constructor(P,W,X){super(),this._ai=P,this._accountId=W,this._pluginId=X}get enabled(){const{swapSettings:P}=this._ai.props.state.accounts[this._accountId],{enabled:W=!0}=P[this._pluginId]!=null?P[this._pluginId]:{};return W}get needsActivation(){var ne,se;const P=this._ai.props.state.plugins.swap[this._pluginId];if(P.checkSettings==null)return!1;const X=(ne=this._ai.props.state.accounts[this._accountId].userSettings[this._pluginId])!=null?ne:{};return(se=P.checkSettings(X).needsActivation)!=null?se:!1}get swapInfo(){return this._ai.props.state.plugins.swap[this._pluginId].swapInfo}get userSettings(){return this._ai.props.state.accounts[this._accountId].userSettings[this._pluginId]}async changeEnabled(P){const W=this._ai.props.state.accounts[this._accountId];return await Wf(this._ai,this._accountId,this._pluginId,{...W.swapSettings[this._pluginId],enabled:P})}async changeUserSettings(P){await Ha(this._ai,this._accountId,this._pluginId,P)}}function c0(_,P){let W=_.props.state.accounts[P];const X=()=>{const Ye=_.props.state.accounts[P];return Ye!=null&&(W=Ye),W},{accountWalletInfo:ne,loginType:se}=X(),de={};for(const Ye of Object.keys(_.props.state.plugins.currency)){const vt=new u0(_,P,Ye);de[Ye]=vt}const Be={};for(const Ye of Object.keys(_.props.state.plugins.swap)){const vt=new l0(_,P,Ye);Be[Ye]=vt}const Ae=a0(_,P),Ue=xs(_,ne);function $e(){if(_.props.state.hideKeys)throw new Error("Not available when `hideKeys` is enabled")}const nt={on:y.onMethod,watch:y.watchMethod,get id(){return Ue.id},get type(){return Ue.type},get disklet(){return $e(),Ue.disklet},get localDisklet(){return $e(),Ue.localDisklet},async sync(){await Ue.sync()},get appId(){return X().login.appId},get created(){return X().login.created},async getLoginKey(){return $e(),gt.stringify(X().login.loginKey)},get lastLogin(){return X().login.lastLogin},get loggedIn(){return _.props.state.accounts[P]!=null},get recoveryKey(){$e();const{login:Ye}=X();return Ye.recovery2Key!=null?gt.stringify(Ye.recovery2Key):void 0},get rootLoginId(){$e();const{loginTree:Ye}=X();return gt.stringify(Ye.loginId)},get username(){const{loginTree:Ye}=X();return Ye.username},get currencyConfig(){return de},get swapConfig(){return Be},get dataStore(){return Ae},get edgeLogin(){const{loginTree:Ye}=X();return Ye.loginKey==null},keyLogin:se==="keyLogin",newAccount:se==="newAccount",passwordLogin:se==="passwordLogin",pinLogin:se==="pinLogin",recoveryLogin:se==="recoveryLogin",async changePassword(Ye){$e(),await Cs(_,P,Ye)},async changePin(Ye){$e(),await jc(_,P,Ye);const{login:vt}=X();return vt.pin2Key!=null?gt.stringify(vt.pin2Key):""},async changeRecovery(Ye,vt){$e(),await Wu(_,P,Ye,vt);const{loginTree:Et}=X();if(Et.recovery2Key==null)throw new Error("Missing recoveryKey");return gt.stringify(Et.recovery2Key)},async changeUsername(Ye){$e(),Ye.username=s(Ye.username),await Us(_,P,Ye)},async checkPassword(Ye){$e();const{loginTree:vt}=X();return await Nu(_,vt,Ye)},async checkPin(Ye){$e();const{login:vt,loginTree:Et}=X();return vt.pin!=null?Ye===vt.pin:await Uu(_,Et,Ye)},async getPin(){var Et;const{login:Ye,loginTree:vt}=X();return(Et=Ye.pin)!=null?Et:vt.pin},async deletePassword(){$e(),await Lu(_,P)},async deletePin(){$e(),await Hu(_,P)},async deleteRecovery(){$e(),await Wc(_,P)},get otpKey(){$e();const{loginTree:Ye}=X();return Ye.otpKey!=null?o.base32.stringify(Ye.otpKey,{pad:!1}):void 0},get otpResetDate(){$e();const{loginTree:Ye}=X();return Ye.otpResetDate},async cancelOtpReset(){$e(),await eu(_,P)},async enableOtp(Ye=7*24*60*60){$e(),await Jf(_,P,Ye)},async disableOtp(){$e(),await Qf(_,P)},async repairOtp(Ye){$e(),await Ki(_,P,o.base32.parse(Ye,{loose:!0}))},get pendingVouchers(){const{login:Ye}=X();return Ye.pendingVouchers},async approveVoucher(Ye){const{loginTree:vt}=X();return await El(_,vt,{approvedVouchers:[Ye]})},async rejectVoucher(Ye){const{loginTree:vt}=X();return await El(_,vt,{rejectedVouchers:[Ye]})},async fetchLobby(Ye){return $e(),await nl(_,P,Ye)},async deleteRemoteAccount(){const{loginTree:Ye}=X();await Qc(_,Ye)},async logout(){_.props.dispatch({type:"LOGOUT",payload:{accountId:P}})},get allKeys(){return _.props.state.accounts[P].allWalletInfosClean},async changeWalletStates(Ye){await Zo(_,P,Ye)},async createWallet(Ye,vt){const{login:Et,loginTree:mt}=X(),Mt=await mo(_,Ye,{keys:vt});return await nn(_,mt,bi(_,Et,[Mt])),Mt.id},getFirstWalletInfo:c.prototype.getFirstWalletInfo,getWalletInfo:c.prototype.getWalletInfo,listWalletIds:c.prototype.listWalletIds,async splitWalletInfo(Ye,vt){return await t0(_,P,Ye,vt)},async listSplittableWalletTypes(Ye){return await e0(_,P,Ye)},async getDisplayPrivateKey(Ye){const vt=Sa(_,P,Ye),Et=yi(_.props.state.plugins.currency,vt.type),mt=await Fn(_,Et);if(mt.getDisplayPrivateKey!=null)return await mt.getDisplayPrivateKey(vt);const{engine:Mt}=_.props.output.currency.wallets[Ye];if(Mt==null||Mt.getDisplayPrivateSeed==null)throw new Error("Wallet has not yet loaded");const Ot=await Mt.getDisplayPrivateSeed(vt.keys);if(Ot==null)throw new Error("The engine failed to return a key");return Ot},async getDisplayPublicKey(Ye){const vt=Sa(_,P,Ye),Et=yi(_.props.state.plugins.currency,vt.type),mt=await Fn(_,Et);if(mt.getDisplayPublicKey!=null){const Vt=Mo(_.props.io,Ye),Zt=await pf(vt,Vt,mt);return await mt.getDisplayPublicKey(Zt)}const{engine:Mt}=_.props.output.currency.wallets[Ye];if(Mt==null||Mt.getDisplayPublicSeed==null)throw new Error("Wallet has not yet loaded");const Ot=await Mt.getDisplayPublicSeed();if(Ot==null)throw new Error("The engine failed to return a key");return Ot},async getRawPrivateKey(Ye){return Sa(_,P,Ye).keys},async getRawPublicKey(Ye){const vt=Sa(_,P,Ye),Et=yi(_.props.state.plugins.currency,vt.type),mt=await Fn(_,Et),Mt=Mo(_.props.io,Ye);return(await pf(vt,Mt,mt)).keys},get activeWalletIds(){return _.props.state.accounts[P].activeWalletIds},get archivedWalletIds(){return _.props.state.accounts[P].archivedWalletIds},get hiddenWalletIds(){return _.props.state.accounts[P].hiddenWalletIds},get currencyWallets(){return _.props.output.accounts[P].currencyWallets},get currencyWalletErrors(){return _.props.state.accounts[P].currencyWalletErrors},async createCurrencyWallet(Ye,vt={}){const{login:Et,loginTree:mt}=X(),Mt=await mo(_,Ye,vt);return await nn(_,mt,bi(_,Et,[Mt])),await qa(_,P,Mt.id,vt)},async createCurrencyWallets(Ye){const{login:vt,loginTree:Et}=X(),mt=await Promise.all(Ye.map(async Mt=>await mo(_,Mt.walletType,Mt)));return await nn(_,Et,bi(_,vt,mt)),await Promise.all(mt.map(async(Mt,Ot)=>await h0(qa(_,P,Mt.id,Ye[Ot]))))},async waitForCurrencyWallet(Ye){return await new Promise((vt,Et)=>{const mt=()=>{const Vt=this.currencyWallets[Ye];Vt!=null&&(vt(Vt),Mt());const Zt=this.currencyWalletErrors[Ye];Zt!=null&&(Et(Zt),Mt())},Mt=()=>{for(const Vt of Ot)Vt()},Ot=[this.watch("currencyWallets",mt),this.watch("currencyWalletErrors",mt)];mt()})},async waitForAllWallets(){return await new Promise((Ye,vt)=>{const Et=()=>{if(this.activeWalletIds.find(Ot=>this.currencyWallets[Ot]==null&&this.currencyWalletErrors[Ot]==null)==null){for(const Ot of mt)Ot();Ye()}},mt=[this.watch("activeWalletIds",Et),this.watch("currencyWallets",Et),this.watch("currencyWalletErrors",Et)];Et()})},async getActivationAssets({activateWalletId:Ye,activateTokenIds:vt}){const{currencyWallets:Et}=_.props.output.accounts[P],mt=_.props.output.currency.wallets[Ye],{engine:Mt}=mt;if(Mt==null)throw new Error(`Invalid wallet: ${Ye} not found`);if(Mt.engineGetActivationAssets==null)throw new Error(`getActivationAssets unsupported by walletId ${Ye}`);const Ot=await Mt.engineGetActivationAssets({currencyWallets:Et,activateTokenIds:vt});return Ot.assetOptions.forEach(Vt=>{var Zt;return Vt.tokenId=(Zt=Vt.tokenId)!=null?Zt:null}),Ot},async activateWallet(Ye){var br;const{activateWalletId:vt,activateTokenIds:Et,paymentInfo:mt}=Ye,{currencyWallets:Mt}=_.props.output.accounts[P],Ot=_.props.output.currency.wallets[vt],{engine:Vt}=Ot;if(Vt==null)throw new Error(`Invalid wallet: ${vt} not found`);if(Vt.engineActivateWallet==null)throw new Error(`activateWallet unsupported by walletId ${vt}`);const Zt=(br=mt==null?void 0:mt.walletId)!=null?br:"",ir=Mt[Zt];if(ir==null)throw new Error(`No wallet for walletId ${Zt}`);const vr=await Vt.engineActivateWallet({activateTokenIds:Et,paymentInfo:mt!=null?{wallet:ir,tokenId:mt.tokenId}:void 0,paymentTokenId:mt==null?void 0:mt.tokenId,paymentWallet:ir});return vr.networkFee.tokenId===void 0&&(vr.networkFee.tokenId=null),y.bridgifyObject(vr)},async fetchSwapQuote(Ye,vt){const[Et,...mt]=await Sl(_,P,Ye,vt);for(const Mt of mt)Mt.close().catch(()=>{});if(Et==null)throw new Error("No swap providers enabled");return Et},async fetchSwapQuotes(Ye,vt){return await Sl(_,P,Ye,vt)}};return y.bridgifyObject(nt),nt}function Sa(_,P,W){const ne=_.props.state.accounts[P].allWalletInfosFull.find(se=>se.id===W);if(ne==null)throw new Error(`Invalid wallet: ${W} not found`);return ne}async function h0(_){try{return{ok:!0,result:await _}}catch(P){return{ok:!1,error:P}}}const yf={},d0=C.buildReducer({accountWalletInfo:C.memoizeReducer(_=>_.self.appId,_=>_.self.login,(_,P)=>{const W=vo(_),X=Vf(P.keyInfos,W);if(X==null)throw new Error(`Cannot find a "${W}" repo`);return X}),accountWalletInfos:C.memoizeReducer(_=>_.self.appId,_=>_.self.login,(_,P)=>{const W=[vo(_)];return _===""&&W.push("account:repo:co.airbitz.wallet",""),P.keyInfos.filter(X=>W.includes(X.type))}),allWalletInfosFull:C.memoizeReducer(_=>_.self.login,_=>_.self.legacyWalletInfos,_=>_.self.walletStates,(_,P,W)=>{const X=qf(_,P),{walletInfos:ne,appIdMap:se}=X;return ne.map(de=>({appId:v0(se[de.id]),appIds:se[de.id],archived:!1,deleted:!1,hidden:!1,sortIndex:ne.length,...W[de.id],...de}))}),allWalletInfosClean:C.memoizeReducer(_=>_.self.allWalletInfosFull,_=>_.map(P=>({...P,keys:{}}))),currencyWalletErrors(_={},P,W,X){var Ae;const{activeWalletIds:ne}=W.self,se=W.root.currency.wallets;let de=ne!==((Ae=X.self)==null?void 0:Ae.activeWalletIds);const Be={};for(const Ue of ne){const $e=se[Ue].engineFailure;$e!=null&&(Be[Ue]=$e),Be[Ue]!==_[Ue]&&(de=!0)}return de?Be:_},currencyWalletIds:C.memoizeReducer(_=>_.self.walletInfos,_=>_.root.plugins.currency,(_,P)=>Object.keys(_).filter(W=>{const X=_[W],ne=po(P,X.type);return!X.deleted&&ne!=null}).sort((W,X)=>{const ne=_[W],se=_[X];return ne.sortIndex-se.sortIndex})),activeWalletIds:C.memoizeReducer(_=>_.self.walletInfos,_=>_.self.currencyWalletIds,_=>_.self.keysLoaded,(_,P,W)=>W?P.filter(X=>!_[X].archived):[]),archivedWalletIds:C.memoizeReducer(_=>_.self.walletInfos,_=>_.self.currencyWalletIds,_=>_.self.keysLoaded,(_,P,W)=>W?P.filter(X=>_[X].archived):[]),hiddenWalletIds:C.memoizeReducer(_=>_.self.walletInfos,_=>_.self.currencyWalletIds,_=>_.self.keysLoaded,(_,P,W)=>W?P.filter(X=>_[X].hidden):[]),keysLoaded(_=!1,P){return P.type==="ACCOUNT_KEYS_LOADED"?!0:_},legacyWalletInfos(_=[],P){return P.type==="ACCOUNT_KEYS_LOADED"?P.payload.legacyWalletInfos:_},walletInfos:C.memoizeReducer(_=>_.self.allWalletInfosFull,_=>{const P={};for(const W of _)P[W.id]=W;return P}),walletStates(_={},P){return P.type==="ACCOUNT_CHANGED_WALLET_STATES"||P.type==="ACCOUNT_KEYS_LOADED"?P.payload.walletStates:_},pauseWallets(_=!1,P){return P.type==="LOGIN"?P.payload.pauseWallets:_},appId(_="",P){return P.type==="LOGIN"?P.payload.appId:_},hasRootKey(_=!0,P){return P.type==="LOGIN"?P.payload.hasRootKey:_},loadFailure(_=null,P){if(P.type==="ACCOUNT_LOAD_FAILED"){const{error:W}=P.payload;return W instanceof Error?W:new Error(String(W))}return _},login:C.memoizeReducer(_=>_.self.appId,_=>_.self.loginTree,(_,P)=>Po(P,_)),loginKey(_=new Uint8Array(0),P){return P.type==="LOGIN"?P.payload.loginKey:_},loginTree:C.memoizeReducer(_=>_.self.appId,_=>_.self.loginKey,_=>_.self.hasRootKey,_=>_.self.stashTree,(_,P,W,X)=>ji(X,P,W?"":_)),loginType(_="newAccount",P){return P.type==="LOGIN"?P.payload.loginType:_},rootLoginId(_=new Uint8Array(0),P){return P.type==="LOGIN"?P.payload.rootLoginId:_},stashTree:C.memoizeReducer(_=>_.self.rootLoginId,_=>_.root.login.stashes,(_,P)=>{for(const W of P)if(Cr(W.loginId,_))return W;throw new Error("There is no stash")}),allTokens(_={},P,W,X){const{builtinTokens:ne,customTokens:se}=W.self;if(X.self==null||ne!==X.self.builtinTokens||se!==X.self.customTokens){const de={..._};for(const Be of Object.keys(W.root.plugins.currency))(X.self==null||ne[Be]!==X.self.builtinTokens[Be]||se[Be]!==X.self.customTokens[Be])&&(de[Be]={...se[Be],...ne[Be]});return de}return _},builtinTokens(_={},P){switch(P.type){case"ACCOUNT_BUILTIN_TOKENS_LOADED":{const{pluginId:W,tokens:X}=P.payload;return{..._,[W]:X}}}return _},customTokens(_=yf,P){var W,X;switch(P.type){case"ACCOUNT_CUSTOM_TOKENS_LOADED":{const{customTokens:ne}=P.payload;return ne}case"ACCOUNT_CUSTOM_TOKEN_ADDED":{const{pluginId:ne,tokenId:se,token:de}=P.payload,Be=(W=_[ne])!=null?W:{};if(Vi(Be[se],de))return _;const Ae={...Be,[se]:de};return{..._,[ne]:Ae}}case"ACCOUNT_CUSTOM_TOKEN_REMOVED":{const{pluginId:ne,tokenId:se}=P.payload,de=(X=_[ne])!=null?X:{};if(de[se]==null)return _;const{[se]:Be,...Ae}=de;return{..._,[ne]:Ae}}}return _},alwaysEnabledTokenIds(_={},P){switch(P.type){case"ACCOUNT_ALWAYS_ENABLED_TOKENS_CHANGED":{const{pluginId:W,tokenIds:X}=P.payload;return{..._,[W]:X}}}return _},swapSettings(_={},P){switch(P.type){case"ACCOUNT_PLUGIN_SETTINGS_LOADED":return P.payload.swapSettings;case"ACCOUNT_SWAP_SETTINGS_CHANGED":{const{pluginId:W,swapSettings:X}=P.payload,ne={..._};return ne[W]=X,ne}}return _},userSettings(_={},P){switch(P.type){case"ACCOUNT_PLUGIN_SETTINGS_CHANGED":{const{pluginId:W,userSettings:X}=P.payload,ne={..._};return ne[W]=X,ne}case"ACCOUNT_PLUGIN_SETTINGS_LOADED":return P.payload.userSettings}return _}}),p0=C.filterReducer(d0,(_,P)=>/^ACCOUNT_/.test(_.type)&&"payload"in _&&typeof _.payload=="object"&&"accountId"in _.payload&&_.payload.accountId===P.id||_.type==="LOGIN"&&P.root.lastAccountId===P.id?_:{type:"UPDATE_NEXT"});function v0(_){return _[_.length-1]}const m0=v.combinePixies({accountApi(_){return{destroy(){const P=_.props;P.state={accounts:{}};const{accountOutput:W}=_.props;if(W==null)return;const{accountApi:X}=W;if(X==null)return;y.update(X),y.close(X),y.close(X.dataStore);const{currencyConfig:ne,swapConfig:se}=X;for(const de of Object.keys(ne))y.close(ne[de]);for(const de of Object.keys(se))y.close(se[de])},async update(){const P=Wn(_),{accountId:W,accountState:X,log:ne}=_.props,{accountWalletInfos:se}=X;async function de(){await Promise.all([Xo(P,W),pu(P,W),za(P,W)])}try{await Wa(P),await hu(P,W),ne.warn("Login: currency plugins exist"),await Promise.all(se.map(Be=>vs(P,Be))),ne.warn("Login: synced account repos"),await de(),ne.warn("Login: loaded files"),_.onOutput(c0(P,W)),ne.warn("Login: complete")}catch(Be){_.props.dispatch({type:"ACCOUNT_LOAD_FAILED",payload:{accountId:W,error:Be}})}return await v.stopUpdates}}},syncTimer:v.filterPixie(_=>{async function P(){const se=Wn(_),{accountId:de,accountState:Be}=_.props,{accountWalletInfos:Ae}=Be;if(_.props.state.accounts[de]==null)return;const Ue=await Promise.all(Ae.map(nt=>Gi(se,nt.id))),$e=[];for(const nt of Ue)$e.push(...nt);$e.length>0&&await Promise.all([za(se,de),Xo(se,de)])}async function W(){const se=Wn(_),{accountId:de}=_.props;if(_.props.state.accounts[de]==null)return;const{login:Be,loginTree:Ae}=_.props.state.accounts[de];await pn(se,Ae,Be)}const X=ki(P,30*1e3),ne=ki(W,30*1e3,{onError(se){const de=di(se);de!=null&&_.props.onError(de)}});return{update(){var se;((se=_.props.accountOutput)==null?void 0:se.accountApi)!=null&&(X.start({wait:!0}),ne.start({wait:!0}))},destroy(){X.stop(),ne.stop()}}},_=>_.state.paused?void 0:_),tokenSaver(_){let P=yf;return async function(){const{accountId:X,accountState:ne}=_.props,{customTokens:se}=ne;se!==P&&P!==yf&&(await vu(Wn(_),X).catch(de=>_.props.onError(de)),await Ca(100)),P=se}},watcher(_){let P;return()=>{const{accountState:W,accountOutput:X}=_.props;if(W==null||X==null)return;const{accountApi:ne}=X;if(ne!=null&&y.update(ne),P!==W&&(P=W,ne!=null)){const{currencyConfig:se,swapConfig:de}=ne;for(const Be of Object.keys(se))y.update(se[Be]);for(const Be of Object.keys(de))y.update(de[Be])}}},currencyWallets(_){let P;return()=>{var Ue;const{accountOutput:W,accountState:X}=_.props,{activeWalletIds:ne}=X;let se=P!==ne;P=ne;let de={};(W==null?void 0:W.currencyWallets)!=null&&(de=W.currencyWallets);const Be={},{wallets:Ae}=_.props.output.currency;for(const $e of ne){const nt=(Ue=Ae[$e])==null?void 0:Ue.walletApi;nt!==de[$e]&&(se=!0),nt!=null&&(Be[$e]=nt)}se&&_.onOutput(Be)}}}),g0=v.mapPixie(m0,_=>_.state.accountIds,(_,P)=>({..._,accountId:P,accountState:_.state.accounts[P],accountOutput:_.output.accounts[P]}));async function y0(_){const{stashes:P}=_.props.state.login,W={},X=[];for(const Be of P){const{loginId:Ae,username:Ue}=Be;Ue!=null&&(W[o.base64.stringify(Ae)]=Ue,X.push(Ae))}const se=await en(_,"POST","/v2/messages",{loginIds:X}),de=[];for(const Be of ae(se)){const{loginId:Ae,...Ue}=Be,$e=o.base64.stringify(Ae),nt=W[$e];nt!=null&&de.push({...Ue,loginId:$e,username:nt})}return de}class b0 extends y.Bridgeable{constructor(P){super(),this._lobby=P,this._cleanups=[P.close,P.on("reply",W=>y.update(this,"replies")),P.on("error",W=>y.emit(this,"error",W))]}get lobbyId(){return this._lobby.lobbyId}get replies(){return this._lobby.replies}close(){this._cleanups.forEach(P=>P()),y.close(this)}}class w0 extends y.Bridgeable{constructor(P){super(),this._ai=P}authRequest(P,W,X){return en(this._ai,P,W,X)}hashUsername(P){return Hi(this._ai,P)}async makeLobby(P,W=1e3){const X=await Vs(this._ai,P,W);return new b0(X)}fetchLobbyRequest(P){return ma(this._ai,P)}async sendLobbyReply(P,W,X){await qs(this._ai,P,W,X)}async syncRepo(P){const{io:W,syncClient:X}=this._ai.props,ne=Eo(W,{dataKey:new Uint8Array(0),syncKey:P});return await na(X,ne,{lastSync:0,lastHash:void 0})}async getRepoDisklet(P,W){const{io:X}=this._ai.props,ne=Eo(X,{dataKey:W,syncKey:P});return y.bridgifyObject(ne.disklet),ne.disklet}}function x0(_){const P=_.props.state.login.appId,W=gt.stringify(_.props.state.login.clientId),X=new w0(_);let ne;const se={on:y.onMethod,watch:y.watchMethod,appId:P,clientId:W,async close(){_.props.close()},$internalStuff:X,fixUsername:s,get localUsers(){return _.props.state.login.localUsers},async forgetAccount(de){const Be=gt.parse(de);for(const Ae of _.props.state.accountIds){const Ue=_.props.state.accounts[Ae];if(Cr(Ue.stashTree.loginId,Be))throw new Error("Cannot remove logged-in user")}await $a(_,Be)},async usernameAvailable(de){return de=s(de),await zs(_,de)},async createAccount(de){de.username!=null&&(de.username=s(de.username));const Be=await Zu(_,de,de);return await ri(_,P,Be,"newAccount",de)},async loginWithKey(de,Be,Ae={}){const{now:Ue=new Date,useLoginId:$e=!1}=Ae,nt=$e?En(_,gt.parse(de)).stashTree:go(_,s(de));if(nt==null)throw new Error("User does not exist on this device");const Ye=ji(nt,gt.parse(Be),P);return nt.lastLogin=Ue,Nn(_,nt).catch(()=>{}),pn(_,Ye,Po(Ye,P)).catch(vt=>_.props.onError(vt)),await ri(_,P,Ye,"keyLogin",Ae)},async loginWithPassword(de,Be,Ae={}){de=s(de);const Ue=go(_,de),$e=await Fu(_,Ue!=null?Ue:Ya(de),Be,Ae);return await ri(_,P,$e,"passwordLogin",Ae)},checkPasswordRules:h,async loginWithPIN(de,Be,Ae={}){const{useLoginId:Ue=!1}=Ae,$e=Ue?En(_,gt.parse(de)).stashTree:go(_,s(de));if($e==null)throw new Error("User does not exist on this device");const nt=await Du(_,P,$e,Be,Ae);return await ri(_,P,nt,"pinLogin",Ae)},async loginWithRecovery2(de,Be,Ae,Ue={}){Be=s(Be);const $e=go(_,Be),nt=await ju(_,$e!=null?$e:Ya(Be),gt.parse(de),Ae,Ue);return await ri(_,P,nt,"recoveryLogin",Ue)},async fetchRecovery2Questions(de,Be){return Be=s(Be),await Ls(_,gt.parse(de),Be)},async requestEdgeLogin(de){return await Qu(_,P,de)},async requestOtpReset(de,Be){return de=s(de),await tu(_,de,Be)},async fetchLoginMessages(){return await y0(_)},get paused(){return _.props.state.paused},async changePaused(de,Be={}){const{secondsDelay:Ae=0}=Be;ne!=null&&(clearTimeout(ne),ne=void 0),_.props.state.paused!==de&&(Ae===0?_.props.dispatch({type:"PAUSE",payload:de}):ne=setTimeout(()=>{ne=void 0,_.props.dispatch({type:"PAUSE",payload:de})},Ae*1e3))},get logSettings(){return _.props.state.logSettings},async changeLogSettings(de){const Be={..._.props.state.logSettings,...de};_.props.dispatch({type:"CHANGE_LOG_SETTINGS",payload:Be})}};return y.bridgifyObject(se),se}const M0=v.combinePixies({api(_){return{destroy(){y.close(_.props.output.context.api)},update(){return _.onOutput(x0(_)),v.stopUpdates}}},watcher(_){let P,W,X;return()=>{(P!==_.props.state.login.localUsers||W!==_.props.state.paused||X!==_.props.state.logSettings)&&(P=_.props.state.login.localUsers,W=_.props.state.paused,X=_.props.state.logSettings,_.props.output.context.api!=null&&y.update(_.props.output.context.api))}},infoFetcher:v.filterPixie(_=>{async function P(){const{dispatch:X,io:ne}=_.props,[se]=Go(_.props.state.infoServers),de=await fetch(`${se}/v1/coreRollup`,{headers:{accept:"application/json"}});if(!de.ok)return;const Be=await de.json(),Ae=is(Be);X({type:"INFO_CACHE_FETCHED",payload:Ae}),await ea.save(ne.disklet,ns,Ae)}const W=ki(P,10*60*1e3);return W.start(),{update(){},destroy(){W.stop()}}},_=>_.state.paused?void 0:_)});function bf(_,P){if(typeof _!="object"||typeof P!="object"||_==null||P==null)return _===P;const W=Array.isArray(_),X=Array.isArray(P);if(W!==X)return!1;if(W){if(_.length!==P.length)return!1;for(let de=0;de<_.length;++de)if(!bf(_[de],P[de]))return!1;return!0}const ne=Object.getOwnPropertyNames(_).filter(de=>_[de]!==void 0),se=Object.getOwnPropertyNames(P).filter(de=>P[de]!==void 0);if(ne.length!==se.length)return!1;for(const de of ne)if(!Object.prototype.hasOwnProperty.call(P,de)||!bf(_[de],P[de]))return!1;return!0}const E0=v.combinePixies({wallets:v.mapPixie(Jc,_=>_.state.currency.currencyWalletIds,(_,P)=>({..._,walletId:P,walletState:_.state.currency.wallets[P],walletOutput:_.output.currency.wallets[P]})),pluginUpdater(_){let P;return async()=>{var ne,se,de,Be;const{infoCache:W,plugins:X}=_.props.state;if(P!==W){if(P!=null)for(const Ae of Object.keys(X.currency)){const Ue=X.currency[Ae],$e=(se=(ne=W.corePlugins)==null?void 0:ne[Ae])!=null?se:{},nt=(Be=(de=P.corePlugins)==null?void 0:de[Ae])!=null?Be:{};Ue.updateInfoPayload!=null&&!bf(nt,$e)&&await Ue.updateInfoPayload($e)}P=W}}}});function S0(_){let P=Promise.resolve();return function(...X){const ne=()=>_.apply(this,X),se=P.then(ne,ne);return P=se,se}}function k0(_,P,W){const X={salt_hex:_,n:16384,r:8,p:1};if(P===0)return X.n=131072,X.r=8,X.p=64,X;let ne=P;const se=8,Be=8-se,Ae=P/se;let Ue=(W-ne)/Ae;Ue=Ue>0?Ue:0,Ue>Be&&(Ue=Be),Ue=Math.floor(Ue),X.r=se+Ue,ne+=Ue*Ae;let $e=14,nt=(W-ne)/ne;nt=nt>0?nt:0,nt>3&&(nt=3),nt=Math.floor(nt),$e+=nt>=0?nt:0,ne+=nt*ne,X.n=Math.pow(2,$e);let Ye=(W-ne)/ne;return Ye=Ye>0?Ye:0,Ye>64&&(Ye=64),Ye=Math.floor(Ye),X.p=Ye>=1?Ye:1,ne+=Ye*ne,X}const _0=v.combinePixies({makeSnrp:_=>()=>{const{io:P,log:W}=_.props;let X;async function ne(se){X==null&&(X=_.props.output.scrypt.timeScrypt(bt.parse("1reallyJunkiePasswordToCheck"),{salt_hex:o.base16.parse("b5865ffb9fa7b3bfe4b2384d47ce831ee22a4a9d5c34c7ef7d21467cc758f81b"),n:16384,r:8,p:1}).then(Ae=>Ae.time));const de=await X,Be=k0(P.random(32),de,se);return W(`snrp for ${se}ms target: ${Be.n} ${Be.r} ${Be.p} based on ${de}ms benchmark`),Be}return _.onOutput(ne),v.stopUpdates},timeScrypt:_=>()=>{const{io:P,log:W}=_.props,X=typeof window<"u"&&window.performance!=null&&typeof window.performance.now=="function"?()=>window.performance.now():()=>Date.now();function ne(se,de,Be=32){const Ae=de.salt_hex,Ue=X();return W(`starting scrypt n=${de.n} r=${de.r} p=${de.p}`),P.scrypt(se,Ae,de.n,de.r,de.p,Be).then($e=>{const nt=X()-Ue;return W(`finished scrypt n=${de.n} r=${de.r} p=${de.p} in ${nt}ms`),{hash:$e,time:nt}})}return _.onOutput(S0(ne)),v.stopUpdates}}),Wn=_=>_,I0=v.combinePixies({accounts:g0,context:M0,currency:E0,scrypt:_0}),A0=C.buildReducer({currencyWalletIds(_,P,W){if(W.accountIds.length===1){const ne=W.accountIds[0];return W.accounts[ne].activeWalletIds}const X=[];for(const ne of W.accountIds)X.push(...W.accounts[ne].activeWalletIds);return X},wallets:C.mapReducer(qc,_=>_.currency.currencyWalletIds)}),T0=new Uint8Array(0),P0=C.buildReducer({apiKey(_="",P){return P.type==="INIT"?P.payload.apiKey:_},appId(_="",P){return P.type==="INIT"?P.payload.appId:_},clientId(_=T0,P){return P.type==="INIT"?P.payload.clientId:_},deviceDescription(_=null,P){return P.type==="INIT"?P.payload.deviceDescription:_},localUsers:C.memoizeReducer(_=>_.login.appId,_=>_.login.stashes,(_,P)=>{const W=[];for(const X of P){const{lastLogin:ne,loginId:se,recovery2Key:de,username:Be}=X,Ae=Sn(X,nt=>nt.appId===_),Ue=Ae!=null&&(Ae.passwordAuthBox!=null||Ae.loginAuthBox!=null),$e=To(X,_);W.push({keyLoginEnabled:Ue,lastLogin:ne,loginId:gt.stringify(se),pinLoginEnabled:$e!=null,recovery2Key:de!=null?gt.stringify(de):void 0,username:Be,voucherId:Ae!=null?Ae.voucherId:void 0})}return W}),serverUri(_="",P){return P.type==="INIT"?P.payload.authServer:_},stashes(_=[],P){switch(P.type){case"INIT":return P.payload.stashes;case"LOGIN_STASH_DELETED":{const W=P.payload;return _.filter(X=>!Cr(X.loginId,W))}case"LOGIN_STASH_SAVED":{const W=P.payload,X=_.filter(ne=>!Cr(ne.loginId,W.loginId));return X.unshift(W),X}}return _},walletInfos(_,P,W){if(W.accountIds.length===1){const ne=W.accountIds[0];return W.accounts[ne].walletInfos}const X={};for(const ne of W.accountIds){const se=W.accounts[ne];for(const de of Object.keys(se.walletInfos)){const Be=se.walletInfos[de];X[de]=Be}}return X}}),O0={init:{},locked:!1,currency:{},swap:{},currencyTools:{}},B0=(_=O0,P)=>{switch(P.type){case"CORE_PLUGINS_ADDED":{const W={..._,currency:{..._.currency},swap:{..._.swap}};for(const X of Object.keys(P.payload)){const ne=P.payload[X];if(ne==null){W.init={...W.init,[X]:!1};continue}"currencyInfo"in ne&&(W.currency[X]=ne),"swapInfo"in ne&&(W.swap[X]=ne)}return W}case"CORE_PLUGINS_LOCKED":return{..._,locked:!0};case"CURRENCY_TOOLS_LOADED":{const W={..._.currencyTools};return W[P.payload.pluginId]=P.payload.tools,{..._,currencyTools:W}}case"INIT":return{..._,init:P.payload.pluginsInit}}return _},_l=A.combineReducers({lastChanges(_=[],P){if(P.type==="STORAGE_WALLET_SYNCED"){const{changes:W}=P.payload;return W.length>0?W:_}return _},localDisklet(_=null){return _},paths(_=null){return _},status(_={lastSync:0,lastHash:void 0},P){return P.type==="STORAGE_WALLET_SYNCED"?P.payload.status:_}}),R0=function(P={},W){switch(W.type){case"STORAGE_WALLET_ADDED":{const{id:X,initialState:ne}=W.payload,se={...P};return se[X]=_l(ne,{type:"UPDATE_NEXT"}),se}case"STORAGE_WALLET_SYNCED":{const{id:X}=W.payload;if(P[X]!=null){const ne={...P};return ne[X]=_l(P[X],W),ne}return P}}return P},Il={sources:{},defaultLogLevel:"warn"},C0=C.buildReducer({accountCount(_=0,P){return P.type==="LOGIN"?_+1:_},accountIds(_=[],P,W){switch(P.type){case"LOGIN":return[..._,W.lastAccountId];case"LOGOUT":{const{accountId:X}=P.payload,ne=_.filter(se=>se!==X);if(ne.length===_.length)throw new Error(`Login ${X} does not exist`);return ne}case"CLOSE":return[]}return _},accounts:C.mapReducer(p0,_=>_.accountIds),hideKeys(_=!0,P){return P.type==="INIT"?P.payload.hideKeys:_},infoCache(_={},P){switch(P.type){case"INIT":return P.payload.infoCache;case"INFO_CACHE_FETCHED":return P.payload}return _},infoServers(_=[],P){return P.type==="INIT"?P.payload.infoServers:_},lastAccountId(_,P,W){return`login${W.accountCount}`},logSettings(_=Il,P){switch(P.type){case"INIT":return P.payload.logSettings;case"CHANGE_LOG_SETTINGS":return P.payload}return _},paused(_=!1,P){return P.type==="PAUSE"?P.payload:_},ready(_=!1,P){return P.type==="INIT"?!0:_},skipBlockHeight(_=!1,P){return P.type==="INIT"?P.payload.skipBlockHeight:_},syncServers(_=[],P){return P.type==="INIT"?P.payload.syncServers:_},currency:A0,login:P0,plugins:B0,storageWallets:R0});let wf=[];const F0=typeof window=="object"&&window.__REDUX_DEVTOOLS_EXTENSION__!=null?window.__REDUX_DEVTOOLS_EXTENSION__({name:"core"}):void 0;async function Al(_,P,W){const{io:X}=_,{airbitzSupport:ne=!1,apiKey:se,appId:de="",authServer:Be="https://login.edge.app/api",deviceDescription:Ae=null,hideKeys:Ue=!1,infoServer:$e,plugins:nt={},skipBlockHeight:Ye=!1,syncServer:vt}=W,Et=typeof $e=="string"?[$e]:$e!=null&&$e.length>0?$e:["https://info-eu1.edge.app","https://info-us1.edge.app"],mt=typeof vt=="string"?[vt]:vt!=null&&vt.length>0?vt:["https://sync-us1.edge.app","https://sync-us2.edge.app","https://sync-us3.edge.app","https://sync-us4.edge.app","https://sync-us5.edge.app","https://sync-us6.edge.app","https://sync-eu.edge.app"],Mt={...Il,...W.logSettings};if(se==null)throw new Error("No API key provided");Tt(Be),Et.map(_r=>Tt(_r)),mt.map(_r=>Tt(_r));const Ot=A.createStore(C0,F0);P=Wo(P,()=>{const _r=Ot.getState();return _r.ready?_r.logSettings:Mt});const Vt=co(P,"edge-core");let[Zt,ir={},vr]=await Promise.all([rs.load(X.disklet,Qo),ea.load(X.disklet,ns),Yf(X.disklet,Vt)]);if(ne){const _r=new Set;for(const{username:Vr}of vr)Vr!=null&&_r.add(Vr);const Lr=await ru(X,_r);vr.push(...Lr)}Zt==null&&(Zt={clientId:X.random(16)},await rs.save(X.disklet,Qo,Zt)),Ot.dispatch({type:"INIT",payload:{apiKey:se,appId:de,authServer:Be,infoCache:ir,infoServers:Et,syncServers:mt,clientId:Zt.clientId,deviceDescription:Ae,hideKeys:Ue,logSettings:Mt,pluginsInit:nt,skipBlockHeight:Ye,stashes:vr}}),su(_,ir,P,nt,Ot.dispatch);const br=d.makeSyncClient({log:Vt,fetch:X.fetch,edgeServers:{infoServers:Et,syncServers:mt}}),Pr={output:{}},kr=v.attachPixie(Ot,v.filterPixie(I0,_r=>({..._r,close(){kr(),Ot.dispatch({type:"CLOSE"})},io:X,log:Vt,logBackend:P,onError:Lr=>{var Vr;((Vr=Pr.output.context)==null?void 0:Vr.api)!=null&&y.emit(Pr.output.context.api,"error",Lr)},syncClient:br})),_r=>Vt.error(_r),_r=>Pr.output=_r),Ar=Pr.output.context.api;return wf.push(Ar),Ar}function N0(){for(const _ of wf)_.close().catch(()=>{});wf=[]}class L0{constructor(){this.lobbies=new Map,this.logins=[],this.repos=new Map}getLoginById(P){return this.logins.find(W=>Cr(W.loginId,P))}getLoginByUserId(P){return this.logins.find(W=>W.userId==null?Cr(W.loginId,P):Cr(W.userId,P))}getLoginByPin2Id(P){return this.logins.find(W=>W.pin2Id!=null&&Cr(W.pin2Id,P))}getLoginByRecovery2Id(P){return this.logins.find(W=>W.recovery2Id!=null&&Cr(W.recovery2Id,P))}getLoginsByParent(P){return this.logins.filter(W=>W.parentId===P.loginId)}insertLogin(P){this.logins.push(P)}setupLogin(P){const{children:W,...X}=P;this.insertLogin(X);for(const ne of W)ne.parentId=P.loginId,this.setupLogin(ne)}setupRepo(P,W){this.repos.set(P,W)}dumpLogin(P){const W=X=>({...X,children:this.getLoginsByParent(X).map(ne=>W(ne))});return W(P)}}function Bo(_,P){const W=_.getLoginsByParent(P).map(X=>Bo(_,X));return{appId:P.appId,created:P.created,loginId:P.loginId,children:W,parentBox:P.parentBox,passwordAuthBox:P.passwordAuthBox,passwordAuthSnrp:P.passwordAuthSnrp,passwordBox:P.passwordBox,passwordKeySnrp:P.passwordKeySnrp,pin2Box:P.pin2Box,pin2KeyBox:P.pin2KeyBox,pin2TextBox:P.pin2TextBox,question2Box:P.question2Box,recovery2Box:P.recovery2Box,recovery2KeyBox:P.recovery2KeyBox,otpKey:P.otpKey,otpResetDate:P.otpResetDate,otpTimeout:P.otpTimeout,pendingVouchers:Tl(P),loginAuthBox:P.loginAuthBox,userId:P.userId,userTextBox:P.userTextBox,keyBoxes:P.keyBoxes,mnemonicBox:P.mnemonicBox,rootKeyBox:P.rootKeyBox,syncKeyBox:P.syncKeyBox}}function Tl(_){return _.vouchers.filter(P=>P.status==="pending").map(P=>({activates:P.activates,created:P.created,deviceDescription:P.deviceDescription,ip:P.ip,ipDescription:P.ipDescription,voucherId:P.voucherId}))}const Ir={success:{code:0,httpStatus:200,message:"Success"},error:{code:1,httpStatus:503,message:"Error"},accountExists:{code:2,httpStatus:401,message:"Account already exists"},noAccount:{code:3,httpStatus:401,message:"No account"},invalidPassword:{code:4,httpStatus:401,message:"Invalid Password"},invalidAnswers:{code:5,httpStatus:401,message:"Invalid Answers"},invalidApiKey:{code:6,httpStatus:401,message:"Invalid API Key"},invalidOtp:{code:8,httpStatus:401,message:"Invalid OTP"},conflict:{code:10,httpStatus:409,message:"Conflicting change"},obsolete:{code:1e3,httpStatus:410,message:"Obsolete API"},created:{code:0,httpStatus:201,message:"Account created"},invalidRequest:{code:1,httpStatus:401,message:"Invalid request"},notFound:{code:1,httpStatus:404,message:"Not found"},noLobby:{code:3,httpStatus:404,message:"Not found"},invalidAppId:{code:10,httpStatus:401,message:"A login with the same appId already exists"}};function ln(_,P){try{return[_(P),{status:200}]}catch(W){return[void 0,Er(Ir.invalidRequest,`Invalid request: ${String(W)}`)]}}function Zi(_,P={}){const{status:W=200,headers:X={}}=P;return{status:W,headers:{"content-type":"application/json",...X},body:JSON.stringify(_)}}function Er(_=Ir.success,P=_.message){const{code:W,httpStatus:X}=_,ne=Ee({status_code:W,message:P});return Zi(ne,{status:X})}function An(_,P=Ir.success,W=P.message){const{code:X,httpStatus:ne}=P,se=Ee({status_code:X,message:W,results:_});return Zi(se,{status:ne})}function D0(_,P={}){const{reason:W="otp",voucher:X}=P;return An(Qe({login_id:_.loginId,otp_reset_auth:_.otpResetAuth,otp_timeout_date:_.otpResetDate,reason:W,voucher_auth:X==null?void 0:X.voucherAuth,voucher_activates:X==null?void 0:X.activates,voucher_id:X==null?void 0:X.voucherId}),Ir.invalidOtp)}function Yi(_){return An(Oe({wait_seconds:_}),Ir.invalidPassword)}const Nr=_=>async P=>{const{json:W}=P,[X,ne]=ln(H,W);return X==null?ne:await _({...P,body:X,payload:X.data})},ka=_=>async P=>{const{body:W,login:X}=P,{otp:ne,voucherAuth:se,voucherId:de}=W,{otpKey:Be}=X;if(Be==null)return await _(P);if(ne!=null&&Qa(Be,ne,{spread:2}))return await _(P);if(se!=null&&de!=null){const Ue=X.vouchers.find($e=>$e.voucherId===de);if(Ue!=null&&Ue.status==="approved"&&Cr(se,Ue.voucherAuth))return await _(P)}X.otpResetAuth="Super secret reset token";const Ae={activates:new Date("2020-01-01T00:00:00Z"),created:new Date("2020-01-08T00:00:00Z"),deviceDescription:"A phone",ip:"localhost",ipDescription:"here",loginId:X.loginId,status:"pending",voucherAuth:Uint8Array.from([170,187]),voucherId:`voucher-${X.vouchers.length}`};return X.vouchers.push(Ae),D0(X,{voucher:Ae})},U0=_=>Er(Ir.invalidRequest),vn=(_,P=U0)=>W=>{const{db:X,body:ne}=W,{loginAuth:se,loginId:de,passwordAuth:Be,pin2Auth:Ae,pin2Id:Ue,recovery2Auth:$e,recovery2Id:nt,userId:Ye}=ne;if(de!=null&&se!=null){const vt=X.getLoginById(de);return vt==null?Er(Ir.noAccount):vt.loginAuth==null||!Cr(se,vt.loginAuth)?Yi(0):ka(_)({...W,login:vt})}if(Ye!=null&&Be!=null){const vt=X.getLoginByUserId(Ye);return vt==null?Er(Ir.noAccount):vt.passwordAuth==null||!Cr(Be,vt.passwordAuth)?Yi(0):ka(_)({...W,login:vt})}if(Ue!=null&&Ae!=null){const vt=X.getLoginByPin2Id(Ue);return vt==null?Er(Ir.noAccount):vt.pin2Auth==null||!Cr(Ae,vt.pin2Auth)?Yi(0):ka(_)({...W,login:vt})}if(nt!=null&&$e!=null){const vt=X.getLoginByRecovery2Id(nt);if(vt==null)return Er(Ir.noAccount);const Et=vt.recovery2Auth,mt=$e;if(Et==null||mt.length!==Et.length)return Yi(0);for(let Mt=0;Mt<mt.length;++Mt)if(!Cr(mt[Mt],Et[Mt]))return Yi(0);return ka(_)({...W,login:vt})}return P(W)},Pl=vn(_=>{const{db:P,login:W}=_;return An(at(Bo(P,W)))},_=>{const{db:P,json:W}=_,X=H(W),{userId:ne,passwordAuth:se,recovery2Id:de,recovery2Auth:Be}=X;if(ne!=null&&se==null){const Ae=P.getLoginByUserId(ne);if(Ae==null)return Er(Ir.noAccount);const{loginId:Ue,passwordAuthSnrp:$e=Qn}=Ae;return An(Ne({loginId:Ue,passwordAuthSnrp:$e}))}if(de!=null&&Be==null){const Ae=P.getLoginByRecovery2Id(de);if(Ae==null)return Er(Ir.noAccount);const{question2Box:Ue}=Ae;return Ue==null?Er(Ir.noAccount):An(ht({question2Box:Ue}))}return Er(Ir.invalidRequest)});function Ol(_,P){const{db:W,json:X}=_,ne=new Date,[se,de]=ln(H,X);if(se==null)return de;const[Be,Ae]=ln(Pe,se.data);if(Be==null)return Ae;const[Ue,$e]=ln(ce,se.data);if(Ue==null)return $e;if(W.getLoginById(Be.loginId)!=null)return Er(Ir.accountExists);const nt=l.asMaybe(ge,()=>({newSyncKeys:[],keyBoxes:[]}))(se.data);for(const vt of nt.newSyncKeys)W.repos.set(vt,{});const Ye={...Be,...Ue,created:ne,keyBoxes:nt.keyBoxes,vouchers:[],...l.asMaybe(ue)(se.data),...l.asMaybe(be)(se.data),...l.asMaybe(J)(se.data),...l.asMaybe(Ge)(se.data),...l.asMaybe(te)(se.data)};if(P!=null){if(W.getLoginsByParent(P).find(mt=>mt.appId===Be.appId)!=null)return Er(Ir.invalidAppId);Ye.parentId=P.loginId}return W.insertLogin(Ye),Er(Ir.created,"Account created")}const Bl=vn(_=>Ol(_,_.login),_=>Ol(_)),H0=vn(_=>{const{db:P,login:W,payload:X}=_,[ne,se]=ln(ge,X);if(ne==null)return se;for(const de of ne.newSyncKeys)P.repos.set(de,{});return W.keyBoxes=Jn(W.keyBoxes,ne.keyBoxes),Er()}),Rl=vn(_=>{const{login:P,payload:W}=_,[X,ne]=ln(ue,W);return X==null?ne:(P.otpKey=X.otpKey,P.otpTimeout=X.otpTimeout,P.otpResetDate=void 0,Er())}),z0=vn(_=>{const{login:P}=_;return P.otpKey=void 0,P.otpResetAuth=void 0,P.otpResetDate=void 0,P.otpTimeout=void 0,Er()},_=>{const{db:P,json:W}=_,X=H(W);if(X.userId==null||X.otpResetAuth==null)return Er(Ir.invalidRequest);const ne=P.getLoginByUserId(X.userId);if(ne==null)return Er(Ir.noAccount);if(X.otpResetAuth!==ne.otpResetAuth)return Yi(0);const{otpKey:se,otpTimeout:de}=ne;return se==null||de==null?Er(Ir.invalidRequest,"OTP not setup for this account."):(ne.otpResetDate==null&&(ne.otpResetDate=new Date(Date.now()+1e3*de)),An(xe({otpResetDate:ne.otpResetDate})))}),K0=vn(_=>{const{login:P}=_;return P.passwordAuth=void 0,P.passwordAuthBox=void 0,P.passwordAuthSnrp=void 0,P.passwordBox=void 0,P.passwordKeySnrp=void 0,Er()}),Cl=vn(_=>{const{login:P,payload:W}=_,[X,ne]=ln(be,W);return X==null?ne:(P.passwordAuth=X.passwordAuth,P.passwordAuthBox=X.passwordAuthBox,P.passwordAuthSnrp=X.passwordAuthSnrp,P.passwordBox=X.passwordBox,P.passwordKeySnrp=X.passwordKeySnrp,Er())}),j0=vn(_=>{const{login:P}=_;return P.pin2Auth=void 0,P.pin2Box=void 0,P.pin2Id=void 0,P.pin2KeyBox=void 0,P.pin2TextBox=void 0,Er()}),Fl=vn(_=>{const{login:P,payload:W}=_,[X,ne]=ln(J,W);return X==null?ne:(P.pin2Auth=X.pin2Auth,P.pin2Box=X.pin2Box,P.pin2Id=X.pin2Id,P.pin2KeyBox=X.pin2KeyBox,P.pin2TextBox=X.pin2TextBox,Er())}),W0=vn(_=>{const{login:P}=_;return P.question2Box=void 0,P.recovery2Auth=void 0,P.recovery2Box=void 0,P.recovery2Id=void 0,P.recovery2KeyBox=void 0,Er()}),xf=vn(_=>{const{login:P,payload:W}=_,[X,ne]=ln(Ge,W);return X==null?ne:(P.question2Box=X.question2Box,P.recovery2Auth=X.recovery2Auth,P.recovery2Box=X.recovery2Box,P.recovery2Id=X.recovery2Id,P.recovery2KeyBox=X.recovery2KeyBox,Er())}),Nl=vn(_=>{const{db:P,login:W,payload:X}=_,[ne,se]=ln(ce,X);return ne==null?se:W.loginAuth!=null?Er(Ir.conflict,"The secret-key login is already configured"):(W.loginAuth=ne.loginAuth,W.loginAuthBox=ne.loginAuthBox,An(at(Bo(P,W))))}),Ll=vn(async _=>{const{db:P,login:W,payload:X}=_,ne=l.asMaybe(be)(X),se=l.asMaybe(ie)(X),de=l.asMaybe(pe)(X),Be=l.asMaybe(te)(X);if(W.passwordAuth!=null&&ne==null)return Er(Ir.invalidRequest,"Missing password payload");if(W.pin2Auth!=null&&se==null)return Er(Ir.invalidRequest,"Missing pin2Id payload");if(W.recovery2Auth!=null&&de==null)return Er(Ir.invalidRequest,"Missing recovery2Id payload");if(W.parentBox==null&&Be==null)return Er(Ir.invalidRequest,"Missing username payload");if(ne!=null&&(W.passwordAuth=ne.passwordAuth,W.passwordAuthBox=ne.passwordAuthBox,W.passwordAuthSnrp=ne.passwordAuthSnrp,W.passwordBox=ne.passwordBox,W.passwordKeySnrp=ne.passwordKeySnrp),se!=null){if(W.pin2Auth==null)return Er(Ir.invalidRequest,"Login lacks pin2");if(P.getLoginByPin2Id(se.pin2Id)!=null)return Er(Ir.conflict);W.pin2Id=se.pin2Id}if(de!=null){if(W.recovery2Auth==null)return Er(Ir.invalidRequest,"Login lacks recovery2");if(P.getLoginByRecovery2Id(de.recovery2Id)!=null)return Er(Ir.conflict);W.recovery2Id=de.recovery2Id}if(Be!=null){if(W.parentBox!=null)return Er(Ir.invalidRequest,"Only top-level logins can have usernames");if(P.getLoginByUserId(Be.userId)!=null)return Er(Ir.conflict);W.userId=Be.userId,W.userTextBox=Be.userTextBox}return An(at(Bo(P,W)))}),Dl=vn(async _=>{const{db:P,login:W,payload:X}=_,[ne,se]=ln(le,X);if(ne==null)return se;const{approvedVouchers:de=[],rejectedVouchers:Be=[]}=ne,Ae={};for(const Ue of de)Ae[Ue]="approved";for(const Ue of Be)Ae[Ue]="rejected";for(const Ue of W.vouchers)Ae[Ue.voucherId]!=null&&(Ue.status=Ae[Ue.voucherId]);return An(at(Bo(P,W)))}),Gr=_=>Er(Ir.noLobby,`Cannot find lobby ${_.lobbyId}`),Ro=(_,P=Gr)=>W=>{const{db:X,path:ne}=W,se=ne.split("/")[4],de=X.lobbies.get(se);return de!=null?_({...W,lobby:de,lobbyId:se}):P({...W,lobbyId:se})},Ul=Ro(_=>Er(Ir.accountExists,`Lobby ${_.lobbyId} already exists.`),_=>{const{db:P,json:W,lobbyId:X}=_,[ne,se]=ln(H,W);if(ne==null)return se;const[de,Be]=ln(q,ne.data);if(de==null)return Be;const{timeout:Ae=600}=de,Ue=new Date(Date.now()+1e3*Ae).toISOString();return P.lobbies.set(X,{request:de,replies:[],expires:Ue}),Er()}),Hl=Ro(_=>{const{json:P,lobby:W}=_,[X,ne]=ln(H,P);if(X==null)return ne;const[se,de]=ln(re,X.data);return se==null?de:(W.replies.push(se),Er())}),Mf=Ro(_=>{const{lobby:P}=_;return An(rr(P))}),zl=Ro(_=>{const{db:P,lobbyId:W}=_;return P.lobbies.delete(W),Er()}),Kl=_=>{const{db:P,json:W}=_,[X,ne]=ln(H,W);if(X==null)return ne;const{loginIds:se}=X;if(se==null)return Er(Ir.invalidRequest);const de=[];for(const Be of se){const Ae=P.getLoginById(Be);Ae!=null&&de.push({loginId:Be,otpResetPending:Ae.otpResetDate!=null,pendingVouchers:Tl(Ae),recovery2Corrupt:!1})}return An(ft(de))},_a=_=>P=>{const{db:W,path:X}=P,se=X.split("/")[4],de=W.repos.get(se);return de==null?Zi({msg:"Hash not found"},{status:404}):_({...P,repo:de})},jl=_a(_=>{const{repo:P}=_;return Zi({changes:Gt(P)})}),Wl=_a(_=>{const{json:P,repo:W}=_,{changes:X}=Gl(P);for(const ne of Object.keys(X))W[ne]=X[ne];return Zi({changes:Gt(W),hash:"1111111111111111111111111111111111111111"})}),Gl=l.asObject({changes:l.asObject(F)}),ii=_=>Zi({infoServers:["https://info-fake1.edge.app"],syncServers:["https://sync-fake1.edge.app","https://sync-fake2.edge.app","https://sync-fake3.edge.app"]}),Sr=m.pickPath({"/api/v2/login/?":m.pickMethod({GET:Nr(Pl),POST:Nr(Pl)}),"/api/v2/login/create/?":m.pickMethod({POST:Nr(Bl),PUT:Nr(Bl)}),"/api/v2/login/keys/?":m.pickMethod({POST:Nr(H0)}),"/api/v2/login/otp/?":m.pickMethod({DELETE:Nr(z0),POST:Nr(Rl),PUT:Nr(Rl)}),"/api/v2/login/password/?":m.pickMethod({DELETE:Nr(K0),POST:Nr(Cl),PUT:Nr(Cl)}),"/api/v2/login/pin2/?":m.pickMethod({DELETE:Nr(j0),POST:Nr(Fl),PUT:Nr(Fl)}),"/api/v2/login/recovery2/?":m.pickMethod({DELETE:Nr(W0),POST:Nr(xf),PUT:Nr(xf)}),"/api/v2/login/secret/?":m.pickMethod({POST:Nr(Nl)}),"/api/v2/login/username/?":m.pickMethod({POST:Nr(Ll)}),"/api/v2/login/vouchers/?":m.pickMethod({POST:Nr(Dl)}),"/api/v2/messages/?":m.pickMethod({POST:Nr(Kl)}),"/api/v2/lobby/[^/]+/?":m.pickMethod({DELETE:Nr(zl),GET:Nr(Mf),POST:Nr(Hl),PUT:Nr(Ul)}),"/api/v2/store/[^/]+/?":m.pickMethod({GET:jl,POST:Wl}),"/v1/edgeServers":m.pickMethod({GET:ii})},_=>Er(Ir.notFound,`Unknown API endpoint ${_.path}`));function Ai(_){const W=Ko(X=>{if(W.offline)throw new Error("Fake network error");const ne=X.body.byteLength>0?JSON.parse(bt.stringify(new Uint8Array(X.body))):{};return Sr({...X,db:_,json:ne})},{offline:!1});return W}async function wn(_,P){const{lastLogin:W,server:X}=P,ne=o.base64.parse(P.loginId),se=o.base64.parse(P.loginKey),de=P.username==null?void 0:s(P.username),Be=Ei({appId:"",lastLogin:W,loginId:ne,pendingVouchers:[],username:de},se,kt(X)),Ae=`logins/${gt.stringify(ne)}.json`;await _.disklet.setText(Ae,JSON.stringify(Ja(Be))).catch(()=>{})}async function Vl(_,P,W){const X=Eo(_,{dataKey:new Uint8Array(0),syncKey:P});await ds(X.dataDisklet,W),await X.baseDisklet.setText("status.json",JSON.stringify({lastSync:1,lastHash:null}))}function ql(_,P,W){const{io:X,nativeIo:ne}=_,se=new L0,de=Ai(se);for(const Ue of W){se.setupLogin(Xe(Ue.server));for(const $e of Object.keys(Ue.repos))se.setupRepo($e,qe(Ue.repos[$e]))}const Be=[],Ae={async close(){await Promise.all(Be.map(Ue=>Ue.close())),y.close(Ae)},async makeEdgeContext(Ue){const{allowNetworkAccess:$e=!1,cleanDevice:nt=!1,extraFiles:Ye={}}=Ue,vt=m.makeFetchFunction(de),Et=$e?(Ot,Vt)=>{try{Tt(Ot)}catch{return X.fetch(Ot,Vt)}return vt(Ot,Vt)}:vt,mt={...X,disklet:p.makeMemoryDisklet(),fetch:Et};if(!nt)for(const Ot of W){await wn(mt,Ot);for(const Vt of Object.keys(Ot.repos))await Vl(mt,o.base16.parse(Vt),qe(Ot.repos[Vt]))}if(Ye!=null)for(const Ot of Object.keys(Ye))await mt.disklet.setText(Ot,Ye[Ot]);const Mt=await Al({io:mt,nativeIo:ne},P,{...Ue});return Be.push(Mt),Mt},async goOffline(Ue=!0){de.offline=Ue},async dumpFakeUser(Ue){if(Ue.appId!=="")throw new Error("Only root logins are dumpable.");const $e=gt.parse(Ue.rootLoginId),nt=gt.parse(await Ue.getLoginKey()),Ye=se.getLoginById($e);if(Ye==null)throw new Error(`Cannot find user ${Ue.rootLoginId}`);const vt=[];for(const mt of Ue.allKeys){const Mt=await Ue.getRawPrivateKey(mt.id);Mt.syncKey!=null&&vt.push(o.base16.stringify(o.base64.parse(Mt.syncKey)).toLowerCase())}const Et={};for(const mt of vt){const Mt=se.repos.get(mt);Mt!=null&&(Et[mt]=Gt(Mt))}return{lastLogin:Ue.lastLogin,loginId:o.base64.stringify($e),loginKey:o.base64.stringify(nt),repos:Et,server:ot(se.dumpLogin(Ye)),username:Ue.username}}};return y.bridgifyObject(Ae),Ae}const Ia=["allKeys","displayPrivateSeed","displayPublicSeed","keys","otpKey","loginKey","publicWalletInfo","recoveryKey"];function Aa(_){return{random(P){return Uint8Array.from(u.default.randomBytes(P))},scrypt:r,disklet:p.makeNodeDisklet(_),fetch:e.default,fetchCors:e.default}}function Xl(_){const{crashReporter:P,onLog:W=jo,path:X="./edge"}=_;return Al({io:Aa(X),nativeIo:{}},{crashReporter:P,onLog:W},_)}function Zl(_=[],P={}){const{crashReporter:W,onLog:X=jo}=P;return Promise.resolve(y.makeLocalBridge(ql({io:Aa("."),nativeIo:{}},{crashReporter:W,onLog:X},_),{cloneMessage:ne=>JSON.parse(JSON.stringify(ne)),hideProperties:Ia}))}x.WK=Ct,x.DE=Xt,x.k5=Yt,x.Dr=ar,x.ef=or,x.GY=sr,x.WM=$t,x.Kz=nr,x.uX=fr,x.IK=lr,x.gw=dr,x.WU=cr,x.G8=gr,x.xQ=pr,x.D7=dn,x.hi=Jr,x.mJ=au,x.zU=a,x.dq=w,x.m$=D,x.MU=lt,x.ID=ue,x.k0=be,x.D4=ie,x.kL=J,x.jx=pe,x.A_=Ge,x.v1=ce,x.TL=te,x.Og=le,x.ft=ge,x.KU=Pe,x.ZU=F,x.ye=re,x.Xj=q,x.Rn=Xe,x.bo=Z,x.KL=qe,x.rW=V,x.U3=Dt,x.$Y=Le,x.EJ=kt,x.XY=H,x.v7=oe,x.up=Mn,x.h=Kn,x.Cx=Xn,x.Zz=On,x.CU=zo,x.ib=ao,x.eT=di,x._0=Zn,x.UR=Bn,x.Up=so,x.y0=Yn,x.A2=pi,x.ql=$n,x.FX=fo,x.Jr=yn,x.zS=In,x.pK=ae,x.ud=he,x.Zk=je,x.Mf=Ie,x.U0=G,x.CX=Ce,x.l4=ut,x.gU=N0,x.M3=cs,x.Xv=Xl,x.vN=Zl,x.g_=f,x.BN=Aa,x.Jv=st,x.T0=rt,x.z8=Fe,x.Gt=He,x.Fm=yt,x.b4=Ke,x.N2=Ze,x.K8=At,x.gB=Ve,x.bd=tt,x.GG=qt,x.V$=et,x.CC=De,x.dT=ye,x.uT=we,x._j=ot,x.p4=Gt,x.W0=rr,x.zk=at,x.AB=ve,x.sn=Ee,x._u=ft,x.Py=Qe,x.iu=xe,x.l7=Oe,x.JU=ht,x.O6=Ne},5043:function(fe,x,T){"use strict";var S=this&&this.__importDefault||function(Q){return Q&&Q.__esModule?Q:{default:Q}};Object.defineProperty(x,"__esModule",{value:!0}),x.abs=x.toFixed=x.log10=x.max=x.min=x.eq=x.lte=x.gte=x.lt=x.gt=x.div=x.mul=x.sub=x.add=void 0;const y=S(T(4101));function p(Q){return!!(Q.startsWith("0x")||Q.startsWith("-0x")||Q.toLowerCase().includes("a")||Q.toLowerCase().includes("b")||Q.toLowerCase().includes("c")||Q.toLowerCase().includes("d")||Q.toLowerCase().includes("e")||Q.toLowerCase().includes("f"))}function I(Q){return Q.replace("0x","")}function o(Q,Y){let ee=Q;for(let u=0;u<Y;u++)ee+="0";return ee}function m(Q){let Y=Q.replace(/^0+/,"");return Y=Y.replace(/^\.+/,"0."),Y.includes(".")&&(Y=Y.replace(/0+$/,""),Y=Y.replace(/\.+$/,""),Y===""&&(Y="0")),Y===""&&(Y="0"),Y}function l(Q,Y){if(Y===0)return Q;let ee=!1;Q.slice(0,1)==="-"&&(ee=!0,Q=Q.slice(1));let u;return Y>Q.length?u="0."+o("",Y-Q.length)+Q:u=Q.substr(0,Q.length-Y)+"."+Q.substr(Q.length-Y,Q.length),u=m(u),ee&&(u=`-${u}`),u}function g(Q,Y,ee){let u=Q,e=Y;M(u,e);let r=u.indexOf("."),n=e.indexOf(".");const i=p(u),f=p(e);if(r!==-1&&(u=m(u),r=u.indexOf(".")),n!==-1&&(e=m(e),n=e.indexOf(".")),r!==-1||n!==-1||typeof ee=="number"){if(i||f)throw new Error("Cannot operate on base16 float values");let c=0,h=0;r!==-1&&(c=u.length-r-1),n!==-1&&(h=e.length-n-1);const s=c>h?c:h;let t=0;return typeof ee=="number"&&(t=ee),u=o(u.replace(".",""),s+t-c),e=o(e.replace(".",""),s-h),{x:u,y:e,shift:s}}else return{x:u,y:e,shift:0}}function M(...Q){for(const Y of Q){if(Y.split(".").length-1>1)throw new Error("Invalid number: more than one decimal point");if(Y.split("-").length-1>1)throw new Error("Invalid number: more than one negative sign")}}function E(Q,Y,ee=10){if(ee!==10&&ee!==16)throw new Error("Unsupported base");let{x:u,y:e,shift:r}=g(Q,Y);const n=p(u)?16:10,i=p(e)?16:10;u=I(u),e=I(e);const f=new y.default(u,n),c=new y.default(e,i);let h=f.add(c).toString(ee);return h=l(h,r),ee===10?h:"0x"+h}x.add=E;function d(Q,Y,ee=10){if(ee!==10&&ee!==16)throw new Error("Unsupported base");let{x:u,y:e,shift:r}=g(Q,Y);const n=p(u)?16:10,i=p(e)?16:10;u=I(u),e=I(e);const f=new y.default(u,n),c=new y.default(e,i);let h=f.mul(c).toString(ee);return h=l(h,r*2),ee===10?h:"0x"+h}x.mul=d;function A(Q,Y,ee=10){if(ee!==10&&ee!==16)throw new Error("Unsupported base");let{x:u,y:e,shift:r}=g(Q,Y);const n=p(u)?16:10,i=p(e)?16:10;u=I(u),e=I(e);const f=new y.default(u,n),c=new y.default(e,i);let h=f.sub(c).toString(ee);return h=l(h,r),ee===10?h:"0x"+h}x.sub=A;function v(Q,Y,ee=0,u=10){if(u!==10&&ee>0)throw new Error("Cannot operate on floating point hex values");if(u!==10&&u!==16)throw new Error("Unsupported base");let{x:e,y:r}=g(Q,Y,ee);const n=p(e)?16:10,i=p(r)?16:10;e=I(e),r=I(r);const f=new y.default(e,n),c=new y.default(r,i);let h=f.div(c).toString(u);return h=l(h,ee),u===10?h:"0x"+h}x.div=v;function b(Q,Y){let{x:ee,y:u}=g(Q,Y);const e=p(ee)?16:10,r=p(u)?16:10;ee=I(ee),u=I(u);const n=new y.default(ee,e),i=new y.default(u,r);return n.lt(i)}x.lt=b;function k(Q,Y){let{x:ee,y:u}=g(Q,Y);const e=p(ee)?16:10,r=p(u)?16:10;ee=I(ee),u=I(u);const n=new y.default(ee,e),i=new y.default(u,r);return n.lte(i)}x.lte=k;function B(Q,Y){let{x:ee,y:u}=g(Q,Y);const e=p(ee)?16:10,r=p(u)?16:10;ee=I(ee),u=I(u);const n=new y.default(ee,e),i=new y.default(u,r);return n.gt(i)}x.gt=B;function U(Q,Y){let{x:ee,y:u}=g(Q,Y);const e=p(ee)?16:10,r=p(u)?16:10;ee=I(ee),u=I(u);const n=new y.default(ee,e),i=new y.default(u,r);return n.gte(i)}x.gte=U;function C(Q,Y){let{x:ee,y:u}=g(Q,Y);const e=p(ee)?16:10,r=p(u)?16:10;ee=I(ee),u=I(u);const n=new y.default(ee,e),i=new y.default(u,r);return n.eq(i)}x.eq=C;function L(Q,Y,ee=10){let{x:u,y:e,shift:r}=g(Q,Y);const n=p(u)?16:10,i=p(e)?16:10;u=I(u),e=I(e);const f=new y.default(u,n),c=new y.default(e,i);let h;return f.lte(c)?h=f.toString(ee):h=c.toString(ee),h=l(h,r),ee===10?h:"0x"+h}x.min=L;function N(Q,Y=10){if(Y!==10&&Y!==16)throw new Error("Unsupported base");let{x:ee,shift:u}=g(Q,"0");const e=p(Q)?16:10;ee=I(ee);let n=new y.default(ee,e).abs().toString(Y);return n=l(n,u),Y===10?n:"0x"+n}x.abs=N;function j(Q,Y,ee=10){let{x:u,y:e,shift:r}=g(Q,Y);const n=p(u)?16:10,i=p(e)?16:10;u=I(u),e=I(e);const f=new y.default(u,n),c=new y.default(e,i);let h;return f.gte(c)?h=f.toString(ee):h=c.toString(ee),h=l(h,r),ee===10?h:"0x"+h}x.max=j;function K(Q,Y=2,ee=8){M(Q);let u=!1,e="",r=Q;r.includes("-")&&(u=!0,r=r.replace(/^-+/,"")),r=m(r);const n=r.indexOf(".");if(n===-1)e=r+"."+o("",Y);else{const i=r.length-n-1;i>ee?e=r.substr(0,r.length-(i-ee)):i<Y?e=r+o("",Y-i):e=r}return e=e.replace(/\.+$/,""),u&&(e="-"+e),e}x.toFixed=K;function $(Q){if(Q.match(/^[0-1]+$/g)===null)throw new Error("InvalidLogInputValue: Must be a power of 10");if(!Q.startsWith("1"))throw new Error("InvalidLogInputValue: Must not have leading zeros");if((Q.match(/1/g)||[]).length>1)throw new Error("InvalidLogInputValue: Must be power of 10.");return(Q.match(/0/g)||[]).length}x.log10=$},4101:function(fe,x,T){fe=T.nmd(fe),function(S,y){"use strict";function p(u,e){if(!u)throw new Error(e||"Assertion failed")}function I(u,e){u.super_=e;var r=function(){};r.prototype=e.prototype,u.prototype=new r,u.prototype.constructor=u}function o(u,e,r){if(o.isBN(u))return u;this.negative=0,this.words=null,this.length=0,this.red=null,u!==null&&((e==="le"||e==="be")&&(r=e,e=10),this._init(u||0,e||10,r||"be"))}typeof S=="object"?S.exports=o:y.BN=o,o.BN=o,o.wordSize=26;var m;try{typeof window<"u"&&typeof window.Buffer<"u"?m=window.Buffer:m=T(2689).Buffer}catch{}o.isBN=function(e){return e instanceof o?!0:e!==null&&typeof e=="object"&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,r){return e.cmp(r)>0?e:r},o.min=function(e,r){return e.cmp(r)<0?e:r},o.prototype._init=function(e,r,n){if(typeof e=="number")return this._initNumber(e,r,n);if(typeof e=="object")return this._initArray(e,r,n);r==="hex"&&(r=16),p(r===(r|0)&&r>=2&&r<=36),e=e.toString().replace(/\s+/g,"");var i=0;e[0]==="-"&&(i++,this.negative=1),i<e.length&&(r===16?this._parseHex(e,i,n):(this._parseBase(e,r,i),n==="le"&&this._initArray(this.toArray(),r,n)))},o.prototype._initNumber=function(e,r,n){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[e&67108863],this.length=1):e<4503599627370496?(this.words=[e&67108863,e/67108864&67108863],this.length=2):(p(e<9007199254740992),this.words=[e&67108863,e/67108864&67108863,1],this.length=3),n==="le"&&this._initArray(this.toArray(),r,n)},o.prototype._initArray=function(e,r,n){if(p(typeof e.length=="number"),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<this.length;i++)this.words[i]=0;var f,c,h=0;if(n==="be")for(i=e.length-1,f=0;i>=0;i-=3)c=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[f]|=c<<h&67108863,this.words[f+1]=c>>>26-h&67108863,h+=24,h>=26&&(h-=26,f++);else if(n==="le")for(i=0,f=0;i<e.length;i+=3)c=e[i]|e[i+1]<<8|e[i+2]<<16,this.words[f]|=c<<h&67108863,this.words[f+1]=c>>>26-h&67108863,h+=24,h>=26&&(h-=26,f++);return this.strip()};function l(u,e){var r=u.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function g(u,e,r){var n=l(u,r);return r-1>=e&&(n|=l(u,r-1)<<4),n}o.prototype._parseHex=function(e,r,n){this.length=Math.ceil((e.length-r)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var f=0,c=0,h;if(n==="be")for(i=e.length-1;i>=r;i-=2)h=g(e,r,i)<<f,this.words[c]|=h&67108863,f>=18?(f-=18,c+=1,this.words[c]|=h>>>26):f+=8;else{var s=e.length-r;for(i=s%2===0?r+1:r;i<e.length;i+=2)h=g(e,r,i)<<f,this.words[c]|=h&67108863,f>=18?(f-=18,c+=1,this.words[c]|=h>>>26):f+=8}this.strip()};function M(u,e,r,n){for(var i=0,f=Math.min(u.length,r),c=e;c<f;c++){var h=u.charCodeAt(c)-48;i*=n,h>=49?i+=h-49+10:h>=17?i+=h-17+10:i+=h}return i}o.prototype._parseBase=function(e,r,n){this.words=[0],this.length=1;for(var i=0,f=1;f<=67108863;f*=r)i++;i--,f=f/r|0;for(var c=e.length-n,h=c%i,s=Math.min(c,c-h)+n,t=0,a=n;a<s;a+=i)t=M(e,a,a+i,r),this.imuln(f),this.words[0]+t<67108864?this.words[0]+=t:this._iaddn(t);if(h!==0){var w=1;for(t=M(e,a,e.length,r),a=0;a<h;a++)w*=r;this.imuln(w),this.words[0]+t<67108864?this.words[0]+=t:this._iaddn(t)}this.strip()},o.prototype.copy=function(e){e.words=new Array(this.length);for(var r=0;r<this.length;r++)e.words[r]=this.words[r];e.length=this.length,e.negative=this.negative,e.red=this.red},o.prototype.clone=function(){var e=new o(null);return this.copy(e),e},o.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},o.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},o.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var E=["","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"],d=[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],A=[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];o.prototype.toString=function(e,r){e=e||10,r=r|0||1;var n;if(e===16||e==="hex"){n="";for(var i=0,f=0,c=0;c<this.length;c++){var h=this.words[c],s=((h<<i|f)&16777215).toString(16);f=h>>>24-i&16777215,f!==0||c!==this.length-1?n=E[6-s.length]+s+n:n=s+n,i+=2,i>=26&&(i-=26,c--)}for(f!==0&&(n=f.toString(16)+n);n.length%r!==0;)n="0"+n;return this.negative!==0&&(n="-"+n),n}if(e===(e|0)&&e>=2&&e<=36){var t=d[e],a=A[e];n="";var w=this.clone();for(w.negative=0;!w.isZero();){var D=w.modn(a).toString(e);w=w.idivn(a),w.isZero()?n=D+n:n=E[t-D.length]+D+n}for(this.isZero()&&(n="0"+n);n.length%r!==0;)n="0"+n;return this.negative!==0&&(n="-"+n),n}p(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return this.length===2?e+=this.words[1]*67108864:this.length===3&&this.words[2]===1?e+=4503599627370496+this.words[1]*67108864:this.length>2&&p(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,r){return p(typeof m<"u"),this.toArrayLike(m,e,r)},o.prototype.toArray=function(e,r){return this.toArrayLike(Array,e,r)},o.prototype.toArrayLike=function(e,r,n){var i=this.byteLength(),f=n||Math.max(1,i);p(i<=f,"byte array longer than desired length"),p(f>0,"Requested array length <= 0"),this.strip();var c=r==="le",h=new e(f),s,t,a=this.clone();if(c){for(t=0;!a.isZero();t++)s=a.andln(255),a.iushrn(8),h[t]=s;for(;t<f;t++)h[t]=0}else{for(t=0;t<f-i;t++)h[t]=0;for(t=0;!a.isZero();t++)s=a.andln(255),a.iushrn(8),h[f-t-1]=s}return h},Math.clz32?o.prototype._countBits=function(e){return 32-Math.clz32(e)}:o.prototype._countBits=function(e){var r=e,n=0;return r>=4096&&(n+=13,r>>>=13),r>=64&&(n+=7,r>>>=7),r>=8&&(n+=4,r>>>=4),r>=2&&(n+=2,r>>>=2),n+r},o.prototype._zeroBits=function(e){if(e===0)return 26;var r=e,n=0;return r&8191||(n+=13,r>>>=13),r&127||(n+=7,r>>>=7),r&15||(n+=4,r>>>=4),r&3||(n+=2,r>>>=2),r&1||n++,n},o.prototype.bitLength=function(){var e=this.words[this.length-1],r=this._countBits(e);return(this.length-1)*26+r};function v(u){for(var e=new Array(u.bitLength()),r=0;r<e.length;r++){var n=r/26|0,i=r%26;e[r]=(u.words[n]&1<<i)>>>i}return e}o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,r=0;r<this.length;r++){var n=this._zeroBits(this.words[r]);if(e+=n,n!==26)break}return e},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(e){return this.negative!==0?this.abs().inotn(e).iaddn(1):this.clone()},o.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return this.negative!==0},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]|e.words[r];return this.strip()},o.prototype.ior=function(e){return p((this.negative|e.negative)===0),this.iuor(e)},o.prototype.or=function(e){return this.length>e.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 r;this.length>e.length?r=e:r=this;for(var n=0;n<r.length;n++)this.words[n]=this.words[n]&e.words[n];return this.length=r.length,this.strip()},o.prototype.iand=function(e){return p((this.negative|e.negative)===0),this.iuand(e)},o.prototype.and=function(e){return this.length>e.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 r,n;this.length>e.length?(r=this,n=e):(r=e,n=this);for(var i=0;i<n.length;i++)this.words[i]=r.words[i]^n.words[i];if(this!==r)for(;i<r.length;i++)this.words[i]=r.words[i];return this.length=r.length,this.strip()},o.prototype.ixor=function(e){return p((this.negative|e.negative)===0),this.iuxor(e)},o.prototype.xor=function(e){return this.length>e.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){p(typeof e=="number"&&e>=0);var r=Math.ceil(e/26)|0,n=e%26;this._expand(r),n>0&&r--;for(var i=0;i<r;i++)this.words[i]=~this.words[i]&67108863;return n>0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,r){p(typeof e=="number"&&e>=0);var n=e/26|0,i=e%26;return this._expand(n+1),r?this.words[n]=this.words[n]|1<<i:this.words[n]=this.words[n]&~(1<<i),this.strip()},o.prototype.iadd=function(e){var r;if(this.negative!==0&&e.negative===0)return this.negative=0,r=this.isub(e),this.negative^=1,this._normSign();if(this.negative===0&&e.negative!==0)return e.negative=0,r=this.isub(e),e.negative=1,r._normSign();var n,i;this.length>e.length?(n=this,i=e):(n=e,i=this);for(var f=0,c=0;c<i.length;c++)r=(n.words[c]|0)+(i.words[c]|0)+f,this.words[c]=r&67108863,f=r>>>26;for(;f!==0&&c<n.length;c++)r=(n.words[c]|0)+f,this.words[c]=r&67108863,f=r>>>26;if(this.length=n.length,f!==0)this.words[this.length]=f,this.length++;else if(n!==this)for(;c<n.length;c++)this.words[c]=n.words[c];return this},o.prototype.add=function(e){var r;return e.negative!==0&&this.negative===0?(e.negative=0,r=this.sub(e),e.negative^=1,r):e.negative===0&&this.negative!==0?(this.negative=0,r=e.sub(this),this.negative=1,r):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(e.negative!==0){e.negative=0;var r=this.iadd(e);return e.negative=1,r._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var n=this.cmp(e);if(n===0)return this.negative=0,this.length=1,this.words[0]=0,this;var i,f;n>0?(i=this,f=e):(i=e,f=this);for(var c=0,h=0;h<f.length;h++)r=(i.words[h]|0)-(f.words[h]|0)+c,c=r>>26,this.words[h]=r&67108863;for(;c!==0&&h<i.length;h++)r=(i.words[h]|0)+c,c=r>>26,this.words[h]=r&67108863;if(c===0&&h<i.length&&i!==this)for(;h<i.length;h++)this.words[h]=i.words[h];return this.length=Math.max(this.length,h),i!==this&&(this.negative=1),this.strip()},o.prototype.sub=function(e){return this.clone().isub(e)};function b(u,e,r){r.negative=e.negative^u.negative;var n=u.length+e.length|0;r.length=n,n=n-1|0;var i=u.words[0]|0,f=e.words[0]|0,c=i*f,h=c&67108863,s=c/67108864|0;r.words[0]=h;for(var t=1;t<n;t++){for(var a=s>>>26,w=s&67108863,D=Math.min(t,e.length-1),Z=Math.max(0,t-u.length+1);Z<=D;Z++){var F=t-Z|0;i=u.words[F]|0,f=e.words[Z]|0,c=i*f+w,a+=c/67108864|0,w=c&67108863}r.words[t]=w|0,s=a|0}return s!==0?r.words[t]=s|0:r.length--,r.strip()}var k=function(e,r,n){var i=e.words,f=r.words,c=n.words,h=0,s,t,a,w=i[0]|0,D=w&8191,Z=w>>>13,F=i[1]|0,V=F&8191,q=F>>>13,re=i[2]|0,G=re&8191,H=re>>>13,oe=i[3]|0,ue=oe&8191,be=oe>>>13,ie=i[4]|0,J=ie&8191,pe=ie>>>13,Ge=i[5]|0,ce=Ge&8191,te=Ge>>>13,le=i[6]|0,ge=le&8191,Pe=le>>>13,lt=i[7]|0,Le=lt&8191,ze=lt>>>13,kt=i[8]|0,ae=kt&8191,he=kt>>>13,je=i[9]|0,Ie=je&8191,Ce=je>>>13,ut=f[0]|0,De=ut&8191,ye=ut>>>13,we=f[1]|0,ve=we&8191,Ee=we>>>13,rt=f[2]|0,Fe=rt&8191,He=rt>>>13,yt=f[3]|0,Ke=yt&8191,Ze=yt>>>13,At=f[4]|0,Ve=At&8191,tt=At>>>13,qt=f[5]|0,et=qt&8191,st=qt>>>13,rr=f[6]|0,at=rr&8191,ft=rr>>>13,Qe=f[7]|0,xe=Qe&8191,Oe=Qe>>>13,ht=f[8]|0,Ne=ht&8191,qe=ht>>>13,Dt=f[9]|0,Xe=Dt&8191,ot=Dt>>>13;n.negative=e.negative^r.negative,n.length=19,s=Math.imul(D,De),t=Math.imul(D,ye),t=t+Math.imul(Z,De)|0,a=Math.imul(Z,ye);var Gt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,s=Math.imul(V,De),t=Math.imul(V,ye),t=t+Math.imul(q,De)|0,a=Math.imul(q,ye),s=s+Math.imul(D,ve)|0,t=t+Math.imul(D,Ee)|0,t=t+Math.imul(Z,ve)|0,a=a+Math.imul(Z,Ee)|0;var xt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(xt>>>26)|0,xt&=67108863,s=Math.imul(G,De),t=Math.imul(G,ye),t=t+Math.imul(H,De)|0,a=Math.imul(H,ye),s=s+Math.imul(V,ve)|0,t=t+Math.imul(V,Ee)|0,t=t+Math.imul(q,ve)|0,a=a+Math.imul(q,Ee)|0,s=s+Math.imul(D,Fe)|0,t=t+Math.imul(D,He)|0,t=t+Math.imul(Z,Fe)|0,a=a+Math.imul(Z,He)|0;var gt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(gt>>>26)|0,gt&=67108863,s=Math.imul(ue,De),t=Math.imul(ue,ye),t=t+Math.imul(be,De)|0,a=Math.imul(be,ye),s=s+Math.imul(G,ve)|0,t=t+Math.imul(G,Ee)|0,t=t+Math.imul(H,ve)|0,a=a+Math.imul(H,Ee)|0,s=s+Math.imul(V,Fe)|0,t=t+Math.imul(V,He)|0,t=t+Math.imul(q,Fe)|0,a=a+Math.imul(q,He)|0,s=s+Math.imul(D,Ke)|0,t=t+Math.imul(D,Ze)|0,t=t+Math.imul(Z,Ke)|0,a=a+Math.imul(Z,Ze)|0;var bt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(bt>>>26)|0,bt&=67108863,s=Math.imul(J,De),t=Math.imul(J,ye),t=t+Math.imul(pe,De)|0,a=Math.imul(pe,ye),s=s+Math.imul(ue,ve)|0,t=t+Math.imul(ue,Ee)|0,t=t+Math.imul(be,ve)|0,a=a+Math.imul(be,Ee)|0,s=s+Math.imul(G,Fe)|0,t=t+Math.imul(G,He)|0,t=t+Math.imul(H,Fe)|0,a=a+Math.imul(H,He)|0,s=s+Math.imul(V,Ke)|0,t=t+Math.imul(V,Ze)|0,t=t+Math.imul(q,Ke)|0,a=a+Math.imul(q,Ze)|0,s=s+Math.imul(D,Ve)|0,t=t+Math.imul(D,tt)|0,t=t+Math.imul(Z,Ve)|0,a=a+Math.imul(Z,tt)|0;var Tt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,s=Math.imul(ce,De),t=Math.imul(ce,ye),t=t+Math.imul(te,De)|0,a=Math.imul(te,ye),s=s+Math.imul(J,ve)|0,t=t+Math.imul(J,Ee)|0,t=t+Math.imul(pe,ve)|0,a=a+Math.imul(pe,Ee)|0,s=s+Math.imul(ue,Fe)|0,t=t+Math.imul(ue,He)|0,t=t+Math.imul(be,Fe)|0,a=a+Math.imul(be,He)|0,s=s+Math.imul(G,Ke)|0,t=t+Math.imul(G,Ze)|0,t=t+Math.imul(H,Ke)|0,a=a+Math.imul(H,Ze)|0,s=s+Math.imul(V,Ve)|0,t=t+Math.imul(V,tt)|0,t=t+Math.imul(q,Ve)|0,a=a+Math.imul(q,tt)|0,s=s+Math.imul(D,et)|0,t=t+Math.imul(D,st)|0,t=t+Math.imul(Z,et)|0,a=a+Math.imul(Z,st)|0;var Ct=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,s=Math.imul(ge,De),t=Math.imul(ge,ye),t=t+Math.imul(Pe,De)|0,a=Math.imul(Pe,ye),s=s+Math.imul(ce,ve)|0,t=t+Math.imul(ce,Ee)|0,t=t+Math.imul(te,ve)|0,a=a+Math.imul(te,Ee)|0,s=s+Math.imul(J,Fe)|0,t=t+Math.imul(J,He)|0,t=t+Math.imul(pe,Fe)|0,a=a+Math.imul(pe,He)|0,s=s+Math.imul(ue,Ke)|0,t=t+Math.imul(ue,Ze)|0,t=t+Math.imul(be,Ke)|0,a=a+Math.imul(be,Ze)|0,s=s+Math.imul(G,Ve)|0,t=t+Math.imul(G,tt)|0,t=t+Math.imul(H,Ve)|0,a=a+Math.imul(H,tt)|0,s=s+Math.imul(V,et)|0,t=t+Math.imul(V,st)|0,t=t+Math.imul(q,et)|0,a=a+Math.imul(q,st)|0,s=s+Math.imul(D,at)|0,t=t+Math.imul(D,ft)|0,t=t+Math.imul(Z,at)|0,a=a+Math.imul(Z,ft)|0;var Xt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Xt>>>26)|0,Xt&=67108863,s=Math.imul(Le,De),t=Math.imul(Le,ye),t=t+Math.imul(ze,De)|0,a=Math.imul(ze,ye),s=s+Math.imul(ge,ve)|0,t=t+Math.imul(ge,Ee)|0,t=t+Math.imul(Pe,ve)|0,a=a+Math.imul(Pe,Ee)|0,s=s+Math.imul(ce,Fe)|0,t=t+Math.imul(ce,He)|0,t=t+Math.imul(te,Fe)|0,a=a+Math.imul(te,He)|0,s=s+Math.imul(J,Ke)|0,t=t+Math.imul(J,Ze)|0,t=t+Math.imul(pe,Ke)|0,a=a+Math.imul(pe,Ze)|0,s=s+Math.imul(ue,Ve)|0,t=t+Math.imul(ue,tt)|0,t=t+Math.imul(be,Ve)|0,a=a+Math.imul(be,tt)|0,s=s+Math.imul(G,et)|0,t=t+Math.imul(G,st)|0,t=t+Math.imul(H,et)|0,a=a+Math.imul(H,st)|0,s=s+Math.imul(V,at)|0,t=t+Math.imul(V,ft)|0,t=t+Math.imul(q,at)|0,a=a+Math.imul(q,ft)|0,s=s+Math.imul(D,xe)|0,t=t+Math.imul(D,Oe)|0,t=t+Math.imul(Z,xe)|0,a=a+Math.imul(Z,Oe)|0;var Yt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Yt>>>26)|0,Yt&=67108863,s=Math.imul(ae,De),t=Math.imul(ae,ye),t=t+Math.imul(he,De)|0,a=Math.imul(he,ye),s=s+Math.imul(Le,ve)|0,t=t+Math.imul(Le,Ee)|0,t=t+Math.imul(ze,ve)|0,a=a+Math.imul(ze,Ee)|0,s=s+Math.imul(ge,Fe)|0,t=t+Math.imul(ge,He)|0,t=t+Math.imul(Pe,Fe)|0,a=a+Math.imul(Pe,He)|0,s=s+Math.imul(ce,Ke)|0,t=t+Math.imul(ce,Ze)|0,t=t+Math.imul(te,Ke)|0,a=a+Math.imul(te,Ze)|0,s=s+Math.imul(J,Ve)|0,t=t+Math.imul(J,tt)|0,t=t+Math.imul(pe,Ve)|0,a=a+Math.imul(pe,tt)|0,s=s+Math.imul(ue,et)|0,t=t+Math.imul(ue,st)|0,t=t+Math.imul(be,et)|0,a=a+Math.imul(be,st)|0,s=s+Math.imul(G,at)|0,t=t+Math.imul(G,ft)|0,t=t+Math.imul(H,at)|0,a=a+Math.imul(H,ft)|0,s=s+Math.imul(V,xe)|0,t=t+Math.imul(V,Oe)|0,t=t+Math.imul(q,xe)|0,a=a+Math.imul(q,Oe)|0,s=s+Math.imul(D,Ne)|0,t=t+Math.imul(D,qe)|0,t=t+Math.imul(Z,Ne)|0,a=a+Math.imul(Z,qe)|0;var ar=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(ar>>>26)|0,ar&=67108863,s=Math.imul(Ie,De),t=Math.imul(Ie,ye),t=t+Math.imul(Ce,De)|0,a=Math.imul(Ce,ye),s=s+Math.imul(ae,ve)|0,t=t+Math.imul(ae,Ee)|0,t=t+Math.imul(he,ve)|0,a=a+Math.imul(he,Ee)|0,s=s+Math.imul(Le,Fe)|0,t=t+Math.imul(Le,He)|0,t=t+Math.imul(ze,Fe)|0,a=a+Math.imul(ze,He)|0,s=s+Math.imul(ge,Ke)|0,t=t+Math.imul(ge,Ze)|0,t=t+Math.imul(Pe,Ke)|0,a=a+Math.imul(Pe,Ze)|0,s=s+Math.imul(ce,Ve)|0,t=t+Math.imul(ce,tt)|0,t=t+Math.imul(te,Ve)|0,a=a+Math.imul(te,tt)|0,s=s+Math.imul(J,et)|0,t=t+Math.imul(J,st)|0,t=t+Math.imul(pe,et)|0,a=a+Math.imul(pe,st)|0,s=s+Math.imul(ue,at)|0,t=t+Math.imul(ue,ft)|0,t=t+Math.imul(be,at)|0,a=a+Math.imul(be,ft)|0,s=s+Math.imul(G,xe)|0,t=t+Math.imul(G,Oe)|0,t=t+Math.imul(H,xe)|0,a=a+Math.imul(H,Oe)|0,s=s+Math.imul(V,Ne)|0,t=t+Math.imul(V,qe)|0,t=t+Math.imul(q,Ne)|0,a=a+Math.imul(q,qe)|0,s=s+Math.imul(D,Xe)|0,t=t+Math.imul(D,ot)|0,t=t+Math.imul(Z,Xe)|0,a=a+Math.imul(Z,ot)|0;var or=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(or>>>26)|0,or&=67108863,s=Math.imul(Ie,ve),t=Math.imul(Ie,Ee),t=t+Math.imul(Ce,ve)|0,a=Math.imul(Ce,Ee),s=s+Math.imul(ae,Fe)|0,t=t+Math.imul(ae,He)|0,t=t+Math.imul(he,Fe)|0,a=a+Math.imul(he,He)|0,s=s+Math.imul(Le,Ke)|0,t=t+Math.imul(Le,Ze)|0,t=t+Math.imul(ze,Ke)|0,a=a+Math.imul(ze,Ze)|0,s=s+Math.imul(ge,Ve)|0,t=t+Math.imul(ge,tt)|0,t=t+Math.imul(Pe,Ve)|0,a=a+Math.imul(Pe,tt)|0,s=s+Math.imul(ce,et)|0,t=t+Math.imul(ce,st)|0,t=t+Math.imul(te,et)|0,a=a+Math.imul(te,st)|0,s=s+Math.imul(J,at)|0,t=t+Math.imul(J,ft)|0,t=t+Math.imul(pe,at)|0,a=a+Math.imul(pe,ft)|0,s=s+Math.imul(ue,xe)|0,t=t+Math.imul(ue,Oe)|0,t=t+Math.imul(be,xe)|0,a=a+Math.imul(be,Oe)|0,s=s+Math.imul(G,Ne)|0,t=t+Math.imul(G,qe)|0,t=t+Math.imul(H,Ne)|0,a=a+Math.imul(H,qe)|0,s=s+Math.imul(V,Xe)|0,t=t+Math.imul(V,ot)|0,t=t+Math.imul(q,Xe)|0,a=a+Math.imul(q,ot)|0;var sr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(sr>>>26)|0,sr&=67108863,s=Math.imul(Ie,Fe),t=Math.imul(Ie,He),t=t+Math.imul(Ce,Fe)|0,a=Math.imul(Ce,He),s=s+Math.imul(ae,Ke)|0,t=t+Math.imul(ae,Ze)|0,t=t+Math.imul(he,Ke)|0,a=a+Math.imul(he,Ze)|0,s=s+Math.imul(Le,Ve)|0,t=t+Math.imul(Le,tt)|0,t=t+Math.imul(ze,Ve)|0,a=a+Math.imul(ze,tt)|0,s=s+Math.imul(ge,et)|0,t=t+Math.imul(ge,st)|0,t=t+Math.imul(Pe,et)|0,a=a+Math.imul(Pe,st)|0,s=s+Math.imul(ce,at)|0,t=t+Math.imul(ce,ft)|0,t=t+Math.imul(te,at)|0,a=a+Math.imul(te,ft)|0,s=s+Math.imul(J,xe)|0,t=t+Math.imul(J,Oe)|0,t=t+Math.imul(pe,xe)|0,a=a+Math.imul(pe,Oe)|0,s=s+Math.imul(ue,Ne)|0,t=t+Math.imul(ue,qe)|0,t=t+Math.imul(be,Ne)|0,a=a+Math.imul(be,qe)|0,s=s+Math.imul(G,Xe)|0,t=t+Math.imul(G,ot)|0,t=t+Math.imul(H,Xe)|0,a=a+Math.imul(H,ot)|0;var $t=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+($t>>>26)|0,$t&=67108863,s=Math.imul(Ie,Ke),t=Math.imul(Ie,Ze),t=t+Math.imul(Ce,Ke)|0,a=Math.imul(Ce,Ze),s=s+Math.imul(ae,Ve)|0,t=t+Math.imul(ae,tt)|0,t=t+Math.imul(he,Ve)|0,a=a+Math.imul(he,tt)|0,s=s+Math.imul(Le,et)|0,t=t+Math.imul(Le,st)|0,t=t+Math.imul(ze,et)|0,a=a+Math.imul(ze,st)|0,s=s+Math.imul(ge,at)|0,t=t+Math.imul(ge,ft)|0,t=t+Math.imul(Pe,at)|0,a=a+Math.imul(Pe,ft)|0,s=s+Math.imul(ce,xe)|0,t=t+Math.imul(ce,Oe)|0,t=t+Math.imul(te,xe)|0,a=a+Math.imul(te,Oe)|0,s=s+Math.imul(J,Ne)|0,t=t+Math.imul(J,qe)|0,t=t+Math.imul(pe,Ne)|0,a=a+Math.imul(pe,qe)|0,s=s+Math.imul(ue,Xe)|0,t=t+Math.imul(ue,ot)|0,t=t+Math.imul(be,Xe)|0,a=a+Math.imul(be,ot)|0;var nr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(nr>>>26)|0,nr&=67108863,s=Math.imul(Ie,Ve),t=Math.imul(Ie,tt),t=t+Math.imul(Ce,Ve)|0,a=Math.imul(Ce,tt),s=s+Math.imul(ae,et)|0,t=t+Math.imul(ae,st)|0,t=t+Math.imul(he,et)|0,a=a+Math.imul(he,st)|0,s=s+Math.imul(Le,at)|0,t=t+Math.imul(Le,ft)|0,t=t+Math.imul(ze,at)|0,a=a+Math.imul(ze,ft)|0,s=s+Math.imul(ge,xe)|0,t=t+Math.imul(ge,Oe)|0,t=t+Math.imul(Pe,xe)|0,a=a+Math.imul(Pe,Oe)|0,s=s+Math.imul(ce,Ne)|0,t=t+Math.imul(ce,qe)|0,t=t+Math.imul(te,Ne)|0,a=a+Math.imul(te,qe)|0,s=s+Math.imul(J,Xe)|0,t=t+Math.imul(J,ot)|0,t=t+Math.imul(pe,Xe)|0,a=a+Math.imul(pe,ot)|0;var fr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(fr>>>26)|0,fr&=67108863,s=Math.imul(Ie,et),t=Math.imul(Ie,st),t=t+Math.imul(Ce,et)|0,a=Math.imul(Ce,st),s=s+Math.imul(ae,at)|0,t=t+Math.imul(ae,ft)|0,t=t+Math.imul(he,at)|0,a=a+Math.imul(he,ft)|0,s=s+Math.imul(Le,xe)|0,t=t+Math.imul(Le,Oe)|0,t=t+Math.imul(ze,xe)|0,a=a+Math.imul(ze,Oe)|0,s=s+Math.imul(ge,Ne)|0,t=t+Math.imul(ge,qe)|0,t=t+Math.imul(Pe,Ne)|0,a=a+Math.imul(Pe,qe)|0,s=s+Math.imul(ce,Xe)|0,t=t+Math.imul(ce,ot)|0,t=t+Math.imul(te,Xe)|0,a=a+Math.imul(te,ot)|0;var lr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(lr>>>26)|0,lr&=67108863,s=Math.imul(Ie,at),t=Math.imul(Ie,ft),t=t+Math.imul(Ce,at)|0,a=Math.imul(Ce,ft),s=s+Math.imul(ae,xe)|0,t=t+Math.imul(ae,Oe)|0,t=t+Math.imul(he,xe)|0,a=a+Math.imul(he,Oe)|0,s=s+Math.imul(Le,Ne)|0,t=t+Math.imul(Le,qe)|0,t=t+Math.imul(ze,Ne)|0,a=a+Math.imul(ze,qe)|0,s=s+Math.imul(ge,Xe)|0,t=t+Math.imul(ge,ot)|0,t=t+Math.imul(Pe,Xe)|0,a=a+Math.imul(Pe,ot)|0;var dr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(dr>>>26)|0,dr&=67108863,s=Math.imul(Ie,xe),t=Math.imul(Ie,Oe),t=t+Math.imul(Ce,xe)|0,a=Math.imul(Ce,Oe),s=s+Math.imul(ae,Ne)|0,t=t+Math.imul(ae,qe)|0,t=t+Math.imul(he,Ne)|0,a=a+Math.imul(he,qe)|0,s=s+Math.imul(Le,Xe)|0,t=t+Math.imul(Le,ot)|0,t=t+Math.imul(ze,Xe)|0,a=a+Math.imul(ze,ot)|0;var cr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(cr>>>26)|0,cr&=67108863,s=Math.imul(Ie,Ne),t=Math.imul(Ie,qe),t=t+Math.imul(Ce,Ne)|0,a=Math.imul(Ce,qe),s=s+Math.imul(ae,Xe)|0,t=t+Math.imul(ae,ot)|0,t=t+Math.imul(he,Xe)|0,a=a+Math.imul(he,ot)|0;var gr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(gr>>>26)|0,gr&=67108863,s=Math.imul(Ie,Xe),t=Math.imul(Ie,ot),t=t+Math.imul(Ce,Xe)|0,a=Math.imul(Ce,ot);var pr=(h+s|0)+((t&8191)<<13)|0;return h=(a+(t>>>13)|0)+(pr>>>26)|0,pr&=67108863,c[0]=Gt,c[1]=xt,c[2]=gt,c[3]=bt,c[4]=Tt,c[5]=Ct,c[6]=Xt,c[7]=Yt,c[8]=ar,c[9]=or,c[10]=sr,c[11]=$t,c[12]=nr,c[13]=fr,c[14]=lr,c[15]=dr,c[16]=cr,c[17]=gr,c[18]=pr,h!==0&&(c[19]=h,n.length++),n};Math.imul||(k=b);function B(u,e,r){r.negative=e.negative^u.negative,r.length=u.length+e.length;for(var n=0,i=0,f=0;f<r.length-1;f++){var c=i;i=0;for(var h=n&67108863,s=Math.min(f,e.length-1),t=Math.max(0,f-u.length+1);t<=s;t++){var a=f-t,w=u.words[a]|0,D=e.words[t]|0,Z=w*D,F=Z&67108863;c=c+(Z/67108864|0)|0,F=F+h|0,h=F&67108863,c=c+(F>>>26)|0,i+=c>>>26,c&=67108863}r.words[f]=h,n=c,c=i}return n!==0?r.words[f]=n:r.length--,r.strip()}function U(u,e,r){var n=new C;return n.mulp(u,e,r)}o.prototype.mulTo=function(e,r){var n,i=this.length+e.length;return this.length===10&&e.length===10?n=k(this,e,r):i<63?n=b(this,e,r):i<1024?n=B(this,e,r):n=U(this,e,r),n};function C(u,e){this.x=u,this.y=e}C.prototype.makeRBT=function(e){for(var r=new Array(e),n=o.prototype._countBits(e)-1,i=0;i<e;i++)r[i]=this.revBin(i,n,e);return r},C.prototype.revBin=function(e,r,n){if(e===0||e===n-1)return e;for(var i=0,f=0;f<r;f++)i|=(e&1)<<r-f-1,e>>=1;return i},C.prototype.permute=function(e,r,n,i,f,c){for(var h=0;h<c;h++)i[h]=r[e[h]],f[h]=n[e[h]]},C.prototype.transform=function(e,r,n,i,f,c){this.permute(c,e,r,n,i,f);for(var h=1;h<f;h<<=1)for(var s=h<<1,t=Math.cos(2*Math.PI/s),a=Math.sin(2*Math.PI/s),w=0;w<f;w+=s)for(var D=t,Z=a,F=0;F<h;F++){var V=n[w+F],q=i[w+F],re=n[w+F+h],G=i[w+F+h],H=D*re-Z*G;G=D*G+Z*re,re=H,n[w+F]=V+re,i[w+F]=q+G,n[w+F+h]=V-re,i[w+F+h]=q-G,F!==s&&(H=t*D-a*Z,Z=t*Z+a*D,D=H)}},C.prototype.guessLen13b=function(e,r){var n=Math.max(r,e)|1,i=n&1,f=0;for(n=n/2|0;n;n=n>>>1)f++;return 1<<f+1+i},C.prototype.conjugate=function(e,r,n){if(!(n<=1))for(var i=0;i<n/2;i++){var f=e[i];e[i]=e[n-i-1],e[n-i-1]=f,f=r[i],r[i]=-r[n-i-1],r[n-i-1]=-f}},C.prototype.normalize13b=function(e,r){for(var n=0,i=0;i<r/2;i++){var f=Math.round(e[2*i+1]/r)*8192+Math.round(e[2*i]/r)+n;e[i]=f&67108863,f<67108864?n=0:n=f/67108864|0}return e},C.prototype.convert13b=function(e,r,n,i){for(var f=0,c=0;c<r;c++)f=f+(e[c]|0),n[2*c]=f&8191,f=f>>>13,n[2*c+1]=f&8191,f=f>>>13;for(c=2*r;c<i;++c)n[c]=0;p(f===0),p((f&-8192)===0)},C.prototype.stub=function(e){for(var r=new Array(e),n=0;n<e;n++)r[n]=0;return r},C.prototype.mulp=function(e,r,n){var i=2*this.guessLen13b(e.length,r.length),f=this.makeRBT(i),c=this.stub(i),h=new Array(i),s=new Array(i),t=new Array(i),a=new Array(i),w=new Array(i),D=new Array(i),Z=n.words;Z.length=i,this.convert13b(e.words,e.length,h,i),this.convert13b(r.words,r.length,a,i),this.transform(h,c,s,t,i,f),this.transform(a,c,w,D,i,f);for(var F=0;F<i;F++){var V=s[F]*w[F]-t[F]*D[F];t[F]=s[F]*D[F]+t[F]*w[F],s[F]=V}return this.conjugate(s,t,i),this.transform(s,t,Z,c,i,f),this.conjugate(Z,c,i),this.normalize13b(Z,i),n.negative=e.negative^r.negative,n.length=e.length+r.length,n.strip()},o.prototype.mul=function(e){var r=new o(null);return r.words=new Array(this.length+e.length),this.mulTo(e,r)},o.prototype.mulf=function(e){var r=new o(null);return r.words=new Array(this.length+e.length),U(this,e,r)},o.prototype.imul=function(e){return this.clone().mulTo(e,this)},o.prototype.imuln=function(e){p(typeof e=="number"),p(e<67108864);for(var r=0,n=0;n<this.length;n++){var i=(this.words[n]|0)*e,f=(i&67108863)+(r&67108863);r>>=26,r+=i/67108864|0,r+=f>>>26,this.words[n]=f&67108863}return r!==0&&(this.words[n]=r,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 r=v(e);if(r.length===0)return new o(1);for(var n=this,i=0;i<r.length&&r[i]===0;i++,n=n.sqr());if(++i<r.length)for(var f=n.sqr();i<r.length;i++,f=f.sqr())r[i]!==0&&(n=n.mul(f));return n},o.prototype.iushln=function(e){p(typeof e=="number"&&e>=0);var r=e%26,n=(e-r)/26,i=67108863>>>26-r<<26-r,f;if(r!==0){var c=0;for(f=0;f<this.length;f++){var h=this.words[f]&i,s=(this.words[f]|0)-h<<r;this.words[f]=s|c,c=h>>>26-r}c&&(this.words[f]=c,this.length++)}if(n!==0){for(f=this.length-1;f>=0;f--)this.words[f+n]=this.words[f];for(f=0;f<n;f++)this.words[f]=0;this.length+=n}return this.strip()},o.prototype.ishln=function(e){return p(this.negative===0),this.iushln(e)},o.prototype.iushrn=function(e,r,n){p(typeof e=="number"&&e>=0);var i;r?i=(r-r%26)/26:i=0;var f=e%26,c=Math.min((e-f)/26,this.length),h=67108863^67108863>>>f<<f,s=n;if(i-=c,i=Math.max(0,i),s){for(var t=0;t<c;t++)s.words[t]=this.words[t];s.length=c}if(c!==0)if(this.length>c)for(this.length-=c,t=0;t<this.length;t++)this.words[t]=this.words[t+c];else this.words[0]=0,this.length=1;var a=0;for(t=this.length-1;t>=0&&(a!==0||t>=i);t--){var w=this.words[t]|0;this.words[t]=a<<26-f|w>>>f,a=w&h}return s&&a!==0&&(s.words[s.length++]=a),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,r,n){return p(this.negative===0),this.iushrn(e,r,n)},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){p(typeof e=="number"&&e>=0);var r=e%26,n=(e-r)/26,i=1<<r;if(this.length<=n)return!1;var f=this.words[n];return!!(f&i)},o.prototype.imaskn=function(e){p(typeof e=="number"&&e>=0);var r=e%26,n=(e-r)/26;if(p(this.negative===0,"imaskn works only with positive numbers"),this.length<=n)return this;if(r!==0&&n++,this.length=Math.min(n,this.length),r!==0){var i=67108863^67108863>>>r<<r;this.words[this.length-1]&=i}return this.strip()},o.prototype.maskn=function(e){return this.clone().imaskn(e)},o.prototype.iaddn=function(e){return p(typeof e=="number"),p(e<67108864),e<0?this.isubn(-e):this.negative!==0?this.length===1&&(this.words[0]|0)<e?(this.words[0]=e-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this):this._iaddn(e)},o.prototype._iaddn=function(e){this.words[0]+=e;for(var r=0;r<this.length&&this.words[r]>=67108864;r++)this.words[r]-=67108864,r===this.length-1?this.words[r+1]=1:this.words[r+1]++;return this.length=Math.max(this.length,r+1),this},o.prototype.isubn=function(e){if(p(typeof e=="number"),p(e<67108864),e<0)return this.iaddn(-e);if(this.negative!==0)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var r=0;r<this.length&&this.words[r]<0;r++)this.words[r]+=67108864,this.words[r+1]-=1;return this.strip()},o.prototype.addn=function(e){return this.clone().iaddn(e)},o.prototype.subn=function(e){return this.clone().isubn(e)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(e,r,n){var i=e.length+n,f;this._expand(i);var c,h=0;for(f=0;f<e.length;f++){c=(this.words[f+n]|0)+h;var s=(e.words[f]|0)*r;c-=s&67108863,h=(c>>26)-(s/67108864|0),this.words[f+n]=c&67108863}for(;f<this.length-n;f++)c=(this.words[f+n]|0)+h,h=c>>26,this.words[f+n]=c&67108863;if(h===0)return this.strip();for(p(h===-1),h=0,f=0;f<this.length;f++)c=-(this.words[f]|0)+h,h=c>>26,this.words[f]=c&67108863;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,r){var n=this.length-e.length,i=this.clone(),f=e,c=f.words[f.length-1]|0,h=this._countBits(c);n=26-h,n!==0&&(f=f.ushln(n),i.iushln(n),c=f.words[f.length-1]|0);var s=i.length-f.length,t;if(r!=="mod"){t=new o(null),t.length=s+1,t.words=new Array(t.length);for(var a=0;a<t.length;a++)t.words[a]=0}var w=i.clone()._ishlnsubmul(f,1,s);w.negative===0&&(i=w,t&&(t.words[s]=1));for(var D=s-1;D>=0;D--){var Z=(i.words[f.length+D]|0)*67108864+(i.words[f.length+D-1]|0);for(Z=Math.min(Z/c|0,67108863),i._ishlnsubmul(f,Z,D);i.negative!==0;)Z--,i.negative=0,i._ishlnsubmul(f,1,D),i.isZero()||(i.negative^=1);t&&(t.words[D]=Z)}return t&&t.strip(),i.strip(),r!=="div"&&n!==0&&i.iushrn(n),{div:t||null,mod:i}},o.prototype.divmod=function(e,r,n){if(p(!e.isZero()),this.isZero())return{div:new o(0),mod:new o(0)};var i,f,c;return this.negative!==0&&e.negative===0?(c=this.neg().divmod(e,r),r!=="mod"&&(i=c.div.neg()),r!=="div"&&(f=c.mod.neg(),n&&f.negative!==0&&f.iadd(e)),{div:i,mod:f}):this.negative===0&&e.negative!==0?(c=this.divmod(e.neg(),r),r!=="mod"&&(i=c.div.neg()),{div:i,mod:c.mod}):this.negative&e.negative?(c=this.neg().divmod(e.neg(),r),r!=="div"&&(f=c.mod.neg(),n&&f.negative!==0&&f.isub(e)),{div:c.div,mod:f}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:e.length===1?r==="div"?{div:this.divn(e.words[0]),mod:null}:r==="mod"?{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,r)},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 r=this.divmod(e);if(r.mod.isZero())return r.div;var n=r.div.negative!==0?r.mod.isub(e):r.mod,i=e.ushrn(1),f=e.andln(1),c=n.cmp(i);return c<0||f===1&&c===0?r.div:r.div.negative!==0?r.div.isubn(1):r.div.iaddn(1)},o.prototype.modn=function(e){p(e<=67108863);for(var r=(1<<26)%e,n=0,i=this.length-1;i>=0;i--)n=(r*n+(this.words[i]|0))%e;return n},o.prototype.idivn=function(e){p(e<=67108863);for(var r=0,n=this.length-1;n>=0;n--){var i=(this.words[n]|0)+r*67108864;this.words[n]=i/e|0,r=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){p(e.negative===0),p(!e.isZero());var r=this,n=e.clone();r.negative!==0?r=r.umod(e):r=r.clone();for(var i=new o(1),f=new o(0),c=new o(0),h=new o(1),s=0;r.isEven()&&n.isEven();)r.iushrn(1),n.iushrn(1),++s;for(var t=n.clone(),a=r.clone();!r.isZero();){for(var w=0,D=1;!(r.words[0]&D)&&w<26;++w,D<<=1);if(w>0)for(r.iushrn(w);w-- >0;)(i.isOdd()||f.isOdd())&&(i.iadd(t),f.isub(a)),i.iushrn(1),f.iushrn(1);for(var Z=0,F=1;!(n.words[0]&F)&&Z<26;++Z,F<<=1);if(Z>0)for(n.iushrn(Z);Z-- >0;)(c.isOdd()||h.isOdd())&&(c.iadd(t),h.isub(a)),c.iushrn(1),h.iushrn(1);r.cmp(n)>=0?(r.isub(n),i.isub(c),f.isub(h)):(n.isub(r),c.isub(i),h.isub(f))}return{a:c,b:h,gcd:n.iushln(s)}},o.prototype._invmp=function(e){p(e.negative===0),p(!e.isZero());var r=this,n=e.clone();r.negative!==0?r=r.umod(e):r=r.clone();for(var i=new o(1),f=new o(0),c=n.clone();r.cmpn(1)>0&&n.cmpn(1)>0;){for(var h=0,s=1;!(r.words[0]&s)&&h<26;++h,s<<=1);if(h>0)for(r.iushrn(h);h-- >0;)i.isOdd()&&i.iadd(c),i.iushrn(1);for(var t=0,a=1;!(n.words[0]&a)&&t<26;++t,a<<=1);if(t>0)for(n.iushrn(t);t-- >0;)f.isOdd()&&f.iadd(c),f.iushrn(1);r.cmp(n)>=0?(r.isub(n),i.isub(f)):(n.isub(r),f.isub(i))}var w;return r.cmpn(1)===0?w=i:w=f,w.cmpn(0)<0&&w.iadd(e),w},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var r=this.clone(),n=e.clone();r.negative=0,n.negative=0;for(var i=0;r.isEven()&&n.isEven();i++)r.iushrn(1),n.iushrn(1);do{for(;r.isEven();)r.iushrn(1);for(;n.isEven();)n.iushrn(1);var f=r.cmp(n);if(f<0){var c=r;r=n,n=c}else if(f===0||n.cmpn(1)===0)break;r.isub(n)}while(!0);return n.iushln(i)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return(this.words[0]&1)===0},o.prototype.isOdd=function(){return(this.words[0]&1)===1},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){p(typeof e=="number");var r=e%26,n=(e-r)/26,i=1<<r;if(this.length<=n)return this._expand(n+1),this.words[n]|=i,this;for(var f=i,c=n;f!==0&&c<this.length;c++){var h=this.words[c]|0;h+=f,f=h>>>26,h&=67108863,this.words[c]=h}return f!==0&&(this.words[c]=f,this.length++),this},o.prototype.isZero=function(){return this.length===1&&this.words[0]===0},o.prototype.cmpn=function(e){var r=e<0;if(this.negative!==0&&!r)return-1;if(this.negative===0&&r)return 1;this.strip();var n;if(this.length>1)n=1;else{r&&(e=-e),p(e<=67108863,"Number is too big");var i=this.words[0]|0;n=i===e?0:i<e?-1:1}return this.negative!==0?-n|0:n},o.prototype.cmp=function(e){if(this.negative!==0&&e.negative===0)return-1;if(this.negative===0&&e.negative!==0)return 1;var r=this.ucmp(e);return this.negative!==0?-r|0:r},o.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length<e.length)return-1;for(var r=0,n=this.length-1;n>=0;n--){var i=this.words[n]|0,f=e.words[n]|0;if(i!==f){i<f?r=-1:i>f&&(r=1);break}}return r},o.prototype.gtn=function(e){return this.cmpn(e)===1},o.prototype.gt=function(e){return this.cmp(e)===1},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 this.cmpn(e)===-1},o.prototype.lt=function(e){return this.cmp(e)===-1},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 this.cmpn(e)===0},o.prototype.eq=function(e){return this.cmp(e)===0},o.red=function(e){return new Y(e)},o.prototype.toRed=function(e){return p(!this.red,"Already a number in reduction context"),p(this.negative===0,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return p(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 p(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return p(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return p(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return p(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return p(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return p(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return p(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return p(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return p(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return p(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return p(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return p(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return p(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return p(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var L={k256:null,p224:null,p192:null,p25519:null};function N(u,e){this.name=u,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}N.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},N.prototype.ireduce=function(e){var r=e,n;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),n=r.bitLength();while(n>this.n);var i=n<this.n?-1:r.ucmp(this.p);return i===0?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):r.strip!==void 0?r.strip():r._strip(),r},N.prototype.split=function(e,r){e.iushrn(this.n,0,r)},N.prototype.imulK=function(e){return e.imul(this.k)};function j(){N.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}I(j,N),j.prototype.split=function(e,r){for(var n=4194303,i=Math.min(e.length,9),f=0;f<i;f++)r.words[f]=e.words[f];if(r.length=i,e.length<=9){e.words[0]=0,e.length=1;return}var c=e.words[9];for(r.words[r.length++]=c&n,f=10;f<e.length;f++){var h=e.words[f]|0;e.words[f-10]=(h&n)<<4|c>>>22,c=h}c>>>=22,e.words[f-10]=c,c===0&&e.length>10?e.length-=10:e.length-=9},j.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var r=0,n=0;n<e.length;n++){var i=e.words[n]|0;r+=i*977,e.words[n]=r&67108863,r=i*64+(r/67108864|0)}return e.words[e.length-1]===0&&(e.length--,e.words[e.length-1]===0&&e.length--),e};function K(){N.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}I(K,N);function $(){N.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}I($,N);function Q(){N.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}I(Q,N),Q.prototype.imulK=function(e){for(var r=0,n=0;n<e.length;n++){var i=(e.words[n]|0)*19+r,f=i&67108863;i>>>=26,e.words[n]=f,r=i}return r!==0&&(e.words[e.length++]=r),e},o._prime=function(e){if(L[e])return L[e];var r;if(e==="k256")r=new j;else if(e==="p224")r=new K;else if(e==="p192")r=new $;else if(e==="p25519")r=new Q;else throw new Error("Unknown prime "+e);return L[e]=r,r};function Y(u){if(typeof u=="string"){var e=o._prime(u);this.m=e.p,this.prime=e}else p(u.gtn(1),"modulus must be greater than 1"),this.m=u,this.prime=null}Y.prototype._verify1=function(e){p(e.negative===0,"red works only with positives"),p(e.red,"red works only with red numbers")},Y.prototype._verify2=function(e,r){p((e.negative|r.negative)===0,"red works only with positives"),p(e.red&&e.red===r.red,"red works only with red numbers")},Y.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},Y.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},Y.prototype.add=function(e,r){this._verify2(e,r);var n=e.add(r);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},Y.prototype.iadd=function(e,r){this._verify2(e,r);var n=e.iadd(r);return n.cmp(this.m)>=0&&n.isub(this.m),n},Y.prototype.sub=function(e,r){this._verify2(e,r);var n=e.sub(r);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},Y.prototype.isub=function(e,r){this._verify2(e,r);var n=e.isub(r);return n.cmpn(0)<0&&n.iadd(this.m),n},Y.prototype.shl=function(e,r){return this._verify1(e),this.imod(e.ushln(r))},Y.prototype.imul=function(e,r){return this._verify2(e,r),this.imod(e.imul(r))},Y.prototype.mul=function(e,r){return this._verify2(e,r),this.imod(e.mul(r))},Y.prototype.isqr=function(e){return this.imul(e,e.clone())},Y.prototype.sqr=function(e){return this.mul(e,e)},Y.prototype.sqrt=function(e){if(e.isZero())return e.clone();var r=this.m.andln(3);if(p(r%2===1),r===3){var n=this.m.add(new o(1)).iushrn(2);return this.pow(e,n)}for(var i=this.m.subn(1),f=0;!i.isZero()&&i.andln(1)===0;)f++,i.iushrn(1);p(!i.isZero());var c=new o(1).toRed(this),h=c.redNeg(),s=this.m.subn(1).iushrn(1),t=this.m.bitLength();for(t=new o(2*t*t).toRed(this);this.pow(t,s).cmp(h)!==0;)t.redIAdd(h);for(var a=this.pow(t,i),w=this.pow(e,i.addn(1).iushrn(1)),D=this.pow(e,i),Z=f;D.cmp(c)!==0;){for(var F=D,V=0;F.cmp(c)!==0;V++)F=F.redSqr();p(V<Z);var q=this.pow(a,new o(1).iushln(Z-V-1));w=w.redMul(q),a=q.redSqr(),D=D.redMul(a),Z=V}return w},Y.prototype.invm=function(e){var r=e._invmp(this.m);return r.negative!==0?(r.negative=0,this.imod(r).redNeg()):this.imod(r)},Y.prototype.pow=function(e,r){if(r.isZero())return new o(1).toRed(this);if(r.cmpn(1)===0)return e.clone();var n=4,i=new Array(1<<n);i[0]=new o(1).toRed(this),i[1]=e;for(var f=2;f<i.length;f++)i[f]=this.mul(i[f-1],e);var c=i[0],h=0,s=0,t=r.bitLength()%26;for(t===0&&(t=26),f=r.length-1;f>=0;f--){for(var a=r.words[f],w=t-1;w>=0;w--){var D=a>>w&1;if(c!==i[0]&&(c=this.sqr(c)),D===0&&h===0){s=0;continue}h<<=1,h|=D,s++,!(s!==n&&(f!==0||w!==0))&&(c=this.mul(c,i[h]),s=0,h=0)}t=26}return c},Y.prototype.convertTo=function(e){var r=e.umod(this.m);return r===e?r.clone():r},Y.prototype.convertFrom=function(e){var r=e.clone();return r.red=null,r},o.mont=function(e){return new ee(e)};function ee(u){Y.call(this,u),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)}I(ee,Y),ee.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},ee.prototype.convertFrom=function(e){var r=this.imod(e.mul(this.rinv));return r.red=null,r},ee.prototype.imul=function(e,r){if(e.isZero()||r.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(r),i=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),f=n.isub(i).iushrn(this.shift),c=f;return f.cmp(this.m)>=0?c=f.isub(this.m):f.cmpn(0)<0&&(c=f.iadd(this.m)),c._forceRed(this)},ee.prototype.mul=function(e,r){if(e.isZero()||r.isZero())return new o(0)._forceRed(this);var n=e.mul(r),i=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),f=n.isub(i).iushrn(this.shift),c=f;return f.cmp(this.m)>=0?c=f.isub(this.m):f.cmpn(0)<0&&(c=f.iadd(this.m)),c._forceRed(this)},ee.prototype.invm=function(e){var r=this.imod(e._invmp(this.m).mul(this.r2));return r._forceRed(this)}}(fe,this)},3812:(fe,x,T)=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});var S=T(6213);function y(F){throw new Error("makeNodeDisklet is not available on this platform")}function p(){throw new Error("makeReactNativeDisklet is not available on this platform")}function I(F,V,q,re,G,H,oe){try{var ue=F[H](oe),be=ue.value}catch(ie){q(ie);return}ue.done?V(be):Promise.resolve(be).then(re,G)}function o(F){return function(){var V=this,q=arguments;return new Promise(function(re,G){var H=F.apply(V,q);function oe(be){I(H,re,G,oe,ue,"next",be)}function ue(be){I(H,re,G,oe,ue,"throw",be)}oe(void 0)})}}function m(){return m=Object.assign||function(F){for(var V=1;V<arguments.length;V++){var q=arguments[V];for(var re in q)Object.prototype.hasOwnProperty.call(q,re)&&(F[re]=q[re])}return F},m.apply(this,arguments)}function l(F){if(/^\//.test(F))throw new Error("Absolute paths are not supported");for(var V=F.split("/"),q=0,re=0;q<V.length;){var G=V[q++];if(G===".."?re--:G!=="."&&G!==""&&(V[re++]=G),re<0)throw new Error("Path would escape folder")}return V.slice(0,re).join("/")}function g(F){return F===""?F:F+"/"}function M(F){for(var V=[],q=0;q<F.length;++q){var re=F.key(q);re!=null&&V.push(re)}return V}function E(F,V){F===void 0&&(F=window.localStorage),V===void 0&&(V={});var q=V.prefix!=null?g(V.prefix):"/";return{delete:function(G){var H=l(G);F.getItem(q+H)!=null&&F.removeItem(q+H);for(var oe=g(H),ue=0,be=M(F);ue<be.length;ue++){var ie=be[ue];ie.indexOf(q+oe)===0&&F.removeItem(ie)}return Promise.resolve()},getData:function(G){return this.getText(G).then(function(H){return S.base64.parse(H)})},getText:function(G){var H=l(G),oe=F.getItem(q+H);return oe==null?Promise.reject(new Error('Cannot load "'+H+'"')):Promise.resolve(oe)},list:function(G){return o(function*(){G===void 0&&(G="");var H=l(G),oe={};F.getItem(q+H)!=null&&(oe[H]="file");for(var ue=g(H),be=0,ie=M(F);be<ie.length;be++){var J=ie[be];if(J.indexOf(q+ue)===0){var pe=J.indexOf("/",q.length+ue.length);pe<0?oe[J.slice(q.length)]="file":oe[J.slice(q.length,pe)]="folder"}}return oe})()},setData:function(G,H){return this.setText(G,S.base64.stringify(H))},setText:function(G,H){return typeof H!="string"?Promise.reject(new TypeError("setText expects a string")):(F.setItem(q+l(G),H),Promise.resolve())}}}function d(F){return F===void 0&&(F={}),{delete:function(q){var re=l(q);F["/"+re]!=null&&delete F["/"+re];for(var G=g(re),H=0,oe=Object.keys(F);H<oe.length;H++){var ue=oe[H];ue.indexOf("/"+G)===0&&delete F[ue]}return Promise.resolve()},getData:function(q){var re=l(q),G=F["/"+re];return G==null?Promise.reject(new Error('Cannot load "'+re+'"')):typeof G=="string"?Promise.reject(new Error('"'+re+'" is a text file.')):Promise.resolve(G)},getText:function(q){var re=l(q),G=F["/"+re];return G==null?Promise.reject(new Error('Cannot load "'+re+'"')):typeof G!="string"?Promise.reject(new Error('"'+re+'" is a binary file.')):Promise.resolve(G)},list:function(q){return o(function*(){q===void 0&&(q="");var re=l(q),G={};F["/"+re]!=null&&(G[re]="file");for(var H=g(re),oe=0,ue=Object.keys(F);oe<ue.length;oe++){var be=ue[oe];if(be.indexOf("/"+H)===0){var ie=be.indexOf("/",1+H.length);ie<0?G[be.slice(1)]="file":G[be.slice(1,ie)]="folder"}}return G})()},setData:function(q,re){var G=re,H=Uint8Array.from(G);return F["/"+l(q)]=H,Promise.resolve()},setText:function(q,re){return typeof re!="string"?Promise.reject(new TypeError("setText expects a string")):(F["/"+l(q)]=re,Promise.resolve())}}}var A=function(){function F(q,re){this._disklet=q,this._path=re}var V=F.prototype;return V.delete=function(){return this._disklet.delete(this._path)},V.getData=function(){return this._disklet.getData(this._path)},V.getText=function(){return this._disklet.getText(this._path)},V.setData=function(re){return this._disklet.setData(this._path,re)},V.setText=function(re){return this._disklet.setText(this._path,re)},F}(),v=function(){function F(q,re){this._disklet=q,this._path=re}var V=F.prototype;return V.delete=function(){return this._disklet.delete(this._path)},V.file=function(re){return new A(this._disklet,this._path+"/"+re)},V.folder=function(re){return new F(this._disklet,this._path+"/"+re)},V.listFiles=function(){return this._disklet.list(this._path).then(function(re){return Object.keys(re).filter(function(G){return re[G]==="file"}).map(function(G){return G.replace(/^.*\//,"")})})},V.listFolders=function(){return this._disklet.list(this._path).then(function(re){return Object.keys(re).filter(function(G){return re[G]==="folder"}).map(function(G){return G.replace(/^.*\//,"")})})},F}();function b(F){return new v(F,".")}function k(F,V){for(var q=0,re=0;q<V.length;){var G=V[q++];if(G===".."?re--:G!=="."&&G!==""&&(V[re++]=G),re<0)throw new Error("Path would escape folder")}for(q=0;q<re;++q)F=F.folder(V[q]);return F}function B(F,V){var q=V.split("/"),re=q.pop();if(re==null)throw new Error("Empty path");return k(F,q).file(re)}function U(F,V){var q=V.split("/");return k(F,q)}function C(F,V){return F.listFiles().then(function(q){return Promise.all(q.map(function(re){return V(F.file(re),re,F)}))})}function L(F,V){return F.listFolders().then(function(q){return Promise.all(q.map(function(re){return V(F.folder(re),re,F)}))})}function N(F,V){function q(re,G,H){return Promise.all([C(re,function(oe,ue){return G(oe,H+ue,re)}),L(re,function(oe,ue){return q(oe,G,H+ue+"/")})]).then(function(oe){var ue=oe[0],be=oe[1];return ue.concat.apply(ue,be)})}return q(F,V,"")}function j(F,V){console.log(V+' "'+F+'"')}function K(F,V,q){var re=q.callback,G=re===void 0?j:re,H=q.verbose,oe=H===void 0?!1:H;(oe||/set|delete/.test(V))&&G(F,V)}var $=function(){function F(q,re,G){this._file=q,this._path=re,this._opts=G}var V=F.prototype;return V.delete=function(){return K(this._path,"delete file",this._opts),this._file.delete()},V.getData=function(){return K(this._path,"get data",this._opts),this._file.getData()},V.getText=function(){return K(this._path,"get text",this._opts),this._file.getText()},V.setData=function(re){return K(this._path,"set data",this._opts),this._file.setData(re)},V.setText=function(re){return K(this._path,"set text",this._opts),this._file.setText(re)},V.getPath=function(){return this._path},F}(),Q=function(){function F(q,re,G){this._folder=q,this._path=re,this._opts=G}var V=F.prototype;return V.delete=function(){return K(this._path,"delete folder",this._opts),this._folder.delete()},V.file=function(re){return new $(this._folder.file(re),this._path+re,this._opts)},V.folder=function(re){return new F(this._folder.folder(re),this._path+re+"/",this._opts)},V.listFiles=function(){return K(this._path,"list files",this._opts),this._folder.listFiles()},V.listFolders=function(){return K(this._path,"list folders",this._opts),this._folder.listFolders()},F}();function Y(F,V){return V===void 0&&(V={}),new Q(F,"",V)}function ee(F,V){var q={},re=[];return F.forEach(function(G){/\._x_$/.test(G)?q[G]=!0:(q[G+"._x_"]=!0,re.push(G))}),V.forEach(function(G){q[G+"._x_"]||re.push(G)}),re}var u=function(){function F(q,re,G){this._master=q,this._fallback=re,this._whiteout=G}var V=F.prototype;return V.delete=function(){return Promise.all([this._whiteout.setData([]),this._master.delete().catch(function(re){return null})])},V.getData=function(){var re=this;return this._master.getData().catch(function(G){return re._whiteout.getData().then(function(H){throw new Error("File has been deleted")},function(H){return re._fallback.getData()})})},V.getText=function(){var re=this;return this._master.getText().catch(function(G){return re._whiteout.getData().then(function(H){throw new Error("File has been deleted")},function(H){return re._fallback.getText()})})},V.setData=function(re){return this._master.setData(re)},V.setText=function(re){return this._master.setText(re)},V.getPath=function(){throw new Error("Cannot call getPath on a Union Folder")},F}(),e=function(){function F(q,re){this._master=q,this._fallback=re}var V=F.prototype;return V.delete=function(){return Promise.all([C(this,function(re){return re.delete()}),L(this,function(re){return re.delete()})]).then(function(){})},V.file=function(re){return new u(this._master.file(re),this._fallback.file(re),this._master.file(re+"._x_"))},V.folder=function(re){return new F(this._master.folder(re),this._fallback.folder(re))},V.listFiles=function(){return Promise.all([this._master.listFiles(),this._fallback.listFiles()]).then(function(re){return ee(re[0],re[1])})},V.listFolders=function(){return Promise.all([this._master.listFolders(),this._fallback.listFolders()]).then(function(re){return ee(re[0],re[1])})},F}();function r(F,V){return new e(F,V)}function n(F,V){var q=g(l(V));return{delete:function(G){return F.delete(q+G)},getData:function(G){return F.getData(q+G)},getText:function(G){return F.getText(q+G)},list:function(G){return G===void 0&&(G="."),F.list(q+G).then(function(H){var oe={};for(var ue in H)oe[ue.replace(q,"")]=H[ue];return oe})},setData:function(G,H){return F.setData(q+G,H)},setText:function(G,H){return F.setText(q+G,H)}}}function i(F){var V={};return F.list().then(function(q){return Promise.all(Object.keys(q).map(function(re){var G=q[re];return G==="folder"?i(n(F,re)).then(function(H){V[re]=H}):F.getText(re).then(function(H){V[re]=JSON.parse(H)})})).then(function(){return V})})}function f(F,V){return F.list(V).then(function(q){return Promise.all(Object.keys(q).filter(function(re){return q[re]==="folder"}).map(function(re){return f(F,re)})).then(function(re){return m.apply(void 0,[q].concat(re))})})}function c(F){return Object.keys(F).filter(function(V){return F[V]==="file"})}function h(F){return Object.keys(F).filter(function(V){return F[V]==="folder"})}function s(F,V){V===void 0&&(V={});var q=V,re=q.callback,G=re===void 0?function(be,ie){console.log(ie+' "'+be+'"')}:re,H=q.verbose,oe=H===void 0?!1:H,ue=function(ie,J){(oe||/set|delete/.test(ie))&&G(J,ie)};return{delete:function(ie){return ue("delete",l(ie)),F.delete(ie)},getData:function(ie){return ue("get data",l(ie)),F.getData(ie)},getText:function(ie){return ue("get text",l(ie)),F.getText(ie)},list:function(ie){return ue("list",ie!=null?l(ie):""),F.list(ie)},setData:function(ie,J){return ue("set data",l(ie)),F.setData(ie,J)},setText:function(ie,J){return ue("set text",l(ie)),F.setText(ie,J)}}}function t(F,V){return{delete:function(re){return Promise.all([F.delete(re),V.delete(re)])},getData:function(re){return F.getData(re).catch(function(G){return V.getData(re)})},getText:function(re){return F.getText(re).catch(function(G){return V.getText(re)})},list:function(re){return Promise.all([F.list(re),V.list(re)]).then(function(G){var H=G[0],oe=G[1];return m(oe,H)})},setData:function(re,G){return F.setData(re,G)},setText:function(re,G){return F.setText(re,G)}}}function a(F,V){return b(E(F,V))}function w(F){return b(d(F))}function D(F){return b(y())}function Z(){return b(p())}x.deepList=f,x.downgradeDisklet=b,x.dumpData=i,x.justFiles=c,x.justFolders=h,x.locateFile=B,x.locateFolder=U,x.logDisklet=s,x.makeLocalStorageDisklet=E,x.makeLocalStorageFolder=a,x.makeLoggedFolder=Y,x.makeMemoryDisklet=d,x.makeMemoryFolder=w,x.makeNodeDisklet=y,x.makeNodeFolder=D,x.makeReactNativeDisklet=p,x.makeReactNativeFolder=Z,x.makeUnionFolder=r,x.mapAllFiles=N,x.mapFiles=C,x.mapFolders=L,x.mergeDisklets=t,x.navigateDisklet=n},6213:(fe,x)=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});function T(v,b,k){var B;if(k===void 0&&(k={}),!b.codes){b.codes={};for(var U=0;U<b.chars.length;++U)b.codes[b.chars[U]]=U}if(!k.loose&&v.length*b.bits&7)throw new SyntaxError("Invalid padding");for(var C=v.length;v[C-1]==="=";)if(--C,!k.loose&&!((v.length-C)*b.bits&7))throw new SyntaxError("Invalid padding");for(var L=new((B=k.out)!=null?B:Uint8Array)(C*b.bits/8|0),N=0,j=0,K=0,$=0;$<C;++$){var Q=b.codes[v[$]];if(Q===void 0)throw new SyntaxError("Invalid character "+v[$]);j=j<<b.bits|Q,N+=b.bits,N>=8&&(N-=8,L[K++]=255&j>>N)}if(N>=b.bits||255&j<<8-N)throw new SyntaxError("Unexpected end of data");return L}function S(v,b,k){k===void 0&&(k={});for(var B=k,U=B.pad,C=U===void 0?!0:U,L=(1<<b.bits)-1,N="",j=0,K=0,$=0;$<v.length;++$)for(K=K<<8|255&v[$],j+=8;j>b.bits;)j-=b.bits,N+=b.chars[L&K>>j];if(j&&(N+=b.chars[L&K<<b.bits-j]),C)for(;N.length*b.bits&7;)N+="=";return N}var y={chars:"0123456789ABCDEF",bits:4},p={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bits:5},I={chars:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bits:5},o={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bits:6},m={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bits:6},l={parse:function(b,k){return T(b.toUpperCase(),y,k)},stringify:function(b,k){return S(b,y,k)}},g={parse:function(b,k){return k===void 0&&(k={}),T(k.loose?b.toUpperCase().replace(/0/g,"O").replace(/1/g,"L").replace(/8/g,"B"):b,p,k)},stringify:function(b,k){return S(b,p,k)}},M={parse:function(b,k){return T(b,I,k)},stringify:function(b,k){return S(b,I,k)}},E={parse:function(b,k){return T(b,o,k)},stringify:function(b,k){return S(b,o,k)}},d={parse:function(b,k){return T(b,m,k)},stringify:function(b,k){return S(b,m,k)}},A={parse:T,stringify:S};x.base16=l,x.base32=g,x.base32hex=M,x.base64=E,x.base64url=d,x.codec=A},3689:(fe,x,T)=>{"use strict";var S;S={value:!0};var y=T(9977),p=T(9796);const I=y.asCodec(xt=>p.base16.parse(y.asString(xt)),xt=>p.base16.stringify(xt).toLowerCase()),o=y.asCodec(xt=>p.base32.parse(y.asString(xt),{loose:!0}),xt=>p.base32.stringify(xt,{pad:!1})),m=y.asCodec(xt=>p.base64.parse(y.asString(xt)),xt=>p.base64.stringify(xt)),l=y.asObject({voucherId:y.asString,activates:y.asDate,created:y.asDate,ip:y.asString,ipDescription:y.asString,deviceDescription:y.asOptional(y.asString)}),g=y.asObject({encryptionType:y.asNumber,data_base64:m,iv_hex:I}),M=y.asObject({salt_hex:I,n:y.asNumber,r:y.asNumber,p:y.asNumber}),E=y.asObject({loginRequest:y.asOptional(y.asObject({appId:y.asString}).withRest),publicKey:m,timeout:y.asOptional(y.asNumber)}).withRest,d=y.asObject({publicKey:m,box:g}),A=y.asArray(m),v=y.asObject({data:y.asUnknown,challengeId:y.asOptional(y.asString),deviceDescription:y.asOptional(y.asString),otp:y.asOptional(y.asString),syncToken:y.asOptional(y.asString),voucherId:y.asOptional(y.asString),voucherAuth:y.asOptional(m),loginId:y.asOptional(m),loginAuth:y.asOptional(m),userId:y.asOptional(m),passwordAuth:y.asOptional(m),pin2Id:y.asOptional(m),pin2Auth:y.asOptional(m),recovery2Id:y.asOptional(m),recovery2Auth:y.asOptional(A),loginIds:y.asOptional(y.asArray(m)),otpResetAuth:y.asOptional(y.asString),did:y.asOptional(y.asString),l1:y.asOptional(m),lp1:y.asOptional(m),lpin1:y.asOptional(m),lra1:y.asOptional(m),recoveryAuth:y.asOptional(m)}),b=y.asObject({results:y.asOptional(y.asUnknown),status_code:y.asNumber,message:y.asString}),k=y.asObject({otpTimeout:y.asOptional(y.asNumber,7*24*60*60),otpKey:o}),B=y.asObject({passwordAuth:m,passwordAuthBox:g,passwordAuthSnrp:M,passwordBox:g,passwordKeySnrp:M}),U=y.asObject({pin2Id:m}),C=y.asObject({pin2Id:y.asOptional(m),pin2Auth:y.asOptional(m),pin2Box:y.asOptional(g),pin2KeyBox:y.asOptional(g),pin2TextBox:g}),L=y.asObject({recovery2Id:m}),N=y.asObject({recovery2Id:m,recovery2Auth:A,recovery2Box:g,recovery2KeyBox:g,question2Box:g}),j=y.asObject({loginAuthBox:g,loginAuth:m}),K=y.asObject({userId:m,userTextBox:g}),$=y.asObject({approvedVouchers:y.asOptional(y.asArray(y.asString)),rejectedVouchers:y.asOptional(y.asArray(y.asString))}),Q=y.asObject({keyBoxes:y.asArray(g),newSyncKeys:y.asOptional(y.asArray(y.asString),()=>[])}),Y=y.asObject({appId:y.asString,loginId:m,parentBox:y.asOptional(g)}),ee=y.asObject({challengeId:y.asString,challengeUri:y.asString}),u=y.asObject({request:E,replies:y.asArray(d)}),e=y.asValue(!0),r=y.asObject({appId:y.asString,created:y.asDate,loginId:m,syncToken:y.asOptional(y.asString),children:y.asOptional(y.asArray(xt=>r(xt))),parentBox:y.asOptional(g),otpKey:y.asOptional(y.asEither(e,o)),otpResetDate:y.asOptional(y.asDate),otpTimeout:y.asOptional(y.asNumber),passwordAuthBox:y.asOptional(g),passwordAuthSnrp:y.asOptional(M),passwordBox:y.asOptional(y.asEither(e,g)),passwordKeySnrp:y.asOptional(M),pin2Box:y.asOptional(y.asEither(e,g)),pin2KeyBox:y.asOptional(g),pin2TextBox:y.asOptional(g),question2Box:y.asOptional(g),recovery2Box:y.asOptional(y.asEither(e,g)),recovery2KeyBox:y.asOptional(g),loginAuthBox:y.asOptional(g),userId:y.asOptional(m),userTextBox:y.asOptional(g),pendingVouchers:y.asOptional(y.asArray(l),()=>[]),keyBoxes:y.asOptional(y.asArray(g)),mnemonicBox:y.asOptional(g),rootKeyBox:y.asOptional(g),syncKeyBox:y.asOptional(g)}),n=y.asArray(y.asObject({loginId:m,otpResetPending:y.asOptional(y.asBoolean,!1),pendingVouchers:y.asOptional(y.asArray(l),()=>[]),recovery2Corrupt:y.asOptional(y.asBoolean,!1)})),i=y.asObject({login_id:y.asOptional(m),otp_reset_auth:y.asOptional(y.asString),otp_timeout_date:y.asOptional(y.asDate),reason:y.asOptional(y.asValue("ip","otp"),"otp"),voucher_activates:y.asOptional(y.asDate),voucher_auth:y.asOptional(m),voucher_id:y.asOptional(y.asString)}),f=y.asObject({otpResetDate:y.asDate}),c=y.asObject({wait_seconds:y.asOptional(y.asNumber)}),h=y.asObject({question2Box:g}),s=y.asObject({loginId:m,passwordAuthSnrp:y.asOptional(M),questionBox:y.asOptional(g),questionKeySnrp:y.asOptional(M),recoveryAuthSnrp:y.asOptional(M)}),t=y.uncleaner(g),a=y.uncleaner(d),w=y.uncleaner(E),D=y.uncleaner(v),Z=y.uncleaner(b),F=y.uncleaner(k),V=y.uncleaner(B),q=y.uncleaner(U),re=y.uncleaner(C),G=y.uncleaner(L),H=y.uncleaner(N),oe=y.uncleaner(j),ue=y.uncleaner(K),be=y.uncleaner($),ie=y.uncleaner(Q),J=y.uncleaner(Y),pe=y.uncleaner(ee),Ge=y.uncleaner(u),ce=y.uncleaner(r),te=y.uncleaner(n),le=y.uncleaner(i),ge=y.uncleaner(f),Pe=y.uncleaner(c),lt=y.uncleaner(h),Le=y.uncleaner(s);function ze(xt,gt="Login requires a CAPTCHA"){if(!(this instanceof ze))throw new TypeError("Class constructor ChallengeError cannot be invoked without 'new'");var bt;function Tt(Ct){return bt=new Error(Ct),Object.defineProperty(bt,"constructor",{value:ze,configurable:!0,writable:!0}),bt}return Tt(gt),bt.name="ChallengeError",bt.challengeId=xt.challengeId,bt.challengeUri=xt.challengeUri,bt}function kt(xt="Please send a larger amount"){if(!(this instanceof kt))throw new TypeError("Class constructor DustSpendError cannot be invoked without 'new'");var gt;function bt(Tt){return gt=new Error(Tt),Object.defineProperty(gt,"constructor",{value:kt,configurable:!0,writable:!0}),gt}return bt(xt),gt.name="DustSpendError",gt}function ae(xt){if(!(this instanceof ae))throw new TypeError("Class constructor InsufficientFundsError cannot be invoked without 'new'");var gt;function bt(Xt){return gt=new Error(Xt),Object.defineProperty(gt,"constructor",{value:ae,configurable:!0,writable:!0}),gt}const{tokenId:Tt=null,networkFee:Ct}=xt!=null?xt:{};return bt(`Insufficient ${Tt!=null?Tt:"funds"}`),gt.tokenId=Tt,gt.networkFee=Ct,gt.name="InsufficientFundsError",gt}function he(xt="Cannot reach the network"){if(!(this instanceof he))throw new TypeError("Class constructor NetworkError cannot be invoked without 'new'");var gt;function bt(Tt){return gt=new Error(Tt),Object.defineProperty(gt,"constructor",{value:he,configurable:!0,writable:!0}),gt}return bt(xt),gt.name="NetworkError",gt}function je(xt="Unable to create zero-amount transaction."){if(!(this instanceof je))throw new TypeError("Class constructor NoAmountSpecifiedError cannot be invoked without 'new'");var gt;function bt(Tt){return gt=new Error(Tt),Object.defineProperty(gt,"constructor",{value:je,configurable:!0,writable:!0}),gt}return bt(xt),gt.name="NoAmountSpecifiedError",gt}function Ie(xt="The application is too old. Please upgrade."){if(!(this instanceof Ie))throw new TypeError("Class constructor ObsoleteApiError cannot be invoked without 'new'");var gt;function bt(Tt){return gt=new Error(Tt),Object.defineProperty(gt,"constructor",{value:Ie,configurable:!0,writable:!0}),gt}return bt(xt),gt.name="ObsoleteApiError",gt}function Ce(xt,gt="Invalid OTP token"){if(!(this instanceof Ce))throw new TypeError("Class constructor OtpError cannot be invoked without 'new'");var bt;function Tt(Xt){return bt=new Error(Xt),Object.defineProperty(bt,"constructor",{value:Ce,configurable:!0,writable:!0}),bt}Tt(gt),bt.name="OtpError",bt.reason="otp";const Ct=y.asMaybe(i)(xt);if(Ct!=null)return Ct.login_id!=null&&(bt.loginId=p.base64.stringify(Ct.login_id)),bt.resetToken=Ct.otp_reset_auth,bt.reason=Ct.reason,bt.resetDate=Ct.otp_timeout_date,bt.voucherActivates=Ct.voucher_activates,Ct.voucher_auth!=null&&(bt.voucherAuth=p.base64.stringify(Ct.voucher_auth)),bt.voucherId=Ct.voucher_id,bt}function ut(xt,gt="Invalid password"){if(!(this instanceof ut))throw new TypeError("Class constructor PasswordError cannot be invoked without 'new'");var bt;function Tt(Xt){return bt=new Error(Xt),Object.defineProperty(bt,"constructor",{value:ut,configurable:!0,writable:!0}),bt}Tt(gt),bt.name="PasswordError";const Ct=y.asMaybe(c)(xt);if(Ct!=null)return bt.wait=Ct.wait_seconds,bt}function De(xt="Not enough confirmed funds"){if(!(this instanceof De))throw new TypeError("Class constructor PendingFundsError cannot be invoked without 'new'");var gt;function bt(Tt){return gt=new Error(Tt),Object.defineProperty(gt,"constructor",{value:De,configurable:!0,writable:!0}),gt}return bt(xt),gt.name="PendingFundsError",gt}function ye(xt="Wallets can not be the same currency"){if(!(this instanceof ye))throw new TypeError("Class constructor SameCurrencyError cannot be invoked without 'new'");var gt;function bt(Tt){return gt=new Error(Tt),Object.defineProperty(gt,"constructor",{value:ye,configurable:!0,writable:!0}),gt}return bt(xt),gt.name="SameCurrencyError",gt}function we(xt="Spending to self"){if(!(this instanceof we))throw new TypeError("Class constructor SpendToSelfError cannot be invoked without 'new'");var gt;function bt(Tt){return gt=new Error(Tt),Object.defineProperty(gt,"constructor",{value:we,configurable:!0,writable:!0}),gt}return bt(xt),gt.name="SpendToSelfError",gt}function ve(xt,gt,bt="from"){if(!(this instanceof ve))throw new TypeError("Class constructor SwapAboveLimitError cannot be invoked without 'new'");var Tt;function Ct(Xt){return Tt=new Error(Xt),Object.defineProperty(Tt,"constructor",{value:ve,configurable:!0,writable:!0}),Tt}return Ct("Amount is too high"),Tt.name="SwapAboveLimitError",Tt.pluginId=xt.pluginId,Tt.nativeMax=gt,Tt.direction=bt,Tt}function Ee(xt,gt,bt="from"){if(!(this instanceof Ee))throw new TypeError("Class constructor SwapBelowLimitError cannot be invoked without 'new'");var Tt;function Ct(Xt){return Tt=new Error(Xt),Object.defineProperty(Tt,"constructor",{value:Ee,configurable:!0,writable:!0}),Tt}return Ct("Amount is too low"),Tt.name="SwapBelowLimitError",Tt.pluginId=xt.pluginId,Tt.nativeMin=gt,Tt.direction=bt,Tt}function rt(xt,gt){if(!(this instanceof rt))throw new TypeError("Class constructor SwapCurrencyError cannot be invoked without 'new'");var bt;function Tt(fr){return bt=new Error(fr),Object.defineProperty(bt,"constructor",{value:rt,configurable:!0,writable:!0}),bt}const{fromWallet:Ct,toWallet:Xt,fromTokenId:Yt,toTokenId:ar}=gt,or=Ct.currencyConfig.currencyInfo.pluginId,sr=Xt.currencyConfig.currencyInfo.pluginId,$t=`${or}:${String(Yt)}`,nr=`${sr}:${String(ar)}`;return Tt(`${xt.displayName} does not support ${$t} to ${nr}`),bt.name="SwapCurrencyError",bt.pluginId=xt.pluginId,bt.fromTokenId=Yt!=null?Yt:null,bt.toTokenId=ar!=null?ar:null,bt}function Fe(xt,gt){if(!(this instanceof Fe))throw new TypeError("Class constructor SwapPermissionError cannot be invoked without 'new'");var bt;function Tt(Ct){return bt=new Error(Ct),Object.defineProperty(bt,"constructor",{value:Fe,configurable:!0,writable:!0}),bt}return gt!=null?Tt(gt):Tt("You are not allowed to make this trade"),bt.name="SwapPermissionError",bt.pluginId=xt.pluginId,bt.reason=gt,bt}function He(xt="Invalid username"){if(!(this instanceof He))throw new TypeError("Class constructor UsernameError cannot be invoked without 'new'");var gt;function bt(Tt){return gt=new Error(Tt),Object.defineProperty(gt,"constructor",{value:He,configurable:!0,writable:!0}),gt}return bt(xt),gt.name="UsernameError",gt}function yt(xt){return function(bt){if(bt instanceof Error&&bt.name===xt)return bt}}const Ke=yt("ChallengeError"),Ze=yt("DustSpendError"),At=yt("InsufficientFundsError"),Ve=yt("NetworkError"),tt=yt("NoAmountSpecifiedError"),qt=yt("ObsoleteApiError"),et=yt("OtpError"),st=yt("PasswordError"),rr=yt("PendingFundsError"),at=yt("SameCurrencyError"),ft=yt("SpendToSelfError"),Qe=yt("SwapAboveLimitError"),xe=yt("SwapBelowLimitError"),Oe=yt("SwapCurrencyError"),ht=yt("SwapPermissionError"),Ne=yt("UsernameError"),qe=y.asObject(g),Dt=y.asObject({loginId:m,voucherAuth:m,voucherId:y.asString,created:y.asDate,activates:y.asDate,status:y.asValue("pending","approved","rejected"),ip:y.asString,ipDescription:y.asString,deviceDescription:y.asOptional(y.asString)}),Xe=y.asObject({appId:y.asString,created:y.asOptional(y.asDate,()=>new Date),loginId:m,children:y.asOptional(y.asArray(xt=>Xe(xt)),()=>[]),parentBox:y.asOptional(g),parentId:()=>{},otpKey:y.asOptional(o),otpResetAuth:y.asOptional(y.asString),otpResetDate:y.asOptional(y.asDate),otpTimeout:y.asOptional(y.asNumber),passwordAuth:y.asOptional(m),passwordAuthBox:y.asOptional(g),passwordAuthSnrp:y.asOptional(M),passwordBox:y.asOptional(g),passwordKeySnrp:y.asOptional(M),pin2Id:y.asOptional(m),pin2Auth:y.asOptional(m),pin2Box:y.asOptional(g),pin2KeyBox:y.asOptional(g),pin2TextBox:y.asOptional(g),recovery2Id:y.asOptional(m),recovery2Auth:y.asOptional(A),question2Box:y.asOptional(g),recovery2Box:y.asOptional(g),recovery2KeyBox:y.asOptional(g),loginAuth:y.asOptional(m),loginAuthBox:y.asOptional(g),userId:y.asOptional(m),userTextBox:y.asOptional(g),keyBoxes:y.asOptional(y.asArray(g),()=>[]),mnemonicBox:y.asOptional(g),rootKeyBox:y.asOptional(g),syncKeyBox:y.asOptional(g),vouchers:y.asOptional(y.asArray(Dt),()=>[]),pinBox:y.asOptional(g),pinId:y.asOptional(y.asString),pinKeyBox:y.asOptional(g)}),ot=y.uncleaner(Xe),Gt=y.uncleaner(qe);x.WK=ze,x.DE=kt,x.k5=ae,x.Dr=he,x.ef=je,x.GY=Ie,x.WM=Ce,x.Kz=ut,x.uX=De,x.IK=ye,x.gw=we,x.WU=ve,x.G8=Ee,x.xQ=rt,x.D7=Fe,x.hi=He,x.zU=I,x.dq=o,x.m$=m,x.MU=ee,x.ID=k,x.k0=B,x.D4=U,x.kL=C,x.jx=L,x.A_=N,x.v1=j,x.TL=K,x.Og=$,x.ft=Q,x.KU=Y,x.ZU=g,x.ye=d,x.Xj=E,x.Rn=Xe,x.bo=l,x.KL=qe,x.rW=M,x.U3=Dt,x.$Y=u,x.EJ=r,x.XY=v,x.v7=b,x.up=Ke,x.h=Ze,x.Cx=At,x.Zz=Ve,x.CU=tt,x.ib=qt,x.eT=et,x._0=st,x.UR=rr,x.Up=at,x.y0=ft,x.A2=Qe,x.ql=xe,x.FX=Oe,x.Jr=ht,x.zS=Ne,x.pK=n,x.ud=i,x.Zk=f,x.Mf=c,x.U0=A,x.CX=h,x.l4=s,x.Jv=pe,x.T0=F,x.z8=V,x.Gt=q,x.Fm=re,x.b4=G,x.N2=H,x.K8=oe,x.gB=ue,x.bd=be,x.GG=ie,x.V$=J,x.CC=t,x.dT=a,x.uT=w,x._j=ot,x.p4=Gt,x.W0=Ge,x.zk=ce,x.AB=D,x.sn=Z,x._u=te,x.Py=le,x.iu=ge,x.l7=Pe,x.JU=lt,x.O6=Le},9112:(fe,x,T)=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});var S=T(9977),y=T(4945),p=T(1395),I=T(7952),o=T(1024);function m(V){return V&&typeof V=="object"&&"default"in V?V:{default:V}}var l=m(y),g=m(p),M=m(I);function E(V){if(/^\//.test(V))throw new Error("Absolute paths are not supported");const q=V.split("/");let re=0,G=0;for(;re<q.length;){const H=q[re++];if(H===".."?G--:H!=="."&&H!==""&&(q[G++]=H),G<0)throw new Error("Path would escape folder");if(G===0&&re===q.length)throw new Error("Path would evaluate to empty file name")}return q.slice(0,G).join("/")}const d=/^[a-z0-9-_.]+(\/+[a-z0-9-_.]+)*$/i,A=/^[a-f0-9]{40}$/,v=S.asObject({infoServers:S.asOptional(S.asArray(S.asString)),syncServers:S.asOptional(S.asArray(S.asString))}),b=V=>{const q=S.asString(V);if(q==="")throw new TypeError("Expected non empty string");return q},k=V=>{const q=S.asString(V);try{if(d.test(q))return E(q)}catch{}throw new Error(`Invalid path '${q}'`)},B=V=>{const q=S.asString(V);if(!A.test(q))throw new TypeError(`Invalid sync key '${q}'`);return q},U=S.asObject({iv_hex:S.asString,encryptionType:S.asNumber,data_base64:S.asString}),C=S.asObject({success:S.asValue(!1),message:S.asString,stack:S.asOptional(S.asString)}),L=S.asEither(U,S.asNull),N=S.asObject(L),j=S.asObject({syncKey:B,hash:S.asOptional(b)}),K=S.asObject({hash:S.asOptional(S.asString),changes:N}),$=S.asObject({syncKey:B,hash:S.asOptional(b)}),Q=S.asObject({changes:N}),Y=S.asObject({hash:S.asString,changes:N}),ee=S.asObject({syncKey:B}),u=S.asUndefined,e=()=>{};async function r(V,q,re={}){const{log:G=e,fetch:H=l.default}=re,{method:oe,url:ue,body:be,numbUrl:ie=ue,headers:J={}}=V,pe=Date.now(),Ge=await H(ue,{method:oe,headers:{"Content-Type":"application/json",...J},body:JSON.stringify(be)}),ce=Date.now()-pe;G(`${oe} ${ie} returned ${Ge.status} in ${ce}ms`);const te=await Ge.text();if(!Ge.ok)throw new Error(`Failed request ${oe} ${ie} failed ${Ge.status}: ${te}`);const le=S.asMaybe(C)(te);if(le!=null)throw new Error(`Failed request ${oe} ${ie} failed ${Ge.status}: ${le.message}`);return q(te.trim()!==""?JSON.parse(te):void 0)}const n=g.default("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),i=V=>{const q=o.base16.parse(V),re=f(f(q));return n.encode(re)};function f(V){const q=M.default.sha256();return Uint8Array.from(q.update(V).digest())}function c(V){for(let q=V.length-1;q>0;q--){const re=Math.floor(Math.random()*(q+1));[V[q],V[re]]=[V[re],V[q]]}return V}class h extends Error{constructor(q="Cannot reach the network"){super(q),this.name="NetworkError"}}function s(V,q){let re=Date.now()+q,G=V(void 0);return{get:()=>((Date.now()>re||G==null)&&(re=Date.now()+q,G=V(G)),G)}}function t(V,q){return V!=null?V:q()}const a={infoServers:["https://info-eu1.edge.app","https://info-us1.edge.app"],syncServers:["https://sync-us1.edge.app","https://sync-us2.edge.app","https://sync-us3.edge.app","https://sync-us4.edge.app","https://sync-us5.edge.app","https://sync-us6.edge.app","https://sync-eu.edge.app"]};function w(V={}){const{log:q=()=>{}}=V,re={...a,...V.edgeServers},{edgeServersCacheTTL:G=6e5}=V,H=s((oe={current:re})=>(oe.current.infoServers.length>0&&D(oe.current.infoServers,V).then(ue=>oe.current={...oe.current,...ue,infoServers:t(ue.infoServers,()=>a.infoServers)}).catch(async ue=>{q(String(ue))}),oe),G);return{async getEdgeServers(){const{current:oe}=await H.get();return oe}}}async function D(V,q={}){const{log:re=e,fetch:G=l.default}=q;let H=new Error("No info servers");for(const oe of V){const[ue,be]=["GET","/v1/edgeServers"],ie=Date.now(),J=`${oe}${be}`;try{const pe=await G(J,{method:ue,headers:{"Content-Type":"application/json"}}).catch(lt=>{const Le=Date.now()-ie,ze=`${ue} ${J} failed in ${Le}ms, ${String(lt)}`;throw re(ze),new h(ze)}),{ok:Ge,status:ce}=pe,te=Date.now()-ie,le=`${ue} ${J} returned ${ce} in ${te}ms`;if(!Ge)throw re(le),new h(le);re(le);const ge=await pe.text(),Pe=JSON.parse(ge);return v(Pe)}catch(pe){H=pe;continue}}throw H}function Z(V,q){return V!=null?V:q()}function F(V={}){const q=w(V);async function re(){const{syncServers:G}=await q.getEdgeServers();return c(G)}return{async createRepo(G,H){const oe=await re();let ue=new Error(`Failed to create repo ${G}: empty sync server list`);for(const be of oe){const ie=`${be}/api/v2/store/${G}`,J=ie.replace(G,`<${i(G)}>`);try{return await r({method:"PUT",url:ie,numbUrl:J,headers:H!=null?{"X-API-Key":H}:{}},u,V)}catch(pe){ue=pe}}throw ue},async readRepo(G,H){const oe=await re();let ue=new Error(`Failed to read repo ${G}: empty sync server list`);for(const be of oe){const ie=`${be}/api/v2/store/${G}/${Z(H,()=>"")}`,J=ie.replace(G,`<${i(G)}>`);try{return await r({method:"GET",url:ie,numbUrl:J},K,V)}catch(pe){ue=pe}}throw ue},async updateRepo(G,H,oe){const ue=await re();let be=new Error(`Failed to update repo ${G}: empty sync server list`);for(const ie of ue){const J=`${ie}/api/v2/store/${G}/${Z(H,()=>"")}`,pe=J.replace(G,`<${i(G)}>`);try{return await r({method:"POST",url:J,numbUrl:pe,body:oe},Y,V)}catch(Ge){be=Ge}}throw be}}}x.asChangeSet=N,x.asEdgeBox=U,x.asEdgeServers=v,x.asFileChange=L,x.asGetStoreParams=j,x.asGetStoreResponse=K,x.asNonEmptyString=b,x.asPath=k,x.asPostStoreBody=Q,x.asPostStoreParams=$,x.asPostStoreResponse=Y,x.asPutStoreParams=ee,x.asPutStoreResponse=u,x.asServerErrorResponse=C,x.asSyncKey=B,x.makeSyncClient=F,x.syncKeyToRepoId=i},1395:fe=>{fe.exports=function(T){for(var S={},y=T.length,p=T.charAt(0),I=0;I<T.length;I++)S[T.charAt(I)]=I;function o(g){if(g.length===0)return"";for(var M=[0],E=0;E<g.length;++E){for(var d=0,A=g[E];d<M.length;++d)A+=M[d]<<8,M[d]=A%y,A=A/y|0;for(;A>0;)M.push(A%y),A=A/y|0}for(var v="",b=0;g[b]===0&&b<g.length-1;++b)v+=T[0];for(var k=M.length-1;k>=0;--k)v+=T[M[k]];return v}function m(g){if(g.length===0)return[];for(var M=[0],E=0;E<g.length;E++){var d=S[g[E]];if(d===void 0)return;for(var A=0,v=d;A<M.length;++A)v+=M[A]*y,M[A]=v&255,v>>=8;for(;v>0;)M.push(v&255),v>>=8}for(var b=0;g[b]===p&&b<g.length-1;++b)M.push(0);return M.reverse()}function l(g){var M=m(g);if(M)return M;throw new Error("Non-base"+y+" character")}return{encode:o,decodeUnsafe:m,decode:l}}},6729:(fe,x,T)=>{"use strict";var S=x;S.version=T(1636).rE,S.utils=T(7011),S.rand=T(5037),S.curve=T(894),S.curves=T(480),S.ec=T(7447),S.eddsa=T(8650)},6677:(fe,x,T)=>{"use strict";var S=T(8490),y=T(7011),p=y.getNAF,I=y.getJSF,o=y.assert;function m(g,M){this.type=g,this.p=new S(M.p,16),this.red=M.prime?S.red(M.prime):S.mont(this.p),this.zero=new S(0).toRed(this.red),this.one=new S(1).toRed(this.red),this.two=new S(2).toRed(this.red),this.n=M.n&&new S(M.n,16),this.g=M.g&&this.pointFromJSON(M.g,M.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var E=this.n&&this.p.div(this.n);!E||E.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}fe.exports=m,m.prototype.point=function(){throw new Error("Not implemented")},m.prototype.validate=function(){throw new Error("Not implemented")},m.prototype._fixedNafMul=function(M,E){o(M.precomputed);var d=M._getDoubles(),A=p(E,1,this._bitLength),v=(1<<d.step+1)-(d.step%2===0?2:1);v/=3;var b=[],k,B;for(k=0;k<A.length;k+=d.step){B=0;for(var U=k+d.step-1;U>=k;U--)B=(B<<1)+A[U];b.push(B)}for(var C=this.jpoint(null,null,null),L=this.jpoint(null,null,null),N=v;N>0;N--){for(k=0;k<b.length;k++)B=b[k],B===N?L=L.mixedAdd(d.points[k]):B===-N&&(L=L.mixedAdd(d.points[k].neg()));C=C.add(L)}return C.toP()},m.prototype._wnafMul=function(M,E){var d=4,A=M._getNAFPoints(d);d=A.wnd;for(var v=A.points,b=p(E,d,this._bitLength),k=this.jpoint(null,null,null),B=b.length-1;B>=0;B--){for(var U=0;B>=0&&b[B]===0;B--)U++;if(B>=0&&U++,k=k.dblp(U),B<0)break;var C=b[B];o(C!==0),M.type==="affine"?C>0?k=k.mixedAdd(v[C-1>>1]):k=k.mixedAdd(v[-C-1>>1].neg()):C>0?k=k.add(v[C-1>>1]):k=k.add(v[-C-1>>1].neg())}return M.type==="affine"?k.toP():k},m.prototype._wnafMulAdd=function(M,E,d,A,v){var b=this._wnafT1,k=this._wnafT2,B=this._wnafT3,U=0,C,L,N;for(C=0;C<A;C++){N=E[C];var j=N._getNAFPoints(M);b[C]=j.wnd,k[C]=j.points}for(C=A-1;C>=1;C-=2){var K=C-1,$=C;if(b[K]!==1||b[$]!==1){B[K]=p(d[K],b[K],this._bitLength),B[$]=p(d[$],b[$],this._bitLength),U=Math.max(B[K].length,U),U=Math.max(B[$].length,U);continue}var Q=[E[K],null,null,E[$]];E[K].y.cmp(E[$].y)===0?(Q[1]=E[K].add(E[$]),Q[2]=E[K].toJ().mixedAdd(E[$].neg())):E[K].y.cmp(E[$].y.redNeg())===0?(Q[1]=E[K].toJ().mixedAdd(E[$]),Q[2]=E[K].add(E[$].neg())):(Q[1]=E[K].toJ().mixedAdd(E[$]),Q[2]=E[K].toJ().mixedAdd(E[$].neg()));var Y=[-3,-1,-5,-7,0,7,5,1,3],ee=I(d[K],d[$]);for(U=Math.max(ee[0].length,U),B[K]=new Array(U),B[$]=new Array(U),L=0;L<U;L++){var u=ee[0][L]|0,e=ee[1][L]|0;B[K][L]=Y[(u+1)*3+(e+1)],B[$][L]=0,k[K]=Q}}var r=this.jpoint(null,null,null),n=this._wnafT4;for(C=U;C>=0;C--){for(var i=0;C>=0;){var f=!0;for(L=0;L<A;L++)n[L]=B[L][C]|0,n[L]!==0&&(f=!1);if(!f)break;i++,C--}if(C>=0&&i++,r=r.dblp(i),C<0)break;for(L=0;L<A;L++){var c=n[L];c!==0&&(c>0?N=k[L][c-1>>1]:c<0&&(N=k[L][-c-1>>1].neg()),N.type==="affine"?r=r.mixedAdd(N):r=r.add(N))}}for(C=0;C<A;C++)k[C]=null;return v?r:r.toP()};function l(g,M){this.curve=g,this.type=M,this.precomputed=null}m.BasePoint=l,l.prototype.eq=function(){throw new Error("Not implemented")},l.prototype.validate=function(){return this.curve.validate(this)},m.prototype.decodePoint=function(M,E){M=y.toArray(M,E);var d=this.p.byteLength();if((M[0]===4||M[0]===6||M[0]===7)&&M.length-1===2*d){M[0]===6?o(M[M.length-1]%2===0):M[0]===7&&o(M[M.length-1]%2===1);var A=this.point(M.slice(1,1+d),M.slice(1+d,1+2*d));return A}else if((M[0]===2||M[0]===3)&&M.length-1===d)return this.pointFromX(M.slice(1,1+d),M[0]===3);throw new Error("Unknown point format")},l.prototype.encodeCompressed=function(M){return this.encode(M,!0)},l.prototype._encode=function(M){var E=this.curve.p.byteLength(),d=this.getX().toArray("be",E);return M?[this.getY().isEven()?2:3].concat(d):[4].concat(d,this.getY().toArray("be",E))},l.prototype.encode=function(M,E){return y.encode(this._encode(E),M)},l.prototype.precompute=function(M){if(this.precomputed)return this;var E={doubles:null,naf:null,beta:null};return E.naf=this._getNAFPoints(8),E.doubles=this._getDoubles(4,M),E.beta=this._getBeta(),this.precomputed=E,this},l.prototype._hasDoubles=function(M){if(!this.precomputed)return!1;var E=this.precomputed.doubles;return E?E.points.length>=Math.ceil((M.bitLength()+1)/E.step):!1},l.prototype._getDoubles=function(M,E){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var d=[this],A=this,v=0;v<E;v+=M){for(var b=0;b<M;b++)A=A.dbl();d.push(A)}return{step:M,points:d}},l.prototype._getNAFPoints=function(M){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var E=[this],d=(1<<M)-1,A=d===1?null:this.dbl(),v=1;v<d;v++)E[v]=E[v-1].add(A);return{wnd:M,points:E}},l.prototype._getBeta=function(){return null},l.prototype.dblp=function(M){for(var E=this,d=0;d<M;d++)E=E.dbl();return E}},1298:(fe,x,T)=>{"use strict";var S=T(7011),y=T(8490),p=T(6698),I=T(6677),o=S.assert;function m(g){this.twisted=(g.a|0)!==1,this.mOneA=this.twisted&&(g.a|0)===-1,this.extended=this.mOneA,I.call(this,"edwards",g),this.a=new y(g.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new y(g.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new y(g.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),o(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(g.c|0)===1}p(m,I),fe.exports=m,m.prototype._mulA=function(M){return this.mOneA?M.redNeg():this.a.redMul(M)},m.prototype._mulC=function(M){return this.oneC?M:this.c.redMul(M)},m.prototype.jpoint=function(M,E,d,A){return this.point(M,E,d,A)},m.prototype.pointFromX=function(M,E){M=new y(M,16),M.red||(M=M.toRed(this.red));var d=M.redSqr(),A=this.c2.redSub(this.a.redMul(d)),v=this.one.redSub(this.c2.redMul(this.d).redMul(d)),b=A.redMul(v.redInvm()),k=b.redSqrt();if(k.redSqr().redSub(b).cmp(this.zero)!==0)throw new Error("invalid point");var B=k.fromRed().isOdd();return(E&&!B||!E&&B)&&(k=k.redNeg()),this.point(M,k)},m.prototype.pointFromY=function(M,E){M=new y(M,16),M.red||(M=M.toRed(this.red));var d=M.redSqr(),A=d.redSub(this.c2),v=d.redMul(this.d).redMul(this.c2).redSub(this.a),b=A.redMul(v.redInvm());if(b.cmp(this.zero)===0){if(E)throw new Error("invalid point");return this.point(this.zero,M)}var k=b.redSqrt();if(k.redSqr().redSub(b).cmp(this.zero)!==0)throw new Error("invalid point");return k.fromRed().isOdd()!==E&&(k=k.redNeg()),this.point(k,M)},m.prototype.validate=function(M){if(M.isInfinity())return!0;M.normalize();var E=M.x.redSqr(),d=M.y.redSqr(),A=E.redMul(this.a).redAdd(d),v=this.c2.redMul(this.one.redAdd(this.d.redMul(E).redMul(d)));return A.cmp(v)===0};function l(g,M,E,d,A){I.BasePoint.call(this,g,"projective"),M===null&&E===null&&d===null?(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 y(M,16),this.y=new y(E,16),this.z=d?new y(d,16):this.curve.one,this.t=A&&new y(A,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()))))}p(l,I.BasePoint),m.prototype.pointFromJSON=function(M){return l.fromJSON(this,M)},m.prototype.point=function(M,E,d,A){return new l(this,M,E,d,A)},l.fromJSON=function(M,E){return new l(M,E[0],E[1],E[2])},l.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},l.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},l.prototype._extDbl=function(){var M=this.x.redSqr(),E=this.y.redSqr(),d=this.z.redSqr();d=d.redIAdd(d);var A=this.curve._mulA(M),v=this.x.redAdd(this.y).redSqr().redISub(M).redISub(E),b=A.redAdd(E),k=b.redSub(d),B=A.redSub(E),U=v.redMul(k),C=b.redMul(B),L=v.redMul(B),N=k.redMul(b);return this.curve.point(U,C,N,L)},l.prototype._projDbl=function(){var M=this.x.redAdd(this.y).redSqr(),E=this.x.redSqr(),d=this.y.redSqr(),A,v,b,k,B,U;if(this.curve.twisted){k=this.curve._mulA(E);var C=k.redAdd(d);this.zOne?(A=M.redSub(E).redSub(d).redMul(C.redSub(this.curve.two)),v=C.redMul(k.redSub(d)),b=C.redSqr().redSub(C).redSub(C)):(B=this.z.redSqr(),U=C.redSub(B).redISub(B),A=M.redSub(E).redISub(d).redMul(U),v=C.redMul(k.redSub(d)),b=C.redMul(U))}else k=E.redAdd(d),B=this.curve._mulC(this.z).redSqr(),U=k.redSub(B).redSub(B),A=this.curve._mulC(M.redISub(k)).redMul(U),v=this.curve._mulC(k).redMul(E.redISub(d)),b=k.redMul(U);return this.curve.point(A,v,b)},l.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},l.prototype._extAdd=function(M){var E=this.y.redSub(this.x).redMul(M.y.redSub(M.x)),d=this.y.redAdd(this.x).redMul(M.y.redAdd(M.x)),A=this.t.redMul(this.curve.dd).redMul(M.t),v=this.z.redMul(M.z.redAdd(M.z)),b=d.redSub(E),k=v.redSub(A),B=v.redAdd(A),U=d.redAdd(E),C=b.redMul(k),L=B.redMul(U),N=b.redMul(U),j=k.redMul(B);return this.curve.point(C,L,j,N)},l.prototype._projAdd=function(M){var E=this.z.redMul(M.z),d=E.redSqr(),A=this.x.redMul(M.x),v=this.y.redMul(M.y),b=this.curve.d.redMul(A).redMul(v),k=d.redSub(b),B=d.redAdd(b),U=this.x.redAdd(this.y).redMul(M.x.redAdd(M.y)).redISub(A).redISub(v),C=E.redMul(k).redMul(U),L,N;return this.curve.twisted?(L=E.redMul(B).redMul(v.redSub(this.curve._mulA(A))),N=k.redMul(B)):(L=E.redMul(B).redMul(v.redSub(A)),N=this.curve._mulC(k).redMul(B)),this.curve.point(C,L,N)},l.prototype.add=function(M){return this.isInfinity()?M:M.isInfinity()?this:this.curve.extended?this._extAdd(M):this._projAdd(M)},l.prototype.mul=function(M){return this._hasDoubles(M)?this.curve._fixedNafMul(this,M):this.curve._wnafMul(this,M)},l.prototype.mulAdd=function(M,E,d){return this.curve._wnafMulAdd(1,[this,E],[M,d],2,!1)},l.prototype.jmulAdd=function(M,E,d){return this.curve._wnafMulAdd(1,[this,E],[M,d],2,!0)},l.prototype.normalize=function(){if(this.zOne)return this;var M=this.z.redInvm();return this.x=this.x.redMul(M),this.y=this.y.redMul(M),this.t&&(this.t=this.t.redMul(M)),this.z=this.curve.one,this.zOne=!0,this},l.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},l.prototype.getX=function(){return this.normalize(),this.x.fromRed()},l.prototype.getY=function(){return this.normalize(),this.y.fromRed()},l.prototype.eq=function(M){return this===M||this.getX().cmp(M.getX())===0&&this.getY().cmp(M.getY())===0},l.prototype.eqXToP=function(M){var E=M.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(E)===0)return!0;for(var d=M.clone(),A=this.curve.redN.redMul(this.z);;){if(d.iadd(this.curve.n),d.cmp(this.curve.p)>=0)return!1;if(E.redIAdd(A),this.x.cmp(E)===0)return!0}},l.prototype.toP=l.prototype.normalize,l.prototype.mixedAdd=l.prototype.add},894:(fe,x,T)=>{"use strict";var S=x;S.base=T(6677),S.short=T(9188),S.mont=T(370),S.edwards=T(1298)},370:(fe,x,T)=>{"use strict";var S=T(8490),y=T(6698),p=T(6677),I=T(7011);function o(l){p.call(this,"mont",l),this.a=new S(l.a,16).toRed(this.red),this.b=new S(l.b,16).toRed(this.red),this.i4=new S(4).toRed(this.red).redInvm(),this.two=new S(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}y(o,p),fe.exports=o,o.prototype.validate=function(g){var M=g.normalize().x,E=M.redSqr(),d=E.redMul(M).redAdd(E.redMul(this.a)).redAdd(M),A=d.redSqrt();return A.redSqr().cmp(d)===0};function m(l,g,M){p.BasePoint.call(this,l,"projective"),g===null&&M===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new S(g,16),this.z=new S(M,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}y(m,p.BasePoint),o.prototype.decodePoint=function(g,M){return this.point(I.toArray(g,M),1)},o.prototype.point=function(g,M){return new m(this,g,M)},o.prototype.pointFromJSON=function(g){return m.fromJSON(this,g)},m.prototype.precompute=function(){},m.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},m.fromJSON=function(g,M){return new m(g,M[0],M[1]||g.one)},m.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},m.prototype.isInfinity=function(){return this.z.cmpn(0)===0},m.prototype.dbl=function(){var g=this.x.redAdd(this.z),M=g.redSqr(),E=this.x.redSub(this.z),d=E.redSqr(),A=M.redSub(d),v=M.redMul(d),b=A.redMul(d.redAdd(this.curve.a24.redMul(A)));return this.curve.point(v,b)},m.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},m.prototype.diffAdd=function(g,M){var E=this.x.redAdd(this.z),d=this.x.redSub(this.z),A=g.x.redAdd(g.z),v=g.x.redSub(g.z),b=v.redMul(E),k=A.redMul(d),B=M.z.redMul(b.redAdd(k).redSqr()),U=M.x.redMul(b.redISub(k).redSqr());return this.curve.point(B,U)},m.prototype.mul=function(g){for(var M=g.clone(),E=this,d=this.curve.point(null,null),A=this,v=[];M.cmpn(0)!==0;M.iushrn(1))v.push(M.andln(1));for(var b=v.length-1;b>=0;b--)v[b]===0?(E=E.diffAdd(d,A),d=d.dbl()):(d=E.diffAdd(d,A),E=E.dbl());return d},m.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},m.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},m.prototype.eq=function(g){return this.getX().cmp(g.getX())===0},m.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},m.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},9188:(fe,x,T)=>{"use strict";var S=T(7011),y=T(8490),p=T(6698),I=T(6677),o=S.assert;function m(M){I.call(this,"short",M),this.a=new y(M.a,16).toRed(this.red),this.b=new y(M.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(M),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}p(m,I),fe.exports=m,m.prototype._getEndomorphism=function(E){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var d,A;if(E.beta)d=new y(E.beta,16).toRed(this.red);else{var v=this._getEndoRoots(this.p);d=v[0].cmp(v[1])<0?v[0]:v[1],d=d.toRed(this.red)}if(E.lambda)A=new y(E.lambda,16);else{var b=this._getEndoRoots(this.n);this.g.mul(b[0]).x.cmp(this.g.x.redMul(d))===0?A=b[0]:(A=b[1],o(this.g.mul(A).x.cmp(this.g.x.redMul(d))===0))}var k;return E.basis?k=E.basis.map(function(B){return{a:new y(B.a,16),b:new y(B.b,16)}}):k=this._getEndoBasis(A),{beta:d,lambda:A,basis:k}}},m.prototype._getEndoRoots=function(E){var d=E===this.p?this.red:y.mont(E),A=new y(2).toRed(d).redInvm(),v=A.redNeg(),b=new y(3).toRed(d).redNeg().redSqrt().redMul(A),k=v.redAdd(b).fromRed(),B=v.redSub(b).fromRed();return[k,B]},m.prototype._getEndoBasis=function(E){for(var d=this.n.ushrn(Math.floor(this.n.bitLength()/2)),A=E,v=this.n.clone(),b=new y(1),k=new y(0),B=new y(0),U=new y(1),C,L,N,j,K,$,Q,Y=0,ee,u;A.cmpn(0)!==0;){var e=v.div(A);ee=v.sub(e.mul(A)),u=B.sub(e.mul(b));var r=U.sub(e.mul(k));if(!N&&ee.cmp(d)<0)C=Q.neg(),L=b,N=ee.neg(),j=u;else if(N&&++Y===2)break;Q=ee,v=A,A=ee,B=b,b=u,U=k,k=r}K=ee.neg(),$=u;var n=N.sqr().add(j.sqr()),i=K.sqr().add($.sqr());return i.cmp(n)>=0&&(K=C,$=L),N.negative&&(N=N.neg(),j=j.neg()),K.negative&&(K=K.neg(),$=$.neg()),[{a:N,b:j},{a:K,b:$}]},m.prototype._endoSplit=function(E){var d=this.endo.basis,A=d[0],v=d[1],b=v.b.mul(E).divRound(this.n),k=A.b.neg().mul(E).divRound(this.n),B=b.mul(A.a),U=k.mul(v.a),C=b.mul(A.b),L=k.mul(v.b),N=E.sub(B).sub(U),j=C.add(L).neg();return{k1:N,k2:j}},m.prototype.pointFromX=function(E,d){E=new y(E,16),E.red||(E=E.toRed(this.red));var A=E.redSqr().redMul(E).redIAdd(E.redMul(this.a)).redIAdd(this.b),v=A.redSqrt();if(v.redSqr().redSub(A).cmp(this.zero)!==0)throw new Error("invalid point");var b=v.fromRed().isOdd();return(d&&!b||!d&&b)&&(v=v.redNeg()),this.point(E,v)},m.prototype.validate=function(E){if(E.inf)return!0;var d=E.x,A=E.y,v=this.a.redMul(d),b=d.redSqr().redMul(d).redIAdd(v).redIAdd(this.b);return A.redSqr().redISub(b).cmpn(0)===0},m.prototype._endoWnafMulAdd=function(E,d,A){for(var v=this._endoWnafT1,b=this._endoWnafT2,k=0;k<E.length;k++){var B=this._endoSplit(d[k]),U=E[k],C=U._getBeta();B.k1.negative&&(B.k1.ineg(),U=U.neg(!0)),B.k2.negative&&(B.k2.ineg(),C=C.neg(!0)),v[k*2]=U,v[k*2+1]=C,b[k*2]=B.k1,b[k*2+1]=B.k2}for(var L=this._wnafMulAdd(1,v,b,k*2,A),N=0;N<k*2;N++)v[N]=null,b[N]=null;return L};function l(M,E,d,A){I.BasePoint.call(this,M,"affine"),E===null&&d===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new y(E,16),this.y=new y(d,16),A&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}p(l,I.BasePoint),m.prototype.point=function(E,d,A){return new l(this,E,d,A)},m.prototype.pointFromJSON=function(E,d){return l.fromJSON(this,E,d)},l.prototype._getBeta=function(){if(this.curve.endo){var E=this.precomputed;if(E&&E.beta)return E.beta;var d=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(E){var A=this.curve,v=function(b){return A.point(b.x.redMul(A.endo.beta),b.y)};E.beta=d,d.precomputed={beta:null,naf:E.naf&&{wnd:E.naf.wnd,points:E.naf.points.map(v)},doubles:E.doubles&&{step:E.doubles.step,points:E.doubles.points.map(v)}}}return d}},l.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},l.fromJSON=function(E,d,A){typeof d=="string"&&(d=JSON.parse(d));var v=E.point(d[0],d[1],A);if(!d[2])return v;function b(B){return E.point(B[0],B[1],A)}var k=d[2];return v.precomputed={beta:null,doubles:k.doubles&&{step:k.doubles.step,points:[v].concat(k.doubles.points.map(b))},naf:k.naf&&{wnd:k.naf.wnd,points:[v].concat(k.naf.points.map(b))}},v},l.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},l.prototype.isInfinity=function(){return this.inf},l.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(this.x.cmp(E.x)===0)return this.curve.point(null,null);var d=this.y.redSub(E.y);d.cmpn(0)!==0&&(d=d.redMul(this.x.redSub(E.x).redInvm()));var A=d.redSqr().redISub(this.x).redISub(E.x),v=d.redMul(this.x.redSub(A)).redISub(this.y);return this.curve.point(A,v)},l.prototype.dbl=function(){if(this.inf)return this;var E=this.y.redAdd(this.y);if(E.cmpn(0)===0)return this.curve.point(null,null);var d=this.curve.a,A=this.x.redSqr(),v=E.redInvm(),b=A.redAdd(A).redIAdd(A).redIAdd(d).redMul(v),k=b.redSqr().redISub(this.x.redAdd(this.x)),B=b.redMul(this.x.redSub(k)).redISub(this.y);return this.curve.point(k,B)},l.prototype.getX=function(){return this.x.fromRed()},l.prototype.getY=function(){return this.y.fromRed()},l.prototype.mul=function(E){return E=new y(E,16),this.isInfinity()?this:this._hasDoubles(E)?this.curve._fixedNafMul(this,E):this.curve.endo?this.curve._endoWnafMulAdd([this],[E]):this.curve._wnafMul(this,E)},l.prototype.mulAdd=function(E,d,A){var v=[this,d],b=[E,A];return this.curve.endo?this.curve._endoWnafMulAdd(v,b):this.curve._wnafMulAdd(1,v,b,2)},l.prototype.jmulAdd=function(E,d,A){var v=[this,d],b=[E,A];return this.curve.endo?this.curve._endoWnafMulAdd(v,b,!0):this.curve._wnafMulAdd(1,v,b,2,!0)},l.prototype.eq=function(E){return this===E||this.inf===E.inf&&(this.inf||this.x.cmp(E.x)===0&&this.y.cmp(E.y)===0)},l.prototype.neg=function(E){if(this.inf)return this;var d=this.curve.point(this.x,this.y.redNeg());if(E&&this.precomputed){var A=this.precomputed,v=function(b){return b.neg()};d.precomputed={naf:A.naf&&{wnd:A.naf.wnd,points:A.naf.points.map(v)},doubles:A.doubles&&{step:A.doubles.step,points:A.doubles.points.map(v)}}}return d},l.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var E=this.curve.jpoint(this.x,this.y,this.curve.one);return E};function g(M,E,d,A){I.BasePoint.call(this,M,"jacobian"),E===null&&d===null&&A===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new y(0)):(this.x=new y(E,16),this.y=new y(d,16),this.z=new y(A,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}p(g,I.BasePoint),m.prototype.jpoint=function(E,d,A){return new g(this,E,d,A)},g.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var E=this.z.redInvm(),d=E.redSqr(),A=this.x.redMul(d),v=this.y.redMul(d).redMul(E);return this.curve.point(A,v)},g.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},g.prototype.add=function(E){if(this.isInfinity())return E;if(E.isInfinity())return this;var d=E.z.redSqr(),A=this.z.redSqr(),v=this.x.redMul(d),b=E.x.redMul(A),k=this.y.redMul(d.redMul(E.z)),B=E.y.redMul(A.redMul(this.z)),U=v.redSub(b),C=k.redSub(B);if(U.cmpn(0)===0)return C.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var L=U.redSqr(),N=L.redMul(U),j=v.redMul(L),K=C.redSqr().redIAdd(N).redISub(j).redISub(j),$=C.redMul(j.redISub(K)).redISub(k.redMul(N)),Q=this.z.redMul(E.z).redMul(U);return this.curve.jpoint(K,$,Q)},g.prototype.mixedAdd=function(E){if(this.isInfinity())return E.toJ();if(E.isInfinity())return this;var d=this.z.redSqr(),A=this.x,v=E.x.redMul(d),b=this.y,k=E.y.redMul(d).redMul(this.z),B=A.redSub(v),U=b.redSub(k);if(B.cmpn(0)===0)return U.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var C=B.redSqr(),L=C.redMul(B),N=A.redMul(C),j=U.redSqr().redIAdd(L).redISub(N).redISub(N),K=U.redMul(N.redISub(j)).redISub(b.redMul(L)),$=this.z.redMul(B);return this.curve.jpoint(j,K,$)},g.prototype.dblp=function(E){if(E===0)return this;if(this.isInfinity())return this;if(!E)return this.dbl();var d;if(this.curve.zeroA||this.curve.threeA){var A=this;for(d=0;d<E;d++)A=A.dbl();return A}var v=this.curve.a,b=this.curve.tinv,k=this.x,B=this.y,U=this.z,C=U.redSqr().redSqr(),L=B.redAdd(B);for(d=0;d<E;d++){var N=k.redSqr(),j=L.redSqr(),K=j.redSqr(),$=N.redAdd(N).redIAdd(N).redIAdd(v.redMul(C)),Q=k.redMul(j),Y=$.redSqr().redISub(Q.redAdd(Q)),ee=Q.redISub(Y),u=$.redMul(ee);u=u.redIAdd(u).redISub(K);var e=L.redMul(U);d+1<E&&(C=C.redMul(K)),k=Y,U=e,L=u}return this.curve.jpoint(k,L.redMul(b),U)},g.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},g.prototype._zeroDbl=function(){var E,d,A;if(this.zOne){var v=this.x.redSqr(),b=this.y.redSqr(),k=b.redSqr(),B=this.x.redAdd(b).redSqr().redISub(v).redISub(k);B=B.redIAdd(B);var U=v.redAdd(v).redIAdd(v),C=U.redSqr().redISub(B).redISub(B),L=k.redIAdd(k);L=L.redIAdd(L),L=L.redIAdd(L),E=C,d=U.redMul(B.redISub(C)).redISub(L),A=this.y.redAdd(this.y)}else{var N=this.x.redSqr(),j=this.y.redSqr(),K=j.redSqr(),$=this.x.redAdd(j).redSqr().redISub(N).redISub(K);$=$.redIAdd($);var Q=N.redAdd(N).redIAdd(N),Y=Q.redSqr(),ee=K.redIAdd(K);ee=ee.redIAdd(ee),ee=ee.redIAdd(ee),E=Y.redISub($).redISub($),d=Q.redMul($.redISub(E)).redISub(ee),A=this.y.redMul(this.z),A=A.redIAdd(A)}return this.curve.jpoint(E,d,A)},g.prototype._threeDbl=function(){var E,d,A;if(this.zOne){var v=this.x.redSqr(),b=this.y.redSqr(),k=b.redSqr(),B=this.x.redAdd(b).redSqr().redISub(v).redISub(k);B=B.redIAdd(B);var U=v.redAdd(v).redIAdd(v).redIAdd(this.curve.a),C=U.redSqr().redISub(B).redISub(B);E=C;var L=k.redIAdd(k);L=L.redIAdd(L),L=L.redIAdd(L),d=U.redMul(B.redISub(C)).redISub(L),A=this.y.redAdd(this.y)}else{var N=this.z.redSqr(),j=this.y.redSqr(),K=this.x.redMul(j),$=this.x.redSub(N).redMul(this.x.redAdd(N));$=$.redAdd($).redIAdd($);var Q=K.redIAdd(K);Q=Q.redIAdd(Q);var Y=Q.redAdd(Q);E=$.redSqr().redISub(Y),A=this.y.redAdd(this.z).redSqr().redISub(j).redISub(N);var ee=j.redSqr();ee=ee.redIAdd(ee),ee=ee.redIAdd(ee),ee=ee.redIAdd(ee),d=$.redMul(Q.redISub(E)).redISub(ee)}return this.curve.jpoint(E,d,A)},g.prototype._dbl=function(){var E=this.curve.a,d=this.x,A=this.y,v=this.z,b=v.redSqr().redSqr(),k=d.redSqr(),B=A.redSqr(),U=k.redAdd(k).redIAdd(k).redIAdd(E.redMul(b)),C=d.redAdd(d);C=C.redIAdd(C);var L=C.redMul(B),N=U.redSqr().redISub(L.redAdd(L)),j=L.redISub(N),K=B.redSqr();K=K.redIAdd(K),K=K.redIAdd(K),K=K.redIAdd(K);var $=U.redMul(j).redISub(K),Q=A.redAdd(A).redMul(v);return this.curve.jpoint(N,$,Q)},g.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var E=this.x.redSqr(),d=this.y.redSqr(),A=this.z.redSqr(),v=d.redSqr(),b=E.redAdd(E).redIAdd(E),k=b.redSqr(),B=this.x.redAdd(d).redSqr().redISub(E).redISub(v);B=B.redIAdd(B),B=B.redAdd(B).redIAdd(B),B=B.redISub(k);var U=B.redSqr(),C=v.redIAdd(v);C=C.redIAdd(C),C=C.redIAdd(C),C=C.redIAdd(C);var L=b.redIAdd(B).redSqr().redISub(k).redISub(U).redISub(C),N=d.redMul(L);N=N.redIAdd(N),N=N.redIAdd(N);var j=this.x.redMul(U).redISub(N);j=j.redIAdd(j),j=j.redIAdd(j);var K=this.y.redMul(L.redMul(C.redISub(L)).redISub(B.redMul(U)));K=K.redIAdd(K),K=K.redIAdd(K),K=K.redIAdd(K);var $=this.z.redAdd(B).redSqr().redISub(A).redISub(U);return this.curve.jpoint(j,K,$)},g.prototype.mul=function(E,d){return E=new y(E,d),this.curve._wnafMul(this,E)},g.prototype.eq=function(E){if(E.type==="affine")return this.eq(E.toJ());if(this===E)return!0;var d=this.z.redSqr(),A=E.z.redSqr();if(this.x.redMul(A).redISub(E.x.redMul(d)).cmpn(0)!==0)return!1;var v=d.redMul(this.z),b=A.redMul(E.z);return this.y.redMul(b).redISub(E.y.redMul(v)).cmpn(0)===0},g.prototype.eqXToP=function(E){var d=this.z.redSqr(),A=E.toRed(this.curve.red).redMul(d);if(this.x.cmp(A)===0)return!0;for(var v=E.clone(),b=this.curve.redN.redMul(d);;){if(v.iadd(this.curve.n),v.cmp(this.curve.p)>=0)return!1;if(A.redIAdd(b),this.x.cmp(A)===0)return!0}},g.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},g.prototype.isInfinity=function(){return this.z.cmpn(0)===0}},480:(fe,x,T)=>{"use strict";var S=x,y=T(7952),p=T(894),I=T(7011),o=I.assert;function m(M){M.type==="short"?this.curve=new p.short(M):M.type==="edwards"?this.curve=new p.edwards(M):this.curve=new p.mont(M),this.g=this.curve.g,this.n=this.curve.n,this.hash=M.hash,o(this.g.validate(),"Invalid curve"),o(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}S.PresetCurve=m;function l(M,E){Object.defineProperty(S,M,{configurable:!0,enumerable:!0,get:function(){var d=new m(E);return Object.defineProperty(S,M,{configurable:!0,enumerable:!0,value:d}),d}})}l("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:y.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),l("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:y.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),l("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:y.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),l("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:y.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"]}),l("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:y.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"]}),l("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:y.sha256,gRed:!1,g:["9"]}),l("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:y.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var g;try{g=T(4011)}catch{g=void 0}l("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:y.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",g]})},7447:(fe,x,T)=>{"use strict";var S=T(8490),y=T(2723),p=T(7011),I=T(480),o=T(5037),m=p.assert,l=T(1200),g=T(8545);function M(E){if(!(this instanceof M))return new M(E);typeof E=="string"&&(m(Object.prototype.hasOwnProperty.call(I,E),"Unknown curve "+E),E=I[E]),E instanceof I.PresetCurve&&(E={curve:E}),this.curve=E.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(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}fe.exports=M,M.prototype.keyPair=function(d){return new l(this,d)},M.prototype.keyFromPrivate=function(d,A){return l.fromPrivate(this,d,A)},M.prototype.keyFromPublic=function(d,A){return l.fromPublic(this,d,A)},M.prototype.genKeyPair=function(d){d||(d={});for(var A=new y({hash:this.hash,pers:d.pers,persEnc:d.persEnc||"utf8",entropy:d.entropy||o(this.hash.hmacStrength),entropyEnc:d.entropy&&d.entropyEnc||"utf8",nonce:this.n.toArray()}),v=this.n.byteLength(),b=this.n.sub(new S(2));;){var k=new S(A.generate(v));if(!(k.cmp(b)>0))return k.iaddn(1),this.keyFromPrivate(k)}},M.prototype._truncateToN=function(d,A){var v=d.byteLength()*8-this.n.bitLength();return v>0&&(d=d.ushrn(v)),!A&&d.cmp(this.n)>=0?d.sub(this.n):d},M.prototype.sign=function(d,A,v,b){typeof v=="object"&&(b=v,v=null),b||(b={}),A=this.keyFromPrivate(A,v),d=this._truncateToN(new S(d,16));for(var k=this.n.byteLength(),B=A.getPrivate().toArray("be",k),U=d.toArray("be",k),C=new y({hash:this.hash,entropy:B,nonce:U,pers:b.pers,persEnc:b.persEnc||"utf8"}),L=this.n.sub(new S(1)),N=0;;N++){var j=b.k?b.k(N):new S(C.generate(this.n.byteLength()));if(j=this._truncateToN(j,!0),!(j.cmpn(1)<=0||j.cmp(L)>=0)){var K=this.g.mul(j);if(!K.isInfinity()){var $=K.getX(),Q=$.umod(this.n);if(Q.cmpn(0)!==0){var Y=j.invm(this.n).mul(Q.mul(A.getPrivate()).iadd(d));if(Y=Y.umod(this.n),Y.cmpn(0)!==0){var ee=(K.getY().isOdd()?1:0)|($.cmp(Q)!==0?2:0);return b.canonical&&Y.cmp(this.nh)>0&&(Y=this.n.sub(Y),ee^=1),new g({r:Q,s:Y,recoveryParam:ee})}}}}}},M.prototype.verify=function(d,A,v,b){d=this._truncateToN(new S(d,16)),v=this.keyFromPublic(v,b),A=new g(A,"hex");var k=A.r,B=A.s;if(k.cmpn(1)<0||k.cmp(this.n)>=0||B.cmpn(1)<0||B.cmp(this.n)>=0)return!1;var U=B.invm(this.n),C=U.mul(d).umod(this.n),L=U.mul(k).umod(this.n),N;return this.curve._maxwellTrick?(N=this.g.jmulAdd(C,v.getPublic(),L),N.isInfinity()?!1:N.eqXToP(k)):(N=this.g.mulAdd(C,v.getPublic(),L),N.isInfinity()?!1:N.getX().umod(this.n).cmp(k)===0)},M.prototype.recoverPubKey=function(E,d,A,v){m((3&A)===A,"The recovery param is more than two bits"),d=new g(d,v);var b=this.n,k=new S(E),B=d.r,U=d.s,C=A&1,L=A>>1;if(B.cmp(this.curve.p.umod(this.curve.n))>=0&&L)throw new Error("Unable to find sencond key candinate");L?B=this.curve.pointFromX(B.add(this.curve.n),C):B=this.curve.pointFromX(B,C);var N=d.r.invm(b),j=b.sub(k).mul(N).umod(b),K=U.mul(N).umod(b);return this.g.mulAdd(j,B,K)},M.prototype.getKeyRecoveryParam=function(E,d,A,v){if(d=new g(d,v),d.recoveryParam!==null)return d.recoveryParam;for(var b=0;b<4;b++){var k;try{k=this.recoverPubKey(E,d,b)}catch{continue}if(k.eq(A))return b}throw new Error("Unable to find valid recovery factor")}},1200:(fe,x,T)=>{"use strict";var S=T(8490),y=T(7011),p=y.assert;function I(o,m){this.ec=o,this.priv=null,this.pub=null,m.priv&&this._importPrivate(m.priv,m.privEnc),m.pub&&this._importPublic(m.pub,m.pubEnc)}fe.exports=I,I.fromPublic=function(m,l,g){return l instanceof I?l:new I(m,{pub:l,pubEnc:g})},I.fromPrivate=function(m,l,g){return l instanceof I?l:new I(m,{priv:l,privEnc:g})},I.prototype.validate=function(){var m=this.getPublic();return m.isInfinity()?{result:!1,reason:"Invalid public key"}:m.validate()?m.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"}},I.prototype.getPublic=function(m,l){return typeof m=="string"&&(l=m,m=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),l?this.pub.encode(l,m):this.pub},I.prototype.getPrivate=function(m){return m==="hex"?this.priv.toString(16,2):this.priv},I.prototype._importPrivate=function(m,l){this.priv=new S(m,l||16),this.priv=this.priv.umod(this.ec.curve.n)},I.prototype._importPublic=function(m,l){if(m.x||m.y){this.ec.curve.type==="mont"?p(m.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&p(m.x&&m.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(m.x,m.y);return}this.pub=this.ec.curve.decodePoint(m,l)},I.prototype.derive=function(m){return m.validate()||p(m.validate(),"public point not validated"),m.mul(this.priv).getX()},I.prototype.sign=function(m,l,g){return this.ec.sign(m,this,l,g)},I.prototype.verify=function(m,l){return this.ec.verify(m,l,this)},I.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"}},8545:(fe,x,T)=>{"use strict";var S=T(8490),y=T(7011),p=y.assert;function I(M,E){if(M instanceof I)return M;this._importDER(M,E)||(p(M.r&&M.s,"Signature without r or s"),this.r=new S(M.r,16),this.s=new S(M.s,16),M.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=M.recoveryParam)}fe.exports=I;function o(){this.place=0}function m(M,E){var d=M[E.place++];if(!(d&128))return d;var A=d&15;if(A===0||A>4)return!1;for(var v=0,b=0,k=E.place;b<A;b++,k++)v<<=8,v|=M[k],v>>>=0;return v<=127?!1:(E.place=k,v)}function l(M){for(var E=0,d=M.length-1;!M[E]&&!(M[E+1]&128)&&E<d;)E++;return E===0?M:M.slice(E)}I.prototype._importDER=function(E,d){E=y.toArray(E,d);var A=new o;if(E[A.place++]!==48)return!1;var v=m(E,A);if(v===!1||v+A.place!==E.length||E[A.place++]!==2)return!1;var b=m(E,A);if(b===!1)return!1;var k=E.slice(A.place,b+A.place);if(A.place+=b,E[A.place++]!==2)return!1;var B=m(E,A);if(B===!1||E.length!==B+A.place)return!1;var U=E.slice(A.place,B+A.place);if(k[0]===0)if(k[1]&128)k=k.slice(1);else return!1;if(U[0]===0)if(U[1]&128)U=U.slice(1);else return!1;return this.r=new S(k),this.s=new S(U),this.recoveryParam=null,!0};function g(M,E){if(E<128){M.push(E);return}var d=1+(Math.log(E)/Math.LN2>>>3);for(M.push(d|128);--d;)M.push(E>>>(d<<3)&255);M.push(E)}I.prototype.toDER=function(E){var d=this.r.toArray(),A=this.s.toArray();for(d[0]&128&&(d=[0].concat(d)),A[0]&128&&(A=[0].concat(A)),d=l(d),A=l(A);!A[0]&&!(A[1]&128);)A=A.slice(1);var v=[2];g(v,d.length),v=v.concat(d),v.push(2),g(v,A.length);var b=v.concat(A),k=[48];return g(k,b.length),k=k.concat(b),y.encode(k,E)}},8650:(fe,x,T)=>{"use strict";var S=T(7952),y=T(480),p=T(7011),I=p.assert,o=p.parseBytes,m=T(6661),l=T(220);function g(M){if(I(M==="ed25519","only tested with ed25519 so far"),!(this instanceof g))return new g(M);M=y[M].curve,this.curve=M,this.g=M.g,this.g.precompute(M.n.bitLength()+1),this.pointClass=M.point().constructor,this.encodingLength=Math.ceil(M.n.bitLength()/8),this.hash=S.sha512}fe.exports=g,g.prototype.sign=function(E,d){E=o(E);var A=this.keyFromSecret(d),v=this.hashInt(A.messagePrefix(),E),b=this.g.mul(v),k=this.encodePoint(b),B=this.hashInt(k,A.pubBytes(),E).mul(A.priv()),U=v.add(B).umod(this.curve.n);return this.makeSignature({R:b,S:U,Rencoded:k})},g.prototype.verify=function(E,d,A){E=o(E),d=this.makeSignature(d);var v=this.keyFromPublic(A),b=this.hashInt(d.Rencoded(),v.pubBytes(),E),k=this.g.mul(d.S()),B=d.R().add(v.pub().mul(b));return B.eq(k)},g.prototype.hashInt=function(){for(var E=this.hash(),d=0;d<arguments.length;d++)E.update(arguments[d]);return p.intFromLE(E.digest()).umod(this.curve.n)},g.prototype.keyFromPublic=function(E){return m.fromPublic(this,E)},g.prototype.keyFromSecret=function(E){return m.fromSecret(this,E)},g.prototype.makeSignature=function(E){return E instanceof l?E:new l(this,E)},g.prototype.encodePoint=function(E){var d=E.getY().toArray("le",this.encodingLength);return d[this.encodingLength-1]|=E.getX().isOdd()?128:0,d},g.prototype.decodePoint=function(E){E=p.parseBytes(E);var d=E.length-1,A=E.slice(0,d).concat(E[d]&-129),v=(E[d]&128)!==0,b=p.intFromLE(A);return this.curve.pointFromY(b,v)},g.prototype.encodeInt=function(E){return E.toArray("le",this.encodingLength)},g.prototype.decodeInt=function(E){return p.intFromLE(E)},g.prototype.isPoint=function(E){return E instanceof this.pointClass}},6661:(fe,x,T)=>{"use strict";var S=T(7011),y=S.assert,p=S.parseBytes,I=S.cachedProperty;function o(m,l){this.eddsa=m,this._secret=p(l.secret),m.isPoint(l.pub)?this._pub=l.pub:this._pubBytes=p(l.pub)}o.fromPublic=function(l,g){return g instanceof o?g:new o(l,{pub:g})},o.fromSecret=function(l,g){return g instanceof o?g:new o(l,{secret:g})},o.prototype.secret=function(){return this._secret},I(o,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),I(o,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),I(o,"privBytes",function(){var l=this.eddsa,g=this.hash(),M=l.encodingLength-1,E=g.slice(0,l.encodingLength);return E[0]&=248,E[M]&=127,E[M]|=64,E}),I(o,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),I(o,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),I(o,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),o.prototype.sign=function(l){return y(this._secret,"KeyPair can only verify"),this.eddsa.sign(l,this)},o.prototype.verify=function(l,g){return this.eddsa.verify(l,g,this)},o.prototype.getSecret=function(l){return y(this._secret,"KeyPair is public only"),S.encode(this.secret(),l)},o.prototype.getPublic=function(l){return S.encode(this.pubBytes(),l)},fe.exports=o},220:(fe,x,T)=>{"use strict";var S=T(8490),y=T(7011),p=y.assert,I=y.cachedProperty,o=y.parseBytes;function m(l,g){this.eddsa=l,typeof g!="object"&&(g=o(g)),Array.isArray(g)&&(g={R:g.slice(0,l.encodingLength),S:g.slice(l.encodingLength)}),p(g.R&&g.S,"Signature without R or S"),l.isPoint(g.R)&&(this._R=g.R),g.S instanceof S&&(this._S=g.S),this._Rencoded=Array.isArray(g.R)?g.R:g.Rencoded,this._Sencoded=Array.isArray(g.S)?g.S:g.Sencoded}I(m,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),I(m,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),I(m,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),I(m,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),m.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},m.prototype.toHex=function(){return y.encode(this.toBytes(),"hex").toUpperCase()},fe.exports=m},4011:fe=>{fe.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"]]}}},7011:(fe,x,T)=>{"use strict";var S=x,y=T(8490),p=T(3349),I=T(4367);S.assert=p,S.toArray=I.toArray,S.zero2=I.zero2,S.toHex=I.toHex,S.encode=I.encode;function o(E,d,A){var v=new Array(Math.max(E.bitLength(),A)+1);v.fill(0);for(var b=1<<d+1,k=E.clone(),B=0;B<v.length;B++){var U,C=k.andln(b-1);k.isOdd()?(C>(b>>1)-1?U=(b>>1)-C:U=C,k.isubn(U)):U=0,v[B]=U,k.iushrn(1)}return v}S.getNAF=o;function m(E,d){var A=[[],[]];E=E.clone(),d=d.clone();for(var v=0,b=0,k;E.cmpn(-v)>0||d.cmpn(-b)>0;){var B=E.andln(3)+v&3,U=d.andln(3)+b&3;B===3&&(B=-1),U===3&&(U=-1);var C;B&1?(k=E.andln(7)+v&7,(k===3||k===5)&&U===2?C=-B:C=B):C=0,A[0].push(C);var L;U&1?(k=d.andln(7)+b&7,(k===3||k===5)&&B===2?L=-U:L=U):L=0,A[1].push(L),2*v===C+1&&(v=1-v),2*b===L+1&&(b=1-b),E.iushrn(1),d.iushrn(1)}return A}S.getJSF=m;function l(E,d,A){var v="_"+d;E.prototype[d]=function(){return this[v]!==void 0?this[v]:this[v]=A.call(this)}}S.cachedProperty=l;function g(E){return typeof E=="string"?S.toArray(E,"hex"):E}S.parseBytes=g;function M(E){return new y(E,"hex","le")}S.intFromLE=M},8490:function(fe,x,T){fe=T.nmd(fe),function(S,y){"use strict";function p(u,e){if(!u)throw new Error(e||"Assertion failed")}function I(u,e){u.super_=e;var r=function(){};r.prototype=e.prototype,u.prototype=new r,u.prototype.constructor=u}function o(u,e,r){if(o.isBN(u))return u;this.negative=0,this.words=null,this.length=0,this.red=null,u!==null&&((e==="le"||e==="be")&&(r=e,e=10),this._init(u||0,e||10,r||"be"))}typeof S=="object"?S.exports=o:y.BN=o,o.BN=o,o.wordSize=26;var m;try{typeof window<"u"&&typeof window.Buffer<"u"?m=window.Buffer:m=T(9368).Buffer}catch{}o.isBN=function(e){return e instanceof o?!0:e!==null&&typeof e=="object"&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,r){return e.cmp(r)>0?e:r},o.min=function(e,r){return e.cmp(r)<0?e:r},o.prototype._init=function(e,r,n){if(typeof e=="number")return this._initNumber(e,r,n);if(typeof e=="object")return this._initArray(e,r,n);r==="hex"&&(r=16),p(r===(r|0)&&r>=2&&r<=36),e=e.toString().replace(/\s+/g,"");var i=0;e[0]==="-"&&(i++,this.negative=1),i<e.length&&(r===16?this._parseHex(e,i,n):(this._parseBase(e,r,i),n==="le"&&this._initArray(this.toArray(),r,n)))},o.prototype._initNumber=function(e,r,n){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[e&67108863],this.length=1):e<4503599627370496?(this.words=[e&67108863,e/67108864&67108863],this.length=2):(p(e<9007199254740992),this.words=[e&67108863,e/67108864&67108863,1],this.length=3),n==="le"&&this._initArray(this.toArray(),r,n)},o.prototype._initArray=function(e,r,n){if(p(typeof e.length=="number"),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<this.length;i++)this.words[i]=0;var f,c,h=0;if(n==="be")for(i=e.length-1,f=0;i>=0;i-=3)c=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[f]|=c<<h&67108863,this.words[f+1]=c>>>26-h&67108863,h+=24,h>=26&&(h-=26,f++);else if(n==="le")for(i=0,f=0;i<e.length;i+=3)c=e[i]|e[i+1]<<8|e[i+2]<<16,this.words[f]|=c<<h&67108863,this.words[f+1]=c>>>26-h&67108863,h+=24,h>=26&&(h-=26,f++);return this.strip()};function l(u,e){var r=u.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function g(u,e,r){var n=l(u,r);return r-1>=e&&(n|=l(u,r-1)<<4),n}o.prototype._parseHex=function(e,r,n){this.length=Math.ceil((e.length-r)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var f=0,c=0,h;if(n==="be")for(i=e.length-1;i>=r;i-=2)h=g(e,r,i)<<f,this.words[c]|=h&67108863,f>=18?(f-=18,c+=1,this.words[c]|=h>>>26):f+=8;else{var s=e.length-r;for(i=s%2===0?r+1:r;i<e.length;i+=2)h=g(e,r,i)<<f,this.words[c]|=h&67108863,f>=18?(f-=18,c+=1,this.words[c]|=h>>>26):f+=8}this.strip()};function M(u,e,r,n){for(var i=0,f=Math.min(u.length,r),c=e;c<f;c++){var h=u.charCodeAt(c)-48;i*=n,h>=49?i+=h-49+10:h>=17?i+=h-17+10:i+=h}return i}o.prototype._parseBase=function(e,r,n){this.words=[0],this.length=1;for(var i=0,f=1;f<=67108863;f*=r)i++;i--,f=f/r|0;for(var c=e.length-n,h=c%i,s=Math.min(c,c-h)+n,t=0,a=n;a<s;a+=i)t=M(e,a,a+i,r),this.imuln(f),this.words[0]+t<67108864?this.words[0]+=t:this._iaddn(t);if(h!==0){var w=1;for(t=M(e,a,e.length,r),a=0;a<h;a++)w*=r;this.imuln(w),this.words[0]+t<67108864?this.words[0]+=t:this._iaddn(t)}this.strip()},o.prototype.copy=function(e){e.words=new Array(this.length);for(var r=0;r<this.length;r++)e.words[r]=this.words[r];e.length=this.length,e.negative=this.negative,e.red=this.red},o.prototype.clone=function(){var e=new o(null);return this.copy(e),e},o.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},o.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},o.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var E=["","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"],d=[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],A=[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];o.prototype.toString=function(e,r){e=e||10,r=r|0||1;var n;if(e===16||e==="hex"){n="";for(var i=0,f=0,c=0;c<this.length;c++){var h=this.words[c],s=((h<<i|f)&16777215).toString(16);f=h>>>24-i&16777215,f!==0||c!==this.length-1?n=E[6-s.length]+s+n:n=s+n,i+=2,i>=26&&(i-=26,c--)}for(f!==0&&(n=f.toString(16)+n);n.length%r!==0;)n="0"+n;return this.negative!==0&&(n="-"+n),n}if(e===(e|0)&&e>=2&&e<=36){var t=d[e],a=A[e];n="";var w=this.clone();for(w.negative=0;!w.isZero();){var D=w.modn(a).toString(e);w=w.idivn(a),w.isZero()?n=D+n:n=E[t-D.length]+D+n}for(this.isZero()&&(n="0"+n);n.length%r!==0;)n="0"+n;return this.negative!==0&&(n="-"+n),n}p(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return this.length===2?e+=this.words[1]*67108864:this.length===3&&this.words[2]===1?e+=4503599627370496+this.words[1]*67108864:this.length>2&&p(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,r){return p(typeof m<"u"),this.toArrayLike(m,e,r)},o.prototype.toArray=function(e,r){return this.toArrayLike(Array,e,r)},o.prototype.toArrayLike=function(e,r,n){var i=this.byteLength(),f=n||Math.max(1,i);p(i<=f,"byte array longer than desired length"),p(f>0,"Requested array length <= 0"),this.strip();var c=r==="le",h=new e(f),s,t,a=this.clone();if(c){for(t=0;!a.isZero();t++)s=a.andln(255),a.iushrn(8),h[t]=s;for(;t<f;t++)h[t]=0}else{for(t=0;t<f-i;t++)h[t]=0;for(t=0;!a.isZero();t++)s=a.andln(255),a.iushrn(8),h[f-t-1]=s}return h},Math.clz32?o.prototype._countBits=function(e){return 32-Math.clz32(e)}:o.prototype._countBits=function(e){var r=e,n=0;return r>=4096&&(n+=13,r>>>=13),r>=64&&(n+=7,r>>>=7),r>=8&&(n+=4,r>>>=4),r>=2&&(n+=2,r>>>=2),n+r},o.prototype._zeroBits=function(e){if(e===0)return 26;var r=e,n=0;return r&8191||(n+=13,r>>>=13),r&127||(n+=7,r>>>=7),r&15||(n+=4,r>>>=4),r&3||(n+=2,r>>>=2),r&1||n++,n},o.prototype.bitLength=function(){var e=this.words[this.length-1],r=this._countBits(e);return(this.length-1)*26+r};function v(u){for(var e=new Array(u.bitLength()),r=0;r<e.length;r++){var n=r/26|0,i=r%26;e[r]=(u.words[n]&1<<i)>>>i}return e}o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,r=0;r<this.length;r++){var n=this._zeroBits(this.words[r]);if(e+=n,n!==26)break}return e},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(e){return this.negative!==0?this.abs().inotn(e).iaddn(1):this.clone()},o.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return this.negative!==0},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]|e.words[r];return this.strip()},o.prototype.ior=function(e){return p((this.negative|e.negative)===0),this.iuor(e)},o.prototype.or=function(e){return this.length>e.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 r;this.length>e.length?r=e:r=this;for(var n=0;n<r.length;n++)this.words[n]=this.words[n]&e.words[n];return this.length=r.length,this.strip()},o.prototype.iand=function(e){return p((this.negative|e.negative)===0),this.iuand(e)},o.prototype.and=function(e){return this.length>e.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 r,n;this.length>e.length?(r=this,n=e):(r=e,n=this);for(var i=0;i<n.length;i++)this.words[i]=r.words[i]^n.words[i];if(this!==r)for(;i<r.length;i++)this.words[i]=r.words[i];return this.length=r.length,this.strip()},o.prototype.ixor=function(e){return p((this.negative|e.negative)===0),this.iuxor(e)},o.prototype.xor=function(e){return this.length>e.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){p(typeof e=="number"&&e>=0);var r=Math.ceil(e/26)|0,n=e%26;this._expand(r),n>0&&r--;for(var i=0;i<r;i++)this.words[i]=~this.words[i]&67108863;return n>0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,r){p(typeof e=="number"&&e>=0);var n=e/26|0,i=e%26;return this._expand(n+1),r?this.words[n]=this.words[n]|1<<i:this.words[n]=this.words[n]&~(1<<i),this.strip()},o.prototype.iadd=function(e){var r;if(this.negative!==0&&e.negative===0)return this.negative=0,r=this.isub(e),this.negative^=1,this._normSign();if(this.negative===0&&e.negative!==0)return e.negative=0,r=this.isub(e),e.negative=1,r._normSign();var n,i;this.length>e.length?(n=this,i=e):(n=e,i=this);for(var f=0,c=0;c<i.length;c++)r=(n.words[c]|0)+(i.words[c]|0)+f,this.words[c]=r&67108863,f=r>>>26;for(;f!==0&&c<n.length;c++)r=(n.words[c]|0)+f,this.words[c]=r&67108863,f=r>>>26;if(this.length=n.length,f!==0)this.words[this.length]=f,this.length++;else if(n!==this)for(;c<n.length;c++)this.words[c]=n.words[c];return this},o.prototype.add=function(e){var r;return e.negative!==0&&this.negative===0?(e.negative=0,r=this.sub(e),e.negative^=1,r):e.negative===0&&this.negative!==0?(this.negative=0,r=e.sub(this),this.negative=1,r):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(e.negative!==0){e.negative=0;var r=this.iadd(e);return e.negative=1,r._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var n=this.cmp(e);if(n===0)return this.negative=0,this.length=1,this.words[0]=0,this;var i,f;n>0?(i=this,f=e):(i=e,f=this);for(var c=0,h=0;h<f.length;h++)r=(i.words[h]|0)-(f.words[h]|0)+c,c=r>>26,this.words[h]=r&67108863;for(;c!==0&&h<i.length;h++)r=(i.words[h]|0)+c,c=r>>26,this.words[h]=r&67108863;if(c===0&&h<i.length&&i!==this)for(;h<i.length;h++)this.words[h]=i.words[h];return this.length=Math.max(this.length,h),i!==this&&(this.negative=1),this.strip()},o.prototype.sub=function(e){return this.clone().isub(e)};function b(u,e,r){r.negative=e.negative^u.negative;var n=u.length+e.length|0;r.length=n,n=n-1|0;var i=u.words[0]|0,f=e.words[0]|0,c=i*f,h=c&67108863,s=c/67108864|0;r.words[0]=h;for(var t=1;t<n;t++){for(var a=s>>>26,w=s&67108863,D=Math.min(t,e.length-1),Z=Math.max(0,t-u.length+1);Z<=D;Z++){var F=t-Z|0;i=u.words[F]|0,f=e.words[Z]|0,c=i*f+w,a+=c/67108864|0,w=c&67108863}r.words[t]=w|0,s=a|0}return s!==0?r.words[t]=s|0:r.length--,r.strip()}var k=function(e,r,n){var i=e.words,f=r.words,c=n.words,h=0,s,t,a,w=i[0]|0,D=w&8191,Z=w>>>13,F=i[1]|0,V=F&8191,q=F>>>13,re=i[2]|0,G=re&8191,H=re>>>13,oe=i[3]|0,ue=oe&8191,be=oe>>>13,ie=i[4]|0,J=ie&8191,pe=ie>>>13,Ge=i[5]|0,ce=Ge&8191,te=Ge>>>13,le=i[6]|0,ge=le&8191,Pe=le>>>13,lt=i[7]|0,Le=lt&8191,ze=lt>>>13,kt=i[8]|0,ae=kt&8191,he=kt>>>13,je=i[9]|0,Ie=je&8191,Ce=je>>>13,ut=f[0]|0,De=ut&8191,ye=ut>>>13,we=f[1]|0,ve=we&8191,Ee=we>>>13,rt=f[2]|0,Fe=rt&8191,He=rt>>>13,yt=f[3]|0,Ke=yt&8191,Ze=yt>>>13,At=f[4]|0,Ve=At&8191,tt=At>>>13,qt=f[5]|0,et=qt&8191,st=qt>>>13,rr=f[6]|0,at=rr&8191,ft=rr>>>13,Qe=f[7]|0,xe=Qe&8191,Oe=Qe>>>13,ht=f[8]|0,Ne=ht&8191,qe=ht>>>13,Dt=f[9]|0,Xe=Dt&8191,ot=Dt>>>13;n.negative=e.negative^r.negative,n.length=19,s=Math.imul(D,De),t=Math.imul(D,ye),t=t+Math.imul(Z,De)|0,a=Math.imul(Z,ye);var Gt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,s=Math.imul(V,De),t=Math.imul(V,ye),t=t+Math.imul(q,De)|0,a=Math.imul(q,ye),s=s+Math.imul(D,ve)|0,t=t+Math.imul(D,Ee)|0,t=t+Math.imul(Z,ve)|0,a=a+Math.imul(Z,Ee)|0;var xt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(xt>>>26)|0,xt&=67108863,s=Math.imul(G,De),t=Math.imul(G,ye),t=t+Math.imul(H,De)|0,a=Math.imul(H,ye),s=s+Math.imul(V,ve)|0,t=t+Math.imul(V,Ee)|0,t=t+Math.imul(q,ve)|0,a=a+Math.imul(q,Ee)|0,s=s+Math.imul(D,Fe)|0,t=t+Math.imul(D,He)|0,t=t+Math.imul(Z,Fe)|0,a=a+Math.imul(Z,He)|0;var gt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(gt>>>26)|0,gt&=67108863,s=Math.imul(ue,De),t=Math.imul(ue,ye),t=t+Math.imul(be,De)|0,a=Math.imul(be,ye),s=s+Math.imul(G,ve)|0,t=t+Math.imul(G,Ee)|0,t=t+Math.imul(H,ve)|0,a=a+Math.imul(H,Ee)|0,s=s+Math.imul(V,Fe)|0,t=t+Math.imul(V,He)|0,t=t+Math.imul(q,Fe)|0,a=a+Math.imul(q,He)|0,s=s+Math.imul(D,Ke)|0,t=t+Math.imul(D,Ze)|0,t=t+Math.imul(Z,Ke)|0,a=a+Math.imul(Z,Ze)|0;var bt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(bt>>>26)|0,bt&=67108863,s=Math.imul(J,De),t=Math.imul(J,ye),t=t+Math.imul(pe,De)|0,a=Math.imul(pe,ye),s=s+Math.imul(ue,ve)|0,t=t+Math.imul(ue,Ee)|0,t=t+Math.imul(be,ve)|0,a=a+Math.imul(be,Ee)|0,s=s+Math.imul(G,Fe)|0,t=t+Math.imul(G,He)|0,t=t+Math.imul(H,Fe)|0,a=a+Math.imul(H,He)|0,s=s+Math.imul(V,Ke)|0,t=t+Math.imul(V,Ze)|0,t=t+Math.imul(q,Ke)|0,a=a+Math.imul(q,Ze)|0,s=s+Math.imul(D,Ve)|0,t=t+Math.imul(D,tt)|0,t=t+Math.imul(Z,Ve)|0,a=a+Math.imul(Z,tt)|0;var Tt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,s=Math.imul(ce,De),t=Math.imul(ce,ye),t=t+Math.imul(te,De)|0,a=Math.imul(te,ye),s=s+Math.imul(J,ve)|0,t=t+Math.imul(J,Ee)|0,t=t+Math.imul(pe,ve)|0,a=a+Math.imul(pe,Ee)|0,s=s+Math.imul(ue,Fe)|0,t=t+Math.imul(ue,He)|0,t=t+Math.imul(be,Fe)|0,a=a+Math.imul(be,He)|0,s=s+Math.imul(G,Ke)|0,t=t+Math.imul(G,Ze)|0,t=t+Math.imul(H,Ke)|0,a=a+Math.imul(H,Ze)|0,s=s+Math.imul(V,Ve)|0,t=t+Math.imul(V,tt)|0,t=t+Math.imul(q,Ve)|0,a=a+Math.imul(q,tt)|0,s=s+Math.imul(D,et)|0,t=t+Math.imul(D,st)|0,t=t+Math.imul(Z,et)|0,a=a+Math.imul(Z,st)|0;var Ct=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,s=Math.imul(ge,De),t=Math.imul(ge,ye),t=t+Math.imul(Pe,De)|0,a=Math.imul(Pe,ye),s=s+Math.imul(ce,ve)|0,t=t+Math.imul(ce,Ee)|0,t=t+Math.imul(te,ve)|0,a=a+Math.imul(te,Ee)|0,s=s+Math.imul(J,Fe)|0,t=t+Math.imul(J,He)|0,t=t+Math.imul(pe,Fe)|0,a=a+Math.imul(pe,He)|0,s=s+Math.imul(ue,Ke)|0,t=t+Math.imul(ue,Ze)|0,t=t+Math.imul(be,Ke)|0,a=a+Math.imul(be,Ze)|0,s=s+Math.imul(G,Ve)|0,t=t+Math.imul(G,tt)|0,t=t+Math.imul(H,Ve)|0,a=a+Math.imul(H,tt)|0,s=s+Math.imul(V,et)|0,t=t+Math.imul(V,st)|0,t=t+Math.imul(q,et)|0,a=a+Math.imul(q,st)|0,s=s+Math.imul(D,at)|0,t=t+Math.imul(D,ft)|0,t=t+Math.imul(Z,at)|0,a=a+Math.imul(Z,ft)|0;var Xt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Xt>>>26)|0,Xt&=67108863,s=Math.imul(Le,De),t=Math.imul(Le,ye),t=t+Math.imul(ze,De)|0,a=Math.imul(ze,ye),s=s+Math.imul(ge,ve)|0,t=t+Math.imul(ge,Ee)|0,t=t+Math.imul(Pe,ve)|0,a=a+Math.imul(Pe,Ee)|0,s=s+Math.imul(ce,Fe)|0,t=t+Math.imul(ce,He)|0,t=t+Math.imul(te,Fe)|0,a=a+Math.imul(te,He)|0,s=s+Math.imul(J,Ke)|0,t=t+Math.imul(J,Ze)|0,t=t+Math.imul(pe,Ke)|0,a=a+Math.imul(pe,Ze)|0,s=s+Math.imul(ue,Ve)|0,t=t+Math.imul(ue,tt)|0,t=t+Math.imul(be,Ve)|0,a=a+Math.imul(be,tt)|0,s=s+Math.imul(G,et)|0,t=t+Math.imul(G,st)|0,t=t+Math.imul(H,et)|0,a=a+Math.imul(H,st)|0,s=s+Math.imul(V,at)|0,t=t+Math.imul(V,ft)|0,t=t+Math.imul(q,at)|0,a=a+Math.imul(q,ft)|0,s=s+Math.imul(D,xe)|0,t=t+Math.imul(D,Oe)|0,t=t+Math.imul(Z,xe)|0,a=a+Math.imul(Z,Oe)|0;var Yt=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(Yt>>>26)|0,Yt&=67108863,s=Math.imul(ae,De),t=Math.imul(ae,ye),t=t+Math.imul(he,De)|0,a=Math.imul(he,ye),s=s+Math.imul(Le,ve)|0,t=t+Math.imul(Le,Ee)|0,t=t+Math.imul(ze,ve)|0,a=a+Math.imul(ze,Ee)|0,s=s+Math.imul(ge,Fe)|0,t=t+Math.imul(ge,He)|0,t=t+Math.imul(Pe,Fe)|0,a=a+Math.imul(Pe,He)|0,s=s+Math.imul(ce,Ke)|0,t=t+Math.imul(ce,Ze)|0,t=t+Math.imul(te,Ke)|0,a=a+Math.imul(te,Ze)|0,s=s+Math.imul(J,Ve)|0,t=t+Math.imul(J,tt)|0,t=t+Math.imul(pe,Ve)|0,a=a+Math.imul(pe,tt)|0,s=s+Math.imul(ue,et)|0,t=t+Math.imul(ue,st)|0,t=t+Math.imul(be,et)|0,a=a+Math.imul(be,st)|0,s=s+Math.imul(G,at)|0,t=t+Math.imul(G,ft)|0,t=t+Math.imul(H,at)|0,a=a+Math.imul(H,ft)|0,s=s+Math.imul(V,xe)|0,t=t+Math.imul(V,Oe)|0,t=t+Math.imul(q,xe)|0,a=a+Math.imul(q,Oe)|0,s=s+Math.imul(D,Ne)|0,t=t+Math.imul(D,qe)|0,t=t+Math.imul(Z,Ne)|0,a=a+Math.imul(Z,qe)|0;var ar=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(ar>>>26)|0,ar&=67108863,s=Math.imul(Ie,De),t=Math.imul(Ie,ye),t=t+Math.imul(Ce,De)|0,a=Math.imul(Ce,ye),s=s+Math.imul(ae,ve)|0,t=t+Math.imul(ae,Ee)|0,t=t+Math.imul(he,ve)|0,a=a+Math.imul(he,Ee)|0,s=s+Math.imul(Le,Fe)|0,t=t+Math.imul(Le,He)|0,t=t+Math.imul(ze,Fe)|0,a=a+Math.imul(ze,He)|0,s=s+Math.imul(ge,Ke)|0,t=t+Math.imul(ge,Ze)|0,t=t+Math.imul(Pe,Ke)|0,a=a+Math.imul(Pe,Ze)|0,s=s+Math.imul(ce,Ve)|0,t=t+Math.imul(ce,tt)|0,t=t+Math.imul(te,Ve)|0,a=a+Math.imul(te,tt)|0,s=s+Math.imul(J,et)|0,t=t+Math.imul(J,st)|0,t=t+Math.imul(pe,et)|0,a=a+Math.imul(pe,st)|0,s=s+Math.imul(ue,at)|0,t=t+Math.imul(ue,ft)|0,t=t+Math.imul(be,at)|0,a=a+Math.imul(be,ft)|0,s=s+Math.imul(G,xe)|0,t=t+Math.imul(G,Oe)|0,t=t+Math.imul(H,xe)|0,a=a+Math.imul(H,Oe)|0,s=s+Math.imul(V,Ne)|0,t=t+Math.imul(V,qe)|0,t=t+Math.imul(q,Ne)|0,a=a+Math.imul(q,qe)|0,s=s+Math.imul(D,Xe)|0,t=t+Math.imul(D,ot)|0,t=t+Math.imul(Z,Xe)|0,a=a+Math.imul(Z,ot)|0;var or=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(or>>>26)|0,or&=67108863,s=Math.imul(Ie,ve),t=Math.imul(Ie,Ee),t=t+Math.imul(Ce,ve)|0,a=Math.imul(Ce,Ee),s=s+Math.imul(ae,Fe)|0,t=t+Math.imul(ae,He)|0,t=t+Math.imul(he,Fe)|0,a=a+Math.imul(he,He)|0,s=s+Math.imul(Le,Ke)|0,t=t+Math.imul(Le,Ze)|0,t=t+Math.imul(ze,Ke)|0,a=a+Math.imul(ze,Ze)|0,s=s+Math.imul(ge,Ve)|0,t=t+Math.imul(ge,tt)|0,t=t+Math.imul(Pe,Ve)|0,a=a+Math.imul(Pe,tt)|0,s=s+Math.imul(ce,et)|0,t=t+Math.imul(ce,st)|0,t=t+Math.imul(te,et)|0,a=a+Math.imul(te,st)|0,s=s+Math.imul(J,at)|0,t=t+Math.imul(J,ft)|0,t=t+Math.imul(pe,at)|0,a=a+Math.imul(pe,ft)|0,s=s+Math.imul(ue,xe)|0,t=t+Math.imul(ue,Oe)|0,t=t+Math.imul(be,xe)|0,a=a+Math.imul(be,Oe)|0,s=s+Math.imul(G,Ne)|0,t=t+Math.imul(G,qe)|0,t=t+Math.imul(H,Ne)|0,a=a+Math.imul(H,qe)|0,s=s+Math.imul(V,Xe)|0,t=t+Math.imul(V,ot)|0,t=t+Math.imul(q,Xe)|0,a=a+Math.imul(q,ot)|0;var sr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(sr>>>26)|0,sr&=67108863,s=Math.imul(Ie,Fe),t=Math.imul(Ie,He),t=t+Math.imul(Ce,Fe)|0,a=Math.imul(Ce,He),s=s+Math.imul(ae,Ke)|0,t=t+Math.imul(ae,Ze)|0,t=t+Math.imul(he,Ke)|0,a=a+Math.imul(he,Ze)|0,s=s+Math.imul(Le,Ve)|0,t=t+Math.imul(Le,tt)|0,t=t+Math.imul(ze,Ve)|0,a=a+Math.imul(ze,tt)|0,s=s+Math.imul(ge,et)|0,t=t+Math.imul(ge,st)|0,t=t+Math.imul(Pe,et)|0,a=a+Math.imul(Pe,st)|0,s=s+Math.imul(ce,at)|0,t=t+Math.imul(ce,ft)|0,t=t+Math.imul(te,at)|0,a=a+Math.imul(te,ft)|0,s=s+Math.imul(J,xe)|0,t=t+Math.imul(J,Oe)|0,t=t+Math.imul(pe,xe)|0,a=a+Math.imul(pe,Oe)|0,s=s+Math.imul(ue,Ne)|0,t=t+Math.imul(ue,qe)|0,t=t+Math.imul(be,Ne)|0,a=a+Math.imul(be,qe)|0,s=s+Math.imul(G,Xe)|0,t=t+Math.imul(G,ot)|0,t=t+Math.imul(H,Xe)|0,a=a+Math.imul(H,ot)|0;var $t=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+($t>>>26)|0,$t&=67108863,s=Math.imul(Ie,Ke),t=Math.imul(Ie,Ze),t=t+Math.imul(Ce,Ke)|0,a=Math.imul(Ce,Ze),s=s+Math.imul(ae,Ve)|0,t=t+Math.imul(ae,tt)|0,t=t+Math.imul(he,Ve)|0,a=a+Math.imul(he,tt)|0,s=s+Math.imul(Le,et)|0,t=t+Math.imul(Le,st)|0,t=t+Math.imul(ze,et)|0,a=a+Math.imul(ze,st)|0,s=s+Math.imul(ge,at)|0,t=t+Math.imul(ge,ft)|0,t=t+Math.imul(Pe,at)|0,a=a+Math.imul(Pe,ft)|0,s=s+Math.imul(ce,xe)|0,t=t+Math.imul(ce,Oe)|0,t=t+Math.imul(te,xe)|0,a=a+Math.imul(te,Oe)|0,s=s+Math.imul(J,Ne)|0,t=t+Math.imul(J,qe)|0,t=t+Math.imul(pe,Ne)|0,a=a+Math.imul(pe,qe)|0,s=s+Math.imul(ue,Xe)|0,t=t+Math.imul(ue,ot)|0,t=t+Math.imul(be,Xe)|0,a=a+Math.imul(be,ot)|0;var nr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(nr>>>26)|0,nr&=67108863,s=Math.imul(Ie,Ve),t=Math.imul(Ie,tt),t=t+Math.imul(Ce,Ve)|0,a=Math.imul(Ce,tt),s=s+Math.imul(ae,et)|0,t=t+Math.imul(ae,st)|0,t=t+Math.imul(he,et)|0,a=a+Math.imul(he,st)|0,s=s+Math.imul(Le,at)|0,t=t+Math.imul(Le,ft)|0,t=t+Math.imul(ze,at)|0,a=a+Math.imul(ze,ft)|0,s=s+Math.imul(ge,xe)|0,t=t+Math.imul(ge,Oe)|0,t=t+Math.imul(Pe,xe)|0,a=a+Math.imul(Pe,Oe)|0,s=s+Math.imul(ce,Ne)|0,t=t+Math.imul(ce,qe)|0,t=t+Math.imul(te,Ne)|0,a=a+Math.imul(te,qe)|0,s=s+Math.imul(J,Xe)|0,t=t+Math.imul(J,ot)|0,t=t+Math.imul(pe,Xe)|0,a=a+Math.imul(pe,ot)|0;var fr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(fr>>>26)|0,fr&=67108863,s=Math.imul(Ie,et),t=Math.imul(Ie,st),t=t+Math.imul(Ce,et)|0,a=Math.imul(Ce,st),s=s+Math.imul(ae,at)|0,t=t+Math.imul(ae,ft)|0,t=t+Math.imul(he,at)|0,a=a+Math.imul(he,ft)|0,s=s+Math.imul(Le,xe)|0,t=t+Math.imul(Le,Oe)|0,t=t+Math.imul(ze,xe)|0,a=a+Math.imul(ze,Oe)|0,s=s+Math.imul(ge,Ne)|0,t=t+Math.imul(ge,qe)|0,t=t+Math.imul(Pe,Ne)|0,a=a+Math.imul(Pe,qe)|0,s=s+Math.imul(ce,Xe)|0,t=t+Math.imul(ce,ot)|0,t=t+Math.imul(te,Xe)|0,a=a+Math.imul(te,ot)|0;var lr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(lr>>>26)|0,lr&=67108863,s=Math.imul(Ie,at),t=Math.imul(Ie,ft),t=t+Math.imul(Ce,at)|0,a=Math.imul(Ce,ft),s=s+Math.imul(ae,xe)|0,t=t+Math.imul(ae,Oe)|0,t=t+Math.imul(he,xe)|0,a=a+Math.imul(he,Oe)|0,s=s+Math.imul(Le,Ne)|0,t=t+Math.imul(Le,qe)|0,t=t+Math.imul(ze,Ne)|0,a=a+Math.imul(ze,qe)|0,s=s+Math.imul(ge,Xe)|0,t=t+Math.imul(ge,ot)|0,t=t+Math.imul(Pe,Xe)|0,a=a+Math.imul(Pe,ot)|0;var dr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(dr>>>26)|0,dr&=67108863,s=Math.imul(Ie,xe),t=Math.imul(Ie,Oe),t=t+Math.imul(Ce,xe)|0,a=Math.imul(Ce,Oe),s=s+Math.imul(ae,Ne)|0,t=t+Math.imul(ae,qe)|0,t=t+Math.imul(he,Ne)|0,a=a+Math.imul(he,qe)|0,s=s+Math.imul(Le,Xe)|0,t=t+Math.imul(Le,ot)|0,t=t+Math.imul(ze,Xe)|0,a=a+Math.imul(ze,ot)|0;var cr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(cr>>>26)|0,cr&=67108863,s=Math.imul(Ie,Ne),t=Math.imul(Ie,qe),t=t+Math.imul(Ce,Ne)|0,a=Math.imul(Ce,qe),s=s+Math.imul(ae,Xe)|0,t=t+Math.imul(ae,ot)|0,t=t+Math.imul(he,Xe)|0,a=a+Math.imul(he,ot)|0;var gr=(h+s|0)+((t&8191)<<13)|0;h=(a+(t>>>13)|0)+(gr>>>26)|0,gr&=67108863,s=Math.imul(Ie,Xe),t=Math.imul(Ie,ot),t=t+Math.imul(Ce,Xe)|0,a=Math.imul(Ce,ot);var pr=(h+s|0)+((t&8191)<<13)|0;return h=(a+(t>>>13)|0)+(pr>>>26)|0,pr&=67108863,c[0]=Gt,c[1]=xt,c[2]=gt,c[3]=bt,c[4]=Tt,c[5]=Ct,c[6]=Xt,c[7]=Yt,c[8]=ar,c[9]=or,c[10]=sr,c[11]=$t,c[12]=nr,c[13]=fr,c[14]=lr,c[15]=dr,c[16]=cr,c[17]=gr,c[18]=pr,h!==0&&(c[19]=h,n.length++),n};Math.imul||(k=b);function B(u,e,r){r.negative=e.negative^u.negative,r.length=u.length+e.length;for(var n=0,i=0,f=0;f<r.length-1;f++){var c=i;i=0;for(var h=n&67108863,s=Math.min(f,e.length-1),t=Math.max(0,f-u.length+1);t<=s;t++){var a=f-t,w=u.words[a]|0,D=e.words[t]|0,Z=w*D,F=Z&67108863;c=c+(Z/67108864|0)|0,F=F+h|0,h=F&67108863,c=c+(F>>>26)|0,i+=c>>>26,c&=67108863}r.words[f]=h,n=c,c=i}return n!==0?r.words[f]=n:r.length--,r.strip()}function U(u,e,r){var n=new C;return n.mulp(u,e,r)}o.prototype.mulTo=function(e,r){var n,i=this.length+e.length;return this.length===10&&e.length===10?n=k(this,e,r):i<63?n=b(this,e,r):i<1024?n=B(this,e,r):n=U(this,e,r),n};function C(u,e){this.x=u,this.y=e}C.prototype.makeRBT=function(e){for(var r=new Array(e),n=o.prototype._countBits(e)-1,i=0;i<e;i++)r[i]=this.revBin(i,n,e);return r},C.prototype.revBin=function(e,r,n){if(e===0||e===n-1)return e;for(var i=0,f=0;f<r;f++)i|=(e&1)<<r-f-1,e>>=1;return i},C.prototype.permute=function(e,r,n,i,f,c){for(var h=0;h<c;h++)i[h]=r[e[h]],f[h]=n[e[h]]},C.prototype.transform=function(e,r,n,i,f,c){this.permute(c,e,r,n,i,f);for(var h=1;h<f;h<<=1)for(var s=h<<1,t=Math.cos(2*Math.PI/s),a=Math.sin(2*Math.PI/s),w=0;w<f;w+=s)for(var D=t,Z=a,F=0;F<h;F++){var V=n[w+F],q=i[w+F],re=n[w+F+h],G=i[w+F+h],H=D*re-Z*G;G=D*G+Z*re,re=H,n[w+F]=V+re,i[w+F]=q+G,n[w+F+h]=V-re,i[w+F+h]=q-G,F!==s&&(H=t*D-a*Z,Z=t*Z+a*D,D=H)}},C.prototype.guessLen13b=function(e,r){var n=Math.max(r,e)|1,i=n&1,f=0;for(n=n/2|0;n;n=n>>>1)f++;return 1<<f+1+i},C.prototype.conjugate=function(e,r,n){if(!(n<=1))for(var i=0;i<n/2;i++){var f=e[i];e[i]=e[n-i-1],e[n-i-1]=f,f=r[i],r[i]=-r[n-i-1],r[n-i-1]=-f}},C.prototype.normalize13b=function(e,r){for(var n=0,i=0;i<r/2;i++){var f=Math.round(e[2*i+1]/r)*8192+Math.round(e[2*i]/r)+n;e[i]=f&67108863,f<67108864?n=0:n=f/67108864|0}return e},C.prototype.convert13b=function(e,r,n,i){for(var f=0,c=0;c<r;c++)f=f+(e[c]|0),n[2*c]=f&8191,f=f>>>13,n[2*c+1]=f&8191,f=f>>>13;for(c=2*r;c<i;++c)n[c]=0;p(f===0),p((f&-8192)===0)},C.prototype.stub=function(e){for(var r=new Array(e),n=0;n<e;n++)r[n]=0;return r},C.prototype.mulp=function(e,r,n){var i=2*this.guessLen13b(e.length,r.length),f=this.makeRBT(i),c=this.stub(i),h=new Array(i),s=new Array(i),t=new Array(i),a=new Array(i),w=new Array(i),D=new Array(i),Z=n.words;Z.length=i,this.convert13b(e.words,e.length,h,i),this.convert13b(r.words,r.length,a,i),this.transform(h,c,s,t,i,f),this.transform(a,c,w,D,i,f);for(var F=0;F<i;F++){var V=s[F]*w[F]-t[F]*D[F];t[F]=s[F]*D[F]+t[F]*w[F],s[F]=V}return this.conjugate(s,t,i),this.transform(s,t,Z,c,i,f),this.conjugate(Z,c,i),this.normalize13b(Z,i),n.negative=e.negative^r.negative,n.length=e.length+r.length,n.strip()},o.prototype.mul=function(e){var r=new o(null);return r.words=new Array(this.length+e.length),this.mulTo(e,r)},o.prototype.mulf=function(e){var r=new o(null);return r.words=new Array(this.length+e.length),U(this,e,r)},o.prototype.imul=function(e){return this.clone().mulTo(e,this)},o.prototype.imuln=function(e){p(typeof e=="number"),p(e<67108864);for(var r=0,n=0;n<this.length;n++){var i=(this.words[n]|0)*e,f=(i&67108863)+(r&67108863);r>>=26,r+=i/67108864|0,r+=f>>>26,this.words[n]=f&67108863}return r!==0&&(this.words[n]=r,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 r=v(e);if(r.length===0)return new o(1);for(var n=this,i=0;i<r.length&&r[i]===0;i++,n=n.sqr());if(++i<r.length)for(var f=n.sqr();i<r.length;i++,f=f.sqr())r[i]!==0&&(n=n.mul(f));return n},o.prototype.iushln=function(e){p(typeof e=="number"&&e>=0);var r=e%26,n=(e-r)/26,i=67108863>>>26-r<<26-r,f;if(r!==0){var c=0;for(f=0;f<this.length;f++){var h=this.words[f]&i,s=(this.words[f]|0)-h<<r;this.words[f]=s|c,c=h>>>26-r}c&&(this.words[f]=c,this.length++)}if(n!==0){for(f=this.length-1;f>=0;f--)this.words[f+n]=this.words[f];for(f=0;f<n;f++)this.words[f]=0;this.length+=n}return this.strip()},o.prototype.ishln=function(e){return p(this.negative===0),this.iushln(e)},o.prototype.iushrn=function(e,r,n){p(typeof e=="number"&&e>=0);var i;r?i=(r-r%26)/26:i=0;var f=e%26,c=Math.min((e-f)/26,this.length),h=67108863^67108863>>>f<<f,s=n;if(i-=c,i=Math.max(0,i),s){for(var t=0;t<c;t++)s.words[t]=this.words[t];s.length=c}if(c!==0)if(this.length>c)for(this.length-=c,t=0;t<this.length;t++)this.words[t]=this.words[t+c];else this.words[0]=0,this.length=1;var a=0;for(t=this.length-1;t>=0&&(a!==0||t>=i);t--){var w=this.words[t]|0;this.words[t]=a<<26-f|w>>>f,a=w&h}return s&&a!==0&&(s.words[s.length++]=a),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,r,n){return p(this.negative===0),this.iushrn(e,r,n)},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){p(typeof e=="number"&&e>=0);var r=e%26,n=(e-r)/26,i=1<<r;if(this.length<=n)return!1;var f=this.words[n];return!!(f&i)},o.prototype.imaskn=function(e){p(typeof e=="number"&&e>=0);var r=e%26,n=(e-r)/26;if(p(this.negative===0,"imaskn works only with positive numbers"),this.length<=n)return this;if(r!==0&&n++,this.length=Math.min(n,this.length),r!==0){var i=67108863^67108863>>>r<<r;this.words[this.length-1]&=i}return this.strip()},o.prototype.maskn=function(e){return this.clone().imaskn(e)},o.prototype.iaddn=function(e){return p(typeof e=="number"),p(e<67108864),e<0?this.isubn(-e):this.negative!==0?this.length===1&&(this.words[0]|0)<e?(this.words[0]=e-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this):this._iaddn(e)},o.prototype._iaddn=function(e){this.words[0]+=e;for(var r=0;r<this.length&&this.words[r]>=67108864;r++)this.words[r]-=67108864,r===this.length-1?this.words[r+1]=1:this.words[r+1]++;return this.length=Math.max(this.length,r+1),this},o.prototype.isubn=function(e){if(p(typeof e=="number"),p(e<67108864),e<0)return this.iaddn(-e);if(this.negative!==0)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var r=0;r<this.length&&this.words[r]<0;r++)this.words[r]+=67108864,this.words[r+1]-=1;return this.strip()},o.prototype.addn=function(e){return this.clone().iaddn(e)},o.prototype.subn=function(e){return this.clone().isubn(e)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(e,r,n){var i=e.length+n,f;this._expand(i);var c,h=0;for(f=0;f<e.length;f++){c=(this.words[f+n]|0)+h;var s=(e.words[f]|0)*r;c-=s&67108863,h=(c>>26)-(s/67108864|0),this.words[f+n]=c&67108863}for(;f<this.length-n;f++)c=(this.words[f+n]|0)+h,h=c>>26,this.words[f+n]=c&67108863;if(h===0)return this.strip();for(p(h===-1),h=0,f=0;f<this.length;f++)c=-(this.words[f]|0)+h,h=c>>26,this.words[f]=c&67108863;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,r){var n=this.length-e.length,i=this.clone(),f=e,c=f.words[f.length-1]|0,h=this._countBits(c);n=26-h,n!==0&&(f=f.ushln(n),i.iushln(n),c=f.words[f.length-1]|0);var s=i.length-f.length,t;if(r!=="mod"){t=new o(null),t.length=s+1,t.words=new Array(t.length);for(var a=0;a<t.length;a++)t.words[a]=0}var w=i.clone()._ishlnsubmul(f,1,s);w.negative===0&&(i=w,t&&(t.words[s]=1));for(var D=s-1;D>=0;D--){var Z=(i.words[f.length+D]|0)*67108864+(i.words[f.length+D-1]|0);for(Z=Math.min(Z/c|0,67108863),i._ishlnsubmul(f,Z,D);i.negative!==0;)Z--,i.negative=0,i._ishlnsubmul(f,1,D),i.isZero()||(i.negative^=1);t&&(t.words[D]=Z)}return t&&t.strip(),i.strip(),r!=="div"&&n!==0&&i.iushrn(n),{div:t||null,mod:i}},o.prototype.divmod=function(e,r,n){if(p(!e.isZero()),this.isZero())return{div:new o(0),mod:new o(0)};var i,f,c;return this.negative!==0&&e.negative===0?(c=this.neg().divmod(e,r),r!=="mod"&&(i=c.div.neg()),r!=="div"&&(f=c.mod.neg(),n&&f.negative!==0&&f.iadd(e)),{div:i,mod:f}):this.negative===0&&e.negative!==0?(c=this.divmod(e.neg(),r),r!=="mod"&&(i=c.div.neg()),{div:i,mod:c.mod}):this.negative&e.negative?(c=this.neg().divmod(e.neg(),r),r!=="div"&&(f=c.mod.neg(),n&&f.negative!==0&&f.isub(e)),{div:c.div,mod:f}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:e.length===1?r==="div"?{div:this.divn(e.words[0]),mod:null}:r==="mod"?{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,r)},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 r=this.divmod(e);if(r.mod.isZero())return r.div;var n=r.div.negative!==0?r.mod.isub(e):r.mod,i=e.ushrn(1),f=e.andln(1),c=n.cmp(i);return c<0||f===1&&c===0?r.div:r.div.negative!==0?r.div.isubn(1):r.div.iaddn(1)},o.prototype.modn=function(e){p(e<=67108863);for(var r=(1<<26)%e,n=0,i=this.length-1;i>=0;i--)n=(r*n+(this.words[i]|0))%e;return n},o.prototype.idivn=function(e){p(e<=67108863);for(var r=0,n=this.length-1;n>=0;n--){var i=(this.words[n]|0)+r*67108864;this.words[n]=i/e|0,r=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){p(e.negative===0),p(!e.isZero());var r=this,n=e.clone();r.negative!==0?r=r.umod(e):r=r.clone();for(var i=new o(1),f=new o(0),c=new o(0),h=new o(1),s=0;r.isEven()&&n.isEven();)r.iushrn(1),n.iushrn(1),++s;for(var t=n.clone(),a=r.clone();!r.isZero();){for(var w=0,D=1;!(r.words[0]&D)&&w<26;++w,D<<=1);if(w>0)for(r.iushrn(w);w-- >0;)(i.isOdd()||f.isOdd())&&(i.iadd(t),f.isub(a)),i.iushrn(1),f.iushrn(1);for(var Z=0,F=1;!(n.words[0]&F)&&Z<26;++Z,F<<=1);if(Z>0)for(n.iushrn(Z);Z-- >0;)(c.isOdd()||h.isOdd())&&(c.iadd(t),h.isub(a)),c.iushrn(1),h.iushrn(1);r.cmp(n)>=0?(r.isub(n),i.isub(c),f.isub(h)):(n.isub(r),c.isub(i),h.isub(f))}return{a:c,b:h,gcd:n.iushln(s)}},o.prototype._invmp=function(e){p(e.negative===0),p(!e.isZero());var r=this,n=e.clone();r.negative!==0?r=r.umod(e):r=r.clone();for(var i=new o(1),f=new o(0),c=n.clone();r.cmpn(1)>0&&n.cmpn(1)>0;){for(var h=0,s=1;!(r.words[0]&s)&&h<26;++h,s<<=1);if(h>0)for(r.iushrn(h);h-- >0;)i.isOdd()&&i.iadd(c),i.iushrn(1);for(var t=0,a=1;!(n.words[0]&a)&&t<26;++t,a<<=1);if(t>0)for(n.iushrn(t);t-- >0;)f.isOdd()&&f.iadd(c),f.iushrn(1);r.cmp(n)>=0?(r.isub(n),i.isub(f)):(n.isub(r),f.isub(i))}var w;return r.cmpn(1)===0?w=i:w=f,w.cmpn(0)<0&&w.iadd(e),w},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var r=this.clone(),n=e.clone();r.negative=0,n.negative=0;for(var i=0;r.isEven()&&n.isEven();i++)r.iushrn(1),n.iushrn(1);do{for(;r.isEven();)r.iushrn(1);for(;n.isEven();)n.iushrn(1);var f=r.cmp(n);if(f<0){var c=r;r=n,n=c}else if(f===0||n.cmpn(1)===0)break;r.isub(n)}while(!0);return n.iushln(i)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return(this.words[0]&1)===0},o.prototype.isOdd=function(){return(this.words[0]&1)===1},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){p(typeof e=="number");var r=e%26,n=(e-r)/26,i=1<<r;if(this.length<=n)return this._expand(n+1),this.words[n]|=i,this;for(var f=i,c=n;f!==0&&c<this.length;c++){var h=this.words[c]|0;h+=f,f=h>>>26,h&=67108863,this.words[c]=h}return f!==0&&(this.words[c]=f,this.length++),this},o.prototype.isZero=function(){return this.length===1&&this.words[0]===0},o.prototype.cmpn=function(e){var r=e<0;if(this.negative!==0&&!r)return-1;if(this.negative===0&&r)return 1;this.strip();var n;if(this.length>1)n=1;else{r&&(e=-e),p(e<=67108863,"Number is too big");var i=this.words[0]|0;n=i===e?0:i<e?-1:1}return this.negative!==0?-n|0:n},o.prototype.cmp=function(e){if(this.negative!==0&&e.negative===0)return-1;if(this.negative===0&&e.negative!==0)return 1;var r=this.ucmp(e);return this.negative!==0?-r|0:r},o.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length<e.length)return-1;for(var r=0,n=this.length-1;n>=0;n--){var i=this.words[n]|0,f=e.words[n]|0;if(i!==f){i<f?r=-1:i>f&&(r=1);break}}return r},o.prototype.gtn=function(e){return this.cmpn(e)===1},o.prototype.gt=function(e){return this.cmp(e)===1},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 this.cmpn(e)===-1},o.prototype.lt=function(e){return this.cmp(e)===-1},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 this.cmpn(e)===0},o.prototype.eq=function(e){return this.cmp(e)===0},o.red=function(e){return new Y(e)},o.prototype.toRed=function(e){return p(!this.red,"Already a number in reduction context"),p(this.negative===0,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return p(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 p(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return p(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return p(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return p(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return p(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return p(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return p(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return p(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return p(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return p(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return p(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return p(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return p(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return p(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var L={k256:null,p224:null,p192:null,p25519:null};function N(u,e){this.name=u,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}N.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},N.prototype.ireduce=function(e){var r=e,n;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),n=r.bitLength();while(n>this.n);var i=n<this.n?-1:r.ucmp(this.p);return i===0?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):r.strip!==void 0?r.strip():r._strip(),r},N.prototype.split=function(e,r){e.iushrn(this.n,0,r)},N.prototype.imulK=function(e){return e.imul(this.k)};function j(){N.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}I(j,N),j.prototype.split=function(e,r){for(var n=4194303,i=Math.min(e.length,9),f=0;f<i;f++)r.words[f]=e.words[f];if(r.length=i,e.length<=9){e.words[0]=0,e.length=1;return}var c=e.words[9];for(r.words[r.length++]=c&n,f=10;f<e.length;f++){var h=e.words[f]|0;e.words[f-10]=(h&n)<<4|c>>>22,c=h}c>>>=22,e.words[f-10]=c,c===0&&e.length>10?e.length-=10:e.length-=9},j.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var r=0,n=0;n<e.length;n++){var i=e.words[n]|0;r+=i*977,e.words[n]=r&67108863,r=i*64+(r/67108864|0)}return e.words[e.length-1]===0&&(e.length--,e.words[e.length-1]===0&&e.length--),e};function K(){N.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}I(K,N);function $(){N.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}I($,N);function Q(){N.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}I(Q,N),Q.prototype.imulK=function(e){for(var r=0,n=0;n<e.length;n++){var i=(e.words[n]|0)*19+r,f=i&67108863;i>>>=26,e.words[n]=f,r=i}return r!==0&&(e.words[e.length++]=r),e},o._prime=function(e){if(L[e])return L[e];var r;if(e==="k256")r=new j;else if(e==="p224")r=new K;else if(e==="p192")r=new $;else if(e==="p25519")r=new Q;else throw new Error("Unknown prime "+e);return L[e]=r,r};function Y(u){if(typeof u=="string"){var e=o._prime(u);this.m=e.p,this.prime=e}else p(u.gtn(1),"modulus must be greater than 1"),this.m=u,this.prime=null}Y.prototype._verify1=function(e){p(e.negative===0,"red works only with positives"),p(e.red,"red works only with red numbers")},Y.prototype._verify2=function(e,r){p((e.negative|r.negative)===0,"red works only with positives"),p(e.red&&e.red===r.red,"red works only with red numbers")},Y.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},Y.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},Y.prototype.add=function(e,r){this._verify2(e,r);var n=e.add(r);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},Y.prototype.iadd=function(e,r){this._verify2(e,r);var n=e.iadd(r);return n.cmp(this.m)>=0&&n.isub(this.m),n},Y.prototype.sub=function(e,r){this._verify2(e,r);var n=e.sub(r);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},Y.prototype.isub=function(e,r){this._verify2(e,r);var n=e.isub(r);return n.cmpn(0)<0&&n.iadd(this.m),n},Y.prototype.shl=function(e,r){return this._verify1(e),this.imod(e.ushln(r))},Y.prototype.imul=function(e,r){return this._verify2(e,r),this.imod(e.imul(r))},Y.prototype.mul=function(e,r){return this._verify2(e,r),this.imod(e.mul(r))},Y.prototype.isqr=function(e){return this.imul(e,e.clone())},Y.prototype.sqr=function(e){return this.mul(e,e)},Y.prototype.sqrt=function(e){if(e.isZero())return e.clone();var r=this.m.andln(3);if(p(r%2===1),r===3){var n=this.m.add(new o(1)).iushrn(2);return this.pow(e,n)}for(var i=this.m.subn(1),f=0;!i.isZero()&&i.andln(1)===0;)f++,i.iushrn(1);p(!i.isZero());var c=new o(1).toRed(this),h=c.redNeg(),s=this.m.subn(1).iushrn(1),t=this.m.bitLength();for(t=new o(2*t*t).toRed(this);this.pow(t,s).cmp(h)!==0;)t.redIAdd(h);for(var a=this.pow(t,i),w=this.pow(e,i.addn(1).iushrn(1)),D=this.pow(e,i),Z=f;D.cmp(c)!==0;){for(var F=D,V=0;F.cmp(c)!==0;V++)F=F.redSqr();p(V<Z);var q=this.pow(a,new o(1).iushln(Z-V-1));w=w.redMul(q),a=q.redSqr(),D=D.redMul(a),Z=V}return w},Y.prototype.invm=function(e){var r=e._invmp(this.m);return r.negative!==0?(r.negative=0,this.imod(r).redNeg()):this.imod(r)},Y.prototype.pow=function(e,r){if(r.isZero())return new o(1).toRed(this);if(r.cmpn(1)===0)return e.clone();var n=4,i=new Array(1<<n);i[0]=new o(1).toRed(this),i[1]=e;for(var f=2;f<i.length;f++)i[f]=this.mul(i[f-1],e);var c=i[0],h=0,s=0,t=r.bitLength()%26;for(t===0&&(t=26),f=r.length-1;f>=0;f--){for(var a=r.words[f],w=t-1;w>=0;w--){var D=a>>w&1;if(c!==i[0]&&(c=this.sqr(c)),D===0&&h===0){s=0;continue}h<<=1,h|=D,s++,!(s!==n&&(f!==0||w!==0))&&(c=this.mul(c,i[h]),s=0,h=0)}t=26}return c},Y.prototype.convertTo=function(e){var r=e.umod(this.m);return r===e?r.clone():r},Y.prototype.convertFrom=function(e){var r=e.clone();return r.red=null,r},o.mont=function(e){return new ee(e)};function ee(u){Y.call(this,u),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)}I(ee,Y),ee.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},ee.prototype.convertFrom=function(e){var r=this.imod(e.mul(this.rinv));return r.red=null,r},ee.prototype.imul=function(e,r){if(e.isZero()||r.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(r),i=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),f=n.isub(i).iushrn(this.shift),c=f;return f.cmp(this.m)>=0?c=f.isub(this.m):f.cmpn(0)<0&&(c=f.iadd(this.m)),c._forceRed(this)},ee.prototype.mul=function(e,r){if(e.isZero()||r.isZero())return new o(0)._forceRed(this);var n=e.mul(r),i=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),f=n.isub(i).iushrn(this.shift),c=f;return f.cmp(this.m)>=0?c=f.isub(this.m):f.cmpn(0)<0&&(c=f.iadd(this.m)),c._forceRed(this)},ee.prototype.invm=function(e){var r=this.imod(e._invmp(this.m).mul(this.r2));return r._forceRed(this)}}(fe,this)},7007:fe=>{"use strict";var x=typeof Reflect=="object"?Reflect:null,T=x&&typeof x.apply=="function"?x.apply:function(N,j,K){return Function.prototype.apply.call(N,j,K)},S;x&&typeof x.ownKeys=="function"?S=x.ownKeys:Object.getOwnPropertySymbols?S=function(N){return Object.getOwnPropertyNames(N).concat(Object.getOwnPropertySymbols(N))}:S=function(N){return Object.getOwnPropertyNames(N)};function y(L){console&&console.warn&&console.warn(L)}var p=Number.isNaN||function(N){return N!==N};function I(){I.init.call(this)}fe.exports=I,fe.exports.once=B,I.EventEmitter=I,I.prototype._events=void 0,I.prototype._eventsCount=0,I.prototype._maxListeners=void 0;var o=10;function m(L){if(typeof L!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof L)}Object.defineProperty(I,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(L){if(typeof L!="number"||L<0||p(L))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+L+".");o=L}}),I.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},I.prototype.setMaxListeners=function(N){if(typeof N!="number"||N<0||p(N))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+N+".");return this._maxListeners=N,this};function l(L){return L._maxListeners===void 0?I.defaultMaxListeners:L._maxListeners}I.prototype.getMaxListeners=function(){return l(this)},I.prototype.emit=function(N){for(var j=[],K=1;K<arguments.length;K++)j.push(arguments[K]);var $=N==="error",Q=this._events;if(Q!==void 0)$=$&&Q.error===void 0;else if(!$)return!1;if($){var Y;if(j.length>0&&(Y=j[0]),Y instanceof Error)throw Y;var ee=new Error("Unhandled error."+(Y?" ("+Y.message+")":""));throw ee.context=Y,ee}var u=Q[N];if(u===void 0)return!1;if(typeof u=="function")T(u,this,j);else for(var e=u.length,r=v(u,e),K=0;K<e;++K)T(r[K],this,j);return!0};function g(L,N,j,K){var $,Q,Y;if(m(j),Q=L._events,Q===void 0?(Q=L._events=Object.create(null),L._eventsCount=0):(Q.newListener!==void 0&&(L.emit("newListener",N,j.listener?j.listener:j),Q=L._events),Y=Q[N]),Y===void 0)Y=Q[N]=j,++L._eventsCount;else if(typeof Y=="function"?Y=Q[N]=K?[j,Y]:[Y,j]:K?Y.unshift(j):Y.push(j),$=l(L),$>0&&Y.length>$&&!Y.warned){Y.warned=!0;var ee=new Error("Possible EventEmitter memory leak detected. "+Y.length+" "+String(N)+" listeners added. Use emitter.setMaxListeners() to increase limit");ee.name="MaxListenersExceededWarning",ee.emitter=L,ee.type=N,ee.count=Y.length,y(ee)}return L}I.prototype.addListener=function(N,j){return g(this,N,j,!1)},I.prototype.on=I.prototype.addListener,I.prototype.prependListener=function(N,j){return g(this,N,j,!0)};function M(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function E(L,N,j){var K={fired:!1,wrapFn:void 0,target:L,type:N,listener:j},$=M.bind(K);return $.listener=j,K.wrapFn=$,$}I.prototype.once=function(N,j){return m(j),this.on(N,E(this,N,j)),this},I.prototype.prependOnceListener=function(N,j){return m(j),this.prependListener(N,E(this,N,j)),this},I.prototype.removeListener=function(N,j){var K,$,Q,Y,ee;if(m(j),$=this._events,$===void 0)return this;if(K=$[N],K===void 0)return this;if(K===j||K.listener===j)--this._eventsCount===0?this._events=Object.create(null):(delete $[N],$.removeListener&&this.emit("removeListener",N,K.listener||j));else if(typeof K!="function"){for(Q=-1,Y=K.length-1;Y>=0;Y--)if(K[Y]===j||K[Y].listener===j){ee=K[Y].listener,Q=Y;break}if(Q<0)return this;Q===0?K.shift():b(K,Q),K.length===1&&($[N]=K[0]),$.removeListener!==void 0&&this.emit("removeListener",N,ee||j)}return this},I.prototype.off=I.prototype.removeListener,I.prototype.removeAllListeners=function(N){var j,K,$;if(K=this._events,K===void 0)return this;if(K.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):K[N]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete K[N]),this;if(arguments.length===0){var Q=Object.keys(K),Y;for($=0;$<Q.length;++$)Y=Q[$],Y!=="removeListener"&&this.removeAllListeners(Y);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(j=K[N],typeof j=="function")this.removeListener(N,j);else if(j!==void 0)for($=j.length-1;$>=0;$--)this.removeListener(N,j[$]);return this};function d(L,N,j){var K=L._events;if(K===void 0)return[];var $=K[N];return $===void 0?[]:typeof $=="function"?j?[$.listener||$]:[$]:j?k($):v($,$.length)}I.prototype.listeners=function(N){return d(this,N,!0)},I.prototype.rawListeners=function(N){return d(this,N,!1)},I.listenerCount=function(L,N){return typeof L.listenerCount=="function"?L.listenerCount(N):A.call(L,N)},I.prototype.listenerCount=A;function A(L){var N=this._events;if(N!==void 0){var j=N[L];if(typeof j=="function")return 1;if(j!==void 0)return j.length}return 0}I.prototype.eventNames=function(){return this._eventsCount>0?S(this._events):[]};function v(L,N){for(var j=new Array(N),K=0;K<N;++K)j[K]=L[K];return j}function b(L,N){for(;N+1<L.length;N++)L[N]=L[N+1];L.pop()}function k(L){for(var N=new Array(L.length),j=0;j<N.length;++j)N[j]=L[j].listener||L[j];return N}function B(L,N){return new Promise(function(j,K){function $(Y){L.removeListener(N,Q),K(Y)}function Q(){typeof L.removeListener=="function"&&L.removeListener("error",$),j([].slice.call(arguments))}C(L,N,Q,{once:!0}),N!=="error"&&U(L,$,{once:!0})})}function U(L,N,j){typeof L.on=="function"&&C(L,"error",N,j)}function C(L,N,j,K){if(typeof L.on=="function")K.once?L.once(N,j):L.on(N,j);else if(typeof L.addEventListener=="function")L.addEventListener(N,function $(Q){K.once&&L.removeEventListener(N,$),j(Q)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof L)}},8078:(fe,x,T)=>{var S=T(2861).Buffer,y=T(8276);function p(I,o,m,l){if(S.isBuffer(I)||(I=S.from(I,"binary")),o&&(S.isBuffer(o)||(o=S.from(o,"binary")),o.length!==8))throw new RangeError("salt should be Buffer with 8 byte length");for(var g=m/8,M=S.alloc(g),E=S.alloc(l||0),d=S.alloc(0);g>0||l>0;){var A=new y;A.update(d),A.update(I),o&&A.update(o),d=A.digest();var v=0;if(g>0){var b=M.length-g;v=Math.min(g,d.length),d.copy(M,b,0,v),g-=v}if(v<d.length&&l>0){var k=E.length-l,B=Math.min(l,d.length-v);d.copy(E,k,v,v+B),l-=B}}return d.fill(0),{key:M,iv:E}}fe.exports=p},6341:fe=>{function x(S){return S}function T(S,I,o){for(var I=I||x,o=o||S,m,l=0,g=S.length;l<g;l+=1)if(m=I.call(o,S[l],l))return S[l]}fe.exports=T},8036:(fe,x,T)=>{"use strict";var S=T(2110),y=T(5174),p=fe.exports;fe.exports.groestl512=function(I,o,m){return S(I,o,m)},fe.exports.groestl=function(I,o,m){var l=S(I,o,2);return l=l.slice(0,8),m===2?l:m===1?y.int32Buffer2Bytes(l):y.int32ArrayToHexString(l)},fe.exports.groestl_2=function(I,o,m){var l=S(I,o,2);return l=S(l,2,2),l=l.slice(0,8),m===2?l:m===1?y.int32Buffer2Bytes(l):y.int32ArrayToHexString(l)}},2110:(fe,x,T)=>{var S=T(7749),y=T(5174),p=y.bytes2Int64Buffer(y.b64Decode("xjL0pfSXpcb4b5eEl+uE+O5esJmwx5nu9nqMjYz3jfb/6BcNF+UN/9YK3L3ct73W3hbIscinsd6RbfxU/DlUkWCQ8FDwwFBgAgcFAwUEAwLOLuCp4IepzlbRh32HrH1W58wrGSvVGee1E6ZipnFitU18MeYxmuZN7Fm1mrXDmuyPQM9FzwVFjx+jvJ28Pp0fiUnAQMAJQIn6aJKHku+H+u/QPxU/xRXvspQm6yZ/67KOzkDJQAfJjvvmHQsd7Qv7QW4v7C+C7EGzGqlnqX1ns19DHP0cvv1fRWAl6iWK6kUj+dq/2ka/I1NRAvcCpvdT5EWhlqHTluSbdu1b7S1bm3UoXcJd6sJ14cUkHCTZHOE91Omu6XquPUzyvmq+mGpMbILuWu7YWmx+vcNBw/xBfvXzBgIG8QL1g1LRT9EdT4NojORc5NBcaFFWB/QHovRR0Y1cNFy5NNH54RgIGOkI+eJMrpOu35Piqz6Vc5VNc6til/VT9cRTYiprQT9BVD8qCBwUDBQQDAiVY/ZS9jFSlUbpr2WvjGVGnX/iXuIhXp0wSHgoeGAoMDfP+KH4bqE3ChsRDxEUDwov68S1xF61Lw4VGwkbHAkOJH5aNlpINiQbrbabtjabG9+YRz1HpT3fzadqJmqBJs1O9btpu5xpTn8zTM1M/s1/6lC6n7rPn+oSPy0bLSQbEh2kuZ65Op4dWMScdJywdFg0RnIucmguNDZBdy13bC023BHNss2jsty0nSnuKXPutFtNFvsWtvtbpKUB9gFT9qR2oddN1+xNdrcUo2GjdWG3fTRJzkn6zn1S3417jaR7Ut2fQj5CoT7dXs2TcZO8cV4TsaKXoiaXE6aiBPUEV/WmuQG4aLhpaLkAAAAAAAAAAMG1dCx0mSzBQOCgYKCAYEDjwiEfId0f43k6Q8hD8sh5tpos7Sx37bbUDdm+2bO+1I1HykbKAUaNZxdw2XDO2Wdyr91L3eRLcpTted55M96UmP9n1Gcr1JiwkyPoI3vosIVb3kreEUqFuwa9a71ta7vFu34qfpEqxU97NOU0nuVP7dc6FjrBFu2G0lTFVBfFhpr4YtdiL9eaZpn/Vf/MVWYRtqeUpyKUEYrASs9KD8+K6dkwEDDJEOkEDgoGCggGBP5mmIGY54H+oKsL8Atb8KB4tMxEzPBEeCXw1brVSrolS3U+4z6W40uirA7zDl/zol1EGf4Zuv5dgNtbwFsbwIAFgIWKhQqKBT/T7K3sfq0/If7fvN9CvCFwqNhI2OBIcPH9DAQM+QTxYxl633rG32N3L1jBWO7Bd68wn3WfRXWvQuelY6WEY0IgcFAwUEAwIOXLLhou0Rrl/e8SDhLhDv2/CLdtt2Vtv4FV1EzUGUyBGCQ8FDwwFBgmeV81X0w1JsOycS9xnS/DvoY44Thn4b41yP2i/WqiNYjHT8xPC8yILmVLOUtcOS6TavlX+T1Xk1VYDfINqvJV/GGdgp3jgvx6s8lHyfRHesgn76zvi6zIuogy5zJv57oyT30rfWQrMuZCpJWk15XmwDv7oPuboMAZqrOYszKYGZ72aNFoJ9GeoyKBf4Fdf6NE7qpmqohmRFTWgn6CqH5UO93mq+Z2qzsLlZ6DnhaDC4zJRcpFA8qMx7x7KXuVKcdrBW7TbtbTayhsRDxEUDwopyyLeYtVeae8gT3iPWPivBYxJx0nLB0WrTeadppBdq3blk07Ta0722Se+lb6yFZkdKbSTtLoTnQUNiIeIigeFJLkdtt2P9uSDBIeCh4YCgxI/LRstJBsSLiPN+Q3a+S4n3jnXeclXZ+9D7JusmFuvUNpKu8qhu9DxDXxpvGTpsQ52uOo43KoOTHG96T3YqQx04pZN1m9N9PydIaLhv+L8tWDVjJWsTLVi07FQ8UNQ4tuhetZ69xZbtoYwrfCr7faAY6PjI8CjAGxHaxkrHlksZzxbdJtI9KcSXI74DuS4EnYH8e0x6u02Ky5FfoVQ/qs8/oJBwn9B/PPoG8lb4Ulz8og6q/qj6/K9H2JjonzjvRHZyDpII7pRxA4KBgoIBgQbwtk1WTe1W/wc4OIg/uI8Er7sW+xlG9KXMqWcpa4clw4VGwkbHAkOFdfCPEIrvFXcyFSx1Lmx3OXZPNR8zVRl8uuZSNljSPLoSWEfIRZfKHoV7+cv8uc6D5dYyFjfCE+lup83Xw33ZZhHn/cf8LcYQ2ckYaRGoYND5uUhZQehQ/gS6uQq9uQ4Hy6xkLG+EJ8cSZXxFfixHHMKeWq5YOqzJDjc9hzO9iQBgkPBQ8MBQb39AMBA/UB9xwqNhI2OBIcwjz+o/6fo8Jqi+Ff4dRfaq6+EPkQR/muaQJr0GvS0GkXv6iRqC6RF5lx6FjoKViZOlNpJ2l0Jzon99C50E65J9mRSDhIqTjZ6941EzXNE+sr5c6zzlazKyJ3VTNVRDMi0gTWu9a/u9KpOZBwkElwqQeHgImADokHM8Hyp/JmpzMt7MG2wVq2LTxaZiJmeCI8Fbitkq0qkhXJqWAgYIkgyYdc20nbFUmHqrAa/xpP/6pQ2Ih4iKB4UKUrjnqOUXqlA4mKj4oGjwNZShP4E7L4WQmSm4CbEoAJGiM5Fzk0FxplEHXadcraZdeEUzFTtTHXhNVRxlETxoTQA9O407u40ILcXsNeH8OCKeLLsMtSsClaw5l3mbR3Wh4tMxEzPBEeez1Gy0b2y3uotx/8H0v8qG0MYdZh2tZtLGJOOk5YOiw=")),I=y.bytes2Int64Buffer(y.b64Decode("xsYy9KX0l6X4+G+XhJfrhO7uXrCZsMeZ9vZ6jI2M943//+gXDRflDdbWCty93Le93t4WyLHIp7GRkW38VPw5VGBgkPBQ8MBQAgIHBQMFBAPOzi7gqeCHqVZW0Yd9h6x95+fMKxkr1Rm1tROmYqZxYk1NfDHmMZrm7OxZtZq1w5qPj0DPRc8FRR8fo7ydvD6diYlJwEDACUD6+miSh5Lvh+/v0D8VP8UVsrKUJusmf+uOjs5AyUAHyfv75h0LHe0LQUFuL+wvguyzsxqpZ6l9Z19fQxz9HL79RUVgJeoliuojI/nav9pGv1NTUQL3Aqb35ORFoZah05abm3btW+0tW3V1KF3CXerC4eHFJBwk2Rw9PdTprul6rkxM8r5qvphqbGyC7lru2Fp+fr3DQcP8QfX18wYCBvECg4NS0U/RHU9oaIzkXOTQXFFRVgf0B6L00dGNXDRcuTT5+eEYCBjpCOLiTK6Trt+Tq6s+lXOVTXNiYpf1U/XEUyoqa0E/QVQ/CAgcFAwUEAyVlWP2UvYxUkZG6a9lr4xlnZ1/4l7iIV4wMEh4KHhgKDc3z/ih+G6hCgobEQ8RFA8vL+vEtcRetQ4OFRsJGxwJJCR+WjZaSDYbG622m7Y2m9/fmEc9R6U9zc2naiZqgSZOTvW7abucaX9/M0zNTP7N6upQup+6z58SEj8tGy0kGx0dpLmeuTqeWFjEnHScsHQ0NEZyLnJoLjY2QXctd2wt3NwRzbLNo7K0tJ0p7ilz7ltbTRb7Frb7pKSlAfYBU/Z2dqHXTdfsTbe3FKNho3VhfX00Sc5J+s5SUt+Ne42ke93dn0I+QqE+Xl7Nk3GTvHETE7Gil6Iml6amogT1BFf1ubkBuGi4aWgAAAAAAAAAAMHBtXQsdJksQEDgoGCggGDj48IhHyHdH3l5OkPIQ/LItraaLO0sd+3U1A3Zvtmzvo2NR8pGygFGZ2cXcNlwztlycq/dS93kS5SU7XneeTPemJj/Z9RnK9SwsJMj6CN76IWFW95K3hFKu7sGvWu9bWvFxbt+Kn6RKk9PezTlNJ7l7e3XOhY6wRaGhtJUxVQXxZqa+GLXYi/XZmaZ/1X/zFUREbanlKcilIqKwErPSg/P6enZMBAwyRAEBA4KBgoIBv7+ZpiBmOeBoKCrC/ALW/B4eLTMRMzwRCUl8NW61Uq6S0t1PuM+luOioqwO8w5f811dRBn+Gbr+gIDbW8BbG8AFBYCFioUKij8/0+yt7H6tISH+37zfQrxwcKjYSNjgSPHx/QwEDPkEY2MZet96xt93dy9YwVjuwa+vMJ91n0V1QkLnpWOlhGMgIHBQMFBAMOXlyy4aLtEa/f3vEg4S4Q6/vwi3bbdlbYGBVdRM1BlMGBgkPBQ8MBQmJnlfNV9MNcPDsnEvcZ0vvr6GOOE4Z+E1Ncj9ov1qooiIx0/MTwvMLi5lSzlLXDmTk2r5V/k9V1VVWA3yDary/PxhnYKd44J6erPJR8n0R8jIJ++s74usurqIMucyb+cyMk99K31kK+bmQqSVpNeVwMA7+6D7m6AZGaqzmLMymJ6e9mjRaCfRo6MigX+BXX9ERO6qZqqIZlRU1oJ+gqh+Ozvd5qvmdqsLC5Weg54Wg4yMyUXKRQPKx8e8eyl7lSlrawVu027W0ygobEQ8RFA8p6csi3mLVXm8vIE94j1j4hYWMScdJywdra03mnaaQXbb25ZNO02tO2RknvpW+shWdHSm0k7S6E4UFDYiHiIoHpKS5Hbbdj/bDAwSHgoeGApISPy0bLSQbLi4jzfkN2vkn594513nJV29vQ+ybrJhbkNDaSrvKobvxMQ18abxk6Y5OdrjqONyqDExxvek92Kk09OKWTdZvTfy8nSGi4b/i9XVg1YyVrEyi4tOxUPFDUNuboXrWevcWdraGMK3wq+3AQGOj4yPAoyxsR2sZKx5ZJyc8W3SbSPSSUlyO+A7kuDY2B/HtMertKysuRX6FUP68/P6CQcJ/QfPz6BvJW+FJcrKIOqv6o+v9PR9iY6J845HR2cg6SCO6RAQOCgYKCAYb28LZNVk3tXw8HODiIP7iEpK+7FvsZRvXFzKlnKWuHI4OFRsJGxwJFdXXwjxCK7xc3MhUsdS5seXl2TzUfM1UcvLrmUjZY0joaElhHyEWXzo6Fe/nL/LnD4+XWMhY3whlpbqfN18N91hYR5/3H/C3A0NnJGGkRqGDw+blIWUHoXg4EurkKvbkHx8usZCxvhCcXEmV8RX4sTMzCnlquWDqpCQ43PYczvYBgYJDwUPDAX39/QDAQP1ARwcKjYSNjgSwsI8/qP+n6NqaovhX+HUX66uvhD5EEf5aWkCa9Br0tAXF7+okagukZmZcehY6ClYOjpTaSdpdCcnJ/fQudBOudnZkUg4SKk46+veNRM1zRMrK+XOs85WsyIid1UzVUQz0tIE1rvWv7upqTmQcJBJcAcHh4CJgA6JMzPB8qfyZqctLezBtsFatjw8WmYiZngiFRW4rZKtKpLJyalgIGCJIIeHXNtJ2xVJqqqwGv8aT/9QUNiIeIigeKWlK456jlF6AwOJio+KBo9ZWUoT+BOy+AkJkpuAmxKAGhojORc5NBdlZRB12nXK2tfXhFMxU7UxhITVUcZRE8bQ0APTuNO7uIKC3F7DXh/DKSniy7DLUrBaWsOZd5m0dx4eLTMRMzwRe3s9RstG9suoqLcf/B9L/G1tDGHWYdrWLCxiTjpOWDo=")),o=y.bytes2Int64Buffer(y.b64Decode("pcbGMvSl9JeE+Phvl4SX65nu7l6wmbDHjfb2eoyNjPcN///oFw0X5b3W1grcvdy3sd7eFsixyKdUkZFt/FT8OVBgYJDwUPDAAwICBwUDBQSpzs4u4Kngh31WVtGHfYesGefnzCsZK9VitbUTpmKmceZNTXwx5jGamuzsWbWatcNFj49Az0XPBZ0fH6O8nbw+QImJScBAwAmH+vpokoeS7xXv79A/FT/F67KylCbrJn/Jjo7OQMlABwv7++YdCx3t7EFBbi/sL4Jns7MaqWepff1fX0Mc/Ry+6kVFYCXqJYq/IyP52r/aRvdTU1EC9wKmluTkRaGWodNbm5t27VvtLcJ1dShdwl3qHOHhxSQcJNmuPT3U6a7pempMTPK+ar6YWmxsgu5a7thBfn69w0HD/AL19fMGAgbxT4ODUtFP0R1caGiM5Fzk0PRRUVYH9AeiNNHRjVw0XLkI+fnhGAgY6ZPi4kyuk67fc6urPpVzlU1TYmKX9VP1xD8qKmtBP0FUDAgIHBQMFBBSlZVj9lL2MWVGRumvZa+MXp2df+Je4iEoMDBIeCh4YKE3N8/4ofhuDwoKGxEPERS1Ly/rxLXEXgkODhUbCRscNiQkflo2WkibGxuttpu2Nj3f35hHPUelJs3Np2omaoFpTk71u2m7nM1/fzNMzUz+n+rqULqfus8bEhI/LRstJJ4dHaS5nrk6dFhYxJx0nLAuNDRGci5yaC02NkF3LXdsstzcEc2yzaPutLSdKe4pc/tbW00W+xa29qSkpQH2AVNNdnah103X7GG3txSjYaN1zn19NEnOSfp7UlLfjXuNpD7d3Z9CPkKhcV5ezZNxk7yXExOxopeiJvWmpqIE9QRXaLm5AbhouGkAAAAAAAAAACzBwbV0LHSZYEBA4KBgoIAf4+PCIR8h3ch5eTpDyEPy7ba2miztLHe+1NQN2b7Zs0aNjUfKRsoB2WdnF3DZcM5LcnKv3Uvd5N6UlO153nkz1JiY/2fUZyvosLCTI+gje0qFhVveSt4Ra7u7Br1rvW0qxcW7fip+keVPT3s05TSeFu3t1zoWOsHFhobSVMVUF9eamvhi12IvVWZmmf9V/8yUERG2p5SnIs+KisBKz0oPEOnp2TAQMMkGBAQOCgYKCIH+/maYgZjn8KCgqwvwC1tEeHi0zETM8LolJfDVutVK40tLdT7jPpbzoqKsDvMOX/5dXUQZ/hm6wICA21vAWxuKBQWAhYqFCq0/P9Psrex+vCEh/t+830JIcHCo2EjY4ATx8f0MBAz532NjGXrfesbBd3cvWMFY7nWvrzCfdZ9FY0JC56VjpYQwICBwUDBQQBrl5csuGi7RDv397xIOEuFtv78It223ZUyBgVXUTNQZFBgYJDwUPDA1JiZ5XzVfTC/Dw7JxL3Gd4b6+hjjhOGeiNTXI/aL9asyIiMdPzE8LOS4uZUs5S1xXk5Nq+Vf5PfJVVVgN8g2qgvz8YZ2CneNHenqzyUfJ9KzIyCfvrO+L57q6iDLnMm8rMjJPfSt9ZJXm5kKklaTXoMDAO/ug+5uYGRmqs5izMtGenvZo0Wgnf6OjIoF/gV1mRETuqmaqiH5UVNaCfoKoqzs73ear5naDCwuVnoOeFsqMjMlFykUDKcfHvHspe5XTa2sFbtNu1jwoKGxEPERQeaenLIt5i1XivLyBPeI9Yx0WFjEnHScsdq2tN5p2mkE729uWTTtNrVZkZJ76VvrITnR0ptJO0ugeFBQ2Ih4iKNuSkuR223Y/CgwMEh4KHhhsSEj8tGy0kOS4uI835DdrXZ+feOdd5yVuvb0Psm6yYe9DQ2kq7yqGpsTENfGm8ZOoOTna46jjcqQxMcb3pPdiN9PTilk3Wb2L8vJ0houG/zLV1YNWMlaxQ4uLTsVDxQ1Zbm6F61nr3Lfa2hjCt8KvjAEBjo+MjwJksbEdrGSsedKcnPFt0m0j4ElJcjvgO5K02Ngfx7THq/qsrLkV+hVDB/Pz+gkHCf0lz8+gbyVvha/KyiDqr+qPjvT0fYmOifPpR0dnIOkgjhgQEDgoGCgg1W9vC2TVZN6I8PBzg4iD+29KSvuxb7GUclxcypZylrgkODhUbCRscPFXV18I8Qiux3NzIVLHUuZRl5dk81HzNSPLy65lI2WNfKGhJYR8hFmc6OhXv5y/yyE+Pl1jIWN83ZaW6nzdfDfcYWEef9x/woYNDZyRhpEahQ8Pm5SFlB6Q4OBLq5Cr20J8fLrGQsb4xHFxJlfEV+KqzMwp5arlg9iQkONz2HM7BQYGCQ8FDwwB9/f0AwED9RIcHCo2EjY4o8LCPP6j/p9famqL4V/h1Pmurr4Q+RBH0GlpAmvQa9KRFxe/qJGoLliZmXHoWOgpJzo6U2knaXS5Jyf30LnQTjjZ2ZFIOEipE+vr3jUTNc2zKyvlzrPOVjMiIndVM1VEu9LSBNa71r9wqak5kHCQSYkHB4eAiYAOpzMzwfKn8ma2LS3swbbBWiI8PFpmImZ4khUVuK2SrSogycmpYCBgiUmHh1zbSdsV/6qqsBr/Gk94UFDYiHiIoHqlpSuOeo5RjwMDiYqPigb4WVlKE/gTsoAJCZKbgJsSFxoaIzkXOTTaZWUQddp1yjHX14RTMVO1xoSE1VHGURO40NAD07jTu8OCgtxew14fsCkp4suwy1J3WlrDmXeZtBEeHi0zETM8y3t7PUbLRvb8qKi3H/wfS9ZtbQxh1mHaOiwsYk46Tlg=")),m=y.bytes2Int64Buffer(y.b64Decode("l6XGxjL0pfTrhPj4b5eEl8eZ7u5esJmw94329nqMjYzlDf//6BcNF7e91tYK3L3cp7He3hbIscg5VJGRbfxU/MBQYGCQ8FDwBAMCAgcFAwWHqc7OLuCp4Kx9VlbRh32H1Rnn58wrGStxYrW1E6ZipprmTU18MeYxw5rs7Fm1mrUFRY+PQM9Fzz6dHx+jvJ28CUCJiUnAQMDvh/r6aJKHksUV7+/QPxU/f+uyspQm6yYHyY6OzkDJQO0L+/vmHQsdguxBQW4v7C99Z7OzGqlnqb79X19DHP0ciupFRWAl6iVGvyMj+dq/2qb3U1NRAvcC05bk5EWhlqEtW5ubdu1b7erCdXUoXcJd2Rzh4cUkHCR6rj091Omu6ZhqTEzyvmq+2FpsbILuWu78QX5+vcNBw/EC9fXzBgIGHU+Dg1LRT9HQXGhojORc5KL0UVFWB/QHuTTR0Y1cNFzpCPn54RgIGN+T4uJMrpOuTXOrqz6Vc5XEU2Jil/VT9VQ/KiprQT9BEAwICBwUDBQxUpWVY/ZS9oxlRkbpr2WvIV6dnX/iXuJgKDAwSHgoeG6hNzfP+KH4FA8KChsRDxFetS8v68S1xBwJDg4VGwkbSDYkJH5aNlo2mxsbrbabtqU939+YRz1HgSbNzadqJmqcaU5O9btpu/7Nf38zTM1Mz5/q6lC6n7okGxISPy0bLTqeHR2kuZ65sHRYWMScdJxoLjQ0RnIucmwtNjZBdy13o7Lc3BHNss1z7rS0nSnuKbb7W1tNFvsWU/akpKUB9gHsTXZ2oddN13Vht7cUo2Gj+s59fTRJzkmke1JS3417jaE+3d2fQj5CvHFeXs2TcZMmlxMTsaKXolf1pqaiBPUEaWi5uQG4aLgAAAAAAAAAAJkswcG1dCx0gGBAQOCgYKDdH+PjwiEfIfLIeXk6Q8hDd+22tpos7SyzvtTUDdm+2QFGjY1HykbKztlnZxdw2XDkS3Jyr91L3TPelJTted55K9SYmP9n1Gd76LCwkyPoIxFKhYVb3krebWu7uwa9a72RKsXFu34qfp7lT097NOU0wRbt7dc6FjoXxYaG0lTFVC/Xmpr4YtdizFVmZpn/Vf8ilBERtqeUpw/PiorASs9KyRDp6dkwEDAIBgQEDgoGCueB/v5mmIGYW/CgoKsL8AvwRHh4tMxEzEq6JSXw1brVluNLS3U+4z5f86KirA7zDrr+XV1EGf4ZG8CAgNtbwFsKigUFgIWKhX6tPz/T7K3sQrwhIf7fvN/gSHBwqNhI2PkE8fH9DAQMxt9jYxl633ruwXd3L1jBWEV1r68wn3WfhGNCQuelY6VAMCAgcFAwUNEa5eXLLhou4Q79/e8SDhJlbb+/CLdttxlMgYFV1EzUMBQYGCQ8FDxMNSYmeV81X50vw8OycS9xZ+G+voY44ThqojU1yP2i/QvMiIjHT8xPXDkuLmVLOUs9V5OTavlX+aryVVVYDfIN44L8/GGdgp30R3p6s8lHyYusyMgn76zvb+e6uogy5zJkKzIyT30rfdeV5uZCpJWkm6DAwDv7oPsymBkZqrOYsyfRnp72aNFoXX+joyKBf4GIZkRE7qpmqqh+VFTWgn6Cdqs7O93mq+YWgwsLlZ6DngPKjIzJRcpFlSnHx7x7KXvW02trBW7TblA8KChsRDxEVXmnpyyLeYtj4ry8gT3iPSwdFhYxJx0nQXatrTeadpqtO9vblk07TchWZGSe+lb66E50dKbSTtIoHhQUNiIeIj/bkpLkdtt2GAoMDBIeCh6QbEhI/LRstGvkuLiPN+Q3JV2fn3jnXedhbr29D7JusobvQ0NpKu8qk6bExDXxpvFyqDk52uOo42KkMTHG96T3vTfT04pZN1n/i/LydIaLhrEy1dWDVjJWDUOLi07FQ8XcWW5uhetZ66+32toYwrfCAowBAY6PjI95ZLGxHaxkrCPSnJzxbdJtkuBJSXI74DurtNjYH8e0x0P6rKy5FfoV/Qfz8/oJBwmFJc/PoG8lb4+vysog6q/q84709H2JjomO6UdHZyDpICAYEBA4KBgo3tVvbwtk1WT7iPDwc4OIg5RvSkr7sW+xuHJcXMqWcpZwJDg4VGwkbK7xV1dfCPEI5sdzcyFSx1I1UZeXZPNR840jy8uuZSNlWXyhoSWEfITLnOjoV7+cv3whPj5dYyFjN92Wlup83XzC3GFhHn/cfxqGDQ2ckYaRHoUPD5uUhZTbkODgS6uQq/hCfHy6xkLG4sRxcSZXxFeDqszMKeWq5TvYkJDjc9hzDAUGBgkPBQ/1Aff39AMBAzgSHBwqNhI2n6PCwjz+o/7UX2pqi+Ff4Uf5rq6+EPkQ0tBpaQJr0GsukRcXv6iRqClYmZlx6FjodCc6OlNpJ2lOuScn99C50Kk42dmRSDhIzRPr6941EzVWsysr5c6zzkQzIiJ3VTNVv7vS0gTWu9ZJcKmpOZBwkA6JBweHgImAZqczM8Hyp/Jati0t7MG2wXgiPDxaZiJmKpIVFbitkq2JIMnJqWAgYBVJh4dc20nbT/+qqrAa/xqgeFBQ2Ih4iFF6paUrjnqOBo8DA4mKj4qy+FlZShP4ExKACQmSm4CbNBcaGiM5FznK2mVlEHXadbUx19eEUzFTE8aEhNVRxlG7uNDQA9O40x/DgoLcXsNeUrApKeLLsMu0d1paw5l3mTwRHh4tMxEz9st7ez1Gy0ZL/Kiotx/8H9rWbW0MYdZhWDosLGJOOk4=")),l=y.bytes2Int64Buffer(y.b64Decode("9JelxsYy9KWX64T4+G+XhLDHme7uXrCZjPeN9vZ6jI0X5Q3//+gXDdy3vdbWCty9yKex3t4WyLH8OVSRkW38VPDAUGBgkPBQBQQDAgIHBQPgh6nOzi7gqYesfVZW0Yd9K9UZ5+fMKxmmcWK1tROmYjGa5k1NfDHmtcOa7OxZtZrPBUWPj0DPRbw+nR8fo7ydwAlAiYlJwECS74f6+miShz/FFe/v0D8VJn/rsrKUJutAB8mOjs5AyR3tC/v75h0LL4LsQUFuL+ypfWezsxqpZxy+/V9fQxz9JYrqRUVgJeraRr8jI/navwKm91NTUQL3odOW5ORFoZbtLVubm3btW13qwnV1KF3CJNkc4eHFJBzpeq49PdTprr6YakxM8r5q7thabGyC7lrD/EF+fr3DQQbxAvX18wYC0R1Pg4NS0U/k0FxoaIzkXAei9FFRVgf0XLk00dGNXDQY6Qj5+eEYCK7fk+LiTK6TlU1zq6s+lXP1xFNiYpf1U0FUPyoqa0E/FBAMCAgcFAz2MVKVlWP2Uq+MZUZG6a9l4iFenZ1/4l54YCgwMEh4KPhuoTc3z/ihERQPCgobEQ/EXrUvL+vEtRscCQ4OFRsJWkg2JCR+Wja2NpsbG622m0elPd/fmEc9aoEmzc2naia7nGlOTvW7aUz+zX9/M0zNus+f6upQup8tJBsSEj8tG7k6nh0dpLmenLB0WFjEnHRyaC40NEZyLndsLTY2QXctzaOy3NwRzbIpc+60tJ0p7ha2+1tbTRb7AVP2pKSlAfbX7E12dqHXTaN1Ybe3FKNhSfrOfX00Sc6NpHtSUt+Ne0KhPt3dn0I+k7xxXl7Nk3GiJpcTE7GilwRX9aamogT1uGloubkBuGgAAAAAAAAAAHSZLMHBtXQsoIBgQEDgoGAh3R/j48IhH0PyyHl5OkPILHfttraaLO3Zs77U1A3ZvsoBRo2NR8pGcM7ZZ2cXcNnd5Etycq/dS3kz3pSU7XneZyvUmJj/Z9Qje+iwsJMj6N4RSoWFW95KvW1ru7sGvWt+kSrFxbt+KjSe5U9PezTlOsEW7e3XOhZUF8WGhtJUxWIv15qa+GLX/8xVZmaZ/1WnIpQREbanlEoPz4qKwErPMMkQ6enZMBAKCAYEBA4KBpjngf7+ZpiBC1vwoKCrC/DM8ER4eLTMRNVKuiUl8NW6PpbjS0t1PuMOX/OioqwO8xm6/l1dRBn+WxvAgIDbW8CFCooFBYCFiux+rT8/0+yt30K8ISH+37zY4EhwcKjYSAz5BPHx/QwEesbfY2MZet9Y7sF3dy9YwZ9Fda+vMJ91pYRjQkLnpWNQQDAgIHBQMC7RGuXlyy4aEuEO/f3vEg63ZW2/vwi3bdQZTIGBVdRMPDAUGBgkPBRfTDUmJnlfNXGdL8PDsnEvOGfhvr6GOOH9aqI1Ncj9ok8LzIiIx0/MS1w5Li5lSzn5PVeTk2r5Vw2q8lVVWA3yneOC/PxhnYLJ9Ed6erPJR++LrMjIJ++sMm/nurqIMud9ZCsyMk99K6TXlebmQqSV+5ugwMA7+6CzMpgZGaqzmGgn0Z6e9mjRgV1/o6MigX+qiGZERO6qZoKoflRU1oJ+5narOzvd5queFoMLC5Weg0UDyoyMyUXKe5Upx8e8eylu1tNrawVu00RQPCgobEQ8i1V5p6csi3k9Y+K8vIE94icsHRYWMScdmkF2ra03mnZNrTvb25ZNO/rIVmRknvpW0uhOdHSm0k4iKB4UFDYiHnY/25KS5HbbHhgKDAwSHgq0kGxISPy0bDdr5Li4jzfk5yVdn594512yYW69vQ+ybiqG70NDaSrv8ZOmxMQ18abjcqg5OdrjqPdipDExxvekWb0309OKWTeG/4vy8nSGi1axMtXVg1YyxQ1Di4tOxUPr3FluboXrWcKvt9raGMK3jwKMAQGOj4yseWSxsR2sZG0j0pyc8W3SO5LgSUlyO+DHq7TY2B/HtBVD+qysuRX6Cf0H8/P6CQdvhSXPz6BvJeqPr8rKIOqvifOO9PR9iY4gjulHR2cg6SggGBAQOCgYZN7Vb28LZNWD+4jw8HODiLGUb0pK+7FvlrhyXFzKlnJscCQ4OFRsJAiu8VdXXwjxUubHc3MhUsfzNVGXl2TzUWWNI8vLrmUjhFl8oaElhHy/y5zo6Fe/nGN8IT4+XWMhfDfdlpbqfN1/wtxhYR5/3JEahg0NnJGGlB6FDw+blIWr25Dg4EurkMb4Qnx8usZCV+LEcXEmV8Tlg6rMzCnlqnM72JCQ43PYDwwFBgYJDwUD9QH39/QDATY4EhwcKjYS/p+jwsI8/qPh1F9qaovhXxBH+a6uvhD5a9LQaWkCa9CoLpEXF7+okegpWJmZcehYaXQnOjpTaSfQTrknJ/fQuUipONnZkUg4Nc0T6+veNRPOVrMrK+XOs1VEMyIid1Uz1r+70tIE1ruQSXCpqTmQcIAOiQcHh4CJ8manMzPB8qfBWrYtLezBtmZ4Ijw8WmYirSqSFRW4rZJgiSDJyalgINsVSYeHXNtJGk//qqqwGv+IoHhQUNiIeI5ReqWlK456igaPAwOJio8TsvhZWUoT+JsSgAkJkpuAOTQXGhojORd1ytplZRB12lO1MdfXhFMxURPGhITVUcbTu7jQ0APTuF4fw4KC3F7Dy1KwKSniy7CZtHdaWsOZdzM8ER4eLTMRRvbLe3s9RssfS/yoqLcf/GHa1m1tDGHWTlg6LCxiTjo=")),g=y.bytes2Int64Buffer(y.b64Decode("pfSXpcbGMvSEl+uE+Phvl5mwx5nu7l6wjYz3jfb2eowNF+UN///oF73ct73W1grcscinsd7eFshU/DlUkZFt/FDwwFBgYJDwAwUEAwICBwWp4Iepzs4u4H2HrH1WVtGHGSvVGefnzCtipnFitbUTpuYxmuZNTXwxmrXDmuzsWbVFzwVFj49Az528Pp0fH6O8QMAJQImJScCHku+H+vpokhU/xRXv79A/6yZ/67KylCbJQAfJjo7OQAsd7Qv7++Yd7C+C7EFBbi9nqX1ns7Maqf0cvv1fX0Mc6iWK6kVFYCW/2ka/IyP52vcCpvdTU1EClqHTluTkRaFb7S1bm5t27cJd6sJ1dShdHCTZHOHhxSSu6XquPT3U6Wq+mGpMTPK+Wu7YWmxsgu5Bw/xBfn69wwIG8QL19fMGT9EdT4ODUtFc5NBcaGiM5PQHovRRUVYHNFy5NNHRjVwIGOkI+fnhGJOu35Pi4kyuc5VNc6urPpVT9cRTYmKX9T9BVD8qKmtBDBQQDAgIHBRS9jFSlZVj9mWvjGVGRumvXuIhXp2df+IoeGAoMDBIeKH4bqE3N8/4DxEUDwoKGxG1xF61Ly/rxAkbHAkODhUbNlpINiQkflqbtjabGxuttj1HpT3f35hHJmqBJs3Np2ppu5xpTk71u81M/s1/fzNMn7rPn+rqULobLSQbEhI/LZ65Op4dHaS5dJywdFhYxJwucmguNDRGci13bC02NkF3ss2jstzcEc3uKXPutLSdKfsWtvtbW00W9gFT9qSkpQFN1+xNdnah12GjdWG3txSjzkn6zn19NEl7jaR7UlLfjT5CoT7d3Z9CcZO8cV5ezZOXoiaXExOxovUEV/WmpqIEaLhpaLm5AbgAAAAAAAAAACx0mSzBwbV0YKCAYEBA4KAfId0f4+PCIchD8sh5eTpD7Sx37ba2miy+2bO+1NQN2UbKAUaNjUfK2XDO2WdnF3BL3eRLcnKv3d55M96UlO151Gcr1JiY/2foI3vosLCTI0reEUqFhVvea71ta7u7Br0qfpEqxcW7fuU0nuVPT3s0FjrBFu3t1zrFVBfFhobSVNdiL9eamvhiVf/MVWZmmf+UpyKUERG2p89KD8+KisBKEDDJEOnp2TAGCggGBAQOCoGY54H+/maY8Atb8KCgqwtEzPBEeHi0zLrVSrolJfDV4z6W40tLdT7zDl/zoqKsDv4Zuv5dXUQZwFsbwICA21uKhQqKBQWAha3sfq0/P9PsvN9CvCEh/t9I2OBIcHCo2AQM+QTx8f0M33rG32NjGXrBWO7Bd3cvWHWfRXWvrzCfY6WEY0JC56UwUEAwICBwUBou0Rrl5csuDhLhDv397xJtt2Vtv78It0zUGUyBgVXUFDwwFBgYJDw1X0w1JiZ5Xy9xnS/Dw7Jx4Thn4b6+hjii/WqiNTXI/cxPC8yIiMdPOUtcOS4uZUtX+T1Xk5Nq+fINqvJVVVgNgp3jgvz8YZ1HyfRHenqzyazvi6zIyCfv5zJv57q6iDIrfWQrMjJPfZWk15Xm5kKkoPuboMDAO/uYszKYGRmqs9FoJ9GenvZof4Fdf6OjIoFmqohmRETuqn6CqH5UVNaCq+Z2qzs73eaDnhaDCwuVnspFA8qMjMlFKXuVKcfHvHvTbtbTa2sFbjxEUDwoKGxEeYtVeaenLIviPWPivLyBPR0nLB0WFjEndppBdq2tN5o7Ta0729uWTVb6yFZkZJ76TtLoTnR0ptIeIigeFBQ2Itt2P9uSkuR2Ch4YCgwMEh5stJBsSEj8tOQ3a+S4uI83XeclXZ+feOdusmFuvb0Psu8qhu9DQ2kqpvGTpsTENfGo43KoOTna46T3YqQxMcb3N1m9N9PTilmLhv+L8vJ0hjJWsTLV1YNWQ8UNQ4uLTsVZ69xZbm6F67fCr7fa2hjCjI8CjAEBjo9krHlksbEdrNJtI9KcnPFt4DuS4ElJcju0x6u02Ngfx/oVQ/qsrLkVBwn9B/Pz+gklb4Ulz8+gb6/qj6/KyiDqjonzjvT0fYnpII7pR0dnIBgoIBgQEDgo1WTe1W9vC2SIg/uI8PBzg2+xlG9KSvuxcpa4clxcypYkbHAkODhUbPEIrvFXV18Ix1Lmx3NzIVJR8zVRl5dk8yNljSPLy65lfIRZfKGhJYScv8uc6OhXvyFjfCE+Pl1j3Xw33ZaW6nzcf8LcYWEef4aRGoYNDZyRhZQehQ8Pm5SQq9uQ4OBLq0LG+EJ8fLrGxFfixHFxJleq5YOqzMwp5dhzO9iQkONzBQ8MBQYGCQ8BA/UB9/f0AxI2OBIcHCo2o/6fo8LCPP5f4dRfamqL4fkQR/murr4Q0GvS0GlpAmuRqC6RFxe/qFjoKViZmXHoJ2l0Jzo6U2m50E65Jyf30DhIqTjZ2ZFIEzXNE+vr3jWzzlazKyvlzjNVRDMiIndVu9a/u9LSBNZwkElwqak5kImADokHB4eAp/JmpzMzwfK2wVq2LS3swSJmeCI8PFpmkq0qkhUVuK0gYIkgycmpYEnbFUmHh1zb/xpP/6qqsBp4iKB4UFDYiHqOUXqlpSuOj4oGjwMDiYr4E7L4WVlKE4CbEoAJCZKbFzk0FxoaIznadcraZWUQdTFTtTHX14RTxlETxoSE1VG407u40NAD08NeH8OCgtxesMtSsCkp4st3mbR3WlrDmREzPBEeHi0zy0b2y3t7PUb8H0v8qKi3H9Zh2tZtbQxhOk5YOiwsYk4=")),M=y.bytes2Int64Buffer(y.b64Decode("9KX0l6XGxjKXhJfrhPj4b7CZsMeZ7u5ejI2M94329noXDRflDf//6Ny93Le91tYKyLHIp7He3hb8VPw5VJGRbfBQ8MBQYGCQBQMFBAMCAgfgqeCHqc7OLod9h6x9VlbRKxkr1Rnn58ymYqZxYrW1EzHmMZrmTU18tZq1w5rs7FnPRc8FRY+PQLydvD6dHx+jwEDACUCJiUmSh5Lvh/r6aD8VP8UV7+/QJusmf+uyspRAyUAHyY6Ozh0LHe0L+/vmL+wvguxBQW6pZ6l9Z7OzGhz9HL79X19DJeoliupFRWDav9pGvyMj+QL3Aqb3U1NRoZah05bk5EXtW+0tW5ubdl3CXerCdXUoJBwk2Rzh4cXprul6rj091L5qvphqTEzy7lru2FpsbILDQcP8QX5+vQYCBvEC9fXz0U/RHU+Dg1LkXOTQXGhojAf0B6L0UVFWXDRcuTTR0Y0YCBjpCPn54a6Trt+T4uJMlXOVTXOrqz71U/XEU2Jil0E/QVQ/KiprFAwUEAwICBz2UvYxUpWVY69lr4xlRkbp4l7iIV6dnX94KHhgKDAwSPih+G6hNzfPEQ8RFA8KChvEtcRetS8v6xsJGxwJDg4VWjZaSDYkJH62m7Y2mxsbrUc9R6U939+YaiZqgSbNzae7abucaU5O9UzNTP7Nf38zup+6z5/q6lAtGy0kGxISP7meuTqeHR2knHScsHRYWMRyLnJoLjQ0Rnctd2wtNjZBzbLNo7Lc3BEp7ilz7rS0nRb7Frb7W1tNAfYBU/akpKXXTdfsTXZ2oaNho3Vht7cUSc5J+s59fTSNe42ke1JS30I+QqE+3d2fk3GTvHFeXs2il6ImlxMTsQT1BFf1pqaiuGi4aWi5uQEAAAAAAAAAAHQsdJkswcG1oGCggGBAQOAhHyHdH+PjwkPIQ/LIeXk6LO0sd+22tprZvtmzvtTUDcpGygFGjY1HcNlwztlnZxfdS93kS3Jyr3neeTPelJTtZ9RnK9SYmP8j6CN76LCwk95K3hFKhYVbvWu9bWu7uwZ+Kn6RKsXFuzTlNJ7lT097OhY6wRbt7ddUxVQXxYaG0mLXYi/Xmpr4/1X/zFVmZpmnlKcilBERtkrPSg/PiorAMBAwyRDp6dkKBgoIBgQEDpiBmOeB/v5mC/ALW/CgoKvMRMzwRHh4tNW61Uq6JSXwPuM+luNLS3UO8w5f86KirBn+Gbr+XV1EW8BbG8CAgNuFioUKigUFgOyt7H6tPz/T37zfQrwhIf7YSNjgSHBwqAwEDPkE8fH9et96xt9jYxlYwVjuwXd3L591n0V1r68wpWOlhGNCQudQMFBAMCAgcC4aLtEa5eXLEg4S4Q79/e+3bbdlbb+/CNRM1BlMgYFVPBQ8MBQYGCRfNV9MNSYmeXEvcZ0vw8OyOOE4Z+G+vob9ov1qojU1yE/MTwvMiIjHSzlLXDkuLmX5V/k9V5OTag3yDaryVVVYnYKd44L8/GHJR8n0R3p6s++s74usyMgnMucyb+e6uoh9K31kKzIyT6SVpNeV5uZC+6D7m6DAwDuzmLMymBkZqmjRaCfRnp72gX+BXX+joyKqZqqIZkRE7oJ+gqh+VFTW5qvmdqs7O92eg54WgwsLlUXKRQPKjIzJeyl7lSnHx7xu027W02trBUQ8RFA8KChsi3mLVXmnpyw94j1j4ry8gScdJywdFhYxmnaaQXatrTdNO02tO9vblvpW+shWZGSe0k7S6E50dKYiHiIoHhQUNnbbdj/bkpLkHgoeGAoMDBK0bLSQbEhI/DfkN2vkuLiP513nJV2fn3iybrJhbr29DyrvKobvQ0Np8abxk6bExDXjqONyqDk52vek92KkMTHGWTdZvTfT04qGi4b/i/LydFYyVrEy1dWDxUPFDUOLi07rWevcWW5uhcK3wq+32toYj4yPAowBAY6sZKx5ZLGxHW3SbSPSnJzxO+A7kuBJSXLHtMertNjYHxX6FUP6rKy5CQcJ/Qfz8/pvJW+FJc/PoOqv6o+vysogiY6J84709H0g6SCO6UdHZygYKCAYEBA4ZNVk3tVvbwuDiIP7iPDwc7FvsZRvSkr7lnKWuHJcXMpsJGxwJDg4VAjxCK7xV1dfUsdS5sdzcyHzUfM1UZeXZGUjZY0jy8uuhHyEWXyhoSW/nL/LnOjoV2MhY3whPj5dfN18N92Wlup/3H/C3GFhHpGGkRqGDQ2clIWUHoUPD5urkKvbkODgS8ZCxvhCfHy6V8RX4sRxcSblquWDqszMKXPYczvYkJDjDwUPDAUGBgkDAQP1Aff39DYSNjgSHBwq/qP+n6PCwjzhX+HUX2pqixD5EEf5rq6+a9Br0tBpaQKokagukRcXv+hY6ClYmZlxaSdpdCc6OlPQudBOuScn90g4SKk42dmRNRM1zRPr697Os85Wsysr5VUzVUQzIiJ31rvWv7vS0gSQcJBJcKmpOYCJgA6JBweH8qfyZqczM8HBtsFati0t7GYiZngiPDxarZKtKpIVFbhgIGCJIMnJqdtJ2xVJh4dcGv8aT/+qqrCIeIigeFBQ2I56jlF6paUrio+KBo8DA4kT+BOy+FlZSpuAmxKACQmSORc5NBcaGiN12nXK2mVlEFMxU7Ux19eEUcZRE8aEhNXTuNO7uNDQA17DXh/DgoLcy7DLUrApKeKZd5m0d1pawzMRMzwRHh4tRstG9st7ez0f/B9L/Kiot2HWYdrWbW0MTjpOWDosLGI=")),E=y.bytes2Int64Buffer(y.b64Decode("MvSl9JelxsZvl4SX64T4+F6wmbDHme7ueoyNjPeN9vboFw0X5Q3//wrcvdy3vdbWFsixyKex3t5t/FT8OVSRkZDwUPDAUGBgBwUDBQQDAgIu4Kngh6nOztGHfYesfVZWzCsZK9UZ5+cTpmKmcWK1tXwx5jGa5k1NWbWatcOa7OxAz0XPBUWPj6O8nbw+nR8fScBAwAlAiYlokoeS74f6+tA/FT/FFe/vlCbrJn/rsrLOQMlAB8mOjuYdCx3tC/v7bi/sL4LsQUEaqWepfWezs0Mc/Ry+/V9fYCXqJYrqRUX52r/aRr8jI1EC9wKm91NTRaGWodOW5OR27VvtLVubmyhdwl3qwnV1xSQcJNkc4eHU6a7peq49PfK+ar6YakxMgu5a7thabGy9w0HD/EF+fvMGAgbxAvX1UtFP0R1Pg4OM5Fzk0FxoaFYH9Aei9FFRjVw0XLk00dHhGAgY6Qj5+Uyuk67fk+LiPpVzlU1zq6uX9VP1xFNiYmtBP0FUPyoqHBQMFBAMCAhj9lL2MVKVlemvZa+MZUZGf+Je4iFenZ1IeCh4YCgwMM/4ofhuoTc3GxEPERQPCgrrxLXEXrUvLxUbCRscCQ4Oflo2Wkg2JCSttpu2NpsbG5hHPUelPd/fp2omaoEmzc31u2m7nGlOTjNMzUz+zX9/ULqfus+f6uo/LRstJBsSEqS5nrk6nh0dxJx0nLB0WFhGci5yaC40NEF3LXdsLTY2Ec2yzaOy3NydKe4pc+60tE0W+xa2+1tbpQH2AVP2pKSh103X7E12dhSjYaN1Ybe3NEnOSfrOfX3fjXuNpHtSUp9CPkKhPt3dzZNxk7xxXl6xopeiJpcTE6IE9QRX9aamAbhouGloubkAAAAAAAAAALV0LHSZLMHB4KBgoIBgQEDCIR8h3R/j4zpDyEPyyHl5miztLHfttrYN2b7Zs77U1EfKRsoBRo2NF3DZcM7ZZ2ev3Uvd5Etycu153nkz3pSU/2fUZyvUmJiTI+gje+iwsFveSt4RSoWFBr1rvW1ru7u7fip+kSrFxXs05TSe5U9P1zoWOsEW7e3SVMVUF8WGhvhi12Iv15qamf9V/8xVZma2p5SnIpQREcBKz0oPz4qK2TAQMMkQ6ekOCgYKCAYEBGaYgZjngf7+qwvwC1vwoKC0zETM8ER4ePDVutVKuiUldT7jPpbjS0usDvMOX/OiokQZ/hm6/l1d21vAWxvAgICAhYqFCooFBdPsrex+rT8//t+830K8ISGo2EjY4EhwcP0MBAz5BPHxGXrfesbfY2MvWMFY7sF3dzCfdZ9Fda+v56VjpYRjQkJwUDBQQDAgIMsuGi7RGuXl7xIOEuEO/f0It223ZW2/v1XUTNQZTIGBJDwUPDAUGBh5XzVfTDUmJrJxL3GdL8PDhjjhOGfhvr7I/aL9aqI1NcdPzE8LzIiIZUs5S1w5Li5q+Vf5PVeTk1gN8g2q8lVVYZ2CneOC/PyzyUfJ9Ed6eifvrO+LrMjIiDLnMm/nurpPfSt9ZCsyMkKklaTXlebmO/ug+5ugwMCqs5izMpgZGfZo0Wgn0Z6eIoF/gV1/o6PuqmaqiGZERNaCfoKoflRU3ear5narOzuVnoOeFoMLC8lFykUDyoyMvHspe5Upx8cFbtNu1tNra2xEPERQPCgoLIt5i1V5p6eBPeI9Y+K8vDEnHScsHRYWN5p2mkF2ra2WTTtNrTvb2576VvrIVmRkptJO0uhOdHQ2Ih4iKB4UFOR223Y/25KSEh4KHhgKDAz8tGy0kGxISI835Ddr5Li4eOdd5yVdn58Psm6yYW69vWkq7yqG70NDNfGm8ZOmxMTa46jjcqg5Ocb3pPdipDExilk3Wb0309N0houG/4vy8oNWMlaxMtXVTsVDxQ1Di4uF61nr3FlubhjCt8Kvt9rajo+MjwKMAQEdrGSseWSxsfFt0m0j0pyccjvgO5LgSUkfx7THq7TY2LkV+hVD+qys+gkHCf0H8/OgbyVvhSXPzyDqr+qPr8rKfYmOifOO9PRnIOkgjulHRzgoGCggGBAQC2TVZN7Vb29zg4iD+4jw8Puxb7GUb0pKypZylrhyXFxUbCRscCQ4OF8I8Qiu8VdXIVLHUubHc3Nk81HzNVGXl65lI2WNI8vLJYR8hFl8oaFXv5y/y5zo6F1jIWN8IT4+6nzdfDfdlpYef9x/wtxhYZyRhpEahg0Nm5SFlB6FDw9Lq5Cr25Dg4LrGQsb4Qnx8JlfEV+LEcXEp5arlg6rMzONz2HM72JCQCQ8FDwwFBgb0AwED9QH39yo2EjY4EhwcPP6j/p+jwsKL4V/h1F9qar4Q+RBH+a6uAmvQa9LQaWm/qJGoLpEXF3HoWOgpWJmZU2knaXQnOjr30LnQTrknJ5FIOEipONnZ3jUTNc0T6+vlzrPOVrMrK3dVM1VEMyIiBNa71r+70tI5kHCQSXCpqYeAiYAOiQcHwfKn8manMzPswbbBWrYtLVpmImZ4Ijw8uK2SrSqSFRWpYCBgiSDJyVzbSdsVSYeHsBr/Gk//qqrYiHiIoHhQUCuOeo5ReqWliYqPigaPAwNKE/gTsvhZWZKbgJsSgAkJIzkXOTQXGhoQddp1ytplZYRTMVO1MdfX1VHGURPGhIQD07jTu7jQ0Nxew14fw4KC4suwy1KwKSnDmXeZtHdaWi0zETM8ER4ePUbLRvbLe3u3H/wfS/yoqAxh1mHa1m1tYk46Tlg6LCw=")),d=function(L,N){if(L===7)return N.lo&255;var j=(7-L)*8;if(j>=32)return N.hi>>>j-32&255;var K=32-j,$=this.hi<<K>>>K;return(N.lo>>>j|$<<K)&255},A=[S.u(0,0),S.u(0,16),S.u(0,32),S.u(0,48),S.u(0,64),S.u(0,80),S.u(0,96),S.u(0,112),S.u(0,128),S.u(0,144),S.u(0,160),S.u(0,176),S.u(0,192),S.u(0,208),S.u(0,224),S.u(0,240)],v=[S.u(4294967295,4294967295),S.u(4294967295,4294967279),S.u(4294967295,4294967263),S.u(4294967295,4294967247),S.u(4294967295,4294967231),S.u(4294967295,4294967215),S.u(4294967295,4294967199),S.u(4294967295,4294967183),S.u(4294967295,4294967167),S.u(4294967295,4294967151),S.u(4294967295,4294967135),S.u(4294967295,4294967119),S.u(4294967295,4294967103),S.u(4294967295,4294967087),S.u(4294967295,4294967071),S.u(4294967295,4294967055)],b=[S.u(0,0),S.u(0,1),S.u(0,2),S.u(0,3),S.u(0,4),S.u(0,5),S.u(0,6),S.u(0,7),S.u(0,8),S.u(0,9),S.u(0,10),S.u(0,11),S.u(0,12),S.u(0,13)],k=function(L,N){for(var j=new Array(16),K=new Array(16),$=0;$<16;$++)K[$]=L[$],j[$]=K[$].xor(N[$]);for(var Q=new Array(16),Y=0;Y<14;Y++){for(var ee=0;ee<16;ee++)j[ee].setxor64(A[ee].plus(b[Y]).setShiftLeft(56));for(var $=0;$<16;$++)Q[$]=S.xor64(p[d(0,j[$])],I[d(1,j[$+1&15])],o[d(2,j[$+2&15])],m[d(3,j[$+3&15])],l[d(4,j[$+4&15])],g[d(5,j[$+5&15])],M[d(6,j[$+6&15])],E[d(7,j[$+11&15])]);var u=j;j=Q,Q=u}for(var Y=0;Y<14;Y++){for(var ee=0;ee<16;ee++)K[ee].setxor64(b[Y],v[ee]);for(var $=0;$<16;$++)Q[$]=S.xor64(p[d(0,K[$+1&15])],I[d(1,K[$+3&15])],o[d(2,K[$+5&15])],m[d(3,K[$+11&15])],l[d(4,K[$+0&15])],g[d(5,K[$+2&15])],M[d(6,K[$+4&15])],E[d(7,K[$+6&15])]);var u=K;K=Q,Q=u}for(var $=0;$<16;$++)N[$].setxor64(j[$],K[$])},B=function(L){var N=new Array(16);S.bufferInsert64(N,0,L,16);for(var j=new Array(16),K=0;K<14;K++){for(var $=0;$<16;$++)N[$].setxor64(A[$].plus(b[K]).setShiftLeft(56));for(var Q=0;Q<16;Q++)j[Q]=S.xor64(p[d(0,N[Q])],I[d(1,N[Q+1&15])],o[d(2,N[Q+2&15])],m[d(3,N[Q+3&15])],l[d(4,N[Q+4&15])],g[d(5,N[Q+5&15])],M[d(6,N[Q+6&15])],E[d(7,N[Q+11&15])]);var Y=N;N=j,j=Y}for(var Q=0;Q<16;Q++)L[Q].setxor64(N[Q])},U=function(L,N,j){var K,$,Q=new Array(16);if(K=L.buffer,$=L.ptr,j<L.buffer.length-$){S.bufferInsert(K,$,N,N.length),$+=N.length,L.ptr=$;return}for(S.bufferInsert(Q,0,L.state,16);j>0;){var Y=L.buffer.length-$;if(Y>j&&(Y=j),S.bufferInsert(K,$,N,Y),$+=Y,N=N.slice(Y),j-=Y,$===L.buffer.length){var ee=y.bytes2Int64Buffer(K);k(ee,Q),L.count.addOne(),$=0}}L.state=Q,L.ptr=$},C=function(L){var N=L.buffer,j=L.ptr,K=new Array(136),$=N.length,Q,Y;K[0]=128,j<120?(Q=128-j,Y=L.count.plus(S.u(0,1))):(Q=256-j,Y=L.count.plus(S.u(0,2))),S.bufferSet(K,1,0,Q-9),y.bufferEncode64(K,Q-8,Y),U(L,K,Q),B(L.state);for(var ee=new Array(16),u=0,e=8;u<8;u++,e++)ee[2*u]=L.state[e].hi,ee[2*u+1]=L.state[e].lo;return ee};fe.exports=function(L,N,j){var K;N===1?K=L:N===2?K=y.int32Buffer2Bytes(L):K=y.string2bytes(L);var $={};$.state=new Array(16);for(var Q=0;Q<15;Q++)$.state[Q]=new S.u64(0,0);$.state[15]=new S.u64(0,512),$.ptr=0,$.count=new S.u64(0,0),$.buffer=new Array(128),U($,K,K.length);var Y=C($,0,0),ee;return j===2?ee=Y:j===1?ee=y.int32Buffer2Bytes(Y):ee=y.int32ArrayToHexString(Y),ee}},5174:(fe,x,T)=>{"use strict";var S=T(7749);fe.exports.int8ArrayToHexString=function(I){for(var o="",m=0;m<I.length;m++)I[m]<16?o+="0"+I[m].toString(16):o+=I[m].toString(16);return o},fe.exports.int32ArrayToHexString=function(I){for(var o="",m=I.length,l=0;l<m;l++){var g=I[l];g<0&&(g=4294967295+I[l]+1);for(var M=g.toString(16),E=8;M.length<E;)M="0"+M;o+=M}return o},fe.exports.hex2string=function(I){for(var o=[],m=I.length,l=0;l<m;l+=2)o.push(String.fromCharCode(parseInt(I.substring(l,l+2),16)));return o.join("")},fe.exports.hex2bytes=function(I){for(var o=[],m=I.length,l=0;l<m;l+=2)o.push(parseInt(I.substring(l,l+2),16));return o},fe.exports.string2bytes=function(p){for(var I=p.length,o=new Array(I),m=0;m<I;)o[m]=p.charCodeAt(m),m++;return o},fe.exports.bytes2Int32Buffer=function(p){if(!p)return[];for(var I=p.length?(p.length-1>>>2)+1:0,o=new Array(I),m=0;m<I;)o[m]=p[m*4]<<24|p[m*4+1]<<16|p[m*4+2]<<8|p[m*4+3],m++;return o},fe.exports.bytes2Int64Buffer=function(p){if(!p)return[];for(var I=p.length?(p.length-1>>>3)+1:0,o=new Array(I),m=0;m<I;)o[m]=new S.u64(p[m*8]<<24|p[m*8+1]<<16|p[m*8+2]<<8|p[m*8+3],p[m*8+4]<<24|p[m*8+5]<<16|p[m*8+6]<<8|p[m*8+7]),m++;return o},fe.exports.bytes2Int64BufferLeAligned=function(p){if(!p)return[];for(var I=p.length?(p.length-1>>>3)+1:0,o=new Array(I),m=0;m<I;)o[m]=new S.u64(p[m*8+7]<<24|p[m*8+6]<<16|p[m*8+5]<<8|p[m*8+4],p[m*8+3]<<24|p[m*8+2]<<16|p[m*8+1]<<8|p[m*8]),m++;return o},fe.exports.bufferEncode64leAligned=function(p,I,o){p[I+7]=o.hi>>>24,p[I+6]=o.hi>>>16&255,p[I+5]=o.hi>>>8&255,p[I+4]=o.hi&255,p[I+3]=o.lo>>>24,p[I+2]=o.lo>>>16&255,p[I+1]=o.lo>>>8&255,p[I+0]=o.lo&255},fe.exports.bufferEncode64=function(p,I,o){p[I]=o.hi>>>24,p[I+1]=o.hi>>>16&255,p[I+2]=o.hi>>>8&255,p[I+3]=o.hi&255,p[I+4]=o.lo>>>24,p[I+5]=o.lo>>>16&255,p[I+6]=o.lo>>>8&255,p[I+7]=o.lo&255},fe.exports.int32Buffer2Bytes=function(p){for(var I=new Array(p.length),o=p.length,m=0;m<o;)I[m*4]=(p[m]&4278190080)>>>24,I[m*4+1]=(p[m]&16711680)>>>16,I[m*4+2]=(p[m]&65280)>>>8,I[m*4+3]=p[m]&255,m++;return I},fe.exports.string2Int32Buffer=function(p){return this.bytes2Int32Buffer(this.string2bytes(p))};var y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";fe.exports.b64Encode=function(p){for(var I="",o,m,l,g,M,E,d,A=0;A<p.length;)o=p[A++],m=p[A++],l=p[A++],g=o>>2,M=(o&3)<<4|m>>4,E=(m&15)<<2|l>>6,d=l&63,isNaN(m)?E=d=64:isNaN(l)&&(d=64),I+=y.charAt(g)+y.charAt(M)+y.charAt(E)+y.charAt(d);return I},fe.exports.b64Decode=function(p){var I=[],o,m,l,g,M,E,d,A=0;for(p=p.replace(/[^A-Za-z0-9\+\/\=]/g,"");A<p.length;)g=y.indexOf(p.charAt(A++)),M=y.indexOf(p.charAt(A++)),E=y.indexOf(p.charAt(A++)),d=y.indexOf(p.charAt(A++)),o=g<<2|M>>4,m=(M&15)<<4|E>>2,l=(E&3)<<6|d,I.push(o),E!=64&&I.push(m),d!=64&&I.push(l);return I}},7749:fe=>{"use strict";function x(y,p){this.hi=y>>>0,this.lo=p>>>0}x.prototype.set=function(y){this.lo=y.lo,this.hi=y.hi},x.prototype.add=function(y){var p,I,o,m;return p=(this.lo&65535)+(y.lo&65535),I=(this.lo>>>16)+(y.lo>>>16)+(p>>>16),o=(this.hi&65535)+(y.hi&65535)+(I>>>16),m=(this.hi>>>16)+(y.hi>>>16)+(o>>>16),this.lo=I<<16|p&65535,this.hi=m<<16|o&65535,this},x.prototype.addOne=function(){this.lo===-1||this.lo===4294967295?(this.lo=0,this.hi++):this.lo++},x.prototype.plus=function(y){var p=new x(0,0),I,o,m,l;return I=(this.lo&65535)+(y.lo&65535),o=(this.lo>>>16)+(y.lo>>>16)+(I>>>16),m=(this.hi&65535)+(y.hi&65535)+(o>>>16),l=(this.hi>>>16)+(y.hi>>>16)+(m>>>16),p.lo=o<<16|I&65535,p.hi=l<<16|m&65535,p},x.prototype.not=function(){return new x(~this.hi,~this.lo)},x.prototype.one=function(){return new x(0,1)},x.prototype.zero=function(){return new x(0,0)},x.prototype.neg=function(){return this.not().plus(this.one())},x.prototype.minus=function(y){return this.plus(y.neg())},x.prototype.isZero=function(){return this.lo===0&&this.hi===0};function T(y){return(y&&y.__isLong__)===!0}function S(y){if(isNaN(y)||!isFinite(y))return this.zero();var p=1;return new x(y%p|0,y/p|0)}x.prototype.multiply=function(y){if(this.isZero())return this.zero();if(T(y)||(y=S(y)),y.isZero())return this.zero();var p=this.hi>>>16,I=this.hi&65535,o=this.lo>>>16,m=this.lo&65535,l=y.hi>>>16,g=y.hi&65535,M=y.lo>>>16,E=y.lo&65535,d=0,A=0,v=0,b=0;return b+=m*E,v+=b>>>16,b&=65535,v+=o*E,A+=v>>>16,v&=65535,v+=m*M,A+=v>>>16,v&=65535,A+=I*E,d+=A>>>16,A&=65535,A+=o*M,d+=A>>>16,A&=65535,A+=m*g,d+=A>>>16,A&=65535,d+=p*E+I*M+o*g+m*l,d&=65535,new x(d<<16|A,v<<16|b)},x.prototype.shiftLeft=function(y){y=y%64;var p=new x(0,0);if(y===0)return this.clone();if(y>31)p.lo=0,p.hi=this.lo<<y-32;else{var I=this.lo>>>32-y;p.lo=this.lo<<y,p.hi=this.hi<<y|I}return p},x.prototype.setShiftLeft=function(y){if(y===0)return this;if(y>63&&(y=y%64),y>31)this.hi=this.lo<<y-32,this.lo=0;else{var p=this.lo>>>32-y;this.lo<<=y,this.hi=this.hi<<y|p}return this},x.prototype.shiftRight=function(y){y=y%64;var p=new x(0,0);if(y===0)return this.clone();if(y>=32)p.hi=0,p.lo=this.hi>>>y-32;else{var I=32-y,o=this.hi<<I>>>I;p.hi=this.hi>>>y,p.lo=this.lo>>>y|o<<I}return p},x.prototype.rotateLeft=function(y){if(y>32)return this.rotateRight(64-y);var p=new x(0,0);return y===0?(p.lo=this.lo>>>0,p.hi=this.hi>>>0):y===32?(p.lo=this.hi,p.hi=this.lo):(p.lo=this.lo<<y|this.hi>>>32-y,p.hi=this.hi<<y|this.lo>>>32-y),p},x.prototype.setRotateLeft=function(y){if(y>32)return this.setRotateRight(64-y);var p;return y===0?this:(y===32?(p=this.lo,this.lo=this.hi,this.hi=p):(p=this.hi<<y|this.lo>>>32-y,this.lo=this.lo<<y|this.hi>>>32-y,this.hi=p),this)},x.prototype.rotateRight=function(y){if(y>32)return this.rotateLeft(64-y);var p=new x(0,0);return y===0?(p.lo=this.lo>>>0,p.hi=this.hi>>>0):y===32?(p.lo=this.hi,p.hi=this.lo):(p.lo=this.hi<<32-y|this.lo>>>y,p.hi=this.lo<<32-y|this.hi>>>y),p},x.prototype.setFlip=function(){var y;return y=this.lo,this.lo=this.hi,this.hi=y,this},x.prototype.setRotateRight=function(y){if(y>32)return this.setRotateLeft(64-y);if(y===0)return this;if(y===32){var p;p=this.lo,this.lo=this.hi,this.hi=p}else p=this.lo<<32-y|this.hi>>>y,this.lo=this.hi<<32-y|this.lo>>>y,this.hi=p;return this},x.prototype.xor=function(y){var p=new x(0,0);return p.hi=this.hi^y.hi,p.lo=this.lo^y.lo,p},x.prototype.setxorOne=function(y){return this.hi^=y.hi,this.lo^=y.lo,this},x.prototype.and=function(y){var p=new x(0,0);return p.hi=this.hi&y.hi,p.lo=this.lo&y.lo,p},x.prototype.clone=function(){return new x(this.hi,this.lo)},x.prototype.setxor64=function(){for(var y=arguments,p=y.length;p--;)this.hi^=y[p].hi,this.lo^=y[p].lo;return this},fe.exports.u64=x,fe.exports.u=function(y,p){return new x(y,p)},fe.exports.xor64=function(){var y=arguments,p=y[0].hi,I=y[0].lo,o=y.length-1;do p^=y[o].hi,I^=y[o].lo,o--;while(o>0);return new this.u64(p,I)},fe.exports.clone64Array=function(y){for(var p=0,I=y.length,o=new Array(I);p<I;)o[p]=y[p],p++;return o},fe.exports.t32=function(y){return y&4294967295},fe.exports.rotl32=function(y,p){return(y<<p|y>>>32-p)&4294967295},fe.exports.rotr32=function(y,p){return this.rotl32(y,32-p)},fe.exports.swap32=function(y){return(y&255)<<24|(y&65280)<<8|y>>>8&65280|y>>>24&255},fe.exports.swap32Array=function(y){for(var p=0,I=y.length,o=new Array(p);p<I;)o[p]=this.swap32(y[p]),p++;return o},fe.exports.xnd64=function(y,p,I){return new this.u64(y.hi^~p.hi&I.hi,y.lo^~p.lo&I.lo)},fe.exports.bufferInsert=function(y,p,I,o,m){m=m|0;for(var l=0;l<o;)y[l+p]=I[l+m],l++},fe.exports.bufferInsert64=function(y,p,I,o){for(var m=0;m<o;)y[m+p]=I[m].clone(),m++},fe.exports.bufferInsertBackwards=function(y,p,I,o){for(var m=0;m<o;)y[m+p]=I[o-1-m],m++},fe.exports.bufferSet=function(y,p,I,o){for(var m=0;m<o;)y[m+p]=I,m++},fe.exports.bufferXORInsert=function(y,p,I,o,m){for(var l=0;l<m;)y[l+p]^=I[l+o],l++},fe.exports.xORTable=function(y,p,I,o){for(var m=0;m<o;)y[m]=p[m]^I[m],m++}},4729:(fe,x,T)=>{"use strict";var S=T(2861).Buffer,y=T(1603).Transform,p=T(6698);function I(m,l){if(!S.isBuffer(m)&&typeof m!="string")throw new TypeError(l+" must be a string or a buffer")}function o(m){y.call(this),this._block=S.allocUnsafe(m),this._blockSize=m,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}p(o,y),o.prototype._transform=function(m,l,g){var M=null;try{this.update(m,l)}catch(E){M=E}g(M)},o.prototype._flush=function(m){var l=null;try{this.push(this.digest())}catch(g){l=g}m(l)},o.prototype.update=function(m,l){if(I(m,"Data"),this._finalized)throw new Error("Digest already called");S.isBuffer(m)||(m=S.from(m,l));for(var g=this._block,M=0;this._blockOffset+m.length-M>=this._blockSize;){for(var E=this._blockOffset;E<this._blockSize;)g[E++]=m[M++];this._update(),this._blockOffset=0}for(;M<m.length;)g[this._blockOffset++]=m[M++];for(var d=0,A=m.length*8;A>0;++d)this._length[d]+=A,A=this._length[d]/4294967296|0,A>0&&(this._length[d]-=4294967296*A);return this},o.prototype._update=function(){throw new Error("_update is not implemented")},o.prototype.digest=function(m){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var l=this._digest();m!==void 0&&(l=l.toString(m)),this._block.fill(0),this._blockOffset=0;for(var g=0;g<4;++g)this._length[g]=0;return l},o.prototype._digest=function(){throw new Error("_digest is not implemented")},fe.exports=o},2260:fe=>{"use strict";function x(m,l){m.prototype=Object.create(l.prototype),m.prototype.constructor=m,m.__proto__=l}var T={};function S(m,l,g){g||(g=Error);function M(d,A,v){return typeof l=="string"?l:l(d,A,v)}var E=function(d){x(A,d);function A(v,b,k){return d.call(this,M(v,b,k))||this}return A}(g);E.prototype.name=g.name,E.prototype.code=m,T[m]=E}function y(m,l){if(Array.isArray(m)){var g=m.length;return m=m.map(function(M){return String(M)}),g>2?"one of ".concat(l," ").concat(m.slice(0,g-1).join(", "),", or ")+m[g-1]:g===2?"one of ".concat(l," ").concat(m[0]," or ").concat(m[1]):"of ".concat(l," ").concat(m[0])}else return"of ".concat(l," ").concat(String(m))}function p(m,l,g){return m.substr(!g||g<0?0:+g,l.length)===l}function I(m,l,g){return(g===void 0||g>m.length)&&(g=m.length),m.substring(g-l.length,g)===l}function o(m,l,g){return typeof g!="number"&&(g=0),g+l.length>m.length?!1:m.indexOf(l,g)!==-1}S("ERR_INVALID_OPT_VALUE",function(m,l){return'The value "'+l+'" is invalid for option "'+m+'"'},TypeError),S("ERR_INVALID_ARG_TYPE",function(m,l,g){var M;typeof l=="string"&&p(l,"not ")?(M="must not be",l=l.replace(/^not /,"")):M="must be";var E;if(I(m," argument"))E="The ".concat(m," ").concat(M," ").concat(y(l,"type"));else{var d=o(m,".")?"property":"argument";E='The "'.concat(m,'" ').concat(d," ").concat(M," ").concat(y(l,"type"))}return E+=". Received type ".concat(typeof g),E},TypeError),S("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),S("ERR_METHOD_NOT_IMPLEMENTED",function(m){return"The "+m+" method is not implemented"}),S("ERR_STREAM_PREMATURE_CLOSE","Premature close"),S("ERR_STREAM_DESTROYED",function(m){return"Cannot call "+m+" after a stream was destroyed"}),S("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),S("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),S("ERR_STREAM_WRITE_AFTER_END","write after end"),S("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),S("ERR_UNKNOWN_ENCODING",function(m){return"Unknown encoding: "+m},TypeError),S("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),fe.exports.F=T},2818:(fe,x,T)=>{"use strict";var S=T(5606),y=Object.keys||function(d){var A=[];for(var v in d)A.push(v);return A};fe.exports=g;var p=T(6736),I=T(2192);T(6698)(g,p);for(var o=y(I.prototype),m=0;m<o.length;m++){var l=o[m];g.prototype[l]||(g.prototype[l]=I.prototype[l])}function g(d){if(!(this instanceof g))return new g(d);p.call(this,d),I.call(this,d),this.allowHalfOpen=!0,d&&(d.readable===!1&&(this.readable=!1),d.writable===!1&&(this.writable=!1),d.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",M)))}Object.defineProperty(g.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(g.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(g.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function M(){this._writableState.ended||S.nextTick(E,this)}function E(d){d.end()}Object.defineProperty(g.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(A){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=A,this._writableState.destroyed=A)}})},5860:(fe,x,T)=>{"use strict";fe.exports=y;var S=T(3054);T(6698)(y,S);function y(p){if(!(this instanceof y))return new y(p);S.call(this,p)}y.prototype._transform=function(p,I,o){o(null,p)}},6736:(fe,x,T)=>{"use strict";var S=T(5606);fe.exports=e;var y;e.ReadableState=u;var p=T(7007).EventEmitter,I=function(J,pe){return J.listeners(pe).length},o=T(1181),m=T(8287).Buffer,l=T.g.Uint8Array||function(){};function g(ie){return m.from(ie)}function M(ie){return m.isBuffer(ie)||ie instanceof l}var E=T(2382),d;E&&E.debuglog?d=E.debuglog("stream"):d=function(){};var A=T(2389),v=T(1468),b=T(8775),k=b.getHighWaterMark,B=T(2260).F,U=B.ERR_INVALID_ARG_TYPE,C=B.ERR_STREAM_PUSH_AFTER_EOF,L=B.ERR_METHOD_NOT_IMPLEMENTED,N=B.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,j,K,$;T(6698)(e,o);var Q=v.errorOrDestroy,Y=["error","close","destroy","pause","resume"];function ee(ie,J,pe){if(typeof ie.prependListener=="function")return ie.prependListener(J,pe);!ie._events||!ie._events[J]?ie.on(J,pe):Array.isArray(ie._events[J])?ie._events[J].unshift(pe):ie._events[J]=[pe,ie._events[J]]}function u(ie,J,pe){y=y||T(2818),ie=ie||{},typeof pe!="boolean"&&(pe=J instanceof y),this.objectMode=!!ie.objectMode,pe&&(this.objectMode=this.objectMode||!!ie.readableObjectMode),this.highWaterMark=k(this,ie,"readableHighWaterMark",pe),this.buffer=new A,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=ie.emitClose!==!1,this.autoDestroy=!!ie.autoDestroy,this.destroyed=!1,this.defaultEncoding=ie.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,ie.encoding&&(j||(j=T(3141).I),this.decoder=new j(ie.encoding),this.encoding=ie.encoding)}function e(ie){if(y=y||T(2818),!(this instanceof e))return new e(ie);var J=this instanceof y;this._readableState=new u(ie,this,J),this.readable=!0,ie&&(typeof ie.read=="function"&&(this._read=ie.read),typeof ie.destroy=="function"&&(this._destroy=ie.destroy)),o.call(this)}Object.defineProperty(e.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(J){this._readableState&&(this._readableState.destroyed=J)}}),e.prototype.destroy=v.destroy,e.prototype._undestroy=v.undestroy,e.prototype._destroy=function(ie,J){J(ie)},e.prototype.push=function(ie,J){var pe=this._readableState,Ge;return pe.objectMode?Ge=!0:typeof ie=="string"&&(J=J||pe.defaultEncoding,J!==pe.encoding&&(ie=m.from(ie,J),J=""),Ge=!0),r(this,ie,J,!1,Ge)},e.prototype.unshift=function(ie){return r(this,ie,null,!0,!1)};function r(ie,J,pe,Ge,ce){d("readableAddChunk",J);var te=ie._readableState;if(J===null)te.reading=!1,s(ie,te);else{var le;if(ce||(le=i(te,J)),le)Q(ie,le);else if(te.objectMode||J&&J.length>0)if(typeof J!="string"&&!te.objectMode&&Object.getPrototypeOf(J)!==m.prototype&&(J=g(J)),Ge)te.endEmitted?Q(ie,new N):n(ie,te,J,!0);else if(te.ended)Q(ie,new C);else{if(te.destroyed)return!1;te.reading=!1,te.decoder&&!pe?(J=te.decoder.write(J),te.objectMode||J.length!==0?n(ie,te,J,!1):w(ie,te)):n(ie,te,J,!1)}else Ge||(te.reading=!1,w(ie,te))}return!te.ended&&(te.length<te.highWaterMark||te.length===0)}function n(ie,J,pe,Ge){J.flowing&&J.length===0&&!J.sync?(J.awaitDrain=0,ie.emit("data",pe)):(J.length+=J.objectMode?1:pe.length,Ge?J.buffer.unshift(pe):J.buffer.push(pe),J.needReadable&&t(ie)),w(ie,J)}function i(ie,J){var pe;return!M(J)&&typeof J!="string"&&J!==void 0&&!ie.objectMode&&(pe=new U("chunk",["string","Buffer","Uint8Array"],J)),pe}e.prototype.isPaused=function(){return this._readableState.flowing===!1},e.prototype.setEncoding=function(ie){j||(j=T(3141).I);var J=new j(ie);this._readableState.decoder=J,this._readableState.encoding=this._readableState.decoder.encoding;for(var pe=this._readableState.buffer.head,Ge="";pe!==null;)Ge+=J.write(pe.data),pe=pe.next;return this._readableState.buffer.clear(),Ge!==""&&this._readableState.buffer.push(Ge),this._readableState.length=Ge.length,this};var f=1073741824;function c(ie){return ie>=f?ie=f:(ie--,ie|=ie>>>1,ie|=ie>>>2,ie|=ie>>>4,ie|=ie>>>8,ie|=ie>>>16,ie++),ie}function h(ie,J){return ie<=0||J.length===0&&J.ended?0:J.objectMode?1:ie!==ie?J.flowing&&J.length?J.buffer.head.data.length:J.length:(ie>J.highWaterMark&&(J.highWaterMark=c(ie)),ie<=J.length?ie:J.ended?J.length:(J.needReadable=!0,0))}e.prototype.read=function(ie){d("read",ie),ie=parseInt(ie,10);var J=this._readableState,pe=ie;if(ie!==0&&(J.emittedReadable=!1),ie===0&&J.needReadable&&((J.highWaterMark!==0?J.length>=J.highWaterMark:J.length>0)||J.ended))return d("read: emitReadable",J.length,J.ended),J.length===0&&J.ended?oe(this):t(this),null;if(ie=h(ie,J),ie===0&&J.ended)return J.length===0&&oe(this),null;var Ge=J.needReadable;d("need readable",Ge),(J.length===0||J.length-ie<J.highWaterMark)&&(Ge=!0,d("length less than watermark",Ge)),J.ended||J.reading?(Ge=!1,d("reading or ended",Ge)):Ge&&(d("do read"),J.reading=!0,J.sync=!0,J.length===0&&(J.needReadable=!0),this._read(J.highWaterMark),J.sync=!1,J.reading||(ie=h(pe,J)));var ce;return ie>0?ce=H(ie,J):ce=null,ce===null?(J.needReadable=J.length<=J.highWaterMark,ie=0):(J.length-=ie,J.awaitDrain=0),J.length===0&&(J.ended||(J.needReadable=!0),pe!==ie&&J.ended&&oe(this)),ce!==null&&this.emit("data",ce),ce};function s(ie,J){if(d("onEofChunk"),!J.ended){if(J.decoder){var pe=J.decoder.end();pe&&pe.length&&(J.buffer.push(pe),J.length+=J.objectMode?1:pe.length)}J.ended=!0,J.sync?t(ie):(J.needReadable=!1,J.emittedReadable||(J.emittedReadable=!0,a(ie)))}}function t(ie){var J=ie._readableState;d("emitReadable",J.needReadable,J.emittedReadable),J.needReadable=!1,J.emittedReadable||(d("emitReadable",J.flowing),J.emittedReadable=!0,S.nextTick(a,ie))}function a(ie){var J=ie._readableState;d("emitReadable_",J.destroyed,J.length,J.ended),!J.destroyed&&(J.length||J.ended)&&(ie.emit("readable"),J.emittedReadable=!1),J.needReadable=!J.flowing&&!J.ended&&J.length<=J.highWaterMark,G(ie)}function w(ie,J){J.readingMore||(J.readingMore=!0,S.nextTick(D,ie,J))}function D(ie,J){for(;!J.reading&&!J.ended&&(J.length<J.highWaterMark||J.flowing&&J.length===0);){var pe=J.length;if(d("maybeReadMore read 0"),ie.read(0),pe===J.length)break}J.readingMore=!1}e.prototype._read=function(ie){Q(this,new L("_read()"))},e.prototype.pipe=function(ie,J){var pe=this,Ge=this._readableState;switch(Ge.pipesCount){case 0:Ge.pipes=ie;break;case 1:Ge.pipes=[Ge.pipes,ie];break;default:Ge.pipes.push(ie);break}Ge.pipesCount+=1,d("pipe count=%d opts=%j",Ge.pipesCount,J);var ce=(!J||J.end!==!1)&&ie!==S.stdout&&ie!==S.stderr,te=ce?ge:je;Ge.endEmitted?S.nextTick(te):pe.once("end",te),ie.on("unpipe",le);function le(Ie,Ce){d("onunpipe"),Ie===pe&&Ce&&Ce.hasUnpiped===!1&&(Ce.hasUnpiped=!0,Le())}function ge(){d("onend"),ie.end()}var Pe=Z(pe);ie.on("drain",Pe);var lt=!1;function Le(){d("cleanup"),ie.removeListener("close",ae),ie.removeListener("finish",he),ie.removeListener("drain",Pe),ie.removeListener("error",kt),ie.removeListener("unpipe",le),pe.removeListener("end",ge),pe.removeListener("end",je),pe.removeListener("data",ze),lt=!0,Ge.awaitDrain&&(!ie._writableState||ie._writableState.needDrain)&&Pe()}pe.on("data",ze);function ze(Ie){d("ondata");var Ce=ie.write(Ie);d("dest.write",Ce),Ce===!1&&((Ge.pipesCount===1&&Ge.pipes===ie||Ge.pipesCount>1&&be(Ge.pipes,ie)!==-1)&&!lt&&(d("false write response, pause",Ge.awaitDrain),Ge.awaitDrain++),pe.pause())}function kt(Ie){d("onerror",Ie),je(),ie.removeListener("error",kt),I(ie,"error")===0&&Q(ie,Ie)}ee(ie,"error",kt);function ae(){ie.removeListener("finish",he),je()}ie.once("close",ae);function he(){d("onfinish"),ie.removeListener("close",ae),je()}ie.once("finish",he);function je(){d("unpipe"),pe.unpipe(ie)}return ie.emit("pipe",pe),Ge.flowing||(d("pipe resume"),pe.resume()),ie};function Z(ie){return function(){var pe=ie._readableState;d("pipeOnDrain",pe.awaitDrain),pe.awaitDrain&&pe.awaitDrain--,pe.awaitDrain===0&&I(ie,"data")&&(pe.flowing=!0,G(ie))}}e.prototype.unpipe=function(ie){var J=this._readableState,pe={hasUnpiped:!1};if(J.pipesCount===0)return this;if(J.pipesCount===1)return ie&&ie!==J.pipes?this:(ie||(ie=J.pipes),J.pipes=null,J.pipesCount=0,J.flowing=!1,ie&&ie.emit("unpipe",this,pe),this);if(!ie){var Ge=J.pipes,ce=J.pipesCount;J.pipes=null,J.pipesCount=0,J.flowing=!1;for(var te=0;te<ce;te++)Ge[te].emit("unpipe",this,{hasUnpiped:!1});return this}var le=be(J.pipes,ie);return le===-1?this:(J.pipes.splice(le,1),J.pipesCount-=1,J.pipesCount===1&&(J.pipes=J.pipes[0]),ie.emit("unpipe",this,pe),this)},e.prototype.on=function(ie,J){var pe=o.prototype.on.call(this,ie,J),Ge=this._readableState;return ie==="data"?(Ge.readableListening=this.listenerCount("readable")>0,Ge.flowing!==!1&&this.resume()):ie==="readable"&&!Ge.endEmitted&&!Ge.readableListening&&(Ge.readableListening=Ge.needReadable=!0,Ge.flowing=!1,Ge.emittedReadable=!1,d("on readable",Ge.length,Ge.reading),Ge.length?t(this):Ge.reading||S.nextTick(V,this)),pe},e.prototype.addListener=e.prototype.on,e.prototype.removeListener=function(ie,J){var pe=o.prototype.removeListener.call(this,ie,J);return ie==="readable"&&S.nextTick(F,this),pe},e.prototype.removeAllListeners=function(ie){var J=o.prototype.removeAllListeners.apply(this,arguments);return(ie==="readable"||ie===void 0)&&S.nextTick(F,this),J};function F(ie){var J=ie._readableState;J.readableListening=ie.listenerCount("readable")>0,J.resumeScheduled&&!J.paused?J.flowing=!0:ie.listenerCount("data")>0&&ie.resume()}function V(ie){d("readable nexttick read 0"),ie.read(0)}e.prototype.resume=function(){var ie=this._readableState;return ie.flowing||(d("resume"),ie.flowing=!ie.readableListening,q(this,ie)),ie.paused=!1,this};function q(ie,J){J.resumeScheduled||(J.resumeScheduled=!0,S.nextTick(re,ie,J))}function re(ie,J){d("resume",J.reading),J.reading||ie.read(0),J.resumeScheduled=!1,ie.emit("resume"),G(ie),J.flowing&&!J.reading&&ie.read(0)}e.prototype.pause=function(){return d("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(d("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function G(ie){var J=ie._readableState;for(d("flow",J.flowing);J.flowing&&ie.read()!==null;);}e.prototype.wrap=function(ie){var J=this,pe=this._readableState,Ge=!1;ie.on("end",function(){if(d("wrapped end"),pe.decoder&&!pe.ended){var le=pe.decoder.end();le&&le.length&&J.push(le)}J.push(null)}),ie.on("data",function(le){if(d("wrapped data"),pe.decoder&&(le=pe.decoder.write(le)),!(pe.objectMode&&le==null)&&!(!pe.objectMode&&(!le||!le.length))){var ge=J.push(le);ge||(Ge=!0,ie.pause())}});for(var ce in ie)this[ce]===void 0&&typeof ie[ce]=="function"&&(this[ce]=function(ge){return function(){return ie[ge].apply(ie,arguments)}}(ce));for(var te=0;te<Y.length;te++)ie.on(Y[te],this.emit.bind(this,Y[te]));return this._read=function(le){d("wrapped _read",le),Ge&&(Ge=!1,ie.resume())},this},typeof Symbol=="function"&&(e.prototype[Symbol.asyncIterator]=function(){return K===void 0&&(K=T(4743)),K(this)}),Object.defineProperty(e.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(e.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(e.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(J){this._readableState&&(this._readableState.flowing=J)}}),e._fromList=H,Object.defineProperty(e.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function H(ie,J){if(J.length===0)return null;var pe;return J.objectMode?pe=J.buffer.shift():!ie||ie>=J.length?(J.decoder?pe=J.buffer.join(""):J.buffer.length===1?pe=J.buffer.first():pe=J.buffer.concat(J.length),J.buffer.clear()):pe=J.buffer.consume(ie,J.decoder),pe}function oe(ie){var J=ie._readableState;d("endReadable",J.endEmitted),J.endEmitted||(J.ended=!0,S.nextTick(ue,J,ie))}function ue(ie,J){if(d("endReadableNT",ie.endEmitted,ie.length),!ie.endEmitted&&ie.length===0&&(ie.endEmitted=!0,J.readable=!1,J.emit("end"),ie.autoDestroy)){var pe=J._writableState;(!pe||pe.autoDestroy&&pe.finished)&&J.destroy()}}typeof Symbol=="function"&&(e.from=function(ie,J){return $===void 0&&($=T(5049)),$(e,ie,J)});function be(ie,J){for(var pe=0,Ge=ie.length;pe<Ge;pe++)if(ie[pe]===J)return pe;return-1}},3054:(fe,x,T)=>{"use strict";fe.exports=g;var S=T(2260).F,y=S.ERR_METHOD_NOT_IMPLEMENTED,p=S.ERR_MULTIPLE_CALLBACK,I=S.ERR_TRANSFORM_ALREADY_TRANSFORMING,o=S.ERR_TRANSFORM_WITH_LENGTH_0,m=T(2818);T(6698)(g,m);function l(d,A){var v=this._transformState;v.transforming=!1;var b=v.writecb;if(b===null)return this.emit("error",new p);v.writechunk=null,v.writecb=null,A!=null&&this.push(A),b(d);var k=this._readableState;k.reading=!1,(k.needReadable||k.length<k.highWaterMark)&&this._read(k.highWaterMark)}function g(d){if(!(this instanceof g))return new g(d);m.call(this,d),this._transformState={afterTransform:l.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,d&&(typeof d.transform=="function"&&(this._transform=d.transform),typeof d.flush=="function"&&(this._flush=d.flush)),this.on("prefinish",M)}function M(){var d=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(A,v){E(d,A,v)}):E(this,null,null)}g.prototype.push=function(d,A){return this._transformState.needTransform=!1,m.prototype.push.call(this,d,A)},g.prototype._transform=function(d,A,v){v(new y("_transform()"))},g.prototype._write=function(d,A,v){var b=this._transformState;if(b.writecb=v,b.writechunk=d,b.writeencoding=A,!b.transforming){var k=this._readableState;(b.needTransform||k.needReadable||k.length<k.highWaterMark)&&this._read(k.highWaterMark)}},g.prototype._read=function(d){var A=this._transformState;A.writechunk!==null&&!A.transforming?(A.transforming=!0,this._transform(A.writechunk,A.writeencoding,A.afterTransform)):A.needTransform=!0},g.prototype._destroy=function(d,A){m.prototype._destroy.call(this,d,function(v){A(v)})};function E(d,A,v){if(A)return d.emit("error",A);if(v!=null&&d.push(v),d._writableState.length)throw new o;if(d._transformState.transforming)throw new I;return d.push(null)}},2192:(fe,x,T)=>{"use strict";var S=T(5606);fe.exports=u;function y(G,H,oe){this.chunk=G,this.encoding=H,this.callback=oe,this.next=null}function p(G){var H=this;this.next=null,this.entry=null,this.finish=function(){re(H,G)}}var I;u.WritableState=Y;var o={deprecate:T(4643)},m=T(1181),l=T(8287).Buffer,g=T.g.Uint8Array||function(){};function M(G){return l.from(G)}function E(G){return l.isBuffer(G)||G instanceof g}var d=T(1468),A=T(8775),v=A.getHighWaterMark,b=T(2260).F,k=b.ERR_INVALID_ARG_TYPE,B=b.ERR_METHOD_NOT_IMPLEMENTED,U=b.ERR_MULTIPLE_CALLBACK,C=b.ERR_STREAM_CANNOT_PIPE,L=b.ERR_STREAM_DESTROYED,N=b.ERR_STREAM_NULL_VALUES,j=b.ERR_STREAM_WRITE_AFTER_END,K=b.ERR_UNKNOWN_ENCODING,$=d.errorOrDestroy;T(6698)(u,m);function Q(){}function Y(G,H,oe){I=I||T(2818),G=G||{},typeof oe!="boolean"&&(oe=H instanceof I),this.objectMode=!!G.objectMode,oe&&(this.objectMode=this.objectMode||!!G.writableObjectMode),this.highWaterMark=v(this,G,"writableHighWaterMark",oe),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var ue=G.decodeStrings===!1;this.decodeStrings=!ue,this.defaultEncoding=G.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(be){s(H,be)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=G.emitClose!==!1,this.autoDestroy=!!G.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new p(this)}Y.prototype.getBuffer=function(){for(var H=this.bufferedRequest,oe=[];H;)oe.push(H),H=H.next;return oe},function(){try{Object.defineProperty(Y.prototype,"buffer",{get:o.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}();var ee;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(ee=Function.prototype[Symbol.hasInstance],Object.defineProperty(u,Symbol.hasInstance,{value:function(H){return ee.call(this,H)?!0:this!==u?!1:H&&H._writableState instanceof Y}})):ee=function(H){return H instanceof this};function u(G){I=I||T(2818);var H=this instanceof I;if(!H&&!ee.call(u,this))return new u(G);this._writableState=new Y(G,this,H),this.writable=!0,G&&(typeof G.write=="function"&&(this._write=G.write),typeof G.writev=="function"&&(this._writev=G.writev),typeof G.destroy=="function"&&(this._destroy=G.destroy),typeof G.final=="function"&&(this._final=G.final)),m.call(this)}u.prototype.pipe=function(){$(this,new C)};function e(G,H){var oe=new j;$(G,oe),S.nextTick(H,oe)}function r(G,H,oe,ue){var be;return oe===null?be=new N:typeof oe!="string"&&!H.objectMode&&(be=new k("chunk",["string","Buffer"],oe)),be?($(G,be),S.nextTick(ue,be),!1):!0}u.prototype.write=function(G,H,oe){var ue=this._writableState,be=!1,ie=!ue.objectMode&&E(G);return ie&&!l.isBuffer(G)&&(G=M(G)),typeof H=="function"&&(oe=H,H=null),ie?H="buffer":H||(H=ue.defaultEncoding),typeof oe!="function"&&(oe=Q),ue.ending?e(this,oe):(ie||r(this,ue,G,oe))&&(ue.pendingcb++,be=i(this,ue,ie,G,H,oe)),be},u.prototype.cork=function(){this._writableState.corked++},u.prototype.uncork=function(){var G=this._writableState;G.corked&&(G.corked--,!G.writing&&!G.corked&&!G.bufferProcessing&&G.bufferedRequest&&w(this,G))},u.prototype.setDefaultEncoding=function(H){if(typeof H=="string"&&(H=H.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((H+"").toLowerCase())>-1))throw new K(H);return this._writableState.defaultEncoding=H,this},Object.defineProperty(u.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function n(G,H,oe){return!G.objectMode&&G.decodeStrings!==!1&&typeof H=="string"&&(H=l.from(H,oe)),H}Object.defineProperty(u.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function i(G,H,oe,ue,be,ie){if(!oe){var J=n(H,ue,be);ue!==J&&(oe=!0,be="buffer",ue=J)}var pe=H.objectMode?1:ue.length;H.length+=pe;var Ge=H.length<H.highWaterMark;if(Ge||(H.needDrain=!0),H.writing||H.corked){var ce=H.lastBufferedRequest;H.lastBufferedRequest={chunk:ue,encoding:be,isBuf:oe,callback:ie,next:null},ce?ce.next=H.lastBufferedRequest:H.bufferedRequest=H.lastBufferedRequest,H.bufferedRequestCount+=1}else f(G,H,!1,pe,ue,be,ie);return Ge}function f(G,H,oe,ue,be,ie,J){H.writelen=ue,H.writecb=J,H.writing=!0,H.sync=!0,H.destroyed?H.onwrite(new L("write")):oe?G._writev(be,H.onwrite):G._write(be,ie,H.onwrite),H.sync=!1}function c(G,H,oe,ue,be){--H.pendingcb,oe?(S.nextTick(be,ue),S.nextTick(V,G,H),G._writableState.errorEmitted=!0,$(G,ue)):(be(ue),G._writableState.errorEmitted=!0,$(G,ue),V(G,H))}function h(G){G.writing=!1,G.writecb=null,G.length-=G.writelen,G.writelen=0}function s(G,H){var oe=G._writableState,ue=oe.sync,be=oe.writecb;if(typeof be!="function")throw new U;if(h(oe),H)c(G,oe,ue,H,be);else{var ie=D(oe)||G.destroyed;!ie&&!oe.corked&&!oe.bufferProcessing&&oe.bufferedRequest&&w(G,oe),ue?S.nextTick(t,G,oe,ie,be):t(G,oe,ie,be)}}function t(G,H,oe,ue){oe||a(G,H),H.pendingcb--,ue(),V(G,H)}function a(G,H){H.length===0&&H.needDrain&&(H.needDrain=!1,G.emit("drain"))}function w(G,H){H.bufferProcessing=!0;var oe=H.bufferedRequest;if(G._writev&&oe&&oe.next){var ue=H.bufferedRequestCount,be=new Array(ue),ie=H.corkedRequestsFree;ie.entry=oe;for(var J=0,pe=!0;oe;)be[J]=oe,oe.isBuf||(pe=!1),oe=oe.next,J+=1;be.allBuffers=pe,f(G,H,!0,H.length,be,"",ie.finish),H.pendingcb++,H.lastBufferedRequest=null,ie.next?(H.corkedRequestsFree=ie.next,ie.next=null):H.corkedRequestsFree=new p(H),H.bufferedRequestCount=0}else{for(;oe;){var Ge=oe.chunk,ce=oe.encoding,te=oe.callback,le=H.objectMode?1:Ge.length;if(f(G,H,!1,le,Ge,ce,te),oe=oe.next,H.bufferedRequestCount--,H.writing)break}oe===null&&(H.lastBufferedRequest=null)}H.bufferedRequest=oe,H.bufferProcessing=!1}u.prototype._write=function(G,H,oe){oe(new B("_write()"))},u.prototype._writev=null,u.prototype.end=function(G,H,oe){var ue=this._writableState;return typeof G=="function"?(oe=G,G=null,H=null):typeof H=="function"&&(oe=H,H=null),G!=null&&this.write(G,H),ue.corked&&(ue.corked=1,this.uncork()),ue.ending||q(this,ue,oe),this},Object.defineProperty(u.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function D(G){return G.ending&&G.length===0&&G.bufferedRequest===null&&!G.finished&&!G.writing}function Z(G,H){G._final(function(oe){H.pendingcb--,oe&&$(G,oe),H.prefinished=!0,G.emit("prefinish"),V(G,H)})}function F(G,H){!H.prefinished&&!H.finalCalled&&(typeof G._final=="function"&&!H.destroyed?(H.pendingcb++,H.finalCalled=!0,S.nextTick(Z,G,H)):(H.prefinished=!0,G.emit("prefinish")))}function V(G,H){var oe=D(H);if(oe&&(F(G,H),H.pendingcb===0&&(H.finished=!0,G.emit("finish"),H.autoDestroy))){var ue=G._readableState;(!ue||ue.autoDestroy&&ue.endEmitted)&&G.destroy()}return oe}function q(G,H,oe){H.ending=!0,V(G,H),oe&&(H.finished?S.nextTick(oe):G.once("finish",oe)),H.ended=!0,G.writable=!1}function re(G,H,oe){var ue=G.entry;for(G.entry=null;ue;){var be=ue.callback;H.pendingcb--,be(oe),ue=ue.next}H.corkedRequestsFree.next=G}Object.defineProperty(u.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(H){this._writableState&&(this._writableState.destroyed=H)}}),u.prototype.destroy=d.destroy,u.prototype._undestroy=d.undestroy,u.prototype._destroy=function(G,H){H(G)}},4743:(fe,x,T)=>{"use strict";var S=T(5606),y;function p(L,N,j){return N in L?Object.defineProperty(L,N,{value:j,enumerable:!0,configurable:!0,writable:!0}):L[N]=j,L}var I=T(5826),o=Symbol("lastResolve"),m=Symbol("lastReject"),l=Symbol("error"),g=Symbol("ended"),M=Symbol("lastPromise"),E=Symbol("handlePromise"),d=Symbol("stream");function A(L,N){return{value:L,done:N}}function v(L){var N=L[o];if(N!==null){var j=L[d].read();j!==null&&(L[M]=null,L[o]=null,L[m]=null,N(A(j,!1)))}}function b(L){S.nextTick(v,L)}function k(L,N){return function(j,K){L.then(function(){if(N[g]){j(A(void 0,!0));return}N[E](j,K)},K)}}var B=Object.getPrototypeOf(function(){}),U=Object.setPrototypeOf((y={get stream(){return this[d]},next:function(){var N=this,j=this[l];if(j!==null)return Promise.reject(j);if(this[g])return Promise.resolve(A(void 0,!0));if(this[d].destroyed)return new Promise(function(Y,ee){S.nextTick(function(){N[l]?ee(N[l]):Y(A(void 0,!0))})});var K=this[M],$;if(K)$=new Promise(k(K,this));else{var Q=this[d].read();if(Q!==null)return Promise.resolve(A(Q,!1));$=new Promise(this[E])}return this[M]=$,$}},p(y,Symbol.asyncIterator,function(){return this}),p(y,"return",function(){var N=this;return new Promise(function(j,K){N[d].destroy(null,function($){if($){K($);return}j(A(void 0,!0))})})}),y),B),C=function(N){var j,K=Object.create(U,(j={},p(j,d,{value:N,writable:!0}),p(j,o,{value:null,writable:!0}),p(j,m,{value:null,writable:!0}),p(j,l,{value:null,writable:!0}),p(j,g,{value:N._readableState.endEmitted,writable:!0}),p(j,E,{value:function(Q,Y){var ee=K[d].read();ee?(K[M]=null,K[o]=null,K[m]=null,Q(A(ee,!1))):(K[o]=Q,K[m]=Y)},writable:!0}),j));return K[M]=null,I(N,function($){if($&&$.code!=="ERR_STREAM_PREMATURE_CLOSE"){var Q=K[m];Q!==null&&(K[M]=null,K[o]=null,K[m]=null,Q($)),K[l]=$;return}var Y=K[o];Y!==null&&(K[M]=null,K[o]=null,K[m]=null,Y(A(void 0,!0))),K[g]=!0}),N.on("readable",b.bind(null,K)),K};fe.exports=C},2389:(fe,x,T)=>{"use strict";function S(v,b){var k=Object.keys(v);if(Object.getOwnPropertySymbols){var B=Object.getOwnPropertySymbols(v);b&&(B=B.filter(function(U){return Object.getOwnPropertyDescriptor(v,U).enumerable})),k.push.apply(k,B)}return k}function y(v){for(var b=1;b<arguments.length;b++){var k=arguments[b]!=null?arguments[b]:{};b%2?S(Object(k),!0).forEach(function(B){p(v,B,k[B])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(k)):S(Object(k)).forEach(function(B){Object.defineProperty(v,B,Object.getOwnPropertyDescriptor(k,B))})}return v}function p(v,b,k){return b in v?Object.defineProperty(v,b,{value:k,enumerable:!0,configurable:!0,writable:!0}):v[b]=k,v}function I(v,b){if(!(v instanceof b))throw new TypeError("Cannot call a class as a function")}function o(v,b){for(var k=0;k<b.length;k++){var B=b[k];B.enumerable=B.enumerable||!1,B.configurable=!0,"value"in B&&(B.writable=!0),Object.defineProperty(v,B.key,B)}}function m(v,b,k){return b&&o(v.prototype,b),k&&o(v,k),v}var l=T(8287),g=l.Buffer,M=T(8460),E=M.inspect,d=E&&E.custom||"inspect";function A(v,b,k){g.prototype.copy.call(v,b,k)}fe.exports=function(){function v(){I(this,v),this.head=null,this.tail=null,this.length=0}return m(v,[{key:"push",value:function(k){var B={data:k,next:null};this.length>0?this.tail.next=B:this.head=B,this.tail=B,++this.length}},{key:"unshift",value:function(k){var B={data:k,next:this.head};this.length===0&&(this.tail=B),this.head=B,++this.length}},{key:"shift",value:function(){if(this.length!==0){var k=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,k}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(k){if(this.length===0)return"";for(var B=this.head,U=""+B.data;B=B.next;)U+=k+B.data;return U}},{key:"concat",value:function(k){if(this.length===0)return g.alloc(0);for(var B=g.allocUnsafe(k>>>0),U=this.head,C=0;U;)A(U.data,B,C),C+=U.data.length,U=U.next;return B}},{key:"consume",value:function(k,B){var U;return k<this.head.data.length?(U=this.head.data.slice(0,k),this.head.data=this.head.data.slice(k)):k===this.head.data.length?U=this.shift():U=B?this._getString(k):this._getBuffer(k),U}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(k){var B=this.head,U=1,C=B.data;for(k-=C.length;B=B.next;){var L=B.data,N=k>L.length?L.length:k;if(N===L.length?C+=L:C+=L.slice(0,k),k-=N,k===0){N===L.length?(++U,B.next?this.head=B.next:this.head=this.tail=null):(this.head=B,B.data=L.slice(N));break}++U}return this.length-=U,C}},{key:"_getBuffer",value:function(k){var B=g.allocUnsafe(k),U=this.head,C=1;for(U.data.copy(B),k-=U.data.length;U=U.next;){var L=U.data,N=k>L.length?L.length:k;if(L.copy(B,B.length-k,0,N),k-=N,k===0){N===L.length?(++C,U.next?this.head=U.next:this.head=this.tail=null):(this.head=U,U.data=L.slice(N));break}++C}return this.length-=C,B}},{key:d,value:function(k,B){return E(this,y({},B,{depth:0,customInspect:!1}))}}]),v}()},1468:(fe,x,T)=>{"use strict";var S=T(5606);function y(g,M){var E=this,d=this._readableState&&this._readableState.destroyed,A=this._writableState&&this._writableState.destroyed;return d||A?(M?M(g):g&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,S.nextTick(m,this,g)):S.nextTick(m,this,g)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(g||null,function(v){!M&&v?E._writableState?E._writableState.errorEmitted?S.nextTick(I,E):(E._writableState.errorEmitted=!0,S.nextTick(p,E,v)):S.nextTick(p,E,v):M?(S.nextTick(I,E),M(v)):S.nextTick(I,E)}),this)}function p(g,M){m(g,M),I(g)}function I(g){g._writableState&&!g._writableState.emitClose||g._readableState&&!g._readableState.emitClose||g.emit("close")}function o(){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.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function m(g,M){g.emit("error",M)}function l(g,M){var E=g._readableState,d=g._writableState;E&&E.autoDestroy||d&&d.autoDestroy?g.destroy(M):g.emit("error",M)}fe.exports={destroy:y,undestroy:o,errorOrDestroy:l}},5826:(fe,x,T)=>{"use strict";var S=T(2260).F.ERR_STREAM_PREMATURE_CLOSE;function y(m){var l=!1;return function(){if(!l){l=!0;for(var g=arguments.length,M=new Array(g),E=0;E<g;E++)M[E]=arguments[E];m.apply(this,M)}}}function p(){}function I(m){return m.setHeader&&typeof m.abort=="function"}function o(m,l,g){if(typeof l=="function")return o(m,null,l);l||(l={}),g=y(g||p);var M=l.readable||l.readable!==!1&&m.readable,E=l.writable||l.writable!==!1&&m.writable,d=function(){m.writable||v()},A=m._writableState&&m._writableState.finished,v=function(){E=!1,A=!0,M||g.call(m)},b=m._readableState&&m._readableState.endEmitted,k=function(){M=!1,b=!0,E||g.call(m)},B=function(N){g.call(m,N)},U=function(){var N;if(M&&!b)return(!m._readableState||!m._readableState.ended)&&(N=new S),g.call(m,N);if(E&&!A)return(!m._writableState||!m._writableState.ended)&&(N=new S),g.call(m,N)},C=function(){m.req.on("finish",v)};return I(m)?(m.on("complete",v),m.on("abort",U),m.req?C():m.on("request",C)):E&&!m._writableState&&(m.on("end",d),m.on("close",d)),m.on("end",k),m.on("finish",v),l.error!==!1&&m.on("error",B),m.on("close",U),function(){m.removeListener("complete",v),m.removeListener("abort",U),m.removeListener("request",C),m.req&&m.req.removeListener("finish",v),m.removeListener("end",d),m.removeListener("close",d),m.removeListener("finish",v),m.removeListener("end",k),m.removeListener("error",B),m.removeListener("close",U)}}fe.exports=o},5049:fe=>{fe.exports=function(){throw new Error("Readable.from is not available in the browser")}},9434:(fe,x,T)=>{"use strict";var S;function y(v){var b=!1;return function(){b||(b=!0,v.apply(void 0,arguments))}}var p=T(2260).F,I=p.ERR_MISSING_ARGS,o=p.ERR_STREAM_DESTROYED;function m(v){if(v)throw v}function l(v){return v.setHeader&&typeof v.abort=="function"}function g(v,b,k,B){B=y(B);var U=!1;v.on("close",function(){U=!0}),S===void 0&&(S=T(5826)),S(v,{readable:b,writable:k},function(L){if(L)return B(L);U=!0,B()});var C=!1;return function(L){if(!U&&!C){if(C=!0,l(v))return v.abort();if(typeof v.destroy=="function")return v.destroy();B(L||new o("pipe"))}}}function M(v){v()}function E(v,b){return v.pipe(b)}function d(v){return!v.length||typeof v[v.length-1]!="function"?m:v.pop()}function A(){for(var v=arguments.length,b=new Array(v),k=0;k<v;k++)b[k]=arguments[k];var B=d(b);if(Array.isArray(b[0])&&(b=b[0]),b.length<2)throw new I("streams");var U,C=b.map(function(L,N){var j=N<b.length-1,K=N>0;return g(L,j,K,function($){U||(U=$),$&&C.forEach(M),!j&&(C.forEach(M),B(U))})});return b.reduce(E)}fe.exports=A},8775:(fe,x,T)=>{"use strict";var S=T(2260).F.ERR_INVALID_OPT_VALUE;function y(I,o,m){return I.highWaterMark!=null?I.highWaterMark:o?I[m]:null}function p(I,o,m,l){var g=y(o,l,m);if(g!=null){if(!(isFinite(g)&&Math.floor(g)===g)||g<0){var M=l?m:"highWaterMark";throw new S(M,g)}return Math.floor(g)}return I.objectMode?16:16384}fe.exports={getHighWaterMark:p}},1181:(fe,x,T)=>{fe.exports=T(7007).EventEmitter},1603:(fe,x,T)=>{x=fe.exports=T(6736),x.Stream=x,x.Readable=x,x.Writable=T(2192),x.Duplex=T(2818),x.Transform=T(3054),x.PassThrough=T(5860),x.finished=T(5826),x.pipeline=T(9434)},7952:(fe,x,T)=>{var S=x;S.utils=T(7426),S.common=T(6166),S.sha=T(6229),S.ripemd=T(6784),S.hmac=T(8948),S.sha1=S.sha.sha1,S.sha256=S.sha.sha256,S.sha224=S.sha.sha224,S.sha384=S.sha.sha384,S.sha512=S.sha.sha512,S.ripemd160=S.ripemd.ripemd160},6166:(fe,x,T)=>{"use strict";var S=T(7426),y=T(3349);function p(){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}x.BlockHash=p,p.prototype.update=function(o,m){if(o=S.toArray(o,m),this.pending?this.pending=this.pending.concat(o):this.pending=o,this.pendingTotal+=o.length,this.pending.length>=this._delta8){o=this.pending;var l=o.length%this._delta8;this.pending=o.slice(o.length-l,o.length),this.pending.length===0&&(this.pending=null),o=S.join32(o,0,o.length-l,this.endian);for(var g=0;g<o.length;g+=this._delta32)this._update(o,g,g+this._delta32)}return this},p.prototype.digest=function(o){return this.update(this._pad()),y(this.pending===null),this._digest(o)},p.prototype._pad=function(){var o=this.pendingTotal,m=this._delta8,l=m-(o+this.padLength)%m,g=new Array(l+this.padLength);g[0]=128;for(var M=1;M<l;M++)g[M]=0;if(o<<=3,this.endian==="big"){for(var E=8;E<this.padLength;E++)g[M++]=0;g[M++]=0,g[M++]=0,g[M++]=0,g[M++]=0,g[M++]=o>>>24&255,g[M++]=o>>>16&255,g[M++]=o>>>8&255,g[M++]=o&255}else for(g[M++]=o&255,g[M++]=o>>>8&255,g[M++]=o>>>16&255,g[M++]=o>>>24&255,g[M++]=0,g[M++]=0,g[M++]=0,g[M++]=0,E=8;E<this.padLength;E++)g[M++]=0;return g}},8948:(fe,x,T)=>{"use strict";var S=T(7426),y=T(3349);function p(I,o,m){if(!(this instanceof p))return new p(I,o,m);this.Hash=I,this.blockSize=I.blockSize/8,this.outSize=I.outSize/8,this.inner=null,this.outer=null,this._init(S.toArray(o,m))}fe.exports=p,p.prototype._init=function(o){o.length>this.blockSize&&(o=new this.Hash().update(o).digest()),y(o.length<=this.blockSize);for(var m=o.length;m<this.blockSize;m++)o.push(0);for(m=0;m<o.length;m++)o[m]^=54;for(this.inner=new this.Hash().update(o),m=0;m<o.length;m++)o[m]^=106;this.outer=new this.Hash().update(o)},p.prototype.update=function(o,m){return this.inner.update(o,m),this},p.prototype.digest=function(o){return this.outer.update(this.inner.digest()),this.outer.digest(o)}},6784:(fe,x,T)=>{"use strict";var S=T(7426),y=T(6166),p=S.rotl32,I=S.sum32,o=S.sum32_3,m=S.sum32_4,l=y.BlockHash;function g(){if(!(this instanceof g))return new g;l.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}S.inherits(g,l),x.ripemd160=g,g.blockSize=512,g.outSize=160,g.hmacStrength=192,g.padLength=64,g.prototype._update=function(U,C){for(var L=this.h[0],N=this.h[1],j=this.h[2],K=this.h[3],$=this.h[4],Q=L,Y=N,ee=j,u=K,e=$,r=0;r<80;r++){var n=I(p(m(L,M(r,N,j,K),U[A[r]+C],E(r)),b[r]),$);L=$,$=K,K=p(j,10),j=N,N=n,n=I(p(m(Q,M(79-r,Y,ee,u),U[v[r]+C],d(r)),k[r]),e),Q=e,e=u,u=p(ee,10),ee=Y,Y=n}n=o(this.h[1],j,u),this.h[1]=o(this.h[2],K,e),this.h[2]=o(this.h[3],$,Q),this.h[3]=o(this.h[4],L,Y),this.h[4]=o(this.h[0],N,ee),this.h[0]=n},g.prototype._digest=function(U){return U==="hex"?S.toHex32(this.h,"little"):S.split32(this.h,"little")};function M(B,U,C,L){return B<=15?U^C^L:B<=31?U&C|~U&L:B<=47?(U|~C)^L:B<=63?U&L|C&~L:U^(C|~L)}function E(B){return B<=15?0:B<=31?1518500249:B<=47?1859775393:B<=63?2400959708:2840853838}function d(B){return B<=15?1352829926:B<=31?1548603684:B<=47?1836072691:B<=63?2053994217:0}var 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],v=[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],b=[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],k=[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]},6229:(fe,x,T)=>{"use strict";x.sha1=T(3917),x.sha224=T(7714),x.sha256=T(2287),x.sha384=T(1911),x.sha512=T(7766)},3917:(fe,x,T)=>{"use strict";var S=T(7426),y=T(6166),p=T(6225),I=S.rotl32,o=S.sum32,m=S.sum32_5,l=p.ft_1,g=y.BlockHash,M=[1518500249,1859775393,2400959708,3395469782];function E(){if(!(this instanceof E))return new E;g.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}S.inherits(E,g),fe.exports=E,E.blockSize=512,E.outSize=160,E.hmacStrength=80,E.padLength=64,E.prototype._update=function(A,v){for(var b=this.W,k=0;k<16;k++)b[k]=A[v+k];for(;k<b.length;k++)b[k]=I(b[k-3]^b[k-8]^b[k-14]^b[k-16],1);var B=this.h[0],U=this.h[1],C=this.h[2],L=this.h[3],N=this.h[4];for(k=0;k<b.length;k++){var j=~~(k/20),K=m(I(B,5),l(j,U,C,L),N,b[k],M[j]);N=L,L=C,C=I(U,30),U=B,B=K}this.h[0]=o(this.h[0],B),this.h[1]=o(this.h[1],U),this.h[2]=o(this.h[2],C),this.h[3]=o(this.h[3],L),this.h[4]=o(this.h[4],N)},E.prototype._digest=function(A){return A==="hex"?S.toHex32(this.h,"big"):S.split32(this.h,"big")}},7714:(fe,x,T)=>{"use strict";var S=T(7426),y=T(2287);function p(){if(!(this instanceof p))return new p;y.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}S.inherits(p,y),fe.exports=p,p.blockSize=512,p.outSize=224,p.hmacStrength=192,p.padLength=64,p.prototype._digest=function(o){return o==="hex"?S.toHex32(this.h.slice(0,7),"big"):S.split32(this.h.slice(0,7),"big")}},2287:(fe,x,T)=>{"use strict";var S=T(7426),y=T(6166),p=T(6225),I=T(3349),o=S.sum32,m=S.sum32_4,l=S.sum32_5,g=p.ch32,M=p.maj32,E=p.s0_256,d=p.s1_256,A=p.g0_256,v=p.g1_256,b=y.BlockHash,k=[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;b.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=k,this.W=new Array(64)}S.inherits(B,b),fe.exports=B,B.blockSize=512,B.outSize=256,B.hmacStrength=192,B.padLength=64,B.prototype._update=function(C,L){for(var N=this.W,j=0;j<16;j++)N[j]=C[L+j];for(;j<N.length;j++)N[j]=m(v(N[j-2]),N[j-7],A(N[j-15]),N[j-16]);var K=this.h[0],$=this.h[1],Q=this.h[2],Y=this.h[3],ee=this.h[4],u=this.h[5],e=this.h[6],r=this.h[7];for(I(this.k.length===N.length),j=0;j<N.length;j++){var n=l(r,d(ee),g(ee,u,e),this.k[j],N[j]),i=o(E(K),M(K,$,Q));r=e,e=u,u=ee,ee=o(Y,n),Y=Q,Q=$,$=K,K=o(n,i)}this.h[0]=o(this.h[0],K),this.h[1]=o(this.h[1],$),this.h[2]=o(this.h[2],Q),this.h[3]=o(this.h[3],Y),this.h[4]=o(this.h[4],ee),this.h[5]=o(this.h[5],u),this.h[6]=o(this.h[6],e),this.h[7]=o(this.h[7],r)},B.prototype._digest=function(C){return C==="hex"?S.toHex32(this.h,"big"):S.split32(this.h,"big")}},1911:(fe,x,T)=>{"use strict";var S=T(7426),y=T(7766);function p(){if(!(this instanceof p))return new p;y.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}S.inherits(p,y),fe.exports=p,p.blockSize=1024,p.outSize=384,p.hmacStrength=192,p.padLength=128,p.prototype._digest=function(o){return o==="hex"?S.toHex32(this.h.slice(0,12),"big"):S.split32(this.h.slice(0,12),"big")}},7766:(fe,x,T)=>{"use strict";var S=T(7426),y=T(6166),p=T(3349),I=S.rotr64_hi,o=S.rotr64_lo,m=S.shr64_hi,l=S.shr64_lo,g=S.sum64,M=S.sum64_hi,E=S.sum64_lo,d=S.sum64_4_hi,A=S.sum64_4_lo,v=S.sum64_5_hi,b=S.sum64_5_lo,k=y.BlockHash,B=[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];function U(){if(!(this instanceof U))return new U;k.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=B,this.W=new Array(160)}S.inherits(U,k),fe.exports=U,U.blockSize=1024,U.outSize=512,U.hmacStrength=192,U.padLength=128,U.prototype._prepareBlock=function(i,f){for(var c=this.W,h=0;h<32;h++)c[h]=i[f+h];for(;h<c.length;h+=2){var s=e(c[h-4],c[h-3]),t=r(c[h-4],c[h-3]),a=c[h-14],w=c[h-13],D=ee(c[h-30],c[h-29]),Z=u(c[h-30],c[h-29]),F=c[h-32],V=c[h-31];c[h]=d(s,t,a,w,D,Z,F,V),c[h+1]=A(s,t,a,w,D,Z,F,V)}},U.prototype._update=function(i,f){this._prepareBlock(i,f);var c=this.W,h=this.h[0],s=this.h[1],t=this.h[2],a=this.h[3],w=this.h[4],D=this.h[5],Z=this.h[6],F=this.h[7],V=this.h[8],q=this.h[9],re=this.h[10],G=this.h[11],H=this.h[12],oe=this.h[13],ue=this.h[14],be=this.h[15];p(this.k.length===c.length);for(var ie=0;ie<c.length;ie+=2){var J=ue,pe=be,Ge=Q(V,q),ce=Y(V,q),te=C(V,q,re,G,H,oe),le=L(V,q,re,G,H,oe),ge=this.k[ie],Pe=this.k[ie+1],lt=c[ie],Le=c[ie+1],ze=v(J,pe,Ge,ce,te,le,ge,Pe,lt,Le),kt=b(J,pe,Ge,ce,te,le,ge,Pe,lt,Le);J=K(h,s),pe=$(h,s),Ge=N(h,s,t,a,w,D),ce=j(h,s,t,a,w,D);var ae=M(J,pe,Ge,ce),he=E(J,pe,Ge,ce);ue=H,be=oe,H=re,oe=G,re=V,G=q,V=M(Z,F,ze,kt),q=E(F,F,ze,kt),Z=w,F=D,w=t,D=a,t=h,a=s,h=M(ze,kt,ae,he),s=E(ze,kt,ae,he)}g(this.h,0,h,s),g(this.h,2,t,a),g(this.h,4,w,D),g(this.h,6,Z,F),g(this.h,8,V,q),g(this.h,10,re,G),g(this.h,12,H,oe),g(this.h,14,ue,be)},U.prototype._digest=function(i){return i==="hex"?S.toHex32(this.h,"big"):S.split32(this.h,"big")};function C(n,i,f,c,h){var s=n&f^~n&h;return s<0&&(s+=4294967296),s}function L(n,i,f,c,h,s){var t=i&c^~i&s;return t<0&&(t+=4294967296),t}function N(n,i,f,c,h){var s=n&f^n&h^f&h;return s<0&&(s+=4294967296),s}function j(n,i,f,c,h,s){var t=i&c^i&s^c&s;return t<0&&(t+=4294967296),t}function K(n,i){var f=I(n,i,28),c=I(i,n,2),h=I(i,n,7),s=f^c^h;return s<0&&(s+=4294967296),s}function $(n,i){var f=o(n,i,28),c=o(i,n,2),h=o(i,n,7),s=f^c^h;return s<0&&(s+=4294967296),s}function Q(n,i){var f=I(n,i,14),c=I(n,i,18),h=I(i,n,9),s=f^c^h;return s<0&&(s+=4294967296),s}function Y(n,i){var f=o(n,i,14),c=o(n,i,18),h=o(i,n,9),s=f^c^h;return s<0&&(s+=4294967296),s}function ee(n,i){var f=I(n,i,1),c=I(n,i,8),h=m(n,i,7),s=f^c^h;return s<0&&(s+=4294967296),s}function u(n,i){var f=o(n,i,1),c=o(n,i,8),h=l(n,i,7),s=f^c^h;return s<0&&(s+=4294967296),s}function e(n,i){var f=I(n,i,19),c=I(i,n,29),h=m(n,i,6),s=f^c^h;return s<0&&(s+=4294967296),s}function r(n,i){var f=o(n,i,19),c=o(i,n,29),h=l(n,i,6),s=f^c^h;return s<0&&(s+=4294967296),s}},6225:(fe,x,T)=>{"use strict";var S=T(7426),y=S.rotr32;function p(d,A,v,b){if(d===0)return I(A,v,b);if(d===1||d===3)return m(A,v,b);if(d===2)return o(A,v,b)}x.ft_1=p;function I(d,A,v){return d&A^~d&v}x.ch32=I;function o(d,A,v){return d&A^d&v^A&v}x.maj32=o;function m(d,A,v){return d^A^v}x.p32=m;function l(d){return y(d,2)^y(d,13)^y(d,22)}x.s0_256=l;function g(d){return y(d,6)^y(d,11)^y(d,25)}x.s1_256=g;function M(d){return y(d,7)^y(d,18)^d>>>3}x.g0_256=M;function E(d){return y(d,17)^y(d,19)^d>>>10}x.g1_256=E},7426:(fe,x,T)=>{"use strict";var S=T(3349),y=T(6698);x.inherits=y;function p(r,n){return(r.charCodeAt(n)&64512)!==55296||n<0||n+1>=r.length?!1:(r.charCodeAt(n+1)&64512)===56320}function I(r,n){if(Array.isArray(r))return r.slice();if(!r)return[];var i=[];if(typeof r=="string")if(n){if(n==="hex")for(r=r.replace(/[^a-z0-9]+/ig,""),r.length%2!==0&&(r="0"+r),c=0;c<r.length;c+=2)i.push(parseInt(r[c]+r[c+1],16))}else for(var f=0,c=0;c<r.length;c++){var h=r.charCodeAt(c);h<128?i[f++]=h:h<2048?(i[f++]=h>>6|192,i[f++]=h&63|128):p(r,c)?(h=65536+((h&1023)<<10)+(r.charCodeAt(++c)&1023),i[f++]=h>>18|240,i[f++]=h>>12&63|128,i[f++]=h>>6&63|128,i[f++]=h&63|128):(i[f++]=h>>12|224,i[f++]=h>>6&63|128,i[f++]=h&63|128)}else for(c=0;c<r.length;c++)i[c]=r[c]|0;return i}x.toArray=I;function o(r){for(var n="",i=0;i<r.length;i++)n+=g(r[i].toString(16));return n}x.toHex=o;function m(r){var n=r>>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24;return n>>>0}x.htonl=m;function l(r,n){for(var i="",f=0;f<r.length;f++){var c=r[f];n==="little"&&(c=m(c)),i+=M(c.toString(16))}return i}x.toHex32=l;function g(r){return r.length===1?"0"+r:r}x.zero2=g;function M(r){return r.length===7?"0"+r:r.length===6?"00"+r:r.length===5?"000"+r:r.length===4?"0000"+r:r.length===3?"00000"+r:r.length===2?"000000"+r:r.length===1?"0000000"+r:r}x.zero8=M;function E(r,n,i,f){var c=i-n;S(c%4===0);for(var h=new Array(c/4),s=0,t=n;s<h.length;s++,t+=4){var a;f==="big"?a=r[t]<<24|r[t+1]<<16|r[t+2]<<8|r[t+3]:a=r[t+3]<<24|r[t+2]<<16|r[t+1]<<8|r[t],h[s]=a>>>0}return h}x.join32=E;function d(r,n){for(var i=new Array(r.length*4),f=0,c=0;f<r.length;f++,c+=4){var h=r[f];n==="big"?(i[c]=h>>>24,i[c+1]=h>>>16&255,i[c+2]=h>>>8&255,i[c+3]=h&255):(i[c+3]=h>>>24,i[c+2]=h>>>16&255,i[c+1]=h>>>8&255,i[c]=h&255)}return i}x.split32=d;function A(r,n){return r>>>n|r<<32-n}x.rotr32=A;function v(r,n){return r<<n|r>>>32-n}x.rotl32=v;function b(r,n){return r+n>>>0}x.sum32=b;function k(r,n,i){return r+n+i>>>0}x.sum32_3=k;function B(r,n,i,f){return r+n+i+f>>>0}x.sum32_4=B;function U(r,n,i,f,c){return r+n+i+f+c>>>0}x.sum32_5=U;function C(r,n,i,f){var c=r[n],h=r[n+1],s=f+h>>>0,t=(s<f?1:0)+i+c;r[n]=t>>>0,r[n+1]=s}x.sum64=C;function L(r,n,i,f){var c=n+f>>>0,h=(c<n?1:0)+r+i;return h>>>0}x.sum64_hi=L;function N(r,n,i,f){var c=n+f;return c>>>0}x.sum64_lo=N;function j(r,n,i,f,c,h,s,t){var a=0,w=n;w=w+f>>>0,a+=w<n?1:0,w=w+h>>>0,a+=w<h?1:0,w=w+t>>>0,a+=w<t?1:0;var D=r+i+c+s+a;return D>>>0}x.sum64_4_hi=j;function K(r,n,i,f,c,h,s,t){var a=n+f+h+t;return a>>>0}x.sum64_4_lo=K;function $(r,n,i,f,c,h,s,t,a,w){var D=0,Z=n;Z=Z+f>>>0,D+=Z<n?1:0,Z=Z+h>>>0,D+=Z<h?1:0,Z=Z+t>>>0,D+=Z<t?1:0,Z=Z+w>>>0,D+=Z<w?1:0;var F=r+i+c+s+a+D;return F>>>0}x.sum64_5_hi=$;function Q(r,n,i,f,c,h,s,t,a,w){var D=n+f+h+t+w;return D>>>0}x.sum64_5_lo=Q;function Y(r,n,i){var f=n<<32-i|r>>>i;return f>>>0}x.rotr64_hi=Y;function ee(r,n,i){var f=r<<32-i|n>>>i;return f>>>0}x.rotr64_lo=ee;function u(r,n,i){return r>>>i}x.shr64_hi=u;function e(r,n,i){var f=r<<32-i|n>>>i;return f>>>0}x.shr64_lo=e},2723:(fe,x,T)=>{"use strict";var S=T(7952),y=T(4367),p=T(3349);function I(o){if(!(this instanceof I))return new I(o);this.hash=o.hash,this.predResist=!!o.predResist,this.outLen=this.hash.outSize,this.minEntropy=o.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var m=y.toArray(o.entropy,o.entropyEnc||"hex"),l=y.toArray(o.nonce,o.nonceEnc||"hex"),g=y.toArray(o.pers,o.persEnc||"hex");p(m.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(m,l,g)}fe.exports=I,I.prototype._init=function(m,l,g){var M=m.concat(l).concat(g);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var E=0;E<this.V.length;E++)this.K[E]=0,this.V[E]=1;this._update(M),this._reseed=1,this.reseedInterval=281474976710656},I.prototype._hmac=function(){return new S.hmac(this.hash,this.K)},I.prototype._update=function(m){var l=this._hmac().update(this.V).update([0]);m&&(l=l.update(m)),this.K=l.digest(),this.V=this._hmac().update(this.V).digest(),m&&(this.K=this._hmac().update(this.V).update([1]).update(m).digest(),this.V=this._hmac().update(this.V).digest())},I.prototype.reseed=function(m,l,g,M){typeof l!="string"&&(M=g,g=l,l=null),m=y.toArray(m,l),g=y.toArray(g,M),p(m.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(m.concat(g||[])),this._reseed=1},I.prototype.generate=function(m,l,g,M){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof l!="string"&&(M=g,g=l,l=null),g&&(g=y.toArray(g,M||"hex"),this._update(g));for(var E=[];E.length<m;)this.V=this._hmac().update(this.V).digest(),E=E.concat(this.V);var d=E.slice(0,m);return this._update(g),this._reseed++,y.encode(d,l)}},251:(fe,x)=>{/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */x.read=function(T,S,y,p,I){var o,m,l=I*8-p-1,g=(1<<l)-1,M=g>>1,E=-7,d=y?I-1:0,A=y?-1:1,v=T[S+d];for(d+=A,o=v&(1<<-E)-1,v>>=-E,E+=l;E>0;o=o*256+T[S+d],d+=A,E-=8);for(m=o&(1<<-E)-1,o>>=-E,E+=p;E>0;m=m*256+T[S+d],d+=A,E-=8);if(o===0)o=1-M;else{if(o===g)return m?NaN:(v?-1:1)*(1/0);m=m+Math.pow(2,p),o=o-M}return(v?-1:1)*m*Math.pow(2,o-p)},x.write=function(T,S,y,p,I,o){var m,l,g,M=o*8-I-1,E=(1<<M)-1,d=E>>1,A=I===23?Math.pow(2,-24)-Math.pow(2,-77):0,v=p?0:o-1,b=p?1:-1,k=S<0||S===0&&1/S<0?1:0;for(S=Math.abs(S),isNaN(S)||S===1/0?(l=isNaN(S)?1:0,m=E):(m=Math.floor(Math.log(S)/Math.LN2),S*(g=Math.pow(2,-m))<1&&(m--,g*=2),m+d>=1?S+=A/g:S+=A*Math.pow(2,1-d),S*g>=2&&(m++,g/=2),m+d>=E?(l=0,m=E):m+d>=1?(l=(S*g-1)*Math.pow(2,I),m=m+d):(l=S*Math.pow(2,d-1)*Math.pow(2,I),m=0));I>=8;T[y+v]=l&255,v+=b,l/=256,I-=8);for(m=m<<I|l,M+=I;M>0;T[y+v]=m&255,v+=b,m/=256,M-=8);T[y+v-b]|=k*128}},6698:fe=>{typeof Object.create=="function"?fe.exports=function(T,S){S&&(T.super_=S,T.prototype=Object.create(S.prototype,{constructor:{value:T,enumerable:!1,writable:!0,configurable:!0}}))}:fe.exports=function(T,S){if(S){T.super_=S;var y=function(){};y.prototype=S.prototype,T.prototype=new y,T.prototype.constructor=T}}},4634:fe=>{var x={}.toString;fe.exports=Array.isArray||function(T){return x.call(T)=="[object Array]"}},1176:(fe,x,T)=>{var S=T(5606);/**
|
|
40
40
|
* [js-sha3]{@link https://github.com/emn178/js-sha3}
|
|
41
41
|
*
|
|
42
42
|
* @version 0.6.1
|
|
@@ -53,7 +53,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
53
53
|
`],wif:[128],legacyXPriv:[76066276],legacyXPub:[76067358],wrappedSegwitXPriv:[77428856],wrappedSegwitXPub:[77429938],segwitXPriv:[78791436],segwitXPub:[78792518],pubkeyHash:[0],scriptHash:[5],bech32:["bc"]}}},nr="bb",fr="ba",lr="ac",dr="30440220256c12175e809381f97637933ed6ab97737d263eaaebca6add21bced67fd12a402205ce29ecc1369d6fc1b51977ed38faaf41119e3be1d7edfafd7cfaf0b6061bd07",cr="",gr="038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508",pr=R=>{const z=(R.length/2).toString(16);return(z.length%2===0?z:`0${z}`)+R},dn=(R,O,z,me)=>{const Me=`${pr(me)}${lr}`;return[`${pr(R)}${pr(O)}${pr(z)}`,Me]},Jr={replayProtection:R=>dn(dr,cr,gr,R).join(nr),checkdatasig:(R,O)=>{var z,me,Me;const Re=(z=O==null?void 0:O.cdsSig)!=null?z:"",Se=(me=O==null?void 0:O.cdsMsg)!=null?me:"",ke=(Me=O==null?void 0:O.cdsPubKey)!=null?Me:"";return dn(Re,Se,ke,R).join(fr)},checkdatasigverify:(R,O)=>{var z,me,Me;const Re=(z=O==null?void 0:O.cdsSig)!=null?z:"",Se=(me=O==null?void 0:O.cdsMsg)!=null?me:"",ke=(Me=O==null?void 0:O.cdsPubKey)!=null?Me:"";return dn(Re,Se,ke,R).join(nr)}};var Ur=Object.defineProperty,Mn=Object.defineProperties,Kn=Object.getOwnPropertyDescriptors,Xn=Object.getOwnPropertySymbols,On=Object.prototype.hasOwnProperty,zo=Object.prototype.propertyIsEnumerable,ao=(R,O,z)=>O in R?Ur(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,di=(R,O)=>{for(var z in O||(O={}))On.call(O,z)&&ao(R,z,O[z]);if(Xn)for(var z of Xn(O))zo.call(O,z)&&ao(R,z,O[z]);return R},Zn=(R,O)=>Mn(R,Kn(O));const Bn=Zn(di({currencyCode:"BCH",customFeeTemplate:At,displayName:"Bitcoin Cash",memoOptions:Ve,pluginId:"bitcoincash",walletType:"wallet:bitcoincash",blockExplorer:"https://blockchair.com/bitcoin-cash/block/%s",addressExplorer:"https://blockchair.com/bitcoin-cash/address/%s",transactionExplorer:"https://blockchair.com/bitcoin-cash/transaction/%s",xpubExplorer:"https://bch1.trezor.io/xpub/%s",denominations:[{name:"BCH",multiplier:"100000000",symbol:"\u20BF"},{name:"mBCH",multiplier:"100000",symbol:"m\u20BF"},{name:"cash",multiplier:"100",symbol:"\u0180"}]},tt),{defaultSettings:{customFeeSettings:["satPerByte"],blockbookServers:["wss://bch1.trezor.io","wss://bch2.trezor.io","wss://bch3.trezor.io","wss://bch4.trezor.io","wss://bch5.trezor.io"],enableCustomServers:!1},metaTokens:[]}),so={serverConfigs:[{type:"blockbook-nownode",uris:["https://bchbook.nownodes.io"]}],formats:["bip44","bip32"],forks:[],gapLimit:10,defaultFee:1e4,feeUpdateInterval:6e4,defaultFeeInfo:{lowFeeFudgeFactor:void 0,standardFeeLowFudgeFactor:void 0,standardFeeHighFudgeFactor:void 0,highFeeFudgeFactor:void 0,highFee:"20",lowFee:"3",standardFeeLow:"5",standardFeeHigh:"10",standardFeeLowAmount:"1000000",standardFeeHighAmount:"65000000",maximumFeeRate:Xe(Bn,212.86)},scriptTemplates:Jr,asBlockbookAddress:H(R=>h(R).split(":")[1],R=>`bitcoincash:${R}`)},Yn={name:"bitcoincash",segwit:!1,sighash:pe.iL.BCH_SIGHASH_ALL,coinType:145,prefixes:{messagePrefix:[`Bitcoin Signed Message:
|
|
54
54
|
`],wif:[128],legacyXPriv:[76066276],legacyXPub:[76067358],pubkeyHash:[0],scriptHash:[5],cashaddr:["bitcoincash"]}},pi={currencyInfo:Bn,engineInfo:so,coinInfo:Yn};var $n=Object.defineProperty,fo=Object.defineProperties,yn=Object.getOwnPropertyDescriptors,In=Object.getOwnPropertySymbols,Ni=Object.prototype.hasOwnProperty,fn=Object.prototype.propertyIsEnumerable,tn=(R,O,z)=>O in R?$n(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,Cr=(R,O)=>{for(var z in O||(O={}))Ni.call(O,z)&&tn(R,z,O[z]);if(In)for(var z of In(O))fn.call(O,z)&&tn(R,z,O[z]);return R},Rn=(R,O)=>fo(R,yn(O));const bn=Rn(Cr({currencyCode:"TBCH",displayName:"Bitcoin Cash",memoOptions:Ve,customFeeTemplate:At,pluginId:"bitcoincashtestnet",walletType:"wallet:bitcoincashtestnet",blockExplorer:"https://blockchair.com/bitcoin-cash/block/%s",addressExplorer:"https://blockchair.com/bitcoin-cash/address/%s",transactionExplorer:"https://blockchair.com/bitcoin-cash/transaction/%s",xpubExplorer:"https://blockchair.com/bitcoin-cash/xpub/%s",denominations:[{name:"TBCH",multiplier:"100000000",symbol:"\u20BF"},{name:"mTBCH",multiplier:"100000",symbol:"m\u20BF"},{name:"cash",multiplier:"100",symbol:"\u0180"}]},tt),{defaultSettings:{customFeeSettings:["satPerByte"],blockbookServers:[],enableCustomServers:!1},metaTokens:[]}),Qr={formats:["bip44","bip32"],forks:["bitcoinsv"],gapLimit:10,defaultFee:1e4,feeUpdateInterval:6e4,defaultFeeInfo:{lowFeeFudgeFactor:void 0,standardFeeLowFudgeFactor:void 0,standardFeeHighFudgeFactor:void 0,highFeeFudgeFactor:void 0,highFee:"20",lowFee:"3",standardFeeLow:"5",standardFeeHigh:"10",standardFeeLowAmount:"1000000",standardFeeHighAmount:"65000000"},scriptTemplates:Jr},rn={name:"bitcoincashtestnet",segwit:!1,sighash:pe.iL.BCH_SIGHASH_ALL,coinType:1,prefixes:{messagePrefix:[`Bitcoin Signed Message:
|
|
55
55
|
`],wif:[239],legacyXPriv:[70615956],legacyXPub:[70617039],pubkeyHash:[111],scriptHash:[196],cashaddr:["bchtest"]}},uo={currencyInfo:bn,engineInfo:Qr,coinInfo:rn};var Jn=Object.defineProperty,Ko=Object.defineProperties,Fr=Object.getOwnPropertyDescriptors,Cn=Object.getOwnPropertySymbols,lo=Object.prototype.hasOwnProperty,jo=Object.prototype.propertyIsEnumerable,Wo=(R,O,z)=>O in R?Jn(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,co=(R,O)=>{for(var z in O||(O={}))lo.call(O,z)&&Wo(R,z,O[z]);if(Cn)for(var z of Cn(O))jo.call(O,z)&&Wo(R,z,O[z]);return R},Ca=(R,O)=>Ko(R,Fr(O));const Go=Ca(co({currencyCode:"BTG",customFeeTemplate:At,displayName:"Bitcoin Gold",memoOptions:Ve,pluginId:"bitcoingold",walletType:"wallet:bitcoingold",addressExplorer:"https://explorer.bitcoingold.org/insight/address/%s",blockExplorer:"https://explorer.bitcoingold.org/insight/block/%s",transactionExplorer:"https://explorer.bitcoingold.org/insight/tx/%s",denominations:[{name:"BTG",multiplier:"100000000",symbol:"\u20BF"},{name:"mBTG",multiplier:"100000",symbol:"m\u20BF"},{name:"bits",multiplier:"100",symbol:"\u0180"}]},tt),{defaultSettings:{customFeeSettings:["satPerByte"],blockbookServers:["wss://btg1.trezor.io","wss://btg2.trezor.io","wss://btg3.trezor.io","wss://btg4.trezor.io","wss://btg5.trezor.io"],enableCustomServers:!1},metaTokens:[]}),Li={formats:["bip49","bip84","bip44","bip32"],gapLimit:10,defaultFee:1e3,feeUpdateInterval:6e4,defaultFeeInfo:{lowFeeFudgeFactor:void 0,standardFeeLowFudgeFactor:void 0,standardFeeHighFudgeFactor:void 0,highFeeFudgeFactor:void 0,highFee:"200",lowFee:"10",standardFeeLow:"15",standardFeeHigh:"140",standardFeeLowAmount:"17320",standardFeeHighAmount:"86700000",maximumFeeRate:Xe(Go,12.62)}},vi={name:"bitcoingold",segwit:!0,sighash:pe.iL.BTG_SIGHASH_ALL,coinType:156,prefixes:{messagePrefix:[`Bitcoin Gold Signed Message:
|
|
56
|
-
`],wif:[128],legacyXPriv:[76066276],legacyXPub:[76067358],wrappedSegwitXPriv:[77428856],wrappedSegwitXPub:[77429938],segwitXPriv:[78791436],segwitXPub:[78792518],pubkeyHash:[38],scriptHash:[23],bech32:["btg"]}},Vo={currencyInfo:Go,engineInfo:Li,coinInfo:vi};var Fa=Object.defineProperty,Rf=Object.defineProperties,
|
|
56
|
+
`],wif:[128],legacyXPriv:[76066276],legacyXPub:[76067358],wrappedSegwitXPriv:[77428856],wrappedSegwitXPub:[77429938],segwitXPriv:[78791436],segwitXPub:[78792518],pubkeyHash:[38],scriptHash:[23],bech32:["btg"]}},Vo={currencyInfo:Go,engineInfo:Li,coinInfo:vi};var Fa=Object.defineProperty,Rf=Object.defineProperties,Kr=Object.getOwnPropertyDescriptors,ho=Object.getOwnPropertySymbols,Cf=Object.prototype.hasOwnProperty,mi=Object.prototype.propertyIsEnumerable,qo=(R,O,z)=>O in R?Fa(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,Ff=(R,O)=>{for(var z in O||(O={}))Cf.call(O,z)&&qo(R,z,O[z]);if(ho)for(var z of ho(O))mi.call(O,z)&&qo(R,z,O[z]);return R},Nf=(R,O)=>Rf(R,Kr(O));const Lf=Nf(Ff({currencyCode:"TBTG",customFeeTemplate:At,displayName:"Bitcoin Gold",memoOptions:Ve,pluginId:"bitcoingoldtestnet",walletType:"wallet:bitcoingoldtestnet",addressExplorer:"https://explorer.bitcoingold.org/insight/address/%s",blockExplorer:"https://explorer.bitcoingold.org/insight/block/%s",transactionExplorer:"https://explorer.bitcoingold.org/insight/tx/%s",denominations:[{name:"TBTG",multiplier:"100000000",symbol:"\u20BF"},{name:"mTBTG",multiplier:"100000",symbol:"m\u20BF"},{name:"bits",multiplier:"100",symbol:"\u0180"}]},tt),{defaultSettings:{customFeeSettings:["satPerByte"],blockbookServers:[],enableCustomServers:!1},metaTokens:[]}),Df={formats:["bip49","bip84","bip44","bip32"],gapLimit:10,defaultFee:1e3,feeUpdateInterval:6e4,defaultFeeInfo:{lowFeeFudgeFactor:void 0,standardFeeLowFudgeFactor:void 0,standardFeeHighFudgeFactor:void 0,highFeeFudgeFactor:void 0,highFee:"200",lowFee:"10",standardFeeLow:"15",standardFeeHigh:"140",standardFeeLowAmount:"17320",standardFeeHighAmount:"86700000"}},Na={name:"bitcoingoldtestnet",segwit:!0,sighash:pe.iL.BTG_SIGHASH_ALL,coinType:1,prefixes:{messagePrefix:[`Bitcoin Gold Signed Message:
|
|
57
57
|
`],wif:[239],legacyXPriv:[70615956],legacyXPub:[70617039],wrappedSegwitXPriv:[71978536],wrappedSegwitXPub:[71979618],segwitXPriv:[73341116],segwitXPub:[73342198],pubkeyHash:[111],scriptHash:[196],bech32:["btg"]}},Uf={currencyInfo:Lf,engineInfo:Df,coinInfo:Na};var Hf=Object.defineProperty,zf=Object.defineProperties,La=Object.getOwnPropertyDescriptors,gi=Object.getOwnPropertySymbols,Da=Object.prototype.hasOwnProperty,Di=Object.prototype.propertyIsEnumerable,Ua=(R,O,z)=>O in R?Hf(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,Kf=(R,O)=>{for(var z in O||(O={}))Da.call(O,z)&&Ua(R,z,O[z]);if(gi)for(var z of gi(O))Di.call(O,z)&&Ua(R,z,O[z]);return R},jf=(R,O)=>zf(R,La(O));const Xo=jf(Kf({currencyCode:"BSV",customFeeTemplate:At,displayName:"Bitcoin SV",memoOptions:Ve,pluginId:"bitcoinsv",walletType:"wallet:bitcoinsv",blockExplorer:"https://whatsonchain.com/block/%s",addressExplorer:"https://whatsonchain.com/address/%s",transactionExplorer:"https://whatsonchain.com/tx/%s",denominations:[{name:"BSV",multiplier:"100000000",symbol:"\u20BF"},{name:"mBSV",multiplier:"100000",symbol:"m\u20BF"},{name:"cash",multiplier:"100",symbol:"\u0180"}]},tt),{defaultSettings:{customFeeSettings:["satPerByte"],blockbookServers:["wss://blockbook.siftbitcoin.com:9146"],enableCustomServers:!1},metaTokens:[]}),Zo={formats:["bip44","bip32"],uriPrefix:"bitcoin",gapLimit:10,defaultFee:1e4,feeUpdateInterval:6e4,defaultFeeInfo:{lowFeeFudgeFactor:void 0,standardFeeLowFudgeFactor:void 0,standardFeeHighFudgeFactor:void 0,highFeeFudgeFactor:void 0,highFee:"20",lowFee:"3",standardFeeLow:"5",standardFeeHigh:"10",standardFeeLowAmount:"1000000",standardFeeHighAmount:"65000000",maximumFeeRate:Xe(Xo,33.61)},asBlockbookAddress:H(R=>{const O=h(R);try{const z=O.replace("bitcoincash:",""),me=Ue({address:z,coin:"bitcoincash"});return $e({scriptPubkey:me,coin:"bitcoinsv",addressType:Ai.p2pkh}).address}catch{return O}},R=>R)},Ha={name:"bitcoinsv",segwit:!1,sighash:pe.iL.BCH_SIGHASH_ALL,coinType:236,prefixes:{messagePrefix:[`Bitcoin Signed Message:
|
|
58
58
|
`],wif:[128],legacyXPriv:[76066276],legacyXPub:[76067358],pubkeyHash:[0],scriptHash:[5]}},Wf={currencyInfo:Xo,engineInfo:Zo,coinInfo:Ha};var za=Object.defineProperty,Ka=Object.defineProperties,ja=Object.getOwnPropertyDescriptors,yi=Object.getOwnPropertySymbols,po=Object.prototype.hasOwnProperty,Fn=Object.prototype.propertyIsEnumerable,Wa=(R,O,z)=>O in R?za(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,Ga=(R,O)=>{for(var z in O||(O={}))po.call(O,z)&&Wa(R,z,O[z]);if(yi)for(var z of yi(O))Fn.call(O,z)&&Wa(R,z,O[z]);return R},Gf=(R,O)=>Ka(R,ja(O));const bi={currencyInfo:Gf(Ga({canReplaceByFee:!0,currencyCode:"TESTBTC",customFeeTemplate:At,displayName:"Bitcoin Testnet",memoOptions:Ve,pluginId:"bitcointestnet",walletType:"wallet:bitcointestnet",blockExplorer:"https://blockchair.com/bitcoin/testnet/block/%s",addressExplorer:"https://blockchair.com/bitcoin/testnet/address/%s",transactionExplorer:"https://blockchair.com/bitcoin/testnet/transaction/%s",denominations:[{name:"TESTBTC",multiplier:"100000000",symbol:"\u20BF"},{name:"mTESTBTC",multiplier:"100000",symbol:"m\u20BF"},{name:"bits",multiplier:"100",symbol:"\u0180"},{name:"sats",multiplier:"1",symbol:"s"}]},tt),{defaultSettings:{customFeeSettings:["satPerByte"],blockbookServers:["wss://tbtc1.trezor.io","wss://tbtc2.trezor.io"],enableCustomServers:!1},metaTokens:[]}),engineInfo:{formats:["bip49","bip84","bip44","bip32"],forks:["bitcoincash","bitcoingold"],gapLimit:25,defaultFee:1e3,feeUpdateInterval:6e4,mempoolSpaceFeeInfoServer:"https://mempool.space/api/v1/fees/recommended",defaultFeeInfo:{lowFeeFudgeFactor:void 0,standardFeeLowFudgeFactor:void 0,standardFeeHighFudgeFactor:void 0,highFeeFudgeFactor:void 0,highFee:"150",lowFee:"20",standardFeeLow:"50",standardFeeHigh:"100",standardFeeLowAmount:"173200",standardFeeHighAmount:"8670000"}},coinInfo:{name:"bitcointestnet",segwit:!0,coinType:1,prefixes:{messagePrefix:[`Bitcoin Signed Message:
|
|
59
59
|
`],wif:[239],legacyXPriv:[70615956],legacyXPub:[70617039],wrappedSegwitXPriv:[71978536],wrappedSegwitXPub:[71979618],segwitXPriv:[73341116],segwitXPub:[73342198],pubkeyHash:[111],scriptHash:[196],bech32:["tb"]}}};var Yo=Object.defineProperty,qf=Object.defineProperties,Va=Object.getOwnPropertyDescriptors,mo=Object.getOwnPropertySymbols,qa=Object.prototype.hasOwnProperty,Xa=Object.prototype.propertyIsEnumerable,Za=(R,O,z)=>O in R?Yo(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,Xf=(R,O)=>{for(var z in O||(O={}))qa.call(O,z)&&Za(R,z,O[z]);if(mo)for(var z of mo(O))Xa.call(O,z)&&Za(R,z,O[z]);return R},en=(R,O)=>qf(R,Va(O));const $o=en(Xf({currencyCode:"DASH",customFeeTemplate:At,displayName:"Dash",memoOptions:Ve,pluginId:"dash",walletType:"wallet:dash",addressExplorer:"https://blockchair.com/dash/address/%s?from=edgeapp",blockExplorer:"https://blockchair.com/dash/block/%s?from=edgeapp",transactionExplorer:"https://blockchair.com/dash/transaction/%s?from=edgeapp",denominations:[{name:"DASH",multiplier:"100000000",symbol:"\xD0"},{name:"mDASH",multiplier:"100000",symbol:"m\xD0"}]},tt),{defaultSettings:{customFeeSettings:["satPerByte"],blockbookServers:["wss://dash1.trezor.io","wss://dash2.trezor.io","wss://dash3.trezor.io","wss://dash4.trezor.io","wss://dash5.trezor.io"],enableCustomServers:!1},metaTokens:[]}),Zf={serverConfigs:[{type:"blockbook-nownode",uris:["https://dashbook.nownodes.io"]}],formats:["bip44","bip32"],gapLimit:10,defaultFee:1e4,feeUpdateInterval:6e4,defaultFeeInfo:{lowFeeFudgeFactor:void 0,standardFeeLowFudgeFactor:void 0,standardFeeHighFudgeFactor:void 0,highFeeFudgeFactor:void 0,highFee:"300",lowFee:"100",standardFeeLow:"150",standardFeeHigh:"200",standardFeeLowAmount:"20000000",standardFeeHighAmount:"981000000",maximumFeeRate:Xe($o,25.8)},txSpecificHandling:(R,O)=>{const z=F({instantlock:n(f)}),me=G(z)(O);return(me==null?void 0:me.instantlock)===!0&&(R.confirmations="confirmed"),R}},Qn={currencyInfo:$o,engineInfo:Zf,coinInfo:{name:"dash",segwit:!1,coinType:5,prefixes:{messagePrefix:["unused"],wif:[204],legacyXPriv:[50221816],legacyXPub:[50221772],pubkeyHash:[76],scriptHash:[16]}}};var Ya=Object.defineProperty,go=Object.defineProperties,En=Object.getOwnPropertyDescriptors,yo=Object.getOwnPropertySymbols,Hi=Object.prototype.hasOwnProperty,Yf=Object.prototype.propertyIsEnumerable,$a=(R,O,z)=>O in R?Ya(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,Nn=(R,O)=>{for(var z in O||(O={}))Hi.call(O,z)&&$a(R,z,O[z]);if(yo)for(var z of yo(O))Yf.call(O,z)&&$a(R,z,O[z]);return R},$f=(R,O)=>go(R,En(O));const xi=$f(Nn({currencyCode:"DGB",customFeeTemplate:At,displayName:"DigiByte",memoOptions:Ve,pluginId:"digibyte",walletType:"wallet:digibyte",addressExplorer:"https://digiexplorer.info/address/%s",blockExplorer:"https://digiexplorer.info/block/%s",transactionExplorer:"https://digiexplorer.info/tx/%s",denominations:[{name:"DGB",multiplier:"100000000",symbol:"\u018A"},{name:"mDGB",multiplier:"100000",symbol:"m\u018A"}]},tt),{defaultSettings:{customFeeSettings:["satPerByte"],blockbookServers:["wss://dgb1.trezor.io","wss://dgb2.trezor.io"],enableCustomServers:!1},metaTokens:[]}),Ja={serverConfigs:[{type:"blockbook-nownode",uris:["https://dgbbook.nownodes.io"]}],formats:["bip49","bip84","bip44","bip32"],forks:[],gapLimit:10,defaultFee:1e3,feeUpdateInterval:6e4,defaultFeeInfo:{lowFeeFudgeFactor:void 0,standardFeeLowFudgeFactor:void 0,standardFeeHighFudgeFactor:void 0,highFeeFudgeFactor:void 0,highFee:"150",lowFee:"20",standardFeeLow:"50",standardFeeHigh:"100",standardFeeLowAmount:"173200",standardFeeHighAmount:"8670000",maximumFeeRate:Xe(xi,.006176)}},bo={currencyInfo:xi,engineInfo:Ja,coinInfo:{name:"digibyte",segwit:!0,coinType:20,prefixes:{messagePrefix:[`Digibyte Signed Message:
|
|
@@ -68,9 +68,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
68
68
|
`],wif:[191],legacyXPriv:[76066276],legacyXPub:[76067358],pubkeyHash:[63],scriptHash:[18]}},tl={currencyInfo:Zs,engineInfo:Qu,coinInfo:el};var Ys=Object.defineProperty,rl=Object.defineProperties,nl=Object.getOwnPropertyDescriptors,$s=Object.getOwnPropertySymbols,Js=Object.prototype.hasOwnProperty,il=Object.prototype.propertyIsEnumerable,ga=(R,O,z)=>O in R?Ys(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,ni=(R,O)=>{for(var z in O||(O={}))Js.call(O,z)&&ga(R,z,O[z]);if($s)for(var z of $s(O))il.call(O,z)&&ga(R,z,O[z]);return R},Qs=(R,O)=>rl(R,nl(O));const ya=Qs(ni({currencyCode:"UFO",customFeeTemplate:At,displayName:"UFO",memoOptions:Ve,pluginId:"ufo",walletType:"wallet:ufo",addressExplorer:"https://explorer.ufobject.com/address/%s",blockExplorer:"https://explorer.ufobject.com/block/%s",transactionExplorer:"https://explorer.ufobject.com/tx/%s",denominations:[{name:"UFO",multiplier:"100000000",symbol:"\u0244"},{name:"kUFO",multiplier:"100000000000",symbol:"k\u0244"}]},tt),{defaultSettings:{customFeeSettings:["satPerByte"],blockbookServers:["wss://blockbook.ufobject.com"],enableCustomServers:!1},metaTokens:[]}),ol={formats:["bip49","bip84","bip44","bip32"],gapLimit:10,defaultFee:5e4,feeUpdateInterval:6e4,defaultFeeInfo:{lowFeeFudgeFactor:void 0,standardFeeLowFudgeFactor:void 0,standardFeeHighFudgeFactor:void 0,highFeeFudgeFactor:void 0,highFee:"2250",lowFee:"1000",standardFeeLow:"1100",standardFeeHigh:"2000",standardFeeLowAmount:"51282051282051",standardFeeHighAmount:"5128205128205100",maximumFeeRate:Xe(ya,137e-6)}},ef={currencyInfo:ya,engineInfo:ol,coinInfo:{name:"uniformfiscalobject",segwit:!0,coinType:202,prefixes:{messagePrefix:[`Bitcoin Signed Message:
|
|
69
69
|
`],wif:[155],legacyXPriv:[76066276],legacyXPub:[76067358],wrappedSegwitXPriv:[77428856],wrappedSegwitXPub:[77429938],segwitXPriv:[78791436],segwitXPub:[78792518],pubkeyHash:[27],scriptHash:[68,5],bech32:["uf"]}}};var sl=Object.defineProperty,tf=Object.defineProperties,fl=Object.getOwnPropertyDescriptors,ba=Object.getOwnPropertySymbols,rf=Object.prototype.hasOwnProperty,wa=Object.prototype.propertyIsEnumerable,xa=(R,O,z)=>O in R?sl(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,nf=(R,O)=>{for(var z in O||(O={}))rf.call(O,z)&&xa(R,z,O[z]);if(ba)for(var z of ba(O))wa.call(O,z)&&xa(R,z,O[z]);return R},ul=(R,O)=>tf(R,fl(O));const of=ul(nf({currencyCode:"VTC",customFeeTemplate:At,displayName:"Vertcoin",memoOptions:Ve,pluginId:"vertcoin",walletType:"wallet:vertcoin",addressExplorer:"https://insight.vertcoin.org/address/%s",blockExplorer:"https://insight.vertcoin.org/block/%s",transactionExplorer:"https://insight.vertcoin.org/tx/%s",denominations:[{name:"VTC",multiplier:"100000000",symbol:"V"},{name:"mVTC",multiplier:"100000",symbol:"mV"}]},tt),{defaultSettings:{customFeeSettings:["satPerByte"],blockbookServers:["wss://vtc1.trezor.io","wss://vtc2.trezor.io","wss://vtc3.trezor.io","wss://vtc4.trezor.io","wss://vtc5.trezor.io"],enableCustomServers:!1},metaTokens:[]}),af={formats:["bip49","bip84","bip44","bip32"],forks:[],gapLimit:10,defaultFee:1e3,feeUpdateInterval:6e4,defaultFeeInfo:{lowFeeFudgeFactor:void 0,standardFeeLowFudgeFactor:void 0,standardFeeHighFudgeFactor:void 0,highFeeFudgeFactor:void 0,highFee:"150",lowFee:"20",standardFeeLow:"50",standardFeeHigh:"100",standardFeeLowAmount:"173200",standardFeeHighAmount:"8670000",maximumFeeRate:Xe(of,.04662)}},ll={currencyInfo:of,engineInfo:af,coinInfo:{name:"vertcoin",segwit:!0,coinType:28,prefixes:{messagePrefix:[`Bitcoin Signed Message:
|
|
70
70
|
`],wif:[128],legacyXPriv:[76066276],legacyXPub:[76067358],wrappedSegwitXPriv:[76066276],wrappedSegwitXPub:[76067358],segwitXPriv:[76066276],segwitXPub:[76067358],pubkeyHash:[71],scriptHash:[5],bech32:["vtc"]}}};var sf=Object.defineProperty,ff=Object.defineProperties,uf=Object.getOwnPropertyDescriptors,lf=Object.getOwnPropertySymbols,cl=Object.prototype.hasOwnProperty,cf=Object.prototype.propertyIsEnumerable,Ma=(R,O,z)=>O in R?sf(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,hf=(R,O)=>{for(var z in O||(O={}))cl.call(O,z)&&Ma(R,z,O[z]);if(lf)for(var z of lf(O))cf.call(O,z)&&Ma(R,z,O[z]);return R},df=(R,O)=>ff(R,uf(O));const Ii=df(hf({currencyCode:"FIRO",customFeeTemplate:At,displayName:"Firo",memoOptions:Ve,pluginId:"zcoin",walletType:"wallet:zcoin",addressExplorer:"https://insight.zcoin.io/address/%s",blockExplorer:"https://insight.zcoin.io/block/%s",transactionExplorer:"https://insight.zcoin.io/tx/%s",denominations:[{name:"FIRO",multiplier:"100000000",symbol:"\u0192"},{name:"mFIRO",multiplier:"100000",symbol:"m\u0192"}]},tt),{defaultSettings:{customFeeSettings:["satPerByte"],blockbookServers:["wss://blockbook.firo.org"],enableCustomServers:!1},metaTokens:[]}),hl={serverConfigs:[{type:"blockbook-nownode",uris:["https://firobook.nownodes.io"]}],formats:["bip44","bip32"],uriPrefix:"firo",gapLimit:10,defaultFee:1e3,feeUpdateInterval:6e4,defaultFeeInfo:{lowFeeFudgeFactor:void 0,standardFeeLowFudgeFactor:void 0,standardFeeHighFudgeFactor:void 0,highFeeFudgeFactor:void 0,highFee:"150",lowFee:"20",standardFeeLow:"50",standardFeeHigh:"100",standardFeeLowAmount:"173200",standardFeeHighAmount:"8670000",maximumFeeRate:Xe(Ii,1.39)}},Oo=[Dt,$t,pi,uo,Vo,Uf,Wf,bi,Qn,bo,jn,bu,Su,_o,Uu,Gu,js,tl,ef,ll,{currencyInfo:Ii,engineInfo:hl,coinInfo:{name:"zcoin",segwit:!1,coinType:136,prefixes:{messagePrefix:[`Zcoin Signed Message:
|
|
71
|
-
`],wif:[210],legacyXPriv:[76066276],legacyXPub:[76067358],pubkeyHash:[82],scriptHash:[7]}}}];function un(R){const O=Oo.find(z=>z.coinInfo.name===R);if(O==null)throw new Error("Could not find coin info "+R);return O.coinInfo}var Wt=er(3689);const pl=Wt.WK,vl=Wt.DE,ml=Wt.k5,gl=Wt.Dr,yl=Wt.ef,Xc=Wt.GY,Zc=Wt.WM,bl=Wt.Kz,Yc=Wt.uX,$c=Wt.IK,Ea=Wt.gw,wl=Wt.WU,xl=Wt.G8,Jc=Wt.xQ,pf=Wt.D7,Qc=Wt.hi,e0=Wt.zU,Ml=Wt.dq,t0=Wt.m$,r0=Wt.MU,vf=Wt.ID,El=Wt.k0,Sl=Wt.D4,n0=Wt.kL,i0=Wt.jx,o0=Wt.A_,kl=Wt.v1,mf=Wt.TL,gf=Wt.Og,a0=Wt.ft,s0=Wt.KU,f0=Wt.ZU,u0=Wt.ye,l0=Wt.Xj,c0=Wt.Rn,Sa=Wt.bo,h0=Wt.KL,yf=Wt.rW,d0=Wt.U3,p0=Wt.$Y,v0=Wt.EJ,m0=Wt.XY,g0=Wt.v7,y0=Wt.up,b0=Wt.h,w0=Wt.Cx,x0=Wt.Zz,M0=Wt.CU,bf=Wt.ib,E0=Wt.eT,S0=Wt._0,k0=Wt.UR,_0=Wt.Up,Wn=Wt.y0,I0=Wt.A2,A0=Wt.ql,T0=Wt.FX,P0=Wt.Jr,O0=Wt.zS,B0=Wt.pK,_l=Wt.ud,R0=Wt.Zk,Il=Wt.Mf,C0=Wt.U0,wf=Wt.CX,F0=Wt.l4,Al=Wt.Jv,N0=Wt.T0,L0=Wt.z8,Bo=Wt.Gt,Tl=Wt.Fm,Ir=Wt.b4,ln=Wt.N2,Zi=Wt.K8,Er=Wt.gB,An=Wt.bd,D0=Wt.GG,Yi=Wt.V$,Nr=Wt.CC,ka=Wt.dT,U0=Wt.uT,vn=Wt._j,Pl=Wt.p4,Ol=Wt.W0,Bl=Wt.zk,H0=Wt.AB,Rl=Wt.sn,z0=Wt._u,K0=Wt.Py,Cl=Wt.iu,j0=Wt.l7,Fl=Wt.JU,W0=Wt.O6;class xf extends ml{constructor(O){super(O);const{networkFeeShortage:z}=O;this.networkFeeShortage=z}}function Nl(R){return function(z){if(z instanceof Error&&z.name===R)return z}}const Ll=Nl("InsufficientFundsError"),Dl={forceUseUtxo:hs,subtractFee:So,accumulative:ss};var Gr=er(8287).Buffer,Ro=Object.defineProperty,Ul=Object.defineProperties,Hl=Object.getOwnPropertyDescriptors,Mf=Object.getOwnPropertySymbols,zl=Object.prototype.hasOwnProperty,Kl=Object.prototype.propertyIsEnumerable,_a=(R,O,z)=>O in R?Ro(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,jl=(R,O)=>{for(var z in O||(O={}))zl.call(O,z)&&_a(R,z,O[z]);if(Mf)for(var z of Mf(O))Kl.call(O,z)&&_a(R,z,O[z]);return R},Wl=(R,O)=>Ul(R,Hl(O)),Gl=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});let ii;er.e(669).then(er.bind(er,7050)).then(R=>{(0,pe.f0)(R),ii=(0,Pe.dg)(R)}).catch(R=>{console.error(R)}).finally(()=>{console.log("loaded ECPair!")});var Sr=(R=>(R.Airbitz="airbitz",R.Legacy="legacy",R.Segwit="segwit",R.WrappedSegwit="wrappedSegwit",R.ReplayProtection="replayProtection",R))(Sr||{}),Ai=(R=>(R.p2pkh="p2pkh",R.p2sh="p2sh",R.p2wpkh="p2wpkh",R.p2wsh="p2wsh",R.p2tr="p2tr",R))(Ai||{}),wn=(R=>(R.p2wpkh="p2wpkh",R.p2wpkhp2sh="p2wpkhp2sh",R.p2wsh="p2wsh",R.p2pk="p2pk",R.p2pkh="p2pkh",R.p2sh="p2sh",R.p2tr="p2tr",R.replayProtection="replayprotection",R.replayProtectionP2SH="replayprotectionp2sh",R))(wn||{});const Vl=i("p2wpkh","p2wpkhp2sh","p2wsh","p2pk","p2pkh","p2sh","p2tr","replayprotection","replayprotectionp2sh");var ql=(R=>(R.Legacy="legacy",R.Segwit="segwit",R))(ql||{}),Ia=(R=>(R.good="good",R.legacy="legacy",R.bad="bad",R))(Ia||{});function Aa(R){switch(R){case 32:return"airbitz";case 44:return"legacy";case 49:return"wrappedSegwit";case 84:return"segwit";default:throw new Error("InvalidPurposeNumber")}}const Xl=(R,O)=>{const z=un(O.coin),me=kr({coinString:O.coin,prefixIndex:R}),Me=Vr(z);if(Me.length>0){try{return Ze(O.address,Me),"good"}catch{}return on(O.address,me,O.coin,void 0),"legacy"}return on(O.address,me,O.coin,void 0),R===0?"good":"legacy"},Zl=R=>{const O=Lr(R.coin,z=>Xl(z,R),[`Could not determine address type of ${R.address}`]);return O!=null?O:"bad"},_=(R,O)=>{const z=Lr(O,me=>{const Me=kr({coinString:O,prefixIndex:me});return on(R,Me,O)},[`Could not determine address type of ${R}`]);if(z==null)throw new Error("Could not determine address type");return z};function P(R){var O,z,me;const Me=R.seed.includes(" "),Re=Me?te.kw(R.seed):Gr.from(R.seed,"base64"),Se=kr({coinString:R.coin,sigType:R.type,prefixIndex:0}),ke=un(R.coin),_e=_r(R.type),Te=(O=R.coinType)!=null?O:ke.coinType,We=(z=R.account)!=null?z:0,it=((me=ke.bip32FromSeedFunc)!=null?me:ce.CC)(Re);return it.network=Se,_e===32||!Me?it.derive(0).toBase58():it.deriveHardened(_e).deriveHardened(Te).deriveHardened(We).toBase58()}const W=(R,O)=>{var z;const me=kr({coinString:O.coin,sigType:O.type,prefixIndex:R});return((z=un(O.coin).bip32FromBase58Func)!=null?z:ce.n3)(O.xpriv,me).neutered().toBase58()},X=R=>{const O=Lr(R.coin,z=>W(z,R),["Invalid private key"]);if(O==null)throw Error("unable to convert xpriv to xpub");return O};function ne(R){let O="0000";return O=pe.Et.hash160(Gr.from(R(""),"hex")).slice(0,4).toString("hex"),parseInt(O,16)}const se=(R,O)=>O.changeIndex===ne(R),de=(R,O)=>{var z;const me=un(O.coin),Me=kr({coinString:O.coin,sigType:O.type,prefixIndex:R});return((z=me.bip32FromBase58Func)!=null?z:ce.n3)(O.xpub,Me).derive(O.bip44ChangeIndex).derive(O.bip44AddressIndex).publicKey.toString("hex")},Be=R=>{const O=Lr(R.coin,z=>de(z,R),["Invalid network version"]);if(O==null)throw Error("unable to derive pubkey from xpub");return O},Ae=(R,O)=>{const z=un(O.coin),me=Vr(z),Me=kr({coinString:O.coin,prefixIndex:R}),Re=kn(z.prefixes,R),Se=on(O.address,Me,O.coin,O.addressType);let ke;const _e=()=>{try{return Ze(O.address,me).scriptHash.toString("hex")}catch{}};switch(Se){case"p2pkh":if(Re.cashaddr!=null){const We=_e();if(We!=null){const Je=mn({scriptHash:We,scriptType:"p2pkh",coin:O.coin});if(Je==null)throw new Error(`unable to convert address ${O.address} to script pubkey`);return Je}}ke=pe.KT.p2pkh;break;case"p2sh":if(Re.cashaddr!=null){const We=_e();if(We!=null){const Je=mn({scriptHash:We,scriptType:"p2sh",coin:O.coin});if(Je==null)throw new Error(`unable to convert address ${O.address} to script pubkey`);return Je}}ke=pe.KT.p2sh;break;case"p2wpkh":ke=pe.KT.p2wpkh;break;case"p2wsh":ke=pe.KT.p2wsh;break;case"p2tr":ke=pe.KT.p2tr;break;default:throw new Error("invalid address type in address to script pubkey")}let Te;try{Te=ke({address:O.address,network:Me,bs58DecodeFunc:z.bs58DecodeFunc,bs58EncodeFunc:z.bs58EncodeFunc}).output}catch(We){throw console.trace(We),We}if(Te==null)throw new Error("failed converting address to scriptPubkey");return Te.toString("hex")},Ue=R=>{const O=Lr(R.coin,z=>Ae(z,R),["Invalid version or Network mismatch","Invalid prefix or Network mismatch",`InvalidArgument: ${R.address} has Mixed case`,`Could not determine address type of ${R.address}`]);if(O==null)throw new Error(`unable to convert address ${R.address} to script pubkey`);return O};function $e(R){const O=kr({coinString:R.coin,prefixIndex:0}),z=kr({coinString:R.coin,prefixIndex:1}),me=un(R.coin),Me=me.prefixes,Re=kn(Me,0),Se=kn(Me,1);let ke,_e,Te;switch(R.addressType){case"p2pkh":Re.cashaddr!=null&&(ke=Ke(nt({scriptPubkey:R.scriptPubkey,scriptType:"p2pkh",coin:R.coin}),Ee.pubkeyhash,Re.cashaddr)),Se.cashaddr!=null&&(_e=Ke(nt({scriptPubkey:R.scriptPubkey,scriptType:"p2pkh",coin:R.coin}),Ee.pubkeyhash,Se.cashaddr)),Te=pe.KT.p2pkh;break;case"p2sh":Re.cashaddr!=null&&(ke=Ke(nt({scriptPubkey:R.scriptPubkey,scriptType:"p2sh",coin:R.coin}),Ee.scripthash,Re.cashaddr)),Se.cashaddr!=null&&(_e=Ke(nt({scriptPubkey:R.scriptPubkey,scriptType:"p2sh",coin:R.coin}),Ee.scripthash,Se.cashaddr)),Te=pe.KT.p2sh;break;case"p2wpkh":Te=pe.KT.p2wpkh;break;case"p2wsh":Te=pe.KT.p2wsh;break;case"p2tr":Te=pe.KT.p2tr;break;default:throw new Error("invalid address type in address to script pubkey")}try{ke=ke!=null?ke:Te({output:Gr.from(R.scriptPubkey,"hex"),network:O,bs58DecodeFunc:me.bs58DecodeFunc,bs58EncodeFunc:me.bs58EncodeFunc}).address,_e=_e!=null?_e:Te({output:Gr.from(R.scriptPubkey,"hex"),network:z,bs58DecodeFunc:me.bs58DecodeFunc,bs58EncodeFunc:me.bs58EncodeFunc}).address}catch(We){throw console.trace(We),We}if(ke==null||_e==null)throw new Error("failed converting scriptPubkey to address");return{address:ke,legacyAddress:_e}}function nt(R){const O=kr({coinString:R.coin,prefixIndex:0});let z;switch(R.scriptType){case"p2pkh":z=pe.KT.p2pkh;break;case"p2sh":z=pe.KT.p2sh;break;case"p2wpkh":z=pe.KT.p2wpkh;break;case"p2tr":z=pe.KT.p2tr;break;default:throw new Error("invalid address type in address to script pubkey")}let me;try{me=z({output:Gr.from(R.scriptPubkey,"hex"),network:O}).hash}catch(Me){throw console.trace(Me),Me}if(me==null)throw new Error("failed converting scriptPubkey to address");return me.toString("hex")}function Ye(R){var O,z,me,Me;const{scriptPubkey:Re,coin:Se}=R;let ke;Se!=null&&(ke=kr({coinString:Se,prefixIndex:0}));const _e=pe.KT.p2sh(Wl(jl({},ke!=null?{network:ke}:{}),{redeem:{output:Gr.from(Re,"hex")}})),Te=(O=_e.output)==null?void 0:O.toString("hex"),We=(me=(z=_e.redeem)==null?void 0:z.output)==null?void 0:me.toString("hex"),Je=(Me=_e.hash)==null?void 0:Me.toString("hex");if(Te==null||We==null)throw new Error("unable to convert script to p2sh");let it=_e.address;if(Se!=null&&Je!=null){const dt=un(Se).prefixes,pt=kn(dt,0);pt.cashaddr!=null&&(it=Ke(Je,Ee.scripthash,pt.cashaddr))}return{scriptPubkey:Te,redeemScript:We,address:it}}function vt(R){let O;switch(R.scriptType){case"p2pkh":{if(O=pe.KT.p2pkh({pubkey:Gr.from(R.pubkey,"hex")}),O.output==null)throw new Error("failed converting pubkey to script pubkey");return{scriptPubkey:O.output.toString("hex")}}case"p2wpkhp2sh":return Ye({scriptPubkey:vt({pubkey:R.pubkey,scriptType:"p2wpkh"}).scriptPubkey});case"p2wpkh":{if(O=pe.KT.p2wpkh({pubkey:Gr.from(R.pubkey,"hex")}),O.output==null)throw new Error("failed converting pubkey to script pubkey");return{scriptPubkey:O.output.toString("hex")}}case"p2tr":{if(O=pe.KT.p2tr({pubkey:Gr.from(R.pubkey,"hex")}),O.output==null)throw new Error("failed converting pubkey to script pubkey");return{scriptPubkey:O.output.toString("hex")}}case"replayprotection":{if(R.scriptTemplates==null)throw new Error("Missing replayProtection script template");const z=R.scriptTemplates.replayProtection(R.pubkey);return Ye({scriptPubkey:z})}default:throw new Error("invalid address type in pubkey to script pubkey")}}const Et=(R,O)=>{const z=_(R,O);return $e({scriptPubkey:Ue({address:R,coin:O}),addressType:z,coin:O}).address},mt=(R,O)=>{var z,me;const Me=un(O.coin),Re=kr({coinString:O.coin,sigType:O.type,prefixIndex:R});return(me=((z=Me.bip32FromBase58Func)!=null?z:ce.n3)(O.xpriv,Re).derive(O.bip44ChangeIndex).derive(O.bip44AddressIndex).privateKey)==null?void 0:me.toString("hex")},Mt=R=>{const O=Lr(R.coin,z=>mt(z,R),["Invalid network version"]);if(O==null)throw new Error("Failed to generate private key from xpriv");return O};function Ot(R){const O=kr({coinString:R.coin,forWIF:!0,prefixIndex:0}),z=getCoinFromString(R.coin);return ii.fromPrivateKey(Gr.from(R.privateKey,"hex"),{network:O}).toWIF(z.wifEncodeFunc)}const Vt=(R,O)=>{const z=un(O.coin),me=kr({coinString:O.coin,forWIF:!0,prefixIndex:R}),Me=ii.fromWIF(O.wifKey,me,z.bs58DecodeFunc);if(Me.privateKey!=null)return{hex:Me.privateKey.toString("hex"),compressed:Me.compressed}},Zt=R=>{const O=Lr(R.coin,z=>Vt(z,R),["Invalid network version"]);if(O==null)throw new Error("Failed to convert WIF key to private key");return O};function ir(R){const{hex:O,compressed:z}=R;return ii.fromPrivateKey(Gr.from(O,"hex"),{compressed:z}).publicKey.toString("hex")}function vr(R,O){const z=ii.fromPrivateKey(Gr.from(O,"hex"));if(z.privateKey==null)throw new Error("Address could not sign message");return ge().sign(R,z.privateKey,z.compressed).toString("base64")}function yr(R){var O,z,me,Me,Re,Se;const{log:ke,outputSort:_e,memos:Te}=R;let We=4294967295;R.enableRbf&&(We-=2);let Je=pe.ZX.SIGHASH_ALL;const it=un(R.coin);it.sighash!=null&&(Je=it.sighash);const ct=[],dt=[],St=[...[...R.utxos,...R.forceUseUtxo].filter(It=>!It.spent).reduce((It,wt)=>It.set(wt.id,wt),new Map).values()].sort((It,wt)=>It.blockHeight<=0&&wt.blockHeight>0?1:wt.blockHeight<=0&&It.blockHeight>0?-1:(0,Ge.lt)(It.value,wt.value)?1:(0,Ge.gt)(It.value,wt.value)?-1:0);for(const It of St){if(It.script==null)continue;const wt={hash:Gr.from(It.txid,"hex").reverse(),index:It.vout,value:parseInt(It.value),script:Gr.from(It.script,"hex"),scriptPubkey:Gr.from(It.scriptPubkey,"hex"),scriptType:It.scriptType,sequence:We,sighashType:Je};switch(It.scriptType){case"p2pk":case"p2pkh":case"p2sh":case"replayprotection":case"replayprotectionp2sh":{wt.nonWitnessUtxo=wt.script;break}case"p2wpkh":case"p2wpkhp2sh":case"p2wsh":{wt.witnessUtxo={script:wt.script,value:parseInt(It.value)};break}default:throw new Error(`unknown script type ${It.scriptType}`)}It.redeemScript!=null&&(wt.redeemScript=Gr.from(It.redeemScript,"hex"));let Nt=!1;for(const Rt of R.forceUseUtxo)Rt.id===It.id&&(ct.push(wt),Nt=!0);Nt||dt.push(wt)}const Ut=[];for(const It of R.targets){if(It.value==null)continue;const wt=It.address==null?It.scriptPubkey:Ue({address:It.address,coin:it.name});wt!=null&&Ut.push({script:wt,value:It.value})}for(const It of Te){const wt=It.type==="text"?Gr.from(It.value,"utf8"):Gr.from(It.value,"hex"),Nt=pe.K$.compile([pe.Ez.OP_RETURN,wt]).toString("hex");Ut.push({script:Nt,value:0})}const Jt=Ue({address:R.freshChangeAddress,coin:it.name}),ur=(O=it.utxoPicker)!=null?O:Dl,Bt=(R.forceUseUtxo.length>0?ur.forceUseUtxo:(z=R.subtractFee)!=null&&z?ur.subtractFee:ur.accumulative)({utxos:dt,useUtxos:ct,targets:Ut,feeRate:R.feeRate,changeScript:Jt});if(Bt.outputs==null){const It=pn(Ut),wt=pn(Bt.inputs),Nt=Bt.fee-(wt-It);throw new xf({tokenId:null,networkFee:Bt.fee.toString(),networkFeeShortage:Nt.toString()})}const Lt=kt(Bt.inputs),Ft=(()=>{switch(_e){case"bip69":return ae(Bt.outputs);case"targets":return Bt.outputs}})(),jt=new pe.iL;try{jt.addInputs(Lt),jt.addOutputs(Ft)}catch(It){throw ke==null||ke.error(`Failed makeTx: ${String(It)}`),It}return{inputs:Lt,outputs:Ft,changeUsed:Bt.changeUsed,fee:Bt.fee,psbtBase64:jt.toBase64(),hex:(Se=(Re=(Me=(me=jt.data)==null?void 0:me.globalMap)==null?void 0:Me.unsignedTx)==null?void 0:Re.toBuffer())==null?void 0:Se.toString("hex")}}function Pr(R){return Gl(this,null,function*(){var O;const{maximumFeeRate:z}=R.feeInfo,me=z!=null?{maximumFeeRate:parseInt(z)}:{},Me=pe.iL.fromBase64(R.psbtBase64,me),Re=un(R.coin),Se=(_e,Te,We)=>ii.fromPublicKey(_e).verify(Te,We);for(let _e=0;_e<Me.inputCount;_e++){const Te=(O=R.privateKeyEncodings[_e])!=null?O:R.privateKeyEncodings[R.privateKeyEncodings.length-1],{hex:We,compressed:Je}=Te;Me.signInput(_e,ii.fromPrivateKey(Gr.from(We,"hex"),{compressed:Je}),pe.iL.DEFAULT_SIGHASHES,Re.sighashFunction),Me.validateSignaturesOfInput(_e,Se),Me.finalizeInput(_e)}const ke=Me.extractTransaction();return{id:ke.getId(Re.txHashFunction),hex:ke.toHex()}})}const kr=R=>{var O,z;const me=(O=R.sigType)!=null?O:"legacy",Me=(z=R.forWIF)!=null?z:!1,Re=un(R.coinString);return Ar(me,Re.prefixes,Re.segwit,Me,R.prefixIndex)},Ar=(R,O,z,me,Me)=>{var Re;let Se;const ke=kn(O,Me);switch(R){case"segwit":if(ke.segwitXPub==null||ke.segwitXPriv==null)throw new Error("segwit xpub prefix is undefined");Se={public:ke.segwitXPub,private:ke.segwitXPriv};break;case"wrappedSegwit":if(ke.wrappedSegwitXPub==null||ke.wrappedSegwitXPriv==null)throw new Error("wrapped segwit xpub prefix is undefined");Se={public:ke.wrappedSegwitXPub,private:ke.wrappedSegwitXPriv};break;case"legacy":case"airbitz":Se={public:ke.legacyXPub,private:ke.legacyXPriv};break;default:throw new Error("invalid bip43 purpose type")}const _e=(Re=ke.bech32)!=null?Re:"";return me?{messagePrefix:ke.messagePrefix,wif:ke.wif,bip32:Se,bech32:_e,pubKeyHash:ke.pubkeyHash,scriptHash:ke.scriptHash}:{messagePrefix:ke.messagePrefix,wif:128,bip32:Se,bech32:_e,pubKeyHash:ke.pubkeyHash,scriptHash:ke.scriptHash}},_r=R=>{switch(R){case"airbitz":return 32;case"legacy":return 44;case"wrappedSegwit":return 49;case"segwit":return 84;case"replayProtection":return 44}},Lr=(R,O,z=[])=>{const me=un(R).prefixes,Me=Object.values(me).reduce((Se,ke)=>Math.max(ke.length,Se),0);let Re;for(let Se=0;Se<Me;Se++){try{Re=O(Se)}catch(ke){if(z.includes(ke.message))continue;throw ke}if(Re!=null)break}return Re},Vr=R=>{var O;return(O=R.prefixes.cashaddr)!=null?O:[]},on=(R,O,z,me)=>{if(me!=null)return me;const Me=un(z);try{return pe.KT.p2pkh({address:R,network:O,bs58DecodeFunc:Me.bs58DecodeFunc,bs58EncodeFunc:Me.bs58EncodeFunc}),"p2pkh"}catch{}try{return pe.KT.p2sh({address:R,network:O,bs58DecodeFunc:Me.bs58DecodeFunc,bs58EncodeFunc:Me.bs58EncodeFunc}),"p2sh"}catch{}try{return pe.KT.p2wsh({address:R,network:O}),"p2wsh"}catch{}try{return pe.KT.p2wpkh({address:R,network:O}),"p2wpkh"}catch{}try{return pe.KT.p2tr({address:R,network:O}),"p2tr"}catch{}const Re=Vr(Me);if(Re.length>0)try{return Ze(R,Re).type===Ee.pubkeyhash?"p2pkh":"p2sh"}catch{}throw new Error(`Could not determine address type of ${R}`)},kn=(R,O)=>{var z;return{messagePrefix:lt(R.messagePrefix,O),wif:lt(R.wif,O),legacyXPriv:lt(R.legacyXPriv,O),legacyXPub:lt(R.legacyXPub,O),wrappedSegwitXPriv:lt(R.wrappedSegwitXPriv,O),wrappedSegwitXPub:lt(R.wrappedSegwitXPub,O),segwitXPriv:lt(R.segwitXPriv,O),segwitXPub:lt(R.segwitXPub,O),pubkeyHash:lt(R.pubkeyHash,O),scriptHash:lt(R.scriptHash,O),bech32:lt(R.bech32,O),cashaddr:Le(((z=R.cashaddr)!=null?z:[])[O])}},mn=R=>{const O=kr({coinString:R.coin,prefixIndex:0});let z;switch(R.scriptType){case"p2pkh":z=pe.KT.p2pkh;break;case"p2sh":z=pe.KT.p2sh;break;case"p2wpkh":z=pe.KT.p2wpkh;break;case"p2tr":z=pe.KT.p2tr;break;default:throw new Error("invalid address type in address to script pubkey")}let me;try{me=z({hash:Gr.from(R.scriptHash,"hex"),network:O}).output}catch(Me){throw console.trace(Me),Me}if(me==null)throw new Error("failed converting scriptPubkey to address");return me.toString("hex")};var Ln=Object.defineProperty,Kr=Object.getOwnPropertySymbols,$i=Object.prototype.hasOwnProperty,Gn=Object.prototype.propertyIsEnumerable,oi=(R,O,z)=>O in R?Ln(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,ai=(R,O)=>{for(var z in O||(O={}))$i.call(O,z)&&oi(R,z,O[z]);if(Kr)for(var z of Kr(O))Gn.call(O,z)&&oi(R,z,O[z]);return R},Co=(R,O)=>{var z={};for(var me in R)$i.call(R,me)&&O.indexOf(me)<0&&(z[me]=R[me]);if(R!=null&&Kr)for(var me of Kr(R))O.indexOf(me)<0&&Gn.call(R,me)&&(z[me]=R[me]);return z};const si=R=>{const O=R,{scriptPubkey:z,used:me=!1}=O,Me=Co(O,["scriptPubkey","used"]);return ai({scriptPubkey:z,used:me,lastQueriedBlockHeight:0,lastQuery:0,lastTouched:0},Me)},Ta=F({id:h,txid:h,vout:c,value:h,scriptPubkey:h,script:h,redeemScript:n(h),scriptType:Vl,blockHeight:c,spent:f});var Yl=Object.defineProperty,$l=Object.defineProperties,Jl=Object.getOwnPropertyDescriptors,G0=Object.getOwnPropertySymbols,Sd=Object.prototype.hasOwnProperty,kd=Object.prototype.propertyIsEnumerable,V0=(R,O,z)=>O in R?Yl(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,_d=(R,O)=>{for(var z in O||(O={}))Sd.call(O,z)&&V0(R,z,O[z]);if(G0)for(var z of G0(O))kd.call(O,z)&&V0(R,z,O[z]);return R},Id=(R,O)=>$l(R,Jl(O));const Ad=i("bip32","bip44","bip49","bip84"),Td=F({utxos:n(Z(Ta)),subtractFee:n(f),CPFP:n(h)}),Pd=F({lowFee:h,standardFeeLow:h,standardFeeHigh:h,highFee:h}),q0=R=>F(Id(_d({},Pd.shape),{lowFeeFudgeFactor:G(h,R==null?void 0:R.lowFeeFudgeFactor),standardFeeLowFudgeFactor:G(h,R==null?void 0:R.standardFeeLowFudgeFactor),standardFeeHighFudgeFactor:G(h,R==null?void 0:R.standardFeeHighFudgeFactor),highFeeFudgeFactor:G(h,R==null?void 0:R.highFeeFudgeFactor),standardFeeLowAmount:h,standardFeeHighAmount:h,maximumFeeRate:n(h,R==null?void 0:R.maximumFeeRate)})).withRest,Od=F({balance:h,addressBalances:F(h),lastSeenBlockHeight:c}),Bd=F({nowNodeApiKey:n(h)}),Ql=F({blockbookServers:G(Z(h),[]),enableCustomServers:G(f,!1)}),Rd=F({publicAddress:h}),Cd=i("bip69","targets"),Fd=F({enableRbf:n(f),forceChangeAddress:n(h),outputSort:n(Cd,"bip69"),txOptions:n(Td),utxoSourceAddress:n(h)});var ec=er(9939),zt=er(8405);const u1=zt.WK,Nd=zt.DE,Ld=zt.k5,l1=zt.Dr,c1=zt.ef,h1=zt.GY,d1=zt.WM,p1=zt.Kz,v1=zt.uX,m1=zt.IK,g1=zt.gw,y1=zt.WU,b1=zt.G8,w1=zt.xQ,x1=zt.D7,M1=zt.hi,E1=zt.mJ,S1=zt.zU,k1=zt.dq,_1=zt.m$,I1=zt.MU,A1=zt.ID,T1=zt.k0,P1=zt.D4,O1=zt.kL,B1=zt.jx,R1=zt.A_,C1=zt.v1,F1=zt.TL,N1=zt.Og,L1=zt.ft,D1=zt.KU,U1=zt.ZU,H1=zt.ye,z1=zt.Xj,K1=zt.Rn,j1=zt.bo,W1=zt.KL,G1=zt.rW,V1=zt.U3,q1=zt.$Y,X1=zt.EJ,Z1=zt.XY,Y1=zt.v7,$1=zt.up,J1=zt.h,Q1=zt.Cx,eg=zt.Zz,tg=zt.CU,rg=zt.ib,ng=zt.eT,ig=zt._0,og=zt.UR,ag=zt.Up,sg=zt.y0,fg=zt.A2,ug=zt.ql,lg=zt.FX,cg=zt.Jr,hg=zt.zS,dg=zt.pK,pg=zt.ud,vg=zt.Zk,mg=zt.Mf,gg=zt.U0,yg=zt.CX,bg=zt.l4,wg=zt.gU,xg=zt.M3,Mg=zt.Xv,Eg=zt.vN,Sg=zt.g_,kg=zt.BN,_g=zt.Jv,Ig=zt.T0,Ag=zt.z8,Tg=zt.Gt,Pg=zt.Fm,Og=zt.b4,Bg=zt.N2,Rg=zt.K8,Cg=zt.gB,Fg=zt.bd,Ng=zt.GG,Lg=zt.V$,Dg=zt.CC,Ug=zt.dT,Hg=zt.uT,zg=zt._j,Kg=zt.p4,jg=zt.W0,Wg=zt.zk,Gg=zt.AB,Vg=zt.sn,qg=zt._u,Xg=zt.Py,Zg=zt.iu,Yg=zt.l7,$g=zt.JU,Jg=zt.O6,tc=R=>R.filter(O=>O!==void 0),Dd=R=>{const O={};for(const z in R)R[z]!==void 0&&(O[z]=R[z]);return O},Pa=(R=Date.now())=>Math.round(R/1e3),Ud="https://info1.edge.app",rc="fees.json",Qg=999999999,Ef=2,ey=200,ty=6,ry=2,ny=1,Hd=(R,O,z,me)=>{const{highFeeFudgeFactor:Me="1",lowFeeFudgeFactor:Re="1",standardFeeHighAmount:Se,standardFeeHighFudgeFactor:ke="1",standardFeeLowAmount:_e,standardFeeLowFudgeFactor:Te="1"}=O;let{highFee:We,lowFee:Je,standardFeeHigh:it,standardFeeLow:ct}=O;switch(We=(0,Ge.round)((0,Ge.mul)(We,Me),0),Je=(0,Ge.round)((0,Ge.mul)(Je,Re),0),it=(0,Ge.round)((0,Ge.mul)(it,ke),0),ct=(0,Ge.round)((0,Ge.mul)(ct,Te),0),z){case"low":return Je;case"standard":{if((0,Ge.gte)(R,Se))return it;if((0,Ge.lte)(R,_e))return ct;const dt=(0,Ge.sub)(Se,_e),pt=(0,Ge.sub)(it,ct),St=(0,Ge.sub)(R,_e),Ut=(0,Ge.mul)(St,pt),Jt=(0,Ge.div)(Ut,dt);return(0,Ge.add)(ct,Jt)}case"high":return We;case"custom":if(me==null||me==="0")throw new Error(`Invalid custom network fee: ${me}`);return me;default:throw new Error(`Invalid networkFeeOption: ${z}`)}},zd=F({fastestFee:c,halfHourFee:c,hourFee:c}),Kd=1.3,jd=2,Wd=R=>{let O;try{O=zd(R)}catch{return null}const{fastestFee:z,halfHourFee:me}=O,Me=me.toString(),Re=z.toString(),Se=Math.round(z*Kd).toString(),ke=Math.round(z*jd).toString();return{lowFee:Ge.max(Me,Ef.toString()),standardFeeLow:Ge.max(Re,Ef.toString()),standardFeeHigh:Ge.max(Se,Ef.toString()),highFee:Ge.max(ke,Ef.toString())}};var Gd=Object.defineProperty,Vd=Object.defineProperties,qd=Object.getOwnPropertyDescriptors,Sf=Object.getOwnPropertySymbols,X0=Object.prototype.hasOwnProperty,Z0=Object.prototype.propertyIsEnumerable,Y0=(R,O,z)=>O in R?Gd(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,nc=(R,O)=>{for(var z in O||(O={}))X0.call(O,z)&&Y0(R,z,O[z]);if(Sf)for(var z of Sf(O))Z0.call(O,z)&&Y0(R,z,O[z]);return R},ic=(R,O)=>Vd(R,qd(O)),Xd=(R,O)=>{var z={};for(var me in R)X0.call(R,me)&&O.indexOf(me)<0&&(z[me]=R[me]);if(R!=null&&Sf)for(var me of Sf(R))O.indexOf(me)<0&&Z0.call(R,me)&&(z[me]=R[me]);return z},fi=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});const Zd=R=>fi(void 0,null,function*(){const O=R,{disklet:z,pluginInfo:me}=O,Me=Xd(O,["disklet","pluginInfo"]),{currencyInfo:Re,engineInfo:Se}=me,ke=v(z),_e=yield Yd(ke,Se.defaultFeeInfo);let Te=0,We;const Je=()=>fi(void 0,null,function*(){if(Date.now()-Te<=Se.feeUpdateInterval)return;const it=yield Qd(ic(nc({},Me),{mempoolSpaceFeeInfoServer:Se.mempoolSpaceFeeInfoServer})),ct=Dd(it!=null?it:{});Object.assign(_e,ct),Te=Date.now(),yield $d(ke,_e)});return{start(){return fi(this,null,function*(){const it=yield $0(ic(nc({},Me),{uri:`${Ud}/v1/networkFees/${Re.pluginId}`,cleaner:G(q0(_e),null)}));Object.assign(_e,it),yield Je(),We=setInterval(Je,Se.feeUpdateInterval)})},stop(){clearInterval(We)},clearCache(){return fi(this,null,function*(){yield ke.delete(rc)})},getRate(it){return fi(this,null,function*(){var ct,dt,pt;const{spendTargets:St,networkFeeOption:Ut="standard",customNetworkFee:Jt={},otherParams:ur={}}=it,_t=(dt=(ct=ur.paymentProtocolInfo)==null?void 0:ct.merchant)==null?void 0:dt.requiredFeeRate;if(_t!=null){const Ft=Ge.add(Ge.mul(`${_t}`,"1.5"),"1");return Ge.toFixed(Ft,0,0)}const Bt=((pt=Re.customFeeTemplate)!=null?pt:[])[0];if(Bt==null)throw new Error("No custom fee template");return Hd(Jd(St),_e,Ut,Jt[Bt.key])})},get feeInfo(){return _e}}}),Yd=(R,O)=>fi(void 0,null,function*(){const z=yield R.getJson(rc).catch(()=>{});return G(q0(O),O)(z)}),$d=(R,O)=>fi(void 0,null,function*(){return yield R.setJson(rc,O)}),Jd=R=>R.reduce((O,{nativeAmount:z})=>{if(z==null)throw new Error(`Invalid spend target amount: ${z}`);return Ge.add(O,z)},"0"),$0=R=>fi(void 0,null,function*(){const{uri:O,cleaner:z,io:me,log:Me}=R;try{const Re=yield me.fetch(O);if(!Re.ok)throw new Error(`Error fetching fees from ${O}`);const Se=yield Re.json();return z(Se)}catch(Re){return Me(Re.message),null}}),Qd=R=>fi(void 0,null,function*(){if(R.mempoolSpaceFeeInfoServer!=null){const O=yield $0(ic(nc({},R),{uri:R.mempoolSpaceFeeInfoServer,cleaner:Wd}));if(O!=null)return O}return{}});var J0=er(7007);class Q0 extends J0.EventEmitter{}var cn=(R=>(R.TRANSACTIONS_CHANGED="transactions:changed",R.WALLET_BALANCE_CHANGED="wallet:balance:changed",R.ADDRESS_BALANCE_CHANGED="address:balance:changed",R.BLOCK_HEIGHT_CHANGED="block:height:changed",R.NEW_ADDRESS_TRANSACTION="address:transaction:changed",R.ADDRESSES_CHECKED="addresses:checked",R.TXIDS_CHANGED="txids:changed",R.CONNECTION_OPEN="connection:open",R.CONNECTION_CLOSE="connection:close",R.CONNECTION_TIMER="connection:timer",R))(cn||{});const ep=R=>{const O=new Q0;return O.on("transactions:changed",R.onTransactionsChanged),O.on("wallet:balance:changed",R.onBalanceChanged),O.on("block:height:changed",(z,me)=>{R.onBlockHeightChanged(me)}),O.on("addresses:checked",R.onAddressesChecked),O.on("txids:changed",R.onTxidsChanged),O};var tp=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});class eh{constructor(){this._acquired=!1,this._waitingResolvers=[]}get acquired(){return this._acquired}acquireAsync(){return tp(this,null,function*(){return this._acquired?yield new Promise(O=>{this._waitingResolvers.push(O)}):(this._acquired=!0,yield Promise.resolve())})}tryAcquire(){return this._acquired?!1:(this._acquired=!0,!0)}release(){if(!this._acquired)throw new Error("Cannot release an unacquired lock");if(this._waitingResolvers.length>0){const O=this._waitingResolvers.shift();if(O==null)throw new Error("Cannot release null lock");O()}else this._acquired=!1}}const rp=R=>{var O;for(const z of Oo)if(z.coinInfo.name===R)return(O=z.engineInfo.formats)!=null?O:[];return[]},an=(R,O)=>{delete R[O]};var Ti=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});const kf="metadata.json",th=R=>Ti(void 0,null,function*(){const{disklet:O,emitter:z,log:me}=R,Me=v(O),Re=new eh,Se={get state(){return Je},clear:()=>Ti(void 0,null,function*(){yield Me.delete(kf);const it=yield Te();Object.assign(Je,it)})},ke=it=>Ti(void 0,null,function*(){const ct=Object.values(Je.addressBalances).reduce((dt,pt)=>(0,Ge.add)(dt,pt),"0");Je.balance=ct,yield We(Je),z.emit(cn.WALLET_BALANCE_CHANGED,it,ct)});z.on(cn.ADDRESS_BALANCE_CHANGED,(it,ct)=>Ti(void 0,null,function*(){yield Re.acquireAsync();try{ct.forEach(({scriptPubkey:dt,balance:pt})=>{pt==="0"?an(Je.addressBalances,dt):Je.addressBalances[dt]=pt}),yield ke(it)}catch(dt){me.error(dt)}finally{Re.release()}})),z.on(cn.BLOCK_HEIGHT_CHANGED,(it,ct)=>Ti(void 0,null,function*(){ct>Je.lastSeenBlockHeight&&(Je.lastSeenBlockHeight=ct,yield We(Je))}));const _e=()=>Ti(void 0,null,function*(){try{const it=yield Me.getJson(kf);return Od(it)}catch(it){return me.error(it),yield Te()}}),Te=()=>Ti(void 0,null,function*(){const it={balance:"0",addressBalances:{},lastSeenBlockHeight:0};return yield Me.setJson(kf,it),it}),We=it=>Ti(void 0,null,function*(){yield Me.setJson(kf,it)}),Je=yield _e();return Se});var rh=er(5582);const np=H(R=>rh.xn.parse(h(R)),R=>rh.xn.stringify(R).toLowerCase());function ip(R){const O=h(R);if(!/^\d+$/.test(O))throw new Error("Expected an integer string");return O}function op(R,O){var z;const{memos:me=[]}=R,{displayName:Me,memoMaxLength:Re,memoMaxValue:Se,memoOptions:ke=[],multipleMemos:_e=!1,memoType:Te}=O,We=[...ke];Te==="text"&&We.push({type:"text",maxLength:Re}),Te==="number"&&We.push({type:"number",maxValue:Se}),Te==="hex"&&We.push({type:"hex",maxBytes:Re==null?void 0:Re/2});const{memoName:Je="memo"}=(z=ke[0])!=null?z:{};for(const it of me){const ct=We.filter(pt=>it.type===pt.type);if(ct.length<1)throw new Error(`${Me} ${Je}: cannot be type ${it.type}`);const dt=ct.map(pt=>ap(it,pt)).find(pt=>pt!=null);if(dt!=null)throw new Error(`${Me} {memoName}: ${dt}`)}if(!_e&&me.length>1)throw new Error(`${Me} only supports one ${Je}`)}function ap(R,O){if(O.type==="text"&&O.maxLength!=null&&R.value.length>O.maxLength)return`cannot be longer than ${O.maxLength}`;if(O.type==="number"){const z=G(ip)(R.value);if(z==null)return"is not a valid number";if(O.maxValue!=null&&(0,Ge.gt)(z,O.maxValue))return`cannot be greater than ${O.maxValue}`}if(O.type==="hex"){const z=G(np)(R.value);if(z==null)return"is not valid hexadecimal";if(O.maxBytes!=null&&z.length>O.maxBytes)return`cannot be longer than ${O.maxBytes} bytes`;if(O.minBytes!=null&&z.length<O.minBytes)return`cannot be shorter than ${O.minBytes} bytes`}}var sp=Object.defineProperty,fp=Object.defineProperties,up=Object.getOwnPropertyDescriptors,nh=Object.getOwnPropertySymbols,lp=Object.prototype.hasOwnProperty,cp=Object.prototype.propertyIsEnumerable,ih=(R,O,z)=>O in R?sp(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,hp=(R,O)=>{for(var z in O||(O={}))lp.call(O,z)&&ih(R,z,O[z]);if(nh)for(var z of nh(O))cp.call(O,z)&&ih(R,z,O[z]);return R},dp=(R,O)=>fp(R,up(O));function pp(R,O){var z,me;const{memoType:Me}=O,Re=[];if(Me==="hex"||Me==="number"||Me==="text")for(const ke of R.spendTargets)ke.memo!=null?Re.push({type:Me,value:ke.memo}):ke.uniqueIdentifier!=null?Re.push({type:Me,value:ke.uniqueIdentifier}):typeof((z=ke.otherParams)==null?void 0:z.uniqueIdentifier)=="string"&&Re.push({type:Me,value:ke.otherParams.uniqueIdentifier});const Se=dp(hp({},R),{memos:(me=R.memos)!=null?me:Re});return op(Se,O),Se}var oc=er(8287).Buffer,vp=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});const mp=R=>{var O;const z=R.otherParams;if(z==null)throw new Error("Invalid transaction data");if(z.psbt==null)throw new Error("Missing PSBT in edge transaction data");const me=z.psbt.inputs.map((Re,Se)=>({amount:Re.value.toString(),scriptPubkey:oc.from(Re.scriptPubkey).toString("hex"),n:Se,txId:oc.from(Re.hash).reverse().toString("hex"),outputIndex:Re.index})),Me=z.psbt.outputs.map((Re,Se)=>({amount:Re.value.toString(),scriptPubkey:oc.from(Re.scriptPubkey).toString("hex"),n:Se}));return{txid:R.txid,hex:R.signedTx,blockHeight:R.blockHeight,date:R.date,fees:R.networkFee,inputs:me,outputs:Me,ourIns:[],ourOuts:[],ourAmount:(O=R.nativeAmount)!=null?O:"0"}},oh=R=>vp(void 0,null,function*(){const{tx:O,processor:z,walletTools:me,pluginInfo:Me,walletId:Re}=R,{currencyInfo:Se}=Me,ke=[];for(const Te of O.ourOuts){const{scriptPubkey:We}=O.outputs[parseInt(Te)],Je=yield z.fetchAddress(We);if((Je==null?void 0:Je.path)!=null){const{address:it}=me.scriptPubkeyToAddress({changePath:Je.path,scriptPubkey:We});ke.push(it)}}let _e;try{const We=pe.ZX.fromHex(O.hex).virtualSize();_e={satPerVByte:new(ye())(O.fees,10).div(new(ye())(We,10)).toNumber()}}catch{}return{blockHeight:O.blockHeight,confirmations:O.confirmations,currencyCode:Se.currencyCode,date:O.date,feeRateUsed:_e,isSend:(0,Ge.lt)(O.ourAmount,"0"),memos:[],nativeAmount:O.ourAmount,networkFee:O.fees,ourReceiveAddresses:ke,signedTx:O.hex,tokenId:null,txid:O.txid,walletId:Re}});var Dn;(function(R){R.CountBase="COUNT_BASE",R.HashBase="HASH_BASE",R.RangeBase="RANGE_BASE"})(Dn||(Dn={}));function ah(R,O,z,me,Me,Re,Se){try{var ke=R[Re](Se),_e=ke.value}catch(Te){z(Te);return}ke.done?O(_e):Promise.resolve(_e).then(me,Me)}function Mr(R){return function(){var O=this,z=arguments;return new Promise(function(me,Me){var Re=R.apply(O,z);function Se(_e){ah(Re,me,Me,Se,ke,"next",_e)}function ke(_e){ah(Re,me,Me,Se,ke,"throw",_e)}Se(void 0)})}}function _f(){return _f=Object.assign||function(R){for(var O=1;O<arguments.length;O++){var z=arguments[O];for(var me in z)Object.prototype.hasOwnProperty.call(z,me)&&(R[me]=z[me])}return R},_f.apply(this,arguments)}function gp(R){return Object.prototype.hasOwnProperty.call(R,"getJson")||Object.prototype.hasOwnProperty.call(R,"setJson")}function ui(R){return gp(R)?R:v(R)}function If(R,O){return R+"/"+lc(O)}function Fo(R,O,z){return If(R,O)+"/"+z+".json"}function ac(R){return R+"/config.json"}function sc(R,O){return fc.apply(this,arguments)}function fc(){return fc=Mr(function*(R,O){return yield R.getJson(ac(O))}),fc.apply(this,arguments)}function Pi(R,O,z){return uc.apply(this,arguments)}function uc(){return uc=Mr(function*(R,O,z){yield R.setJson(ac(O),z)}),uc.apply(this,arguments)}function lc(R){R===void 0&&(R="");var O=/^[a-z0-9_]*$/i,z=R.trim();if(!O.test(z))throw new Error("partitions may only contain alphanumeric and underscore characters");return z}function cc(R){if(R==="")throw new Error("database name cannot be empty");var O=/^[a-z0-9_]*$/i,z=R.trim();if(!O.test(z))throw new Error("database name may only contain alphanumeric and underscore characters");return z}function hc(R,O){return dc.apply(this,arguments)}function dc(){return dc=Mr(function*(R,O){return yield R.list("./").then(function(z){return z[O]==="folder"})}),dc.apply(this,arguments)}function pc(R){return Number.isInteger(R)&&R>=1}function vc(R,O){return mc.apply(this,arguments)}function mc(){return mc=Mr(function*(R,O){var z=ui(R),me=yield sc(z,O);if(me.type!==Dn.CountBase)throw new Error("Tried to open CountBase, but type is "+String(me.type));var Me={databaseName:O,insert:function(Se,ke,_e){return Mr(function*(){var Te=lc(Se),We=!1,Je=me.partitions[Te];Je===void 0&&(Je={length:0},We=!0);var it=Je.length;if(Number.isNaN(ke)||ke<0)throw new Error("index must be a Number greater than 0");if(ke>it)throw new Error("index is larger than next index in partition");ke===it&&(++Je.length,We=!0);var ct=Math.floor(ke/me.bucketSize),dt=Fo(O,Se,ct),pt=yield z.getJson(dt).catch(function(){return[]}),St=ke%me.bucketSize;pt[St]=_e,yield z.setJson(dt,pt),We&&(me.partitions[Te]=Je),yield Pi(z,O,me)})()},query:function(Se,ke,_e){return Mr(function*(){ke===void 0&&(ke=0),_e===void 0&&(_e=ke);for(var Te=[],We=Math.floor(ke/me.bucketSize);We<=Math.floor(_e/me.bucketSize);We++){var Je=Fo(O,Se,We);Te.push(z.getJson(Je).catch(function(){return[]}))}for(var it=yield Promise.all(Te),ct=[],dt=ke;dt<=_e;dt++){var pt=Math.floor(dt/me.bucketSize),St=dt%me.bucketSize,Ut=pt-Math.floor(ke/me.bucketSize);ct.push(it[Ut][St])}return ct})()},length:function(Se){var ke,_e=lc(Se),Te=me.partitions[_e];return(ke=Te==null?void 0:Te.length)!=null?ke:0},dumpData:function(){return Mr(function*(){for(var Se={},ke=0,_e=Object.keys(me.partitions);ke<_e.length;ke++){var Te=_e[ke];Se[Te]=yield Me.query(Te,0,Me.length(Te)-1)}return{config:me,data:Se}})()}};return Me}),mc.apply(this,arguments)}function yp(R,O){return gc.apply(this,arguments)}function gc(){return gc=Mr(function*(R,O){var z=ui(R),me=O.name,Me=O.bucketSize;if(!pc(Me))throw new Error("bucketSize must be a number greater than 0");var Re=cc(me),Se=yield hc(z,Re);if(Se)throw new Error("database "+Re+" already exists");var ke={type:Dn.CountBase,bucketSize:Math.floor(Me),partitions:{}};return yield Pi(z,Re,ke),yield vc(z,Re)}),gc.apply(this,arguments)}function bp(R,O){return yc.apply(this,arguments)}function yc(){return yc=Mr(function*(R,O){var z=ui(R);try{return yield yp(z,O)}catch(me){if(me instanceof Error&&!me.message.includes("already exists"))throw me;return yield vc(z,O.name)}}),yc.apply(this,arguments)}function bc(R,O){return wc.apply(this,arguments)}function wc(){return wc=Mr(function*(R,O){var z=ui(R),me=yield sc(z,O);if(me.type!==Dn.HashBase)throw new Error("Tried to open HashBase, but type is "+String(me.type));function Me(ke,_e,Te){return Re.apply(this,arguments)}function Re(){return Re=Mr(function*(ke,_e,Te){if(Te===void 0&&(Te=!1),_e.length===0)return[];for(var We=me.prefixSize,Je=[],it={},ct=function(It){var wt=_e[It];if(wt.length<We)return"continue";var Nt=wt.substring(0,We);if(it[Nt]===void 0){var Rt=Fo(O,ke,Nt),tr=z.getJson(Rt).then(function(br){return it[Nt].bucketData=br},function(){});it[Nt]={bucketFetcher:tr,bucketPath:Rt,bucketData:{}},Je.push(tr)}},dt=0;dt<_e.length;dt++)var pt=ct(dt);yield Promise.all(Je);for(var St=[],Ut=new Set,Jt=0;Jt<_e.length;Jt++){var ur=_e[Jt].substring(0,We);Ut.add(ur);var _t=it[ur].bucketData,Bt=_t[_e[Jt]];Te&&delete _t[_e[Jt]],St.push(Bt)}var Lt=Promise.resolve();if(Te){var Ft=Array.from(Ut).map(function(){var jt=Mr(function*(It){var wt=it[It],Nt=wt.bucketPath,Rt=wt.bucketData;return yield z.setJson(Nt,Rt)});return function(It){return jt.apply(this,arguments)}}());Lt=Promise.all(Ft)}return yield Lt,St}),Re.apply(this,arguments)}var Se={databaseName:O,insert:function(_e,Te,We){return Mr(function*(){var Je=me.prefixSize;if(Te.length<Je)throw new Error("hash must be a string of length at least "+Je);var it=Te.substring(0,Je),ct=Fo(O,_e,it),dt=function(){var pt=Mr(function*(St){var Ut;return St===void 0&&(St={}),yield z.setJson(ct,_f(St,(Ut={},Ut[Te]=We,Ut)))});return function(Ut){return pt.apply(this,arguments)}}();yield z.getJson(ct).then(function(){var pt=Mr(function*(St){return yield dt(St)});return function(St){return pt.apply(this,arguments)}}(),Mr(function*(){return yield dt()}))})()},query:function(_e,Te){return Mr(function*(){return yield Me(_e,Te)})()},delete:function(){var ke=Mr(function*(Te,We){return yield Me(Te,We,!0)});function _e(Te,We){return ke.apply(this,arguments)}return _e}(),dumpData:function(_e){return Mr(function*(){_e===void 0&&(_e="");var Te={},We=function(){var it=Mr(function*(ct,dt){dt===void 0&&(dt="");var pt=yield ct.list(),St=Object.keys(pt).map(function(){var Ut=Mr(function*(Jt){if(!ac(O).includes(Jt)){var ur=pt[Jt];if(ur==="folder"){if(dt!=="")throw new Error("Unexpected partition hierarchy");return yield We(m(ct,Jt),Jt)}if(ur==="file"){var _t=yield ct.getJson(Jt);Te[dt]=_f({},Te[dt],_t);return}throw new Error("Unknown listing type "+String(ur))}});return function(Jt){return Ut.apply(this,arguments)}}());yield Promise.all(St)});return function(dt,pt){return it.apply(this,arguments)}}(),Je=m(z,If(O,_e));return yield We(Je,_e),{config:me,data:Te}})()}};return Se}),wc.apply(this,arguments)}function wp(R,O){return xc.apply(this,arguments)}function xc(){return xc=Mr(function*(R,O){var z=ui(R),me=O.prefixSize,Me=cc(O.name);if(!pc(me))throw new Error("prefixSize must be a number greater than 0");var Re=yield hc(z,Me);if(Re)throw new Error("database "+Me+" already exists");var Se={type:Dn.HashBase,prefixSize:me};return yield Pi(z,Me,Se),yield bc(z,Me)}),xc.apply(this,arguments)}function Oa(R,O){return Mc.apply(this,arguments)}function Mc(){return Mc=Mr(function*(R,O){var z=ui(R);try{return yield wp(z,O)}catch(me){if(me instanceof Error&&!me.message.includes("already exists"))throw me;return yield bc(z,O.name)}}),Mc.apply(this,arguments)}function Ec(R,O){return Sc.apply(this,arguments)}function Sc(){return Sc=Mr(function*(R,O){var z=ui(R);function me(_t,Bt,Lt,Ft,jt,It){if(Ft===void 0&&(Ft=0),jt===void 0&&(jt=Lt.length-1),It===void 0&&(It=!1),Lt.length===0)return{found:!1,index:0};var wt=Ft,Nt=jt,Rt=0,tr;if(!Number.isInteger(Ft)||!Number.isInteger(jt)||Ft<0||jt>Lt.length-1||jt<Ft)throw new Error("indices must be valid bucket index values and endIndex >= startIndex");for(;wt<=Nt;)if(Rt=~~((wt+Nt)/2),tr=Lt[Rt][Bt],tr<_t)wt=Rt+1;else if(tr>_t)Nt=Rt-1;else if(It){var br=Rt===Nt||Lt[Rt+1][Bt]!==_t;if(br)return{found:!0,index:Rt};wt=Rt+1}else{var hr=Rt===wt||Lt[Rt-1][Bt]!==_t;if(hr)return{found:!0,index:Rt};Nt=Rt-1}return{found:!1,index:tr!=null&&tr<_t?Rt+1:Rt}}var Me=yield sc(z,O);if(Me.type!==Dn.RangeBase)throw new Error("Tried to open RangeBase, but type is "+String(Me.type));function Re(_t,Bt){return Se.apply(this,arguments)}function Se(){return Se=Mr(function*(_t,Bt){var Lt=Me.rangeKey,Ft=If(O,_t),jt=yield z.list(Ft),It;for(var wt in jt)if(!/config\.json$/.test(wt)){var Nt=wt.split("/"),Rt=Number(Nt[Nt.length-1].split(".")[0]);It==null?It=Rt:Bt?Rt>It&&(It=Rt):Rt<It&&(It=Rt)}if(It!=null){var tr=yield pt(_t,It),br=Bt?tr.length-1:0;return Number(tr[br][Lt])}}),Se.apply(this,arguments)}function ke(_t,Bt,Lt){return _e.apply(this,arguments)}function _e(){return _e=Mr(function*(_t,Bt,Lt){var Ft,jt=Me.rangeKey,It=Me.limits,wt=Bt[jt],Nt=(Ft=It[_t])!=null?Ft:It[_t]={};if(Lt){var Rt=wt===Nt.minRange,tr=wt===Nt.maxRange;if(Rt||tr)return yield ur.query(_t,wt).then(function(mr){if(mr.length===0)return Re(_t,tr).then(function(){var Kt=Mr(function*(Pt){return Rt&&(Nt.minRange=Pt),tr&&(Nt.maxRange=Pt),yield Pi(z,O,Me)});return function(Pt){return Kt.apply(this,arguments)}}())})}else{var br=Nt.minRange,hr=Nt.maxRange;return(br==null||wt<br)&&(Nt.minRange=wt),(hr==null||wt>hr)&&(Nt.maxRange=wt),yield Pi(z,O,Me)}}),_e.apply(this,arguments)}function Te(_t,Bt,Lt,Ft){return We.apply(this,arguments)}function We(){return We=Mr(function*(_t,Bt,Lt,Ft){Ft===void 0&&(Ft=!1);var jt=Me.bucketSize,It=Me.rangeKey,wt=Me.idKey,Nt=Math.floor(Bt/jt),Rt=yield pt(_t,Nt),tr=me(Bt,It,Rt);if(tr.found){var br=me(Bt,It,Rt,tr.index,Rt.length-1,!0),hr=me(Lt,wt,Rt,tr.index,br.index);if(hr.found)if(Ft){var mr=Rt.splice(hr.index,1),Kt=mr[0];return yield Ut(_t,Nt,Rt),yield ke(_t,Kt,!0),Kt}else return Rt[hr.index]}}),We.apply(this,arguments)}function Je(_t,Bt,Lt){return it.apply(this,arguments)}function it(){return it=Mr(function*(_t,Bt,Lt){var Ft=yield ct(_t),jt=[],It=Lt;function wt(Rt){return Nt.apply(this,arguments)}function Nt(){return Nt=Mr(function*(Rt){if(Bt===jt.length||Rt===Ft.length)return yield Promise.resolve();var tr=yield pt(_t,Ft[Rt]);if(tr.length<=It)return It-=tr.length,yield wt(++Rt);var br=tr.length-It,hr=br+jt.length-Bt,mr=hr>0?hr:0;return jt=[].concat(jt,tr.slice(mr,br).reverse()),It=0,yield wt(++Rt)}),Nt.apply(this,arguments)}return yield wt(0),jt}),it.apply(this,arguments)}function ct(_t){return dt.apply(this,arguments)}function dt(){return dt=Mr(function*(_t){var Bt=If(O,_t),Lt=yield z.list(Bt),Ft={};for(var jt in Lt)if(Object.hasOwnProperty.call(Lt,jt)&&Lt[jt]!=="folder"&&!/config\.json$/.test(jt)){var It=jt.split("/"),wt=Number(It[It.length-1].split(".")[0]);Ft[wt]=!0}return Object.keys(Ft).sort(function(Nt,Rt){return Nt<Rt?1:-1})}),dt.apply(this,arguments)}function pt(_t,Bt){return St.apply(this,arguments)}function St(){return St=Mr(function*(_t,Bt){var Lt=Fo(O,_t,Bt);return yield z.getJson(Lt).catch(function(){return[]})}),St.apply(this,arguments)}function Ut(_t,Bt,Lt){return Jt.apply(this,arguments)}function Jt(){return Jt=Mr(function*(_t,Bt,Lt){var Ft=Fo(O,_t,Bt);return Lt.length===0?yield z.delete(Ft):yield z.setJson(Ft,Lt)}),Jt.apply(this,arguments)}var ur={rangeKey:Me.rangeKey,idKey:Me.idKey,databaseName:O,insert:function(Bt,Lt){return Mr(function*(){var Ft,jt=Me.bucketSize,It=Me.rangeKey,wt=Me.idKey;if(!(Object.prototype.hasOwnProperty.call(Lt,It)&&Object.prototype.hasOwnProperty.call(Lt,wt)))throw new Error("data must have properties "+It+" and "+wt);var Nt=yield Te(Bt,Lt[It],Lt[wt]);if(Nt!=null)throw new Error("Cannot insert data because id already exists");var Rt=Math.floor(Lt[It]/jt);yield pt(Bt,Rt).then(function(){var br=Mr(function*(hr){var mr=me(Lt[It],It,hr);if(!mr.found)hr.splice(mr.index,0,Lt);else{var Kt=me(Lt[It],It,hr,mr.index,hr.length-1,!0),Pt=me(Lt[wt],wt,hr,mr.index,Kt.index);hr.splice(Pt.index,0,Lt)}return yield Ut(Bt,Rt,hr)});return function(hr){return br.apply(this,arguments)}}(),Mr(function*(){return yield Ut(Bt,Rt,[Lt])})),yield ke(Bt,Lt,!1);var tr=(Ft=Me.sizes[Bt])!=null?Ft:0;Me.sizes[Bt]=tr+1,yield Pi(z,O,Me)})()},query:function(Bt,Lt,Ft){return Mr(function*(){Bt===void 0&&(Bt="/"),Ft===void 0&&(Ft=Lt);var jt=Me.bucketSize,It=Me.rangeKey,wt=[];if(Ft<Lt)throw new Error("rangeStart must be larger than rangeEnd");for(var Nt=Math.floor(Lt/jt);Nt<=Math.floor(Ft/jt);Nt++)wt.push(pt(Bt,Nt));var Rt=yield Promise.all(wt),tr=[];if(Rt.length===1){var br=me(Lt,It,Rt[0]),hr=me(Ft,It,Rt[0],0,Rt[0].length-1,!0);tr=Rt[0].slice(br.index,hr.found?hr.index+1:hr.index)}else for(var mr=0;mr<Rt.length;mr++)if(mr===0){var Kt=me(Lt,It,Rt[mr]);tr=Rt[mr].slice(Kt.index)}else if(mr===Rt.length-1){var Pt=me(Ft,It,Rt[mr],0,Rt[mr].length-1,!0);Array.prototype.push.apply(tr,Rt[mr].slice(0,Pt.found?Pt.index+1:Pt.index))}else tr.push.apply(tr,Rt[mr]);return tr})()},queryById:function(Bt,Lt,Ft){return Mr(function*(){return yield Te(Bt,Lt,Ft)})()},queryByCount:function(Bt,Lt,Ft){return Mr(function*(){return Ft===void 0&&(Ft=0),yield Je(Bt,Lt,Ft)})()},delete:function(){var _t=Mr(function*(Lt,Ft,jt){return yield Te(Lt,Ft,jt,!0).then(function(){var It=Mr(function*(wt){var Nt,Rt=(Nt=Me.sizes[Lt])!=null?Nt:0;return Me.sizes[Lt]=Rt-1,yield Pi(z,O,Me).then(function(){return wt})});return function(wt){return It.apply(this,arguments)}}())});function Bt(Lt,Ft,jt){return _t.apply(this,arguments)}return Bt}(),update:function(Bt,Lt,Ft){return Mr(function*(){var jt=yield ur.delete(Bt,Lt,Ft[Me.idKey]);if(jt==null)throw new Error("Cannot update a non-existing element");yield ur.insert(Bt,Ft)})()},min:function(Bt){var Lt,Ft;return(Lt=(Ft=Me.limits[Bt])==null?void 0:Ft.minRange)!=null?Lt:0},max:function(Bt){var Lt,Ft;return(Lt=(Ft=Me.limits[Bt])==null?void 0:Ft.maxRange)!=null?Lt:0},size:function(Bt){var Lt;return(Lt=Me.sizes[Bt])!=null?Lt:0},dumpData:function(){return Mr(function*(){for(var Bt={},Lt=0,Ft=Object.keys(Me.sizes);Lt<Ft.length;Lt++){var jt,It=Ft[Lt],wt=(jt=ur.min(It))!=null?jt:0;Bt[It]=yield ur.query(It,wt,ur.max(It))}return{config:Me,data:Bt}})()}};return ur}),Sc.apply(this,arguments)}function xp(R,O){return kc.apply(this,arguments)}function kc(){return kc=Mr(function*(R,O){var z=ui(R),me=O.name,Me=O.bucketSize,Re=O.rangeKey,Se=O.idKey,ke=O.idPrefixLength,_e=ke===void 0?1:ke;if(!pc(Me))throw new Error("bucketSize must be a number greater than 0");var Te=cc(me),We=yield hc(z,Te);if(We)throw new Error("database "+Te+" already exists");var Je={type:Dn.RangeBase,bucketSize:Math.floor(Me),rangeKey:Re,idKey:Se,idPrefixLength:_e,limits:{},sizes:{}};return yield Pi(z,Te,Je),yield Ec(z,Te)}),kc.apply(this,arguments)}function sh(R,O){return _c.apply(this,arguments)}function _c(){return _c=Mr(function*(R,O){var z=ui(R);try{return yield xp(z,O)}catch(me){if(me instanceof Error&&!me.message.includes("already exists"))throw me;return yield Ec(z,O.name)}}),_c.apply(this,arguments)}function iy(R,O){return Ic.apply(this,arguments)}function Ic(){return Ic=Mr(function*(R,O){var z=yield R.getText(O+"/config.json").then(function(Me){return JSON.parse(Me)});switch(z.type){case Dn.CountBase:return yield vc(R,O);case Dn.HashBase:return yield bc(R,O);case Dn.RangeBase:return yield Ec(R,O);default:{var me=z==null?void 0:z.type;throw new Error("Unknown base type: "+me)}}}),Ic.apply(this,arguments)}var Mp=function(R,O,z,me){function Me(Re){return Re instanceof z?Re:new z(function(Se){Se(Re)})}return new(z||(z=Promise))(function(Re,Se){function ke(We){try{Te(me.next(We))}catch(Je){Se(Je)}}function _e(We){try{Te(me.throw(We))}catch(Je){Se(Je)}}function Te(We){We.done?Re(We.value):Me(We.value).then(ke,_e)}Te((me=me.apply(R,O||[])).next())})};class Ep{constructor(O){if(this._maxConcurrency=O,this._queue=[],O<=0)throw new Error("semaphore must be initialized to a positive value");this._value=O}acquire(){const O=this.isLocked(),z=new Promise(me=>this._queue.push(me));return O||this._dispatch(),z}runExclusive(O){return Mp(this,void 0,void 0,function*(){const[z,me]=yield this.acquire();try{return yield O(z)}finally{me()}})}isLocked(){return this._value<=0}release(){if(this._maxConcurrency>1)throw new Error("this method is unavailabel on semaphores with concurrency > 1; use the scoped release returned by acquire instead");if(this._currentReleaser){const O=this._currentReleaser;this._currentReleaser=void 0,O()}}_dispatch(){const O=this._queue.shift();if(!O)return;let z=!1;this._currentReleaser=()=>{z||(z=!0,this._value++,this._dispatch())},O([this._value--,this._currentReleaser])}}var Sp=function(R,O,z,me){function Me(Re){return Re instanceof z?Re:new z(function(Se){Se(Re)})}return new(z||(z=Promise))(function(Re,Se){function ke(We){try{Te(me.next(We))}catch(Je){Se(Je)}}function _e(We){try{Te(me.throw(We))}catch(Je){Se(Je)}}function Te(We){We.done?Re(We.value):Me(We.value).then(ke,_e)}Te((me=me.apply(R,O||[])).next())})};class Ac{constructor(){this._semaphore=new Ep(1)}acquire(){return Sp(this,void 0,void 0,function*(){const[,O]=yield this._semaphore.acquire();return O})}runExclusive(O){return this._semaphore.runExclusive(()=>O())}isLocked(){return this._semaphore.isLocked()}release(){this._semaphore.release()}}var fh=function(R,O,z,me){function Me(Re){return Re instanceof z?Re:new z(function(Se){Se(Re)})}return new(z||(z=Promise))(function(Re,Se){function ke(We){try{Te(me.next(We))}catch(Je){Se(Je)}}function _e(We){try{Te(me.throw(We))}catch(Je){Se(Je)}}function Te(We){We.done?Re(We.value):Me(We.value).then(ke,_e)}Te((me=me.apply(R,O||[])).next())})};function oy(R,O,z=new Error("timeout")){return{acquire:()=>new Promise((me,Me)=>fh(this,void 0,void 0,function*(){let Re=!1;setTimeout(()=>{Re=!0,Me(z)},O);const Se=yield R.acquire();Re?(Array.isArray(Se)?Se[1]:Se)():me(Se)})),runExclusive(me){return fh(this,void 0,void 0,function*(){let Me=()=>{};try{const Re=yield this.acquire();return Array.isArray(Re)?(Me=Re[1],yield me(Re[0])):(Me=Re,yield me())}finally{Me()}})},release(){R.release()},isLocked:()=>R.isLocked()}}const li=R=>`${R.format}_${R.changeIndex}`,kp={name:"scriptPubkeyByPath",bucketSize:50},_p={name:"addressByScriptPubkey",prefixSize:4},Ip={name:"lastUsedByFormatPath",prefixSize:2},Ap={name:"txIdByBlockHeight",bucketSize:1e5,rangeKey:"blockHeight",idKey:"txid"},Tp={name:"txById",prefixSize:2},Pp={name:"txIdsByDate",bucketSize:30*24*60*60,rangeKey:"date",idKey:"txid"},Op={name:"utxoById",prefixSize:2},Bp={name:"utxoIdsByScriptPubkey",prefixSize:4};var Rp=Object.defineProperty,uh=Object.getOwnPropertySymbols,Cp=Object.prototype.hasOwnProperty,Fp=Object.prototype.propertyIsEnumerable,lh=(R,O,z)=>O in R?Rp(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,Tc=(R,O)=>{for(var z in O||(O={}))Cp.call(O,z)&&lh(R,z,O[z]);if(uh)for(var z of uh(O))Fp.call(O,z)&&lh(R,z,O[z]);return R},Ji=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});const ch=R=>Ji(void 0,null,function*(){const O={addressByScriptPubkey:yield Oa(R.storage,_p),scriptPubkeyByPath:yield bp(R.storage,kp),lastUsedByFormatPath:yield Oa(R.storage,Ip)},z={txById:yield Oa(R.storage,Tp),txIdsByBlockHeight:yield sh(R.storage,Ap),txIdsByDate:yield sh(R.storage,Pp)},me={utxoById:yield Oa(R.storage,Op),utxoIdsByScriptPubkey:yield Oa(R.storage,Bp)},Me=new Ac,Re=new Ac,Se=new Ac;return{address(ke){return Ji(this,null,function*(){return yield Me.runExclusive(()=>Ji(this,null,function*(){return yield ke(O)}))})},tx(ke){return Ji(this,null,function*(){return yield Re.runExclusive(()=>Ji(this,null,function*(){return yield ke(z)}))})},utxo(ke){return Ji(this,null,function*(){return yield Se.runExclusive(()=>Ji(this,null,function*(){return yield ke(me)}))})},all:Tc(Tc(Tc({},O),z),me)}});var qr=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});const Np="tables";function hh(R){return qr(this,null,function*(){const O=(0,ec.my)(R.disklet,Np);let z=v(O),me=yield ch({storage:z}).catch(Se=>qr(this,null,function*(){throw yield z.delete("."),Se}));const Me=Se=>{let ke="0",_e={};for(const Te of Se.inputs)_e[Te.n.toString()]=Te;for(const Te of Se.ourIns){const We=_e[Te];ke=Ge.sub(ke,We.amount)}_e={};for(const Te of Se.outputs)_e[Te.n.toString()]=Te;for(const Te of Se.ourOuts){const We=_e[Te];ke=Ge.add(ke,We.amount)}return ke};return{clearAll(){return qr(this,null,function*(){yield z.onFlush.next().value,yield k(),yield O.delete("."),z=v(O),me=yield ch({storage:z})})},dumpData(){return qr(this,null,function*(){const Se=Object.values(me.all);return yield Promise.all(Se.map(ke=>qr(this,null,function*(){return{databaseName:ke.databaseName,data:yield ke.dumpData()}})))})},saveUtxo(Se){return qr(this,null,function*(){return yield me.utxo(ke=>qr(this,null,function*(){const[_e=[]]=yield ke.utxoIdsByScriptPubkey.query("",[Se.scriptPubkey]);_e.includes(Se.id)||(_e.push(Se.id),yield ke.utxoIdsByScriptPubkey.insert("",Se.scriptPubkey,_e)),yield ke.utxoById.insert("",Se.id,Se)}))})},removeUtxos(Se){return qr(this,null,function*(){return yield me.utxo(ke=>qr(this,null,function*(){var _e;if(Se.length===0)return;const Te=(yield ke.utxoById.query("",Se)).filter(Je=>Je!=null),We={};for(const Je of Te)We[Je.scriptPubkey]=[...(_e=We[Je.scriptPubkey])!=null?_e:[],Je.id];for(const Je of Object.keys(We)){const it=We[Je],[ct=[]]=yield ke.utxoIdsByScriptPubkey.query("",[Je]);for(const dt of it)ct.splice(ct.indexOf(dt),1);ct.length>0?yield ke.utxoIdsByScriptPubkey.insert("",Je,ct):yield ke.utxoIdsByScriptPubkey.delete("",[Je])}yield ke.utxoById.delete("",Se)}))})},fetchUtxos(Se){return qr(this,null,function*(){const{scriptPubkey:ke,utxoIds:_e=[]}=Se;return yield me.utxo(Te=>qr(this,null,function*(){var We;if(ke!=null){const[Je]=yield Te.utxoIdsByScriptPubkey.query("",[ke]);if(Je!=null&&_e.push(...Je),_e.length===0)return[]}if(_e.length===0){const{data:Je}=yield Te.utxoById.dumpData("");return Object.values((We=Je[""])!=null?We:{})}return yield Te.utxoById.query("",_e)}))})},saveTransaction(Se){return qr(this,null,function*(){const{scriptPubkeys:ke=[],tx:_e}=Se;return yield me.tx(Te=>qr(this,null,function*(){const We=yield Te.txById.query("",[_e.txid]).then(it=>it[0]).catch(it=>{}),Je=We!=null?We:_e;for(const it of ke){for(const ct of Je.inputs)ct.scriptPubkey===it&&(Je.ourIns.includes(ct.n.toString())||Je.ourIns.push(ct.n.toString()));for(const ct of Je.outputs)ct.scriptPubkey===it&&(Je.ourOuts.includes(ct.n.toString())||Je.ourOuts.push(ct.n.toString()));Je.ourAmount=Me(Je)}return Je.blockHeight!==_e.blockHeight?(yield Te.txIdsByBlockHeight.delete("",Je.blockHeight,Je.txid),Je.blockHeight=_e.blockHeight,yield Te.txIdsByBlockHeight.insert("",{txid:Je.txid,blockHeight:Je.blockHeight})):(yield(yield Te.txIdsByBlockHeight.query("",Je.blockHeight)).reverse().map(({txid:ct})=>ct)).includes(Je.txid)||(yield Te.txIdsByBlockHeight.insert("",{txid:Je.txid,blockHeight:Je.blockHeight})),yield Te.txById.insert("",Je.txid,Je),We==null&&(yield Te.txIdsByDate.insert("",{txid:_e.txid,date:_e.date})),Je}))})},numTransactions(){return me.all.txIdsByDate.size("")},removeTransaction(Se){return qr(this,null,function*(){})},fetchTransactions(Se){return qr(this,null,function*(){const{blockHeightMax:ke,txId:_e,options:Te}=Se;let{blockHeight:We}=Se;const Je=[];return yield me.tx(it=>qr(this,null,function*(){if(_e!=null){const ct=yield it.txById.query("",[_e]);Je.push(...ct)}if(ke!=null&&We==null&&(We=0),We!=null){const ct=yield(yield it.txIdsByBlockHeight.query("",We,ke)).reverse().map(({txid:pt})=>pt),dt=yield it.txById.query("",ct);Je.push(...dt)}if(Te!=null){const{startEntries:ct,startIndex:dt,startDate:pt=new Date(0),endDate:St=new Date}=Te;let Ut;ct!=null&&dt!=null?Ut=yield it.txIdsByDate.queryByCount("",ct,dt):Ut=yield it.txIdsByDate.query("",Pa(pt.getTime()),Pa(St.getTime()));const Jt=yield Ut.reverse().map(({txid:_t})=>_t),ur=yield it.txById.query("",Jt);Je.push(...ur.filter(_t=>_t!=null))}})),Je})},saveAddress(Se){return qr(this,null,function*(){yield me.address(ke=>qr(this,null,function*(){let _e;const[Te]=yield ke.addressByScriptPubkey.query("",[Se.scriptPubkey]);if(Se.path!=null){const[We]=yield ke.scriptPubkeyByPath.query(li(Se.path),Se.path.addressIndex);if(We!=null&&We!==Se.scriptPubkey)throw new Error("Attempted to save address with an existing path, but different script pubkey");if(_e={path:Se.path,scriptPubkey:Se.scriptPubkey},Se.used||(Te==null?void 0:Te.used)===!0){let[Je]=yield ke.lastUsedByFormatPath.query("",[li(Se.path)]);Je==null&&(Je=-1),Je<Se.path.addressIndex&&(yield ke.lastUsedByFormatPath.insert("",li(Se.path),Se.path.addressIndex))}}if(Te!=null){if(Se.lastQueriedBlockHeight>Te.lastQueriedBlockHeight&&(Te.lastQueriedBlockHeight=Se.lastQueriedBlockHeight),Se.lastQuery>Te.lastQuery&&(Te.lastQuery=Se.lastQuery),Se.lastTouched>Te.lastTouched&&(Te.lastTouched=Se.lastTouched),Se.balance!=null&&(Te.balance=Se.balance),Se.path!=null&&Te.path==null&&(Te.path=Se.path,_e={path:Te.path,scriptPubkey:Te.scriptPubkey}),Se.used&&!Te.used&&(Te.used=!0),Te.path!=null&&Te.used){let[We]=yield ke.lastUsedByFormatPath.query("",[li(Te.path)]);We==null&&(We=-1),We<Te.path.addressIndex&&(yield ke.lastUsedByFormatPath.insert("",li(Te.path),Te.path.addressIndex))}yield ke.addressByScriptPubkey.insert("",Te.scriptPubkey,Te)}Te==null&&(yield ke.addressByScriptPubkey.insert("",Se.scriptPubkey,Se)),_e!=null&&(yield ke.scriptPubkeyByPath.insert(li(_e.path),_e.path.addressIndex,_e.scriptPubkey))}))})},numAddressesByFormatPath(Se){return me.all.scriptPubkeyByPath.length(li(Se))},lastUsedIndexByFormatPath(Se){return qr(this,null,function*(){const[ke]=yield me.address(_e=>qr(this,null,function*(){return yield _e.lastUsedByFormatPath.query("",[li(Se)])}));return ke!=null?ke:-1})},fetchAddress(Se){return qr(this,null,function*(){return yield me.address(ke=>qr(this,null,function*(){if(typeof Se=="string"){const Je=Se,[it]=yield ke.addressByScriptPubkey.query("",[Je]);return it}const _e=Se,[Te]=yield ke.scriptPubkeyByPath.query(li(_e),_e.addressIndex);if(Te==null)return;const[We]=yield ke.addressByScriptPubkey.query("",[Te]);return We}))})}}})}var Lp=Object.defineProperty,Dp=Object.defineProperties,Up=Object.getOwnPropertyDescriptors,dh=Object.getOwnPropertySymbols,Hp=Object.prototype.hasOwnProperty,zp=Object.prototype.propertyIsEnumerable,ph=(R,O,z)=>O in R?Lp(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,Kp=(R,O)=>{for(var z in O||(O={}))Hp.call(O,z)&&ph(R,z,O[z]);if(dh)for(var z of dh(O))zp.call(O,z)&&ph(R,z,O[z]);return R},jp=(R,O)=>Dp(R,Up(O));const Wp=i("bip32","bip44","bip49"),Gp=n(Wp,"bip32");function Pc(R,O=0){return H(z=>{if(z==null||typeof z!="object")throw new TypeError("Private keys must be objects");return F({coinType:n(c,O),format:Gp,imported:n(f),seed:h})(jp(Kp({},z),{seed:z[`${R}Key`]}))},z=>{const{coinType:me,format:Me,imported:Re,seed:Se}=z;return{coinType:me,format:Me,imported:Re,[`${R}Key`]:Se}})}const vh=F({publicKeys:F({bip32:n(h),bip44:n(h),bip49:n(h),bip84:n(h)})}),Af=(R,O)=>{var z;const me=(()=>{switch(O){case"bip32":return["bip32"];case"bip44":return["bip44"];case"bip49":return["bip49","bip84"]}})(),Me=(z=R.formats)!=null?z:["bip44","bip32"];return me.filter(Re=>Me.includes(Re))},mh=R=>{const O=[];for(const[z,me]of Object.entries(R.publicKeys))me!=null&&O.push(z);return O.includes("bip49")?"bip49":O.includes("bip44")?"bip44":(O.includes("bip32"),"bip32")},gh=R=>O=>{const{coinInfo:z,engineInfo:me}=R,{id:Me,type:Re}=O,Se=Pc(z.name,z.coinType),ke=G(vh)(O.keys);if(ke!=null){const Te=Object.entries(ke.publicKeys).filter(([,Je])=>Je!=null).map(([Je])=>G(Ad)(Je)).filter(Je=>Je!=null);if(Te.length===0)throw new Error("Missing wallet public keys");const We=mh(ke);return{id:Me,type:Re,keys:{privateKeyFormat:We,walletFormats:Te,publicKey:ke}}}const _e=G(Se)(O.keys);if(_e!=null){const Te=Jp({engineInfo:me,privateKey:_e,coin:z.name}),We=Af(me,_e.format);return{id:Me,type:Re,keys:{privateKeyFormat:_e.format,walletFormats:We,publicKey:{publicKeys:Te}}}}throw new Error("Either a public or private key are required")};var Vp=Object.defineProperty,qp=Object.defineProperties,Xp=Object.getOwnPropertyDescriptors,yh=Object.getOwnPropertySymbols,Zp=Object.prototype.hasOwnProperty,Yp=Object.prototype.propertyIsEnumerable,bh=(R,O,z)=>O in R?Vp(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,Tf=(R,O)=>{for(var z in O||(O={}))Zp.call(O,z)&&bh(R,z,O[z]);if(yh)for(var z of yh(O))Yp.call(O,z)&&bh(R,z,O[z]);return R},Oc=(R,O)=>qp(R,Xp(O)),$p=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});const Bc=R=>{switch(R){case Sr.Airbitz:return"bip32";case Sr.Legacy:return"bip44";case Sr.WrappedSegwit:return"bip49";case Sr.Segwit:return"bip84";case Sr.ReplayProtection:return"bip44"}},Rc=R=>{switch(R){case Sr.Airbitz:case Sr.Legacy:return Ai.p2pkh;case Sr.WrappedSegwit:return Ai.p2sh;case Sr.Segwit:return Ai.p2wpkh;case Sr.ReplayProtection:return Ai.p2sh}},Pf=R=>{switch(R){case Sr.Airbitz:case Sr.Legacy:return wn.p2pkh;case Sr.WrappedSegwit:return wn.p2wpkhp2sh;case Sr.Segwit:return wn.p2wpkh;case Sr.ReplayProtection:return wn.replayProtection}},wh=R=>Ue(Tf({},R)),xh=(R,O)=>{const z=[0];return Oi(O)!==Sr.Airbitz&&z.push(1),R.scriptTemplates!=null&&R.scriptTemplates.replayProtection!=null&&z.push(ne(R.scriptTemplates.replayProtection)),z},Qi=(R,O)=>O!=null&&O.replayProtection!=null&&se(O.replayProtection,R)?Sr.ReplayProtection:Oi(R.format),Oi=R=>Aa(parseInt(R.replace("bip",""))),Mh=R=>$p(void 0,null,function*(){const O="walletKeys.json";let z;try{const me=yield R.walletLocalEncryptedDisklet.getText(O);z=JSON.parse(me)}catch{z=Eh(R),yield R.walletLocalEncryptedDisklet.setText(O,JSON.stringify(z))}return z}),Eh=R=>{const O={},z={seed:R.privateKey.seed,coinType:R.privateKey.coinType,coin:R.coin},me=Oi(R.privateKey.format);return me===Sr.Segwit||me===Sr.WrappedSegwit?(O[Bc(Sr.Segwit)]=P(Oc(Tf({},z),{type:Sr.Segwit})),O[Bc(Sr.WrappedSegwit)]=P(Oc(Tf({},z),{type:Sr.WrappedSegwit}))):O[Bc(me)]=P(Oc(Tf({},z),{type:me})),O},Jp=R=>{const{engineInfo:O,privateKey:z,coin:me}=R,Me={};for(const Re of Af(O,z.format)){const Se=Eh({coin:me,privateKey:z})[Re];if(Se==null)throw new Error("Cannot derive xpub: no private key exists");Me[Re]=X({coin:me,type:Oi(Re),xpriv:Se})}return Me},Qp=R=>{const O={};try{Zt({wifKey:R.pathname,coin:R.coin}),O.privateKeys=[R.pathname]}catch{const me=Zl({address:R.pathname,coin:R.coin});if(me===Ia.bad)throw new Error("InvalidPublicAddressError");O.publicAddress=Et(R.pathname,R.coin),me===Ia.legacy&&(O.legacyAddress=R.pathname)}return O},ev=R=>R.reduce((O,{spent:z,value:me})=>z?O:Ge.add(O,me),"0");var Sh=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});const tv=(R,O,z)=>Sh(void 0,null,function*(){const me=O.inputs[z],{scriptPubkey:Me}=me,Re=yield R.fetchAddress(Me);if(Re==null)throw new Error(`Cannot find address for ${Me}`);if(Re.path==null)throw new Error("Address has no derivation path information");const Se=Re.redeemScript,ke=Oi(Re.path.format),_e=Je=>Sh(void 0,null,function*(){switch(ke){case Sr.Airbitz:case Sr.Legacy:return{script:O.hex,scriptType:Se!=null?wn.p2sh:wn.p2pkh};case Sr.WrappedSegwit:return{script:Je,scriptType:wn.p2wpkhp2sh};case Sr.Segwit:return{script:Je,scriptType:wn.p2wpkh};default:throw new Error(`Unknown purpose type ${ke}`)}}),{script:Te,scriptType:We}=yield _e(Me);return{id:`${me.txId}_${me.outputIndex}`,txid:me.txId,vout:me.outputIndex,value:me.amount,scriptPubkey:Me,script:Te,redeemScript:Se,scriptType:We,blockHeight:O.blockHeight,spent:!0}});var rv=er(1160),kh=er.n(rv),_h=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});function nv(R){let O=0;const z=[];for(const me of R)O+=me.amount,z.push({publicAddress:me.address,nativeAmount:`${me.amount}`});return{nativeAmount:O,spendTargets:z}}function iv(R,O,z){return _h(this,null,function*(){const Me=yield z(R,{headers:{Accept:"application/payment-request","x-currency":O}});if(Me.status!==200){const pt=yield Me.text();throw new Error(pt)}const Re=yield Me.json(),{outputs:Se,memo:ke,paymentUrl:_e,paymentId:Te,requiredFeeRate:We}=Re,{nativeAmount:Je,spendTargets:it}=nv(Se),ct=kh()(_e,{}).hostname;return{nativeAmount:`${Je}`,merchant:`{ ${JSON.stringify(Te)}, ${JSON.stringify(We)} }`,memo:ke,domain:ct,spendTargets:it}})}function ov(R,O){return{currency:O,transactions:[R]}}function av(R,O,z){return _h(this,null,function*(){const Me=yield R(O,{method:"POST",headers:{"Content-Type":"application/payment"},body:JSON.stringify(z)});if(Me.status!==200){const Se=yield Me.text();throw new Error(Se)}return yield Me.json()})}var sv=Object.defineProperty,fv=Object.defineProperties,uv=Object.getOwnPropertyDescriptors,Ih=Object.getOwnPropertySymbols,lv=Object.prototype.hasOwnProperty,cv=Object.prototype.propertyIsEnumerable,Ah=(R,O,z)=>O in R?sv(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,hv=(R,O)=>{for(var z in O||(O={}))lv.call(O,z)&&Ah(R,z,O[z]);if(Ih)for(var z of Ih(O))cv.call(O,z)&&Ah(R,z,O[z]);return R},dv=(R,O)=>fv(R,uv(O)),pv=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});const vv=(R,O,z)=>pv(void 0,null,function*(){const me=[],Me=z.inputs.map(Se=>`${Se.txId}_${Se.outputIndex}`),Re=yield O.fetchUtxos({utxoIds:Me});for(const Se of Re)Se!=null&&me.push(dv(hv({},Se),{spent:!0}));for(const Se of z.outputs){const ke=Se.scriptPubkey,_e=yield O.fetchAddress(ke);if(_e!=null){const Te=`${z.txid}_${Se.n}`,We=_e.path;if(We!=null){const Je=_e.redeemScript,it=Qi(We,R.scriptTemplates),ct=[Sr.Airbitz,Sr.Legacy,Sr.ReplayProtection].includes(it),dt=Pf(it),pt=ct?z.hex:_e.scriptPubkey,St={id:Te,txid:z.txid,vout:Se.n,value:Se.amount,scriptPubkey:ke,script:pt,redeemScript:Je,scriptType:dt,blockHeight:z.blockHeight,spent:!1};me.push(St)}}}return me});class Vn{constructor(){this._resolve=()=>{},this._reject=()=>{},this._promise=new Promise((O,z)=>{this._reject=z,this._resolve=O})}get promise(){return this._promise}resolve(O){this._resolve(O)}reject(O){this._reject(O)}}const mv=100,gv=.05,yv=2,Th=8;var Ph=er(6579),bv=Object.defineProperty,wv=Object.defineProperties,xv=Object.getOwnPropertyDescriptors,Oh=Object.getOwnPropertySymbols,Mv=Object.prototype.hasOwnProperty,Ev=Object.prototype.propertyIsEnumerable,Bh=(R,O,z)=>O in R?bv(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,Rh=(R,O)=>{for(var z in O||(O={}))Mv.call(O,z)&&Bh(R,z,O[z]);if(Oh)for(var z of Oh(O))Ev.call(O,z)&&Bh(R,z,O[z]);return R},Sv=(R,O)=>wv(R,xv(O));const kv=(R=h)=>F({txid:h,vout:c,value:h,confirmations:n(c),coinbase:n(f),height:n(c),lockTime:n(c),address:n(R),path:n(h)}),Cc=(R=h)=>F({txid:h,hex:h,blockHeight:c,confirmations:c,blockTime:c,fees:h,vin:Z(F({txid:h,sequence:n(c),n:c,vout:n(c,0),addresses:Z(R),isAddress:f,value:h,hex:n(h)})),vout:Z(F({n:c,value:h,addresses:Z(R),hex:n(h)}))}),_v=F({error:F({message:h})}),qn=R=>O=>{const z=G(_v)(O);if(z!=null)throw new Error(`Blockbook Error: ${z.error.message}`);return R(O)},Iv=()=>({method:"ping",params:void 0,cleaner:qn(Av)}),Av=F({}),Tv=()=>({method:"getInfo",params:{},cleaner:qn(Pv)}),Pv=F({name:h,shortcut:h,decimals:c,version:h,bestHeight:c,bestHash:h,block0Hash:h,testnet:f,backend:n(F({version:h,subversion:h}))}),Ch=(R,O=h)=>({method:"getAccountUtxo",params:{descriptor:oe(O)(R)},cleaner:qn(Ov(O))}),Ov=(R=h)=>Z(kv(R)),Fh=(R,O=h)=>({method:"getTransaction",params:{txid:R},cleaner:qn(Bv(O))}),Bv=Cc,Rv=R=>({method:"getTransactionSpecific",params:{txid:R},cleaner:qn(a)}),Cv=R=>({method:"sendTransaction",params:{hex:R},cleaner:qn(Nh)}),Nh=F({result:h}),Lh=(R,O=h,z={})=>{const me=oe(O);return{method:"getAccountInfo",params:Sv(Rh({},Rh({details:"basic",page:1,pageSize:100},z)),{descriptor:me(R)}),cleaner:qn(Fv(O))}},Fv=(R=h)=>F({address:R,balance:h,totalReceived:h,totalSent:h,txs:c,unconfirmedBalance:h,unconfirmedTxs:c,txids:n(Z(h),[]),transactions:n(Z(Cc(R)),[]),page:n(c,NaN),totalPages:n(c,NaN),itemsOnPage:n(c,NaN)}),Nv=()=>({method:"subscribeNewBlock",params:{},cleaner:qn(Lv)}),Lv=F({height:c,hash:h}),Dv=(R,O=h)=>{const z=oe(O);return{method:"subscribeAddresses",params:{addresses:R.map(z)},cleaner:qn(Uv(O))}},Uv=(R=h)=>F({address:R,tx:Cc(R)});var Hv=er(7689),eo=er.n(Hv),xn=(R=>(R[R.CONNECTING=0]="CONNECTING",R[R.OPEN=1]="OPEN",R[R.CLOSING=2]="CLOSING",R[R.CLOSED=3]="CLOSED",R))(xn||{});function zv(R,O){const z=new(eo())(R,{headers:{"User-Agent":"NodeJS-WS-agent"}});return z.on("open",()=>{O.onOpen()}),z.on("message",me=>{O.onMessage(me.toString())}),z.on("error",me=>{O.onError(me)}),z.on("close",me=>{O.onClose()}),{get readyState(){switch(z.readyState){case eo().CONNECTING:return xn.CONNECTING;case eo().OPEN:return xn.OPEN;case eo().CLOSING:return xn.CLOSING;case eo().CLOSED:default:return xn.CLOSED}},disconnect(){z==null||z.readyState===eo().CLOSING||z.readyState===eo().CLOSED||(z.removeAllListeners(),z.close())},send(me){z.send(me)}}}class Kv extends J0.EventEmitter{}var to=(R=>(R.CONNECTION_OPEN="connection:open",R.CONNECTION_CLOSE="connection:close",R.CONNECTION_TIMER="connection:timer",R))(to||{});const Dh=3,jv=1e3,Tn=[];let Uh;function Hh(R){const O=Tn.length===0;let z=!1;for(const me of Tn)if(me.id===R.id&&me.action===R.action){me.updateFunc=R.updateFunc,z=!0;break}z||Tn.push(R),O&&Kh()}function zh(R){for(let O=0;O<Tn.length;O++){const z=Tn[O];if(R===z.id){Tn.splice(O,1);break}}Tn.length===0&&clearTimeout(Uh)}function Kh(){const R=Dh<Tn.length?Dh:Tn.length;for(let O=0;O<R;O++)if(Tn.length>0){const z=Tn.shift();z==null||z.updateFunc()}Tn.length>0&&(Uh=setTimeout(()=>{Kh()},jv))}function Wv(R,O){if(window.WebSocket==null)throw Error("Native browser WebSocket does not exists");const z=new window.WebSocket(R);return z.onopen=()=>{O.onOpen()},z.onmessage=me=>{O.onMessage(me.data.toString())},z.onerror=()=>{O.onError()},z.onclose=()=>{O.onClose()},{get readyState(){switch(z.readyState){case WebSocket.CONNECTING:return xn.CONNECTING;case WebSocket.OPEN:return xn.OPEN;case WebSocket.CLOSING:return xn.CLOSING;case WebSocket.CLOSED:default:return xn.CLOSED}},disconnect(){z==null||z.readyState===WebSocket.CLOSING||z.readyState===WebSocket.CLOSED||z.close()},send(me){z.send(me)}}}var jh=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});const Wh=500,Gv=5e4,Vv=5e3,qv=F({subscribed:f}),Xv=J(F({id:h,data:n(a),error:n(re(F({message:h}),F({connected:h})))})),Zv=R=>[Xv(R)];function Yv(R,O){var z;let me;const{asResponse:Me=Zv,emitter:Re,log:Se,queueSize:ke=50,walletId:_e}=O;Se("makeSocket connects to",R);const Te="",We=_e+"=="+R,Je={};let it=O.onQueueSpaceCB,ct={},dt=0,pt=0,St=0,Ut=!1,Jt=!1;const ur=1e3*((z=O.timeout)!=null?z:30);let _t,Bt;const Lt=Pt=>{_t==null&&(_t=Pt),Ut&&me!=null&&me.readyState===xn.OPEN?Ft():Jt=!0,Se.error("handled error!",Pt)},Ft=()=>{Se.warn("disconnecting from socket",R),clearTimeout(Bt),Ut=!1,me!=null&&me.disconnect(),zh(We)},jt=()=>{const Pt=_t!=null?_t:new Error("Socket close");Se.warn(`onSocketClose due to ${Pt.message} with server ${R}`),clearTimeout(Bt),Ut=!1,me=null,Jt=!1;for(const Ht of Object.values(ct))try{Ht.task.deferred.reject(Pt)}catch(Qt){Se.error(Qt.message)}ct={};try{Re.emit(to.CONNECTION_CLOSE,R,Pt)}catch(Ht){Se.error(Ht.message)}},It=()=>{if(Se(`onSocketConnect with server ${R}`),Jt){me!=null&&me.disconnect();return}Ut=!0,pt=Date.now();try{Re.emit(to.CONNECTION_OPEN,R)}catch(Pt){Lt(Pt)}for(const[Pt,Ht]of Object.entries(ct))br(Pt,Ht);wt(),Jt=!1},wt=()=>{Se(`wakeUp socket with server ${R}`),Hh({id:We,updateFunc:()=>{Nt().catch(Pt=>{throw new Error(`wake up error from: ${Pt.message}`)})}})},Nt=()=>jh(this,null,function*(){if(Se(`doWakeUp socket with server ${R}`),St=Date.now(),Ut&&Te!=null)for(;Object.keys(ct).length<ke;){const Pt=yield it(R);if(Pt==null)break;if(typeof Pt=="boolean"){if(Pt)continue;break}tr(Pt)}}),Rt=Pt=>{var Ht;if(me!=null&&me.readyState===xn.OPEN&&Ut){const Qt=Pt.method,wr={id:Qt,method:Pt.method,params:(Ht=Pt.params)!=null?Ht:{}};Je[Qt]=Pt,me.send(JSON.stringify(wr))}},tr=Pt=>{const Ht=(dt++).toString(),Qt={task:Pt,startTime:Date.now()};ct[Ht]=Qt,br(Ht,Qt)},br=(Pt,Ht)=>{var Qt;const wr=Date.now();if(me!=null&&me.readyState===xn.OPEN&&Ut&&!Jt){Ht.startTime=wr;const xr={id:Pt,method:Ht.task.method,params:(Qt=Ht.task.params)!=null?Qt:{}};me.send(JSON.stringify(xr)+`
|
|
71
|
+
`],wif:[210],legacyXPriv:[76066276],legacyXPub:[76067358],pubkeyHash:[82],scriptHash:[7]}}}];function un(R){const O=Oo.find(z=>z.coinInfo.name===R);if(O==null)throw new Error("Could not find coin info "+R);return O.coinInfo}var Wt=er(3689);const pl=Wt.WK,vl=Wt.DE,ml=Wt.k5,gl=Wt.Dr,yl=Wt.ef,Xc=Wt.GY,Zc=Wt.WM,bl=Wt.Kz,Yc=Wt.uX,$c=Wt.IK,Ea=Wt.gw,wl=Wt.WU,xl=Wt.G8,Jc=Wt.xQ,pf=Wt.D7,Qc=Wt.hi,e0=Wt.zU,Ml=Wt.dq,t0=Wt.m$,r0=Wt.MU,vf=Wt.ID,El=Wt.k0,Sl=Wt.D4,n0=Wt.kL,i0=Wt.jx,o0=Wt.A_,kl=Wt.v1,mf=Wt.TL,gf=Wt.Og,a0=Wt.ft,s0=Wt.KU,f0=Wt.ZU,u0=Wt.ye,l0=Wt.Xj,c0=Wt.Rn,Sa=Wt.bo,h0=Wt.KL,yf=Wt.rW,d0=Wt.U3,p0=Wt.$Y,v0=Wt.EJ,m0=Wt.XY,g0=Wt.v7,y0=Wt.up,b0=Wt.h,w0=Wt.Cx,x0=Wt.Zz,M0=Wt.CU,bf=Wt.ib,E0=Wt.eT,S0=Wt._0,k0=Wt.UR,_0=Wt.Up,Wn=Wt.y0,I0=Wt.A2,A0=Wt.ql,T0=Wt.FX,P0=Wt.Jr,O0=Wt.zS,B0=Wt.pK,_l=Wt.ud,R0=Wt.Zk,Il=Wt.Mf,C0=Wt.U0,wf=Wt.CX,F0=Wt.l4,Al=Wt.Jv,N0=Wt.T0,L0=Wt.z8,Bo=Wt.Gt,Tl=Wt.Fm,Ir=Wt.b4,ln=Wt.N2,Zi=Wt.K8,Er=Wt.gB,An=Wt.bd,D0=Wt.GG,Yi=Wt.V$,Nr=Wt.CC,ka=Wt.dT,U0=Wt.uT,vn=Wt._j,Pl=Wt.p4,Ol=Wt.W0,Bl=Wt.zk,H0=Wt.AB,Rl=Wt.sn,z0=Wt._u,K0=Wt.Py,Cl=Wt.iu,j0=Wt.l7,Fl=Wt.JU,W0=Wt.O6;class xf extends ml{constructor(O){super(O);const{networkFeeShortage:z}=O;this.networkFeeShortage=z}}function Nl(R){return function(z){if(z instanceof Error&&z.name===R)return z}}const Ll=Nl("InsufficientFundsError"),Dl={forceUseUtxo:hs,subtractFee:So,accumulative:ss};var Gr=er(8287).Buffer,Ro=Object.defineProperty,Ul=Object.defineProperties,Hl=Object.getOwnPropertyDescriptors,Mf=Object.getOwnPropertySymbols,zl=Object.prototype.hasOwnProperty,Kl=Object.prototype.propertyIsEnumerable,_a=(R,O,z)=>O in R?Ro(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,jl=(R,O)=>{for(var z in O||(O={}))zl.call(O,z)&&_a(R,z,O[z]);if(Mf)for(var z of Mf(O))Kl.call(O,z)&&_a(R,z,O[z]);return R},Wl=(R,O)=>Ul(R,Hl(O)),Gl=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});let ii;er.e(669).then(er.bind(er,7050)).then(R=>{(0,pe.f0)(R),ii=(0,Pe.dg)(R)}).catch(R=>{console.error(R)}).finally(()=>{console.log("loaded ECPair!")});var Sr=(R=>(R.Airbitz="airbitz",R.Legacy="legacy",R.Segwit="segwit",R.WrappedSegwit="wrappedSegwit",R.ReplayProtection="replayProtection",R))(Sr||{}),Ai=(R=>(R.p2pkh="p2pkh",R.p2sh="p2sh",R.p2wpkh="p2wpkh",R.p2wsh="p2wsh",R.p2tr="p2tr",R))(Ai||{}),wn=(R=>(R.p2wpkh="p2wpkh",R.p2wpkhp2sh="p2wpkhp2sh",R.p2wsh="p2wsh",R.p2pk="p2pk",R.p2pkh="p2pkh",R.p2sh="p2sh",R.p2tr="p2tr",R.replayProtection="replayprotection",R.replayProtectionP2SH="replayprotectionp2sh",R))(wn||{});const Vl=i("p2wpkh","p2wpkhp2sh","p2wsh","p2pk","p2pkh","p2sh","p2tr","replayprotection","replayprotectionp2sh");var ql=(R=>(R.Legacy="legacy",R.Segwit="segwit",R))(ql||{}),Ia=(R=>(R.good="good",R.legacy="legacy",R.bad="bad",R))(Ia||{});function Aa(R){switch(R){case 32:return"airbitz";case 44:return"legacy";case 49:return"wrappedSegwit";case 84:return"segwit";default:throw new Error("InvalidPurposeNumber")}}const Xl=(R,O)=>{const z=un(O.coin),me=kr({coinString:O.coin,prefixIndex:R}),Me=Vr(z);if(Me.length>0){try{return Ze(O.address,Me),"good"}catch{}return on(O.address,me,O.coin,void 0),"legacy"}return on(O.address,me,O.coin,void 0),R===0?"good":"legacy"},Zl=R=>{const O=Lr(R.coin,z=>Xl(z,R),[`Could not determine address type of ${R.address}`]);return O!=null?O:"bad"},_=(R,O)=>{const z=Lr(O,me=>{const Me=kr({coinString:O,prefixIndex:me});return on(R,Me,O)},[`Could not determine address type of ${R}`]);if(z==null)throw new Error("Could not determine address type");return z};function P(R){var O,z,me;const Me=R.seed.includes(" "),Re=Me?te.kw(R.seed):Gr.from(R.seed,"base64"),Se=kr({coinString:R.coin,sigType:R.type,prefixIndex:0}),ke=un(R.coin),_e=_r(R.type),Te=(O=R.coinType)!=null?O:ke.coinType,We=(z=R.account)!=null?z:0,it=((me=ke.bip32FromSeedFunc)!=null?me:ce.CC)(Re);return it.network=Se,_e===32||!Me?it.derive(0).toBase58():it.deriveHardened(_e).deriveHardened(Te).deriveHardened(We).toBase58()}const W=(R,O)=>{var z;const me=kr({coinString:O.coin,sigType:O.type,prefixIndex:R});return((z=un(O.coin).bip32FromBase58Func)!=null?z:ce.n3)(O.xpriv,me).neutered().toBase58()},X=R=>{const O=Lr(R.coin,z=>W(z,R),["Invalid private key"]);if(O==null)throw Error("unable to convert xpriv to xpub");return O};function ne(R){let O="0000";return O=pe.Et.hash160(Gr.from(R(""),"hex")).slice(0,4).toString("hex"),parseInt(O,16)}const se=(R,O)=>O.changeIndex===ne(R),de=(R,O)=>{var z;const me=un(O.coin),Me=kr({coinString:O.coin,sigType:O.type,prefixIndex:R});return((z=me.bip32FromBase58Func)!=null?z:ce.n3)(O.xpub,Me).derive(O.bip44ChangeIndex).derive(O.bip44AddressIndex).publicKey.toString("hex")},Be=R=>{const O=Lr(R.coin,z=>de(z,R),["Invalid network version"]);if(O==null)throw Error("unable to derive pubkey from xpub");return O},Ae=(R,O)=>{const z=un(O.coin),me=Vr(z),Me=kr({coinString:O.coin,prefixIndex:R}),Re=kn(z.prefixes,R),Se=on(O.address,Me,O.coin,O.addressType);let ke;const _e=()=>{try{return Ze(O.address,me).scriptHash.toString("hex")}catch{}};switch(Se){case"p2pkh":if(Re.cashaddr!=null){const We=_e();if(We!=null){const Je=mn({scriptHash:We,scriptType:"p2pkh",coin:O.coin});if(Je==null)throw new Error(`unable to convert address ${O.address} to script pubkey`);return Je}}ke=pe.KT.p2pkh;break;case"p2sh":if(Re.cashaddr!=null){const We=_e();if(We!=null){const Je=mn({scriptHash:We,scriptType:"p2sh",coin:O.coin});if(Je==null)throw new Error(`unable to convert address ${O.address} to script pubkey`);return Je}}ke=pe.KT.p2sh;break;case"p2wpkh":ke=pe.KT.p2wpkh;break;case"p2wsh":ke=pe.KT.p2wsh;break;case"p2tr":ke=pe.KT.p2tr;break;default:throw new Error("invalid address type in address to script pubkey")}let Te;try{Te=ke({address:O.address,network:Me,bs58DecodeFunc:z.bs58DecodeFunc,bs58EncodeFunc:z.bs58EncodeFunc}).output}catch(We){throw console.trace(We),We}if(Te==null)throw new Error("failed converting address to scriptPubkey");return Te.toString("hex")},Ue=R=>{const O=Lr(R.coin,z=>Ae(z,R),["Invalid version or Network mismatch","Invalid prefix or Network mismatch",`InvalidArgument: ${R.address} has Mixed case`,`Could not determine address type of ${R.address}`]);if(O==null)throw new Error(`unable to convert address ${R.address} to script pubkey`);return O};function $e(R){const O=kr({coinString:R.coin,prefixIndex:0}),z=kr({coinString:R.coin,prefixIndex:1}),me=un(R.coin),Me=me.prefixes,Re=kn(Me,0),Se=kn(Me,1);let ke,_e,Te;switch(R.addressType){case"p2pkh":Re.cashaddr!=null&&(ke=Ke(nt({scriptPubkey:R.scriptPubkey,scriptType:"p2pkh",coin:R.coin}),Ee.pubkeyhash,Re.cashaddr)),Se.cashaddr!=null&&(_e=Ke(nt({scriptPubkey:R.scriptPubkey,scriptType:"p2pkh",coin:R.coin}),Ee.pubkeyhash,Se.cashaddr)),Te=pe.KT.p2pkh;break;case"p2sh":Re.cashaddr!=null&&(ke=Ke(nt({scriptPubkey:R.scriptPubkey,scriptType:"p2sh",coin:R.coin}),Ee.scripthash,Re.cashaddr)),Se.cashaddr!=null&&(_e=Ke(nt({scriptPubkey:R.scriptPubkey,scriptType:"p2sh",coin:R.coin}),Ee.scripthash,Se.cashaddr)),Te=pe.KT.p2sh;break;case"p2wpkh":Te=pe.KT.p2wpkh;break;case"p2wsh":Te=pe.KT.p2wsh;break;case"p2tr":Te=pe.KT.p2tr;break;default:throw new Error("invalid address type in address to script pubkey")}try{ke=ke!=null?ke:Te({output:Gr.from(R.scriptPubkey,"hex"),network:O,bs58DecodeFunc:me.bs58DecodeFunc,bs58EncodeFunc:me.bs58EncodeFunc}).address,_e=_e!=null?_e:Te({output:Gr.from(R.scriptPubkey,"hex"),network:z,bs58DecodeFunc:me.bs58DecodeFunc,bs58EncodeFunc:me.bs58EncodeFunc}).address}catch(We){throw console.trace(We),We}if(ke==null||_e==null)throw new Error("failed converting scriptPubkey to address");return{address:ke,legacyAddress:_e}}function nt(R){const O=kr({coinString:R.coin,prefixIndex:0});let z;switch(R.scriptType){case"p2pkh":z=pe.KT.p2pkh;break;case"p2sh":z=pe.KT.p2sh;break;case"p2wpkh":z=pe.KT.p2wpkh;break;case"p2tr":z=pe.KT.p2tr;break;default:throw new Error("invalid address type in address to script pubkey")}let me;try{me=z({output:Gr.from(R.scriptPubkey,"hex"),network:O}).hash}catch(Me){throw console.trace(Me),Me}if(me==null)throw new Error("failed converting scriptPubkey to address");return me.toString("hex")}function Ye(R){var O,z,me,Me;const{scriptPubkey:Re,coin:Se}=R;let ke;Se!=null&&(ke=kr({coinString:Se,prefixIndex:0}));const _e=pe.KT.p2sh(Wl(jl({},ke!=null?{network:ke}:{}),{redeem:{output:Gr.from(Re,"hex")}})),Te=(O=_e.output)==null?void 0:O.toString("hex"),We=(me=(z=_e.redeem)==null?void 0:z.output)==null?void 0:me.toString("hex"),Je=(Me=_e.hash)==null?void 0:Me.toString("hex");if(Te==null||We==null)throw new Error("unable to convert script to p2sh");let it=_e.address;if(Se!=null&&Je!=null){const dt=un(Se).prefixes,pt=kn(dt,0);pt.cashaddr!=null&&(it=Ke(Je,Ee.scripthash,pt.cashaddr))}return{scriptPubkey:Te,redeemScript:We,address:it}}function vt(R){let O;switch(R.scriptType){case"p2pkh":{if(O=pe.KT.p2pkh({pubkey:Gr.from(R.pubkey,"hex")}),O.output==null)throw new Error("failed converting pubkey to script pubkey");return{scriptPubkey:O.output.toString("hex")}}case"p2wpkhp2sh":return Ye({scriptPubkey:vt({pubkey:R.pubkey,scriptType:"p2wpkh"}).scriptPubkey});case"p2wpkh":{if(O=pe.KT.p2wpkh({pubkey:Gr.from(R.pubkey,"hex")}),O.output==null)throw new Error("failed converting pubkey to script pubkey");return{scriptPubkey:O.output.toString("hex")}}case"p2tr":{if(O=pe.KT.p2tr({pubkey:Gr.from(R.pubkey,"hex")}),O.output==null)throw new Error("failed converting pubkey to script pubkey");return{scriptPubkey:O.output.toString("hex")}}case"replayprotection":{if(R.scriptTemplates==null)throw new Error("Missing replayProtection script template");const z=R.scriptTemplates.replayProtection(R.pubkey);return Ye({scriptPubkey:z})}default:throw new Error("invalid address type in pubkey to script pubkey")}}const Et=(R,O)=>{const z=_(R,O);return $e({scriptPubkey:Ue({address:R,coin:O}),addressType:z,coin:O}).address},mt=(R,O)=>{var z,me;const Me=un(O.coin),Re=kr({coinString:O.coin,sigType:O.type,prefixIndex:R});return(me=((z=Me.bip32FromBase58Func)!=null?z:ce.n3)(O.xpriv,Re).derive(O.bip44ChangeIndex).derive(O.bip44AddressIndex).privateKey)==null?void 0:me.toString("hex")},Mt=R=>{const O=Lr(R.coin,z=>mt(z,R),["Invalid network version"]);if(O==null)throw new Error("Failed to generate private key from xpriv");return O};function Ot(R){const O=kr({coinString:R.coin,forWIF:!0,prefixIndex:0}),z=getCoinFromString(R.coin);return ii.fromPrivateKey(Gr.from(R.privateKey,"hex"),{network:O}).toWIF(z.wifEncodeFunc)}const Vt=(R,O)=>{const z=un(O.coin),me=kr({coinString:O.coin,forWIF:!0,prefixIndex:R}),Me=ii.fromWIF(O.wifKey,me,z.bs58DecodeFunc);if(Me.privateKey!=null)return{hex:Me.privateKey.toString("hex"),compressed:Me.compressed}},Zt=R=>{const O=Lr(R.coin,z=>Vt(z,R),["Invalid network version"]);if(O==null)throw new Error("Failed to convert WIF key to private key");return O};function ir(R){const{hex:O,compressed:z}=R;return ii.fromPrivateKey(Gr.from(O,"hex"),{compressed:z}).publicKey.toString("hex")}function vr(R,O){const z=ii.fromPrivateKey(Gr.from(O,"hex"));if(z.privateKey==null)throw new Error("Address could not sign message");return ge().sign(R,z.privateKey,z.compressed).toString("base64")}function br(R){var O,z,me,Me,Re,Se;const{log:ke,outputSort:_e,memos:Te}=R;let We=4294967295;R.enableRbf&&(We-=2);let Je=pe.ZX.SIGHASH_ALL;const it=un(R.coin);it.sighash!=null&&(Je=it.sighash);const ct=[],dt=[],St=[...[...R.utxos,...R.forceUseUtxo].filter(It=>!It.spent).reduce((It,wt)=>It.set(wt.id,wt),new Map).values()].sort((It,wt)=>It.blockHeight<=0&&wt.blockHeight>0?1:wt.blockHeight<=0&&It.blockHeight>0?-1:(0,Ge.lt)(It.value,wt.value)?1:(0,Ge.gt)(It.value,wt.value)?-1:0);for(const It of St){if(It.script==null)continue;const wt={hash:Gr.from(It.txid,"hex").reverse(),index:It.vout,value:parseInt(It.value),script:Gr.from(It.script,"hex"),scriptPubkey:Gr.from(It.scriptPubkey,"hex"),scriptType:It.scriptType,sequence:We,sighashType:Je};switch(It.scriptType){case"p2pk":case"p2pkh":case"p2sh":case"replayprotection":case"replayprotectionp2sh":{wt.nonWitnessUtxo=wt.script;break}case"p2wpkh":case"p2wpkhp2sh":case"p2wsh":{wt.witnessUtxo={script:wt.script,value:parseInt(It.value)};break}default:throw new Error(`unknown script type ${It.scriptType}`)}It.redeemScript!=null&&(wt.redeemScript=Gr.from(It.redeemScript,"hex"));let Nt=!1;for(const Rt of R.forceUseUtxo)Rt.id===It.id&&(ct.push(wt),Nt=!0);Nt||dt.push(wt)}const Ut=[];for(const It of R.targets){if(It.value==null)continue;const wt=It.address==null?It.scriptPubkey:Ue({address:It.address,coin:it.name});wt!=null&&Ut.push({script:wt,value:It.value})}for(const It of Te){const wt=It.type==="text"?Gr.from(It.value,"utf8"):Gr.from(It.value,"hex"),Nt=pe.K$.compile([pe.Ez.OP_RETURN,wt]).toString("hex");Ut.push({script:Nt,value:0})}const Jt=Ue({address:R.freshChangeAddress,coin:it.name}),ur=(O=it.utxoPicker)!=null?O:Dl,Bt=(R.forceUseUtxo.length>0?ur.forceUseUtxo:(z=R.subtractFee)!=null&&z?ur.subtractFee:ur.accumulative)({utxos:dt,useUtxos:ct,targets:Ut,feeRate:R.feeRate,changeScript:Jt});if(Bt.outputs==null){const It=pn(Ut),wt=pn(Bt.inputs),Nt=Bt.fee-(wt-It);throw new xf({tokenId:null,networkFee:Bt.fee.toString(),networkFeeShortage:Nt.toString()})}const Lt=kt(Bt.inputs),Ft=(()=>{switch(_e){case"bip69":return ae(Bt.outputs);case"targets":return Bt.outputs}})(),jt=new pe.iL;try{jt.addInputs(Lt),jt.addOutputs(Ft)}catch(It){throw ke==null||ke.error(`Failed makeTx: ${String(It)}`),It}return{inputs:Lt,outputs:Ft,changeUsed:Bt.changeUsed,fee:Bt.fee,psbtBase64:jt.toBase64(),hex:(Se=(Re=(Me=(me=jt.data)==null?void 0:me.globalMap)==null?void 0:Me.unsignedTx)==null?void 0:Re.toBuffer())==null?void 0:Se.toString("hex")}}function Pr(R){return Gl(this,null,function*(){var O;const{maximumFeeRate:z}=R.feeInfo,me=z!=null?{maximumFeeRate:parseInt(z)}:{},Me=pe.iL.fromBase64(R.psbtBase64,me),Re=un(R.coin),Se=(_e,Te,We)=>ii.fromPublicKey(_e).verify(Te,We);for(let _e=0;_e<Me.inputCount;_e++){const Te=(O=R.privateKeyEncodings[_e])!=null?O:R.privateKeyEncodings[R.privateKeyEncodings.length-1],{hex:We,compressed:Je}=Te;Me.signInput(_e,ii.fromPrivateKey(Gr.from(We,"hex"),{compressed:Je}),pe.iL.DEFAULT_SIGHASHES,Re.sighashFunction),Me.validateSignaturesOfInput(_e,Se),Me.finalizeInput(_e)}const ke=Me.extractTransaction();return{id:ke.getId(Re.txHashFunction),hex:ke.toHex()}})}const kr=R=>{var O,z;const me=(O=R.sigType)!=null?O:"legacy",Me=(z=R.forWIF)!=null?z:!1,Re=un(R.coinString);return Ar(me,Re.prefixes,Re.segwit,Me,R.prefixIndex)},Ar=(R,O,z,me,Me)=>{var Re;let Se;const ke=kn(O,Me);switch(R){case"segwit":if(ke.segwitXPub==null||ke.segwitXPriv==null)throw new Error("segwit xpub prefix is undefined");Se={public:ke.segwitXPub,private:ke.segwitXPriv};break;case"wrappedSegwit":if(ke.wrappedSegwitXPub==null||ke.wrappedSegwitXPriv==null)throw new Error("wrapped segwit xpub prefix is undefined");Se={public:ke.wrappedSegwitXPub,private:ke.wrappedSegwitXPriv};break;case"legacy":case"airbitz":Se={public:ke.legacyXPub,private:ke.legacyXPriv};break;default:throw new Error("invalid bip43 purpose type")}const _e=(Re=ke.bech32)!=null?Re:"";return me?{messagePrefix:ke.messagePrefix,wif:ke.wif,bip32:Se,bech32:_e,pubKeyHash:ke.pubkeyHash,scriptHash:ke.scriptHash}:{messagePrefix:ke.messagePrefix,wif:128,bip32:Se,bech32:_e,pubKeyHash:ke.pubkeyHash,scriptHash:ke.scriptHash}},_r=R=>{switch(R){case"airbitz":return 32;case"legacy":return 44;case"wrappedSegwit":return 49;case"segwit":return 84;case"replayProtection":return 44}},Lr=(R,O,z=[])=>{const me=un(R).prefixes,Me=Object.values(me).reduce((Se,ke)=>Math.max(ke.length,Se),0);let Re;for(let Se=0;Se<Me;Se++){try{Re=O(Se)}catch(ke){if(z.includes(ke.message))continue;throw ke}if(Re!=null)break}return Re},Vr=R=>{var O;return(O=R.prefixes.cashaddr)!=null?O:[]},on=(R,O,z,me)=>{if(me!=null)return me;const Me=un(z);try{return pe.KT.p2pkh({address:R,network:O,bs58DecodeFunc:Me.bs58DecodeFunc,bs58EncodeFunc:Me.bs58EncodeFunc}),"p2pkh"}catch{}try{return pe.KT.p2sh({address:R,network:O,bs58DecodeFunc:Me.bs58DecodeFunc,bs58EncodeFunc:Me.bs58EncodeFunc}),"p2sh"}catch{}try{return pe.KT.p2wsh({address:R,network:O}),"p2wsh"}catch{}try{return pe.KT.p2wpkh({address:R,network:O}),"p2wpkh"}catch{}try{return pe.KT.p2tr({address:R,network:O}),"p2tr"}catch{}const Re=Vr(Me);if(Re.length>0)try{return Ze(R,Re).type===Ee.pubkeyhash?"p2pkh":"p2sh"}catch{}throw new Error(`Could not determine address type of ${R}`)},kn=(R,O)=>{var z;return{messagePrefix:lt(R.messagePrefix,O),wif:lt(R.wif,O),legacyXPriv:lt(R.legacyXPriv,O),legacyXPub:lt(R.legacyXPub,O),wrappedSegwitXPriv:lt(R.wrappedSegwitXPriv,O),wrappedSegwitXPub:lt(R.wrappedSegwitXPub,O),segwitXPriv:lt(R.segwitXPriv,O),segwitXPub:lt(R.segwitXPub,O),pubkeyHash:lt(R.pubkeyHash,O),scriptHash:lt(R.scriptHash,O),bech32:lt(R.bech32,O),cashaddr:Le(((z=R.cashaddr)!=null?z:[])[O])}},mn=R=>{const O=kr({coinString:R.coin,prefixIndex:0});let z;switch(R.scriptType){case"p2pkh":z=pe.KT.p2pkh;break;case"p2sh":z=pe.KT.p2sh;break;case"p2wpkh":z=pe.KT.p2wpkh;break;case"p2tr":z=pe.KT.p2tr;break;default:throw new Error("invalid address type in address to script pubkey")}let me;try{me=z({hash:Gr.from(R.scriptHash,"hex"),network:O}).output}catch(Me){throw console.trace(Me),Me}if(me==null)throw new Error("failed converting scriptPubkey to address");return me.toString("hex")};var Ln=Object.defineProperty,jr=Object.getOwnPropertySymbols,$i=Object.prototype.hasOwnProperty,Gn=Object.prototype.propertyIsEnumerable,oi=(R,O,z)=>O in R?Ln(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,ai=(R,O)=>{for(var z in O||(O={}))$i.call(O,z)&&oi(R,z,O[z]);if(jr)for(var z of jr(O))Gn.call(O,z)&&oi(R,z,O[z]);return R},Co=(R,O)=>{var z={};for(var me in R)$i.call(R,me)&&O.indexOf(me)<0&&(z[me]=R[me]);if(R!=null&&jr)for(var me of jr(R))O.indexOf(me)<0&&Gn.call(R,me)&&(z[me]=R[me]);return z};const si=R=>{const O=R,{scriptPubkey:z,used:me=!1}=O,Me=Co(O,["scriptPubkey","used"]);return ai({scriptPubkey:z,used:me,lastQueriedBlockHeight:0,lastQuery:0,lastTouched:0},Me)},Ta=F({id:h,txid:h,vout:c,value:h,scriptPubkey:h,script:h,redeemScript:n(h),scriptType:Vl,blockHeight:c,spent:f});var Yl=Object.defineProperty,$l=Object.defineProperties,Jl=Object.getOwnPropertyDescriptors,G0=Object.getOwnPropertySymbols,Sd=Object.prototype.hasOwnProperty,kd=Object.prototype.propertyIsEnumerable,V0=(R,O,z)=>O in R?Yl(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,_d=(R,O)=>{for(var z in O||(O={}))Sd.call(O,z)&&V0(R,z,O[z]);if(G0)for(var z of G0(O))kd.call(O,z)&&V0(R,z,O[z]);return R},Id=(R,O)=>$l(R,Jl(O));const Ad=i("bip32","bip44","bip49","bip84"),Td=F({utxos:n(Z(Ta)),subtractFee:n(f),CPFP:n(h)}),Pd=F({lowFee:h,standardFeeLow:h,standardFeeHigh:h,highFee:h}),q0=R=>F(Id(_d({},Pd.shape),{lowFeeFudgeFactor:G(h,R==null?void 0:R.lowFeeFudgeFactor),standardFeeLowFudgeFactor:G(h,R==null?void 0:R.standardFeeLowFudgeFactor),standardFeeHighFudgeFactor:G(h,R==null?void 0:R.standardFeeHighFudgeFactor),highFeeFudgeFactor:G(h,R==null?void 0:R.highFeeFudgeFactor),standardFeeLowAmount:h,standardFeeHighAmount:h,maximumFeeRate:n(h,R==null?void 0:R.maximumFeeRate)})).withRest,Od=F({balance:h,addressBalances:F(h),lastSeenBlockHeight:c}),Bd=F({nowNodeApiKey:n(h)}),Ql=F({blockbookServers:G(Z(h),[]),enableCustomServers:G(f,!1)}),Rd=F({publicAddress:h}),Cd=i("bip69","targets"),Fd=F({enableRbf:n(f),forceChangeAddress:n(h),outputSort:n(Cd,"bip69"),txOptions:n(Td),utxoSourceAddress:n(h)});var ec=er(9939),zt=er(8405);const u1=zt.WK,Nd=zt.DE,Ld=zt.k5,l1=zt.Dr,c1=zt.ef,h1=zt.GY,d1=zt.WM,p1=zt.Kz,v1=zt.uX,m1=zt.IK,g1=zt.gw,y1=zt.WU,b1=zt.G8,w1=zt.xQ,x1=zt.D7,M1=zt.hi,E1=zt.mJ,S1=zt.zU,k1=zt.dq,_1=zt.m$,I1=zt.MU,A1=zt.ID,T1=zt.k0,P1=zt.D4,O1=zt.kL,B1=zt.jx,R1=zt.A_,C1=zt.v1,F1=zt.TL,N1=zt.Og,L1=zt.ft,D1=zt.KU,U1=zt.ZU,H1=zt.ye,z1=zt.Xj,K1=zt.Rn,j1=zt.bo,W1=zt.KL,G1=zt.rW,V1=zt.U3,q1=zt.$Y,X1=zt.EJ,Z1=zt.XY,Y1=zt.v7,$1=zt.up,J1=zt.h,Q1=zt.Cx,eg=zt.Zz,tg=zt.CU,rg=zt.ib,ng=zt.eT,ig=zt._0,og=zt.UR,ag=zt.Up,sg=zt.y0,fg=zt.A2,ug=zt.ql,lg=zt.FX,cg=zt.Jr,hg=zt.zS,dg=zt.pK,pg=zt.ud,vg=zt.Zk,mg=zt.Mf,gg=zt.U0,yg=zt.CX,bg=zt.l4,wg=zt.gU,xg=zt.M3,Mg=zt.Xv,Eg=zt.vN,Sg=zt.g_,kg=zt.BN,_g=zt.Jv,Ig=zt.T0,Ag=zt.z8,Tg=zt.Gt,Pg=zt.Fm,Og=zt.b4,Bg=zt.N2,Rg=zt.K8,Cg=zt.gB,Fg=zt.bd,Ng=zt.GG,Lg=zt.V$,Dg=zt.CC,Ug=zt.dT,Hg=zt.uT,zg=zt._j,Kg=zt.p4,jg=zt.W0,Wg=zt.zk,Gg=zt.AB,Vg=zt.sn,qg=zt._u,Xg=zt.Py,Zg=zt.iu,Yg=zt.l7,$g=zt.JU,Jg=zt.O6,tc=R=>R.filter(O=>O!==void 0),Dd=R=>{const O={};for(const z in R)R[z]!==void 0&&(O[z]=R[z]);return O},Pa=(R=Date.now())=>Math.round(R/1e3),Ud="https://info1.edge.app",rc="fees.json",Qg=999999999,Ef=2,ey=200,ty=6,ry=2,ny=1,Hd=(R,O,z,me)=>{const{highFeeFudgeFactor:Me="1",lowFeeFudgeFactor:Re="1",standardFeeHighAmount:Se,standardFeeHighFudgeFactor:ke="1",standardFeeLowAmount:_e,standardFeeLowFudgeFactor:Te="1"}=O;let{highFee:We,lowFee:Je,standardFeeHigh:it,standardFeeLow:ct}=O;switch(We=(0,Ge.round)((0,Ge.mul)(We,Me),0),Je=(0,Ge.round)((0,Ge.mul)(Je,Re),0),it=(0,Ge.round)((0,Ge.mul)(it,ke),0),ct=(0,Ge.round)((0,Ge.mul)(ct,Te),0),z){case"low":return Je;case"standard":{if((0,Ge.gte)(R,Se))return it;if((0,Ge.lte)(R,_e))return ct;const dt=(0,Ge.sub)(Se,_e),pt=(0,Ge.sub)(it,ct),St=(0,Ge.sub)(R,_e),Ut=(0,Ge.mul)(St,pt),Jt=(0,Ge.div)(Ut,dt);return(0,Ge.add)(ct,Jt)}case"high":return We;case"custom":if(me==null||me==="0")throw new Error(`Invalid custom network fee: ${me}`);return me;default:throw new Error(`Invalid networkFeeOption: ${z}`)}},zd=F({fastestFee:c,halfHourFee:c,hourFee:c}),Kd=1.3,jd=2,Wd=R=>{let O;try{O=zd(R)}catch{return null}const{fastestFee:z,halfHourFee:me}=O,Me=me.toString(),Re=z.toString(),Se=Math.round(z*Kd).toString(),ke=Math.round(z*jd).toString();return{lowFee:Ge.max(Me,Ef.toString()),standardFeeLow:Ge.max(Re,Ef.toString()),standardFeeHigh:Ge.max(Se,Ef.toString()),highFee:Ge.max(ke,Ef.toString())}};var Gd=Object.defineProperty,Vd=Object.defineProperties,qd=Object.getOwnPropertyDescriptors,Sf=Object.getOwnPropertySymbols,X0=Object.prototype.hasOwnProperty,Z0=Object.prototype.propertyIsEnumerable,Y0=(R,O,z)=>O in R?Gd(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,nc=(R,O)=>{for(var z in O||(O={}))X0.call(O,z)&&Y0(R,z,O[z]);if(Sf)for(var z of Sf(O))Z0.call(O,z)&&Y0(R,z,O[z]);return R},ic=(R,O)=>Vd(R,qd(O)),Xd=(R,O)=>{var z={};for(var me in R)X0.call(R,me)&&O.indexOf(me)<0&&(z[me]=R[me]);if(R!=null&&Sf)for(var me of Sf(R))O.indexOf(me)<0&&Z0.call(R,me)&&(z[me]=R[me]);return z},fi=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});const Zd=R=>fi(void 0,null,function*(){const O=R,{disklet:z,pluginInfo:me}=O,Me=Xd(O,["disklet","pluginInfo"]),{currencyInfo:Re,engineInfo:Se}=me,ke=v(z),_e=yield Yd(ke,Se.defaultFeeInfo);let Te=0,We;const Je=()=>fi(void 0,null,function*(){if(Date.now()-Te<=Se.feeUpdateInterval)return;const it=yield Qd(ic(nc({},Me),{mempoolSpaceFeeInfoServer:Se.mempoolSpaceFeeInfoServer})),ct=Dd(it!=null?it:{});Object.assign(_e,ct),Te=Date.now(),yield $d(ke,_e)});return{start(){return fi(this,null,function*(){const it=yield $0(ic(nc({},Me),{uri:`${Ud}/v1/networkFees/${Re.pluginId}`,cleaner:G(q0(_e),null)}));Object.assign(_e,it),yield Je(),We=setInterval(Je,Se.feeUpdateInterval)})},stop(){clearInterval(We)},clearCache(){return fi(this,null,function*(){yield ke.delete(rc)})},getRate(it){return fi(this,null,function*(){var ct,dt,pt;const{spendTargets:St,networkFeeOption:Ut="standard",customNetworkFee:Jt={},otherParams:ur={}}=it,_t=(dt=(ct=ur.paymentProtocolInfo)==null?void 0:ct.merchant)==null?void 0:dt.requiredFeeRate;if(_t!=null){const Ft=Ge.add(Ge.mul(`${_t}`,"1.5"),"1");return Ge.toFixed(Ft,0,0)}const Bt=((pt=Re.customFeeTemplate)!=null?pt:[])[0];if(Bt==null)throw new Error("No custom fee template");return Hd(Jd(St),_e,Ut,Jt[Bt.key])})},get feeInfo(){return _e}}}),Yd=(R,O)=>fi(void 0,null,function*(){const z=yield R.getJson(rc).catch(()=>{});return G(q0(O),O)(z)}),$d=(R,O)=>fi(void 0,null,function*(){return yield R.setJson(rc,O)}),Jd=R=>R.reduce((O,{nativeAmount:z})=>{if(z==null)throw new Error(`Invalid spend target amount: ${z}`);return Ge.add(O,z)},"0"),$0=R=>fi(void 0,null,function*(){const{uri:O,cleaner:z,io:me,log:Me}=R;try{const Re=yield me.fetch(O);if(!Re.ok)throw new Error(`Error fetching fees from ${O}`);const Se=yield Re.json();return z(Se)}catch(Re){return Me(Re.message),null}}),Qd=R=>fi(void 0,null,function*(){if(R.mempoolSpaceFeeInfoServer!=null){const O=yield $0(ic(nc({},R),{uri:R.mempoolSpaceFeeInfoServer,cleaner:Wd}));if(O!=null)return O}return{}});var J0=er(7007);class Q0 extends J0.EventEmitter{}var cn=(R=>(R.TRANSACTIONS_CHANGED="transactions:changed",R.WALLET_BALANCE_CHANGED="wallet:balance:changed",R.ADDRESS_BALANCE_CHANGED="address:balance:changed",R.BLOCK_HEIGHT_CHANGED="block:height:changed",R.NEW_ADDRESS_TRANSACTION="address:transaction:changed",R.ADDRESSES_CHECKED="addresses:checked",R.TXIDS_CHANGED="txids:changed",R.CONNECTION_OPEN="connection:open",R.CONNECTION_CLOSE="connection:close",R.CONNECTION_TIMER="connection:timer",R))(cn||{});const ep=R=>{const O=new Q0;return O.on("transactions:changed",R.onTransactionsChanged),O.on("wallet:balance:changed",R.onBalanceChanged),O.on("block:height:changed",(z,me)=>{R.onBlockHeightChanged(me)}),O.on("addresses:checked",R.onAddressesChecked),O.on("txids:changed",R.onTxidsChanged),O};var tp=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});class eh{constructor(){this._acquired=!1,this._waitingResolvers=[]}get acquired(){return this._acquired}acquireAsync(){return tp(this,null,function*(){return this._acquired?yield new Promise(O=>{this._waitingResolvers.push(O)}):(this._acquired=!0,yield Promise.resolve())})}tryAcquire(){return this._acquired?!1:(this._acquired=!0,!0)}release(){if(!this._acquired)throw new Error("Cannot release an unacquired lock");if(this._waitingResolvers.length>0){const O=this._waitingResolvers.shift();if(O==null)throw new Error("Cannot release null lock");O()}else this._acquired=!1}}const rp=R=>{var O;for(const z of Oo)if(z.coinInfo.name===R)return(O=z.engineInfo.formats)!=null?O:[];return[]},an=(R,O)=>{delete R[O]};var Ti=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});const kf="metadata.json",th=R=>Ti(void 0,null,function*(){const{disklet:O,emitter:z,log:me}=R,Me=v(O),Re=new eh,Se={get state(){return Je},clear:()=>Ti(void 0,null,function*(){yield Me.delete(kf);const it=yield Te();Object.assign(Je,it)})},ke=it=>Ti(void 0,null,function*(){const ct=Object.values(Je.addressBalances).reduce((dt,pt)=>(0,Ge.add)(dt,pt),"0");Je.balance=ct,yield We(Je),z.emit(cn.WALLET_BALANCE_CHANGED,it,ct)});z.on(cn.ADDRESS_BALANCE_CHANGED,(it,ct)=>Ti(void 0,null,function*(){yield Re.acquireAsync();try{ct.forEach(({scriptPubkey:dt,balance:pt})=>{pt==="0"?an(Je.addressBalances,dt):Je.addressBalances[dt]=pt}),yield ke(it)}catch(dt){me.error(dt)}finally{Re.release()}})),z.on(cn.BLOCK_HEIGHT_CHANGED,(it,ct)=>Ti(void 0,null,function*(){ct>Je.lastSeenBlockHeight&&(Je.lastSeenBlockHeight=ct,yield We(Je))}));const _e=()=>Ti(void 0,null,function*(){try{const it=yield Me.getJson(kf);return Od(it)}catch(it){return me.error(it),yield Te()}}),Te=()=>Ti(void 0,null,function*(){const it={balance:"0",addressBalances:{},lastSeenBlockHeight:0};return yield Me.setJson(kf,it),it}),We=it=>Ti(void 0,null,function*(){yield Me.setJson(kf,it)}),Je=yield _e();return Se});var rh=er(5582);const np=H(R=>rh.xn.parse(h(R)),R=>rh.xn.stringify(R).toLowerCase());function ip(R){const O=h(R);if(!/^\d+$/.test(O))throw new Error("Expected an integer string");return O}function op(R,O){var z;const{memos:me=[]}=R,{displayName:Me,memoMaxLength:Re,memoMaxValue:Se,memoOptions:ke=[],multipleMemos:_e=!1,memoType:Te}=O,We=[...ke];Te==="text"&&We.push({type:"text",maxLength:Re}),Te==="number"&&We.push({type:"number",maxValue:Se}),Te==="hex"&&We.push({type:"hex",maxBytes:Re==null?void 0:Re/2});const{memoName:Je="memo"}=(z=ke[0])!=null?z:{};for(const it of me){const ct=We.filter(pt=>it.type===pt.type);if(ct.length<1)throw new Error(`${Me} ${Je}: cannot be type ${it.type}`);const dt=ct.map(pt=>ap(it,pt)).find(pt=>pt!=null);if(dt!=null)throw new Error(`${Me} {memoName}: ${dt}`)}if(!_e&&me.length>1)throw new Error(`${Me} only supports one ${Je}`)}function ap(R,O){if(O.type==="text"&&O.maxLength!=null&&R.value.length>O.maxLength)return`cannot be longer than ${O.maxLength}`;if(O.type==="number"){const z=G(ip)(R.value);if(z==null)return"is not a valid number";if(O.maxValue!=null&&(0,Ge.gt)(z,O.maxValue))return`cannot be greater than ${O.maxValue}`}if(O.type==="hex"){const z=G(np)(R.value);if(z==null)return"is not valid hexadecimal";if(O.maxBytes!=null&&z.length>O.maxBytes)return`cannot be longer than ${O.maxBytes} bytes`;if(O.minBytes!=null&&z.length<O.minBytes)return`cannot be shorter than ${O.minBytes} bytes`}}var sp=Object.defineProperty,fp=Object.defineProperties,up=Object.getOwnPropertyDescriptors,nh=Object.getOwnPropertySymbols,lp=Object.prototype.hasOwnProperty,cp=Object.prototype.propertyIsEnumerable,ih=(R,O,z)=>O in R?sp(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,hp=(R,O)=>{for(var z in O||(O={}))lp.call(O,z)&&ih(R,z,O[z]);if(nh)for(var z of nh(O))cp.call(O,z)&&ih(R,z,O[z]);return R},dp=(R,O)=>fp(R,up(O));function pp(R,O){var z,me;const{memoType:Me}=O,Re=[];if(Me==="hex"||Me==="number"||Me==="text")for(const ke of R.spendTargets)ke.memo!=null?Re.push({type:Me,value:ke.memo}):ke.uniqueIdentifier!=null?Re.push({type:Me,value:ke.uniqueIdentifier}):typeof((z=ke.otherParams)==null?void 0:z.uniqueIdentifier)=="string"&&Re.push({type:Me,value:ke.otherParams.uniqueIdentifier});const Se=dp(hp({},R),{memos:(me=R.memos)!=null?me:Re});return op(Se,O),Se}var oc=er(8287).Buffer,vp=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});const mp=R=>{var O;const z=R.otherParams;if(z==null)throw new Error("Invalid transaction data");if(z.psbt==null)throw new Error("Missing PSBT in edge transaction data");const me=z.psbt.inputs.map((Re,Se)=>({amount:Re.value.toString(),scriptPubkey:oc.from(Re.scriptPubkey).toString("hex"),sequence:Re.sequence,n:Se,txId:oc.from(Re.hash).reverse().toString("hex"),outputIndex:Re.index})),Me=z.psbt.outputs.map((Re,Se)=>({amount:Re.value.toString(),scriptPubkey:oc.from(Re.scriptPubkey).toString("hex"),n:Se}));return{txid:R.txid,hex:R.signedTx,blockHeight:R.blockHeight,date:R.date,fees:R.networkFee,inputs:me,outputs:Me,ourIns:[],ourOuts:[],ourAmount:(O=R.nativeAmount)!=null?O:"0"}},oh=R=>vp(void 0,null,function*(){const{tx:O,processor:z,walletTools:me,pluginInfo:Me,walletId:Re}=R,{currencyInfo:Se}=Me,ke=[];for(const Te of O.ourOuts){const{scriptPubkey:We}=O.outputs[parseInt(Te)],Je=yield z.fetchAddress(We);if((Je==null?void 0:Je.path)!=null){const{address:it}=me.scriptPubkeyToAddress({changePath:Je.path,scriptPubkey:We});ke.push(it)}}let _e;try{const We=pe.ZX.fromHex(O.hex).virtualSize();_e={satPerVByte:new(ye())(O.fees,10).div(new(ye())(We,10)).toNumber()}}catch{}return{blockHeight:O.blockHeight,confirmations:O.confirmations,currencyCode:Se.currencyCode,date:O.date,feeRateUsed:_e,isSend:(0,Ge.lt)(O.ourAmount,"0"),memos:[],nativeAmount:O.ourAmount,networkFee:O.fees,ourReceiveAddresses:ke,signedTx:O.hex,tokenId:null,txid:O.txid,walletId:Re}});var Dn;(function(R){R.CountBase="COUNT_BASE",R.HashBase="HASH_BASE",R.RangeBase="RANGE_BASE"})(Dn||(Dn={}));function ah(R,O,z,me,Me,Re,Se){try{var ke=R[Re](Se),_e=ke.value}catch(Te){z(Te);return}ke.done?O(_e):Promise.resolve(_e).then(me,Me)}function Mr(R){return function(){var O=this,z=arguments;return new Promise(function(me,Me){var Re=R.apply(O,z);function Se(_e){ah(Re,me,Me,Se,ke,"next",_e)}function ke(_e){ah(Re,me,Me,Se,ke,"throw",_e)}Se(void 0)})}}function _f(){return _f=Object.assign||function(R){for(var O=1;O<arguments.length;O++){var z=arguments[O];for(var me in z)Object.prototype.hasOwnProperty.call(z,me)&&(R[me]=z[me])}return R},_f.apply(this,arguments)}function gp(R){return Object.prototype.hasOwnProperty.call(R,"getJson")||Object.prototype.hasOwnProperty.call(R,"setJson")}function ui(R){return gp(R)?R:v(R)}function If(R,O){return R+"/"+lc(O)}function Fo(R,O,z){return If(R,O)+"/"+z+".json"}function ac(R){return R+"/config.json"}function sc(R,O){return fc.apply(this,arguments)}function fc(){return fc=Mr(function*(R,O){return yield R.getJson(ac(O))}),fc.apply(this,arguments)}function Pi(R,O,z){return uc.apply(this,arguments)}function uc(){return uc=Mr(function*(R,O,z){yield R.setJson(ac(O),z)}),uc.apply(this,arguments)}function lc(R){R===void 0&&(R="");var O=/^[a-z0-9_]*$/i,z=R.trim();if(!O.test(z))throw new Error("partitions may only contain alphanumeric and underscore characters");return z}function cc(R){if(R==="")throw new Error("database name cannot be empty");var O=/^[a-z0-9_]*$/i,z=R.trim();if(!O.test(z))throw new Error("database name may only contain alphanumeric and underscore characters");return z}function hc(R,O){return dc.apply(this,arguments)}function dc(){return dc=Mr(function*(R,O){return yield R.list("./").then(function(z){return z[O]==="folder"})}),dc.apply(this,arguments)}function pc(R){return Number.isInteger(R)&&R>=1}function vc(R,O){return mc.apply(this,arguments)}function mc(){return mc=Mr(function*(R,O){var z=ui(R),me=yield sc(z,O);if(me.type!==Dn.CountBase)throw new Error("Tried to open CountBase, but type is "+String(me.type));var Me={databaseName:O,insert:function(Se,ke,_e){return Mr(function*(){var Te=lc(Se),We=!1,Je=me.partitions[Te];Je===void 0&&(Je={length:0},We=!0);var it=Je.length;if(Number.isNaN(ke)||ke<0)throw new Error("index must be a Number greater than 0");if(ke>it)throw new Error("index is larger than next index in partition");ke===it&&(++Je.length,We=!0);var ct=Math.floor(ke/me.bucketSize),dt=Fo(O,Se,ct),pt=yield z.getJson(dt).catch(function(){return[]}),St=ke%me.bucketSize;pt[St]=_e,yield z.setJson(dt,pt),We&&(me.partitions[Te]=Je),yield Pi(z,O,me)})()},query:function(Se,ke,_e){return Mr(function*(){ke===void 0&&(ke=0),_e===void 0&&(_e=ke);for(var Te=[],We=Math.floor(ke/me.bucketSize);We<=Math.floor(_e/me.bucketSize);We++){var Je=Fo(O,Se,We);Te.push(z.getJson(Je).catch(function(){return[]}))}for(var it=yield Promise.all(Te),ct=[],dt=ke;dt<=_e;dt++){var pt=Math.floor(dt/me.bucketSize),St=dt%me.bucketSize,Ut=pt-Math.floor(ke/me.bucketSize);ct.push(it[Ut][St])}return ct})()},length:function(Se){var ke,_e=lc(Se),Te=me.partitions[_e];return(ke=Te==null?void 0:Te.length)!=null?ke:0},dumpData:function(){return Mr(function*(){for(var Se={},ke=0,_e=Object.keys(me.partitions);ke<_e.length;ke++){var Te=_e[ke];Se[Te]=yield Me.query(Te,0,Me.length(Te)-1)}return{config:me,data:Se}})()}};return Me}),mc.apply(this,arguments)}function yp(R,O){return gc.apply(this,arguments)}function gc(){return gc=Mr(function*(R,O){var z=ui(R),me=O.name,Me=O.bucketSize;if(!pc(Me))throw new Error("bucketSize must be a number greater than 0");var Re=cc(me),Se=yield hc(z,Re);if(Se)throw new Error("database "+Re+" already exists");var ke={type:Dn.CountBase,bucketSize:Math.floor(Me),partitions:{}};return yield Pi(z,Re,ke),yield vc(z,Re)}),gc.apply(this,arguments)}function bp(R,O){return yc.apply(this,arguments)}function yc(){return yc=Mr(function*(R,O){var z=ui(R);try{return yield yp(z,O)}catch(me){if(me instanceof Error&&!me.message.includes("already exists"))throw me;return yield vc(z,O.name)}}),yc.apply(this,arguments)}function bc(R,O){return wc.apply(this,arguments)}function wc(){return wc=Mr(function*(R,O){var z=ui(R),me=yield sc(z,O);if(me.type!==Dn.HashBase)throw new Error("Tried to open HashBase, but type is "+String(me.type));function Me(ke,_e,Te){return Re.apply(this,arguments)}function Re(){return Re=Mr(function*(ke,_e,Te){if(Te===void 0&&(Te=!1),_e.length===0)return[];for(var We=me.prefixSize,Je=[],it={},ct=function(It){var wt=_e[It];if(wt.length<We)return"continue";var Nt=wt.substring(0,We);if(it[Nt]===void 0){var Rt=Fo(O,ke,Nt),tr=z.getJson(Rt).then(function(yr){return it[Nt].bucketData=yr},function(){});it[Nt]={bucketFetcher:tr,bucketPath:Rt,bucketData:{}},Je.push(tr)}},dt=0;dt<_e.length;dt++)var pt=ct(dt);yield Promise.all(Je);for(var St=[],Ut=new Set,Jt=0;Jt<_e.length;Jt++){var ur=_e[Jt].substring(0,We);Ut.add(ur);var _t=it[ur].bucketData,Bt=_t[_e[Jt]];Te&&delete _t[_e[Jt]],St.push(Bt)}var Lt=Promise.resolve();if(Te){var Ft=Array.from(Ut).map(function(){var jt=Mr(function*(It){var wt=it[It],Nt=wt.bucketPath,Rt=wt.bucketData;return yield z.setJson(Nt,Rt)});return function(It){return jt.apply(this,arguments)}}());Lt=Promise.all(Ft)}return yield Lt,St}),Re.apply(this,arguments)}var Se={databaseName:O,insert:function(_e,Te,We){return Mr(function*(){var Je=me.prefixSize;if(Te.length<Je)throw new Error("hash must be a string of length at least "+Je);var it=Te.substring(0,Je),ct=Fo(O,_e,it),dt=function(){var pt=Mr(function*(St){var Ut;return St===void 0&&(St={}),yield z.setJson(ct,_f(St,(Ut={},Ut[Te]=We,Ut)))});return function(Ut){return pt.apply(this,arguments)}}();yield z.getJson(ct).then(function(){var pt=Mr(function*(St){return yield dt(St)});return function(St){return pt.apply(this,arguments)}}(),Mr(function*(){return yield dt()}))})()},query:function(_e,Te){return Mr(function*(){return yield Me(_e,Te)})()},delete:function(){var ke=Mr(function*(Te,We){return yield Me(Te,We,!0)});function _e(Te,We){return ke.apply(this,arguments)}return _e}(),dumpData:function(_e){return Mr(function*(){_e===void 0&&(_e="");var Te={},We=function(){var it=Mr(function*(ct,dt){dt===void 0&&(dt="");var pt=yield ct.list(),St=Object.keys(pt).map(function(){var Ut=Mr(function*(Jt){if(!ac(O).includes(Jt)){var ur=pt[Jt];if(ur==="folder"){if(dt!=="")throw new Error("Unexpected partition hierarchy");return yield We(m(ct,Jt),Jt)}if(ur==="file"){var _t=yield ct.getJson(Jt);Te[dt]=_f({},Te[dt],_t);return}throw new Error("Unknown listing type "+String(ur))}});return function(Jt){return Ut.apply(this,arguments)}}());yield Promise.all(St)});return function(dt,pt){return it.apply(this,arguments)}}(),Je=m(z,If(O,_e));return yield We(Je,_e),{config:me,data:Te}})()}};return Se}),wc.apply(this,arguments)}function wp(R,O){return xc.apply(this,arguments)}function xc(){return xc=Mr(function*(R,O){var z=ui(R),me=O.prefixSize,Me=cc(O.name);if(!pc(me))throw new Error("prefixSize must be a number greater than 0");var Re=yield hc(z,Me);if(Re)throw new Error("database "+Me+" already exists");var Se={type:Dn.HashBase,prefixSize:me};return yield Pi(z,Me,Se),yield bc(z,Me)}),xc.apply(this,arguments)}function Oa(R,O){return Mc.apply(this,arguments)}function Mc(){return Mc=Mr(function*(R,O){var z=ui(R);try{return yield wp(z,O)}catch(me){if(me instanceof Error&&!me.message.includes("already exists"))throw me;return yield bc(z,O.name)}}),Mc.apply(this,arguments)}function Ec(R,O){return Sc.apply(this,arguments)}function Sc(){return Sc=Mr(function*(R,O){var z=ui(R);function me(_t,Bt,Lt,Ft,jt,It){if(Ft===void 0&&(Ft=0),jt===void 0&&(jt=Lt.length-1),It===void 0&&(It=!1),Lt.length===0)return{found:!1,index:0};var wt=Ft,Nt=jt,Rt=0,tr;if(!Number.isInteger(Ft)||!Number.isInteger(jt)||Ft<0||jt>Lt.length-1||jt<Ft)throw new Error("indices must be valid bucket index values and endIndex >= startIndex");for(;wt<=Nt;)if(Rt=~~((wt+Nt)/2),tr=Lt[Rt][Bt],tr<_t)wt=Rt+1;else if(tr>_t)Nt=Rt-1;else if(It){var yr=Rt===Nt||Lt[Rt+1][Bt]!==_t;if(yr)return{found:!0,index:Rt};wt=Rt+1}else{var hr=Rt===wt||Lt[Rt-1][Bt]!==_t;if(hr)return{found:!0,index:Rt};Nt=Rt-1}return{found:!1,index:tr!=null&&tr<_t?Rt+1:Rt}}var Me=yield sc(z,O);if(Me.type!==Dn.RangeBase)throw new Error("Tried to open RangeBase, but type is "+String(Me.type));function Re(_t,Bt){return Se.apply(this,arguments)}function Se(){return Se=Mr(function*(_t,Bt){var Lt=Me.rangeKey,Ft=If(O,_t),jt=yield z.list(Ft),It;for(var wt in jt)if(!/config\.json$/.test(wt)){var Nt=wt.split("/"),Rt=Number(Nt[Nt.length-1].split(".")[0]);It==null?It=Rt:Bt?Rt>It&&(It=Rt):Rt<It&&(It=Rt)}if(It!=null){var tr=yield pt(_t,It),yr=Bt?tr.length-1:0;return Number(tr[yr][Lt])}}),Se.apply(this,arguments)}function ke(_t,Bt,Lt){return _e.apply(this,arguments)}function _e(){return _e=Mr(function*(_t,Bt,Lt){var Ft,jt=Me.rangeKey,It=Me.limits,wt=Bt[jt],Nt=(Ft=It[_t])!=null?Ft:It[_t]={};if(Lt){var Rt=wt===Nt.minRange,tr=wt===Nt.maxRange;if(Rt||tr)return yield ur.query(_t,wt).then(function(mr){if(mr.length===0)return Re(_t,tr).then(function(){var Kt=Mr(function*(Pt){return Rt&&(Nt.minRange=Pt),tr&&(Nt.maxRange=Pt),yield Pi(z,O,Me)});return function(Pt){return Kt.apply(this,arguments)}}())})}else{var yr=Nt.minRange,hr=Nt.maxRange;return(yr==null||wt<yr)&&(Nt.minRange=wt),(hr==null||wt>hr)&&(Nt.maxRange=wt),yield Pi(z,O,Me)}}),_e.apply(this,arguments)}function Te(_t,Bt,Lt,Ft){return We.apply(this,arguments)}function We(){return We=Mr(function*(_t,Bt,Lt,Ft){Ft===void 0&&(Ft=!1);var jt=Me.bucketSize,It=Me.rangeKey,wt=Me.idKey,Nt=Math.floor(Bt/jt),Rt=yield pt(_t,Nt),tr=me(Bt,It,Rt);if(tr.found){var yr=me(Bt,It,Rt,tr.index,Rt.length-1,!0),hr=me(Lt,wt,Rt,tr.index,yr.index);if(hr.found)if(Ft){var mr=Rt.splice(hr.index,1),Kt=mr[0];return yield Ut(_t,Nt,Rt),yield ke(_t,Kt,!0),Kt}else return Rt[hr.index]}}),We.apply(this,arguments)}function Je(_t,Bt,Lt){return it.apply(this,arguments)}function it(){return it=Mr(function*(_t,Bt,Lt){var Ft=yield ct(_t),jt=[],It=Lt;function wt(Rt){return Nt.apply(this,arguments)}function Nt(){return Nt=Mr(function*(Rt){if(Bt===jt.length||Rt===Ft.length)return yield Promise.resolve();var tr=yield pt(_t,Ft[Rt]);if(tr.length<=It)return It-=tr.length,yield wt(++Rt);var yr=tr.length-It,hr=yr+jt.length-Bt,mr=hr>0?hr:0;return jt=[].concat(jt,tr.slice(mr,yr).reverse()),It=0,yield wt(++Rt)}),Nt.apply(this,arguments)}return yield wt(0),jt}),it.apply(this,arguments)}function ct(_t){return dt.apply(this,arguments)}function dt(){return dt=Mr(function*(_t){var Bt=If(O,_t),Lt=yield z.list(Bt),Ft={};for(var jt in Lt)if(Object.hasOwnProperty.call(Lt,jt)&&Lt[jt]!=="folder"&&!/config\.json$/.test(jt)){var It=jt.split("/"),wt=Number(It[It.length-1].split(".")[0]);Ft[wt]=!0}return Object.keys(Ft).sort(function(Nt,Rt){return Nt<Rt?1:-1})}),dt.apply(this,arguments)}function pt(_t,Bt){return St.apply(this,arguments)}function St(){return St=Mr(function*(_t,Bt){var Lt=Fo(O,_t,Bt);return yield z.getJson(Lt).catch(function(){return[]})}),St.apply(this,arguments)}function Ut(_t,Bt,Lt){return Jt.apply(this,arguments)}function Jt(){return Jt=Mr(function*(_t,Bt,Lt){var Ft=Fo(O,_t,Bt);return Lt.length===0?yield z.delete(Ft):yield z.setJson(Ft,Lt)}),Jt.apply(this,arguments)}var ur={rangeKey:Me.rangeKey,idKey:Me.idKey,databaseName:O,insert:function(Bt,Lt){return Mr(function*(){var Ft,jt=Me.bucketSize,It=Me.rangeKey,wt=Me.idKey;if(!(Object.prototype.hasOwnProperty.call(Lt,It)&&Object.prototype.hasOwnProperty.call(Lt,wt)))throw new Error("data must have properties "+It+" and "+wt);var Nt=yield Te(Bt,Lt[It],Lt[wt]);if(Nt!=null)throw new Error("Cannot insert data because id already exists");var Rt=Math.floor(Lt[It]/jt);yield pt(Bt,Rt).then(function(){var yr=Mr(function*(hr){var mr=me(Lt[It],It,hr);if(!mr.found)hr.splice(mr.index,0,Lt);else{var Kt=me(Lt[It],It,hr,mr.index,hr.length-1,!0),Pt=me(Lt[wt],wt,hr,mr.index,Kt.index);hr.splice(Pt.index,0,Lt)}return yield Ut(Bt,Rt,hr)});return function(hr){return yr.apply(this,arguments)}}(),Mr(function*(){return yield Ut(Bt,Rt,[Lt])})),yield ke(Bt,Lt,!1);var tr=(Ft=Me.sizes[Bt])!=null?Ft:0;Me.sizes[Bt]=tr+1,yield Pi(z,O,Me)})()},query:function(Bt,Lt,Ft){return Mr(function*(){Bt===void 0&&(Bt="/"),Ft===void 0&&(Ft=Lt);var jt=Me.bucketSize,It=Me.rangeKey,wt=[];if(Ft<Lt)throw new Error("rangeStart must be larger than rangeEnd");for(var Nt=Math.floor(Lt/jt);Nt<=Math.floor(Ft/jt);Nt++)wt.push(pt(Bt,Nt));var Rt=yield Promise.all(wt),tr=[];if(Rt.length===1){var yr=me(Lt,It,Rt[0]),hr=me(Ft,It,Rt[0],0,Rt[0].length-1,!0);tr=Rt[0].slice(yr.index,hr.found?hr.index+1:hr.index)}else for(var mr=0;mr<Rt.length;mr++)if(mr===0){var Kt=me(Lt,It,Rt[mr]);tr=Rt[mr].slice(Kt.index)}else if(mr===Rt.length-1){var Pt=me(Ft,It,Rt[mr],0,Rt[mr].length-1,!0);Array.prototype.push.apply(tr,Rt[mr].slice(0,Pt.found?Pt.index+1:Pt.index))}else tr.push.apply(tr,Rt[mr]);return tr})()},queryById:function(Bt,Lt,Ft){return Mr(function*(){return yield Te(Bt,Lt,Ft)})()},queryByCount:function(Bt,Lt,Ft){return Mr(function*(){return Ft===void 0&&(Ft=0),yield Je(Bt,Lt,Ft)})()},delete:function(){var _t=Mr(function*(Lt,Ft,jt){return yield Te(Lt,Ft,jt,!0).then(function(){var It=Mr(function*(wt){var Nt,Rt=(Nt=Me.sizes[Lt])!=null?Nt:0;return Me.sizes[Lt]=Rt-1,yield Pi(z,O,Me).then(function(){return wt})});return function(wt){return It.apply(this,arguments)}}())});function Bt(Lt,Ft,jt){return _t.apply(this,arguments)}return Bt}(),update:function(Bt,Lt,Ft){return Mr(function*(){var jt=yield ur.delete(Bt,Lt,Ft[Me.idKey]);if(jt==null)throw new Error("Cannot update a non-existing element");yield ur.insert(Bt,Ft)})()},min:function(Bt){var Lt,Ft;return(Lt=(Ft=Me.limits[Bt])==null?void 0:Ft.minRange)!=null?Lt:0},max:function(Bt){var Lt,Ft;return(Lt=(Ft=Me.limits[Bt])==null?void 0:Ft.maxRange)!=null?Lt:0},size:function(Bt){var Lt;return(Lt=Me.sizes[Bt])!=null?Lt:0},dumpData:function(){return Mr(function*(){for(var Bt={},Lt=0,Ft=Object.keys(Me.sizes);Lt<Ft.length;Lt++){var jt,It=Ft[Lt],wt=(jt=ur.min(It))!=null?jt:0;Bt[It]=yield ur.query(It,wt,ur.max(It))}return{config:Me,data:Bt}})()}};return ur}),Sc.apply(this,arguments)}function xp(R,O){return kc.apply(this,arguments)}function kc(){return kc=Mr(function*(R,O){var z=ui(R),me=O.name,Me=O.bucketSize,Re=O.rangeKey,Se=O.idKey,ke=O.idPrefixLength,_e=ke===void 0?1:ke;if(!pc(Me))throw new Error("bucketSize must be a number greater than 0");var Te=cc(me),We=yield hc(z,Te);if(We)throw new Error("database "+Te+" already exists");var Je={type:Dn.RangeBase,bucketSize:Math.floor(Me),rangeKey:Re,idKey:Se,idPrefixLength:_e,limits:{},sizes:{}};return yield Pi(z,Te,Je),yield Ec(z,Te)}),kc.apply(this,arguments)}function sh(R,O){return _c.apply(this,arguments)}function _c(){return _c=Mr(function*(R,O){var z=ui(R);try{return yield xp(z,O)}catch(me){if(me instanceof Error&&!me.message.includes("already exists"))throw me;return yield Ec(z,O.name)}}),_c.apply(this,arguments)}function iy(R,O){return Ic.apply(this,arguments)}function Ic(){return Ic=Mr(function*(R,O){var z=yield R.getText(O+"/config.json").then(function(Me){return JSON.parse(Me)});switch(z.type){case Dn.CountBase:return yield vc(R,O);case Dn.HashBase:return yield bc(R,O);case Dn.RangeBase:return yield Ec(R,O);default:{var me=z==null?void 0:z.type;throw new Error("Unknown base type: "+me)}}}),Ic.apply(this,arguments)}var Mp=function(R,O,z,me){function Me(Re){return Re instanceof z?Re:new z(function(Se){Se(Re)})}return new(z||(z=Promise))(function(Re,Se){function ke(We){try{Te(me.next(We))}catch(Je){Se(Je)}}function _e(We){try{Te(me.throw(We))}catch(Je){Se(Je)}}function Te(We){We.done?Re(We.value):Me(We.value).then(ke,_e)}Te((me=me.apply(R,O||[])).next())})};class Ep{constructor(O){if(this._maxConcurrency=O,this._queue=[],O<=0)throw new Error("semaphore must be initialized to a positive value");this._value=O}acquire(){const O=this.isLocked(),z=new Promise(me=>this._queue.push(me));return O||this._dispatch(),z}runExclusive(O){return Mp(this,void 0,void 0,function*(){const[z,me]=yield this.acquire();try{return yield O(z)}finally{me()}})}isLocked(){return this._value<=0}release(){if(this._maxConcurrency>1)throw new Error("this method is unavailabel on semaphores with concurrency > 1; use the scoped release returned by acquire instead");if(this._currentReleaser){const O=this._currentReleaser;this._currentReleaser=void 0,O()}}_dispatch(){const O=this._queue.shift();if(!O)return;let z=!1;this._currentReleaser=()=>{z||(z=!0,this._value++,this._dispatch())},O([this._value--,this._currentReleaser])}}var Sp=function(R,O,z,me){function Me(Re){return Re instanceof z?Re:new z(function(Se){Se(Re)})}return new(z||(z=Promise))(function(Re,Se){function ke(We){try{Te(me.next(We))}catch(Je){Se(Je)}}function _e(We){try{Te(me.throw(We))}catch(Je){Se(Je)}}function Te(We){We.done?Re(We.value):Me(We.value).then(ke,_e)}Te((me=me.apply(R,O||[])).next())})};class Ac{constructor(){this._semaphore=new Ep(1)}acquire(){return Sp(this,void 0,void 0,function*(){const[,O]=yield this._semaphore.acquire();return O})}runExclusive(O){return this._semaphore.runExclusive(()=>O())}isLocked(){return this._semaphore.isLocked()}release(){this._semaphore.release()}}var fh=function(R,O,z,me){function Me(Re){return Re instanceof z?Re:new z(function(Se){Se(Re)})}return new(z||(z=Promise))(function(Re,Se){function ke(We){try{Te(me.next(We))}catch(Je){Se(Je)}}function _e(We){try{Te(me.throw(We))}catch(Je){Se(Je)}}function Te(We){We.done?Re(We.value):Me(We.value).then(ke,_e)}Te((me=me.apply(R,O||[])).next())})};function oy(R,O,z=new Error("timeout")){return{acquire:()=>new Promise((me,Me)=>fh(this,void 0,void 0,function*(){let Re=!1;setTimeout(()=>{Re=!0,Me(z)},O);const Se=yield R.acquire();Re?(Array.isArray(Se)?Se[1]:Se)():me(Se)})),runExclusive(me){return fh(this,void 0,void 0,function*(){let Me=()=>{};try{const Re=yield this.acquire();return Array.isArray(Re)?(Me=Re[1],yield me(Re[0])):(Me=Re,yield me())}finally{Me()}})},release(){R.release()},isLocked:()=>R.isLocked()}}const li=R=>`${R.format}_${R.changeIndex}`,kp={name:"scriptPubkeyByPath",bucketSize:50},_p={name:"addressByScriptPubkey",prefixSize:4},Ip={name:"lastUsedByFormatPath",prefixSize:2},Ap={name:"txIdByBlockHeight",bucketSize:1e5,rangeKey:"blockHeight",idKey:"txid"},Tp={name:"txById",prefixSize:2},Pp={name:"txIdsByDate",bucketSize:30*24*60*60,rangeKey:"date",idKey:"txid"},Op={name:"utxoById",prefixSize:2},Bp={name:"utxoIdsByScriptPubkey",prefixSize:4};var Rp=Object.defineProperty,uh=Object.getOwnPropertySymbols,Cp=Object.prototype.hasOwnProperty,Fp=Object.prototype.propertyIsEnumerable,lh=(R,O,z)=>O in R?Rp(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,Tc=(R,O)=>{for(var z in O||(O={}))Cp.call(O,z)&&lh(R,z,O[z]);if(uh)for(var z of uh(O))Fp.call(O,z)&&lh(R,z,O[z]);return R},Ji=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});const ch=R=>Ji(void 0,null,function*(){const O={addressByScriptPubkey:yield Oa(R.storage,_p),scriptPubkeyByPath:yield bp(R.storage,kp),lastUsedByFormatPath:yield Oa(R.storage,Ip)},z={txById:yield Oa(R.storage,Tp),txIdsByBlockHeight:yield sh(R.storage,Ap),txIdsByDate:yield sh(R.storage,Pp)},me={utxoById:yield Oa(R.storage,Op),utxoIdsByScriptPubkey:yield Oa(R.storage,Bp)},Me=new Ac,Re=new Ac,Se=new Ac;return{address(ke){return Ji(this,null,function*(){return yield Me.runExclusive(()=>Ji(this,null,function*(){return yield ke(O)}))})},tx(ke){return Ji(this,null,function*(){return yield Re.runExclusive(()=>Ji(this,null,function*(){return yield ke(z)}))})},utxo(ke){return Ji(this,null,function*(){return yield Se.runExclusive(()=>Ji(this,null,function*(){return yield ke(me)}))})},all:Tc(Tc(Tc({},O),z),me)}});var qr=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});const Np="tables";function hh(R){return qr(this,null,function*(){const O=(0,ec.my)(R.disklet,Np);let z=v(O),me=yield ch({storage:z}).catch(Se=>qr(this,null,function*(){throw yield z.delete("."),Se}));const Me=Se=>{let ke="0",_e={};for(const Te of Se.inputs)_e[Te.n.toString()]=Te;for(const Te of Se.ourIns){const We=_e[Te];ke=Ge.sub(ke,We.amount)}_e={};for(const Te of Se.outputs)_e[Te.n.toString()]=Te;for(const Te of Se.ourOuts){const We=_e[Te];ke=Ge.add(ke,We.amount)}return ke};return{clearAll(){return qr(this,null,function*(){yield z.onFlush.next().value,yield k(),yield O.delete("."),z=v(O),me=yield ch({storage:z})})},dumpData(){return qr(this,null,function*(){const Se=Object.values(me.all);return yield Promise.all(Se.map(ke=>qr(this,null,function*(){return{databaseName:ke.databaseName,data:yield ke.dumpData()}})))})},saveUtxo(Se){return qr(this,null,function*(){return yield me.utxo(ke=>qr(this,null,function*(){const[_e=[]]=yield ke.utxoIdsByScriptPubkey.query("",[Se.scriptPubkey]);_e.includes(Se.id)||(_e.push(Se.id),yield ke.utxoIdsByScriptPubkey.insert("",Se.scriptPubkey,_e)),yield ke.utxoById.insert("",Se.id,Se)}))})},removeUtxos(Se){return qr(this,null,function*(){return yield me.utxo(ke=>qr(this,null,function*(){var _e;if(Se.length===0)return;const Te=(yield ke.utxoById.query("",Se)).filter(Je=>Je!=null),We={};for(const Je of Te)We[Je.scriptPubkey]=[...(_e=We[Je.scriptPubkey])!=null?_e:[],Je.id];for(const Je of Object.keys(We)){const it=We[Je],[ct=[]]=yield ke.utxoIdsByScriptPubkey.query("",[Je]);for(const dt of it)ct.splice(ct.indexOf(dt),1);ct.length>0?yield ke.utxoIdsByScriptPubkey.insert("",Je,ct):yield ke.utxoIdsByScriptPubkey.delete("",[Je])}yield ke.utxoById.delete("",Se)}))})},fetchUtxos(Se){return qr(this,null,function*(){const{scriptPubkey:ke,utxoIds:_e=[]}=Se;return yield me.utxo(Te=>qr(this,null,function*(){var We;if(ke!=null){const[Je]=yield Te.utxoIdsByScriptPubkey.query("",[ke]);if(Je!=null&&_e.push(...Je),_e.length===0)return[]}if(_e.length===0){const{data:Je}=yield Te.utxoById.dumpData("");return Object.values((We=Je[""])!=null?We:{})}return yield Te.utxoById.query("",_e)}))})},saveTransaction(Se){return qr(this,null,function*(){const{scriptPubkeys:ke=[],tx:_e}=Se;return yield me.tx(Te=>qr(this,null,function*(){const We=yield Te.txById.query("",[_e.txid]).then(it=>it[0]).catch(it=>{}),Je=We!=null?We:_e;for(const it of ke){for(const ct of Je.inputs)ct.scriptPubkey===it&&(Je.ourIns.includes(ct.n.toString())||Je.ourIns.push(ct.n.toString()));for(const ct of Je.outputs)ct.scriptPubkey===it&&(Je.ourOuts.includes(ct.n.toString())||Je.ourOuts.push(ct.n.toString()));Je.ourAmount=Me(Je)}return Je.blockHeight!==_e.blockHeight?(yield Te.txIdsByBlockHeight.delete("",Je.blockHeight,Je.txid),Je.blockHeight=_e.blockHeight,yield Te.txIdsByBlockHeight.insert("",{txid:Je.txid,blockHeight:Je.blockHeight})):(yield(yield Te.txIdsByBlockHeight.query("",Je.blockHeight)).reverse().map(({txid:ct})=>ct)).includes(Je.txid)||(yield Te.txIdsByBlockHeight.insert("",{txid:Je.txid,blockHeight:Je.blockHeight})),yield Te.txById.insert("",Je.txid,Je),We==null&&(yield Te.txIdsByDate.insert("",{txid:_e.txid,date:_e.date})),Je}))})},numTransactions(){return me.all.txIdsByDate.size("")},removeTransaction(Se){return qr(this,null,function*(){})},fetchTransactions(Se){return qr(this,null,function*(){const{blockHeightMax:ke,txId:_e,options:Te}=Se;let{blockHeight:We}=Se;const Je=[];return yield me.tx(it=>qr(this,null,function*(){if(_e!=null){const ct=yield it.txById.query("",[_e]);Je.push(...ct)}if(ke!=null&&We==null&&(We=0),We!=null){const ct=yield(yield it.txIdsByBlockHeight.query("",We,ke)).reverse().map(({txid:pt})=>pt),dt=yield it.txById.query("",ct);Je.push(...dt)}if(Te!=null){const{startEntries:ct,startIndex:dt,startDate:pt=new Date(0),endDate:St=new Date}=Te;let Ut;ct!=null&&dt!=null?Ut=yield it.txIdsByDate.queryByCount("",ct,dt):Ut=yield it.txIdsByDate.query("",Pa(pt.getTime()),Pa(St.getTime()));const Jt=yield Ut.reverse().map(({txid:_t})=>_t),ur=yield it.txById.query("",Jt);Je.push(...ur.filter(_t=>_t!=null))}})),Je})},saveAddress(Se){return qr(this,null,function*(){yield me.address(ke=>qr(this,null,function*(){let _e;const[Te]=yield ke.addressByScriptPubkey.query("",[Se.scriptPubkey]);if(Se.path!=null){const[We]=yield ke.scriptPubkeyByPath.query(li(Se.path),Se.path.addressIndex);if(We!=null&&We!==Se.scriptPubkey)throw new Error("Attempted to save address with an existing path, but different script pubkey");if(_e={path:Se.path,scriptPubkey:Se.scriptPubkey},Se.used||(Te==null?void 0:Te.used)===!0){let[Je]=yield ke.lastUsedByFormatPath.query("",[li(Se.path)]);Je==null&&(Je=-1),Je<Se.path.addressIndex&&(yield ke.lastUsedByFormatPath.insert("",li(Se.path),Se.path.addressIndex))}}if(Te!=null){if(Se.lastQueriedBlockHeight>Te.lastQueriedBlockHeight&&(Te.lastQueriedBlockHeight=Se.lastQueriedBlockHeight),Se.lastQuery>Te.lastQuery&&(Te.lastQuery=Se.lastQuery),Se.lastTouched>Te.lastTouched&&(Te.lastTouched=Se.lastTouched),Se.balance!=null&&(Te.balance=Se.balance),Se.path!=null&&Te.path==null&&(Te.path=Se.path,_e={path:Te.path,scriptPubkey:Te.scriptPubkey}),Se.used&&!Te.used&&(Te.used=!0),Te.path!=null&&Te.used){let[We]=yield ke.lastUsedByFormatPath.query("",[li(Te.path)]);We==null&&(We=-1),We<Te.path.addressIndex&&(yield ke.lastUsedByFormatPath.insert("",li(Te.path),Te.path.addressIndex))}yield ke.addressByScriptPubkey.insert("",Te.scriptPubkey,Te)}Te==null&&(yield ke.addressByScriptPubkey.insert("",Se.scriptPubkey,Se)),_e!=null&&(yield ke.scriptPubkeyByPath.insert(li(_e.path),_e.path.addressIndex,_e.scriptPubkey))}))})},numAddressesByFormatPath(Se){return me.all.scriptPubkeyByPath.length(li(Se))},lastUsedIndexByFormatPath(Se){return qr(this,null,function*(){const[ke]=yield me.address(_e=>qr(this,null,function*(){return yield _e.lastUsedByFormatPath.query("",[li(Se)])}));return ke!=null?ke:-1})},fetchAddress(Se){return qr(this,null,function*(){return yield me.address(ke=>qr(this,null,function*(){if(typeof Se=="string"){const Je=Se,[it]=yield ke.addressByScriptPubkey.query("",[Je]);return it}const _e=Se,[Te]=yield ke.scriptPubkeyByPath.query(li(_e),_e.addressIndex);if(Te==null)return;const[We]=yield ke.addressByScriptPubkey.query("",[Te]);return We}))})}}})}var Lp=Object.defineProperty,Dp=Object.defineProperties,Up=Object.getOwnPropertyDescriptors,dh=Object.getOwnPropertySymbols,Hp=Object.prototype.hasOwnProperty,zp=Object.prototype.propertyIsEnumerable,ph=(R,O,z)=>O in R?Lp(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,Kp=(R,O)=>{for(var z in O||(O={}))Hp.call(O,z)&&ph(R,z,O[z]);if(dh)for(var z of dh(O))zp.call(O,z)&&ph(R,z,O[z]);return R},jp=(R,O)=>Dp(R,Up(O));const Wp=i("bip32","bip44","bip49"),Gp=n(Wp,"bip32");function Pc(R,O=0){return H(z=>{if(z==null||typeof z!="object")throw new TypeError("Private keys must be objects");return F({coinType:n(c,O),format:Gp,imported:n(f),seed:h})(jp(Kp({},z),{seed:z[`${R}Key`]}))},z=>{const{coinType:me,format:Me,imported:Re,seed:Se}=z;return{coinType:me,format:Me,imported:Re,[`${R}Key`]:Se}})}const vh=F({publicKeys:F({bip32:n(h),bip44:n(h),bip49:n(h),bip84:n(h)})}),Af=(R,O)=>{var z;const me=(()=>{switch(O){case"bip32":return["bip32"];case"bip44":return["bip44"];case"bip49":return["bip49","bip84"]}})(),Me=(z=R.formats)!=null?z:["bip44","bip32"];return me.filter(Re=>Me.includes(Re))},mh=R=>{const O=[];for(const[z,me]of Object.entries(R.publicKeys))me!=null&&O.push(z);return O.includes("bip49")?"bip49":O.includes("bip44")?"bip44":(O.includes("bip32"),"bip32")},gh=R=>O=>{const{coinInfo:z,engineInfo:me}=R,{id:Me,type:Re}=O,Se=Pc(z.name,z.coinType),ke=G(vh)(O.keys);if(ke!=null){const Te=Object.entries(ke.publicKeys).filter(([,Je])=>Je!=null).map(([Je])=>G(Ad)(Je)).filter(Je=>Je!=null);if(Te.length===0)throw new Error("Missing wallet public keys");const We=mh(ke);return{id:Me,type:Re,keys:{privateKeyFormat:We,walletFormats:Te,publicKey:ke}}}const _e=G(Se)(O.keys);if(_e!=null){const Te=Jp({engineInfo:me,privateKey:_e,coin:z.name}),We=Af(me,_e.format);return{id:Me,type:Re,keys:{privateKeyFormat:_e.format,walletFormats:We,publicKey:{publicKeys:Te}}}}throw new Error("Either a public or private key are required")};var Vp=Object.defineProperty,qp=Object.defineProperties,Xp=Object.getOwnPropertyDescriptors,yh=Object.getOwnPropertySymbols,Zp=Object.prototype.hasOwnProperty,Yp=Object.prototype.propertyIsEnumerable,bh=(R,O,z)=>O in R?Vp(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,Tf=(R,O)=>{for(var z in O||(O={}))Zp.call(O,z)&&bh(R,z,O[z]);if(yh)for(var z of yh(O))Yp.call(O,z)&&bh(R,z,O[z]);return R},Oc=(R,O)=>qp(R,Xp(O)),$p=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});const Bc=R=>{switch(R){case Sr.Airbitz:return"bip32";case Sr.Legacy:return"bip44";case Sr.WrappedSegwit:return"bip49";case Sr.Segwit:return"bip84";case Sr.ReplayProtection:return"bip44"}},Rc=R=>{switch(R){case Sr.Airbitz:case Sr.Legacy:return Ai.p2pkh;case Sr.WrappedSegwit:return Ai.p2sh;case Sr.Segwit:return Ai.p2wpkh;case Sr.ReplayProtection:return Ai.p2sh}},Pf=R=>{switch(R){case Sr.Airbitz:case Sr.Legacy:return wn.p2pkh;case Sr.WrappedSegwit:return wn.p2wpkhp2sh;case Sr.Segwit:return wn.p2wpkh;case Sr.ReplayProtection:return wn.replayProtection}},wh=R=>Ue(Tf({},R)),xh=(R,O)=>{const z=[0];return Oi(O)!==Sr.Airbitz&&z.push(1),R.scriptTemplates!=null&&R.scriptTemplates.replayProtection!=null&&z.push(ne(R.scriptTemplates.replayProtection)),z},Qi=(R,O)=>O!=null&&O.replayProtection!=null&&se(O.replayProtection,R)?Sr.ReplayProtection:Oi(R.format),Oi=R=>Aa(parseInt(R.replace("bip",""))),Mh=R=>$p(void 0,null,function*(){const O="walletKeys.json";let z;try{const me=yield R.walletLocalEncryptedDisklet.getText(O);z=JSON.parse(me)}catch{z=Eh(R),yield R.walletLocalEncryptedDisklet.setText(O,JSON.stringify(z))}return z}),Eh=R=>{const O={},z={seed:R.privateKey.seed,coinType:R.privateKey.coinType,coin:R.coin},me=Oi(R.privateKey.format);return me===Sr.Segwit||me===Sr.WrappedSegwit?(O[Bc(Sr.Segwit)]=P(Oc(Tf({},z),{type:Sr.Segwit})),O[Bc(Sr.WrappedSegwit)]=P(Oc(Tf({},z),{type:Sr.WrappedSegwit}))):O[Bc(me)]=P(Oc(Tf({},z),{type:me})),O},Jp=R=>{const{engineInfo:O,privateKey:z,coin:me}=R,Me={};for(const Re of Af(O,z.format)){const Se=Eh({coin:me,privateKey:z})[Re];if(Se==null)throw new Error("Cannot derive xpub: no private key exists");Me[Re]=X({coin:me,type:Oi(Re),xpriv:Se})}return Me},Qp=R=>{const O={};try{Zt({wifKey:R.pathname,coin:R.coin}),O.privateKeys=[R.pathname]}catch{const me=Zl({address:R.pathname,coin:R.coin});if(me===Ia.bad)throw new Error("InvalidPublicAddressError");O.publicAddress=Et(R.pathname,R.coin),me===Ia.legacy&&(O.legacyAddress=R.pathname)}return O},ev=R=>R.reduce((O,{spent:z,value:me})=>z?O:Ge.add(O,me),"0");var Sh=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});const tv=(R,O,z)=>Sh(void 0,null,function*(){const me=O.inputs[z],{scriptPubkey:Me}=me,Re=yield R.fetchAddress(Me);if(Re==null)throw new Error(`Cannot find address for ${Me}`);if(Re.path==null)throw new Error("Address has no derivation path information");const Se=Re.redeemScript,ke=Oi(Re.path.format),_e=Je=>Sh(void 0,null,function*(){switch(ke){case Sr.Airbitz:case Sr.Legacy:return{script:O.hex,scriptType:Se!=null?wn.p2sh:wn.p2pkh};case Sr.WrappedSegwit:return{script:Je,scriptType:wn.p2wpkhp2sh};case Sr.Segwit:return{script:Je,scriptType:wn.p2wpkh};default:throw new Error(`Unknown purpose type ${ke}`)}}),{script:Te,scriptType:We}=yield _e(Me);return{id:`${me.txId}_${me.outputIndex}`,txid:me.txId,vout:me.outputIndex,value:me.amount,scriptPubkey:Me,script:Te,redeemScript:Se,scriptType:We,blockHeight:O.blockHeight,spent:!0}});var rv=er(1160),kh=er.n(rv),_h=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});function nv(R){let O=0;const z=[];for(const me of R)O+=me.amount,z.push({publicAddress:me.address,nativeAmount:`${me.amount}`});return{nativeAmount:O,spendTargets:z}}function iv(R,O,z){return _h(this,null,function*(){const Me=yield z(R,{headers:{Accept:"application/payment-request","x-currency":O}});if(Me.status!==200){const pt=yield Me.text();throw new Error(pt)}const Re=yield Me.json(),{outputs:Se,memo:ke,paymentUrl:_e,paymentId:Te,requiredFeeRate:We}=Re,{nativeAmount:Je,spendTargets:it}=nv(Se),ct=kh()(_e,{}).hostname;return{nativeAmount:`${Je}`,merchant:`{ ${JSON.stringify(Te)}, ${JSON.stringify(We)} }`,memo:ke,domain:ct,spendTargets:it}})}function ov(R,O){return{currency:O,transactions:[R]}}function av(R,O,z){return _h(this,null,function*(){const Me=yield R(O,{method:"POST",headers:{"Content-Type":"application/payment"},body:JSON.stringify(z)});if(Me.status!==200){const Se=yield Me.text();throw new Error(Se)}return yield Me.json()})}var sv=Object.defineProperty,fv=Object.defineProperties,uv=Object.getOwnPropertyDescriptors,Ih=Object.getOwnPropertySymbols,lv=Object.prototype.hasOwnProperty,cv=Object.prototype.propertyIsEnumerable,Ah=(R,O,z)=>O in R?sv(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,hv=(R,O)=>{for(var z in O||(O={}))lv.call(O,z)&&Ah(R,z,O[z]);if(Ih)for(var z of Ih(O))cv.call(O,z)&&Ah(R,z,O[z]);return R},dv=(R,O)=>fv(R,uv(O)),pv=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});const vv=(R,O,z)=>pv(void 0,null,function*(){const me=[],Me=z.inputs.map(Se=>`${Se.txId}_${Se.outputIndex}`),Re=yield O.fetchUtxos({utxoIds:Me});for(const Se of Re)Se!=null&&me.push(dv(hv({},Se),{spent:!0}));for(const Se of z.outputs){const ke=Se.scriptPubkey,_e=yield O.fetchAddress(ke);if(_e!=null){const Te=`${z.txid}_${Se.n}`,We=_e.path;if(We!=null){const Je=_e.redeemScript,it=Qi(We,R.scriptTemplates),ct=[Sr.Airbitz,Sr.Legacy,Sr.ReplayProtection].includes(it),dt=Pf(it),pt=ct?z.hex:_e.scriptPubkey,St={id:Te,txid:z.txid,vout:Se.n,value:Se.amount,scriptPubkey:ke,script:pt,redeemScript:Je,scriptType:dt,blockHeight:z.blockHeight,spent:!1};me.push(St)}}}return me});class Vn{constructor(){this._resolve=()=>{},this._reject=()=>{},this._promise=new Promise((O,z)=>{this._reject=z,this._resolve=O})}get promise(){return this._promise}resolve(O){this._resolve(O)}reject(O){this._reject(O)}}const mv=100,gv=.05,yv=2,Th=8;var Ph=er(6579),bv=Object.defineProperty,wv=Object.defineProperties,xv=Object.getOwnPropertyDescriptors,Oh=Object.getOwnPropertySymbols,Mv=Object.prototype.hasOwnProperty,Ev=Object.prototype.propertyIsEnumerable,Bh=(R,O,z)=>O in R?bv(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,Rh=(R,O)=>{for(var z in O||(O={}))Mv.call(O,z)&&Bh(R,z,O[z]);if(Oh)for(var z of Oh(O))Ev.call(O,z)&&Bh(R,z,O[z]);return R},Sv=(R,O)=>wv(R,xv(O));const kv=(R=h)=>F({txid:h,vout:c,value:h,confirmations:n(c),coinbase:n(f),height:n(c),lockTime:n(c),address:n(R),path:n(h)}),Cc=(R=h)=>F({txid:h,hex:h,blockHeight:c,confirmations:c,blockTime:c,fees:h,vin:Z(F({txid:h,sequence:n(c,0),n:c,vout:n(c,0),addresses:Z(R),isAddress:f,value:h,hex:n(h)})),vout:Z(F({n:c,value:h,addresses:Z(R),hex:n(h)}))}),_v=F({error:F({message:h})}),qn=R=>O=>{const z=G(_v)(O);if(z!=null)throw new Error(`Blockbook Error: ${z.error.message}`);return R(O)},Iv=()=>({method:"ping",params:void 0,cleaner:qn(Av)}),Av=F({}),Tv=()=>({method:"getInfo",params:{},cleaner:qn(Pv)}),Pv=F({name:h,shortcut:h,decimals:c,version:h,bestHeight:c,bestHash:h,block0Hash:h,testnet:f,backend:n(F({version:h,subversion:h}))}),Ch=(R,O=h)=>({method:"getAccountUtxo",params:{descriptor:oe(O)(R)},cleaner:qn(Ov(O))}),Ov=(R=h)=>Z(kv(R)),Fh=(R,O=h)=>({method:"getTransaction",params:{txid:R},cleaner:qn(Bv(O))}),Bv=Cc,Rv=R=>({method:"getTransactionSpecific",params:{txid:R},cleaner:qn(a)}),Cv=R=>({method:"sendTransaction",params:{hex:R},cleaner:qn(Nh)}),Nh=F({result:h}),Lh=(R,O=h,z={})=>{const me=oe(O);return{method:"getAccountInfo",params:Sv(Rh({},Rh({details:"basic",page:1,pageSize:100},z)),{descriptor:me(R)}),cleaner:qn(Fv(O))}},Fv=(R=h)=>F({address:R,balance:h,totalReceived:h,totalSent:h,txs:c,unconfirmedBalance:h,unconfirmedTxs:c,txids:n(Z(h),[]),transactions:n(Z(Cc(R)),[]),page:n(c,NaN),totalPages:n(c,NaN),itemsOnPage:n(c,NaN)}),Nv=()=>({method:"subscribeNewBlock",params:{},cleaner:qn(Lv)}),Lv=F({height:c,hash:h}),Dv=(R,O=h)=>{const z=oe(O);return{method:"subscribeAddresses",params:{addresses:R.map(z)},cleaner:qn(Uv(O))}},Uv=(R=h)=>F({address:R,tx:Cc(R)});var Hv=er(7689),eo=er.n(Hv),xn=(R=>(R[R.CONNECTING=0]="CONNECTING",R[R.OPEN=1]="OPEN",R[R.CLOSING=2]="CLOSING",R[R.CLOSED=3]="CLOSED",R))(xn||{});function zv(R,O){const z=new(eo())(R,{headers:{"User-Agent":"NodeJS-WS-agent"}});return z.on("open",()=>{O.onOpen()}),z.on("message",me=>{O.onMessage(me.toString())}),z.on("error",me=>{O.onError(me)}),z.on("close",me=>{O.onClose()}),{get readyState(){switch(z.readyState){case eo().CONNECTING:return xn.CONNECTING;case eo().OPEN:return xn.OPEN;case eo().CLOSING:return xn.CLOSING;case eo().CLOSED:default:return xn.CLOSED}},disconnect(){z==null||z.readyState===eo().CLOSING||z.readyState===eo().CLOSED||(z.removeAllListeners(),z.close())},send(me){z.send(me)}}}class Kv extends J0.EventEmitter{}var to=(R=>(R.CONNECTION_OPEN="connection:open",R.CONNECTION_CLOSE="connection:close",R.CONNECTION_TIMER="connection:timer",R))(to||{});const Dh=3,jv=1e3,Tn=[];let Uh;function Hh(R){const O=Tn.length===0;let z=!1;for(const me of Tn)if(me.id===R.id&&me.action===R.action){me.updateFunc=R.updateFunc,z=!0;break}z||Tn.push(R),O&&Kh()}function zh(R){for(let O=0;O<Tn.length;O++){const z=Tn[O];if(R===z.id){Tn.splice(O,1);break}}Tn.length===0&&clearTimeout(Uh)}function Kh(){const R=Dh<Tn.length?Dh:Tn.length;for(let O=0;O<R;O++)if(Tn.length>0){const z=Tn.shift();z==null||z.updateFunc()}Tn.length>0&&(Uh=setTimeout(()=>{Kh()},jv))}function Wv(R,O){if(window.WebSocket==null)throw Error("Native browser WebSocket does not exists");const z=new window.WebSocket(R);return z.onopen=()=>{O.onOpen()},z.onmessage=me=>{O.onMessage(me.data.toString())},z.onerror=()=>{O.onError()},z.onclose=()=>{O.onClose()},{get readyState(){switch(z.readyState){case WebSocket.CONNECTING:return xn.CONNECTING;case WebSocket.OPEN:return xn.OPEN;case WebSocket.CLOSING:return xn.CLOSING;case WebSocket.CLOSED:default:return xn.CLOSED}},disconnect(){z==null||z.readyState===WebSocket.CLOSING||z.readyState===WebSocket.CLOSED||z.close()},send(me){z.send(me)}}}var jh=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});const Wh=500,Gv=5e4,Vv=5e3,qv=F({subscribed:f}),Xv=J(F({id:h,data:n(a),error:n(re(F({message:h}),F({connected:h})))})),Zv=R=>[Xv(R)];function Yv(R,O){var z;let me;const{asResponse:Me=Zv,emitter:Re,log:Se,queueSize:ke=50,walletId:_e}=O;Se("makeSocket connects to",R);const Te="",We=_e+"=="+R,Je={};let it=O.onQueueSpaceCB,ct={},dt=0,pt=0,St=0,Ut=!1,Jt=!1;const ur=1e3*((z=O.timeout)!=null?z:30);let _t,Bt;const Lt=Pt=>{_t==null&&(_t=Pt),Ut&&me!=null&&me.readyState===xn.OPEN?Ft():Jt=!0,Se.error("handled error!",Pt)},Ft=()=>{Se.warn("disconnecting from socket",R),clearTimeout(Bt),Ut=!1,me!=null&&me.disconnect(),zh(We)},jt=()=>{const Pt=_t!=null?_t:new Error("Socket close");Se.warn(`onSocketClose due to ${Pt.message} with server ${R}`),clearTimeout(Bt),Ut=!1,me=null,Jt=!1;for(const Ht of Object.values(ct))try{Ht.task.deferred.reject(Pt)}catch(Qt){Se.error(Qt.message)}ct={};try{Re.emit(to.CONNECTION_CLOSE,R,Pt)}catch(Ht){Se.error(Ht.message)}},It=()=>{if(Se(`onSocketConnect with server ${R}`),Jt){me!=null&&me.disconnect();return}Ut=!0,pt=Date.now();try{Re.emit(to.CONNECTION_OPEN,R)}catch(Pt){Lt(Pt)}for(const[Pt,Ht]of Object.entries(ct))yr(Pt,Ht);wt(),Jt=!1},wt=()=>{Se(`wakeUp socket with server ${R}`),Hh({id:We,updateFunc:()=>{Nt().catch(Pt=>{throw new Error(`wake up error from: ${Pt.message}`)})}})},Nt=()=>jh(this,null,function*(){if(Se(`doWakeUp socket with server ${R}`),St=Date.now(),Ut&&Te!=null)for(;Object.keys(ct).length<ke;){const Pt=yield it(R);if(Pt==null)break;if(typeof Pt=="boolean"){if(Pt)continue;break}tr(Pt)}}),Rt=Pt=>{var Ht;if(me!=null&&me.readyState===xn.OPEN&&Ut){const Qt=Pt.method,wr={id:Qt,method:Pt.method,params:(Ht=Pt.params)!=null?Ht:{}};Je[Qt]=Pt,me.send(JSON.stringify(wr))}},tr=Pt=>{const Ht=(dt++).toString(),Qt={task:Pt,startTime:Date.now()};ct[Ht]=Qt,yr(Ht,Qt)},yr=(Pt,Ht)=>{var Qt;const wr=Date.now();if(me!=null&&me.readyState===xn.OPEN&&Ut&&!Jt){Ht.startTime=wr;const xr={id:Pt,method:Ht.task.method,params:(Qt=Ht.task.params)!=null?Qt:{}};me.send(JSON.stringify(xr)+`
|
|
72
72
|
`)}},hr=()=>{Se(`socket timer with server ${R} expired, check if healthCheck needed`);const Pt=Date.now()-Wh;pt+Gv<Pt&&(Se(`submitting healthCheck to server ${R}`),pt=Pt,O.healthCheck().then(()=>{Re.emit(to.CONNECTION_TIMER,R,Pt)}).catch(Ht=>Lt(Ht)));for(const[Ht,Qt]of Object.entries(ct))if(Qt.startTime+ur<Pt){try{Qt.task.deferred.reject(new Error(`Timeout for request ${Ht}`))}catch(wr){Se.error(wr.message)}an(ct,Ht)}wt(),mr()},mr=()=>{Se(`setupTimer with server ${R}`);let Pt=St+Vv;for(const wr of Object.values(ct)){const xr=wr.startTime+ur;xr<Pt&&(Pt=xr)}const Ht=Date.now()-Wh,Qt=Pt<Ht?0:Pt-Ht;Bt=setTimeout(()=>hr(),Qt)},Kt=Pt=>{try{const Ht=Me(Pt);for(const Qt of Ht)if(Qt.id!=null){const wr=Qt.id.toString(),xr=Je[wr];if(xr!=null){const Or=G(qv)(Qt.data);if((Or==null?void 0:Or.subscribed)!=null){xr.subscribed=!0,xr.deferred.resolve(Qt.data);continue}xr.subscribed||xr.deferred.reject();try{xr.cb(xr.cleaner(Qt.data))}catch(Hr){throw console.log({uri:R,error:Hr,response:Qt,subscription:xr}),Hr}continue}const Tr=ct[wr];if(Tr!=null){an(ct,wr);const{error:Or}=Qt;try{if(Or!=null){const Hr="message"in Or?Or.message:Or.connected;throw new Error(Hr)}Tr.task.cleaner!=null?Tr.task.deferred.resolve(Tr.task.cleaner(Qt.data)):Tr.task.deferred.resolve(Qt.data)}catch(Hr){console.log({uri:R,error:Hr,response:Qt,request:Tr}),Tr.task.deferred.reject(Hr)}continue}throw new Error(`Unknown message id from incoming ws message: ${Pt}`)}}catch(Ht){Lt(Ht)}wt()};return mr(),{get readyState(){var Pt;return(Pt=me==null?void 0:me.readyState)!=null?Pt:xn.CLOSED},connect(){return jh(this,null,function*(){return me==null||me.disconnect(),yield new Promise(Pt=>{const Ht={onOpen:()=>{It(),Pt()},onMessage:Kt,onError:wr=>{_t=new Error(JSON.stringify(wr))},onClose:jt};let Qt=R;(R.startsWith("wss:")||R.startsWith("ws:"))&&(Qt=R.replace(/\/websocket\/?$/,"")+"/websocket"),R.startsWith("electrumwss:")&&(Qt=R.replace(/^electrumwss:/,"wss:")),R.startsWith("electrumws:")&&(Qt=R.replace(/^electrumws:/,"ws:"));try{me=Wv(Qt,Ht)}catch{me=zv(Qt,Ht)}})})},disconnect(){me==null||me.disconnect(),me=null,Ft()},isConnected(){return(me==null?void 0:me.readyState)===xn.OPEN},submitTask:tr,onQueueSpace(Pt){it=Pt},subscribe:Rt}}var $v=Object.defineProperty,Jv=Object.defineProperties,Qv=Object.getOwnPropertyDescriptors,Gh=Object.getOwnPropertySymbols,em=Object.prototype.hasOwnProperty,tm=Object.prototype.propertyIsEnumerable,Vh=(R,O,z)=>O in R?$v(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,ro=(R,O)=>{for(var z in O||(O={}))em.call(O,z)&&Vh(R,z,O[z]);if(Gh)for(var z of Gh(O))tm.call(O,z)&&Vh(R,z,O[z]);return R},no=(R,O)=>Jv(R,Qv(O)),Pn=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});function qh(R){var O;const{asAddress:z,asResponse:me,connectionUri:Me,engineEmitter:Re,log:Se,onQueueSpaceCB:ke,socketEmitter:_e,walletId:Te}=R;Se(`makeBlockbook with uri ${Me}`);const We={isConnected:!1,broadcastTx(ct){return Pn(this,null,function*(){return yield We.promisifyWsMessage(Cv(ct.signedTx))})},connect(){return Pn(this,null,function*(){Se(`connecting to blockbook socket with uri ${Me}`),!We.isConnected&&(yield Je.connect(),We.isConnected=Je.isConnected())})},disconnect(){return Pn(this,null,function*(){Se(`disconnecting from blockbook socket with uri ${Me}, currently connected: ${We.isConnected}`),We.isConnected&&(Je.disconnect(),We.isConnected=!1)})},fetchAddress(ct){return Pn(this,arguments,function*(dt,pt={}){return yield We.promisifyWsMessage(Lh(dt,z,pt))})},fetchAddressUtxos(ct){return Pn(this,null,function*(){return yield We.promisifyWsMessage(Ch(ct))})},fetchInfo(){return Pn(this,null,function*(){return yield We.promisifyWsMessage(Tv())})},fetchTransaction(ct){return Pn(this,null,function*(){return yield We.promisifyWsMessage(Fh(ct))})},onQueueSpace(ct){Je.onQueueSpace(ct)},promisifyWsMessage(ct){return Pn(this,null,function*(){const dt=new Vn;return Je.submitTask(no(ro({},ct),{deferred:dt})),yield dt.promise})},watchAddresses(ct,dt){const pt=St=>Pn(this,null,function*(){Re.emit(cn.NEW_ADDRESS_TRANSACTION,Me,St)});Je.subscribe(no(ro({},Dv(ct,z)),{cb:pt,deferred:dt,subscribed:!1}))},watchBlocks(ct){return Pn(this,null,function*(){const dt=pt=>Pn(this,null,function*(){Re.emit(cn.BLOCK_HEIGHT_CHANGED,Me,pt.height)});Je.subscribe(no(ro({},Nv()),{cb:dt,deferred:ct,subscribed:!1}))})},addressQueryTask(ct,dt,pt){return no(ro({},Lh(ct,dt.asBlockbookAddress,{details:"txs",from:dt.lastQueriedBlockHeight,pageSize:mv,page:dt.page})),{deferred:pt})},transactionQueryTask(ct,dt){return no(ro({},Fh(ct)),{deferred:dt})},transactionSpecialQueryTask(ct,dt){return no(ro({},Rv(ct)),{deferred:dt})},utxoListQueryTask(ct,dt,pt){return no(ro({},Ch(ct,dt.asBlockbookAddress)),{deferred:pt})}},Je=Yv(Me,{asResponse:me,healthCheck:(O=R.ping)!=null?O:it,onQueueSpaceCB:ke,log:Se,emitter:_e,walletId:Te});function it(){return Pn(this,null,function*(){yield We.promisifyWsMessage(Iv())})}return We}const rm=F({tx_pos:c,value:c,tx_hash:h,height:c}),ay=(R=asString)=>asObject({blockhash:asString,blocktime:asNumber,confirmations:asNumber,hash:asString,hex:asString,locktime:asNumber,size:asNumber,time:asNumber,txid:asString,version:asNumber,vin:asArray(asObject({scriptSig:asObject({asm:asString,hex:asString}),sequence:asNumber,txid:asString,vout:asNumber})),vout:asArray(asObject({n:asNumber,scriptPubKey:asObject({addresses:asArray(R),asm:asString,hex:asString,reqSigs:asNumber,type:asString}),value:asNumber}))}),nm=F({error:F({message:h})}),Of=R=>O=>{const z=G(nm)(O);if(z!=null)throw new Error(`Electrum Error: ${z.error.message}`);return R(O)},im=()=>({method:"server.ping",params:void 0,cleaner:Of(om)}),om=G(t),am=R=>({method:"blockchain.scripthash.listunspent",params:[R],cleaner:Of(sm)}),sm=Z(rm),fm=R=>({method:"blockchain.scripthash.get_history",params:[R],cleaner:Of(um)}),um=Z(F({height:c,tx_hash:h})),sy=(R,O=asString)=>({method:"blockchain.transaction.get",params:[R,!0],cleaner:Of(lm(O))}),lm=null;var cm=er(8287).Buffer,hm=Object.defineProperty,dm=Object.defineProperties,pm=Object.getOwnPropertyDescriptors,Xh=Object.getOwnPropertySymbols,vm=Object.prototype.hasOwnProperty,mm=Object.prototype.propertyIsEnumerable,Zh=(R,O,z)=>O in R?hm(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,Yh=(R,O)=>{for(var z in O||(O={}))vm.call(O,z)&&Zh(R,z,O[z]);if(Xh)for(var z of Xh(O))mm.call(O,z)&&Zh(R,z,O[z]);return R},$h=(R,O)=>dm(R,pm(O)),ci=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});const gm=R=>{const O=J(F({id:h,result:a,error:n(re(F({message:h}),F({connected:h})))}))(R);return{id:O.id,data:O.result,error:O.error}},ym=R=>h(R).trimEnd().split(`
|
|
73
73
|
`).map(gm);function bm(R){const{asAddress:O,connectionUri:z,engineEmitter:me,log:Me,onQueueSpaceCB:Re,pluginInfo:Se,socketEmitter:ke,walletId:_e}=R;Me(`makeBlockbookElectrum with uri ${z}`);const Te=Je=>{const it=Ue({address:Je,coin:Se.coinInfo.name});return pe.Et.sha256(cm.from(it,"hex")).reverse().toString("hex")},We=qh({asAddress:O,asResponse:ym,connectionUri:z,engineEmitter:me,log:Me,onQueueSpaceCB:Je=>ci(this,null,function*(){const it=yield Re(Je);if(it==null||typeof it=="boolean")return it;if(it.method==="getAccountUtxo"){const ct=it.params,dt=O!=null?O(ct.descriptor):ct.descriptor,pt=Te(dt),St=new Vn;return St.promise.then(Jt=>{const ur=Jt.map(_t=>({txid:_t.tx_hash,vout:_t.tx_pos,value:_t.value.toString(),height:_t.height}));it.deferred.resolve(ur)}).catch(Jt=>{it.deferred.reject(Jt)}),$h(Yh({},am(pt)),{deferred:St})}if(it.method==="getAccountInfo"){const ct=it.params,dt=O!=null?O(ct.descriptor):ct.descriptor,pt=Te(dt),St=new Vn;return St.promise.then(Jt=>{const ur={address:dt,balance:"0",totalReceived:"0",totalSent:"0",txs:Jt.length,unconfirmedBalance:"0",unconfirmedTxs:Jt.reduce((_t,Bt)=>_t+Bt.height>=0?1:0,0),txids:[],transactions:[],page:0,totalPages:1,itemsOnPage:0};it.deferred.resolve(ur)}).catch(Jt=>{it.deferred.reject(Jt)}),$h(Yh({},fm(pt)),{deferred:St})}return!0}),ping:()=>ci(this,null,function*(){return yield We.promisifyWsMessage(im())}),socketEmitter:ke,walletId:_e});return We.broadcastTx=()=>ci(this,null,function*(){throw new Error("broadcastTx not supported for Electrum connections")}),We.fetchAddress=()=>ci(this,null,function*(){throw new Error("fetchAddress not supported for Electrum connections")}),We.fetchAddressUtxos=()=>ci(this,null,function*(){throw new Error("fetchAddressUtxos not supported for Electrum connections")}),We.fetchInfo=()=>ci(this,null,function*(){throw new Error("fetchInfo not supported for Electrum connections")}),We.fetchTransaction=()=>ci(this,null,function*(){throw new Error("fetchTransaction not supported for Electrum connections")}),We.watchAddresses=()=>ci(this,null,function*(){}),We.watchBlocks=()=>ci(this,null,function*(){}),We}var No=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});function wm(R){const{engineEmitter:O,initOptions:z,io:me,log:Me,pluginInfo:Re,pluginState:Se,walletInfo:ke}=R,{serverConfigs:_e=[]}=Re.engineInfo;Me("Making server states");const Te={};let We=!0,Je=[],it=0,ct=setTimeout(()=>{},0);const dt=new Kv;dt.on(to.CONNECTION_OPEN,Kt=>{it=0,Me(`${Kt} ** Connected **`)}),dt.on(to.CONNECTION_CLOSE,(Kt,Pt)=>{an(Te,Kt);const Ht=Pt!=null?` !! Connection ERROR !! ${Pt.message}`:"";Me(`${Kt} onClose ${Ht}`),Pt!=null&&Se.serverScoreDown(Kt),ur()}),dt.on(to.CONNECTION_TIMER,(Kt,Pt)=>{const Ht=Date.now()-Pt;Me(`${Kt} returned healthCheck in ${Ht}ms`),Se.serverScoreUp(Kt,Ht)}),O.on(cn.NEW_ADDRESS_TRANSACTION,(Kt,Pt)=>{Me(`${Kt} received received new transaction with id ${Pt.tx.txid} to address ${Pt.address}`);const Ht=Te[Kt];Ht!=null&&Ht.txids.add(Pt.tx.txid)}),O.on(cn.BLOCK_HEIGHT_CHANGED,(Kt,Pt)=>{Me(`${Kt} block height changed to ${Pt}`),Te[Kt].blockHeight=Pt});let pt;const St=Kt=>({blockbook:Kt,blockSubscriptionStatus:"unsubscribed",txids:new Set,addresses:new Set,blockHeight:0}),Ut=Kt=>{pt=Kt},Jt=()=>No(this,null,function*(){We=!1,Me("stopping server states"),zh(ke.id),clearTimeout(ct);for(const Kt of Object.keys(Te)){const Pt=Te[Kt],{blockbook:Ht}=Pt;Ht!=null&&(yield Ht.disconnect(),an(Te,Kt))}}),ur=()=>{if(We){Me(`attempting server reconnect number ${it}`);const Kt=Math.max(5,it++)*1e3;ct=setTimeout(()=>{clearTimeout(ct),_t()},Kt)}},_t=()=>{Me("refilling servers..."),We=!0,Hh({id:ke.id,updateFunc:()=>{Bt()}})},Bt=()=>{const Kt=["wss:","ws:","electrumwss:","electrumws:"];Je.length===0&&(Je=Se.getLocalServers(Th,Kt)),Me(`refillServers: Top ${Th} servers:`,Je);let Pt=1.25;for(;Object.keys(Te).length<yv&&Je.length!==0;){const Ht=Je.shift();if(Ht==null){ur();break}if(Te[Ht]!=null)continue;const Qt=(0,Ph.parse)(Ht);if(Qt.scheme==null||Qt.scheme.length<2||Qt.host==null)continue;if(Pt-=Pt>.5?.25:0,Math.random()>Pt){Je.push(Ht);continue}let wr;["electrumwss","electrumws"].includes(Qt.scheme)?wr=bm({asAddress:Re.engineInfo.asBlockbookAddress,connectionUri:Ht,engineEmitter:O,log:Me,onQueueSpaceCB:()=>No(this,null,function*(){if(!(Ht in Te))return;const xr=yield pt(Ht);if(xr!=null&&typeof xr!="boolean"){const Tr=`${xr.method} params: ${JSON.stringify(xr.params)}`;Me(`${Ht} nextTask: ${Tr}`)}return xr}),pluginInfo:Re,socketEmitter:dt,walletId:ke.id}):wr=qh({asAddress:Re.engineInfo.asBlockbookAddress,connectionUri:Ht,engineEmitter:O,log:Me,onQueueSpaceCB:()=>No(this,null,function*(){if(!(Ht in Te))return;const xr=yield pt(Ht);if(xr!=null&&typeof xr!="boolean"){const Tr=`${xr.method} params: ${JSON.stringify(xr.params)}`;Me(`${Ht} nextTask: ${Tr}`)}return xr}),socketEmitter:dt,walletId:ke.id}),Te[Ht]=St(wr),wr.connect().then(()=>No(this,null,function*(){const xr=Date.now(),{bestHeight:Tr}=yield wr.fetchInfo();Me("height:",Tr),Te[Ht].blockHeight=Tr,O.emit(cn.BLOCK_HEIGHT_CHANGED,Ht,Tr);const Or=Date.now()-xr;Se.serverScoreUp(Ht,Or)})).catch(xr=>{Me.error(`${JSON.stringify(xr.message)}`)})}};return{setPickNextTaskCB:Ut,stop:Jt,serverCanGetTx:(Kt,Pt)=>{const Ht=Te[Kt];if(Ht==null)return!1;if(Ht.txids.has(Pt))return!0;for(const Qt of Object.values(Te))if(Qt.txids.has(Pt))return!1;return!0},serverCanGetAddress:(Kt,Pt)=>{const Ht=Te[Kt];if(Ht==null)return!1;if(Ht.addresses.has(Pt))return!0;for(const Qt of Object.values(Te))if(Qt.addresses.has(Pt))return!1;return!0},serverIsAwareOfAddress:(Kt,Pt)=>{const Ht=Te[Kt];return Ht==null?!1:!!Ht.addresses.has(Pt)},getServerState:Kt=>Te[Kt],refillServers:_t,getServerList:()=>Je,setServerList:Kt=>{Je=Kt},broadcastTx:Kt=>No(this,null,function*(){return yield new Promise((Pt,Ht)=>{let Qt=!1,wr=0;const xr=Object.keys(Te).filter(Or=>Te[Or].blockbook!=null);if(xr.length<1){Ht(new Error("Unexpected error. Missing WebSocket connections."));return}const Tr=xr.some(Or=>Te[Or].blockbook.isConnected);if(Tr)for(const Or of xr){const{blockbook:Hr}=Te[Or];Hr!=null&&Hr.broadcastTx(Kt).then(Zr=>{Qt||(Qt=!0,Pt(Zr.result))}).catch(Zr=>{if(++wr===xr.length){const Rr=Zr!=null?`With error ${Zr.message}`:"";Me.error(`broadcastTx fail: ${JSON.stringify(Kt)}
|
|
74
|
-
${Rr}`),Ht(Zr)}})}if(!Tr){const{nowNodeApiKey:Or}=z,Hr=_e.filter(Zr=>Zr.type==="blockbook-nownode").map(Zr=>Zr.uris).flat(1);if(Hr.length<1){Ht(new Error("No available connections. Check your internet signal."));return}if(Or==null){Ht(new Error("Missing connection key for fallback servers."));return}for(const Zr of Hr)Me.warn("Falling back to NOWNode server broadcast over HTTP:",Zr),me.fetchCors(`${Zr}/api/v2/sendtx/`,{method:"POST",headers:{"api-key":Or},body:Kt.signedTx}).then(Rr=>No(this,null,function*(){if(!Rr.ok)throw new Error(`Failed to broadcast transaction via Blockbook: HTTP ${Rr.status}`);const
|
|
75
|
-
${jr}`),Ht(Rr)}})}})}),watchAddresses:(Kt,Pt,Ht)=>{const Qt=Te[Kt];if(Qt==null)throw new Error(`No blockbook connection with ${Kt}`);const{blockbook:wr}=Qt;for(const Or of Pt)Qt.addresses.add(Or);const xr=Date.now(),Tr=new Vn;Tr.promise.then(Or=>{Se.serverScoreUp(Kt,Date.now()-xr),Ht==null||Ht.resolve(Or)}).catch(()=>{for(const Or of Pt)Qt.addresses.delete(Or);Se.serverScoreDown(Kt),Ht==null||Ht.reject()}),wr.watchAddresses(Array.from(Qt.addresses),Tr)},watchBlocks:Kt=>{const Pt=Te[Kt];if(Pt==null)throw new Error(`No blockbook connection with ${Kt}`);const{blockbook:Ht}=Pt;Pt.blockSubscriptionStatus="subscribing";const Qt=Date.now(),wr=new Vn;wr.promise.then(()=>{Pt.blockSubscriptionStatus="subscribed",Se.serverScoreUp(Kt,Date.now()-Qt)}).catch(()=>{Pt.blockSubscriptionStatus="unsubscribed"}),Ht.watchBlocks(wr)},getBlockHeight:Kt=>Te[Kt].blockHeight,addressQueryTask(Kt,Pt,Ht,Qt){const wr=Te[Kt];if(wr==null)throw new Error(`No blockbook connection with ${Kt}`);return wr.blockbook.addressQueryTask(Pt,{asBlockbookAddress:Re.engineInfo.asBlockbookAddress,lastQueriedBlockHeight:Ht.lastQueriedBlockHeight,page:Ht.page},Qt)},transactionQueryTask(Kt,Pt,Ht){const Qt=Te[Kt];if(Qt==null)throw new Error(`No blockbook connection with ${Kt}`);return Qt.blockbook.transactionQueryTask(Pt,Ht)},transactionSpecialQueryTask(Kt,Pt,Ht){const Qt=Te[Kt];if(Qt==null)throw new Error(`No blockbook connection with ${Kt}`);return Qt.blockbook.transactionSpecialQueryTask(Pt,Ht)},utxoListQueryTask(Kt,Pt,Ht){const Qt=Te[Kt];if(Qt==null)throw new Error(`No blockbook connection with ${Kt}`);return Qt.blockbook.utxoListQueryTask(Pt,{asBlockbookAddress:Re.engineInfo.asBlockbookAddress},Ht)}}}var xm=Object.defineProperty,Mm=Object.defineProperties,Em=Object.getOwnPropertyDescriptors,Jh=Object.getOwnPropertySymbols,Sm=Object.prototype.hasOwnProperty,km=Object.prototype.propertyIsEnumerable,Qh=(R,O,z)=>O in R?xm(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,Yr=(R,O)=>{for(var z in O||(O={}))Sm.call(O,z)&&Qh(R,z,O[z]);if(Jh)for(var z of Jh(O))km.call(O,z)&&Qh(R,z,O[z]);return R},sn=(R,O)=>Mm(R,Em(O)),Br=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});function ed(R){const{initOptions:O,io:z,options:me,pluginState:Me,pluginInfo:Re,processor:Se,walletInfo:ke,walletTools:_e}=R,{emitter:Te,log:We}=me,{walletFormats:Je}=ke.keys,it={blockWatching:!1,addressSubscribeCache:{},addressTransactionCache:{},addressUtxoCache:{},rawUtxoCache:{},processorUtxoCache:{},updateTransactionCache:{},updateTransactionSpecificCache:{}},ct=()=>{it.blockWatching=!1;for(const jt of Object.keys(it.addressSubscribeCache))an(it.addressSubscribeCache,jt);for(const jt of Object.keys(it.addressTransactionCache))an(it.addressTransactionCache,jt);for(const jt of Object.keys(it.addressUtxoCache))an(it.addressUtxoCache,jt);for(const jt of Object.keys(it.rawUtxoCache))an(it.rawUtxoCache,jt);for(const jt of Object.keys(it.processorUtxoCache))an(it.processorUtxoCache,jt);for(const jt of Object.keys(it.updateTransactionCache))an(it.updateTransactionCache,jt);for(const jt of Object.keys(it.updateTransactionSpecificCache))an(it.updateTransactionSpecificCache,jt)},dt=2;let pt=0,St=0;const Ut=()=>Br(this,null,function*(){if(St>=1)return;const jt=Object.keys(it.addressSubscribeCache).length*dt;if(pt=pt+1,jt===0)throw new Error("No addresses to process");const It=pt/jt;(It-St>gv||It===1)&&(We(`processed changed, percent: ${It}, processedCount: ${pt}, totalCount: ${jt}`),St=It,Te.emit(cn.ADDRESSES_CHECKED,It))}),Jt=new eh,ur=wm({engineEmitter:Te,initOptions:O,io:z,log:We,pluginInfo:Re,pluginState:Me,walletInfo:ke}),_t={pluginInfo:Re,walletInfo:ke,walletTools:_e,processor:Se,emitter:Te,taskCache:it,updateProgressRatio:Ut,io:z,log:We,serverStates:ur,pluginState:Me,walletFormats:Je,lock:Jt};ur.setPickNextTaskCB(jt=>Br(this,null,function*(){return yield _m(_t,jt)}));let Bt=!1;const Lt=()=>Br(this,null,function*(){Bt||(Bt=!0,yield Ft(),yield Bf(_t))});Te.on(cn.BLOCK_HEIGHT_CHANGED,(jt,It)=>Br(this,null,function*(){const wt=yield Se.fetchTransactions({blockHeight:0});for(const Nt of wt)Nt!=null&&(it.updateTransactionCache[Nt.txid]={processing:!1})})),Te.on(cn.NEW_ADDRESS_TRANSACTION,(jt,It)=>Br(this,null,function*(){const wt=it.addressSubscribeCache[It.address];if(wt!=null){const{path:Nt}=wt;it.addressUtxoCache[It.address]={processing:!1,path:Nt},td(_t,It.address,Nt,0,it.addressTransactionCache).catch(()=>{throw new Error("failed to add to transaction cache")}),Bf(_t).catch(Rt=>{We(Rt)})}}));const Ft=()=>Br(this,null,function*(){const jt=[];for(const It of Je){const wt=xh(Re.engineInfo,It);for(const Nt of wt){const Rt=new Set,tr={format:It,changeIndex:Nt},br=Se.numAddressesByFormatPath(tr);for(let hr=0;hr<br;hr++){const mr=yield Se.fetchAddress({format:It,changeIndex:Nt,addressIndex:hr});if(mr==null)throw new Error(`Missing processor address ${It} ${Nt} ${hr} during initialization`);const{address:Kt}=_e.scriptPubkeyToAddress({changePath:tr,scriptPubkey:mr.scriptPubkey});Rt.add(Kt),mr.balance!=null&&jt.push({scriptPubkey:mr.scriptPubkey,balance:mr.balance})}Fc(_t.taskCache,Rt,{format:It,changeIndex:Nt})}}Te.emit(cn.ADDRESS_BALANCE_CHANGED,Re.currencyInfo.currencyCode,jt)});return{processedPercent:St,start(){return Br(this,null,function*(){pt=0,St=0,yield Lt(),ur.refillServers()})},stop(){return Br(this,null,function*(){ur.stop(),ct(),Bt=!1})},getFreshAddress(jt){return Br(this,arguments,function*({branch:It=0,forceIndex:wt}){const{privateKeyFormat:Nt}=ke.keys;Nt==="bip32"&&(It=0);const{address:Rt,nativeBalance:tr="0",legacyAddress:br}=yield rd(sn(Yr({},_t),{format:Nt,forceIndex:wt,changeIndex:It})),hr={publicAddress:Rt,nativeBalance:tr,legacyAddress:br!==Rt?br:void 0,legacyNativeBalance:br!==Rt?tr:void 0},mr=Af(Re.engineInfo,ke.keys.privateKeyFormat).filter(Kt=>Kt!==Nt);for(const Kt of mr)if(Kt==="bip84"){const{address:Pt,nativeBalance:Ht="0"}=yield rd(sn(Yr({},_t),{format:Kt,forceIndex:wt,changeIndex:It}));hr.segwitAddress=Pt,hr.segwitNativeBalance=Ht}return hr})},deriveScriptAddress(jt){return Br(this,null,function*(){const{address:It}=yield Tm({walletTools:_t.walletTools,engineInfo:_t.pluginInfo.engineInfo,processor:_t.processor,taskCache:_t.taskCache,format:ke.keys.privateKeyFormat,script:jt});return{publicAddress:It}})},addGapLimitAddresses(jt){return Br(this,null,function*(){const It=jt.map(wt=>Br(this,null,function*(){const Nt=_e.addressToScriptPubkey(wt);yield Se.saveAddress(si({scriptPubkey:Nt,used:!0}))}));yield Promise.all(It),yield Lt()})},broadcastTx(jt){return Br(this,null,function*(){return yield ur.broadcastTx(jt)})},refillServers(){ur.refillServers()},getServerList(){return ur.getServerList()},setServerList(jt){ur.setServerList(jt)},loadWifs(jt){return Br(this,null,function*(){for(const It of jt)for(const wt of Je){const Nt={format:wt,changeIndex:0},Rt=sn(Yr({},Nt),{addressIndex:0}),{scriptPubkey:tr,redeemScript:br}=_e.getScriptPubkeyFromWif(It,wt),{address:hr}=_e.scriptPubkeyToAddress({changePath:Rt,scriptPubkey:tr});yield Se.saveAddress(si({scriptPubkey:tr,redeemScript:br,path:Rt})),it.addressSubscribeCache[hr]={path:Nt,processing:!1}}})},processUtxos(jt){return Br(this,null,function*(){var It;const wt=new Map,Nt=new Set;for(const Rt of jt){const tr=(It=wt.get(Rt.scriptPubkey))!=null?It:[];wt.has(Rt.scriptPubkey)||wt.set(Rt.scriptPubkey,tr),tr.push(Rt),Nt.add(Rt.id)}for(const[Rt,tr]of wt.entries()){const mr=[...(yield Se.fetchUtxos({scriptPubkey:Rt})).filter(Kt=>Kt!=null&&!Nt.has(Kt==null?void 0:Kt.id)),...tr];yield nd(sn(Yr({},_t),{scriptPubkey:Rt,utxos:mr}))}})}}}const Bf=R=>Br(void 0,null,function*(){const{pluginInfo:{engineInfo:O},lock:z,processor:me,walletFormats:Me,walletTools:Re}=R;yield z.acquireAsync();try{for(const ke of Me){const _e=xh(O,ke);for(const Te of _e)yield Se({format:ke,changeIndex:Te})}}finally{z.release()}function Se(ke){return Br(this,null,function*(){const _e=new Set,Te=me.numAddressesByFormatPath(ke);let We=yield me.lastUsedIndexByFormatPath(ke),Je=We+O.gapLimit,it=Te;for(;it<=Je;){const ct=sn(Yr({},ke),{addressIndex:it}),{scriptPubkey:dt,redeemScript:pt}=Re.getScriptPubkey(ct),{address:St}=Re.scriptPubkeyToAddress({changePath:ct,scriptPubkey:dt});yield me.saveAddress(si({scriptPubkey:dt,redeemScript:pt,path:ct})),_e.add(St),We=yield me.lastUsedIndexByFormatPath(ke),Je=We+O.gapLimit,it=me.numAddressesByFormatPath(ke)}Fc(R.taskCache,_e,ke)})}}),Fc=(R,O,z)=>{O.forEach(me=>{R.addressSubscribeCache[me]={path:z,processing:!1}})},td=(R,O,z,me,Me)=>Br(void 0,null,function*(){var Re;const{walletTools:Se,processor:ke}=R,_e=Se.addressToScriptPubkey(O);if(me===0){const{lastQueriedBlockHeight:Te=0}=(Re=yield ke.fetchAddress(_e))!=null?Re:{};me=Te}Me[O]={processing:!1,path:z,page:1,blockHeight:me}}),Ba=R=>Br(void 0,null,function*(){const{emitter:O,walletTools:z,processor:me,pluginInfo:Me,tx:Re,walletId:Se}=R;O.emit(cn.TRANSACTIONS_CHANGED,[yield oh({walletId:Se,tx:Re,walletTools:z,processor:me,pluginInfo:Me})])}),_m=(R,O)=>Br(void 0,null,function*(){const{pluginInfo:z,taskCache:me,serverStates:Me}=R,{addressSubscribeCache:Re,addressUtxoCache:Se,rawUtxoCache:ke,processorUtxoCache:_e,addressTransactionCache:Te,updateTransactionCache:We,updateTransactionSpecificCache:Je}=me,it=z.engineInfo.txSpecificHandling!=null,ct=Me.getServerState(O);if(ct!=null){if(ct.blockSubscriptionStatus==="unsubscribed")return Me.watchBlocks(O),!0;if(Object.keys(_e).length>0){for(const[dt,pt]of Object.entries(_e))if(!pt.processing&&pt.full)return pt.processing=!0,yield nd(sn(Yr({},R),{scriptPubkey:dt,utxos:pt.utxos})),an(_e,dt),!0}for(const[dt,pt]of Object.entries(ke)){const St=pt.blockbookUtxo;if(St!=null&&!pt.processing){const Ut=Qi(pt.path,z.engineInfo.scriptTemplates);if((Ut===Sr.Airbitz||Ut===Sr.Legacy||Ut===Sr.ReplayProtection)&&!Me.serverCanGetTx(O,St.txid))return;pt.processing=!0,an(ke,dt);const Jt=yield Bm(sn(Yr(Yr({},R),pt),{address:pt.address,serverUri:O,utxo:St,id:`${St.txid}_${St.vout}`}));return Jt!=null?Jt:!0}}for(const[dt,pt]of Object.entries(Se))if(!pt.processing&&Me.serverCanGetAddress(O,dt)){pt.processing=!0,an(Se,dt);const St=yield Om(sn(Yr(Yr({},R),pt),{address:dt,serverUri:O}));return St.deferred.promise.then(()=>{ct.addresses.add(dt)}).catch(Ut=>{Se[dt]=pt,console.error(Ut),R.log("error in addressUtxoCache:",Ut)}),St}if(Object.keys(Re).length>0){const dt=[],pt=Me.getBlockHeight(O);for(const[St,Ut]of Object.entries(Re)){const Jt=!Me.serverIsAwareOfAddress(O,St);Jt&&dt.push(St),!Ut.processing&&(Jt&&(Se[St]={processing:!1,path:Ut.path}),yield td(R,St,Ut.path,pt,Te),Ut.processing=!0)}if(dt.length>0)return Me.watchAddresses(O,dt),!0}if(Object.keys(Je).length>0){let dt=!1;for(const[pt,St]of Object.entries(Je))if(!St.processing&&Me.serverCanGetTx(O,pt)){dt=!0,St.processing=!0,an(Je,pt);const Ut=Im(sn(Yr({},R),{serverUri:O,txId:pt}));return Ut.deferred.promise.then(()=>{ct.txids.add(pt)}).catch(Jt=>{Je[pt]=St,console.error(Jt),R.log("error in updateTransactionSpecificCache:",Jt)}),Ut}if(dt)return!0}if(Object.keys(We).length>0){let dt=!1;for(const[pt,St]of Object.entries(We))if(!St.processing&&Me.serverCanGetTx(O,pt)){dt=!0,St.processing=!0,an(We,pt);const Ut=Am(sn(Yr({},R),{serverUri:O,needsTxSpecific:it,txId:pt}));return Ut.deferred.promise.then(()=>{ct.txids.add(pt)}).catch(Jt=>{We[pt]=St,console.error(Jt),R.log("error in updateTransactionCache:",Jt)}),Ut}if(dt)return!0}for(const[dt,pt]of Object.entries(Te))if(!pt.processing&&Me.serverCanGetAddress(O,dt)){pt.processing=!0,an(Te,dt);const St=yield Pm(sn(Yr({},R),{addressTransactionState:pt,address:dt,needsTxSpecific:it,serverUri:O}));return St.deferred.promise.then(()=>{ct.addresses.add(dt)}).catch(Ut=>{Te[dt]=pt,console.error(Ut),R.log("error in updateTransactionCache:",Ut)}),St}}}),Im=R=>{const{walletInfo:O,emitter:z,walletTools:me,pluginInfo:Me,processor:Re,serverUri:Se,txId:ke,taskCache:_e}=R,Te=new Vn;return Te.promise.then(We=>Br(void 0,null,function*(){let it=(yield Re.fetchTransactions({txId:ke}))[0];if(it==null)return;Me.engineInfo.txSpecificHandling!=null&&(it=Me.engineInfo.txSpecificHandling(it,We));const ct=yield Re.saveTransaction({tx:it});yield Ba({walletId:O.id,emitter:z,walletTools:me,processor:Re,pluginInfo:Me,tx:ct})})).catch(We=>{console.error(We),R.log("error in updateTransactionsSpecific:",We),_e.updateTransactionSpecificCache[ke]={processing:!1}}),R.serverStates.transactionSpecialQueryTask(Se,ke,Te)},Am=R=>{const{walletInfo:O,emitter:z,walletTools:me,txId:Me,needsTxSpecific:Re,pluginInfo:Se,processor:ke,serverUri:_e,taskCache:Te}=R,We=new Vn;return We.promise.then(Je=>Br(void 0,null,function*(){if(Je.blockHeight<1)return;const it=Nc(sn(Yr({},R),{txResponse:Je}));for(const St of it.inputs)yield ke.removeUtxos([`${St.txId}_${St.outputIndex}`]);const ct=it.outputs.map(St=>`${it.txid}_${St.n}`),dt=yield ke.fetchUtxos({utxoIds:ct});for(const St of dt)St!=null&&(St.blockHeight=it.blockHeight,yield ke.saveUtxo(St));const pt=yield ke.saveTransaction({tx:it});yield Ba({walletId:O.id,emitter:z,walletTools:me,processor:ke,pluginInfo:Se,tx:pt}),Re&&(Te.updateTransactionSpecificCache[Me]={processing:!1})})).catch(Je=>{console.error(Je),R.log("error in updateTransactions:",Je),Te.updateTransactionCache[Me]={processing:!1}}),R.serverStates.transactionQueryTask(_e,Me,We)},Tm=R=>Br(void 0,[R],function*({walletTools:O,engineInfo:z,processor:me,format:Me,taskCache:Re,script:Se}){if(z.scriptTemplates==null)throw new Error(`cannot derive script address ${Se} without defined script template`);const ke=z.scriptTemplates[Se],_e={format:Me,changeIndex:ne(ke),addressIndex:0},{address:Te,scriptPubkey:We,redeemScript:Je}=O.getScriptAddress({path:_e,scriptTemplate:ke});yield me.saveAddress(si({scriptPubkey:We,redeemScript:Je,path:_e}));const it=new Set;return it.add(Te),Fc(Re,it,{format:_e.format,changeIndex:_e.changeIndex}),{address:Te,scriptPubkey:We,redeemScript:Je}}),rd=R=>Br(void 0,null,function*(){var O;const{format:z,changeIndex:me,walletTools:Me,processor:Re,forceIndex:Se}=R,ke=Re.numAddressesByFormatPath({format:z,changeIndex:me}),_e={format:z,changeIndex:me,addressIndex:Math.max(ke-R.pluginInfo.engineInfo.gapLimit,0)};Se!=null&&(_e.addressIndex=Se);const Te=yield Re.fetchAddress(_e),We=(O=Te==null?void 0:Te.balance)!=null?O:"0",{scriptPubkey:Je}=Te!=null?Te:yield Me.getScriptPubkey(_e);if(Je==null)throw new Error("Unknown address path");const it=Me.scriptPubkeyToAddress({changePath:_e,scriptPubkey:Je});return sn(Yr({},it),{nativeBalance:We})}),Pm=R=>Br(void 0,null,function*(){const{walletInfo:O,address:z,addressTransactionState:me,emitter:Me,needsTxSpecific:Re,pluginInfo:Se,processor:ke,walletTools:_e,taskCache:Te,pluginState:We,serverUri:Je}=R,{page:it=1,blockHeight:ct}=me,dt=Te.addressTransactionCache,pt=_e.addressToScriptPubkey(z),St=yield ke.fetchAddress(pt);if(St==null)throw new Error(`could not find address with script pubkey ${pt}`);const Ut=Date.now(),Jt=new Vn;return Jt.promise.then(ur=>Br(void 0,null,function*(){We.serverScoreUp(Je,Date.now()-Ut);const{transactions:_t=[],txs:Bt,unconfirmedTxs:Lt,totalPages:Ft}=ur,jt=Bt>0||Lt>0;!St.used&&jt&&it===1&&(St.used=!0);for(const It of _t){const wt=Nc(sn(Yr({},R),{txResponse:It})),Nt=yield ke.saveTransaction({tx:wt,scriptPubkeys:[pt]});yield Ba({walletId:O.id,emitter:Me,walletTools:_e,processor:ke,pluginInfo:Se,tx:Nt}),Re&&(Te.updateTransactionSpecificCache[wt.txid]={processing:!1})}if(it<Ft){dt[z]=sn(Yr({},me),{processing:!1,page:it+1});return}St.lastQueriedBlockHeight=ct,yield ke.saveAddress(St),yield R.updateProgressRatio(),yield Bf(R)})).catch(ur=>{console.error(ur),dt[z]=me}),R.serverStates.addressQueryTask(Je,z,{lastQueriedBlockHeight:St.lastQueriedBlockHeight,page:it},Jt)}),Nc=R=>{const{txResponse:O,pluginInfo:{coinInfo:z}}=R,me=O.vin.map(Re=>{const Se=G(ke=>wh(ke),"unknown")({address:Re.addresses[0],coin:z.name});return{txId:Re.txid,outputIndex:Re.vout,n:Re.n,scriptPubkey:Se,amount:Re.value}}),Me=O.vout.map(Re=>{var Se;const ke=(Se=Re.hex)!=null?Se:G(_e=>wh(_e),"unknown")({address:Re.addresses[0],coin:z.name});return{n:Re.n,scriptPubkey:ke,amount:Re.value}});return{txid:O.txid,hex:O.hex,blockHeight:O.blockHeight>0?O.blockHeight:0,date:O.blockTime,fees:O.fees,inputs:me,outputs:Me,ourIns:[],ourOuts:[],ourAmount:"0"}},Om=R=>Br(void 0,null,function*(){const{address:O,walletTools:z,processor:me,taskCache:Me,path:Re,pluginState:Se,serverUri:ke}=R,{addressUtxoCache:_e,rawUtxoCache:Te,processorUtxoCache:We}=Me,Je=Date.now(),it=new Vn;return it.promise.then(ct=>Br(void 0,null,function*(){Se.serverScoreUp(ke,Date.now()-Je);const dt=z.addressToScriptPubkey(O),pt=yield me.fetchAddress(dt);if(!(pt==null||pt.path==null)){if(ct.length===0){id(We,Re,dt,0);return}for(const St of ct){const Ut=`${St.txid}_${St.vout}`;Te[Ut]={blockbookUtxo:St,processing:!1,requiredCount:ct.length,path:Re,address:sn(Yr({},pt),{path:pt.path})}}}})).catch(()=>{R.processing=!1,_e[O]={processing:R.processing,path:Re}}),R.serverStates.utxoListQueryTask(ke,O,it)}),nd=R=>Br(void 0,null,function*(){const{utxos:O,processor:z,scriptPubkey:me,log:Me,emitter:Re,pluginInfo:{currencyInfo:Se}}=R,ke=Object.fromEntries([...O].map(it=>[it.id,it])),_e=[],Te=yield z.fetchUtxos({scriptPubkey:me});let We="0";for(const it of Te){if(it==null)throw new Error("Unexpected undefined utxo when processing unspent transactions");it.spent||(We=(0,Ge.add)(it.value,We)),ke[it.id]==null&&_e.push(it.id)}yield z.removeUtxos(_e);let Je="0";for(const it of Object.values(ke))it.spent||(Je=(0,Ge.add)(it.value,Je)),yield z.saveUtxo(it);if(Je!==We){Me("address balance changed:",{scriptPubkey:me,oldBalance:We,newBalance:Je}),Re.emit(cn.ADDRESS_BALANCE_CHANGED,Se.currencyCode,[{scriptPubkey:me,balance:Je}]);const it=yield z.fetchAddress(me);if(it==null)throw new Error("address not found when processing UTXO transactions");yield z.saveAddress(sn(Yr({},it),{balance:Je,used:!0}))}yield R.updateProgressRatio(),yield Bf(R).catch(it=>{throw Me.error(it),it})}),Bm=R=>Br(void 0,null,function*(){const{utxo:O,id:z,address:me,pluginInfo:Me,processor:Re,path:Se,taskCache:ke,requiredCount:_e,pluginState:Te,serverUri:We,log:Je}=R,{rawUtxoCache:it,processorUtxoCache:ct}=ke,dt=Qi(Se,Me.engineInfo.scriptTemplates),pt=Pf(dt);let St,Ut;const Jt=()=>{var ur;const _t={id:z,txid:O.txid,vout:O.vout,value:O.value,scriptPubkey:me.scriptPubkey,script:St,redeemScript:Ut,scriptType:pt,blockHeight:(ur=O.height)!=null?ur:-1,spent:!1};id(ct,Se,me.scriptPubkey,_e,_t)};switch(dt){case Sr.Airbitz:case Sr.Legacy:case Sr.ReplayProtection:Ut=me.redeemScript;{const[ur]=yield Re.fetchTransactions({txId:O.txid});if(ur==null){const _t=Date.now(),Bt=new Vn;return Bt.promise.then(Lt=>{Te.serverScoreUp(We,Date.now()-_t),St=Nc(sn(Yr({},R),{txResponse:Lt})).hex,Jt()}).catch(Lt=>{Je("error in processRawUtxo:",Lt);const Ft=`${O.txid}_${O.vout}`;it[Ft]={blockbookUtxo:O,processing:!1,path:Se,address:me,requiredCount:_e}}),R.serverStates.transactionQueryTask(We,O.txid,Bt)}else St=ur.hex}break;case Sr.WrappedSegwit:if(St=me.scriptPubkey,me.redeemScript==null)throw new Error("Address redeem script not defined, but required for p2sh wrapped segwit utxo processing");Ut=me.redeemScript;break;case Sr.Segwit:St=me.scriptPubkey;break}Jt()}),id=(R,O,z,me,Me)=>{var Re;const Se=(Re=R[z])!=null?Re:{utxos:[],processing:!1,path:O,full:!1};Me!=null&&Se.utxos.push(Me),R[z]=Se,Se.full=Se.utxos.length>=me};function od(R){const{pluginInfo:O,publicKey:z}=R,{engineInfo:me}=O,{name:Me}=O.coinInfo,Re=z.publicKeys,Se={getPubkey(ke){var _e;if(Re[ke.format]==null)throw new Error(`wallet tools: xpub with format ${ke.format} does not exist`);return Be({xpub:(_e=Re[ke.format])!=null?_e:"",coin:Me,type:Oi(ke.format),bip44ChangeIndex:ke.changeIndex,bip44AddressIndex:ke.addressIndex})},getScriptPubkey(ke){const _e=Qi(ke,me.scriptTemplates),Te=Pf(_e);return vt({pubkey:Se.getPubkey(ke),scriptTemplates:me.scriptTemplates,scriptType:Te})},getScriptPubkeyFromWif(ke,_e){const Te=Oi(_e),We=Pf(Te),Je=Zt({wifKey:ke,coin:Me});[Sr.Segwit,Sr.WrappedSegwit].includes(Te)&&!Je.compressed&&(Je.compressed=!0);const it=ir(Je);return vt({pubkey:it,scriptTemplates:me.scriptTemplates,scriptType:We})},getAddress(ke){const _e=Qi(ke,O.engineInfo.scriptTemplates),{scriptPubkey:Te}=Se.getScriptPubkey(ke),We=Rc(_e);return $e({scriptPubkey:Te,addressType:We,coin:Me})},addressToScriptPubkey(ke){return Ue({address:ke,coin:Me})},scriptPubkeyToAddress(ke){const{changePath:_e}=ke,Te=Qi(_e,O.engineInfo.scriptTemplates),We=Rc(Te);return $e({scriptPubkey:ke.scriptPubkey,addressType:We,coin:Me})},getPrivateKey(ke){const{path:_e,xprivKeys:Te}=ke,We=Te[_e.format];if(We==null)throw new Error(`wallet tools: xpriv with format ${_e.format} does not exist`);return Mt({xpriv:We,type:Oi(_e.format),coin:Me,bip44ChangeIndex:_e.changeIndex,bip44AddressIndex:_e.addressIndex})},getPrivateKeyEncodingFromWif(ke){return Zt({wifKey:ke,coin:Me})},getScriptAddress({path:ke,scriptTemplate:_e}){const Te=Se.getPubkey(ke),We=_e(Te),{address:Je,scriptPubkey:it,redeemScript:ct}=Ye({coin:Me,scriptPubkey:We});if(Je==null)throw new Error("Failed to derive address for script");return{address:Je,scriptPubkey:it,redeemScript:ct}},signMessageBase64({path:ke,message:_e,xprivKeys:Te}){const We=Se.getPrivateKey({path:ke,xprivKeys:Te});return vr(_e,We)}};return Se}var ad=er(8287).Buffer,Rm=Object.defineProperty,Cm=Object.defineProperties,Fm=Object.getOwnPropertyDescriptors,sd=Object.getOwnPropertySymbols,Nm=Object.prototype.hasOwnProperty,Lm=Object.prototype.propertyIsEnumerable,fd=(R,O,z)=>O in R?Rm(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,Bi=(R,O)=>{for(var z in O||(O={}))Nm.call(O,z)&&fd(R,z,O[z]);if(sd)for(var z of sd(O))Lm.call(O,z)&&fd(R,z,O[z]);return R},Ri=(R,O)=>Cm(R,Fm(O)),Dr=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});function Dm(R){return Dr(this,null,function*(){const{pluginInfo:O,pluginDisklet:z,options:me,io:Me,pluginState:Re}=R,{walletLocalDisklet:Se,walletLocalEncryptedDisklet:ke,emitter:_e,log:Te}=me,{currencyInfo:We,engineInfo:Je,coinInfo:it}=O,ct=Ql(me.userSettings);Re.updateServers(ct).catch(wt=>{Te.error(wt)});const dt=Pc(it.name,it.coinType),pt=G(dt),St=gh(O)(R.walletInfo),{privateKeyFormat:Ut,publicKey:Jt,walletFormats:ur}=St.keys;if(Je.formats==null||!Je.formats.includes(Ut)){const wt=`Wallet format is not supported: ${Ut}`;throw Te.error(wt),new Error(wt)}const _t=od({pluginInfo:O,publicKey:Jt}),Bt=yield Zd({disklet:z,pluginInfo:O,io:Me,log:R.options.log}),Lt=yield th({disklet:Se,emitter:_e,log:Te}),Ft=yield hh({disklet:Se}),jt=ed(Ri(Bi({},R),{walletTools:_t,walletInfo:St,processor:Ft,pluginState:Re})),It={accelerate(wt){return Dr(this,null,function*(){var Nt;const{canReplaceByFee:Rt=!1}=We;if(!Rt||Ut==="bip32"||Ut==="bip44")return null;const tr=wt.txid,[br]=yield Ft.fetchTransactions({txId:tr});if(br==null||br.blockHeight!==0)return null;const hr=Wi(br.hex),mr=Math.round(parseInt(br.fees)/hr*2),Kt=br.inputs,Pt=yield Promise.all(Kt.map((Wr,$r)=>Dr(this,null,function*(){const hn=yield tv(Ft,br,$r);return hn.spent=!1,hn}))),Ht=Pt.reduce((Wr,$r)=>$r.value>Wr.value?$r:Wr),Qt=[],wr=[];let xr;for(const Wr of br.outputs){const $r=yield Ft.fetchAddress(Wr.scriptPubkey);if($r==null){Qt.push({scriptPubkey:Wr.scriptPubkey,value:parseInt(Wr.amount)});continue}if($r.path==null)throw new Error("Expecting path for address");const hn=Qi($r.path,Je.scriptTemplates),Hn=Rc(hn),{address:Fi}=$e({scriptPubkey:$r.scriptPubkey,addressType:Hn,coin:it.name,redeemScript:$r.redeemScript});wr.push(Fi),$r.path.changeIndex===1?xr=Fi:Qt.push({scriptPubkey:Wr.scriptPubkey,value:parseInt(Wr.amount)})}const Tr=xr==null?yield jt.getFreshAddress({branch:1}):{publicAddress:xr},Or=(Nt=Tr.segwitAddress)!=null?Nt:Tr.publicAddress,Hr=tc(yield Ft.fetchUtxos({utxoIds:[]})).filter(Wr=>Wr.txid!==tr),Rr={utxos:[...Pt,...Hr],forceUseUtxo:[Ht],targets:Qt,memos:wt.memos,feeRate:mr,coin:it.name,currencyCode:We.currencyCode,enableRbf:!0,freshChangeAddress:Or,subtractFee:!1,log:Te,outputSort:"bip69"},jr=(()=>{try{return yr(Rr)}catch(Wr){const $r=Ll(Wr);if(($r==null?void 0:$r.networkFeeShortage)!=null){let hn=parseInt($r.networkFeeShortage);for(const Hn of Qt){if(Hn.value==null)continue;const Fi=Math.min(Hn.value,hn);Hn.value-=Fi,hn-=Fi}return yr(Rr)}throw Wr}})();jr.changeUsed&&wr.push(Or);const Un=jr.inputs.map(Wr=>Wr.scriptPubkey.toString("hex"));let gn="0";for(const Wr of jr.outputs){const $r=Wr.scriptPubkey.toString("hex");(yield Ft.fetchAddress($r))==null?gn=Ge.sub(gn,Wr.value.toString()):Un.push($r)}const Ci=jr.fee.toString();gn=Ge.sub(gn,Ci);const io={unsignedTx:jr.hex,psbt:{base64:jr.psbtBase64,inputs:jr.inputs,outputs:jr.outputs},ourScriptPubkeys:Un,replacedTxid:tr};return Ri(Bi({},wt),{blockHeight:0,currencyCode:We.currencyCode,date:Pa(),feeRateUsed:{satPerVByte:mr},isSend:!0,nativeAmount:gn,networkFee:Ci,otherParams:io,ourReceiveAddresses:wr,parentNetworkFee:void 0,signedTx:"",txid:"",walletId:St.id})})},startEngine(){return Dr(this,null,function*(){_e.emit(cn.WALLET_BALANCE_CHANGED,We.currencyCode,Lt.state.balance),Re.addEngine(jt),yield Bt.start(),yield jt.start()})},killEngine(){return Dr(this,null,function*(){yield jt.stop(),Bt.stop(),Re.removeEngine(jt)})},getBalance(wt){return Lt.state.balance},getBlockHeight(){return Lt.state.lastSeenBlockHeight},addCustomToken(wt){return Dr(this,null,function*(){return yield Promise.resolve(void 0)})},addGapLimitAddresses(wt){return Dr(this,null,function*(){return yield jt.addGapLimitAddresses(wt)})},broadcastTx(wt){return Dr(this,null,function*(){var Nt,Rt;const{otherParams:tr}=wt;if(((Nt=tr==null?void 0:tr.paymentProtocolInfo)==null?void 0:Nt.payment)!=null&&((Rt=tr==null?void 0:tr.paymentProtocolInfo)==null?void 0:Rt.paymentUrl)!=null&&typeof(yield av(Me.fetch,tr.paymentProtocolInfo.paymentUrl,tr.paymentProtocolInfo.payment))>"u")throw new Error(`Error when sending to ${tr.paymentProtocolInfo.paymentUrl}`);if((yield jt.broadcastTx(wt).catch(hr=>{throw String(hr).includes("Error: Blockbook Error: -26: dust")?new Nd:hr}))!==wt.txid)throw new Error("broadcast response txid does not match original");return wt})},changeUserSettings(wt){return Dr(this,null,function*(){yield Re.updateServers(Ql(wt))})},disableTokens(wt){return Dr(this,null,function*(){return yield Promise.resolve(void 0)})},dumpData(){return Dr(this,null,function*(){return{walletId:St.id.split(" - ")[0],walletType:St.type,data:{walletInfo:{pluginType:We.pluginId,privateKeyFormat:Ut,walletFormats:ur},metadataState:Lt.state,processorState:yield Ft.dumpData(),pluginState:Re.dumpData()}}})},enableTokens(wt){return Dr(this,null,function*(){return yield Promise.resolve(void 0)})},getDisplayPrivateSeed(wt){const Nt=pt(wt);return Nt==null?null:Nt.format==="bip32"?ad.from(Nt.seed,"base64").toString("hex"):Nt.seed},getDisplayPublicSeed(){const wt=Jt.publicKeys;return Object.values(wt).filter(Nt=>Nt!=null).join(`
|
|
76
|
-
`)},getFreshAddress(wt){return Dr(this,null,function*(){const{forceIndex:Nt}=wt;return yield jt.getFreshAddress({forceIndex:Nt})})},getNumTransactions(wt){return Ft.numTransactions()},getPaymentProtocolInfo(wt){return Dr(this,null,function*(){return yield iv(wt,We.currencyCode,Me.fetch)})},getTransactions(wt){return Dr(this,null,function*(){const Nt=tc(yield Ft.fetchTransactions({options:wt}));return yield Promise.all(Nt.map(Rt=>Dr(this,null,function*(){return yield oh({walletId:St.id,tx:Rt,walletTools:_t,processor:Ft,pluginInfo:O})})))})},isAddressUsed(wt){return Dr(this,null,function*(){const Nt=_t.addressToScriptPubkey(wt),Rt=yield Ft.fetchAddress(Nt);if(Rt==null)throw new Error("Address not found in wallet");return Rt.used})},makeSpend(wt){return Dr(this,null,function*(){var Nt,Rt,tr,br,hr,mr,Kt;wt=pp(wt,We);const{memos:Pt=[],spendTargets:Ht}=wt,Qt=Fd((Nt=wt.otherParams)!=null?Nt:{}),wr=(Rt=Qt.txOptions)!=null?Rt:{},{outputSort:xr,utxoSourceAddress:Tr,forceChangeAddress:Or}=Qt;let Hr;if(Tr!=null&&(Hr=_t.addressToScriptPubkey(Tr)),wr.CPFP==null&&Ht.length<1)throw new Error("Need to provide Spend Targets");const Zr=Ht.reduce((Xr,{nativeAmount:_n})=>Ge.add(Xr,_n!=null?_n:"0"),"0"),Rr=(tr=wr.utxos)!=null?tr:tc(yield Ft.fetchUtxos({scriptPubkey:Hr,utxoIds:[]}));if(Ge.gt(Zr,`${ev(Rr)}`)||Rr.length===0)throw new Ld({tokenId:null});let jr=[];const Un=[];for(const Xr of Ht){if(Xr.publicAddress==null||Xr.nativeAmount==null)throw new Error("Invalid spend target");if(((br=Xr.otherParams)==null?void 0:br.script)!=null){const{script:_n}=Xr.otherParams;if(_n.type==="replayProtection"){const{publicAddress:oo}=yield jt.deriveScriptAddress(_n.type);jr.push({address:oo,value:Xr.nativeAmount==null?void 0:parseInt(Xr.nativeAmount)})}}else{if(Xr.publicAddress!=null){const _n=_t.addressToScriptPubkey(Xr.publicAddress);(yield Ft.fetchAddress(_n))!=null&&Un.push(Xr.publicAddress)}jr.push({address:Xr.publicAddress,value:Xr.nativeAmount==null?void 0:parseInt(Xr.nativeAmount)})}}if(jr.length+Pt.length<1)throw new Error("Need to provide Spend Targets");const gn=yield jt.getFreshAddress({branch:1}),Ci=(hr=Or!=null?Or:gn.segwitAddress)!=null?hr:gn.publicAddress,io=parseInt(yield Bt.getRate(wt));let Wr;if(wr.CPFP!=null){const[Xr]=yield Ft.fetchTransactions({txId:wr.CPFP});if(Xr==null)throw new Error("transaction not found");const _n=[];for(const oo of Xr.ourOuts){const[Ra]=yield Ft.fetchUtxos({utxoIds:[oo]});Ra!=null&&_n.push(Ra)}Wr=_n.reduce((oo,Ra)=>Ge.gt(oo.value,Ra.value)?oo:Ra),jr=[]}Te.warn(`spend: Using fee rate ${io} sat/B`);const $r=wr.subtractFee!=null?wr.subtractFee:!1,hn=yr({utxos:Rr,forceUseUtxo:Wr!=null?[Wr]:[],targets:jr,memos:Pt,feeRate:io,coin:it.name,currencyCode:We.currencyCode,enableRbf:(Kt=(mr=Qt.enableRbf)!=null?mr:We.canReplaceByFee)!=null?Kt:!1,freshChangeAddress:Ci,subtractFee:$r,log:Te,outputSort:xr});hn.changeUsed&&Un.push(Ci);let Hn="0";const Fi=hn.inputs.map(Xr=>Xr.scriptPubkey.toString("hex"));for(const Xr of hn.outputs){const _n=Xr.scriptPubkey.toString("hex");(yield Ft.fetchAddress(_n))==null?Hn=Ge.sub(Hn,Xr.value.toString()):Fi.push(_n)}const Ed=hn.fee.toString();Hn=Ge.sub(Hn,Ed);const o1={unsignedTx:hn.hex,psbt:{base64:hn.psbtBase64,inputs:hn.inputs,outputs:hn.outputs},edgeSpendInfo:wt,ourScriptPubkeys:Fi};return{blockHeight:0,currencyCode:We.currencyCode,date:Pa(),feeRateUsed:{satPerVByte:io},isSend:!0,memos:Pt,nativeAmount:Hn,networkFee:Ed,otherParams:o1,ourReceiveAddresses:Un,signedTx:"",tokenId:null,txid:"",walletId:St.id}})},resyncBlockchain(){return Dr(this,null,function*(){yield It.killEngine(),yield Ft.clearAll(),yield Re.clearCache(),yield Lt.clear(),yield Bt.clearCache(),yield Re.refreshServers(),yield It.startEngine()})},saveTx(wt){return Dr(this,null,function*(){var Nt,Rt;const tr=(Nt=wt.otherParams)==null?void 0:Nt.replacedTxid;if(tr!=null){const[mr]=yield Ft.fetchTransactions({txId:tr});mr!=null&&(mr.blockHeight=-1,yield Ba({walletId:St.id,tx:mr,pluginInfo:O,emitter:_e,walletTools:_t,processor:Ft}))}const br=mp(wt);yield Ba({walletId:St.id,tx:br,pluginInfo:O,emitter:_e,walletTools:_t,processor:Ft}),yield Ft.saveTransaction({tx:br,scriptPubkeys:(Rt=wt.otherParams)==null?void 0:Rt.ourScriptPubkeys});const hr=yield vv(Je,Ft,br);yield jt.processUtxos(hr)})},signMessage(wt,Nt,Rt){return Dr(this,null,function*(){const tr=Rd(Rt.otherParams),{publicAddress:br}=tr,hr=_t.addressToScriptPubkey(br),mr=yield Ft.fetchAddress(hr);if((mr==null?void 0:mr.path)==null)throw new Error("Missing address to sign with");const Kt=pt(Nt);if(Kt==null)throw new Error("Cannot sign a message for a read-only wallet");const Pt=yield Mh({privateKey:Kt,walletLocalEncryptedDisklet:ke,coin:it.name});return yield _t.signMessageBase64({path:mr==null?void 0:mr.path,message:wt,xprivKeys:Pt})})},signTx(wt,Nt){return Dr(this,null,function*(){var Rt,tr,br;const hr=wt.otherParams;if(hr==null)throw new Error("Invalid transaction data");const{psbt:mr,edgeSpendInfo:Kt}=hr;if(mr==null)throw new Error("Invalid transaction data");const Pt=pt(Nt);if(Pt==null)throw new Error("Cannot sign a transaction for a read-only wallet");const Ht=yield Mh({privateKey:Pt,walletLocalEncryptedDisklet:ke,coin:it.name}),Qt=yield Dr(this,null,function*(){return(Kt==null?void 0:Kt.privateKeys)!=null?Kt.privateKeys.map(Tr=>_t.getPrivateKeyEncodingFromWif(Tr)):yield Promise.all(mr.inputs.map(Tr=>Dr(this,[Tr],function*({hash:Or,index:Hr}){const Zr=ad.from(Or).reverse().toString("hex"),[Rr]=yield Ft.fetchTransactions({txId:Zr});if(Rr==null)throw new Error("Unable to find previous transaction data for input");const jr=Rr.outputs.find(io=>io.n===Hr);if(jr==null)throw new Error("Unable to find prevout in transaction");const{scriptPubkey:Un}=jr,gn=yield Ft.fetchAddress(Un);if(gn==null)throw new Error(`Address for scriptPubkey '${Un}' not found`);if(gn.path==null)throw new Error(`Invalid scriptPubkey ${gn.scriptPubkey}; Missing path`);return{hex:_t.getPrivateKey({path:gn.path,xprivKeys:Ht}),compressed:!0}})))}),wr=yield Pr({coin:it.name,feeInfo:Bt.feeInfo,privateKeyEncodings:Qt,psbtBase64:mr.base64});wt.txid=wr.id,wt.signedTx=wr.hex;const{paymentProtocolInfo:xr}=(br=(tr=(Rt=wt.otherParams)==null?void 0:Rt.edgeSpendInfo)==null?void 0:tr.otherParams)!=null?br:{};if(xr!=null){const Tr=ov(wt.signedTx,wt.currencyCode);wt.otherParams==null&&(wt.otherParams={}),Object.assign(wt.otherParams,{paymentProtocolInfo:Ri(Bi({},xr),{payment:Tr})})}return wt.date=Pa(),wt})},sweepPrivateKeys(wt){return Dr(this,null,function*(){var Nt;let Rt,tr;const br=new Promise((Zr,Rr)=>{Rt=Zr,tr=Rr}),hr=Je.formats;if(hr==null)throw new Error(`Missing formats for wallet type ${We.walletType}`);const mr={id:St.id,type:St.type,keys:{privateKeyFormat:St.keys.privateKeyFormat,walletFormats:hr,publicKey:{publicKeys:{}}}},Kt=(Nt=wt.privateKeys)!=null?Nt:[];if(Kt.length<1)throw new Error("No private keys given");const Pt=(0,ec.cQ)(),Ht=(0,ec.cQ)(),Qt=new Q0,wr={disklet:Pt,emitter:Qt,log:Te},xr=yield th(wr),Tr=yield hh(wr),Or=od({pluginInfo:O,publicKey:mr.keys.publicKey});Qt.on(cn.ADDRESSES_CHECKED,Zr=>Dr(this,null,function*(){if(Zr===1)try{yield Hr.stop();const Rr=yield Tr.fetchUtxos({utxoIds:[]});if(Rr===null||Rr.length<1)throw new Error("Private key has no funds");const jr=yield this.getFreshAddress({tokenId:null}),Un=xr.state.balance,gn={utxos:Rr,subtractFee:!0};wt.spendTargets=[{publicAddress:jr.publicAddress,nativeAmount:Un}],wt.otherParams=Ri(Bi({},wt.otherParams),{txOptions:gn});const Ci=yield this.makeSpend(wt);Rt(Ci)}catch(Rr){tr(Rr)}}));const Hr=ed(Ri(Bi({},R),{options:Ri(Bi({},R.options),{walletLocalDisklet:Pt,walletLocalEncryptedDisklet:Ht,emitter:Qt}),pluginInfo:Ri(Bi({},O),{engineInfo:Ri(Bi({},Je),{gapLimit:0})}),processor:Tr,walletTools:Or,walletInfo:mr}));return yield Hr.loadWifs(Kt),yield Hr.start(),yield br})},otherMethods:{}};return It})}var ud=er(8287).Buffer,Lo=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});function Um(R,O){const{currencyInfo:z,engineInfo:me,coinInfo:Me}=O,Re=Pc(Me.name,Me.coinType),Se=oe(Re),ke=gh(O);return{checkPublicKey(Te){return Lo(this,null,function*(){const We=G(vh)(Te);if(We==null)return!1;const Je=mh(We);return Af(me,Je).every(ct=>We.publicKeys[ct]!=null)})},createPrivateKey(Te,We){return Lo(this,null,function*(){var Je,it,ct,dt,pt;const Ut={imported:!1,seed:te.VF(ud.from(R.random(32))),format:(ct=(it=We==null?void 0:We.format)!=null?it:(Je=me.formats)==null?void 0:Je[0])!=null?ct:"bip44",coinType:(pt=(dt=We==null?void 0:We.coinType)!=null?dt:Me.coinType)!=null?pt:0};return Se(Ut)})},importPrivateKey(Te,We){return Lo(this,null,function*(){var Je,it,ct,dt,pt;if(!te.JB(Te))throw ud.from(Te,"base64").length===32?new Error("Import for Airbitz seeds is unsupported."):new Error("Invalid mnemonic");const Ut={imported:!0,seed:Te,format:(ct=(it=We==null?void 0:We.format)!=null?it:(Je=me.formats)==null?void 0:Je[0])!=null?ct:"bip44",coinType:(pt=(dt=We==null?void 0:We.coinType)!=null?dt:Me.coinType)!=null?pt:0};return Se(Ut)})},derivePublicKey(Te){return Lo(this,null,function*(){return ke(Te).keys.publicKey})},parseUri(Te){return Lo(this,null,function*(){const We=Te.toLocaleLowerCase().startsWith(`${Me.name}://`);We&&(Te=Te.replace("//",""));const Je=kh()(Te,{},!0),it=Je.protocol.replace(":","").toLowerCase();if(it!==""&&it!==z.pluginId&&it!==me.uriPrefix&&it!=="pay")throw new Error("InvalidUriError");const{pathname:ct,query:dt}=Je;if(ct===""&&dt.r==null)throw new Error("InvalidUriError");const pt={};if(ct!==""){const Jt=Qp({pathname:Je.pathname,coin:Me.name});if(Jt==null)throw new Error("InvalidUriError");Object.assign(pt,Jt)}const St={};dt.label!=null&&(St.name=dt.label),dt.message!=null&&(St.notes=dt.message),dt.category!=null&&(St.category=dt.category),dt.r!=null&&(pt.paymentProtocolUrl=dt.r),We&&(St.gateway=!0),Object.assign(pt,{metadata:St});const Ut=z.denominations.find(({name:Jt})=>Jt===z.currencyCode);if(Ut!=null&&dt.amount!=null){const{multiplier:Jt="1"}=Ut,ur=Ge.mul(dt.amount,Jt.toString());pt.currencyCode=z.currencyCode,pt.nativeAmount=Ge.toFixed(ur,0,0)}return pt})},encodeUri(Te,We){return Lo(this,null,function*(){var Je,it;const{publicAddress:ct}=Te;if(ct==="")throw new Error("InvalidPublicAddressError");const dt=[];if(Te.nativeAmount!=null){const St=(Je=Te.currencyCode)!=null?Je:z.currencyCode,Ut=z.denominations.find(({name:ur})=>ur===St);if(Ut==null)throw new Error("InvalidDenominationError");const Jt=Ge.div(Te.nativeAmount,Ut.multiplier,8);dt.push(`amount=${Jt}`)}Te.label!=null&&dt.push(`label=${Te.label}`),Te.message!=null&&dt.push(`message=${Te.message}`);const pt=Te.metadata;return pt!=null&&(pt.name!=null&&dt.push(`label=${pt.name}`),pt.notes!=null&&dt.push(`message=${pt.notes}`)),dt.length>0?Ph.serialize({scheme:(it=me.uriPrefix)!=null?it:z.pluginId,path:ct,query:dt.join("&")}):ct})},getSplittableTypes(Te){var We;const{keys:{format:Je="bip32"}={}}=Te;return((We=me.forks)!=null?We:[]).filter(ct=>rp(ct).includes(Je)).map(ct=>`wallet:${ct}`)}}}const Hm=F({serverUrl:h,serverScore:c,responseTime:c,numResponseTimes:c}),ld=F(Hm),zm=F({customServers:ld,internalServers:ld}),Do=999999999,Lc=500,cd=-100,hd=-100,dd=-10;class Km{constructor(O){const{log:z,onDirtyServer:me=()=>{}}=O;this.log=z,this.scoresLastLoaded=Date.now(),this.lastScoreUpTime=Date.now(),this.onDirtyServer=me}serverScoresLoad(O,z=[]){for(const me of z)if(O[me]===void 0){const Me={serverUrl:me,serverScore:0,responseTime:Do,numResponseTimes:0};O[me]=Me}for(const me in O){const Me=O[me];let Re=!1;for(const ke of z)if(ke===me){Re=!0;break}let Se=Me.serverScore;Re?Se<dd&&(Se=dd):Se>hd&&(Se=hd),this.scoresLastLoaded===0&&(Se=Math.min(Se,Lc-100)),me.startsWith("ws")&&Se>0&&(Se=0,Me.responseTime=Do),Me.serverScore=Se,this.onDirtyServer(me)}}clearServerScoreTimes(){this.scoresLastLoaded=Date.now(),this.lastScoreUpTime=Date.now()}printServers(O){this.log("**** printServers ****");const z=[];for(const me in O)z.push(O[me]);z.sort((me,Me)=>Me.serverScore-me.serverScore);for(const me of z){const Me=me.serverScore.toString(),Re=me.responseTime.toString(),Se=me.numResponseTimes.toString(),ke=me.serverUrl;this.log(`ServerInfo ${Me} ${Re}ms ${Se} ${ke}`)}this.log("**************************")}serverScoreUp(O,z,me,Me=1){const Re=O[z];Re.serverScore+=Me,Re.serverScore>Lc&&(Re.serverScore=Lc),this.lastScoreUpTime=Date.now(),me!==0&&this.setResponseTime(O,z,me),this.log(`${z}: score UP to ${Re.serverScore} ${me}ms`),this.onDirtyServer(z)}serverScoreDown(O,z,me=10){if(Date.now()-this.lastScoreUpTime>6e4){this.log(`${z}: score DOWN cancelled`);return}const Re=O[z];Re.serverScore-=me,Re.serverScore<cd&&(Re.serverScore=cd),Re.numResponseTimes===0&&this.setResponseTime(O,z,9999),this.log(`${z}: score DOWN to ${Re.serverScore}`),this.onDirtyServer(z)}setResponseTime(O,z,me){const Me=O[z];Me.numResponseTimes++;const Re=Me.responseTime;let Se=0;Do===Re?Se=me:Me.numResponseTimes%10===0?Se=(Re+me*4)/5:Se=(Re+me)/2,Me.responseTime=Se,this.onDirtyServer(z)}getServers(O,z,me=[]){if(O==null||Object.keys(O).length===0)return[];let Me=[],Re=[];for(const ct in O){const dt=O[ct];Me.push(dt),dt.responseTime===Do&&dt.serverScore===0&&Re.push(dt)}if(Me.length===0)return[];if(me.length>0){const ct=dt=>{for(const pt of me)if(typeof pt=="string"&&dt.serverUrl.indexOf(pt)===0||pt instanceof RegExp&&pt.test(dt.serverUrl))return!0;return!1};Me=Me.filter(ct),Re=Re.filter(ct)}Me.sort((ct,dt)=>dt.serverScore-ct.serverScore);const Se=Me[0];let ke=0,_e=0;for(let ct=0;ct<Me.length;ct++){const dt=Me[ct];dt.serverScore<Se.serverScore-100||dt.serverScore<5||dt.responseTime>=Do||(ke++,!(ke<z)&&(ke>=Me.length/2||(_e=ct)))}let Te=Me.slice(0,_e);Te.sort((ct,dt)=>ct.responseTime-dt.responseTime),Te=Te.concat(Me.slice(_e));const We=[];let Je=0,it=0;for(const ct of Te)if(Je++,We.push(ct.serverUrl),ct.responseTime===Do&&ct.serverScore===0&&it++,Je>=z||Je>=z/2&&it===0&&Re.length>=z-Je)break;if(it===0){for(const ct of Re)if(We.unshift(ct.serverUrl),Je++,Je>=z)break}return We}}var jm=Object.defineProperty,Wm=Object.defineProperties,Gm=Object.getOwnPropertyDescriptors,pd=Object.getOwnPropertySymbols,Vm=Object.prototype.hasOwnProperty,qm=Object.prototype.propertyIsEnumerable,vd=(R,O,z)=>O in R?jm(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,Xm=(R,O)=>{for(var z in O||(O={}))Vm.call(O,z)&&vd(R,z,O[z]);if(pd)for(var z of pd(O))qm.call(O,z)&&vd(R,z,O[z]);return R},Zm=(R,O)=>Wm(R,Gm(O)),Uo=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});const Dc="https://info1.edge.app/v1/blockbook/",Uc="serverCache.json",Ym=F(re(Z(h),s));function $m(R){const{io:O,defaultSettings:z,currencyCode:me,pluginId:Me,pluginDisklet:Re,log:Se}=R,ke=z.blockbookServers;let _e=[],Te=z.enableCustomServers,We=[];const Je=v(Re);let it={customServers:{},internalServers:{}},ct=!1,dt={};const pt=()=>Uo(this,null,function*(){Ut.printServers(dt),ct&&(yield Je.setJson(Uc,it).catch(_t=>{Se(`${Me} - ${JSON.stringify(_t.toString())}`)}),ct=!1,Ut.scoresLastLoaded=Date.now(),Se(`${Me} - Saved server cache`))}),St=_t=>{ct=!0;for(const Bt of We)if(Bt.processedPercent===1&&Bt.getServerList().includes(_t)){pt().catch(Ft=>{Se(`${Me} - ${JSON.stringify(Ft.toString())}`)});return}},Ut=new Km({log:Se,onDirtyServer:St}),Jt=()=>Uo(this,null,function*(){var _t;Se(`${Me} - GET ${Dc}`);try{const Bt=yield O.fetch(Dc);if(!Bt.ok)throw new Error(`Failed with status ${Bt.status}`);const Lt=yield Bt.json();return(_t=Ym(Lt)[me])!=null?_t:[]}catch(Bt){return Se.warn(`${Me} - GET ${Dc} failed: ${Bt.toString()}`),[]}}),ur=()=>Uo(this,null,function*(){let _t;if(Te)_t=_e;else{const Lt=yield Jt();_t=Lt.length>0?Lt:ke}dt=it[Te?"customServers":"internalServers"],Ut.serverScoresLoad(dt,_t),yield pt();for(const Lt of We)Lt.refillServers()});return{addEngine(_t){We.push(_t)},removeEngine(_t){We=We.filter(Bt=>Bt!==_t)},dumpData(){return{"pluginState.servers_":dt}},load(){return Uo(this,null,function*(){try{it=zm(yield Je.getJson(Uc))}catch(_t){Se(`${Me}: Failed to load server cache: ${JSON.stringify(_t)}`)}return ur().catch(_t=>{Se(`${Me} - ${JSON.stringify(_t.toString())}`)}),this})},serverScoreDown(_t){Ut.serverScoreDown(dt,_t)},serverScoreUp(_t,Bt){Ut.serverScoreUp(dt,_t,Bt)},clearCache(){return Uo(this,null,function*(){Ut.clearServerScoreTimes(),dt={},ct=!0,yield Je.delete(Uc)})},getLocalServers(_t,Bt=[]){return Ut.getServers(dt,_t,Bt)},refreshServers:ur,updateServers(_t){return Uo(this,null,function*(){Te=_t.enableCustomServers,_e=_t.blockbookServers;const Bt=[],Lt=[];for(const Ft of We)Bt.push(Ft),Ft.setServerList([]),Lt.push(Ft.stop());yield Promise.all(Lt),Ut.clearServerScoreTimes(),it=Zm(Xm({},it),{customServers:{}}),ct=!0,yield pt(),yield ur();for(const Ft of Bt)yield Ft.start()})}}}var Jm=Object.defineProperty,Qm=Object.defineProperties,e1=Object.getOwnPropertyDescriptors,md=Object.getOwnPropertySymbols,t1=Object.prototype.hasOwnProperty,r1=Object.prototype.propertyIsEnumerable,gd=(R,O,z)=>O in R?Jm(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,yd=(R,O)=>{for(var z in O||(O={}))t1.call(O,z)&&gd(R,z,O[z]);if(md)for(var z of md(O))r1.call(O,z)&&gd(R,z,O[z]);return R},n1=(R,O)=>Qm(R,e1(O)),bd=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});let wd=!1;function i1(R,O){const{currencyInfo:z}=O,{initOptions:me,io:Me,log:Re,nativeIo:Se,pluginDisklet:ke}=R,_e=Um(Me,O),{defaultSettings:Te,pluginId:We,currencyCode:Je}=z,it=$m({io:Me,currencyCode:Je,pluginId:We,pluginDisklet:ke,log:Re,defaultSettings:Ql(Te)});if(!wd){const{memletConfig:ct}=Se["edge-currency-plugins"];ct!=null&&(wd=!0,b(ct))}return{currencyInfo:z,makeCurrencyEngine(ct,dt){return bd(this,null,function*(){const pt=ep(dt.callbacks),St={walletInfo:ct,pluginInfo:O,pluginDisklet:ke,currencyTools:_e,initOptions:Bd(me),io:Me,options:n1(yd(yd({},R),dt),{emitter:pt}),pluginState:it};return yield Dm(St)})},makeCurrencyTools(){return bd(this,null,function*(){return it.load().catch(ct=>{throw ct}),_e})}}}var xd;const Md={};for(const R of Oo)Md[R.currencyInfo.pluginId]=O=>i1(O,R);typeof window<"u"&&((xd=window.addEdgeCorePlugins)==null||xd.call(window,Md));const fy=null})()})();})();
|
|
74
|
+
${Rr}`),Ht(Zr)}})}if(!Tr){const{nowNodeApiKey:Or}=z,Hr=_e.filter(Zr=>Zr.type==="blockbook-nownode").map(Zr=>Zr.uris).flat(1);if(Hr.length<1){Ht(new Error("No available connections. Check your internet signal."));return}if(Or==null){Ht(new Error("Missing connection key for fallback servers."));return}for(const Zr of Hr)Me.warn("Falling back to NOWNode server broadcast over HTTP:",Zr),me.fetchCors(`${Zr}/api/v2/sendtx/`,{method:"POST",headers:{"api-key":Or},body:Kt.signedTx}).then(Rr=>No(this,null,function*(){if(!Rr.ok)throw new Error(`Failed to broadcast transaction via Blockbook: HTTP ${Rr.status}`);const Wr=yield Rr.json();return qn(Nh)(Wr)})).then(Rr=>{Qt||(Qt=!0,Pt(Rr.result))}).catch(Rr=>{if(++wr===Hr.length){const Wr=Rr!=null?`With error ${Rr.message}`:"";Me.error(`broadcastTx fail: ${JSON.stringify(Kt)}
|
|
75
|
+
${Wr}`),Ht(Rr)}})}})}),watchAddresses:(Kt,Pt,Ht)=>{const Qt=Te[Kt];if(Qt==null)throw new Error(`No blockbook connection with ${Kt}`);const{blockbook:wr}=Qt;for(const Or of Pt)Qt.addresses.add(Or);const xr=Date.now(),Tr=new Vn;Tr.promise.then(Or=>{Se.serverScoreUp(Kt,Date.now()-xr),Ht==null||Ht.resolve(Or)}).catch(()=>{for(const Or of Pt)Qt.addresses.delete(Or);Se.serverScoreDown(Kt),Ht==null||Ht.reject()}),wr.watchAddresses(Array.from(Qt.addresses),Tr)},watchBlocks:Kt=>{const Pt=Te[Kt];if(Pt==null)throw new Error(`No blockbook connection with ${Kt}`);const{blockbook:Ht}=Pt;Pt.blockSubscriptionStatus="subscribing";const Qt=Date.now(),wr=new Vn;wr.promise.then(()=>{Pt.blockSubscriptionStatus="subscribed",Se.serverScoreUp(Kt,Date.now()-Qt)}).catch(()=>{Pt.blockSubscriptionStatus="unsubscribed"}),Ht.watchBlocks(wr)},getBlockHeight:Kt=>Te[Kt].blockHeight,addressQueryTask(Kt,Pt,Ht,Qt){const wr=Te[Kt];if(wr==null)throw new Error(`No blockbook connection with ${Kt}`);return wr.blockbook.addressQueryTask(Pt,{asBlockbookAddress:Re.engineInfo.asBlockbookAddress,lastQueriedBlockHeight:Ht.lastQueriedBlockHeight,page:Ht.page},Qt)},transactionQueryTask(Kt,Pt,Ht){const Qt=Te[Kt];if(Qt==null)throw new Error(`No blockbook connection with ${Kt}`);return Qt.blockbook.transactionQueryTask(Pt,Ht)},transactionSpecialQueryTask(Kt,Pt,Ht){const Qt=Te[Kt];if(Qt==null)throw new Error(`No blockbook connection with ${Kt}`);return Qt.blockbook.transactionSpecialQueryTask(Pt,Ht)},utxoListQueryTask(Kt,Pt,Ht){const Qt=Te[Kt];if(Qt==null)throw new Error(`No blockbook connection with ${Kt}`);return Qt.blockbook.utxoListQueryTask(Pt,{asBlockbookAddress:Re.engineInfo.asBlockbookAddress},Ht)}}}var xm=Object.defineProperty,Mm=Object.defineProperties,Em=Object.getOwnPropertyDescriptors,Jh=Object.getOwnPropertySymbols,Sm=Object.prototype.hasOwnProperty,km=Object.prototype.propertyIsEnumerable,Qh=(R,O,z)=>O in R?xm(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,Yr=(R,O)=>{for(var z in O||(O={}))Sm.call(O,z)&&Qh(R,z,O[z]);if(Jh)for(var z of Jh(O))km.call(O,z)&&Qh(R,z,O[z]);return R},sn=(R,O)=>Mm(R,Em(O)),Br=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});function ed(R){const{initOptions:O,io:z,options:me,pluginState:Me,pluginInfo:Re,processor:Se,walletInfo:ke,walletTools:_e}=R,{emitter:Te,log:We}=me,{walletFormats:Je}=ke.keys,it={blockWatching:!1,addressSubscribeCache:{},addressTransactionCache:{},addressUtxoCache:{},rawUtxoCache:{},processorUtxoCache:{},updateTransactionCache:{},updateTransactionSpecificCache:{}},ct=()=>{it.blockWatching=!1;for(const jt of Object.keys(it.addressSubscribeCache))an(it.addressSubscribeCache,jt);for(const jt of Object.keys(it.addressTransactionCache))an(it.addressTransactionCache,jt);for(const jt of Object.keys(it.addressUtxoCache))an(it.addressUtxoCache,jt);for(const jt of Object.keys(it.rawUtxoCache))an(it.rawUtxoCache,jt);for(const jt of Object.keys(it.processorUtxoCache))an(it.processorUtxoCache,jt);for(const jt of Object.keys(it.updateTransactionCache))an(it.updateTransactionCache,jt);for(const jt of Object.keys(it.updateTransactionSpecificCache))an(it.updateTransactionSpecificCache,jt)},dt=2;let pt=0,St=0;const Ut=()=>Br(this,null,function*(){if(St>=1)return;const jt=Object.keys(it.addressSubscribeCache).length*dt;if(pt=pt+1,jt===0)throw new Error("No addresses to process");const It=pt/jt;(It-St>gv||It===1)&&(We(`processed changed, percent: ${It}, processedCount: ${pt}, totalCount: ${jt}`),St=It,Te.emit(cn.ADDRESSES_CHECKED,It))}),Jt=new eh,ur=wm({engineEmitter:Te,initOptions:O,io:z,log:We,pluginInfo:Re,pluginState:Me,walletInfo:ke}),_t={pluginInfo:Re,walletInfo:ke,walletTools:_e,processor:Se,emitter:Te,taskCache:it,updateProgressRatio:Ut,io:z,log:We,serverStates:ur,pluginState:Me,walletFormats:Je,lock:Jt};ur.setPickNextTaskCB(jt=>Br(this,null,function*(){return yield _m(_t,jt)}));let Bt=!1;const Lt=()=>Br(this,null,function*(){Bt||(Bt=!0,yield Ft(),yield Bf(_t))});Te.on(cn.BLOCK_HEIGHT_CHANGED,(jt,It)=>Br(this,null,function*(){const wt=yield Se.fetchTransactions({blockHeight:0});for(const Nt of wt)Nt!=null&&(it.updateTransactionCache[Nt.txid]={processing:!1})})),Te.on(cn.NEW_ADDRESS_TRANSACTION,(jt,It)=>Br(this,null,function*(){const wt=it.addressSubscribeCache[It.address];if(wt!=null){const{path:Nt}=wt;it.addressUtxoCache[It.address]={processing:!1,path:Nt},td(_t,It.address,Nt,0,it.addressTransactionCache).catch(()=>{throw new Error("failed to add to transaction cache")}),Bf(_t).catch(Rt=>{We(Rt)})}}));const Ft=()=>Br(this,null,function*(){const jt=[];for(const It of Je){const wt=xh(Re.engineInfo,It);for(const Nt of wt){const Rt=new Set,tr={format:It,changeIndex:Nt},yr=Se.numAddressesByFormatPath(tr);for(let hr=0;hr<yr;hr++){const mr=yield Se.fetchAddress({format:It,changeIndex:Nt,addressIndex:hr});if(mr==null)throw new Error(`Missing processor address ${It} ${Nt} ${hr} during initialization`);const{address:Kt}=_e.scriptPubkeyToAddress({changePath:tr,scriptPubkey:mr.scriptPubkey});Rt.add(Kt),mr.balance!=null&&jt.push({scriptPubkey:mr.scriptPubkey,balance:mr.balance})}Fc(_t.taskCache,Rt,{format:It,changeIndex:Nt})}}Te.emit(cn.ADDRESS_BALANCE_CHANGED,Re.currencyInfo.currencyCode,jt)});return{processedPercent:St,start(){return Br(this,null,function*(){pt=0,St=0,yield Lt(),ur.refillServers()})},stop(){return Br(this,null,function*(){ur.stop(),ct(),Bt=!1})},getFreshAddress(jt){return Br(this,arguments,function*({branch:It=0,forceIndex:wt}){const{privateKeyFormat:Nt}=ke.keys;Nt==="bip32"&&(It=0);const{address:Rt,nativeBalance:tr="0",legacyAddress:yr}=yield rd(sn(Yr({},_t),{format:Nt,forceIndex:wt,changeIndex:It})),hr={publicAddress:Rt,nativeBalance:tr,legacyAddress:yr!==Rt?yr:void 0,legacyNativeBalance:yr!==Rt?tr:void 0},mr=Af(Re.engineInfo,ke.keys.privateKeyFormat).filter(Kt=>Kt!==Nt);for(const Kt of mr)if(Kt==="bip84"){const{address:Pt,nativeBalance:Ht="0"}=yield rd(sn(Yr({},_t),{format:Kt,forceIndex:wt,changeIndex:It}));hr.segwitAddress=Pt,hr.segwitNativeBalance=Ht}return hr})},deriveScriptAddress(jt){return Br(this,null,function*(){const{address:It}=yield Tm({walletTools:_t.walletTools,engineInfo:_t.pluginInfo.engineInfo,processor:_t.processor,taskCache:_t.taskCache,format:ke.keys.privateKeyFormat,script:jt});return{publicAddress:It}})},addGapLimitAddresses(jt){return Br(this,null,function*(){const It=jt.map(wt=>Br(this,null,function*(){const Nt=_e.addressToScriptPubkey(wt);yield Se.saveAddress(si({scriptPubkey:Nt,used:!0}))}));yield Promise.all(It),yield Lt()})},broadcastTx(jt){return Br(this,null,function*(){return yield ur.broadcastTx(jt)})},refillServers(){ur.refillServers()},getServerList(){return ur.getServerList()},setServerList(jt){ur.setServerList(jt)},loadWifs(jt){return Br(this,null,function*(){for(const It of jt)for(const wt of Je){const Nt={format:wt,changeIndex:0},Rt=sn(Yr({},Nt),{addressIndex:0}),{scriptPubkey:tr,redeemScript:yr}=_e.getScriptPubkeyFromWif(It,wt),{address:hr}=_e.scriptPubkeyToAddress({changePath:Rt,scriptPubkey:tr});yield Se.saveAddress(si({scriptPubkey:tr,redeemScript:yr,path:Rt})),it.addressSubscribeCache[hr]={path:Nt,processing:!1}}})},processUtxos(jt){return Br(this,null,function*(){var It;const wt=new Map,Nt=new Set;for(const Rt of jt){const tr=(It=wt.get(Rt.scriptPubkey))!=null?It:[];wt.has(Rt.scriptPubkey)||wt.set(Rt.scriptPubkey,tr),tr.push(Rt),Nt.add(Rt.id)}for(const[Rt,tr]of wt.entries()){const mr=[...(yield Se.fetchUtxos({scriptPubkey:Rt})).filter(Kt=>Kt!=null&&!Nt.has(Kt==null?void 0:Kt.id)),...tr];yield nd(sn(Yr({},_t),{scriptPubkey:Rt,utxos:mr}))}})}}}const Bf=R=>Br(void 0,null,function*(){const{pluginInfo:{engineInfo:O},lock:z,processor:me,walletFormats:Me,walletTools:Re}=R;yield z.acquireAsync();try{for(const ke of Me){const _e=xh(O,ke);for(const Te of _e)yield Se({format:ke,changeIndex:Te})}}finally{z.release()}function Se(ke){return Br(this,null,function*(){const _e=new Set,Te=me.numAddressesByFormatPath(ke);let We=yield me.lastUsedIndexByFormatPath(ke),Je=We+O.gapLimit,it=Te;for(;it<=Je;){const ct=sn(Yr({},ke),{addressIndex:it}),{scriptPubkey:dt,redeemScript:pt}=Re.getScriptPubkey(ct),{address:St}=Re.scriptPubkeyToAddress({changePath:ct,scriptPubkey:dt});yield me.saveAddress(si({scriptPubkey:dt,redeemScript:pt,path:ct})),_e.add(St),We=yield me.lastUsedIndexByFormatPath(ke),Je=We+O.gapLimit,it=me.numAddressesByFormatPath(ke)}Fc(R.taskCache,_e,ke)})}}),Fc=(R,O,z)=>{O.forEach(me=>{R.addressSubscribeCache[me]={path:z,processing:!1}})},td=(R,O,z,me,Me)=>Br(void 0,null,function*(){var Re;const{walletTools:Se,processor:ke}=R,_e=Se.addressToScriptPubkey(O);if(me===0){const{lastQueriedBlockHeight:Te=0}=(Re=yield ke.fetchAddress(_e))!=null?Re:{};me=Te}Me[O]={processing:!1,path:z,page:1,blockHeight:me}}),Ba=R=>Br(void 0,null,function*(){const{emitter:O,walletTools:z,processor:me,pluginInfo:Me,tx:Re,walletId:Se}=R;O.emit(cn.TRANSACTIONS_CHANGED,[yield oh({walletId:Se,tx:Re,walletTools:z,processor:me,pluginInfo:Me})])}),_m=(R,O)=>Br(void 0,null,function*(){const{pluginInfo:z,taskCache:me,serverStates:Me}=R,{addressSubscribeCache:Re,addressUtxoCache:Se,rawUtxoCache:ke,processorUtxoCache:_e,addressTransactionCache:Te,updateTransactionCache:We,updateTransactionSpecificCache:Je}=me,it=z.engineInfo.txSpecificHandling!=null,ct=Me.getServerState(O);if(ct!=null){if(ct.blockSubscriptionStatus==="unsubscribed")return Me.watchBlocks(O),!0;if(Object.keys(_e).length>0){for(const[dt,pt]of Object.entries(_e))if(!pt.processing&&pt.full)return pt.processing=!0,yield nd(sn(Yr({},R),{scriptPubkey:dt,utxos:pt.utxos})),an(_e,dt),!0}for(const[dt,pt]of Object.entries(ke)){const St=pt.blockbookUtxo;if(St!=null&&!pt.processing){const Ut=Qi(pt.path,z.engineInfo.scriptTemplates);if((Ut===Sr.Airbitz||Ut===Sr.Legacy||Ut===Sr.ReplayProtection)&&!Me.serverCanGetTx(O,St.txid))return;pt.processing=!0,an(ke,dt);const Jt=yield Bm(sn(Yr(Yr({},R),pt),{address:pt.address,serverUri:O,utxo:St,id:`${St.txid}_${St.vout}`}));return Jt!=null?Jt:!0}}for(const[dt,pt]of Object.entries(Se))if(!pt.processing&&Me.serverCanGetAddress(O,dt)){pt.processing=!0,an(Se,dt);const St=yield Om(sn(Yr(Yr({},R),pt),{address:dt,serverUri:O}));return St.deferred.promise.then(()=>{ct.addresses.add(dt)}).catch(Ut=>{Se[dt]=pt,console.error(Ut),R.log("error in addressUtxoCache:",Ut)}),St}if(Object.keys(Re).length>0){const dt=[],pt=Me.getBlockHeight(O);for(const[St,Ut]of Object.entries(Re)){const Jt=!Me.serverIsAwareOfAddress(O,St);Jt&&dt.push(St),!Ut.processing&&(Jt&&(Se[St]={processing:!1,path:Ut.path}),yield td(R,St,Ut.path,pt,Te),Ut.processing=!0)}if(dt.length>0)return Me.watchAddresses(O,dt),!0}if(Object.keys(Je).length>0){let dt=!1;for(const[pt,St]of Object.entries(Je))if(!St.processing&&Me.serverCanGetTx(O,pt)){dt=!0,St.processing=!0,an(Je,pt);const Ut=Im(sn(Yr({},R),{serverUri:O,txId:pt}));return Ut.deferred.promise.then(()=>{ct.txids.add(pt)}).catch(Jt=>{Je[pt]=St,console.error(Jt),R.log("error in updateTransactionSpecificCache:",Jt)}),Ut}if(dt)return!0}if(Object.keys(We).length>0){let dt=!1;for(const[pt,St]of Object.entries(We))if(!St.processing&&Me.serverCanGetTx(O,pt)){dt=!0,St.processing=!0,an(We,pt);const Ut=Am(sn(Yr({},R),{serverUri:O,needsTxSpecific:it,txId:pt}));return Ut.deferred.promise.then(()=>{ct.txids.add(pt)}).catch(Jt=>{We[pt]=St,console.error(Jt),R.log("error in updateTransactionCache:",Jt)}),Ut}if(dt)return!0}for(const[dt,pt]of Object.entries(Te))if(!pt.processing&&Me.serverCanGetAddress(O,dt)){pt.processing=!0,an(Te,dt);const St=yield Pm(sn(Yr({},R),{addressTransactionState:pt,address:dt,needsTxSpecific:it,serverUri:O}));return St.deferred.promise.then(()=>{ct.addresses.add(dt)}).catch(Ut=>{Te[dt]=pt,console.error(Ut),R.log("error in updateTransactionCache:",Ut)}),St}}}),Im=R=>{const{walletInfo:O,emitter:z,walletTools:me,pluginInfo:Me,processor:Re,serverUri:Se,txId:ke,taskCache:_e}=R,Te=new Vn;return Te.promise.then(We=>Br(void 0,null,function*(){let it=(yield Re.fetchTransactions({txId:ke}))[0];if(it==null)return;Me.engineInfo.txSpecificHandling!=null&&(it=Me.engineInfo.txSpecificHandling(it,We));const ct=yield Re.saveTransaction({tx:it});yield Ba({walletId:O.id,emitter:z,walletTools:me,processor:Re,pluginInfo:Me,tx:ct})})).catch(We=>{console.error(We),R.log("error in updateTransactionsSpecific:",We),_e.updateTransactionSpecificCache[ke]={processing:!1}}),R.serverStates.transactionSpecialQueryTask(Se,ke,Te)},Am=R=>{const{walletInfo:O,emitter:z,walletTools:me,txId:Me,needsTxSpecific:Re,pluginInfo:Se,processor:ke,serverUri:_e,taskCache:Te}=R,We=new Vn;return We.promise.then(Je=>Br(void 0,null,function*(){if(Je.blockHeight<1)return;const it=Nc(sn(Yr({},R),{txResponse:Je}));for(const St of it.inputs)yield ke.removeUtxos([`${St.txId}_${St.outputIndex}`]);const ct=it.outputs.map(St=>`${it.txid}_${St.n}`),dt=yield ke.fetchUtxos({utxoIds:ct});for(const St of dt)St!=null&&(St.blockHeight=it.blockHeight,yield ke.saveUtxo(St));const pt=yield ke.saveTransaction({tx:it});yield Ba({walletId:O.id,emitter:z,walletTools:me,processor:ke,pluginInfo:Se,tx:pt}),Re&&(Te.updateTransactionSpecificCache[Me]={processing:!1})})).catch(Je=>{console.error(Je),R.log("error in updateTransactions:",Je),Te.updateTransactionCache[Me]={processing:!1}}),R.serverStates.transactionQueryTask(_e,Me,We)},Tm=R=>Br(void 0,[R],function*({walletTools:O,engineInfo:z,processor:me,format:Me,taskCache:Re,script:Se}){if(z.scriptTemplates==null)throw new Error(`cannot derive script address ${Se} without defined script template`);const ke=z.scriptTemplates[Se],_e={format:Me,changeIndex:ne(ke),addressIndex:0},{address:Te,scriptPubkey:We,redeemScript:Je}=O.getScriptAddress({path:_e,scriptTemplate:ke});yield me.saveAddress(si({scriptPubkey:We,redeemScript:Je,path:_e}));const it=new Set;return it.add(Te),Fc(Re,it,{format:_e.format,changeIndex:_e.changeIndex}),{address:Te,scriptPubkey:We,redeemScript:Je}}),rd=R=>Br(void 0,null,function*(){var O;const{format:z,changeIndex:me,walletTools:Me,processor:Re,forceIndex:Se}=R,ke=Re.numAddressesByFormatPath({format:z,changeIndex:me}),_e={format:z,changeIndex:me,addressIndex:Math.max(ke-R.pluginInfo.engineInfo.gapLimit,0)};Se!=null&&(_e.addressIndex=Se);const Te=yield Re.fetchAddress(_e),We=(O=Te==null?void 0:Te.balance)!=null?O:"0",{scriptPubkey:Je}=Te!=null?Te:yield Me.getScriptPubkey(_e);if(Je==null)throw new Error("Unknown address path");const it=Me.scriptPubkeyToAddress({changePath:_e,scriptPubkey:Je});return sn(Yr({},it),{nativeBalance:We})}),Pm=R=>Br(void 0,null,function*(){const{walletInfo:O,address:z,addressTransactionState:me,emitter:Me,needsTxSpecific:Re,pluginInfo:Se,processor:ke,walletTools:_e,taskCache:Te,pluginState:We,serverUri:Je}=R,{page:it=1,blockHeight:ct}=me,dt=Te.addressTransactionCache,pt=_e.addressToScriptPubkey(z),St=yield ke.fetchAddress(pt);if(St==null)throw new Error(`could not find address with script pubkey ${pt}`);const Ut=Date.now(),Jt=new Vn;return Jt.promise.then(ur=>Br(void 0,null,function*(){We.serverScoreUp(Je,Date.now()-Ut);const{transactions:_t=[],txs:Bt,unconfirmedTxs:Lt,totalPages:Ft}=ur,jt=Bt>0||Lt>0;!St.used&&jt&&it===1&&(St.used=!0);for(const It of _t){const wt=Nc(sn(Yr({},R),{txResponse:It})),Nt=yield ke.saveTransaction({tx:wt,scriptPubkeys:[pt]});yield Ba({walletId:O.id,emitter:Me,walletTools:_e,processor:ke,pluginInfo:Se,tx:Nt}),Re&&(Te.updateTransactionSpecificCache[wt.txid]={processing:!1})}if(it<Ft){dt[z]=sn(Yr({},me),{processing:!1,page:it+1});return}St.lastQueriedBlockHeight=ct,yield ke.saveAddress(St),yield R.updateProgressRatio(),yield Bf(R)})).catch(ur=>{console.error(ur),dt[z]=me}),R.serverStates.addressQueryTask(Je,z,{lastQueriedBlockHeight:St.lastQueriedBlockHeight,page:it},Jt)}),Nc=R=>{const{txResponse:O,pluginInfo:{coinInfo:z}}=R,me=O.vin.map(Re=>{const Se=G(ke=>wh(ke),"unknown")({address:Re.addresses[0],coin:z.name});return{txId:Re.txid,outputIndex:Re.vout,n:Re.n,scriptPubkey:Se,sequence:Re.sequence,amount:Re.value}}),Me=O.vout.map(Re=>{var Se;const ke=(Se=Re.hex)!=null?Se:G(_e=>wh(_e),"unknown")({address:Re.addresses[0],coin:z.name});return{n:Re.n,scriptPubkey:ke,amount:Re.value}});return{txid:O.txid,hex:O.hex,blockHeight:O.blockHeight>0?O.blockHeight:0,date:O.blockTime,fees:O.fees,inputs:me,outputs:Me,ourIns:[],ourOuts:[],ourAmount:"0"}},Om=R=>Br(void 0,null,function*(){const{address:O,walletTools:z,processor:me,taskCache:Me,path:Re,pluginState:Se,serverUri:ke}=R,{addressUtxoCache:_e,rawUtxoCache:Te,processorUtxoCache:We}=Me,Je=Date.now(),it=new Vn;return it.promise.then(ct=>Br(void 0,null,function*(){Se.serverScoreUp(ke,Date.now()-Je);const dt=z.addressToScriptPubkey(O),pt=yield me.fetchAddress(dt);if(!(pt==null||pt.path==null)){if(ct.length===0){id(We,Re,dt,0);return}for(const St of ct){const Ut=`${St.txid}_${St.vout}`;Te[Ut]={blockbookUtxo:St,processing:!1,requiredCount:ct.length,path:Re,address:sn(Yr({},pt),{path:pt.path})}}}})).catch(()=>{R.processing=!1,_e[O]={processing:R.processing,path:Re}}),R.serverStates.utxoListQueryTask(ke,O,it)}),nd=R=>Br(void 0,null,function*(){const{utxos:O,processor:z,scriptPubkey:me,log:Me,emitter:Re,pluginInfo:{currencyInfo:Se}}=R,ke=Object.fromEntries([...O].map(it=>[it.id,it])),_e=[],Te=yield z.fetchUtxos({scriptPubkey:me});let We="0";for(const it of Te){if(it==null)throw new Error("Unexpected undefined utxo when processing unspent transactions");it.spent||(We=(0,Ge.add)(it.value,We)),ke[it.id]==null&&_e.push(it.id)}yield z.removeUtxos(_e);let Je="0";for(const it of Object.values(ke))it.spent||(Je=(0,Ge.add)(it.value,Je)),yield z.saveUtxo(it);if(Je!==We){Me("address balance changed:",{scriptPubkey:me,oldBalance:We,newBalance:Je}),Re.emit(cn.ADDRESS_BALANCE_CHANGED,Se.currencyCode,[{scriptPubkey:me,balance:Je}]);const it=yield z.fetchAddress(me);if(it==null)throw new Error("address not found when processing UTXO transactions");yield z.saveAddress(sn(Yr({},it),{balance:Je,used:!0}))}yield R.updateProgressRatio(),yield Bf(R).catch(it=>{throw Me.error(it),it})}),Bm=R=>Br(void 0,null,function*(){const{utxo:O,id:z,address:me,pluginInfo:Me,processor:Re,path:Se,taskCache:ke,requiredCount:_e,pluginState:Te,serverUri:We,log:Je}=R,{rawUtxoCache:it,processorUtxoCache:ct}=ke,dt=Qi(Se,Me.engineInfo.scriptTemplates),pt=Pf(dt);let St,Ut;const Jt=()=>{var ur;const _t={id:z,txid:O.txid,vout:O.vout,value:O.value,scriptPubkey:me.scriptPubkey,script:St,redeemScript:Ut,scriptType:pt,blockHeight:(ur=O.height)!=null?ur:-1,spent:!1};id(ct,Se,me.scriptPubkey,_e,_t)};switch(dt){case Sr.Airbitz:case Sr.Legacy:case Sr.ReplayProtection:Ut=me.redeemScript;{const[ur]=yield Re.fetchTransactions({txId:O.txid});if(ur==null){const _t=Date.now(),Bt=new Vn;return Bt.promise.then(Lt=>{Te.serverScoreUp(We,Date.now()-_t),St=Nc(sn(Yr({},R),{txResponse:Lt})).hex,Jt()}).catch(Lt=>{Je("error in processRawUtxo:",Lt);const Ft=`${O.txid}_${O.vout}`;it[Ft]={blockbookUtxo:O,processing:!1,path:Se,address:me,requiredCount:_e}}),R.serverStates.transactionQueryTask(We,O.txid,Bt)}else St=ur.hex}break;case Sr.WrappedSegwit:if(St=me.scriptPubkey,me.redeemScript==null)throw new Error("Address redeem script not defined, but required for p2sh wrapped segwit utxo processing");Ut=me.redeemScript;break;case Sr.Segwit:St=me.scriptPubkey;break}Jt()}),id=(R,O,z,me,Me)=>{var Re;const Se=(Re=R[z])!=null?Re:{utxos:[],processing:!1,path:O,full:!1};Me!=null&&Se.utxos.push(Me),R[z]=Se,Se.full=Se.utxos.length>=me};function od(R){const{pluginInfo:O,publicKey:z}=R,{engineInfo:me}=O,{name:Me}=O.coinInfo,Re=z.publicKeys,Se={getPubkey(ke){var _e;if(Re[ke.format]==null)throw new Error(`wallet tools: xpub with format ${ke.format} does not exist`);return Be({xpub:(_e=Re[ke.format])!=null?_e:"",coin:Me,type:Oi(ke.format),bip44ChangeIndex:ke.changeIndex,bip44AddressIndex:ke.addressIndex})},getScriptPubkey(ke){const _e=Qi(ke,me.scriptTemplates),Te=Pf(_e);return vt({pubkey:Se.getPubkey(ke),scriptTemplates:me.scriptTemplates,scriptType:Te})},getScriptPubkeyFromWif(ke,_e){const Te=Oi(_e),We=Pf(Te),Je=Zt({wifKey:ke,coin:Me});[Sr.Segwit,Sr.WrappedSegwit].includes(Te)&&!Je.compressed&&(Je.compressed=!0);const it=ir(Je);return vt({pubkey:it,scriptTemplates:me.scriptTemplates,scriptType:We})},getAddress(ke){const _e=Qi(ke,O.engineInfo.scriptTemplates),{scriptPubkey:Te}=Se.getScriptPubkey(ke),We=Rc(_e);return $e({scriptPubkey:Te,addressType:We,coin:Me})},addressToScriptPubkey(ke){return Ue({address:ke,coin:Me})},scriptPubkeyToAddress(ke){const{changePath:_e}=ke,Te=Qi(_e,O.engineInfo.scriptTemplates),We=Rc(Te);return $e({scriptPubkey:ke.scriptPubkey,addressType:We,coin:Me})},getPrivateKey(ke){const{path:_e,xprivKeys:Te}=ke,We=Te[_e.format];if(We==null)throw new Error(`wallet tools: xpriv with format ${_e.format} does not exist`);return Mt({xpriv:We,type:Oi(_e.format),coin:Me,bip44ChangeIndex:_e.changeIndex,bip44AddressIndex:_e.addressIndex})},getPrivateKeyEncodingFromWif(ke){return Zt({wifKey:ke,coin:Me})},getScriptAddress({path:ke,scriptTemplate:_e}){const Te=Se.getPubkey(ke),We=_e(Te),{address:Je,scriptPubkey:it,redeemScript:ct}=Ye({coin:Me,scriptPubkey:We});if(Je==null)throw new Error("Failed to derive address for script");return{address:Je,scriptPubkey:it,redeemScript:ct}},signMessageBase64({path:ke,message:_e,xprivKeys:Te}){const We=Se.getPrivateKey({path:ke,xprivKeys:Te});return vr(_e,We)}};return Se}var ad=er(8287).Buffer,Rm=Object.defineProperty,Cm=Object.defineProperties,Fm=Object.getOwnPropertyDescriptors,sd=Object.getOwnPropertySymbols,Nm=Object.prototype.hasOwnProperty,Lm=Object.prototype.propertyIsEnumerable,fd=(R,O,z)=>O in R?Rm(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,Bi=(R,O)=>{for(var z in O||(O={}))Nm.call(O,z)&&fd(R,z,O[z]);if(sd)for(var z of sd(O))Lm.call(O,z)&&fd(R,z,O[z]);return R},Ri=(R,O)=>Cm(R,Fm(O)),Dr=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});function Dm(R){return Dr(this,null,function*(){const{pluginInfo:O,pluginDisklet:z,options:me,io:Me,pluginState:Re}=R,{walletLocalDisklet:Se,walletLocalEncryptedDisklet:ke,emitter:_e,log:Te}=me,{currencyInfo:We,engineInfo:Je,coinInfo:it}=O,ct=Ql(me.userSettings);Re.updateServers(ct).catch(wt=>{Te.error(wt)});const dt=Pc(it.name,it.coinType),pt=G(dt),St=gh(O)(R.walletInfo),{privateKeyFormat:Ut,publicKey:Jt,walletFormats:ur}=St.keys;if(Je.formats==null||!Je.formats.includes(Ut)){const wt=`Wallet format is not supported: ${Ut}`;throw Te.error(wt),new Error(wt)}const _t=od({pluginInfo:O,publicKey:Jt}),Bt=yield Zd({disklet:z,pluginInfo:O,io:Me,log:R.options.log}),Lt=yield th({disklet:Se,emitter:_e,log:Te}),Ft=yield hh({disklet:Se}),jt=ed(Ri(Bi({},R),{walletTools:_t,walletInfo:St,processor:Ft,pluginState:Re})),It={accelerate(wt){return Dr(this,null,function*(){var Nt;const{canReplaceByFee:Rt=!1}=We;if(!Rt||Ut==="bip32"||Ut==="bip44")return null;const tr=wt.txid,[yr]=yield Ft.fetchTransactions({txId:tr});if(yr==null||yr.inputs.every(zr=>zr.sequence>4294967293)||yr.blockHeight!==0)return null;const hr=Wi(yr.hex),mr=Math.round(parseInt(yr.fees)/hr*2),Kt=yr.inputs,Pt=yield Promise.all(Kt.map((zr,$r)=>Dr(this,null,function*(){const hn=yield tv(Ft,yr,$r);return hn.spent=!1,hn}))),Ht=Pt.reduce((zr,$r)=>$r.value>zr.value?$r:zr),Qt=[],wr=[];let xr;for(const zr of yr.outputs){const $r=yield Ft.fetchAddress(zr.scriptPubkey);if($r==null){Qt.push({scriptPubkey:zr.scriptPubkey,value:parseInt(zr.amount)});continue}if($r.path==null)throw new Error("Expecting path for address");const hn=Qi($r.path,Je.scriptTemplates),Hn=Rc(hn),{address:Fi}=$e({scriptPubkey:$r.scriptPubkey,addressType:Hn,coin:it.name,redeemScript:$r.redeemScript});wr.push(Fi),$r.path.changeIndex===1?xr=Fi:Qt.push({scriptPubkey:zr.scriptPubkey,value:parseInt(zr.amount)})}const Tr=xr==null?yield jt.getFreshAddress({branch:1}):{publicAddress:xr},Or=(Nt=Tr.segwitAddress)!=null?Nt:Tr.publicAddress,Hr=tc(yield Ft.fetchUtxos({utxoIds:[]})).filter(zr=>zr.txid!==tr),Rr={utxos:[...Pt,...Hr],forceUseUtxo:[Ht],targets:Qt,memos:wt.memos,feeRate:mr,coin:it.name,currencyCode:We.currencyCode,enableRbf:!0,freshChangeAddress:Or,subtractFee:!1,log:Te,outputSort:"bip69"},Wr=(()=>{try{return br(Rr)}catch(zr){const $r=Ll(zr);if(($r==null?void 0:$r.networkFeeShortage)!=null){let hn=parseInt($r.networkFeeShortage);for(const Hn of Qt){if(Hn.value==null)continue;const Fi=Math.min(Hn.value,hn);Hn.value-=Fi,hn-=Fi}return br(Rr)}throw zr}})();Wr.changeUsed&&wr.push(Or);const Un=Wr.inputs.map(zr=>zr.scriptPubkey.toString("hex"));let gn="0";for(const zr of Wr.outputs){const $r=zr.scriptPubkey.toString("hex");(yield Ft.fetchAddress($r))==null?gn=Ge.sub(gn,zr.value.toString()):Un.push($r)}const Ci=Wr.fee.toString();gn=Ge.sub(gn,Ci);const io={unsignedTx:Wr.hex,psbt:{base64:Wr.psbtBase64,inputs:Wr.inputs,outputs:Wr.outputs},ourScriptPubkeys:Un,replacedTxid:tr};return Ri(Bi({},wt),{blockHeight:0,currencyCode:We.currencyCode,date:Pa(),feeRateUsed:{satPerVByte:mr},isSend:!0,nativeAmount:gn,networkFee:Ci,otherParams:io,ourReceiveAddresses:wr,parentNetworkFee:void 0,signedTx:"",txid:"",walletId:St.id})})},startEngine(){return Dr(this,null,function*(){_e.emit(cn.WALLET_BALANCE_CHANGED,We.currencyCode,Lt.state.balance),Re.addEngine(jt),yield Bt.start(),yield jt.start()})},killEngine(){return Dr(this,null,function*(){yield jt.stop(),Bt.stop(),Re.removeEngine(jt)})},getBalance(wt){return Lt.state.balance},getBlockHeight(){return Lt.state.lastSeenBlockHeight},addCustomToken(wt){return Dr(this,null,function*(){return yield Promise.resolve(void 0)})},addGapLimitAddresses(wt){return Dr(this,null,function*(){return yield jt.addGapLimitAddresses(wt)})},broadcastTx(wt){return Dr(this,null,function*(){var Nt,Rt;const{otherParams:tr}=wt;if(((Nt=tr==null?void 0:tr.paymentProtocolInfo)==null?void 0:Nt.payment)!=null&&((Rt=tr==null?void 0:tr.paymentProtocolInfo)==null?void 0:Rt.paymentUrl)!=null&&typeof(yield av(Me.fetch,tr.paymentProtocolInfo.paymentUrl,tr.paymentProtocolInfo.payment))>"u")throw new Error(`Error when sending to ${tr.paymentProtocolInfo.paymentUrl}`);if((yield jt.broadcastTx(wt).catch(hr=>{throw String(hr).includes("Error: Blockbook Error: -26: dust")?new Nd:hr}))!==wt.txid)throw new Error("broadcast response txid does not match original");return wt})},changeUserSettings(wt){return Dr(this,null,function*(){yield Re.updateServers(Ql(wt))})},disableTokens(wt){return Dr(this,null,function*(){return yield Promise.resolve(void 0)})},dumpData(){return Dr(this,null,function*(){return{walletId:St.id.split(" - ")[0],walletType:St.type,data:{walletInfo:{pluginType:We.pluginId,privateKeyFormat:Ut,walletFormats:ur},metadataState:Lt.state,processorState:yield Ft.dumpData(),pluginState:Re.dumpData()}}})},enableTokens(wt){return Dr(this,null,function*(){return yield Promise.resolve(void 0)})},getDisplayPrivateSeed(wt){const Nt=pt(wt);return Nt==null?null:Nt.format==="bip32"?ad.from(Nt.seed,"base64").toString("hex"):Nt.seed},getDisplayPublicSeed(){const wt=Jt.publicKeys;return Object.values(wt).filter(Nt=>Nt!=null).join(`
|
|
76
|
+
`)},getFreshAddress(wt){return Dr(this,null,function*(){const{forceIndex:Nt}=wt;return yield jt.getFreshAddress({forceIndex:Nt})})},getNumTransactions(wt){return Ft.numTransactions()},getPaymentProtocolInfo(wt){return Dr(this,null,function*(){return yield iv(wt,We.currencyCode,Me.fetch)})},getTransactions(wt){return Dr(this,null,function*(){const Nt=tc(yield Ft.fetchTransactions({options:wt}));return yield Promise.all(Nt.map(Rt=>Dr(this,null,function*(){return yield oh({walletId:St.id,tx:Rt,walletTools:_t,processor:Ft,pluginInfo:O})})))})},isAddressUsed(wt){return Dr(this,null,function*(){const Nt=_t.addressToScriptPubkey(wt),Rt=yield Ft.fetchAddress(Nt);if(Rt==null)throw new Error("Address not found in wallet");return Rt.used})},makeSpend(wt){return Dr(this,null,function*(){var Nt,Rt,tr,yr,hr,mr,Kt;wt=pp(wt,We);const{memos:Pt=[],spendTargets:Ht}=wt,Qt=Fd((Nt=wt.otherParams)!=null?Nt:{}),wr=(Rt=Qt.txOptions)!=null?Rt:{},{outputSort:xr,utxoSourceAddress:Tr,forceChangeAddress:Or}=Qt;let Hr;if(Tr!=null&&(Hr=_t.addressToScriptPubkey(Tr)),wr.CPFP==null&&Ht.length<1)throw new Error("Need to provide Spend Targets");const Zr=Ht.reduce((Xr,{nativeAmount:_n})=>Ge.add(Xr,_n!=null?_n:"0"),"0"),Rr=(tr=wr.utxos)!=null?tr:tc(yield Ft.fetchUtxos({scriptPubkey:Hr,utxoIds:[]}));if(Ge.gt(Zr,`${ev(Rr)}`)||Rr.length===0)throw new Ld({tokenId:null});let Wr=[];const Un=[];for(const Xr of Ht){if(Xr.publicAddress==null||Xr.nativeAmount==null)throw new Error("Invalid spend target");if(((yr=Xr.otherParams)==null?void 0:yr.script)!=null){const{script:_n}=Xr.otherParams;if(_n.type==="replayProtection"){const{publicAddress:oo}=yield jt.deriveScriptAddress(_n.type);Wr.push({address:oo,value:Xr.nativeAmount==null?void 0:parseInt(Xr.nativeAmount)})}}else{if(Xr.publicAddress!=null){const _n=_t.addressToScriptPubkey(Xr.publicAddress);(yield Ft.fetchAddress(_n))!=null&&Un.push(Xr.publicAddress)}Wr.push({address:Xr.publicAddress,value:Xr.nativeAmount==null?void 0:parseInt(Xr.nativeAmount)})}}if(Wr.length+Pt.length<1)throw new Error("Need to provide Spend Targets");const gn=yield jt.getFreshAddress({branch:1}),Ci=(hr=Or!=null?Or:gn.segwitAddress)!=null?hr:gn.publicAddress,io=parseInt(yield Bt.getRate(wt));let zr;if(wr.CPFP!=null){const[Xr]=yield Ft.fetchTransactions({txId:wr.CPFP});if(Xr==null)throw new Error("transaction not found");const _n=[];for(const oo of Xr.ourOuts){const[Ra]=yield Ft.fetchUtxos({utxoIds:[oo]});Ra!=null&&_n.push(Ra)}zr=_n.reduce((oo,Ra)=>Ge.gt(oo.value,Ra.value)?oo:Ra),Wr=[]}Te.warn(`spend: Using fee rate ${io} sat/B`);const $r=wr.subtractFee!=null?wr.subtractFee:!1,hn=br({utxos:Rr,forceUseUtxo:zr!=null?[zr]:[],targets:Wr,memos:Pt,feeRate:io,coin:it.name,currencyCode:We.currencyCode,enableRbf:(Kt=(mr=Qt.enableRbf)!=null?mr:We.canReplaceByFee)!=null?Kt:!1,freshChangeAddress:Ci,subtractFee:$r,log:Te,outputSort:xr});hn.changeUsed&&Un.push(Ci);let Hn="0";const Fi=hn.inputs.map(Xr=>Xr.scriptPubkey.toString("hex"));for(const Xr of hn.outputs){const _n=Xr.scriptPubkey.toString("hex");(yield Ft.fetchAddress(_n))==null?Hn=Ge.sub(Hn,Xr.value.toString()):Fi.push(_n)}const Ed=hn.fee.toString();Hn=Ge.sub(Hn,Ed);const o1={unsignedTx:hn.hex,psbt:{base64:hn.psbtBase64,inputs:hn.inputs,outputs:hn.outputs},edgeSpendInfo:wt,ourScriptPubkeys:Fi};return{blockHeight:0,currencyCode:We.currencyCode,date:Pa(),feeRateUsed:{satPerVByte:io},isSend:!0,memos:Pt,nativeAmount:Hn,networkFee:Ed,otherParams:o1,ourReceiveAddresses:Un,signedTx:"",tokenId:null,txid:"",walletId:St.id}})},resyncBlockchain(){return Dr(this,null,function*(){yield It.killEngine(),yield Ft.clearAll(),yield Re.clearCache(),yield Lt.clear(),yield Bt.clearCache(),yield Re.refreshServers(),yield It.startEngine()})},saveTx(wt){return Dr(this,null,function*(){var Nt,Rt;const tr=(Nt=wt.otherParams)==null?void 0:Nt.replacedTxid;if(tr!=null){const[mr]=yield Ft.fetchTransactions({txId:tr});mr!=null&&(mr.blockHeight=-1,yield Ba({walletId:St.id,tx:mr,pluginInfo:O,emitter:_e,walletTools:_t,processor:Ft}))}const yr=mp(wt);yield Ba({walletId:St.id,tx:yr,pluginInfo:O,emitter:_e,walletTools:_t,processor:Ft}),yield Ft.saveTransaction({tx:yr,scriptPubkeys:(Rt=wt.otherParams)==null?void 0:Rt.ourScriptPubkeys});const hr=yield vv(Je,Ft,yr);yield jt.processUtxos(hr)})},signMessage(wt,Nt,Rt){return Dr(this,null,function*(){const tr=Rd(Rt.otherParams),{publicAddress:yr}=tr,hr=_t.addressToScriptPubkey(yr),mr=yield Ft.fetchAddress(hr);if((mr==null?void 0:mr.path)==null)throw new Error("Missing address to sign with");const Kt=pt(Nt);if(Kt==null)throw new Error("Cannot sign a message for a read-only wallet");const Pt=yield Mh({privateKey:Kt,walletLocalEncryptedDisklet:ke,coin:it.name});return yield _t.signMessageBase64({path:mr==null?void 0:mr.path,message:wt,xprivKeys:Pt})})},signTx(wt,Nt){return Dr(this,null,function*(){var Rt,tr,yr;const hr=wt.otherParams;if(hr==null)throw new Error("Invalid transaction data");const{psbt:mr,edgeSpendInfo:Kt}=hr;if(mr==null)throw new Error("Invalid transaction data");const Pt=pt(Nt);if(Pt==null)throw new Error("Cannot sign a transaction for a read-only wallet");const Ht=yield Mh({privateKey:Pt,walletLocalEncryptedDisklet:ke,coin:it.name}),Qt=yield Dr(this,null,function*(){return(Kt==null?void 0:Kt.privateKeys)!=null?Kt.privateKeys.map(Tr=>_t.getPrivateKeyEncodingFromWif(Tr)):yield Promise.all(mr.inputs.map(Tr=>Dr(this,[Tr],function*({hash:Or,index:Hr}){const Zr=ad.from(Or).reverse().toString("hex"),[Rr]=yield Ft.fetchTransactions({txId:Zr});if(Rr==null)throw new Error("Unable to find previous transaction data for input");const Wr=Rr.outputs.find(io=>io.n===Hr);if(Wr==null)throw new Error("Unable to find prevout in transaction");const{scriptPubkey:Un}=Wr,gn=yield Ft.fetchAddress(Un);if(gn==null)throw new Error(`Address for scriptPubkey '${Un}' not found`);if(gn.path==null)throw new Error(`Invalid scriptPubkey ${gn.scriptPubkey}; Missing path`);return{hex:_t.getPrivateKey({path:gn.path,xprivKeys:Ht}),compressed:!0}})))}),wr=yield Pr({coin:it.name,feeInfo:Bt.feeInfo,privateKeyEncodings:Qt,psbtBase64:mr.base64});wt.txid=wr.id,wt.signedTx=wr.hex;const{paymentProtocolInfo:xr}=(yr=(tr=(Rt=wt.otherParams)==null?void 0:Rt.edgeSpendInfo)==null?void 0:tr.otherParams)!=null?yr:{};if(xr!=null){const Tr=ov(wt.signedTx,wt.currencyCode);wt.otherParams==null&&(wt.otherParams={}),Object.assign(wt.otherParams,{paymentProtocolInfo:Ri(Bi({},xr),{payment:Tr})})}return wt.date=Pa(),wt})},sweepPrivateKeys(wt){return Dr(this,null,function*(){var Nt;let Rt,tr;const yr=new Promise((Zr,Rr)=>{Rt=Zr,tr=Rr}),hr=Je.formats;if(hr==null)throw new Error(`Missing formats for wallet type ${We.walletType}`);const mr={id:St.id,type:St.type,keys:{privateKeyFormat:St.keys.privateKeyFormat,walletFormats:hr,publicKey:{publicKeys:{}}}},Kt=(Nt=wt.privateKeys)!=null?Nt:[];if(Kt.length<1)throw new Error("No private keys given");const Pt=(0,ec.cQ)(),Ht=(0,ec.cQ)(),Qt=new Q0,wr={disklet:Pt,emitter:Qt,log:Te},xr=yield th(wr),Tr=yield hh(wr),Or=od({pluginInfo:O,publicKey:mr.keys.publicKey});Qt.on(cn.ADDRESSES_CHECKED,Zr=>Dr(this,null,function*(){if(Zr===1)try{yield Hr.stop();const Rr=yield Tr.fetchUtxos({utxoIds:[]});if(Rr===null||Rr.length<1)throw new Error("Private key has no funds");const Wr=yield this.getFreshAddress({tokenId:null}),Un=xr.state.balance,gn={utxos:Rr,subtractFee:!0};wt.spendTargets=[{publicAddress:Wr.publicAddress,nativeAmount:Un}],wt.otherParams=Ri(Bi({},wt.otherParams),{txOptions:gn});const Ci=yield this.makeSpend(wt);Rt(Ci)}catch(Rr){tr(Rr)}}));const Hr=ed(Ri(Bi({},R),{options:Ri(Bi({},R.options),{walletLocalDisklet:Pt,walletLocalEncryptedDisklet:Ht,emitter:Qt}),pluginInfo:Ri(Bi({},O),{engineInfo:Ri(Bi({},Je),{gapLimit:0})}),processor:Tr,walletTools:Or,walletInfo:mr}));return yield Hr.loadWifs(Kt),yield Hr.start(),yield yr})},otherMethods:{}};return It})}var ud=er(8287).Buffer,Lo=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});function Um(R,O){const{currencyInfo:z,engineInfo:me,coinInfo:Me}=O,Re=Pc(Me.name,Me.coinType),Se=oe(Re),ke=gh(O);return{checkPublicKey(Te){return Lo(this,null,function*(){const We=G(vh)(Te);if(We==null)return!1;const Je=mh(We);return Af(me,Je).every(ct=>We.publicKeys[ct]!=null)})},createPrivateKey(Te,We){return Lo(this,null,function*(){var Je,it,ct,dt,pt;const Ut={imported:!1,seed:te.VF(ud.from(R.random(32))),format:(ct=(it=We==null?void 0:We.format)!=null?it:(Je=me.formats)==null?void 0:Je[0])!=null?ct:"bip44",coinType:(pt=(dt=We==null?void 0:We.coinType)!=null?dt:Me.coinType)!=null?pt:0};return Se(Ut)})},importPrivateKey(Te,We){return Lo(this,null,function*(){var Je,it,ct,dt,pt;if(!te.JB(Te))throw ud.from(Te,"base64").length===32?new Error("Import for Airbitz seeds is unsupported."):new Error("Invalid mnemonic");const Ut={imported:!0,seed:Te,format:(ct=(it=We==null?void 0:We.format)!=null?it:(Je=me.formats)==null?void 0:Je[0])!=null?ct:"bip44",coinType:(pt=(dt=We==null?void 0:We.coinType)!=null?dt:Me.coinType)!=null?pt:0};return Se(Ut)})},derivePublicKey(Te){return Lo(this,null,function*(){return ke(Te).keys.publicKey})},parseUri(Te){return Lo(this,null,function*(){const We=Te.toLocaleLowerCase().startsWith(`${Me.name}://`);We&&(Te=Te.replace("//",""));const Je=kh()(Te,{},!0),it=Je.protocol.replace(":","").toLowerCase();if(it!==""&&it!==z.pluginId&&it!==me.uriPrefix&&it!=="pay")throw new Error("InvalidUriError");const{pathname:ct,query:dt}=Je;if(ct===""&&dt.r==null)throw new Error("InvalidUriError");const pt={};if(ct!==""){const Jt=Qp({pathname:Je.pathname,coin:Me.name});if(Jt==null)throw new Error("InvalidUriError");Object.assign(pt,Jt)}const St={};dt.label!=null&&(St.name=dt.label),dt.message!=null&&(St.notes=dt.message),dt.category!=null&&(St.category=dt.category),dt.r!=null&&(pt.paymentProtocolUrl=dt.r),We&&(St.gateway=!0),Object.assign(pt,{metadata:St});const Ut=z.denominations.find(({name:Jt})=>Jt===z.currencyCode);if(Ut!=null&&dt.amount!=null){const{multiplier:Jt="1"}=Ut,ur=Ge.mul(dt.amount,Jt.toString());pt.currencyCode=z.currencyCode,pt.nativeAmount=Ge.toFixed(ur,0,0)}return pt})},encodeUri(Te,We){return Lo(this,null,function*(){var Je,it;const{publicAddress:ct}=Te;if(ct==="")throw new Error("InvalidPublicAddressError");const dt=[];if(Te.nativeAmount!=null){const St=(Je=Te.currencyCode)!=null?Je:z.currencyCode,Ut=z.denominations.find(({name:ur})=>ur===St);if(Ut==null)throw new Error("InvalidDenominationError");const Jt=Ge.div(Te.nativeAmount,Ut.multiplier,8);dt.push(`amount=${Jt}`)}Te.label!=null&&dt.push(`label=${Te.label}`),Te.message!=null&&dt.push(`message=${Te.message}`);const pt=Te.metadata;return pt!=null&&(pt.name!=null&&dt.push(`label=${pt.name}`),pt.notes!=null&&dt.push(`message=${pt.notes}`)),dt.length>0?Ph.serialize({scheme:(it=me.uriPrefix)!=null?it:z.pluginId,path:ct,query:dt.join("&")}):ct})},getSplittableTypes(Te){var We;const{keys:{format:Je="bip32"}={}}=Te;return((We=me.forks)!=null?We:[]).filter(ct=>rp(ct).includes(Je)).map(ct=>`wallet:${ct}`)}}}const Hm=F({serverUrl:h,serverScore:c,responseTime:c,numResponseTimes:c}),ld=F(Hm),zm=F({customServers:ld,internalServers:ld}),Do=999999999,Lc=500,cd=-100,hd=-100,dd=-10;class Km{constructor(O){const{log:z,onDirtyServer:me=()=>{}}=O;this.log=z,this.scoresLastLoaded=Date.now(),this.lastScoreUpTime=Date.now(),this.onDirtyServer=me}serverScoresLoad(O,z=[]){for(const me of z)if(O[me]===void 0){const Me={serverUrl:me,serverScore:0,responseTime:Do,numResponseTimes:0};O[me]=Me}for(const me in O){const Me=O[me];let Re=!1;for(const ke of z)if(ke===me){Re=!0;break}let Se=Me.serverScore;Re?Se<dd&&(Se=dd):Se>hd&&(Se=hd),this.scoresLastLoaded===0&&(Se=Math.min(Se,Lc-100)),me.startsWith("ws")&&Se>0&&(Se=0,Me.responseTime=Do),Me.serverScore=Se,this.onDirtyServer(me)}}clearServerScoreTimes(){this.scoresLastLoaded=Date.now(),this.lastScoreUpTime=Date.now()}printServers(O){this.log("**** printServers ****");const z=[];for(const me in O)z.push(O[me]);z.sort((me,Me)=>Me.serverScore-me.serverScore);for(const me of z){const Me=me.serverScore.toString(),Re=me.responseTime.toString(),Se=me.numResponseTimes.toString(),ke=me.serverUrl;this.log(`ServerInfo ${Me} ${Re}ms ${Se} ${ke}`)}this.log("**************************")}serverScoreUp(O,z,me,Me=1){const Re=O[z];Re.serverScore+=Me,Re.serverScore>Lc&&(Re.serverScore=Lc),this.lastScoreUpTime=Date.now(),me!==0&&this.setResponseTime(O,z,me),this.log(`${z}: score UP to ${Re.serverScore} ${me}ms`),this.onDirtyServer(z)}serverScoreDown(O,z,me=10){if(Date.now()-this.lastScoreUpTime>6e4){this.log(`${z}: score DOWN cancelled`);return}const Re=O[z];Re.serverScore-=me,Re.serverScore<cd&&(Re.serverScore=cd),Re.numResponseTimes===0&&this.setResponseTime(O,z,9999),this.log(`${z}: score DOWN to ${Re.serverScore}`),this.onDirtyServer(z)}setResponseTime(O,z,me){const Me=O[z];Me.numResponseTimes++;const Re=Me.responseTime;let Se=0;Do===Re?Se=me:Me.numResponseTimes%10===0?Se=(Re+me*4)/5:Se=(Re+me)/2,Me.responseTime=Se,this.onDirtyServer(z)}getServers(O,z,me=[]){if(O==null||Object.keys(O).length===0)return[];let Me=[],Re=[];for(const ct in O){const dt=O[ct];Me.push(dt),dt.responseTime===Do&&dt.serverScore===0&&Re.push(dt)}if(Me.length===0)return[];if(me.length>0){const ct=dt=>{for(const pt of me)if(typeof pt=="string"&&dt.serverUrl.indexOf(pt)===0||pt instanceof RegExp&&pt.test(dt.serverUrl))return!0;return!1};Me=Me.filter(ct),Re=Re.filter(ct)}Me.sort((ct,dt)=>dt.serverScore-ct.serverScore);const Se=Me[0];let ke=0,_e=0;for(let ct=0;ct<Me.length;ct++){const dt=Me[ct];dt.serverScore<Se.serverScore-100||dt.serverScore<5||dt.responseTime>=Do||(ke++,!(ke<z)&&(ke>=Me.length/2||(_e=ct)))}let Te=Me.slice(0,_e);Te.sort((ct,dt)=>ct.responseTime-dt.responseTime),Te=Te.concat(Me.slice(_e));const We=[];let Je=0,it=0;for(const ct of Te)if(Je++,We.push(ct.serverUrl),ct.responseTime===Do&&ct.serverScore===0&&it++,Je>=z||Je>=z/2&&it===0&&Re.length>=z-Je)break;if(it===0){for(const ct of Re)if(We.unshift(ct.serverUrl),Je++,Je>=z)break}return We}}var jm=Object.defineProperty,Wm=Object.defineProperties,Gm=Object.getOwnPropertyDescriptors,pd=Object.getOwnPropertySymbols,Vm=Object.prototype.hasOwnProperty,qm=Object.prototype.propertyIsEnumerable,vd=(R,O,z)=>O in R?jm(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,Xm=(R,O)=>{for(var z in O||(O={}))Vm.call(O,z)&&vd(R,z,O[z]);if(pd)for(var z of pd(O))qm.call(O,z)&&vd(R,z,O[z]);return R},Zm=(R,O)=>Wm(R,Gm(O)),Uo=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});const Dc="https://info1.edge.app/v1/blockbook/",Uc="serverCache.json",Ym=F(re(Z(h),s));function $m(R){const{io:O,defaultSettings:z,currencyCode:me,pluginId:Me,pluginDisklet:Re,log:Se}=R,ke=z.blockbookServers;let _e=[],Te=z.enableCustomServers,We=[];const Je=v(Re);let it={customServers:{},internalServers:{}},ct=!1,dt={};const pt=()=>Uo(this,null,function*(){Ut.printServers(dt),ct&&(yield Je.setJson(Uc,it).catch(_t=>{Se(`${Me} - ${JSON.stringify(_t.toString())}`)}),ct=!1,Ut.scoresLastLoaded=Date.now(),Se(`${Me} - Saved server cache`))}),St=_t=>{ct=!0;for(const Bt of We)if(Bt.processedPercent===1&&Bt.getServerList().includes(_t)){pt().catch(Ft=>{Se(`${Me} - ${JSON.stringify(Ft.toString())}`)});return}},Ut=new Km({log:Se,onDirtyServer:St}),Jt=()=>Uo(this,null,function*(){var _t;Se(`${Me} - GET ${Dc}`);try{const Bt=yield O.fetch(Dc);if(!Bt.ok)throw new Error(`Failed with status ${Bt.status}`);const Lt=yield Bt.json();return(_t=Ym(Lt)[me])!=null?_t:[]}catch(Bt){return Se.warn(`${Me} - GET ${Dc} failed: ${Bt.toString()}`),[]}}),ur=()=>Uo(this,null,function*(){let _t;if(Te)_t=_e;else{const Lt=yield Jt();_t=Lt.length>0?Lt:ke}dt=it[Te?"customServers":"internalServers"],Ut.serverScoresLoad(dt,_t),yield pt();for(const Lt of We)Lt.refillServers()});return{addEngine(_t){We.push(_t)},removeEngine(_t){We=We.filter(Bt=>Bt!==_t)},dumpData(){return{"pluginState.servers_":dt}},load(){return Uo(this,null,function*(){try{it=zm(yield Je.getJson(Uc))}catch(_t){Se(`${Me}: Failed to load server cache: ${JSON.stringify(_t)}`)}return ur().catch(_t=>{Se(`${Me} - ${JSON.stringify(_t.toString())}`)}),this})},serverScoreDown(_t){Ut.serverScoreDown(dt,_t)},serverScoreUp(_t,Bt){Ut.serverScoreUp(dt,_t,Bt)},clearCache(){return Uo(this,null,function*(){Ut.clearServerScoreTimes(),dt={},ct=!0,yield Je.delete(Uc)})},getLocalServers(_t,Bt=[]){return Ut.getServers(dt,_t,Bt)},refreshServers:ur,updateServers(_t){return Uo(this,null,function*(){Te=_t.enableCustomServers,_e=_t.blockbookServers;const Bt=[],Lt=[];for(const Ft of We)Bt.push(Ft),Ft.setServerList([]),Lt.push(Ft.stop());yield Promise.all(Lt),Ut.clearServerScoreTimes(),it=Zm(Xm({},it),{customServers:{}}),ct=!0,yield pt(),yield ur();for(const Ft of Bt)yield Ft.start()})}}}var Jm=Object.defineProperty,Qm=Object.defineProperties,e1=Object.getOwnPropertyDescriptors,md=Object.getOwnPropertySymbols,t1=Object.prototype.hasOwnProperty,r1=Object.prototype.propertyIsEnumerable,gd=(R,O,z)=>O in R?Jm(R,O,{enumerable:!0,configurable:!0,writable:!0,value:z}):R[O]=z,yd=(R,O)=>{for(var z in O||(O={}))t1.call(O,z)&&gd(R,z,O[z]);if(md)for(var z of md(O))r1.call(O,z)&&gd(R,z,O[z]);return R},n1=(R,O)=>Qm(R,e1(O)),bd=(R,O,z)=>new Promise((me,Me)=>{var Re=_e=>{try{ke(z.next(_e))}catch(Te){Me(Te)}},Se=_e=>{try{ke(z.throw(_e))}catch(Te){Me(Te)}},ke=_e=>_e.done?me(_e.value):Promise.resolve(_e.value).then(Re,Se);ke((z=z.apply(R,O)).next())});let wd=!1;function i1(R,O){const{currencyInfo:z}=O,{initOptions:me,io:Me,log:Re,nativeIo:Se,pluginDisklet:ke}=R,_e=Um(Me,O),{defaultSettings:Te,pluginId:We,currencyCode:Je}=z,it=$m({io:Me,currencyCode:Je,pluginId:We,pluginDisklet:ke,log:Re,defaultSettings:Ql(Te)});if(!wd){const{memletConfig:ct}=Se["edge-currency-plugins"];ct!=null&&(wd=!0,b(ct))}return{currencyInfo:z,makeCurrencyEngine(ct,dt){return bd(this,null,function*(){const pt=ep(dt.callbacks),St={walletInfo:ct,pluginInfo:O,pluginDisklet:ke,currencyTools:_e,initOptions:Bd(me),io:Me,options:n1(yd(yd({},R),dt),{emitter:pt}),pluginState:it};return yield Dm(St)})},makeCurrencyTools(){return bd(this,null,function*(){return it.load().catch(ct=>{throw ct}),_e})}}}var xd;const Md={};for(const R of Oo)Md[R.currencyInfo.pluginId]=O=>i1(O,R);typeof window<"u"&&((xd=window.addEdgeCorePlugins)==null||xd.call(window,Md));const fy=null})()})();})();
|