UNPKG

caver-js

Version:

caver-js is a JavaScript API library that allows developers to interact with a Kaia node

2 lines 1.58 MB
/*! For license information please see caver.min.js.LICENSE.txt */ (()=>{var e={46010:(e,t,r)=>{r.g.rootRequire=e=>r(86456)(`./${e}/src/index.js`);const{packageInit:n,providers:i}=r(53998),o=r(30459),s=r(35628),a=r(58544),f=r(55341),c=r(33305),u=r(98270),h=r(67464),l=r(18271),d=r(12680),p=r(53998),m=r(80184),b=r(95490),y=r(63379).formatters,g=r(52405),{version:w}=r(4147);function v(e,t){const r=this;this.use=m.registerMiddleware.bind(m),n(this,[e,t]),this.version=w,this.utils=b,this.account=s,this.abi=u,this.wallet=new a,this.kct=new l(this),this.klay=new o(this),this.rpc=new c(this),this.validator=new d(this.rpc.klay.klaytnCall),this.transaction=new f(this.rpc.klay.klaytnCall),this.ipfs=new g;const i=this.setProvider;this.setProvider=(e,t)=>(i.apply(this,[e,t]),r.klay.setRequestManager(r._requestManager),r.rpc.setRequestManager(r._requestManager),r.kct.setRequestManager(r._requestManager),r.contract._requestManager=r._requestManager,r.contract.currentProvider=r._provider,!0);const y=this,v=function(){h.apply(this,arguments),p.packageInit(this,[y]),this.setWallet(y.wallet)};v.create=function(){return new v(...arguments)},v.setProvider=function(){h.setProvider.apply(this,arguments)},(v.prototype=Object.create(h.prototype)).constructor=v,this.contract=v,this.contract._requestManager=this._requestManager,this.contract.currentProvider=this._requestManager.provider}v.utils=b,v.abi=u,v.providers=i,e.exports=v,e.exports.formatters=y},52093:(e,t,r)=>{"use strict";r.d(t,{RQ:()=>Ie,_R:()=>T});let n=!1,i=!1;const o={debug:1,default:2,info:2,warning:3,error:4,off:5};let s=o.default,a=null;const f=function(){try{const e=[];if(["NFD","NFC","NFKD","NFKC"].forEach((t=>{try{if("test"!=="test".normalize(t))throw new Error("bad normalize")}catch(r){e.push(t)}})),e.length)throw new Error("missing "+e.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(e){return e.message}return null}();var c,u;!function(e){e.DEBUG="DEBUG",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR",e.OFF="OFF"}(c||(c={})),function(e){e.UNKNOWN_ERROR="UNKNOWN_ERROR",e.NOT_IMPLEMENTED="NOT_IMPLEMENTED",e.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",e.NETWORK_ERROR="NETWORK_ERROR",e.SERVER_ERROR="SERVER_ERROR",e.TIMEOUT="TIMEOUT",e.BUFFER_OVERRUN="BUFFER_OVERRUN",e.NUMERIC_FAULT="NUMERIC_FAULT",e.MISSING_NEW="MISSING_NEW",e.INVALID_ARGUMENT="INVALID_ARGUMENT",e.MISSING_ARGUMENT="MISSING_ARGUMENT",e.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",e.CALL_EXCEPTION="CALL_EXCEPTION",e.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",e.NONCE_EXPIRED="NONCE_EXPIRED",e.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",e.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",e.TRANSACTION_REPLACED="TRANSACTION_REPLACED"}(u||(u={}));const h="0123456789abcdef";class l{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){const r=e.toLowerCase();null==o[r]&&this.throwArgumentError("invalid log level name","logLevel",e),s>o[r]||console.log.apply(console,t)}debug(...e){this._log(l.levels.DEBUG,e)}info(...e){this._log(l.levels.INFO,e)}warn(...e){this._log(l.levels.WARNING,e)}makeError(e,t,r){if(i)return this.makeError("censored error",t,{});t||(t=l.errors.UNKNOWN_ERROR),r||(r={});const n=[];Object.keys(r).forEach((e=>{const t=r[e];try{if(t instanceof Uint8Array){let r="";for(let e=0;e<t.length;e++)r+=h[t[e]>>4],r+=h[15&t[e]];n.push(e+"=Uint8Array(0x"+r+")")}else n.push(e+"="+JSON.stringify(t))}catch(t){n.push(e+"="+JSON.stringify(r[e].toString()))}})),n.push(`code=${t}`),n.push(`version=${this.version}`);const o=e;n.length&&(e+=" ("+n.join(", ")+")");const s=new Error(e);return s.reason=o,s.code=t,Object.keys(r).forEach((function(e){s[e]=r[e]})),s}throwError(e,t,r){throw this.makeError(e,t,r)}throwArgumentError(e,t,r){return this.throwError(e,l.errors.INVALID_ARGUMENT,{argument:t,value:r})}assert(e,t,r,n){e||this.throwError(t,r,n)}assertArgument(e,t,r,n){e||this.throwArgumentError(t,r,n)}checkNormalize(e){null==e&&(e="platform missing String.prototype.normalize"),f&&this.throwError("platform missing String.prototype.normalize",l.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:f})}checkSafeUint53(e,t){"number"==typeof e&&(null==t&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,l.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,l.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,r){r=r?": "+r:"",e<t&&this.throwError("missing argument"+r,l.errors.MISSING_ARGUMENT,{count:e,expectedCount:t}),e>t&&this.throwError("too many arguments"+r,l.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){e!==Object&&null!=e||this.throwError("missing new",l.errors.MISSING_NEW,{name:t.name})}checkAbstract(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",l.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):e!==Object&&null!=e||this.throwError("missing new",l.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return a||(a=new l("logger/5.5.0")),a}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",l.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),n){if(!e)return;this.globalLogger().throwError("error censorship permanent",l.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}i=!!e,n=!!t}static setLogLevel(e){const t=o[e.toLowerCase()];null!=t?s=t:l.globalLogger().warn("invalid log level - "+e)}static from(e){return new l(e)}}function d(e,t,r){Object.defineProperty(e,t,{enumerable:!0,value:r,writable:!1})}l.errors=u,l.levels=c,new l("properties/5.5.0");const p="abi/5.0.7",m=new l(p),b={};let y={calldata:!0,memory:!0,storage:!0},g={calldata:!0,memory:!0};function w(e,t){if("bytes"===e||"string"===e){if(y[t])return!0}else if("address"===e){if("payable"===t)return!0}else if((e.indexOf("[")>=0||"tuple"===e)&&g[t])return!0;return(y[t]||"payable"===t)&&m.throwArgumentError("invalid modifier","name",t),!1}function v(e,t){for(let r in t)d(e,r,t[r])}const _=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),E=new RegExp(/^(.*)\[([0-9]*)\]$/);class T{constructor(e,t){e!==b&&m.throwError("use fromString",l.errors.UNSUPPORTED_OPERATION,{operation:"new ParamType()"}),v(this,t);let r=this.type.match(E);v(this,r?{arrayLength:parseInt(r[2]||"-1"),arrayChildren:T.fromObject({type:r[1],components:this.components}),baseType:"array"}:{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}format(e){if(e||(e=_.sighash),_[e]||m.throwArgumentError("invalid format type","format",e),e===_.json){let t={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(t.indexed=this.indexed),this.components&&(t.components=this.components.map((t=>JSON.parse(t.format(e))))),JSON.stringify(t)}let t="";return"array"===this.baseType?(t+=this.arrayChildren.format(e),t+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):"tuple"===this.baseType?(e!==_.sighash&&(t+=this.type),t+="("+this.components.map((t=>t.format(e))).join(e===_.full?", ":",")+")"):t+=this.type,e!==_.sighash&&(!0===this.indexed&&(t+=" indexed"),e===_.full&&this.name&&(t+=" "+this.name)),t}static from(e,t){return"string"==typeof e?T.fromString(e,t):T.fromObject(e)}static fromObject(e){return T.isParamType(e)?e:new T(b,{name:e.name||null,type:k(e.type),indexed:null==e.indexed?null:!!e.indexed,components:e.components?e.components.map(T.fromObject):null})}static fromString(e,t){return r=function(e,t){let r=e;function n(t){m.throwArgumentError(`unexpected character at position ${t}`,"param",e)}function i(e){let r={type:"",name:"",parent:e,state:{allowType:!0}};return t&&(r.indexed=!1),r}e=e.replace(/\s/g," ");let o={type:"",name:"",state:{allowType:!0}},s=o;for(let r=0;r<e.length;r++){let o=e[r];switch(o){case"(":s.state.allowType&&""===s.type?s.type="tuple":s.state.allowParams||n(r),s.state.allowType=!1,s.type=k(s.type),s.components=[i(s)],s=s.components[0];break;case")":delete s.state,"indexed"===s.name&&(t||n(r),s.indexed=!0,s.name=""),w(s.type,s.name)&&(s.name=""),s.type=k(s.type);let e=s;s=s.parent,s||n(r),delete e.parent,s.state.allowParams=!1,s.state.allowName=!0,s.state.allowArray=!0;break;case",":delete s.state,"indexed"===s.name&&(t||n(r),s.indexed=!0,s.name=""),w(s.type,s.name)&&(s.name=""),s.type=k(s.type);let a=i(s.parent);s.parent.components.push(a),delete s.parent,s=a;break;case" ":s.state.allowType&&""!==s.type&&(s.type=k(s.type),delete s.state.allowType,s.state.allowName=!0,s.state.allowParams=!0),s.state.allowName&&""!==s.name&&("indexed"===s.name?(t||n(r),s.indexed&&n(r),s.indexed=!0,s.name=""):w(s.type,s.name)?s.name="":s.state.allowName=!1);break;case"[":s.state.allowArray||n(r),s.type+=o,s.state.allowArray=!1,s.state.allowName=!1,s.state.readArray=!0;break;case"]":s.state.readArray||n(r),s.type+=o,s.state.readArray=!1,s.state.allowArray=!0,s.state.allowName=!0;break;default:s.state.allowType?(s.type+=o,s.state.allowParams=!0,s.state.allowArray=!0):s.state.allowName?(s.name+=o,delete s.state.allowArray):s.state.readArray?s.type+=o:n(r)}}return s.parent&&m.throwArgumentError("unexpected eof","param",e),delete o.state,"indexed"===s.name?(t||n(r.length-7),s.indexed&&n(r.length-7),s.indexed=!0,s.name=""):w(s.type,s.name)&&(s.name=""),o.type=k(o.type),o}(e,!!t),T.fromObject({name:r.name,type:r.type,indexed:r.indexed,components:r.components});var r}static isParamType(e){return!(null==e||!e._isParamType)}}function k(e){return e.match(/^uint($|[^1-9])/)?e="uint256"+e.substring(4):e.match(/^int($|[^1-9])/)&&(e="int256"+e.substring(3)),e}const x=new l("bytes/5.5.0");function A(e){return!!e.toHexString}function M(e){return e.slice||(e.slice=function(){const t=Array.prototype.slice.call(arguments);return M(new Uint8Array(Array.prototype.slice.apply(e,t)))}),e}function S(e){return"number"==typeof e&&e==e&&e%1==0}function P(e){if(null==e)return!1;if(e.constructor===Uint8Array)return!0;if("string"==typeof e)return!1;if(!S(e.length)||e.length<0)return!1;for(let t=0;t<e.length;t++){const r=e[t];if(!S(r)||r<0||r>=256)return!1}return!0}function C(e,t){if(t||(t={}),"number"==typeof e){x.checkSafeUint53(e,"invalid arrayify value");const t=[];for(;e;)t.unshift(255&e),e=parseInt(String(e/256));return 0===t.length&&t.push(0),M(new Uint8Array(t))}if(t.allowMissingPrefix&&"string"==typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),A(e)&&(e=e.toHexString()),N(e)){let r=e.substring(2);r.length%2&&("left"===t.hexPad?r="0x0"+r.substring(2):"right"===t.hexPad?r+="0":x.throwArgumentError("hex data is odd-length","value",e));const n=[];for(let e=0;e<r.length;e+=2)n.push(parseInt(r.substring(e,e+2),16));return M(new Uint8Array(n))}return P(e)?M(new Uint8Array(e)):x.throwArgumentError("invalid arrayify value","value",e)}function I(e){const t=e.map((e=>C(e))),r=t.reduce(((e,t)=>e+t.length),0),n=new Uint8Array(r);return t.reduce(((e,t)=>(n.set(t,e),e+t.length)),0),M(n)}function N(e,t){return!("string"!=typeof e||!e.match(/^0x[0-9A-Fa-f]*$/)||t&&e.length!==2+2*t)}const R="0123456789abcdef";function O(e,t){if(t||(t={}),"number"==typeof e){x.checkSafeUint53(e,"invalid hexlify value");let t="";for(;e;)t=R[15&e]+t,e=Math.floor(e/16);return t.length?(t.length%2&&(t="0"+t),"0x"+t):"0x00"}if("bigint"==typeof e)return(e=e.toString(16)).length%2?"0x0"+e:"0x"+e;if(t.allowMissingPrefix&&"string"==typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),A(e))return e.toHexString();if(N(e))return e.length%2&&("left"===t.hexPad?e="0x0"+e.substring(2):"right"===t.hexPad?e+="0":x.throwArgumentError("hex data is odd-length","value",e)),e.toLowerCase();if(P(e)){let t="0x";for(let r=0;r<e.length;r++){let n=e[r];t+=R[(240&n)>>4]+R[15&n]}return t}return x.throwArgumentError("invalid hexlify value","value",e)}var L=r(83877),F=r.n(L)().BN;const B=new l("bignumber/5.5.0"),D={},U=9007199254740991;let j=!1;class K{constructor(e,t){B.checkNew(new.target,K),e!==D&&B.throwError("cannot call constructor directly; use BigNumber.from",l.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=t,this._isBigNumber=!0,Object.freeze(this)}fromTwos(e){return H($(this).fromTwos(e))}toTwos(e){return H($(this).toTwos(e))}abs(){return"-"===this._hex[0]?K.from(this._hex.substring(1)):this}add(e){return H($(this).add($(e)))}sub(e){return H($(this).sub($(e)))}div(e){return K.from(e).isZero()&&q("division by zero","div"),H($(this).div($(e)))}mul(e){return H($(this).mul($(e)))}mod(e){const t=$(e);return t.isNeg()&&q("cannot modulo negative values","mod"),H($(this).umod(t))}pow(e){const t=$(e);return t.isNeg()&&q("cannot raise to negative values","pow"),H($(this).pow(t))}and(e){const t=$(e);return(this.isNegative()||t.isNeg())&&q("cannot 'and' negative values","and"),H($(this).and(t))}or(e){const t=$(e);return(this.isNegative()||t.isNeg())&&q("cannot 'or' negative values","or"),H($(this).or(t))}xor(e){const t=$(e);return(this.isNegative()||t.isNeg())&&q("cannot 'xor' negative values","xor"),H($(this).xor(t))}mask(e){return(this.isNegative()||e<0)&&q("cannot mask negative values","mask"),H($(this).maskn(e))}shl(e){return(this.isNegative()||e<0)&&q("cannot shift negative values","shl"),H($(this).shln(e))}shr(e){return(this.isNegative()||e<0)&&q("cannot shift negative values","shr"),H($(this).shrn(e))}eq(e){return $(this).eq($(e))}lt(e){return $(this).lt($(e))}lte(e){return $(this).lte($(e))}gt(e){return $(this).gt($(e))}gte(e){return $(this).gte($(e))}isNegative(){return"-"===this._hex[0]}isZero(){return $(this).isZero()}toNumber(){try{return $(this).toNumber()}catch(e){q("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(e){}return B.throwError("this platform does not support BigInt",l.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?j||(j=!0,B.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?B.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",l.errors.UNEXPECTED_ARGUMENT,{}):B.throwError("BigNumber.toString does not accept parameters",l.errors.UNEXPECTED_ARGUMENT,{})),$(this).toString(10)}toHexString(){return this._hex}toJSON(e){return{type:"BigNumber",hex:this.toHexString()}}static from(e){if(e instanceof K)return e;if("string"==typeof e)return e.match(/^-?0x[0-9a-f]+$/i)?new K(D,G(e)):e.match(/^-?[0-9]+$/)?new K(D,G(new F(e))):B.throwArgumentError("invalid BigNumber string","value",e);if("number"==typeof e)return e%1&&q("underflow","BigNumber.from",e),(e>=U||e<=-U)&&q("overflow","BigNumber.from",e),K.from(String(e));const t=e;if("bigint"==typeof t)return K.from(t.toString());if(P(t))return K.from(O(t));if(t)if(t.toHexString){const e=t.toHexString();if("string"==typeof e)return K.from(e)}else{let e=t._hex;if(null==e&&"BigNumber"===t.type&&(e=t.hex),"string"==typeof e&&(N(e)||"-"===e[0]&&N(e.substring(1))))return K.from(e)}return B.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return!(!e||!e._isBigNumber)}}function G(e){if("string"!=typeof e)return G(e.toString(16));if("-"===e[0])return"-"===(e=e.substring(1))[0]&&B.throwArgumentError("invalid hex","value",e),"0x00"===(e=G(e))?e:"-"+e;if("0x"!==e.substring(0,2)&&(e="0x"+e),"0x"===e)return"0x00";for(e.length%2&&(e="0x0"+e.substring(2));e.length>4&&"0x00"===e.substring(0,4);)e="0x"+e.substring(4);return e}function H(e){return K.from(G(e))}function $(e){const t=K.from(e).toHexString();return"-"===t[0]?new F("-"+t.substring(3),16):new F(t.substring(2),16)}function q(e,t,r){const n={fault:e,operation:t};return null!=r&&(n.value=r),B.throwError(e,l.errors.NUMERIC_FAULT,n)}const z=new l(p);class V{constructor(e,t,r,n){this.name=e,this.type=t,this.localName=r,this.dynamic=n}_throwError(e,t){z.throwArgumentError(e,this.localName,t)}}class W{constructor(e){d(this,"wordSize",e||32),this._data=[],this._dataLength=0,this._padding=new Uint8Array(e)}get data(){return function(e){let t="0x";return e.forEach((e=>{t+=O(e).substring(2)})),t}(this._data)}get length(){return this._dataLength}_writeData(e){return this._data.push(e),this._dataLength+=e.length,e.length}appendWriter(e){return this._writeData(I(e._data))}writeBytes(e){let t=C(e);const r=t.length%this.wordSize;return r&&(t=I([t,this._padding.slice(r)])),this._writeData(t)}_getValue(e){let t=C(K.from(e));return t.length>this.wordSize&&z.throwError("value out-of-bounds",l.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:t.length}),t.length%this.wordSize&&(t=I([this._padding.slice(t.length%this.wordSize),t])),t}writeValue(e){return this._writeData(this._getValue(e))}writeUpdatableValue(){const e=this._data.length;return this._data.push(this._padding),this._dataLength+=this.wordSize,t=>{this._data[e]=this._getValue(t)}}}class Y{constructor(e,t,r,n){d(this,"_data",C(e)),d(this,"wordSize",t||32),d(this,"_coerceFunc",r),d(this,"allowLoose",n),this._offset=0}get data(){return O(this._data)}get consumed(){return this._offset}static coerce(e,t){let r=e.match("^u?int([0-9]+)$");return r&&parseInt(r[1])<=48&&(t=t.toNumber()),t}coerce(e,t){return this._coerceFunc?this._coerceFunc(e,t):Y.coerce(e,t)}_peekBytes(e,t,r){let n=Math.ceil(t/this.wordSize)*this.wordSize;return this._offset+n>this._data.length&&(this.allowLoose&&r&&this._offset+t<=this._data.length?n=t:z.throwError("data out-of-bounds",l.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+n})),this._data.slice(this._offset,this._offset+n)}subReader(e){return new Y(this._data.slice(this._offset+e),this.wordSize,this._coerceFunc,this.allowLoose)}readBytes(e,t){let r=this._peekBytes(0,e,!!t);return this._offset+=r.length,r.slice(0,e)}readValue(){return K.from(this.readBytes(this.wordSize))}}var Z=r(91094),X=r.n(Z);const J=new l("address/5.5.0");function Q(e){N(e,20)||J.throwArgumentError("invalid address","address",e);const t=(e=e.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let e=0;e<40;e++)r[e]=t[e].charCodeAt(0);const n=C((i=r,"0x"+X().keccak_256(C(i))));var i;for(let e=0;e<40;e+=2)n[e>>1]>>4>=8&&(t[e]=t[e].toUpperCase()),(15&n[e>>1])>=8&&(t[e+1]=t[e+1].toUpperCase());return"0x"+t.join("")}const ee={};for(let e=0;e<10;e++)ee[String(e)]=String(e);for(let e=0;e<26;e++)ee[String.fromCharCode(65+e)]=String(10+e);const te=Math.floor((re=9007199254740991,Math.log10?Math.log10(re):Math.log(re)/Math.LN10));var re;function ne(e){let t=null;if("string"!=typeof e&&J.throwArgumentError("invalid address","address",e),e.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==e.substring(0,2)&&(e="0x"+e),t=Q(e),e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==e&&J.throwArgumentError("bad address checksum","address",e);else if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(e.substring(2,4)!==function(e){let t=(e=(e=e.toUpperCase()).substring(4)+e.substring(0,2)+"00").split("").map((e=>ee[e])).join("");for(;t.length>=te;){let e=t.substring(0,te);t=parseInt(e,10)%97+t.substring(e.length)}let r=String(98-parseInt(t,10)%97);for(;r.length<2;)r="0"+r;return r}(e)&&J.throwArgumentError("bad icap checksum","address",e),r=e.substring(4),t=new F(r,36).toString(16);t.length<40;)t="0"+t;t=Q("0x"+t)}else J.throwArgumentError("invalid address","address",e);var r;return t}class ie extends V{constructor(e){super("address","address",e,!1)}encode(e,t){try{ne(t)}catch(e){this._throwError(e.message,t)}return e.writeValue(t)}decode(e){return ne(function(e,t){for("string"!=typeof e?e=O(e):N(e)||x.throwArgumentError("invalid hex string","value",e),e.length>2*t+2&&x.throwArgumentError("value out of range","value",arguments[1]);e.length<2*t+2;)e="0x0"+e.substring(2);return e}(e.readValue().toHexString(),20))}}class oe extends V{constructor(e){super(e.name,e.type,void 0,e.dynamic),this.coder=e}encode(e,t){return this.coder.encode(e,t)}decode(e){return this.coder.decode(e)}}const se=new l(p);function ae(e,t,r){let n=null;if(Array.isArray(r))n=r;else if(r&&"object"==typeof r){let e={};n=t.map((t=>{const n=t.localName;return n||se.throwError("cannot encode object for signature with missing names",l.errors.INVALID_ARGUMENT,{argument:"values",coder:t,value:r}),e[n]&&se.throwError("cannot encode object for signature with duplicate names",l.errors.INVALID_ARGUMENT,{argument:"values",coder:t,value:r}),e[n]=!0,r[n]}))}else se.throwArgumentError("invalid tuple value","tuple",r);t.length!==n.length&&se.throwArgumentError("types/value length mismatch","tuple",r);let i=new W(e.wordSize),o=new W(e.wordSize),s=[];t.forEach(((e,t)=>{let r=n[t];if(e.dynamic){let t=o.length;e.encode(o,r);let n=i.writeUpdatableValue();s.push((e=>{n(e+t)}))}else e.encode(i,r)})),s.forEach((e=>{e(i.length)}));let a=e.appendWriter(i);return a+=e.appendWriter(o),a}function fe(e,t){let r=[],n=e.subReader(0);t.forEach((t=>{let i=null;if(t.dynamic){let r=e.readValue(),o=n.subReader(r.toNumber());try{i=t.decode(o)}catch(e){if(e.code===l.errors.BUFFER_OVERRUN)throw e;i=e,i.baseType=t.name,i.name=t.localName,i.type=t.type}}else try{i=t.decode(e)}catch(e){if(e.code===l.errors.BUFFER_OVERRUN)throw e;i=e,i.baseType=t.name,i.name=t.localName,i.type=t.type}null!=i&&r.push(i)}));const i=t.reduce(((e,t)=>{const r=t.localName;return r&&(e[r]||(e[r]=0),e[r]++),e}),{});t.forEach(((e,t)=>{let n=e.localName;if(!n||1!==i[n])return;if("length"===n&&(n="_length"),null!=r[n])return;const o=r[t];o instanceof Error?Object.defineProperty(r,n,{get:()=>{throw o}}):r[n]=o}));for(let e=0;e<r.length;e++){const t=r[e];t instanceof Error&&Object.defineProperty(r,e,{get:()=>{throw t}})}return Object.freeze(r)}class ce extends V{constructor(e,t,r){super("array",e.type+"["+(t>=0?t:"")+"]",r,-1===t||e.dynamic),this.coder=e,this.length=t}encode(e,t){Array.isArray(t)||this._throwError("expected array value",t);let r=this.length;-1===r&&(r=t.length,e.writeValue(t.length)),se.checkArgumentCount(t.length,r,"coder array"+(this.localName?" "+this.localName:""));let n=[];for(let e=0;e<t.length;e++)n.push(this.coder);return ae(e,n,t)}decode(e){let t=this.length;-1===t&&(t=e.readValue().toNumber());let r=[];for(let e=0;e<t;e++)r.push(new oe(this.coder));return e.coerce(this.name,fe(e,r))}}class ue extends V{constructor(e){super("bool","bool",e,!1)}encode(e,t){return e.writeValue(t?1:0)}decode(e){return e.coerce(this.type,!e.readValue().isZero())}}class he extends V{constructor(e,t){super(e,e,t,!0)}encode(e,t){t=C(t);let r=e.writeValue(t.length);return r+=e.writeBytes(t),r}decode(e){return e.readBytes(e.readValue().toNumber(),!0)}}class le extends he{constructor(e){super("bytes",e)}decode(e){return e.coerce(this.name,O(super.decode(e)))}}class de extends V{constructor(e,t){let r="bytes"+String(e);super(r,r,t,!1),this.size=e}encode(e,t){let r=C(t);return r.length!==this.size&&this._throwError("incorrect data length",t),e.writeBytes(r)}decode(e){return e.coerce(this.name,O(e.readBytes(this.size)))}}class pe extends V{constructor(e){super("null","",e,!1)}encode(e,t){return null!=t&&this._throwError("not null",t),e.writeBytes([])}decode(e){return e.readBytes(0),e.coerce(this.name,null)}}const me=K.from(-1),be=K.from(0),ye=K.from(1),ge=K.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class we extends V{constructor(e,t,r){const n=(t?"int":"uint")+8*e;super(n,n,r,!1),this.size=e,this.signed=t}encode(e,t){let r=K.from(t),n=ge.mask(8*e.wordSize);if(this.signed){let e=n.mask(8*this.size-1);(r.gt(e)||r.lt(e.add(ye).mul(me)))&&this._throwError("value out-of-bounds",t)}else(r.lt(be)||r.gt(n.mask(8*this.size)))&&this._throwError("value out-of-bounds",t);return r=r.toTwos(8*this.size).mask(8*this.size),this.signed&&(r=r.fromTwos(8*this.size).toTwos(8*e.wordSize)),e.writeValue(r)}decode(e){let t=e.readValue().mask(8*this.size);return this.signed&&(t=t.fromTwos(8*this.size)),e.coerce(this.name,t)}}const ve=new l("strings/5.5.0");var _e,Ee;function Te(e,t,r,n,i){if(e===Ee.BAD_PREFIX||e===Ee.UNEXPECTED_CONTINUE){let e=0;for(let n=t+1;n<r.length&&r[n]>>6==2;n++)e++;return e}return e===Ee.OVERRUN?r.length-t-1:0}!function(e){e.current="",e.NFC="NFC",e.NFD="NFD",e.NFKC="NFKC",e.NFKD="NFKD"}(_e||(_e={})),function(e){e.UNEXPECTED_CONTINUE="unexpected continuation byte",e.BAD_PREFIX="bad codepoint prefix",e.OVERRUN="string overrun",e.MISSING_CONTINUE="missing continuation byte",e.OUT_OF_RANGE="out of UTF-8 range",e.UTF16_SURROGATE="UTF-16 surrogate",e.OVERLONG="overlong representation"}(Ee||(Ee={}));const ke=Object.freeze({error:function(e,t,r,n,i){return ve.throwArgumentError(`invalid codepoint at offset ${t}; ${e}`,"bytes",r)},ignore:Te,replace:function(e,t,r,n,i){return e===Ee.OVERLONG?(n.push(i),0):(n.push(65533),Te(e,t,r))}});function xe(e,t){return function(e,t){null==t&&(t=ke.error),e=C(e);const r=[];let n=0;for(;n<e.length;){const i=e[n++];if(i>>7==0){r.push(i);continue}let o=null,s=null;if(192==(224&i))o=1,s=127;else if(224==(240&i))o=2,s=2047;else{if(240!=(248&i)){n+=t(128==(192&i)?Ee.UNEXPECTED_CONTINUE:Ee.BAD_PREFIX,n-1,e,r);continue}o=3,s=65535}if(n-1+o>=e.length){n+=t(Ee.OVERRUN,n-1,e,r);continue}let a=i&(1<<8-o-1)-1;for(let i=0;i<o;i++){let i=e[n];if(128!=(192&i)){n+=t(Ee.MISSING_CONTINUE,n,e,r),a=null;break}a=a<<6|63&i,n++}null!==a&&(a>1114111?n+=t(Ee.OUT_OF_RANGE,n-1-o,e,r,a):a>=55296&&a<=57343?n+=t(Ee.UTF16_SURROGATE,n-1-o,e,r,a):a<=s?n+=t(Ee.OVERLONG,n-1-o,e,r,a):r.push(a))}return r}(e,t).map((e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10&1023),56320+(1023&e))))).join("")}class Ae extends he{constructor(e){super("string",e)}encode(e,t){return super.encode(e,function(e,t=_e.current){t!=_e.current&&(ve.checkNormalize(),e=e.normalize(t));let r=[];for(let t=0;t<e.length;t++){const n=e.charCodeAt(t);if(n<128)r.push(n);else if(n<2048)r.push(n>>6|192),r.push(63&n|128);else if(55296==(64512&n)){t++;const i=e.charCodeAt(t);if(t>=e.length||56320!=(64512&i))throw new Error("invalid utf-8 string");const o=65536+((1023&n)<<10)+(1023&i);r.push(o>>18|240),r.push(o>>12&63|128),r.push(o>>6&63|128),r.push(63&o|128)}else r.push(n>>12|224),r.push(n>>6&63|128),r.push(63&n|128)}return C(r)}(t))}decode(e){return xe(super.decode(e))}}class Me extends V{constructor(e,t){let r=!1;const n=[];e.forEach((e=>{e.dynamic&&(r=!0),n.push(e.type)})),super("tuple","tuple("+n.join(",")+")",t,r),this.coders=e}encode(e,t){return ae(e,this.coders,t)}decode(e){return e.coerce(this.name,fe(e,this.coders))}}const Se=new l(p),Pe=new RegExp(/^bytes([0-9]*)$/),Ce=new RegExp(/^(u?int)([0-9]*)$/);class Ie{constructor(e){Se.checkNew(new.target,Ie),d(this,"coerceFunc",e||null)}_getCoder(e){switch(e.baseType){case"address":return new ie(e.name);case"bool":return new ue(e.name);case"string":return new Ae(e.name);case"bytes":return new le(e.name);case"array":return new ce(this._getCoder(e.arrayChildren),e.arrayLength,e.name);case"tuple":return new Me((e.components||[]).map((e=>this._getCoder(e))),e.name);case"":return new pe(e.name)}let t=e.type.match(Ce);if(t){let r=parseInt(t[2]||"256");return(0===r||r>256||r%8!=0)&&Se.throwArgumentError("invalid "+t[1]+" bit length","param",e),new we(r/8,"int"===t[1],e.name)}if(t=e.type.match(Pe),t){let r=parseInt(t[1]);return(0===r||r>32)&&Se.throwArgumentError("invalid bytes length","param",e),new de(r,e.name)}return Se.throwArgumentError("invalid type","type",e.type)}_getWordSize(){return 32}_getReader(e,t){return new Y(e,this._getWordSize(),this.coerceFunc,t)}_getWriter(){return new W(this._getWordSize())}encode(e,t){e.length!==t.length&&Se.throwError("types/values length mismatch",l.errors.INVALID_ARGUMENT,{count:{types:e.length,values:t.length},value:{types:e,values:t}});const r=e.map((e=>this._getCoder(T.from(e)))),n=new Me(r,"_"),i=this._getWriter();return n.encode(i,t),i.data}decode(e,t,r){const n=e.map((e=>this._getCoder(T.from(e))));return new Me(n,"_").decode(this._getReader(C(t),r))}}new Ie,new l(p)},83877:function(e,t,r){!function(e,t){"use strict";function n(e,t){if(!e)throw new Error(t||"Assertion failed")}function i(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function o(e,t,r){if(o.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var s;"object"==typeof e?e.exports=o:t.BN=o,o.BN=o,o.wordSize=26;try{s="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:r(88677).Buffer}catch(e){}function a(e,t){var r=e.charCodeAt(t);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function f(e,t,r){var n=a(e,r);return r-1>=t&&(n|=a(e,r-1)<<4),n}function c(e,t,r,n){for(var i=0,o=Math.min(e.length,r),s=t;s<o;s++){var a=e.charCodeAt(s)-48;i*=n,i+=a>=49?a-49+10:a>=17?a-17+10:a}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i<e.length&&(16===t?this._parseHex(e,i,r):(this._parseBase(e,t,i),"le"===r&&this._initArray(this.toArray(),t,r)))},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var o,s,a=0;if("be"===r)for(i=e.length-1,o=0;i>=0;i-=3)s=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i<e.length;i+=3)s=e[i]|e[i+1]<<8|e[i+2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t,r){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var i,o=0,s=0;if("be"===r)for(n=e.length-1;n>=t;n-=2)i=f(e,t,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(e.length-t)%2==0?t+1:t;n<e.length;n+=2)i=f(e,t,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,s=o%n,a=Math.min(o,o-s)+r,f=0,u=r;u<a;u+=n)f=c(e,u,u+n,t),this.imuln(i),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f);if(0!==s){var h=1;for(f=c(e,u,e.length,t),u=0;u<s;u++)h*=t;this.imuln(h),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f)}this.strip()},o.prototype.copy=function(e){e.words=new Array(this.length);for(var t=0;t<this.length;t++)e.words[t]=this.words[t];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&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],h=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],l=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function d(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],s=i*o,a=67108863&s,f=s/67108864|0;r.words[0]=a;for(var c=1;c<n;c++){for(var u=f>>>26,h=67108863&f,l=Math.min(c,t.length-1),d=Math.max(0,c-e.length+1);d<=l;d++){var p=c-d|0;u+=(s=(i=0|e.words[p])*(o=0|t.words[d])+h)/67108864|0,h=67108863&s}r.words[c]=0|h,f=0|u}return 0!==f?r.words[c]=0|f:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,s=0;s<this.length;s++){var a=this.words[s],f=(16777215&(a<<i|o)).toString(16);r=0!=(o=a>>>24-i&16777215)||s!==this.length-1?u[6-f.length]+f+r:f+r,(i+=2)>=26&&(i-=26,s--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var c=h[e],d=l[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(e);r=(p=p.idivn(d)).isZero()?m+r:u[c-m.length]+m+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==s),this.toArrayLike(s,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var s,a,f="le"===t,c=new e(o),u=this.clone();if(f){for(a=0;!u.isZero();a++)s=u.andln(255),u.iushrn(8),c[a]=s;for(;a<o;a++)c[a]=0}else{for(a=0;a<o-i;a++)c[a]=0;for(a=0;!u.isZero();a++)s=u.andln(255),u.iushrn(8),c[o-a-1]=s}return c},Math.clz32?o.prototype._countBits=function(e){return 32-Math.clz32(e)}:o.prototype._countBits=function(e){var t=e,r=0;return t>=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;t<this.length;t++){var r=this._zeroBits(this.words[t]);if(e+=r,26!==r)break}return e},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(e){return 0!==this.negative?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 0!==this.negative},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 t=0;t<e.length;t++)this.words[t]=this.words[t]|e.words[t];return this.strip()},o.prototype.ior=function(e){return n(0==(this.negative|e.negative)),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 t;t=this.length>e.length?e:this;for(var r=0;r<t.length;r++)this.words[r]=this.words[r]&e.words[r];return this.length=t.length,this.strip()},o.prototype.iand=function(e){return n(0==(this.negative|e.negative)),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 t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;n<r.length;n++)this.words[n]=t.words[n]^r.words[n];if(this!==t)for(;n<t.length;n++)this.words[n]=t.words[n];return this.length=t.length,this.strip()},o.prototype.ixor=function(e){return n(0==(this.negative|e.negative)),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){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i<t;i++)this.words[i]=67108863&~this.words[i];return r>0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<<i:this.words[r]&~(1<<i),this.strip()},o.prototype.iadd=function(e){var t,r,n;if(0!==this.negative&&0===e.negative)return this.negative=0,t=this.isub(e),this.negative^=1,this._normSign();if(0===this.negative&&0!==e.negative)return e.negative=0,t=this.isub(e),e.negative=1,t._normSign();this.length>e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o<n.length;o++)t=(0|r.words[o])+(0|n.words[o])+i,this.words[o]=67108863&t,i=t>>>26;for(;0!==i&&o<r.length;o++)t=(0|r.words[o])+i,this.words[o]=67108863&t,i=t>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},o.prototype.add=function(e){var t;return 0!==e.negative&&0===this.negative?(e.negative=0,t=this.sub(e),e.negative^=1,t):0===e.negative&&0!==this.negative?(this.negative=0,t=e.sub(this),this.negative=1,t):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,s=0;s<n.length;s++)o=(t=(0|r.words[s])-(0|n.words[s])+o)>>26,this.words[s]=67108863&t;for(;0!==o&&s<r.length;s++)o=(t=(0|r.words[s])+o)>>26,this.words[s]=67108863&t;if(0===o&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this.strip()},o.prototype.sub=function(e){return this.clone().isub(e)};var p=function(e,t,r){var n,i,o,s=e.words,a=t.words,f=r.words,c=0,u=0|s[0],h=8191&u,l=u>>>13,d=0|s[1],p=8191&d,m=d>>>13,b=0|s[2],y=8191&b,g=b>>>13,w=0|s[3],v=8191&w,_=w>>>13,E=0|s[4],T=8191&E,k=E>>>13,x=0|s[5],A=8191&x,M=x>>>13,S=0|s[6],P=8191&S,C=S>>>13,I=0|s[7],N=8191&I,R=I>>>13,O=0|s[8],L=8191&O,F=O>>>13,B=0|s[9],D=8191&B,U=B>>>13,j=0|a[0],K=8191&j,G=j>>>13,H=0|a[1],$=8191&H,q=H>>>13,z=0|a[2],V=8191&z,W=z>>>13,Y=0|a[3],Z=8191&Y,X=Y>>>13,J=0|a[4],Q=8191&J,ee=J>>>13,te=0|a[5],re=8191&te,ne=te>>>13,ie=0|a[6],oe=8191&ie,se=ie>>>13,ae=0|a[7],fe=8191&ae,ce=ae>>>13,ue=0|a[8],he=8191&ue,le=ue>>>13,de=0|a[9],pe=8191&de,me=de>>>13;r.negative=e.negative^t.negative,r.length=19;var be=(c+(n=Math.imul(h,K))|0)+((8191&(i=(i=Math.imul(h,G))+Math.imul(l,K)|0))<<13)|0;c=((o=Math.imul(l,G))+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(p,K),i=(i=Math.imul(p,G))+Math.imul(m,K)|0,o=Math.imul(m,G);var ye=(c+(n=n+Math.imul(h,$)|0)|0)+((8191&(i=(i=i+Math.imul(h,q)|0)+Math.imul(l,$)|0))<<13)|0;c=((o=o+Math.imul(l,q)|0)+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(y,K),i=(i=Math.imul(y,G))+Math.imul(g,K)|0,o=Math.imul(g,G),n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,q)|0)+Math.imul(m,$)|0,o=o+Math.imul(m,q)|0;var ge=(c+(n=n+Math.imul(h,V)|0)|0)+((8191&(i=(i=i+Math.imul(h,W)|0)+Math.imul(l,V)|0))<<13)|0;c=((o=o+Math.imul(l,W)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(v,K),i=(i=Math.imul(v,G))+Math.imul(_,K)|0,o=Math.imul(_,G),n=n+Math.imul(y,$)|0,i=(i=i+Math.imul(y,q)|0)+Math.imul(g,$)|0,o=o+Math.imul(g,q)|0,n=n+Math.imul(p,V)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(m,V)|0,o=o+Math.imul(m,W)|0;var we=(c+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,X)|0)+Math.imul(l,Z)|0))<<13)|0;c=((o=o+Math.imul(l,X)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(T,K),i=(i=Math.imul(T,G))+Math.imul(k,K)|0,o=Math.imul(k,G),n=n+Math.imul(v,$)|0,i=(i=i+Math.imul(v,q)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,q)|0,n=n+Math.imul(y,V)|0,i=(i=i+Math.imul(y,W)|0)+Math.imul(g,V)|0,o=o+Math.imul(g,W)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,X)|0)+Math.imul(m,Z)|0,o=o+Math.imul(m,X)|0;var ve=(c+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(l,Q)|0))<<13)|0;c=((o=o+Math.imul(l,ee)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(A,K),i=(i=Math.imul(A,G))+Math.imul(M,K)|0,o=Math.imul(M,G),n=n+Math.imul(T,$)|0,i=(i=i+Math.imul(T,q)|0)+Math.imul(k,$)|0,o=o+Math.imul(k,q)|0,n=n+Math.imul(v,V)|0,i=(i=i+Math.imul(v,W)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(y,Z)|0,i=(i=i+Math.imul(y,X)|0)+Math.imul(g,Z)|0,o=o+Math.imul(g,X)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(m,Q)|0,o=o+Math.imul(m,ee)|0;var _e=(c+(n=n+Math.imul(h,re)|0)|0)+((8191&(i=(i=i+Math.imul(h,ne)|0)+Math.imul(l,re)|0))<<13)|0;c=((o=o+Math.imul(l,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(P,K),i=(i=Math.imul(P,G))+Math.imul(C,K)|0,o=Math.imul(C,G),n=n+Math.imul(A,$)|0,i=(i=i+Math.imul(A,q)|0)+Math.imul(M,$)|0,o=o+Math.imul(M,q)|0,n=n+Math.imul(T,V)|0,i=(i=i+Math.imul(T,W)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(v,Z)|0,i=(i=i+Math.imul(v,X)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,X)|0,n=n+Math.imul(y,Q)|0,i=(i=i+Math.imul(y,ee)|0)+Math.imul(g,Q)|0,o=o+Math.imul(g,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(m,re)|0,o=o+Math.imul(m,ne)|0;var Ee=(c+(n=n+Math.imul(h,oe)|0)|0)+((8191&(i=(i=i+Math.imul(h,se)|0)+Math.imul(l,oe)|0))<<13)|0;c=((o=o+Math.imul(l,se)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(N,K),i=(i=Math.imul(N,G))+Math.imul(R,K)|0,o=Math.imul(R,G),n=n+Math.imul(P,$)|0,i=(i=i+Math.imul(P,q)|0)+Math.imul(C,$)|0,o=o+Math.imul(C,q)|0,n=n+Math.imul(A,V)|0,i=(i=i+Math.imul(A,W)|0)+Math.imul(M,V)|0,o=o+Math.imul(M,W)|0,n=n+Math.imul(T,Z)|0,i=(i=i+Math.imul(T,X)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,X)|0,n=n+Math.imul(v,Q)|0,i=(i=i+Math.imul(v,ee)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(y,re)|0,i=(i=i+Math.imul(y,ne)|0)+Math.imul(g,re)|0,o=o+Math.imul(g,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,se)|0)+Math.imul(m,oe)|0,o=o+Math.imul(m,se)|0;var Te=(c+(n=n+Math.imul(h,fe)|0)|0)+((8191&(i=(i=i+Math.imul(h,ce)|0)+Math.imul(l,fe)|0))<<13)|0;c=((o=o+Math.imul(l,ce)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(L,K),i=(i=Math.imul(L,G))+Math.imul(F,K)|0,o=Math.imul(F,G),n=n+Math.imul(N,$)|0,i=(i=i+Math.imul(N,q)|0)+Math.imul(R,$)|0,o=o+Math.imul(R,q)|0,n=n+Math.imul(P,V)|0,i=(i=i+Math.imul(P,W)|0)+Math.imul(C,V)|0,o=o+Math.imul(C,W)|0,n=n+Math.imul(A,Z)|0,i=(i=i+Math.imul(A,X)|0)+Math.imul(M,Z)|0,o=o+Math.imul(M,X)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,ee)|0)+Math.imul(k,Q)|0,o=o+Math.imul(k,ee)|0,n=n+Math.imul(v,re)|0,i=(i=i+Math.imul(v,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(y,oe)|0,i=(i=i+Math.imul(y,se)|0)+Math.imul(g,oe)|0,o=o+Math.imul(g,se)|0,n=n+Math.imul(p,fe)|0,i=(i=i+Math.imul(p,ce)|0)+Math.imul(m,fe)|0,o=o+Math.imul(m,ce)|0;var ke=(c+(n=n+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,le)|0)+Math.imul(l,he)|0))<<13)|0;c=((o=o+Math.imul(l,le)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(D,K),i=(i=Math.imul(D,G))+Math.imul(U,K)|0,o=Math.imul(U,G),n=n+Math.imul(L,$)|0,i=(i=i+Math.imul(L,q)|0)+Math.imul(F,$)|0,o=o+Math.imul(F,q)|0,n=n+Math.imul(N,V)|0,i=(i=i+Math.imul(N,W)|0)+Math.imul(R,V)|0,o=o+Math.imul(R,W)|0,n=n+Math.imul(P,Z)|0,i=(i=i+Math.imul(P,X)|0)+Math.imul(C,Z)|0,o=o+Math.imul(C,X)|0,n=n+Math.imul(A,Q)|0,i=(i=i+Math.imul(A,ee)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,ee)|0,n=n+Math.imul(T,re)|0,i=(i=i+Math.imul(T,ne)|0)+Math.imul(k,re)|0,o=o+Math.imul(k,ne)|0,n=n+Math.imul(v,oe)|0,i=(i=i+Math.imul(v,se)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,se)|0,n=n+Math.imul(y,fe)|0,i=(i=i+Math.imul(y,ce)|0)+Math.imul(g,fe)|0,o=o+Math.imul(g,ce)|0,n=n+Math.imul(p,he)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(m,he)|0,o=o+Math.imul(m,le)|0;var xe=(c+(n=n+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,me)|0)+Math.imul(l,pe)|0))<<13)|0;c=((o=o+Math.imul(l,me)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(D,$),i=(i=Math.imul(D,q))+Math.imul(U,$)|0,o=Math.imul(U,q),n=n+Math.imul(L,V)|0,i=(i=i+Math.imul(L,W)|0)+Math.imul(F,V)|0,o=o+Math.imul(F,W)|0,n=n+Math.imul(N,Z)|0,i=(i=i+Math.imul(N,X)|0)+Math.imul(R,Z)|0,o=o+Math.imul(R,X)|0,n=n+Math.imul(P,Q)|0,i=(i=i+Math.imul(P,ee)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,ee)|0,n=n+Math.imul(A,re)|0,i=(i=i+Math.imul(A,ne)|0)+Math.imul(M,re)|0,o=o+Math.imul(M,ne)|0,n=n+Math.imul(T,oe)|0,i=(i=i+Math.imul(T,se)|0)+Math.imul(k,oe)|0,o=o+Math.imul(k,se)|0,n=n+Math.imul(v,fe)|0,i=(i=i+Math.imul(v,ce)|0)+Math.imul(_,fe)|0,o=o+Math.imul(_,ce)|0,n=n+Math.imul(y,he)|0,i=(i=i+Math.imul(y,le)|0)+Math.imul(g,he)|0,o=o+Math.imul(g,le)|0;var Ae=(c+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,me)|0)+Math.imul(m,pe)|0))<<13)|0;c=((o=o+Math.imul(m,me)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(D,V),i=(i=Math.imul(D,W))+Math.imul(U,V)|0,o=Math.imul(U,W),n=n+Math.imul(L,Z)|0,i=(i=i+Math.imul(L,X)|0)+Math.imul(F,Z)|0,o=o+Math.imul(F,X)|0,n=n+Math.imul(N,Q)|0,i=(i=i+Math.imul(N,ee)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(P,re)|0,i=(i=i+Math.imul(P,ne)|0)+Math.imul(C,re)|0,o=o+Math.imul(C,ne)|0,n=n+Math.imul(A,oe)|0,i=(i=i+Math.imul(A,se)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,se)|0,n=n+Math.imul(T,fe)|0,i=(i=i+Math.imul(T,ce)|0)+Math.imul(k,fe)|0,o=o+Math.imul(k,ce)|0,n=n+Math.imul(v,he)|0,i=(i=i+Math.imul(v,le)|0)+Math.imul(_,he)|0,o=o+Math.imul(_,le)|0;var Me=(c+(n=n+Math.imul(y,pe)|0)|0)+((8191&(i=(i=i+Math.imul(y,me)|0)+Math.imul(g,pe)|0))<<13)|0;c=((o=o+Math.imul(g,me)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(D,Z),i=(i=Math.imul(D,X))+Math.imul(U,Z)|0,o=Math.imul(U,X),n=n+Math.imul(L,Q)|0,i=(i=i+Math.imul(L,ee)|0)+Math.imul(F,Q)|0,o=o+Math.imul(F,ee)|0,n=n+Math.imul(N,re)|0,i=(i=i+Math.imul(N,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(P,oe)|0,i=(i=i+Math.imul(P,se)|0)+Math.imul(C,oe)|0,o=o+Math.imul(C,se)|0,n=n+Math.imul(A,fe)|0,i=(i=i+Math.imul(A,ce)|0)+Math.imul(M,fe)|0,o=o+Math.imul(M,ce)|0,n=n+Math.imul(T,he)|0,i=(i=i+Math.imul(T,le)|0)+Math.imul(k,he)|0,o=o+Math.imul(k,le)|0;var Se=(c+(n=n+Math.imul(v,pe)|0)|0)+((8191&(i=(i=i+Math.imul(v,me)|0)+Math.imul(_,pe)|0))<<13)|0;c=((o=o+Math.imul(_,me)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(D,Q),i=(i=Math.imul(D,ee))+Math.imul(U,Q)|0,o=Math.imul(U,ee),n=n+Math.imul(L,re)|0,i=(i=i+Math.imul(L,ne)|0)+Math.imul(F,re)|0,o=o+Math.imul(F,ne)|0,n=n+Math.imul(N,oe)|0,i=(i=i+Math.imul(N,se)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,se)|0,n=n+Math.imul(P,fe)|0,i=(i=i+Math.imul(P,ce)|0)+Math.imul(C,fe)|0,o=o+Math.imul(C,ce)|0,n=n+Math.imul(A,he)|0,i=(i=i+Math.imul(A,le)|0)+Math.imul(M,he)|0,o=o+Math.imul(M,le)|0;var Pe=(c+(n=n+Math.imul(T,pe)|0)|0)+((8191&(i=(i=i+Math.imul(T,me)|0)+Math.imul(k,pe)|0))<<13)|0;c=((o=o+Math.imul(k,me)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(D,re),i=(i=Math.imul(D,ne))+Math.imul(U,re)|0,o=Math.imul(U,ne),n=n+Math.imul(L,oe)|0,i=(i=i+Math.imul(L,se)|0)+Math.imul(F,oe)|0,o=o+Math.imul(F,se)|0,n=n+Math.imul(N,fe)|0,i=(i=i+Math.imul(N,ce)|0)+Math.imul(R,fe)|0,o=o+Math.imul(R,ce)|0,n=n+Math.imul(P,he)|0,i=(i=i+Math.imul(P,le)|0)+Math.imul(C,he)|0,o=o+Math.imul(C,le)|0;var Ce=(c+(n=n+Math.imul(A,pe)|0)|0)+((8191&(i=(i=i+Math.imul(A,me)|0)+Math.imul(M,pe)|0))<<13)|0;c=((o=o+Math.imul(M,me)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,n=Math.imul(D,oe),i=(i=Math.imul(D,se))+Math.imul(U,oe)|0,o=Math.imul(U,se),n=n+Math.imul(L,fe)|0,i=(i=i+Math.imul(L,ce)|0)+Math.imul(F,fe)|0,o=o+Math.imul(F,ce)|0,n=n+Math.imul(N,he)|0,i=(i=i+Math.imul(N,le)|0)+Math.imul(R,he)|0,o=o+Math.imul(R,le)|0;var Ie=(c+(n=n+Math.imul(P,pe)|0)|0)+((8191&(i=(i=i+Math.imul(P,me)|0)+Math.imul(C,pe)|0))<<13)|0;c=((o=o+Math.imul(C,me)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(D,fe),i=(i=Math.imul(D,ce))+Math.imul(U,fe)|0,o=Math.imul(U,ce),n=n+Math.imul(L,he)|0,i=(i=i+Math.imul(L,le)|0)+Math.imul(F,he)|0,o=o+Math.imul(F,le)|0;var Ne=(c+(n=n+Math.imul(N,pe)|0)|0)+((8191&(i=(i=i+Math.imul(N,me)|0)+Math.imul(R,pe)|0))<<13)|0;c=((o=o+Math.imul(R,me)|0)+(i>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,n=Math.imul(D,he),i=(i=Math.imul(D,le))+Math.imul(U,he)|0,o=Math.imul(U,le);var Re=(c+(n=n+Math.imul(L,pe)|0)|0)+((8191&(i=(i=i+Math.imul(L,me)|0)+Math.imul(F,pe)|0))<<13)|0;c=((o=o+Math.imul(F,me)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863;var Oe=(c+(n=Math.imul(D,pe))|0)+((8191&(i=(i=Math.imul(D,me))+Math.imul(U,pe)|0))<<13)|0;return c=((o=Math.imul(U,me))+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,f[0]=be,f[1]=ye,f[2]=ge,f[3]=we,f[4]=ve,f[5]=_e,f[6]=Ee,f[7]=Te,f[8]=ke,f[9]=xe,f[10]=Ae,f[11]=Me,f[12]=Se,f[13]=Pe,f[14]=Ce,f[15]=Ie,f[16]=Ne,f[17]=Re,f[18]=Oe,0!==c&&(f[19]=c,r.length++