@gardenfi/core 2.1.6 → 2.1.7

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.
@@ -33,11 +33,11 @@
33
33
  ${vp(p)}`),super(t.shortMessage,{cause:t,docsPath:n,metaMessages:[...t.metaMessages?[...t.metaMessages," "]:[],"Raw Call Arguments:",_].filter(Boolean),name:"CallExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=t}}class Ip extends L{constructor(t,{abi:r,args:n,contractAddress:i,docsPath:s,functionName:o,sender:a}){const c=Pn({abi:r,args:n,name:o}),f=c?Yf({abiItem:c,args:n,includeFunctionName:!1,includeName:!1}):void 0,l=c?Bt(c,{includeName:!0}):void 0,h=Ui({address:i&&Tp(i),function:l,args:f&&f!=="()"&&`${[...Array((o==null?void 0:o.length)??0).keys()].map(()=>" ").join("")}${f}`,sender:a});super(t.shortMessage||`An unknown error occurred while executing the contract function "${o}".`,{cause:t,docsPath:s,metaMessages:[...t.metaMessages?[...t.metaMessages," "]:[],h&&"Contract Call:",h].filter(Boolean),name:"ContractFunctionExecutionError"}),Object.defineProperty(this,"abi",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"args",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"contractAddress",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"formattedArgs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"functionName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sender",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abi=r,this.args=n,this.cause=t,this.contractAddress=i,this.functionName=o,this.sender=a}}class Bp extends L{constructor({abi:t,data:r,functionName:n,message:i}){let s,o,a,c;if(r&&r!=="0x")try{o=Kf({abi:t,data:r});const{abiItem:l,errorName:h,args:y}=o;if(h==="Error")c=y[0];else if(h==="Panic"){const[p]=y;c=np[p]}else{const p=l?Bt(l,{includeName:!0}):void 0,g=l&&y?Yf({abiItem:l,args:y,includeFunctionName:!1,includeName:!1}):void 0;a=[p?`Error: ${p}`:"",g&&g!=="()"?` ${[...Array((h==null?void 0:h.length)??0).keys()].map(()=>" ").join("")}${g}`:""]}}catch(l){s=l}else i&&(c=i);let f;s instanceof Sf&&(f=s.signature,a=[`Unable to decode signature "${f}" as it was not found on the provided ABI.`,"Make sure you are using the correct ABI and that the error exists on it.",`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${f}.`]),super(c&&c!=="execution reverted"||f?[`The contract function "${n}" reverted with the following ${f?"signature":"reason"}:`,c||f].join(`
34
34
  `):`The contract function "${n}" reverted.`,{cause:s,metaMessages:a,name:"ContractFunctionRevertedError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"raw",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reason",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=o,this.raw=r,this.reason=c,this.signature=f}}class Cp extends L{constructor({functionName:t}){super(`The contract function "${t}" returned no data ("0x").`,{metaMessages:["This could be due to any of the following:",` - The contract does not have the function "${t}",`," - The parameters passed to the contract function may be invalid, or"," - The address is not a contract."],name:"ContractFunctionZeroDataError"})}}class Op extends L{constructor({factory:t}){super(`Deployment for counterfactual contract call failed${t?` for factory "${t}".`:""}`,{metaMessages:["Please ensure:","- The `factory` is a valid contract deployment factory (ie. Create2 Factory, ERC-4337 Factory, etc).","- The `factoryData` is a valid encoded function call for contract deployment function on the factory."],name:"CounterfactualDeploymentFailedError"})}}class Jf extends L{constructor({data:t,message:r}){super(r||"",{name:"RawContractError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=t}}class on extends L{constructor({body:t,cause:r,details:n,headers:i,status:s,url:o}){super("HTTP request failed.",{cause:r,details:n,metaMessages:[s&&`Status: ${s}`,`URL: ${Ms(o)}`,t&&`Request body: ${rt(t)}`].filter(Boolean),name:"HttpRequestError"}),Object.defineProperty(this,"body",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"url",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.body=t,this.headers=i,this.status=s,this.url=o}}class Va extends L{constructor({body:t,error:r,url:n}){super("RPC Request failed.",{cause:r,details:r.message,metaMessages:[`URL: ${Ms(n)}`,`Request body: ${rt(t)}`],name:"RpcRequestError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=r.code,this.data=r.data}}class Wc extends L{constructor({body:t,url:r}){super("The request took too long to respond.",{details:"The request timed out.",metaMessages:[`URL: ${Ms(r)}`,`Request body: ${rt(t)}`],name:"TimeoutError"})}}const Rp=-1;class it extends L{constructor(t,{code:r,docsPath:n,metaMessages:i,name:s,shortMessage:o}){super(o,{cause:t,docsPath:n,metaMessages:i||(t==null?void 0:t.metaMessages),name:s||"RpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=s||t.name,this.code=t instanceof Va?t.code:r??Rp}}class ct extends it{constructor(t,r){super(t,r),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=r.data}}class ni extends it{constructor(t){super(t,{code:ni.code,name:"ParseRpcError",shortMessage:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."})}}Object.defineProperty(ni,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class ii extends it{constructor(t){super(t,{code:ii.code,name:"InvalidRequestRpcError",shortMessage:"JSON is not a valid request object."})}}Object.defineProperty(ii,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class si extends it{constructor(t,{method:r}={}){super(t,{code:si.code,name:"MethodNotFoundRpcError",shortMessage:`The method${r?` "${r}"`:""} does not exist / is not available.`})}}Object.defineProperty(si,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class oi extends it{constructor(t){super(t,{code:oi.code,name:"InvalidParamsRpcError",shortMessage:["Invalid parameters were provided to the RPC method.","Double check you have provided the correct parameters."].join(`
35
35
  `)})}}Object.defineProperty(oi,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class Nr extends it{constructor(t){super(t,{code:Nr.code,name:"InternalRpcError",shortMessage:"An internal error was received."})}}Object.defineProperty(Nr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class pn extends it{constructor(t){super(t,{code:pn.code,name:"InvalidInputRpcError",shortMessage:["Missing or invalid parameters.","Double check you have provided the correct parameters."].join(`
36
- `)})}}Object.defineProperty(pn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class ai extends it{constructor(t){super(t,{code:ai.code,name:"ResourceNotFoundRpcError",shortMessage:"Requested resource not found."}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ResourceNotFoundRpcError"})}}Object.defineProperty(ai,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class ci extends it{constructor(t){super(t,{code:ci.code,name:"ResourceUnavailableRpcError",shortMessage:"Requested resource not available."})}}Object.defineProperty(ci,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class ui extends it{constructor(t){super(t,{code:ui.code,name:"TransactionRejectedRpcError",shortMessage:"Transaction creation failed."})}}Object.defineProperty(ui,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class Ir extends it{constructor(t,{method:r}={}){super(t,{code:Ir.code,name:"MethodNotSupportedRpcError",shortMessage:`Method${r?` "${r}"`:""} is not supported.`})}}Object.defineProperty(Ir,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class yn extends it{constructor(t){super(t,{code:yn.code,name:"LimitExceededRpcError",shortMessage:"Request exceeds defined limit."})}}Object.defineProperty(yn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class fi extends it{constructor(t){super(t,{code:fi.code,name:"JsonRpcVersionUnsupportedError",shortMessage:"Version of JSON-RPC protocol is not supported."})}}Object.defineProperty(fi,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class an extends ct{constructor(t){super(t,{code:an.code,name:"UserRejectedRequestError",shortMessage:"User rejected the request."})}}Object.defineProperty(an,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class di extends ct{constructor(t){super(t,{code:di.code,name:"UnauthorizedProviderError",shortMessage:"The requested method and/or account has not been authorized by the user."})}}Object.defineProperty(di,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class li extends ct{constructor(t,{method:r}={}){super(t,{code:li.code,name:"UnsupportedProviderMethodError",shortMessage:`The Provider does not support the requested method${r?` " ${r}"`:""}.`})}}Object.defineProperty(li,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class hi extends ct{constructor(t){super(t,{code:hi.code,name:"ProviderDisconnectedError",shortMessage:"The Provider is disconnected from all chains."})}}Object.defineProperty(hi,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class pi extends ct{constructor(t){super(t,{code:pi.code,name:"ChainDisconnectedError",shortMessage:"The Provider is not connected to the requested chain."})}}Object.defineProperty(pi,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class yi extends ct{constructor(t){super(t,{code:yi.code,name:"SwitchChainError",shortMessage:"An error occurred when attempting to switch chain."})}}Object.defineProperty(yi,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class mi extends ct{constructor(t){super(t,{code:mi.code,name:"UnsupportedNonOptionalCapabilityError",shortMessage:"This Wallet does not support a capability that was not marked as optional."})}}Object.defineProperty(mi,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700});class bi extends ct{constructor(t){super(t,{code:bi.code,name:"UnsupportedChainIdError",shortMessage:"This Wallet does not support the requested chain ID."})}}Object.defineProperty(bi,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710});class gi extends ct{constructor(t){super(t,{code:gi.code,name:"DuplicateIdError",shortMessage:"There is already a bundle submitted with this ID."})}}Object.defineProperty(gi,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720});class wi extends ct{constructor(t){super(t,{code:wi.code,name:"UnknownBundleIdError",shortMessage:"This bundle id is unknown / has not been submitted"})}}Object.defineProperty(wi,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730});class _i extends ct{constructor(t){super(t,{code:_i.code,name:"BundleTooLargeError",shortMessage:"The call bundle is too large for the Wallet to process."})}}Object.defineProperty(_i,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740});class vi extends ct{constructor(t){super(t,{code:vi.code,name:"AtomicReadyWalletRejectedUpgradeError",shortMessage:"The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."})}}Object.defineProperty(vi,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750});class Ei extends ct{constructor(t){super(t,{code:Ei.code,name:"AtomicityNotSupportedError",shortMessage:"The wallet does not support atomic execution but the request requires it."})}}Object.defineProperty(Ei,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760});class Fp extends it{constructor(t){super(t,{name:"UnknownRpcError",shortMessage:"An unknown RPC error occurred."})}}const Up=3;function $s(e,{abi:t,address:r,args:n,docsPath:i,functionName:s,sender:o}){const a=e instanceof Jf?e:e instanceof L?e.walk(g=>"data"in g)||e.walk():{},{code:c,data:f,details:l,message:h,shortMessage:y}=a,p=e instanceof Na?new Cp({functionName:s}):[Up,Nr.code].includes(c)&&(f||l||h||y)?new Bp({abi:t,data:typeof f=="object"?f.data:f,functionName:s,message:a instanceof Va?l:y??h}):e;return new Ip(p,{abi:t,args:n,contractAddress:r,docsPath:i,functionName:s,sender:o})}function Np(e){const t=Sn(`0x${e.substring(4)}`).substring(26);return Ri(`0x${t}`)}async function Lp({hash:e,signature:t}){const r=qt(e)?e:J(e),{secp256k1:n}=await Promise.resolve().then(()=>require("./secp256k1-CO0Q3cOC.cjs"));return`0x${(()=>{if(typeof t=="object"&&"r"in t&&"s"in t){const{r:f,s:l,v:h,yParity:y}=t,p=Number(y??h),g=Kc(p);return new n.Signature(pt(f),pt(l)).addRecoveryBit(g)}const o=qt(t)?t:J(t),a=Vt(`0x${o.slice(130)}`),c=Kc(a);return n.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(c)})().recoverPublicKey(r.substring(2)).toHex(!1)}`}function Kc(e){if(e===0||e===1)return e;if(e===27)return 0;if(e===28)return 1;throw new Error("Invalid yParityOrV value")}async function Mp({hash:e,signature:t}){return Np(await Lp({hash:e,signature:t}))}function mr(e,t="hex"){const r=Qf(e),n=za(new Uint8Array(r.length));return r.encode(n),t==="hex"?Ze(n.bytes):n.bytes}function Qf(e){return Array.isArray(e)?$p(e.map(t=>Qf(t))):Hp(e)}function $p(e){const t=e.reduce((i,s)=>i+s.length,0),r=Zf(t);return{length:t<=55?1+t:1+r+t,encode(i){t<=55?i.pushByte(192+t):(i.pushByte(247+r),r===1?i.pushUint8(t):r===2?i.pushUint16(t):r===3?i.pushUint24(t):i.pushUint32(t));for(const{encode:s}of e)s(i)}}}function Hp(e){const t=typeof e=="string"?Wt(e):e,r=Zf(t.length);return{length:t.length===1&&t[0]<128?1:t.length<=55?1+t.length:1+r+t.length,encode(i){t.length===1&&t[0]<128?i.pushBytes(t):t.length<=55?(i.pushByte(128+t.length),i.pushBytes(t)):(i.pushByte(183+r),r===1?i.pushUint8(t.length):r===2?i.pushUint16(t.length):r===3?i.pushUint24(t.length):i.pushUint32(t.length),i.pushBytes(t))}}}function Zf(e){if(e<2**8)return 1;if(e<2**16)return 2;if(e<2**24)return 3;if(e<2**32)return 4;throw new L("Length is too large.")}function Dp(e){const{chainId:t,nonce:r,to:n}=e,i=e.contractAddress??e.address,s=Sn(Ot(["0x05",mr([t?Q(t):"0x",i,r?Q(r):"0x"])]));return n==="bytes"?Wt(s):s}async function ed(e){const{authorization:t,signature:r}=e;return Mp({hash:Dp(t),signature:r??t})}class jp extends L{constructor(t,{account:r,docsPath:n,chain:i,data:s,gas:o,gasPrice:a,maxFeePerGas:c,maxPriorityFeePerGas:f,nonce:l,to:h,value:y}){var g;const p=Ui({from:r==null?void 0:r.address,to:h,value:typeof y<"u"&&`${qa(y)} ${((g=i==null?void 0:i.nativeCurrency)==null?void 0:g.symbol)||"ETH"}`,data:s,gas:o,gasPrice:typeof a<"u"&&`${nt(a)} gwei`,maxFeePerGas:typeof c<"u"&&`${nt(c)} gwei`,maxPriorityFeePerGas:typeof f<"u"&&`${nt(f)} gwei`,nonce:l});super(t.shortMessage,{cause:t,docsPath:n,metaMessages:[...t.metaMessages?[...t.metaMessages," "]:[],"Estimate Gas Arguments:",p].filter(Boolean),name:"EstimateGasExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=t}}class rn extends L{constructor({cause:t,message:r}={}){var i;const n=(i=r==null?void 0:r.replace("execution reverted: ",""))==null?void 0:i.replace("execution reverted","");super(`Execution reverted ${n?`with reason: ${n}`:"for an unknown reason"}.`,{cause:t,name:"ExecutionRevertedError"})}}Object.defineProperty(rn,"code",{enumerable:!0,configurable:!0,writable:!0,value:3});Object.defineProperty(rn,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});class Lr extends L{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${nt(r)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:t,name:"FeeCapTooHighError"})}}Object.defineProperty(Lr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});class aa extends L{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${nt(r)}`:""} gwei) cannot be lower than the block base fee.`,{cause:t,name:"FeeCapTooLowError"})}}Object.defineProperty(aa,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/});class ca extends L{constructor({cause:t,nonce:r}={}){super(`Nonce provided for the transaction ${r?`(${r}) `:""}is higher than the next one expected.`,{cause:t,name:"NonceTooHighError"})}}Object.defineProperty(ca,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class ua extends L{constructor({cause:t,nonce:r}={}){super([`Nonce provided for the transaction ${r?`(${r}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join(`
36
+ `)})}}Object.defineProperty(pn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class ai extends it{constructor(t){super(t,{code:ai.code,name:"ResourceNotFoundRpcError",shortMessage:"Requested resource not found."}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ResourceNotFoundRpcError"})}}Object.defineProperty(ai,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class ci extends it{constructor(t){super(t,{code:ci.code,name:"ResourceUnavailableRpcError",shortMessage:"Requested resource not available."})}}Object.defineProperty(ci,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class ui extends it{constructor(t){super(t,{code:ui.code,name:"TransactionRejectedRpcError",shortMessage:"Transaction creation failed."})}}Object.defineProperty(ui,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class Ir extends it{constructor(t,{method:r}={}){super(t,{code:Ir.code,name:"MethodNotSupportedRpcError",shortMessage:`Method${r?` "${r}"`:""} is not supported.`})}}Object.defineProperty(Ir,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class yn extends it{constructor(t){super(t,{code:yn.code,name:"LimitExceededRpcError",shortMessage:"Request exceeds defined limit."})}}Object.defineProperty(yn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class fi extends it{constructor(t){super(t,{code:fi.code,name:"JsonRpcVersionUnsupportedError",shortMessage:"Version of JSON-RPC protocol is not supported."})}}Object.defineProperty(fi,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class an extends ct{constructor(t){super(t,{code:an.code,name:"UserRejectedRequestError",shortMessage:"User rejected the request."})}}Object.defineProperty(an,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class di extends ct{constructor(t){super(t,{code:di.code,name:"UnauthorizedProviderError",shortMessage:"The requested method and/or account has not been authorized by the user."})}}Object.defineProperty(di,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class li extends ct{constructor(t,{method:r}={}){super(t,{code:li.code,name:"UnsupportedProviderMethodError",shortMessage:`The Provider does not support the requested method${r?` " ${r}"`:""}.`})}}Object.defineProperty(li,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class hi extends ct{constructor(t){super(t,{code:hi.code,name:"ProviderDisconnectedError",shortMessage:"The Provider is disconnected from all chains."})}}Object.defineProperty(hi,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class pi extends ct{constructor(t){super(t,{code:pi.code,name:"ChainDisconnectedError",shortMessage:"The Provider is not connected to the requested chain."})}}Object.defineProperty(pi,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class yi extends ct{constructor(t){super(t,{code:yi.code,name:"SwitchChainError",shortMessage:"An error occurred when attempting to switch chain."})}}Object.defineProperty(yi,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class mi extends ct{constructor(t){super(t,{code:mi.code,name:"UnsupportedNonOptionalCapabilityError",shortMessage:"This Wallet does not support a capability that was not marked as optional."})}}Object.defineProperty(mi,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700});class bi extends ct{constructor(t){super(t,{code:bi.code,name:"UnsupportedChainIdError",shortMessage:"This Wallet does not support the requested chain ID."})}}Object.defineProperty(bi,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710});class gi extends ct{constructor(t){super(t,{code:gi.code,name:"DuplicateIdError",shortMessage:"There is already a bundle submitted with this ID."})}}Object.defineProperty(gi,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720});class wi extends ct{constructor(t){super(t,{code:wi.code,name:"UnknownBundleIdError",shortMessage:"This bundle id is unknown / has not been submitted"})}}Object.defineProperty(wi,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730});class _i extends ct{constructor(t){super(t,{code:_i.code,name:"BundleTooLargeError",shortMessage:"The call bundle is too large for the Wallet to process."})}}Object.defineProperty(_i,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740});class vi extends ct{constructor(t){super(t,{code:vi.code,name:"AtomicReadyWalletRejectedUpgradeError",shortMessage:"The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."})}}Object.defineProperty(vi,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750});class Ei extends ct{constructor(t){super(t,{code:Ei.code,name:"AtomicityNotSupportedError",shortMessage:"The wallet does not support atomic execution but the request requires it."})}}Object.defineProperty(Ei,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760});class Fp extends it{constructor(t){super(t,{name:"UnknownRpcError",shortMessage:"An unknown RPC error occurred."})}}const Up=3;function $s(e,{abi:t,address:r,args:n,docsPath:i,functionName:s,sender:o}){const a=e instanceof Jf?e:e instanceof L?e.walk(g=>"data"in g)||e.walk():{},{code:c,data:f,details:l,message:h,shortMessage:y}=a,p=e instanceof Na?new Cp({functionName:s}):[Up,Nr.code].includes(c)&&(f||l||h||y)?new Bp({abi:t,data:typeof f=="object"?f.data:f,functionName:s,message:a instanceof Va?l:y??h}):e;return new Ip(p,{abi:t,args:n,contractAddress:r,docsPath:i,functionName:s,sender:o})}function Np(e){const t=Sn(`0x${e.substring(4)}`).substring(26);return Ri(`0x${t}`)}async function Lp({hash:e,signature:t}){const r=qt(e)?e:J(e),{secp256k1:n}=await Promise.resolve().then(()=>require("./secp256k1-CTJXVISW.cjs"));return`0x${(()=>{if(typeof t=="object"&&"r"in t&&"s"in t){const{r:f,s:l,v:h,yParity:y}=t,p=Number(y??h),g=Kc(p);return new n.Signature(pt(f),pt(l)).addRecoveryBit(g)}const o=qt(t)?t:J(t),a=Vt(`0x${o.slice(130)}`),c=Kc(a);return n.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(c)})().recoverPublicKey(r.substring(2)).toHex(!1)}`}function Kc(e){if(e===0||e===1)return e;if(e===27)return 0;if(e===28)return 1;throw new Error("Invalid yParityOrV value")}async function Mp({hash:e,signature:t}){return Np(await Lp({hash:e,signature:t}))}function mr(e,t="hex"){const r=Qf(e),n=za(new Uint8Array(r.length));return r.encode(n),t==="hex"?Ze(n.bytes):n.bytes}function Qf(e){return Array.isArray(e)?$p(e.map(t=>Qf(t))):Hp(e)}function $p(e){const t=e.reduce((i,s)=>i+s.length,0),r=Zf(t);return{length:t<=55?1+t:1+r+t,encode(i){t<=55?i.pushByte(192+t):(i.pushByte(247+r),r===1?i.pushUint8(t):r===2?i.pushUint16(t):r===3?i.pushUint24(t):i.pushUint32(t));for(const{encode:s}of e)s(i)}}}function Hp(e){const t=typeof e=="string"?Wt(e):e,r=Zf(t.length);return{length:t.length===1&&t[0]<128?1:t.length<=55?1+t.length:1+r+t.length,encode(i){t.length===1&&t[0]<128?i.pushBytes(t):t.length<=55?(i.pushByte(128+t.length),i.pushBytes(t)):(i.pushByte(183+r),r===1?i.pushUint8(t.length):r===2?i.pushUint16(t.length):r===3?i.pushUint24(t.length):i.pushUint32(t.length),i.pushBytes(t))}}}function Zf(e){if(e<2**8)return 1;if(e<2**16)return 2;if(e<2**24)return 3;if(e<2**32)return 4;throw new L("Length is too large.")}function Dp(e){const{chainId:t,nonce:r,to:n}=e,i=e.contractAddress??e.address,s=Sn(Ot(["0x05",mr([t?Q(t):"0x",i,r?Q(r):"0x"])]));return n==="bytes"?Wt(s):s}async function ed(e){const{authorization:t,signature:r}=e;return Mp({hash:Dp(t),signature:r??t})}class jp extends L{constructor(t,{account:r,docsPath:n,chain:i,data:s,gas:o,gasPrice:a,maxFeePerGas:c,maxPriorityFeePerGas:f,nonce:l,to:h,value:y}){var g;const p=Ui({from:r==null?void 0:r.address,to:h,value:typeof y<"u"&&`${qa(y)} ${((g=i==null?void 0:i.nativeCurrency)==null?void 0:g.symbol)||"ETH"}`,data:s,gas:o,gasPrice:typeof a<"u"&&`${nt(a)} gwei`,maxFeePerGas:typeof c<"u"&&`${nt(c)} gwei`,maxPriorityFeePerGas:typeof f<"u"&&`${nt(f)} gwei`,nonce:l});super(t.shortMessage,{cause:t,docsPath:n,metaMessages:[...t.metaMessages?[...t.metaMessages," "]:[],"Estimate Gas Arguments:",p].filter(Boolean),name:"EstimateGasExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=t}}class rn extends L{constructor({cause:t,message:r}={}){var i;const n=(i=r==null?void 0:r.replace("execution reverted: ",""))==null?void 0:i.replace("execution reverted","");super(`Execution reverted ${n?`with reason: ${n}`:"for an unknown reason"}.`,{cause:t,name:"ExecutionRevertedError"})}}Object.defineProperty(rn,"code",{enumerable:!0,configurable:!0,writable:!0,value:3});Object.defineProperty(rn,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});class Lr extends L{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${nt(r)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:t,name:"FeeCapTooHighError"})}}Object.defineProperty(Lr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});class aa extends L{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${nt(r)}`:""} gwei) cannot be lower than the block base fee.`,{cause:t,name:"FeeCapTooLowError"})}}Object.defineProperty(aa,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/});class ca extends L{constructor({cause:t,nonce:r}={}){super(`Nonce provided for the transaction ${r?`(${r}) `:""}is higher than the next one expected.`,{cause:t,name:"NonceTooHighError"})}}Object.defineProperty(ca,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class ua extends L{constructor({cause:t,nonce:r}={}){super([`Nonce provided for the transaction ${r?`(${r}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join(`
37
37
  `),{cause:t,name:"NonceTooLowError"})}}Object.defineProperty(ua,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class fa extends L{constructor({cause:t,nonce:r}={}){super(`Nonce provided for the transaction ${r?`(${r}) `:""}exceeds the maximum allowed nonce.`,{cause:t,name:"NonceMaxValueError"})}}Object.defineProperty(fa,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class da extends L{constructor({cause:t}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join(`
38
38
  `),{cause:t,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}}Object.defineProperty(da,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class la extends L{constructor({cause:t,gas:r}={}){super(`The amount of gas ${r?`(${r}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:t,name:"IntrinsicGasTooHighError"})}}Object.defineProperty(la,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class ha extends L{constructor({cause:t,gas:r}={}){super(`The amount of gas ${r?`(${r}) `:""}provided for the transaction is too low.`,{cause:t,name:"IntrinsicGasTooLowError"})}}Object.defineProperty(ha,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class pa extends L{constructor({cause:t}){super("The transaction type is not supported for this chain.",{cause:t,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(pa,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class xi extends L{constructor({cause:t,maxPriorityFeePerGas:r,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${r?` = ${nt(r)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${nt(n)} gwei`:""}).`].join(`
39
39
  `),{cause:t,name:"TipAboveFeeCapError"})}}Object.defineProperty(xi,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max priority fee per gas higher than max fee per gas|tip higher than fee cap/});class Hs extends L{constructor({cause:t}){super(`An error occurred while executing: ${t==null?void 0:t.shortMessage}`,{cause:t,name:"UnknownNodeError"})}}function Wa(e,t){const r=(e.details||"").toLowerCase(),n=e instanceof L?e.walk(i=>(i==null?void 0:i.code)===rn.code):e;return n instanceof L?new rn({cause:e,message:n.details}):rn.nodeMessage.test(r)?new rn({cause:e,message:e.details}):Lr.nodeMessage.test(r)?new Lr({cause:e,maxFeePerGas:t==null?void 0:t.maxFeePerGas}):aa.nodeMessage.test(r)?new aa({cause:e,maxFeePerGas:t==null?void 0:t.maxFeePerGas}):ca.nodeMessage.test(r)?new ca({cause:e,nonce:t==null?void 0:t.nonce}):ua.nodeMessage.test(r)?new ua({cause:e,nonce:t==null?void 0:t.nonce}):fa.nodeMessage.test(r)?new fa({cause:e,nonce:t==null?void 0:t.nonce}):da.nodeMessage.test(r)?new da({cause:e}):la.nodeMessage.test(r)?new la({cause:e,gas:t==null?void 0:t.gas}):ha.nodeMessage.test(r)?new ha({cause:e,gas:t==null?void 0:t.gas}):pa.nodeMessage.test(r)?new pa({cause:e}):xi.nodeMessage.test(r)?new xi({cause:e,maxFeePerGas:t==null?void 0:t.maxFeePerGas,maxPriorityFeePerGas:t==null?void 0:t.maxPriorityFeePerGas}):new Hs({cause:e})}function Gp(e,{docsPath:t,...r}){const n=(()=>{const i=Wa(e,r);return i instanceof Hs?e:i})();return new jp(n,{docsPath:t,...r})}function Ka(e,{format:t}){if(!t)return{};const r={};function n(s){const o=Object.keys(s);for(const a of o)a in e&&(r[a]=e[a]),s[a]&&typeof s[a]=="object"&&!Array.isArray(s[a])&&n(s[a])}const i=t(e||{});return n(i),r}function Ya(e,t){return({exclude:r,format:n})=>({exclude:r,format:i=>{const s=t(i);if(r)for(const o of r)delete s[o];return{...s,...n(i)}},type:e})}const zp={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function Ds(e){const t={};return typeof e.authorizationList<"u"&&(t.authorizationList=qp(e.authorizationList)),typeof e.accessList<"u"&&(t.accessList=e.accessList),typeof e.blobVersionedHashes<"u"&&(t.blobVersionedHashes=e.blobVersionedHashes),typeof e.blobs<"u"&&(typeof e.blobs[0]!="string"?t.blobs=e.blobs.map(r=>Ze(r)):t.blobs=e.blobs),typeof e.data<"u"&&(t.data=e.data),typeof e.from<"u"&&(t.from=e.from),typeof e.gas<"u"&&(t.gas=Q(e.gas)),typeof e.gasPrice<"u"&&(t.gasPrice=Q(e.gasPrice)),typeof e.maxFeePerBlobGas<"u"&&(t.maxFeePerBlobGas=Q(e.maxFeePerBlobGas)),typeof e.maxFeePerGas<"u"&&(t.maxFeePerGas=Q(e.maxFeePerGas)),typeof e.maxPriorityFeePerGas<"u"&&(t.maxPriorityFeePerGas=Q(e.maxPriorityFeePerGas)),typeof e.nonce<"u"&&(t.nonce=Q(e.nonce)),typeof e.to<"u"&&(t.to=e.to),typeof e.type<"u"&&(t.type=zp[e.type]),typeof e.value<"u"&&(t.value=Q(e.value)),t}function qp(e){return e.map(t=>({address:t.address,r:t.r?Q(BigInt(t.r)):t.r,s:t.s?Q(BigInt(t.s)):t.s,chainId:Q(t.chainId),nonce:Q(t.nonce),...typeof t.yParity<"u"?{yParity:Q(t.yParity)}:{},...typeof t.v<"u"&&typeof t.yParity>"u"?{v:Q(t.v)}:{}}))}function Yc(e){if(!(!e||e.length===0))return e.reduce((t,{slot:r,value:n})=>{if(r.length!==66)throw new Fc({size:r.length,targetSize:66,type:"hex"});if(n.length!==66)throw new Fc({size:n.length,targetSize:66,type:"hex"});return t[r]=n,t},{})}function Vp(e){const{balance:t,nonce:r,state:n,stateDiff:i,code:s}=e,o={};if(s!==void 0&&(o.code=s),t!==void 0&&(o.balance=Q(t)),r!==void 0&&(o.nonce=Q(r)),n!==void 0&&(o.state=Yc(n)),i!==void 0){if(o.state)throw new _p;o.stateDiff=Yc(i)}return o}function td(e){if(!e)return;const t={};for(const{address:r,...n}of e){if(!Ue(r,{strict:!1}))throw new et({address:r});if(t[r])throw new wp({address:r});t[r]=Vp(n)}return t}const js=2n**256n-1n;function Ni(e){const{account:t,gasPrice:r,maxFeePerGas:n,maxPriorityFeePerGas:i,to:s}=e,o=t?Ne(t):void 0;if(o&&!Ue(o.address))throw new et({address:o.address});if(s&&!Ue(s))throw new et({address:s});if(typeof r<"u"&&(typeof n<"u"||typeof i<"u"))throw new Ep;if(n&&n>js)throw new Lr({maxFeePerGas:n});if(i&&n&&i>n)throw new xi({maxFeePerGas:n,maxPriorityFeePerGas:i})}class Wp extends L{constructor(){super("`baseFeeMultiplier` must be greater than 1.",{name:"BaseFeeScalarError"})}}class Xa extends L{constructor(){super("Chain does not support EIP-1559 fees.",{name:"Eip1559FeesNotSupportedError"})}}class Kp extends L{constructor({maxPriorityFeePerGas:t}){super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${nt(t)} gwei).`,{name:"MaxFeePerGasTooLowError"})}}class Yp extends L{constructor({blockHash:t,blockNumber:r}){let n="Block";t&&(n=`Block at hash "${t}"`),r&&(n=`Block at number "${r}"`),super(`${n} could not be found.`,{name:"BlockNotFoundError"})}}const rd={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function Ja(e){const t={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?Vt(e.chainId):void 0,gas:e.gas?BigInt(e.gas):void 0,gasPrice:e.gasPrice?BigInt(e.gasPrice):void 0,maxFeePerBlobGas:e.maxFeePerBlobGas?BigInt(e.maxFeePerBlobGas):void 0,maxFeePerGas:e.maxFeePerGas?BigInt(e.maxFeePerGas):void 0,maxPriorityFeePerGas:e.maxPriorityFeePerGas?BigInt(e.maxPriorityFeePerGas):void 0,nonce:e.nonce?Vt(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?rd[e.type]:void 0,typeHex:e.type?e.type:void 0,value:e.value?BigInt(e.value):void 0,v:e.v?BigInt(e.v):void 0};return e.authorizationList&&(t.authorizationList=Jp(e.authorizationList)),t.yParity=(()=>{if(e.yParity)return Number(e.yParity);if(typeof t.v=="bigint"){if(t.v===0n||t.v===27n)return 0;if(t.v===1n||t.v===28n)return 1;if(t.v>=35n)return t.v%2n===0n?1:0}})(),t.type==="legacy"&&(delete t.accessList,delete t.maxFeePerBlobGas,delete t.maxFeePerGas,delete t.maxPriorityFeePerGas,delete t.yParity),t.type==="eip2930"&&(delete t.maxFeePerBlobGas,delete t.maxFeePerGas,delete t.maxPriorityFeePerGas),t.type==="eip1559"&&delete t.maxFeePerBlobGas,t}const Xp=Ya("transaction",Ja);function Jp(e){return e.map(t=>({address:t.address,chainId:Number(t.chainId),nonce:Number(t.nonce),r:t.r,s:t.s,yParity:Number(t.yParity)}))}function nd(e){const t=(e.transactions??[]).map(r=>typeof r=="string"?r:Ja(r));return{...e,baseFeePerGas:e.baseFeePerGas?BigInt(e.baseFeePerGas):null,blobGasUsed:e.blobGasUsed?BigInt(e.blobGasUsed):void 0,difficulty:e.difficulty?BigInt(e.difficulty):void 0,excessBlobGas:e.excessBlobGas?BigInt(e.excessBlobGas):void 0,gasLimit:e.gasLimit?BigInt(e.gasLimit):void 0,gasUsed:e.gasUsed?BigInt(e.gasUsed):void 0,hash:e.hash?e.hash:null,logsBloom:e.logsBloom?e.logsBloom:null,nonce:e.nonce?e.nonce:null,number:e.number?BigInt(e.number):null,size:e.size?BigInt(e.size):void 0,timestamp:e.timestamp?BigInt(e.timestamp):void 0,transactions:t,totalDifficulty:e.totalDifficulty?BigInt(e.totalDifficulty):null}}const Qp=Ya("block",nd);async function As(e,{blockHash:t,blockNumber:r,blockTag:n,includeTransactions:i}={}){var l,h,y;const s=n??"latest",o=i??!1,a=r!==void 0?Q(r):void 0;let c=null;if(t?c=await e.request({method:"eth_getBlockByHash",params:[t,o]},{dedupe:!0}):c=await e.request({method:"eth_getBlockByNumber",params:[a||s,o]},{dedupe:!!a}),!c)throw new Yp({blockHash:t,blockNumber:r});return(((y=(h=(l=e.chain)==null?void 0:l.formatters)==null?void 0:h.block)==null?void 0:y.format)||nd)(c)}async function id(e){const t=await e.request({method:"eth_gasPrice"});return BigInt(t)}async function Zp(e,t){var s,o;const{block:r,chain:n=e.chain,request:i}=t||{};try{const a=((s=n==null?void 0:n.fees)==null?void 0:s.maxPriorityFeePerGas)??((o=n==null?void 0:n.fees)==null?void 0:o.defaultPriorityFee);if(typeof a=="function"){const f=r||await oe(e,As,"getBlock")({}),l=await a({block:f,client:e,request:i});if(l===null)throw new Error;return l}if(typeof a<"u")return a;const c=await e.request({method:"eth_maxPriorityFeePerGas"});return pt(c)}catch{const[a,c]=await Promise.all([r?Promise.resolve(r):oe(e,As,"getBlock")({}),oe(e,id,"getGasPrice")({})]);if(typeof a.baseFeePerGas!="bigint")throw new Xa;const f=c-a.baseFeePerGas;return f<0n?0n:f}}async function Xc(e,t){var y,p;const{block:r,chain:n=e.chain,request:i,type:s="eip1559"}=t||{},o=await(async()=>{var g,_;return typeof((g=n==null?void 0:n.fees)==null?void 0:g.baseFeeMultiplier)=="function"?n.fees.baseFeeMultiplier({block:r,client:e,request:i}):((_=n==null?void 0:n.fees)==null?void 0:_.baseFeeMultiplier)??1.2})();if(o<1)throw new Wp;const c=10**(((y=o.toString().split(".")[1])==null?void 0:y.length)??0),f=g=>g*BigInt(Math.ceil(o*c))/BigInt(c),l=r||await oe(e,As,"getBlock")({});if(typeof((p=n==null?void 0:n.fees)==null?void 0:p.estimateFeesPerGas)=="function"){const g=await n.fees.estimateFeesPerGas({block:r,client:e,multiply:f,request:i,type:s});if(g!==null)return g}if(s==="eip1559"){if(typeof l.baseFeePerGas!="bigint")throw new Xa;const g=typeof(i==null?void 0:i.maxPriorityFeePerGas)=="bigint"?i.maxPriorityFeePerGas:await Zp(e,{block:l,chain:n,request:i}),_=f(l.baseFeePerGas);return{maxFeePerGas:(i==null?void 0:i.maxFeePerGas)??_+g,maxPriorityFeePerGas:g}}return{gasPrice:(i==null?void 0:i.gasPrice)??f(await oe(e,id,"getGasPrice")({}))}}async function sd(e,{address:t,blockTag:r="latest",blockNumber:n}){const i=await e.request({method:"eth_getTransactionCount",params:[t,n?Q(n):r]},{dedupe:!!n});return Vt(i)}function Qa(e){const{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),n=typeof e.blobs[0]=="string"?e.blobs.map(s=>Wt(s)):e.blobs,i=[];for(const s of n)i.push(Uint8Array.from(t.blobToKzgCommitment(s)));return r==="bytes"?i:i.map(s=>Ze(s))}function Za(e){const{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),n=typeof e.blobs[0]=="string"?e.blobs.map(o=>Wt(o)):e.blobs,i=typeof e.commitments[0]=="string"?e.commitments.map(o=>Wt(o)):e.commitments,s=[];for(let o=0;o<n.length;o++){const a=n[o],c=i[o];s.push(Uint8Array.from(t.computeBlobKzgProof(a,c)))}return r==="bytes"?s:s.map(o=>Ze(o))}function ey(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);const i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),c=n?4:0,f=n?0:4;e.setUint32(t+c,o,n),e.setUint32(t+f,a,n)}function ty(e,t,r){return e&t^~e&r}function ry(e,t,r){return e&t^e&r^t&r}let ny=class extends Ma{constructor(t,r,n,i){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(t),this.view=bo(this.buffer)}update(t){ti(this);const{view:r,buffer:n,blockLen:i}=this;t=Rs(t);const s=t.length;for(let o=0;o<s;){const a=Math.min(i-this.pos,s-o);if(a===i){const c=bo(t);for(;i<=s-o;o+=i)this.process(c,o);continue}n.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){ti(this),Ff(t,this),this.finished=!0;const{buffer:r,view:n,blockLen:i,isLE:s}=this;let{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let h=o;h<i;h++)r[h]=0;ey(n,i-8,BigInt(this.length*8),s),this.process(n,0);const a=bo(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=c/4,l=this.get();if(f>l.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<f;h++)a.setUint32(4*h,l[h],s)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:r,buffer:n,length:i,finished:s,destroyed:o,pos:a}=this;return t.length=i,t.pos=a,t.finished=s,t.destroyed=o,i%r&&t.buffer.set(n),t}};const iy=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]),rr=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),nr=new Uint32Array(64);let sy=class extends ny{constructor(t=32){super(64,t,8,!1),this.A=rr[0]|0,this.B=rr[1]|0,this.C=rr[2]|0,this.D=rr[3]|0,this.E=rr[4]|0,this.F=rr[5]|0,this.G=rr[6]|0,this.H=rr[7]|0}get(){const{A:t,B:r,C:n,D:i,E:s,F:o,G:a,H:c}=this;return[t,r,n,i,s,o,a,c]}set(t,r,n,i,s,o,a,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(t,r){for(let h=0;h<16;h++,r+=4)nr[h]=t.getUint32(r,!1);for(let h=16;h<64;h++){const y=nr[h-15],p=nr[h-2],g=vt(y,7)^vt(y,18)^y>>>3,_=vt(p,17)^vt(p,19)^p>>>10;nr[h]=_+nr[h-7]+g+nr[h-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:c,G:f,H:l}=this;for(let h=0;h<64;h++){const y=vt(a,6)^vt(a,11)^vt(a,25),p=l+y+ty(a,c,f)+iy[h]+nr[h]|0,_=(vt(n,2)^vt(n,13)^vt(n,22))+ry(n,i,s)|0;l=f,f=c,c=a,a=o+p|0,o=s,s=i,i=n,n=p+_|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,l=l+this.H|0,this.set(n,i,s,o,a,c,f,l)}roundClean(){nr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const od=Uf(()=>new sy);function Wn(e,t){const r=t||"hex",n=od(qt(e,{strict:!1})?Ci(e):e);return r==="bytes"?n:J(n)}function oy(e){const{commitment:t,version:r=1}=e,n=e.to??(typeof t=="string"?"hex":"bytes"),i=Wn(t,"bytes");return i.set([r],0),n==="bytes"?i:Ze(i)}function ad(e){const{commitments:t,version:r}=e,n=e.to??(typeof t[0]=="string"?"hex":"bytes"),i=[];for(const s of t)i.push(oy({commitment:s,to:n,version:r}));return i}const Jc=6,cd=32,ec=4096,ud=cd*ec,Qc=ud*Jc-1-1*ec*Jc,fd=1;class ay extends L{constructor({maxSize:t,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${t} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}}class dd extends L{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}class cy extends L{constructor({hash:t,size:r}){super(`Versioned hash "${t}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${r}`],name:"InvalidVersionedHashSizeError"})}}class uy extends L{constructor({hash:t,version:r}){super(`Versioned hash "${t}" version is invalid.`,{metaMessages:[`Expected: ${fd}`,`Received: ${r}`],name:"InvalidVersionedHashVersionError"})}}function fy(e){const t=e.to??(typeof e.data=="string"?"hex":"bytes"),r=typeof e.data=="string"?Wt(e.data):e.data,n=Ie(r);if(!n)throw new dd;if(n>Qc)throw new ay({maxSize:Qc,size:n});const i=[];let s=!0,o=0;for(;s;){const a=za(new Uint8Array(ud));let c=0;for(;c<ec;){const f=r.slice(o,o+(cd-1));if(a.pushByte(0),a.pushBytes(f),f.length<31){a.pushByte(128),s=!1;break}c++,o+=31}i.push(a)}return t==="bytes"?i.map(a=>a.bytes):i.map(a=>Ze(a.bytes))}function ld(e){const{data:t,kzg:r,to:n}=e,i=e.blobs??fy({data:t,to:n}),s=e.commitments??Qa({blobs:i,kzg:r,to:n}),o=e.proofs??Za({blobs:i,commitments:s,kzg:r,to:n}),a=[];for(let c=0;c<i.length;c++)a.push({blob:i[c],commitment:s[c],proof:o[c]});return a}function hd(e){if(e.type)return e.type;if(typeof e.authorizationList<"u")return"eip7702";if(typeof e.blobs<"u"||typeof e.blobVersionedHashes<"u"||typeof e.maxFeePerBlobGas<"u"||typeof e.sidecars<"u")return"eip4844";if(typeof e.maxFeePerGas<"u"||typeof e.maxPriorityFeePerGas<"u")return"eip1559";if(typeof e.gasPrice<"u")return typeof e.accessList<"u"?"eip2930":"legacy";throw new Ap({transaction:e})}async function Li(e){const t=await e.request({method:"eth_chainId"},{dedupe:!0});return Vt(t)}const pd=["blobVersionedHashes","chainId","fees","gas","nonce","type"],Zc=new Map;async function tc(e,t){const{account:r=e.account,blobs:n,chain:i,gas:s,kzg:o,nonce:a,nonceManager:c,parameters:f=pd,type:l}=t,h=r&&Ne(r),y={...t,...h?{from:h==null?void 0:h.address}:{}};let p;async function g(){return p||(p=await oe(e,As,"getBlock")({blockTag:"latest"}),p)}let _;async function x(){return _||(i?i.id:typeof t.chainId<"u"?t.chainId:(_=await oe(e,Li,"getChainId")({}),_))}if(f.includes("nonce")&&typeof a>"u"&&h)if(c){const k=await x();y.nonce=await c.consume({address:h.address,chainId:k,client:e})}else y.nonce=await oe(e,sd,"getTransactionCount")({address:h.address,blockTag:"pending"});if((f.includes("blobVersionedHashes")||f.includes("sidecars"))&&n&&o){const k=Qa({blobs:n,kzg:o});if(f.includes("blobVersionedHashes")){const T=ad({commitments:k,to:"hex"});y.blobVersionedHashes=T}if(f.includes("sidecars")){const T=Za({blobs:n,commitments:k,kzg:o}),A=ld({blobs:n,commitments:k,proofs:T,to:"hex"});y.sidecars=A}}if(f.includes("chainId")&&(y.chainId=await x()),(f.includes("fees")||f.includes("type"))&&typeof l>"u")try{y.type=hd(y)}catch{let k=Zc.get(e.uid);if(typeof k>"u"){const T=await g();k=typeof(T==null?void 0:T.baseFeePerGas)=="bigint",Zc.set(e.uid,k)}y.type=k?"eip1559":"legacy"}if(f.includes("fees"))if(y.type!=="legacy"&&y.type!=="eip2930"){if(typeof y.maxFeePerGas>"u"||typeof y.maxPriorityFeePerGas>"u"){const k=await g(),{maxFeePerGas:T,maxPriorityFeePerGas:A}=await Xc(e,{block:k,chain:i,request:y});if(typeof t.maxPriorityFeePerGas>"u"&&t.maxFeePerGas&&t.maxFeePerGas<A)throw new Kp({maxPriorityFeePerGas:A});y.maxPriorityFeePerGas=A,y.maxFeePerGas=T}}else{if(typeof t.maxFeePerGas<"u"||typeof t.maxPriorityFeePerGas<"u")throw new Xa;if(typeof t.gasPrice>"u"){const k=await g(),{gasPrice:T}=await Xc(e,{block:k,chain:i,request:y,type:"legacy"});y.gasPrice=T}}return f.includes("gas")&&typeof s>"u"&&(y.gas=await oe(e,yd,"estimateGas")({...y,account:h&&{address:h.address,type:"json-rpc"}})),Ni(y),delete y.parameters,y}async function dy(e,{address:t,blockNumber:r,blockTag:n="latest"}){const i=r?Q(r):void 0,s=await e.request({method:"eth_getBalance",params:[t,i||n]});return BigInt(s)}async function yd(e,t){var i,s,o;const{account:r=e.account}=t,n=r?Ne(r):void 0;try{let V=function(ne){const{block:pe,request:_e,rpcStateOverride:Te}=ne;return e.request({method:"eth_estimateGas",params:Te?[_e,pe??"latest",Te]:pe?[_e,pe]:[_e]})};const{accessList:a,authorizationList:c,blobs:f,blobVersionedHashes:l,blockNumber:h,blockTag:y,data:p,gas:g,gasPrice:_,maxFeePerBlobGas:x,maxFeePerGas:k,maxPriorityFeePerGas:T,nonce:A,value:E,stateOverride:I,...S}=await tc(e,{...t,parameters:(n==null?void 0:n.type)==="local"?void 0:["blobVersionedHashes"]}),$=(h?Q(h):void 0)||y,B=td(I),W=await(async()=>{if(S.to)return S.to;if(c&&c.length>0)return await ed({authorization:c[0]}).catch(()=>{throw new L("`to` is required. Could not infer from `authorizationList`")})})();Ni(t);const R=(o=(s=(i=e.chain)==null?void 0:i.formatters)==null?void 0:s.transactionRequest)==null?void 0:o.format,j=(R||Ds)({...Ka(S,{format:R}),from:n==null?void 0:n.address,accessList:a,authorizationList:c,blobs:f,blobVersionedHashes:l,data:p,gas:g,gasPrice:_,maxFeePerBlobGas:x,maxFeePerGas:k,maxPriorityFeePerGas:T,nonce:A,to:W,value:E});let X=BigInt(await V({block:$,request:j,rpcStateOverride:B}));if(c){const ne=await dy(e,{address:j.from}),pe=await Promise.all(c.map(async _e=>{const{address:Te}=_e,We=await V({block:$,request:{authorizationList:void 0,data:p,from:n==null?void 0:n.address,to:Te,value:Q(ne)},rpcStateOverride:B}).catch(()=>100000n);return 2n*BigInt(We)}));X+=pe.reduce((_e,Te)=>_e+Te,0n)}return X}catch(a){throw Gp(a,{...t,account:n,chain:e.chain})}}async function ly(e,t){const{abi:r,address:n,args:i,functionName:s,dataSuffix:o,...a}=t,c=Tn({abi:r,args:i,functionName:s});try{return await oe(e,yd,"estimateGas")({data:`${c}${o?o.replace("0x",""):""}`,to:n,...a})}catch(f){const l=a.account?Ne(a.account):void 0;throw $s(f,{abi:r,address:n,args:i,docsPath:"/docs/contract/estimateContractGas",functionName:s,sender:l==null?void 0:l.address})}}function rc(e,t){if(!Ue(e,{strict:!1}))throw new et({address:e});if(!Ue(t,{strict:!1}))throw new et({address:t});return e.toLowerCase()===t.toLowerCase()}const eu="/docs/contract/decodeEventLog";function md(e){const{abi:t,data:r,strict:n,topics:i}=e,s=n??!0,[o,...a]=i;if(!o)throw new Zh({docsPath:eu});const c=t.length===1?t[0]:t.find(_=>_.type==="event"&&o===Fs(Bt(_)));if(!(c&&"name"in c)||c.type!=="event")throw new Pf(o,{docsPath:eu});const{name:f,inputs:l}=c,h=l==null?void 0:l.some(_=>!("name"in _&&_.name));let y=h?[]:{};const p=l.filter(_=>"indexed"in _&&_.indexed);for(let _=0;_<p.length;_++){const x=p[_],k=a[_];if(!k)throw new La({abiItem:c,param:x});y[h?_:x.name||_]=hy({param:x,value:k})}const g=l.filter(_=>!("indexed"in _&&_.indexed));if(g.length>0){if(r&&r!=="0x")try{const _=Fi(g,r);if(_)if(h)y=[...y,..._];else for(let x=0;x<g.length;x++)y[g[x].name]=_[x]}catch(_){if(s)throw _ instanceof Af||_ instanceof Wf?new Es({abiItem:c,data:r,params:g,size:Ie(r)}):_}else if(s)throw new Es({abiItem:c,data:"0x",params:g,size:0})}return{eventName:f,args:Object.values(y).length>0?y:void 0}}function hy({param:e,value:t}){return e.type==="string"||e.type==="bytes"||e.type==="tuple"||e.type.match(/^(.*)\[(\d+)?\]$/)?t:(Fi([e],t)||[])[0]}function bd(e){const{abi:t,args:r,logs:n,strict:i=!0}=e,s=(()=>{if(e.eventName)return Array.isArray(e.eventName)?e.eventName:[e.eventName]})();return n.map(o=>{var a;try{const c=t.find(l=>l.type==="event"&&o.topics[0]===Fs(l));if(!c)return null;const f=md({...o,abi:[c],strict:i});return s&&!s.includes(f.eventName)||!py({args:f.args,inputs:c.inputs,matchArgs:r})?null:{...f,...o}}catch(c){let f,l;if(c instanceof Pf)return null;if(c instanceof Es||c instanceof La){if(i)return null;f=c.abiItem.name,l=(a=c.abiItem.inputs)==null?void 0:a.some(h=>!("name"in h&&h.name))}return{...o,args:l?[]:{},eventName:f}}}).filter(Boolean)}function py(e){const{args:t,inputs:r,matchArgs:n}=e;if(!n)return!0;if(!t)return!1;function i(s,o,a){try{return s.type==="address"?rc(o,a):s.type==="string"||s.type==="bytes"?Sn(Ci(o))===a:o===a}catch{return!1}}return Array.isArray(t)&&Array.isArray(n)?n.every((s,o)=>{if(s==null)return!0;const a=r[o];return a?(Array.isArray(s)?s:[s]).some(f=>i(a,f,t[o])):!1}):typeof t=="object"&&!Array.isArray(t)&&typeof n=="object"&&!Array.isArray(n)?Object.entries(n).every(([s,o])=>{if(o==null)return!0;const a=r.find(f=>f.name===s);return a?(Array.isArray(o)?o:[o]).some(f=>i(a,f,t[s])):!1}):!1}function Ai(e,{args:t,eventName:r}={}){return{...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,logIndex:e.logIndex?Number(e.logIndex):null,transactionHash:e.transactionHash?e.transactionHash:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,...r?{args:t,eventName:r}:{}}}async function yy(e,{address:t,blockHash:r,fromBlock:n,toBlock:i,event:s,events:o,args:a,strict:c}={}){const f=c??!1,l=o??(s?[s]:void 0);let h=[];l&&(h=[l.flatMap(_=>Ga({abi:[_],eventName:_.name,args:o?void 0:a}))],s&&(h=h[0]));let y;r?y=await e.request({method:"eth_getLogs",params:[{address:t,topics:h,blockHash:r}]}):y=await e.request({method:"eth_getLogs",params:[{address:t,topics:h,fromBlock:typeof n=="bigint"?Q(n):n,toBlock:typeof i=="bigint"?Q(i):i}]});const p=y.map(g=>Ai(g));return l?bd({abi:l,args:a,logs:p,strict:f}):p}async function gd(e,t){const{abi:r,address:n,args:i,blockHash:s,eventName:o,fromBlock:a,toBlock:c,strict:f}=t,l=o?Pn({abi:r,name:o}):void 0,h=l?void 0:r.filter(y=>y.type==="event");return oe(e,yy,"getLogs")({address:n,args:i,blockHash:s,event:l,events:h,fromBlock:a,toBlock:c,strict:f})}const _o="/docs/contract/decodeFunctionResult";function nc(e){const{abi:t,args:r,functionName:n,data:i}=e;let s=t[0];if(n){const a=Pn({abi:t,args:r,name:n});if(!a)throw new ei(n,{docsPath:_o});s=a}if(s.type!=="function")throw new ei(void 0,{docsPath:_o});if(!s.outputs)throw new Tf(s.name,{docsPath:_o});const o=Fi(s.outputs,i);if(o&&o.length>1)return o;if(o&&o.length===1)return o[0]}const tu=[{inputs:[{components:[{name:"target",type:"address"},{name:"allowFailure",type:"bool"},{name:"callData",type:"bytes"}],name:"calls",type:"tuple[]"}],name:"aggregate3",outputs:[{components:[{name:"success",type:"bool"},{name:"returnData",type:"bytes"}],name:"returnData",type:"tuple[]"}],stateMutability:"view",type:"function"}],my=[{name:"query",type:"function",stateMutability:"view",inputs:[{type:"tuple[]",name:"queries",components:[{type:"address",name:"sender"},{type:"string[]",name:"urls"},{type:"bytes",name:"data"}]}],outputs:[{type:"bool[]",name:"failures"},{type:"bytes[]",name:"responses"}]},{name:"HttpError",type:"error",inputs:[{type:"uint16",name:"status"},{type:"string",name:"message"}]}],by="0x82ad56cb",gy="0x608060405234801561001057600080fd5b5060405161018e38038061018e83398101604081905261002f91610124565b6000808351602085016000f59050803b61004857600080fd5b6000808351602085016000855af16040513d6000823e81610067573d81fd5b3d81f35b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009257600080fd5b81516001600160401b038111156100ab576100ab61006b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156100d9576100d961006b565b6040528181528382016020018510156100f157600080fd5b60005b82811015610110576020818601810151838301820152016100f4565b506000918101602001919091529392505050565b6000806040838503121561013757600080fd5b82516001600160401b0381111561014d57600080fd5b61015985828601610081565b602085015190935090506001600160401b0381111561017757600080fd5b61018385828601610081565b915050925092905056fe",wy="0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe";class ya extends L{constructor({blockNumber:t,chain:r,contract:n}){super(`Chain "${r.name}" does not support contract "${n.name}".`,{metaMessages:["This could be due to any of the following:",...t&&n.blockCreated&&n.blockCreated>t?[`- The contract "${n.name}" was not deployed until block ${n.blockCreated} (current block ${t}).`]:[`- The chain does not have the contract "${n.name}" configured.`]],name:"ChainDoesNotSupportContract"})}}class _y extends L{constructor({chain:t,currentChainId:r}){super(`The current chain of the wallet (id: ${r}) does not match the target chain for the transaction (id: ${t.id} – ${t.name}).`,{metaMessages:[`Current Chain ID: ${r}`,`Expected Chain ID: ${t.id} – ${t.name}`],name:"ChainMismatchError"})}}class vy extends L{constructor(){super(["No chain was provided to the request.","Please provide a chain with the `chain` argument on the Action, or by supplying a `chain` to WalletClient."].join(`
40
- `),{name:"ChainNotFoundError"})}}class wd extends L{constructor(){super("No chain was provided to the Client.",{name:"ClientChainNotConfiguredError"})}}class Gs extends L{constructor({chainId:t}){super(typeof t=="number"?`Chain ID "${t}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}const vo="/docs/contract/encodeDeployData";function ic(e){const{abi:t,args:r,bytecode:n}=e;if(!r||r.length===0)return n;const i=t.find(o=>"type"in o&&o.type==="constructor");if(!i)throw new Wh({docsPath:vo});if(!("inputs"in i))throw new Oc({docsPath:vo});if(!i.inputs||i.inputs.length===0)throw new Oc({docsPath:vo});const s=Ns(i.inputs,r);return Ot([n,s])}function Ey({blockNumber:e,chain:t,contract:r}){var i;const n=(i=t==null?void 0:t.contracts)==null?void 0:i[r];if(!n)throw new ya({chain:t,contract:{name:r}});if(e&&n.blockCreated&&n.blockCreated>e)throw new ya({blockNumber:e,chain:t,contract:{name:r,blockCreated:n.blockCreated}});return n.address}function xy(e,{docsPath:t,...r}){const n=(()=>{const i=Wa(e,r);return i instanceof Hs?e:i})();return new kp(n,{docsPath:t,...r})}function _d(){let e=()=>{},t=()=>{};return{promise:new Promise((n,i)=>{e=n,t=i}),resolve:e,reject:t}}const Eo=new Map;function vd({fn:e,id:t,shouldSplitBatch:r,wait:n=0,sort:i}){const s=async()=>{const l=c();o();const h=l.map(({args:y})=>y);h.length!==0&&e(h).then(y=>{i&&Array.isArray(y)&&y.sort(i);for(let p=0;p<l.length;p++){const{resolve:g}=l[p];g==null||g([y[p],y])}}).catch(y=>{for(let p=0;p<l.length;p++){const{reject:g}=l[p];g==null||g(y)}})},o=()=>Eo.delete(t),a=()=>c().map(({args:l})=>l),c=()=>Eo.get(t)||[],f=l=>Eo.set(t,[...c(),l]);return{flush:o,async schedule(l){const{promise:h,resolve:y,reject:p}=_d();return(r==null?void 0:r([...a(),l]))&&s(),c().length>0?(f({args:l,resolve:y,reject:p}),h):(f({args:l,resolve:y,reject:p}),setTimeout(s,n),h)}}}async function sc(e,t){var R,D,j,V;const{account:r=e.account,batch:n=!!((R=e.batch)!=null&&R.multicall),blockNumber:i,blockTag:s="latest",accessList:o,blobs:a,code:c,data:f,factory:l,factoryData:h,gas:y,gasPrice:p,maxFeePerBlobGas:g,maxFeePerGas:_,maxPriorityFeePerGas:x,nonce:k,to:T,value:A,stateOverride:E,...I}=t,S=r?Ne(r):void 0;if(c&&(l||h))throw new L("Cannot provide both `code` & `factory`/`factoryData` as parameters.");if(c&&T)throw new L("Cannot provide both `code` & `to` as parameters.");const N=c&&f,$=l&&h&&T&&f,B=N||$,W=N?Py({code:c,data:f}):$?Ty({data:f,factory:l,factoryData:h,to:T}):f;try{Ni(t);const ne=(i?Q(i):void 0)||s,pe=td(E),_e=(V=(j=(D=e.chain)==null?void 0:D.formatters)==null?void 0:j.transactionRequest)==null?void 0:V.format,We=(_e||Ds)({...Ka(I,{format:_e}),from:S==null?void 0:S.address,accessList:o,blobs:a,data:W,gas:y,gasPrice:p,maxFeePerBlobGas:g,maxFeePerGas:_,maxPriorityFeePerGas:x,nonce:k,to:B?void 0:T,value:A});if(n&&Ay({request:We})&&!pe)try{return await Sy(e,{...We,blockNumber:i,blockTag:s})}catch(me){if(!(me instanceof wd)&&!(me instanceof ya))throw me}const fe=await e.request({method:"eth_call",params:pe?[We,ne,pe]:[We,ne]});return fe==="0x"?{data:void 0}:{data:fe}}catch(X){const ne=ky(X),{offchainLookup:pe,offchainLookupSignature:_e}=await Promise.resolve().then(()=>require("./ccip-FG4vhh8P.cjs"));if(e.ccipRead!==!1&&(ne==null?void 0:ne.slice(0,10))===_e&&T)return{data:await pe(e,{data:ne,to:T})};throw B&&(ne==null?void 0:ne.slice(0,10))==="0x101bb98d"?new Op({factory:l}):xy(X,{...t,account:S,chain:e.chain})}}function Ay({request:e}){const{data:t,to:r,...n}=e;return!(!t||t.startsWith(by)||!r||Object.values(n).filter(i=>typeof i<"u").length>0)}async function Sy(e,t){var _;const{batchSize:r=1024,wait:n=0}=typeof((_=e.batch)==null?void 0:_.multicall)=="object"?e.batch.multicall:{},{blockNumber:i,blockTag:s="latest",data:o,multicallAddress:a,to:c}=t;let f=a;if(!f){if(!e.chain)throw new wd;f=Ey({blockNumber:i,chain:e.chain,contract:"multicall3"})}const h=(i?Q(i):void 0)||s,{schedule:y}=vd({id:`${e.uid}.${h}`,wait:n,shouldSplitBatch(x){return x.reduce((T,{data:A})=>T+(A.length-2),0)>r*2},fn:async x=>{const k=x.map(E=>({allowFailure:!0,callData:E.data,target:E.to})),T=Tn({abi:tu,args:[k],functionName:"aggregate3"}),A=await e.request({method:"eth_call",params:[{data:T,to:f},h]});return nc({abi:tu,args:[k],functionName:"aggregate3",data:A||"0x"})}}),[{returnData:p,success:g}]=await y({data:o,to:c});if(!g)throw new Jf({data:p});return p==="0x"?{data:void 0}:{data:p}}function Py(e){const{code:t,data:r}=e;return ic({abi:vf(["constructor(bytes, bytes)"]),bytecode:gy,args:[t,r]})}function Ty(e){const{data:t,factory:r,factoryData:n,to:i}=e;return ic({abi:vf(["constructor(address, bytes, address, bytes)"]),bytecode:wy,args:[i,t,r,n]})}function ky(e){var r;if(!(e instanceof L))return;const t=e.walk();return typeof(t==null?void 0:t.data)=="object"?(r=t.data)==null?void 0:r.data:t.data}async function Iy(e,t){const{abi:r,address:n,args:i,functionName:s,...o}=t,a=Tn({abi:r,args:i,functionName:s});try{const{data:c}=await oe(e,sc,"call")({...o,data:a,to:n});return nc({abi:r,args:i,functionName:s,data:c||"0x"})}catch(c){throw $s(c,{abi:r,address:n,args:i,docsPath:"/docs/contract/readContract",functionName:s})}}async function By(e,t){const{abi:r,address:n,args:i,dataSuffix:s,functionName:o,...a}=t,c=a.account?Ne(a.account):e.account,f=Tn({abi:r,args:i,functionName:o});try{const{data:l}=await oe(e,sc,"call")({batch:!1,data:`${f}${s?s.replace("0x",""):""}`,to:n,...a,account:c}),h=nc({abi:r,args:i,functionName:o,data:l||"0x"}),y=r.filter(p=>"name"in p&&p.name===t.functionName);return{result:h,request:{abi:y,address:n,args:i,dataSuffix:s,functionName:o,...a,account:c}}}catch(l){throw $s(l,{abi:r,address:n,args:i,docsPath:"/docs/contract/simulateContract",functionName:o,sender:c==null?void 0:c.address})}}const xo=new Map,ru=new Map;let Cy=0;function ma(e,t,r){const n=++Cy,i=()=>xo.get(e)||[],s=()=>{const l=i();xo.set(e,l.filter(h=>h.id!==n))},o=()=>{const l=i();if(!l.some(y=>y.id===n))return;const h=ru.get(e);l.length===1&&h&&h(),s()},a=i();if(xo.set(e,[...a,{id:n,fns:t}]),a&&a.length>0)return o;const c={};for(const l in t)c[l]=(...h)=>{var p,g;const y=i();if(y.length!==0)for(const _ of y)(g=(p=_.fns)[l])==null||g.call(p,...h)};const f=r(c);return typeof f=="function"&&ru.set(e,f),o}async function ba(e){return new Promise(t=>setTimeout(t,e))}function Ed(e,{emitOnBegin:t,initialWaitTime:r,interval:n}){let i=!0;const s=()=>i=!1;return(async()=>{let a;a=await e({unpoll:s});const c=await(r==null?void 0:r(a))??n;await ba(c);const f=async()=>{i&&(await e({unpoll:s}),await ba(n),f())};f()})(),s}const Oy=new Map,Ry=new Map;function Fy(e){const t=(i,s)=>({clear:()=>s.delete(i),get:()=>s.get(i),set:o=>s.set(i,o)}),r=t(e,Oy),n=t(e,Ry);return{clear:()=>{r.clear(),n.clear()},promise:r,response:n}}async function Uy(e,{cacheKey:t,cacheTime:r=Number.POSITIVE_INFINITY}){const n=Fy(t),i=n.response.get();if(i&&r>0&&new Date().getTime()-i.created.getTime()<r)return i.data;let s=n.promise.get();s||(s=e(),n.promise.set(s));try{const o=await s;return n.response.set({created:new Date,data:o}),o}finally{n.promise.clear()}}const Ny=e=>`blockNumber.${e}`;async function Ly(e,{cacheTime:t=e.cacheTime}={}){const r=await Uy(()=>e.request({method:"eth_blockNumber"}),{cacheKey:Ny(e.uid),cacheTime:t});return BigInt(r)}async function My(e,{filter:t}){const r="strict"in t&&t.strict,n=await t.request({method:"eth_getFilterChanges",params:[t.id]});if(typeof n[0]=="string")return n;const i=n.map(s=>Ai(s));return!("abi"in t)||!t.abi?i:bd({abi:t.abi,logs:i,strict:r})}async function $y(e,{filter:t}){return t.request({method:"eth_uninstallFilter",params:[t.id]})}function Hy(e,t){const{abi:r,address:n,args:i,batch:s=!0,eventName:o,fromBlock:a,onError:c,onLogs:f,poll:l,pollingInterval:h=e.pollingInterval,strict:y}=t;return(typeof l<"u"?l:typeof a=="bigint"?!0:!(e.transport.type==="webSocket"||e.transport.type==="fallback"&&e.transport.transports[0].config.type==="webSocket"))?(()=>{const x=y??!1,k=rt(["watchContractEvent",n,i,s,e.uid,o,h,x,a]);return ma(k,{onLogs:f,onError:c},T=>{let A;a!==void 0&&(A=a-1n);let E,I=!1;const S=Ed(async()=>{var N;if(!I){try{E=await oe(e,qf,"createContractEventFilter")({abi:r,address:n,args:i,eventName:o,strict:x,fromBlock:a})}catch{}I=!0;return}try{let $;if(E)$=await oe(e,My,"getFilterChanges")({filter:E});else{const B=await oe(e,Ly,"getBlockNumber")({});A&&A<B?$=await oe(e,gd,"getContractEvents")({abi:r,address:n,args:i,eventName:o,fromBlock:A+1n,toBlock:B,strict:x}):$=[],A=B}if($.length===0)return;if(s)T.onLogs($);else for(const B of $)T.onLogs([B])}catch($){E&&$ instanceof pn&&(I=!1),(N=T.onError)==null||N.call(T,$)}},{emitOnBegin:!0,interval:h});return async()=>{E&&await oe(e,$y,"uninstallFilter")({filter:E}),S()}})})():(()=>{const x=y??!1,k=rt(["watchContractEvent",n,i,s,e.uid,o,h,x]);let T=!0,A=()=>T=!1;return ma(k,{onLogs:f,onError:c},E=>((async()=>{try{const I=(()=>{if(e.transport.type==="fallback"){const $=e.transport.transports.find(B=>B.config.type==="webSocket");return $?$.value:e.transport}return e.transport})(),S=o?Ga({abi:r,eventName:o,args:i}):[],{unsubscribe:N}=await I.subscribe({params:["logs",{address:n,topics:S}],onData($){var W;if(!T)return;const B=$.result;try{const{eventName:R,args:D}=md({abi:r,data:B.data,topics:B.topics,strict:y}),j=Ai(B,{args:D,eventName:R});E.onLogs([j])}catch(R){let D,j;if(R instanceof Es||R instanceof La){if(y)return;D=R.abiItem.name,j=(W=R.abiItem.inputs)==null?void 0:W.some(X=>!("name"in X&&X.name))}const V=Ai(B,{args:j?[]:{},eventName:D});E.onLogs([V])}},onError($){var B;(B=E.onError)==null||B.call(E,$)}});A=N,T||A()}catch(I){c==null||c(I)}})(),()=>A()))})()}class wr extends L{constructor({docsPath:t}={}){super(["Could not find an Account to execute with this Action.","Please provide an Account with the `account` argument on the Action, or by supplying an `account` to the Client."].join(`
40
+ `),{name:"ChainNotFoundError"})}}class wd extends L{constructor(){super("No chain was provided to the Client.",{name:"ClientChainNotConfiguredError"})}}class Gs extends L{constructor({chainId:t}){super(typeof t=="number"?`Chain ID "${t}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}const vo="/docs/contract/encodeDeployData";function ic(e){const{abi:t,args:r,bytecode:n}=e;if(!r||r.length===0)return n;const i=t.find(o=>"type"in o&&o.type==="constructor");if(!i)throw new Wh({docsPath:vo});if(!("inputs"in i))throw new Oc({docsPath:vo});if(!i.inputs||i.inputs.length===0)throw new Oc({docsPath:vo});const s=Ns(i.inputs,r);return Ot([n,s])}function Ey({blockNumber:e,chain:t,contract:r}){var i;const n=(i=t==null?void 0:t.contracts)==null?void 0:i[r];if(!n)throw new ya({chain:t,contract:{name:r}});if(e&&n.blockCreated&&n.blockCreated>e)throw new ya({blockNumber:e,chain:t,contract:{name:r,blockCreated:n.blockCreated}});return n.address}function xy(e,{docsPath:t,...r}){const n=(()=>{const i=Wa(e,r);return i instanceof Hs?e:i})();return new kp(n,{docsPath:t,...r})}function _d(){let e=()=>{},t=()=>{};return{promise:new Promise((n,i)=>{e=n,t=i}),resolve:e,reject:t}}const Eo=new Map;function vd({fn:e,id:t,shouldSplitBatch:r,wait:n=0,sort:i}){const s=async()=>{const l=c();o();const h=l.map(({args:y})=>y);h.length!==0&&e(h).then(y=>{i&&Array.isArray(y)&&y.sort(i);for(let p=0;p<l.length;p++){const{resolve:g}=l[p];g==null||g([y[p],y])}}).catch(y=>{for(let p=0;p<l.length;p++){const{reject:g}=l[p];g==null||g(y)}})},o=()=>Eo.delete(t),a=()=>c().map(({args:l})=>l),c=()=>Eo.get(t)||[],f=l=>Eo.set(t,[...c(),l]);return{flush:o,async schedule(l){const{promise:h,resolve:y,reject:p}=_d();return(r==null?void 0:r([...a(),l]))&&s(),c().length>0?(f({args:l,resolve:y,reject:p}),h):(f({args:l,resolve:y,reject:p}),setTimeout(s,n),h)}}}async function sc(e,t){var R,D,j,V;const{account:r=e.account,batch:n=!!((R=e.batch)!=null&&R.multicall),blockNumber:i,blockTag:s="latest",accessList:o,blobs:a,code:c,data:f,factory:l,factoryData:h,gas:y,gasPrice:p,maxFeePerBlobGas:g,maxFeePerGas:_,maxPriorityFeePerGas:x,nonce:k,to:T,value:A,stateOverride:E,...I}=t,S=r?Ne(r):void 0;if(c&&(l||h))throw new L("Cannot provide both `code` & `factory`/`factoryData` as parameters.");if(c&&T)throw new L("Cannot provide both `code` & `to` as parameters.");const N=c&&f,$=l&&h&&T&&f,B=N||$,W=N?Py({code:c,data:f}):$?Ty({data:f,factory:l,factoryData:h,to:T}):f;try{Ni(t);const ne=(i?Q(i):void 0)||s,pe=td(E),_e=(V=(j=(D=e.chain)==null?void 0:D.formatters)==null?void 0:j.transactionRequest)==null?void 0:V.format,We=(_e||Ds)({...Ka(I,{format:_e}),from:S==null?void 0:S.address,accessList:o,blobs:a,data:W,gas:y,gasPrice:p,maxFeePerBlobGas:g,maxFeePerGas:_,maxPriorityFeePerGas:x,nonce:k,to:B?void 0:T,value:A});if(n&&Ay({request:We})&&!pe)try{return await Sy(e,{...We,blockNumber:i,blockTag:s})}catch(me){if(!(me instanceof wd)&&!(me instanceof ya))throw me}const fe=await e.request({method:"eth_call",params:pe?[We,ne,pe]:[We,ne]});return fe==="0x"?{data:void 0}:{data:fe}}catch(X){const ne=ky(X),{offchainLookup:pe,offchainLookupSignature:_e}=await Promise.resolve().then(()=>require("./ccip-XLm2qDuq.cjs"));if(e.ccipRead!==!1&&(ne==null?void 0:ne.slice(0,10))===_e&&T)return{data:await pe(e,{data:ne,to:T})};throw B&&(ne==null?void 0:ne.slice(0,10))==="0x101bb98d"?new Op({factory:l}):xy(X,{...t,account:S,chain:e.chain})}}function Ay({request:e}){const{data:t,to:r,...n}=e;return!(!t||t.startsWith(by)||!r||Object.values(n).filter(i=>typeof i<"u").length>0)}async function Sy(e,t){var _;const{batchSize:r=1024,wait:n=0}=typeof((_=e.batch)==null?void 0:_.multicall)=="object"?e.batch.multicall:{},{blockNumber:i,blockTag:s="latest",data:o,multicallAddress:a,to:c}=t;let f=a;if(!f){if(!e.chain)throw new wd;f=Ey({blockNumber:i,chain:e.chain,contract:"multicall3"})}const h=(i?Q(i):void 0)||s,{schedule:y}=vd({id:`${e.uid}.${h}`,wait:n,shouldSplitBatch(x){return x.reduce((T,{data:A})=>T+(A.length-2),0)>r*2},fn:async x=>{const k=x.map(E=>({allowFailure:!0,callData:E.data,target:E.to})),T=Tn({abi:tu,args:[k],functionName:"aggregate3"}),A=await e.request({method:"eth_call",params:[{data:T,to:f},h]});return nc({abi:tu,args:[k],functionName:"aggregate3",data:A||"0x"})}}),[{returnData:p,success:g}]=await y({data:o,to:c});if(!g)throw new Jf({data:p});return p==="0x"?{data:void 0}:{data:p}}function Py(e){const{code:t,data:r}=e;return ic({abi:vf(["constructor(bytes, bytes)"]),bytecode:gy,args:[t,r]})}function Ty(e){const{data:t,factory:r,factoryData:n,to:i}=e;return ic({abi:vf(["constructor(address, bytes, address, bytes)"]),bytecode:wy,args:[i,t,r,n]})}function ky(e){var r;if(!(e instanceof L))return;const t=e.walk();return typeof(t==null?void 0:t.data)=="object"?(r=t.data)==null?void 0:r.data:t.data}async function Iy(e,t){const{abi:r,address:n,args:i,functionName:s,...o}=t,a=Tn({abi:r,args:i,functionName:s});try{const{data:c}=await oe(e,sc,"call")({...o,data:a,to:n});return nc({abi:r,args:i,functionName:s,data:c||"0x"})}catch(c){throw $s(c,{abi:r,address:n,args:i,docsPath:"/docs/contract/readContract",functionName:s})}}async function By(e,t){const{abi:r,address:n,args:i,dataSuffix:s,functionName:o,...a}=t,c=a.account?Ne(a.account):e.account,f=Tn({abi:r,args:i,functionName:o});try{const{data:l}=await oe(e,sc,"call")({batch:!1,data:`${f}${s?s.replace("0x",""):""}`,to:n,...a,account:c}),h=nc({abi:r,args:i,functionName:o,data:l||"0x"}),y=r.filter(p=>"name"in p&&p.name===t.functionName);return{result:h,request:{abi:y,address:n,args:i,dataSuffix:s,functionName:o,...a,account:c}}}catch(l){throw $s(l,{abi:r,address:n,args:i,docsPath:"/docs/contract/simulateContract",functionName:o,sender:c==null?void 0:c.address})}}const xo=new Map,ru=new Map;let Cy=0;function ma(e,t,r){const n=++Cy,i=()=>xo.get(e)||[],s=()=>{const l=i();xo.set(e,l.filter(h=>h.id!==n))},o=()=>{const l=i();if(!l.some(y=>y.id===n))return;const h=ru.get(e);l.length===1&&h&&h(),s()},a=i();if(xo.set(e,[...a,{id:n,fns:t}]),a&&a.length>0)return o;const c={};for(const l in t)c[l]=(...h)=>{var p,g;const y=i();if(y.length!==0)for(const _ of y)(g=(p=_.fns)[l])==null||g.call(p,...h)};const f=r(c);return typeof f=="function"&&ru.set(e,f),o}async function ba(e){return new Promise(t=>setTimeout(t,e))}function Ed(e,{emitOnBegin:t,initialWaitTime:r,interval:n}){let i=!0;const s=()=>i=!1;return(async()=>{let a;a=await e({unpoll:s});const c=await(r==null?void 0:r(a))??n;await ba(c);const f=async()=>{i&&(await e({unpoll:s}),await ba(n),f())};f()})(),s}const Oy=new Map,Ry=new Map;function Fy(e){const t=(i,s)=>({clear:()=>s.delete(i),get:()=>s.get(i),set:o=>s.set(i,o)}),r=t(e,Oy),n=t(e,Ry);return{clear:()=>{r.clear(),n.clear()},promise:r,response:n}}async function Uy(e,{cacheKey:t,cacheTime:r=Number.POSITIVE_INFINITY}){const n=Fy(t),i=n.response.get();if(i&&r>0&&new Date().getTime()-i.created.getTime()<r)return i.data;let s=n.promise.get();s||(s=e(),n.promise.set(s));try{const o=await s;return n.response.set({created:new Date,data:o}),o}finally{n.promise.clear()}}const Ny=e=>`blockNumber.${e}`;async function Ly(e,{cacheTime:t=e.cacheTime}={}){const r=await Uy(()=>e.request({method:"eth_blockNumber"}),{cacheKey:Ny(e.uid),cacheTime:t});return BigInt(r)}async function My(e,{filter:t}){const r="strict"in t&&t.strict,n=await t.request({method:"eth_getFilterChanges",params:[t.id]});if(typeof n[0]=="string")return n;const i=n.map(s=>Ai(s));return!("abi"in t)||!t.abi?i:bd({abi:t.abi,logs:i,strict:r})}async function $y(e,{filter:t}){return t.request({method:"eth_uninstallFilter",params:[t.id]})}function Hy(e,t){const{abi:r,address:n,args:i,batch:s=!0,eventName:o,fromBlock:a,onError:c,onLogs:f,poll:l,pollingInterval:h=e.pollingInterval,strict:y}=t;return(typeof l<"u"?l:typeof a=="bigint"?!0:!(e.transport.type==="webSocket"||e.transport.type==="fallback"&&e.transport.transports[0].config.type==="webSocket"))?(()=>{const x=y??!1,k=rt(["watchContractEvent",n,i,s,e.uid,o,h,x,a]);return ma(k,{onLogs:f,onError:c},T=>{let A;a!==void 0&&(A=a-1n);let E,I=!1;const S=Ed(async()=>{var N;if(!I){try{E=await oe(e,qf,"createContractEventFilter")({abi:r,address:n,args:i,eventName:o,strict:x,fromBlock:a})}catch{}I=!0;return}try{let $;if(E)$=await oe(e,My,"getFilterChanges")({filter:E});else{const B=await oe(e,Ly,"getBlockNumber")({});A&&A<B?$=await oe(e,gd,"getContractEvents")({abi:r,address:n,args:i,eventName:o,fromBlock:A+1n,toBlock:B,strict:x}):$=[],A=B}if($.length===0)return;if(s)T.onLogs($);else for(const B of $)T.onLogs([B])}catch($){E&&$ instanceof pn&&(I=!1),(N=T.onError)==null||N.call(T,$)}},{emitOnBegin:!0,interval:h});return async()=>{E&&await oe(e,$y,"uninstallFilter")({filter:E}),S()}})})():(()=>{const x=y??!1,k=rt(["watchContractEvent",n,i,s,e.uid,o,h,x]);let T=!0,A=()=>T=!1;return ma(k,{onLogs:f,onError:c},E=>((async()=>{try{const I=(()=>{if(e.transport.type==="fallback"){const $=e.transport.transports.find(B=>B.config.type==="webSocket");return $?$.value:e.transport}return e.transport})(),S=o?Ga({abi:r,eventName:o,args:i}):[],{unsubscribe:N}=await I.subscribe({params:["logs",{address:n,topics:S}],onData($){var W;if(!T)return;const B=$.result;try{const{eventName:R,args:D}=md({abi:r,data:B.data,topics:B.topics,strict:y}),j=Ai(B,{args:D,eventName:R});E.onLogs([j])}catch(R){let D,j;if(R instanceof Es||R instanceof La){if(y)return;D=R.abiItem.name,j=(W=R.abiItem.inputs)==null?void 0:W.some(X=>!("name"in X&&X.name))}const V=Ai(B,{args:j?[]:{},eventName:D});E.onLogs([V])}},onError($){var B;(B=E.onError)==null||B.call(E,$)}});A=N,T||A()}catch(I){c==null||c(I)}})(),()=>A()))})()}class wr extends L{constructor({docsPath:t}={}){super(["Could not find an Account to execute with this Action.","Please provide an Account with the `account` argument on the Action, or by supplying an `account` to the Client."].join(`
41
41
  `),{docsPath:t,docsSlug:"account",name:"AccountNotFoundError"})}}class ls extends L{constructor({docsPath:t,metaMessages:r,type:n}){super(`Account type "${n}" is not supported.`,{docsPath:t,metaMessages:r,name:"AccountTypeNotSupportedError"})}}function xd({chain:e,currentChainId:t}){if(!e)throw new vy;if(t!==e.id)throw new _y({chain:e,currentChainId:t})}function Ad(e,{docsPath:t,...r}){const n=(()=>{const i=Wa(e,r);return i instanceof Hs?e:i})();return new Pp(n,{docsPath:t,...r})}async function Sd(e,{serializedTransaction:t}){return e.request({method:"eth_sendRawTransaction",params:[t]},{retryCount:0})}const Ao=new Us(128);async function oc(e,t){var k,T,A,E;const{account:r=e.account,chain:n=e.chain,accessList:i,authorizationList:s,blobs:o,data:a,gas:c,gasPrice:f,maxFeePerBlobGas:l,maxFeePerGas:h,maxPriorityFeePerGas:y,nonce:p,value:g,..._}=t;if(typeof r>"u")throw new wr({docsPath:"/docs/actions/wallet/sendTransaction"});const x=r?Ne(r):null;try{Ni(t);const I=await(async()=>{if(t.to)return t.to;if(t.to!==null&&s&&s.length>0)return await ed({authorization:s[0]}).catch(()=>{throw new L("`to` is required. Could not infer from `authorizationList`.")})})();if((x==null?void 0:x.type)==="json-rpc"||x===null){let S;n!==null&&(S=await oe(e,Li,"getChainId")({}),xd({currentChainId:S,chain:n}));const N=(A=(T=(k=e.chain)==null?void 0:k.formatters)==null?void 0:T.transactionRequest)==null?void 0:A.format,B=(N||Ds)({...Ka(_,{format:N}),accessList:i,authorizationList:s,blobs:o,chainId:S,data:a,from:x==null?void 0:x.address,gas:c,gasPrice:f,maxFeePerBlobGas:l,maxFeePerGas:h,maxPriorityFeePerGas:y,nonce:p,to:I,value:g}),W=Ao.get(e.uid),R=W?"wallet_sendTransaction":"eth_sendTransaction";try{return await e.request({method:R,params:[B]},{retryCount:0})}catch(D){if(W===!1)throw D;const j=D;if(j.name==="InvalidInputRpcError"||j.name==="InvalidParamsRpcError"||j.name==="MethodNotFoundRpcError"||j.name==="MethodNotSupportedRpcError")return await e.request({method:"wallet_sendTransaction",params:[B]},{retryCount:0}).then(V=>(Ao.set(e.uid,!0),V)).catch(V=>{const X=V;throw X.name==="MethodNotFoundRpcError"||X.name==="MethodNotSupportedRpcError"?(Ao.set(e.uid,!1),j):X});throw j}}if((x==null?void 0:x.type)==="local"){const S=await oe(e,tc,"prepareTransactionRequest")({account:x,accessList:i,authorizationList:s,blobs:o,chain:n,data:a,gas:c,gasPrice:f,maxFeePerBlobGas:l,maxFeePerGas:h,maxPriorityFeePerGas:y,nonce:p,nonceManager:x.nonceManager,parameters:[...pd,"sidecars"],value:g,..._,to:I}),N=(E=n==null?void 0:n.serializers)==null?void 0:E.transaction,$=await x.signTransaction(S,{serializer:N});return await oe(e,Sd,"sendRawTransaction")({serializedTransaction:$})}throw(x==null?void 0:x.type)==="smart"?new ls({metaMessages:["Consider using the `sendUserOperation` Action instead."],docsPath:"/docs/actions/bundler/sendUserOperation",type:"smart"}):new ls({docsPath:"/docs/actions/wallet/sendTransaction",type:x==null?void 0:x.type})}catch(I){throw I instanceof ls?I:Ad(I,{...t,account:x,chain:t.chain||void 0})}}async function Pd(e,t){const{abi:r,account:n=e.account,address:i,args:s,dataSuffix:o,functionName:a,...c}=t;if(typeof n>"u")throw new wr({docsPath:"/docs/contract/writeContract"});const f=n?Ne(n):null,l=Tn({abi:r,args:s,functionName:a});try{return await oe(e,oc,"sendTransaction")({data:`${l}${o?o.replace("0x",""):""}`,to:i,account:f,...c})}catch(h){throw $s(h,{abi:r,address:i,args:s,docsPath:"/docs/contract/writeContract",functionName:a,sender:f==null?void 0:f.address})}}function So({abi:e,address:t,client:r}){const n=r,[i,s]=n?"public"in n&&"wallet"in n?[n.public,n.wallet]:"public"in n?[n.public,void 0]:"wallet"in n?[void 0,n.wallet]:[n,n]:[void 0,void 0],o=i!=null,a=s!=null,c={};let f=!1,l=!1,h=!1;for(const y of e)if(y.type==="function"?y.stateMutability==="view"||y.stateMutability==="pure"?f=!0:l=!0:y.type==="event"&&(h=!0),f&&l&&h)break;return o&&(f&&(c.read=new Proxy({},{get(y,p){return(...g)=>{const{args:_,options:x}=Xi(g);return oe(i,Iy,"readContract")({abi:e,address:t,functionName:p,args:_,...x})}}})),l&&(c.simulate=new Proxy({},{get(y,p){return(...g)=>{const{args:_,options:x}=Xi(g);return oe(i,By,"simulateContract")({abi:e,address:t,functionName:p,args:_,...x})}}})),h&&(c.createEventFilter=new Proxy({},{get(y,p){return(...g)=>{const _=e.find(T=>T.type==="event"&&T.name===p),{args:x,options:k}=Po(g,_);return oe(i,qf,"createContractEventFilter")({abi:e,address:t,eventName:p,args:x,...k})}}}),c.getEvents=new Proxy({},{get(y,p){return(...g)=>{const _=e.find(T=>T.type==="event"&&T.name===p),{args:x,options:k}=Po(g,_);return oe(i,gd,"getContractEvents")({abi:e,address:t,eventName:p,args:x,...k})}}}),c.watchEvent=new Proxy({},{get(y,p){return(...g)=>{const _=e.find(T=>T.type==="event"&&T.name===p),{args:x,options:k}=Po(g,_);return oe(i,Hy,"watchContractEvent")({abi:e,address:t,eventName:p,args:x,...k})}}}))),a&&l&&(c.write=new Proxy({},{get(y,p){return(...g)=>{const{args:_,options:x}=Xi(g);return oe(s,Pd,"writeContract")({abi:e,address:t,functionName:p,args:_,...x})}}})),(o||a)&&l&&(c.estimateGas=new Proxy({},{get(y,p){return(...g)=>{const{args:_,options:x}=Xi(g);return oe(i??s,ly,"estimateContractGas")({abi:e,address:t,functionName:p,args:_,...x,account:x.account??s.account})}}})),c.address=t,c.abi=e,c}function Xi(e){const t=e.length&&Array.isArray(e[0]),r=t?e[0]:[],n=(t?e[1]:e[0])??{};return{args:r,options:n}}function Po(e,t){let r=!1;Array.isArray(e[0])?r=!0:e.length===1?r=t.inputs.some(s=>s.indexed):e.length===2&&(r=!0);const n=r?e[0]:void 0,i=(r?e[1]:e[0])??{};return{args:n,options:i}}const Td={"0x0":"reverted","0x1":"success"};function Dy(e){const t={...e,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,contractAddress:e.contractAddress?e.contractAddress:null,cumulativeGasUsed:e.cumulativeGasUsed?BigInt(e.cumulativeGasUsed):null,effectiveGasPrice:e.effectiveGasPrice?BigInt(e.effectiveGasPrice):null,gasUsed:e.gasUsed?BigInt(e.gasUsed):null,logs:e.logs?e.logs.map(r=>Ai(r)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Vt(e.transactionIndex):null,status:e.status?Td[e.status]:null,type:e.type?rd[e.type]||e.type:null};return e.blobGasPrice&&(t.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(t.blobGasUsed=BigInt(e.blobGasUsed)),t}const jy=Ya("transactionReceipt",Dy);async function kd(e,t){const{atomic:r=!1,chainId:n,receipts:i,version:s="2.0.0",...o}=await e.request({method:"wallet_getCallsStatus",params:[t.id]}),[a,c]=(()=>{const f=o.status;return f>=100&&f<200?["pending",f]:f>=200&&f<300?["success",f]:f>=300&&f<700?["failure",f]:f==="CONFIRMED"?["success",200]:f==="PENDING"?["pending",100]:[void 0,f]})();return{...o,atomic:r,chainId:n?Vt(n):void 0,receipts:(i==null?void 0:i.map(f=>({...f,blockNumber:pt(f.blockNumber),gasUsed:pt(f.gasUsed),status:Td[f.status]})))??[],statusCode:c,status:a,version:s}}async function Gy(e,t){const{id:r,pollingInterval:n=e.pollingInterval,status:i=({statusCode:y})=>y>=200,timeout:s=6e4}=t,o=rt(["waitForCallsStatus",e.uid,r]),{promise:a,resolve:c,reject:f}=_d();let l;const h=ma(o,{resolve:c,reject:f},y=>{const p=Ed(async()=>{const g=_=>{clearTimeout(l),p(),_(),h()};try{const _=await kd(e,{id:r});if(!i(_))return;g(()=>y.resolve(_))}catch(_){g(()=>y.reject(_))}},{interval:n,emitOnBegin:!0});return p});return l=s?setTimeout(()=>{h(),clearTimeout(l),f(new zy({id:r}))},s):void 0,await a}class zy extends L{constructor({id:t}){super(`Timed out while waiting for call bundle with id "${t}" to be confirmed.`,{name:"WaitForCallsStatusTimeoutError"})}}const ga=256;let Ji=ga,Qi;function Id(e=11){if(!Qi||Ji+e>ga*2){Qi="",Ji=0;for(let t=0;t<ga;t++)Qi+=(256+Math.random()*256|0).toString(16).substring(1)}return Qi.substring(Ji,Ji+++e)}function qy(e){const{batch:t,cacheTime:r=e.pollingInterval??4e3,ccipRead:n,key:i="base",name:s="Base Client",pollingInterval:o=4e3,type:a="base"}=e,c=e.chain,f=e.account?Ne(e.account):void 0,{config:l,request:h,value:y}=e.transport({chain:c,pollingInterval:o}),p={...l,...y},g={account:f,batch:t,cacheTime:r,ccipRead:n,chain:c,key:i,name:s,pollingInterval:o,request:h,transport:p,type:a,uid:Id()};function _(x){return k=>{const T=k(x);for(const E in g)delete T[E];const A={...x,...T};return Object.assign(A,{extend:_(A)})}}return Object.assign(g,{extend:_(g)})}const Zi=new Us(8192);function Vy(e,{enabled:t=!0,id:r}){if(!t||!r)return e();if(Zi.get(r))return Zi.get(r);const n=e().finally(()=>Zi.delete(r));return Zi.set(r,n),n}function Wy(e,{delay:t=100,retryCount:r=2,shouldRetry:n=()=>!0}={}){return new Promise((i,s)=>{const o=async({count:a=0}={})=>{const c=async({error:f})=>{const l=typeof t=="function"?t({count:a,error:f}):t;l&&await ba(l),o({count:a+1})};try{const f=await e();i(f)}catch(f){if(a<r&&await n({count:a,error:f}))return c({error:f});s(f)}};o()})}function Ky(e,t={}){return async(r,n={})=>{var h;const{dedupe:i=!1,methods:s,retryDelay:o=150,retryCount:a=3,uid:c}={...t,...n},{method:f}=r;if((h=s==null?void 0:s.exclude)!=null&&h.includes(f))throw new Ir(new Error("method not supported"),{method:f});if(s!=null&&s.include&&!s.include.includes(f))throw new Ir(new Error("method not supported"),{method:f});const l=i?Os(`${c}.${rt(r)}`):void 0;return Vy(()=>Wy(async()=>{try{return await e(r)}catch(y){const p=y;switch(p.code){case ni.code:throw new ni(p);case ii.code:throw new ii(p);case si.code:throw new si(p,{method:r.method});case oi.code:throw new oi(p);case Nr.code:throw new Nr(p);case pn.code:throw new pn(p);case ai.code:throw new ai(p);case ci.code:throw new ci(p);case ui.code:throw new ui(p);case Ir.code:throw new Ir(p,{method:r.method});case yn.code:throw new yn(p);case fi.code:throw new fi(p);case an.code:throw new an(p);case di.code:throw new di(p);case li.code:throw new li(p);case hi.code:throw new hi(p);case pi.code:throw new pi(p);case yi.code:throw new yi(p);case mi.code:throw new mi(p);case bi.code:throw new bi(p);case gi.code:throw new gi(p);case wi.code:throw new wi(p);case _i.code:throw new _i(p);case vi.code:throw new vi(p);case Ei.code:throw new Ei(p);case 5e3:throw new an(p);default:throw y instanceof L?y:new Fp(p)}}},{delay:({count:y,error:p})=>{var g;if(p&&p instanceof on){const _=(g=p==null?void 0:p.headers)==null?void 0:g.get("Retry-After");if(_!=null&&_.match(/\d/))return Number.parseInt(_)*1e3}return~~(1<<y)*o},retryCount:a,shouldRetry:({error:y})=>Yy(y)}),{enabled:i,id:l})}}function Yy(e){return"code"in e&&typeof e.code=="number"?e.code===-1||e.code===yn.code||e.code===Nr.code:e instanceof on&&e.status?e.status===403||e.status===408||e.status===413||e.status===429||e.status===500||e.status===502||e.status===503||e.status===504:!0}function Bd({key:e,methods:t,name:r,request:n,retryCount:i=3,retryDelay:s=150,timeout:o,type:a},c){const f=Id();return{config:{key:e,methods:t,name:r,request:n,retryCount:i,retryDelay:s,timeout:o,type:a},request:Ky(n,{methods:t,retryCount:i,retryDelay:s,uid:f}),value:c}}function nu(e,t={}){const{key:r="custom",methods:n,name:i="Custom Provider",retryDelay:s}=t;return({retryCount:o})=>Bd({key:r,methods:n,name:i,request:e.request.bind(e),retryCount:t.retryCount??o,retryDelay:s,type:"custom"})}class Xy extends L{constructor(){super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",{docsPath:"/docs/clients/intro",name:"UrlRequiredError"})}}function Jy(e,{errorInstance:t=new Error("timed out"),timeout:r,signal:n}){return new Promise((i,s)=>{(async()=>{let o;try{const a=new AbortController;r>0&&(o=setTimeout(()=>{n&&a.abort()},r)),i(await e({signal:(a==null?void 0:a.signal)||null}))}catch(a){(a==null?void 0:a.name)==="AbortError"&&s(t),s(a)}finally{clearTimeout(o)}})()})}function Qy(){return{current:0,take(){return this.current++},reset(){this.current=0}}}const iu=Qy();function Zy(e,t={}){return{async request(r){var h;const{body:n,onRequest:i=t.onRequest,onResponse:s=t.onResponse,timeout:o=t.timeout??1e4}=r,a={...t.fetchOptions??{},...r.fetchOptions??{}},{headers:c,method:f,signal:l}=a;try{const y=await Jy(async({signal:g})=>{const _={...a,body:Array.isArray(n)?rt(n.map(A=>({jsonrpc:"2.0",id:A.id??iu.take(),...A}))):rt({jsonrpc:"2.0",id:n.id??iu.take(),...n}),headers:{"Content-Type":"application/json",...c},method:f||"POST",signal:l||(o>0?g:null)},x=new Request(e,_),k=await(i==null?void 0:i(x,_))??{..._,url:e};return await fetch(k.url??e,k)},{errorInstance:new Wc({body:n,url:e}),timeout:o,signal:!0});s&&await s(y);let p;if((h=y.headers.get("Content-Type"))!=null&&h.startsWith("application/json"))p=await y.json();else{p=await y.text();try{p=JSON.parse(p||"{}")}catch(g){if(y.ok)throw g;p={error:p}}}if(!y.ok)throw new on({body:n,details:rt(p.error)||y.statusText,headers:y.headers,status:y.status,url:e});return p}catch(y){throw y instanceof on||y instanceof Wc?y:new on({body:n,cause:y,url:e})}}}}function em(e,t={}){const{batch:r,fetchOptions:n,key:i="http",methods:s,name:o="HTTP JSON-RPC",onFetchRequest:a,onFetchResponse:c,retryDelay:f,raw:l}=t;return({chain:h,retryCount:y,timeout:p})=>{const{batchSize:g=1e3,wait:_=0}=typeof r=="object"?r:{},x=t.retryCount??y,k=p??t.timeout??1e4,T=h==null?void 0:h.rpcUrls.default.http[0];if(!T)throw new Xy;const A=Zy(T,{fetchOptions:n,onRequest:a,onResponse:c,timeout:k});return Bd({key:i,methods:s,name:o,async request({method:E,params:I}){const S={method:E,params:I},{schedule:N}=vd({id:T,wait:_,shouldSplitBatch(R){return R.length>g},fn:R=>A.request({body:R}),sort:(R,D)=>R.id-D.id}),$=async R=>r?N(R):[await A.request({body:R})],[{error:B,result:W}]=await $(S);if(l)return{error:B,result:W};if(B)throw new Va({body:S,error:B,url:T});return W},retryCount:x,retryDelay:f,timeout:k,type:"http"},{fetchOptions:n,url:T})}}function wt(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}class tm extends L{constructor({domain:t}){super(`Invalid domain "${rt(t)}".`,{metaMessages:["Must be a valid EIP-712 domain."]})}}class rm extends L{constructor({primaryType:t,types:r}){super(`Invalid primary type \`${t}\` must be one of \`${JSON.stringify(Object.keys(r))}\`.`,{docsPath:"/api/glossary/Errors#typeddatainvalidprimarytypeerror",metaMessages:["Check that the primary type is a key in `types`."]})}}class nm extends L{constructor({type:t}){super(`Struct type "${t}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."],name:"InvalidStructTypeError"})}}function im(e){const{domain:t,message:r,primaryType:n,types:i}=e,s=(c,f)=>{const l={...f};for(const h of c){const{name:y,type:p}=h;p==="address"&&(l[y]=l[y].toLowerCase())}return l},o=i.EIP712Domain?t?s(i.EIP712Domain,t):{}:{},a=(()=>{if(n!=="EIP712Domain")return s(i[n],r)})();return rt({domain:o,message:a,primaryType:n,types:i})}function sm(e){const{domain:t,message:r,primaryType:n,types:i}=e,s=(o,a)=>{for(const c of o){const{name:f,type:l}=c,h=a[f],y=l.match(Gf);if(y&&(typeof h=="number"||typeof h=="bigint")){const[_,x,k]=y;Q(h,{signed:x==="int",size:Number.parseInt(k)/8})}if(l==="address"&&typeof h=="string"&&!Ue(h))throw new et({address:h});const p=l.match(V0);if(p){const[_,x]=p;if(x&&Ie(h)!==Number.parseInt(x))throw new r0({expectedSize:Number.parseInt(x),givenSize:Ie(h)})}const g=i[l];g&&(am(l),s(g,h))}};if(i.EIP712Domain&&t){if(typeof t!="object")throw new tm({domain:t});s(i.EIP712Domain,t)}if(n!=="EIP712Domain")if(i[n])s(i[n],r);else throw new rm({primaryType:n,types:i})}function om({domain:e}){return[typeof(e==null?void 0:e.name)=="string"&&{name:"name",type:"string"},(e==null?void 0:e.version)&&{name:"version",type:"string"},(typeof(e==null?void 0:e.chainId)=="number"||typeof(e==null?void 0:e.chainId)=="bigint")&&{name:"chainId",type:"uint256"},(e==null?void 0:e.verifyingContract)&&{name:"verifyingContract",type:"address"},(e==null?void 0:e.salt)&&{name:"salt",type:"bytes32"}].filter(Boolean)}function am(e){if(e==="address"||e==="bool"||e==="string"||e.startsWith("bytes")||e.startsWith("uint")||e.startsWith("int"))throw new nm({type:e})}function cm(e){const{authorizationList:t}=e;if(t)for(const r of t){const{chainId:n}=r,i=r.address;if(!Ue(i))throw new et({address:i});if(n<0)throw new Gs({chainId:n})}ac(e)}function um(e){const{blobVersionedHashes:t}=e;if(t){if(t.length===0)throw new dd;for(const r of t){const n=Ie(r),i=Vt(hn(r,0,1));if(n!==32)throw new cy({hash:r,size:n});if(i!==fd)throw new uy({hash:r,version:i})}}ac(e)}function ac(e){const{chainId:t,maxPriorityFeePerGas:r,maxFeePerGas:n,to:i}=e;if(t<=0)throw new Gs({chainId:t});if(i&&!Ue(i))throw new et({address:i});if(n&&n>js)throw new Lr({maxFeePerGas:n});if(r&&n&&r>n)throw new xi({maxFeePerGas:n,maxPriorityFeePerGas:r})}function fm(e){const{chainId:t,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:i,to:s}=e;if(t<=0)throw new Gs({chainId:t});if(s&&!Ue(s))throw new et({address:s});if(r||i)throw new L("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(n&&n>js)throw new Lr({maxFeePerGas:n})}function dm(e){const{chainId:t,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:i,to:s}=e;if(s&&!Ue(s))throw new et({address:s});if(typeof t<"u"&&t<=0)throw new Gs({chainId:t});if(r||i)throw new L("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(n&&n>js)throw new Lr({maxFeePerGas:n})}function zs(e){if(!e||e.length===0)return[];const t=[];for(let r=0;r<e.length;r++){const{address:n,storageKeys:i}=e[r];for(let s=0;s<i.length;s++)if(i[s].length-2!==64)throw new Sp({storageKey:i[s]});if(!Ue(n,{strict:!1}))throw new et({address:n});t.push([n,i])}return t}function lm(e,t){const r=hd(e);return r==="eip1559"?ym(e,t):r==="eip2930"?mm(e,t):r==="eip4844"?pm(e,t):r==="eip7702"?hm(e,t):bm(e,t)}function hm(e,t){const{authorizationList:r,chainId:n,gas:i,nonce:s,to:o,value:a,maxFeePerGas:c,maxPriorityFeePerGas:f,accessList:l,data:h}=e;cm(e);const y=zs(l),p=gm(r);return Ot(["0x04",mr([J(n),s?J(s):"0x",f?J(f):"0x",c?J(c):"0x",i?J(i):"0x",o??"0x",a?J(a):"0x",h??"0x",y,p,...Mi(e,t)])])}function pm(e,t){const{chainId:r,gas:n,nonce:i,to:s,value:o,maxFeePerBlobGas:a,maxFeePerGas:c,maxPriorityFeePerGas:f,accessList:l,data:h}=e;um(e);let y=e.blobVersionedHashes,p=e.sidecars;if(e.blobs&&(typeof y>"u"||typeof p>"u")){const A=typeof e.blobs[0]=="string"?e.blobs:e.blobs.map(S=>Ze(S)),E=e.kzg,I=Qa({blobs:A,kzg:E});if(typeof y>"u"&&(y=ad({commitments:I})),typeof p>"u"){const S=Za({blobs:A,commitments:I,kzg:E});p=ld({blobs:A,commitments:I,proofs:S})}}const g=zs(l),_=[J(r),i?J(i):"0x",f?J(f):"0x",c?J(c):"0x",n?J(n):"0x",s??"0x",o?J(o):"0x",h??"0x",g,a?J(a):"0x",y??[],...Mi(e,t)],x=[],k=[],T=[];if(p)for(let A=0;A<p.length;A++){const{blob:E,commitment:I,proof:S}=p[A];x.push(E),k.push(I),T.push(S)}return Ot(["0x03",mr(p?[_,x,k,T]:_)])}function ym(e,t){const{chainId:r,gas:n,nonce:i,to:s,value:o,maxFeePerGas:a,maxPriorityFeePerGas:c,accessList:f,data:l}=e;ac(e);const h=zs(f),y=[J(r),i?J(i):"0x",c?J(c):"0x",a?J(a):"0x",n?J(n):"0x",s??"0x",o?J(o):"0x",l??"0x",h,...Mi(e,t)];return Ot(["0x02",mr(y)])}function mm(e,t){const{chainId:r,gas:n,data:i,nonce:s,to:o,value:a,accessList:c,gasPrice:f}=e;fm(e);const l=zs(c),h=[J(r),s?J(s):"0x",f?J(f):"0x",n?J(n):"0x",o??"0x",a?J(a):"0x",i??"0x",l,...Mi(e,t)];return Ot(["0x01",mr(h)])}function bm(e,t){const{chainId:r=0,gas:n,data:i,nonce:s,to:o,value:a,gasPrice:c}=e;dm(e);let f=[s?J(s):"0x",c?J(c):"0x",n?J(n):"0x",o??"0x",a?J(a):"0x",i??"0x"];if(t){const l=(()=>{if(t.v>=35n)return(t.v-35n)/2n>0?t.v:27n+(t.v===35n?0n:1n);if(r>0)return BigInt(r*2)+BigInt(35n+t.v-27n);const p=27n+(t.v===27n?0n:1n);if(t.v!==p)throw new xp({v:t.v});return p})(),h=Fr(t.r),y=Fr(t.s);f=[...f,J(l),h==="0x00"?"0x":h,y==="0x00"?"0x":y]}else r>0&&(f=[...f,J(r),"0x","0x"]);return mr(f)}function Mi(e,t){const r=t??e,{v:n,yParity:i}=r;if(typeof r.r>"u")return[];if(typeof r.s>"u")return[];if(typeof n>"u"&&typeof i>"u")return[];const s=Fr(r.r),o=Fr(r.s);return[typeof i=="number"?i?J(1):"0x":n===0n?"0x":n===1n?J(1):n===27n?"0x":J(1),s==="0x00"?"0x":s,o==="0x00"?"0x":o]}function gm(e){if(!e||e.length===0)return[];const t=[];for(const r of e){const{chainId:n,nonce:i,...s}=r,o=r.address;t.push([n?J(n):"0x",o,i?J(i):"0x",...Mi({},s)])}return t}var br=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function wm(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function _m(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}),r}var mn={},Qt={},_r={};Object.defineProperty(_r,"__esModule",{value:!0});_r.anumber=wa;_r.abytes=Cd;_r.ahash=Em;_r.aexists=xm;_r.aoutput=Am;function wa(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function vm(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Cd(e,...t){if(!vm(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Em(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");wa(e.outputLen),wa(e.blockLen)}function xm(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Am(e,t){Cd(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}var $i={},qs={};Object.defineProperty(qs,"__esModule",{value:!0});qs.crypto=void 0;qs.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;(function(e){/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.isLE=void 0,e.isBytes=n,e.u8=i,e.u32=s,e.createView=o,e.rotr=a,e.rotl=c,e.byteSwap=f,e.byteSwap32=l,e.bytesToHex=y,e.hexToBytes=_,e.asyncLoop=k,e.utf8ToBytes=T,e.toBytes=A,e.concatBytes=E,e.checkOpts=S,e.wrapConstructor=N,e.wrapConstructorWithOpts=$,e.wrapXOFConstructorWithOpts=B,e.randomBytes=W;const t=qs,r=_r;function n(R){return R instanceof Uint8Array||ArrayBuffer.isView(R)&&R.constructor.name==="Uint8Array"}function i(R){return new Uint8Array(R.buffer,R.byteOffset,R.byteLength)}function s(R){return new Uint32Array(R.buffer,R.byteOffset,Math.floor(R.byteLength/4))}function o(R){return new DataView(R.buffer,R.byteOffset,R.byteLength)}function a(R,D){return R<<32-D|R>>>D}function c(R,D){return R<<D|R>>>32-D>>>0}e.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function f(R){return R<<24&4278190080|R<<8&16711680|R>>>8&65280|R>>>24&255}e.byteSwapIfBE=e.isLE?R=>R:R=>f(R);function l(R){for(let D=0;D<R.length;D++)R[D]=f(R[D])}const h=Array.from({length:256},(R,D)=>D.toString(16).padStart(2,"0"));function y(R){(0,r.abytes)(R);let D="";for(let j=0;j<R.length;j++)D+=h[R[j]];return D}const p={_0:48,_9:57,A:65,F:70,a:97,f:102};function g(R){if(R>=p._0&&R<=p._9)return R-p._0;if(R>=p.A&&R<=p.F)return R-(p.A-10);if(R>=p.a&&R<=p.f)return R-(p.a-10)}function _(R){if(typeof R!="string")throw new Error("hex string expected, got "+typeof R);const D=R.length,j=D/2;if(D%2)throw new Error("hex string expected, got unpadded hex of length "+D);const V=new Uint8Array(j);for(let X=0,ne=0;X<j;X++,ne+=2){const pe=g(R.charCodeAt(ne)),_e=g(R.charCodeAt(ne+1));if(pe===void 0||_e===void 0){const Te=R[ne]+R[ne+1];throw new Error('hex string expected, got non-hex character "'+Te+'" at index '+ne)}V[X]=pe*16+_e}return V}const x=async()=>{};e.nextTick=x;async function k(R,D,j){let V=Date.now();for(let X=0;X<R;X++){j(X);const ne=Date.now()-V;ne>=0&&ne<D||(await(0,e.nextTick)(),V+=ne)}}function T(R){if(typeof R!="string")throw new Error("utf8ToBytes expected string, got "+typeof R);return new Uint8Array(new TextEncoder().encode(R))}function A(R){return typeof R=="string"&&(R=T(R)),(0,r.abytes)(R),R}function E(...R){let D=0;for(let V=0;V<R.length;V++){const X=R[V];(0,r.abytes)(X),D+=X.length}const j=new Uint8Array(D);for(let V=0,X=0;V<R.length;V++){const ne=R[V];j.set(ne,X),X+=ne.length}return j}class I{clone(){return this._cloneInto()}}e.Hash=I;function S(R,D){if(D!==void 0&&{}.toString.call(D)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(R,D)}function N(R){const D=V=>R().update(A(V)).digest(),j=R();return D.outputLen=j.outputLen,D.blockLen=j.blockLen,D.create=()=>R(),D}function $(R){const D=(V,X)=>R(X).update(A(V)).digest(),j=R({});return D.outputLen=j.outputLen,D.blockLen=j.blockLen,D.create=V=>R(V),D}function B(R){const D=(V,X)=>R(X).update(A(V)).digest(),j=R({});return D.outputLen=j.outputLen,D.blockLen=j.blockLen,D.create=V=>R(V),D}function W(R=32){if(t.crypto&&typeof t.crypto.getRandomValues=="function")return t.crypto.getRandomValues(new Uint8Array(R));if(t.crypto&&typeof t.crypto.randomBytes=="function")return t.crypto.randomBytes(R);throw new Error("crypto.getRandomValues must be defined")}})($i);Object.defineProperty(Qt,"__esModule",{value:!0});Qt.HashMD=void 0;Qt.setBigUint64=Od;Qt.Chi=Sm;Qt.Maj=Pm;const To=_r,Fn=$i;function Od(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);const i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),c=n?4:0,f=n?0:4;e.setUint32(t+c,o,n),e.setUint32(t+f,a,n)}function Sm(e,t,r){return e&t^~e&r}function Pm(e,t,r){return e&t^e&r^t&r}class Tm extends Fn.Hash{constructor(t,r,n,i){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,Fn.createView)(this.buffer)}update(t){(0,To.aexists)(this);const{view:r,buffer:n,blockLen:i}=this;t=(0,Fn.toBytes)(t);const s=t.length;for(let o=0;o<s;){const a=Math.min(i-this.pos,s-o);if(a===i){const c=(0,Fn.createView)(t);for(;i<=s-o;o+=i)this.process(c,o);continue}n.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,To.aexists)(this),(0,To.aoutput)(t,this),this.finished=!0;const{buffer:r,view:n,blockLen:i,isLE:s}=this;let{pos:o}=this;r[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>i-o&&(this.process(n,0),o=0);for(let h=o;h<i;h++)r[h]=0;Od(n,i-8,BigInt(this.length*8),s),this.process(n,0);const a=(0,Fn.createView)(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=c/4,l=this.get();if(f>l.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<f;h++)a.setUint32(4*h,l[h],s)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:r,buffer:n,length:i,finished:s,destroyed:o,pos:a}=this;return t.length=i,t.pos=a,t.finished=s,t.destroyed=o,i%r&&t.buffer.set(n),t}}Qt.HashMD=Tm;Object.defineProperty(mn,"__esModule",{value:!0});mn.ripemd160=mn.RIPEMD160=void 0;const km=Qt,Kn=$i,Im=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Rd=new Uint8Array(new Array(16).fill(0).map((e,t)=>t)),Bm=Rd.map(e=>(9*e+5)%16);let cc=[Rd],uc=[Bm];for(let e=0;e<4;e++)for(let t of[cc,uc])t.push(t[e].map(r=>Im[r]));const Fd=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(e=>new Uint8Array(e)),Cm=cc.map((e,t)=>e.map(r=>Fd[t][r])),Om=uc.map((e,t)=>e.map(r=>Fd[t][r])),Rm=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),Fm=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function su(e,t,r,n){return e===0?t^r^n:e===1?t&r|~t&n:e===2?(t|~r)^n:e===3?t&n|r&~n:t^(r|~n)}const es=new Uint32Array(16);let Ud=class extends km.HashMD{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:r,h2:n,h3:i,h4:s}=this;return[t,r,n,i,s]}set(t,r,n,i,s){this.h0=t|0,this.h1=r|0,this.h2=n|0,this.h3=i|0,this.h4=s|0}process(t,r){for(let p=0;p<16;p++,r+=4)es[p]=t.getUint32(r,!0);let n=this.h0|0,i=n,s=this.h1|0,o=s,a=this.h2|0,c=a,f=this.h3|0,l=f,h=this.h4|0,y=h;for(let p=0;p<5;p++){const g=4-p,_=Rm[p],x=Fm[p],k=cc[p],T=uc[p],A=Cm[p],E=Om[p];for(let I=0;I<16;I++){const S=(0,Kn.rotl)(n+su(p,s,a,f)+es[k[I]]+_,A[I])+h|0;n=h,h=f,f=(0,Kn.rotl)(a,10)|0,a=s,s=S}for(let I=0;I<16;I++){const S=(0,Kn.rotl)(i+su(g,o,c,l)+es[T[I]]+x,E[I])+y|0;i=y,y=l,l=(0,Kn.rotl)(c,10)|0,c=o,o=S}}this.set(this.h1+a+l|0,this.h2+f+y|0,this.h3+h+i|0,this.h4+n+o|0,this.h0+s+c|0)}roundClean(){es.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}};mn.RIPEMD160=Ud;mn.ripemd160=(0,Kn.wrapConstructor)(()=>new Ud);var Gt={};Object.defineProperty(Gt,"__esModule",{value:!0});Gt.sha224=Gt.sha256=Gt.SHA256=void 0;const ko=Qt,lt=$i,Um=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]),ir=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),sr=new Uint32Array(64);class fc extends ko.HashMD{constructor(){super(64,32,8,!1),this.A=ir[0]|0,this.B=ir[1]|0,this.C=ir[2]|0,this.D=ir[3]|0,this.E=ir[4]|0,this.F=ir[5]|0,this.G=ir[6]|0,this.H=ir[7]|0}get(){const{A:t,B:r,C:n,D:i,E:s,F:o,G:a,H:c}=this;return[t,r,n,i,s,o,a,c]}set(t,r,n,i,s,o,a,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=s|0,this.F=o|0,this.G=a|0,this.H=c|0}process(t,r){for(let h=0;h<16;h++,r+=4)sr[h]=t.getUint32(r,!1);for(let h=16;h<64;h++){const y=sr[h-15],p=sr[h-2],g=(0,lt.rotr)(y,7)^(0,lt.rotr)(y,18)^y>>>3,_=(0,lt.rotr)(p,17)^(0,lt.rotr)(p,19)^p>>>10;sr[h]=_+sr[h-7]+g+sr[h-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:c,G:f,H:l}=this;for(let h=0;h<64;h++){const y=(0,lt.rotr)(a,6)^(0,lt.rotr)(a,11)^(0,lt.rotr)(a,25),p=l+y+(0,ko.Chi)(a,c,f)+Um[h]+sr[h]|0,_=((0,lt.rotr)(n,2)^(0,lt.rotr)(n,13)^(0,lt.rotr)(n,22))+(0,ko.Maj)(n,i,s)|0;l=f,f=c,c=a,a=o+p|0,o=s,s=i,i=n,n=p+_|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,l=l+this.H|0,this.set(n,i,s,o,a,c,f,l)}roundClean(){sr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}Gt.SHA256=fc;class Nm extends fc{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}Gt.sha256=(0,lt.wrapConstructor)(()=>new fc);Gt.sha224=(0,lt.wrapConstructor)(()=>new Nm);async function Lm(e,{chain:t}){const{id:r,name:n,nativeCurrency:i,rpcUrls:s,blockExplorers:o}=t;await e.request({method:"wallet_addEthereumChain",params:[{chainId:Q(r),chainName:n,nativeCurrency:i,rpcUrls:s.default.http,blockExplorerUrls:o?Object.values(o).map(({url:a})=>a):void 0}]},{dedupe:!0,retryCount:0})}function Mm(e,t){const{abi:r,args:n,bytecode:i,...s}=t,o=ic({abi:r,args:n,bytecode:i});return oc(e,{...s,...s.authorizationList?{to:null}:{},data:o})}async function $m(e){var r;return((r=e.account)==null?void 0:r.type)==="local"?[e.account.address]:(await e.request({method:"eth_accounts"},{dedupe:!0})).map(n=>Ri(n))}async function Hm(e,t={}){const{account:r=e.account,chainId:n}=t,i=r?Ne(r):void 0,s=await e.request({method:"wallet_getCapabilities",params:[i==null?void 0:i.address]}),o={};for(const[a,c]of Object.entries(s))o[Number(a)]=c;return typeof n=="number"?o[n]:o}async function Dm(e){return await e.request({method:"wallet_getPermissions"},{dedupe:!0})}async function Nd(e,t){var c;const{account:r=e.account,chainId:n,nonce:i}=t;if(!r)throw new wr({docsPath:"/docs/eip7702/prepareAuthorization"});const s=Ne(r),o=(()=>{if(t.executor)return t.executor==="self"?t.executor:Ne(t.executor)})(),a={address:t.contractAddress??t.address,chainId:n,nonce:i};return typeof a.chainId>"u"&&(a.chainId=((c=e.chain)==null?void 0:c.id)??await oe(e,Li,"getChainId")({})),typeof a.nonce>"u"&&(a.nonce=await oe(e,sd,"getTransactionCount")({address:s.address,blockTag:"pending"}),(o==="self"||o!=null&&o.address&&rc(o.address,s.address))&&(a.nonce+=1)),a}async function jm(e){return(await e.request({method:"eth_requestAccounts"},{dedupe:!0,retryCount:0})).map(r=>j0(r))}async function Gm(e,t){return e.request({method:"wallet_requestPermissions",params:[t]},{retryCount:0})}async function zm(e,t){const{account:r=e.account,capabilities:n,chain:i=e.chain,forceAtomic:s=!1,id:o,version:a="2.0.0"}=t;if(typeof r>"u")throw new wr({docsPath:"/experimental/eip5792/sendCalls"});const c=r?Ne(r):null,f=t.calls.map(l=>{const h=l;return{data:h.abi?Tn({abi:h.abi,functionName:h.functionName,args:h.args}):h.data,to:h.to,value:h.value?Q(h.value):void 0}});try{const l=await e.request({method:"wallet_sendCalls",params:[{atomicRequired:s,calls:f,capabilities:n,chainId:Q(i.id),from:c==null?void 0:c.address,id:o,version:a}]},{retryCount:0});return typeof l=="string"?{id:l}:l}catch(l){throw Ad(l,{...t,account:c,chain:t.chain})}}async function qm(e,t){const{id:r}=t;await e.request({method:"wallet_showCallsStatus",params:[r]})}async function Vm(e,t){const{account:r=e.account}=t;if(!r)throw new wr({docsPath:"/docs/eip7702/signAuthorization"});const n=Ne(r);if(!n.signAuthorization)throw new ls({docsPath:"/docs/eip7702/signAuthorization",metaMessages:["The `signAuthorization` Action does not support JSON-RPC Accounts."],type:n.type});const i=await Nd(e,t);return n.signAuthorization(i)}async function Wm(e,{account:t=e.account,message:r}){if(!t)throw new wr({docsPath:"/docs/actions/wallet/signMessage"});const n=Ne(t);if(n.signMessage)return n.signMessage({message:r});const i=typeof r=="string"?Os(r):r.raw instanceof Uint8Array?J(r.raw):r.raw;return e.request({method:"personal_sign",params:[i,n.address]},{retryCount:0})}async function Km(e,t){var f,l,h,y;const{account:r=e.account,chain:n=e.chain,...i}=t;if(!r)throw new wr({docsPath:"/docs/actions/wallet/signTransaction"});const s=Ne(r);Ni({account:s,...t});const o=await oe(e,Li,"getChainId")({});n!==null&&xd({currentChainId:o,chain:n});const a=(n==null?void 0:n.formatters)||((f=e.chain)==null?void 0:f.formatters),c=((l=a==null?void 0:a.transactionRequest)==null?void 0:l.format)||Ds;return s.signTransaction?s.signTransaction({...i,chainId:o},{serializer:(y=(h=e.chain)==null?void 0:h.serializers)==null?void 0:y.transaction}):await e.request({method:"eth_signTransaction",params:[{...c(i),chainId:Q(o),from:s.address}]},{retryCount:0})}async function Ym(e,t){const{account:r=e.account,domain:n,message:i,primaryType:s}=t;if(!r)throw new wr({docsPath:"/docs/actions/wallet/signTypedData"});const o=Ne(r),a={EIP712Domain:om({domain:n}),...t.types};if(sm({domain:n,message:i,primaryType:s,types:a}),o.signTypedData)return o.signTypedData({domain:n,message:i,primaryType:s,types:a});const c=im({domain:n,message:i,primaryType:s,types:a});return e.request({method:"eth_signTypedData_v4",params:[o.address,c]},{retryCount:0})}async function Xm(e,{id:t}){await e.request({method:"wallet_switchEthereumChain",params:[{chainId:Q(t)}]},{retryCount:0})}async function Jm(e,t){return await e.request({method:"wallet_watchAsset",params:t},{retryCount:0})}function Qm(e){return{addChain:t=>Lm(e,t),deployContract:t=>Mm(e,t),getAddresses:()=>$m(e),getCallsStatus:t=>kd(e,t),getCapabilities:()=>Hm(e),getChainId:()=>Li(e),getPermissions:()=>Dm(e),prepareAuthorization:t=>Nd(e,t),prepareTransactionRequest:t=>tc(e,t),requestAddresses:()=>jm(e),requestPermissions:t=>Gm(e,t),sendCalls:t=>zm(e,t),sendRawTransaction:t=>Sd(e,t),sendTransaction:t=>oc(e,t),showCallsStatus:t=>qm(e,t),signAuthorization:t=>Vm(e,t),signMessage:t=>Wm(e,t),signTransaction:t=>Km(e,t),signTypedData:t=>Ym(e,t),switchChain:t=>Xm(e,t),waitForCallsStatus:t=>Gy(e,t),watchAsset:t=>Jm(e,t),writeContract:t=>Pd(e,t)}}function Io(e){const{key:t="wallet",name:r="Wallet Client",transport:n}=e;return qy({...e,key:t,name:r,transport:n,type:"walletClient"}).extend(Qm)}const hs={mainnet:{orderbook:"https://api.garden.finance",auth:"https://api.garden.finance/auth",quote:"https://api.garden.finance/quote",info:"https://api.garden.finance/info",evmRelay:"https://api.garden.finance/relayer",starknetRelay:"https://api.garden.finance/starknet"},testnet:{orderbook:"https://testnet.api.garden.finance",auth:"https://testnet.api.garden.finance/auth",quote:"https://testnet.api.garden.finance/quote",info:"https://testnet.api.garden.finance/info",evmRelay:"https://testnet.api.garden.finance/relayer",starknetRelay:"https://testnet.api.garden.finance/starknet"},localnet:{orderbook:"",auth:"",quote:"",info:"",evmRelay:"",starknetRelay:""}},Si={[q.Network.MAINNET]:{chainId:"0x534e5f4d41494e",nodeUrl:"https://starknet-mainnet.public.blastapi.io/rpc/v0_8"},[q.Network.TESTNET]:{chainId:"0x534e5f5345504f4c4941",nodeUrl:"https://starknet-sepolia.public.blastapi.io/rpc/v0_8"}},ou={chain:le.SupportedAssets.mainnet.base_cbBTC.chain,asset:le.SupportedAssets.mainnet.base_cbBTC.atomicSwapAddress};function au(e){const t=typeof e=="string"?e:e.environment,r=t===q.Environment.MAINNET?hs.mainnet:q.Environment.TESTNET?hs.testnet:hs.localnet;return{api:typeof e=="string"?r:{...r,...e},environment:t}}function _a(e){return typeof e=="string"&&(e=Buffer.from(e,"hex")),e.length===32?e:e.subarray(1,33)}function Pr(e,t){if(!e)throw new Error(t)}function Zm(e){return Buffer.concat([Uint8Array.from([192]),eb(e)])}function eb(e){const t=Ic.encodingLength(e.length),r=Buffer.allocUnsafe(t);return Ic.encode(e.length,r),Buffer.concat([r,e])}function tb(e,t){if(e.compare(t)>0){const r=e;e=t,t=r}return[e,t]}const fr=e=>e.length===64?e:e.slice(2),rb=e=>{if(!e)return!1;try{const t=Buffer.from(e,"hex");return Or.isPoint(t)}catch{return!1}},va=(e,t,r,n)=>e+":"+t.toLowerCase()+"::"+r+":"+n.toLowerCase();function nb(e,t){if(!e)return!1;const r=t===q.Environment.MAINNET?ce.networks.bitcoin:t===q.Environment.TESTNET?ce.networks.testnet:ce.networks.regtest;if(!r)return!1;ce.initEccLib(Or);try{return ce.address.toOutputScript(e,r),!0}catch{return!1}}const ib=e=>{switch(e){case q.Environment.MAINNET:return ln.BitcoinNetwork.Mainnet;case q.Environment.TESTNET:return ln.BitcoinNetwork.Testnet;default:throw new Error(`Invalid bitcoin network ${e}`)}},sb=e=>{const t=e.toLowerCase().replace("0x","");return/^[0-9a-f]+$/.test(t)},ob=e=>{if(typeof e=="object"&&"r"in e&&"s"in e)return q.Ok([e.r.toString(),e.s.toString()]);if(Array.isArray(e)){const t=e.map(r=>typeof r=="string"&&r.startsWith("0x")&&sb(r)?BigInt(r).toString():r);return q.Ok(t)}return q.Err("Invalid signature format")};var we=(e=>(e.Created="Created",e.Matched="Matched",e.InitiateDetected="InitiateDetected",e.Initiated="Initiated",e.CounterPartyInitiateDetected="CounterPartyInitiateDetected",e.CounterPartyInitiated="CounterPartyInitiated",e.RedeemDetected="RedeemDetected",e.Redeemed="Redeemed",e.CounterPartyRedeemDetected="CounterPartyRedeemDetected",e.CounterPartyRedeemed="CounterPartyRedeemed",e.Completed="Completed",e.CounterPartySwapExpired="CounterPartySwapExpired",e.Expired="Expired",e.RefundDetected="RefundDetected",e.Refunded="Refunded",e.CounterPartyRefundDetected="CounterPartyRefundDetected",e.CounterPartyRefunded="CounterPartyRefunded",e.Cancelled="Cancelled",e.DeadLineExceeded="DeadLineExceeded",e))(we||{}),xe=(e=>(e.Idle="Idle",e.InitiateDetected="InitiateDetected",e.Initiated="Initiated",e.RedeemDetected="RedeemDetected",e.Redeemed="Redeemed",e.RefundDetected="RefundDetected",e.Refunded="Refunded",e.Expired="Expired",e))(xe||{});const dc=(e,t,r)=>{const n=Ea(e.source_swap,t),i=Ea(e.destination_swap,r);if(i===xe.RedeemDetected)return we.RedeemDetected;if(i===xe.Redeemed)return we.Redeemed;if(n===xe.Refunded)return we.Refunded;if(n===xe.RefundDetected)return we.RefundDetected;if(i===xe.Expired)return we.CounterPartySwapExpired;if(n===xe.Expired)return we.Expired;if(i===xe.Refunded)return we.CounterPartyRefunded;if(i===xe.RefundDetected)return we.CounterPartyRefundDetected;const s=Number(e.create_order.additional_data.deadline);return i===xe.Initiated?we.CounterPartyInitiated:i===xe.InitiateDetected?we.CounterPartyInitiateDetected:Pi(s,12)?we.DeadLineExceeded:n===xe.Initiated?we.Initiated:Pi(s,1)?we.DeadLineExceeded:n===xe.InitiateDetected?we.InitiateDetected:n===xe.Redeemed?we.CounterPartyRedeemed:n===xe.RedeemDetected?we.CounterPartyRedeemDetected:we.Matched},Ea=(e,t)=>{if(e.redeem_tx_hash)return Number(e.redeem_block_number)?xe.Redeemed:xe.RedeemDetected;if(e.refund_tx_hash)return Number(e.refund_block_number)?xe.Refunded:xe.RefundDetected;if(Number(e.initiate_block_number)){const r=Number(e.initiate_block_number)+e.timelock;if(t>r)return xe.Expired}return e.initiate_tx_hash?Number(e.initiate_block_number)?xe.Initiated:xe.InitiateDetected:xe.Idle},ab=(e,t,r)=>{const n=dc(e,t,r);return lc(n)},lc=e=>{switch(e){case we.Matched:return Ce.Initiate;case we.CounterPartyInitiated:case we.CounterPartyInitiateDetected:case we.RedeemDetected:return Ce.Redeem;case we.Expired:return Ce.Refund;default:return Ce.Idle}},Pi=(e,t=0)=>{const r=Date.now(),n=e*1e3+t*36e5;return r>=n},cb=e=>e.filter(t=>!Ld(t)),Ld=e=>{const{source_swap:t,create_order:r}=e,{initiate_tx_hash:n,initiate_block_number:i}=t,{deadline:s}=r.additional_data;return n&&Number(i)?!1:n&&!Number(i)?Pi(Number(s),12):n?!1:Pi(Number(s),1)},ub=Buffer.from("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","hex"),fb=Buffer.from("483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8","hex"),db=Buffer.concat([ub,fb]),lb=Buffer.from("0250929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0","hex"),cu={failedToCreateInternalPubkey:"failed to create internal pubkey"};function hb(){const e=af.crypto.sha256(Buffer.from("GardenHTLC","utf-8")),t=Or.pointMultiply(Buffer.concat([Buffer.from("04","hex"),db]),e);if(!t)throw new Error(cu.failedToCreateInternalPubkey);const r=Or.pointAdd(lb,t);if(!r)throw new Error(cu.failedToCreateInternalPubkey);return _a(Buffer.from(r))}var Ae={},Ve={},Zt={},Vs={};Vs.byteLength=mb;Vs.toByteArray=gb;Vs.fromByteArray=vb;var It=[],ht=[],pb=typeof Uint8Array<"u"?Uint8Array:Array,Bo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var Yr=0,yb=Bo.length;Yr<yb;++Yr)It[Yr]=Bo[Yr],ht[Bo.charCodeAt(Yr)]=Yr;ht[45]=62;ht[95]=63;function Md(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function mb(e){var t=Md(e),r=t[0],n=t[1];return(r+n)*3/4-n}function bb(e,t,r){return(t+r)*3/4-r}function gb(e){var t,r=Md(e),n=r[0],i=r[1],s=new pb(bb(e,n,i)),o=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)t=ht[e.charCodeAt(c)]<<18|ht[e.charCodeAt(c+1)]<<12|ht[e.charCodeAt(c+2)]<<6|ht[e.charCodeAt(c+3)],s[o++]=t>>16&255,s[o++]=t>>8&255,s[o++]=t&255;return i===2&&(t=ht[e.charCodeAt(c)]<<2|ht[e.charCodeAt(c+1)]>>4,s[o++]=t&255),i===1&&(t=ht[e.charCodeAt(c)]<<10|ht[e.charCodeAt(c+1)]<<4|ht[e.charCodeAt(c+2)]>>2,s[o++]=t>>8&255,s[o++]=t&255),s}function wb(e){return It[e>>18&63]+It[e>>12&63]+It[e>>6&63]+It[e&63]}function _b(e,t,r){for(var n,i=[],s=t;s<r;s+=3)n=(e[s]<<16&16711680)+(e[s+1]<<8&65280)+(e[s+2]&255),i.push(wb(n));return i.join("")}function vb(e){for(var t,r=e.length,n=r%3,i=[],s=16383,o=0,a=r-n;o<a;o+=s)i.push(_b(e,o,o+s>a?a:o+s));return n===1?(t=e[r-1],i.push(It[t>>2]+It[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(It[t>>10]+It[t>>4&63]+It[t<<2&63]+"=")),i.join("")}var hc={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */hc.read=function(e,t,r,n,i){var s,o,a=i*8-n-1,c=(1<<a)-1,f=c>>1,l=-7,h=r?i-1:0,y=r?-1:1,p=e[t+h];for(h+=y,s=p&(1<<-l)-1,p>>=-l,l+=a;l>0;s=s*256+e[t+h],h+=y,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=n;l>0;o=o*256+e[t+h],h+=y,l-=8);if(s===0)s=1-f;else{if(s===c)return o?NaN:(p?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-f}return(p?-1:1)*o*Math.pow(2,s-n)};hc.write=function(e,t,r,n,i,s){var o,a,c,f=s*8-i-1,l=(1<<f)-1,h=l>>1,y=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:s-1,g=n?1:-1,_=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=l):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+h>=1?t+=y/c:t+=y*Math.pow(2,1-h),t*c>=2&&(o++,c/=2),o+h>=l?(a=0,o=l):o+h>=1?(a=(t*c-1)*Math.pow(2,i),o=o+h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;e[r+p]=a&255,p+=g,a/=256,i-=8);for(o=o<<i|a,f+=i;f>0;e[r+p]=o&255,p+=g,o/=256,f-=8);e[r+p-g]|=_*128};/*!
42
42
  * The buffer module from node.js, for the browser.
43
43
  *
@@ -68,4 +68,4 @@ ${vp(p)}`),super(t.shortMessage,{cause:t,docsPath:n,metaMessages:[...t.metaMessa
68
68
  `.trim().replace(/\s+/g," "))}leaves(){return[{version:os,output:this.redeemLeaf()},[{version:os,output:this.refundLeaf()},{version:os,output:this.instantRefundLeaf()}]]}generateMerkleProofFor(t){const r=this.leafHash(1),n=this.leafHash(2),i=this.leafHash(0);switch(t){case 1:{const s=tb(i,n);return[ce.crypto.taggedHash("TapBranch",Buffer.concat(s))]}case 0:return[n,r];case 2:return[i,r];default:throw new Error(Le.invalidLeaf)}}}function Jr(e,t){const r=[];for(let n=0;n<t;n++)r.push(e);return r}class r1{constructor(){this.cache={}}set(t,r,n,i){const s={txHash:n,timeStamp:Date.now(),btcRedeemUTXO:i};this.cache[`${r}_${t.create_order.create_id}`]=s}get(t,r){return this.cache[`${r}_${t.create_order.create_id}`]||null}remove(t,r){delete this.cache[`${r}_${t.create_order.create_id}`]}}class n1{constructor(){this.cache={}}set(t,r){this.cache[t]=r}get(t){return this.cache[t]||null}}class il{constructor(t,r){this.url=new q.Url(t).endpoint("blocknumbers").endpoint(r)}async fetchBlockNumbers(){try{const t=await Dt.get(this.url);return ie(t)}catch(t){return G("Failed to fetch block numbers",t)}}}class sl{constructor(t){this.quoteUrl=new q.Url(t)}async getQuoteFromAssets(t,r,n,i=!1,s){const o=va(t.chain,t.atomicSwapAddress,r.chain,r.atomicSwapAddress);return this.getQuote(o,n,i,s)}async getQuote(t,r,n=!1,i){try{const s={order_pair:t,amount:r.toString(),exact_out:n.toString(),...(i==null?void 0:i.affiliateFee)!==void 0&&{affiliate_fee:i.affiliateFee.toString()}},o=this.quoteUrl.endpoint("/").addSearchParams(s),a=await Dt.get(o,{retryCount:0,...i==null?void 0:i.request});return a.error?G(a.error):a.result?ie(a.result):G("GetQuote: Unexpected error, result is undefined")}catch(s){return G("GetQuote:",String(s))}}async getAttestedQuote(t){try{const r=await Dt.post(this.quoteUrl.endpoint("/attested").toString(),{body:JSON.stringify(t),headers:{"Content-Type":"application/json"}});return r.error?G(r.error):r.result?ie(r.result):G("GetAttestedQuote: Unexpected error, result is undefined")}catch(r){return console.log("error :",r),G("GetAttestedQuote:",String(r))}}async getStrategies(){try{const t=await Dt.get(this.quoteUrl.endpoint("/strategies"));if(t.error)return G(t.error);if(!t.result)return G("GetStrategies: Unexpected error, result is undefined");const r={};for(const n of Object.values(t.result)){const i=va(n.source_chain,n.source_asset.asset,n.dest_chain,n.dest_asset.asset);r[i]={id:n.id,minAmount:n.min_amount,maxAmount:n.max_amount,fee:n.fee}}return ie(r)}catch(t){return G("GetStrategies:",String(t))}}}var ol={},wn={},_n={};Object.defineProperty(_n,"__esModule",{value:!0});_n.testnet=_n.bitcoin=void 0;_n.bitcoin={messagePrefix:`Bitcoin Signed Message:
69
69
  `,bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128};_n.testnet={messagePrefix:`Bitcoin Signed Message:
70
70
  `,bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};var al={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.maybe=e.Boolean=e.Array=e.Buffer256bit=e.Network=e.typeforce=void 0,e.typeforce=zd,e.Network=e.typeforce.compile({messagePrefix:e.typeforce.oneOf(e.typeforce.Buffer,e.typeforce.String),bip32:{public:e.typeforce.UInt32,private:e.typeforce.UInt32},pubKeyHash:e.typeforce.UInt8,scriptHash:e.typeforce.UInt8,wif:e.typeforce.UInt8}),e.Buffer256bit=e.typeforce.BufferN(32),e.Array=e.typeforce.Array,e.Boolean=e.typeforce.Boolean,e.maybe=e.typeforce.maybe})(al);var Pa={exports:{}},Ta={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(e,t){var r=Zt,n=r.Buffer;function i(o,a){for(var c in o)a[c]=o[c]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(i(r,t),t.Buffer=s);function s(o,a,c){return n(o,a,c)}s.prototype=Object.create(n.prototype),i(n,s),s.from=function(o,a,c){if(typeof o=="number")throw new TypeError("Argument must not be a number");return n(o,a,c)},s.alloc=function(o,a,c){if(typeof o!="number")throw new TypeError("Argument must be a number");var f=n(o);return a!==void 0?typeof c=="string"?f.fill(a,c):f.fill(a):f.fill(0),f},s.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return n(o)},s.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(o)}})(Ta,Ta.exports);var tt=Ta.exports,jo=65536,i1=4294967295;function s1(){throw new Error(`Secure random number generation is not supported by this browser.
71
- Use Chrome, Firefox or Internet Explorer 11`)}var o1=tt.Buffer,Ts=br.crypto||br.msCrypto;Ts&&Ts.getRandomValues?Pa.exports=a1:Pa.exports=s1;function a1(e,t){if(e>i1)throw new RangeError("requested too many random bytes");var r=o1.allocUnsafe(e);if(e>0)if(e>jo)for(var n=0;n<e;n+=jo)Ts.getRandomValues(r.slice(n,n+jo));else Ts.getRandomValues(r);return typeof t=="function"?process.nextTick(function(){t(null,r)}):r}var c1=Pa.exports,ka={exports:{}};typeof Object.create=="function"?ka.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:ka.exports=function(t,r){if(r){t.super_=r;var n=function(){};n.prototype=r.prototype,t.prototype=new n,t.prototype.constructor=t}};var He=ka.exports,Ia={exports:{}},Ac={exports:{}},dn=typeof Reflect=="object"?Reflect:null,Cu=dn&&typeof dn.apply=="function"?dn.apply:function(t,r,n){return Function.prototype.apply.call(t,r,n)},_s;dn&&typeof dn.ownKeys=="function"?_s=dn.ownKeys:Object.getOwnPropertySymbols?_s=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:_s=function(t){return Object.getOwnPropertyNames(t)};function u1(e){console&&console.warn&&console.warn(e)}var cl=Number.isNaN||function(t){return t!==t};function ue(){ue.init.call(this)}Ac.exports=ue;Ac.exports.once=h1;ue.EventEmitter=ue;ue.prototype._events=void 0;ue.prototype._eventsCount=0;ue.prototype._maxListeners=void 0;var Ou=10;function to(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(ue,"defaultMaxListeners",{enumerable:!0,get:function(){return Ou},set:function(e){if(typeof e!="number"||e<0||cl(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");Ou=e}});ue.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};ue.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||cl(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function ul(e){return e._maxListeners===void 0?ue.defaultMaxListeners:e._maxListeners}ue.prototype.getMaxListeners=function(){return ul(this)};ue.prototype.emit=function(t){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=t==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){var o;if(r.length>0&&(o=r[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=s[t];if(c===void 0)return!1;if(typeof c=="function")Cu(c,this,r);else for(var f=c.length,l=pl(c,f),n=0;n<f;++n)Cu(l[n],this,r);return!0};function fl(e,t,r,n){var i,s,o;if(to(r),s=e._events,s===void 0?(s=e._events=Object.create(null),e._eventsCount=0):(s.newListener!==void 0&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]),o===void 0)o=s[t]=r,++e._eventsCount;else if(typeof o=="function"?o=s[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),i=ul(e),i>0&&o.length>i&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=o.length,u1(a)}return e}ue.prototype.addListener=function(t,r){return fl(this,t,r,!1)};ue.prototype.on=ue.prototype.addListener;ue.prototype.prependListener=function(t,r){return fl(this,t,r,!0)};function f1(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function dl(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=f1.bind(n);return i.listener=r,n.wrapFn=i,i}ue.prototype.once=function(t,r){return to(r),this.on(t,dl(this,t,r)),this};ue.prototype.prependOnceListener=function(t,r){return to(r),this.prependListener(t,dl(this,t,r)),this};ue.prototype.removeListener=function(t,r){var n,i,s,o,a;if(to(r),i=this._events,i===void 0)return this;if(n=i[t],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,n.listener||r));else if(typeof n!="function"){for(s=-1,o=n.length-1;o>=0;o--)if(n[o]===r||n[o].listener===r){a=n[o].listener,s=o;break}if(s<0)return this;s===0?n.shift():d1(n,s),n.length===1&&(i[t]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",t,a||r)}return this};ue.prototype.off=ue.prototype.removeListener;ue.prototype.removeAllListeners=function(t){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[t]),this;if(arguments.length===0){var s=Object.keys(n),o;for(i=0;i<s.length;++i)o=s[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[t],typeof r=="function")this.removeListener(t,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(t,r[i]);return this};function ll(e,t,r){var n=e._events;if(n===void 0)return[];var i=n[t];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?l1(i):pl(i,i.length)}ue.prototype.listeners=function(t){return ll(this,t,!0)};ue.prototype.rawListeners=function(t){return ll(this,t,!1)};ue.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):hl.call(e,t)};ue.prototype.listenerCount=hl;function hl(e){var t=this._events;if(t!==void 0){var r=t[e];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}ue.prototype.eventNames=function(){return this._eventsCount>0?_s(this._events):[]};function pl(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function d1(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function l1(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}function h1(e,t){return new Promise(function(r,n){function i(o){e.removeListener(t,s),n(o)}function s(){typeof e.removeListener=="function"&&e.removeListener("error",i),r([].slice.call(arguments))}yl(e,t,s,{once:!0}),t!=="error"&&p1(e,i,{once:!0})})}function p1(e,t,r){typeof e.on=="function"&&yl(e,"error",t,r)}function yl(e,t,r,n){if(typeof e.on=="function")n.once?e.once(t,r):e.on(t,r);else if(typeof e.addEventListener=="function")e.addEventListener(t,function i(s){n.once&&e.removeEventListener(t,i),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}var ml=Ac.exports,bl=ml.EventEmitter;const y1={},m1=Object.freeze(Object.defineProperty({__proto__:null,default:y1},Symbol.toStringTag,{value:"Module"})),Sc=_m(m1);var Go,Ru;function b1(){if(Ru)return Go;Ru=1;function e(g,_){var x=Object.keys(g);if(Object.getOwnPropertySymbols){var k=Object.getOwnPropertySymbols(g);_&&(k=k.filter(function(T){return Object.getOwnPropertyDescriptor(g,T).enumerable})),x.push.apply(x,k)}return x}function t(g){for(var _=1;_<arguments.length;_++){var x=arguments[_]!=null?arguments[_]:{};_%2?e(Object(x),!0).forEach(function(k){r(g,k,x[k])}):Object.getOwnPropertyDescriptors?Object.defineProperties(g,Object.getOwnPropertyDescriptors(x)):e(Object(x)).forEach(function(k){Object.defineProperty(g,k,Object.getOwnPropertyDescriptor(x,k))})}return g}function r(g,_,x){return _=o(_),_ in g?Object.defineProperty(g,_,{value:x,enumerable:!0,configurable:!0,writable:!0}):g[_]=x,g}function n(g,_){if(!(g instanceof _))throw new TypeError("Cannot call a class as a function")}function i(g,_){for(var x=0;x<_.length;x++){var k=_[x];k.enumerable=k.enumerable||!1,k.configurable=!0,"value"in k&&(k.writable=!0),Object.defineProperty(g,o(k.key),k)}}function s(g,_,x){return _&&i(g.prototype,_),Object.defineProperty(g,"prototype",{writable:!1}),g}function o(g){var _=a(g,"string");return typeof _=="symbol"?_:String(_)}function a(g,_){if(typeof g!="object"||g===null)return g;var x=g[Symbol.toPrimitive];if(x!==void 0){var k=x.call(g,_);if(typeof k!="object")return k;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(g)}var c=Zt,f=c.Buffer,l=Sc,h=l.inspect,y=h&&h.custom||"inspect";function p(g,_,x){f.prototype.copy.call(g,_,x)}return Go=function(){function g(){n(this,g),this.head=null,this.tail=null,this.length=0}return s(g,[{key:"push",value:function(x){var k={data:x,next:null};this.length>0?this.tail.next=k:this.head=k,this.tail=k,++this.length}},{key:"unshift",value:function(x){var k={data:x,next:this.head};this.length===0&&(this.tail=k),this.head=k,++this.length}},{key:"shift",value:function(){if(this.length!==0){var x=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,x}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(x){if(this.length===0)return"";for(var k=this.head,T=""+k.data;k=k.next;)T+=x+k.data;return T}},{key:"concat",value:function(x){if(this.length===0)return f.alloc(0);for(var k=f.allocUnsafe(x>>>0),T=this.head,A=0;T;)p(T.data,k,A),A+=T.data.length,T=T.next;return k}},{key:"consume",value:function(x,k){var T;return x<this.head.data.length?(T=this.head.data.slice(0,x),this.head.data=this.head.data.slice(x)):x===this.head.data.length?T=this.shift():T=k?this._getString(x):this._getBuffer(x),T}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(x){var k=this.head,T=1,A=k.data;for(x-=A.length;k=k.next;){var E=k.data,I=x>E.length?E.length:x;if(I===E.length?A+=E:A+=E.slice(0,x),x-=I,x===0){I===E.length?(++T,k.next?this.head=k.next:this.head=this.tail=null):(this.head=k,k.data=E.slice(I));break}++T}return this.length-=T,A}},{key:"_getBuffer",value:function(x){var k=f.allocUnsafe(x),T=this.head,A=1;for(T.data.copy(k),x-=T.data.length;T=T.next;){var E=T.data,I=x>E.length?E.length:x;if(E.copy(k,k.length-x,0,I),x-=I,x===0){I===E.length?(++A,T.next?this.head=T.next:this.head=this.tail=null):(this.head=T,T.data=E.slice(I));break}++A}return this.length-=A,k}},{key:y,value:function(x,k){return h(this,t(t({},k),{},{depth:0,customInspect:!1}))}}]),g}(),Go}function g1(e,t){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(Ba,this,e)):process.nextTick(Ba,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(s){!t&&s?r._writableState?r._writableState.errorEmitted?process.nextTick(vs,r):(r._writableState.errorEmitted=!0,process.nextTick(Fu,r,s)):process.nextTick(Fu,r,s):t?(process.nextTick(vs,r),t(s)):process.nextTick(vs,r)}),this)}function Fu(e,t){Ba(e,t),vs(e)}function vs(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function w1(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function Ba(e,t){e.emit("error",t)}function _1(e,t){var r=e._readableState,n=e._writableState;r&&r.autoDestroy||n&&n.autoDestroy?e.destroy(t):e.emit("error",t)}var gl={destroy:g1,undestroy:w1,errorOrDestroy:_1},Gr={};function v1(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var wl={};function mt(e,t,r){r||(r=Error);function n(s,o,a){return typeof t=="string"?t:t(s,o,a)}var i=function(s){v1(o,s);function o(a,c,f){return s.call(this,n(a,c,f))||this}return o}(r);i.prototype.name=r.name,i.prototype.code=e,wl[e]=i}function Uu(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(n){return String(n)}),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:r===2?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}else return"of ".concat(t," ").concat(String(e))}function E1(e,t,r){return e.substr(0,t.length)===t}function x1(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function A1(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}mt("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError);mt("ERR_INVALID_ARG_TYPE",function(e,t,r){var n;typeof t=="string"&&E1(t,"not ")?(n="must not be",t=t.replace(/^not /,"")):n="must be";var i;if(x1(e," argument"))i="The ".concat(e," ").concat(n," ").concat(Uu(t,"type"));else{var s=A1(e,".")?"property":"argument";i='The "'.concat(e,'" ').concat(s," ").concat(n," ").concat(Uu(t,"type"))}return i+=". Received type ".concat(typeof r),i},TypeError);mt("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");mt("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"});mt("ERR_STREAM_PREMATURE_CLOSE","Premature close");mt("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"});mt("ERR_MULTIPLE_CALLBACK","Callback called multiple times");mt("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");mt("ERR_STREAM_WRITE_AFTER_END","write after end");mt("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);mt("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError);mt("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");Gr.codes=wl;var S1=Gr.codes.ERR_INVALID_OPT_VALUE;function P1(e,t,r){return e.highWaterMark!=null?e.highWaterMark:t?e[r]:null}function T1(e,t,r,n){var i=P1(t,n,r);if(i!=null){if(!(isFinite(i)&&Math.floor(i)===i)||i<0){var s=n?r:"highWaterMark";throw new S1(s,i)}return Math.floor(i)}return e.objectMode?16:16*1024}var _l={getHighWaterMark:T1},k1=I1;function I1(e,t){if(zo("noDeprecation"))return e;var r=!1;function n(){if(!r){if(zo("throwDeprecation"))throw new Error(t);zo("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}return n}function zo(e){try{if(!br.localStorage)return!1}catch{return!1}var t=br.localStorage[e];return t==null?!1:String(t).toLowerCase()==="true"}var qo,Nu;function vl(){if(Nu)return qo;Nu=1,qo=$;function e(O){var C=this;this.next=null,this.entry=null,this.finish=function(){Rt(C,O)}}var t;$.WritableState=S;var r={deprecate:k1},n=bl,i=Zt.Buffer,s=(typeof br<"u"?br:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function o(O){return i.from(O)}function a(O){return i.isBuffer(O)||O instanceof s}var c=gl,f=_l,l=f.getHighWaterMark,h=Gr.codes,y=h.ERR_INVALID_ARG_TYPE,p=h.ERR_METHOD_NOT_IMPLEMENTED,g=h.ERR_MULTIPLE_CALLBACK,_=h.ERR_STREAM_CANNOT_PIPE,x=h.ERR_STREAM_DESTROYED,k=h.ERR_STREAM_NULL_VALUES,T=h.ERR_STREAM_WRITE_AFTER_END,A=h.ERR_UNKNOWN_ENCODING,E=c.errorOrDestroy;He($,n);function I(){}function S(O,C,H){t=t||vn(),O=O||{},typeof H!="boolean"&&(H=C instanceof t),this.objectMode=!!O.objectMode,H&&(this.objectMode=this.objectMode||!!O.writableObjectMode),this.highWaterMark=l(this,O,"writableHighWaterMark",H),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var K=O.decodeStrings===!1;this.decodeStrings=!K,this.defaultEncoding=O.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(Z){ne(C,Z)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=O.emitClose!==!1,this.autoDestroy=!!O.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new e(this)}S.prototype.getBuffer=function(){for(var C=this.bufferedRequest,H=[];C;)H.push(C),C=C.next;return H},function(){try{Object.defineProperty(S.prototype,"buffer",{get:r.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}();var N;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(N=Function.prototype[Symbol.hasInstance],Object.defineProperty($,Symbol.hasInstance,{value:function(C){return N.call(this,C)?!0:this!==$?!1:C&&C._writableState instanceof S}})):N=function(C){return C instanceof this};function $(O){t=t||vn();var C=this instanceof t;if(!C&&!N.call($,this))return new $(O);this._writableState=new S(O,this,C),this.writable=!0,O&&(typeof O.write=="function"&&(this._write=O.write),typeof O.writev=="function"&&(this._writev=O.writev),typeof O.destroy=="function"&&(this._destroy=O.destroy),typeof O.final=="function"&&(this._final=O.final)),n.call(this)}$.prototype.pipe=function(){E(this,new _)};function B(O,C){var H=new T;E(O,H),process.nextTick(C,H)}function W(O,C,H,K){var Z;return H===null?Z=new k:typeof H!="string"&&!C.objectMode&&(Z=new y("chunk",["string","Buffer"],H)),Z?(E(O,Z),process.nextTick(K,Z),!1):!0}$.prototype.write=function(O,C,H){var K=this._writableState,Z=!1,w=!K.objectMode&&a(O);return w&&!i.isBuffer(O)&&(O=o(O)),typeof C=="function"&&(H=C,C=null),w?C="buffer":C||(C=K.defaultEncoding),typeof H!="function"&&(H=I),K.ending?B(this,H):(w||W(this,K,O,H))&&(K.pendingcb++,Z=D(this,K,w,O,C,H)),Z},$.prototype.cork=function(){this._writableState.corked++},$.prototype.uncork=function(){var O=this._writableState;O.corked&&(O.corked--,!O.writing&&!O.corked&&!O.bufferProcessing&&O.bufferedRequest&&Te(this,O))},$.prototype.setDefaultEncoding=function(C){if(typeof C=="string"&&(C=C.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((C+"").toLowerCase())>-1))throw new A(C);return this._writableState.defaultEncoding=C,this},Object.defineProperty($.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function R(O,C,H){return!O.objectMode&&O.decodeStrings!==!1&&typeof C=="string"&&(C=i.from(C,H)),C}Object.defineProperty($.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function D(O,C,H,K,Z,w){if(!H){var v=R(C,K,Z);K!==v&&(H=!0,Z="buffer",K=v)}var M=C.objectMode?1:K.length;C.length+=M;var z=C.length<C.highWaterMark;if(z||(C.needDrain=!0),C.writing||C.corked){var ve=C.lastBufferedRequest;C.lastBufferedRequest={chunk:K,encoding:Z,isBuf:H,callback:w,next:null},ve?ve.next=C.lastBufferedRequest:C.bufferedRequest=C.lastBufferedRequest,C.bufferedRequestCount+=1}else j(O,C,!1,M,K,Z,w);return z}function j(O,C,H,K,Z,w,v){C.writelen=K,C.writecb=v,C.writing=!0,C.sync=!0,C.destroyed?C.onwrite(new x("write")):H?O._writev(Z,C.onwrite):O._write(Z,w,C.onwrite),C.sync=!1}function V(O,C,H,K,Z){--C.pendingcb,H?(process.nextTick(Z,K),process.nextTick(st,O,C),O._writableState.errorEmitted=!0,E(O,K)):(Z(K),O._writableState.errorEmitted=!0,E(O,K),st(O,C))}function X(O){O.writing=!1,O.writecb=null,O.length-=O.writelen,O.writelen=0}function ne(O,C){var H=O._writableState,K=H.sync,Z=H.writecb;if(typeof Z!="function")throw new g;if(X(H),C)V(O,H,K,C,Z);else{var w=We(H)||O.destroyed;!w&&!H.corked&&!H.bufferProcessing&&H.bufferedRequest&&Te(O,H),K?process.nextTick(pe,O,H,w,Z):pe(O,H,w,Z)}}function pe(O,C,H,K){H||_e(O,C),C.pendingcb--,K(),st(O,C)}function _e(O,C){C.length===0&&C.needDrain&&(C.needDrain=!1,O.emit("drain"))}function Te(O,C){C.bufferProcessing=!0;var H=C.bufferedRequest;if(O._writev&&H&&H.next){var K=C.bufferedRequestCount,Z=new Array(K),w=C.corkedRequestsFree;w.entry=H;for(var v=0,M=!0;H;)Z[v]=H,H.isBuf||(M=!1),H=H.next,v+=1;Z.allBuffers=M,j(O,C,!0,C.length,Z,"",w.finish),C.pendingcb++,C.lastBufferedRequest=null,w.next?(C.corkedRequestsFree=w.next,w.next=null):C.corkedRequestsFree=new e(C),C.bufferedRequestCount=0}else{for(;H;){var z=H.chunk,ve=H.encoding,ee=H.callback,ae=C.objectMode?1:z.length;if(j(O,C,!1,ae,z,ve,ee),H=H.next,C.bufferedRequestCount--,C.writing)break}H===null&&(C.lastBufferedRequest=null)}C.bufferedRequest=H,C.bufferProcessing=!1}$.prototype._write=function(O,C,H){H(new p("_write()"))},$.prototype._writev=null,$.prototype.end=function(O,C,H){var K=this._writableState;return typeof O=="function"?(H=O,O=null,C=null):typeof C=="function"&&(H=C,C=null),O!=null&&this.write(O,C),K.corked&&(K.corked=1,this.uncork()),K.ending||er(this,K,H),this},Object.defineProperty($.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function We(O){return O.ending&&O.length===0&&O.bufferedRequest===null&&!O.finished&&!O.writing}function fe(O,C){O._final(function(H){C.pendingcb--,H&&E(O,H),C.prefinished=!0,O.emit("prefinish"),st(O,C)})}function me(O,C){!C.prefinished&&!C.finalCalled&&(typeof O._final=="function"&&!C.destroyed?(C.pendingcb++,C.finalCalled=!0,process.nextTick(fe,O,C)):(C.prefinished=!0,O.emit("prefinish")))}function st(O,C){var H=We(C);if(H&&(me(O,C),C.pendingcb===0&&(C.finished=!0,O.emit("finish"),C.autoDestroy))){var K=O._readableState;(!K||K.autoDestroy&&K.endEmitted)&&O.destroy()}return H}function er(O,C,H){C.ending=!0,st(O,C),H&&(C.finished?process.nextTick(H):O.once("finish",H)),C.ended=!0,O.writable=!1}function Rt(O,C,H){var K=O.entry;for(O.entry=null;K;){var Z=K.callback;C.pendingcb--,Z(H),K=K.next}C.corkedRequestsFree.next=O}return Object.defineProperty($.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(C){this._writableState&&(this._writableState.destroyed=C)}}),$.prototype.destroy=c.destroy,$.prototype._undestroy=c.undestroy,$.prototype._destroy=function(O,C){C(O)},qo}var Vo,Lu;function vn(){if(Lu)return Vo;Lu=1;var e=Object.keys||function(f){var l=[];for(var h in f)l.push(h);return l};Vo=o;var t=xl(),r=vl();He(o,t);for(var n=e(r.prototype),i=0;i<n.length;i++){var s=n[i];o.prototype[s]||(o.prototype[s]=r.prototype[s])}function o(f){if(!(this instanceof o))return new o(f);t.call(this,f),r.call(this,f),this.allowHalfOpen=!0,f&&(f.readable===!1&&(this.readable=!1),f.writable===!1&&(this.writable=!1),f.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",a)))}Object.defineProperty(o.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(o.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(o.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function a(){this._writableState.ended||process.nextTick(c,this)}function c(f){f.end()}return Object.defineProperty(o.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(l){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=l,this._writableState.destroyed=l)}}),Vo}var ks={},Pc=tt.Buffer,Mu=Pc.isEncoding||function(e){switch(e=""+e,e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function B1(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function C1(e){var t=B1(e);if(typeof t!="string"&&(Pc.isEncoding===Mu||!Mu(e)))throw new Error("Unknown encoding: "+e);return t||e}ks.StringDecoder=Gi;function Gi(e){this.encoding=C1(e);var t;switch(this.encoding){case"utf16le":this.text=L1,this.end=M1,t=4;break;case"utf8":this.fillLast=F1,t=4;break;case"base64":this.text=$1,this.end=H1,t=3;break;default:this.write=D1,this.end=j1;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Pc.allocUnsafe(t)}Gi.prototype.write=function(e){if(e.length===0)return"";var t,r;if(this.lastNeed){if(t=this.fillLast(e),t===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""};Gi.prototype.end=N1;Gi.prototype.text=U1;Gi.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};function Wo(e){return e<=127?0:e>>5===6?2:e>>4===14?3:e>>3===30?4:e>>6===2?-1:-2}function O1(e,t,r){var n=t.length-1;if(n<r)return 0;var i=Wo(t[n]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--n<r||i===-2?0:(i=Wo(t[n]),i>=0?(i>0&&(e.lastNeed=i-2),i):--n<r||i===-2?0:(i=Wo(t[n]),i>=0?(i>0&&(i===2?i=0:e.lastNeed=i-3),i):0))}function R1(e,t,r){if((t[0]&192)!==128)return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if((t[1]&192)!==128)return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&(t[2]&192)!==128)return e.lastNeed=2,"�"}}function F1(e){var t=this.lastTotal-this.lastNeed,r=R1(this,e);if(r!==void 0)return r;if(this.lastNeed<=e.length)return e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length}function U1(e,t){var r=O1(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)}function N1(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t}function L1(e,t){if((e.length-t)%2===0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function M1(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function $1(e,t){var r=(e.length-t)%3;return r===0?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function H1(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function D1(e){return e.toString(this.encoding)}function j1(e){return e&&e.length?this.write(e):""}var $u=Gr.codes.ERR_STREAM_PREMATURE_CLOSE;function G1(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];e.apply(this,n)}}}function z1(){}function q1(e){return e.setHeader&&typeof e.abort=="function"}function El(e,t,r){if(typeof t=="function")return El(e,null,t);t||(t={}),r=G1(r||z1);var n=t.readable||t.readable!==!1&&e.readable,i=t.writable||t.writable!==!1&&e.writable,s=function(){e.writable||a()},o=e._writableState&&e._writableState.finished,a=function(){i=!1,o=!0,n||r.call(e)},c=e._readableState&&e._readableState.endEmitted,f=function(){n=!1,c=!0,i||r.call(e)},l=function(g){r.call(e,g)},h=function(){var g;if(n&&!c)return(!e._readableState||!e._readableState.ended)&&(g=new $u),r.call(e,g);if(i&&!o)return(!e._writableState||!e._writableState.ended)&&(g=new $u),r.call(e,g)},y=function(){e.req.on("finish",a)};return q1(e)?(e.on("complete",a),e.on("abort",h),e.req?y():e.on("request",y)):i&&!e._writableState&&(e.on("end",s),e.on("close",s)),e.on("end",f),e.on("finish",a),t.error!==!1&&e.on("error",l),e.on("close",h),function(){e.removeListener("complete",a),e.removeListener("abort",h),e.removeListener("request",y),e.req&&e.req.removeListener("finish",a),e.removeListener("end",s),e.removeListener("close",s),e.removeListener("finish",a),e.removeListener("end",f),e.removeListener("error",l),e.removeListener("close",h)}}var Tc=El,Ko,Hu;function V1(){if(Hu)return Ko;Hu=1;var e;function t(A,E,I){return E=r(E),E in A?Object.defineProperty(A,E,{value:I,enumerable:!0,configurable:!0,writable:!0}):A[E]=I,A}function r(A){var E=n(A,"string");return typeof E=="symbol"?E:String(E)}function n(A,E){if(typeof A!="object"||A===null)return A;var I=A[Symbol.toPrimitive];if(I!==void 0){var S=I.call(A,E);if(typeof S!="object")return S;throw new TypeError("@@toPrimitive must return a primitive value.")}return(E==="string"?String:Number)(A)}var i=Tc,s=Symbol("lastResolve"),o=Symbol("lastReject"),a=Symbol("error"),c=Symbol("ended"),f=Symbol("lastPromise"),l=Symbol("handlePromise"),h=Symbol("stream");function y(A,E){return{value:A,done:E}}function p(A){var E=A[s];if(E!==null){var I=A[h].read();I!==null&&(A[f]=null,A[s]=null,A[o]=null,E(y(I,!1)))}}function g(A){process.nextTick(p,A)}function _(A,E){return function(I,S){A.then(function(){if(E[c]){I(y(void 0,!0));return}E[l](I,S)},S)}}var x=Object.getPrototypeOf(function(){}),k=Object.setPrototypeOf((e={get stream(){return this[h]},next:function(){var E=this,I=this[a];if(I!==null)return Promise.reject(I);if(this[c])return Promise.resolve(y(void 0,!0));if(this[h].destroyed)return new Promise(function(B,W){process.nextTick(function(){E[a]?W(E[a]):B(y(void 0,!0))})});var S=this[f],N;if(S)N=new Promise(_(S,this));else{var $=this[h].read();if($!==null)return Promise.resolve(y($,!1));N=new Promise(this[l])}return this[f]=N,N}},t(e,Symbol.asyncIterator,function(){return this}),t(e,"return",function(){var E=this;return new Promise(function(I,S){E[h].destroy(null,function(N){if(N){S(N);return}I(y(void 0,!0))})})}),e),x),T=function(E){var I,S=Object.create(k,(I={},t(I,h,{value:E,writable:!0}),t(I,s,{value:null,writable:!0}),t(I,o,{value:null,writable:!0}),t(I,a,{value:null,writable:!0}),t(I,c,{value:E._readableState.endEmitted,writable:!0}),t(I,l,{value:function($,B){var W=S[h].read();W?(S[f]=null,S[s]=null,S[o]=null,$(y(W,!1))):(S[s]=$,S[o]=B)},writable:!0}),I));return S[f]=null,i(E,function(N){if(N&&N.code!=="ERR_STREAM_PREMATURE_CLOSE"){var $=S[o];$!==null&&(S[f]=null,S[s]=null,S[o]=null,$(N)),S[a]=N;return}var B=S[s];B!==null&&(S[f]=null,S[s]=null,S[o]=null,B(y(void 0,!0))),S[c]=!0}),E.on("readable",g.bind(null,S)),S};return Ko=T,Ko}var Yo,Du;function W1(){return Du||(Du=1,Yo=function(){throw new Error("Readable.from is not available in the browser")}),Yo}var Xo,ju;function xl(){if(ju)return Xo;ju=1,Xo=B;var e;B.ReadableState=$,ml.EventEmitter;var t=function(v,M){return v.listeners(M).length},r=bl,n=Zt.Buffer,i=(typeof br<"u"?br:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function s(w){return n.from(w)}function o(w){return n.isBuffer(w)||w instanceof i}var a=Sc,c;a&&a.debuglog?c=a.debuglog("stream"):c=function(){};var f=b1(),l=gl,h=_l,y=h.getHighWaterMark,p=Gr.codes,g=p.ERR_INVALID_ARG_TYPE,_=p.ERR_STREAM_PUSH_AFTER_EOF,x=p.ERR_METHOD_NOT_IMPLEMENTED,k=p.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,T,A,E;He(B,r);var I=l.errorOrDestroy,S=["error","close","destroy","pause","resume"];function N(w,v,M){if(typeof w.prependListener=="function")return w.prependListener(v,M);!w._events||!w._events[v]?w.on(v,M):Array.isArray(w._events[v])?w._events[v].unshift(M):w._events[v]=[M,w._events[v]]}function $(w,v,M){e=e||vn(),w=w||{},typeof M!="boolean"&&(M=v instanceof e),this.objectMode=!!w.objectMode,M&&(this.objectMode=this.objectMode||!!w.readableObjectMode),this.highWaterMark=y(this,w,"readableHighWaterMark",M),this.buffer=new f,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=w.emitClose!==!1,this.autoDestroy=!!w.autoDestroy,this.destroyed=!1,this.defaultEncoding=w.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,w.encoding&&(T||(T=ks.StringDecoder),this.decoder=new T(w.encoding),this.encoding=w.encoding)}function B(w){if(e=e||vn(),!(this instanceof B))return new B(w);var v=this instanceof e;this._readableState=new $(w,this,v),this.readable=!0,w&&(typeof w.read=="function"&&(this._read=w.read),typeof w.destroy=="function"&&(this._destroy=w.destroy)),r.call(this)}Object.defineProperty(B.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(v){this._readableState&&(this._readableState.destroyed=v)}}),B.prototype.destroy=l.destroy,B.prototype._undestroy=l.undestroy,B.prototype._destroy=function(w,v){v(w)},B.prototype.push=function(w,v){var M=this._readableState,z;return M.objectMode?z=!0:typeof w=="string"&&(v=v||M.defaultEncoding,v!==M.encoding&&(w=n.from(w,v),v=""),z=!0),W(this,w,v,!1,z)},B.prototype.unshift=function(w){return W(this,w,null,!0,!1)};function W(w,v,M,z,ve){c("readableAddChunk",v);var ee=w._readableState;if(v===null)ee.reading=!1,ne(w,ee);else{var ae;if(ve||(ae=D(ee,v)),ae)I(w,ae);else if(ee.objectMode||v&&v.length>0)if(typeof v!="string"&&!ee.objectMode&&Object.getPrototypeOf(v)!==n.prototype&&(v=s(v)),z)ee.endEmitted?I(w,new k):R(w,ee,v,!0);else if(ee.ended)I(w,new _);else{if(ee.destroyed)return!1;ee.reading=!1,ee.decoder&&!M?(v=ee.decoder.write(v),ee.objectMode||v.length!==0?R(w,ee,v,!1):Te(w,ee)):R(w,ee,v,!1)}else z||(ee.reading=!1,Te(w,ee))}return!ee.ended&&(ee.length<ee.highWaterMark||ee.length===0)}function R(w,v,M,z){v.flowing&&v.length===0&&!v.sync?(v.awaitDrain=0,w.emit("data",M)):(v.length+=v.objectMode?1:M.length,z?v.buffer.unshift(M):v.buffer.push(M),v.needReadable&&pe(w)),Te(w,v)}function D(w,v){var M;return!o(v)&&typeof v!="string"&&v!==void 0&&!w.objectMode&&(M=new g("chunk",["string","Buffer","Uint8Array"],v)),M}B.prototype.isPaused=function(){return this._readableState.flowing===!1},B.prototype.setEncoding=function(w){T||(T=ks.StringDecoder);var v=new T(w);this._readableState.decoder=v,this._readableState.encoding=this._readableState.decoder.encoding;for(var M=this._readableState.buffer.head,z="";M!==null;)z+=v.write(M.data),M=M.next;return this._readableState.buffer.clear(),z!==""&&this._readableState.buffer.push(z),this._readableState.length=z.length,this};var j=1073741824;function V(w){return w>=j?w=j:(w--,w|=w>>>1,w|=w>>>2,w|=w>>>4,w|=w>>>8,w|=w>>>16,w++),w}function X(w,v){return w<=0||v.length===0&&v.ended?0:v.objectMode?1:w!==w?v.flowing&&v.length?v.buffer.head.data.length:v.length:(w>v.highWaterMark&&(v.highWaterMark=V(w)),w<=v.length?w:v.ended?v.length:(v.needReadable=!0,0))}B.prototype.read=function(w){c("read",w),w=parseInt(w,10);var v=this._readableState,M=w;if(w!==0&&(v.emittedReadable=!1),w===0&&v.needReadable&&((v.highWaterMark!==0?v.length>=v.highWaterMark:v.length>0)||v.ended))return c("read: emitReadable",v.length,v.ended),v.length===0&&v.ended?H(this):pe(this),null;if(w=X(w,v),w===0&&v.ended)return v.length===0&&H(this),null;var z=v.needReadable;c("need readable",z),(v.length===0||v.length-w<v.highWaterMark)&&(z=!0,c("length less than watermark",z)),v.ended||v.reading?(z=!1,c("reading or ended",z)):z&&(c("do read"),v.reading=!0,v.sync=!0,v.length===0&&(v.needReadable=!0),this._read(v.highWaterMark),v.sync=!1,v.reading||(w=X(M,v)));var ve;return w>0?ve=C(w,v):ve=null,ve===null?(v.needReadable=v.length<=v.highWaterMark,w=0):(v.length-=w,v.awaitDrain=0),v.length===0&&(v.ended||(v.needReadable=!0),M!==w&&v.ended&&H(this)),ve!==null&&this.emit("data",ve),ve};function ne(w,v){if(c("onEofChunk"),!v.ended){if(v.decoder){var M=v.decoder.end();M&&M.length&&(v.buffer.push(M),v.length+=v.objectMode?1:M.length)}v.ended=!0,v.sync?pe(w):(v.needReadable=!1,v.emittedReadable||(v.emittedReadable=!0,_e(w)))}}function pe(w){var v=w._readableState;c("emitReadable",v.needReadable,v.emittedReadable),v.needReadable=!1,v.emittedReadable||(c("emitReadable",v.flowing),v.emittedReadable=!0,process.nextTick(_e,w))}function _e(w){var v=w._readableState;c("emitReadable_",v.destroyed,v.length,v.ended),!v.destroyed&&(v.length||v.ended)&&(w.emit("readable"),v.emittedReadable=!1),v.needReadable=!v.flowing&&!v.ended&&v.length<=v.highWaterMark,O(w)}function Te(w,v){v.readingMore||(v.readingMore=!0,process.nextTick(We,w,v))}function We(w,v){for(;!v.reading&&!v.ended&&(v.length<v.highWaterMark||v.flowing&&v.length===0);){var M=v.length;if(c("maybeReadMore read 0"),w.read(0),M===v.length)break}v.readingMore=!1}B.prototype._read=function(w){I(this,new x("_read()"))},B.prototype.pipe=function(w,v){var M=this,z=this._readableState;switch(z.pipesCount){case 0:z.pipes=w;break;case 1:z.pipes=[z.pipes,w];break;default:z.pipes.push(w);break}z.pipesCount+=1,c("pipe count=%d opts=%j",z.pipesCount,v);var ve=(!v||v.end!==!1)&&w!==process.stdout&&w!==process.stderr,ee=ve?tr:Sr;z.endEmitted?process.nextTick(ee):M.once("end",ee),w.on("unpipe",ae);function ae(m,u){c("onunpipe"),m===M&&u&&u.hasUnpiped===!1&&(u.hasUnpiped=!0,Vr())}function tr(){c("onend"),w.end()}var qr=fe(M);w.on("drain",qr);var In=!1;function Vr(){c("cleanup"),w.removeListener("close",Bn),w.removeListener("finish",ft),w.removeListener("drain",qr),w.removeListener("error",Ar),w.removeListener("unpipe",ae),M.removeListener("end",tr),M.removeListener("end",Sr),M.removeListener("data",ot),In=!0,z.awaitDrain&&(!w._writableState||w._writableState.needDrain)&&qr()}M.on("data",ot);function ot(m){c("ondata");var u=w.write(m);c("dest.write",u),u===!1&&((z.pipesCount===1&&z.pipes===w||z.pipesCount>1&&Z(z.pipes,w)!==-1)&&!In&&(c("false write response, pause",z.awaitDrain),z.awaitDrain++),M.pause())}function Ar(m){c("onerror",m),Sr(),w.removeListener("error",Ar),t(w,"error")===0&&I(w,m)}N(w,"error",Ar);function Bn(){w.removeListener("finish",ft),Sr()}w.once("close",Bn);function ft(){c("onfinish"),w.removeListener("close",Bn),Sr()}w.once("finish",ft);function Sr(){c("unpipe"),M.unpipe(w)}return w.emit("pipe",M),z.flowing||(c("pipe resume"),M.resume()),w};function fe(w){return function(){var M=w._readableState;c("pipeOnDrain",M.awaitDrain),M.awaitDrain&&M.awaitDrain--,M.awaitDrain===0&&t(w,"data")&&(M.flowing=!0,O(w))}}B.prototype.unpipe=function(w){var v=this._readableState,M={hasUnpiped:!1};if(v.pipesCount===0)return this;if(v.pipesCount===1)return w&&w!==v.pipes?this:(w||(w=v.pipes),v.pipes=null,v.pipesCount=0,v.flowing=!1,w&&w.emit("unpipe",this,M),this);if(!w){var z=v.pipes,ve=v.pipesCount;v.pipes=null,v.pipesCount=0,v.flowing=!1;for(var ee=0;ee<ve;ee++)z[ee].emit("unpipe",this,{hasUnpiped:!1});return this}var ae=Z(v.pipes,w);return ae===-1?this:(v.pipes.splice(ae,1),v.pipesCount-=1,v.pipesCount===1&&(v.pipes=v.pipes[0]),w.emit("unpipe",this,M),this)},B.prototype.on=function(w,v){var M=r.prototype.on.call(this,w,v),z=this._readableState;return w==="data"?(z.readableListening=this.listenerCount("readable")>0,z.flowing!==!1&&this.resume()):w==="readable"&&!z.endEmitted&&!z.readableListening&&(z.readableListening=z.needReadable=!0,z.flowing=!1,z.emittedReadable=!1,c("on readable",z.length,z.reading),z.length?pe(this):z.reading||process.nextTick(st,this)),M},B.prototype.addListener=B.prototype.on,B.prototype.removeListener=function(w,v){var M=r.prototype.removeListener.call(this,w,v);return w==="readable"&&process.nextTick(me,this),M},B.prototype.removeAllListeners=function(w){var v=r.prototype.removeAllListeners.apply(this,arguments);return(w==="readable"||w===void 0)&&process.nextTick(me,this),v};function me(w){var v=w._readableState;v.readableListening=w.listenerCount("readable")>0,v.resumeScheduled&&!v.paused?v.flowing=!0:w.listenerCount("data")>0&&w.resume()}function st(w){c("readable nexttick read 0"),w.read(0)}B.prototype.resume=function(){var w=this._readableState;return w.flowing||(c("resume"),w.flowing=!w.readableListening,er(this,w)),w.paused=!1,this};function er(w,v){v.resumeScheduled||(v.resumeScheduled=!0,process.nextTick(Rt,w,v))}function Rt(w,v){c("resume",v.reading),v.reading||w.read(0),v.resumeScheduled=!1,w.emit("resume"),O(w),v.flowing&&!v.reading&&w.read(0)}B.prototype.pause=function(){return c("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(c("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function O(w){var v=w._readableState;for(c("flow",v.flowing);v.flowing&&w.read()!==null;);}B.prototype.wrap=function(w){var v=this,M=this._readableState,z=!1;w.on("end",function(){if(c("wrapped end"),M.decoder&&!M.ended){var ae=M.decoder.end();ae&&ae.length&&v.push(ae)}v.push(null)}),w.on("data",function(ae){if(c("wrapped data"),M.decoder&&(ae=M.decoder.write(ae)),!(M.objectMode&&ae==null)&&!(!M.objectMode&&(!ae||!ae.length))){var tr=v.push(ae);tr||(z=!0,w.pause())}});for(var ve in w)this[ve]===void 0&&typeof w[ve]=="function"&&(this[ve]=function(tr){return function(){return w[tr].apply(w,arguments)}}(ve));for(var ee=0;ee<S.length;ee++)w.on(S[ee],this.emit.bind(this,S[ee]));return this._read=function(ae){c("wrapped _read",ae),z&&(z=!1,w.resume())},this},typeof Symbol=="function"&&(B.prototype[Symbol.asyncIterator]=function(){return A===void 0&&(A=V1()),A(this)}),Object.defineProperty(B.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(B.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(B.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(v){this._readableState&&(this._readableState.flowing=v)}}),B._fromList=C,Object.defineProperty(B.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function C(w,v){if(v.length===0)return null;var M;return v.objectMode?M=v.buffer.shift():!w||w>=v.length?(v.decoder?M=v.buffer.join(""):v.buffer.length===1?M=v.buffer.first():M=v.buffer.concat(v.length),v.buffer.clear()):M=v.buffer.consume(w,v.decoder),M}function H(w){var v=w._readableState;c("endReadable",v.endEmitted),v.endEmitted||(v.ended=!0,process.nextTick(K,v,w))}function K(w,v){if(c("endReadableNT",w.endEmitted,w.length),!w.endEmitted&&w.length===0&&(w.endEmitted=!0,v.readable=!1,v.emit("end"),w.autoDestroy)){var M=v._writableState;(!M||M.autoDestroy&&M.finished)&&v.destroy()}}typeof Symbol=="function"&&(B.from=function(w,v){return E===void 0&&(E=W1()),E(B,w,v)});function Z(w,v){for(var M=0,z=w.length;M<z;M++)if(w[M]===v)return M;return-1}return Xo}var Al=Xt,ro=Gr.codes,K1=ro.ERR_METHOD_NOT_IMPLEMENTED,Y1=ro.ERR_MULTIPLE_CALLBACK,X1=ro.ERR_TRANSFORM_ALREADY_TRANSFORMING,J1=ro.ERR_TRANSFORM_WITH_LENGTH_0,no=vn();He(Xt,no);function Q1(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(n===null)return this.emit("error",new Y1);r.writechunk=null,r.writecb=null,t!=null&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function Xt(e){if(!(this instanceof Xt))return new Xt(e);no.call(this,e),this._transformState={afterTransform:Q1.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",Z1)}function Z1(){var e=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(t,r){Gu(e,t,r)}):Gu(this,null,null)}Xt.prototype.push=function(e,t){return this._transformState.needTransform=!1,no.prototype.push.call(this,e,t)};Xt.prototype._transform=function(e,t,r){r(new K1("_transform()"))};Xt.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}};Xt.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};Xt.prototype._destroy=function(e,t){no.prototype._destroy.call(this,e,function(r){t(r)})};function Gu(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new J1;if(e._transformState.transforming)throw new X1;return e.push(null)}var ew=Ii,Sl=Al;He(Ii,Sl);function Ii(e){if(!(this instanceof Ii))return new Ii(e);Sl.call(this,e)}Ii.prototype._transform=function(e,t,r){r(null,e)};var Jo;function tw(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var Pl=Gr.codes,rw=Pl.ERR_MISSING_ARGS,nw=Pl.ERR_STREAM_DESTROYED;function zu(e){if(e)throw e}function iw(e){return e.setHeader&&typeof e.abort=="function"}function sw(e,t,r,n){n=tw(n);var i=!1;e.on("close",function(){i=!0}),Jo===void 0&&(Jo=Tc),Jo(e,{readable:t,writable:r},function(o){if(o)return n(o);i=!0,n()});var s=!1;return function(o){if(!i&&!s){if(s=!0,iw(e))return e.abort();if(typeof e.destroy=="function")return e.destroy();n(o||new nw("pipe"))}}}function qu(e){e()}function ow(e,t){return e.pipe(t)}function aw(e){return!e.length||typeof e[e.length-1]!="function"?zu:e.pop()}function cw(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=aw(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new rw("streams");var i,s=t.map(function(o,a){var c=a<t.length-1,f=a>0;return sw(o,c,f,function(l){i||(i=l),l&&s.forEach(qu),!c&&(s.forEach(qu),n(i))})});return t.reduce(ow)}var uw=cw;(function(e,t){t=e.exports=xl(),t.Stream=t,t.Readable=t,t.Writable=vl(),t.Duplex=vn(),t.Transform=Al,t.PassThrough=ew,t.finished=Tc,t.pipeline=uw})(Ia,Ia.exports);var Tl=Ia.exports,Is=tt.Buffer,kl=Tl.Transform,fw=He;function dw(e,t){if(!Is.isBuffer(e)&&typeof e!="string")throw new TypeError(t+" must be a string or a buffer")}function Er(e){kl.call(this),this._block=Is.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}fw(Er,kl);Er.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(i){n=i}r(n)};Er.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(r){t=r}e(t)};Er.prototype.update=function(e,t){if(dw(e,"Data"),this._finalized)throw new Error("Digest already called");Is.isBuffer(e)||(e=Is.from(e,t));for(var r=this._block,n=0;this._blockOffset+e.length-n>=this._blockSize;){for(var i=this._blockOffset;i<this._blockSize;)r[i++]=e[n++];this._update(),this._blockOffset=0}for(;n<e.length;)r[this._blockOffset++]=e[n++];for(var s=0,o=e.length*8;o>0;++s)this._length[s]+=o,o=this._length[s]/4294967296|0,o>0&&(this._length[s]-=4294967296*o);return this};Er.prototype._update=function(){throw new Error("_update is not implemented")};Er.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();e!==void 0&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t};Er.prototype._digest=function(){throw new Error("_digest is not implemented")};var lw=Er,hw=He,Il=lw,pw=tt.Buffer,yw=new Array(16);function io(){Il.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}hw(io,Il);io.prototype._update=function(){for(var e=yw,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);var r=this._a,n=this._b,i=this._c,s=this._d;r=De(r,n,i,s,e[0],3614090360,7),s=De(s,r,n,i,e[1],3905402710,12),i=De(i,s,r,n,e[2],606105819,17),n=De(n,i,s,r,e[3],3250441966,22),r=De(r,n,i,s,e[4],4118548399,7),s=De(s,r,n,i,e[5],1200080426,12),i=De(i,s,r,n,e[6],2821735955,17),n=De(n,i,s,r,e[7],4249261313,22),r=De(r,n,i,s,e[8],1770035416,7),s=De(s,r,n,i,e[9],2336552879,12),i=De(i,s,r,n,e[10],4294925233,17),n=De(n,i,s,r,e[11],2304563134,22),r=De(r,n,i,s,e[12],1804603682,7),s=De(s,r,n,i,e[13],4254626195,12),i=De(i,s,r,n,e[14],2792965006,17),n=De(n,i,s,r,e[15],1236535329,22),r=je(r,n,i,s,e[1],4129170786,5),s=je(s,r,n,i,e[6],3225465664,9),i=je(i,s,r,n,e[11],643717713,14),n=je(n,i,s,r,e[0],3921069994,20),r=je(r,n,i,s,e[5],3593408605,5),s=je(s,r,n,i,e[10],38016083,9),i=je(i,s,r,n,e[15],3634488961,14),n=je(n,i,s,r,e[4],3889429448,20),r=je(r,n,i,s,e[9],568446438,5),s=je(s,r,n,i,e[14],3275163606,9),i=je(i,s,r,n,e[3],4107603335,14),n=je(n,i,s,r,e[8],1163531501,20),r=je(r,n,i,s,e[13],2850285829,5),s=je(s,r,n,i,e[2],4243563512,9),i=je(i,s,r,n,e[7],1735328473,14),n=je(n,i,s,r,e[12],2368359562,20),r=Ge(r,n,i,s,e[5],4294588738,4),s=Ge(s,r,n,i,e[8],2272392833,11),i=Ge(i,s,r,n,e[11],1839030562,16),n=Ge(n,i,s,r,e[14],4259657740,23),r=Ge(r,n,i,s,e[1],2763975236,4),s=Ge(s,r,n,i,e[4],1272893353,11),i=Ge(i,s,r,n,e[7],4139469664,16),n=Ge(n,i,s,r,e[10],3200236656,23),r=Ge(r,n,i,s,e[13],681279174,4),s=Ge(s,r,n,i,e[0],3936430074,11),i=Ge(i,s,r,n,e[3],3572445317,16),n=Ge(n,i,s,r,e[6],76029189,23),r=Ge(r,n,i,s,e[9],3654602809,4),s=Ge(s,r,n,i,e[12],3873151461,11),i=Ge(i,s,r,n,e[15],530742520,16),n=Ge(n,i,s,r,e[2],3299628645,23),r=ze(r,n,i,s,e[0],4096336452,6),s=ze(s,r,n,i,e[7],1126891415,10),i=ze(i,s,r,n,e[14],2878612391,15),n=ze(n,i,s,r,e[5],4237533241,21),r=ze(r,n,i,s,e[12],1700485571,6),s=ze(s,r,n,i,e[3],2399980690,10),i=ze(i,s,r,n,e[10],4293915773,15),n=ze(n,i,s,r,e[1],2240044497,21),r=ze(r,n,i,s,e[8],1873313359,6),s=ze(s,r,n,i,e[15],4264355552,10),i=ze(i,s,r,n,e[6],2734768916,15),n=ze(n,i,s,r,e[13],1309151649,21),r=ze(r,n,i,s,e[4],4149444226,6),s=ze(s,r,n,i,e[11],3174756917,10),i=ze(i,s,r,n,e[2],718787259,15),n=ze(n,i,s,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+s|0};io.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=pw.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e};function so(e,t){return e<<t|e>>>32-t}function De(e,t,r,n,i,s,o){return so(e+(t&r|~t&n)+i+s|0,o)+t|0}function je(e,t,r,n,i,s,o){return so(e+(t&n|r&~n)+i+s|0,o)+t|0}function Ge(e,t,r,n,i,s,o){return so(e+(t^r^n)+i+s|0,o)+t|0}function ze(e,t,r,n,i,s,o){return so(e+(r^(t|~n))+i+s|0,o)+t|0}var mw=io,Bs=tt.Buffer,Bl=Tl.Transform,bw=He;function gw(e,t){if(!Bs.isBuffer(e)&&typeof e!="string")throw new TypeError(t+" must be a string or a buffer")}function xr(e){Bl.call(this),this._block=Bs.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}bw(xr,Bl);xr.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(i){n=i}r(n)};xr.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(r){t=r}e(t)};xr.prototype.update=function(e,t){if(gw(e,"Data"),this._finalized)throw new Error("Digest already called");Bs.isBuffer(e)||(e=Bs.from(e,t));for(var r=this._block,n=0;this._blockOffset+e.length-n>=this._blockSize;){for(var i=this._blockOffset;i<this._blockSize;)r[i++]=e[n++];this._update(),this._blockOffset=0}for(;n<e.length;)r[this._blockOffset++]=e[n++];for(var s=0,o=e.length*8;o>0;++s)this._length[s]+=o,o=this._length[s]/4294967296|0,o>0&&(this._length[s]-=4294967296*o);return this};xr.prototype._update=function(){throw new Error("_update is not implemented")};xr.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();e!==void 0&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t};xr.prototype._digest=function(){throw new Error("_digest is not implemented")};var ww=xr,Qo=Zt.Buffer,_w=He,Cl=ww,vw=new Array(16),$n=[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],Hn=[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],Dn=[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],jn=[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],Gn=[0,1518500249,1859775393,2400959708,2840853838],zn=[1352829926,1548603684,1836072691,2053994217,0];function oo(){Cl.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}_w(oo,Cl);oo.prototype._update=function(){for(var e=vw,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);for(var r=this._a|0,n=this._b|0,i=this._c|0,s=this._d|0,o=this._e|0,a=this._a|0,c=this._b|0,f=this._c|0,l=this._d|0,h=this._e|0,y=0;y<80;y+=1){var p,g;y<16?(p=Vu(r,n,i,s,o,e[$n[y]],Gn[0],Dn[y]),g=Xu(a,c,f,l,h,e[Hn[y]],zn[0],jn[y])):y<32?(p=Wu(r,n,i,s,o,e[$n[y]],Gn[1],Dn[y]),g=Yu(a,c,f,l,h,e[Hn[y]],zn[1],jn[y])):y<48?(p=Ku(r,n,i,s,o,e[$n[y]],Gn[2],Dn[y]),g=Ku(a,c,f,l,h,e[Hn[y]],zn[2],jn[y])):y<64?(p=Yu(r,n,i,s,o,e[$n[y]],Gn[3],Dn[y]),g=Wu(a,c,f,l,h,e[Hn[y]],zn[3],jn[y])):(p=Xu(r,n,i,s,o,e[$n[y]],Gn[4],Dn[y]),g=Vu(a,c,f,l,h,e[Hn[y]],zn[4],jn[y])),r=o,o=s,s=Hr(i,10),i=n,n=p,a=h,h=l,l=Hr(f,10),f=c,c=g}var _=this._b+i+l|0;this._b=this._c+s+h|0,this._c=this._d+o+a|0,this._d=this._e+r+c|0,this._e=this._a+n+f|0,this._a=_};oo.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=Qo.alloc?Qo.alloc(20):new Qo(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e};function Hr(e,t){return e<<t|e>>>32-t}function Vu(e,t,r,n,i,s,o,a){return Hr(e+(t^r^n)+s+o|0,a)+i|0}function Wu(e,t,r,n,i,s,o,a){return Hr(e+(t&r|~t&n)+s+o|0,a)+i|0}function Ku(e,t,r,n,i,s,o,a){return Hr(e+((t|~r)^n)+s+o|0,a)+i|0}function Yu(e,t,r,n,i,s,o,a){return Hr(e+(t&n|r&~n)+s+o|0,a)+i|0}function Xu(e,t,r,n,i,s,o,a){return Hr(e+(t^(r|~n))+s+o|0,a)+i|0}var Ew=oo,Ol={exports:{}},Rl=tt.Buffer;function ao(e,t){this._block=Rl.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}ao.prototype.update=function(e,t){typeof e=="string"&&(t=t||"utf8",e=Rl.from(e,t));for(var r=this._block,n=this._blockSize,i=e.length,s=this._len,o=0;o<i;){for(var a=s%n,c=Math.min(i-o,n-a),f=0;f<c;f++)r[a+f]=e[o+f];s+=c,o+=c,s%n===0&&this._update(r)}return this._len+=i,this};ao.prototype.digest=function(e){var t=this._len%this._blockSize;this._block[t]=128,this._block.fill(0,t+1),t>=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=this._len*8;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(r&4294967295)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var s=this._hash();return e?s.toString(e):s};ao.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var kn=ao,xw=He,Fl=kn,Aw=tt.Buffer,Sw=[1518500249,1859775393,-1894007588,-899497514],Pw=new Array(80);function zi(){this.init(),this._w=Pw,Fl.call(this,64,56)}xw(zi,Fl);zi.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Tw(e){return e<<5|e>>>27}function kw(e){return e<<30|e>>>2}function Iw(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}zi.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,s=this._d|0,o=this._e|0,a=0;a<16;++a)t[a]=e.readInt32BE(a*4);for(;a<80;++a)t[a]=t[a-3]^t[a-8]^t[a-14]^t[a-16];for(var c=0;c<80;++c){var f=~~(c/20),l=Tw(r)+Iw(f,n,i,s)+o+t[c]+Sw[f]|0;o=s,s=i,i=kw(n),n=r,r=l}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=s+this._d|0,this._e=o+this._e|0};zi.prototype._hash=function(){var e=Aw.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};var Bw=zi,Cw=He,Ul=kn,Ow=tt.Buffer,Rw=[1518500249,1859775393,-1894007588,-899497514],Fw=new Array(80);function qi(){this.init(),this._w=Fw,Ul.call(this,64,56)}Cw(qi,Ul);qi.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Uw(e){return e<<1|e>>>31}function Nw(e){return e<<5|e>>>27}function Lw(e){return e<<30|e>>>2}function Mw(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}qi.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,s=this._d|0,o=this._e|0,a=0;a<16;++a)t[a]=e.readInt32BE(a*4);for(;a<80;++a)t[a]=Uw(t[a-3]^t[a-8]^t[a-14]^t[a-16]);for(var c=0;c<80;++c){var f=~~(c/20),l=Nw(r)+Mw(f,n,i,s)+o+t[c]+Rw[f]|0;o=s,s=i,i=Lw(n),n=r,r=l}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=s+this._d|0,this._e=o+this._e|0};qi.prototype._hash=function(){var e=Ow.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};var $w=qi,Hw=He,Nl=kn,Dw=tt.Buffer,jw=[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],Gw=new Array(64);function Vi(){this.init(),this._w=Gw,Nl.call(this,64,56)}Hw(Vi,Nl);Vi.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function zw(e,t,r){return r^e&(t^r)}function qw(e,t,r){return e&t|r&(e|t)}function Vw(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function Ww(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function Kw(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function Yw(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}Vi.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,s=this._d|0,o=this._e|0,a=this._f|0,c=this._g|0,f=this._h|0,l=0;l<16;++l)t[l]=e.readInt32BE(l*4);for(;l<64;++l)t[l]=Yw(t[l-2])+t[l-7]+Kw(t[l-15])+t[l-16]|0;for(var h=0;h<64;++h){var y=f+Ww(o)+zw(o,a,c)+jw[h]+t[h]|0,p=Vw(r)+qw(r,n,i)|0;f=c,c=a,a=o,o=s+y|0,s=i,i=n,n=r,r=y+p|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=s+this._d|0,this._e=o+this._e|0,this._f=a+this._f|0,this._g=c+this._g|0,this._h=f+this._h|0};Vi.prototype._hash=function(){var e=Dw.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e};var Ll=Vi,Xw=He,Jw=Ll,Qw=kn,Zw=tt.Buffer,e2=new Array(64);function co(){this.init(),this._w=e2,Qw.call(this,64,56)}Xw(co,Jw);co.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this};co.prototype._hash=function(){var e=Zw.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e};var t2=co,r2=He,Ml=kn,n2=tt.Buffer,Ju=[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],i2=new Array(160);function Wi(){this.init(),this._w=i2,Ml.call(this,128,112)}r2(Wi,Ml);Wi.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this};function Qu(e,t,r){return r^e&(t^r)}function Zu(e,t,r){return e&t|r&(e|t)}function ef(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function tf(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function s2(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function o2(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function a2(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function c2(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function Fe(e,t){return e>>>0<t>>>0?1:0}Wi.prototype._update=function(e){for(var t=this._w,r=this._ah|0,n=this._bh|0,i=this._ch|0,s=this._dh|0,o=this._eh|0,a=this._fh|0,c=this._gh|0,f=this._hh|0,l=this._al|0,h=this._bl|0,y=this._cl|0,p=this._dl|0,g=this._el|0,_=this._fl|0,x=this._gl|0,k=this._hl|0,T=0;T<32;T+=2)t[T]=e.readInt32BE(T*4),t[T+1]=e.readInt32BE(T*4+4);for(;T<160;T+=2){var A=t[T-30],E=t[T-15*2+1],I=s2(A,E),S=o2(E,A);A=t[T-2*2],E=t[T-2*2+1];var N=a2(A,E),$=c2(E,A),B=t[T-7*2],W=t[T-7*2+1],R=t[T-16*2],D=t[T-16*2+1],j=S+W|0,V=I+B+Fe(j,S)|0;j=j+$|0,V=V+N+Fe(j,$)|0,j=j+D|0,V=V+R+Fe(j,D)|0,t[T]=V,t[T+1]=j}for(var X=0;X<160;X+=2){V=t[X],j=t[X+1];var ne=Zu(r,n,i),pe=Zu(l,h,y),_e=ef(r,l),Te=ef(l,r),We=tf(o,g),fe=tf(g,o),me=Ju[X],st=Ju[X+1],er=Qu(o,a,c),Rt=Qu(g,_,x),O=k+fe|0,C=f+We+Fe(O,k)|0;O=O+Rt|0,C=C+er+Fe(O,Rt)|0,O=O+st|0,C=C+me+Fe(O,st)|0,O=O+j|0,C=C+V+Fe(O,j)|0;var H=Te+pe|0,K=_e+ne+Fe(H,Te)|0;f=c,k=x,c=a,x=_,a=o,_=g,g=p+O|0,o=s+C+Fe(g,p)|0,s=i,p=y,i=n,y=h,n=r,h=l,l=O+H|0,r=C+K+Fe(l,O)|0}this._al=this._al+l|0,this._bl=this._bl+h|0,this._cl=this._cl+y|0,this._dl=this._dl+p|0,this._el=this._el+g|0,this._fl=this._fl+_|0,this._gl=this._gl+x|0,this._hl=this._hl+k|0,this._ah=this._ah+r+Fe(this._al,l)|0,this._bh=this._bh+n+Fe(this._bl,h)|0,this._ch=this._ch+i+Fe(this._cl,y)|0,this._dh=this._dh+s+Fe(this._dl,p)|0,this._eh=this._eh+o+Fe(this._el,g)|0,this._fh=this._fh+a+Fe(this._fl,_)|0,this._gh=this._gh+c+Fe(this._gl,x)|0,this._hh=this._hh+f+Fe(this._hl,k)|0};Wi.prototype._hash=function(){var e=n2.allocUnsafe(64);function t(r,n,i){e.writeInt32BE(r,i),e.writeInt32BE(n,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e};var $l=Wi,u2=He,f2=$l,d2=kn,l2=tt.Buffer,h2=new Array(160);function uo(){this.init(),this._w=h2,d2.call(this,128,112)}u2(uo,f2);uo.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this};uo.prototype._hash=function(){var e=l2.allocUnsafe(48);function t(r,n,i){e.writeInt32BE(r,i),e.writeInt32BE(n,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e};var p2=uo,zr=Ol.exports=function(t){t=t.toLowerCase();var r=zr[t];if(!r)throw new Error(t+" is not supported (we accept pull requests)");return new r};zr.sha=Bw;zr.sha1=$w;zr.sha224=t2;zr.sha256=Ll;zr.sha384=p2;zr.sha512=$l;var y2=Ol.exports,kt=tt.Buffer,Hl=Sc.Transform,m2=ks.StringDecoder,b2=He;function _t(e){Hl.call(this),this.hashMode=typeof e=="string",this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}b2(_t,Hl);var g2=typeof Uint8Array<"u",w2=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u"&&ArrayBuffer.isView&&(kt.prototype instanceof Uint8Array||kt.TYPED_ARRAY_SUPPORT);function _2(e,t){if(e instanceof kt)return e;if(typeof e=="string")return kt.from(e,t);if(w2&&ArrayBuffer.isView(e)){if(e.byteLength===0)return kt.alloc(0);var r=kt.from(e.buffer,e.byteOffset,e.byteLength);if(r.byteLength===e.byteLength)return r}if(g2&&e instanceof Uint8Array||kt.isBuffer(e)&&e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e))return kt.from(e);throw new TypeError('The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView.')}_t.prototype.update=function(e,t,r){var n=_2(e,t),i=this._update(n);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)};_t.prototype.setAutoPadding=function(){};_t.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")};_t.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")};_t.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")};_t.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(i){n=i}finally{r(n)}};_t.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(r){t=r}e(t)};_t.prototype._finalOrDigest=function(e){var t=this.__final()||kt.alloc(0);return e&&(t=this._toString(t,e,!0)),t};_t.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new m2(t),this._encoding=t),this._encoding!==t)throw new Error("can’t switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n};var v2=_t,E2=He,x2=mw,A2=Ew,S2=y2,Dl=v2;function fo(e){Dl.call(this,"digest"),this._hash=e}E2(fo,Dl);fo.prototype._update=function(e){this._hash.update(e)};fo.prototype._final=function(){return this._hash.digest()};var P2=function(t){return t=t.toLowerCase(),t==="md5"?new x2:t==="rmd160"||t==="ripemd160"?new A2:new fo(S2(t))},as=tt.Buffer;function T2(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var n=0;n<e.length;n++){var i=e.charAt(n),s=i.charCodeAt(0);if(t[s]!==255)throw new TypeError(i+" is ambiguous");t[s]=n}var o=e.length,a=e.charAt(0),c=Math.log(o)/Math.log(256),f=Math.log(256)/Math.log(o);function l(p){if((Array.isArray(p)||p instanceof Uint8Array)&&(p=as.from(p)),!as.isBuffer(p))throw new TypeError("Expected Buffer");if(p.length===0)return"";for(var g=0,_=0,x=0,k=p.length;x!==k&&p[x]===0;)x++,g++;for(var T=(k-x)*f+1>>>0,A=new Uint8Array(T);x!==k;){for(var E=p[x],I=0,S=T-1;(E!==0||I<_)&&S!==-1;S--,I++)E+=256*A[S]>>>0,A[S]=E%o>>>0,E=E/o>>>0;if(E!==0)throw new Error("Non-zero carry");_=I,x++}for(var N=T-_;N!==T&&A[N]===0;)N++;for(var $=a.repeat(g);N<T;++N)$+=e.charAt(A[N]);return $}function h(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return as.alloc(0);for(var g=0,_=0,x=0;p[g]===a;)_++,g++;for(var k=(p.length-g)*c+1>>>0,T=new Uint8Array(k);g<p.length;){var A=p.charCodeAt(g);if(A>255)return;var E=t[A];if(E===255)return;for(var I=0,S=k-1;(E!==0||I<x)&&S!==-1;S--,I++)E+=o*T[S]>>>0,T[S]=E%256>>>0,E=E/256>>>0;if(E!==0)throw new Error("Non-zero carry");x=I,g++}for(var N=k-x;N!==k&&T[N]===0;)N++;var $=as.allocUnsafe(_+(k-N));$.fill(0,0,_);for(var B=_;N!==k;)$[B++]=T[N++];return $}function y(p){var g=h(p);if(g)return g;throw new Error("Non-base"+o+" character")}return{encode:l,decodeUnsafe:h,decode:y}}var k2=T2,I2=k2,B2="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",C2=I2(B2),Zo=C2,O2=tt.Buffer,R2=function(e){function t(s){var o=e(s);return Zo.encode(O2.concat([s,o],s.length+4))}function r(s){var o=s.slice(0,-4),a=s.slice(-4),c=e(o);if(!(a[0]^c[0]|a[1]^c[1]|a[2]^c[2]|a[3]^c[3]))return o}function n(s){var o=Zo.decodeUnsafe(s);if(o)return r(o)}function i(s){var o=Zo.decode(s),a=r(o);if(!a)throw new Error("Invalid checksum");return a}return{encode:t,decode:i,decodeUnsafe:n}},rf=P2,F2=R2;function U2(e){var t=rf("sha256").update(e).digest();return rf("sha256").update(t).digest()}var N2=F2(U2),Ca=N2;function jl(e,t){if(t!==void 0&&e[0]!==t)throw new Error("Invalid network version");if(e.length===33)return{version:e[0],privateKey:e.slice(1,33),compressed:!1};if(e.length!==34)throw new Error("Invalid WIF length");if(e[33]!==1)throw new Error("Invalid compression flag");return{version:e[0],privateKey:e.slice(1,33),compressed:!0}}function Oa(e,t,r){var n=new Buffer(r?34:33);return n.writeUInt8(e,0),t.copy(n,1),r&&(n[33]=1),n}function L2(e,t){return jl(Ca.decode(e),t)}function M2(e,t,r){return typeof e=="number"?Ca.encode(Oa(e,t,r)):Ca.encode(Oa(e.version,e.privateKey,e.compressed))}var $2={decode:L2,decodeRaw:jl,encode:M2,encodeRaw:Oa},lo={};Object.defineProperty(lo,"__esModule",{value:!0});lo.testEcc=void 0;const Y=e=>Buffer.from(e,"hex");function H2(e){ge(e.isPoint(Y("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),ge(!e.isPoint(Y("030000000000000000000000000000000000000000000000000000000000000005"))),ge(e.isPrivate(Y("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),ge(e.isPrivate(Y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),ge(!e.isPrivate(Y("0000000000000000000000000000000000000000000000000000000000000000"))),ge(!e.isPrivate(Y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),ge(!e.isPrivate(Y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),ge(Buffer.from(e.privateAdd(Y("0000000000000000000000000000000000000000000000000000000000000001"),Y("0000000000000000000000000000000000000000000000000000000000000000"))).equals(Y("0000000000000000000000000000000000000000000000000000000000000001"))),ge(e.privateAdd(Y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),Y("0000000000000000000000000000000000000000000000000000000000000003"))===null),ge(Buffer.from(e.privateAdd(Y("e211078564db65c3ce7704f08262b1f38f1ef412ad15b5ac2d76657a63b2c500"),Y("b51fbb69051255d1becbd683de5848242a89c229348dd72896a87ada94ae8665"))).equals(Y("9730c2ee69edbb958d42db7460bafa18fef9d955325aec99044c81c8282b0a24"))),ge(Buffer.from(e.privateNegate(Y("0000000000000000000000000000000000000000000000000000000000000001"))).equals(Y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),ge(Buffer.from(e.privateNegate(Y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"))).equals(Y("0000000000000000000000000000000000000000000000000000000000000003"))),ge(Buffer.from(e.privateNegate(Y("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(Y("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792"))),ge(Buffer.from(e.pointCompress(Y("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!0)).equals(Y("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),ge(Buffer.from(e.pointCompress(Y("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!1)).equals(Y("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),ge(Buffer.from(e.pointCompress(Y("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!0)).equals(Y("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),ge(Buffer.from(e.pointCompress(Y("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!1)).equals(Y("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),ge(Buffer.from(e.pointFromScalar(Y("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(Y("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),ge(e.xOnlyPointAddTweak(Y("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))===null);let t=e.xOnlyPointAddTweak(Y("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),Y("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));ge(Buffer.from(t.xOnlyPubkey).equals(Y("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&t.parity===1),t=e.xOnlyPointAddTweak(Y("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),Y("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47")),ge(Buffer.from(t.xOnlyPubkey).equals(Y("9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"))&&t.parity===0),ge(Buffer.from(e.sign(Y("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),Y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))).equals(Y("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),ge(e.verify(Y("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),Y("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Y("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),e.signSchnorr&&ge(Buffer.from(e.signSchnorr(Y("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),Y("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),Y("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906"))).equals(Y("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),e.verifySchnorr&&ge(e.verifySchnorr(Y("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),Y("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),Y("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}lo.testEcc=H2;function ge(e){if(!e)throw new Error("ecc library invalid")}Object.defineProperty(wn,"__esModule",{value:!0});wn.ECPairFactory=wn.networks=void 0;const Ra=_n;wn.networks=Ra;const Je=al,D2=c1,nf=$2,j2=lo,ea=Je.typeforce.maybe(Je.typeforce.compile({compressed:Je.maybe(Je.Boolean),network:Je.maybe(Je.Network)})),G2=e=>e.length===32?e:e.slice(1,33);function z2(e){(0,j2.testEcc)(e);function t(a){return e.isPoint(a)}function r(a,c){if(Je.typeforce(Je.Buffer256bit,a),!e.isPrivate(a))throw new TypeError("Private key not in range [1, n)");return Je.typeforce(ea,c),new o(a,void 0,c)}function n(a,c){return Je.typeforce(e.isPoint,a),Je.typeforce(ea,c),new o(void 0,a,c)}function i(a,c){const f=nf.decode(a),l=f.version;if(Je.Array(c)){if(c=c.filter(h=>l===h.wif).pop(),!c)throw new Error("Unknown network version")}else if(c=c||Ra.bitcoin,l!==c.wif)throw new Error("Invalid network version");return r(f.privateKey,{compressed:f.compressed,network:c})}function s(a){Je.typeforce(ea,a),a===void 0&&(a={});const c=a.rng||D2;let f;do f=c(32),Je.typeforce(Je.Buffer256bit,f);while(!e.isPrivate(f));return r(f,a)}class o{constructor(c,f,l){Wr(this,"__D");Wr(this,"__Q");Wr(this,"compressed");Wr(this,"network");Wr(this,"lowR");this.__D=c,this.__Q=f,this.lowR=!1,l===void 0&&(l={}),this.compressed=l.compressed===void 0?!0:l.compressed,this.network=l.network||Ra.bitcoin,f!==void 0&&(this.__Q=Buffer.from(e.pointCompress(f,this.compressed)))}get privateKey(){return this.__D}get publicKey(){if(!this.__Q){const c=e.pointFromScalar(this.__D,this.compressed);this.__Q=Buffer.from(c)}return this.__Q}toWIF(){if(!this.__D)throw new Error("Missing private key");return nf.encode(this.network.wif,this.__D,this.compressed)}tweak(c){return this.privateKey?this.tweakFromPrivateKey(c):this.tweakFromPublicKey(c)}sign(c,f){if(!this.__D)throw new Error("Missing private key");if(f===void 0&&(f=this.lowR),f===!1)return Buffer.from(e.sign(c,this.__D));{let l=e.sign(c,this.__D);const h=Buffer.alloc(32,0);let y=0;for(;l[0]>127;)y++,h.writeUIntLE(y,0,6),l=e.sign(c,this.__D,h);return Buffer.from(l)}}signSchnorr(c){if(!this.privateKey)throw new Error("Missing private key");if(!e.signSchnorr)throw new Error("signSchnorr not supported by ecc library");return Buffer.from(e.signSchnorr(c,this.privateKey))}verify(c,f){return e.verify(c,this.publicKey,f)}verifySchnorr(c,f){if(!e.verifySchnorr)throw new Error("verifySchnorr not supported by ecc library");return e.verifySchnorr(c,this.publicKey.subarray(1,33),f)}tweakFromPublicKey(c){const f=G2(this.publicKey),l=e.xOnlyPointAddTweak(f,c);if(!l||l.xOnlyPubkey===null)throw new Error("Cannot tweak public key!");const h=Buffer.from([l.parity===0?2:3]);return n(Buffer.concat([h,l.xOnlyPubkey]),{network:this.network,compressed:this.compressed})}tweakFromPrivateKey(c){const l=this.publicKey[0]===3||this.publicKey[0]===4&&(this.publicKey[64]&1)===1?e.privateNegate(this.privateKey):this.privateKey,h=e.privateAdd(l,c);if(!h)throw new Error("Invalid tweaked private key!");return r(Buffer.from(h),{network:this.network,compressed:this.compressed})}}return{isPoint:t,fromPrivateKey:r,fromPublicKey:n,fromWIF:i,makeRandom:s}}wn.ECPairFactory=z2;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.networks=e.ECPairFactory=e.default=void 0;var t=wn;Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t.ECPairFactory}}),Object.defineProperty(e,"ECPairFactory",{enumerable:!0,get:function(){return t.ECPairFactory}}),Object.defineProperty(e,"networks",{enumerable:!0,get:function(){return t.networks}})})(ol);const q2=wm(ol);class Bi extends q.EventBroker{get isInitialized(){return!!this.digestKey}constructor(t,r){super(),this.digestKey=t,this.walletClient=r}static fromDigestKey(t){return new Bi(kr(t))}static fromWalletClient(t){return new Bi(void 0,t)}async initialize(){if(this.digestKey)return ie("Already initialized");const t=await this.deriveDigestKeyFromWalletClient();return t.error?G(t.error):(this.emit("initialized",!0),ie("Initialized"))}async deriveDigestKeyFromWalletClient(){if(!this.walletClient)return G("No walletClient found");if(!this.walletClient.account)return G("No account found");try{const t=await this.walletClient.signTypedData({account:this.walletClient.account,types:{EIP712Domain:[{name:"name",type:"string"},{name:"version",type:"string"}],Data:[{name:"Message",type:"string"},{name:"Version",type:"string"},{name:"Nonce",type:"uint256"}]},domain:{name:"GARDEN FINANCE",version:"1"},primaryType:"Data",message:{Message:"Initialize your account",Version:"1.0.2",Nonce:1n}});return this.digestKey=kr(Wn(t)),this.emit("initialized",!0),ie(this.digestKey)}catch(t){return G("Failed to initialize: "+t)}}async getDigestKey(){if(!this.digestKey&&!this.walletClient)return G("No private key or wallet client found");if(!this.digestKey&&this.walletClient){const t=await this.deriveDigestKeyFromWalletClient();if(t.error)return G(t.error)}return this.digestKey?ie(this.digestKey):G("No private key found")}async generateSecret(t){const r=await this.signMessage(t);if(r.error)return G(r.error);const n=Wn(q.with0x(r.val)),i=Wn(n);return ie({secret:n,secretHash:i})}async signMessage(t){if(!this.digestKey){const f=await this.getDigestKey();if(f.error)return G(f.error);this.digestKey=f.val}const r=q2(Or),n="Garden.fi"+t.toString(),i=Buffer.from(n,"utf8"),s=Wn(i),o=Buffer.from(kr(this.digestKey),"hex");if(o.length!==32)return G("Invalid private key length. Expected 32 bytes.");const c=r.fromPrivateKey(o).sign(Buffer.from(kr(s),"hex"));return ie(c.toString("hex"))}}const sf=[{inputs:[{internalType:"address",name:"token_",type:"address"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"version",type:"string"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"InvalidShortString",type:"error"},{inputs:[{internalType:"string",name:"str",type:"string"}],name:"StringTooLong",type:"error"},{anonymous:!1,inputs:[],name:"EIP712DomainChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"secretHash",type:"bytes32"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"Initiated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"secretHash",type:"bytes32"},{indexed:!1,internalType:"bytes",name:"secret",type:"bytes"}],name:"Redeemed",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"}],name:"Refunded",type:"event"},{inputs:[],name:"eip712Domain",outputs:[{internalType:"bytes1",name:"fields",type:"bytes1"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"version",type:"string"},{internalType:"uint256",name:"chainId",type:"uint256"},{internalType:"address",name:"verifyingContract",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"uint256[]",name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"redeemer",type:"address"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"secretHash",type:"bytes32"}],name:"initiate",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"redeemer",type:"address"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"secretHash",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"initiateWithSignature",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"instantRefund",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"redeemer",type:"address"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"secretHash",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],internalType:"struct HTLC.InitWithSig[]",name:"inits",type:"tuple[]"},{components:[{internalType:"bytes32",name:"orderID",type:"bytes32"},{internalType:"bytes",name:"secret",type:"bytes"}],internalType:"struct HTLC.Redeem[]",name:"redeems",type:"tuple[]"},{components:[{internalType:"bytes32",name:"orderID",type:"bytes32"}],internalType:"struct HTLC.Refund[]",name:"refunds",type:"tuple[]"}],name:"multicall",outputs:[{internalType:"bool[]",name:"results",type:"bool[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"",type:"bytes32"}],name:"orders",outputs:[{internalType:"bool",name:"isFulfilled",type:"bool"},{internalType:"address",name:"initiator",type:"address"},{internalType:"address",name:"redeemer",type:"address"},{internalType:"uint256",name:"initiatedAt",type:"uint256"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"},{internalType:"bytes",name:"secret",type:"bytes"}],name:"redeem",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"}],name:"refund",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"token",outputs:[{internalType:"contract IERC20",name:"",type:"address"}],stateMutability:"view",type:"function"}],V2={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}},W2={block:Qp({format(e){var r;return{transactions:(r=e.transactions)==null?void 0:r.map(n=>{if(typeof n=="string")return n;const i=Ja(n);return i.typeHex==="0x7e"&&(i.isSystemTx=n.isSystemTx,i.mint=n.mint?pt(n.mint):void 0,i.sourceHash=n.sourceHash,i.type="deposit"),i}),stateRoot:e.stateRoot}}}),transaction:Xp({format(e){const t={};return e.type==="0x7e"&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?pt(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:jy({format(e){return{l1GasPrice:e.l1GasPrice?pt(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?pt(e.l1GasUsed):null,l1Fee:e.l1Fee?pt(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null}}})};function K2(e,t){return J2(e)?X2(e):lm(e,t)}const Y2={transaction:K2};function X2(e){Q2(e);const{sourceHash:t,data:r,from:n,gas:i,isSystemTx:s,mint:o,to:a,value:c}=e,f=[t,n,a??"0x",o?J(o):"0x",c?J(c):"0x",i?J(i):"0x",s?"0x1":"0x",r??"0x"];return Ot(["0x7e",mr(f)])}function J2(e){return e.type==="deposit"||typeof e.sourceHash<"u"}function Q2(e){const{from:t,to:r}=e;if(t&&!Ue(t))throw new et({address:t});if(r&&!Ue(r))throw new et({address:r})}const En={contracts:V2,formatters:W2,serializers:Y2},Z2=wt({id:42161,name:"Arbitrum One",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://arbiscan.io",apiUrl:"https://api.arbiscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:7654707}}}),e_=wt({id:421614,name:"Arbitrum Sepolia",nativeCurrency:{name:"Arbitrum Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia-rollup.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://sepolia.arbiscan.io",apiUrl:"https://api-sepolia.arbiscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:81930}},testnet:!0}),qn=1,t_=wt({...En,id:8453,name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.base.org"]}},blockExplorers:{default:{name:"Basescan",url:"https://basescan.org",apiUrl:"https://api.basescan.org/api"}},contracts:{...En.contracts,disputeGameFactory:{[qn]:{address:"0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e"}},l2OutputOracle:{[qn]:{address:"0x56315b90c40730925ec5485cf004d835058518A0"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:5022},portal:{[qn]:{address:"0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",blockCreated:17482143}},l1StandardBridge:{[qn]:{address:"0x3154Cf16ccdb4C6d922629664174b904d80F2C35",blockCreated:17482143}}},sourceId:qn}),Vn=11155111,r_=wt({...En,id:84532,network:"base-sepolia",name:"Base Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.base.org"]}},blockExplorers:{default:{name:"Basescan",url:"https://sepolia.basescan.org",apiUrl:"https://api-sepolia.basescan.org/api"}},contracts:{...En.contracts,disputeGameFactory:{[Vn]:{address:"0xd6E6dBf4F7EA0ac412fD8b65ED297e64BB7a06E1"}},l2OutputOracle:{[Vn]:{address:"0x84457ca9D0163FbC4bbfe4Dfbb20ba46e48DF254"}},portal:{[Vn]:{address:"0x49f53e41452c74589e85ca1677426ba426459e85",blockCreated:4446677}},l1StandardBridge:{[Vn]:{address:"0xfd0Bf71F60660E2f608ed56e1659C450eB113120",blockCreated:4446677}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:1059647}},testnet:!0,sourceId:Vn}),n_=wt({id:80094,name:"Berachain",nativeCurrency:{decimals:18,name:"BERA Token",symbol:"BERA"},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:0},ensRegistry:{address:"0x5b22280886a2f5e09a49bea7e320eab0e5320e28",blockCreated:877007},ensUniversalResolver:{address:"0xddfb18888a9466688235887dec2a10c4f5effee9",blockCreated:877008}},rpcUrls:{default:{http:["https://rpc.berachain.com"]}},blockExplorers:{default:{name:"Berascan",url:"https://berascan.com"}},ensTlds:[".bera"],testnet:!1}),i_=wt({id:80084,name:"Berachain bArtio",nativeCurrency:{decimals:18,name:"BERA Token",symbol:"BERA"},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:109269},ensRegistry:{address:"0xB0eef18971290b333450586D33dcA6cE122651D2",blockCreated:7736794},ensUniversalResolver:{address:"0x41692Ef1EA0C79E6b73077E4A67572D2BDbD7057",blockCreated:7736795}},ensTlds:[".bera"],rpcUrls:{default:{http:["https://bartio.rpc.berachain.com"]}},blockExplorers:{default:{name:"Berachain bArtio Beratrail",url:"https://bartio.beratrail.io"}},testnet:!0}),s_=wt({id:5115,name:"Citrea Testnet",nativeCurrency:{name:"cBTC",symbol:"cBTC",decimals:18},rpcUrls:{default:{http:["https://rpc.testnet.citrea.xyz"]}},blockExplorers:{default:{name:"Citrea Explorer",url:"https://explorer.testnet.citrea.xyz",apiUrl:"https://explorer.testnet.citrea.xyz/api"}},testnet:!0}),o_=wt({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://eth.merkle.io"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io",apiUrl:"https://api.etherscan.io/api"}},contracts:{ensRegistry:{address:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},ensUniversalResolver:{address:"0xce01f8eee7E479C928F8919abD53E553a36CeF67",blockCreated:19258213},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}}),a_=wt({id:10143,name:"Monad Testnet",nativeCurrency:{name:"Testnet MON Token",symbol:"MON",decimals:18},rpcUrls:{default:{http:["https://testnet-rpc.monad.xyz"]}},blockExplorers:{default:{name:"Monad Testnet explorer",url:"https://testnet.monadexplorer.com"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:251449}},testnet:!0}),c_=wt({id:11155111,name:"Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.drpc.org"]}},blockExplorers:{default:{name:"Etherscan",url:"https://sepolia.etherscan.io",apiUrl:"https://api-sepolia.etherscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:751532},ensRegistry:{address:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},ensUniversalResolver:{address:"0xc8Af999e38273D658BE1b921b88A9Ddf005769cC",blockCreated:5317080}},testnet:!0}),cs=1,u_=wt({...En,id:130,name:"Unichain",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.unichain.org/"]}},blockExplorers:{default:{name:"Uniscan",url:"https://uniscan.xyz",apiUrl:"https://api.uniscan.xyz/api"}},contracts:{...En.contracts,multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:0},disputeGameFactory:{[cs]:{address:"0x2F12d621a16e2d3285929C9996f478508951dFe4"}},portal:{[cs]:{address:"0x0bd48f6B86a26D3a217d0Fa6FfE2B491B956A7a2"}},l1StandardBridge:{[cs]:{address:"0x81014F44b0a345033bB2b3B21C7a1A308B35fEeA"}}},sourceId:cs}),f_={...c_,rpcUrls:{default:{http:["https://ethereum-sepolia-rpc.publicnode.com"]}}},Gl={id:998,name:"Hyperliquid EVM Testnet",nativeCurrency:{name:"Hyperliquid",symbol:"HYPE",decimals:18},blockExplorers:{default:{name:"Hyperliquid Explorer",url:"https://testnet.purrsec.com/"}},rpcUrls:{default:{http:["https://rpc.hyperliquid-testnet.xyz/evm"]}}},zl={id:999,name:"HyperEVM",nativeCurrency:{name:"Hyperliquid",symbol:"HYPE",decimals:18},blockExplorers:{default:{name:"Hyperliquid Explorer",url:"https://hyperscan.gas.zip/"}},rpcUrls:{default:{http:["https://rpc.hyperliquid.xyz/evm"]}}},ql={ethereum:o_,arbitrum:Z2,ethereum_sepolia:f_,arbitrum_sepolia:e_,ethereum_localnet:le.EthereumLocalnet,arbitrum_localnet:le.ArbitrumLocalnet,base_sepolia:r_,base:t_,bera_testnet:i_,citrea_testnet:s_,bera:n_,monad_testnet:a_,hyperliquid_testnet:Gl,hyperliquid:zl,unichan:u_},Vl=async(e,t)=>{var n,i,s,o;const r=ql[e];if(r)try{if(r.id===((n=t.chain)==null?void 0:n.id))return ie({message:"Already on the network",walletClient:t});await t.switchChain({id:r.id});const a=Io({account:t.account,chain:r,transport:nu(t.transport)});return ie({message:"Switched chain",walletClient:a})}catch(a){if(d_(a))if(a.code===4902)try{await t.addChain({chain:r});const c=Io({account:t.account,chain:r,transport:nu(t.transport)});return ie({message:"Added network",walletClient:c})}catch{return G("Failed to add network")}else if((s=(i=a.body)==null?void 0:i.method)!=null&&s.includes("wallet_switchEthereumChain")||(o=a.message)!=null&&o.includes("wallet_switchEthereumChain")){const c=Io({account:t.account,chain:r,transport:em()});return ie({message:"Added network",walletClient:c})}else return G("Failed to switch network");else return G("Failed to switch network")}else return G("Chain not supported")},d_=e=>typeof e=="object"&&e!=null&&("code"in e||"message"in e||"body"in e),l_=[{inputs:[{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"version",type:"string"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"InvalidShortString",type:"error"},{inputs:[],name:"NativeHTLC__DuplicateOrder",type:"error"},{inputs:[],name:"NativeHTLC__IncorrectFundsRecieved",type:"error"},{inputs:[],name:"NativeHTLC__IncorrectSecret",type:"error"},{inputs:[],name:"NativeHTLC__InsufficientBalance",type:"error"},{inputs:[],name:"NativeHTLC__InvalidRedeemerSignature",type:"error"},{inputs:[],name:"NativeHTLC__OrderFulfilled",type:"error"},{inputs:[],name:"NativeHTLC__OrderNotExpired",type:"error"},{inputs:[],name:"NativeHTLC__OrderNotInitiated",type:"error"},{inputs:[],name:"NativeHTLC__SameInitiatorAndRedeemer",type:"error"},{inputs:[],name:"NativeHTLC__ZeroAddressInitiator",type:"error"},{inputs:[],name:"NativeHTLC__ZeroAddressRedeemer",type:"error"},{inputs:[],name:"NativeHTLC__ZeroAmount",type:"error"},{inputs:[],name:"NativeHTLC__ZeroTimelock",type:"error"},{inputs:[{internalType:"string",name:"str",type:"string"}],name:"StringTooLong",type:"error"},{anonymous:!1,inputs:[],name:"EIP712DomainChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"secretHash",type:"bytes32"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"Initiated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"secretHash",type:"bytes32"},{indexed:!1,internalType:"bytes",name:"secret",type:"bytes"}],name:"Redeemed",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"}],name:"Refunded",type:"event"},{inputs:[],name:"eip712Domain",outputs:[{internalType:"bytes1",name:"fields",type:"bytes1"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"version",type:"string"},{internalType:"uint256",name:"chainId",type:"uint256"},{internalType:"address",name:"verifyingContract",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"uint256[]",name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address payable",name:"redeemer",type:"address"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"secretHash",type:"bytes32"}],name:"initiate",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address payable",name:"initiator",type:"address"},{internalType:"address payable",name:"redeemer",type:"address"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"secretHash",type:"bytes32"}],name:"initiateOnBehalf",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"instantRefund",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"}],name:"instantRefundDigest",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"",type:"bytes32"}],name:"orders",outputs:[{internalType:"bool",name:"isFulfilled",type:"bool"},{internalType:"address payable",name:"initiator",type:"address"},{internalType:"address payable",name:"redeemer",type:"address"},{internalType:"uint256",name:"initiatedAt",type:"uint256"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"},{internalType:"bytes",name:"secret",type:"bytes"}],name:"redeem",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"}],name:"refund",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"token",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"}];class Wl{constructor(t,r,n){this.url=new q.Url("/relayer",t),this.auth=n,this.wallet=r}get htlcActorAddress(){if(!this.wallet.account)throw new Error("No account found");return this.wallet.account.address}async initiate(t){if(!this.wallet.account)return q.Err("No account found");if(this.wallet.account.address.toLowerCase()!==t.source_swap.initiator.toLowerCase())return q.Err("Account address and order initiator mismatch");if(!le.isEVM(t.source_swap.chain))return q.Err("Source chain is not an EVM chain");const r=await Vl(t.source_swap.chain,this.wallet);if(r.error)return q.Err(r.error);if(this.wallet=r.val.walletClient,!this.wallet.account)return q.Err("No account found");const{create_order:n,source_swap:i}=t;if(!i.amount||!i.redeemer||!n.timelock||!n.secret_hash)return q.Err("Invalid order");const s=q.with0x(n.secret_hash),o=BigInt(n.timelock),a=q.with0x(i.redeemer),c=BigInt(i.amount),f=await this.getTokenAddress(t.source_swap.asset);return f.ok?le.isEvmNativeToken(t.source_swap.chain,f.val)?this._initiateOnNativeHTLC(s,o,c,a,t.source_swap.asset):this._initiateOnErc20HTLC(s,o,c,a,t.source_swap.asset,f.val,n.create_id):q.Err(f.error)}async getTokenAddress(t){try{const n=await So({address:q.with0x(t),abi:sf,client:this.wallet}).read.token();return q.Ok(n)}catch(r){return q.Err("Failed to get token address",String(r))}}async _initiateOnNativeHTLC(t,r,n,i,s){if(!this.wallet.account)return q.Err("No account found");try{const a=await So({address:q.with0x(s),abi:l_,client:this.wallet}).write.initiate([i,r,n,t],{account:this.wallet.account,chain:this.wallet.chain,value:n});return q.Ok(a)}catch(o){return q.Err("Failed to initiate on native HTLC",String(o))}}async _initiateOnErc20HTLC(t,r,n,i,s,o,a){if(!this.wallet.account)return q.Err("No account found");try{const c=await this.auth.getAuthHeaders();if(c.error)return q.Err(c.error);const f=So({address:q.with0x(s),abi:sf,client:this.wallet}),l=await q.checkAllowanceAndApprove(Number(n),o,s,this.wallet);if(l.error)return q.Err(l.error);const h=await f.read.eip712Domain(),y=await this.wallet.signTypedData({account:this.wallet.account,domain:{name:h[1],version:h[2],chainId:Number(h[3]),verifyingContract:h[4]},types:{Initiate:[{name:"redeemer",type:"address"},{name:"timelock",type:"uint256"},{name:"amount",type:"uint256"},{name:"secretHash",type:"bytes32"}]},primaryType:"Initiate",message:{redeemer:i,timelock:r,amount:n,secretHash:t}}),p={...c.val,"Content-Type":"application/json"},g=await Dt.post(this.url.endpoint("initiate"),{body:JSON.stringify({order_id:a,signature:y,perform_on:"Source"}),headers:p});return g.error?q.Err(g.error):g.result?q.Ok(g.result):q.Err("Init: No result found")}catch(c){return console.log("init error :",c),q.Err(String(c))}}async redeem(t,r){try{const n=await this.auth.getAuthHeaders();if(n.error)return q.Err(n.error);const i=await Dt.post(this.url.endpoint("redeem"),{body:JSON.stringify({order_id:t.create_order.create_id,secret:kr(r),perform_on:"Destination"}),headers:{...n.val,"Content-Type":"application/json"}});return i.error?q.Err(i.error):i.result?q.Ok(i.result):q.Err("Redeem: No result found")}catch(n){return q.Err(String(n))}}async refund(){return q.Err("Refund not supported")}}const Kl=[{name:"LockingContract",type:"impl",interface_name:"src::mintable_lock_interface::ILockingContract"},{name:"src::mintable_lock_interface::ILockingContract",type:"interface",items:[{name:"set_locking_contract",type:"function",inputs:[{name:"locking_contract",type:"core::starknet::contract_address::ContractAddress"}],outputs:[],state_mutability:"external"},{name:"get_locking_contract",type:"function",inputs:[],outputs:[{type:"core::starknet::contract_address::ContractAddress"}],state_mutability:"view"}]},{name:"LockAndDelegate",type:"impl",interface_name:"src::mintable_lock_interface::ILockAndDelegate"},{name:"core::integer::u256",type:"struct",members:[{name:"low",type:"core::integer::u128"},{name:"high",type:"core::integer::u128"}]},{name:"src::mintable_lock_interface::ILockAndDelegate",type:"interface",items:[{name:"lock_and_delegate",type:"function",inputs:[{name:"delegatee",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[],state_mutability:"external"},{name:"lock_and_delegate_by_sig",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"},{name:"delegatee",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"},{name:"nonce",type:"core::felt252"},{name:"expiry",type:"core::integer::u64"},{name:"signature",type:"core::array::Array::<core::felt252>"}],outputs:[],state_mutability:"external"}]},{name:"MintableToken",type:"impl",interface_name:"src::mintable_token_interface::IMintableToken"},{name:"src::mintable_token_interface::IMintableToken",type:"interface",items:[{name:"permissioned_mint",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[],state_mutability:"external"},{name:"permissioned_burn",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[],state_mutability:"external"}]},{name:"MintableTokenCamelImpl",type:"impl",interface_name:"src::mintable_token_interface::IMintableTokenCamel"},{name:"src::mintable_token_interface::IMintableTokenCamel",type:"interface",items:[{name:"permissionedMint",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[],state_mutability:"external"},{name:"permissionedBurn",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[],state_mutability:"external"}]},{name:"Replaceable",type:"impl",interface_name:"src::replaceability_interface::IReplaceable"},{name:"core::array::Span::<core::felt252>",type:"struct",members:[{name:"snapshot",type:"@core::array::Array::<core::felt252>"}]},{name:"src::replaceability_interface::EICData",type:"struct",members:[{name:"eic_hash",type:"core::starknet::class_hash::ClassHash"},{name:"eic_init_data",type:"core::array::Span::<core::felt252>"}]},{name:"core::option::Option::<src::replaceability_interface::EICData>",type:"enum",variants:[{name:"Some",type:"src::replaceability_interface::EICData"},{name:"None",type:"()"}]},{name:"core::bool",type:"enum",variants:[{name:"False",type:"()"},{name:"True",type:"()"}]},{name:"src::replaceability_interface::ImplementationData",type:"struct",members:[{name:"impl_hash",type:"core::starknet::class_hash::ClassHash"},{name:"eic_data",type:"core::option::Option::<src::replaceability_interface::EICData>"},{name:"final",type:"core::bool"}]},{name:"src::replaceability_interface::IReplaceable",type:"interface",items:[{name:"get_upgrade_delay",type:"function",inputs:[],outputs:[{type:"core::integer::u64"}],state_mutability:"view"},{name:"get_impl_activation_time",type:"function",inputs:[{name:"implementation_data",type:"src::replaceability_interface::ImplementationData"}],outputs:[{type:"core::integer::u64"}],state_mutability:"view"},{name:"add_new_implementation",type:"function",inputs:[{name:"implementation_data",type:"src::replaceability_interface::ImplementationData"}],outputs:[],state_mutability:"external"},{name:"remove_implementation",type:"function",inputs:[{name:"implementation_data",type:"src::replaceability_interface::ImplementationData"}],outputs:[],state_mutability:"external"},{name:"replace_to",type:"function",inputs:[{name:"implementation_data",type:"src::replaceability_interface::ImplementationData"}],outputs:[],state_mutability:"external"}]},{name:"AccessControlImplExternal",type:"impl",interface_name:"src::access_control_interface::IAccessControl"},{name:"src::access_control_interface::IAccessControl",type:"interface",items:[{name:"has_role",type:"function",inputs:[{name:"role",type:"core::felt252"},{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[{type:"core::bool"}],state_mutability:"view"},{name:"get_role_admin",type:"function",inputs:[{name:"role",type:"core::felt252"}],outputs:[{type:"core::felt252"}],state_mutability:"view"}]},{name:"RolesImpl",type:"impl",interface_name:"src::roles_interface::IMinimalRoles"},{name:"src::roles_interface::IMinimalRoles",type:"interface",items:[{name:"is_governance_admin",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[{type:"core::bool"}],state_mutability:"view"},{name:"is_upgrade_governor",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[{type:"core::bool"}],state_mutability:"view"},{name:"register_governance_admin",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[],state_mutability:"external"},{name:"remove_governance_admin",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[],state_mutability:"external"},{name:"register_upgrade_governor",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[],state_mutability:"external"},{name:"remove_upgrade_governor",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[],state_mutability:"external"},{name:"renounce",type:"function",inputs:[{name:"role",type:"core::felt252"}],outputs:[],state_mutability:"external"}]},{name:"ERC20Impl",type:"impl",interface_name:"openzeppelin::token::erc20::interface::IERC20"},{name:"openzeppelin::token::erc20::interface::IERC20",type:"interface",items:[{name:"name",type:"function",inputs:[],outputs:[{type:"core::felt252"}],state_mutability:"view"},{name:"symbol",type:"function",inputs:[],outputs:[{type:"core::felt252"}],state_mutability:"view"},{name:"decimals",type:"function",inputs:[],outputs:[{type:"core::integer::u8"}],state_mutability:"view"},{name:"total_supply",type:"function",inputs:[],outputs:[{type:"core::integer::u256"}],state_mutability:"view"},{name:"balance_of",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[{type:"core::integer::u256"}],state_mutability:"view"},{name:"allowance",type:"function",inputs:[{name:"owner",type:"core::starknet::contract_address::ContractAddress"},{name:"spender",type:"core::starknet::contract_address::ContractAddress"}],outputs:[{type:"core::integer::u256"}],state_mutability:"view"},{name:"transfer",type:"function",inputs:[{name:"recipient",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"},{name:"transfer_from",type:"function",inputs:[{name:"sender",type:"core::starknet::contract_address::ContractAddress"},{name:"recipient",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"},{name:"approve",type:"function",inputs:[{name:"spender",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"}]},{name:"ERC20CamelOnlyImpl",type:"impl",interface_name:"openzeppelin::token::erc20::interface::IERC20CamelOnly"},{name:"openzeppelin::token::erc20::interface::IERC20CamelOnly",type:"interface",items:[{name:"totalSupply",type:"function",inputs:[],outputs:[{type:"core::integer::u256"}],state_mutability:"view"},{name:"balanceOf",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[{type:"core::integer::u256"}],state_mutability:"view"},{name:"transferFrom",type:"function",inputs:[{name:"sender",type:"core::starknet::contract_address::ContractAddress"},{name:"recipient",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"}]},{name:"constructor",type:"constructor",inputs:[{name:"name",type:"core::felt252"},{name:"symbol",type:"core::felt252"},{name:"decimals",type:"core::integer::u8"},{name:"initial_supply",type:"core::integer::u256"},{name:"recipient",type:"core::starknet::contract_address::ContractAddress"},{name:"permitted_minter",type:"core::starknet::contract_address::ContractAddress"},{name:"provisional_governance_admin",type:"core::starknet::contract_address::ContractAddress"},{name:"upgrade_delay",type:"core::integer::u64"}]},{name:"increase_allowance",type:"function",inputs:[{name:"spender",type:"core::starknet::contract_address::ContractAddress"},{name:"added_value",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"},{name:"decrease_allowance",type:"function",inputs:[{name:"spender",type:"core::starknet::contract_address::ContractAddress"},{name:"subtracted_value",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"},{name:"increaseAllowance",type:"function",inputs:[{name:"spender",type:"core::starknet::contract_address::ContractAddress"},{name:"addedValue",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"},{name:"decreaseAllowance",type:"function",inputs:[{name:"spender",type:"core::starknet::contract_address::ContractAddress"},{name:"subtractedValue",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"},{kind:"struct",name:"src::strk::erc20_lockable::ERC20Lockable::Transfer",type:"event",members:[{kind:"data",name:"from",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"to",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"value",type:"core::integer::u256"}]},{kind:"struct",name:"src::strk::erc20_lockable::ERC20Lockable::Approval",type:"event",members:[{kind:"data",name:"owner",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"spender",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"value",type:"core::integer::u256"}]},{kind:"struct",name:"src::replaceability_interface::ImplementationAdded",type:"event",members:[{kind:"data",name:"implementation_data",type:"src::replaceability_interface::ImplementationData"}]},{kind:"struct",name:"src::replaceability_interface::ImplementationRemoved",type:"event",members:[{kind:"data",name:"implementation_data",type:"src::replaceability_interface::ImplementationData"}]},{kind:"struct",name:"src::replaceability_interface::ImplementationReplaced",type:"event",members:[{kind:"data",name:"implementation_data",type:"src::replaceability_interface::ImplementationData"}]},{kind:"struct",name:"src::replaceability_interface::ImplementationFinalized",type:"event",members:[{kind:"data",name:"impl_hash",type:"core::starknet::class_hash::ClassHash"}]},{kind:"struct",name:"src::access_control_interface::RoleGranted",type:"event",members:[{kind:"data",name:"role",type:"core::felt252"},{kind:"data",name:"account",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"sender",type:"core::starknet::contract_address::ContractAddress"}]},{kind:"struct",name:"src::access_control_interface::RoleRevoked",type:"event",members:[{kind:"data",name:"role",type:"core::felt252"},{kind:"data",name:"account",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"sender",type:"core::starknet::contract_address::ContractAddress"}]},{kind:"struct",name:"src::access_control_interface::RoleAdminChanged",type:"event",members:[{kind:"data",name:"role",type:"core::felt252"},{kind:"data",name:"previous_admin_role",type:"core::felt252"},{kind:"data",name:"new_admin_role",type:"core::felt252"}]},{kind:"struct",name:"src::roles_interface::GovernanceAdminAdded",type:"event",members:[{kind:"data",name:"added_account",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"added_by",type:"core::starknet::contract_address::ContractAddress"}]},{kind:"struct",name:"src::roles_interface::GovernanceAdminRemoved",type:"event",members:[{kind:"data",name:"removed_account",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"removed_by",type:"core::starknet::contract_address::ContractAddress"}]},{kind:"struct",name:"src::roles_interface::UpgradeGovernorAdded",type:"event",members:[{kind:"data",name:"added_account",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"added_by",type:"core::starknet::contract_address::ContractAddress"}]},{kind:"struct",name:"src::roles_interface::UpgradeGovernorRemoved",type:"event",members:[{kind:"data",name:"removed_account",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"removed_by",type:"core::starknet::contract_address::ContractAddress"}]},{kind:"enum",name:"src::strk::erc20_lockable::ERC20Lockable::Event",type:"event",variants:[{kind:"nested",name:"Transfer",type:"src::strk::erc20_lockable::ERC20Lockable::Transfer"},{kind:"nested",name:"Approval",type:"src::strk::erc20_lockable::ERC20Lockable::Approval"},{kind:"nested",name:"ImplementationAdded",type:"src::replaceability_interface::ImplementationAdded"},{kind:"nested",name:"ImplementationRemoved",type:"src::replaceability_interface::ImplementationRemoved"},{kind:"nested",name:"ImplementationReplaced",type:"src::replaceability_interface::ImplementationReplaced"},{kind:"nested",name:"ImplementationFinalized",type:"src::replaceability_interface::ImplementationFinalized"},{kind:"nested",name:"RoleGranted",type:"src::access_control_interface::RoleGranted"},{kind:"nested",name:"RoleRevoked",type:"src::access_control_interface::RoleRevoked"},{kind:"nested",name:"RoleAdminChanged",type:"src::access_control_interface::RoleAdminChanged"},{kind:"nested",name:"GovernanceAdminAdded",type:"src::roles_interface::GovernanceAdminAdded"},{kind:"nested",name:"GovernanceAdminRemoved",type:"src::roles_interface::GovernanceAdminRemoved"},{kind:"nested",name:"UpgradeGovernorAdded",type:"src::roles_interface::UpgradeGovernorAdded"},{kind:"nested",name:"UpgradeGovernorRemoved",type:"src::roles_interface::UpgradeGovernorRemoved"}]}],h_=async(e,t,r,n,i)=>{try{const s=await Fa(e.address,t,r,i);if(s.error)return G(s.error);const o=Oe.cairo.uint256(BigInt(Oe.uint256.UINT_256_MAX));if(s.val<n){const a=await e.execute([{contractAddress:nn(t),entrypoint:"approve",calldata:[r,o.low,o.high]}]);await i.waitForTransaction(a.transaction_hash,{retryInterval:3e3,successStates:[Oe.TransactionExecutionStatus.SUCCEEDED]}),await q.sleep(2e3);let c=0n;for(let f=0;f<20;f++){const l=await Fa(e.address,t,r,i);if(l.error)return G(l.error);if(c=l.val,c>=n)break;await q.sleep(2e3)}return c<n?G("Allowance not approved"):ie(a.transaction_hash)}return ie("Allowance already approved")}catch(s){return G(`Failed to check or approve allowance: ${s instanceof Error?s.message:String(s)}`)}},Fa=async(e,t,r,n)=>{try{const s=await new Oe.Contract(Kl,nn(t),n).call("allowance",[nn(e),nn(r)]);return ie(BigInt((s==null?void 0:s.toString())||"0"))}catch(i){return G(`Failed to check allowance: ${i instanceof Error?i.message:String(i)}`)}},p_=async(e,t,r,n,i)=>{const s=await Fa(e,t,r,n);return s.error?G(s.error):ie(s.val>=i)},Yl=[{name:"HTLC",type:"impl",interface_name:"starknet_htlc::interface::IHTLC"},{name:"core::integer::u256",type:"struct",members:[{name:"low",type:"core::integer::u128"},{name:"high",type:"core::integer::u128"}]},{name:"starknet_htlc::interface::IHTLC",type:"interface",items:[{name:"token",type:"function",inputs:[],outputs:[{type:"core::starknet::contract_address::ContractAddress"}],state_mutability:"view"},{name:"initiate",type:"function",inputs:[{name:"redeemer",type:"core::starknet::contract_address::ContractAddress"},{name:"timelock",type:"core::integer::u128"},{name:"amount",type:"core::integer::u256"},{name:"secret_hash",type:"[core::integer::u32; 8]"}],outputs:[],state_mutability:"external"},{name:"initiate_on_behalf",type:"function",inputs:[{name:"initiator",type:"core::starknet::contract_address::ContractAddress"},{name:"redeemer",type:"core::starknet::contract_address::ContractAddress"},{name:"timelock",type:"core::integer::u128"},{name:"amount",type:"core::integer::u256"},{name:"secret_hash",type:"[core::integer::u32; 8]"}],outputs:[],state_mutability:"external"},{name:"initiate_with_signature",type:"function",inputs:[{name:"initiator",type:"core::starknet::contract_address::ContractAddress"},{name:"redeemer",type:"core::starknet::contract_address::ContractAddress"},{name:"timelock",type:"core::integer::u128"},{name:"amount",type:"core::integer::u256"},{name:"secret_hash",type:"[core::integer::u32; 8]"},{name:"signature",type:"core::array::Array::<core::felt252>"}],outputs:[],state_mutability:"external"},{name:"redeem",type:"function",inputs:[{name:"order_id",type:"core::felt252"},{name:"secret",type:"core::array::Array::<core::integer::u32>"}],outputs:[],state_mutability:"external"},{name:"refund",type:"function",inputs:[{name:"order_id",type:"core::felt252"}],outputs:[],state_mutability:"external"},{name:"instant_refund",type:"function",inputs:[{name:"order_id",type:"core::felt252"},{name:"signature",type:"core::array::Array::<core::felt252>"}],outputs:[],state_mutability:"external"}]},{name:"constructor",type:"constructor",inputs:[{name:"token",type:"core::starknet::contract_address::ContractAddress"}]},{kind:"struct",name:"starknet_htlc::interface::events::Initiated",type:"event",members:[{kind:"key",name:"order_id",type:"core::felt252"},{kind:"data",name:"secret_hash",type:"[core::integer::u32; 8]"},{kind:"data",name:"amount",type:"core::integer::u256"}]},{kind:"struct",name:"starknet_htlc::interface::events::Redeemed",type:"event",members:[{kind:"key",name:"order_id",type:"core::felt252"},{kind:"data",name:"secret_hash",type:"[core::integer::u32; 8]"},{kind:"data",name:"secret",type:"core::array::Array::<core::integer::u32>"}]},{kind:"struct",name:"starknet_htlc::interface::events::Refunded",type:"event",members:[{kind:"key",name:"order_id",type:"core::felt252"}]},{kind:"enum",name:"starknet_htlc::htlc::HTLC::Event",type:"event",variants:[{kind:"nested",name:"Initiated",type:"starknet_htlc::interface::events::Initiated"},{kind:"nested",name:"Redeemed",type:"starknet_htlc::interface::events::Redeemed"},{kind:"nested",name:"Refunded",type:"starknet_htlc::interface::events::Refunded"}]}],y_={StarknetDomain:[{name:"name",type:"shortstring"},{name:"version",type:"shortstring"},{name:"chainId",type:"shortstring"},{name:"revision",type:"shortstring"}],Initiate:[{name:"redeemer",type:"ContractAddress"},{name:"amount",type:"u256"},{name:"timelock",type:"u128"},{name:"secretHash",type:"u128*"}]};class Xl{constructor(t,r,n,i){this.url=t instanceof q.Url?t:new q.Url(t),this.account=r,this.starknetProvider=new Oe.RpcProvider({nodeUrl:i||Si[n].nodeUrl}),this.chainId=Si[n].chainId}get htlcActorAddress(){if(!this.account.address)throw new Error("No account found");return this.account.address}async initiate(t){if(!this.account.address)return G("No account address");const{create_order:r,source_swap:n}=t,{redeemer:i,amount:s}=n;if(!s||!i||!r.secret_hash||!r.timelock)return G("Invalid order");try{const o=new Oe.Contract(Yl,t.source_swap.asset,this.account),a=await(o==null?void 0:o.token()),c=Oe.num.toHex(a),f=await p_(this.account.address,c,n.asset,this.starknetProvider,BigInt(s));return f.error?G(f.error):f.val?this.initiateRelay(t):this.approveAndInitiate(c,t)}catch(o){return G(String(o))}}async approveAndInitiate(t,r){const{create_order:n,source_swap:i}=r,{redeemer:s,amount:o}=i,{secret_hash:a,timelock:c}=n,f=i.asset;try{const l=Oe.cairo.uint256(BigInt(Oe.uint256.UINT_256_MAX)),h={contractAddress:nn(t),entrypoint:"approve",calldata:[f,l.low,l.high]},y=Oe.cairo.uint256(o),p={contractAddress:nn(f),entrypoint:"initiate",calldata:[s,c.toString(),y.low.toString(),y.high.toString(),...q.hexToU32Array(a)]},g=await this.account.execute([h,p]);return await this.starknetProvider.waitForTransaction(g.transaction_hash,{retryInterval:2e3,successStates:[Oe.TransactionExecutionStatus.SUCCEEDED]}),ie(g.transaction_hash)}catch(l){return G(`Failed to approve and initiate: ${String(l)}`)}}async initiateRelay(t){const{create_order:r,source_swap:n}=t,{redeemer:i,amount:s}=n,a={domain:{name:"HTLC",version:Oe.shortString.encodeShortString("1"),chainId:this.chainId,revision:Oe.TypedDataRevision.ACTIVE},primaryType:"Initiate",types:y_,message:{redeemer:i,amount:Oe.cairo.uint256(s),timelock:r.timelock,secretHash:q.hexToU32Array(r.secret_hash)}};try{const c=await this.account.signMessage(a),f=ob(c);if(f.error)return G(f.error);const l=await Dt.post(this.url.endpoint("initiate"),{body:JSON.stringify({order_id:r.create_id,signature:f.val,perform_on:"Source"}),headers:{"Content-Type":"application/json"},retryCount:10,retryDelay:2e3});return l.error?G(l.error):l.result?ie(l.result):G("Init: No result found")}catch(c){return G(`Failed to initiate relayer: ${String(c)}`)}}async redeem(t,r){try{const n=await Dt.post(this.url.endpoint("redeem"),{body:JSON.stringify({order_id:t.create_order.create_id,secret:r,perform_on:"Destination"}),headers:{"Content-Type":"application/json"},retryCount:10,retryDelay:2e3});return n.error?G(n.error):n.result?ie(n.result):G("Redeem: No result found")}catch(n){return G(String(n))}}async refund(){return G("Refund is taken care of by the relayer")}}class kc extends q.EventBroker{constructor(t){super(),this.environment=q.Environment.TESTNET,this.getOrderThreshold=20,this.refundSacpCache=new Map,this.bitcoinRedeemCache=new n1;const{api:r,environment:n}=au(t.environment);if(this.environment=n,this._api=r,typeof t.digestKey=="string"){const s=q.DigestKey.from(t.digestKey);if(!s.ok)throw new Error(s.error);this._digestKey=s.val}else this._digestKey=t.digestKey;this._quote=t.quote??new sl(this._api.quote),this._auth=t.auth??q.Siwe.fromDigestKey(new q.Url(this._api.auth),this._digestKey),this._orderbook=t.orderbook??new le.Orderbook(new q.Url(this._api.orderbook)),this._evmHTLC=t.htlc.evm,this._starknetHTLC=t.htlc.starknet,this._secretManager=t.secretManager??Bi.fromDigestKey(this._digestKey.digestKey),this.orderExecutorCache=new r1,this._blockNumberFetcher=t.blockNumberFetcher??new il(this._api.info,this.environment);const i=new ln.BitcoinProvider(ib(this.environment));this._btcWallet=ln.BitcoinWallet.fromPrivateKey(this._digestKey.digestKey,i)}static fromWallets(t){let r;if(typeof t.digestKey=="string"){const s=q.DigestKey.from(t.digestKey);if(!s.ok)throw new Error(s.error);r=s.val}else r=t.digestKey;const{api:n}=au(t.environment);if(!n)throw new Error("API not found, invalid environment "+t.environment);const i={evm:t.wallets.evm?new Wl(n.evmRelay,t.wallets.evm,q.Siwe.fromDigestKey(new q.Url(n.auth),r)):void 0,starknet:t.wallets.starknet?new Xl(n.starknetRelay,t.wallets.starknet,t.environment===q.Environment.MAINNET?q.Network.MAINNET:q.Network.TESTNET):void 0};return new kc({htlc:i,...t})}get evmHTLC(){return this._evmHTLC}get starknetHTLC(){return this._starknetHTLC}get quote(){return this._quote}get btcWallet(){return this._btcWallet}get orderbook(){return this._orderbook}get blockNumberFetcher(){return this._blockNumberFetcher}get secretManager(){return this._secretManager}get auth(){return this._auth}get digestKey(){return this._digestKey}async swap(t){const r=await this.validateAndFillParams(t);if(r.error)return G(r.error);const{sendAddress:n,receiveAddress:i,timelock:s}=r.val,o=Date.now().toString(),a=await this._secretManager.generateSecret(o);if(a.error)return G(a.error);const{strategyId:c,btcAddress:f}=t.additionalData,l={strategy_id:c,...f&&{bitcoin_optional_recipient:f}},h={source_chain:t.fromAsset.chain,destination_chain:t.toAsset.chain,source_asset:t.fromAsset.atomicSwapAddress,destination_asset:t.toAsset.atomicSwapAddress,initiator_source_address:n,initiator_destination_address:i,source_amount:t.sendAmount,destination_amount:t.receiveAmount,fee:"1",nonce:o,timelock:s,secret_hash:kr(a.val.secretHash),min_destination_confirmations:t.minDestinationConfirmations??0,additional_data:l,affiliate_fees:this.withDefaultAffiliateFees(t.affiliateFee)},y=await this._quote.getAttestedQuote(h);if(y.error)return G(y.error);const p=await this._orderbook.createOrder(y.val,this.auth);if(p.error)return G(p.error);const g=await this.pollOrder(p.val);return g.error?G(g.error):ie(g.val)}withDefaultAffiliateFees(t){return(t??[]).map(r=>({fee:r.fee,address:r.address,chain:r.chain??ou.chain,asset:r.asset??ou.asset}))}async validateAndFillParams(t){if(!t.additionalData.strategyId)return G("StrategyId is required");if(!t.fromAsset||!t.toAsset)return G("Source and destination assets are required for swap");if(t.fromAsset.chain===t.toAsset.chain&&t.fromAsset.atomicSwapAddress===t.toAsset.atomicSwapAddress)return G("Source and destination assets cannot be the same");if(le.isMainnet(t.fromAsset.chain)&&!le.isMainnet(t.toAsset.chain)||!le.isMainnet(t.fromAsset.chain)&&le.isMainnet(t.toAsset.chain))return G("Both assets should be on the same network (either mainnet or testnet)");const r=this.validateAmount(t.sendAmount);if(r.error)return G(r.error);const n=this.validateAmount(t.receiveAmount);if(n.error)return G(n.error);if(r<n)return G("Send amount should be greater than receive amount");const i=le.getTimeLock(t.fromAsset.chain);if(!i)return G("Unsupported chain for timelock");if((le.isBitcoin(t.fromAsset.chain)||le.isBitcoin(t.toAsset.chain))&&!t.additionalData.btcAddress)return G("btcAddress in additionalData is required if source or destination chain is bitcoin, it is used as refund or redeem address.");const s=await this.getAddresses(t.fromAsset.chain);if(s.error)return G(s.error);const o=await this.getAddresses(t.toAsset.chain);return o.error?G(o.error):ie({sendAddress:s.val,receiveAddress:o.val,timelock:t.timelock??i})}async getAddresses(t){var n;switch(le.getBlockchainType(t)){case le.BlockchainType.EVM:return this._evmHTLC?ie(this._evmHTLC.htlcActorAddress):G("Please provide evmHTLC when initializing garden");case le.BlockchainType.Bitcoin:{const i=await((n=this._btcWallet)==null?void 0:n.getPublicKey());return!i||!rb(i)?G("Invalid btc public key"):ie(fr(i))}case le.BlockchainType.Starknet:return this._starknetHTLC?ie(this._starknetHTLC.htlcActorAddress):G("Please provide starknetHTLC when initializing garden");default:return G("Unsupported chain")}}validateAmount(t){if(t==null||t.includes("."))return G("Invalid amount ",t);const r=new eh(t);return!r.isInteger()||r.isNaN()||r.lt(0)||r.isLessThanOrEqualTo(0)?G("Invalid amount ",t):ie(r)}async pollOrder(t){let r=await this._orderbook.getOrder(t,!0),n=0;for(;n<this.getOrderThreshold;){if(await q.sleep(1e3),n++,r.error){if(!r.error.includes("result is undefined"))return G(r.error)}else if(r.val&&r.val.create_order.create_id.toLowerCase()===t.toLowerCase())return ie(r.val);r=await this._orderbook.getOrder(t,!0)}return G(`Order not found, createOrder id: ${t}`)}async execute(t=5e3){return await this._orderbook.subscribeOrders(this._digestKey.userId,!0,t,async r=>{const n=await this.filterExpiredAndAssignStatus(r.data);if(!n.error&&(this.emit("onPendingOrdersChanged",n.val),r.data.length!==0))for(let i=0;i<n.val.length;i++){const s=n.val[i],o=lc(s.status);if(le.isBitcoin(s.source_swap.chain)&&s.status===we.InitiateDetected){const a=this.btcWallet;if(!a){this.emit("error",s,"BTC wallet not found");continue}await this.postRefundSACP(s,a)}switch(o){case Ce.Redeem:{const a=await this._secretManager.generateSecret(s.create_order.nonce);if(a.error){this.emit("error",s,a.error);return}switch(le.getBlockchainType(s.destination_swap.chain)){case le.BlockchainType.EVM:{await this.evmRedeem(s,a.val.secret);break}case le.BlockchainType.Bitcoin:{const c=this.btcWallet;if(!c){this.emit("error",s,"BTC wallet not found");return}await this.btcRedeem(c,s,a.val.secret);break}case le.BlockchainType.Starknet:{await this.starknetRedeem(s,a.val.secret);break}default:this.emit("error",s,"Unsupported chain: "+s.destination_swap.chain)}break}case Ce.Refund:{switch(le.getBlockchainType(s.source_swap.chain)){case le.BlockchainType.EVM:{this.emit("error",s,"EVM refund is automatically done by relay service");break}case le.BlockchainType.Bitcoin:{const a=this.btcWallet;if(!a){this.emit("error",s,"BTC wallet not found");return}await this.btcRefund(a,s);break}case le.BlockchainType.Starknet:{this.emit("error",s,"Starknet refund is automatically done by relay service");break}default:this.emit("error",s,"Unsupported chain: "+s.source_swap.chain)}break}}}},"pending",{per_page:500})}async evmRedeem(t,r){if(this.emit("log",t.create_order.create_id,"executing evm redeem"),this.orderExecutorCache.get(t,Ce.Redeem)){this.emit("log",t.create_order.create_id,"already redeemed");return}if(!this._evmHTLC){this.emit("error",t,"EVMHTLC is required");return}const i=await this._evmHTLC.redeem(t,r);if(!i.ok){this.emit("error",t,i.error),i.error.includes("Order already redeemed")&&this.orderExecutorCache.set(t,Ce.Redeem,t.destination_swap.redeem_tx_hash);return}this.orderExecutorCache.set(t,Ce.Redeem,i.val),this.emit("success",t,Ce.Redeem,i.val)}async starknetRedeem(t,r){if(this.emit("log",t.create_order.create_id,"executing starknet redeem"),this.orderExecutorCache.get(t,Ce.Redeem)){this.emit("log",t.create_order.create_id,"already redeemed");return}if(!this._starknetHTLC){this.emit("error",t,"StarknetHTLC is required");return}const i=await this._starknetHTLC.redeem(t,r);if(i.error){this.emit("error",t,i.error),i.error.includes("Order already redeemed")&&this.orderExecutorCache.set(t,Ce.Redeem,t.destination_swap.redeem_tx_hash);return}i.val&&(this.orderExecutorCache.set(t,Ce.Redeem,i.val),this.emit("success",t,Ce.Redeem,i.val))}async btcRedeem(t,r,n){var a,c;const i=this.bitcoinRedeemCache.get(r.create_order.create_id),s=(a=r.destination_swap.initiate_tx_hash.split(",").at(-1))==null?void 0:a.split(":").at(0);if(!s){this.emit("error",r,"Failed to get initiate_tx_hash");return}let o=!1;if(i)if(i.redeemedFromUTXO&&i.redeemedFromUTXO!==s)o=!0,this.emit("log",r.create_order.create_id,"rbf btc redeem");else if(i.redeemedAt&&Date.now()-i.redeemedAt>1e3*60*15)this.emit("log",r.create_order.create_id,"redeem not confirmed in last 15 minutes"),o=!0;else{this.emit("log",r.create_order.create_id,"btcRedeem: already redeemed");return}else if(r.destination_swap.redeem_tx_hash&&!Number(r.destination_swap.redeem_block_number))try{const f=await(await t.getProvider()).getTransaction(r.destination_swap.redeem_tx_hash);let l=!1;for(const h of f.vin)if(h.txid===s){l=!0;break}if(l){this.emit("log",r.create_order.create_id,"already a valid redeem");let h=0;try{const[y]=await(await t.getProvider()).getTransactionTimes([r.destination_swap.redeem_tx_hash]);y!==0&&(h=y)}catch{h=Date.now()}this.bitcoinRedeemCache.set(r.create_order.create_id,{redeemedFromUTXO:s,redeemedAt:h,redeemTxHash:r.destination_swap.redeem_tx_hash});return}o=!0}catch(f){if(f.message.includes("Transaction not found"))o=!0;else{this.emit("error",r,"Failed to get redeem tx: "+f);return}}this.emit("log",r.create_order.create_id,"executing btc redeem");try{const l=await(await Zn.from(t,Number(r.destination_swap.amount),r.create_order.secret_hash,fr(r.destination_swap.initiator),fr(r.destination_swap.redeemer),r.destination_swap.timelock,o?[s]:[])).getRedeemHex(kr(n),(c=r.create_order.additional_data)==null?void 0:c.bitcoin_optional_recipient),h=await this.broadcastRedeemTx(l,r.create_order.create_id);if(h.error||!h.val){this.emit("error",r,h.error||"Failed to broadcast redeem tx");return}o?(this.emit("log",r.create_order.create_id,"rbf: btc redeem success"),this.emit("rbf",r,h.val)):this.emit("success",r,Ce.Redeem,h.val),this.bitcoinRedeemCache.set(r.create_order.create_id,{redeemedFromUTXO:s,redeemedAt:Date.now(),redeemTxHash:h.val})}catch(f){console.log("error",f),this.emit("error",r,"Failed btc redeem: "+f)}}async btcRefund(t,r){var n;if(!this.orderExecutorCache.get(r,Ce.Refund)){this.emit("log",r.create_order.create_id,"executing btc refund");try{const s=await(await Zn.from(t,Number(r.source_swap.amount),r.create_order.secret_hash,fr(r.source_swap.initiator),fr(r.source_swap.redeemer),r.source_swap.timelock)).refund((n=r.create_order.additional_data)==null?void 0:n.bitcoin_optional_recipient);this.orderExecutorCache.set(r,Ce.Refund,s),this.emit("success",r,Ce.Refund,s)}catch(i){this.emit("error",r,"Failed btc refund: "+i)}}}async postRefundSACP(t,r){const n=this.refundSacpCache.get(t.create_order.create_id);if((n==null?void 0:n.initTxHash)===t.source_swap.initiate_tx_hash)return;const i=await Zn.from(r,Number(t.source_swap.amount),t.create_order.secret_hash,fr(t.source_swap.initiator),fr(t.source_swap.redeemer),t.source_swap.timelock),s=t.create_order.additional_data.bitcoin_optional_recipient;if(s)try{const o=await i.generateInstantRefundSACP(s);if(!this._api)return;const a=new q.Url(this._api.orderbook).endpoint("orders/bitcoin/"+t.create_order.create_id+"/instant-refund");(await Dt.post(a,{headers:{"Content-Type":"application/json"},body:JSON.stringify({instant_refund_tx_bytes:o})})).status==="Ok"&&this.refundSacpCache.set(t.create_order.create_id,{initTxHash:t.source_swap.initiate_tx_hash})}catch(o){this.emit("error",t,"Failed to generate and post SACP: "+o);return}}async filterExpiredAndAssignStatus(t){var i;if(t.length===0)return ie([]);const r=await((i=this._blockNumberFetcher)==null?void 0:i.fetchBlockNumbers());if(r.error)return G(r.error);const n=[];for(let s=0;s<t.length;s++){const o=t[s];if(Ld(o))continue;const a=o.source_swap.chain,c=o.destination_swap.chain,f=r==null?void 0:r.val[a],l=r==null?void 0:r.val[c];if(!f||!l){this.emit("error",o,"Error while fetching CurrentBlockNumbers");continue}const h=dc(o,f,l);n.push({...o,status:h})}return ie(n)}async broadcastRedeemTx(t,r){try{if(!this._api)return G("API not found");const n=new q.Url(this._api.evmRelay).endpoint("/bitcoin/redeem "),i=await this._auth.getAuthHeaders(),o=await(await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",...i.val},body:JSON.stringify({redeem_tx_bytes:t,order_id:r})})).json();return o.status==="Ok"&&o.result?ie(o.result):G(o.error)}catch(n){return G("Failed to broadcast redeem tx: "+n)}}}class m_{constructor(t,r,n){this.callData=new Oe.CallData(Kl),this.account=t,this.starknetProvider=new Oe.RpcProvider({nodeUrl:r||(n?Si[n].nodeUrl:Si.mainnet.nodeUrl)})}get htlcActorAddress(){return this.account.address}async getHTLCContract(t,r=!1){const n=r?t.destination_swap.asset:t.source_swap.asset;return new Oe.Contract(Yl,n,this.account)}async initiate(t){try{const n=await(await this.getHTLCContract(t)).token();if(!n)throw new Error("Token address retrieval failed");const i=Oe.num.toHex(n),s=Oe.cairo.uint256(BigInt(t.source_swap.amount));try{const a=await h_(this.account,i,t.source_swap.asset,BigInt(t.source_swap.amount),this.starknetProvider);if(a.error)return G(a.error)}catch(a){return G(`Allowance check failed: ${a}`)}const o=await this.account.execute({contractAddress:t.source_swap.asset,entrypoint:"initiate",calldata:[t.source_swap.redeemer,BigInt(t.source_swap.timelock),s.low,s.high,...q.hexToU32Array(t.create_order.secret_hash)]});if(!o.transaction_hash)throw new Error("Failed to initiate HTLC transaction");return ie(o.transaction_hash)}catch(r){return G(`HTLC Initiation Error: ${r}`)}}async redeem(t,r){try{const n=await this.getHTLCContract(t,!0),i=t.create_order.source_chain.includes("starknet")?t.source_swap.swap_id:t.destination_swap.swap_id,s=await this.account.execute({contractAddress:n.address,entrypoint:"redeem",calldata:Oe.CallData.compile({swap_id:i,secret:q.hexToU32Array(r)})});return s.transaction_hash?ie(s.transaction_hash):G("Failed to redeem HTLC transaction")}catch{return G("HTLC Redeem Error")}}async refund(t){try{const r=t.create_order.source_chain.includes("starknet")?t.source_swap.swap_id:t.destination_swap.swap_id,n=await this.getHTLCContract(t),i=await this.account.execute({contractAddress:n.address,entrypoint:"refund",calldata:{orderId:r}});return i.transaction_hash?ie(i.transaction_hash):G("Failed to refund HTLC transaction")}catch{return G("HTLC Refund Error")}}}exports.API=hs;exports.AbiErrorInputsNotFoundError=Jh;exports.AbiErrorNotFoundError=Qh;exports.AbiFunctionNotFoundError=ei;exports.AbiFunctionOutputsNotFoundError=Tf;exports.AbiFunctionSignatureNotFoundError=e0;exports.BaseError=L;exports.BlockNumberFetcher=il;exports.EvmRelay=Wl;exports.Garden=kc;exports.Hash=Ma;exports.HttpRequestError=on;exports.InvalidArrayError=kf;exports.OrderActions=Ce;exports.OrderStatus=we;exports.ParseOrderStatus=dc;exports.ParseSwapStatus=Ea;exports.Quote=sl;exports.STARKNET_CONFIG=Si;exports.SecretManager=Bi;exports.StarknetHTLC=m_;exports.StarknetRelay=Xl;exports.SwapStatus=xe;exports.abytes=Oi;exports.aexists=ti;exports.ahash=m0;exports.batchGatewayAbi=my;exports.call=sc;exports.concat=Ur;exports.concatBytes=P0;exports.concatHex=Ot;exports.constructOrderPair=va;exports.decodeAbiParameters=Fi;exports.decodeErrorResult=Kf;exports.encodeAbiParameters=Ns;exports.evmToViemChainMap=ql;exports.filterDeadlineExpiredOrders=cb;exports.formatAbiItem=Bt;exports.getAbiItem=Pn;exports.getUrl=Ms;exports.hyperliquid=zl;exports.hyperliquidTestnet=Gl;exports.isAddressEqual=rc;exports.isExpired=Pi;exports.isHex=qt;exports.parseAction=ab;exports.parseActionFromStatus=lc;exports.randomBytes=T0;exports.sha256=od;exports.slice=hn;exports.solidityError=Vf;exports.stringify=rt;exports.switchOrAddNetwork=Vl;exports.toBytes=Rs;exports.toFunctionSelector=Ls;exports.toXOnly=fr;exports.validateBTCAddress=nb;
71
+ Use Chrome, Firefox or Internet Explorer 11`)}var o1=tt.Buffer,Ts=br.crypto||br.msCrypto;Ts&&Ts.getRandomValues?Pa.exports=a1:Pa.exports=s1;function a1(e,t){if(e>i1)throw new RangeError("requested too many random bytes");var r=o1.allocUnsafe(e);if(e>0)if(e>jo)for(var n=0;n<e;n+=jo)Ts.getRandomValues(r.slice(n,n+jo));else Ts.getRandomValues(r);return typeof t=="function"?process.nextTick(function(){t(null,r)}):r}var c1=Pa.exports,ka={exports:{}};typeof Object.create=="function"?ka.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:ka.exports=function(t,r){if(r){t.super_=r;var n=function(){};n.prototype=r.prototype,t.prototype=new n,t.prototype.constructor=t}};var He=ka.exports,Ia={exports:{}},Ac={exports:{}},dn=typeof Reflect=="object"?Reflect:null,Cu=dn&&typeof dn.apply=="function"?dn.apply:function(t,r,n){return Function.prototype.apply.call(t,r,n)},_s;dn&&typeof dn.ownKeys=="function"?_s=dn.ownKeys:Object.getOwnPropertySymbols?_s=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:_s=function(t){return Object.getOwnPropertyNames(t)};function u1(e){console&&console.warn&&console.warn(e)}var cl=Number.isNaN||function(t){return t!==t};function ue(){ue.init.call(this)}Ac.exports=ue;Ac.exports.once=h1;ue.EventEmitter=ue;ue.prototype._events=void 0;ue.prototype._eventsCount=0;ue.prototype._maxListeners=void 0;var Ou=10;function to(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(ue,"defaultMaxListeners",{enumerable:!0,get:function(){return Ou},set:function(e){if(typeof e!="number"||e<0||cl(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");Ou=e}});ue.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};ue.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||cl(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function ul(e){return e._maxListeners===void 0?ue.defaultMaxListeners:e._maxListeners}ue.prototype.getMaxListeners=function(){return ul(this)};ue.prototype.emit=function(t){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=t==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){var o;if(r.length>0&&(o=r[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=s[t];if(c===void 0)return!1;if(typeof c=="function")Cu(c,this,r);else for(var f=c.length,l=pl(c,f),n=0;n<f;++n)Cu(l[n],this,r);return!0};function fl(e,t,r,n){var i,s,o;if(to(r),s=e._events,s===void 0?(s=e._events=Object.create(null),e._eventsCount=0):(s.newListener!==void 0&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]),o===void 0)o=s[t]=r,++e._eventsCount;else if(typeof o=="function"?o=s[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),i=ul(e),i>0&&o.length>i&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=o.length,u1(a)}return e}ue.prototype.addListener=function(t,r){return fl(this,t,r,!1)};ue.prototype.on=ue.prototype.addListener;ue.prototype.prependListener=function(t,r){return fl(this,t,r,!0)};function f1(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function dl(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=f1.bind(n);return i.listener=r,n.wrapFn=i,i}ue.prototype.once=function(t,r){return to(r),this.on(t,dl(this,t,r)),this};ue.prototype.prependOnceListener=function(t,r){return to(r),this.prependListener(t,dl(this,t,r)),this};ue.prototype.removeListener=function(t,r){var n,i,s,o,a;if(to(r),i=this._events,i===void 0)return this;if(n=i[t],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,n.listener||r));else if(typeof n!="function"){for(s=-1,o=n.length-1;o>=0;o--)if(n[o]===r||n[o].listener===r){a=n[o].listener,s=o;break}if(s<0)return this;s===0?n.shift():d1(n,s),n.length===1&&(i[t]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",t,a||r)}return this};ue.prototype.off=ue.prototype.removeListener;ue.prototype.removeAllListeners=function(t){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[t]),this;if(arguments.length===0){var s=Object.keys(n),o;for(i=0;i<s.length;++i)o=s[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[t],typeof r=="function")this.removeListener(t,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(t,r[i]);return this};function ll(e,t,r){var n=e._events;if(n===void 0)return[];var i=n[t];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?l1(i):pl(i,i.length)}ue.prototype.listeners=function(t){return ll(this,t,!0)};ue.prototype.rawListeners=function(t){return ll(this,t,!1)};ue.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):hl.call(e,t)};ue.prototype.listenerCount=hl;function hl(e){var t=this._events;if(t!==void 0){var r=t[e];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}ue.prototype.eventNames=function(){return this._eventsCount>0?_s(this._events):[]};function pl(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function d1(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function l1(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}function h1(e,t){return new Promise(function(r,n){function i(o){e.removeListener(t,s),n(o)}function s(){typeof e.removeListener=="function"&&e.removeListener("error",i),r([].slice.call(arguments))}yl(e,t,s,{once:!0}),t!=="error"&&p1(e,i,{once:!0})})}function p1(e,t,r){typeof e.on=="function"&&yl(e,"error",t,r)}function yl(e,t,r,n){if(typeof e.on=="function")n.once?e.once(t,r):e.on(t,r);else if(typeof e.addEventListener=="function")e.addEventListener(t,function i(s){n.once&&e.removeEventListener(t,i),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}var ml=Ac.exports,bl=ml.EventEmitter;const y1={},m1=Object.freeze(Object.defineProperty({__proto__:null,default:y1},Symbol.toStringTag,{value:"Module"})),Sc=_m(m1);var Go,Ru;function b1(){if(Ru)return Go;Ru=1;function e(g,_){var x=Object.keys(g);if(Object.getOwnPropertySymbols){var k=Object.getOwnPropertySymbols(g);_&&(k=k.filter(function(T){return Object.getOwnPropertyDescriptor(g,T).enumerable})),x.push.apply(x,k)}return x}function t(g){for(var _=1;_<arguments.length;_++){var x=arguments[_]!=null?arguments[_]:{};_%2?e(Object(x),!0).forEach(function(k){r(g,k,x[k])}):Object.getOwnPropertyDescriptors?Object.defineProperties(g,Object.getOwnPropertyDescriptors(x)):e(Object(x)).forEach(function(k){Object.defineProperty(g,k,Object.getOwnPropertyDescriptor(x,k))})}return g}function r(g,_,x){return _=o(_),_ in g?Object.defineProperty(g,_,{value:x,enumerable:!0,configurable:!0,writable:!0}):g[_]=x,g}function n(g,_){if(!(g instanceof _))throw new TypeError("Cannot call a class as a function")}function i(g,_){for(var x=0;x<_.length;x++){var k=_[x];k.enumerable=k.enumerable||!1,k.configurable=!0,"value"in k&&(k.writable=!0),Object.defineProperty(g,o(k.key),k)}}function s(g,_,x){return _&&i(g.prototype,_),Object.defineProperty(g,"prototype",{writable:!1}),g}function o(g){var _=a(g,"string");return typeof _=="symbol"?_:String(_)}function a(g,_){if(typeof g!="object"||g===null)return g;var x=g[Symbol.toPrimitive];if(x!==void 0){var k=x.call(g,_);if(typeof k!="object")return k;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(g)}var c=Zt,f=c.Buffer,l=Sc,h=l.inspect,y=h&&h.custom||"inspect";function p(g,_,x){f.prototype.copy.call(g,_,x)}return Go=function(){function g(){n(this,g),this.head=null,this.tail=null,this.length=0}return s(g,[{key:"push",value:function(x){var k={data:x,next:null};this.length>0?this.tail.next=k:this.head=k,this.tail=k,++this.length}},{key:"unshift",value:function(x){var k={data:x,next:this.head};this.length===0&&(this.tail=k),this.head=k,++this.length}},{key:"shift",value:function(){if(this.length!==0){var x=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,x}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(x){if(this.length===0)return"";for(var k=this.head,T=""+k.data;k=k.next;)T+=x+k.data;return T}},{key:"concat",value:function(x){if(this.length===0)return f.alloc(0);for(var k=f.allocUnsafe(x>>>0),T=this.head,A=0;T;)p(T.data,k,A),A+=T.data.length,T=T.next;return k}},{key:"consume",value:function(x,k){var T;return x<this.head.data.length?(T=this.head.data.slice(0,x),this.head.data=this.head.data.slice(x)):x===this.head.data.length?T=this.shift():T=k?this._getString(x):this._getBuffer(x),T}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(x){var k=this.head,T=1,A=k.data;for(x-=A.length;k=k.next;){var E=k.data,I=x>E.length?E.length:x;if(I===E.length?A+=E:A+=E.slice(0,x),x-=I,x===0){I===E.length?(++T,k.next?this.head=k.next:this.head=this.tail=null):(this.head=k,k.data=E.slice(I));break}++T}return this.length-=T,A}},{key:"_getBuffer",value:function(x){var k=f.allocUnsafe(x),T=this.head,A=1;for(T.data.copy(k),x-=T.data.length;T=T.next;){var E=T.data,I=x>E.length?E.length:x;if(E.copy(k,k.length-x,0,I),x-=I,x===0){I===E.length?(++A,T.next?this.head=T.next:this.head=this.tail=null):(this.head=T,T.data=E.slice(I));break}++A}return this.length-=A,k}},{key:y,value:function(x,k){return h(this,t(t({},k),{},{depth:0,customInspect:!1}))}}]),g}(),Go}function g1(e,t){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(Ba,this,e)):process.nextTick(Ba,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(s){!t&&s?r._writableState?r._writableState.errorEmitted?process.nextTick(vs,r):(r._writableState.errorEmitted=!0,process.nextTick(Fu,r,s)):process.nextTick(Fu,r,s):t?(process.nextTick(vs,r),t(s)):process.nextTick(vs,r)}),this)}function Fu(e,t){Ba(e,t),vs(e)}function vs(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function w1(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function Ba(e,t){e.emit("error",t)}function _1(e,t){var r=e._readableState,n=e._writableState;r&&r.autoDestroy||n&&n.autoDestroy?e.destroy(t):e.emit("error",t)}var gl={destroy:g1,undestroy:w1,errorOrDestroy:_1},Gr={};function v1(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var wl={};function mt(e,t,r){r||(r=Error);function n(s,o,a){return typeof t=="string"?t:t(s,o,a)}var i=function(s){v1(o,s);function o(a,c,f){return s.call(this,n(a,c,f))||this}return o}(r);i.prototype.name=r.name,i.prototype.code=e,wl[e]=i}function Uu(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(n){return String(n)}),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:r===2?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}else return"of ".concat(t," ").concat(String(e))}function E1(e,t,r){return e.substr(0,t.length)===t}function x1(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function A1(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}mt("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError);mt("ERR_INVALID_ARG_TYPE",function(e,t,r){var n;typeof t=="string"&&E1(t,"not ")?(n="must not be",t=t.replace(/^not /,"")):n="must be";var i;if(x1(e," argument"))i="The ".concat(e," ").concat(n," ").concat(Uu(t,"type"));else{var s=A1(e,".")?"property":"argument";i='The "'.concat(e,'" ').concat(s," ").concat(n," ").concat(Uu(t,"type"))}return i+=". Received type ".concat(typeof r),i},TypeError);mt("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");mt("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"});mt("ERR_STREAM_PREMATURE_CLOSE","Premature close");mt("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"});mt("ERR_MULTIPLE_CALLBACK","Callback called multiple times");mt("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");mt("ERR_STREAM_WRITE_AFTER_END","write after end");mt("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);mt("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError);mt("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");Gr.codes=wl;var S1=Gr.codes.ERR_INVALID_OPT_VALUE;function P1(e,t,r){return e.highWaterMark!=null?e.highWaterMark:t?e[r]:null}function T1(e,t,r,n){var i=P1(t,n,r);if(i!=null){if(!(isFinite(i)&&Math.floor(i)===i)||i<0){var s=n?r:"highWaterMark";throw new S1(s,i)}return Math.floor(i)}return e.objectMode?16:16*1024}var _l={getHighWaterMark:T1},k1=I1;function I1(e,t){if(zo("noDeprecation"))return e;var r=!1;function n(){if(!r){if(zo("throwDeprecation"))throw new Error(t);zo("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}return n}function zo(e){try{if(!br.localStorage)return!1}catch{return!1}var t=br.localStorage[e];return t==null?!1:String(t).toLowerCase()==="true"}var qo,Nu;function vl(){if(Nu)return qo;Nu=1,qo=$;function e(O){var C=this;this.next=null,this.entry=null,this.finish=function(){Rt(C,O)}}var t;$.WritableState=S;var r={deprecate:k1},n=bl,i=Zt.Buffer,s=(typeof br<"u"?br:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function o(O){return i.from(O)}function a(O){return i.isBuffer(O)||O instanceof s}var c=gl,f=_l,l=f.getHighWaterMark,h=Gr.codes,y=h.ERR_INVALID_ARG_TYPE,p=h.ERR_METHOD_NOT_IMPLEMENTED,g=h.ERR_MULTIPLE_CALLBACK,_=h.ERR_STREAM_CANNOT_PIPE,x=h.ERR_STREAM_DESTROYED,k=h.ERR_STREAM_NULL_VALUES,T=h.ERR_STREAM_WRITE_AFTER_END,A=h.ERR_UNKNOWN_ENCODING,E=c.errorOrDestroy;He($,n);function I(){}function S(O,C,H){t=t||vn(),O=O||{},typeof H!="boolean"&&(H=C instanceof t),this.objectMode=!!O.objectMode,H&&(this.objectMode=this.objectMode||!!O.writableObjectMode),this.highWaterMark=l(this,O,"writableHighWaterMark",H),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var K=O.decodeStrings===!1;this.decodeStrings=!K,this.defaultEncoding=O.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(Z){ne(C,Z)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=O.emitClose!==!1,this.autoDestroy=!!O.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new e(this)}S.prototype.getBuffer=function(){for(var C=this.bufferedRequest,H=[];C;)H.push(C),C=C.next;return H},function(){try{Object.defineProperty(S.prototype,"buffer",{get:r.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}();var N;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(N=Function.prototype[Symbol.hasInstance],Object.defineProperty($,Symbol.hasInstance,{value:function(C){return N.call(this,C)?!0:this!==$?!1:C&&C._writableState instanceof S}})):N=function(C){return C instanceof this};function $(O){t=t||vn();var C=this instanceof t;if(!C&&!N.call($,this))return new $(O);this._writableState=new S(O,this,C),this.writable=!0,O&&(typeof O.write=="function"&&(this._write=O.write),typeof O.writev=="function"&&(this._writev=O.writev),typeof O.destroy=="function"&&(this._destroy=O.destroy),typeof O.final=="function"&&(this._final=O.final)),n.call(this)}$.prototype.pipe=function(){E(this,new _)};function B(O,C){var H=new T;E(O,H),process.nextTick(C,H)}function W(O,C,H,K){var Z;return H===null?Z=new k:typeof H!="string"&&!C.objectMode&&(Z=new y("chunk",["string","Buffer"],H)),Z?(E(O,Z),process.nextTick(K,Z),!1):!0}$.prototype.write=function(O,C,H){var K=this._writableState,Z=!1,w=!K.objectMode&&a(O);return w&&!i.isBuffer(O)&&(O=o(O)),typeof C=="function"&&(H=C,C=null),w?C="buffer":C||(C=K.defaultEncoding),typeof H!="function"&&(H=I),K.ending?B(this,H):(w||W(this,K,O,H))&&(K.pendingcb++,Z=D(this,K,w,O,C,H)),Z},$.prototype.cork=function(){this._writableState.corked++},$.prototype.uncork=function(){var O=this._writableState;O.corked&&(O.corked--,!O.writing&&!O.corked&&!O.bufferProcessing&&O.bufferedRequest&&Te(this,O))},$.prototype.setDefaultEncoding=function(C){if(typeof C=="string"&&(C=C.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((C+"").toLowerCase())>-1))throw new A(C);return this._writableState.defaultEncoding=C,this},Object.defineProperty($.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function R(O,C,H){return!O.objectMode&&O.decodeStrings!==!1&&typeof C=="string"&&(C=i.from(C,H)),C}Object.defineProperty($.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function D(O,C,H,K,Z,w){if(!H){var v=R(C,K,Z);K!==v&&(H=!0,Z="buffer",K=v)}var M=C.objectMode?1:K.length;C.length+=M;var z=C.length<C.highWaterMark;if(z||(C.needDrain=!0),C.writing||C.corked){var ve=C.lastBufferedRequest;C.lastBufferedRequest={chunk:K,encoding:Z,isBuf:H,callback:w,next:null},ve?ve.next=C.lastBufferedRequest:C.bufferedRequest=C.lastBufferedRequest,C.bufferedRequestCount+=1}else j(O,C,!1,M,K,Z,w);return z}function j(O,C,H,K,Z,w,v){C.writelen=K,C.writecb=v,C.writing=!0,C.sync=!0,C.destroyed?C.onwrite(new x("write")):H?O._writev(Z,C.onwrite):O._write(Z,w,C.onwrite),C.sync=!1}function V(O,C,H,K,Z){--C.pendingcb,H?(process.nextTick(Z,K),process.nextTick(st,O,C),O._writableState.errorEmitted=!0,E(O,K)):(Z(K),O._writableState.errorEmitted=!0,E(O,K),st(O,C))}function X(O){O.writing=!1,O.writecb=null,O.length-=O.writelen,O.writelen=0}function ne(O,C){var H=O._writableState,K=H.sync,Z=H.writecb;if(typeof Z!="function")throw new g;if(X(H),C)V(O,H,K,C,Z);else{var w=We(H)||O.destroyed;!w&&!H.corked&&!H.bufferProcessing&&H.bufferedRequest&&Te(O,H),K?process.nextTick(pe,O,H,w,Z):pe(O,H,w,Z)}}function pe(O,C,H,K){H||_e(O,C),C.pendingcb--,K(),st(O,C)}function _e(O,C){C.length===0&&C.needDrain&&(C.needDrain=!1,O.emit("drain"))}function Te(O,C){C.bufferProcessing=!0;var H=C.bufferedRequest;if(O._writev&&H&&H.next){var K=C.bufferedRequestCount,Z=new Array(K),w=C.corkedRequestsFree;w.entry=H;for(var v=0,M=!0;H;)Z[v]=H,H.isBuf||(M=!1),H=H.next,v+=1;Z.allBuffers=M,j(O,C,!0,C.length,Z,"",w.finish),C.pendingcb++,C.lastBufferedRequest=null,w.next?(C.corkedRequestsFree=w.next,w.next=null):C.corkedRequestsFree=new e(C),C.bufferedRequestCount=0}else{for(;H;){var z=H.chunk,ve=H.encoding,ee=H.callback,ae=C.objectMode?1:z.length;if(j(O,C,!1,ae,z,ve,ee),H=H.next,C.bufferedRequestCount--,C.writing)break}H===null&&(C.lastBufferedRequest=null)}C.bufferedRequest=H,C.bufferProcessing=!1}$.prototype._write=function(O,C,H){H(new p("_write()"))},$.prototype._writev=null,$.prototype.end=function(O,C,H){var K=this._writableState;return typeof O=="function"?(H=O,O=null,C=null):typeof C=="function"&&(H=C,C=null),O!=null&&this.write(O,C),K.corked&&(K.corked=1,this.uncork()),K.ending||er(this,K,H),this},Object.defineProperty($.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function We(O){return O.ending&&O.length===0&&O.bufferedRequest===null&&!O.finished&&!O.writing}function fe(O,C){O._final(function(H){C.pendingcb--,H&&E(O,H),C.prefinished=!0,O.emit("prefinish"),st(O,C)})}function me(O,C){!C.prefinished&&!C.finalCalled&&(typeof O._final=="function"&&!C.destroyed?(C.pendingcb++,C.finalCalled=!0,process.nextTick(fe,O,C)):(C.prefinished=!0,O.emit("prefinish")))}function st(O,C){var H=We(C);if(H&&(me(O,C),C.pendingcb===0&&(C.finished=!0,O.emit("finish"),C.autoDestroy))){var K=O._readableState;(!K||K.autoDestroy&&K.endEmitted)&&O.destroy()}return H}function er(O,C,H){C.ending=!0,st(O,C),H&&(C.finished?process.nextTick(H):O.once("finish",H)),C.ended=!0,O.writable=!1}function Rt(O,C,H){var K=O.entry;for(O.entry=null;K;){var Z=K.callback;C.pendingcb--,Z(H),K=K.next}C.corkedRequestsFree.next=O}return Object.defineProperty($.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(C){this._writableState&&(this._writableState.destroyed=C)}}),$.prototype.destroy=c.destroy,$.prototype._undestroy=c.undestroy,$.prototype._destroy=function(O,C){C(O)},qo}var Vo,Lu;function vn(){if(Lu)return Vo;Lu=1;var e=Object.keys||function(f){var l=[];for(var h in f)l.push(h);return l};Vo=o;var t=xl(),r=vl();He(o,t);for(var n=e(r.prototype),i=0;i<n.length;i++){var s=n[i];o.prototype[s]||(o.prototype[s]=r.prototype[s])}function o(f){if(!(this instanceof o))return new o(f);t.call(this,f),r.call(this,f),this.allowHalfOpen=!0,f&&(f.readable===!1&&(this.readable=!1),f.writable===!1&&(this.writable=!1),f.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",a)))}Object.defineProperty(o.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(o.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(o.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function a(){this._writableState.ended||process.nextTick(c,this)}function c(f){f.end()}return Object.defineProperty(o.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(l){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=l,this._writableState.destroyed=l)}}),Vo}var ks={},Pc=tt.Buffer,Mu=Pc.isEncoding||function(e){switch(e=""+e,e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function B1(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function C1(e){var t=B1(e);if(typeof t!="string"&&(Pc.isEncoding===Mu||!Mu(e)))throw new Error("Unknown encoding: "+e);return t||e}ks.StringDecoder=Gi;function Gi(e){this.encoding=C1(e);var t;switch(this.encoding){case"utf16le":this.text=L1,this.end=M1,t=4;break;case"utf8":this.fillLast=F1,t=4;break;case"base64":this.text=$1,this.end=H1,t=3;break;default:this.write=D1,this.end=j1;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Pc.allocUnsafe(t)}Gi.prototype.write=function(e){if(e.length===0)return"";var t,r;if(this.lastNeed){if(t=this.fillLast(e),t===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""};Gi.prototype.end=N1;Gi.prototype.text=U1;Gi.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};function Wo(e){return e<=127?0:e>>5===6?2:e>>4===14?3:e>>3===30?4:e>>6===2?-1:-2}function O1(e,t,r){var n=t.length-1;if(n<r)return 0;var i=Wo(t[n]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--n<r||i===-2?0:(i=Wo(t[n]),i>=0?(i>0&&(e.lastNeed=i-2),i):--n<r||i===-2?0:(i=Wo(t[n]),i>=0?(i>0&&(i===2?i=0:e.lastNeed=i-3),i):0))}function R1(e,t,r){if((t[0]&192)!==128)return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if((t[1]&192)!==128)return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&(t[2]&192)!==128)return e.lastNeed=2,"�"}}function F1(e){var t=this.lastTotal-this.lastNeed,r=R1(this,e);if(r!==void 0)return r;if(this.lastNeed<=e.length)return e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length}function U1(e,t){var r=O1(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)}function N1(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t}function L1(e,t){if((e.length-t)%2===0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function M1(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function $1(e,t){var r=(e.length-t)%3;return r===0?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function H1(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function D1(e){return e.toString(this.encoding)}function j1(e){return e&&e.length?this.write(e):""}var $u=Gr.codes.ERR_STREAM_PREMATURE_CLOSE;function G1(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];e.apply(this,n)}}}function z1(){}function q1(e){return e.setHeader&&typeof e.abort=="function"}function El(e,t,r){if(typeof t=="function")return El(e,null,t);t||(t={}),r=G1(r||z1);var n=t.readable||t.readable!==!1&&e.readable,i=t.writable||t.writable!==!1&&e.writable,s=function(){e.writable||a()},o=e._writableState&&e._writableState.finished,a=function(){i=!1,o=!0,n||r.call(e)},c=e._readableState&&e._readableState.endEmitted,f=function(){n=!1,c=!0,i||r.call(e)},l=function(g){r.call(e,g)},h=function(){var g;if(n&&!c)return(!e._readableState||!e._readableState.ended)&&(g=new $u),r.call(e,g);if(i&&!o)return(!e._writableState||!e._writableState.ended)&&(g=new $u),r.call(e,g)},y=function(){e.req.on("finish",a)};return q1(e)?(e.on("complete",a),e.on("abort",h),e.req?y():e.on("request",y)):i&&!e._writableState&&(e.on("end",s),e.on("close",s)),e.on("end",f),e.on("finish",a),t.error!==!1&&e.on("error",l),e.on("close",h),function(){e.removeListener("complete",a),e.removeListener("abort",h),e.removeListener("request",y),e.req&&e.req.removeListener("finish",a),e.removeListener("end",s),e.removeListener("close",s),e.removeListener("finish",a),e.removeListener("end",f),e.removeListener("error",l),e.removeListener("close",h)}}var Tc=El,Ko,Hu;function V1(){if(Hu)return Ko;Hu=1;var e;function t(A,E,I){return E=r(E),E in A?Object.defineProperty(A,E,{value:I,enumerable:!0,configurable:!0,writable:!0}):A[E]=I,A}function r(A){var E=n(A,"string");return typeof E=="symbol"?E:String(E)}function n(A,E){if(typeof A!="object"||A===null)return A;var I=A[Symbol.toPrimitive];if(I!==void 0){var S=I.call(A,E);if(typeof S!="object")return S;throw new TypeError("@@toPrimitive must return a primitive value.")}return(E==="string"?String:Number)(A)}var i=Tc,s=Symbol("lastResolve"),o=Symbol("lastReject"),a=Symbol("error"),c=Symbol("ended"),f=Symbol("lastPromise"),l=Symbol("handlePromise"),h=Symbol("stream");function y(A,E){return{value:A,done:E}}function p(A){var E=A[s];if(E!==null){var I=A[h].read();I!==null&&(A[f]=null,A[s]=null,A[o]=null,E(y(I,!1)))}}function g(A){process.nextTick(p,A)}function _(A,E){return function(I,S){A.then(function(){if(E[c]){I(y(void 0,!0));return}E[l](I,S)},S)}}var x=Object.getPrototypeOf(function(){}),k=Object.setPrototypeOf((e={get stream(){return this[h]},next:function(){var E=this,I=this[a];if(I!==null)return Promise.reject(I);if(this[c])return Promise.resolve(y(void 0,!0));if(this[h].destroyed)return new Promise(function(B,W){process.nextTick(function(){E[a]?W(E[a]):B(y(void 0,!0))})});var S=this[f],N;if(S)N=new Promise(_(S,this));else{var $=this[h].read();if($!==null)return Promise.resolve(y($,!1));N=new Promise(this[l])}return this[f]=N,N}},t(e,Symbol.asyncIterator,function(){return this}),t(e,"return",function(){var E=this;return new Promise(function(I,S){E[h].destroy(null,function(N){if(N){S(N);return}I(y(void 0,!0))})})}),e),x),T=function(E){var I,S=Object.create(k,(I={},t(I,h,{value:E,writable:!0}),t(I,s,{value:null,writable:!0}),t(I,o,{value:null,writable:!0}),t(I,a,{value:null,writable:!0}),t(I,c,{value:E._readableState.endEmitted,writable:!0}),t(I,l,{value:function($,B){var W=S[h].read();W?(S[f]=null,S[s]=null,S[o]=null,$(y(W,!1))):(S[s]=$,S[o]=B)},writable:!0}),I));return S[f]=null,i(E,function(N){if(N&&N.code!=="ERR_STREAM_PREMATURE_CLOSE"){var $=S[o];$!==null&&(S[f]=null,S[s]=null,S[o]=null,$(N)),S[a]=N;return}var B=S[s];B!==null&&(S[f]=null,S[s]=null,S[o]=null,B(y(void 0,!0))),S[c]=!0}),E.on("readable",g.bind(null,S)),S};return Ko=T,Ko}var Yo,Du;function W1(){return Du||(Du=1,Yo=function(){throw new Error("Readable.from is not available in the browser")}),Yo}var Xo,ju;function xl(){if(ju)return Xo;ju=1,Xo=B;var e;B.ReadableState=$,ml.EventEmitter;var t=function(v,M){return v.listeners(M).length},r=bl,n=Zt.Buffer,i=(typeof br<"u"?br:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function s(w){return n.from(w)}function o(w){return n.isBuffer(w)||w instanceof i}var a=Sc,c;a&&a.debuglog?c=a.debuglog("stream"):c=function(){};var f=b1(),l=gl,h=_l,y=h.getHighWaterMark,p=Gr.codes,g=p.ERR_INVALID_ARG_TYPE,_=p.ERR_STREAM_PUSH_AFTER_EOF,x=p.ERR_METHOD_NOT_IMPLEMENTED,k=p.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,T,A,E;He(B,r);var I=l.errorOrDestroy,S=["error","close","destroy","pause","resume"];function N(w,v,M){if(typeof w.prependListener=="function")return w.prependListener(v,M);!w._events||!w._events[v]?w.on(v,M):Array.isArray(w._events[v])?w._events[v].unshift(M):w._events[v]=[M,w._events[v]]}function $(w,v,M){e=e||vn(),w=w||{},typeof M!="boolean"&&(M=v instanceof e),this.objectMode=!!w.objectMode,M&&(this.objectMode=this.objectMode||!!w.readableObjectMode),this.highWaterMark=y(this,w,"readableHighWaterMark",M),this.buffer=new f,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=w.emitClose!==!1,this.autoDestroy=!!w.autoDestroy,this.destroyed=!1,this.defaultEncoding=w.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,w.encoding&&(T||(T=ks.StringDecoder),this.decoder=new T(w.encoding),this.encoding=w.encoding)}function B(w){if(e=e||vn(),!(this instanceof B))return new B(w);var v=this instanceof e;this._readableState=new $(w,this,v),this.readable=!0,w&&(typeof w.read=="function"&&(this._read=w.read),typeof w.destroy=="function"&&(this._destroy=w.destroy)),r.call(this)}Object.defineProperty(B.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(v){this._readableState&&(this._readableState.destroyed=v)}}),B.prototype.destroy=l.destroy,B.prototype._undestroy=l.undestroy,B.prototype._destroy=function(w,v){v(w)},B.prototype.push=function(w,v){var M=this._readableState,z;return M.objectMode?z=!0:typeof w=="string"&&(v=v||M.defaultEncoding,v!==M.encoding&&(w=n.from(w,v),v=""),z=!0),W(this,w,v,!1,z)},B.prototype.unshift=function(w){return W(this,w,null,!0,!1)};function W(w,v,M,z,ve){c("readableAddChunk",v);var ee=w._readableState;if(v===null)ee.reading=!1,ne(w,ee);else{var ae;if(ve||(ae=D(ee,v)),ae)I(w,ae);else if(ee.objectMode||v&&v.length>0)if(typeof v!="string"&&!ee.objectMode&&Object.getPrototypeOf(v)!==n.prototype&&(v=s(v)),z)ee.endEmitted?I(w,new k):R(w,ee,v,!0);else if(ee.ended)I(w,new _);else{if(ee.destroyed)return!1;ee.reading=!1,ee.decoder&&!M?(v=ee.decoder.write(v),ee.objectMode||v.length!==0?R(w,ee,v,!1):Te(w,ee)):R(w,ee,v,!1)}else z||(ee.reading=!1,Te(w,ee))}return!ee.ended&&(ee.length<ee.highWaterMark||ee.length===0)}function R(w,v,M,z){v.flowing&&v.length===0&&!v.sync?(v.awaitDrain=0,w.emit("data",M)):(v.length+=v.objectMode?1:M.length,z?v.buffer.unshift(M):v.buffer.push(M),v.needReadable&&pe(w)),Te(w,v)}function D(w,v){var M;return!o(v)&&typeof v!="string"&&v!==void 0&&!w.objectMode&&(M=new g("chunk",["string","Buffer","Uint8Array"],v)),M}B.prototype.isPaused=function(){return this._readableState.flowing===!1},B.prototype.setEncoding=function(w){T||(T=ks.StringDecoder);var v=new T(w);this._readableState.decoder=v,this._readableState.encoding=this._readableState.decoder.encoding;for(var M=this._readableState.buffer.head,z="";M!==null;)z+=v.write(M.data),M=M.next;return this._readableState.buffer.clear(),z!==""&&this._readableState.buffer.push(z),this._readableState.length=z.length,this};var j=1073741824;function V(w){return w>=j?w=j:(w--,w|=w>>>1,w|=w>>>2,w|=w>>>4,w|=w>>>8,w|=w>>>16,w++),w}function X(w,v){return w<=0||v.length===0&&v.ended?0:v.objectMode?1:w!==w?v.flowing&&v.length?v.buffer.head.data.length:v.length:(w>v.highWaterMark&&(v.highWaterMark=V(w)),w<=v.length?w:v.ended?v.length:(v.needReadable=!0,0))}B.prototype.read=function(w){c("read",w),w=parseInt(w,10);var v=this._readableState,M=w;if(w!==0&&(v.emittedReadable=!1),w===0&&v.needReadable&&((v.highWaterMark!==0?v.length>=v.highWaterMark:v.length>0)||v.ended))return c("read: emitReadable",v.length,v.ended),v.length===0&&v.ended?H(this):pe(this),null;if(w=X(w,v),w===0&&v.ended)return v.length===0&&H(this),null;var z=v.needReadable;c("need readable",z),(v.length===0||v.length-w<v.highWaterMark)&&(z=!0,c("length less than watermark",z)),v.ended||v.reading?(z=!1,c("reading or ended",z)):z&&(c("do read"),v.reading=!0,v.sync=!0,v.length===0&&(v.needReadable=!0),this._read(v.highWaterMark),v.sync=!1,v.reading||(w=X(M,v)));var ve;return w>0?ve=C(w,v):ve=null,ve===null?(v.needReadable=v.length<=v.highWaterMark,w=0):(v.length-=w,v.awaitDrain=0),v.length===0&&(v.ended||(v.needReadable=!0),M!==w&&v.ended&&H(this)),ve!==null&&this.emit("data",ve),ve};function ne(w,v){if(c("onEofChunk"),!v.ended){if(v.decoder){var M=v.decoder.end();M&&M.length&&(v.buffer.push(M),v.length+=v.objectMode?1:M.length)}v.ended=!0,v.sync?pe(w):(v.needReadable=!1,v.emittedReadable||(v.emittedReadable=!0,_e(w)))}}function pe(w){var v=w._readableState;c("emitReadable",v.needReadable,v.emittedReadable),v.needReadable=!1,v.emittedReadable||(c("emitReadable",v.flowing),v.emittedReadable=!0,process.nextTick(_e,w))}function _e(w){var v=w._readableState;c("emitReadable_",v.destroyed,v.length,v.ended),!v.destroyed&&(v.length||v.ended)&&(w.emit("readable"),v.emittedReadable=!1),v.needReadable=!v.flowing&&!v.ended&&v.length<=v.highWaterMark,O(w)}function Te(w,v){v.readingMore||(v.readingMore=!0,process.nextTick(We,w,v))}function We(w,v){for(;!v.reading&&!v.ended&&(v.length<v.highWaterMark||v.flowing&&v.length===0);){var M=v.length;if(c("maybeReadMore read 0"),w.read(0),M===v.length)break}v.readingMore=!1}B.prototype._read=function(w){I(this,new x("_read()"))},B.prototype.pipe=function(w,v){var M=this,z=this._readableState;switch(z.pipesCount){case 0:z.pipes=w;break;case 1:z.pipes=[z.pipes,w];break;default:z.pipes.push(w);break}z.pipesCount+=1,c("pipe count=%d opts=%j",z.pipesCount,v);var ve=(!v||v.end!==!1)&&w!==process.stdout&&w!==process.stderr,ee=ve?tr:Sr;z.endEmitted?process.nextTick(ee):M.once("end",ee),w.on("unpipe",ae);function ae(m,u){c("onunpipe"),m===M&&u&&u.hasUnpiped===!1&&(u.hasUnpiped=!0,Vr())}function tr(){c("onend"),w.end()}var qr=fe(M);w.on("drain",qr);var In=!1;function Vr(){c("cleanup"),w.removeListener("close",Bn),w.removeListener("finish",ft),w.removeListener("drain",qr),w.removeListener("error",Ar),w.removeListener("unpipe",ae),M.removeListener("end",tr),M.removeListener("end",Sr),M.removeListener("data",ot),In=!0,z.awaitDrain&&(!w._writableState||w._writableState.needDrain)&&qr()}M.on("data",ot);function ot(m){c("ondata");var u=w.write(m);c("dest.write",u),u===!1&&((z.pipesCount===1&&z.pipes===w||z.pipesCount>1&&Z(z.pipes,w)!==-1)&&!In&&(c("false write response, pause",z.awaitDrain),z.awaitDrain++),M.pause())}function Ar(m){c("onerror",m),Sr(),w.removeListener("error",Ar),t(w,"error")===0&&I(w,m)}N(w,"error",Ar);function Bn(){w.removeListener("finish",ft),Sr()}w.once("close",Bn);function ft(){c("onfinish"),w.removeListener("close",Bn),Sr()}w.once("finish",ft);function Sr(){c("unpipe"),M.unpipe(w)}return w.emit("pipe",M),z.flowing||(c("pipe resume"),M.resume()),w};function fe(w){return function(){var M=w._readableState;c("pipeOnDrain",M.awaitDrain),M.awaitDrain&&M.awaitDrain--,M.awaitDrain===0&&t(w,"data")&&(M.flowing=!0,O(w))}}B.prototype.unpipe=function(w){var v=this._readableState,M={hasUnpiped:!1};if(v.pipesCount===0)return this;if(v.pipesCount===1)return w&&w!==v.pipes?this:(w||(w=v.pipes),v.pipes=null,v.pipesCount=0,v.flowing=!1,w&&w.emit("unpipe",this,M),this);if(!w){var z=v.pipes,ve=v.pipesCount;v.pipes=null,v.pipesCount=0,v.flowing=!1;for(var ee=0;ee<ve;ee++)z[ee].emit("unpipe",this,{hasUnpiped:!1});return this}var ae=Z(v.pipes,w);return ae===-1?this:(v.pipes.splice(ae,1),v.pipesCount-=1,v.pipesCount===1&&(v.pipes=v.pipes[0]),w.emit("unpipe",this,M),this)},B.prototype.on=function(w,v){var M=r.prototype.on.call(this,w,v),z=this._readableState;return w==="data"?(z.readableListening=this.listenerCount("readable")>0,z.flowing!==!1&&this.resume()):w==="readable"&&!z.endEmitted&&!z.readableListening&&(z.readableListening=z.needReadable=!0,z.flowing=!1,z.emittedReadable=!1,c("on readable",z.length,z.reading),z.length?pe(this):z.reading||process.nextTick(st,this)),M},B.prototype.addListener=B.prototype.on,B.prototype.removeListener=function(w,v){var M=r.prototype.removeListener.call(this,w,v);return w==="readable"&&process.nextTick(me,this),M},B.prototype.removeAllListeners=function(w){var v=r.prototype.removeAllListeners.apply(this,arguments);return(w==="readable"||w===void 0)&&process.nextTick(me,this),v};function me(w){var v=w._readableState;v.readableListening=w.listenerCount("readable")>0,v.resumeScheduled&&!v.paused?v.flowing=!0:w.listenerCount("data")>0&&w.resume()}function st(w){c("readable nexttick read 0"),w.read(0)}B.prototype.resume=function(){var w=this._readableState;return w.flowing||(c("resume"),w.flowing=!w.readableListening,er(this,w)),w.paused=!1,this};function er(w,v){v.resumeScheduled||(v.resumeScheduled=!0,process.nextTick(Rt,w,v))}function Rt(w,v){c("resume",v.reading),v.reading||w.read(0),v.resumeScheduled=!1,w.emit("resume"),O(w),v.flowing&&!v.reading&&w.read(0)}B.prototype.pause=function(){return c("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(c("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function O(w){var v=w._readableState;for(c("flow",v.flowing);v.flowing&&w.read()!==null;);}B.prototype.wrap=function(w){var v=this,M=this._readableState,z=!1;w.on("end",function(){if(c("wrapped end"),M.decoder&&!M.ended){var ae=M.decoder.end();ae&&ae.length&&v.push(ae)}v.push(null)}),w.on("data",function(ae){if(c("wrapped data"),M.decoder&&(ae=M.decoder.write(ae)),!(M.objectMode&&ae==null)&&!(!M.objectMode&&(!ae||!ae.length))){var tr=v.push(ae);tr||(z=!0,w.pause())}});for(var ve in w)this[ve]===void 0&&typeof w[ve]=="function"&&(this[ve]=function(tr){return function(){return w[tr].apply(w,arguments)}}(ve));for(var ee=0;ee<S.length;ee++)w.on(S[ee],this.emit.bind(this,S[ee]));return this._read=function(ae){c("wrapped _read",ae),z&&(z=!1,w.resume())},this},typeof Symbol=="function"&&(B.prototype[Symbol.asyncIterator]=function(){return A===void 0&&(A=V1()),A(this)}),Object.defineProperty(B.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(B.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(B.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(v){this._readableState&&(this._readableState.flowing=v)}}),B._fromList=C,Object.defineProperty(B.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function C(w,v){if(v.length===0)return null;var M;return v.objectMode?M=v.buffer.shift():!w||w>=v.length?(v.decoder?M=v.buffer.join(""):v.buffer.length===1?M=v.buffer.first():M=v.buffer.concat(v.length),v.buffer.clear()):M=v.buffer.consume(w,v.decoder),M}function H(w){var v=w._readableState;c("endReadable",v.endEmitted),v.endEmitted||(v.ended=!0,process.nextTick(K,v,w))}function K(w,v){if(c("endReadableNT",w.endEmitted,w.length),!w.endEmitted&&w.length===0&&(w.endEmitted=!0,v.readable=!1,v.emit("end"),w.autoDestroy)){var M=v._writableState;(!M||M.autoDestroy&&M.finished)&&v.destroy()}}typeof Symbol=="function"&&(B.from=function(w,v){return E===void 0&&(E=W1()),E(B,w,v)});function Z(w,v){for(var M=0,z=w.length;M<z;M++)if(w[M]===v)return M;return-1}return Xo}var Al=Xt,ro=Gr.codes,K1=ro.ERR_METHOD_NOT_IMPLEMENTED,Y1=ro.ERR_MULTIPLE_CALLBACK,X1=ro.ERR_TRANSFORM_ALREADY_TRANSFORMING,J1=ro.ERR_TRANSFORM_WITH_LENGTH_0,no=vn();He(Xt,no);function Q1(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(n===null)return this.emit("error",new Y1);r.writechunk=null,r.writecb=null,t!=null&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function Xt(e){if(!(this instanceof Xt))return new Xt(e);no.call(this,e),this._transformState={afterTransform:Q1.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",Z1)}function Z1(){var e=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(t,r){Gu(e,t,r)}):Gu(this,null,null)}Xt.prototype.push=function(e,t){return this._transformState.needTransform=!1,no.prototype.push.call(this,e,t)};Xt.prototype._transform=function(e,t,r){r(new K1("_transform()"))};Xt.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}};Xt.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};Xt.prototype._destroy=function(e,t){no.prototype._destroy.call(this,e,function(r){t(r)})};function Gu(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new J1;if(e._transformState.transforming)throw new X1;return e.push(null)}var ew=Ii,Sl=Al;He(Ii,Sl);function Ii(e){if(!(this instanceof Ii))return new Ii(e);Sl.call(this,e)}Ii.prototype._transform=function(e,t,r){r(null,e)};var Jo;function tw(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var Pl=Gr.codes,rw=Pl.ERR_MISSING_ARGS,nw=Pl.ERR_STREAM_DESTROYED;function zu(e){if(e)throw e}function iw(e){return e.setHeader&&typeof e.abort=="function"}function sw(e,t,r,n){n=tw(n);var i=!1;e.on("close",function(){i=!0}),Jo===void 0&&(Jo=Tc),Jo(e,{readable:t,writable:r},function(o){if(o)return n(o);i=!0,n()});var s=!1;return function(o){if(!i&&!s){if(s=!0,iw(e))return e.abort();if(typeof e.destroy=="function")return e.destroy();n(o||new nw("pipe"))}}}function qu(e){e()}function ow(e,t){return e.pipe(t)}function aw(e){return!e.length||typeof e[e.length-1]!="function"?zu:e.pop()}function cw(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=aw(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new rw("streams");var i,s=t.map(function(o,a){var c=a<t.length-1,f=a>0;return sw(o,c,f,function(l){i||(i=l),l&&s.forEach(qu),!c&&(s.forEach(qu),n(i))})});return t.reduce(ow)}var uw=cw;(function(e,t){t=e.exports=xl(),t.Stream=t,t.Readable=t,t.Writable=vl(),t.Duplex=vn(),t.Transform=Al,t.PassThrough=ew,t.finished=Tc,t.pipeline=uw})(Ia,Ia.exports);var Tl=Ia.exports,Is=tt.Buffer,kl=Tl.Transform,fw=He;function dw(e,t){if(!Is.isBuffer(e)&&typeof e!="string")throw new TypeError(t+" must be a string or a buffer")}function Er(e){kl.call(this),this._block=Is.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}fw(Er,kl);Er.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(i){n=i}r(n)};Er.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(r){t=r}e(t)};Er.prototype.update=function(e,t){if(dw(e,"Data"),this._finalized)throw new Error("Digest already called");Is.isBuffer(e)||(e=Is.from(e,t));for(var r=this._block,n=0;this._blockOffset+e.length-n>=this._blockSize;){for(var i=this._blockOffset;i<this._blockSize;)r[i++]=e[n++];this._update(),this._blockOffset=0}for(;n<e.length;)r[this._blockOffset++]=e[n++];for(var s=0,o=e.length*8;o>0;++s)this._length[s]+=o,o=this._length[s]/4294967296|0,o>0&&(this._length[s]-=4294967296*o);return this};Er.prototype._update=function(){throw new Error("_update is not implemented")};Er.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();e!==void 0&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t};Er.prototype._digest=function(){throw new Error("_digest is not implemented")};var lw=Er,hw=He,Il=lw,pw=tt.Buffer,yw=new Array(16);function io(){Il.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}hw(io,Il);io.prototype._update=function(){for(var e=yw,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);var r=this._a,n=this._b,i=this._c,s=this._d;r=De(r,n,i,s,e[0],3614090360,7),s=De(s,r,n,i,e[1],3905402710,12),i=De(i,s,r,n,e[2],606105819,17),n=De(n,i,s,r,e[3],3250441966,22),r=De(r,n,i,s,e[4],4118548399,7),s=De(s,r,n,i,e[5],1200080426,12),i=De(i,s,r,n,e[6],2821735955,17),n=De(n,i,s,r,e[7],4249261313,22),r=De(r,n,i,s,e[8],1770035416,7),s=De(s,r,n,i,e[9],2336552879,12),i=De(i,s,r,n,e[10],4294925233,17),n=De(n,i,s,r,e[11],2304563134,22),r=De(r,n,i,s,e[12],1804603682,7),s=De(s,r,n,i,e[13],4254626195,12),i=De(i,s,r,n,e[14],2792965006,17),n=De(n,i,s,r,e[15],1236535329,22),r=je(r,n,i,s,e[1],4129170786,5),s=je(s,r,n,i,e[6],3225465664,9),i=je(i,s,r,n,e[11],643717713,14),n=je(n,i,s,r,e[0],3921069994,20),r=je(r,n,i,s,e[5],3593408605,5),s=je(s,r,n,i,e[10],38016083,9),i=je(i,s,r,n,e[15],3634488961,14),n=je(n,i,s,r,e[4],3889429448,20),r=je(r,n,i,s,e[9],568446438,5),s=je(s,r,n,i,e[14],3275163606,9),i=je(i,s,r,n,e[3],4107603335,14),n=je(n,i,s,r,e[8],1163531501,20),r=je(r,n,i,s,e[13],2850285829,5),s=je(s,r,n,i,e[2],4243563512,9),i=je(i,s,r,n,e[7],1735328473,14),n=je(n,i,s,r,e[12],2368359562,20),r=Ge(r,n,i,s,e[5],4294588738,4),s=Ge(s,r,n,i,e[8],2272392833,11),i=Ge(i,s,r,n,e[11],1839030562,16),n=Ge(n,i,s,r,e[14],4259657740,23),r=Ge(r,n,i,s,e[1],2763975236,4),s=Ge(s,r,n,i,e[4],1272893353,11),i=Ge(i,s,r,n,e[7],4139469664,16),n=Ge(n,i,s,r,e[10],3200236656,23),r=Ge(r,n,i,s,e[13],681279174,4),s=Ge(s,r,n,i,e[0],3936430074,11),i=Ge(i,s,r,n,e[3],3572445317,16),n=Ge(n,i,s,r,e[6],76029189,23),r=Ge(r,n,i,s,e[9],3654602809,4),s=Ge(s,r,n,i,e[12],3873151461,11),i=Ge(i,s,r,n,e[15],530742520,16),n=Ge(n,i,s,r,e[2],3299628645,23),r=ze(r,n,i,s,e[0],4096336452,6),s=ze(s,r,n,i,e[7],1126891415,10),i=ze(i,s,r,n,e[14],2878612391,15),n=ze(n,i,s,r,e[5],4237533241,21),r=ze(r,n,i,s,e[12],1700485571,6),s=ze(s,r,n,i,e[3],2399980690,10),i=ze(i,s,r,n,e[10],4293915773,15),n=ze(n,i,s,r,e[1],2240044497,21),r=ze(r,n,i,s,e[8],1873313359,6),s=ze(s,r,n,i,e[15],4264355552,10),i=ze(i,s,r,n,e[6],2734768916,15),n=ze(n,i,s,r,e[13],1309151649,21),r=ze(r,n,i,s,e[4],4149444226,6),s=ze(s,r,n,i,e[11],3174756917,10),i=ze(i,s,r,n,e[2],718787259,15),n=ze(n,i,s,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+s|0};io.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=pw.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e};function so(e,t){return e<<t|e>>>32-t}function De(e,t,r,n,i,s,o){return so(e+(t&r|~t&n)+i+s|0,o)+t|0}function je(e,t,r,n,i,s,o){return so(e+(t&n|r&~n)+i+s|0,o)+t|0}function Ge(e,t,r,n,i,s,o){return so(e+(t^r^n)+i+s|0,o)+t|0}function ze(e,t,r,n,i,s,o){return so(e+(r^(t|~n))+i+s|0,o)+t|0}var mw=io,Bs=tt.Buffer,Bl=Tl.Transform,bw=He;function gw(e,t){if(!Bs.isBuffer(e)&&typeof e!="string")throw new TypeError(t+" must be a string or a buffer")}function xr(e){Bl.call(this),this._block=Bs.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}bw(xr,Bl);xr.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(i){n=i}r(n)};xr.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(r){t=r}e(t)};xr.prototype.update=function(e,t){if(gw(e,"Data"),this._finalized)throw new Error("Digest already called");Bs.isBuffer(e)||(e=Bs.from(e,t));for(var r=this._block,n=0;this._blockOffset+e.length-n>=this._blockSize;){for(var i=this._blockOffset;i<this._blockSize;)r[i++]=e[n++];this._update(),this._blockOffset=0}for(;n<e.length;)r[this._blockOffset++]=e[n++];for(var s=0,o=e.length*8;o>0;++s)this._length[s]+=o,o=this._length[s]/4294967296|0,o>0&&(this._length[s]-=4294967296*o);return this};xr.prototype._update=function(){throw new Error("_update is not implemented")};xr.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();e!==void 0&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t};xr.prototype._digest=function(){throw new Error("_digest is not implemented")};var ww=xr,Qo=Zt.Buffer,_w=He,Cl=ww,vw=new Array(16),$n=[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],Hn=[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],Dn=[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],jn=[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],Gn=[0,1518500249,1859775393,2400959708,2840853838],zn=[1352829926,1548603684,1836072691,2053994217,0];function oo(){Cl.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}_w(oo,Cl);oo.prototype._update=function(){for(var e=vw,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);for(var r=this._a|0,n=this._b|0,i=this._c|0,s=this._d|0,o=this._e|0,a=this._a|0,c=this._b|0,f=this._c|0,l=this._d|0,h=this._e|0,y=0;y<80;y+=1){var p,g;y<16?(p=Vu(r,n,i,s,o,e[$n[y]],Gn[0],Dn[y]),g=Xu(a,c,f,l,h,e[Hn[y]],zn[0],jn[y])):y<32?(p=Wu(r,n,i,s,o,e[$n[y]],Gn[1],Dn[y]),g=Yu(a,c,f,l,h,e[Hn[y]],zn[1],jn[y])):y<48?(p=Ku(r,n,i,s,o,e[$n[y]],Gn[2],Dn[y]),g=Ku(a,c,f,l,h,e[Hn[y]],zn[2],jn[y])):y<64?(p=Yu(r,n,i,s,o,e[$n[y]],Gn[3],Dn[y]),g=Wu(a,c,f,l,h,e[Hn[y]],zn[3],jn[y])):(p=Xu(r,n,i,s,o,e[$n[y]],Gn[4],Dn[y]),g=Vu(a,c,f,l,h,e[Hn[y]],zn[4],jn[y])),r=o,o=s,s=Hr(i,10),i=n,n=p,a=h,h=l,l=Hr(f,10),f=c,c=g}var _=this._b+i+l|0;this._b=this._c+s+h|0,this._c=this._d+o+a|0,this._d=this._e+r+c|0,this._e=this._a+n+f|0,this._a=_};oo.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=Qo.alloc?Qo.alloc(20):new Qo(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e};function Hr(e,t){return e<<t|e>>>32-t}function Vu(e,t,r,n,i,s,o,a){return Hr(e+(t^r^n)+s+o|0,a)+i|0}function Wu(e,t,r,n,i,s,o,a){return Hr(e+(t&r|~t&n)+s+o|0,a)+i|0}function Ku(e,t,r,n,i,s,o,a){return Hr(e+((t|~r)^n)+s+o|0,a)+i|0}function Yu(e,t,r,n,i,s,o,a){return Hr(e+(t&n|r&~n)+s+o|0,a)+i|0}function Xu(e,t,r,n,i,s,o,a){return Hr(e+(t^(r|~n))+s+o|0,a)+i|0}var Ew=oo,Ol={exports:{}},Rl=tt.Buffer;function ao(e,t){this._block=Rl.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}ao.prototype.update=function(e,t){typeof e=="string"&&(t=t||"utf8",e=Rl.from(e,t));for(var r=this._block,n=this._blockSize,i=e.length,s=this._len,o=0;o<i;){for(var a=s%n,c=Math.min(i-o,n-a),f=0;f<c;f++)r[a+f]=e[o+f];s+=c,o+=c,s%n===0&&this._update(r)}return this._len+=i,this};ao.prototype.digest=function(e){var t=this._len%this._blockSize;this._block[t]=128,this._block.fill(0,t+1),t>=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=this._len*8;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(r&4294967295)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var s=this._hash();return e?s.toString(e):s};ao.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var kn=ao,xw=He,Fl=kn,Aw=tt.Buffer,Sw=[1518500249,1859775393,-1894007588,-899497514],Pw=new Array(80);function zi(){this.init(),this._w=Pw,Fl.call(this,64,56)}xw(zi,Fl);zi.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Tw(e){return e<<5|e>>>27}function kw(e){return e<<30|e>>>2}function Iw(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}zi.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,s=this._d|0,o=this._e|0,a=0;a<16;++a)t[a]=e.readInt32BE(a*4);for(;a<80;++a)t[a]=t[a-3]^t[a-8]^t[a-14]^t[a-16];for(var c=0;c<80;++c){var f=~~(c/20),l=Tw(r)+Iw(f,n,i,s)+o+t[c]+Sw[f]|0;o=s,s=i,i=kw(n),n=r,r=l}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=s+this._d|0,this._e=o+this._e|0};zi.prototype._hash=function(){var e=Aw.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};var Bw=zi,Cw=He,Ul=kn,Ow=tt.Buffer,Rw=[1518500249,1859775393,-1894007588,-899497514],Fw=new Array(80);function qi(){this.init(),this._w=Fw,Ul.call(this,64,56)}Cw(qi,Ul);qi.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Uw(e){return e<<1|e>>>31}function Nw(e){return e<<5|e>>>27}function Lw(e){return e<<30|e>>>2}function Mw(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}qi.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,s=this._d|0,o=this._e|0,a=0;a<16;++a)t[a]=e.readInt32BE(a*4);for(;a<80;++a)t[a]=Uw(t[a-3]^t[a-8]^t[a-14]^t[a-16]);for(var c=0;c<80;++c){var f=~~(c/20),l=Nw(r)+Mw(f,n,i,s)+o+t[c]+Rw[f]|0;o=s,s=i,i=Lw(n),n=r,r=l}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=s+this._d|0,this._e=o+this._e|0};qi.prototype._hash=function(){var e=Ow.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};var $w=qi,Hw=He,Nl=kn,Dw=tt.Buffer,jw=[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],Gw=new Array(64);function Vi(){this.init(),this._w=Gw,Nl.call(this,64,56)}Hw(Vi,Nl);Vi.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function zw(e,t,r){return r^e&(t^r)}function qw(e,t,r){return e&t|r&(e|t)}function Vw(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function Ww(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function Kw(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function Yw(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}Vi.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,s=this._d|0,o=this._e|0,a=this._f|0,c=this._g|0,f=this._h|0,l=0;l<16;++l)t[l]=e.readInt32BE(l*4);for(;l<64;++l)t[l]=Yw(t[l-2])+t[l-7]+Kw(t[l-15])+t[l-16]|0;for(var h=0;h<64;++h){var y=f+Ww(o)+zw(o,a,c)+jw[h]+t[h]|0,p=Vw(r)+qw(r,n,i)|0;f=c,c=a,a=o,o=s+y|0,s=i,i=n,n=r,r=y+p|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=s+this._d|0,this._e=o+this._e|0,this._f=a+this._f|0,this._g=c+this._g|0,this._h=f+this._h|0};Vi.prototype._hash=function(){var e=Dw.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e};var Ll=Vi,Xw=He,Jw=Ll,Qw=kn,Zw=tt.Buffer,e2=new Array(64);function co(){this.init(),this._w=e2,Qw.call(this,64,56)}Xw(co,Jw);co.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this};co.prototype._hash=function(){var e=Zw.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e};var t2=co,r2=He,Ml=kn,n2=tt.Buffer,Ju=[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],i2=new Array(160);function Wi(){this.init(),this._w=i2,Ml.call(this,128,112)}r2(Wi,Ml);Wi.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this};function Qu(e,t,r){return r^e&(t^r)}function Zu(e,t,r){return e&t|r&(e|t)}function ef(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function tf(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function s2(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function o2(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function a2(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function c2(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function Fe(e,t){return e>>>0<t>>>0?1:0}Wi.prototype._update=function(e){for(var t=this._w,r=this._ah|0,n=this._bh|0,i=this._ch|0,s=this._dh|0,o=this._eh|0,a=this._fh|0,c=this._gh|0,f=this._hh|0,l=this._al|0,h=this._bl|0,y=this._cl|0,p=this._dl|0,g=this._el|0,_=this._fl|0,x=this._gl|0,k=this._hl|0,T=0;T<32;T+=2)t[T]=e.readInt32BE(T*4),t[T+1]=e.readInt32BE(T*4+4);for(;T<160;T+=2){var A=t[T-30],E=t[T-15*2+1],I=s2(A,E),S=o2(E,A);A=t[T-2*2],E=t[T-2*2+1];var N=a2(A,E),$=c2(E,A),B=t[T-7*2],W=t[T-7*2+1],R=t[T-16*2],D=t[T-16*2+1],j=S+W|0,V=I+B+Fe(j,S)|0;j=j+$|0,V=V+N+Fe(j,$)|0,j=j+D|0,V=V+R+Fe(j,D)|0,t[T]=V,t[T+1]=j}for(var X=0;X<160;X+=2){V=t[X],j=t[X+1];var ne=Zu(r,n,i),pe=Zu(l,h,y),_e=ef(r,l),Te=ef(l,r),We=tf(o,g),fe=tf(g,o),me=Ju[X],st=Ju[X+1],er=Qu(o,a,c),Rt=Qu(g,_,x),O=k+fe|0,C=f+We+Fe(O,k)|0;O=O+Rt|0,C=C+er+Fe(O,Rt)|0,O=O+st|0,C=C+me+Fe(O,st)|0,O=O+j|0,C=C+V+Fe(O,j)|0;var H=Te+pe|0,K=_e+ne+Fe(H,Te)|0;f=c,k=x,c=a,x=_,a=o,_=g,g=p+O|0,o=s+C+Fe(g,p)|0,s=i,p=y,i=n,y=h,n=r,h=l,l=O+H|0,r=C+K+Fe(l,O)|0}this._al=this._al+l|0,this._bl=this._bl+h|0,this._cl=this._cl+y|0,this._dl=this._dl+p|0,this._el=this._el+g|0,this._fl=this._fl+_|0,this._gl=this._gl+x|0,this._hl=this._hl+k|0,this._ah=this._ah+r+Fe(this._al,l)|0,this._bh=this._bh+n+Fe(this._bl,h)|0,this._ch=this._ch+i+Fe(this._cl,y)|0,this._dh=this._dh+s+Fe(this._dl,p)|0,this._eh=this._eh+o+Fe(this._el,g)|0,this._fh=this._fh+a+Fe(this._fl,_)|0,this._gh=this._gh+c+Fe(this._gl,x)|0,this._hh=this._hh+f+Fe(this._hl,k)|0};Wi.prototype._hash=function(){var e=n2.allocUnsafe(64);function t(r,n,i){e.writeInt32BE(r,i),e.writeInt32BE(n,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e};var $l=Wi,u2=He,f2=$l,d2=kn,l2=tt.Buffer,h2=new Array(160);function uo(){this.init(),this._w=h2,d2.call(this,128,112)}u2(uo,f2);uo.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this};uo.prototype._hash=function(){var e=l2.allocUnsafe(48);function t(r,n,i){e.writeInt32BE(r,i),e.writeInt32BE(n,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e};var p2=uo,zr=Ol.exports=function(t){t=t.toLowerCase();var r=zr[t];if(!r)throw new Error(t+" is not supported (we accept pull requests)");return new r};zr.sha=Bw;zr.sha1=$w;zr.sha224=t2;zr.sha256=Ll;zr.sha384=p2;zr.sha512=$l;var y2=Ol.exports,kt=tt.Buffer,Hl=Sc.Transform,m2=ks.StringDecoder,b2=He;function _t(e){Hl.call(this),this.hashMode=typeof e=="string",this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}b2(_t,Hl);var g2=typeof Uint8Array<"u",w2=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u"&&ArrayBuffer.isView&&(kt.prototype instanceof Uint8Array||kt.TYPED_ARRAY_SUPPORT);function _2(e,t){if(e instanceof kt)return e;if(typeof e=="string")return kt.from(e,t);if(w2&&ArrayBuffer.isView(e)){if(e.byteLength===0)return kt.alloc(0);var r=kt.from(e.buffer,e.byteOffset,e.byteLength);if(r.byteLength===e.byteLength)return r}if(g2&&e instanceof Uint8Array||kt.isBuffer(e)&&e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e))return kt.from(e);throw new TypeError('The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView.')}_t.prototype.update=function(e,t,r){var n=_2(e,t),i=this._update(n);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)};_t.prototype.setAutoPadding=function(){};_t.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")};_t.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")};_t.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")};_t.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(i){n=i}finally{r(n)}};_t.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(r){t=r}e(t)};_t.prototype._finalOrDigest=function(e){var t=this.__final()||kt.alloc(0);return e&&(t=this._toString(t,e,!0)),t};_t.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new m2(t),this._encoding=t),this._encoding!==t)throw new Error("can’t switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n};var v2=_t,E2=He,x2=mw,A2=Ew,S2=y2,Dl=v2;function fo(e){Dl.call(this,"digest"),this._hash=e}E2(fo,Dl);fo.prototype._update=function(e){this._hash.update(e)};fo.prototype._final=function(){return this._hash.digest()};var P2=function(t){return t=t.toLowerCase(),t==="md5"?new x2:t==="rmd160"||t==="ripemd160"?new A2:new fo(S2(t))},as=tt.Buffer;function T2(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var n=0;n<e.length;n++){var i=e.charAt(n),s=i.charCodeAt(0);if(t[s]!==255)throw new TypeError(i+" is ambiguous");t[s]=n}var o=e.length,a=e.charAt(0),c=Math.log(o)/Math.log(256),f=Math.log(256)/Math.log(o);function l(p){if((Array.isArray(p)||p instanceof Uint8Array)&&(p=as.from(p)),!as.isBuffer(p))throw new TypeError("Expected Buffer");if(p.length===0)return"";for(var g=0,_=0,x=0,k=p.length;x!==k&&p[x]===0;)x++,g++;for(var T=(k-x)*f+1>>>0,A=new Uint8Array(T);x!==k;){for(var E=p[x],I=0,S=T-1;(E!==0||I<_)&&S!==-1;S--,I++)E+=256*A[S]>>>0,A[S]=E%o>>>0,E=E/o>>>0;if(E!==0)throw new Error("Non-zero carry");_=I,x++}for(var N=T-_;N!==T&&A[N]===0;)N++;for(var $=a.repeat(g);N<T;++N)$+=e.charAt(A[N]);return $}function h(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return as.alloc(0);for(var g=0,_=0,x=0;p[g]===a;)_++,g++;for(var k=(p.length-g)*c+1>>>0,T=new Uint8Array(k);g<p.length;){var A=p.charCodeAt(g);if(A>255)return;var E=t[A];if(E===255)return;for(var I=0,S=k-1;(E!==0||I<x)&&S!==-1;S--,I++)E+=o*T[S]>>>0,T[S]=E%256>>>0,E=E/256>>>0;if(E!==0)throw new Error("Non-zero carry");x=I,g++}for(var N=k-x;N!==k&&T[N]===0;)N++;var $=as.allocUnsafe(_+(k-N));$.fill(0,0,_);for(var B=_;N!==k;)$[B++]=T[N++];return $}function y(p){var g=h(p);if(g)return g;throw new Error("Non-base"+o+" character")}return{encode:l,decodeUnsafe:h,decode:y}}var k2=T2,I2=k2,B2="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",C2=I2(B2),Zo=C2,O2=tt.Buffer,R2=function(e){function t(s){var o=e(s);return Zo.encode(O2.concat([s,o],s.length+4))}function r(s){var o=s.slice(0,-4),a=s.slice(-4),c=e(o);if(!(a[0]^c[0]|a[1]^c[1]|a[2]^c[2]|a[3]^c[3]))return o}function n(s){var o=Zo.decodeUnsafe(s);if(o)return r(o)}function i(s){var o=Zo.decode(s),a=r(o);if(!a)throw new Error("Invalid checksum");return a}return{encode:t,decode:i,decodeUnsafe:n}},rf=P2,F2=R2;function U2(e){var t=rf("sha256").update(e).digest();return rf("sha256").update(t).digest()}var N2=F2(U2),Ca=N2;function jl(e,t){if(t!==void 0&&e[0]!==t)throw new Error("Invalid network version");if(e.length===33)return{version:e[0],privateKey:e.slice(1,33),compressed:!1};if(e.length!==34)throw new Error("Invalid WIF length");if(e[33]!==1)throw new Error("Invalid compression flag");return{version:e[0],privateKey:e.slice(1,33),compressed:!0}}function Oa(e,t,r){var n=new Buffer(r?34:33);return n.writeUInt8(e,0),t.copy(n,1),r&&(n[33]=1),n}function L2(e,t){return jl(Ca.decode(e),t)}function M2(e,t,r){return typeof e=="number"?Ca.encode(Oa(e,t,r)):Ca.encode(Oa(e.version,e.privateKey,e.compressed))}var $2={decode:L2,decodeRaw:jl,encode:M2,encodeRaw:Oa},lo={};Object.defineProperty(lo,"__esModule",{value:!0});lo.testEcc=void 0;const Y=e=>Buffer.from(e,"hex");function H2(e){ge(e.isPoint(Y("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),ge(!e.isPoint(Y("030000000000000000000000000000000000000000000000000000000000000005"))),ge(e.isPrivate(Y("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),ge(e.isPrivate(Y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),ge(!e.isPrivate(Y("0000000000000000000000000000000000000000000000000000000000000000"))),ge(!e.isPrivate(Y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),ge(!e.isPrivate(Y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),ge(Buffer.from(e.privateAdd(Y("0000000000000000000000000000000000000000000000000000000000000001"),Y("0000000000000000000000000000000000000000000000000000000000000000"))).equals(Y("0000000000000000000000000000000000000000000000000000000000000001"))),ge(e.privateAdd(Y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),Y("0000000000000000000000000000000000000000000000000000000000000003"))===null),ge(Buffer.from(e.privateAdd(Y("e211078564db65c3ce7704f08262b1f38f1ef412ad15b5ac2d76657a63b2c500"),Y("b51fbb69051255d1becbd683de5848242a89c229348dd72896a87ada94ae8665"))).equals(Y("9730c2ee69edbb958d42db7460bafa18fef9d955325aec99044c81c8282b0a24"))),ge(Buffer.from(e.privateNegate(Y("0000000000000000000000000000000000000000000000000000000000000001"))).equals(Y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),ge(Buffer.from(e.privateNegate(Y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"))).equals(Y("0000000000000000000000000000000000000000000000000000000000000003"))),ge(Buffer.from(e.privateNegate(Y("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(Y("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792"))),ge(Buffer.from(e.pointCompress(Y("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!0)).equals(Y("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),ge(Buffer.from(e.pointCompress(Y("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!1)).equals(Y("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),ge(Buffer.from(e.pointCompress(Y("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!0)).equals(Y("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),ge(Buffer.from(e.pointCompress(Y("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!1)).equals(Y("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),ge(Buffer.from(e.pointFromScalar(Y("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(Y("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),ge(e.xOnlyPointAddTweak(Y("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))===null);let t=e.xOnlyPointAddTweak(Y("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),Y("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));ge(Buffer.from(t.xOnlyPubkey).equals(Y("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&t.parity===1),t=e.xOnlyPointAddTweak(Y("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),Y("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47")),ge(Buffer.from(t.xOnlyPubkey).equals(Y("9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"))&&t.parity===0),ge(Buffer.from(e.sign(Y("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),Y("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))).equals(Y("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),ge(e.verify(Y("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),Y("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Y("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),e.signSchnorr&&ge(Buffer.from(e.signSchnorr(Y("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),Y("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),Y("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906"))).equals(Y("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),e.verifySchnorr&&ge(e.verifySchnorr(Y("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),Y("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),Y("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}lo.testEcc=H2;function ge(e){if(!e)throw new Error("ecc library invalid")}Object.defineProperty(wn,"__esModule",{value:!0});wn.ECPairFactory=wn.networks=void 0;const Ra=_n;wn.networks=Ra;const Je=al,D2=c1,nf=$2,j2=lo,ea=Je.typeforce.maybe(Je.typeforce.compile({compressed:Je.maybe(Je.Boolean),network:Je.maybe(Je.Network)})),G2=e=>e.length===32?e:e.slice(1,33);function z2(e){(0,j2.testEcc)(e);function t(a){return e.isPoint(a)}function r(a,c){if(Je.typeforce(Je.Buffer256bit,a),!e.isPrivate(a))throw new TypeError("Private key not in range [1, n)");return Je.typeforce(ea,c),new o(a,void 0,c)}function n(a,c){return Je.typeforce(e.isPoint,a),Je.typeforce(ea,c),new o(void 0,a,c)}function i(a,c){const f=nf.decode(a),l=f.version;if(Je.Array(c)){if(c=c.filter(h=>l===h.wif).pop(),!c)throw new Error("Unknown network version")}else if(c=c||Ra.bitcoin,l!==c.wif)throw new Error("Invalid network version");return r(f.privateKey,{compressed:f.compressed,network:c})}function s(a){Je.typeforce(ea,a),a===void 0&&(a={});const c=a.rng||D2;let f;do f=c(32),Je.typeforce(Je.Buffer256bit,f);while(!e.isPrivate(f));return r(f,a)}class o{constructor(c,f,l){Wr(this,"__D");Wr(this,"__Q");Wr(this,"compressed");Wr(this,"network");Wr(this,"lowR");this.__D=c,this.__Q=f,this.lowR=!1,l===void 0&&(l={}),this.compressed=l.compressed===void 0?!0:l.compressed,this.network=l.network||Ra.bitcoin,f!==void 0&&(this.__Q=Buffer.from(e.pointCompress(f,this.compressed)))}get privateKey(){return this.__D}get publicKey(){if(!this.__Q){const c=e.pointFromScalar(this.__D,this.compressed);this.__Q=Buffer.from(c)}return this.__Q}toWIF(){if(!this.__D)throw new Error("Missing private key");return nf.encode(this.network.wif,this.__D,this.compressed)}tweak(c){return this.privateKey?this.tweakFromPrivateKey(c):this.tweakFromPublicKey(c)}sign(c,f){if(!this.__D)throw new Error("Missing private key");if(f===void 0&&(f=this.lowR),f===!1)return Buffer.from(e.sign(c,this.__D));{let l=e.sign(c,this.__D);const h=Buffer.alloc(32,0);let y=0;for(;l[0]>127;)y++,h.writeUIntLE(y,0,6),l=e.sign(c,this.__D,h);return Buffer.from(l)}}signSchnorr(c){if(!this.privateKey)throw new Error("Missing private key");if(!e.signSchnorr)throw new Error("signSchnorr not supported by ecc library");return Buffer.from(e.signSchnorr(c,this.privateKey))}verify(c,f){return e.verify(c,this.publicKey,f)}verifySchnorr(c,f){if(!e.verifySchnorr)throw new Error("verifySchnorr not supported by ecc library");return e.verifySchnorr(c,this.publicKey.subarray(1,33),f)}tweakFromPublicKey(c){const f=G2(this.publicKey),l=e.xOnlyPointAddTweak(f,c);if(!l||l.xOnlyPubkey===null)throw new Error("Cannot tweak public key!");const h=Buffer.from([l.parity===0?2:3]);return n(Buffer.concat([h,l.xOnlyPubkey]),{network:this.network,compressed:this.compressed})}tweakFromPrivateKey(c){const l=this.publicKey[0]===3||this.publicKey[0]===4&&(this.publicKey[64]&1)===1?e.privateNegate(this.privateKey):this.privateKey,h=e.privateAdd(l,c);if(!h)throw new Error("Invalid tweaked private key!");return r(Buffer.from(h),{network:this.network,compressed:this.compressed})}}return{isPoint:t,fromPrivateKey:r,fromPublicKey:n,fromWIF:i,makeRandom:s}}wn.ECPairFactory=z2;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.networks=e.ECPairFactory=e.default=void 0;var t=wn;Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t.ECPairFactory}}),Object.defineProperty(e,"ECPairFactory",{enumerable:!0,get:function(){return t.ECPairFactory}}),Object.defineProperty(e,"networks",{enumerable:!0,get:function(){return t.networks}})})(ol);const q2=wm(ol);class Bi extends q.EventBroker{get isInitialized(){return!!this.digestKey}constructor(t,r){super(),this.digestKey=t,this.walletClient=r}static fromDigestKey(t){return new Bi(kr(t))}static fromWalletClient(t){return new Bi(void 0,t)}async initialize(){if(this.digestKey)return ie("Already initialized");const t=await this.deriveDigestKeyFromWalletClient();return t.error?G(t.error):(this.emit("initialized",!0),ie("Initialized"))}async deriveDigestKeyFromWalletClient(){if(!this.walletClient)return G("No walletClient found");if(!this.walletClient.account)return G("No account found");try{const t=await this.walletClient.signTypedData({account:this.walletClient.account,types:{EIP712Domain:[{name:"name",type:"string"},{name:"version",type:"string"}],Data:[{name:"Message",type:"string"},{name:"Version",type:"string"},{name:"Nonce",type:"uint256"}]},domain:{name:"GARDEN FINANCE",version:"1"},primaryType:"Data",message:{Message:"Initialize your account",Version:"1.0.2",Nonce:1n}});return this.digestKey=kr(Wn(t)),this.emit("initialized",!0),ie(this.digestKey)}catch(t){return G("Failed to initialize: "+t)}}async getDigestKey(){if(!this.digestKey&&!this.walletClient)return G("No private key or wallet client found");if(!this.digestKey&&this.walletClient){const t=await this.deriveDigestKeyFromWalletClient();if(t.error)return G(t.error)}return this.digestKey?ie(this.digestKey):G("No private key found")}async generateSecret(t){const r=await this.signMessage(t);if(r.error)return G(r.error);const n=Wn(q.with0x(r.val)),i=Wn(n);return ie({secret:n,secretHash:i})}async signMessage(t){if(!this.digestKey){const f=await this.getDigestKey();if(f.error)return G(f.error);this.digestKey=f.val}const r=q2(Or),n="Garden.fi"+t.toString(),i=Buffer.from(n,"utf8"),s=Wn(i),o=Buffer.from(kr(this.digestKey),"hex");if(o.length!==32)return G("Invalid private key length. Expected 32 bytes.");const c=r.fromPrivateKey(o).sign(Buffer.from(kr(s),"hex"));return ie(c.toString("hex"))}}const sf=[{inputs:[{internalType:"address",name:"token_",type:"address"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"version",type:"string"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"InvalidShortString",type:"error"},{inputs:[{internalType:"string",name:"str",type:"string"}],name:"StringTooLong",type:"error"},{anonymous:!1,inputs:[],name:"EIP712DomainChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"secretHash",type:"bytes32"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"Initiated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"secretHash",type:"bytes32"},{indexed:!1,internalType:"bytes",name:"secret",type:"bytes"}],name:"Redeemed",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"}],name:"Refunded",type:"event"},{inputs:[],name:"eip712Domain",outputs:[{internalType:"bytes1",name:"fields",type:"bytes1"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"version",type:"string"},{internalType:"uint256",name:"chainId",type:"uint256"},{internalType:"address",name:"verifyingContract",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"uint256[]",name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"redeemer",type:"address"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"secretHash",type:"bytes32"}],name:"initiate",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"redeemer",type:"address"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"secretHash",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"initiateWithSignature",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"instantRefund",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"redeemer",type:"address"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"secretHash",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],internalType:"struct HTLC.InitWithSig[]",name:"inits",type:"tuple[]"},{components:[{internalType:"bytes32",name:"orderID",type:"bytes32"},{internalType:"bytes",name:"secret",type:"bytes"}],internalType:"struct HTLC.Redeem[]",name:"redeems",type:"tuple[]"},{components:[{internalType:"bytes32",name:"orderID",type:"bytes32"}],internalType:"struct HTLC.Refund[]",name:"refunds",type:"tuple[]"}],name:"multicall",outputs:[{internalType:"bool[]",name:"results",type:"bool[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"",type:"bytes32"}],name:"orders",outputs:[{internalType:"bool",name:"isFulfilled",type:"bool"},{internalType:"address",name:"initiator",type:"address"},{internalType:"address",name:"redeemer",type:"address"},{internalType:"uint256",name:"initiatedAt",type:"uint256"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"},{internalType:"bytes",name:"secret",type:"bytes"}],name:"redeem",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"}],name:"refund",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"token",outputs:[{internalType:"contract IERC20",name:"",type:"address"}],stateMutability:"view",type:"function"}],V2={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}},W2={block:Qp({format(e){var r;return{transactions:(r=e.transactions)==null?void 0:r.map(n=>{if(typeof n=="string")return n;const i=Ja(n);return i.typeHex==="0x7e"&&(i.isSystemTx=n.isSystemTx,i.mint=n.mint?pt(n.mint):void 0,i.sourceHash=n.sourceHash,i.type="deposit"),i}),stateRoot:e.stateRoot}}}),transaction:Xp({format(e){const t={};return e.type==="0x7e"&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?pt(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:jy({format(e){return{l1GasPrice:e.l1GasPrice?pt(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?pt(e.l1GasUsed):null,l1Fee:e.l1Fee?pt(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null}}})};function K2(e,t){return J2(e)?X2(e):lm(e,t)}const Y2={transaction:K2};function X2(e){Q2(e);const{sourceHash:t,data:r,from:n,gas:i,isSystemTx:s,mint:o,to:a,value:c}=e,f=[t,n,a??"0x",o?J(o):"0x",c?J(c):"0x",i?J(i):"0x",s?"0x1":"0x",r??"0x"];return Ot(["0x7e",mr(f)])}function J2(e){return e.type==="deposit"||typeof e.sourceHash<"u"}function Q2(e){const{from:t,to:r}=e;if(t&&!Ue(t))throw new et({address:t});if(r&&!Ue(r))throw new et({address:r})}const En={contracts:V2,formatters:W2,serializers:Y2},Z2=wt({id:42161,name:"Arbitrum One",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://arbiscan.io",apiUrl:"https://api.arbiscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:7654707}}}),e_=wt({id:421614,name:"Arbitrum Sepolia",nativeCurrency:{name:"Arbitrum Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia-rollup.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://sepolia.arbiscan.io",apiUrl:"https://api-sepolia.arbiscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:81930}},testnet:!0}),qn=1,t_=wt({...En,id:8453,name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.base.org"]}},blockExplorers:{default:{name:"Basescan",url:"https://basescan.org",apiUrl:"https://api.basescan.org/api"}},contracts:{...En.contracts,disputeGameFactory:{[qn]:{address:"0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e"}},l2OutputOracle:{[qn]:{address:"0x56315b90c40730925ec5485cf004d835058518A0"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:5022},portal:{[qn]:{address:"0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",blockCreated:17482143}},l1StandardBridge:{[qn]:{address:"0x3154Cf16ccdb4C6d922629664174b904d80F2C35",blockCreated:17482143}}},sourceId:qn}),Vn=11155111,r_=wt({...En,id:84532,network:"base-sepolia",name:"Base Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.base.org"]}},blockExplorers:{default:{name:"Basescan",url:"https://sepolia.basescan.org",apiUrl:"https://api-sepolia.basescan.org/api"}},contracts:{...En.contracts,disputeGameFactory:{[Vn]:{address:"0xd6E6dBf4F7EA0ac412fD8b65ED297e64BB7a06E1"}},l2OutputOracle:{[Vn]:{address:"0x84457ca9D0163FbC4bbfe4Dfbb20ba46e48DF254"}},portal:{[Vn]:{address:"0x49f53e41452c74589e85ca1677426ba426459e85",blockCreated:4446677}},l1StandardBridge:{[Vn]:{address:"0xfd0Bf71F60660E2f608ed56e1659C450eB113120",blockCreated:4446677}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:1059647}},testnet:!0,sourceId:Vn}),n_=wt({id:80094,name:"Berachain",nativeCurrency:{decimals:18,name:"BERA Token",symbol:"BERA"},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:0},ensRegistry:{address:"0x5b22280886a2f5e09a49bea7e320eab0e5320e28",blockCreated:877007},ensUniversalResolver:{address:"0xddfb18888a9466688235887dec2a10c4f5effee9",blockCreated:877008}},rpcUrls:{default:{http:["https://rpc.berachain.com"]}},blockExplorers:{default:{name:"Berascan",url:"https://berascan.com"}},ensTlds:[".bera"],testnet:!1}),i_=wt({id:80084,name:"Berachain bArtio",nativeCurrency:{decimals:18,name:"BERA Token",symbol:"BERA"},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:109269},ensRegistry:{address:"0xB0eef18971290b333450586D33dcA6cE122651D2",blockCreated:7736794},ensUniversalResolver:{address:"0x41692Ef1EA0C79E6b73077E4A67572D2BDbD7057",blockCreated:7736795}},ensTlds:[".bera"],rpcUrls:{default:{http:["https://bartio.rpc.berachain.com"]}},blockExplorers:{default:{name:"Berachain bArtio Beratrail",url:"https://bartio.beratrail.io"}},testnet:!0}),s_=wt({id:5115,name:"Citrea Testnet",nativeCurrency:{name:"cBTC",symbol:"cBTC",decimals:18},rpcUrls:{default:{http:["https://rpc.testnet.citrea.xyz"]}},blockExplorers:{default:{name:"Citrea Explorer",url:"https://explorer.testnet.citrea.xyz",apiUrl:"https://explorer.testnet.citrea.xyz/api"}},testnet:!0}),o_=wt({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://eth.merkle.io"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io",apiUrl:"https://api.etherscan.io/api"}},contracts:{ensRegistry:{address:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},ensUniversalResolver:{address:"0xce01f8eee7E479C928F8919abD53E553a36CeF67",blockCreated:19258213},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}}),a_=wt({id:10143,name:"Monad Testnet",nativeCurrency:{name:"Testnet MON Token",symbol:"MON",decimals:18},rpcUrls:{default:{http:["https://testnet-rpc.monad.xyz"]}},blockExplorers:{default:{name:"Monad Testnet explorer",url:"https://testnet.monadexplorer.com"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:251449}},testnet:!0}),c_=wt({id:11155111,name:"Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.drpc.org"]}},blockExplorers:{default:{name:"Etherscan",url:"https://sepolia.etherscan.io",apiUrl:"https://api-sepolia.etherscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:751532},ensRegistry:{address:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},ensUniversalResolver:{address:"0xc8Af999e38273D658BE1b921b88A9Ddf005769cC",blockCreated:5317080}},testnet:!0}),cs=1,u_=wt({...En,id:130,name:"Unichain",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.unichain.org/"]}},blockExplorers:{default:{name:"Uniscan",url:"https://uniscan.xyz",apiUrl:"https://api.uniscan.xyz/api"}},contracts:{...En.contracts,multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:0},disputeGameFactory:{[cs]:{address:"0x2F12d621a16e2d3285929C9996f478508951dFe4"}},portal:{[cs]:{address:"0x0bd48f6B86a26D3a217d0Fa6FfE2B491B956A7a2"}},l1StandardBridge:{[cs]:{address:"0x81014F44b0a345033bB2b3B21C7a1A308B35fEeA"}}},sourceId:cs}),f_={...c_,rpcUrls:{default:{http:["https://ethereum-sepolia-rpc.publicnode.com"]}}},Gl={id:998,name:"Hyperliquid EVM Testnet",nativeCurrency:{name:"Hyperliquid",symbol:"HYPE",decimals:18},blockExplorers:{default:{name:"Hyperliquid Explorer",url:"https://testnet.purrsec.com/"}},rpcUrls:{default:{http:["https://rpc.hyperliquid-testnet.xyz/evm"]}}},zl={id:999,name:"HyperEVM",nativeCurrency:{name:"Hyperliquid",symbol:"HYPE",decimals:18},blockExplorers:{default:{name:"Hyperliquid Explorer",url:"https://hyperscan.gas.zip/"}},rpcUrls:{default:{http:["https://rpc.hyperliquid.xyz/evm"]}}},ql={ethereum:o_,arbitrum:Z2,ethereum_sepolia:f_,arbitrum_sepolia:e_,ethereum_localnet:le.EthereumLocalnet,arbitrum_localnet:le.ArbitrumLocalnet,base_sepolia:r_,base:t_,bera_testnet:i_,citrea_testnet:s_,bera:n_,monad_testnet:a_,hyperliquid_testnet:Gl,hyperliquid:zl,unichain:u_},Vl=async(e,t)=>{var n,i,s,o;const r=ql[e];if(r)try{if(r.id===((n=t.chain)==null?void 0:n.id))return ie({message:"Already on the network",walletClient:t});await t.switchChain({id:r.id});const a=Io({account:t.account,chain:r,transport:nu(t.transport)});return ie({message:"Switched chain",walletClient:a})}catch(a){if(d_(a))if(a.code===4902)try{await t.addChain({chain:r});const c=Io({account:t.account,chain:r,transport:nu(t.transport)});return ie({message:"Added network",walletClient:c})}catch{return G("Failed to add network")}else if((s=(i=a.body)==null?void 0:i.method)!=null&&s.includes("wallet_switchEthereumChain")||(o=a.message)!=null&&o.includes("wallet_switchEthereumChain")){const c=Io({account:t.account,chain:r,transport:em()});return ie({message:"Added network",walletClient:c})}else return G("Failed to switch network");else return G("Failed to switch network")}else return G("Chain not supported")},d_=e=>typeof e=="object"&&e!=null&&("code"in e||"message"in e||"body"in e),l_=[{inputs:[{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"version",type:"string"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"InvalidShortString",type:"error"},{inputs:[],name:"NativeHTLC__DuplicateOrder",type:"error"},{inputs:[],name:"NativeHTLC__IncorrectFundsRecieved",type:"error"},{inputs:[],name:"NativeHTLC__IncorrectSecret",type:"error"},{inputs:[],name:"NativeHTLC__InsufficientBalance",type:"error"},{inputs:[],name:"NativeHTLC__InvalidRedeemerSignature",type:"error"},{inputs:[],name:"NativeHTLC__OrderFulfilled",type:"error"},{inputs:[],name:"NativeHTLC__OrderNotExpired",type:"error"},{inputs:[],name:"NativeHTLC__OrderNotInitiated",type:"error"},{inputs:[],name:"NativeHTLC__SameInitiatorAndRedeemer",type:"error"},{inputs:[],name:"NativeHTLC__ZeroAddressInitiator",type:"error"},{inputs:[],name:"NativeHTLC__ZeroAddressRedeemer",type:"error"},{inputs:[],name:"NativeHTLC__ZeroAmount",type:"error"},{inputs:[],name:"NativeHTLC__ZeroTimelock",type:"error"},{inputs:[{internalType:"string",name:"str",type:"string"}],name:"StringTooLong",type:"error"},{anonymous:!1,inputs:[],name:"EIP712DomainChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"secretHash",type:"bytes32"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"Initiated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"secretHash",type:"bytes32"},{indexed:!1,internalType:"bytes",name:"secret",type:"bytes"}],name:"Redeemed",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"}],name:"Refunded",type:"event"},{inputs:[],name:"eip712Domain",outputs:[{internalType:"bytes1",name:"fields",type:"bytes1"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"version",type:"string"},{internalType:"uint256",name:"chainId",type:"uint256"},{internalType:"address",name:"verifyingContract",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"uint256[]",name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address payable",name:"redeemer",type:"address"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"secretHash",type:"bytes32"}],name:"initiate",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address payable",name:"initiator",type:"address"},{internalType:"address payable",name:"redeemer",type:"address"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"secretHash",type:"bytes32"}],name:"initiateOnBehalf",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"instantRefund",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"}],name:"instantRefundDigest",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"",type:"bytes32"}],name:"orders",outputs:[{internalType:"bool",name:"isFulfilled",type:"bool"},{internalType:"address payable",name:"initiator",type:"address"},{internalType:"address payable",name:"redeemer",type:"address"},{internalType:"uint256",name:"initiatedAt",type:"uint256"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"},{internalType:"bytes",name:"secret",type:"bytes"}],name:"redeem",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"}],name:"refund",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"token",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"}];class Wl{constructor(t,r,n){this.url=new q.Url("/relayer",t),this.auth=n,this.wallet=r}get htlcActorAddress(){if(!this.wallet.account)throw new Error("No account found");return this.wallet.account.address}async initiate(t){if(!this.wallet.account)return q.Err("No account found");if(this.wallet.account.address.toLowerCase()!==t.source_swap.initiator.toLowerCase())return q.Err("Account address and order initiator mismatch");if(!le.isEVM(t.source_swap.chain))return q.Err("Source chain is not an EVM chain");const r=await Vl(t.source_swap.chain,this.wallet);if(r.error)return q.Err(r.error);if(this.wallet=r.val.walletClient,!this.wallet.account)return q.Err("No account found");const{create_order:n,source_swap:i}=t;if(!i.amount||!i.redeemer||!n.timelock||!n.secret_hash)return q.Err("Invalid order");const s=q.with0x(n.secret_hash),o=BigInt(n.timelock),a=q.with0x(i.redeemer),c=BigInt(i.amount),f=await this.getTokenAddress(t.source_swap.asset);return f.ok?le.isEvmNativeToken(t.source_swap.chain,f.val)?this._initiateOnNativeHTLC(s,o,c,a,t.source_swap.asset):this._initiateOnErc20HTLC(s,o,c,a,t.source_swap.asset,f.val,n.create_id):q.Err(f.error)}async getTokenAddress(t){try{const n=await So({address:q.with0x(t),abi:sf,client:this.wallet}).read.token();return q.Ok(n)}catch(r){return q.Err("Failed to get token address",String(r))}}async _initiateOnNativeHTLC(t,r,n,i,s){if(!this.wallet.account)return q.Err("No account found");try{const a=await So({address:q.with0x(s),abi:l_,client:this.wallet}).write.initiate([i,r,n,t],{account:this.wallet.account,chain:this.wallet.chain,value:n});return q.Ok(a)}catch(o){return q.Err("Failed to initiate on native HTLC",String(o))}}async _initiateOnErc20HTLC(t,r,n,i,s,o,a){if(!this.wallet.account)return q.Err("No account found");try{const c=await this.auth.getAuthHeaders();if(c.error)return q.Err(c.error);const f=So({address:q.with0x(s),abi:sf,client:this.wallet}),l=await q.checkAllowanceAndApprove(Number(n),o,s,this.wallet);if(l.error)return q.Err(l.error);const h=await f.read.eip712Domain(),y=await this.wallet.signTypedData({account:this.wallet.account,domain:{name:h[1],version:h[2],chainId:Number(h[3]),verifyingContract:h[4]},types:{Initiate:[{name:"redeemer",type:"address"},{name:"timelock",type:"uint256"},{name:"amount",type:"uint256"},{name:"secretHash",type:"bytes32"}]},primaryType:"Initiate",message:{redeemer:i,timelock:r,amount:n,secretHash:t}}),p={...c.val,"Content-Type":"application/json"},g=await Dt.post(this.url.endpoint("initiate"),{body:JSON.stringify({order_id:a,signature:y,perform_on:"Source"}),headers:p});return g.error?q.Err(g.error):g.result?q.Ok(g.result):q.Err("Init: No result found")}catch(c){return console.log("init error :",c),q.Err(String(c))}}async redeem(t,r){try{const n=await this.auth.getAuthHeaders();if(n.error)return q.Err(n.error);const i=await Dt.post(this.url.endpoint("redeem"),{body:JSON.stringify({order_id:t.create_order.create_id,secret:kr(r),perform_on:"Destination"}),headers:{...n.val,"Content-Type":"application/json"}});return i.error?q.Err(i.error):i.result?q.Ok(i.result):q.Err("Redeem: No result found")}catch(n){return q.Err(String(n))}}async refund(){return q.Err("Refund not supported")}}const Kl=[{name:"LockingContract",type:"impl",interface_name:"src::mintable_lock_interface::ILockingContract"},{name:"src::mintable_lock_interface::ILockingContract",type:"interface",items:[{name:"set_locking_contract",type:"function",inputs:[{name:"locking_contract",type:"core::starknet::contract_address::ContractAddress"}],outputs:[],state_mutability:"external"},{name:"get_locking_contract",type:"function",inputs:[],outputs:[{type:"core::starknet::contract_address::ContractAddress"}],state_mutability:"view"}]},{name:"LockAndDelegate",type:"impl",interface_name:"src::mintable_lock_interface::ILockAndDelegate"},{name:"core::integer::u256",type:"struct",members:[{name:"low",type:"core::integer::u128"},{name:"high",type:"core::integer::u128"}]},{name:"src::mintable_lock_interface::ILockAndDelegate",type:"interface",items:[{name:"lock_and_delegate",type:"function",inputs:[{name:"delegatee",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[],state_mutability:"external"},{name:"lock_and_delegate_by_sig",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"},{name:"delegatee",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"},{name:"nonce",type:"core::felt252"},{name:"expiry",type:"core::integer::u64"},{name:"signature",type:"core::array::Array::<core::felt252>"}],outputs:[],state_mutability:"external"}]},{name:"MintableToken",type:"impl",interface_name:"src::mintable_token_interface::IMintableToken"},{name:"src::mintable_token_interface::IMintableToken",type:"interface",items:[{name:"permissioned_mint",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[],state_mutability:"external"},{name:"permissioned_burn",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[],state_mutability:"external"}]},{name:"MintableTokenCamelImpl",type:"impl",interface_name:"src::mintable_token_interface::IMintableTokenCamel"},{name:"src::mintable_token_interface::IMintableTokenCamel",type:"interface",items:[{name:"permissionedMint",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[],state_mutability:"external"},{name:"permissionedBurn",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[],state_mutability:"external"}]},{name:"Replaceable",type:"impl",interface_name:"src::replaceability_interface::IReplaceable"},{name:"core::array::Span::<core::felt252>",type:"struct",members:[{name:"snapshot",type:"@core::array::Array::<core::felt252>"}]},{name:"src::replaceability_interface::EICData",type:"struct",members:[{name:"eic_hash",type:"core::starknet::class_hash::ClassHash"},{name:"eic_init_data",type:"core::array::Span::<core::felt252>"}]},{name:"core::option::Option::<src::replaceability_interface::EICData>",type:"enum",variants:[{name:"Some",type:"src::replaceability_interface::EICData"},{name:"None",type:"()"}]},{name:"core::bool",type:"enum",variants:[{name:"False",type:"()"},{name:"True",type:"()"}]},{name:"src::replaceability_interface::ImplementationData",type:"struct",members:[{name:"impl_hash",type:"core::starknet::class_hash::ClassHash"},{name:"eic_data",type:"core::option::Option::<src::replaceability_interface::EICData>"},{name:"final",type:"core::bool"}]},{name:"src::replaceability_interface::IReplaceable",type:"interface",items:[{name:"get_upgrade_delay",type:"function",inputs:[],outputs:[{type:"core::integer::u64"}],state_mutability:"view"},{name:"get_impl_activation_time",type:"function",inputs:[{name:"implementation_data",type:"src::replaceability_interface::ImplementationData"}],outputs:[{type:"core::integer::u64"}],state_mutability:"view"},{name:"add_new_implementation",type:"function",inputs:[{name:"implementation_data",type:"src::replaceability_interface::ImplementationData"}],outputs:[],state_mutability:"external"},{name:"remove_implementation",type:"function",inputs:[{name:"implementation_data",type:"src::replaceability_interface::ImplementationData"}],outputs:[],state_mutability:"external"},{name:"replace_to",type:"function",inputs:[{name:"implementation_data",type:"src::replaceability_interface::ImplementationData"}],outputs:[],state_mutability:"external"}]},{name:"AccessControlImplExternal",type:"impl",interface_name:"src::access_control_interface::IAccessControl"},{name:"src::access_control_interface::IAccessControl",type:"interface",items:[{name:"has_role",type:"function",inputs:[{name:"role",type:"core::felt252"},{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[{type:"core::bool"}],state_mutability:"view"},{name:"get_role_admin",type:"function",inputs:[{name:"role",type:"core::felt252"}],outputs:[{type:"core::felt252"}],state_mutability:"view"}]},{name:"RolesImpl",type:"impl",interface_name:"src::roles_interface::IMinimalRoles"},{name:"src::roles_interface::IMinimalRoles",type:"interface",items:[{name:"is_governance_admin",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[{type:"core::bool"}],state_mutability:"view"},{name:"is_upgrade_governor",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[{type:"core::bool"}],state_mutability:"view"},{name:"register_governance_admin",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[],state_mutability:"external"},{name:"remove_governance_admin",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[],state_mutability:"external"},{name:"register_upgrade_governor",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[],state_mutability:"external"},{name:"remove_upgrade_governor",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[],state_mutability:"external"},{name:"renounce",type:"function",inputs:[{name:"role",type:"core::felt252"}],outputs:[],state_mutability:"external"}]},{name:"ERC20Impl",type:"impl",interface_name:"openzeppelin::token::erc20::interface::IERC20"},{name:"openzeppelin::token::erc20::interface::IERC20",type:"interface",items:[{name:"name",type:"function",inputs:[],outputs:[{type:"core::felt252"}],state_mutability:"view"},{name:"symbol",type:"function",inputs:[],outputs:[{type:"core::felt252"}],state_mutability:"view"},{name:"decimals",type:"function",inputs:[],outputs:[{type:"core::integer::u8"}],state_mutability:"view"},{name:"total_supply",type:"function",inputs:[],outputs:[{type:"core::integer::u256"}],state_mutability:"view"},{name:"balance_of",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[{type:"core::integer::u256"}],state_mutability:"view"},{name:"allowance",type:"function",inputs:[{name:"owner",type:"core::starknet::contract_address::ContractAddress"},{name:"spender",type:"core::starknet::contract_address::ContractAddress"}],outputs:[{type:"core::integer::u256"}],state_mutability:"view"},{name:"transfer",type:"function",inputs:[{name:"recipient",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"},{name:"transfer_from",type:"function",inputs:[{name:"sender",type:"core::starknet::contract_address::ContractAddress"},{name:"recipient",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"},{name:"approve",type:"function",inputs:[{name:"spender",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"}]},{name:"ERC20CamelOnlyImpl",type:"impl",interface_name:"openzeppelin::token::erc20::interface::IERC20CamelOnly"},{name:"openzeppelin::token::erc20::interface::IERC20CamelOnly",type:"interface",items:[{name:"totalSupply",type:"function",inputs:[],outputs:[{type:"core::integer::u256"}],state_mutability:"view"},{name:"balanceOf",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[{type:"core::integer::u256"}],state_mutability:"view"},{name:"transferFrom",type:"function",inputs:[{name:"sender",type:"core::starknet::contract_address::ContractAddress"},{name:"recipient",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"}]},{name:"constructor",type:"constructor",inputs:[{name:"name",type:"core::felt252"},{name:"symbol",type:"core::felt252"},{name:"decimals",type:"core::integer::u8"},{name:"initial_supply",type:"core::integer::u256"},{name:"recipient",type:"core::starknet::contract_address::ContractAddress"},{name:"permitted_minter",type:"core::starknet::contract_address::ContractAddress"},{name:"provisional_governance_admin",type:"core::starknet::contract_address::ContractAddress"},{name:"upgrade_delay",type:"core::integer::u64"}]},{name:"increase_allowance",type:"function",inputs:[{name:"spender",type:"core::starknet::contract_address::ContractAddress"},{name:"added_value",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"},{name:"decrease_allowance",type:"function",inputs:[{name:"spender",type:"core::starknet::contract_address::ContractAddress"},{name:"subtracted_value",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"},{name:"increaseAllowance",type:"function",inputs:[{name:"spender",type:"core::starknet::contract_address::ContractAddress"},{name:"addedValue",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"},{name:"decreaseAllowance",type:"function",inputs:[{name:"spender",type:"core::starknet::contract_address::ContractAddress"},{name:"subtractedValue",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"},{kind:"struct",name:"src::strk::erc20_lockable::ERC20Lockable::Transfer",type:"event",members:[{kind:"data",name:"from",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"to",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"value",type:"core::integer::u256"}]},{kind:"struct",name:"src::strk::erc20_lockable::ERC20Lockable::Approval",type:"event",members:[{kind:"data",name:"owner",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"spender",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"value",type:"core::integer::u256"}]},{kind:"struct",name:"src::replaceability_interface::ImplementationAdded",type:"event",members:[{kind:"data",name:"implementation_data",type:"src::replaceability_interface::ImplementationData"}]},{kind:"struct",name:"src::replaceability_interface::ImplementationRemoved",type:"event",members:[{kind:"data",name:"implementation_data",type:"src::replaceability_interface::ImplementationData"}]},{kind:"struct",name:"src::replaceability_interface::ImplementationReplaced",type:"event",members:[{kind:"data",name:"implementation_data",type:"src::replaceability_interface::ImplementationData"}]},{kind:"struct",name:"src::replaceability_interface::ImplementationFinalized",type:"event",members:[{kind:"data",name:"impl_hash",type:"core::starknet::class_hash::ClassHash"}]},{kind:"struct",name:"src::access_control_interface::RoleGranted",type:"event",members:[{kind:"data",name:"role",type:"core::felt252"},{kind:"data",name:"account",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"sender",type:"core::starknet::contract_address::ContractAddress"}]},{kind:"struct",name:"src::access_control_interface::RoleRevoked",type:"event",members:[{kind:"data",name:"role",type:"core::felt252"},{kind:"data",name:"account",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"sender",type:"core::starknet::contract_address::ContractAddress"}]},{kind:"struct",name:"src::access_control_interface::RoleAdminChanged",type:"event",members:[{kind:"data",name:"role",type:"core::felt252"},{kind:"data",name:"previous_admin_role",type:"core::felt252"},{kind:"data",name:"new_admin_role",type:"core::felt252"}]},{kind:"struct",name:"src::roles_interface::GovernanceAdminAdded",type:"event",members:[{kind:"data",name:"added_account",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"added_by",type:"core::starknet::contract_address::ContractAddress"}]},{kind:"struct",name:"src::roles_interface::GovernanceAdminRemoved",type:"event",members:[{kind:"data",name:"removed_account",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"removed_by",type:"core::starknet::contract_address::ContractAddress"}]},{kind:"struct",name:"src::roles_interface::UpgradeGovernorAdded",type:"event",members:[{kind:"data",name:"added_account",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"added_by",type:"core::starknet::contract_address::ContractAddress"}]},{kind:"struct",name:"src::roles_interface::UpgradeGovernorRemoved",type:"event",members:[{kind:"data",name:"removed_account",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"removed_by",type:"core::starknet::contract_address::ContractAddress"}]},{kind:"enum",name:"src::strk::erc20_lockable::ERC20Lockable::Event",type:"event",variants:[{kind:"nested",name:"Transfer",type:"src::strk::erc20_lockable::ERC20Lockable::Transfer"},{kind:"nested",name:"Approval",type:"src::strk::erc20_lockable::ERC20Lockable::Approval"},{kind:"nested",name:"ImplementationAdded",type:"src::replaceability_interface::ImplementationAdded"},{kind:"nested",name:"ImplementationRemoved",type:"src::replaceability_interface::ImplementationRemoved"},{kind:"nested",name:"ImplementationReplaced",type:"src::replaceability_interface::ImplementationReplaced"},{kind:"nested",name:"ImplementationFinalized",type:"src::replaceability_interface::ImplementationFinalized"},{kind:"nested",name:"RoleGranted",type:"src::access_control_interface::RoleGranted"},{kind:"nested",name:"RoleRevoked",type:"src::access_control_interface::RoleRevoked"},{kind:"nested",name:"RoleAdminChanged",type:"src::access_control_interface::RoleAdminChanged"},{kind:"nested",name:"GovernanceAdminAdded",type:"src::roles_interface::GovernanceAdminAdded"},{kind:"nested",name:"GovernanceAdminRemoved",type:"src::roles_interface::GovernanceAdminRemoved"},{kind:"nested",name:"UpgradeGovernorAdded",type:"src::roles_interface::UpgradeGovernorAdded"},{kind:"nested",name:"UpgradeGovernorRemoved",type:"src::roles_interface::UpgradeGovernorRemoved"}]}],h_=async(e,t,r,n,i)=>{try{const s=await Fa(e.address,t,r,i);if(s.error)return G(s.error);const o=Oe.cairo.uint256(BigInt(Oe.uint256.UINT_256_MAX));if(s.val<n){const a=await e.execute([{contractAddress:nn(t),entrypoint:"approve",calldata:[r,o.low,o.high]}]);await i.waitForTransaction(a.transaction_hash,{retryInterval:3e3,successStates:[Oe.TransactionExecutionStatus.SUCCEEDED]}),await q.sleep(2e3);let c=0n;for(let f=0;f<20;f++){const l=await Fa(e.address,t,r,i);if(l.error)return G(l.error);if(c=l.val,c>=n)break;await q.sleep(2e3)}return c<n?G("Allowance not approved"):ie(a.transaction_hash)}return ie("Allowance already approved")}catch(s){return G(`Failed to check or approve allowance: ${s instanceof Error?s.message:String(s)}`)}},Fa=async(e,t,r,n)=>{try{const s=await new Oe.Contract(Kl,nn(t),n).call("allowance",[nn(e),nn(r)]);return ie(BigInt((s==null?void 0:s.toString())||"0"))}catch(i){return G(`Failed to check allowance: ${i instanceof Error?i.message:String(i)}`)}},p_=async(e,t,r,n,i)=>{const s=await Fa(e,t,r,n);return s.error?G(s.error):ie(s.val>=i)},Yl=[{name:"HTLC",type:"impl",interface_name:"starknet_htlc::interface::IHTLC"},{name:"core::integer::u256",type:"struct",members:[{name:"low",type:"core::integer::u128"},{name:"high",type:"core::integer::u128"}]},{name:"starknet_htlc::interface::IHTLC",type:"interface",items:[{name:"token",type:"function",inputs:[],outputs:[{type:"core::starknet::contract_address::ContractAddress"}],state_mutability:"view"},{name:"initiate",type:"function",inputs:[{name:"redeemer",type:"core::starknet::contract_address::ContractAddress"},{name:"timelock",type:"core::integer::u128"},{name:"amount",type:"core::integer::u256"},{name:"secret_hash",type:"[core::integer::u32; 8]"}],outputs:[],state_mutability:"external"},{name:"initiate_on_behalf",type:"function",inputs:[{name:"initiator",type:"core::starknet::contract_address::ContractAddress"},{name:"redeemer",type:"core::starknet::contract_address::ContractAddress"},{name:"timelock",type:"core::integer::u128"},{name:"amount",type:"core::integer::u256"},{name:"secret_hash",type:"[core::integer::u32; 8]"}],outputs:[],state_mutability:"external"},{name:"initiate_with_signature",type:"function",inputs:[{name:"initiator",type:"core::starknet::contract_address::ContractAddress"},{name:"redeemer",type:"core::starknet::contract_address::ContractAddress"},{name:"timelock",type:"core::integer::u128"},{name:"amount",type:"core::integer::u256"},{name:"secret_hash",type:"[core::integer::u32; 8]"},{name:"signature",type:"core::array::Array::<core::felt252>"}],outputs:[],state_mutability:"external"},{name:"redeem",type:"function",inputs:[{name:"order_id",type:"core::felt252"},{name:"secret",type:"core::array::Array::<core::integer::u32>"}],outputs:[],state_mutability:"external"},{name:"refund",type:"function",inputs:[{name:"order_id",type:"core::felt252"}],outputs:[],state_mutability:"external"},{name:"instant_refund",type:"function",inputs:[{name:"order_id",type:"core::felt252"},{name:"signature",type:"core::array::Array::<core::felt252>"}],outputs:[],state_mutability:"external"}]},{name:"constructor",type:"constructor",inputs:[{name:"token",type:"core::starknet::contract_address::ContractAddress"}]},{kind:"struct",name:"starknet_htlc::interface::events::Initiated",type:"event",members:[{kind:"key",name:"order_id",type:"core::felt252"},{kind:"data",name:"secret_hash",type:"[core::integer::u32; 8]"},{kind:"data",name:"amount",type:"core::integer::u256"}]},{kind:"struct",name:"starknet_htlc::interface::events::Redeemed",type:"event",members:[{kind:"key",name:"order_id",type:"core::felt252"},{kind:"data",name:"secret_hash",type:"[core::integer::u32; 8]"},{kind:"data",name:"secret",type:"core::array::Array::<core::integer::u32>"}]},{kind:"struct",name:"starknet_htlc::interface::events::Refunded",type:"event",members:[{kind:"key",name:"order_id",type:"core::felt252"}]},{kind:"enum",name:"starknet_htlc::htlc::HTLC::Event",type:"event",variants:[{kind:"nested",name:"Initiated",type:"starknet_htlc::interface::events::Initiated"},{kind:"nested",name:"Redeemed",type:"starknet_htlc::interface::events::Redeemed"},{kind:"nested",name:"Refunded",type:"starknet_htlc::interface::events::Refunded"}]}],y_={StarknetDomain:[{name:"name",type:"shortstring"},{name:"version",type:"shortstring"},{name:"chainId",type:"shortstring"},{name:"revision",type:"shortstring"}],Initiate:[{name:"redeemer",type:"ContractAddress"},{name:"amount",type:"u256"},{name:"timelock",type:"u128"},{name:"secretHash",type:"u128*"}]};class Xl{constructor(t,r,n,i){this.url=t instanceof q.Url?t:new q.Url(t),this.account=r,this.starknetProvider=new Oe.RpcProvider({nodeUrl:i||Si[n].nodeUrl}),this.chainId=Si[n].chainId}get htlcActorAddress(){if(!this.account.address)throw new Error("No account found");return this.account.address}async initiate(t){if(!this.account.address)return G("No account address");const{create_order:r,source_swap:n}=t,{redeemer:i,amount:s}=n;if(!s||!i||!r.secret_hash||!r.timelock)return G("Invalid order");try{const o=new Oe.Contract(Yl,t.source_swap.asset,this.account),a=await(o==null?void 0:o.token()),c=Oe.num.toHex(a),f=await p_(this.account.address,c,n.asset,this.starknetProvider,BigInt(s));return f.error?G(f.error):f.val?this.initiateRelay(t):this.approveAndInitiate(c,t)}catch(o){return G(String(o))}}async approveAndInitiate(t,r){const{create_order:n,source_swap:i}=r,{redeemer:s,amount:o}=i,{secret_hash:a,timelock:c}=n,f=i.asset;try{const l=Oe.cairo.uint256(BigInt(Oe.uint256.UINT_256_MAX)),h={contractAddress:nn(t),entrypoint:"approve",calldata:[f,l.low,l.high]},y=Oe.cairo.uint256(o),p={contractAddress:nn(f),entrypoint:"initiate",calldata:[s,c.toString(),y.low.toString(),y.high.toString(),...q.hexToU32Array(a)]},g=await this.account.execute([h,p]);return await this.starknetProvider.waitForTransaction(g.transaction_hash,{retryInterval:2e3,successStates:[Oe.TransactionExecutionStatus.SUCCEEDED]}),ie(g.transaction_hash)}catch(l){return G(`Failed to approve and initiate: ${String(l)}`)}}async initiateRelay(t){const{create_order:r,source_swap:n}=t,{redeemer:i,amount:s}=n,a={domain:{name:"HTLC",version:Oe.shortString.encodeShortString("1"),chainId:this.chainId,revision:Oe.TypedDataRevision.ACTIVE},primaryType:"Initiate",types:y_,message:{redeemer:i,amount:Oe.cairo.uint256(s),timelock:r.timelock,secretHash:q.hexToU32Array(r.secret_hash)}};try{const c=await this.account.signMessage(a),f=ob(c);if(f.error)return G(f.error);const l=await Dt.post(this.url.endpoint("initiate"),{body:JSON.stringify({order_id:r.create_id,signature:f.val,perform_on:"Source"}),headers:{"Content-Type":"application/json"},retryCount:10,retryDelay:2e3});return l.error?G(l.error):l.result?ie(l.result):G("Init: No result found")}catch(c){return G(`Failed to initiate relayer: ${String(c)}`)}}async redeem(t,r){try{const n=await Dt.post(this.url.endpoint("redeem"),{body:JSON.stringify({order_id:t.create_order.create_id,secret:r,perform_on:"Destination"}),headers:{"Content-Type":"application/json"},retryCount:10,retryDelay:2e3});return n.error?G(n.error):n.result?ie(n.result):G("Redeem: No result found")}catch(n){return G(String(n))}}async refund(){return G("Refund is taken care of by the relayer")}}class kc extends q.EventBroker{constructor(t){super(),this.environment=q.Environment.TESTNET,this.getOrderThreshold=20,this.refundSacpCache=new Map,this.bitcoinRedeemCache=new n1;const{api:r,environment:n}=au(t.environment);if(this.environment=n,this._api=r,typeof t.digestKey=="string"){const s=q.DigestKey.from(t.digestKey);if(!s.ok)throw new Error(s.error);this._digestKey=s.val}else this._digestKey=t.digestKey;this._quote=t.quote??new sl(this._api.quote),this._auth=t.auth??q.Siwe.fromDigestKey(new q.Url(this._api.auth),this._digestKey),this._orderbook=t.orderbook??new le.Orderbook(new q.Url(this._api.orderbook)),this._evmHTLC=t.htlc.evm,this._starknetHTLC=t.htlc.starknet,this._secretManager=t.secretManager??Bi.fromDigestKey(this._digestKey.digestKey),this.orderExecutorCache=new r1,this._blockNumberFetcher=t.blockNumberFetcher??new il(this._api.info,this.environment);const i=new ln.BitcoinProvider(ib(this.environment));this._btcWallet=ln.BitcoinWallet.fromPrivateKey(this._digestKey.digestKey,i)}static fromWallets(t){let r;if(typeof t.digestKey=="string"){const s=q.DigestKey.from(t.digestKey);if(!s.ok)throw new Error(s.error);r=s.val}else r=t.digestKey;const{api:n}=au(t.environment);if(!n)throw new Error("API not found, invalid environment "+t.environment);const i={evm:t.wallets.evm?new Wl(n.evmRelay,t.wallets.evm,q.Siwe.fromDigestKey(new q.Url(n.auth),r)):void 0,starknet:t.wallets.starknet?new Xl(n.starknetRelay,t.wallets.starknet,t.environment===q.Environment.MAINNET?q.Network.MAINNET:q.Network.TESTNET):void 0};return new kc({htlc:i,...t})}get evmHTLC(){return this._evmHTLC}get starknetHTLC(){return this._starknetHTLC}get quote(){return this._quote}get btcWallet(){return this._btcWallet}get orderbook(){return this._orderbook}get blockNumberFetcher(){return this._blockNumberFetcher}get secretManager(){return this._secretManager}get auth(){return this._auth}get digestKey(){return this._digestKey}async swap(t){const r=await this.validateAndFillParams(t);if(r.error)return G(r.error);const{sendAddress:n,receiveAddress:i,timelock:s}=r.val,o=Date.now().toString(),a=await this._secretManager.generateSecret(o);if(a.error)return G(a.error);const{strategyId:c,btcAddress:f}=t.additionalData,l={strategy_id:c,...f&&{bitcoin_optional_recipient:f}},h={source_chain:t.fromAsset.chain,destination_chain:t.toAsset.chain,source_asset:t.fromAsset.atomicSwapAddress,destination_asset:t.toAsset.atomicSwapAddress,initiator_source_address:n,initiator_destination_address:i,source_amount:t.sendAmount,destination_amount:t.receiveAmount,fee:"1",nonce:o,timelock:s,secret_hash:kr(a.val.secretHash),min_destination_confirmations:t.minDestinationConfirmations??0,additional_data:l,affiliate_fees:this.withDefaultAffiliateFees(t.affiliateFee)},y=await this._quote.getAttestedQuote(h);if(y.error)return G(y.error);const p=await this._orderbook.createOrder(y.val,this.auth);if(p.error)return G(p.error);const g=await this.pollOrder(p.val);return g.error?G(g.error):ie(g.val)}withDefaultAffiliateFees(t){return(t??[]).map(r=>({fee:r.fee,address:r.address,chain:r.chain??ou.chain,asset:r.asset??ou.asset}))}async validateAndFillParams(t){if(!t.additionalData.strategyId)return G("StrategyId is required");if(!t.fromAsset||!t.toAsset)return G("Source and destination assets are required for swap");if(t.fromAsset.chain===t.toAsset.chain&&t.fromAsset.atomicSwapAddress===t.toAsset.atomicSwapAddress)return G("Source and destination assets cannot be the same");if(le.isMainnet(t.fromAsset.chain)&&!le.isMainnet(t.toAsset.chain)||!le.isMainnet(t.fromAsset.chain)&&le.isMainnet(t.toAsset.chain))return G("Both assets should be on the same network (either mainnet or testnet)");const r=this.validateAmount(t.sendAmount);if(r.error)return G(r.error);const n=this.validateAmount(t.receiveAmount);if(n.error)return G(n.error);if(r<n)return G("Send amount should be greater than receive amount");const i=le.getTimeLock(t.fromAsset.chain);if(!i)return G("Unsupported chain for timelock");if((le.isBitcoin(t.fromAsset.chain)||le.isBitcoin(t.toAsset.chain))&&!t.additionalData.btcAddress)return G("btcAddress in additionalData is required if source or destination chain is bitcoin, it is used as refund or redeem address.");const s=await this.getAddresses(t.fromAsset.chain);if(s.error)return G(s.error);const o=await this.getAddresses(t.toAsset.chain);return o.error?G(o.error):ie({sendAddress:s.val,receiveAddress:o.val,timelock:t.timelock??i})}async getAddresses(t){var n;switch(le.getBlockchainType(t)){case le.BlockchainType.EVM:return this._evmHTLC?ie(this._evmHTLC.htlcActorAddress):G("Please provide evmHTLC when initializing garden");case le.BlockchainType.Bitcoin:{const i=await((n=this._btcWallet)==null?void 0:n.getPublicKey());return!i||!rb(i)?G("Invalid btc public key"):ie(fr(i))}case le.BlockchainType.Starknet:return this._starknetHTLC?ie(this._starknetHTLC.htlcActorAddress):G("Please provide starknetHTLC when initializing garden");default:return G("Unsupported chain")}}validateAmount(t){if(t==null||t.includes("."))return G("Invalid amount ",t);const r=new eh(t);return!r.isInteger()||r.isNaN()||r.lt(0)||r.isLessThanOrEqualTo(0)?G("Invalid amount ",t):ie(r)}async pollOrder(t){let r=await this._orderbook.getOrder(t,!0),n=0;for(;n<this.getOrderThreshold;){if(await q.sleep(1e3),n++,r.error){if(!r.error.includes("result is undefined"))return G(r.error)}else if(r.val&&r.val.create_order.create_id.toLowerCase()===t.toLowerCase())return ie(r.val);r=await this._orderbook.getOrder(t,!0)}return G(`Order not found, createOrder id: ${t}`)}async execute(t=5e3){return await this._orderbook.subscribeOrders(this._digestKey.userId,!0,t,async r=>{const n=await this.filterExpiredAndAssignStatus(r.data);if(!n.error&&(this.emit("onPendingOrdersChanged",n.val),r.data.length!==0))for(let i=0;i<n.val.length;i++){const s=n.val[i],o=lc(s.status);if(le.isBitcoin(s.source_swap.chain)&&s.status===we.InitiateDetected){const a=this.btcWallet;if(!a){this.emit("error",s,"BTC wallet not found");continue}await this.postRefundSACP(s,a)}switch(o){case Ce.Redeem:{const a=await this._secretManager.generateSecret(s.create_order.nonce);if(a.error){this.emit("error",s,a.error);return}switch(le.getBlockchainType(s.destination_swap.chain)){case le.BlockchainType.EVM:{await this.evmRedeem(s,a.val.secret);break}case le.BlockchainType.Bitcoin:{const c=this.btcWallet;if(!c){this.emit("error",s,"BTC wallet not found");return}await this.btcRedeem(c,s,a.val.secret);break}case le.BlockchainType.Starknet:{await this.starknetRedeem(s,a.val.secret);break}default:this.emit("error",s,"Unsupported chain: "+s.destination_swap.chain)}break}case Ce.Refund:{switch(le.getBlockchainType(s.source_swap.chain)){case le.BlockchainType.EVM:{this.emit("error",s,"EVM refund is automatically done by relay service");break}case le.BlockchainType.Bitcoin:{const a=this.btcWallet;if(!a){this.emit("error",s,"BTC wallet not found");return}await this.btcRefund(a,s);break}case le.BlockchainType.Starknet:{this.emit("error",s,"Starknet refund is automatically done by relay service");break}default:this.emit("error",s,"Unsupported chain: "+s.source_swap.chain)}break}}}},"pending",{per_page:500})}async evmRedeem(t,r){if(this.emit("log",t.create_order.create_id,"executing evm redeem"),this.orderExecutorCache.get(t,Ce.Redeem)){this.emit("log",t.create_order.create_id,"already redeemed");return}if(!this._evmHTLC){this.emit("error",t,"EVMHTLC is required");return}const i=await this._evmHTLC.redeem(t,r);if(!i.ok){this.emit("error",t,i.error),i.error.includes("Order already redeemed")&&this.orderExecutorCache.set(t,Ce.Redeem,t.destination_swap.redeem_tx_hash);return}this.orderExecutorCache.set(t,Ce.Redeem,i.val),this.emit("success",t,Ce.Redeem,i.val)}async starknetRedeem(t,r){if(this.emit("log",t.create_order.create_id,"executing starknet redeem"),this.orderExecutorCache.get(t,Ce.Redeem)){this.emit("log",t.create_order.create_id,"already redeemed");return}if(!this._starknetHTLC){this.emit("error",t,"StarknetHTLC is required");return}const i=await this._starknetHTLC.redeem(t,r);if(i.error){this.emit("error",t,i.error),i.error.includes("Order already redeemed")&&this.orderExecutorCache.set(t,Ce.Redeem,t.destination_swap.redeem_tx_hash);return}i.val&&(this.orderExecutorCache.set(t,Ce.Redeem,i.val),this.emit("success",t,Ce.Redeem,i.val))}async btcRedeem(t,r,n){var a,c;const i=this.bitcoinRedeemCache.get(r.create_order.create_id),s=(a=r.destination_swap.initiate_tx_hash.split(",").at(-1))==null?void 0:a.split(":").at(0);if(!s){this.emit("error",r,"Failed to get initiate_tx_hash");return}let o=!1;if(i)if(i.redeemedFromUTXO&&i.redeemedFromUTXO!==s)o=!0,this.emit("log",r.create_order.create_id,"rbf btc redeem");else if(i.redeemedAt&&Date.now()-i.redeemedAt>1e3*60*15)this.emit("log",r.create_order.create_id,"redeem not confirmed in last 15 minutes"),o=!0;else{this.emit("log",r.create_order.create_id,"btcRedeem: already redeemed");return}else if(r.destination_swap.redeem_tx_hash&&!Number(r.destination_swap.redeem_block_number))try{const f=await(await t.getProvider()).getTransaction(r.destination_swap.redeem_tx_hash);let l=!1;for(const h of f.vin)if(h.txid===s){l=!0;break}if(l){this.emit("log",r.create_order.create_id,"already a valid redeem");let h=0;try{const[y]=await(await t.getProvider()).getTransactionTimes([r.destination_swap.redeem_tx_hash]);y!==0&&(h=y)}catch{h=Date.now()}this.bitcoinRedeemCache.set(r.create_order.create_id,{redeemedFromUTXO:s,redeemedAt:h,redeemTxHash:r.destination_swap.redeem_tx_hash});return}o=!0}catch(f){if(f.message.includes("Transaction not found"))o=!0;else{this.emit("error",r,"Failed to get redeem tx: "+f);return}}this.emit("log",r.create_order.create_id,"executing btc redeem");try{const l=await(await Zn.from(t,Number(r.destination_swap.amount),r.create_order.secret_hash,fr(r.destination_swap.initiator),fr(r.destination_swap.redeemer),r.destination_swap.timelock,o?[s]:[])).getRedeemHex(kr(n),(c=r.create_order.additional_data)==null?void 0:c.bitcoin_optional_recipient),h=await this.broadcastRedeemTx(l,r.create_order.create_id);if(h.error||!h.val){this.emit("error",r,h.error||"Failed to broadcast redeem tx");return}o?(this.emit("log",r.create_order.create_id,"rbf: btc redeem success"),this.emit("rbf",r,h.val)):this.emit("success",r,Ce.Redeem,h.val),this.bitcoinRedeemCache.set(r.create_order.create_id,{redeemedFromUTXO:s,redeemedAt:Date.now(),redeemTxHash:h.val})}catch(f){console.log("error",f),this.emit("error",r,"Failed btc redeem: "+f)}}async btcRefund(t,r){var n;if(!this.orderExecutorCache.get(r,Ce.Refund)){this.emit("log",r.create_order.create_id,"executing btc refund");try{const s=await(await Zn.from(t,Number(r.source_swap.amount),r.create_order.secret_hash,fr(r.source_swap.initiator),fr(r.source_swap.redeemer),r.source_swap.timelock)).refund((n=r.create_order.additional_data)==null?void 0:n.bitcoin_optional_recipient);this.orderExecutorCache.set(r,Ce.Refund,s),this.emit("success",r,Ce.Refund,s)}catch(i){this.emit("error",r,"Failed btc refund: "+i)}}}async postRefundSACP(t,r){const n=this.refundSacpCache.get(t.create_order.create_id);if((n==null?void 0:n.initTxHash)===t.source_swap.initiate_tx_hash)return;const i=await Zn.from(r,Number(t.source_swap.amount),t.create_order.secret_hash,fr(t.source_swap.initiator),fr(t.source_swap.redeemer),t.source_swap.timelock),s=t.create_order.additional_data.bitcoin_optional_recipient;if(s)try{const o=await i.generateInstantRefundSACP(s);if(!this._api)return;const a=new q.Url(this._api.orderbook).endpoint("orders/bitcoin/"+t.create_order.create_id+"/instant-refund");(await Dt.post(a,{headers:{"Content-Type":"application/json"},body:JSON.stringify({instant_refund_tx_bytes:o})})).status==="Ok"&&this.refundSacpCache.set(t.create_order.create_id,{initTxHash:t.source_swap.initiate_tx_hash})}catch(o){this.emit("error",t,"Failed to generate and post SACP: "+o);return}}async filterExpiredAndAssignStatus(t){var i;if(t.length===0)return ie([]);const r=await((i=this._blockNumberFetcher)==null?void 0:i.fetchBlockNumbers());if(r.error)return G(r.error);const n=[];for(let s=0;s<t.length;s++){const o=t[s];if(Ld(o))continue;const a=o.source_swap.chain,c=o.destination_swap.chain,f=r==null?void 0:r.val[a],l=r==null?void 0:r.val[c];if(!f||!l){this.emit("error",o,"Error while fetching CurrentBlockNumbers");continue}const h=dc(o,f,l);n.push({...o,status:h})}return ie(n)}async broadcastRedeemTx(t,r){try{if(!this._api)return G("API not found");const n=new q.Url(this._api.evmRelay).endpoint("/bitcoin/redeem "),i=await this._auth.getAuthHeaders(),o=await(await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",...i.val},body:JSON.stringify({redeem_tx_bytes:t,order_id:r})})).json();return o.status==="Ok"&&o.result?ie(o.result):G(o.error)}catch(n){return G("Failed to broadcast redeem tx: "+n)}}}class m_{constructor(t,r,n){this.callData=new Oe.CallData(Kl),this.account=t,this.starknetProvider=new Oe.RpcProvider({nodeUrl:r||(n?Si[n].nodeUrl:Si.mainnet.nodeUrl)})}get htlcActorAddress(){return this.account.address}async getHTLCContract(t,r=!1){const n=r?t.destination_swap.asset:t.source_swap.asset;return new Oe.Contract(Yl,n,this.account)}async initiate(t){try{const n=await(await this.getHTLCContract(t)).token();if(!n)throw new Error("Token address retrieval failed");const i=Oe.num.toHex(n),s=Oe.cairo.uint256(BigInt(t.source_swap.amount));try{const a=await h_(this.account,i,t.source_swap.asset,BigInt(t.source_swap.amount),this.starknetProvider);if(a.error)return G(a.error)}catch(a){return G(`Allowance check failed: ${a}`)}const o=await this.account.execute({contractAddress:t.source_swap.asset,entrypoint:"initiate",calldata:[t.source_swap.redeemer,BigInt(t.source_swap.timelock),s.low,s.high,...q.hexToU32Array(t.create_order.secret_hash)]});if(!o.transaction_hash)throw new Error("Failed to initiate HTLC transaction");return ie(o.transaction_hash)}catch(r){return G(`HTLC Initiation Error: ${r}`)}}async redeem(t,r){try{const n=await this.getHTLCContract(t,!0),i=t.create_order.source_chain.includes("starknet")?t.source_swap.swap_id:t.destination_swap.swap_id,s=await this.account.execute({contractAddress:n.address,entrypoint:"redeem",calldata:Oe.CallData.compile({swap_id:i,secret:q.hexToU32Array(r)})});return s.transaction_hash?ie(s.transaction_hash):G("Failed to redeem HTLC transaction")}catch{return G("HTLC Redeem Error")}}async refund(t){try{const r=t.create_order.source_chain.includes("starknet")?t.source_swap.swap_id:t.destination_swap.swap_id,n=await this.getHTLCContract(t),i=await this.account.execute({contractAddress:n.address,entrypoint:"refund",calldata:{orderId:r}});return i.transaction_hash?ie(i.transaction_hash):G("Failed to refund HTLC transaction")}catch{return G("HTLC Refund Error")}}}exports.API=hs;exports.AbiErrorInputsNotFoundError=Jh;exports.AbiErrorNotFoundError=Qh;exports.AbiFunctionNotFoundError=ei;exports.AbiFunctionOutputsNotFoundError=Tf;exports.AbiFunctionSignatureNotFoundError=e0;exports.BaseError=L;exports.BlockNumberFetcher=il;exports.EvmRelay=Wl;exports.Garden=kc;exports.Hash=Ma;exports.HttpRequestError=on;exports.InvalidArrayError=kf;exports.OrderActions=Ce;exports.OrderStatus=we;exports.ParseOrderStatus=dc;exports.ParseSwapStatus=Ea;exports.Quote=sl;exports.STARKNET_CONFIG=Si;exports.SecretManager=Bi;exports.StarknetHTLC=m_;exports.StarknetRelay=Xl;exports.SwapStatus=xe;exports.abytes=Oi;exports.aexists=ti;exports.ahash=m0;exports.batchGatewayAbi=my;exports.call=sc;exports.concat=Ur;exports.concatBytes=P0;exports.concatHex=Ot;exports.constructOrderPair=va;exports.decodeAbiParameters=Fi;exports.decodeErrorResult=Kf;exports.encodeAbiParameters=Ns;exports.evmToViemChainMap=ql;exports.filterDeadlineExpiredOrders=cb;exports.formatAbiItem=Bt;exports.getAbiItem=Pn;exports.getUrl=Ms;exports.hyperliquid=zl;exports.hyperliquidTestnet=Gl;exports.isAddressEqual=rc;exports.isExpired=Pi;exports.isHex=qt;exports.parseAction=ab;exports.parseActionFromStatus=lc;exports.randomBytes=T0;exports.sha256=od;exports.slice=hn;exports.solidityError=Vf;exports.stringify=rt;exports.switchOrAddNetwork=Vl;exports.toBytes=Rs;exports.toFunctionSelector=Ls;exports.toXOnly=fr;exports.validateBTCAddress=nb;