@gardenfi/core 0.2.0-beta.45 → 0.2.0-beta.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
- "use strict";var Ls=Object.defineProperty;var Os=(e,t,r)=>t in e?Ls(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var pt=(e,t,r)=>Os(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("@catalogfi/utils"),J=require("@gardenfi/orderbook"),ge=require("@gardenfi/utils"),He=require("viem"),Fs=require("varuint-bitcoin"),Us=require("tiny-secp256k1"),Bn=require("@catalogfi/wallets"),bi=require("bitcoinjs-lib"),Ms=require("bignumber.js");function an(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const Sn=an(Fs),_t=an(Us),be=an(bi);var Yr=(e=>(e[e.evm=14400]="evm",e[e.btc=288]="btc",e))(Yr||{}),ye=(e=>(e.Idle="Idle",e.Initiate="Initiate",e.Redeem="Redeem",e.Refund="Refund",e))(ye||{});function Gt(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}const yi="2.21.30";let kt={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${yi}`};class Q extends Error{constructor(t,r={}){var u;const n=(()=>{var l;return r.cause instanceof Q?r.cause.details:(l=r.cause)!=null&&l.message?r.cause.message:r.details})(),i=r.cause instanceof Q&&r.cause.docsPath||r.docsPath,a=(u=kt.getDocsUrl)==null?void 0:u.call(kt,{...r,docsPath:i}),f=[t||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...a?[`Docs: ${a}`]:[],...n?[`Details: ${n}`]:[],...kt.version?[`Version: ${kt.version}`]:[]].join(`
2
- `);super(f,r.cause?{cause:r.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=n,this.docsPath=i,this.metaMessages=r.metaMessages,this.name=r.name??this.name,this.shortMessage=t,this.version=yi}walk(t){return gi(this,t)}}function gi(e,t){return t!=null&&t(e)?e:e&&typeof e=="object"&&"cause"in e?gi(e.cause,t):t?null:e}class Ns extends Q{constructor({max:t,min:r,signed:n,size:i,value:a}){super(`Number "${a}" is not in safe ${i?`${i*8}-bit ${n?"signed":"unsigned"} `:""}integer range ${t?`(${r} to ${t})`:`(above ${r})`}`,{name:"IntegerOutOfRangeError"})}}class Ds extends Q{constructor({givenSize:t,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}function qt(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}function xt(e){return qt(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}function sr(e,{dir:t="left"}={}){let r=typeof e=="string"?e.replace("0x",""):e,n=0;for(let i=0;i<r.length-1&&r[t==="left"?i:r.length-i-1].toString()==="0";i++)n++;return r=t==="left"?r.slice(n):r.slice(0,r.length-n),typeof e=="string"?(r.length===1&&t==="right"&&(r=`${r}0`),`0x${r.length%2===1?`0${r}`:r}`):r}class $s extends Q{constructor({offset:t,position:r,size:n}){super(`Slice ${r==="start"?"starting":"ending"} at offset "${t}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}}class mi extends Q{constructor({size:t,targetSize:r,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${t}) exceeds padding size (${r}).`,{name:"SizeExceedsPaddingSizeError"})}}function St(e,{dir:t,size:r=32}={}){return typeof e=="string"?Hs(e,{dir:t,size:r}):zs(e,{dir:t,size:r})}function Hs(e,{dir:t,size:r=32}={}){if(r===null)return e;const n=e.replace("0x","");if(n.length>r*2)throw new mi({size:Math.ceil(n.length/2),targetSize:r,type:"hex"});return`0x${n[t==="right"?"padEnd":"padStart"](r*2,"0")}`}function zs(e,{dir:t,size:r=32}={}){if(r===null)return e;if(e.length>r)throw new mi({size:e.length,targetSize:r,type:"bytes"});const n=new Uint8Array(r);for(let i=0;i<r;i++){const a=t==="right";n[a?i:r-i-1]=e[a?i:e.length-i-1]}return n}const js=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function q(e,t={}){return typeof e=="number"||typeof e=="bigint"?wi(e,t):typeof e=="string"?Ws(e,t):typeof e=="boolean"?Gs(e,t):Ze(e,t)}function Gs(e,t={}){const r=`0x${Number(e)}`;return typeof t.size=="number"?(It(r,{size:t.size}),St(r,{size:t.size})):r}function Ze(e,t={}){let r="";for(let i=0;i<e.length;i++)r+=js[e[i]];const n=`0x${r}`;return typeof t.size=="number"?(It(n,{size:t.size}),St(n,{dir:"right",size:t.size})):n}function wi(e,t={}){const{signed:r,size:n}=t,i=BigInt(e);let a;n?r?a=(1n<<BigInt(n)*8n-1n)-1n:a=2n**(BigInt(n)*8n)-1n:typeof e=="number"&&(a=BigInt(Number.MAX_SAFE_INTEGER));const f=typeof a=="bigint"&&r?-a-1n:0;if(a&&i>a||i<f){const l=typeof e=="bigint"?"n":"";throw new Ns({max:a?`${a}${l}`:void 0,min:`${f}${l}`,signed:r,size:n,value:`${e}${l}`})}const u=`0x${(r&&i<0?(1n<<BigInt(n*8))+BigInt(i):i).toString(16)}`;return n?St(u,{size:n}):u}const qs=new TextEncoder;function Ws(e,t={}){const r=qs.encode(e);return Ze(r,t)}const Vs=new TextEncoder;function _i(e,t={}){return typeof e=="number"||typeof e=="bigint"?Ys(e,t):typeof e=="boolean"?Ks(e,t):qt(e)?st(e,t):xi(e,t)}function Ks(e,t={}){const r=new Uint8Array(1);return r[0]=Number(e),typeof t.size=="number"?(It(r,{size:t.size}),St(r,{size:t.size})):r}const Ne={zero:48,nine:57,A:65,F:70,a:97,f:102};function In(e){if(e>=Ne.zero&&e<=Ne.nine)return e-Ne.zero;if(e>=Ne.A&&e<=Ne.F)return e-(Ne.A-10);if(e>=Ne.a&&e<=Ne.f)return e-(Ne.a-10)}function st(e,t={}){let r=e;t.size&&(It(r,{size:t.size}),r=St(r,{dir:"right",size:t.size}));let n=r.slice(2);n.length%2&&(n=`0${n}`);const i=n.length/2,a=new Uint8Array(i);for(let f=0,u=0;f<i;f++){const l=In(n.charCodeAt(u++)),y=In(n.charCodeAt(u++));if(l===void 0||y===void 0)throw new Q(`Invalid byte sequence ("${n[u-2]}${n[u-1]}" in "${n}").`);a[f]=l*16+y}return a}function Ys(e,t){const r=wi(e,t);return st(r)}function xi(e,t={}){const r=Vs.encode(e);return typeof t.size=="number"?(It(r,{size:t.size}),St(r,{dir:"right",size:t.size})):r}function It(e,{size:t}){if(xt(e)>t)throw new Ds({givenSize:xt(e),maxSize:t})}function gt(e,t={}){const{signed:r}=t;t.size&&It(e,{size:t.size});const n=BigInt(e);if(!r)return n;const i=(e.length-2)/2,a=(1n<<BigInt(i)*8n-1n)-1n;return n<=a?n:n-BigInt(`0x${"f".padStart(i*2,"f")}`)-1n}function or(e,t={}){return Number(gt(e,t))}function fn(e,t){return({exclude:r,format:n})=>({exclude:r,format:i=>{const a=t(i);if(r)for(const f of r)delete a[f];return{...a,...n(i)}},type:e})}const vi={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function un(e){const t={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?or(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?or(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?vi[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=Xs(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 Js=fn("transaction",un);function Xs(e){return e.map(t=>({contractAddress:t.address,chainId:Number(t.chainId),nonce:Number(t.nonce),r:t.r,s:t.s,yParity:Number(t.yParity)}))}function Qs(e){var r;const t=(r=e.transactions)==null?void 0:r.map(n=>typeof n=="string"?n:un(n));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 Zs=fn("block",Qs);function eo(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}:{}}}const to={"0x0":"reverted","0x1":"success"};function ro(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=>eo(r)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?or(e.transactionIndex):null,status:e.status?to[e.status]:null,type:e.type?vi[e.type]||e.type:null};return e.blobGasPrice&&(t.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(t.blobGasUsed=BigInt(e.blobGasUsed)),t}const no=fn("transactionReceipt",ro),cn=2n**256n-1n;function Wt(e){return`0x${e.reduce((t,r)=>t+r.replace("0x",""),"")}`}class An extends Q{constructor({offset:t}){super(`Offset \`${t}\` cannot be negative.`,{name:"NegativeOffsetError"})}}class io extends Q{constructor({length:t,position:r}){super(`Position \`${r}\` is out of bounds (\`0 < position < ${t}\`).`,{name:"PositionOutOfBoundsError"})}}class so extends Q{constructor({count:t,limit:r}){super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${t}\`).`,{name:"RecursiveReadLimitExceededError"})}}const oo={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new so({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new io({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new An({offset:e});const t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new An({offset:e});const t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){const r=t??this.position;return this.assertPosition(r+e-1),this.bytes.subarray(r,r+e)},inspectUint8(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){const t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){const t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){const t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,e&255),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();const r=this.inspectBytes(e);return this.position+=t??e,r},readUint8(){this.assertReadLimit(),this._touch();const e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();const e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();const e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();const e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){const t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}};function Ei(e,{recursiveReadLimit:t=8192}={}){const r=Object.create(oo);return r.bytes=e,r.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),r.positionReadCount=new Map,r.recursiveReadLimit=t,r}function ot(e,t="hex"){const r=Bi(e),n=Ei(new Uint8Array(r.length));return r.encode(n),t==="hex"?Ze(n.bytes):n.bytes}function Bi(e){return Array.isArray(e)?ao(e.map(t=>Bi(t))):fo(e)}function ao(e){const t=e.reduce((i,a)=>i+a.length,0),r=Si(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:a}of e)a(i)}}}function fo(e){const t=typeof e=="string"?st(e):e,r=Si(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 Si(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 Q("Length is too large.")}const uo={ether:-9,wei:9};function co(e,t){let r=e.toString();const n=r.startsWith("-");n&&(r=r.slice(1)),r=r.padStart(t,"0");let[i,a]=[r.slice(0,r.length-t),r.slice(r.length-t)];return a=a.replace(/(0+)$/,""),`${n?"-":""}${i||"0"}${a?`.${a}`:""}`}function Jr(e,t="wei"){return co(e,uo[t])}function lo(e){const t=Object.entries(e).map(([n,i])=>i===void 0||i===!1?null:[n,i]).filter(Boolean),r=t.reduce((n,[i])=>Math.max(n,i.length),0);return t.map(([n,i])=>` ${`${n}:`.padEnd(r+1)} ${i}`).join(`
3
- `)}class ho extends Q{constructor({v:t}){super(`Invalid \`v\` value "${t}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}}class po extends Q{constructor({transaction:t}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",lo(t),"}","","To infer the type, either provide:","- a `type` to the Transaction, or","- an EIP-1559 Transaction with `maxFeePerGas`, or","- an EIP-2930 Transaction with `gasPrice` & `accessList`, or","- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or","- an EIP-7702 Transaction with `authorizationList`, or","- a Legacy Transaction with `gasPrice`"],name:"InvalidSerializableTransactionError"})}}class bo extends Q{constructor({storageKey:t}){super(`Size for storage key "${t}" is invalid. Expected 32 bytes. Got ${Math.floor((t.length-2)/2)} bytes.`,{name:"InvalidStorageKeySizeError"})}}function Ii(e){const{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),n=typeof e.blobs[0]=="string"?e.blobs.map(a=>st(a)):e.blobs,i=[];for(const a of n)i.push(Uint8Array.from(t.blobToKzgCommitment(a)));return r==="bytes"?i:i.map(a=>Ze(a))}function Ai(e){const{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),n=typeof e.blobs[0]=="string"?e.blobs.map(f=>st(f)):e.blobs,i=typeof e.commitments[0]=="string"?e.commitments.map(f=>st(f)):e.commitments,a=[];for(let f=0;f<n.length;f++){const u=n[f],l=i[f];a.push(Uint8Array.from(t.computeBlobKzgProof(u,l)))}return r==="bytes"?a:a.map(f=>Ze(f))}function Rn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function yo(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function ln(e,...t){if(!yo(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function ar(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 Ri(e,t){ln(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const go=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),Pr=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Oe=(e,t)=>e<<32-t|e>>>t,Tn=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,mo=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;function Pn(e){for(let t=0;t<e.length;t++)e[t]=mo(e[t])}function wo(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function hn(e){return typeof e=="string"&&(e=wo(e)),ln(e),e}let Ti=class{clone(){return this._cloneInto()}};function Pi(e){const t=n=>e().update(hn(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function _o(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);const i=BigInt(32),a=BigInt(4294967295),f=Number(r>>i&a),u=Number(r&a),l=n?4:0,y=n?0:4;e.setUint32(t+l,f,n),e.setUint32(t+y,u,n)}const xo=(e,t,r)=>e&t^~e&r,vo=(e,t,r)=>e&t^e&r^t&r;class Eo extends Ti{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=Pr(this.buffer)}update(t){ar(this);const{view:r,buffer:n,blockLen:i}=this;t=hn(t);const a=t.length;for(let f=0;f<a;){const u=Math.min(i-this.pos,a-f);if(u===i){const l=Pr(t);for(;i<=a-f;f+=i)this.process(l,f);continue}n.set(t.subarray(f,f+u),this.pos),this.pos+=u,f+=u,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){ar(this),Ri(t,this),this.finished=!0;const{buffer:r,view:n,blockLen:i,isLE:a}=this;let{pos:f}=this;r[f++]=128,this.buffer.subarray(f).fill(0),this.padOffset>i-f&&(this.process(n,0),f=0);for(let w=f;w<i;w++)r[w]=0;_o(n,i-8,BigInt(this.length*8),a),this.process(n,0);const u=Pr(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const y=l/4,g=this.get();if(y>g.length)throw new Error("_sha2: outputLen bigger than state");for(let w=0;w<y;w++)u.setUint32(4*w,g[w],a)}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:a,destroyed:f,pos:u}=this;return t.length=i,t.pos=u,t.finished=a,t.destroyed=f,i%r&&t.buffer.set(n),t}}const Bo=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]),Ye=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Je=new Uint32Array(64);class So extends Eo{constructor(){super(64,32,8,!1),this.A=Ye[0]|0,this.B=Ye[1]|0,this.C=Ye[2]|0,this.D=Ye[3]|0,this.E=Ye[4]|0,this.F=Ye[5]|0,this.G=Ye[6]|0,this.H=Ye[7]|0}get(){const{A:t,B:r,C:n,D:i,E:a,F:f,G:u,H:l}=this;return[t,r,n,i,a,f,u,l]}set(t,r,n,i,a,f,u,l){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=a|0,this.F=f|0,this.G=u|0,this.H=l|0}process(t,r){for(let w=0;w<16;w++,r+=4)Je[w]=t.getUint32(r,!1);for(let w=16;w<64;w++){const E=Je[w-15],I=Je[w-2],v=Oe(E,7)^Oe(E,18)^E>>>3,P=Oe(I,17)^Oe(I,19)^I>>>10;Je[w]=P+Je[w-7]+v+Je[w-16]|0}let{A:n,B:i,C:a,D:f,E:u,F:l,G:y,H:g}=this;for(let w=0;w<64;w++){const E=Oe(u,6)^Oe(u,11)^Oe(u,25),I=g+E+xo(u,l,y)+Bo[w]+Je[w]|0,P=(Oe(n,2)^Oe(n,13)^Oe(n,22))+vo(n,i,a)|0;g=y,y=l,l=u,u=f+I|0,f=a,a=i,i=n,n=I+P|0}n=n+this.A|0,i=i+this.B|0,a=a+this.C|0,f=f+this.D|0,u=u+this.E|0,l=l+this.F|0,y=y+this.G|0,g=g+this.H|0,this.set(n,i,a,f,u,l,y,g)}roundClean(){Je.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Io=Pi(()=>new So);function Ao(e,t){return Io(qt(e,{strict:!1})?_i(e):e)}function Ro(e){const{commitment:t,version:r=1}=e,n=e.to??(typeof t=="string"?"hex":"bytes"),i=Ao(t);return i.set([r],0),n==="bytes"?i:Ze(i)}function To(e){const{commitments:t,version:r}=e,n=e.to??(typeof t[0]=="string"?"hex":"bytes"),i=[];for(const a of t)i.push(Ro({commitment:a,to:n,version:r}));return i}const kn=6,ki=32,dn=4096,Ci=ki*dn,Cn=Ci*kn-1-1*dn*kn,Li=1;class Po extends Q{constructor({maxSize:t,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${t} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}}class Oi extends Q{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}class ko extends Q{constructor({hash:t,size:r}){super(`Versioned hash "${t}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${r}`],name:"InvalidVersionedHashSizeError"})}}class Co extends Q{constructor({hash:t,version:r}){super(`Versioned hash "${t}" version is invalid.`,{metaMessages:[`Expected: ${Li}`,`Received: ${r}`],name:"InvalidVersionedHashVersionError"})}}function Lo(e){const t=e.to??(typeof e.data=="string"?"hex":"bytes"),r=typeof e.data=="string"?st(e.data):e.data,n=xt(r);if(!n)throw new Oi;if(n>Cn)throw new Po({maxSize:Cn,size:n});const i=[];let a=!0,f=0;for(;a;){const u=Ei(new Uint8Array(Ci));let l=0;for(;l<dn;){const y=r.slice(f,f+(ki-1));if(u.pushByte(0),u.pushBytes(y),y.length<31){u.pushByte(128),a=!1;break}l++,f+=31}i.push(u)}return t==="bytes"?i.map(u=>u.bytes):i.map(u=>Ze(u.bytes))}function Oo(e){const{data:t,kzg:r,to:n}=e,i=e.blobs??Lo({data:t,to:n}),a=e.commitments??Ii({blobs:i,kzg:r,to:n}),f=e.proofs??Ai({blobs:i,commitments:a,kzg:r,to:n}),u=[];for(let l=0;l<i.length;l++)u.push({blob:i[l],commitment:a[l],proof:f[l]});return u}function Fo(e){if(!e||e.length===0)return[];const t=[];for(const r of e){const{contractAddress:n,chainId:i,nonce:a,...f}=r;t.push([q(i),n,a?q(a):"0x",...Vt({},f)])}return t}class at extends Q{constructor({address:t}){super(`Address "${t}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class br extends Q{constructor({chainId:t}){super(typeof t=="number"?`Chain ID "${t}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}class yr extends Q{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${Jr(r)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:t,name:"FeeCapTooHighError"})}}Object.defineProperty(yr,"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 Fi extends Q{constructor({cause:t,maxPriorityFeePerGas:r,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${r?` = ${Jr(r)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${Jr(n)} gwei`:""}).`].join(`
4
- `),{cause:t,name:"TipAboveFeeCapError"})}}Object.defineProperty(Fi,"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 Ui extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){const r=super.get(t);return super.has(t)&&r!==void 0&&(this.delete(t),super.set(t,r)),r}set(t,r){if(super.set(t,r),this.maxSize&&this.size>this.maxSize){const n=this.keys().next().value;n&&this.delete(n)}return this}}const er=BigInt(2**32-1),Ln=BigInt(32);function Uo(e,t=!1){return t?{h:Number(e&er),l:Number(e>>Ln&er)}:{h:Number(e>>Ln&er)|0,l:Number(e&er)|0}}function Mo(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:a,l:f}=Uo(e[i],t);[r[i],n[i]]=[a,f]}return[r,n]}const No=(e,t,r)=>e<<r|t>>>32-r,Do=(e,t,r)=>t<<r|e>>>32-r,$o=(e,t,r)=>t<<r-32|e>>>64-r,Ho=(e,t,r)=>e<<r-32|t>>>64-r,Mi=[],Ni=[],Di=[],zo=BigInt(0),Ct=BigInt(1),jo=BigInt(2),Go=BigInt(7),qo=BigInt(256),Wo=BigInt(113);for(let e=0,t=Ct,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],Mi.push(2*(5*n+r)),Ni.push((e+1)*(e+2)/2%64);let i=zo;for(let a=0;a<7;a++)t=(t<<Ct^(t>>Go)*Wo)%qo,t&jo&&(i^=Ct<<(Ct<<BigInt(a))-Ct);Di.push(i)}const[Vo,Ko]=Mo(Di,!0),On=(e,t,r)=>r>32?$o(e,t,r):No(e,t,r),Fn=(e,t,r)=>r>32?Ho(e,t,r):Do(e,t,r);function Yo(e,t=24){const r=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let f=0;f<10;f++)r[f]=e[f]^e[f+10]^e[f+20]^e[f+30]^e[f+40];for(let f=0;f<10;f+=2){const u=(f+8)%10,l=(f+2)%10,y=r[l],g=r[l+1],w=On(y,g,1)^r[u],E=Fn(y,g,1)^r[u+1];for(let I=0;I<50;I+=10)e[f+I]^=w,e[f+I+1]^=E}let i=e[2],a=e[3];for(let f=0;f<24;f++){const u=Ni[f],l=On(i,a,u),y=Fn(i,a,u),g=Mi[f];i=e[g],a=e[g+1],e[g]=l,e[g+1]=y}for(let f=0;f<50;f+=10){for(let u=0;u<10;u++)r[u]=e[f+u];for(let u=0;u<10;u++)e[f+u]^=~r[(u+2)%10]&r[(u+4)%10]}e[0]^=Vo[n],e[1]^=Ko[n]}r.fill(0)}class pn extends Ti{constructor(t,r,n,i=!1,a=24){if(super(),this.blockLen=t,this.suffix=r,this.outputLen=n,this.enableXOF=i,this.rounds=a,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Rn(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=go(this.state)}keccak(){Tn||Pn(this.state32),Yo(this.state32,this.rounds),Tn||Pn(this.state32),this.posOut=0,this.pos=0}update(t){ar(this);const{blockLen:r,state:n}=this;t=hn(t);const i=t.length;for(let a=0;a<i;){const f=Math.min(r-this.pos,i-a);for(let u=0;u<f;u++)n[this.pos++]^=t[a++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:r,pos:n,blockLen:i}=this;t[n]^=r,r&128&&n===i-1&&this.keccak(),t[i-1]^=128,this.keccak()}writeInto(t){ar(this,!1),ln(t),this.finish();const r=this.state,{blockLen:n}=this;for(let i=0,a=t.length;i<a;){this.posOut>=n&&this.keccak();const f=Math.min(n-this.posOut,a-i);t.set(r.subarray(this.posOut,this.posOut+f),i),this.posOut+=f,i+=f}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Rn(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Ri(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:r,suffix:n,outputLen:i,rounds:a,enableXOF:f}=this;return t||(t=new pn(r,n,i,f,a)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=n,t.outputLen=i,t.enableXOF=f,t.destroyed=this.destroyed,t}}const Jo=(e,t,r)=>Pi(()=>new pn(t,e,r)),Xo=Jo(1,136,256/8);function Qo(e,t){return Xo(qt(e,{strict:!1})?_i(e):e)}const kr=new Ui(8192);function Zo(e,t){if(kr.has(`${e}.${t}`))return kr.get(`${e}.${t}`);const r=e.substring(2).toLowerCase(),n=Qo(xi(r)),i=r.split("");for(let f=0;f<40;f+=2)n[f>>1]>>4>=8&&i[f]&&(i[f]=i[f].toUpperCase()),(n[f>>1]&15)>=8&&i[f+1]&&(i[f+1]=i[f+1].toUpperCase());const a=`0x${i.join("")}`;return kr.set(`${e}.${t}`,a),a}const ea=/^0x[a-fA-F0-9]{40}$/,Cr=new Ui(8192);function ft(e,t){const{strict:r=!0}=t??{},n=`${e}.${r}`;if(Cr.has(n))return Cr.get(n);const i=ea.test(e)?e.toLowerCase()===e?!0:r?Zo(e)===e:!0:!1;return Cr.set(n,i),i}function ta(e,t,r,{strict:n}={}){return qt(e,{strict:!1})?na(e,t,r,{strict:n}):ra(e,t,r,{strict:n})}function $i(e,t,r){if(xt(e)!==r-t)throw new $s({offset:r,position:"end",size:xt(e)})}function ra(e,t,r,{strict:n}={}){const i=e.slice(t,r);return n&&$i(i,t,r),i}function na(e,t,r,{strict:n}={}){const i=`0x${e.replace("0x","").slice(t*2,r*2)}`;return n&&$i(i,t,r),i}function ia(e){const{authorizationList:t}=e;if(t)for(const r of t){const{contractAddress:n,chainId:i}=r;if(!ft(n))throw new at({address:n});if(i<=0)throw new br({chainId:i})}bn(e)}function sa(e){const{blobVersionedHashes:t}=e;if(t){if(t.length===0)throw new Oi;for(const r of t){const n=xt(r),i=or(ta(r,0,1));if(n!==32)throw new ko({hash:r,size:n});if(i!==Li)throw new Co({hash:r,version:i})}}bn(e)}function bn(e){const{chainId:t,maxPriorityFeePerGas:r,maxFeePerGas:n,to:i}=e;if(t<=0)throw new br({chainId:t});if(i&&!ft(i))throw new at({address:i});if(n&&n>cn)throw new yr({maxFeePerGas:n});if(r&&n&&r>n)throw new Fi({maxFeePerGas:n,maxPriorityFeePerGas:r})}function oa(e){const{chainId:t,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:i,to:a}=e;if(t<=0)throw new br({chainId:t});if(a&&!ft(a))throw new at({address:a});if(r||i)throw new Q("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(n&&n>cn)throw new yr({maxFeePerGas:n})}function aa(e){const{chainId:t,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:i,to:a}=e;if(a&&!ft(a))throw new at({address:a});if(typeof t<"u"&&t<=0)throw new br({chainId:t});if(r||i)throw new Q("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(n&&n>cn)throw new yr({maxFeePerGas:n})}function fa(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 po({transaction:e})}function gr(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 a=0;a<i.length;a++)if(i[a].length-2!==64)throw new bo({storageKey:i[a]});if(!ft(n,{strict:!1}))throw new at({address:n});t.push([n,i])}return t}function ua(e,t){const r=fa(e);return r==="eip1559"?ha(e,t):r==="eip2930"?da(e,t):r==="eip4844"?la(e,t):r==="eip7702"?ca(e,t):pa(e,t)}function ca(e,t){const{authorizationList:r,chainId:n,gas:i,nonce:a,to:f,value:u,maxFeePerGas:l,maxPriorityFeePerGas:y,accessList:g,data:w}=e;ia(e);const E=gr(g),I=Fo(r);return Wt(["0x04",ot([q(n),a?q(a):"0x",y?q(y):"0x",l?q(l):"0x",i?q(i):"0x",f??"0x",u?q(u):"0x",w??"0x",E,I,...Vt(e,t)])])}function la(e,t){const{chainId:r,gas:n,nonce:i,to:a,value:f,maxFeePerBlobGas:u,maxFeePerGas:l,maxPriorityFeePerGas:y,accessList:g,data:w}=e;sa(e);let E=e.blobVersionedHashes,I=e.sidecars;if(e.blobs&&(typeof E>"u"||typeof I>"u")){const O=typeof e.blobs[0]=="string"?e.blobs:e.blobs.map(S=>Ze(S)),L=e.kzg,U=Ii({blobs:O,kzg:L});if(typeof E>"u"&&(E=To({commitments:U})),typeof I>"u"){const S=Ai({blobs:O,commitments:U,kzg:L});I=Oo({blobs:O,commitments:U,proofs:S})}}const v=gr(g),P=[q(r),i?q(i):"0x",y?q(y):"0x",l?q(l):"0x",n?q(n):"0x",a??"0x",f?q(f):"0x",w??"0x",v,u?q(u):"0x",E??[],...Vt(e,t)],T=[],k=[],F=[];if(I)for(let O=0;O<I.length;O++){const{blob:L,commitment:U,proof:S}=I[O];T.push(L),k.push(U),F.push(S)}return Wt(["0x03",ot(I?[P,T,k,F]:P)])}function ha(e,t){const{chainId:r,gas:n,nonce:i,to:a,value:f,maxFeePerGas:u,maxPriorityFeePerGas:l,accessList:y,data:g}=e;bn(e);const w=gr(y),E=[q(r),i?q(i):"0x",l?q(l):"0x",u?q(u):"0x",n?q(n):"0x",a??"0x",f?q(f):"0x",g??"0x",w,...Vt(e,t)];return Wt(["0x02",ot(E)])}function da(e,t){const{chainId:r,gas:n,data:i,nonce:a,to:f,value:u,accessList:l,gasPrice:y}=e;oa(e);const g=gr(l),w=[q(r),a?q(a):"0x",y?q(y):"0x",n?q(n):"0x",f??"0x",u?q(u):"0x",i??"0x",g,...Vt(e,t)];return Wt(["0x01",ot(w)])}function pa(e,t){const{chainId:r=0,gas:n,data:i,nonce:a,to:f,value:u,gasPrice:l}=e;aa(e);let y=[a?q(a):"0x",l?q(l):"0x",n?q(n):"0x",f??"0x",u?q(u):"0x",i??"0x"];if(t){const g=(()=>{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 I=27n+(t.v===27n?0n:1n);if(t.v!==I)throw new ho({v:t.v});return I})(),w=sr(t.r),E=sr(t.s);y=[...y,q(g),w==="0x00"?"0x":w,E==="0x00"?"0x":E]}else r>0&&(y=[...y,q(r),"0x","0x"]);return ot(y)}function Vt(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 a=sr(r.r),f=sr(r.s);return[typeof i=="number"?i?q(1):"0x":n===0n?"0x":n===1n?q(1):n===27n?"0x":q(1),a==="0x00"?"0x":a,f==="0x00"?"0x":f]}const ba={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}},ya={block:Zs({format(e){var r;return{transactions:(r=e.transactions)==null?void 0:r.map(n=>{if(typeof n=="string")return n;const i=un(n);return i.typeHex==="0x7e"&&(i.isSystemTx=n.isSystemTx,i.mint=n.mint?gt(n.mint):void 0,i.sourceHash=n.sourceHash,i.type="deposit"),i}),stateRoot:e.stateRoot}}}),transaction:Js({format(e){const t={};return e.type==="0x7e"&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?gt(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:no({format(e){return{l1GasPrice:e.l1GasPrice?gt(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?gt(e.l1GasUsed):null,l1Fee:e.l1Fee?gt(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null}}})};function ga(e,t){return _a(e)?wa(e):ua(e,t)}const ma={transaction:ga};function wa(e){xa(e);const{sourceHash:t,data:r,from:n,gas:i,isSystemTx:a,mint:f,to:u,value:l}=e,y=[t,n,u??"0x",f?q(f):"0x",l?q(l):"0x",i?q(i):"0x",a?"0x1":"0x",r??"0x"];return Wt(["0x7e",ot(y)])}function _a(e){return e.type==="deposit"||typeof e.sourceHash<"u"}function xa(e){const{from:t,to:r}=e;if(t&&!ft(t))throw new at({address:t});if(r&&!ft(r))throw new at({address:r})}const Un={contracts:ba,formatters:ya,serializers:ma},va=Gt({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}}}),Ea=Gt({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}),Lt=11155111,Ba=Gt({...Un,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:{...Un.contracts,disputeGameFactory:{[Lt]:{address:"0xd6E6dBf4F7EA0ac412fD8b65ED297e64BB7a06E1"}},l2OutputOracle:{[Lt]:{address:"0x84457ca9D0163FbC4bbfe4Dfbb20ba46e48DF254"}},portal:{[Lt]:{address:"0x49f53e41452c74589e85ca1677426ba426459e85",blockCreated:4446677}},l1StandardBridge:{[Lt]:{address:"0xfd0Bf71F60660E2f608ed56e1659C450eB113120",blockCreated:4446677}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:1059647}},testnet:!0,sourceId:Lt}),Sa=Gt({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://cloudflare-eth.com"]}},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}}}),Ia=Gt({id:11155111,name:"Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc2.sepolia.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});function Xr(e){return typeof e=="string"&&(e=Buffer.from(e,"hex")),e.length===32?e:e.subarray(1,33)}function bt(e,t){if(!e)throw new Error(t)}function Aa(e){return Buffer.concat([Uint8Array.from([192]),Ra(e)])}function Ra(e){const t=Sn.encodingLength(e.length),r=Buffer.allocUnsafe(t);return Sn.encode(e.length,r),Buffer.concat([r,e])}function Ta(e,t){if(e.compare(t)>0){const r=e;e=t,t=r}return[e,t]}const Ot=e=>e.length===64?e:e.slice(2),Pa=e=>{if(!e)return!1;try{const t=Buffer.from(e,"hex");return _t.isPoint(t)}catch{return!1}},ka={ethereum:Sa,ethereum_arbitrum:va,ethereum_sepolia:Ia,arbitrum_sepolia:Ea,ethereum_localnet:J.EthereumLocalnet,arbitrum_localnet:J.ArbitrumLocalnet,base_sepolia:Ba},Ca=async(e,t)=>{var n;const r=ka[e];if(r)try{if(r.id===((n=t.chain)==null?void 0:n.id))return C.Ok({message:"Already on the network",walletClient:t});await t.switchChain({id:r.id});const i=He.createWalletClient({account:t.account,chain:r,transport:He.custom(window.ethereum)});return C.Ok({message:"Switched chain",walletClient:i})}catch(i){if(La(i))try{await t.addChain({chain:r});const a=He.createWalletClient({account:t.account,chain:r,transport:He.custom(window.ethereum)});return C.Ok({message:"Added network",walletClient:a})}catch{return C.Err("Failed to add network")}else return C.Err("Failed to switch network")}else return C.Err("Chain not supported")},La=e=>typeof e=="object"&&e!==null&&"code"in e&&e.code===4902;var se=(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))(se||{}),re=(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))(re||{});const Hi=(e,t,r)=>{const n=fr(e.source_swap,t),i=fr(e.destination_swap,r);if(n===re.Redeemed)return se.CounterPartyRedeemed;if(n===re.RedeemDetected)return se.CounterPartyRedeemDetected;if(i===re.Redeemed)return se.Redeemed;if(i===re.RedeemDetected)return se.RedeemDetected;if(n===re.Refunded)return se.Refunded;if(n===re.RefundDetected)return se.RefundDetected;if(i===re.Refunded)return se.CounterPartyRefunded;if(i===re.RefundDetected)return se.CounterPartyRefundDetected;if(i===re.Expired)return se.CounterPartySwapExpired;if(n===re.Expired)return se.Expired;const a=Number(e.create_order.additional_data.deadline);return i===re.Initiated?se.CounterPartyInitiated:i===re.InitiateDetected?se.CounterPartyInitiateDetected:Mn(a,12)?se.DeadLineExceeded:n===re.Initiated?se.Initiated:Mn(a,1)?se.DeadLineExceeded:n===re.InitiateDetected?se.InitiateDetected:se.Matched},fr=(e,t)=>{if(e.redeem_tx_hash)return Number(e.redeem_block_number)?re.Redeemed:re.RedeemDetected;if(e.refund_tx_hash)return Number(e.refund_block_number)?re.Refunded:re.RefundDetected;if(Number(e.initiate_block_number)){const r=Number(e.initiate_block_number)+e.timelock;if(t>r)return re.Expired}return e.initiate_tx_hash?Number(e.initiate_block_number)?re.Initiated:re.InitiateDetected:re.Idle},zi=(e,t,r)=>{switch(Hi(e,t,r)){case se.Matched:return ye.Initiate;case se.CounterPartyInitiated:case se.CounterPartyInitiateDetected:return ye.Redeem;case se.Expired:return ye.Refund;default:return ye.Idle}},Mn=(e,t=0)=>{const r=Date.now(),n=e*1e3+t*36e5;return r>=n},Oa=[{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"}];class ji{constructor(t,r,n){this.url=new ge.Url("/relayer",r),this.auth=n,this.order=t}async init(t,r){if(!t.account)return C.Err("No account found");if(t.account.address.toLowerCase()!==this.order.source_swap.initiator.toLowerCase())return C.Err("Account address and order initiator mismatch");if(!r){const g=await ge.fetchEVMBlockNumber(t);if(g.error)return C.Err(g.error);r=g.val}if(fr(this.order.source_swap,r)!==re.Idle)return C.Err("Invalid swap status");const{create_order:i,source_swap:a}=this.order;if(!a.amount||!a.redeemer||!i.timelock||!i.secret_hash)return C.Err("Invalid order");const f=ge.with0x(i.secret_hash),u=BigInt(i.timelock),l=ge.with0x(a.redeemer),y=BigInt(a.amount);try{const g=await this.auth.getToken();if(g.error)return C.Err(g.error);const w=He.getContract({address:ge.with0x(this.order.source_swap.asset),abi:Oa,client:t}),E=await w.read.token(),I=await ge.checkAllowanceAndApprove(Number(y),E,this.order.source_swap.asset,t);if(I.error)return C.Err(I.error);const v=await w.read.eip712Domain(),P=await t.signTypedData({account:t.account,domain:{name:v[1],version:v[2],chainId:Number(v[3]),verifyingContract:v[4]},types:{Initiate:[{name:"redeemer",type:"address"},{name:"timelock",type:"uint256"},{name:"amount",type:"uint256"},{name:"secretHash",type:"bytes32"}]},primaryType:"Initiate",message:{redeemer:l,timelock:u,amount:y,secretHash:f}}),T=await C.Fetcher.post(this.url.endpoint("initiate"),{body:JSON.stringify({order_id:i.create_id,signature:P,perform_on:"Source"}),headers:{Authorization:ge.Authorization(g.val),"Content-Type":"application/json"}});return T.error?C.Err(T.error):T.result?C.Ok(T.result):C.Err("Init: No result found")}catch(g){return console.log("init error :",g),C.Err(String(g))}}async redeem(t,r){try{const n=await this.auth.getToken();if(n.error)return C.Err(n.error);const i=await C.Fetcher.post(this.url.endpoint("redeem"),{body:JSON.stringify({order_id:t,secret:C.trim0x(r),perform_on:"Destination"}),headers:{Authorization:ge.Authorization(n.val),"Content-Type":"application/json"}});return i.error?C.Err(i.error):i.result?C.Ok(i.result):C.Err("Redeem: No result found")}catch(n){return C.Err(String(n))}}}const Fa=Buffer.from("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","hex"),Ua=Buffer.from("483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8","hex"),Ma=Buffer.concat([Fa,Ua]),Na=Buffer.from("0250929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0","hex"),Nn={failedToCreateInternalPubkey:"failed to create internal pubkey",failedToTweakPubkey:"failed to tweak pubkey"};function Da(){const e=bi.crypto.sha256(Buffer.from("GardenHTLC","utf-8")),t=_t.pointMultiply(Buffer.concat([Buffer.from("04","hex"),Ma]),e);if(!t)throw new Error(Nn.failedToCreateInternalPubkey);const r=_t.pointAdd(Na,t);if(!r)throw new Error(Nn.failedToCreateInternalPubkey);return Xr(Buffer.from(r))}const we={secretMismatch:"invalid secret",secretHashLenMismatch:"secret hash should be 32 bytes",pubkeyLenMismatch:"pubkey should be 32 bytes",zeroOrNegativeExpiry:"expiry should be greater than 0",htlcAddressGenerationFailed:"failed to generate htlc address",notFunded:"address not funded",noCounterpartySigs:"counterparty signatures are required",counterPartySigNotFound:e=>"counterparty signature not found for utxo "+e,invalidCounterpartySigForUTXO:e=>"invalid counterparty signature for utxo "+e,htlcNotExpired:e=>`HTLC not expired, need more ${e} blocks`,controlBlockGenerationFailed:"failed to generate control block",invalidLeaf:"invalid leaf"},tr=192;be.initEccLib(_t);class ur{constructor(t,r,n,i,a,f,u,l){this.secretHash=n,this.redeemerPubkey=i,this.initiatorPubkey=a,this.expiry=f,this.signer=t,this.network=u,this.internalPubkey=Da(),this.initiateAmount=r,this.utxoHashes=l}static async from(t,r,n,i,a,f,u){n=n.startsWith("0x")?n.slice(2):n,bt(n.length===64,we.secretHashLenMismatch),bt(i.length===64||i.length===66,`initiator ${we.pubkeyLenMismatch}`),bt(a.length===64||a.length===66,`redeemer ${we.pubkeyLenMismatch}`),bt(f>0,we.zeroOrNegativeExpiry);const l=await t.getNetwork();return new ur(t,r,n,Xr(a).toString("hex"),Xr(i).toString("hex"),f,l,u)}address(){const{address:t}=be.payments.p2tr({internalPubkey:this.internalPubkey,network:this.network,scriptTree:this.leaves()});if(!t)throw new Error(we.htlcAddressGenerationFailed);return t}id(){return this.address()}async _buildRawTx(t,r){const n=new be.Transaction;n.version=2;const i=this.address(),a=await this.signer.getProvider();let f=[];if(this.utxoHashes&&this.utxoHashes.length>0)for(const l of this.utxoHashes){const y=await a.getTransaction(l);for(let g=0;g<y.vout.length;g++){const w=y.vout[g];w.scriptpubkey_address===i&&f.push({txid:y.txid,vout:g,value:w.value,status:{confirmed:!1}})}}else f=await a.getUTXOs(i);const u=f.reduce((l,y)=>l+y.value,0);if(u===0)throw new Error(`${i} ${we.notFunded}`);for(let l=0;l<f.length;l++)n.addInput(Buffer.from(f[l].txid,"hex").reverse(),f[l].vout);return r??(r=await a.suggestFee(i,u,Bn.Urgency.MEDIUM)),n.addOutput(be.address.toOutputScript(t,this.network),u-r),{tx:n,usedUtxos:f}}async buildRawTx(t){return await this._buildRawTx(await this.signer.getAddress(),t)}getOutputScript(){return be.address.toOutputScript(this.address(),this.network)}async init(t){return t??(t=await(await this.signer.getProvider()).suggestFee(await this.signer.getAddress(),this.initiateAmount,Bn.Urgency.MEDIUM)),await this.signer.send(this.address(),this.initiateAmount,t)}async instantRefund(t,r){bt(t.length>0,we.noCounterpartySigs);const{tx:n,usedUtxos:i}=await this.buildRawTx(r);for(const w of i)if(!t.find(E=>E.utxo===w.txid))throw new Error(we.counterPartySigNotFound(w.txid));const a=this.getOutputScript(),f=be.Transaction.SIGHASH_DEFAULT,u=this.leafHash(2),l=i.map(w=>w.value),y=Lr(a,i.length);for(let w=0;w<n.ins.length;w++){const E=n.hashForWitnessV1(w,y,l,f,u);if(!_t.verifySchnorr(E,Buffer.from(this.redeemerPubkey,"hex"),Buffer.from(t[w].sig,"hex")))throw new Error(we.invalidCounterpartySigForUTXO(t[w].utxo));const I=await this.signer.signSchnorr(E),v=Buffer.from(n.ins[w].hash).reverse().toString("hex"),P=t.find(T=>T.utxo===v);if(!P)throw new Error(we.counterPartySigNotFound(v));n.setWitness(w,[Buffer.from(P.sig,"hex"),I,this.instantRefundLeaf(),this.generateControlBlockFor(2)])}return await(await this.signer.getProvider()).broadcast(n.toHex())}async redeem(t,r,n){bt(be.crypto.sha256(Buffer.from(t,"hex")).toString("hex")===this.secretHash,we.secretMismatch);const{tx:i,usedUtxos:a}=await this._buildRawTx(r??await this.signer.getAddress(),n),f=this.leafHash(1),u=a.map(w=>w.value),l=Lr(this.getOutputScript(),a.length),y=be.Transaction.SIGHASH_DEFAULT;for(let w=0;w<i.ins.length;w++){const E=i.hashForWitnessV1(w,l,u,y,f),I=await this.signer.signSchnorr(E);i.setWitness(w,[I,Buffer.from(t,"hex"),this.redeemLeaf(),this.generateControlBlockFor(1)])}return await(await this.signer.getProvider()).broadcast(i.toHex())}async refund(t,r){const{tx:n,usedUtxos:i}=await this._buildRawTx(t??await this.signer.getAddress(),r),[a,f]=await this.canRefund(i);if(!a)throw new Error(we.htlcNotExpired(f));const u=this.leafHash(0),l=i.map(E=>E.value),y=Lr(this.getOutputScript(),i.length),g=be.Transaction.SIGHASH_DEFAULT;for(let E=0;E<n.ins.length;E++){n.ins[E].sequence=this.expiry;const I=n.hashForWitnessV1(E,y,l,g,u),v=await this.signer.signSchnorr(I);n.setWitness(E,[v,this.refundLeaf(),this.generateControlBlockFor(0)])}return await(await this.signer.getProvider()).broadcast(n.toHex())}async canRefund(t){const n=await(await this.signer.getProvider()).getLatestTip();for(const i of t){let a=0;if(i.status.confirmed&&i.status.block_height+this.expiry>n?a=i.status.block_height+this.expiry-n+1:i.status.confirmed||(a=this.expiry+1),a>0)return[!1,a]}return[!0,0]}generateControlBlockFor(t){let r;switch(t){case 1:r=this.redeemLeaf();break;case 0:r=this.refundLeaf();break;case 2:r=this.instantRefundLeaf();break;default:throw new Error(we.invalidLeaf)}const n=be.payments.p2tr({internalPubkey:this.internalPubkey,network:this.network,scriptTree:this.leaves(),redeem:{output:r,redeemVersion:tr}});if(!n.witness)throw new Error(we.controlBlockGenerationFailed);return n.witness[n.witness.length-1]}leafHash(t){let r=this.redeemLeaf();return t===0&&(r=this.refundLeaf()),t===2&&(r=this.instantRefundLeaf()),be.crypto.taggedHash("TapLeaf",Aa(r))}refundLeaf(){return be.script.fromASM(`
1
+ "use strict";var Os=Object.defineProperty;var Fs=(e,t,r)=>t in e?Os(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var pt=(e,t,r)=>Fs(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("@catalogfi/utils"),J=require("@gardenfi/orderbook"),ge=require("@gardenfi/utils"),He=require("viem"),Us=require("varuint-bitcoin"),Ms=require("tiny-secp256k1"),Bn=require("@catalogfi/wallets"),bi=require("bitcoinjs-lib"),Ns=require("bignumber.js");function an(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const Sn=an(Us),_t=an(Ms),be=an(bi);var Yr=(e=>(e[e.evm=14400]="evm",e[e.btc=288]="btc",e))(Yr||{}),ye=(e=>(e.Idle="Idle",e.Initiate="Initiate",e.Redeem="Redeem",e.Refund="Refund",e))(ye||{});function Gt(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}const yi="2.21.30";let kt={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${yi}`};class Q extends Error{constructor(t,r={}){var u;const n=(()=>{var l;return r.cause instanceof Q?r.cause.details:(l=r.cause)!=null&&l.message?r.cause.message:r.details})(),i=r.cause instanceof Q&&r.cause.docsPath||r.docsPath,a=(u=kt.getDocsUrl)==null?void 0:u.call(kt,{...r,docsPath:i}),f=[t||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...a?[`Docs: ${a}`]:[],...n?[`Details: ${n}`]:[],...kt.version?[`Version: ${kt.version}`]:[]].join(`
2
+ `);super(f,r.cause?{cause:r.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=n,this.docsPath=i,this.metaMessages=r.metaMessages,this.name=r.name??this.name,this.shortMessage=t,this.version=yi}walk(t){return gi(this,t)}}function gi(e,t){return t!=null&&t(e)?e:e&&typeof e=="object"&&"cause"in e?gi(e.cause,t):t?null:e}class Ds extends Q{constructor({max:t,min:r,signed:n,size:i,value:a}){super(`Number "${a}" is not in safe ${i?`${i*8}-bit ${n?"signed":"unsigned"} `:""}integer range ${t?`(${r} to ${t})`:`(above ${r})`}`,{name:"IntegerOutOfRangeError"})}}class $s extends Q{constructor({givenSize:t,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}function qt(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}function xt(e){return qt(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}function sr(e,{dir:t="left"}={}){let r=typeof e=="string"?e.replace("0x",""):e,n=0;for(let i=0;i<r.length-1&&r[t==="left"?i:r.length-i-1].toString()==="0";i++)n++;return r=t==="left"?r.slice(n):r.slice(0,r.length-n),typeof e=="string"?(r.length===1&&t==="right"&&(r=`${r}0`),`0x${r.length%2===1?`0${r}`:r}`):r}class Hs extends Q{constructor({offset:t,position:r,size:n}){super(`Slice ${r==="start"?"starting":"ending"} at offset "${t}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}}class mi extends Q{constructor({size:t,targetSize:r,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${t}) exceeds padding size (${r}).`,{name:"SizeExceedsPaddingSizeError"})}}function St(e,{dir:t,size:r=32}={}){return typeof e=="string"?zs(e,{dir:t,size:r}):js(e,{dir:t,size:r})}function zs(e,{dir:t,size:r=32}={}){if(r===null)return e;const n=e.replace("0x","");if(n.length>r*2)throw new mi({size:Math.ceil(n.length/2),targetSize:r,type:"hex"});return`0x${n[t==="right"?"padEnd":"padStart"](r*2,"0")}`}function js(e,{dir:t,size:r=32}={}){if(r===null)return e;if(e.length>r)throw new mi({size:e.length,targetSize:r,type:"bytes"});const n=new Uint8Array(r);for(let i=0;i<r;i++){const a=t==="right";n[a?i:r-i-1]=e[a?i:e.length-i-1]}return n}const Gs=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function q(e,t={}){return typeof e=="number"||typeof e=="bigint"?wi(e,t):typeof e=="string"?Vs(e,t):typeof e=="boolean"?qs(e,t):Ze(e,t)}function qs(e,t={}){const r=`0x${Number(e)}`;return typeof t.size=="number"?(It(r,{size:t.size}),St(r,{size:t.size})):r}function Ze(e,t={}){let r="";for(let i=0;i<e.length;i++)r+=Gs[e[i]];const n=`0x${r}`;return typeof t.size=="number"?(It(n,{size:t.size}),St(n,{dir:"right",size:t.size})):n}function wi(e,t={}){const{signed:r,size:n}=t,i=BigInt(e);let a;n?r?a=(1n<<BigInt(n)*8n-1n)-1n:a=2n**(BigInt(n)*8n)-1n:typeof e=="number"&&(a=BigInt(Number.MAX_SAFE_INTEGER));const f=typeof a=="bigint"&&r?-a-1n:0;if(a&&i>a||i<f){const l=typeof e=="bigint"?"n":"";throw new Ds({max:a?`${a}${l}`:void 0,min:`${f}${l}`,signed:r,size:n,value:`${e}${l}`})}const u=`0x${(r&&i<0?(1n<<BigInt(n*8))+BigInt(i):i).toString(16)}`;return n?St(u,{size:n}):u}const Ws=new TextEncoder;function Vs(e,t={}){const r=Ws.encode(e);return Ze(r,t)}const Ks=new TextEncoder;function _i(e,t={}){return typeof e=="number"||typeof e=="bigint"?Js(e,t):typeof e=="boolean"?Ys(e,t):qt(e)?st(e,t):xi(e,t)}function Ys(e,t={}){const r=new Uint8Array(1);return r[0]=Number(e),typeof t.size=="number"?(It(r,{size:t.size}),St(r,{size:t.size})):r}const Ne={zero:48,nine:57,A:65,F:70,a:97,f:102};function In(e){if(e>=Ne.zero&&e<=Ne.nine)return e-Ne.zero;if(e>=Ne.A&&e<=Ne.F)return e-(Ne.A-10);if(e>=Ne.a&&e<=Ne.f)return e-(Ne.a-10)}function st(e,t={}){let r=e;t.size&&(It(r,{size:t.size}),r=St(r,{dir:"right",size:t.size}));let n=r.slice(2);n.length%2&&(n=`0${n}`);const i=n.length/2,a=new Uint8Array(i);for(let f=0,u=0;f<i;f++){const l=In(n.charCodeAt(u++)),y=In(n.charCodeAt(u++));if(l===void 0||y===void 0)throw new Q(`Invalid byte sequence ("${n[u-2]}${n[u-1]}" in "${n}").`);a[f]=l*16+y}return a}function Js(e,t){const r=wi(e,t);return st(r)}function xi(e,t={}){const r=Ks.encode(e);return typeof t.size=="number"?(It(r,{size:t.size}),St(r,{dir:"right",size:t.size})):r}function It(e,{size:t}){if(xt(e)>t)throw new $s({givenSize:xt(e),maxSize:t})}function gt(e,t={}){const{signed:r}=t;t.size&&It(e,{size:t.size});const n=BigInt(e);if(!r)return n;const i=(e.length-2)/2,a=(1n<<BigInt(i)*8n-1n)-1n;return n<=a?n:n-BigInt(`0x${"f".padStart(i*2,"f")}`)-1n}function or(e,t={}){return Number(gt(e,t))}function fn(e,t){return({exclude:r,format:n})=>({exclude:r,format:i=>{const a=t(i);if(r)for(const f of r)delete a[f];return{...a,...n(i)}},type:e})}const vi={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function un(e){const t={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?or(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?or(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?vi[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=Qs(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 Xs=fn("transaction",un);function Qs(e){return e.map(t=>({contractAddress:t.address,chainId:Number(t.chainId),nonce:Number(t.nonce),r:t.r,s:t.s,yParity:Number(t.yParity)}))}function Zs(e){var r;const t=(r=e.transactions)==null?void 0:r.map(n=>typeof n=="string"?n:un(n));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 eo=fn("block",Zs);function to(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}:{}}}const ro={"0x0":"reverted","0x1":"success"};function no(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=>to(r)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?or(e.transactionIndex):null,status:e.status?ro[e.status]:null,type:e.type?vi[e.type]||e.type:null};return e.blobGasPrice&&(t.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(t.blobGasUsed=BigInt(e.blobGasUsed)),t}const io=fn("transactionReceipt",no),cn=2n**256n-1n;function Wt(e){return`0x${e.reduce((t,r)=>t+r.replace("0x",""),"")}`}class An extends Q{constructor({offset:t}){super(`Offset \`${t}\` cannot be negative.`,{name:"NegativeOffsetError"})}}class so extends Q{constructor({length:t,position:r}){super(`Position \`${r}\` is out of bounds (\`0 < position < ${t}\`).`,{name:"PositionOutOfBoundsError"})}}class oo extends Q{constructor({count:t,limit:r}){super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${t}\`).`,{name:"RecursiveReadLimitExceededError"})}}const ao={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new oo({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new so({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new An({offset:e});const t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new An({offset:e});const t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){const r=t??this.position;return this.assertPosition(r+e-1),this.bytes.subarray(r,r+e)},inspectUint8(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){const t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){const t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){const t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,e&255),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();const r=this.inspectBytes(e);return this.position+=t??e,r},readUint8(){this.assertReadLimit(),this._touch();const e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();const e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();const e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();const e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){const t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}};function Ei(e,{recursiveReadLimit:t=8192}={}){const r=Object.create(ao);return r.bytes=e,r.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),r.positionReadCount=new Map,r.recursiveReadLimit=t,r}function ot(e,t="hex"){const r=Bi(e),n=Ei(new Uint8Array(r.length));return r.encode(n),t==="hex"?Ze(n.bytes):n.bytes}function Bi(e){return Array.isArray(e)?fo(e.map(t=>Bi(t))):uo(e)}function fo(e){const t=e.reduce((i,a)=>i+a.length,0),r=Si(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:a}of e)a(i)}}}function uo(e){const t=typeof e=="string"?st(e):e,r=Si(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 Si(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 Q("Length is too large.")}const co={ether:-9,wei:9};function lo(e,t){let r=e.toString();const n=r.startsWith("-");n&&(r=r.slice(1)),r=r.padStart(t,"0");let[i,a]=[r.slice(0,r.length-t),r.slice(r.length-t)];return a=a.replace(/(0+)$/,""),`${n?"-":""}${i||"0"}${a?`.${a}`:""}`}function Jr(e,t="wei"){return lo(e,co[t])}function ho(e){const t=Object.entries(e).map(([n,i])=>i===void 0||i===!1?null:[n,i]).filter(Boolean),r=t.reduce((n,[i])=>Math.max(n,i.length),0);return t.map(([n,i])=>` ${`${n}:`.padEnd(r+1)} ${i}`).join(`
3
+ `)}class po extends Q{constructor({v:t}){super(`Invalid \`v\` value "${t}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}}class bo extends Q{constructor({transaction:t}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",ho(t),"}","","To infer the type, either provide:","- a `type` to the Transaction, or","- an EIP-1559 Transaction with `maxFeePerGas`, or","- an EIP-2930 Transaction with `gasPrice` & `accessList`, or","- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or","- an EIP-7702 Transaction with `authorizationList`, or","- a Legacy Transaction with `gasPrice`"],name:"InvalidSerializableTransactionError"})}}class yo extends Q{constructor({storageKey:t}){super(`Size for storage key "${t}" is invalid. Expected 32 bytes. Got ${Math.floor((t.length-2)/2)} bytes.`,{name:"InvalidStorageKeySizeError"})}}function Ii(e){const{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),n=typeof e.blobs[0]=="string"?e.blobs.map(a=>st(a)):e.blobs,i=[];for(const a of n)i.push(Uint8Array.from(t.blobToKzgCommitment(a)));return r==="bytes"?i:i.map(a=>Ze(a))}function Ai(e){const{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),n=typeof e.blobs[0]=="string"?e.blobs.map(f=>st(f)):e.blobs,i=typeof e.commitments[0]=="string"?e.commitments.map(f=>st(f)):e.commitments,a=[];for(let f=0;f<n.length;f++){const u=n[f],l=i[f];a.push(Uint8Array.from(t.computeBlobKzgProof(u,l)))}return r==="bytes"?a:a.map(f=>Ze(f))}function Rn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function go(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function ln(e,...t){if(!go(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function ar(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 Ri(e,t){ln(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const mo=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),Pr=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Oe=(e,t)=>e<<32-t|e>>>t,Tn=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,wo=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;function Pn(e){for(let t=0;t<e.length;t++)e[t]=wo(e[t])}function _o(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function hn(e){return typeof e=="string"&&(e=_o(e)),ln(e),e}let Ti=class{clone(){return this._cloneInto()}};function Pi(e){const t=n=>e().update(hn(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function xo(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);const i=BigInt(32),a=BigInt(4294967295),f=Number(r>>i&a),u=Number(r&a),l=n?4:0,y=n?0:4;e.setUint32(t+l,f,n),e.setUint32(t+y,u,n)}const vo=(e,t,r)=>e&t^~e&r,Eo=(e,t,r)=>e&t^e&r^t&r;class Bo extends Ti{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=Pr(this.buffer)}update(t){ar(this);const{view:r,buffer:n,blockLen:i}=this;t=hn(t);const a=t.length;for(let f=0;f<a;){const u=Math.min(i-this.pos,a-f);if(u===i){const l=Pr(t);for(;i<=a-f;f+=i)this.process(l,f);continue}n.set(t.subarray(f,f+u),this.pos),this.pos+=u,f+=u,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){ar(this),Ri(t,this),this.finished=!0;const{buffer:r,view:n,blockLen:i,isLE:a}=this;let{pos:f}=this;r[f++]=128,this.buffer.subarray(f).fill(0),this.padOffset>i-f&&(this.process(n,0),f=0);for(let w=f;w<i;w++)r[w]=0;xo(n,i-8,BigInt(this.length*8),a),this.process(n,0);const u=Pr(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const y=l/4,g=this.get();if(y>g.length)throw new Error("_sha2: outputLen bigger than state");for(let w=0;w<y;w++)u.setUint32(4*w,g[w],a)}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:a,destroyed:f,pos:u}=this;return t.length=i,t.pos=u,t.finished=a,t.destroyed=f,i%r&&t.buffer.set(n),t}}const So=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]),Ye=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Je=new Uint32Array(64);class Io extends Bo{constructor(){super(64,32,8,!1),this.A=Ye[0]|0,this.B=Ye[1]|0,this.C=Ye[2]|0,this.D=Ye[3]|0,this.E=Ye[4]|0,this.F=Ye[5]|0,this.G=Ye[6]|0,this.H=Ye[7]|0}get(){const{A:t,B:r,C:n,D:i,E:a,F:f,G:u,H:l}=this;return[t,r,n,i,a,f,u,l]}set(t,r,n,i,a,f,u,l){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=a|0,this.F=f|0,this.G=u|0,this.H=l|0}process(t,r){for(let w=0;w<16;w++,r+=4)Je[w]=t.getUint32(r,!1);for(let w=16;w<64;w++){const E=Je[w-15],I=Je[w-2],v=Oe(E,7)^Oe(E,18)^E>>>3,P=Oe(I,17)^Oe(I,19)^I>>>10;Je[w]=P+Je[w-7]+v+Je[w-16]|0}let{A:n,B:i,C:a,D:f,E:u,F:l,G:y,H:g}=this;for(let w=0;w<64;w++){const E=Oe(u,6)^Oe(u,11)^Oe(u,25),I=g+E+vo(u,l,y)+So[w]+Je[w]|0,P=(Oe(n,2)^Oe(n,13)^Oe(n,22))+Eo(n,i,a)|0;g=y,y=l,l=u,u=f+I|0,f=a,a=i,i=n,n=I+P|0}n=n+this.A|0,i=i+this.B|0,a=a+this.C|0,f=f+this.D|0,u=u+this.E|0,l=l+this.F|0,y=y+this.G|0,g=g+this.H|0,this.set(n,i,a,f,u,l,y,g)}roundClean(){Je.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Ao=Pi(()=>new Io);function Ro(e,t){return Ao(qt(e,{strict:!1})?_i(e):e)}function To(e){const{commitment:t,version:r=1}=e,n=e.to??(typeof t=="string"?"hex":"bytes"),i=Ro(t);return i.set([r],0),n==="bytes"?i:Ze(i)}function Po(e){const{commitments:t,version:r}=e,n=e.to??(typeof t[0]=="string"?"hex":"bytes"),i=[];for(const a of t)i.push(To({commitment:a,to:n,version:r}));return i}const kn=6,ki=32,dn=4096,Ci=ki*dn,Cn=Ci*kn-1-1*dn*kn,Li=1;class ko extends Q{constructor({maxSize:t,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${t} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}}class Oi extends Q{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}class Co extends Q{constructor({hash:t,size:r}){super(`Versioned hash "${t}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${r}`],name:"InvalidVersionedHashSizeError"})}}class Lo extends Q{constructor({hash:t,version:r}){super(`Versioned hash "${t}" version is invalid.`,{metaMessages:[`Expected: ${Li}`,`Received: ${r}`],name:"InvalidVersionedHashVersionError"})}}function Oo(e){const t=e.to??(typeof e.data=="string"?"hex":"bytes"),r=typeof e.data=="string"?st(e.data):e.data,n=xt(r);if(!n)throw new Oi;if(n>Cn)throw new ko({maxSize:Cn,size:n});const i=[];let a=!0,f=0;for(;a;){const u=Ei(new Uint8Array(Ci));let l=0;for(;l<dn;){const y=r.slice(f,f+(ki-1));if(u.pushByte(0),u.pushBytes(y),y.length<31){u.pushByte(128),a=!1;break}l++,f+=31}i.push(u)}return t==="bytes"?i.map(u=>u.bytes):i.map(u=>Ze(u.bytes))}function Fo(e){const{data:t,kzg:r,to:n}=e,i=e.blobs??Oo({data:t,to:n}),a=e.commitments??Ii({blobs:i,kzg:r,to:n}),f=e.proofs??Ai({blobs:i,commitments:a,kzg:r,to:n}),u=[];for(let l=0;l<i.length;l++)u.push({blob:i[l],commitment:a[l],proof:f[l]});return u}function Uo(e){if(!e||e.length===0)return[];const t=[];for(const r of e){const{contractAddress:n,chainId:i,nonce:a,...f}=r;t.push([q(i),n,a?q(a):"0x",...Vt({},f)])}return t}class at extends Q{constructor({address:t}){super(`Address "${t}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class br extends Q{constructor({chainId:t}){super(typeof t=="number"?`Chain ID "${t}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}class yr extends Q{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${Jr(r)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:t,name:"FeeCapTooHighError"})}}Object.defineProperty(yr,"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 Fi extends Q{constructor({cause:t,maxPriorityFeePerGas:r,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${r?` = ${Jr(r)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${Jr(n)} gwei`:""}).`].join(`
4
+ `),{cause:t,name:"TipAboveFeeCapError"})}}Object.defineProperty(Fi,"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 Ui extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){const r=super.get(t);return super.has(t)&&r!==void 0&&(this.delete(t),super.set(t,r)),r}set(t,r){if(super.set(t,r),this.maxSize&&this.size>this.maxSize){const n=this.keys().next().value;n&&this.delete(n)}return this}}const er=BigInt(2**32-1),Ln=BigInt(32);function Mo(e,t=!1){return t?{h:Number(e&er),l:Number(e>>Ln&er)}:{h:Number(e>>Ln&er)|0,l:Number(e&er)|0}}function No(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:a,l:f}=Mo(e[i],t);[r[i],n[i]]=[a,f]}return[r,n]}const Do=(e,t,r)=>e<<r|t>>>32-r,$o=(e,t,r)=>t<<r|e>>>32-r,Ho=(e,t,r)=>t<<r-32|e>>>64-r,zo=(e,t,r)=>e<<r-32|t>>>64-r,Mi=[],Ni=[],Di=[],jo=BigInt(0),Ct=BigInt(1),Go=BigInt(2),qo=BigInt(7),Wo=BigInt(256),Vo=BigInt(113);for(let e=0,t=Ct,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],Mi.push(2*(5*n+r)),Ni.push((e+1)*(e+2)/2%64);let i=jo;for(let a=0;a<7;a++)t=(t<<Ct^(t>>qo)*Vo)%Wo,t&Go&&(i^=Ct<<(Ct<<BigInt(a))-Ct);Di.push(i)}const[Ko,Yo]=No(Di,!0),On=(e,t,r)=>r>32?Ho(e,t,r):Do(e,t,r),Fn=(e,t,r)=>r>32?zo(e,t,r):$o(e,t,r);function Jo(e,t=24){const r=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let f=0;f<10;f++)r[f]=e[f]^e[f+10]^e[f+20]^e[f+30]^e[f+40];for(let f=0;f<10;f+=2){const u=(f+8)%10,l=(f+2)%10,y=r[l],g=r[l+1],w=On(y,g,1)^r[u],E=Fn(y,g,1)^r[u+1];for(let I=0;I<50;I+=10)e[f+I]^=w,e[f+I+1]^=E}let i=e[2],a=e[3];for(let f=0;f<24;f++){const u=Ni[f],l=On(i,a,u),y=Fn(i,a,u),g=Mi[f];i=e[g],a=e[g+1],e[g]=l,e[g+1]=y}for(let f=0;f<50;f+=10){for(let u=0;u<10;u++)r[u]=e[f+u];for(let u=0;u<10;u++)e[f+u]^=~r[(u+2)%10]&r[(u+4)%10]}e[0]^=Ko[n],e[1]^=Yo[n]}r.fill(0)}class pn extends Ti{constructor(t,r,n,i=!1,a=24){if(super(),this.blockLen=t,this.suffix=r,this.outputLen=n,this.enableXOF=i,this.rounds=a,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Rn(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=mo(this.state)}keccak(){Tn||Pn(this.state32),Jo(this.state32,this.rounds),Tn||Pn(this.state32),this.posOut=0,this.pos=0}update(t){ar(this);const{blockLen:r,state:n}=this;t=hn(t);const i=t.length;for(let a=0;a<i;){const f=Math.min(r-this.pos,i-a);for(let u=0;u<f;u++)n[this.pos++]^=t[a++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:r,pos:n,blockLen:i}=this;t[n]^=r,r&128&&n===i-1&&this.keccak(),t[i-1]^=128,this.keccak()}writeInto(t){ar(this,!1),ln(t),this.finish();const r=this.state,{blockLen:n}=this;for(let i=0,a=t.length;i<a;){this.posOut>=n&&this.keccak();const f=Math.min(n-this.posOut,a-i);t.set(r.subarray(this.posOut,this.posOut+f),i),this.posOut+=f,i+=f}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Rn(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Ri(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:r,suffix:n,outputLen:i,rounds:a,enableXOF:f}=this;return t||(t=new pn(r,n,i,f,a)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=n,t.outputLen=i,t.enableXOF=f,t.destroyed=this.destroyed,t}}const Xo=(e,t,r)=>Pi(()=>new pn(t,e,r)),Qo=Xo(1,136,256/8);function Zo(e,t){return Qo(qt(e,{strict:!1})?_i(e):e)}const kr=new Ui(8192);function ea(e,t){if(kr.has(`${e}.${t}`))return kr.get(`${e}.${t}`);const r=e.substring(2).toLowerCase(),n=Zo(xi(r)),i=r.split("");for(let f=0;f<40;f+=2)n[f>>1]>>4>=8&&i[f]&&(i[f]=i[f].toUpperCase()),(n[f>>1]&15)>=8&&i[f+1]&&(i[f+1]=i[f+1].toUpperCase());const a=`0x${i.join("")}`;return kr.set(`${e}.${t}`,a),a}const ta=/^0x[a-fA-F0-9]{40}$/,Cr=new Ui(8192);function ft(e,t){const{strict:r=!0}=t??{},n=`${e}.${r}`;if(Cr.has(n))return Cr.get(n);const i=ta.test(e)?e.toLowerCase()===e?!0:r?ea(e)===e:!0:!1;return Cr.set(n,i),i}function ra(e,t,r,{strict:n}={}){return qt(e,{strict:!1})?ia(e,t,r,{strict:n}):na(e,t,r,{strict:n})}function $i(e,t,r){if(xt(e)!==r-t)throw new Hs({offset:r,position:"end",size:xt(e)})}function na(e,t,r,{strict:n}={}){const i=e.slice(t,r);return n&&$i(i,t,r),i}function ia(e,t,r,{strict:n}={}){const i=`0x${e.replace("0x","").slice(t*2,r*2)}`;return n&&$i(i,t,r),i}function sa(e){const{authorizationList:t}=e;if(t)for(const r of t){const{contractAddress:n,chainId:i}=r;if(!ft(n))throw new at({address:n});if(i<=0)throw new br({chainId:i})}bn(e)}function oa(e){const{blobVersionedHashes:t}=e;if(t){if(t.length===0)throw new Oi;for(const r of t){const n=xt(r),i=or(ra(r,0,1));if(n!==32)throw new Co({hash:r,size:n});if(i!==Li)throw new Lo({hash:r,version:i})}}bn(e)}function bn(e){const{chainId:t,maxPriorityFeePerGas:r,maxFeePerGas:n,to:i}=e;if(t<=0)throw new br({chainId:t});if(i&&!ft(i))throw new at({address:i});if(n&&n>cn)throw new yr({maxFeePerGas:n});if(r&&n&&r>n)throw new Fi({maxFeePerGas:n,maxPriorityFeePerGas:r})}function aa(e){const{chainId:t,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:i,to:a}=e;if(t<=0)throw new br({chainId:t});if(a&&!ft(a))throw new at({address:a});if(r||i)throw new Q("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(n&&n>cn)throw new yr({maxFeePerGas:n})}function fa(e){const{chainId:t,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:i,to:a}=e;if(a&&!ft(a))throw new at({address:a});if(typeof t<"u"&&t<=0)throw new br({chainId:t});if(r||i)throw new Q("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(n&&n>cn)throw new yr({maxFeePerGas:n})}function ua(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 bo({transaction:e})}function gr(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 a=0;a<i.length;a++)if(i[a].length-2!==64)throw new yo({storageKey:i[a]});if(!ft(n,{strict:!1}))throw new at({address:n});t.push([n,i])}return t}function ca(e,t){const r=ua(e);return r==="eip1559"?da(e,t):r==="eip2930"?pa(e,t):r==="eip4844"?ha(e,t):r==="eip7702"?la(e,t):ba(e,t)}function la(e,t){const{authorizationList:r,chainId:n,gas:i,nonce:a,to:f,value:u,maxFeePerGas:l,maxPriorityFeePerGas:y,accessList:g,data:w}=e;sa(e);const E=gr(g),I=Uo(r);return Wt(["0x04",ot([q(n),a?q(a):"0x",y?q(y):"0x",l?q(l):"0x",i?q(i):"0x",f??"0x",u?q(u):"0x",w??"0x",E,I,...Vt(e,t)])])}function ha(e,t){const{chainId:r,gas:n,nonce:i,to:a,value:f,maxFeePerBlobGas:u,maxFeePerGas:l,maxPriorityFeePerGas:y,accessList:g,data:w}=e;oa(e);let E=e.blobVersionedHashes,I=e.sidecars;if(e.blobs&&(typeof E>"u"||typeof I>"u")){const O=typeof e.blobs[0]=="string"?e.blobs:e.blobs.map(S=>Ze(S)),L=e.kzg,U=Ii({blobs:O,kzg:L});if(typeof E>"u"&&(E=Po({commitments:U})),typeof I>"u"){const S=Ai({blobs:O,commitments:U,kzg:L});I=Fo({blobs:O,commitments:U,proofs:S})}}const v=gr(g),P=[q(r),i?q(i):"0x",y?q(y):"0x",l?q(l):"0x",n?q(n):"0x",a??"0x",f?q(f):"0x",w??"0x",v,u?q(u):"0x",E??[],...Vt(e,t)],T=[],k=[],F=[];if(I)for(let O=0;O<I.length;O++){const{blob:L,commitment:U,proof:S}=I[O];T.push(L),k.push(U),F.push(S)}return Wt(["0x03",ot(I?[P,T,k,F]:P)])}function da(e,t){const{chainId:r,gas:n,nonce:i,to:a,value:f,maxFeePerGas:u,maxPriorityFeePerGas:l,accessList:y,data:g}=e;bn(e);const w=gr(y),E=[q(r),i?q(i):"0x",l?q(l):"0x",u?q(u):"0x",n?q(n):"0x",a??"0x",f?q(f):"0x",g??"0x",w,...Vt(e,t)];return Wt(["0x02",ot(E)])}function pa(e,t){const{chainId:r,gas:n,data:i,nonce:a,to:f,value:u,accessList:l,gasPrice:y}=e;aa(e);const g=gr(l),w=[q(r),a?q(a):"0x",y?q(y):"0x",n?q(n):"0x",f??"0x",u?q(u):"0x",i??"0x",g,...Vt(e,t)];return Wt(["0x01",ot(w)])}function ba(e,t){const{chainId:r=0,gas:n,data:i,nonce:a,to:f,value:u,gasPrice:l}=e;fa(e);let y=[a?q(a):"0x",l?q(l):"0x",n?q(n):"0x",f??"0x",u?q(u):"0x",i??"0x"];if(t){const g=(()=>{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 I=27n+(t.v===27n?0n:1n);if(t.v!==I)throw new po({v:t.v});return I})(),w=sr(t.r),E=sr(t.s);y=[...y,q(g),w==="0x00"?"0x":w,E==="0x00"?"0x":E]}else r>0&&(y=[...y,q(r),"0x","0x"]);return ot(y)}function Vt(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 a=sr(r.r),f=sr(r.s);return[typeof i=="number"?i?q(1):"0x":n===0n?"0x":n===1n?q(1):n===27n?"0x":q(1),a==="0x00"?"0x":a,f==="0x00"?"0x":f]}const ya={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}},ga={block:eo({format(e){var r;return{transactions:(r=e.transactions)==null?void 0:r.map(n=>{if(typeof n=="string")return n;const i=un(n);return i.typeHex==="0x7e"&&(i.isSystemTx=n.isSystemTx,i.mint=n.mint?gt(n.mint):void 0,i.sourceHash=n.sourceHash,i.type="deposit"),i}),stateRoot:e.stateRoot}}}),transaction:Xs({format(e){const t={};return e.type==="0x7e"&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?gt(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:io({format(e){return{l1GasPrice:e.l1GasPrice?gt(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?gt(e.l1GasUsed):null,l1Fee:e.l1Fee?gt(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null}}})};function ma(e,t){return xa(e)?_a(e):ca(e,t)}const wa={transaction:ma};function _a(e){va(e);const{sourceHash:t,data:r,from:n,gas:i,isSystemTx:a,mint:f,to:u,value:l}=e,y=[t,n,u??"0x",f?q(f):"0x",l?q(l):"0x",i?q(i):"0x",a?"0x1":"0x",r??"0x"];return Wt(["0x7e",ot(y)])}function xa(e){return e.type==="deposit"||typeof e.sourceHash<"u"}function va(e){const{from:t,to:r}=e;if(t&&!ft(t))throw new at({address:t});if(r&&!ft(r))throw new at({address:r})}const Un={contracts:ya,formatters:ga,serializers:wa},Ea=Gt({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}}}),Ba=Gt({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}),Lt=11155111,Sa=Gt({...Un,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:{...Un.contracts,disputeGameFactory:{[Lt]:{address:"0xd6E6dBf4F7EA0ac412fD8b65ED297e64BB7a06E1"}},l2OutputOracle:{[Lt]:{address:"0x84457ca9D0163FbC4bbfe4Dfbb20ba46e48DF254"}},portal:{[Lt]:{address:"0x49f53e41452c74589e85ca1677426ba426459e85",blockCreated:4446677}},l1StandardBridge:{[Lt]:{address:"0xfd0Bf71F60660E2f608ed56e1659C450eB113120",blockCreated:4446677}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:1059647}},testnet:!0,sourceId:Lt}),Ia=Gt({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://cloudflare-eth.com"]}},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}}}),Aa=Gt({id:11155111,name:"Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc2.sepolia.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});function Xr(e){return typeof e=="string"&&(e=Buffer.from(e,"hex")),e.length===32?e:e.subarray(1,33)}function bt(e,t){if(!e)throw new Error(t)}function Ra(e){return Buffer.concat([Uint8Array.from([192]),Ta(e)])}function Ta(e){const t=Sn.encodingLength(e.length),r=Buffer.allocUnsafe(t);return Sn.encode(e.length,r),Buffer.concat([r,e])}function Pa(e,t){if(e.compare(t)>0){const r=e;e=t,t=r}return[e,t]}const Ot=e=>e.length===64?e:e.slice(2),ka=e=>{if(!e)return!1;try{const t=Buffer.from(e,"hex");return _t.isPoint(t)}catch{return!1}},Ca={ethereum:Ia,ethereum_arbitrum:Ea,ethereum_sepolia:Aa,arbitrum_sepolia:Ba,ethereum_localnet:J.EthereumLocalnet,arbitrum_localnet:J.ArbitrumLocalnet,base_sepolia:Sa},La=async(e,t)=>{var n;const r=Ca[e];if(r)try{if(r.id===((n=t.chain)==null?void 0:n.id))return C.Ok({message:"Already on the network",walletClient:t});await t.switchChain({id:r.id});const i=He.createWalletClient({account:t.account,chain:r,transport:He.custom(window.ethereum)});return C.Ok({message:"Switched chain",walletClient:i})}catch(i){if(Oa(i))try{await t.addChain({chain:r});const a=He.createWalletClient({account:t.account,chain:r,transport:He.custom(window.ethereum)});return C.Ok({message:"Added network",walletClient:a})}catch{return C.Err("Failed to add network")}else return C.Err("Failed to switch network")}else return C.Err("Chain not supported")},Oa=e=>typeof e=="object"&&e!==null&&"code"in e&&e.code===4902;var se=(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))(se||{}),re=(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))(re||{});const Hi=(e,t,r)=>{const n=fr(e.source_swap,t),i=fr(e.destination_swap,r);if(n===re.Redeemed)return se.CounterPartyRedeemed;if(n===re.RedeemDetected)return se.CounterPartyRedeemDetected;if(i===re.Redeemed)return se.Redeemed;if(i===re.RedeemDetected)return se.RedeemDetected;if(n===re.Refunded)return se.Refunded;if(n===re.RefundDetected)return se.RefundDetected;if(i===re.Refunded)return se.CounterPartyRefunded;if(i===re.RefundDetected)return se.CounterPartyRefundDetected;if(i===re.Expired)return se.CounterPartySwapExpired;if(n===re.Expired)return se.Expired;const a=Number(e.create_order.additional_data.deadline);return i===re.Initiated?se.CounterPartyInitiated:i===re.InitiateDetected?se.CounterPartyInitiateDetected:Mn(a,12)?se.DeadLineExceeded:n===re.Initiated?se.Initiated:Mn(a,1)?se.DeadLineExceeded:n===re.InitiateDetected?se.InitiateDetected:se.Matched},fr=(e,t)=>{if(e.redeem_tx_hash)return Number(e.redeem_block_number)?re.Redeemed:re.RedeemDetected;if(e.refund_tx_hash)return Number(e.refund_block_number)?re.Refunded:re.RefundDetected;if(Number(e.initiate_block_number)){const r=Number(e.initiate_block_number)+e.timelock;if(t>r)return re.Expired}return e.initiate_tx_hash?Number(e.initiate_block_number)?re.Initiated:re.InitiateDetected:re.Idle},zi=(e,t,r)=>{switch(Hi(e,t,r)){case se.Matched:return ye.Initiate;case se.CounterPartyInitiated:case se.CounterPartyInitiateDetected:return ye.Redeem;case se.Expired:return ye.Refund;default:return ye.Idle}},Mn=(e,t=0)=>{const r=Date.now(),n=e*1e3+t*36e5;return r>=n},Fa=[{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"}];class ji{constructor(t,r,n){this.url=new ge.Url("/relayer",r),this.auth=n,this.order=t}async init(t,r){if(!t.account)return C.Err("No account found");if(t.account.address.toLowerCase()!==this.order.source_swap.initiator.toLowerCase())return C.Err("Account address and order initiator mismatch");if(!r){const g=await ge.fetchEVMBlockNumber(t);if(g.error)return C.Err(g.error);r=g.val}if(fr(this.order.source_swap,r)!==re.Idle)return C.Err("Invalid swap status");const{create_order:i,source_swap:a}=this.order;if(!a.amount||!a.redeemer||!i.timelock||!i.secret_hash)return C.Err("Invalid order");const f=ge.with0x(i.secret_hash),u=BigInt(i.timelock),l=ge.with0x(a.redeemer),y=BigInt(a.amount);try{const g=await this.auth.getToken();if(g.error)return C.Err(g.error);const w=He.getContract({address:ge.with0x(this.order.source_swap.asset),abi:Fa,client:t}),E=await w.read.token(),I=await ge.checkAllowanceAndApprove(Number(y),E,this.order.source_swap.asset,t);if(I.error)return C.Err(I.error);const v=await w.read.eip712Domain(),P=await t.signTypedData({account:t.account,domain:{name:v[1],version:v[2],chainId:Number(v[3]),verifyingContract:v[4]},types:{Initiate:[{name:"redeemer",type:"address"},{name:"timelock",type:"uint256"},{name:"amount",type:"uint256"},{name:"secretHash",type:"bytes32"}]},primaryType:"Initiate",message:{redeemer:l,timelock:u,amount:y,secretHash:f}}),T=await C.Fetcher.post(this.url.endpoint("initiate"),{body:JSON.stringify({order_id:i.create_id,signature:P,perform_on:"Source"}),headers:{Authorization:ge.Authorization(g.val),"Content-Type":"application/json"}});return T.error?C.Err(T.error):T.result?C.Ok(T.result):C.Err("Init: No result found")}catch(g){return console.log("init error :",g),C.Err(String(g))}}async redeem(t,r){try{const n=await this.auth.getToken();if(n.error)return C.Err(n.error);const i=await C.Fetcher.post(this.url.endpoint("redeem"),{body:JSON.stringify({order_id:t,secret:C.trim0x(r),perform_on:"Destination"}),headers:{Authorization:ge.Authorization(n.val),"Content-Type":"application/json"}});return i.error?C.Err(i.error):i.result?C.Ok(i.result):C.Err("Redeem: No result found")}catch(n){return C.Err(String(n))}}}const Ua=Buffer.from("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","hex"),Ma=Buffer.from("483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8","hex"),Na=Buffer.concat([Ua,Ma]),Da=Buffer.from("0250929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0","hex"),Nn={failedToCreateInternalPubkey:"failed to create internal pubkey",failedToTweakPubkey:"failed to tweak pubkey"};function $a(){const e=bi.crypto.sha256(Buffer.from("GardenHTLC","utf-8")),t=_t.pointMultiply(Buffer.concat([Buffer.from("04","hex"),Na]),e);if(!t)throw new Error(Nn.failedToCreateInternalPubkey);const r=_t.pointAdd(Da,t);if(!r)throw new Error(Nn.failedToCreateInternalPubkey);return Xr(Buffer.from(r))}const we={secretMismatch:"invalid secret",secretHashLenMismatch:"secret hash should be 32 bytes",pubkeyLenMismatch:"pubkey should be 32 bytes",zeroOrNegativeExpiry:"expiry should be greater than 0",htlcAddressGenerationFailed:"failed to generate htlc address",notFunded:"address not funded",noCounterpartySigs:"counterparty signatures are required",counterPartySigNotFound:e=>"counterparty signature not found for utxo "+e,invalidCounterpartySigForUTXO:e=>"invalid counterparty signature for utxo "+e,htlcNotExpired:e=>`HTLC not expired, need more ${e} blocks`,controlBlockGenerationFailed:"failed to generate control block",invalidLeaf:"invalid leaf"},tr=192;be.initEccLib(_t);class ur{constructor(t,r,n,i,a,f,u,l){this.secretHash=n,this.redeemerPubkey=i,this.initiatorPubkey=a,this.expiry=f,this.signer=t,this.network=u,this.internalPubkey=$a(),this.initiateAmount=r,this.utxoHashes=l}static async from(t,r,n,i,a,f,u){n=n.startsWith("0x")?n.slice(2):n,bt(n.length===64,we.secretHashLenMismatch),bt(i.length===64||i.length===66,`initiator ${we.pubkeyLenMismatch}`),bt(a.length===64||a.length===66,`redeemer ${we.pubkeyLenMismatch}`),bt(f>0,we.zeroOrNegativeExpiry);const l=await t.getNetwork();return new ur(t,r,n,Xr(a).toString("hex"),Xr(i).toString("hex"),f,l,u)}address(){const{address:t}=be.payments.p2tr({internalPubkey:this.internalPubkey,network:this.network,scriptTree:this.leaves()});if(!t)throw new Error(we.htlcAddressGenerationFailed);return t}id(){return this.address()}async _buildRawTx(t,r){const n=new be.Transaction;n.version=2;const i=this.address(),a=await this.signer.getProvider();let f=[];if(this.utxoHashes&&this.utxoHashes.length>0)for(const l of this.utxoHashes){const y=await a.getTransaction(l);for(let g=0;g<y.vout.length;g++){const w=y.vout[g];w.scriptpubkey_address===i&&f.push({txid:y.txid,vout:g,value:w.value,status:{confirmed:!1}})}}else f=await a.getUTXOs(i);const u=f.reduce((l,y)=>l+y.value,0);if(u===0)throw new Error(`${i} ${we.notFunded}`);for(let l=0;l<f.length;l++)n.addInput(Buffer.from(f[l].txid,"hex").reverse(),f[l].vout);return r??(r=await a.suggestFee(i,u,Bn.Urgency.MEDIUM)),n.addOutput(be.address.toOutputScript(t,this.network),u-r),{tx:n,usedUtxos:f}}async buildRawTx(t){return await this._buildRawTx(await this.signer.getAddress(),t)}getOutputScript(){return be.address.toOutputScript(this.address(),this.network)}async init(t){return t??(t=await(await this.signer.getProvider()).suggestFee(await this.signer.getAddress(),this.initiateAmount,Bn.Urgency.MEDIUM)),await this.signer.send(this.address(),this.initiateAmount,t)}async instantRefund(t,r){bt(t.length>0,we.noCounterpartySigs);const{tx:n,usedUtxos:i}=await this.buildRawTx(r);for(const w of i)if(!t.find(E=>E.utxo===w.txid))throw new Error(we.counterPartySigNotFound(w.txid));const a=this.getOutputScript(),f=be.Transaction.SIGHASH_DEFAULT,u=this.leafHash(2),l=i.map(w=>w.value),y=Lr(a,i.length);for(let w=0;w<n.ins.length;w++){const E=n.hashForWitnessV1(w,y,l,f,u);if(!_t.verifySchnorr(E,Buffer.from(this.redeemerPubkey,"hex"),Buffer.from(t[w].sig,"hex")))throw new Error(we.invalidCounterpartySigForUTXO(t[w].utxo));const I=await this.signer.signSchnorr(E),v=Buffer.from(n.ins[w].hash).reverse().toString("hex"),P=t.find(T=>T.utxo===v);if(!P)throw new Error(we.counterPartySigNotFound(v));n.setWitness(w,[Buffer.from(P.sig,"hex"),I,this.instantRefundLeaf(),this.generateControlBlockFor(2)])}return await(await this.signer.getProvider()).broadcast(n.toHex())}async redeem(t,r,n){bt(be.crypto.sha256(Buffer.from(t,"hex")).toString("hex")===this.secretHash,we.secretMismatch);const{tx:i,usedUtxos:a}=await this._buildRawTx(r??await this.signer.getAddress(),n),f=this.leafHash(1),u=a.map(w=>w.value),l=Lr(this.getOutputScript(),a.length),y=be.Transaction.SIGHASH_DEFAULT;for(let w=0;w<i.ins.length;w++){const E=i.hashForWitnessV1(w,l,u,y,f),I=await this.signer.signSchnorr(E);i.setWitness(w,[I,Buffer.from(t,"hex"),this.redeemLeaf(),this.generateControlBlockFor(1)])}return await(await this.signer.getProvider()).broadcast(i.toHex())}async refund(t,r){const{tx:n,usedUtxos:i}=await this._buildRawTx(t??await this.signer.getAddress(),r),[a,f]=await this.canRefund(i);if(!a)throw new Error(we.htlcNotExpired(f));const u=this.leafHash(0),l=i.map(E=>E.value),y=Lr(this.getOutputScript(),i.length),g=be.Transaction.SIGHASH_DEFAULT;for(let E=0;E<n.ins.length;E++){n.ins[E].sequence=this.expiry;const I=n.hashForWitnessV1(E,y,l,g,u),v=await this.signer.signSchnorr(I);n.setWitness(E,[v,this.refundLeaf(),this.generateControlBlockFor(0)])}return await(await this.signer.getProvider()).broadcast(n.toHex())}async canRefund(t){const n=await(await this.signer.getProvider()).getLatestTip();for(const i of t){let a=0;if(i.status.confirmed&&i.status.block_height+this.expiry>n?a=i.status.block_height+this.expiry-n+1:i.status.confirmed||(a=this.expiry+1),a>0)return[!1,a]}return[!0,0]}generateControlBlockFor(t){let r;switch(t){case 1:r=this.redeemLeaf();break;case 0:r=this.refundLeaf();break;case 2:r=this.instantRefundLeaf();break;default:throw new Error(we.invalidLeaf)}const n=be.payments.p2tr({internalPubkey:this.internalPubkey,network:this.network,scriptTree:this.leaves(),redeem:{output:r,redeemVersion:tr}});if(!n.witness)throw new Error(we.controlBlockGenerationFailed);return n.witness[n.witness.length-1]}leafHash(t){let r=this.redeemLeaf();return t===0&&(r=this.refundLeaf()),t===2&&(r=this.instantRefundLeaf()),be.crypto.taggedHash("TapLeaf",Ra(r))}refundLeaf(){return be.script.fromASM(`
5
5
  ${be.script.number.encode(this.expiry).toString("hex")}
6
6
  OP_CHECKSEQUENCEVERIFY
7
7
  OP_DROP
@@ -20,12 +20,12 @@
20
20
  OP_CHECKSIGADD
21
21
  OP_2
22
22
  OP_NUMEQUAL
23
- `.trim().replace(/\s+/g," "))}leaves(){return[{version:tr,output:this.redeemLeaf()},[{version:tr,output:this.refundLeaf()},{version:tr,output:this.instantRefundLeaf()}]]}generateMerkleProofFor(t){const r=this.leafHash(1),n=this.leafHash(2),i=this.leafHash(0);switch(t){case 1:{const a=Ta(i,n);return[be.crypto.taggedHash("TapBranch",Buffer.concat(a))]}case 0:return[n,r];case 2:return[i,r];default:throw new Error(we.invalidLeaf)}}}function Lr(e,t){const r=[];for(let n=0;n<t;n++)r.push(e);return r}class $a{constructor(){this.cache={}}set(t,r,n,i){const a={txHash:n,timeStamp:Date.now(),btcRedeemUTXO:i};this.cache[`${r}_${t.create_order.create_id}`]=a}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 Ha{constructor(t,r){this.url=new ge.Url("/blocknumber/"+r,t)}async fetchBlockNumbers(){console.log("this.url :",this.url.toString());try{const t=await C.Fetcher.get(this.url);return C.Ok(t)}catch(t){return C.Err("Failed to fetch block numbers",t)}}}class za{constructor(t){if(this.eventListeners=new Map,this.getOrderThreshold=20,this.pendingOrdersCount=0,this.useRelay=!0,this.orderBook=new J.Orderbook({url:t.orderbookURl,walletClient:t.wallets.evmWallet,auth:t.auth}),this.quote=t.quote,this.secretManager=t.secretManager,this.wallets=t.wallets,this.orderbookUrl=t.orderbookURl,this.auth=t.auth,this.orderExecutorCache=new $a,!t.wallets.evmWallet.account)throw new Error("Account not found in evmWallet");this.evmAddress=t.wallets.evmWallet.account.address,this.blockNumberFetcher=t.blockNumberFetcher&&new Ha(t.blockNumberFetcher.url,t.blockNumberFetcher.network)}getPendingOrderCount(){return this.pendingOrdersCount}setUseRelay(t){this.useRelay=t}async swap(t){const r=await this.validateAndFillParams(t);if(r.error)return C.Err(r.error);const{sendAddress:n,receiveAddress:i,timelock:a}=r.val,f=await this.orderBook.getOrdersCount(this.evmAddress);if(f.error)return C.Err(f.error);const u=f.val+1,l=this.secretManager.generateSecret(u);if(l.error)return C.Err(l.error);const{strategyId:y,btcAddress:g}=t.additionalData,w={strategy_id:y,...g&&{bitcoin_optional_recipient:g}},E={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:u.toString(),timelock:a,secret_hash:C.trim0x(l.val.secretHash),min_destination_confirmations:t.minDestinationConfirmations??0,additional_data:w},I=await this.quote.getAttestedQuote(E);if(I.error)return C.Err(I.error);const v=await this.orderBook.createOrder(I.val);if(v.error)return C.Err(v.error);const P=await this.pollOrder(v.val);return P.error?C.Err(P.error):C.Ok(P.val)}async validateAndFillParams(t){if(t.fromAsset.chain===t.toAsset.chain&&t.fromAsset.atomicSwapAddress===t.toAsset.atomicSwapAddress)return C.Err("Source and destination assets cannot be the same");if(J.isMainnet(t.fromAsset.chain)&&!J.isMainnet(t.toAsset.chain)||!J.isMainnet(t.fromAsset.chain)&&J.isMainnet(t.toAsset.chain))return C.Err("Both assets should be on the same network (either mainnet or testnet)");if(J.isBitcoin(t.fromAsset.chain)||J.isBitcoin(t.toAsset.chain)){if(!this.wallets.btcWallet)return C.Err("btcWallet is required for bitcoin chain. Please provide btcWallet in the constructor");if(!t.additionalData.btcAddress)return C.Err("btcAddress in additionalData is required for bitcoin chain")}const r=await this.getAddresses(t.fromAsset.chain);if(r.error)return C.Err(r.error);const n=await this.getAddresses(t.toAsset.chain);if(n.error)return C.Err(n.error);const i=this.validateAmount(t.sendAmount);if(i.error)return C.Err(i.error);const a=this.validateAmount(t.receiveAmount);if(a.error)return C.Err(a.error);if(i<a)return C.Err("Send amount should be greater than receive amount");const f=this.getTimelock(t.fromAsset.chain);return f?C.Ok({sendAddress:r.val,receiveAddress:n.val,timelock:t.timelock??f}):C.Err("Unsupported chain for timelock")}async getAddresses(t){var n;switch(J.getBlockchainType(t)){case J.BlockchainType.EVM:return this.wallets.evmWallet.account?C.Ok(this.wallets.evmWallet.account.address):C.Err("EVM Wallet not found");case J.BlockchainType.Bitcoin:{const i=await((n=this.wallets.btcWallet)==null?void 0:n.getPublicKey());return!i||!Pa(i)?C.Err("Invalid btc public key"):C.Ok(Ot(i))}default:return C.Err("Unsupported chain")}}validateAmount(t){if(t==null||t.includes("."))return C.Err("Invalid amount ",t);const r=new Ms(t);return!r.isInteger()||r.isNaN()||r.lt(0)||r.isLessThanOrEqualTo(0)?C.Err("Invalid amount ",t):C.Ok(r)}getTimelock(t){switch(J.getBlockchainType(t)){case J.BlockchainType.EVM:return Yr.evm;case J.BlockchainType.Bitcoin:return Yr.btc;default:return}}async pollOrder(t){let r=await this.orderBook.getOrder(t,!0),n=0;for(;n<this.getOrderThreshold;){if(await ge.sleep(1e3),n++,r.error){if(!r.error.includes("result is undefined"))return C.Err(r.error)}else if(r.val&&r.val.create_order.create_id.toLowerCase()===t.toLowerCase())return C.Ok(r.val);r=await this.orderBook.getOrder(t,!0)}return C.Err(`Order not found, createOrder id: ${t}`)}emit(t,...r){(this.eventListeners.get(t)??[]).forEach(i=>{i(...r)})}async execute(t=5e3){return await this.orderBook.subscribeToOrders(!0,t,async r=>{var i;this.pendingOrdersCount=r.data.length,this.emit("onPendingOrdersChanged",r.data);const n=await((i=this.blockNumberFetcher)==null?void 0:i.fetchBlockNumbers());for(let a=0;a<r.data.length;a++){const f=r.data[a],u=f.source_swap.chain,l=f.destination_swap.chain,y=this.getWallet(u),g=this.getWallet(l);if(y.error||g.error||!y.val||!g.val){this.emit("error",f,"Source or Destination Wallet not found while executing order");return}let w=n==null?void 0:n.val[u],E=n==null?void 0:n.val[l];if(!w||!E){const v=await this.fetchCurrentBlockNumbers(f,{source:y.val,destination:g.val});if(v.error){this.emit("error",f,"Error while fetching CurrentBlockNumbers: "+v.error);return}w=v.val.source,E=v.val.destination}switch(zi(f,w,E)){case ye.Redeem:{const v=this.secretManager.generateSecret(Number(f.create_order.nonce));if(v.error){this.emit("error",f,v.error);return}switch(J.getBlockchainType(f.destination_swap.chain)){case J.BlockchainType.EVM:{await this.evmRedeem(f,v.val.secret);break}case J.BlockchainType.Bitcoin:{await this.btcRedeem(g.val,f,v.val.secret);break}default:this.emit("error",f,"Unsupported chain: "+f.destination_swap.chain)}break}case ye.Refund:{switch(J.getBlockchainType(f.source_swap.chain)){case J.BlockchainType.EVM:{this.emit("error",f,"EVM refund is automatically done by relay service");break}case J.BlockchainType.Bitcoin:{await this.btcRefund(y.val,f);break}default:this.emit("error",f,"Unsupported chain: "+f.source_swap.chain)}break}}}},{per_page:500},!0)}async evmRedeem(t,r){if(this.emit("log",t.create_order.create_id,"executing evm redeem"),this.orderExecutorCache.get(t,ye.Redeem)){this.emit("log",t.create_order.create_id,"already redeemed");return}const a=await new ji(t,this.orderbookUrl,this.auth).redeem(t.create_order.create_id,r);if(a.error){this.emit("error",t,a.error);return}this.emit("success",t,ye.Redeem,a.val),this.orderExecutorCache.set(t,ye.Redeem,a.val)}async btcRedeem(t,r,n){var f;const i=this.orderExecutorCache.get(r,ye.Redeem);let a=!1;if(i)if(i.btcRedeemUTXO&&i.btcRedeemUTXO!==r.destination_swap.initiate_tx_hash)a=!0,this.emit("log",r.create_order.create_id,"rbf btc redeem");else{this.emit("log",r.create_order.create_id,"btcRedeem: already redeemed");return}this.emit("log",r.create_order.create_id,"executing btc redeem");try{const l=await(await ur.from(t,Number(r.destination_swap.amount),r.create_order.secret_hash,Ot(r.destination_swap.initiator),Ot(r.destination_swap.redeemer),r.destination_swap.timelock,a?[r.destination_swap.initiate_tx_hash]:[])).redeem(C.trim0x(n),(f=r.create_order.additional_data)==null?void 0:f.bitcoin_optional_recipient);this.emit("success",r,ye.Redeem,l),this.orderExecutorCache.set(r,ye.Redeem,l,r.destination_swap.initiate_tx_hash)}catch(u){this.emit("error",r,"Failed btc redeem: "+u)}}async btcRefund(t,r){var n;if(!this.orderExecutorCache.get(r,ye.Refund)){this.emit("log",r.create_order.create_id,"executing btc refund");try{const a=await(await ur.from(t,Number(r.source_swap.amount),r.create_order.secret_hash,Ot(r.source_swap.initiator),Ot(r.source_swap.redeemer),r.source_swap.timelock)).refund((n=r.create_order.additional_data)==null?void 0:n.bitcoin_optional_recipient);this.emit("success",r,ye.Refund,a),this.orderExecutorCache.set(r,ye.Refund,a)}catch(i){this.emit("error",r,"Failed btc refund: "+i)}}}getWallet(t){switch(J.getBlockchainType(t)){case J.BlockchainType.EVM:return C.Ok(this.wallets.evmWallet);case J.BlockchainType.Bitcoin:return C.Ok(this.wallets.btcWallet);default:return C.Err("Unsupported chain for wallet")}}on(t,r){const n=this.eventListeners.get(t)??[];n.push(r),this.eventListeners.set(t,n)}off(t,r){const n=this.eventListeners.get(t)??[],i=n.indexOf(r);i!==-1&&n.splice(i,1)}async fetchCurrentBlockNumbers(t,r){if(!r||!r.source||!r.destination)return C.Err("Provide wallets to fetch the current block number");const n=J.isBitcoin(t.source_swap.chain)?await ge.fetchBitcoinBlockNumber(await r.source.getProvider()):await ge.fetchEVMBlockNumber(r.source);if(n.error)return C.Err(n.error);const i=J.isBitcoin(t.destination_swap.chain)?await ge.fetchBitcoinBlockNumber(await r.destination.getProvider()):await ge.fetchEVMBlockNumber(r.destination);return i.error?C.Err(i.error):C.Ok({source:n.val,destination:i.val})}}var Qe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ja(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 Gi={},vt={},Et={};Object.defineProperty(Et,"__esModule",{value:!0});Et.testnet=Et.bitcoin=void 0;Et.bitcoin={messagePrefix:`Bitcoin Signed Message:
23
+ `.trim().replace(/\s+/g," "))}leaves(){return[{version:tr,output:this.redeemLeaf()},[{version:tr,output:this.refundLeaf()},{version:tr,output:this.instantRefundLeaf()}]]}generateMerkleProofFor(t){const r=this.leafHash(1),n=this.leafHash(2),i=this.leafHash(0);switch(t){case 1:{const a=Pa(i,n);return[be.crypto.taggedHash("TapBranch",Buffer.concat(a))]}case 0:return[n,r];case 2:return[i,r];default:throw new Error(we.invalidLeaf)}}}function Lr(e,t){const r=[];for(let n=0;n<t;n++)r.push(e);return r}class Ha{constructor(){this.cache={}}set(t,r,n,i){const a={txHash:n,timeStamp:Date.now(),btcRedeemUTXO:i};this.cache[`${r}_${t.create_order.create_id}`]=a}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 Gi{constructor(t,r){this.url=new ge.Url("/blocknumber/"+r,t)}async fetchBlockNumbers(){console.log("this.url :",this.url.toString());try{const t=await C.Fetcher.get(this.url);return C.Ok(t)}catch(t){return C.Err("Failed to fetch block numbers",t)}}}class za{constructor(t){if(this.eventListeners=new Map,this.getOrderThreshold=20,this.pendingOrdersCount=0,this.useRelay=!0,this.orderBook=new J.Orderbook({url:t.orderbookURl,walletClient:t.wallets.evmWallet,auth:t.auth}),this.quote=t.quote,this.secretManager=t.secretManager,this.wallets=t.wallets,this.orderbookUrl=t.orderbookURl,this.auth=t.auth,this.orderExecutorCache=new Ha,!t.wallets.evmWallet.account)throw new Error("Account not found in evmWallet");this.evmAddress=t.wallets.evmWallet.account.address,this.blockNumberFetcher=t.blockNumberFetcher&&new Gi(t.blockNumberFetcher.url,t.blockNumberFetcher.network)}getPendingOrderCount(){return this.pendingOrdersCount}setUseRelay(t){this.useRelay=t}async swap(t){const r=await this.validateAndFillParams(t);if(r.error)return C.Err(r.error);const{sendAddress:n,receiveAddress:i,timelock:a}=r.val,f=await this.orderBook.getOrdersCount(this.evmAddress);if(f.error)return C.Err(f.error);const u=f.val+1,l=this.secretManager.generateSecret(u);if(l.error)return C.Err(l.error);const{strategyId:y,btcAddress:g}=t.additionalData,w={strategy_id:y,...g&&{bitcoin_optional_recipient:g}},E={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:u.toString(),timelock:a,secret_hash:C.trim0x(l.val.secretHash),min_destination_confirmations:t.minDestinationConfirmations??0,additional_data:w},I=await this.quote.getAttestedQuote(E);if(I.error)return C.Err(I.error);const v=await this.orderBook.createOrder(I.val);if(v.error)return C.Err(v.error);const P=await this.pollOrder(v.val);return P.error?C.Err(P.error):C.Ok(P.val)}async validateAndFillParams(t){if(t.fromAsset.chain===t.toAsset.chain&&t.fromAsset.atomicSwapAddress===t.toAsset.atomicSwapAddress)return C.Err("Source and destination assets cannot be the same");if(J.isMainnet(t.fromAsset.chain)&&!J.isMainnet(t.toAsset.chain)||!J.isMainnet(t.fromAsset.chain)&&J.isMainnet(t.toAsset.chain))return C.Err("Both assets should be on the same network (either mainnet or testnet)");if(J.isBitcoin(t.fromAsset.chain)||J.isBitcoin(t.toAsset.chain)){if(!this.wallets.btcWallet)return C.Err("btcWallet is required for bitcoin chain. Please provide btcWallet in the constructor");if(!t.additionalData.btcAddress)return C.Err("btcAddress in additionalData is required for bitcoin chain")}const r=await this.getAddresses(t.fromAsset.chain);if(r.error)return C.Err(r.error);const n=await this.getAddresses(t.toAsset.chain);if(n.error)return C.Err(n.error);const i=this.validateAmount(t.sendAmount);if(i.error)return C.Err(i.error);const a=this.validateAmount(t.receiveAmount);if(a.error)return C.Err(a.error);if(i<a)return C.Err("Send amount should be greater than receive amount");const f=this.getTimelock(t.fromAsset.chain);return f?C.Ok({sendAddress:r.val,receiveAddress:n.val,timelock:t.timelock??f}):C.Err("Unsupported chain for timelock")}async getAddresses(t){var n;switch(J.getBlockchainType(t)){case J.BlockchainType.EVM:return this.wallets.evmWallet.account?C.Ok(this.wallets.evmWallet.account.address):C.Err("EVM Wallet not found");case J.BlockchainType.Bitcoin:{const i=await((n=this.wallets.btcWallet)==null?void 0:n.getPublicKey());return!i||!ka(i)?C.Err("Invalid btc public key"):C.Ok(Ot(i))}default:return C.Err("Unsupported chain")}}validateAmount(t){if(t==null||t.includes("."))return C.Err("Invalid amount ",t);const r=new Ns(t);return!r.isInteger()||r.isNaN()||r.lt(0)||r.isLessThanOrEqualTo(0)?C.Err("Invalid amount ",t):C.Ok(r)}getTimelock(t){switch(J.getBlockchainType(t)){case J.BlockchainType.EVM:return Yr.evm;case J.BlockchainType.Bitcoin:return Yr.btc;default:return}}async pollOrder(t){let r=await this.orderBook.getOrder(t,!0),n=0;for(;n<this.getOrderThreshold;){if(await ge.sleep(1e3),n++,r.error){if(!r.error.includes("result is undefined"))return C.Err(r.error)}else if(r.val&&r.val.create_order.create_id.toLowerCase()===t.toLowerCase())return C.Ok(r.val);r=await this.orderBook.getOrder(t,!0)}return C.Err(`Order not found, createOrder id: ${t}`)}emit(t,...r){(this.eventListeners.get(t)??[]).forEach(i=>{i(...r)})}async execute(t=5e3){return await this.orderBook.subscribeToOrders(!0,t,async r=>{var i;this.pendingOrdersCount=r.data.length,this.emit("onPendingOrdersChanged",r.data);const n=await((i=this.blockNumberFetcher)==null?void 0:i.fetchBlockNumbers());for(let a=0;a<r.data.length;a++){const f=r.data[a],u=f.source_swap.chain,l=f.destination_swap.chain,y=this.getWallet(u),g=this.getWallet(l);if(y.error||g.error||!y.val||!g.val){this.emit("error",f,"Source or Destination Wallet not found while executing order");return}let w=n==null?void 0:n.val[u],E=n==null?void 0:n.val[l];if(!w||!E){const v=await this.fetchCurrentBlockNumbers(f,{source:y.val,destination:g.val});if(v.error){this.emit("error",f,"Error while fetching CurrentBlockNumbers: "+v.error);return}w=v.val.source,E=v.val.destination}switch(zi(f,w,E)){case ye.Redeem:{const v=this.secretManager.generateSecret(Number(f.create_order.nonce));if(v.error){this.emit("error",f,v.error);return}switch(J.getBlockchainType(f.destination_swap.chain)){case J.BlockchainType.EVM:{await this.evmRedeem(f,v.val.secret);break}case J.BlockchainType.Bitcoin:{await this.btcRedeem(g.val,f,v.val.secret);break}default:this.emit("error",f,"Unsupported chain: "+f.destination_swap.chain)}break}case ye.Refund:{switch(J.getBlockchainType(f.source_swap.chain)){case J.BlockchainType.EVM:{this.emit("error",f,"EVM refund is automatically done by relay service");break}case J.BlockchainType.Bitcoin:{await this.btcRefund(y.val,f);break}default:this.emit("error",f,"Unsupported chain: "+f.source_swap.chain)}break}}}},{per_page:500},!0)}async evmRedeem(t,r){if(this.emit("log",t.create_order.create_id,"executing evm redeem"),this.orderExecutorCache.get(t,ye.Redeem)){this.emit("log",t.create_order.create_id,"already redeemed");return}const a=await new ji(t,this.orderbookUrl,this.auth).redeem(t.create_order.create_id,r);if(a.error){this.emit("error",t,a.error);return}this.emit("success",t,ye.Redeem,a.val),this.orderExecutorCache.set(t,ye.Redeem,a.val)}async btcRedeem(t,r,n){var f;const i=this.orderExecutorCache.get(r,ye.Redeem);let a=!1;if(i)if(i.btcRedeemUTXO&&i.btcRedeemUTXO!==r.destination_swap.initiate_tx_hash)a=!0,this.emit("log",r.create_order.create_id,"rbf btc redeem");else{this.emit("log",r.create_order.create_id,"btcRedeem: already redeemed");return}this.emit("log",r.create_order.create_id,"executing btc redeem");try{const l=await(await ur.from(t,Number(r.destination_swap.amount),r.create_order.secret_hash,Ot(r.destination_swap.initiator),Ot(r.destination_swap.redeemer),r.destination_swap.timelock,a?[r.destination_swap.initiate_tx_hash]:[])).redeem(C.trim0x(n),(f=r.create_order.additional_data)==null?void 0:f.bitcoin_optional_recipient);this.emit("success",r,ye.Redeem,l),this.orderExecutorCache.set(r,ye.Redeem,l,r.destination_swap.initiate_tx_hash)}catch(u){this.emit("error",r,"Failed btc redeem: "+u)}}async btcRefund(t,r){var n;if(!this.orderExecutorCache.get(r,ye.Refund)){this.emit("log",r.create_order.create_id,"executing btc refund");try{const a=await(await ur.from(t,Number(r.source_swap.amount),r.create_order.secret_hash,Ot(r.source_swap.initiator),Ot(r.source_swap.redeemer),r.source_swap.timelock)).refund((n=r.create_order.additional_data)==null?void 0:n.bitcoin_optional_recipient);this.emit("success",r,ye.Refund,a),this.orderExecutorCache.set(r,ye.Refund,a)}catch(i){this.emit("error",r,"Failed btc refund: "+i)}}}getWallet(t){switch(J.getBlockchainType(t)){case J.BlockchainType.EVM:return C.Ok(this.wallets.evmWallet);case J.BlockchainType.Bitcoin:return C.Ok(this.wallets.btcWallet);default:return C.Err("Unsupported chain for wallet")}}on(t,r){const n=this.eventListeners.get(t)??[];n.push(r),this.eventListeners.set(t,n)}off(t,r){const n=this.eventListeners.get(t)??[],i=n.indexOf(r);i!==-1&&n.splice(i,1)}async fetchCurrentBlockNumbers(t,r){if(!r||!r.source||!r.destination)return C.Err("Provide wallets to fetch the current block number");const n=J.isBitcoin(t.source_swap.chain)?await ge.fetchBitcoinBlockNumber(await r.source.getProvider()):await ge.fetchEVMBlockNumber(r.source);if(n.error)return C.Err(n.error);const i=J.isBitcoin(t.destination_swap.chain)?await ge.fetchBitcoinBlockNumber(await r.destination.getProvider()):await ge.fetchEVMBlockNumber(r.destination);return i.error?C.Err(i.error):C.Ok({source:n.val,destination:i.val})}}var Qe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ja(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 qi={},vt={},Et={};Object.defineProperty(Et,"__esModule",{value:!0});Et.testnet=Et.bitcoin=void 0;Et.bitcoin={messagePrefix:`Bitcoin Signed Message:
24
24
  `,bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128};Et.testnet={messagePrefix:`Bitcoin Signed Message:
25
- `,bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};var qi={},zt={Array:function(e){return e!=null&&e.constructor===Array},Boolean:function(e){return typeof e=="boolean"},Function:function(e){return typeof e=="function"},Nil:function(e){return e==null},Number:function(e){return typeof e=="number"},Object:function(e){return typeof e=="object"},String:function(e){return typeof e=="string"},"":function(){return!0}};zt.Null=zt.Nil;for(var Dn in zt)zt[Dn].toJSON=(function(e){return e}).bind(null,Dn);var yn=zt,it=yn;function Wi(e){return e.name||e.toString().match(/function (.*?)\s*\(/)[1]}function gn(e){return it.Nil(e)?"":Wi(e.constructor)}function Ga(e){return it.Function(e)?"":it.String(e)?JSON.stringify(e):e&&it.Object(e)?"":e}function mn(e,t){Error.captureStackTrace&&Error.captureStackTrace(e,t)}function cr(e){return it.Function(e)?e.toJSON?e.toJSON():Wi(e):it.Array(e)?"Array":e&&it.Object(e)?"Object":e!==void 0?e:""}function Vi(e,t,r){var n=Ga(t);return"Expected "+cr(e)+", got"+(r!==""?" "+r:"")+(n!==""?" "+n:"")}function ze(e,t,r){r=r||gn(t),this.message=Vi(e,t,r),mn(this,ze),this.__type=e,this.__value=t,this.__valueTypeName=r}ze.prototype=Object.create(Error.prototype);ze.prototype.constructor=ze;function qa(e,t,r,n,i){var a='" of type ';return t==="key"&&(a='" with key type '),Vi('property "'+cr(r)+a+cr(e),n,i)}function mt(e,t,r,n,i){e?(i=i||gn(n),this.message=qa(e,r,t,n,i)):this.message='Unexpected property "'+t+'"',mn(this,ze),this.__label=r,this.__property=t,this.__type=e,this.__value=n,this.__valueTypeName=i}mt.prototype=Object.create(Error.prototype);mt.prototype.constructor=ze;function Wa(e,t){return new ze(e,{},t)}function Va(e,t,r){return e instanceof mt?(t=t+"."+e.__property,e=new mt(e.__type,t,e.__label,e.__value,e.__valueTypeName)):e instanceof ze&&(e=new mt(e.__type,t,r,e.__value,e.__valueTypeName)),mn(e),e}var Ki={TfTypeError:ze,TfPropertyTypeError:mt,tfCustomError:Wa,tfSubError:Va,tfJSON:cr,getValueTypeName:gn},Or,$n;function Ka(){if($n)return Or;$n=1;var e=yn,t=Ki;function r(S){return Buffer.isBuffer(S)}function n(S){return typeof S=="string"&&/^([0-9a-f]{2})+$/i.test(S)}function i(S,z){var N=S.toJSON();function $(oe){if(!S(oe))return!1;if(oe.length===z)return!0;throw t.tfCustomError(N+"(Length: "+z+")",N+"(Length: "+oe.length+")")}return $.toJSON=function(){return N},$}var a=i.bind(null,e.Array),f=i.bind(null,r),u=i.bind(null,n),l=i.bind(null,e.String);function y(S,z,N){N=N||e.Number;function $(oe,Pe){return N(oe,Pe)&&oe>S&&oe<z}return $.toJSON=function(){return`${N.toJSON()} between [${S}, ${z}]`},$}var g=Math.pow(2,53)-1;function w(S){return typeof S=="number"&&isFinite(S)}function E(S){return S<<24>>24===S}function I(S){return S<<16>>16===S}function v(S){return(S|0)===S}function P(S){return typeof S=="number"&&S>=-g&&S<=g&&Math.floor(S)===S}function T(S){return(S&255)===S}function k(S){return(S&65535)===S}function F(S){return S>>>0===S}function O(S){return typeof S=="number"&&S>=0&&S<=g&&Math.floor(S)===S}var L={ArrayN:a,Buffer:r,BufferN:f,Finite:w,Hex:n,HexN:u,Int8:E,Int16:I,Int32:v,Int53:P,Range:y,StringN:l,UInt8:T,UInt16:k,UInt32:F,UInt53:O};for(var U in L)L[U].toJSON=(function(S){return S}).bind(null,U);return Or=L,Or}var Kt=Ki,ce=yn,De=Kt.tfJSON,Yi=Kt.TfTypeError,Ji=Kt.TfPropertyTypeError,Ft=Kt.tfSubError,Ya=Kt.getValueTypeName,$e={arrayOf:function(t,r){t=Fe(t),r=r||{};function n(i,a){return!ce.Array(i)||ce.Nil(i)||r.minLength!==void 0&&i.length<r.minLength||r.maxLength!==void 0&&i.length>r.maxLength||r.length!==void 0&&i.length!==r.length?!1:i.every(function(f,u){try{return xe(t,f,a)}catch(l){throw Ft(l,u)}})}return n.toJSON=function(){var i="["+De(t)+"]";return r.length!==void 0?i+="{"+r.length+"}":(r.minLength!==void 0||r.maxLength!==void 0)&&(i+="{"+(r.minLength===void 0?0:r.minLength)+","+(r.maxLength===void 0?1/0:r.maxLength)+"}"),i},n},maybe:function e(t){t=Fe(t);function r(n,i){return ce.Nil(n)||t(n,i,e)}return r.toJSON=function(){return"?"+De(t)},r},map:function(t,r){t=Fe(t),r&&(r=Fe(r));function n(i,a){if(!ce.Object(i)||ce.Nil(i))return!1;for(var f in i){try{r&&xe(r,f,a)}catch(l){throw Ft(l,f,"key")}try{var u=i[f];xe(t,u,a)}catch(l){throw Ft(l,f)}}return!0}return r?n.toJSON=function(){return"{"+De(r)+": "+De(t)+"}"}:n.toJSON=function(){return"{"+De(t)+"}"},n},object:function(t){var r={};for(var n in t)r[n]=Fe(t[n]);function i(a,f){if(!ce.Object(a)||ce.Nil(a))return!1;var u;try{for(u in r){var l=r[u],y=a[u];xe(l,y,f)}}catch(g){throw Ft(g,u)}if(f){for(u in a)if(!r[u])throw new Ji(void 0,u)}return!0}return i.toJSON=function(){return De(r)},i},anyOf:function(){var t=[].slice.call(arguments).map(Fe);function r(n,i){return t.some(function(a){try{return xe(a,n,i)}catch{return!1}})}return r.toJSON=function(){return t.map(De).join("|")},r},allOf:function(){var t=[].slice.call(arguments).map(Fe);function r(n,i){return t.every(function(a){try{return xe(a,n,i)}catch{return!1}})}return r.toJSON=function(){return t.map(De).join(" & ")},r},quacksLike:function(t){function r(n){return t===Ya(n)}return r.toJSON=function(){return t},r},tuple:function(){var t=[].slice.call(arguments).map(Fe);function r(n,i){return ce.Nil(n)||ce.Nil(n.length)||i&&n.length!==t.length?!1:t.every(function(a,f){try{return xe(a,n[f],i)}catch(u){throw Ft(u,f)}})}return r.toJSON=function(){return"("+t.map(De).join(", ")+")"},r},value:function(t){function r(n){return n===t}return r.toJSON=function(){return t},r}};$e.oneOf=$e.anyOf;function Fe(e){if(ce.String(e))return e[0]==="?"?$e.maybe(e.slice(1)):ce[e]||$e.quacksLike(e);if(e&&ce.Object(e)){if(ce.Array(e)){if(e.length!==1)throw new TypeError("Expected compile() parameter of type Array of length 1");return $e.arrayOf(e[0])}return $e.object(e)}else if(ce.Function(e))return e;return $e.value(e)}function xe(e,t,r,n){if(ce.Function(e)){if(e(t,r))return!0;throw new Yi(n||e,t)}return xe(Fe(e),t,r)}for(var Xe in ce)xe[Xe]=ce[Xe];for(Xe in $e)xe[Xe]=$e[Xe];var Hn=Ka();for(Xe in Hn)xe[Xe]=Hn[Xe];xe.compile=Fe;xe.TfTypeError=Yi;xe.TfPropertyTypeError=Ji;var Ja=xe;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.maybe=e.Boolean=e.Array=e.Buffer256bit=e.Network=e.typeforce=void 0,e.typeforce=Ja,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})(qi);var Qr={exports:{}},Zr={exports:{}},At={},mr={};mr.byteLength=Za;mr.toByteArray=tf;mr.fromByteArray=sf;var Ue=[],Re=[],Xa=typeof Uint8Array<"u"?Uint8Array:Array,Fr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var yt=0,Qa=Fr.length;yt<Qa;++yt)Ue[yt]=Fr[yt],Re[Fr.charCodeAt(yt)]=yt;Re[45]=62;Re[95]=63;function Xi(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 Za(e){var t=Xi(e),r=t[0],n=t[1];return(r+n)*3/4-n}function ef(e,t,r){return(t+r)*3/4-r}function tf(e){var t,r=Xi(e),n=r[0],i=r[1],a=new Xa(ef(e,n,i)),f=0,u=i>0?n-4:n,l;for(l=0;l<u;l+=4)t=Re[e.charCodeAt(l)]<<18|Re[e.charCodeAt(l+1)]<<12|Re[e.charCodeAt(l+2)]<<6|Re[e.charCodeAt(l+3)],a[f++]=t>>16&255,a[f++]=t>>8&255,a[f++]=t&255;return i===2&&(t=Re[e.charCodeAt(l)]<<2|Re[e.charCodeAt(l+1)]>>4,a[f++]=t&255),i===1&&(t=Re[e.charCodeAt(l)]<<10|Re[e.charCodeAt(l+1)]<<4|Re[e.charCodeAt(l+2)]>>2,a[f++]=t>>8&255,a[f++]=t&255),a}function rf(e){return Ue[e>>18&63]+Ue[e>>12&63]+Ue[e>>6&63]+Ue[e&63]}function nf(e,t,r){for(var n,i=[],a=t;a<r;a+=3)n=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),i.push(rf(n));return i.join("")}function sf(e){for(var t,r=e.length,n=r%3,i=[],a=16383,f=0,u=r-n;f<u;f+=a)i.push(nf(e,f,f+a>u?u:f+a));return n===1?(t=e[r-1],i.push(Ue[t>>2]+Ue[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Ue[t>>10]+Ue[t>>4&63]+Ue[t<<2&63]+"=")),i.join("")}var wn={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */wn.read=function(e,t,r,n,i){var a,f,u=i*8-n-1,l=(1<<u)-1,y=l>>1,g=-7,w=r?i-1:0,E=r?-1:1,I=e[t+w];for(w+=E,a=I&(1<<-g)-1,I>>=-g,g+=u;g>0;a=a*256+e[t+w],w+=E,g-=8);for(f=a&(1<<-g)-1,a>>=-g,g+=n;g>0;f=f*256+e[t+w],w+=E,g-=8);if(a===0)a=1-y;else{if(a===l)return f?NaN:(I?-1:1)*(1/0);f=f+Math.pow(2,n),a=a-y}return(I?-1:1)*f*Math.pow(2,a-n)};wn.write=function(e,t,r,n,i,a){var f,u,l,y=a*8-i-1,g=(1<<y)-1,w=g>>1,E=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,I=n?0:a-1,v=n?1:-1,P=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(u=isNaN(t)?1:0,f=g):(f=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-f))<1&&(f--,l*=2),f+w>=1?t+=E/l:t+=E*Math.pow(2,1-w),t*l>=2&&(f++,l/=2),f+w>=g?(u=0,f=g):f+w>=1?(u=(t*l-1)*Math.pow(2,i),f=f+w):(u=t*Math.pow(2,w-1)*Math.pow(2,i),f=0));i>=8;e[r+I]=u&255,I+=v,u/=256,i-=8);for(f=f<<i|u,y+=i;y>0;e[r+I]=f&255,I+=v,f/=256,y-=8);e[r+I-v]|=P*128};/*!
25
+ `,bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};var Wi={},zt={Array:function(e){return e!=null&&e.constructor===Array},Boolean:function(e){return typeof e=="boolean"},Function:function(e){return typeof e=="function"},Nil:function(e){return e==null},Number:function(e){return typeof e=="number"},Object:function(e){return typeof e=="object"},String:function(e){return typeof e=="string"},"":function(){return!0}};zt.Null=zt.Nil;for(var Dn in zt)zt[Dn].toJSON=(function(e){return e}).bind(null,Dn);var yn=zt,it=yn;function Vi(e){return e.name||e.toString().match(/function (.*?)\s*\(/)[1]}function gn(e){return it.Nil(e)?"":Vi(e.constructor)}function Ga(e){return it.Function(e)?"":it.String(e)?JSON.stringify(e):e&&it.Object(e)?"":e}function mn(e,t){Error.captureStackTrace&&Error.captureStackTrace(e,t)}function cr(e){return it.Function(e)?e.toJSON?e.toJSON():Vi(e):it.Array(e)?"Array":e&&it.Object(e)?"Object":e!==void 0?e:""}function Ki(e,t,r){var n=Ga(t);return"Expected "+cr(e)+", got"+(r!==""?" "+r:"")+(n!==""?" "+n:"")}function ze(e,t,r){r=r||gn(t),this.message=Ki(e,t,r),mn(this,ze),this.__type=e,this.__value=t,this.__valueTypeName=r}ze.prototype=Object.create(Error.prototype);ze.prototype.constructor=ze;function qa(e,t,r,n,i){var a='" of type ';return t==="key"&&(a='" with key type '),Ki('property "'+cr(r)+a+cr(e),n,i)}function mt(e,t,r,n,i){e?(i=i||gn(n),this.message=qa(e,r,t,n,i)):this.message='Unexpected property "'+t+'"',mn(this,ze),this.__label=r,this.__property=t,this.__type=e,this.__value=n,this.__valueTypeName=i}mt.prototype=Object.create(Error.prototype);mt.prototype.constructor=ze;function Wa(e,t){return new ze(e,{},t)}function Va(e,t,r){return e instanceof mt?(t=t+"."+e.__property,e=new mt(e.__type,t,e.__label,e.__value,e.__valueTypeName)):e instanceof ze&&(e=new mt(e.__type,t,r,e.__value,e.__valueTypeName)),mn(e),e}var Yi={TfTypeError:ze,TfPropertyTypeError:mt,tfCustomError:Wa,tfSubError:Va,tfJSON:cr,getValueTypeName:gn},Or,$n;function Ka(){if($n)return Or;$n=1;var e=yn,t=Yi;function r(S){return Buffer.isBuffer(S)}function n(S){return typeof S=="string"&&/^([0-9a-f]{2})+$/i.test(S)}function i(S,z){var N=S.toJSON();function $(oe){if(!S(oe))return!1;if(oe.length===z)return!0;throw t.tfCustomError(N+"(Length: "+z+")",N+"(Length: "+oe.length+")")}return $.toJSON=function(){return N},$}var a=i.bind(null,e.Array),f=i.bind(null,r),u=i.bind(null,n),l=i.bind(null,e.String);function y(S,z,N){N=N||e.Number;function $(oe,Pe){return N(oe,Pe)&&oe>S&&oe<z}return $.toJSON=function(){return`${N.toJSON()} between [${S}, ${z}]`},$}var g=Math.pow(2,53)-1;function w(S){return typeof S=="number"&&isFinite(S)}function E(S){return S<<24>>24===S}function I(S){return S<<16>>16===S}function v(S){return(S|0)===S}function P(S){return typeof S=="number"&&S>=-g&&S<=g&&Math.floor(S)===S}function T(S){return(S&255)===S}function k(S){return(S&65535)===S}function F(S){return S>>>0===S}function O(S){return typeof S=="number"&&S>=0&&S<=g&&Math.floor(S)===S}var L={ArrayN:a,Buffer:r,BufferN:f,Finite:w,Hex:n,HexN:u,Int8:E,Int16:I,Int32:v,Int53:P,Range:y,StringN:l,UInt8:T,UInt16:k,UInt32:F,UInt53:O};for(var U in L)L[U].toJSON=(function(S){return S}).bind(null,U);return Or=L,Or}var Kt=Yi,ce=yn,De=Kt.tfJSON,Ji=Kt.TfTypeError,Xi=Kt.TfPropertyTypeError,Ft=Kt.tfSubError,Ya=Kt.getValueTypeName,$e={arrayOf:function(t,r){t=Fe(t),r=r||{};function n(i,a){return!ce.Array(i)||ce.Nil(i)||r.minLength!==void 0&&i.length<r.minLength||r.maxLength!==void 0&&i.length>r.maxLength||r.length!==void 0&&i.length!==r.length?!1:i.every(function(f,u){try{return xe(t,f,a)}catch(l){throw Ft(l,u)}})}return n.toJSON=function(){var i="["+De(t)+"]";return r.length!==void 0?i+="{"+r.length+"}":(r.minLength!==void 0||r.maxLength!==void 0)&&(i+="{"+(r.minLength===void 0?0:r.minLength)+","+(r.maxLength===void 0?1/0:r.maxLength)+"}"),i},n},maybe:function e(t){t=Fe(t);function r(n,i){return ce.Nil(n)||t(n,i,e)}return r.toJSON=function(){return"?"+De(t)},r},map:function(t,r){t=Fe(t),r&&(r=Fe(r));function n(i,a){if(!ce.Object(i)||ce.Nil(i))return!1;for(var f in i){try{r&&xe(r,f,a)}catch(l){throw Ft(l,f,"key")}try{var u=i[f];xe(t,u,a)}catch(l){throw Ft(l,f)}}return!0}return r?n.toJSON=function(){return"{"+De(r)+": "+De(t)+"}"}:n.toJSON=function(){return"{"+De(t)+"}"},n},object:function(t){var r={};for(var n in t)r[n]=Fe(t[n]);function i(a,f){if(!ce.Object(a)||ce.Nil(a))return!1;var u;try{for(u in r){var l=r[u],y=a[u];xe(l,y,f)}}catch(g){throw Ft(g,u)}if(f){for(u in a)if(!r[u])throw new Xi(void 0,u)}return!0}return i.toJSON=function(){return De(r)},i},anyOf:function(){var t=[].slice.call(arguments).map(Fe);function r(n,i){return t.some(function(a){try{return xe(a,n,i)}catch{return!1}})}return r.toJSON=function(){return t.map(De).join("|")},r},allOf:function(){var t=[].slice.call(arguments).map(Fe);function r(n,i){return t.every(function(a){try{return xe(a,n,i)}catch{return!1}})}return r.toJSON=function(){return t.map(De).join(" & ")},r},quacksLike:function(t){function r(n){return t===Ya(n)}return r.toJSON=function(){return t},r},tuple:function(){var t=[].slice.call(arguments).map(Fe);function r(n,i){return ce.Nil(n)||ce.Nil(n.length)||i&&n.length!==t.length?!1:t.every(function(a,f){try{return xe(a,n[f],i)}catch(u){throw Ft(u,f)}})}return r.toJSON=function(){return"("+t.map(De).join(", ")+")"},r},value:function(t){function r(n){return n===t}return r.toJSON=function(){return t},r}};$e.oneOf=$e.anyOf;function Fe(e){if(ce.String(e))return e[0]==="?"?$e.maybe(e.slice(1)):ce[e]||$e.quacksLike(e);if(e&&ce.Object(e)){if(ce.Array(e)){if(e.length!==1)throw new TypeError("Expected compile() parameter of type Array of length 1");return $e.arrayOf(e[0])}return $e.object(e)}else if(ce.Function(e))return e;return $e.value(e)}function xe(e,t,r,n){if(ce.Function(e)){if(e(t,r))return!0;throw new Ji(n||e,t)}return xe(Fe(e),t,r)}for(var Xe in ce)xe[Xe]=ce[Xe];for(Xe in $e)xe[Xe]=$e[Xe];var Hn=Ka();for(Xe in Hn)xe[Xe]=Hn[Xe];xe.compile=Fe;xe.TfTypeError=Ji;xe.TfPropertyTypeError=Xi;var Ja=xe;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.maybe=e.Boolean=e.Array=e.Buffer256bit=e.Network=e.typeforce=void 0,e.typeforce=Ja,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})(Wi);var Qr={exports:{}},Zr={exports:{}},At={},mr={};mr.byteLength=Za;mr.toByteArray=tf;mr.fromByteArray=sf;var Ue=[],Re=[],Xa=typeof Uint8Array<"u"?Uint8Array:Array,Fr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var yt=0,Qa=Fr.length;yt<Qa;++yt)Ue[yt]=Fr[yt],Re[Fr.charCodeAt(yt)]=yt;Re[45]=62;Re[95]=63;function Qi(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 Za(e){var t=Qi(e),r=t[0],n=t[1];return(r+n)*3/4-n}function ef(e,t,r){return(t+r)*3/4-r}function tf(e){var t,r=Qi(e),n=r[0],i=r[1],a=new Xa(ef(e,n,i)),f=0,u=i>0?n-4:n,l;for(l=0;l<u;l+=4)t=Re[e.charCodeAt(l)]<<18|Re[e.charCodeAt(l+1)]<<12|Re[e.charCodeAt(l+2)]<<6|Re[e.charCodeAt(l+3)],a[f++]=t>>16&255,a[f++]=t>>8&255,a[f++]=t&255;return i===2&&(t=Re[e.charCodeAt(l)]<<2|Re[e.charCodeAt(l+1)]>>4,a[f++]=t&255),i===1&&(t=Re[e.charCodeAt(l)]<<10|Re[e.charCodeAt(l+1)]<<4|Re[e.charCodeAt(l+2)]>>2,a[f++]=t>>8&255,a[f++]=t&255),a}function rf(e){return Ue[e>>18&63]+Ue[e>>12&63]+Ue[e>>6&63]+Ue[e&63]}function nf(e,t,r){for(var n,i=[],a=t;a<r;a+=3)n=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),i.push(rf(n));return i.join("")}function sf(e){for(var t,r=e.length,n=r%3,i=[],a=16383,f=0,u=r-n;f<u;f+=a)i.push(nf(e,f,f+a>u?u:f+a));return n===1?(t=e[r-1],i.push(Ue[t>>2]+Ue[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Ue[t>>10]+Ue[t>>4&63]+Ue[t<<2&63]+"=")),i.join("")}var wn={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */wn.read=function(e,t,r,n,i){var a,f,u=i*8-n-1,l=(1<<u)-1,y=l>>1,g=-7,w=r?i-1:0,E=r?-1:1,I=e[t+w];for(w+=E,a=I&(1<<-g)-1,I>>=-g,g+=u;g>0;a=a*256+e[t+w],w+=E,g-=8);for(f=a&(1<<-g)-1,a>>=-g,g+=n;g>0;f=f*256+e[t+w],w+=E,g-=8);if(a===0)a=1-y;else{if(a===l)return f?NaN:(I?-1:1)*(1/0);f=f+Math.pow(2,n),a=a-y}return(I?-1:1)*f*Math.pow(2,a-n)};wn.write=function(e,t,r,n,i,a){var f,u,l,y=a*8-i-1,g=(1<<y)-1,w=g>>1,E=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,I=n?0:a-1,v=n?1:-1,P=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(u=isNaN(t)?1:0,f=g):(f=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-f))<1&&(f--,l*=2),f+w>=1?t+=E/l:t+=E*Math.pow(2,1-w),t*l>=2&&(f++,l/=2),f+w>=g?(u=0,f=g):f+w>=1?(u=(t*l-1)*Math.pow(2,i),f=f+w):(u=t*Math.pow(2,w-1)*Math.pow(2,i),f=0));i>=8;e[r+I]=u&255,I+=v,u/=256,i-=8);for(f=f<<i|u,y+=i;y>0;e[r+I]=f&255,I+=v,f/=256,y-=8);e[r+I-v]|=P*128};/*!
26
26
  * The buffer module from node.js, for the browser.
27
27
  *
28
28
  * @author Feross Aboukhadijeh <https://feross.org>
29
29
  * @license MIT
30
30
  */(function(e){const t=mr,r=wn,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=u,e.SlowBuffer=F,e.INSPECT_MAX_BYTES=50;const i=2147483647;e.kMaxLength=i,u.TYPED_ARRAY_SUPPORT=a(),!u.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function a(){try{const c=new Uint8Array(1),s={foo:function(){return 42}};return Object.setPrototypeOf(s,Uint8Array.prototype),Object.setPrototypeOf(c,s),c.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function f(c){if(c>i)throw new RangeError('The value "'+c+'" is invalid for option "size"');const s=new Uint8Array(c);return Object.setPrototypeOf(s,u.prototype),s}function u(c,s,o){if(typeof c=="number"){if(typeof s=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return w(c)}return l(c,s,o)}u.poolSize=8192;function l(c,s,o){if(typeof c=="string")return E(c,s);if(ArrayBuffer.isView(c))return v(c);if(c==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c);if(Ie(c,ArrayBuffer)||c&&Ie(c.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Ie(c,SharedArrayBuffer)||c&&Ie(c.buffer,SharedArrayBuffer)))return P(c,s,o);if(typeof c=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const h=c.valueOf&&c.valueOf();if(h!=null&&h!==c)return u.from(h,s,o);const b=T(c);if(b)return b;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof c[Symbol.toPrimitive]=="function")return u.from(c[Symbol.toPrimitive]("string"),s,o);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c)}u.from=function(c,s,o){return l(c,s,o)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array);function y(c){if(typeof c!="number")throw new TypeError('"size" argument must be of type number');if(c<0)throw new RangeError('The value "'+c+'" is invalid for option "size"')}function g(c,s,o){return y(c),c<=0?f(c):s!==void 0?typeof o=="string"?f(c).fill(s,o):f(c).fill(s):f(c)}u.alloc=function(c,s,o){return g(c,s,o)};function w(c){return y(c),f(c<0?0:k(c)|0)}u.allocUnsafe=function(c){return w(c)},u.allocUnsafeSlow=function(c){return w(c)};function E(c,s){if((typeof s!="string"||s==="")&&(s="utf8"),!u.isEncoding(s))throw new TypeError("Unknown encoding: "+s);const o=O(c,s)|0;let h=f(o);const b=h.write(c,s);return b!==o&&(h=h.slice(0,b)),h}function I(c){const s=c.length<0?0:k(c.length)|0,o=f(s);for(let h=0;h<s;h+=1)o[h]=c[h]&255;return o}function v(c){if(Ie(c,Uint8Array)){const s=new Uint8Array(c);return P(s.buffer,s.byteOffset,s.byteLength)}return I(c)}function P(c,s,o){if(s<0||c.byteLength<s)throw new RangeError('"offset" is outside of buffer bounds');if(c.byteLength<s+(o||0))throw new RangeError('"length" is outside of buffer bounds');let h;return s===void 0&&o===void 0?h=new Uint8Array(c):o===void 0?h=new Uint8Array(c,s):h=new Uint8Array(c,s,o),Object.setPrototypeOf(h,u.prototype),h}function T(c){if(u.isBuffer(c)){const s=k(c.length)|0,o=f(s);return o.length===0||c.copy(o,0,0,s),o}if(c.length!==void 0)return typeof c.length!="number"||rt(c.length)?f(0):I(c);if(c.type==="Buffer"&&Array.isArray(c.data))return I(c.data)}function k(c){if(c>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return c|0}function F(c){return+c!=c&&(c=0),u.alloc(+c)}u.isBuffer=function(s){return s!=null&&s._isBuffer===!0&&s!==u.prototype},u.compare=function(s,o){if(Ie(s,Uint8Array)&&(s=u.from(s,s.offset,s.byteLength)),Ie(o,Uint8Array)&&(o=u.from(o,o.offset,o.byteLength)),!u.isBuffer(s)||!u.isBuffer(o))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(s===o)return 0;let h=s.length,b=o.length;for(let x=0,B=Math.min(h,b);x<B;++x)if(s[x]!==o[x]){h=s[x],b=o[x];break}return h<b?-1:b<h?1:0},u.isEncoding=function(s){switch(String(s).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(s,o){if(!Array.isArray(s))throw new TypeError('"list" argument must be an Array of Buffers');if(s.length===0)return u.alloc(0);let h;if(o===void 0)for(o=0,h=0;h<s.length;++h)o+=s[h].length;const b=u.allocUnsafe(o);let x=0;for(h=0;h<s.length;++h){let B=s[h];if(Ie(B,Uint8Array))x+B.length>b.length?(u.isBuffer(B)||(B=u.from(B)),B.copy(b,x)):Uint8Array.prototype.set.call(b,B,x);else if(u.isBuffer(B))B.copy(b,x);else throw new TypeError('"list" argument must be an Array of Buffers');x+=B.length}return b};function O(c,s){if(u.isBuffer(c))return c.length;if(ArrayBuffer.isView(c)||Ie(c,ArrayBuffer))return c.byteLength;if(typeof c!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof c);const o=c.length,h=arguments.length>2&&arguments[2]===!0;if(!h&&o===0)return 0;let b=!1;for(;;)switch(s){case"ascii":case"latin1":case"binary":return o;case"utf8":case"utf-8":return V(c).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return o*2;case"hex":return o>>>1;case"base64":return Tt(c).length;default:if(b)return h?-1:V(c).length;s=(""+s).toLowerCase(),b=!0}}u.byteLength=O;function L(c,s,o){let h=!1;if((s===void 0||s<0)&&(s=0),s>this.length||((o===void 0||o>this.length)&&(o=this.length),o<=0)||(o>>>=0,s>>>=0,o<=s))return"";for(c||(c="utf8");;)switch(c){case"hex":return Ce(this,s,o);case"utf8":case"utf-8":return ve(this,s,o);case"ascii":return ke(this,s,o);case"latin1":case"binary":return qe(this,s,o);case"base64":return fe(this,s,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return We(this,s,o);default:if(h)throw new TypeError("Unknown encoding: "+c);c=(c+"").toLowerCase(),h=!0}}u.prototype._isBuffer=!0;function U(c,s,o){const h=c[s];c[s]=c[o],c[o]=h}u.prototype.swap16=function(){const s=this.length;if(s%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let o=0;o<s;o+=2)U(this,o,o+1);return this},u.prototype.swap32=function(){const s=this.length;if(s%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let o=0;o<s;o+=4)U(this,o,o+3),U(this,o+1,o+2);return this},u.prototype.swap64=function(){const s=this.length;if(s%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let o=0;o<s;o+=8)U(this,o,o+7),U(this,o+1,o+6),U(this,o+2,o+5),U(this,o+3,o+4);return this},u.prototype.toString=function(){const s=this.length;return s===0?"":arguments.length===0?ve(this,0,s):L.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(s){if(!u.isBuffer(s))throw new TypeError("Argument must be a Buffer");return this===s?!0:u.compare(this,s)===0},u.prototype.inspect=function(){let s="";const o=e.INSPECT_MAX_BYTES;return s=this.toString("hex",0,o).replace(/(.{2})/g,"$1 ").trim(),this.length>o&&(s+=" ... "),"<Buffer "+s+">"},n&&(u.prototype[n]=u.prototype.inspect),u.prototype.compare=function(s,o,h,b,x){if(Ie(s,Uint8Array)&&(s=u.from(s,s.offset,s.byteLength)),!u.isBuffer(s))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof s);if(o===void 0&&(o=0),h===void 0&&(h=s?s.length:0),b===void 0&&(b=0),x===void 0&&(x=this.length),o<0||h>s.length||b<0||x>this.length)throw new RangeError("out of range index");if(b>=x&&o>=h)return 0;if(b>=x)return-1;if(o>=h)return 1;if(o>>>=0,h>>>=0,b>>>=0,x>>>=0,this===s)return 0;let B=x-b,W=h-o;const ne=Math.min(B,W),te=this.slice(b,x),ie=s.slice(o,h);for(let Y=0;Y<ne;++Y)if(te[Y]!==ie[Y]){B=te[Y],W=ie[Y];break}return B<W?-1:W<B?1:0};function S(c,s,o,h,b){if(c.length===0)return-1;if(typeof o=="string"?(h=o,o=0):o>2147483647?o=2147483647:o<-2147483648&&(o=-2147483648),o=+o,rt(o)&&(o=b?0:c.length-1),o<0&&(o=c.length+o),o>=c.length){if(b)return-1;o=c.length-1}else if(o<0)if(b)o=0;else return-1;if(typeof s=="string"&&(s=u.from(s,h)),u.isBuffer(s))return s.length===0?-1:z(c,s,o,h,b);if(typeof s=="number")return s=s&255,typeof Uint8Array.prototype.indexOf=="function"?b?Uint8Array.prototype.indexOf.call(c,s,o):Uint8Array.prototype.lastIndexOf.call(c,s,o):z(c,[s],o,h,b);throw new TypeError("val must be string, number or Buffer")}function z(c,s,o,h,b){let x=1,B=c.length,W=s.length;if(h!==void 0&&(h=String(h).toLowerCase(),h==="ucs2"||h==="ucs-2"||h==="utf16le"||h==="utf-16le")){if(c.length<2||s.length<2)return-1;x=2,B/=2,W/=2,o/=2}function ne(ie,Y){return x===1?ie[Y]:ie.readUInt16BE(Y*x)}let te;if(b){let ie=-1;for(te=o;te<B;te++)if(ne(c,te)===ne(s,ie===-1?0:te-ie)){if(ie===-1&&(ie=te),te-ie+1===W)return ie*x}else ie!==-1&&(te-=te-ie),ie=-1}else for(o+W>B&&(o=B-W),te=o;te>=0;te--){let ie=!0;for(let Y=0;Y<W;Y++)if(ne(c,te+Y)!==ne(s,Y)){ie=!1;break}if(ie)return te}return-1}u.prototype.includes=function(s,o,h){return this.indexOf(s,o,h)!==-1},u.prototype.indexOf=function(s,o,h){return S(this,s,o,h,!0)},u.prototype.lastIndexOf=function(s,o,h){return S(this,s,o,h,!1)};function N(c,s,o,h){o=Number(o)||0;const b=c.length-o;h?(h=Number(h),h>b&&(h=b)):h=b;const x=s.length;h>x/2&&(h=x/2);let B;for(B=0;B<h;++B){const W=parseInt(s.substr(B*2,2),16);if(rt(W))return B;c[o+B]=W}return B}function $(c,s,o,h){return dt(V(s,c.length-o),c,o,h)}function oe(c,s,o,h){return dt(Ke(s),c,o,h)}function Pe(c,s,o,h){return dt(Tt(s),c,o,h)}function Ge(c,s,o,h){return dt(ht(s,c.length-o),c,o,h)}u.prototype.write=function(s,o,h,b){if(o===void 0)b="utf8",h=this.length,o=0;else if(h===void 0&&typeof o=="string")b=o,h=this.length,o=0;else if(isFinite(o))o=o>>>0,isFinite(h)?(h=h>>>0,b===void 0&&(b="utf8")):(b=h,h=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const x=this.length-o;if((h===void 0||h>x)&&(h=x),s.length>0&&(h<0||o<0)||o>this.length)throw new RangeError("Attempt to write outside buffer bounds");b||(b="utf8");let B=!1;for(;;)switch(b){case"hex":return N(this,s,o,h);case"utf8":case"utf-8":return $(this,s,o,h);case"ascii":case"latin1":case"binary":return oe(this,s,o,h);case"base64":return Pe(this,s,o,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ge(this,s,o,h);default:if(B)throw new TypeError("Unknown encoding: "+b);b=(""+b).toLowerCase(),B=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function fe(c,s,o){return s===0&&o===c.length?t.fromByteArray(c):t.fromByteArray(c.slice(s,o))}function ve(c,s,o){o=Math.min(c.length,o);const h=[];let b=s;for(;b<o;){const x=c[b];let B=null,W=x>239?4:x>223?3:x>191?2:1;if(b+W<=o){let ne,te,ie,Y;switch(W){case 1:x<128&&(B=x);break;case 2:ne=c[b+1],(ne&192)===128&&(Y=(x&31)<<6|ne&63,Y>127&&(B=Y));break;case 3:ne=c[b+1],te=c[b+2],(ne&192)===128&&(te&192)===128&&(Y=(x&15)<<12|(ne&63)<<6|te&63,Y>2047&&(Y<55296||Y>57343)&&(B=Y));break;case 4:ne=c[b+1],te=c[b+2],ie=c[b+3],(ne&192)===128&&(te&192)===128&&(ie&192)===128&&(Y=(x&15)<<18|(ne&63)<<12|(te&63)<<6|ie&63,Y>65535&&Y<1114112&&(B=Y))}}B===null?(B=65533,W=1):B>65535&&(B-=65536,h.push(B>>>10&1023|55296),B=56320|B&1023),h.push(B),b+=W}return tt(h)}const Ee=4096;function tt(c){const s=c.length;if(s<=Ee)return String.fromCharCode.apply(String,c);let o="",h=0;for(;h<s;)o+=String.fromCharCode.apply(String,c.slice(h,h+=Ee));return o}function ke(c,s,o){let h="";o=Math.min(c.length,o);for(let b=s;b<o;++b)h+=String.fromCharCode(c[b]&127);return h}function qe(c,s,o){let h="";o=Math.min(c.length,o);for(let b=s;b<o;++b)h+=String.fromCharCode(c[b]);return h}function Ce(c,s,o){const h=c.length;(!s||s<0)&&(s=0),(!o||o<0||o>h)&&(o=h);let b="";for(let x=s;x<o;++x)b+=Pt[c[x]];return b}function We(c,s,o){const h=c.slice(s,o);let b="";for(let x=0;x<h.length-1;x+=2)b+=String.fromCharCode(h[x]+h[x+1]*256);return b}u.prototype.slice=function(s,o){const h=this.length;s=~~s,o=o===void 0?h:~~o,s<0?(s+=h,s<0&&(s=0)):s>h&&(s=h),o<0?(o+=h,o<0&&(o=0)):o>h&&(o=h),o<s&&(o=s);const b=this.subarray(s,o);return Object.setPrototypeOf(b,u.prototype),b};function Z(c,s,o){if(c%1!==0||c<0)throw new RangeError("offset is not uint");if(c+s>o)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(s,o,h){s=s>>>0,o=o>>>0,h||Z(s,o,this.length);let b=this[s],x=1,B=0;for(;++B<o&&(x*=256);)b+=this[s+B]*x;return b},u.prototype.readUintBE=u.prototype.readUIntBE=function(s,o,h){s=s>>>0,o=o>>>0,h||Z(s,o,this.length);let b=this[s+--o],x=1;for(;o>0&&(x*=256);)b+=this[s+--o]*x;return b},u.prototype.readUint8=u.prototype.readUInt8=function(s,o){return s=s>>>0,o||Z(s,1,this.length),this[s]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(s,o){return s=s>>>0,o||Z(s,2,this.length),this[s]|this[s+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(s,o){return s=s>>>0,o||Z(s,2,this.length),this[s]<<8|this[s+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(s,o){return s=s>>>0,o||Z(s,4,this.length),(this[s]|this[s+1]<<8|this[s+2]<<16)+this[s+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(s,o){return s=s>>>0,o||Z(s,4,this.length),this[s]*16777216+(this[s+1]<<16|this[s+2]<<8|this[s+3])},u.prototype.readBigUInt64LE=Ae(function(s){s=s>>>0,A(s,"offset");const o=this[s],h=this[s+7];(o===void 0||h===void 0)&&M(s,this.length-8);const b=o+this[++s]*2**8+this[++s]*2**16+this[++s]*2**24,x=this[++s]+this[++s]*2**8+this[++s]*2**16+h*2**24;return BigInt(b)+(BigInt(x)<<BigInt(32))}),u.prototype.readBigUInt64BE=Ae(function(s){s=s>>>0,A(s,"offset");const o=this[s],h=this[s+7];(o===void 0||h===void 0)&&M(s,this.length-8);const b=o*2**24+this[++s]*2**16+this[++s]*2**8+this[++s],x=this[++s]*2**24+this[++s]*2**16+this[++s]*2**8+h;return(BigInt(b)<<BigInt(32))+BigInt(x)}),u.prototype.readIntLE=function(s,o,h){s=s>>>0,o=o>>>0,h||Z(s,o,this.length);let b=this[s],x=1,B=0;for(;++B<o&&(x*=256);)b+=this[s+B]*x;return x*=128,b>=x&&(b-=Math.pow(2,8*o)),b},u.prototype.readIntBE=function(s,o,h){s=s>>>0,o=o>>>0,h||Z(s,o,this.length);let b=o,x=1,B=this[s+--b];for(;b>0&&(x*=256);)B+=this[s+--b]*x;return x*=128,B>=x&&(B-=Math.pow(2,8*o)),B},u.prototype.readInt8=function(s,o){return s=s>>>0,o||Z(s,1,this.length),this[s]&128?(255-this[s]+1)*-1:this[s]},u.prototype.readInt16LE=function(s,o){s=s>>>0,o||Z(s,2,this.length);const h=this[s]|this[s+1]<<8;return h&32768?h|4294901760:h},u.prototype.readInt16BE=function(s,o){s=s>>>0,o||Z(s,2,this.length);const h=this[s+1]|this[s]<<8;return h&32768?h|4294901760:h},u.prototype.readInt32LE=function(s,o){return s=s>>>0,o||Z(s,4,this.length),this[s]|this[s+1]<<8|this[s+2]<<16|this[s+3]<<24},u.prototype.readInt32BE=function(s,o){return s=s>>>0,o||Z(s,4,this.length),this[s]<<24|this[s+1]<<16|this[s+2]<<8|this[s+3]},u.prototype.readBigInt64LE=Ae(function(s){s=s>>>0,A(s,"offset");const o=this[s],h=this[s+7];(o===void 0||h===void 0)&&M(s,this.length-8);const b=this[s+4]+this[s+5]*2**8+this[s+6]*2**16+(h<<24);return(BigInt(b)<<BigInt(32))+BigInt(o+this[++s]*2**8+this[++s]*2**16+this[++s]*2**24)}),u.prototype.readBigInt64BE=Ae(function(s){s=s>>>0,A(s,"offset");const o=this[s],h=this[s+7];(o===void 0||h===void 0)&&M(s,this.length-8);const b=(o<<24)+this[++s]*2**16+this[++s]*2**8+this[++s];return(BigInt(b)<<BigInt(32))+BigInt(this[++s]*2**24+this[++s]*2**16+this[++s]*2**8+h)}),u.prototype.readFloatLE=function(s,o){return s=s>>>0,o||Z(s,4,this.length),r.read(this,s,!0,23,4)},u.prototype.readFloatBE=function(s,o){return s=s>>>0,o||Z(s,4,this.length),r.read(this,s,!1,23,4)},u.prototype.readDoubleLE=function(s,o){return s=s>>>0,o||Z(s,8,this.length),r.read(this,s,!0,52,8)},u.prototype.readDoubleBE=function(s,o){return s=s>>>0,o||Z(s,8,this.length),r.read(this,s,!1,52,8)};function ae(c,s,o,h,b,x){if(!u.isBuffer(c))throw new TypeError('"buffer" argument must be a Buffer instance');if(s>b||s<x)throw new RangeError('"value" argument is out of bounds');if(o+h>c.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(s,o,h,b){if(s=+s,o=o>>>0,h=h>>>0,!b){const W=Math.pow(2,8*h)-1;ae(this,s,o,h,W,0)}let x=1,B=0;for(this[o]=s&255;++B<h&&(x*=256);)this[o+B]=s/x&255;return o+h},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(s,o,h,b){if(s=+s,o=o>>>0,h=h>>>0,!b){const W=Math.pow(2,8*h)-1;ae(this,s,o,h,W,0)}let x=h-1,B=1;for(this[o+x]=s&255;--x>=0&&(B*=256);)this[o+x]=s/B&255;return o+h},u.prototype.writeUint8=u.prototype.writeUInt8=function(s,o,h){return s=+s,o=o>>>0,h||ae(this,s,o,1,255,0),this[o]=s&255,o+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(s,o,h){return s=+s,o=o>>>0,h||ae(this,s,o,2,65535,0),this[o]=s&255,this[o+1]=s>>>8,o+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(s,o,h){return s=+s,o=o>>>0,h||ae(this,s,o,2,65535,0),this[o]=s>>>8,this[o+1]=s&255,o+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(s,o,h){return s=+s,o=o>>>0,h||ae(this,s,o,4,4294967295,0),this[o+3]=s>>>24,this[o+2]=s>>>16,this[o+1]=s>>>8,this[o]=s&255,o+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(s,o,h){return s=+s,o=o>>>0,h||ae(this,s,o,4,4294967295,0),this[o]=s>>>24,this[o+1]=s>>>16,this[o+2]=s>>>8,this[o+3]=s&255,o+4};function Se(c,s,o,h,b){p(s,h,b,c,o,7);let x=Number(s&BigInt(4294967295));c[o++]=x,x=x>>8,c[o++]=x,x=x>>8,c[o++]=x,x=x>>8,c[o++]=x;let B=Number(s>>BigInt(32)&BigInt(4294967295));return c[o++]=B,B=B>>8,c[o++]=B,B=B>>8,c[o++]=B,B=B>>8,c[o++]=B,o}function Ve(c,s,o,h,b){p(s,h,b,c,o,7);let x=Number(s&BigInt(4294967295));c[o+7]=x,x=x>>8,c[o+6]=x,x=x>>8,c[o+5]=x,x=x>>8,c[o+4]=x;let B=Number(s>>BigInt(32)&BigInt(4294967295));return c[o+3]=B,B=B>>8,c[o+2]=B,B=B>>8,c[o+1]=B,B=B>>8,c[o]=B,o+8}u.prototype.writeBigUInt64LE=Ae(function(s,o=0){return Se(this,s,o,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=Ae(function(s,o=0){return Ve(this,s,o,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(s,o,h,b){if(s=+s,o=o>>>0,!b){const ne=Math.pow(2,8*h-1);ae(this,s,o,h,ne-1,-ne)}let x=0,B=1,W=0;for(this[o]=s&255;++x<h&&(B*=256);)s<0&&W===0&&this[o+x-1]!==0&&(W=1),this[o+x]=(s/B>>0)-W&255;return o+h},u.prototype.writeIntBE=function(s,o,h,b){if(s=+s,o=o>>>0,!b){const ne=Math.pow(2,8*h-1);ae(this,s,o,h,ne-1,-ne)}let x=h-1,B=1,W=0;for(this[o+x]=s&255;--x>=0&&(B*=256);)s<0&&W===0&&this[o+x+1]!==0&&(W=1),this[o+x]=(s/B>>0)-W&255;return o+h},u.prototype.writeInt8=function(s,o,h){return s=+s,o=o>>>0,h||ae(this,s,o,1,127,-128),s<0&&(s=255+s+1),this[o]=s&255,o+1},u.prototype.writeInt16LE=function(s,o,h){return s=+s,o=o>>>0,h||ae(this,s,o,2,32767,-32768),this[o]=s&255,this[o+1]=s>>>8,o+2},u.prototype.writeInt16BE=function(s,o,h){return s=+s,o=o>>>0,h||ae(this,s,o,2,32767,-32768),this[o]=s>>>8,this[o+1]=s&255,o+2},u.prototype.writeInt32LE=function(s,o,h){return s=+s,o=o>>>0,h||ae(this,s,o,4,2147483647,-2147483648),this[o]=s&255,this[o+1]=s>>>8,this[o+2]=s>>>16,this[o+3]=s>>>24,o+4},u.prototype.writeInt32BE=function(s,o,h){return s=+s,o=o>>>0,h||ae(this,s,o,4,2147483647,-2147483648),s<0&&(s=4294967295+s+1),this[o]=s>>>24,this[o+1]=s>>>16,this[o+2]=s>>>8,this[o+3]=s&255,o+4},u.prototype.writeBigInt64LE=Ae(function(s,o=0){return Se(this,s,o,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=Ae(function(s,o=0){return Ve(this,s,o,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Me(c,s,o,h,b,x){if(o+h>c.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("Index out of range")}function _(c,s,o,h,b){return s=+s,o=o>>>0,b||Me(c,s,o,4),r.write(c,s,o,h,23,4),o+4}u.prototype.writeFloatLE=function(s,o,h){return _(this,s,o,!0,h)},u.prototype.writeFloatBE=function(s,o,h){return _(this,s,o,!1,h)};function m(c,s,o,h,b){return s=+s,o=o>>>0,b||Me(c,s,o,8),r.write(c,s,o,h,52,8),o+8}u.prototype.writeDoubleLE=function(s,o,h){return m(this,s,o,!0,h)},u.prototype.writeDoubleBE=function(s,o,h){return m(this,s,o,!1,h)},u.prototype.copy=function(s,o,h,b){if(!u.isBuffer(s))throw new TypeError("argument should be a Buffer");if(h||(h=0),!b&&b!==0&&(b=this.length),o>=s.length&&(o=s.length),o||(o=0),b>0&&b<h&&(b=h),b===h||s.length===0||this.length===0)return 0;if(o<0)throw new RangeError("targetStart out of bounds");if(h<0||h>=this.length)throw new RangeError("Index out of range");if(b<0)throw new RangeError("sourceEnd out of bounds");b>this.length&&(b=this.length),s.length-o<b-h&&(b=s.length-o+h);const x=b-h;return this===s&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(o,h,b):Uint8Array.prototype.set.call(s,this.subarray(h,b),o),x},u.prototype.fill=function(s,o,h,b){if(typeof s=="string"){if(typeof o=="string"?(b=o,o=0,h=this.length):typeof h=="string"&&(b=h,h=this.length),b!==void 0&&typeof b!="string")throw new TypeError("encoding must be a string");if(typeof b=="string"&&!u.isEncoding(b))throw new TypeError("Unknown encoding: "+b);if(s.length===1){const B=s.charCodeAt(0);(b==="utf8"&&B<128||b==="latin1")&&(s=B)}}else typeof s=="number"?s=s&255:typeof s=="boolean"&&(s=Number(s));if(o<0||this.length<o||this.length<h)throw new RangeError("Out of range index");if(h<=o)return this;o=o>>>0,h=h===void 0?this.length:h>>>0,s||(s=0);let x;if(typeof s=="number")for(x=o;x<h;++x)this[x]=s;else{const B=u.isBuffer(s)?s:u.from(s,b),W=B.length;if(W===0)throw new TypeError('The value "'+s+'" is invalid for argument "value"');for(x=0;x<h-o;++x)this[x+o]=B[x%W]}return this};const R={};function D(c,s,o){R[c]=class extends o{constructor(){super(),Object.defineProperty(this,"message",{value:s.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${c}]`,this.stack,delete this.name}get code(){return c}set code(b){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:b,writable:!0})}toString(){return`${this.name} [${c}]: ${this.message}`}}}D("ERR_BUFFER_OUT_OF_BOUNDS",function(c){return c?`${c} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),D("ERR_INVALID_ARG_TYPE",function(c,s){return`The "${c}" argument must be of type number. Received type ${typeof s}`},TypeError),D("ERR_OUT_OF_RANGE",function(c,s,o){let h=`The value of "${c}" is out of range.`,b=o;return Number.isInteger(o)&&Math.abs(o)>2**32?b=j(String(o)):typeof o=="bigint"&&(b=String(o),(o>BigInt(2)**BigInt(32)||o<-(BigInt(2)**BigInt(32)))&&(b=j(b)),b+="n"),h+=` It must be ${s}. Received ${b}`,h},RangeError);function j(c){let s="",o=c.length;const h=c[0]==="-"?1:0;for(;o>=h+4;o-=3)s=`_${c.slice(o-3,o)}${s}`;return`${c.slice(0,o)}${s}`}function d(c,s,o){A(s,"offset"),(c[s]===void 0||c[s+o]===void 0)&&M(s,c.length-(o+1))}function p(c,s,o,h,b,x){if(c>o||c<s){const B=typeof s=="bigint"?"n":"";let W;throw s===0||s===BigInt(0)?W=`>= 0${B} and < 2${B} ** ${(x+1)*8}${B}`:W=`>= -(2${B} ** ${(x+1)*8-1}${B}) and < 2 ** ${(x+1)*8-1}${B}`,new R.ERR_OUT_OF_RANGE("value",W,c)}d(h,b,x)}function A(c,s){if(typeof c!="number")throw new R.ERR_INVALID_ARG_TYPE(s,"number",c)}function M(c,s,o){throw Math.floor(c)!==c?(A(c,o),new R.ERR_OUT_OF_RANGE("offset","an integer",c)):s<0?new R.ERR_BUFFER_OUT_OF_BOUNDS:new R.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${s}`,c)}const ee=/[^+/0-9A-Za-z-_]/g;function G(c){if(c=c.split("=")[0],c=c.trim().replace(ee,""),c.length<2)return"";for(;c.length%4!==0;)c=c+"=";return c}function V(c,s){s=s||1/0;let o;const h=c.length;let b=null;const x=[];for(let B=0;B<h;++B){if(o=c.charCodeAt(B),o>55295&&o<57344){if(!b){if(o>56319){(s-=3)>-1&&x.push(239,191,189);continue}else if(B+1===h){(s-=3)>-1&&x.push(239,191,189);continue}b=o;continue}if(o<56320){(s-=3)>-1&&x.push(239,191,189),b=o;continue}o=(b-55296<<10|o-56320)+65536}else b&&(s-=3)>-1&&x.push(239,191,189);if(b=null,o<128){if((s-=1)<0)break;x.push(o)}else if(o<2048){if((s-=2)<0)break;x.push(o>>6|192,o&63|128)}else if(o<65536){if((s-=3)<0)break;x.push(o>>12|224,o>>6&63|128,o&63|128)}else if(o<1114112){if((s-=4)<0)break;x.push(o>>18|240,o>>12&63|128,o>>6&63|128,o&63|128)}else throw new Error("Invalid code point")}return x}function Ke(c){const s=[];for(let o=0;o<c.length;++o)s.push(c.charCodeAt(o)&255);return s}function ht(c,s){let o,h,b;const x=[];for(let B=0;B<c.length&&!((s-=2)<0);++B)o=c.charCodeAt(B),h=o>>8,b=o%256,x.push(b),x.push(h);return x}function Tt(c){return t.toByteArray(G(c))}function dt(c,s,o,h){let b;for(b=0;b<h&&!(b+o>=s.length||b>=c.length);++b)s[b+o]=c[b];return b}function Ie(c,s){return c instanceof s||c!=null&&c.constructor!=null&&c.constructor.name!=null&&c.constructor.name===s.name}function rt(c){return c!==c}const Pt=function(){const c="0123456789abcdef",s=new Array(256);for(let o=0;o<16;++o){const h=o*16;for(let b=0;b<16;++b)s[h+b]=c[o]+c[b]}return s}();function Ae(c){return typeof BigInt>"u"?nt:c}function nt(){throw new Error("BigInt not supported")}})(At);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(e,t){var r=At,n=r.Buffer;function i(f,u){for(var l in f)u[l]=f[l]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(i(r,t),t.Buffer=a);function a(f,u,l){return n(f,u,l)}a.prototype=Object.create(n.prototype),i(n,a),a.from=function(f,u,l){if(typeof f=="number")throw new TypeError("Argument must not be a number");return n(f,u,l)},a.alloc=function(f,u,l){if(typeof f!="number")throw new TypeError("Argument must be a number");var y=n(f);return u!==void 0?typeof l=="string"?y.fill(u,l):y.fill(u):y.fill(0),y},a.allocUnsafe=function(f){if(typeof f!="number")throw new TypeError("Argument must be a number");return n(f)},a.allocUnsafeSlow=function(f){if(typeof f!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(f)}})(Zr,Zr.exports);var Be=Zr.exports,Ur=65536,of=4294967295;function af(){throw new Error(`Secure random number generation is not supported by this browser.
31
- Use Chrome, Firefox or Internet Explorer 11`)}var ff=Be.Buffer,lr=Qe.crypto||Qe.msCrypto;lr&&lr.getRandomValues?Qr.exports=uf:Qr.exports=af;function uf(e,t){if(e>of)throw new RangeError("requested too many random bytes");var r=ff.allocUnsafe(e);if(e>0)if(e>Ur)for(var n=0;n<e;n+=Ur)lr.getRandomValues(r.slice(n,n+Ur));else lr.getRandomValues(r);return typeof t=="function"?process.nextTick(function(){t(null,r)}):r}var cf=Qr.exports,en={exports:{}};typeof Object.create=="function"?en.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:en.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 me=en.exports,tn={exports:{}},_n={exports:{}},wt=typeof Reflect=="object"?Reflect:null,zn=wt&&typeof wt.apply=="function"?wt.apply:function(t,r,n){return Function.prototype.apply.call(t,r,n)},nr;wt&&typeof wt.ownKeys=="function"?nr=wt.ownKeys:Object.getOwnPropertySymbols?nr=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:nr=function(t){return Object.getOwnPropertyNames(t)};function lf(e){console&&console.warn&&console.warn(e)}var Qi=Number.isNaN||function(t){return t!==t};function K(){K.init.call(this)}_n.exports=K;_n.exports.once=bf;K.EventEmitter=K;K.prototype._events=void 0;K.prototype._eventsCount=0;K.prototype._maxListeners=void 0;var jn=10;function wr(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(K,"defaultMaxListeners",{enumerable:!0,get:function(){return jn},set:function(e){if(typeof e!="number"||e<0||Qi(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");jn=e}});K.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};K.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||Qi(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 Zi(e){return e._maxListeners===void 0?K.defaultMaxListeners:e._maxListeners}K.prototype.getMaxListeners=function(){return Zi(this)};K.prototype.emit=function(t){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=t==="error",a=this._events;if(a!==void 0)i=i&&a.error===void 0;else if(!i)return!1;if(i){var f;if(r.length>0&&(f=r[0]),f instanceof Error)throw f;var u=new Error("Unhandled error."+(f?" ("+f.message+")":""));throw u.context=f,u}var l=a[t];if(l===void 0)return!1;if(typeof l=="function")zn(l,this,r);else for(var y=l.length,g=is(l,y),n=0;n<y;++n)zn(g[n],this,r);return!0};function es(e,t,r,n){var i,a,f;if(wr(r),a=e._events,a===void 0?(a=e._events=Object.create(null),e._eventsCount=0):(a.newListener!==void 0&&(e.emit("newListener",t,r.listener?r.listener:r),a=e._events),f=a[t]),f===void 0)f=a[t]=r,++e._eventsCount;else if(typeof f=="function"?f=a[t]=n?[r,f]:[f,r]:n?f.unshift(r):f.push(r),i=Zi(e),i>0&&f.length>i&&!f.warned){f.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+f.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=f.length,lf(u)}return e}K.prototype.addListener=function(t,r){return es(this,t,r,!1)};K.prototype.on=K.prototype.addListener;K.prototype.prependListener=function(t,r){return es(this,t,r,!0)};function hf(){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 ts(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=hf.bind(n);return i.listener=r,n.wrapFn=i,i}K.prototype.once=function(t,r){return wr(r),this.on(t,ts(this,t,r)),this};K.prototype.prependOnceListener=function(t,r){return wr(r),this.prependListener(t,ts(this,t,r)),this};K.prototype.removeListener=function(t,r){var n,i,a,f,u;if(wr(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(a=-1,f=n.length-1;f>=0;f--)if(n[f]===r||n[f].listener===r){u=n[f].listener,a=f;break}if(a<0)return this;a===0?n.shift():df(n,a),n.length===1&&(i[t]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",t,u||r)}return this};K.prototype.off=K.prototype.removeListener;K.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 a=Object.keys(n),f;for(i=0;i<a.length;++i)f=a[i],f!=="removeListener"&&this.removeAllListeners(f);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 rs(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?pf(i):is(i,i.length)}K.prototype.listeners=function(t){return rs(this,t,!0)};K.prototype.rawListeners=function(t){return rs(this,t,!1)};K.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):ns.call(e,t)};K.prototype.listenerCount=ns;function ns(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}K.prototype.eventNames=function(){return this._eventsCount>0?nr(this._events):[]};function is(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function df(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function pf(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}function bf(e,t){return new Promise(function(r,n){function i(f){e.removeListener(t,a),n(f)}function a(){typeof e.removeListener=="function"&&e.removeListener("error",i),r([].slice.call(arguments))}ss(e,t,a,{once:!0}),t!=="error"&&yf(e,i,{once:!0})})}function yf(e,t,r){typeof e.on=="function"&&ss(e,"error",t,r)}function ss(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(a){n.once&&e.removeEventListener(t,i),r(a)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}var os=_n.exports,as=os.EventEmitter;const gf={},mf=Object.freeze(Object.defineProperty({__proto__:null,default:gf},Symbol.toStringTag,{value:"Module"})),xn=ja(mf);var Mr,Gn;function wf(){if(Gn)return Mr;Gn=1;function e(v,P){var T=Object.keys(v);if(Object.getOwnPropertySymbols){var k=Object.getOwnPropertySymbols(v);P&&(k=k.filter(function(F){return Object.getOwnPropertyDescriptor(v,F).enumerable})),T.push.apply(T,k)}return T}function t(v){for(var P=1;P<arguments.length;P++){var T=arguments[P]!=null?arguments[P]:{};P%2?e(Object(T),!0).forEach(function(k){r(v,k,T[k])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(T)):e(Object(T)).forEach(function(k){Object.defineProperty(v,k,Object.getOwnPropertyDescriptor(T,k))})}return v}function r(v,P,T){return P=f(P),P in v?Object.defineProperty(v,P,{value:T,enumerable:!0,configurable:!0,writable:!0}):v[P]=T,v}function n(v,P){if(!(v instanceof P))throw new TypeError("Cannot call a class as a function")}function i(v,P){for(var T=0;T<P.length;T++){var k=P[T];k.enumerable=k.enumerable||!1,k.configurable=!0,"value"in k&&(k.writable=!0),Object.defineProperty(v,f(k.key),k)}}function a(v,P,T){return P&&i(v.prototype,P),Object.defineProperty(v,"prototype",{writable:!1}),v}function f(v){var P=u(v,"string");return typeof P=="symbol"?P:String(P)}function u(v,P){if(typeof v!="object"||v===null)return v;var T=v[Symbol.toPrimitive];if(T!==void 0){var k=T.call(v,P||"default");if(typeof k!="object")return k;throw new TypeError("@@toPrimitive must return a primitive value.")}return(P==="string"?String:Number)(v)}var l=At,y=l.Buffer,g=xn,w=g.inspect,E=w&&w.custom||"inspect";function I(v,P,T){y.prototype.copy.call(v,P,T)}return Mr=function(){function v(){n(this,v),this.head=null,this.tail=null,this.length=0}return a(v,[{key:"push",value:function(T){var k={data:T,next:null};this.length>0?this.tail.next=k:this.head=k,this.tail=k,++this.length}},{key:"unshift",value:function(T){var k={data:T,next:this.head};this.length===0&&(this.tail=k),this.head=k,++this.length}},{key:"shift",value:function(){if(this.length!==0){var T=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,T}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(T){if(this.length===0)return"";for(var k=this.head,F=""+k.data;k=k.next;)F+=T+k.data;return F}},{key:"concat",value:function(T){if(this.length===0)return y.alloc(0);for(var k=y.allocUnsafe(T>>>0),F=this.head,O=0;F;)I(F.data,k,O),O+=F.data.length,F=F.next;return k}},{key:"consume",value:function(T,k){var F;return T<this.head.data.length?(F=this.head.data.slice(0,T),this.head.data=this.head.data.slice(T)):T===this.head.data.length?F=this.shift():F=k?this._getString(T):this._getBuffer(T),F}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(T){var k=this.head,F=1,O=k.data;for(T-=O.length;k=k.next;){var L=k.data,U=T>L.length?L.length:T;if(U===L.length?O+=L:O+=L.slice(0,T),T-=U,T===0){U===L.length?(++F,k.next?this.head=k.next:this.head=this.tail=null):(this.head=k,k.data=L.slice(U));break}++F}return this.length-=F,O}},{key:"_getBuffer",value:function(T){var k=y.allocUnsafe(T),F=this.head,O=1;for(F.data.copy(k),T-=F.data.length;F=F.next;){var L=F.data,U=T>L.length?L.length:T;if(L.copy(k,k.length-T,0,U),T-=U,T===0){U===L.length?(++O,F.next?this.head=F.next:this.head=this.tail=null):(this.head=F,F.data=L.slice(U));break}++O}return this.length-=O,k}},{key:E,value:function(T,k){return w(this,t(t({},k),{},{depth:0,customInspect:!1}))}}]),v}(),Mr}function _f(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(rn,this,e)):process.nextTick(rn,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(a){!t&&a?r._writableState?r._writableState.errorEmitted?process.nextTick(ir,r):(r._writableState.errorEmitted=!0,process.nextTick(qn,r,a)):process.nextTick(qn,r,a):t?(process.nextTick(ir,r),t(a)):process.nextTick(ir,r)}),this)}function qn(e,t){rn(e,t),ir(e)}function ir(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function xf(){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 rn(e,t){e.emit("error",t)}function vf(e,t){var r=e._readableState,n=e._writableState;r&&r.autoDestroy||n&&n.autoDestroy?e.destroy(t):e.emit("error",t)}var fs={destroy:_f,undestroy:xf,errorOrDestroy:vf},ct={};function Ef(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var us={};function Te(e,t,r){r||(r=Error);function n(a,f,u){return typeof t=="string"?t:t(a,f,u)}var i=function(a){Ef(f,a);function f(u,l,y){return a.call(this,n(u,l,y))||this}return f}(r);i.prototype.name=r.name,i.prototype.code=e,us[e]=i}function Wn(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 Bf(e,t,r){return e.substr(0,t.length)===t}function Sf(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function If(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}Te("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError);Te("ERR_INVALID_ARG_TYPE",function(e,t,r){var n;typeof t=="string"&&Bf(t,"not ")?(n="must not be",t=t.replace(/^not /,"")):n="must be";var i;if(Sf(e," argument"))i="The ".concat(e," ").concat(n," ").concat(Wn(t,"type"));else{var a=If(e,".")?"property":"argument";i='The "'.concat(e,'" ').concat(a," ").concat(n," ").concat(Wn(t,"type"))}return i+=". Received type ".concat(typeof r),i},TypeError);Te("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");Te("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"});Te("ERR_STREAM_PREMATURE_CLOSE","Premature close");Te("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"});Te("ERR_MULTIPLE_CALLBACK","Callback called multiple times");Te("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");Te("ERR_STREAM_WRITE_AFTER_END","write after end");Te("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);Te("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError);Te("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");ct.codes=us;var Af=ct.codes.ERR_INVALID_OPT_VALUE;function Rf(e,t,r){return e.highWaterMark!=null?e.highWaterMark:t?e[r]:null}function Tf(e,t,r,n){var i=Rf(t,n,r);if(i!=null){if(!(isFinite(i)&&Math.floor(i)===i)||i<0){var a=n?r:"highWaterMark";throw new Af(a,i)}return Math.floor(i)}return e.objectMode?16:16*1024}var cs={getHighWaterMark:Tf},Pf=kf;function kf(e,t){if(Nr("noDeprecation"))return e;var r=!1;function n(){if(!r){if(Nr("throwDeprecation"))throw new Error(t);Nr("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}return n}function Nr(e){try{if(!Qe.localStorage)return!1}catch{return!1}var t=Qe.localStorage[e];return t==null?!1:String(t).toLowerCase()==="true"}var Dr,Vn;function ls(){if(Vn)return Dr;Vn=1,Dr=N;function e(_){var m=this;this.next=null,this.entry=null,this.finish=function(){Me(m,_)}}var t;N.WritableState=S;var r={deprecate:Pf},n=as,i=At.Buffer,a=(typeof Qe<"u"?Qe:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function f(_){return i.from(_)}function u(_){return i.isBuffer(_)||_ instanceof a}var l=fs,y=cs,g=y.getHighWaterMark,w=ct.codes,E=w.ERR_INVALID_ARG_TYPE,I=w.ERR_METHOD_NOT_IMPLEMENTED,v=w.ERR_MULTIPLE_CALLBACK,P=w.ERR_STREAM_CANNOT_PIPE,T=w.ERR_STREAM_DESTROYED,k=w.ERR_STREAM_NULL_VALUES,F=w.ERR_STREAM_WRITE_AFTER_END,O=w.ERR_UNKNOWN_ENCODING,L=l.errorOrDestroy;me(N,n);function U(){}function S(_,m,R){t=t||Bt(),_=_||{},typeof R!="boolean"&&(R=m instanceof t),this.objectMode=!!_.objectMode,R&&(this.objectMode=this.objectMode||!!_.writableObjectMode),this.highWaterMark=g(this,_,"writableHighWaterMark",R),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var D=_.decodeStrings===!1;this.decodeStrings=!D,this.defaultEncoding=_.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(j){tt(m,j)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=_.emitClose!==!1,this.autoDestroy=!!_.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new e(this)}S.prototype.getBuffer=function(){for(var m=this.bufferedRequest,R=[];m;)R.push(m),m=m.next;return R},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 z;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(z=Function.prototype[Symbol.hasInstance],Object.defineProperty(N,Symbol.hasInstance,{value:function(m){return z.call(this,m)?!0:this!==N?!1:m&&m._writableState instanceof S}})):z=function(m){return m instanceof this};function N(_){t=t||Bt();var m=this instanceof t;if(!m&&!z.call(N,this))return new N(_);this._writableState=new S(_,this,m),this.writable=!0,_&&(typeof _.write=="function"&&(this._write=_.write),typeof _.writev=="function"&&(this._writev=_.writev),typeof _.destroy=="function"&&(this._destroy=_.destroy),typeof _.final=="function"&&(this._final=_.final)),n.call(this)}N.prototype.pipe=function(){L(this,new P)};function $(_,m){var R=new F;L(_,R),process.nextTick(m,R)}function oe(_,m,R,D){var j;return R===null?j=new k:typeof R!="string"&&!m.objectMode&&(j=new E("chunk",["string","Buffer"],R)),j?(L(_,j),process.nextTick(D,j),!1):!0}N.prototype.write=function(_,m,R){var D=this._writableState,j=!1,d=!D.objectMode&&u(_);return d&&!i.isBuffer(_)&&(_=f(_)),typeof m=="function"&&(R=m,m=null),d?m="buffer":m||(m=D.defaultEncoding),typeof R!="function"&&(R=U),D.ending?$(this,R):(d||oe(this,D,_,R))&&(D.pendingcb++,j=Ge(this,D,d,_,m,R)),j},N.prototype.cork=function(){this._writableState.corked++},N.prototype.uncork=function(){var _=this._writableState;_.corked&&(_.corked--,!_.writing&&!_.corked&&!_.bufferProcessing&&_.bufferedRequest&&Ce(this,_))},N.prototype.setDefaultEncoding=function(m){if(typeof m=="string"&&(m=m.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((m+"").toLowerCase())>-1))throw new O(m);return this._writableState.defaultEncoding=m,this},Object.defineProperty(N.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function Pe(_,m,R){return!_.objectMode&&_.decodeStrings!==!1&&typeof m=="string"&&(m=i.from(m,R)),m}Object.defineProperty(N.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function Ge(_,m,R,D,j,d){if(!R){var p=Pe(m,D,j);D!==p&&(R=!0,j="buffer",D=p)}var A=m.objectMode?1:D.length;m.length+=A;var M=m.length<m.highWaterMark;if(M||(m.needDrain=!0),m.writing||m.corked){var ee=m.lastBufferedRequest;m.lastBufferedRequest={chunk:D,encoding:j,isBuf:R,callback:d,next:null},ee?ee.next=m.lastBufferedRequest:m.bufferedRequest=m.lastBufferedRequest,m.bufferedRequestCount+=1}else fe(_,m,!1,A,D,j,d);return M}function fe(_,m,R,D,j,d,p){m.writelen=D,m.writecb=p,m.writing=!0,m.sync=!0,m.destroyed?m.onwrite(new T("write")):R?_._writev(j,m.onwrite):_._write(j,d,m.onwrite),m.sync=!1}function ve(_,m,R,D,j){--m.pendingcb,R?(process.nextTick(j,D),process.nextTick(Se,_,m),_._writableState.errorEmitted=!0,L(_,D)):(j(D),_._writableState.errorEmitted=!0,L(_,D),Se(_,m))}function Ee(_){_.writing=!1,_.writecb=null,_.length-=_.writelen,_.writelen=0}function tt(_,m){var R=_._writableState,D=R.sync,j=R.writecb;if(typeof j!="function")throw new v;if(Ee(R),m)ve(_,R,D,m,j);else{var d=We(R)||_.destroyed;!d&&!R.corked&&!R.bufferProcessing&&R.bufferedRequest&&Ce(_,R),D?process.nextTick(ke,_,R,d,j):ke(_,R,d,j)}}function ke(_,m,R,D){R||qe(_,m),m.pendingcb--,D(),Se(_,m)}function qe(_,m){m.length===0&&m.needDrain&&(m.needDrain=!1,_.emit("drain"))}function Ce(_,m){m.bufferProcessing=!0;var R=m.bufferedRequest;if(_._writev&&R&&R.next){var D=m.bufferedRequestCount,j=new Array(D),d=m.corkedRequestsFree;d.entry=R;for(var p=0,A=!0;R;)j[p]=R,R.isBuf||(A=!1),R=R.next,p+=1;j.allBuffers=A,fe(_,m,!0,m.length,j,"",d.finish),m.pendingcb++,m.lastBufferedRequest=null,d.next?(m.corkedRequestsFree=d.next,d.next=null):m.corkedRequestsFree=new e(m),m.bufferedRequestCount=0}else{for(;R;){var M=R.chunk,ee=R.encoding,G=R.callback,V=m.objectMode?1:M.length;if(fe(_,m,!1,V,M,ee,G),R=R.next,m.bufferedRequestCount--,m.writing)break}R===null&&(m.lastBufferedRequest=null)}m.bufferedRequest=R,m.bufferProcessing=!1}N.prototype._write=function(_,m,R){R(new I("_write()"))},N.prototype._writev=null,N.prototype.end=function(_,m,R){var D=this._writableState;return typeof _=="function"?(R=_,_=null,m=null):typeof m=="function"&&(R=m,m=null),_!=null&&this.write(_,m),D.corked&&(D.corked=1,this.uncork()),D.ending||Ve(this,D,R),this},Object.defineProperty(N.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function We(_){return _.ending&&_.length===0&&_.bufferedRequest===null&&!_.finished&&!_.writing}function Z(_,m){_._final(function(R){m.pendingcb--,R&&L(_,R),m.prefinished=!0,_.emit("prefinish"),Se(_,m)})}function ae(_,m){!m.prefinished&&!m.finalCalled&&(typeof _._final=="function"&&!m.destroyed?(m.pendingcb++,m.finalCalled=!0,process.nextTick(Z,_,m)):(m.prefinished=!0,_.emit("prefinish")))}function Se(_,m){var R=We(m);if(R&&(ae(_,m),m.pendingcb===0&&(m.finished=!0,_.emit("finish"),m.autoDestroy))){var D=_._readableState;(!D||D.autoDestroy&&D.endEmitted)&&_.destroy()}return R}function Ve(_,m,R){m.ending=!0,Se(_,m),R&&(m.finished?process.nextTick(R):_.once("finish",R)),m.ended=!0,_.writable=!1}function Me(_,m,R){var D=_.entry;for(_.entry=null;D;){var j=D.callback;m.pendingcb--,j(R),D=D.next}m.corkedRequestsFree.next=_}return Object.defineProperty(N.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(m){this._writableState&&(this._writableState.destroyed=m)}}),N.prototype.destroy=l.destroy,N.prototype._undestroy=l.undestroy,N.prototype._destroy=function(_,m){m(_)},Dr}var $r,Kn;function Bt(){if(Kn)return $r;Kn=1;var e=Object.keys||function(y){var g=[];for(var w in y)g.push(w);return g};$r=f;var t=ds(),r=ls();me(f,t);for(var n=e(r.prototype),i=0;i<n.length;i++){var a=n[i];f.prototype[a]||(f.prototype[a]=r.prototype[a])}function f(y){if(!(this instanceof f))return new f(y);t.call(this,y),r.call(this,y),this.allowHalfOpen=!0,y&&(y.readable===!1&&(this.readable=!1),y.writable===!1&&(this.writable=!1),y.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",u)))}Object.defineProperty(f.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(f.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(f.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function u(){this._writableState.ended||process.nextTick(l,this)}function l(y){y.end()}return Object.defineProperty(f.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(g){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=g,this._writableState.destroyed=g)}}),$r}var hr={},vn=Be.Buffer,Yn=vn.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 Cf(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 Lf(e){var t=Cf(e);if(typeof t!="string"&&(vn.isEncoding===Yn||!Yn(e)))throw new Error("Unknown encoding: "+e);return t||e}hr.StringDecoder=Yt;function Yt(e){this.encoding=Lf(e);var t;switch(this.encoding){case"utf16le":this.text=Df,this.end=$f,t=4;break;case"utf8":this.fillLast=Uf,t=4;break;case"base64":this.text=Hf,this.end=zf,t=3;break;default:this.write=jf,this.end=Gf;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=vn.allocUnsafe(t)}Yt.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||""};Yt.prototype.end=Nf;Yt.prototype.text=Mf;Yt.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 Hr(e){return e<=127?0:e>>5===6?2:e>>4===14?3:e>>3===30?4:e>>6===2?-1:-2}function Of(e,t,r){var n=t.length-1;if(n<r)return 0;var i=Hr(t[n]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--n<r||i===-2?0:(i=Hr(t[n]),i>=0?(i>0&&(e.lastNeed=i-2),i):--n<r||i===-2?0:(i=Hr(t[n]),i>=0?(i>0&&(i===2?i=0:e.lastNeed=i-3),i):0))}function Ff(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 Uf(e){var t=this.lastTotal-this.lastNeed,r=Ff(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 Mf(e,t){var r=Of(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 Nf(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t}function Df(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 $f(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 Hf(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 zf(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function jf(e){return e.toString(this.encoding)}function Gf(e){return e&&e.length?this.write(e):""}var Jn=ct.codes.ERR_STREAM_PREMATURE_CLOSE;function qf(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 Wf(){}function Vf(e){return e.setHeader&&typeof e.abort=="function"}function hs(e,t,r){if(typeof t=="function")return hs(e,null,t);t||(t={}),r=qf(r||Wf);var n=t.readable||t.readable!==!1&&e.readable,i=t.writable||t.writable!==!1&&e.writable,a=function(){e.writable||u()},f=e._writableState&&e._writableState.finished,u=function(){i=!1,f=!0,n||r.call(e)},l=e._readableState&&e._readableState.endEmitted,y=function(){n=!1,l=!0,i||r.call(e)},g=function(v){r.call(e,v)},w=function(){var v;if(n&&!l)return(!e._readableState||!e._readableState.ended)&&(v=new Jn),r.call(e,v);if(i&&!f)return(!e._writableState||!e._writableState.ended)&&(v=new Jn),r.call(e,v)},E=function(){e.req.on("finish",u)};return Vf(e)?(e.on("complete",u),e.on("abort",w),e.req?E():e.on("request",E)):i&&!e._writableState&&(e.on("end",a),e.on("close",a)),e.on("end",y),e.on("finish",u),t.error!==!1&&e.on("error",g),e.on("close",w),function(){e.removeListener("complete",u),e.removeListener("abort",w),e.removeListener("request",E),e.req&&e.req.removeListener("finish",u),e.removeListener("end",a),e.removeListener("close",a),e.removeListener("finish",u),e.removeListener("end",y),e.removeListener("error",g),e.removeListener("close",w)}}var En=hs,zr,Xn;function Kf(){if(Xn)return zr;Xn=1;var e;function t(O,L,U){return L=r(L),L in O?Object.defineProperty(O,L,{value:U,enumerable:!0,configurable:!0,writable:!0}):O[L]=U,O}function r(O){var L=n(O,"string");return typeof L=="symbol"?L:String(L)}function n(O,L){if(typeof O!="object"||O===null)return O;var U=O[Symbol.toPrimitive];if(U!==void 0){var S=U.call(O,L||"default");if(typeof S!="object")return S;throw new TypeError("@@toPrimitive must return a primitive value.")}return(L==="string"?String:Number)(O)}var i=En,a=Symbol("lastResolve"),f=Symbol("lastReject"),u=Symbol("error"),l=Symbol("ended"),y=Symbol("lastPromise"),g=Symbol("handlePromise"),w=Symbol("stream");function E(O,L){return{value:O,done:L}}function I(O){var L=O[a];if(L!==null){var U=O[w].read();U!==null&&(O[y]=null,O[a]=null,O[f]=null,L(E(U,!1)))}}function v(O){process.nextTick(I,O)}function P(O,L){return function(U,S){O.then(function(){if(L[l]){U(E(void 0,!0));return}L[g](U,S)},S)}}var T=Object.getPrototypeOf(function(){}),k=Object.setPrototypeOf((e={get stream(){return this[w]},next:function(){var L=this,U=this[u];if(U!==null)return Promise.reject(U);if(this[l])return Promise.resolve(E(void 0,!0));if(this[w].destroyed)return new Promise(function($,oe){process.nextTick(function(){L[u]?oe(L[u]):$(E(void 0,!0))})});var S=this[y],z;if(S)z=new Promise(P(S,this));else{var N=this[w].read();if(N!==null)return Promise.resolve(E(N,!1));z=new Promise(this[g])}return this[y]=z,z}},t(e,Symbol.asyncIterator,function(){return this}),t(e,"return",function(){var L=this;return new Promise(function(U,S){L[w].destroy(null,function(z){if(z){S(z);return}U(E(void 0,!0))})})}),e),T),F=function(L){var U,S=Object.create(k,(U={},t(U,w,{value:L,writable:!0}),t(U,a,{value:null,writable:!0}),t(U,f,{value:null,writable:!0}),t(U,u,{value:null,writable:!0}),t(U,l,{value:L._readableState.endEmitted,writable:!0}),t(U,g,{value:function(N,$){var oe=S[w].read();oe?(S[y]=null,S[a]=null,S[f]=null,N(E(oe,!1))):(S[a]=N,S[f]=$)},writable:!0}),U));return S[y]=null,i(L,function(z){if(z&&z.code!=="ERR_STREAM_PREMATURE_CLOSE"){var N=S[f];N!==null&&(S[y]=null,S[a]=null,S[f]=null,N(z)),S[u]=z;return}var $=S[a];$!==null&&(S[y]=null,S[a]=null,S[f]=null,$(E(void 0,!0))),S[l]=!0}),L.on("readable",v.bind(null,S)),S};return zr=F,zr}var jr,Qn;function Yf(){return Qn||(Qn=1,jr=function(){throw new Error("Readable.from is not available in the browser")}),jr}var Gr,Zn;function ds(){if(Zn)return Gr;Zn=1,Gr=$;var e;$.ReadableState=N,os.EventEmitter;var t=function(p,A){return p.listeners(A).length},r=as,n=At.Buffer,i=(typeof Qe<"u"?Qe:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function a(d){return n.from(d)}function f(d){return n.isBuffer(d)||d instanceof i}var u=xn,l;u&&u.debuglog?l=u.debuglog("stream"):l=function(){};var y=wf(),g=fs,w=cs,E=w.getHighWaterMark,I=ct.codes,v=I.ERR_INVALID_ARG_TYPE,P=I.ERR_STREAM_PUSH_AFTER_EOF,T=I.ERR_METHOD_NOT_IMPLEMENTED,k=I.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,F,O,L;me($,r);var U=g.errorOrDestroy,S=["error","close","destroy","pause","resume"];function z(d,p,A){if(typeof d.prependListener=="function")return d.prependListener(p,A);!d._events||!d._events[p]?d.on(p,A):Array.isArray(d._events[p])?d._events[p].unshift(A):d._events[p]=[A,d._events[p]]}function N(d,p,A){e=e||Bt(),d=d||{},typeof A!="boolean"&&(A=p instanceof e),this.objectMode=!!d.objectMode,A&&(this.objectMode=this.objectMode||!!d.readableObjectMode),this.highWaterMark=E(this,d,"readableHighWaterMark",A),this.buffer=new y,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=d.emitClose!==!1,this.autoDestroy=!!d.autoDestroy,this.destroyed=!1,this.defaultEncoding=d.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,d.encoding&&(F||(F=hr.StringDecoder),this.decoder=new F(d.encoding),this.encoding=d.encoding)}function $(d){if(e=e||Bt(),!(this instanceof $))return new $(d);var p=this instanceof e;this._readableState=new N(d,this,p),this.readable=!0,d&&(typeof d.read=="function"&&(this._read=d.read),typeof d.destroy=="function"&&(this._destroy=d.destroy)),r.call(this)}Object.defineProperty($.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(p){this._readableState&&(this._readableState.destroyed=p)}}),$.prototype.destroy=g.destroy,$.prototype._undestroy=g.undestroy,$.prototype._destroy=function(d,p){p(d)},$.prototype.push=function(d,p){var A=this._readableState,M;return A.objectMode?M=!0:typeof d=="string"&&(p=p||A.defaultEncoding,p!==A.encoding&&(d=n.from(d,p),p=""),M=!0),oe(this,d,p,!1,M)},$.prototype.unshift=function(d){return oe(this,d,null,!0,!1)};function oe(d,p,A,M,ee){l("readableAddChunk",p);var G=d._readableState;if(p===null)G.reading=!1,tt(d,G);else{var V;if(ee||(V=Ge(G,p)),V)U(d,V);else if(G.objectMode||p&&p.length>0)if(typeof p!="string"&&!G.objectMode&&Object.getPrototypeOf(p)!==n.prototype&&(p=a(p)),M)G.endEmitted?U(d,new k):Pe(d,G,p,!0);else if(G.ended)U(d,new P);else{if(G.destroyed)return!1;G.reading=!1,G.decoder&&!A?(p=G.decoder.write(p),G.objectMode||p.length!==0?Pe(d,G,p,!1):Ce(d,G)):Pe(d,G,p,!1)}else M||(G.reading=!1,Ce(d,G))}return!G.ended&&(G.length<G.highWaterMark||G.length===0)}function Pe(d,p,A,M){p.flowing&&p.length===0&&!p.sync?(p.awaitDrain=0,d.emit("data",A)):(p.length+=p.objectMode?1:A.length,M?p.buffer.unshift(A):p.buffer.push(A),p.needReadable&&ke(d)),Ce(d,p)}function Ge(d,p){var A;return!f(p)&&typeof p!="string"&&p!==void 0&&!d.objectMode&&(A=new v("chunk",["string","Buffer","Uint8Array"],p)),A}$.prototype.isPaused=function(){return this._readableState.flowing===!1},$.prototype.setEncoding=function(d){F||(F=hr.StringDecoder);var p=new F(d);this._readableState.decoder=p,this._readableState.encoding=this._readableState.decoder.encoding;for(var A=this._readableState.buffer.head,M="";A!==null;)M+=p.write(A.data),A=A.next;return this._readableState.buffer.clear(),M!==""&&this._readableState.buffer.push(M),this._readableState.length=M.length,this};var fe=1073741824;function ve(d){return d>=fe?d=fe:(d--,d|=d>>>1,d|=d>>>2,d|=d>>>4,d|=d>>>8,d|=d>>>16,d++),d}function Ee(d,p){return d<=0||p.length===0&&p.ended?0:p.objectMode?1:d!==d?p.flowing&&p.length?p.buffer.head.data.length:p.length:(d>p.highWaterMark&&(p.highWaterMark=ve(d)),d<=p.length?d:p.ended?p.length:(p.needReadable=!0,0))}$.prototype.read=function(d){l("read",d),d=parseInt(d,10);var p=this._readableState,A=d;if(d!==0&&(p.emittedReadable=!1),d===0&&p.needReadable&&((p.highWaterMark!==0?p.length>=p.highWaterMark:p.length>0)||p.ended))return l("read: emitReadable",p.length,p.ended),p.length===0&&p.ended?R(this):ke(this),null;if(d=Ee(d,p),d===0&&p.ended)return p.length===0&&R(this),null;var M=p.needReadable;l("need readable",M),(p.length===0||p.length-d<p.highWaterMark)&&(M=!0,l("length less than watermark",M)),p.ended||p.reading?(M=!1,l("reading or ended",M)):M&&(l("do read"),p.reading=!0,p.sync=!0,p.length===0&&(p.needReadable=!0),this._read(p.highWaterMark),p.sync=!1,p.reading||(d=Ee(A,p)));var ee;return d>0?ee=m(d,p):ee=null,ee===null?(p.needReadable=p.length<=p.highWaterMark,d=0):(p.length-=d,p.awaitDrain=0),p.length===0&&(p.ended||(p.needReadable=!0),A!==d&&p.ended&&R(this)),ee!==null&&this.emit("data",ee),ee};function tt(d,p){if(l("onEofChunk"),!p.ended){if(p.decoder){var A=p.decoder.end();A&&A.length&&(p.buffer.push(A),p.length+=p.objectMode?1:A.length)}p.ended=!0,p.sync?ke(d):(p.needReadable=!1,p.emittedReadable||(p.emittedReadable=!0,qe(d)))}}function ke(d){var p=d._readableState;l("emitReadable",p.needReadable,p.emittedReadable),p.needReadable=!1,p.emittedReadable||(l("emitReadable",p.flowing),p.emittedReadable=!0,process.nextTick(qe,d))}function qe(d){var p=d._readableState;l("emitReadable_",p.destroyed,p.length,p.ended),!p.destroyed&&(p.length||p.ended)&&(d.emit("readable"),p.emittedReadable=!1),p.needReadable=!p.flowing&&!p.ended&&p.length<=p.highWaterMark,_(d)}function Ce(d,p){p.readingMore||(p.readingMore=!0,process.nextTick(We,d,p))}function We(d,p){for(;!p.reading&&!p.ended&&(p.length<p.highWaterMark||p.flowing&&p.length===0);){var A=p.length;if(l("maybeReadMore read 0"),d.read(0),A===p.length)break}p.readingMore=!1}$.prototype._read=function(d){U(this,new T("_read()"))},$.prototype.pipe=function(d,p){var A=this,M=this._readableState;switch(M.pipesCount){case 0:M.pipes=d;break;case 1:M.pipes=[M.pipes,d];break;default:M.pipes.push(d);break}M.pipesCount+=1,l("pipe count=%d opts=%j",M.pipesCount,p);var ee=(!p||p.end!==!1)&&d!==process.stdout&&d!==process.stderr,G=ee?Ke:nt;M.endEmitted?process.nextTick(G):A.once("end",G),d.on("unpipe",V);function V(c,s){l("onunpipe"),c===A&&s&&s.hasUnpiped===!1&&(s.hasUnpiped=!0,dt())}function Ke(){l("onend"),d.end()}var ht=Z(A);d.on("drain",ht);var Tt=!1;function dt(){l("cleanup"),d.removeListener("close",Pt),d.removeListener("finish",Ae),d.removeListener("drain",ht),d.removeListener("error",rt),d.removeListener("unpipe",V),A.removeListener("end",Ke),A.removeListener("end",nt),A.removeListener("data",Ie),Tt=!0,M.awaitDrain&&(!d._writableState||d._writableState.needDrain)&&ht()}A.on("data",Ie);function Ie(c){l("ondata");var s=d.write(c);l("dest.write",s),s===!1&&((M.pipesCount===1&&M.pipes===d||M.pipesCount>1&&j(M.pipes,d)!==-1)&&!Tt&&(l("false write response, pause",M.awaitDrain),M.awaitDrain++),A.pause())}function rt(c){l("onerror",c),nt(),d.removeListener("error",rt),t(d,"error")===0&&U(d,c)}z(d,"error",rt);function Pt(){d.removeListener("finish",Ae),nt()}d.once("close",Pt);function Ae(){l("onfinish"),d.removeListener("close",Pt),nt()}d.once("finish",Ae);function nt(){l("unpipe"),A.unpipe(d)}return d.emit("pipe",A),M.flowing||(l("pipe resume"),A.resume()),d};function Z(d){return function(){var A=d._readableState;l("pipeOnDrain",A.awaitDrain),A.awaitDrain&&A.awaitDrain--,A.awaitDrain===0&&t(d,"data")&&(A.flowing=!0,_(d))}}$.prototype.unpipe=function(d){var p=this._readableState,A={hasUnpiped:!1};if(p.pipesCount===0)return this;if(p.pipesCount===1)return d&&d!==p.pipes?this:(d||(d=p.pipes),p.pipes=null,p.pipesCount=0,p.flowing=!1,d&&d.emit("unpipe",this,A),this);if(!d){var M=p.pipes,ee=p.pipesCount;p.pipes=null,p.pipesCount=0,p.flowing=!1;for(var G=0;G<ee;G++)M[G].emit("unpipe",this,{hasUnpiped:!1});return this}var V=j(p.pipes,d);return V===-1?this:(p.pipes.splice(V,1),p.pipesCount-=1,p.pipesCount===1&&(p.pipes=p.pipes[0]),d.emit("unpipe",this,A),this)},$.prototype.on=function(d,p){var A=r.prototype.on.call(this,d,p),M=this._readableState;return d==="data"?(M.readableListening=this.listenerCount("readable")>0,M.flowing!==!1&&this.resume()):d==="readable"&&!M.endEmitted&&!M.readableListening&&(M.readableListening=M.needReadable=!0,M.flowing=!1,M.emittedReadable=!1,l("on readable",M.length,M.reading),M.length?ke(this):M.reading||process.nextTick(Se,this)),A},$.prototype.addListener=$.prototype.on,$.prototype.removeListener=function(d,p){var A=r.prototype.removeListener.call(this,d,p);return d==="readable"&&process.nextTick(ae,this),A},$.prototype.removeAllListeners=function(d){var p=r.prototype.removeAllListeners.apply(this,arguments);return(d==="readable"||d===void 0)&&process.nextTick(ae,this),p};function ae(d){var p=d._readableState;p.readableListening=d.listenerCount("readable")>0,p.resumeScheduled&&!p.paused?p.flowing=!0:d.listenerCount("data")>0&&d.resume()}function Se(d){l("readable nexttick read 0"),d.read(0)}$.prototype.resume=function(){var d=this._readableState;return d.flowing||(l("resume"),d.flowing=!d.readableListening,Ve(this,d)),d.paused=!1,this};function Ve(d,p){p.resumeScheduled||(p.resumeScheduled=!0,process.nextTick(Me,d,p))}function Me(d,p){l("resume",p.reading),p.reading||d.read(0),p.resumeScheduled=!1,d.emit("resume"),_(d),p.flowing&&!p.reading&&d.read(0)}$.prototype.pause=function(){return l("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(l("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function _(d){var p=d._readableState;for(l("flow",p.flowing);p.flowing&&d.read()!==null;);}$.prototype.wrap=function(d){var p=this,A=this._readableState,M=!1;d.on("end",function(){if(l("wrapped end"),A.decoder&&!A.ended){var V=A.decoder.end();V&&V.length&&p.push(V)}p.push(null)}),d.on("data",function(V){if(l("wrapped data"),A.decoder&&(V=A.decoder.write(V)),!(A.objectMode&&V==null)&&!(!A.objectMode&&(!V||!V.length))){var Ke=p.push(V);Ke||(M=!0,d.pause())}});for(var ee in d)this[ee]===void 0&&typeof d[ee]=="function"&&(this[ee]=function(Ke){return function(){return d[Ke].apply(d,arguments)}}(ee));for(var G=0;G<S.length;G++)d.on(S[G],this.emit.bind(this,S[G]));return this._read=function(V){l("wrapped _read",V),M&&(M=!1,d.resume())},this},typeof Symbol=="function"&&($.prototype[Symbol.asyncIterator]=function(){return O===void 0&&(O=Kf()),O(this)}),Object.defineProperty($.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty($.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty($.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(p){this._readableState&&(this._readableState.flowing=p)}}),$._fromList=m,Object.defineProperty($.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function m(d,p){if(p.length===0)return null;var A;return p.objectMode?A=p.buffer.shift():!d||d>=p.length?(p.decoder?A=p.buffer.join(""):p.buffer.length===1?A=p.buffer.first():A=p.buffer.concat(p.length),p.buffer.clear()):A=p.buffer.consume(d,p.decoder),A}function R(d){var p=d._readableState;l("endReadable",p.endEmitted),p.endEmitted||(p.ended=!0,process.nextTick(D,p,d))}function D(d,p){if(l("endReadableNT",d.endEmitted,d.length),!d.endEmitted&&d.length===0&&(d.endEmitted=!0,p.readable=!1,p.emit("end"),d.autoDestroy)){var A=p._writableState;(!A||A.autoDestroy&&A.finished)&&p.destroy()}}typeof Symbol=="function"&&($.from=function(d,p){return L===void 0&&(L=Yf()),L($,d,p)});function j(d,p){for(var A=0,M=d.length;A<M;A++)if(d[A]===p)return A;return-1}return Gr}var ps=je,_r=ct.codes,Jf=_r.ERR_METHOD_NOT_IMPLEMENTED,Xf=_r.ERR_MULTIPLE_CALLBACK,Qf=_r.ERR_TRANSFORM_ALREADY_TRANSFORMING,Zf=_r.ERR_TRANSFORM_WITH_LENGTH_0,xr=Bt();me(je,xr);function eu(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(n===null)return this.emit("error",new Xf);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 je(e){if(!(this instanceof je))return new je(e);xr.call(this,e),this._transformState={afterTransform:eu.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",tu)}function tu(){var e=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(t,r){ei(e,t,r)}):ei(this,null,null)}je.prototype.push=function(e,t){return this._transformState.needTransform=!1,xr.prototype.push.call(this,e,t)};je.prototype._transform=function(e,t,r){r(new Jf("_transform()"))};je.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)}};je.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};je.prototype._destroy=function(e,t){xr.prototype._destroy.call(this,e,function(r){t(r)})};function ei(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new Zf;if(e._transformState.transforming)throw new Qf;return e.push(null)}var ru=jt,bs=ps;me(jt,bs);function jt(e){if(!(this instanceof jt))return new jt(e);bs.call(this,e)}jt.prototype._transform=function(e,t,r){r(null,e)};var qr;function nu(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var ys=ct.codes,iu=ys.ERR_MISSING_ARGS,su=ys.ERR_STREAM_DESTROYED;function ti(e){if(e)throw e}function ou(e){return e.setHeader&&typeof e.abort=="function"}function au(e,t,r,n){n=nu(n);var i=!1;e.on("close",function(){i=!0}),qr===void 0&&(qr=En),qr(e,{readable:t,writable:r},function(f){if(f)return n(f);i=!0,n()});var a=!1;return function(f){if(!i&&!a){if(a=!0,ou(e))return e.abort();if(typeof e.destroy=="function")return e.destroy();n(f||new su("pipe"))}}}function ri(e){e()}function fu(e,t){return e.pipe(t)}function uu(e){return!e.length||typeof e[e.length-1]!="function"?ti:e.pop()}function cu(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=uu(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new iu("streams");var i,a=t.map(function(f,u){var l=u<t.length-1,y=u>0;return au(f,l,y,function(g){i||(i=g),g&&a.forEach(ri),!l&&(a.forEach(ri),n(i))})});return t.reduce(fu)}var lu=cu;(function(e,t){t=e.exports=ds(),t.Stream=t,t.Readable=t,t.Writable=ls(),t.Duplex=Bt(),t.Transform=ps,t.PassThrough=ru,t.finished=En,t.pipeline=lu})(tn,tn.exports);var hu=tn.exports,dr=Be.Buffer,gs=hu.Transform,du=me;function pu(e,t){if(!dr.isBuffer(e)&&typeof e!="string")throw new TypeError(t+" must be a string or a buffer")}function et(e){gs.call(this),this._block=dr.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}du(et,gs);et.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(i){n=i}r(n)};et.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(r){t=r}e(t)};et.prototype.update=function(e,t){if(pu(e,"Data"),this._finalized)throw new Error("Digest already called");dr.isBuffer(e)||(e=dr.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 a=0,f=e.length*8;f>0;++a)this._length[a]+=f,f=this._length[a]/4294967296|0,f>0&&(this._length[a]-=4294967296*f);return this};et.prototype._update=function(){throw new Error("_update is not implemented")};et.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};et.prototype._digest=function(){throw new Error("_digest is not implemented")};var ms=et,bu=me,ws=ms,yu=Be.Buffer,gu=new Array(16);function vr(){ws.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}bu(vr,ws);vr.prototype._update=function(){for(var e=gu,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);var r=this._a,n=this._b,i=this._c,a=this._d;r=le(r,n,i,a,e[0],3614090360,7),a=le(a,r,n,i,e[1],3905402710,12),i=le(i,a,r,n,e[2],606105819,17),n=le(n,i,a,r,e[3],3250441966,22),r=le(r,n,i,a,e[4],4118548399,7),a=le(a,r,n,i,e[5],1200080426,12),i=le(i,a,r,n,e[6],2821735955,17),n=le(n,i,a,r,e[7],4249261313,22),r=le(r,n,i,a,e[8],1770035416,7),a=le(a,r,n,i,e[9],2336552879,12),i=le(i,a,r,n,e[10],4294925233,17),n=le(n,i,a,r,e[11],2304563134,22),r=le(r,n,i,a,e[12],1804603682,7),a=le(a,r,n,i,e[13],4254626195,12),i=le(i,a,r,n,e[14],2792965006,17),n=le(n,i,a,r,e[15],1236535329,22),r=he(r,n,i,a,e[1],4129170786,5),a=he(a,r,n,i,e[6],3225465664,9),i=he(i,a,r,n,e[11],643717713,14),n=he(n,i,a,r,e[0],3921069994,20),r=he(r,n,i,a,e[5],3593408605,5),a=he(a,r,n,i,e[10],38016083,9),i=he(i,a,r,n,e[15],3634488961,14),n=he(n,i,a,r,e[4],3889429448,20),r=he(r,n,i,a,e[9],568446438,5),a=he(a,r,n,i,e[14],3275163606,9),i=he(i,a,r,n,e[3],4107603335,14),n=he(n,i,a,r,e[8],1163531501,20),r=he(r,n,i,a,e[13],2850285829,5),a=he(a,r,n,i,e[2],4243563512,9),i=he(i,a,r,n,e[7],1735328473,14),n=he(n,i,a,r,e[12],2368359562,20),r=de(r,n,i,a,e[5],4294588738,4),a=de(a,r,n,i,e[8],2272392833,11),i=de(i,a,r,n,e[11],1839030562,16),n=de(n,i,a,r,e[14],4259657740,23),r=de(r,n,i,a,e[1],2763975236,4),a=de(a,r,n,i,e[4],1272893353,11),i=de(i,a,r,n,e[7],4139469664,16),n=de(n,i,a,r,e[10],3200236656,23),r=de(r,n,i,a,e[13],681279174,4),a=de(a,r,n,i,e[0],3936430074,11),i=de(i,a,r,n,e[3],3572445317,16),n=de(n,i,a,r,e[6],76029189,23),r=de(r,n,i,a,e[9],3654602809,4),a=de(a,r,n,i,e[12],3873151461,11),i=de(i,a,r,n,e[15],530742520,16),n=de(n,i,a,r,e[2],3299628645,23),r=pe(r,n,i,a,e[0],4096336452,6),a=pe(a,r,n,i,e[7],1126891415,10),i=pe(i,a,r,n,e[14],2878612391,15),n=pe(n,i,a,r,e[5],4237533241,21),r=pe(r,n,i,a,e[12],1700485571,6),a=pe(a,r,n,i,e[3],2399980690,10),i=pe(i,a,r,n,e[10],4293915773,15),n=pe(n,i,a,r,e[1],2240044497,21),r=pe(r,n,i,a,e[8],1873313359,6),a=pe(a,r,n,i,e[15],4264355552,10),i=pe(i,a,r,n,e[6],2734768916,15),n=pe(n,i,a,r,e[13],1309151649,21),r=pe(r,n,i,a,e[4],4149444226,6),a=pe(a,r,n,i,e[11],3174756917,10),i=pe(i,a,r,n,e[2],718787259,15),n=pe(n,i,a,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+a|0};vr.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=yu.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 Er(e,t){return e<<t|e>>>32-t}function le(e,t,r,n,i,a,f){return Er(e+(t&r|~t&n)+i+a|0,f)+t|0}function he(e,t,r,n,i,a,f){return Er(e+(t&n|r&~n)+i+a|0,f)+t|0}function de(e,t,r,n,i,a,f){return Er(e+(t^r^n)+i+a|0,f)+t|0}function pe(e,t,r,n,i,a,f){return Er(e+(r^(t|~n))+i+a|0,f)+t|0}var mu=vr,Wr=At.Buffer,wu=me,_s=ms,_u=new Array(16),Ut=[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],Mt=[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],Nt=[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],Dt=[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],$t=[0,1518500249,1859775393,2400959708,2840853838],Ht=[1352829926,1548603684,1836072691,2053994217,0];function Br(){_s.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}wu(Br,_s);Br.prototype._update=function(){for(var e=_u,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,a=this._d|0,f=this._e|0,u=this._a|0,l=this._b|0,y=this._c|0,g=this._d|0,w=this._e|0,E=0;E<80;E+=1){var I,v;E<16?(I=ni(r,n,i,a,f,e[Ut[E]],$t[0],Nt[E]),v=ai(u,l,y,g,w,e[Mt[E]],Ht[0],Dt[E])):E<32?(I=ii(r,n,i,a,f,e[Ut[E]],$t[1],Nt[E]),v=oi(u,l,y,g,w,e[Mt[E]],Ht[1],Dt[E])):E<48?(I=si(r,n,i,a,f,e[Ut[E]],$t[2],Nt[E]),v=si(u,l,y,g,w,e[Mt[E]],Ht[2],Dt[E])):E<64?(I=oi(r,n,i,a,f,e[Ut[E]],$t[3],Nt[E]),v=ii(u,l,y,g,w,e[Mt[E]],Ht[3],Dt[E])):(I=ai(r,n,i,a,f,e[Ut[E]],$t[4],Nt[E]),v=ni(u,l,y,g,w,e[Mt[E]],Ht[4],Dt[E])),r=f,f=a,a=ut(i,10),i=n,n=I,u=w,w=g,g=ut(y,10),y=l,l=v}var P=this._b+i+g|0;this._b=this._c+a+w|0,this._c=this._d+f+u|0,this._d=this._e+r+l|0,this._e=this._a+n+y|0,this._a=P};Br.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=Wr.alloc?Wr.alloc(20):new Wr(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 ut(e,t){return e<<t|e>>>32-t}function ni(e,t,r,n,i,a,f,u){return ut(e+(t^r^n)+a+f|0,u)+i|0}function ii(e,t,r,n,i,a,f,u){return ut(e+(t&r|~t&n)+a+f|0,u)+i|0}function si(e,t,r,n,i,a,f,u){return ut(e+((t|~r)^n)+a+f|0,u)+i|0}function oi(e,t,r,n,i,a,f,u){return ut(e+(t&n|r&~n)+a+f|0,u)+i|0}function ai(e,t,r,n,i,a,f,u){return ut(e+(t^(r|~n))+a+f|0,u)+i|0}var xu=Br,xs={exports:{}},vs=Be.Buffer;function Sr(e,t){this._block=vs.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}Sr.prototype.update=function(e,t){typeof e=="string"&&(t=t||"utf8",e=vs.from(e,t));for(var r=this._block,n=this._blockSize,i=e.length,a=this._len,f=0;f<i;){for(var u=a%n,l=Math.min(i-f,n-u),y=0;y<l;y++)r[u+y]=e[f+y];a+=l,f+=l,a%n===0&&this._update(r)}return this._len+=i,this};Sr.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 a=this._hash();return e?a.toString(e):a};Sr.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var Rt=Sr,vu=me,Es=Rt,Eu=Be.Buffer,Bu=[1518500249,1859775393,-1894007588,-899497514],Su=new Array(80);function Jt(){this.init(),this._w=Su,Es.call(this,64,56)}vu(Jt,Es);Jt.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Iu(e){return e<<5|e>>>27}function Au(e){return e<<30|e>>>2}function Ru(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}Jt.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,a=this._d|0,f=this._e|0,u=0;u<16;++u)t[u]=e.readInt32BE(u*4);for(;u<80;++u)t[u]=t[u-3]^t[u-8]^t[u-14]^t[u-16];for(var l=0;l<80;++l){var y=~~(l/20),g=Iu(r)+Ru(y,n,i,a)+f+t[l]+Bu[y]|0;f=a,a=i,i=Au(n),n=r,r=g}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=a+this._d|0,this._e=f+this._e|0};Jt.prototype._hash=function(){var e=Eu.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 Tu=Jt,Pu=me,Bs=Rt,ku=Be.Buffer,Cu=[1518500249,1859775393,-1894007588,-899497514],Lu=new Array(80);function Xt(){this.init(),this._w=Lu,Bs.call(this,64,56)}Pu(Xt,Bs);Xt.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Ou(e){return e<<1|e>>>31}function Fu(e){return e<<5|e>>>27}function Uu(e){return e<<30|e>>>2}function Mu(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}Xt.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,a=this._d|0,f=this._e|0,u=0;u<16;++u)t[u]=e.readInt32BE(u*4);for(;u<80;++u)t[u]=Ou(t[u-3]^t[u-8]^t[u-14]^t[u-16]);for(var l=0;l<80;++l){var y=~~(l/20),g=Fu(r)+Mu(y,n,i,a)+f+t[l]+Cu[y]|0;f=a,a=i,i=Uu(n),n=r,r=g}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=a+this._d|0,this._e=f+this._e|0};Xt.prototype._hash=function(){var e=ku.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 Nu=Xt,Du=me,Ss=Rt,$u=Be.Buffer,Hu=[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],zu=new Array(64);function Qt(){this.init(),this._w=zu,Ss.call(this,64,56)}Du(Qt,Ss);Qt.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 ju(e,t,r){return r^e&(t^r)}function Gu(e,t,r){return e&t|r&(e|t)}function qu(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function Wu(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function Vu(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function Ku(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}Qt.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,a=this._d|0,f=this._e|0,u=this._f|0,l=this._g|0,y=this._h|0,g=0;g<16;++g)t[g]=e.readInt32BE(g*4);for(;g<64;++g)t[g]=Ku(t[g-2])+t[g-7]+Vu(t[g-15])+t[g-16]|0;for(var w=0;w<64;++w){var E=y+Wu(f)+ju(f,u,l)+Hu[w]+t[w]|0,I=qu(r)+Gu(r,n,i)|0;y=l,l=u,u=f,f=a+E|0,a=i,i=n,n=r,r=E+I|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=a+this._d|0,this._e=f+this._e|0,this._f=u+this._f|0,this._g=l+this._g|0,this._h=y+this._h|0};Qt.prototype._hash=function(){var e=$u.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 Is=Qt,Yu=me,Ju=Is,Xu=Rt,Qu=Be.Buffer,Zu=new Array(64);function Ir(){this.init(),this._w=Zu,Xu.call(this,64,56)}Yu(Ir,Ju);Ir.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};Ir.prototype._hash=function(){var e=Qu.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 ec=Ir,tc=me,As=Rt,rc=Be.Buffer,fi=[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],nc=new Array(160);function Zt(){this.init(),this._w=nc,As.call(this,128,112)}tc(Zt,As);Zt.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 ui(e,t,r){return r^e&(t^r)}function ci(e,t,r){return e&t|r&(e|t)}function li(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function hi(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function ic(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function sc(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function oc(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function ac(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function ue(e,t){return e>>>0<t>>>0?1:0}Zt.prototype._update=function(e){for(var t=this._w,r=this._ah|0,n=this._bh|0,i=this._ch|0,a=this._dh|0,f=this._eh|0,u=this._fh|0,l=this._gh|0,y=this._hh|0,g=this._al|0,w=this._bl|0,E=this._cl|0,I=this._dl|0,v=this._el|0,P=this._fl|0,T=this._gl|0,k=this._hl|0,F=0;F<32;F+=2)t[F]=e.readInt32BE(F*4),t[F+1]=e.readInt32BE(F*4+4);for(;F<160;F+=2){var O=t[F-30],L=t[F-15*2+1],U=ic(O,L),S=sc(L,O);O=t[F-2*2],L=t[F-2*2+1];var z=oc(O,L),N=ac(L,O),$=t[F-7*2],oe=t[F-7*2+1],Pe=t[F-16*2],Ge=t[F-16*2+1],fe=S+oe|0,ve=U+$+ue(fe,S)|0;fe=fe+N|0,ve=ve+z+ue(fe,N)|0,fe=fe+Ge|0,ve=ve+Pe+ue(fe,Ge)|0,t[F]=ve,t[F+1]=fe}for(var Ee=0;Ee<160;Ee+=2){ve=t[Ee],fe=t[Ee+1];var tt=ci(r,n,i),ke=ci(g,w,E),qe=li(r,g),Ce=li(g,r),We=hi(f,v),Z=hi(v,f),ae=fi[Ee],Se=fi[Ee+1],Ve=ui(f,u,l),Me=ui(v,P,T),_=k+Z|0,m=y+We+ue(_,k)|0;_=_+Me|0,m=m+Ve+ue(_,Me)|0,_=_+Se|0,m=m+ae+ue(_,Se)|0,_=_+fe|0,m=m+ve+ue(_,fe)|0;var R=Ce+ke|0,D=qe+tt+ue(R,Ce)|0;y=l,k=T,l=u,T=P,u=f,P=v,v=I+_|0,f=a+m+ue(v,I)|0,a=i,I=E,i=n,E=w,n=r,w=g,g=_+R|0,r=m+D+ue(g,_)|0}this._al=this._al+g|0,this._bl=this._bl+w|0,this._cl=this._cl+E|0,this._dl=this._dl+I|0,this._el=this._el+v|0,this._fl=this._fl+P|0,this._gl=this._gl+T|0,this._hl=this._hl+k|0,this._ah=this._ah+r+ue(this._al,g)|0,this._bh=this._bh+n+ue(this._bl,w)|0,this._ch=this._ch+i+ue(this._cl,E)|0,this._dh=this._dh+a+ue(this._dl,I)|0,this._eh=this._eh+f+ue(this._el,v)|0,this._fh=this._fh+u+ue(this._fl,P)|0,this._gh=this._gh+l+ue(this._gl,T)|0,this._hh=this._hh+y+ue(this._hl,k)|0};Zt.prototype._hash=function(){var e=rc.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 Rs=Zt,fc=me,uc=Rs,cc=Rt,lc=Be.Buffer,hc=new Array(160);function Ar(){this.init(),this._w=hc,cc.call(this,128,112)}fc(Ar,uc);Ar.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};Ar.prototype._hash=function(){var e=lc.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 dc=Ar,lt=xs.exports=function(t){t=t.toLowerCase();var r=lt[t];if(!r)throw new Error(t+" is not supported (we accept pull requests)");return new r};lt.sha=Tu;lt.sha1=Nu;lt.sha224=ec;lt.sha256=Is;lt.sha384=dc;lt.sha512=Rs;var pc=xs.exports,Ts=Be.Buffer,Ps=xn.Transform,bc=hr.StringDecoder,yc=me;function Le(e){Ps.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}yc(Le,Ps);Le.prototype.update=function(e,t,r){typeof e=="string"&&(e=Ts.from(e,t));var n=this._update(e);return this.hashMode?this:(r&&(n=this._toString(n,r)),n)};Le.prototype.setAutoPadding=function(){};Le.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")};Le.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")};Le.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")};Le.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)}};Le.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(r){t=r}e(t)};Le.prototype._finalOrDigest=function(e){var t=this.__final()||Ts.alloc(0);return e&&(t=this._toString(t,e,!0)),t};Le.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new bc(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 gc=Le,mc=me,wc=mu,_c=xu,xc=pc,ks=gc;function Rr(e){ks.call(this,"digest"),this._hash=e}mc(Rr,ks);Rr.prototype._update=function(e){this._hash.update(e)};Rr.prototype._final=function(){return this._hash.digest()};var vc=function(t){return t=t.toLowerCase(),t==="md5"?new wc:t==="rmd160"||t==="ripemd160"?new _c:new Rr(xc(t))},rr=Be.Buffer;function Ec(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),a=i.charCodeAt(0);if(t[a]!==255)throw new TypeError(i+" is ambiguous");t[a]=n}var f=e.length,u=e.charAt(0),l=Math.log(f)/Math.log(256),y=Math.log(256)/Math.log(f);function g(I){if((Array.isArray(I)||I instanceof Uint8Array)&&(I=rr.from(I)),!rr.isBuffer(I))throw new TypeError("Expected Buffer");if(I.length===0)return"";for(var v=0,P=0,T=0,k=I.length;T!==k&&I[T]===0;)T++,v++;for(var F=(k-T)*y+1>>>0,O=new Uint8Array(F);T!==k;){for(var L=I[T],U=0,S=F-1;(L!==0||U<P)&&S!==-1;S--,U++)L+=256*O[S]>>>0,O[S]=L%f>>>0,L=L/f>>>0;if(L!==0)throw new Error("Non-zero carry");P=U,T++}for(var z=F-P;z!==F&&O[z]===0;)z++;for(var N=u.repeat(v);z<F;++z)N+=e.charAt(O[z]);return N}function w(I){if(typeof I!="string")throw new TypeError("Expected String");if(I.length===0)return rr.alloc(0);for(var v=0,P=0,T=0;I[v]===u;)P++,v++;for(var k=(I.length-v)*l+1>>>0,F=new Uint8Array(k);v<I.length;){var O=t[I.charCodeAt(v)];if(O===255)return;for(var L=0,U=k-1;(O!==0||L<T)&&U!==-1;U--,L++)O+=f*F[U]>>>0,F[U]=O%256>>>0,O=O/256>>>0;if(O!==0)throw new Error("Non-zero carry");T=L,v++}for(var S=k-T;S!==k&&F[S]===0;)S++;var z=rr.allocUnsafe(P+(k-S));z.fill(0,0,P);for(var N=P;S!==k;)z[N++]=F[S++];return z}function E(I){var v=w(I);if(v)return v;throw new Error("Non-base"+f+" character")}return{encode:g,decodeUnsafe:w,decode:E}}var Bc=Ec,Sc=Bc,Ic="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Ac=Sc(Ic),Vr=Ac,Rc=Be.Buffer,Tc=function(e){function t(a){var f=e(a);return Vr.encode(Rc.concat([a,f],a.length+4))}function r(a){var f=a.slice(0,-4),u=a.slice(-4),l=e(f);if(!(u[0]^l[0]|u[1]^l[1]|u[2]^l[2]|u[3]^l[3]))return f}function n(a){var f=Vr.decodeUnsafe(a);if(f)return r(f)}function i(a){var f=Vr.decode(a),u=r(f);if(!u)throw new Error("Invalid checksum");return u}return{encode:t,decode:i,decodeUnsafe:n}},di=vc,Pc=Tc;function kc(e){var t=di("sha256").update(e).digest();return di("sha256").update(t).digest()}var Cc=Pc(kc),nn=Cc;function Cs(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 sn(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 Lc(e,t){return Cs(nn.decode(e),t)}function Oc(e,t,r){return typeof e=="number"?nn.encode(sn(e,t,r)):nn.encode(sn(e.version,e.privateKey,e.compressed))}var Fc={decode:Lc,decodeRaw:Cs,encode:Oc,encodeRaw:sn},Tr={};Object.defineProperty(Tr,"__esModule",{value:!0});Tr.testEcc=void 0;const H=e=>Buffer.from(e,"hex");function Uc(e){X(e.isPoint(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),X(!e.isPoint(H("030000000000000000000000000000000000000000000000000000000000000005"))),X(e.isPrivate(H("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),X(e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),X(!e.isPrivate(H("0000000000000000000000000000000000000000000000000000000000000000"))),X(!e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),X(!e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),X(Buffer.from(e.privateAdd(H("0000000000000000000000000000000000000000000000000000000000000001"),H("0000000000000000000000000000000000000000000000000000000000000000"))).equals(H("0000000000000000000000000000000000000000000000000000000000000001"))),X(e.privateAdd(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),H("0000000000000000000000000000000000000000000000000000000000000003"))===null),X(Buffer.from(e.privateAdd(H("e211078564db65c3ce7704f08262b1f38f1ef412ad15b5ac2d76657a63b2c500"),H("b51fbb69051255d1becbd683de5848242a89c229348dd72896a87ada94ae8665"))).equals(H("9730c2ee69edbb958d42db7460bafa18fef9d955325aec99044c81c8282b0a24"))),X(Buffer.from(e.privateNegate(H("0000000000000000000000000000000000000000000000000000000000000001"))).equals(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),X(Buffer.from(e.privateNegate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"))).equals(H("0000000000000000000000000000000000000000000000000000000000000003"))),X(Buffer.from(e.privateNegate(H("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(H("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792"))),X(Buffer.from(e.pointCompress(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!0)).equals(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),X(Buffer.from(e.pointCompress(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!1)).equals(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),X(Buffer.from(e.pointCompress(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!0)).equals(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),X(Buffer.from(e.pointCompress(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!1)).equals(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),X(Buffer.from(e.pointFromScalar(H("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(H("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),X(e.xOnlyPointAddTweak(H("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))===null);let t=e.xOnlyPointAddTweak(H("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),H("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));X(Buffer.from(t.xOnlyPubkey).equals(H("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&t.parity===1),t=e.xOnlyPointAddTweak(H("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),H("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47")),X(Buffer.from(t.xOnlyPubkey).equals(H("9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"))&&t.parity===0),X(Buffer.from(e.sign(H("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))).equals(H("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),X(e.verify(H("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),H("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),H("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),e.signSchnorr&&X(Buffer.from(e.signSchnorr(H("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),H("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),H("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906"))).equals(H("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),e.verifySchnorr&&X(e.verifySchnorr(H("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),H("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),H("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}Tr.testEcc=Uc;function X(e){if(!e)throw new Error("ecc library invalid")}Object.defineProperty(vt,"__esModule",{value:!0});vt.ECPairFactory=vt.networks=void 0;const on=Et;vt.networks=on;const _e=qi,Mc=cf,pi=Fc,Nc=Tr,Kr=_e.typeforce.maybe(_e.typeforce.compile({compressed:_e.maybe(_e.Boolean),network:_e.maybe(_e.Network)})),Dc=e=>e.length===32?e:e.slice(1,33);function $c(e){(0,Nc.testEcc)(e);function t(u){return e.isPoint(u)}function r(u,l){if(_e.typeforce(_e.Buffer256bit,u),!e.isPrivate(u))throw new TypeError("Private key not in range [1, n)");return _e.typeforce(Kr,l),new f(u,void 0,l)}function n(u,l){return _e.typeforce(e.isPoint,u),_e.typeforce(Kr,l),new f(void 0,u,l)}function i(u,l){const y=pi.decode(u),g=y.version;if(_e.Array(l)){if(l=l.filter(w=>g===w.wif).pop(),!l)throw new Error("Unknown network version")}else if(l=l||on.bitcoin,g!==l.wif)throw new Error("Invalid network version");return r(y.privateKey,{compressed:y.compressed,network:l})}function a(u){_e.typeforce(Kr,u),u===void 0&&(u={});const l=u.rng||Mc;let y;do y=l(32),_e.typeforce(_e.Buffer256bit,y);while(!e.isPrivate(y));return r(y,u)}class f{constructor(l,y,g){pt(this,"__D");pt(this,"__Q");pt(this,"compressed");pt(this,"network");pt(this,"lowR");this.__D=l,this.__Q=y,this.lowR=!1,g===void 0&&(g={}),this.compressed=g.compressed===void 0?!0:g.compressed,this.network=g.network||on.bitcoin,y!==void 0&&(this.__Q=Buffer.from(e.pointCompress(y,this.compressed)))}get privateKey(){return this.__D}get publicKey(){if(!this.__Q){const l=e.pointFromScalar(this.__D,this.compressed);this.__Q=Buffer.from(l)}return this.__Q}toWIF(){if(!this.__D)throw new Error("Missing private key");return pi.encode(this.network.wif,this.__D,this.compressed)}tweak(l){return this.privateKey?this.tweakFromPrivateKey(l):this.tweakFromPublicKey(l)}sign(l,y){if(!this.__D)throw new Error("Missing private key");if(y===void 0&&(y=this.lowR),y===!1)return Buffer.from(e.sign(l,this.__D));{let g=e.sign(l,this.__D);const w=Buffer.alloc(32,0);let E=0;for(;g[0]>127;)E++,w.writeUIntLE(E,0,6),g=e.sign(l,this.__D,w);return Buffer.from(g)}}signSchnorr(l){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(l,this.privateKey))}verify(l,y){return e.verify(l,this.publicKey,y)}verifySchnorr(l,y){if(!e.verifySchnorr)throw new Error("verifySchnorr not supported by ecc library");return e.verifySchnorr(l,this.publicKey.subarray(1,33),y)}tweakFromPublicKey(l){const y=Dc(this.publicKey),g=e.xOnlyPointAddTweak(y,l);if(!g||g.xOnlyPubkey===null)throw new Error("Cannot tweak public key!");const w=Buffer.from([g.parity===0?2:3]);return n(Buffer.concat([w,g.xOnlyPubkey]),{network:this.network,compressed:this.compressed})}tweakFromPrivateKey(l){const g=this.publicKey[0]===3||this.publicKey[0]===4&&(this.publicKey[64]&1)===1?e.privateNegate(this.privateKey):this.privateKey,w=e.privateAdd(g,l);if(!w)throw new Error("Invalid tweaked private key!");return r(Buffer.from(w),{network:this.network,compressed:this.compressed})}}return{isPoint:t,fromPrivateKey:r,fromPublicKey:n,fromWIF:i,makeRandom:a}}vt.ECPairFactory=$c;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.networks=e.ECPairFactory=e.default=void 0;var t=vt;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}})})(Gi);class pr{constructor(t){this.privKey=t}static fromPrivKey(t){return new pr(C.trim0x(t))}static async fromWalletClient(t){if(!t.account)return C.Err("No account found");try{const r=await t.signTypedData({account:t.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:"WBTC GARDEN",version:"1"},primaryType:"Data",message:{Message:"Initialize your swap",Version:"1.0.2",Nonce:1n}});return C.Ok(new pr(C.trim0x(He.sha256(r))))}catch(r){return C.Err("Failed to initialize: "+r)}}getMasterPrivKey(){return this.privKey}generateSecret(t){const r=this.signMessage(t),n=He.sha256(ge.with0x(r)),i=He.sha256(n);return C.Ok({secret:n,secretHash:i})}signMessage(t){const r=Gi.ECPairFactory(_t),n="Garden.fi"+t.toString(),i=Buffer.from(n,"utf8"),a=He.sha256(i),f=Buffer.from(C.trim0x(this.privKey),"hex");if(f.length!==32)throw new Error("Invalid private key length. Expected 32 bytes.");return r.fromPrivateKey(f).sign(Buffer.from(C.trim0x(a),"hex")).toString("hex")}}class Hc{constructor(t){this.quoteUrl=new ge.Url("/quote",t)}async getQuote(t,r,n=!1){try{const i=this.quoteUrl.addSearchParams({order_pair:t,amount:r.toString(),exact_out:n.toString()}),a=await C.Fetcher.get(i);return a.error?C.Err(a.error):a.result?C.Ok(a.result):C.Err("GetQuote: Unexpected error, result is undefined")}catch(i){return C.Err("GetQuote:",String(i))}}async getAttestedQuote(t){try{const r=await C.Fetcher.post(this.quoteUrl.endpoint("/attested").toString(),{body:JSON.stringify(t),headers:{"Content-Type":"application/json"}});return r.error?C.Err(r.error):r.result?C.Ok(r.result):C.Err("GetAttestedQuote: Unexpected error, result is undefined")}catch(r){return console.log("error :",r),C.Err("GetAttestedQuote:",String(r))}}}exports.EvmRelay=ji;exports.Garden=za;exports.ParseOrderStatus=Hi;exports.ParseSwapStatus=fr;exports.Quote=Hc;exports.SecretManager=pr;exports.parseAction=zi;exports.switchOrAddNetwork=Ca;
31
+ Use Chrome, Firefox or Internet Explorer 11`)}var ff=Be.Buffer,lr=Qe.crypto||Qe.msCrypto;lr&&lr.getRandomValues?Qr.exports=uf:Qr.exports=af;function uf(e,t){if(e>of)throw new RangeError("requested too many random bytes");var r=ff.allocUnsafe(e);if(e>0)if(e>Ur)for(var n=0;n<e;n+=Ur)lr.getRandomValues(r.slice(n,n+Ur));else lr.getRandomValues(r);return typeof t=="function"?process.nextTick(function(){t(null,r)}):r}var cf=Qr.exports,en={exports:{}};typeof Object.create=="function"?en.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:en.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 me=en.exports,tn={exports:{}},_n={exports:{}},wt=typeof Reflect=="object"?Reflect:null,zn=wt&&typeof wt.apply=="function"?wt.apply:function(t,r,n){return Function.prototype.apply.call(t,r,n)},nr;wt&&typeof wt.ownKeys=="function"?nr=wt.ownKeys:Object.getOwnPropertySymbols?nr=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:nr=function(t){return Object.getOwnPropertyNames(t)};function lf(e){console&&console.warn&&console.warn(e)}var Zi=Number.isNaN||function(t){return t!==t};function K(){K.init.call(this)}_n.exports=K;_n.exports.once=bf;K.EventEmitter=K;K.prototype._events=void 0;K.prototype._eventsCount=0;K.prototype._maxListeners=void 0;var jn=10;function wr(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(K,"defaultMaxListeners",{enumerable:!0,get:function(){return jn},set:function(e){if(typeof e!="number"||e<0||Zi(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");jn=e}});K.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};K.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||Zi(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 es(e){return e._maxListeners===void 0?K.defaultMaxListeners:e._maxListeners}K.prototype.getMaxListeners=function(){return es(this)};K.prototype.emit=function(t){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=t==="error",a=this._events;if(a!==void 0)i=i&&a.error===void 0;else if(!i)return!1;if(i){var f;if(r.length>0&&(f=r[0]),f instanceof Error)throw f;var u=new Error("Unhandled error."+(f?" ("+f.message+")":""));throw u.context=f,u}var l=a[t];if(l===void 0)return!1;if(typeof l=="function")zn(l,this,r);else for(var y=l.length,g=ss(l,y),n=0;n<y;++n)zn(g[n],this,r);return!0};function ts(e,t,r,n){var i,a,f;if(wr(r),a=e._events,a===void 0?(a=e._events=Object.create(null),e._eventsCount=0):(a.newListener!==void 0&&(e.emit("newListener",t,r.listener?r.listener:r),a=e._events),f=a[t]),f===void 0)f=a[t]=r,++e._eventsCount;else if(typeof f=="function"?f=a[t]=n?[r,f]:[f,r]:n?f.unshift(r):f.push(r),i=es(e),i>0&&f.length>i&&!f.warned){f.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+f.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=f.length,lf(u)}return e}K.prototype.addListener=function(t,r){return ts(this,t,r,!1)};K.prototype.on=K.prototype.addListener;K.prototype.prependListener=function(t,r){return ts(this,t,r,!0)};function hf(){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 rs(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=hf.bind(n);return i.listener=r,n.wrapFn=i,i}K.prototype.once=function(t,r){return wr(r),this.on(t,rs(this,t,r)),this};K.prototype.prependOnceListener=function(t,r){return wr(r),this.prependListener(t,rs(this,t,r)),this};K.prototype.removeListener=function(t,r){var n,i,a,f,u;if(wr(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(a=-1,f=n.length-1;f>=0;f--)if(n[f]===r||n[f].listener===r){u=n[f].listener,a=f;break}if(a<0)return this;a===0?n.shift():df(n,a),n.length===1&&(i[t]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",t,u||r)}return this};K.prototype.off=K.prototype.removeListener;K.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 a=Object.keys(n),f;for(i=0;i<a.length;++i)f=a[i],f!=="removeListener"&&this.removeAllListeners(f);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 ns(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?pf(i):ss(i,i.length)}K.prototype.listeners=function(t){return ns(this,t,!0)};K.prototype.rawListeners=function(t){return ns(this,t,!1)};K.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):is.call(e,t)};K.prototype.listenerCount=is;function is(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}K.prototype.eventNames=function(){return this._eventsCount>0?nr(this._events):[]};function ss(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function df(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function pf(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}function bf(e,t){return new Promise(function(r,n){function i(f){e.removeListener(t,a),n(f)}function a(){typeof e.removeListener=="function"&&e.removeListener("error",i),r([].slice.call(arguments))}os(e,t,a,{once:!0}),t!=="error"&&yf(e,i,{once:!0})})}function yf(e,t,r){typeof e.on=="function"&&os(e,"error",t,r)}function os(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(a){n.once&&e.removeEventListener(t,i),r(a)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}var as=_n.exports,fs=as.EventEmitter;const gf={},mf=Object.freeze(Object.defineProperty({__proto__:null,default:gf},Symbol.toStringTag,{value:"Module"})),xn=ja(mf);var Mr,Gn;function wf(){if(Gn)return Mr;Gn=1;function e(v,P){var T=Object.keys(v);if(Object.getOwnPropertySymbols){var k=Object.getOwnPropertySymbols(v);P&&(k=k.filter(function(F){return Object.getOwnPropertyDescriptor(v,F).enumerable})),T.push.apply(T,k)}return T}function t(v){for(var P=1;P<arguments.length;P++){var T=arguments[P]!=null?arguments[P]:{};P%2?e(Object(T),!0).forEach(function(k){r(v,k,T[k])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(T)):e(Object(T)).forEach(function(k){Object.defineProperty(v,k,Object.getOwnPropertyDescriptor(T,k))})}return v}function r(v,P,T){return P=f(P),P in v?Object.defineProperty(v,P,{value:T,enumerable:!0,configurable:!0,writable:!0}):v[P]=T,v}function n(v,P){if(!(v instanceof P))throw new TypeError("Cannot call a class as a function")}function i(v,P){for(var T=0;T<P.length;T++){var k=P[T];k.enumerable=k.enumerable||!1,k.configurable=!0,"value"in k&&(k.writable=!0),Object.defineProperty(v,f(k.key),k)}}function a(v,P,T){return P&&i(v.prototype,P),Object.defineProperty(v,"prototype",{writable:!1}),v}function f(v){var P=u(v,"string");return typeof P=="symbol"?P:String(P)}function u(v,P){if(typeof v!="object"||v===null)return v;var T=v[Symbol.toPrimitive];if(T!==void 0){var k=T.call(v,P||"default");if(typeof k!="object")return k;throw new TypeError("@@toPrimitive must return a primitive value.")}return(P==="string"?String:Number)(v)}var l=At,y=l.Buffer,g=xn,w=g.inspect,E=w&&w.custom||"inspect";function I(v,P,T){y.prototype.copy.call(v,P,T)}return Mr=function(){function v(){n(this,v),this.head=null,this.tail=null,this.length=0}return a(v,[{key:"push",value:function(T){var k={data:T,next:null};this.length>0?this.tail.next=k:this.head=k,this.tail=k,++this.length}},{key:"unshift",value:function(T){var k={data:T,next:this.head};this.length===0&&(this.tail=k),this.head=k,++this.length}},{key:"shift",value:function(){if(this.length!==0){var T=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,T}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(T){if(this.length===0)return"";for(var k=this.head,F=""+k.data;k=k.next;)F+=T+k.data;return F}},{key:"concat",value:function(T){if(this.length===0)return y.alloc(0);for(var k=y.allocUnsafe(T>>>0),F=this.head,O=0;F;)I(F.data,k,O),O+=F.data.length,F=F.next;return k}},{key:"consume",value:function(T,k){var F;return T<this.head.data.length?(F=this.head.data.slice(0,T),this.head.data=this.head.data.slice(T)):T===this.head.data.length?F=this.shift():F=k?this._getString(T):this._getBuffer(T),F}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(T){var k=this.head,F=1,O=k.data;for(T-=O.length;k=k.next;){var L=k.data,U=T>L.length?L.length:T;if(U===L.length?O+=L:O+=L.slice(0,T),T-=U,T===0){U===L.length?(++F,k.next?this.head=k.next:this.head=this.tail=null):(this.head=k,k.data=L.slice(U));break}++F}return this.length-=F,O}},{key:"_getBuffer",value:function(T){var k=y.allocUnsafe(T),F=this.head,O=1;for(F.data.copy(k),T-=F.data.length;F=F.next;){var L=F.data,U=T>L.length?L.length:T;if(L.copy(k,k.length-T,0,U),T-=U,T===0){U===L.length?(++O,F.next?this.head=F.next:this.head=this.tail=null):(this.head=F,F.data=L.slice(U));break}++O}return this.length-=O,k}},{key:E,value:function(T,k){return w(this,t(t({},k),{},{depth:0,customInspect:!1}))}}]),v}(),Mr}function _f(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(rn,this,e)):process.nextTick(rn,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(a){!t&&a?r._writableState?r._writableState.errorEmitted?process.nextTick(ir,r):(r._writableState.errorEmitted=!0,process.nextTick(qn,r,a)):process.nextTick(qn,r,a):t?(process.nextTick(ir,r),t(a)):process.nextTick(ir,r)}),this)}function qn(e,t){rn(e,t),ir(e)}function ir(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function xf(){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 rn(e,t){e.emit("error",t)}function vf(e,t){var r=e._readableState,n=e._writableState;r&&r.autoDestroy||n&&n.autoDestroy?e.destroy(t):e.emit("error",t)}var us={destroy:_f,undestroy:xf,errorOrDestroy:vf},ct={};function Ef(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var cs={};function Te(e,t,r){r||(r=Error);function n(a,f,u){return typeof t=="string"?t:t(a,f,u)}var i=function(a){Ef(f,a);function f(u,l,y){return a.call(this,n(u,l,y))||this}return f}(r);i.prototype.name=r.name,i.prototype.code=e,cs[e]=i}function Wn(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 Bf(e,t,r){return e.substr(0,t.length)===t}function Sf(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function If(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}Te("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError);Te("ERR_INVALID_ARG_TYPE",function(e,t,r){var n;typeof t=="string"&&Bf(t,"not ")?(n="must not be",t=t.replace(/^not /,"")):n="must be";var i;if(Sf(e," argument"))i="The ".concat(e," ").concat(n," ").concat(Wn(t,"type"));else{var a=If(e,".")?"property":"argument";i='The "'.concat(e,'" ').concat(a," ").concat(n," ").concat(Wn(t,"type"))}return i+=". Received type ".concat(typeof r),i},TypeError);Te("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");Te("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"});Te("ERR_STREAM_PREMATURE_CLOSE","Premature close");Te("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"});Te("ERR_MULTIPLE_CALLBACK","Callback called multiple times");Te("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");Te("ERR_STREAM_WRITE_AFTER_END","write after end");Te("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);Te("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError);Te("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");ct.codes=cs;var Af=ct.codes.ERR_INVALID_OPT_VALUE;function Rf(e,t,r){return e.highWaterMark!=null?e.highWaterMark:t?e[r]:null}function Tf(e,t,r,n){var i=Rf(t,n,r);if(i!=null){if(!(isFinite(i)&&Math.floor(i)===i)||i<0){var a=n?r:"highWaterMark";throw new Af(a,i)}return Math.floor(i)}return e.objectMode?16:16*1024}var ls={getHighWaterMark:Tf},Pf=kf;function kf(e,t){if(Nr("noDeprecation"))return e;var r=!1;function n(){if(!r){if(Nr("throwDeprecation"))throw new Error(t);Nr("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}return n}function Nr(e){try{if(!Qe.localStorage)return!1}catch{return!1}var t=Qe.localStorage[e];return t==null?!1:String(t).toLowerCase()==="true"}var Dr,Vn;function hs(){if(Vn)return Dr;Vn=1,Dr=N;function e(_){var m=this;this.next=null,this.entry=null,this.finish=function(){Me(m,_)}}var t;N.WritableState=S;var r={deprecate:Pf},n=fs,i=At.Buffer,a=(typeof Qe<"u"?Qe:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function f(_){return i.from(_)}function u(_){return i.isBuffer(_)||_ instanceof a}var l=us,y=ls,g=y.getHighWaterMark,w=ct.codes,E=w.ERR_INVALID_ARG_TYPE,I=w.ERR_METHOD_NOT_IMPLEMENTED,v=w.ERR_MULTIPLE_CALLBACK,P=w.ERR_STREAM_CANNOT_PIPE,T=w.ERR_STREAM_DESTROYED,k=w.ERR_STREAM_NULL_VALUES,F=w.ERR_STREAM_WRITE_AFTER_END,O=w.ERR_UNKNOWN_ENCODING,L=l.errorOrDestroy;me(N,n);function U(){}function S(_,m,R){t=t||Bt(),_=_||{},typeof R!="boolean"&&(R=m instanceof t),this.objectMode=!!_.objectMode,R&&(this.objectMode=this.objectMode||!!_.writableObjectMode),this.highWaterMark=g(this,_,"writableHighWaterMark",R),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var D=_.decodeStrings===!1;this.decodeStrings=!D,this.defaultEncoding=_.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(j){tt(m,j)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=_.emitClose!==!1,this.autoDestroy=!!_.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new e(this)}S.prototype.getBuffer=function(){for(var m=this.bufferedRequest,R=[];m;)R.push(m),m=m.next;return R},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 z;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(z=Function.prototype[Symbol.hasInstance],Object.defineProperty(N,Symbol.hasInstance,{value:function(m){return z.call(this,m)?!0:this!==N?!1:m&&m._writableState instanceof S}})):z=function(m){return m instanceof this};function N(_){t=t||Bt();var m=this instanceof t;if(!m&&!z.call(N,this))return new N(_);this._writableState=new S(_,this,m),this.writable=!0,_&&(typeof _.write=="function"&&(this._write=_.write),typeof _.writev=="function"&&(this._writev=_.writev),typeof _.destroy=="function"&&(this._destroy=_.destroy),typeof _.final=="function"&&(this._final=_.final)),n.call(this)}N.prototype.pipe=function(){L(this,new P)};function $(_,m){var R=new F;L(_,R),process.nextTick(m,R)}function oe(_,m,R,D){var j;return R===null?j=new k:typeof R!="string"&&!m.objectMode&&(j=new E("chunk",["string","Buffer"],R)),j?(L(_,j),process.nextTick(D,j),!1):!0}N.prototype.write=function(_,m,R){var D=this._writableState,j=!1,d=!D.objectMode&&u(_);return d&&!i.isBuffer(_)&&(_=f(_)),typeof m=="function"&&(R=m,m=null),d?m="buffer":m||(m=D.defaultEncoding),typeof R!="function"&&(R=U),D.ending?$(this,R):(d||oe(this,D,_,R))&&(D.pendingcb++,j=Ge(this,D,d,_,m,R)),j},N.prototype.cork=function(){this._writableState.corked++},N.prototype.uncork=function(){var _=this._writableState;_.corked&&(_.corked--,!_.writing&&!_.corked&&!_.bufferProcessing&&_.bufferedRequest&&Ce(this,_))},N.prototype.setDefaultEncoding=function(m){if(typeof m=="string"&&(m=m.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((m+"").toLowerCase())>-1))throw new O(m);return this._writableState.defaultEncoding=m,this},Object.defineProperty(N.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function Pe(_,m,R){return!_.objectMode&&_.decodeStrings!==!1&&typeof m=="string"&&(m=i.from(m,R)),m}Object.defineProperty(N.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function Ge(_,m,R,D,j,d){if(!R){var p=Pe(m,D,j);D!==p&&(R=!0,j="buffer",D=p)}var A=m.objectMode?1:D.length;m.length+=A;var M=m.length<m.highWaterMark;if(M||(m.needDrain=!0),m.writing||m.corked){var ee=m.lastBufferedRequest;m.lastBufferedRequest={chunk:D,encoding:j,isBuf:R,callback:d,next:null},ee?ee.next=m.lastBufferedRequest:m.bufferedRequest=m.lastBufferedRequest,m.bufferedRequestCount+=1}else fe(_,m,!1,A,D,j,d);return M}function fe(_,m,R,D,j,d,p){m.writelen=D,m.writecb=p,m.writing=!0,m.sync=!0,m.destroyed?m.onwrite(new T("write")):R?_._writev(j,m.onwrite):_._write(j,d,m.onwrite),m.sync=!1}function ve(_,m,R,D,j){--m.pendingcb,R?(process.nextTick(j,D),process.nextTick(Se,_,m),_._writableState.errorEmitted=!0,L(_,D)):(j(D),_._writableState.errorEmitted=!0,L(_,D),Se(_,m))}function Ee(_){_.writing=!1,_.writecb=null,_.length-=_.writelen,_.writelen=0}function tt(_,m){var R=_._writableState,D=R.sync,j=R.writecb;if(typeof j!="function")throw new v;if(Ee(R),m)ve(_,R,D,m,j);else{var d=We(R)||_.destroyed;!d&&!R.corked&&!R.bufferProcessing&&R.bufferedRequest&&Ce(_,R),D?process.nextTick(ke,_,R,d,j):ke(_,R,d,j)}}function ke(_,m,R,D){R||qe(_,m),m.pendingcb--,D(),Se(_,m)}function qe(_,m){m.length===0&&m.needDrain&&(m.needDrain=!1,_.emit("drain"))}function Ce(_,m){m.bufferProcessing=!0;var R=m.bufferedRequest;if(_._writev&&R&&R.next){var D=m.bufferedRequestCount,j=new Array(D),d=m.corkedRequestsFree;d.entry=R;for(var p=0,A=!0;R;)j[p]=R,R.isBuf||(A=!1),R=R.next,p+=1;j.allBuffers=A,fe(_,m,!0,m.length,j,"",d.finish),m.pendingcb++,m.lastBufferedRequest=null,d.next?(m.corkedRequestsFree=d.next,d.next=null):m.corkedRequestsFree=new e(m),m.bufferedRequestCount=0}else{for(;R;){var M=R.chunk,ee=R.encoding,G=R.callback,V=m.objectMode?1:M.length;if(fe(_,m,!1,V,M,ee,G),R=R.next,m.bufferedRequestCount--,m.writing)break}R===null&&(m.lastBufferedRequest=null)}m.bufferedRequest=R,m.bufferProcessing=!1}N.prototype._write=function(_,m,R){R(new I("_write()"))},N.prototype._writev=null,N.prototype.end=function(_,m,R){var D=this._writableState;return typeof _=="function"?(R=_,_=null,m=null):typeof m=="function"&&(R=m,m=null),_!=null&&this.write(_,m),D.corked&&(D.corked=1,this.uncork()),D.ending||Ve(this,D,R),this},Object.defineProperty(N.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function We(_){return _.ending&&_.length===0&&_.bufferedRequest===null&&!_.finished&&!_.writing}function Z(_,m){_._final(function(R){m.pendingcb--,R&&L(_,R),m.prefinished=!0,_.emit("prefinish"),Se(_,m)})}function ae(_,m){!m.prefinished&&!m.finalCalled&&(typeof _._final=="function"&&!m.destroyed?(m.pendingcb++,m.finalCalled=!0,process.nextTick(Z,_,m)):(m.prefinished=!0,_.emit("prefinish")))}function Se(_,m){var R=We(m);if(R&&(ae(_,m),m.pendingcb===0&&(m.finished=!0,_.emit("finish"),m.autoDestroy))){var D=_._readableState;(!D||D.autoDestroy&&D.endEmitted)&&_.destroy()}return R}function Ve(_,m,R){m.ending=!0,Se(_,m),R&&(m.finished?process.nextTick(R):_.once("finish",R)),m.ended=!0,_.writable=!1}function Me(_,m,R){var D=_.entry;for(_.entry=null;D;){var j=D.callback;m.pendingcb--,j(R),D=D.next}m.corkedRequestsFree.next=_}return Object.defineProperty(N.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(m){this._writableState&&(this._writableState.destroyed=m)}}),N.prototype.destroy=l.destroy,N.prototype._undestroy=l.undestroy,N.prototype._destroy=function(_,m){m(_)},Dr}var $r,Kn;function Bt(){if(Kn)return $r;Kn=1;var e=Object.keys||function(y){var g=[];for(var w in y)g.push(w);return g};$r=f;var t=ps(),r=hs();me(f,t);for(var n=e(r.prototype),i=0;i<n.length;i++){var a=n[i];f.prototype[a]||(f.prototype[a]=r.prototype[a])}function f(y){if(!(this instanceof f))return new f(y);t.call(this,y),r.call(this,y),this.allowHalfOpen=!0,y&&(y.readable===!1&&(this.readable=!1),y.writable===!1&&(this.writable=!1),y.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",u)))}Object.defineProperty(f.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(f.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(f.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function u(){this._writableState.ended||process.nextTick(l,this)}function l(y){y.end()}return Object.defineProperty(f.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(g){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=g,this._writableState.destroyed=g)}}),$r}var hr={},vn=Be.Buffer,Yn=vn.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 Cf(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 Lf(e){var t=Cf(e);if(typeof t!="string"&&(vn.isEncoding===Yn||!Yn(e)))throw new Error("Unknown encoding: "+e);return t||e}hr.StringDecoder=Yt;function Yt(e){this.encoding=Lf(e);var t;switch(this.encoding){case"utf16le":this.text=Df,this.end=$f,t=4;break;case"utf8":this.fillLast=Uf,t=4;break;case"base64":this.text=Hf,this.end=zf,t=3;break;default:this.write=jf,this.end=Gf;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=vn.allocUnsafe(t)}Yt.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||""};Yt.prototype.end=Nf;Yt.prototype.text=Mf;Yt.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 Hr(e){return e<=127?0:e>>5===6?2:e>>4===14?3:e>>3===30?4:e>>6===2?-1:-2}function Of(e,t,r){var n=t.length-1;if(n<r)return 0;var i=Hr(t[n]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--n<r||i===-2?0:(i=Hr(t[n]),i>=0?(i>0&&(e.lastNeed=i-2),i):--n<r||i===-2?0:(i=Hr(t[n]),i>=0?(i>0&&(i===2?i=0:e.lastNeed=i-3),i):0))}function Ff(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 Uf(e){var t=this.lastTotal-this.lastNeed,r=Ff(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 Mf(e,t){var r=Of(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 Nf(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t}function Df(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 $f(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 Hf(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 zf(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function jf(e){return e.toString(this.encoding)}function Gf(e){return e&&e.length?this.write(e):""}var Jn=ct.codes.ERR_STREAM_PREMATURE_CLOSE;function qf(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 Wf(){}function Vf(e){return e.setHeader&&typeof e.abort=="function"}function ds(e,t,r){if(typeof t=="function")return ds(e,null,t);t||(t={}),r=qf(r||Wf);var n=t.readable||t.readable!==!1&&e.readable,i=t.writable||t.writable!==!1&&e.writable,a=function(){e.writable||u()},f=e._writableState&&e._writableState.finished,u=function(){i=!1,f=!0,n||r.call(e)},l=e._readableState&&e._readableState.endEmitted,y=function(){n=!1,l=!0,i||r.call(e)},g=function(v){r.call(e,v)},w=function(){var v;if(n&&!l)return(!e._readableState||!e._readableState.ended)&&(v=new Jn),r.call(e,v);if(i&&!f)return(!e._writableState||!e._writableState.ended)&&(v=new Jn),r.call(e,v)},E=function(){e.req.on("finish",u)};return Vf(e)?(e.on("complete",u),e.on("abort",w),e.req?E():e.on("request",E)):i&&!e._writableState&&(e.on("end",a),e.on("close",a)),e.on("end",y),e.on("finish",u),t.error!==!1&&e.on("error",g),e.on("close",w),function(){e.removeListener("complete",u),e.removeListener("abort",w),e.removeListener("request",E),e.req&&e.req.removeListener("finish",u),e.removeListener("end",a),e.removeListener("close",a),e.removeListener("finish",u),e.removeListener("end",y),e.removeListener("error",g),e.removeListener("close",w)}}var En=ds,zr,Xn;function Kf(){if(Xn)return zr;Xn=1;var e;function t(O,L,U){return L=r(L),L in O?Object.defineProperty(O,L,{value:U,enumerable:!0,configurable:!0,writable:!0}):O[L]=U,O}function r(O){var L=n(O,"string");return typeof L=="symbol"?L:String(L)}function n(O,L){if(typeof O!="object"||O===null)return O;var U=O[Symbol.toPrimitive];if(U!==void 0){var S=U.call(O,L||"default");if(typeof S!="object")return S;throw new TypeError("@@toPrimitive must return a primitive value.")}return(L==="string"?String:Number)(O)}var i=En,a=Symbol("lastResolve"),f=Symbol("lastReject"),u=Symbol("error"),l=Symbol("ended"),y=Symbol("lastPromise"),g=Symbol("handlePromise"),w=Symbol("stream");function E(O,L){return{value:O,done:L}}function I(O){var L=O[a];if(L!==null){var U=O[w].read();U!==null&&(O[y]=null,O[a]=null,O[f]=null,L(E(U,!1)))}}function v(O){process.nextTick(I,O)}function P(O,L){return function(U,S){O.then(function(){if(L[l]){U(E(void 0,!0));return}L[g](U,S)},S)}}var T=Object.getPrototypeOf(function(){}),k=Object.setPrototypeOf((e={get stream(){return this[w]},next:function(){var L=this,U=this[u];if(U!==null)return Promise.reject(U);if(this[l])return Promise.resolve(E(void 0,!0));if(this[w].destroyed)return new Promise(function($,oe){process.nextTick(function(){L[u]?oe(L[u]):$(E(void 0,!0))})});var S=this[y],z;if(S)z=new Promise(P(S,this));else{var N=this[w].read();if(N!==null)return Promise.resolve(E(N,!1));z=new Promise(this[g])}return this[y]=z,z}},t(e,Symbol.asyncIterator,function(){return this}),t(e,"return",function(){var L=this;return new Promise(function(U,S){L[w].destroy(null,function(z){if(z){S(z);return}U(E(void 0,!0))})})}),e),T),F=function(L){var U,S=Object.create(k,(U={},t(U,w,{value:L,writable:!0}),t(U,a,{value:null,writable:!0}),t(U,f,{value:null,writable:!0}),t(U,u,{value:null,writable:!0}),t(U,l,{value:L._readableState.endEmitted,writable:!0}),t(U,g,{value:function(N,$){var oe=S[w].read();oe?(S[y]=null,S[a]=null,S[f]=null,N(E(oe,!1))):(S[a]=N,S[f]=$)},writable:!0}),U));return S[y]=null,i(L,function(z){if(z&&z.code!=="ERR_STREAM_PREMATURE_CLOSE"){var N=S[f];N!==null&&(S[y]=null,S[a]=null,S[f]=null,N(z)),S[u]=z;return}var $=S[a];$!==null&&(S[y]=null,S[a]=null,S[f]=null,$(E(void 0,!0))),S[l]=!0}),L.on("readable",v.bind(null,S)),S};return zr=F,zr}var jr,Qn;function Yf(){return Qn||(Qn=1,jr=function(){throw new Error("Readable.from is not available in the browser")}),jr}var Gr,Zn;function ps(){if(Zn)return Gr;Zn=1,Gr=$;var e;$.ReadableState=N,as.EventEmitter;var t=function(p,A){return p.listeners(A).length},r=fs,n=At.Buffer,i=(typeof Qe<"u"?Qe:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function a(d){return n.from(d)}function f(d){return n.isBuffer(d)||d instanceof i}var u=xn,l;u&&u.debuglog?l=u.debuglog("stream"):l=function(){};var y=wf(),g=us,w=ls,E=w.getHighWaterMark,I=ct.codes,v=I.ERR_INVALID_ARG_TYPE,P=I.ERR_STREAM_PUSH_AFTER_EOF,T=I.ERR_METHOD_NOT_IMPLEMENTED,k=I.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,F,O,L;me($,r);var U=g.errorOrDestroy,S=["error","close","destroy","pause","resume"];function z(d,p,A){if(typeof d.prependListener=="function")return d.prependListener(p,A);!d._events||!d._events[p]?d.on(p,A):Array.isArray(d._events[p])?d._events[p].unshift(A):d._events[p]=[A,d._events[p]]}function N(d,p,A){e=e||Bt(),d=d||{},typeof A!="boolean"&&(A=p instanceof e),this.objectMode=!!d.objectMode,A&&(this.objectMode=this.objectMode||!!d.readableObjectMode),this.highWaterMark=E(this,d,"readableHighWaterMark",A),this.buffer=new y,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=d.emitClose!==!1,this.autoDestroy=!!d.autoDestroy,this.destroyed=!1,this.defaultEncoding=d.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,d.encoding&&(F||(F=hr.StringDecoder),this.decoder=new F(d.encoding),this.encoding=d.encoding)}function $(d){if(e=e||Bt(),!(this instanceof $))return new $(d);var p=this instanceof e;this._readableState=new N(d,this,p),this.readable=!0,d&&(typeof d.read=="function"&&(this._read=d.read),typeof d.destroy=="function"&&(this._destroy=d.destroy)),r.call(this)}Object.defineProperty($.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(p){this._readableState&&(this._readableState.destroyed=p)}}),$.prototype.destroy=g.destroy,$.prototype._undestroy=g.undestroy,$.prototype._destroy=function(d,p){p(d)},$.prototype.push=function(d,p){var A=this._readableState,M;return A.objectMode?M=!0:typeof d=="string"&&(p=p||A.defaultEncoding,p!==A.encoding&&(d=n.from(d,p),p=""),M=!0),oe(this,d,p,!1,M)},$.prototype.unshift=function(d){return oe(this,d,null,!0,!1)};function oe(d,p,A,M,ee){l("readableAddChunk",p);var G=d._readableState;if(p===null)G.reading=!1,tt(d,G);else{var V;if(ee||(V=Ge(G,p)),V)U(d,V);else if(G.objectMode||p&&p.length>0)if(typeof p!="string"&&!G.objectMode&&Object.getPrototypeOf(p)!==n.prototype&&(p=a(p)),M)G.endEmitted?U(d,new k):Pe(d,G,p,!0);else if(G.ended)U(d,new P);else{if(G.destroyed)return!1;G.reading=!1,G.decoder&&!A?(p=G.decoder.write(p),G.objectMode||p.length!==0?Pe(d,G,p,!1):Ce(d,G)):Pe(d,G,p,!1)}else M||(G.reading=!1,Ce(d,G))}return!G.ended&&(G.length<G.highWaterMark||G.length===0)}function Pe(d,p,A,M){p.flowing&&p.length===0&&!p.sync?(p.awaitDrain=0,d.emit("data",A)):(p.length+=p.objectMode?1:A.length,M?p.buffer.unshift(A):p.buffer.push(A),p.needReadable&&ke(d)),Ce(d,p)}function Ge(d,p){var A;return!f(p)&&typeof p!="string"&&p!==void 0&&!d.objectMode&&(A=new v("chunk",["string","Buffer","Uint8Array"],p)),A}$.prototype.isPaused=function(){return this._readableState.flowing===!1},$.prototype.setEncoding=function(d){F||(F=hr.StringDecoder);var p=new F(d);this._readableState.decoder=p,this._readableState.encoding=this._readableState.decoder.encoding;for(var A=this._readableState.buffer.head,M="";A!==null;)M+=p.write(A.data),A=A.next;return this._readableState.buffer.clear(),M!==""&&this._readableState.buffer.push(M),this._readableState.length=M.length,this};var fe=1073741824;function ve(d){return d>=fe?d=fe:(d--,d|=d>>>1,d|=d>>>2,d|=d>>>4,d|=d>>>8,d|=d>>>16,d++),d}function Ee(d,p){return d<=0||p.length===0&&p.ended?0:p.objectMode?1:d!==d?p.flowing&&p.length?p.buffer.head.data.length:p.length:(d>p.highWaterMark&&(p.highWaterMark=ve(d)),d<=p.length?d:p.ended?p.length:(p.needReadable=!0,0))}$.prototype.read=function(d){l("read",d),d=parseInt(d,10);var p=this._readableState,A=d;if(d!==0&&(p.emittedReadable=!1),d===0&&p.needReadable&&((p.highWaterMark!==0?p.length>=p.highWaterMark:p.length>0)||p.ended))return l("read: emitReadable",p.length,p.ended),p.length===0&&p.ended?R(this):ke(this),null;if(d=Ee(d,p),d===0&&p.ended)return p.length===0&&R(this),null;var M=p.needReadable;l("need readable",M),(p.length===0||p.length-d<p.highWaterMark)&&(M=!0,l("length less than watermark",M)),p.ended||p.reading?(M=!1,l("reading or ended",M)):M&&(l("do read"),p.reading=!0,p.sync=!0,p.length===0&&(p.needReadable=!0),this._read(p.highWaterMark),p.sync=!1,p.reading||(d=Ee(A,p)));var ee;return d>0?ee=m(d,p):ee=null,ee===null?(p.needReadable=p.length<=p.highWaterMark,d=0):(p.length-=d,p.awaitDrain=0),p.length===0&&(p.ended||(p.needReadable=!0),A!==d&&p.ended&&R(this)),ee!==null&&this.emit("data",ee),ee};function tt(d,p){if(l("onEofChunk"),!p.ended){if(p.decoder){var A=p.decoder.end();A&&A.length&&(p.buffer.push(A),p.length+=p.objectMode?1:A.length)}p.ended=!0,p.sync?ke(d):(p.needReadable=!1,p.emittedReadable||(p.emittedReadable=!0,qe(d)))}}function ke(d){var p=d._readableState;l("emitReadable",p.needReadable,p.emittedReadable),p.needReadable=!1,p.emittedReadable||(l("emitReadable",p.flowing),p.emittedReadable=!0,process.nextTick(qe,d))}function qe(d){var p=d._readableState;l("emitReadable_",p.destroyed,p.length,p.ended),!p.destroyed&&(p.length||p.ended)&&(d.emit("readable"),p.emittedReadable=!1),p.needReadable=!p.flowing&&!p.ended&&p.length<=p.highWaterMark,_(d)}function Ce(d,p){p.readingMore||(p.readingMore=!0,process.nextTick(We,d,p))}function We(d,p){for(;!p.reading&&!p.ended&&(p.length<p.highWaterMark||p.flowing&&p.length===0);){var A=p.length;if(l("maybeReadMore read 0"),d.read(0),A===p.length)break}p.readingMore=!1}$.prototype._read=function(d){U(this,new T("_read()"))},$.prototype.pipe=function(d,p){var A=this,M=this._readableState;switch(M.pipesCount){case 0:M.pipes=d;break;case 1:M.pipes=[M.pipes,d];break;default:M.pipes.push(d);break}M.pipesCount+=1,l("pipe count=%d opts=%j",M.pipesCount,p);var ee=(!p||p.end!==!1)&&d!==process.stdout&&d!==process.stderr,G=ee?Ke:nt;M.endEmitted?process.nextTick(G):A.once("end",G),d.on("unpipe",V);function V(c,s){l("onunpipe"),c===A&&s&&s.hasUnpiped===!1&&(s.hasUnpiped=!0,dt())}function Ke(){l("onend"),d.end()}var ht=Z(A);d.on("drain",ht);var Tt=!1;function dt(){l("cleanup"),d.removeListener("close",Pt),d.removeListener("finish",Ae),d.removeListener("drain",ht),d.removeListener("error",rt),d.removeListener("unpipe",V),A.removeListener("end",Ke),A.removeListener("end",nt),A.removeListener("data",Ie),Tt=!0,M.awaitDrain&&(!d._writableState||d._writableState.needDrain)&&ht()}A.on("data",Ie);function Ie(c){l("ondata");var s=d.write(c);l("dest.write",s),s===!1&&((M.pipesCount===1&&M.pipes===d||M.pipesCount>1&&j(M.pipes,d)!==-1)&&!Tt&&(l("false write response, pause",M.awaitDrain),M.awaitDrain++),A.pause())}function rt(c){l("onerror",c),nt(),d.removeListener("error",rt),t(d,"error")===0&&U(d,c)}z(d,"error",rt);function Pt(){d.removeListener("finish",Ae),nt()}d.once("close",Pt);function Ae(){l("onfinish"),d.removeListener("close",Pt),nt()}d.once("finish",Ae);function nt(){l("unpipe"),A.unpipe(d)}return d.emit("pipe",A),M.flowing||(l("pipe resume"),A.resume()),d};function Z(d){return function(){var A=d._readableState;l("pipeOnDrain",A.awaitDrain),A.awaitDrain&&A.awaitDrain--,A.awaitDrain===0&&t(d,"data")&&(A.flowing=!0,_(d))}}$.prototype.unpipe=function(d){var p=this._readableState,A={hasUnpiped:!1};if(p.pipesCount===0)return this;if(p.pipesCount===1)return d&&d!==p.pipes?this:(d||(d=p.pipes),p.pipes=null,p.pipesCount=0,p.flowing=!1,d&&d.emit("unpipe",this,A),this);if(!d){var M=p.pipes,ee=p.pipesCount;p.pipes=null,p.pipesCount=0,p.flowing=!1;for(var G=0;G<ee;G++)M[G].emit("unpipe",this,{hasUnpiped:!1});return this}var V=j(p.pipes,d);return V===-1?this:(p.pipes.splice(V,1),p.pipesCount-=1,p.pipesCount===1&&(p.pipes=p.pipes[0]),d.emit("unpipe",this,A),this)},$.prototype.on=function(d,p){var A=r.prototype.on.call(this,d,p),M=this._readableState;return d==="data"?(M.readableListening=this.listenerCount("readable")>0,M.flowing!==!1&&this.resume()):d==="readable"&&!M.endEmitted&&!M.readableListening&&(M.readableListening=M.needReadable=!0,M.flowing=!1,M.emittedReadable=!1,l("on readable",M.length,M.reading),M.length?ke(this):M.reading||process.nextTick(Se,this)),A},$.prototype.addListener=$.prototype.on,$.prototype.removeListener=function(d,p){var A=r.prototype.removeListener.call(this,d,p);return d==="readable"&&process.nextTick(ae,this),A},$.prototype.removeAllListeners=function(d){var p=r.prototype.removeAllListeners.apply(this,arguments);return(d==="readable"||d===void 0)&&process.nextTick(ae,this),p};function ae(d){var p=d._readableState;p.readableListening=d.listenerCount("readable")>0,p.resumeScheduled&&!p.paused?p.flowing=!0:d.listenerCount("data")>0&&d.resume()}function Se(d){l("readable nexttick read 0"),d.read(0)}$.prototype.resume=function(){var d=this._readableState;return d.flowing||(l("resume"),d.flowing=!d.readableListening,Ve(this,d)),d.paused=!1,this};function Ve(d,p){p.resumeScheduled||(p.resumeScheduled=!0,process.nextTick(Me,d,p))}function Me(d,p){l("resume",p.reading),p.reading||d.read(0),p.resumeScheduled=!1,d.emit("resume"),_(d),p.flowing&&!p.reading&&d.read(0)}$.prototype.pause=function(){return l("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(l("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function _(d){var p=d._readableState;for(l("flow",p.flowing);p.flowing&&d.read()!==null;);}$.prototype.wrap=function(d){var p=this,A=this._readableState,M=!1;d.on("end",function(){if(l("wrapped end"),A.decoder&&!A.ended){var V=A.decoder.end();V&&V.length&&p.push(V)}p.push(null)}),d.on("data",function(V){if(l("wrapped data"),A.decoder&&(V=A.decoder.write(V)),!(A.objectMode&&V==null)&&!(!A.objectMode&&(!V||!V.length))){var Ke=p.push(V);Ke||(M=!0,d.pause())}});for(var ee in d)this[ee]===void 0&&typeof d[ee]=="function"&&(this[ee]=function(Ke){return function(){return d[Ke].apply(d,arguments)}}(ee));for(var G=0;G<S.length;G++)d.on(S[G],this.emit.bind(this,S[G]));return this._read=function(V){l("wrapped _read",V),M&&(M=!1,d.resume())},this},typeof Symbol=="function"&&($.prototype[Symbol.asyncIterator]=function(){return O===void 0&&(O=Kf()),O(this)}),Object.defineProperty($.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty($.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty($.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(p){this._readableState&&(this._readableState.flowing=p)}}),$._fromList=m,Object.defineProperty($.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function m(d,p){if(p.length===0)return null;var A;return p.objectMode?A=p.buffer.shift():!d||d>=p.length?(p.decoder?A=p.buffer.join(""):p.buffer.length===1?A=p.buffer.first():A=p.buffer.concat(p.length),p.buffer.clear()):A=p.buffer.consume(d,p.decoder),A}function R(d){var p=d._readableState;l("endReadable",p.endEmitted),p.endEmitted||(p.ended=!0,process.nextTick(D,p,d))}function D(d,p){if(l("endReadableNT",d.endEmitted,d.length),!d.endEmitted&&d.length===0&&(d.endEmitted=!0,p.readable=!1,p.emit("end"),d.autoDestroy)){var A=p._writableState;(!A||A.autoDestroy&&A.finished)&&p.destroy()}}typeof Symbol=="function"&&($.from=function(d,p){return L===void 0&&(L=Yf()),L($,d,p)});function j(d,p){for(var A=0,M=d.length;A<M;A++)if(d[A]===p)return A;return-1}return Gr}var bs=je,_r=ct.codes,Jf=_r.ERR_METHOD_NOT_IMPLEMENTED,Xf=_r.ERR_MULTIPLE_CALLBACK,Qf=_r.ERR_TRANSFORM_ALREADY_TRANSFORMING,Zf=_r.ERR_TRANSFORM_WITH_LENGTH_0,xr=Bt();me(je,xr);function eu(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(n===null)return this.emit("error",new Xf);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 je(e){if(!(this instanceof je))return new je(e);xr.call(this,e),this._transformState={afterTransform:eu.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",tu)}function tu(){var e=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(t,r){ei(e,t,r)}):ei(this,null,null)}je.prototype.push=function(e,t){return this._transformState.needTransform=!1,xr.prototype.push.call(this,e,t)};je.prototype._transform=function(e,t,r){r(new Jf("_transform()"))};je.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)}};je.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};je.prototype._destroy=function(e,t){xr.prototype._destroy.call(this,e,function(r){t(r)})};function ei(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new Zf;if(e._transformState.transforming)throw new Qf;return e.push(null)}var ru=jt,ys=bs;me(jt,ys);function jt(e){if(!(this instanceof jt))return new jt(e);ys.call(this,e)}jt.prototype._transform=function(e,t,r){r(null,e)};var qr;function nu(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var gs=ct.codes,iu=gs.ERR_MISSING_ARGS,su=gs.ERR_STREAM_DESTROYED;function ti(e){if(e)throw e}function ou(e){return e.setHeader&&typeof e.abort=="function"}function au(e,t,r,n){n=nu(n);var i=!1;e.on("close",function(){i=!0}),qr===void 0&&(qr=En),qr(e,{readable:t,writable:r},function(f){if(f)return n(f);i=!0,n()});var a=!1;return function(f){if(!i&&!a){if(a=!0,ou(e))return e.abort();if(typeof e.destroy=="function")return e.destroy();n(f||new su("pipe"))}}}function ri(e){e()}function fu(e,t){return e.pipe(t)}function uu(e){return!e.length||typeof e[e.length-1]!="function"?ti:e.pop()}function cu(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=uu(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new iu("streams");var i,a=t.map(function(f,u){var l=u<t.length-1,y=u>0;return au(f,l,y,function(g){i||(i=g),g&&a.forEach(ri),!l&&(a.forEach(ri),n(i))})});return t.reduce(fu)}var lu=cu;(function(e,t){t=e.exports=ps(),t.Stream=t,t.Readable=t,t.Writable=hs(),t.Duplex=Bt(),t.Transform=bs,t.PassThrough=ru,t.finished=En,t.pipeline=lu})(tn,tn.exports);var hu=tn.exports,dr=Be.Buffer,ms=hu.Transform,du=me;function pu(e,t){if(!dr.isBuffer(e)&&typeof e!="string")throw new TypeError(t+" must be a string or a buffer")}function et(e){ms.call(this),this._block=dr.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}du(et,ms);et.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(i){n=i}r(n)};et.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(r){t=r}e(t)};et.prototype.update=function(e,t){if(pu(e,"Data"),this._finalized)throw new Error("Digest already called");dr.isBuffer(e)||(e=dr.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 a=0,f=e.length*8;f>0;++a)this._length[a]+=f,f=this._length[a]/4294967296|0,f>0&&(this._length[a]-=4294967296*f);return this};et.prototype._update=function(){throw new Error("_update is not implemented")};et.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};et.prototype._digest=function(){throw new Error("_digest is not implemented")};var ws=et,bu=me,_s=ws,yu=Be.Buffer,gu=new Array(16);function vr(){_s.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}bu(vr,_s);vr.prototype._update=function(){for(var e=gu,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);var r=this._a,n=this._b,i=this._c,a=this._d;r=le(r,n,i,a,e[0],3614090360,7),a=le(a,r,n,i,e[1],3905402710,12),i=le(i,a,r,n,e[2],606105819,17),n=le(n,i,a,r,e[3],3250441966,22),r=le(r,n,i,a,e[4],4118548399,7),a=le(a,r,n,i,e[5],1200080426,12),i=le(i,a,r,n,e[6],2821735955,17),n=le(n,i,a,r,e[7],4249261313,22),r=le(r,n,i,a,e[8],1770035416,7),a=le(a,r,n,i,e[9],2336552879,12),i=le(i,a,r,n,e[10],4294925233,17),n=le(n,i,a,r,e[11],2304563134,22),r=le(r,n,i,a,e[12],1804603682,7),a=le(a,r,n,i,e[13],4254626195,12),i=le(i,a,r,n,e[14],2792965006,17),n=le(n,i,a,r,e[15],1236535329,22),r=he(r,n,i,a,e[1],4129170786,5),a=he(a,r,n,i,e[6],3225465664,9),i=he(i,a,r,n,e[11],643717713,14),n=he(n,i,a,r,e[0],3921069994,20),r=he(r,n,i,a,e[5],3593408605,5),a=he(a,r,n,i,e[10],38016083,9),i=he(i,a,r,n,e[15],3634488961,14),n=he(n,i,a,r,e[4],3889429448,20),r=he(r,n,i,a,e[9],568446438,5),a=he(a,r,n,i,e[14],3275163606,9),i=he(i,a,r,n,e[3],4107603335,14),n=he(n,i,a,r,e[8],1163531501,20),r=he(r,n,i,a,e[13],2850285829,5),a=he(a,r,n,i,e[2],4243563512,9),i=he(i,a,r,n,e[7],1735328473,14),n=he(n,i,a,r,e[12],2368359562,20),r=de(r,n,i,a,e[5],4294588738,4),a=de(a,r,n,i,e[8],2272392833,11),i=de(i,a,r,n,e[11],1839030562,16),n=de(n,i,a,r,e[14],4259657740,23),r=de(r,n,i,a,e[1],2763975236,4),a=de(a,r,n,i,e[4],1272893353,11),i=de(i,a,r,n,e[7],4139469664,16),n=de(n,i,a,r,e[10],3200236656,23),r=de(r,n,i,a,e[13],681279174,4),a=de(a,r,n,i,e[0],3936430074,11),i=de(i,a,r,n,e[3],3572445317,16),n=de(n,i,a,r,e[6],76029189,23),r=de(r,n,i,a,e[9],3654602809,4),a=de(a,r,n,i,e[12],3873151461,11),i=de(i,a,r,n,e[15],530742520,16),n=de(n,i,a,r,e[2],3299628645,23),r=pe(r,n,i,a,e[0],4096336452,6),a=pe(a,r,n,i,e[7],1126891415,10),i=pe(i,a,r,n,e[14],2878612391,15),n=pe(n,i,a,r,e[5],4237533241,21),r=pe(r,n,i,a,e[12],1700485571,6),a=pe(a,r,n,i,e[3],2399980690,10),i=pe(i,a,r,n,e[10],4293915773,15),n=pe(n,i,a,r,e[1],2240044497,21),r=pe(r,n,i,a,e[8],1873313359,6),a=pe(a,r,n,i,e[15],4264355552,10),i=pe(i,a,r,n,e[6],2734768916,15),n=pe(n,i,a,r,e[13],1309151649,21),r=pe(r,n,i,a,e[4],4149444226,6),a=pe(a,r,n,i,e[11],3174756917,10),i=pe(i,a,r,n,e[2],718787259,15),n=pe(n,i,a,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+a|0};vr.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=yu.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 Er(e,t){return e<<t|e>>>32-t}function le(e,t,r,n,i,a,f){return Er(e+(t&r|~t&n)+i+a|0,f)+t|0}function he(e,t,r,n,i,a,f){return Er(e+(t&n|r&~n)+i+a|0,f)+t|0}function de(e,t,r,n,i,a,f){return Er(e+(t^r^n)+i+a|0,f)+t|0}function pe(e,t,r,n,i,a,f){return Er(e+(r^(t|~n))+i+a|0,f)+t|0}var mu=vr,Wr=At.Buffer,wu=me,xs=ws,_u=new Array(16),Ut=[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],Mt=[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],Nt=[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],Dt=[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],$t=[0,1518500249,1859775393,2400959708,2840853838],Ht=[1352829926,1548603684,1836072691,2053994217,0];function Br(){xs.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}wu(Br,xs);Br.prototype._update=function(){for(var e=_u,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,a=this._d|0,f=this._e|0,u=this._a|0,l=this._b|0,y=this._c|0,g=this._d|0,w=this._e|0,E=0;E<80;E+=1){var I,v;E<16?(I=ni(r,n,i,a,f,e[Ut[E]],$t[0],Nt[E]),v=ai(u,l,y,g,w,e[Mt[E]],Ht[0],Dt[E])):E<32?(I=ii(r,n,i,a,f,e[Ut[E]],$t[1],Nt[E]),v=oi(u,l,y,g,w,e[Mt[E]],Ht[1],Dt[E])):E<48?(I=si(r,n,i,a,f,e[Ut[E]],$t[2],Nt[E]),v=si(u,l,y,g,w,e[Mt[E]],Ht[2],Dt[E])):E<64?(I=oi(r,n,i,a,f,e[Ut[E]],$t[3],Nt[E]),v=ii(u,l,y,g,w,e[Mt[E]],Ht[3],Dt[E])):(I=ai(r,n,i,a,f,e[Ut[E]],$t[4],Nt[E]),v=ni(u,l,y,g,w,e[Mt[E]],Ht[4],Dt[E])),r=f,f=a,a=ut(i,10),i=n,n=I,u=w,w=g,g=ut(y,10),y=l,l=v}var P=this._b+i+g|0;this._b=this._c+a+w|0,this._c=this._d+f+u|0,this._d=this._e+r+l|0,this._e=this._a+n+y|0,this._a=P};Br.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=Wr.alloc?Wr.alloc(20):new Wr(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 ut(e,t){return e<<t|e>>>32-t}function ni(e,t,r,n,i,a,f,u){return ut(e+(t^r^n)+a+f|0,u)+i|0}function ii(e,t,r,n,i,a,f,u){return ut(e+(t&r|~t&n)+a+f|0,u)+i|0}function si(e,t,r,n,i,a,f,u){return ut(e+((t|~r)^n)+a+f|0,u)+i|0}function oi(e,t,r,n,i,a,f,u){return ut(e+(t&n|r&~n)+a+f|0,u)+i|0}function ai(e,t,r,n,i,a,f,u){return ut(e+(t^(r|~n))+a+f|0,u)+i|0}var xu=Br,vs={exports:{}},Es=Be.Buffer;function Sr(e,t){this._block=Es.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}Sr.prototype.update=function(e,t){typeof e=="string"&&(t=t||"utf8",e=Es.from(e,t));for(var r=this._block,n=this._blockSize,i=e.length,a=this._len,f=0;f<i;){for(var u=a%n,l=Math.min(i-f,n-u),y=0;y<l;y++)r[u+y]=e[f+y];a+=l,f+=l,a%n===0&&this._update(r)}return this._len+=i,this};Sr.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 a=this._hash();return e?a.toString(e):a};Sr.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var Rt=Sr,vu=me,Bs=Rt,Eu=Be.Buffer,Bu=[1518500249,1859775393,-1894007588,-899497514],Su=new Array(80);function Jt(){this.init(),this._w=Su,Bs.call(this,64,56)}vu(Jt,Bs);Jt.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Iu(e){return e<<5|e>>>27}function Au(e){return e<<30|e>>>2}function Ru(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}Jt.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,a=this._d|0,f=this._e|0,u=0;u<16;++u)t[u]=e.readInt32BE(u*4);for(;u<80;++u)t[u]=t[u-3]^t[u-8]^t[u-14]^t[u-16];for(var l=0;l<80;++l){var y=~~(l/20),g=Iu(r)+Ru(y,n,i,a)+f+t[l]+Bu[y]|0;f=a,a=i,i=Au(n),n=r,r=g}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=a+this._d|0,this._e=f+this._e|0};Jt.prototype._hash=function(){var e=Eu.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 Tu=Jt,Pu=me,Ss=Rt,ku=Be.Buffer,Cu=[1518500249,1859775393,-1894007588,-899497514],Lu=new Array(80);function Xt(){this.init(),this._w=Lu,Ss.call(this,64,56)}Pu(Xt,Ss);Xt.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Ou(e){return e<<1|e>>>31}function Fu(e){return e<<5|e>>>27}function Uu(e){return e<<30|e>>>2}function Mu(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}Xt.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,a=this._d|0,f=this._e|0,u=0;u<16;++u)t[u]=e.readInt32BE(u*4);for(;u<80;++u)t[u]=Ou(t[u-3]^t[u-8]^t[u-14]^t[u-16]);for(var l=0;l<80;++l){var y=~~(l/20),g=Fu(r)+Mu(y,n,i,a)+f+t[l]+Cu[y]|0;f=a,a=i,i=Uu(n),n=r,r=g}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=a+this._d|0,this._e=f+this._e|0};Xt.prototype._hash=function(){var e=ku.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 Nu=Xt,Du=me,Is=Rt,$u=Be.Buffer,Hu=[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],zu=new Array(64);function Qt(){this.init(),this._w=zu,Is.call(this,64,56)}Du(Qt,Is);Qt.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 ju(e,t,r){return r^e&(t^r)}function Gu(e,t,r){return e&t|r&(e|t)}function qu(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function Wu(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function Vu(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function Ku(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}Qt.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,a=this._d|0,f=this._e|0,u=this._f|0,l=this._g|0,y=this._h|0,g=0;g<16;++g)t[g]=e.readInt32BE(g*4);for(;g<64;++g)t[g]=Ku(t[g-2])+t[g-7]+Vu(t[g-15])+t[g-16]|0;for(var w=0;w<64;++w){var E=y+Wu(f)+ju(f,u,l)+Hu[w]+t[w]|0,I=qu(r)+Gu(r,n,i)|0;y=l,l=u,u=f,f=a+E|0,a=i,i=n,n=r,r=E+I|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=a+this._d|0,this._e=f+this._e|0,this._f=u+this._f|0,this._g=l+this._g|0,this._h=y+this._h|0};Qt.prototype._hash=function(){var e=$u.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 As=Qt,Yu=me,Ju=As,Xu=Rt,Qu=Be.Buffer,Zu=new Array(64);function Ir(){this.init(),this._w=Zu,Xu.call(this,64,56)}Yu(Ir,Ju);Ir.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};Ir.prototype._hash=function(){var e=Qu.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 ec=Ir,tc=me,Rs=Rt,rc=Be.Buffer,fi=[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],nc=new Array(160);function Zt(){this.init(),this._w=nc,Rs.call(this,128,112)}tc(Zt,Rs);Zt.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 ui(e,t,r){return r^e&(t^r)}function ci(e,t,r){return e&t|r&(e|t)}function li(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function hi(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function ic(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function sc(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function oc(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function ac(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function ue(e,t){return e>>>0<t>>>0?1:0}Zt.prototype._update=function(e){for(var t=this._w,r=this._ah|0,n=this._bh|0,i=this._ch|0,a=this._dh|0,f=this._eh|0,u=this._fh|0,l=this._gh|0,y=this._hh|0,g=this._al|0,w=this._bl|0,E=this._cl|0,I=this._dl|0,v=this._el|0,P=this._fl|0,T=this._gl|0,k=this._hl|0,F=0;F<32;F+=2)t[F]=e.readInt32BE(F*4),t[F+1]=e.readInt32BE(F*4+4);for(;F<160;F+=2){var O=t[F-30],L=t[F-15*2+1],U=ic(O,L),S=sc(L,O);O=t[F-2*2],L=t[F-2*2+1];var z=oc(O,L),N=ac(L,O),$=t[F-7*2],oe=t[F-7*2+1],Pe=t[F-16*2],Ge=t[F-16*2+1],fe=S+oe|0,ve=U+$+ue(fe,S)|0;fe=fe+N|0,ve=ve+z+ue(fe,N)|0,fe=fe+Ge|0,ve=ve+Pe+ue(fe,Ge)|0,t[F]=ve,t[F+1]=fe}for(var Ee=0;Ee<160;Ee+=2){ve=t[Ee],fe=t[Ee+1];var tt=ci(r,n,i),ke=ci(g,w,E),qe=li(r,g),Ce=li(g,r),We=hi(f,v),Z=hi(v,f),ae=fi[Ee],Se=fi[Ee+1],Ve=ui(f,u,l),Me=ui(v,P,T),_=k+Z|0,m=y+We+ue(_,k)|0;_=_+Me|0,m=m+Ve+ue(_,Me)|0,_=_+Se|0,m=m+ae+ue(_,Se)|0,_=_+fe|0,m=m+ve+ue(_,fe)|0;var R=Ce+ke|0,D=qe+tt+ue(R,Ce)|0;y=l,k=T,l=u,T=P,u=f,P=v,v=I+_|0,f=a+m+ue(v,I)|0,a=i,I=E,i=n,E=w,n=r,w=g,g=_+R|0,r=m+D+ue(g,_)|0}this._al=this._al+g|0,this._bl=this._bl+w|0,this._cl=this._cl+E|0,this._dl=this._dl+I|0,this._el=this._el+v|0,this._fl=this._fl+P|0,this._gl=this._gl+T|0,this._hl=this._hl+k|0,this._ah=this._ah+r+ue(this._al,g)|0,this._bh=this._bh+n+ue(this._bl,w)|0,this._ch=this._ch+i+ue(this._cl,E)|0,this._dh=this._dh+a+ue(this._dl,I)|0,this._eh=this._eh+f+ue(this._el,v)|0,this._fh=this._fh+u+ue(this._fl,P)|0,this._gh=this._gh+l+ue(this._gl,T)|0,this._hh=this._hh+y+ue(this._hl,k)|0};Zt.prototype._hash=function(){var e=rc.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 Ts=Zt,fc=me,uc=Ts,cc=Rt,lc=Be.Buffer,hc=new Array(160);function Ar(){this.init(),this._w=hc,cc.call(this,128,112)}fc(Ar,uc);Ar.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};Ar.prototype._hash=function(){var e=lc.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 dc=Ar,lt=vs.exports=function(t){t=t.toLowerCase();var r=lt[t];if(!r)throw new Error(t+" is not supported (we accept pull requests)");return new r};lt.sha=Tu;lt.sha1=Nu;lt.sha224=ec;lt.sha256=As;lt.sha384=dc;lt.sha512=Ts;var pc=vs.exports,Ps=Be.Buffer,ks=xn.Transform,bc=hr.StringDecoder,yc=me;function Le(e){ks.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}yc(Le,ks);Le.prototype.update=function(e,t,r){typeof e=="string"&&(e=Ps.from(e,t));var n=this._update(e);return this.hashMode?this:(r&&(n=this._toString(n,r)),n)};Le.prototype.setAutoPadding=function(){};Le.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")};Le.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")};Le.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")};Le.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)}};Le.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(r){t=r}e(t)};Le.prototype._finalOrDigest=function(e){var t=this.__final()||Ps.alloc(0);return e&&(t=this._toString(t,e,!0)),t};Le.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new bc(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 gc=Le,mc=me,wc=mu,_c=xu,xc=pc,Cs=gc;function Rr(e){Cs.call(this,"digest"),this._hash=e}mc(Rr,Cs);Rr.prototype._update=function(e){this._hash.update(e)};Rr.prototype._final=function(){return this._hash.digest()};var vc=function(t){return t=t.toLowerCase(),t==="md5"?new wc:t==="rmd160"||t==="ripemd160"?new _c:new Rr(xc(t))},rr=Be.Buffer;function Ec(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),a=i.charCodeAt(0);if(t[a]!==255)throw new TypeError(i+" is ambiguous");t[a]=n}var f=e.length,u=e.charAt(0),l=Math.log(f)/Math.log(256),y=Math.log(256)/Math.log(f);function g(I){if((Array.isArray(I)||I instanceof Uint8Array)&&(I=rr.from(I)),!rr.isBuffer(I))throw new TypeError("Expected Buffer");if(I.length===0)return"";for(var v=0,P=0,T=0,k=I.length;T!==k&&I[T]===0;)T++,v++;for(var F=(k-T)*y+1>>>0,O=new Uint8Array(F);T!==k;){for(var L=I[T],U=0,S=F-1;(L!==0||U<P)&&S!==-1;S--,U++)L+=256*O[S]>>>0,O[S]=L%f>>>0,L=L/f>>>0;if(L!==0)throw new Error("Non-zero carry");P=U,T++}for(var z=F-P;z!==F&&O[z]===0;)z++;for(var N=u.repeat(v);z<F;++z)N+=e.charAt(O[z]);return N}function w(I){if(typeof I!="string")throw new TypeError("Expected String");if(I.length===0)return rr.alloc(0);for(var v=0,P=0,T=0;I[v]===u;)P++,v++;for(var k=(I.length-v)*l+1>>>0,F=new Uint8Array(k);v<I.length;){var O=t[I.charCodeAt(v)];if(O===255)return;for(var L=0,U=k-1;(O!==0||L<T)&&U!==-1;U--,L++)O+=f*F[U]>>>0,F[U]=O%256>>>0,O=O/256>>>0;if(O!==0)throw new Error("Non-zero carry");T=L,v++}for(var S=k-T;S!==k&&F[S]===0;)S++;var z=rr.allocUnsafe(P+(k-S));z.fill(0,0,P);for(var N=P;S!==k;)z[N++]=F[S++];return z}function E(I){var v=w(I);if(v)return v;throw new Error("Non-base"+f+" character")}return{encode:g,decodeUnsafe:w,decode:E}}var Bc=Ec,Sc=Bc,Ic="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Ac=Sc(Ic),Vr=Ac,Rc=Be.Buffer,Tc=function(e){function t(a){var f=e(a);return Vr.encode(Rc.concat([a,f],a.length+4))}function r(a){var f=a.slice(0,-4),u=a.slice(-4),l=e(f);if(!(u[0]^l[0]|u[1]^l[1]|u[2]^l[2]|u[3]^l[3]))return f}function n(a){var f=Vr.decodeUnsafe(a);if(f)return r(f)}function i(a){var f=Vr.decode(a),u=r(f);if(!u)throw new Error("Invalid checksum");return u}return{encode:t,decode:i,decodeUnsafe:n}},di=vc,Pc=Tc;function kc(e){var t=di("sha256").update(e).digest();return di("sha256").update(t).digest()}var Cc=Pc(kc),nn=Cc;function Ls(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 sn(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 Lc(e,t){return Ls(nn.decode(e),t)}function Oc(e,t,r){return typeof e=="number"?nn.encode(sn(e,t,r)):nn.encode(sn(e.version,e.privateKey,e.compressed))}var Fc={decode:Lc,decodeRaw:Ls,encode:Oc,encodeRaw:sn},Tr={};Object.defineProperty(Tr,"__esModule",{value:!0});Tr.testEcc=void 0;const H=e=>Buffer.from(e,"hex");function Uc(e){X(e.isPoint(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),X(!e.isPoint(H("030000000000000000000000000000000000000000000000000000000000000005"))),X(e.isPrivate(H("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),X(e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),X(!e.isPrivate(H("0000000000000000000000000000000000000000000000000000000000000000"))),X(!e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),X(!e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),X(Buffer.from(e.privateAdd(H("0000000000000000000000000000000000000000000000000000000000000001"),H("0000000000000000000000000000000000000000000000000000000000000000"))).equals(H("0000000000000000000000000000000000000000000000000000000000000001"))),X(e.privateAdd(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),H("0000000000000000000000000000000000000000000000000000000000000003"))===null),X(Buffer.from(e.privateAdd(H("e211078564db65c3ce7704f08262b1f38f1ef412ad15b5ac2d76657a63b2c500"),H("b51fbb69051255d1becbd683de5848242a89c229348dd72896a87ada94ae8665"))).equals(H("9730c2ee69edbb958d42db7460bafa18fef9d955325aec99044c81c8282b0a24"))),X(Buffer.from(e.privateNegate(H("0000000000000000000000000000000000000000000000000000000000000001"))).equals(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),X(Buffer.from(e.privateNegate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"))).equals(H("0000000000000000000000000000000000000000000000000000000000000003"))),X(Buffer.from(e.privateNegate(H("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(H("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792"))),X(Buffer.from(e.pointCompress(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!0)).equals(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),X(Buffer.from(e.pointCompress(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!1)).equals(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),X(Buffer.from(e.pointCompress(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!0)).equals(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),X(Buffer.from(e.pointCompress(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!1)).equals(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),X(Buffer.from(e.pointFromScalar(H("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(H("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),X(e.xOnlyPointAddTweak(H("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))===null);let t=e.xOnlyPointAddTweak(H("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),H("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));X(Buffer.from(t.xOnlyPubkey).equals(H("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&t.parity===1),t=e.xOnlyPointAddTweak(H("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),H("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47")),X(Buffer.from(t.xOnlyPubkey).equals(H("9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"))&&t.parity===0),X(Buffer.from(e.sign(H("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))).equals(H("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),X(e.verify(H("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),H("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),H("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),e.signSchnorr&&X(Buffer.from(e.signSchnorr(H("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),H("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),H("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906"))).equals(H("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),e.verifySchnorr&&X(e.verifySchnorr(H("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),H("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),H("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}Tr.testEcc=Uc;function X(e){if(!e)throw new Error("ecc library invalid")}Object.defineProperty(vt,"__esModule",{value:!0});vt.ECPairFactory=vt.networks=void 0;const on=Et;vt.networks=on;const _e=Wi,Mc=cf,pi=Fc,Nc=Tr,Kr=_e.typeforce.maybe(_e.typeforce.compile({compressed:_e.maybe(_e.Boolean),network:_e.maybe(_e.Network)})),Dc=e=>e.length===32?e:e.slice(1,33);function $c(e){(0,Nc.testEcc)(e);function t(u){return e.isPoint(u)}function r(u,l){if(_e.typeforce(_e.Buffer256bit,u),!e.isPrivate(u))throw new TypeError("Private key not in range [1, n)");return _e.typeforce(Kr,l),new f(u,void 0,l)}function n(u,l){return _e.typeforce(e.isPoint,u),_e.typeforce(Kr,l),new f(void 0,u,l)}function i(u,l){const y=pi.decode(u),g=y.version;if(_e.Array(l)){if(l=l.filter(w=>g===w.wif).pop(),!l)throw new Error("Unknown network version")}else if(l=l||on.bitcoin,g!==l.wif)throw new Error("Invalid network version");return r(y.privateKey,{compressed:y.compressed,network:l})}function a(u){_e.typeforce(Kr,u),u===void 0&&(u={});const l=u.rng||Mc;let y;do y=l(32),_e.typeforce(_e.Buffer256bit,y);while(!e.isPrivate(y));return r(y,u)}class f{constructor(l,y,g){pt(this,"__D");pt(this,"__Q");pt(this,"compressed");pt(this,"network");pt(this,"lowR");this.__D=l,this.__Q=y,this.lowR=!1,g===void 0&&(g={}),this.compressed=g.compressed===void 0?!0:g.compressed,this.network=g.network||on.bitcoin,y!==void 0&&(this.__Q=Buffer.from(e.pointCompress(y,this.compressed)))}get privateKey(){return this.__D}get publicKey(){if(!this.__Q){const l=e.pointFromScalar(this.__D,this.compressed);this.__Q=Buffer.from(l)}return this.__Q}toWIF(){if(!this.__D)throw new Error("Missing private key");return pi.encode(this.network.wif,this.__D,this.compressed)}tweak(l){return this.privateKey?this.tweakFromPrivateKey(l):this.tweakFromPublicKey(l)}sign(l,y){if(!this.__D)throw new Error("Missing private key");if(y===void 0&&(y=this.lowR),y===!1)return Buffer.from(e.sign(l,this.__D));{let g=e.sign(l,this.__D);const w=Buffer.alloc(32,0);let E=0;for(;g[0]>127;)E++,w.writeUIntLE(E,0,6),g=e.sign(l,this.__D,w);return Buffer.from(g)}}signSchnorr(l){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(l,this.privateKey))}verify(l,y){return e.verify(l,this.publicKey,y)}verifySchnorr(l,y){if(!e.verifySchnorr)throw new Error("verifySchnorr not supported by ecc library");return e.verifySchnorr(l,this.publicKey.subarray(1,33),y)}tweakFromPublicKey(l){const y=Dc(this.publicKey),g=e.xOnlyPointAddTweak(y,l);if(!g||g.xOnlyPubkey===null)throw new Error("Cannot tweak public key!");const w=Buffer.from([g.parity===0?2:3]);return n(Buffer.concat([w,g.xOnlyPubkey]),{network:this.network,compressed:this.compressed})}tweakFromPrivateKey(l){const g=this.publicKey[0]===3||this.publicKey[0]===4&&(this.publicKey[64]&1)===1?e.privateNegate(this.privateKey):this.privateKey,w=e.privateAdd(g,l);if(!w)throw new Error("Invalid tweaked private key!");return r(Buffer.from(w),{network:this.network,compressed:this.compressed})}}return{isPoint:t,fromPrivateKey:r,fromPublicKey:n,fromWIF:i,makeRandom:a}}vt.ECPairFactory=$c;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.networks=e.ECPairFactory=e.default=void 0;var t=vt;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}})})(qi);class pr{constructor(t){this.privKey=t}static fromPrivKey(t){return new pr(C.trim0x(t))}static async fromWalletClient(t){if(!t.account)return C.Err("No account found");try{const r=await t.signTypedData({account:t.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:"WBTC GARDEN",version:"1"},primaryType:"Data",message:{Message:"Initialize your swap",Version:"1.0.2",Nonce:1n}});return C.Ok(new pr(C.trim0x(He.sha256(r))))}catch(r){return C.Err("Failed to initialize: "+r)}}getMasterPrivKey(){return this.privKey}generateSecret(t){const r=this.signMessage(t),n=He.sha256(ge.with0x(r)),i=He.sha256(n);return C.Ok({secret:n,secretHash:i})}signMessage(t){const r=qi.ECPairFactory(_t),n="Garden.fi"+t.toString(),i=Buffer.from(n,"utf8"),a=He.sha256(i),f=Buffer.from(C.trim0x(this.privKey),"hex");if(f.length!==32)throw new Error("Invalid private key length. Expected 32 bytes.");return r.fromPrivateKey(f).sign(Buffer.from(C.trim0x(a),"hex")).toString("hex")}}class Hc{constructor(t){this.quoteUrl=new ge.Url("/quote",t)}async getQuote(t,r,n=!1){try{const i=this.quoteUrl.addSearchParams({order_pair:t,amount:r.toString(),exact_out:n.toString()}),a=await C.Fetcher.get(i);return a.error?C.Err(a.error):a.result?C.Ok(a.result):C.Err("GetQuote: Unexpected error, result is undefined")}catch(i){return C.Err("GetQuote:",String(i))}}async getAttestedQuote(t){try{const r=await C.Fetcher.post(this.quoteUrl.endpoint("/attested").toString(),{body:JSON.stringify(t),headers:{"Content-Type":"application/json"}});return r.error?C.Err(r.error):r.result?C.Ok(r.result):C.Err("GetAttestedQuote: Unexpected error, result is undefined")}catch(r){return console.log("error :",r),C.Err("GetAttestedQuote:",String(r))}}}exports.BlockNumberFetcher=Gi;exports.EvmRelay=ji;exports.Garden=za;exports.ParseOrderStatus=Hi;exports.ParseSwapStatus=fr;exports.Quote=Hc;exports.SecretManager=pr;exports.parseAction=zi;exports.switchOrAddNetwork=La;
package/dist/index.js CHANGED
@@ -7700,6 +7700,7 @@ class h0 {
7700
7700
  }
7701
7701
  }
7702
7702
  export {
7703
+ tf as BlockNumberFetcher,
7703
7704
  Ka as EvmRelay,
7704
7705
  c0 as Garden,
7705
7706
  Wa as ParseOrderStatus,
@@ -1,5 +1,7 @@
1
1
  export { Garden } from './lib/garden/garden';
2
2
  export type { IGardenJS, SwapParams, TimeLocks, OrderActions, GardenEvents, IOrderExecutorCache, OrderCacheValue, EventCallback, } from './lib/garden/garden.types';
3
+ export { BlockNumberFetcher } from './lib/garden/blockNumber';
4
+ export type { IBlockNumberFetcher, Network } from './lib/garden/blockNumber';
3
5
  export { EvmRelay } from './lib/evm/relay/evmRelay';
4
6
  export type { IEVMRelay } from './lib/evm/relay/evmRelay.types';
5
7
  export type { OrderStatus, SwapStatus } from './lib/status';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gardenfi/core",
3
- "version": "0.2.0-beta.45",
3
+ "version": "0.2.0-beta.46",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"