droplinked-web3-ui 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -10,7 +10,7 @@ React keys must be passed directly to JSX without using spread:
10
10
  See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.`),c.useMemoCache(t)}})()),reactCompilerRuntime_development}var hasRequiredCompilerRuntime;function requireCompilerRuntime(){return hasRequiredCompilerRuntime||(hasRequiredCompilerRuntime=1,process.env.NODE_ENV==="production"?compilerRuntime.exports=requireReactCompilerRuntime_production():compilerRuntime.exports=requireReactCompilerRuntime_development()),compilerRuntime.exports}var compilerRuntimeExports=requireCompilerRuntime(),si=Object.defineProperty,ni=n=>{throw TypeError(n)},fi=(n,t,c)=>t in n?si(n,t,{enumerable:!0,configurable:!0,writable:!0,value:c}):n[t]=c,Xn=(n,t,c)=>fi(n,typeof t!="symbol"?t+"":t,c),ui=(n,t,c)=>t.has(n)||ni("Cannot "+c),ii=(n,t,c)=>t.has(n)?ni("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,c),ai=(n,t,c)=>(ui(n,t,"access private method"),c);class WalletException extends Error{constructor(t,c){const ie=`<${t}> ${c}`;console.log(ie),super(c),this.name=new.target.name}}class WalletNotFoundException extends WalletException{constructor(t,c=""){const ie=`Wallet Not found ${c}`;super(t,ie)}}class UserDeniedException extends WalletException{constructor(t){super(t,"User denied the request")}}class NotSupportedException extends WalletException{constructor(t,c){super(t,`${c} networks are not supported by this wallet.`)}}class WalletNotInstalledException extends WalletException{constructor(t){super(t,"Not Installed.")}}class TokenNotSupportedException extends WalletException{constructor(t,c){super(t,`${c} token is not supported by this wallet.`)}}class ChainNotSupportedException extends WalletException{constructor(t,c){super(t,`${c} is not supported by this wallet.`)}}class ProviderException extends WalletException{constructor(t){super(t,"Provider could not be initialized.")}}class ChainException extends Error{constructor(t,c){const ie=`<${t}> ${c}`;console.log(ie),super(c),this.name=new.target.name}}class ChainNotImplementedException extends ChainException{constructor(t){super(t,"Not Implemented!")}}class InvalidParametersException extends ChainException{constructor(t,c){super(t,`Invalid parameters: ${c}`)}}class Unauthorized extends ChainException{constructor(t,c,ie,se){super(t,`Unauthorized access to ${c} from ${ie} to ${se}`),this.method=c,this.from=ie,this.to=se}}class ActionExceptions extends Error{constructor(t,c){super(`${t}: ${c}`),this.name=new.target.name}}class ActionNotImplementedException extends ActionExceptions{constructor(t){super(t,"Not Implemented!")}}class Web3CallbackFailedException extends ActionExceptions{constructor(t){super(t,"Something went wrong during web3 callback process!")}}class InitializationException extends ActionExceptions{constructor(){super("","Provider not initialized.")}}class InsufficientBalanceException extends ActionExceptions{constructor(){super("Payment","Insufficient Funds")}}var Actions=(n=>(n.Payment="Payment",n.ClaimNFT="ClaimNFT",n.Record="Record",n.Auth="Aut",n.Login="Login",n))(Actions||{}),Groups=(n=>(n.EVM="EVM",n.SOL="SOL",n.BTC="BTC",n.XION="XION",n.UD="UD",n))(Groups||{}),Network=(n=>(n.TESTNET="TESTNET",n.MAINNET="MAINNET",n))(Network||{}),Chains=(n=>(n.POLYGON="POLYGON",n.BINANCE="BINANCE",n.SKALE="SKALE",n.BASE="BASE",n.LINEA="LINEA",n.ETH="ETH",n.SOLANA="SOLANA",n.REDBELLY="REDBELLY",n.UNSTOPPABLE="UNSTOPPABLE",n.BITLAYER="BITLAYER",n.XION="XION",n))(Chains||{});const chains=[{name:"BINANCE",group:Groups.EVM,TESTNET:{chainName:"Smart Chain - Testnet",chainId:"0x61",nativeCurrency:{name:"BNB",decimals:18,symbol:"BNB"},rpcUrls:["https://bsc-testnet-dataseed.bnbchain.org/"]},MAINNET:{chainName:"Smart Chain",chainId:"0x38",nativeCurrency:{name:"BNB",decimals:18,symbol:"BNB"},rpcUrls:["https://bsc-dataseed.binance.org/"]}},{name:"POLYGON",group:Groups.EVM,TESTNET:{chainName:"Polygon Amoy Testnet",chainId:"0x13882",nativeCurrency:{name:"MATIC",decimals:18,symbol:"MATIC"},rpcUrls:["https://rpc-amoy.polygon.technology"]},MAINNET:{chainName:"Polygon Mainnet",chainId:"0x89",nativeCurrency:{name:"MATIC",decimals:18,symbol:"MATIC"},rpcUrls:["https://polygon-rpc.com/"]}},{name:"SKALE",group:Groups.EVM,TESTNET:{chainName:"SKALE Testnet Calypso Hub",chainId:"0x3A14269B",nativeCurrency:{name:"sFUEL",decimals:18,symbol:"sFUEL"},rpcUrls:["https://testnet.skalenodes.com/v1/giant-half-dual-testnet"]},MAINNET:{chainName:"SKALE Calypso Hub",chainId:"0x5D456C62",nativeCurrency:{name:"sFUEL",decimals:18,symbol:"sFUEL"},rpcUrls:["https://mainnet.skalenodes.com/v1/honorable-steel-rasalhague"]}},{name:"BASE",group:Groups.EVM,TESTNET:{chainName:"Base Sepolia",chainId:"0x14a34",nativeCurrency:{name:"ETH",decimals:18,symbol:"ETH"},rpcUrls:["https://sepolia.base.org"]},MAINNET:{chainName:"Base Mainnet",chainId:"0x2105",nativeCurrency:{name:"ETH",decimals:18,symbol:"ETH"},rpcUrls:["https://mainnet.base.org/"]}},{name:"LINEA",group:Groups.EVM,MAINNET:{chainName:"Linea",chainId:"0xe708",nativeCurrency:{name:"ETH",decimals:18,symbol:"LineaETH"},rpcUrls:["https://rpc.linea.build"]},TESTNET:{chainName:"Linea",chainId:"0xe705",nativeCurrency:{name:"ETH",decimals:18,symbol:"LineaETH"},rpcUrls:["https://rpc.sepolia.linea.build"]}},{name:"ETH",group:Groups.EVM,MAINNET:{chainName:"Ethereum",chainId:"0x1",nativeCurrency:{name:"ETH",decimals:18,symbol:"ETH"},rpcUrls:["https://mainnet.infura.io/v3/"]},TESTNET:{chainName:"Sepolia",chainId:"0xaa36a7",nativeCurrency:{name:"ETH",decimals:18,symbol:"ETH"},rpcUrls:["https://eth-sepolia.public.blastapi.io/"]}},{name:"REDBELLY",group:Groups.EVM,TESTNET:{chainName:"Redbelly Network Testnet",chainId:"0x99",nativeCurrency:{name:"RBNT",decimals:18,symbol:"RBNT"},rpcUrls:["https://governors.testnet.redbelly.network"]},MAINNET:{chainName:"Redbelly Network Mainnet",chainId:"0x97",nativeCurrency:{name:"RBNT",decimals:18,symbol:"RBNT"},rpcUrls:["https://governors.mainnet.redbelly.network"]}},{name:"BITLAYER",group:Groups.EVM,MAINNET:{chainName:"Bitlayer Mainnet",chainId:"0x310C5",nativeCurrency:{name:"BTC",decimals:18,symbol:"BTC"},rpcUrls:["https://rpc.bitlayer.org"]},TESTNET:{chainName:"Bitlayer Testnet",chainId:"0x3106A",nativeCurrency:{name:"BTC",decimals:18,symbol:"BTC"},rpcUrls:["https://testnet-rpc.bitlayer.org"]}},{name:"SOLANA",group:Groups.SOL,MAINNET:{chainName:"Solana Mainnet",chainId:"0x1",nativeCurrency:{name:"SOL",decimals:9,symbol:"SOL"},rpcUrls:[]},TESTNET:{chainName:"Solana Testnet",chainId:"0x01",nativeCurrency:{name:"SOL",decimals:9,symbol:"SOL"},rpcUrls:[]}},{name:"XION",group:Groups.XION,MAINNET:{chainName:"Xion Mainnet",chainId:"0x1",nativeCurrency:{name:"XION",decimals:6,symbol:"XION"},rpcUrls:[]},TESTNET:{chainName:"Xion Testnet",chainId:"0x01",nativeCurrency:{name:"XION",decimals:6,symbol:"XION"},rpcUrls:[]}},{name:"UNSTOPPABLE",group:Groups.UD,MAINNET:{chainName:"Unstoppable Domains Mainnet",chainId:"0x1",nativeCurrency:{name:"UD",decimals:18,symbol:"UD"},rpcUrls:[]},TESTNET:{chainName:"Unstoppable Domains Testnet",chainId:"0x01",nativeCurrency:{name:"UD",decimals:18,symbol:"UD"},rpcUrls:[]}}];function getChainByName(n){const t=chains.find(c=>c.name.toLowerCase()===n.toLowerCase());if(!t)throw new ChainNotImplementedException(n);return t}function getGroupOfChain(n){return getChainByName(n).group}function isChainInGroup(n,t){return getGroupOfChain(n)===t}class Web3Wallet{constructor(t,c,ie){this.name=t,this.group=c,this.stepizer=ie}}async function getEvmProviderByWalletName(n,t=500){return new Promise(c=>{const ie=[];function se(ae){const ue=ae.detail;!(ue!=null&&ue.provider)||!(ue!=null&&ue.info)||ie.push(ue)}window.addEventListener("eip6963:announceProvider",se),window.dispatchEvent(new Event("eip6963:requestProvider")),setTimeout(()=>{window.removeEventListener("eip6963:announceProvider",se),console.log("EIP-6963 providers announced:",ie.map(de=>de.info.name));const ae=ie.find(({info:de})=>de.name===n||de.name.toLowerCase()===n.toLowerCase());if(ae){c(ae.provider);return}const ue=window.ethereum;if(n.toLowerCase()==="metamask"&&ue!=null&&ue.isMetaMask){c(ue);return}c(null)},t)})}var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};function getDefaultExportFromCjs$2(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function getAugmentedNamespace(n){if(n.__esModule)return n;var t=n.default;if(typeof t=="function"){var c=function ie(){return this instanceof ie?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};c.prototype=t.prototype}else c={};return Object.defineProperty(c,"__esModule",{value:!0}),Object.keys(n).forEach(function(ie){var se=Object.getOwnPropertyDescriptor(n,ie);Object.defineProperty(c,ie,se.get?se:{enumerable:!0,get:function(){return n[ie]}})}),c}var bn$8={exports:{}},buffer$1={},base64Js={};base64Js.byteLength=byteLength;base64Js.toByteArray=toByteArray;base64Js.fromByteArray=fromByteArray;var lookup=[],revLookup=[],Arr=typeof Uint8Array<"u"?Uint8Array:Array,code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var i$3=0,len=code.length;i$3<len;++i$3)lookup[i$3]=code[i$3],revLookup[code.charCodeAt(i$3)]=i$3;revLookup[45]=62;revLookup[95]=63;function getLens(n){var t=n.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var c=n.indexOf("=");c===-1&&(c=t);var ie=c===t?0:4-c%4;return[c,ie]}function byteLength(n){var t=getLens(n),c=t[0],ie=t[1];return(c+ie)*3/4-ie}function _byteLength(n,t,c){return(t+c)*3/4-c}function toByteArray(n){var t,c=getLens(n),ie=c[0],se=c[1],ae=new Arr(_byteLength(n,ie,se)),ue=0,de=se>0?ie-4:ie,ve;for(ve=0;ve<de;ve+=4)t=revLookup[n.charCodeAt(ve)]<<18|revLookup[n.charCodeAt(ve+1)]<<12|revLookup[n.charCodeAt(ve+2)]<<6|revLookup[n.charCodeAt(ve+3)],ae[ue++]=t>>16&255,ae[ue++]=t>>8&255,ae[ue++]=t&255;return se===2&&(t=revLookup[n.charCodeAt(ve)]<<2|revLookup[n.charCodeAt(ve+1)]>>4,ae[ue++]=t&255),se===1&&(t=revLookup[n.charCodeAt(ve)]<<10|revLookup[n.charCodeAt(ve+1)]<<4|revLookup[n.charCodeAt(ve+2)]>>2,ae[ue++]=t>>8&255,ae[ue++]=t&255),ae}function tripletToBase64(n){return lookup[n>>18&63]+lookup[n>>12&63]+lookup[n>>6&63]+lookup[n&63]}function encodeChunk(n,t,c){for(var ie,se=[],ae=t;ae<c;ae+=3)ie=(n[ae]<<16&16711680)+(n[ae+1]<<8&65280)+(n[ae+2]&255),se.push(tripletToBase64(ie));return se.join("")}function fromByteArray(n){for(var t,c=n.length,ie=c%3,se=[],ae=16383,ue=0,de=c-ie;ue<de;ue+=ae)se.push(encodeChunk(n,ue,ue+ae>de?de:ue+ae));return ie===1?(t=n[c-1],se.push(lookup[t>>2]+lookup[t<<4&63]+"==")):ie===2&&(t=(n[c-2]<<8)+n[c-1],se.push(lookup[t>>10]+lookup[t>>4&63]+lookup[t<<2&63]+"=")),se.join("")}var ieee754={};ieee754.read=function(n,t,c,ie,se){var ae,ue,de=se*8-ie-1,ve=(1<<de)-1,ge=ve>>1,we=-7,Te=c?se-1:0,Ne=c?-1:1,qe=n[t+Te];for(Te+=Ne,ae=qe&(1<<-we)-1,qe>>=-we,we+=de;we>0;ae=ae*256+n[t+Te],Te+=Ne,we-=8);for(ue=ae&(1<<-we)-1,ae>>=-we,we+=ie;we>0;ue=ue*256+n[t+Te],Te+=Ne,we-=8);if(ae===0)ae=1-ge;else{if(ae===ve)return ue?NaN:(qe?-1:1)*(1/0);ue=ue+Math.pow(2,ie),ae=ae-ge}return(qe?-1:1)*ue*Math.pow(2,ae-ie)};ieee754.write=function(n,t,c,ie,se,ae){var ue,de,ve,ge=ae*8-se-1,we=(1<<ge)-1,Te=we>>1,Ne=se===23?Math.pow(2,-24)-Math.pow(2,-77):0,qe=ie?0:ae-1,ze=ie?1:-1,He=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(de=isNaN(t)?1:0,ue=we):(ue=Math.floor(Math.log(t)/Math.LN2),t*(ve=Math.pow(2,-ue))<1&&(ue--,ve*=2),ue+Te>=1?t+=Ne/ve:t+=Ne*Math.pow(2,1-Te),t*ve>=2&&(ue++,ve/=2),ue+Te>=we?(de=0,ue=we):ue+Te>=1?(de=(t*ve-1)*Math.pow(2,se),ue=ue+Te):(de=t*Math.pow(2,Te-1)*Math.pow(2,se),ue=0));se>=8;n[c+qe]=de&255,qe+=ze,de/=256,se-=8);for(ue=ue<<se|de,ge+=se;ge>0;n[c+qe]=ue&255,qe+=ze,ue/=256,ge-=8);n[c+qe-ze]|=He*128};(function(n){const t=base64Js,c=ieee754,ie=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=we,n.SlowBuffer=Zt,n.INSPECT_MAX_BYTES=50;const se=2147483647;n.kMaxLength=se;const{Uint8Array:ae,ArrayBuffer:ue,SharedArrayBuffer:de}=globalThis;we.TYPED_ARRAY_SUPPORT=ve(),!we.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function ve(){try{const Gt=new ae(1),En={foo:function(){return 42}};return Object.setPrototypeOf(En,ae.prototype),Object.setPrototypeOf(Gt,En),Gt.foo()===42}catch{return!1}}Object.defineProperty(we.prototype,"parent",{enumerable:!0,get:function(){if(we.isBuffer(this))return this.buffer}}),Object.defineProperty(we.prototype,"offset",{enumerable:!0,get:function(){if(we.isBuffer(this))return this.byteOffset}});function ge(Gt){if(Gt>se)throw new RangeError('The value "'+Gt+'" is invalid for option "size"');const En=new ae(Gt);return Object.setPrototypeOf(En,we.prototype),En}function we(Gt,En,xn){if(typeof Gt=="number"){if(typeof En=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return ze(Gt)}return Te(Gt,En,xn)}we.poolSize=8192;function Te(Gt,En,xn){if(typeof Gt=="string")return He(Gt,En);if(ue.isView(Gt))return Ze(Gt);if(Gt==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof Gt);if(Ln(Gt,ue)||Gt&&Ln(Gt.buffer,ue)||typeof de<"u"&&(Ln(Gt,de)||Gt&&Ln(Gt.buffer,de)))return Ye(Gt,En,xn);if(typeof Gt=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const In=Gt.valueOf&&Gt.valueOf();if(In!=null&&In!==Gt)return we.from(In,En,xn);const Wn=Ft(Gt);if(Wn)return Wn;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof Gt[Symbol.toPrimitive]=="function")return we.from(Gt[Symbol.toPrimitive]("string"),En,xn);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof Gt)}we.from=function(Gt,En,xn){return Te(Gt,En,xn)},Object.setPrototypeOf(we.prototype,ae.prototype),Object.setPrototypeOf(we,ae);function Ne(Gt){if(typeof Gt!="number")throw new TypeError('"size" argument must be of type number');if(Gt<0)throw new RangeError('The value "'+Gt+'" is invalid for option "size"')}function qe(Gt,En,xn){return Ne(Gt),Gt<=0?ge(Gt):En!==void 0?typeof xn=="string"?ge(Gt).fill(En,xn):ge(Gt).fill(En):ge(Gt)}we.alloc=function(Gt,En,xn){return qe(Gt,En,xn)};function ze(Gt){return Ne(Gt),ge(Gt<0?0:Mt(Gt)|0)}we.allocUnsafe=function(Gt){return ze(Gt)},we.allocUnsafeSlow=function(Gt){return ze(Gt)};function He(Gt,En){if((typeof En!="string"||En==="")&&(En="utf8"),!we.isEncoding(En))throw new TypeError("Unknown encoding: "+En);const xn=cn(Gt,En)|0;let In=ge(xn);const Wn=In.write(Gt,En);return Wn!==xn&&(In=In.slice(0,Wn)),In}function Ge(Gt){const En=Gt.length<0?0:Mt(Gt.length)|0,xn=ge(En);for(let In=0;In<En;In+=1)xn[In]=Gt[In]&255;return xn}function Ze(Gt){if(Ln(Gt,ae)){const En=new ae(Gt);return Ye(En.buffer,En.byteOffset,En.byteLength)}return Ge(Gt)}function Ye(Gt,En,xn){if(En<0||Gt.byteLength<En)throw new RangeError('"offset" is outside of buffer bounds');if(Gt.byteLength<En+(xn||0))throw new RangeError('"length" is outside of buffer bounds');let In;return En===void 0&&xn===void 0?In=new ae(Gt):xn===void 0?In=new ae(Gt,En):In=new ae(Gt,En,xn),Object.setPrototypeOf(In,we.prototype),In}function Ft(Gt){if(we.isBuffer(Gt)){const En=Mt(Gt.length)|0,xn=ge(En);return xn.length===0||Gt.copy(xn,0,0,En),xn}if(Gt.length!==void 0)return typeof Gt.length!="number"||On(Gt.length)?ge(0):Ge(Gt);if(Gt.type==="Buffer"&&Array.isArray(Gt.data))return Ge(Gt.data)}function Mt(Gt){if(Gt>=se)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+se.toString(16)+" bytes");return Gt|0}function Zt(Gt){return+Gt!=Gt&&(Gt=0),we.alloc(+Gt)}we.isBuffer=function(Gt){return Gt!=null&&Gt._isBuffer===!0&&Gt!==we.prototype},we.compare=function(Gt,En){if(Ln(Gt,ae)&&(Gt=we.from(Gt,Gt.offset,Gt.byteLength)),Ln(En,ae)&&(En=we.from(En,En.offset,En.byteLength)),!we.isBuffer(Gt)||!we.isBuffer(En))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(Gt===En)return 0;let xn=Gt.length,In=En.length;for(let Wn=0,jn=Math.min(xn,In);Wn<jn;++Wn)if(Gt[Wn]!==En[Wn]){xn=Gt[Wn],In=En[Wn];break}return xn<In?-1:In<xn?1:0},we.isEncoding=function(Gt){switch(String(Gt).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},we.concat=function(Gt,En){if(!Array.isArray(Gt))throw new TypeError('"list" argument must be an Array of Buffers');if(Gt.length===0)return we.alloc(0);let xn;if(En===void 0)for(En=0,xn=0;xn<Gt.length;++xn)En+=Gt[xn].length;const In=we.allocUnsafe(En);let Wn=0;for(xn=0;xn<Gt.length;++xn){let jn=Gt[xn];if(Ln(jn,ae))Wn+jn.length>In.length?(we.isBuffer(jn)||(jn=we.from(jn)),jn.copy(In,Wn)):ae.prototype.set.call(In,jn,Wn);else if(we.isBuffer(jn))jn.copy(In,Wn);else throw new TypeError('"list" argument must be an Array of Buffers');Wn+=jn.length}return In};function cn(Gt,En){if(we.isBuffer(Gt))return Gt.length;if(ue.isView(Gt)||Ln(Gt,ue))return Gt.byteLength;if(typeof Gt!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof Gt);const xn=Gt.length,In=arguments.length>2&&arguments[2]===!0;if(!In&&xn===0)return 0;let Wn=!1;for(;;)switch(En){case"ascii":case"latin1":case"binary":return xn;case"utf8":case"utf-8":return Kn(Gt).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xn*2;case"hex":return xn>>>1;case"base64":return Hn(Gt).length;default:if(Wn)return In?-1:Kn(Gt).length;En=(""+En).toLowerCase(),Wn=!0}}we.byteLength=cn;function hn(Gt,En,xn){let In=!1;if((En===void 0||En<0)&&(En=0),En>this.length||((xn===void 0||xn>this.length)&&(xn=this.length),xn<=0)||(xn>>>=0,En>>>=0,xn<=En))return"";for(Gt||(Gt="utf8");;)switch(Gt){case"hex":return $t(this,En,xn);case"utf8":case"utf-8":return Fe(this,En,xn);case"ascii":return Me(this,En,xn);case"latin1":case"binary":return We(this,En,xn);case"base64":return De(this,En,xn);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return dn(this,En,xn);default:if(In)throw new TypeError("Unknown encoding: "+Gt);Gt=(Gt+"").toLowerCase(),In=!0}}we.prototype._isBuffer=!0;function yn(Gt,En,xn){const In=Gt[En];Gt[En]=Gt[xn],Gt[xn]=In}we.prototype.swap16=function(){const Gt=this.length;if(Gt%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let En=0;En<Gt;En+=2)yn(this,En,En+1);return this},we.prototype.swap32=function(){const Gt=this.length;if(Gt%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let En=0;En<Gt;En+=4)yn(this,En,En+3),yn(this,En+1,En+2);return this},we.prototype.swap64=function(){const Gt=this.length;if(Gt%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let En=0;En<Gt;En+=8)yn(this,En,En+7),yn(this,En+1,En+6),yn(this,En+2,En+5),yn(this,En+3,En+4);return this},we.prototype.toString=function(){const Gt=this.length;return Gt===0?"":arguments.length===0?Fe(this,0,Gt):hn.apply(this,arguments)},we.prototype.toLocaleString=we.prototype.toString,we.prototype.equals=function(Gt){if(!we.isBuffer(Gt))throw new TypeError("Argument must be a Buffer");return this===Gt?!0:we.compare(this,Gt)===0},we.prototype.inspect=function(){let Gt="";const En=n.INSPECT_MAX_BYTES;return Gt=this.toString("hex",0,En).replace(/(.{2})/g,"$1 ").trim(),this.length>En&&(Gt+=" ... "),"<Buffer "+Gt+">"},ie&&(we.prototype[ie]=we.prototype.inspect),we.prototype.compare=function(Gt,En,xn,In,Wn){if(Ln(Gt,ae)&&(Gt=we.from(Gt,Gt.offset,Gt.byteLength)),!we.isBuffer(Gt))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof Gt);if(En===void 0&&(En=0),xn===void 0&&(xn=Gt?Gt.length:0),In===void 0&&(In=0),Wn===void 0&&(Wn=this.length),En<0||xn>Gt.length||In<0||Wn>this.length)throw new RangeError("out of range index");if(In>=Wn&&En>=xn)return 0;if(In>=Wn)return-1;if(En>=xn)return 1;if(En>>>=0,xn>>>=0,In>>>=0,Wn>>>=0,this===Gt)return 0;let jn=Wn-In,zn=xn-En;const Ri=Math.min(jn,zn),Qn=this.slice(In,Wn),li=Gt.slice(En,xn);for(let Ci=0;Ci<Ri;++Ci)if(Qn[Ci]!==li[Ci]){jn=Qn[Ci],zn=li[Ci];break}return jn<zn?-1:zn<jn?1:0};function Ht(Gt,En,xn,In,Wn){if(Gt.length===0)return-1;if(typeof xn=="string"?(In=xn,xn=0):xn>2147483647?xn=2147483647:xn<-2147483648&&(xn=-2147483648),xn=+xn,On(xn)&&(xn=Wn?0:Gt.length-1),xn<0&&(xn=Gt.length+xn),xn>=Gt.length){if(Wn)return-1;xn=Gt.length-1}else if(xn<0)if(Wn)xn=0;else return-1;if(typeof En=="string"&&(En=we.from(En,In)),we.isBuffer(En))return En.length===0?-1:Sn(Gt,En,xn,In,Wn);if(typeof En=="number")return En=En&255,typeof ae.prototype.indexOf=="function"?Wn?ae.prototype.indexOf.call(Gt,En,xn):ae.prototype.lastIndexOf.call(Gt,En,xn):Sn(Gt,[En],xn,In,Wn);throw new TypeError("val must be string, number or Buffer")}function Sn(Gt,En,xn,In,Wn){let jn=1,zn=Gt.length,Ri=En.length;if(In!==void 0&&(In=String(In).toLowerCase(),In==="ucs2"||In==="ucs-2"||In==="utf16le"||In==="utf-16le")){if(Gt.length<2||En.length<2)return-1;jn=2,zn/=2,Ri/=2,xn/=2}function Qn(Ci,ri){return jn===1?Ci[ri]:Ci.readUInt16BE(ri*jn)}let li;if(Wn){let Ci=-1;for(li=xn;li<zn;li++)if(Qn(Gt,li)===Qn(En,Ci===-1?0:li-Ci)){if(Ci===-1&&(Ci=li),li-Ci+1===Ri)return Ci*jn}else Ci!==-1&&(li-=li-Ci),Ci=-1}else for(xn+Ri>zn&&(xn=zn-Ri),li=xn;li>=0;li--){let Ci=!0;for(let ri=0;ri<Ri;ri++)if(Qn(Gt,li+ri)!==Qn(En,ri)){Ci=!1;break}if(Ci)return li}return-1}we.prototype.includes=function(Gt,En,xn){return this.indexOf(Gt,En,xn)!==-1},we.prototype.indexOf=function(Gt,En,xn){return Ht(this,Gt,En,xn,!0)},we.prototype.lastIndexOf=function(Gt,En,xn){return Ht(this,Gt,En,xn,!1)};function le(Gt,En,xn,In){xn=Number(xn)||0;const Wn=Gt.length-xn;In?(In=Number(In),In>Wn&&(In=Wn)):In=Wn;const jn=En.length;In>jn/2&&(In=jn/2);let zn;for(zn=0;zn<In;++zn){const Ri=parseInt(En.substr(zn*2,2),16);if(On(Ri))return zn;Gt[xn+zn]=Ri}return zn}function pe(Gt,En,xn,In){return An(Kn(En,Gt.length-xn),Gt,xn,In)}function be(Gt,En,xn,In){return An(Jn(En),Gt,xn,In)}function xe(Gt,En,xn,In){return An(Hn(En),Gt,xn,In)}function _e(Gt,En,xn,In){return An(bi(En,Gt.length-xn),Gt,xn,In)}we.prototype.write=function(Gt,En,xn,In){if(En===void 0)In="utf8",xn=this.length,En=0;else if(xn===void 0&&typeof En=="string")In=En,xn=this.length,En=0;else if(isFinite(En))En=En>>>0,isFinite(xn)?(xn=xn>>>0,In===void 0&&(In="utf8")):(In=xn,xn=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const Wn=this.length-En;if((xn===void 0||xn>Wn)&&(xn=Wn),Gt.length>0&&(xn<0||En<0)||En>this.length)throw new RangeError("Attempt to write outside buffer bounds");In||(In="utf8");let jn=!1;for(;;)switch(In){case"hex":return le(this,Gt,En,xn);case"utf8":case"utf-8":return pe(this,Gt,En,xn);case"ascii":case"latin1":case"binary":return be(this,Gt,En,xn);case"base64":return xe(this,Gt,En,xn);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _e(this,Gt,En,xn);default:if(jn)throw new TypeError("Unknown encoding: "+In);In=(""+In).toLowerCase(),jn=!0}},we.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function De(Gt,En,xn){return En===0&&xn===Gt.length?t.fromByteArray(Gt):t.fromByteArray(Gt.slice(En,xn))}function Fe(Gt,En,xn){xn=Math.min(Gt.length,xn);const In=[];let Wn=En;for(;Wn<xn;){const jn=Gt[Wn];let zn=null,Ri=jn>239?4:jn>223?3:jn>191?2:1;if(Wn+Ri<=xn){let Qn,li,Ci,ri;switch(Ri){case 1:jn<128&&(zn=jn);break;case 2:Qn=Gt[Wn+1],(Qn&192)===128&&(ri=(jn&31)<<6|Qn&63,ri>127&&(zn=ri));break;case 3:Qn=Gt[Wn+1],li=Gt[Wn+2],(Qn&192)===128&&(li&192)===128&&(ri=(jn&15)<<12|(Qn&63)<<6|li&63,ri>2047&&(ri<55296||ri>57343)&&(zn=ri));break;case 4:Qn=Gt[Wn+1],li=Gt[Wn+2],Ci=Gt[Wn+3],(Qn&192)===128&&(li&192)===128&&(Ci&192)===128&&(ri=(jn&15)<<18|(Qn&63)<<12|(li&63)<<6|Ci&63,ri>65535&&ri<1114112&&(zn=ri))}}zn===null?(zn=65533,Ri=1):zn>65535&&(zn-=65536,In.push(zn>>>10&1023|55296),zn=56320|zn&1023),In.push(zn),Wn+=Ri}return ce(In)}const $e=4096;function ce(Gt){const En=Gt.length;if(En<=$e)return String.fromCharCode.apply(String,Gt);let xn="",In=0;for(;In<En;)xn+=String.fromCharCode.apply(String,Gt.slice(In,In+=$e));return xn}function Me(Gt,En,xn){let In="";xn=Math.min(Gt.length,xn);for(let Wn=En;Wn<xn;++Wn)In+=String.fromCharCode(Gt[Wn]&127);return In}function We(Gt,En,xn){let In="";xn=Math.min(Gt.length,xn);for(let Wn=En;Wn<xn;++Wn)In+=String.fromCharCode(Gt[Wn]);return In}function $t(Gt,En,xn){const In=Gt.length;(!En||En<0)&&(En=0),(!xn||xn<0||xn>In)&&(xn=In);let Wn="";for(let jn=En;jn<xn;++jn)Wn+=Un[Gt[jn]];return Wn}function dn(Gt,En,xn){const In=Gt.slice(En,xn);let Wn="";for(let jn=0;jn<In.length-1;jn+=2)Wn+=String.fromCharCode(In[jn]+In[jn+1]*256);return Wn}we.prototype.slice=function(Gt,En){const xn=this.length;Gt=~~Gt,En=En===void 0?xn:~~En,Gt<0?(Gt+=xn,Gt<0&&(Gt=0)):Gt>xn&&(Gt=xn),En<0?(En+=xn,En<0&&(En=0)):En>xn&&(En=xn),En<Gt&&(En=Gt);const In=this.subarray(Gt,En);return Object.setPrototypeOf(In,we.prototype),In};function gn(Gt,En,xn){if(Gt%1!==0||Gt<0)throw new RangeError("offset is not uint");if(Gt+En>xn)throw new RangeError("Trying to access beyond buffer length")}we.prototype.readUintLE=we.prototype.readUIntLE=function(Gt,En,xn){Gt=Gt>>>0,En=En>>>0,xn||gn(Gt,En,this.length);let In=this[Gt],Wn=1,jn=0;for(;++jn<En&&(Wn*=256);)In+=this[Gt+jn]*Wn;return In},we.prototype.readUintBE=we.prototype.readUIntBE=function(Gt,En,xn){Gt=Gt>>>0,En=En>>>0,xn||gn(Gt,En,this.length);let In=this[Gt+--En],Wn=1;for(;En>0&&(Wn*=256);)In+=this[Gt+--En]*Wn;return In},we.prototype.readUint8=we.prototype.readUInt8=function(Gt,En){return Gt=Gt>>>0,En||gn(Gt,1,this.length),this[Gt]},we.prototype.readUint16LE=we.prototype.readUInt16LE=function(Gt,En){return Gt=Gt>>>0,En||gn(Gt,2,this.length),this[Gt]|this[Gt+1]<<8},we.prototype.readUint16BE=we.prototype.readUInt16BE=function(Gt,En){return Gt=Gt>>>0,En||gn(Gt,2,this.length),this[Gt]<<8|this[Gt+1]},we.prototype.readUint32LE=we.prototype.readUInt32LE=function(Gt,En){return Gt=Gt>>>0,En||gn(Gt,4,this.length),(this[Gt]|this[Gt+1]<<8|this[Gt+2]<<16)+this[Gt+3]*16777216},we.prototype.readUint32BE=we.prototype.readUInt32BE=function(Gt,En){return Gt=Gt>>>0,En||gn(Gt,4,this.length),this[Gt]*16777216+(this[Gt+1]<<16|this[Gt+2]<<8|this[Gt+3])},we.prototype.readBigUInt64LE=ti(function(Gt){Gt=Gt>>>0,Zn(Gt,"offset");const En=this[Gt],xn=this[Gt+7];(En===void 0||xn===void 0)&&qn(Gt,this.length-8);const In=En+this[++Gt]*2**8+this[++Gt]*2**16+this[++Gt]*2**24,Wn=this[++Gt]+this[++Gt]*2**8+this[++Gt]*2**16+xn*2**24;return BigInt(In)+(BigInt(Wn)<<BigInt(32))}),we.prototype.readBigUInt64BE=ti(function(Gt){Gt=Gt>>>0,Zn(Gt,"offset");const En=this[Gt],xn=this[Gt+7];(En===void 0||xn===void 0)&&qn(Gt,this.length-8);const In=En*2**24+this[++Gt]*2**16+this[++Gt]*2**8+this[++Gt],Wn=this[++Gt]*2**24+this[++Gt]*2**16+this[++Gt]*2**8+xn;return(BigInt(In)<<BigInt(32))+BigInt(Wn)}),we.prototype.readIntLE=function(Gt,En,xn){Gt=Gt>>>0,En=En>>>0,xn||gn(Gt,En,this.length);let In=this[Gt],Wn=1,jn=0;for(;++jn<En&&(Wn*=256);)In+=this[Gt+jn]*Wn;return Wn*=128,In>=Wn&&(In-=Math.pow(2,8*En)),In},we.prototype.readIntBE=function(Gt,En,xn){Gt=Gt>>>0,En=En>>>0,xn||gn(Gt,En,this.length);let In=En,Wn=1,jn=this[Gt+--In];for(;In>0&&(Wn*=256);)jn+=this[Gt+--In]*Wn;return Wn*=128,jn>=Wn&&(jn-=Math.pow(2,8*En)),jn},we.prototype.readInt8=function(Gt,En){return Gt=Gt>>>0,En||gn(Gt,1,this.length),this[Gt]&128?(255-this[Gt]+1)*-1:this[Gt]},we.prototype.readInt16LE=function(Gt,En){Gt=Gt>>>0,En||gn(Gt,2,this.length);const xn=this[Gt]|this[Gt+1]<<8;return xn&32768?xn|4294901760:xn},we.prototype.readInt16BE=function(Gt,En){Gt=Gt>>>0,En||gn(Gt,2,this.length);const xn=this[Gt+1]|this[Gt]<<8;return xn&32768?xn|4294901760:xn},we.prototype.readInt32LE=function(Gt,En){return Gt=Gt>>>0,En||gn(Gt,4,this.length),this[Gt]|this[Gt+1]<<8|this[Gt+2]<<16|this[Gt+3]<<24},we.prototype.readInt32BE=function(Gt,En){return Gt=Gt>>>0,En||gn(Gt,4,this.length),this[Gt]<<24|this[Gt+1]<<16|this[Gt+2]<<8|this[Gt+3]},we.prototype.readBigInt64LE=ti(function(Gt){Gt=Gt>>>0,Zn(Gt,"offset");const En=this[Gt],xn=this[Gt+7];(En===void 0||xn===void 0)&&qn(Gt,this.length-8);const In=this[Gt+4]+this[Gt+5]*2**8+this[Gt+6]*2**16+(xn<<24);return(BigInt(In)<<BigInt(32))+BigInt(En+this[++Gt]*2**8+this[++Gt]*2**16+this[++Gt]*2**24)}),we.prototype.readBigInt64BE=ti(function(Gt){Gt=Gt>>>0,Zn(Gt,"offset");const En=this[Gt],xn=this[Gt+7];(En===void 0||xn===void 0)&&qn(Gt,this.length-8);const In=(En<<24)+this[++Gt]*2**16+this[++Gt]*2**8+this[++Gt];return(BigInt(In)<<BigInt(32))+BigInt(this[++Gt]*2**24+this[++Gt]*2**16+this[++Gt]*2**8+xn)}),we.prototype.readFloatLE=function(Gt,En){return Gt=Gt>>>0,En||gn(Gt,4,this.length),c.read(this,Gt,!0,23,4)},we.prototype.readFloatBE=function(Gt,En){return Gt=Gt>>>0,En||gn(Gt,4,this.length),c.read(this,Gt,!1,23,4)},we.prototype.readDoubleLE=function(Gt,En){return Gt=Gt>>>0,En||gn(Gt,8,this.length),c.read(this,Gt,!0,52,8)},we.prototype.readDoubleBE=function(Gt,En){return Gt=Gt>>>0,En||gn(Gt,8,this.length),c.read(this,Gt,!1,52,8)};function Vt(Gt,En,xn,In,Wn,jn){if(!we.isBuffer(Gt))throw new TypeError('"buffer" argument must be a Buffer instance');if(En>Wn||En<jn)throw new RangeError('"value" argument is out of bounds');if(xn+In>Gt.length)throw new RangeError("Index out of range")}we.prototype.writeUintLE=we.prototype.writeUIntLE=function(Gt,En,xn,In){if(Gt=+Gt,En=En>>>0,xn=xn>>>0,!In){const zn=Math.pow(2,8*xn)-1;Vt(this,Gt,En,xn,zn,0)}let Wn=1,jn=0;for(this[En]=Gt&255;++jn<xn&&(Wn*=256);)this[En+jn]=Gt/Wn&255;return En+xn},we.prototype.writeUintBE=we.prototype.writeUIntBE=function(Gt,En,xn,In){if(Gt=+Gt,En=En>>>0,xn=xn>>>0,!In){const zn=Math.pow(2,8*xn)-1;Vt(this,Gt,En,xn,zn,0)}let Wn=xn-1,jn=1;for(this[En+Wn]=Gt&255;--Wn>=0&&(jn*=256);)this[En+Wn]=Gt/jn&255;return En+xn},we.prototype.writeUint8=we.prototype.writeUInt8=function(Gt,En,xn){return Gt=+Gt,En=En>>>0,xn||Vt(this,Gt,En,1,255,0),this[En]=Gt&255,En+1},we.prototype.writeUint16LE=we.prototype.writeUInt16LE=function(Gt,En,xn){return Gt=+Gt,En=En>>>0,xn||Vt(this,Gt,En,2,65535,0),this[En]=Gt&255,this[En+1]=Gt>>>8,En+2},we.prototype.writeUint16BE=we.prototype.writeUInt16BE=function(Gt,En,xn){return Gt=+Gt,En=En>>>0,xn||Vt(this,Gt,En,2,65535,0),this[En]=Gt>>>8,this[En+1]=Gt&255,En+2},we.prototype.writeUint32LE=we.prototype.writeUInt32LE=function(Gt,En,xn){return Gt=+Gt,En=En>>>0,xn||Vt(this,Gt,En,4,4294967295,0),this[En+3]=Gt>>>24,this[En+2]=Gt>>>16,this[En+1]=Gt>>>8,this[En]=Gt&255,En+4},we.prototype.writeUint32BE=we.prototype.writeUInt32BE=function(Gt,En,xn){return Gt=+Gt,En=En>>>0,xn||Vt(this,Gt,En,4,4294967295,0),this[En]=Gt>>>24,this[En+1]=Gt>>>16,this[En+2]=Gt>>>8,this[En+3]=Gt&255,En+4};function Cn(Gt,En,xn,In,Wn){Nn(En,In,Wn,Gt,xn,7);let jn=Number(En&BigInt(4294967295));Gt[xn++]=jn,jn=jn>>8,Gt[xn++]=jn,jn=jn>>8,Gt[xn++]=jn,jn=jn>>8,Gt[xn++]=jn;let zn=Number(En>>BigInt(32)&BigInt(4294967295));return Gt[xn++]=zn,zn=zn>>8,Gt[xn++]=zn,zn=zn>>8,Gt[xn++]=zn,zn=zn>>8,Gt[xn++]=zn,xn}function un(Gt,En,xn,In,Wn){Nn(En,In,Wn,Gt,xn,7);let jn=Number(En&BigInt(4294967295));Gt[xn+7]=jn,jn=jn>>8,Gt[xn+6]=jn,jn=jn>>8,Gt[xn+5]=jn,jn=jn>>8,Gt[xn+4]=jn;let zn=Number(En>>BigInt(32)&BigInt(4294967295));return Gt[xn+3]=zn,zn=zn>>8,Gt[xn+2]=zn,zn=zn>>8,Gt[xn+1]=zn,zn=zn>>8,Gt[xn]=zn,xn+8}we.prototype.writeBigUInt64LE=ti(function(Gt,En=0){return Cn(this,Gt,En,BigInt(0),BigInt("0xffffffffffffffff"))}),we.prototype.writeBigUInt64BE=ti(function(Gt,En=0){return un(this,Gt,En,BigInt(0),BigInt("0xffffffffffffffff"))}),we.prototype.writeIntLE=function(Gt,En,xn,In){if(Gt=+Gt,En=En>>>0,!In){const Ri=Math.pow(2,8*xn-1);Vt(this,Gt,En,xn,Ri-1,-Ri)}let Wn=0,jn=1,zn=0;for(this[En]=Gt&255;++Wn<xn&&(jn*=256);)Gt<0&&zn===0&&this[En+Wn-1]!==0&&(zn=1),this[En+Wn]=(Gt/jn>>0)-zn&255;return En+xn},we.prototype.writeIntBE=function(Gt,En,xn,In){if(Gt=+Gt,En=En>>>0,!In){const Ri=Math.pow(2,8*xn-1);Vt(this,Gt,En,xn,Ri-1,-Ri)}let Wn=xn-1,jn=1,zn=0;for(this[En+Wn]=Gt&255;--Wn>=0&&(jn*=256);)Gt<0&&zn===0&&this[En+Wn+1]!==0&&(zn=1),this[En+Wn]=(Gt/jn>>0)-zn&255;return En+xn},we.prototype.writeInt8=function(Gt,En,xn){return Gt=+Gt,En=En>>>0,xn||Vt(this,Gt,En,1,127,-128),Gt<0&&(Gt=255+Gt+1),this[En]=Gt&255,En+1},we.prototype.writeInt16LE=function(Gt,En,xn){return Gt=+Gt,En=En>>>0,xn||Vt(this,Gt,En,2,32767,-32768),this[En]=Gt&255,this[En+1]=Gt>>>8,En+2},we.prototype.writeInt16BE=function(Gt,En,xn){return Gt=+Gt,En=En>>>0,xn||Vt(this,Gt,En,2,32767,-32768),this[En]=Gt>>>8,this[En+1]=Gt&255,En+2},we.prototype.writeInt32LE=function(Gt,En,xn){return Gt=+Gt,En=En>>>0,xn||Vt(this,Gt,En,4,2147483647,-2147483648),this[En]=Gt&255,this[En+1]=Gt>>>8,this[En+2]=Gt>>>16,this[En+3]=Gt>>>24,En+4},we.prototype.writeInt32BE=function(Gt,En,xn){return Gt=+Gt,En=En>>>0,xn||Vt(this,Gt,En,4,2147483647,-2147483648),Gt<0&&(Gt=4294967295+Gt+1),this[En]=Gt>>>24,this[En+1]=Gt>>>16,this[En+2]=Gt>>>8,this[En+3]=Gt&255,En+4},we.prototype.writeBigInt64LE=ti(function(Gt,En=0){return Cn(this,Gt,En,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),we.prototype.writeBigInt64BE=ti(function(Gt,En=0){return un(this,Gt,En,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Pt(Gt,En,xn,In,Wn,jn){if(xn+In>Gt.length)throw new RangeError("Index out of range");if(xn<0)throw new RangeError("Index out of range")}function mn(Gt,En,xn,In,Wn){return En=+En,xn=xn>>>0,Wn||Pt(Gt,En,xn,4),c.write(Gt,En,xn,In,23,4),xn+4}we.prototype.writeFloatLE=function(Gt,En,xn){return mn(this,Gt,En,!0,xn)},we.prototype.writeFloatBE=function(Gt,En,xn){return mn(this,Gt,En,!1,xn)};function Pn(Gt,En,xn,In,Wn){return En=+En,xn=xn>>>0,Wn||Pt(Gt,En,xn,8),c.write(Gt,En,xn,In,52,8),xn+8}we.prototype.writeDoubleLE=function(Gt,En,xn){return Pn(this,Gt,En,!0,xn)},we.prototype.writeDoubleBE=function(Gt,En,xn){return Pn(this,Gt,En,!1,xn)},we.prototype.copy=function(Gt,En,xn,In){if(!we.isBuffer(Gt))throw new TypeError("argument should be a Buffer");if(xn||(xn=0),!In&&In!==0&&(In=this.length),En>=Gt.length&&(En=Gt.length),En||(En=0),In>0&&In<xn&&(In=xn),In===xn||Gt.length===0||this.length===0)return 0;if(En<0)throw new RangeError("targetStart out of bounds");if(xn<0||xn>=this.length)throw new RangeError("Index out of range");if(In<0)throw new RangeError("sourceEnd out of bounds");In>this.length&&(In=this.length),Gt.length-En<In-xn&&(In=Gt.length-En+xn);const Wn=In-xn;return this===Gt&&typeof ae.prototype.copyWithin=="function"?this.copyWithin(En,xn,In):ae.prototype.set.call(Gt,this.subarray(xn,In),En),Wn},we.prototype.fill=function(Gt,En,xn,In){if(typeof Gt=="string"){if(typeof En=="string"?(In=En,En=0,xn=this.length):typeof xn=="string"&&(In=xn,xn=this.length),In!==void 0&&typeof In!="string")throw new TypeError("encoding must be a string");if(typeof In=="string"&&!we.isEncoding(In))throw new TypeError("Unknown encoding: "+In);if(Gt.length===1){const jn=Gt.charCodeAt(0);(In==="utf8"&&jn<128||In==="latin1")&&(Gt=jn)}}else typeof Gt=="number"?Gt=Gt&255:typeof Gt=="boolean"&&(Gt=Number(Gt));if(En<0||this.length<En||this.length<xn)throw new RangeError("Out of range index");if(xn<=En)return this;En=En>>>0,xn=xn===void 0?this.length:xn>>>0,Gt||(Gt=0);let Wn;if(typeof Gt=="number")for(Wn=En;Wn<xn;++Wn)this[Wn]=Gt;else{const jn=we.isBuffer(Gt)?Gt:we.from(Gt,In),zn=jn.length;if(zn===0)throw new TypeError('The value "'+Gt+'" is invalid for argument "value"');for(Wn=0;Wn<xn-En;++Wn)this[Wn+En]=jn[Wn%zn]}return this};const wn={};function jt(Gt,En,xn){wn[Gt]=class extends xn{constructor(){super(),Object.defineProperty(this,"message",{value:En.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${Gt}]`,this.stack,delete this.name}get code(){return Gt}set code(In){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:In,writable:!0})}toString(){return`${this.name} [${Gt}]: ${this.message}`}}}jt("ERR_BUFFER_OUT_OF_BOUNDS",function(Gt){return Gt?`${Gt} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),jt("ERR_INVALID_ARG_TYPE",function(Gt,En){return`The "${Gt}" argument must be of type number. Received type ${typeof En}`},TypeError),jt("ERR_OUT_OF_RANGE",function(Gt,En,xn){let In=`The value of "${Gt}" is out of range.`,Wn=xn;return Number.isInteger(xn)&&Math.abs(xn)>2**32?Wn=$n(String(xn)):typeof xn=="bigint"&&(Wn=String(xn),(xn>BigInt(2)**BigInt(32)||xn<-(BigInt(2)**BigInt(32)))&&(Wn=$n(Wn)),Wn+="n"),In+=` It must be ${En}. Received ${Wn}`,In},RangeError);function $n(Gt){let En="",xn=Gt.length;const In=Gt[0]==="-"?1:0;for(;xn>=In+4;xn-=3)En=`_${Gt.slice(xn-3,xn)}${En}`;return`${Gt.slice(0,xn)}${En}`}function Mn(Gt,En,xn){Zn(En,"offset"),(Gt[En]===void 0||Gt[En+xn]===void 0)&&qn(En,Gt.length-(xn+1))}function Nn(Gt,En,xn,In,Wn,jn){if(Gt>xn||Gt<En){const zn=typeof En=="bigint"?"n":"";let Ri;throw En===0||En===BigInt(0)?Ri=`>= 0${zn} and < 2${zn} ** ${(jn+1)*8}${zn}`:Ri=`>= -(2${zn} ** ${(jn+1)*8-1}${zn}) and < 2 ** ${(jn+1)*8-1}${zn}`,new wn.ERR_OUT_OF_RANGE("value",Ri,Gt)}Mn(In,Wn,jn)}function Zn(Gt,En){if(typeof Gt!="number")throw new wn.ERR_INVALID_ARG_TYPE(En,"number",Gt)}function qn(Gt,En,xn){throw Math.floor(Gt)!==Gt?(Zn(Gt,xn),new wn.ERR_OUT_OF_RANGE("offset","an integer",Gt)):En<0?new wn.ERR_BUFFER_OUT_OF_BOUNDS:new wn.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${En}`,Gt)}const Vn=/[^+/0-9A-Za-z-_]/g;function Gn(Gt){if(Gt=Gt.split("=")[0],Gt=Gt.trim().replace(Vn,""),Gt.length<2)return"";for(;Gt.length%4!==0;)Gt=Gt+"=";return Gt}function Kn(Gt,En){En=En||1/0;let xn;const In=Gt.length;let Wn=null;const jn=[];for(let zn=0;zn<In;++zn){if(xn=Gt.charCodeAt(zn),xn>55295&&xn<57344){if(!Wn){if(xn>56319){(En-=3)>-1&&jn.push(239,191,189);continue}else if(zn+1===In){(En-=3)>-1&&jn.push(239,191,189);continue}Wn=xn;continue}if(xn<56320){(En-=3)>-1&&jn.push(239,191,189),Wn=xn;continue}xn=(Wn-55296<<10|xn-56320)+65536}else Wn&&(En-=3)>-1&&jn.push(239,191,189);if(Wn=null,xn<128){if((En-=1)<0)break;jn.push(xn)}else if(xn<2048){if((En-=2)<0)break;jn.push(xn>>6|192,xn&63|128)}else if(xn<65536){if((En-=3)<0)break;jn.push(xn>>12|224,xn>>6&63|128,xn&63|128)}else if(xn<1114112){if((En-=4)<0)break;jn.push(xn>>18|240,xn>>12&63|128,xn>>6&63|128,xn&63|128)}else throw new Error("Invalid code point")}return jn}function Jn(Gt){const En=[];for(let xn=0;xn<Gt.length;++xn)En.push(Gt.charCodeAt(xn)&255);return En}function bi(Gt,En){let xn,In,Wn;const jn=[];for(let zn=0;zn<Gt.length&&!((En-=2)<0);++zn)xn=Gt.charCodeAt(zn),In=xn>>8,Wn=xn%256,jn.push(Wn),jn.push(In);return jn}function Hn(Gt){return t.toByteArray(Gn(Gt))}function An(Gt,En,xn,In){let Wn;for(Wn=0;Wn<In&&!(Wn+xn>=En.length||Wn>=Gt.length);++Wn)En[Wn+xn]=Gt[Wn];return Wn}function Ln(Gt,En){return Gt instanceof En||Gt!=null&&Gt.constructor!=null&&Gt.constructor.name!=null&&Gt.constructor.name===En.name}function On(Gt){return Gt!==Gt}const Un=(function(){const Gt="0123456789abcdef",En=new Array(256);for(let xn=0;xn<16;++xn){const In=xn*16;for(let Wn=0;Wn<16;++Wn)En[In+Wn]=Gt[xn]+Gt[Wn]}return En})();function ti(Gt){return typeof BigInt>"u"?Fn:Gt}function Fn(){throw new Error("BigInt not supported")}})(buffer$1);const Buffer$7=buffer$1.Buffer,Blob$2=buffer$1.Blob,BlobOptions=buffer$1.BlobOptions,Buffer$1$1=buffer$1.Buffer,File=buffer$1.File,FileOptions=buffer$1.FileOptions,INSPECT_MAX_BYTES=buffer$1.INSPECT_MAX_BYTES,SlowBuffer=buffer$1.SlowBuffer,TranscodeEncoding=buffer$1.TranscodeEncoding,atob$1=buffer$1.atob,btoa$1=buffer$1.btoa,constants$4=buffer$1.constants,isAscii=buffer$1.isAscii,isUtf8=buffer$1.isUtf8,kMaxLength=buffer$1.kMaxLength,kStringMaxLength=buffer$1.kStringMaxLength,resolveObjectURL=buffer$1.resolveObjectURL,transcode=buffer$1.transcode,dist$1=Object.freeze(Object.defineProperty({__proto__:null,Blob:Blob$2,BlobOptions,Buffer:Buffer$1$1,File,FileOptions,INSPECT_MAX_BYTES,SlowBuffer,TranscodeEncoding,atob:atob$1,btoa:btoa$1,constants:constants$4,default:Buffer$7,isAscii,isUtf8,kMaxLength,kStringMaxLength,resolveObjectURL,transcode},Symbol.toStringTag,{value:"Module"})),require$$0$4=getAugmentedNamespace(dist$1);(function(n){(function(t,c){function ie(be,xe){if(!be)throw new Error(xe||"Assertion failed")}function se(be,xe){be.super_=xe;var _e=function(){};_e.prototype=xe.prototype,be.prototype=new _e,be.prototype.constructor=be}function ae(be,xe,_e){if(ae.isBN(be))return be;this.negative=0,this.words=null,this.length=0,this.red=null,be!==null&&((xe==="le"||xe==="be")&&(_e=xe,xe=10),this._init(be||0,xe||10,_e||"be"))}typeof t=="object"?t.exports=ae:c.BN=ae,ae.BN=ae,ae.wordSize=26;var ue;try{typeof window<"u"&&typeof window.Buffer<"u"?ue=window.Buffer:ue=require$$0$4.Buffer}catch{}ae.isBN=function(be){return be instanceof ae?!0:be!==null&&typeof be=="object"&&be.constructor.wordSize===ae.wordSize&&Array.isArray(be.words)},ae.max=function(be,xe){return be.cmp(xe)>0?be:xe},ae.min=function(be,xe){return be.cmp(xe)<0?be:xe},ae.prototype._init=function(be,xe,_e){if(typeof be=="number")return this._initNumber(be,xe,_e);if(typeof be=="object")return this._initArray(be,xe,_e);xe==="hex"&&(xe=16),ie(xe===(xe|0)&&xe>=2&&xe<=36),be=be.toString().replace(/\s+/g,"");var De=0;be[0]==="-"&&(De++,this.negative=1),De<be.length&&(xe===16?this._parseHex(be,De,_e):(this._parseBase(be,xe,De),_e==="le"&&this._initArray(this.toArray(),xe,_e)))},ae.prototype._initNumber=function(be,xe,_e){be<0&&(this.negative=1,be=-be),be<67108864?(this.words=[be&67108863],this.length=1):be<4503599627370496?(this.words=[be&67108863,be/67108864&67108863],this.length=2):(ie(be<9007199254740992),this.words=[be&67108863,be/67108864&67108863,1],this.length=3),_e==="le"&&this._initArray(this.toArray(),xe,_e)},ae.prototype._initArray=function(be,xe,_e){if(ie(typeof be.length=="number"),be.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(be.length/3),this.words=new Array(this.length);for(var De=0;De<this.length;De++)this.words[De]=0;var Fe,$e,ce=0;if(_e==="be")for(De=be.length-1,Fe=0;De>=0;De-=3)$e=be[De]|be[De-1]<<8|be[De-2]<<16,this.words[Fe]|=$e<<ce&67108863,this.words[Fe+1]=$e>>>26-ce&67108863,ce+=24,ce>=26&&(ce-=26,Fe++);else if(_e==="le")for(De=0,Fe=0;De<be.length;De+=3)$e=be[De]|be[De+1]<<8|be[De+2]<<16,this.words[Fe]|=$e<<ce&67108863,this.words[Fe+1]=$e>>>26-ce&67108863,ce+=24,ce>=26&&(ce-=26,Fe++);return this._strip()};function de(be,xe){var _e=be.charCodeAt(xe);if(_e>=48&&_e<=57)return _e-48;if(_e>=65&&_e<=70)return _e-55;if(_e>=97&&_e<=102)return _e-87;ie(!1,"Invalid character in "+be)}function ve(be,xe,_e){var De=de(be,_e);return _e-1>=xe&&(De|=de(be,_e-1)<<4),De}ae.prototype._parseHex=function(be,xe,_e){this.length=Math.ceil((be.length-xe)/6),this.words=new Array(this.length);for(var De=0;De<this.length;De++)this.words[De]=0;var Fe=0,$e=0,ce;if(_e==="be")for(De=be.length-1;De>=xe;De-=2)ce=ve(be,xe,De)<<Fe,this.words[$e]|=ce&67108863,Fe>=18?(Fe-=18,$e+=1,this.words[$e]|=ce>>>26):Fe+=8;else{var Me=be.length-xe;for(De=Me%2===0?xe+1:xe;De<be.length;De+=2)ce=ve(be,xe,De)<<Fe,this.words[$e]|=ce&67108863,Fe>=18?(Fe-=18,$e+=1,this.words[$e]|=ce>>>26):Fe+=8}this._strip()};function ge(be,xe,_e,De){for(var Fe=0,$e=0,ce=Math.min(be.length,_e),Me=xe;Me<ce;Me++){var We=be.charCodeAt(Me)-48;Fe*=De,We>=49?$e=We-49+10:We>=17?$e=We-17+10:$e=We,ie(We>=0&&$e<De,"Invalid character"),Fe+=$e}return Fe}ae.prototype._parseBase=function(be,xe,_e){this.words=[0],this.length=1;for(var De=0,Fe=1;Fe<=67108863;Fe*=xe)De++;De--,Fe=Fe/xe|0;for(var $e=be.length-_e,ce=$e%De,Me=Math.min($e,$e-ce)+_e,We=0,$t=_e;$t<Me;$t+=De)We=ge(be,$t,$t+De,xe),this.imuln(Fe),this.words[0]+We<67108864?this.words[0]+=We:this._iaddn(We);if(ce!==0){var dn=1;for(We=ge(be,$t,be.length,xe),$t=0;$t<ce;$t++)dn*=xe;this.imuln(dn),this.words[0]+We<67108864?this.words[0]+=We:this._iaddn(We)}this._strip()},ae.prototype.copy=function(be){be.words=new Array(this.length);for(var xe=0;xe<this.length;xe++)be.words[xe]=this.words[xe];be.length=this.length,be.negative=this.negative,be.red=this.red};function we(be,xe){be.words=xe.words,be.length=xe.length,be.negative=xe.negative,be.red=xe.red}if(ae.prototype._move=function(be){we(be,this)},ae.prototype.clone=function(){var be=new ae(null);return this.copy(be),be},ae.prototype._expand=function(be){for(;this.length<be;)this.words[this.length++]=0;return this},ae.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},ae.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{ae.prototype[Symbol.for("nodejs.util.inspect.custom")]=Te}catch{ae.prototype.inspect=Te}else ae.prototype.inspect=Te;function Te(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var Ne=["","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"],qe=[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],ze=[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];ae.prototype.toString=function(be,xe){be=be||10,xe=xe|0||1;var _e;if(be===16||be==="hex"){_e="";for(var De=0,Fe=0,$e=0;$e<this.length;$e++){var ce=this.words[$e],Me=((ce<<De|Fe)&16777215).toString(16);Fe=ce>>>24-De&16777215,De+=2,De>=26&&(De-=26,$e--),Fe!==0||$e!==this.length-1?_e=Ne[6-Me.length]+Me+_e:_e=Me+_e}for(Fe!==0&&(_e=Fe.toString(16)+_e);_e.length%xe!==0;)_e="0"+_e;return this.negative!==0&&(_e="-"+_e),_e}if(be===(be|0)&&be>=2&&be<=36){var We=qe[be],$t=ze[be];_e="";var dn=this.clone();for(dn.negative=0;!dn.isZero();){var gn=dn.modrn($t).toString(be);dn=dn.idivn($t),dn.isZero()?_e=gn+_e:_e=Ne[We-gn.length]+gn+_e}for(this.isZero()&&(_e="0"+_e);_e.length%xe!==0;)_e="0"+_e;return this.negative!==0&&(_e="-"+_e),_e}ie(!1,"Base should be between 2 and 36")},ae.prototype.toNumber=function(){var be=this.words[0];return this.length===2?be+=this.words[1]*67108864:this.length===3&&this.words[2]===1?be+=4503599627370496+this.words[1]*67108864:this.length>2&&ie(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-be:be},ae.prototype.toJSON=function(){return this.toString(16,2)},ue&&(ae.prototype.toBuffer=function(be,xe){return this.toArrayLike(ue,be,xe)}),ae.prototype.toArray=function(be,xe){return this.toArrayLike(Array,be,xe)};var He=function(be,xe){return be.allocUnsafe?be.allocUnsafe(xe):new be(xe)};ae.prototype.toArrayLike=function(be,xe,_e){this._strip();var De=this.byteLength(),Fe=_e||Math.max(1,De);ie(De<=Fe,"byte array longer than desired length"),ie(Fe>0,"Requested array length <= 0");var $e=He(be,Fe),ce=xe==="le"?"LE":"BE";return this["_toArrayLike"+ce]($e,De),$e},ae.prototype._toArrayLikeLE=function(be,xe){for(var _e=0,De=0,Fe=0,$e=0;Fe<this.length;Fe++){var ce=this.words[Fe]<<$e|De;be[_e++]=ce&255,_e<be.length&&(be[_e++]=ce>>8&255),_e<be.length&&(be[_e++]=ce>>16&255),$e===6?(_e<be.length&&(be[_e++]=ce>>24&255),De=0,$e=0):(De=ce>>>24,$e+=2)}if(_e<be.length)for(be[_e++]=De;_e<be.length;)be[_e++]=0},ae.prototype._toArrayLikeBE=function(be,xe){for(var _e=be.length-1,De=0,Fe=0,$e=0;Fe<this.length;Fe++){var ce=this.words[Fe]<<$e|De;be[_e--]=ce&255,_e>=0&&(be[_e--]=ce>>8&255),_e>=0&&(be[_e--]=ce>>16&255),$e===6?(_e>=0&&(be[_e--]=ce>>24&255),De=0,$e=0):(De=ce>>>24,$e+=2)}if(_e>=0)for(be[_e--]=De;_e>=0;)be[_e--]=0},Math.clz32?ae.prototype._countBits=function(be){return 32-Math.clz32(be)}:ae.prototype._countBits=function(be){var xe=be,_e=0;return xe>=4096&&(_e+=13,xe>>>=13),xe>=64&&(_e+=7,xe>>>=7),xe>=8&&(_e+=4,xe>>>=4),xe>=2&&(_e+=2,xe>>>=2),_e+xe},ae.prototype._zeroBits=function(be){if(be===0)return 26;var xe=be,_e=0;return xe&8191||(_e+=13,xe>>>=13),xe&127||(_e+=7,xe>>>=7),xe&15||(_e+=4,xe>>>=4),xe&3||(_e+=2,xe>>>=2),xe&1||_e++,_e},ae.prototype.bitLength=function(){var be=this.words[this.length-1],xe=this._countBits(be);return(this.length-1)*26+xe};function Ge(be){for(var xe=new Array(be.bitLength()),_e=0;_e<xe.length;_e++){var De=_e/26|0,Fe=_e%26;xe[_e]=be.words[De]>>>Fe&1}return xe}ae.prototype.zeroBits=function(){if(this.isZero())return 0;for(var be=0,xe=0;xe<this.length;xe++){var _e=this._zeroBits(this.words[xe]);if(be+=_e,_e!==26)break}return be},ae.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},ae.prototype.toTwos=function(be){return this.negative!==0?this.abs().inotn(be).iaddn(1):this.clone()},ae.prototype.fromTwos=function(be){return this.testn(be-1)?this.notn(be).iaddn(1).ineg():this.clone()},ae.prototype.isNeg=function(){return this.negative!==0},ae.prototype.neg=function(){return this.clone().ineg()},ae.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},ae.prototype.iuor=function(be){for(;this.length<be.length;)this.words[this.length++]=0;for(var xe=0;xe<be.length;xe++)this.words[xe]=this.words[xe]|be.words[xe];return this._strip()},ae.prototype.ior=function(be){return ie((this.negative|be.negative)===0),this.iuor(be)},ae.prototype.or=function(be){return this.length>be.length?this.clone().ior(be):be.clone().ior(this)},ae.prototype.uor=function(be){return this.length>be.length?this.clone().iuor(be):be.clone().iuor(this)},ae.prototype.iuand=function(be){var xe;this.length>be.length?xe=be:xe=this;for(var _e=0;_e<xe.length;_e++)this.words[_e]=this.words[_e]&be.words[_e];return this.length=xe.length,this._strip()},ae.prototype.iand=function(be){return ie((this.negative|be.negative)===0),this.iuand(be)},ae.prototype.and=function(be){return this.length>be.length?this.clone().iand(be):be.clone().iand(this)},ae.prototype.uand=function(be){return this.length>be.length?this.clone().iuand(be):be.clone().iuand(this)},ae.prototype.iuxor=function(be){var xe,_e;this.length>be.length?(xe=this,_e=be):(xe=be,_e=this);for(var De=0;De<_e.length;De++)this.words[De]=xe.words[De]^_e.words[De];if(this!==xe)for(;De<xe.length;De++)this.words[De]=xe.words[De];return this.length=xe.length,this._strip()},ae.prototype.ixor=function(be){return ie((this.negative|be.negative)===0),this.iuxor(be)},ae.prototype.xor=function(be){return this.length>be.length?this.clone().ixor(be):be.clone().ixor(this)},ae.prototype.uxor=function(be){return this.length>be.length?this.clone().iuxor(be):be.clone().iuxor(this)},ae.prototype.inotn=function(be){ie(typeof be=="number"&&be>=0);var xe=Math.ceil(be/26)|0,_e=be%26;this._expand(xe),_e>0&&xe--;for(var De=0;De<xe;De++)this.words[De]=~this.words[De]&67108863;return _e>0&&(this.words[De]=~this.words[De]&67108863>>26-_e),this._strip()},ae.prototype.notn=function(be){return this.clone().inotn(be)},ae.prototype.setn=function(be,xe){ie(typeof be=="number"&&be>=0);var _e=be/26|0,De=be%26;return this._expand(_e+1),xe?this.words[_e]=this.words[_e]|1<<De:this.words[_e]=this.words[_e]&~(1<<De),this._strip()},ae.prototype.iadd=function(be){var xe;if(this.negative!==0&&be.negative===0)return this.negative=0,xe=this.isub(be),this.negative^=1,this._normSign();if(this.negative===0&&be.negative!==0)return be.negative=0,xe=this.isub(be),be.negative=1,xe._normSign();var _e,De;this.length>be.length?(_e=this,De=be):(_e=be,De=this);for(var Fe=0,$e=0;$e<De.length;$e++)xe=(_e.words[$e]|0)+(De.words[$e]|0)+Fe,this.words[$e]=xe&67108863,Fe=xe>>>26;for(;Fe!==0&&$e<_e.length;$e++)xe=(_e.words[$e]|0)+Fe,this.words[$e]=xe&67108863,Fe=xe>>>26;if(this.length=_e.length,Fe!==0)this.words[this.length]=Fe,this.length++;else if(_e!==this)for(;$e<_e.length;$e++)this.words[$e]=_e.words[$e];return this},ae.prototype.add=function(be){var xe;return be.negative!==0&&this.negative===0?(be.negative=0,xe=this.sub(be),be.negative^=1,xe):be.negative===0&&this.negative!==0?(this.negative=0,xe=be.sub(this),this.negative=1,xe):this.length>be.length?this.clone().iadd(be):be.clone().iadd(this)},ae.prototype.isub=function(be){if(be.negative!==0){be.negative=0;var xe=this.iadd(be);return be.negative=1,xe._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(be),this.negative=1,this._normSign();var _e=this.cmp(be);if(_e===0)return this.negative=0,this.length=1,this.words[0]=0,this;var De,Fe;_e>0?(De=this,Fe=be):(De=be,Fe=this);for(var $e=0,ce=0;ce<Fe.length;ce++)xe=(De.words[ce]|0)-(Fe.words[ce]|0)+$e,$e=xe>>26,this.words[ce]=xe&67108863;for(;$e!==0&&ce<De.length;ce++)xe=(De.words[ce]|0)+$e,$e=xe>>26,this.words[ce]=xe&67108863;if($e===0&&ce<De.length&&De!==this)for(;ce<De.length;ce++)this.words[ce]=De.words[ce];return this.length=Math.max(this.length,ce),De!==this&&(this.negative=1),this._strip()},ae.prototype.sub=function(be){return this.clone().isub(be)};function Ze(be,xe,_e){_e.negative=xe.negative^be.negative;var De=be.length+xe.length|0;_e.length=De,De=De-1|0;var Fe=be.words[0]|0,$e=xe.words[0]|0,ce=Fe*$e,Me=ce&67108863,We=ce/67108864|0;_e.words[0]=Me;for(var $t=1;$t<De;$t++){for(var dn=We>>>26,gn=We&67108863,Vt=Math.min($t,xe.length-1),Cn=Math.max(0,$t-be.length+1);Cn<=Vt;Cn++){var un=$t-Cn|0;Fe=be.words[un]|0,$e=xe.words[Cn]|0,ce=Fe*$e+gn,dn+=ce/67108864|0,gn=ce&67108863}_e.words[$t]=gn|0,We=dn|0}return We!==0?_e.words[$t]=We|0:_e.length--,_e._strip()}var Ye=function(be,xe,_e){var De=be.words,Fe=xe.words,$e=_e.words,ce=0,Me,We,$t,dn=De[0]|0,gn=dn&8191,Vt=dn>>>13,Cn=De[1]|0,un=Cn&8191,Pt=Cn>>>13,mn=De[2]|0,Pn=mn&8191,wn=mn>>>13,jt=De[3]|0,$n=jt&8191,Mn=jt>>>13,Nn=De[4]|0,Zn=Nn&8191,qn=Nn>>>13,Vn=De[5]|0,Gn=Vn&8191,Kn=Vn>>>13,Jn=De[6]|0,bi=Jn&8191,Hn=Jn>>>13,An=De[7]|0,Ln=An&8191,On=An>>>13,Un=De[8]|0,ti=Un&8191,Fn=Un>>>13,Gt=De[9]|0,En=Gt&8191,xn=Gt>>>13,In=Fe[0]|0,Wn=In&8191,jn=In>>>13,zn=Fe[1]|0,Ri=zn&8191,Qn=zn>>>13,li=Fe[2]|0,Ci=li&8191,ri=li>>>13,yi=Fe[3]|0,Ai=yi&8191,ci=yi>>>13,vi=Fe[4]|0,Mi=vi&8191,di=vi>>>13,wi=Fe[5]|0,Ti=wi&8191,hi=wi>>>13,xi=Fe[6]|0,Pi=xi&8191,pi=xi>>>13,Ei=Fe[7]|0,Bi=Ei&8191,mi=Ei>>>13,_i=Fe[8]|0,Ii=_i&8191,gi=_i>>>13,Si=Fe[9]|0,ki=Si&8191,$i=Si>>>13;_e.negative=be.negative^xe.negative,_e.length=19,Me=Math.imul(gn,Wn),We=Math.imul(gn,jn),We=We+Math.imul(Vt,Wn)|0,$t=Math.imul(Vt,jn);var Ni=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(Ni>>>26)|0,Ni&=67108863,Me=Math.imul(un,Wn),We=Math.imul(un,jn),We=We+Math.imul(Pt,Wn)|0,$t=Math.imul(Pt,jn),Me=Me+Math.imul(gn,Ri)|0,We=We+Math.imul(gn,Qn)|0,We=We+Math.imul(Vt,Ri)|0,$t=$t+Math.imul(Vt,Qn)|0;var Oi=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(Oi>>>26)|0,Oi&=67108863,Me=Math.imul(Pn,Wn),We=Math.imul(Pn,jn),We=We+Math.imul(wn,Wn)|0,$t=Math.imul(wn,jn),Me=Me+Math.imul(un,Ri)|0,We=We+Math.imul(un,Qn)|0,We=We+Math.imul(Pt,Ri)|0,$t=$t+Math.imul(Pt,Qn)|0,Me=Me+Math.imul(gn,Ci)|0,We=We+Math.imul(gn,ri)|0,We=We+Math.imul(Vt,Ci)|0,$t=$t+Math.imul(Vt,ri)|0;var Li=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(Li>>>26)|0,Li&=67108863,Me=Math.imul($n,Wn),We=Math.imul($n,jn),We=We+Math.imul(Mn,Wn)|0,$t=Math.imul(Mn,jn),Me=Me+Math.imul(Pn,Ri)|0,We=We+Math.imul(Pn,Qn)|0,We=We+Math.imul(wn,Ri)|0,$t=$t+Math.imul(wn,Qn)|0,Me=Me+Math.imul(un,Ci)|0,We=We+Math.imul(un,ri)|0,We=We+Math.imul(Pt,Ci)|0,$t=$t+Math.imul(Pt,ri)|0,Me=Me+Math.imul(gn,Ai)|0,We=We+Math.imul(gn,ci)|0,We=We+Math.imul(Vt,Ai)|0,$t=$t+Math.imul(Vt,ci)|0;var Fi=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(Fi>>>26)|0,Fi&=67108863,Me=Math.imul(Zn,Wn),We=Math.imul(Zn,jn),We=We+Math.imul(qn,Wn)|0,$t=Math.imul(qn,jn),Me=Me+Math.imul($n,Ri)|0,We=We+Math.imul($n,Qn)|0,We=We+Math.imul(Mn,Ri)|0,$t=$t+Math.imul(Mn,Qn)|0,Me=Me+Math.imul(Pn,Ci)|0,We=We+Math.imul(Pn,ri)|0,We=We+Math.imul(wn,Ci)|0,$t=$t+Math.imul(wn,ri)|0,Me=Me+Math.imul(un,Ai)|0,We=We+Math.imul(un,ci)|0,We=We+Math.imul(Pt,Ai)|0,$t=$t+Math.imul(Pt,ci)|0,Me=Me+Math.imul(gn,Mi)|0,We=We+Math.imul(gn,di)|0,We=We+Math.imul(Vt,Mi)|0,$t=$t+Math.imul(Vt,di)|0;var ji=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(ji>>>26)|0,ji&=67108863,Me=Math.imul(Gn,Wn),We=Math.imul(Gn,jn),We=We+Math.imul(Kn,Wn)|0,$t=Math.imul(Kn,jn),Me=Me+Math.imul(Zn,Ri)|0,We=We+Math.imul(Zn,Qn)|0,We=We+Math.imul(qn,Ri)|0,$t=$t+Math.imul(qn,Qn)|0,Me=Me+Math.imul($n,Ci)|0,We=We+Math.imul($n,ri)|0,We=We+Math.imul(Mn,Ci)|0,$t=$t+Math.imul(Mn,ri)|0,Me=Me+Math.imul(Pn,Ai)|0,We=We+Math.imul(Pn,ci)|0,We=We+Math.imul(wn,Ai)|0,$t=$t+Math.imul(wn,ci)|0,Me=Me+Math.imul(un,Mi)|0,We=We+Math.imul(un,di)|0,We=We+Math.imul(Pt,Mi)|0,$t=$t+Math.imul(Pt,di)|0,Me=Me+Math.imul(gn,Ti)|0,We=We+Math.imul(gn,hi)|0,We=We+Math.imul(Vt,Ti)|0,$t=$t+Math.imul(Vt,hi)|0;var Di=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(Di>>>26)|0,Di&=67108863,Me=Math.imul(bi,Wn),We=Math.imul(bi,jn),We=We+Math.imul(Hn,Wn)|0,$t=Math.imul(Hn,jn),Me=Me+Math.imul(Gn,Ri)|0,We=We+Math.imul(Gn,Qn)|0,We=We+Math.imul(Kn,Ri)|0,$t=$t+Math.imul(Kn,Qn)|0,Me=Me+Math.imul(Zn,Ci)|0,We=We+Math.imul(Zn,ri)|0,We=We+Math.imul(qn,Ci)|0,$t=$t+Math.imul(qn,ri)|0,Me=Me+Math.imul($n,Ai)|0,We=We+Math.imul($n,ci)|0,We=We+Math.imul(Mn,Ai)|0,$t=$t+Math.imul(Mn,ci)|0,Me=Me+Math.imul(Pn,Mi)|0,We=We+Math.imul(Pn,di)|0,We=We+Math.imul(wn,Mi)|0,$t=$t+Math.imul(wn,di)|0,Me=Me+Math.imul(un,Ti)|0,We=We+Math.imul(un,hi)|0,We=We+Math.imul(Pt,Ti)|0,$t=$t+Math.imul(Pt,hi)|0,Me=Me+Math.imul(gn,Pi)|0,We=We+Math.imul(gn,pi)|0,We=We+Math.imul(Vt,Pi)|0,$t=$t+Math.imul(Vt,pi)|0;var Ui=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(Ui>>>26)|0,Ui&=67108863,Me=Math.imul(Ln,Wn),We=Math.imul(Ln,jn),We=We+Math.imul(On,Wn)|0,$t=Math.imul(On,jn),Me=Me+Math.imul(bi,Ri)|0,We=We+Math.imul(bi,Qn)|0,We=We+Math.imul(Hn,Ri)|0,$t=$t+Math.imul(Hn,Qn)|0,Me=Me+Math.imul(Gn,Ci)|0,We=We+Math.imul(Gn,ri)|0,We=We+Math.imul(Kn,Ci)|0,$t=$t+Math.imul(Kn,ri)|0,Me=Me+Math.imul(Zn,Ai)|0,We=We+Math.imul(Zn,ci)|0,We=We+Math.imul(qn,Ai)|0,$t=$t+Math.imul(qn,ci)|0,Me=Me+Math.imul($n,Mi)|0,We=We+Math.imul($n,di)|0,We=We+Math.imul(Mn,Mi)|0,$t=$t+Math.imul(Mn,di)|0,Me=Me+Math.imul(Pn,Ti)|0,We=We+Math.imul(Pn,hi)|0,We=We+Math.imul(wn,Ti)|0,$t=$t+Math.imul(wn,hi)|0,Me=Me+Math.imul(un,Pi)|0,We=We+Math.imul(un,pi)|0,We=We+Math.imul(Pt,Pi)|0,$t=$t+Math.imul(Pt,pi)|0,Me=Me+Math.imul(gn,Bi)|0,We=We+Math.imul(gn,mi)|0,We=We+Math.imul(Vt,Bi)|0,$t=$t+Math.imul(Vt,mi)|0;var qi=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(qi>>>26)|0,qi&=67108863,Me=Math.imul(ti,Wn),We=Math.imul(ti,jn),We=We+Math.imul(Fn,Wn)|0,$t=Math.imul(Fn,jn),Me=Me+Math.imul(Ln,Ri)|0,We=We+Math.imul(Ln,Qn)|0,We=We+Math.imul(On,Ri)|0,$t=$t+Math.imul(On,Qn)|0,Me=Me+Math.imul(bi,Ci)|0,We=We+Math.imul(bi,ri)|0,We=We+Math.imul(Hn,Ci)|0,$t=$t+Math.imul(Hn,ri)|0,Me=Me+Math.imul(Gn,Ai)|0,We=We+Math.imul(Gn,ci)|0,We=We+Math.imul(Kn,Ai)|0,$t=$t+Math.imul(Kn,ci)|0,Me=Me+Math.imul(Zn,Mi)|0,We=We+Math.imul(Zn,di)|0,We=We+Math.imul(qn,Mi)|0,$t=$t+Math.imul(qn,di)|0,Me=Me+Math.imul($n,Ti)|0,We=We+Math.imul($n,hi)|0,We=We+Math.imul(Mn,Ti)|0,$t=$t+Math.imul(Mn,hi)|0,Me=Me+Math.imul(Pn,Pi)|0,We=We+Math.imul(Pn,pi)|0,We=We+Math.imul(wn,Pi)|0,$t=$t+Math.imul(wn,pi)|0,Me=Me+Math.imul(un,Bi)|0,We=We+Math.imul(un,mi)|0,We=We+Math.imul(Pt,Bi)|0,$t=$t+Math.imul(Pt,mi)|0,Me=Me+Math.imul(gn,Ii)|0,We=We+Math.imul(gn,gi)|0,We=We+Math.imul(Vt,Ii)|0,$t=$t+Math.imul(Vt,gi)|0;var Vi=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(Vi>>>26)|0,Vi&=67108863,Me=Math.imul(En,Wn),We=Math.imul(En,jn),We=We+Math.imul(xn,Wn)|0,$t=Math.imul(xn,jn),Me=Me+Math.imul(ti,Ri)|0,We=We+Math.imul(ti,Qn)|0,We=We+Math.imul(Fn,Ri)|0,$t=$t+Math.imul(Fn,Qn)|0,Me=Me+Math.imul(Ln,Ci)|0,We=We+Math.imul(Ln,ri)|0,We=We+Math.imul(On,Ci)|0,$t=$t+Math.imul(On,ri)|0,Me=Me+Math.imul(bi,Ai)|0,We=We+Math.imul(bi,ci)|0,We=We+Math.imul(Hn,Ai)|0,$t=$t+Math.imul(Hn,ci)|0,Me=Me+Math.imul(Gn,Mi)|0,We=We+Math.imul(Gn,di)|0,We=We+Math.imul(Kn,Mi)|0,$t=$t+Math.imul(Kn,di)|0,Me=Me+Math.imul(Zn,Ti)|0,We=We+Math.imul(Zn,hi)|0,We=We+Math.imul(qn,Ti)|0,$t=$t+Math.imul(qn,hi)|0,Me=Me+Math.imul($n,Pi)|0,We=We+Math.imul($n,pi)|0,We=We+Math.imul(Mn,Pi)|0,$t=$t+Math.imul(Mn,pi)|0,Me=Me+Math.imul(Pn,Bi)|0,We=We+Math.imul(Pn,mi)|0,We=We+Math.imul(wn,Bi)|0,$t=$t+Math.imul(wn,mi)|0,Me=Me+Math.imul(un,Ii)|0,We=We+Math.imul(un,gi)|0,We=We+Math.imul(Pt,Ii)|0,$t=$t+Math.imul(Pt,gi)|0,Me=Me+Math.imul(gn,ki)|0,We=We+Math.imul(gn,$i)|0,We=We+Math.imul(Vt,ki)|0,$t=$t+Math.imul(Vt,$i)|0;var zi=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(zi>>>26)|0,zi&=67108863,Me=Math.imul(En,Ri),We=Math.imul(En,Qn),We=We+Math.imul(xn,Ri)|0,$t=Math.imul(xn,Qn),Me=Me+Math.imul(ti,Ci)|0,We=We+Math.imul(ti,ri)|0,We=We+Math.imul(Fn,Ci)|0,$t=$t+Math.imul(Fn,ri)|0,Me=Me+Math.imul(Ln,Ai)|0,We=We+Math.imul(Ln,ci)|0,We=We+Math.imul(On,Ai)|0,$t=$t+Math.imul(On,ci)|0,Me=Me+Math.imul(bi,Mi)|0,We=We+Math.imul(bi,di)|0,We=We+Math.imul(Hn,Mi)|0,$t=$t+Math.imul(Hn,di)|0,Me=Me+Math.imul(Gn,Ti)|0,We=We+Math.imul(Gn,hi)|0,We=We+Math.imul(Kn,Ti)|0,$t=$t+Math.imul(Kn,hi)|0,Me=Me+Math.imul(Zn,Pi)|0,We=We+Math.imul(Zn,pi)|0,We=We+Math.imul(qn,Pi)|0,$t=$t+Math.imul(qn,pi)|0,Me=Me+Math.imul($n,Bi)|0,We=We+Math.imul($n,mi)|0,We=We+Math.imul(Mn,Bi)|0,$t=$t+Math.imul(Mn,mi)|0,Me=Me+Math.imul(Pn,Ii)|0,We=We+Math.imul(Pn,gi)|0,We=We+Math.imul(wn,Ii)|0,$t=$t+Math.imul(wn,gi)|0,Me=Me+Math.imul(un,ki)|0,We=We+Math.imul(un,$i)|0,We=We+Math.imul(Pt,ki)|0,$t=$t+Math.imul(Pt,$i)|0;var Hi=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(Hi>>>26)|0,Hi&=67108863,Me=Math.imul(En,Ci),We=Math.imul(En,ri),We=We+Math.imul(xn,Ci)|0,$t=Math.imul(xn,ri),Me=Me+Math.imul(ti,Ai)|0,We=We+Math.imul(ti,ci)|0,We=We+Math.imul(Fn,Ai)|0,$t=$t+Math.imul(Fn,ci)|0,Me=Me+Math.imul(Ln,Mi)|0,We=We+Math.imul(Ln,di)|0,We=We+Math.imul(On,Mi)|0,$t=$t+Math.imul(On,di)|0,Me=Me+Math.imul(bi,Ti)|0,We=We+Math.imul(bi,hi)|0,We=We+Math.imul(Hn,Ti)|0,$t=$t+Math.imul(Hn,hi)|0,Me=Me+Math.imul(Gn,Pi)|0,We=We+Math.imul(Gn,pi)|0,We=We+Math.imul(Kn,Pi)|0,$t=$t+Math.imul(Kn,pi)|0,Me=Me+Math.imul(Zn,Bi)|0,We=We+Math.imul(Zn,mi)|0,We=We+Math.imul(qn,Bi)|0,$t=$t+Math.imul(qn,mi)|0,Me=Me+Math.imul($n,Ii)|0,We=We+Math.imul($n,gi)|0,We=We+Math.imul(Mn,Ii)|0,$t=$t+Math.imul(Mn,gi)|0,Me=Me+Math.imul(Pn,ki)|0,We=We+Math.imul(Pn,$i)|0,We=We+Math.imul(wn,ki)|0,$t=$t+Math.imul(wn,$i)|0;var Ki=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(Ki>>>26)|0,Ki&=67108863,Me=Math.imul(En,Ai),We=Math.imul(En,ci),We=We+Math.imul(xn,Ai)|0,$t=Math.imul(xn,ci),Me=Me+Math.imul(ti,Mi)|0,We=We+Math.imul(ti,di)|0,We=We+Math.imul(Fn,Mi)|0,$t=$t+Math.imul(Fn,di)|0,Me=Me+Math.imul(Ln,Ti)|0,We=We+Math.imul(Ln,hi)|0,We=We+Math.imul(On,Ti)|0,$t=$t+Math.imul(On,hi)|0,Me=Me+Math.imul(bi,Pi)|0,We=We+Math.imul(bi,pi)|0,We=We+Math.imul(Hn,Pi)|0,$t=$t+Math.imul(Hn,pi)|0,Me=Me+Math.imul(Gn,Bi)|0,We=We+Math.imul(Gn,mi)|0,We=We+Math.imul(Kn,Bi)|0,$t=$t+Math.imul(Kn,mi)|0,Me=Me+Math.imul(Zn,Ii)|0,We=We+Math.imul(Zn,gi)|0,We=We+Math.imul(qn,Ii)|0,$t=$t+Math.imul(qn,gi)|0,Me=Me+Math.imul($n,ki)|0,We=We+Math.imul($n,$i)|0,We=We+Math.imul(Mn,ki)|0,$t=$t+Math.imul(Mn,$i)|0;var Wi=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(Wi>>>26)|0,Wi&=67108863,Me=Math.imul(En,Mi),We=Math.imul(En,di),We=We+Math.imul(xn,Mi)|0,$t=Math.imul(xn,di),Me=Me+Math.imul(ti,Ti)|0,We=We+Math.imul(ti,hi)|0,We=We+Math.imul(Fn,Ti)|0,$t=$t+Math.imul(Fn,hi)|0,Me=Me+Math.imul(Ln,Pi)|0,We=We+Math.imul(Ln,pi)|0,We=We+Math.imul(On,Pi)|0,$t=$t+Math.imul(On,pi)|0,Me=Me+Math.imul(bi,Bi)|0,We=We+Math.imul(bi,mi)|0,We=We+Math.imul(Hn,Bi)|0,$t=$t+Math.imul(Hn,mi)|0,Me=Me+Math.imul(Gn,Ii)|0,We=We+Math.imul(Gn,gi)|0,We=We+Math.imul(Kn,Ii)|0,$t=$t+Math.imul(Kn,gi)|0,Me=Me+Math.imul(Zn,ki)|0,We=We+Math.imul(Zn,$i)|0,We=We+Math.imul(qn,ki)|0,$t=$t+Math.imul(qn,$i)|0;var Gi=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(Gi>>>26)|0,Gi&=67108863,Me=Math.imul(En,Ti),We=Math.imul(En,hi),We=We+Math.imul(xn,Ti)|0,$t=Math.imul(xn,hi),Me=Me+Math.imul(ti,Pi)|0,We=We+Math.imul(ti,pi)|0,We=We+Math.imul(Fn,Pi)|0,$t=$t+Math.imul(Fn,pi)|0,Me=Me+Math.imul(Ln,Bi)|0,We=We+Math.imul(Ln,mi)|0,We=We+Math.imul(On,Bi)|0,$t=$t+Math.imul(On,mi)|0,Me=Me+Math.imul(bi,Ii)|0,We=We+Math.imul(bi,gi)|0,We=We+Math.imul(Hn,Ii)|0,$t=$t+Math.imul(Hn,gi)|0,Me=Me+Math.imul(Gn,ki)|0,We=We+Math.imul(Gn,$i)|0,We=We+Math.imul(Kn,ki)|0,$t=$t+Math.imul(Kn,$i)|0;var Zi=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(Zi>>>26)|0,Zi&=67108863,Me=Math.imul(En,Pi),We=Math.imul(En,pi),We=We+Math.imul(xn,Pi)|0,$t=Math.imul(xn,pi),Me=Me+Math.imul(ti,Bi)|0,We=We+Math.imul(ti,mi)|0,We=We+Math.imul(Fn,Bi)|0,$t=$t+Math.imul(Fn,mi)|0,Me=Me+Math.imul(Ln,Ii)|0,We=We+Math.imul(Ln,gi)|0,We=We+Math.imul(On,Ii)|0,$t=$t+Math.imul(On,gi)|0,Me=Me+Math.imul(bi,ki)|0,We=We+Math.imul(bi,$i)|0,We=We+Math.imul(Hn,ki)|0,$t=$t+Math.imul(Hn,$i)|0;var Xi=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(Xi>>>26)|0,Xi&=67108863,Me=Math.imul(En,Bi),We=Math.imul(En,mi),We=We+Math.imul(xn,Bi)|0,$t=Math.imul(xn,mi),Me=Me+Math.imul(ti,Ii)|0,We=We+Math.imul(ti,gi)|0,We=We+Math.imul(Fn,Ii)|0,$t=$t+Math.imul(Fn,gi)|0,Me=Me+Math.imul(Ln,ki)|0,We=We+Math.imul(Ln,$i)|0,We=We+Math.imul(On,ki)|0,$t=$t+Math.imul(On,$i)|0;var Ji=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(Ji>>>26)|0,Ji&=67108863,Me=Math.imul(En,Ii),We=Math.imul(En,gi),We=We+Math.imul(xn,Ii)|0,$t=Math.imul(xn,gi),Me=Me+Math.imul(ti,ki)|0,We=We+Math.imul(ti,$i)|0,We=We+Math.imul(Fn,ki)|0,$t=$t+Math.imul(Fn,$i)|0;var no=(ce+Me|0)+((We&8191)<<13)|0;ce=($t+(We>>>13)|0)+(no>>>26)|0,no&=67108863,Me=Math.imul(En,ki),We=Math.imul(En,$i),We=We+Math.imul(xn,ki)|0,$t=Math.imul(xn,$i);var io=(ce+Me|0)+((We&8191)<<13)|0;return ce=($t+(We>>>13)|0)+(io>>>26)|0,io&=67108863,$e[0]=Ni,$e[1]=Oi,$e[2]=Li,$e[3]=Fi,$e[4]=ji,$e[5]=Di,$e[6]=Ui,$e[7]=qi,$e[8]=Vi,$e[9]=zi,$e[10]=Hi,$e[11]=Ki,$e[12]=Wi,$e[13]=Gi,$e[14]=Zi,$e[15]=Xi,$e[16]=Ji,$e[17]=no,$e[18]=io,ce!==0&&($e[19]=ce,_e.length++),_e};Math.imul||(Ye=Ze);function Ft(be,xe,_e){_e.negative=xe.negative^be.negative,_e.length=be.length+xe.length;for(var De=0,Fe=0,$e=0;$e<_e.length-1;$e++){var ce=Fe;Fe=0;for(var Me=De&67108863,We=Math.min($e,xe.length-1),$t=Math.max(0,$e-be.length+1);$t<=We;$t++){var dn=$e-$t,gn=be.words[dn]|0,Vt=xe.words[$t]|0,Cn=gn*Vt,un=Cn&67108863;ce=ce+(Cn/67108864|0)|0,un=un+Me|0,Me=un&67108863,ce=ce+(un>>>26)|0,Fe+=ce>>>26,ce&=67108863}_e.words[$e]=Me,De=ce,ce=Fe}return De!==0?_e.words[$e]=De:_e.length--,_e._strip()}function Mt(be,xe,_e){return Ft(be,xe,_e)}ae.prototype.mulTo=function(be,xe){var _e,De=this.length+be.length;return this.length===10&&be.length===10?_e=Ye(this,be,xe):De<63?_e=Ze(this,be,xe):De<1024?_e=Ft(this,be,xe):_e=Mt(this,be,xe),_e},ae.prototype.mul=function(be){var xe=new ae(null);return xe.words=new Array(this.length+be.length),this.mulTo(be,xe)},ae.prototype.mulf=function(be){var xe=new ae(null);return xe.words=new Array(this.length+be.length),Mt(this,be,xe)},ae.prototype.imul=function(be){return this.clone().mulTo(be,this)},ae.prototype.imuln=function(be){var xe=be<0;xe&&(be=-be),ie(typeof be=="number"),ie(be<67108864);for(var _e=0,De=0;De<this.length;De++){var Fe=(this.words[De]|0)*be,$e=(Fe&67108863)+(_e&67108863);_e>>=26,_e+=Fe/67108864|0,_e+=$e>>>26,this.words[De]=$e&67108863}return _e!==0&&(this.words[De]=_e,this.length++),this.length=be===0?1:this.length,xe?this.ineg():this},ae.prototype.muln=function(be){return this.clone().imuln(be)},ae.prototype.sqr=function(){return this.mul(this)},ae.prototype.isqr=function(){return this.imul(this.clone())},ae.prototype.pow=function(be){var xe=Ge(be);if(xe.length===0)return new ae(1);for(var _e=this,De=0;De<xe.length&&xe[De]===0;De++,_e=_e.sqr());if(++De<xe.length)for(var Fe=_e.sqr();De<xe.length;De++,Fe=Fe.sqr())xe[De]!==0&&(_e=_e.mul(Fe));return _e},ae.prototype.iushln=function(be){ie(typeof be=="number"&&be>=0);var xe=be%26,_e=(be-xe)/26,De=67108863>>>26-xe<<26-xe,Fe;if(xe!==0){var $e=0;for(Fe=0;Fe<this.length;Fe++){var ce=this.words[Fe]&De,Me=(this.words[Fe]|0)-ce<<xe;this.words[Fe]=Me|$e,$e=ce>>>26-xe}$e&&(this.words[Fe]=$e,this.length++)}if(_e!==0){for(Fe=this.length-1;Fe>=0;Fe--)this.words[Fe+_e]=this.words[Fe];for(Fe=0;Fe<_e;Fe++)this.words[Fe]=0;this.length+=_e}return this._strip()},ae.prototype.ishln=function(be){return ie(this.negative===0),this.iushln(be)},ae.prototype.iushrn=function(be,xe,_e){ie(typeof be=="number"&&be>=0);var De;xe?De=(xe-xe%26)/26:De=0;var Fe=be%26,$e=Math.min((be-Fe)/26,this.length),ce=67108863^67108863>>>Fe<<Fe,Me=_e;if(De-=$e,De=Math.max(0,De),Me){for(var We=0;We<$e;We++)Me.words[We]=this.words[We];Me.length=$e}if($e!==0)if(this.length>$e)for(this.length-=$e,We=0;We<this.length;We++)this.words[We]=this.words[We+$e];else this.words[0]=0,this.length=1;var $t=0;for(We=this.length-1;We>=0&&($t!==0||We>=De);We--){var dn=this.words[We]|0;this.words[We]=$t<<26-Fe|dn>>>Fe,$t=dn&ce}return Me&&$t!==0&&(Me.words[Me.length++]=$t),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},ae.prototype.ishrn=function(be,xe,_e){return ie(this.negative===0),this.iushrn(be,xe,_e)},ae.prototype.shln=function(be){return this.clone().ishln(be)},ae.prototype.ushln=function(be){return this.clone().iushln(be)},ae.prototype.shrn=function(be){return this.clone().ishrn(be)},ae.prototype.ushrn=function(be){return this.clone().iushrn(be)},ae.prototype.testn=function(be){ie(typeof be=="number"&&be>=0);var xe=be%26,_e=(be-xe)/26,De=1<<xe;if(this.length<=_e)return!1;var Fe=this.words[_e];return!!(Fe&De)},ae.prototype.imaskn=function(be){ie(typeof be=="number"&&be>=0);var xe=be%26,_e=(be-xe)/26;if(ie(this.negative===0,"imaskn works only with positive numbers"),this.length<=_e)return this;if(xe!==0&&_e++,this.length=Math.min(_e,this.length),xe!==0){var De=67108863^67108863>>>xe<<xe;this.words[this.length-1]&=De}return this._strip()},ae.prototype.maskn=function(be){return this.clone().imaskn(be)},ae.prototype.iaddn=function(be){return ie(typeof be=="number"),ie(be<67108864),be<0?this.isubn(-be):this.negative!==0?this.length===1&&(this.words[0]|0)<=be?(this.words[0]=be-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(be),this.negative=1,this):this._iaddn(be)},ae.prototype._iaddn=function(be){this.words[0]+=be;for(var xe=0;xe<this.length&&this.words[xe]>=67108864;xe++)this.words[xe]-=67108864,xe===this.length-1?this.words[xe+1]=1:this.words[xe+1]++;return this.length=Math.max(this.length,xe+1),this},ae.prototype.isubn=function(be){if(ie(typeof be=="number"),ie(be<67108864),be<0)return this.iaddn(-be);if(this.negative!==0)return this.negative=0,this.iaddn(be),this.negative=1,this;if(this.words[0]-=be,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var xe=0;xe<this.length&&this.words[xe]<0;xe++)this.words[xe]+=67108864,this.words[xe+1]-=1;return this._strip()},ae.prototype.addn=function(be){return this.clone().iaddn(be)},ae.prototype.subn=function(be){return this.clone().isubn(be)},ae.prototype.iabs=function(){return this.negative=0,this},ae.prototype.abs=function(){return this.clone().iabs()},ae.prototype._ishlnsubmul=function(be,xe,_e){var De=be.length+_e,Fe;this._expand(De);var $e,ce=0;for(Fe=0;Fe<be.length;Fe++){$e=(this.words[Fe+_e]|0)+ce;var Me=(be.words[Fe]|0)*xe;$e-=Me&67108863,ce=($e>>26)-(Me/67108864|0),this.words[Fe+_e]=$e&67108863}for(;Fe<this.length-_e;Fe++)$e=(this.words[Fe+_e]|0)+ce,ce=$e>>26,this.words[Fe+_e]=$e&67108863;if(ce===0)return this._strip();for(ie(ce===-1),ce=0,Fe=0;Fe<this.length;Fe++)$e=-(this.words[Fe]|0)+ce,ce=$e>>26,this.words[Fe]=$e&67108863;return this.negative=1,this._strip()},ae.prototype._wordDiv=function(be,xe){var _e=this.length-be.length,De=this.clone(),Fe=be,$e=Fe.words[Fe.length-1]|0,ce=this._countBits($e);_e=26-ce,_e!==0&&(Fe=Fe.ushln(_e),De.iushln(_e),$e=Fe.words[Fe.length-1]|0);var Me=De.length-Fe.length,We;if(xe!=="mod"){We=new ae(null),We.length=Me+1,We.words=new Array(We.length);for(var $t=0;$t<We.length;$t++)We.words[$t]=0}var dn=De.clone()._ishlnsubmul(Fe,1,Me);dn.negative===0&&(De=dn,We&&(We.words[Me]=1));for(var gn=Me-1;gn>=0;gn--){var Vt=(De.words[Fe.length+gn]|0)*67108864+(De.words[Fe.length+gn-1]|0);for(Vt=Math.min(Vt/$e|0,67108863),De._ishlnsubmul(Fe,Vt,gn);De.negative!==0;)Vt--,De.negative=0,De._ishlnsubmul(Fe,1,gn),De.isZero()||(De.negative^=1);We&&(We.words[gn]=Vt)}return We&&We._strip(),De._strip(),xe!=="div"&&_e!==0&&De.iushrn(_e),{div:We||null,mod:De}},ae.prototype.divmod=function(be,xe,_e){if(ie(!be.isZero()),this.isZero())return{div:new ae(0),mod:new ae(0)};var De,Fe,$e;return this.negative!==0&&be.negative===0?($e=this.neg().divmod(be,xe),xe!=="mod"&&(De=$e.div.neg()),xe!=="div"&&(Fe=$e.mod.neg(),_e&&Fe.negative!==0&&Fe.iadd(be)),{div:De,mod:Fe}):this.negative===0&&be.negative!==0?($e=this.divmod(be.neg(),xe),xe!=="mod"&&(De=$e.div.neg()),{div:De,mod:$e.mod}):this.negative&be.negative?($e=this.neg().divmod(be.neg(),xe),xe!=="div"&&(Fe=$e.mod.neg(),_e&&Fe.negative!==0&&Fe.isub(be)),{div:$e.div,mod:Fe}):be.length>this.length||this.cmp(be)<0?{div:new ae(0),mod:this}:be.length===1?xe==="div"?{div:this.divn(be.words[0]),mod:null}:xe==="mod"?{div:null,mod:new ae(this.modrn(be.words[0]))}:{div:this.divn(be.words[0]),mod:new ae(this.modrn(be.words[0]))}:this._wordDiv(be,xe)},ae.prototype.div=function(be){return this.divmod(be,"div",!1).div},ae.prototype.mod=function(be){return this.divmod(be,"mod",!1).mod},ae.prototype.umod=function(be){return this.divmod(be,"mod",!0).mod},ae.prototype.divRound=function(be){var xe=this.divmod(be);if(xe.mod.isZero())return xe.div;var _e=xe.div.negative!==0?xe.mod.isub(be):xe.mod,De=be.ushrn(1),Fe=be.andln(1),$e=_e.cmp(De);return $e<0||Fe===1&&$e===0?xe.div:xe.div.negative!==0?xe.div.isubn(1):xe.div.iaddn(1)},ae.prototype.modrn=function(be){var xe=be<0;xe&&(be=-be),ie(be<=67108863);for(var _e=(1<<26)%be,De=0,Fe=this.length-1;Fe>=0;Fe--)De=(_e*De+(this.words[Fe]|0))%be;return xe?-De:De},ae.prototype.modn=function(be){return this.modrn(be)},ae.prototype.idivn=function(be){var xe=be<0;xe&&(be=-be),ie(be<=67108863);for(var _e=0,De=this.length-1;De>=0;De--){var Fe=(this.words[De]|0)+_e*67108864;this.words[De]=Fe/be|0,_e=Fe%be}return this._strip(),xe?this.ineg():this},ae.prototype.divn=function(be){return this.clone().idivn(be)},ae.prototype.egcd=function(be){ie(be.negative===0),ie(!be.isZero());var xe=this,_e=be.clone();xe.negative!==0?xe=xe.umod(be):xe=xe.clone();for(var De=new ae(1),Fe=new ae(0),$e=new ae(0),ce=new ae(1),Me=0;xe.isEven()&&_e.isEven();)xe.iushrn(1),_e.iushrn(1),++Me;for(var We=_e.clone(),$t=xe.clone();!xe.isZero();){for(var dn=0,gn=1;!(xe.words[0]&gn)&&dn<26;++dn,gn<<=1);if(dn>0)for(xe.iushrn(dn);dn-- >0;)(De.isOdd()||Fe.isOdd())&&(De.iadd(We),Fe.isub($t)),De.iushrn(1),Fe.iushrn(1);for(var Vt=0,Cn=1;!(_e.words[0]&Cn)&&Vt<26;++Vt,Cn<<=1);if(Vt>0)for(_e.iushrn(Vt);Vt-- >0;)($e.isOdd()||ce.isOdd())&&($e.iadd(We),ce.isub($t)),$e.iushrn(1),ce.iushrn(1);xe.cmp(_e)>=0?(xe.isub(_e),De.isub($e),Fe.isub(ce)):(_e.isub(xe),$e.isub(De),ce.isub(Fe))}return{a:$e,b:ce,gcd:_e.iushln(Me)}},ae.prototype._invmp=function(be){ie(be.negative===0),ie(!be.isZero());var xe=this,_e=be.clone();xe.negative!==0?xe=xe.umod(be):xe=xe.clone();for(var De=new ae(1),Fe=new ae(0),$e=_e.clone();xe.cmpn(1)>0&&_e.cmpn(1)>0;){for(var ce=0,Me=1;!(xe.words[0]&Me)&&ce<26;++ce,Me<<=1);if(ce>0)for(xe.iushrn(ce);ce-- >0;)De.isOdd()&&De.iadd($e),De.iushrn(1);for(var We=0,$t=1;!(_e.words[0]&$t)&&We<26;++We,$t<<=1);if(We>0)for(_e.iushrn(We);We-- >0;)Fe.isOdd()&&Fe.iadd($e),Fe.iushrn(1);xe.cmp(_e)>=0?(xe.isub(_e),De.isub(Fe)):(_e.isub(xe),Fe.isub(De))}var dn;return xe.cmpn(1)===0?dn=De:dn=Fe,dn.cmpn(0)<0&&dn.iadd(be),dn},ae.prototype.gcd=function(be){if(this.isZero())return be.abs();if(be.isZero())return this.abs();var xe=this.clone(),_e=be.clone();xe.negative=0,_e.negative=0;for(var De=0;xe.isEven()&&_e.isEven();De++)xe.iushrn(1),_e.iushrn(1);do{for(;xe.isEven();)xe.iushrn(1);for(;_e.isEven();)_e.iushrn(1);var Fe=xe.cmp(_e);if(Fe<0){var $e=xe;xe=_e,_e=$e}else if(Fe===0||_e.cmpn(1)===0)break;xe.isub(_e)}while(!0);return _e.iushln(De)},ae.prototype.invm=function(be){return this.egcd(be).a.umod(be)},ae.prototype.isEven=function(){return(this.words[0]&1)===0},ae.prototype.isOdd=function(){return(this.words[0]&1)===1},ae.prototype.andln=function(be){return this.words[0]&be},ae.prototype.bincn=function(be){ie(typeof be=="number");var xe=be%26,_e=(be-xe)/26,De=1<<xe;if(this.length<=_e)return this._expand(_e+1),this.words[_e]|=De,this;for(var Fe=De,$e=_e;Fe!==0&&$e<this.length;$e++){var ce=this.words[$e]|0;ce+=Fe,Fe=ce>>>26,ce&=67108863,this.words[$e]=ce}return Fe!==0&&(this.words[$e]=Fe,this.length++),this},ae.prototype.isZero=function(){return this.length===1&&this.words[0]===0},ae.prototype.cmpn=function(be){var xe=be<0;if(this.negative!==0&&!xe)return-1;if(this.negative===0&&xe)return 1;this._strip();var _e;if(this.length>1)_e=1;else{xe&&(be=-be),ie(be<=67108863,"Number is too big");var De=this.words[0]|0;_e=De===be?0:De<be?-1:1}return this.negative!==0?-_e|0:_e},ae.prototype.cmp=function(be){if(this.negative!==0&&be.negative===0)return-1;if(this.negative===0&&be.negative!==0)return 1;var xe=this.ucmp(be);return this.negative!==0?-xe|0:xe},ae.prototype.ucmp=function(be){if(this.length>be.length)return 1;if(this.length<be.length)return-1;for(var xe=0,_e=this.length-1;_e>=0;_e--){var De=this.words[_e]|0,Fe=be.words[_e]|0;if(De!==Fe){De<Fe?xe=-1:De>Fe&&(xe=1);break}}return xe},ae.prototype.gtn=function(be){return this.cmpn(be)===1},ae.prototype.gt=function(be){return this.cmp(be)===1},ae.prototype.gten=function(be){return this.cmpn(be)>=0},ae.prototype.gte=function(be){return this.cmp(be)>=0},ae.prototype.ltn=function(be){return this.cmpn(be)===-1},ae.prototype.lt=function(be){return this.cmp(be)===-1},ae.prototype.lten=function(be){return this.cmpn(be)<=0},ae.prototype.lte=function(be){return this.cmp(be)<=0},ae.prototype.eqn=function(be){return this.cmpn(be)===0},ae.prototype.eq=function(be){return this.cmp(be)===0},ae.red=function(be){return new le(be)},ae.prototype.toRed=function(be){return ie(!this.red,"Already a number in reduction context"),ie(this.negative===0,"red works only with positives"),be.convertTo(this)._forceRed(be)},ae.prototype.fromRed=function(){return ie(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},ae.prototype._forceRed=function(be){return this.red=be,this},ae.prototype.forceRed=function(be){return ie(!this.red,"Already a number in reduction context"),this._forceRed(be)},ae.prototype.redAdd=function(be){return ie(this.red,"redAdd works only with red numbers"),this.red.add(this,be)},ae.prototype.redIAdd=function(be){return ie(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,be)},ae.prototype.redSub=function(be){return ie(this.red,"redSub works only with red numbers"),this.red.sub(this,be)},ae.prototype.redISub=function(be){return ie(this.red,"redISub works only with red numbers"),this.red.isub(this,be)},ae.prototype.redShl=function(be){return ie(this.red,"redShl works only with red numbers"),this.red.shl(this,be)},ae.prototype.redMul=function(be){return ie(this.red,"redMul works only with red numbers"),this.red._verify2(this,be),this.red.mul(this,be)},ae.prototype.redIMul=function(be){return ie(this.red,"redMul works only with red numbers"),this.red._verify2(this,be),this.red.imul(this,be)},ae.prototype.redSqr=function(){return ie(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},ae.prototype.redISqr=function(){return ie(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},ae.prototype.redSqrt=function(){return ie(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},ae.prototype.redInvm=function(){return ie(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},ae.prototype.redNeg=function(){return ie(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},ae.prototype.redPow=function(be){return ie(this.red&&!be.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,be)};var Zt={k256:null,p224:null,p192:null,p25519:null};function cn(be,xe){this.name=be,this.p=new ae(xe,16),this.n=this.p.bitLength(),this.k=new ae(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}cn.prototype._tmp=function(){var be=new ae(null);return be.words=new Array(Math.ceil(this.n/13)),be},cn.prototype.ireduce=function(be){var xe=be,_e;do this.split(xe,this.tmp),xe=this.imulK(xe),xe=xe.iadd(this.tmp),_e=xe.bitLength();while(_e>this.n);var De=_e<this.n?-1:xe.ucmp(this.p);return De===0?(xe.words[0]=0,xe.length=1):De>0?xe.isub(this.p):xe.strip!==void 0?xe.strip():xe._strip(),xe},cn.prototype.split=function(be,xe){be.iushrn(this.n,0,xe)},cn.prototype.imulK=function(be){return be.imul(this.k)};function hn(){cn.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}se(hn,cn),hn.prototype.split=function(be,xe){for(var _e=4194303,De=Math.min(be.length,9),Fe=0;Fe<De;Fe++)xe.words[Fe]=be.words[Fe];if(xe.length=De,be.length<=9){be.words[0]=0,be.length=1;return}var $e=be.words[9];for(xe.words[xe.length++]=$e&_e,Fe=10;Fe<be.length;Fe++){var ce=be.words[Fe]|0;be.words[Fe-10]=(ce&_e)<<4|$e>>>22,$e=ce}$e>>>=22,be.words[Fe-10]=$e,$e===0&&be.length>10?be.length-=10:be.length-=9},hn.prototype.imulK=function(be){be.words[be.length]=0,be.words[be.length+1]=0,be.length+=2;for(var xe=0,_e=0;_e<be.length;_e++){var De=be.words[_e]|0;xe+=De*977,be.words[_e]=xe&67108863,xe=De*64+(xe/67108864|0)}return be.words[be.length-1]===0&&(be.length--,be.words[be.length-1]===0&&be.length--),be};function yn(){cn.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}se(yn,cn);function Ht(){cn.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}se(Ht,cn);function Sn(){cn.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}se(Sn,cn),Sn.prototype.imulK=function(be){for(var xe=0,_e=0;_e<be.length;_e++){var De=(be.words[_e]|0)*19+xe,Fe=De&67108863;De>>>=26,be.words[_e]=Fe,xe=De}return xe!==0&&(be.words[be.length++]=xe),be},ae._prime=function(be){if(Zt[be])return Zt[be];var xe;if(be==="k256")xe=new hn;else if(be==="p224")xe=new yn;else if(be==="p192")xe=new Ht;else if(be==="p25519")xe=new Sn;else throw new Error("Unknown prime "+be);return Zt[be]=xe,xe};function le(be){if(typeof be=="string"){var xe=ae._prime(be);this.m=xe.p,this.prime=xe}else ie(be.gtn(1),"modulus must be greater than 1"),this.m=be,this.prime=null}le.prototype._verify1=function(be){ie(be.negative===0,"red works only with positives"),ie(be.red,"red works only with red numbers")},le.prototype._verify2=function(be,xe){ie((be.negative|xe.negative)===0,"red works only with positives"),ie(be.red&&be.red===xe.red,"red works only with red numbers")},le.prototype.imod=function(be){return this.prime?this.prime.ireduce(be)._forceRed(this):(we(be,be.umod(this.m)._forceRed(this)),be)},le.prototype.neg=function(be){return be.isZero()?be.clone():this.m.sub(be)._forceRed(this)},le.prototype.add=function(be,xe){this._verify2(be,xe);var _e=be.add(xe);return _e.cmp(this.m)>=0&&_e.isub(this.m),_e._forceRed(this)},le.prototype.iadd=function(be,xe){this._verify2(be,xe);var _e=be.iadd(xe);return _e.cmp(this.m)>=0&&_e.isub(this.m),_e},le.prototype.sub=function(be,xe){this._verify2(be,xe);var _e=be.sub(xe);return _e.cmpn(0)<0&&_e.iadd(this.m),_e._forceRed(this)},le.prototype.isub=function(be,xe){this._verify2(be,xe);var _e=be.isub(xe);return _e.cmpn(0)<0&&_e.iadd(this.m),_e},le.prototype.shl=function(be,xe){return this._verify1(be),this.imod(be.ushln(xe))},le.prototype.imul=function(be,xe){return this._verify2(be,xe),this.imod(be.imul(xe))},le.prototype.mul=function(be,xe){return this._verify2(be,xe),this.imod(be.mul(xe))},le.prototype.isqr=function(be){return this.imul(be,be.clone())},le.prototype.sqr=function(be){return this.mul(be,be)},le.prototype.sqrt=function(be){if(be.isZero())return be.clone();var xe=this.m.andln(3);if(ie(xe%2===1),xe===3){var _e=this.m.add(new ae(1)).iushrn(2);return this.pow(be,_e)}for(var De=this.m.subn(1),Fe=0;!De.isZero()&&De.andln(1)===0;)Fe++,De.iushrn(1);ie(!De.isZero());var $e=new ae(1).toRed(this),ce=$e.redNeg(),Me=this.m.subn(1).iushrn(1),We=this.m.bitLength();for(We=new ae(2*We*We).toRed(this);this.pow(We,Me).cmp(ce)!==0;)We.redIAdd(ce);for(var $t=this.pow(We,De),dn=this.pow(be,De.addn(1).iushrn(1)),gn=this.pow(be,De),Vt=Fe;gn.cmp($e)!==0;){for(var Cn=gn,un=0;Cn.cmp($e)!==0;un++)Cn=Cn.redSqr();ie(un<Vt);var Pt=this.pow($t,new ae(1).iushln(Vt-un-1));dn=dn.redMul(Pt),$t=Pt.redSqr(),gn=gn.redMul($t),Vt=un}return dn},le.prototype.invm=function(be){var xe=be._invmp(this.m);return xe.negative!==0?(xe.negative=0,this.imod(xe).redNeg()):this.imod(xe)},le.prototype.pow=function(be,xe){if(xe.isZero())return new ae(1).toRed(this);if(xe.cmpn(1)===0)return be.clone();var _e=4,De=new Array(1<<_e);De[0]=new ae(1).toRed(this),De[1]=be;for(var Fe=2;Fe<De.length;Fe++)De[Fe]=this.mul(De[Fe-1],be);var $e=De[0],ce=0,Me=0,We=xe.bitLength()%26;for(We===0&&(We=26),Fe=xe.length-1;Fe>=0;Fe--){for(var $t=xe.words[Fe],dn=We-1;dn>=0;dn--){var gn=$t>>dn&1;if($e!==De[0]&&($e=this.sqr($e)),gn===0&&ce===0){Me=0;continue}ce<<=1,ce|=gn,Me++,!(Me!==_e&&(Fe!==0||dn!==0))&&($e=this.mul($e,De[ce]),Me=0,ce=0)}We=26}return $e},le.prototype.convertTo=function(be){var xe=be.umod(this.m);return xe===be?xe.clone():xe},le.prototype.convertFrom=function(be){var xe=be.clone();return xe.red=null,xe},ae.mont=function(be){return new pe(be)};function pe(be){le.call(this,be),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new ae(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}se(pe,le),pe.prototype.convertTo=function(be){return this.imod(be.ushln(this.shift))},pe.prototype.convertFrom=function(be){var xe=this.imod(be.mul(this.rinv));return xe.red=null,xe},pe.prototype.imul=function(be,xe){if(be.isZero()||xe.isZero())return be.words[0]=0,be.length=1,be;var _e=be.imul(xe),De=_e.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),Fe=_e.isub(De).iushrn(this.shift),$e=Fe;return Fe.cmp(this.m)>=0?$e=Fe.isub(this.m):Fe.cmpn(0)<0&&($e=Fe.iadd(this.m)),$e._forceRed(this)},pe.prototype.mul=function(be,xe){if(be.isZero()||xe.isZero())return new ae(0)._forceRed(this);var _e=be.mul(xe),De=_e.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),Fe=_e.isub(De).iushrn(this.shift),$e=Fe;return Fe.cmp(this.m)>=0?$e=Fe.isub(this.m):Fe.cmpn(0)<0&&($e=Fe.iadd(this.m)),$e._forceRed(this)},pe.prototype.invm=function(be){var xe=this.imod(be._invmp(this.m).mul(this.r2));return xe._forceRed(this)}})(n,commonjsGlobal)})(bn$8);var bnExports$3=bn$8.exports;const BN$8=getDefaultExportFromCjs$2(bnExports$3),version$u="logger/5.8.0";let _permanentCensorErrors=!1,_censorErrors=!1;const LogLevels={debug:1,default:2,info:2,warning:3,error:4,off:5};let _logLevel=LogLevels.default,_globalLogger=null;function _checkNormalize(){try{const n=[];if(["NFD","NFC","NFKD","NFKC"].forEach(t=>{try{if("test".normalize(t)!=="test")throw new Error("bad normalize")}catch{n.push(t)}}),n.length)throw new Error("missing "+n.join(", "));if("é".normalize("NFD")!=="é")throw new Error("broken implementation")}catch(n){return n.message}return null}const _normalizeError=_checkNormalize();var LogLevel;(function(n){n.DEBUG="DEBUG",n.INFO="INFO",n.WARNING="WARNING",n.ERROR="ERROR",n.OFF="OFF"})(LogLevel||(LogLevel={}));var ErrorCode;(function(n){n.UNKNOWN_ERROR="UNKNOWN_ERROR",n.NOT_IMPLEMENTED="NOT_IMPLEMENTED",n.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",n.NETWORK_ERROR="NETWORK_ERROR",n.SERVER_ERROR="SERVER_ERROR",n.TIMEOUT="TIMEOUT",n.BUFFER_OVERRUN="BUFFER_OVERRUN",n.NUMERIC_FAULT="NUMERIC_FAULT",n.MISSING_NEW="MISSING_NEW",n.INVALID_ARGUMENT="INVALID_ARGUMENT",n.MISSING_ARGUMENT="MISSING_ARGUMENT",n.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",n.CALL_EXCEPTION="CALL_EXCEPTION",n.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",n.NONCE_EXPIRED="NONCE_EXPIRED",n.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",n.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",n.TRANSACTION_REPLACED="TRANSACTION_REPLACED",n.ACTION_REJECTED="ACTION_REJECTED"})(ErrorCode||(ErrorCode={}));const HEX="0123456789abcdef";class Logger{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,c){const ie=t.toLowerCase();LogLevels[ie]==null&&this.throwArgumentError("invalid log level name","logLevel",t),!(_logLevel>LogLevels[ie])&&console.log.apply(console,c)}debug(...t){this._log(Logger.levels.DEBUG,t)}info(...t){this._log(Logger.levels.INFO,t)}warn(...t){this._log(Logger.levels.WARNING,t)}makeError(t,c,ie){if(_censorErrors)return this.makeError("censored error",c,{});c||(c=Logger.errors.UNKNOWN_ERROR),ie||(ie={});const se=[];Object.keys(ie).forEach(ve=>{const ge=ie[ve];try{if(ge instanceof Uint8Array){let we="";for(let Te=0;Te<ge.length;Te++)we+=HEX[ge[Te]>>4],we+=HEX[ge[Te]&15];se.push(ve+"=Uint8Array(0x"+we+")")}else se.push(ve+"="+JSON.stringify(ge))}catch{se.push(ve+"="+JSON.stringify(ie[ve].toString()))}}),se.push(`code=${c}`),se.push(`version=${this.version}`);const ae=t;let ue="";switch(c){case ErrorCode.NUMERIC_FAULT:{ue="NUMERIC_FAULT";const ve=t;switch(ve){case"overflow":case"underflow":case"division-by-zero":ue+="-"+ve;break;case"negative-power":case"negative-width":ue+="-unsupported";break;case"unbound-bitwise-result":ue+="-unbound-result";break}break}case ErrorCode.CALL_EXCEPTION:case ErrorCode.INSUFFICIENT_FUNDS:case ErrorCode.MISSING_NEW:case ErrorCode.NONCE_EXPIRED:case ErrorCode.REPLACEMENT_UNDERPRICED:case ErrorCode.TRANSACTION_REPLACED:case ErrorCode.UNPREDICTABLE_GAS_LIMIT:ue=c;break}ue&&(t+=" [ See: https://links.ethers.org/v5-errors-"+ue+" ]"),se.length&&(t+=" ("+se.join(", ")+")");const de=new Error(t);return de.reason=ae,de.code=c,Object.keys(ie).forEach(function(ve){de[ve]=ie[ve]}),de}throwError(t,c,ie){throw this.makeError(t,c,ie)}throwArgumentError(t,c,ie){return this.throwError(t,Logger.errors.INVALID_ARGUMENT,{argument:c,value:ie})}assert(t,c,ie,se){t||this.throwError(c,ie,se)}assertArgument(t,c,ie,se){t||this.throwArgumentError(c,ie,se)}checkNormalize(t){_normalizeError&&this.throwError("platform missing String.prototype.normalize",Logger.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:_normalizeError})}checkSafeUint53(t,c){typeof t=="number"&&(c==null&&(c="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(c,Logger.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(c,Logger.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,c,ie){ie?ie=": "+ie:ie="",t<c&&this.throwError("missing argument"+ie,Logger.errors.MISSING_ARGUMENT,{count:t,expectedCount:c}),t>c&&this.throwError("too many arguments"+ie,Logger.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:c})}checkNew(t,c){(t===Object||t==null)&&this.throwError("missing new",Logger.errors.MISSING_NEW,{name:c.name})}checkAbstract(t,c){t===c?this.throwError("cannot instantiate abstract class "+JSON.stringify(c.name)+" directly; use a sub-class",Logger.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):(t===Object||t==null)&&this.throwError("missing new",Logger.errors.MISSING_NEW,{name:c.name})}static globalLogger(){return _globalLogger||(_globalLogger=new Logger(version$u)),_globalLogger}static setCensorship(t,c){if(!t&&c&&this.globalLogger().throwError("cannot permanently disable censorship",Logger.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),_permanentCensorErrors){if(!t)return;this.globalLogger().throwError("error censorship permanent",Logger.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}_censorErrors=!!t,_permanentCensorErrors=!!c}static setLogLevel(t){const c=LogLevels[t.toLowerCase()];if(c==null){Logger.globalLogger().warn("invalid log level - "+t);return}_logLevel=c}static from(t){return new Logger(t)}}Logger.errors=ErrorCode;Logger.levels=LogLevel;const lib_esm$k=Object.freeze(Object.defineProperty({__proto__:null,get ErrorCode(){return ErrorCode},get LogLevel(){return LogLevel},Logger},Symbol.toStringTag,{value:"Module"})),version$t="bytes/5.8.0",logger$x=new Logger(version$t);function isHexable(n){return!!n.toHexString}function addSlice(n){return n.slice||(n.slice=function(){const t=Array.prototype.slice.call(arguments);return addSlice(new Uint8Array(Array.prototype.slice.apply(n,t)))}),n}function isBytesLike(n){return isHexString(n)&&!(n.length%2)||isBytes$1(n)}function isInteger(n){return typeof n=="number"&&n==n&&n%1===0}function isBytes$1(n){if(n==null)return!1;if(n.constructor===Uint8Array)return!0;if(typeof n=="string"||!isInteger(n.length)||n.length<0)return!1;for(let t=0;t<n.length;t++){const c=n[t];if(!isInteger(c)||c<0||c>=256)return!1}return!0}function arrayify(n,t){if(t||(t={}),typeof n=="number"){logger$x.checkSafeUint53(n,"invalid arrayify value");const c=[];for(;n;)c.unshift(n&255),n=parseInt(String(n/256));return c.length===0&&c.push(0),addSlice(new Uint8Array(c))}if(t.allowMissingPrefix&&typeof n=="string"&&n.substring(0,2)!=="0x"&&(n="0x"+n),isHexable(n)&&(n=n.toHexString()),isHexString(n)){let c=n.substring(2);c.length%2&&(t.hexPad==="left"?c="0"+c:t.hexPad==="right"?c+="0":logger$x.throwArgumentError("hex data is odd-length","value",n));const ie=[];for(let se=0;se<c.length;se+=2)ie.push(parseInt(c.substring(se,se+2),16));return addSlice(new Uint8Array(ie))}return isBytes$1(n)?addSlice(new Uint8Array(n)):logger$x.throwArgumentError("invalid arrayify value","value",n)}function concat$1(n){const t=n.map(se=>arrayify(se)),c=t.reduce((se,ae)=>se+ae.length,0),ie=new Uint8Array(c);return t.reduce((se,ae)=>(ie.set(ae,se),se+ae.length),0),addSlice(ie)}function stripZeros(n){let t=arrayify(n);if(t.length===0)return t;let c=0;for(;c<t.length&&t[c]===0;)c++;return c&&(t=t.slice(c)),t}function zeroPad(n,t){n=arrayify(n),n.length>t&&logger$x.throwArgumentError("value out of range","value",arguments[0]);const c=new Uint8Array(t);return c.set(n,t-n.length),addSlice(c)}function isHexString(n,t){return!(typeof n!="string"||!n.match(/^0x[0-9A-Fa-f]*$/)||t&&n.length!==2+2*t)}const HexCharacters="0123456789abcdef";function hexlify(n,t){if(t||(t={}),typeof n=="number"){logger$x.checkSafeUint53(n,"invalid hexlify value");let c="";for(;n;)c=HexCharacters[n&15]+c,n=Math.floor(n/16);return c.length?(c.length%2&&(c="0"+c),"0x"+c):"0x00"}if(typeof n=="bigint")return n=n.toString(16),n.length%2?"0x0"+n:"0x"+n;if(t.allowMissingPrefix&&typeof n=="string"&&n.substring(0,2)!=="0x"&&(n="0x"+n),isHexable(n))return n.toHexString();if(isHexString(n))return n.length%2&&(t.hexPad==="left"?n="0x0"+n.substring(2):t.hexPad==="right"?n+="0":logger$x.throwArgumentError("hex data is odd-length","value",n)),n.toLowerCase();if(isBytes$1(n)){let c="0x";for(let ie=0;ie<n.length;ie++){let se=n[ie];c+=HexCharacters[(se&240)>>4]+HexCharacters[se&15]}return c}return logger$x.throwArgumentError("invalid hexlify value","value",n)}function hexDataLength(n){if(typeof n!="string")n=hexlify(n);else if(!isHexString(n)||n.length%2)return null;return(n.length-2)/2}function hexDataSlice(n,t,c){return typeof n!="string"?n=hexlify(n):(!isHexString(n)||n.length%2)&&logger$x.throwArgumentError("invalid hexData","value",n),t=2+2*t,c!=null?"0x"+n.substring(t,2+2*c):"0x"+n.substring(t)}function hexConcat(n){let t="0x";return n.forEach(c=>{t+=hexlify(c).substring(2)}),t}function hexValue(n){const t=hexStripZeros(hexlify(n,{hexPad:"left"}));return t==="0x"?"0x0":t}function hexStripZeros(n){typeof n!="string"&&(n=hexlify(n)),isHexString(n)||logger$x.throwArgumentError("invalid hex string","value",n),n=n.substring(2);let t=0;for(;t<n.length&&n[t]==="0";)t++;return"0x"+n.substring(t)}function hexZeroPad(n,t){for(typeof n!="string"?n=hexlify(n):isHexString(n)||logger$x.throwArgumentError("invalid hex string","value",n),n.length>2*t+2&&logger$x.throwArgumentError("value out of range","value",arguments[1]);n.length<2*t+2;)n="0x0"+n.substring(2);return n}function splitSignature(n){const t={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(isBytesLike(n)){let c=arrayify(n);c.length===64?(t.v=27+(c[32]>>7),c[32]&=127,t.r=hexlify(c.slice(0,32)),t.s=hexlify(c.slice(32,64))):c.length===65?(t.r=hexlify(c.slice(0,32)),t.s=hexlify(c.slice(32,64)),t.v=c[64]):logger$x.throwArgumentError("invalid signature string","signature",n),t.v<27&&(t.v===0||t.v===1?t.v+=27:logger$x.throwArgumentError("signature invalid v byte","signature",n)),t.recoveryParam=1-t.v%2,t.recoveryParam&&(c[32]|=128),t._vs=hexlify(c.slice(32,64))}else{if(t.r=n.r,t.s=n.s,t.v=n.v,t.recoveryParam=n.recoveryParam,t._vs=n._vs,t._vs!=null){const se=zeroPad(arrayify(t._vs),32);t._vs=hexlify(se);const ae=se[0]>=128?1:0;t.recoveryParam==null?t.recoveryParam=ae:t.recoveryParam!==ae&&logger$x.throwArgumentError("signature recoveryParam mismatch _vs","signature",n),se[0]&=127;const ue=hexlify(se);t.s==null?t.s=ue:t.s!==ue&&logger$x.throwArgumentError("signature v mismatch _vs","signature",n)}if(t.recoveryParam==null)t.v==null?logger$x.throwArgumentError("signature missing v and recoveryParam","signature",n):t.v===0||t.v===1?t.recoveryParam=t.v:t.recoveryParam=1-t.v%2;else if(t.v==null)t.v=27+t.recoveryParam;else{const se=t.v===0||t.v===1?t.v:1-t.v%2;t.recoveryParam!==se&&logger$x.throwArgumentError("signature recoveryParam mismatch v","signature",n)}t.r==null||!isHexString(t.r)?logger$x.throwArgumentError("signature missing or invalid r","signature",n):t.r=hexZeroPad(t.r,32),t.s==null||!isHexString(t.s)?logger$x.throwArgumentError("signature missing or invalid s","signature",n):t.s=hexZeroPad(t.s,32);const c=arrayify(t.s);c[0]>=128&&logger$x.throwArgumentError("signature s out of range","signature",n),t.recoveryParam&&(c[0]|=128);const ie=hexlify(c);t._vs&&(isHexString(t._vs)||logger$x.throwArgumentError("signature invalid _vs","signature",n),t._vs=hexZeroPad(t._vs,32)),t._vs==null?t._vs=ie:t._vs!==ie&&logger$x.throwArgumentError("signature _vs mismatch v and s","signature",n)}return t.yParityAndS=t._vs,t.compact=t.r+t.yParityAndS.substring(2),t}function joinSignature(n){return n=splitSignature(n),hexlify(concat$1([n.r,n.s,n.recoveryParam?"0x1c":"0x1b"]))}const lib_esm$j=Object.freeze(Object.defineProperty({__proto__:null,arrayify,concat:concat$1,hexConcat,hexDataLength,hexDataSlice,hexStripZeros,hexValue,hexZeroPad,hexlify,isBytes:isBytes$1,isBytesLike,isHexString,joinSignature,splitSignature,stripZeros,zeroPad},Symbol.toStringTag,{value:"Module"})),version$s="bignumber/5.8.0";var BN$7=BN$8.BN;const logger$w=new Logger(version$s),_constructorGuard$4={},MAX_SAFE=9007199254740991;function isBigNumberish(n){return n!=null&&(BigNumber.isBigNumber(n)||typeof n=="number"&&n%1===0||typeof n=="string"&&!!n.match(/^-?[0-9]+$/)||isHexString(n)||typeof n=="bigint"||isBytes$1(n))}let _warnedToStringRadix=!1;class BigNumber{constructor(t,c){t!==_constructorGuard$4&&logger$w.throwError("cannot call constructor directly; use BigNumber.from",Logger.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=c,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return toBigNumber(toBN(this).fromTwos(t))}toTwos(t){return toBigNumber(toBN(this).toTwos(t))}abs(){return this._hex[0]==="-"?BigNumber.from(this._hex.substring(1)):this}add(t){return toBigNumber(toBN(this).add(toBN(t)))}sub(t){return toBigNumber(toBN(this).sub(toBN(t)))}div(t){return BigNumber.from(t).isZero()&&throwFault$1("division-by-zero","div"),toBigNumber(toBN(this).div(toBN(t)))}mul(t){return toBigNumber(toBN(this).mul(toBN(t)))}mod(t){const c=toBN(t);return c.isNeg()&&throwFault$1("division-by-zero","mod"),toBigNumber(toBN(this).umod(c))}pow(t){const c=toBN(t);return c.isNeg()&&throwFault$1("negative-power","pow"),toBigNumber(toBN(this).pow(c))}and(t){const c=toBN(t);return(this.isNegative()||c.isNeg())&&throwFault$1("unbound-bitwise-result","and"),toBigNumber(toBN(this).and(c))}or(t){const c=toBN(t);return(this.isNegative()||c.isNeg())&&throwFault$1("unbound-bitwise-result","or"),toBigNumber(toBN(this).or(c))}xor(t){const c=toBN(t);return(this.isNegative()||c.isNeg())&&throwFault$1("unbound-bitwise-result","xor"),toBigNumber(toBN(this).xor(c))}mask(t){return(this.isNegative()||t<0)&&throwFault$1("negative-width","mask"),toBigNumber(toBN(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&throwFault$1("negative-width","shl"),toBigNumber(toBN(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&throwFault$1("negative-width","shr"),toBigNumber(toBN(this).shrn(t))}eq(t){return toBN(this).eq(toBN(t))}lt(t){return toBN(this).lt(toBN(t))}lte(t){return toBN(this).lte(toBN(t))}gt(t){return toBN(this).gt(toBN(t))}gte(t){return toBN(this).gte(toBN(t))}isNegative(){return this._hex[0]==="-"}isZero(){return toBN(this).isZero()}toNumber(){try{return toBN(this).toNumber()}catch{throwFault$1("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch{}return logger$w.throwError("this platform does not support BigInt",Logger.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?_warnedToStringRadix||(_warnedToStringRadix=!0,logger$w.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?logger$w.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Logger.errors.UNEXPECTED_ARGUMENT,{}):logger$w.throwError("BigNumber.toString does not accept parameters",Logger.errors.UNEXPECTED_ARGUMENT,{})),toBN(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof BigNumber)return t;if(typeof t=="string")return t.match(/^-?0x[0-9a-f]+$/i)?new BigNumber(_constructorGuard$4,toHex$2(t)):t.match(/^-?[0-9]+$/)?new BigNumber(_constructorGuard$4,toHex$2(new BN$7(t))):logger$w.throwArgumentError("invalid BigNumber string","value",t);if(typeof t=="number")return t%1&&throwFault$1("underflow","BigNumber.from",t),(t>=MAX_SAFE||t<=-MAX_SAFE)&&throwFault$1("overflow","BigNumber.from",t),BigNumber.from(String(t));const c=t;if(typeof c=="bigint")return BigNumber.from(c.toString());if(isBytes$1(c))return BigNumber.from(hexlify(c));if(c)if(c.toHexString){const ie=c.toHexString();if(typeof ie=="string")return BigNumber.from(ie)}else{let ie=c._hex;if(ie==null&&c.type==="BigNumber"&&(ie=c.hex),typeof ie=="string"&&(isHexString(ie)||ie[0]==="-"&&isHexString(ie.substring(1))))return BigNumber.from(ie)}return logger$w.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!!(t&&t._isBigNumber)}}function toHex$2(n){if(typeof n!="string")return toHex$2(n.toString(16));if(n[0]==="-")return n=n.substring(1),n[0]==="-"&&logger$w.throwArgumentError("invalid hex","value",n),n=toHex$2(n),n==="0x00"?n:"-"+n;if(n.substring(0,2)!=="0x"&&(n="0x"+n),n==="0x")return"0x00";for(n.length%2&&(n="0x0"+n.substring(2));n.length>4&&n.substring(0,4)==="0x00";)n="0x"+n.substring(4);return n}function toBigNumber(n){return BigNumber.from(toHex$2(n))}function toBN(n){const t=BigNumber.from(n).toHexString();return t[0]==="-"?new BN$7("-"+t.substring(3),16):new BN$7(t.substring(2),16)}function throwFault$1(n,t,c){const ie={fault:n,operation:t};return c!=null&&(ie.value=c),logger$w.throwError(n,Logger.errors.NUMERIC_FAULT,ie)}function _base36To16(n){return new BN$7(n,36).toString(16)}function _base16To36(n){return new BN$7(n,16).toString(36)}const logger$v=new Logger(version$s),_constructorGuard$3={},Zero$2=BigNumber.from(0),NegativeOne$2=BigNumber.from(-1);function throwFault(n,t,c,ie){const se={fault:t,operation:c};return ie!==void 0&&(se.value=ie),logger$v.throwError(n,Logger.errors.NUMERIC_FAULT,se)}let zeros="0";for(;zeros.length<256;)zeros+=zeros;function getMultiplier(n){if(typeof n!="number")try{n=BigNumber.from(n).toNumber()}catch{}return typeof n=="number"&&n>=0&&n<=256&&!(n%1)?"1"+zeros.substring(0,n):logger$v.throwArgumentError("invalid decimal size","decimals",n)}function formatFixed(n,t){t==null&&(t=0);const c=getMultiplier(t);n=BigNumber.from(n);const ie=n.lt(Zero$2);ie&&(n=n.mul(NegativeOne$2));let se=n.mod(c).toString();for(;se.length<c.length-1;)se="0"+se;se=se.match(/^([0-9]*[1-9]|0)(0*)/)[1];const ae=n.div(c).toString();return c.length===1?n=ae:n=ae+"."+se,ie&&(n="-"+n),n}function parseFixed(n,t){t==null&&(t=0);const c=getMultiplier(t);(typeof n!="string"||!n.match(/^-?[0-9.]+$/))&&logger$v.throwArgumentError("invalid decimal value","value",n);const ie=n.substring(0,1)==="-";ie&&(n=n.substring(1)),n==="."&&logger$v.throwArgumentError("missing value","value",n);const se=n.split(".");se.length>2&&logger$v.throwArgumentError("too many decimal points","value",n);let ae=se[0],ue=se[1];for(ae||(ae="0"),ue||(ue="0");ue[ue.length-1]==="0";)ue=ue.substring(0,ue.length-1);for(ue.length>c.length-1&&throwFault("fractional component exceeds decimals","underflow","parseFixed"),ue===""&&(ue="0");ue.length<c.length-1;)ue+="0";const de=BigNumber.from(ae),ve=BigNumber.from(ue);let ge=de.mul(c).add(ve);return ie&&(ge=ge.mul(NegativeOne$2)),ge}class FixedFormat{constructor(t,c,ie,se){t!==_constructorGuard$3&&logger$v.throwError("cannot use FixedFormat constructor; use FixedFormat.from",Logger.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.signed=c,this.width=ie,this.decimals=se,this.name=(c?"":"u")+"fixed"+String(ie)+"x"+String(se),this._multiplier=getMultiplier(se),Object.freeze(this)}static from(t){if(t instanceof FixedFormat)return t;typeof t=="number"&&(t=`fixed128x${t}`);let c=!0,ie=128,se=18;if(typeof t=="string"){if(t!=="fixed")if(t==="ufixed")c=!1;else{const ae=t.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);ae||logger$v.throwArgumentError("invalid fixed format","format",t),c=ae[1]!=="u",ie=parseInt(ae[2]),se=parseInt(ae[3])}}else if(t){const ae=(ue,de,ve)=>t[ue]==null?ve:(typeof t[ue]!==de&&logger$v.throwArgumentError("invalid fixed format ("+ue+" not "+de+")","format."+ue,t[ue]),t[ue]);c=ae("signed","boolean",c),ie=ae("width","number",ie),se=ae("decimals","number",se)}return ie%8&&logger$v.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",ie),se>80&&logger$v.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",se),new FixedFormat(_constructorGuard$3,c,ie,se)}}class FixedNumber{constructor(t,c,ie,se){t!==_constructorGuard$3&&logger$v.throwError("cannot use FixedNumber constructor; use FixedNumber.from",Logger.errors.UNSUPPORTED_OPERATION,{operation:"new FixedFormat"}),this.format=se,this._hex=c,this._value=ie,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(t){this.format.name!==t.format.name&&logger$v.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",t)}addUnsafe(t){this._checkFormat(t);const c=parseFixed(this._value,this.format.decimals),ie=parseFixed(t._value,t.format.decimals);return FixedNumber.fromValue(c.add(ie),this.format.decimals,this.format)}subUnsafe(t){this._checkFormat(t);const c=parseFixed(this._value,this.format.decimals),ie=parseFixed(t._value,t.format.decimals);return FixedNumber.fromValue(c.sub(ie),this.format.decimals,this.format)}mulUnsafe(t){this._checkFormat(t);const c=parseFixed(this._value,this.format.decimals),ie=parseFixed(t._value,t.format.decimals);return FixedNumber.fromValue(c.mul(ie).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(t){this._checkFormat(t);const c=parseFixed(this._value,this.format.decimals),ie=parseFixed(t._value,t.format.decimals);return FixedNumber.fromValue(c.mul(this.format._multiplier).div(ie),this.format.decimals,this.format)}floor(){const t=this.toString().split(".");t.length===1&&t.push("0");let c=FixedNumber.from(t[0],this.format);const ie=!t[1].match(/^(0*)$/);return this.isNegative()&&ie&&(c=c.subUnsafe(ONE.toFormat(c.format))),c}ceiling(){const t=this.toString().split(".");t.length===1&&t.push("0");let c=FixedNumber.from(t[0],this.format);const ie=!t[1].match(/^(0*)$/);return!this.isNegative()&&ie&&(c=c.addUnsafe(ONE.toFormat(c.format))),c}round(t){t==null&&(t=0);const c=this.toString().split(".");if(c.length===1&&c.push("0"),(t<0||t>80||t%1)&&logger$v.throwArgumentError("invalid decimal count","decimals",t),c[1].length<=t)return this;const ie=FixedNumber.from("1"+zeros.substring(0,t),this.format),se=BUMP.toFormat(this.format);return this.mulUnsafe(ie).addUnsafe(se).floor().divUnsafe(ie)}isZero(){return this._value==="0.0"||this._value==="0"}isNegative(){return this._value[0]==="-"}toString(){return this._value}toHexString(t){if(t==null)return this._hex;t%8&&logger$v.throwArgumentError("invalid byte width","width",t);const c=BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(t).toHexString();return hexZeroPad(c,t/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(t){return FixedNumber.fromString(this._value,t)}static fromValue(t,c,ie){return ie==null&&c!=null&&!isBigNumberish(c)&&(ie=c,c=null),c==null&&(c=0),ie==null&&(ie="fixed"),FixedNumber.fromString(formatFixed(t,c),FixedFormat.from(ie))}static fromString(t,c){c==null&&(c="fixed");const ie=FixedFormat.from(c),se=parseFixed(t,ie.decimals);!ie.signed&&se.lt(Zero$2)&&throwFault("unsigned value cannot be negative","overflow","value",t);let ae=null;ie.signed?ae=se.toTwos(ie.width).toHexString():(ae=se.toHexString(),ae=hexZeroPad(ae,ie.width/8));const ue=formatFixed(se,ie.decimals);return new FixedNumber(_constructorGuard$3,ae,ue,ie)}static fromBytes(t,c){c==null&&(c="fixed");const ie=FixedFormat.from(c);if(arrayify(t).length>ie.width/8)throw new Error("overflow");let se=BigNumber.from(t);ie.signed&&(se=se.fromTwos(ie.width));const ae=se.toTwos((ie.signed?0:1)+ie.width).toHexString(),ue=formatFixed(se,ie.decimals);return new FixedNumber(_constructorGuard$3,ae,ue,ie)}static from(t,c){if(typeof t=="string")return FixedNumber.fromString(t,c);if(isBytes$1(t))return FixedNumber.fromBytes(t,c);try{return FixedNumber.fromValue(t,0,c)}catch(ie){if(ie.code!==Logger.errors.INVALID_ARGUMENT)throw ie}return logger$v.throwArgumentError("invalid FixedNumber value","value",t)}static isFixedNumber(t){return!!(t&&t._isFixedNumber)}}const ONE=FixedNumber.from(1),BUMP=FixedNumber.from("0.5"),version$r="properties/5.8.0";var __awaiter$l=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$u=new Logger(version$r);function defineReadOnly(n,t,c){Object.defineProperty(n,t,{enumerable:!0,value:c,writable:!1})}function getStatic(n,t){for(let c=0;c<32;c++){if(n[t])return n[t];if(!n.prototype||typeof n.prototype!="object")break;n=Object.getPrototypeOf(n.prototype).constructor}return null}function resolveProperties(n){return __awaiter$l(this,void 0,void 0,function*(){const t=Object.keys(n).map(c=>{const ie=n[c];return Promise.resolve(ie).then(se=>({key:c,value:se}))});return(yield Promise.all(t)).reduce((c,ie)=>(c[ie.key]=ie.value,c),{})})}function checkProperties(n,t){(!n||typeof n!="object")&&logger$u.throwArgumentError("invalid object","object",n),Object.keys(n).forEach(c=>{t[c]||logger$u.throwArgumentError("invalid object key - "+c,"transaction:"+c,n)})}function shallowCopy(n){const t={};for(const c in n)t[c]=n[c];return t}const opaque={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function _isFrozen(n){if(n==null||opaque[typeof n])return!0;if(Array.isArray(n)||typeof n=="object"){if(!Object.isFrozen(n))return!1;const t=Object.keys(n);for(let c=0;c<t.length;c++){let ie=null;try{ie=n[t[c]]}catch{continue}if(!_isFrozen(ie))return!1}return!0}return logger$u.throwArgumentError(`Cannot deepCopy ${typeof n}`,"object",n)}function _deepCopy(n){if(_isFrozen(n))return n;if(Array.isArray(n))return Object.freeze(n.map(t=>deepCopy(t)));if(typeof n=="object"){const t={};for(const c in n){const ie=n[c];ie!==void 0&&defineReadOnly(t,c,deepCopy(ie))}return t}return logger$u.throwArgumentError(`Cannot deepCopy ${typeof n}`,"object",n)}function deepCopy(n){return _deepCopy(n)}class Description{constructor(t){for(const c in t)this[c]=deepCopy(t[c])}}const lib_esm$i=Object.freeze(Object.defineProperty({__proto__:null,Description,checkProperties,deepCopy,defineReadOnly,getStatic,resolveProperties,shallowCopy},Symbol.toStringTag,{value:"Module"})),version$q="abi/5.8.0",logger$t=new Logger(version$q),_constructorGuard$2={};let ModifiersBytes={calldata:!0,memory:!0,storage:!0},ModifiersNest={calldata:!0,memory:!0};function checkModifier(n,t){if(n==="bytes"||n==="string"){if(ModifiersBytes[t])return!0}else if(n==="address"){if(t==="payable")return!0}else if((n.indexOf("[")>=0||n==="tuple")&&ModifiersNest[t])return!0;return(ModifiersBytes[t]||t==="payable")&&logger$t.throwArgumentError("invalid modifier","name",t),!1}function parseParamType(n,t){let c=n;function ie(de){logger$t.throwArgumentError(`unexpected character at position ${de}`,"param",n)}n=n.replace(/\s/g," ");function se(de){let ve={type:"",name:"",parent:de,state:{allowType:!0}};return t&&(ve.indexed=!1),ve}let ae={type:"",name:"",state:{allowType:!0}},ue=ae;for(let de=0;de<n.length;de++){let ve=n[de];switch(ve){case"(":ue.state.allowType&&ue.type===""?ue.type="tuple":ue.state.allowParams||ie(de),ue.state.allowType=!1,ue.type=verifyType(ue.type),ue.components=[se(ue)],ue=ue.components[0];break;case")":delete ue.state,ue.name==="indexed"&&(t||ie(de),ue.indexed=!0,ue.name=""),checkModifier(ue.type,ue.name)&&(ue.name=""),ue.type=verifyType(ue.type);let ge=ue;ue=ue.parent,ue||ie(de),delete ge.parent,ue.state.allowParams=!1,ue.state.allowName=!0,ue.state.allowArray=!0;break;case",":delete ue.state,ue.name==="indexed"&&(t||ie(de),ue.indexed=!0,ue.name=""),checkModifier(ue.type,ue.name)&&(ue.name=""),ue.type=verifyType(ue.type);let we=se(ue.parent);ue.parent.components.push(we),delete ue.parent,ue=we;break;case" ":ue.state.allowType&&ue.type!==""&&(ue.type=verifyType(ue.type),delete ue.state.allowType,ue.state.allowName=!0,ue.state.allowParams=!0),ue.state.allowName&&ue.name!==""&&(ue.name==="indexed"?(t||ie(de),ue.indexed&&ie(de),ue.indexed=!0,ue.name=""):checkModifier(ue.type,ue.name)?ue.name="":ue.state.allowName=!1);break;case"[":ue.state.allowArray||ie(de),ue.type+=ve,ue.state.allowArray=!1,ue.state.allowName=!1,ue.state.readArray=!0;break;case"]":ue.state.readArray||ie(de),ue.type+=ve,ue.state.readArray=!1,ue.state.allowArray=!0,ue.state.allowName=!0;break;default:ue.state.allowType?(ue.type+=ve,ue.state.allowParams=!0,ue.state.allowArray=!0):ue.state.allowName?(ue.name+=ve,delete ue.state.allowArray):ue.state.readArray?ue.type+=ve:ie(de)}}return ue.parent&&logger$t.throwArgumentError("unexpected eof","param",n),delete ae.state,ue.name==="indexed"?(t||ie(c.length-7),ue.indexed&&ie(c.length-7),ue.indexed=!0,ue.name=""):checkModifier(ue.type,ue.name)&&(ue.name=""),ae.type=verifyType(ae.type),ae}function populate(n,t){for(let c in t)defineReadOnly(n,c,t[c])}const FormatTypes=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),paramTypeArray=new RegExp(/^(.*)\[([0-9]*)\]$/);class ParamType{constructor(t,c){t!==_constructorGuard$2&&logger$t.throwError("use fromString",Logger.errors.UNSUPPORTED_OPERATION,{operation:"new ParamType()"}),populate(this,c);let ie=this.type.match(paramTypeArray);ie?populate(this,{arrayLength:parseInt(ie[2]||"-1"),arrayChildren:ParamType.fromObject({type:ie[1],components:this.components}),baseType:"array"}):populate(this,{arrayLength:null,arrayChildren:null,baseType:this.components!=null?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}format(t){if(t||(t=FormatTypes.sighash),FormatTypes[t]||logger$t.throwArgumentError("invalid format type","format",t),t===FormatTypes.json){let ie={type:this.baseType==="tuple"?"tuple":this.type,name:this.name||void 0};return typeof this.indexed=="boolean"&&(ie.indexed=this.indexed),this.components&&(ie.components=this.components.map(se=>JSON.parse(se.format(t)))),JSON.stringify(ie)}let c="";return this.baseType==="array"?(c+=this.arrayChildren.format(t),c+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):this.baseType==="tuple"?(t!==FormatTypes.sighash&&(c+=this.type),c+="("+this.components.map(ie=>ie.format(t)).join(t===FormatTypes.full?", ":",")+")"):c+=this.type,t!==FormatTypes.sighash&&(this.indexed===!0&&(c+=" indexed"),t===FormatTypes.full&&this.name&&(c+=" "+this.name)),c}static from(t,c){return typeof t=="string"?ParamType.fromString(t,c):ParamType.fromObject(t)}static fromObject(t){return ParamType.isParamType(t)?t:new ParamType(_constructorGuard$2,{name:t.name||null,type:verifyType(t.type),indexed:t.indexed==null?null:!!t.indexed,components:t.components?t.components.map(ParamType.fromObject):null})}static fromString(t,c){function ie(se){return ParamType.fromObject({name:se.name,type:se.type,indexed:se.indexed,components:se.components})}return ie(parseParamType(t,!!c))}static isParamType(t){return!!(t!=null&&t._isParamType)}}function parseParams(n,t){return splitNesting(n).map(c=>ParamType.fromString(c,t))}class Fragment{constructor(t,c){t!==_constructorGuard$2&&logger$t.throwError("use a static from method",Logger.errors.UNSUPPORTED_OPERATION,{operation:"new Fragment()"}),populate(this,c),this._isFragment=!0,Object.freeze(this)}static from(t){return Fragment.isFragment(t)?t:typeof t=="string"?Fragment.fromString(t):Fragment.fromObject(t)}static fromObject(t){if(Fragment.isFragment(t))return t;switch(t.type){case"function":return FunctionFragment.fromObject(t);case"event":return EventFragment.fromObject(t);case"constructor":return ConstructorFragment.fromObject(t);case"error":return ErrorFragment.fromObject(t);case"fallback":case"receive":return null}return logger$t.throwArgumentError("invalid fragment object","value",t)}static fromString(t){return t=t.replace(/\s/g," "),t=t.replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," "),t=t.trim(),t.split(" ")[0]==="event"?EventFragment.fromString(t.substring(5).trim()):t.split(" ")[0]==="function"?FunctionFragment.fromString(t.substring(8).trim()):t.split("(")[0].trim()==="constructor"?ConstructorFragment.fromString(t.trim()):t.split(" ")[0]==="error"?ErrorFragment.fromString(t.substring(5).trim()):logger$t.throwArgumentError("unsupported fragment","value",t)}static isFragment(t){return!!(t&&t._isFragment)}}class EventFragment extends Fragment{format(t){if(t||(t=FormatTypes.sighash),FormatTypes[t]||logger$t.throwArgumentError("invalid format type","format",t),t===FormatTypes.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(ie=>JSON.parse(ie.format(t)))});let c="";return t!==FormatTypes.sighash&&(c+="event "),c+=this.name+"("+this.inputs.map(ie=>ie.format(t)).join(t===FormatTypes.full?", ":",")+") ",t!==FormatTypes.sighash&&this.anonymous&&(c+="anonymous "),c.trim()}static from(t){return typeof t=="string"?EventFragment.fromString(t):EventFragment.fromObject(t)}static fromObject(t){if(EventFragment.isEventFragment(t))return t;t.type!=="event"&&logger$t.throwArgumentError("invalid event object","value",t);const c={name:verifyIdentifier(t.name),anonymous:t.anonymous,inputs:t.inputs?t.inputs.map(ParamType.fromObject):[],type:"event"};return new EventFragment(_constructorGuard$2,c)}static fromString(t){let c=t.match(regexParen);c||logger$t.throwArgumentError("invalid event string","value",t);let ie=!1;return c[3].split(" ").forEach(se=>{switch(se.trim()){case"anonymous":ie=!0;break;case"":break;default:logger$t.warn("unknown modifier: "+se)}}),EventFragment.fromObject({name:c[1].trim(),anonymous:ie,inputs:parseParams(c[2],!0),type:"event"})}static isEventFragment(t){return t&&t._isFragment&&t.type==="event"}}function parseGas(n,t){t.gas=null;let c=n.split("@");return c.length!==1?(c.length>2&&logger$t.throwArgumentError("invalid human-readable ABI signature","value",n),c[1].match(/^[0-9]+$/)||logger$t.throwArgumentError("invalid human-readable ABI signature gas","value",n),t.gas=BigNumber.from(c[1]),c[0]):n}function parseModifiers(n,t){t.constant=!1,t.payable=!1,t.stateMutability="nonpayable",n.split(" ").forEach(c=>{switch(c.trim()){case"constant":t.constant=!0;break;case"payable":t.payable=!0,t.stateMutability="payable";break;case"nonpayable":t.payable=!1,t.stateMutability="nonpayable";break;case"pure":t.constant=!0,t.stateMutability="pure";break;case"view":t.constant=!0,t.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+c)}})}function verifyState(n){let t={constant:!1,payable:!0,stateMutability:"payable"};return n.stateMutability!=null?(t.stateMutability=n.stateMutability,t.constant=t.stateMutability==="view"||t.stateMutability==="pure",n.constant!=null&&!!n.constant!==t.constant&&logger$t.throwArgumentError("cannot have constant function with mutability "+t.stateMutability,"value",n),t.payable=t.stateMutability==="payable",n.payable!=null&&!!n.payable!==t.payable&&logger$t.throwArgumentError("cannot have payable function with mutability "+t.stateMutability,"value",n)):n.payable!=null?(t.payable=!!n.payable,n.constant==null&&!t.payable&&n.type!=="constructor"&&logger$t.throwArgumentError("unable to determine stateMutability","value",n),t.constant=!!n.constant,t.constant?t.stateMutability="view":t.stateMutability=t.payable?"payable":"nonpayable",t.payable&&t.constant&&logger$t.throwArgumentError("cannot have constant payable function","value",n)):n.constant!=null?(t.constant=!!n.constant,t.payable=!t.constant,t.stateMutability=t.constant?"view":"payable"):n.type!=="constructor"&&logger$t.throwArgumentError("unable to determine stateMutability","value",n),t}class ConstructorFragment extends Fragment{format(t){if(t||(t=FormatTypes.sighash),FormatTypes[t]||logger$t.throwArgumentError("invalid format type","format",t),t===FormatTypes.json)return JSON.stringify({type:"constructor",stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(ie=>JSON.parse(ie.format(t)))});t===FormatTypes.sighash&&logger$t.throwError("cannot format a constructor for sighash",Logger.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let c="constructor("+this.inputs.map(ie=>ie.format(t)).join(t===FormatTypes.full?", ":",")+") ";return this.stateMutability&&this.stateMutability!=="nonpayable"&&(c+=this.stateMutability+" "),c.trim()}static from(t){return typeof t=="string"?ConstructorFragment.fromString(t):ConstructorFragment.fromObject(t)}static fromObject(t){if(ConstructorFragment.isConstructorFragment(t))return t;t.type!=="constructor"&&logger$t.throwArgumentError("invalid constructor object","value",t);let c=verifyState(t);c.constant&&logger$t.throwArgumentError("constructor cannot be constant","value",t);const ie={name:null,type:t.type,inputs:t.inputs?t.inputs.map(ParamType.fromObject):[],payable:c.payable,stateMutability:c.stateMutability,gas:t.gas?BigNumber.from(t.gas):null};return new ConstructorFragment(_constructorGuard$2,ie)}static fromString(t){let c={type:"constructor"};t=parseGas(t,c);let ie=t.match(regexParen);return(!ie||ie[1].trim()!=="constructor")&&logger$t.throwArgumentError("invalid constructor string","value",t),c.inputs=parseParams(ie[2].trim(),!1),parseModifiers(ie[3].trim(),c),ConstructorFragment.fromObject(c)}static isConstructorFragment(t){return t&&t._isFragment&&t.type==="constructor"}}class FunctionFragment extends ConstructorFragment{format(t){if(t||(t=FormatTypes.sighash),FormatTypes[t]||logger$t.throwArgumentError("invalid format type","format",t),t===FormatTypes.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(ie=>JSON.parse(ie.format(t))),outputs:this.outputs.map(ie=>JSON.parse(ie.format(t)))});let c="";return t!==FormatTypes.sighash&&(c+="function "),c+=this.name+"("+this.inputs.map(ie=>ie.format(t)).join(t===FormatTypes.full?", ":",")+") ",t!==FormatTypes.sighash&&(this.stateMutability?this.stateMutability!=="nonpayable"&&(c+=this.stateMutability+" "):this.constant&&(c+="view "),this.outputs&&this.outputs.length&&(c+="returns ("+this.outputs.map(ie=>ie.format(t)).join(", ")+") "),this.gas!=null&&(c+="@"+this.gas.toString()+" ")),c.trim()}static from(t){return typeof t=="string"?FunctionFragment.fromString(t):FunctionFragment.fromObject(t)}static fromObject(t){if(FunctionFragment.isFunctionFragment(t))return t;t.type!=="function"&&logger$t.throwArgumentError("invalid function object","value",t);let c=verifyState(t);const ie={type:t.type,name:verifyIdentifier(t.name),constant:c.constant,inputs:t.inputs?t.inputs.map(ParamType.fromObject):[],outputs:t.outputs?t.outputs.map(ParamType.fromObject):[],payable:c.payable,stateMutability:c.stateMutability,gas:t.gas?BigNumber.from(t.gas):null};return new FunctionFragment(_constructorGuard$2,ie)}static fromString(t){let c={type:"function"};t=parseGas(t,c);let ie=t.split(" returns ");ie.length>2&&logger$t.throwArgumentError("invalid function string","value",t);let se=ie[0].match(regexParen);if(se||logger$t.throwArgumentError("invalid function signature","value",t),c.name=se[1].trim(),c.name&&verifyIdentifier(c.name),c.inputs=parseParams(se[2],!1),parseModifiers(se[3].trim(),c),ie.length>1){let ae=ie[1].match(regexParen);(ae[1].trim()!=""||ae[3].trim()!="")&&logger$t.throwArgumentError("unexpected tokens","value",t),c.outputs=parseParams(ae[2],!1)}else c.outputs=[];return FunctionFragment.fromObject(c)}static isFunctionFragment(t){return t&&t._isFragment&&t.type==="function"}}function checkForbidden(n){const t=n.format();return(t==="Error(string)"||t==="Panic(uint256)")&&logger$t.throwArgumentError(`cannot specify user defined ${t} error`,"fragment",n),n}class ErrorFragment extends Fragment{format(t){if(t||(t=FormatTypes.sighash),FormatTypes[t]||logger$t.throwArgumentError("invalid format type","format",t),t===FormatTypes.json)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(ie=>JSON.parse(ie.format(t)))});let c="";return t!==FormatTypes.sighash&&(c+="error "),c+=this.name+"("+this.inputs.map(ie=>ie.format(t)).join(t===FormatTypes.full?", ":",")+") ",c.trim()}static from(t){return typeof t=="string"?ErrorFragment.fromString(t):ErrorFragment.fromObject(t)}static fromObject(t){if(ErrorFragment.isErrorFragment(t))return t;t.type!=="error"&&logger$t.throwArgumentError("invalid error object","value",t);const c={type:t.type,name:verifyIdentifier(t.name),inputs:t.inputs?t.inputs.map(ParamType.fromObject):[]};return checkForbidden(new ErrorFragment(_constructorGuard$2,c))}static fromString(t){let c={type:"error"},ie=t.match(regexParen);return ie||logger$t.throwArgumentError("invalid error signature","value",t),c.name=ie[1].trim(),c.name&&verifyIdentifier(c.name),c.inputs=parseParams(ie[2],!1),checkForbidden(ErrorFragment.fromObject(c))}static isErrorFragment(t){return t&&t._isFragment&&t.type==="error"}}function verifyType(n){return n.match(/^uint($|[^1-9])/)?n="uint256"+n.substring(4):n.match(/^int($|[^1-9])/)&&(n="int256"+n.substring(3)),n}const regexIdentifier=new RegExp("^[a-zA-Z$_][a-zA-Z0-9$_]*$");function verifyIdentifier(n){return(!n||!n.match(regexIdentifier))&&logger$t.throwArgumentError(`invalid identifier "${n}"`,"value",n),n}const regexParen=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");function splitNesting(n){n=n.trim();let t=[],c="",ie=0;for(let se=0;se<n.length;se++){let ae=n[se];ae===","&&ie===0?(t.push(c),c=""):(c+=ae,ae==="("?ie++:ae===")"&&(ie--,ie===-1&&logger$t.throwArgumentError("unbalanced parenthesis","value",n)))}return c&&t.push(c),t}const logger$s=new Logger(version$q);function checkResultErrors(n){const t=[],c=function(ie,se){if(Array.isArray(se))for(let ae in se){const ue=ie.slice();ue.push(ae);try{c(ue,se[ae])}catch(de){t.push({path:ue,error:de})}}};return c([],n),t}class Coder{constructor(t,c,ie,se){this.name=t,this.type=c,this.localName=ie,this.dynamic=se}_throwError(t,c){logger$s.throwArgumentError(t,this.localName,c)}}class Writer{constructor(t){defineReadOnly(this,"wordSize",t||32),this._data=[],this._dataLength=0,this._padding=new Uint8Array(t)}get data(){return hexConcat(this._data)}get length(){return this._dataLength}_writeData(t){return this._data.push(t),this._dataLength+=t.length,t.length}appendWriter(t){return this._writeData(concat$1(t._data))}writeBytes(t){let c=arrayify(t);const ie=c.length%this.wordSize;return ie&&(c=concat$1([c,this._padding.slice(ie)])),this._writeData(c)}_getValue(t){let c=arrayify(BigNumber.from(t));return c.length>this.wordSize&&logger$s.throwError("value out-of-bounds",Logger.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:c.length}),c.length%this.wordSize&&(c=concat$1([this._padding.slice(c.length%this.wordSize),c])),c}writeValue(t){return this._writeData(this._getValue(t))}writeUpdatableValue(){const t=this._data.length;return this._data.push(this._padding),this._dataLength+=this.wordSize,c=>{this._data[t]=this._getValue(c)}}}class Reader{constructor(t,c,ie,se){defineReadOnly(this,"_data",arrayify(t)),defineReadOnly(this,"wordSize",c||32),defineReadOnly(this,"_coerceFunc",ie),defineReadOnly(this,"allowLoose",se),this._offset=0}get data(){return hexlify(this._data)}get consumed(){return this._offset}static coerce(t,c){let ie=t.match("^u?int([0-9]+)$");return ie&&parseInt(ie[1])<=48&&(c=c.toNumber()),c}coerce(t,c){return this._coerceFunc?this._coerceFunc(t,c):Reader.coerce(t,c)}_peekBytes(t,c,ie){let se=Math.ceil(c/this.wordSize)*this.wordSize;return this._offset+se>this._data.length&&(this.allowLoose&&ie&&this._offset+c<=this._data.length?se=c:logger$s.throwError("data out-of-bounds",Logger.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+se})),this._data.slice(this._offset,this._offset+se)}subReader(t){return new Reader(this._data.slice(this._offset+t),this.wordSize,this._coerceFunc,this.allowLoose)}readBytes(t,c){let ie=this._peekBytes(0,t,!!c);return this._offset+=ie.length,ie.slice(0,t)}readValue(){return BigNumber.from(this.readBytes(this.wordSize))}}function getDefaultExportFromCjs$1(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var browser$e={exports:{}},process$1=browser$e.exports={},cachedSetTimeout,cachedClearTimeout;function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?cachedSetTimeout=setTimeout:cachedSetTimeout=defaultSetTimout}catch{cachedSetTimeout=defaultSetTimout}try{typeof clearTimeout=="function"?cachedClearTimeout=clearTimeout:cachedClearTimeout=defaultClearTimeout}catch{cachedClearTimeout=defaultClearTimeout}})();function runTimeout(n){if(cachedSetTimeout===setTimeout)return setTimeout(n,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(n,0);try{return cachedSetTimeout(n,0)}catch{try{return cachedSetTimeout.call(null,n,0)}catch{return cachedSetTimeout.call(this,n,0)}}}function runClearTimeout(n){if(cachedClearTimeout===clearTimeout)return clearTimeout(n);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(n);try{return cachedClearTimeout(n)}catch{try{return cachedClearTimeout.call(null,n)}catch{return cachedClearTimeout.call(this,n)}}}var queue=[],draining=!1,currentQueue,queueIndex=-1;function cleanUpNextTick(){!draining||!currentQueue||(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var n=runTimeout(cleanUpNextTick);draining=!0;for(var t=queue.length;t;){for(currentQueue=queue,queue=[];++queueIndex<t;)currentQueue&&currentQueue[queueIndex].run();queueIndex=-1,t=queue.length}currentQueue=null,draining=!1,runClearTimeout(n)}}process$1.nextTick=function(n){var t=new Array(arguments.length-1);if(arguments.length>1)for(var c=1;c<arguments.length;c++)t[c-1]=arguments[c];queue.push(new Item(n,t)),queue.length===1&&!draining&&runTimeout(drainQueue)};function Item(n,t){this.fun=n,this.array=t}Item.prototype.run=function(){this.fun.apply(null,this.array)};process$1.title="browser";process$1.browser=!0;process$1.env={};process$1.argv=[];process$1.version="";process$1.versions={};function noop$4(){}process$1.on=noop$4;process$1.addListener=noop$4;process$1.once=noop$4;process$1.off=noop$4;process$1.removeListener=noop$4;process$1.removeAllListeners=noop$4;process$1.emit=noop$4;process$1.prependListener=noop$4;process$1.prependOnceListener=noop$4;process$1.listeners=function(n){return[]};process$1.binding=function(n){throw new Error("process.binding is not supported")};process$1.cwd=function(){return"/"};process$1.chdir=function(n){throw new Error("process.chdir is not supported")};process$1.umask=function(){return 0};var browserExports=browser$e.exports;const process$1$1=getDefaultExportFromCjs$1(browserExports);var sha3$3={exports:{}};(function(n){(function(){var t="input is invalid type",c="finalize already called",ie=typeof window=="object",se=ie?window:{};se.JS_SHA3_NO_WINDOW&&(ie=!1);var ae=!ie&&typeof self=="object",ue=!se.JS_SHA3_NO_NODE_JS&&typeof process$1$1=="object"&&process$1$1.versions&&process$1$1.versions.node;ue?se=globalThis:ae&&(se=self);var de=!se.JS_SHA3_NO_COMMON_JS&&!0&&n.exports,ve=!se.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",ge="0123456789abcdef".split(""),we=[31,7936,2031616,520093696],Te=[4,1024,262144,67108864],Ne=[1,256,65536,16777216],qe=[6,1536,393216,100663296],ze=[0,8,16,24],He=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],Ge=[224,256,384,512],Ze=[128,256],Ye=["hex","buffer","arrayBuffer","array","digest"],Ft={128:168,256:136};(se.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(Vt){return Object.prototype.toString.call(Vt)==="[object Array]"}),ve&&(se.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(Vt){return typeof Vt=="object"&&Vt.buffer&&Vt.buffer.constructor===ArrayBuffer});for(var Mt=function(Vt,Cn,un){return function(Pt){return new $t(Vt,Cn,Vt).update(Pt)[un]()}},Zt=function(Vt,Cn,un){return function(Pt,mn){return new $t(Vt,Cn,mn).update(Pt)[un]()}},cn=function(Vt,Cn,un){return function(Pt,mn,Pn,wn){return xe["cshake"+Vt].update(Pt,mn,Pn,wn)[un]()}},hn=function(Vt,Cn,un){return function(Pt,mn,Pn,wn){return xe["kmac"+Vt].update(Pt,mn,Pn,wn)[un]()}},yn=function(Vt,Cn,un,Pt){for(var mn=0;mn<Ye.length;++mn){var Pn=Ye[mn];Vt[Pn]=Cn(un,Pt,Pn)}return Vt},Ht=function(Vt,Cn){var un=Mt(Vt,Cn,"hex");return un.create=function(){return new $t(Vt,Cn,Vt)},un.update=function(Pt){return un.create().update(Pt)},yn(un,Mt,Vt,Cn)},Sn=function(Vt,Cn){var un=Zt(Vt,Cn,"hex");return un.create=function(Pt){return new $t(Vt,Cn,Pt)},un.update=function(Pt,mn){return un.create(mn).update(Pt)},yn(un,Zt,Vt,Cn)},le=function(Vt,Cn){var un=Ft[Vt],Pt=cn(Vt,Cn,"hex");return Pt.create=function(mn,Pn,wn){return!Pn&&!wn?xe["shake"+Vt].create(mn):new $t(Vt,Cn,mn).bytepad([Pn,wn],un)},Pt.update=function(mn,Pn,wn,jt){return Pt.create(Pn,wn,jt).update(mn)},yn(Pt,cn,Vt,Cn)},pe=function(Vt,Cn){var un=Ft[Vt],Pt=hn(Vt,Cn,"hex");return Pt.create=function(mn,Pn,wn){return new dn(Vt,Cn,Pn).bytepad(["KMAC",wn],un).bytepad([mn],un)},Pt.update=function(mn,Pn,wn,jt){return Pt.create(mn,wn,jt).update(Pn)},yn(Pt,hn,Vt,Cn)},be=[{name:"keccak",padding:Ne,bits:Ge,createMethod:Ht},{name:"sha3",padding:qe,bits:Ge,createMethod:Ht},{name:"shake",padding:we,bits:Ze,createMethod:Sn},{name:"cshake",padding:Te,bits:Ze,createMethod:le},{name:"kmac",padding:Te,bits:Ze,createMethod:pe}],xe={},_e=[],De=0;De<be.length;++De)for(var Fe=be[De],$e=Fe.bits,ce=0;ce<$e.length;++ce){var Me=Fe.name+"_"+$e[ce];if(_e.push(Me),xe[Me]=Fe.createMethod($e[ce],Fe.padding),Fe.name!=="sha3"){var We=Fe.name+$e[ce];_e.push(We),xe[We]=xe[Me]}}function $t(Vt,Cn,un){this.blocks=[],this.s=[],this.padding=Cn,this.outputBits=un,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(Vt<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=un>>5,this.extraBytes=(un&31)>>3;for(var Pt=0;Pt<50;++Pt)this.s[Pt]=0}$t.prototype.update=function(Vt){if(this.finalized)throw new Error(c);var Cn,un=typeof Vt;if(un!=="string"){if(un==="object"){if(Vt===null)throw new Error(t);if(ve&&Vt.constructor===ArrayBuffer)Vt=new Uint8Array(Vt);else if(!Array.isArray(Vt)&&(!ve||!ArrayBuffer.isView(Vt)))throw new Error(t)}else throw new Error(t);Cn=!0}for(var Pt=this.blocks,mn=this.byteCount,Pn=Vt.length,wn=this.blockCount,jt=0,$n=this.s,Mn,Nn;jt<Pn;){if(this.reset)for(this.reset=!1,Pt[0]=this.block,Mn=1;Mn<wn+1;++Mn)Pt[Mn]=0;if(Cn)for(Mn=this.start;jt<Pn&&Mn<mn;++jt)Pt[Mn>>2]|=Vt[jt]<<ze[Mn++&3];else for(Mn=this.start;jt<Pn&&Mn<mn;++jt)Nn=Vt.charCodeAt(jt),Nn<128?Pt[Mn>>2]|=Nn<<ze[Mn++&3]:Nn<2048?(Pt[Mn>>2]|=(192|Nn>>6)<<ze[Mn++&3],Pt[Mn>>2]|=(128|Nn&63)<<ze[Mn++&3]):Nn<55296||Nn>=57344?(Pt[Mn>>2]|=(224|Nn>>12)<<ze[Mn++&3],Pt[Mn>>2]|=(128|Nn>>6&63)<<ze[Mn++&3],Pt[Mn>>2]|=(128|Nn&63)<<ze[Mn++&3]):(Nn=65536+((Nn&1023)<<10|Vt.charCodeAt(++jt)&1023),Pt[Mn>>2]|=(240|Nn>>18)<<ze[Mn++&3],Pt[Mn>>2]|=(128|Nn>>12&63)<<ze[Mn++&3],Pt[Mn>>2]|=(128|Nn>>6&63)<<ze[Mn++&3],Pt[Mn>>2]|=(128|Nn&63)<<ze[Mn++&3]);if(this.lastByteIndex=Mn,Mn>=mn){for(this.start=Mn-mn,this.block=Pt[wn],Mn=0;Mn<wn;++Mn)$n[Mn]^=Pt[Mn];gn($n),this.reset=!0}else this.start=Mn}return this},$t.prototype.encode=function(Vt,Cn){var un=Vt&255,Pt=1,mn=[un];for(Vt=Vt>>8,un=Vt&255;un>0;)mn.unshift(un),Vt=Vt>>8,un=Vt&255,++Pt;return Cn?mn.push(Pt):mn.unshift(Pt),this.update(mn),mn.length},$t.prototype.encodeString=function(Vt){var Cn,un=typeof Vt;if(un!=="string"){if(un==="object"){if(Vt===null)throw new Error(t);if(ve&&Vt.constructor===ArrayBuffer)Vt=new Uint8Array(Vt);else if(!Array.isArray(Vt)&&(!ve||!ArrayBuffer.isView(Vt)))throw new Error(t)}else throw new Error(t);Cn=!0}var Pt=0,mn=Vt.length;if(Cn)Pt=mn;else for(var Pn=0;Pn<Vt.length;++Pn){var wn=Vt.charCodeAt(Pn);wn<128?Pt+=1:wn<2048?Pt+=2:wn<55296||wn>=57344?Pt+=3:(wn=65536+((wn&1023)<<10|Vt.charCodeAt(++Pn)&1023),Pt+=4)}return Pt+=this.encode(Pt*8),this.update(Vt),Pt},$t.prototype.bytepad=function(Vt,Cn){for(var un=this.encode(Cn),Pt=0;Pt<Vt.length;++Pt)un+=this.encodeString(Vt[Pt]);var mn=Cn-un%Cn,Pn=[];return Pn.length=mn,this.update(Pn),this},$t.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var Vt=this.blocks,Cn=this.lastByteIndex,un=this.blockCount,Pt=this.s;if(Vt[Cn>>2]|=this.padding[Cn&3],this.lastByteIndex===this.byteCount)for(Vt[0]=Vt[un],Cn=1;Cn<un+1;++Cn)Vt[Cn]=0;for(Vt[un-1]|=2147483648,Cn=0;Cn<un;++Cn)Pt[Cn]^=Vt[Cn];gn(Pt)}},$t.prototype.toString=$t.prototype.hex=function(){this.finalize();for(var Vt=this.blockCount,Cn=this.s,un=this.outputBlocks,Pt=this.extraBytes,mn=0,Pn=0,wn="",jt;Pn<un;){for(mn=0;mn<Vt&&Pn<un;++mn,++Pn)jt=Cn[mn],wn+=ge[jt>>4&15]+ge[jt&15]+ge[jt>>12&15]+ge[jt>>8&15]+ge[jt>>20&15]+ge[jt>>16&15]+ge[jt>>28&15]+ge[jt>>24&15];Pn%Vt===0&&(gn(Cn),mn=0)}return Pt&&(jt=Cn[mn],wn+=ge[jt>>4&15]+ge[jt&15],Pt>1&&(wn+=ge[jt>>12&15]+ge[jt>>8&15]),Pt>2&&(wn+=ge[jt>>20&15]+ge[jt>>16&15])),wn},$t.prototype.arrayBuffer=function(){this.finalize();var Vt=this.blockCount,Cn=this.s,un=this.outputBlocks,Pt=this.extraBytes,mn=0,Pn=0,wn=this.outputBits>>3,jt;Pt?jt=new ArrayBuffer(un+1<<2):jt=new ArrayBuffer(wn);for(var $n=new Uint32Array(jt);Pn<un;){for(mn=0;mn<Vt&&Pn<un;++mn,++Pn)$n[Pn]=Cn[mn];Pn%Vt===0&&gn(Cn)}return Pt&&($n[mn]=Cn[mn],jt=jt.slice(0,wn)),jt},$t.prototype.buffer=$t.prototype.arrayBuffer,$t.prototype.digest=$t.prototype.array=function(){this.finalize();for(var Vt=this.blockCount,Cn=this.s,un=this.outputBlocks,Pt=this.extraBytes,mn=0,Pn=0,wn=[],jt,$n;Pn<un;){for(mn=0;mn<Vt&&Pn<un;++mn,++Pn)jt=Pn<<2,$n=Cn[mn],wn[jt]=$n&255,wn[jt+1]=$n>>8&255,wn[jt+2]=$n>>16&255,wn[jt+3]=$n>>24&255;Pn%Vt===0&&gn(Cn)}return Pt&&(jt=Pn<<2,$n=Cn[mn],wn[jt]=$n&255,Pt>1&&(wn[jt+1]=$n>>8&255),Pt>2&&(wn[jt+2]=$n>>16&255)),wn};function dn(Vt,Cn,un){$t.call(this,Vt,Cn,un)}dn.prototype=new $t,dn.prototype.finalize=function(){return this.encode(this.outputBits,!0),$t.prototype.finalize.call(this)};var gn=function(Vt){var Cn,un,Pt,mn,Pn,wn,jt,$n,Mn,Nn,Zn,qn,Vn,Gn,Kn,Jn,bi,Hn,An,Ln,On,Un,ti,Fn,Gt,En,xn,In,Wn,jn,zn,Ri,Qn,li,Ci,ri,yi,Ai,ci,vi,Mi,di,wi,Ti,hi,xi,Pi,pi,Ei,Bi,mi,_i,Ii,gi,Si,ki,$i,Ni,Oi,Li,Fi,ji,Di;for(Pt=0;Pt<48;Pt+=2)mn=Vt[0]^Vt[10]^Vt[20]^Vt[30]^Vt[40],Pn=Vt[1]^Vt[11]^Vt[21]^Vt[31]^Vt[41],wn=Vt[2]^Vt[12]^Vt[22]^Vt[32]^Vt[42],jt=Vt[3]^Vt[13]^Vt[23]^Vt[33]^Vt[43],$n=Vt[4]^Vt[14]^Vt[24]^Vt[34]^Vt[44],Mn=Vt[5]^Vt[15]^Vt[25]^Vt[35]^Vt[45],Nn=Vt[6]^Vt[16]^Vt[26]^Vt[36]^Vt[46],Zn=Vt[7]^Vt[17]^Vt[27]^Vt[37]^Vt[47],qn=Vt[8]^Vt[18]^Vt[28]^Vt[38]^Vt[48],Vn=Vt[9]^Vt[19]^Vt[29]^Vt[39]^Vt[49],Cn=qn^(wn<<1|jt>>>31),un=Vn^(jt<<1|wn>>>31),Vt[0]^=Cn,Vt[1]^=un,Vt[10]^=Cn,Vt[11]^=un,Vt[20]^=Cn,Vt[21]^=un,Vt[30]^=Cn,Vt[31]^=un,Vt[40]^=Cn,Vt[41]^=un,Cn=mn^($n<<1|Mn>>>31),un=Pn^(Mn<<1|$n>>>31),Vt[2]^=Cn,Vt[3]^=un,Vt[12]^=Cn,Vt[13]^=un,Vt[22]^=Cn,Vt[23]^=un,Vt[32]^=Cn,Vt[33]^=un,Vt[42]^=Cn,Vt[43]^=un,Cn=wn^(Nn<<1|Zn>>>31),un=jt^(Zn<<1|Nn>>>31),Vt[4]^=Cn,Vt[5]^=un,Vt[14]^=Cn,Vt[15]^=un,Vt[24]^=Cn,Vt[25]^=un,Vt[34]^=Cn,Vt[35]^=un,Vt[44]^=Cn,Vt[45]^=un,Cn=$n^(qn<<1|Vn>>>31),un=Mn^(Vn<<1|qn>>>31),Vt[6]^=Cn,Vt[7]^=un,Vt[16]^=Cn,Vt[17]^=un,Vt[26]^=Cn,Vt[27]^=un,Vt[36]^=Cn,Vt[37]^=un,Vt[46]^=Cn,Vt[47]^=un,Cn=Nn^(mn<<1|Pn>>>31),un=Zn^(Pn<<1|mn>>>31),Vt[8]^=Cn,Vt[9]^=un,Vt[18]^=Cn,Vt[19]^=un,Vt[28]^=Cn,Vt[29]^=un,Vt[38]^=Cn,Vt[39]^=un,Vt[48]^=Cn,Vt[49]^=un,Gn=Vt[0],Kn=Vt[1],xi=Vt[11]<<4|Vt[10]>>>28,Pi=Vt[10]<<4|Vt[11]>>>28,In=Vt[20]<<3|Vt[21]>>>29,Wn=Vt[21]<<3|Vt[20]>>>29,Li=Vt[31]<<9|Vt[30]>>>23,Fi=Vt[30]<<9|Vt[31]>>>23,di=Vt[40]<<18|Vt[41]>>>14,wi=Vt[41]<<18|Vt[40]>>>14,li=Vt[2]<<1|Vt[3]>>>31,Ci=Vt[3]<<1|Vt[2]>>>31,Jn=Vt[13]<<12|Vt[12]>>>20,bi=Vt[12]<<12|Vt[13]>>>20,pi=Vt[22]<<10|Vt[23]>>>22,Ei=Vt[23]<<10|Vt[22]>>>22,jn=Vt[33]<<13|Vt[32]>>>19,zn=Vt[32]<<13|Vt[33]>>>19,ji=Vt[42]<<2|Vt[43]>>>30,Di=Vt[43]<<2|Vt[42]>>>30,gi=Vt[5]<<30|Vt[4]>>>2,Si=Vt[4]<<30|Vt[5]>>>2,ri=Vt[14]<<6|Vt[15]>>>26,yi=Vt[15]<<6|Vt[14]>>>26,Hn=Vt[25]<<11|Vt[24]>>>21,An=Vt[24]<<11|Vt[25]>>>21,Bi=Vt[34]<<15|Vt[35]>>>17,mi=Vt[35]<<15|Vt[34]>>>17,Ri=Vt[45]<<29|Vt[44]>>>3,Qn=Vt[44]<<29|Vt[45]>>>3,Fn=Vt[6]<<28|Vt[7]>>>4,Gt=Vt[7]<<28|Vt[6]>>>4,ki=Vt[17]<<23|Vt[16]>>>9,$i=Vt[16]<<23|Vt[17]>>>9,Ai=Vt[26]<<25|Vt[27]>>>7,ci=Vt[27]<<25|Vt[26]>>>7,Ln=Vt[36]<<21|Vt[37]>>>11,On=Vt[37]<<21|Vt[36]>>>11,_i=Vt[47]<<24|Vt[46]>>>8,Ii=Vt[46]<<24|Vt[47]>>>8,Ti=Vt[8]<<27|Vt[9]>>>5,hi=Vt[9]<<27|Vt[8]>>>5,En=Vt[18]<<20|Vt[19]>>>12,xn=Vt[19]<<20|Vt[18]>>>12,Ni=Vt[29]<<7|Vt[28]>>>25,Oi=Vt[28]<<7|Vt[29]>>>25,vi=Vt[38]<<8|Vt[39]>>>24,Mi=Vt[39]<<8|Vt[38]>>>24,Un=Vt[48]<<14|Vt[49]>>>18,ti=Vt[49]<<14|Vt[48]>>>18,Vt[0]=Gn^~Jn&Hn,Vt[1]=Kn^~bi&An,Vt[10]=Fn^~En&In,Vt[11]=Gt^~xn&Wn,Vt[20]=li^~ri&Ai,Vt[21]=Ci^~yi&ci,Vt[30]=Ti^~xi&pi,Vt[31]=hi^~Pi&Ei,Vt[40]=gi^~ki&Ni,Vt[41]=Si^~$i&Oi,Vt[2]=Jn^~Hn&Ln,Vt[3]=bi^~An&On,Vt[12]=En^~In&jn,Vt[13]=xn^~Wn&zn,Vt[22]=ri^~Ai&vi,Vt[23]=yi^~ci&Mi,Vt[32]=xi^~pi&Bi,Vt[33]=Pi^~Ei&mi,Vt[42]=ki^~Ni&Li,Vt[43]=$i^~Oi&Fi,Vt[4]=Hn^~Ln&Un,Vt[5]=An^~On&ti,Vt[14]=In^~jn&Ri,Vt[15]=Wn^~zn&Qn,Vt[24]=Ai^~vi&di,Vt[25]=ci^~Mi&wi,Vt[34]=pi^~Bi&_i,Vt[35]=Ei^~mi&Ii,Vt[44]=Ni^~Li&ji,Vt[45]=Oi^~Fi&Di,Vt[6]=Ln^~Un&Gn,Vt[7]=On^~ti&Kn,Vt[16]=jn^~Ri&Fn,Vt[17]=zn^~Qn&Gt,Vt[26]=vi^~di&li,Vt[27]=Mi^~wi&Ci,Vt[36]=Bi^~_i&Ti,Vt[37]=mi^~Ii&hi,Vt[46]=Li^~ji&gi,Vt[47]=Fi^~Di&Si,Vt[8]=Un^~Gn&Jn,Vt[9]=ti^~Kn&bi,Vt[18]=Ri^~Fn&En,Vt[19]=Qn^~Gt&xn,Vt[28]=di^~li&ri,Vt[29]=wi^~Ci&yi,Vt[38]=_i^~Ti&xi,Vt[39]=Ii^~hi&Pi,Vt[48]=ji^~gi&ki,Vt[49]=Di^~Si&$i,Vt[0]^=He[Pt],Vt[1]^=He[Pt+1]};if(de)n.exports=xe;else for(De=0;De<_e.length;++De)se[_e[De]]=xe[_e[De]]})()})(sha3$3);var sha3Exports$1=sha3$3.exports;const sha3$2=getDefaultExportFromCjs$2(sha3Exports$1);function keccak256$1(n){return"0x"+sha3$2.keccak_256(arrayify(n))}const lib_esm$h=Object.freeze(Object.defineProperty({__proto__:null,keccak256:keccak256$1},Symbol.toStringTag,{value:"Module"})),version$p="rlp/5.8.0",logger$r=new Logger(version$p);function arrayifyInteger(n){const t=[];for(;n;)t.unshift(n&255),n>>=8;return t}function unarrayifyInteger(n,t,c){let ie=0;for(let se=0;se<c;se++)ie=ie*256+n[t+se];return ie}function _encode(n){if(Array.isArray(n)){let ie=[];if(n.forEach(function(ae){ie=ie.concat(_encode(ae))}),ie.length<=55)return ie.unshift(192+ie.length),ie;const se=arrayifyInteger(ie.length);return se.unshift(247+se.length),se.concat(ie)}isBytesLike(n)||logger$r.throwArgumentError("RLP object must be BytesLike","object",n);const t=Array.prototype.slice.call(arrayify(n));if(t.length===1&&t[0]<=127)return t;if(t.length<=55)return t.unshift(128+t.length),t;const c=arrayifyInteger(t.length);return c.unshift(183+c.length),c.concat(t)}function encode$6(n){return hexlify(_encode(n))}function _decodeChildren(n,t,c,ie){const se=[];for(;c<t+1+ie;){const ae=_decode(n,c);se.push(ae.result),c+=ae.consumed,c>t+1+ie&&logger$r.throwError("child data too short",Logger.errors.BUFFER_OVERRUN,{})}return{consumed:1+ie,result:se}}function _decode(n,t){if(n.length===0&&logger$r.throwError("data too short",Logger.errors.BUFFER_OVERRUN,{}),n[t]>=248){const c=n[t]-247;t+1+c>n.length&&logger$r.throwError("data short segment too short",Logger.errors.BUFFER_OVERRUN,{});const ie=unarrayifyInteger(n,t+1,c);return t+1+c+ie>n.length&&logger$r.throwError("data long segment too short",Logger.errors.BUFFER_OVERRUN,{}),_decodeChildren(n,t,t+1+c,c+ie)}else if(n[t]>=192){const c=n[t]-192;return t+1+c>n.length&&logger$r.throwError("data array too short",Logger.errors.BUFFER_OVERRUN,{}),_decodeChildren(n,t,t+1,c)}else if(n[t]>=184){const c=n[t]-183;t+1+c>n.length&&logger$r.throwError("data array too short",Logger.errors.BUFFER_OVERRUN,{});const ie=unarrayifyInteger(n,t+1,c);t+1+c+ie>n.length&&logger$r.throwError("data array too short",Logger.errors.BUFFER_OVERRUN,{});const se=hexlify(n.slice(t+1+c,t+1+c+ie));return{consumed:1+c+ie,result:se}}else if(n[t]>=128){const c=n[t]-128;t+1+c>n.length&&logger$r.throwError("data too short",Logger.errors.BUFFER_OVERRUN,{});const ie=hexlify(n.slice(t+1,t+1+c));return{consumed:1+c,result:ie}}return{consumed:1,result:hexlify(n[t])}}function decode$7(n){const t=arrayify(n),c=_decode(t,0);return c.consumed!==t.length&&logger$r.throwArgumentError("invalid rlp data","data",n),c.result}const lib_esm$g=Object.freeze(Object.defineProperty({__proto__:null,decode:decode$7,encode:encode$6},Symbol.toStringTag,{value:"Module"})),version$o="address/5.8.0",logger$q=new Logger(version$o);function getChecksumAddress(n){isHexString(n,20)||logger$q.throwArgumentError("invalid address","address",n),n=n.toLowerCase();const t=n.substring(2).split(""),c=new Uint8Array(40);for(let se=0;se<40;se++)c[se]=t[se].charCodeAt(0);const ie=arrayify(keccak256$1(c));for(let se=0;se<40;se+=2)ie[se>>1]>>4>=8&&(t[se]=t[se].toUpperCase()),(ie[se>>1]&15)>=8&&(t[se+1]=t[se+1].toUpperCase());return"0x"+t.join("")}const MAX_SAFE_INTEGER=9007199254740991;function log10(n){return Math.log10?Math.log10(n):Math.log(n)/Math.LN10}const ibanLookup={};for(let n=0;n<10;n++)ibanLookup[String(n)]=String(n);for(let n=0;n<26;n++)ibanLookup[String.fromCharCode(65+n)]=String(10+n);const safeDigits=Math.floor(log10(MAX_SAFE_INTEGER));function ibanChecksum(n){n=n.toUpperCase(),n=n.substring(4)+n.substring(0,2)+"00";let t=n.split("").map(ie=>ibanLookup[ie]).join("");for(;t.length>=safeDigits;){let ie=t.substring(0,safeDigits);t=parseInt(ie,10)%97+t.substring(ie.length)}let c=String(98-parseInt(t,10)%97);for(;c.length<2;)c="0"+c;return c}function getAddress$1(n){let t=null;if(typeof n!="string"&&logger$q.throwArgumentError("invalid address","address",n),n.match(/^(0x)?[0-9a-fA-F]{40}$/))n.substring(0,2)!=="0x"&&(n="0x"+n),t=getChecksumAddress(n),n.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==n&&logger$q.throwArgumentError("bad address checksum","address",n);else if(n.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(n.substring(2,4)!==ibanChecksum(n)&&logger$q.throwArgumentError("bad icap checksum","address",n),t=_base36To16(n.substring(4));t.length<40;)t="0"+t;t=getChecksumAddress("0x"+t)}else logger$q.throwArgumentError("invalid address","address",n);return t}function isAddress(n){try{return getAddress$1(n),!0}catch{}return!1}function getIcapAddress(n){let t=_base16To36(getAddress$1(n).substring(2)).toUpperCase();for(;t.length<30;)t="0"+t;return"XE"+ibanChecksum("XE00"+t)+t}function getContractAddress(n){let t=null;try{t=getAddress$1(n.from)}catch{logger$q.throwArgumentError("missing from address","transaction",n)}const c=stripZeros(arrayify(BigNumber.from(n.nonce).toHexString()));return getAddress$1(hexDataSlice(keccak256$1(encode$6([t,c])),12))}function getCreate2Address(n,t,c){return hexDataLength(t)!==32&&logger$q.throwArgumentError("salt must be 32 bytes","salt",t),hexDataLength(c)!==32&&logger$q.throwArgumentError("initCodeHash must be 32 bytes","initCodeHash",c),getAddress$1(hexDataSlice(keccak256$1(concat$1(["0xff",getAddress$1(n),t,c])),12))}const lib_esm$f=Object.freeze(Object.defineProperty({__proto__:null,getAddress:getAddress$1,getContractAddress,getCreate2Address,getIcapAddress,isAddress},Symbol.toStringTag,{value:"Module"}));class AddressCoder extends Coder{constructor(t){super("address","address",t,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(t,c){try{c=getAddress$1(c)}catch(ie){this._throwError(ie.message,c)}return t.writeValue(c)}decode(t){return getAddress$1(hexZeroPad(t.readValue().toHexString(),20))}}class AnonymousCoder extends Coder{constructor(t){super(t.name,t.type,void 0,t.dynamic),this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,c){return this.coder.encode(t,c)}decode(t){return this.coder.decode(t)}}const logger$p=new Logger(version$q);function pack$1(n,t,c){let ie=null;if(Array.isArray(c))ie=c;else if(c&&typeof c=="object"){let ve={};ie=t.map(ge=>{const we=ge.localName;return we||logger$p.throwError("cannot encode object for signature with missing names",Logger.errors.INVALID_ARGUMENT,{argument:"values",coder:ge,value:c}),ve[we]&&logger$p.throwError("cannot encode object for signature with duplicate names",Logger.errors.INVALID_ARGUMENT,{argument:"values",coder:ge,value:c}),ve[we]=!0,c[we]})}else logger$p.throwArgumentError("invalid tuple value","tuple",c);t.length!==ie.length&&logger$p.throwArgumentError("types/value length mismatch","tuple",c);let se=new Writer(n.wordSize),ae=new Writer(n.wordSize),ue=[];t.forEach((ve,ge)=>{let we=ie[ge];if(ve.dynamic){let Te=ae.length;ve.encode(ae,we);let Ne=se.writeUpdatableValue();ue.push(qe=>{Ne(qe+Te)})}else ve.encode(se,we)}),ue.forEach(ve=>{ve(se.length)});let de=n.appendWriter(se);return de+=n.appendWriter(ae),de}function unpack(n,t){let c=[],ie=n.subReader(0);t.forEach(ae=>{let ue=null;if(ae.dynamic){let de=n.readValue(),ve=ie.subReader(de.toNumber());try{ue=ae.decode(ve)}catch(ge){if(ge.code===Logger.errors.BUFFER_OVERRUN)throw ge;ue=ge,ue.baseType=ae.name,ue.name=ae.localName,ue.type=ae.type}}else try{ue=ae.decode(n)}catch(de){if(de.code===Logger.errors.BUFFER_OVERRUN)throw de;ue=de,ue.baseType=ae.name,ue.name=ae.localName,ue.type=ae.type}ue!=null&&c.push(ue)});const se=t.reduce((ae,ue)=>{const de=ue.localName;return de&&(ae[de]||(ae[de]=0),ae[de]++),ae},{});t.forEach((ae,ue)=>{let de=ae.localName;if(!de||se[de]!==1||(de==="length"&&(de="_length"),c[de]!=null))return;const ve=c[ue];ve instanceof Error?Object.defineProperty(c,de,{enumerable:!0,get:()=>{throw ve}}):c[de]=ve});for(let ae=0;ae<c.length;ae++){const ue=c[ae];ue instanceof Error&&Object.defineProperty(c,ae,{enumerable:!0,get:()=>{throw ue}})}return Object.freeze(c)}class ArrayCoder extends Coder{constructor(t,c,ie){const se=t.type+"["+(c>=0?c:"")+"]",ae=c===-1||t.dynamic;super("array",se,ie,ae),this.coder=t,this.length=c}defaultValue(){const t=this.coder.defaultValue(),c=[];for(let ie=0;ie<this.length;ie++)c.push(t);return c}encode(t,c){Array.isArray(c)||this._throwError("expected array value",c);let ie=this.length;ie===-1&&(ie=c.length,t.writeValue(c.length)),logger$p.checkArgumentCount(c.length,ie,"coder array"+(this.localName?" "+this.localName:""));let se=[];for(let ae=0;ae<c.length;ae++)se.push(this.coder);return pack$1(t,se,c)}decode(t){let c=this.length;c===-1&&(c=t.readValue().toNumber(),c*32>t._data.length&&logger$p.throwError("insufficient data length",Logger.errors.BUFFER_OVERRUN,{length:t._data.length,count:c}));let ie=[];for(let se=0;se<c;se++)ie.push(new AnonymousCoder(this.coder));return t.coerce(this.name,unpack(t,ie))}}class BooleanCoder extends Coder{constructor(t){super("bool","bool",t,!1)}defaultValue(){return!1}encode(t,c){return t.writeValue(c?1:0)}decode(t){return t.coerce(this.type,!t.readValue().isZero())}}class DynamicBytesCoder extends Coder{constructor(t,c){super(t,t,c,!0)}defaultValue(){return"0x"}encode(t,c){c=arrayify(c);let ie=t.writeValue(c.length);return ie+=t.writeBytes(c),ie}decode(t){return t.readBytes(t.readValue().toNumber(),!0)}}class BytesCoder extends DynamicBytesCoder{constructor(t){super("bytes",t)}decode(t){return t.coerce(this.name,hexlify(super.decode(t)))}}class FixedBytesCoder extends Coder{constructor(t,c){let ie="bytes"+String(t);super(ie,ie,c,!1),this.size=t}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(t,c){let ie=arrayify(c);return ie.length!==this.size&&this._throwError("incorrect data length",c),t.writeBytes(ie)}decode(t){return t.coerce(this.name,hexlify(t.readBytes(this.size)))}}class NullCoder extends Coder{constructor(t){super("null","",t,!1)}defaultValue(){return null}encode(t,c){return c!=null&&this._throwError("not null",c),t.writeBytes([])}decode(t){return t.readBytes(0),t.coerce(this.name,null)}}const AddressZero="0x0000000000000000000000000000000000000000",NegativeOne$1=BigNumber.from(-1),Zero$1=BigNumber.from(0),One$1=BigNumber.from(1),MaxUint256$1=BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),HashZero="0x0000000000000000000000000000000000000000000000000000000000000000";class NumberCoder extends Coder{constructor(t,c,ie){const se=(c?"int":"uint")+t*8;super(se,se,ie,!1),this.size=t,this.signed=c}defaultValue(){return 0}encode(t,c){let ie=BigNumber.from(c),se=MaxUint256$1.mask(t.wordSize*8);if(this.signed){let ae=se.mask(this.size*8-1);(ie.gt(ae)||ie.lt(ae.add(One$1).mul(NegativeOne$1)))&&this._throwError("value out-of-bounds",c)}else(ie.lt(Zero$1)||ie.gt(se.mask(this.size*8)))&&this._throwError("value out-of-bounds",c);return ie=ie.toTwos(this.size*8).mask(this.size*8),this.signed&&(ie=ie.fromTwos(this.size*8).toTwos(8*t.wordSize)),t.writeValue(ie)}decode(t){let c=t.readValue().mask(this.size*8);return this.signed&&(c=c.fromTwos(this.size*8)),t.coerce(this.name,c)}}const version$n="strings/5.8.0",logger$o=new Logger(version$n);var UnicodeNormalizationForm;(function(n){n.current="",n.NFC="NFC",n.NFD="NFD",n.NFKC="NFKC",n.NFKD="NFKD"})(UnicodeNormalizationForm||(UnicodeNormalizationForm={}));var Utf8ErrorReason;(function(n){n.UNEXPECTED_CONTINUE="unexpected continuation byte",n.BAD_PREFIX="bad codepoint prefix",n.OVERRUN="string overrun",n.MISSING_CONTINUE="missing continuation byte",n.OUT_OF_RANGE="out of UTF-8 range",n.UTF16_SURROGATE="UTF-16 surrogate",n.OVERLONG="overlong representation"})(Utf8ErrorReason||(Utf8ErrorReason={}));function errorFunc(n,t,c,ie,se){return logger$o.throwArgumentError(`invalid codepoint at offset ${t}; ${n}`,"bytes",c)}function ignoreFunc(n,t,c,ie,se){if(n===Utf8ErrorReason.BAD_PREFIX||n===Utf8ErrorReason.UNEXPECTED_CONTINUE){let ae=0;for(let ue=t+1;ue<c.length&&c[ue]>>6===2;ue++)ae++;return ae}return n===Utf8ErrorReason.OVERRUN?c.length-t-1:0}function replaceFunc(n,t,c,ie,se){return n===Utf8ErrorReason.OVERLONG?(ie.push(se),0):(ie.push(65533),ignoreFunc(n,t,c))}const Utf8ErrorFuncs=Object.freeze({error:errorFunc,ignore:ignoreFunc,replace:replaceFunc});function getUtf8CodePoints(n,t){t==null&&(t=Utf8ErrorFuncs.error),n=arrayify(n);const c=[];let ie=0;for(;ie<n.length;){const se=n[ie++];if(!(se>>7)){c.push(se);continue}let ae=null,ue=null;if((se&224)===192)ae=1,ue=127;else if((se&240)===224)ae=2,ue=2047;else if((se&248)===240)ae=3,ue=65535;else{(se&192)===128?ie+=t(Utf8ErrorReason.UNEXPECTED_CONTINUE,ie-1,n,c):ie+=t(Utf8ErrorReason.BAD_PREFIX,ie-1,n,c);continue}if(ie-1+ae>=n.length){ie+=t(Utf8ErrorReason.OVERRUN,ie-1,n,c);continue}let de=se&(1<<8-ae-1)-1;for(let ve=0;ve<ae;ve++){let ge=n[ie];if((ge&192)!=128){ie+=t(Utf8ErrorReason.MISSING_CONTINUE,ie,n,c),de=null;break}de=de<<6|ge&63,ie++}if(de!==null){if(de>1114111){ie+=t(Utf8ErrorReason.OUT_OF_RANGE,ie-1-ae,n,c,de);continue}if(de>=55296&&de<=57343){ie+=t(Utf8ErrorReason.UTF16_SURROGATE,ie-1-ae,n,c,de);continue}if(de<=ue){ie+=t(Utf8ErrorReason.OVERLONG,ie-1-ae,n,c,de);continue}c.push(de)}}return c}function toUtf8Bytes(n,t=UnicodeNormalizationForm.current){t!=UnicodeNormalizationForm.current&&(logger$o.checkNormalize(),n=n.normalize(t));let c=[];for(let ie=0;ie<n.length;ie++){const se=n.charCodeAt(ie);if(se<128)c.push(se);else if(se<2048)c.push(se>>6|192),c.push(se&63|128);else if((se&64512)==55296){ie++;const ae=n.charCodeAt(ie);if(ie>=n.length||(ae&64512)!==56320)throw new Error("invalid utf-8 string");const ue=65536+((se&1023)<<10)+(ae&1023);c.push(ue>>18|240),c.push(ue>>12&63|128),c.push(ue>>6&63|128),c.push(ue&63|128)}else c.push(se>>12|224),c.push(se>>6&63|128),c.push(se&63|128)}return arrayify(c)}function escapeChar(n){const t="0000"+n.toString(16);return"\\u"+t.substring(t.length-4)}function _toEscapedUtf8String(n,t){return'"'+getUtf8CodePoints(n,t).map(c=>{if(c<256){switch(c){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(c>=32&&c<127)return String.fromCharCode(c)}return c<=65535?escapeChar(c):(c-=65536,escapeChar((c>>10&1023)+55296)+escapeChar((c&1023)+56320))}).join("")+'"'}function _toUtf8String(n){return n.map(t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10&1023)+55296,(t&1023)+56320))).join("")}function toUtf8String(n,t){return _toUtf8String(getUtf8CodePoints(n,t))}function toUtf8CodePoints(n,t=UnicodeNormalizationForm.current){return getUtf8CodePoints(toUtf8Bytes(n,t))}function formatBytes32String(n){const t=toUtf8Bytes(n);if(t.length>31)throw new Error("bytes32 string must be less than 32 bytes");return hexlify(concat$1([t,HashZero]).slice(0,32))}function parseBytes32String(n){const t=arrayify(n);if(t.length!==32)throw new Error("invalid bytes32 - not 32 bytes long");if(t[31]!==0)throw new Error("invalid bytes32 string - no null terminator");let c=31;for(;t[c-1]===0;)c--;return toUtf8String(t.slice(0,c))}function bytes2(n){if(n.length%4!==0)throw new Error("bad data");let t=[];for(let c=0;c<n.length;c+=4)t.push(parseInt(n.substring(c,c+4),16));return t}function createTable(n,t){t||(t=function(se){return[parseInt(se,16)]});let c=0,ie={};return n.split(",").forEach(se=>{let ae=se.split(":");c+=parseInt(ae[0],16),ie[c]=t(ae[1])}),ie}function createRangeTable(n){let t=0;return n.split(",").map(c=>{let ie=c.split("-");ie.length===1?ie[1]="0":ie[1]===""&&(ie[1]="1");let se=t+parseInt(ie[0],16);return t=parseInt(ie[1],16),{l:se,h:t}})}function matchMap(n,t){let c=0;for(let ie=0;ie<t.length;ie++){let se=t[ie];if(c+=se.l,n>=c&&n<=c+se.h&&(n-c)%(se.d||1)===0){if(se.e&&se.e.indexOf(n-c)!==-1)continue;return se}}return null}const Table_A_1_ranges=createRangeTable("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),Table_B_1_flags="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(n=>parseInt(n,16)),Table_B_2_ranges=[{h:25,s:32,l:65},{h:30,s:32,e:[23],l:127},{h:54,s:1,e:[48],l:64,d:2},{h:14,s:1,l:57,d:2},{h:44,s:1,l:17,d:2},{h:10,s:1,e:[2,6,8],l:61,d:2},{h:16,s:1,l:68,d:2},{h:84,s:1,e:[18,24,66],l:19,d:2},{h:26,s:32,e:[17],l:435},{h:22,s:1,l:71,d:2},{h:15,s:80,l:40},{h:31,s:32,l:16},{h:32,s:1,l:80,d:2},{h:52,s:1,l:42,d:2},{h:12,s:1,l:55,d:2},{h:40,s:1,e:[38],l:15,d:2},{h:14,s:1,l:48,d:2},{h:37,s:48,l:49},{h:148,s:1,l:6351,d:2},{h:88,s:1,l:160,d:2},{h:15,s:16,l:704},{h:25,s:26,l:854},{h:25,s:32,l:55915},{h:37,s:40,l:1247},{h:25,s:-119711,l:53248},{h:25,s:-119763,l:52},{h:25,s:-119815,l:52},{h:25,s:-119867,e:[1,4,5,7,8,11,12,17],l:52},{h:25,s:-119919,l:52},{h:24,s:-119971,e:[2,7,8,17],l:52},{h:24,s:-120023,e:[2,7,13,15,16,17],l:52},{h:25,s:-120075,l:52},{h:25,s:-120127,l:52},{h:25,s:-120179,l:52},{h:25,s:-120231,l:52},{h:25,s:-120283,l:52},{h:25,s:-120335,l:52},{h:24,s:-119543,e:[17],l:56},{h:24,s:-119601,e:[17],l:58},{h:24,s:-119659,e:[17],l:58},{h:24,s:-119717,e:[17],l:58},{h:24,s:-119775,e:[17],l:58}],Table_B_2_lut_abs=createTable("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),Table_B_2_lut_rel=createTable("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),Table_B_2_complex=createTable("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",bytes2),Table_C_ranges=createRangeTable("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001");function flatten$2(n){return n.reduce((t,c)=>(c.forEach(ie=>{t.push(ie)}),t),[])}function _nameprepTableA1(n){return!!matchMap(n,Table_A_1_ranges)}function _nameprepTableB2(n){let t=matchMap(n,Table_B_2_ranges);if(t)return[n+t.s];let c=Table_B_2_lut_abs[n];if(c)return c;let ie=Table_B_2_lut_rel[n];return ie?[n+ie[0]]:Table_B_2_complex[n]||null}function _nameprepTableC(n){return!!matchMap(n,Table_C_ranges)}function nameprep(n){if(n.match(/^[a-z0-9-]*$/i)&&n.length<=59)return n.toLowerCase();let t=toUtf8CodePoints(n);t=flatten$2(t.map(ie=>Table_B_1_flags.indexOf(ie)>=0?[]:ie>=65024&&ie<=65039?[]:_nameprepTableB2(ie)||[ie])),t=toUtf8CodePoints(_toUtf8String(t),UnicodeNormalizationForm.NFKC),t.forEach(ie=>{if(_nameprepTableC(ie))throw new Error("STRINGPREP_CONTAINS_PROHIBITED")}),t.forEach(ie=>{if(_nameprepTableA1(ie))throw new Error("STRINGPREP_CONTAINS_UNASSIGNED")});let c=_toUtf8String(t);if(c.substring(0,1)==="-"||c.substring(2,4)==="--"||c.substring(c.length-1)==="-")throw new Error("invalid hyphen");return c}const lib_esm$e=Object.freeze(Object.defineProperty({__proto__:null,get UnicodeNormalizationForm(){return UnicodeNormalizationForm},Utf8ErrorFuncs,get Utf8ErrorReason(){return Utf8ErrorReason},_toEscapedUtf8String,formatBytes32String,nameprep,parseBytes32String,toUtf8Bytes,toUtf8CodePoints,toUtf8String},Symbol.toStringTag,{value:"Module"}));class StringCoder extends DynamicBytesCoder{constructor(t){super("string",t)}defaultValue(){return""}encode(t,c){return super.encode(t,toUtf8Bytes(c))}decode(t){return toUtf8String(super.decode(t))}}class TupleCoder extends Coder{constructor(t,c){let ie=!1;const se=[];t.forEach(ue=>{ue.dynamic&&(ie=!0),se.push(ue.type)});const ae="tuple("+se.join(",")+")";super("tuple",ae,c,ie),this.coders=t}defaultValue(){const t=[];this.coders.forEach(ie=>{t.push(ie.defaultValue())});const c=this.coders.reduce((ie,se)=>{const ae=se.localName;return ae&&(ie[ae]||(ie[ae]=0),ie[ae]++),ie},{});return this.coders.forEach((ie,se)=>{let ae=ie.localName;!ae||c[ae]!==1||(ae==="length"&&(ae="_length"),t[ae]==null&&(t[ae]=t[se]))}),Object.freeze(t)}encode(t,c){return pack$1(t,this.coders,c)}decode(t){return t.coerce(this.name,unpack(t,this.coders))}}const logger$n=new Logger(version$q),paramTypeBytes=new RegExp(/^bytes([0-9]*)$/),paramTypeNumber=new RegExp(/^(u?int)([0-9]*)$/);class AbiCoder{constructor(t){defineReadOnly(this,"coerceFunc",t||null)}_getCoder(t){switch(t.baseType){case"address":return new AddressCoder(t.name);case"bool":return new BooleanCoder(t.name);case"string":return new StringCoder(t.name);case"bytes":return new BytesCoder(t.name);case"array":return new ArrayCoder(this._getCoder(t.arrayChildren),t.arrayLength,t.name);case"tuple":return new TupleCoder((t.components||[]).map(ie=>this._getCoder(ie)),t.name);case"":return new NullCoder(t.name)}let c=t.type.match(paramTypeNumber);if(c){let ie=parseInt(c[2]||"256");return(ie===0||ie>256||ie%8!==0)&&logger$n.throwArgumentError("invalid "+c[1]+" bit length","param",t),new NumberCoder(ie/8,c[1]==="int",t.name)}if(c=t.type.match(paramTypeBytes),c){let ie=parseInt(c[1]);return(ie===0||ie>32)&&logger$n.throwArgumentError("invalid bytes length","param",t),new FixedBytesCoder(ie,t.name)}return logger$n.throwArgumentError("invalid type","type",t.type)}_getWordSize(){return 32}_getReader(t,c){return new Reader(t,this._getWordSize(),this.coerceFunc,c)}_getWriter(){return new Writer(this._getWordSize())}getDefaultValue(t){const c=t.map(ie=>this._getCoder(ParamType.from(ie)));return new TupleCoder(c,"_").defaultValue()}encode(t,c){t.length!==c.length&&logger$n.throwError("types/values length mismatch",Logger.errors.INVALID_ARGUMENT,{count:{types:t.length,values:c.length},value:{types:t,values:c}});const ie=t.map(ue=>this._getCoder(ParamType.from(ue))),se=new TupleCoder(ie,"_"),ae=this._getWriter();return se.encode(ae,c),ae.data}decode(t,c,ie){const se=t.map(ae=>this._getCoder(ParamType.from(ae)));return new TupleCoder(se,"_").decode(this._getReader(arrayify(c),ie))}}const defaultAbiCoder=new AbiCoder;function id(n){return keccak256$1(toUtf8Bytes(n))}const version$m="hash/5.8.0";function decode$6(n){n=atob(n);const t=[];for(let c=0;c<n.length;c++)t.push(n.charCodeAt(c));return arrayify(t)}function encode$5(n){n=arrayify(n);let t="";for(let c=0;c<n.length;c++)t+=String.fromCharCode(n[c]);return btoa(t)}const lib_esm$d=Object.freeze(Object.defineProperty({__proto__:null,decode:decode$6,encode:encode$5},Symbol.toStringTag,{value:"Module"}));function flat(n,t){t==null&&(t=1);const c=[],ie=c.forEach,se=function(ae,ue){ie.call(ae,function(de){ue>0&&Array.isArray(de)?se(de,ue-1):c.push(de)})};return se(n,t),c}function fromEntries(n){const t={};for(let c=0;c<n.length;c++){const ie=n[c];t[ie[0]]=ie[1]}return t}function decode_arithmetic(n){let t=0;function c(){return n[t++]<<8|n[t++]}let ie=c(),se=1,ae=[0,1];for(let Zt=1;Zt<ie;Zt++)ae.push(se+=c());let ue=c(),de=t;t+=ue;let ve=0,ge=0;function we(){return ve==0&&(ge=ge<<8|n[t++],ve=8),ge>>--ve&1}const Te=31,Ne=Math.pow(2,Te),qe=Ne>>>1,ze=qe>>1,He=Ne-1;let Ge=0;for(let Zt=0;Zt<Te;Zt++)Ge=Ge<<1|we();let Ze=[],Ye=0,Ft=Ne;for(;;){let Zt=Math.floor(((Ge-Ye+1)*se-1)/Ft),cn=0,hn=ie;for(;hn-cn>1;){let Sn=cn+hn>>>1;Zt<ae[Sn]?hn=Sn:cn=Sn}if(cn==0)break;Ze.push(cn);let yn=Ye+Math.floor(Ft*ae[cn]/se),Ht=Ye+Math.floor(Ft*ae[cn+1]/se)-1;for(;!((yn^Ht)&qe);)Ge=Ge<<1&He|we(),yn=yn<<1&He,Ht=Ht<<1&He|1;for(;yn&~Ht&ze;)Ge=Ge&qe|Ge<<1&He>>>1|we(),yn=yn<<1^qe,Ht=(Ht^qe)<<1|qe|1;Ye=yn,Ft=1+Ht-yn}let Mt=ie-4;return Ze.map(Zt=>{switch(Zt-Mt){case 3:return Mt+65792+(n[de++]<<16|n[de++]<<8|n[de++]);case 2:return Mt+256+(n[de++]<<8|n[de++]);case 1:return Mt+n[de++];default:return Zt-1}})}function read_payload(n){let t=0;return()=>n[t++]}function read_compressed_payload(n){return read_payload(decode_arithmetic(n))}function signed(n){return n&1?~n>>1:n>>1}function read_counts(n,t){let c=Array(n);for(let ie=0;ie<n;ie++)c[ie]=1+t();return c}function read_ascending(n,t){let c=Array(n);for(let ie=0,se=-1;ie<n;ie++)c[ie]=se+=1+t();return c}function read_deltas(n,t){let c=Array(n);for(let ie=0,se=0;ie<n;ie++)c[ie]=se+=signed(t());return c}function read_member_array(n,t){let c=read_ascending(n(),n),ie=n(),se=read_ascending(ie,n),ae=read_counts(ie,n);for(let ue=0;ue<ie;ue++)for(let de=0;de<ae[ue];de++)c.push(se[ue]+de);return t?c.map(ue=>t[ue]):c}function read_mapped_map(n){let t=[];for(;;){let c=n();if(c==0)break;t.push(read_linear_table(c,n))}for(;;){let c=n()-1;if(c<0)break;t.push(read_replacement_table(c,n))}return fromEntries(flat(t))}function read_zero_terminated_array(n){let t=[];for(;;){let c=n();if(c==0)break;t.push(c)}return t}function read_transposed(n,t,c){let ie=Array(n).fill(void 0).map(()=>[]);for(let se=0;se<t;se++)read_deltas(n,c).forEach((ae,ue)=>ie[ue].push(ae));return ie}function read_linear_table(n,t){let c=1+t(),ie=t(),se=read_zero_terminated_array(t),ae=read_transposed(se.length,1+n,t);return flat(ae.map((ue,de)=>{const ve=ue[0],ge=ue.slice(1);return Array(se[de]).fill(void 0).map((we,Te)=>{let Ne=Te*ie;return[ve+Te*c,ge.map(qe=>qe+Ne)]})}))}function read_replacement_table(n,t){let c=1+t();return read_transposed(c,1+n,t).map(ie=>[ie[0],ie.slice(1)])}function read_emoji_trie(n){let t=read_member_array(n).sort((ie,se)=>ie-se);return c();function c(){let ie=[];for(;;){let ge=read_member_array(n,t);if(ge.length==0)break;ie.push({set:new Set(ge),node:c()})}ie.sort((ge,we)=>we.set.size-ge.set.size);let se=n(),ae=se%3;se=se/3|0;let ue=!!(se&1);se>>=1;let de=se==1,ve=se==2;return{branches:ie,valid:ae,fe0f:ue,save:de,check:ve}}}function getData(){return read_compressed_payload(decode$6("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA=="))}const r$2=getData(),VALID=new Set(read_member_array(r$2)),IGNORED=new Set(read_member_array(r$2)),MAPPED=read_mapped_map(r$2),EMOJI_ROOT=read_emoji_trie(r$2),HYPHEN=45,UNDERSCORE=95;function explode_cp(n){return toUtf8CodePoints(n)}function filter_fe0f(n){return n.filter(t=>t!=65039)}function ens_normalize_post_check(n){for(let t of n.split(".")){let c=explode_cp(t);try{for(let ie=c.lastIndexOf(UNDERSCORE)-1;ie>=0;ie--)if(c[ie]!==UNDERSCORE)throw new Error("underscore only allowed at start");if(c.length>=4&&c.every(ie=>ie<128)&&c[2]===HYPHEN&&c[3]===HYPHEN)throw new Error("invalid label extension")}catch(ie){throw new Error(`Invalid label "${t}": ${ie.message}`)}}return n}function ens_normalize(n){return ens_normalize_post_check(normalize$1(n,filter_fe0f))}function normalize$1(n,t){let c=explode_cp(n).reverse(),ie=[];for(;c.length;){let se=consume_emoji_reversed(c);if(se){ie.push(...t(se));continue}let ae=c.pop();if(VALID.has(ae)){ie.push(ae);continue}if(IGNORED.has(ae))continue;let ue=MAPPED[ae];if(ue){ie.push(...ue);continue}throw new Error(`Disallowed codepoint: 0x${ae.toString(16).toUpperCase()}`)}return ens_normalize_post_check(nfc(String.fromCodePoint(...ie)))}function nfc(n){return n.normalize("NFC")}function consume_emoji_reversed(n,t){var c;let ie=EMOJI_ROOT,se,ae,ue=[],de=n.length;for(;de;){let ve=n[--de];if(ie=(c=ie.branches.find(ge=>ge.set.has(ve)))===null||c===void 0?void 0:c.node,!ie)break;if(ie.save)ae=ve;else if(ie.check&&ve===ae)break;ue.push(ve),ie.fe0f&&(ue.push(65039),de>0&&n[de-1]==65039&&de--),ie.valid&&(se=ue.slice(),ie.valid==2&&se.splice(1,1),n.length=de)}return se}const logger$m=new Logger(version$m),Zeros$1=new Uint8Array(32);Zeros$1.fill(0);function checkComponent(n){if(n.length===0)throw new Error("invalid ENS name; empty component");return n}function ensNameSplit(n){const t=toUtf8Bytes(ens_normalize(n)),c=[];if(n.length===0)return c;let ie=0;for(let se=0;se<t.length;se++)t[se]===46&&(c.push(checkComponent(t.slice(ie,se))),ie=se+1);if(ie>=t.length)throw new Error("invalid ENS name; empty component");return c.push(checkComponent(t.slice(ie))),c}function ensNormalize(n){return ensNameSplit(n).map(t=>toUtf8String(t)).join(".")}function isValidName(n){try{return ensNameSplit(n).length!==0}catch{}return!1}function namehash$1(n){typeof n!="string"&&logger$m.throwArgumentError("invalid ENS name; not a string","name",n);let t=Zeros$1;const c=ensNameSplit(n);for(;c.length;)t=keccak256$1(concat$1([t,keccak256$1(c.pop())]));return hexlify(t)}function dnsEncode(n){return hexlify(concat$1(ensNameSplit(n).map(t=>{if(t.length>63)throw new Error("invalid DNS encoded entry; length exceeds 63 bytes");const c=new Uint8Array(t.length+1);return c.set(t,1),c[0]=c.length-1,c})))+"00"}const messagePrefix=`Ethereum Signed Message:
11
11
  `;function hashMessage(n){return typeof n=="string"&&(n=toUtf8Bytes(n)),keccak256$1(concat$1([toUtf8Bytes(messagePrefix),toUtf8Bytes(String(n.length)),n]))}var __awaiter$k=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$l=new Logger(version$m),padding=new Uint8Array(32);padding.fill(0);const NegativeOne=BigNumber.from(-1),Zero=BigNumber.from(0),One=BigNumber.from(1),MaxUint256=BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function hexPadRight(n){const t=arrayify(n),c=t.length%32;return c?hexConcat([t,padding.slice(c)]):hexlify(t)}const hexTrue=hexZeroPad(One.toHexString(),32),hexFalse=hexZeroPad(Zero.toHexString(),32),domainFieldTypes={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},domainFieldNames=["name","version","chainId","verifyingContract","salt"];function checkString(n){return function(t){return typeof t!="string"&&logger$l.throwArgumentError(`invalid domain value for ${JSON.stringify(n)}`,`domain.${n}`,t),t}}const domainChecks={name:checkString("name"),version:checkString("version"),chainId:function(n){try{return BigNumber.from(n).toString()}catch{}return logger$l.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",n)},verifyingContract:function(n){try{return getAddress$1(n).toLowerCase()}catch{}return logger$l.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",n)},salt:function(n){try{const t=arrayify(n);if(t.length!==32)throw new Error("bad length");return hexlify(t)}catch{}return logger$l.throwArgumentError('invalid domain value "salt"',"domain.salt",n)}};function getBaseEncoder(n){{const t=n.match(/^(u?)int(\d*)$/);if(t){const c=t[1]==="",ie=parseInt(t[2]||"256");(ie%8!==0||ie>256||t[2]&&t[2]!==String(ie))&&logger$l.throwArgumentError("invalid numeric width","type",n);const se=MaxUint256.mask(c?ie-1:ie),ae=c?se.add(One).mul(NegativeOne):Zero;return function(ue){const de=BigNumber.from(ue);return(de.lt(ae)||de.gt(se))&&logger$l.throwArgumentError(`value out-of-bounds for ${n}`,"value",ue),hexZeroPad(de.toTwos(256).toHexString(),32)}}}{const t=n.match(/^bytes(\d+)$/);if(t){const c=parseInt(t[1]);return(c===0||c>32||t[1]!==String(c))&&logger$l.throwArgumentError("invalid bytes width","type",n),function(ie){return arrayify(ie).length!==c&&logger$l.throwArgumentError(`invalid length for ${n}`,"value",ie),hexPadRight(ie)}}}switch(n){case"address":return function(t){return hexZeroPad(getAddress$1(t),32)};case"bool":return function(t){return t?hexTrue:hexFalse};case"bytes":return function(t){return keccak256$1(t)};case"string":return function(t){return id(t)}}return null}function encodeType(n,t){return`${n}(${t.map(({name:c,type:ie})=>ie+" "+c).join(",")})`}class TypedDataEncoder{constructor(t){defineReadOnly(this,"types",Object.freeze(deepCopy(t))),defineReadOnly(this,"_encoderCache",{}),defineReadOnly(this,"_types",{});const c={},ie={},se={};Object.keys(t).forEach(de=>{c[de]={},ie[de]=[],se[de]={}});for(const de in t){const ve={};t[de].forEach(ge=>{ve[ge.name]&&logger$l.throwArgumentError(`duplicate variable name ${JSON.stringify(ge.name)} in ${JSON.stringify(de)}`,"types",t),ve[ge.name]=!0;const we=ge.type.match(/^([^\x5b]*)(\x5b|$)/)[1];we===de&&logger$l.throwArgumentError(`circular type reference to ${JSON.stringify(we)}`,"types",t),!getBaseEncoder(we)&&(ie[we]||logger$l.throwArgumentError(`unknown type ${JSON.stringify(we)}`,"types",t),ie[we].push(de),c[de][we]=!0)})}const ae=Object.keys(ie).filter(de=>ie[de].length===0);ae.length===0?logger$l.throwArgumentError("missing primary type","types",t):ae.length>1&&logger$l.throwArgumentError(`ambiguous primary types or unused types: ${ae.map(de=>JSON.stringify(de)).join(", ")}`,"types",t),defineReadOnly(this,"primaryType",ae[0]);function ue(de,ve){ve[de]&&logger$l.throwArgumentError(`circular type reference to ${JSON.stringify(de)}`,"types",t),ve[de]=!0,Object.keys(c[de]).forEach(ge=>{ie[ge]&&(ue(ge,ve),Object.keys(ve).forEach(we=>{se[we][ge]=!0}))}),delete ve[de]}ue(this.primaryType,{});for(const de in se){const ve=Object.keys(se[de]);ve.sort(),this._types[de]=encodeType(de,t[de])+ve.map(ge=>encodeType(ge,t[ge])).join("")}}getEncoder(t){let c=this._encoderCache[t];return c||(c=this._encoderCache[t]=this._getEncoder(t)),c}_getEncoder(t){{const se=getBaseEncoder(t);if(se)return se}const c=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(c){const se=c[1],ae=this.getEncoder(se),ue=parseInt(c[3]);return de=>{ue>=0&&de.length!==ue&&logger$l.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",de);let ve=de.map(ae);return this._types[se]&&(ve=ve.map(keccak256$1)),keccak256$1(hexConcat(ve))}}const ie=this.types[t];if(ie){const se=id(this._types[t]);return ae=>{const ue=ie.map(({name:de,type:ve})=>{const ge=this.getEncoder(ve)(ae[de]);return this._types[ve]?keccak256$1(ge):ge});return ue.unshift(se),hexConcat(ue)}}return logger$l.throwArgumentError(`unknown type: ${t}`,"type",t)}encodeType(t){const c=this._types[t];return c||logger$l.throwArgumentError(`unknown type: ${JSON.stringify(t)}`,"name",t),c}encodeData(t,c){return this.getEncoder(t)(c)}hashStruct(t,c){return keccak256$1(this.encodeData(t,c))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,c,ie){if(getBaseEncoder(t))return ie(t,c);const se=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(se){const ue=se[1],de=parseInt(se[3]);return de>=0&&c.length!==de&&logger$l.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",c),c.map(ve=>this._visit(ue,ve,ie))}const ae=this.types[t];return ae?ae.reduce((ue,{name:de,type:ve})=>(ue[de]=this._visit(ve,c[de],ie),ue),{}):logger$l.throwArgumentError(`unknown type: ${t}`,"type",t)}visit(t,c){return this._visit(this.primaryType,t,c)}static from(t){return new TypedDataEncoder(t)}static getPrimaryType(t){return TypedDataEncoder.from(t).primaryType}static hashStruct(t,c,ie){return TypedDataEncoder.from(c).hashStruct(t,ie)}static hashDomain(t){const c=[];for(const ie in t){const se=domainFieldTypes[ie];se||logger$l.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(ie)}`,"domain",t),c.push({name:ie,type:se})}return c.sort((ie,se)=>domainFieldNames.indexOf(ie.name)-domainFieldNames.indexOf(se.name)),TypedDataEncoder.hashStruct("EIP712Domain",{EIP712Domain:c},t)}static encode(t,c,ie){return hexConcat(["0x1901",TypedDataEncoder.hashDomain(t),TypedDataEncoder.from(c).hash(ie)])}static hash(t,c,ie){return keccak256$1(TypedDataEncoder.encode(t,c,ie))}static resolveNames(t,c,ie,se){return __awaiter$k(this,void 0,void 0,function*(){t=shallowCopy(t);const ae={};t.verifyingContract&&!isHexString(t.verifyingContract,20)&&(ae[t.verifyingContract]="0x");const ue=TypedDataEncoder.from(c);ue.visit(ie,(de,ve)=>(de==="address"&&!isHexString(ve,20)&&(ae[ve]="0x"),ve));for(const de in ae)ae[de]=yield se(de);return t.verifyingContract&&ae[t.verifyingContract]&&(t.verifyingContract=ae[t.verifyingContract]),ie=ue.visit(ie,(de,ve)=>de==="address"&&ae[ve]?ae[ve]:ve),{domain:t,value:ie}})}static getPayload(t,c,ie){TypedDataEncoder.hashDomain(t);const se={},ae=[];domainFieldNames.forEach(ve=>{const ge=t[ve];ge!=null&&(se[ve]=domainChecks[ve](ge),ae.push({name:ve,type:domainFieldTypes[ve]}))});const ue=TypedDataEncoder.from(c),de=shallowCopy(c);return de.EIP712Domain?logger$l.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",c):de.EIP712Domain=ae,ue.encode(ie),{types:de,domain:se,primaryType:ue.primaryType,message:ue.visit(ie,(ve,ge)=>{if(ve.match(/^bytes(\d*)/))return hexlify(arrayify(ge));if(ve.match(/^u?int/))return BigNumber.from(ge).toString();switch(ve){case"address":return ge.toLowerCase();case"bool":return!!ge;case"string":return typeof ge!="string"&&logger$l.throwArgumentError("invalid string","value",ge),ge}return logger$l.throwArgumentError("unsupported type","type",ve)})}}}const lib_esm$c=Object.freeze(Object.defineProperty({__proto__:null,_TypedDataEncoder:TypedDataEncoder,dnsEncode,ensNormalize,hashMessage,id,isValidName,messagePrefix,namehash:namehash$1},Symbol.toStringTag,{value:"Module"})),logger$k=new Logger(version$q);class LogDescription extends Description{}class TransactionDescription extends Description{}class ErrorDescription extends Description{}class Indexed extends Description{static isIndexed(t){return!!(t&&t._isIndexed)}}const BuiltinErrors={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:!0},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"]}};function wrapAccessError(n,t){const c=new Error(`deferred error during ABI decoding triggered accessing ${n}`);return c.error=t,c}class Interface{constructor(t){let c=[];typeof t=="string"?c=JSON.parse(t):c=t,defineReadOnly(this,"fragments",c.map(ie=>Fragment.from(ie)).filter(ie=>ie!=null)),defineReadOnly(this,"_abiCoder",getStatic(new.target,"getAbiCoder")()),defineReadOnly(this,"functions",{}),defineReadOnly(this,"errors",{}),defineReadOnly(this,"events",{}),defineReadOnly(this,"structs",{}),this.fragments.forEach(ie=>{let se=null;switch(ie.type){case"constructor":if(this.deploy){logger$k.warn("duplicate definition - constructor");return}defineReadOnly(this,"deploy",ie);return;case"function":se=this.functions;break;case"event":se=this.events;break;case"error":se=this.errors;break;default:return}let ae=ie.format();if(se[ae]){logger$k.warn("duplicate definition - "+ae);return}se[ae]=ie}),this.deploy||defineReadOnly(this,"deploy",ConstructorFragment.from({payable:!1,type:"constructor"})),defineReadOnly(this,"_isInterface",!0)}format(t){t||(t=FormatTypes.full),t===FormatTypes.sighash&&logger$k.throwArgumentError("interface does not support formatting sighash","format",t);const c=this.fragments.map(ie=>ie.format(t));return t===FormatTypes.json?JSON.stringify(c.map(ie=>JSON.parse(ie))):c}static getAbiCoder(){return defaultAbiCoder}static getAddress(t){return getAddress$1(t)}static getSighash(t){return hexDataSlice(id(t.format()),0,4)}static getEventTopic(t){return id(t.format())}getFunction(t){if(isHexString(t)){for(const ie in this.functions)if(t===this.getSighash(ie))return this.functions[ie];logger$k.throwArgumentError("no matching function","sighash",t)}if(t.indexOf("(")===-1){const ie=t.trim(),se=Object.keys(this.functions).filter(ae=>ae.split("(")[0]===ie);return se.length===0?logger$k.throwArgumentError("no matching function","name",ie):se.length>1&&logger$k.throwArgumentError("multiple matching functions","name",ie),this.functions[se[0]]}const c=this.functions[FunctionFragment.fromString(t).format()];return c||logger$k.throwArgumentError("no matching function","signature",t),c}getEvent(t){if(isHexString(t)){const ie=t.toLowerCase();for(const se in this.events)if(ie===this.getEventTopic(se))return this.events[se];logger$k.throwArgumentError("no matching event","topichash",ie)}if(t.indexOf("(")===-1){const ie=t.trim(),se=Object.keys(this.events).filter(ae=>ae.split("(")[0]===ie);return se.length===0?logger$k.throwArgumentError("no matching event","name",ie):se.length>1&&logger$k.throwArgumentError("multiple matching events","name",ie),this.events[se[0]]}const c=this.events[EventFragment.fromString(t).format()];return c||logger$k.throwArgumentError("no matching event","signature",t),c}getError(t){if(isHexString(t)){const ie=getStatic(this.constructor,"getSighash");for(const se in this.errors){const ae=this.errors[se];if(t===ie(ae))return this.errors[se]}logger$k.throwArgumentError("no matching error","sighash",t)}if(t.indexOf("(")===-1){const ie=t.trim(),se=Object.keys(this.errors).filter(ae=>ae.split("(")[0]===ie);return se.length===0?logger$k.throwArgumentError("no matching error","name",ie):se.length>1&&logger$k.throwArgumentError("multiple matching errors","name",ie),this.errors[se[0]]}const c=this.errors[FunctionFragment.fromString(t).format()];return c||logger$k.throwArgumentError("no matching error","signature",t),c}getSighash(t){if(typeof t=="string")try{t=this.getFunction(t)}catch(c){try{t=this.getError(t)}catch{throw c}}return getStatic(this.constructor,"getSighash")(t)}getEventTopic(t){return typeof t=="string"&&(t=this.getEvent(t)),getStatic(this.constructor,"getEventTopic")(t)}_decodeParams(t,c){return this._abiCoder.decode(t,c)}_encodeParams(t,c){return this._abiCoder.encode(t,c)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}decodeErrorResult(t,c){typeof t=="string"&&(t=this.getError(t));const ie=arrayify(c);return hexlify(ie.slice(0,4))!==this.getSighash(t)&&logger$k.throwArgumentError(`data signature does not match error ${t.name}.`,"data",hexlify(ie)),this._decodeParams(t.inputs,ie.slice(4))}encodeErrorResult(t,c){return typeof t=="string"&&(t=this.getError(t)),hexlify(concat$1([this.getSighash(t),this._encodeParams(t.inputs,c||[])]))}decodeFunctionData(t,c){typeof t=="string"&&(t=this.getFunction(t));const ie=arrayify(c);return hexlify(ie.slice(0,4))!==this.getSighash(t)&&logger$k.throwArgumentError(`data signature does not match function ${t.name}.`,"data",hexlify(ie)),this._decodeParams(t.inputs,ie.slice(4))}encodeFunctionData(t,c){return typeof t=="string"&&(t=this.getFunction(t)),hexlify(concat$1([this.getSighash(t),this._encodeParams(t.inputs,c||[])]))}decodeFunctionResult(t,c){typeof t=="string"&&(t=this.getFunction(t));let ie=arrayify(c),se=null,ae="",ue=null,de=null,ve=null;switch(ie.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(t.outputs,ie)}catch{}break;case 4:{const ge=hexlify(ie.slice(0,4)),we=BuiltinErrors[ge];if(we)ue=this._abiCoder.decode(we.inputs,ie.slice(4)),de=we.name,ve=we.signature,we.reason&&(se=ue[0]),de==="Error"?ae=`; VM Exception while processing transaction: reverted with reason string ${JSON.stringify(ue[0])}`:de==="Panic"&&(ae=`; VM Exception while processing transaction: reverted with panic code ${ue[0]}`);else try{const Te=this.getError(ge);ue=this._abiCoder.decode(Te.inputs,ie.slice(4)),de=Te.name,ve=Te.format()}catch{}break}}return logger$k.throwError("call revert exception"+ae,Logger.errors.CALL_EXCEPTION,{method:t.format(),data:hexlify(c),errorArgs:ue,errorName:de,errorSignature:ve,reason:se})}encodeFunctionResult(t,c){return typeof t=="string"&&(t=this.getFunction(t)),hexlify(this._abiCoder.encode(t.outputs,c||[]))}encodeFilterTopics(t,c){typeof t=="string"&&(t=this.getEvent(t)),c.length>t.inputs.length&&logger$k.throwError("too many arguments for "+t.format(),Logger.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:c});let ie=[];t.anonymous||ie.push(this.getEventTopic(t));const se=(ae,ue)=>ae.type==="string"?id(ue):ae.type==="bytes"?keccak256$1(hexlify(ue)):(ae.type==="bool"&&typeof ue=="boolean"&&(ue=ue?"0x01":"0x00"),ae.type.match(/^u?int/)&&(ue=BigNumber.from(ue).toHexString()),ae.type==="address"&&this._abiCoder.encode(["address"],[ue]),hexZeroPad(hexlify(ue),32));for(c.forEach((ae,ue)=>{let de=t.inputs[ue];if(!de.indexed){ae!=null&&logger$k.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+de.name,ae);return}ae==null?ie.push(null):de.baseType==="array"||de.baseType==="tuple"?logger$k.throwArgumentError("filtering with tuples or arrays not supported","contract."+de.name,ae):Array.isArray(ae)?ie.push(ae.map(ve=>se(de,ve))):ie.push(se(de,ae))});ie.length&&ie[ie.length-1]===null;)ie.pop();return ie}encodeEventLog(t,c){typeof t=="string"&&(t=this.getEvent(t));const ie=[],se=[],ae=[];return t.anonymous||ie.push(this.getEventTopic(t)),c.length!==t.inputs.length&&logger$k.throwArgumentError("event arguments/values mismatch","values",c),t.inputs.forEach((ue,de)=>{const ve=c[de];if(ue.indexed)if(ue.type==="string")ie.push(id(ve));else if(ue.type==="bytes")ie.push(keccak256$1(ve));else{if(ue.baseType==="tuple"||ue.baseType==="array")throw new Error("not implemented");ie.push(this._abiCoder.encode([ue.type],[ve]))}else se.push(ue),ae.push(ve)}),{data:this._abiCoder.encode(se,ae),topics:ie}}decodeEventLog(t,c,ie){if(typeof t=="string"&&(t=this.getEvent(t)),ie!=null&&!t.anonymous){let Ne=this.getEventTopic(t);(!isHexString(ie[0],32)||ie[0].toLowerCase()!==Ne)&&logger$k.throwError("fragment/topic mismatch",Logger.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:Ne,value:ie[0]}),ie=ie.slice(1)}let se=[],ae=[],ue=[];t.inputs.forEach((Ne,qe)=>{Ne.indexed?Ne.type==="string"||Ne.type==="bytes"||Ne.baseType==="tuple"||Ne.baseType==="array"?(se.push(ParamType.fromObject({type:"bytes32",name:Ne.name})),ue.push(!0)):(se.push(Ne),ue.push(!1)):(ae.push(Ne),ue.push(!1))});let de=ie!=null?this._abiCoder.decode(se,concat$1(ie)):null,ve=this._abiCoder.decode(ae,c,!0),ge=[],we=0,Te=0;t.inputs.forEach((Ne,qe)=>{if(Ne.indexed)if(de==null)ge[qe]=new Indexed({_isIndexed:!0,hash:null});else if(ue[qe])ge[qe]=new Indexed({_isIndexed:!0,hash:de[Te++]});else try{ge[qe]=de[Te++]}catch(ze){ge[qe]=ze}else try{ge[qe]=ve[we++]}catch(ze){ge[qe]=ze}if(Ne.name&&ge[Ne.name]==null){const ze=ge[qe];ze instanceof Error?Object.defineProperty(ge,Ne.name,{enumerable:!0,get:()=>{throw wrapAccessError(`property ${JSON.stringify(Ne.name)}`,ze)}}):ge[Ne.name]=ze}});for(let Ne=0;Ne<ge.length;Ne++){const qe=ge[Ne];qe instanceof Error&&Object.defineProperty(ge,Ne,{enumerable:!0,get:()=>{throw wrapAccessError(`index ${Ne}`,qe)}})}return Object.freeze(ge)}parseTransaction(t){let c=this.getFunction(t.data.substring(0,10).toLowerCase());return c?new TransactionDescription({args:this._abiCoder.decode(c.inputs,"0x"+t.data.substring(10)),functionFragment:c,name:c.name,signature:c.format(),sighash:this.getSighash(c),value:BigNumber.from(t.value||"0")}):null}parseLog(t){let c=this.getEvent(t.topics[0]);return!c||c.anonymous?null:new LogDescription({eventFragment:c,name:c.name,signature:c.format(),topic:this.getEventTopic(c),args:this.decodeEventLog(c,t.data,t.topics)})}parseError(t){const c=hexlify(t);let ie=this.getError(c.substring(0,10).toLowerCase());return ie?new ErrorDescription({args:this._abiCoder.decode(ie.inputs,"0x"+c.substring(10)),errorFragment:ie,name:ie.name,signature:ie.format(),sighash:this.getSighash(ie)}):null}static isInterface(t){return!!(t&&t._isInterface)}}const lib_esm$b=Object.freeze(Object.defineProperty({__proto__:null,AbiCoder,ConstructorFragment,ErrorFragment,EventFragment,FormatTypes,Fragment,FunctionFragment,Indexed,Interface,LogDescription,ParamType,TransactionDescription,checkResultErrors,defaultAbiCoder},Symbol.toStringTag,{value:"Module"})),version$l="abstract-provider/5.8.0";var __awaiter$j=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$j=new Logger(version$l);class ForkEvent extends Description{static isForkEvent(t){return!!(t&&t._isForkEvent)}}class Provider{constructor(){logger$j.checkAbstract(new.target,Provider),defineReadOnly(this,"_isProvider",!0)}getFeeData(){return __awaiter$j(this,void 0,void 0,function*(){const{block:t,gasPrice:c}=yield resolveProperties({block:this.getBlock("latest"),gasPrice:this.getGasPrice().catch(ue=>null)});let ie=null,se=null,ae=null;return t&&t.baseFeePerGas&&(ie=t.baseFeePerGas,ae=BigNumber.from("1500000000"),se=t.baseFeePerGas.mul(2).add(ae)),{lastBaseFeePerGas:ie,maxFeePerGas:se,maxPriorityFeePerGas:ae,gasPrice:c}})}addListener(t,c){return this.on(t,c)}removeListener(t,c){return this.off(t,c)}static isProvider(t){return!!(t&&t._isProvider)}}const version$k="abstract-signer/5.8.0";var __awaiter$i=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$i=new Logger(version$k),allowedTransactionKeys$2=["accessList","ccipReadEnabled","chainId","customData","data","from","gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","nonce","to","type","value"],forwardErrors=[Logger.errors.INSUFFICIENT_FUNDS,Logger.errors.NONCE_EXPIRED,Logger.errors.REPLACEMENT_UNDERPRICED];class Signer{constructor(){logger$i.checkAbstract(new.target,Signer),defineReadOnly(this,"_isSigner",!0)}getBalance(t){return __awaiter$i(this,void 0,void 0,function*(){return this._checkProvider("getBalance"),yield this.provider.getBalance(this.getAddress(),t)})}getTransactionCount(t){return __awaiter$i(this,void 0,void 0,function*(){return this._checkProvider("getTransactionCount"),yield this.provider.getTransactionCount(this.getAddress(),t)})}estimateGas(t){return __awaiter$i(this,void 0,void 0,function*(){this._checkProvider("estimateGas");const c=yield resolveProperties(this.checkTransaction(t));return yield this.provider.estimateGas(c)})}call(t,c){return __awaiter$i(this,void 0,void 0,function*(){this._checkProvider("call");const ie=yield resolveProperties(this.checkTransaction(t));return yield this.provider.call(ie,c)})}sendTransaction(t){return __awaiter$i(this,void 0,void 0,function*(){this._checkProvider("sendTransaction");const c=yield this.populateTransaction(t),ie=yield this.signTransaction(c);return yield this.provider.sendTransaction(ie)})}getChainId(){return __awaiter$i(this,void 0,void 0,function*(){return this._checkProvider("getChainId"),(yield this.provider.getNetwork()).chainId})}getGasPrice(){return __awaiter$i(this,void 0,void 0,function*(){return this._checkProvider("getGasPrice"),yield this.provider.getGasPrice()})}getFeeData(){return __awaiter$i(this,void 0,void 0,function*(){return this._checkProvider("getFeeData"),yield this.provider.getFeeData()})}resolveName(t){return __awaiter$i(this,void 0,void 0,function*(){return this._checkProvider("resolveName"),yield this.provider.resolveName(t)})}checkTransaction(t){for(const ie in t)allowedTransactionKeys$2.indexOf(ie)===-1&&logger$i.throwArgumentError("invalid transaction key: "+ie,"transaction",t);const c=shallowCopy(t);return c.from==null?c.from=this.getAddress():c.from=Promise.all([Promise.resolve(c.from),this.getAddress()]).then(ie=>(ie[0].toLowerCase()!==ie[1].toLowerCase()&&logger$i.throwArgumentError("from address mismatch","transaction",t),ie[0])),c}populateTransaction(t){return __awaiter$i(this,void 0,void 0,function*(){const c=yield resolveProperties(this.checkTransaction(t));c.to!=null&&(c.to=Promise.resolve(c.to).then(se=>__awaiter$i(this,void 0,void 0,function*(){if(se==null)return null;const ae=yield this.resolveName(se);return ae==null&&logger$i.throwArgumentError("provided ENS name resolves to null","tx.to",se),ae})),c.to.catch(se=>{}));const ie=c.maxFeePerGas!=null||c.maxPriorityFeePerGas!=null;if(c.gasPrice!=null&&(c.type===2||ie)?logger$i.throwArgumentError("eip-1559 transaction do not support gasPrice","transaction",t):(c.type===0||c.type===1)&&ie&&logger$i.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","transaction",t),(c.type===2||c.type==null)&&c.maxFeePerGas!=null&&c.maxPriorityFeePerGas!=null)c.type=2;else if(c.type===0||c.type===1)c.gasPrice==null&&(c.gasPrice=this.getGasPrice());else{const se=yield this.getFeeData();if(c.type==null)if(se.maxFeePerGas!=null&&se.maxPriorityFeePerGas!=null)if(c.type=2,c.gasPrice!=null){const ae=c.gasPrice;delete c.gasPrice,c.maxFeePerGas=ae,c.maxPriorityFeePerGas=ae}else c.maxFeePerGas==null&&(c.maxFeePerGas=se.maxFeePerGas),c.maxPriorityFeePerGas==null&&(c.maxPriorityFeePerGas=se.maxPriorityFeePerGas);else se.gasPrice!=null?(ie&&logger$i.throwError("network does not support EIP-1559",Logger.errors.UNSUPPORTED_OPERATION,{operation:"populateTransaction"}),c.gasPrice==null&&(c.gasPrice=se.gasPrice),c.type=0):logger$i.throwError("failed to get consistent fee data",Logger.errors.UNSUPPORTED_OPERATION,{operation:"signer.getFeeData"});else c.type===2&&(c.maxFeePerGas==null&&(c.maxFeePerGas=se.maxFeePerGas),c.maxPriorityFeePerGas==null&&(c.maxPriorityFeePerGas=se.maxPriorityFeePerGas))}return c.nonce==null&&(c.nonce=this.getTransactionCount("pending")),c.gasLimit==null&&(c.gasLimit=this.estimateGas(c).catch(se=>{if(forwardErrors.indexOf(se.code)>=0)throw se;return logger$i.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",Logger.errors.UNPREDICTABLE_GAS_LIMIT,{error:se,tx:c})})),c.chainId==null?c.chainId=this.getChainId():c.chainId=Promise.all([Promise.resolve(c.chainId),this.getChainId()]).then(se=>(se[1]!==0&&se[0]!==se[1]&&logger$i.throwArgumentError("chainId address mismatch","transaction",t),se[0])),yield resolveProperties(c)})}_checkProvider(t){this.provider||logger$i.throwError("missing provider",Logger.errors.UNSUPPORTED_OPERATION,{operation:t||"_checkProvider"})}static isSigner(t){return!!(t&&t._isSigner)}}class VoidSigner extends Signer{constructor(t,c){super(),defineReadOnly(this,"address",t),defineReadOnly(this,"provider",c||null)}getAddress(){return Promise.resolve(this.address)}_fail(t,c){return Promise.resolve().then(()=>{logger$i.throwError(t,Logger.errors.UNSUPPORTED_OPERATION,{operation:c})})}signMessage(t){return this._fail("VoidSigner cannot sign messages","signMessage")}signTransaction(t){return this._fail("VoidSigner cannot sign transactions","signTransaction")}_signTypedData(t,c,ie){return this._fail("VoidSigner cannot sign typed data","signTypedData")}connect(t){return new VoidSigner(this.address,t)}}var hash$4={},utils$o={},minimalisticAssert$1=assert$h;function assert$h(n,t){if(!n)throw new Error(t||"Assertion failed")}assert$h.equal=function(n,t,c){if(n!=t)throw new Error(c||"Assertion failed: "+n+" != "+t)};var inherits_browser$1={exports:{}};typeof Object.create=="function"?inherits_browser$1.exports=function(n,t){t&&(n.super_=t,n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}))}:inherits_browser$1.exports=function(n,t){if(t){n.super_=t;var c=function(){};c.prototype=t.prototype,n.prototype=new c,n.prototype.constructor=n}};var inherits_browserExports=inherits_browser$1.exports,assert$g=minimalisticAssert$1,inherits$3=inherits_browserExports;utils$o.inherits=inherits$3;function isSurrogatePair(n,t){return(n.charCodeAt(t)&64512)!==55296||t<0||t+1>=n.length?!1:(n.charCodeAt(t+1)&64512)===56320}function toArray$3(n,t){if(Array.isArray(n))return n.slice();if(!n)return[];var c=[];if(typeof n=="string")if(t){if(t==="hex")for(n=n.replace(/[^a-z0-9]+/ig,""),n.length%2!==0&&(n="0"+n),se=0;se<n.length;se+=2)c.push(parseInt(n[se]+n[se+1],16))}else for(var ie=0,se=0;se<n.length;se++){var ae=n.charCodeAt(se);ae<128?c[ie++]=ae:ae<2048?(c[ie++]=ae>>6|192,c[ie++]=ae&63|128):isSurrogatePair(n,se)?(ae=65536+((ae&1023)<<10)+(n.charCodeAt(++se)&1023),c[ie++]=ae>>18|240,c[ie++]=ae>>12&63|128,c[ie++]=ae>>6&63|128,c[ie++]=ae&63|128):(c[ie++]=ae>>12|224,c[ie++]=ae>>6&63|128,c[ie++]=ae&63|128)}else for(se=0;se<n.length;se++)c[se]=n[se]|0;return c}utils$o.toArray=toArray$3;function toHex$1(n){for(var t="",c=0;c<n.length;c++)t+=zero2(n[c].toString(16));return t}utils$o.toHex=toHex$1;function htonl(n){var t=n>>>24|n>>>8&65280|n<<8&16711680|(n&255)<<24;return t>>>0}utils$o.htonl=htonl;function toHex32(n,t){for(var c="",ie=0;ie<n.length;ie++){var se=n[ie];t==="little"&&(se=htonl(se)),c+=zero8(se.toString(16))}return c}utils$o.toHex32=toHex32;function zero2(n){return n.length===1?"0"+n:n}utils$o.zero2=zero2;function zero8(n){return n.length===7?"0"+n:n.length===6?"00"+n:n.length===5?"000"+n:n.length===4?"0000"+n:n.length===3?"00000"+n:n.length===2?"000000"+n:n.length===1?"0000000"+n:n}utils$o.zero8=zero8;function join32(n,t,c,ie){var se=c-t;assert$g(se%4===0);for(var ae=new Array(se/4),ue=0,de=t;ue<ae.length;ue++,de+=4){var ve;ie==="big"?ve=n[de]<<24|n[de+1]<<16|n[de+2]<<8|n[de+3]:ve=n[de+3]<<24|n[de+2]<<16|n[de+1]<<8|n[de],ae[ue]=ve>>>0}return ae}utils$o.join32=join32;function split32(n,t){for(var c=new Array(n.length*4),ie=0,se=0;ie<n.length;ie++,se+=4){var ae=n[ie];t==="big"?(c[se]=ae>>>24,c[se+1]=ae>>>16&255,c[se+2]=ae>>>8&255,c[se+3]=ae&255):(c[se+3]=ae>>>24,c[se+2]=ae>>>16&255,c[se+1]=ae>>>8&255,c[se]=ae&255)}return c}utils$o.split32=split32;function rotr32$1(n,t){return n>>>t|n<<32-t}utils$o.rotr32=rotr32$1;function rotl32$2(n,t){return n<<t|n>>>32-t}utils$o.rotl32=rotl32$2;function sum32$3(n,t){return n+t>>>0}utils$o.sum32=sum32$3;function sum32_3$1(n,t,c){return n+t+c>>>0}utils$o.sum32_3=sum32_3$1;function sum32_4$2(n,t,c,ie){return n+t+c+ie>>>0}utils$o.sum32_4=sum32_4$2;function sum32_5$2(n,t,c,ie,se){return n+t+c+ie+se>>>0}utils$o.sum32_5=sum32_5$2;function sum64$1(n,t,c,ie){var se=n[t],ae=n[t+1],ue=ie+ae>>>0,de=(ue<ie?1:0)+c+se;n[t]=de>>>0,n[t+1]=ue}utils$o.sum64=sum64$1;function sum64_hi$1(n,t,c,ie){var se=t+ie>>>0,ae=(se<t?1:0)+n+c;return ae>>>0}utils$o.sum64_hi=sum64_hi$1;function sum64_lo$1(n,t,c,ie){var se=t+ie;return se>>>0}utils$o.sum64_lo=sum64_lo$1;function sum64_4_hi$1(n,t,c,ie,se,ae,ue,de){var ve=0,ge=t;ge=ge+ie>>>0,ve+=ge<t?1:0,ge=ge+ae>>>0,ve+=ge<ae?1:0,ge=ge+de>>>0,ve+=ge<de?1:0;var we=n+c+se+ue+ve;return we>>>0}utils$o.sum64_4_hi=sum64_4_hi$1;function sum64_4_lo$1(n,t,c,ie,se,ae,ue,de){var ve=t+ie+ae+de;return ve>>>0}utils$o.sum64_4_lo=sum64_4_lo$1;function sum64_5_hi$1(n,t,c,ie,se,ae,ue,de,ve,ge){var we=0,Te=t;Te=Te+ie>>>0,we+=Te<t?1:0,Te=Te+ae>>>0,we+=Te<ae?1:0,Te=Te+de>>>0,we+=Te<de?1:0,Te=Te+ge>>>0,we+=Te<ge?1:0;var Ne=n+c+se+ue+ve+we;return Ne>>>0}utils$o.sum64_5_hi=sum64_5_hi$1;function sum64_5_lo$1(n,t,c,ie,se,ae,ue,de,ve,ge){var we=t+ie+ae+de+ge;return we>>>0}utils$o.sum64_5_lo=sum64_5_lo$1;function rotr64_hi$1(n,t,c){var ie=t<<32-c|n>>>c;return ie>>>0}utils$o.rotr64_hi=rotr64_hi$1;function rotr64_lo$1(n,t,c){var ie=n<<32-c|t>>>c;return ie>>>0}utils$o.rotr64_lo=rotr64_lo$1;function shr64_hi$1(n,t,c){return n>>>c}utils$o.shr64_hi=shr64_hi$1;function shr64_lo$1(n,t,c){var ie=n<<32-c|t>>>c;return ie>>>0}utils$o.shr64_lo=shr64_lo$1;var common$5={},utils$n=utils$o,assert$f=minimalisticAssert$1;function BlockHash$4(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}common$5.BlockHash=BlockHash$4;BlockHash$4.prototype.update=function(n,t){if(n=utils$n.toArray(n,t),this.pending?this.pending=this.pending.concat(n):this.pending=n,this.pendingTotal+=n.length,this.pending.length>=this._delta8){n=this.pending;var c=n.length%this._delta8;this.pending=n.slice(n.length-c,n.length),this.pending.length===0&&(this.pending=null),n=utils$n.join32(n,0,n.length-c,this.endian);for(var ie=0;ie<n.length;ie+=this._delta32)this._update(n,ie,ie+this._delta32)}return this};BlockHash$4.prototype.digest=function(n){return this.update(this._pad()),assert$f(this.pending===null),this._digest(n)};BlockHash$4.prototype._pad=function(){var n=this.pendingTotal,t=this._delta8,c=t-(n+this.padLength)%t,ie=new Array(c+this.padLength);ie[0]=128;for(var se=1;se<c;se++)ie[se]=0;if(n<<=3,this.endian==="big"){for(var ae=8;ae<this.padLength;ae++)ie[se++]=0;ie[se++]=0,ie[se++]=0,ie[se++]=0,ie[se++]=0,ie[se++]=n>>>24&255,ie[se++]=n>>>16&255,ie[se++]=n>>>8&255,ie[se++]=n&255}else for(ie[se++]=n&255,ie[se++]=n>>>8&255,ie[se++]=n>>>16&255,ie[se++]=n>>>24&255,ie[se++]=0,ie[se++]=0,ie[se++]=0,ie[se++]=0,ae=8;ae<this.padLength;ae++)ie[se++]=0;return ie};var sha$1={},common$4={},utils$m=utils$o,rotr32=utils$m.rotr32;function ft_1$1(n,t,c,ie){if(n===0)return ch32$1(t,c,ie);if(n===1||n===3)return p32(t,c,ie);if(n===2)return maj32$1(t,c,ie)}common$4.ft_1=ft_1$1;function ch32$1(n,t,c){return n&t^~n&c}common$4.ch32=ch32$1;function maj32$1(n,t,c){return n&t^n&c^t&c}common$4.maj32=maj32$1;function p32(n,t,c){return n^t^c}common$4.p32=p32;function s0_256$1(n){return rotr32(n,2)^rotr32(n,13)^rotr32(n,22)}common$4.s0_256=s0_256$1;function s1_256$1(n){return rotr32(n,6)^rotr32(n,11)^rotr32(n,25)}common$4.s1_256=s1_256$1;function g0_256$1(n){return rotr32(n,7)^rotr32(n,18)^n>>>3}common$4.g0_256=g0_256$1;function g1_256$1(n){return rotr32(n,17)^rotr32(n,19)^n>>>10}common$4.g1_256=g1_256$1;var utils$l=utils$o,common$3=common$5,shaCommon$1=common$4,rotl32$1=utils$l.rotl32,sum32$2=utils$l.sum32,sum32_5$1=utils$l.sum32_5,ft_1=shaCommon$1.ft_1,BlockHash$3=common$3.BlockHash,sha1_K=[1518500249,1859775393,2400959708,3395469782];function SHA1(){if(!(this instanceof SHA1))return new SHA1;BlockHash$3.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}utils$l.inherits(SHA1,BlockHash$3);var _1=SHA1;SHA1.blockSize=512;SHA1.outSize=160;SHA1.hmacStrength=80;SHA1.padLength=64;SHA1.prototype._update=function(n,t){for(var c=this.W,ie=0;ie<16;ie++)c[ie]=n[t+ie];for(;ie<c.length;ie++)c[ie]=rotl32$1(c[ie-3]^c[ie-8]^c[ie-14]^c[ie-16],1);var se=this.h[0],ae=this.h[1],ue=this.h[2],de=this.h[3],ve=this.h[4];for(ie=0;ie<c.length;ie++){var ge=~~(ie/20),we=sum32_5$1(rotl32$1(se,5),ft_1(ge,ae,ue,de),ve,c[ie],sha1_K[ge]);ve=de,de=ue,ue=rotl32$1(ae,30),ae=se,se=we}this.h[0]=sum32$2(this.h[0],se),this.h[1]=sum32$2(this.h[1],ae),this.h[2]=sum32$2(this.h[2],ue),this.h[3]=sum32$2(this.h[3],de),this.h[4]=sum32$2(this.h[4],ve)};SHA1.prototype._digest=function(n){return n==="hex"?utils$l.toHex32(this.h,"big"):utils$l.split32(this.h,"big")};var utils$k=utils$o,common$2=common$5,shaCommon=common$4,assert$e=minimalisticAssert$1,sum32$1=utils$k.sum32,sum32_4$1=utils$k.sum32_4,sum32_5=utils$k.sum32_5,ch32=shaCommon.ch32,maj32=shaCommon.maj32,s0_256=shaCommon.s0_256,s1_256=shaCommon.s1_256,g0_256=shaCommon.g0_256,g1_256=shaCommon.g1_256,BlockHash$2=common$2.BlockHash,sha256_K=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function SHA256$2(){if(!(this instanceof SHA256$2))return new SHA256$2;BlockHash$2.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=sha256_K,this.W=new Array(64)}utils$k.inherits(SHA256$2,BlockHash$2);var _256=SHA256$2;SHA256$2.blockSize=512;SHA256$2.outSize=256;SHA256$2.hmacStrength=192;SHA256$2.padLength=64;SHA256$2.prototype._update=function(n,t){for(var c=this.W,ie=0;ie<16;ie++)c[ie]=n[t+ie];for(;ie<c.length;ie++)c[ie]=sum32_4$1(g1_256(c[ie-2]),c[ie-7],g0_256(c[ie-15]),c[ie-16]);var se=this.h[0],ae=this.h[1],ue=this.h[2],de=this.h[3],ve=this.h[4],ge=this.h[5],we=this.h[6],Te=this.h[7];for(assert$e(this.k.length===c.length),ie=0;ie<c.length;ie++){var Ne=sum32_5(Te,s1_256(ve),ch32(ve,ge,we),this.k[ie],c[ie]),qe=sum32$1(s0_256(se),maj32(se,ae,ue));Te=we,we=ge,ge=ve,ve=sum32$1(de,Ne),de=ue,ue=ae,ae=se,se=sum32$1(Ne,qe)}this.h[0]=sum32$1(this.h[0],se),this.h[1]=sum32$1(this.h[1],ae),this.h[2]=sum32$1(this.h[2],ue),this.h[3]=sum32$1(this.h[3],de),this.h[4]=sum32$1(this.h[4],ve),this.h[5]=sum32$1(this.h[5],ge),this.h[6]=sum32$1(this.h[6],we),this.h[7]=sum32$1(this.h[7],Te)};SHA256$2.prototype._digest=function(n){return n==="hex"?utils$k.toHex32(this.h,"big"):utils$k.split32(this.h,"big")};var utils$j=utils$o,SHA256$1=_256;function SHA224(){if(!(this instanceof SHA224))return new SHA224;SHA256$1.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}utils$j.inherits(SHA224,SHA256$1);var _224=SHA224;SHA224.blockSize=512;SHA224.outSize=224;SHA224.hmacStrength=192;SHA224.padLength=64;SHA224.prototype._digest=function(n){return n==="hex"?utils$j.toHex32(this.h.slice(0,7),"big"):utils$j.split32(this.h.slice(0,7),"big")};var utils$i=utils$o,common$1=common$5,assert$d=minimalisticAssert$1,rotr64_hi=utils$i.rotr64_hi,rotr64_lo=utils$i.rotr64_lo,shr64_hi=utils$i.shr64_hi,shr64_lo=utils$i.shr64_lo,sum64=utils$i.sum64,sum64_hi=utils$i.sum64_hi,sum64_lo=utils$i.sum64_lo,sum64_4_hi=utils$i.sum64_4_hi,sum64_4_lo=utils$i.sum64_4_lo,sum64_5_hi=utils$i.sum64_5_hi,sum64_5_lo=utils$i.sum64_5_lo,BlockHash$1=common$1.BlockHash,sha512_K=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function SHA512$2(){if(!(this instanceof SHA512$2))return new SHA512$2;BlockHash$1.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=sha512_K,this.W=new Array(160)}utils$i.inherits(SHA512$2,BlockHash$1);var _512=SHA512$2;SHA512$2.blockSize=1024;SHA512$2.outSize=512;SHA512$2.hmacStrength=192;SHA512$2.padLength=128;SHA512$2.prototype._prepareBlock=function(n,t){for(var c=this.W,ie=0;ie<32;ie++)c[ie]=n[t+ie];for(;ie<c.length;ie+=2){var se=g1_512_hi(c[ie-4],c[ie-3]),ae=g1_512_lo(c[ie-4],c[ie-3]),ue=c[ie-14],de=c[ie-13],ve=g0_512_hi(c[ie-30],c[ie-29]),ge=g0_512_lo(c[ie-30],c[ie-29]),we=c[ie-32],Te=c[ie-31];c[ie]=sum64_4_hi(se,ae,ue,de,ve,ge,we,Te),c[ie+1]=sum64_4_lo(se,ae,ue,de,ve,ge,we,Te)}};SHA512$2.prototype._update=function(n,t){this._prepareBlock(n,t);var c=this.W,ie=this.h[0],se=this.h[1],ae=this.h[2],ue=this.h[3],de=this.h[4],ve=this.h[5],ge=this.h[6],we=this.h[7],Te=this.h[8],Ne=this.h[9],qe=this.h[10],ze=this.h[11],He=this.h[12],Ge=this.h[13],Ze=this.h[14],Ye=this.h[15];assert$d(this.k.length===c.length);for(var Ft=0;Ft<c.length;Ft+=2){var Mt=Ze,Zt=Ye,cn=s1_512_hi(Te,Ne),hn=s1_512_lo(Te,Ne),yn=ch64_hi(Te,Ne,qe,ze,He),Ht=ch64_lo(Te,Ne,qe,ze,He,Ge),Sn=this.k[Ft],le=this.k[Ft+1],pe=c[Ft],be=c[Ft+1],xe=sum64_5_hi(Mt,Zt,cn,hn,yn,Ht,Sn,le,pe,be),_e=sum64_5_lo(Mt,Zt,cn,hn,yn,Ht,Sn,le,pe,be);Mt=s0_512_hi(ie,se),Zt=s0_512_lo(ie,se),cn=maj64_hi(ie,se,ae,ue,de),hn=maj64_lo(ie,se,ae,ue,de,ve);var De=sum64_hi(Mt,Zt,cn,hn),Fe=sum64_lo(Mt,Zt,cn,hn);Ze=He,Ye=Ge,He=qe,Ge=ze,qe=Te,ze=Ne,Te=sum64_hi(ge,we,xe,_e),Ne=sum64_lo(we,we,xe,_e),ge=de,we=ve,de=ae,ve=ue,ae=ie,ue=se,ie=sum64_hi(xe,_e,De,Fe),se=sum64_lo(xe,_e,De,Fe)}sum64(this.h,0,ie,se),sum64(this.h,2,ae,ue),sum64(this.h,4,de,ve),sum64(this.h,6,ge,we),sum64(this.h,8,Te,Ne),sum64(this.h,10,qe,ze),sum64(this.h,12,He,Ge),sum64(this.h,14,Ze,Ye)};SHA512$2.prototype._digest=function(n){return n==="hex"?utils$i.toHex32(this.h,"big"):utils$i.split32(this.h,"big")};function ch64_hi(n,t,c,ie,se){var ae=n&c^~n&se;return ae<0&&(ae+=4294967296),ae}function ch64_lo(n,t,c,ie,se,ae){var ue=t&ie^~t&ae;return ue<0&&(ue+=4294967296),ue}function maj64_hi(n,t,c,ie,se){var ae=n&c^n&se^c&se;return ae<0&&(ae+=4294967296),ae}function maj64_lo(n,t,c,ie,se,ae){var ue=t&ie^t&ae^ie&ae;return ue<0&&(ue+=4294967296),ue}function s0_512_hi(n,t){var c=rotr64_hi(n,t,28),ie=rotr64_hi(t,n,2),se=rotr64_hi(t,n,7),ae=c^ie^se;return ae<0&&(ae+=4294967296),ae}function s0_512_lo(n,t){var c=rotr64_lo(n,t,28),ie=rotr64_lo(t,n,2),se=rotr64_lo(t,n,7),ae=c^ie^se;return ae<0&&(ae+=4294967296),ae}function s1_512_hi(n,t){var c=rotr64_hi(n,t,14),ie=rotr64_hi(n,t,18),se=rotr64_hi(t,n,9),ae=c^ie^se;return ae<0&&(ae+=4294967296),ae}function s1_512_lo(n,t){var c=rotr64_lo(n,t,14),ie=rotr64_lo(n,t,18),se=rotr64_lo(t,n,9),ae=c^ie^se;return ae<0&&(ae+=4294967296),ae}function g0_512_hi(n,t){var c=rotr64_hi(n,t,1),ie=rotr64_hi(n,t,8),se=shr64_hi(n,t,7),ae=c^ie^se;return ae<0&&(ae+=4294967296),ae}function g0_512_lo(n,t){var c=rotr64_lo(n,t,1),ie=rotr64_lo(n,t,8),se=shr64_lo(n,t,7),ae=c^ie^se;return ae<0&&(ae+=4294967296),ae}function g1_512_hi(n,t){var c=rotr64_hi(n,t,19),ie=rotr64_hi(t,n,29),se=shr64_hi(n,t,6),ae=c^ie^se;return ae<0&&(ae+=4294967296),ae}function g1_512_lo(n,t){var c=rotr64_lo(n,t,19),ie=rotr64_lo(t,n,29),se=shr64_lo(n,t,6),ae=c^ie^se;return ae<0&&(ae+=4294967296),ae}var utils$h=utils$o,SHA512$1=_512;function SHA384(){if(!(this instanceof SHA384))return new SHA384;SHA512$1.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}utils$h.inherits(SHA384,SHA512$1);var _384=SHA384;SHA384.blockSize=1024;SHA384.outSize=384;SHA384.hmacStrength=192;SHA384.padLength=128;SHA384.prototype._digest=function(n){return n==="hex"?utils$h.toHex32(this.h.slice(0,12),"big"):utils$h.split32(this.h.slice(0,12),"big")};sha$1.sha1=_1;sha$1.sha224=_224;sha$1.sha256=_256;sha$1.sha384=_384;sha$1.sha512=_512;var ripemd={},utils$g=utils$o,common=common$5,rotl32=utils$g.rotl32,sum32=utils$g.sum32,sum32_3=utils$g.sum32_3,sum32_4=utils$g.sum32_4,BlockHash=common.BlockHash;function RIPEMD160$1(){if(!(this instanceof RIPEMD160$1))return new RIPEMD160$1;BlockHash.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}utils$g.inherits(RIPEMD160$1,BlockHash);ripemd.ripemd160=RIPEMD160$1;RIPEMD160$1.blockSize=512;RIPEMD160$1.outSize=160;RIPEMD160$1.hmacStrength=192;RIPEMD160$1.padLength=64;RIPEMD160$1.prototype._update=function(n,t){for(var c=this.h[0],ie=this.h[1],se=this.h[2],ae=this.h[3],ue=this.h[4],de=c,ve=ie,ge=se,we=ae,Te=ue,Ne=0;Ne<80;Ne++){var qe=sum32(rotl32(sum32_4(c,f$2(Ne,ie,se,ae),n[r$1[Ne]+t],K$3(Ne)),s$2[Ne]),ue);c=ue,ue=ae,ae=rotl32(se,10),se=ie,ie=qe,qe=sum32(rotl32(sum32_4(de,f$2(79-Ne,ve,ge,we),n[rh[Ne]+t],Kh(Ne)),sh[Ne]),Te),de=Te,Te=we,we=rotl32(ge,10),ge=ve,ve=qe}qe=sum32_3(this.h[1],se,we),this.h[1]=sum32_3(this.h[2],ae,Te),this.h[2]=sum32_3(this.h[3],ue,de),this.h[3]=sum32_3(this.h[4],c,ve),this.h[4]=sum32_3(this.h[0],ie,ge),this.h[0]=qe};RIPEMD160$1.prototype._digest=function(n){return n==="hex"?utils$g.toHex32(this.h,"little"):utils$g.split32(this.h,"little")};function f$2(n,t,c,ie){return n<=15?t^c^ie:n<=31?t&c|~t&ie:n<=47?(t|~c)^ie:n<=63?t&ie|c&~ie:t^(c|~ie)}function K$3(n){return n<=15?0:n<=31?1518500249:n<=47?1859775393:n<=63?2400959708:2840853838}function Kh(n){return n<=15?1352829926:n<=31?1548603684:n<=47?1836072691:n<=63?2053994217:0}var r$1=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],rh=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],s$2=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],sh=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],utils$f=utils$o,assert$c=minimalisticAssert$1;function Hmac(n,t,c){if(!(this instanceof Hmac))return new Hmac(n,t,c);this.Hash=n,this.blockSize=n.blockSize/8,this.outSize=n.outSize/8,this.inner=null,this.outer=null,this._init(utils$f.toArray(t,c))}var hmac$1=Hmac;Hmac.prototype._init=function(n){n.length>this.blockSize&&(n=new this.Hash().update(n).digest()),assert$c(n.length<=this.blockSize);for(var t=n.length;t<this.blockSize;t++)n.push(0);for(t=0;t<n.length;t++)n[t]^=54;for(this.inner=new this.Hash().update(n),t=0;t<n.length;t++)n[t]^=106;this.outer=new this.Hash().update(n)};Hmac.prototype.update=function(n,t){return this.inner.update(n,t),this};Hmac.prototype.digest=function(n){return this.outer.update(this.inner.digest()),this.outer.digest(n)};(function(n){var t=n;t.utils=utils$o,t.common=common$5,t.sha=sha$1,t.ripemd=ripemd,t.hmac=hmac$1,t.sha1=t.sha.sha1,t.sha256=t.sha.sha256,t.sha224=t.sha.sha224,t.sha384=t.sha.sha384,t.sha512=t.sha.sha512,t.ripemd160=t.ripemd.ripemd160})(hash$4);const hash$3=getDefaultExportFromCjs$2(hash$4);function createCommonjsModule(n,t,c){return c={path:t,exports:{},require:function(ie,se){return commonjsRequire$1(ie,se??c.path)}},n(c,c.exports),c.exports}function commonjsRequire$1(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var minimalisticAssert=assert$b;function assert$b(n,t){if(!n)throw new Error(t||"Assertion failed")}assert$b.equal=function(n,t,c){if(n!=t)throw new Error(c||"Assertion failed: "+n+" != "+t)};var utils_1$7=createCommonjsModule(function(n,t){var c=t;function ie(ue,de){if(Array.isArray(ue))return ue.slice();if(!ue)return[];var ve=[];if(typeof ue!="string"){for(var ge=0;ge<ue.length;ge++)ve[ge]=ue[ge]|0;return ve}if(de==="hex"){ue=ue.replace(/[^a-z0-9]+/ig,""),ue.length%2!==0&&(ue="0"+ue);for(var ge=0;ge<ue.length;ge+=2)ve.push(parseInt(ue[ge]+ue[ge+1],16))}else for(var ge=0;ge<ue.length;ge++){var we=ue.charCodeAt(ge),Te=we>>8,Ne=we&255;Te?ve.push(Te,Ne):ve.push(Ne)}return ve}c.toArray=ie;function se(ue){return ue.length===1?"0"+ue:ue}c.zero2=se;function ae(ue){for(var de="",ve=0;ve<ue.length;ve++)de+=se(ue[ve].toString(16));return de}c.toHex=ae,c.encode=function(ue,de){return de==="hex"?ae(ue):ue}}),utils_1$1$1=createCommonjsModule(function(n,t){var c=t;c.assert=minimalisticAssert,c.toArray=utils_1$7.toArray,c.zero2=utils_1$7.zero2,c.toHex=utils_1$7.toHex,c.encode=utils_1$7.encode;function ie(ve,ge,we){var Te=new Array(Math.max(ve.bitLength(),we)+1),Ne;for(Ne=0;Ne<Te.length;Ne+=1)Te[Ne]=0;var qe=1<<ge+1,ze=ve.clone();for(Ne=0;Ne<Te.length;Ne++){var He,Ge=ze.andln(qe-1);ze.isOdd()?(Ge>(qe>>1)-1?He=(qe>>1)-Ge:He=Ge,ze.isubn(He)):He=0,Te[Ne]=He,ze.iushrn(1)}return Te}c.getNAF=ie;function se(ve,ge){var we=[[],[]];ve=ve.clone(),ge=ge.clone();for(var Te=0,Ne=0,qe;ve.cmpn(-Te)>0||ge.cmpn(-Ne)>0;){var ze=ve.andln(3)+Te&3,He=ge.andln(3)+Ne&3;ze===3&&(ze=-1),He===3&&(He=-1);var Ge;ze&1?(qe=ve.andln(7)+Te&7,(qe===3||qe===5)&&He===2?Ge=-ze:Ge=ze):Ge=0,we[0].push(Ge);var Ze;He&1?(qe=ge.andln(7)+Ne&7,(qe===3||qe===5)&&ze===2?Ze=-He:Ze=He):Ze=0,we[1].push(Ze),2*Te===Ge+1&&(Te=1-Te),2*Ne===Ze+1&&(Ne=1-Ne),ve.iushrn(1),ge.iushrn(1)}return we}c.getJSF=se;function ae(ve,ge,we){var Te="_"+ge;ve.prototype[ge]=function(){return this[Te]!==void 0?this[Te]:this[Te]=we.call(this)}}c.cachedProperty=ae;function ue(ve){return typeof ve=="string"?c.toArray(ve,"hex"):ve}c.parseBytes=ue;function de(ve){return new BN$8(ve,"hex","le")}c.intFromLE=de}),getNAF$1=utils_1$1$1.getNAF,getJSF$1=utils_1$1$1.getJSF,assert$1$1=utils_1$1$1.assert;function BaseCurve$1(n,t){this.type=n,this.p=new BN$8(t.p,16),this.red=t.prime?BN$8.red(t.prime):BN$8.mont(this.p),this.zero=new BN$8(0).toRed(this.red),this.one=new BN$8(1).toRed(this.red),this.two=new BN$8(2).toRed(this.red),this.n=t.n&&new BN$8(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var c=this.n&&this.p.div(this.n);!c||c.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var base$5=BaseCurve$1;BaseCurve$1.prototype.point=function(){throw new Error("Not implemented")};BaseCurve$1.prototype.validate=function(){throw new Error("Not implemented")};BaseCurve$1.prototype._fixedNafMul=function(n,t){assert$1$1(n.precomputed);var c=n._getDoubles(),ie=getNAF$1(t,1,this._bitLength),se=(1<<c.step+1)-(c.step%2===0?2:1);se/=3;var ae=[],ue,de;for(ue=0;ue<ie.length;ue+=c.step){de=0;for(var ve=ue+c.step-1;ve>=ue;ve--)de=(de<<1)+ie[ve];ae.push(de)}for(var ge=this.jpoint(null,null,null),we=this.jpoint(null,null,null),Te=se;Te>0;Te--){for(ue=0;ue<ae.length;ue++)de=ae[ue],de===Te?we=we.mixedAdd(c.points[ue]):de===-Te&&(we=we.mixedAdd(c.points[ue].neg()));ge=ge.add(we)}return ge.toP()};BaseCurve$1.prototype._wnafMul=function(n,t){var c=4,ie=n._getNAFPoints(c);c=ie.wnd;for(var se=ie.points,ae=getNAF$1(t,c,this._bitLength),ue=this.jpoint(null,null,null),de=ae.length-1;de>=0;de--){for(var ve=0;de>=0&&ae[de]===0;de--)ve++;if(de>=0&&ve++,ue=ue.dblp(ve),de<0)break;var ge=ae[de];assert$1$1(ge!==0),n.type==="affine"?ge>0?ue=ue.mixedAdd(se[ge-1>>1]):ue=ue.mixedAdd(se[-ge-1>>1].neg()):ge>0?ue=ue.add(se[ge-1>>1]):ue=ue.add(se[-ge-1>>1].neg())}return n.type==="affine"?ue.toP():ue};BaseCurve$1.prototype._wnafMulAdd=function(n,t,c,ie,se){var ae=this._wnafT1,ue=this._wnafT2,de=this._wnafT3,ve=0,ge,we,Te;for(ge=0;ge<ie;ge++){Te=t[ge];var Ne=Te._getNAFPoints(n);ae[ge]=Ne.wnd,ue[ge]=Ne.points}for(ge=ie-1;ge>=1;ge-=2){var qe=ge-1,ze=ge;if(ae[qe]!==1||ae[ze]!==1){de[qe]=getNAF$1(c[qe],ae[qe],this._bitLength),de[ze]=getNAF$1(c[ze],ae[ze],this._bitLength),ve=Math.max(de[qe].length,ve),ve=Math.max(de[ze].length,ve);continue}var He=[t[qe],null,null,t[ze]];t[qe].y.cmp(t[ze].y)===0?(He[1]=t[qe].add(t[ze]),He[2]=t[qe].toJ().mixedAdd(t[ze].neg())):t[qe].y.cmp(t[ze].y.redNeg())===0?(He[1]=t[qe].toJ().mixedAdd(t[ze]),He[2]=t[qe].add(t[ze].neg())):(He[1]=t[qe].toJ().mixedAdd(t[ze]),He[2]=t[qe].toJ().mixedAdd(t[ze].neg()));var Ge=[-3,-1,-5,-7,0,7,5,1,3],Ze=getJSF$1(c[qe],c[ze]);for(ve=Math.max(Ze[0].length,ve),de[qe]=new Array(ve),de[ze]=new Array(ve),we=0;we<ve;we++){var Ye=Ze[0][we]|0,Ft=Ze[1][we]|0;de[qe][we]=Ge[(Ye+1)*3+(Ft+1)],de[ze][we]=0,ue[qe]=He}}var Mt=this.jpoint(null,null,null),Zt=this._wnafT4;for(ge=ve;ge>=0;ge--){for(var cn=0;ge>=0;){var hn=!0;for(we=0;we<ie;we++)Zt[we]=de[we][ge]|0,Zt[we]!==0&&(hn=!1);if(!hn)break;cn++,ge--}if(ge>=0&&cn++,Mt=Mt.dblp(cn),ge<0)break;for(we=0;we<ie;we++){var yn=Zt[we];yn!==0&&(yn>0?Te=ue[we][yn-1>>1]:yn<0&&(Te=ue[we][-yn-1>>1].neg()),Te.type==="affine"?Mt=Mt.mixedAdd(Te):Mt=Mt.add(Te))}}for(ge=0;ge<ie;ge++)ue[ge]=null;return se?Mt:Mt.toP()};function BasePoint$1(n,t){this.curve=n,this.type=t,this.precomputed=null}BaseCurve$1.BasePoint=BasePoint$1;BasePoint$1.prototype.eq=function(){throw new Error("Not implemented")};BasePoint$1.prototype.validate=function(){return this.curve.validate(this)};BaseCurve$1.prototype.decodePoint=function(n,t){n=utils_1$1$1.toArray(n,t);var c=this.p.byteLength();if((n[0]===4||n[0]===6||n[0]===7)&&n.length-1===2*c){n[0]===6?assert$1$1(n[n.length-1]%2===0):n[0]===7&&assert$1$1(n[n.length-1]%2===1);var ie=this.point(n.slice(1,1+c),n.slice(1+c,1+2*c));return ie}else if((n[0]===2||n[0]===3)&&n.length-1===c)return this.pointFromX(n.slice(1,1+c),n[0]===3);throw new Error("Unknown point format")};BasePoint$1.prototype.encodeCompressed=function(n){return this.encode(n,!0)};BasePoint$1.prototype._encode=function(n){var t=this.curve.p.byteLength(),c=this.getX().toArray("be",t);return n?[this.getY().isEven()?2:3].concat(c):[4].concat(c,this.getY().toArray("be",t))};BasePoint$1.prototype.encode=function(n,t){return utils_1$1$1.encode(this._encode(t),n)};BasePoint$1.prototype.precompute=function(n){if(this.precomputed)return this;var t={doubles:null,naf:null,beta:null};return t.naf=this._getNAFPoints(8),t.doubles=this._getDoubles(4,n),t.beta=this._getBeta(),this.precomputed=t,this};BasePoint$1.prototype._hasDoubles=function(n){if(!this.precomputed)return!1;var t=this.precomputed.doubles;return t?t.points.length>=Math.ceil((n.bitLength()+1)/t.step):!1};BasePoint$1.prototype._getDoubles=function(n,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var c=[this],ie=this,se=0;se<t;se+=n){for(var ae=0;ae<n;ae++)ie=ie.dbl();c.push(ie)}return{step:n,points:c}};BasePoint$1.prototype._getNAFPoints=function(n){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var t=[this],c=(1<<n)-1,ie=c===1?null:this.dbl(),se=1;se<c;se++)t[se]=t[se-1].add(ie);return{wnd:n,points:t}};BasePoint$1.prototype._getBeta=function(){return null};BasePoint$1.prototype.dblp=function(n){for(var t=this,c=0;c<n;c++)t=t.dbl();return t};var inherits_browser=createCommonjsModule(function(n){typeof Object.create=="function"?n.exports=function(t,c){c&&(t.super_=c,t.prototype=Object.create(c.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:n.exports=function(t,c){if(c){t.super_=c;var ie=function(){};ie.prototype=c.prototype,t.prototype=new ie,t.prototype.constructor=t}}}),assert$2$1=utils_1$1$1.assert;function ShortCurve$1(n){base$5.call(this,"short",n),this.a=new BN$8(n.a,16).toRed(this.red),this.b=new BN$8(n.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(n),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}inherits_browser(ShortCurve$1,base$5);var short_1=ShortCurve$1;ShortCurve$1.prototype._getEndomorphism=function(n){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,c;if(n.beta)t=new BN$8(n.beta,16).toRed(this.red);else{var ie=this._getEndoRoots(this.p);t=ie[0].cmp(ie[1])<0?ie[0]:ie[1],t=t.toRed(this.red)}if(n.lambda)c=new BN$8(n.lambda,16);else{var se=this._getEndoRoots(this.n);this.g.mul(se[0]).x.cmp(this.g.x.redMul(t))===0?c=se[0]:(c=se[1],assert$2$1(this.g.mul(c).x.cmp(this.g.x.redMul(t))===0))}var ae;return n.basis?ae=n.basis.map(function(ue){return{a:new BN$8(ue.a,16),b:new BN$8(ue.b,16)}}):ae=this._getEndoBasis(c),{beta:t,lambda:c,basis:ae}}};ShortCurve$1.prototype._getEndoRoots=function(n){var t=n===this.p?this.red:BN$8.mont(n),c=new BN$8(2).toRed(t).redInvm(),ie=c.redNeg(),se=new BN$8(3).toRed(t).redNeg().redSqrt().redMul(c),ae=ie.redAdd(se).fromRed(),ue=ie.redSub(se).fromRed();return[ae,ue]};ShortCurve$1.prototype._getEndoBasis=function(n){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),c=n,ie=this.n.clone(),se=new BN$8(1),ae=new BN$8(0),ue=new BN$8(0),de=new BN$8(1),ve,ge,we,Te,Ne,qe,ze,He=0,Ge,Ze;c.cmpn(0)!==0;){var Ye=ie.div(c);Ge=ie.sub(Ye.mul(c)),Ze=ue.sub(Ye.mul(se));var Ft=de.sub(Ye.mul(ae));if(!we&&Ge.cmp(t)<0)ve=ze.neg(),ge=se,we=Ge.neg(),Te=Ze;else if(we&&++He===2)break;ze=Ge,ie=c,c=Ge,ue=se,se=Ze,de=ae,ae=Ft}Ne=Ge.neg(),qe=Ze;var Mt=we.sqr().add(Te.sqr()),Zt=Ne.sqr().add(qe.sqr());return Zt.cmp(Mt)>=0&&(Ne=ve,qe=ge),we.negative&&(we=we.neg(),Te=Te.neg()),Ne.negative&&(Ne=Ne.neg(),qe=qe.neg()),[{a:we,b:Te},{a:Ne,b:qe}]};ShortCurve$1.prototype._endoSplit=function(n){var t=this.endo.basis,c=t[0],ie=t[1],se=ie.b.mul(n).divRound(this.n),ae=c.b.neg().mul(n).divRound(this.n),ue=se.mul(c.a),de=ae.mul(ie.a),ve=se.mul(c.b),ge=ae.mul(ie.b),we=n.sub(ue).sub(de),Te=ve.add(ge).neg();return{k1:we,k2:Te}};ShortCurve$1.prototype.pointFromX=function(n,t){n=new BN$8(n,16),n.red||(n=n.toRed(this.red));var c=n.redSqr().redMul(n).redIAdd(n.redMul(this.a)).redIAdd(this.b),ie=c.redSqrt();if(ie.redSqr().redSub(c).cmp(this.zero)!==0)throw new Error("invalid point");var se=ie.fromRed().isOdd();return(t&&!se||!t&&se)&&(ie=ie.redNeg()),this.point(n,ie)};ShortCurve$1.prototype.validate=function(n){if(n.inf)return!0;var t=n.x,c=n.y,ie=this.a.redMul(t),se=t.redSqr().redMul(t).redIAdd(ie).redIAdd(this.b);return c.redSqr().redISub(se).cmpn(0)===0};ShortCurve$1.prototype._endoWnafMulAdd=function(n,t,c){for(var ie=this._endoWnafT1,se=this._endoWnafT2,ae=0;ae<n.length;ae++){var ue=this._endoSplit(t[ae]),de=n[ae],ve=de._getBeta();ue.k1.negative&&(ue.k1.ineg(),de=de.neg(!0)),ue.k2.negative&&(ue.k2.ineg(),ve=ve.neg(!0)),ie[ae*2]=de,ie[ae*2+1]=ve,se[ae*2]=ue.k1,se[ae*2+1]=ue.k2}for(var ge=this._wnafMulAdd(1,ie,se,ae*2,c),we=0;we<ae*2;we++)ie[we]=null,se[we]=null;return ge};function Point$3(n,t,c,ie){base$5.BasePoint.call(this,n,"affine"),t===null&&c===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new BN$8(t,16),this.y=new BN$8(c,16),ie&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}inherits_browser(Point$3,base$5.BasePoint);ShortCurve$1.prototype.point=function(n,t,c){return new Point$3(this,n,t,c)};ShortCurve$1.prototype.pointFromJSON=function(n,t){return Point$3.fromJSON(this,n,t)};Point$3.prototype._getBeta=function(){if(this.curve.endo){var n=this.precomputed;if(n&&n.beta)return n.beta;var t=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(n){var c=this.curve,ie=function(se){return c.point(se.x.redMul(c.endo.beta),se.y)};n.beta=t,t.precomputed={beta:null,naf:n.naf&&{wnd:n.naf.wnd,points:n.naf.points.map(ie)},doubles:n.doubles&&{step:n.doubles.step,points:n.doubles.points.map(ie)}}}return t}};Point$3.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]};Point$3.fromJSON=function(n,t,c){typeof t=="string"&&(t=JSON.parse(t));var ie=n.point(t[0],t[1],c);if(!t[2])return ie;function se(ue){return n.point(ue[0],ue[1],c)}var ae=t[2];return ie.precomputed={beta:null,doubles:ae.doubles&&{step:ae.doubles.step,points:[ie].concat(ae.doubles.points.map(se))},naf:ae.naf&&{wnd:ae.naf.wnd,points:[ie].concat(ae.naf.points.map(se))}},ie};Point$3.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"};Point$3.prototype.isInfinity=function(){return this.inf};Point$3.prototype.add=function(n){if(this.inf)return n;if(n.inf)return this;if(this.eq(n))return this.dbl();if(this.neg().eq(n))return this.curve.point(null,null);if(this.x.cmp(n.x)===0)return this.curve.point(null,null);var t=this.y.redSub(n.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(n.x).redInvm()));var c=t.redSqr().redISub(this.x).redISub(n.x),ie=t.redMul(this.x.redSub(c)).redISub(this.y);return this.curve.point(c,ie)};Point$3.prototype.dbl=function(){if(this.inf)return this;var n=this.y.redAdd(this.y);if(n.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,c=this.x.redSqr(),ie=n.redInvm(),se=c.redAdd(c).redIAdd(c).redIAdd(t).redMul(ie),ae=se.redSqr().redISub(this.x.redAdd(this.x)),ue=se.redMul(this.x.redSub(ae)).redISub(this.y);return this.curve.point(ae,ue)};Point$3.prototype.getX=function(){return this.x.fromRed()};Point$3.prototype.getY=function(){return this.y.fromRed()};Point$3.prototype.mul=function(n){return n=new BN$8(n,16),this.isInfinity()?this:this._hasDoubles(n)?this.curve._fixedNafMul(this,n):this.curve.endo?this.curve._endoWnafMulAdd([this],[n]):this.curve._wnafMul(this,n)};Point$3.prototype.mulAdd=function(n,t,c){var ie=[this,t],se=[n,c];return this.curve.endo?this.curve._endoWnafMulAdd(ie,se):this.curve._wnafMulAdd(1,ie,se,2)};Point$3.prototype.jmulAdd=function(n,t,c){var ie=[this,t],se=[n,c];return this.curve.endo?this.curve._endoWnafMulAdd(ie,se,!0):this.curve._wnafMulAdd(1,ie,se,2,!0)};Point$3.prototype.eq=function(n){return this===n||this.inf===n.inf&&(this.inf||this.x.cmp(n.x)===0&&this.y.cmp(n.y)===0)};Point$3.prototype.neg=function(n){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(n&&this.precomputed){var c=this.precomputed,ie=function(se){return se.neg()};t.precomputed={naf:c.naf&&{wnd:c.naf.wnd,points:c.naf.points.map(ie)},doubles:c.doubles&&{step:c.doubles.step,points:c.doubles.points.map(ie)}}}return t};Point$3.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var n=this.curve.jpoint(this.x,this.y,this.curve.one);return n};function JPoint$1(n,t,c,ie){base$5.BasePoint.call(this,n,"jacobian"),t===null&&c===null&&ie===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new BN$8(0)):(this.x=new BN$8(t,16),this.y=new BN$8(c,16),this.z=new BN$8(ie,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}inherits_browser(JPoint$1,base$5.BasePoint);ShortCurve$1.prototype.jpoint=function(n,t,c){return new JPoint$1(this,n,t,c)};JPoint$1.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var n=this.z.redInvm(),t=n.redSqr(),c=this.x.redMul(t),ie=this.y.redMul(t).redMul(n);return this.curve.point(c,ie)};JPoint$1.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};JPoint$1.prototype.add=function(n){if(this.isInfinity())return n;if(n.isInfinity())return this;var t=n.z.redSqr(),c=this.z.redSqr(),ie=this.x.redMul(t),se=n.x.redMul(c),ae=this.y.redMul(t.redMul(n.z)),ue=n.y.redMul(c.redMul(this.z)),de=ie.redSub(se),ve=ae.redSub(ue);if(de.cmpn(0)===0)return ve.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var ge=de.redSqr(),we=ge.redMul(de),Te=ie.redMul(ge),Ne=ve.redSqr().redIAdd(we).redISub(Te).redISub(Te),qe=ve.redMul(Te.redISub(Ne)).redISub(ae.redMul(we)),ze=this.z.redMul(n.z).redMul(de);return this.curve.jpoint(Ne,qe,ze)};JPoint$1.prototype.mixedAdd=function(n){if(this.isInfinity())return n.toJ();if(n.isInfinity())return this;var t=this.z.redSqr(),c=this.x,ie=n.x.redMul(t),se=this.y,ae=n.y.redMul(t).redMul(this.z),ue=c.redSub(ie),de=se.redSub(ae);if(ue.cmpn(0)===0)return de.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var ve=ue.redSqr(),ge=ve.redMul(ue),we=c.redMul(ve),Te=de.redSqr().redIAdd(ge).redISub(we).redISub(we),Ne=de.redMul(we.redISub(Te)).redISub(se.redMul(ge)),qe=this.z.redMul(ue);return this.curve.jpoint(Te,Ne,qe)};JPoint$1.prototype.dblp=function(n){if(n===0)return this;if(this.isInfinity())return this;if(!n)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var c=this;for(t=0;t<n;t++)c=c.dbl();return c}var ie=this.curve.a,se=this.curve.tinv,ae=this.x,ue=this.y,de=this.z,ve=de.redSqr().redSqr(),ge=ue.redAdd(ue);for(t=0;t<n;t++){var we=ae.redSqr(),Te=ge.redSqr(),Ne=Te.redSqr(),qe=we.redAdd(we).redIAdd(we).redIAdd(ie.redMul(ve)),ze=ae.redMul(Te),He=qe.redSqr().redISub(ze.redAdd(ze)),Ge=ze.redISub(He),Ze=qe.redMul(Ge);Ze=Ze.redIAdd(Ze).redISub(Ne);var Ye=ge.redMul(de);t+1<n&&(ve=ve.redMul(Ne)),ae=He,de=Ye,ge=Ze}return this.curve.jpoint(ae,ge.redMul(se),de)};JPoint$1.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()};JPoint$1.prototype._zeroDbl=function(){var n,t,c;if(this.zOne){var ie=this.x.redSqr(),se=this.y.redSqr(),ae=se.redSqr(),ue=this.x.redAdd(se).redSqr().redISub(ie).redISub(ae);ue=ue.redIAdd(ue);var de=ie.redAdd(ie).redIAdd(ie),ve=de.redSqr().redISub(ue).redISub(ue),ge=ae.redIAdd(ae);ge=ge.redIAdd(ge),ge=ge.redIAdd(ge),n=ve,t=de.redMul(ue.redISub(ve)).redISub(ge),c=this.y.redAdd(this.y)}else{var we=this.x.redSqr(),Te=this.y.redSqr(),Ne=Te.redSqr(),qe=this.x.redAdd(Te).redSqr().redISub(we).redISub(Ne);qe=qe.redIAdd(qe);var ze=we.redAdd(we).redIAdd(we),He=ze.redSqr(),Ge=Ne.redIAdd(Ne);Ge=Ge.redIAdd(Ge),Ge=Ge.redIAdd(Ge),n=He.redISub(qe).redISub(qe),t=ze.redMul(qe.redISub(n)).redISub(Ge),c=this.y.redMul(this.z),c=c.redIAdd(c)}return this.curve.jpoint(n,t,c)};JPoint$1.prototype._threeDbl=function(){var n,t,c;if(this.zOne){var ie=this.x.redSqr(),se=this.y.redSqr(),ae=se.redSqr(),ue=this.x.redAdd(se).redSqr().redISub(ie).redISub(ae);ue=ue.redIAdd(ue);var de=ie.redAdd(ie).redIAdd(ie).redIAdd(this.curve.a),ve=de.redSqr().redISub(ue).redISub(ue);n=ve;var ge=ae.redIAdd(ae);ge=ge.redIAdd(ge),ge=ge.redIAdd(ge),t=de.redMul(ue.redISub(ve)).redISub(ge),c=this.y.redAdd(this.y)}else{var we=this.z.redSqr(),Te=this.y.redSqr(),Ne=this.x.redMul(Te),qe=this.x.redSub(we).redMul(this.x.redAdd(we));qe=qe.redAdd(qe).redIAdd(qe);var ze=Ne.redIAdd(Ne);ze=ze.redIAdd(ze);var He=ze.redAdd(ze);n=qe.redSqr().redISub(He),c=this.y.redAdd(this.z).redSqr().redISub(Te).redISub(we);var Ge=Te.redSqr();Ge=Ge.redIAdd(Ge),Ge=Ge.redIAdd(Ge),Ge=Ge.redIAdd(Ge),t=qe.redMul(ze.redISub(n)).redISub(Ge)}return this.curve.jpoint(n,t,c)};JPoint$1.prototype._dbl=function(){var n=this.curve.a,t=this.x,c=this.y,ie=this.z,se=ie.redSqr().redSqr(),ae=t.redSqr(),ue=c.redSqr(),de=ae.redAdd(ae).redIAdd(ae).redIAdd(n.redMul(se)),ve=t.redAdd(t);ve=ve.redIAdd(ve);var ge=ve.redMul(ue),we=de.redSqr().redISub(ge.redAdd(ge)),Te=ge.redISub(we),Ne=ue.redSqr();Ne=Ne.redIAdd(Ne),Ne=Ne.redIAdd(Ne),Ne=Ne.redIAdd(Ne);var qe=de.redMul(Te).redISub(Ne),ze=c.redAdd(c).redMul(ie);return this.curve.jpoint(we,qe,ze)};JPoint$1.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var n=this.x.redSqr(),t=this.y.redSqr(),c=this.z.redSqr(),ie=t.redSqr(),se=n.redAdd(n).redIAdd(n),ae=se.redSqr(),ue=this.x.redAdd(t).redSqr().redISub(n).redISub(ie);ue=ue.redIAdd(ue),ue=ue.redAdd(ue).redIAdd(ue),ue=ue.redISub(ae);var de=ue.redSqr(),ve=ie.redIAdd(ie);ve=ve.redIAdd(ve),ve=ve.redIAdd(ve),ve=ve.redIAdd(ve);var ge=se.redIAdd(ue).redSqr().redISub(ae).redISub(de).redISub(ve),we=t.redMul(ge);we=we.redIAdd(we),we=we.redIAdd(we);var Te=this.x.redMul(de).redISub(we);Te=Te.redIAdd(Te),Te=Te.redIAdd(Te);var Ne=this.y.redMul(ge.redMul(ve.redISub(ge)).redISub(ue.redMul(de)));Ne=Ne.redIAdd(Ne),Ne=Ne.redIAdd(Ne),Ne=Ne.redIAdd(Ne);var qe=this.z.redAdd(ue).redSqr().redISub(c).redISub(de);return this.curve.jpoint(Te,Ne,qe)};JPoint$1.prototype.mul=function(n,t){return n=new BN$8(n,t),this.curve._wnafMul(this,n)};JPoint$1.prototype.eq=function(n){if(n.type==="affine")return this.eq(n.toJ());if(this===n)return!0;var t=this.z.redSqr(),c=n.z.redSqr();if(this.x.redMul(c).redISub(n.x.redMul(t)).cmpn(0)!==0)return!1;var ie=t.redMul(this.z),se=c.redMul(n.z);return this.y.redMul(se).redISub(n.y.redMul(ie)).cmpn(0)===0};JPoint$1.prototype.eqXToP=function(n){var t=this.z.redSqr(),c=n.toRed(this.curve.red).redMul(t);if(this.x.cmp(c)===0)return!0;for(var ie=n.clone(),se=this.curve.redN.redMul(t);;){if(ie.iadd(this.curve.n),ie.cmp(this.curve.p)>=0)return!1;if(c.redIAdd(se),this.x.cmp(c)===0)return!0}};JPoint$1.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"};JPoint$1.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var curve_1=createCommonjsModule(function(n,t){var c=t;c.base=base$5,c.short=short_1,c.mont=null,c.edwards=null}),curves_1=createCommonjsModule(function(n,t){var c=t,ie=utils_1$1$1.assert;function se(de){de.type==="short"?this.curve=new curve_1.short(de):de.type==="edwards"?this.curve=new curve_1.edwards(de):this.curve=new curve_1.mont(de),this.g=this.curve.g,this.n=this.curve.n,this.hash=de.hash,ie(this.g.validate(),"Invalid curve"),ie(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}c.PresetCurve=se;function ae(de,ve){Object.defineProperty(c,de,{configurable:!0,enumerable:!0,get:function(){var ge=new se(ve);return Object.defineProperty(c,de,{configurable:!0,enumerable:!0,value:ge}),ge}})}ae("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:hash$3.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),ae("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:hash$3.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),ae("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:hash$3.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),ae("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:hash$3.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),ae("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:hash$3.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),ae("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:hash$3.sha256,gRed:!1,g:["9"]}),ae("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:hash$3.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var ue;try{ue=null.crash()}catch{ue=void 0}ae("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:hash$3.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",ue]})});function HmacDRBG$1(n){if(!(this instanceof HmacDRBG$1))return new HmacDRBG$1(n);this.hash=n.hash,this.predResist=!!n.predResist,this.outLen=this.hash.outSize,this.minEntropy=n.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=utils_1$7.toArray(n.entropy,n.entropyEnc||"hex"),c=utils_1$7.toArray(n.nonce,n.nonceEnc||"hex"),ie=utils_1$7.toArray(n.pers,n.persEnc||"hex");minimalisticAssert(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,c,ie)}var hmacDrbg$1=HmacDRBG$1;HmacDRBG$1.prototype._init=function(n,t,c){var ie=n.concat(t).concat(c);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var se=0;se<this.V.length;se++)this.K[se]=0,this.V[se]=1;this._update(ie),this._reseed=1,this.reseedInterval=281474976710656};HmacDRBG$1.prototype._hmac=function(){return new hash$3.hmac(this.hash,this.K)};HmacDRBG$1.prototype._update=function(n){var t=this._hmac().update(this.V).update([0]);n&&(t=t.update(n)),this.K=t.digest(),this.V=this._hmac().update(this.V).digest(),n&&(this.K=this._hmac().update(this.V).update([1]).update(n).digest(),this.V=this._hmac().update(this.V).digest())};HmacDRBG$1.prototype.reseed=function(n,t,c,ie){typeof t!="string"&&(ie=c,c=t,t=null),n=utils_1$7.toArray(n,t),c=utils_1$7.toArray(c,ie),minimalisticAssert(n.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(n.concat(c||[])),this._reseed=1};HmacDRBG$1.prototype.generate=function(n,t,c,ie){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(ie=c,c=t,t=null),c&&(c=utils_1$7.toArray(c,ie||"hex"),this._update(c));for(var se=[];se.length<n;)this.V=this._hmac().update(this.V).digest(),se=se.concat(this.V);var ae=se.slice(0,n);return this._update(c),this._reseed++,utils_1$7.encode(ae,t)};var assert$3$1=utils_1$1$1.assert;function KeyPair$3(n,t){this.ec=n,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}var key$2=KeyPair$3;KeyPair$3.fromPublic=function(n,t,c){return t instanceof KeyPair$3?t:new KeyPair$3(n,{pub:t,pubEnc:c})};KeyPair$3.fromPrivate=function(n,t,c){return t instanceof KeyPair$3?t:new KeyPair$3(n,{priv:t,privEnc:c})};KeyPair$3.prototype.validate=function(){var n=this.getPublic();return n.isInfinity()?{result:!1,reason:"Invalid public key"}:n.validate()?n.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}};KeyPair$3.prototype.getPublic=function(n,t){return typeof n=="string"&&(t=n,n=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,n):this.pub};KeyPair$3.prototype.getPrivate=function(n){return n==="hex"?this.priv.toString(16,2):this.priv};KeyPair$3.prototype._importPrivate=function(n,t){this.priv=new BN$8(n,t||16),this.priv=this.priv.umod(this.ec.curve.n)};KeyPair$3.prototype._importPublic=function(n,t){if(n.x||n.y){this.ec.curve.type==="mont"?assert$3$1(n.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&assert$3$1(n.x&&n.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(n.x,n.y);return}this.pub=this.ec.curve.decodePoint(n,t)};KeyPair$3.prototype.derive=function(n){return n.validate()||assert$3$1(n.validate(),"public point not validated"),n.mul(this.priv).getX()};KeyPair$3.prototype.sign=function(n,t,c){return this.ec.sign(n,this,t,c)};KeyPair$3.prototype.verify=function(n,t,c){return this.ec.verify(n,t,this,void 0,c)};KeyPair$3.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var assert$4$1=utils_1$1$1.assert;function Signature$3(n,t){if(n instanceof Signature$3)return n;this._importDER(n,t)||(assert$4$1(n.r&&n.s,"Signature without r or s"),this.r=new BN$8(n.r,16),this.s=new BN$8(n.s,16),n.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=n.recoveryParam)}var signature$3=Signature$3;function Position$1(){this.place=0}function getLength$1(n,t){var c=n[t.place++];if(!(c&128))return c;var ie=c&15;if(ie===0||ie>4||n[t.place]===0)return!1;for(var se=0,ae=0,ue=t.place;ae<ie;ae++,ue++)se<<=8,se|=n[ue],se>>>=0;return se<=127?!1:(t.place=ue,se)}function rmPadding$1(n){for(var t=0,c=n.length-1;!n[t]&&!(n[t+1]&128)&&t<c;)t++;return t===0?n:n.slice(t)}Signature$3.prototype._importDER=function(n,t){n=utils_1$1$1.toArray(n,t);var c=new Position$1;if(n[c.place++]!==48)return!1;var ie=getLength$1(n,c);if(ie===!1||ie+c.place!==n.length||n[c.place++]!==2)return!1;var se=getLength$1(n,c);if(se===!1||n[c.place]&128)return!1;var ae=n.slice(c.place,se+c.place);if(c.place+=se,n[c.place++]!==2)return!1;var ue=getLength$1(n,c);if(ue===!1||n.length!==ue+c.place||n[c.place]&128)return!1;var de=n.slice(c.place,ue+c.place);if(ae[0]===0)if(ae[1]&128)ae=ae.slice(1);else return!1;if(de[0]===0)if(de[1]&128)de=de.slice(1);else return!1;return this.r=new BN$8(ae),this.s=new BN$8(de),this.recoveryParam=null,!0};function constructLength$1(n,t){if(t<128){n.push(t);return}var c=1+(Math.log(t)/Math.LN2>>>3);for(n.push(c|128);--c;)n.push(t>>>(c<<3)&255);n.push(t)}Signature$3.prototype.toDER=function(n){var t=this.r.toArray(),c=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),c[0]&128&&(c=[0].concat(c)),t=rmPadding$1(t),c=rmPadding$1(c);!c[0]&&!(c[1]&128);)c=c.slice(1);var ie=[2];constructLength$1(ie,t.length),ie=ie.concat(t),ie.push(2),constructLength$1(ie,c.length);var se=ie.concat(c),ae=[48];return constructLength$1(ae,se.length),ae=ae.concat(se),utils_1$1$1.encode(ae,n)};var rand=(function(){throw new Error("unsupported")}),assert$5$1=utils_1$1$1.assert;function EC(n){if(!(this instanceof EC))return new EC(n);typeof n=="string"&&(assert$5$1(Object.prototype.hasOwnProperty.call(curves_1,n),"Unknown curve "+n),n=curves_1[n]),n instanceof curves_1.PresetCurve&&(n={curve:n}),this.curve=n.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=n.curve.g,this.g.precompute(n.curve.n.bitLength()+1),this.hash=n.hash||n.curve.hash}var ec$1=EC;EC.prototype.keyPair=function(n){return new key$2(this,n)};EC.prototype.keyFromPrivate=function(n,t){return key$2.fromPrivate(this,n,t)};EC.prototype.keyFromPublic=function(n,t){return key$2.fromPublic(this,n,t)};EC.prototype.genKeyPair=function(n){n||(n={});for(var t=new hmacDrbg$1({hash:this.hash,pers:n.pers,persEnc:n.persEnc||"utf8",entropy:n.entropy||rand(this.hash.hmacStrength),entropyEnc:n.entropy&&n.entropyEnc||"utf8",nonce:this.n.toArray()}),c=this.n.byteLength(),ie=this.n.sub(new BN$8(2));;){var se=new BN$8(t.generate(c));if(!(se.cmp(ie)>0))return se.iaddn(1),this.keyFromPrivate(se)}};EC.prototype._truncateToN=function(n,t,c){var ie;if(BN$8.isBN(n)||typeof n=="number")n=new BN$8(n,16),ie=n.byteLength();else if(typeof n=="object")ie=n.length,n=new BN$8(n,16);else{var se=n.toString();ie=se.length+1>>>1,n=new BN$8(se,16)}typeof c!="number"&&(c=ie*8);var ae=c-this.n.bitLength();return ae>0&&(n=n.ushrn(ae)),!t&&n.cmp(this.n)>=0?n.sub(this.n):n};EC.prototype.sign=function(n,t,c,ie){if(typeof c=="object"&&(ie=c,c=null),ie||(ie={}),typeof n!="string"&&typeof n!="number"&&!BN$8.isBN(n)){assert$5$1(typeof n=="object"&&n&&typeof n.length=="number","Expected message to be an array-like, a hex string, or a BN instance"),assert$5$1(n.length>>>0===n.length);for(var se=0;se<n.length;se++)assert$5$1((n[se]&255)===n[se])}t=this.keyFromPrivate(t,c),n=this._truncateToN(n,!1,ie.msgBitLength),assert$5$1(!n.isNeg(),"Can not sign a negative message");var ae=this.n.byteLength(),ue=t.getPrivate().toArray("be",ae),de=n.toArray("be",ae);assert$5$1(new BN$8(de).eq(n),"Can not sign message");for(var ve=new hmacDrbg$1({hash:this.hash,entropy:ue,nonce:de,pers:ie.pers,persEnc:ie.persEnc||"utf8"}),ge=this.n.sub(new BN$8(1)),we=0;;we++){var Te=ie.k?ie.k(we):new BN$8(ve.generate(this.n.byteLength()));if(Te=this._truncateToN(Te,!0),!(Te.cmpn(1)<=0||Te.cmp(ge)>=0)){var Ne=this.g.mul(Te);if(!Ne.isInfinity()){var qe=Ne.getX(),ze=qe.umod(this.n);if(ze.cmpn(0)!==0){var He=Te.invm(this.n).mul(ze.mul(t.getPrivate()).iadd(n));if(He=He.umod(this.n),He.cmpn(0)!==0){var Ge=(Ne.getY().isOdd()?1:0)|(qe.cmp(ze)!==0?2:0);return ie.canonical&&He.cmp(this.nh)>0&&(He=this.n.sub(He),Ge^=1),new signature$3({r:ze,s:He,recoveryParam:Ge})}}}}}};EC.prototype.verify=function(n,t,c,ie,se){se||(se={}),n=this._truncateToN(n,!1,se.msgBitLength),c=this.keyFromPublic(c,ie),t=new signature$3(t,"hex");var ae=t.r,ue=t.s;if(ae.cmpn(1)<0||ae.cmp(this.n)>=0||ue.cmpn(1)<0||ue.cmp(this.n)>=0)return!1;var de=ue.invm(this.n),ve=de.mul(n).umod(this.n),ge=de.mul(ae).umod(this.n),we;return this.curve._maxwellTrick?(we=this.g.jmulAdd(ve,c.getPublic(),ge),we.isInfinity()?!1:we.eqXToP(ae)):(we=this.g.mulAdd(ve,c.getPublic(),ge),we.isInfinity()?!1:we.getX().umod(this.n).cmp(ae)===0)};EC.prototype.recoverPubKey=function(n,t,c,ie){assert$5$1((3&c)===c,"The recovery param is more than two bits"),t=new signature$3(t,ie);var se=this.n,ae=new BN$8(n),ue=t.r,de=t.s,ve=c&1,ge=c>>1;if(ue.cmp(this.curve.p.umod(this.curve.n))>=0&&ge)throw new Error("Unable to find sencond key candinate");ge?ue=this.curve.pointFromX(ue.add(this.curve.n),ve):ue=this.curve.pointFromX(ue,ve);var we=t.r.invm(se),Te=se.sub(ae).mul(we).umod(se),Ne=de.mul(we).umod(se);return this.g.mulAdd(Te,ue,Ne)};EC.prototype.getKeyRecoveryParam=function(n,t,c,ie){if(t=new signature$3(t,ie),t.recoveryParam!==null)return t.recoveryParam;for(var se=0;se<4;se++){var ae;try{ae=this.recoverPubKey(n,t,se)}catch{continue}if(ae.eq(c))return se}throw new Error("Unable to find valid recovery factor")};var elliptic_1=createCommonjsModule(function(n,t){var c=t;c.version="6.6.1",c.utils=utils_1$1$1,c.rand=function(){throw new Error("unsupported")},c.curve=curve_1,c.curves=curves_1,c.ec=ec$1,c.eddsa=null}),EC$1=elliptic_1.ec;const version$j="signing-key/5.8.0",logger$h=new Logger(version$j);let _curve=null;function getCurve(){return _curve||(_curve=new EC$1("secp256k1")),_curve}class SigningKey{constructor(t){defineReadOnly(this,"curve","secp256k1"),defineReadOnly(this,"privateKey",hexlify(t)),hexDataLength(this.privateKey)!==32&&logger$h.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const c=getCurve().keyFromPrivate(arrayify(this.privateKey));defineReadOnly(this,"publicKey","0x"+c.getPublic(!1,"hex")),defineReadOnly(this,"compressedPublicKey","0x"+c.getPublic(!0,"hex")),defineReadOnly(this,"_isSigningKey",!0)}_addPoint(t){const c=getCurve().keyFromPublic(arrayify(this.publicKey)),ie=getCurve().keyFromPublic(arrayify(t));return"0x"+c.pub.add(ie.pub).encodeCompressed("hex")}signDigest(t){const c=getCurve().keyFromPrivate(arrayify(this.privateKey)),ie=arrayify(t);ie.length!==32&&logger$h.throwArgumentError("bad digest length","digest",t);const se=c.sign(ie,{canonical:!0});return splitSignature({recoveryParam:se.recoveryParam,r:hexZeroPad("0x"+se.r.toString(16),32),s:hexZeroPad("0x"+se.s.toString(16),32)})}computeSharedSecret(t){const c=getCurve().keyFromPrivate(arrayify(this.privateKey)),ie=getCurve().keyFromPublic(arrayify(computePublicKey(t)));return hexZeroPad("0x"+c.derive(ie.getPublic()).toString(16),32)}static isSigningKey(t){return!!(t&&t._isSigningKey)}}function recoverPublicKey(n,t){const c=splitSignature(t),ie={r:arrayify(c.r),s:arrayify(c.s)};return"0x"+getCurve().recoverPubKey(arrayify(n),ie,c.recoveryParam).encode("hex",!1)}function computePublicKey(n,t){const c=arrayify(n);if(c.length===32){const ie=new SigningKey(c);return t?"0x"+getCurve().keyFromPrivate(c).getPublic(!0,"hex"):ie.publicKey}else{if(c.length===33)return t?hexlify(c):"0x"+getCurve().keyFromPublic(c).getPublic(!1,"hex");if(c.length===65)return t?"0x"+getCurve().keyFromPublic(c).getPublic(!0,"hex"):hexlify(c)}return logger$h.throwArgumentError("invalid public or private key","key","[REDACTED]")}const lib_esm$a=Object.freeze(Object.defineProperty({__proto__:null,SigningKey,computePublicKey,recoverPublicKey},Symbol.toStringTag,{value:"Module"})),version$i="transactions/5.8.0",logger$g=new Logger(version$i);var TransactionTypes;(function(n){n[n.legacy=0]="legacy",n[n.eip2930=1]="eip2930",n[n.eip1559=2]="eip1559"})(TransactionTypes||(TransactionTypes={}));function handleAddress(n){return n==="0x"?null:getAddress$1(n)}function handleNumber(n){return n==="0x"?Zero$1:BigNumber.from(n)}const transactionFields=[{name:"nonce",maxLength:32,numeric:!0},{name:"gasPrice",maxLength:32,numeric:!0},{name:"gasLimit",maxLength:32,numeric:!0},{name:"to",length:20},{name:"value",maxLength:32,numeric:!0},{name:"data"}],allowedTransactionKeys$1={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,type:!0,value:!0};function computeAddress(n){const t=computePublicKey(n);return getAddress$1(hexDataSlice(keccak256$1(hexDataSlice(t,1)),12))}function recoverAddress(n,t){return computeAddress(recoverPublicKey(arrayify(n),t))}function formatNumber(n,t){const c=stripZeros(BigNumber.from(n).toHexString());return c.length>32&&logger$g.throwArgumentError("invalid length for "+t,"transaction:"+t,n),c}function accessSetify(n,t){return{address:getAddress$1(n),storageKeys:(t||[]).map((c,ie)=>(hexDataLength(c)!==32&&logger$g.throwArgumentError("invalid access list storageKey",`accessList[${n}:${ie}]`,c),c.toLowerCase()))}}function accessListify(n){if(Array.isArray(n))return n.map((c,ie)=>Array.isArray(c)?(c.length>2&&logger$g.throwArgumentError("access list expected to be [ address, storageKeys[] ]",`value[${ie}]`,c),accessSetify(c[0],c[1])):accessSetify(c.address,c.storageKeys));const t=Object.keys(n).map(c=>{const ie=n[c].reduce((se,ae)=>(se[ae]=!0,se),{});return accessSetify(c,Object.keys(ie).sort())});return t.sort((c,ie)=>c.address.localeCompare(ie.address)),t}function formatAccessList(n){return accessListify(n).map(t=>[t.address,t.storageKeys])}function _serializeEip1559(n,t){if(n.gasPrice!=null){const ie=BigNumber.from(n.gasPrice),se=BigNumber.from(n.maxFeePerGas||0);ie.eq(se)||logger$g.throwArgumentError("mismatch EIP-1559 gasPrice != maxFeePerGas","tx",{gasPrice:ie,maxFeePerGas:se})}const c=[formatNumber(n.chainId||0,"chainId"),formatNumber(n.nonce||0,"nonce"),formatNumber(n.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),formatNumber(n.maxFeePerGas||0,"maxFeePerGas"),formatNumber(n.gasLimit||0,"gasLimit"),n.to!=null?getAddress$1(n.to):"0x",formatNumber(n.value||0,"value"),n.data||"0x",formatAccessList(n.accessList||[])];if(t){const ie=splitSignature(t);c.push(formatNumber(ie.recoveryParam,"recoveryParam")),c.push(stripZeros(ie.r)),c.push(stripZeros(ie.s))}return hexConcat(["0x02",encode$6(c)])}function _serializeEip2930(n,t){const c=[formatNumber(n.chainId||0,"chainId"),formatNumber(n.nonce||0,"nonce"),formatNumber(n.gasPrice||0,"gasPrice"),formatNumber(n.gasLimit||0,"gasLimit"),n.to!=null?getAddress$1(n.to):"0x",formatNumber(n.value||0,"value"),n.data||"0x",formatAccessList(n.accessList||[])];if(t){const ie=splitSignature(t);c.push(formatNumber(ie.recoveryParam,"recoveryParam")),c.push(stripZeros(ie.r)),c.push(stripZeros(ie.s))}return hexConcat(["0x01",encode$6(c)])}function _serialize(n,t){checkProperties(n,allowedTransactionKeys$1);const c=[];transactionFields.forEach(function(ue){let de=n[ue.name]||[];const ve={};ue.numeric&&(ve.hexPad="left"),de=arrayify(hexlify(de,ve)),ue.length&&de.length!==ue.length&&de.length>0&&logger$g.throwArgumentError("invalid length for "+ue.name,"transaction:"+ue.name,de),ue.maxLength&&(de=stripZeros(de),de.length>ue.maxLength&&logger$g.throwArgumentError("invalid length for "+ue.name,"transaction:"+ue.name,de)),c.push(hexlify(de))});let ie=0;if(n.chainId!=null?(ie=n.chainId,typeof ie!="number"&&logger$g.throwArgumentError("invalid transaction.chainId","transaction",n)):t&&!isBytesLike(t)&&t.v>28&&(ie=Math.floor((t.v-35)/2)),ie!==0&&(c.push(hexlify(ie)),c.push("0x"),c.push("0x")),!t)return encode$6(c);const se=splitSignature(t);let ae=27+se.recoveryParam;return ie!==0?(c.pop(),c.pop(),c.pop(),ae+=ie*2+8,se.v>28&&se.v!==ae&&logger$g.throwArgumentError("transaction.chainId/signature.v mismatch","signature",t)):se.v!==ae&&logger$g.throwArgumentError("transaction.chainId/signature.v mismatch","signature",t),c.push(hexlify(ae)),c.push(stripZeros(arrayify(se.r))),c.push(stripZeros(arrayify(se.s))),encode$6(c)}function serialize$1$1(n,t){if(n.type==null||n.type===0)return n.accessList!=null&&logger$g.throwArgumentError("untyped transactions do not support accessList; include type: 1","transaction",n),_serialize(n,t);switch(n.type){case 1:return _serializeEip2930(n,t);case 2:return _serializeEip1559(n,t)}return logger$g.throwError(`unsupported transaction type: ${n.type}`,Logger.errors.UNSUPPORTED_OPERATION,{operation:"serializeTransaction",transactionType:n.type})}function _parseEipSignature(n,t,c){try{const ie=handleNumber(t[0]).toNumber();if(ie!==0&&ie!==1)throw new Error("bad recid");n.v=ie}catch{logger$g.throwArgumentError("invalid v for transaction type: 1","v",t[0])}n.r=hexZeroPad(t[1],32),n.s=hexZeroPad(t[2],32);try{const ie=keccak256$1(c(n));n.from=recoverAddress(ie,{r:n.r,s:n.s,recoveryParam:n.v})}catch{}}function _parseEip1559(n){const t=decode$7(n.slice(1));t.length!==9&&t.length!==12&&logger$g.throwArgumentError("invalid component count for transaction type: 2","payload",hexlify(n));const c=handleNumber(t[2]),ie=handleNumber(t[3]),se={type:2,chainId:handleNumber(t[0]).toNumber(),nonce:handleNumber(t[1]).toNumber(),maxPriorityFeePerGas:c,maxFeePerGas:ie,gasPrice:null,gasLimit:handleNumber(t[4]),to:handleAddress(t[5]),value:handleNumber(t[6]),data:t[7],accessList:accessListify(t[8])};return t.length===9||(se.hash=keccak256$1(n),_parseEipSignature(se,t.slice(9),_serializeEip1559)),se}function _parseEip2930(n){const t=decode$7(n.slice(1));t.length!==8&&t.length!==11&&logger$g.throwArgumentError("invalid component count for transaction type: 1","payload",hexlify(n));const c={type:1,chainId:handleNumber(t[0]).toNumber(),nonce:handleNumber(t[1]).toNumber(),gasPrice:handleNumber(t[2]),gasLimit:handleNumber(t[3]),to:handleAddress(t[4]),value:handleNumber(t[5]),data:t[6],accessList:accessListify(t[7])};return t.length===8||(c.hash=keccak256$1(n),_parseEipSignature(c,t.slice(8),_serializeEip2930)),c}function _parse(n){const t=decode$7(n);t.length!==9&&t.length!==6&&logger$g.throwArgumentError("invalid raw transaction","rawTransaction",n);const c={nonce:handleNumber(t[0]).toNumber(),gasPrice:handleNumber(t[1]),gasLimit:handleNumber(t[2]),to:handleAddress(t[3]),value:handleNumber(t[4]),data:t[5],chainId:0};if(t.length===6)return c;try{c.v=BigNumber.from(t[6]).toNumber()}catch{return c}if(c.r=hexZeroPad(t[7],32),c.s=hexZeroPad(t[8],32),BigNumber.from(c.r).isZero()&&BigNumber.from(c.s).isZero())c.chainId=c.v,c.v=0;else{c.chainId=Math.floor((c.v-35)/2),c.chainId<0&&(c.chainId=0);let ie=c.v-27;const se=t.slice(0,6);c.chainId!==0&&(se.push(hexlify(c.chainId)),se.push("0x"),se.push("0x"),ie-=c.chainId*2+8);const ae=keccak256$1(encode$6(se));try{c.from=recoverAddress(ae,{r:hexlify(c.r),s:hexlify(c.s),recoveryParam:ie})}catch{}c.hash=keccak256$1(n)}return c.type=null,c}function parse$2(n){const t=arrayify(n);if(t[0]>127)return _parse(t);switch(t[0]){case 1:return _parseEip2930(t);case 2:return _parseEip1559(t)}return logger$g.throwError(`unsupported transaction type: ${t[0]}`,Logger.errors.UNSUPPORTED_OPERATION,{operation:"parseTransaction",transactionType:t[0]})}const lib_esm$9=Object.freeze(Object.defineProperty({__proto__:null,get TransactionTypes(){return TransactionTypes},accessListify,computeAddress,parse:parse$2,recoverAddress,serialize:serialize$1$1},Symbol.toStringTag,{value:"Module"})),version$h="contracts/5.8.0";var __awaiter$h=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$f=new Logger(version$h);function resolveName(n,t){return __awaiter$h(this,void 0,void 0,function*(){const c=yield t;typeof c!="string"&&logger$f.throwArgumentError("invalid address or ENS name","name",c);try{return getAddress$1(c)}catch{}n||logger$f.throwError("a provider or signer is needed to resolve ENS names",Logger.errors.UNSUPPORTED_OPERATION,{operation:"resolveName"});const ie=yield n.resolveName(c);return ie==null&&logger$f.throwArgumentError("resolver or addr is not configured for ENS name","name",c),ie})}function resolveAddresses(n,t,c){return __awaiter$h(this,void 0,void 0,function*(){return Array.isArray(c)?yield Promise.all(c.map((ie,se)=>resolveAddresses(n,Array.isArray(t)?t[se]:t[ie.name],ie))):c.type==="address"?yield resolveName(n,t):c.type==="tuple"?yield resolveAddresses(n,t,c.components):c.baseType==="array"?Array.isArray(t)?yield Promise.all(t.map(ie=>resolveAddresses(n,ie,c.arrayChildren))):Promise.reject(logger$f.makeError("invalid value for array",Logger.errors.INVALID_ARGUMENT,{argument:"value",value:t})):t})}function populateTransaction(n,t,c){return __awaiter$h(this,void 0,void 0,function*(){let ie={};c.length===t.inputs.length+1&&typeof c[c.length-1]=="object"&&(ie=shallowCopy(c.pop())),logger$f.checkArgumentCount(c.length,t.inputs.length,"passed to contract"),n.signer?ie.from?ie.from=resolveProperties({override:resolveName(n.signer,ie.from),signer:n.signer.getAddress()}).then(ge=>__awaiter$h(this,void 0,void 0,function*(){return getAddress$1(ge.signer)!==ge.override&&logger$f.throwError("Contract with a Signer cannot override from",Logger.errors.UNSUPPORTED_OPERATION,{operation:"overrides.from"}),ge.override})):ie.from=n.signer.getAddress():ie.from&&(ie.from=resolveName(n.provider,ie.from));const se=yield resolveProperties({args:resolveAddresses(n.signer||n.provider,c,t.inputs),address:n.resolvedAddress,overrides:resolveProperties(ie)||{}}),ae=n.interface.encodeFunctionData(t,se.args),ue={data:ae,to:se.address},de=se.overrides;if(de.nonce!=null&&(ue.nonce=BigNumber.from(de.nonce).toNumber()),de.gasLimit!=null&&(ue.gasLimit=BigNumber.from(de.gasLimit)),de.gasPrice!=null&&(ue.gasPrice=BigNumber.from(de.gasPrice)),de.maxFeePerGas!=null&&(ue.maxFeePerGas=BigNumber.from(de.maxFeePerGas)),de.maxPriorityFeePerGas!=null&&(ue.maxPriorityFeePerGas=BigNumber.from(de.maxPriorityFeePerGas)),de.from!=null&&(ue.from=de.from),de.type!=null&&(ue.type=de.type),de.accessList!=null&&(ue.accessList=accessListify(de.accessList)),ue.gasLimit==null&&t.gas!=null){let ge=21e3;const we=arrayify(ae);for(let Te=0;Te<we.length;Te++)ge+=4,we[Te]&&(ge+=64);ue.gasLimit=BigNumber.from(t.gas).add(ge)}if(de.value){const ge=BigNumber.from(de.value);!ge.isZero()&&!t.payable&&logger$f.throwError("non-payable method cannot override value",Logger.errors.UNSUPPORTED_OPERATION,{operation:"overrides.value",value:ie.value}),ue.value=ge}de.customData&&(ue.customData=shallowCopy(de.customData)),de.ccipReadEnabled&&(ue.ccipReadEnabled=!!de.ccipReadEnabled),delete ie.nonce,delete ie.gasLimit,delete ie.gasPrice,delete ie.from,delete ie.value,delete ie.type,delete ie.accessList,delete ie.maxFeePerGas,delete ie.maxPriorityFeePerGas,delete ie.customData,delete ie.ccipReadEnabled;const ve=Object.keys(ie).filter(ge=>ie[ge]!=null);return ve.length&&logger$f.throwError(`cannot override ${ve.map(ge=>JSON.stringify(ge)).join(",")}`,Logger.errors.UNSUPPORTED_OPERATION,{operation:"overrides",overrides:ve}),ue})}function buildPopulate(n,t){return function(...c){return populateTransaction(n,t,c)}}function buildEstimate(n,t){const c=n.signer||n.provider;return function(...ie){return __awaiter$h(this,void 0,void 0,function*(){c||logger$f.throwError("estimate require a provider or signer",Logger.errors.UNSUPPORTED_OPERATION,{operation:"estimateGas"});const se=yield populateTransaction(n,t,ie);return yield c.estimateGas(se)})}}function addContractWait(n,t){const c=t.wait.bind(t);t.wait=ie=>c(ie).then(se=>(se.events=se.logs.map(ae=>{let ue=deepCopy(ae),de=null;try{de=n.interface.parseLog(ae)}catch{}return de&&(ue.args=de.args,ue.decode=(ve,ge)=>n.interface.decodeEventLog(de.eventFragment,ve,ge),ue.event=de.name,ue.eventSignature=de.signature),ue.removeListener=()=>n.provider,ue.getBlock=()=>n.provider.getBlock(se.blockHash),ue.getTransaction=()=>n.provider.getTransaction(se.transactionHash),ue.getTransactionReceipt=()=>Promise.resolve(se),ue}),se))}function buildCall(n,t,c){const ie=n.signer||n.provider;return function(...se){return __awaiter$h(this,void 0,void 0,function*(){let ae;if(se.length===t.inputs.length+1&&typeof se[se.length-1]=="object"){const ve=shallowCopy(se.pop());ve.blockTag!=null&&(ae=yield ve.blockTag),delete ve.blockTag,se.push(ve)}n.deployTransaction!=null&&(yield n._deployed(ae));const ue=yield populateTransaction(n,t,se),de=yield ie.call(ue,ae);try{let ve=n.interface.decodeFunctionResult(t,de);return c&&t.outputs.length===1&&(ve=ve[0]),ve}catch(ve){throw ve.code===Logger.errors.CALL_EXCEPTION&&(ve.address=n.address,ve.args=se,ve.transaction=ue),ve}})}}function buildSend(n,t){return function(...c){return __awaiter$h(this,void 0,void 0,function*(){n.signer||logger$f.throwError("sending a transaction requires a signer",Logger.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction"}),n.deployTransaction!=null&&(yield n._deployed());const ie=yield populateTransaction(n,t,c),se=yield n.signer.sendTransaction(ie);return addContractWait(n,se),se})}}function buildDefault(n,t,c){return t.constant?buildCall(n,t,c):buildSend(n,t)}function getEventTag$1(n){return n.address&&(n.topics==null||n.topics.length===0)?"*":(n.address||"*")+"@"+(n.topics?n.topics.map(t=>Array.isArray(t)?t.join("|"):t).join(":"):"")}class RunningEvent{constructor(t,c){defineReadOnly(this,"tag",t),defineReadOnly(this,"filter",c),this._listeners=[]}addListener(t,c){this._listeners.push({listener:t,once:c})}removeListener(t){let c=!1;this._listeners=this._listeners.filter(ie=>c||ie.listener!==t?!0:(c=!0,!1))}removeAllListeners(){this._listeners=[]}listeners(){return this._listeners.map(t=>t.listener)}listenerCount(){return this._listeners.length}run(t){const c=this.listenerCount();return this._listeners=this._listeners.filter(ie=>{const se=t.slice();return setTimeout(()=>{ie.listener.apply(this,se)},0),!ie.once}),c}prepareEvent(t){}getEmit(t){return[t]}}class ErrorRunningEvent extends RunningEvent{constructor(){super("error",null)}}class FragmentRunningEvent extends RunningEvent{constructor(t,c,ie,se){const ae={address:t};let ue=c.getEventTopic(ie);se?(ue!==se[0]&&logger$f.throwArgumentError("topic mismatch","topics",se),ae.topics=se.slice()):ae.topics=[ue],super(getEventTag$1(ae),ae),defineReadOnly(this,"address",t),defineReadOnly(this,"interface",c),defineReadOnly(this,"fragment",ie)}prepareEvent(t){super.prepareEvent(t),t.event=this.fragment.name,t.eventSignature=this.fragment.format(),t.decode=(c,ie)=>this.interface.decodeEventLog(this.fragment,c,ie);try{t.args=this.interface.decodeEventLog(this.fragment,t.data,t.topics)}catch(c){t.args=null,t.decodeError=c}}getEmit(t){const c=checkResultErrors(t.args);if(c.length)throw c[0].error;const ie=(t.args||[]).slice();return ie.push(t),ie}}class WildcardRunningEvent extends RunningEvent{constructor(t,c){super("*",{address:t}),defineReadOnly(this,"address",t),defineReadOnly(this,"interface",c)}prepareEvent(t){super.prepareEvent(t);try{const c=this.interface.parseLog(t);t.event=c.name,t.eventSignature=c.signature,t.decode=(ie,se)=>this.interface.decodeEventLog(c.eventFragment,ie,se),t.args=c.args}catch{}}}class BaseContract{constructor(t,c,ie){defineReadOnly(this,"interface",getStatic(new.target,"getInterface")(c)),ie==null?(defineReadOnly(this,"provider",null),defineReadOnly(this,"signer",null)):Signer.isSigner(ie)?(defineReadOnly(this,"provider",ie.provider||null),defineReadOnly(this,"signer",ie)):Provider.isProvider(ie)?(defineReadOnly(this,"provider",ie),defineReadOnly(this,"signer",null)):logger$f.throwArgumentError("invalid signer or provider","signerOrProvider",ie),defineReadOnly(this,"callStatic",{}),defineReadOnly(this,"estimateGas",{}),defineReadOnly(this,"functions",{}),defineReadOnly(this,"populateTransaction",{}),defineReadOnly(this,"filters",{});{const ue={};Object.keys(this.interface.events).forEach(de=>{const ve=this.interface.events[de];defineReadOnly(this.filters,de,(...ge)=>({address:this.address,topics:this.interface.encodeFilterTopics(ve,ge)})),ue[ve.name]||(ue[ve.name]=[]),ue[ve.name].push(de)}),Object.keys(ue).forEach(de=>{const ve=ue[de];ve.length===1?defineReadOnly(this.filters,de,this.filters[ve[0]]):logger$f.warn(`Duplicate definition of ${de} (${ve.join(", ")})`)})}if(defineReadOnly(this,"_runningEvents",{}),defineReadOnly(this,"_wrappedEmits",{}),t==null&&logger$f.throwArgumentError("invalid contract address or ENS name","addressOrName",t),defineReadOnly(this,"address",t),this.provider)defineReadOnly(this,"resolvedAddress",resolveName(this.provider,t));else try{defineReadOnly(this,"resolvedAddress",Promise.resolve(getAddress$1(t)))}catch{logger$f.throwError("provider is required to use ENS name as contract address",Logger.errors.UNSUPPORTED_OPERATION,{operation:"new Contract"})}this.resolvedAddress.catch(ue=>{});const se={},ae={};Object.keys(this.interface.functions).forEach(ue=>{const de=this.interface.functions[ue];if(ae[ue]){logger$f.warn(`Duplicate ABI entry for ${JSON.stringify(ue)}`);return}ae[ue]=!0;{const ve=de.name;se[`%${ve}`]||(se[`%${ve}`]=[]),se[`%${ve}`].push(ue)}this[ue]==null&&defineReadOnly(this,ue,buildDefault(this,de,!0)),this.functions[ue]==null&&defineReadOnly(this.functions,ue,buildDefault(this,de,!1)),this.callStatic[ue]==null&&defineReadOnly(this.callStatic,ue,buildCall(this,de,!0)),this.populateTransaction[ue]==null&&defineReadOnly(this.populateTransaction,ue,buildPopulate(this,de)),this.estimateGas[ue]==null&&defineReadOnly(this.estimateGas,ue,buildEstimate(this,de))}),Object.keys(se).forEach(ue=>{const de=se[ue];if(de.length>1)return;ue=ue.substring(1);const ve=de[0];try{this[ue]==null&&defineReadOnly(this,ue,this[ve])}catch{}this.functions[ue]==null&&defineReadOnly(this.functions,ue,this.functions[ve]),this.callStatic[ue]==null&&defineReadOnly(this.callStatic,ue,this.callStatic[ve]),this.populateTransaction[ue]==null&&defineReadOnly(this.populateTransaction,ue,this.populateTransaction[ve]),this.estimateGas[ue]==null&&defineReadOnly(this.estimateGas,ue,this.estimateGas[ve])})}static getContractAddress(t){return getContractAddress(t)}static getInterface(t){return Interface.isInterface(t)?t:new Interface(t)}deployed(){return this._deployed()}_deployed(t){return this._deployedPromise||(this.deployTransaction?this._deployedPromise=this.deployTransaction.wait().then(()=>this):this._deployedPromise=this.provider.getCode(this.address,t).then(c=>(c==="0x"&&logger$f.throwError("contract not deployed",Logger.errors.UNSUPPORTED_OPERATION,{contractAddress:this.address,operation:"getDeployed"}),this))),this._deployedPromise}fallback(t){this.signer||logger$f.throwError("sending a transactions require a signer",Logger.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction(fallback)"});const c=shallowCopy(t||{});return["from","to"].forEach(function(ie){c[ie]!=null&&logger$f.throwError("cannot override "+ie,Logger.errors.UNSUPPORTED_OPERATION,{operation:ie})}),c.to=this.resolvedAddress,this.deployed().then(()=>this.signer.sendTransaction(c))}connect(t){typeof t=="string"&&(t=new VoidSigner(t,this.provider));const c=new this.constructor(this.address,this.interface,t);return this.deployTransaction&&defineReadOnly(c,"deployTransaction",this.deployTransaction),c}attach(t){return new this.constructor(t,this.interface,this.signer||this.provider)}static isIndexed(t){return Indexed.isIndexed(t)}_normalizeRunningEvent(t){return this._runningEvents[t.tag]?this._runningEvents[t.tag]:t}_getRunningEvent(t){if(typeof t=="string"){if(t==="error")return this._normalizeRunningEvent(new ErrorRunningEvent);if(t==="event")return this._normalizeRunningEvent(new RunningEvent("event",null));if(t==="*")return this._normalizeRunningEvent(new WildcardRunningEvent(this.address,this.interface));const c=this.interface.getEvent(t);return this._normalizeRunningEvent(new FragmentRunningEvent(this.address,this.interface,c))}if(t.topics&&t.topics.length>0){try{const ie=t.topics[0];if(typeof ie!="string")throw new Error("invalid topic");const se=this.interface.getEvent(ie);return this._normalizeRunningEvent(new FragmentRunningEvent(this.address,this.interface,se,t.topics))}catch{}const c={address:this.address,topics:t.topics};return this._normalizeRunningEvent(new RunningEvent(getEventTag$1(c),c))}return this._normalizeRunningEvent(new WildcardRunningEvent(this.address,this.interface))}_checkRunningEvents(t){if(t.listenerCount()===0){delete this._runningEvents[t.tag];const c=this._wrappedEmits[t.tag];c&&t.filter&&(this.provider.off(t.filter,c),delete this._wrappedEmits[t.tag])}}_wrapEvent(t,c,ie){const se=deepCopy(c);return se.removeListener=()=>{ie&&(t.removeListener(ie),this._checkRunningEvents(t))},se.getBlock=()=>this.provider.getBlock(c.blockHash),se.getTransaction=()=>this.provider.getTransaction(c.transactionHash),se.getTransactionReceipt=()=>this.provider.getTransactionReceipt(c.transactionHash),t.prepareEvent(se),se}_addEventListener(t,c,ie){if(this.provider||logger$f.throwError("events require a provider or a signer with a provider",Logger.errors.UNSUPPORTED_OPERATION,{operation:"once"}),t.addListener(c,ie),this._runningEvents[t.tag]=t,!this._wrappedEmits[t.tag]){const se=ae=>{let ue=this._wrapEvent(t,ae,c);if(ue.decodeError==null)try{const de=t.getEmit(ue);this.emit(t.filter,...de)}catch(de){ue.decodeError=de.error}t.filter!=null&&this.emit("event",ue),ue.decodeError!=null&&this.emit("error",ue.decodeError,ue)};this._wrappedEmits[t.tag]=se,t.filter!=null&&this.provider.on(t.filter,se)}}queryFilter(t,c,ie){const se=this._getRunningEvent(t),ae=shallowCopy(se.filter);return typeof c=="string"&&isHexString(c,32)?(ie!=null&&logger$f.throwArgumentError("cannot specify toBlock with blockhash","toBlock",ie),ae.blockHash=c):(ae.fromBlock=c??0,ae.toBlock=ie??"latest"),this.provider.getLogs(ae).then(ue=>ue.map(de=>this._wrapEvent(se,de,null)))}on(t,c){return this._addEventListener(this._getRunningEvent(t),c,!1),this}once(t,c){return this._addEventListener(this._getRunningEvent(t),c,!0),this}emit(t,...c){if(!this.provider)return!1;const ie=this._getRunningEvent(t),se=ie.run(c)>0;return this._checkRunningEvents(ie),se}listenerCount(t){return this.provider?t==null?Object.keys(this._runningEvents).reduce((c,ie)=>c+this._runningEvents[ie].listenerCount(),0):this._getRunningEvent(t).listenerCount():0}listeners(t){if(!this.provider)return[];if(t==null){const c=[];for(let ie in this._runningEvents)this._runningEvents[ie].listeners().forEach(se=>{c.push(se)});return c}return this._getRunningEvent(t).listeners()}removeAllListeners(t){if(!this.provider)return this;if(t==null){for(const ie in this._runningEvents){const se=this._runningEvents[ie];se.removeAllListeners(),this._checkRunningEvents(se)}return this}const c=this._getRunningEvent(t);return c.removeAllListeners(),this._checkRunningEvents(c),this}off(t,c){if(!this.provider)return this;const ie=this._getRunningEvent(t);return ie.removeListener(c),this._checkRunningEvents(ie),this}removeListener(t,c){return this.off(t,c)}}class Contract extends BaseContract{}class BaseX{constructor(t){defineReadOnly(this,"alphabet",t),defineReadOnly(this,"base",t.length),defineReadOnly(this,"_alphabetMap",{}),defineReadOnly(this,"_leader",t.charAt(0));for(let c=0;c<t.length;c++)this._alphabetMap[t.charAt(c)]=c}encode(t){let c=arrayify(t);if(c.length===0)return"";let ie=[0];for(let ae=0;ae<c.length;++ae){let ue=c[ae];for(let de=0;de<ie.length;++de)ue+=ie[de]<<8,ie[de]=ue%this.base,ue=ue/this.base|0;for(;ue>0;)ie.push(ue%this.base),ue=ue/this.base|0}let se="";for(let ae=0;c[ae]===0&&ae<c.length-1;++ae)se+=this._leader;for(let ae=ie.length-1;ae>=0;--ae)se+=this.alphabet[ie[ae]];return se}decode(t){if(typeof t!="string")throw new TypeError("Expected String");let c=[];if(t.length===0)return new Uint8Array(c);c.push(0);for(let ie=0;ie<t.length;ie++){let se=this._alphabetMap[t[ie]];if(se===void 0)throw new Error("Non-base"+this.base+" character");let ae=se;for(let ue=0;ue<c.length;++ue)ae+=c[ue]*this.base,c[ue]=ae&255,ae>>=8;for(;ae>0;)c.push(ae&255),ae>>=8}for(let ie=0;t[ie]===this._leader&&ie<t.length-1;++ie)c.push(0);return arrayify(new Uint8Array(c.reverse()))}}const Base32=new BaseX("abcdefghijklmnopqrstuvwxyz234567"),Base58=new BaseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),lib_esm$8=Object.freeze(Object.defineProperty({__proto__:null,Base32,Base58,BaseX},Symbol.toStringTag,{value:"Module"}));var SupportedAlgorithm;(function(n){n.sha256="sha256",n.sha512="sha512"})(SupportedAlgorithm||(SupportedAlgorithm={}));const version$g="sha2/5.8.0",logger$e=new Logger(version$g);function ripemd160$1(n){return"0x"+hash$3.ripemd160().update(arrayify(n)).digest("hex")}function sha256$7(n){return"0x"+hash$3.sha256().update(arrayify(n)).digest("hex")}function sha512$4(n){return"0x"+hash$3.sha512().update(arrayify(n)).digest("hex")}function computeHmac(n,t,c){return SupportedAlgorithm[n]||logger$e.throwError("unsupported algorithm "+n,Logger.errors.UNSUPPORTED_OPERATION,{operation:"hmac",algorithm:n}),"0x"+hash$3.hmac(hash$3[n],arrayify(t)).update(arrayify(c)).digest("hex")}const lib_esm$7=Object.freeze(Object.defineProperty({__proto__:null,get SupportedAlgorithm(){return SupportedAlgorithm},computeHmac,ripemd160:ripemd160$1,sha256:sha256$7,sha512:sha512$4},Symbol.toStringTag,{value:"Module"}));function pbkdf2$1(n,t,c,ie,se){n=arrayify(n),t=arrayify(t);let ae,ue=1;const de=new Uint8Array(ie),ve=new Uint8Array(t.length+4);ve.set(t);let ge,we;for(let Te=1;Te<=ue;Te++){ve[t.length]=Te>>24&255,ve[t.length+1]=Te>>16&255,ve[t.length+2]=Te>>8&255,ve[t.length+3]=Te&255;let Ne=arrayify(computeHmac(se,n,ve));ae||(ae=Ne.length,we=new Uint8Array(ae),ue=Math.ceil(ie/ae),ge=ie-(ue-1)*ae),we.set(Ne);for(let He=1;He<c;He++){Ne=arrayify(computeHmac(se,n,Ne));for(let Ge=0;Ge<ae;Ge++)we[Ge]^=Ne[Ge]}const qe=(Te-1)*ae,ze=Te===ue?ge:ae;de.set(arrayify(we).slice(0,ze),qe)}return hexlify(de)}const version$f="wordlists/5.8.0",logger$d=new Logger(version$f);class Wordlist{constructor(t){logger$d.checkAbstract(new.target,Wordlist),defineReadOnly(this,"locale",t)}split(t){return t.toLowerCase().split(/ +/g)}join(t){return t.join(" ")}static check(t){const c=[];for(let ie=0;ie<2048;ie++){const se=t.getWord(ie);if(ie!==t.getWordIndex(se))return"0x";c.push(se)}return id(c.join(`
12
12
  `)+`
13
- `)}static register(t,c){c||(c=t.locale)}}const words="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo";let wordlist=null;function loadWords(n){if(wordlist==null&&(wordlist=words.replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),Wordlist.check(n)!=="0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"))throw wordlist=null,new Error("BIP39 Wordlist for en (English) FAILED")}class LangEn extends Wordlist{constructor(){super("en")}getWord(t){return loadWords(this),wordlist[t]}getWordIndex(t){return loadWords(this),wordlist.indexOf(t)}}const langEn=new LangEn;Wordlist.register(langEn);const wordlists={en:langEn},version$e="hdnode/5.8.0",logger$c=new Logger(version$e),N$3=BigNumber.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),MasterSecret=toUtf8Bytes("Bitcoin seed"),HardenedBit=2147483648;function getUpperMask(n){return(1<<n)-1<<8-n}function getLowerMask(n){return(1<<n)-1}function bytes32(n){return hexZeroPad(hexlify(n),32)}function base58check(n){return Base58.encode(concat$1([n,hexDataSlice(sha256$7(sha256$7(n)),0,4)]))}function getWordlist(n){if(n==null)return wordlists.en;if(typeof n=="string"){const t=wordlists[n];return t==null&&logger$c.throwArgumentError("unknown locale","wordlist",n),t}return n}const _constructorGuard$1={},defaultPath="m/44'/60'/0'/0/0";class HDNode{constructor(t,c,ie,se,ae,ue,de,ve){if(t!==_constructorGuard$1)throw new Error("HDNode constructor cannot be called directly");if(c){const ge=new SigningKey(c);defineReadOnly(this,"privateKey",ge.privateKey),defineReadOnly(this,"publicKey",ge.compressedPublicKey)}else defineReadOnly(this,"privateKey",null),defineReadOnly(this,"publicKey",hexlify(ie));defineReadOnly(this,"parentFingerprint",se),defineReadOnly(this,"fingerprint",hexDataSlice(ripemd160$1(sha256$7(this.publicKey)),0,4)),defineReadOnly(this,"address",computeAddress(this.publicKey)),defineReadOnly(this,"chainCode",ae),defineReadOnly(this,"index",ue),defineReadOnly(this,"depth",de),ve==null?(defineReadOnly(this,"mnemonic",null),defineReadOnly(this,"path",null)):typeof ve=="string"?(defineReadOnly(this,"mnemonic",null),defineReadOnly(this,"path",ve)):(defineReadOnly(this,"mnemonic",ve),defineReadOnly(this,"path",ve.path))}get extendedKey(){if(this.depth>=256)throw new Error("Depth too large!");return base58check(concat$1([this.privateKey!=null?"0x0488ADE4":"0x0488B21E",hexlify(this.depth),this.parentFingerprint,hexZeroPad(hexlify(this.index),4),this.chainCode,this.privateKey!=null?concat$1(["0x00",this.privateKey]):this.publicKey]))}neuter(){return new HDNode(_constructorGuard$1,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,this.path)}_derive(t){if(t>4294967295)throw new Error("invalid index - "+String(t));let c=this.path;c&&(c+="/"+(t&~HardenedBit));const ie=new Uint8Array(37);if(t&HardenedBit){if(!this.privateKey)throw new Error("cannot derive child of neutered node");ie.set(arrayify(this.privateKey),1),c&&(c+="'")}else ie.set(arrayify(this.publicKey));for(let Te=24;Te>=0;Te-=8)ie[33+(Te>>3)]=t>>24-Te&255;const se=arrayify(computeHmac(SupportedAlgorithm.sha512,this.chainCode,ie)),ae=se.slice(0,32),ue=se.slice(32);let de=null,ve=null;this.privateKey?de=bytes32(BigNumber.from(ae).add(this.privateKey).mod(N$3)):ve=new SigningKey(hexlify(ae))._addPoint(this.publicKey);let ge=c;const we=this.mnemonic;return we&&(ge=Object.freeze({phrase:we.phrase,path:c,locale:we.locale||"en"})),new HDNode(_constructorGuard$1,de,ve,this.fingerprint,bytes32(ue),t,this.depth+1,ge)}derivePath(t){const c=t.split("/");if(c.length===0||c[0]==="m"&&this.depth!==0)throw new Error("invalid path - "+t);c[0]==="m"&&c.shift();let ie=this;for(let se=0;se<c.length;se++){const ae=c[se];if(ae.match(/^[0-9]+'$/)){const ue=parseInt(ae.substring(0,ae.length-1));if(ue>=HardenedBit)throw new Error("invalid path index - "+ae);ie=ie._derive(HardenedBit+ue)}else if(ae.match(/^[0-9]+$/)){const ue=parseInt(ae);if(ue>=HardenedBit)throw new Error("invalid path index - "+ae);ie=ie._derive(ue)}else throw new Error("invalid path component - "+ae)}return ie}static _fromSeed(t,c){const ie=arrayify(t);if(ie.length<16||ie.length>64)throw new Error("invalid seed");const se=arrayify(computeHmac(SupportedAlgorithm.sha512,MasterSecret,ie));return new HDNode(_constructorGuard$1,bytes32(se.slice(0,32)),null,"0x00000000",bytes32(se.slice(32)),0,0,c)}static fromMnemonic(t,c,ie){return ie=getWordlist(ie),t=entropyToMnemonic(mnemonicToEntropy(t,ie),ie),HDNode._fromSeed(mnemonicToSeed(t,c),{phrase:t,path:"m",locale:ie.locale})}static fromSeed(t){return HDNode._fromSeed(t,null)}static fromExtendedKey(t){const c=Base58.decode(t);(c.length!==82||base58check(c.slice(0,78))!==t)&&logger$c.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");const ie=c[4],se=hexlify(c.slice(5,9)),ae=parseInt(hexlify(c.slice(9,13)).substring(2),16),ue=hexlify(c.slice(13,45)),de=c.slice(45,78);switch(hexlify(c.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new HDNode(_constructorGuard$1,null,hexlify(de),se,ue,ae,ie,null);case"0x0488ade4":case"0x04358394 ":if(de[0]!==0)break;return new HDNode(_constructorGuard$1,hexlify(de.slice(1)),null,se,ue,ae,ie,null)}return logger$c.throwArgumentError("invalid extended key","extendedKey","[REDACTED]")}}function mnemonicToSeed(n,t){t||(t="");const c=toUtf8Bytes("mnemonic"+t,UnicodeNormalizationForm.NFKD);return pbkdf2$1(toUtf8Bytes(n,UnicodeNormalizationForm.NFKD),c,2048,64,"sha512")}function mnemonicToEntropy(n,t){t=getWordlist(t),logger$c.checkNormalize();const c=t.split(n);if(c.length%3!==0)throw new Error("invalid mnemonic");const ie=arrayify(new Uint8Array(Math.ceil(11*c.length/8)));let se=0;for(let ve=0;ve<c.length;ve++){let ge=t.getWordIndex(c[ve].normalize("NFKD"));if(ge===-1)throw new Error("invalid mnemonic");for(let we=0;we<11;we++)ge&1<<10-we&&(ie[se>>3]|=1<<7-se%8),se++}const ae=32*c.length/3,ue=c.length/3,de=getUpperMask(ue);if((arrayify(sha256$7(ie.slice(0,ae/8)))[0]&de)!==(ie[ie.length-1]&de))throw new Error("invalid checksum");return hexlify(ie.slice(0,ae/8))}function entropyToMnemonic(n,t){if(t=getWordlist(t),n=arrayify(n),n.length%4!==0||n.length<16||n.length>32)throw new Error("invalid entropy");const c=[0];let ie=11;for(let ue=0;ue<n.length;ue++)ie>8?(c[c.length-1]<<=8,c[c.length-1]|=n[ue],ie-=8):(c[c.length-1]<<=ie,c[c.length-1]|=n[ue]>>8-ie,c.push(n[ue]&getLowerMask(8-ie)),ie+=3);const se=n.length/4,ae=arrayify(sha256$7(n))[0]&getUpperMask(se);return c[c.length-1]<<=se,c[c.length-1]|=ae>>8-se,t.join(c.map(ue=>t.getWord(ue)))}function isValidMnemonic(n,t){try{return mnemonicToEntropy(n,t),!0}catch{}return!1}function getAccountPath(n){return(typeof n!="number"||n<0||n>=HardenedBit||n%1)&&logger$c.throwArgumentError("invalid account index","index",n),`m/44'/60'/${n}'/0/0`}const lib_esm$6=Object.freeze(Object.defineProperty({__proto__:null,HDNode,defaultPath,entropyToMnemonic,getAccountPath,isValidMnemonic,mnemonicToEntropy,mnemonicToSeed},Symbol.toStringTag,{value:"Module"})),version$d="random/5.8.0",logger$b=new Logger(version$d);function getGlobal(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof globalThis<"u")return globalThis;throw new Error("unable to locate global object")}const anyGlobal=getGlobal();let crypto$3=anyGlobal.crypto||anyGlobal.msCrypto;(!crypto$3||!crypto$3.getRandomValues)&&(logger$b.warn("WARNING: Missing strong random number source"),crypto$3={getRandomValues:function(n){return logger$b.throwError("no secure random source avaialble",Logger.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}});function randomBytes$1(n){(n<=0||n>1024||n%1||n!=n)&&logger$b.throwArgumentError("invalid length","length",n);const t=new Uint8Array(n);return crypto$3.getRandomValues(t),arrayify(t)}function shuffled(n){n=n.slice();for(let t=n.length-1;t>0;t--){const c=Math.floor(Math.random()*(t+1)),ie=n[t];n[t]=n[c],n[c]=ie}return n}const lib_esm$5=Object.freeze(Object.defineProperty({__proto__:null,randomBytes:randomBytes$1,shuffled},Symbol.toStringTag,{value:"Module"}));var aesJs={exports:{}};(function(n,t){(function(c){function ie(We){return parseInt(We)===We}function se(We){if(!ie(We.length))return!1;for(var $t=0;$t<We.length;$t++)if(!ie(We[$t])||We[$t]<0||We[$t]>255)return!1;return!0}function ae(We,$t){if(We.buffer&&ArrayBuffer.isView(We)&&We.name==="Uint8Array")return $t&&(We.slice?We=We.slice():We=Array.prototype.slice.call(We)),We;if(Array.isArray(We)){if(!se(We))throw new Error("Array contains invalid value: "+We);return new Uint8Array(We)}if(ie(We.length)&&se(We))return new Uint8Array(We);throw new Error("unsupported array-like object")}function ue(We){return new Uint8Array(We)}function de(We,$t,dn,gn,Vt){(gn!=null||Vt!=null)&&(We.slice?We=We.slice(gn,Vt):We=Array.prototype.slice.call(We,gn,Vt)),$t.set(We,dn)}var ve=(function(){function We(dn){var gn=[],Vt=0;for(dn=encodeURI(dn);Vt<dn.length;){var Cn=dn.charCodeAt(Vt++);Cn===37?(gn.push(parseInt(dn.substr(Vt,2),16)),Vt+=2):gn.push(Cn)}return ae(gn)}function $t(dn){for(var gn=[],Vt=0;Vt<dn.length;){var Cn=dn[Vt];Cn<128?(gn.push(String.fromCharCode(Cn)),Vt++):Cn>191&&Cn<224?(gn.push(String.fromCharCode((Cn&31)<<6|dn[Vt+1]&63)),Vt+=2):(gn.push(String.fromCharCode((Cn&15)<<12|(dn[Vt+1]&63)<<6|dn[Vt+2]&63)),Vt+=3)}return gn.join("")}return{toBytes:We,fromBytes:$t}})(),ge=(function(){function We(gn){for(var Vt=[],Cn=0;Cn<gn.length;Cn+=2)Vt.push(parseInt(gn.substr(Cn,2),16));return Vt}var $t="0123456789abcdef";function dn(gn){for(var Vt=[],Cn=0;Cn<gn.length;Cn++){var un=gn[Cn];Vt.push($t[(un&240)>>4]+$t[un&15])}return Vt.join("")}return{toBytes:We,fromBytes:dn}})(),we={16:10,24:12,32:14},Te=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],Ne=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],qe=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],ze=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],He=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],Ge=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],Ze=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],Ye=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],Ft=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],Mt=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],Zt=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],cn=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],hn=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],yn=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],Ht=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function Sn(We){for(var $t=[],dn=0;dn<We.length;dn+=4)$t.push(We[dn]<<24|We[dn+1]<<16|We[dn+2]<<8|We[dn+3]);return $t}var le=function(We){if(!(this instanceof le))throw Error("AES must be instanitated with `new`");Object.defineProperty(this,"key",{value:ae(We,!0)}),this._prepare()};le.prototype._prepare=function(){var We=we[this.key.length];if(We==null)throw new Error("invalid key size (must be 16, 24 or 32 bytes)");this._Ke=[],this._Kd=[];for(var $t=0;$t<=We;$t++)this._Ke.push([0,0,0,0]),this._Kd.push([0,0,0,0]);for(var dn=(We+1)*4,gn=this.key.length/4,Vt=Sn(this.key),Cn,$t=0;$t<gn;$t++)Cn=$t>>2,this._Ke[Cn][$t%4]=Vt[$t],this._Kd[We-Cn][$t%4]=Vt[$t];for(var un=0,Pt=gn,mn;Pt<dn;){if(mn=Vt[gn-1],Vt[0]^=Ne[mn>>16&255]<<24^Ne[mn>>8&255]<<16^Ne[mn&255]<<8^Ne[mn>>24&255]^Te[un]<<24,un+=1,gn!=8)for(var $t=1;$t<gn;$t++)Vt[$t]^=Vt[$t-1];else{for(var $t=1;$t<gn/2;$t++)Vt[$t]^=Vt[$t-1];mn=Vt[gn/2-1],Vt[gn/2]^=Ne[mn&255]^Ne[mn>>8&255]<<8^Ne[mn>>16&255]<<16^Ne[mn>>24&255]<<24;for(var $t=gn/2+1;$t<gn;$t++)Vt[$t]^=Vt[$t-1]}for(var $t=0,Pn,wn;$t<gn&&Pt<dn;)Pn=Pt>>2,wn=Pt%4,this._Ke[Pn][wn]=Vt[$t],this._Kd[We-Pn][wn]=Vt[$t++],Pt++}for(var Pn=1;Pn<We;Pn++)for(var wn=0;wn<4;wn++)mn=this._Kd[Pn][wn],this._Kd[Pn][wn]=cn[mn>>24&255]^hn[mn>>16&255]^yn[mn>>8&255]^Ht[mn&255]},le.prototype.encrypt=function(We){if(We.length!=16)throw new Error("invalid plaintext size (must be 16 bytes)");for(var $t=this._Ke.length-1,dn=[0,0,0,0],gn=Sn(We),Vt=0;Vt<4;Vt++)gn[Vt]^=this._Ke[0][Vt];for(var Cn=1;Cn<$t;Cn++){for(var Vt=0;Vt<4;Vt++)dn[Vt]=ze[gn[Vt]>>24&255]^He[gn[(Vt+1)%4]>>16&255]^Ge[gn[(Vt+2)%4]>>8&255]^Ze[gn[(Vt+3)%4]&255]^this._Ke[Cn][Vt];gn=dn.slice()}for(var un=ue(16),Pt,Vt=0;Vt<4;Vt++)Pt=this._Ke[$t][Vt],un[4*Vt]=(Ne[gn[Vt]>>24&255]^Pt>>24)&255,un[4*Vt+1]=(Ne[gn[(Vt+1)%4]>>16&255]^Pt>>16)&255,un[4*Vt+2]=(Ne[gn[(Vt+2)%4]>>8&255]^Pt>>8)&255,un[4*Vt+3]=(Ne[gn[(Vt+3)%4]&255]^Pt)&255;return un},le.prototype.decrypt=function(We){if(We.length!=16)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var $t=this._Kd.length-1,dn=[0,0,0,0],gn=Sn(We),Vt=0;Vt<4;Vt++)gn[Vt]^=this._Kd[0][Vt];for(var Cn=1;Cn<$t;Cn++){for(var Vt=0;Vt<4;Vt++)dn[Vt]=Ye[gn[Vt]>>24&255]^Ft[gn[(Vt+3)%4]>>16&255]^Mt[gn[(Vt+2)%4]>>8&255]^Zt[gn[(Vt+1)%4]&255]^this._Kd[Cn][Vt];gn=dn.slice()}for(var un=ue(16),Pt,Vt=0;Vt<4;Vt++)Pt=this._Kd[$t][Vt],un[4*Vt]=(qe[gn[Vt]>>24&255]^Pt>>24)&255,un[4*Vt+1]=(qe[gn[(Vt+3)%4]>>16&255]^Pt>>16)&255,un[4*Vt+2]=(qe[gn[(Vt+2)%4]>>8&255]^Pt>>8)&255,un[4*Vt+3]=(qe[gn[(Vt+1)%4]&255]^Pt)&255;return un};var pe=function(We){if(!(this instanceof pe))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new le(We)};pe.prototype.encrypt=function(We){if(We=ae(We),We.length%16!==0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var $t=ue(We.length),dn=ue(16),gn=0;gn<We.length;gn+=16)de(We,dn,0,gn,gn+16),dn=this._aes.encrypt(dn),de(dn,$t,gn);return $t},pe.prototype.decrypt=function(We){if(We=ae(We),We.length%16!==0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var $t=ue(We.length),dn=ue(16),gn=0;gn<We.length;gn+=16)de(We,dn,0,gn,gn+16),dn=this._aes.decrypt(dn),de(dn,$t,gn);return $t};var be=function(We,$t){if(!(this instanceof be))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Block Chaining",this.name="cbc",!$t)$t=ue(16);else if($t.length!=16)throw new Error("invalid initialation vector size (must be 16 bytes)");this._lastCipherblock=ae($t,!0),this._aes=new le(We)};be.prototype.encrypt=function(We){if(We=ae(We),We.length%16!==0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var $t=ue(We.length),dn=ue(16),gn=0;gn<We.length;gn+=16){de(We,dn,0,gn,gn+16);for(var Vt=0;Vt<16;Vt++)dn[Vt]^=this._lastCipherblock[Vt];this._lastCipherblock=this._aes.encrypt(dn),de(this._lastCipherblock,$t,gn)}return $t},be.prototype.decrypt=function(We){if(We=ae(We),We.length%16!==0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var $t=ue(We.length),dn=ue(16),gn=0;gn<We.length;gn+=16){de(We,dn,0,gn,gn+16),dn=this._aes.decrypt(dn);for(var Vt=0;Vt<16;Vt++)$t[gn+Vt]=dn[Vt]^this._lastCipherblock[Vt];de(We,this._lastCipherblock,0,gn,gn+16)}return $t};var xe=function(We,$t,dn){if(!(this instanceof xe))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Feedback",this.name="cfb",!$t)$t=ue(16);else if($t.length!=16)throw new Error("invalid initialation vector size (must be 16 size)");dn||(dn=1),this.segmentSize=dn,this._shiftRegister=ae($t,!0),this._aes=new le(We)};xe.prototype.encrypt=function(We){if(We.length%this.segmentSize!=0)throw new Error("invalid plaintext size (must be segmentSize bytes)");for(var $t=ae(We,!0),dn,gn=0;gn<$t.length;gn+=this.segmentSize){dn=this._aes.encrypt(this._shiftRegister);for(var Vt=0;Vt<this.segmentSize;Vt++)$t[gn+Vt]^=dn[Vt];de(this._shiftRegister,this._shiftRegister,0,this.segmentSize),de($t,this._shiftRegister,16-this.segmentSize,gn,gn+this.segmentSize)}return $t},xe.prototype.decrypt=function(We){if(We.length%this.segmentSize!=0)throw new Error("invalid ciphertext size (must be segmentSize bytes)");for(var $t=ae(We,!0),dn,gn=0;gn<$t.length;gn+=this.segmentSize){dn=this._aes.encrypt(this._shiftRegister);for(var Vt=0;Vt<this.segmentSize;Vt++)$t[gn+Vt]^=dn[Vt];de(this._shiftRegister,this._shiftRegister,0,this.segmentSize),de(We,this._shiftRegister,16-this.segmentSize,gn,gn+this.segmentSize)}return $t};var _e=function(We,$t){if(!(this instanceof _e))throw Error("AES must be instanitated with `new`");if(this.description="Output Feedback",this.name="ofb",!$t)$t=ue(16);else if($t.length!=16)throw new Error("invalid initialation vector size (must be 16 bytes)");this._lastPrecipher=ae($t,!0),this._lastPrecipherIndex=16,this._aes=new le(We)};_e.prototype.encrypt=function(We){for(var $t=ae(We,!0),dn=0;dn<$t.length;dn++)this._lastPrecipherIndex===16&&(this._lastPrecipher=this._aes.encrypt(this._lastPrecipher),this._lastPrecipherIndex=0),$t[dn]^=this._lastPrecipher[this._lastPrecipherIndex++];return $t},_e.prototype.decrypt=_e.prototype.encrypt;var De=function(We){if(!(this instanceof De))throw Error("Counter must be instanitated with `new`");We!==0&&!We&&(We=1),typeof We=="number"?(this._counter=ue(16),this.setValue(We)):this.setBytes(We)};De.prototype.setValue=function(We){if(typeof We!="number"||parseInt(We)!=We)throw new Error("invalid counter value (must be an integer)");for(var $t=15;$t>=0;--$t)this._counter[$t]=We%256,We=We>>8},De.prototype.setBytes=function(We){if(We=ae(We,!0),We.length!=16)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=We},De.prototype.increment=function(){for(var We=15;We>=0;We--)if(this._counter[We]===255)this._counter[We]=0;else{this._counter[We]++;break}};var Fe=function(We,$t){if(!(this instanceof Fe))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",$t instanceof De||($t=new De($t)),this._counter=$t,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new le(We)};Fe.prototype.encrypt=function(We){for(var $t=ae(We,!0),dn=0;dn<$t.length;dn++)this._remainingCounterIndex===16&&(this._remainingCounter=this._aes.encrypt(this._counter._counter),this._remainingCounterIndex=0,this._counter.increment()),$t[dn]^=this._remainingCounter[this._remainingCounterIndex++];return $t},Fe.prototype.decrypt=Fe.prototype.encrypt;function $e(We){We=ae(We,!0);var $t=16-We.length%16,dn=ue(We.length+$t);de(We,dn);for(var gn=We.length;gn<dn.length;gn++)dn[gn]=$t;return dn}function ce(We){if(We=ae(We,!0),We.length<16)throw new Error("PKCS#7 invalid length");var $t=We[We.length-1];if($t>16)throw new Error("PKCS#7 padding byte out of range");for(var dn=We.length-$t,gn=0;gn<$t;gn++)if(We[dn+gn]!==$t)throw new Error("PKCS#7 invalid padding byte");var Vt=ue(dn);return de(We,Vt,0,0,dn),Vt}var Me={AES:le,Counter:De,ModeOfOperation:{ecb:pe,cbc:be,cfb:xe,ofb:_e,ctr:Fe},utils:{hex:ge,utf8:ve},padding:{pkcs7:{pad:$e,strip:ce}},_arrayTest:{coerceArray:ae,createArray:ue,copyArray:de}};n.exports=Me})()})(aesJs);var aesJsExports=aesJs.exports;const aes$1=getDefaultExportFromCjs$2(aesJsExports),version$c="json-wallets/5.8.0";function looseArrayify(n){return typeof n=="string"&&n.substring(0,2)!=="0x"&&(n="0x"+n),arrayify(n)}function zpad(n,t){for(n=String(n);n.length<t;)n="0"+n;return n}function getPassword(n){return typeof n=="string"?toUtf8Bytes(n,UnicodeNormalizationForm.NFKC):arrayify(n)}function searchPath(n,t){let c=n;const ie=t.toLowerCase().split("/");for(let se=0;se<ie.length;se++){let ae=null;for(const ue in c)if(ue.toLowerCase()===ie[se]){ae=c[ue];break}if(ae===null)return null;c=ae}return c}function uuidV4(n){const t=arrayify(n);t[6]=t[6]&15|64,t[8]=t[8]&63|128;const c=hexlify(t);return[c.substring(2,10),c.substring(10,14),c.substring(14,18),c.substring(18,22),c.substring(22,34)].join("-")}const logger$a=new Logger(version$c);class CrowdsaleAccount extends Description{isCrowdsaleAccount(t){return!!(t&&t._isCrowdsaleAccount)}}function decrypt$1(n,t){const c=JSON.parse(n);t=getPassword(t);const ie=getAddress$1(searchPath(c,"ethaddr")),se=looseArrayify(searchPath(c,"encseed"));(!se||se.length%16!==0)&&logger$a.throwArgumentError("invalid encseed","json",n);const ae=arrayify(pbkdf2$1(t,t,2e3,32,"sha256")).slice(0,16),ue=se.slice(0,16),de=se.slice(16),ve=new aes$1.ModeOfOperation.cbc(ae,ue),ge=aes$1.padding.pkcs7.strip(arrayify(ve.decrypt(de)));let we="";for(let qe=0;qe<ge.length;qe++)we+=String.fromCharCode(ge[qe]);const Te=toUtf8Bytes(we),Ne=keccak256$1(Te);return new CrowdsaleAccount({_isCrowdsaleAccount:!0,address:ie,privateKey:Ne})}function isCrowdsaleWallet(n){let t=null;try{t=JSON.parse(n)}catch{return!1}return t.encseed&&t.ethaddr}function isKeystoreWallet(n){let t=null;try{t=JSON.parse(n)}catch{return!1}return!(!t.version||parseInt(t.version)!==t.version||parseInt(t.version)!==3)}function getJsonWalletAddress(n){if(isCrowdsaleWallet(n))try{return getAddress$1(JSON.parse(n).ethaddr)}catch{return null}if(isKeystoreWallet(n))try{return getAddress$1(JSON.parse(n).address)}catch{return null}return null}var scrypt$1={exports:{}};(function(n,t){(function(c){function ie(ze){const He=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);let Ge=1779033703,Ze=3144134277,Ye=1013904242,Ft=2773480762,Mt=1359893119,Zt=2600822924,cn=528734635,hn=1541459225;const yn=new Uint32Array(64);function Ht(De){let Fe=0,$e=De.length;for(;$e>=64;){let ce=Ge,Me=Ze,We=Ye,$t=Ft,dn=Mt,gn=Zt,Vt=cn,Cn=hn,un,Pt,mn,Pn,wn;for(Pt=0;Pt<16;Pt++)mn=Fe+Pt*4,yn[Pt]=(De[mn]&255)<<24|(De[mn+1]&255)<<16|(De[mn+2]&255)<<8|De[mn+3]&255;for(Pt=16;Pt<64;Pt++)un=yn[Pt-2],Pn=(un>>>17|un<<15)^(un>>>19|un<<13)^un>>>10,un=yn[Pt-15],wn=(un>>>7|un<<25)^(un>>>18|un<<14)^un>>>3,yn[Pt]=(Pn+yn[Pt-7]|0)+(wn+yn[Pt-16]|0)|0;for(Pt=0;Pt<64;Pt++)Pn=(((dn>>>6|dn<<26)^(dn>>>11|dn<<21)^(dn>>>25|dn<<7))+(dn&gn^~dn&Vt)|0)+(Cn+(He[Pt]+yn[Pt]|0)|0)|0,wn=((ce>>>2|ce<<30)^(ce>>>13|ce<<19)^(ce>>>22|ce<<10))+(ce&Me^ce&We^Me&We)|0,Cn=Vt,Vt=gn,gn=dn,dn=$t+Pn|0,$t=We,We=Me,Me=ce,ce=Pn+wn|0;Ge=Ge+ce|0,Ze=Ze+Me|0,Ye=Ye+We|0,Ft=Ft+$t|0,Mt=Mt+dn|0,Zt=Zt+gn|0,cn=cn+Vt|0,hn=hn+Cn|0,Fe+=64,$e-=64}}Ht(ze);let Sn,le=ze.length%64,pe=ze.length/536870912|0,be=ze.length<<3,xe=le<56?56:120,_e=ze.slice(ze.length-le,ze.length);for(_e.push(128),Sn=le+1;Sn<xe;Sn++)_e.push(0);return _e.push(pe>>>24&255),_e.push(pe>>>16&255),_e.push(pe>>>8&255),_e.push(pe>>>0&255),_e.push(be>>>24&255),_e.push(be>>>16&255),_e.push(be>>>8&255),_e.push(be>>>0&255),Ht(_e),[Ge>>>24&255,Ge>>>16&255,Ge>>>8&255,Ge>>>0&255,Ze>>>24&255,Ze>>>16&255,Ze>>>8&255,Ze>>>0&255,Ye>>>24&255,Ye>>>16&255,Ye>>>8&255,Ye>>>0&255,Ft>>>24&255,Ft>>>16&255,Ft>>>8&255,Ft>>>0&255,Mt>>>24&255,Mt>>>16&255,Mt>>>8&255,Mt>>>0&255,Zt>>>24&255,Zt>>>16&255,Zt>>>8&255,Zt>>>0&255,cn>>>24&255,cn>>>16&255,cn>>>8&255,cn>>>0&255,hn>>>24&255,hn>>>16&255,hn>>>8&255,hn>>>0&255]}function se(ze,He,Ge){ze=ze.length<=64?ze:ie(ze);const Ze=64+He.length+4,Ye=new Array(Ze),Ft=new Array(64);let Mt,Zt=[];for(Mt=0;Mt<64;Mt++)Ye[Mt]=54;for(Mt=0;Mt<ze.length;Mt++)Ye[Mt]^=ze[Mt];for(Mt=0;Mt<He.length;Mt++)Ye[64+Mt]=He[Mt];for(Mt=Ze-4;Mt<Ze;Mt++)Ye[Mt]=0;for(Mt=0;Mt<64;Mt++)Ft[Mt]=92;for(Mt=0;Mt<ze.length;Mt++)Ft[Mt]^=ze[Mt];function cn(){for(let hn=Ze-1;hn>=Ze-4;hn--){if(Ye[hn]++,Ye[hn]<=255)return;Ye[hn]=0}}for(;Ge>=32;)cn(),Zt=Zt.concat(ie(Ft.concat(ie(Ye)))),Ge-=32;return Ge>0&&(cn(),Zt=Zt.concat(ie(Ft.concat(ie(Ye))).slice(0,Ge))),Zt}function ae(ze,He,Ge,Ze,Ye){let Ft;for(ge(ze,(2*Ge-1)*16,Ye,0,16),Ft=0;Ft<2*Ge;Ft++)ve(ze,Ft*16,Ye,16),de(Ye,Ze),ge(Ye,0,ze,He+Ft*16,16);for(Ft=0;Ft<Ge;Ft++)ge(ze,He+Ft*2*16,ze,Ft*16,16);for(Ft=0;Ft<Ge;Ft++)ge(ze,He+(Ft*2+1)*16,ze,(Ft+Ge)*16,16)}function ue(ze,He){return ze<<He|ze>>>32-He}function de(ze,He){ge(ze,0,He,0,16);for(let Ge=8;Ge>0;Ge-=2)He[4]^=ue(He[0]+He[12],7),He[8]^=ue(He[4]+He[0],9),He[12]^=ue(He[8]+He[4],13),He[0]^=ue(He[12]+He[8],18),He[9]^=ue(He[5]+He[1],7),He[13]^=ue(He[9]+He[5],9),He[1]^=ue(He[13]+He[9],13),He[5]^=ue(He[1]+He[13],18),He[14]^=ue(He[10]+He[6],7),He[2]^=ue(He[14]+He[10],9),He[6]^=ue(He[2]+He[14],13),He[10]^=ue(He[6]+He[2],18),He[3]^=ue(He[15]+He[11],7),He[7]^=ue(He[3]+He[15],9),He[11]^=ue(He[7]+He[3],13),He[15]^=ue(He[11]+He[7],18),He[1]^=ue(He[0]+He[3],7),He[2]^=ue(He[1]+He[0],9),He[3]^=ue(He[2]+He[1],13),He[0]^=ue(He[3]+He[2],18),He[6]^=ue(He[5]+He[4],7),He[7]^=ue(He[6]+He[5],9),He[4]^=ue(He[7]+He[6],13),He[5]^=ue(He[4]+He[7],18),He[11]^=ue(He[10]+He[9],7),He[8]^=ue(He[11]+He[10],9),He[9]^=ue(He[8]+He[11],13),He[10]^=ue(He[9]+He[8],18),He[12]^=ue(He[15]+He[14],7),He[13]^=ue(He[12]+He[15],9),He[14]^=ue(He[13]+He[12],13),He[15]^=ue(He[14]+He[13],18);for(let Ge=0;Ge<16;++Ge)ze[Ge]+=He[Ge]}function ve(ze,He,Ge,Ze){for(let Ye=0;Ye<Ze;Ye++)Ge[Ye]^=ze[He+Ye]}function ge(ze,He,Ge,Ze,Ye){for(;Ye--;)Ge[Ze++]=ze[He++]}function we(ze){if(!ze||typeof ze.length!="number")return!1;for(let He=0;He<ze.length;He++){const Ge=ze[He];if(typeof Ge!="number"||Ge%1||Ge<0||Ge>=256)return!1}return!0}function Te(ze,He){if(typeof ze!="number"||ze%1)throw new Error("invalid "+He);return ze}function Ne(ze,He,Ge,Ze,Ye,Ft,Mt){if(Ge=Te(Ge,"N"),Ze=Te(Ze,"r"),Ye=Te(Ye,"p"),Ft=Te(Ft,"dkLen"),Ge===0||Ge&Ge-1)throw new Error("N must be power of 2");if(Ge>2147483647/128/Ze)throw new Error("N too large");if(Ze>2147483647/128/Ye)throw new Error("r too large");if(!we(ze))throw new Error("password must be an array or buffer");if(ze=Array.prototype.slice.call(ze),!we(He))throw new Error("salt must be an array or buffer");He=Array.prototype.slice.call(He);let Zt=se(ze,He,Ye*128*Ze);const cn=new Uint32Array(Ye*32*Ze);for(let dn=0;dn<cn.length;dn++){const gn=dn*4;cn[dn]=(Zt[gn+3]&255)<<24|(Zt[gn+2]&255)<<16|(Zt[gn+1]&255)<<8|(Zt[gn+0]&255)<<0}const hn=new Uint32Array(64*Ze),yn=new Uint32Array(32*Ze*Ge),Ht=32*Ze,Sn=new Uint32Array(16),le=new Uint32Array(16),pe=Ye*Ge*2;let be=0,xe=null,_e=!1,De=0,Fe=0,$e,ce;const Me=Mt?parseInt(1e3/Ze):4294967295,We=typeof setImmediate<"u"?setImmediate:setTimeout,$t=function(){if(_e)return Mt(new Error("cancelled"),be/pe);let dn;switch(De){case 0:ce=Fe*32*Ze,ge(cn,ce,hn,0,Ht),De=1,$e=0;case 1:dn=Ge-$e,dn>Me&&(dn=Me);for(let Vt=0;Vt<dn;Vt++)ge(hn,0,yn,($e+Vt)*Ht,Ht),ae(hn,Ht,Ze,Sn,le);if($e+=dn,be+=dn,Mt){const Vt=parseInt(1e3*be/pe);if(Vt!==xe){if(_e=Mt(null,be/pe),_e)break;xe=Vt}}if($e<Ge)break;$e=0,De=2;case 2:dn=Ge-$e,dn>Me&&(dn=Me);for(let Vt=0;Vt<dn;Vt++){const Cn=(2*Ze-1)*16,un=hn[Cn]&Ge-1;ve(yn,un*Ht,hn,Ht),ae(hn,Ht,Ze,Sn,le)}if($e+=dn,be+=dn,Mt){const Vt=parseInt(1e3*be/pe);if(Vt!==xe){if(_e=Mt(null,be/pe),_e)break;xe=Vt}}if($e<Ge)break;if(ge(hn,0,cn,ce,Ht),Fe++,Fe<Ye){De=0;break}Zt=[];for(let Vt=0;Vt<cn.length;Vt++)Zt.push(cn[Vt]>>0&255),Zt.push(cn[Vt]>>8&255),Zt.push(cn[Vt]>>16&255),Zt.push(cn[Vt]>>24&255);const gn=se(ze,Zt,Ft);return Mt&&Mt(null,1,gn),gn}Mt&&We($t)};if(!Mt)for(;;){const dn=$t();if(dn!=null)return dn}$t()}const qe={scrypt:function(ze,He,Ge,Ze,Ye,Ft,Mt){return new Promise(function(Zt,cn){let hn=0;Mt&&Mt(0),Ne(ze,He,Ge,Ze,Ye,Ft,function(yn,Ht,Sn){if(yn)cn(yn);else if(Sn)Mt&&hn!==1&&Mt(1),Zt(new Uint8Array(Sn));else if(Mt&&Ht!==hn)return hn=Ht,Mt(Ht)})})},syncScrypt:function(ze,He,Ge,Ze,Ye,Ft){return new Uint8Array(Ne(ze,He,Ge,Ze,Ye,Ft))}};n.exports=qe})()})(scrypt$1);var scryptExports=scrypt$1.exports;const scrypt=getDefaultExportFromCjs$2(scryptExports);var __awaiter$g=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$9=new Logger(version$c);function hasMnemonic$1(n){return n!=null&&n.mnemonic&&n.mnemonic.phrase}class KeystoreAccount extends Description{isKeystoreAccount(t){return!!(t&&t._isKeystoreAccount)}}function _decrypt(n,t,c){if(searchPath(n,"crypto/cipher")==="aes-128-ctr"){const ie=looseArrayify(searchPath(n,"crypto/cipherparams/iv")),se=new aes$1.Counter(ie),ae=new aes$1.ModeOfOperation.ctr(t,se);return arrayify(ae.decrypt(c))}return null}function _getAccount(n,t){const c=looseArrayify(searchPath(n,"crypto/ciphertext"));if(hexlify(keccak256$1(concat$1([t.slice(16,32),c]))).substring(2)!==searchPath(n,"crypto/mac").toLowerCase())throw new Error("invalid password");const ie=_decrypt(n,t.slice(0,16),c);ie||logger$9.throwError("unsupported cipher",Logger.errors.UNSUPPORTED_OPERATION,{operation:"decrypt"});const se=t.slice(32,64),ae=computeAddress(ie);if(n.address){let de=n.address.toLowerCase();if(de.substring(0,2)!=="0x"&&(de="0x"+de),getAddress$1(de)!==ae)throw new Error("address mismatch")}const ue={_isKeystoreAccount:!0,address:ae,privateKey:hexlify(ie)};if(searchPath(n,"x-ethers/version")==="0.1"){const de=looseArrayify(searchPath(n,"x-ethers/mnemonicCiphertext")),ve=looseArrayify(searchPath(n,"x-ethers/mnemonicCounter")),ge=new aes$1.Counter(ve),we=new aes$1.ModeOfOperation.ctr(se,ge),Te=searchPath(n,"x-ethers/path")||defaultPath,Ne=searchPath(n,"x-ethers/locale")||"en",qe=arrayify(we.decrypt(de));try{const ze=entropyToMnemonic(qe,Ne),He=HDNode.fromMnemonic(ze,null,Ne).derivePath(Te);if(He.privateKey!=ue.privateKey)throw new Error("mnemonic mismatch");ue.mnemonic=He.mnemonic}catch(ze){if(ze.code!==Logger.errors.INVALID_ARGUMENT||ze.argument!=="wordlist")throw ze}}return new KeystoreAccount(ue)}function pbkdf2Sync(n,t,c,ie,se){return arrayify(pbkdf2$1(n,t,c,ie,se))}function pbkdf2(n,t,c,ie,se){return Promise.resolve(pbkdf2Sync(n,t,c,ie,se))}function _computeKdfKey(n,t,c,ie,se){const ae=getPassword(t),ue=searchPath(n,"crypto/kdf");if(ue&&typeof ue=="string"){const de=function(ve,ge){return logger$9.throwArgumentError("invalid key-derivation function parameters",ve,ge)};if(ue.toLowerCase()==="scrypt"){const ve=looseArrayify(searchPath(n,"crypto/kdfparams/salt")),ge=parseInt(searchPath(n,"crypto/kdfparams/n")),we=parseInt(searchPath(n,"crypto/kdfparams/r")),Te=parseInt(searchPath(n,"crypto/kdfparams/p"));(!ge||!we||!Te)&&de("kdf",ue),ge&ge-1&&de("N",ge);const Ne=parseInt(searchPath(n,"crypto/kdfparams/dklen"));return Ne!==32&&de("dklen",Ne),ie(ae,ve,ge,we,Te,64,se)}else if(ue.toLowerCase()==="pbkdf2"){const ve=looseArrayify(searchPath(n,"crypto/kdfparams/salt"));let ge=null;const we=searchPath(n,"crypto/kdfparams/prf");we==="hmac-sha256"?ge="sha256":we==="hmac-sha512"?ge="sha512":de("prf",we);const Te=parseInt(searchPath(n,"crypto/kdfparams/c")),Ne=parseInt(searchPath(n,"crypto/kdfparams/dklen"));return Ne!==32&&de("dklen",Ne),c(ae,ve,Te,Ne,ge)}}return logger$9.throwArgumentError("unsupported key-derivation function","kdf",ue)}function decryptSync(n,t){const c=JSON.parse(n),ie=_computeKdfKey(c,t,pbkdf2Sync,scrypt.syncScrypt);return _getAccount(c,ie)}function decrypt(n,t,c){return __awaiter$g(this,void 0,void 0,function*(){const ie=JSON.parse(n),se=yield _computeKdfKey(ie,t,pbkdf2,scrypt.scrypt,c);return _getAccount(ie,se)})}function encrypt(n,t,c,ie){try{if(getAddress$1(n.address)!==computeAddress(n.privateKey))throw new Error("address/privateKey mismatch");if(hasMnemonic$1(n)){const Ge=n.mnemonic;if(HDNode.fromMnemonic(Ge.phrase,null,Ge.locale).derivePath(Ge.path||defaultPath).privateKey!=n.privateKey)throw new Error("mnemonic mismatch")}}catch(Ge){return Promise.reject(Ge)}typeof c=="function"&&!ie&&(ie=c,c={}),c||(c={});const se=arrayify(n.privateKey),ae=getPassword(t);let ue=null,de=null,ve=null;if(hasMnemonic$1(n)){const Ge=n.mnemonic;ue=arrayify(mnemonicToEntropy(Ge.phrase,Ge.locale||"en")),de=Ge.path||defaultPath,ve=Ge.locale||"en"}let ge=c.client;ge||(ge="ethers.js");let we=null;c.salt?we=arrayify(c.salt):we=randomBytes$1(32);let Te=null;if(c.iv){if(Te=arrayify(c.iv),Te.length!==16)throw new Error("invalid iv")}else Te=randomBytes$1(16);let Ne=null;if(c.uuid){if(Ne=arrayify(c.uuid),Ne.length!==16)throw new Error("invalid uuid")}else Ne=randomBytes$1(16);let qe=1<<17,ze=8,He=1;return c.scrypt&&(c.scrypt.N&&(qe=c.scrypt.N),c.scrypt.r&&(ze=c.scrypt.r),c.scrypt.p&&(He=c.scrypt.p)),scrypt.scrypt(ae,we,qe,ze,He,64,ie).then(Ge=>{Ge=arrayify(Ge);const Ze=Ge.slice(0,16),Ye=Ge.slice(16,32),Ft=Ge.slice(32,64),Mt=new aes$1.Counter(Te),Zt=new aes$1.ModeOfOperation.ctr(Ze,Mt),cn=arrayify(Zt.encrypt(se)),hn=keccak256$1(concat$1([Ye,cn])),yn={address:n.address.substring(2).toLowerCase(),id:uuidV4(Ne),version:3,crypto:{cipher:"aes-128-ctr",cipherparams:{iv:hexlify(Te).substring(2)},ciphertext:hexlify(cn).substring(2),kdf:"scrypt",kdfparams:{salt:hexlify(we).substring(2),n:qe,dklen:32,p:He,r:ze},mac:hn.substring(2)}};if(ue){const Ht=randomBytes$1(16),Sn=new aes$1.Counter(Ht),le=new aes$1.ModeOfOperation.ctr(Ft,Sn),pe=arrayify(le.encrypt(ue)),be=new Date,xe=be.getUTCFullYear()+"-"+zpad(be.getUTCMonth()+1,2)+"-"+zpad(be.getUTCDate(),2)+"T"+zpad(be.getUTCHours(),2)+"-"+zpad(be.getUTCMinutes(),2)+"-"+zpad(be.getUTCSeconds(),2)+".0Z";yn["x-ethers"]={client:ge,gethFilename:"UTC--"+xe+"--"+yn.address,mnemonicCounter:hexlify(Ht).substring(2),mnemonicCiphertext:hexlify(pe).substring(2),path:de,locale:ve,version:"0.1"}}return JSON.stringify(yn)})}function decryptJsonWallet(n,t,c){if(isCrowdsaleWallet(n)){c&&c(0);const ie=decrypt$1(n,t);return c&&c(1),Promise.resolve(ie)}return isKeystoreWallet(n)?decrypt(n,t,c):Promise.reject(new Error("invalid JSON wallet"))}function decryptJsonWalletSync(n,t){if(isCrowdsaleWallet(n))return decrypt$1(n,t);if(isKeystoreWallet(n))return decryptSync(n,t);throw new Error("invalid JSON wallet")}const lib_esm$4=Object.freeze(Object.defineProperty({__proto__:null,decryptCrowdsale:decrypt$1,decryptJsonWallet,decryptJsonWalletSync,decryptKeystore:decrypt,decryptKeystoreSync:decryptSync,encryptKeystore:encrypt,getJsonWalletAddress,isCrowdsaleWallet,isKeystoreWallet},Symbol.toStringTag,{value:"Module"})),version$b="wallet/5.8.0";var __awaiter$f=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$8=new Logger(version$b);function isAccount(n){return n!=null&&isHexString(n.privateKey,32)&&n.address!=null}function hasMnemonic(n){const t=n.mnemonic;return t&&t.phrase}class Wallet extends Signer{constructor(t,c){if(super(),isAccount(t)){const ie=new SigningKey(t.privateKey);if(defineReadOnly(this,"_signingKey",()=>ie),defineReadOnly(this,"address",computeAddress(this.publicKey)),this.address!==getAddress$1(t.address)&&logger$8.throwArgumentError("privateKey/address mismatch","privateKey","[REDACTED]"),hasMnemonic(t)){const se=t.mnemonic;defineReadOnly(this,"_mnemonic",()=>({phrase:se.phrase,path:se.path||defaultPath,locale:se.locale||"en"}));const ae=this.mnemonic,ue=HDNode.fromMnemonic(ae.phrase,null,ae.locale).derivePath(ae.path);computeAddress(ue.privateKey)!==this.address&&logger$8.throwArgumentError("mnemonic/address mismatch","privateKey","[REDACTED]")}else defineReadOnly(this,"_mnemonic",()=>null)}else{if(SigningKey.isSigningKey(t))t.curve!=="secp256k1"&&logger$8.throwArgumentError("unsupported curve; must be secp256k1","privateKey","[REDACTED]"),defineReadOnly(this,"_signingKey",()=>t);else{typeof t=="string"&&t.match(/^[0-9a-f]*$/i)&&t.length===64&&(t="0x"+t);const ie=new SigningKey(t);defineReadOnly(this,"_signingKey",()=>ie)}defineReadOnly(this,"_mnemonic",()=>null),defineReadOnly(this,"address",computeAddress(this.publicKey))}c&&!Provider.isProvider(c)&&logger$8.throwArgumentError("invalid provider","provider",c),defineReadOnly(this,"provider",c||null)}get mnemonic(){return this._mnemonic()}get privateKey(){return this._signingKey().privateKey}get publicKey(){return this._signingKey().publicKey}getAddress(){return Promise.resolve(this.address)}connect(t){return new Wallet(this,t)}signTransaction(t){return resolveProperties(t).then(c=>{c.from!=null&&(getAddress$1(c.from)!==this.address&&logger$8.throwArgumentError("transaction from address mismatch","transaction.from",t.from),delete c.from);const ie=this._signingKey().signDigest(keccak256$1(serialize$1$1(c)));return serialize$1$1(c,ie)})}signMessage(t){return __awaiter$f(this,void 0,void 0,function*(){return joinSignature(this._signingKey().signDigest(hashMessage(t)))})}_signTypedData(t,c,ie){return __awaiter$f(this,void 0,void 0,function*(){const se=yield TypedDataEncoder.resolveNames(t,c,ie,ae=>(this.provider==null&&logger$8.throwError("cannot resolve ENS names without a provider",Logger.errors.UNSUPPORTED_OPERATION,{operation:"resolveName",value:ae}),this.provider.resolveName(ae)));return joinSignature(this._signingKey().signDigest(TypedDataEncoder.hash(se.domain,c,se.value)))})}encrypt(t,c,ie){if(typeof c=="function"&&!ie&&(ie=c,c={}),ie&&typeof ie!="function")throw new Error("invalid callback");return c||(c={}),encrypt(this,t,c,ie)}static createRandom(t){let c=randomBytes$1(16);t||(t={}),t.extraEntropy&&(c=arrayify(hexDataSlice(keccak256$1(concat$1([c,t.extraEntropy])),0,16)));const ie=entropyToMnemonic(c,t.locale);return Wallet.fromMnemonic(ie,t.path,t.locale)}static fromEncryptedJson(t,c,ie){return decryptJsonWallet(t,c,ie).then(se=>new Wallet(se))}static fromEncryptedJsonSync(t,c){return new Wallet(decryptJsonWalletSync(t,c))}static fromMnemonic(t,c,ie){return c||(c=defaultPath),new Wallet(HDNode.fromMnemonic(t,null,ie).derivePath(c))}}function verifyMessage(n,t){return recoverAddress(hashMessage(n),t)}function verifyTypedData(n,t,c,ie){return recoverAddress(TypedDataEncoder.hash(n,t,c),ie)}const lib_esm$3=Object.freeze(Object.defineProperty({__proto__:null,Wallet,verifyMessage,verifyTypedData},Symbol.toStringTag,{value:"Module"})),version$a="networks/5.8.0",logger$7=new Logger(version$a);function isRenetworkable(n){return n&&typeof n.renetwork=="function"}function ethDefaultProvider(n){const t=function(c,ie){ie==null&&(ie={});const se=[];if(c.InfuraProvider&&ie.infura!=="-")try{se.push(new c.InfuraProvider(n,ie.infura))}catch{}if(c.EtherscanProvider&&ie.etherscan!=="-")try{se.push(new c.EtherscanProvider(n,ie.etherscan))}catch{}if(c.AlchemyProvider&&ie.alchemy!=="-")try{se.push(new c.AlchemyProvider(n,ie.alchemy))}catch{}if(c.PocketProvider&&ie.pocket!=="-"){const ae=["goerli","ropsten","rinkeby","sepolia"];try{const ue=new c.PocketProvider(n,ie.pocket);ue.network&&ae.indexOf(ue.network.name)===-1&&se.push(ue)}catch{}}if(c.CloudflareProvider&&ie.cloudflare!=="-")try{se.push(new c.CloudflareProvider(n))}catch{}if(c.AnkrProvider&&ie.ankr!=="-")try{const ae=["ropsten"],ue=new c.AnkrProvider(n,ie.ankr);ue.network&&ae.indexOf(ue.network.name)===-1&&se.push(ue)}catch{}if(c.QuickNodeProvider&&ie.quicknode!=="-")try{se.push(new c.QuickNodeProvider(n,ie.quicknode))}catch{}if(se.length===0)return null;if(c.FallbackProvider){let ae=1;return ie.quorum!=null?ae=ie.quorum:n==="homestead"&&(ae=2),new c.FallbackProvider(se,ae)}return se[0]};return t.renetwork=function(c){return ethDefaultProvider(c)},t}function etcDefaultProvider(n,t){const c=function(ie,se){return ie.JsonRpcProvider?new ie.JsonRpcProvider(n,t):null};return c.renetwork=function(ie){return etcDefaultProvider(n,ie)},c}const homestead={chainId:1,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"homestead",_defaultProvider:ethDefaultProvider("homestead")},ropsten={chainId:3,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"ropsten",_defaultProvider:ethDefaultProvider("ropsten")},classicMordor={chainId:63,name:"classicMordor",_defaultProvider:etcDefaultProvider("https://www.ethercluster.com/mordor","classicMordor")},networks$2={unspecified:{chainId:0,name:"unspecified"},homestead,mainnet:homestead,morden:{chainId:2,name:"morden"},ropsten,testnet:ropsten,rinkeby:{chainId:4,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"rinkeby",_defaultProvider:ethDefaultProvider("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:ethDefaultProvider("kovan")},goerli:{chainId:5,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"goerli",_defaultProvider:ethDefaultProvider("goerli")},kintsugi:{chainId:1337702,name:"kintsugi"},sepolia:{chainId:11155111,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"sepolia",_defaultProvider:ethDefaultProvider("sepolia")},holesky:{chainId:17e3,name:"holesky",_defaultProvider:ethDefaultProvider("holesky")},classic:{chainId:61,name:"classic",_defaultProvider:etcDefaultProvider("https://www.ethercluster.com/etc","classic")},classicMorden:{chainId:62,name:"classicMorden"},classicMordor,classicTestnet:classicMordor,classicKotti:{chainId:6,name:"classicKotti",_defaultProvider:etcDefaultProvider("https://www.ethercluster.com/kotti","classicKotti")},xdai:{chainId:100,name:"xdai"},matic:{chainId:137,name:"matic",_defaultProvider:ethDefaultProvider("matic")},maticmum:{chainId:80001,name:"maticmum",_defaultProvider:ethDefaultProvider("maticmum")},optimism:{chainId:10,name:"optimism",_defaultProvider:ethDefaultProvider("optimism")},"optimism-kovan":{chainId:69,name:"optimism-kovan"},"optimism-goerli":{chainId:420,name:"optimism-goerli"},"optimism-sepolia":{chainId:11155420,name:"optimism-sepolia"},arbitrum:{chainId:42161,name:"arbitrum"},"arbitrum-rinkeby":{chainId:421611,name:"arbitrum-rinkeby"},"arbitrum-goerli":{chainId:421613,name:"arbitrum-goerli"},"arbitrum-sepolia":{chainId:421614,name:"arbitrum-sepolia"},bnb:{chainId:56,name:"bnb"},bnbt:{chainId:97,name:"bnbt"}};function getNetwork(n){if(n==null)return null;if(typeof n=="number"){for(const ie in networks$2){const se=networks$2[ie];if(se.chainId===n)return{name:se.name,chainId:se.chainId,ensAddress:se.ensAddress||null,_defaultProvider:se._defaultProvider||null}}return{chainId:n,name:"unknown"}}if(typeof n=="string"){const ie=networks$2[n];return ie==null?null:{name:ie.name,chainId:ie.chainId,ensAddress:ie.ensAddress,_defaultProvider:ie._defaultProvider||null}}const t=networks$2[n.name];if(!t)return typeof n.chainId!="number"&&logger$7.throwArgumentError("invalid network chainId","network",n),n;n.chainId!==0&&n.chainId!==t.chainId&&logger$7.throwArgumentError("network chainId mismatch","network",n);let c=n._defaultProvider||null;return c==null&&t._defaultProvider&&(isRenetworkable(t._defaultProvider)?c=t._defaultProvider.renetwork(n):c=t._defaultProvider),{name:n.name,chainId:t.chainId,ensAddress:n.ensAddress||t.ensAddress||null,_defaultProvider:c}}const version$9="web/5.8.0";var __awaiter$e=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};function getUrl(n,t){return __awaiter$e(this,void 0,void 0,function*(){t==null&&(t={});const c={method:t.method||"GET",headers:t.headers||{},body:t.body||void 0};if(t.skipFetchSetup!==!0&&(c.mode="cors",c.cache="no-cache",c.credentials="same-origin",c.redirect="follow",c.referrer="client"),t.fetchOptions!=null){const ue=t.fetchOptions;ue.mode&&(c.mode=ue.mode),ue.cache&&(c.cache=ue.cache),ue.credentials&&(c.credentials=ue.credentials),ue.redirect&&(c.redirect=ue.redirect),ue.referrer&&(c.referrer=ue.referrer)}const ie=yield fetch(n,c),se=yield ie.arrayBuffer(),ae={};return ie.headers.forEach?ie.headers.forEach((ue,de)=>{ae[de.toLowerCase()]=ue}):ie.headers.keys().forEach(ue=>{ae[ue.toLowerCase()]=ie.headers.get(ue)}),{headers:ae,statusCode:ie.status,statusMessage:ie.statusText,body:arrayify(new Uint8Array(se))}})}var __awaiter$d=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$6=new Logger(version$9);function staller(n){return new Promise(t=>{setTimeout(t,n)})}function bodyify(n,t){if(n==null)return null;if(typeof n=="string")return n;if(isBytesLike(n)){if(t&&(t.split("/")[0]==="text"||t.split(";")[0].trim()==="application/json"))try{return toUtf8String(n)}catch{}return hexlify(n)}return n}function unpercent(n){return toUtf8Bytes(n.replace(/%([0-9a-f][0-9a-f])/gi,(t,c)=>String.fromCharCode(parseInt(c,16))))}function _fetchData(n,t,c){const ie=typeof n=="object"&&n.throttleLimit!=null?n.throttleLimit:12;logger$6.assertArgument(ie>0&&ie%1===0,"invalid connection throttle limit","connection.throttleLimit",ie);const se=typeof n=="object"?n.throttleCallback:null,ae=typeof n=="object"&&typeof n.throttleSlotInterval=="number"?n.throttleSlotInterval:100;logger$6.assertArgument(ae>0&&ae%1===0,"invalid connection throttle slot interval","connection.throttleSlotInterval",ae);const ue=typeof n=="object"?!!n.errorPassThrough:!1,de={};let ve=null;const ge={method:"GET"};let we=!1,Te=120*1e3;if(typeof n=="string")ve=n;else if(typeof n=="object"){if((n==null||n.url==null)&&logger$6.throwArgumentError("missing URL","connection.url",n),ve=n.url,typeof n.timeout=="number"&&n.timeout>0&&(Te=n.timeout),n.headers)for(const Ze in n.headers)de[Ze.toLowerCase()]={key:Ze,value:String(n.headers[Ze])},["if-none-match","if-modified-since"].indexOf(Ze.toLowerCase())>=0&&(we=!0);if(ge.allowGzip=!!n.allowGzip,n.user!=null&&n.password!=null){ve.substring(0,6)!=="https:"&&n.allowInsecureAuthentication!==!0&&logger$6.throwError("basic authentication requires a secure https url",Logger.errors.INVALID_ARGUMENT,{argument:"url",url:ve,user:n.user,password:"[REDACTED]"});const Ze=n.user+":"+n.password;de.authorization={key:"Authorization",value:"Basic "+encode$5(toUtf8Bytes(Ze))}}n.skipFetchSetup!=null&&(ge.skipFetchSetup=!!n.skipFetchSetup),n.fetchOptions!=null&&(ge.fetchOptions=shallowCopy(n.fetchOptions))}const Ne=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),qe=ve?ve.match(Ne):null;if(qe)try{const Ze={statusCode:200,statusMessage:"OK",headers:{"content-type":qe[1]||"text/plain"},body:qe[2]?decode$6(qe[3]):unpercent(qe[3])};let Ye=Ze.body;return c&&(Ye=c(Ze.body,Ze)),Promise.resolve(Ye)}catch(Ze){logger$6.throwError("processing response error",Logger.errors.SERVER_ERROR,{body:bodyify(qe[1],qe[2]),error:Ze,requestBody:null,requestMethod:"GET",url:ve})}t&&(ge.method="POST",ge.body=t,de["content-type"]==null&&(de["content-type"]={key:"Content-Type",value:"application/octet-stream"}),de["content-length"]==null&&(de["content-length"]={key:"Content-Length",value:String(t.length)}));const ze={};Object.keys(de).forEach(Ze=>{const Ye=de[Ze];ze[Ye.key]=Ye.value}),ge.headers=ze;const He=(function(){let Ze=null;return{promise:new Promise(function(Ye,Ft){Te&&(Ze=setTimeout(()=>{Ze!=null&&(Ze=null,Ft(logger$6.makeError("timeout",Logger.errors.TIMEOUT,{requestBody:bodyify(ge.body,ze["content-type"]),requestMethod:ge.method,timeout:Te,url:ve})))},Te))}),cancel:function(){Ze!=null&&(clearTimeout(Ze),Ze=null)}}})(),Ge=(function(){return __awaiter$d(this,void 0,void 0,function*(){for(let Ze=0;Ze<ie;Ze++){let Ye=null;try{if(Ye=yield getUrl(ve,ge),Ze<ie){if(Ye.statusCode===301||Ye.statusCode===302){const Mt=Ye.headers.location||"";if(ge.method==="GET"&&Mt.match(/^https:/)){ve=Ye.headers.location;continue}}else if(Ye.statusCode===429){let Mt=!0;if(se&&(Mt=yield se(Ze,ve)),Mt){let Zt=0;const cn=Ye.headers["retry-after"];typeof cn=="string"&&cn.match(/^[1-9][0-9]*$/)?Zt=parseInt(cn)*1e3:Zt=ae*parseInt(String(Math.random()*Math.pow(2,Ze))),yield staller(Zt);continue}}}}catch(Mt){Ye=Mt.response,Ye==null&&(He.cancel(),logger$6.throwError("missing response",Logger.errors.SERVER_ERROR,{requestBody:bodyify(ge.body,ze["content-type"]),requestMethod:ge.method,serverError:Mt,url:ve}))}let Ft=Ye.body;if(we&&Ye.statusCode===304?Ft=null:!ue&&(Ye.statusCode<200||Ye.statusCode>=300)&&(He.cancel(),logger$6.throwError("bad response",Logger.errors.SERVER_ERROR,{status:Ye.statusCode,headers:Ye.headers,body:bodyify(Ft,Ye.headers?Ye.headers["content-type"]:null),requestBody:bodyify(ge.body,ze["content-type"]),requestMethod:ge.method,url:ve})),c)try{const Mt=yield c(Ft,Ye);return He.cancel(),Mt}catch(Mt){if(Mt.throttleRetry&&Ze<ie){let Zt=!0;if(se&&(Zt=yield se(Ze,ve)),Zt){const cn=ae*parseInt(String(Math.random()*Math.pow(2,Ze)));yield staller(cn);continue}}He.cancel(),logger$6.throwError("processing response error",Logger.errors.SERVER_ERROR,{body:bodyify(Ft,Ye.headers?Ye.headers["content-type"]:null),error:Mt,requestBody:bodyify(ge.body,ze["content-type"]),requestMethod:ge.method,url:ve})}return He.cancel(),Ft}return logger$6.throwError("failed response",Logger.errors.SERVER_ERROR,{requestBody:bodyify(ge.body,ze["content-type"]),requestMethod:ge.method,url:ve})})})();return Promise.race([He.promise,Ge])}function fetchJson(n,t,c){let ie=(ae,ue)=>{let de=null;if(ae!=null)try{de=JSON.parse(toUtf8String(ae))}catch(ve){logger$6.throwError("invalid JSON",Logger.errors.SERVER_ERROR,{body:ae,error:ve})}return c&&(de=c(de,ue)),de},se=null;if(t!=null){se=toUtf8Bytes(t);const ae=typeof n=="string"?{url:n}:shallowCopy(n);ae.headers?Object.keys(ae.headers).filter(ue=>ue.toLowerCase()==="content-type").length!==0||(ae.headers=shallowCopy(ae.headers),ae.headers["content-type"]="application/json"):ae.headers={"content-type":"application/json"},n=ae}return _fetchData(n,se,ie)}function poll(n,t){return t||(t={}),t=shallowCopy(t),t.floor==null&&(t.floor=0),t.ceiling==null&&(t.ceiling=1e4),t.interval==null&&(t.interval=250),new Promise(function(c,ie){let se=null,ae=!1;const ue=()=>ae?!1:(ae=!0,se&&clearTimeout(se),!0);t.timeout&&(se=setTimeout(()=>{ue()&&ie(new Error("timeout"))},t.timeout));const de=t.retryLimit;let ve=0;function ge(){return n().then(function(we){if(we!==void 0)ue()&&c(we);else if(t.oncePoll)t.oncePoll.once("poll",ge);else if(t.onceBlock)t.onceBlock.once("block",ge);else if(!ae){if(ve++,ve>de){ue()&&ie(new Error("retry limit reached"));return}let Te=t.interval*parseInt(String(Math.random()*Math.pow(2,ve)));Te<t.floor&&(Te=t.floor),Te>t.ceiling&&(Te=t.ceiling),setTimeout(ge,Te)}return null},function(we){ue()&&ie(we)})}ge()})}const lib_esm$2=Object.freeze(Object.defineProperty({__proto__:null,_fetchData,fetchJson,poll},Symbol.toStringTag,{value:"Module"}));var ALPHABET$2="qpzry9x8gf2tvdw0s3jn54khce6mua7l",ALPHABET_MAP$1={};for(var z$3=0;z$3<ALPHABET$2.length;z$3++){var x$2=ALPHABET$2.charAt(z$3);if(ALPHABET_MAP$1[x$2]!==void 0)throw new TypeError(x$2+" is ambiguous");ALPHABET_MAP$1[x$2]=z$3}function polymodStep$1(n){var t=n>>25;return(n&33554431)<<5^-(t>>0&1)&996825010^-(t>>1&1)&642813549^-(t>>2&1)&513874426^-(t>>3&1)&1027748829^-(t>>4&1)&705979059}function prefixChk$1(n){for(var t=1,c=0;c<n.length;++c){var ie=n.charCodeAt(c);if(ie<33||ie>126)return"Invalid prefix ("+n+")";t=polymodStep$1(t)^ie>>5}for(t=polymodStep$1(t),c=0;c<n.length;++c){var se=n.charCodeAt(c);t=polymodStep$1(t)^se&31}return t}function encode$4(n,t,c){if(c=c||90,n.length+7+t.length>c)throw new TypeError("Exceeds length limit");n=n.toLowerCase();var ie=prefixChk$1(n);if(typeof ie=="string")throw new Error(ie);for(var se=n+"1",ae=0;ae<t.length;++ae){var ue=t[ae];if(ue>>5)throw new Error("Non 5-bit word");ie=polymodStep$1(ie)^ue,se+=ALPHABET$2.charAt(ue)}for(ae=0;ae<6;++ae)ie=polymodStep$1(ie);for(ie^=1,ae=0;ae<6;++ae){var de=ie>>(5-ae)*5&31;se+=ALPHABET$2.charAt(de)}return se}function __decode(n,t){if(t=t||90,n.length<8)return n+" too short";if(n.length>t)return"Exceeds length limit";var c=n.toLowerCase(),ie=n.toUpperCase();if(n!==c&&n!==ie)return"Mixed-case string "+n;n=c;var se=n.lastIndexOf("1");if(se===-1)return"No separator character for "+n;if(se===0)return"Missing prefix for "+n;var ae=n.slice(0,se),ue=n.slice(se+1);if(ue.length<6)return"Data too short";var de=prefixChk$1(ae);if(typeof de=="string")return de;for(var ve=[],ge=0;ge<ue.length;++ge){var we=ue.charAt(ge),Te=ALPHABET_MAP$1[we];if(Te===void 0)return"Unknown character "+we;de=polymodStep$1(de)^Te,!(ge+6>=ue.length)&&ve.push(Te)}return de!==1?"Invalid checksum for "+n:{prefix:ae,words:ve}}function decodeUnsafe(){var n=__decode.apply(null,arguments);if(typeof n=="object")return n}function decode$5(n){var t=__decode.apply(null,arguments);if(typeof t=="object")return t;throw new Error(t)}function convert$1(n,t,c,ie){for(var se=0,ae=0,ue=(1<<c)-1,de=[],ve=0;ve<n.length;++ve)for(se=se<<t|n[ve],ae+=t;ae>=c;)ae-=c,de.push(se>>ae&ue);if(ie)ae>0&&de.push(se<<c-ae&ue);else{if(ae>=t)return"Excess padding";if(se<<c-ae&ue)return"Non-zero padding"}return de}function toWordsUnsafe(n){var t=convert$1(n,8,5,!0);if(Array.isArray(t))return t}function toWords$1(n){var t=convert$1(n,8,5,!0);if(Array.isArray(t))return t;throw new Error(t)}function fromWordsUnsafe$1(n){var t=convert$1(n,5,8,!1);if(Array.isArray(t))return t}function fromWords$1(n){var t=convert$1(n,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}var bech32$1={decodeUnsafe,decode:decode$5,encode:encode$4,toWordsUnsafe,toWords:toWords$1,fromWordsUnsafe:fromWordsUnsafe$1,fromWords:fromWords$1};const bech32$2=getDefaultExportFromCjs$2(bech32$1),version$8="providers/5.8.0",logger$5=new Logger(version$8);class Formatter{constructor(){this.formats=this.getDefaultFormats()}getDefaultFormats(){const t={},c=this.address.bind(this),ie=this.bigNumber.bind(this),se=this.blockTag.bind(this),ae=this.data.bind(this),ue=this.hash.bind(this),de=this.hex.bind(this),ve=this.number.bind(this),ge=this.type.bind(this),we=Te=>this.data(Te,!0);return t.transaction={hash:ue,type:ge,accessList:Formatter.allowNull(this.accessList.bind(this),null),blockHash:Formatter.allowNull(ue,null),blockNumber:Formatter.allowNull(ve,null),transactionIndex:Formatter.allowNull(ve,null),confirmations:Formatter.allowNull(ve,null),from:c,gasPrice:Formatter.allowNull(ie),maxPriorityFeePerGas:Formatter.allowNull(ie),maxFeePerGas:Formatter.allowNull(ie),gasLimit:ie,to:Formatter.allowNull(c,null),value:ie,nonce:ve,data:ae,r:Formatter.allowNull(this.uint256),s:Formatter.allowNull(this.uint256),v:Formatter.allowNull(ve),creates:Formatter.allowNull(c,null),raw:Formatter.allowNull(ae)},t.transactionRequest={from:Formatter.allowNull(c),nonce:Formatter.allowNull(ve),gasLimit:Formatter.allowNull(ie),gasPrice:Formatter.allowNull(ie),maxPriorityFeePerGas:Formatter.allowNull(ie),maxFeePerGas:Formatter.allowNull(ie),to:Formatter.allowNull(c),value:Formatter.allowNull(ie),data:Formatter.allowNull(we),type:Formatter.allowNull(ve),accessList:Formatter.allowNull(this.accessList.bind(this),null)},t.receiptLog={transactionIndex:ve,blockNumber:ve,transactionHash:ue,address:c,topics:Formatter.arrayOf(ue),data:ae,logIndex:ve,blockHash:ue},t.receipt={to:Formatter.allowNull(this.address,null),from:Formatter.allowNull(this.address,null),contractAddress:Formatter.allowNull(c,null),transactionIndex:ve,root:Formatter.allowNull(de),gasUsed:ie,logsBloom:Formatter.allowNull(ae),blockHash:ue,transactionHash:ue,logs:Formatter.arrayOf(this.receiptLog.bind(this)),blockNumber:ve,confirmations:Formatter.allowNull(ve,null),cumulativeGasUsed:ie,effectiveGasPrice:Formatter.allowNull(ie),status:Formatter.allowNull(ve),type:ge},t.block={hash:Formatter.allowNull(ue),parentHash:ue,number:ve,timestamp:ve,nonce:Formatter.allowNull(de),difficulty:this.difficulty.bind(this),gasLimit:ie,gasUsed:ie,miner:Formatter.allowNull(c),extraData:ae,transactions:Formatter.allowNull(Formatter.arrayOf(ue)),baseFeePerGas:Formatter.allowNull(ie)},t.blockWithTransactions=shallowCopy(t.block),t.blockWithTransactions.transactions=Formatter.allowNull(Formatter.arrayOf(this.transactionResponse.bind(this))),t.filter={fromBlock:Formatter.allowNull(se,void 0),toBlock:Formatter.allowNull(se,void 0),blockHash:Formatter.allowNull(ue,void 0),address:Formatter.allowNull(c,void 0),topics:Formatter.allowNull(this.topics.bind(this),void 0)},t.filterLog={blockNumber:Formatter.allowNull(ve),blockHash:Formatter.allowNull(ue),transactionIndex:ve,removed:Formatter.allowNull(this.boolean.bind(this)),address:c,data:Formatter.allowFalsish(ae,"0x"),topics:Formatter.arrayOf(ue),transactionHash:ue,logIndex:ve},t}accessList(t){return accessListify(t||[])}number(t){return t==="0x"?0:BigNumber.from(t).toNumber()}type(t){return t==="0x"||t==null?0:BigNumber.from(t).toNumber()}bigNumber(t){return BigNumber.from(t)}boolean(t){if(typeof t=="boolean")return t;if(typeof t=="string"){if(t=t.toLowerCase(),t==="true")return!0;if(t==="false")return!1}throw new Error("invalid boolean - "+t)}hex(t,c){return typeof t=="string"&&(!c&&t.substring(0,2)!=="0x"&&(t="0x"+t),isHexString(t))?t.toLowerCase():logger$5.throwArgumentError("invalid hash","value",t)}data(t,c){const ie=this.hex(t,c);if(ie.length%2!==0)throw new Error("invalid data; odd-length - "+t);return ie}address(t){return getAddress$1(t)}callAddress(t){if(!isHexString(t,32))return null;const c=getAddress$1(hexDataSlice(t,12));return c===AddressZero?null:c}contractAddress(t){return getContractAddress(t)}blockTag(t){if(t==null)return"latest";if(t==="earliest")return"0x0";switch(t){case"earliest":return"0x0";case"latest":case"pending":case"safe":case"finalized":return t}if(typeof t=="number"||isHexString(t))return hexValue(t);throw new Error("invalid blockTag")}hash(t,c){const ie=this.hex(t,c);return hexDataLength(ie)!==32?logger$5.throwArgumentError("invalid hash","value",t):ie}difficulty(t){if(t==null)return null;const c=BigNumber.from(t);try{return c.toNumber()}catch{}return null}uint256(t){if(!isHexString(t))throw new Error("invalid uint256");return hexZeroPad(t,32)}_block(t,c){t.author!=null&&t.miner==null&&(t.miner=t.author);const ie=t._difficulty!=null?t._difficulty:t.difficulty,se=Formatter.check(c,t);return se._difficulty=ie==null?null:BigNumber.from(ie),se}block(t){return this._block(t,this.formats.block)}blockWithTransactions(t){return this._block(t,this.formats.blockWithTransactions)}transactionRequest(t){return Formatter.check(this.formats.transactionRequest,t)}transactionResponse(t){t.gas!=null&&t.gasLimit==null&&(t.gasLimit=t.gas),t.to&&BigNumber.from(t.to).isZero()&&(t.to="0x0000000000000000000000000000000000000000"),t.input!=null&&t.data==null&&(t.data=t.input),t.to==null&&t.creates==null&&(t.creates=this.contractAddress(t)),(t.type===1||t.type===2)&&t.accessList==null&&(t.accessList=[]);const c=Formatter.check(this.formats.transaction,t);if(t.chainId!=null){let ie=t.chainId;isHexString(ie)&&(ie=BigNumber.from(ie).toNumber()),c.chainId=ie}else{let ie=t.networkId;ie==null&&c.v==null&&(ie=t.chainId),isHexString(ie)&&(ie=BigNumber.from(ie).toNumber()),typeof ie!="number"&&c.v!=null&&(ie=(c.v-35)/2,ie<0&&(ie=0),ie=parseInt(ie)),typeof ie!="number"&&(ie=0),c.chainId=ie}return c.blockHash&&c.blockHash.replace(/0/g,"")==="x"&&(c.blockHash=null),c}transaction(t){return parse$2(t)}receiptLog(t){return Formatter.check(this.formats.receiptLog,t)}receipt(t){const c=Formatter.check(this.formats.receipt,t);if(c.root!=null)if(c.root.length<=4){const ie=BigNumber.from(c.root).toNumber();ie===0||ie===1?(c.status!=null&&c.status!==ie&&logger$5.throwArgumentError("alt-root-status/status mismatch","value",{root:c.root,status:c.status}),c.status=ie,delete c.root):logger$5.throwArgumentError("invalid alt-root-status","value.root",c.root)}else c.root.length!==66&&logger$5.throwArgumentError("invalid root hash","value.root",c.root);return c.status!=null&&(c.byzantium=!0),c}topics(t){return Array.isArray(t)?t.map(c=>this.topics(c)):t!=null?this.hash(t,!0):null}filter(t){return Formatter.check(this.formats.filter,t)}filterLog(t){return Formatter.check(this.formats.filterLog,t)}static check(t,c){const ie={};for(const se in t)try{const ae=t[se](c[se]);ae!==void 0&&(ie[se]=ae)}catch(ae){throw ae.checkKey=se,ae.checkValue=c[se],ae}return ie}static allowNull(t,c){return function(ie){return ie==null?c:t(ie)}}static allowFalsish(t,c){return function(ie){return ie?t(ie):c}}static arrayOf(t){return function(c){if(!Array.isArray(c))throw new Error("not an array");const ie=[];return c.forEach(function(se){ie.push(t(se))}),ie}}}var __awaiter$c=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$4=new Logger(version$8),MAX_CCIP_REDIRECTS=10;function checkTopic(n){return n==null?"null":(hexDataLength(n)!==32&&logger$4.throwArgumentError("invalid topic","topic",n),n.toLowerCase())}function serializeTopics(n){for(n=n.slice();n.length>0&&n[n.length-1]==null;)n.pop();return n.map(t=>{if(Array.isArray(t)){const c={};t.forEach(se=>{c[checkTopic(se)]=!0});const ie=Object.keys(c);return ie.sort(),ie.join("|")}else return checkTopic(t)}).join("&")}function deserializeTopics(n){return n===""?[]:n.split(/&/g).map(t=>{if(t==="")return[];const c=t.split("|").map(ie=>ie==="null"?null:ie);return c.length===1?c[0]:c})}function getEventTag(n){if(typeof n=="string"){if(n=n.toLowerCase(),hexDataLength(n)===32)return"tx:"+n;if(n.indexOf(":")===-1)return n}else{if(Array.isArray(n))return"filter:*:"+serializeTopics(n);if(ForkEvent.isForkEvent(n))throw logger$4.warn("not implemented"),new Error("not implemented");if(n&&typeof n=="object")return"filter:"+(n.address||"*")+":"+serializeTopics(n.topics||[])}throw new Error("invalid event - "+n)}function getTime(){return new Date().getTime()}function stall(n){return new Promise(t=>{setTimeout(t,n)})}const PollableEvents=["block","network","pending","poll"];let Event$1=class{constructor(n,t,c){defineReadOnly(this,"tag",n),defineReadOnly(this,"listener",t),defineReadOnly(this,"once",c),this._lastBlockNumber=-2,this._inflight=!1}get event(){switch(this.type){case"tx":return this.hash;case"filter":return this.filter}return this.tag}get type(){return this.tag.split(":")[0]}get hash(){const n=this.tag.split(":");return n[0]!=="tx"?null:n[1]}get filter(){const n=this.tag.split(":");if(n[0]!=="filter")return null;const t=n[1],c=deserializeTopics(n[2]),ie={};return c.length>0&&(ie.topics=c),t&&t!=="*"&&(ie.address=t),ie}pollable(){return this.tag.indexOf(":")>=0||PollableEvents.indexOf(this.tag)>=0}};const coinInfos={0:{symbol:"btc",p2pkh:0,p2sh:5,prefix:"bc"},2:{symbol:"ltc",p2pkh:48,p2sh:50,prefix:"ltc"},3:{symbol:"doge",p2pkh:30,p2sh:22},60:{symbol:"eth",ilk:"eth"},61:{symbol:"etc",ilk:"eth"},700:{symbol:"xdai",ilk:"eth"}};function bytes32ify(n){return hexZeroPad(BigNumber.from(n).toHexString(),32)}function base58Encode(n){return Base58.encode(concat$1([n,hexDataSlice(sha256$7(sha256$7(n)),0,4)]))}const matcherIpfs=new RegExp("^(ipfs)://(.*)$","i"),matchers=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),matcherIpfs,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];function _parseString(n,t){try{return toUtf8String(_parseBytes(n,t))}catch{}return null}function _parseBytes(n,t){if(n==="0x")return null;const c=BigNumber.from(hexDataSlice(n,t,t+32)).toNumber(),ie=BigNumber.from(hexDataSlice(n,c,c+32)).toNumber();return hexDataSlice(n,c+32,c+32+ie)}function getIpfsLink(n){return n.match(/^ipfs:\/\/ipfs\//i)?n=n.substring(12):n.match(/^ipfs:\/\//i)?n=n.substring(7):logger$4.throwArgumentError("unsupported IPFS format","link",n),`https://gateway.ipfs.io/ipfs/${n}`}function numPad(n){const t=arrayify(n);if(t.length>32)throw new Error("internal; should not happen");const c=new Uint8Array(32);return c.set(t,32-t.length),c}function bytesPad(n){if(n.length%32===0)return n;const t=new Uint8Array(Math.ceil(n.length/32)*32);return t.set(n),t}function encodeBytes(n){const t=[];let c=0;for(let ie=0;ie<n.length;ie++)t.push(null),c+=32;for(let ie=0;ie<n.length;ie++){const se=arrayify(n[ie]);t[ie]=numPad(c),t.push(numPad(se.length)),t.push(bytesPad(se)),c+=32+Math.ceil(se.length/32)*32}return hexConcat(t)}class Resolver{constructor(t,c,ie,se){defineReadOnly(this,"provider",t),defineReadOnly(this,"name",ie),defineReadOnly(this,"address",t.formatter.address(c)),defineReadOnly(this,"_resolvedAddress",se)}supportsWildcard(){return this._supportsEip2544||(this._supportsEip2544=this.provider.call({to:this.address,data:"0x01ffc9a79061b92300000000000000000000000000000000000000000000000000000000"}).then(t=>BigNumber.from(t).eq(1)).catch(t=>{if(t.code===Logger.errors.CALL_EXCEPTION)return!1;throw this._supportsEip2544=null,t})),this._supportsEip2544}_fetch(t,c){return __awaiter$c(this,void 0,void 0,function*(){const ie={to:this.address,ccipReadEnabled:!0,data:hexConcat([t,namehash$1(this.name),c||"0x"])};let se=!1;(yield this.supportsWildcard())&&(se=!0,ie.data=hexConcat(["0x9061b923",encodeBytes([dnsEncode(this.name),ie.data])]));try{let ae=yield this.provider.call(ie);return arrayify(ae).length%32===4&&logger$4.throwError("resolver threw error",Logger.errors.CALL_EXCEPTION,{transaction:ie,data:ae}),se&&(ae=_parseBytes(ae,0)),ae}catch(ae){if(ae.code===Logger.errors.CALL_EXCEPTION)return null;throw ae}})}_fetchBytes(t,c){return __awaiter$c(this,void 0,void 0,function*(){const ie=yield this._fetch(t,c);return ie!=null?_parseBytes(ie,0):null})}_getAddress(t,c){const ie=coinInfos[String(t)];if(ie==null&&logger$4.throwError(`unsupported coin type: ${t}`,Logger.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${t})`}),ie.ilk==="eth")return this.provider.formatter.address(c);const se=arrayify(c);if(ie.p2pkh!=null){const ae=c.match(/^0x76a9([0-9a-f][0-9a-f])([0-9a-f]*)88ac$/);if(ae){const ue=parseInt(ae[1],16);if(ae[2].length===ue*2&&ue>=1&&ue<=75)return base58Encode(concat$1([[ie.p2pkh],"0x"+ae[2]]))}}if(ie.p2sh!=null){const ae=c.match(/^0xa9([0-9a-f][0-9a-f])([0-9a-f]*)87$/);if(ae){const ue=parseInt(ae[1],16);if(ae[2].length===ue*2&&ue>=1&&ue<=75)return base58Encode(concat$1([[ie.p2sh],"0x"+ae[2]]))}}if(ie.prefix!=null){const ae=se[1];let ue=se[0];if(ue===0?ae!==20&&ae!==32&&(ue=-1):ue=-1,ue>=0&&se.length===2+ae&&ae>=1&&ae<=75){const de=bech32$2.toWords(se.slice(2));return de.unshift(ue),bech32$2.encode(ie.prefix,de)}}return null}getAddress(t){return __awaiter$c(this,void 0,void 0,function*(){if(t==null&&(t=60),t===60)try{const se=yield this._fetch("0x3b3b57de");return se==="0x"||se===HashZero?null:this.provider.formatter.callAddress(se)}catch(se){if(se.code===Logger.errors.CALL_EXCEPTION)return null;throw se}const c=yield this._fetchBytes("0xf1cb7e06",bytes32ify(t));if(c==null||c==="0x")return null;const ie=this._getAddress(t,c);return ie==null&&logger$4.throwError("invalid or unsupported coin data",Logger.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${t})`,coinType:t,data:c}),ie})}getAvatar(){return __awaiter$c(this,void 0,void 0,function*(){const t=[{type:"name",content:this.name}];try{const c=yield this.getText("avatar");if(c==null)return null;for(let ie=0;ie<matchers.length;ie++){const se=c.match(matchers[ie]);if(se==null)continue;const ae=se[1].toLowerCase();switch(ae){case"https":return t.push({type:"url",content:c}),{linkage:t,url:c};case"data":return t.push({type:"data",content:c}),{linkage:t,url:c};case"ipfs":return t.push({type:"ipfs",content:c}),{linkage:t,url:getIpfsLink(c)};case"erc721":case"erc1155":{const ue=ae==="erc721"?"0xc87b56dd":"0x0e89341c";t.push({type:ae,content:c});const de=this._resolvedAddress||(yield this.getAddress()),ve=(se[2]||"").split("/");if(ve.length!==2)return null;const ge=yield this.provider.formatter.address(ve[0]),we=hexZeroPad(BigNumber.from(ve[1]).toHexString(),32);if(ae==="erc721"){const He=this.provider.formatter.callAddress(yield this.provider.call({to:ge,data:hexConcat(["0x6352211e",we])}));if(de!==He)return null;t.push({type:"owner",content:He})}else if(ae==="erc1155"){const He=BigNumber.from(yield this.provider.call({to:ge,data:hexConcat(["0x00fdd58e",hexZeroPad(de,32),we])}));if(He.isZero())return null;t.push({type:"balance",content:He.toString()})}const Te={to:this.provider.formatter.address(ve[0]),data:hexConcat([ue,we])};let Ne=_parseString(yield this.provider.call(Te),0);if(Ne==null)return null;t.push({type:"metadata-url-base",content:Ne}),ae==="erc1155"&&(Ne=Ne.replace("{id}",we.substring(2)),t.push({type:"metadata-url-expanded",content:Ne})),Ne.match(/^ipfs:/i)&&(Ne=getIpfsLink(Ne)),t.push({type:"metadata-url",content:Ne});const qe=yield fetchJson(Ne);if(!qe)return null;t.push({type:"metadata",content:JSON.stringify(qe)});let ze=qe.image;if(typeof ze!="string")return null;if(!ze.match(/^(https:\/\/|data:)/i)){if(ze.match(matcherIpfs)==null)return null;t.push({type:"url-ipfs",content:ze}),ze=getIpfsLink(ze)}return t.push({type:"url",content:ze}),{linkage:t,url:ze}}}}}catch{}return null})}getContentHash(){return __awaiter$c(this,void 0,void 0,function*(){const t=yield this._fetchBytes("0xbc1c58d1");if(t==null||t==="0x")return null;const c=t.match(/^0xe3010170(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(c){const ue=parseInt(c[3],16);if(c[4].length===ue*2)return"ipfs://"+Base58.encode("0x"+c[1])}const ie=t.match(/^0xe5010172(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(ie){const ue=parseInt(ie[3],16);if(ie[4].length===ue*2)return"ipns://"+Base58.encode("0x"+ie[1])}const se=t.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(se&&se[1].length===64)return"bzz://"+se[1];const ae=t.match(/^0x90b2c605([0-9a-f]*)$/);if(ae&&ae[1].length===68){const ue={"=":"","+":"-","/":"_"};return"sia://"+encode$5("0x"+ae[1]).replace(/[=+\/]/g,de=>ue[de])}return logger$4.throwError("invalid or unsupported content hash data",Logger.errors.UNSUPPORTED_OPERATION,{operation:"getContentHash()",data:t})})}getText(t){return __awaiter$c(this,void 0,void 0,function*(){let c=toUtf8Bytes(t);c=concat$1([bytes32ify(64),bytes32ify(c.length),c]),c.length%32!==0&&(c=concat$1([c,hexZeroPad("0x",32-t.length%32)]));const ie=yield this._fetchBytes("0x59d1d43c",hexlify(c));return ie==null||ie==="0x"?null:toUtf8String(ie)})}}let defaultFormatter=null,nextPollId=1;class BaseProvider extends Provider{constructor(t){if(super(),this._events=[],this._emitted={block:-2},this.disableCcipRead=!1,this.formatter=new.target.getFormatter(),defineReadOnly(this,"anyNetwork",t==="any"),this.anyNetwork&&(t=this.detectNetwork()),t instanceof Promise)this._networkPromise=t,t.catch(c=>{}),this._ready().catch(c=>{});else{const c=getStatic(new.target,"getNetwork")(t);c?(defineReadOnly(this,"_network",c),this.emit("network",c,null)):logger$4.throwArgumentError("invalid network","network",t)}this._maxInternalBlockNumber=-1024,this._lastBlockNumber=-2,this._maxFilterBlockRange=10,this._pollingInterval=4e3,this._fastQueryDate=0}_ready(){return __awaiter$c(this,void 0,void 0,function*(){if(this._network==null){let t=null;if(this._networkPromise)try{t=yield this._networkPromise}catch{}t==null&&(t=yield this.detectNetwork()),t||logger$4.throwError("no network detected",Logger.errors.UNKNOWN_ERROR,{}),this._network==null&&(this.anyNetwork?this._network=t:defineReadOnly(this,"_network",t),this.emit("network",t,null))}return this._network})}get ready(){return poll(()=>this._ready().then(t=>t,t=>{if(!(t.code===Logger.errors.NETWORK_ERROR&&t.event==="noNetwork"))throw t}))}static getFormatter(){return defaultFormatter==null&&(defaultFormatter=new Formatter),defaultFormatter}static getNetwork(t){return getNetwork(t??"homestead")}ccipReadFetch(t,c,ie){return __awaiter$c(this,void 0,void 0,function*(){if(this.disableCcipRead||ie.length===0)return null;const se=t.to.toLowerCase(),ae=c.toLowerCase(),ue=[];for(let de=0;de<ie.length;de++){const ve=ie[de],ge=ve.replace("{sender}",se).replace("{data}",ae),we=ve.indexOf("{data}")>=0?null:JSON.stringify({data:ae,sender:se}),Te=yield fetchJson({url:ge,errorPassThrough:!0},we,(qe,ze)=>(qe.status=ze.statusCode,qe));if(Te.data)return Te.data;const Ne=Te.message||"unknown error";if(Te.status>=400&&Te.status<500)return logger$4.throwError(`response not found during CCIP fetch: ${Ne}`,Logger.errors.SERVER_ERROR,{url:ve,errorMessage:Ne});ue.push(Ne)}return logger$4.throwError(`error encountered during CCIP fetch: ${ue.map(de=>JSON.stringify(de)).join(", ")}`,Logger.errors.SERVER_ERROR,{urls:ie,errorMessages:ue})})}_getInternalBlockNumber(t){return __awaiter$c(this,void 0,void 0,function*(){if(yield this._ready(),t>0)for(;this._internalBlockNumber;){const se=this._internalBlockNumber;try{const ae=yield se;if(getTime()-ae.respTime<=t)return ae.blockNumber;break}catch{if(this._internalBlockNumber===se)break}}const c=getTime(),ie=resolveProperties({blockNumber:this.perform("getBlockNumber",{}),networkError:this.getNetwork().then(se=>null,se=>se)}).then(({blockNumber:se,networkError:ae})=>{if(ae)throw this._internalBlockNumber===ie&&(this._internalBlockNumber=null),ae;const ue=getTime();return se=BigNumber.from(se).toNumber(),se<this._maxInternalBlockNumber&&(se=this._maxInternalBlockNumber),this._maxInternalBlockNumber=se,this._setFastBlockNumber(se),{blockNumber:se,reqTime:c,respTime:ue}});return this._internalBlockNumber=ie,ie.catch(se=>{this._internalBlockNumber===ie&&(this._internalBlockNumber=null)}),(yield ie).blockNumber})}poll(){return __awaiter$c(this,void 0,void 0,function*(){const t=nextPollId++,c=[];let ie=null;try{ie=yield this._getInternalBlockNumber(100+this.pollingInterval/2)}catch(se){this.emit("error",se);return}if(this._setFastBlockNumber(ie),this.emit("poll",t,ie),ie===this._lastBlockNumber){this.emit("didPoll",t);return}if(this._emitted.block===-2&&(this._emitted.block=ie-1),Math.abs(this._emitted.block-ie)>1e3)logger$4.warn(`network block skew detected; skipping block events (emitted=${this._emitted.block} blockNumber${ie})`),this.emit("error",logger$4.makeError("network block skew detected",Logger.errors.NETWORK_ERROR,{blockNumber:ie,event:"blockSkew",previousBlockNumber:this._emitted.block})),this.emit("block",ie);else for(let se=this._emitted.block+1;se<=ie;se++)this.emit("block",se);this._emitted.block!==ie&&(this._emitted.block=ie,Object.keys(this._emitted).forEach(se=>{if(se==="block")return;const ae=this._emitted[se];ae!=="pending"&&ie-ae>12&&delete this._emitted[se]})),this._lastBlockNumber===-2&&(this._lastBlockNumber=ie-1),this._events.forEach(se=>{switch(se.type){case"tx":{const ae=se.hash;let ue=this.getTransactionReceipt(ae).then(de=>(!de||de.blockNumber==null||(this._emitted["t:"+ae]=de.blockNumber,this.emit(ae,de)),null)).catch(de=>{this.emit("error",de)});c.push(ue);break}case"filter":{if(!se._inflight){se._inflight=!0,se._lastBlockNumber===-2&&(se._lastBlockNumber=ie-1);const ae=se.filter;ae.fromBlock=se._lastBlockNumber+1,ae.toBlock=ie;const ue=ae.toBlock-this._maxFilterBlockRange;ue>ae.fromBlock&&(ae.fromBlock=ue),ae.fromBlock<0&&(ae.fromBlock=0);const de=this.getLogs(ae).then(ve=>{se._inflight=!1,ve.length!==0&&ve.forEach(ge=>{ge.blockNumber>se._lastBlockNumber&&(se._lastBlockNumber=ge.blockNumber),this._emitted["b:"+ge.blockHash]=ge.blockNumber,this._emitted["t:"+ge.transactionHash]=ge.blockNumber,this.emit(ae,ge)})}).catch(ve=>{this.emit("error",ve),se._inflight=!1});c.push(de)}break}}}),this._lastBlockNumber=ie,Promise.all(c).then(()=>{this.emit("didPoll",t)}).catch(se=>{this.emit("error",se)})})}resetEventsBlock(t){this._lastBlockNumber=t-1,this.polling&&this.poll()}get network(){return this._network}detectNetwork(){return __awaiter$c(this,void 0,void 0,function*(){return logger$4.throwError("provider does not support network detection",Logger.errors.UNSUPPORTED_OPERATION,{operation:"provider.detectNetwork"})})}getNetwork(){return __awaiter$c(this,void 0,void 0,function*(){const t=yield this._ready(),c=yield this.detectNetwork();if(t.chainId!==c.chainId){if(this.anyNetwork)return this._network=c,this._lastBlockNumber=-2,this._fastBlockNumber=null,this._fastBlockNumberPromise=null,this._fastQueryDate=0,this._emitted.block=-2,this._maxInternalBlockNumber=-1024,this._internalBlockNumber=null,this.emit("network",c,t),yield stall(0),this._network;const ie=logger$4.makeError("underlying network changed",Logger.errors.NETWORK_ERROR,{event:"changed",network:t,detectedNetwork:c});throw this.emit("error",ie),ie}return t})}get blockNumber(){return this._getInternalBlockNumber(100+this.pollingInterval/2).then(t=>{this._setFastBlockNumber(t)},t=>{}),this._fastBlockNumber!=null?this._fastBlockNumber:-1}get polling(){return this._poller!=null}set polling(t){t&&!this._poller?(this._poller=setInterval(()=>{this.poll()},this.pollingInterval),this._bootstrapPoll||(this._bootstrapPoll=setTimeout(()=>{this.poll(),this._bootstrapPoll=setTimeout(()=>{this._poller||this.poll(),this._bootstrapPoll=null},this.pollingInterval)},0))):!t&&this._poller&&(clearInterval(this._poller),this._poller=null)}get pollingInterval(){return this._pollingInterval}set pollingInterval(t){if(typeof t!="number"||t<=0||parseInt(String(t))!=t)throw new Error("invalid polling interval");this._pollingInterval=t,this._poller&&(clearInterval(this._poller),this._poller=setInterval(()=>{this.poll()},this._pollingInterval))}_getFastBlockNumber(){const t=getTime();return t-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=t,this._fastBlockNumberPromise=this.getBlockNumber().then(c=>((this._fastBlockNumber==null||c>this._fastBlockNumber)&&(this._fastBlockNumber=c),this._fastBlockNumber))),this._fastBlockNumberPromise}_setFastBlockNumber(t){this._fastBlockNumber!=null&&t<this._fastBlockNumber||(this._fastQueryDate=getTime(),(this._fastBlockNumber==null||t>this._fastBlockNumber)&&(this._fastBlockNumber=t,this._fastBlockNumberPromise=Promise.resolve(t)))}waitForTransaction(t,c,ie){return __awaiter$c(this,void 0,void 0,function*(){return this._waitForTransaction(t,c??1,ie||0,null)})}_waitForTransaction(t,c,ie,se){return __awaiter$c(this,void 0,void 0,function*(){const ae=yield this.getTransactionReceipt(t);return(ae?ae.confirmations:0)>=c?ae:new Promise((ue,de)=>{const ve=[];let ge=!1;const we=function(){return ge?!0:(ge=!0,ve.forEach(Ne=>{Ne()}),!1)},Te=Ne=>{Ne.confirmations<c||we()||ue(Ne)};if(this.on(t,Te),ve.push(()=>{this.removeListener(t,Te)}),se){let Ne=se.startBlock,qe=null;const ze=He=>__awaiter$c(this,void 0,void 0,function*(){ge||(yield stall(1e3),this.getTransactionCount(se.from).then(Ge=>__awaiter$c(this,void 0,void 0,function*(){if(!ge){if(Ge<=se.nonce)Ne=He;else{{const Ze=yield this.getTransaction(t);if(Ze&&Ze.blockNumber!=null)return}for(qe==null&&(qe=Ne-3,qe<se.startBlock&&(qe=se.startBlock));qe<=He;){if(ge)return;const Ze=yield this.getBlockWithTransactions(qe);for(let Ye=0;Ye<Ze.transactions.length;Ye++){const Ft=Ze.transactions[Ye];if(Ft.hash===t)return;if(Ft.from===se.from&&Ft.nonce===se.nonce){if(ge)return;const Mt=yield this.waitForTransaction(Ft.hash,c);if(we())return;let Zt="replaced";Ft.data===se.data&&Ft.to===se.to&&Ft.value.eq(se.value)?Zt="repriced":Ft.data==="0x"&&Ft.from===Ft.to&&Ft.value.isZero()&&(Zt="cancelled"),de(logger$4.makeError("transaction was replaced",Logger.errors.TRANSACTION_REPLACED,{cancelled:Zt==="replaced"||Zt==="cancelled",reason:Zt,replacement:this._wrapTransaction(Ft),hash:t,receipt:Mt}));return}}qe++}}ge||this.once("block",ze)}}),Ge=>{ge||this.once("block",ze)}))});if(ge)return;this.once("block",ze),ve.push(()=>{this.removeListener("block",ze)})}if(typeof ie=="number"&&ie>0){const Ne=setTimeout(()=>{we()||de(logger$4.makeError("timeout exceeded",Logger.errors.TIMEOUT,{timeout:ie}))},ie);Ne.unref&&Ne.unref(),ve.push(()=>{clearTimeout(Ne)})}})})}getBlockNumber(){return __awaiter$c(this,void 0,void 0,function*(){return this._getInternalBlockNumber(0)})}getGasPrice(){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const t=yield this.perform("getGasPrice",{});try{return BigNumber.from(t)}catch(c){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getGasPrice",result:t,error:c})}})}getBalance(t,c){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const ie=yield resolveProperties({address:this._getAddress(t),blockTag:this._getBlockTag(c)}),se=yield this.perform("getBalance",ie);try{return BigNumber.from(se)}catch(ae){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getBalance",params:ie,result:se,error:ae})}})}getTransactionCount(t,c){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const ie=yield resolveProperties({address:this._getAddress(t),blockTag:this._getBlockTag(c)}),se=yield this.perform("getTransactionCount",ie);try{return BigNumber.from(se).toNumber()}catch(ae){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getTransactionCount",params:ie,result:se,error:ae})}})}getCode(t,c){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const ie=yield resolveProperties({address:this._getAddress(t),blockTag:this._getBlockTag(c)}),se=yield this.perform("getCode",ie);try{return hexlify(se)}catch(ae){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getCode",params:ie,result:se,error:ae})}})}getStorageAt(t,c,ie){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const se=yield resolveProperties({address:this._getAddress(t),blockTag:this._getBlockTag(ie),position:Promise.resolve(c).then(ue=>hexValue(ue))}),ae=yield this.perform("getStorageAt",se);try{return hexlify(ae)}catch(ue){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getStorageAt",params:se,result:ae,error:ue})}})}_wrapTransaction(t,c,ie){if(c!=null&&hexDataLength(c)!==32)throw new Error("invalid response - sendTransaction");const se=t;return c!=null&&t.hash!==c&&logger$4.throwError("Transaction hash mismatch from Provider.sendTransaction.",Logger.errors.UNKNOWN_ERROR,{expectedHash:t.hash,returnedHash:c}),se.wait=(ae,ue)=>__awaiter$c(this,void 0,void 0,function*(){ae==null&&(ae=1),ue==null&&(ue=0);let de;ae!==0&&ie!=null&&(de={data:t.data,from:t.from,nonce:t.nonce,to:t.to,value:t.value,startBlock:ie});const ve=yield this._waitForTransaction(t.hash,ae,ue,de);return ve==null&&ae===0?null:(this._emitted["t:"+t.hash]=ve.blockNumber,ve.status===0&&logger$4.throwError("transaction failed",Logger.errors.CALL_EXCEPTION,{transactionHash:t.hash,transaction:t,receipt:ve}),ve)}),se}sendTransaction(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const c=yield Promise.resolve(t).then(ae=>hexlify(ae)),ie=this.formatter.transaction(t);ie.confirmations==null&&(ie.confirmations=0);const se=yield this._getInternalBlockNumber(100+2*this.pollingInterval);try{const ae=yield this.perform("sendTransaction",{signedTransaction:c});return this._wrapTransaction(ie,ae,se)}catch(ae){throw ae.transaction=ie,ae.transactionHash=ie.hash,ae}})}_getTransactionRequest(t){return __awaiter$c(this,void 0,void 0,function*(){const c=yield t,ie={};return["from","to"].forEach(se=>{c[se]!=null&&(ie[se]=Promise.resolve(c[se]).then(ae=>ae?this._getAddress(ae):null))}),["gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","value"].forEach(se=>{c[se]!=null&&(ie[se]=Promise.resolve(c[se]).then(ae=>ae?BigNumber.from(ae):null))}),["type"].forEach(se=>{c[se]!=null&&(ie[se]=Promise.resolve(c[se]).then(ae=>ae??null))}),c.accessList&&(ie.accessList=this.formatter.accessList(c.accessList)),["data"].forEach(se=>{c[se]!=null&&(ie[se]=Promise.resolve(c[se]).then(ae=>ae?hexlify(ae):null))}),this.formatter.transactionRequest(yield resolveProperties(ie))})}_getFilter(t){return __awaiter$c(this,void 0,void 0,function*(){t=yield t;const c={};return t.address!=null&&(c.address=this._getAddress(t.address)),["blockHash","topics"].forEach(ie=>{t[ie]!=null&&(c[ie]=t[ie])}),["fromBlock","toBlock"].forEach(ie=>{t[ie]!=null&&(c[ie]=this._getBlockTag(t[ie]))}),this.formatter.filter(yield resolveProperties(c))})}_call(t,c,ie){return __awaiter$c(this,void 0,void 0,function*(){ie>=MAX_CCIP_REDIRECTS&&logger$4.throwError("CCIP read exceeded maximum redirections",Logger.errors.SERVER_ERROR,{redirects:ie,transaction:t});const se=t.to,ae=yield this.perform("call",{transaction:t,blockTag:c});if(ie>=0&&c==="latest"&&se!=null&&ae.substring(0,10)==="0x556f1830"&&hexDataLength(ae)%32===4)try{const ue=hexDataSlice(ae,4),de=hexDataSlice(ue,0,32);BigNumber.from(de).eq(se)||logger$4.throwError("CCIP Read sender did not match",Logger.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:t,data:ae});const ve=[],ge=BigNumber.from(hexDataSlice(ue,32,64)).toNumber(),we=BigNumber.from(hexDataSlice(ue,ge,ge+32)).toNumber(),Te=hexDataSlice(ue,ge+32);for(let Ze=0;Ze<we;Ze++){const Ye=_parseString(Te,Ze*32);Ye==null&&logger$4.throwError("CCIP Read contained corrupt URL string",Logger.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:t,data:ae}),ve.push(Ye)}const Ne=_parseBytes(ue,64);BigNumber.from(hexDataSlice(ue,100,128)).isZero()||logger$4.throwError("CCIP Read callback selector included junk",Logger.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:t,data:ae});const qe=hexDataSlice(ue,96,100),ze=_parseBytes(ue,128),He=yield this.ccipReadFetch(t,Ne,ve);He==null&&logger$4.throwError("CCIP Read disabled or provided no URLs",Logger.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:t,data:ae});const Ge={to:se,data:hexConcat([qe,encodeBytes([He,ze])])};return this._call(Ge,c,ie+1)}catch(ue){if(ue.code===Logger.errors.SERVER_ERROR)throw ue}try{return hexlify(ae)}catch(ue){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"call",params:{transaction:t,blockTag:c},result:ae,error:ue})}})}call(t,c){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const ie=yield resolveProperties({transaction:this._getTransactionRequest(t),blockTag:this._getBlockTag(c),ccipReadEnabled:Promise.resolve(t.ccipReadEnabled)});return this._call(ie.transaction,ie.blockTag,ie.ccipReadEnabled?0:-1)})}estimateGas(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const c=yield resolveProperties({transaction:this._getTransactionRequest(t)}),ie=yield this.perform("estimateGas",c);try{return BigNumber.from(ie)}catch(se){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"estimateGas",params:c,result:ie,error:se})}})}_getAddress(t){return __awaiter$c(this,void 0,void 0,function*(){t=yield t,typeof t!="string"&&logger$4.throwArgumentError("invalid address or ENS name","name",t);const c=yield this.resolveName(t);return c==null&&logger$4.throwError("ENS name not configured",Logger.errors.UNSUPPORTED_OPERATION,{operation:`resolveName(${JSON.stringify(t)})`}),c})}_getBlock(t,c){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork(),t=yield t;let ie=-128;const se={includeTransactions:!!c};if(isHexString(t,32))se.blockHash=t;else try{se.blockTag=yield this._getBlockTag(t),isHexString(se.blockTag)&&(ie=parseInt(se.blockTag.substring(2),16))}catch{logger$4.throwArgumentError("invalid block hash or block tag","blockHashOrBlockTag",t)}return poll(()=>__awaiter$c(this,void 0,void 0,function*(){const ae=yield this.perform("getBlock",se);if(ae==null)return se.blockHash!=null&&this._emitted["b:"+se.blockHash]==null||se.blockTag!=null&&ie>this._emitted.block?null:void 0;if(c){let ue=null;for(let ve=0;ve<ae.transactions.length;ve++){const ge=ae.transactions[ve];if(ge.blockNumber==null)ge.confirmations=0;else if(ge.confirmations==null){ue==null&&(ue=yield this._getInternalBlockNumber(100+2*this.pollingInterval));let we=ue-ge.blockNumber+1;we<=0&&(we=1),ge.confirmations=we}}const de=this.formatter.blockWithTransactions(ae);return de.transactions=de.transactions.map(ve=>this._wrapTransaction(ve)),de}return this.formatter.block(ae)}),{oncePoll:this})})}getBlock(t){return this._getBlock(t,!1)}getBlockWithTransactions(t){return this._getBlock(t,!0)}getTransaction(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork(),t=yield t;const c={transactionHash:this.formatter.hash(t,!0)};return poll(()=>__awaiter$c(this,void 0,void 0,function*(){const ie=yield this.perform("getTransaction",c);if(ie==null)return this._emitted["t:"+t]==null?null:void 0;const se=this.formatter.transactionResponse(ie);if(se.blockNumber==null)se.confirmations=0;else if(se.confirmations==null){let ae=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-se.blockNumber+1;ae<=0&&(ae=1),se.confirmations=ae}return this._wrapTransaction(se)}),{oncePoll:this})})}getTransactionReceipt(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork(),t=yield t;const c={transactionHash:this.formatter.hash(t,!0)};return poll(()=>__awaiter$c(this,void 0,void 0,function*(){const ie=yield this.perform("getTransactionReceipt",c);if(ie==null)return this._emitted["t:"+t]==null?null:void 0;if(ie.blockHash==null)return;const se=this.formatter.receipt(ie);if(se.blockNumber==null)se.confirmations=0;else if(se.confirmations==null){let ae=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-se.blockNumber+1;ae<=0&&(ae=1),se.confirmations=ae}return se}),{oncePoll:this})})}getLogs(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const c=yield resolveProperties({filter:this._getFilter(t)}),ie=yield this.perform("getLogs",c);return ie.forEach(se=>{se.removed==null&&(se.removed=!1)}),Formatter.arrayOf(this.formatter.filterLog.bind(this.formatter))(ie)})}getEtherPrice(){return __awaiter$c(this,void 0,void 0,function*(){return yield this.getNetwork(),this.perform("getEtherPrice",{})})}_getBlockTag(t){return __awaiter$c(this,void 0,void 0,function*(){if(t=yield t,typeof t=="number"&&t<0){t%1&&logger$4.throwArgumentError("invalid BlockTag","blockTag",t);let c=yield this._getInternalBlockNumber(100+2*this.pollingInterval);return c+=t,c<0&&(c=0),this.formatter.blockTag(c)}return this.formatter.blockTag(t)})}getResolver(t){return __awaiter$c(this,void 0,void 0,function*(){let c=t;for(;;){if(c===""||c==="."||t!=="eth"&&c==="eth")return null;const ie=yield this._getResolver(c,"getResolver");if(ie!=null){const se=new Resolver(this,ie,t);return c!==t&&!(yield se.supportsWildcard())?null:se}c=c.split(".").slice(1).join(".")}})}_getResolver(t,c){return __awaiter$c(this,void 0,void 0,function*(){c==null&&(c="ENS");const ie=yield this.getNetwork();ie.ensAddress||logger$4.throwError("network does not support ENS",Logger.errors.UNSUPPORTED_OPERATION,{operation:c,network:ie.name});try{const se=yield this.call({to:ie.ensAddress,data:"0x0178b8bf"+namehash$1(t).substring(2)});return this.formatter.callAddress(se)}catch{}return null})}resolveName(t){return __awaiter$c(this,void 0,void 0,function*(){t=yield t;try{return Promise.resolve(this.formatter.address(t))}catch(ie){if(isHexString(t))throw ie}typeof t!="string"&&logger$4.throwArgumentError("invalid ENS name","name",t);const c=yield this.getResolver(t);return c?yield c.getAddress():null})}lookupAddress(t){return __awaiter$c(this,void 0,void 0,function*(){t=yield t,t=this.formatter.address(t);const c=t.substring(2).toLowerCase()+".addr.reverse",ie=yield this._getResolver(c,"lookupAddress");if(ie==null)return null;const se=_parseString(yield this.call({to:ie,data:"0x691f3431"+namehash$1(c).substring(2)}),0);return(yield this.resolveName(se))!=t?null:se})}getAvatar(t){return __awaiter$c(this,void 0,void 0,function*(){let c=null;if(isHexString(t)){const se=this.formatter.address(t).substring(2).toLowerCase()+".addr.reverse",ae=yield this._getResolver(se,"getAvatar");if(!ae)return null;c=new Resolver(this,ae,se);try{const ue=yield c.getAvatar();if(ue)return ue.url}catch(ue){if(ue.code!==Logger.errors.CALL_EXCEPTION)throw ue}try{const ue=_parseString(yield this.call({to:ae,data:"0x691f3431"+namehash$1(se).substring(2)}),0);c=yield this.getResolver(ue)}catch(ue){if(ue.code!==Logger.errors.CALL_EXCEPTION)throw ue;return null}}else if(c=yield this.getResolver(t),!c)return null;const ie=yield c.getAvatar();return ie==null?null:ie.url})}perform(t,c){return logger$4.throwError(t+" not implemented",Logger.errors.NOT_IMPLEMENTED,{operation:t})}_startEvent(t){this.polling=this._events.filter(c=>c.pollable()).length>0}_stopEvent(t){this.polling=this._events.filter(c=>c.pollable()).length>0}_addEventListener(t,c,ie){const se=new Event$1(getEventTag(t),c,ie);return this._events.push(se),this._startEvent(se),this}on(t,c){return this._addEventListener(t,c,!1)}once(t,c){return this._addEventListener(t,c,!0)}emit(t,...c){let ie=!1,se=[],ae=getEventTag(t);return this._events=this._events.filter(ue=>ue.tag!==ae?!0:(setTimeout(()=>{ue.listener.apply(this,c)},0),ie=!0,ue.once?(se.push(ue),!1):!0)),se.forEach(ue=>{this._stopEvent(ue)}),ie}listenerCount(t){if(!t)return this._events.length;let c=getEventTag(t);return this._events.filter(ie=>ie.tag===c).length}listeners(t){if(t==null)return this._events.map(ie=>ie.listener);let c=getEventTag(t);return this._events.filter(ie=>ie.tag===c).map(ie=>ie.listener)}off(t,c){if(c==null)return this.removeAllListeners(t);const ie=[];let se=!1,ae=getEventTag(t);return this._events=this._events.filter(ue=>ue.tag!==ae||ue.listener!=c||se?!0:(se=!0,ie.push(ue),!1)),ie.forEach(ue=>{this._stopEvent(ue)}),this}removeAllListeners(t){let c=[];if(t==null)c=this._events,this._events=[];else{const ie=getEventTag(t);this._events=this._events.filter(se=>se.tag!==ie?!0:(c.push(se),!1))}return c.forEach(ie=>{this._stopEvent(ie)}),this}}var __awaiter$b=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$3=new Logger(version$8),errorGas=["call","estimateGas"];function spelunk(n,t){if(n==null)return null;if(typeof n.message=="string"&&n.message.match("reverted")){const c=isHexString(n.data)?n.data:null;if(!t||c)return{message:n.message,data:c}}if(typeof n=="object"){for(const c in n){const ie=spelunk(n[c],t);if(ie)return ie}return null}if(typeof n=="string")try{return spelunk(JSON.parse(n),t)}catch{}return null}function checkError(n,t,c){const ie=c.transaction||c.signedTransaction;if(n==="call"){const ae=spelunk(t,!0);if(ae)return ae.data;logger$3.throwError("missing revert data in call exception; Transaction reverted without a reason string",Logger.errors.CALL_EXCEPTION,{data:"0x",transaction:ie,error:t})}if(n==="estimateGas"){let ae=spelunk(t.body,!1);ae==null&&(ae=spelunk(t,!1)),ae&&logger$3.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",Logger.errors.UNPREDICTABLE_GAS_LIMIT,{reason:ae.message,method:n,transaction:ie,error:t})}let se=t.message;throw t.code===Logger.errors.SERVER_ERROR&&t.error&&typeof t.error.message=="string"?se=t.error.message:typeof t.body=="string"?se=t.body:typeof t.responseText=="string"&&(se=t.responseText),se=(se||"").toLowerCase(),se.match(/insufficient funds|base fee exceeds gas limit|InsufficientFunds/i)&&logger$3.throwError("insufficient funds for intrinsic transaction cost",Logger.errors.INSUFFICIENT_FUNDS,{error:t,method:n,transaction:ie}),se.match(/nonce (is )?too low/i)&&logger$3.throwError("nonce has already been used",Logger.errors.NONCE_EXPIRED,{error:t,method:n,transaction:ie}),se.match(/replacement transaction underpriced|transaction gas price.*too low/i)&&logger$3.throwError("replacement fee too low",Logger.errors.REPLACEMENT_UNDERPRICED,{error:t,method:n,transaction:ie}),se.match(/only replay-protected/i)&&logger$3.throwError("legacy pre-eip-155 transactions not supported",Logger.errors.UNSUPPORTED_OPERATION,{error:t,method:n,transaction:ie}),errorGas.indexOf(n)>=0&&se.match(/gas required exceeds allowance|always failing transaction|execution reverted|revert/)&&logger$3.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",Logger.errors.UNPREDICTABLE_GAS_LIMIT,{error:t,method:n,transaction:ie}),t}function timer(n){return new Promise(function(t){setTimeout(t,n)})}function getResult(n){if(n.error){const t=new Error(n.error.message);throw t.code=n.error.code,t.data=n.error.data,t}return n.result}function getLowerCase(n){return n&&n.toLowerCase()}const _constructorGuard={};class JsonRpcSigner extends Signer{constructor(t,c,ie){if(super(),t!==_constructorGuard)throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");defineReadOnly(this,"provider",c),ie==null&&(ie=0),typeof ie=="string"?(defineReadOnly(this,"_address",this.provider.formatter.address(ie)),defineReadOnly(this,"_index",null)):typeof ie=="number"?(defineReadOnly(this,"_index",ie),defineReadOnly(this,"_address",null)):logger$3.throwArgumentError("invalid address or index","addressOrIndex",ie)}connect(t){return logger$3.throwError("cannot alter JSON-RPC Signer connection",Logger.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}connectUnchecked(){return new UncheckedJsonRpcSigner(_constructorGuard,this.provider,this._address||this._index)}getAddress(){return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then(t=>(t.length<=this._index&&logger$3.throwError("unknown account #"+this._index,Logger.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),this.provider.formatter.address(t[this._index])))}sendUncheckedTransaction(t){t=shallowCopy(t);const c=this.getAddress().then(ie=>(ie&&(ie=ie.toLowerCase()),ie));if(t.gasLimit==null){const ie=shallowCopy(t);ie.from=c,t.gasLimit=this.provider.estimateGas(ie)}return t.to!=null&&(t.to=Promise.resolve(t.to).then(ie=>__awaiter$b(this,void 0,void 0,function*(){if(ie==null)return null;const se=yield this.provider.resolveName(ie);return se==null&&logger$3.throwArgumentError("provided ENS name resolves to null","tx.to",ie),se}))),resolveProperties({tx:resolveProperties(t),sender:c}).then(({tx:ie,sender:se})=>{ie.from!=null?ie.from.toLowerCase()!==se&&logger$3.throwArgumentError("from address mismatch","transaction",t):ie.from=se;const ae=this.provider.constructor.hexlifyTransaction(ie,{from:!0});return this.provider.send("eth_sendTransaction",[ae]).then(ue=>ue,ue=>(typeof ue.message=="string"&&ue.message.match(/user denied/i)&&logger$3.throwError("user rejected transaction",Logger.errors.ACTION_REJECTED,{action:"sendTransaction",transaction:ie}),checkError("sendTransaction",ue,ae)))})}signTransaction(t){return logger$3.throwError("signing transactions is unsupported",Logger.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}sendTransaction(t){return __awaiter$b(this,void 0,void 0,function*(){const c=yield this.provider._getInternalBlockNumber(100+2*this.provider.pollingInterval),ie=yield this.sendUncheckedTransaction(t);try{return yield poll(()=>__awaiter$b(this,void 0,void 0,function*(){const se=yield this.provider.getTransaction(ie);if(se!==null)return this.provider._wrapTransaction(se,ie,c)}),{oncePoll:this.provider})}catch(se){throw se.transactionHash=ie,se}})}signMessage(t){return __awaiter$b(this,void 0,void 0,function*(){const c=typeof t=="string"?toUtf8Bytes(t):t,ie=yield this.getAddress();try{return yield this.provider.send("personal_sign",[hexlify(c),ie.toLowerCase()])}catch(se){throw typeof se.message=="string"&&se.message.match(/user denied/i)&&logger$3.throwError("user rejected signing",Logger.errors.ACTION_REJECTED,{action:"signMessage",from:ie,messageData:t}),se}})}_legacySignMessage(t){return __awaiter$b(this,void 0,void 0,function*(){const c=typeof t=="string"?toUtf8Bytes(t):t,ie=yield this.getAddress();try{return yield this.provider.send("eth_sign",[ie.toLowerCase(),hexlify(c)])}catch(se){throw typeof se.message=="string"&&se.message.match(/user denied/i)&&logger$3.throwError("user rejected signing",Logger.errors.ACTION_REJECTED,{action:"_legacySignMessage",from:ie,messageData:t}),se}})}_signTypedData(t,c,ie){return __awaiter$b(this,void 0,void 0,function*(){const se=yield TypedDataEncoder.resolveNames(t,c,ie,ue=>this.provider.resolveName(ue)),ae=yield this.getAddress();try{return yield this.provider.send("eth_signTypedData_v4",[ae.toLowerCase(),JSON.stringify(TypedDataEncoder.getPayload(se.domain,c,se.value))])}catch(ue){throw typeof ue.message=="string"&&ue.message.match(/user denied/i)&&logger$3.throwError("user rejected signing",Logger.errors.ACTION_REJECTED,{action:"_signTypedData",from:ae,messageData:{domain:se.domain,types:c,value:se.value}}),ue}})}unlock(t){return __awaiter$b(this,void 0,void 0,function*(){const c=this.provider,ie=yield this.getAddress();return c.send("personal_unlockAccount",[ie.toLowerCase(),t,null])})}}class UncheckedJsonRpcSigner extends JsonRpcSigner{sendTransaction(t){return this.sendUncheckedTransaction(t).then(c=>({hash:c,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:ie=>this.provider.waitForTransaction(c,ie)}))}}const allowedTransactionKeys={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0,type:!0,accessList:!0,maxFeePerGas:!0,maxPriorityFeePerGas:!0};class JsonRpcProvider extends BaseProvider{constructor(t,c){let ie=c;ie==null&&(ie=new Promise((se,ae)=>{setTimeout(()=>{this.detectNetwork().then(ue=>{se(ue)},ue=>{ae(ue)})},0)})),super(ie),t||(t=getStatic(this.constructor,"defaultUrl")()),typeof t=="string"?defineReadOnly(this,"connection",Object.freeze({url:t})):defineReadOnly(this,"connection",Object.freeze(shallowCopy(t))),this._nextId=42}get _cache(){return this._eventLoopCache==null&&(this._eventLoopCache={}),this._eventLoopCache}static defaultUrl(){return"http://localhost:8545"}detectNetwork(){return this._cache.detectNetwork||(this._cache.detectNetwork=this._uncachedDetectNetwork(),setTimeout(()=>{this._cache.detectNetwork=null},0)),this._cache.detectNetwork}_uncachedDetectNetwork(){return __awaiter$b(this,void 0,void 0,function*(){yield timer(0);let t=null;try{t=yield this.send("eth_chainId",[])}catch{try{t=yield this.send("net_version",[])}catch{}}if(t!=null){const c=getStatic(this.constructor,"getNetwork");try{return c(BigNumber.from(t).toNumber())}catch(ie){return logger$3.throwError("could not detect network",Logger.errors.NETWORK_ERROR,{chainId:t,event:"invalidNetwork",serverError:ie})}}return logger$3.throwError("could not detect network",Logger.errors.NETWORK_ERROR,{event:"noNetwork"})})}getSigner(t){return new JsonRpcSigner(_constructorGuard,this,t)}getUncheckedSigner(t){return this.getSigner(t).connectUnchecked()}listAccounts(){return this.send("eth_accounts",[]).then(t=>t.map(c=>this.formatter.address(c)))}send(t,c){const ie={method:t,params:c,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:deepCopy(ie),provider:this});const se=["eth_chainId","eth_blockNumber"].indexOf(t)>=0;if(se&&this._cache[t])return this._cache[t];const ae=fetchJson(this.connection,JSON.stringify(ie),getResult).then(ue=>(this.emit("debug",{action:"response",request:ie,response:ue,provider:this}),ue),ue=>{throw this.emit("debug",{action:"response",error:ue,request:ie,provider:this}),ue});return se&&(this._cache[t]=ae,setTimeout(()=>{this._cache[t]=null},0)),ae}prepareRequest(t,c){switch(t){case"getBlockNumber":return["eth_blockNumber",[]];case"getGasPrice":return["eth_gasPrice",[]];case"getBalance":return["eth_getBalance",[getLowerCase(c.address),c.blockTag]];case"getTransactionCount":return["eth_getTransactionCount",[getLowerCase(c.address),c.blockTag]];case"getCode":return["eth_getCode",[getLowerCase(c.address),c.blockTag]];case"getStorageAt":return["eth_getStorageAt",[getLowerCase(c.address),hexZeroPad(c.position,32),c.blockTag]];case"sendTransaction":return["eth_sendRawTransaction",[c.signedTransaction]];case"getBlock":return c.blockTag?["eth_getBlockByNumber",[c.blockTag,!!c.includeTransactions]]:c.blockHash?["eth_getBlockByHash",[c.blockHash,!!c.includeTransactions]]:null;case"getTransaction":return["eth_getTransactionByHash",[c.transactionHash]];case"getTransactionReceipt":return["eth_getTransactionReceipt",[c.transactionHash]];case"call":return["eth_call",[getStatic(this.constructor,"hexlifyTransaction")(c.transaction,{from:!0}),c.blockTag]];case"estimateGas":return["eth_estimateGas",[getStatic(this.constructor,"hexlifyTransaction")(c.transaction,{from:!0})]];case"getLogs":return c.filter&&c.filter.address!=null&&(c.filter.address=getLowerCase(c.filter.address)),["eth_getLogs",[c.filter]]}return null}perform(t,c){return __awaiter$b(this,void 0,void 0,function*(){if(t==="call"||t==="estimateGas"){const se=c.transaction;if(se&&se.type!=null&&BigNumber.from(se.type).isZero()&&se.maxFeePerGas==null&&se.maxPriorityFeePerGas==null){const ae=yield this.getFeeData();ae.maxFeePerGas==null&&ae.maxPriorityFeePerGas==null&&(c=shallowCopy(c),c.transaction=shallowCopy(se),delete c.transaction.type)}}const ie=this.prepareRequest(t,c);ie==null&&logger$3.throwError(t+" not implemented",Logger.errors.NOT_IMPLEMENTED,{operation:t});try{return yield this.send(ie[0],ie[1])}catch(se){return checkError(t,se,c)}})}_startEvent(t){t.tag==="pending"&&this._startPending(),super._startEvent(t)}_startPending(){if(this._pendingFilter!=null)return;const t=this,c=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=c,c.then(function(ie){function se(){t.send("eth_getFilterChanges",[ie]).then(function(ae){if(t._pendingFilter!=c)return null;let ue=Promise.resolve();return ae.forEach(function(de){t._emitted["t:"+de.toLowerCase()]="pending",ue=ue.then(function(){return t.getTransaction(de).then(function(ve){return t.emit("pending",ve),null})})}),ue.then(function(){return timer(1e3)})}).then(function(){if(t._pendingFilter!=c){t.send("eth_uninstallFilter",[ie]);return}return setTimeout(function(){se()},0),null}).catch(ae=>{})}return se(),ie}).catch(ie=>{})}_stopEvent(t){t.tag==="pending"&&this.listenerCount("pending")===0&&(this._pendingFilter=null),super._stopEvent(t)}static hexlifyTransaction(t,c){const ie=shallowCopy(allowedTransactionKeys);if(c)for(const ae in c)c[ae]&&(ie[ae]=!0);checkProperties(t,ie);const se={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(function(ae){if(t[ae]==null)return;const ue=hexValue(BigNumber.from(t[ae]));ae==="gasLimit"&&(ae="gas"),se[ae]=ue}),["from","to","data"].forEach(function(ae){t[ae]!=null&&(se[ae]=hexlify(t[ae]))}),t.accessList&&(se.accessList=accessListify(t.accessList)),se}}const logger$2=new Logger(version$8);let _nextId=1;function buildWeb3LegacyFetcher(n,t){const c="Web3LegacyFetcher";return function(ie,se){const ae={method:ie,params:se,id:_nextId++,jsonrpc:"2.0"};return new Promise((ue,de)=>{this.emit("debug",{action:"request",fetcher:c,request:deepCopy(ae),provider:this}),t(ae,(ve,ge)=>{if(ve)return this.emit("debug",{action:"response",fetcher:c,error:ve,request:ae,provider:this}),de(ve);if(this.emit("debug",{action:"response",fetcher:c,request:ae,response:ge,provider:this}),ge.error){const we=new Error(ge.error.message);return we.code=ge.error.code,we.data=ge.error.data,de(we)}ue(ge.result)})})}}function buildEip1193Fetcher(n){return function(t,c){c==null&&(c=[]);const ie={method:t,params:c};return this.emit("debug",{action:"request",fetcher:"Eip1193Fetcher",request:deepCopy(ie),provider:this}),n.request(ie).then(se=>(this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:ie,response:se,provider:this}),se),se=>{throw this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:ie,error:se,provider:this}),se})}}class Web3Provider extends JsonRpcProvider{constructor(t,c){t==null&&logger$2.throwArgumentError("missing provider","provider",t);let ie=null,se=null,ae=null;typeof t=="function"?(ie="unknown:",se=t):(ie=t.host||t.path||"",!ie&&t.isMetaMask&&(ie="metamask"),ae=t,t.request?(ie===""&&(ie="eip-1193:"),se=buildEip1193Fetcher(t)):t.sendAsync?se=buildWeb3LegacyFetcher(t,t.sendAsync.bind(t)):t.send?se=buildWeb3LegacyFetcher(t,t.send.bind(t)):logger$2.throwArgumentError("unsupported provider","provider",t),ie||(ie="unknown:")),super(ie,c),defineReadOnly(this,"jsonRpcFetchFunc",se),defineReadOnly(this,"provider",ae)}send(t,c){return this.jsonRpcFetchFunc(t,c)}}const version$7="solidity/5.8.0",regexBytes=new RegExp("^bytes([0-9]+)$"),regexNumber=new RegExp("^(u?int)([0-9]*)$"),regexArray=new RegExp("^(.*)\\[([0-9]*)\\]$"),Zeros="0000000000000000000000000000000000000000000000000000000000000000",logger$1$1=new Logger(version$7);function _pack(n,t,c){switch(n){case"address":return c?zeroPad(t,32):arrayify(t);case"string":return toUtf8Bytes(t);case"bytes":return arrayify(t);case"bool":return t=t?"0x01":"0x00",c?zeroPad(t,32):arrayify(t)}let ie=n.match(regexNumber);if(ie){let se=parseInt(ie[2]||"256");return(ie[2]&&String(se)!==ie[2]||se%8!==0||se===0||se>256)&&logger$1$1.throwArgumentError("invalid number type","type",n),c&&(se=256),t=BigNumber.from(t).toTwos(se),zeroPad(t,se/8)}if(ie=n.match(regexBytes),ie){const se=parseInt(ie[1]);return(String(se)!==ie[1]||se===0||se>32)&&logger$1$1.throwArgumentError("invalid bytes type","type",n),arrayify(t).byteLength!==se&&logger$1$1.throwArgumentError(`invalid value for ${n}`,"value",t),c?arrayify((t+Zeros).substring(0,66)):t}if(ie=n.match(regexArray),ie&&Array.isArray(t)){const se=ie[1];parseInt(ie[2]||String(t.length))!=t.length&&logger$1$1.throwArgumentError(`invalid array length for ${n}`,"value",t);const ae=[];return t.forEach(function(ue){ae.push(_pack(se,ue,!0))}),concat$1(ae)}return logger$1$1.throwArgumentError("invalid type","type",n)}function pack(n,t){n.length!=t.length&&logger$1$1.throwArgumentError("wrong number of values; expected ${ types.length }","values",t);const c=[];return n.forEach(function(ie,se){c.push(_pack(ie,t[se]))}),hexlify(concat$1(c))}function keccak256(n,t){return keccak256$1(pack(n,t))}function sha256$6(n,t){return sha256$7(pack(n,t))}const lib_esm$1=Object.freeze(Object.defineProperty({__proto__:null,keccak256,pack,sha256:sha256$6},Symbol.toStringTag,{value:"Module"})),version$6="units/5.8.0",logger$y=new Logger(version$6),names$2=["wei","kwei","mwei","gwei","szabo","finney","ether"];function commify(n){const t=String(n).split(".");(t.length>2||!t[0].match(/^-?[0-9]*$/)||t[1]&&!t[1].match(/^[0-9]*$/)||n==="."||n==="-.")&&logger$y.throwArgumentError("invalid value","value",n);let c=t[0],ie="";for(c.substring(0,1)==="-"&&(ie="-",c=c.substring(1));c.substring(0,1)==="0";)c=c.substring(1);c===""&&(c="0");let se="";for(t.length===2&&(se="."+(t[1]||"0"));se.length>2&&se[se.length-1]==="0";)se=se.substring(0,se.length-1);const ae=[];for(;c.length;)if(c.length<=3){ae.unshift(c);break}else{const ue=c.length-3;ae.unshift(c.substring(ue)),c=c.substring(0,ue)}return ie+ae.join(",")+se}function formatUnits(n,t){if(typeof t=="string"){const c=names$2.indexOf(t);c!==-1&&(t=3*c)}return formatFixed(n,t??18)}function parseUnits(n,t){if(typeof n!="string"&&logger$y.throwArgumentError("value must be a string","value",n),typeof t=="string"){const c=names$2.indexOf(t);c!==-1&&(t=3*c)}return parseFixed(n,t??18)}function formatEther(n){return formatUnits(n,18)}function parseEther(n){return parseUnits(n,18)}const lib_esm=Object.freeze(Object.defineProperty({__proto__:null,commify,formatEther,formatUnits,parseEther,parseUnits},Symbol.toStringTag,{value:"Module"}));var NFTType=(n=>(n[n.ERC1155=0]="ERC1155",n[n.ERC721=1]="ERC721",n))(NFTType||{}),ProductType=(n=>(n[n.DIGITAL=0]="DIGITAL",n[n.POD=1]="POD",n[n.PHYSICAL=2]="PHYSICAL",n))(ProductType||{});class HTTPError extends Error{constructor(t,c,ie){const se=t.status||t.status===0?t.status:"",ae=t.statusText??"",ue=`${se} ${ae}`.trim(),de=ue?`status code ${ue}`:"an unknown error";super(`Request failed with ${de}: ${c.method} ${c.url}`),Xn(this,"response"),Xn(this,"request"),Xn(this,"options"),this.name="HTTPError",this.response=t,this.request=c,this.options=ie}}class TimeoutError extends Error{constructor(t){super(`Request timed out: ${t.method} ${t.url}`),Xn(this,"request"),this.name="TimeoutError",this.request=t}}const supportsRequestStreams=(()=>{let n=!1,t=!1;const c=typeof globalThis.ReadableStream=="function",ie=typeof globalThis.Request=="function";if(c&&ie)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return n=!0,"half"}}).headers.has("Content-Type")}catch(se){if(se instanceof Error&&se.message==="unsupported BodyInit type")return!1;throw se}return n&&!t})(),supportsAbortController=typeof globalThis.AbortController=="function",supportsAbortSignal=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",supportsResponseStreams=typeof globalThis.ReadableStream=="function",supportsFormData=typeof globalThis.FormData=="function",requestMethods=["get","post","put","patch","head","delete"],responseTypes={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},maxSafeTimeout=2147483647,usualFormBoundarySize=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,stop$1=Symbol("stop"),kyOptionKeys={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},requestOptionsRegistry={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0},getBodySize=n=>{if(!n)return 0;if(n instanceof FormData){let t=0;for(const[c,ie]of n)t+=usualFormBoundarySize,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${c}"`).length,t+=typeof ie=="string"?new TextEncoder().encode(ie).length:ie.size;return t}if(n instanceof Blob)return n.size;if(n instanceof ArrayBuffer)return n.byteLength;if(typeof n=="string")return new TextEncoder().encode(n).length;if(n instanceof URLSearchParams)return new TextEncoder().encode(n.toString()).length;if("byteLength"in n)return n.byteLength;if(typeof n=="object"&&n!==null)try{const t=JSON.stringify(n);return new TextEncoder().encode(t).length}catch{return 0}return 0},withProgress=(n,t,c)=>{let ie,se=0;return n.pipeThrough(new TransformStream({transform(ae,ue){if(ue.enqueue(ae),ie){se+=ie.byteLength;let de=t===0?0:se/t;de>=1&&(de=1-Number.EPSILON),c?.({percent:de,totalBytes:Math.max(t,se),transferredBytes:se},ie)}ie=ae},flush(){ie&&(se+=ie.byteLength,c?.({percent:1,totalBytes:Math.max(t,se),transferredBytes:se},ie))}}))},streamResponse=(n,t)=>{if(!n.body)return n;if(n.status===204)return new Response(null,{status:n.status,statusText:n.statusText,headers:n.headers});const c=Number(n.headers.get("content-length"))||0;return new Response(withProgress(n.body,c,t),{status:n.status,statusText:n.statusText,headers:n.headers})},streamRequest=(n,t,c)=>{if(!n.body)return n;const ie=getBodySize(c??n.body);return new Request(n,{duplex:"half",body:withProgress(n.body,ie,t)})},isObject$2$1=n=>n!==null&&typeof n=="object",validateAndMerge=(...n)=>{for(const t of n)if((!isObject$2$1(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return deepMerge({},...n)},mergeHeaders=(n={},t={})=>{const c=new globalThis.Headers(n),ie=t instanceof globalThis.Headers,se=new globalThis.Headers(t);for(const[ae,ue]of se.entries())ie&&ue==="undefined"||ue===void 0?c.delete(ae):c.set(ae,ue);return c};function newHookValue(n,t,c){return Object.hasOwn(t,c)&&t[c]===void 0?[]:deepMerge(n[c]??[],t[c]??[])}const mergeHooks=(n={},t={})=>({beforeRequest:newHookValue(n,t,"beforeRequest"),beforeRetry:newHookValue(n,t,"beforeRetry"),afterResponse:newHookValue(n,t,"afterResponse"),beforeError:newHookValue(n,t,"beforeError")}),deepMerge=(...n)=>{let t={},c={},ie={};for(const se of n)if(Array.isArray(se))Array.isArray(t)||(t=[]),t=[...t,...se];else if(isObject$2$1(se)){for(let[ae,ue]of Object.entries(se))isObject$2$1(ue)&&ae in t&&(ue=deepMerge(t[ae],ue)),t={...t,[ae]:ue};isObject$2$1(se.hooks)&&(ie=mergeHooks(ie,se.hooks),t.hooks=ie),isObject$2$1(se.headers)&&(c=mergeHeaders(c,se.headers),t.headers=c)}return t},normalizeRequestMethod=n=>requestMethods.includes(n)?n.toUpperCase():n,retryMethods=["get","put","head","delete","options","trace"],retryStatusCodes=[408,413,429,500,502,503,504],retryAfterStatusCodes=[413,429,503],defaultRetryOptions={limit:2,methods:retryMethods,statusCodes:retryStatusCodes,afterStatusCodes:retryAfterStatusCodes,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:n=>.3*2**(n-1)*1e3},normalizeRetryOptions=(n={})=>{if(typeof n=="number")return{...defaultRetryOptions,limit:n};if(n.methods&&!Array.isArray(n.methods))throw new Error("retry.methods must be an array");if(n.statusCodes&&!Array.isArray(n.statusCodes))throw new Error("retry.statusCodes must be an array");return{...defaultRetryOptions,...n}};async function timeout(n,t,c,ie){return new Promise((se,ae)=>{const ue=setTimeout(()=>{c&&c.abort(),ae(new TimeoutError(n))},ie.timeout);ie.fetch(n,t).then(se).catch(ae).then(()=>{clearTimeout(ue)})})}async function delay$1(n,{signal:t}){return new Promise((c,ie)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",se,{once:!0}));function se(){clearTimeout(ae),ie(t.reason)}const ae=setTimeout(()=>{t?.removeEventListener("abort",se),c()},n)})}const findUnknownOptions=(n,t)=>{const c={};for(const ie in t)!(ie in requestOptionsRegistry)&&!(ie in kyOptionKeys)&&!(ie in n)&&(c[ie]=t[ie]);return c},hasSearchParameters=n=>n===void 0?!1:Array.isArray(n)?n.length>0:n instanceof URLSearchParams?n.size>0:typeof n=="object"?Object.keys(n).length>0:typeof n=="string"?n.trim().length>0:!!n;var ei,oi;const Yn=class oo{constructor(t,c={}){Xn(this,"request"),Xn(this,"abortController"),Xn(this,"_retryCount",0),Xn(this,"_input"),Xn(this,"_options"),Xn(this,"_originalRequest");var ie,se,ae;if(this._input=t,this._options={...c,headers:mergeHeaders(this._input.headers,c.headers),hooks:mergeHooks({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},c.hooks),method:normalizeRequestMethod(c.method??this._input.method??"GET"),prefixUrl:String(c.prefixUrl||""),retry:normalizeRetryOptions(c.retry),throwHttpErrors:c.throwHttpErrors!==!1,timeout:c.timeout??1e4,fetch:c.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(supportsAbortController&&supportsAbortSignal){const ue=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=ue?AbortSignal.any([ue,this.abortController.signal]):this.abortController.signal}if(supportsRequestStreams&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=((se=(ie=this._options).stringifyJson)==null?void 0:se.call(ie,this._options.json))??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),hasSearchParameters(this._options.searchParams)){const ue="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(ai(ae=oo,ei,oi).call(ae,this._options.searchParams)).toString()),de=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,ue);(supportsFormData&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(de,{...this.request}),this._options)}if(this._options.onUploadProgress){if(typeof this._options.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!supportsRequestStreams)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=streamRequest(this.request,this._options.onUploadProgress,this._options.body))}}static create(t,c){var ie,se;const ae=new oo(t,c),ue=async()=>{if(typeof ae._options.timeout=="number"&&ae._options.timeout>maxSafeTimeout)throw new RangeError(`The \`timeout\` option cannot be greater than ${maxSafeTimeout}`);await Promise.resolve();let ve=await ae._fetch();for(const ge of ae._options.hooks.afterResponse){const we=await ge(ae.request,ae._options,ae._decorateResponse(ve.clone()));we instanceof globalThis.Response&&(ve=we)}if(ae._decorateResponse(ve),!ve.ok&&ae._options.throwHttpErrors){let ge=new HTTPError(ve,ae.request,ae._options);for(const we of ae._options.hooks.beforeError)ge=await we(ge);throw ge}if(ae._options.onDownloadProgress){if(typeof ae._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!supportsResponseStreams)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return streamResponse(ve.clone(),ae._options.onDownloadProgress)}return ve},de=(ae._options.retry.methods.includes(ae.request.method.toLowerCase())?ae._retry(ue):ue()).finally(async()=>{var ve,ge;const we=ae._originalRequest,Te=[];we&&!we.bodyUsed&&Te.push((ve=we.body)==null?void 0:ve.cancel()),ae.request.bodyUsed||Te.push((ge=ae.request.body)==null?void 0:ge.cancel()),await Promise.all(Te)});for(const[ve,ge]of Object.entries(responseTypes))ve==="bytes"&&typeof((se=(ie=globalThis.Response)==null?void 0:ie.prototype)==null?void 0:se.bytes)!="function"||(de[ve]=async()=>{ae.request.headers.set("accept",ae.request.headers.get("accept")||ge);const we=await de;if(ve==="json"){if(we.status===204)return"";const Te=await we.text();return Te===""?"":c.parseJson?c.parseJson(Te):JSON.parse(Te)}return we[ve]()});return de}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof TimeoutError)throw t;if(t instanceof HTTPError){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;const ie=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(ie&&this._options.retry.afterStatusCodes.includes(t.response.status)){let se=Number(ie)*1e3;Number.isNaN(se)?se=Date.parse(ie)-Date.now():se>=Date.parse("2024-01-01")&&(se-=Date.now());const ae=this._options.retry.maxRetryAfter??se;return se<ae?se:ae}if(t.response.status===413)throw t}const c=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,c)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(c){const ie=Math.min(this._calculateRetryDelay(c),maxSafeTimeout);if(this._retryCount<1)throw c;await delay$1(ie,{signal:this._options.signal});for(const se of this._options.hooks.beforeRetry)if(await se({request:this.request,options:this._options,error:c,retryCount:this._retryCount})===stop$1)return;return this._retry(t)}}async _fetch(){for(const c of this._options.hooks.beforeRequest){const ie=await c(this.request,this._options);if(ie instanceof Request){this.request=ie;break}if(ie instanceof Response)return ie}const t=findUnknownOptions(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):timeout(this._originalRequest,t,this.abortController,this._options)}};ei=new WeakSet,oi=function(n){return n&&typeof n=="object"&&!Array.isArray(n)&&!(n instanceof URLSearchParams)?Object.fromEntries(Object.entries(n).filter(([,t])=>t!==void 0)):n},ii(Yn,ei);let Ky=Yn;const createInstance$1=n=>{const t=(c,ie)=>Ky.create(c,validateAndMerge(n,ie));for(const c of requestMethods)t[c]=(ie,se)=>Ky.create(ie,validateAndMerge(n,se,{method:c}));return t.create=c=>createInstance$1(validateAndMerge(c)),t.extend=c=>(typeof c=="function"&&(c=c(n??{})),createInstance$1(validateAndMerge(n,c))),t.stop=stop$1,t},ky=createInstance$1();async function uploadMetadata(n,t,c){return(await(await c.post("uploader/cdn-upload-json",{json:{data:n,key:`record-metadata/${t}.json`}})).json()).url}async function startRecord(n,t,c,ie,se,ae){return(await(await ae.post("web3/record/transactions",{json:{uris:se,network:ie,data:{productId:n,skuIds:t},productId:n,skuIds:t,metadata:{},shopId:c,txType:"RECORD"}})).json()).data.id}async function getShopInfo(n,t,c){const ie=(await(await c.get(`shops/v2/public/${t}`)).json()).data.deployedContracts.filter(se=>se.type===n);return ie.length===0?{nftContractAddress:"",shopContractAddress:""}:{nftContractAddress:ie[0].deployedNFTAddress,shopContractAddress:ie[0].deployedShopAddress}}async function deleteRecordTransaction(n,t){await t.delete(`web3/record/transactions/${n}`)}async function web3Callback(n,t,c,ie){const se={"X-API-KEY":"ho8homr9e8p4fwii7tjiz41xs4hlbl2h4i"};return(await(await ky.create({headers:se,prefixUrl:c==="TESTNET"?"https://web3dev.droplinked.com/":"https://web3.droplinked.com/"}).post("transactions",{json:{transaction_id:n,callback_url:ie,chain:t,network:c},headers:se})).json()).data}async function getProductData(n,t){return(await(await t.get(`product-v2/public/${n}`)).json()).data}async function transformProductData(n,t){const c=await getProductData(n,t);if(!c||c.skus.length===0)throw new Error("Product not found or no SKUs available");return{productData:{acceptsManageWallet:!0,commission:c.affiliate.commissionPercent||0,description:c.description,productTitle:c.title,royalty:c.skus[0].royalty||0,type:ProductType[c.type.toUpperCase()]||ProductType.DIGITAL},skuData:c.skus.map(ie=>{var se;return{amount:ie.inventory.quantity,imageUrl:((se=c.images[c.defaultImageIndex])==null?void 0:se.original)||"",skuID:ie.id,skuProperties:ie}})}}async function updateUris(n,t,c){return(await(await c.put(`web3/record/transactions/${n}/uris`,{json:{uris:t}})).json()).data}async function updateHash(n,t,c,ie){return(await(await ie.put(`web3/${n}/transactions/${t}/hash`,{json:{transactionHash:c}})).json()).data}async function getProductDataForRecord(n,t){if(!n)throw new InvalidParametersException(Chains.BASE,"Product ID is required");let c,ie=[];try{const{productData:se,skuData:ae}=await transformProductData(n,t);c=se,ie=ae}catch(se){throw new Error(`Failed to fetch product data: ${se}`)}if(!c||ie.length===0)throw new Error("Product not found or no SKUs available");return{productData:c,skuData:ie}}async function getNonce(n,t){return await(await t.get(`web3/auth/nonce?wallet=${n}`)).json()}async function getAddress(n,t,c){const ie=se=>se.charAt(0).toUpperCase()+se.slice(1).toLowerCase();try{const se=t===Network.TESTNET?"apiv3dev":"apiv3",ae=ie(n),ue=ie(Network[t]),de=`https://${se}.droplinked.com/storage/${ae}${ue}ContractAddress${c}`;return(await await ky.get(de).json()).value}catch(se){throw console.error(`Failed to fetch ${c.toLowerCase()} address:`,se),new Error(`Unable to get ${c.toLowerCase()} address`)}}async function getDeployerAddress(n,t){return getAddress(n,t,"Deployer")}async function getProxyAddress(n,t){return getAddress(n,t,"Proxy")}async function startPayment(n,t,c,ie,se){return(await(await se.post("web3/payment/transactions",{json:{network:c,token:t,shopId:ie,orderId:n}})).json()).data.id}async function getCartData(n,t,c,ie){const se=await(await ie.get(`web3/payment/distribution/${n}/${t}/${c}`)).json();return{paymentData:se.data,orderID:se.orderID}}async function getPurchaseSignature(n,t,c){const ie=await(await c.get(`nfts/by-order?orderId=${n}&skuId=${t}`)).json();return{signature:ie.purchaseSignature,shopContractAddress:ie.shopContractAddress,networkName:ie.networkName}}async function getShopByteCode(){try{return String((await await ky.get("https://apiv3dev.droplinked.com/storage/shopByteCodeType0").json()).value)}catch(n){throw console.error(`Failed to get shop bytecode: ${n}`),new Error("Unable to get shop bytecode")}}async function getShopDeployInfo(n,t){const c=(await(await t.get(`shops/v2/public/${n}`)).json()).data;return{name:c.name,description:c.description,logo:c.logo,url:c.url,deployedContracts:c.deployedContracts}}const shopABI=[{inputs:[{internalType:"string",name:"_shopName",type:"string"},{internalType:"string",name:"_shopAddress",type:"string"},{internalType:"address",name:"_shopOwner",type:"address"},{internalType:"string",name:"_shopLogo",type:"string"},{internalType:"string",name:"_shopDescription",type:"string"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"AccessDenied",type:"error"},{inputs:[],name:"AffiliatePOD",type:"error"},{inputs:[],name:"AlreadyClaimed",type:"error"},{inputs:[{internalType:"address",name:"requester",type:"address"},{internalType:"uint256",name:"productId",type:"uint256"}],name:"AlreadyRequested",type:"error"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"producer",type:"address"}],name:"NotEnoughTokens",type:"error"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"OwnableInvalidOwner",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"OwnableUnauthorizedAccount",type:"error"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"ProductDoesntExist",type:"error"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"ProductExists",type:"error"},{inputs:[],name:"ReentrancyGuardReentrantCall",type:"error"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"RequestAlreadyConfirmed",type:"error"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"RequestDoesntExist",type:"error"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"RequestNotConfirmed",type:"error"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"}],name:"ShopDoesNotOwnToken",type:"error"},{inputs:[],name:"oldPrice",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"requestId",type:"uint256"},{indexed:!0,internalType:"address",name:"approver",type:"address"}],name:"AffiliateRequestApproved",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"requestId",type:"uint256"},{indexed:!0,internalType:"address",name:"disapprover",type:"address"}],name:"AffiliateRequestDisapproved",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"requestId",type:"uint256"},{indexed:!0,internalType:"uint256",name:"productId",type:"uint256"},{indexed:!1,internalType:"address",name:"requester",type:"address"}],name:"AffiliateRequested",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"count",type:"uint256"}],name:"BatchProductRegistered",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"productId",type:"uint256"},{indexed:!0,internalType:"address",name:"claimer",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"ProductClaimed",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"productId",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!1,internalType:"string",name:"uri",type:"string"}],name:"ProductRegistered",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"productId",type:"uint256"},{indexed:!0,internalType:"address",name:"owner",type:"address"}],name:"ProductUnregistered",type:"event"},{inputs:[],name:"affiliateRequestCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"affiliateRequests",outputs:[{internalType:"address",name:"publisher",type:"address"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"bool",name:"isConfirmed",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"approveRequest",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"manager",type:"address"},{internalType:"bytes",name:"signature",type:"bytes"},{components:[{components:[{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"uint256",name:"nullifier",type:"uint256"}],internalType:"struct PurchasedItem[]",name:"cart",type:"tuple[]"},{internalType:"address",name:"shop",type:"address"}],internalType:"struct PurchaseSignature",name:"purchaseSignature",type:"tuple"}],name:"claimPurchase",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"disapproveRequest",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"droplinkedManagerWallet",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"getAffiliate",outputs:[{components:[{internalType:"address",name:"publisher",type:"address"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"bool",name:"isConfirmed",type:"bool"}],internalType:"struct AffiliateRequest",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAffiliateRequestCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"messageHash",type:"bytes32"}],name:"getEthSignedMessageHash",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"pure",type:"function"},{inputs:[{components:[{components:[{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"uint256",name:"nullifier",type:"uint256"}],internalType:"struct PurchasedItem[]",name:"cart",type:"tuple[]"},{internalType:"address",name:"shop",type:"address"}],internalType:"struct PurchaseSignature",name:"data",type:"tuple"}],name:"getMessageHash",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"getProduct",outputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],internalType:"struct Product",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[],name:"getProductCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],internalType:"struct Product",name:"product",type:"tuple"}],name:"getProductId",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"nftAddress",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getProductIdV2",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint256",name:"affiliateId",type:"uint256"}],name:"getProductViaAffiliateId",outputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],internalType:"struct Product",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopAddress",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopDescription",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopLogo",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopName",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopOwner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"address",name:"requester",type:"address"}],name:"isRequestSubmited",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"managers",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"address",name:"nftAddress",type:"address"},{internalType:"string",name:"uri",type:"string"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bool",name:"accepted",type:"bool"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"},{internalType:"uint256",name:"royalty",type:"uint256"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"}],internalType:"struct RecordData",name:"mintData",type:"tuple"}],name:"mintAndRegister",outputs:[{internalType:"uint256",name:"productId",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"nftAddress",type:"address"},{internalType:"string",name:"uri",type:"string"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bool",name:"accepted",type:"bool"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"},{internalType:"uint256",name:"royalty",type:"uint256"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"}],internalType:"struct RecordData[]",name:"recordData",type:"tuple[]"}],name:"mintAndRegisterBatch",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"nullifiers",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC1155BatchReceived",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC1155Received",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC721Received",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"productCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"products",outputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"ethSignedMessageHash",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"recoverSigner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"pure",type:"function"},{inputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],internalType:"struct Product",name:"p",type:"tuple"}],name:"registerProduct",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"requestAffiliate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"manager",type:"address"}],name:"revokeManager",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"manager",type:"address"}],name:"setManager",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"shopInfo",outputs:[{internalType:"string",name:"shopName",type:"string"},{internalType:"string",name:"shopAddress",type:"string"},{internalType:"string",name:"shopLogo",type:"string"},{internalType:"string",name:"shopDescription",type:"string"},{internalType:"address",name:"shopOwner",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"sig",type:"bytes"}],name:"splitSignature",outputs:[{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"},{internalType:"uint8",name:"v",type:"uint8"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"newManager",type:"address"}],name:"transferManagerShip",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"unregisterProduct",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newManagerWallet",type:"address"}],name:"updateDroplinkedManagerWallet",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"signer",type:"address"},{internalType:"bytes",name:"signature",type:"bytes"},{components:[{components:[{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"uint256",name:"nullifier",type:"uint256"}],internalType:"struct PurchasedItem[]",name:"cart",type:"tuple[]"},{internalType:"address",name:"shop",type:"address"}],internalType:"struct PurchaseSignature",name:"data",type:"tuple"}],name:"verifyPurchase",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"pure",type:"function"}];function getTransactionLink({blockchain:n,transactionHash:t,isTestnet:c=!1}){const ie=t.trim();switch(n.toUpperCase()){case"CASPER":return`https://${c?"testnet.":""}cspr.live/deploy/${ie}`;case"STACKS":return`https://explorer.hiro.so/txid/${ie}?chain=${c?"testnet":"mainnet"}`;case"POLYGON":return`https://${c?"amoy.":""}polygonscan.com/tx/${ie}`;case"XRPLSIDECHAIN":return`https://evm-sidechain.xrpl.org/tx/${ie}`;case"BINANCE":return`https://${c?"testnet.":""}bscscan.com/tx/${ie}`;case"NEAR":return`https://explorer.${c?"testnet":"mainnet"}.aurora.dev/tx/${ie}`;case"BASE":return`https://base${c?"-sepolia":""}.blockscout.com/tx/${ie}`;case"LINEA":return`https://${c?"sepolia.":""}lineascan.build/tx/${ie}`;case"ETH":return`https://${c?"sepolia.":""}etherscan.io/tx/${ie}`;case"SOLANA":return`https://explorer.solana.com/tx/${ie}?cluster=${c?"devnet":"mainnet"}`;case"REDBELLY":return c?`https://redbelly.testnet.routescan.io/tx/${ie}`:`https://redbelly.routescan.io/tx/${ie}`;case"SKALE":return`https://${c?"giant-half-dual-testnet.explorer.testnet.skalenodes.com":"honorable-steel-rasalhague.explorer.mainnet.skalenodes.com"}/tx/${ie}`;case"BITLAYER":return c?`https://testnet.btrscan.com/tx/${ie}`:`https://www.btrscan.com/tx/${ie}`;default:return""}}async function ensureWalletOnChainFromConfig(n,t,c){const ie=t[c];if(!ie)throw new Error(`Network config not found for ${t.name} (${c})`);const se=n.provider;if(!(se!=null&&se.request))throw new Error("Provider does not support network switching");const ae=await n.getNetwork(),ue=Number(ie.chainId);if(ae.chainId!==ue){try{await se.request({method:"wallet_switchEthereumChain",params:[{chainId:ie.chainId}]})}catch(de){if(de.code===4902)await se.request({method:"wallet_addEthereumChain",params:[{chainId:ie.chainId,chainName:ie.chainName,rpcUrls:ie.rpcUrls,nativeCurrency:ie.nativeCurrency}]});else throw de}if((await n.getNetwork()).chainId!==ue)throw new Error(`Failed to switch to ${t.name} (${c})`)}}function getBaseUrl(n){return n===Network.MAINNET?"https://apiv3.droplinked.com":n===Network.TESTNET?"https://apiv3dev.droplinked.com":"http://127.0.0.1:3000"}async function getGasPrice(n){return(await n.getGasPrice()).toBigInt()}const deployerABI=[{inputs:[],name:"InvalidInitialization",type:"error"},{inputs:[],name:"NotInitializing",type:"error"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"OwnableInvalidOwner",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"OwnableUnauthorizedAccount",type:"error"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"newFee",type:"uint256"}],name:"DroplinkedFeeUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"newHeartBeat",type:"uint256"}],name:"HeartBeatUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint64",name:"version",type:"uint64"}],name:"Initialized",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"shop",type:"address"},{indexed:!1,internalType:"address",name:"nftContract",type:"address"}],name:"ShopDeployed",type:"event"},{inputs:[{internalType:"bytes",name:"bytecode",type:"bytes"},{internalType:"bytes32",name:"salt",type:"bytes32"}],name:"deployShop",outputs:[{internalType:"address",name:"shop",type:"address"},{internalType:"address",name:"nftContract",type:"address"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"droplinkedFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"droplinkedWallet",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getDroplinkedFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getHeartBeat",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"heartBeat",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"_heartBeat",type:"uint256"},{internalType:"address",name:"_droplinkedWallet",type:"address"},{internalType:"uint256",name:"_droplinkedFee",type:"uint256"}],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"nftContracts",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"shopOwner",type:"address"},{internalType:"uint256",name:"",type:"uint256"}],name:"nftOwners",outputs:[{internalType:"address",name:"nftContracts",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"newFee",type:"uint256"}],name:"setDroplinkedFee",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"newHeartBeat",type:"uint256"}],name:"setHeartBeat",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"shopAddresses",outputs:[{internalType:"contract IDropShop",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"shopCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"shopOwner",type:"address"},{internalType:"uint256",name:"",type:"uint256"}],name:"shopOwners",outputs:[{internalType:"address",name:"shops",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"}],sixify=n=>n.toString().padStart(6,"0");async function getConstructorArgs(n,t,c){return[n.shopName||"",n.shopAddress||"",c,n.shopLogo||"",n.shopDescription||"",t]}async function deployEVMShop(n,t,c){console.log({...n,...t,...c});const{modalInterface:ie}=t,{chain:se,network:ae,provider:ue}=n,de=ue.getSigner(),ve=await getDeployerAddress(se,ae),ge=new Contract(ve,deployerABI,de),we=await getShopByteCode(),Te=await de.getAddress(),Ne="0x"+Te.split("0x")[1]+"000000000000000000"+sixify(Math.floor(Math.random()*1e6)+1),qe=await getConstructorArgs(c,ve,Te),ze=defaultAbiCoder.encode(["string","string","address","string","string","address"],qe);try{let He;const Ge=we+ze.split("0x")[1];console.log({fullBytecode:Ge}),n.chain!==Chains.SKALE?(await ge.callStatic.deployShop(Ge,Ne),He=await ge.deployShop(Ge,Ne,{})):He=await ge.deployShop(Ge,Ne);const Ze=(await He.wait()).logs.map(Mt=>{try{return ge.interface.parseLog(Mt)}catch{return null}}).filter(Mt=>Mt!=null).find(Mt=>Mt.name==="ShopDeployed"),Ye=Ze.args.shop,Ft=Ze.args.nftContract;return{transactionHash:He.hash,deployedShopAddress:Ye,deployedNFTAddress:Ft}}catch(He){if(ie.error("Error during shop deployment",`${He.message||He}`),He.code.toString()==="ACTION_REJECTED")throw new UserDeniedException("Deployer");try{const Ge=ge.interface.parseError(He.data);throw ie.error("Contract error",`${Ge}`),Ge}catch(Ge){throw ie.error("Unhandled error during shop deployment.",`${Ge||He}`),new Error(Ge||"Unknown error occurred.")}}}function getRecordData(n,t,c){const{acceptsManageWallet:ie,amount:se,royalty:ae,type:ue}=n;return{nftAddress:c,uri:t,amount:se,accepted:ie,affiliatePercentage:ae,royalty:ae,nftType:NFTType.ERC1155,productType:ue}}async function prepareRecordData(n,t,c,ie){const{nftContract:se}=ie;if(!se)throw new InvalidParametersException(n.chain,"nftContract");const{description:ae}=c,{skuID:ue}=t,de={...t,...c},ve={...de.skuProperties},ge={name:de.productTitle,description:ae,image:de.imageUrl,properties:ve},we=await uploadMetadata(ge,ue,ie.axiosInstance);return getRecordData(de,we,se)}async function doRecordProduct(n,t,c,ie){const{modalInterface:se,nftContract:ae,shopContractAddress:ue}=t;if(!ae||!ue)throw se.error("Invalid Parameters","nftContract||shopContractAddress"),new InvalidParametersException(n.chain,"nftContract||shopContractAddress");se.changeStep("Connecting to wallet");const de=n.provider.getSigner(),ve=new Contract(ue,shopABI,de);try{se.changeStep("Preparing products for recording");const ge=await Promise.all(ie.map(Te=>prepareRecordData(n,Te,c,t)));let we;return n.chain!==Chains.SKALE?(await ve.callStatic.mintAndRegisterBatch(ge),se.changeStep("Recording products on blockchain"),we=await ve.mintAndRegisterBatch(ge)):(se.changeStep("Recording products on blockchain"),we=await ve.mintAndRegisterBatch(ge)),se.changeStep("Waiting for transaction confirmation"),await we.wait(),{transactionHash:we.hash,metadataUrls:ge.map(Te=>Te.uri)}}catch(ge){if(ge.code&&ge.code.toString()==="ACTION_REJECTED")throw t.modalInterface.error("Transaction Rejected","ACTION_REJECTED"),new Error("Transaction Rejected");try{if(ge.data&&ge.data!=="0x"){const we=ve.interface.parseError(ge.data);throw we.name==="OwnableUnauthorizedAccount"?(t.modalInterface.error("Unauthorized","OwnableUnauthorizedAccount"),new Unauthorized(n.chain,"record",await de.getAddress(),ue)):(t.modalInterface.error(we.name,we.args.join(", ")),t.modalInterface.error(ge,we.name),ge)}else throw se.error("Transaction reverted without reason",`${ge}`),ge}catch(we){throw se.error("Unexpected error",`${we}`),we}}}async function recordProduct({productId:n,chain:t,axiosInstance:c,shopId:ie,network:se,stepizer:ae,provider:ue}){let de="",ve="";if(ae.changeStep("Starting record process"),ie!==""){const qe=await getShopInfo(t,ie,c);de=qe.nftContractAddress,ve=qe.shopContractAddress}const ge=new Web3Provider(ue,"any");if(!de||!ve){ae.changeStep("Deploying shop contract");const qe={chain:t,network:se,provider:ge},ze={axiosInstance:c,modalInterface:ae,nftContract:"",shopContractAddress:""},{description:He,logo:Ge,name:Ze,url:Ye,deployedContracts:Ft}=await getShopDeployInfo(ie,c),{deployedNFTAddress:Mt,deployedShopAddress:Zt,transactionHash:cn}=await deployEVMShop(qe,ze,{shopName:Ze,shopAddress:Ye,shopLogo:Ge,shopDescription:He}),hn=[...Ft||[],{type:t,deployedShopAddress:Zt,transactionId:cn,deployedNFTAddress:Mt,isCircle:!1,platform:"DROPLINKED",status:"SUCCESS"}];console.log({newDeployedContracts:hn}),de=Mt,ve=Zt,ae.changeStep("Shop deployed successfully")}await ensureWalletOnChainFromConfig(ge,getChainByName(t),se);const{productData:we,skuData:Te}=await getProductDataForRecord(n,c);if(!ie)throw new InvalidParametersException(t,"shopId");const Ne=await startRecord(n,Te.map(qe=>qe.skuID),ie,t,[],c);try{const qe=await doRecordProduct({chain:t,network:se,provider:ge},{axiosInstance:c,modalInterface:ae,nftContract:de,shopContractAddress:ve},we,Te);await updateUris(Ne,qe.metadataUrls,c),await updateHash("record",Ne,qe.transactionHash,c);const ze=`${getBaseUrl(se)}/web3/record/callback/events/${Ne}`;if(!await web3Callback(qe.transactionHash,t,Network[se],ze))throw new Web3CallbackFailedException("Record");return{...qe,transactionId:Ne,transactionHashUrl:getTransactionLink({blockchain:t,transactionHash:qe.transactionHash,isTestnet:se!==Network.MAINNET})}}catch(qe){throw console.error("Error during recording process:",qe),await deleteRecordTransaction(Ne,c),qe}}var utils$e={};const require$$0$3=getAugmentedNamespace(lib_esm$b),require$$1$2=getAugmentedNamespace(lib_esm$f),require$$2$3=getAugmentedNamespace(lib_esm$d),require$$3=getAugmentedNamespace(lib_esm$8),require$$4$3=getAugmentedNamespace(lib_esm$j),require$$5=getAugmentedNamespace(lib_esm$c),require$$6$2=getAugmentedNamespace(lib_esm$6),require$$7=getAugmentedNamespace(lib_esm$4),require$$8=getAugmentedNamespace(lib_esm$h),require$$9=getAugmentedNamespace(lib_esm$k),require$$10=getAugmentedNamespace(lib_esm$7),require$$11$1=getAugmentedNamespace(lib_esm$1),require$$12=getAugmentedNamespace(lib_esm$5),require$$13=getAugmentedNamespace(lib_esm$i),require$$14=getAugmentedNamespace(lib_esm$g),require$$15=getAugmentedNamespace(lib_esm$a),require$$16=getAugmentedNamespace(lib_esm$e),require$$17$1=getAugmentedNamespace(lib_esm$9),require$$18=getAugmentedNamespace(lib_esm),require$$19=getAugmentedNamespace(lib_esm$3),require$$20=getAugmentedNamespace(lib_esm$2);(function(n){var t=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(le,pe,be,xe){xe===void 0&&(xe=be),Object.defineProperty(le,xe,{enumerable:!0,get:function(){return pe[be]}})}:function(le,pe,be,xe){xe===void 0&&(xe=be),le[xe]=pe[be]}),c=commonjsGlobal&&commonjsGlobal.__setModuleDefault||(Object.create?function(le,pe){Object.defineProperty(le,"default",{enumerable:!0,value:pe})}:function(le,pe){le.default=pe}),ie=commonjsGlobal&&commonjsGlobal.__importStar||function(le){if(le&&le.__esModule)return le;var pe={};if(le!=null)for(var be in le)be!=="default"&&Object.prototype.hasOwnProperty.call(le,be)&&t(pe,le,be);return c(pe,le),pe};Object.defineProperty(n,"__esModule",{value:!0}),n.formatBytes32String=n.Utf8ErrorFuncs=n.toUtf8String=n.toUtf8CodePoints=n.toUtf8Bytes=n._toEscapedUtf8String=n.nameprep=n.hexDataSlice=n.hexDataLength=n.hexZeroPad=n.hexValue=n.hexStripZeros=n.hexConcat=n.isHexString=n.hexlify=n.base64=n.base58=n.TransactionDescription=n.LogDescription=n.Interface=n.SigningKey=n.HDNode=n.defaultPath=n.isBytesLike=n.isBytes=n.zeroPad=n.stripZeros=n.concat=n.arrayify=n.shallowCopy=n.resolveProperties=n.getStatic=n.defineReadOnly=n.deepCopy=n.checkProperties=n.poll=n.fetchJson=n._fetchData=n.RLP=n.Logger=n.checkResultErrors=n.FormatTypes=n.ParamType=n.FunctionFragment=n.EventFragment=n.ErrorFragment=n.ConstructorFragment=n.Fragment=n.defaultAbiCoder=n.AbiCoder=void 0,n.Indexed=n.Utf8ErrorReason=n.UnicodeNormalizationForm=n.SupportedAlgorithm=n.mnemonicToSeed=n.isValidMnemonic=n.entropyToMnemonic=n.mnemonicToEntropy=n.getAccountPath=n.verifyTypedData=n.verifyMessage=n.recoverPublicKey=n.computePublicKey=n.recoverAddress=n.computeAddress=n.getJsonWalletAddress=n.TransactionTypes=n.serializeTransaction=n.parseTransaction=n.accessListify=n.joinSignature=n.splitSignature=n.soliditySha256=n.solidityKeccak256=n.solidityPack=n.shuffled=n.randomBytes=n.sha512=n.sha256=n.ripemd160=n.keccak256=n.computeHmac=n.commify=n.parseUnits=n.formatUnits=n.parseEther=n.formatEther=n.isAddress=n.getCreate2Address=n.getContractAddress=n.getIcapAddress=n.getAddress=n._TypedDataEncoder=n.id=n.isValidName=n.namehash=n.hashMessage=n.dnsEncode=n.parseBytes32String=void 0;var se=require$$0$3;Object.defineProperty(n,"AbiCoder",{enumerable:!0,get:function(){return se.AbiCoder}}),Object.defineProperty(n,"checkResultErrors",{enumerable:!0,get:function(){return se.checkResultErrors}}),Object.defineProperty(n,"ConstructorFragment",{enumerable:!0,get:function(){return se.ConstructorFragment}}),Object.defineProperty(n,"defaultAbiCoder",{enumerable:!0,get:function(){return se.defaultAbiCoder}}),Object.defineProperty(n,"ErrorFragment",{enumerable:!0,get:function(){return se.ErrorFragment}}),Object.defineProperty(n,"EventFragment",{enumerable:!0,get:function(){return se.EventFragment}}),Object.defineProperty(n,"FormatTypes",{enumerable:!0,get:function(){return se.FormatTypes}}),Object.defineProperty(n,"Fragment",{enumerable:!0,get:function(){return se.Fragment}}),Object.defineProperty(n,"FunctionFragment",{enumerable:!0,get:function(){return se.FunctionFragment}}),Object.defineProperty(n,"Indexed",{enumerable:!0,get:function(){return se.Indexed}}),Object.defineProperty(n,"Interface",{enumerable:!0,get:function(){return se.Interface}}),Object.defineProperty(n,"LogDescription",{enumerable:!0,get:function(){return se.LogDescription}}),Object.defineProperty(n,"ParamType",{enumerable:!0,get:function(){return se.ParamType}}),Object.defineProperty(n,"TransactionDescription",{enumerable:!0,get:function(){return se.TransactionDescription}});var ae=require$$1$2;Object.defineProperty(n,"getAddress",{enumerable:!0,get:function(){return ae.getAddress}}),Object.defineProperty(n,"getCreate2Address",{enumerable:!0,get:function(){return ae.getCreate2Address}}),Object.defineProperty(n,"getContractAddress",{enumerable:!0,get:function(){return ae.getContractAddress}}),Object.defineProperty(n,"getIcapAddress",{enumerable:!0,get:function(){return ae.getIcapAddress}}),Object.defineProperty(n,"isAddress",{enumerable:!0,get:function(){return ae.isAddress}});var ue=ie(require$$2$3);n.base64=ue;var de=require$$3;Object.defineProperty(n,"base58",{enumerable:!0,get:function(){return de.Base58}});var ve=require$$4$3;Object.defineProperty(n,"arrayify",{enumerable:!0,get:function(){return ve.arrayify}}),Object.defineProperty(n,"concat",{enumerable:!0,get:function(){return ve.concat}}),Object.defineProperty(n,"hexConcat",{enumerable:!0,get:function(){return ve.hexConcat}}),Object.defineProperty(n,"hexDataSlice",{enumerable:!0,get:function(){return ve.hexDataSlice}}),Object.defineProperty(n,"hexDataLength",{enumerable:!0,get:function(){return ve.hexDataLength}}),Object.defineProperty(n,"hexlify",{enumerable:!0,get:function(){return ve.hexlify}}),Object.defineProperty(n,"hexStripZeros",{enumerable:!0,get:function(){return ve.hexStripZeros}}),Object.defineProperty(n,"hexValue",{enumerable:!0,get:function(){return ve.hexValue}}),Object.defineProperty(n,"hexZeroPad",{enumerable:!0,get:function(){return ve.hexZeroPad}}),Object.defineProperty(n,"isBytes",{enumerable:!0,get:function(){return ve.isBytes}}),Object.defineProperty(n,"isBytesLike",{enumerable:!0,get:function(){return ve.isBytesLike}}),Object.defineProperty(n,"isHexString",{enumerable:!0,get:function(){return ve.isHexString}}),Object.defineProperty(n,"joinSignature",{enumerable:!0,get:function(){return ve.joinSignature}}),Object.defineProperty(n,"zeroPad",{enumerable:!0,get:function(){return ve.zeroPad}}),Object.defineProperty(n,"splitSignature",{enumerable:!0,get:function(){return ve.splitSignature}}),Object.defineProperty(n,"stripZeros",{enumerable:!0,get:function(){return ve.stripZeros}});var ge=require$$5;Object.defineProperty(n,"_TypedDataEncoder",{enumerable:!0,get:function(){return ge._TypedDataEncoder}}),Object.defineProperty(n,"dnsEncode",{enumerable:!0,get:function(){return ge.dnsEncode}}),Object.defineProperty(n,"hashMessage",{enumerable:!0,get:function(){return ge.hashMessage}}),Object.defineProperty(n,"id",{enumerable:!0,get:function(){return ge.id}}),Object.defineProperty(n,"isValidName",{enumerable:!0,get:function(){return ge.isValidName}}),Object.defineProperty(n,"namehash",{enumerable:!0,get:function(){return ge.namehash}});var we=require$$6$2;Object.defineProperty(n,"defaultPath",{enumerable:!0,get:function(){return we.defaultPath}}),Object.defineProperty(n,"entropyToMnemonic",{enumerable:!0,get:function(){return we.entropyToMnemonic}}),Object.defineProperty(n,"getAccountPath",{enumerable:!0,get:function(){return we.getAccountPath}}),Object.defineProperty(n,"HDNode",{enumerable:!0,get:function(){return we.HDNode}}),Object.defineProperty(n,"isValidMnemonic",{enumerable:!0,get:function(){return we.isValidMnemonic}}),Object.defineProperty(n,"mnemonicToEntropy",{enumerable:!0,get:function(){return we.mnemonicToEntropy}}),Object.defineProperty(n,"mnemonicToSeed",{enumerable:!0,get:function(){return we.mnemonicToSeed}});var Te=require$$7;Object.defineProperty(n,"getJsonWalletAddress",{enumerable:!0,get:function(){return Te.getJsonWalletAddress}});var Ne=require$$8;Object.defineProperty(n,"keccak256",{enumerable:!0,get:function(){return Ne.keccak256}});var qe=require$$9;Object.defineProperty(n,"Logger",{enumerable:!0,get:function(){return qe.Logger}});var ze=require$$10;Object.defineProperty(n,"computeHmac",{enumerable:!0,get:function(){return ze.computeHmac}}),Object.defineProperty(n,"ripemd160",{enumerable:!0,get:function(){return ze.ripemd160}}),Object.defineProperty(n,"sha256",{enumerable:!0,get:function(){return ze.sha256}}),Object.defineProperty(n,"sha512",{enumerable:!0,get:function(){return ze.sha512}});var He=require$$11$1;Object.defineProperty(n,"solidityKeccak256",{enumerable:!0,get:function(){return He.keccak256}}),Object.defineProperty(n,"solidityPack",{enumerable:!0,get:function(){return He.pack}}),Object.defineProperty(n,"soliditySha256",{enumerable:!0,get:function(){return He.sha256}});var Ge=require$$12;Object.defineProperty(n,"randomBytes",{enumerable:!0,get:function(){return Ge.randomBytes}}),Object.defineProperty(n,"shuffled",{enumerable:!0,get:function(){return Ge.shuffled}});var Ze=require$$13;Object.defineProperty(n,"checkProperties",{enumerable:!0,get:function(){return Ze.checkProperties}}),Object.defineProperty(n,"deepCopy",{enumerable:!0,get:function(){return Ze.deepCopy}}),Object.defineProperty(n,"defineReadOnly",{enumerable:!0,get:function(){return Ze.defineReadOnly}}),Object.defineProperty(n,"getStatic",{enumerable:!0,get:function(){return Ze.getStatic}}),Object.defineProperty(n,"resolveProperties",{enumerable:!0,get:function(){return Ze.resolveProperties}}),Object.defineProperty(n,"shallowCopy",{enumerable:!0,get:function(){return Ze.shallowCopy}});var Ye=ie(require$$14);n.RLP=Ye;var Ft=require$$15;Object.defineProperty(n,"computePublicKey",{enumerable:!0,get:function(){return Ft.computePublicKey}}),Object.defineProperty(n,"recoverPublicKey",{enumerable:!0,get:function(){return Ft.recoverPublicKey}}),Object.defineProperty(n,"SigningKey",{enumerable:!0,get:function(){return Ft.SigningKey}});var Mt=require$$16;Object.defineProperty(n,"formatBytes32String",{enumerable:!0,get:function(){return Mt.formatBytes32String}}),Object.defineProperty(n,"nameprep",{enumerable:!0,get:function(){return Mt.nameprep}}),Object.defineProperty(n,"parseBytes32String",{enumerable:!0,get:function(){return Mt.parseBytes32String}}),Object.defineProperty(n,"_toEscapedUtf8String",{enumerable:!0,get:function(){return Mt._toEscapedUtf8String}}),Object.defineProperty(n,"toUtf8Bytes",{enumerable:!0,get:function(){return Mt.toUtf8Bytes}}),Object.defineProperty(n,"toUtf8CodePoints",{enumerable:!0,get:function(){return Mt.toUtf8CodePoints}}),Object.defineProperty(n,"toUtf8String",{enumerable:!0,get:function(){return Mt.toUtf8String}}),Object.defineProperty(n,"Utf8ErrorFuncs",{enumerable:!0,get:function(){return Mt.Utf8ErrorFuncs}});var Zt=require$$17$1;Object.defineProperty(n,"accessListify",{enumerable:!0,get:function(){return Zt.accessListify}}),Object.defineProperty(n,"computeAddress",{enumerable:!0,get:function(){return Zt.computeAddress}}),Object.defineProperty(n,"parseTransaction",{enumerable:!0,get:function(){return Zt.parse}}),Object.defineProperty(n,"recoverAddress",{enumerable:!0,get:function(){return Zt.recoverAddress}}),Object.defineProperty(n,"serializeTransaction",{enumerable:!0,get:function(){return Zt.serialize}}),Object.defineProperty(n,"TransactionTypes",{enumerable:!0,get:function(){return Zt.TransactionTypes}});var cn=require$$18;Object.defineProperty(n,"commify",{enumerable:!0,get:function(){return cn.commify}}),Object.defineProperty(n,"formatEther",{enumerable:!0,get:function(){return cn.formatEther}}),Object.defineProperty(n,"parseEther",{enumerable:!0,get:function(){return cn.parseEther}}),Object.defineProperty(n,"formatUnits",{enumerable:!0,get:function(){return cn.formatUnits}}),Object.defineProperty(n,"parseUnits",{enumerable:!0,get:function(){return cn.parseUnits}});var hn=require$$19;Object.defineProperty(n,"verifyMessage",{enumerable:!0,get:function(){return hn.verifyMessage}}),Object.defineProperty(n,"verifyTypedData",{enumerable:!0,get:function(){return hn.verifyTypedData}});var yn=require$$20;Object.defineProperty(n,"_fetchData",{enumerable:!0,get:function(){return yn._fetchData}}),Object.defineProperty(n,"fetchJson",{enumerable:!0,get:function(){return yn.fetchJson}}),Object.defineProperty(n,"poll",{enumerable:!0,get:function(){return yn.poll}});var Ht=require$$10;Object.defineProperty(n,"SupportedAlgorithm",{enumerable:!0,get:function(){return Ht.SupportedAlgorithm}});var Sn=require$$16;Object.defineProperty(n,"UnicodeNormalizationForm",{enumerable:!0,get:function(){return Sn.UnicodeNormalizationForm}}),Object.defineProperty(n,"Utf8ErrorReason",{enumerable:!0,get:function(){return Sn.Utf8ErrorReason}})})(utils$e);const ZERO_ADDRESS="0x0000000000000000000000000000000000000000",SkaleUsdcAddressForTestnet="0x2aebcdc4f9f9149a50422fff86198cb0939ea165",SkaleUsdcAddressForMainnet="0x7Cf76E740Cb23b99337b21F392F22c47Ad910c67",erc20ABI=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"allowance",type:"uint256"},{internalType:"uint256",name:"needed",type:"uint256"}],name:"ERC20InsufficientAllowance",type:"error"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"uint256",name:"balance",type:"uint256"},{internalType:"uint256",name:"needed",type:"uint256"}],name:"ERC20InsufficientBalance",type:"error"},{inputs:[{internalType:"address",name:"approver",type:"address"}],name:"ERC20InvalidApprover",type:"error"},{inputs:[{internalType:"address",name:"receiver",type:"address"}],name:"ERC20InvalidReceiver",type:"error"},{inputs:[{internalType:"address",name:"sender",type:"address"}],name:"ERC20InvalidSender",type:"error"},{inputs:[{internalType:"address",name:"spender",type:"address"}],name:"ERC20InvalidSpender",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"}],paymentProxyABI=[{inputs:[{internalType:"uint256",name:"_heartBeat",type:"uint256"},{internalType:"address",name:"_chainLinkProvider",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"OwnableInvalidOwner",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"OwnableUnauthorizedAccount",type:"error"},{inputs:[{internalType:"uint256",name:"priceTimestamp",type:"uint256"},{internalType:"uint256",name:"currentTimestamp",type:"uint256"}],name:"oldPrice",type:"error"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"newHeartBeat",type:"uint256"}],name:"HeartBeatChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"ProductPurchased",type:"event"},{inputs:[{internalType:"uint256",name:"_heartBeat",type:"uint256"}],name:"changeHeartBeat",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256[]",name:"tbdValues",type:"uint256[]"},{internalType:"address[]",name:"tbdReceivers",type:"address[]"},{internalType:"address",name:"currency",type:"address"},{internalType:"uint80",name:"roundId",type:"uint80"},{internalType:"string",name:"memo",type:"string"}],name:"droplinkedPurchase",outputs:[],stateMutability:"payable",type:"function"},{inputs:[],name:"heartBeat",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"}];async function handleCustomTokenApproval(n,t,c,ie,se){if(!n.tokenAddress)throw new InvalidParametersException(Chains.BASE,"Token address is not set");try{const ae=new Contract(n.tokenAddress,erc20ABI,c),ue=await ae.balanceOf(ie),de=n.tbdValues.reduce((ge,we)=>ge.add(BigNumber.from(we)),BigNumber.from(0));if(ue.lt(de))throw new InsufficientBalanceException;se.changeStep("Approving token");const ve=await ae.approve(t,MaxUint256$1);se.changeStep("awaiting confirmation"),await ve.wait(),se.changeStep("Token approval confirmed")}catch(ae){handleError(ae)}}const droplinkedPayment=async function(n,t,c){const{modalInterface:ie}=t,{provider:se,chain:ae,network:ue}=n;if(!c.tbdReceivers.every(utils$e.isAddress))throw new InvalidParametersException(ae,"Invalid receiver address found");c.chainLinkRoundId=c.chainLinkRoundId||"0";const de=c.tokenAddress&&c.tokenAddress!==ZERO_ADDRESS;if(de){if(!c.tbdValues.every(Ne=>BigNumber.from(Ne).gt(0)))throw new InvalidParametersException(ae,"tbdValues must be positive numbers")}else if(!c.tbdValues.every(Ne=>Ne>0))throw new InvalidParametersException(ae,"tbdValues must be positive numbers");const ve=se.getSigner(),ge=await ve.getAddress();if(!c.tbdValues)throw new InvalidParametersException(ae,`Invalid tbdValues: ${c.tbdValues}`);if(!c.tbdReceivers)throw new InvalidParametersException(ae,`Invalid tbdReceivers: ${c.tbdReceivers}`);if(!c.memo)throw new InvalidParametersException(ae,`Memo is required for payment, current memo: ${c.memo}`);if(c.tbdReceivers.length!==c.tbdValues.length)throw new InvalidParametersException(ae,"tbdReceivers and tbdValues must be the same length");let we;try{we=await getProxyAddress(ae,ue)}catch(Ne){throw new Error("Failed to get contract address: "+Ne.message)}let Te;try{Te=new Contract(we,paymentProxyABI,ve)}catch(Ne){throw new Error("Failed to create contract instance: "+Ne.message)}try{if(console.log(`
13
+ `)}static register(t,c){c||(c=t.locale)}}const words="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo";let wordlist=null;function loadWords(n){if(wordlist==null&&(wordlist=words.replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),Wordlist.check(n)!=="0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"))throw wordlist=null,new Error("BIP39 Wordlist for en (English) FAILED")}class LangEn extends Wordlist{constructor(){super("en")}getWord(t){return loadWords(this),wordlist[t]}getWordIndex(t){return loadWords(this),wordlist.indexOf(t)}}const langEn=new LangEn;Wordlist.register(langEn);const wordlists={en:langEn},version$e="hdnode/5.8.0",logger$c=new Logger(version$e),N$3=BigNumber.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),MasterSecret=toUtf8Bytes("Bitcoin seed"),HardenedBit=2147483648;function getUpperMask(n){return(1<<n)-1<<8-n}function getLowerMask(n){return(1<<n)-1}function bytes32(n){return hexZeroPad(hexlify(n),32)}function base58check(n){return Base58.encode(concat$1([n,hexDataSlice(sha256$7(sha256$7(n)),0,4)]))}function getWordlist(n){if(n==null)return wordlists.en;if(typeof n=="string"){const t=wordlists[n];return t==null&&logger$c.throwArgumentError("unknown locale","wordlist",n),t}return n}const _constructorGuard$1={},defaultPath="m/44'/60'/0'/0/0";class HDNode{constructor(t,c,ie,se,ae,ue,de,ve){if(t!==_constructorGuard$1)throw new Error("HDNode constructor cannot be called directly");if(c){const ge=new SigningKey(c);defineReadOnly(this,"privateKey",ge.privateKey),defineReadOnly(this,"publicKey",ge.compressedPublicKey)}else defineReadOnly(this,"privateKey",null),defineReadOnly(this,"publicKey",hexlify(ie));defineReadOnly(this,"parentFingerprint",se),defineReadOnly(this,"fingerprint",hexDataSlice(ripemd160$1(sha256$7(this.publicKey)),0,4)),defineReadOnly(this,"address",computeAddress(this.publicKey)),defineReadOnly(this,"chainCode",ae),defineReadOnly(this,"index",ue),defineReadOnly(this,"depth",de),ve==null?(defineReadOnly(this,"mnemonic",null),defineReadOnly(this,"path",null)):typeof ve=="string"?(defineReadOnly(this,"mnemonic",null),defineReadOnly(this,"path",ve)):(defineReadOnly(this,"mnemonic",ve),defineReadOnly(this,"path",ve.path))}get extendedKey(){if(this.depth>=256)throw new Error("Depth too large!");return base58check(concat$1([this.privateKey!=null?"0x0488ADE4":"0x0488B21E",hexlify(this.depth),this.parentFingerprint,hexZeroPad(hexlify(this.index),4),this.chainCode,this.privateKey!=null?concat$1(["0x00",this.privateKey]):this.publicKey]))}neuter(){return new HDNode(_constructorGuard$1,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,this.path)}_derive(t){if(t>4294967295)throw new Error("invalid index - "+String(t));let c=this.path;c&&(c+="/"+(t&~HardenedBit));const ie=new Uint8Array(37);if(t&HardenedBit){if(!this.privateKey)throw new Error("cannot derive child of neutered node");ie.set(arrayify(this.privateKey),1),c&&(c+="'")}else ie.set(arrayify(this.publicKey));for(let Te=24;Te>=0;Te-=8)ie[33+(Te>>3)]=t>>24-Te&255;const se=arrayify(computeHmac(SupportedAlgorithm.sha512,this.chainCode,ie)),ae=se.slice(0,32),ue=se.slice(32);let de=null,ve=null;this.privateKey?de=bytes32(BigNumber.from(ae).add(this.privateKey).mod(N$3)):ve=new SigningKey(hexlify(ae))._addPoint(this.publicKey);let ge=c;const we=this.mnemonic;return we&&(ge=Object.freeze({phrase:we.phrase,path:c,locale:we.locale||"en"})),new HDNode(_constructorGuard$1,de,ve,this.fingerprint,bytes32(ue),t,this.depth+1,ge)}derivePath(t){const c=t.split("/");if(c.length===0||c[0]==="m"&&this.depth!==0)throw new Error("invalid path - "+t);c[0]==="m"&&c.shift();let ie=this;for(let se=0;se<c.length;se++){const ae=c[se];if(ae.match(/^[0-9]+'$/)){const ue=parseInt(ae.substring(0,ae.length-1));if(ue>=HardenedBit)throw new Error("invalid path index - "+ae);ie=ie._derive(HardenedBit+ue)}else if(ae.match(/^[0-9]+$/)){const ue=parseInt(ae);if(ue>=HardenedBit)throw new Error("invalid path index - "+ae);ie=ie._derive(ue)}else throw new Error("invalid path component - "+ae)}return ie}static _fromSeed(t,c){const ie=arrayify(t);if(ie.length<16||ie.length>64)throw new Error("invalid seed");const se=arrayify(computeHmac(SupportedAlgorithm.sha512,MasterSecret,ie));return new HDNode(_constructorGuard$1,bytes32(se.slice(0,32)),null,"0x00000000",bytes32(se.slice(32)),0,0,c)}static fromMnemonic(t,c,ie){return ie=getWordlist(ie),t=entropyToMnemonic(mnemonicToEntropy(t,ie),ie),HDNode._fromSeed(mnemonicToSeed(t,c),{phrase:t,path:"m",locale:ie.locale})}static fromSeed(t){return HDNode._fromSeed(t,null)}static fromExtendedKey(t){const c=Base58.decode(t);(c.length!==82||base58check(c.slice(0,78))!==t)&&logger$c.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");const ie=c[4],se=hexlify(c.slice(5,9)),ae=parseInt(hexlify(c.slice(9,13)).substring(2),16),ue=hexlify(c.slice(13,45)),de=c.slice(45,78);switch(hexlify(c.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new HDNode(_constructorGuard$1,null,hexlify(de),se,ue,ae,ie,null);case"0x0488ade4":case"0x04358394 ":if(de[0]!==0)break;return new HDNode(_constructorGuard$1,hexlify(de.slice(1)),null,se,ue,ae,ie,null)}return logger$c.throwArgumentError("invalid extended key","extendedKey","[REDACTED]")}}function mnemonicToSeed(n,t){t||(t="");const c=toUtf8Bytes("mnemonic"+t,UnicodeNormalizationForm.NFKD);return pbkdf2$1(toUtf8Bytes(n,UnicodeNormalizationForm.NFKD),c,2048,64,"sha512")}function mnemonicToEntropy(n,t){t=getWordlist(t),logger$c.checkNormalize();const c=t.split(n);if(c.length%3!==0)throw new Error("invalid mnemonic");const ie=arrayify(new Uint8Array(Math.ceil(11*c.length/8)));let se=0;for(let ve=0;ve<c.length;ve++){let ge=t.getWordIndex(c[ve].normalize("NFKD"));if(ge===-1)throw new Error("invalid mnemonic");for(let we=0;we<11;we++)ge&1<<10-we&&(ie[se>>3]|=1<<7-se%8),se++}const ae=32*c.length/3,ue=c.length/3,de=getUpperMask(ue);if((arrayify(sha256$7(ie.slice(0,ae/8)))[0]&de)!==(ie[ie.length-1]&de))throw new Error("invalid checksum");return hexlify(ie.slice(0,ae/8))}function entropyToMnemonic(n,t){if(t=getWordlist(t),n=arrayify(n),n.length%4!==0||n.length<16||n.length>32)throw new Error("invalid entropy");const c=[0];let ie=11;for(let ue=0;ue<n.length;ue++)ie>8?(c[c.length-1]<<=8,c[c.length-1]|=n[ue],ie-=8):(c[c.length-1]<<=ie,c[c.length-1]|=n[ue]>>8-ie,c.push(n[ue]&getLowerMask(8-ie)),ie+=3);const se=n.length/4,ae=arrayify(sha256$7(n))[0]&getUpperMask(se);return c[c.length-1]<<=se,c[c.length-1]|=ae>>8-se,t.join(c.map(ue=>t.getWord(ue)))}function isValidMnemonic(n,t){try{return mnemonicToEntropy(n,t),!0}catch{}return!1}function getAccountPath(n){return(typeof n!="number"||n<0||n>=HardenedBit||n%1)&&logger$c.throwArgumentError("invalid account index","index",n),`m/44'/60'/${n}'/0/0`}const lib_esm$6=Object.freeze(Object.defineProperty({__proto__:null,HDNode,defaultPath,entropyToMnemonic,getAccountPath,isValidMnemonic,mnemonicToEntropy,mnemonicToSeed},Symbol.toStringTag,{value:"Module"})),version$d="random/5.8.0",logger$b=new Logger(version$d);function getGlobal(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof globalThis<"u")return globalThis;throw new Error("unable to locate global object")}const anyGlobal=getGlobal();let crypto$3=anyGlobal.crypto||anyGlobal.msCrypto;(!crypto$3||!crypto$3.getRandomValues)&&(logger$b.warn("WARNING: Missing strong random number source"),crypto$3={getRandomValues:function(n){return logger$b.throwError("no secure random source avaialble",Logger.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}});function randomBytes$1(n){(n<=0||n>1024||n%1||n!=n)&&logger$b.throwArgumentError("invalid length","length",n);const t=new Uint8Array(n);return crypto$3.getRandomValues(t),arrayify(t)}function shuffled(n){n=n.slice();for(let t=n.length-1;t>0;t--){const c=Math.floor(Math.random()*(t+1)),ie=n[t];n[t]=n[c],n[c]=ie}return n}const lib_esm$5=Object.freeze(Object.defineProperty({__proto__:null,randomBytes:randomBytes$1,shuffled},Symbol.toStringTag,{value:"Module"}));var aesJs={exports:{}};(function(n,t){(function(c){function ie(We){return parseInt(We)===We}function se(We){if(!ie(We.length))return!1;for(var $t=0;$t<We.length;$t++)if(!ie(We[$t])||We[$t]<0||We[$t]>255)return!1;return!0}function ae(We,$t){if(We.buffer&&ArrayBuffer.isView(We)&&We.name==="Uint8Array")return $t&&(We.slice?We=We.slice():We=Array.prototype.slice.call(We)),We;if(Array.isArray(We)){if(!se(We))throw new Error("Array contains invalid value: "+We);return new Uint8Array(We)}if(ie(We.length)&&se(We))return new Uint8Array(We);throw new Error("unsupported array-like object")}function ue(We){return new Uint8Array(We)}function de(We,$t,dn,gn,Vt){(gn!=null||Vt!=null)&&(We.slice?We=We.slice(gn,Vt):We=Array.prototype.slice.call(We,gn,Vt)),$t.set(We,dn)}var ve=(function(){function We(dn){var gn=[],Vt=0;for(dn=encodeURI(dn);Vt<dn.length;){var Cn=dn.charCodeAt(Vt++);Cn===37?(gn.push(parseInt(dn.substr(Vt,2),16)),Vt+=2):gn.push(Cn)}return ae(gn)}function $t(dn){for(var gn=[],Vt=0;Vt<dn.length;){var Cn=dn[Vt];Cn<128?(gn.push(String.fromCharCode(Cn)),Vt++):Cn>191&&Cn<224?(gn.push(String.fromCharCode((Cn&31)<<6|dn[Vt+1]&63)),Vt+=2):(gn.push(String.fromCharCode((Cn&15)<<12|(dn[Vt+1]&63)<<6|dn[Vt+2]&63)),Vt+=3)}return gn.join("")}return{toBytes:We,fromBytes:$t}})(),ge=(function(){function We(gn){for(var Vt=[],Cn=0;Cn<gn.length;Cn+=2)Vt.push(parseInt(gn.substr(Cn,2),16));return Vt}var $t="0123456789abcdef";function dn(gn){for(var Vt=[],Cn=0;Cn<gn.length;Cn++){var un=gn[Cn];Vt.push($t[(un&240)>>4]+$t[un&15])}return Vt.join("")}return{toBytes:We,fromBytes:dn}})(),we={16:10,24:12,32:14},Te=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],Ne=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],qe=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],ze=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],He=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],Ge=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],Ze=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],Ye=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],Ft=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],Mt=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],Zt=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],cn=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],hn=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],yn=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],Ht=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function Sn(We){for(var $t=[],dn=0;dn<We.length;dn+=4)$t.push(We[dn]<<24|We[dn+1]<<16|We[dn+2]<<8|We[dn+3]);return $t}var le=function(We){if(!(this instanceof le))throw Error("AES must be instanitated with `new`");Object.defineProperty(this,"key",{value:ae(We,!0)}),this._prepare()};le.prototype._prepare=function(){var We=we[this.key.length];if(We==null)throw new Error("invalid key size (must be 16, 24 or 32 bytes)");this._Ke=[],this._Kd=[];for(var $t=0;$t<=We;$t++)this._Ke.push([0,0,0,0]),this._Kd.push([0,0,0,0]);for(var dn=(We+1)*4,gn=this.key.length/4,Vt=Sn(this.key),Cn,$t=0;$t<gn;$t++)Cn=$t>>2,this._Ke[Cn][$t%4]=Vt[$t],this._Kd[We-Cn][$t%4]=Vt[$t];for(var un=0,Pt=gn,mn;Pt<dn;){if(mn=Vt[gn-1],Vt[0]^=Ne[mn>>16&255]<<24^Ne[mn>>8&255]<<16^Ne[mn&255]<<8^Ne[mn>>24&255]^Te[un]<<24,un+=1,gn!=8)for(var $t=1;$t<gn;$t++)Vt[$t]^=Vt[$t-1];else{for(var $t=1;$t<gn/2;$t++)Vt[$t]^=Vt[$t-1];mn=Vt[gn/2-1],Vt[gn/2]^=Ne[mn&255]^Ne[mn>>8&255]<<8^Ne[mn>>16&255]<<16^Ne[mn>>24&255]<<24;for(var $t=gn/2+1;$t<gn;$t++)Vt[$t]^=Vt[$t-1]}for(var $t=0,Pn,wn;$t<gn&&Pt<dn;)Pn=Pt>>2,wn=Pt%4,this._Ke[Pn][wn]=Vt[$t],this._Kd[We-Pn][wn]=Vt[$t++],Pt++}for(var Pn=1;Pn<We;Pn++)for(var wn=0;wn<4;wn++)mn=this._Kd[Pn][wn],this._Kd[Pn][wn]=cn[mn>>24&255]^hn[mn>>16&255]^yn[mn>>8&255]^Ht[mn&255]},le.prototype.encrypt=function(We){if(We.length!=16)throw new Error("invalid plaintext size (must be 16 bytes)");for(var $t=this._Ke.length-1,dn=[0,0,0,0],gn=Sn(We),Vt=0;Vt<4;Vt++)gn[Vt]^=this._Ke[0][Vt];for(var Cn=1;Cn<$t;Cn++){for(var Vt=0;Vt<4;Vt++)dn[Vt]=ze[gn[Vt]>>24&255]^He[gn[(Vt+1)%4]>>16&255]^Ge[gn[(Vt+2)%4]>>8&255]^Ze[gn[(Vt+3)%4]&255]^this._Ke[Cn][Vt];gn=dn.slice()}for(var un=ue(16),Pt,Vt=0;Vt<4;Vt++)Pt=this._Ke[$t][Vt],un[4*Vt]=(Ne[gn[Vt]>>24&255]^Pt>>24)&255,un[4*Vt+1]=(Ne[gn[(Vt+1)%4]>>16&255]^Pt>>16)&255,un[4*Vt+2]=(Ne[gn[(Vt+2)%4]>>8&255]^Pt>>8)&255,un[4*Vt+3]=(Ne[gn[(Vt+3)%4]&255]^Pt)&255;return un},le.prototype.decrypt=function(We){if(We.length!=16)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var $t=this._Kd.length-1,dn=[0,0,0,0],gn=Sn(We),Vt=0;Vt<4;Vt++)gn[Vt]^=this._Kd[0][Vt];for(var Cn=1;Cn<$t;Cn++){for(var Vt=0;Vt<4;Vt++)dn[Vt]=Ye[gn[Vt]>>24&255]^Ft[gn[(Vt+3)%4]>>16&255]^Mt[gn[(Vt+2)%4]>>8&255]^Zt[gn[(Vt+1)%4]&255]^this._Kd[Cn][Vt];gn=dn.slice()}for(var un=ue(16),Pt,Vt=0;Vt<4;Vt++)Pt=this._Kd[$t][Vt],un[4*Vt]=(qe[gn[Vt]>>24&255]^Pt>>24)&255,un[4*Vt+1]=(qe[gn[(Vt+3)%4]>>16&255]^Pt>>16)&255,un[4*Vt+2]=(qe[gn[(Vt+2)%4]>>8&255]^Pt>>8)&255,un[4*Vt+3]=(qe[gn[(Vt+1)%4]&255]^Pt)&255;return un};var pe=function(We){if(!(this instanceof pe))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new le(We)};pe.prototype.encrypt=function(We){if(We=ae(We),We.length%16!==0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var $t=ue(We.length),dn=ue(16),gn=0;gn<We.length;gn+=16)de(We,dn,0,gn,gn+16),dn=this._aes.encrypt(dn),de(dn,$t,gn);return $t},pe.prototype.decrypt=function(We){if(We=ae(We),We.length%16!==0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var $t=ue(We.length),dn=ue(16),gn=0;gn<We.length;gn+=16)de(We,dn,0,gn,gn+16),dn=this._aes.decrypt(dn),de(dn,$t,gn);return $t};var be=function(We,$t){if(!(this instanceof be))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Block Chaining",this.name="cbc",!$t)$t=ue(16);else if($t.length!=16)throw new Error("invalid initialation vector size (must be 16 bytes)");this._lastCipherblock=ae($t,!0),this._aes=new le(We)};be.prototype.encrypt=function(We){if(We=ae(We),We.length%16!==0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var $t=ue(We.length),dn=ue(16),gn=0;gn<We.length;gn+=16){de(We,dn,0,gn,gn+16);for(var Vt=0;Vt<16;Vt++)dn[Vt]^=this._lastCipherblock[Vt];this._lastCipherblock=this._aes.encrypt(dn),de(this._lastCipherblock,$t,gn)}return $t},be.prototype.decrypt=function(We){if(We=ae(We),We.length%16!==0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var $t=ue(We.length),dn=ue(16),gn=0;gn<We.length;gn+=16){de(We,dn,0,gn,gn+16),dn=this._aes.decrypt(dn);for(var Vt=0;Vt<16;Vt++)$t[gn+Vt]=dn[Vt]^this._lastCipherblock[Vt];de(We,this._lastCipherblock,0,gn,gn+16)}return $t};var xe=function(We,$t,dn){if(!(this instanceof xe))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Feedback",this.name="cfb",!$t)$t=ue(16);else if($t.length!=16)throw new Error("invalid initialation vector size (must be 16 size)");dn||(dn=1),this.segmentSize=dn,this._shiftRegister=ae($t,!0),this._aes=new le(We)};xe.prototype.encrypt=function(We){if(We.length%this.segmentSize!=0)throw new Error("invalid plaintext size (must be segmentSize bytes)");for(var $t=ae(We,!0),dn,gn=0;gn<$t.length;gn+=this.segmentSize){dn=this._aes.encrypt(this._shiftRegister);for(var Vt=0;Vt<this.segmentSize;Vt++)$t[gn+Vt]^=dn[Vt];de(this._shiftRegister,this._shiftRegister,0,this.segmentSize),de($t,this._shiftRegister,16-this.segmentSize,gn,gn+this.segmentSize)}return $t},xe.prototype.decrypt=function(We){if(We.length%this.segmentSize!=0)throw new Error("invalid ciphertext size (must be segmentSize bytes)");for(var $t=ae(We,!0),dn,gn=0;gn<$t.length;gn+=this.segmentSize){dn=this._aes.encrypt(this._shiftRegister);for(var Vt=0;Vt<this.segmentSize;Vt++)$t[gn+Vt]^=dn[Vt];de(this._shiftRegister,this._shiftRegister,0,this.segmentSize),de(We,this._shiftRegister,16-this.segmentSize,gn,gn+this.segmentSize)}return $t};var _e=function(We,$t){if(!(this instanceof _e))throw Error("AES must be instanitated with `new`");if(this.description="Output Feedback",this.name="ofb",!$t)$t=ue(16);else if($t.length!=16)throw new Error("invalid initialation vector size (must be 16 bytes)");this._lastPrecipher=ae($t,!0),this._lastPrecipherIndex=16,this._aes=new le(We)};_e.prototype.encrypt=function(We){for(var $t=ae(We,!0),dn=0;dn<$t.length;dn++)this._lastPrecipherIndex===16&&(this._lastPrecipher=this._aes.encrypt(this._lastPrecipher),this._lastPrecipherIndex=0),$t[dn]^=this._lastPrecipher[this._lastPrecipherIndex++];return $t},_e.prototype.decrypt=_e.prototype.encrypt;var De=function(We){if(!(this instanceof De))throw Error("Counter must be instanitated with `new`");We!==0&&!We&&(We=1),typeof We=="number"?(this._counter=ue(16),this.setValue(We)):this.setBytes(We)};De.prototype.setValue=function(We){if(typeof We!="number"||parseInt(We)!=We)throw new Error("invalid counter value (must be an integer)");for(var $t=15;$t>=0;--$t)this._counter[$t]=We%256,We=We>>8},De.prototype.setBytes=function(We){if(We=ae(We,!0),We.length!=16)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=We},De.prototype.increment=function(){for(var We=15;We>=0;We--)if(this._counter[We]===255)this._counter[We]=0;else{this._counter[We]++;break}};var Fe=function(We,$t){if(!(this instanceof Fe))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",$t instanceof De||($t=new De($t)),this._counter=$t,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new le(We)};Fe.prototype.encrypt=function(We){for(var $t=ae(We,!0),dn=0;dn<$t.length;dn++)this._remainingCounterIndex===16&&(this._remainingCounter=this._aes.encrypt(this._counter._counter),this._remainingCounterIndex=0,this._counter.increment()),$t[dn]^=this._remainingCounter[this._remainingCounterIndex++];return $t},Fe.prototype.decrypt=Fe.prototype.encrypt;function $e(We){We=ae(We,!0);var $t=16-We.length%16,dn=ue(We.length+$t);de(We,dn);for(var gn=We.length;gn<dn.length;gn++)dn[gn]=$t;return dn}function ce(We){if(We=ae(We,!0),We.length<16)throw new Error("PKCS#7 invalid length");var $t=We[We.length-1];if($t>16)throw new Error("PKCS#7 padding byte out of range");for(var dn=We.length-$t,gn=0;gn<$t;gn++)if(We[dn+gn]!==$t)throw new Error("PKCS#7 invalid padding byte");var Vt=ue(dn);return de(We,Vt,0,0,dn),Vt}var Me={AES:le,Counter:De,ModeOfOperation:{ecb:pe,cbc:be,cfb:xe,ofb:_e,ctr:Fe},utils:{hex:ge,utf8:ve},padding:{pkcs7:{pad:$e,strip:ce}},_arrayTest:{coerceArray:ae,createArray:ue,copyArray:de}};n.exports=Me})()})(aesJs);var aesJsExports=aesJs.exports;const aes$1=getDefaultExportFromCjs$2(aesJsExports),version$c="json-wallets/5.8.0";function looseArrayify(n){return typeof n=="string"&&n.substring(0,2)!=="0x"&&(n="0x"+n),arrayify(n)}function zpad(n,t){for(n=String(n);n.length<t;)n="0"+n;return n}function getPassword(n){return typeof n=="string"?toUtf8Bytes(n,UnicodeNormalizationForm.NFKC):arrayify(n)}function searchPath(n,t){let c=n;const ie=t.toLowerCase().split("/");for(let se=0;se<ie.length;se++){let ae=null;for(const ue in c)if(ue.toLowerCase()===ie[se]){ae=c[ue];break}if(ae===null)return null;c=ae}return c}function uuidV4(n){const t=arrayify(n);t[6]=t[6]&15|64,t[8]=t[8]&63|128;const c=hexlify(t);return[c.substring(2,10),c.substring(10,14),c.substring(14,18),c.substring(18,22),c.substring(22,34)].join("-")}const logger$a=new Logger(version$c);class CrowdsaleAccount extends Description{isCrowdsaleAccount(t){return!!(t&&t._isCrowdsaleAccount)}}function decrypt$1(n,t){const c=JSON.parse(n);t=getPassword(t);const ie=getAddress$1(searchPath(c,"ethaddr")),se=looseArrayify(searchPath(c,"encseed"));(!se||se.length%16!==0)&&logger$a.throwArgumentError("invalid encseed","json",n);const ae=arrayify(pbkdf2$1(t,t,2e3,32,"sha256")).slice(0,16),ue=se.slice(0,16),de=se.slice(16),ve=new aes$1.ModeOfOperation.cbc(ae,ue),ge=aes$1.padding.pkcs7.strip(arrayify(ve.decrypt(de)));let we="";for(let qe=0;qe<ge.length;qe++)we+=String.fromCharCode(ge[qe]);const Te=toUtf8Bytes(we),Ne=keccak256$1(Te);return new CrowdsaleAccount({_isCrowdsaleAccount:!0,address:ie,privateKey:Ne})}function isCrowdsaleWallet(n){let t=null;try{t=JSON.parse(n)}catch{return!1}return t.encseed&&t.ethaddr}function isKeystoreWallet(n){let t=null;try{t=JSON.parse(n)}catch{return!1}return!(!t.version||parseInt(t.version)!==t.version||parseInt(t.version)!==3)}function getJsonWalletAddress(n){if(isCrowdsaleWallet(n))try{return getAddress$1(JSON.parse(n).ethaddr)}catch{return null}if(isKeystoreWallet(n))try{return getAddress$1(JSON.parse(n).address)}catch{return null}return null}var scrypt$1={exports:{}};(function(n,t){(function(c){function ie(ze){const He=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);let Ge=1779033703,Ze=3144134277,Ye=1013904242,Ft=2773480762,Mt=1359893119,Zt=2600822924,cn=528734635,hn=1541459225;const yn=new Uint32Array(64);function Ht(De){let Fe=0,$e=De.length;for(;$e>=64;){let ce=Ge,Me=Ze,We=Ye,$t=Ft,dn=Mt,gn=Zt,Vt=cn,Cn=hn,un,Pt,mn,Pn,wn;for(Pt=0;Pt<16;Pt++)mn=Fe+Pt*4,yn[Pt]=(De[mn]&255)<<24|(De[mn+1]&255)<<16|(De[mn+2]&255)<<8|De[mn+3]&255;for(Pt=16;Pt<64;Pt++)un=yn[Pt-2],Pn=(un>>>17|un<<15)^(un>>>19|un<<13)^un>>>10,un=yn[Pt-15],wn=(un>>>7|un<<25)^(un>>>18|un<<14)^un>>>3,yn[Pt]=(Pn+yn[Pt-7]|0)+(wn+yn[Pt-16]|0)|0;for(Pt=0;Pt<64;Pt++)Pn=(((dn>>>6|dn<<26)^(dn>>>11|dn<<21)^(dn>>>25|dn<<7))+(dn&gn^~dn&Vt)|0)+(Cn+(He[Pt]+yn[Pt]|0)|0)|0,wn=((ce>>>2|ce<<30)^(ce>>>13|ce<<19)^(ce>>>22|ce<<10))+(ce&Me^ce&We^Me&We)|0,Cn=Vt,Vt=gn,gn=dn,dn=$t+Pn|0,$t=We,We=Me,Me=ce,ce=Pn+wn|0;Ge=Ge+ce|0,Ze=Ze+Me|0,Ye=Ye+We|0,Ft=Ft+$t|0,Mt=Mt+dn|0,Zt=Zt+gn|0,cn=cn+Vt|0,hn=hn+Cn|0,Fe+=64,$e-=64}}Ht(ze);let Sn,le=ze.length%64,pe=ze.length/536870912|0,be=ze.length<<3,xe=le<56?56:120,_e=ze.slice(ze.length-le,ze.length);for(_e.push(128),Sn=le+1;Sn<xe;Sn++)_e.push(0);return _e.push(pe>>>24&255),_e.push(pe>>>16&255),_e.push(pe>>>8&255),_e.push(pe>>>0&255),_e.push(be>>>24&255),_e.push(be>>>16&255),_e.push(be>>>8&255),_e.push(be>>>0&255),Ht(_e),[Ge>>>24&255,Ge>>>16&255,Ge>>>8&255,Ge>>>0&255,Ze>>>24&255,Ze>>>16&255,Ze>>>8&255,Ze>>>0&255,Ye>>>24&255,Ye>>>16&255,Ye>>>8&255,Ye>>>0&255,Ft>>>24&255,Ft>>>16&255,Ft>>>8&255,Ft>>>0&255,Mt>>>24&255,Mt>>>16&255,Mt>>>8&255,Mt>>>0&255,Zt>>>24&255,Zt>>>16&255,Zt>>>8&255,Zt>>>0&255,cn>>>24&255,cn>>>16&255,cn>>>8&255,cn>>>0&255,hn>>>24&255,hn>>>16&255,hn>>>8&255,hn>>>0&255]}function se(ze,He,Ge){ze=ze.length<=64?ze:ie(ze);const Ze=64+He.length+4,Ye=new Array(Ze),Ft=new Array(64);let Mt,Zt=[];for(Mt=0;Mt<64;Mt++)Ye[Mt]=54;for(Mt=0;Mt<ze.length;Mt++)Ye[Mt]^=ze[Mt];for(Mt=0;Mt<He.length;Mt++)Ye[64+Mt]=He[Mt];for(Mt=Ze-4;Mt<Ze;Mt++)Ye[Mt]=0;for(Mt=0;Mt<64;Mt++)Ft[Mt]=92;for(Mt=0;Mt<ze.length;Mt++)Ft[Mt]^=ze[Mt];function cn(){for(let hn=Ze-1;hn>=Ze-4;hn--){if(Ye[hn]++,Ye[hn]<=255)return;Ye[hn]=0}}for(;Ge>=32;)cn(),Zt=Zt.concat(ie(Ft.concat(ie(Ye)))),Ge-=32;return Ge>0&&(cn(),Zt=Zt.concat(ie(Ft.concat(ie(Ye))).slice(0,Ge))),Zt}function ae(ze,He,Ge,Ze,Ye){let Ft;for(ge(ze,(2*Ge-1)*16,Ye,0,16),Ft=0;Ft<2*Ge;Ft++)ve(ze,Ft*16,Ye,16),de(Ye,Ze),ge(Ye,0,ze,He+Ft*16,16);for(Ft=0;Ft<Ge;Ft++)ge(ze,He+Ft*2*16,ze,Ft*16,16);for(Ft=0;Ft<Ge;Ft++)ge(ze,He+(Ft*2+1)*16,ze,(Ft+Ge)*16,16)}function ue(ze,He){return ze<<He|ze>>>32-He}function de(ze,He){ge(ze,0,He,0,16);for(let Ge=8;Ge>0;Ge-=2)He[4]^=ue(He[0]+He[12],7),He[8]^=ue(He[4]+He[0],9),He[12]^=ue(He[8]+He[4],13),He[0]^=ue(He[12]+He[8],18),He[9]^=ue(He[5]+He[1],7),He[13]^=ue(He[9]+He[5],9),He[1]^=ue(He[13]+He[9],13),He[5]^=ue(He[1]+He[13],18),He[14]^=ue(He[10]+He[6],7),He[2]^=ue(He[14]+He[10],9),He[6]^=ue(He[2]+He[14],13),He[10]^=ue(He[6]+He[2],18),He[3]^=ue(He[15]+He[11],7),He[7]^=ue(He[3]+He[15],9),He[11]^=ue(He[7]+He[3],13),He[15]^=ue(He[11]+He[7],18),He[1]^=ue(He[0]+He[3],7),He[2]^=ue(He[1]+He[0],9),He[3]^=ue(He[2]+He[1],13),He[0]^=ue(He[3]+He[2],18),He[6]^=ue(He[5]+He[4],7),He[7]^=ue(He[6]+He[5],9),He[4]^=ue(He[7]+He[6],13),He[5]^=ue(He[4]+He[7],18),He[11]^=ue(He[10]+He[9],7),He[8]^=ue(He[11]+He[10],9),He[9]^=ue(He[8]+He[11],13),He[10]^=ue(He[9]+He[8],18),He[12]^=ue(He[15]+He[14],7),He[13]^=ue(He[12]+He[15],9),He[14]^=ue(He[13]+He[12],13),He[15]^=ue(He[14]+He[13],18);for(let Ge=0;Ge<16;++Ge)ze[Ge]+=He[Ge]}function ve(ze,He,Ge,Ze){for(let Ye=0;Ye<Ze;Ye++)Ge[Ye]^=ze[He+Ye]}function ge(ze,He,Ge,Ze,Ye){for(;Ye--;)Ge[Ze++]=ze[He++]}function we(ze){if(!ze||typeof ze.length!="number")return!1;for(let He=0;He<ze.length;He++){const Ge=ze[He];if(typeof Ge!="number"||Ge%1||Ge<0||Ge>=256)return!1}return!0}function Te(ze,He){if(typeof ze!="number"||ze%1)throw new Error("invalid "+He);return ze}function Ne(ze,He,Ge,Ze,Ye,Ft,Mt){if(Ge=Te(Ge,"N"),Ze=Te(Ze,"r"),Ye=Te(Ye,"p"),Ft=Te(Ft,"dkLen"),Ge===0||Ge&Ge-1)throw new Error("N must be power of 2");if(Ge>2147483647/128/Ze)throw new Error("N too large");if(Ze>2147483647/128/Ye)throw new Error("r too large");if(!we(ze))throw new Error("password must be an array or buffer");if(ze=Array.prototype.slice.call(ze),!we(He))throw new Error("salt must be an array or buffer");He=Array.prototype.slice.call(He);let Zt=se(ze,He,Ye*128*Ze);const cn=new Uint32Array(Ye*32*Ze);for(let dn=0;dn<cn.length;dn++){const gn=dn*4;cn[dn]=(Zt[gn+3]&255)<<24|(Zt[gn+2]&255)<<16|(Zt[gn+1]&255)<<8|(Zt[gn+0]&255)<<0}const hn=new Uint32Array(64*Ze),yn=new Uint32Array(32*Ze*Ge),Ht=32*Ze,Sn=new Uint32Array(16),le=new Uint32Array(16),pe=Ye*Ge*2;let be=0,xe=null,_e=!1,De=0,Fe=0,$e,ce;const Me=Mt?parseInt(1e3/Ze):4294967295,We=typeof setImmediate<"u"?setImmediate:setTimeout,$t=function(){if(_e)return Mt(new Error("cancelled"),be/pe);let dn;switch(De){case 0:ce=Fe*32*Ze,ge(cn,ce,hn,0,Ht),De=1,$e=0;case 1:dn=Ge-$e,dn>Me&&(dn=Me);for(let Vt=0;Vt<dn;Vt++)ge(hn,0,yn,($e+Vt)*Ht,Ht),ae(hn,Ht,Ze,Sn,le);if($e+=dn,be+=dn,Mt){const Vt=parseInt(1e3*be/pe);if(Vt!==xe){if(_e=Mt(null,be/pe),_e)break;xe=Vt}}if($e<Ge)break;$e=0,De=2;case 2:dn=Ge-$e,dn>Me&&(dn=Me);for(let Vt=0;Vt<dn;Vt++){const Cn=(2*Ze-1)*16,un=hn[Cn]&Ge-1;ve(yn,un*Ht,hn,Ht),ae(hn,Ht,Ze,Sn,le)}if($e+=dn,be+=dn,Mt){const Vt=parseInt(1e3*be/pe);if(Vt!==xe){if(_e=Mt(null,be/pe),_e)break;xe=Vt}}if($e<Ge)break;if(ge(hn,0,cn,ce,Ht),Fe++,Fe<Ye){De=0;break}Zt=[];for(let Vt=0;Vt<cn.length;Vt++)Zt.push(cn[Vt]>>0&255),Zt.push(cn[Vt]>>8&255),Zt.push(cn[Vt]>>16&255),Zt.push(cn[Vt]>>24&255);const gn=se(ze,Zt,Ft);return Mt&&Mt(null,1,gn),gn}Mt&&We($t)};if(!Mt)for(;;){const dn=$t();if(dn!=null)return dn}$t()}const qe={scrypt:function(ze,He,Ge,Ze,Ye,Ft,Mt){return new Promise(function(Zt,cn){let hn=0;Mt&&Mt(0),Ne(ze,He,Ge,Ze,Ye,Ft,function(yn,Ht,Sn){if(yn)cn(yn);else if(Sn)Mt&&hn!==1&&Mt(1),Zt(new Uint8Array(Sn));else if(Mt&&Ht!==hn)return hn=Ht,Mt(Ht)})})},syncScrypt:function(ze,He,Ge,Ze,Ye,Ft){return new Uint8Array(Ne(ze,He,Ge,Ze,Ye,Ft))}};n.exports=qe})()})(scrypt$1);var scryptExports=scrypt$1.exports;const scrypt=getDefaultExportFromCjs$2(scryptExports);var __awaiter$g=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$9=new Logger(version$c);function hasMnemonic$1(n){return n!=null&&n.mnemonic&&n.mnemonic.phrase}class KeystoreAccount extends Description{isKeystoreAccount(t){return!!(t&&t._isKeystoreAccount)}}function _decrypt(n,t,c){if(searchPath(n,"crypto/cipher")==="aes-128-ctr"){const ie=looseArrayify(searchPath(n,"crypto/cipherparams/iv")),se=new aes$1.Counter(ie),ae=new aes$1.ModeOfOperation.ctr(t,se);return arrayify(ae.decrypt(c))}return null}function _getAccount(n,t){const c=looseArrayify(searchPath(n,"crypto/ciphertext"));if(hexlify(keccak256$1(concat$1([t.slice(16,32),c]))).substring(2)!==searchPath(n,"crypto/mac").toLowerCase())throw new Error("invalid password");const ie=_decrypt(n,t.slice(0,16),c);ie||logger$9.throwError("unsupported cipher",Logger.errors.UNSUPPORTED_OPERATION,{operation:"decrypt"});const se=t.slice(32,64),ae=computeAddress(ie);if(n.address){let de=n.address.toLowerCase();if(de.substring(0,2)!=="0x"&&(de="0x"+de),getAddress$1(de)!==ae)throw new Error("address mismatch")}const ue={_isKeystoreAccount:!0,address:ae,privateKey:hexlify(ie)};if(searchPath(n,"x-ethers/version")==="0.1"){const de=looseArrayify(searchPath(n,"x-ethers/mnemonicCiphertext")),ve=looseArrayify(searchPath(n,"x-ethers/mnemonicCounter")),ge=new aes$1.Counter(ve),we=new aes$1.ModeOfOperation.ctr(se,ge),Te=searchPath(n,"x-ethers/path")||defaultPath,Ne=searchPath(n,"x-ethers/locale")||"en",qe=arrayify(we.decrypt(de));try{const ze=entropyToMnemonic(qe,Ne),He=HDNode.fromMnemonic(ze,null,Ne).derivePath(Te);if(He.privateKey!=ue.privateKey)throw new Error("mnemonic mismatch");ue.mnemonic=He.mnemonic}catch(ze){if(ze.code!==Logger.errors.INVALID_ARGUMENT||ze.argument!=="wordlist")throw ze}}return new KeystoreAccount(ue)}function pbkdf2Sync(n,t,c,ie,se){return arrayify(pbkdf2$1(n,t,c,ie,se))}function pbkdf2(n,t,c,ie,se){return Promise.resolve(pbkdf2Sync(n,t,c,ie,se))}function _computeKdfKey(n,t,c,ie,se){const ae=getPassword(t),ue=searchPath(n,"crypto/kdf");if(ue&&typeof ue=="string"){const de=function(ve,ge){return logger$9.throwArgumentError("invalid key-derivation function parameters",ve,ge)};if(ue.toLowerCase()==="scrypt"){const ve=looseArrayify(searchPath(n,"crypto/kdfparams/salt")),ge=parseInt(searchPath(n,"crypto/kdfparams/n")),we=parseInt(searchPath(n,"crypto/kdfparams/r")),Te=parseInt(searchPath(n,"crypto/kdfparams/p"));(!ge||!we||!Te)&&de("kdf",ue),ge&ge-1&&de("N",ge);const Ne=parseInt(searchPath(n,"crypto/kdfparams/dklen"));return Ne!==32&&de("dklen",Ne),ie(ae,ve,ge,we,Te,64,se)}else if(ue.toLowerCase()==="pbkdf2"){const ve=looseArrayify(searchPath(n,"crypto/kdfparams/salt"));let ge=null;const we=searchPath(n,"crypto/kdfparams/prf");we==="hmac-sha256"?ge="sha256":we==="hmac-sha512"?ge="sha512":de("prf",we);const Te=parseInt(searchPath(n,"crypto/kdfparams/c")),Ne=parseInt(searchPath(n,"crypto/kdfparams/dklen"));return Ne!==32&&de("dklen",Ne),c(ae,ve,Te,Ne,ge)}}return logger$9.throwArgumentError("unsupported key-derivation function","kdf",ue)}function decryptSync(n,t){const c=JSON.parse(n),ie=_computeKdfKey(c,t,pbkdf2Sync,scrypt.syncScrypt);return _getAccount(c,ie)}function decrypt(n,t,c){return __awaiter$g(this,void 0,void 0,function*(){const ie=JSON.parse(n),se=yield _computeKdfKey(ie,t,pbkdf2,scrypt.scrypt,c);return _getAccount(ie,se)})}function encrypt(n,t,c,ie){try{if(getAddress$1(n.address)!==computeAddress(n.privateKey))throw new Error("address/privateKey mismatch");if(hasMnemonic$1(n)){const Ge=n.mnemonic;if(HDNode.fromMnemonic(Ge.phrase,null,Ge.locale).derivePath(Ge.path||defaultPath).privateKey!=n.privateKey)throw new Error("mnemonic mismatch")}}catch(Ge){return Promise.reject(Ge)}typeof c=="function"&&!ie&&(ie=c,c={}),c||(c={});const se=arrayify(n.privateKey),ae=getPassword(t);let ue=null,de=null,ve=null;if(hasMnemonic$1(n)){const Ge=n.mnemonic;ue=arrayify(mnemonicToEntropy(Ge.phrase,Ge.locale||"en")),de=Ge.path||defaultPath,ve=Ge.locale||"en"}let ge=c.client;ge||(ge="ethers.js");let we=null;c.salt?we=arrayify(c.salt):we=randomBytes$1(32);let Te=null;if(c.iv){if(Te=arrayify(c.iv),Te.length!==16)throw new Error("invalid iv")}else Te=randomBytes$1(16);let Ne=null;if(c.uuid){if(Ne=arrayify(c.uuid),Ne.length!==16)throw new Error("invalid uuid")}else Ne=randomBytes$1(16);let qe=1<<17,ze=8,He=1;return c.scrypt&&(c.scrypt.N&&(qe=c.scrypt.N),c.scrypt.r&&(ze=c.scrypt.r),c.scrypt.p&&(He=c.scrypt.p)),scrypt.scrypt(ae,we,qe,ze,He,64,ie).then(Ge=>{Ge=arrayify(Ge);const Ze=Ge.slice(0,16),Ye=Ge.slice(16,32),Ft=Ge.slice(32,64),Mt=new aes$1.Counter(Te),Zt=new aes$1.ModeOfOperation.ctr(Ze,Mt),cn=arrayify(Zt.encrypt(se)),hn=keccak256$1(concat$1([Ye,cn])),yn={address:n.address.substring(2).toLowerCase(),id:uuidV4(Ne),version:3,crypto:{cipher:"aes-128-ctr",cipherparams:{iv:hexlify(Te).substring(2)},ciphertext:hexlify(cn).substring(2),kdf:"scrypt",kdfparams:{salt:hexlify(we).substring(2),n:qe,dklen:32,p:He,r:ze},mac:hn.substring(2)}};if(ue){const Ht=randomBytes$1(16),Sn=new aes$1.Counter(Ht),le=new aes$1.ModeOfOperation.ctr(Ft,Sn),pe=arrayify(le.encrypt(ue)),be=new Date,xe=be.getUTCFullYear()+"-"+zpad(be.getUTCMonth()+1,2)+"-"+zpad(be.getUTCDate(),2)+"T"+zpad(be.getUTCHours(),2)+"-"+zpad(be.getUTCMinutes(),2)+"-"+zpad(be.getUTCSeconds(),2)+".0Z";yn["x-ethers"]={client:ge,gethFilename:"UTC--"+xe+"--"+yn.address,mnemonicCounter:hexlify(Ht).substring(2),mnemonicCiphertext:hexlify(pe).substring(2),path:de,locale:ve,version:"0.1"}}return JSON.stringify(yn)})}function decryptJsonWallet(n,t,c){if(isCrowdsaleWallet(n)){c&&c(0);const ie=decrypt$1(n,t);return c&&c(1),Promise.resolve(ie)}return isKeystoreWallet(n)?decrypt(n,t,c):Promise.reject(new Error("invalid JSON wallet"))}function decryptJsonWalletSync(n,t){if(isCrowdsaleWallet(n))return decrypt$1(n,t);if(isKeystoreWallet(n))return decryptSync(n,t);throw new Error("invalid JSON wallet")}const lib_esm$4=Object.freeze(Object.defineProperty({__proto__:null,decryptCrowdsale:decrypt$1,decryptJsonWallet,decryptJsonWalletSync,decryptKeystore:decrypt,decryptKeystoreSync:decryptSync,encryptKeystore:encrypt,getJsonWalletAddress,isCrowdsaleWallet,isKeystoreWallet},Symbol.toStringTag,{value:"Module"})),version$b="wallet/5.8.0";var __awaiter$f=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$8=new Logger(version$b);function isAccount(n){return n!=null&&isHexString(n.privateKey,32)&&n.address!=null}function hasMnemonic(n){const t=n.mnemonic;return t&&t.phrase}class Wallet extends Signer{constructor(t,c){if(super(),isAccount(t)){const ie=new SigningKey(t.privateKey);if(defineReadOnly(this,"_signingKey",()=>ie),defineReadOnly(this,"address",computeAddress(this.publicKey)),this.address!==getAddress$1(t.address)&&logger$8.throwArgumentError("privateKey/address mismatch","privateKey","[REDACTED]"),hasMnemonic(t)){const se=t.mnemonic;defineReadOnly(this,"_mnemonic",()=>({phrase:se.phrase,path:se.path||defaultPath,locale:se.locale||"en"}));const ae=this.mnemonic,ue=HDNode.fromMnemonic(ae.phrase,null,ae.locale).derivePath(ae.path);computeAddress(ue.privateKey)!==this.address&&logger$8.throwArgumentError("mnemonic/address mismatch","privateKey","[REDACTED]")}else defineReadOnly(this,"_mnemonic",()=>null)}else{if(SigningKey.isSigningKey(t))t.curve!=="secp256k1"&&logger$8.throwArgumentError("unsupported curve; must be secp256k1","privateKey","[REDACTED]"),defineReadOnly(this,"_signingKey",()=>t);else{typeof t=="string"&&t.match(/^[0-9a-f]*$/i)&&t.length===64&&(t="0x"+t);const ie=new SigningKey(t);defineReadOnly(this,"_signingKey",()=>ie)}defineReadOnly(this,"_mnemonic",()=>null),defineReadOnly(this,"address",computeAddress(this.publicKey))}c&&!Provider.isProvider(c)&&logger$8.throwArgumentError("invalid provider","provider",c),defineReadOnly(this,"provider",c||null)}get mnemonic(){return this._mnemonic()}get privateKey(){return this._signingKey().privateKey}get publicKey(){return this._signingKey().publicKey}getAddress(){return Promise.resolve(this.address)}connect(t){return new Wallet(this,t)}signTransaction(t){return resolveProperties(t).then(c=>{c.from!=null&&(getAddress$1(c.from)!==this.address&&logger$8.throwArgumentError("transaction from address mismatch","transaction.from",t.from),delete c.from);const ie=this._signingKey().signDigest(keccak256$1(serialize$1$1(c)));return serialize$1$1(c,ie)})}signMessage(t){return __awaiter$f(this,void 0,void 0,function*(){return joinSignature(this._signingKey().signDigest(hashMessage(t)))})}_signTypedData(t,c,ie){return __awaiter$f(this,void 0,void 0,function*(){const se=yield TypedDataEncoder.resolveNames(t,c,ie,ae=>(this.provider==null&&logger$8.throwError("cannot resolve ENS names without a provider",Logger.errors.UNSUPPORTED_OPERATION,{operation:"resolveName",value:ae}),this.provider.resolveName(ae)));return joinSignature(this._signingKey().signDigest(TypedDataEncoder.hash(se.domain,c,se.value)))})}encrypt(t,c,ie){if(typeof c=="function"&&!ie&&(ie=c,c={}),ie&&typeof ie!="function")throw new Error("invalid callback");return c||(c={}),encrypt(this,t,c,ie)}static createRandom(t){let c=randomBytes$1(16);t||(t={}),t.extraEntropy&&(c=arrayify(hexDataSlice(keccak256$1(concat$1([c,t.extraEntropy])),0,16)));const ie=entropyToMnemonic(c,t.locale);return Wallet.fromMnemonic(ie,t.path,t.locale)}static fromEncryptedJson(t,c,ie){return decryptJsonWallet(t,c,ie).then(se=>new Wallet(se))}static fromEncryptedJsonSync(t,c){return new Wallet(decryptJsonWalletSync(t,c))}static fromMnemonic(t,c,ie){return c||(c=defaultPath),new Wallet(HDNode.fromMnemonic(t,null,ie).derivePath(c))}}function verifyMessage(n,t){return recoverAddress(hashMessage(n),t)}function verifyTypedData(n,t,c,ie){return recoverAddress(TypedDataEncoder.hash(n,t,c),ie)}const lib_esm$3=Object.freeze(Object.defineProperty({__proto__:null,Wallet,verifyMessage,verifyTypedData},Symbol.toStringTag,{value:"Module"})),version$a="networks/5.8.0",logger$7=new Logger(version$a);function isRenetworkable(n){return n&&typeof n.renetwork=="function"}function ethDefaultProvider(n){const t=function(c,ie){ie==null&&(ie={});const se=[];if(c.InfuraProvider&&ie.infura!=="-")try{se.push(new c.InfuraProvider(n,ie.infura))}catch{}if(c.EtherscanProvider&&ie.etherscan!=="-")try{se.push(new c.EtherscanProvider(n,ie.etherscan))}catch{}if(c.AlchemyProvider&&ie.alchemy!=="-")try{se.push(new c.AlchemyProvider(n,ie.alchemy))}catch{}if(c.PocketProvider&&ie.pocket!=="-"){const ae=["goerli","ropsten","rinkeby","sepolia"];try{const ue=new c.PocketProvider(n,ie.pocket);ue.network&&ae.indexOf(ue.network.name)===-1&&se.push(ue)}catch{}}if(c.CloudflareProvider&&ie.cloudflare!=="-")try{se.push(new c.CloudflareProvider(n))}catch{}if(c.AnkrProvider&&ie.ankr!=="-")try{const ae=["ropsten"],ue=new c.AnkrProvider(n,ie.ankr);ue.network&&ae.indexOf(ue.network.name)===-1&&se.push(ue)}catch{}if(c.QuickNodeProvider&&ie.quicknode!=="-")try{se.push(new c.QuickNodeProvider(n,ie.quicknode))}catch{}if(se.length===0)return null;if(c.FallbackProvider){let ae=1;return ie.quorum!=null?ae=ie.quorum:n==="homestead"&&(ae=2),new c.FallbackProvider(se,ae)}return se[0]};return t.renetwork=function(c){return ethDefaultProvider(c)},t}function etcDefaultProvider(n,t){const c=function(ie,se){return ie.JsonRpcProvider?new ie.JsonRpcProvider(n,t):null};return c.renetwork=function(ie){return etcDefaultProvider(n,ie)},c}const homestead={chainId:1,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"homestead",_defaultProvider:ethDefaultProvider("homestead")},ropsten={chainId:3,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"ropsten",_defaultProvider:ethDefaultProvider("ropsten")},classicMordor={chainId:63,name:"classicMordor",_defaultProvider:etcDefaultProvider("https://www.ethercluster.com/mordor","classicMordor")},networks$2={unspecified:{chainId:0,name:"unspecified"},homestead,mainnet:homestead,morden:{chainId:2,name:"morden"},ropsten,testnet:ropsten,rinkeby:{chainId:4,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"rinkeby",_defaultProvider:ethDefaultProvider("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:ethDefaultProvider("kovan")},goerli:{chainId:5,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"goerli",_defaultProvider:ethDefaultProvider("goerli")},kintsugi:{chainId:1337702,name:"kintsugi"},sepolia:{chainId:11155111,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"sepolia",_defaultProvider:ethDefaultProvider("sepolia")},holesky:{chainId:17e3,name:"holesky",_defaultProvider:ethDefaultProvider("holesky")},classic:{chainId:61,name:"classic",_defaultProvider:etcDefaultProvider("https://www.ethercluster.com/etc","classic")},classicMorden:{chainId:62,name:"classicMorden"},classicMordor,classicTestnet:classicMordor,classicKotti:{chainId:6,name:"classicKotti",_defaultProvider:etcDefaultProvider("https://www.ethercluster.com/kotti","classicKotti")},xdai:{chainId:100,name:"xdai"},matic:{chainId:137,name:"matic",_defaultProvider:ethDefaultProvider("matic")},maticmum:{chainId:80001,name:"maticmum",_defaultProvider:ethDefaultProvider("maticmum")},optimism:{chainId:10,name:"optimism",_defaultProvider:ethDefaultProvider("optimism")},"optimism-kovan":{chainId:69,name:"optimism-kovan"},"optimism-goerli":{chainId:420,name:"optimism-goerli"},"optimism-sepolia":{chainId:11155420,name:"optimism-sepolia"},arbitrum:{chainId:42161,name:"arbitrum"},"arbitrum-rinkeby":{chainId:421611,name:"arbitrum-rinkeby"},"arbitrum-goerli":{chainId:421613,name:"arbitrum-goerli"},"arbitrum-sepolia":{chainId:421614,name:"arbitrum-sepolia"},bnb:{chainId:56,name:"bnb"},bnbt:{chainId:97,name:"bnbt"}};function getNetwork(n){if(n==null)return null;if(typeof n=="number"){for(const ie in networks$2){const se=networks$2[ie];if(se.chainId===n)return{name:se.name,chainId:se.chainId,ensAddress:se.ensAddress||null,_defaultProvider:se._defaultProvider||null}}return{chainId:n,name:"unknown"}}if(typeof n=="string"){const ie=networks$2[n];return ie==null?null:{name:ie.name,chainId:ie.chainId,ensAddress:ie.ensAddress,_defaultProvider:ie._defaultProvider||null}}const t=networks$2[n.name];if(!t)return typeof n.chainId!="number"&&logger$7.throwArgumentError("invalid network chainId","network",n),n;n.chainId!==0&&n.chainId!==t.chainId&&logger$7.throwArgumentError("network chainId mismatch","network",n);let c=n._defaultProvider||null;return c==null&&t._defaultProvider&&(isRenetworkable(t._defaultProvider)?c=t._defaultProvider.renetwork(n):c=t._defaultProvider),{name:n.name,chainId:t.chainId,ensAddress:n.ensAddress||t.ensAddress||null,_defaultProvider:c}}const version$9="web/5.8.0";var __awaiter$e=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};function getUrl(n,t){return __awaiter$e(this,void 0,void 0,function*(){t==null&&(t={});const c={method:t.method||"GET",headers:t.headers||{},body:t.body||void 0};if(t.skipFetchSetup!==!0&&(c.mode="cors",c.cache="no-cache",c.credentials="same-origin",c.redirect="follow",c.referrer="client"),t.fetchOptions!=null){const ue=t.fetchOptions;ue.mode&&(c.mode=ue.mode),ue.cache&&(c.cache=ue.cache),ue.credentials&&(c.credentials=ue.credentials),ue.redirect&&(c.redirect=ue.redirect),ue.referrer&&(c.referrer=ue.referrer)}const ie=yield fetch(n,c),se=yield ie.arrayBuffer(),ae={};return ie.headers.forEach?ie.headers.forEach((ue,de)=>{ae[de.toLowerCase()]=ue}):ie.headers.keys().forEach(ue=>{ae[ue.toLowerCase()]=ie.headers.get(ue)}),{headers:ae,statusCode:ie.status,statusMessage:ie.statusText,body:arrayify(new Uint8Array(se))}})}var __awaiter$d=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$6=new Logger(version$9);function staller(n){return new Promise(t=>{setTimeout(t,n)})}function bodyify(n,t){if(n==null)return null;if(typeof n=="string")return n;if(isBytesLike(n)){if(t&&(t.split("/")[0]==="text"||t.split(";")[0].trim()==="application/json"))try{return toUtf8String(n)}catch{}return hexlify(n)}return n}function unpercent(n){return toUtf8Bytes(n.replace(/%([0-9a-f][0-9a-f])/gi,(t,c)=>String.fromCharCode(parseInt(c,16))))}function _fetchData(n,t,c){const ie=typeof n=="object"&&n.throttleLimit!=null?n.throttleLimit:12;logger$6.assertArgument(ie>0&&ie%1===0,"invalid connection throttle limit","connection.throttleLimit",ie);const se=typeof n=="object"?n.throttleCallback:null,ae=typeof n=="object"&&typeof n.throttleSlotInterval=="number"?n.throttleSlotInterval:100;logger$6.assertArgument(ae>0&&ae%1===0,"invalid connection throttle slot interval","connection.throttleSlotInterval",ae);const ue=typeof n=="object"?!!n.errorPassThrough:!1,de={};let ve=null;const ge={method:"GET"};let we=!1,Te=120*1e3;if(typeof n=="string")ve=n;else if(typeof n=="object"){if((n==null||n.url==null)&&logger$6.throwArgumentError("missing URL","connection.url",n),ve=n.url,typeof n.timeout=="number"&&n.timeout>0&&(Te=n.timeout),n.headers)for(const Ze in n.headers)de[Ze.toLowerCase()]={key:Ze,value:String(n.headers[Ze])},["if-none-match","if-modified-since"].indexOf(Ze.toLowerCase())>=0&&(we=!0);if(ge.allowGzip=!!n.allowGzip,n.user!=null&&n.password!=null){ve.substring(0,6)!=="https:"&&n.allowInsecureAuthentication!==!0&&logger$6.throwError("basic authentication requires a secure https url",Logger.errors.INVALID_ARGUMENT,{argument:"url",url:ve,user:n.user,password:"[REDACTED]"});const Ze=n.user+":"+n.password;de.authorization={key:"Authorization",value:"Basic "+encode$5(toUtf8Bytes(Ze))}}n.skipFetchSetup!=null&&(ge.skipFetchSetup=!!n.skipFetchSetup),n.fetchOptions!=null&&(ge.fetchOptions=shallowCopy(n.fetchOptions))}const Ne=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),qe=ve?ve.match(Ne):null;if(qe)try{const Ze={statusCode:200,statusMessage:"OK",headers:{"content-type":qe[1]||"text/plain"},body:qe[2]?decode$6(qe[3]):unpercent(qe[3])};let Ye=Ze.body;return c&&(Ye=c(Ze.body,Ze)),Promise.resolve(Ye)}catch(Ze){logger$6.throwError("processing response error",Logger.errors.SERVER_ERROR,{body:bodyify(qe[1],qe[2]),error:Ze,requestBody:null,requestMethod:"GET",url:ve})}t&&(ge.method="POST",ge.body=t,de["content-type"]==null&&(de["content-type"]={key:"Content-Type",value:"application/octet-stream"}),de["content-length"]==null&&(de["content-length"]={key:"Content-Length",value:String(t.length)}));const ze={};Object.keys(de).forEach(Ze=>{const Ye=de[Ze];ze[Ye.key]=Ye.value}),ge.headers=ze;const He=(function(){let Ze=null;return{promise:new Promise(function(Ye,Ft){Te&&(Ze=setTimeout(()=>{Ze!=null&&(Ze=null,Ft(logger$6.makeError("timeout",Logger.errors.TIMEOUT,{requestBody:bodyify(ge.body,ze["content-type"]),requestMethod:ge.method,timeout:Te,url:ve})))},Te))}),cancel:function(){Ze!=null&&(clearTimeout(Ze),Ze=null)}}})(),Ge=(function(){return __awaiter$d(this,void 0,void 0,function*(){for(let Ze=0;Ze<ie;Ze++){let Ye=null;try{if(Ye=yield getUrl(ve,ge),Ze<ie){if(Ye.statusCode===301||Ye.statusCode===302){const Mt=Ye.headers.location||"";if(ge.method==="GET"&&Mt.match(/^https:/)){ve=Ye.headers.location;continue}}else if(Ye.statusCode===429){let Mt=!0;if(se&&(Mt=yield se(Ze,ve)),Mt){let Zt=0;const cn=Ye.headers["retry-after"];typeof cn=="string"&&cn.match(/^[1-9][0-9]*$/)?Zt=parseInt(cn)*1e3:Zt=ae*parseInt(String(Math.random()*Math.pow(2,Ze))),yield staller(Zt);continue}}}}catch(Mt){Ye=Mt.response,Ye==null&&(He.cancel(),logger$6.throwError("missing response",Logger.errors.SERVER_ERROR,{requestBody:bodyify(ge.body,ze["content-type"]),requestMethod:ge.method,serverError:Mt,url:ve}))}let Ft=Ye.body;if(we&&Ye.statusCode===304?Ft=null:!ue&&(Ye.statusCode<200||Ye.statusCode>=300)&&(He.cancel(),logger$6.throwError("bad response",Logger.errors.SERVER_ERROR,{status:Ye.statusCode,headers:Ye.headers,body:bodyify(Ft,Ye.headers?Ye.headers["content-type"]:null),requestBody:bodyify(ge.body,ze["content-type"]),requestMethod:ge.method,url:ve})),c)try{const Mt=yield c(Ft,Ye);return He.cancel(),Mt}catch(Mt){if(Mt.throttleRetry&&Ze<ie){let Zt=!0;if(se&&(Zt=yield se(Ze,ve)),Zt){const cn=ae*parseInt(String(Math.random()*Math.pow(2,Ze)));yield staller(cn);continue}}He.cancel(),logger$6.throwError("processing response error",Logger.errors.SERVER_ERROR,{body:bodyify(Ft,Ye.headers?Ye.headers["content-type"]:null),error:Mt,requestBody:bodyify(ge.body,ze["content-type"]),requestMethod:ge.method,url:ve})}return He.cancel(),Ft}return logger$6.throwError("failed response",Logger.errors.SERVER_ERROR,{requestBody:bodyify(ge.body,ze["content-type"]),requestMethod:ge.method,url:ve})})})();return Promise.race([He.promise,Ge])}function fetchJson(n,t,c){let ie=(ae,ue)=>{let de=null;if(ae!=null)try{de=JSON.parse(toUtf8String(ae))}catch(ve){logger$6.throwError("invalid JSON",Logger.errors.SERVER_ERROR,{body:ae,error:ve})}return c&&(de=c(de,ue)),de},se=null;if(t!=null){se=toUtf8Bytes(t);const ae=typeof n=="string"?{url:n}:shallowCopy(n);ae.headers?Object.keys(ae.headers).filter(ue=>ue.toLowerCase()==="content-type").length!==0||(ae.headers=shallowCopy(ae.headers),ae.headers["content-type"]="application/json"):ae.headers={"content-type":"application/json"},n=ae}return _fetchData(n,se,ie)}function poll(n,t){return t||(t={}),t=shallowCopy(t),t.floor==null&&(t.floor=0),t.ceiling==null&&(t.ceiling=1e4),t.interval==null&&(t.interval=250),new Promise(function(c,ie){let se=null,ae=!1;const ue=()=>ae?!1:(ae=!0,se&&clearTimeout(se),!0);t.timeout&&(se=setTimeout(()=>{ue()&&ie(new Error("timeout"))},t.timeout));const de=t.retryLimit;let ve=0;function ge(){return n().then(function(we){if(we!==void 0)ue()&&c(we);else if(t.oncePoll)t.oncePoll.once("poll",ge);else if(t.onceBlock)t.onceBlock.once("block",ge);else if(!ae){if(ve++,ve>de){ue()&&ie(new Error("retry limit reached"));return}let Te=t.interval*parseInt(String(Math.random()*Math.pow(2,ve)));Te<t.floor&&(Te=t.floor),Te>t.ceiling&&(Te=t.ceiling),setTimeout(ge,Te)}return null},function(we){ue()&&ie(we)})}ge()})}const lib_esm$2=Object.freeze(Object.defineProperty({__proto__:null,_fetchData,fetchJson,poll},Symbol.toStringTag,{value:"Module"}));var ALPHABET$2="qpzry9x8gf2tvdw0s3jn54khce6mua7l",ALPHABET_MAP$1={};for(var z$3=0;z$3<ALPHABET$2.length;z$3++){var x$2=ALPHABET$2.charAt(z$3);if(ALPHABET_MAP$1[x$2]!==void 0)throw new TypeError(x$2+" is ambiguous");ALPHABET_MAP$1[x$2]=z$3}function polymodStep$1(n){var t=n>>25;return(n&33554431)<<5^-(t>>0&1)&996825010^-(t>>1&1)&642813549^-(t>>2&1)&513874426^-(t>>3&1)&1027748829^-(t>>4&1)&705979059}function prefixChk$1(n){for(var t=1,c=0;c<n.length;++c){var ie=n.charCodeAt(c);if(ie<33||ie>126)return"Invalid prefix ("+n+")";t=polymodStep$1(t)^ie>>5}for(t=polymodStep$1(t),c=0;c<n.length;++c){var se=n.charCodeAt(c);t=polymodStep$1(t)^se&31}return t}function encode$4(n,t,c){if(c=c||90,n.length+7+t.length>c)throw new TypeError("Exceeds length limit");n=n.toLowerCase();var ie=prefixChk$1(n);if(typeof ie=="string")throw new Error(ie);for(var se=n+"1",ae=0;ae<t.length;++ae){var ue=t[ae];if(ue>>5)throw new Error("Non 5-bit word");ie=polymodStep$1(ie)^ue,se+=ALPHABET$2.charAt(ue)}for(ae=0;ae<6;++ae)ie=polymodStep$1(ie);for(ie^=1,ae=0;ae<6;++ae){var de=ie>>(5-ae)*5&31;se+=ALPHABET$2.charAt(de)}return se}function __decode(n,t){if(t=t||90,n.length<8)return n+" too short";if(n.length>t)return"Exceeds length limit";var c=n.toLowerCase(),ie=n.toUpperCase();if(n!==c&&n!==ie)return"Mixed-case string "+n;n=c;var se=n.lastIndexOf("1");if(se===-1)return"No separator character for "+n;if(se===0)return"Missing prefix for "+n;var ae=n.slice(0,se),ue=n.slice(se+1);if(ue.length<6)return"Data too short";var de=prefixChk$1(ae);if(typeof de=="string")return de;for(var ve=[],ge=0;ge<ue.length;++ge){var we=ue.charAt(ge),Te=ALPHABET_MAP$1[we];if(Te===void 0)return"Unknown character "+we;de=polymodStep$1(de)^Te,!(ge+6>=ue.length)&&ve.push(Te)}return de!==1?"Invalid checksum for "+n:{prefix:ae,words:ve}}function decodeUnsafe(){var n=__decode.apply(null,arguments);if(typeof n=="object")return n}function decode$5(n){var t=__decode.apply(null,arguments);if(typeof t=="object")return t;throw new Error(t)}function convert$1(n,t,c,ie){for(var se=0,ae=0,ue=(1<<c)-1,de=[],ve=0;ve<n.length;++ve)for(se=se<<t|n[ve],ae+=t;ae>=c;)ae-=c,de.push(se>>ae&ue);if(ie)ae>0&&de.push(se<<c-ae&ue);else{if(ae>=t)return"Excess padding";if(se<<c-ae&ue)return"Non-zero padding"}return de}function toWordsUnsafe(n){var t=convert$1(n,8,5,!0);if(Array.isArray(t))return t}function toWords$1(n){var t=convert$1(n,8,5,!0);if(Array.isArray(t))return t;throw new Error(t)}function fromWordsUnsafe$1(n){var t=convert$1(n,5,8,!1);if(Array.isArray(t))return t}function fromWords$1(n){var t=convert$1(n,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}var bech32$1={decodeUnsafe,decode:decode$5,encode:encode$4,toWordsUnsafe,toWords:toWords$1,fromWordsUnsafe:fromWordsUnsafe$1,fromWords:fromWords$1};const bech32$2=getDefaultExportFromCjs$2(bech32$1),version$8="providers/5.8.0",logger$5=new Logger(version$8);class Formatter{constructor(){this.formats=this.getDefaultFormats()}getDefaultFormats(){const t={},c=this.address.bind(this),ie=this.bigNumber.bind(this),se=this.blockTag.bind(this),ae=this.data.bind(this),ue=this.hash.bind(this),de=this.hex.bind(this),ve=this.number.bind(this),ge=this.type.bind(this),we=Te=>this.data(Te,!0);return t.transaction={hash:ue,type:ge,accessList:Formatter.allowNull(this.accessList.bind(this),null),blockHash:Formatter.allowNull(ue,null),blockNumber:Formatter.allowNull(ve,null),transactionIndex:Formatter.allowNull(ve,null),confirmations:Formatter.allowNull(ve,null),from:c,gasPrice:Formatter.allowNull(ie),maxPriorityFeePerGas:Formatter.allowNull(ie),maxFeePerGas:Formatter.allowNull(ie),gasLimit:ie,to:Formatter.allowNull(c,null),value:ie,nonce:ve,data:ae,r:Formatter.allowNull(this.uint256),s:Formatter.allowNull(this.uint256),v:Formatter.allowNull(ve),creates:Formatter.allowNull(c,null),raw:Formatter.allowNull(ae)},t.transactionRequest={from:Formatter.allowNull(c),nonce:Formatter.allowNull(ve),gasLimit:Formatter.allowNull(ie),gasPrice:Formatter.allowNull(ie),maxPriorityFeePerGas:Formatter.allowNull(ie),maxFeePerGas:Formatter.allowNull(ie),to:Formatter.allowNull(c),value:Formatter.allowNull(ie),data:Formatter.allowNull(we),type:Formatter.allowNull(ve),accessList:Formatter.allowNull(this.accessList.bind(this),null)},t.receiptLog={transactionIndex:ve,blockNumber:ve,transactionHash:ue,address:c,topics:Formatter.arrayOf(ue),data:ae,logIndex:ve,blockHash:ue},t.receipt={to:Formatter.allowNull(this.address,null),from:Formatter.allowNull(this.address,null),contractAddress:Formatter.allowNull(c,null),transactionIndex:ve,root:Formatter.allowNull(de),gasUsed:ie,logsBloom:Formatter.allowNull(ae),blockHash:ue,transactionHash:ue,logs:Formatter.arrayOf(this.receiptLog.bind(this)),blockNumber:ve,confirmations:Formatter.allowNull(ve,null),cumulativeGasUsed:ie,effectiveGasPrice:Formatter.allowNull(ie),status:Formatter.allowNull(ve),type:ge},t.block={hash:Formatter.allowNull(ue),parentHash:ue,number:ve,timestamp:ve,nonce:Formatter.allowNull(de),difficulty:this.difficulty.bind(this),gasLimit:ie,gasUsed:ie,miner:Formatter.allowNull(c),extraData:ae,transactions:Formatter.allowNull(Formatter.arrayOf(ue)),baseFeePerGas:Formatter.allowNull(ie)},t.blockWithTransactions=shallowCopy(t.block),t.blockWithTransactions.transactions=Formatter.allowNull(Formatter.arrayOf(this.transactionResponse.bind(this))),t.filter={fromBlock:Formatter.allowNull(se,void 0),toBlock:Formatter.allowNull(se,void 0),blockHash:Formatter.allowNull(ue,void 0),address:Formatter.allowNull(c,void 0),topics:Formatter.allowNull(this.topics.bind(this),void 0)},t.filterLog={blockNumber:Formatter.allowNull(ve),blockHash:Formatter.allowNull(ue),transactionIndex:ve,removed:Formatter.allowNull(this.boolean.bind(this)),address:c,data:Formatter.allowFalsish(ae,"0x"),topics:Formatter.arrayOf(ue),transactionHash:ue,logIndex:ve},t}accessList(t){return accessListify(t||[])}number(t){return t==="0x"?0:BigNumber.from(t).toNumber()}type(t){return t==="0x"||t==null?0:BigNumber.from(t).toNumber()}bigNumber(t){return BigNumber.from(t)}boolean(t){if(typeof t=="boolean")return t;if(typeof t=="string"){if(t=t.toLowerCase(),t==="true")return!0;if(t==="false")return!1}throw new Error("invalid boolean - "+t)}hex(t,c){return typeof t=="string"&&(!c&&t.substring(0,2)!=="0x"&&(t="0x"+t),isHexString(t))?t.toLowerCase():logger$5.throwArgumentError("invalid hash","value",t)}data(t,c){const ie=this.hex(t,c);if(ie.length%2!==0)throw new Error("invalid data; odd-length - "+t);return ie}address(t){return getAddress$1(t)}callAddress(t){if(!isHexString(t,32))return null;const c=getAddress$1(hexDataSlice(t,12));return c===AddressZero?null:c}contractAddress(t){return getContractAddress(t)}blockTag(t){if(t==null)return"latest";if(t==="earliest")return"0x0";switch(t){case"earliest":return"0x0";case"latest":case"pending":case"safe":case"finalized":return t}if(typeof t=="number"||isHexString(t))return hexValue(t);throw new Error("invalid blockTag")}hash(t,c){const ie=this.hex(t,c);return hexDataLength(ie)!==32?logger$5.throwArgumentError("invalid hash","value",t):ie}difficulty(t){if(t==null)return null;const c=BigNumber.from(t);try{return c.toNumber()}catch{}return null}uint256(t){if(!isHexString(t))throw new Error("invalid uint256");return hexZeroPad(t,32)}_block(t,c){t.author!=null&&t.miner==null&&(t.miner=t.author);const ie=t._difficulty!=null?t._difficulty:t.difficulty,se=Formatter.check(c,t);return se._difficulty=ie==null?null:BigNumber.from(ie),se}block(t){return this._block(t,this.formats.block)}blockWithTransactions(t){return this._block(t,this.formats.blockWithTransactions)}transactionRequest(t){return Formatter.check(this.formats.transactionRequest,t)}transactionResponse(t){t.gas!=null&&t.gasLimit==null&&(t.gasLimit=t.gas),t.to&&BigNumber.from(t.to).isZero()&&(t.to="0x0000000000000000000000000000000000000000"),t.input!=null&&t.data==null&&(t.data=t.input),t.to==null&&t.creates==null&&(t.creates=this.contractAddress(t)),(t.type===1||t.type===2)&&t.accessList==null&&(t.accessList=[]);const c=Formatter.check(this.formats.transaction,t);if(t.chainId!=null){let ie=t.chainId;isHexString(ie)&&(ie=BigNumber.from(ie).toNumber()),c.chainId=ie}else{let ie=t.networkId;ie==null&&c.v==null&&(ie=t.chainId),isHexString(ie)&&(ie=BigNumber.from(ie).toNumber()),typeof ie!="number"&&c.v!=null&&(ie=(c.v-35)/2,ie<0&&(ie=0),ie=parseInt(ie)),typeof ie!="number"&&(ie=0),c.chainId=ie}return c.blockHash&&c.blockHash.replace(/0/g,"")==="x"&&(c.blockHash=null),c}transaction(t){return parse$2(t)}receiptLog(t){return Formatter.check(this.formats.receiptLog,t)}receipt(t){const c=Formatter.check(this.formats.receipt,t);if(c.root!=null)if(c.root.length<=4){const ie=BigNumber.from(c.root).toNumber();ie===0||ie===1?(c.status!=null&&c.status!==ie&&logger$5.throwArgumentError("alt-root-status/status mismatch","value",{root:c.root,status:c.status}),c.status=ie,delete c.root):logger$5.throwArgumentError("invalid alt-root-status","value.root",c.root)}else c.root.length!==66&&logger$5.throwArgumentError("invalid root hash","value.root",c.root);return c.status!=null&&(c.byzantium=!0),c}topics(t){return Array.isArray(t)?t.map(c=>this.topics(c)):t!=null?this.hash(t,!0):null}filter(t){return Formatter.check(this.formats.filter,t)}filterLog(t){return Formatter.check(this.formats.filterLog,t)}static check(t,c){const ie={};for(const se in t)try{const ae=t[se](c[se]);ae!==void 0&&(ie[se]=ae)}catch(ae){throw ae.checkKey=se,ae.checkValue=c[se],ae}return ie}static allowNull(t,c){return function(ie){return ie==null?c:t(ie)}}static allowFalsish(t,c){return function(ie){return ie?t(ie):c}}static arrayOf(t){return function(c){if(!Array.isArray(c))throw new Error("not an array");const ie=[];return c.forEach(function(se){ie.push(t(se))}),ie}}}var __awaiter$c=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$4=new Logger(version$8),MAX_CCIP_REDIRECTS=10;function checkTopic(n){return n==null?"null":(hexDataLength(n)!==32&&logger$4.throwArgumentError("invalid topic","topic",n),n.toLowerCase())}function serializeTopics(n){for(n=n.slice();n.length>0&&n[n.length-1]==null;)n.pop();return n.map(t=>{if(Array.isArray(t)){const c={};t.forEach(se=>{c[checkTopic(se)]=!0});const ie=Object.keys(c);return ie.sort(),ie.join("|")}else return checkTopic(t)}).join("&")}function deserializeTopics(n){return n===""?[]:n.split(/&/g).map(t=>{if(t==="")return[];const c=t.split("|").map(ie=>ie==="null"?null:ie);return c.length===1?c[0]:c})}function getEventTag(n){if(typeof n=="string"){if(n=n.toLowerCase(),hexDataLength(n)===32)return"tx:"+n;if(n.indexOf(":")===-1)return n}else{if(Array.isArray(n))return"filter:*:"+serializeTopics(n);if(ForkEvent.isForkEvent(n))throw logger$4.warn("not implemented"),new Error("not implemented");if(n&&typeof n=="object")return"filter:"+(n.address||"*")+":"+serializeTopics(n.topics||[])}throw new Error("invalid event - "+n)}function getTime(){return new Date().getTime()}function stall(n){return new Promise(t=>{setTimeout(t,n)})}const PollableEvents=["block","network","pending","poll"];let Event$1=class{constructor(n,t,c){defineReadOnly(this,"tag",n),defineReadOnly(this,"listener",t),defineReadOnly(this,"once",c),this._lastBlockNumber=-2,this._inflight=!1}get event(){switch(this.type){case"tx":return this.hash;case"filter":return this.filter}return this.tag}get type(){return this.tag.split(":")[0]}get hash(){const n=this.tag.split(":");return n[0]!=="tx"?null:n[1]}get filter(){const n=this.tag.split(":");if(n[0]!=="filter")return null;const t=n[1],c=deserializeTopics(n[2]),ie={};return c.length>0&&(ie.topics=c),t&&t!=="*"&&(ie.address=t),ie}pollable(){return this.tag.indexOf(":")>=0||PollableEvents.indexOf(this.tag)>=0}};const coinInfos={0:{symbol:"btc",p2pkh:0,p2sh:5,prefix:"bc"},2:{symbol:"ltc",p2pkh:48,p2sh:50,prefix:"ltc"},3:{symbol:"doge",p2pkh:30,p2sh:22},60:{symbol:"eth",ilk:"eth"},61:{symbol:"etc",ilk:"eth"},700:{symbol:"xdai",ilk:"eth"}};function bytes32ify(n){return hexZeroPad(BigNumber.from(n).toHexString(),32)}function base58Encode(n){return Base58.encode(concat$1([n,hexDataSlice(sha256$7(sha256$7(n)),0,4)]))}const matcherIpfs=new RegExp("^(ipfs)://(.*)$","i"),matchers=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),matcherIpfs,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];function _parseString(n,t){try{return toUtf8String(_parseBytes(n,t))}catch{}return null}function _parseBytes(n,t){if(n==="0x")return null;const c=BigNumber.from(hexDataSlice(n,t,t+32)).toNumber(),ie=BigNumber.from(hexDataSlice(n,c,c+32)).toNumber();return hexDataSlice(n,c+32,c+32+ie)}function getIpfsLink(n){return n.match(/^ipfs:\/\/ipfs\//i)?n=n.substring(12):n.match(/^ipfs:\/\//i)?n=n.substring(7):logger$4.throwArgumentError("unsupported IPFS format","link",n),`https://gateway.ipfs.io/ipfs/${n}`}function numPad(n){const t=arrayify(n);if(t.length>32)throw new Error("internal; should not happen");const c=new Uint8Array(32);return c.set(t,32-t.length),c}function bytesPad(n){if(n.length%32===0)return n;const t=new Uint8Array(Math.ceil(n.length/32)*32);return t.set(n),t}function encodeBytes(n){const t=[];let c=0;for(let ie=0;ie<n.length;ie++)t.push(null),c+=32;for(let ie=0;ie<n.length;ie++){const se=arrayify(n[ie]);t[ie]=numPad(c),t.push(numPad(se.length)),t.push(bytesPad(se)),c+=32+Math.ceil(se.length/32)*32}return hexConcat(t)}class Resolver{constructor(t,c,ie,se){defineReadOnly(this,"provider",t),defineReadOnly(this,"name",ie),defineReadOnly(this,"address",t.formatter.address(c)),defineReadOnly(this,"_resolvedAddress",se)}supportsWildcard(){return this._supportsEip2544||(this._supportsEip2544=this.provider.call({to:this.address,data:"0x01ffc9a79061b92300000000000000000000000000000000000000000000000000000000"}).then(t=>BigNumber.from(t).eq(1)).catch(t=>{if(t.code===Logger.errors.CALL_EXCEPTION)return!1;throw this._supportsEip2544=null,t})),this._supportsEip2544}_fetch(t,c){return __awaiter$c(this,void 0,void 0,function*(){const ie={to:this.address,ccipReadEnabled:!0,data:hexConcat([t,namehash$1(this.name),c||"0x"])};let se=!1;(yield this.supportsWildcard())&&(se=!0,ie.data=hexConcat(["0x9061b923",encodeBytes([dnsEncode(this.name),ie.data])]));try{let ae=yield this.provider.call(ie);return arrayify(ae).length%32===4&&logger$4.throwError("resolver threw error",Logger.errors.CALL_EXCEPTION,{transaction:ie,data:ae}),se&&(ae=_parseBytes(ae,0)),ae}catch(ae){if(ae.code===Logger.errors.CALL_EXCEPTION)return null;throw ae}})}_fetchBytes(t,c){return __awaiter$c(this,void 0,void 0,function*(){const ie=yield this._fetch(t,c);return ie!=null?_parseBytes(ie,0):null})}_getAddress(t,c){const ie=coinInfos[String(t)];if(ie==null&&logger$4.throwError(`unsupported coin type: ${t}`,Logger.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${t})`}),ie.ilk==="eth")return this.provider.formatter.address(c);const se=arrayify(c);if(ie.p2pkh!=null){const ae=c.match(/^0x76a9([0-9a-f][0-9a-f])([0-9a-f]*)88ac$/);if(ae){const ue=parseInt(ae[1],16);if(ae[2].length===ue*2&&ue>=1&&ue<=75)return base58Encode(concat$1([[ie.p2pkh],"0x"+ae[2]]))}}if(ie.p2sh!=null){const ae=c.match(/^0xa9([0-9a-f][0-9a-f])([0-9a-f]*)87$/);if(ae){const ue=parseInt(ae[1],16);if(ae[2].length===ue*2&&ue>=1&&ue<=75)return base58Encode(concat$1([[ie.p2sh],"0x"+ae[2]]))}}if(ie.prefix!=null){const ae=se[1];let ue=se[0];if(ue===0?ae!==20&&ae!==32&&(ue=-1):ue=-1,ue>=0&&se.length===2+ae&&ae>=1&&ae<=75){const de=bech32$2.toWords(se.slice(2));return de.unshift(ue),bech32$2.encode(ie.prefix,de)}}return null}getAddress(t){return __awaiter$c(this,void 0,void 0,function*(){if(t==null&&(t=60),t===60)try{const se=yield this._fetch("0x3b3b57de");return se==="0x"||se===HashZero?null:this.provider.formatter.callAddress(se)}catch(se){if(se.code===Logger.errors.CALL_EXCEPTION)return null;throw se}const c=yield this._fetchBytes("0xf1cb7e06",bytes32ify(t));if(c==null||c==="0x")return null;const ie=this._getAddress(t,c);return ie==null&&logger$4.throwError("invalid or unsupported coin data",Logger.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${t})`,coinType:t,data:c}),ie})}getAvatar(){return __awaiter$c(this,void 0,void 0,function*(){const t=[{type:"name",content:this.name}];try{const c=yield this.getText("avatar");if(c==null)return null;for(let ie=0;ie<matchers.length;ie++){const se=c.match(matchers[ie]);if(se==null)continue;const ae=se[1].toLowerCase();switch(ae){case"https":return t.push({type:"url",content:c}),{linkage:t,url:c};case"data":return t.push({type:"data",content:c}),{linkage:t,url:c};case"ipfs":return t.push({type:"ipfs",content:c}),{linkage:t,url:getIpfsLink(c)};case"erc721":case"erc1155":{const ue=ae==="erc721"?"0xc87b56dd":"0x0e89341c";t.push({type:ae,content:c});const de=this._resolvedAddress||(yield this.getAddress()),ve=(se[2]||"").split("/");if(ve.length!==2)return null;const ge=yield this.provider.formatter.address(ve[0]),we=hexZeroPad(BigNumber.from(ve[1]).toHexString(),32);if(ae==="erc721"){const He=this.provider.formatter.callAddress(yield this.provider.call({to:ge,data:hexConcat(["0x6352211e",we])}));if(de!==He)return null;t.push({type:"owner",content:He})}else if(ae==="erc1155"){const He=BigNumber.from(yield this.provider.call({to:ge,data:hexConcat(["0x00fdd58e",hexZeroPad(de,32),we])}));if(He.isZero())return null;t.push({type:"balance",content:He.toString()})}const Te={to:this.provider.formatter.address(ve[0]),data:hexConcat([ue,we])};let Ne=_parseString(yield this.provider.call(Te),0);if(Ne==null)return null;t.push({type:"metadata-url-base",content:Ne}),ae==="erc1155"&&(Ne=Ne.replace("{id}",we.substring(2)),t.push({type:"metadata-url-expanded",content:Ne})),Ne.match(/^ipfs:/i)&&(Ne=getIpfsLink(Ne)),t.push({type:"metadata-url",content:Ne});const qe=yield fetchJson(Ne);if(!qe)return null;t.push({type:"metadata",content:JSON.stringify(qe)});let ze=qe.image;if(typeof ze!="string")return null;if(!ze.match(/^(https:\/\/|data:)/i)){if(ze.match(matcherIpfs)==null)return null;t.push({type:"url-ipfs",content:ze}),ze=getIpfsLink(ze)}return t.push({type:"url",content:ze}),{linkage:t,url:ze}}}}}catch{}return null})}getContentHash(){return __awaiter$c(this,void 0,void 0,function*(){const t=yield this._fetchBytes("0xbc1c58d1");if(t==null||t==="0x")return null;const c=t.match(/^0xe3010170(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(c){const ue=parseInt(c[3],16);if(c[4].length===ue*2)return"ipfs://"+Base58.encode("0x"+c[1])}const ie=t.match(/^0xe5010172(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(ie){const ue=parseInt(ie[3],16);if(ie[4].length===ue*2)return"ipns://"+Base58.encode("0x"+ie[1])}const se=t.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(se&&se[1].length===64)return"bzz://"+se[1];const ae=t.match(/^0x90b2c605([0-9a-f]*)$/);if(ae&&ae[1].length===68){const ue={"=":"","+":"-","/":"_"};return"sia://"+encode$5("0x"+ae[1]).replace(/[=+\/]/g,de=>ue[de])}return logger$4.throwError("invalid or unsupported content hash data",Logger.errors.UNSUPPORTED_OPERATION,{operation:"getContentHash()",data:t})})}getText(t){return __awaiter$c(this,void 0,void 0,function*(){let c=toUtf8Bytes(t);c=concat$1([bytes32ify(64),bytes32ify(c.length),c]),c.length%32!==0&&(c=concat$1([c,hexZeroPad("0x",32-t.length%32)]));const ie=yield this._fetchBytes("0x59d1d43c",hexlify(c));return ie==null||ie==="0x"?null:toUtf8String(ie)})}}let defaultFormatter=null,nextPollId=1;class BaseProvider extends Provider{constructor(t){if(super(),this._events=[],this._emitted={block:-2},this.disableCcipRead=!1,this.formatter=new.target.getFormatter(),defineReadOnly(this,"anyNetwork",t==="any"),this.anyNetwork&&(t=this.detectNetwork()),t instanceof Promise)this._networkPromise=t,t.catch(c=>{}),this._ready().catch(c=>{});else{const c=getStatic(new.target,"getNetwork")(t);c?(defineReadOnly(this,"_network",c),this.emit("network",c,null)):logger$4.throwArgumentError("invalid network","network",t)}this._maxInternalBlockNumber=-1024,this._lastBlockNumber=-2,this._maxFilterBlockRange=10,this._pollingInterval=4e3,this._fastQueryDate=0}_ready(){return __awaiter$c(this,void 0,void 0,function*(){if(this._network==null){let t=null;if(this._networkPromise)try{t=yield this._networkPromise}catch{}t==null&&(t=yield this.detectNetwork()),t||logger$4.throwError("no network detected",Logger.errors.UNKNOWN_ERROR,{}),this._network==null&&(this.anyNetwork?this._network=t:defineReadOnly(this,"_network",t),this.emit("network",t,null))}return this._network})}get ready(){return poll(()=>this._ready().then(t=>t,t=>{if(!(t.code===Logger.errors.NETWORK_ERROR&&t.event==="noNetwork"))throw t}))}static getFormatter(){return defaultFormatter==null&&(defaultFormatter=new Formatter),defaultFormatter}static getNetwork(t){return getNetwork(t??"homestead")}ccipReadFetch(t,c,ie){return __awaiter$c(this,void 0,void 0,function*(){if(this.disableCcipRead||ie.length===0)return null;const se=t.to.toLowerCase(),ae=c.toLowerCase(),ue=[];for(let de=0;de<ie.length;de++){const ve=ie[de],ge=ve.replace("{sender}",se).replace("{data}",ae),we=ve.indexOf("{data}")>=0?null:JSON.stringify({data:ae,sender:se}),Te=yield fetchJson({url:ge,errorPassThrough:!0},we,(qe,ze)=>(qe.status=ze.statusCode,qe));if(Te.data)return Te.data;const Ne=Te.message||"unknown error";if(Te.status>=400&&Te.status<500)return logger$4.throwError(`response not found during CCIP fetch: ${Ne}`,Logger.errors.SERVER_ERROR,{url:ve,errorMessage:Ne});ue.push(Ne)}return logger$4.throwError(`error encountered during CCIP fetch: ${ue.map(de=>JSON.stringify(de)).join(", ")}`,Logger.errors.SERVER_ERROR,{urls:ie,errorMessages:ue})})}_getInternalBlockNumber(t){return __awaiter$c(this,void 0,void 0,function*(){if(yield this._ready(),t>0)for(;this._internalBlockNumber;){const se=this._internalBlockNumber;try{const ae=yield se;if(getTime()-ae.respTime<=t)return ae.blockNumber;break}catch{if(this._internalBlockNumber===se)break}}const c=getTime(),ie=resolveProperties({blockNumber:this.perform("getBlockNumber",{}),networkError:this.getNetwork().then(se=>null,se=>se)}).then(({blockNumber:se,networkError:ae})=>{if(ae)throw this._internalBlockNumber===ie&&(this._internalBlockNumber=null),ae;const ue=getTime();return se=BigNumber.from(se).toNumber(),se<this._maxInternalBlockNumber&&(se=this._maxInternalBlockNumber),this._maxInternalBlockNumber=se,this._setFastBlockNumber(se),{blockNumber:se,reqTime:c,respTime:ue}});return this._internalBlockNumber=ie,ie.catch(se=>{this._internalBlockNumber===ie&&(this._internalBlockNumber=null)}),(yield ie).blockNumber})}poll(){return __awaiter$c(this,void 0,void 0,function*(){const t=nextPollId++,c=[];let ie=null;try{ie=yield this._getInternalBlockNumber(100+this.pollingInterval/2)}catch(se){this.emit("error",se);return}if(this._setFastBlockNumber(ie),this.emit("poll",t,ie),ie===this._lastBlockNumber){this.emit("didPoll",t);return}if(this._emitted.block===-2&&(this._emitted.block=ie-1),Math.abs(this._emitted.block-ie)>1e3)logger$4.warn(`network block skew detected; skipping block events (emitted=${this._emitted.block} blockNumber${ie})`),this.emit("error",logger$4.makeError("network block skew detected",Logger.errors.NETWORK_ERROR,{blockNumber:ie,event:"blockSkew",previousBlockNumber:this._emitted.block})),this.emit("block",ie);else for(let se=this._emitted.block+1;se<=ie;se++)this.emit("block",se);this._emitted.block!==ie&&(this._emitted.block=ie,Object.keys(this._emitted).forEach(se=>{if(se==="block")return;const ae=this._emitted[se];ae!=="pending"&&ie-ae>12&&delete this._emitted[se]})),this._lastBlockNumber===-2&&(this._lastBlockNumber=ie-1),this._events.forEach(se=>{switch(se.type){case"tx":{const ae=se.hash;let ue=this.getTransactionReceipt(ae).then(de=>(!de||de.blockNumber==null||(this._emitted["t:"+ae]=de.blockNumber,this.emit(ae,de)),null)).catch(de=>{this.emit("error",de)});c.push(ue);break}case"filter":{if(!se._inflight){se._inflight=!0,se._lastBlockNumber===-2&&(se._lastBlockNumber=ie-1);const ae=se.filter;ae.fromBlock=se._lastBlockNumber+1,ae.toBlock=ie;const ue=ae.toBlock-this._maxFilterBlockRange;ue>ae.fromBlock&&(ae.fromBlock=ue),ae.fromBlock<0&&(ae.fromBlock=0);const de=this.getLogs(ae).then(ve=>{se._inflight=!1,ve.length!==0&&ve.forEach(ge=>{ge.blockNumber>se._lastBlockNumber&&(se._lastBlockNumber=ge.blockNumber),this._emitted["b:"+ge.blockHash]=ge.blockNumber,this._emitted["t:"+ge.transactionHash]=ge.blockNumber,this.emit(ae,ge)})}).catch(ve=>{this.emit("error",ve),se._inflight=!1});c.push(de)}break}}}),this._lastBlockNumber=ie,Promise.all(c).then(()=>{this.emit("didPoll",t)}).catch(se=>{this.emit("error",se)})})}resetEventsBlock(t){this._lastBlockNumber=t-1,this.polling&&this.poll()}get network(){return this._network}detectNetwork(){return __awaiter$c(this,void 0,void 0,function*(){return logger$4.throwError("provider does not support network detection",Logger.errors.UNSUPPORTED_OPERATION,{operation:"provider.detectNetwork"})})}getNetwork(){return __awaiter$c(this,void 0,void 0,function*(){const t=yield this._ready(),c=yield this.detectNetwork();if(t.chainId!==c.chainId){if(this.anyNetwork)return this._network=c,this._lastBlockNumber=-2,this._fastBlockNumber=null,this._fastBlockNumberPromise=null,this._fastQueryDate=0,this._emitted.block=-2,this._maxInternalBlockNumber=-1024,this._internalBlockNumber=null,this.emit("network",c,t),yield stall(0),this._network;const ie=logger$4.makeError("underlying network changed",Logger.errors.NETWORK_ERROR,{event:"changed",network:t,detectedNetwork:c});throw this.emit("error",ie),ie}return t})}get blockNumber(){return this._getInternalBlockNumber(100+this.pollingInterval/2).then(t=>{this._setFastBlockNumber(t)},t=>{}),this._fastBlockNumber!=null?this._fastBlockNumber:-1}get polling(){return this._poller!=null}set polling(t){t&&!this._poller?(this._poller=setInterval(()=>{this.poll()},this.pollingInterval),this._bootstrapPoll||(this._bootstrapPoll=setTimeout(()=>{this.poll(),this._bootstrapPoll=setTimeout(()=>{this._poller||this.poll(),this._bootstrapPoll=null},this.pollingInterval)},0))):!t&&this._poller&&(clearInterval(this._poller),this._poller=null)}get pollingInterval(){return this._pollingInterval}set pollingInterval(t){if(typeof t!="number"||t<=0||parseInt(String(t))!=t)throw new Error("invalid polling interval");this._pollingInterval=t,this._poller&&(clearInterval(this._poller),this._poller=setInterval(()=>{this.poll()},this._pollingInterval))}_getFastBlockNumber(){const t=getTime();return t-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=t,this._fastBlockNumberPromise=this.getBlockNumber().then(c=>((this._fastBlockNumber==null||c>this._fastBlockNumber)&&(this._fastBlockNumber=c),this._fastBlockNumber))),this._fastBlockNumberPromise}_setFastBlockNumber(t){this._fastBlockNumber!=null&&t<this._fastBlockNumber||(this._fastQueryDate=getTime(),(this._fastBlockNumber==null||t>this._fastBlockNumber)&&(this._fastBlockNumber=t,this._fastBlockNumberPromise=Promise.resolve(t)))}waitForTransaction(t,c,ie){return __awaiter$c(this,void 0,void 0,function*(){return this._waitForTransaction(t,c??1,ie||0,null)})}_waitForTransaction(t,c,ie,se){return __awaiter$c(this,void 0,void 0,function*(){const ae=yield this.getTransactionReceipt(t);return(ae?ae.confirmations:0)>=c?ae:new Promise((ue,de)=>{const ve=[];let ge=!1;const we=function(){return ge?!0:(ge=!0,ve.forEach(Ne=>{Ne()}),!1)},Te=Ne=>{Ne.confirmations<c||we()||ue(Ne)};if(this.on(t,Te),ve.push(()=>{this.removeListener(t,Te)}),se){let Ne=se.startBlock,qe=null;const ze=He=>__awaiter$c(this,void 0,void 0,function*(){ge||(yield stall(1e3),this.getTransactionCount(se.from).then(Ge=>__awaiter$c(this,void 0,void 0,function*(){if(!ge){if(Ge<=se.nonce)Ne=He;else{{const Ze=yield this.getTransaction(t);if(Ze&&Ze.blockNumber!=null)return}for(qe==null&&(qe=Ne-3,qe<se.startBlock&&(qe=se.startBlock));qe<=He;){if(ge)return;const Ze=yield this.getBlockWithTransactions(qe);for(let Ye=0;Ye<Ze.transactions.length;Ye++){const Ft=Ze.transactions[Ye];if(Ft.hash===t)return;if(Ft.from===se.from&&Ft.nonce===se.nonce){if(ge)return;const Mt=yield this.waitForTransaction(Ft.hash,c);if(we())return;let Zt="replaced";Ft.data===se.data&&Ft.to===se.to&&Ft.value.eq(se.value)?Zt="repriced":Ft.data==="0x"&&Ft.from===Ft.to&&Ft.value.isZero()&&(Zt="cancelled"),de(logger$4.makeError("transaction was replaced",Logger.errors.TRANSACTION_REPLACED,{cancelled:Zt==="replaced"||Zt==="cancelled",reason:Zt,replacement:this._wrapTransaction(Ft),hash:t,receipt:Mt}));return}}qe++}}ge||this.once("block",ze)}}),Ge=>{ge||this.once("block",ze)}))});if(ge)return;this.once("block",ze),ve.push(()=>{this.removeListener("block",ze)})}if(typeof ie=="number"&&ie>0){const Ne=setTimeout(()=>{we()||de(logger$4.makeError("timeout exceeded",Logger.errors.TIMEOUT,{timeout:ie}))},ie);Ne.unref&&Ne.unref(),ve.push(()=>{clearTimeout(Ne)})}})})}getBlockNumber(){return __awaiter$c(this,void 0,void 0,function*(){return this._getInternalBlockNumber(0)})}getGasPrice(){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const t=yield this.perform("getGasPrice",{});try{return BigNumber.from(t)}catch(c){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getGasPrice",result:t,error:c})}})}getBalance(t,c){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const ie=yield resolveProperties({address:this._getAddress(t),blockTag:this._getBlockTag(c)}),se=yield this.perform("getBalance",ie);try{return BigNumber.from(se)}catch(ae){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getBalance",params:ie,result:se,error:ae})}})}getTransactionCount(t,c){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const ie=yield resolveProperties({address:this._getAddress(t),blockTag:this._getBlockTag(c)}),se=yield this.perform("getTransactionCount",ie);try{return BigNumber.from(se).toNumber()}catch(ae){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getTransactionCount",params:ie,result:se,error:ae})}})}getCode(t,c){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const ie=yield resolveProperties({address:this._getAddress(t),blockTag:this._getBlockTag(c)}),se=yield this.perform("getCode",ie);try{return hexlify(se)}catch(ae){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getCode",params:ie,result:se,error:ae})}})}getStorageAt(t,c,ie){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const se=yield resolveProperties({address:this._getAddress(t),blockTag:this._getBlockTag(ie),position:Promise.resolve(c).then(ue=>hexValue(ue))}),ae=yield this.perform("getStorageAt",se);try{return hexlify(ae)}catch(ue){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"getStorageAt",params:se,result:ae,error:ue})}})}_wrapTransaction(t,c,ie){if(c!=null&&hexDataLength(c)!==32)throw new Error("invalid response - sendTransaction");const se=t;return c!=null&&t.hash!==c&&logger$4.throwError("Transaction hash mismatch from Provider.sendTransaction.",Logger.errors.UNKNOWN_ERROR,{expectedHash:t.hash,returnedHash:c}),se.wait=(ae,ue)=>__awaiter$c(this,void 0,void 0,function*(){ae==null&&(ae=1),ue==null&&(ue=0);let de;ae!==0&&ie!=null&&(de={data:t.data,from:t.from,nonce:t.nonce,to:t.to,value:t.value,startBlock:ie});const ve=yield this._waitForTransaction(t.hash,ae,ue,de);return ve==null&&ae===0?null:(this._emitted["t:"+t.hash]=ve.blockNumber,ve.status===0&&logger$4.throwError("transaction failed",Logger.errors.CALL_EXCEPTION,{transactionHash:t.hash,transaction:t,receipt:ve}),ve)}),se}sendTransaction(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const c=yield Promise.resolve(t).then(ae=>hexlify(ae)),ie=this.formatter.transaction(t);ie.confirmations==null&&(ie.confirmations=0);const se=yield this._getInternalBlockNumber(100+2*this.pollingInterval);try{const ae=yield this.perform("sendTransaction",{signedTransaction:c});return this._wrapTransaction(ie,ae,se)}catch(ae){throw ae.transaction=ie,ae.transactionHash=ie.hash,ae}})}_getTransactionRequest(t){return __awaiter$c(this,void 0,void 0,function*(){const c=yield t,ie={};return["from","to"].forEach(se=>{c[se]!=null&&(ie[se]=Promise.resolve(c[se]).then(ae=>ae?this._getAddress(ae):null))}),["gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","value"].forEach(se=>{c[se]!=null&&(ie[se]=Promise.resolve(c[se]).then(ae=>ae?BigNumber.from(ae):null))}),["type"].forEach(se=>{c[se]!=null&&(ie[se]=Promise.resolve(c[se]).then(ae=>ae??null))}),c.accessList&&(ie.accessList=this.formatter.accessList(c.accessList)),["data"].forEach(se=>{c[se]!=null&&(ie[se]=Promise.resolve(c[se]).then(ae=>ae?hexlify(ae):null))}),this.formatter.transactionRequest(yield resolveProperties(ie))})}_getFilter(t){return __awaiter$c(this,void 0,void 0,function*(){t=yield t;const c={};return t.address!=null&&(c.address=this._getAddress(t.address)),["blockHash","topics"].forEach(ie=>{t[ie]!=null&&(c[ie]=t[ie])}),["fromBlock","toBlock"].forEach(ie=>{t[ie]!=null&&(c[ie]=this._getBlockTag(t[ie]))}),this.formatter.filter(yield resolveProperties(c))})}_call(t,c,ie){return __awaiter$c(this,void 0,void 0,function*(){ie>=MAX_CCIP_REDIRECTS&&logger$4.throwError("CCIP read exceeded maximum redirections",Logger.errors.SERVER_ERROR,{redirects:ie,transaction:t});const se=t.to,ae=yield this.perform("call",{transaction:t,blockTag:c});if(ie>=0&&c==="latest"&&se!=null&&ae.substring(0,10)==="0x556f1830"&&hexDataLength(ae)%32===4)try{const ue=hexDataSlice(ae,4),de=hexDataSlice(ue,0,32);BigNumber.from(de).eq(se)||logger$4.throwError("CCIP Read sender did not match",Logger.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:t,data:ae});const ve=[],ge=BigNumber.from(hexDataSlice(ue,32,64)).toNumber(),we=BigNumber.from(hexDataSlice(ue,ge,ge+32)).toNumber(),Te=hexDataSlice(ue,ge+32);for(let Ze=0;Ze<we;Ze++){const Ye=_parseString(Te,Ze*32);Ye==null&&logger$4.throwError("CCIP Read contained corrupt URL string",Logger.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:t,data:ae}),ve.push(Ye)}const Ne=_parseBytes(ue,64);BigNumber.from(hexDataSlice(ue,100,128)).isZero()||logger$4.throwError("CCIP Read callback selector included junk",Logger.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:t,data:ae});const qe=hexDataSlice(ue,96,100),ze=_parseBytes(ue,128),He=yield this.ccipReadFetch(t,Ne,ve);He==null&&logger$4.throwError("CCIP Read disabled or provided no URLs",Logger.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:t,data:ae});const Ge={to:se,data:hexConcat([qe,encodeBytes([He,ze])])};return this._call(Ge,c,ie+1)}catch(ue){if(ue.code===Logger.errors.SERVER_ERROR)throw ue}try{return hexlify(ae)}catch(ue){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"call",params:{transaction:t,blockTag:c},result:ae,error:ue})}})}call(t,c){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const ie=yield resolveProperties({transaction:this._getTransactionRequest(t),blockTag:this._getBlockTag(c),ccipReadEnabled:Promise.resolve(t.ccipReadEnabled)});return this._call(ie.transaction,ie.blockTag,ie.ccipReadEnabled?0:-1)})}estimateGas(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const c=yield resolveProperties({transaction:this._getTransactionRequest(t)}),ie=yield this.perform("estimateGas",c);try{return BigNumber.from(ie)}catch(se){return logger$4.throwError("bad result from backend",Logger.errors.SERVER_ERROR,{method:"estimateGas",params:c,result:ie,error:se})}})}_getAddress(t){return __awaiter$c(this,void 0,void 0,function*(){t=yield t,typeof t!="string"&&logger$4.throwArgumentError("invalid address or ENS name","name",t);const c=yield this.resolveName(t);return c==null&&logger$4.throwError("ENS name not configured",Logger.errors.UNSUPPORTED_OPERATION,{operation:`resolveName(${JSON.stringify(t)})`}),c})}_getBlock(t,c){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork(),t=yield t;let ie=-128;const se={includeTransactions:!!c};if(isHexString(t,32))se.blockHash=t;else try{se.blockTag=yield this._getBlockTag(t),isHexString(se.blockTag)&&(ie=parseInt(se.blockTag.substring(2),16))}catch{logger$4.throwArgumentError("invalid block hash or block tag","blockHashOrBlockTag",t)}return poll(()=>__awaiter$c(this,void 0,void 0,function*(){const ae=yield this.perform("getBlock",se);if(ae==null)return se.blockHash!=null&&this._emitted["b:"+se.blockHash]==null||se.blockTag!=null&&ie>this._emitted.block?null:void 0;if(c){let ue=null;for(let ve=0;ve<ae.transactions.length;ve++){const ge=ae.transactions[ve];if(ge.blockNumber==null)ge.confirmations=0;else if(ge.confirmations==null){ue==null&&(ue=yield this._getInternalBlockNumber(100+2*this.pollingInterval));let we=ue-ge.blockNumber+1;we<=0&&(we=1),ge.confirmations=we}}const de=this.formatter.blockWithTransactions(ae);return de.transactions=de.transactions.map(ve=>this._wrapTransaction(ve)),de}return this.formatter.block(ae)}),{oncePoll:this})})}getBlock(t){return this._getBlock(t,!1)}getBlockWithTransactions(t){return this._getBlock(t,!0)}getTransaction(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork(),t=yield t;const c={transactionHash:this.formatter.hash(t,!0)};return poll(()=>__awaiter$c(this,void 0,void 0,function*(){const ie=yield this.perform("getTransaction",c);if(ie==null)return this._emitted["t:"+t]==null?null:void 0;const se=this.formatter.transactionResponse(ie);if(se.blockNumber==null)se.confirmations=0;else if(se.confirmations==null){let ae=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-se.blockNumber+1;ae<=0&&(ae=1),se.confirmations=ae}return this._wrapTransaction(se)}),{oncePoll:this})})}getTransactionReceipt(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork(),t=yield t;const c={transactionHash:this.formatter.hash(t,!0)};return poll(()=>__awaiter$c(this,void 0,void 0,function*(){const ie=yield this.perform("getTransactionReceipt",c);if(ie==null)return this._emitted["t:"+t]==null?null:void 0;if(ie.blockHash==null)return;const se=this.formatter.receipt(ie);if(se.blockNumber==null)se.confirmations=0;else if(se.confirmations==null){let ae=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-se.blockNumber+1;ae<=0&&(ae=1),se.confirmations=ae}return se}),{oncePoll:this})})}getLogs(t){return __awaiter$c(this,void 0,void 0,function*(){yield this.getNetwork();const c=yield resolveProperties({filter:this._getFilter(t)}),ie=yield this.perform("getLogs",c);return ie.forEach(se=>{se.removed==null&&(se.removed=!1)}),Formatter.arrayOf(this.formatter.filterLog.bind(this.formatter))(ie)})}getEtherPrice(){return __awaiter$c(this,void 0,void 0,function*(){return yield this.getNetwork(),this.perform("getEtherPrice",{})})}_getBlockTag(t){return __awaiter$c(this,void 0,void 0,function*(){if(t=yield t,typeof t=="number"&&t<0){t%1&&logger$4.throwArgumentError("invalid BlockTag","blockTag",t);let c=yield this._getInternalBlockNumber(100+2*this.pollingInterval);return c+=t,c<0&&(c=0),this.formatter.blockTag(c)}return this.formatter.blockTag(t)})}getResolver(t){return __awaiter$c(this,void 0,void 0,function*(){let c=t;for(;;){if(c===""||c==="."||t!=="eth"&&c==="eth")return null;const ie=yield this._getResolver(c,"getResolver");if(ie!=null){const se=new Resolver(this,ie,t);return c!==t&&!(yield se.supportsWildcard())?null:se}c=c.split(".").slice(1).join(".")}})}_getResolver(t,c){return __awaiter$c(this,void 0,void 0,function*(){c==null&&(c="ENS");const ie=yield this.getNetwork();ie.ensAddress||logger$4.throwError("network does not support ENS",Logger.errors.UNSUPPORTED_OPERATION,{operation:c,network:ie.name});try{const se=yield this.call({to:ie.ensAddress,data:"0x0178b8bf"+namehash$1(t).substring(2)});return this.formatter.callAddress(se)}catch{}return null})}resolveName(t){return __awaiter$c(this,void 0,void 0,function*(){t=yield t;try{return Promise.resolve(this.formatter.address(t))}catch(ie){if(isHexString(t))throw ie}typeof t!="string"&&logger$4.throwArgumentError("invalid ENS name","name",t);const c=yield this.getResolver(t);return c?yield c.getAddress():null})}lookupAddress(t){return __awaiter$c(this,void 0,void 0,function*(){t=yield t,t=this.formatter.address(t);const c=t.substring(2).toLowerCase()+".addr.reverse",ie=yield this._getResolver(c,"lookupAddress");if(ie==null)return null;const se=_parseString(yield this.call({to:ie,data:"0x691f3431"+namehash$1(c).substring(2)}),0);return(yield this.resolveName(se))!=t?null:se})}getAvatar(t){return __awaiter$c(this,void 0,void 0,function*(){let c=null;if(isHexString(t)){const se=this.formatter.address(t).substring(2).toLowerCase()+".addr.reverse",ae=yield this._getResolver(se,"getAvatar");if(!ae)return null;c=new Resolver(this,ae,se);try{const ue=yield c.getAvatar();if(ue)return ue.url}catch(ue){if(ue.code!==Logger.errors.CALL_EXCEPTION)throw ue}try{const ue=_parseString(yield this.call({to:ae,data:"0x691f3431"+namehash$1(se).substring(2)}),0);c=yield this.getResolver(ue)}catch(ue){if(ue.code!==Logger.errors.CALL_EXCEPTION)throw ue;return null}}else if(c=yield this.getResolver(t),!c)return null;const ie=yield c.getAvatar();return ie==null?null:ie.url})}perform(t,c){return logger$4.throwError(t+" not implemented",Logger.errors.NOT_IMPLEMENTED,{operation:t})}_startEvent(t){this.polling=this._events.filter(c=>c.pollable()).length>0}_stopEvent(t){this.polling=this._events.filter(c=>c.pollable()).length>0}_addEventListener(t,c,ie){const se=new Event$1(getEventTag(t),c,ie);return this._events.push(se),this._startEvent(se),this}on(t,c){return this._addEventListener(t,c,!1)}once(t,c){return this._addEventListener(t,c,!0)}emit(t,...c){let ie=!1,se=[],ae=getEventTag(t);return this._events=this._events.filter(ue=>ue.tag!==ae?!0:(setTimeout(()=>{ue.listener.apply(this,c)},0),ie=!0,ue.once?(se.push(ue),!1):!0)),se.forEach(ue=>{this._stopEvent(ue)}),ie}listenerCount(t){if(!t)return this._events.length;let c=getEventTag(t);return this._events.filter(ie=>ie.tag===c).length}listeners(t){if(t==null)return this._events.map(ie=>ie.listener);let c=getEventTag(t);return this._events.filter(ie=>ie.tag===c).map(ie=>ie.listener)}off(t,c){if(c==null)return this.removeAllListeners(t);const ie=[];let se=!1,ae=getEventTag(t);return this._events=this._events.filter(ue=>ue.tag!==ae||ue.listener!=c||se?!0:(se=!0,ie.push(ue),!1)),ie.forEach(ue=>{this._stopEvent(ue)}),this}removeAllListeners(t){let c=[];if(t==null)c=this._events,this._events=[];else{const ie=getEventTag(t);this._events=this._events.filter(se=>se.tag!==ie?!0:(c.push(se),!1))}return c.forEach(ie=>{this._stopEvent(ie)}),this}}var __awaiter$b=function(n,t,c,ie){function se(ae){return ae instanceof c?ae:new c(function(ue){ue(ae)})}return new(c||(c=Promise))(function(ae,ue){function de(we){try{ge(ie.next(we))}catch(Te){ue(Te)}}function ve(we){try{ge(ie.throw(we))}catch(Te){ue(Te)}}function ge(we){we.done?ae(we.value):se(we.value).then(de,ve)}ge((ie=ie.apply(n,[])).next())})};const logger$3=new Logger(version$8),errorGas=["call","estimateGas"];function spelunk(n,t){if(n==null)return null;if(typeof n.message=="string"&&n.message.match("reverted")){const c=isHexString(n.data)?n.data:null;if(!t||c)return{message:n.message,data:c}}if(typeof n=="object"){for(const c in n){const ie=spelunk(n[c],t);if(ie)return ie}return null}if(typeof n=="string")try{return spelunk(JSON.parse(n),t)}catch{}return null}function checkError(n,t,c){const ie=c.transaction||c.signedTransaction;if(n==="call"){const ae=spelunk(t,!0);if(ae)return ae.data;logger$3.throwError("missing revert data in call exception; Transaction reverted without a reason string",Logger.errors.CALL_EXCEPTION,{data:"0x",transaction:ie,error:t})}if(n==="estimateGas"){let ae=spelunk(t.body,!1);ae==null&&(ae=spelunk(t,!1)),ae&&logger$3.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",Logger.errors.UNPREDICTABLE_GAS_LIMIT,{reason:ae.message,method:n,transaction:ie,error:t})}let se=t.message;throw t.code===Logger.errors.SERVER_ERROR&&t.error&&typeof t.error.message=="string"?se=t.error.message:typeof t.body=="string"?se=t.body:typeof t.responseText=="string"&&(se=t.responseText),se=(se||"").toLowerCase(),se.match(/insufficient funds|base fee exceeds gas limit|InsufficientFunds/i)&&logger$3.throwError("insufficient funds for intrinsic transaction cost",Logger.errors.INSUFFICIENT_FUNDS,{error:t,method:n,transaction:ie}),se.match(/nonce (is )?too low/i)&&logger$3.throwError("nonce has already been used",Logger.errors.NONCE_EXPIRED,{error:t,method:n,transaction:ie}),se.match(/replacement transaction underpriced|transaction gas price.*too low/i)&&logger$3.throwError("replacement fee too low",Logger.errors.REPLACEMENT_UNDERPRICED,{error:t,method:n,transaction:ie}),se.match(/only replay-protected/i)&&logger$3.throwError("legacy pre-eip-155 transactions not supported",Logger.errors.UNSUPPORTED_OPERATION,{error:t,method:n,transaction:ie}),errorGas.indexOf(n)>=0&&se.match(/gas required exceeds allowance|always failing transaction|execution reverted|revert/)&&logger$3.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",Logger.errors.UNPREDICTABLE_GAS_LIMIT,{error:t,method:n,transaction:ie}),t}function timer(n){return new Promise(function(t){setTimeout(t,n)})}function getResult(n){if(n.error){const t=new Error(n.error.message);throw t.code=n.error.code,t.data=n.error.data,t}return n.result}function getLowerCase(n){return n&&n.toLowerCase()}const _constructorGuard={};class JsonRpcSigner extends Signer{constructor(t,c,ie){if(super(),t!==_constructorGuard)throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");defineReadOnly(this,"provider",c),ie==null&&(ie=0),typeof ie=="string"?(defineReadOnly(this,"_address",this.provider.formatter.address(ie)),defineReadOnly(this,"_index",null)):typeof ie=="number"?(defineReadOnly(this,"_index",ie),defineReadOnly(this,"_address",null)):logger$3.throwArgumentError("invalid address or index","addressOrIndex",ie)}connect(t){return logger$3.throwError("cannot alter JSON-RPC Signer connection",Logger.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}connectUnchecked(){return new UncheckedJsonRpcSigner(_constructorGuard,this.provider,this._address||this._index)}getAddress(){return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then(t=>(t.length<=this._index&&logger$3.throwError("unknown account #"+this._index,Logger.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),this.provider.formatter.address(t[this._index])))}sendUncheckedTransaction(t){t=shallowCopy(t);const c=this.getAddress().then(ie=>(ie&&(ie=ie.toLowerCase()),ie));if(t.gasLimit==null){const ie=shallowCopy(t);ie.from=c,t.gasLimit=this.provider.estimateGas(ie)}return t.to!=null&&(t.to=Promise.resolve(t.to).then(ie=>__awaiter$b(this,void 0,void 0,function*(){if(ie==null)return null;const se=yield this.provider.resolveName(ie);return se==null&&logger$3.throwArgumentError("provided ENS name resolves to null","tx.to",ie),se}))),resolveProperties({tx:resolveProperties(t),sender:c}).then(({tx:ie,sender:se})=>{ie.from!=null?ie.from.toLowerCase()!==se&&logger$3.throwArgumentError("from address mismatch","transaction",t):ie.from=se;const ae=this.provider.constructor.hexlifyTransaction(ie,{from:!0});return this.provider.send("eth_sendTransaction",[ae]).then(ue=>ue,ue=>(typeof ue.message=="string"&&ue.message.match(/user denied/i)&&logger$3.throwError("user rejected transaction",Logger.errors.ACTION_REJECTED,{action:"sendTransaction",transaction:ie}),checkError("sendTransaction",ue,ae)))})}signTransaction(t){return logger$3.throwError("signing transactions is unsupported",Logger.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}sendTransaction(t){return __awaiter$b(this,void 0,void 0,function*(){const c=yield this.provider._getInternalBlockNumber(100+2*this.provider.pollingInterval),ie=yield this.sendUncheckedTransaction(t);try{return yield poll(()=>__awaiter$b(this,void 0,void 0,function*(){const se=yield this.provider.getTransaction(ie);if(se!==null)return this.provider._wrapTransaction(se,ie,c)}),{oncePoll:this.provider})}catch(se){throw se.transactionHash=ie,se}})}signMessage(t){return __awaiter$b(this,void 0,void 0,function*(){const c=typeof t=="string"?toUtf8Bytes(t):t,ie=yield this.getAddress();try{return yield this.provider.send("personal_sign",[hexlify(c),ie.toLowerCase()])}catch(se){throw typeof se.message=="string"&&se.message.match(/user denied/i)&&logger$3.throwError("user rejected signing",Logger.errors.ACTION_REJECTED,{action:"signMessage",from:ie,messageData:t}),se}})}_legacySignMessage(t){return __awaiter$b(this,void 0,void 0,function*(){const c=typeof t=="string"?toUtf8Bytes(t):t,ie=yield this.getAddress();try{return yield this.provider.send("eth_sign",[ie.toLowerCase(),hexlify(c)])}catch(se){throw typeof se.message=="string"&&se.message.match(/user denied/i)&&logger$3.throwError("user rejected signing",Logger.errors.ACTION_REJECTED,{action:"_legacySignMessage",from:ie,messageData:t}),se}})}_signTypedData(t,c,ie){return __awaiter$b(this,void 0,void 0,function*(){const se=yield TypedDataEncoder.resolveNames(t,c,ie,ue=>this.provider.resolveName(ue)),ae=yield this.getAddress();try{return yield this.provider.send("eth_signTypedData_v4",[ae.toLowerCase(),JSON.stringify(TypedDataEncoder.getPayload(se.domain,c,se.value))])}catch(ue){throw typeof ue.message=="string"&&ue.message.match(/user denied/i)&&logger$3.throwError("user rejected signing",Logger.errors.ACTION_REJECTED,{action:"_signTypedData",from:ae,messageData:{domain:se.domain,types:c,value:se.value}}),ue}})}unlock(t){return __awaiter$b(this,void 0,void 0,function*(){const c=this.provider,ie=yield this.getAddress();return c.send("personal_unlockAccount",[ie.toLowerCase(),t,null])})}}class UncheckedJsonRpcSigner extends JsonRpcSigner{sendTransaction(t){return this.sendUncheckedTransaction(t).then(c=>({hash:c,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:ie=>this.provider.waitForTransaction(c,ie)}))}}const allowedTransactionKeys={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0,type:!0,accessList:!0,maxFeePerGas:!0,maxPriorityFeePerGas:!0};class JsonRpcProvider extends BaseProvider{constructor(t,c){let ie=c;ie==null&&(ie=new Promise((se,ae)=>{setTimeout(()=>{this.detectNetwork().then(ue=>{se(ue)},ue=>{ae(ue)})},0)})),super(ie),t||(t=getStatic(this.constructor,"defaultUrl")()),typeof t=="string"?defineReadOnly(this,"connection",Object.freeze({url:t})):defineReadOnly(this,"connection",Object.freeze(shallowCopy(t))),this._nextId=42}get _cache(){return this._eventLoopCache==null&&(this._eventLoopCache={}),this._eventLoopCache}static defaultUrl(){return"http://localhost:8545"}detectNetwork(){return this._cache.detectNetwork||(this._cache.detectNetwork=this._uncachedDetectNetwork(),setTimeout(()=>{this._cache.detectNetwork=null},0)),this._cache.detectNetwork}_uncachedDetectNetwork(){return __awaiter$b(this,void 0,void 0,function*(){yield timer(0);let t=null;try{t=yield this.send("eth_chainId",[])}catch{try{t=yield this.send("net_version",[])}catch{}}if(t!=null){const c=getStatic(this.constructor,"getNetwork");try{return c(BigNumber.from(t).toNumber())}catch(ie){return logger$3.throwError("could not detect network",Logger.errors.NETWORK_ERROR,{chainId:t,event:"invalidNetwork",serverError:ie})}}return logger$3.throwError("could not detect network",Logger.errors.NETWORK_ERROR,{event:"noNetwork"})})}getSigner(t){return new JsonRpcSigner(_constructorGuard,this,t)}getUncheckedSigner(t){return this.getSigner(t).connectUnchecked()}listAccounts(){return this.send("eth_accounts",[]).then(t=>t.map(c=>this.formatter.address(c)))}send(t,c){const ie={method:t,params:c,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:deepCopy(ie),provider:this});const se=["eth_chainId","eth_blockNumber"].indexOf(t)>=0;if(se&&this._cache[t])return this._cache[t];const ae=fetchJson(this.connection,JSON.stringify(ie),getResult).then(ue=>(this.emit("debug",{action:"response",request:ie,response:ue,provider:this}),ue),ue=>{throw this.emit("debug",{action:"response",error:ue,request:ie,provider:this}),ue});return se&&(this._cache[t]=ae,setTimeout(()=>{this._cache[t]=null},0)),ae}prepareRequest(t,c){switch(t){case"getBlockNumber":return["eth_blockNumber",[]];case"getGasPrice":return["eth_gasPrice",[]];case"getBalance":return["eth_getBalance",[getLowerCase(c.address),c.blockTag]];case"getTransactionCount":return["eth_getTransactionCount",[getLowerCase(c.address),c.blockTag]];case"getCode":return["eth_getCode",[getLowerCase(c.address),c.blockTag]];case"getStorageAt":return["eth_getStorageAt",[getLowerCase(c.address),hexZeroPad(c.position,32),c.blockTag]];case"sendTransaction":return["eth_sendRawTransaction",[c.signedTransaction]];case"getBlock":return c.blockTag?["eth_getBlockByNumber",[c.blockTag,!!c.includeTransactions]]:c.blockHash?["eth_getBlockByHash",[c.blockHash,!!c.includeTransactions]]:null;case"getTransaction":return["eth_getTransactionByHash",[c.transactionHash]];case"getTransactionReceipt":return["eth_getTransactionReceipt",[c.transactionHash]];case"call":return["eth_call",[getStatic(this.constructor,"hexlifyTransaction")(c.transaction,{from:!0}),c.blockTag]];case"estimateGas":return["eth_estimateGas",[getStatic(this.constructor,"hexlifyTransaction")(c.transaction,{from:!0})]];case"getLogs":return c.filter&&c.filter.address!=null&&(c.filter.address=getLowerCase(c.filter.address)),["eth_getLogs",[c.filter]]}return null}perform(t,c){return __awaiter$b(this,void 0,void 0,function*(){if(t==="call"||t==="estimateGas"){const se=c.transaction;if(se&&se.type!=null&&BigNumber.from(se.type).isZero()&&se.maxFeePerGas==null&&se.maxPriorityFeePerGas==null){const ae=yield this.getFeeData();ae.maxFeePerGas==null&&ae.maxPriorityFeePerGas==null&&(c=shallowCopy(c),c.transaction=shallowCopy(se),delete c.transaction.type)}}const ie=this.prepareRequest(t,c);ie==null&&logger$3.throwError(t+" not implemented",Logger.errors.NOT_IMPLEMENTED,{operation:t});try{return yield this.send(ie[0],ie[1])}catch(se){return checkError(t,se,c)}})}_startEvent(t){t.tag==="pending"&&this._startPending(),super._startEvent(t)}_startPending(){if(this._pendingFilter!=null)return;const t=this,c=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=c,c.then(function(ie){function se(){t.send("eth_getFilterChanges",[ie]).then(function(ae){if(t._pendingFilter!=c)return null;let ue=Promise.resolve();return ae.forEach(function(de){t._emitted["t:"+de.toLowerCase()]="pending",ue=ue.then(function(){return t.getTransaction(de).then(function(ve){return t.emit("pending",ve),null})})}),ue.then(function(){return timer(1e3)})}).then(function(){if(t._pendingFilter!=c){t.send("eth_uninstallFilter",[ie]);return}return setTimeout(function(){se()},0),null}).catch(ae=>{})}return se(),ie}).catch(ie=>{})}_stopEvent(t){t.tag==="pending"&&this.listenerCount("pending")===0&&(this._pendingFilter=null),super._stopEvent(t)}static hexlifyTransaction(t,c){const ie=shallowCopy(allowedTransactionKeys);if(c)for(const ae in c)c[ae]&&(ie[ae]=!0);checkProperties(t,ie);const se={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(function(ae){if(t[ae]==null)return;const ue=hexValue(BigNumber.from(t[ae]));ae==="gasLimit"&&(ae="gas"),se[ae]=ue}),["from","to","data"].forEach(function(ae){t[ae]!=null&&(se[ae]=hexlify(t[ae]))}),t.accessList&&(se.accessList=accessListify(t.accessList)),se}}const logger$2=new Logger(version$8);let _nextId=1;function buildWeb3LegacyFetcher(n,t){const c="Web3LegacyFetcher";return function(ie,se){const ae={method:ie,params:se,id:_nextId++,jsonrpc:"2.0"};return new Promise((ue,de)=>{this.emit("debug",{action:"request",fetcher:c,request:deepCopy(ae),provider:this}),t(ae,(ve,ge)=>{if(ve)return this.emit("debug",{action:"response",fetcher:c,error:ve,request:ae,provider:this}),de(ve);if(this.emit("debug",{action:"response",fetcher:c,request:ae,response:ge,provider:this}),ge.error){const we=new Error(ge.error.message);return we.code=ge.error.code,we.data=ge.error.data,de(we)}ue(ge.result)})})}}function buildEip1193Fetcher(n){return function(t,c){c==null&&(c=[]);const ie={method:t,params:c};return this.emit("debug",{action:"request",fetcher:"Eip1193Fetcher",request:deepCopy(ie),provider:this}),n.request(ie).then(se=>(this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:ie,response:se,provider:this}),se),se=>{throw this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:ie,error:se,provider:this}),se})}}class Web3Provider extends JsonRpcProvider{constructor(t,c){t==null&&logger$2.throwArgumentError("missing provider","provider",t);let ie=null,se=null,ae=null;typeof t=="function"?(ie="unknown:",se=t):(ie=t.host||t.path||"",!ie&&t.isMetaMask&&(ie="metamask"),ae=t,t.request?(ie===""&&(ie="eip-1193:"),se=buildEip1193Fetcher(t)):t.sendAsync?se=buildWeb3LegacyFetcher(t,t.sendAsync.bind(t)):t.send?se=buildWeb3LegacyFetcher(t,t.send.bind(t)):logger$2.throwArgumentError("unsupported provider","provider",t),ie||(ie="unknown:")),super(ie,c),defineReadOnly(this,"jsonRpcFetchFunc",se),defineReadOnly(this,"provider",ae)}send(t,c){return this.jsonRpcFetchFunc(t,c)}}const version$7="solidity/5.8.0",regexBytes=new RegExp("^bytes([0-9]+)$"),regexNumber=new RegExp("^(u?int)([0-9]*)$"),regexArray=new RegExp("^(.*)\\[([0-9]*)\\]$"),Zeros="0000000000000000000000000000000000000000000000000000000000000000",logger$1$1=new Logger(version$7);function _pack(n,t,c){switch(n){case"address":return c?zeroPad(t,32):arrayify(t);case"string":return toUtf8Bytes(t);case"bytes":return arrayify(t);case"bool":return t=t?"0x01":"0x00",c?zeroPad(t,32):arrayify(t)}let ie=n.match(regexNumber);if(ie){let se=parseInt(ie[2]||"256");return(ie[2]&&String(se)!==ie[2]||se%8!==0||se===0||se>256)&&logger$1$1.throwArgumentError("invalid number type","type",n),c&&(se=256),t=BigNumber.from(t).toTwos(se),zeroPad(t,se/8)}if(ie=n.match(regexBytes),ie){const se=parseInt(ie[1]);return(String(se)!==ie[1]||se===0||se>32)&&logger$1$1.throwArgumentError("invalid bytes type","type",n),arrayify(t).byteLength!==se&&logger$1$1.throwArgumentError(`invalid value for ${n}`,"value",t),c?arrayify((t+Zeros).substring(0,66)):t}if(ie=n.match(regexArray),ie&&Array.isArray(t)){const se=ie[1];parseInt(ie[2]||String(t.length))!=t.length&&logger$1$1.throwArgumentError(`invalid array length for ${n}`,"value",t);const ae=[];return t.forEach(function(ue){ae.push(_pack(se,ue,!0))}),concat$1(ae)}return logger$1$1.throwArgumentError("invalid type","type",n)}function pack(n,t){n.length!=t.length&&logger$1$1.throwArgumentError("wrong number of values; expected ${ types.length }","values",t);const c=[];return n.forEach(function(ie,se){c.push(_pack(ie,t[se]))}),hexlify(concat$1(c))}function keccak256(n,t){return keccak256$1(pack(n,t))}function sha256$6(n,t){return sha256$7(pack(n,t))}const lib_esm$1=Object.freeze(Object.defineProperty({__proto__:null,keccak256,pack,sha256:sha256$6},Symbol.toStringTag,{value:"Module"})),version$6="units/5.8.0",logger$y=new Logger(version$6),names$2=["wei","kwei","mwei","gwei","szabo","finney","ether"];function commify(n){const t=String(n).split(".");(t.length>2||!t[0].match(/^-?[0-9]*$/)||t[1]&&!t[1].match(/^[0-9]*$/)||n==="."||n==="-.")&&logger$y.throwArgumentError("invalid value","value",n);let c=t[0],ie="";for(c.substring(0,1)==="-"&&(ie="-",c=c.substring(1));c.substring(0,1)==="0";)c=c.substring(1);c===""&&(c="0");let se="";for(t.length===2&&(se="."+(t[1]||"0"));se.length>2&&se[se.length-1]==="0";)se=se.substring(0,se.length-1);const ae=[];for(;c.length;)if(c.length<=3){ae.unshift(c);break}else{const ue=c.length-3;ae.unshift(c.substring(ue)),c=c.substring(0,ue)}return ie+ae.join(",")+se}function formatUnits(n,t){if(typeof t=="string"){const c=names$2.indexOf(t);c!==-1&&(t=3*c)}return formatFixed(n,t??18)}function parseUnits(n,t){if(typeof n!="string"&&logger$y.throwArgumentError("value must be a string","value",n),typeof t=="string"){const c=names$2.indexOf(t);c!==-1&&(t=3*c)}return parseFixed(n,t??18)}function formatEther(n){return formatUnits(n,18)}function parseEther(n){return parseUnits(n,18)}const lib_esm=Object.freeze(Object.defineProperty({__proto__:null,commify,formatEther,formatUnits,parseEther,parseUnits},Symbol.toStringTag,{value:"Module"}));var NFTType=(n=>(n[n.ERC1155=0]="ERC1155",n[n.ERC721=1]="ERC721",n))(NFTType||{}),ProductType=(n=>(n[n.DIGITAL=0]="DIGITAL",n[n.POD=1]="POD",n[n.PHYSICAL=2]="PHYSICAL",n))(ProductType||{});class HTTPError extends Error{constructor(t,c,ie){const se=t.status||t.status===0?t.status:"",ae=t.statusText??"",ue=`${se} ${ae}`.trim(),de=ue?`status code ${ue}`:"an unknown error";super(`Request failed with ${de}: ${c.method} ${c.url}`),Xn(this,"response"),Xn(this,"request"),Xn(this,"options"),this.name="HTTPError",this.response=t,this.request=c,this.options=ie}}class TimeoutError extends Error{constructor(t){super(`Request timed out: ${t.method} ${t.url}`),Xn(this,"request"),this.name="TimeoutError",this.request=t}}const supportsRequestStreams=(()=>{let n=!1,t=!1;const c=typeof globalThis.ReadableStream=="function",ie=typeof globalThis.Request=="function";if(c&&ie)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return n=!0,"half"}}).headers.has("Content-Type")}catch(se){if(se instanceof Error&&se.message==="unsupported BodyInit type")return!1;throw se}return n&&!t})(),supportsAbortController=typeof globalThis.AbortController=="function",supportsAbortSignal=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",supportsResponseStreams=typeof globalThis.ReadableStream=="function",supportsFormData=typeof globalThis.FormData=="function",requestMethods=["get","post","put","patch","head","delete"],responseTypes={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},maxSafeTimeout=2147483647,usualFormBoundarySize=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,stop$1=Symbol("stop"),kyOptionKeys={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},requestOptionsRegistry={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0,priority:!0},getBodySize=n=>{if(!n)return 0;if(n instanceof FormData){let t=0;for(const[c,ie]of n)t+=usualFormBoundarySize,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${c}"`).length,t+=typeof ie=="string"?new TextEncoder().encode(ie).length:ie.size;return t}if(n instanceof Blob)return n.size;if(n instanceof ArrayBuffer)return n.byteLength;if(typeof n=="string")return new TextEncoder().encode(n).length;if(n instanceof URLSearchParams)return new TextEncoder().encode(n.toString()).length;if("byteLength"in n)return n.byteLength;if(typeof n=="object"&&n!==null)try{const t=JSON.stringify(n);return new TextEncoder().encode(t).length}catch{return 0}return 0},withProgress=(n,t,c)=>{let ie,se=0;return n.pipeThrough(new TransformStream({transform(ae,ue){if(ue.enqueue(ae),ie){se+=ie.byteLength;let de=t===0?0:se/t;de>=1&&(de=1-Number.EPSILON),c?.({percent:de,totalBytes:Math.max(t,se),transferredBytes:se},ie)}ie=ae},flush(){ie&&(se+=ie.byteLength,c?.({percent:1,totalBytes:Math.max(t,se),transferredBytes:se},ie))}}))},streamResponse=(n,t)=>{if(!n.body)return n;if(n.status===204)return new Response(null,{status:n.status,statusText:n.statusText,headers:n.headers});const c=Number(n.headers.get("content-length"))||0;return new Response(withProgress(n.body,c,t),{status:n.status,statusText:n.statusText,headers:n.headers})},streamRequest=(n,t,c)=>{if(!n.body)return n;const ie=getBodySize(c??n.body);return new Request(n,{duplex:"half",body:withProgress(n.body,ie,t)})},isObject$2$1=n=>n!==null&&typeof n=="object",validateAndMerge=(...n)=>{for(const t of n)if((!isObject$2$1(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return deepMerge({},...n)},mergeHeaders=(n={},t={})=>{const c=new globalThis.Headers(n),ie=t instanceof globalThis.Headers,se=new globalThis.Headers(t);for(const[ae,ue]of se.entries())ie&&ue==="undefined"||ue===void 0?c.delete(ae):c.set(ae,ue);return c};function newHookValue(n,t,c){return Object.hasOwn(t,c)&&t[c]===void 0?[]:deepMerge(n[c]??[],t[c]??[])}const mergeHooks=(n={},t={})=>({beforeRequest:newHookValue(n,t,"beforeRequest"),beforeRetry:newHookValue(n,t,"beforeRetry"),afterResponse:newHookValue(n,t,"afterResponse"),beforeError:newHookValue(n,t,"beforeError")}),deepMerge=(...n)=>{let t={},c={},ie={};for(const se of n)if(Array.isArray(se))Array.isArray(t)||(t=[]),t=[...t,...se];else if(isObject$2$1(se)){for(let[ae,ue]of Object.entries(se))isObject$2$1(ue)&&ae in t&&(ue=deepMerge(t[ae],ue)),t={...t,[ae]:ue};isObject$2$1(se.hooks)&&(ie=mergeHooks(ie,se.hooks),t.hooks=ie),isObject$2$1(se.headers)&&(c=mergeHeaders(c,se.headers),t.headers=c)}return t},normalizeRequestMethod=n=>requestMethods.includes(n)?n.toUpperCase():n,retryMethods=["get","put","head","delete","options","trace"],retryStatusCodes=[408,413,429,500,502,503,504],retryAfterStatusCodes=[413,429,503],defaultRetryOptions={limit:2,methods:retryMethods,statusCodes:retryStatusCodes,afterStatusCodes:retryAfterStatusCodes,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:n=>.3*2**(n-1)*1e3},normalizeRetryOptions=(n={})=>{if(typeof n=="number")return{...defaultRetryOptions,limit:n};if(n.methods&&!Array.isArray(n.methods))throw new Error("retry.methods must be an array");if(n.statusCodes&&!Array.isArray(n.statusCodes))throw new Error("retry.statusCodes must be an array");return{...defaultRetryOptions,...n}};async function timeout(n,t,c,ie){return new Promise((se,ae)=>{const ue=setTimeout(()=>{c&&c.abort(),ae(new TimeoutError(n))},ie.timeout);ie.fetch(n,t).then(se).catch(ae).then(()=>{clearTimeout(ue)})})}async function delay$1(n,{signal:t}){return new Promise((c,ie)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",se,{once:!0}));function se(){clearTimeout(ae),ie(t.reason)}const ae=setTimeout(()=>{t?.removeEventListener("abort",se),c()},n)})}const findUnknownOptions=(n,t)=>{const c={};for(const ie in t)!(ie in requestOptionsRegistry)&&!(ie in kyOptionKeys)&&!(ie in n)&&(c[ie]=t[ie]);return c},hasSearchParameters=n=>n===void 0?!1:Array.isArray(n)?n.length>0:n instanceof URLSearchParams?n.size>0:typeof n=="object"?Object.keys(n).length>0:typeof n=="string"?n.trim().length>0:!!n;var ei,oi;const Yn=class oo{constructor(t,c={}){Xn(this,"request"),Xn(this,"abortController"),Xn(this,"_retryCount",0),Xn(this,"_input"),Xn(this,"_options"),Xn(this,"_originalRequest");var ie,se,ae;if(this._input=t,this._options={...c,headers:mergeHeaders(this._input.headers,c.headers),hooks:mergeHooks({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},c.hooks),method:normalizeRequestMethod(c.method??this._input.method??"GET"),prefixUrl:String(c.prefixUrl||""),retry:normalizeRetryOptions(c.retry),throwHttpErrors:c.throwHttpErrors!==!1,timeout:c.timeout??1e4,fetch:c.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(supportsAbortController&&supportsAbortSignal){const ue=this._options.signal??this._input.signal;this.abortController=new globalThis.AbortController,this._options.signal=ue?AbortSignal.any([ue,this.abortController.signal]):this.abortController.signal}if(supportsRequestStreams&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=((se=(ie=this._options).stringifyJson)==null?void 0:se.call(ie,this._options.json))??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),hasSearchParameters(this._options.searchParams)){const ue="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(ai(ae=oo,ei,oi).call(ae,this._options.searchParams)).toString()),de=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,ue);(supportsFormData&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(de,{...this.request}),this._options)}if(this._options.onUploadProgress){if(typeof this._options.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!supportsRequestStreams)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=streamRequest(this.request,this._options.onUploadProgress,this._options.body))}}static create(t,c){var ie,se;const ae=new oo(t,c),ue=async()=>{if(typeof ae._options.timeout=="number"&&ae._options.timeout>maxSafeTimeout)throw new RangeError(`The \`timeout\` option cannot be greater than ${maxSafeTimeout}`);await Promise.resolve();let ve=await ae._fetch();for(const ge of ae._options.hooks.afterResponse){const we=await ge(ae.request,ae._options,ae._decorateResponse(ve.clone()));we instanceof globalThis.Response&&(ve=we)}if(ae._decorateResponse(ve),!ve.ok&&ae._options.throwHttpErrors){let ge=new HTTPError(ve,ae.request,ae._options);for(const we of ae._options.hooks.beforeError)ge=await we(ge);throw ge}if(ae._options.onDownloadProgress){if(typeof ae._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!supportsResponseStreams)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return streamResponse(ve.clone(),ae._options.onDownloadProgress)}return ve},de=(ae._options.retry.methods.includes(ae.request.method.toLowerCase())?ae._retry(ue):ue()).finally(async()=>{var ve,ge;const we=ae._originalRequest,Te=[];we&&!we.bodyUsed&&Te.push((ve=we.body)==null?void 0:ve.cancel()),ae.request.bodyUsed||Te.push((ge=ae.request.body)==null?void 0:ge.cancel()),await Promise.all(Te)});for(const[ve,ge]of Object.entries(responseTypes))ve==="bytes"&&typeof((se=(ie=globalThis.Response)==null?void 0:ie.prototype)==null?void 0:se.bytes)!="function"||(de[ve]=async()=>{ae.request.headers.set("accept",ae.request.headers.get("accept")||ge);const we=await de;if(ve==="json"){if(we.status===204)return"";const Te=await we.text();return Te===""?"":c.parseJson?c.parseJson(Te):JSON.parse(Te)}return we[ve]()});return de}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof TimeoutError)throw t;if(t instanceof HTTPError){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;const ie=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(ie&&this._options.retry.afterStatusCodes.includes(t.response.status)){let se=Number(ie)*1e3;Number.isNaN(se)?se=Date.parse(ie)-Date.now():se>=Date.parse("2024-01-01")&&(se-=Date.now());const ae=this._options.retry.maxRetryAfter??se;return se<ae?se:ae}if(t.response.status===413)throw t}const c=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,c)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(c){const ie=Math.min(this._calculateRetryDelay(c),maxSafeTimeout);if(this._retryCount<1)throw c;await delay$1(ie,{signal:this._options.signal});for(const se of this._options.hooks.beforeRetry)if(await se({request:this.request,options:this._options,error:c,retryCount:this._retryCount})===stop$1)return;return this._retry(t)}}async _fetch(){for(const c of this._options.hooks.beforeRequest){const ie=await c(this.request,this._options);if(ie instanceof Request){this.request=ie;break}if(ie instanceof Response)return ie}const t=findUnknownOptions(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):timeout(this._originalRequest,t,this.abortController,this._options)}};ei=new WeakSet,oi=function(n){return n&&typeof n=="object"&&!Array.isArray(n)&&!(n instanceof URLSearchParams)?Object.fromEntries(Object.entries(n).filter(([,t])=>t!==void 0)):n},ii(Yn,ei);let Ky=Yn;const createInstance$1=n=>{const t=(c,ie)=>Ky.create(c,validateAndMerge(n,ie));for(const c of requestMethods)t[c]=(ie,se)=>Ky.create(ie,validateAndMerge(n,se,{method:c}));return t.create=c=>createInstance$1(validateAndMerge(c)),t.extend=c=>(typeof c=="function"&&(c=c(n??{})),createInstance$1(validateAndMerge(n,c))),t.stop=stop$1,t},ky=createInstance$1();async function uploadMetadata(n,t,c){return(await(await c.post("uploader/cdn-upload-json",{json:{data:n,key:`record-metadata/${t}.json`}})).json()).url}async function startRecord(n,t,c,ie,se,ae){return(await(await ae.post("web3/record/transactions",{json:{uris:se,network:ie,data:{productId:n,skuIds:t},productId:n,skuIds:t,metadata:{},shopId:c,txType:"RECORD"}})).json()).data.id}async function getShopInfo(n,t,c){const ie=(await(await c.get(`shops/v2/public/${t}`)).json()).data.deployedContracts.filter(se=>se.type===n);return ie.length===0?{nftContractAddress:"",shopContractAddress:""}:{nftContractAddress:ie[0].deployedNFTAddress,shopContractAddress:ie[0].deployedShopAddress}}async function deleteRecordTransaction(n,t){await t.delete(`web3/record/transactions/${n}`)}async function web3Callback(n,t,c,ie){const se={"X-API-KEY":"ho8homr9e8p4fwii7tjiz41xs4hlbl2h4i"};return(await(await ky.create({headers:se,prefixUrl:c==="TESTNET"?"https://web3dev.droplinked.com/":"https://web3.droplinked.com/"}).post("transactions",{json:{transaction_id:n,callback_url:ie,chain:t,network:c},headers:se})).json()).data}async function getProductData(n,t){return(await(await t.get(`product-v2/public/${n}`)).json()).data}async function transformProductData(n,t){const c=await getProductData(n,t);if(!c||c.skus.length===0)throw new Error("Product not found or no SKUs available");return{productData:{acceptsManageWallet:!0,commission:c.affiliate.commissionPercent||0,description:c.description,productTitle:c.title,royalty:c.skus[0].royalty||0,type:ProductType[c.type.toUpperCase()]||ProductType.DIGITAL},skuData:c.skus.map(ie=>{var se;return{amount:ie.inventory.quantity,imageUrl:((se=c.images[c.defaultImageIndex])==null?void 0:se.original)||"",skuID:ie.id,skuProperties:ie}})}}async function updateUris(n,t,c){return(await(await c.put(`web3/record/transactions/${n}/uris`,{json:{uris:t}})).json()).data}async function updateHash(n,t,c,ie){return(await(await ie.put(`web3/${n}/transactions/${t}/hash`,{json:{transactionHash:c}})).json()).data}async function getProductDataForRecord(n,t){if(!n)throw new InvalidParametersException(Chains.BASE,"Product ID is required");let c,ie=[];try{const{productData:se,skuData:ae}=await transformProductData(n,t);c=se,ie=ae}catch(se){throw new Error(`Failed to fetch product data: ${se}`)}if(!c||ie.length===0)throw new Error("Product not found or no SKUs available");return{productData:c,skuData:ie}}async function getNonce(n,t){return await(await t.get(`web3/auth/nonce?wallet=${n}`)).json()}async function getAddress(n,t,c){const ie=se=>se.charAt(0).toUpperCase()+se.slice(1).toLowerCase();try{const se=t===Network.TESTNET?"apiv3dev":"apiv3",ae=ie(n),ue=ie(Network[t]),de=`https://${se}.droplinked.com/storage/${ae}${ue}ContractAddress${c}`;return(await await ky.get(de).json()).value}catch(se){throw console.error(`Failed to fetch ${c.toLowerCase()} address:`,se),new Error(`Unable to get ${c.toLowerCase()} address`)}}async function getDeployerAddress(n,t){return getAddress(n,t,"Deployer")}async function getProxyAddress(n,t){return getAddress(n,t,"Proxy")}async function startPayment(n,t,c,ie,se){return(await(await se.post("web3/payment/transactions",{json:{network:c,token:t,shopId:ie,orderId:n}})).json()).data.id}async function getCartData(n,t,c,ie){const se=await(await ie.get(`web3/payment/distribution/${n}/${t}/${c}`)).json();return{paymentData:se.data,orderID:se.orderID}}async function getPurchaseSignature(n,t,c){const ie=await(await c.get(`nfts/by-order?orderId=${n}&skuId=${t}`)).json();return{signature:ie.purchaseSignature,shopContractAddress:ie.shopContractAddress,networkName:ie.networkName}}async function getShopByteCode(){try{return String((await await ky.get("https://apiv3dev.droplinked.com/storage/shopByteCodeType0").json()).value)}catch(n){throw console.error(`Failed to get shop bytecode: ${n}`),new Error("Unable to get shop bytecode")}}async function getShopDeployInfo(n,t){const c=(await(await t.get(`shops/v2/public/${n}`)).json()).data;return{name:c.name,description:c.description,logo:c.logo,url:c.url,deployedContracts:c.deployedContracts}}const shopABI=[{inputs:[{internalType:"string",name:"_shopName",type:"string"},{internalType:"string",name:"_shopAddress",type:"string"},{internalType:"address",name:"_shopOwner",type:"address"},{internalType:"string",name:"_shopLogo",type:"string"},{internalType:"string",name:"_shopDescription",type:"string"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"AccessDenied",type:"error"},{inputs:[],name:"AffiliatePOD",type:"error"},{inputs:[],name:"AlreadyClaimed",type:"error"},{inputs:[{internalType:"address",name:"requester",type:"address"},{internalType:"uint256",name:"productId",type:"uint256"}],name:"AlreadyRequested",type:"error"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"producer",type:"address"}],name:"NotEnoughTokens",type:"error"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"OwnableInvalidOwner",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"OwnableUnauthorizedAccount",type:"error"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"ProductDoesntExist",type:"error"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"ProductExists",type:"error"},{inputs:[],name:"ReentrancyGuardReentrantCall",type:"error"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"RequestAlreadyConfirmed",type:"error"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"RequestDoesntExist",type:"error"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"RequestNotConfirmed",type:"error"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"}],name:"ShopDoesNotOwnToken",type:"error"},{inputs:[],name:"oldPrice",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"requestId",type:"uint256"},{indexed:!0,internalType:"address",name:"approver",type:"address"}],name:"AffiliateRequestApproved",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"requestId",type:"uint256"},{indexed:!0,internalType:"address",name:"disapprover",type:"address"}],name:"AffiliateRequestDisapproved",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"requestId",type:"uint256"},{indexed:!0,internalType:"uint256",name:"productId",type:"uint256"},{indexed:!1,internalType:"address",name:"requester",type:"address"}],name:"AffiliateRequested",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"count",type:"uint256"}],name:"BatchProductRegistered",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"productId",type:"uint256"},{indexed:!0,internalType:"address",name:"claimer",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"ProductClaimed",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"productId",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!1,internalType:"string",name:"uri",type:"string"}],name:"ProductRegistered",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"productId",type:"uint256"},{indexed:!0,internalType:"address",name:"owner",type:"address"}],name:"ProductUnregistered",type:"event"},{inputs:[],name:"affiliateRequestCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"affiliateRequests",outputs:[{internalType:"address",name:"publisher",type:"address"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"bool",name:"isConfirmed",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"approveRequest",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"manager",type:"address"},{internalType:"bytes",name:"signature",type:"bytes"},{components:[{components:[{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"uint256",name:"nullifier",type:"uint256"}],internalType:"struct PurchasedItem[]",name:"cart",type:"tuple[]"},{internalType:"address",name:"shop",type:"address"}],internalType:"struct PurchaseSignature",name:"purchaseSignature",type:"tuple"}],name:"claimPurchase",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"disapproveRequest",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"droplinkedManagerWallet",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"requestId",type:"uint256"}],name:"getAffiliate",outputs:[{components:[{internalType:"address",name:"publisher",type:"address"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"bool",name:"isConfirmed",type:"bool"}],internalType:"struct AffiliateRequest",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[],name:"getAffiliateRequestCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"messageHash",type:"bytes32"}],name:"getEthSignedMessageHash",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"pure",type:"function"},{inputs:[{components:[{components:[{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"uint256",name:"nullifier",type:"uint256"}],internalType:"struct PurchasedItem[]",name:"cart",type:"tuple[]"},{internalType:"address",name:"shop",type:"address"}],internalType:"struct PurchaseSignature",name:"data",type:"tuple"}],name:"getMessageHash",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"getProduct",outputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],internalType:"struct Product",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[],name:"getProductCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],internalType:"struct Product",name:"product",type:"tuple"}],name:"getProductId",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"nftAddress",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getProductIdV2",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint256",name:"affiliateId",type:"uint256"}],name:"getProductViaAffiliateId",outputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],internalType:"struct Product",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopAddress",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopDescription",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopLogo",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopName",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"getShopOwner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"address",name:"requester",type:"address"}],name:"isRequestSubmited",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"managers",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"address",name:"nftAddress",type:"address"},{internalType:"string",name:"uri",type:"string"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bool",name:"accepted",type:"bool"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"},{internalType:"uint256",name:"royalty",type:"uint256"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"}],internalType:"struct RecordData",name:"mintData",type:"tuple"}],name:"mintAndRegister",outputs:[{internalType:"uint256",name:"productId",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"nftAddress",type:"address"},{internalType:"string",name:"uri",type:"string"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bool",name:"accepted",type:"bool"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"},{internalType:"uint256",name:"royalty",type:"uint256"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"}],internalType:"struct RecordData[]",name:"recordData",type:"tuple[]"}],name:"mintAndRegisterBatch",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"nullifiers",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC1155BatchReceived",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC1155Received",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC721Received",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"productCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"products",outputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"ethSignedMessageHash",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"recoverSigner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"pure",type:"function"},{inputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"nftAddress",type:"address"},{internalType:"enum NFTType",name:"nftType",type:"uint8"},{internalType:"enum ProductType",name:"productType",type:"uint8"},{internalType:"uint256",name:"affiliatePercentage",type:"uint256"}],internalType:"struct Product",name:"p",type:"tuple"}],name:"registerProduct",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"requestAffiliate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"manager",type:"address"}],name:"revokeManager",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"manager",type:"address"}],name:"setManager",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"shopInfo",outputs:[{internalType:"string",name:"shopName",type:"string"},{internalType:"string",name:"shopAddress",type:"string"},{internalType:"string",name:"shopLogo",type:"string"},{internalType:"string",name:"shopDescription",type:"string"},{internalType:"address",name:"shopOwner",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"sig",type:"bytes"}],name:"splitSignature",outputs:[{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"},{internalType:"uint8",name:"v",type:"uint8"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"newManager",type:"address"}],name:"transferManagerShip",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"productId",type:"uint256"}],name:"unregisterProduct",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newManagerWallet",type:"address"}],name:"updateDroplinkedManagerWallet",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"signer",type:"address"},{internalType:"bytes",name:"signature",type:"bytes"},{components:[{components:[{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint256",name:"productId",type:"uint256"},{internalType:"uint256",name:"nullifier",type:"uint256"}],internalType:"struct PurchasedItem[]",name:"cart",type:"tuple[]"},{internalType:"address",name:"shop",type:"address"}],internalType:"struct PurchaseSignature",name:"data",type:"tuple"}],name:"verifyPurchase",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"pure",type:"function"}];function getTransactionLink({blockchain:n,transactionHash:t,isTestnet:c=!1}){const ie=t.trim();switch(n.toUpperCase()){case"CASPER":return`https://${c?"testnet.":""}cspr.live/deploy/${ie}`;case"STACKS":return`https://explorer.hiro.so/txid/${ie}?chain=${c?"testnet":"mainnet"}`;case"POLYGON":return`https://${c?"amoy.":""}polygonscan.com/tx/${ie}`;case"XRPLSIDECHAIN":return`https://evm-sidechain.xrpl.org/tx/${ie}`;case"BINANCE":return`https://${c?"testnet.":""}bscscan.com/tx/${ie}`;case"NEAR":return`https://explorer.${c?"testnet":"mainnet"}.aurora.dev/tx/${ie}`;case"BASE":return`https://base${c?"-sepolia":""}.blockscout.com/tx/${ie}`;case"LINEA":return`https://${c?"sepolia.":""}lineascan.build/tx/${ie}`;case"ETH":return`https://${c?"sepolia.":""}etherscan.io/tx/${ie}`;case"SOLANA":return`https://explorer.solana.com/tx/${ie}?cluster=${c?"devnet":"mainnet"}`;case"REDBELLY":return c?`https://redbelly.testnet.routescan.io/tx/${ie}`:`https://redbelly.routescan.io/tx/${ie}`;case"SKALE":return`https://${c?"giant-half-dual-testnet.explorer.testnet.skalenodes.com":"honorable-steel-rasalhague.explorer.mainnet.skalenodes.com"}/tx/${ie}`;case"BITLAYER":return c?`https://testnet.btrscan.com/tx/${ie}`:`https://www.btrscan.com/tx/${ie}`;default:return""}}async function ensureWalletOnChainFromConfig(n,t,c){const ie=t[c];if(!ie)throw new Error(`Network config not found for ${t.name} (${c})`);const se=n.provider;if(!(se!=null&&se.request))throw new Error("Provider does not support network switching");const ae=await n.getNetwork(),ue=Number(ie.chainId);if(ae.chainId!==ue){try{await se.request({method:"wallet_switchEthereumChain",params:[{chainId:ie.chainId}]})}catch(de){if(de.code===4902)await se.request({method:"wallet_addEthereumChain",params:[{chainId:ie.chainId,chainName:ie.chainName,rpcUrls:ie.rpcUrls,nativeCurrency:ie.nativeCurrency}]});else throw de}if((await n.getNetwork()).chainId!==ue)throw new Error(`Failed to switch to ${t.name} (${c})`)}}function getBaseUrl(n){return n===Network.MAINNET?"https://apiv3.droplinked.com":n===Network.TESTNET?"https://apiv3dev.droplinked.com":"http://127.0.0.1:3000"}async function getGasPrice(n){return(await n.getGasPrice()).toBigInt()}const deployerABI=[{inputs:[],name:"InvalidInitialization",type:"error"},{inputs:[],name:"NotInitializing",type:"error"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"OwnableInvalidOwner",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"OwnableUnauthorizedAccount",type:"error"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"newFee",type:"uint256"}],name:"DroplinkedFeeUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"newHeartBeat",type:"uint256"}],name:"HeartBeatUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint64",name:"version",type:"uint64"}],name:"Initialized",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"shop",type:"address"},{indexed:!1,internalType:"address",name:"nftContract",type:"address"}],name:"ShopDeployed",type:"event"},{inputs:[{internalType:"bytes",name:"bytecode",type:"bytes"},{internalType:"bytes32",name:"salt",type:"bytes32"}],name:"deployShop",outputs:[{internalType:"address",name:"shop",type:"address"},{internalType:"address",name:"nftContract",type:"address"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"droplinkedFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"droplinkedWallet",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"getDroplinkedFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getHeartBeat",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"heartBeat",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"_heartBeat",type:"uint256"},{internalType:"address",name:"_droplinkedWallet",type:"address"},{internalType:"uint256",name:"_droplinkedFee",type:"uint256"}],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"nftContracts",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"shopOwner",type:"address"},{internalType:"uint256",name:"",type:"uint256"}],name:"nftOwners",outputs:[{internalType:"address",name:"nftContracts",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"newFee",type:"uint256"}],name:"setDroplinkedFee",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"newHeartBeat",type:"uint256"}],name:"setHeartBeat",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"shopAddresses",outputs:[{internalType:"contract IDropShop",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"shopCount",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"shopOwner",type:"address"},{internalType:"uint256",name:"",type:"uint256"}],name:"shopOwners",outputs:[{internalType:"address",name:"shops",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"}],sixify=n=>n.toString().padStart(6,"0");async function getConstructorArgs(n,t,c){return[n.shopName||"",n.shopAddress||"",c,n.shopLogo||"",n.shopDescription||"",t]}async function deployEVMShop(n,t,c){console.log({...n,...t,...c});const{modalInterface:ie}=t,{chain:se,network:ae,provider:ue}=n,de=ue.getSigner(),ve=await getDeployerAddress(se,ae),ge=new Contract(ve,deployerABI,de),we=await getShopByteCode(),Te=await de.getAddress(),Ne="0x"+Te.split("0x")[1]+"000000000000000000"+sixify(Math.floor(Math.random()*1e6)+1),qe=await getConstructorArgs(c,ve,Te),ze=defaultAbiCoder.encode(["string","string","address","string","string","address"],qe);try{let He;const Ge=we+ze.split("0x")[1];console.log({fullBytecode:Ge}),n.chain!==Chains.SKALE?(await ge.callStatic.deployShop(Ge,Ne),He=await ge.deployShop(Ge,Ne,{})):He=await ge.deployShop(Ge,Ne);const Ze=(await He.wait()).logs.map(Mt=>{try{return ge.interface.parseLog(Mt)}catch{return null}}).filter(Mt=>Mt!=null).find(Mt=>Mt.name==="ShopDeployed"),Ye=Ze.args.shop,Ft=Ze.args.nftContract;return{transactionHash:He.hash,deployedShopAddress:Ye,deployedNFTAddress:Ft}}catch(He){if(ie.error("Error during shop deployment",`${He.message||He}`),He.code.toString()==="ACTION_REJECTED")throw new UserDeniedException("Deployer");try{const Ge=ge.interface.parseError(He.data);throw ie.error("Contract error",`${Ge}`),Ge}catch(Ge){throw ie.error("Unhandled error during shop deployment.",`${Ge||He}`),new Error(Ge||"Unknown error occurred.")}}}function getRecordData(n,t,c){const{acceptsManageWallet:ie,amount:se,royalty:ae,type:ue}=n;return{nftAddress:c,uri:t,amount:se,accepted:ie,affiliatePercentage:ae,royalty:ae,nftType:NFTType.ERC1155,productType:ue}}async function prepareRecordData(n,t,c,ie){const{nftContract:se}=ie;if(!se)throw new InvalidParametersException(n.chain,"nftContract");const{description:ae}=c,{skuID:ue}=t,de={...t,...c},ve={...de.skuProperties},ge={name:de.productTitle,description:ae,image:de.imageUrl,properties:ve},we=await uploadMetadata(ge,ue,ie.axiosInstance);return getRecordData(de,we,se)}async function doRecordProduct(n,t,c,ie){const{modalInterface:se,nftContract:ae,shopContractAddress:ue}=t;if(!ae||!ue)throw se.error("Invalid Parameters","nftContract||shopContractAddress"),new InvalidParametersException(n.chain,"nftContract||shopContractAddress");se.changeStep("Connecting to wallet");const de=n.provider.getSigner(),ve=new Contract(ue,shopABI,de);try{se.changeStep("Preparing products for recording");const ge=await Promise.all(ie.map(Te=>prepareRecordData(n,Te,c,t)));let we;return n.chain!==Chains.SKALE?(await ve.callStatic.mintAndRegisterBatch(ge),se.changeStep("Recording products on blockchain"),we=await ve.mintAndRegisterBatch(ge)):(se.changeStep("Recording products on blockchain"),we=await ve.mintAndRegisterBatch(ge)),se.changeStep("Waiting for transaction confirmation"),await we.wait(),{transactionHash:we.hash,metadataUrls:ge.map(Te=>Te.uri)}}catch(ge){if(ge.code&&ge.code.toString()==="ACTION_REJECTED")throw t.modalInterface.error("Transaction Rejected","ACTION_REJECTED"),new Error("Transaction Rejected");try{if(ge.data&&ge.data!=="0x"){const we=ve.interface.parseError(ge.data);throw we.name==="OwnableUnauthorizedAccount"?(t.modalInterface.error("Unauthorized","OwnableUnauthorizedAccount"),new Unauthorized(n.chain,"record",await de.getAddress(),ue)):(t.modalInterface.error(we.name,we.args.join(", ")),t.modalInterface.error(ge,we.name),ge)}else throw se.error("Transaction reverted without reason",`${ge}`),ge}catch(we){throw se.error("Unexpected error",`${we}`),we}}}async function recordProduct({productId:n,chain:t,axiosInstance:c,shopId:ie,network:se,stepizer:ae,provider:ue}){let de="",ve="";if(ae.changeStep("Starting record process"),ie!==""){const qe=await getShopInfo(t,ie,c);de=qe.nftContractAddress,ve=qe.shopContractAddress}const ge=new Web3Provider(ue,"any");if(!de||!ve){ae.changeStep("Deploying shop contract");const qe={chain:t,network:se,provider:ge},ze={axiosInstance:c,modalInterface:ae,nftContract:"",shopContractAddress:""},{description:He,logo:Ge,name:Ze,url:Ye,deployedContracts:Ft}=await getShopDeployInfo(ie,c),{deployedNFTAddress:Mt,deployedShopAddress:Zt,transactionHash:cn}=await deployEVMShop(qe,ze,{shopName:Ze,shopAddress:Ye,shopLogo:Ge,shopDescription:He}),hn=[...Ft||[],{type:t,deployedShopAddress:Zt,transactionId:cn,deployedNFTAddress:Mt,isCircle:!1,platform:"DROPLINKED",status:"SUCCESS"}];console.log({newDeployedContracts:hn}),de=Mt,ve=Zt,ae.changeStep("Shop deployed successfully")}await ensureWalletOnChainFromConfig(ge,getChainByName(t),se);const{productData:we,skuData:Te}=await getProductDataForRecord(n,c);if(!ie)throw new InvalidParametersException(t,"shopId");const Ne=await startRecord(n,Te.map(qe=>qe.skuID),ie,t,[],c);try{const qe=await doRecordProduct({chain:t,network:se,provider:ge},{axiosInstance:c,modalInterface:ae,nftContract:de,shopContractAddress:ve},we,Te);await updateUris(Ne,qe.metadataUrls,c),await updateHash("record",Ne,qe.transactionHash,c);const ze=`${getBaseUrl(se)}/web3/record/callback/events/${Ne}`;if(!await web3Callback(qe.transactionHash,t,Network[se],ze))throw new Web3CallbackFailedException("Record");return{...qe,transactionId:Ne,transactionHashUrl:getTransactionLink({blockchain:t,transactionHash:qe.transactionHash,isTestnet:se!==Network.MAINNET})}}catch(qe){throw console.error("Error during recording process:",qe),await deleteRecordTransaction(Ne,c),qe}}var utils$e={};const require$$0$3=getAugmentedNamespace(lib_esm$b),require$$1$2=getAugmentedNamespace(lib_esm$f),require$$2$3=getAugmentedNamespace(lib_esm$d),require$$3=getAugmentedNamespace(lib_esm$8),require$$4$3=getAugmentedNamespace(lib_esm$j),require$$5=getAugmentedNamespace(lib_esm$c),require$$6$2=getAugmentedNamespace(lib_esm$6),require$$7=getAugmentedNamespace(lib_esm$4),require$$8=getAugmentedNamespace(lib_esm$h),require$$9=getAugmentedNamespace(lib_esm$k),require$$10=getAugmentedNamespace(lib_esm$7),require$$11$1=getAugmentedNamespace(lib_esm$1),require$$12=getAugmentedNamespace(lib_esm$5),require$$13=getAugmentedNamespace(lib_esm$i),require$$14=getAugmentedNamespace(lib_esm$g),require$$15=getAugmentedNamespace(lib_esm$a),require$$16=getAugmentedNamespace(lib_esm$e),require$$17$1=getAugmentedNamespace(lib_esm$9),require$$18=getAugmentedNamespace(lib_esm),require$$19=getAugmentedNamespace(lib_esm$3),require$$20=getAugmentedNamespace(lib_esm$2);(function(n){var t=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(le,pe,be,xe){xe===void 0&&(xe=be),Object.defineProperty(le,xe,{enumerable:!0,get:function(){return pe[be]}})}:function(le,pe,be,xe){xe===void 0&&(xe=be),le[xe]=pe[be]}),c=commonjsGlobal&&commonjsGlobal.__setModuleDefault||(Object.create?function(le,pe){Object.defineProperty(le,"default",{enumerable:!0,value:pe})}:function(le,pe){le.default=pe}),ie=commonjsGlobal&&commonjsGlobal.__importStar||function(le){if(le&&le.__esModule)return le;var pe={};if(le!=null)for(var be in le)be!=="default"&&Object.prototype.hasOwnProperty.call(le,be)&&t(pe,le,be);return c(pe,le),pe};Object.defineProperty(n,"__esModule",{value:!0}),n.formatBytes32String=n.Utf8ErrorFuncs=n.toUtf8String=n.toUtf8CodePoints=n.toUtf8Bytes=n._toEscapedUtf8String=n.nameprep=n.hexDataSlice=n.hexDataLength=n.hexZeroPad=n.hexValue=n.hexStripZeros=n.hexConcat=n.isHexString=n.hexlify=n.base64=n.base58=n.TransactionDescription=n.LogDescription=n.Interface=n.SigningKey=n.HDNode=n.defaultPath=n.isBytesLike=n.isBytes=n.zeroPad=n.stripZeros=n.concat=n.arrayify=n.shallowCopy=n.resolveProperties=n.getStatic=n.defineReadOnly=n.deepCopy=n.checkProperties=n.poll=n.fetchJson=n._fetchData=n.RLP=n.Logger=n.checkResultErrors=n.FormatTypes=n.ParamType=n.FunctionFragment=n.EventFragment=n.ErrorFragment=n.ConstructorFragment=n.Fragment=n.defaultAbiCoder=n.AbiCoder=void 0,n.Indexed=n.Utf8ErrorReason=n.UnicodeNormalizationForm=n.SupportedAlgorithm=n.mnemonicToSeed=n.isValidMnemonic=n.entropyToMnemonic=n.mnemonicToEntropy=n.getAccountPath=n.verifyTypedData=n.verifyMessage=n.recoverPublicKey=n.computePublicKey=n.recoverAddress=n.computeAddress=n.getJsonWalletAddress=n.TransactionTypes=n.serializeTransaction=n.parseTransaction=n.accessListify=n.joinSignature=n.splitSignature=n.soliditySha256=n.solidityKeccak256=n.solidityPack=n.shuffled=n.randomBytes=n.sha512=n.sha256=n.ripemd160=n.keccak256=n.computeHmac=n.commify=n.parseUnits=n.formatUnits=n.parseEther=n.formatEther=n.isAddress=n.getCreate2Address=n.getContractAddress=n.getIcapAddress=n.getAddress=n._TypedDataEncoder=n.id=n.isValidName=n.namehash=n.hashMessage=n.dnsEncode=n.parseBytes32String=void 0;var se=require$$0$3;Object.defineProperty(n,"AbiCoder",{enumerable:!0,get:function(){return se.AbiCoder}}),Object.defineProperty(n,"checkResultErrors",{enumerable:!0,get:function(){return se.checkResultErrors}}),Object.defineProperty(n,"ConstructorFragment",{enumerable:!0,get:function(){return se.ConstructorFragment}}),Object.defineProperty(n,"defaultAbiCoder",{enumerable:!0,get:function(){return se.defaultAbiCoder}}),Object.defineProperty(n,"ErrorFragment",{enumerable:!0,get:function(){return se.ErrorFragment}}),Object.defineProperty(n,"EventFragment",{enumerable:!0,get:function(){return se.EventFragment}}),Object.defineProperty(n,"FormatTypes",{enumerable:!0,get:function(){return se.FormatTypes}}),Object.defineProperty(n,"Fragment",{enumerable:!0,get:function(){return se.Fragment}}),Object.defineProperty(n,"FunctionFragment",{enumerable:!0,get:function(){return se.FunctionFragment}}),Object.defineProperty(n,"Indexed",{enumerable:!0,get:function(){return se.Indexed}}),Object.defineProperty(n,"Interface",{enumerable:!0,get:function(){return se.Interface}}),Object.defineProperty(n,"LogDescription",{enumerable:!0,get:function(){return se.LogDescription}}),Object.defineProperty(n,"ParamType",{enumerable:!0,get:function(){return se.ParamType}}),Object.defineProperty(n,"TransactionDescription",{enumerable:!0,get:function(){return se.TransactionDescription}});var ae=require$$1$2;Object.defineProperty(n,"getAddress",{enumerable:!0,get:function(){return ae.getAddress}}),Object.defineProperty(n,"getCreate2Address",{enumerable:!0,get:function(){return ae.getCreate2Address}}),Object.defineProperty(n,"getContractAddress",{enumerable:!0,get:function(){return ae.getContractAddress}}),Object.defineProperty(n,"getIcapAddress",{enumerable:!0,get:function(){return ae.getIcapAddress}}),Object.defineProperty(n,"isAddress",{enumerable:!0,get:function(){return ae.isAddress}});var ue=ie(require$$2$3);n.base64=ue;var de=require$$3;Object.defineProperty(n,"base58",{enumerable:!0,get:function(){return de.Base58}});var ve=require$$4$3;Object.defineProperty(n,"arrayify",{enumerable:!0,get:function(){return ve.arrayify}}),Object.defineProperty(n,"concat",{enumerable:!0,get:function(){return ve.concat}}),Object.defineProperty(n,"hexConcat",{enumerable:!0,get:function(){return ve.hexConcat}}),Object.defineProperty(n,"hexDataSlice",{enumerable:!0,get:function(){return ve.hexDataSlice}}),Object.defineProperty(n,"hexDataLength",{enumerable:!0,get:function(){return ve.hexDataLength}}),Object.defineProperty(n,"hexlify",{enumerable:!0,get:function(){return ve.hexlify}}),Object.defineProperty(n,"hexStripZeros",{enumerable:!0,get:function(){return ve.hexStripZeros}}),Object.defineProperty(n,"hexValue",{enumerable:!0,get:function(){return ve.hexValue}}),Object.defineProperty(n,"hexZeroPad",{enumerable:!0,get:function(){return ve.hexZeroPad}}),Object.defineProperty(n,"isBytes",{enumerable:!0,get:function(){return ve.isBytes}}),Object.defineProperty(n,"isBytesLike",{enumerable:!0,get:function(){return ve.isBytesLike}}),Object.defineProperty(n,"isHexString",{enumerable:!0,get:function(){return ve.isHexString}}),Object.defineProperty(n,"joinSignature",{enumerable:!0,get:function(){return ve.joinSignature}}),Object.defineProperty(n,"zeroPad",{enumerable:!0,get:function(){return ve.zeroPad}}),Object.defineProperty(n,"splitSignature",{enumerable:!0,get:function(){return ve.splitSignature}}),Object.defineProperty(n,"stripZeros",{enumerable:!0,get:function(){return ve.stripZeros}});var ge=require$$5;Object.defineProperty(n,"_TypedDataEncoder",{enumerable:!0,get:function(){return ge._TypedDataEncoder}}),Object.defineProperty(n,"dnsEncode",{enumerable:!0,get:function(){return ge.dnsEncode}}),Object.defineProperty(n,"hashMessage",{enumerable:!0,get:function(){return ge.hashMessage}}),Object.defineProperty(n,"id",{enumerable:!0,get:function(){return ge.id}}),Object.defineProperty(n,"isValidName",{enumerable:!0,get:function(){return ge.isValidName}}),Object.defineProperty(n,"namehash",{enumerable:!0,get:function(){return ge.namehash}});var we=require$$6$2;Object.defineProperty(n,"defaultPath",{enumerable:!0,get:function(){return we.defaultPath}}),Object.defineProperty(n,"entropyToMnemonic",{enumerable:!0,get:function(){return we.entropyToMnemonic}}),Object.defineProperty(n,"getAccountPath",{enumerable:!0,get:function(){return we.getAccountPath}}),Object.defineProperty(n,"HDNode",{enumerable:!0,get:function(){return we.HDNode}}),Object.defineProperty(n,"isValidMnemonic",{enumerable:!0,get:function(){return we.isValidMnemonic}}),Object.defineProperty(n,"mnemonicToEntropy",{enumerable:!0,get:function(){return we.mnemonicToEntropy}}),Object.defineProperty(n,"mnemonicToSeed",{enumerable:!0,get:function(){return we.mnemonicToSeed}});var Te=require$$7;Object.defineProperty(n,"getJsonWalletAddress",{enumerable:!0,get:function(){return Te.getJsonWalletAddress}});var Ne=require$$8;Object.defineProperty(n,"keccak256",{enumerable:!0,get:function(){return Ne.keccak256}});var qe=require$$9;Object.defineProperty(n,"Logger",{enumerable:!0,get:function(){return qe.Logger}});var ze=require$$10;Object.defineProperty(n,"computeHmac",{enumerable:!0,get:function(){return ze.computeHmac}}),Object.defineProperty(n,"ripemd160",{enumerable:!0,get:function(){return ze.ripemd160}}),Object.defineProperty(n,"sha256",{enumerable:!0,get:function(){return ze.sha256}}),Object.defineProperty(n,"sha512",{enumerable:!0,get:function(){return ze.sha512}});var He=require$$11$1;Object.defineProperty(n,"solidityKeccak256",{enumerable:!0,get:function(){return He.keccak256}}),Object.defineProperty(n,"solidityPack",{enumerable:!0,get:function(){return He.pack}}),Object.defineProperty(n,"soliditySha256",{enumerable:!0,get:function(){return He.sha256}});var Ge=require$$12;Object.defineProperty(n,"randomBytes",{enumerable:!0,get:function(){return Ge.randomBytes}}),Object.defineProperty(n,"shuffled",{enumerable:!0,get:function(){return Ge.shuffled}});var Ze=require$$13;Object.defineProperty(n,"checkProperties",{enumerable:!0,get:function(){return Ze.checkProperties}}),Object.defineProperty(n,"deepCopy",{enumerable:!0,get:function(){return Ze.deepCopy}}),Object.defineProperty(n,"defineReadOnly",{enumerable:!0,get:function(){return Ze.defineReadOnly}}),Object.defineProperty(n,"getStatic",{enumerable:!0,get:function(){return Ze.getStatic}}),Object.defineProperty(n,"resolveProperties",{enumerable:!0,get:function(){return Ze.resolveProperties}}),Object.defineProperty(n,"shallowCopy",{enumerable:!0,get:function(){return Ze.shallowCopy}});var Ye=ie(require$$14);n.RLP=Ye;var Ft=require$$15;Object.defineProperty(n,"computePublicKey",{enumerable:!0,get:function(){return Ft.computePublicKey}}),Object.defineProperty(n,"recoverPublicKey",{enumerable:!0,get:function(){return Ft.recoverPublicKey}}),Object.defineProperty(n,"SigningKey",{enumerable:!0,get:function(){return Ft.SigningKey}});var Mt=require$$16;Object.defineProperty(n,"formatBytes32String",{enumerable:!0,get:function(){return Mt.formatBytes32String}}),Object.defineProperty(n,"nameprep",{enumerable:!0,get:function(){return Mt.nameprep}}),Object.defineProperty(n,"parseBytes32String",{enumerable:!0,get:function(){return Mt.parseBytes32String}}),Object.defineProperty(n,"_toEscapedUtf8String",{enumerable:!0,get:function(){return Mt._toEscapedUtf8String}}),Object.defineProperty(n,"toUtf8Bytes",{enumerable:!0,get:function(){return Mt.toUtf8Bytes}}),Object.defineProperty(n,"toUtf8CodePoints",{enumerable:!0,get:function(){return Mt.toUtf8CodePoints}}),Object.defineProperty(n,"toUtf8String",{enumerable:!0,get:function(){return Mt.toUtf8String}}),Object.defineProperty(n,"Utf8ErrorFuncs",{enumerable:!0,get:function(){return Mt.Utf8ErrorFuncs}});var Zt=require$$17$1;Object.defineProperty(n,"accessListify",{enumerable:!0,get:function(){return Zt.accessListify}}),Object.defineProperty(n,"computeAddress",{enumerable:!0,get:function(){return Zt.computeAddress}}),Object.defineProperty(n,"parseTransaction",{enumerable:!0,get:function(){return Zt.parse}}),Object.defineProperty(n,"recoverAddress",{enumerable:!0,get:function(){return Zt.recoverAddress}}),Object.defineProperty(n,"serializeTransaction",{enumerable:!0,get:function(){return Zt.serialize}}),Object.defineProperty(n,"TransactionTypes",{enumerable:!0,get:function(){return Zt.TransactionTypes}});var cn=require$$18;Object.defineProperty(n,"commify",{enumerable:!0,get:function(){return cn.commify}}),Object.defineProperty(n,"formatEther",{enumerable:!0,get:function(){return cn.formatEther}}),Object.defineProperty(n,"parseEther",{enumerable:!0,get:function(){return cn.parseEther}}),Object.defineProperty(n,"formatUnits",{enumerable:!0,get:function(){return cn.formatUnits}}),Object.defineProperty(n,"parseUnits",{enumerable:!0,get:function(){return cn.parseUnits}});var hn=require$$19;Object.defineProperty(n,"verifyMessage",{enumerable:!0,get:function(){return hn.verifyMessage}}),Object.defineProperty(n,"verifyTypedData",{enumerable:!0,get:function(){return hn.verifyTypedData}});var yn=require$$20;Object.defineProperty(n,"_fetchData",{enumerable:!0,get:function(){return yn._fetchData}}),Object.defineProperty(n,"fetchJson",{enumerable:!0,get:function(){return yn.fetchJson}}),Object.defineProperty(n,"poll",{enumerable:!0,get:function(){return yn.poll}});var Ht=require$$10;Object.defineProperty(n,"SupportedAlgorithm",{enumerable:!0,get:function(){return Ht.SupportedAlgorithm}});var Sn=require$$16;Object.defineProperty(n,"UnicodeNormalizationForm",{enumerable:!0,get:function(){return Sn.UnicodeNormalizationForm}}),Object.defineProperty(n,"Utf8ErrorReason",{enumerable:!0,get:function(){return Sn.Utf8ErrorReason}})})(utils$e);const ZERO_ADDRESS="0x0000000000000000000000000000000000000000",SkaleUsdcAddressForTestnet="0x2aebcdc4f9f9149a50422fff86198cb0939ea165",SkaleUsdcAddressForMainnet="0x7Cf76E740Cb23b99337b21F392F22c47Ad910c67",erc20ABI=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"allowance",type:"uint256"},{internalType:"uint256",name:"needed",type:"uint256"}],name:"ERC20InsufficientAllowance",type:"error"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"uint256",name:"balance",type:"uint256"},{internalType:"uint256",name:"needed",type:"uint256"}],name:"ERC20InsufficientBalance",type:"error"},{inputs:[{internalType:"address",name:"approver",type:"address"}],name:"ERC20InvalidApprover",type:"error"},{inputs:[{internalType:"address",name:"receiver",type:"address"}],name:"ERC20InvalidReceiver",type:"error"},{inputs:[{internalType:"address",name:"sender",type:"address"}],name:"ERC20InvalidSender",type:"error"},{inputs:[{internalType:"address",name:"spender",type:"address"}],name:"ERC20InvalidSpender",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"}],paymentProxyABI=[{inputs:[{internalType:"uint256",name:"_heartBeat",type:"uint256"},{internalType:"address",name:"_chainLinkProvider",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"OwnableInvalidOwner",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"OwnableUnauthorizedAccount",type:"error"},{inputs:[{internalType:"uint256",name:"priceTimestamp",type:"uint256"},{internalType:"uint256",name:"currentTimestamp",type:"uint256"}],name:"oldPrice",type:"error"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"newHeartBeat",type:"uint256"}],name:"HeartBeatChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"ProductPurchased",type:"event"},{inputs:[{internalType:"uint256",name:"_heartBeat",type:"uint256"}],name:"changeHeartBeat",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256[]",name:"tbdValues",type:"uint256[]"},{internalType:"address[]",name:"tbdReceivers",type:"address[]"},{internalType:"address",name:"currency",type:"address"},{internalType:"uint80",name:"roundId",type:"uint80"},{internalType:"string",name:"memo",type:"string"}],name:"droplinkedPurchase",outputs:[],stateMutability:"payable",type:"function"},{inputs:[],name:"heartBeat",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"}];async function handleCustomTokenApproval(n,t,c,ie,se){if(!n.tokenAddress)throw new InvalidParametersException(Chains.BASE,"Token address is not set");try{const ae=new Contract(n.tokenAddress,erc20ABI,c),ue=await ae.balanceOf(ie),de=n.tbdValues.reduce((ge,we)=>ge.add(BigNumber.from(we)),BigNumber.from(0));if(ue.lt(de))throw new InsufficientBalanceException;se.changeStep("Approving token");const ve=await ae.approve(t,MaxUint256$1);se.changeStep("awaiting confirmation"),await ve.wait(),se.changeStep("Token approval confirmed")}catch(ae){handleError(ae,se)}}const droplinkedPayment=async function(n,t,c){const{modalInterface:ie}=t,{provider:se,chain:ae,network:ue}=n;if(!c.tbdReceivers.every(utils$e.isAddress))throw new InvalidParametersException(ae,"Invalid receiver address found");c.chainLinkRoundId=c.chainLinkRoundId||"0";const de=c.tokenAddress&&c.tokenAddress!==ZERO_ADDRESS;if(de){if(!c.tbdValues.every(Ne=>BigNumber.from(Ne).gt(0)))throw new InvalidParametersException(ae,"tbdValues must be positive numbers")}else if(!c.tbdValues.every(Ne=>Ne>0))throw new InvalidParametersException(ae,"tbdValues must be positive numbers");const ve=se.getSigner(),ge=await ve.getAddress();if(!c.tbdValues)throw new InvalidParametersException(ae,`Invalid tbdValues: ${c.tbdValues}`);if(!c.tbdReceivers)throw new InvalidParametersException(ae,`Invalid tbdReceivers: ${c.tbdReceivers}`);if(!c.memo)throw new InvalidParametersException(ae,`Memo is required for payment, current memo: ${c.memo}`);if(c.tbdReceivers.length!==c.tbdValues.length)throw new InvalidParametersException(ae,"tbdReceivers and tbdValues must be the same length");let we;try{we=await getProxyAddress(ae,ue)}catch(Ne){throw new Error("Failed to get contract address: "+Ne.message)}let Te;try{Te=new Contract(we,paymentProxyABI,ve)}catch(Ne){throw new Error("Failed to create contract instance: "+Ne.message)}try{if(console.log(`
14
14
  Purchase Details:
15
15
  data.tbdValues: ${c.tbdValues}
16
16
  data.tbdReceivers: ${c.tbdReceivers}
@@ -18,7 +18,7 @@ See https://react.dev/link/invalid-hook-call for tips about how to debug and fix
18
18
  data.chainLinkRoundId: ${c.chainLinkRoundId}
19
19
  data.memo: ${c.memo}
20
20
  data.totalPrice: ${Number(c.totalPrice)}
21
- `),ae===Chains.SKALE)return await skalePayment(c,ue,ve,Te,ge,we,ie);de?await handleCustomTokenApproval(c,we,ve,ge,ie):c.tbdValues=c.tbdValues.map(Ft=>parseInt(Ft.toString(),10));try{await Te.callStatic.droplinkedPurchase(c.tbdValues,c.tbdReceivers,c.tokenAddress,c.chainLinkRoundId,c.memo,{value:de?BigNumber.from(0):c.totalPrice})}catch(Ft){throw new Error("Transaction will fail: "+Ft.message)}let Ne;try{Ne=await getGasPrice(se)}catch(Ft){throw new Error("Failed to get gas price: "+Ft.message)}let qe;try{qe=await Te.estimateGas.droplinkedPurchase(c.tbdValues,c.tbdReceivers,c.tokenAddress,c.chainLinkRoundId,c.memo,{value:de?BigNumber.from(0):c.totalPrice})}catch(Ft){throw new Error(`Gas estimation failed: ${Ft.message}. Please check the transaction parameters.`)}const ze=qe.mul(105).div(100),He=de?BigNumber.from(0):BigNumber.from(c.totalPrice);let Ge;try{Ge=await se.getBalance(ge)}catch(Ft){throw new Error("Failed to get user balance: "+Ft.message)}const Ze=He.add(ze.mul(Ne));if(Ge.lt(Ze))throw new InsufficientBalanceException;ie.changeStep("Sending Payment Transaction");const Ye=await Te.droplinkedPurchase(c.tbdValues,c.tbdReceivers,c.tokenAddress,c.chainLinkRoundId,c.memo,{gasLimit:ze,value:de?BigNumber.from(0):c.totalPrice});return ie.changeStep("Awaiting transaction"),await Ye.wait(),ie.success("Payment Successful"),{transactionHash:Ye.hash,cryptoAmount:c.totalPrice}}catch(Ne){handleError(Ne)}},skalePayment=async function(n,t,c,ie,se,ae,ue){try{const de=t===Network.TESTNET?SkaleUsdcAddressForTestnet:SkaleUsdcAddressForMainnet;return n.tokenAddress=de,await handleCustomTokenApproval(n,ae,c,se,ue),{transactionHash:(await ie.droplinkedPurchase(n.tbdValues,n.tbdReceivers,de,"0",n.memo)).hash,cryptoAmount:n.totalPrice}}catch(de){handleError(de)}};function handleError(n){var t;throw n instanceof Error?((t=n.code)==null?void 0:t.toString())==="ACTION_REJECTED"||n.message.includes("User denied")||n.message.includes("User cancelled transaction")?new UserDeniedException("Metamask*"):n.message.includes("insufficient funds")||n.message.includes("gas * price + value")||n.code==="INSUFFICIENT_FUNDS"?new InsufficientBalanceException:n:new Error("An unknown error occurred")}async function payment({chain:n,orderID:t,paymentToken:c,axiosInstance:ie,shopId:se,network:ae,provider:ue,stepizer:de}){const ve=new Web3Provider(ue,"any");if(await ensureWalletOnChainFromConfig(ve,getChainByName(n),ae),!se)throw new InvalidParametersException(n,"shopId not found");const ge=await startPayment(t,c,n,se,ie),we=await getCartData(t,c,n,ie),Te=we.paymentData,Ne=await droplinkedPayment({chain:n,network:ae,provider:ve},{modalInterface:de},Te);if(await updateHash("payment",ge,Ne.transactionHash,ie),!await web3Callback(Ne.transactionHash,n,Network[ae],`${getBaseUrl(ae)}/web3/payment/callback/${ge}/${Ne.transactionHash}`))throw new Web3CallbackFailedException(Actions.Payment);return{...Ne,orderID:we.orderID,transactionId:ge}}const DROPLINKED_MANAGER="0x2F86E1B1A69D259b9609b40E3cbEBEa29946f979";async function doClaimNFT(n,t,c){const{modalInterface:ie}=c,se=t.provider.getSigner();ie.changeStep("Claiming NFTs");const ae=new Contract(c.shopContractAddress,shopABI,se);try{console.log(DROPLINKED_MANAGER,n.signature.signature,{cart:n.signature.purchaseData.map(ve=>({amount:ve.amount,productId:ve.productId,nullifier:ve.nullifier})),shop:c.shopContractAddress});const ue=n.signature.purchaseData.map(ve=>({amount:ve.amount,productId:BigNumber.from(ve.productId),nullifier:BigNumber.from(ve.nullifier)}));ie.changeStep("Sending Transaction");const de=await ae.claimPurchase(DROPLINKED_MANAGER,n.signature.signature,{cart:ue,shop:c.shopContractAddress});return ie.changeStep("Waiting for confirmation"),await de.wait(),ie.changeStep("NFT Claimed!"),{transactionHash:de.hash}}catch(ue){if(console.error(ue),ue.code&&ue.code.toString()==="ACTION_REJECTED")throw c.modalInterface.error("Transaction Rejected","Transaction Rejected by the user"),new UserDeniedException("Transaction Rejected");try{const de=ae.interface.parseError(ue.data);throw de.name==="OwnableUnauthorizedAccount"&&c.modalInterface.error(de.name,de.name),c.modalInterface.error(ue,ue),ue}catch(de){throw ie.error("Unexpected error occurred",`An unexpected error occurred: ${de}`),de}}}async function claimNFT({provider:n,axiosInstance:t,stepizer:c,orderId:ie,skuId:se,network:ae}){const ue=new Web3Provider(n,"any"),{shopContractAddress:de,signature:ve,networkName:ge}=await getPurchaseSignature(ie,se,t);return await ensureWalletOnChainFromConfig(ue,getChainByName(ge),ae),await doClaimNFT({signature:ve},{provider:ue},{axiosInstance:t,modalInterface:c,nftContract:"",shopContractAddress:de})}class EVMBaseWallet extends Web3Wallet{constructor(t,c){super(t.wallet,t.group,c),this.provider=null,this.cfg=t}async initializeProvider(){this.provider=await getEvmProviderByWalletName(this.cfg.wallet),console.log(`Initialized ${this.name} EVM Provider.`)}async login({chain:t,network:c}){if(!this.provider)throw this.stepizer.error("Provider Error","Provider not initialized"),new ProviderException(this.name);try{this.stepizer.changeStep("Connecting to wallet..."),console.log(`Login on ${t} ${c}`);const ie=await this.provider.request({method:"eth_requestAccounts"});if(!Array.isArray(ie)||ie.length===0)throw new ProviderException("Evm Wallet");return this.stepizer.success("Wallet connected"),{address:ie[0]}}catch(ie){throw console.error(ie),ie instanceof UserDeniedException?(this.stepizer.error("User denied the request",""),ie):(this.stepizer.error("An error occurred while connecting to the wallet",""),ie)}}async isWalletConnected(){if(!this.provider)return!1;try{const t=await this.provider.request({method:"eth_accounts"});return Array.isArray(t)&&t.length>0}catch{return!1}}async getConnectedAccounts(){if(!this.provider)return[];const t=await this.provider.request({method:"eth_accounts"});return Array.isArray(t)?t:[]}async recordProduct({productId:t,chain:c,axiosInstance:ie,shopId:se,network:ae}){if(console.log(`Recording for ${t} on ${c}`),!this.provider)throw this.stepizer.error("Provider Error","Provider not initialized"),new ProviderException(this.name);return recordProduct({axiosInstance:ie,chain:c,network:ae,productId:t,provider:this.provider,shopId:se,stepizer:this.stepizer})}async auth({chain:t,network:c,axiosInstance:ie}){if(console.log(`Authentication process ${t}`),!this.provider)throw this.stepizer.error("Provider Error","Provider not initialized"),new ProviderException(this.name);const se=this.provider,ae=this.stepizer,ue=new Web3Provider(this.provider,"any");try{if(ae.changeStep("Connecting to wallet..."),!await this.isWalletConnected())try{return await se.request({method:"eth_requestAccounts"})}catch(Ne){throw console.error(Ne),new UserDeniedException(this.name)}const de=(await this.login({chain:t,network:c})).address;ae.changeStep("Signing message...");const ve=await getNonce(de,ie),ge=new Date().toLocaleString(),we=`Welcome to Droplinked! Please sign this message to verify your ownership over your wallet and log in. - Nonce: ${ve} - Date: ${ge}`,Te=await ue.getSigner().signMessage(we);return ae.success("Authentication successful!"),{address:de,signature:Te,nonce:ve,date:ge}}catch(de){throw console.error(de),de instanceof UserDeniedException?(ae.error("User denied the request",""),de):(ae.error("An error occurred while connecting to the wallet",""),de)}}async claimNFT({orderId:t,skuId:c,axiosInstance:ie,network:se}){if(console.log(`ClaimNFT process for order: ${t} - sku: ${c}`),!this.provider)throw this.stepizer.error("Provider Error","Provider not initialized"),new ProviderException(this.name);return claimNFT({axiosInstance:ie,network:se,orderId:t,provider:this.provider,skuId:c,stepizer:this.stepizer})}async payment({chain:t,network:c,orderID:ie,paymentToken:se,shopId:ae,axiosInstance:ue}){if(!this.supportsToken(t,se))throw new TokenNotSupportedException(this.name,se);if(this.stepizer.changeStep("Starting payment process"),!this.provider)throw this.stepizer.error("Provider Error","Provider not initialized"),new ProviderException(this.name);return await payment({axiosInstance:ue,chain:t,network:c,orderID:ie,paymentToken:se,provider:this.provider,shopId:ae,stepizer:this.stepizer})}async isWalletInstalled(){let t=!1;const c=this.name;function ie(se){var ae,ue;const de=se.detail;((ue=(ae=de?.info)==null?void 0:ae.name)==null?void 0:ue.toLowerCase())===c.toLowerCase()&&(t=!0)}return window.addEventListener("eip6963:announceProvider",ie),window.dispatchEvent(new Event("eip6963:requestProvider")),await new Promise(se=>setTimeout(se,700)),window.removeEventListener("eip6963:announceProvider",ie),t}getInstallationLink(){return this.cfg.installationLink}}var Wallets=(n=>(n.Metamask="Metamask",n.Phantom="Phantom",n.TrustWallet="Trust Wallet",n.UnstoppableDomains="Unstoppable Domains",n.XION="Xion",n))(Wallets||{});class MetamaskEVMWallet extends EVMBaseWallet{constructor(t){super({group:Groups.EVM,installationLink:{website:"https://metamask.io/download",chrome:"https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn",firefox:"https://addons.mozilla.org/en-US/firefox/addon/ether-metamask/"},wallet:Wallets.Metamask},t)}supportsToken(t,c){return console.log(`Checking support for ${c} on ${t}`),!!this.supportsChain(t)}supportsChain(t){return isChainInGroup(t,Groups.EVM)}}var __classPrivateFieldGet=function(n,t,c,ie){if(typeof t=="function"?n!==t||!ie:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return c==="m"?ie:c==="a"?ie.call(n):ie?ie.value:t.get(n)},__classPrivateFieldSet=function(n,t,c,ie,se){if(typeof t=="function"?n!==t||!0:!t.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(n,c),c},_AppReadyEvent_detail;let wallets;const registeredWalletsSet=new Set;function addRegisteredWallet(n){cachedWalletsArray=void 0,registeredWalletsSet.add(n)}function removeRegisteredWallet(n){cachedWalletsArray=void 0,registeredWalletsSet.delete(n)}const listeners={};function getWallets(){if(wallets||(wallets=Object.freeze({register,get:get$1,on:on$1}),typeof window>"u"))return wallets;const n=Object.freeze({register});try{window.addEventListener("wallet-standard:register-wallet",({detail:t})=>t(n))}catch(t){console.error(`wallet-standard:register-wallet event listener could not be added
21
+ `),ae===Chains.SKALE)return await skalePayment(c,ue,ve,Te,ge,we,ie);de?await handleCustomTokenApproval(c,we,ve,ge,ie):c.tbdValues=c.tbdValues.map(Ft=>parseInt(Ft.toString(),10));try{await Te.callStatic.droplinkedPurchase(c.tbdValues,c.tbdReceivers,c.tokenAddress,c.chainLinkRoundId,c.memo,{value:de?BigNumber.from(0):c.totalPrice})}catch(Ft){throw new Error("Transaction will fail: "+Ft.message)}let Ne;try{Ne=await getGasPrice(se)}catch(Ft){throw new Error("Failed to get gas price: "+Ft.message)}let qe;try{qe=await Te.estimateGas.droplinkedPurchase(c.tbdValues,c.tbdReceivers,c.tokenAddress,c.chainLinkRoundId,c.memo,{value:de?BigNumber.from(0):c.totalPrice})}catch(Ft){throw new Error(`Gas estimation failed: ${Ft.message}. Please check the transaction parameters.`)}const ze=qe.mul(105).div(100),He=de?BigNumber.from(0):BigNumber.from(c.totalPrice);let Ge;try{Ge=await se.getBalance(ge)}catch(Ft){throw new Error("Failed to get user balance: "+Ft.message)}const Ze=He.add(ze.mul(Ne));if(Ge.lt(Ze))throw new InsufficientBalanceException;ie.changeStep("Sending Payment Transaction");const Ye=await Te.droplinkedPurchase(c.tbdValues,c.tbdReceivers,c.tokenAddress,c.chainLinkRoundId,c.memo,{gasLimit:ze,value:de?BigNumber.from(0):c.totalPrice});return ie.changeStep("Awaiting transaction"),await Ye.wait(),ie.success("Payment Successful"),{transactionHash:Ye.hash,cryptoAmount:c.totalPrice}}catch(Ne){handleError(Ne,ie)}},skalePayment=async function(n,t,c,ie,se,ae,ue){try{const de=t===Network.TESTNET?SkaleUsdcAddressForTestnet:SkaleUsdcAddressForMainnet;return n.tokenAddress=de,await handleCustomTokenApproval(n,ae,c,se,ue),{transactionHash:(await ie.droplinkedPurchase(n.tbdValues,n.tbdReceivers,de,"0",n.memo)).hash,cryptoAmount:n.totalPrice}}catch(de){handleError(de,ue)}};function handleError(n,t){var c;throw n instanceof Error?((c=n.code)==null?void 0:c.toString())==="ACTION_REJECTED"||n.message.includes("User denied")||n.message.includes("User cancelled transaction")?(t.error("Transaction rejected by user","User Denied"),new UserDeniedException("Metamask*")):n.message.includes("insufficient funds")||n.message.includes("gas * price + value")||n.code==="INSUFFICIENT_FUNDS"?(t.error("Insufficient balance to complete the transaction","Insufficient Balance"),new InsufficientBalanceException):n:(t.error("An unknown error occurred","Unknown Error"),new Error("An unknown error occurred"))}async function payment({chain:n,orderID:t,paymentToken:c,axiosInstance:ie,shopId:se,network:ae,provider:ue,stepizer:de}){const ve=new Web3Provider(ue,"any");if(await ensureWalletOnChainFromConfig(ve,getChainByName(n),ae),!se)throw new InvalidParametersException(n,"shopId not found");const ge=await startPayment(t,c,n,se,ie),we=await getCartData(t,c,n,ie),Te=we.paymentData,Ne=await droplinkedPayment({chain:n,network:ae,provider:ve},{modalInterface:de},Te);if(await updateHash("payment",ge,Ne.transactionHash,ie),!await web3Callback(Ne.transactionHash,n,Network[ae],`${getBaseUrl(ae)}/web3/payment/callback/${ge}/${Ne.transactionHash}`))throw new Web3CallbackFailedException(Actions.Payment);return{...Ne,orderID:we.orderID,transactionId:ge}}const DROPLINKED_MANAGER="0x2F86E1B1A69D259b9609b40E3cbEBEa29946f979";async function doClaimNFT(n,t,c){const{modalInterface:ie}=c,se=t.provider.getSigner();ie.changeStep("Claiming NFTs");const ae=new Contract(c.shopContractAddress,shopABI,se);try{console.log(DROPLINKED_MANAGER,n.signature.signature,{cart:n.signature.purchaseData.map(ve=>({amount:ve.amount,productId:ve.productId,nullifier:ve.nullifier})),shop:c.shopContractAddress});const ue=n.signature.purchaseData.map(ve=>({amount:ve.amount,productId:BigNumber.from(ve.productId),nullifier:BigNumber.from(ve.nullifier)}));ie.changeStep("Sending Transaction");const de=await ae.claimPurchase(DROPLINKED_MANAGER,n.signature.signature,{cart:ue,shop:c.shopContractAddress});return ie.changeStep("Waiting for confirmation"),await de.wait(),ie.changeStep("NFT Claimed!"),{transactionHash:de.hash}}catch(ue){if(console.error(ue),ue.code&&ue.code.toString()==="ACTION_REJECTED")throw c.modalInterface.error("Transaction Rejected","Transaction Rejected by the user"),new UserDeniedException("Transaction Rejected");try{const de=ae.interface.parseError(ue.data);throw de.name==="OwnableUnauthorizedAccount"&&c.modalInterface.error(de.name,de.name),c.modalInterface.error(ue,ue),ue}catch(de){throw ie.error("Unexpected error occurred",`An unexpected error occurred: ${de}`),de}}}async function claimNFT({provider:n,axiosInstance:t,stepizer:c,orderId:ie,skuId:se,network:ae}){const ue=new Web3Provider(n,"any"),{shopContractAddress:de,signature:ve,networkName:ge}=await getPurchaseSignature(ie,se,t);return await ensureWalletOnChainFromConfig(ue,getChainByName(ge),ae),await doClaimNFT({signature:ve},{provider:ue},{axiosInstance:t,modalInterface:c,nftContract:"",shopContractAddress:de})}class EVMBaseWallet extends Web3Wallet{constructor(t,c){super(t.wallet,t.group,c),this.provider=null,this.cfg=t}async initializeProvider(){this.provider=await getEvmProviderByWalletName(this.cfg.wallet),console.log(`Initialized ${this.name} EVM Provider.`)}async login({chain:t,network:c}){if(!this.provider)throw this.stepizer.error("Provider Error","Provider not initialized"),new ProviderException(this.name);try{this.stepizer.changeStep("Connecting to wallet..."),console.log(`Login on ${t} ${c}`);const ie=await this.provider.request({method:"eth_requestAccounts"});if(!Array.isArray(ie)||ie.length===0)throw new ProviderException("Evm Wallet");return this.stepizer.success("Wallet connected"),{address:ie[0]}}catch(ie){throw console.error(ie),ie instanceof UserDeniedException?(this.stepizer.error("User denied the request",""),ie):(this.stepizer.error("An error occurred while connecting to the wallet",""),ie)}}async isWalletConnected(){if(!this.provider)return!1;try{const t=await this.provider.request({method:"eth_accounts"});return Array.isArray(t)&&t.length>0}catch{return!1}}async getConnectedAccounts(){if(!this.provider)return[];const t=await this.provider.request({method:"eth_accounts"});return Array.isArray(t)?t:[]}async recordProduct({productId:t,chain:c,axiosInstance:ie,shopId:se,network:ae}){if(console.log(`Recording for ${t} on ${c}`),!this.provider)throw this.stepizer.error("Provider Error","Provider not initialized"),new ProviderException(this.name);return recordProduct({axiosInstance:ie,chain:c,network:ae,productId:t,provider:this.provider,shopId:se,stepizer:this.stepizer})}async auth({chain:t,network:c,axiosInstance:ie}){if(console.log(`Authentication process ${t}`),!this.provider)throw this.stepizer.error("Provider Error","Provider not initialized"),new ProviderException(this.name);const se=this.provider,ae=this.stepizer,ue=new Web3Provider(this.provider,"any");try{if(ae.changeStep("Connecting to wallet..."),!await this.isWalletConnected())try{return await se.request({method:"eth_requestAccounts"})}catch(Ne){throw console.error(Ne),new UserDeniedException(this.name)}const de=(await this.login({chain:t,network:c})).address;ae.changeStep("Signing message...");const ve=await getNonce(de,ie),ge=new Date().toLocaleString(),we=`Welcome to Droplinked! Please sign this message to verify your ownership over your wallet and log in. - Nonce: ${ve} - Date: ${ge}`,Te=await ue.getSigner().signMessage(we);return ae.success("Authentication successful!"),{address:de,signature:Te,nonce:ve,date:ge}}catch(de){throw console.error(de),de instanceof UserDeniedException?(ae.error("User denied the request",""),de):(ae.error("An error occurred while connecting to the wallet",""),de)}}async claimNFT({orderId:t,skuId:c,axiosInstance:ie,network:se}){if(console.log(`ClaimNFT process for order: ${t} - sku: ${c}`),!this.provider)throw this.stepizer.error("Provider Error","Provider not initialized"),new ProviderException(this.name);return claimNFT({axiosInstance:ie,network:se,orderId:t,provider:this.provider,skuId:c,stepizer:this.stepizer})}async payment({chain:t,network:c,orderID:ie,paymentToken:se,shopId:ae,axiosInstance:ue}){if(!this.supportsToken(t,se))throw new TokenNotSupportedException(this.name,se);if(this.stepizer.changeStep("Starting payment process"),!this.provider)throw this.stepizer.error("Provider Error","Provider not initialized"),new ProviderException(this.name);return await payment({axiosInstance:ue,chain:t,network:c,orderID:ie,paymentToken:se,provider:this.provider,shopId:ae,stepizer:this.stepizer})}async isWalletInstalled(){let t=!1;const c=this.name;function ie(se){var ae,ue;const de=se.detail;((ue=(ae=de?.info)==null?void 0:ae.name)==null?void 0:ue.toLowerCase())===c.toLowerCase()&&(t=!0)}return window.addEventListener("eip6963:announceProvider",ie),window.dispatchEvent(new Event("eip6963:requestProvider")),await new Promise(se=>setTimeout(se,700)),window.removeEventListener("eip6963:announceProvider",ie),t}getInstallationLink(){return this.cfg.installationLink}}var Wallets=(n=>(n.Metamask="Metamask",n.Phantom="Phantom",n.TrustWallet="Trust Wallet",n.UnstoppableDomains="Unstoppable Domains",n.XION="Xion",n))(Wallets||{});class MetamaskEVMWallet extends EVMBaseWallet{constructor(t){super({group:Groups.EVM,installationLink:{website:"https://metamask.io/download",chrome:"https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn",firefox:"https://addons.mozilla.org/en-US/firefox/addon/ether-metamask/"},wallet:Wallets.Metamask},t)}supportsToken(t,c){return console.log(`Checking support for ${c} on ${t}`),!!this.supportsChain(t)}supportsChain(t){return isChainInGroup(t,Groups.EVM)}}var __classPrivateFieldGet=function(n,t,c,ie){if(typeof t=="function"?n!==t||!ie:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return c==="m"?ie:c==="a"?ie.call(n):ie?ie.value:t.get(n)},__classPrivateFieldSet=function(n,t,c,ie,se){if(typeof t=="function"?n!==t||!0:!t.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(n,c),c},_AppReadyEvent_detail;let wallets;const registeredWalletsSet=new Set;function addRegisteredWallet(n){cachedWalletsArray=void 0,registeredWalletsSet.add(n)}function removeRegisteredWallet(n){cachedWalletsArray=void 0,registeredWalletsSet.delete(n)}const listeners={};function getWallets(){if(wallets||(wallets=Object.freeze({register,get:get$1,on:on$1}),typeof window>"u"))return wallets;const n=Object.freeze({register});try{window.addEventListener("wallet-standard:register-wallet",({detail:t})=>t(n))}catch(t){console.error(`wallet-standard:register-wallet event listener could not be added
22
22
  `,t)}try{window.dispatchEvent(new AppReadyEvent(n))}catch(t){console.error(`wallet-standard:app-ready event could not be dispatched
23
23
  `,t)}return wallets}function register(...n){var t;return n=n.filter(c=>!registeredWalletsSet.has(c)),n.length?(n.forEach(c=>addRegisteredWallet(c)),(t=listeners.register)==null||t.forEach(c=>guard(()=>c(...n))),function(){var c;n.forEach(ie=>removeRegisteredWallet(ie)),(c=listeners.unregister)==null||c.forEach(ie=>guard(()=>ie(...n)))}):()=>{}}let cachedWalletsArray;function get$1(){return cachedWalletsArray||(cachedWalletsArray=[...registeredWalletsSet]),cachedWalletsArray}function on$1(n,t){var c;return(c=listeners[n])!=null&&c.push(t)||(listeners[n]=[t]),function(){var ie;listeners[n]=(ie=listeners[n])==null?void 0:ie.filter(se=>t!==se)}}function guard(n){try{n()}catch(t){console.error(t)}}class AppReadyEvent extends Event{get detail(){return __classPrivateFieldGet(this,_AppReadyEvent_detail,"f")}get type(){return"wallet-standard:app-ready"}constructor(t){super("wallet-standard:app-ready",{bubbles:!1,cancelable:!1,composed:!1}),_AppReadyEvent_detail.set(this,void 0),__classPrivateFieldSet(this,_AppReadyEvent_detail,t)}preventDefault(){throw new Error("preventDefault cannot be called")}stopImmediatePropagation(){throw new Error("stopImmediatePropagation cannot be called")}stopPropagation(){throw new Error("stopPropagation cannot be called")}}_AppReadyEvent_detail=new WeakMap;const crypto$2=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function isBytes(n){return n instanceof Uint8Array||ArrayBuffer.isView(n)&&n.constructor.name==="Uint8Array"}function anumber(n){if(!Number.isSafeInteger(n)||n<0)throw new Error("positive integer expected, got "+n)}function abytes(n,...t){if(!isBytes(n))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(n.length))throw new Error("Uint8Array expected of length "+t+", got length="+n.length)}function ahash(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");anumber(n.outputLen),anumber(n.blockLen)}function aexists(n,t=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(t&&n.finished)throw new Error("Hash#digest() has already been called")}function aoutput(n,t){abytes(n);const c=t.outputLen;if(n.length<c)throw new Error("digestInto() expects output buffer of length at least "+c)}function clean(...n){for(let t=0;t<n.length;t++)n[t].fill(0)}function createView(n){return new DataView(n.buffer,n.byteOffset,n.byteLength)}function rotr(n,t){return n<<32-t|n>>>t}const hasHexBuiltin=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",hexes=Array.from({length:256},(n,t)=>t.toString(16).padStart(2,"0"));function bytesToHex(n){if(abytes(n),hasHexBuiltin)return n.toHex();let t="";for(let c=0;c<n.length;c++)t+=hexes[n[c]];return t}const asciis={_0:48,_9:57,A:65,F:70,a:97,f:102};function asciiToBase16(n){if(n>=asciis._0&&n<=asciis._9)return n-asciis._0;if(n>=asciis.A&&n<=asciis.F)return n-(asciis.A-10);if(n>=asciis.a&&n<=asciis.f)return n-(asciis.a-10)}function hexToBytes(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);if(hasHexBuiltin)return Uint8Array.fromHex(n);const t=n.length,c=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const ie=new Uint8Array(c);for(let se=0,ae=0;se<c;se++,ae+=2){const ue=asciiToBase16(n.charCodeAt(ae)),de=asciiToBase16(n.charCodeAt(ae+1));if(ue===void 0||de===void 0){const ve=n[ae]+n[ae+1];throw new Error('hex string expected, got non-hex character "'+ve+'" at index '+ae)}ie[se]=ue*16+de}return ie}function utf8ToBytes(n){if(typeof n!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(n))}function toBytes(n){return typeof n=="string"&&(n=utf8ToBytes(n)),abytes(n),n}function concatBytes(...n){let t=0;for(let ie=0;ie<n.length;ie++){const se=n[ie];abytes(se),t+=se.length}const c=new Uint8Array(t);for(let ie=0,se=0;ie<n.length;ie++){const ae=n[ie];c.set(ae,se),se+=ae.length}return c}class Hash{}function createHasher(n){const t=ie=>n().update(toBytes(ie)).digest(),c=n();return t.outputLen=c.outputLen,t.blockLen=c.blockLen,t.create=()=>n(),t}function randomBytes(n=32){if(crypto$2&&typeof crypto$2.getRandomValues=="function")return crypto$2.getRandomValues(new Uint8Array(n));if(crypto$2&&typeof crypto$2.randomBytes=="function")return Uint8Array.from(crypto$2.randomBytes(n));throw new Error("crypto.getRandomValues must be defined")}function setBigUint64(n,t,c,ie){if(typeof n.setBigUint64=="function")return n.setBigUint64(t,c,ie);const se=BigInt(32),ae=BigInt(4294967295),ue=Number(c>>se&ae),de=Number(c&ae),ve=ie?4:0,ge=ie?0:4;n.setUint32(t+ve,ue,ie),n.setUint32(t+ge,de,ie)}function Chi(n,t,c){return n&t^~n&c}function Maj(n,t,c){return n&t^n&c^t&c}class HashMD extends Hash{constructor(t,c,ie,se){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=c,this.padOffset=ie,this.isLE=se,this.buffer=new Uint8Array(t),this.view=createView(this.buffer)}update(t){aexists(this),t=toBytes(t),abytes(t);const{view:c,buffer:ie,blockLen:se}=this,ae=t.length;for(let ue=0;ue<ae;){const de=Math.min(se-this.pos,ae-ue);if(de===se){const ve=createView(t);for(;se<=ae-ue;ue+=se)this.process(ve,ue);continue}ie.set(t.subarray(ue,ue+de),this.pos),this.pos+=de,ue+=de,this.pos===se&&(this.process(c,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){aexists(this),aoutput(t,this),this.finished=!0;const{buffer:c,view:ie,blockLen:se,isLE:ae}=this;let{pos:ue}=this;c[ue++]=128,clean(this.buffer.subarray(ue)),this.padOffset>se-ue&&(this.process(ie,0),ue=0);for(let Te=ue;Te<se;Te++)c[Te]=0;setBigUint64(ie,se-8,BigInt(this.length*8),ae),this.process(ie,0);const de=createView(t),ve=this.outputLen;if(ve%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const ge=ve/4,we=this.get();if(ge>we.length)throw new Error("_sha2: outputLen bigger than state");for(let Te=0;Te<ge;Te++)de.setUint32(4*Te,we[Te],ae)}digest(){const{buffer:t,outputLen:c}=this;this.digestInto(t);const ie=t.slice(0,c);return this.destroy(),ie}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:c,buffer:ie,length:se,finished:ae,destroyed:ue,pos:de}=this;return t.destroyed=ue,t.finished=ae,t.length=se,t.pos=de,se%c&&t.buffer.set(ie),t}clone(){return this._cloneInto()}}const SHA256_IV=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),SHA512_IV=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),U32_MASK64=BigInt(2**32-1),_32n=BigInt(32);function fromBig(n,t=!1){return t?{h:Number(n&U32_MASK64),l:Number(n>>_32n&U32_MASK64)}:{h:Number(n>>_32n&U32_MASK64)|0,l:Number(n&U32_MASK64)|0}}function split(n,t=!1){const c=n.length;let ie=new Uint32Array(c),se=new Uint32Array(c);for(let ae=0;ae<c;ae++){const{h:ue,l:de}=fromBig(n[ae],t);[ie[ae],se[ae]]=[ue,de]}return[ie,se]}const shrSH=(n,t,c)=>n>>>c,shrSL=(n,t,c)=>n<<32-c|t>>>c,rotrSH=(n,t,c)=>n>>>c|t<<32-c,rotrSL=(n,t,c)=>n<<32-c|t>>>c,rotrBH=(n,t,c)=>n<<64-c|t>>>c-32,rotrBL=(n,t,c)=>n>>>c-32|t<<64-c;function add$2(n,t,c,ie){const se=(t>>>0)+(ie>>>0);return{h:n+c+(se/2**32|0)|0,l:se|0}}const add3L=(n,t,c)=>(n>>>0)+(t>>>0)+(c>>>0),add3H=(n,t,c,ie)=>t+c+ie+(n/2**32|0)|0,add4L=(n,t,c,ie)=>(n>>>0)+(t>>>0)+(c>>>0)+(ie>>>0),add4H=(n,t,c,ie,se)=>t+c+ie+se+(n/2**32|0)|0,add5L=(n,t,c,ie,se)=>(n>>>0)+(t>>>0)+(c>>>0)+(ie>>>0)+(se>>>0),add5H=(n,t,c,ie,se,ae)=>t+c+ie+se+ae+(n/2**32|0)|0,SHA256_K=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),SHA256_W=new Uint32Array(64);class SHA256 extends HashMD{constructor(t=32){super(64,t,8,!1),this.A=SHA256_IV[0]|0,this.B=SHA256_IV[1]|0,this.C=SHA256_IV[2]|0,this.D=SHA256_IV[3]|0,this.E=SHA256_IV[4]|0,this.F=SHA256_IV[5]|0,this.G=SHA256_IV[6]|0,this.H=SHA256_IV[7]|0}get(){const{A:t,B:c,C:ie,D:se,E:ae,F:ue,G:de,H:ve}=this;return[t,c,ie,se,ae,ue,de,ve]}set(t,c,ie,se,ae,ue,de,ve){this.A=t|0,this.B=c|0,this.C=ie|0,this.D=se|0,this.E=ae|0,this.F=ue|0,this.G=de|0,this.H=ve|0}process(t,c){for(let Te=0;Te<16;Te++,c+=4)SHA256_W[Te]=t.getUint32(c,!1);for(let Te=16;Te<64;Te++){const Ne=SHA256_W[Te-15],qe=SHA256_W[Te-2],ze=rotr(Ne,7)^rotr(Ne,18)^Ne>>>3,He=rotr(qe,17)^rotr(qe,19)^qe>>>10;SHA256_W[Te]=He+SHA256_W[Te-7]+ze+SHA256_W[Te-16]|0}let{A:ie,B:se,C:ae,D:ue,E:de,F:ve,G:ge,H:we}=this;for(let Te=0;Te<64;Te++){const Ne=rotr(de,6)^rotr(de,11)^rotr(de,25),qe=we+Ne+Chi(de,ve,ge)+SHA256_K[Te]+SHA256_W[Te]|0,ze=(rotr(ie,2)^rotr(ie,13)^rotr(ie,22))+Maj(ie,se,ae)|0;we=ge,ge=ve,ve=de,de=ue+qe|0,ue=ae,ae=se,se=ie,ie=qe+ze|0}ie=ie+this.A|0,se=se+this.B|0,ae=ae+this.C|0,ue=ue+this.D|0,de=de+this.E|0,ve=ve+this.F|0,ge=ge+this.G|0,we=we+this.H|0,this.set(ie,se,ae,ue,de,ve,ge,we)}roundClean(){clean(SHA256_W)}destroy(){this.set(0,0,0,0,0,0,0,0),clean(this.buffer)}}const K512=split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(n=>BigInt(n))),SHA512_Kh=K512[0],SHA512_Kl=K512[1],SHA512_W_H=new Uint32Array(80),SHA512_W_L=new Uint32Array(80);class SHA512 extends HashMD{constructor(t=64){super(128,t,16,!1),this.Ah=SHA512_IV[0]|0,this.Al=SHA512_IV[1]|0,this.Bh=SHA512_IV[2]|0,this.Bl=SHA512_IV[3]|0,this.Ch=SHA512_IV[4]|0,this.Cl=SHA512_IV[5]|0,this.Dh=SHA512_IV[6]|0,this.Dl=SHA512_IV[7]|0,this.Eh=SHA512_IV[8]|0,this.El=SHA512_IV[9]|0,this.Fh=SHA512_IV[10]|0,this.Fl=SHA512_IV[11]|0,this.Gh=SHA512_IV[12]|0,this.Gl=SHA512_IV[13]|0,this.Hh=SHA512_IV[14]|0,this.Hl=SHA512_IV[15]|0}get(){const{Ah:t,Al:c,Bh:ie,Bl:se,Ch:ae,Cl:ue,Dh:de,Dl:ve,Eh:ge,El:we,Fh:Te,Fl:Ne,Gh:qe,Gl:ze,Hh:He,Hl:Ge}=this;return[t,c,ie,se,ae,ue,de,ve,ge,we,Te,Ne,qe,ze,He,Ge]}set(t,c,ie,se,ae,ue,de,ve,ge,we,Te,Ne,qe,ze,He,Ge){this.Ah=t|0,this.Al=c|0,this.Bh=ie|0,this.Bl=se|0,this.Ch=ae|0,this.Cl=ue|0,this.Dh=de|0,this.Dl=ve|0,this.Eh=ge|0,this.El=we|0,this.Fh=Te|0,this.Fl=Ne|0,this.Gh=qe|0,this.Gl=ze|0,this.Hh=He|0,this.Hl=Ge|0}process(t,c){for(let Ft=0;Ft<16;Ft++,c+=4)SHA512_W_H[Ft]=t.getUint32(c),SHA512_W_L[Ft]=t.getUint32(c+=4);for(let Ft=16;Ft<80;Ft++){const Mt=SHA512_W_H[Ft-15]|0,Zt=SHA512_W_L[Ft-15]|0,cn=rotrSH(Mt,Zt,1)^rotrSH(Mt,Zt,8)^shrSH(Mt,Zt,7),hn=rotrSL(Mt,Zt,1)^rotrSL(Mt,Zt,8)^shrSL(Mt,Zt,7),yn=SHA512_W_H[Ft-2]|0,Ht=SHA512_W_L[Ft-2]|0,Sn=rotrSH(yn,Ht,19)^rotrBH(yn,Ht,61)^shrSH(yn,Ht,6),le=rotrSL(yn,Ht,19)^rotrBL(yn,Ht,61)^shrSL(yn,Ht,6),pe=add4L(hn,le,SHA512_W_L[Ft-7],SHA512_W_L[Ft-16]),be=add4H(pe,cn,Sn,SHA512_W_H[Ft-7],SHA512_W_H[Ft-16]);SHA512_W_H[Ft]=be|0,SHA512_W_L[Ft]=pe|0}let{Ah:ie,Al:se,Bh:ae,Bl:ue,Ch:de,Cl:ve,Dh:ge,Dl:we,Eh:Te,El:Ne,Fh:qe,Fl:ze,Gh:He,Gl:Ge,Hh:Ze,Hl:Ye}=this;for(let Ft=0;Ft<80;Ft++){const Mt=rotrSH(Te,Ne,14)^rotrSH(Te,Ne,18)^rotrBH(Te,Ne,41),Zt=rotrSL(Te,Ne,14)^rotrSL(Te,Ne,18)^rotrBL(Te,Ne,41),cn=Te&qe^~Te&He,hn=Ne&ze^~Ne&Ge,yn=add5L(Ye,Zt,hn,SHA512_Kl[Ft],SHA512_W_L[Ft]),Ht=add5H(yn,Ze,Mt,cn,SHA512_Kh[Ft],SHA512_W_H[Ft]),Sn=yn|0,le=rotrSH(ie,se,28)^rotrBH(ie,se,34)^rotrBH(ie,se,39),pe=rotrSL(ie,se,28)^rotrBL(ie,se,34)^rotrBL(ie,se,39),be=ie&ae^ie&de^ae&de,xe=se&ue^se&ve^ue&ve;Ze=He|0,Ye=Ge|0,He=qe|0,Ge=ze|0,qe=Te|0,ze=Ne|0,{h:Te,l:Ne}=add$2(ge|0,we|0,Ht|0,Sn|0),ge=de|0,we=ve|0,de=ae|0,ve=ue|0,ae=ie|0,ue=se|0;const _e=add3L(Sn,pe,xe);ie=add3H(_e,Ht,le,be),se=_e|0}({h:ie,l:se}=add$2(this.Ah|0,this.Al|0,ie|0,se|0)),{h:ae,l:ue}=add$2(this.Bh|0,this.Bl|0,ae|0,ue|0),{h:de,l:ve}=add$2(this.Ch|0,this.Cl|0,de|0,ve|0),{h:ge,l:we}=add$2(this.Dh|0,this.Dl|0,ge|0,we|0),{h:Te,l:Ne}=add$2(this.Eh|0,this.El|0,Te|0,Ne|0),{h:qe,l:ze}=add$2(this.Fh|0,this.Fl|0,qe|0,ze|0),{h:He,l:Ge}=add$2(this.Gh|0,this.Gl|0,He|0,Ge|0),{h:Ze,l:Ye}=add$2(this.Hh|0,this.Hl|0,Ze|0,Ye|0),this.set(ie,se,ae,ue,de,ve,ge,we,Te,Ne,qe,ze,He,Ge,Ze,Ye)}roundClean(){clean(SHA512_W_H,SHA512_W_L)}destroy(){clean(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const sha256$5=createHasher(()=>new SHA256),sha512$3=createHasher(()=>new SHA512);const _0n$4=BigInt(0),_1n$5=BigInt(1);function _abool2(n,t=""){if(typeof n!="boolean"){const c=t&&`"${t}"`;throw new Error(c+"expected boolean, got type="+typeof n)}return n}function _abytes2(n,t,c=""){const ie=isBytes(n),se=n?.length,ae=t!==void 0;if(!ie||ae&&se!==t){const ue=c&&`"${c}" `,de=ae?` of length ${t}`:"",ve=ie?`length=${se}`:`type=${typeof n}`;throw new Error(ue+"expected Uint8Array"+de+", got "+ve)}return n}function numberToHexUnpadded(n){const t=n.toString(16);return t.length&1?"0"+t:t}function hexToNumber(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);return n===""?_0n$4:BigInt("0x"+n)}function bytesToNumberBE(n){return hexToNumber(bytesToHex(n))}function bytesToNumberLE(n){return abytes(n),hexToNumber(bytesToHex(Uint8Array.from(n).reverse()))}function numberToBytesBE(n,t){return hexToBytes(n.toString(16).padStart(t*2,"0"))}function numberToBytesLE(n,t){return numberToBytesBE(n,t).reverse()}function ensureBytes(n,t,c){let ie;if(typeof t=="string")try{ie=hexToBytes(t)}catch(ae){throw new Error(n+" must be hex string or Uint8Array, cause: "+ae)}else if(isBytes(t))ie=Uint8Array.from(t);else throw new Error(n+" must be hex string or Uint8Array");const se=ie.length;if(typeof c=="number"&&se!==c)throw new Error(n+" of length "+c+" expected, got "+se);return ie}function copyBytes(n){return Uint8Array.from(n)}const isPosBig=n=>typeof n=="bigint"&&_0n$4<=n;function inRange$1(n,t,c){return isPosBig(n)&&isPosBig(t)&&isPosBig(c)&&t<=n&&n<c}function aInRange(n,t,c,ie){if(!inRange$1(t,c,ie))throw new Error("expected valid "+n+": "+c+" <= n < "+ie+", got "+t)}function bitLen(n){let t;for(t=0;n>_0n$4;n>>=_1n$5,t+=1);return t}const bitMask=n=>(_1n$5<<BigInt(n))-_1n$5;function createHmacDrbg(n,t,c){if(typeof n!="number"||n<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof c!="function")throw new Error("hmacFn must be a function");const ie=Ne=>new Uint8Array(Ne),se=Ne=>Uint8Array.of(Ne);let ae=ie(n),ue=ie(n),de=0;const ve=()=>{ae.fill(1),ue.fill(0),de=0},ge=(...Ne)=>c(ue,ae,...Ne),we=(Ne=ie(0))=>{ue=ge(se(0),Ne),ae=ge(),Ne.length!==0&&(ue=ge(se(1),Ne),ae=ge())},Te=()=>{if(de++>=1e3)throw new Error("drbg: tried 1000 values");let Ne=0;const qe=[];for(;Ne<t;){ae=ge();const ze=ae.slice();qe.push(ze),Ne+=ae.length}return concatBytes(...qe)};return(Ne,qe)=>{ve(),we(Ne);let ze;for(;!(ze=qe(Te()));)we();return ve(),ze}}function _validateObject(n,t,c={}){if(!n||typeof n!="object")throw new Error("expected valid options object");function ie(se,ae,ue){const de=n[se];if(ue&&de===void 0)return;const ve=typeof de;if(ve!==ae||de===null)throw new Error(`param "${se}" is invalid: expected ${ae}, got ${ve}`)}Object.entries(t).forEach(([se,ae])=>ie(se,ae,!1)),Object.entries(c).forEach(([se,ae])=>ie(se,ae,!0))}function memoized(n){const t=new WeakMap;return(c,...ie)=>{const se=t.get(c);if(se!==void 0)return se;const ae=n(c,...ie);return t.set(c,ae),ae}}const _0n$3=BigInt(0),_1n$4=BigInt(1),_2n$4=BigInt(2),_3n$1=BigInt(3),_4n$1=BigInt(4),_5n$1=BigInt(5),_7n=BigInt(7),_8n$2=BigInt(8),_9n=BigInt(9),_16n=BigInt(16);function mod$1(n,t){const c=n%t;return c>=_0n$3?c:t+c}function pow2(n,t,c){let ie=n;for(;t-- >_0n$3;)ie*=ie,ie%=c;return ie}function invert(n,t){if(n===_0n$3)throw new Error("invert: expected non-zero number");if(t<=_0n$3)throw new Error("invert: expected positive modulus, got "+t);let c=mod$1(n,t),ie=t,se=_0n$3,ae=_1n$4;for(;c!==_0n$3;){const ue=ie/c,de=ie%c,ve=se-ae*ue;ie=c,c=de,se=ae,ae=ve}if(ie!==_1n$4)throw new Error("invert: does not exist");return mod$1(se,t)}function assertIsSquare(n,t,c){if(!n.eql(n.sqr(t),c))throw new Error("Cannot find square root")}function sqrt3mod4(n,t){const c=(n.ORDER+_1n$4)/_4n$1,ie=n.pow(t,c);return assertIsSquare(n,ie,t),ie}function sqrt5mod8(n,t){const c=(n.ORDER-_5n$1)/_8n$2,ie=n.mul(t,_2n$4),se=n.pow(ie,c),ae=n.mul(t,se),ue=n.mul(n.mul(ae,_2n$4),se),de=n.mul(ae,n.sub(ue,n.ONE));return assertIsSquare(n,de,t),de}function sqrt9mod16(n){const t=Field(n),c=tonelliShanks(n),ie=c(t,t.neg(t.ONE)),se=c(t,ie),ae=c(t,t.neg(ie)),ue=(n+_7n)/_16n;return(de,ve)=>{let ge=de.pow(ve,ue),we=de.mul(ge,ie);const Te=de.mul(ge,se),Ne=de.mul(ge,ae),qe=de.eql(de.sqr(we),ve),ze=de.eql(de.sqr(Te),ve);ge=de.cmov(ge,we,qe),we=de.cmov(Ne,Te,ze);const He=de.eql(de.sqr(we),ve),Ge=de.cmov(ge,we,He);return assertIsSquare(de,Ge,ve),Ge}}function tonelliShanks(n){if(n<_3n$1)throw new Error("sqrt is not defined for small field");let t=n-_1n$4,c=0;for(;t%_2n$4===_0n$3;)t/=_2n$4,c++;let ie=_2n$4;const se=Field(n);for(;FpLegendre(se,ie)===1;)if(ie++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(c===1)return sqrt3mod4;let ae=se.pow(ie,t);const ue=(t+_1n$4)/_2n$4;return function(de,ve){if(de.is0(ve))return ve;if(FpLegendre(de,ve)!==1)throw new Error("Cannot find square root");let ge=c,we=de.mul(de.ONE,ae),Te=de.pow(ve,t),Ne=de.pow(ve,ue);for(;!de.eql(Te,de.ONE);){if(de.is0(Te))return de.ZERO;let qe=1,ze=de.sqr(Te);for(;!de.eql(ze,de.ONE);)if(qe++,ze=de.sqr(ze),qe===ge)throw new Error("Cannot find square root");const He=_1n$4<<BigInt(ge-qe-1),Ge=de.pow(we,He);ge=qe,we=de.sqr(Ge),Te=de.mul(Te,we),Ne=de.mul(Ne,Ge)}return Ne}}function FpSqrt(n){return n%_4n$1===_3n$1?sqrt3mod4:n%_8n$2===_5n$1?sqrt5mod8:n%_16n===_9n?sqrt9mod16(n):tonelliShanks(n)}const isNegativeLE=(n,t)=>(mod$1(n,t)&_1n$4)===_1n$4,FIELD_FIELDS=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function validateField(n){const t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},c=FIELD_FIELDS.reduce((ie,se)=>(ie[se]="function",ie),t);return _validateObject(n,c),n}function FpPow(n,t,c){if(c<_0n$3)throw new Error("invalid exponent, negatives unsupported");if(c===_0n$3)return n.ONE;if(c===_1n$4)return t;let ie=n.ONE,se=t;for(;c>_0n$3;)c&_1n$4&&(ie=n.mul(ie,se)),se=n.sqr(se),c>>=_1n$4;return ie}function FpInvertBatch(n,t,c=!1){const ie=new Array(t.length).fill(c?n.ZERO:void 0),se=t.reduce((ue,de,ve)=>n.is0(de)?ue:(ie[ve]=ue,n.mul(ue,de)),n.ONE),ae=n.inv(se);return t.reduceRight((ue,de,ve)=>n.is0(de)?ue:(ie[ve]=n.mul(ue,ie[ve]),n.mul(ue,de)),ae),ie}function FpLegendre(n,t){const c=(n.ORDER-_1n$4)/_2n$4,ie=n.pow(t,c),se=n.eql(ie,n.ONE),ae=n.eql(ie,n.ZERO),ue=n.eql(ie,n.neg(n.ONE));if(!se&&!ae&&!ue)throw new Error("invalid Legendre symbol result");return se?1:ae?0:-1}function nLength(n,t){t!==void 0&&anumber(t);const c=t!==void 0?t:n.toString(2).length,ie=Math.ceil(c/8);return{nBitLength:c,nByteLength:ie}}function Field(n,t,c=!1,ie={}){if(n<=_0n$3)throw new Error("invalid field: expected ORDER > 0, got "+n);let se,ae,ue=!1,de;if(typeof t=="object"&&t!=null){if(ie.sqrt||c)throw new Error("cannot specify opts in two arguments");const Ne=t;Ne.BITS&&(se=Ne.BITS),Ne.sqrt&&(ae=Ne.sqrt),typeof Ne.isLE=="boolean"&&(c=Ne.isLE),typeof Ne.modFromBytes=="boolean"&&(ue=Ne.modFromBytes),de=Ne.allowedLengths}else typeof t=="number"&&(se=t),ie.sqrt&&(ae=ie.sqrt);const{nBitLength:ve,nByteLength:ge}=nLength(n,se);if(ge>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let we;const Te=Object.freeze({ORDER:n,isLE:c,BITS:ve,BYTES:ge,MASK:bitMask(ve),ZERO:_0n$3,ONE:_1n$4,allowedLengths:de,create:Ne=>mod$1(Ne,n),isValid:Ne=>{if(typeof Ne!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof Ne);return _0n$3<=Ne&&Ne<n},is0:Ne=>Ne===_0n$3,isValidNot0:Ne=>!Te.is0(Ne)&&Te.isValid(Ne),isOdd:Ne=>(Ne&_1n$4)===_1n$4,neg:Ne=>mod$1(-Ne,n),eql:(Ne,qe)=>Ne===qe,sqr:Ne=>mod$1(Ne*Ne,n),add:(Ne,qe)=>mod$1(Ne+qe,n),sub:(Ne,qe)=>mod$1(Ne-qe,n),mul:(Ne,qe)=>mod$1(Ne*qe,n),pow:(Ne,qe)=>FpPow(Te,Ne,qe),div:(Ne,qe)=>mod$1(Ne*invert(qe,n),n),sqrN:Ne=>Ne*Ne,addN:(Ne,qe)=>Ne+qe,subN:(Ne,qe)=>Ne-qe,mulN:(Ne,qe)=>Ne*qe,inv:Ne=>invert(Ne,n),sqrt:ae||(Ne=>(we||(we=FpSqrt(n)),we(Te,Ne))),toBytes:Ne=>c?numberToBytesLE(Ne,ge):numberToBytesBE(Ne,ge),fromBytes:(Ne,qe=!0)=>{if(de){if(!de.includes(Ne.length)||Ne.length>ge)throw new Error("Field.fromBytes: expected "+de+" bytes, got "+Ne.length);const He=new Uint8Array(ge);He.set(Ne,c?0:He.length-Ne.length),Ne=He}if(Ne.length!==ge)throw new Error("Field.fromBytes: expected "+ge+" bytes, got "+Ne.length);let ze=c?bytesToNumberLE(Ne):bytesToNumberBE(Ne);if(ue&&(ze=mod$1(ze,n)),!qe&&!Te.isValid(ze))throw new Error("invalid field element: outside of range 0..ORDER");return ze},invertBatch:Ne=>FpInvertBatch(Te,Ne),cmov:(Ne,qe,ze)=>ze?qe:Ne});return Object.freeze(Te)}function getFieldBytesLength(n){if(typeof n!="bigint")throw new Error("field order must be bigint");const t=n.toString(2).length;return Math.ceil(t/8)}function getMinHashLength(n){const t=getFieldBytesLength(n);return t+Math.ceil(t/2)}function mapHashToField(n,t,c=!1){const ie=n.length,se=getFieldBytesLength(t),ae=getMinHashLength(t);if(ie<16||ie<ae||ie>1024)throw new Error("expected "+ae+"-1024 bytes of input, got "+ie);const ue=c?bytesToNumberLE(n):bytesToNumberBE(n),de=mod$1(ue,t-_1n$4)+_1n$4;return c?numberToBytesLE(de,se):numberToBytesBE(de,se)}const _0n$2=BigInt(0),_1n$3=BigInt(1);function negateCt(n,t){const c=t.negate();return n?c:t}function normalizeZ(n,t){const c=FpInvertBatch(n.Fp,t.map(ie=>ie.Z));return t.map((ie,se)=>n.fromAffine(ie.toAffine(c[se])))}function validateW(n,t){if(!Number.isSafeInteger(n)||n<=0||n>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+n)}function calcWOpts(n,t){validateW(n,t);const c=Math.ceil(t/n)+1,ie=2**(n-1),se=2**n,ae=bitMask(n),ue=BigInt(n);return{windows:c,windowSize:ie,mask:ae,maxNumber:se,shiftBy:ue}}function calcOffsets(n,t,c){const{windowSize:ie,mask:se,maxNumber:ae,shiftBy:ue}=c;let de=Number(n&se),ve=n>>ue;de>ie&&(de-=ae,ve+=_1n$3);const ge=t*ie,we=ge+Math.abs(de)-1,Te=de===0,Ne=de<0,qe=t%2!==0;return{nextN:ve,offset:we,isZero:Te,isNeg:Ne,isNegF:qe,offsetF:ge}}function validateMSMPoints(n,t){if(!Array.isArray(n))throw new Error("array expected");n.forEach((c,ie)=>{if(!(c instanceof t))throw new Error("invalid point at index "+ie)})}function validateMSMScalars(n,t){if(!Array.isArray(n))throw new Error("array of scalars expected");n.forEach((c,ie)=>{if(!t.isValid(c))throw new Error("invalid scalar at index "+ie)})}const pointPrecomputes=new WeakMap,pointWindowSizes=new WeakMap;function getW(n){return pointWindowSizes.get(n)||1}function assert0(n){if(n!==_0n$2)throw new Error("invalid wNAF")}class wNAF{constructor(t,c){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=c}_unsafeLadder(t,c,ie=this.ZERO){let se=t;for(;c>_0n$2;)c&_1n$3&&(ie=ie.add(se)),se=se.double(),c>>=_1n$3;return ie}precomputeWindow(t,c){const{windows:ie,windowSize:se}=calcWOpts(c,this.bits),ae=[];let ue=t,de=ue;for(let ve=0;ve<ie;ve++){de=ue,ae.push(de);for(let ge=1;ge<se;ge++)de=de.add(ue),ae.push(de);ue=de.double()}return ae}wNAF(t,c,ie){if(!this.Fn.isValid(ie))throw new Error("invalid scalar");let se=this.ZERO,ae=this.BASE;const ue=calcWOpts(t,this.bits);for(let de=0;de<ue.windows;de++){const{nextN:ve,offset:ge,isZero:we,isNeg:Te,isNegF:Ne,offsetF:qe}=calcOffsets(ie,de,ue);ie=ve,we?ae=ae.add(negateCt(Ne,c[qe])):se=se.add(negateCt(Te,c[ge]))}return assert0(ie),{p:se,f:ae}}wNAFUnsafe(t,c,ie,se=this.ZERO){const ae=calcWOpts(t,this.bits);for(let ue=0;ue<ae.windows&&ie!==_0n$2;ue++){const{nextN:de,offset:ve,isZero:ge,isNeg:we}=calcOffsets(ie,ue,ae);if(ie=de,!ge){const Te=c[ve];se=se.add(we?Te.negate():Te)}}return assert0(ie),se}getPrecomputes(t,c,ie){let se=pointPrecomputes.get(c);return se||(se=this.precomputeWindow(c,t),t!==1&&(typeof ie=="function"&&(se=ie(se)),pointPrecomputes.set(c,se))),se}cached(t,c,ie){const se=getW(t);return this.wNAF(se,this.getPrecomputes(se,t,ie),c)}unsafe(t,c,ie,se){const ae=getW(t);return ae===1?this._unsafeLadder(t,c,se):this.wNAFUnsafe(ae,this.getPrecomputes(ae,t,ie),c,se)}createCache(t,c){validateW(c,this.bits),pointWindowSizes.set(t,c),pointPrecomputes.delete(t)}hasCache(t){return getW(t)!==1}}function mulEndoUnsafe(n,t,c,ie){let se=t,ae=n.ZERO,ue=n.ZERO;for(;c>_0n$2||ie>_0n$2;)c&_1n$3&&(ae=ae.add(se)),ie&_1n$3&&(ue=ue.add(se)),se=se.double(),c>>=_1n$3,ie>>=_1n$3;return{p1:ae,p2:ue}}function pippenger(n,t,c,ie){validateMSMPoints(c,n),validateMSMScalars(ie,t);const se=c.length,ae=ie.length;if(se!==ae)throw new Error("arrays of points and scalars must have equal length");const ue=n.ZERO,de=bitLen(BigInt(se));let ve=1;de>12?ve=de-3:de>4?ve=de-2:de>0&&(ve=2);const ge=bitMask(ve),we=new Array(Number(ge)+1).fill(ue),Te=Math.floor((t.BITS-1)/ve)*ve;let Ne=ue;for(let qe=Te;qe>=0;qe-=ve){we.fill(ue);for(let He=0;He<ae;He++){const Ge=ie[He],Ze=Number(Ge>>BigInt(qe)&ge);we[Ze]=we[Ze].add(c[He])}let ze=ue;for(let He=we.length-1,Ge=ue;He>0;He--)Ge=Ge.add(we[He]),ze=ze.add(Ge);if(Ne=Ne.add(ze),qe!==0)for(let He=0;He<ve;He++)Ne=Ne.double()}return Ne}function createField(n,t,c){if(t){if(t.ORDER!==n)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return validateField(t),t}else return Field(n,{isLE:c})}function _createCurveFields(n,t,c={},ie){if(ie===void 0&&(ie=n==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${n} CURVE object`);for(const de of["p","n","h"]){const ve=t[de];if(!(typeof ve=="bigint"&&ve>_0n$2))throw new Error(`CURVE.${de} must be positive bigint`)}const se=createField(t.p,c.Fp,ie),ae=createField(t.n,c.Fn,ie),ue=["Gx","Gy","a",n==="weierstrass"?"b":"d"];for(const de of ue)if(!se.isValid(t[de]))throw new Error(`CURVE.${de} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:se,Fn:ae}}const _0n$1=BigInt(0),_1n$2=BigInt(1),_2n$3=BigInt(2),_8n$1=BigInt(8);function isEdValidXY(n,t,c,ie){const se=n.sqr(c),ae=n.sqr(ie),ue=n.add(n.mul(t.a,se),ae),de=n.add(n.ONE,n.mul(t.d,n.mul(se,ae)));return n.eql(ue,de)}function edwards$1(n,t={}){const c=_createCurveFields("edwards",n,t,t.FpFnLE),{Fp:ie,Fn:se}=c;let ae=c.CURVE;const{h:ue}=ae;_validateObject(t,{},{uvRatio:"function"});const de=_2n$3<<BigInt(se.BYTES*8)-_1n$2,ve=Ge=>ie.create(Ge),ge=t.uvRatio||((Ge,Ze)=>{try{return{isValid:!0,value:ie.sqrt(ie.div(Ge,Ze))}}catch{return{isValid:!1,value:_0n$1}}});if(!isEdValidXY(ie,ae,ae.Gx,ae.Gy))throw new Error("bad curve params: generator point");function we(Ge,Ze,Ye=!1){const Ft=Ye?_1n$2:_0n$1;return aInRange("coordinate "+Ge,Ze,Ft,de),Ze}function Te(Ge){if(!(Ge instanceof ze))throw new Error("ExtendedPoint expected")}const Ne=memoized((Ge,Ze)=>{const{X:Ye,Y:Ft,Z:Mt}=Ge,Zt=Ge.is0();Ze==null&&(Ze=Zt?_8n$1:ie.inv(Mt));const cn=ve(Ye*Ze),hn=ve(Ft*Ze),yn=ie.mul(Mt,Ze);if(Zt)return{x:_0n$1,y:_1n$2};if(yn!==_1n$2)throw new Error("invZ was invalid");return{x:cn,y:hn}}),qe=memoized(Ge=>{const{a:Ze,d:Ye}=ae;if(Ge.is0())throw new Error("bad point: ZERO");const{X:Ft,Y:Mt,Z:Zt,T:cn}=Ge,hn=ve(Ft*Ft),yn=ve(Mt*Mt),Ht=ve(Zt*Zt),Sn=ve(Ht*Ht),le=ve(hn*Ze),pe=ve(Ht*ve(le+yn)),be=ve(Sn+ve(Ye*ve(hn*yn)));if(pe!==be)throw new Error("bad point: equation left != right (1)");const xe=ve(Ft*Mt),_e=ve(Zt*cn);if(xe!==_e)throw new Error("bad point: equation left != right (2)");return!0});class ze{constructor(Ze,Ye,Ft,Mt){this.X=we("x",Ze),this.Y=we("y",Ye),this.Z=we("z",Ft,!0),this.T=we("t",Mt),Object.freeze(this)}static CURVE(){return ae}static fromAffine(Ze){if(Ze instanceof ze)throw new Error("extended point not allowed");const{x:Ye,y:Ft}=Ze||{};return we("x",Ye),we("y",Ft),new ze(Ye,Ft,_1n$2,ve(Ye*Ft))}static fromBytes(Ze,Ye=!1){const Ft=ie.BYTES,{a:Mt,d:Zt}=ae;Ze=copyBytes(_abytes2(Ze,Ft,"point")),_abool2(Ye,"zip215");const cn=copyBytes(Ze),hn=Ze[Ft-1];cn[Ft-1]=hn&-129;const yn=bytesToNumberLE(cn),Ht=Ye?de:ie.ORDER;aInRange("point.y",yn,_0n$1,Ht);const Sn=ve(yn*yn),le=ve(Sn-_1n$2),pe=ve(Zt*Sn-Mt);let{isValid:be,value:xe}=ge(le,pe);if(!be)throw new Error("bad point: invalid y coordinate");const _e=(xe&_1n$2)===_1n$2,De=(hn&128)!==0;if(!Ye&&xe===_0n$1&&De)throw new Error("bad point: x=0 and x_0=1");return De!==_e&&(xe=ve(-xe)),ze.fromAffine({x:xe,y:yn})}static fromHex(Ze,Ye=!1){return ze.fromBytes(ensureBytes("point",Ze),Ye)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(Ze=8,Ye=!0){return He.createCache(this,Ze),Ye||this.multiply(_2n$3),this}assertValidity(){qe(this)}equals(Ze){Te(Ze);const{X:Ye,Y:Ft,Z:Mt}=this,{X:Zt,Y:cn,Z:hn}=Ze,yn=ve(Ye*hn),Ht=ve(Zt*Mt),Sn=ve(Ft*hn),le=ve(cn*Mt);return yn===Ht&&Sn===le}is0(){return this.equals(ze.ZERO)}negate(){return new ze(ve(-this.X),this.Y,this.Z,ve(-this.T))}double(){const{a:Ze}=ae,{X:Ye,Y:Ft,Z:Mt}=this,Zt=ve(Ye*Ye),cn=ve(Ft*Ft),hn=ve(_2n$3*ve(Mt*Mt)),yn=ve(Ze*Zt),Ht=Ye+Ft,Sn=ve(ve(Ht*Ht)-Zt-cn),le=yn+cn,pe=le-hn,be=yn-cn,xe=ve(Sn*pe),_e=ve(le*be),De=ve(Sn*be),Fe=ve(pe*le);return new ze(xe,_e,Fe,De)}add(Ze){Te(Ze);const{a:Ye,d:Ft}=ae,{X:Mt,Y:Zt,Z:cn,T:hn}=this,{X:yn,Y:Ht,Z:Sn,T:le}=Ze,pe=ve(Mt*yn),be=ve(Zt*Ht),xe=ve(hn*Ft*le),_e=ve(cn*Sn),De=ve((Mt+Zt)*(yn+Ht)-pe-be),Fe=_e-xe,$e=_e+xe,ce=ve(be-Ye*pe),Me=ve(De*Fe),We=ve($e*ce),$t=ve(De*ce),dn=ve(Fe*$e);return new ze(Me,We,dn,$t)}subtract(Ze){return this.add(Ze.negate())}multiply(Ze){if(!se.isValidNot0(Ze))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:Ye,f:Ft}=He.cached(this,Ze,Mt=>normalizeZ(ze,Mt));return normalizeZ(ze,[Ye,Ft])[0]}multiplyUnsafe(Ze,Ye=ze.ZERO){if(!se.isValid(Ze))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return Ze===_0n$1?ze.ZERO:this.is0()||Ze===_1n$2?this:He.unsafe(this,Ze,Ft=>normalizeZ(ze,Ft),Ye)}isSmallOrder(){return this.multiplyUnsafe(ue).is0()}isTorsionFree(){return He.unsafe(this,ae.n).is0()}toAffine(Ze){return Ne(this,Ze)}clearCofactor(){return ue===_1n$2?this:this.multiplyUnsafe(ue)}toBytes(){const{x:Ze,y:Ye}=this.toAffine(),Ft=ie.toBytes(Ye);return Ft[Ft.length-1]|=Ze&_1n$2?128:0,Ft}toHex(){return bytesToHex(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(Ze){return normalizeZ(ze,Ze)}static msm(Ze,Ye){return pippenger(ze,se,Ze,Ye)}_setWindowSize(Ze){this.precompute(Ze)}toRawBytes(){return this.toBytes()}}ze.BASE=new ze(ae.Gx,ae.Gy,_1n$2,ve(ae.Gx*ae.Gy)),ze.ZERO=new ze(_0n$1,_1n$2,_1n$2,_0n$1),ze.Fp=ie,ze.Fn=se;const He=new wNAF(ze,se.BITS);return ze.BASE.precompute(8),ze}function eddsa$1(n,t,c={}){if(typeof t!="function")throw new Error('"hash" function param is required');_validateObject(c,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:ie}=c,{BASE:se,Fp:ae,Fn:ue}=n,de=c.randomBytes||randomBytes,ve=c.adjustScalarBytes||(Ht=>Ht),ge=c.domain||((Ht,Sn,le)=>{if(_abool2(le,"phflag"),Sn.length||le)throw new Error("Contexts/pre-hash are not supported");return Ht});function we(Ht){return ue.create(bytesToNumberLE(Ht))}function Te(Ht){const Sn=Ft.secretKey;Ht=ensureBytes("private key",Ht,Sn);const le=ensureBytes("hashed private key",t(Ht),2*Sn),pe=ve(le.slice(0,Sn)),be=le.slice(Sn,2*Sn),xe=we(pe);return{head:pe,prefix:be,scalar:xe}}function Ne(Ht){const{head:Sn,prefix:le,scalar:pe}=Te(Ht),be=se.multiply(pe),xe=be.toBytes();return{head:Sn,prefix:le,scalar:pe,point:be,pointBytes:xe}}function qe(Ht){return Ne(Ht).pointBytes}function ze(Ht=Uint8Array.of(),...Sn){const le=concatBytes(...Sn);return we(t(ge(le,ensureBytes("context",Ht),!!ie)))}function He(Ht,Sn,le={}){Ht=ensureBytes("message",Ht),ie&&(Ht=ie(Ht));const{prefix:pe,scalar:be,pointBytes:xe}=Ne(Sn),_e=ze(le.context,pe,Ht),De=se.multiply(_e).toBytes(),Fe=ze(le.context,De,xe,Ht),$e=ue.create(_e+Fe*be);if(!ue.isValid($e))throw new Error("sign failed: invalid s");const ce=concatBytes(De,ue.toBytes($e));return _abytes2(ce,Ft.signature,"result")}const Ge={zip215:!0};function Ze(Ht,Sn,le,pe=Ge){const{context:be,zip215:xe}=pe,_e=Ft.signature;Ht=ensureBytes("signature",Ht,_e),Sn=ensureBytes("message",Sn),le=ensureBytes("publicKey",le,Ft.publicKey),xe!==void 0&&_abool2(xe,"zip215"),ie&&(Sn=ie(Sn));const De=_e/2,Fe=Ht.subarray(0,De),$e=bytesToNumberLE(Ht.subarray(De,_e));let ce,Me,We;try{ce=n.fromBytes(le,xe),Me=n.fromBytes(Fe,xe),We=se.multiplyUnsafe($e)}catch{return!1}if(!xe&&ce.isSmallOrder())return!1;const $t=ze(be,Me.toBytes(),ce.toBytes(),Sn);return Me.add(ce.multiplyUnsafe($t)).subtract(We).clearCofactor().is0()}const Ye=ae.BYTES,Ft={secretKey:Ye,publicKey:Ye,signature:2*Ye,seed:Ye};function Mt(Ht=de(Ft.seed)){return _abytes2(Ht,Ft.seed,"seed")}function Zt(Ht){const Sn=yn.randomSecretKey(Ht);return{secretKey:Sn,publicKey:qe(Sn)}}function cn(Ht){return isBytes(Ht)&&Ht.length===ue.BYTES}function hn(Ht,Sn){try{return!!n.fromBytes(Ht,Sn)}catch{return!1}}const yn={getExtendedPublicKey:Ne,randomSecretKey:Mt,isValidSecretKey:cn,isValidPublicKey:hn,toMontgomery(Ht){const{y:Sn}=n.fromBytes(Ht),le=Ft.publicKey,pe=le===32;if(!pe&&le!==57)throw new Error("only defined for 25519 and 448");const be=pe?ae.div(_1n$2+Sn,_1n$2-Sn):ae.div(Sn-_1n$2,Sn+_1n$2);return ae.toBytes(be)},toMontgomerySecret(Ht){const Sn=Ft.secretKey;_abytes2(Ht,Sn);const le=t(Ht.subarray(0,Sn));return ve(le).subarray(0,Sn)},randomPrivateKey:Mt,precompute(Ht=8,Sn=n.BASE){return Sn.precompute(Ht,!1)}};return Object.freeze({keygen:Zt,getPublicKey:qe,sign:He,verify:Ze,utils:yn,Point:n,lengths:Ft})}function _eddsa_legacy_opts_to_new(n){const t={a:n.a,d:n.d,p:n.Fp.ORDER,n:n.n,h:n.h,Gx:n.Gx,Gy:n.Gy},c=n.Fp,ie=Field(t.n,n.nBitLength,!0),se={Fp:c,Fn:ie,uvRatio:n.uvRatio},ae={randomBytes:n.randomBytes,adjustScalarBytes:n.adjustScalarBytes,domain:n.domain,prehash:n.prehash,mapToCurve:n.mapToCurve};return{CURVE:t,curveOpts:se,hash:n.hash,eddsaOpts:ae}}function _eddsa_new_output_to_legacy(n,t){const c=t.Point;return Object.assign({},t,{ExtendedPoint:c,CURVE:n,nBitLength:c.Fn.BITS,nByteLength:c.Fn.BYTES})}function twistedEdwards(n){const{CURVE:t,curveOpts:c,hash:ie,eddsaOpts:se}=_eddsa_legacy_opts_to_new(n),ae=edwards$1(t,c),ue=eddsa$1(ae,ie,se);return _eddsa_new_output_to_legacy(n,ue)}const _1n$1=BigInt(1),_2n$2=BigInt(2);BigInt(3);const _5n=BigInt(5),_8n=BigInt(8),ed25519_CURVE_p=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),ed25519_CURVE={p:ed25519_CURVE_p,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:_8n,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function ed25519_pow_2_252_3(n){const t=BigInt(10),c=BigInt(20),ie=BigInt(40),se=BigInt(80),ae=ed25519_CURVE_p,ue=n*n%ae*n%ae,de=pow2(ue,_2n$2,ae)*ue%ae,ve=pow2(de,_1n$1,ae)*n%ae,ge=pow2(ve,_5n,ae)*ve%ae,we=pow2(ge,t,ae)*ge%ae,Te=pow2(we,c,ae)*we%ae,Ne=pow2(Te,ie,ae)*Te%ae,qe=pow2(Ne,se,ae)*Ne%ae,ze=pow2(qe,se,ae)*Ne%ae,He=pow2(ze,t,ae)*ge%ae;return{pow_p_5_8:pow2(He,_2n$2,ae)*n%ae,b2:ue}}function adjustScalarBytes(n){return n[0]&=248,n[31]&=127,n[31]|=64,n}const ED25519_SQRT_M1=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function uvRatio(n,t){const c=ed25519_CURVE_p,ie=mod$1(t*t*t,c),se=mod$1(ie*ie*t,c),ae=ed25519_pow_2_252_3(n*se).pow_p_5_8;let ue=mod$1(n*ie*ae,c);const de=mod$1(t*ue*ue,c),ve=ue,ge=mod$1(ue*ED25519_SQRT_M1,c),we=de===n,Te=de===mod$1(-n,c),Ne=de===mod$1(-n*ED25519_SQRT_M1,c);return we&&(ue=ve),(Te||Ne)&&(ue=ge),isNegativeLE(ue,c)&&(ue=mod$1(-ue,c)),{isValid:we||Te,value:ue}}const Fp=Field(ed25519_CURVE.p,{isLE:!0}),ed25519Defaults={...ed25519_CURVE,Fp,hash:sha512$3,adjustScalarBytes,uvRatio},ed25519=twistedEdwards(ed25519Defaults);var safeBuffer$2={exports:{}};(function(n,t){var c=require$$0$4,ie=c.Buffer;function se(ue,de){for(var ve in ue)de[ve]=ue[ve]}ie.from&&ie.alloc&&ie.allocUnsafe&&ie.allocUnsafeSlow?n.exports=c:(se(c,t),t.Buffer=ae);function ae(ue,de,ve){return ie(ue,de,ve)}ae.prototype=Object.create(ie.prototype),se(ie,ae),ae.from=function(ue,de,ve){if(typeof ue=="number")throw new TypeError("Argument must not be a number");return ie(ue,de,ve)},ae.alloc=function(ue,de,ve){if(typeof ue!="number")throw new TypeError("Argument must be a number");var ge=ie(ue);return de!==void 0?typeof ve=="string"?ge.fill(de,ve):ge.fill(de):ge.fill(0),ge},ae.allocUnsafe=function(ue){if(typeof ue!="number")throw new TypeError("Argument must be a number");return ie(ue)},ae.allocUnsafeSlow=function(ue){if(typeof ue!="number")throw new TypeError("Argument must be a number");return c.SlowBuffer(ue)}})(safeBuffer$2,safeBuffer$2.exports);var safeBufferExports=safeBuffer$2.exports,_Buffer=safeBufferExports.Buffer;function base$4(n){if(n.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),c=0;c<t.length;c++)t[c]=255;for(var ie=0;ie<n.length;ie++){var se=n.charAt(ie),ae=se.charCodeAt(0);if(t[ae]!==255)throw new TypeError(se+" is ambiguous");t[ae]=ie}var ue=n.length,de=n.charAt(0),ve=Math.log(ue)/Math.log(256),ge=Math.log(256)/Math.log(ue);function we(qe){if((Array.isArray(qe)||qe instanceof Uint8Array)&&(qe=_Buffer.from(qe)),!_Buffer.isBuffer(qe))throw new TypeError("Expected Buffer");if(qe.length===0)return"";for(var ze=0,He=0,Ge=0,Ze=qe.length;Ge!==Ze&&qe[Ge]===0;)Ge++,ze++;for(var Ye=(Ze-Ge)*ge+1>>>0,Ft=new Uint8Array(Ye);Ge!==Ze;){for(var Mt=qe[Ge],Zt=0,cn=Ye-1;(Mt!==0||Zt<He)&&cn!==-1;cn--,Zt++)Mt+=256*Ft[cn]>>>0,Ft[cn]=Mt%ue>>>0,Mt=Mt/ue>>>0;if(Mt!==0)throw new Error("Non-zero carry");He=Zt,Ge++}for(var hn=Ye-He;hn!==Ye&&Ft[hn]===0;)hn++;for(var yn=de.repeat(ze);hn<Ye;++hn)yn+=n.charAt(Ft[hn]);return yn}function Te(qe){if(typeof qe!="string")throw new TypeError("Expected String");if(qe.length===0)return _Buffer.alloc(0);for(var ze=0,He=0,Ge=0;qe[ze]===de;)He++,ze++;for(var Ze=(qe.length-ze)*ve+1>>>0,Ye=new Uint8Array(Ze);ze<qe.length;){var Ft=qe.charCodeAt(ze);if(Ft>255)return;var Mt=t[Ft];if(Mt===255)return;for(var Zt=0,cn=Ze-1;(Mt!==0||Zt<Ge)&&cn!==-1;cn--,Zt++)Mt+=ue*Ye[cn]>>>0,Ye[cn]=Mt%256>>>0,Mt=Mt/256>>>0;if(Mt!==0)throw new Error("Non-zero carry");Ge=Zt,ze++}for(var hn=Ze-Ge;hn!==Ze&&Ye[hn]===0;)hn++;var yn=_Buffer.allocUnsafe(He+(Ze-hn));yn.fill(0,0,He);for(var Ht=He;hn!==Ze;)yn[Ht++]=Ye[hn++];return yn}function Ne(qe){var ze=Te(qe);if(ze)return ze;throw new Error("Non-base"+ue+" character")}return{encode:we,decodeUnsafe:Te,decode:Ne}}var src$7=base$4;const e$1=getDefaultExportFromCjs$2(src$7);var basex=src$7,ALPHABET$1="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",bs58=basex(ALPHABET$1);const o$1=getDefaultExportFromCjs$2(bs58),sha256$4=sha256$5;var lib={};function inRange(n,t,c){return t<=n&&n<=c}function ToDictionary(n){if(n===void 0)return{};if(n===Object(n))return n;throw TypeError("Could not convert argument to dictionary")}function stringToCodePoints(n){for(var t=String(n),c=t.length,ie=0,se=[];ie<c;){var ae=t.charCodeAt(ie);if(ae<55296||ae>57343)se.push(ae);else if(56320<=ae&&ae<=57343)se.push(65533);else if(55296<=ae&&ae<=56319)if(ie===c-1)se.push(65533);else{var ue=n.charCodeAt(ie+1);if(56320<=ue&&ue<=57343){var de=ae&1023,ve=ue&1023;se.push(65536+(de<<10)+ve),ie+=1}else se.push(65533)}ie+=1}return se}function codePointsToString(n){for(var t="",c=0;c<n.length;++c){var ie=n[c];ie<=65535?t+=String.fromCharCode(ie):(ie-=65536,t+=String.fromCharCode((ie>>10)+55296,(ie&1023)+56320))}return t}var end_of_stream=-1;function Stream(n){this.tokens=[].slice.call(n)}Stream.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():end_of_stream},prepend:function(n){if(Array.isArray(n))for(var t=n;t.length;)this.tokens.unshift(t.pop());else this.tokens.unshift(n)},push:function(n){if(Array.isArray(n))for(var t=n;t.length;)this.tokens.push(t.shift());else this.tokens.push(n)}};var finished=-1;function decoderError(n,t){if(n)throw TypeError("Decoder error");return t||65533}var DEFAULT_ENCODING="utf-8";function TextDecoder$1(n,t){if(!(this instanceof TextDecoder$1))return new TextDecoder$1(n,t);if(n=n!==void 0?String(n).toLowerCase():DEFAULT_ENCODING,n!==DEFAULT_ENCODING)throw new Error("Encoding not supported. Only utf-8 is supported");t=ToDictionary(t),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!t.fatal,this._ignoreBOM=!!t.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}TextDecoder$1.prototype={decode:function(n,t){var c;typeof n=="object"&&n instanceof ArrayBuffer?c=new Uint8Array(n):typeof n=="object"&&"buffer"in n&&n.buffer instanceof ArrayBuffer?c=new Uint8Array(n.buffer,n.byteOffset,n.byteLength):c=new Uint8Array(0),t=ToDictionary(t),this._streaming||(this._decoder=new UTF8Decoder({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!t.stream;for(var ie=new Stream(c),se=[],ae;!ie.endOfStream()&&(ae=this._decoder.handler(ie,ie.read()),ae!==finished);)ae!==null&&(Array.isArray(ae)?se.push.apply(se,ae):se.push(ae));if(!this._streaming){do{if(ae=this._decoder.handler(ie,ie.read()),ae===finished)break;ae!==null&&(Array.isArray(ae)?se.push.apply(se,ae):se.push(ae))}while(!ie.endOfStream());this._decoder=null}return se.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(se[0]===65279?(this._BOMseen=!0,se.shift()):this._BOMseen=!0),codePointsToString(se)}};function TextEncoder$1$1(n,t){if(!(this instanceof TextEncoder$1$1))return new TextEncoder$1$1(n,t);if(n=n!==void 0?String(n).toLowerCase():DEFAULT_ENCODING,n!==DEFAULT_ENCODING)throw new Error("Encoding not supported. Only utf-8 is supported");t=ToDictionary(t),this._streaming=!1,this._encoder=null,this._options={fatal:!!t.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}TextEncoder$1$1.prototype={encode:function(n,t){n=n?String(n):"",t=ToDictionary(t),this._streaming||(this._encoder=new UTF8Encoder(this._options)),this._streaming=!!t.stream;for(var c=[],ie=new Stream(stringToCodePoints(n)),se;!ie.endOfStream()&&(se=this._encoder.handler(ie,ie.read()),se!==finished);)Array.isArray(se)?c.push.apply(c,se):c.push(se);if(!this._streaming){for(;se=this._encoder.handler(ie,ie.read()),se!==finished;)Array.isArray(se)?c.push.apply(c,se):c.push(se);this._encoder=null}return new Uint8Array(c)}};function UTF8Decoder(n){var t=n.fatal,c=0,ie=0,se=0,ae=128,ue=191;this.handler=function(de,ve){if(ve===end_of_stream&&se!==0)return se=0,decoderError(t);if(ve===end_of_stream)return finished;if(se===0){if(inRange(ve,0,127))return ve;if(inRange(ve,194,223))se=1,c=ve-192;else if(inRange(ve,224,239))ve===224&&(ae=160),ve===237&&(ue=159),se=2,c=ve-224;else if(inRange(ve,240,244))ve===240&&(ae=144),ve===244&&(ue=143),se=3,c=ve-240;else return decoderError(t);return c=c<<6*se,null}if(!inRange(ve,ae,ue))return c=se=ie=0,ae=128,ue=191,de.prepend(ve),decoderError(t);if(ae=128,ue=191,ie+=1,c+=ve-128<<6*(se-ie),ie!==se)return null;var ge=c;return c=se=ie=0,ge}}function UTF8Encoder(n){n.fatal,this.handler=function(t,c){if(c===end_of_stream)return finished;if(inRange(c,0,127))return c;var ie,se;inRange(c,128,2047)?(ie=1,se=192):inRange(c,2048,65535)?(ie=2,se=224):inRange(c,65536,1114111)&&(ie=3,se=240);for(var ae=[(c>>6*ie)+se];ie>0;){var ue=c>>6*(ie-1);ae.push(128|ue&63),ie-=1}return ae}}const encoding$1=Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:TextDecoder$1,TextEncoder:TextEncoder$1$1},Symbol.toStringTag,{value:"Module"})),require$$2$2=getAugmentedNamespace(encoding$1);var __createBinding$9=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(n,t,c,ie){ie===void 0&&(ie=c),Object.defineProperty(n,ie,{enumerable:!0,get:function(){return t[c]}})}:function(n,t,c,ie){ie===void 0&&(ie=c),n[ie]=t[c]}),__setModuleDefault$9=commonjsGlobal&&commonjsGlobal.__setModuleDefault||(Object.create?function(n,t){Object.defineProperty(n,"default",{enumerable:!0,value:t})}:function(n,t){n.default=t}),__decorate=commonjsGlobal&&commonjsGlobal.__decorate||function(n,t,c,ie){var se=arguments.length,ae=se<3?t:ie===null?ie=Object.getOwnPropertyDescriptor(t,c):ie,ue;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")ae=Reflect.decorate(n,t,c,ie);else for(var de=n.length-1;de>=0;de--)(ue=n[de])&&(ae=(se<3?ue(ae):se>3?ue(t,c,ae):ue(t,c))||ae);return se>3&&ae&&Object.defineProperty(t,c,ae),ae},__importStar$9=commonjsGlobal&&commonjsGlobal.__importStar||function(n){if(n&&n.__esModule)return n;var t={};if(n!=null)for(var c in n)c!=="default"&&Object.hasOwnProperty.call(n,c)&&__createBinding$9(t,n,c);return __setModuleDefault$9(t,n),t},__importDefault$9=commonjsGlobal&&commonjsGlobal.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(lib,"__esModule",{value:!0});var deserializeUnchecked_1=lib.deserializeUnchecked=deserialize_1=lib.deserialize=serialize_1=lib.serialize=lib.BinaryReader=lib.BinaryWriter=lib.BorshError=lib.baseDecode=lib.baseEncode=void 0;const bn_js_1$1=__importDefault$9(bnExports$3),bs58_1=__importDefault$9(bs58),encoding=__importStar$9(require$$2$2),ResolvedTextDecoder=typeof TextDecoder!="function"?encoding.TextDecoder:TextDecoder,textDecoder=new ResolvedTextDecoder("utf-8",{fatal:!0});function baseEncode(n){return typeof n=="string"&&(n=Buffer$7.from(n,"utf8")),bs58_1.default.encode(Buffer$7.from(n))}lib.baseEncode=baseEncode;function baseDecode(n){return Buffer$7.from(bs58_1.default.decode(n))}lib.baseDecode=baseDecode;const INITIAL_LENGTH=1024;class BorshError extends Error{constructor(t){super(t),this.fieldPath=[],this.originalMessage=t}addToFieldPath(t){this.fieldPath.splice(0,0,t),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}lib.BorshError=BorshError;class BinaryWriter{constructor(){this.buf=Buffer$7.alloc(INITIAL_LENGTH),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer$7.concat([this.buf,Buffer$7.alloc(INITIAL_LENGTH)]))}writeU8(t){this.maybeResize(),this.buf.writeUInt8(t,this.length),this.length+=1}writeU16(t){this.maybeResize(),this.buf.writeUInt16LE(t,this.length),this.length+=2}writeU32(t){this.maybeResize(),this.buf.writeUInt32LE(t,this.length),this.length+=4}writeU64(t){this.maybeResize(),this.writeBuffer(Buffer$7.from(new bn_js_1$1.default(t).toArray("le",8)))}writeU128(t){this.maybeResize(),this.writeBuffer(Buffer$7.from(new bn_js_1$1.default(t).toArray("le",16)))}writeU256(t){this.maybeResize(),this.writeBuffer(Buffer$7.from(new bn_js_1$1.default(t).toArray("le",32)))}writeU512(t){this.maybeResize(),this.writeBuffer(Buffer$7.from(new bn_js_1$1.default(t).toArray("le",64)))}writeBuffer(t){this.buf=Buffer$7.concat([Buffer$7.from(this.buf.subarray(0,this.length)),t,Buffer$7.alloc(INITIAL_LENGTH)]),this.length+=t.length}writeString(t){this.maybeResize();const c=Buffer$7.from(t,"utf8");this.writeU32(c.length),this.writeBuffer(c)}writeFixedArray(t){this.writeBuffer(Buffer$7.from(t))}writeArray(t,c){this.maybeResize(),this.writeU32(t.length);for(const ie of t)this.maybeResize(),c(ie)}toArray(){return this.buf.subarray(0,this.length)}}lib.BinaryWriter=BinaryWriter;function handlingRangeError(n,t,c){const ie=c.value;c.value=function(...se){try{return ie.apply(this,se)}catch(ae){if(ae instanceof RangeError){const ue=ae.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(ue)>=0)throw new BorshError("Reached the end of buffer when deserializing")}throw ae}}}class BinaryReader{constructor(t){this.buf=t,this.offset=0}readU8(){const t=this.buf.readUInt8(this.offset);return this.offset+=1,t}readU16(){const t=this.buf.readUInt16LE(this.offset);return this.offset+=2,t}readU32(){const t=this.buf.readUInt32LE(this.offset);return this.offset+=4,t}readU64(){const t=this.readBuffer(8);return new bn_js_1$1.default(t,"le")}readU128(){const t=this.readBuffer(16);return new bn_js_1$1.default(t,"le")}readU256(){const t=this.readBuffer(32);return new bn_js_1$1.default(t,"le")}readU512(){const t=this.readBuffer(64);return new bn_js_1$1.default(t,"le")}readBuffer(t){if(this.offset+t>this.buf.length)throw new BorshError(`Expected buffer length ${t} isn't within bounds`);const c=this.buf.slice(this.offset,this.offset+t);return this.offset+=t,c}readString(){const t=this.readU32(),c=this.readBuffer(t);try{return textDecoder.decode(c)}catch(ie){throw new BorshError(`Error decoding UTF-8 string: ${ie}`)}}readFixedArray(t){return new Uint8Array(this.readBuffer(t))}readArray(t){const c=this.readU32(),ie=Array();for(let se=0;se<c;++se)ie.push(t());return ie}}__decorate([handlingRangeError],BinaryReader.prototype,"readU8",null);__decorate([handlingRangeError],BinaryReader.prototype,"readU16",null);__decorate([handlingRangeError],BinaryReader.prototype,"readU32",null);__decorate([handlingRangeError],BinaryReader.prototype,"readU64",null);__decorate([handlingRangeError],BinaryReader.prototype,"readU128",null);__decorate([handlingRangeError],BinaryReader.prototype,"readU256",null);__decorate([handlingRangeError],BinaryReader.prototype,"readU512",null);__decorate([handlingRangeError],BinaryReader.prototype,"readString",null);__decorate([handlingRangeError],BinaryReader.prototype,"readFixedArray",null);__decorate([handlingRangeError],BinaryReader.prototype,"readArray",null);lib.BinaryReader=BinaryReader;function capitalizeFirstLetter(n){return n.charAt(0).toUpperCase()+n.slice(1)}function serializeField(n,t,c,ie,se){try{if(typeof ie=="string")se[`write${capitalizeFirstLetter(ie)}`](c);else if(ie instanceof Array)if(typeof ie[0]=="number"){if(c.length!==ie[0])throw new BorshError(`Expecting byte array of length ${ie[0]}, but got ${c.length} bytes`);se.writeFixedArray(c)}else if(ie.length===2&&typeof ie[1]=="number"){if(c.length!==ie[1])throw new BorshError(`Expecting byte array of length ${ie[1]}, but got ${c.length} bytes`);for(let ae=0;ae<ie[1];ae++)serializeField(n,null,c[ae],ie[0],se)}else se.writeArray(c,ae=>{serializeField(n,t,ae,ie[0],se)});else if(ie.kind!==void 0)switch(ie.kind){case"option":{c==null?se.writeU8(0):(se.writeU8(1),serializeField(n,t,c,ie.type,se));break}case"map":{se.writeU32(c.size),c.forEach((ae,ue)=>{serializeField(n,t,ue,ie.key,se),serializeField(n,t,ae,ie.value,se)});break}default:throw new BorshError(`FieldType ${ie} unrecognized`)}else serializeStruct(n,c,se)}catch(ae){throw ae instanceof BorshError&&ae.addToFieldPath(t),ae}}function serializeStruct(n,t,c){if(typeof t.borshSerialize=="function"){t.borshSerialize(c);return}const ie=n.get(t.constructor);if(!ie)throw new BorshError(`Class ${t.constructor.name} is missing in schema`);if(ie.kind==="struct")ie.fields.map(([se,ae])=>{serializeField(n,se,t[se],ae,c)});else if(ie.kind==="enum"){const se=t[ie.field];for(let ae=0;ae<ie.values.length;++ae){const[ue,de]=ie.values[ae];if(ue===se){c.writeU8(ae),serializeField(n,ue,t[ue],de,c);break}}}else throw new BorshError(`Unexpected schema kind: ${ie.kind} for ${t.constructor.name}`)}function serialize$2(n,t,c=BinaryWriter){const ie=new c;return serializeStruct(n,t,ie),ie.toArray()}var serialize_1=lib.serialize=serialize$2;function deserializeField(n,t,c,ie){try{if(typeof c=="string")return ie[`read${capitalizeFirstLetter(c)}`]();if(c instanceof Array){if(typeof c[0]=="number")return ie.readFixedArray(c[0]);if(typeof c[1]=="number"){const se=[];for(let ae=0;ae<c[1];ae++)se.push(deserializeField(n,null,c[0],ie));return se}else return ie.readArray(()=>deserializeField(n,t,c[0],ie))}if(c.kind==="option")return ie.readU8()?deserializeField(n,t,c.type,ie):void 0;if(c.kind==="map"){let se=new Map;const ae=ie.readU32();for(let ue=0;ue<ae;ue++){const de=deserializeField(n,t,c.key,ie),ve=deserializeField(n,t,c.value,ie);se.set(de,ve)}return se}return deserializeStruct(n,c,ie)}catch(se){throw se instanceof BorshError&&se.addToFieldPath(t),se}}function deserializeStruct(n,t,c){if(typeof t.borshDeserialize=="function")return t.borshDeserialize(c);const ie=n.get(t);if(!ie)throw new BorshError(`Class ${t.name} is missing in schema`);if(ie.kind==="struct"){const se={};for(const[ae,ue]of n.get(t).fields)se[ae]=deserializeField(n,ae,ue,c);return new t(se)}if(ie.kind==="enum"){const se=c.readU8();if(se>=ie.values.length)throw new BorshError(`Enum index: ${se} is out of range`);const[ae,ue]=ie.values[se],de=deserializeField(n,ae,ue,c);return new t({[ae]:de})}throw new BorshError(`Unexpected schema kind: ${ie.kind} for ${t.constructor.name}`)}function deserialize(n,t,c,ie=BinaryReader){const se=new ie(c),ae=deserializeStruct(n,t,se);if(se.offset<c.length)throw new BorshError(`Unexpected ${c.length-se.offset} bytes after deserialized data`);return ae}var deserialize_1=lib.deserialize=deserialize;function deserializeUnchecked(n,t,c,ie=BinaryReader){const se=new ie(c);return deserializeStruct(n,t,se)}deserializeUnchecked_1=lib.deserializeUnchecked=deserializeUnchecked;var Layout$1={};Object.defineProperty(Layout$1,"__esModule",{value:!0});Layout$1.s16=Layout$1.s8=Layout$1.nu64be=Layout$1.u48be=Layout$1.u40be=Layout$1.u32be=Layout$1.u24be=Layout$1.u16be=nu64=Layout$1.nu64=Layout$1.u48=Layout$1.u40=u32=Layout$1.u32=Layout$1.u24=u16=Layout$1.u16=u8=Layout$1.u8=offset$2=Layout$1.offset=Layout$1.greedy=Layout$1.Constant=Layout$1.UTF8=Layout$1.CString=Layout$1.Blob=Layout$1.Boolean=Layout$1.BitField=Layout$1.BitStructure=Layout$1.VariantLayout=Layout$1.Union=Layout$1.UnionLayoutDiscriminator=Layout$1.UnionDiscriminator=Layout$1.Structure=Layout$1.Sequence=Layout$1.DoubleBE=Layout$1.Double=Layout$1.FloatBE=Layout$1.Float=Layout$1.NearInt64BE=Layout$1.NearInt64=Layout$1.NearUInt64BE=Layout$1.NearUInt64=Layout$1.IntBE=Layout$1.Int=Layout$1.UIntBE=Layout$1.UInt=Layout$1.OffsetLayout=Layout$1.GreedyCount=Layout$1.ExternalLayout=Layout$1.bindConstructorLayout=Layout$1.nameWithProperty=Layout$1.Layout=Layout$1.uint8ArrayToBuffer=Layout$1.checkUint8Array=void 0;Layout$1.constant=Layout$1.utf8=Layout$1.cstr=blob=Layout$1.blob=Layout$1.unionLayoutDiscriminator=Layout$1.union=seq=Layout$1.seq=Layout$1.bits=struct=Layout$1.struct=Layout$1.f64be=Layout$1.f64=Layout$1.f32be=Layout$1.f32=Layout$1.ns64be=Layout$1.s48be=Layout$1.s40be=Layout$1.s32be=Layout$1.s24be=Layout$1.s16be=ns64=Layout$1.ns64=Layout$1.s48=Layout$1.s40=Layout$1.s32=Layout$1.s24=void 0;const buffer_1=require$$0$4;function checkUint8Array(n){if(!(n instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}Layout$1.checkUint8Array=checkUint8Array;function uint8ArrayToBuffer(n){return checkUint8Array(n),buffer_1.Buffer.from(n.buffer,n.byteOffset,n.length)}Layout$1.uint8ArrayToBuffer=uint8ArrayToBuffer;class Layout{constructor(t,c){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=c}makeDestinationObject(){return{}}getSpan(t,c){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const c=Object.create(this.constructor.prototype);return Object.assign(c,this),c.property=t,c}fromArray(t){}}Layout$1.Layout=Layout;function nameWithProperty(n,t){return t.property?n+"["+t.property+"]":n}Layout$1.nameWithProperty=nameWithProperty;function bindConstructorLayout(n,t){if(typeof n!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(n,"layout_"))throw new Error("Class is already bound to a layout");if(!(t&&t instanceof Layout))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(t,"boundConstructor_"))throw new Error("layout is already bound to a constructor");n.layout_=t,t.boundConstructor_=n,t.makeDestinationObject=()=>new n,Object.defineProperty(n.prototype,"encode",{value(c,ie){return t.encode(this,c,ie)},writable:!0}),Object.defineProperty(n,"decode",{value(c,ie){return t.decode(c,ie)},writable:!0})}Layout$1.bindConstructorLayout=bindConstructorLayout;class ExternalLayout extends Layout{isCount(){throw new Error("ExternalLayout is abstract")}}Layout$1.ExternalLayout=ExternalLayout;class GreedyCount extends ExternalLayout{constructor(t=1,c){if(!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");super(-1,c),this.elementSpan=t}isCount(){return!0}decode(t,c=0){checkUint8Array(t);const ie=t.length-c;return Math.floor(ie/this.elementSpan)}encode(t,c,ie){return 0}}Layout$1.GreedyCount=GreedyCount;class OffsetLayout extends ExternalLayout{constructor(t,c=0,ie){if(!(t instanceof Layout))throw new TypeError("layout must be a Layout");if(!Number.isInteger(c))throw new TypeError("offset must be integer or undefined");super(t.span,ie||t.property),this.layout=t,this.offset=c}isCount(){return this.layout instanceof UInt||this.layout instanceof UIntBE}decode(t,c=0){return this.layout.decode(t,c+this.offset)}encode(t,c,ie=0){return this.layout.encode(t,c,ie+this.offset)}}Layout$1.OffsetLayout=OffsetLayout;class UInt extends Layout{constructor(t,c){if(super(t,c),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,c=0){return uint8ArrayToBuffer(t).readUIntLE(c,this.span)}encode(t,c,ie=0){return uint8ArrayToBuffer(c).writeUIntLE(t,ie,this.span),this.span}}Layout$1.UInt=UInt;class UIntBE extends Layout{constructor(t,c){if(super(t,c),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,c=0){return uint8ArrayToBuffer(t).readUIntBE(c,this.span)}encode(t,c,ie=0){return uint8ArrayToBuffer(c).writeUIntBE(t,ie,this.span),this.span}}Layout$1.UIntBE=UIntBE;class Int extends Layout{constructor(t,c){if(super(t,c),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,c=0){return uint8ArrayToBuffer(t).readIntLE(c,this.span)}encode(t,c,ie=0){return uint8ArrayToBuffer(c).writeIntLE(t,ie,this.span),this.span}}Layout$1.Int=Int;class IntBE extends Layout{constructor(t,c){if(super(t,c),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,c=0){return uint8ArrayToBuffer(t).readIntBE(c,this.span)}encode(t,c,ie=0){return uint8ArrayToBuffer(c).writeIntBE(t,ie,this.span),this.span}}Layout$1.IntBE=IntBE;const V2E32=Math.pow(2,32);function divmodInt64(n){const t=Math.floor(n/V2E32),c=n-t*V2E32;return{hi32:t,lo32:c}}function roundedInt64(n,t){return n*V2E32+t}class NearUInt64 extends Layout{constructor(t){super(8,t)}decode(t,c=0){const ie=uint8ArrayToBuffer(t),se=ie.readUInt32LE(c),ae=ie.readUInt32LE(c+4);return roundedInt64(ae,se)}encode(t,c,ie=0){const se=divmodInt64(t),ae=uint8ArrayToBuffer(c);return ae.writeUInt32LE(se.lo32,ie),ae.writeUInt32LE(se.hi32,ie+4),8}}Layout$1.NearUInt64=NearUInt64;class NearUInt64BE extends Layout{constructor(t){super(8,t)}decode(t,c=0){const ie=uint8ArrayToBuffer(t),se=ie.readUInt32BE(c),ae=ie.readUInt32BE(c+4);return roundedInt64(se,ae)}encode(t,c,ie=0){const se=divmodInt64(t),ae=uint8ArrayToBuffer(c);return ae.writeUInt32BE(se.hi32,ie),ae.writeUInt32BE(se.lo32,ie+4),8}}Layout$1.NearUInt64BE=NearUInt64BE;class NearInt64 extends Layout{constructor(t){super(8,t)}decode(t,c=0){const ie=uint8ArrayToBuffer(t),se=ie.readUInt32LE(c),ae=ie.readInt32LE(c+4);return roundedInt64(ae,se)}encode(t,c,ie=0){const se=divmodInt64(t),ae=uint8ArrayToBuffer(c);return ae.writeUInt32LE(se.lo32,ie),ae.writeInt32LE(se.hi32,ie+4),8}}Layout$1.NearInt64=NearInt64;class NearInt64BE extends Layout{constructor(t){super(8,t)}decode(t,c=0){const ie=uint8ArrayToBuffer(t),se=ie.readInt32BE(c),ae=ie.readUInt32BE(c+4);return roundedInt64(se,ae)}encode(t,c,ie=0){const se=divmodInt64(t),ae=uint8ArrayToBuffer(c);return ae.writeInt32BE(se.hi32,ie),ae.writeUInt32BE(se.lo32,ie+4),8}}Layout$1.NearInt64BE=NearInt64BE;class Float extends Layout{constructor(t){super(4,t)}decode(t,c=0){return uint8ArrayToBuffer(t).readFloatLE(c)}encode(t,c,ie=0){return uint8ArrayToBuffer(c).writeFloatLE(t,ie),4}}Layout$1.Float=Float;class FloatBE extends Layout{constructor(t){super(4,t)}decode(t,c=0){return uint8ArrayToBuffer(t).readFloatBE(c)}encode(t,c,ie=0){return uint8ArrayToBuffer(c).writeFloatBE(t,ie),4}}Layout$1.FloatBE=FloatBE;class Double extends Layout{constructor(t){super(8,t)}decode(t,c=0){return uint8ArrayToBuffer(t).readDoubleLE(c)}encode(t,c,ie=0){return uint8ArrayToBuffer(c).writeDoubleLE(t,ie),8}}Layout$1.Double=Double;class DoubleBE extends Layout{constructor(t){super(8,t)}decode(t,c=0){return uint8ArrayToBuffer(t).readDoubleBE(c)}encode(t,c,ie=0){return uint8ArrayToBuffer(c).writeDoubleBE(t,ie),8}}Layout$1.DoubleBE=DoubleBE;class Sequence extends Layout{constructor(t,c,ie){if(!(t instanceof Layout))throw new TypeError("elementLayout must be a Layout");if(!(c instanceof ExternalLayout&&c.isCount()||Number.isInteger(c)&&0<=c))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let se=-1;!(c instanceof ExternalLayout)&&0<t.span&&(se=c*t.span),super(se,ie),this.elementLayout=t,this.count=c}getSpan(t,c=0){if(0<=this.span)return this.span;let ie=0,se=this.count;if(se instanceof ExternalLayout&&(se=se.decode(t,c)),0<this.elementLayout.span)ie=se*this.elementLayout.span;else{let ae=0;for(;ae<se;)ie+=this.elementLayout.getSpan(t,c+ie),++ae}return ie}decode(t,c=0){const ie=[];let se=0,ae=this.count;for(ae instanceof ExternalLayout&&(ae=ae.decode(t,c));se<ae;)ie.push(this.elementLayout.decode(t,c)),c+=this.elementLayout.getSpan(t,c),se+=1;return ie}encode(t,c,ie=0){const se=this.elementLayout,ae=t.reduce((ue,de)=>ue+se.encode(de,c,ie+ue),0);return this.count instanceof ExternalLayout&&this.count.encode(t.length,c,ie),ae}}Layout$1.Sequence=Sequence;class Structure extends Layout{constructor(t,c,ie){if(!(Array.isArray(t)&&t.reduce((ae,ue)=>ae&&ue instanceof Layout,!0)))throw new TypeError("fields must be array of Layout instances");typeof c=="boolean"&&ie===void 0&&(ie=c,c=void 0);for(const ae of t)if(0>ae.span&&ae.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let se=-1;try{se=t.reduce((ae,ue)=>ae+ue.getSpan(),0)}catch{}super(se,c),this.fields=t,this.decodePrefixes=!!ie}getSpan(t,c=0){if(0<=this.span)return this.span;let ie=0;try{ie=this.fields.reduce((se,ae)=>{const ue=ae.getSpan(t,c);return c+=ue,se+ue},0)}catch{throw new RangeError("indeterminate span")}return ie}decode(t,c=0){checkUint8Array(t);const ie=this.makeDestinationObject();for(const se of this.fields)if(se.property!==void 0&&(ie[se.property]=se.decode(t,c)),c+=se.getSpan(t,c),this.decodePrefixes&&t.length===c)break;return ie}encode(t,c,ie=0){const se=ie;let ae=0,ue=0;for(const de of this.fields){let ve=de.span;if(ue=0<ve?ve:0,de.property!==void 0){const ge=t[de.property];ge!==void 0&&(ue=de.encode(ge,c,ie),0>ve&&(ve=de.getSpan(c,ie)))}ae=ie,ie+=ve}return ae+ue-se}fromArray(t){const c=this.makeDestinationObject();for(const ie of this.fields)ie.property!==void 0&&0<t.length&&(c[ie.property]=t.shift());return c}layoutFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const c of this.fields)if(c.property===t)return c}offsetOf(t){if(typeof t!="string")throw new TypeError("property must be string");let c=0;for(const ie of this.fields){if(ie.property===t)return c;0>ie.span?c=-1:0<=c&&(c+=ie.span)}}}Layout$1.Structure=Structure;class UnionDiscriminator{constructor(t){this.property=t}decode(t,c){throw new Error("UnionDiscriminator is abstract")}encode(t,c,ie){throw new Error("UnionDiscriminator is abstract")}}Layout$1.UnionDiscriminator=UnionDiscriminator;class UnionLayoutDiscriminator extends UnionDiscriminator{constructor(t,c){if(!(t instanceof ExternalLayout&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(c||t.property||"variant"),this.layout=t}decode(t,c){return this.layout.decode(t,c)}encode(t,c,ie){return this.layout.encode(t,c,ie)}}Layout$1.UnionLayoutDiscriminator=UnionLayoutDiscriminator;class Union extends Layout{constructor(t,c,ie){let se;if(t instanceof UInt||t instanceof UIntBE)se=new UnionLayoutDiscriminator(new OffsetLayout(t));else if(t instanceof ExternalLayout&&t.isCount())se=new UnionLayoutDiscriminator(t);else if(t instanceof UnionDiscriminator)se=t;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(c===void 0&&(c=null),!(c===null||c instanceof Layout))throw new TypeError("defaultLayout must be null or a Layout");if(c!==null){if(0>c.span)throw new Error("defaultLayout must have constant span");c.property===void 0&&(c=c.replicate("content"))}let ae=-1;c&&(ae=c.span,0<=ae&&(t instanceof UInt||t instanceof UIntBE)&&(ae+=se.layout.span)),super(ae,ie),this.discriminator=se,this.usesPrefixDiscriminator=t instanceof UInt||t instanceof UIntBE,this.defaultLayout=c,this.registry={};let ue=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(de){return ue(de)},this.configGetSourceVariant=function(de){ue=de.bind(this)}}getSpan(t,c=0){if(0<=this.span)return this.span;const ie=this.getVariant(t,c);if(!ie)throw new Error("unable to determine span for unrecognized variant");return ie.getSpan(t,c)}defaultGetSourceVariant(t){if(Object.prototype.hasOwnProperty.call(t,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(t,this.defaultLayout.property))return;const c=this.registry[t[this.discriminator.property]];if(c&&(!c.layout||c.property&&Object.prototype.hasOwnProperty.call(t,c.property)))return c}else for(const c in this.registry){const ie=this.registry[c];if(ie.property&&Object.prototype.hasOwnProperty.call(t,ie.property))return ie}throw new Error("unable to infer src variant")}decode(t,c=0){let ie;const se=this.discriminator,ae=se.decode(t,c),ue=this.registry[ae];if(ue===void 0){const de=this.defaultLayout;let ve=0;this.usesPrefixDiscriminator&&(ve=se.layout.span),ie=this.makeDestinationObject(),ie[se.property]=ae,ie[de.property]=de.decode(t,c+ve)}else ie=ue.decode(t,c);return ie}encode(t,c,ie=0){const se=this.getSourceVariant(t);if(se===void 0){const ae=this.discriminator,ue=this.defaultLayout;let de=0;return this.usesPrefixDiscriminator&&(de=ae.layout.span),ae.encode(t[ae.property],c,ie),de+ue.encode(t[ue.property],c,ie+de)}return se.encode(t,c,ie)}addVariant(t,c,ie){const se=new VariantLayout(this,t,c,ie);return this.registry[t]=se,se}getVariant(t,c=0){let ie;return t instanceof Uint8Array?ie=this.discriminator.decode(t,c):ie=t,this.registry[ie]}}Layout$1.Union=Union;class VariantLayout extends Layout{constructor(t,c,ie,se){if(!(t instanceof Union))throw new TypeError("union must be a Union");if(!Number.isInteger(c)||0>c)throw new TypeError("variant must be a (non-negative) integer");if(typeof ie=="string"&&se===void 0&&(se=ie,ie=null),ie){if(!(ie instanceof Layout))throw new TypeError("layout must be a Layout");if(t.defaultLayout!==null&&0<=ie.span&&ie.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof se!="string")throw new TypeError("variant must have a String property")}let ae=t.span;0>t.span&&(ae=ie?ie.span:0,0<=ae&&t.usesPrefixDiscriminator&&(ae+=t.discriminator.layout.span)),super(ae,se),this.union=t,this.variant=c,this.layout=ie||null}getSpan(t,c=0){if(0<=this.span)return this.span;let ie=0;this.union.usesPrefixDiscriminator&&(ie=this.union.discriminator.layout.span);let se=0;return this.layout&&(se=this.layout.getSpan(t,c+ie)),ie+se}decode(t,c=0){const ie=this.makeDestinationObject();if(this!==this.union.getVariant(t,c))throw new Error("variant mismatch");let se=0;return this.union.usesPrefixDiscriminator&&(se=this.union.discriminator.layout.span),this.layout?ie[this.property]=this.layout.decode(t,c+se):this.property?ie[this.property]=!0:this.union.usesPrefixDiscriminator&&(ie[this.union.discriminator.property]=this.variant),ie}encode(t,c,ie=0){let se=0;if(this.union.usesPrefixDiscriminator&&(se=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(t,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,c,ie);let ae=se;if(this.layout&&(this.layout.encode(t[this.property],c,ie+se),ae+=this.layout.getSpan(c,ie+se),0<=this.union.span&&ae>this.union.span))throw new Error("encoded variant overruns containing union");return ae}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}Layout$1.VariantLayout=VariantLayout;function fixBitwiseResult(n){return 0>n&&(n+=4294967296),n}class BitStructure extends Layout{constructor(t,c,ie){if(!(t instanceof UInt||t instanceof UIntBE))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof c=="string"&&ie===void 0&&(ie=c,c=!1),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,ie),this.word=t,this.msb=!!c,this.fields=[];let se=0;this._packedSetValue=function(ae){return se=fixBitwiseResult(ae),this},this._packedGetValue=function(){return se}}decode(t,c=0){const ie=this.makeDestinationObject(),se=this.word.decode(t,c);this._packedSetValue(se);for(const ae of this.fields)ae.property!==void 0&&(ie[ae.property]=ae.decode(t));return ie}encode(t,c,ie=0){const se=this.word.decode(c,ie);this._packedSetValue(se);for(const ae of this.fields)if(ae.property!==void 0){const ue=t[ae.property];ue!==void 0&&ae.encode(ue)}return this.word.encode(this._packedGetValue(),c,ie)}addField(t,c){const ie=new BitField(this,t,c);return this.fields.push(ie),ie}addBoolean(t){const c=new Boolean$1(this,t);return this.fields.push(c),c}fieldFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const c of this.fields)if(c.property===t)return c}}Layout$1.BitStructure=BitStructure;class BitField{constructor(t,c,ie){if(!(t instanceof BitStructure))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(c)||0>=c)throw new TypeError("bits must be positive integer");const se=8*t.span,ae=t.fields.reduce((ue,de)=>ue+de.bits,0);if(c+ae>se)throw new Error("bits too long for span remainder ("+(se-ae)+" of "+se+" remain)");this.container=t,this.bits=c,this.valueMask=(1<<c)-1,c===32&&(this.valueMask=4294967295),this.start=ae,this.container.msb&&(this.start=se-ae-c),this.wordMask=fixBitwiseResult(this.valueMask<<this.start),this.property=ie}decode(t,c){const ie=this.container._packedGetValue();return fixBitwiseResult(ie&this.wordMask)>>>this.start}encode(t){if(typeof t!="number"||!Number.isInteger(t)||t!==fixBitwiseResult(t&this.valueMask))throw new TypeError(nameWithProperty("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const c=this.container._packedGetValue(),ie=fixBitwiseResult(t<<this.start);this.container._packedSetValue(fixBitwiseResult(c&~this.wordMask)|ie)}}Layout$1.BitField=BitField;let Boolean$1=class extends BitField{constructor(n,t){super(n,1,t)}decode(n,t){return!!super.decode(n,t)}encode(n){typeof n=="boolean"&&(n=+n),super.encode(n)}};Layout$1.Boolean=Boolean$1;let Blob$1$1=class extends Layout{constructor(t,c){if(!(t instanceof ExternalLayout&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let ie=-1;t instanceof ExternalLayout||(ie=t),super(ie,c),this.length=t}getSpan(t,c){let ie=this.span;return 0>ie&&(ie=this.length.decode(t,c)),ie}decode(t,c=0){let ie=this.span;return 0>ie&&(ie=this.length.decode(t,c)),uint8ArrayToBuffer(t).slice(c,c+ie)}encode(t,c,ie){let se=this.length;if(this.length instanceof ExternalLayout&&(se=t.length),!(t instanceof Uint8Array&&se===t.length))throw new TypeError(nameWithProperty("Blob.encode",this)+" requires (length "+se+") Uint8Array as src");if(ie+se>c.length)throw new RangeError("encoding overruns Uint8Array");const ae=uint8ArrayToBuffer(t);return uint8ArrayToBuffer(c).write(ae.toString("hex"),ie,se,"hex"),this.length instanceof ExternalLayout&&this.length.encode(se,c,ie),se}};Layout$1.Blob=Blob$1$1;class CString extends Layout{constructor(t){super(-1,t)}getSpan(t,c=0){checkUint8Array(t);let ie=c;for(;ie<t.length&&t[ie]!==0;)ie+=1;return 1+ie-c}decode(t,c=0){const ie=this.getSpan(t,c);return uint8ArrayToBuffer(t).slice(c,c+ie-1).toString("utf-8")}encode(t,c,ie=0){typeof t!="string"&&(t=String(t));const se=buffer_1.Buffer.from(t,"utf8"),ae=se.length;if(ie+ae>c.length)throw new RangeError("encoding overruns Buffer");const ue=uint8ArrayToBuffer(c);return se.copy(ue,ie),ue[ie+ae]=0,ae+1}}Layout$1.CString=CString;class UTF8 extends Layout{constructor(t,c){if(typeof t=="string"&&c===void 0&&(c=t,t=void 0),t===void 0)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");super(-1,c),this.maxSpan=t}getSpan(t,c=0){return checkUint8Array(t),t.length-c}decode(t,c=0){const ie=this.getSpan(t,c);if(0<=this.maxSpan&&this.maxSpan<ie)throw new RangeError("text length exceeds maxSpan");return uint8ArrayToBuffer(t).slice(c,c+ie).toString("utf-8")}encode(t,c,ie=0){typeof t!="string"&&(t=String(t));const se=buffer_1.Buffer.from(t,"utf8"),ae=se.length;if(0<=this.maxSpan&&this.maxSpan<ae)throw new RangeError("text length exceeds maxSpan");if(ie+ae>c.length)throw new RangeError("encoding overruns Buffer");return se.copy(uint8ArrayToBuffer(c),ie),ae}}Layout$1.UTF8=UTF8;class Constant extends Layout{constructor(t,c){super(0,c),this.value=t}decode(t,c){return this.value}encode(t,c,ie){return 0}}Layout$1.Constant=Constant;Layout$1.greedy=(n,t)=>new GreedyCount(n,t);var offset$2=Layout$1.offset=(n,t,c)=>new OffsetLayout(n,t,c),u8=Layout$1.u8=n=>new UInt(1,n),u16=Layout$1.u16=n=>new UInt(2,n);Layout$1.u24=n=>new UInt(3,n);var u32=Layout$1.u32=n=>new UInt(4,n);Layout$1.u40=n=>new UInt(5,n);Layout$1.u48=n=>new UInt(6,n);var nu64=Layout$1.nu64=n=>new NearUInt64(n);Layout$1.u16be=n=>new UIntBE(2,n);Layout$1.u24be=n=>new UIntBE(3,n);Layout$1.u32be=n=>new UIntBE(4,n);Layout$1.u40be=n=>new UIntBE(5,n);Layout$1.u48be=n=>new UIntBE(6,n);Layout$1.nu64be=n=>new NearUInt64BE(n);Layout$1.s8=n=>new Int(1,n);Layout$1.s16=n=>new Int(2,n);Layout$1.s24=n=>new Int(3,n);Layout$1.s32=n=>new Int(4,n);Layout$1.s40=n=>new Int(5,n);Layout$1.s48=n=>new Int(6,n);var ns64=Layout$1.ns64=n=>new NearInt64(n);Layout$1.s16be=n=>new IntBE(2,n);Layout$1.s24be=n=>new IntBE(3,n);Layout$1.s32be=n=>new IntBE(4,n);Layout$1.s40be=n=>new IntBE(5,n);Layout$1.s48be=n=>new IntBE(6,n);Layout$1.ns64be=n=>new NearInt64BE(n);Layout$1.f32=n=>new Float(n);Layout$1.f32be=n=>new FloatBE(n);Layout$1.f64=n=>new Double(n);Layout$1.f64be=n=>new DoubleBE(n);var struct=Layout$1.struct=(n,t,c)=>new Structure(n,t,c);Layout$1.bits=(n,t,c)=>new BitStructure(n,t,c);var seq=Layout$1.seq=(n,t,c)=>new Sequence(n,t,c);Layout$1.union=(n,t,c)=>new Union(n,t,c);Layout$1.unionLayoutDiscriminator=(n,t)=>new UnionLayoutDiscriminator(n,t);var blob=Layout$1.blob=(n,t)=>new Blob$1$1(n,t);Layout$1.cstr=n=>new CString(n);Layout$1.utf8=(n,t)=>new UTF8(n,t);Layout$1.constant=(n,t)=>new Constant(n,t);var browser$d={};Object.defineProperty(browser$d,"__esModule",{value:!0});function toBigIntLE(n){{const t=Buffer$7.from(n);t.reverse();const c=t.toString("hex");return c.length===0?BigInt(0):BigInt(`0x${c}`)}}var toBigIntLE_1=browser$d.toBigIntLE=toBigIntLE;function toBigIntBE(n){{const t=n.toString("hex");return t.length===0?BigInt(0):BigInt(`0x${t}`)}}browser$d.toBigIntBE=toBigIntBE;function toBufferLE(n,t){{const c=n.toString(16),ie=Buffer$7.from(c.padStart(t*2,"0").slice(0,t*2),"hex");return ie.reverse(),ie}}var toBufferLE_1=browser$d.toBufferLE=toBufferLE;function toBufferBE(n,t){{const c=n.toString(16);return Buffer$7.from(c.padStart(t*2,"0").slice(0,t*2),"hex")}}browser$d.toBufferBE=toBufferBE;class StructError extends TypeError{constructor(t,c){let ie;const{message:se,explanation:ae,...ue}=t,{path:de}=t,ve=de.length===0?se:`At path: ${de.join(".")} -- ${se}`;super(ae??ve),ae!=null&&(this.cause=ve),Object.assign(this,ue),this.name=this.constructor.name,this.failures=()=>ie??(ie=[t,...c()])}}function isIterable$1(n){return isObject$1$1(n)&&typeof n[Symbol.iterator]=="function"}function isObject$1$1(n){return typeof n=="object"&&n!=null}function isNonArrayObject(n){return isObject$1$1(n)&&!Array.isArray(n)}function print$2(n){return typeof n=="symbol"?n.toString():typeof n=="string"?JSON.stringify(n):`${n}`}function shiftIterator(n){const{done:t,value:c}=n.next();return t?void 0:c}function toFailure(n,t,c,ie){if(n===!0)return;n===!1?n={}:typeof n=="string"&&(n={message:n});const{path:se,branch:ae}=t,{type:ue}=c,{refinement:de,message:ve=`Expected a value of type \`${ue}\`${de?` with refinement \`${de}\``:""}, but received: \`${print$2(ie)}\``}=n;return{value:ie,type:ue,refinement:de,key:se[se.length-1],path:se,branch:ae,...n,message:ve}}function*toFailures(n,t,c,ie){isIterable$1(n)||(n=[n]);for(const se of n){const ae=toFailure(se,t,c,ie);ae&&(yield ae)}}function*run(n,t,c={}){const{path:ie=[],branch:se=[n],coerce:ae=!1,mask:ue=!1}=c,de={path:ie,branch:se,mask:ue};ae&&(n=t.coercer(n,de));let ve="valid";for(const ge of t.validator(n,de))ge.explanation=c.message,ve="not_valid",yield[ge,void 0];for(let[ge,we,Te]of t.entries(n,de)){const Ne=run(we,Te,{path:ge===void 0?ie:[...ie,ge],branch:ge===void 0?se:[...se,we],coerce:ae,mask:ue,message:c.message});for(const qe of Ne)qe[0]?(ve=qe[0].refinement!=null?"not_refined":"not_valid",yield[qe[0],void 0]):ae&&(we=qe[1],ge===void 0?n=we:n instanceof Map?n.set(ge,we):n instanceof Set?n.add(we):isObject$1$1(n)&&(we!==void 0||ge in n)&&(n[ge]=we))}if(ve!=="not_valid")for(const ge of t.refiner(n,de))ge.explanation=c.message,ve="not_refined",yield[ge,void 0];ve==="valid"&&(yield[void 0,n])}let Struct$1=class{constructor(n){const{type:t,schema:c,validator:ie,refiner:se,coercer:ae=de=>de,entries:ue=function*(){}}=n;this.type=t,this.schema=c,this.entries=ue,this.coercer=ae,ie?this.validator=(de,ve)=>{const ge=ie(de,ve);return toFailures(ge,ve,this,de)}:this.validator=()=>[],se?this.refiner=(de,ve)=>{const ge=se(de,ve);return toFailures(ge,ve,this,de)}:this.refiner=()=>[]}assert(n,t){return assert$a(n,this,t)}create(n,t){return create$1(n,this,t)}is(n){return is(n,this)}mask(n,t){return mask(n,this,t)}validate(n,t={}){return validate$1(n,this,t)}};function assert$a(n,t,c){const ie=validate$1(n,t,{message:c});if(ie[0])throw ie[0]}function create$1(n,t,c){const ie=validate$1(n,t,{coerce:!0,message:c});if(ie[0])throw ie[0];return ie[1]}function mask(n,t,c){const ie=validate$1(n,t,{coerce:!0,mask:!0,message:c});if(ie[0])throw ie[0];return ie[1]}function is(n,t){return!validate$1(n,t)[0]}function validate$1(n,t,c={}){const ie=run(n,t,c),se=shiftIterator(ie);return se[0]?[new StructError(se[0],function*(){for(const ae of ie)ae[0]&&(yield ae[0])}),void 0]:[void 0,se[1]]}function define(n,t){return new Struct$1({type:n,schema:null,validator:t})}function any(){return define("any",()=>!0)}function array(n){return new Struct$1({type:"array",schema:n,*entries(t){if(n&&Array.isArray(t))for(const[c,ie]of t.entries())yield[c,ie,n]},coercer(t){return Array.isArray(t)?t.slice():t},validator(t){return Array.isArray(t)||`Expected an array value, but received: ${print$2(t)}`}})}function boolean(){return define("boolean",n=>typeof n=="boolean")}function instance(n){return define("instance",t=>t instanceof n||`Expected a \`${n.name}\` instance, but received: ${print$2(t)}`)}function literal(n){const t=print$2(n),c=typeof n;return new Struct$1({type:"literal",schema:c==="string"||c==="number"||c==="boolean"?n:null,validator(ie){return ie===n||`Expected the literal \`${t}\`, but received: ${print$2(ie)}`}})}function never(){return define("never",()=>!1)}function nullable(n){return new Struct$1({...n,validator:(t,c)=>t===null||n.validator(t,c),refiner:(t,c)=>t===null||n.refiner(t,c)})}function number(){return define("number",n=>typeof n=="number"&&!isNaN(n)||`Expected a number, but received: ${print$2(n)}`)}function optional(n){return new Struct$1({...n,validator:(t,c)=>t===void 0||n.validator(t,c),refiner:(t,c)=>t===void 0||n.refiner(t,c)})}function record(n,t){return new Struct$1({type:"record",schema:null,*entries(c){if(isObject$1$1(c))for(const ie in c){const se=c[ie];yield[ie,ie,n],yield[ie,se,t]}},validator(c){return isNonArrayObject(c)||`Expected an object, but received: ${print$2(c)}`},coercer(c){return isNonArrayObject(c)?{...c}:c}})}function string(){return define("string",n=>typeof n=="string"||`Expected a string, but received: ${print$2(n)}`)}function tuple(n){const t=never();return new Struct$1({type:"tuple",schema:null,*entries(c){if(Array.isArray(c)){const ie=Math.max(n.length,c.length);for(let se=0;se<ie;se++)yield[se,c[se],n[se]||t]}},validator(c){return Array.isArray(c)||`Expected an array, but received: ${print$2(c)}`},coercer(c){return Array.isArray(c)?c.slice():c}})}function type$1(n){const t=Object.keys(n);return new Struct$1({type:"type",schema:n,*entries(c){if(isObject$1$1(c))for(const ie of t)yield[ie,c[ie],n[ie]]},validator(c){return isNonArrayObject(c)||`Expected an object, but received: ${print$2(c)}`},coercer(c){return isNonArrayObject(c)?{...c}:c}})}function union(n){const t=n.map(c=>c.type).join(" | ");return new Struct$1({type:"union",schema:null,coercer(c,ie){for(const se of n){const[ae,ue]=se.validate(c,{coerce:!0,mask:ie.mask});if(!ae)return ue}return c},validator(c,ie){const se=[];for(const ae of n){const[...ue]=run(c,ae,ie),[de]=ue;if(de[0])for(const[ve]of ue)ve&&se.push(ve);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${print$2(c)}`,...se]}})}function unknown(){return define("unknown",()=>!0)}function coerce(n,t,c){return new Struct$1({...n,coercer:(ie,se)=>is(ie,t)?n.coercer(c(ie,se),se):n.coercer(ie,se)})}var getRandomValues,rnds8=new Uint8Array(16);function rng(){if(!getRandomValues&&(getRandomValues=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!getRandomValues))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return getRandomValues(rnds8)}const REGEX$1=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function validate(n){return typeof n=="string"&&REGEX$1.test(n)}var byteToHex=[];for(var i$2=0;i$2<256;++i$2)byteToHex.push((i$2+256).toString(16).substr(1));function stringify$1(n){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,c=(byteToHex[n[t+0]]+byteToHex[n[t+1]]+byteToHex[n[t+2]]+byteToHex[n[t+3]]+"-"+byteToHex[n[t+4]]+byteToHex[n[t+5]]+"-"+byteToHex[n[t+6]]+byteToHex[n[t+7]]+"-"+byteToHex[n[t+8]]+byteToHex[n[t+9]]+"-"+byteToHex[n[t+10]]+byteToHex[n[t+11]]+byteToHex[n[t+12]]+byteToHex[n[t+13]]+byteToHex[n[t+14]]+byteToHex[n[t+15]]).toLowerCase();if(!validate(c))throw TypeError("Stringified UUID is invalid");return c}var _nodeId,_clockseq,_lastMSecs=0,_lastNSecs=0;function v1(n,t,c){var ie=t&&c||0,se=t||new Array(16);n=n||{};var ae=n.node||_nodeId,ue=n.clockseq!==void 0?n.clockseq:_clockseq;if(ae==null||ue==null){var de=n.random||(n.rng||rng)();ae==null&&(ae=_nodeId=[de[0]|1,de[1],de[2],de[3],de[4],de[5]]),ue==null&&(ue=_clockseq=(de[6]<<8|de[7])&16383)}var ve=n.msecs!==void 0?n.msecs:Date.now(),ge=n.nsecs!==void 0?n.nsecs:_lastNSecs+1,we=ve-_lastMSecs+(ge-_lastNSecs)/1e4;if(we<0&&n.clockseq===void 0&&(ue=ue+1&16383),(we<0||ve>_lastMSecs)&&n.nsecs===void 0&&(ge=0),ge>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_lastMSecs=ve,_lastNSecs=ge,_clockseq=ue,ve+=122192928e5;var Te=((ve&268435455)*1e4+ge)%4294967296;se[ie++]=Te>>>24&255,se[ie++]=Te>>>16&255,se[ie++]=Te>>>8&255,se[ie++]=Te&255;var Ne=ve/4294967296*1e4&268435455;se[ie++]=Ne>>>8&255,se[ie++]=Ne&255,se[ie++]=Ne>>>24&15|16,se[ie++]=Ne>>>16&255,se[ie++]=ue>>>8|128,se[ie++]=ue&255;for(var qe=0;qe<6;++qe)se[ie+qe]=ae[qe];return t||stringify$1(se)}function parse$1$1(n){if(!validate(n))throw TypeError("Invalid UUID");var t,c=new Uint8Array(16);return c[0]=(t=parseInt(n.slice(0,8),16))>>>24,c[1]=t>>>16&255,c[2]=t>>>8&255,c[3]=t&255,c[4]=(t=parseInt(n.slice(9,13),16))>>>8,c[5]=t&255,c[6]=(t=parseInt(n.slice(14,18),16))>>>8,c[7]=t&255,c[8]=(t=parseInt(n.slice(19,23),16))>>>8,c[9]=t&255,c[10]=(t=parseInt(n.slice(24,36),16))/1099511627776&255,c[11]=t/4294967296&255,c[12]=t>>>24&255,c[13]=t>>>16&255,c[14]=t>>>8&255,c[15]=t&255,c}function stringToBytes(n){n=unescape(encodeURIComponent(n));for(var t=[],c=0;c<n.length;++c)t.push(n.charCodeAt(c));return t}var DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",URL$1="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function v35(n,t,c){function ie(se,ae,ue,de){if(typeof se=="string"&&(se=stringToBytes(se)),typeof ae=="string"&&(ae=parse$1$1(ae)),ae.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var ve=new Uint8Array(16+se.length);if(ve.set(ae),ve.set(se,ae.length),ve=c(ve),ve[6]=ve[6]&15|t,ve[8]=ve[8]&63|128,ue){de=de||0;for(var ge=0;ge<16;++ge)ue[de+ge]=ve[ge];return ue}return stringify$1(ve)}try{ie.name=n}catch{}return ie.DNS=DNS,ie.URL=URL$1,ie}function md5$3(n){if(typeof n=="string"){var t=unescape(encodeURIComponent(n));n=new Uint8Array(t.length);for(var c=0;c<t.length;++c)n[c]=t.charCodeAt(c)}return md5ToHexEncodedArray(wordsToMd5(bytesToWords(n),n.length*8))}function md5ToHexEncodedArray(n){for(var t=[],c=n.length*32,ie="0123456789abcdef",se=0;se<c;se+=8){var ae=n[se>>5]>>>se%32&255,ue=parseInt(ie.charAt(ae>>>4&15)+ie.charAt(ae&15),16);t.push(ue)}return t}function getOutputLength(n){return(n+64>>>9<<4)+14+1}function wordsToMd5(n,t){n[t>>5]|=128<<t%32,n[getOutputLength(t)-1]=t;for(var c=1732584193,ie=-271733879,se=-1732584194,ae=271733878,ue=0;ue<n.length;ue+=16){var de=c,ve=ie,ge=se,we=ae;c=md5ff(c,ie,se,ae,n[ue],7,-680876936),ae=md5ff(ae,c,ie,se,n[ue+1],12,-389564586),se=md5ff(se,ae,c,ie,n[ue+2],17,606105819),ie=md5ff(ie,se,ae,c,n[ue+3],22,-1044525330),c=md5ff(c,ie,se,ae,n[ue+4],7,-176418897),ae=md5ff(ae,c,ie,se,n[ue+5],12,1200080426),se=md5ff(se,ae,c,ie,n[ue+6],17,-1473231341),ie=md5ff(ie,se,ae,c,n[ue+7],22,-45705983),c=md5ff(c,ie,se,ae,n[ue+8],7,1770035416),ae=md5ff(ae,c,ie,se,n[ue+9],12,-1958414417),se=md5ff(se,ae,c,ie,n[ue+10],17,-42063),ie=md5ff(ie,se,ae,c,n[ue+11],22,-1990404162),c=md5ff(c,ie,se,ae,n[ue+12],7,1804603682),ae=md5ff(ae,c,ie,se,n[ue+13],12,-40341101),se=md5ff(se,ae,c,ie,n[ue+14],17,-1502002290),ie=md5ff(ie,se,ae,c,n[ue+15],22,1236535329),c=md5gg(c,ie,se,ae,n[ue+1],5,-165796510),ae=md5gg(ae,c,ie,se,n[ue+6],9,-1069501632),se=md5gg(se,ae,c,ie,n[ue+11],14,643717713),ie=md5gg(ie,se,ae,c,n[ue],20,-373897302),c=md5gg(c,ie,se,ae,n[ue+5],5,-701558691),ae=md5gg(ae,c,ie,se,n[ue+10],9,38016083),se=md5gg(se,ae,c,ie,n[ue+15],14,-660478335),ie=md5gg(ie,se,ae,c,n[ue+4],20,-405537848),c=md5gg(c,ie,se,ae,n[ue+9],5,568446438),ae=md5gg(ae,c,ie,se,n[ue+14],9,-1019803690),se=md5gg(se,ae,c,ie,n[ue+3],14,-187363961),ie=md5gg(ie,se,ae,c,n[ue+8],20,1163531501),c=md5gg(c,ie,se,ae,n[ue+13],5,-1444681467),ae=md5gg(ae,c,ie,se,n[ue+2],9,-51403784),se=md5gg(se,ae,c,ie,n[ue+7],14,1735328473),ie=md5gg(ie,se,ae,c,n[ue+12],20,-1926607734),c=md5hh(c,ie,se,ae,n[ue+5],4,-378558),ae=md5hh(ae,c,ie,se,n[ue+8],11,-2022574463),se=md5hh(se,ae,c,ie,n[ue+11],16,1839030562),ie=md5hh(ie,se,ae,c,n[ue+14],23,-35309556),c=md5hh(c,ie,se,ae,n[ue+1],4,-1530992060),ae=md5hh(ae,c,ie,se,n[ue+4],11,1272893353),se=md5hh(se,ae,c,ie,n[ue+7],16,-155497632),ie=md5hh(ie,se,ae,c,n[ue+10],23,-1094730640),c=md5hh(c,ie,se,ae,n[ue+13],4,681279174),ae=md5hh(ae,c,ie,se,n[ue],11,-358537222),se=md5hh(se,ae,c,ie,n[ue+3],16,-722521979),ie=md5hh(ie,se,ae,c,n[ue+6],23,76029189),c=md5hh(c,ie,se,ae,n[ue+9],4,-640364487),ae=md5hh(ae,c,ie,se,n[ue+12],11,-421815835),se=md5hh(se,ae,c,ie,n[ue+15],16,530742520),ie=md5hh(ie,se,ae,c,n[ue+2],23,-995338651),c=md5ii(c,ie,se,ae,n[ue],6,-198630844),ae=md5ii(ae,c,ie,se,n[ue+7],10,1126891415),se=md5ii(se,ae,c,ie,n[ue+14],15,-1416354905),ie=md5ii(ie,se,ae,c,n[ue+5],21,-57434055),c=md5ii(c,ie,se,ae,n[ue+12],6,1700485571),ae=md5ii(ae,c,ie,se,n[ue+3],10,-1894986606),se=md5ii(se,ae,c,ie,n[ue+10],15,-1051523),ie=md5ii(ie,se,ae,c,n[ue+1],21,-2054922799),c=md5ii(c,ie,se,ae,n[ue+8],6,1873313359),ae=md5ii(ae,c,ie,se,n[ue+15],10,-30611744),se=md5ii(se,ae,c,ie,n[ue+6],15,-1560198380),ie=md5ii(ie,se,ae,c,n[ue+13],21,1309151649),c=md5ii(c,ie,se,ae,n[ue+4],6,-145523070),ae=md5ii(ae,c,ie,se,n[ue+11],10,-1120210379),se=md5ii(se,ae,c,ie,n[ue+2],15,718787259),ie=md5ii(ie,se,ae,c,n[ue+9],21,-343485551),c=safeAdd(c,de),ie=safeAdd(ie,ve),se=safeAdd(se,ge),ae=safeAdd(ae,we)}return[c,ie,se,ae]}function bytesToWords(n){if(n.length===0)return[];for(var t=n.length*8,c=new Uint32Array(getOutputLength(t)),ie=0;ie<t;ie+=8)c[ie>>5]|=(n[ie/8]&255)<<ie%32;return c}function safeAdd(n,t){var c=(n&65535)+(t&65535),ie=(n>>16)+(t>>16)+(c>>16);return ie<<16|c&65535}function bitRotateLeft(n,t){return n<<t|n>>>32-t}function md5cmn(n,t,c,ie,se,ae){return safeAdd(bitRotateLeft(safeAdd(safeAdd(t,n),safeAdd(ie,ae)),se),c)}function md5ff(n,t,c,ie,se,ae,ue){return md5cmn(t&c|~t&ie,n,t,se,ae,ue)}function md5gg(n,t,c,ie,se,ae,ue){return md5cmn(t&ie|c&~ie,n,t,se,ae,ue)}function md5hh(n,t,c,ie,se,ae,ue){return md5cmn(t^c^ie,n,t,se,ae,ue)}function md5ii(n,t,c,ie,se,ae,ue){return md5cmn(c^(t|~ie),n,t,se,ae,ue)}var v3=v35("v3",48,md5$3);function v4(n,t,c){n=n||{};var ie=n.random||(n.rng||rng)();if(ie[6]=ie[6]&15|64,ie[8]=ie[8]&63|128,t){c=c||0;for(var se=0;se<16;++se)t[c+se]=ie[se];return t}return stringify$1(ie)}function f$1(n,t,c,ie){switch(n){case 0:return t&c^~t&ie;case 1:return t^c^ie;case 2:return t&c^t&ie^c&ie;case 3:return t^c^ie}}function ROTL(n,t){return n<<t|n>>>32-t}function sha1$3(n){var t=[1518500249,1859775393,2400959708,3395469782],c=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof n=="string"){var ie=unescape(encodeURIComponent(n));n=[];for(var se=0;se<ie.length;++se)n.push(ie.charCodeAt(se))}else Array.isArray(n)||(n=Array.prototype.slice.call(n));n.push(128);for(var ae=n.length/4+2,ue=Math.ceil(ae/16),de=new Array(ue),ve=0;ve<ue;++ve){for(var ge=new Uint32Array(16),we=0;we<16;++we)ge[we]=n[ve*64+we*4]<<24|n[ve*64+we*4+1]<<16|n[ve*64+we*4+2]<<8|n[ve*64+we*4+3];de[ve]=ge}de[ue-1][14]=(n.length-1)*8/Math.pow(2,32),de[ue-1][14]=Math.floor(de[ue-1][14]),de[ue-1][15]=(n.length-1)*8&4294967295;for(var Te=0;Te<ue;++Te){for(var Ne=new Uint32Array(80),qe=0;qe<16;++qe)Ne[qe]=de[Te][qe];for(var ze=16;ze<80;++ze)Ne[ze]=ROTL(Ne[ze-3]^Ne[ze-8]^Ne[ze-14]^Ne[ze-16],1);for(var He=c[0],Ge=c[1],Ze=c[2],Ye=c[3],Ft=c[4],Mt=0;Mt<80;++Mt){var Zt=Math.floor(Mt/20),cn=ROTL(He,5)+f$1(Zt,Ge,Ze,Ye)+Ft+t[Zt]+Ne[Mt]>>>0;Ft=Ye,Ye=Ze,Ze=ROTL(Ge,30)>>>0,Ge=He,He=cn}c[0]=c[0]+He>>>0,c[1]=c[1]+Ge>>>0,c[2]=c[2]+Ze>>>0,c[3]=c[3]+Ye>>>0,c[4]=c[4]+Ft>>>0}return[c[0]>>24&255,c[0]>>16&255,c[0]>>8&255,c[0]&255,c[1]>>24&255,c[1]>>16&255,c[1]>>8&255,c[1]&255,c[2]>>24&255,c[2]>>16&255,c[2]>>8&255,c[2]&255,c[3]>>24&255,c[3]>>16&255,c[3]>>8&255,c[3]&255,c[4]>>24&255,c[4]>>16&255,c[4]>>8&255,c[4]&255]}var v5=v35("v5",80,sha1$3);const nil="00000000-0000-0000-0000-000000000000";function version$5(n){if(!validate(n))throw TypeError("Invalid UUID");return parseInt(n.substr(14,1),16)}const esmBrowser=Object.freeze(Object.defineProperty({__proto__:null,NIL:nil,parse:parse$1$1,stringify:stringify$1,v1,v3,v4,v5,validate,version:version$5},Symbol.toStringTag,{value:"Module"})),require$$0$2=getAugmentedNamespace(esmBrowser),uuid$1=require$$0$2.v4,generateRequest$1=function(n,t,c,ie){if(typeof n!="string")throw new TypeError(n+" must be a string");ie=ie||{};const se=typeof ie.version=="number"?ie.version:2;if(se!==1&&se!==2)throw new TypeError(se+" must be 1 or 2");const ae={method:n};if(se===2&&(ae.jsonrpc="2.0"),t){if(typeof t!="object"&&!Array.isArray(t))throw new TypeError(t+" must be an object, array or omitted");ae.params=t}if(typeof c>"u"){const ue=typeof ie.generator=="function"?ie.generator:function(){return uuid$1()};ae.id=ue(ae,ie)}else se===2&&c===null?ie.notificationIdNull&&(ae.id=null):ae.id=c;return ae};var generateRequest_1=generateRequest$1;const uuid=require$$0$2.v4,generateRequest=generateRequest_1,ClientBrowser=function(n,t){if(!(this instanceof ClientBrowser))return new ClientBrowser(n,t);t||(t={}),this.options={reviver:typeof t.reviver<"u"?t.reviver:null,replacer:typeof t.replacer<"u"?t.replacer:null,generator:typeof t.generator<"u"?t.generator:function(){return uuid()},version:typeof t.version<"u"?t.version:2,notificationIdNull:typeof t.notificationIdNull=="boolean"?t.notificationIdNull:!1},this.callServer=n};var browser$c=ClientBrowser;ClientBrowser.prototype.request=function(n,t,c,ie){const se=this;let ae=null;const ue=Array.isArray(n)&&typeof t=="function";if(this.options.version===1&&ue)throw new TypeError("JSON-RPC 1.0 does not support batching");if(ue||!ue&&n&&typeof n=="object"&&typeof t=="function")ie=t,ae=n;else{typeof c=="function"&&(ie=c,c=void 0);const ve=typeof ie=="function";try{ae=generateRequest(n,t,c,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(ge){if(ve)return ie(ge);throw ge}if(!ve)return ae}let de;try{de=JSON.stringify(ae,this.options.replacer)}catch(ve){return ie(ve)}return this.callServer(de,function(ve,ge){se._parseResponse(ve,ge,ie)}),ae};ClientBrowser.prototype._parseResponse=function(n,t,c){if(n){c(n);return}if(!t)return c();let ie;try{ie=JSON.parse(t,this.options.reviver)}catch(se){return c(se)}if(c.length===3)if(Array.isArray(ie)){const se=function(ue){return typeof ue.error<"u"},ae=function(ue){return!se(ue)};return c(null,ie.filter(se),ie.filter(ae))}else return c(null,ie.error,ie.result);c(null,ie)};const RpcClient=getDefaultExportFromCjs$2(browser$c);var eventemitter3={exports:{}};(function(n){var t=Object.prototype.hasOwnProperty,c="~";function ie(){}Object.create&&(ie.prototype=Object.create(null),new ie().__proto__||(c=!1));function se(ve,ge,we){this.fn=ve,this.context=ge,this.once=we||!1}function ae(ve,ge,we,Te,Ne){if(typeof we!="function")throw new TypeError("The listener must be a function");var qe=new se(we,Te||ve,Ne),ze=c?c+ge:ge;return ve._events[ze]?ve._events[ze].fn?ve._events[ze]=[ve._events[ze],qe]:ve._events[ze].push(qe):(ve._events[ze]=qe,ve._eventsCount++),ve}function ue(ve,ge){--ve._eventsCount===0?ve._events=new ie:delete ve._events[ge]}function de(){this._events=new ie,this._eventsCount=0}de.prototype.eventNames=function(){var ve=[],ge,we;if(this._eventsCount===0)return ve;for(we in ge=this._events)t.call(ge,we)&&ve.push(c?we.slice(1):we);return Object.getOwnPropertySymbols?ve.concat(Object.getOwnPropertySymbols(ge)):ve},de.prototype.listeners=function(ve){var ge=c?c+ve:ve,we=this._events[ge];if(!we)return[];if(we.fn)return[we.fn];for(var Te=0,Ne=we.length,qe=new Array(Ne);Te<Ne;Te++)qe[Te]=we[Te].fn;return qe},de.prototype.listenerCount=function(ve){var ge=c?c+ve:ve,we=this._events[ge];return we?we.fn?1:we.length:0},de.prototype.emit=function(ve,ge,we,Te,Ne,qe){var ze=c?c+ve:ve;if(!this._events[ze])return!1;var He=this._events[ze],Ge=arguments.length,Ze,Ye;if(He.fn){switch(He.once&&this.removeListener(ve,He.fn,void 0,!0),Ge){case 1:return He.fn.call(He.context),!0;case 2:return He.fn.call(He.context,ge),!0;case 3:return He.fn.call(He.context,ge,we),!0;case 4:return He.fn.call(He.context,ge,we,Te),!0;case 5:return He.fn.call(He.context,ge,we,Te,Ne),!0;case 6:return He.fn.call(He.context,ge,we,Te,Ne,qe),!0}for(Ye=1,Ze=new Array(Ge-1);Ye<Ge;Ye++)Ze[Ye-1]=arguments[Ye];He.fn.apply(He.context,Ze)}else{var Ft=He.length,Mt;for(Ye=0;Ye<Ft;Ye++)switch(He[Ye].once&&this.removeListener(ve,He[Ye].fn,void 0,!0),Ge){case 1:He[Ye].fn.call(He[Ye].context);break;case 2:He[Ye].fn.call(He[Ye].context,ge);break;case 3:He[Ye].fn.call(He[Ye].context,ge,we);break;case 4:He[Ye].fn.call(He[Ye].context,ge,we,Te);break;default:if(!Ze)for(Mt=1,Ze=new Array(Ge-1);Mt<Ge;Mt++)Ze[Mt-1]=arguments[Mt];He[Ye].fn.apply(He[Ye].context,Ze)}}return!0},de.prototype.on=function(ve,ge,we){return ae(this,ve,ge,we,!1)},de.prototype.once=function(ve,ge,we){return ae(this,ve,ge,we,!0)},de.prototype.removeListener=function(ve,ge,we,Te){var Ne=c?c+ve:ve;if(!this._events[Ne])return this;if(!ge)return ue(this,Ne),this;var qe=this._events[Ne];if(qe.fn)qe.fn===ge&&(!Te||qe.once)&&(!we||qe.context===we)&&ue(this,Ne);else{for(var ze=0,He=[],Ge=qe.length;ze<Ge;ze++)(qe[ze].fn!==ge||Te&&!qe[ze].once||we&&qe[ze].context!==we)&&He.push(qe[ze]);He.length?this._events[Ne]=He.length===1?He[0]:He:ue(this,Ne)}return this},de.prototype.removeAllListeners=function(ve){var ge;return ve?(ge=c?c+ve:ve,this._events[ge]&&ue(this,ge)):(this._events=new ie,this._eventsCount=0),this},de.prototype.off=de.prototype.removeListener,de.prototype.addListener=de.prototype.on,de.prefixed=c,de.EventEmitter=de,n.exports=de})(eventemitter3);var eventemitter3Exports=eventemitter3.exports;const EventEmitter=getDefaultExportFromCjs$2(eventemitter3Exports);var WebSocketBrowserImpl=class extends EventEmitter{constructor(n,t,c){super(),Xn(this,"socket"),this.socket=new window.WebSocket(n,c),this.socket.onopen=()=>this.emit("open"),this.socket.onmessage=ie=>this.emit("message",ie.data),this.socket.onerror=ie=>this.emit("error",ie),this.socket.onclose=ie=>{this.emit("close",ie.code,ie.reason)}}send(n,t,c){const ie=c||t;try{this.socket.send(n),ie()}catch(se){ie(se)}}close(n,t){this.socket.close(n,t)}addEventListener(n,t,c){this.socket.addEventListener(n,t,c)}};function WebSocket(n,t){return new WebSocketBrowserImpl(n,t)}var DefaultDataPack=class{encode(n){return JSON.stringify(n)}decode(n){return JSON.parse(n)}},CommonClient=class extends EventEmitter{constructor(n,t="ws://localhost:8080",{autoconnect:c=!0,reconnect:ie=!0,reconnect_interval:se=1e3,max_reconnects:ae=5,...ue}={},de,ve){super(),Xn(this,"address"),Xn(this,"rpc_id"),Xn(this,"queue"),Xn(this,"options"),Xn(this,"autoconnect"),Xn(this,"ready"),Xn(this,"reconnect"),Xn(this,"reconnect_timer_id"),Xn(this,"reconnect_interval"),Xn(this,"max_reconnects"),Xn(this,"rest_options"),Xn(this,"current_reconnects"),Xn(this,"generate_request_id"),Xn(this,"socket"),Xn(this,"webSocketFactory"),Xn(this,"dataPack"),this.webSocketFactory=n,this.queue={},this.rpc_id=0,this.address=t,this.autoconnect=c,this.ready=!1,this.reconnect=ie,this.reconnect_timer_id=void 0,this.reconnect_interval=se,this.max_reconnects=ae,this.rest_options=ue,this.current_reconnects=0,this.generate_request_id=de||(()=>typeof this.rpc_id=="number"?++this.rpc_id:Number(this.rpc_id)+1),ve?this.dataPack=ve:this.dataPack=new DefaultDataPack,this.autoconnect&&this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}connect(){this.socket||this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}call(n,t,c,ie){return!ie&&typeof c=="object"&&(ie=c,c=null),new Promise((se,ae)=>{if(!this.ready)return ae(new Error("socket not ready"));const ue=this.generate_request_id(n,t),de={jsonrpc:"2.0",method:n,params:t||void 0,id:ue};this.socket.send(this.dataPack.encode(de),ie,ve=>{if(ve)return ae(ve);this.queue[ue]={promise:[se,ae]},c&&(this.queue[ue].timeout=setTimeout(()=>{delete this.queue[ue],ae(new Error("reply timeout"))},c))})})}async login(n){const t=await this.call("rpc.login",n);if(!t)throw new Error("authentication failed");return t}async listMethods(){return await this.call("__listMethods")}notify(n,t){return new Promise((c,ie)=>{if(!this.ready)return ie(new Error("socket not ready"));const se={jsonrpc:"2.0",method:n,params:t};this.socket.send(this.dataPack.encode(se),ae=>{if(ae)return ie(ae);c()})})}async subscribe(n){typeof n=="string"&&(n=[n]);const t=await this.call("rpc.on",n);if(typeof n=="string"&&t[n]!=="ok")throw new Error("Failed subscribing to an event '"+n+"' with: "+t[n]);return t}async unsubscribe(n){typeof n=="string"&&(n=[n]);const t=await this.call("rpc.off",n);if(typeof n=="string"&&t[n]!=="ok")throw new Error("Failed unsubscribing from an event with: "+t);return t}close(n,t){this.socket&&this.socket.close(n||1e3,t)}setAutoReconnect(n){this.reconnect=n}setReconnectInterval(n){this.reconnect_interval=n}setMaxReconnects(n){this.max_reconnects=n}getCurrentReconnects(){return this.current_reconnects}getMaxReconnects(){return this.max_reconnects}isReconnecting(){return this.reconnect_timer_id!==void 0}willReconnect(){return this.reconnect&&(this.max_reconnects===0||this.current_reconnects<this.max_reconnects)}_connect(n,t){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(n,t),this.socket.addEventListener("open",()=>{this.ready=!0,this.emit("open"),this.current_reconnects=0}),this.socket.addEventListener("message",({data:c})=>{c instanceof ArrayBuffer&&(c=Buffer$1$1.from(c).toString());try{c=this.dataPack.decode(c)}catch{return}if(c.notification&&this.listeners(c.notification).length){if(!Object.keys(c.params).length)return this.emit(c.notification);const ie=[c.notification];if(c.params.constructor===Object)ie.push(c.params);else for(let se=0;se<c.params.length;se++)ie.push(c.params[se]);return Promise.resolve().then(()=>{this.emit.apply(this,ie)})}if(!this.queue[c.id])return c.method?Promise.resolve().then(()=>{this.emit(c.method,c?.params)}):void 0;"error"in c=="result"in c&&this.queue[c.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[c.id].timeout&&clearTimeout(this.queue[c.id].timeout),c.error?this.queue[c.id].promise[1](c.error):this.queue[c.id].promise[0](c.result),delete this.queue[c.id]}),this.socket.addEventListener("error",c=>this.emit("error",c)),this.socket.addEventListener("close",({code:c,reason:ie})=>{this.ready&&setTimeout(()=>this.emit("close",c,ie),0),this.ready=!1,this.socket=void 0,c!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)?this.reconnect_timer_id=setTimeout(()=>this._connect(n,t),this.reconnect_interval):this.reconnect&&this.max_reconnects>0&&this.current_reconnects>=this.max_reconnects&&setTimeout(()=>this.emit("max_reconnects_reached",c,ie),1))})}};class HMAC extends Hash{constructor(t,c){super(),this.finished=!1,this.destroyed=!1,ahash(t);const ie=toBytes(c);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const se=this.blockLen,ae=new Uint8Array(se);ae.set(ie.length>se?t.create().update(ie).digest():ie);for(let ue=0;ue<ae.length;ue++)ae[ue]^=54;this.iHash.update(ae),this.oHash=t.create();for(let ue=0;ue<ae.length;ue++)ae[ue]^=106;this.oHash.update(ae),clean(ae)}update(t){return aexists(this),this.iHash.update(t),this}digestInto(t){aexists(this),abytes(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:c,iHash:ie,finished:se,destroyed:ae,blockLen:ue,outputLen:de}=this;return t=t,t.finished=se,t.destroyed=ae,t.blockLen=ue,t.outputLen=de,t.oHash=c._cloneInto(t.oHash),t.iHash=ie._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const hmac=(n,t,c)=>new HMAC(n,t).update(c).digest();hmac.create=(n,t)=>new HMAC(n,t);const divNearest=(n,t)=>(n+(n>=0?t:-t)/_2n$1)/t;function _splitEndoScalar(n,t,c){const[[ie,se],[ae,ue]]=t,de=divNearest(ue*n,c),ve=divNearest(-se*n,c);let ge=n-de*ie-ve*ae,we=-de*se-ve*ue;const Te=ge<_0n,Ne=we<_0n;Te&&(ge=-ge),Ne&&(we=-we);const qe=bitMask(Math.ceil(bitLen(c)/2))+_1n;if(ge<_0n||ge>=qe||we<_0n||we>=qe)throw new Error("splitScalar (endomorphism): failed, k="+n);return{k1neg:Te,k1:ge,k2neg:Ne,k2:we}}function validateSigFormat(n){if(!["compact","recovered","der"].includes(n))throw new Error('Signature format must be "compact", "recovered", or "der"');return n}function validateSigOpts(n,t){const c={};for(let ie of Object.keys(t))c[ie]=n[ie]===void 0?t[ie]:n[ie];return _abool2(c.lowS,"lowS"),_abool2(c.prehash,"prehash"),c.format!==void 0&&validateSigFormat(c.format),c}class DERErr extends Error{constructor(t=""){super(t)}}const DER={Err:DERErr,_tlv:{encode:(n,t)=>{const{Err:c}=DER;if(n<0||n>256)throw new c("tlv.encode: wrong tag");if(t.length&1)throw new c("tlv.encode: unpadded data");const ie=t.length/2,se=numberToHexUnpadded(ie);if(se.length/2&128)throw new c("tlv.encode: long form length too big");const ae=ie>127?numberToHexUnpadded(se.length/2|128):"";return numberToHexUnpadded(n)+ae+se+t},decode(n,t){const{Err:c}=DER;let ie=0;if(n<0||n>256)throw new c("tlv.encode: wrong tag");if(t.length<2||t[ie++]!==n)throw new c("tlv.decode: wrong tlv");const se=t[ie++],ae=!!(se&128);let ue=0;if(!ae)ue=se;else{const ve=se&127;if(!ve)throw new c("tlv.decode(long): indefinite length not supported");if(ve>4)throw new c("tlv.decode(long): byte length is too big");const ge=t.subarray(ie,ie+ve);if(ge.length!==ve)throw new c("tlv.decode: length bytes not complete");if(ge[0]===0)throw new c("tlv.decode(long): zero leftmost byte");for(const we of ge)ue=ue<<8|we;if(ie+=ve,ue<128)throw new c("tlv.decode(long): not minimal encoding")}const de=t.subarray(ie,ie+ue);if(de.length!==ue)throw new c("tlv.decode: wrong value length");return{v:de,l:t.subarray(ie+ue)}}},_int:{encode(n){const{Err:t}=DER;if(n<_0n)throw new t("integer: negative integers are not allowed");let c=numberToHexUnpadded(n);if(Number.parseInt(c[0],16)&8&&(c="00"+c),c.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return c},decode(n){const{Err:t}=DER;if(n[0]&128)throw new t("invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return bytesToNumberBE(n)}},toSig(n){const{Err:t,_int:c,_tlv:ie}=DER,se=ensureBytes("signature",n),{v:ae,l:ue}=ie.decode(48,se);if(ue.length)throw new t("invalid signature: left bytes after parsing");const{v:de,l:ve}=ie.decode(2,ae),{v:ge,l:we}=ie.decode(2,ve);if(we.length)throw new t("invalid signature: left bytes after parsing");return{r:c.decode(de),s:c.decode(ge)}},hexFromSig(n){const{_tlv:t,_int:c}=DER,ie=t.encode(2,c.encode(n.r)),se=t.encode(2,c.encode(n.s)),ae=ie+se;return t.encode(48,ae)}},_0n=BigInt(0),_1n=BigInt(1),_2n$1=BigInt(2),_3n=BigInt(3),_4n=BigInt(4);function _normFnElement(n,t){const{BYTES:c}=n;let ie;if(typeof t=="bigint")ie=t;else{let se=ensureBytes("private key",t);try{ie=n.fromBytes(se)}catch{throw new Error(`invalid private key: expected ui8a of size ${c}, got ${typeof t}`)}}if(!n.isValidNot0(ie))throw new Error("invalid private key: out of range [1..N-1]");return ie}function weierstrassN(n,t={}){const c=_createCurveFields("weierstrass",n,t),{Fp:ie,Fn:se}=c;let ae=c.CURVE;const{h:ue,n:de}=ae;_validateObject(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:ve}=t;if(ve&&(!ie.is0(ae.a)||typeof ve.beta!="bigint"||!Array.isArray(ve.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const ge=getWLengths(ie,se);function we(){if(!ie.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function Te(pe,be,xe){const{x:_e,y:De}=be.toAffine(),Fe=ie.toBytes(_e);if(_abool2(xe,"isCompressed"),xe){we();const $e=!ie.isOdd(De);return concatBytes(pprefix($e),Fe)}else return concatBytes(Uint8Array.of(4),Fe,ie.toBytes(De))}function Ne(pe){_abytes2(pe,void 0,"Point");const{publicKey:be,publicKeyUncompressed:xe}=ge,_e=pe.length,De=pe[0],Fe=pe.subarray(1);if(_e===be&&(De===2||De===3)){const $e=ie.fromBytes(Fe);if(!ie.isValid($e))throw new Error("bad point: is not on curve, wrong x");const ce=He($e);let Me;try{Me=ie.sqrt(ce)}catch($t){const dn=$t instanceof Error?": "+$t.message:"";throw new Error("bad point: is not on curve, sqrt error"+dn)}we();const We=ie.isOdd(Me);return(De&1)===1!==We&&(Me=ie.neg(Me)),{x:$e,y:Me}}else if(_e===xe&&De===4){const $e=ie.BYTES,ce=ie.fromBytes(Fe.subarray(0,$e)),Me=ie.fromBytes(Fe.subarray($e,$e*2));if(!Ge(ce,Me))throw new Error("bad point: is not on curve");return{x:ce,y:Me}}else throw new Error(`bad point: got length ${_e}, expected compressed=${be} or uncompressed=${xe}`)}const qe=t.toBytes||Te,ze=t.fromBytes||Ne;function He(pe){const be=ie.sqr(pe),xe=ie.mul(be,pe);return ie.add(ie.add(xe,ie.mul(pe,ae.a)),ae.b)}function Ge(pe,be){const xe=ie.sqr(be),_e=He(pe);return ie.eql(xe,_e)}if(!Ge(ae.Gx,ae.Gy))throw new Error("bad curve params: generator point");const Ze=ie.mul(ie.pow(ae.a,_3n),_4n),Ye=ie.mul(ie.sqr(ae.b),BigInt(27));if(ie.is0(ie.add(Ze,Ye)))throw new Error("bad curve params: a or b");function Ft(pe,be,xe=!1){if(!ie.isValid(be)||xe&&ie.is0(be))throw new Error(`bad point coordinate ${pe}`);return be}function Mt(pe){if(!(pe instanceof Ht))throw new Error("ProjectivePoint expected")}function Zt(pe){if(!ve||!ve.basises)throw new Error("no endo");return _splitEndoScalar(pe,ve.basises,se.ORDER)}const cn=memoized((pe,be)=>{const{X:xe,Y:_e,Z:De}=pe;if(ie.eql(De,ie.ONE))return{x:xe,y:_e};const Fe=pe.is0();be==null&&(be=Fe?ie.ONE:ie.inv(De));const $e=ie.mul(xe,be),ce=ie.mul(_e,be),Me=ie.mul(De,be);if(Fe)return{x:ie.ZERO,y:ie.ZERO};if(!ie.eql(Me,ie.ONE))throw new Error("invZ was invalid");return{x:$e,y:ce}}),hn=memoized(pe=>{if(pe.is0()){if(t.allowInfinityPoint&&!ie.is0(pe.Y))return;throw new Error("bad point: ZERO")}const{x:be,y:xe}=pe.toAffine();if(!ie.isValid(be)||!ie.isValid(xe))throw new Error("bad point: x or y not field elements");if(!Ge(be,xe))throw new Error("bad point: equation left != right");if(!pe.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function yn(pe,be,xe,_e,De){return xe=new Ht(ie.mul(xe.X,pe),xe.Y,xe.Z),be=negateCt(_e,be),xe=negateCt(De,xe),be.add(xe)}class Ht{constructor(be,xe,_e){this.X=Ft("x",be),this.Y=Ft("y",xe,!0),this.Z=Ft("z",_e),Object.freeze(this)}static CURVE(){return ae}static fromAffine(be){const{x:xe,y:_e}=be||{};if(!be||!ie.isValid(xe)||!ie.isValid(_e))throw new Error("invalid affine point");if(be instanceof Ht)throw new Error("projective point not allowed");return ie.is0(xe)&&ie.is0(_e)?Ht.ZERO:new Ht(xe,_e,ie.ONE)}static fromBytes(be){const xe=Ht.fromAffine(ze(_abytes2(be,void 0,"point")));return xe.assertValidity(),xe}static fromHex(be){return Ht.fromBytes(ensureBytes("pointHex",be))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(be=8,xe=!0){return le.createCache(this,be),xe||this.multiply(_3n),this}assertValidity(){hn(this)}hasEvenY(){const{y:be}=this.toAffine();if(!ie.isOdd)throw new Error("Field doesn't support isOdd");return!ie.isOdd(be)}equals(be){Mt(be);const{X:xe,Y:_e,Z:De}=this,{X:Fe,Y:$e,Z:ce}=be,Me=ie.eql(ie.mul(xe,ce),ie.mul(Fe,De)),We=ie.eql(ie.mul(_e,ce),ie.mul($e,De));return Me&&We}negate(){return new Ht(this.X,ie.neg(this.Y),this.Z)}double(){const{a:be,b:xe}=ae,_e=ie.mul(xe,_3n),{X:De,Y:Fe,Z:$e}=this;let ce=ie.ZERO,Me=ie.ZERO,We=ie.ZERO,$t=ie.mul(De,De),dn=ie.mul(Fe,Fe),gn=ie.mul($e,$e),Vt=ie.mul(De,Fe);return Vt=ie.add(Vt,Vt),We=ie.mul(De,$e),We=ie.add(We,We),ce=ie.mul(be,We),Me=ie.mul(_e,gn),Me=ie.add(ce,Me),ce=ie.sub(dn,Me),Me=ie.add(dn,Me),Me=ie.mul(ce,Me),ce=ie.mul(Vt,ce),We=ie.mul(_e,We),gn=ie.mul(be,gn),Vt=ie.sub($t,gn),Vt=ie.mul(be,Vt),Vt=ie.add(Vt,We),We=ie.add($t,$t),$t=ie.add(We,$t),$t=ie.add($t,gn),$t=ie.mul($t,Vt),Me=ie.add(Me,$t),gn=ie.mul(Fe,$e),gn=ie.add(gn,gn),$t=ie.mul(gn,Vt),ce=ie.sub(ce,$t),We=ie.mul(gn,dn),We=ie.add(We,We),We=ie.add(We,We),new Ht(ce,Me,We)}add(be){Mt(be);const{X:xe,Y:_e,Z:De}=this,{X:Fe,Y:$e,Z:ce}=be;let Me=ie.ZERO,We=ie.ZERO,$t=ie.ZERO;const dn=ae.a,gn=ie.mul(ae.b,_3n);let Vt=ie.mul(xe,Fe),Cn=ie.mul(_e,$e),un=ie.mul(De,ce),Pt=ie.add(xe,_e),mn=ie.add(Fe,$e);Pt=ie.mul(Pt,mn),mn=ie.add(Vt,Cn),Pt=ie.sub(Pt,mn),mn=ie.add(xe,De);let Pn=ie.add(Fe,ce);return mn=ie.mul(mn,Pn),Pn=ie.add(Vt,un),mn=ie.sub(mn,Pn),Pn=ie.add(_e,De),Me=ie.add($e,ce),Pn=ie.mul(Pn,Me),Me=ie.add(Cn,un),Pn=ie.sub(Pn,Me),$t=ie.mul(dn,mn),Me=ie.mul(gn,un),$t=ie.add(Me,$t),Me=ie.sub(Cn,$t),$t=ie.add(Cn,$t),We=ie.mul(Me,$t),Cn=ie.add(Vt,Vt),Cn=ie.add(Cn,Vt),un=ie.mul(dn,un),mn=ie.mul(gn,mn),Cn=ie.add(Cn,un),un=ie.sub(Vt,un),un=ie.mul(dn,un),mn=ie.add(mn,un),Vt=ie.mul(Cn,mn),We=ie.add(We,Vt),Vt=ie.mul(Pn,mn),Me=ie.mul(Pt,Me),Me=ie.sub(Me,Vt),Vt=ie.mul(Pt,Cn),$t=ie.mul(Pn,$t),$t=ie.add($t,Vt),new Ht(Me,We,$t)}subtract(be){return this.add(be.negate())}is0(){return this.equals(Ht.ZERO)}multiply(be){const{endo:xe}=t;if(!se.isValidNot0(be))throw new Error("invalid scalar: out of range");let _e,De;const Fe=$e=>le.cached(this,$e,ce=>normalizeZ(Ht,ce));if(xe){const{k1neg:$e,k1:ce,k2neg:Me,k2:We}=Zt(be),{p:$t,f:dn}=Fe(ce),{p:gn,f:Vt}=Fe(We);De=dn.add(Vt),_e=yn(xe.beta,$t,gn,$e,Me)}else{const{p:$e,f:ce}=Fe(be);_e=$e,De=ce}return normalizeZ(Ht,[_e,De])[0]}multiplyUnsafe(be){const{endo:xe}=t,_e=this;if(!se.isValid(be))throw new Error("invalid scalar: out of range");if(be===_0n||_e.is0())return Ht.ZERO;if(be===_1n)return _e;if(le.hasCache(this))return this.multiply(be);if(xe){const{k1neg:De,k1:Fe,k2neg:$e,k2:ce}=Zt(be),{p1:Me,p2:We}=mulEndoUnsafe(Ht,_e,Fe,ce);return yn(xe.beta,Me,We,De,$e)}else return le.unsafe(_e,be)}multiplyAndAddUnsafe(be,xe,_e){const De=this.multiplyUnsafe(xe).add(be.multiplyUnsafe(_e));return De.is0()?void 0:De}toAffine(be){return cn(this,be)}isTorsionFree(){const{isTorsionFree:be}=t;return ue===_1n?!0:be?be(Ht,this):le.unsafe(this,de).is0()}clearCofactor(){const{clearCofactor:be}=t;return ue===_1n?this:be?be(Ht,this):this.multiplyUnsafe(ue)}isSmallOrder(){return this.multiplyUnsafe(ue).is0()}toBytes(be=!0){return _abool2(be,"isCompressed"),this.assertValidity(),qe(Ht,this,be)}toHex(be=!0){return bytesToHex(this.toBytes(be))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(be=!0){return this.toBytes(be)}_setWindowSize(be){this.precompute(be)}static normalizeZ(be){return normalizeZ(Ht,be)}static msm(be,xe){return pippenger(Ht,se,be,xe)}static fromPrivateKey(be){return Ht.BASE.multiply(_normFnElement(se,be))}}Ht.BASE=new Ht(ae.Gx,ae.Gy,ie.ONE),Ht.ZERO=new Ht(ie.ZERO,ie.ONE,ie.ZERO),Ht.Fp=ie,Ht.Fn=se;const Sn=se.BITS,le=new wNAF(Ht,t.endo?Math.ceil(Sn/2):Sn);return Ht.BASE.precompute(8),Ht}function pprefix(n){return Uint8Array.of(n?2:3)}function getWLengths(n,t){return{secretKey:t.BYTES,publicKey:1+n.BYTES,publicKeyUncompressed:1+2*n.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function ecdh(n,t={}){const{Fn:c}=n,ie=t.randomBytes||randomBytes,se=Object.assign(getWLengths(n.Fp,c),{seed:getMinHashLength(c.ORDER)});function ae(Ne){try{return!!_normFnElement(c,Ne)}catch{return!1}}function ue(Ne,qe){const{publicKey:ze,publicKeyUncompressed:He}=se;try{const Ge=Ne.length;return qe===!0&&Ge!==ze||qe===!1&&Ge!==He?!1:!!n.fromBytes(Ne)}catch{return!1}}function de(Ne=ie(se.seed)){return mapHashToField(_abytes2(Ne,se.seed,"seed"),c.ORDER)}function ve(Ne,qe=!0){return n.BASE.multiply(_normFnElement(c,Ne)).toBytes(qe)}function ge(Ne){const qe=de(Ne);return{secretKey:qe,publicKey:ve(qe)}}function we(Ne){if(typeof Ne=="bigint")return!1;if(Ne instanceof n)return!0;const{secretKey:qe,publicKey:ze,publicKeyUncompressed:He}=se;if(c.allowedLengths||qe===ze)return;const Ge=ensureBytes("key",Ne).length;return Ge===ze||Ge===He}function Te(Ne,qe,ze=!0){if(we(Ne)===!0)throw new Error("first arg must be private key");if(we(qe)===!1)throw new Error("second arg must be public key");const He=_normFnElement(c,Ne);return n.fromHex(qe).multiply(He).toBytes(ze)}return Object.freeze({getPublicKey:ve,getSharedSecret:Te,keygen:ge,Point:n,utils:{isValidSecretKey:ae,isValidPublicKey:ue,randomSecretKey:de,isValidPrivateKey:ae,randomPrivateKey:de,normPrivateKeyToScalar:Ne=>_normFnElement(c,Ne),precompute(Ne=8,qe=n.BASE){return qe.precompute(Ne,!1)}},lengths:se})}function ecdsa(n,t,c={}){ahash(t),_validateObject(c,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const ie=c.randomBytes||randomBytes,se=c.hmac||((xe,..._e)=>hmac(t,xe,concatBytes(..._e))),{Fp:ae,Fn:ue}=n,{ORDER:de,BITS:ve}=ue,{keygen:ge,getPublicKey:we,getSharedSecret:Te,utils:Ne,lengths:qe}=ecdh(n,c),ze={prehash:!1,lowS:typeof c.lowS=="boolean"?c.lowS:!1,format:void 0,extraEntropy:!1},He="compact";function Ge(xe){const _e=de>>_1n;return xe>_e}function Ze(xe,_e){if(!ue.isValidNot0(_e))throw new Error(`invalid signature ${xe}: out of range 1..Point.Fn.ORDER`);return _e}function Ye(xe,_e){validateSigFormat(_e);const De=qe.signature,Fe=_e==="compact"?De:_e==="recovered"?De+1:void 0;return _abytes2(xe,Fe,`${_e} signature`)}class Ft{constructor(_e,De,Fe){this.r=Ze("r",_e),this.s=Ze("s",De),Fe!=null&&(this.recovery=Fe),Object.freeze(this)}static fromBytes(_e,De=He){Ye(_e,De);let Fe;if(De==="der"){const{r:We,s:$t}=DER.toSig(_abytes2(_e));return new Ft(We,$t)}De==="recovered"&&(Fe=_e[0],De="compact",_e=_e.subarray(1));const $e=ue.BYTES,ce=_e.subarray(0,$e),Me=_e.subarray($e,$e*2);return new Ft(ue.fromBytes(ce),ue.fromBytes(Me),Fe)}static fromHex(_e,De){return this.fromBytes(hexToBytes(_e),De)}addRecoveryBit(_e){return new Ft(this.r,this.s,_e)}recoverPublicKey(_e){const De=ae.ORDER,{r:Fe,s:$e,recovery:ce}=this;if(ce==null||![0,1,2,3].includes(ce))throw new Error("recovery id invalid");if(de*_2n$1<De&&ce>1)throw new Error("recovery id is ambiguous for h>1 curve");const Me=ce===2||ce===3?Fe+de:Fe;if(!ae.isValid(Me))throw new Error("recovery id 2 or 3 invalid");const We=ae.toBytes(Me),$t=n.fromBytes(concatBytes(pprefix((ce&1)===0),We)),dn=ue.inv(Me),gn=Zt(ensureBytes("msgHash",_e)),Vt=ue.create(-gn*dn),Cn=ue.create($e*dn),un=n.BASE.multiplyUnsafe(Vt).add($t.multiplyUnsafe(Cn));if(un.is0())throw new Error("point at infinify");return un.assertValidity(),un}hasHighS(){return Ge(this.s)}toBytes(_e=He){if(validateSigFormat(_e),_e==="der")return hexToBytes(DER.hexFromSig(this));const De=ue.toBytes(this.r),Fe=ue.toBytes(this.s);if(_e==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return concatBytes(Uint8Array.of(this.recovery),De,Fe)}return concatBytes(De,Fe)}toHex(_e){return bytesToHex(this.toBytes(_e))}assertValidity(){}static fromCompact(_e){return Ft.fromBytes(ensureBytes("sig",_e),"compact")}static fromDER(_e){return Ft.fromBytes(ensureBytes("sig",_e),"der")}normalizeS(){return this.hasHighS()?new Ft(this.r,ue.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return bytesToHex(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return bytesToHex(this.toBytes("compact"))}}const Mt=c.bits2int||function(xe){if(xe.length>8192)throw new Error("input is too large");const _e=bytesToNumberBE(xe),De=xe.length*8-ve;return De>0?_e>>BigInt(De):_e},Zt=c.bits2int_modN||function(xe){return ue.create(Mt(xe))},cn=bitMask(ve);function hn(xe){return aInRange("num < 2^"+ve,xe,_0n,cn),ue.toBytes(xe)}function yn(xe,_e){return _abytes2(xe,void 0,"message"),_e?_abytes2(t(xe),void 0,"prehashed message"):xe}function Ht(xe,_e,De){if(["recovered","canonical"].some(Cn=>Cn in De))throw new Error("sign() legacy options not supported");const{lowS:Fe,prehash:$e,extraEntropy:ce}=validateSigOpts(De,ze);xe=yn(xe,$e);const Me=Zt(xe),We=_normFnElement(ue,_e),$t=[hn(We),hn(Me)];if(ce!=null&&ce!==!1){const Cn=ce===!0?ie(qe.secretKey):ce;$t.push(ensureBytes("extraEntropy",Cn))}const dn=concatBytes(...$t),gn=Me;function Vt(Cn){const un=Mt(Cn);if(!ue.isValidNot0(un))return;const Pt=ue.inv(un),mn=n.BASE.multiply(un).toAffine(),Pn=ue.create(mn.x);if(Pn===_0n)return;const wn=ue.create(Pt*ue.create(gn+Pn*We));if(wn===_0n)return;let jt=(mn.x===Pn?0:2)|Number(mn.y&_1n),$n=wn;return Fe&&Ge(wn)&&($n=ue.neg(wn),jt^=1),new Ft(Pn,$n,jt)}return{seed:dn,k2sig:Vt}}function Sn(xe,_e,De={}){xe=ensureBytes("message",xe);const{seed:Fe,k2sig:$e}=Ht(xe,_e,De);return createHmacDrbg(t.outputLen,ue.BYTES,se)(Fe,$e)}function le(xe){let _e;const De=typeof xe=="string"||isBytes(xe),Fe=!De&&xe!==null&&typeof xe=="object"&&typeof xe.r=="bigint"&&typeof xe.s=="bigint";if(!De&&!Fe)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(Fe)_e=new Ft(xe.r,xe.s);else if(De){try{_e=Ft.fromBytes(ensureBytes("sig",xe),"der")}catch($e){if(!($e instanceof DER.Err))throw $e}if(!_e)try{_e=Ft.fromBytes(ensureBytes("sig",xe),"compact")}catch{return!1}}return _e||!1}function pe(xe,_e,De,Fe={}){const{lowS:$e,prehash:ce,format:Me}=validateSigOpts(Fe,ze);if(De=ensureBytes("publicKey",De),_e=yn(ensureBytes("message",_e),ce),"strict"in Fe)throw new Error("options.strict was renamed to lowS");const We=Me===void 0?le(xe):Ft.fromBytes(ensureBytes("sig",xe),Me);if(We===!1)return!1;try{const $t=n.fromBytes(De);if($e&&We.hasHighS())return!1;const{r:dn,s:gn}=We,Vt=Zt(_e),Cn=ue.inv(gn),un=ue.create(Vt*Cn),Pt=ue.create(dn*Cn),mn=n.BASE.multiplyUnsafe(un).add($t.multiplyUnsafe(Pt));return mn.is0()?!1:ue.create(mn.x)===dn}catch{return!1}}function be(xe,_e,De={}){const{prehash:Fe}=validateSigOpts(De,ze);return _e=yn(_e,Fe),Ft.fromBytes(xe,"recovered").recoverPublicKey(_e).toBytes()}return Object.freeze({keygen:ge,getPublicKey:we,getSharedSecret:Te,utils:Ne,lengths:qe,Point:n,sign:Sn,verify:pe,recoverPublicKey:be,Signature:Ft,hash:t})}function _weierstrass_legacy_opts_to_new(n){const t={a:n.a,b:n.b,p:n.Fp.ORDER,n:n.n,h:n.h,Gx:n.Gx,Gy:n.Gy},c=n.Fp;let ie=n.allowedPrivateKeyLengths?Array.from(new Set(n.allowedPrivateKeyLengths.map(ue=>Math.ceil(ue/2)))):void 0;const se=Field(t.n,{BITS:n.nBitLength,allowedLengths:ie,modFromBytes:n.wrapPrivateKey}),ae={Fp:c,Fn:se,allowInfinityPoint:n.allowInfinityPoint,endo:n.endo,isTorsionFree:n.isTorsionFree,clearCofactor:n.clearCofactor,fromBytes:n.fromBytes,toBytes:n.toBytes};return{CURVE:t,curveOpts:ae}}function _ecdsa_legacy_opts_to_new(n){const{CURVE:t,curveOpts:c}=_weierstrass_legacy_opts_to_new(n),ie={hmac:n.hmac,randomBytes:n.randomBytes,lowS:n.lowS,bits2int:n.bits2int,bits2int_modN:n.bits2int_modN};return{CURVE:t,curveOpts:c,hash:n.hash,ecdsaOpts:ie}}function _ecdsa_new_output_to_legacy(n,t){const c=t.Point;return Object.assign({},t,{ProjectivePoint:c,CURVE:Object.assign({},n,nLength(c.Fn.ORDER,c.Fn.BITS))})}function weierstrass(n){const{CURVE:t,curveOpts:c,hash:ie,ecdsaOpts:se}=_ecdsa_legacy_opts_to_new(n),ae=weierstrassN(t,c),ue=ecdsa(ae,ie,se);return _ecdsa_new_output_to_legacy(n,ue)}function createCurve(n,t){const c=ie=>weierstrass({...n,hash:ie});return{...c(t),create:c}}const secp256k1_CURVE={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},secp256k1_ENDO={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},_2n=BigInt(2);function sqrtMod(n){const t=secp256k1_CURVE.p,c=BigInt(3),ie=BigInt(6),se=BigInt(11),ae=BigInt(22),ue=BigInt(23),de=BigInt(44),ve=BigInt(88),ge=n*n*n%t,we=ge*ge*n%t,Te=pow2(we,c,t)*we%t,Ne=pow2(Te,c,t)*we%t,qe=pow2(Ne,_2n,t)*ge%t,ze=pow2(qe,se,t)*qe%t,He=pow2(ze,ae,t)*ze%t,Ge=pow2(He,de,t)*He%t,Ze=pow2(Ge,ve,t)*Ge%t,Ye=pow2(Ze,de,t)*He%t,Ft=pow2(Ye,c,t)*we%t,Mt=pow2(Ft,ue,t)*ze%t,Zt=pow2(Mt,ie,t)*ge%t,cn=pow2(Zt,_2n,t);if(!Fpk1.eql(Fpk1.sqr(cn),n))throw new Error("Cannot find square root");return cn}const Fpk1=Field(secp256k1_CURVE.p,{sqrt:sqrtMod}),secp256k1$1=createCurve({...secp256k1_CURVE,Fp:Fpk1,lowS:!0,endo:secp256k1_ENDO},sha256$5);ed25519.utils.randomPrivateKey;ed25519.getPublicKey;function isOnCurve(n){try{return ed25519.ExtendedPoint.fromHex(n),!0}catch{return!1}}const sign$2=(n,t)=>ed25519.sign(n,t.slice(0,32)),verify$1=ed25519.verify,toBuffer$1=n=>Buffer$1$1.isBuffer(n)?n:n instanceof Uint8Array?Buffer$1$1.from(n.buffer,n.byteOffset,n.byteLength):Buffer$1$1.from(n);class Struct{constructor(t){Object.assign(this,t)}encode(){return Buffer$1$1.from(serialize_1(SOLANA_SCHEMA,this))}static decode(t){return deserialize_1(SOLANA_SCHEMA,this,t)}static decodeUnchecked(t){return deserializeUnchecked_1(SOLANA_SCHEMA,this,t)}}const SOLANA_SCHEMA=new Map;var _PublicKey;const MAX_SEED_LENGTH=32,PUBLIC_KEY_LENGTH=32;function isPublicKeyData(n){return n._bn!==void 0}let uniquePublicKeyCounter=1;class PublicKey extends Struct{constructor(t){if(super({}),this._bn=void 0,isPublicKeyData(t))this._bn=t._bn;else{if(typeof t=="string"){const c=o$1.decode(t);if(c.length!=PUBLIC_KEY_LENGTH)throw new Error("Invalid public key input");this._bn=new BN$8(c)}else this._bn=new BN$8(t);if(this._bn.byteLength()>PUBLIC_KEY_LENGTH)throw new Error("Invalid public key input")}}static unique(){const t=new PublicKey(uniquePublicKeyCounter);return uniquePublicKeyCounter+=1,new PublicKey(t.toBuffer())}equals(t){return this._bn.eq(t._bn)}toBase58(){return o$1.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const t=this.toBuffer();return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}toBuffer(){const t=this._bn.toArrayLike(Buffer$1$1);if(t.length===PUBLIC_KEY_LENGTH)return t;const c=Buffer$1$1.alloc(32);return t.copy(c,32-t.length),c}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(t,c,ie){const se=Buffer$1$1.concat([t.toBuffer(),Buffer$1$1.from(c),ie.toBuffer()]),ae=sha256$4(se);return new PublicKey(ae)}static createProgramAddressSync(t,c){let ie=Buffer$1$1.alloc(0);t.forEach(function(ae){if(ae.length>MAX_SEED_LENGTH)throw new TypeError("Max seed length exceeded");ie=Buffer$1$1.concat([ie,toBuffer$1(ae)])}),ie=Buffer$1$1.concat([ie,c.toBuffer(),Buffer$1$1.from("ProgramDerivedAddress")]);const se=sha256$4(ie);if(isOnCurve(se))throw new Error("Invalid seeds, address must fall off the curve");return new PublicKey(se)}static async createProgramAddress(t,c){return this.createProgramAddressSync(t,c)}static findProgramAddressSync(t,c){let ie=255,se;for(;ie!=0;){try{const ae=t.concat(Buffer$1$1.from([ie]));se=this.createProgramAddressSync(ae,c)}catch(ae){if(ae instanceof TypeError)throw ae;ie--;continue}return[se,ie]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(t,c){return this.findProgramAddressSync(t,c)}static isOnCurve(t){const c=new PublicKey(t);return isOnCurve(c.toBytes())}}_PublicKey=PublicKey;PublicKey.default=new _PublicKey("11111111111111111111111111111111");SOLANA_SCHEMA.set(PublicKey,{kind:"struct",fields:[["_bn","u256"]]});new PublicKey("BPFLoader1111111111111111111111111111111111");const PACKET_DATA_SIZE=1232,VERSION_PREFIX_MASK=127,SIGNATURE_LENGTH_IN_BYTES=64;class TransactionExpiredBlockheightExceededError extends Error{constructor(t){super(`Signature ${t} has expired: block height exceeded.`),this.signature=void 0,this.signature=t}}Object.defineProperty(TransactionExpiredBlockheightExceededError.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class TransactionExpiredTimeoutError extends Error{constructor(t,c){super(`Transaction was not confirmed in ${c.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${t} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=t}}Object.defineProperty(TransactionExpiredTimeoutError.prototype,"name",{value:"TransactionExpiredTimeoutError"});class TransactionExpiredNonceInvalidError extends Error{constructor(t){super(`Signature ${t} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=t}}Object.defineProperty(TransactionExpiredNonceInvalidError.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class MessageAccountKeys{constructor(t,c){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=t,this.accountKeysFromLookups=c}keySegments(){const t=[this.staticAccountKeys];return this.accountKeysFromLookups&&(t.push(this.accountKeysFromLookups.writable),t.push(this.accountKeysFromLookups.readonly)),t}get(t){for(const c of this.keySegments()){if(t<c.length)return c[t];t-=c.length}}get length(){return this.keySegments().flat().length}compileInstructions(t){if(this.length>256)throw new Error("Account index overflow encountered during compilation");const c=new Map;this.keySegments().flat().forEach((se,ae)=>{c.set(se.toBase58(),ae)});const ie=se=>{const ae=c.get(se.toBase58());if(ae===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return ae};return t.map(se=>({programIdIndex:ie(se.programId),accountKeyIndexes:se.keys.map(ae=>ie(ae.pubkey)),data:se.data}))}}const publicKey$1=(n="publicKey")=>blob(32,n),signature$2=(n="signature")=>blob(64,n),rustString=(n="string")=>{const t=struct([u32("length"),u32("lengthPadding"),blob(offset$2(u32(),-8),"chars")],n),c=t.decode.bind(t),ie=t.encode.bind(t),se=t;return se.decode=(ae,ue)=>c(ae,ue).chars.toString(),se.encode=(ae,ue,de)=>{const ve={chars:Buffer$1$1.from(ae,"utf8")};return ie(ve,ue,de)},se.alloc=ae=>u32().span+u32().span+Buffer$1$1.from(ae,"utf8").length,se},authorized=(n="authorized")=>struct([publicKey$1("staker"),publicKey$1("withdrawer")],n),lockup=(n="lockup")=>struct([ns64("unixTimestamp"),ns64("epoch"),publicKey$1("custodian")],n),voteInit=(n="voteInit")=>struct([publicKey$1("nodePubkey"),publicKey$1("authorizedVoter"),publicKey$1("authorizedWithdrawer"),u8("commission")],n),voteAuthorizeWithSeedArgs=(n="voteAuthorizeWithSeedArgs")=>struct([u32("voteAuthorizationType"),publicKey$1("currentAuthorityDerivedKeyOwnerPubkey"),rustString("currentAuthorityDerivedKeySeed"),publicKey$1("newAuthorized")],n);function getAlloc(n,t){const c=se=>{if(se.span>=0)return se.span;if(typeof se.alloc=="function")return se.alloc(t[se.property]);if("count"in se&&"elementLayout"in se){const ae=t[se.property];if(Array.isArray(ae))return ae.length*c(se.elementLayout)}else if("fields"in se)return getAlloc({layout:se},t[se.property]);return 0};let ie=0;return n.layout.fields.forEach(se=>{ie+=c(se)}),ie}function decodeLength(n){let t=0,c=0;for(;;){let ie=n.shift();if(t|=(ie&127)<<c*7,c+=1,!(ie&128))break}return t}function encodeLength(n,t){let c=t;for(;;){let ie=c&127;if(c>>=7,c==0){n.push(ie);break}else ie|=128,n.push(ie)}}function assert$9(n,t){if(!n)throw new Error(t||"Assertion failed")}class CompiledKeys{constructor(t,c){this.payer=void 0,this.keyMetaMap=void 0,this.payer=t,this.keyMetaMap=c}static compile(t,c){const ie=new Map,se=ue=>{const de=ue.toBase58();let ve=ie.get(de);return ve===void 0&&(ve={isSigner:!1,isWritable:!1,isInvoked:!1},ie.set(de,ve)),ve},ae=se(c);ae.isSigner=!0,ae.isWritable=!0;for(const ue of t){se(ue.programId).isInvoked=!0;for(const de of ue.keys){const ve=se(de.pubkey);ve.isSigner||(ve.isSigner=de.isSigner),ve.isWritable||(ve.isWritable=de.isWritable)}}return new CompiledKeys(c,ie)}getMessageComponents(){const t=[...this.keyMetaMap.entries()];assert$9(t.length<=256,"Max static account keys length exceeded");const c=t.filter(([,ve])=>ve.isSigner&&ve.isWritable),ie=t.filter(([,ve])=>ve.isSigner&&!ve.isWritable),se=t.filter(([,ve])=>!ve.isSigner&&ve.isWritable),ae=t.filter(([,ve])=>!ve.isSigner&&!ve.isWritable),ue={numRequiredSignatures:c.length+ie.length,numReadonlySignedAccounts:ie.length,numReadonlyUnsignedAccounts:ae.length};{assert$9(c.length>0,"Expected at least one writable signer key");const[ve]=c[0];assert$9(ve===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const de=[...c.map(([ve])=>new PublicKey(ve)),...ie.map(([ve])=>new PublicKey(ve)),...se.map(([ve])=>new PublicKey(ve)),...ae.map(([ve])=>new PublicKey(ve))];return[ue,de]}extractTableLookup(t){const[c,ie]=this.drainKeysFoundInLookupTable(t.state.addresses,ue=>!ue.isSigner&&!ue.isInvoked&&ue.isWritable),[se,ae]=this.drainKeysFoundInLookupTable(t.state.addresses,ue=>!ue.isSigner&&!ue.isInvoked&&!ue.isWritable);if(!(c.length===0&&se.length===0))return[{accountKey:t.key,writableIndexes:c,readonlyIndexes:se},{writable:ie,readonly:ae}]}drainKeysFoundInLookupTable(t,c){const ie=new Array,se=new Array;for(const[ae,ue]of this.keyMetaMap.entries())if(c(ue)){const de=new PublicKey(ae),ve=t.findIndex(ge=>ge.equals(de));ve>=0&&(assert$9(ve<256,"Max lookup table index exceeded"),ie.push(ve),se.push(de),this.keyMetaMap.delete(ae))}return[ie,se]}}const END_OF_BUFFER_ERROR_MESSAGE="Reached end of buffer unexpectedly";function guardedShift(n){if(n.length===0)throw new Error(END_OF_BUFFER_ERROR_MESSAGE);return n.shift()}function guardedSplice(n,...t){const[c]=t;if(t.length===2?c+(t[1]??0)>n.length:c>=n.length)throw new Error(END_OF_BUFFER_ERROR_MESSAGE);return n.splice(...t)}class Message{constructor(t){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=t.header,this.accountKeys=t.accountKeys.map(c=>new PublicKey(c)),this.recentBlockhash=t.recentBlockhash,this.instructions=t.instructions,this.instructions.forEach(c=>this.indexToProgramIds.set(c.programIdIndex,this.accountKeys[c.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:o$1.decode(t.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new MessageAccountKeys(this.staticAccountKeys)}static compile(t){const c=CompiledKeys.compile(t.instructions,t.payerKey),[ie,se]=c.getMessageComponents(),ae=new MessageAccountKeys(se).compileInstructions(t.instructions).map(ue=>({programIdIndex:ue.programIdIndex,accounts:ue.accountKeyIndexes,data:o$1.encode(ue.data)}));return new Message({header:ie,accountKeys:se,recentBlockhash:t.recentBlockhash,instructions:ae})}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const c=this.header.numRequiredSignatures;if(t>=this.header.numRequiredSignatures){const ie=t-c,se=this.accountKeys.length-c-this.header.numReadonlyUnsignedAccounts;return ie<se}else{const ie=c-this.header.numReadonlySignedAccounts;return t<ie}}isProgramId(t){return this.indexToProgramIds.has(t)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((t,c)=>!this.isProgramId(c))}serialize(){const t=this.accountKeys.length;let c=[];encodeLength(c,t);const ie=this.instructions.map(Te=>{const{accounts:Ne,programIdIndex:qe}=Te,ze=Array.from(o$1.decode(Te.data));let He=[];encodeLength(He,Ne.length);let Ge=[];return encodeLength(Ge,ze.length),{programIdIndex:qe,keyIndicesCount:Buffer$1$1.from(He),keyIndices:Ne,dataLength:Buffer$1$1.from(Ge),data:ze}});let se=[];encodeLength(se,ie.length);let ae=Buffer$1$1.alloc(PACKET_DATA_SIZE);Buffer$1$1.from(se).copy(ae);let ue=se.length;ie.forEach(Te=>{const Ne=struct([u8("programIdIndex"),blob(Te.keyIndicesCount.length,"keyIndicesCount"),seq(u8("keyIndex"),Te.keyIndices.length,"keyIndices"),blob(Te.dataLength.length,"dataLength"),seq(u8("userdatum"),Te.data.length,"data")]).encode(Te,ae,ue);ue+=Ne}),ae=ae.slice(0,ue);const de=struct([blob(1,"numRequiredSignatures"),blob(1,"numReadonlySignedAccounts"),blob(1,"numReadonlyUnsignedAccounts"),blob(c.length,"keyCount"),seq(publicKey$1("key"),t,"keys"),publicKey$1("recentBlockhash")]),ve={numRequiredSignatures:Buffer$1$1.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:Buffer$1$1.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:Buffer$1$1.from([this.header.numReadonlyUnsignedAccounts]),keyCount:Buffer$1$1.from(c),keys:this.accountKeys.map(Te=>toBuffer$1(Te.toBytes())),recentBlockhash:o$1.decode(this.recentBlockhash)};let ge=Buffer$1$1.alloc(2048);const we=de.encode(ve,ge);return ae.copy(ge,we),ge.slice(0,we+ae.length)}static from(t){let c=[...t];const ie=guardedShift(c);if(ie!==(ie&VERSION_PREFIX_MASK))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const se=guardedShift(c),ae=guardedShift(c),ue=decodeLength(c);let de=[];for(let Ne=0;Ne<ue;Ne++){const qe=guardedSplice(c,0,PUBLIC_KEY_LENGTH);de.push(new PublicKey(Buffer$1$1.from(qe)))}const ve=guardedSplice(c,0,PUBLIC_KEY_LENGTH),ge=decodeLength(c);let we=[];for(let Ne=0;Ne<ge;Ne++){const qe=guardedShift(c),ze=decodeLength(c),He=guardedSplice(c,0,ze),Ge=decodeLength(c),Ze=guardedSplice(c,0,Ge),Ye=o$1.encode(Buffer$1$1.from(Ze));we.push({programIdIndex:qe,accounts:He,data:Ye})}const Te={header:{numRequiredSignatures:ie,numReadonlySignedAccounts:se,numReadonlyUnsignedAccounts:ae},recentBlockhash:o$1.encode(Buffer$1$1.from(ve)),accountKeys:de,instructions:we};return new Message(Te)}}class MessageV0{constructor(t){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=t.header,this.staticAccountKeys=t.staticAccountKeys,this.recentBlockhash=t.recentBlockhash,this.compiledInstructions=t.compiledInstructions,this.addressTableLookups=t.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let t=0;for(const c of this.addressTableLookups)t+=c.readonlyIndexes.length+c.writableIndexes.length;return t}getAccountKeys(t){let c;if(t&&"accountKeysFromLookups"in t&&t.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=t.accountKeysFromLookups.writable.length+t.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");c=t.accountKeysFromLookups}else if(t&&"addressLookupTableAccounts"in t&&t.addressLookupTableAccounts)c=this.resolveAddressTableLookups(t.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new MessageAccountKeys(this.staticAccountKeys,c)}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const c=this.header.numRequiredSignatures,ie=this.staticAccountKeys.length;if(t>=ie){const se=t-ie,ae=this.addressTableLookups.reduce((ue,de)=>ue+de.writableIndexes.length,0);return se<ae}else if(t>=this.header.numRequiredSignatures){const se=t-c,ae=ie-c-this.header.numReadonlyUnsignedAccounts;return se<ae}else{const se=c-this.header.numReadonlySignedAccounts;return t<se}}resolveAddressTableLookups(t){const c={writable:[],readonly:[]};for(const ie of this.addressTableLookups){const se=t.find(ae=>ae.key.equals(ie.accountKey));if(!se)throw new Error(`Failed to find address lookup table account for table key ${ie.accountKey.toBase58()}`);for(const ae of ie.writableIndexes)if(ae<se.state.addresses.length)c.writable.push(se.state.addresses[ae]);else throw new Error(`Failed to find address for index ${ae} in address lookup table ${ie.accountKey.toBase58()}`);for(const ae of ie.readonlyIndexes)if(ae<se.state.addresses.length)c.readonly.push(se.state.addresses[ae]);else throw new Error(`Failed to find address for index ${ae} in address lookup table ${ie.accountKey.toBase58()}`)}return c}static compile(t){const c=CompiledKeys.compile(t.instructions,t.payerKey),ie=new Array,se={writable:new Array,readonly:new Array},ae=t.addressLookupTableAccounts||[];for(const ge of ae){const we=c.extractTableLookup(ge);if(we!==void 0){const[Te,{writable:Ne,readonly:qe}]=we;ie.push(Te),se.writable.push(...Ne),se.readonly.push(...qe)}}const[ue,de]=c.getMessageComponents(),ve=new MessageAccountKeys(de,se).compileInstructions(t.instructions);return new MessageV0({header:ue,staticAccountKeys:de,recentBlockhash:t.recentBlockhash,compiledInstructions:ve,addressTableLookups:ie})}serialize(){const t=Array();encodeLength(t,this.staticAccountKeys.length);const c=this.serializeInstructions(),ie=Array();encodeLength(ie,this.compiledInstructions.length);const se=this.serializeAddressTableLookups(),ae=Array();encodeLength(ae,this.addressTableLookups.length);const ue=struct([u8("prefix"),struct([u8("numRequiredSignatures"),u8("numReadonlySignedAccounts"),u8("numReadonlyUnsignedAccounts")],"header"),blob(t.length,"staticAccountKeysLength"),seq(publicKey$1(),this.staticAccountKeys.length,"staticAccountKeys"),publicKey$1("recentBlockhash"),blob(ie.length,"instructionsLength"),blob(c.length,"serializedInstructions"),blob(ae.length,"addressTableLookupsLength"),blob(se.length,"serializedAddressTableLookups")]),de=new Uint8Array(PACKET_DATA_SIZE),ve=ue.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(t),staticAccountKeys:this.staticAccountKeys.map(ge=>ge.toBytes()),recentBlockhash:o$1.decode(this.recentBlockhash),instructionsLength:new Uint8Array(ie),serializedInstructions:c,addressTableLookupsLength:new Uint8Array(ae),serializedAddressTableLookups:se},de);return de.slice(0,ve)}serializeInstructions(){let t=0;const c=new Uint8Array(PACKET_DATA_SIZE);for(const ie of this.compiledInstructions){const se=Array();encodeLength(se,ie.accountKeyIndexes.length);const ae=Array();encodeLength(ae,ie.data.length);const ue=struct([u8("programIdIndex"),blob(se.length,"encodedAccountKeyIndexesLength"),seq(u8(),ie.accountKeyIndexes.length,"accountKeyIndexes"),blob(ae.length,"encodedDataLength"),blob(ie.data.length,"data")]);t+=ue.encode({programIdIndex:ie.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(se),accountKeyIndexes:ie.accountKeyIndexes,encodedDataLength:new Uint8Array(ae),data:ie.data},c,t)}return c.slice(0,t)}serializeAddressTableLookups(){let t=0;const c=new Uint8Array(PACKET_DATA_SIZE);for(const ie of this.addressTableLookups){const se=Array();encodeLength(se,ie.writableIndexes.length);const ae=Array();encodeLength(ae,ie.readonlyIndexes.length);const ue=struct([publicKey$1("accountKey"),blob(se.length,"encodedWritableIndexesLength"),seq(u8(),ie.writableIndexes.length,"writableIndexes"),blob(ae.length,"encodedReadonlyIndexesLength"),seq(u8(),ie.readonlyIndexes.length,"readonlyIndexes")]);t+=ue.encode({accountKey:ie.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(se),writableIndexes:ie.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(ae),readonlyIndexes:ie.readonlyIndexes},c,t)}return c.slice(0,t)}static deserialize(t){let c=[...t];const ie=guardedShift(c),se=ie&VERSION_PREFIX_MASK;assert$9(ie!==se,"Expected versioned message but received legacy message");const ae=se;assert$9(ae===0,`Expected versioned message with version 0 but found version ${ae}`);const ue={numRequiredSignatures:guardedShift(c),numReadonlySignedAccounts:guardedShift(c),numReadonlyUnsignedAccounts:guardedShift(c)},de=[],ve=decodeLength(c);for(let ze=0;ze<ve;ze++)de.push(new PublicKey(guardedSplice(c,0,PUBLIC_KEY_LENGTH)));const ge=o$1.encode(guardedSplice(c,0,PUBLIC_KEY_LENGTH)),we=decodeLength(c),Te=[];for(let ze=0;ze<we;ze++){const He=guardedShift(c),Ge=decodeLength(c),Ze=guardedSplice(c,0,Ge),Ye=decodeLength(c),Ft=new Uint8Array(guardedSplice(c,0,Ye));Te.push({programIdIndex:He,accountKeyIndexes:Ze,data:Ft})}const Ne=decodeLength(c),qe=[];for(let ze=0;ze<Ne;ze++){const He=new PublicKey(guardedSplice(c,0,PUBLIC_KEY_LENGTH)),Ge=decodeLength(c),Ze=guardedSplice(c,0,Ge),Ye=decodeLength(c),Ft=guardedSplice(c,0,Ye);qe.push({accountKey:He,writableIndexes:Ze,readonlyIndexes:Ft})}return new MessageV0({header:ue,staticAccountKeys:de,recentBlockhash:ge,compiledInstructions:Te,addressTableLookups:qe})}}const VersionedMessage={deserializeMessageVersion(n){const t=n[0],c=t&VERSION_PREFIX_MASK;return c===t?"legacy":c},deserialize:n=>{const t=VersionedMessage.deserializeMessageVersion(n);if(t==="legacy")return Message.from(n);if(t===0)return MessageV0.deserialize(n);throw new Error(`Transaction message version ${t} deserialization is not supported`)}};let TransactionStatus=(function(n){return n[n.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",n[n.PROCESSED=1]="PROCESSED",n[n.TIMED_OUT=2]="TIMED_OUT",n[n.NONCE_INVALID=3]="NONCE_INVALID",n})({});const DEFAULT_SIGNATURE=Buffer$1$1.alloc(SIGNATURE_LENGTH_IN_BYTES).fill(0);class TransactionInstruction{constructor(t){this.keys=void 0,this.programId=void 0,this.data=Buffer$1$1.alloc(0),this.programId=t.programId,this.keys=t.keys,t.data&&(this.data=t.data)}toJSON(){return{keys:this.keys.map(({pubkey:t,isSigner:c,isWritable:ie})=>({pubkey:t.toJSON(),isSigner:c,isWritable:ie})),programId:this.programId.toJSON(),data:[...this.data]}}}class Transaction{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(t){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,!!t)if(t.feePayer&&(this.feePayer=t.feePayer),t.signatures&&(this.signatures=t.signatures),Object.prototype.hasOwnProperty.call(t,"nonceInfo")){const{minContextSlot:c,nonceInfo:ie}=t;this.minNonceContextSlot=c,this.nonceInfo=ie}else if(Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")){const{blockhash:c,lastValidBlockHeight:ie}=t;this.recentBlockhash=c,this.lastValidBlockHeight=ie}else{const{recentBlockhash:c,nonceInfo:ie}=t;ie&&(this.nonceInfo=ie),this.recentBlockhash=c}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(t=>t.toJSON()),signers:this.signatures.map(({publicKey:t})=>t.toJSON())}}add(...t){if(t.length===0)throw new Error("No instructions");return t.forEach(c=>{"instructions"in c?this.instructions=this.instructions.concat(c.instructions):"data"in c&&"programId"in c&&"keys"in c?this.instructions.push(c):this.instructions.push(new TransactionInstruction(c))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let t,c;if(this.nonceInfo?(t=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?c=[this.nonceInfo.nonceInstruction,...this.instructions]:c=this.instructions):(t=this.recentBlockhash,c=this.instructions),!t)throw new Error("Transaction recentBlockhash required");c.length<1&&console.warn("No instructions provided");let ie;if(this.feePayer)ie=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)ie=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let He=0;He<c.length;He++)if(c[He].programId===void 0)throw new Error(`Transaction instruction index ${He} has undefined program id`);const se=[],ae=[];c.forEach(He=>{He.keys.forEach(Ze=>{ae.push({...Ze})});const Ge=He.programId.toString();se.includes(Ge)||se.push(Ge)}),se.forEach(He=>{ae.push({pubkey:new PublicKey(He),isSigner:!1,isWritable:!1})});const ue=[];ae.forEach(He=>{const Ge=He.pubkey.toString(),Ze=ue.findIndex(Ye=>Ye.pubkey.toString()===Ge);Ze>-1?(ue[Ze].isWritable=ue[Ze].isWritable||He.isWritable,ue[Ze].isSigner=ue[Ze].isSigner||He.isSigner):ue.push(He)}),ue.sort(function(He,Ge){if(He.isSigner!==Ge.isSigner)return He.isSigner?-1:1;if(He.isWritable!==Ge.isWritable)return He.isWritable?-1:1;const Ze={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return He.pubkey.toBase58().localeCompare(Ge.pubkey.toBase58(),"en",Ze)});const de=ue.findIndex(He=>He.pubkey.equals(ie));if(de>-1){const[He]=ue.splice(de,1);He.isSigner=!0,He.isWritable=!0,ue.unshift(He)}else ue.unshift({pubkey:ie,isSigner:!0,isWritable:!0});for(const He of this.signatures){const Ge=ue.findIndex(Ze=>Ze.pubkey.equals(He.publicKey));if(Ge>-1)ue[Ge].isSigner||(ue[Ge].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."));else throw new Error(`unknown signer: ${He.publicKey.toString()}`)}let ve=0,ge=0,we=0;const Te=[],Ne=[];ue.forEach(({pubkey:He,isSigner:Ge,isWritable:Ze})=>{Ge?(Te.push(He.toString()),ve+=1,Ze||(ge+=1)):(Ne.push(He.toString()),Ze||(we+=1))});const qe=Te.concat(Ne),ze=c.map(He=>{const{data:Ge,programId:Ze}=He;return{programIdIndex:qe.indexOf(Ze.toString()),accounts:He.keys.map(Ye=>qe.indexOf(Ye.pubkey.toString())),data:o$1.encode(Ge)}});return ze.forEach(He=>{assert$9(He.programIdIndex>=0),He.accounts.forEach(Ge=>assert$9(Ge>=0))}),new Message({header:{numRequiredSignatures:ve,numReadonlySignedAccounts:ge,numReadonlyUnsignedAccounts:we},accountKeys:qe,recentBlockhash:t,instructions:ze})}_compile(){const t=this.compileMessage(),c=t.accountKeys.slice(0,t.header.numRequiredSignatures);return this.signatures.length===c.length&&this.signatures.every((ie,se)=>c[se].equals(ie.publicKey))||(this.signatures=c.map(ie=>({signature:null,publicKey:ie}))),t}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(t){return(await t.getFeeForMessage(this.compileMessage())).value}setSigners(...t){if(t.length===0)throw new Error("No signers");const c=new Set;this.signatures=t.filter(ie=>{const se=ie.toString();return c.has(se)?!1:(c.add(se),!0)}).map(ie=>({signature:null,publicKey:ie}))}sign(...t){if(t.length===0)throw new Error("No signers");const c=new Set,ie=[];for(const ae of t){const ue=ae.publicKey.toString();c.has(ue)||(c.add(ue),ie.push(ae))}this.signatures=ie.map(ae=>({signature:null,publicKey:ae.publicKey}));const se=this._compile();this._partialSign(se,...ie)}partialSign(...t){if(t.length===0)throw new Error("No signers");const c=new Set,ie=[];for(const ae of t){const ue=ae.publicKey.toString();c.has(ue)||(c.add(ue),ie.push(ae))}const se=this._compile();this._partialSign(se,...ie)}_partialSign(t,...c){const ie=t.serialize();c.forEach(se=>{const ae=sign$2(ie,se.secretKey);this._addSignature(se.publicKey,toBuffer$1(ae))})}addSignature(t,c){this._compile(),this._addSignature(t,c)}_addSignature(t,c){assert$9(c.length===64);const ie=this.signatures.findIndex(se=>t.equals(se.publicKey));if(ie<0)throw new Error(`unknown signer: ${t.toString()}`);this.signatures[ie].signature=Buffer$1$1.from(c)}verifySignatures(t=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),t)}_getMessageSignednessErrors(t,c){const ie={};for(const{signature:se,publicKey:ae}of this.signatures)se===null?c&&(ie.missing||(ie.missing=[])).push(ae):verify$1(se,t,ae.toBytes())||(ie.invalid||(ie.invalid=[])).push(ae);return ie.invalid||ie.missing?ie:void 0}serialize(t){const{requireAllSignatures:c,verifySignatures:ie}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},t),se=this.serializeMessage();if(ie){const ae=this._getMessageSignednessErrors(se,c);if(ae){let ue="Signature verification failed.";throw ae.invalid&&(ue+=`
24
24
  Invalid signature for public key${ae.invalid.length===1?"":"(s)"} [\`${ae.invalid.map(de=>de.toBase58()).join("`, `")}\`].`),ae.missing&&(ue+=`