@soloseng/ganache
Version:
A library and cli to create a local blockchain for fast Ethereum development.
2 lines • 4.18 MB
JavaScript
/*! For license information please see 0.js.LICENSE.txt */
exports.id=0,exports.ids=[0],exports.modules=[function(B,n,I){"use strict";var E=this&&this.__createBinding||(Object.create?function(B,n,I,E){void 0===E&&(E=I);var Q=Object.getOwnPropertyDescriptor(n,I);Q&&!("get"in Q?!n.__esModule:Q.writable||Q.configurable)||(Q={enumerable:!0,get:function(){return n[I]}}),Object.defineProperty(B,E,Q)}:function(B,n,I,E){void 0===E&&(E=I),B[E]=n[I]}),Q=this&&this.__exportStar||function(B,n){for(var I in B)"default"===I||Object.prototype.hasOwnProperty.call(n,I)||E(n,B,I)};Object.defineProperty(n,"__esModule",{value:!0}),n.toAscii=n.stripHexPrefix=n.padToEven=n.isHexString=n.isHexPrefixed=n.getKeys=n.getBinarySize=n.fromUtf8=n.fromAscii=n.arrayContainsArray=n.ssz=void 0,Q(I(85),n),Q(I(697),n),Q(I(178),n),Q(I(407),n),Q(I(699),n),Q(I(700),n),Q(I(47),n),n.ssz=I(316),Q(I(207),n),Q(I(731),n);var C=I(100);Object.defineProperty(n,"arrayContainsArray",{enumerable:!0,get:function(){return C.arrayContainsArray}}),Object.defineProperty(n,"fromAscii",{enumerable:!0,get:function(){return C.fromAscii}}),Object.defineProperty(n,"fromUtf8",{enumerable:!0,get:function(){return C.fromUtf8}}),Object.defineProperty(n,"getBinarySize",{enumerable:!0,get:function(){return C.getBinarySize}}),Object.defineProperty(n,"getKeys",{enumerable:!0,get:function(){return C.getKeys}}),Object.defineProperty(n,"isHexPrefixed",{enumerable:!0,get:function(){return C.isHexPrefixed}}),Object.defineProperty(n,"isHexString",{enumerable:!0,get:function(){return C.isHexString}}),Object.defineProperty(n,"padToEven",{enumerable:!0,get:function(){return C.padToEven}}),Object.defineProperty(n,"stripHexPrefix",{enumerable:!0,get:function(){return C.stripHexPrefix}}),Object.defineProperty(n,"toAscii",{enumerable:!0,get:function(){return C.toAscii}}),Q(I(732),n)},,function(B,n,I){"use strict";var E=this&&this.__createBinding||(Object.create?function(B,n,I,E){void 0===E&&(E=I),Object.defineProperty(B,E,{enumerable:!0,get:function(){return n[I]}})}:function(B,n,I,E){void 0===E&&(E=I),B[E]=n[I]}),Q=this&&this.__exportStar||function(B,n){for(var I in B)"default"===I||Object.prototype.hasOwnProperty.call(n,I)||E(n,B,I)};Object.defineProperty(n,"__esModule",{value:!0}),Q(I(138),n),Q(I(408),n),Q(I(42),n),Q(I(705),n),Q(I(186),n),Q(I(410),n),Q(I(411),n),Q(I(209),n)},function(B,n,I){"use strict";var E=this&&this.__createBinding||(Object.create?function(B,n,I,E){void 0===E&&(E=I),Object.defineProperty(B,E,{enumerable:!0,get:function(){return n[I]}})}:function(B,n,I,E){void 0===E&&(E=I),B[E]=n[I]}),Q=this&&this.__exportStar||function(B,n){for(var I in B)"default"===I||Object.prototype.hasOwnProperty.call(n,I)||E(n,B,I)};Object.defineProperty(n,"__esModule",{value:!0}),Q(I(105),n),Q(I(80),n),Q(I(37),n),Q(I(910),n),Q(I(187),n),Q(I(499),n),Q(I(500),n),Q(I(239),n)},(B,n)=>{"use strict";function encode(B){if(Array.isArray(B)){const n=[];let I=0;for(let E=0;E<B.length;E++){const Q=encode(B[E]);n.push(Q),I+=Q.length}return concatBytes(encodeLength(I,192),...n)}const n=toBytes(B);return 1===n.length&&n[0]<128?n:concatBytes(encodeLength(n.length,128),n)}function safeSlice(B,n,I){if(I>B.length)throw new Error("invalid RLP (safeSlice): end slice of Uint8Array out-of-bounds");return B.slice(n,I)}function decodeLength(B){if(0===B[0])throw new Error("invalid RLP: extra zeros");return parseHexByte(bytesToHex(B))}function encodeLength(B,n){if(B<56)return Uint8Array.from([B+n]);const I=numberToHex(B),E=numberToHex(n+55+I.length/2);return Uint8Array.from(hexToBytes(E+I))}function decode(B,n=!1){if(null==B||0===B.length)return Uint8Array.from([]);const I=_decode(toBytes(B));if(n)return I;if(0!==I.remainder.length)throw new Error("invalid RLP: remainder must be zero");return I.data}function _decode(B){let n,I,E,Q,C;const x=[],p=B[0];if(p<=127)return{data:B.slice(0,1),remainder:B.slice(1)};if(p<=183){if(n=p-127,E=128===p?Uint8Array.from([]):safeSlice(B,1,n),2===n&&E[0]<128)throw new Error("invalid RLP encoding: invalid prefix, single byte < 0x80 are not prefixed");return{data:E,remainder:B.slice(n)}}if(p<=191){if(I=p-182,B.length-1<I)throw new Error("invalid RLP: not enough bytes for string length");if(n=decodeLength(safeSlice(B,1,I)),n<=55)throw new Error("invalid RLP: expected string length to be greater than 55");return E=safeSlice(B,I,n+I),{data:E,remainder:B.slice(n+I)}}if(p<=247){for(n=p-191,Q=safeSlice(B,1,n);Q.length;)C=_decode(Q),x.push(C.data),Q=C.remainder;return{data:x,remainder:B.slice(n)}}{if(I=p-246,n=decodeLength(safeSlice(B,1,I)),n<56)throw new Error("invalid RLP: encoded list too short");const E=I+n;if(E>B.length)throw new Error("invalid RLP: total length is larger than the data");for(Q=safeSlice(B,I,E);Q.length;)C=_decode(Q),x.push(C.data),Q=C.remainder;return{data:x,remainder:B.slice(E)}}}Object.defineProperty(n,"__esModule",{value:!0}),n.RLP=n.utils=n.decode=n.encode=void 0,n.encode=encode,n.decode=decode;const I=Array.from({length:256},((B,n)=>n.toString(16).padStart(2,"0")));function bytesToHex(B){let n="";for(let E=0;E<B.length;E++)n+=I[B[E]];return n}function parseHexByte(B){const n=Number.parseInt(B,16);if(Number.isNaN(n))throw new Error("Invalid byte sequence");return n}function hexToBytes(B){if("string"!=typeof B)throw new TypeError("hexToBytes: expected string, got "+typeof B);if(B.length%2)throw new Error("hexToBytes: received invalid unpadded hex");const n=new Uint8Array(B.length/2);for(let I=0;I<n.length;I++){const E=2*I;n[I]=parseHexByte(B.slice(E,E+2))}return n}function concatBytes(...B){if(1===B.length)return B[0];const n=B.reduce(((B,n)=>B+n.length),0),I=new Uint8Array(n);for(let n=0,E=0;n<B.length;n++){const Q=B[n];I.set(Q,E),E+=Q.length}return I}function utf8ToBytes(B){return(new TextEncoder).encode(B)}function numberToHex(B){if(B<0)throw new Error("Invalid integer as argument, must be unsigned!");const n=B.toString(16);return n.length%2?`0${n}`:n}function isHexPrefixed(B){return B.length>=2&&"0"===B[0]&&"x"===B[1]}function toBytes(B){if(B instanceof Uint8Array)return B;if("string"==typeof B)return isHexPrefixed(B)?hexToBytes(function padToEven(B){return B.length%2?`0${B}`:B}(function stripHexPrefix(B){return"string"!=typeof B?B:isHexPrefixed(B)?B.slice(2):B}(B))):utf8ToBytes(B);if("number"==typeof B||"bigint"==typeof B)return B?hexToBytes(numberToHex(B)):Uint8Array.from([]);if(null==B)return Uint8Array.from([]);throw new Error("toBytes: received unsupported type "+typeof B)}n.utils={bytesToHex,concatBytes,hexToBytes,utf8ToBytes},n.RLP={encode,decode}},,(B,n,I)=>{try{var E=I(11);if("function"!=typeof E.inherits)throw"";B.exports=E.inherits}catch(n){B.exports=I(353)}},(B,n,I)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.EvmErrorResult=n.CodesizeExceedsMaximumError=n.INVALID_EOF_RESULT=n.INVALID_BYTECODE_RESULT=n.COOGResult=n.OOGResult=n.EVM=void 0;const E=I(10),Q=I(0),C=I(44),x=I(11),p=I(173),m=I(9),D=I(855),k=I(232),G=I(118),N=I(231),U=I(858),L=(0,C.debug)("evm"),q=(0,C.debug)("evm:gas"),H=new Function("try {return this===window;}catch(e){ return false;}");let J,T;!1===H()&&(J=I(488),T=J.init(J.BLS12_381));class EVM{constructor(B){if(this._isInitialized=!1,this.DEBUG=!1,this.events=new Q.AsyncEventEmitter,this._optsCached=B,this.eei=B.eei,this._transientStorage=new U.TransientStorage,B.common)this._common=B.common;else{const B=E.Chain.Mainnet;this._common=new E.Common({chain:B})}const n=[1153,1559,2315,2537,2565,2718,2929,2930,3074,3198,3529,3540,3541,3607,3651,3670,3855,3860,4399,4895,4844,5133];for(const B of this._common.eips())if(!n.includes(B))throw new Error(`EIP-${B} is not supported by the EVM`);if(!EVM.supportedHardforks.includes(this._common.hardfork()))throw new Error(`Hardfork ${this._common.hardfork()} not set as supported in supportedHardforks`);if(this._allowUnlimitedContractSize=B.allowUnlimitedContractSize??!1,this._customOpcodes=B.customOpcodes,this._customPrecompiles=B.customPrecompiles,this._common.on("hardforkChanged",(()=>{this.getActiveOpcodes(),this._precompiles=(0,N.getActivePrecompiles)(this._common,this._customPrecompiles)})),this.getActiveOpcodes(),this._precompiles=(0,N.getActivePrecompiles)(this._common,this._customPrecompiles),this._common.isActivatedEIP(2537)){if(!0===H())throw new Error("EIP-2537 is currently not supported in browsers");this._mcl=J}this._emit=(0,x.promisify)(this.events.emit.bind(this.events)),this.DEBUG=!1}get precompiles(){return this._precompiles}get opcodes(){return this._opcodes}static async create(B){const n=new this(B);return await n.init(),n}async init(){if(!this._isInitialized){if(this._common.isActivatedEIP(2537)){if(!0===H())throw new Error("EIP-2537 is currently not supported in browsers");{const B=this._mcl;await T,B.setMapToMode(B.IRTF),B.verifyOrderG1(1),B.verifyOrderG2(1)}}this._isInitialized=!0}}getActiveOpcodes(){const B=(0,G.getOpcodesForHF)(this._common,this._customOpcodes);return this._opcodes=B.opcodes,this._dynamicGasHandlers=B.dynamicGasHandlers,this._handlers=B.handlers,B.opcodes}async _executeCall(B){const n=await this.eei.getAccount(B.authcallOrigin??B.caller);let I;if(!B.delegatecall)try{await this._reduceSenderBalance(n,B)}catch(B){I=B}const E=await this.eei.getAccount(B.to);if(!B.delegatecall)try{await this._addToBalance(E,B)}catch(B){I=B}await this._loadCode(B);let Q,C=!1;return B.code&&0!==B.code.length||(C=!0,this.DEBUG&&L("Exit early on no code")),void 0!==I&&(C=!0,this.DEBUG&&L("Exit early on value transfer overflowed")),C?{execResult:{gasRefund:B.gasRefund,executionGasUsed:BigInt(0),exceptionError:I,returnValue:Buffer.alloc(0)}}:(B.isCompiled?(this.DEBUG&&L("Run precompile"),Q=await this.runPrecompile(B.code,B.data,B.gasLimit),Q.gasRefund=B.gasRefund):(this.DEBUG&&L("Start bytecode processing..."),Q=await this.runInterpreter(B)),0===B.depth&&this.postMessageCleanup(),{execResult:Q})}async _executeCreate(B){const n=await this.eei.getAccount(B.caller);if(await this._reduceSenderBalance(n,B),this._common.isActivatedEIP(3860)&&B.data.length>Number(this._common.param("vm","maxInitCodeSize")))return{createdAddress:B.to,execResult:{returnValue:Buffer.alloc(0),exceptionError:new m.EvmError(m.ERROR.INITCODE_SIZE_VIOLATION),executionGasUsed:B.gasLimit}};B.code=B.data,B.data=Buffer.alloc(0),B.to=await this._generateAddress(B),this.DEBUG&&L(`Generated CREATE contract address ${B.to}`);let I=await this.eei.getAccount(B.to);if(I.nonce&&I.nonce>BigInt(0)||!I.codeHash.equals(Q.KECCAK256_NULL))return this.DEBUG&&L("Returning on address collision"),{createdAddress:B.to,execResult:{returnValue:Buffer.alloc(0),exceptionError:new m.EvmError(m.ERROR.CREATE_COLLISION),executionGasUsed:B.gasLimit}};await this.eei.clearContractStorage(B.to);const C={address:B.to,code:B.code};let x;await this._emit("newContract",C),I=await this.eei.getAccount(B.to),this._common.gteHardfork(E.Hardfork.SpuriousDragon)&&(I.nonce+=BigInt(1));try{await this._addToBalance(I,B)}catch(B){x=B}let D=!1;if(void 0!==B.code&&0!==B.code.length||(D=!0,this.DEBUG&&L("Exit early on no code")),void 0!==x&&(D=!0,this.DEBUG&&L("Exit early on value transfer overflowed")),D)return{createdAddress:B.to,execResult:{executionGasUsed:BigInt(0),gasRefund:B.gasRefund,exceptionError:x,returnValue:Buffer.alloc(0)}};this.DEBUG&&L("Start bytecode processing...");let k=await this.runInterpreter(B),G=k.executionGasUsed,N=BigInt(0);k.exceptionError||(N=BigInt(k.returnValue.length)*BigInt(this._common.param("gasPrices","createData")),G+=N,this.DEBUG&&q(`Add return value size fee (${N} to gas used (-> ${G}))`));let U=!0;!k.exceptionError&&this._common.gteHardfork(E.Hardfork.SpuriousDragon)&&k.returnValue.length>Number(this._common.param("vm","maxCodeSize"))&&(U=!1);let H=!1;if(G<=B.gasLimit&&(this._allowUnlimitedContractSize||U))if(this._common.isActivatedEIP(3541)&&k.returnValue[0]===p.EOF.FORMAT){this._common.isActivatedEIP(3540)||(k={...k,...INVALID_BYTECODE_RESULT(B.gasLimit)});const n=p.EOF.codeAnalysis(k.returnValue);if(void 0===n?.code)k={...k,...INVALID_EOF_RESULT(B.gasLimit)};else if(this._common.isActivatedEIP(3670)){const I=n.data>0?10:7;p.EOF.validOpcodes(k.returnValue.slice(I,I+n.code))?k.executionGasUsed=G:k={...k,...INVALID_EOF_RESULT(B.gasLimit)}}}else k.executionGasUsed=G;else this._common.gteHardfork(E.Hardfork.Homestead)?(this.DEBUG&&L("Not enough gas or code size not allowed (>= Homestead)"),k={...k,...CodesizeExceedsMaximumError(B.gasLimit)}):(this.DEBUG&&L("Not enough gas or code size not allowed (Frontier)"),G-N<=B.gasLimit?(k={...k,...COOGResult(G-N)},H=!0):k={...k,...OOGResult(B.gasLimit)});if(k.exceptionError||void 0===k.returnValue||0===k.returnValue.length){if(H&&!this._common.gteHardfork(E.Hardfork.Homestead)){const n=await this.eei.getAccount(B.to);await this.eei.putAccount(B.to,n)}}else await this.eei.putContractCode(B.to,k.returnValue),this.DEBUG&&L("Code saved on new contract creation");return{createdAddress:B.to,execResult:k}}async runInterpreter(B,n={}){const I={address:B.to??Q.Address.zero(),caller:B.caller??Q.Address.zero(),callData:B.data??Buffer.from([0]),callValue:B.value??BigInt(0),code:B.code,isStatic:B.isStatic??!1,depth:B.depth??0,gasPrice:this._tx.gasPrice,origin:this._tx.origin??B.caller??Q.Address.zero(),block:this._block??defaultBlock(),contract:await this.eei.getAccount(B.to??Q.Address.zero()),codeAddress:B.codeAddress,gasRefund:B.gasRefund,containerCode:B.containerCode,versionedHashes:B.versionedHashes??[]},E=new D.Interpreter(this,this.eei,I,B.gasLimit);B.selfdestruct&&(E._result.selfdestruct=B.selfdestruct);const C=await E.run(B.code,n);let x=E._result,p=B.gasLimit-C.runState.gasLeft;return C.exceptionError&&(C.exceptionError.error!==m.ERROR.REVERT&&C.exceptionError.error!==m.ERROR.INVALID_EOF_FORMAT&&(p=B.gasLimit),x={...x,logs:[],selfdestruct:{}}),{...x,runState:{...C.runState,...x,...E._env},exceptionError:C.exceptionError,gas:C.runState?.gasLeft,executionGasUsed:p,gasRefund:C.runState.gasRefund,returnValue:x.returnValue?x.returnValue:Buffer.alloc(0)}}async runCall(B){let n,I,C=B.message;if(!C){this._block=B.block??defaultBlock(),this._tx={gasPrice:B.gasPrice??BigInt(0),origin:B.origin??B.caller??Q.Address.zero()};const I=B.caller??Q.Address.zero(),E=B.value??BigInt(0);!0===B.skipBalance&&(n=await this.eei.getAccount(I),n.balance<E&&(n.balance=E,await this.eei.putAccount(I,n))),C=new k.Message({caller:I,gasLimit:B.gasLimit??BigInt(16777215),to:B.to,value:E,data:B.data,code:B.code,depth:B.depth,isCompiled:B.isCompiled,isStatic:B.isStatic,salt:B.salt,selfdestruct:B.selfdestruct??{},delegatecall:B.delegatecall,versionedHashes:B.versionedHashes})}if(0===C.depth&&(n||(n=await this.eei.getAccount(C.caller)),n.nonce++,await this.eei.putAccount(C.caller,n),this.DEBUG&&L(`Update fromAccount (caller) nonce (-> ${n.nonce}))`)),await this._emit("beforeMessage",C),C.to||!0!==this._common.isActivatedEIP(2929)||(C.code=C.data,this.eei.addWarmedAddress((await this._generateAddress(C)).buf)),await this.eei.checkpoint(),this._transientStorage.checkpoint(),this.DEBUG&&(L("-".repeat(100)),L("message checkpoint")),this.DEBUG){const{caller:B,gasLimit:n,to:I,value:E,delegatecall:Q}=C;L(`New message caller=${B} gasLimit=${n} to=${I?.toString()??"none"} value=${E} delegatecall=${Q?"yes":"no"}`)}if(C.to?(this.DEBUG&&L(`Message CALL execution (to: ${C.to})`),I=await this._executeCall(C)):(this.DEBUG&&L("Message CREATE execution (to undefined)"),I=await this._executeCreate(C)),this.DEBUG){const{executionGasUsed:B,exceptionError:n,returnValue:E}=I.execResult;L(`Received message execResult: [ gasUsed=${B} exceptionError=${n?`'${n.error}'`:"none"} returnValue=0x${(0,Q.short)(E)} gasRefund=${I.execResult.gasRefund??0} ]`)}const x=I.execResult.exceptionError;return x&&x.error!==m.ERROR.CODESTORE_OUT_OF_GAS&&(I.execResult.selfdestruct={},I.execResult.gasRefund=BigInt(0)),x&&(this._common.gteHardfork(E.Hardfork.Homestead)||x.error!==m.ERROR.CODESTORE_OUT_OF_GAS)?(I.execResult.logs=[],await this.eei.revert(),this._transientStorage.revert(),this.DEBUG&&L("message checkpoint reverted")):(await this.eei.commit(),this._transientStorage.commit(),this.DEBUG&&L("message checkpoint committed")),await this._emit("afterMessage",I),I}async runCode(B){this._block=B.block??defaultBlock(),this._tx={gasPrice:B.gasPrice??BigInt(0),origin:B.origin??B.caller??Q.Address.zero()};const n=new k.Message({code:B.code,data:B.data,gasLimit:B.gasLimit,to:B.address??Q.Address.zero(),caller:B.caller,value:B.value,depth:B.depth,selfdestruct:B.selfdestruct??{},isStatic:B.isStatic,versionedHashes:B.versionedHashes});return this.runInterpreter(n,{pc:B.pc})}getPrecompile(B){return this.precompiles.get(B.buf.toString("hex"))}runPrecompile(B,n,I){if("function"!=typeof B)throw new Error("Invalid precompile");return B({data:n,gasLimit:I,_common:this._common,_EVM:this})}async _loadCode(B){if(!B.code){const n=this.getPrecompile(B.codeAddress);n?(B.code=n,B.isCompiled=!0):(B.containerCode=await this.eei.getContractCode(B.codeAddress),B.isCompiled=!1,this._common.isActivatedEIP(3540)?B.code=(0,p.getEOFCode)(B.containerCode):B.code=B.containerCode)}}async _generateAddress(B){let n;if(B.salt)n=(0,Q.generateAddress2)(B.caller.buf,B.salt,B.code);else{const I=(await this.eei.getAccount(B.caller)).nonce-BigInt(1);n=(0,Q.generateAddress)(B.caller.buf,(0,Q.bigIntToBuffer)(I))}return new Q.Address(n)}async _reduceSenderBalance(B,n){if(B.balance-=n.value,B.balance<BigInt(0))throw new m.EvmError(m.ERROR.INSUFFICIENT_BALANCE);const I=this.eei.putAccount(n.authcallOrigin??n.caller,B);return this.DEBUG&&L(`Reduced sender (${n.caller}) balance (-> ${B.balance})`),I}async _addToBalance(B,n){const I=B.balance+n.value;if(I>Q.MAX_INTEGER)throw new m.EvmError(m.ERROR.VALUE_OVERFLOW);B.balance=I;const E=this.eei.putAccount(n.to,B);return this.DEBUG&&L(`Added toAccount (${n.to}) balance (-> ${B.balance})`),E}async _touchAccount(B){const n=await this.eei.getAccount(B);return this.eei.putAccount(B,n)}postMessageCleanup(){this._common.isActivatedEIP(1153)&&this._transientStorage.clear()}copy(){const B=this._common.copy();B.setHardfork(this._common.hardfork());const n={...this._optsCached,common:B,eei:this.eei.copy()};return n.eei._common=B,new EVM(n)}}function OOGResult(B){return{returnValue:Buffer.alloc(0),executionGasUsed:B,exceptionError:new m.EvmError(m.ERROR.OUT_OF_GAS)}}function COOGResult(B){return{returnValue:Buffer.alloc(0),executionGasUsed:B,exceptionError:new m.EvmError(m.ERROR.CODESTORE_OUT_OF_GAS)}}function INVALID_BYTECODE_RESULT(B){return{returnValue:Buffer.alloc(0),executionGasUsed:B,exceptionError:new m.EvmError(m.ERROR.INVALID_BYTECODE_RESULT)}}function INVALID_EOF_RESULT(B){return{returnValue:Buffer.alloc(0),executionGasUsed:B,exceptionError:new m.EvmError(m.ERROR.INVALID_EOF_FORMAT)}}function CodesizeExceedsMaximumError(B){return{returnValue:Buffer.alloc(0),executionGasUsed:B,exceptionError:new m.EvmError(m.ERROR.CODESIZE_EXCEEDS_MAXIMUM)}}function defaultBlock(){return{header:{number:BigInt(0),cliqueSigner:()=>Q.Address.zero(),coinbase:Q.Address.zero(),timestamp:BigInt(0),difficulty:BigInt(0),prevRandao:(0,Q.zeros)(32),gasLimit:BigInt(0),baseFeePerGas:void 0}}}n.EVM=EVM,EVM.supportedHardforks=[E.Hardfork.Chainstart,E.Hardfork.Homestead,E.Hardfork.Dao,E.Hardfork.TangerineWhistle,E.Hardfork.SpuriousDragon,E.Hardfork.Byzantium,E.Hardfork.Constantinople,E.Hardfork.Petersburg,E.Hardfork.Istanbul,E.Hardfork.MuirGlacier,E.Hardfork.Berlin,E.Hardfork.London,E.Hardfork.ArrowGlacier,E.Hardfork.GrayGlacier,E.Hardfork.MergeForkIdTransition,E.Hardfork.Merge,E.Hardfork.Shanghai,E.Hardfork.ShardingForkDev],n.OOGResult=OOGResult,n.COOGResult=COOGResult,n.INVALID_BYTECODE_RESULT=INVALID_BYTECODE_RESULT,n.INVALID_EOF_RESULT=INVALID_EOF_RESULT,n.CodesizeExceedsMaximumError=CodesizeExceedsMaximumError,n.EvmErrorResult=function EvmErrorResult(B,n){return{returnValue:Buffer.alloc(0),executionGasUsed:n,exceptionError:B}}},function(B,n,I){!function(B,n){"use strict";function assert(B,n){if(!B)throw new Error(n||"Assertion failed")}function inherits(B,n){B.super_=n;var TempCtor=function(){};TempCtor.prototype=n.prototype,B.prototype=new TempCtor,B.prototype.constructor=B}function BN(B,n,I){if(BN.isBN(B))return B;this.negative=0,this.words=null,this.length=0,this.red=null,null!==B&&("le"!==n&&"be"!==n||(I=n,n=10),this._init(B||0,n||10,I||"be"))}var E;"object"==typeof B?B.exports=BN:n.BN=BN,BN.BN=BN,BN.wordSize=26;try{E="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:I(22).Buffer}catch(B){}function parseHex4Bits(B,n){var I=B.charCodeAt(n);return I>=65&&I<=70?I-55:I>=97&&I<=102?I-87:I-48&15}function parseHexByte(B,n,I){var E=parseHex4Bits(B,I);return I-1>=n&&(E|=parseHex4Bits(B,I-1)<<4),E}function parseBase(B,n,I,E){for(var Q=0,C=Math.min(B.length,I),x=n;x<C;x++){var p=B.charCodeAt(x)-48;Q*=E,Q+=p>=49?p-49+10:p>=17?p-17+10:p}return Q}BN.isBN=function isBN(B){return B instanceof BN||null!==B&&"object"==typeof B&&B.constructor.wordSize===BN.wordSize&&Array.isArray(B.words)},BN.max=function max(B,n){return B.cmp(n)>0?B:n},BN.min=function min(B,n){return B.cmp(n)<0?B:n},BN.prototype._init=function init(B,n,I){if("number"==typeof B)return this._initNumber(B,n,I);if("object"==typeof B)return this._initArray(B,n,I);"hex"===n&&(n=16),assert(n===(0|n)&&n>=2&&n<=36);var E=0;"-"===(B=B.toString().replace(/\s+/g,""))[0]&&(E++,this.negative=1),E<B.length&&(16===n?this._parseHex(B,E,I):(this._parseBase(B,n,E),"le"===I&&this._initArray(this.toArray(),n,I)))},BN.prototype._initNumber=function _initNumber(B,n,I){B<0&&(this.negative=1,B=-B),B<67108864?(this.words=[67108863&B],this.length=1):B<4503599627370496?(this.words=[67108863&B,B/67108864&67108863],this.length=2):(assert(B<9007199254740992),this.words=[67108863&B,B/67108864&67108863,1],this.length=3),"le"===I&&this._initArray(this.toArray(),n,I)},BN.prototype._initArray=function _initArray(B,n,I){if(assert("number"==typeof B.length),B.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(B.length/3),this.words=new Array(this.length);for(var E=0;E<this.length;E++)this.words[E]=0;var Q,C,x=0;if("be"===I)for(E=B.length-1,Q=0;E>=0;E-=3)C=B[E]|B[E-1]<<8|B[E-2]<<16,this.words[Q]|=C<<x&67108863,this.words[Q+1]=C>>>26-x&67108863,(x+=24)>=26&&(x-=26,Q++);else if("le"===I)for(E=0,Q=0;E<B.length;E+=3)C=B[E]|B[E+1]<<8|B[E+2]<<16,this.words[Q]|=C<<x&67108863,this.words[Q+1]=C>>>26-x&67108863,(x+=24)>=26&&(x-=26,Q++);return this.strip()},BN.prototype._parseHex=function _parseHex(B,n,I){this.length=Math.ceil((B.length-n)/6),this.words=new Array(this.length);for(var E=0;E<this.length;E++)this.words[E]=0;var Q,C=0,x=0;if("be"===I)for(E=B.length-1;E>=n;E-=2)Q=parseHexByte(B,n,E)<<C,this.words[x]|=67108863&Q,C>=18?(C-=18,x+=1,this.words[x]|=Q>>>26):C+=8;else for(E=(B.length-n)%2==0?n+1:n;E<B.length;E+=2)Q=parseHexByte(B,n,E)<<C,this.words[x]|=67108863&Q,C>=18?(C-=18,x+=1,this.words[x]|=Q>>>26):C+=8;this.strip()},BN.prototype._parseBase=function _parseBase(B,n,I){this.words=[0],this.length=1;for(var E=0,Q=1;Q<=67108863;Q*=n)E++;E--,Q=Q/n|0;for(var C=B.length-I,x=C%E,p=Math.min(C,C-x)+I,m=0,D=I;D<p;D+=E)m=parseBase(B,D,D+E,n),this.imuln(Q),this.words[0]+m<67108864?this.words[0]+=m:this._iaddn(m);if(0!==x){var k=1;for(m=parseBase(B,D,B.length,n),D=0;D<x;D++)k*=n;this.imuln(k),this.words[0]+m<67108864?this.words[0]+=m:this._iaddn(m)}this.strip()},BN.prototype.copy=function copy(B){B.words=new Array(this.length);for(var n=0;n<this.length;n++)B.words[n]=this.words[n];B.length=this.length,B.negative=this.negative,B.red=this.red},BN.prototype.clone=function clone(){var B=new BN(null);return this.copy(B),B},BN.prototype._expand=function _expand(B){for(;this.length<B;)this.words[this.length++]=0;return this},BN.prototype.strip=function strip(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},BN.prototype._normSign=function _normSign(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},BN.prototype.inspect=function inspect(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var Q=["","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"],C=[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],x=[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 smallMulTo(B,n,I){I.negative=n.negative^B.negative;var E=B.length+n.length|0;I.length=E,E=E-1|0;var Q=0|B.words[0],C=0|n.words[0],x=Q*C,p=67108863&x,m=x/67108864|0;I.words[0]=p;for(var D=1;D<E;D++){for(var k=m>>>26,G=67108863&m,N=Math.min(D,n.length-1),U=Math.max(0,D-B.length+1);U<=N;U++){var L=D-U|0;k+=(x=(Q=0|B.words[L])*(C=0|n.words[U])+G)/67108864|0,G=67108863&x}I.words[D]=0|G,m=0|k}return 0!==m?I.words[D]=0|m:I.length--,I.strip()}BN.prototype.toString=function toString(B,n){var I;if(n=0|n||1,16===(B=B||10)||"hex"===B){I="";for(var E=0,p=0,m=0;m<this.length;m++){var D=this.words[m],k=(16777215&(D<<E|p)).toString(16);I=0!==(p=D>>>24-E&16777215)||m!==this.length-1?Q[6-k.length]+k+I:k+I,(E+=2)>=26&&(E-=26,m--)}for(0!==p&&(I=p.toString(16)+I);I.length%n!=0;)I="0"+I;return 0!==this.negative&&(I="-"+I),I}if(B===(0|B)&&B>=2&&B<=36){var G=C[B],N=x[B];I="";var U=this.clone();for(U.negative=0;!U.isZero();){var L=U.modn(N).toString(B);I=(U=U.idivn(N)).isZero()?L+I:Q[G-L.length]+L+I}for(this.isZero()&&(I="0"+I);I.length%n!=0;)I="0"+I;return 0!==this.negative&&(I="-"+I),I}assert(!1,"Base should be between 2 and 36")},BN.prototype.toNumber=function toNumber(){var B=this.words[0];return 2===this.length?B+=67108864*this.words[1]:3===this.length&&1===this.words[2]?B+=4503599627370496+67108864*this.words[1]:this.length>2&&assert(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-B:B},BN.prototype.toJSON=function toJSON(){return this.toString(16)},BN.prototype.toBuffer=function toBuffer(B,n){return assert(void 0!==E),this.toArrayLike(E,B,n)},BN.prototype.toArray=function toArray(B,n){return this.toArrayLike(Array,B,n)},BN.prototype.toArrayLike=function toArrayLike(B,n,I){var E=this.byteLength(),Q=I||Math.max(1,E);assert(E<=Q,"byte array longer than desired length"),assert(Q>0,"Requested array length <= 0"),this.strip();var C,x,p="le"===n,m=new B(Q),D=this.clone();if(p){for(x=0;!D.isZero();x++)C=D.andln(255),D.iushrn(8),m[x]=C;for(;x<Q;x++)m[x]=0}else{for(x=0;x<Q-E;x++)m[x]=0;for(x=0;!D.isZero();x++)C=D.andln(255),D.iushrn(8),m[Q-x-1]=C}return m},Math.clz32?BN.prototype._countBits=function _countBits(B){return 32-Math.clz32(B)}:BN.prototype._countBits=function _countBits(B){var n=B,I=0;return n>=4096&&(I+=13,n>>>=13),n>=64&&(I+=7,n>>>=7),n>=8&&(I+=4,n>>>=4),n>=2&&(I+=2,n>>>=2),I+n},BN.prototype._zeroBits=function _zeroBits(B){if(0===B)return 26;var n=B,I=0;return 0==(8191&n)&&(I+=13,n>>>=13),0==(127&n)&&(I+=7,n>>>=7),0==(15&n)&&(I+=4,n>>>=4),0==(3&n)&&(I+=2,n>>>=2),0==(1&n)&&I++,I},BN.prototype.bitLength=function bitLength(){var B=this.words[this.length-1],n=this._countBits(B);return 26*(this.length-1)+n},BN.prototype.zeroBits=function zeroBits(){if(this.isZero())return 0;for(var B=0,n=0;n<this.length;n++){var I=this._zeroBits(this.words[n]);if(B+=I,26!==I)break}return B},BN.prototype.byteLength=function byteLength(){return Math.ceil(this.bitLength()/8)},BN.prototype.toTwos=function toTwos(B){return 0!==this.negative?this.abs().inotn(B).iaddn(1):this.clone()},BN.prototype.fromTwos=function fromTwos(B){return this.testn(B-1)?this.notn(B).iaddn(1).ineg():this.clone()},BN.prototype.isNeg=function isNeg(){return 0!==this.negative},BN.prototype.neg=function neg(){return this.clone().ineg()},BN.prototype.ineg=function ineg(){return this.isZero()||(this.negative^=1),this},BN.prototype.iuor=function iuor(B){for(;this.length<B.length;)this.words[this.length++]=0;for(var n=0;n<B.length;n++)this.words[n]=this.words[n]|B.words[n];return this.strip()},BN.prototype.ior=function ior(B){return assert(0==(this.negative|B.negative)),this.iuor(B)},BN.prototype.or=function or(B){return this.length>B.length?this.clone().ior(B):B.clone().ior(this)},BN.prototype.uor=function uor(B){return this.length>B.length?this.clone().iuor(B):B.clone().iuor(this)},BN.prototype.iuand=function iuand(B){var n;n=this.length>B.length?B:this;for(var I=0;I<n.length;I++)this.words[I]=this.words[I]&B.words[I];return this.length=n.length,this.strip()},BN.prototype.iand=function iand(B){return assert(0==(this.negative|B.negative)),this.iuand(B)},BN.prototype.and=function and(B){return this.length>B.length?this.clone().iand(B):B.clone().iand(this)},BN.prototype.uand=function uand(B){return this.length>B.length?this.clone().iuand(B):B.clone().iuand(this)},BN.prototype.iuxor=function iuxor(B){var n,I;this.length>B.length?(n=this,I=B):(n=B,I=this);for(var E=0;E<I.length;E++)this.words[E]=n.words[E]^I.words[E];if(this!==n)for(;E<n.length;E++)this.words[E]=n.words[E];return this.length=n.length,this.strip()},BN.prototype.ixor=function ixor(B){return assert(0==(this.negative|B.negative)),this.iuxor(B)},BN.prototype.xor=function xor(B){return this.length>B.length?this.clone().ixor(B):B.clone().ixor(this)},BN.prototype.uxor=function uxor(B){return this.length>B.length?this.clone().iuxor(B):B.clone().iuxor(this)},BN.prototype.inotn=function inotn(B){assert("number"==typeof B&&B>=0);var n=0|Math.ceil(B/26),I=B%26;this._expand(n),I>0&&n--;for(var E=0;E<n;E++)this.words[E]=67108863&~this.words[E];return I>0&&(this.words[E]=~this.words[E]&67108863>>26-I),this.strip()},BN.prototype.notn=function notn(B){return this.clone().inotn(B)},BN.prototype.setn=function setn(B,n){assert("number"==typeof B&&B>=0);var I=B/26|0,E=B%26;return this._expand(I+1),this.words[I]=n?this.words[I]|1<<E:this.words[I]&~(1<<E),this.strip()},BN.prototype.iadd=function iadd(B){var n,I,E;if(0!==this.negative&&0===B.negative)return this.negative=0,n=this.isub(B),this.negative^=1,this._normSign();if(0===this.negative&&0!==B.negative)return B.negative=0,n=this.isub(B),B.negative=1,n._normSign();this.length>B.length?(I=this,E=B):(I=B,E=this);for(var Q=0,C=0;C<E.length;C++)n=(0|I.words[C])+(0|E.words[C])+Q,this.words[C]=67108863&n,Q=n>>>26;for(;0!==Q&&C<I.length;C++)n=(0|I.words[C])+Q,this.words[C]=67108863&n,Q=n>>>26;if(this.length=I.length,0!==Q)this.words[this.length]=Q,this.length++;else if(I!==this)for(;C<I.length;C++)this.words[C]=I.words[C];return this},BN.prototype.add=function add(B){var n;return 0!==B.negative&&0===this.negative?(B.negative=0,n=this.sub(B),B.negative^=1,n):0===B.negative&&0!==this.negative?(this.negative=0,n=B.sub(this),this.negative=1,n):this.length>B.length?this.clone().iadd(B):B.clone().iadd(this)},BN.prototype.isub=function isub(B){if(0!==B.negative){B.negative=0;var n=this.iadd(B);return B.negative=1,n._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(B),this.negative=1,this._normSign();var I,E,Q=this.cmp(B);if(0===Q)return this.negative=0,this.length=1,this.words[0]=0,this;Q>0?(I=this,E=B):(I=B,E=this);for(var C=0,x=0;x<E.length;x++)C=(n=(0|I.words[x])-(0|E.words[x])+C)>>26,this.words[x]=67108863&n;for(;0!==C&&x<I.length;x++)C=(n=(0|I.words[x])+C)>>26,this.words[x]=67108863&n;if(0===C&&x<I.length&&I!==this)for(;x<I.length;x++)this.words[x]=I.words[x];return this.length=Math.max(this.length,x),I!==this&&(this.negative=1),this.strip()},BN.prototype.sub=function sub(B){return this.clone().isub(B)};var p=function comb10MulTo(B,n,I){var E,Q,C,x=B.words,p=n.words,m=I.words,D=0,k=0|x[0],G=8191&k,N=k>>>13,U=0|x[1],L=8191&U,q=U>>>13,H=0|x[2],J=8191&H,T=H>>>13,Y=0|x[3],O=8191&Y,P=Y>>>13,z=0|x[4],j=8191&z,W=z>>>13,V=0|x[5],X=8191&V,$=V>>>13,AA=0|x[6],eA=8191&AA,aA=AA>>>13,tA=0|x[7],iA=8191&tA,oA=tA>>>13,gA=0|x[8],rA=8191&gA,cA=gA>>>13,BA=0|x[9],nA=8191&BA,IA=BA>>>13,sA=0|p[0],dA=8191&sA,fA=sA>>>13,EA=0|p[1],QA=8191&EA,CA=EA>>>13,bA=0|p[2],lA=8191&bA,hA=bA>>>13,uA=0|p[3],xA=8191&uA,pA=uA>>>13,wA=0|p[4],mA=8191&wA,yA=wA>>>13,DA=0|p[5],kA=8191&DA,MA=DA>>>13,SA=0|p[6],GA=8191&SA,FA=SA>>>13,NA=0|p[7],UA=8191&NA,RA=NA>>>13,vA=0|p[8],LA=8191&vA,qA=vA>>>13,HA=0|p[9],JA=8191&HA,TA=HA>>>13;I.negative=B.negative^n.negative,I.length=19;var YA=(D+(E=Math.imul(G,dA))|0)+((8191&(Q=(Q=Math.imul(G,fA))+Math.imul(N,dA)|0))<<13)|0;D=((C=Math.imul(N,fA))+(Q>>>13)|0)+(YA>>>26)|0,YA&=67108863,E=Math.imul(L,dA),Q=(Q=Math.imul(L,fA))+Math.imul(q,dA)|0,C=Math.imul(q,fA);var _A=(D+(E=E+Math.imul(G,QA)|0)|0)+((8191&(Q=(Q=Q+Math.imul(G,CA)|0)+Math.imul(N,QA)|0))<<13)|0;D=((C=C+Math.imul(N,CA)|0)+(Q>>>13)|0)+(_A>>>26)|0,_A&=67108863,E=Math.imul(J,dA),Q=(Q=Math.imul(J,fA))+Math.imul(T,dA)|0,C=Math.imul(T,fA),E=E+Math.imul(L,QA)|0,Q=(Q=Q+Math.imul(L,CA)|0)+Math.imul(q,QA)|0,C=C+Math.imul(q,CA)|0;var KA=(D+(E=E+Math.imul(G,lA)|0)|0)+((8191&(Q=(Q=Q+Math.imul(G,hA)|0)+Math.imul(N,lA)|0))<<13)|0;D=((C=C+Math.imul(N,hA)|0)+(Q>>>13)|0)+(KA>>>26)|0,KA&=67108863,E=Math.imul(O,dA),Q=(Q=Math.imul(O,fA))+Math.imul(P,dA)|0,C=Math.imul(P,fA),E=E+Math.imul(J,QA)|0,Q=(Q=Q+Math.imul(J,CA)|0)+Math.imul(T,QA)|0,C=C+Math.imul(T,CA)|0,E=E+Math.imul(L,lA)|0,Q=(Q=Q+Math.imul(L,hA)|0)+Math.imul(q,lA)|0,C=C+Math.imul(q,hA)|0;var ZA=(D+(E=E+Math.imul(G,xA)|0)|0)+((8191&(Q=(Q=Q+Math.imul(G,pA)|0)+Math.imul(N,xA)|0))<<13)|0;D=((C=C+Math.imul(N,pA)|0)+(Q>>>13)|0)+(ZA>>>26)|0,ZA&=67108863,E=Math.imul(j,dA),Q=(Q=Math.imul(j,fA))+Math.imul(W,dA)|0,C=Math.imul(W,fA),E=E+Math.imul(O,QA)|0,Q=(Q=Q+Math.imul(O,CA)|0)+Math.imul(P,QA)|0,C=C+Math.imul(P,CA)|0,E=E+Math.imul(J,lA)|0,Q=(Q=Q+Math.imul(J,hA)|0)+Math.imul(T,lA)|0,C=C+Math.imul(T,hA)|0,E=E+Math.imul(L,xA)|0,Q=(Q=Q+Math.imul(L,pA)|0)+Math.imul(q,xA)|0,C=C+Math.imul(q,pA)|0;var OA=(D+(E=E+Math.imul(G,mA)|0)|0)+((8191&(Q=(Q=Q+Math.imul(G,yA)|0)+Math.imul(N,mA)|0))<<13)|0;D=((C=C+Math.imul(N,yA)|0)+(Q>>>13)|0)+(OA>>>26)|0,OA&=67108863,E=Math.imul(X,dA),Q=(Q=Math.imul(X,fA))+Math.imul($,dA)|0,C=Math.imul($,fA),E=E+Math.imul(j,QA)|0,Q=(Q=Q+Math.imul(j,CA)|0)+Math.imul(W,QA)|0,C=C+Math.imul(W,CA)|0,E=E+Math.imul(O,lA)|0,Q=(Q=Q+Math.imul(O,hA)|0)+Math.imul(P,lA)|0,C=C+Math.imul(P,hA)|0,E=E+Math.imul(J,xA)|0,Q=(Q=Q+Math.imul(J,pA)|0)+Math.imul(T,xA)|0,C=C+Math.imul(T,pA)|0,E=E+Math.imul(L,mA)|0,Q=(Q=Q+Math.imul(L,yA)|0)+Math.imul(q,mA)|0,C=C+Math.imul(q,yA)|0;var PA=(D+(E=E+Math.imul(G,kA)|0)|0)+((8191&(Q=(Q=Q+Math.imul(G,MA)|0)+Math.imul(N,kA)|0))<<13)|0;D=((C=C+Math.imul(N,MA)|0)+(Q>>>13)|0)+(PA>>>26)|0,PA&=67108863,E=Math.imul(eA,dA),Q=(Q=Math.imul(eA,fA))+Math.imul(aA,dA)|0,C=Math.imul(aA,fA),E=E+Math.imul(X,QA)|0,Q=(Q=Q+Math.imul(X,CA)|0)+Math.imul($,QA)|0,C=C+Math.imul($,CA)|0,E=E+Math.imul(j,lA)|0,Q=(Q=Q+Math.imul(j,hA)|0)+Math.imul(W,lA)|0,C=C+Math.imul(W,hA)|0,E=E+Math.imul(O,xA)|0,Q=(Q=Q+Math.imul(O,pA)|0)+Math.imul(P,xA)|0,C=C+Math.imul(P,pA)|0,E=E+Math.imul(J,mA)|0,Q=(Q=Q+Math.imul(J,yA)|0)+Math.imul(T,mA)|0,C=C+Math.imul(T,yA)|0,E=E+Math.imul(L,kA)|0,Q=(Q=Q+Math.imul(L,MA)|0)+Math.imul(q,kA)|0,C=C+Math.imul(q,MA)|0;var zA=(D+(E=E+Math.imul(G,GA)|0)|0)+((8191&(Q=(Q=Q+Math.imul(G,FA)|0)+Math.imul(N,GA)|0))<<13)|0;D=((C=C+Math.imul(N,FA)|0)+(Q>>>13)|0)+(zA>>>26)|0,zA&=67108863,E=Math.imul(iA,dA),Q=(Q=Math.imul(iA,fA))+Math.imul(oA,dA)|0,C=Math.imul(oA,fA),E=E+Math.imul(eA,QA)|0,Q=(Q=Q+Math.imul(eA,CA)|0)+Math.imul(aA,QA)|0,C=C+Math.imul(aA,CA)|0,E=E+Math.imul(X,lA)|0,Q=(Q=Q+Math.imul(X,hA)|0)+Math.imul($,lA)|0,C=C+Math.imul($,hA)|0,E=E+Math.imul(j,xA)|0,Q=(Q=Q+Math.imul(j,pA)|0)+Math.imul(W,xA)|0,C=C+Math.imul(W,pA)|0,E=E+Math.imul(O,mA)|0,Q=(Q=Q+Math.imul(O,yA)|0)+Math.imul(P,mA)|0,C=C+Math.imul(P,yA)|0,E=E+Math.imul(J,kA)|0,Q=(Q=Q+Math.imul(J,MA)|0)+Math.imul(T,kA)|0,C=C+Math.imul(T,MA)|0,E=E+Math.imul(L,GA)|0,Q=(Q=Q+Math.imul(L,FA)|0)+Math.imul(q,GA)|0,C=C+Math.imul(q,FA)|0;var jA=(D+(E=E+Math.imul(G,UA)|0)|0)+((8191&(Q=(Q=Q+Math.imul(G,RA)|0)+Math.imul(N,UA)|0))<<13)|0;D=((C=C+Math.imul(N,RA)|0)+(Q>>>13)|0)+(jA>>>26)|0,jA&=67108863,E=Math.imul(rA,dA),Q=(Q=Math.imul(rA,fA))+Math.imul(cA,dA)|0,C=Math.imul(cA,fA),E=E+Math.imul(iA,QA)|0,Q=(Q=Q+Math.imul(iA,CA)|0)+Math.imul(oA,QA)|0,C=C+Math.imul(oA,CA)|0,E=E+Math.imul(eA,lA)|0,Q=(Q=Q+Math.imul(eA,hA)|0)+Math.imul(aA,lA)|0,C=C+Math.imul(aA,hA)|0,E=E+Math.imul(X,xA)|0,Q=(Q=Q+Math.imul(X,pA)|0)+Math.imul($,xA)|0,C=C+Math.imul($,pA)|0,E=E+Math.imul(j,mA)|0,Q=(Q=Q+Math.imul(j,yA)|0)+Math.imul(W,mA)|0,C=C+Math.imul(W,yA)|0,E=E+Math.imul(O,kA)|0,Q=(Q=Q+Math.imul(O,MA)|0)+Math.imul(P,kA)|0,C=C+Math.imul(P,MA)|0,E=E+Math.imul(J,GA)|0,Q=(Q=Q+Math.imul(J,FA)|0)+Math.imul(T,GA)|0,C=C+Math.imul(T,FA)|0,E=E+Math.imul(L,UA)|0,Q=(Q=Q+Math.imul(L,RA)|0)+Math.imul(q,UA)|0,C=C+Math.imul(q,RA)|0;var WA=(D+(E=E+Math.imul(G,LA)|0)|0)+((8191&(Q=(Q=Q+Math.imul(G,qA)|0)+Math.imul(N,LA)|0))<<13)|0;D=((C=C+Math.imul(N,qA)|0)+(Q>>>13)|0)+(WA>>>26)|0,WA&=67108863,E=Math.imul(nA,dA),Q=(Q=Math.imul(nA,fA))+Math.imul(IA,dA)|0,C=Math.imul(IA,fA),E=E+Math.imul(rA,QA)|0,Q=(Q=Q+Math.imul(rA,CA)|0)+Math.imul(cA,QA)|0,C=C+Math.imul(cA,CA)|0,E=E+Math.imul(iA,lA)|0,Q=(Q=Q+Math.imul(iA,hA)|0)+Math.imul(oA,lA)|0,C=C+Math.imul(oA,hA)|0,E=E+Math.imul(eA,xA)|0,Q=(Q=Q+Math.imul(eA,pA)|0)+Math.imul(aA,xA)|0,C=C+Math.imul(aA,pA)|0,E=E+Math.imul(X,mA)|0,Q=(Q=Q+Math.imul(X,yA)|0)+Math.imul($,mA)|0,C=C+Math.imul($,yA)|0,E=E+Math.imul(j,kA)|0,Q=(Q=Q+Math.imul(j,MA)|0)+Math.imul(W,kA)|0,C=C+Math.imul(W,MA)|0,E=E+Math.imul(O,GA)|0,Q=(Q=Q+Math.imul(O,FA)|0)+Math.imul(P,GA)|0,C=C+Math.imul(P,FA)|0,E=E+Math.imul(J,UA)|0,Q=(Q=Q+Math.imul(J,RA)|0)+Math.imul(T,UA)|0,C=C+Math.imul(T,RA)|0,E=E+Math.imul(L,LA)|0,Q=(Q=Q+Math.imul(L,qA)|0)+Math.imul(q,LA)|0,C=C+Math.imul(q,qA)|0;var VA=(D+(E=E+Math.imul(G,JA)|0)|0)+((8191&(Q=(Q=Q+Math.imul(G,TA)|0)+Math.imul(N,JA)|0))<<13)|0;D=((C=C+Math.imul(N,TA)|0)+(Q>>>13)|0)+(VA>>>26)|0,VA&=67108863,E=Math.imul(nA,QA),Q=(Q=Math.imul(nA,CA))+Math.imul(IA,QA)|0,C=Math.imul(IA,CA),E=E+Math.imul(rA,lA)|0,Q=(Q=Q+Math.imul(rA,hA)|0)+Math.imul(cA,lA)|0,C=C+Math.imul(cA,hA)|0,E=E+Math.imul(iA,xA)|0,Q=(Q=Q+Math.imul(iA,pA)|0)+Math.imul(oA,xA)|0,C=C+Math.imul(oA,pA)|0,E=E+Math.imul(eA,mA)|0,Q=(Q=Q+Math.imul(eA,yA)|0)+Math.imul(aA,mA)|0,C=C+Math.imul(aA,yA)|0,E=E+Math.imul(X,kA)|0,Q=(Q=Q+Math.imul(X,MA)|0)+Math.imul($,kA)|0,C=C+Math.imul($,MA)|0,E=E+Math.imul(j,GA)|0,Q=(Q=Q+Math.imul(j,FA)|0)+Math.imul(W,GA)|0,C=C+Math.imul(W,FA)|0,E=E+Math.imul(O,UA)|0,Q=(Q=Q+Math.imul(O,RA)|0)+Math.imul(P,UA)|0,C=C+Math.imul(P,RA)|0,E=E+Math.imul(J,LA)|0,Q=(Q=Q+Math.imul(J,qA)|0)+Math.imul(T,LA)|0,C=C+Math.imul(T,qA)|0;var XA=(D+(E=E+Math.imul(L,JA)|0)|0)+((8191&(Q=(Q=Q+Math.imul(L,TA)|0)+Math.imul(q,JA)|0))<<13)|0;D=((C=C+Math.imul(q,TA)|0)+(Q>>>13)|0)+(XA>>>26)|0,XA&=67108863,E=Math.imul(nA,lA),Q=(Q=Math.imul(nA,hA))+Math.imul(IA,lA)|0,C=Math.imul(IA,hA),E=E+Math.imul(rA,xA)|0,Q=(Q=Q+Math.imul(rA,pA)|0)+Math.imul(cA,xA)|0,C=C+Math.imul(cA,pA)|0,E=E+Math.imul(iA,mA)|0,Q=(Q=Q+Math.imul(iA,yA)|0)+Math.imul(oA,mA)|0,C=C+Math.imul(oA,yA)|0,E=E+Math.imul(eA,kA)|0,Q=(Q=Q+Math.imul(eA,MA)|0)+Math.imul(aA,kA)|0,C=C+Math.imul(aA,MA)|0,E=E+Math.imul(X,GA)|0,Q=(Q=Q+Math.imul(X,FA)|0)+Math.imul($,GA)|0,C=C+Math.imul($,FA)|0,E=E+Math.imul(j,UA)|0,Q=(Q=Q+Math.imul(j,RA)|0)+Math.imul(W,UA)|0,C=C+Math.imul(W,RA)|0,E=E+Math.imul(O,LA)|0,Q=(Q=Q+Math.imul(O,qA)|0)+Math.imul(P,LA)|0,C=C+Math.imul(P,qA)|0;var $A=(D+(E=E+Math.imul(J,JA)|0)|0)+((8191&(Q=(Q=Q+Math.imul(J,TA)|0)+Math.imul(T,JA)|0))<<13)|0;D=((C=C+Math.imul(T,TA)|0)+(Q>>>13)|0)+($A>>>26)|0,$A&=67108863,E=Math.imul(nA,xA),Q=(Q=Math.imul(nA,pA))+Math.imul(IA,xA)|0,C=Math.imul(IA,pA),E=E+Math.imul(rA,mA)|0,Q=(Q=Q+Math.imul(rA,yA)|0)+Math.imul(cA,mA)|0,C=C+Math.imul(cA,yA)|0,E=E+Math.imul(iA,kA)|0,Q=(Q=Q+Math.imul(iA,MA)|0)+Math.imul(oA,kA)|0,C=C+Math.imul(oA,MA)|0,E=E+Math.imul(eA,GA)|0,Q=(Q=Q+Math.imul(eA,FA)|0)+Math.imul(aA,GA)|0,C=C+Math.imul(aA,FA)|0,E=E+Math.imul(X,UA)|0,Q=(Q=Q+Math.imul(X,RA)|0)+Math.imul($,UA)|0,C=C+Math.imul($,RA)|0,E=E+Math.imul(j,LA)|0,Q=(Q=Q+Math.imul(j,qA)|0)+Math.imul(W,LA)|0,C=C+Math.imul(W,qA)|0;var Aa=(D+(E=E+Math.imul(O,JA)|0)|0)+((8191&(Q=(Q=Q+Math.imul(O,TA)|0)+Math.imul(P,JA)|0))<<13)|0;D=((C=C+Math.imul(P,TA)|0)+(Q>>>13)|0)+(Aa>>>26)|0,Aa&=67108863,E=Math.imul(nA,mA),Q=(Q=Math.imul(nA,yA))+Math.imul(IA,mA)|0,C=Math.imul(IA,yA),E=E+Math.imul(rA,kA)|0,Q=(Q=Q+Math.imul(rA,MA)|0)+Math.imul(cA,kA)|0,C=C+Math.imul(cA,MA)|0,E=E+Math.imul(iA,GA)|0,Q=(Q=Q+Math.imul(iA,FA)|0)+Math.imul(oA,GA)|0,C=C+Math.imul(oA,FA)|0,E=E+Math.imul(eA,UA)|0,Q=(Q=Q+Math.imul(eA,RA)|0)+Math.imul(aA,UA)|0,C=C+Math.imul(aA,RA)|0,E=E+Math.imul(X,LA)|0,Q=(Q=Q+Math.imul(X,qA)|0)+Math.imul($,LA)|0,C=C+Math.imul($,qA)|0;var ea=(D+(E=E+Math.imul(j,JA)|0)|0)+((8191&(Q=(Q=Q+Math.imul(j,TA)|0)+Math.imul(W,JA)|0))<<13)|0;D=((C=C+Math.imul(W,TA)|0)+(Q>>>13)|0)+(ea>>>26)|0,ea&=67108863,E=Math.imul(nA,kA),Q=(Q=Math.imul(nA,MA))+Math.imul(IA,kA)|0,C=Math.imul(IA,MA),E=E+Math.imul(rA,GA)|0,Q=(Q=Q+Math.imul(rA,FA)|0)+Math.imul(cA,GA)|0,C=C+Math.imul(cA,FA)|0,E=E+Math.imul(iA,UA)|0,Q=(Q=Q+Math.imul(iA,RA)|0)+Math.imul(oA,UA)|0,C=C+Math.imul(oA,RA)|0,E=E+Math.imul(eA,LA)|0,Q=(Q=Q+Math.imul(eA,qA)|0)+Math.imul(aA,LA)|0,C=C+Math.imul(aA,qA)|0;var aa=(D+(E=E+Math.imul(X,JA)|0)|0)+((8191&(Q=(Q=Q+Math.imul(X,TA)|0)+Math.imul($,JA)|0))<<13)|0;D=((C=C+Math.imul($,TA)|0)+(Q>>>13)|0)+(aa>>>26)|0,aa&=67108863,E=Math.imul(nA,GA),Q=(Q=Math.imul(nA,FA))+Math.imul(IA,GA)|0,C=Math.imul(IA,FA),E=E+Math.imul(rA,UA)|0,Q=(Q=Q+Math.imul(rA,RA)|0)+Math.imul(cA,UA)|0,C=C+Math.imul(cA,RA)|0,E=E+Math.imul(iA,LA)|0,Q=(Q=Q+Math.imul(iA,qA)|0)+Math.imul(oA,LA)|0,C=C+Math.imul(oA,qA)|0;var ta=(D+(E=E+Math.imul(eA,JA)|0)|0)+((8191&(Q=(Q=Q+Math.imul(eA,TA)|0)+Math.imul(aA,JA)|0))<<13)|0;D=((C=C+Math.imul(aA,TA)|0)+(Q>>>13)|0)+(ta>>>26)|0,ta&=67108863,E=Math.imul(nA,UA),Q=(Q=Math.imul(nA,RA))+Math.imul(IA,UA)|0,C=Math.imul(IA,RA),E=E+Math.imul(rA,LA)|0,Q=(Q=Q+Math.imul(rA,qA)|0)+Math.imul(cA,LA)|0,C=C+Math.imul(cA,qA)|0;var ia=(D+(E=E+Math.imul(iA,JA)|0)|0)+((8191&(Q=(Q=Q+Math.imul(iA,TA)|0)+Math.imul(oA,JA)|0))<<13)|0;D=((C=C+Math.imul(oA,TA)|0)+(Q>>>13)|0)+(ia>>>26)|0,ia&=67108863,E=Math.imul(nA,LA),Q=(Q=Math.imul(nA,qA))+Math.imul(IA,LA)|0,C=Math.imul(IA,qA);var oa=(D+(E=E+Math.imul(rA,JA)|0)|0)+((8191&(Q=(Q=Q+Math.imul(rA,TA)|0)+Math.imul(cA,JA)|0))<<13)|0;D=((C=C+Math.imul(cA,TA)|0)+(Q>>>13)|0)+(oa>>>26)|0,oa&=67108863;var ga=(D+(E=Math.imul(nA,JA))|0)+((8191&(Q=(Q=Math.imul(nA,TA))+Math.imul(IA,JA)|0))<<13)|0;return D=((C=Math.imul(IA,TA))+(Q>>>13)|0)+(ga>>>26)|0,ga&=67108863,m[0]=YA,m[1]=_A,m[2]=KA,m[3]=ZA,m[4]=OA,m[5]=PA,m[6]=zA,m[7]=jA,m[8]=WA,m[9]=VA,m[10]=XA,m[11]=$A,m[12]=Aa,m[13]=ea,m[14]=aa,m[15]=ta,m[16]=ia,m[17]=oa,m[18]=ga,0!==D&&(m[19]=D,I.length++),I};function jumboMulTo(B,n,I){return(new FFTM).mulp(B,n,I)}function FFTM(B,n){this.x=B,this.y=n}Math.imul||(p=smallMulTo),BN.prototype.mulTo=function mulTo(B,n){var I,E=this.length+B.length;return I=10===this.length&&10===B.length?p(this,B,n):E<63?smallMulTo(this,B,n):E<1024?function bigMulTo(B,n,I){I.negative=n.negative^B.negative,I.length=B.length+n.length;for(var E=0,Q=0,C=0;C<I.length-1;C++){var x=Q;Q=0;for(var p=67108863&E,m=Math.min(C,n.length-1),D=Math.max(0,C-B.length+1);D<=m;D++){var k=C-D,G=(0|B.words[k])*(0|n.words[D]),N=67108863&G;p=67108863&(N=N+p|0),Q+=(x=(x=x+(G/67108864|0)|0)+(N>>>26)|0)>>>26,x&=67108863}I.words[C]=p,E=x,x=Q}return 0!==E?I.words[C]=E:I.length--,I.strip()}(this,B,n):jumboMulTo(this,B,n),I},FFTM.prototype.makeRBT=function makeRBT(B){for(var n=new Array(B),I=BN.prototype._countBits(B)-1,E=0;E<B;E++)n[E]=this.revBin(E,I,B);return n},FFTM.prototype.revBin=function revBin(B,n,I){if(0===B||B===I-1)return B;for(var E=0,Q=0;Q<n;Q++)E|=(1&B)<<n-Q-1,B>>=1;return E},FFTM.prototype.permute=function permute(B,n,I,E,Q,C){for(var x=0;x<C;x++)E[x]=n[B[x]],Q[x]=I[B[x]]},FFTM.prototype.transform=function transform(B,n,I,E,Q,C){this.permute(C,B,n,I,E,Q);for(var x=1;x<Q;x<<=1)for(var p=x<<1,m=Math.cos(2*Math.PI/p),D=Math.sin(2*Math.PI/p),k=0;k<Q;k+=p)for(var G=m,N=D,U=0;U<x;U++){var L=I[k+U],q=E[k+U],H=I[k+U+x],J=E[k+U+x],T=G*H-N*J;J=G*J+N*H,H=T,I[k+U]=L+H,E[k+U]=q+J,I[k+U+x]=L-H,E[k+U+x]=q-J,U!==p&&(T=m*G-D*N,N=m*N+D*G,G=T)}},FFTM.prototype.guessLen13b=function guessLen13b(B,n){var I=1|Math.max(n,B),E=1&I,Q=0;for(I=I/2|0;I;I>>>=1)Q++;return 1<<Q+1+E},FFTM.prototype.conjugate=function conjugate(B,n,I){if(!(I<=1))for(var E=0;E<I/2;E++){var Q=B[E];B[E]=B[I-E-1],B[I-E-1]=Q,Q=n[E],n[E]=-n[I-E-1],n[I-E-1]=-Q}},FFTM.prototype.normalize13b=function normalize13b(B,n){for(var I=0,E=0;E<n/2;E++){var Q=8192*Math.round(B[2*E+1]/n)+Math.round(B[2*E]/n)+I;B[E]=67108863&Q,I=Q<67108864?0:Q/67108864|0}return B},FFTM.prototype.convert13b=function convert13b(B,n,I,E){for(var Q=0,C=0;C<n;C++)Q+=0|B[C],I[2*C]=8191&Q,Q>>>=13,I[2*C+1]=8191&Q,Q>>>=13;for(C=2*n;C<E;++C)I[C]=0;assert(0===Q),assert(0==(-8192&Q))},FFTM.prototype.stub=function stub(B){for(var n=new Array(B),I=0;I<B;I++)n[I]=0;return n},FFTM.prototype.mulp=function mulp(B,n,I){var E=2*this.guessLen13b(B.length,n.length),Q=this.makeRBT(E),C=this.stub(E),x=new Array(E),p=new Array(E),m=new Array(E),D=new Array(E),k=new Array(E),G=new Array(E),N=I.words;N.length=E,this.convert13b(B.words,B.length,x,E),this.convert13b(n.words,n.length,D,E),this.transform(x,C,p,m,E,Q),this.transform(D,C,k,G,E,Q);for(var U=0;U<E;U++){var L=p[U]*k[U]-m[U]*G[U];m[U]=p[U]*G[U]+m[U]*k[U],p[U]=L}return this.conjugate(p,m,E),this.transform(p,m,N,C,E,Q),this.conjugate(N,C,E),this.normalize13b(N,E),I.negative=B.negative^n.negative,I.length=B.length+n.length,I.strip()},BN.prototype.mul=function mul(B){var n=new BN(null);return n.words=new Array(this.length+B.length),this.mulTo(B,n)},BN.prototype.mulf=function mulf(B){var n=new BN(null);return n.words=new Array(this.length+B.length),jumboMulTo(this,B,n)},BN.prototype.imul=function imul(B){return this.clone().mulTo(B,this)},BN.prototype.imuln=function imuln(B){assert("number"==typeof B),assert(B<67108864);for(var n=0,I=0;I<this.length;I++){var E=(0|this.words[I])*B,Q=(67108863&E)+(67108863&n);n>>=26,n+=E/67108864|0,n+=Q>>>26,this.words[I]=67108863&Q}return 0!==n&&(this.words[I]=n,this.length++),this},BN.prototype.muln=function muln(B){return this.clone().imuln(B)},BN.prototype.sqr=function sqr(){return this.mul(this)},BN.prototype.isqr=function isqr(){return this.imul(this.clone())},BN.prototype.pow=function pow(B){var n=function toBitArray(B){for(var n=new Array(B.bitLength()),I=0;I<n.length;I++){var E=I/26|0,Q=I%26;n[I]=(B.words[E]&1<<Q)>>>Q}return n}(B);if(0===n.length)return new BN(1);for(var I=this,E=0;E<n.length&&0===n[E];E++,I=I.sqr());if(++E<n.length)for(var Q=I.sqr();E<n.length;E++,Q=Q.sqr())0!==n[E]&&(I=I.mul(Q));return I},BN.prototype.iushln=function iushln(B){assert("number"==typeof B&&B>=0);var n,I=B%26,E=(B-I)/26,Q=67108863>>>26-I<<26-I;if(0!==I){var C=0;for(n=0;n<this.length;n++){var x=this.words[n]&Q,p=(0|this.words[n])-x<<I;this.words[n]=p|C,C=x>>>26-I}C&&(this.words[n]=C,this.length++)}if(0!==E){for(n=this.length-1;n>=0;n--)this.words[n+E]=this.words[n];for(n=0;n<E;n++)this.words[n]=0;this.length+=E}return this.strip()},BN.prototype.ishln=function ishln(B){return assert(0===this.negative),this.iushln(B)},BN.prototype.iushrn=function iushrn(B,n,I){var E;assert("number"==typeof B&&B>=0),E=n?(n-n%26)/26:0;var Q=B%26,C=Math.min((B-Q)/26,this.length),x=67108863^67108863>>>Q<<Q,p=I;if(E-=C,E=Math.max(0,E),p){for(var m=0;m<C;m++)p.words[m]=this.words[m];p.length=C}if(0===C);else if(this.length>C)for(this.length-=C,m=0;m<this.length;m++)this.words[m]=this.words[m+C];else this.words[0]=0,this.length=1;var D=0;for(m=this.length-1;m>=0&&(0!==D||m>=E);m--){var k=0|this.words[m];this.words[m]=D<<26-Q|k>>>Q,D=k&x}return p&&0!==D&&(p.words[p.length++]=D),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},BN.prototype.ishrn=function ishrn(B,n,I){return assert(0===this.negative),this.iushrn(B,n,I)},BN.prototype.shln=function shln(B){return this.clone().ishln(B)},BN.prototype.ushln=function ushln(B){return this.clone().iushln(B)},BN.prototype.shrn=function shrn(B){return this.clone().ishrn(B)},BN.prototype.ushrn=function ushrn(B){return this.clone().iushrn(B)},BN.prototype.testn=function testn(B){assert("number"==typeof B&&B>=0);var n=B%26,I=(B-n)/26,E=1<<n;return!(this.length<=I)&&!!(this.words[I]&E)},BN.prototype.imaskn=function imaskn(B){assert("number"==typeof B&&B>=0);var n=B%26,I=(B-n)/26;if(assert(0===this.negative,"imaskn works only with positive numbers"),this.length<=I)return this;if(0!==n&&I++,this.length=Math.min(I,this.length),0!==n){var E=67108863^67108863>>>n<<n;this.words[this.length-1]&=E}return this.strip()},BN.prototype.maskn=function maskn(B){return this.clone().imaskn(B)},BN.prototype.iaddn=function iaddn(B){return assert("number"==typeof B),assert(B<67108864),B<0?this.isubn(-B):0!==this.negative?1===this.length&&(0|this.words[0])<B?(this.words[0]=B-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(B),this.negative=1,this):this._iaddn(B)},BN.prototype._iaddn=function _iaddn(B){this.words[0]+=B;for(var n=0;n<this.length&&this.words[n]>=67108864;n++)this.words[n]-=67108864,n===this.length-1?this.words[n+1]=1:this.words[n+1]++;return this.length=Math.max(this.length,n+1),this},BN.prototype.isubn=function isubn(B){if(assert("number"==typeof B),assert(B<67108864),B<0)return this.iaddn(-B);if(0!==this.negative)return this.negative=0,this.iaddn(B),this.negative=1,this;if(this.words[0]-=B,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var n=0;n<this.length&&this.words[n]<0;n++)this.words[n]+=67108864,this.words[n+1]-=1;return this.strip()},BN.prototype.addn=function addn(B){return this.clone().iaddn(B)},BN.prototype.subn=function subn(B){return this.clone().isubn(B)},BN.prototype.iabs=function iabs(){return this.negative=0,this},BN.prototype.abs=function abs(){return this.clone().iabs()},BN.prototyp