@bsv/sdk 2.0.0 → 2.0.1

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.
@@ -1,4 +1,4 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.bsv=t():e.bsv=t()}(this,()=>(()=>{"use strict";let e,t,i,r,n;var a,s,o,c,l,h,d,u,f={};f.d=(e,t)=>{for(var i in t)f.o(t,i)&&!f.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},f.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),f.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var p={};f.r(p),f.d(p,{walletErrors:()=>d,BEEF_V1:()=>i0,BEEF_V2:()=>i1,SignedMessage:()=>b,KeyShares:()=>t8,ThreadHandle:()=>af,BlockHeadersService:()=>rr,MerklePath:()=>iZ,PrivateKey:()=>t3,RemittanceManager:()=>au,XDM:()=>rR,binaryHttpClient:()=>rt,LivePolicy:()=>iq,DefaultNonceProvider:()=>ay,HD:()=>rp,Brc29RemittanceModule:()=>aw,KeyDeriver:()=>rx,defaultBroadcaster:()=>iG,verifyNonce:()=>nO,AuthFetch:()=>nD,Secp256r1:()=>iO,UnlockingScript:()=>i_,Random:()=>t0,WERR_REVIEW_ACTIONS:()=>rL,TOTP:()=>rS,Curve:()=>tH,VerifiableCertificate:()=>nP,SHIPCast:()=>nX,WhatsOnChain:()=>iY,DEFAULT_SLAP_TRACKERS:()=>nq,MasterCertificate:()=>nx,SAT_UNIT:()=>ah,defaultChainTracker:()=>iJ,DEFAULT_TESTNET_SLAP_TRACKERS:()=>n$,OverlayAdminTokenTemplate:()=>nL,NodejsHttpClient:()=>i$,Schnorr:()=>iI,WERR_INSUFFICIENT_FUNDS:()=>rK,LockingScript:()=>iT,DEFAULT_IDENTITY_CLIENT_OPTIONS:()=>n3,PublicKey:()=>tJ,Transaction:()=>i3,TransactionSignature:()=>iv,defaultIdentity:()=>n8,TX_DATA_FORMAT:()=>l,Signature:()=>tK,Teranode:()=>ri,PointInFiniteField:()=>t1,CachedKeyDeriver:()=>rP,Polynomial:()=>t2,OP:()=>im,P2PKH:()=>iL,deserializeWalletProtocol:()=>at,BeefParty:()=>i5,InvoiceHandle:()=>ap,Point:()=>tF,BSM:()=>v,ATOMIC_BEEF:()=>i2,SatoshisPerKilobyte:()=>iM,Validation:()=>I,HTTPWalletWire:()=>rV,TopicBroadcaster:()=>nX,StorageUtils:()=>k,isBroadcastResponse:()=>i6,RPuzzle:()=>iF,StorageDownloader:()=>n2,CompletedProtoWallet:()=>nA,LookupResolver:()=>nW,LocalKVStore:()=>ai,ProtoWallet:()=>rN,FetchHttpClient:()=>iz,WalletErrors:()=>r_,ECIES:()=>rI,WERR_INVALID_PARAMETER:()=>rH,fromUtxo:()=>rk,ARC:()=>iX,ECDSA:()=>y,GlobalKVStore:()=>ac,WindowCWISubstrate:()=>rO,SessionManager:()=>nN,SHIPBroadcaster:()=>nX,StorageUploader:()=>n1,SymmetricKey:()=>ip,validateCertificates:()=>nR,EncryptedMessage:()=>w,REMITTANCE_STATE_TRANSITIONS:()=>al,Hash:()=>g,Spend:()=>iD,isBroadcastFailure:()=>i4,DEFAULT_REMITTANCE_MESSAGEBOX:()=>ad,Mnemonic:()=>rm,Script:()=>ib,HTTPWalletJSON:()=>rM,ScriptEvaluationError:()=>iR,PushDrop:()=>iK,WalletWireProcessor:()=>nE,WalletWireTransceiver:()=>rU,RegistryClient:()=>ae,HTTPSOverlayLookupFacilitator:()=>nz,BigNumber:()=>P,Beef:()=>i8,createNonce:()=>nT,getVerifiableCertificates:()=>n_,BeefTx:()=>iQ,Certificate:()=>rC,KNOWN_IDENTITY_TYPES:()=>n6,HTTPSOverlayBroadcastFacilitator:()=>nj,Peer:()=>nB,ReactNativeWebView:()=>rq,WhatsOnChainBroadcaster:()=>i7,defaultHttpClient:()=>iW,withDoubleSpendRetry:()=>nG,SimplifiedFetchTransport:()=>nV,WalletError:()=>rT,SecurityLevels:()=>h,DefaultLockingScriptProvider:()=>ab,WalletClient:()=>nS,IdentityClient:()=>n9,Utils:()=>m});var g={};f.r(g),f.d(g,{RIPEMD160:()=>Y,SHA1:()=>Z,SHA1HMAC:()=>et,SHA256:()=>J,SHA256HMAC:()=>ee,SHA512:()=>Q,SHA512HMAC:()=>ei,hash160:()=>ec,hash256:()=>eo,htonl:()=>L,pbkdf2:()=>eQ,realHtonl:()=>e2,ripemd160:()=>er,sha1:()=>en,sha256:()=>ea,sha256hmac:()=>el,sha512:()=>es,sha512hmac:()=>eh,swapBytes32:()=>e0,toArray:()=>D});var m={};f.r(m),f.d(m,{Reader:()=>tg,ReaderUint8Array:()=>e3,Writer:()=>tp,WriterUint8Array:()=>e8,base64ToArray:()=>ta,constantTimeEquals:()=>tv,encode:()=>to,fromBase58:()=>th,fromBase58Check:()=>tf,minimallyEncode:()=>tm,toArray:()=>ti,toBase58:()=>td,toBase58Check:()=>tu,toBase64:()=>tc,toHex:()=>te,toUTF8:()=>ts,toUint8Array:()=>tt,verifyNotNull:()=>tw,zero2:()=>e5});var y={};f.r(y),f.d(y,{sign:()=>tG,verify:()=>tY});var b={};f.r(b),f.d(b,{sign:()=>ra,verify:()=>rs});var w={};f.r(w),f.d(w,{decrypt:()=>rl,encrypt:()=>rc});var v={};f.r(v),f.d(v,{magicHash:()=>rd,sign:()=>ru,verify:()=>rf});var I={};f.r(I),f.d(I,{isHexString:()=>r4,parseWalletOutpoint:()=>r$,specOpThrowReviewActions:()=>nk,validateAbortActionArgs:()=>nr,validateAcquireDirectCertificateArgs:()=>nm,validateAcquireIssuanceCertificateArgs:()=>ng,validateBase64String:()=>r8,validateBasketInsertion:()=>na,validateCreateActionArgs:()=>ne,validateCreateActionInput:()=>r5,validateCreateActionOptions:()=>r9,validateCreateActionOutput:()=>r7,validateDiscoverByAttributesArgs:()=>nw,validateDiscoverByIdentityKeyArgs:()=>nb,validateInteger:()=>rG,validateInternalizeActionArgs:()=>nc,validateInternalizeOutput:()=>ns,validateListActionsArgs:()=>nI,validateListCertificatesArgs:()=>nf,validateListOutputsArgs:()=>nv,validateOptionalInteger:()=>rX,validateOptionalOutpointString:()=>nl,validateOriginator:()=>no,validateOutpointString:()=>nh,validatePositiveIntegerOrZero:()=>rY,validateProveCertificateArgs:()=>ny,validateRelinquishCertificateArgs:()=>nu,validateRelinquishOutputArgs:()=>nd,validateSatoshis:()=>rj,validateSignActionArgs:()=>ni,validateSignActionOptions:()=>nt,validateStringLength:()=>rJ,validateWalletPayment:()=>nn});var k={};f.r(k),f.d(k,{getHashFromURL:()=>nQ,getURLForFile:()=>nZ,getURLForHash:()=>nJ,isValidURL:()=>n0,normalizeURL:()=>nY});let S="u">typeof globalThis?globalThis.Buffer:void 0,E=null!=S&&"function"==typeof S.from,x=new Int8Array(256).fill(-1);for(let e=0;e<10;e++)x[48+e]=e;for(let e=0;e<6;e++)x[65+e]=10+e,x[97+e]=10+e;class P{static zeros=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"];static groupSizes=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5];static groupBases=[0,0,0x2000000,0x290d741,0x1000000,0x2e90edd,0x39aa400,0x267bf47,0x1000000,0x290d741,1e7,0x12959c3,0x222c000,0x3bd7765,7529536,0xadcea1,0x1000000,0x1704f61,0x206fc40,0x2cddcf9,64e6,4084101,5153632,6436343,7962624,9765625,0xb54ba0,0xdaf26b,0x1069c00,0x138f9ad,243e5,0x1b4d89f,0x2000000,0x25528a1,0x2b54a20,0x3216b93,0x39aa400];static wordSize=26;static WORD_SIZE_BIGINT=BigInt(P.wordSize);static WORD_MASK=(1n<<P.WORD_SIZE_BIGINT)-1n;static MAX_SAFE_INTEGER_BIGINT=BigInt(Number.MAX_SAFE_INTEGER);static MIN_SAFE_INTEGER_BIGINT=BigInt(Number.MIN_SAFE_INTEGER);static MAX_IMULN_ARG=0x3ffffff;static MAX_NUMBER_CONSTRUCTOR_MAG_BIGINT=(1n<<53n)-1n;_magnitude;_sign;_nominalWordLength;red;get negative(){return this._sign}set negative(e){this.assert(0===e||1===e,"Negative property must be 0 or 1"),0n===this._magnitude?this._sign=0:this._sign=+(1===e)}get _computedWordsArray(){if(0n===this._magnitude)return[0];let e=[],t=this._magnitude;for(;t>0n;)e.push(Number(t&P.WORD_MASK)),t>>=P.WORD_SIZE_BIGINT;return e.length>0?e:[0]}get words(){let e=this._computedWordsArray;if(this._nominalWordLength<=e.length)return e;let t=Array(this._nominalWordLength).fill(0);for(let i=0;i<e.length;i++)t[i]=e[i];return t}set words(e){let t=this._sign,i=0n,r=e.length>0?e.length:1;for(let t=r-1;t>=0;t--){let r=void 0===e[t]?0:e[t];i=i<<P.WORD_SIZE_BIGINT|BigInt(r&Number(P.WORD_MASK))}this._magnitude=i,this._sign=t,this._nominalWordLength=r,this.normSign()}get length(){return Math.max(1,this._nominalWordLength)}static isBN(e){return e instanceof P||null!==e&&"object"==typeof e&&e.constructor?.wordSize===P.wordSize&&Array.isArray(e.words)}static max(e,t){return e.cmp(t)>0?e:t}static min(e,t){return 0>e.cmp(t)?e:t}constructor(e=0,t=10,i="be"){if(this._magnitude=0n,this._sign=0,this._nominalWordLength=1,this.red=null,void 0===e&&(e=0),null===e)return void this._initializeState(0n,0);if("bigint"==typeof e){this._initializeState(e<0n?-e:e,+(e<0n)),this.normSign();return}let r=t,n=i;if(("le"===t||"be"===t)&&(n=t,r=10),"number"==typeof e)return void this.initNumber(e,n);if(Array.isArray(e))return void this.initArray(e,n);if("string"==typeof e){"hex"===r&&(r=16),this.assert("number"==typeof r&&r===(0|r)&&r>=2&&r<=36,"Base must be an integer between 2 and 36");const t=e.toString().replace(/\s+/g,"");let i=0,a=0;t.startsWith("-")?(i++,a=1):t.startsWith("+")&&i++;const s=t.substring(i);if(0===s.length){this._initializeState(0n,1===a&&t.startsWith("-")?1:0),this.normSign();return}if(16===r){let e;if("le"===n){const e=[];let t=s;t.length%2!=0&&(t="0"+t);for(let i=0;i<t.length;i+=2){const r=parseInt(t.substring(i,i+2),16);if(isNaN(r))throw Error("Invalid character in "+t);e.push(r)}this.initArray(e,"le"),this._sign=a,this.normSign();return}try{e=BigInt("0x"+s)}catch(e){throw Error("Invalid character in "+s)}this._initializeState(e,a),this.normSign()}else try{if(this._parseBaseString(s,r),this._sign=a,this.normSign(),"le"===n){const e=this._sign;this.initArray(this.toArray("be"),"le"),this._sign=e,this.normSign()}}catch(e){if(e.message.includes("Invalid character in string")||e.message.includes("Invalid digit for base")||e.message.startsWith("Invalid character:"))throw Error("Invalid character");throw e}}else 0!==e?this.assert(!1,"Unsupported input type for BigNumber constructor"):this._initializeState(0n,0)}_bigIntToStringInBase(e,t){if(0n===e)return"0";if(t<2||t>36)throw Error("Base must be between 2 and 36");let i="",r=e>0n?e:-e,n=BigInt(t);for(;r>0n;)i="0123456789abcdefghijklmnopqrstuvwxyz"[Number(r%n)]+i,r/=n;return i}_parseBaseString(e,t){if(0===e.length){this._magnitude=0n,this._finishInitialization();return}this._magnitude=0n;let i=BigInt(t),r=P.groupSizes[t],n=BigInt(P.groupBases[t]);(0===r||0n===n)&&(0===(r=Math.floor(Math.log(0x3ffffff)/Math.log(t)))&&(r=1),n=i**BigInt(r));let a=0,s=e.length,o=s%r;if(0===o&&s>0&&(o=r),o>0){let i=e.substring(a,a+o);this._magnitude=BigInt(this._parseBaseWord(i,t)),a+=o}for(;a<s;){let i=e.substring(a,a+r),s=BigInt(this._parseBaseWord(i,t));this._magnitude=this._magnitude*n+s,a+=r}this._finishInitialization()}_parseBaseWord(e,t){let i=0;for(let r=0;r<e.length;r++){let n,a=e.charCodeAt(r);if(a>=48&&a<=57)n=a-48;else if(a>=65&&a<=90)n=a-65+10;else if(a>=97&&a<=122)n=a-97+10;else throw Error("Invalid character: "+e[r]);if(n>=t)throw Error("Invalid character");i=i*t+n}return i}_initializeState(e,t){this._magnitude=e,this._sign=0n===e?0:t,this._finishInitialization()}_finishInitialization(){if(0n===this._magnitude)this._nominalWordLength=1,this._sign=0;else{let e=this._magnitude.toString(2).length;this._nominalWordLength=Math.max(1,Math.ceil(e/P.wordSize))}}assert(e,t="Assertion failed"){if(!e)throw Error(t)}initNumber(e,t="be"){if(this.assert(BigInt(Math.abs(e))<=P.MAX_NUMBER_CONSTRUCTOR_MAG_BIGINT,"The number is larger than 2 ^ 53 (unsafe)"),this.assert(e%1==0,"Number must be an integer for BigNumber conversion"),this._initializeState(BigInt(Math.abs(e)),+(e<0)),"le"===t){let e=this._sign,t=this.toArray("be");this.initArray(t,"le"),this._sign=e,this.normSign()}return this}initArray(e,t){if(0===e.length)return this._initializeState(0n,0),this;let i=0n;if("be"===t)for(let t=0;t<e.length;t++)i=i<<8n|BigInt(255&e[t]);else for(let t=e.length-1;t>=0;t--)i=i<<8n|BigInt(255&e[t]);return this._initializeState(i,0),this}copy(e){e._magnitude=this._magnitude,e._sign=this._sign,e._nominalWordLength=this._nominalWordLength,e.red=this.red}static move(e,t){e._magnitude=t._magnitude,e._sign=t._sign,e._nominalWordLength=t._nominalWordLength,e.red=t.red}clone(){let e=new P(0n);return this.copy(e),e}expand(e){return this.assert(e>=0,"Expand size must be non-negative"),this._nominalWordLength=Math.max(this._nominalWordLength,e,1),this}strip(){return this._finishInitialization(),this.normSign()}normSign(){return 0n===this._magnitude&&(this._sign=0),this}inspect(){return(null!==this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}_getMinimalHex(){return 0n===this._magnitude?"0":this._magnitude.toString(16)}toString(e=10,t=1){if(16===e||"hex"===e){let e=this._getMinimalHex();if(t>1)for("0"!==e&&e.length%2!=0&&(e="0"+e);e.length%t!=0;)e="0"+e;return(this.isNeg()?"-":"")+e}if("number"!=typeof e||e<2||e>36||e%1!=0)throw Error("Base should be an integer between 2 and 36");return this.toBaseString(e,t)}toBaseString(e,t){if(0n===this._magnitude){let e="0";if(t>1)for(;e.length<t;)e="0"+e;return e}let i=P.groupSizes[e],r=BigInt(P.groupBases[e]);(0===i||0n===r)&&(0===(i=Math.floor(Math.log(Number.MAX_SAFE_INTEGER)/Math.log(e)))&&(i=1),r=BigInt(e)**BigInt(i));let n="",a=this._magnitude;for(;a>0n;){let t=a%r;a/=r;let s=this._bigIntToStringInBase(t,e);if(a>0n){let e=i-s.length;n=e>0&&e<P.zeros.length?P.zeros[e]+s+n:e>0?"0".repeat(e)+s+n:s+n}else n=s+n}if(t>0)for(;n.length<t;)n="0"+n;return(1===this._sign?"-":"")+n}toNumber(){let e=this._getSignedValue();if(e>P.MAX_SAFE_INTEGER_BIGINT||e<P.MIN_SAFE_INTEGER_BIGINT)throw Error("Number can only safely store up to 53 bits");return Number(e)}toBigInt(){return this._getSignedValue()}toJSON(){let e=this._getMinimalHex();return(this.isNeg()?"-":"")+e}toArrayLikeGeneric(e,t){let i=this._magnitude,r=t?0:e.length-1,n=t?1:-1;for(let t=0;t<e.length;++t){if(0n===i&&r>=0&&r<e.length)e[r]=0;else if(r>=0&&r<e.length)e[r]=Number(255n&i);else break;i>>=8n,r+=n}}toArray(e="be",t){this.strip();let i=this.byteLength(),r=t??Math.max(1,i);this.assert(i<=r,"byte array longer than desired length"),this.assert(r>0,"Requested array length <= 0");let n=Array(r).fill(0);return 0n===this._magnitude&&r>0?n:0n===this._magnitude&&0===r?[]:(this.toArrayLikeGeneric(n,"le"===e),n)}bitLength(){return 0n===this._magnitude?0:this._magnitude.toString(2).length}static toBitArray(e){let t=e.bitLength();if(0===t)return[];let i=Array(t),r=e._magnitude;for(let e=0;e<t;e++)i[e]=+((r>>BigInt(e)&1n)!==0n);return i}toBitArray(){return P.toBitArray(this)}zeroBits(){if(0n===this._magnitude)return 0;let e=0,t=this._magnitude;for(;(1n&t)===0n&&0n!==t;)e++,t>>=1n;return e}byteLength(){return 0n===this._magnitude?0:Math.ceil(this.bitLength()/8)}_getSignedValue(){return 1===this._sign?-this._magnitude:this._magnitude}_setValueFromSigned(e){e<0n?(this._magnitude=-e,this._sign=1):(this._magnitude=e,this._sign=0),this._finishInitialization(),this.normSign()}toTwos(e){this.assert(e>=0);let t=BigInt(e),i=this._getSignedValue();1===this._sign&&0n!==this._magnitude&&(i=(1n<<t)+i),i&=(1n<<t)-1n;let r=new P(0n);return r._initializeState(i,0),r}fromTwos(e){this.assert(e>=0);let t=BigInt(e),i=this._magnitude;if(e>0&&(i>>t-1n&1n)!==0n&&0===this._sign){let e=new P(0n);return e._setValueFromSigned(i-(1n<<t)),e}return this.clone()}isNeg(){return 1===this._sign&&0n!==this._magnitude}neg(){return this.clone().ineg()}ineg(){return 0n!==this._magnitude&&(this._sign=+(1!==this._sign)),this}_iuop(e,t){let i=t(this._magnitude,e._magnitude),r=t===((e,t)=>e^t),n=this._nominalWordLength;return r&&(n=Math.max(this.length,e.length)),this._magnitude=i,this._finishInitialization(),r&&(this._nominalWordLength=Math.max(this._nominalWordLength,n)),this.strip()}iuor(e){return this._iuop(e,(e,t)=>e|t)}iuand(e){return this._iuop(e,(e,t)=>e&t)}iuxor(e){return this._iuop(e,(e,t)=>e^t)}_iop(e,t){return this.assert(0===this._sign&&0===e._sign),this._iuop(e,t)}ior(e){return this._iop(e,(e,t)=>e|t)}iand(e){return this._iop(e,(e,t)=>e&t)}ixor(e){return this._iop(e,(e,t)=>e^t)}_uop_new(e,t){return this.length>=e.length?this.clone()[t](e):e.clone()[t](this)}or(e){return this.assert(0===this._sign&&0===e._sign),this._uop_new(e,"iuor")}uor(e){return this._uop_new(e,"iuor")}and(e){return this.assert(0===this._sign&&0===e._sign),this._uop_new(e,"iuand")}uand(e){return this._uop_new(e,"iuand")}xor(e){return this.assert(0===this._sign&&0===e._sign),this._uop_new(e,"iuxor")}uxor(e){return this._uop_new(e,"iuxor")}inotn(e){this.assert("number"==typeof e&&e>=0);let t=BigInt(e);this._magnitude=~this._magnitude&(1n<<t)-1n;let i=0===e?1:Math.ceil(e/P.wordSize);return this._nominalWordLength=Math.max(1,i),this.strip(),this._nominalWordLength=Math.max(this._nominalWordLength,Math.max(1,i)),this}notn(e){return this.clone().inotn(e)}setn(e,t){this.assert("number"==typeof e&&e>=0);let i=BigInt(e);1===t||!0===t?this._magnitude|=1n<<i:this._magnitude&=~(1n<<i);let r=Math.floor(e/P.wordSize)+1;return this._nominalWordLength=Math.max(this._nominalWordLength,r),this._finishInitialization(),this.strip()}iadd(e){return this._setValueFromSigned(this._getSignedValue()+e._getSignedValue()),this}add(e){let t=new P(0n);return t._setValueFromSigned(this._getSignedValue()+e._getSignedValue()),t}isub(e){return this._setValueFromSigned(this._getSignedValue()-e._getSignedValue()),this}sub(e){let t=new P(0n);return t._setValueFromSigned(this._getSignedValue()-e._getSignedValue()),t}mul(e){let t=new P(0n);return t._magnitude=this._magnitude*e._magnitude,t._sign=0n===t._magnitude?0:this._sign^e._sign,t._nominalWordLength=this.length+e.length,t.red=null,t.normSign()}imul(e){return this._magnitude*=e._magnitude,this._sign=0n===this._magnitude?0:this._sign^e._sign,this._nominalWordLength=this.length+e.length,this.red=null,this.normSign()}imuln(e){return this.assert("number"==typeof e,"Assertion failed"),this.assert(Math.abs(e)<=P.MAX_IMULN_ARG,"Assertion failed"),this._setValueFromSigned(this._getSignedValue()*BigInt(e)),this}muln(e){return this.clone().imuln(e)}sqr(){let e=new P(0n);return e._magnitude=this._magnitude*this._magnitude,e._sign=0,e._nominalWordLength=2*this.length,e.red=null,e}isqr(){return this._magnitude*=this._magnitude,this._sign=0,this._nominalWordLength=2*this.length,this.red=null,this}pow(e){if(this.assert(0===e._sign,"Exponent for pow must be non-negative"),e.isZero())return new P(1n);let t=new P(1n),i=this.clone(),r=e.clone(),n=i.isNeg(),a=r.isOdd();for(n&&i.ineg();!r.isZero();)r.isOdd()&&t.imul(i),i.isqr(),r.iushrn(1);return n&&a&&t.ineg(),t}static normalizeNonNegativeBigInt(e,t){if("number"==typeof e){if(!Number.isFinite(e)||!Number.isInteger(e)||e<0)throw Error(`${t} must be a non-negative integer`);return BigInt(e)}if(e<0n)throw Error(`${t} must be a non-negative integer`);return e}iushln(e){let t=P.normalizeNonNegativeBigInt(e,"Shift bits");return 0n===t?this:(this._magnitude<<=t,this._finishInitialization(),this.strip())}ishln(e){return this.assert(0===this._sign,"ishln requires positive number"),this.iushln(e)}iushrn(e,t,i){let r=P.normalizeNonNegativeBigInt(e,"Shift bits");if(0n===r)return null!=i&&i._initializeState(0n,0),this;if(null!=i){let e=this._magnitude&(1n<<r)-1n;i._initializeState(e,0)}return this._magnitude>>=r,this._finishInitialization(),this.strip()}ishrn(e,t,i){return this.assert(0===this._sign,"ishrn requires positive number"),this.iushrn(e,t,i)}shln(e){return this.clone().ishln(e)}ushln(e){return this.clone().iushln(e)}shrn(e){return this.clone().ishrn(e)}ushrn(e){return this.clone().iushrn(e)}testn(e){return this.assert("number"==typeof e&&e>=0),(this._magnitude>>BigInt(e)&1n)!==0n}imaskn(e){this.assert("number"==typeof e&&e>=0),this.assert(0===this._sign,"imaskn works only with positive numbers");let t=BigInt(e);this._magnitude&=0n===t?0n:(1n<<t)-1n;let i=0===e?1:Math.max(1,Math.ceil(e/P.wordSize));return this._nominalWordLength=i,this._finishInitialization(),this._nominalWordLength=Math.max(this._nominalWordLength,i),this.strip()}maskn(e){return this.clone().imaskn(e)}iaddn(e){return this.assert("number"==typeof e),this.assert(Math.abs(e)<=P.MAX_IMULN_ARG,"num is too large"),this._setValueFromSigned(this._getSignedValue()+BigInt(e)),this}_iaddn(e){return this.iaddn(e)}isubn(e){return this.assert("number"==typeof e),this.assert(Math.abs(e)<=P.MAX_IMULN_ARG,"Assertion failed"),this._setValueFromSigned(this._getSignedValue()-BigInt(e)),this}addn(e){return this.clone().iaddn(e)}subn(e){return this.clone().isubn(e)}iabs(){return this._sign=0,this}abs(){return this.clone().iabs()}divmod(e,t,i){if(this.assert(!e.isZero(),"Division by zero"),this.isZero()){let e=new P(0n);return{div:"mod"!==t?e:null,mod:"div"!==t?e:null}}let r=this._getSignedValue(),n=e._getSignedValue(),a=null,s=null;"mod"!==t&&(a=r/n),"div"!==t&&(s=r%n,!0===i&&s<0n&&(s+=n<0n?-n:n));let o=null!==a?new P(0n):null;null!==o&&null!==a&&o._setValueFromSigned(a);let c=null!==s?new P(0n):null;return null!==c&&null!==s&&c._setValueFromSigned(s),{div:o,mod:c}}div(e){return this.divmod(e,"div",!1).div}mod(e){return this.divmod(e,"mod",!1).mod}umod(e){return this.divmod(e,"mod",!0).mod}divRound(e){this.assert(!e.isZero());let t=this._getSignedValue(),i=e._getSignedValue(),r=t/i,n=t%i;if(0n===n){let e=new P(0n);return e._setValueFromSigned(r),e}2n*(n<0n?-n:n)>=(i<0n?-i:i)&&(t>0n&&i>0n||t<0n&&i<0n?r+=1n:r-=1n);let a=new P(0n);return a._setValueFromSigned(r),a}modrn(e){this.assert(0!==e,"Division by zero in modrn");let t=BigInt(Math.abs(e));if(0n===t)throw Error("Division by zero in modrn");let i=this._magnitude%t;return e<0?Number(-i):Number(i)}idivn(e){return this.assert(0!==e),this.assert(Math.abs(e)<=P.MAX_IMULN_ARG,"num is too large"),this._setValueFromSigned(this._getSignedValue()/BigInt(e)),this}divn(e){return this.clone().idivn(e)}egcd(e){this.assert(0===e._sign,"p must not be negative"),this.assert(!e.isZero(),"p must not be zero");let t=this._getSignedValue(),i=e._magnitude,r=1n,n=0n,a=0n,s=1n;for(;0n!==i;){let e=t/i,o=i;i=t%i,t=o,o=n,n=r-e*n,r=o,o=s,s=a-e*s,a=o}let o=new P(0n);o._setValueFromSigned(r);let c=new P(0n);c._setValueFromSigned(a);let l=new P(0n);return l._initializeState(t<0n?-t:t,0),{a:o,b:c,gcd:l}}gcd(e){let t=this._magnitude,i=e._magnitude;if(0n===t){let e=new P(0n);return e._setValueFromSigned(i),e.iabs()}if(0n===i){let e=new P(0n);return e._setValueFromSigned(t),e.iabs()}for(;0n!==i;){let e=t%i;t=i,i=e}let r=new P(0n);return r._initializeState(t,0),r}invm(e){this.assert(!e.isZero()&&0===e._sign,"Modulus for invm must be positive and non-zero");let t=this.egcd(e);if(!t.gcd.eqn(1))throw Error("Inverse does not exist (numbers are not coprime).");return t.a.umod(e)}isEven(){return this._magnitude%2n===0n}isOdd(){return this._magnitude%2n===1n}andln(e){return this.assert(e>=0),Number(this._magnitude&BigInt(e))}bincn(e){this.assert("number"==typeof e&&e>=0);let t=1n<<BigInt(e);return this._setValueFromSigned(this._getSignedValue()+t),this}isZero(){return 0n===this._magnitude}cmpn(e){this.assert(Math.abs(e)<=P.MAX_IMULN_ARG,"Number is too big");let t=this._getSignedValue(),i=BigInt(e);return t<i?-1:+(t>i)}cmp(e){let t=this._getSignedValue(),i=e._getSignedValue();return t<i?-1:+(t>i)}ucmp(e){return this._magnitude<e._magnitude?-1:+(this._magnitude>e._magnitude)}gtn(e){return 1===this.cmpn(e)}gt(e){return 1===this.cmp(e)}gten(e){return this.cmpn(e)>=0}gte(e){return this.cmp(e)>=0}ltn(e){return -1===this.cmpn(e)}lt(e){return -1===this.cmp(e)}lten(e){return 0>=this.cmpn(e)}lte(e){return 0>=this.cmp(e)}eqn(e){return 0===this.cmpn(e)}eq(e){return 0===this.cmp(e)}toRed(e){return this.assert(null==this.red,"Already a number in reduction context"),this.assert(0===this._sign,"toRed works only with positives"),e.convertTo(this).forceRed(e)}fromRed(){return this.assert(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)}forceRed(e){return this.red=e,this}redAdd(e){return this.assert(this.red,"redAdd works only with red numbers"),this.red.add(this,e)}redIAdd(e){return this.assert(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)}redSub(e){return this.assert(this.red,"redSub works only with red numbers"),this.red.sub(this,e)}redISub(e){return this.assert(this.red,"redISub works only with red numbers"),this.red.isub(this,e)}redShl(e){return this.assert(this.red,"redShl works only with red numbers"),this.red.shl(this,e)}redMul(e){return this.assert(this.red,"redMul works only with red numbers"),this.red.verify2(this,e),this.red.mul(this,e)}redIMul(e){return this.assert(this.red,"redIMul works only with red numbers"),this.red.verify2(this,e),this.red.imul(this,e)}redSqr(){return this.assert(this.red,"redSqr works only with red numbers"),this.red.verify1(this),this.red.sqr(this)}redISqr(){return this.assert(this.red,"redISqr works only with red numbers"),this.red.verify1(this),this.red.isqr(this)}redSqrt(){return this.assert(this.red,"redSqrt works only with red numbers"),this.red.verify1(this),this.red.sqrt(this)}redInvm(){return this.assert(this.red,"redInvm works only with red numbers"),this.red.verify1(this),this.red.invm(this)}redNeg(){return this.assert(this.red,"redNeg works only with red numbers"),this.red.verify1(this),this.red.neg(this)}redPow(e){return this.assert(null!=this.red&&null==e.red,"redPow(normalNum)"),this.red.verify1(this),this.red.pow(this,e)}static fromHex(e,t){let i="be";return("little"===t||"le"===t)&&(i="le"),new P(e,16,i)}toHex(e=0){if(this.isZero()&&0===e)return"";let t=this._getMinimalHex();"0"!==t&&t.length%2!=0&&(t="0"+t);let i=2*e;for(;t.length<i;)t="0"+t;return(this.isNeg()?"-":"")+t}static fromJSON(e){return new P(e,16)}static fromNumber(e){return new P(e)}static fromString(e,t){return new P(e,t)}static fromSm(e,t="big"){if(0===e.length)return new P(0n);let i=e.slice();"little"===t&&i.reverse();let r=0;i.length>0&&(128&i[0])!=0&&(r=1,i[0]&=127);let n=0n;if(E){let e=S.from(i).toString("hex");n=0===e.length?0n:BigInt("0x"+e)}else{let e="";for(let t of i)e+=t<16?"0"+t.toString(16):t.toString(16);n=0===e.length?0n:BigInt("0x"+e)}let a=new P(0n);return a._initializeState(n,r),a}toSm(e="big"){let t;if(0n===this._magnitude)return 1===this._sign?[128]:[];let i=this._getMinimalHex();i.length%2!=0&&(i="0"+i);let r=Array(i.length/2);for(let e=0,t=0;e<i.length;e+=2){let n=x[i.charCodeAt(e)],a=x[i.charCodeAt(e+1)];r[t++]=(15&n)<<4|15&a}return 1===this._sign?(128&r[0])!=0?t=[128,...r]:(t=r.slice(),t[0]|=128):t=(128&r[0])!=0?[0,...r]:r.slice(),"little"===e?t.reverse():t}static fromBits(e,t=!1){let i=e>>>24,r=8388607&e,n=(8388608&e)!=0;if(t&&n)throw Error("negative bit set");if(0===i&&0===r){if(n&&t)throw Error("negative bit set for zero value");return new P(0n)}let a=new P(r);return i<=3?a.iushrn((3-i)*8):a.iushln((i-3)*8),n&&a.ineg(),a}toBits(){let e;if(this.strip(),this.isZero()&&!this.isNeg())return 0;let t=this.isNeg(),i=this.abs(),r=i.toArray("be"),n=0;for(;n<r.length-1&&0===r[n];)n++;let a=(r=r.slice(n)).length;if(0!==a||i.isZero()||(r=[0],a=1),i.isZero()&&(a=0,r=[]),0===a)e=0;else if(a<=3){e=0;for(let t=0;t<a;t++)e=e<<8|r[t]}else e=r[0]<<16|r[1]<<8|r[2];(8388608&e)!=0&&a<=255&&(e>>>=8,a++);let s=a<<24|e;return t&&(s|=8388608),s>>>0}static fromScriptNum(e,t=!1,i){if(void 0!==i&&e.length>i)throw Error("script number overflow");if(0===e.length)return new P(0n);if(t&&(127&e[e.length-1])==0&&(e.length<=1||(128&e[e.length-2])==0))throw Error("non-minimally encoded script number");return P.fromSm(e,"little")}toScriptNum(){return this.toSm("little")}_invmp(e){this.assert(0===e._sign,"p must not be negative for _invmp"),this.assert(!e.isZero(),"p must not be zero for _invmp");let t=this.umod(e),i=e.subn(2);if(null!==t.red)return t.redPow(i);let r=new P(1n),n=t.clone(),a=i.clone();for(;!a.isZero();)a.isOdd()&&(r=r.mul(n).umod(e)),n=n.sqr().umod(e),a.iushrn(1);return r}mulTo(e,t){return t._magnitude=this._magnitude*e._magnitude,t._sign=0n===t._magnitude?0:this._sign^e._sign,t._nominalWordLength=this.length+e.length,t.red=null,t.normSign(),t}}class A{name;p;k;n;tmp;constructor(e,t){this.name=e,this.p=new P(t,16),this.n=this.p.bitLength(),this.k=new P(BigInt(1)).iushln(this.n).isub(this.p),this.tmp=this._tmp()}_tmp(){let e=new P(BigInt(0)),t=Math.ceil(this.n/P.wordSize);return e.expand(Math.max(1,t)),e}ireduce(e){let t;do this.split(e,this.tmp),this.imulK(e),e.iadd(this.tmp),t=e.bitLength();while(t>this.n);let i=t<this.n?-1:e.ucmp(this.p);return 0===i?e.words=[0]:i>0&&e.isub(this.p),e.strip(),e}split(e,t){e.iushrn(this.n,0,t)}imulK(e){return e.imul(this.k)}}class N extends A{constructor(){super("k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}split(e,t){let i=e.words,r=e.length,n=Math.min(r,9),a=Array(n+ +(r>9)).fill(0);for(let e=0;e<n;e++)a[e]=i[e];let s=n;if(r<=9){let i=Array(s);for(let e=0;e<s;++e)i[e]=a[e];t.words=i,e.words=[0];return}let o=i[9];a[s++]=4194303&o;let c=Array(s);for(let e=0;e<s;++e)c[e]=a[e];t.words=c;let l=Array(Math.max(1,r-9)).fill(0),h=0;for(let e=10;e<r;e++){let t=0|i[e];h<l.length&&(l[h++]=(4194303&t)<<4|o>>>22),o=t}o>>>=22,h<l.length?l[h++]=o:0!==o&&l.length;let d=Array(h);for(let e=0;e<h;++e)d[e]=l[e];e.words=d}imulK(e){let t=e.words,i=e.length,r=i+2,n=Array(r).fill(0);for(let e=0;e<i;e++)n[e]=t[e];let a=0;for(let e=0;e<r;e++){let t=0|n[e];a+=977*t,n[e]=0x3ffffff&a,a=64*t+(a/0x4000000|0)}return e.words=n,e}}class O{prime;m;constructor(e){if("k256"===e){const e=new N;this.m=e.p,this.prime=e}else this.assert(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}assert(e,t="Assertion failed"){if(!e)throw Error(t)}verify1(e){this.assert(0===e.negative,"red works only with positives"),this.assert(e.red,"red works only with red numbers")}verify2(e,t){this.assert((e.negative|t.negative)==0,"red works only with positives"),this.assert(null!=e.red&&e.red===t.red,"red works only with red numbers")}imod(e){return null!=this.prime?this.prime.ireduce(e).forceRed(this):(P.move(e,e.umod(this.m).forceRed(this)),e)}neg(e){return e.isZero()?e.clone():this.m.sub(e).forceRed(this)}add(e,t){this.verify2(e,t);let i=e.clone();return i.iadd(t),i.isub(this.m),i.isNeg()&&i.iadd(this.m),i}iadd(e,t){return this.verify2(e,t),e.iadd(t),e.isub(this.m),e.isNeg()&&e.iadd(this.m),e}sub(e,t){this.verify2(e,t);let i=e.sub(t);return 0>i.cmpn(0)&&i.iadd(this.m),i.forceRed(this)}isub(e,t){this.verify2(e,t);let i=e.isub(t);return 0>i.cmpn(0)&&i.iadd(this.m),i}shl(e,t){return this.verify1(e),this.imod(e.ushln(t))}imul(e,t){return this.verify2(e,t),this.imod(e.imul(t))}mul(e,t){return this.verify2(e,t),this.imod(e.mul(t))}isqr(e){return this.imul(e,e.clone())}sqr(e){return this.mul(e,e)}sqrt(e){if(e.isZero())return e.clone();let t=this.m.andln(3);if(this.assert(t%2==1),3===t){let t=this.m.add(new P(1)).iushrn(2);return this.pow(e,t)}let i=this.m.subn(1),r=0;for(;!i.isZero()&&0===i.andln(1);)r++,i.iushrn(1);this.assert(!i.isZero());let n=new P(1).toRed(this),a=n.redNeg(),s=this.m.subn(1).iushrn(1),o=this.m.bitLength(),c=new P(2*o*o).toRed(this);for(;0!==this.pow(c,s).cmp(a);)c.redIAdd(a);let l=this.pow(c,i),h=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),u=r;for(;0!==d.cmp(n);){let e=d,t=0;for(;0!==e.cmp(n);t++)e=e.redSqr();this.assert(t<u);let i=this.pow(l,new P(1).iushln(u-t-1));h=h.redMul(i),l=i.redSqr(),d=d.redMul(l),u=t}return h}invm(e){let t=e._invmp(this.m);return 0!==t.negative?(t.negative=0,this.imod(t).redNeg()):this.imod(t)}pow(e,t){if(this.verify1(e),t.isZero())return new P(1).toRed(this);let i=new P(1).toRed(this),r=e.clone(),n=t.bitLength();for(let e=n-1;e>=0;e--)i=this.sqr(i),t.testn(e)&&(i=this.mul(i,r));return i}convertTo(e){let t=e.umod(this.m);return t===e?t.clone():t}convertFrom(e){let t=e.clone();return t.red=null,t}}class T extends O{shift;r;r2;rinv;minv;constructor(e){super(e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new P(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}convertTo(e){return this.imod(e.ushln(this.shift))}convertFrom(e){let t=this.imod(e.mul(this.rinv));return t.red=null,t}imul(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;let i=e.imul(t),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),a=n;return n.cmp(this.m)>=0?a=n.isub(this.m):0>n.cmpn(0)&&(a=n.iadd(this.m)),a.forceRed(this)}mul(e,t){if(e.isZero()||t.isZero())return new P(0).forceRed(this);let i=e.mul(t),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),a=n;return n.cmp(this.m)>=0?a=n.isub(this.m):0>n.cmpn(0)&&(a=n.iadd(this.m)),a.forceRed(this)}invm(e){return this.imod(e._invmp(this.m).mul(this.r2)).forceRed(this)}}class _{curve;type;precomputed;constructor(e){this.curve=new tH,this.type=e,this.precomputed=null}}class R extends _{x;y;z;zOne;constructor(e,t,i){super("jacobian"),null===e&&null===t&&null===i?(this.x=this.curve.one,this.y=this.curve.one,this.z=new P(0)):(P.isBN(e)||(e=new P(e,16)),this.x=e,P.isBN(t)||(t=new P(t,16)),this.y=t,P.isBN(i)||(i=new P(i,16)),this.z=i),null==this.x.red&&(this.x=this.x.toRed(this.curve.red)),null==this.y.red&&(this.y=this.y.toRed(this.curve.red)),null==this.z.red&&(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.isInfinity()&&(this.x=this.curve.one,this.y=this.curve.one,this.z=new P(0).toRed(this.curve.red),this.zOne=!1)}toP(){if(this.isInfinity())return new tF(null,null);let e=this.z.redInvm(),t=e.redSqr();return new tF(this.x.redMul(t),this.y.redMul(t).redMul(e))}neg(){return new R(this.x,this.y.redNeg(),this.z)}add(e){if(this.isInfinity())return e;if(e.isInfinity())return this;let t=e.z.redSqr(),i=this.z.redSqr(),r=this.x.redMul(t),n=e.x.redMul(i),a=this.y.redMul(t.redMul(e.z)),s=e.y.redMul(i.redMul(this.z)),o=r.redSub(n),c=a.redSub(s);if(0===o.cmpn(0))if(0!==c.cmpn(0))return new R(null,null,null);else return this.dbl();let l=o.redSqr(),h=l.redMul(o),d=r.redMul(l),u=c.redSqr().redIAdd(h).redISub(d).redISub(d),f=c.redMul(d.redISub(u)).redISub(a.redMul(h));return new R(u,f,this.z.redMul(e.z).redMul(o))}mixedAdd(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;if(null===e.x||null===e.y)throw Error("Point coordinates cannot be null");let t=this.z.redSqr(),i=this.x,r=e.x.redMul(t),n=this.y,a=e.y.redMul(t).redMul(this.z),s=i.redSub(r),o=n.redSub(a);if(0===s.cmpn(0))if(0!==o.cmpn(0))return new R(null,null,null);else return this.dbl();let c=s.redSqr(),l=c.redMul(s),h=i.redMul(c),d=o.redSqr().redIAdd(l).redISub(h).redISub(h),u=o.redMul(h.redISub(d)).redISub(n.redMul(l));return new R(d,u,this.z.redMul(s))}dblp(e){if(0===e||this.isInfinity())return this;if(void 0===e)return this.dbl();let t=this;for(let i=0;i<e;i++)t=t.dbl();return t}dbl(){let e,t,i;if(this.isInfinity())return this;if(this.zOne){let r=this.x.redSqr(),n=this.y.redSqr(),a=n.redSqr(),s=this.x.redAdd(n).redSqr().redISub(r).redISub(a);s=s.redIAdd(s);let o=r.redAdd(r).redIAdd(r),c=o.redSqr().redISub(s).redISub(s),l=a.redIAdd(a);l=(l=l.redIAdd(l)).redIAdd(l),e=c,t=o.redMul(s.redISub(c)).redISub(l),i=this.y.redAdd(this.y)}else{let r=this.x.redSqr(),n=this.y.redSqr(),a=n.redSqr(),s=this.x.redAdd(n).redSqr().redISub(r).redISub(a);s=s.redIAdd(s);let o=r.redAdd(r).redIAdd(r),c=o.redSqr(),l=a.redIAdd(a);l=(l=l.redIAdd(l)).redIAdd(l),e=c.redISub(s).redISub(s),t=o.redMul(s.redISub(e)).redISub(l),i=(i=this.y.redMul(this.z)).redIAdd(i)}return new R(e,t,i)}eq(e){if("affine"===e.type)return this.eq(e.toJ());if(this===e||this.isInfinity()&&e.isInfinity())return!0;if(this.isInfinity()!==e.isInfinity())return!1;let t=this.z.redSqr(),i=e.z.redSqr();if(0!==this.x.redMul(i).redISub(e.x.redMul(t)).cmpn(0))return!1;let r=t.redMul(this.z),n=i.redMul(e.z);return 0===this.y.redMul(n).redISub(e.y.redMul(r)).cmpn(0)}eqXToP(e){let t=this.z.redSqr(),i=e.toRed(this.curve?.red).redMul(t);if(0===this.x.cmp(i))return!0;let r=e.clone();if(null===this.curve||null==this.curve.redN)throw Error("Curve or redN is not initialized.");let n=this.curve.redN.redMul(t);for(;0>r.cmp(this.curve.p)&&(r.iadd(this.curve.n),!(r.cmp(this.curve.p)>=0));)if(i.redIAdd(n),0===this.x.cmp(i))return!0;return!1}inspect(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"}isInfinity(){return 0===this.z.cmpn(0)}}let C=/^[0-9a-fA-F]*$/;function B(e){if("string"!=typeof e)throw TypeError("Invalid hex string");if(0!==e.length&&!C.test(e))throw Error("Invalid hex string")}let U=(e,t="Hash assertion failed")=>{if(!e)throw Error(t)};class V{pending;pendingTotal;blockSize;outSize;endian;_delta8;_delta32;padLength;hmacStrength;constructor(e,t,i,r){this.pending=null,this.pendingTotal=0,this.blockSize=e,this.outSize=t,this.hmacStrength=i,this.padLength=r/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}_update(e,t){throw Error("Not implemented")}_digest(){throw Error("Not implemented")}_digestHex(){throw Error("Not implemented")}update(e,t){if(e=D(e,t),null==this.pending?this.pending=e:this.pending=this.pending.concat(e),this.pendingTotal+=e.length,this.pending.length>=this._delta8){let t=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-t,e.length),0===this.pending.length&&(this.pending=null),e=function(e,t,i,r){let n=i-0;U(n%4==0);let a=Array(n/4);for(let t=0,i=0;t<a.length;t++,i+=4){let n;n="big"===r?e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3]:e[i+3]<<24|e[i+2]<<16|e[i+1]<<8|e[i],a[t]=n>>>0}return a}(e,0,e.length-t,this.endian);for(let t=0;t<e.length;t+=this._delta32)this._update(e,t)}return this}digest(){return this.update(this._pad()),U(null===this.pending),this._digest()}digestHex(){return this.update(this._pad()),U(null===this.pending),this._digestHex()}_pad(){let e,t=this.pendingTotal;if(!Number.isSafeInteger(t)||t<0)throw Error("Message too long for this hash function");let i=this._delta8,r=i-(t+this.padLength)%i,n=Array(r+this.padLength);for(e=1,n[0]=128;e<r;e++)n[e]=0;let a=this.padLength,s=1n<<BigInt(8*a),o=8n*BigInt(t);if(o>=s)throw Error("Message too long for this hash function");if("big"===this.endian){let t=Array(a);for(let e=a-1;e>=0;e--)t[e]=Number(255n&o),o>>=8n;for(let i=0;i<a;i++)n[e++]=t[i]}else for(let t=0;t<a;t++)n[e++]=Number(255n&o),o>>=8n;return n}}function D(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];let i=[];if("string"==typeof e)if("hex"!==t){let t=0;for(let a=0;a<e.length;a++){let s=e.charCodeAt(a);if(s<128)i[t++]=s;else if(s<2048)i[t++]=s>>6|192,i[t++]=63&s|128;else{var r,n;(r=e,n=a,(64512&r.charCodeAt(n))!=55296||n<0||n+1>=r.length?1:(64512&r.charCodeAt(n+1))!=56320)?i[t++]=s>>12|224:(s=65536+((1023&s)<<10)+(1023&e.charCodeAt(++a)),i[t++]=s>>18|240,i[t++]=s>>12&63|128),i[t++]=s>>6&63|128,i[t++]=63&s|128}}}else{B(e),e=function(e){if(B(e),0===e.length)return"";let t=e.toLowerCase();return t.length%2!=0&&(t="0"+t),t}(e);for(let t=0;t<e.length;t+=2)i.push(parseInt(e[t]+e[t+1],16))}else for(let t=0;t<e.length;t++)i[t]=0|e[t];return i}function L(e){return e0(e)}function F(e,t){let i="";for(let r=0;r<e.length;r++){let n=e[r];"little"===t&&(n=e0(n)),i+=function(e){if(7===e.length)return"0"+e;if(6===e.length)return"00"+e;if(5===e.length)return"000"+e;if(4===e.length)return"0000"+e;if(3===e.length)return"00000"+e;else if(2===e.length)return"000000"+e;else if(1===e.length)return"0000000"+e;else return e}(n.toString(16))}return i}function H(e){let t="";for(let i of e)t+=i.toString(16).padStart(2,"0");return t}function K(e,t){let i=Array(4*e.length);for(let r=0,n=0;r<e.length;r++,n+=4){let a=e[r];"big"===t?(i[n]=a>>>24,i[n+1]=a>>>16&255,i[n+2]=a>>>8&255,i[n+3]=255&a):(i[n+3]=a>>>24,i[n+2]=a>>>16&255,i[n+1]=a>>>8&255,i[n]=255&a)}return i}function M(e,t){return e>>>t|e<<32-t}function q(e,t){return e<<t|e>>>32-t}function $(e,t){return e+t>>>0}let z=[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],W=[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],j=[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],X=[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];function G(e,t,i,r){return e<=15?t^i^r:e<=31?t&i|~t&r:e<=47?(t|~i)^r:e<=63?t&r|i&~r:t^(i|~r)}class Y extends V{h;constructor(){super(512,160,192,64),this.endian="little",this.h=[0x67452301,0xefcdab89,0x98badcfe,0x10325476,0xc3d2e1f0],this.endian="little"}_update(e,t){var i,r,n,a,s,o;let c,l=this.h[0],h=this.h[1],d=this.h[2],u=this.h[3],f=this.h[4],p=l,g=h,m=d,y=u,b=f;for(let w=0;w<80;w++){c=$(q((i=l,r=G(w,h,d,u),i+r+e[z[w]+t]+((s=w)<=15?0:s<=31?0x5a827999:s<=47?0x6ed9eba1:s<=63?0x8f1bbcdc:0xa953fd4e)>>>0),j[w]),f),l=f,f=u,u=q(d,10),d=h,h=c,c=$(q((n=p,a=G(79-w,g,m,y),n+a+e[W[w]+t]+((o=w)<=15?0x50a28be6:o<=31?0x5c4dd124:o<=47?0x6d703ef3:0x7a6d76e9*!!(o<=63))>>>0),X[w]),b),p=b,b=y,y=q(m,10),m=g,g=c}c=this.h[1]+d+y>>>0,this.h[1]=this.h[2]+u+b>>>0,this.h[2]=this.h[3]+f+p>>>0,this.h[3]=this.h[4]+l+g>>>0,this.h[4]=this.h[0]+h+m>>>0,this.h[0]=c}_digest(){return K(this.h,"little")}_digestHex(){return F(this.h,"little")}}class J{h;constructor(){this.h=new eK}update(e,t){let i=e instanceof Uint8Array?e:Uint8Array.from(D(e,t));return this.h.update(i),this}digest(){return Array.from(this.h.digest())}digestHex(){return H(this.h.digest())}}class Z extends V{h;W;k;constructor(){super(512,160,80,64),this.k=[0x5a827999,0x6ed9eba1,0x8f1bbcdc,0xca62c1d6],this.h=[0x67452301,0xefcdab89,0x98badcfe,0x10325476,0xc3d2e1f0],this.W=Array(80)}_update(e,t){let i,r=this.W;for(void 0===t&&(t=0),i=0;i<16;i++)r[i]=e[t+i];for(;i<r.length;i++)r[i]=q(r[i-3]^r[i-8]^r[i-14]^r[i-16],1);let n=this.h[0],a=this.h[1],s=this.h[2],o=this.h[3],c=this.h[4];for(i=0;i<r.length;i++){var l,h,d,u,f,p,g,m,y;let e=~~(i/20),t=(u=q(n,5),l=a,h=s,d=o,f=0===e?(p=l)&h^~p&d:1===e||3===e?l^h^d:2===e?(g=l)&(m=h)^g&(y=d)^m&y:0,u+f+c+r[i]+this.k[e]>>>0);c=o,o=s,s=q(a,30),a=n,n=t}this.h[0]=$(this.h[0],n),this.h[1]=$(this.h[1],a),this.h[2]=$(this.h[2],s),this.h[3]=$(this.h[3],o),this.h[4]=$(this.h[4],c)}_digest(){return K(this.h,"big")}_digestHex(){return F(this.h,"big")}}class Q{h;constructor(){this.h=new eG}update(e,t){let i=Uint8Array.from(D(e,t));return this.h.update(i),this}digest(){return Array.from(this.h.digest())}digestHex(){return H(this.h.digest())}}class ee{h;blockSize=64;outSize=32;constructor(e){const t=e instanceof Uint8Array?e:Uint8Array.from(D(e,"string"==typeof e?"hex":void 0));this.h=new eJ(eM,t)}update(e,t){let i=e instanceof Uint8Array?e:Uint8Array.from(D(e,t));return this.h.update(i),this}digest(){return Array.from(this.h.digest())}digestHex(){return H(this.h.digest())}}class et{inner;outer;blockSize=64;constructor(e){let t;for((e=D(e,"hex")).length>this.blockSize&&(e=new Z().update(e).digest()),t=e.length;t<this.blockSize;t++)e.push(0);for(t=0;t<e.length;t++)e[t]^=54;for(t=0,this.inner=new Z().update(e);t<e.length;t++)e[t]^=106;this.outer=new Z().update(e)}update(e,t){return this.inner.update(e,t),this}digest(){return this.outer.update(this.inner.digest()),this.outer.digest()}digestHex(){return this.outer.update(this.inner.digest()),this.outer.digestHex()}}class ei{h;blockSize=128;outSize=32;constructor(e){const t=e instanceof Uint8Array?e:Uint8Array.from(D(e,"string"==typeof e?"hex":void 0));this.h=new eJ(eY,t)}update(e,t){let i=e instanceof Uint8Array?e:Uint8Array.from(D(e,t));return this.h.update(i),this}digest(){return Array.from(this.h.digest())}digestHex(){return H(this.h.digest())}}let er=(e,t)=>new Y().update(e,t).digest(),en=(e,t)=>new Z().update(e,t).digest(),ea=(e,t)=>new J().update(e,t).digest(),es=(e,t)=>new Q().update(e,t).digest(),eo=(e,t)=>{let i=new J().update(e,t).digest();return new J().update(i).digest()},ec=(e,t)=>{let i=new J().update(e,t).digest();return new Y().update(i).digest()},el=(e,t,i)=>new ee(e).update(t,i).digest(),eh=(e,t,i)=>new ei(e).update(t,i).digest();function ed(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`positive integer expected, got ${e}`)}function eu(e,...t){if(!(e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name))throw Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length)){let i=t.join(",");throw Error(`Uint8Array expected of length ${i}, got length=${e.length}`)}}function ef(e){if("function"!=typeof e||"function"!=typeof e.create)throw Error("Hash should be wrapped by utils.createHasher");ed(e.outputLen),ed(e.blockLen)}function ep(e,t=!0){if(!0===e.destroyed)throw Error("Hash instance has been destroyed");if(t&&!0===e.finished)throw Error("Hash#digest() has already been called")}function eg(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function em(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ey(e){return"string"==typeof e&&(e=eb(e)),eu(e),e}function eb(e){if("string"!=typeof e)throw Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function ew(e){return"string"==typeof e&&(e=eb(e)),eu(e),e}class ev{}function eI(e){let t=t=>e().update(ey(t)).digest(),i=e();return t.outputLen=i.outputLen,t.blockLen=i.blockLen,t.create=()=>e(),t}let ek=BigInt(0x100000000-1),eS=BigInt(32),eE=(e,t,i)=>e>>>i,ex=(e,t,i)=>e<<32-i|t>>>i,eP=(e,t,i)=>e>>>i|t<<32-i,eA=(e,t,i)=>e<<32-i|t>>>i,eN=(e,t,i)=>e<<64-i|t>>>i-32,eO=(e,t,i)=>e>>>i-32|t<<64-i;function eT(e,t,i,r){let n=(t>>>0)+(r>>>0);return{h:e+i+(n/0x100000000|0)|0,l:0|n}}let e_=(e,t,i)=>(e>>>0)+(t>>>0)+(i>>>0),eR=(e,t,i,r)=>t+i+r+(e/0x100000000|0)|0,eC=(e,t,i,r)=>(e>>>0)+(t>>>0)+(i>>>0)+(r>>>0),eB=(e,t,i,r,n)=>t+i+r+n+(e/0x100000000|0)|0,eU=(e,t,i,r,n)=>(e>>>0)+(t>>>0)+(i>>>0)+(r>>>0)+(n>>>0),eV=(e,t,i,r,n,a)=>t+i+r+n+a+(e/0x100000000|0)|0;class eD extends ev{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,i,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=i,this.isLE=r,this.buffer=new Uint8Array(e),this.view=em(this.buffer)}update(e){ep(this),eu(e=ey(e));let{view:t,buffer:i,blockLen:r}=this,n=e.length;for(let a=0;a<n;){let s=Math.min(r-this.pos,n-a);if(s===r){let t=em(e);for(;r<=n-a;a+=r)this.process(t,a);continue}i.set(e.subarray(a,a+s),this.pos),this.pos+=s,a+=s,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ep(this);eu(e);let t=this.outputLen;if(e.length<t)throw Error(`digestInto() expects output buffer of length at least ${t}`);this.finished=!0;let{buffer:i,view:r,blockLen:n,isLE:a}=this,{pos:s}=this;i[s++]=128,eg(this.buffer.subarray(s)),this.padOffset>n-s&&(this.process(r,0),s=0);for(let e=s;e<n;e++)i[e]=0;(function(e,t,i,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,i,r);let n=BigInt(32),a=BigInt(0xffffffff),s=Number(i>>n&a),o=Number(i&a),c=4*!!r,l=4*!r;e.setUint32(t+c,s,r),e.setUint32(t+l,o,r)})(r,n-8,BigInt(8*this.length),a),this.process(r,0);let o=em(e),c=this.outputLen;if(c%4!=0)throw Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,h=this.get();if(l>h.length)throw Error("_sha2: outputLen bigger than state");for(let e=0;e<l;e++)o.setUint32(4*e,h[e],a)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let i=e.slice(0,t);return this.destroy(),i}_cloneInto(e){(e||=new this.constructor).set(...this.get());let{blockLen:t,buffer:i,length:r,finished:n,destroyed:a,pos:s}=this;return e.destroyed=a,e.finished=n,e.length=r,e.pos=s,r%t!=0&&e.buffer.set(i),e}clone(){return this._cloneInto()}}let eL=Uint32Array.from([0x6a09e667,0xbb67ae85,0x3c6ef372,0xa54ff53a,0x510e527f,0x9b05688c,0x1f83d9ab,0x5be0cd19]),eF=Uint32Array.from([0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,0xe49b69c1,0xefbe4786,0xfc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x6ca6351,0x14292967,0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2]),eH=new Uint32Array(64);class eK extends eD{A=0|eL[0];B=0|eL[1];C=0|eL[2];D=0|eL[3];E=0|eL[4];F=0|eL[5];G=0|eL[6];H=0|eL[7];constructor(e=32){super(64,e,8,!1)}get(){let{A:e,B:t,C:i,D:r,E:n,F:a,G:s,H:o}=this;return[e,t,i,r,n,a,s,o]}set(e,t,i,r,n,a,s,o){this.A=0|e,this.B=0|t,this.C=0|i,this.D=0|r,this.E=0|n,this.F=0|a,this.G=0|s,this.H=0|o}process(e,t){var i,r,n,a,s,o,c,l,h;for(let i=0;i<16;i++,t+=4)eH[i]=e.getUint32(t);for(let e=16;e<64;e++){let t=eH[e-15],i=eH[e-2],r=M(t,7)^M(t,18)^t>>>3,n=M(i,17)^M(i,19)^i>>>10;eH[e]=$($(r,eH[e-7]),$(n,eH[e-16]))}let{A:d,B:u,C:f,D:p,E:g,F:m,G:y,H:b}=this;for(let e=0;e<64;e++){let t=(n=b,a=M(i=g,6)^M(i,11)^M(i,25),s=(r=g)&m^~r&y,n+a+s+eF[e]+eH[e]>>>0),w=$(M(o=d,2)^M(o,13)^M(o,22),(c=d)&(l=u)^c&(h=f)^l&h);b=y,y=m,m=g,g=$(p,t),p=f,f=u,u=d,d=$(t,w)}this.A=$(this.A,d),this.B=$(this.B,u),this.C=$(this.C,f),this.D=$(this.D,p),this.E=$(this.E,g),this.F=$(this.F,m),this.G=$(this.G,y),this.H=$(this.H,b)}roundClean(){eg(eH)}destroy(){eg(this.buffer),this.set(0,0,0,0,0,0,0,0)}}let eM=eI(()=>new eK),eq=Uint32Array.from([0x6a09e667,0xf3bcc908,0xbb67ae85,0x84caa73b,0x3c6ef372,0xfe94f82b,0xa54ff53a,0x5f1d36f1,0x510e527f,0xade682d1,0x9b05688c,0x2b3e6c1f,0x1f83d9ab,0xfb41bd6b,0x5be0cd19,0x137e2179]),e$=function(e,t=!1){let i=e.length,r=new Uint32Array(i),n=new Uint32Array(i);for(let a=0;a<i;a++){let{h:i,l:s}=function(e,t=!1){return t?{h:Number(e&ek),l:Number(e>>eS&ek)}:{h:0|Number(e>>eS&ek),l:0|Number(e&ek)}}(e[a],t);r[a]=i,n[a]=s}return[r,n]}(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),ez=e$[0],eW=e$[1],ej=new Uint32Array(80),eX=new Uint32Array(80);class eG extends eD{Ah=0|eq[0];Al=0|eq[1];Bh=0|eq[2];Bl=0|eq[3];Ch=0|eq[4];Cl=0|eq[5];Dh=0|eq[6];Dl=0|eq[7];Eh=0|eq[8];El=0|eq[9];Fh=0|eq[10];Fl=0|eq[11];Gh=0|eq[12];Gl=0|eq[13];Hh=0|eq[14];Hl=0|eq[15];constructor(e=64){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:i,Bl:r,Ch:n,Cl:a,Dh:s,Dl:o,Eh:c,El:l,Fh:h,Fl:d,Gh:u,Gl:f,Hh:p,Hl:g}=this;return[e,t,i,r,n,a,s,o,c,l,h,d,u,f,p,g]}set(e,t,i,r,n,a,s,o,c,l,h,d,u,f,p,g){this.Ah=0|e,this.Al=0|t,this.Bh=0|i,this.Bl=0|r,this.Ch=0|n,this.Cl=0|a,this.Dh=0|s,this.Dl=0|o,this.Eh=0|c,this.El=0|l,this.Fh=0|h,this.Fl=0|d,this.Gh=0|u,this.Gl=0|f,this.Hh=0|p,this.Hl=0|g}process(e,t){for(let i=0;i<16;i++,t+=4)ej[i]=e.getUint32(t),eX[i]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=0|ej[e-15],i=0|eX[e-15],r=eP(t,i,1)^eP(t,i,8)^eE(t,i,7),n=eA(t,i,1)^eA(t,i,8)^ex(t,i,7),a=0|ej[e-2],s=0|eX[e-2],o=eP(a,s,19)^eN(a,s,61)^eE(a,s,6),c=eC(n,eA(a,s,19)^eO(a,s,61)^ex(a,s,6),eX[e-7],eX[e-16]),l=eB(c,r,o,ej[e-7],ej[e-16]);ej[e]=0|l,eX[e]=0|c}let{Ah:i,Al:r,Bh:n,Bl:a,Ch:s,Cl:o,Dh:c,Dl:l,Eh:h,El:d,Fh:u,Fl:f,Gh:p,Gl:g,Hh:m,Hl:y}=this;for(let e=0;e<80;e++){let t=eP(h,d,14)^eP(h,d,18)^eN(h,d,41),b=eA(h,d,14)^eA(h,d,18)^eO(h,d,41),w=h&u^~h&p,v=eU(y,b,d&f^~d&g,eW[e],eX[e]),I=eV(v,m,t,w,ez[e],ej[e]),k=0|v,S=eP(i,r,28)^eN(i,r,34)^eN(i,r,39),E=eA(i,r,28)^eO(i,r,34)^eO(i,r,39),x=i&n^i&s^n&s,P=r&a^r&o^a&o;m=0|p,y=0|g,p=0|u,g=0|f,u=0|h,f=0|d,({h:h,l:d}=eT(0|c,0|l,0|I,0|k)),c=0|s,l=0|o,s=0|n,o=0|a,n=0|i,a=0|r;let A=e_(E,P,k);i=eR(A,S,x,I),r=0|A}({h:i,l:r}=eT(i,r,this.Ah,this.Al)),({h:n,l:a}=eT(n,a,this.Bh,this.Bl)),({h:s,l:o}=eT(s,o,this.Ch,this.Cl)),({h:c,l:l}=eT(c,l,this.Dh,this.Dl)),({h:h,l:d}=eT(h,d,this.Eh,this.El)),({h:u,l:f}=eT(u,f,this.Fh,this.Fl)),({h:p,l:g}=eT(p,g,this.Gh,this.Gl)),({h:m,l:y}=eT(m,y,this.Hh,this.Hl)),this.set(i,r,n,a,s,o,c,l,h,d,u,f,p,g,m,y)}roundClean(){eg(ej,eX)}destroy(){eg(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}let eY=eI(()=>new eG);class eJ extends ev{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,t){super(),ef(e);const i=ey(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,n=new Uint8Array(r);n.set(i.length>r?e.create().update(i).digest():i);for(let e=0;e<n.length;e++)n[e]^=54;this.iHash.update(n),this.oHash=e.create();for(let e=0;e<n.length;e++)n[e]^=106;this.oHash.update(n),eg(n)}update(e){return ep(this),this.iHash.update(e),this}digestInto(e){ep(this),eu(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:i,finished:r,destroyed:n,blockLen:a,outputLen:s}=this;return e.finished=r,e.destroyed=n,e.blockLen=a,e.outputLen=s,e.oHash=t._cloneInto(e.oHash??void 0),e.iHash=i._cloneInto(e.iHash??void 0),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}let eZ=(e,t,i)=>new eJ(e,t).update(i).digest();function eQ(e,t,i,r,n="sha512"){if("sha512"!==n)throw Error("Only sha512 is supported in this PBKDF2 implementation");try{let a=require("crypto");if("function"==typeof a.pbkdf2Sync){let s=Buffer.from(e),o=Buffer.from(t);return[...a.pbkdf2Sync(s,o,i,r,n)]}}catch{}return Array.from(function(e,t,i,r){let n;ef(e);let{c:a,dkLen:s}=Object.assign({dkLen:32},r);if(ed(a),ed(s),a<1)throw Error("iterations (c) should be >= 1");let o=ew(t),c=ew(i),l=new Uint8Array(s),h=eZ.create(e,o),d=h._cloneInto().update(c),u=new Uint8Array(4),f=em(u),p=new Uint8Array(h.outputLen);for(let e=1,t=0;t<s;e++,t+=h.outputLen){let i=l.subarray(t,t+h.outputLen);f.setInt32(0,e,!1),(n=d._cloneInto(n)).update(u).digestInto(p),i.set(p.subarray(0,i.length));for(let e=1;e<a;e++){h._cloneInto(n).update(p).digestInto(p);for(let e=0;e<i.length;e++)i[e]^=p[e]}}return h.destroy(),d.destroy(),null!=n&&n.destroy(),eg(p),l}(eY,Uint8Array.from(e),Uint8Array.from(t),{c:i,dkLen:r}))}function e0(e){return(e>>>24|e>>>8&65280|e<<8&0xff0000|(255&e)<<24)>>>0}eZ.create=(e,t)=>new eJ(e,t);let e1=(i=new Uint32Array(t=new ArrayBuffer(4)),r=new Uint8Array(t),i[0]=0x1020304,4===r[0]);function e2(e){return e1?e0(e):e>>>0}class e8{buffer;pos;capacity;constructor(e,t=256){if(null!=e&&e.length>0&&(t=Math.max(t,e.reduce((e,t)=>e+t.length,0))),this.buffer=new Uint8Array(t),this.pos=0,this.capacity=t,null!=e)for(const t of e)this.write(t)}getLength(){return this.pos}toUint8Array(){return this.buffer.slice(0,this.pos)}toArray(){return Array.from(this.toUint8Array())}toUint8ArrayZeroCopy(){return this.buffer.subarray(0,this.pos)}ensureCapacity(e){if(this.pos+e>this.capacity){let t=2*this.capacity;for(;this.pos+e>t;)t*=2;let i=new Uint8Array(t);i.set(this.buffer),this.buffer=i,this.capacity=t}}write(e){let t=e instanceof Uint8Array?e:new Uint8Array(e);return this.ensureCapacity(t.length),this.buffer.set(t,this.pos),this.pos+=t.length,this}writeReverse(e){let t=e instanceof Uint8Array?e:new Uint8Array(e);this.ensureCapacity(t.length);for(let e=t.length-1;e>=0;e--)this.buffer[this.pos]=t[e],this.pos+=1;return this}writeUInt8(e){return this.ensureCapacity(1),this.buffer[this.pos]=255&e,this.pos+=1,this}writeInt8(e){return this.writeUInt8(e),this}writeUInt16LE(e){return this.ensureCapacity(2),this.buffer[this.pos]=255&e,this.buffer[this.pos+1]=e>>8&255,this.pos+=2,this}writeUInt16BE(e){return this.ensureCapacity(2),this.buffer[this.pos]=e>>8&255,this.buffer[this.pos+1]=255&e,this.pos+=2,this}writeInt16LE(e){return this.writeUInt16LE(65535&e),this}writeInt16BE(e){return this.writeUInt16BE(65535&e),this}writeUInt32LE(e){return this.ensureCapacity(4),this.buffer[this.pos]=255&e,this.buffer[this.pos+1]=e>>8&255,this.buffer[this.pos+2]=e>>16&255,this.buffer[this.pos+3]=e>>24&255,this.pos+=4,this}writeUInt32BE(e){return this.ensureCapacity(4),this.buffer[this.pos]=e>>24&255,this.buffer[this.pos+1]=e>>16&255,this.buffer[this.pos+2]=e>>8&255,this.buffer[this.pos+3]=255&e,this.pos+=4,this}writeInt32LE(e){return this.writeUInt32LE(e>>>0),this}writeInt32BE(e){return this.writeUInt32BE(e>>>0),this}writeUInt64BEBn(e){let t=e.toArray("be",8);return this.write(t),this}writeUInt64LEBn(e){let t=e.toArray("be",8);return this.writeReverse(t),this}writeUInt64LE(e){let t=new P(e).toArray("be",8);return this.writeReverse(t),this}writeVarIntNum(e){let t=tp.varIntNum(e);return this.write(t),this}writeVarIntBn(e){let t=tp.varIntBn(e);return this.write(t),this}reset(){this.pos=0}}class e3{bin;pos;length;static makeReader(e,t=0){if(e instanceof Uint8Array)return new e3(e,t);if(Array.isArray(e))return new tg(e,t);throw Error("ReaderUint8Array.makeReader: bin must be Uint8Array or number[]")}constructor(e=new Uint8Array(0),t=0){if(e instanceof Uint8Array)this.bin=e;else if(Array.isArray(e))this.bin=new Uint8Array(e);else throw Error("ReaderUint8Array constructor: bin must be Uint8Array or number[]");this.pos=t,this.length=this.bin.length}eof(){return this.pos>=this.length}read(e=this.length){let t=this.pos,i=this.pos+e;return this.pos=i,this.bin.slice(t,i)}readReverse(e=this.length){let t=new Uint8Array(e);for(let i=0;i<e;i++)t[i]=this.bin[this.pos+e-1-i];return this.pos+=e,t}readUInt8(){let e=this.bin[this.pos];return this.pos+=1,e}readInt8(){let e=this.bin[this.pos];return this.pos+=1,(128&e)!=0?e-256:e}readUInt16BE(){let e=this.bin[this.pos]<<8|this.bin[this.pos+1];return this.pos+=2,e}readInt16BE(){let e=this.readUInt16BE();return(32768&e)!=0?e-65536:e}readUInt16LE(){let e=this.bin[this.pos]|this.bin[this.pos+1]<<8;return this.pos+=2,e}readInt16LE(){let e=this.readUInt16LE();return(32768&e)!=0?e-65536:e}readUInt32BE(){let e=0x1000000*this.bin[this.pos]+(this.bin[this.pos+1]<<16|this.bin[this.pos+2]<<8|this.bin[this.pos+3]);return this.pos+=4,e}readInt32BE(){let e=this.readUInt32BE();return(0x80000000&e)!=0?e-0x100000000:e}readUInt32LE(){let e=(this.bin[this.pos]|this.bin[this.pos+1]<<8|this.bin[this.pos+2]<<16|this.bin[this.pos+3]<<24)>>>0;return this.pos+=4,e}readInt32LE(){let e=this.readUInt32LE();return(0x80000000&e)!=0?e-0x100000000:e}readUInt64BEBn(){let e=new P(Array.from(this.bin.slice(this.pos,this.pos+8)));return this.pos=this.pos+8,e}readUInt64LEBn(){return new P(Array.from(this.readReverse(8)))}readInt64LEBn(){let e=new P(2).pow(new P(63)),t=new P(2).pow(new P(64)),i=new P(Array.from(this.readReverse(8)));return i.gte(e)&&(i=i.sub(t)),i}readVarIntNum(e=!0){let t,i=this.readUInt8();switch(i){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:if((t=e?this.readInt64LEBn():this.readUInt64LEBn()).lte(new P(2).pow(new P(53))))return t.toNumber();throw Error("number too large to retain precision - use readVarIntBn");default:return i}}readVarInt(){switch(this.bin[this.pos]){case 253:return this.read(3);case 254:return this.read(5);case 255:return this.read(9);default:return this.read(1)}}readVarIntBn(){let e=this.readUInt8();switch(e){case 253:return new P(this.readUInt16LE());case 254:return new P(this.readUInt32LE());case 255:return this.readUInt64LEBn();default:return new P(e)}}}let e6="u">typeof globalThis?globalThis.Buffer:void 0,e4=null!=e6&&"function"==typeof e6.from,e5=e=>e.length%2==1?"0"+e:e,e7="0123456789abcdef",e9=Array(256);for(let e=0;e<256;e++)e9[e]=e7[e>>4&15]+e7[15&e];let te=e=>{if(e4)return e6.from(e).toString("hex");if(0===e.length)return"";let t=Array(e.length);for(let i=0;i<e.length;i++)t[i]=e9[255&e[i]];return t.join("")},tt=(e,t)=>e instanceof Uint8Array?e:new Uint8Array(ti(e,t)),ti=(e,t)=>{if(Array.isArray(e))return e.slice();if(void 0===e)return[];if("string"!=typeof e)return Array.from(e,e=>0|e);switch(t){case"hex":return tn(e);case"base64":return ta(e);default:var i;return i=e,Array.from(new TextEncoder().encode(i))}},tr=new Int8Array(256).fill(-1);for(let e=0;e<10;e++)tr[48+e]=e;for(let e=0;e<6;e++)tr[65+e]=10+e,tr[97+e]=10+e;let tn=e=>{B(e);let t=e.length%2==0?e:"0"+e;if(e4)return Array.from(e6.from(t,"hex"));let i=Array(t.length/2),r=0;for(let e=0;e<t.length;e+=2){let n=tr[t.charCodeAt(e)],a=tr[t.charCodeAt(e+1)];i[r++]=n<<4|a}return i};function ta(e){if("string"!=typeof e)throw TypeError("msg must be a string");let t=e.trim().replace(/[\r\n\t\f\v ]+/g,""),i=(t=t.replace(/-/g,"+").replace(/_/g,"/")).indexOf("=");if(-1!==i){let e=t.slice(i);if(!/^={1,2}$/.test(e)||t.slice(0,i).includes("="))throw Error("Invalid base64 padding");t=t.slice(0,i)}let r=[],n=0,a=0;for(let e=0;e<t.length;e++){let i=t.charCodeAt(e),s=-1;if(i>=65&&i<=90)s=i-65;else if(i>=97&&i<=122)s=i-97+26;else if(i>=48&&i<=57)s=i-48+52;else if(43===i)s=62;else if(47===i)s=63;else throw Error(`Invalid base64 character at index ${e}`);for(n=n<<6|s,a+=6;a>=8;)a-=8,r.push(n>>a&255),n&=(1<<a)-1}return r}let ts=e=>new TextDecoder().decode(new Uint8Array(e)),to=(e,t)=>{switch(t){case"hex":return te(e);case"utf8":return ts(e);default:return e}};function tc(e){let t,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r="";for(t=0;t<e.length;t+=3){let n=e[t],a=t+1<e.length?e[t+1]:0,s=t+2<e.length?e[t+2]:0,o=n>>2,c=(3&n)<<4|a>>4,l=(15&a)<<2|s>>6,h=63&s;r+=i.charAt(o)+i.charAt(c),r+=t+1<e.length?i.charAt(l):"=",r+=t+2<e.length?i.charAt(h):"="}return r}let tl="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",th=e=>{let t;if(""===e||"string"!=typeof e)throw Error(`Expected base58 string but got “${e}”`);let i=e.match(/[IOl0]/gmu);if(null!==i)throw Error(`Invalid base58 character “${i.join("")}”`);let r=e.match(/^1+/gmu),n=null!==r?r[0].length:0,a=(e.length-n)*(Math.log(58)/Math.log(256))+1>>>0;return[...new Uint8Array([...new Uint8Array(n),...(e.match(/./gmu)??[]).map(e=>tl.indexOf(e)).reduce((e,t)=>e=e.map(e=>{let i=58*e+t;return t=i>>8,i}),new Uint8Array(a)).reverse().filter((t=!1,e=>t=t||e))])]},td=e=>{let t=Array(256).fill(-1);for(let e=0;e<tl.length;++e)t[tl.charCodeAt(e)]=e;let i=[];for(let r of e){let e=r;for(let r=0;r<i.length;++r){let n=(t[i[r]]<<8)+e;i[r]=tl.charCodeAt(n%58),e=n/58|0}for(;0!==e;)i.push(tl.charCodeAt(e%58)),e=e/58|0}for(let t of e)if(0!==t)break;else i.push(49);return i.reverse(),String.fromCharCode(...i)},tu=(e,t=[0])=>{let i=eo([...t,...e]);return td(i=[...t,...e,...i.slice(0,4)])},tf=(e,t,i=1)=>{let r=th(e),n=r.slice(0,i),a=r.slice(i,-4),s=[...n,...a];return s=eo(s),r.slice(-4).forEach((e,t)=>{if(e!==s[t])throw Error("Invalid checksum")}),"hex"===t&&(n=te(n),a=te(a)),{prefix:n,data:a}};class tp{bufs;length;constructor(e){for(const t of(this.bufs=void 0!==e?e:[],this.length=0,this.bufs))this.length+=t.length}getLength(){return this.length}toUint8Array(){let e=new Uint8Array(this.length),t=0;for(let i of this.bufs)e.set(i,t),t+=i.length;return e}toArray(){let e=Array(this.length),t=0;for(let i of this.bufs)if(i instanceof Uint8Array)for(let r=0;r<i.length;r++)e[t++]=i[r];else for(let r=0;r<i.length;r++)e[t++]=i[r];return e}toHex(){return this.toArray().map(e=>e.toString(16).padStart(2,"0")).join("")}write(e){return this.bufs.push(e),this.length+=e.length,this}writeReverse(e){let t=Array(e.length);for(let i=0;i<t.length;i++)t[i]=e[e.length-1-i];return this.write(t)}writeUInt8(e){let t=[,];return t[0]=255&e,this.write(t),this}writeInt8(e){let t=[,];return t[0]=255&e,this.write(t),this}writeUInt16BE(e){return this.write([e>>8&255,255&e])}writeInt16BE(e){return this.writeUInt16BE(65535&e)}writeUInt16LE(e){return this.write([255&e,e>>8&255])}writeInt16LE(e){return this.writeUInt16LE(65535&e)}writeUInt32BE(e){return this.write([e>>24&255,e>>16&255,e>>8&255,255&e])}writeInt32BE(e){return this.writeUInt32BE(e>>>0)}writeUInt32LE(e){return this.write([255&e,e>>8&255,e>>16&255,e>>24&255])}writeInt32LE(e){return this.writeUInt32LE(e>>>0)}writeUInt64BEBn(e){let t=e.toArray("be",8);return this.write(t),this}writeUInt64LEBn(e){let t=e.toArray("be",8);return this.writeReverse(t),this}writeUInt64LE(e){if(-1===e)this.write(Array(8).fill(255));else{let t=new P(e).toArray("be",8);this.writeReverse(t)}return this}writeVarIntNum(e){let t=tp.varIntNum(e);return this.write(t),this}writeVarIntBn(e){let t=tp.varIntBn(e);return this.write(t),this}static varIntNum(e){let t;if(e<0)return this.varIntBn(new P(e));if(e<253)t=[e];else if(e<65536)t=[253,255&e,e>>8&255];else if(e<0x100000000)t=[254,255&e,e>>8&255,e>>16&255,e>>24&255];else{let i=0|e,r=0|Math.floor(e/0x100000000);t=[255,255&i,i>>8&255,i>>16&255,i>>24&255,255&r,r>>8&255,r>>16&255,r>>24&255]}return t}static varIntBn(e){let t;if(e.isNeg()&&(e=e.add(tb)),e.ltn(253))t=[e.toNumber()];else if(e.ltn(65536)){let i=e.toNumber();t=[253,255&i,i>>8&255]}else if(e.lt(new P(0x100000000))){let i=e.toNumber();t=[254,255&i,i>>8&255,i>>16&255,i>>24&255]}else{let i=new tp;i.writeUInt8(255),i.writeUInt64LEBn(e),t=i.toArray()}return t}}class tg{bin;pos;length;constructor(e=[],t=0){this.bin=e,this.pos=t,this.length=e.length}eof(){return this.pos>=this.length}read(e=this.length){let t=this.pos,i=this.pos+e;return this.pos=i,this.bin.slice(t,i)}readReverse(e=this.length){let t=Array(e);for(let i=0;i<e;i++)t[i]=this.bin[this.pos+e-1-i];return this.pos+=e,t}readUInt8(){let e=this.bin[this.pos];return this.pos+=1,e}readInt8(){let e=this.bin[this.pos];return this.pos+=1,(128&e)!=0?e-256:e}readUInt16BE(){let e=this.bin[this.pos]<<8|this.bin[this.pos+1];return this.pos+=2,e}readInt16BE(){let e=this.readUInt16BE();return(32768&e)!=0?e-65536:e}readUInt16LE(){let e=this.bin[this.pos]|this.bin[this.pos+1]<<8;return this.pos+=2,e}readInt16LE(){let e=this.readUInt16LE();return(32768&e)!=0?e-65536:e}readUInt32BE(){let e=0x1000000*this.bin[this.pos]+(this.bin[this.pos+1]<<16|this.bin[this.pos+2]<<8|this.bin[this.pos+3]);return this.pos+=4,e}readInt32BE(){let e=this.readUInt32BE();return(0x80000000&e)!=0?e-0x100000000:e}readUInt32LE(){let e=(this.bin[this.pos]|this.bin[this.pos+1]<<8|this.bin[this.pos+2]<<16|this.bin[this.pos+3]<<24)>>>0;return this.pos+=4,e}readInt32LE(){let e=this.readUInt32LE();return(0x80000000&e)!=0?e-0x100000000:e}readUInt64BEBn(){let e=new P(this.bin.slice(this.pos,this.pos+8));return this.pos=this.pos+8,e}readUInt64LEBn(){return new P(this.readReverse(8))}readInt64LEBn(){let e=new P(this.readReverse(8));return e.gte(ty)&&(e=e.sub(tb)),e}readVarIntNum(e=!0){let t,i=this.readUInt8();switch(i){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:if((t=e?this.readInt64LEBn():this.readUInt64LEBn()).lte(new P(2).pow(new P(53))))return t.toNumber();throw Error("number too large to retain precision - use readVarIntBn");default:return i}}readVarInt(){switch(this.bin[this.pos]){case 253:return this.read(3);case 254:return this.read(5);case 255:return this.read(9);default:return this.read(1)}}readVarIntBn(){let e=this.readUInt8();switch(e){case 253:return new P(this.readUInt16LE());case 254:return new P(this.readUInt32LE());case 255:return this.readUInt64LEBn();default:return new P(e)}}}let tm=e=>{if(0===e.length)return e;let t=e[e.length-1];if((127&t)!=0)return e;if(1===e.length)return[];if((128&e[e.length-2])!=0)return e;for(let i=e.length-1;i>0;i--)if(0!==e[i-1])if((128&e[i-1])!=0)return e[i]=t,e.slice(0,i+1);else return e[i-1]|=t,e.slice(0,i);return[]},ty=new P(2).pow(new P(63)),tb=new P(2).pow(new P(64));function tw(e,t="Expected a valid value, but got undefined or null."){if(null==e)throw Error(t);return e}function tv(e,t){if(e.length!==t.length)return!1;let i=0;for(let r=0;r<e.length;r++)i|=e[r]^t[r];return 0===i}function tI(e,t,i){let r=-e,n=(t.X^i.X)&r,a=(t.Y^i.Y)&r,s=(t.Z^i.Z)&r;t.X^=n,i.X^=n,t.Y^=a,i.Y^=a,t.Z^=s,i.Z^=s}let tk=(1n<<256n)-1n;function tS(e){let t=e>>256n;return t=(e=(e&tk)+(t<<32n)+977n*t)>>256n,(e=(e&tk)+(t<<32n)+977n*t)>=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn&&(e-=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn),e}let tE=e=>tS((e%0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn+0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn)%0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn),tx=(e,t)=>e>=t?e-t:0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn-(t-e),tP=(e,t)=>tS(e*t),tA=e=>{let t=1n,i=0n,r=tE(e),n=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn;for(;r>1n;){let e=n/r;[t,i]=[i-t*e,t],[r,n]=[n-r*e,r]}return tE(t)},tN=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn+1n>>2n,tO=BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),tT=BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),t_=new Map,tR=e=>{let{X:t,Y:i,Z:r}=e;if(0n===i)return{X:0n,Y:1n,Z:0n};let n=tP(i,i),a=tP(4n,tP(t,n)),s=tP(3n,tP(t,t)),o=tx(tP(s,s),tP(2n,a)),c=tx(tP(s,tx(a,o)),tP(8n,tP(n,n)));return{X:o,Y:c,Z:tP(2n,tP(i,r))}},tC=(e,t)=>{if(0n===e.Z)return t;if(0n===t.Z)return e;let i=tP(e.Z,e.Z),r=tP(t.Z,t.Z),n=tP(e.X,r),a=tP(t.X,i),s=tP(e.Y,tP(r,t.Z)),o=tP(t.Y,tP(i,e.Z)),c=tx(a,n),l=tx(o,s);if(0n===c)return 0n===l?tR(e):{X:0n,Y:1n,Z:0n};let h=tP(c,c),d=tP(c,h),u=tP(n,h),f=tx(tx(tP(l,l),d),tP(2n,u)),p=tx(tP(l,tx(u,f)),tP(s,d));return{X:f,Y:p,Z:tP(c,tP(e.Z,t.Z))}},tB=e=>0n===e.Z?e:{X:e.X,Y:0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn-e.Y,Z:e.Z},tU=(e,t,i=5)=>{let r,n=`${i}:${t.x.toString(16)}:${t.y.toString(16)}`,a=t_.get(n);if(void 0===a){let e=1<<i-1;a=Array(e),r={X:t.x,Y:t.y,Z:1n},a[0]=r;let s=tR(r);for(let t=1;t<e;t++)a[t]=tC(a[t-1],s);t_.set(n,a)}else r=a[0];let s=[],o=1n<<BigInt(i),c=o>>1n,l=e;for(;l>0n;)if((1n&l)===0n)s.push(0),l>>=1n;else{let e=l&o-1n;e>c&&(e-=o),s.push(Number(e)),l-=e,l>>=1n}let h={X:0n,Y:1n,Z:0n};for(let e=s.length-1;e>=0;e--){h=tR(h);let t=s[e];if(0!==t){let e=Math.abs(t)>>1;h=tC(h,t>0?a[e]:tB(a[e]))}}return h},tV=e=>{let t=e%0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n;return t<0n&&(t+=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n),t},tD=(e,t)=>tV(e*t),tL=e=>{let t=1n,i=0n,r=tV(e),n=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n;for(;r>1n;){let e=n/r;[t,i]=[i-t*e,t],[r,n]=[n-r*e,r]}return tV(t)};class tF extends _{x;y;inf;static _assertOnCurve(e){if(!e.validate())throw Error("Invalid point");return e}static fromDER(e){if((4===e[0]||6===e[0]||7===e[0])&&e.length-1==64){if(6===e[0]){if(e[e.length-1]%2!=0)throw Error("Point string value is wrong length")}else if(7===e[0]&&e[e.length-1]%2!=1)throw Error("Point string value is wrong length");let t=new tF(e.slice(1,33),e.slice(33,65));return tF._assertOnCurve(t)}if((2===e[0]||3===e[0])&&e.length-1==32)return tF._assertOnCurve(tF.fromX(e.slice(1,33),3===e[0]));throw Error("Unknown point format")}static fromString(e){let t=ti(e,"hex");return tF._assertOnCurve(tF.fromDER(t))}static fromX(e,t){var i;let r,n,a=P.isBN(e)?BigInt("0x"+e.toString(16)):"string"==typeof e?BigInt("0x"+e):Array.isArray(e)?BigInt("0x"+te(e)):BigInt(e),s=(n=((e,t)=>{let i=1n;for(e=tE(e);t>0n;)(1n&t)!==0n&&(i=tP(i,e)),e=tP(e,e),t>>=1n;return i})(i=tS(tP(tP(r=a=tE(a),r),a)+7n),tN),tP(n,n)!==tE(i)?null:n);if(null===s)throw Error("Invalid point");let o=s;(1n&o)!==(t?1n:0n)&&(o=tx(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,o));let c=new P(a.toString(16),16),l=new P(o.toString(16),16);return tF._assertOnCurve(new tF(c,l))}static fromJSON(e,t){"string"==typeof e&&(e=JSON.parse(e));let i=new tF(e[0],e[1],t);if(i=tF._assertOnCurve(i),"object"!=typeof e[2]||null===e[2])return i;let r=e[2],n=e=>{let i=new tF(e[0],e[1],t);return tF._assertOnCurve(i)};return i.precomputed={beta:null,doubles:"object"==typeof r.doubles&&null!==r.doubles?{step:r.doubles.step,points:[i].concat(r.doubles.points.map(n))}:void 0,naf:"object"==typeof r.naf&&null!==r.naf?{wnd:r.naf.wnd,points:[i].concat(r.naf.points.map(n))}:void 0},i}constructor(e,t,i=!0){super("affine"),this.precomputed=null,null===e&&null===t?(this.x=null,this.y=null,this.inf=!0):(P.isBN(e)||(e=new P(e,16)),this.x=e,P.isBN(t)||(t=new P(t,16)),this.y=t,i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),null===this.x.red&&(this.x=this.x.toRed(this.curve.red)),null===this.y.red&&(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}validate(){if(this.inf||null==this.x||null==this.y)return!1;try{let e,t=BigInt("0x"+this.x.fromRed().toString(16)),i=BigInt("0x"+this.y.fromRed().toString(16)),r=tP(i,i),n=(e=tP(tP(t,t),t),tS(e+7n));return r===n}catch{return!1}}encode(e=!0,t){let i;if(this.inf)return"hex"===t?"00":[0];let r=this.curve.p.byteLength(),n=this.getX().toArray("be",r);return(i=e?[this.getY().isEven()?2:3].concat(n):[4].concat(n,this.getY().toArray("be",r)),"hex"!==t)?i:te(i)}toString(){return this.encode(!0,"hex")}toJSON(){return null==this.precomputed?[this.x,this.y]:[this.x,this.y,"object"==typeof this.precomputed&&null!==this.precomputed?{doubles:null!=this.precomputed.doubles?{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)}:void 0,naf:null!=this.precomputed.naf?{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}:void 0}:void 0]}inspect(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+(this.x?.fromRed()?.toString(16,2)??"undefined")+" y: "+(this.y?.fromRed()?.toString(16,2)??"undefined")+">"}isInfinity(){return this.inf}add(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e)||this.x?.cmp(e.x??new P(0))===0)return new tF(null,null);let t=tC({X:BigInt("0x"+this.x.fromRed().toString(16)),Y:BigInt("0x"+this.y.fromRed().toString(16)),Z:1n},{X:BigInt("0x"+e.x.fromRed().toString(16)),Y:BigInt("0x"+e.y.fromRed().toString(16)),Z:1n});if(0n===t.Z)return new tF(null,null);let i=tA(t.Z),r=tP(i,i),n=tP(t.X,r),a=tP(t.Y,tP(r,i));return new tF(n.toString(16),a.toString(16))}dbl(){if(this.inf)return this;if(null===this.x||null===this.y)throw Error("Point coordinates cannot be null");let e=BigInt("0x"+this.x.fromRed().toString(16)),t=BigInt("0x"+this.y.fromRed().toString(16));if(0n===t)return new tF(null,null);let i=tR({X:e,Y:t,Z:1n}),r=tA(i.Z),n=tP(r,r),a=tP(i.X,n),s=tP(i.Y,tP(n,r));return new tF(a.toString(16),s.toString(16))}getX(){return(this.x??new P(0)).fromRed()}getY(){return(this.y??new P(0)).fromRed()}mul(e){let t,i;if(P.isBN(e)||(e=new P(e,16)),this.inf)return this;let r=e.isNeg(),n=BigInt("0x"+(r?e.neg():e).toString(16));if(0n===(n=tE(n))||0n===n)return new tF(null,null);if(null===this.x||null===this.y)throw Error("Point coordinates cannot be null");this===this.curve.g?(t=tO,i=tT):(t=BigInt("0x"+this.x.fromRed().toString(16)),i=BigInt("0x"+this.y.fromRed().toString(16)));let a=tU(n,{x:t,y:i});if(0n===a.Z)return new tF(null,null);let s=tA(a.Z),o=tP(s,s),c=tP(a.X,o),l=tP(a.Y,tP(o,s)),h=new tF(new P(c.toString(16),16),new P(l.toString(16),16));return r?h.neg():h}mulCT(e){if(P.isBN(e)||(e=new P(e,16)),this.inf)return new tF(null,null);let t=e.isNeg(),i=BigInt("0x"+(t?e.neg():e).toString(16));if(0n===(i=tE(i)))return new tF(null,null);let r=this===this.curve.g?tO:BigInt("0x"+this.getX().toString(16)),n=this===this.curve.g?tT:BigInt("0x"+this.getY().toString(16)),a={X:0n,Y:1n,Z:0n},s={X:r,Y:n,Z:1n},o=i.toString(2);for(let e=0;e<o.length;e++){let t="1"===o[e]?1n:0n;tI(t,a,s),s=tC(a,s),tI(t,a=tR(a),s)}if(0n===a.Z)return new tF(null,null);let c=tA(a.Z),l=tP(c,c),h=tP(a.X,l),d=tP(a.Y,tP(l,c)),u=new tF(h.toString(16),d.toString(16));return t?u.neg():u}mulAdd(e,t,i){return this._endoWnafMulAdd([this,t],[e,i])}jmulAdd(e,t,i){return this._endoWnafMulAdd([this,t],[e,i],!0)}eq(e){return this===e||this.inf===e.inf&&(this.inf||0===(this.x??new P(0)).cmp(e.x??new P(0))&&0===(this.y??new P(0)).cmp(e.y??new P(0)))}neg(e){if(this.inf)return this;let t=new tF(this.x,(this.y??new P(0)).redNeg());if(!0===e&&null!=this.precomputed){let e=this.precomputed;t.precomputed={naf:null!=e.naf?{wnd:e.naf.wnd,points:e.naf.points.map(e=>e.neg())}:void 0,doubles:null!=e.doubles?{step:e.doubles.step,points:e.doubles.points.map(e=>e.neg())}:void 0,beta:void 0}}return t}dblp(e){let t=this;for(let i=0;i<e;i++)t=t.dbl();return t}toJ(){return this.inf?new R(null,null,null):new R(this.x,this.y,this.curve.one)}_getBeta(){if("object"!=typeof this.curve.endo)return;let e=this.precomputed;if("object"==typeof e&&null!==e&&"object"==typeof e.beta&&null!==e.beta)return e.beta;let t=new tF((this.x??new P(0)).redMul(this.curve.endo.beta),this.y);if(null!=e){let i=this.curve,r=e=>{if(null===e.x)throw Error("p.x is null");if(void 0===i.endo||null===i.endo)throw Error("curve.endo is undefined");return new tF(e.x.redMul(i.endo.beta),e.y)};e.beta=t,t.precomputed={beta:null,naf:null!=e.naf?{wnd:e.naf.wnd,points:e.naf.points.map(r)}:void 0,doubles:null!=e.doubles?{step:e.doubles.step,points:e.doubles.points.map(r)}:void 0}}return t}_fixedNafMul(e){if("object"!=typeof this.precomputed||null===this.precomputed)throw Error("_fixedNafMul requires precomputed values for the point");let t=this._getDoubles(),i=this.curve.getNAF(e,1,this.curve._bitLength),r=(1<<t.step+1)-(t.step%2==0?2:1);r/=3;let n=[];for(let e=0;e<i.length;e+=t.step){let r=0;for(let n=e+t.step-1;n>=e;n--)r=(r<<1)+i[n];n.push(r)}let a=new R(null,null,null),s=new R(null,null,null);for(let e=r;e>0;e--){for(let i=0;i<n.length;i++){let r=n[i];r===e?s=s.mixedAdd(t.points[i]):r===-e&&(s=s.mixedAdd(t.points[i].neg()))}a=a.add(s)}return a.toP()}_wnafMulAdd(e,t,i,r,n){let a=this.curve._wnafT1.map(e=>e.toNumber()),s=this.curve._wnafT2.map(()=>[]),o=this.curve._wnafT3.map(()=>[]),c=0;for(let i=0;i<r;i++){let r=t[i]._getNAFPoints(e);a[i]=r.wnd,s[i]=r.points}for(let e=r-1;e>=1;e-=2){let r=e-1,n=e;if(1!==a[r]||1!==a[n]){o[r]=this.curve.getNAF(i[r],a[r],this.curve._bitLength),o[n]=this.curve.getNAF(i[n],a[n],this.curve._bitLength),c=Math.max(o[r].length,c),c=Math.max(o[n].length,c);continue}let l=[t[r],null,null,t[n]];0===(t[r].y??new P(0)).cmp(t[n].y??new P(0))?(l[1]=t[r].add(t[n]),l[2]=t[r].toJ().mixedAdd(t[n].neg())):0===(t[r].y??new P(0)).cmp((t[n].y??new P(0)).redNeg())?(l[1]=t[r].toJ().mixedAdd(t[n]),l[2]=t[r].add(t[n].neg())):(l[1]=t[r].toJ().mixedAdd(t[n]),l[2]=t[r].toJ().mixedAdd(t[n].neg()));let h=[-3,-1,-5,-7,0,7,5,1,3],d=this.curve.getJSF(i[r],i[n]);c=Math.max(d[0].length,c),o[r]=Array(c),o[n]=Array(c);for(let e=0;e<c;e++){let t=0|d[0][e],i=0|d[1][e];o[r][e]=h[(t+1)*3+(i+1)],o[n][e]=0,s[r]=l}}let l=new R(null,null,null),h=this.curve._wnafT4;for(let e=c;e>=0;e--){let t=0;for(;e>=0;){let i=!0;for(let t=0;t<r;t++)h[t]=new P("number"==typeof o[t][e]?o[t][e]:0),h[t].isZero()||(i=!1);if(!i)break;t++,e--}if(e>=0&&t++,l=l.dblp(t),e<0)break;let i=new P(1),n=new P(2);for(let e=0;e<r;e++){let t,r=h[e];0!==r.cmpn(0)&&(l="affine"===(t=r.isNeg()?s[e][r.neg().sub(i).div(n).toNumber()].neg():s[e][r.sub(i).div(n).toNumber()]).type?l.mixedAdd(t):l.add(t))}}for(let e=0;e<r;e++)s[e]=[];return!0===n?l:l.toP()}_endoWnafMulAdd(e,t,i){let r,n=Array(2*e.length),a=Array(2*e.length);for(r=0;r<e.length;r++){let i=this.curve._endoSplit(t[r]),s=e[r],o=s._getBeta()??new tF(null,null);0!==i.k1.negative&&(i.k1.ineg(),s=s.neg(!0)),0!==i.k2.negative&&(i.k2.ineg(),o=o.neg(!0)),n[2*r]=s,n[2*r+1]=o,a[2*r]=i.k1,a[2*r+1]=i.k2}let s=this._wnafMulAdd(1,n,a,2*r,i);for(let e=0;e<2*r;e++)n[e]=null,a[e]=null;return s}_hasDoubles(e){if(null==this.precomputed)return!1;let t=this.precomputed.doubles;return"object"==typeof t&&t.points.length>=Math.ceil((e.bitLength()+1)/t.step)}_getDoubles(e,t){if("object"==typeof this.precomputed&&null!==this.precomputed&&"object"==typeof this.precomputed.doubles&&null!==this.precomputed.doubles)return this.precomputed.doubles;let i=[this],r=this;for(let n=0;n<(t??0);n+=e??1){for(let t=0;t<(e??1);t++)r=r.dbl();i.push(r)}return{step:e??1,points:i}}_getNAFPoints(e){if("object"==typeof this.precomputed&&null!==this.precomputed&&"object"==typeof this.precomputed.naf&&null!==this.precomputed.naf)return this.precomputed.naf;let t=[this],i=(1<<e)-1,r=1===i?null:this.dbl();for(let e=1;e<i;e++)null!==r&&(t[e]=t[e-1].add(r));return{wnd:e,points:t}}}class tH{p;red;redN;zero;one;two;g;n;a;b;tinv;zeroA;threeA;endo;_endoWnafT1;_endoWnafT2;_wnafT1;_wnafT2;_wnafT3;_wnafT4;_bitLength;static assert(e,t="Elliptic curve assertion failed"){if(!e)throw Error(t)}getNAF(e,t,i){let r=Array(Math.max(e.bitLength(),i)+1);r.fill(0);let n=1<<t+1,a=e.clone();for(let e=0;e<r.length;e++){let t,i=a.andln(n-1);a.isOdd()?(t=i>(n>>1)-1?(n>>1)-i:i,a.isubn(t)):t=0,r[e]=t,a.iushrn(1)}return r}getJSF(e,t){let i=[[],[]];e=e.clone(),t=t.clone();let r=0,n=0;for(;e.cmpn(-r)>0||t.cmpn(-n)>0;){let a,s,o=e.andln(3)+r&3,c=t.andln(3)+n&3;if(3===o&&(o=-1),3===c&&(c=-1),(1&o)==0)a=0;else{let t=e.andln(7)+r&7;a=(3===t||5===t)&&2===c?-o:o}if(i[0].push(a),(1&c)==0)s=0;else{let e=t.andln(7)+n&7;s=(3===e||5===e)&&2===o?-c:c}i[1].push(s),2*r===a+1&&(r=1-r),2*n===s+1&&(n=1-n),e.iushrn(1),t.iushrn(1)}return i}static cachedProperty(e,t,i){let r="_"+t;e.prototype[t]=function(){return void 0!==this[r]?this[r]:this[r]=i.call(this)}}static parseBytes(e){return"string"==typeof e?ti(e,"hex"):e}static intFromLE(e){return new P(e,"hex","le")}constructor(){if(void 0!==e)return e;e=this;const t={prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",{doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}]};this.p=new P(t.p,16),this.red=new O(t.prime),this.zero=new P(0).toRed(this.red),this.one=new P(1).toRed(this.red),this.two=new P(2).toRed(this.red),this.n=new P(t.n,16),this.g=tF.fromJSON(t.g,t.gRed),this._wnafT1=[,,,,],this._wnafT2=[,,,,],this._wnafT3=[,,,,],this._wnafT4=[,,,,],this._bitLength=this.n.bitLength(),this.redN=this.n.toRed(this.red),this.a=new P(t.a,16).toRed(this.red),this.b=new P(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=[,,,,],this._endoWnafT2=[,,,,]}_getEndomorphism(e){let t,i,r;if(this.zeroA&&1===this.p.modrn(3)){if(void 0!==e.beta)t=new P(e.beta,16).toRed(this.red);else{let e=this._getEndoRoots(this.p);if(null===e)throw Error("Failed to get endomorphism roots for beta.");t=(t=0>e[0].cmp(e[1])?e[0]:e[1]).toRed(this.red)}if(void 0!==e.lambda)i=new P(e.lambda,16);else{let e=this._getEndoRoots(this.n);if(null===e)throw Error("Failed to get endomorphism roots for lambda.");if(null==this.g)throw Error("Curve generator point (g) is not defined.");let r=this.g.mul(e[0])?.x,n=null!=this.g.x?this.g.x.redMul(t):void 0;if(null!=r&&null!=n&&0===r.cmp(n))i=e[0];else{if(i=e[1],null==this.g)throw Error("Curve generator point (g) is not defined.");let r=this.g.mul(i)?.x,n=null!=this.g.x?this.g.x.redMul(t):void 0;if(null==r||null==n)throw Error("Lambda computation failed: g.mul(lambda).x or g.x.redMul(beta) is undefined.");tH.assert(0===r.cmp(n),"Lambda selection does not match computed beta.")}}return r="object"==typeof e.basis&&null!==e.basis?e.basis.map(function(e){return{a:new P(e.a,16),b:new P(e.b,16)}}):this._getEndoBasis(i),{beta:t,lambda:i,basis:r}}}_getEndoRoots(e){let t=e===this.p?this.red:new T(e),i=new P(2).toRed(t).redInvm(),r=i.redNeg(),n=new P(3).toRed(t).redNeg().redSqrt().redMul(i);return[r.redAdd(n).fromRed(),r.redSub(n).fromRed()]}_getEndoBasis(e){let t,i,r,n,a,s,o=this.n.ushrn(Math.floor(this.n.bitLength()/2)),c=e,l=this.n.clone(),h=new P(1),d=new P(0),u=new P(0),f=new P(1),p=new P(0),g=0,m=new P(0),y=new P(0);for(;0!==c.cmpn(0);){let e=l.div(c);m=l.sub(e.mul(c)),y=u.sub(e.mul(h));let a=f.sub(e.mul(d));if(void 0===r&&0>m.cmp(o))t=p.neg(),i=h,r=m.neg(),n=y;else if(void 0!==r&&2==++g)break;p=m,l=c,c=m,u=h,h=y,f=d,d=a}if(void 0===t||void 0===i||void 0===r||void 0===n)throw Error("Failed to compute Endo Basis values");a=m.neg(),s=y;let b=r.sqr().add(n.sqr());return a.sqr().add(s.sqr()).cmp(b)>=0&&(a=t,s=i),0!==r.negative&&(r=r.neg(),n=n.neg()),0!==a.negative&&(a=a.neg(),s=s.neg()),[{a:r,b:n},{a:a,b:s}]}_endoSplit(e){if(null==this.endo)throw Error("Endomorphism is not defined.");let t=this.endo.basis,i=t[0],r=t[1],n=r.b.mul(e).divRound(this.n),a=i.b.neg().mul(e).divRound(this.n),s=n.mul(i.a),o=a.mul(r.a),c=n.mul(i.b),l=a.mul(r.b);return{k1:e.sub(s).sub(o),k2:c.add(l).neg()}}validate(e){if(e.inf)return!0;let t=e.x,i=e.y;if(null===t||null===i)throw Error("Point coordinates cannot be null");let r=this.a.redMul(t),n=t.redSqr().redMul(t).redIAdd(r).redIAdd(this.b);return 0===i.redSqr().redISub(n).cmpn(0)}}class tK{r;s;static fromDER(e,t){let i=(e,t)=>{let i=e[t.place++];if((128&i)==0)return i;throw Error("Invalid DER entity length")};e=ti(e,t);let r=new class{place;constructor(){this.place=0}};if(48!==e[r.place++])throw Error("Signature DER must start with 0x30");if(i(e,r)+r.place!==e.length||2!==e[r.place++])throw Error("Signature DER invalid");let n=i(e,r),a=e.slice(r.place,n+r.place);if(r.place+=n,2!==e[r.place++])throw Error("Signature DER invalid");let s=i(e,r);if(e.length!==s+r.place)throw Error("Invalid R-length in signature DER");let o=e.slice(r.place,s+r.place);if(0===a[0])if((128&a[1])!=0)a=a.slice(1);else throw Error("Invalid R-value in signature DER");if(0===o[0])if((128&o[1])!=0)o=o.slice(1);else throw Error("Invalid S-value in signature DER");return new tK(new P(a),new P(o))}static fromCompact(e,t){if(65!==(e=ti(e,t)).length)throw Error("Invalid Compact Signature");let i=e[0];if(i<27||i>=35)throw Error("Invalid Compact Byte");return new tK(new P(e.slice(1,33)),new P(e.slice(33,65)))}constructor(e,t){this.r=e,this.s=t}verify(e,t,i){return tY(new P(ea(e,i),16),this,t)}toString(e){return this.toDER(e)}toDER(e){let t=(e,t)=>{if(t<128)e.push(t);else throw Error("len must be < 0x80")},i=e=>{let t=0,i=e.length-1;for(;0===e[t]&&(128&e[t+1])==0&&t<i;)t++;return 0===t?e:e.slice(t)},r=this.r.toArray(),n=this.s.toArray();for((128&r[0])!=0&&(r=[0].concat(r)),(128&n[0])!=0&&(n=[0].concat(n)),r=i(r),n=i(n);0===n[0]&&(128&n[1])==0;)n=n.slice(1);let a=[2];t(a,r.length),(a=a.concat(r)).push(2),t(a,n.length);let s=a.concat(n),o=[48];return(t(o,s.length),o=o.concat(s),"hex"===e)?te(o):"base64"===e?tc(o):o}toCompact(e,t,i){if(e<0||e>3)throw Error("Invalid recovery param");if("boolean"!=typeof t)throw Error("Invalid compressed param");let r=27+e;t&&(r+=4);let n=[r];return(n=(n=n.concat(this.r.toArray("be",32))).concat(this.s.toArray("be",32)),"hex"===i)?te(n):"base64"===i?tc(n):n}RecoverPublicKey(e,t){let i=this.r,r=this.s,n=new tH,a=n.n,s=n.g,o=0!=e>>1?i.add(a):i,c=tF.fromX(o,(1&e)!=0);if(!c.mul(a).isInfinity())throw Error("nR is not at infinity");let l=t.neg().umod(a),h=i.invm(a),d=h.mul(r).umod(a),u=h.mul(l).umod(a),f=new tJ(s.mul(u).add(c.mul(d)));return f.validate(),f}CalculateRecoveryFactor(e,t){for(let i=0;i<4;i++){let r;try{r=this.RecoverPublicKey(i,t)}catch{continue}if(e.eq(r))return i}throw Error("Unable to find valid recovery factor")}}class tM{K;V;constructor(e,t){const i=ti(e,"hex"),r=ti(t,"hex");if(32!==i.length)throw Error("Entropy must be exactly 32 bytes (256 bits)");if(32!==r.length)throw Error("Nonce must be exactly 32 bytes (256 bits)");const n=i.concat(r);this.K=Array(32),this.V=Array(32);for(let e=0;e<32;e++)this.K[e]=0,this.V[e]=1;this.update(n)}hmac(){return new ee(this.K)}update(e){let t=this.hmac().update(this.V).update([0]);void 0!==e&&(t=t.update(e)),this.K=t.digest(),this.V=this.hmac().update(this.V).digest(),void 0!==e&&(this.K=this.hmac().update(this.V).update([1]).update(e).digest(),this.V=this.hmac().update(this.V).digest())}generate(e){let t=[];for(;t.length<e;)this.V=this.hmac().update(this.V).digest(),t=t.concat(this.V);let i=t.slice(0,e);return this.update(),te(i)}}function tq(e,t,i=new tH){let r=8*e.byteLength()-i.n.bitLength();return(r>0&&e.iushrn(r),!0!==t&&e.cmp(i.n)>=0)?e.sub(i.n):e}function t$(e){let t=e.toArray("be"),i=0n;for(let e=0;e<t.length;e++)i=i<<8n|BigInt(t[e]);return i}let tz=new tH,tW=tz.n.byteLength(),tj=tz.n.subn(1),tX=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n>>1n,tG=(e,t,i=!1,r)=>{let n=tz.n.bitLength();if(e.bitLength()>n)throw Error(`ECDSA message is too large: expected <= ${n} bits. Callers must hash messages before signing.`);let a=t$(e=tq(e)),s=t$(t),o=new tM(t.toArray("be",tW),e.toArray("be",tW));for(let e=0;;e++){let t="function"==typeof r?r(e):P.isBN(r)?r:new P(o.generate(tW),16);if(null==t)throw Error("k is undefined");if(0>(t=tq(t,!0)).cmpn(1)||t.cmp(tj)>0){if(P.isBN(r))throw Error("Invalid fixed custom K value (must be >1 and <N-1)");continue}let n=tz.g.mulCT(t);if(n.isInfinity()){if(P.isBN(r))throw Error("Invalid fixed custom K value (k\xb7G at infinity)");continue}let c=tV(BigInt("0x"+n.getX().toString(16)));if(0n===c){if(P.isBN(r))throw Error("Invalid fixed custom K value (r == 0)");continue}let l=tL(BigInt("0x"+t.toString(16))),h=tV(a+tD(c,s)),d=tD(l,h);if(0n===d){if(P.isBN(r))throw Error("Invalid fixed custom K value (s == 0)");continue}return i&&d>tX&&(d=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n-d),new tK(new P(c.toString(16),16),new P(d.toString(16),16))}},tY=(e,t,i)=>{let r=tz.n.bitLength();if(e.bitLength()>r)return!1;let n=t$(e);if(null==i.x||null==i.y)throw Error("Invalid public key: missing coordinates.");let a={x:t$(i.x),y:t$(i.y)},{r:s,s:o}={r:t$(t.r),s:t$(t.s)};if(s<=0n||s>=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n||o<=0n||o>=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n)return!1;let c=tL(o);if(0n===c)return!1;let l=tD(n,c),h=tD(s,c),d=tC(tU(l,{x:tO,y:tT}),tU(h,a));if(0n===d.Z)return!1;let u=tA(d.Z),f=tP(u,u);return tV(tP(d.X,f))===s};class tJ extends tF{static fromPrivateKey(e){let t=new tH().g.mul(e);return new tJ(t.x,t.y)}static fromString(e){let t=tF.fromString(e);return new tJ(t.x,t.y)}static fromDER(e){let t=tF.fromDER(e);return new tJ(t.x,t.y)}constructor(e,t=null,i=!0){if(e instanceof tF)super(e.getX(),e.getY());else{if(null===t&&i&&"string"==typeof e&&(66===e.length||130===e.length))throw Error('You are using the "new PublicKey()" constructor with a DER hex string. You need to use "PublicKey.fromString()" instead.');super(e,t,i)}}deriveSharedSecret(e){if(!this.validate())throw Error("Public key not valid for ECDH secret derivation");return this.mulCT(e)}verify(e,t,i){return tY(new P(ea(e,i),16),t,this)}toDER(e){return"hex"===e?this.encode(!0,e):this.encode(!0)}toHash(e){let t=ec(this.encode(!0));return"hex"===e?te(t):t}toAddress(e=[0]){if("string"==typeof e)if("testnet"===e||"test"===e)e=[111];else if("mainnet"===e||"main"===e)e=[0];else throw Error(`Invalid prefix ${e}`);return tu(this.toHash(),e)}deriveChild(e,t,i,r){let n;if("function"==typeof r){let t=r(e,this);void 0!==t?n=t:(n=this.deriveSharedSecret(e),"function"==typeof i&&i(e,this,n))}else n=this.deriveSharedSecret(e);let a=ti(t,"utf8"),s=el(n.encode(!0),a),o=new tH().g.mul(new P(s)),c=this.add(o);return new tJ(c.x,c.y)}static fromMsgHashAndCompactSignature(e,t,i){let r=ti(t,i);if(65!==r.length)throw Error("Invalid Compact Signature");let n=r[0];if(n<27||n>=35)throw Error("Invalid Compact Byte");let a=r[0]-27;return a>3&&(a-=4),new tK(new P(r.slice(1,33)),new P(r.slice(33,65))).RecoverPublicKey(a,e)}}class tZ{_rand;getRandomValues(e,t){let i=new Uint8Array(t);return e.crypto.getRandomValues(i),Array.from(i)}constructor(){const e=()=>{throw Error("No secure random number generator is available in this environment.")};if(this._rand=e,"u">typeof globalThis&&"function"==typeof globalThis.crypto?.getRandomValues){this._rand=e=>this.getRandomValues(globalThis,e);return}if("u">typeof process&&process.release?.name==="node")try{const e=require("crypto");if("function"==typeof e.randomBytes){this._rand=t=>Array.from(e.randomBytes(t));return}}catch(e){}if("u">typeof self&&"function"==typeof self.crypto?.getRandomValues){this._rand=e=>this.getRandomValues(self,e);return}if("u">typeof window&&"function"==typeof window.crypto?.getRandomValues){this._rand=e=>this.getRandomValues(window,e);return}this._rand=e}generate(e){return this._rand(e)}}let tQ=null,t0=e=>(null==tQ&&(tQ=new tZ),tQ.generate(e));class t1{x;y;constructor(e,t){const i=new tH().p;this.x=e.umod(i),this.y=t.umod(i)}toString(){return td(this.x.toArray())+"."+td(this.y.toArray())}static fromString(e){let[t,i]=e.split(".");return new t1(new P(th(t)),new P(th(i)))}}class t2{points;threshold;constructor(e,t){this.points=e,this.threshold=t??e.length}static fromPrivateKey(e,t){let i=new tH().p,r=[new t1(new P(0),new P(e.toArray()))];for(let e=1;e<t;e++){let e=new P(t0(32)).umod(i),t=new P(t0(32)).umod(i);r.push(new t1(e,t))}return new t2(r)}valueAt(e){let t=new tH().p,i=new P(0);for(let r=0;r<this.threshold;r++){let n=this.points[r].y;for(let i=0;i<this.threshold;i++)if(r!==i){let a=this.points[i].x,s=this.points[r].x,o=e.sub(a).umod(t),c=s.sub(a).umod(t).invm(t),l=o.mul(c).umod(t);n=n.mul(l).umod(t)}i=i.add(n).umod(t)}return i}}class t8{points;threshold;integrity;constructor(e,t,i){this.points=e,this.threshold=t,this.integrity=i}static fromBackupFormat(e){let t=0,i="";return new t8(e.map((e,r)=>{let n=e.split(".");if(4!==n.length)throw Error("Invalid share format in share "+r.toString()+'. Expected format: "x.y.t.i" - received '+e);let[a,s,o,c]=n;if(void 0===o)throw Error("Threshold not found in share "+r.toString());if(void 0===c)throw Error("Integrity not found in share "+r.toString());let l=parseInt(o);if(0!==r&&t!==l)throw Error("Threshold mismatch in share "+r.toString());if(0!==r&&i!==c)throw Error("Integrity mismatch in share "+r.toString());return t=l,i=c,t1.fromString([a,s].join("."))}),t,i)}toBackupFormat(){return this.points.map(e=>e.toString()+"."+this.threshold.toString()+"."+this.integrity)}}class t3 extends P{static fromRandom(){return new t3(t0(32))}static fromString(e,t="hex"){return new t3(super.fromString(e,t).toArray())}static fromHex(e){return new t3(super.fromHex(e,"big"))}static fromWif(e,t=1){let i=tf(e,void 0,t);if(33!==i.data.length)throw Error("Invalid WIF length");if(1!==i.data[32])throw Error("Invalid WIF padding");return new t3(i.data.slice(0,32))}constructor(e=0,t=10,i="be",r="apply"){if(e instanceof P?(super(),e.copy(this)):super(e,t,i),"nocheck"!==r){const e=this.checkInField();if(!e.inField){if("error"===r)throw Error("Input is out of field");P.move(this,e.modN)}}}checkInField(){let e=new tH,t=this.mod(e.n);return{inField:0===this.cmp(t),modN:t}}isValid(){return this.checkInField().inField}sign(e,t,i=!0,r){return tG(new P(ea(e,t),16),this,i,r)}verify(e,t,i){return tY(new P(ea(e,i),16),t,this.toPublicKey())}toPublicKey(){let e=new tH().g.mulCT(this);return new tJ(e.x,e.y)}toWif(e=[128]){if(!this.isValid())throw Error("Value is out of field");return tu([...this.toArray("be",32),1],e)}toAddress(e=[0]){return this.toPublicKey().toAddress(e)}toHex(){return super.toHex(32)}toString(e="hex",t=64){return super.toString(e,t)}deriveSharedSecret(e){if(!e.validate())throw Error("Public key not valid for ECDH secret derivation");return e.mulCT(this)}deriveChild(e,t,i,r){let n;if("function"==typeof r){let t=r(this,e);void 0!==t?n=t:(n=this.deriveSharedSecret(e),"function"==typeof i&&i(this,e,n))}else n=this.deriveSharedSecret(e);let a=ti(t,"utf8"),s=el(n.encode(!0),a),o=new tH;return new t3(this.add(new P(s)).mod(o.n).toArray())}toKeyShares(e,t){if("number"!=typeof e||"number"!=typeof t)throw Error("threshold and totalShares must be numbers");if(e<2)throw Error("threshold must be at least 2");if(t<2)throw Error("totalShares must be at least 2");if(e>t)throw Error("threshold should be less than or equal to totalShares");let i=t2.fromPrivateKey(this,e),r=[],n=new Set,a=new tH,s=t0(64);for(let e=0;e<t;e++){let t,o=0;do if(t=new P(eh(s,[e,o,...t0(32)])).umod(a.p),++o>5)throw Error("Failed to generate unique x coordinate after 5 attempts");while(t.isZero()||n.has(t.toString()));n.add(t.toString());let c=i.valueAt(t);r.push(new t1(t,c))}return new t8(r,e,this.toPublicKey().toHash("hex").slice(0,8))}toBackupShares(e,t){return this.toKeyShares(e,t).toBackupFormat()}static fromBackupShares(e){return t3.fromKeyShares(t8.fromBackupFormat(e))}static fromKeyShares(e){let{points:t,threshold:i,integrity:r}=e;if(i<2)throw Error("threshold must be at least 2");if(t.length<i)throw Error(`At least ${i} shares are required to reconstruct the private key`);for(let e=0;e<i;e++)for(let r=e+1;r<i;r++)if(t[e].x.eq(t[r].x))throw Error("Duplicate share detected, each must be unique.");let n=new t3(new t2(t,i).valueAt(new P(0)).toArray());if(n.toPublicKey().toHash("hex").slice(0,8)!==r)throw Error("Integrity hash mismatch");return n}}let t6=new Uint8Array([99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22]),t4=[[0,0,0,0],[1,0,0,0],[2,0,0,0],[4,0,0,0],[8,0,0,0],[16,0,0,0],[32,0,0,0],[64,0,0,0],[128,0,0,0],[27,0,0,0],[54,0,0,0]].map(e=>new Uint8Array(e)),t5=new Uint8Array(256),t7=new Uint8Array(256);for(let e=0;e<256;e++){let t=(e<<1^27*((128&e)!=0))&255;t5[e]=t,t7[e]=t^e}function t9(e,t,i){for(let r=0;r<4;r++){let n=t[i+r];for(let t=0;t<4;t++)e[t][r]^=n[t]}}function ie(e){for(let t=0;t<4;t++)e[t]=t6[e[t]]}function it(e,t){let i,r,n,a,s=[[],[],[],[]],o=[],c=Array.from(t);if(16===c.length)a=11;else if(24===c.length)a=13;else if(32===c.length)a=15;else throw Error("Illegal key length: "+String(c.length));let l=function(e,t){let i=t.length/4,r=[];for(let e=0;e<t.length;e++)e%4==0&&r.push([]),r[e>>2].push(t[e]);for(let t=i;t<4*e;t++){r[t]=[];let e=r[t-1].slice();if(t%i==0){!function(e){let t=e[0];e[0]=e[1],e[1]=e[2],e[2]=e[3],e[3]=t}(e),ie(e);let r=t4[t/i];for(let t=0;t<4;t++)e[t]^=r[t]}else i>6&&t%i==4&&ie(e);for(let n=0;n<4;n++)r[t][n]=r[t-i][n]^e[n]}return r}(a,c);for(let t=0;t<4;t++)s[0][t]=e[4*t],s[1][t]=e[4*t+1],s[2][t]=e[4*t+2],s[3][t]=e[4*t+3];for(t9(s,l,0),n=1;n<a;n++){for(let e=0;e<4;e++)for(let t=0;t<4;t++)s[e][t]=t6[s[e][t]];!function(e){let t=e[1][0];e[1][0]=e[1][1],e[1][1]=e[1][2],e[1][2]=e[1][3],e[1][3]=t,t=e[2][0];let i=e[2][1];e[2][0]=e[2][2],e[2][1]=e[2][3],e[2][2]=t,e[2][3]=i,t=e[3][3],e[3][3]=e[3][2],e[3][2]=e[3][1],e[3][1]=e[3][0],e[3][0]=t}(s),n+1<a&&function(e){for(let t=0;t<4;t++){let i=e[0][t],r=e[1][t],n=e[2][t],a=e[3][t];e[0][t]=t5[i]^t7[r]^n^a,e[1][t]=i^t5[r]^t7[n]^a,e[2][t]=i^r^t5[n]^t7[a],e[3][t]=t7[i]^r^n^t5[a]}}(s),t9(s,l,4*n)}for(i=0;i<4;i++)for(r=0;r<4;r++)o.push(s[r][i]);return o}let ii=function(e){if(e<0||e>Number.MAX_SAFE_INTEGER)throw Error("getBytes64: value out of range");let t=Math.floor(e/0x100000000),i=e>>>0;return[t>>>24&255,t>>>16&255,t>>>8&255,255&t,i>>>24&255,i>>>16&255,i>>>8&255,255&i]},ir=function(e){return new Uint8Array(e)},ia=((n=new Uint8Array(16))[0]=225,n),is=(...e)=>{let t=0;for(let i of e)t+=i.length;let i=new Uint8Array(t),r=0;for(let t of e)i.set(t,r),r+=t.length;return i},io=function(e){let t=0,i=0;for(let r=0;r<e.length;r++)i=t,t=1&e[r],e[r]=e[r]>>1,0!==i&&(e[r]=128|e[r]);return e},ic=function(e,t){let i=t.slice(),r=ir(16);for(let t=0;t<16;t++){let n=e[t];for(let e=7;e>=0;e--){let t=255&-(n>>e&1);for(let e=0;e<16;e++)r[e]^=i[e]&t;let a=255&-(1&i[15]);io(i);for(let e=0;e<16;e++)i[e]^=ia[e]&a}}return r},il=function(e){let t=e.slice();for(let e=15;e>11&&(t[e]=t[e]+1&255,0===t[e]);e--);return t};function ih(e,t){let i=ir(16),r=new Uint8Array(16);for(let n=0;n<e.length;n+=16){r.set(i);for(let t=0;t<16;t++)r[t]^=e[n+t]??0;i=ic(r,t)}return i}function id(e,t,i){if(0===e.length)return new Uint8Array(0);let r=new Uint8Array(e.length),n=t.slice(),a=0,s=Math.ceil(e.length/16);for(let t=0;t<s;t++){let o=it(n,i),c=Math.min(16,e.length-a);for(let t=0;t<c;t++)r[a]=e[a]^o[t],a++;t+1<s&&(n=il(n))}return r}function iu(e){let t,i,r=8*e.length;t=0===e.length?16:e.length%16==0?0:16-e.length%16;let n=new Uint8Array(16+e.length+t+16);i=16,n.set(e,i),i+=e.length,i+=t;let a=ii(0);n.set(a,i),i+=8;let s=ii(r);return n.set(s,i),n}class ip extends P{static fromRandom(){return new ip(t0(32))}encrypt(e,t){let i=new Uint8Array(t0(32)),{result:r,authenticationTag:n}=function(e,t,i){let r;if(0===t.length)throw Error("Initialization vector must not be empty");if(0===i.length)throw Error("Key must not be empty");let n=new Uint8Array(it(ir(16),i));if(12===t.length)r=is(t,ir(3),new Uint8Array([1]));else{let e=t;e.length%16!=0&&(e=is(e,ir(16-e.length%16)));let i=ii(8*t.length);r=ih(is(e,ir(8),new Uint8Array(i)),n)}let a=id(e,il(r),i),s=id(ih(iu(a),n),r,i);return{result:a,authenticationTag:s}}(new Uint8Array(ti(e,t)),i,new Uint8Array(this.toArray("be",32))),a=new Uint8Array(i.length+r.length+n.length),s=0;return a.set(i,s),s+=i.length,a.set(r,s),s+=r.length,a.set(n,s),to(Array.from(a),t)}decrypt(e,t){let i=new Uint8Array(ti(e,t));if(i.length<48)throw Error("Ciphertext too short");let r=i.slice(0,32),n=i.length-16,a=function(e,t,i,r){let n;if(0===e.length)throw Error("Cipher text must not be empty");if(0===t.length)throw Error("Initialization vector must not be empty");if(0===r.length)throw Error("Key must not be empty");let a=new Uint8Array(it(ir(16),r));if(12===t.length)n=is(t,ir(3),new Uint8Array([1]));else{let e=t;e.length%16!=0&&(e=is(e,ir(16-e.length%16)));let i=ii(8*t.length);n=ih(is(e,ir(8),new Uint8Array(i)),a)}let s=id(e,il(n),r),o=id(ih(iu(e),a),n,r);if(o.length!==i.length)return null;let c=0;for(let e=0;e<o.length;e++)c|=o[e]^i[e];return 0!==c?null:s}(i.slice(32,n),r,i.slice(n),new Uint8Array(this.toArray("be",32)));if(null===a)throw Error("Decryption failed!");return to(Array.from(a),t)}}let ig={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SPLIT:127,OP_NUM2BIN:128,OP_BIN2NUM:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_NOP3:178,OP_NOP4:179,OP_SUBSTR:179,OP_NOP5:180,OP_LEFT:180,OP_NOP6:181,OP_RIGHT:181,OP_NOP7:182,OP_LSHIFTNUM:182,OP_NOP8:183,OP_RSHIFTNUM:183,OP_NOP9:184,OP_NOP10:185,OP_NOP11:186,OP_NOP12:187,OP_NOP13:188,OP_NOP14:189,OP_NOP15:190,OP_NOP16:191,OP_NOP17:192,OP_NOP18:193,OP_NOP19:194,OP_NOP20:195,OP_NOP21:196,OP_NOP22:197,OP_NOP23:198,OP_NOP24:199,OP_NOP25:200,OP_NOP26:201,OP_NOP27:202,OP_NOP28:203,OP_NOP29:204,OP_NOP30:205,OP_NOP31:206,OP_NOP32:207,OP_NOP33:208,OP_NOP34:209,OP_NOP35:210,OP_NOP36:211,OP_NOP37:212,OP_NOP38:213,OP_NOP39:214,OP_NOP40:215,OP_NOP41:216,OP_NOP42:217,OP_NOP43:218,OP_NOP44:219,OP_NOP45:220,OP_NOP46:221,OP_NOP47:222,OP_NOP48:223,OP_NOP49:224,OP_NOP50:225,OP_NOP51:226,OP_NOP52:227,OP_NOP53:228,OP_NOP54:229,OP_NOP55:230,OP_NOP56:231,OP_NOP57:232,OP_NOP58:233,OP_NOP59:234,OP_NOP60:235,OP_NOP61:236,OP_NOP62:237,OP_NOP63:238,OP_NOP64:239,OP_NOP65:240,OP_NOP66:241,OP_NOP67:242,OP_NOP68:243,OP_NOP69:244,OP_NOP70:245,OP_NOP71:246,OP_NOP72:247,OP_NOP73:248,OP_NOP77:252,OP_SMALLDATA:249,OP_SMALLINTEGER:250,OP_PUBKEYS:251,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};for(let e in ig)ig[ig[e]]=e;let im=ig,iy="u">typeof globalThis?globalThis.Buffer:void 0;class ib{_chunks;parsed;rawBytesCache;hexCache;static fromASM(e){let t=[],i=e.split(" "),r=0;for(;r<i.length;){let e,n=i[r],a=0;if(n.startsWith("OP_")&&void 0!==im[n]&&(e=n,a=im[n]),"0"===n)a=0,t.push({op:a}),r+=1;else if("-1"===n)a=im.OP_1NEGATE,t.push({op:a}),r+=1;else if(void 0===e){let e=i[r];e.length%2!=0&&(e="0"+e);let n=ti(e,"hex");if(to(n,"hex")!==e)throw Error("invalid hex string in script");let s=n.length;s>=0&&s<im.OP_PUSHDATA1?a=s:s<256?a=im.OP_PUSHDATA1:s<65536?a=im.OP_PUSHDATA2:s<0x100000000&&(a=im.OP_PUSHDATA4),t.push({data:n,op:a}),r+=1}else a===im.OP_PUSHDATA1||a===im.OP_PUSHDATA2||a===im.OP_PUSHDATA4?(t.push({data:ti(i[r+2],"hex"),op:a}),r+=3):(t.push({op:a}),r+=1)}return new ib(t)}static fromHex(e){if(0===e.length)return ib.fromBinary([]);if(e.length%2!=0)throw Error("There is an uneven number of characters in the string which suggests it is not hex encoded.");if(!/^[0-9a-fA-F]+$/.test(e))throw Error("Some elements in this string are not hex encoded.");let t=ti(e,"hex");return new ib([],Uint8Array.from(t),e.toLowerCase(),!1)}static fromBinary(e){return new ib([],Uint8Array.from(e),void 0,!1)}constructor(e=[],t,i,r=!0){this._chunks=e,this.parsed=r,this.rawBytesCache=t,this.hexCache=i}get chunks(){return this.ensureParsed(),this._chunks}set chunks(e){this._chunks=e,this.parsed=!0,this.invalidateSerializationCaches()}ensureParsed(){this.parsed||(null!=this.rawBytesCache?this._chunks=ib.parseChunks(this.rawBytesCache):this._chunks=[],this.parsed=!0)}toASM(){let e="";for(let t=0;t<this.chunks.length;t++){let i=this.chunks[t];e+=this._chunkToString(i)}return e.slice(1)}toHex(){if(null!=this.hexCache)return this.hexCache;null==this.rawBytesCache&&(this.rawBytesCache=this.serializeChunksToBytes());let e=null!=iy?iy.from(this.rawBytesCache).toString("hex"):to(Array.from(this.rawBytesCache),"hex");return this.hexCache=e,e}toBinary(){return Array.from(this.toUint8Array())}toUint8Array(){return null==this.rawBytesCache&&(this.rawBytesCache=this.serializeChunksToBytes()),this.rawBytesCache}writeScript(e){return this.invalidateSerializationCaches(),this.chunks=this.chunks.concat(e.chunks),this}writeOpCode(e){return this.invalidateSerializationCaches(),this.chunks.push({op:e}),this}setChunkOpCode(e,t){return this.invalidateSerializationCaches(),this.chunks[e]={op:t},this}writeBn(e){if(this.invalidateSerializationCaches(),e.cmpn(0)===im.OP_0)this.chunks.push({op:im.OP_0});else if(0===e.cmpn(-1))this.chunks.push({op:im.OP_1NEGATE});else if(e.cmpn(1)>=0&&0>=e.cmpn(16))this.chunks.push({op:e.toNumber()+im.OP_1-1});else{let t=e.toSm("little");this.writeBin(t)}return this}writeBin(e){let t;this.invalidateSerializationCaches();let i=e.length>0?e:void 0;if(e.length>0&&e.length<im.OP_PUSHDATA1)t=e.length;else if(0===e.length)t=im.OP_0;else if(e.length<256)t=im.OP_PUSHDATA1;else if(e.length<65536)t=im.OP_PUSHDATA2;else if(e.length<0x100000000)t=im.OP_PUSHDATA4;else throw Error("You can't push that much data");return this.chunks.push({data:i,op:t}),this}writeNumber(e){return this.invalidateSerializationCaches(),this.writeBn(new P(e)),this}removeCodeseparators(){this.invalidateSerializationCaches();let e=[];for(let t=0;t<this.chunks.length;t++)this.chunks[t].op!==im.OP_CODESEPARATOR&&e.push(this.chunks[t]);return this.chunks=e,this}findAndDelete(e){this.invalidateSerializationCaches();let t=e.toHex();for(let e=0;e<this.chunks.length;)t===new ib([this.chunks[e]]).toHex()?this.chunks.splice(e,1):e++;return this}isPushOnly(){for(let e=0;e<this.chunks.length;e++)if(this.chunks[e].op>im.OP_16)return!1;return!0}isLockingScript(){throw Error("Not implemented")}isUnlockingScript(){throw Error("Not implemented")}static computeSerializedLength(e){let t=0;for(let i of e){if(t+=1,null==i.data)continue;let e=i.data.length;if(i.op===im.OP_RETURN){t+=e;break}i.op<im.OP_PUSHDATA1?t+=e:i.op===im.OP_PUSHDATA1?t+=1+e:i.op===im.OP_PUSHDATA2?t+=2+e:i.op===im.OP_PUSHDATA4&&(t+=4+e)}return t}serializeChunksToBytes(){let e=this.chunks,t=new Uint8Array(ib.computeSerializedLength(e)),i=0;for(let r=0;r<e.length;r++){let n=e[r];if(t[i++]=n.op,null!=n.data){if(n.op===im.OP_RETURN){t.set(n.data,i),i+=n.data.length;break}i=ib.writeChunkData(t,i,n.op,n.data)}}return t}invalidateSerializationCaches(){this.rawBytesCache=void 0,this.hexCache=void 0}static writeChunkData(e,t,i,r){let n=r.length;if(i<im.OP_PUSHDATA1)return e.set(r,t),t+n;if(i===im.OP_PUSHDATA1)return e[t++]=255&n,e.set(r,t),t+n;if(i===im.OP_PUSHDATA2)return e[t++]=255&n,e[t++]=n>>8&255,e.set(r,t),t+n;if(i===im.OP_PUSHDATA4){let i=n>>>0;return e[t++]=255&i,e[t++]=i>>8&255,e[t++]=i>>16&255,e[t++]=i>>24&255,e.set(r,t),t+n}return t}static parseChunks(e){let t=[],i=e.length,r=0,n=0;for(;r<i;){let a=e[r++]??0;if(a===im.OP_RETURN&&0===n){t.push({op:a,data:ib.copyRange(e,r,i)});break}if(a===im.OP_IF||a===im.OP_NOTIF||a===im.OP_VERIF||a===im.OP_VERNOTIF?n++:a===im.OP_ENDIF&&n--,a>0&&a<im.OP_PUSHDATA1){let n=Math.min(r+a,i);t.push({data:ib.copyRange(e,r,n),op:a}),r=n}else if(a===im.OP_PUSHDATA1){let n=r<i?e[r++]??0:0,s=Math.min(r+n,i);t.push({data:ib.copyRange(e,r,s),op:a}),r=s}else if(a===im.OP_PUSHDATA2){let n=(e[r]??0)|(e[r+1]??0)<<8,s=Math.min((r=Math.min(r+2,i))+n,i);t.push({data:ib.copyRange(e,r,s),op:a}),r=s}else if(a===im.OP_PUSHDATA4){let n=((e[r]??0)|(e[r+1]??0)<<8|(e[r+2]??0)<<16|(e[r+3]??0)<<24)>>>0,s=Math.min((r=Math.min(r+4,i))+n,i);t.push({data:ib.copyRange(e,r,s),op:a}),r=s}else t.push({op:a})}return t}static copyRange(e,t,i){let r=Math.max(i-t,0),n=Array(r);for(let i=0;i<r;i++)n[i]=e[t+i]??0;return n}_chunkToString(e){let t=e.op,i="";if(void 0===e.data){let e=im[t];i=`${i} ${e}`}else i=`${i} ${te(e.data)}`;return i}}let iw=new Uint8Array(0);class iv extends tK{static SIGHASH_ALL=1;static SIGHASH_NONE=2;static SIGHASH_SINGLE=3;static SIGHASH_CHRONICLE=32;static SIGHASH_FORKID=64;static SIGHASH_ANYONECANPAY=128;scope;static formatOTDA(e){let t=(e.scope&iv.SIGHASH_ANYONECANPAY)===iv.SIGHASH_ANYONECANPAY,i=(31&e.scope)===iv.SIGHASH_SINGLE,r=(31&e.scope)===iv.SIGHASH_NONE,n=(31&e.scope)===iv.SIGHASH_ALL||!i&&!r,a=new ib([...e.subscript.chunks]);a.findAndDelete(new ib().writeOpCode(im.OP_CODESEPARATOR));let s={sourceTXID:e.sourceTXID,sourceOutputIndex:e.sourceOutputIndex,sequence:e.inputSequence,script:a.toBinary()},o=new tp;function c(e){for(let t of(o.writeVarIntNum(e.length),e))o.writeReverse(ti(t.sourceTXID,"hex")),o.writeUInt32LE(t.sourceOutputIndex),o.writeVarIntNum(t.script.length),o.write(t.script),o.writeUInt32LE(t.sequence)}function l(e){for(let t of(o.writeVarIntNum(e.length),e))o.writeUInt64LE(t.satoshis),o.writeVarIntNum(t.script.length),o.write(t.script)}o.writeInt32LE(e.transactionVersion);let h=new ib().toBinary();if(t)t&&c([s]);else{let t=e.otherInputs.map(e=>({sourceTXID:e.sourceTXID??e.sourceTransaction?.id("hex")??"",sourceOutputIndex:e.sourceOutputIndex,sequence:i||r?0:e.sequence??0xffffffff,script:h}));t.splice(e.inputIndex,0,s),c(t)}if(n)l(e.outputs.map(e=>({satoshis:e.satoshis??0,script:e.lockingScript.toBinary()})));else if(i){let t=[];for(let i=0;i<e.inputIndex;i++)t.push({satoshis:-1,script:h});let i=e.outputs[e.inputIndex];void 0!==i&&t.push({satoshis:i.satoshis??0,script:i.lockingScript.toBinary()}),l(t)}else r&&l([]);return o.writeUInt32LE(e.lockTime),o.writeUInt32LE(e.scope>>>0),o.toUint8Array()}static formatBip143(e){let t=e.cache,i={sourceTXID:e.sourceTXID,sourceOutputIndex:e.sourceOutputIndex,sequence:e.inputSequence},r=[...e.otherInputs];function n(t){let i=new tp;if(void 0===t)for(let t of e.outputs){let e=t.satoshis??0;i.writeUInt64LE(e);let r=t.lockingScript?.toUint8Array()??iw;i.writeVarIntNum(r.length),i.write(r)}else{let r=e.outputs[t];if(void 0===r)throw Error(`Output at index ${t} does not exist`);let n=r.satoshis??0;i.writeUInt64LE(n);let a=r.lockingScript?.toUint8Array()??iw;i.writeVarIntNum(a.length),i.write(a)}return eo(i.toUint8Array())}r.splice(e.inputIndex,0,i);let a=Array(32).fill(0),s=Array(32).fill(0),o=Array(32).fill(0);if((e.scope&iv.SIGHASH_ANYONECANPAY)==0&&(t?.hashPrevouts!=null?a=t.hashPrevouts:(a=(()=>{let e=new tp;for(let t of r){if(void 0===t.sourceTXID){if(null==t.sourceTransaction)throw Error("Missing sourceTransaction for input");e.write(t.sourceTransaction.hash())}else e.writeReverse(ti(t.sourceTXID,"hex"));e.writeUInt32LE(t.sourceOutputIndex)}return eo(e.toUint8Array())})(),null!=t&&(t.hashPrevouts=a))),(e.scope&iv.SIGHASH_ANYONECANPAY)==0&&(31&e.scope)!==iv.SIGHASH_SINGLE&&(31&e.scope)!==iv.SIGHASH_NONE&&(t?.hashSequence!=null?s=t.hashSequence:(s=(()=>{let e=new tp;for(let t of r){let i=t.sequence??0xffffffff;e.writeUInt32LE(i)}return eo(e.toUint8Array())})(),null!=t&&(t.hashSequence=s))),(31&e.scope)!==iv.SIGHASH_SINGLE&&(31&e.scope)!==iv.SIGHASH_NONE)t?.hashOutputsAll!=null?o=t.hashOutputsAll:(o=n(),null!=t&&(t.hashOutputsAll=o));else if((31&e.scope)===iv.SIGHASH_SINGLE&&e.inputIndex<e.outputs.length){let i=e.inputIndex,r=t?.hashOutputsSingle?.get(i);null!=r?o=r:(o=n(i),null!=t&&(null==t.hashOutputsSingle&&(t.hashOutputsSingle=new Map),t.hashOutputsSingle.set(i,o)))}let c=new tp;c.writeInt32LE(e.transactionVersion),c.write(a),c.write(s),c.writeReverse(ti(e.sourceTXID,"hex")),c.writeUInt32LE(e.sourceOutputIndex);let l=e.subscript.toUint8Array();c.writeVarIntNum(l.length),c.write(l),c.writeUInt64LE(e.sourceSatoshis);let h=i.sequence;return c.writeUInt32LE(h),c.write(o),c.writeUInt32LE(e.lockTime),c.writeUInt32LE(e.scope>>>0),c.toUint8Array()}static format(e){return Array.from(this.formatBytes(e))}static formatBytes(e){let t=(e.scope&iv.SIGHASH_FORKID)!=0,i=!0!==e.ignoreChronicle&&(e.scope&iv.SIGHASH_CHRONICLE)!=0;return t&&!i?iv.formatBip143(e):!t||t&&i?iv.formatOTDA(e):new Uint8Array(0)}static fromChecksigFormat(e){if(0===e.length)return new iv(new P(1),new P(1),1);let t=e[e.length-1],i=e.slice(0,e.length-1),r=tK.fromDER(i);return new iv(r.r,r.s,t)}constructor(e,t,i){super(e,t),this.scope=i}hasLowS(){return!(this.s.ltn(1)||this.s.gt(new P("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))}toChecksigFormat(){return[...this.toDER(),this.scope]}}class iI{curve;constructor(){this.curve=new tH}generateProof(e,t,i,r){let n=t3.fromRandom(),a=n.toPublicKey(),s=i.mul(n),o=this.computeChallenge(t,i,r,s,a);return{R:a,SPrime:s,z:n.add(o.mul(e)).umod(this.curve.n)}}verifyProof(e,t,i,r){let{R:n,SPrime:a,z:s}=r,o=this.computeChallenge(e,t,i,a,n),c=this.curve.g.mul(s),l=n.add(e.mul(o));if(!c.eq(l))return!1;let h=t.mul(s),d=a.add(i.mul(o));return!!h.eq(d)}computeChallenge(e,t,i,r,n){return new P(ea([...e.encode(!0),...t.encode(!0),...i.encode(!0),...r.encode(!0),...n.encode(!0)])).umod(this.curve.n)}}let ik=/^[0-9a-fA-F]+$/,iS=BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),iE=BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),ix=iS-3n,iP=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),iA={x:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),y:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")},iN=iE>>1n;class iO{p=iS;n=iE;a=ix;b=iP;g=iA;mod(e,t=this.p){let i=e%t;return i>=0n?i:i+t}modInv(e,t){if(0n===e||t<=0n)throw Error("Invalid mod inverse input");let[i,r]=[this.mod(e,t),t],[n,a]=[1n,0n];for(;0n!==r;){let e=i/r;[i,r]=[r,i-e*r],[n,a]=[a,n-e*a]}if(1n!==i)throw Error("Inverse does not exist");return this.mod(n,t)}modPow(e,t,i){if(1n===i)return 0n;let r=1n,n=this.mod(e,i),a=t;for(;a>0n;)(1n&a)===1n&&(r=this.mod(r*n,i)),a>>=1n,n=this.mod(n*n,i);return r}isInfinity(e){return null===e}assertOnCurve(e){if(this.isInfinity(e))return;let{x:t,y:i}=e;if(this.mod(i*i)!==this.mod(this.mod(t*t*t+this.a*t)+this.b))throw Error("Point is not on secp256r1")}pointFromAffine(e,t){let i={x:this.mod(e),y:this.mod(t)};return this.assertOnCurve(i),i}pointFromHex(e){if(e.startsWith("04")){let t=BigInt("0x"+e.slice(2,66)),i=BigInt("0x"+e.slice(66));return this.pointFromAffine(t,i)}if(e.startsWith("02")||e.startsWith("03")){let t=BigInt("0x"+e.slice(2)),i=this.mod(this.mod(t*t*t+this.a*t)+this.b),r=this.modPow(i,this.p+1n>>2n,this.p),n=(1n&r)===1n===e.startsWith("03")?r:this.p-r;return this.pointFromAffine(t,n)}throw Error("Invalid point encoding")}pointToHex(e,t=!1){if(this.isInfinity(e))return"00";let i=this.to32BytesHex(e.x),r=this.to32BytesHex(e.y);return t?((1n&e.y)===0n?"02":"03")+i:"04"+i+r}addPoints(e,t){if(this.isInfinity(e))return t;if(this.isInfinity(t))return e;let{x:i,y:r}=e,{x:n,y:a}=t;if(i===n)return r===a?this.doublePoint(e):null;let s=this.mod((a-r)*this.modInv(n-i,this.p)),o=this.mod(s*s-i-n),c=this.mod(s*(i-o)-r);return{x:o,y:c}}doublePoint(e){if(this.isInfinity(e))return e;if(0n===e.y)return null;let t=this.mod((3n*e.x*e.x+this.a)*this.modInv(2n*e.y,this.p)),i=this.mod(t*t-2n*e.x),r=this.mod(t*(e.x-i)-e.y);return{x:i,y:r}}add(e,t){return this.addPoints(e,t)}multiply(e,t){if(0n===t||this.isInfinity(e))return null;let i=this.mod(t,this.n),r=null,n=e;for(;i>0n;)(1n&i)===1n&&(r=this.addPoints(r,n)),n=this.doublePoint(n),i>>=1n;return r}multiplyBase(e){return this.multiply(this.g,e)}isOnCurve(e){try{return this.assertOnCurve(e),!0}catch(e){return!1}}generatePrivateKeyHex(){return this.to32BytesHex(this.randomScalar())}randomScalar(){for(;;){let e=BigInt("0x"+te(t0(32)));if(e>0n&&e<this.n)return e}}normalizePrivateKey(e){let t=this.mod(e,this.n);if(0n===t)throw Error("Invalid private key");return t}toScalar(e){if("bigint"==typeof e)return this.normalizePrivateKey(e);let t=e.startsWith("0x")?e.slice(2):e;if(!ik.test(t)||0===t.length||t.length>64)throw Error("Private key must be a hex string <= 32 bytes");let i=BigInt("0x"+t.padStart(64,"0"));return this.normalizePrivateKey(i)}publicKeyFromPrivate(e){let t=this.toScalar(e);return this.multiplyBase(t)}sign(e,t,i={}){let{prehashed:r=!1,nonce:n}=i,a=this.toScalar(t),s=this.normalizeMessage(e,r),o=this.bytesToScalar(s),c=n??this.deterministicNonce(a,s);for(;;){let e=this.multiplyBase(c);if(this.isInfinity(e)){c=n??this.deterministicNonce(a,s);continue}let t=this.mod(e.x,this.n);if(0n===t){c=n??this.deterministicNonce(a,s);continue}let i=this.modInv(c,this.n),r=this.mod(i*(o+t*a),this.n);if(0n===r){c=n??this.deterministicNonce(a,s);continue}return r>iN&&(r=this.n-r),{r:this.to32BytesHex(t),s:this.to32BytesHex(r)}}}verify(e,t,i,r={}){let n,{prehashed:a=!1}=r;try{n="string"==typeof i?this.pointFromHex(i):i}catch{return!1}if(null==n||!this.isOnCurve(n))return!1;let s="bigint"==typeof t.r?t.r:BigInt("0x"+t.r),o="bigint"==typeof t.s?t.s:BigInt("0x"+t.s);if(s<=0n||s>=this.n||o<=0n||o>=this.n)return!1;let c=this.bytesToScalar(this.normalizeMessage(e,a)),l=this.modInv(o,this.n),h=this.mod(c*l,this.n),d=this.mod(s*l,this.n),u=this.addPoints(this.multiplyBase(h),this.multiply(n,d));return!this.isInfinity(u)&&this.mod(u.x,this.n)===s}normalizeMessage(e,t){let i=this.toBytes(e);return t?i:new Uint8Array(ea(i))}bytesToScalar(e){return BigInt("0x"+te(Array.from(e)))%this.n}deterministicNonce(e,t){let i=ti(this.to32BytesHex(e),"hex"),r=0;for(;r<1024;){let e=BigInt("0x"+te(el(i,0===r?Array.from(t):Array.from(t).concat([255&r]))))%this.n;if(e>0n)return e;r++}throw Error("Failed to derive deterministic nonce")}toBytes(e){if("string"==typeof e){let t=ik.test(e)&&e.length%2==0;return Uint8Array.from(ti(e,t?"hex":"utf8"))}if(e instanceof Uint8Array)return e;if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw Error("Unsupported message format")}to32BytesHex(e){return e.toString(16).padStart(64,"0")}}class iT extends ib{isLockingScript(){return!0}isUnlockingScript(){return!1}}class i_ extends ib{isLockingScript(){return!1}isUnlockingScript(){return!0}}class iR extends Error{txid;outputIndex;context;programCounter;stackState;altStackState;ifStackState;stackMem;altStackMem;constructor(e){const t=e.stackState.map(e=>null!=e&&void 0!==e.length?te(e):null==e?"null/undef":"INVALID_STACK_ITEM").join(", "),i=e.altStackState.map(e=>null!=e&&void 0!==e.length?te(e):null==e?"null/undef":"INVALID_STACK_ITEM").join(", "),r=`Context: ${e.context}, PC: ${e.programCounter}`,n=`Stack: [${t}] (len: ${e.stackState.length}, mem: ${e.stackMem})`,a=`AltStack: [${i}] (len: ${e.altStackState.length}, mem: ${e.altStackMem})`,s=`IfStack: [${e.ifStackState.join(", ")}]`;super(`Script evaluation error: ${e.message}
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.bsv=t():e.bsv=t()}(this,()=>(()=>{"use strict";let e,t,i,r,n;var a,s,o,c,l,h,d,u,f={};f.d=(e,t)=>{for(var i in t)f.o(t,i)&&!f.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},f.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),f.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var p={};f.r(p),f.d(p,{walletErrors:()=>d,BEEF_V1:()=>i0,BEEF_V2:()=>i1,SignedMessage:()=>b,KeyShares:()=>t8,ThreadHandle:()=>af,BlockHeadersService:()=>rr,MerklePath:()=>iZ,PrivateKey:()=>t3,RemittanceManager:()=>au,XDM:()=>rR,binaryHttpClient:()=>rt,LivePolicy:()=>iq,DefaultNonceProvider:()=>ay,HD:()=>rp,Brc29RemittanceModule:()=>aw,KeyDeriver:()=>rx,defaultBroadcaster:()=>iG,verifyNonce:()=>nO,AuthFetch:()=>nD,Secp256r1:()=>iO,UnlockingScript:()=>i_,Random:()=>t0,WERR_REVIEW_ACTIONS:()=>rL,TOTP:()=>rS,Curve:()=>tH,VerifiableCertificate:()=>nP,SHIPCast:()=>nX,WhatsOnChain:()=>iY,DEFAULT_SLAP_TRACKERS:()=>nq,MasterCertificate:()=>nx,SAT_UNIT:()=>ah,defaultChainTracker:()=>iJ,DEFAULT_TESTNET_SLAP_TRACKERS:()=>n$,OverlayAdminTokenTemplate:()=>nL,NodejsHttpClient:()=>i$,Schnorr:()=>iI,WERR_INSUFFICIENT_FUNDS:()=>rK,LockingScript:()=>iT,DEFAULT_IDENTITY_CLIENT_OPTIONS:()=>n3,PublicKey:()=>tJ,Transaction:()=>i3,TransactionSignature:()=>iv,defaultIdentity:()=>n8,TX_DATA_FORMAT:()=>l,Signature:()=>tK,Teranode:()=>ri,PointInFiniteField:()=>t1,CachedKeyDeriver:()=>rP,Polynomial:()=>t2,OP:()=>im,P2PKH:()=>iL,deserializeWalletProtocol:()=>at,BeefParty:()=>i5,InvoiceHandle:()=>ap,Point:()=>tF,BSM:()=>v,ATOMIC_BEEF:()=>i2,SatoshisPerKilobyte:()=>iM,Validation:()=>I,HTTPWalletWire:()=>rV,TopicBroadcaster:()=>nX,StorageUtils:()=>k,isBroadcastResponse:()=>i6,RPuzzle:()=>iF,StorageDownloader:()=>n2,CompletedProtoWallet:()=>nA,LookupResolver:()=>nW,LocalKVStore:()=>ai,ProtoWallet:()=>rN,FetchHttpClient:()=>iz,WalletErrors:()=>r_,ECIES:()=>rI,WERR_INVALID_PARAMETER:()=>rH,fromUtxo:()=>rk,ARC:()=>iX,ECDSA:()=>y,GlobalKVStore:()=>ac,WindowCWISubstrate:()=>rO,SessionManager:()=>nN,SHIPBroadcaster:()=>nX,StorageUploader:()=>n1,SymmetricKey:()=>ip,validateCertificates:()=>nR,EncryptedMessage:()=>w,REMITTANCE_STATE_TRANSITIONS:()=>al,Hash:()=>g,Spend:()=>iD,isBroadcastFailure:()=>i4,DEFAULT_REMITTANCE_MESSAGEBOX:()=>ad,Mnemonic:()=>rm,Script:()=>ib,HTTPWalletJSON:()=>rM,ScriptEvaluationError:()=>iR,PushDrop:()=>iK,WalletWireProcessor:()=>nE,WalletWireTransceiver:()=>rU,RegistryClient:()=>ae,HTTPSOverlayLookupFacilitator:()=>nz,BigNumber:()=>P,Beef:()=>i8,createNonce:()=>nT,getVerifiableCertificates:()=>n_,BeefTx:()=>iQ,Certificate:()=>rC,KNOWN_IDENTITY_TYPES:()=>n6,HTTPSOverlayBroadcastFacilitator:()=>nj,Peer:()=>nB,ReactNativeWebView:()=>rq,WhatsOnChainBroadcaster:()=>i7,defaultHttpClient:()=>iW,withDoubleSpendRetry:()=>nG,SimplifiedFetchTransport:()=>nV,WalletError:()=>rT,SecurityLevels:()=>h,DefaultLockingScriptProvider:()=>ab,WalletClient:()=>nS,IdentityClient:()=>n9,Utils:()=>m});var g={};f.r(g),f.d(g,{RIPEMD160:()=>Y,SHA1:()=>Z,SHA1HMAC:()=>et,SHA256:()=>J,SHA256HMAC:()=>ee,SHA512:()=>Q,SHA512HMAC:()=>ei,hash160:()=>ec,hash256:()=>eo,htonl:()=>L,pbkdf2:()=>eQ,realHtonl:()=>e2,ripemd160:()=>er,sha1:()=>en,sha256:()=>ea,sha256hmac:()=>el,sha512:()=>es,sha512hmac:()=>eh,swapBytes32:()=>e0,toArray:()=>D});var m={};f.r(m),f.d(m,{Reader:()=>tg,ReaderUint8Array:()=>e3,Writer:()=>tp,WriterUint8Array:()=>e8,base64ToArray:()=>ta,constantTimeEquals:()=>tv,encode:()=>to,fromBase58:()=>th,fromBase58Check:()=>tf,minimallyEncode:()=>tm,toArray:()=>ti,toBase58:()=>td,toBase58Check:()=>tu,toBase64:()=>tc,toHex:()=>te,toUTF8:()=>ts,toUint8Array:()=>tt,verifyNotNull:()=>tw,zero2:()=>e5});var y={};f.r(y),f.d(y,{sign:()=>tG,verify:()=>tY});var b={};f.r(b),f.d(b,{sign:()=>ra,verify:()=>rs});var w={};f.r(w),f.d(w,{decrypt:()=>rl,encrypt:()=>rc});var v={};f.r(v),f.d(v,{magicHash:()=>rd,sign:()=>ru,verify:()=>rf});var I={};f.r(I),f.d(I,{isHexString:()=>r4,parseWalletOutpoint:()=>r$,specOpThrowReviewActions:()=>nk,validateAbortActionArgs:()=>nr,validateAcquireDirectCertificateArgs:()=>nm,validateAcquireIssuanceCertificateArgs:()=>ng,validateBase64String:()=>r8,validateBasketInsertion:()=>na,validateCreateActionArgs:()=>ne,validateCreateActionInput:()=>r5,validateCreateActionOptions:()=>r9,validateCreateActionOutput:()=>r7,validateDiscoverByAttributesArgs:()=>nw,validateDiscoverByIdentityKeyArgs:()=>nb,validateInteger:()=>rG,validateInternalizeActionArgs:()=>nc,validateInternalizeOutput:()=>ns,validateListActionsArgs:()=>nI,validateListCertificatesArgs:()=>nf,validateListOutputsArgs:()=>nv,validateOptionalInteger:()=>rX,validateOptionalOutpointString:()=>nl,validateOriginator:()=>no,validateOutpointString:()=>nh,validatePositiveIntegerOrZero:()=>rY,validateProveCertificateArgs:()=>ny,validateRelinquishCertificateArgs:()=>nu,validateRelinquishOutputArgs:()=>nd,validateSatoshis:()=>rj,validateSignActionArgs:()=>ni,validateSignActionOptions:()=>nt,validateStringLength:()=>rJ,validateWalletPayment:()=>nn});var k={};f.r(k),f.d(k,{getHashFromURL:()=>nQ,getURLForFile:()=>nZ,getURLForHash:()=>nJ,isValidURL:()=>n0,normalizeURL:()=>nY});let S="u">typeof globalThis?globalThis.Buffer:void 0,E=null!=S&&"function"==typeof S.from,x=new Int8Array(256).fill(-1);for(let e=0;e<10;e++)x[48+e]=e;for(let e=0;e<6;e++)x[65+e]=10+e,x[97+e]=10+e;class P{static zeros=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"];static groupSizes=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5];static groupBases=[0,0,0x2000000,0x290d741,0x1000000,0x2e90edd,0x39aa400,0x267bf47,0x1000000,0x290d741,1e7,0x12959c3,0x222c000,0x3bd7765,7529536,0xadcea1,0x1000000,0x1704f61,0x206fc40,0x2cddcf9,64e6,4084101,5153632,6436343,7962624,9765625,0xb54ba0,0xdaf26b,0x1069c00,0x138f9ad,243e5,0x1b4d89f,0x2000000,0x25528a1,0x2b54a20,0x3216b93,0x39aa400];static wordSize=26;static WORD_SIZE_BIGINT=BigInt(P.wordSize);static WORD_MASK=(1n<<P.WORD_SIZE_BIGINT)-1n;static MAX_SAFE_INTEGER_BIGINT=BigInt(Number.MAX_SAFE_INTEGER);static MIN_SAFE_INTEGER_BIGINT=BigInt(Number.MIN_SAFE_INTEGER);static MAX_IMULN_ARG=0x3ffffff;static MAX_NUMBER_CONSTRUCTOR_MAG_BIGINT=(1n<<53n)-1n;_magnitude;_sign;_nominalWordLength;red;get negative(){return this._sign}set negative(e){this.assert(0===e||1===e,"Negative property must be 0 or 1"),0n===this._magnitude?this._sign=0:this._sign=+(1===e)}get _computedWordsArray(){if(0n===this._magnitude)return[0];let e=[],t=this._magnitude;for(;t>0n;)e.push(Number(t&P.WORD_MASK)),t>>=P.WORD_SIZE_BIGINT;return e.length>0?e:[0]}get words(){let e=this._computedWordsArray;if(this._nominalWordLength<=e.length)return e;let t=Array(this._nominalWordLength).fill(0);for(let i=0;i<e.length;i++)t[i]=e[i];return t}set words(e){let t=this._sign,i=0n,r=e.length>0?e.length:1;for(let t=r-1;t>=0;t--){let r=void 0===e[t]?0:e[t];i=i<<P.WORD_SIZE_BIGINT|BigInt(r&Number(P.WORD_MASK))}this._magnitude=i,this._sign=t,this._nominalWordLength=r,this.normSign()}get length(){return Math.max(1,this._nominalWordLength)}static isBN(e){return e instanceof P||null!==e&&"object"==typeof e&&e.constructor?.wordSize===P.wordSize&&Array.isArray(e.words)}static max(e,t){return e.cmp(t)>0?e:t}static min(e,t){return 0>e.cmp(t)?e:t}constructor(e=0,t=10,i="be"){if(this._magnitude=0n,this._sign=0,this._nominalWordLength=1,this.red=null,void 0===e&&(e=0),null===e)return void this._initializeState(0n,0);if("bigint"==typeof e){this._initializeState(e<0n?-e:e,+(e<0n)),this.normSign();return}let r=t,n=i;if(("le"===t||"be"===t)&&(n=t,r=10),"number"==typeof e)return void this.initNumber(e,n);if(Array.isArray(e))return void this.initArray(e,n);if("string"==typeof e){"hex"===r&&(r=16),this.assert("number"==typeof r&&r===(0|r)&&r>=2&&r<=36,"Base must be an integer between 2 and 36");const t=e.toString().replace(/\s+/g,"");let i=0,a=0;t.startsWith("-")?(i++,a=1):t.startsWith("+")&&i++;const s=t.substring(i);if(0===s.length){this._initializeState(0n,1===a&&t.startsWith("-")?1:0),this.normSign();return}if(16===r){let e;if("le"===n){const e=[];let t=s;t.length%2!=0&&(t="0"+t);for(let i=0;i<t.length;i+=2){const r=parseInt(t.substring(i,i+2),16);if(isNaN(r))throw Error("Invalid character in "+t);e.push(r)}this.initArray(e,"le"),this._sign=a,this.normSign();return}try{e=BigInt("0x"+s)}catch(e){throw Error("Invalid character in "+s)}this._initializeState(e,a),this.normSign()}else try{if(this._parseBaseString(s,r),this._sign=a,this.normSign(),"le"===n){const e=this._sign;this.initArray(this.toArray("be"),"le"),this._sign=e,this.normSign()}}catch(e){if(e.message.includes("Invalid character in string")||e.message.includes("Invalid digit for base")||e.message.startsWith("Invalid character:"))throw Error("Invalid character");throw e}}else 0!==e?this.assert(!1,"Unsupported input type for BigNumber constructor"):this._initializeState(0n,0)}_bigIntToStringInBase(e,t){if(0n===e)return"0";if(t<2||t>36)throw Error("Base must be between 2 and 36");let i="",r=e>0n?e:-e,n=BigInt(t);for(;r>0n;)i="0123456789abcdefghijklmnopqrstuvwxyz"[Number(r%n)]+i,r/=n;return i}_parseBaseString(e,t){if(0===e.length){this._magnitude=0n,this._finishInitialization();return}this._magnitude=0n;let i=BigInt(t),r=P.groupSizes[t],n=BigInt(P.groupBases[t]);(0===r||0n===n)&&(0===(r=Math.floor(Math.log(0x3ffffff)/Math.log(t)))&&(r=1),n=i**BigInt(r));let a=0,s=e.length,o=s%r;if(0===o&&s>0&&(o=r),o>0){let i=e.substring(a,a+o);this._magnitude=BigInt(this._parseBaseWord(i,t)),a+=o}for(;a<s;){let i=e.substring(a,a+r),s=BigInt(this._parseBaseWord(i,t));this._magnitude=this._magnitude*n+s,a+=r}this._finishInitialization()}_parseBaseWord(e,t){let i=0;for(let r=0;r<e.length;r++){let n,a=e.charCodeAt(r);if(a>=48&&a<=57)n=a-48;else if(a>=65&&a<=90)n=a-65+10;else if(a>=97&&a<=122)n=a-97+10;else throw Error("Invalid character: "+e[r]);if(n>=t)throw Error("Invalid character");i=i*t+n}return i}_initializeState(e,t){this._magnitude=e,this._sign=0n===e?0:t,this._finishInitialization()}_finishInitialization(){if(0n===this._magnitude)this._nominalWordLength=1,this._sign=0;else{let e=this._magnitude.toString(2).length;this._nominalWordLength=Math.max(1,Math.ceil(e/P.wordSize))}}assert(e,t="Assertion failed"){if(!e)throw Error(t)}initNumber(e,t="be"){if(this.assert(BigInt(Math.abs(e))<=P.MAX_NUMBER_CONSTRUCTOR_MAG_BIGINT,"The number is larger than 2 ^ 53 (unsafe)"),this.assert(e%1==0,"Number must be an integer for BigNumber conversion"),this._initializeState(BigInt(Math.abs(e)),+(e<0)),"le"===t){let e=this._sign,t=this.toArray("be");this.initArray(t,"le"),this._sign=e,this.normSign()}return this}initArray(e,t){if(0===e.length)return this._initializeState(0n,0),this;let i=0n;if("be"===t)for(let t=0;t<e.length;t++)i=i<<8n|BigInt(255&e[t]);else for(let t=e.length-1;t>=0;t--)i=i<<8n|BigInt(255&e[t]);return this._initializeState(i,0),this}copy(e){e._magnitude=this._magnitude,e._sign=this._sign,e._nominalWordLength=this._nominalWordLength,e.red=this.red}static move(e,t){e._magnitude=t._magnitude,e._sign=t._sign,e._nominalWordLength=t._nominalWordLength,e.red=t.red}clone(){let e=new P(0n);return this.copy(e),e}expand(e){return this.assert(e>=0,"Expand size must be non-negative"),this._nominalWordLength=Math.max(this._nominalWordLength,e,1),this}strip(){return this._finishInitialization(),this.normSign()}normSign(){return 0n===this._magnitude&&(this._sign=0),this}inspect(){return(null!==this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}_getMinimalHex(){return 0n===this._magnitude?"0":this._magnitude.toString(16)}toString(e=10,t=1){if(16===e||"hex"===e){let e=this._getMinimalHex();if(t>1)for("0"!==e&&e.length%2!=0&&(e="0"+e);e.length%t!=0;)e="0"+e;return(this.isNeg()?"-":"")+e}if("number"!=typeof e||e<2||e>36||e%1!=0)throw Error("Base should be an integer between 2 and 36");return this.toBaseString(e,t)}toBaseString(e,t){if(0n===this._magnitude){let e="0";if(t>1)for(;e.length<t;)e="0"+e;return e}let i=P.groupSizes[e],r=BigInt(P.groupBases[e]);(0===i||0n===r)&&(0===(i=Math.floor(Math.log(Number.MAX_SAFE_INTEGER)/Math.log(e)))&&(i=1),r=BigInt(e)**BigInt(i));let n="",a=this._magnitude;for(;a>0n;){let t=a%r;a/=r;let s=this._bigIntToStringInBase(t,e);if(a>0n){let e=i-s.length;n=e>0&&e<P.zeros.length?P.zeros[e]+s+n:e>0?"0".repeat(e)+s+n:s+n}else n=s+n}if(t>0)for(;n.length<t;)n="0"+n;return(1===this._sign?"-":"")+n}toNumber(){let e=this._getSignedValue();if(e>P.MAX_SAFE_INTEGER_BIGINT||e<P.MIN_SAFE_INTEGER_BIGINT)throw Error("Number can only safely store up to 53 bits");return Number(e)}toBigInt(){return this._getSignedValue()}toJSON(){let e=this._getMinimalHex();return(this.isNeg()?"-":"")+e}toArrayLikeGeneric(e,t){let i=this._magnitude,r=t?0:e.length-1,n=t?1:-1;for(let t=0;t<e.length;++t){if(0n===i&&r>=0&&r<e.length)e[r]=0;else if(r>=0&&r<e.length)e[r]=Number(255n&i);else break;i>>=8n,r+=n}}toArray(e="be",t){this.strip();let i=this.byteLength(),r=t??Math.max(1,i);this.assert(i<=r,"byte array longer than desired length"),this.assert(r>0,"Requested array length <= 0");let n=Array(r).fill(0);return 0n===this._magnitude&&r>0?n:0n===this._magnitude&&0===r?[]:(this.toArrayLikeGeneric(n,"le"===e),n)}bitLength(){return 0n===this._magnitude?0:this._magnitude.toString(2).length}static toBitArray(e){let t=e.bitLength();if(0===t)return[];let i=Array(t),r=e._magnitude;for(let e=0;e<t;e++)i[e]=+((r>>BigInt(e)&1n)!==0n);return i}toBitArray(){return P.toBitArray(this)}zeroBits(){if(0n===this._magnitude)return 0;let e=0,t=this._magnitude;for(;(1n&t)===0n&&0n!==t;)e++,t>>=1n;return e}byteLength(){return 0n===this._magnitude?0:Math.ceil(this.bitLength()/8)}_getSignedValue(){return 1===this._sign?-this._magnitude:this._magnitude}_setValueFromSigned(e){e<0n?(this._magnitude=-e,this._sign=1):(this._magnitude=e,this._sign=0),this._finishInitialization(),this.normSign()}toTwos(e){this.assert(e>=0);let t=BigInt(e),i=this._getSignedValue();1===this._sign&&0n!==this._magnitude&&(i=(1n<<t)+i),i&=(1n<<t)-1n;let r=new P(0n);return r._initializeState(i,0),r}fromTwos(e){this.assert(e>=0);let t=BigInt(e),i=this._magnitude;if(e>0&&(i>>t-1n&1n)!==0n&&0===this._sign){let e=new P(0n);return e._setValueFromSigned(i-(1n<<t)),e}return this.clone()}isNeg(){return 1===this._sign&&0n!==this._magnitude}neg(){return this.clone().ineg()}ineg(){return 0n!==this._magnitude&&(this._sign=+(1!==this._sign)),this}_iuop(e,t){let i=t(this._magnitude,e._magnitude),r=t===((e,t)=>e^t),n=this._nominalWordLength;return r&&(n=Math.max(this.length,e.length)),this._magnitude=i,this._finishInitialization(),r&&(this._nominalWordLength=Math.max(this._nominalWordLength,n)),this.strip()}iuor(e){return this._iuop(e,(e,t)=>e|t)}iuand(e){return this._iuop(e,(e,t)=>e&t)}iuxor(e){return this._iuop(e,(e,t)=>e^t)}_iop(e,t){return this.assert(0===this._sign&&0===e._sign),this._iuop(e,t)}ior(e){return this._iop(e,(e,t)=>e|t)}iand(e){return this._iop(e,(e,t)=>e&t)}ixor(e){return this._iop(e,(e,t)=>e^t)}_uop_new(e,t){return this.length>=e.length?this.clone()[t](e):e.clone()[t](this)}or(e){return this.assert(0===this._sign&&0===e._sign),this._uop_new(e,"iuor")}uor(e){return this._uop_new(e,"iuor")}and(e){return this.assert(0===this._sign&&0===e._sign),this._uop_new(e,"iuand")}uand(e){return this._uop_new(e,"iuand")}xor(e){return this.assert(0===this._sign&&0===e._sign),this._uop_new(e,"iuxor")}uxor(e){return this._uop_new(e,"iuxor")}inotn(e){this.assert("number"==typeof e&&e>=0);let t=BigInt(e);this._magnitude=~this._magnitude&(1n<<t)-1n;let i=0===e?1:Math.ceil(e/P.wordSize);return this._nominalWordLength=Math.max(1,i),this.strip(),this._nominalWordLength=Math.max(this._nominalWordLength,Math.max(1,i)),this}notn(e){return this.clone().inotn(e)}setn(e,t){this.assert("number"==typeof e&&e>=0);let i=BigInt(e);1===t||!0===t?this._magnitude|=1n<<i:this._magnitude&=~(1n<<i);let r=Math.floor(e/P.wordSize)+1;return this._nominalWordLength=Math.max(this._nominalWordLength,r),this._finishInitialization(),this.strip()}iadd(e){return this._setValueFromSigned(this._getSignedValue()+e._getSignedValue()),this}add(e){let t=new P(0n);return t._setValueFromSigned(this._getSignedValue()+e._getSignedValue()),t}isub(e){return this._setValueFromSigned(this._getSignedValue()-e._getSignedValue()),this}sub(e){let t=new P(0n);return t._setValueFromSigned(this._getSignedValue()-e._getSignedValue()),t}mul(e){let t=new P(0n);return t._magnitude=this._magnitude*e._magnitude,t._sign=0n===t._magnitude?0:this._sign^e._sign,t._nominalWordLength=this.length+e.length,t.red=null,t.normSign()}imul(e){return this._magnitude*=e._magnitude,this._sign=0n===this._magnitude?0:this._sign^e._sign,this._nominalWordLength=this.length+e.length,this.red=null,this.normSign()}imuln(e){return this.assert("number"==typeof e,"Assertion failed"),this.assert(Math.abs(e)<=P.MAX_IMULN_ARG,"Assertion failed"),this._setValueFromSigned(this._getSignedValue()*BigInt(e)),this}muln(e){return this.clone().imuln(e)}sqr(){let e=new P(0n);return e._magnitude=this._magnitude*this._magnitude,e._sign=0,e._nominalWordLength=2*this.length,e.red=null,e}isqr(){return this._magnitude*=this._magnitude,this._sign=0,this._nominalWordLength=2*this.length,this.red=null,this}pow(e){if(this.assert(0===e._sign,"Exponent for pow must be non-negative"),e.isZero())return new P(1n);let t=new P(1n),i=this.clone(),r=e.clone(),n=i.isNeg(),a=r.isOdd();for(n&&i.ineg();!r.isZero();)r.isOdd()&&t.imul(i),i.isqr(),r.iushrn(1);return n&&a&&t.ineg(),t}static normalizeNonNegativeBigInt(e,t){if("number"==typeof e){if(!Number.isFinite(e)||!Number.isInteger(e)||e<0)throw Error(`${t} must be a non-negative integer`);return BigInt(e)}if(e<0n)throw Error(`${t} must be a non-negative integer`);return e}iushln(e){let t=P.normalizeNonNegativeBigInt(e,"Shift bits");return 0n===t?this:(this._magnitude<<=t,this._finishInitialization(),this.strip())}ishln(e){return this.assert(0===this._sign,"ishln requires positive number"),this.iushln(e)}iushrn(e,t,i){let r=P.normalizeNonNegativeBigInt(e,"Shift bits");if(0n===r)return null!=i&&i._initializeState(0n,0),this;if(null!=i){let e=this._magnitude&(1n<<r)-1n;i._initializeState(e,0)}return this._magnitude>>=r,this._finishInitialization(),this.strip()}ishrn(e,t,i){return this.assert(0===this._sign,"ishrn requires positive number"),this.iushrn(e,t,i)}shln(e){return this.clone().ishln(e)}ushln(e){return this.clone().iushln(e)}shrn(e){return this.clone().ishrn(e)}ushrn(e){return this.clone().iushrn(e)}testn(e){return this.assert("number"==typeof e&&e>=0),(this._magnitude>>BigInt(e)&1n)!==0n}imaskn(e){this.assert("number"==typeof e&&e>=0),this.assert(0===this._sign,"imaskn works only with positive numbers");let t=BigInt(e);this._magnitude&=0n===t?0n:(1n<<t)-1n;let i=0===e?1:Math.max(1,Math.ceil(e/P.wordSize));return this._nominalWordLength=i,this._finishInitialization(),this._nominalWordLength=Math.max(this._nominalWordLength,i),this.strip()}maskn(e){return this.clone().imaskn(e)}iaddn(e){return this.assert("number"==typeof e),this.assert(Math.abs(e)<=P.MAX_IMULN_ARG,"num is too large"),this._setValueFromSigned(this._getSignedValue()+BigInt(e)),this}_iaddn(e){return this.iaddn(e)}isubn(e){return this.assert("number"==typeof e),this.assert(Math.abs(e)<=P.MAX_IMULN_ARG,"Assertion failed"),this._setValueFromSigned(this._getSignedValue()-BigInt(e)),this}addn(e){return this.clone().iaddn(e)}subn(e){return this.clone().isubn(e)}iabs(){return this._sign=0,this}abs(){return this.clone().iabs()}divmod(e,t,i){if(this.assert(!e.isZero(),"Division by zero"),this.isZero()){let e=new P(0n);return{div:"mod"!==t?e:null,mod:"div"!==t?e:null}}let r=this._getSignedValue(),n=e._getSignedValue(),a=null,s=null;"mod"!==t&&(a=r/n),"div"!==t&&(s=r%n,!0===i&&s<0n&&(s+=n<0n?-n:n));let o=null!==a?new P(0n):null;null!==o&&null!==a&&o._setValueFromSigned(a);let c=null!==s?new P(0n):null;return null!==c&&null!==s&&c._setValueFromSigned(s),{div:o,mod:c}}div(e){return this.divmod(e,"div",!1).div}mod(e){return this.divmod(e,"mod",!1).mod}umod(e){return this.divmod(e,"mod",!0).mod}divRound(e){this.assert(!e.isZero());let t=this._getSignedValue(),i=e._getSignedValue(),r=t/i,n=t%i;if(0n===n){let e=new P(0n);return e._setValueFromSigned(r),e}2n*(n<0n?-n:n)>=(i<0n?-i:i)&&(t>0n&&i>0n||t<0n&&i<0n?r+=1n:r-=1n);let a=new P(0n);return a._setValueFromSigned(r),a}modrn(e){this.assert(0!==e,"Division by zero in modrn");let t=BigInt(Math.abs(e));if(0n===t)throw Error("Division by zero in modrn");let i=this._magnitude%t;return e<0?Number(-i):Number(i)}idivn(e){return this.assert(0!==e),this.assert(Math.abs(e)<=P.MAX_IMULN_ARG,"num is too large"),this._setValueFromSigned(this._getSignedValue()/BigInt(e)),this}divn(e){return this.clone().idivn(e)}egcd(e){this.assert(0===e._sign,"p must not be negative"),this.assert(!e.isZero(),"p must not be zero");let t=this._getSignedValue(),i=e._magnitude,r=1n,n=0n,a=0n,s=1n;for(;0n!==i;){let e=t/i,o=i;i=t%i,t=o,o=n,n=r-e*n,r=o,o=s,s=a-e*s,a=o}let o=new P(0n);o._setValueFromSigned(r);let c=new P(0n);c._setValueFromSigned(a);let l=new P(0n);return l._initializeState(t<0n?-t:t,0),{a:o,b:c,gcd:l}}gcd(e){let t=this._magnitude,i=e._magnitude;if(0n===t){let e=new P(0n);return e._setValueFromSigned(i),e.iabs()}if(0n===i){let e=new P(0n);return e._setValueFromSigned(t),e.iabs()}for(;0n!==i;){let e=t%i;t=i,i=e}let r=new P(0n);return r._initializeState(t,0),r}invm(e){this.assert(!e.isZero()&&0===e._sign,"Modulus for invm must be positive and non-zero");let t=this.egcd(e);if(!t.gcd.eqn(1))throw Error("Inverse does not exist (numbers are not coprime).");return t.a.umod(e)}isEven(){return this._magnitude%2n===0n}isOdd(){return this._magnitude%2n===1n}andln(e){return this.assert(e>=0),Number(this._magnitude&BigInt(e))}bincn(e){this.assert("number"==typeof e&&e>=0);let t=1n<<BigInt(e);return this._setValueFromSigned(this._getSignedValue()+t),this}isZero(){return 0n===this._magnitude}cmpn(e){this.assert(Math.abs(e)<=P.MAX_IMULN_ARG,"Number is too big");let t=this._getSignedValue(),i=BigInt(e);return t<i?-1:+(t>i)}cmp(e){let t=this._getSignedValue(),i=e._getSignedValue();return t<i?-1:+(t>i)}ucmp(e){return this._magnitude<e._magnitude?-1:+(this._magnitude>e._magnitude)}gtn(e){return 1===this.cmpn(e)}gt(e){return 1===this.cmp(e)}gten(e){return this.cmpn(e)>=0}gte(e){return this.cmp(e)>=0}ltn(e){return -1===this.cmpn(e)}lt(e){return -1===this.cmp(e)}lten(e){return 0>=this.cmpn(e)}lte(e){return 0>=this.cmp(e)}eqn(e){return 0===this.cmpn(e)}eq(e){return 0===this.cmp(e)}toRed(e){return this.assert(null==this.red,"Already a number in reduction context"),this.assert(0===this._sign,"toRed works only with positives"),e.convertTo(this).forceRed(e)}fromRed(){return this.assert(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)}forceRed(e){return this.red=e,this}redAdd(e){return this.assert(this.red,"redAdd works only with red numbers"),this.red.add(this,e)}redIAdd(e){return this.assert(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)}redSub(e){return this.assert(this.red,"redSub works only with red numbers"),this.red.sub(this,e)}redISub(e){return this.assert(this.red,"redISub works only with red numbers"),this.red.isub(this,e)}redShl(e){return this.assert(this.red,"redShl works only with red numbers"),this.red.shl(this,e)}redMul(e){return this.assert(this.red,"redMul works only with red numbers"),this.red.verify2(this,e),this.red.mul(this,e)}redIMul(e){return this.assert(this.red,"redIMul works only with red numbers"),this.red.verify2(this,e),this.red.imul(this,e)}redSqr(){return this.assert(this.red,"redSqr works only with red numbers"),this.red.verify1(this),this.red.sqr(this)}redISqr(){return this.assert(this.red,"redISqr works only with red numbers"),this.red.verify1(this),this.red.isqr(this)}redSqrt(){return this.assert(this.red,"redSqrt works only with red numbers"),this.red.verify1(this),this.red.sqrt(this)}redInvm(){return this.assert(this.red,"redInvm works only with red numbers"),this.red.verify1(this),this.red.invm(this)}redNeg(){return this.assert(this.red,"redNeg works only with red numbers"),this.red.verify1(this),this.red.neg(this)}redPow(e){return this.assert(null!=this.red&&null==e.red,"redPow(normalNum)"),this.red.verify1(this),this.red.pow(this,e)}static fromHex(e,t){let i="be";return("little"===t||"le"===t)&&(i="le"),new P(e,16,i)}toHex(e=0){if(this.isZero()&&0===e)return"";let t=this._getMinimalHex();"0"!==t&&t.length%2!=0&&(t="0"+t);let i=2*e;for(;t.length<i;)t="0"+t;return(this.isNeg()?"-":"")+t}static fromJSON(e){return new P(e,16)}static fromNumber(e){return new P(e)}static fromString(e,t){return new P(e,t)}static fromSm(e,t="big"){if(0===e.length)return new P(0n);let i=e.slice();"little"===t&&i.reverse();let r=0;i.length>0&&(128&i[0])!=0&&(r=1,i[0]&=127);let n=0n;if(E){let e=S.from(i).toString("hex");n=0===e.length?0n:BigInt("0x"+e)}else{let e="";for(let t of i)e+=t<16?"0"+t.toString(16):t.toString(16);n=0===e.length?0n:BigInt("0x"+e)}let a=new P(0n);return a._initializeState(n,r),a}toSm(e="big"){let t;if(0n===this._magnitude)return 1===this._sign?[128]:[];let i=this._getMinimalHex();i.length%2!=0&&(i="0"+i);let r=Array(i.length/2);for(let e=0,t=0;e<i.length;e+=2){let n=x[i.charCodeAt(e)],a=x[i.charCodeAt(e+1)];r[t++]=(15&n)<<4|15&a}return 1===this._sign?(128&r[0])!=0?t=[128,...r]:(t=r.slice(),t[0]|=128):t=(128&r[0])!=0?[0,...r]:r.slice(),"little"===e?t.reverse():t}static fromBits(e,t=!1){let i=e>>>24,r=8388607&e,n=(8388608&e)!=0;if(t&&n)throw Error("negative bit set");if(0===i&&0===r){if(n&&t)throw Error("negative bit set for zero value");return new P(0n)}let a=new P(r);return i<=3?a.iushrn((3-i)*8):a.iushln((i-3)*8),n&&a.ineg(),a}toBits(){let e;if(this.strip(),this.isZero()&&!this.isNeg())return 0;let t=this.isNeg(),i=this.abs(),r=i.toArray("be"),n=0;for(;n<r.length-1&&0===r[n];)n++;let a=(r=r.slice(n)).length;if(0!==a||i.isZero()||(r=[0],a=1),i.isZero()&&(a=0,r=[]),0===a)e=0;else if(a<=3){e=0;for(let t=0;t<a;t++)e=e<<8|r[t]}else e=r[0]<<16|r[1]<<8|r[2];(8388608&e)!=0&&a<=255&&(e>>>=8,a++);let s=a<<24|e;return t&&(s|=8388608),s>>>0}static fromScriptNum(e,t=!1,i){if(void 0!==i&&e.length>i)throw Error("script number overflow");if(0===e.length)return new P(0n);if(t&&(127&e[e.length-1])==0&&(e.length<=1||(128&e[e.length-2])==0))throw Error("non-minimally encoded script number");return P.fromSm(e,"little")}toScriptNum(){return this.toSm("little")}_invmp(e){this.assert(0===e._sign,"p must not be negative for _invmp"),this.assert(!e.isZero(),"p must not be zero for _invmp");let t=this.umod(e),i=e.subn(2);if(null!==t.red)return t.redPow(i);let r=new P(1n),n=t.clone(),a=i.clone();for(;!a.isZero();)a.isOdd()&&(r=r.mul(n).umod(e)),n=n.sqr().umod(e),a.iushrn(1);return r}mulTo(e,t){return t._magnitude=this._magnitude*e._magnitude,t._sign=0n===t._magnitude?0:this._sign^e._sign,t._nominalWordLength=this.length+e.length,t.red=null,t.normSign(),t}}class A{name;p;k;n;tmp;constructor(e,t){this.name=e,this.p=new P(t,16),this.n=this.p.bitLength(),this.k=new P(BigInt(1)).iushln(this.n).isub(this.p),this.tmp=this._tmp()}_tmp(){let e=new P(BigInt(0)),t=Math.ceil(this.n/P.wordSize);return e.expand(Math.max(1,t)),e}ireduce(e){let t;do this.split(e,this.tmp),this.imulK(e),e.iadd(this.tmp),t=e.bitLength();while(t>this.n);let i=t<this.n?-1:e.ucmp(this.p);return 0===i?e.words=[0]:i>0&&e.isub(this.p),e.strip(),e}split(e,t){e.iushrn(this.n,0,t)}imulK(e){return e.imul(this.k)}}class N extends A{constructor(){super("k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}split(e,t){let i=e.words,r=e.length,n=Math.min(r,9),a=Array(n+ +(r>9)).fill(0);for(let e=0;e<n;e++)a[e]=i[e];let s=n;if(r<=9){let i=Array(s);for(let e=0;e<s;++e)i[e]=a[e];t.words=i,e.words=[0];return}let o=i[9];a[s++]=4194303&o;let c=Array(s);for(let e=0;e<s;++e)c[e]=a[e];t.words=c;let l=Array(Math.max(1,r-9)).fill(0),h=0;for(let e=10;e<r;e++){let t=0|i[e];h<l.length&&(l[h++]=(4194303&t)<<4|o>>>22),o=t}o>>>=22,h<l.length?l[h++]=o:0!==o&&l.length;let d=Array(h);for(let e=0;e<h;++e)d[e]=l[e];e.words=d}imulK(e){let t=e.words,i=e.length,r=i+2,n=Array(r).fill(0);for(let e=0;e<i;e++)n[e]=t[e];let a=0;for(let e=0;e<r;e++){let t=0|n[e];a+=977*t,n[e]=0x3ffffff&a,a=64*t+(a/0x4000000|0)}return e.words=n,e}}class O{prime;m;constructor(e){if("k256"===e){const e=new N;this.m=e.p,this.prime=e}else this.assert(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}assert(e,t="Assertion failed"){if(!e)throw Error(t)}verify1(e){this.assert(0===e.negative,"red works only with positives"),this.assert(e.red,"red works only with red numbers")}verify2(e,t){this.assert((e.negative|t.negative)==0,"red works only with positives"),this.assert(null!=e.red&&e.red===t.red,"red works only with red numbers")}imod(e){return null!=this.prime?this.prime.ireduce(e).forceRed(this):(P.move(e,e.umod(this.m).forceRed(this)),e)}neg(e){return e.isZero()?e.clone():this.m.sub(e).forceRed(this)}add(e,t){this.verify2(e,t);let i=e.clone();return i.iadd(t),i.isub(this.m),i.isNeg()&&i.iadd(this.m),i}iadd(e,t){return this.verify2(e,t),e.iadd(t),e.isub(this.m),e.isNeg()&&e.iadd(this.m),e}sub(e,t){this.verify2(e,t);let i=e.sub(t);return 0>i.cmpn(0)&&i.iadd(this.m),i.forceRed(this)}isub(e,t){this.verify2(e,t);let i=e.isub(t);return 0>i.cmpn(0)&&i.iadd(this.m),i}shl(e,t){return this.verify1(e),this.imod(e.ushln(t))}imul(e,t){return this.verify2(e,t),this.imod(e.imul(t))}mul(e,t){return this.verify2(e,t),this.imod(e.mul(t))}isqr(e){return this.imul(e,e.clone())}sqr(e){return this.mul(e,e)}sqrt(e){if(e.isZero())return e.clone();let t=this.m.andln(3);if(this.assert(t%2==1),3===t){let t=this.m.add(new P(1)).iushrn(2);return this.pow(e,t)}let i=this.m.subn(1),r=0;for(;!i.isZero()&&0===i.andln(1);)r++,i.iushrn(1);this.assert(!i.isZero());let n=new P(1).toRed(this),a=n.redNeg(),s=this.m.subn(1).iushrn(1),o=this.m.bitLength(),c=new P(2*o*o).toRed(this);for(;0!==this.pow(c,s).cmp(a);)c.redIAdd(a);let l=this.pow(c,i),h=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),u=r;for(;0!==d.cmp(n);){let e=d,t=0;for(;0!==e.cmp(n);t++)e=e.redSqr();this.assert(t<u);let i=this.pow(l,new P(1).iushln(u-t-1));h=h.redMul(i),l=i.redSqr(),d=d.redMul(l),u=t}return h}invm(e){let t=e._invmp(this.m);return 0!==t.negative?(t.negative=0,this.imod(t).redNeg()):this.imod(t)}pow(e,t){if(this.verify1(e),t.isZero())return new P(1).toRed(this);let i=new P(1).toRed(this),r=e.clone(),n=t.bitLength();for(let e=n-1;e>=0;e--)i=this.sqr(i),t.testn(e)&&(i=this.mul(i,r));return i}convertTo(e){let t=e.umod(this.m);return t===e?t.clone():t}convertFrom(e){let t=e.clone();return t.red=null,t}}class T extends O{shift;r;r2;rinv;minv;constructor(e){super(e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new P(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}convertTo(e){return this.imod(e.ushln(this.shift))}convertFrom(e){let t=this.imod(e.mul(this.rinv));return t.red=null,t}imul(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;let i=e.imul(t),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),a=n;return n.cmp(this.m)>=0?a=n.isub(this.m):0>n.cmpn(0)&&(a=n.iadd(this.m)),a.forceRed(this)}mul(e,t){if(e.isZero()||t.isZero())return new P(0).forceRed(this);let i=e.mul(t),r=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(r).iushrn(this.shift),a=n;return n.cmp(this.m)>=0?a=n.isub(this.m):0>n.cmpn(0)&&(a=n.iadd(this.m)),a.forceRed(this)}invm(e){return this.imod(e._invmp(this.m).mul(this.r2)).forceRed(this)}}class _{curve;type;precomputed;constructor(e){this.curve=new tH,this.type=e,this.precomputed=null}}class R extends _{x;y;z;zOne;constructor(e,t,i){super("jacobian"),null===e&&null===t&&null===i?(this.x=this.curve.one,this.y=this.curve.one,this.z=new P(0)):(P.isBN(e)||(e=new P(e,16)),this.x=e,P.isBN(t)||(t=new P(t,16)),this.y=t,P.isBN(i)||(i=new P(i,16)),this.z=i),null==this.x.red&&(this.x=this.x.toRed(this.curve.red)),null==this.y.red&&(this.y=this.y.toRed(this.curve.red)),null==this.z.red&&(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.isInfinity()&&(this.x=this.curve.one,this.y=this.curve.one,this.z=new P(0).toRed(this.curve.red),this.zOne=!1)}toP(){if(this.isInfinity())return new tF(null,null);let e=this.z.redInvm(),t=e.redSqr();return new tF(this.x.redMul(t),this.y.redMul(t).redMul(e))}neg(){return new R(this.x,this.y.redNeg(),this.z)}add(e){if(this.isInfinity())return e;if(e.isInfinity())return this;let t=e.z.redSqr(),i=this.z.redSqr(),r=this.x.redMul(t),n=e.x.redMul(i),a=this.y.redMul(t.redMul(e.z)),s=e.y.redMul(i.redMul(this.z)),o=r.redSub(n),c=a.redSub(s);if(0===o.cmpn(0))if(0!==c.cmpn(0))return new R(null,null,null);else return this.dbl();let l=o.redSqr(),h=l.redMul(o),d=r.redMul(l),u=c.redSqr().redIAdd(h).redISub(d).redISub(d),f=c.redMul(d.redISub(u)).redISub(a.redMul(h));return new R(u,f,this.z.redMul(e.z).redMul(o))}mixedAdd(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;if(null===e.x||null===e.y)throw Error("Point coordinates cannot be null");let t=this.z.redSqr(),i=this.x,r=e.x.redMul(t),n=this.y,a=e.y.redMul(t).redMul(this.z),s=i.redSub(r),o=n.redSub(a);if(0===s.cmpn(0))if(0!==o.cmpn(0))return new R(null,null,null);else return this.dbl();let c=s.redSqr(),l=c.redMul(s),h=i.redMul(c),d=o.redSqr().redIAdd(l).redISub(h).redISub(h),u=o.redMul(h.redISub(d)).redISub(n.redMul(l));return new R(d,u,this.z.redMul(s))}dblp(e){if(0===e||this.isInfinity())return this;if(void 0===e)return this.dbl();let t=this;for(let i=0;i<e;i++)t=t.dbl();return t}dbl(){let e,t,i;if(this.isInfinity())return this;if(this.zOne){let r=this.x.redSqr(),n=this.y.redSqr(),a=n.redSqr(),s=this.x.redAdd(n).redSqr().redISub(r).redISub(a);s=s.redIAdd(s);let o=r.redAdd(r).redIAdd(r),c=o.redSqr().redISub(s).redISub(s),l=a.redIAdd(a);l=(l=l.redIAdd(l)).redIAdd(l),e=c,t=o.redMul(s.redISub(c)).redISub(l),i=this.y.redAdd(this.y)}else{let r=this.x.redSqr(),n=this.y.redSqr(),a=n.redSqr(),s=this.x.redAdd(n).redSqr().redISub(r).redISub(a);s=s.redIAdd(s);let o=r.redAdd(r).redIAdd(r),c=o.redSqr(),l=a.redIAdd(a);l=(l=l.redIAdd(l)).redIAdd(l),e=c.redISub(s).redISub(s),t=o.redMul(s.redISub(e)).redISub(l),i=(i=this.y.redMul(this.z)).redIAdd(i)}return new R(e,t,i)}eq(e){if("affine"===e.type)return this.eq(e.toJ());if(this===e||this.isInfinity()&&e.isInfinity())return!0;if(this.isInfinity()!==e.isInfinity())return!1;let t=this.z.redSqr(),i=e.z.redSqr();if(0!==this.x.redMul(i).redISub(e.x.redMul(t)).cmpn(0))return!1;let r=t.redMul(this.z),n=i.redMul(e.z);return 0===this.y.redMul(n).redISub(e.y.redMul(r)).cmpn(0)}eqXToP(e){let t=this.z.redSqr(),i=e.toRed(this.curve?.red).redMul(t);if(0===this.x.cmp(i))return!0;let r=e.clone();if(null===this.curve||null==this.curve.redN)throw Error("Curve or redN is not initialized.");let n=this.curve.redN.redMul(t);for(;0>r.cmp(this.curve.p)&&(r.iadd(this.curve.n),!(r.cmp(this.curve.p)>=0));)if(i.redIAdd(n),0===this.x.cmp(i))return!0;return!1}inspect(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"}isInfinity(){return 0===this.z.cmpn(0)}}let C=/^[0-9a-fA-F]*$/;function B(e){if("string"!=typeof e)throw TypeError("Invalid hex string");if(0!==e.length&&!C.test(e))throw Error("Invalid hex string")}let U=(e,t="Hash assertion failed")=>{if(!e)throw Error(t)};class V{pending;pendingTotal;blockSize;outSize;endian;_delta8;_delta32;padLength;hmacStrength;constructor(e,t,i,r){this.pending=null,this.pendingTotal=0,this.blockSize=e,this.outSize=t,this.hmacStrength=i,this.padLength=r/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}_update(e,t){throw Error("Not implemented")}_digest(){throw Error("Not implemented")}_digestHex(){throw Error("Not implemented")}update(e,t){if(e=D(e,t),null==this.pending?this.pending=e:this.pending=this.pending.concat(e),this.pendingTotal+=e.length,this.pending.length>=this._delta8){let t=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-t,e.length),0===this.pending.length&&(this.pending=null),e=function(e,t,i,r){let n=i-0;U(n%4==0);let a=Array(n/4);for(let t=0,i=0;t<a.length;t++,i+=4){let n;n="big"===r?e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3]:e[i+3]<<24|e[i+2]<<16|e[i+1]<<8|e[i],a[t]=n>>>0}return a}(e,0,e.length-t,this.endian);for(let t=0;t<e.length;t+=this._delta32)this._update(e,t)}return this}digest(){return this.update(this._pad()),U(null===this.pending),this._digest()}digestHex(){return this.update(this._pad()),U(null===this.pending),this._digestHex()}_pad(){let e,t=this.pendingTotal;if(!Number.isSafeInteger(t)||t<0)throw Error("Message too long for this hash function");let i=this._delta8,r=i-(t+this.padLength)%i,n=Array(r+this.padLength);for(e=1,n[0]=128;e<r;e++)n[e]=0;let a=this.padLength,s=1n<<BigInt(8*a),o=8n*BigInt(t);if(o>=s)throw Error("Message too long for this hash function");if("big"===this.endian){let t=Array(a);for(let e=a-1;e>=0;e--)t[e]=Number(255n&o),o>>=8n;for(let i=0;i<a;i++)n[e++]=t[i]}else for(let t=0;t<a;t++)n[e++]=Number(255n&o),o>>=8n;return n}}function D(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];let i=[];if("string"==typeof e)if("hex"!==t){let t=0;for(let a=0;a<e.length;a++){let s=e.charCodeAt(a);if(s<128)i[t++]=s;else if(s<2048)i[t++]=s>>6|192,i[t++]=63&s|128;else{var r,n;(r=e,n=a,(64512&r.charCodeAt(n))!=55296||n<0||n+1>=r.length?1:(64512&r.charCodeAt(n+1))!=56320)?i[t++]=s>>12|224:(s=65536+((1023&s)<<10)+(1023&e.charCodeAt(++a)),i[t++]=s>>18|240,i[t++]=s>>12&63|128),i[t++]=s>>6&63|128,i[t++]=63&s|128}}}else{B(e),e=function(e){if(B(e),0===e.length)return"";let t=e.toLowerCase();return t.length%2!=0&&(t="0"+t),t}(e);for(let t=0;t<e.length;t+=2)i.push(parseInt(e[t]+e[t+1],16))}else for(let t=0;t<e.length;t++)i[t]=0|e[t];return i}function L(e){return e0(e)}function F(e,t){let i="";for(let r=0;r<e.length;r++){let n=e[r];"little"===t&&(n=e0(n)),i+=function(e){if(7===e.length)return"0"+e;if(6===e.length)return"00"+e;if(5===e.length)return"000"+e;if(4===e.length)return"0000"+e;if(3===e.length)return"00000"+e;else if(2===e.length)return"000000"+e;else if(1===e.length)return"0000000"+e;else return e}(n.toString(16))}return i}function H(e){let t="";for(let i of e)t+=i.toString(16).padStart(2,"0");return t}function K(e,t){let i=Array(4*e.length);for(let r=0,n=0;r<e.length;r++,n+=4){let a=e[r];"big"===t?(i[n]=a>>>24,i[n+1]=a>>>16&255,i[n+2]=a>>>8&255,i[n+3]=255&a):(i[n+3]=a>>>24,i[n+2]=a>>>16&255,i[n+1]=a>>>8&255,i[n]=255&a)}return i}function M(e,t){return e>>>t|e<<32-t}function q(e,t){return e<<t|e>>>32-t}function $(e,t){return e+t>>>0}let z=[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],W=[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],j=[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],X=[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];function G(e,t,i,r){return e<=15?t^i^r:e<=31?t&i|~t&r:e<=47?(t|~i)^r:e<=63?t&r|i&~r:t^(i|~r)}class Y extends V{h;constructor(){super(512,160,192,64),this.endian="little",this.h=[0x67452301,0xefcdab89,0x98badcfe,0x10325476,0xc3d2e1f0],this.endian="little"}_update(e,t){var i,r,n,a,s,o;let c,l=this.h[0],h=this.h[1],d=this.h[2],u=this.h[3],f=this.h[4],p=l,g=h,m=d,y=u,b=f;for(let w=0;w<80;w++){c=$(q((i=l,r=G(w,h,d,u),i+r+e[z[w]+t]+((s=w)<=15?0:s<=31?0x5a827999:s<=47?0x6ed9eba1:s<=63?0x8f1bbcdc:0xa953fd4e)>>>0),j[w]),f),l=f,f=u,u=q(d,10),d=h,h=c,c=$(q((n=p,a=G(79-w,g,m,y),n+a+e[W[w]+t]+((o=w)<=15?0x50a28be6:o<=31?0x5c4dd124:o<=47?0x6d703ef3:0x7a6d76e9*!!(o<=63))>>>0),X[w]),b),p=b,b=y,y=q(m,10),m=g,g=c}c=this.h[1]+d+y>>>0,this.h[1]=this.h[2]+u+b>>>0,this.h[2]=this.h[3]+f+p>>>0,this.h[3]=this.h[4]+l+g>>>0,this.h[4]=this.h[0]+h+m>>>0,this.h[0]=c}_digest(){return K(this.h,"little")}_digestHex(){return F(this.h,"little")}}class J{h;constructor(){this.h=new eK}update(e,t){let i=e instanceof Uint8Array?e:Uint8Array.from(D(e,t));return this.h.update(i),this}digest(){return Array.from(this.h.digest())}digestHex(){return H(this.h.digest())}}class Z extends V{h;W;k;constructor(){super(512,160,80,64),this.k=[0x5a827999,0x6ed9eba1,0x8f1bbcdc,0xca62c1d6],this.h=[0x67452301,0xefcdab89,0x98badcfe,0x10325476,0xc3d2e1f0],this.W=Array(80)}_update(e,t){let i,r=this.W;for(void 0===t&&(t=0),i=0;i<16;i++)r[i]=e[t+i];for(;i<r.length;i++)r[i]=q(r[i-3]^r[i-8]^r[i-14]^r[i-16],1);let n=this.h[0],a=this.h[1],s=this.h[2],o=this.h[3],c=this.h[4];for(i=0;i<r.length;i++){var l,h,d,u,f,p,g,m,y;let e=~~(i/20),t=(u=q(n,5),l=a,h=s,d=o,f=0===e?(p=l)&h^~p&d:1===e||3===e?l^h^d:2===e?(g=l)&(m=h)^g&(y=d)^m&y:0,u+f+c+r[i]+this.k[e]>>>0);c=o,o=s,s=q(a,30),a=n,n=t}this.h[0]=$(this.h[0],n),this.h[1]=$(this.h[1],a),this.h[2]=$(this.h[2],s),this.h[3]=$(this.h[3],o),this.h[4]=$(this.h[4],c)}_digest(){return K(this.h,"big")}_digestHex(){return F(this.h,"big")}}class Q{h;constructor(){this.h=new eG}update(e,t){let i=Uint8Array.from(D(e,t));return this.h.update(i),this}digest(){return Array.from(this.h.digest())}digestHex(){return H(this.h.digest())}}class ee{h;blockSize=64;outSize=32;constructor(e){const t=e instanceof Uint8Array?e:Uint8Array.from(D(e,"string"==typeof e?"hex":void 0));this.h=new eJ(eM,t)}update(e,t){let i=e instanceof Uint8Array?e:Uint8Array.from(D(e,t));return this.h.update(i),this}digest(){return Array.from(this.h.digest())}digestHex(){return H(this.h.digest())}}class et{inner;outer;blockSize=64;constructor(e){let t;for((e=D(e,"hex")).length>this.blockSize&&(e=new Z().update(e).digest()),t=e.length;t<this.blockSize;t++)e.push(0);for(t=0;t<e.length;t++)e[t]^=54;for(t=0,this.inner=new Z().update(e);t<e.length;t++)e[t]^=106;this.outer=new Z().update(e)}update(e,t){return this.inner.update(e,t),this}digest(){return this.outer.update(this.inner.digest()),this.outer.digest()}digestHex(){return this.outer.update(this.inner.digest()),this.outer.digestHex()}}class ei{h;blockSize=128;outSize=32;constructor(e){const t=e instanceof Uint8Array?e:Uint8Array.from(D(e,"string"==typeof e?"hex":void 0));this.h=new eJ(eY,t)}update(e,t){let i=e instanceof Uint8Array?e:Uint8Array.from(D(e,t));return this.h.update(i),this}digest(){return Array.from(this.h.digest())}digestHex(){return H(this.h.digest())}}let er=(e,t)=>new Y().update(e,t).digest(),en=(e,t)=>new Z().update(e,t).digest(),ea=(e,t)=>new J().update(e,t).digest(),es=(e,t)=>new Q().update(e,t).digest(),eo=(e,t)=>{let i=new J().update(e,t).digest();return new J().update(i).digest()},ec=(e,t)=>{let i=new J().update(e,t).digest();return new Y().update(i).digest()},el=(e,t,i)=>new ee(e).update(t,i).digest(),eh=(e,t,i)=>new ei(e).update(t,i).digest();function ed(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`positive integer expected, got ${e}`)}function eu(e,...t){if(!(e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name))throw Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length)){let i=t.join(",");throw Error(`Uint8Array expected of length ${i}, got length=${e.length}`)}}function ef(e){if("function"!=typeof e||"function"!=typeof e.create)throw Error("Hash should be wrapped by utils.createHasher");ed(e.outputLen),ed(e.blockLen)}function ep(e,t=!0){if(!0===e.destroyed)throw Error("Hash instance has been destroyed");if(t&&!0===e.finished)throw Error("Hash#digest() has already been called")}function eg(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function em(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ey(e){return"string"==typeof e&&(e=eb(e)),eu(e),e}function eb(e){if("string"!=typeof e)throw Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function ew(e){return"string"==typeof e&&(e=eb(e)),eu(e),e}class ev{}function eI(e){let t=t=>e().update(ey(t)).digest(),i=e();return t.outputLen=i.outputLen,t.blockLen=i.blockLen,t.create=()=>e(),t}let ek=BigInt(0x100000000-1),eS=BigInt(32),eE=(e,t,i)=>e>>>i,ex=(e,t,i)=>e<<32-i|t>>>i,eP=(e,t,i)=>e>>>i|t<<32-i,eA=(e,t,i)=>e<<32-i|t>>>i,eN=(e,t,i)=>e<<64-i|t>>>i-32,eO=(e,t,i)=>e>>>i-32|t<<64-i;function eT(e,t,i,r){let n=(t>>>0)+(r>>>0);return{h:e+i+(n/0x100000000|0)|0,l:0|n}}let e_=(e,t,i)=>(e>>>0)+(t>>>0)+(i>>>0),eR=(e,t,i,r)=>t+i+r+(e/0x100000000|0)|0,eC=(e,t,i,r)=>(e>>>0)+(t>>>0)+(i>>>0)+(r>>>0),eB=(e,t,i,r,n)=>t+i+r+n+(e/0x100000000|0)|0,eU=(e,t,i,r,n)=>(e>>>0)+(t>>>0)+(i>>>0)+(r>>>0)+(n>>>0),eV=(e,t,i,r,n,a)=>t+i+r+n+a+(e/0x100000000|0)|0;class eD extends ev{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,i,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=i,this.isLE=r,this.buffer=new Uint8Array(e),this.view=em(this.buffer)}update(e){ep(this),eu(e=ey(e));let{view:t,buffer:i,blockLen:r}=this,n=e.length;for(let a=0;a<n;){let s=Math.min(r-this.pos,n-a);if(s===r){let t=em(e);for(;r<=n-a;a+=r)this.process(t,a);continue}i.set(e.subarray(a,a+s),this.pos),this.pos+=s,a+=s,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ep(this);eu(e);let t=this.outputLen;if(e.length<t)throw Error(`digestInto() expects output buffer of length at least ${t}`);this.finished=!0;let{buffer:i,view:r,blockLen:n,isLE:a}=this,{pos:s}=this;i[s++]=128,eg(this.buffer.subarray(s)),this.padOffset>n-s&&(this.process(r,0),s=0);for(let e=s;e<n;e++)i[e]=0;(function(e,t,i,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,i,r);let n=BigInt(32),a=BigInt(0xffffffff),s=Number(i>>n&a),o=Number(i&a),c=4*!!r,l=4*!r;e.setUint32(t+c,s,r),e.setUint32(t+l,o,r)})(r,n-8,BigInt(8*this.length),a),this.process(r,0);let o=em(e),c=this.outputLen;if(c%4!=0)throw Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,h=this.get();if(l>h.length)throw Error("_sha2: outputLen bigger than state");for(let e=0;e<l;e++)o.setUint32(4*e,h[e],a)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let i=e.slice(0,t);return this.destroy(),i}_cloneInto(e){(e||=new this.constructor).set(...this.get());let{blockLen:t,buffer:i,length:r,finished:n,destroyed:a,pos:s}=this;return e.destroyed=a,e.finished=n,e.length=r,e.pos=s,r%t!=0&&e.buffer.set(i),e}clone(){return this._cloneInto()}}let eL=Uint32Array.from([0x6a09e667,0xbb67ae85,0x3c6ef372,0xa54ff53a,0x510e527f,0x9b05688c,0x1f83d9ab,0x5be0cd19]),eF=Uint32Array.from([0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,0xe49b69c1,0xefbe4786,0xfc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x6ca6351,0x14292967,0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2]),eH=new Uint32Array(64);class eK extends eD{A=0|eL[0];B=0|eL[1];C=0|eL[2];D=0|eL[3];E=0|eL[4];F=0|eL[5];G=0|eL[6];H=0|eL[7];constructor(e=32){super(64,e,8,!1)}get(){let{A:e,B:t,C:i,D:r,E:n,F:a,G:s,H:o}=this;return[e,t,i,r,n,a,s,o]}set(e,t,i,r,n,a,s,o){this.A=0|e,this.B=0|t,this.C=0|i,this.D=0|r,this.E=0|n,this.F=0|a,this.G=0|s,this.H=0|o}process(e,t){var i,r,n,a,s,o,c,l,h;for(let i=0;i<16;i++,t+=4)eH[i]=e.getUint32(t);for(let e=16;e<64;e++){let t=eH[e-15],i=eH[e-2],r=M(t,7)^M(t,18)^t>>>3,n=M(i,17)^M(i,19)^i>>>10;eH[e]=$($(r,eH[e-7]),$(n,eH[e-16]))}let{A:d,B:u,C:f,D:p,E:g,F:m,G:y,H:b}=this;for(let e=0;e<64;e++){let t=(n=b,a=M(i=g,6)^M(i,11)^M(i,25),s=(r=g)&m^~r&y,n+a+s+eF[e]+eH[e]>>>0),w=$(M(o=d,2)^M(o,13)^M(o,22),(c=d)&(l=u)^c&(h=f)^l&h);b=y,y=m,m=g,g=$(p,t),p=f,f=u,u=d,d=$(t,w)}this.A=$(this.A,d),this.B=$(this.B,u),this.C=$(this.C,f),this.D=$(this.D,p),this.E=$(this.E,g),this.F=$(this.F,m),this.G=$(this.G,y),this.H=$(this.H,b)}roundClean(){eg(eH)}destroy(){eg(this.buffer),this.set(0,0,0,0,0,0,0,0)}}let eM=eI(()=>new eK),eq=Uint32Array.from([0x6a09e667,0xf3bcc908,0xbb67ae85,0x84caa73b,0x3c6ef372,0xfe94f82b,0xa54ff53a,0x5f1d36f1,0x510e527f,0xade682d1,0x9b05688c,0x2b3e6c1f,0x1f83d9ab,0xfb41bd6b,0x5be0cd19,0x137e2179]),e$=function(e,t=!1){let i=e.length,r=new Uint32Array(i),n=new Uint32Array(i);for(let a=0;a<i;a++){let{h:i,l:s}=function(e,t=!1){return t?{h:Number(e&ek),l:Number(e>>eS&ek)}:{h:0|Number(e>>eS&ek),l:0|Number(e&ek)}}(e[a],t);r[a]=i,n[a]=s}return[r,n]}(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),ez=e$[0],eW=e$[1],ej=new Uint32Array(80),eX=new Uint32Array(80);class eG extends eD{Ah=0|eq[0];Al=0|eq[1];Bh=0|eq[2];Bl=0|eq[3];Ch=0|eq[4];Cl=0|eq[5];Dh=0|eq[6];Dl=0|eq[7];Eh=0|eq[8];El=0|eq[9];Fh=0|eq[10];Fl=0|eq[11];Gh=0|eq[12];Gl=0|eq[13];Hh=0|eq[14];Hl=0|eq[15];constructor(e=64){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:i,Bl:r,Ch:n,Cl:a,Dh:s,Dl:o,Eh:c,El:l,Fh:h,Fl:d,Gh:u,Gl:f,Hh:p,Hl:g}=this;return[e,t,i,r,n,a,s,o,c,l,h,d,u,f,p,g]}set(e,t,i,r,n,a,s,o,c,l,h,d,u,f,p,g){this.Ah=0|e,this.Al=0|t,this.Bh=0|i,this.Bl=0|r,this.Ch=0|n,this.Cl=0|a,this.Dh=0|s,this.Dl=0|o,this.Eh=0|c,this.El=0|l,this.Fh=0|h,this.Fl=0|d,this.Gh=0|u,this.Gl=0|f,this.Hh=0|p,this.Hl=0|g}process(e,t){for(let i=0;i<16;i++,t+=4)ej[i]=e.getUint32(t),eX[i]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=0|ej[e-15],i=0|eX[e-15],r=eP(t,i,1)^eP(t,i,8)^eE(t,i,7),n=eA(t,i,1)^eA(t,i,8)^ex(t,i,7),a=0|ej[e-2],s=0|eX[e-2],o=eP(a,s,19)^eN(a,s,61)^eE(a,s,6),c=eC(n,eA(a,s,19)^eO(a,s,61)^ex(a,s,6),eX[e-7],eX[e-16]),l=eB(c,r,o,ej[e-7],ej[e-16]);ej[e]=0|l,eX[e]=0|c}let{Ah:i,Al:r,Bh:n,Bl:a,Ch:s,Cl:o,Dh:c,Dl:l,Eh:h,El:d,Fh:u,Fl:f,Gh:p,Gl:g,Hh:m,Hl:y}=this;for(let e=0;e<80;e++){let t=eP(h,d,14)^eP(h,d,18)^eN(h,d,41),b=eA(h,d,14)^eA(h,d,18)^eO(h,d,41),w=h&u^~h&p,v=eU(y,b,d&f^~d&g,eW[e],eX[e]),I=eV(v,m,t,w,ez[e],ej[e]),k=0|v,S=eP(i,r,28)^eN(i,r,34)^eN(i,r,39),E=eA(i,r,28)^eO(i,r,34)^eO(i,r,39),x=i&n^i&s^n&s,P=r&a^r&o^a&o;m=0|p,y=0|g,p=0|u,g=0|f,u=0|h,f=0|d,({h:h,l:d}=eT(0|c,0|l,0|I,0|k)),c=0|s,l=0|o,s=0|n,o=0|a,n=0|i,a=0|r;let A=e_(E,P,k);i=eR(A,S,x,I),r=0|A}({h:i,l:r}=eT(i,r,this.Ah,this.Al)),({h:n,l:a}=eT(n,a,this.Bh,this.Bl)),({h:s,l:o}=eT(s,o,this.Ch,this.Cl)),({h:c,l:l}=eT(c,l,this.Dh,this.Dl)),({h:h,l:d}=eT(h,d,this.Eh,this.El)),({h:u,l:f}=eT(u,f,this.Fh,this.Fl)),({h:p,l:g}=eT(p,g,this.Gh,this.Gl)),({h:m,l:y}=eT(m,y,this.Hh,this.Hl)),this.set(i,r,n,a,s,o,c,l,h,d,u,f,p,g,m,y)}roundClean(){eg(ej,eX)}destroy(){eg(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}let eY=eI(()=>new eG);class eJ extends ev{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,t){super(),ef(e);const i=ey(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,n=new Uint8Array(r);n.set(i.length>r?e.create().update(i).digest():i);for(let e=0;e<n.length;e++)n[e]^=54;this.iHash.update(n),this.oHash=e.create();for(let e=0;e<n.length;e++)n[e]^=106;this.oHash.update(n),eg(n)}update(e){return ep(this),this.iHash.update(e),this}digestInto(e){ep(this),eu(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:i,finished:r,destroyed:n,blockLen:a,outputLen:s}=this;return e.finished=r,e.destroyed=n,e.blockLen=a,e.outputLen=s,e.oHash=t._cloneInto(e.oHash??void 0),e.iHash=i._cloneInto(e.iHash??void 0),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}let eZ=(e,t,i)=>new eJ(e,t).update(i).digest();function eQ(e,t,i,r,n="sha512"){if("sha512"!==n)throw Error("Only sha512 is supported in this PBKDF2 implementation");try{let a=require("crypto");if("function"==typeof a.pbkdf2Sync){let s=Buffer.from(e),o=Buffer.from(t);return[...a.pbkdf2Sync(s,o,i,r,n)]}}catch{}return Array.from(function(e,t,i,r){let n;ef(e);let{c:a,dkLen:s}=Object.assign({dkLen:32},r);if(ed(a),ed(s),a<1)throw Error("iterations (c) should be >= 1");let o=ew(t),c=ew(i),l=new Uint8Array(s),h=eZ.create(e,o),d=h._cloneInto().update(c),u=new Uint8Array(4),f=em(u),p=new Uint8Array(h.outputLen);for(let e=1,t=0;t<s;e++,t+=h.outputLen){let i=l.subarray(t,t+h.outputLen);f.setInt32(0,e,!1),(n=d._cloneInto(n)).update(u).digestInto(p),i.set(p.subarray(0,i.length));for(let e=1;e<a;e++){h._cloneInto(n).update(p).digestInto(p);for(let e=0;e<i.length;e++)i[e]^=p[e]}}return h.destroy(),d.destroy(),null!=n&&n.destroy(),eg(p),l}(eY,Uint8Array.from(e),Uint8Array.from(t),{c:i,dkLen:r}))}function e0(e){return(e>>>24|e>>>8&65280|e<<8&0xff0000|(255&e)<<24)>>>0}eZ.create=(e,t)=>new eJ(e,t);let e1=(i=new Uint32Array(t=new ArrayBuffer(4)),r=new Uint8Array(t),i[0]=0x1020304,4===r[0]);function e2(e){return e1?e0(e):e>>>0}class e8{buffer;pos;capacity;constructor(e,t=256){if(null!=e&&e.length>0&&(t=Math.max(t,e.reduce((e,t)=>e+t.length,0))),this.buffer=new Uint8Array(t),this.pos=0,this.capacity=t,null!=e)for(const t of e)this.write(t)}getLength(){return this.pos}toUint8Array(){return this.buffer.slice(0,this.pos)}toArray(){return Array.from(this.toUint8Array())}toUint8ArrayZeroCopy(){return this.buffer.subarray(0,this.pos)}ensureCapacity(e){if(this.pos+e>this.capacity){let t=2*this.capacity;for(;this.pos+e>t;)t*=2;let i=new Uint8Array(t);i.set(this.buffer),this.buffer=i,this.capacity=t}}write(e){let t=e instanceof Uint8Array?e:new Uint8Array(e);return this.ensureCapacity(t.length),this.buffer.set(t,this.pos),this.pos+=t.length,this}writeReverse(e){let t=e instanceof Uint8Array?e:new Uint8Array(e);this.ensureCapacity(t.length);for(let e=t.length-1;e>=0;e--)this.buffer[this.pos]=t[e],this.pos+=1;return this}writeUInt8(e){return this.ensureCapacity(1),this.buffer[this.pos]=255&e,this.pos+=1,this}writeInt8(e){return this.writeUInt8(e),this}writeUInt16LE(e){return this.ensureCapacity(2),this.buffer[this.pos]=255&e,this.buffer[this.pos+1]=e>>8&255,this.pos+=2,this}writeUInt16BE(e){return this.ensureCapacity(2),this.buffer[this.pos]=e>>8&255,this.buffer[this.pos+1]=255&e,this.pos+=2,this}writeInt16LE(e){return this.writeUInt16LE(65535&e),this}writeInt16BE(e){return this.writeUInt16BE(65535&e),this}writeUInt32LE(e){return this.ensureCapacity(4),this.buffer[this.pos]=255&e,this.buffer[this.pos+1]=e>>8&255,this.buffer[this.pos+2]=e>>16&255,this.buffer[this.pos+3]=e>>24&255,this.pos+=4,this}writeUInt32BE(e){return this.ensureCapacity(4),this.buffer[this.pos]=e>>24&255,this.buffer[this.pos+1]=e>>16&255,this.buffer[this.pos+2]=e>>8&255,this.buffer[this.pos+3]=255&e,this.pos+=4,this}writeInt32LE(e){return this.writeUInt32LE(e>>>0),this}writeInt32BE(e){return this.writeUInt32BE(e>>>0),this}writeUInt64BEBn(e){let t=e.toArray("be",8);return this.write(t),this}writeUInt64LEBn(e){let t=e.toArray("be",8);return this.writeReverse(t),this}writeUInt64LE(e){let t=new P(e).toArray("be",8);return this.writeReverse(t),this}writeVarIntNum(e){let t=tp.varIntNum(e);return this.write(t),this}writeVarIntBn(e){let t=tp.varIntBn(e);return this.write(t),this}reset(){this.pos=0}}class e3{bin;pos;length;static makeReader(e,t=0){if(e instanceof Uint8Array)return new e3(e,t);if(Array.isArray(e))return new tg(e,t);throw Error("ReaderUint8Array.makeReader: bin must be Uint8Array or number[]")}constructor(e=new Uint8Array(0),t=0){if(e instanceof Uint8Array)this.bin=e;else if(Array.isArray(e))this.bin=new Uint8Array(e);else throw Error("ReaderUint8Array constructor: bin must be Uint8Array or number[]");this.pos=t,this.length=this.bin.length}eof(){return this.pos>=this.length}read(e=this.length){let t=this.pos,i=this.pos+e;return this.pos=i,this.bin.slice(t,i)}readReverse(e=this.length){let t=new Uint8Array(e);for(let i=0;i<e;i++)t[i]=this.bin[this.pos+e-1-i];return this.pos+=e,t}readUInt8(){let e=this.bin[this.pos];return this.pos+=1,e}readInt8(){let e=this.bin[this.pos];return this.pos+=1,(128&e)!=0?e-256:e}readUInt16BE(){let e=this.bin[this.pos]<<8|this.bin[this.pos+1];return this.pos+=2,e}readInt16BE(){let e=this.readUInt16BE();return(32768&e)!=0?e-65536:e}readUInt16LE(){let e=this.bin[this.pos]|this.bin[this.pos+1]<<8;return this.pos+=2,e}readInt16LE(){let e=this.readUInt16LE();return(32768&e)!=0?e-65536:e}readUInt32BE(){let e=0x1000000*this.bin[this.pos]+(this.bin[this.pos+1]<<16|this.bin[this.pos+2]<<8|this.bin[this.pos+3]);return this.pos+=4,e}readInt32BE(){let e=this.readUInt32BE();return(0x80000000&e)!=0?e-0x100000000:e}readUInt32LE(){let e=(this.bin[this.pos]|this.bin[this.pos+1]<<8|this.bin[this.pos+2]<<16|this.bin[this.pos+3]<<24)>>>0;return this.pos+=4,e}readInt32LE(){let e=this.readUInt32LE();return(0x80000000&e)!=0?e-0x100000000:e}readUInt64BEBn(){let e=new P(Array.from(this.bin.slice(this.pos,this.pos+8)));return this.pos=this.pos+8,e}readUInt64LEBn(){return new P(Array.from(this.readReverse(8)))}readInt64LEBn(){let e=new P(2).pow(new P(63)),t=new P(2).pow(new P(64)),i=new P(Array.from(this.readReverse(8)));return i.gte(e)&&(i=i.sub(t)),i}readVarIntNum(e=!0){let t,i=this.readUInt8();switch(i){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:if((t=e?this.readInt64LEBn():this.readUInt64LEBn()).lte(new P(2).pow(new P(53))))return t.toNumber();throw Error("number too large to retain precision - use readVarIntBn");default:return i}}readVarInt(){switch(this.bin[this.pos]){case 253:return this.read(3);case 254:return this.read(5);case 255:return this.read(9);default:return this.read(1)}}readVarIntBn(){let e=this.readUInt8();switch(e){case 253:return new P(this.readUInt16LE());case 254:return new P(this.readUInt32LE());case 255:return this.readUInt64LEBn();default:return new P(e)}}}let e6="u">typeof globalThis?globalThis.Buffer:void 0,e4=null!=e6&&"function"==typeof e6.from,e5=e=>e.length%2==1?"0"+e:e,e7="0123456789abcdef",e9=Array(256);for(let e=0;e<256;e++)e9[e]=e7[e>>4&15]+e7[15&e];let te=e=>{if(e4)return e6.from(e).toString("hex");if(0===e.length)return"";let t=Array(e.length);for(let i=0;i<e.length;i++)t[i]=e9[255&e[i]];return t.join("")},tt=(e,t)=>e instanceof Uint8Array?e:new Uint8Array(ti(e,t)),ti=(e,t)=>{if(Array.isArray(e))return e.slice();if(void 0===e)return[];if("string"!=typeof e)return Array.from(e,e=>0|e);switch(t){case"hex":return tn(e);case"base64":return ta(e);default:var i;return i=e,Array.from(new TextEncoder().encode(i))}},tr=new Int8Array(256).fill(-1);for(let e=0;e<10;e++)tr[48+e]=e;for(let e=0;e<6;e++)tr[65+e]=10+e,tr[97+e]=10+e;let tn=e=>{B(e);let t=e.length%2==0?e:"0"+e;if(e4)return Array.from(e6.from(t,"hex"));let i=Array(t.length/2),r=0;for(let e=0;e<t.length;e+=2){let n=tr[t.charCodeAt(e)],a=tr[t.charCodeAt(e+1)];i[r++]=n<<4|a}return i};function ta(e){if("string"!=typeof e)throw TypeError("msg must be a string");let t=e.trim().replace(/[\r\n\t\f\v ]+/g,""),i=(t=t.replace(/-/g,"+").replace(/_/g,"/")).indexOf("=");if(-1!==i){let e=t.slice(i);if(!/^={1,2}$/.test(e)||t.slice(0,i).includes("="))throw Error("Invalid base64 padding");t=t.slice(0,i)}let r=[],n=0,a=0;for(let e=0;e<t.length;e++){let i=t.charCodeAt(e),s=-1;if(i>=65&&i<=90)s=i-65;else if(i>=97&&i<=122)s=i-97+26;else if(i>=48&&i<=57)s=i-48+52;else if(43===i)s=62;else if(47===i)s=63;else throw Error(`Invalid base64 character at index ${e}`);for(n=n<<6|s,a+=6;a>=8;)a-=8,r.push(n>>a&255),n&=(1<<a)-1}return r}let ts=e=>new TextDecoder().decode(new Uint8Array(e)),to=(e,t)=>{switch(t){case"hex":return te(e);case"utf8":return ts(e);default:return e}};function tc(e){let t,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r="";for(t=0;t<e.length;t+=3){let n=e[t],a=t+1<e.length?e[t+1]:0,s=t+2<e.length?e[t+2]:0,o=n>>2,c=(3&n)<<4|a>>4,l=(15&a)<<2|s>>6,h=63&s;r+=i.charAt(o)+i.charAt(c),r+=t+1<e.length?i.charAt(l):"=",r+=t+2<e.length?i.charAt(h):"="}return r}let tl="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",th=e=>{let t;if(""===e||"string"!=typeof e)throw Error(`Expected base58 string but got “${e}”`);let i=e.match(/[IOl0]/gmu);if(null!==i)throw Error(`Invalid base58 character “${i.join("")}”`);let r=e.match(/^1+/gmu),n=null!==r?r[0].length:0,a=(e.length-n)*(Math.log(58)/Math.log(256))+1>>>0;return[...new Uint8Array([...new Uint8Array(n),...(e.match(/./gmu)??[]).map(e=>tl.indexOf(e)).reduce((e,t)=>e=e.map(e=>{let i=58*e+t;return t=i>>8,i}),new Uint8Array(a)).reverse().filter((t=!1,e=>t=t||e))])]},td=e=>{let t=Array(256).fill(-1);for(let e=0;e<tl.length;++e)t[tl.charCodeAt(e)]=e;let i=[];for(let r of e){let e=r;for(let r=0;r<i.length;++r){let n=(t[i[r]]<<8)+e;i[r]=tl.charCodeAt(n%58),e=n/58|0}for(;0!==e;)i.push(tl.charCodeAt(e%58)),e=e/58|0}for(let t of e)if(0!==t)break;else i.push(49);return i.reverse(),String.fromCharCode(...i)},tu=(e,t=[0])=>{let i=eo([...t,...e]);return td(i=[...t,...e,...i.slice(0,4)])},tf=(e,t,i=1)=>{let r=th(e),n=r.slice(0,i),a=r.slice(i,-4),s=[...n,...a];return s=eo(s),r.slice(-4).forEach((e,t)=>{if(e!==s[t])throw Error("Invalid checksum")}),"hex"===t&&(n=te(n),a=te(a)),{prefix:n,data:a}};class tp{bufs;length;constructor(e){for(const t of(this.bufs=void 0!==e?e:[],this.length=0,this.bufs))this.length+=t.length}getLength(){return this.length}toUint8Array(){let e=new Uint8Array(this.length),t=0;for(let i of this.bufs)e.set(i,t),t+=i.length;return e}toArray(){let e=Array(this.length),t=0;for(let i of this.bufs)if(i instanceof Uint8Array)for(let r=0;r<i.length;r++)e[t++]=i[r];else for(let r=0;r<i.length;r++)e[t++]=i[r];return e}toHex(){return this.toArray().map(e=>e.toString(16).padStart(2,"0")).join("")}write(e){return this.bufs.push(e),this.length+=e.length,this}writeReverse(e){let t=Array(e.length);for(let i=0;i<t.length;i++)t[i]=e[e.length-1-i];return this.write(t)}writeUInt8(e){let t=[,];return t[0]=255&e,this.write(t),this}writeInt8(e){let t=[,];return t[0]=255&e,this.write(t),this}writeUInt16BE(e){return this.write([e>>8&255,255&e])}writeInt16BE(e){return this.writeUInt16BE(65535&e)}writeUInt16LE(e){return this.write([255&e,e>>8&255])}writeInt16LE(e){return this.writeUInt16LE(65535&e)}writeUInt32BE(e){return this.write([e>>24&255,e>>16&255,e>>8&255,255&e])}writeInt32BE(e){return this.writeUInt32BE(e>>>0)}writeUInt32LE(e){return this.write([255&e,e>>8&255,e>>16&255,e>>24&255])}writeInt32LE(e){return this.writeUInt32LE(e>>>0)}writeUInt64BEBn(e){let t=e.toArray("be",8);return this.write(t),this}writeUInt64LEBn(e){let t=e.toArray("be",8);return this.writeReverse(t),this}writeUInt64LE(e){if(-1===e)this.write(Array(8).fill(255));else{let t=new P(e).toArray("be",8);this.writeReverse(t)}return this}writeVarIntNum(e){let t=tp.varIntNum(e);return this.write(t),this}writeVarIntBn(e){let t=tp.varIntBn(e);return this.write(t),this}static varIntNum(e){let t;if(e<0)return this.varIntBn(new P(e));if(e<253)t=[e];else if(e<65536)t=[253,255&e,e>>8&255];else if(e<0x100000000)t=[254,255&e,e>>8&255,e>>16&255,e>>24&255];else{let i=0|e,r=0|Math.floor(e/0x100000000);t=[255,255&i,i>>8&255,i>>16&255,i>>24&255,255&r,r>>8&255,r>>16&255,r>>24&255]}return t}static varIntBn(e){let t;if(e.isNeg()&&(e=e.add(tb)),e.ltn(253))t=[e.toNumber()];else if(e.ltn(65536)){let i=e.toNumber();t=[253,255&i,i>>8&255]}else if(e.lt(new P(0x100000000))){let i=e.toNumber();t=[254,255&i,i>>8&255,i>>16&255,i>>24&255]}else{let i=new tp;i.writeUInt8(255),i.writeUInt64LEBn(e),t=i.toArray()}return t}}class tg{bin;pos;length;constructor(e=[],t=0){this.bin=e,this.pos=t,this.length=e.length}eof(){return this.pos>=this.length}read(e=this.length){let t=this.pos,i=this.pos+e;return this.pos=i,this.bin.slice(t,i)}readReverse(e=this.length){let t=Array(e);for(let i=0;i<e;i++)t[i]=this.bin[this.pos+e-1-i];return this.pos+=e,t}readUInt8(){let e=this.bin[this.pos];return this.pos+=1,e}readInt8(){let e=this.bin[this.pos];return this.pos+=1,(128&e)!=0?e-256:e}readUInt16BE(){let e=this.bin[this.pos]<<8|this.bin[this.pos+1];return this.pos+=2,e}readInt16BE(){let e=this.readUInt16BE();return(32768&e)!=0?e-65536:e}readUInt16LE(){let e=this.bin[this.pos]|this.bin[this.pos+1]<<8;return this.pos+=2,e}readInt16LE(){let e=this.readUInt16LE();return(32768&e)!=0?e-65536:e}readUInt32BE(){let e=0x1000000*this.bin[this.pos]+(this.bin[this.pos+1]<<16|this.bin[this.pos+2]<<8|this.bin[this.pos+3]);return this.pos+=4,e}readInt32BE(){let e=this.readUInt32BE();return(0x80000000&e)!=0?e-0x100000000:e}readUInt32LE(){let e=(this.bin[this.pos]|this.bin[this.pos+1]<<8|this.bin[this.pos+2]<<16|this.bin[this.pos+3]<<24)>>>0;return this.pos+=4,e}readInt32LE(){let e=this.readUInt32LE();return(0x80000000&e)!=0?e-0x100000000:e}readUInt64BEBn(){let e=new P(this.bin.slice(this.pos,this.pos+8));return this.pos=this.pos+8,e}readUInt64LEBn(){return new P(this.readReverse(8))}readInt64LEBn(){let e=new P(this.readReverse(8));return e.gte(ty)&&(e=e.sub(tb)),e}readVarIntNum(e=!0){let t,i=this.readUInt8();switch(i){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:if((t=e?this.readInt64LEBn():this.readUInt64LEBn()).lte(new P(2).pow(new P(53))))return t.toNumber();throw Error("number too large to retain precision - use readVarIntBn");default:return i}}readVarInt(){switch(this.bin[this.pos]){case 253:return this.read(3);case 254:return this.read(5);case 255:return this.read(9);default:return this.read(1)}}readVarIntBn(){let e=this.readUInt8();switch(e){case 253:return new P(this.readUInt16LE());case 254:return new P(this.readUInt32LE());case 255:return this.readUInt64LEBn();default:return new P(e)}}}let tm=e=>{if(0===e.length)return e;let t=e[e.length-1];if((127&t)!=0)return e;if(1===e.length)return[];if((128&e[e.length-2])!=0)return e;for(let i=e.length-1;i>0;i--)if(0!==e[i-1])if((128&e[i-1])!=0)return e[i]=t,e.slice(0,i+1);else return e[i-1]|=t,e.slice(0,i);return[]},ty=new P(2).pow(new P(63)),tb=new P(2).pow(new P(64));function tw(e,t="Expected a valid value, but got undefined or null."){if(null==e)throw Error(t);return e}function tv(e,t){if(e.length!==t.length)return!1;let i=0;for(let r=0;r<e.length;r++)i|=e[r]^t[r];return 0===i}function tI(e,t,i){let r=-e,n=(t.X^i.X)&r,a=(t.Y^i.Y)&r,s=(t.Z^i.Z)&r;t.X^=n,i.X^=n,t.Y^=a,i.Y^=a,t.Z^=s,i.Z^=s}let tk=(1n<<256n)-1n;function tS(e){let t=e>>256n;return t=(e=(e&tk)+(t<<32n)+977n*t)>>256n,(e=(e&tk)+(t<<32n)+977n*t)>=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn&&(e-=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn),e}let tE=e=>tS((e%0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn+0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn)%0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn),tx=(e,t)=>e>=t?e-t:0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn-(t-e),tP=(e,t)=>tS(e*t),tA=e=>{let t=1n,i=0n,r=tE(e),n=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn;for(;r>1n;){let e=n/r;[t,i]=[i-t*e,t],[r,n]=[n-r*e,r]}return tE(t)},tN=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn+1n>>2n,tO=BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),tT=BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),t_=new Map,tR=e=>{let{X:t,Y:i,Z:r}=e;if(0n===i)return{X:0n,Y:1n,Z:0n};let n=tP(i,i),a=tP(4n,tP(t,n)),s=tP(3n,tP(t,t)),o=tx(tP(s,s),tP(2n,a)),c=tx(tP(s,tx(a,o)),tP(8n,tP(n,n)));return{X:o,Y:c,Z:tP(2n,tP(i,r))}},tC=(e,t)=>{if(0n===e.Z)return t;if(0n===t.Z)return e;let i=tP(e.Z,e.Z),r=tP(t.Z,t.Z),n=tP(e.X,r),a=tP(t.X,i),s=tP(e.Y,tP(r,t.Z)),o=tP(t.Y,tP(i,e.Z)),c=tx(a,n),l=tx(o,s);if(0n===c)return 0n===l?tR(e):{X:0n,Y:1n,Z:0n};let h=tP(c,c),d=tP(c,h),u=tP(n,h),f=tx(tx(tP(l,l),d),tP(2n,u)),p=tx(tP(l,tx(u,f)),tP(s,d));return{X:f,Y:p,Z:tP(c,tP(e.Z,t.Z))}},tB=e=>0n===e.Z?e:{X:e.X,Y:0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn-e.Y,Z:e.Z},tU=(e,t,i=5)=>{let r,n=`${i}:${t.x.toString(16)}:${t.y.toString(16)}`,a=t_.get(n);if(void 0===a){let e=1<<i-1;a=Array(e),r={X:t.x,Y:t.y,Z:1n},a[0]=r;let s=tR(r);for(let t=1;t<e;t++)a[t]=tC(a[t-1],s);t_.set(n,a)}else r=a[0];let s=[],o=1n<<BigInt(i),c=o>>1n,l=e;for(;l>0n;)if((1n&l)===0n)s.push(0),l>>=1n;else{let e=l&o-1n;e>c&&(e-=o),s.push(Number(e)),l-=e,l>>=1n}let h={X:0n,Y:1n,Z:0n};for(let e=s.length-1;e>=0;e--){h=tR(h);let t=s[e];if(0!==t){let e=Math.abs(t)>>1;h=tC(h,t>0?a[e]:tB(a[e]))}}return h},tV=e=>{let t=e%0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n;return t<0n&&(t+=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n),t},tD=(e,t)=>tV(e*t),tL=e=>{let t=1n,i=0n,r=tV(e),n=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n;for(;r>1n;){let e=n/r;[t,i]=[i-t*e,t],[r,n]=[n-r*e,r]}return tV(t)};class tF extends _{x;y;inf;static _assertOnCurve(e){if(!e.validate())throw Error("Invalid point");return e}static fromDER(e){if((4===e[0]||6===e[0]||7===e[0])&&e.length-1==64){if(6===e[0]){if(e[e.length-1]%2!=0)throw Error("Point string value is wrong length")}else if(7===e[0]&&e[e.length-1]%2!=1)throw Error("Point string value is wrong length");let t=new tF(e.slice(1,33),e.slice(33,65));return tF._assertOnCurve(t)}if((2===e[0]||3===e[0])&&e.length-1==32)return tF._assertOnCurve(tF.fromX(e.slice(1,33),3===e[0]));throw Error("Unknown point format")}static fromString(e){let t=ti(e,"hex");return tF._assertOnCurve(tF.fromDER(t))}static fromX(e,t){var i;let r,n,a=P.isBN(e)?BigInt("0x"+e.toString(16)):"string"==typeof e?BigInt("0x"+e):Array.isArray(e)?BigInt("0x"+te(e)):BigInt(e),s=(n=((e,t)=>{let i=1n;for(e=tE(e);t>0n;)(1n&t)!==0n&&(i=tP(i,e)),e=tP(e,e),t>>=1n;return i})(i=tS(tP(tP(r=a=tE(a),r),a)+7n),tN),tP(n,n)!==tE(i)?null:n);if(null===s)throw Error("Invalid point");let o=s;(1n&o)!==(t?1n:0n)&&(o=tx(0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,o));let c=new P(a.toString(16),16),l=new P(o.toString(16),16);return tF._assertOnCurve(new tF(c,l))}static fromJSON(e,t){"string"==typeof e&&(e=JSON.parse(e));let i=new tF(e[0],e[1],t);if(i=tF._assertOnCurve(i),"object"!=typeof e[2]||null===e[2])return i;let r=e[2],n=e=>{let i=new tF(e[0],e[1],t);return tF._assertOnCurve(i)};return i.precomputed={beta:null,doubles:"object"==typeof r.doubles&&null!==r.doubles?{step:r.doubles.step,points:[i].concat(r.doubles.points.map(n))}:void 0,naf:"object"==typeof r.naf&&null!==r.naf?{wnd:r.naf.wnd,points:[i].concat(r.naf.points.map(n))}:void 0},i}constructor(e,t,i=!0){super("affine"),this.precomputed=null,null===e&&null===t?(this.x=null,this.y=null,this.inf=!0):(P.isBN(e)||(e=new P(e,16)),this.x=e,P.isBN(t)||(t=new P(t,16)),this.y=t,i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),null===this.x.red&&(this.x=this.x.toRed(this.curve.red)),null===this.y.red&&(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}validate(){if(this.inf||null==this.x||null==this.y)return!1;try{let e,t=BigInt("0x"+this.x.fromRed().toString(16)),i=BigInt("0x"+this.y.fromRed().toString(16)),r=tP(i,i),n=(e=tP(tP(t,t),t),tS(e+7n));return r===n}catch{return!1}}encode(e=!0,t){let i;if(this.inf)return"hex"===t?"00":[0];let r=this.curve.p.byteLength(),n=this.getX().toArray("be",r);return(i=e?[this.getY().isEven()?2:3].concat(n):[4].concat(n,this.getY().toArray("be",r)),"hex"!==t)?i:te(i)}toString(){return this.encode(!0,"hex")}toJSON(){return null==this.precomputed?[this.x,this.y]:[this.x,this.y,"object"==typeof this.precomputed&&null!==this.precomputed?{doubles:null!=this.precomputed.doubles?{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)}:void 0,naf:null!=this.precomputed.naf?{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}:void 0}:void 0]}inspect(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+(this.x?.fromRed()?.toString(16,2)??"undefined")+" y: "+(this.y?.fromRed()?.toString(16,2)??"undefined")+">"}isInfinity(){return this.inf}add(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e)||this.x?.cmp(e.x??new P(0))===0)return new tF(null,null);let t=tC({X:BigInt("0x"+this.x.fromRed().toString(16)),Y:BigInt("0x"+this.y.fromRed().toString(16)),Z:1n},{X:BigInt("0x"+e.x.fromRed().toString(16)),Y:BigInt("0x"+e.y.fromRed().toString(16)),Z:1n});if(0n===t.Z)return new tF(null,null);let i=tA(t.Z),r=tP(i,i),n=tP(t.X,r),a=tP(t.Y,tP(r,i));return new tF(n.toString(16),a.toString(16))}dbl(){if(this.inf)return this;if(null===this.x||null===this.y)throw Error("Point coordinates cannot be null");let e=BigInt("0x"+this.x.fromRed().toString(16)),t=BigInt("0x"+this.y.fromRed().toString(16));if(0n===t)return new tF(null,null);let i=tR({X:e,Y:t,Z:1n}),r=tA(i.Z),n=tP(r,r),a=tP(i.X,n),s=tP(i.Y,tP(n,r));return new tF(a.toString(16),s.toString(16))}getX(){return(this.x??new P(0)).fromRed()}getY(){return(this.y??new P(0)).fromRed()}mul(e){let t,i;if(P.isBN(e)||(e=new P(e,16)),this.inf)return this;let r=e.isNeg(),n=BigInt("0x"+(r?e.neg():e).toString(16));if(0n===(n=tE(n))||0n===n)return new tF(null,null);if(null===this.x||null===this.y)throw Error("Point coordinates cannot be null");this===this.curve.g?(t=tO,i=tT):(t=BigInt("0x"+this.x.fromRed().toString(16)),i=BigInt("0x"+this.y.fromRed().toString(16)));let a=tU(n,{x:t,y:i});if(0n===a.Z)return new tF(null,null);let s=tA(a.Z),o=tP(s,s),c=tP(a.X,o),l=tP(a.Y,tP(o,s)),h=new tF(new P(c.toString(16),16),new P(l.toString(16),16));return r?h.neg():h}mulCT(e){if(P.isBN(e)||(e=new P(e,16)),this.inf)return new tF(null,null);let t=e.isNeg(),i=BigInt("0x"+(t?e.neg():e).toString(16));if(0n===(i=tE(i)))return new tF(null,null);let r=this===this.curve.g?tO:BigInt("0x"+this.getX().toString(16)),n=this===this.curve.g?tT:BigInt("0x"+this.getY().toString(16)),a={X:0n,Y:1n,Z:0n},s={X:r,Y:n,Z:1n},o=i.toString(2);for(let e=0;e<o.length;e++){let t="1"===o[e]?1n:0n;tI(t,a,s),s=tC(a,s),tI(t,a=tR(a),s)}if(0n===a.Z)return new tF(null,null);let c=tA(a.Z),l=tP(c,c),h=tP(a.X,l),d=tP(a.Y,tP(l,c)),u=new tF(h.toString(16),d.toString(16));return t?u.neg():u}mulAdd(e,t,i){return this._endoWnafMulAdd([this,t],[e,i])}jmulAdd(e,t,i){return this._endoWnafMulAdd([this,t],[e,i],!0)}eq(e){return this===e||this.inf===e.inf&&(this.inf||0===(this.x??new P(0)).cmp(e.x??new P(0))&&0===(this.y??new P(0)).cmp(e.y??new P(0)))}neg(e){if(this.inf)return this;let t=new tF(this.x,(this.y??new P(0)).redNeg());if(!0===e&&null!=this.precomputed){let e=this.precomputed;t.precomputed={naf:null!=e.naf?{wnd:e.naf.wnd,points:e.naf.points.map(e=>e.neg())}:void 0,doubles:null!=e.doubles?{step:e.doubles.step,points:e.doubles.points.map(e=>e.neg())}:void 0,beta:void 0}}return t}dblp(e){let t=this;for(let i=0;i<e;i++)t=t.dbl();return t}toJ(){return this.inf?new R(null,null,null):new R(this.x,this.y,this.curve.one)}_getBeta(){if("object"!=typeof this.curve.endo)return;let e=this.precomputed;if("object"==typeof e&&null!==e&&"object"==typeof e.beta&&null!==e.beta)return e.beta;let t=new tF((this.x??new P(0)).redMul(this.curve.endo.beta),this.y);if(null!=e){let i=this.curve,r=e=>{if(null===e.x)throw Error("p.x is null");if(void 0===i.endo||null===i.endo)throw Error("curve.endo is undefined");return new tF(e.x.redMul(i.endo.beta),e.y)};e.beta=t,t.precomputed={beta:null,naf:null!=e.naf?{wnd:e.naf.wnd,points:e.naf.points.map(r)}:void 0,doubles:null!=e.doubles?{step:e.doubles.step,points:e.doubles.points.map(r)}:void 0}}return t}_fixedNafMul(e){if("object"!=typeof this.precomputed||null===this.precomputed)throw Error("_fixedNafMul requires precomputed values for the point");let t=this._getDoubles(),i=this.curve.getNAF(e,1,this.curve._bitLength),r=(1<<t.step+1)-(t.step%2==0?2:1);r/=3;let n=[];for(let e=0;e<i.length;e+=t.step){let r=0;for(let n=e+t.step-1;n>=e;n--)r=(r<<1)+i[n];n.push(r)}let a=new R(null,null,null),s=new R(null,null,null);for(let e=r;e>0;e--){for(let i=0;i<n.length;i++){let r=n[i];r===e?s=s.mixedAdd(t.points[i]):r===-e&&(s=s.mixedAdd(t.points[i].neg()))}a=a.add(s)}return a.toP()}_wnafMulAdd(e,t,i,r,n){let a=this.curve._wnafT1.map(e=>e.toNumber()),s=this.curve._wnafT2.map(()=>[]),o=this.curve._wnafT3.map(()=>[]),c=0;for(let i=0;i<r;i++){let r=t[i]._getNAFPoints(e);a[i]=r.wnd,s[i]=r.points}for(let e=r-1;e>=1;e-=2){let r=e-1,n=e;if(1!==a[r]||1!==a[n]){o[r]=this.curve.getNAF(i[r],a[r],this.curve._bitLength),o[n]=this.curve.getNAF(i[n],a[n],this.curve._bitLength),c=Math.max(o[r].length,c),c=Math.max(o[n].length,c);continue}let l=[t[r],null,null,t[n]];0===(t[r].y??new P(0)).cmp(t[n].y??new P(0))?(l[1]=t[r].add(t[n]),l[2]=t[r].toJ().mixedAdd(t[n].neg())):0===(t[r].y??new P(0)).cmp((t[n].y??new P(0)).redNeg())?(l[1]=t[r].toJ().mixedAdd(t[n]),l[2]=t[r].add(t[n].neg())):(l[1]=t[r].toJ().mixedAdd(t[n]),l[2]=t[r].toJ().mixedAdd(t[n].neg()));let h=[-3,-1,-5,-7,0,7,5,1,3],d=this.curve.getJSF(i[r],i[n]);c=Math.max(d[0].length,c),o[r]=Array(c),o[n]=Array(c);for(let e=0;e<c;e++){let t=0|d[0][e],i=0|d[1][e];o[r][e]=h[(t+1)*3+(i+1)],o[n][e]=0,s[r]=l}}let l=new R(null,null,null),h=this.curve._wnafT4;for(let e=c;e>=0;e--){let t=0;for(;e>=0;){let i=!0;for(let t=0;t<r;t++)h[t]=new P("number"==typeof o[t][e]?o[t][e]:0),h[t].isZero()||(i=!1);if(!i)break;t++,e--}if(e>=0&&t++,l=l.dblp(t),e<0)break;let i=new P(1),n=new P(2);for(let e=0;e<r;e++){let t,r=h[e];0!==r.cmpn(0)&&(l="affine"===(t=r.isNeg()?s[e][r.neg().sub(i).div(n).toNumber()].neg():s[e][r.sub(i).div(n).toNumber()]).type?l.mixedAdd(t):l.add(t))}}for(let e=0;e<r;e++)s[e]=[];return!0===n?l:l.toP()}_endoWnafMulAdd(e,t,i){let r,n=Array(2*e.length),a=Array(2*e.length);for(r=0;r<e.length;r++){let i=this.curve._endoSplit(t[r]),s=e[r],o=s._getBeta()??new tF(null,null);0!==i.k1.negative&&(i.k1.ineg(),s=s.neg(!0)),0!==i.k2.negative&&(i.k2.ineg(),o=o.neg(!0)),n[2*r]=s,n[2*r+1]=o,a[2*r]=i.k1,a[2*r+1]=i.k2}let s=this._wnafMulAdd(1,n,a,2*r,i);for(let e=0;e<2*r;e++)n[e]=null,a[e]=null;return s}_hasDoubles(e){if(null==this.precomputed)return!1;let t=this.precomputed.doubles;return"object"==typeof t&&t.points.length>=Math.ceil((e.bitLength()+1)/t.step)}_getDoubles(e,t){if("object"==typeof this.precomputed&&null!==this.precomputed&&"object"==typeof this.precomputed.doubles&&null!==this.precomputed.doubles)return this.precomputed.doubles;let i=[this],r=this;for(let n=0;n<(t??0);n+=e??1){for(let t=0;t<(e??1);t++)r=r.dbl();i.push(r)}return{step:e??1,points:i}}_getNAFPoints(e){if("object"==typeof this.precomputed&&null!==this.precomputed&&"object"==typeof this.precomputed.naf&&null!==this.precomputed.naf)return this.precomputed.naf;let t=[this],i=(1<<e)-1,r=1===i?null:this.dbl();for(let e=1;e<i;e++)null!==r&&(t[e]=t[e-1].add(r));return{wnd:e,points:t}}}class tH{p;red;redN;zero;one;two;g;n;a;b;tinv;zeroA;threeA;endo;_endoWnafT1;_endoWnafT2;_wnafT1;_wnafT2;_wnafT3;_wnafT4;_bitLength;static assert(e,t="Elliptic curve assertion failed"){if(!e)throw Error(t)}getNAF(e,t,i){let r=Array(Math.max(e.bitLength(),i)+1);r.fill(0);let n=1<<t+1,a=e.clone();for(let e=0;e<r.length;e++){let t,i=a.andln(n-1);a.isOdd()?(t=i>(n>>1)-1?(n>>1)-i:i,a.isubn(t)):t=0,r[e]=t,a.iushrn(1)}return r}getJSF(e,t){let i=[[],[]];e=e.clone(),t=t.clone();let r=0,n=0;for(;e.cmpn(-r)>0||t.cmpn(-n)>0;){let a,s,o=e.andln(3)+r&3,c=t.andln(3)+n&3;if(3===o&&(o=-1),3===c&&(c=-1),(1&o)==0)a=0;else{let t=e.andln(7)+r&7;a=(3===t||5===t)&&2===c?-o:o}if(i[0].push(a),(1&c)==0)s=0;else{let e=t.andln(7)+n&7;s=(3===e||5===e)&&2===o?-c:c}i[1].push(s),2*r===a+1&&(r=1-r),2*n===s+1&&(n=1-n),e.iushrn(1),t.iushrn(1)}return i}static cachedProperty(e,t,i){let r="_"+t;e.prototype[t]=function(){return void 0!==this[r]?this[r]:this[r]=i.call(this)}}static parseBytes(e){return"string"==typeof e?ti(e,"hex"):e}static intFromLE(e){return new P(e,"hex","le")}constructor(){if(void 0!==e)return e;e=this;const t={prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",{doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}]};this.p=new P(t.p,16),this.red=new O(t.prime),this.zero=new P(0).toRed(this.red),this.one=new P(1).toRed(this.red),this.two=new P(2).toRed(this.red),this.n=new P(t.n,16),this.g=tF.fromJSON(t.g,t.gRed),this._wnafT1=[,,,,],this._wnafT2=[,,,,],this._wnafT3=[,,,,],this._wnafT4=[,,,,],this._bitLength=this.n.bitLength(),this.redN=this.n.toRed(this.red),this.a=new P(t.a,16).toRed(this.red),this.b=new P(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=[,,,,],this._endoWnafT2=[,,,,]}_getEndomorphism(e){let t,i,r;if(this.zeroA&&1===this.p.modrn(3)){if(void 0!==e.beta)t=new P(e.beta,16).toRed(this.red);else{let e=this._getEndoRoots(this.p);if(null===e)throw Error("Failed to get endomorphism roots for beta.");t=(t=0>e[0].cmp(e[1])?e[0]:e[1]).toRed(this.red)}if(void 0!==e.lambda)i=new P(e.lambda,16);else{let e=this._getEndoRoots(this.n);if(null===e)throw Error("Failed to get endomorphism roots for lambda.");if(null==this.g)throw Error("Curve generator point (g) is not defined.");let r=this.g.mul(e[0])?.x,n=null!=this.g.x?this.g.x.redMul(t):void 0;if(null!=r&&null!=n&&0===r.cmp(n))i=e[0];else{if(i=e[1],null==this.g)throw Error("Curve generator point (g) is not defined.");let r=this.g.mul(i)?.x,n=null!=this.g.x?this.g.x.redMul(t):void 0;if(null==r||null==n)throw Error("Lambda computation failed: g.mul(lambda).x or g.x.redMul(beta) is undefined.");tH.assert(0===r.cmp(n),"Lambda selection does not match computed beta.")}}return r="object"==typeof e.basis&&null!==e.basis?e.basis.map(function(e){return{a:new P(e.a,16),b:new P(e.b,16)}}):this._getEndoBasis(i),{beta:t,lambda:i,basis:r}}}_getEndoRoots(e){let t=e===this.p?this.red:new T(e),i=new P(2).toRed(t).redInvm(),r=i.redNeg(),n=new P(3).toRed(t).redNeg().redSqrt().redMul(i);return[r.redAdd(n).fromRed(),r.redSub(n).fromRed()]}_getEndoBasis(e){let t,i,r,n,a,s,o=this.n.ushrn(Math.floor(this.n.bitLength()/2)),c=e,l=this.n.clone(),h=new P(1),d=new P(0),u=new P(0),f=new P(1),p=new P(0),g=0,m=new P(0),y=new P(0);for(;0!==c.cmpn(0);){let e=l.div(c);m=l.sub(e.mul(c)),y=u.sub(e.mul(h));let a=f.sub(e.mul(d));if(void 0===r&&0>m.cmp(o))t=p.neg(),i=h,r=m.neg(),n=y;else if(void 0!==r&&2==++g)break;p=m,l=c,c=m,u=h,h=y,f=d,d=a}if(void 0===t||void 0===i||void 0===r||void 0===n)throw Error("Failed to compute Endo Basis values");a=m.neg(),s=y;let b=r.sqr().add(n.sqr());return a.sqr().add(s.sqr()).cmp(b)>=0&&(a=t,s=i),0!==r.negative&&(r=r.neg(),n=n.neg()),0!==a.negative&&(a=a.neg(),s=s.neg()),[{a:r,b:n},{a:a,b:s}]}_endoSplit(e){if(null==this.endo)throw Error("Endomorphism is not defined.");let t=this.endo.basis,i=t[0],r=t[1],n=r.b.mul(e).divRound(this.n),a=i.b.neg().mul(e).divRound(this.n),s=n.mul(i.a),o=a.mul(r.a),c=n.mul(i.b),l=a.mul(r.b);return{k1:e.sub(s).sub(o),k2:c.add(l).neg()}}validate(e){if(e.inf)return!0;let t=e.x,i=e.y;if(null===t||null===i)throw Error("Point coordinates cannot be null");let r=this.a.redMul(t),n=t.redSqr().redMul(t).redIAdd(r).redIAdd(this.b);return 0===i.redSqr().redISub(n).cmpn(0)}}class tK{r;s;static fromDER(e,t){let i=(e,t)=>{let i=e[t.place++];if((128&i)==0)return i;throw Error("Invalid DER entity length")};e=ti(e,t);let r=new class{place;constructor(){this.place=0}};if(48!==e[r.place++])throw Error("Signature DER must start with 0x30");if(i(e,r)+r.place!==e.length||2!==e[r.place++])throw Error("Signature DER invalid");let n=i(e,r),a=e.slice(r.place,n+r.place);if(r.place+=n,2!==e[r.place++])throw Error("Signature DER invalid");let s=i(e,r);if(e.length!==s+r.place)throw Error("Invalid R-length in signature DER");let o=e.slice(r.place,s+r.place);if(0===a[0])if((128&a[1])!=0)a=a.slice(1);else throw Error("Invalid R-value in signature DER");if(0===o[0])if((128&o[1])!=0)o=o.slice(1);else throw Error("Invalid S-value in signature DER");return new tK(new P(a),new P(o))}static fromCompact(e,t){if(65!==(e=ti(e,t)).length)throw Error("Invalid Compact Signature");let i=e[0];if(i<27||i>=35)throw Error("Invalid Compact Byte");return new tK(new P(e.slice(1,33)),new P(e.slice(33,65)))}constructor(e,t){this.r=e,this.s=t}verify(e,t,i){return tY(new P(ea(e,i),16),this,t)}toString(e){return this.toDER(e)}toDER(e){let t=(e,t)=>{if(t<128)e.push(t);else throw Error("len must be < 0x80")},i=e=>{let t=0,i=e.length-1;for(;0===e[t]&&(128&e[t+1])==0&&t<i;)t++;return 0===t?e:e.slice(t)},r=this.r.toArray(),n=this.s.toArray();for((128&r[0])!=0&&(r=[0].concat(r)),(128&n[0])!=0&&(n=[0].concat(n)),r=i(r),n=i(n);0===n[0]&&(128&n[1])==0;)n=n.slice(1);let a=[2];t(a,r.length),(a=a.concat(r)).push(2),t(a,n.length);let s=a.concat(n),o=[48];return(t(o,s.length),o=o.concat(s),"hex"===e)?te(o):"base64"===e?tc(o):o}toCompact(e,t,i){if(e<0||e>3)throw Error("Invalid recovery param");if("boolean"!=typeof t)throw Error("Invalid compressed param");let r=27+e;t&&(r+=4);let n=[r];return(n=(n=n.concat(this.r.toArray("be",32))).concat(this.s.toArray("be",32)),"hex"===i)?te(n):"base64"===i?tc(n):n}RecoverPublicKey(e,t){let i=this.r,r=this.s,n=new tH,a=n.n,s=n.g,o=0!=e>>1?i.add(a):i,c=tF.fromX(o,(1&e)!=0);if(!c.mul(a).isInfinity())throw Error("nR is not at infinity");let l=t.neg().umod(a),h=i.invm(a),d=h.mul(r).umod(a),u=h.mul(l).umod(a),f=new tJ(s.mul(u).add(c.mul(d)));return f.validate(),f}CalculateRecoveryFactor(e,t){for(let i=0;i<4;i++){let r;try{r=this.RecoverPublicKey(i,t)}catch{continue}if(e.eq(r))return i}throw Error("Unable to find valid recovery factor")}}class tM{K;V;constructor(e,t){const i=ti(e,"hex"),r=ti(t,"hex");if(32!==i.length)throw Error("Entropy must be exactly 32 bytes (256 bits)");if(32!==r.length)throw Error("Nonce must be exactly 32 bytes (256 bits)");const n=i.concat(r);this.K=Array(32),this.V=Array(32);for(let e=0;e<32;e++)this.K[e]=0,this.V[e]=1;this.update(n)}hmac(){return new ee(this.K)}update(e){let t=this.hmac().update(this.V).update([0]);void 0!==e&&(t=t.update(e)),this.K=t.digest(),this.V=this.hmac().update(this.V).digest(),void 0!==e&&(this.K=this.hmac().update(this.V).update([1]).update(e).digest(),this.V=this.hmac().update(this.V).digest())}generate(e){let t=[];for(;t.length<e;)this.V=this.hmac().update(this.V).digest(),t=t.concat(this.V);let i=t.slice(0,e);return this.update(),te(i)}}function tq(e,t,i=new tH){let r=8*e.byteLength()-i.n.bitLength();return(r>0&&e.iushrn(r),!0!==t&&e.cmp(i.n)>=0)?e.sub(i.n):e}function t$(e){let t=e.toArray("be"),i=0n;for(let e=0;e<t.length;e++)i=i<<8n|BigInt(t[e]);return i}let tz=new tH,tW=tz.n.byteLength(),tj=tz.n.subn(1),tX=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n>>1n,tG=(e,t,i=!1,r)=>{let n=tz.n.bitLength();if(e.bitLength()>n)throw Error(`ECDSA message is too large: expected <= ${n} bits. Callers must hash messages before signing.`);let a=t$(e=tq(e)),s=t$(t),o=new tM(t.toArray("be",tW),e.toArray("be",tW));for(let e=0;;e++){let t="function"==typeof r?r(e):P.isBN(r)?r:new P(o.generate(tW),16);if(null==t)throw Error("k is undefined");if(0>(t=tq(t,!0)).cmpn(1)||t.cmp(tj)>0){if(P.isBN(r))throw Error("Invalid fixed custom K value (must be >1 and <N-1)");continue}let n=tz.g.mulCT(t);if(n.isInfinity()){if(P.isBN(r))throw Error("Invalid fixed custom K value (k\xb7G at infinity)");continue}let c=tV(BigInt("0x"+n.getX().toString(16)));if(0n===c){if(P.isBN(r))throw Error("Invalid fixed custom K value (r == 0)");continue}let l=tL(BigInt("0x"+t.toString(16))),h=tV(a+tD(c,s)),d=tD(l,h);if(0n===d){if(P.isBN(r))throw Error("Invalid fixed custom K value (s == 0)");continue}return i&&d>tX&&(d=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n-d),new tK(new P(c.toString(16),16),new P(d.toString(16),16))}},tY=(e,t,i)=>{let r=tz.n.bitLength();if(e.bitLength()>r)return!1;let n=t$(e);if(null==i.x||null==i.y)throw Error("Invalid public key: missing coordinates.");let a={x:t$(i.x),y:t$(i.y)},{r:s,s:o}={r:t$(t.r),s:t$(t.s)};if(s<=0n||s>=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n||o<=0n||o>=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n)return!1;let c=tL(o);if(0n===c)return!1;let l=tD(n,c),h=tD(s,c),d=tC(tU(l,{x:tO,y:tT}),tU(h,a));if(0n===d.Z)return!1;let u=tA(d.Z),f=tP(u,u);return tV(tP(d.X,f))===s};class tJ extends tF{static fromPrivateKey(e){let t=new tH().g.mul(e);return new tJ(t.x,t.y)}static fromString(e){let t=tF.fromString(e);return new tJ(t.x,t.y)}static fromDER(e){let t=tF.fromDER(e);return new tJ(t.x,t.y)}constructor(e,t=null,i=!0){if(e instanceof tF)super(e.getX(),e.getY());else{if(null===t&&i&&"string"==typeof e&&(66===e.length||130===e.length))throw Error('You are using the "new PublicKey()" constructor with a DER hex string. You need to use "PublicKey.fromString()" instead.');super(e,t,i)}}deriveSharedSecret(e){if(!this.validate())throw Error("Public key not valid for ECDH secret derivation");return this.mulCT(e)}verify(e,t,i){return tY(new P(ea(e,i),16),t,this)}toDER(e){return"hex"===e?this.encode(!0,e):this.encode(!0)}toHash(e){let t=ec(this.encode(!0));return"hex"===e?te(t):t}toAddress(e=[0]){if("string"==typeof e)if("testnet"===e||"test"===e)e=[111];else if("mainnet"===e||"main"===e)e=[0];else throw Error(`Invalid prefix ${e}`);return tu(this.toHash(),e)}deriveChild(e,t,i,r){let n;if("function"==typeof r){let t=r(e,this);void 0!==t?n=t:(n=this.deriveSharedSecret(e),"function"==typeof i&&i(e,this,n))}else n=this.deriveSharedSecret(e);let a=ti(t,"utf8"),s=el(n.encode(!0),a),o=new tH().g.mul(new P(s)),c=this.add(o);return new tJ(c.x,c.y)}static fromMsgHashAndCompactSignature(e,t,i){let r=ti(t,i);if(65!==r.length)throw Error("Invalid Compact Signature");let n=r[0];if(n<27||n>=35)throw Error("Invalid Compact Byte");let a=r[0]-27;return a>3&&(a-=4),new tK(new P(r.slice(1,33)),new P(r.slice(33,65))).RecoverPublicKey(a,e)}}class tZ{_rand;getRandomValues(e,t){let i=new Uint8Array(t);return e.crypto.getRandomValues(i),Array.from(i)}constructor(){const e=()=>{throw Error("No secure random number generator is available in this environment.")};if(this._rand=e,"u">typeof globalThis&&"function"==typeof globalThis.crypto?.getRandomValues){this._rand=e=>this.getRandomValues(globalThis,e);return}if("u">typeof process&&process.release?.name==="node")try{const e=require("crypto");if("function"==typeof e.randomBytes){this._rand=t=>Array.from(e.randomBytes(t));return}}catch(e){}if("u">typeof self&&"function"==typeof self.crypto?.getRandomValues){this._rand=e=>this.getRandomValues(self,e);return}if("u">typeof window&&"function"==typeof window.crypto?.getRandomValues){this._rand=e=>this.getRandomValues(window,e);return}this._rand=e}generate(e){return this._rand(e)}}let tQ=null,t0=e=>(null==tQ&&(tQ=new tZ),tQ.generate(e));class t1{x;y;constructor(e,t){const i=new tH().p;this.x=e.umod(i),this.y=t.umod(i)}toString(){return td(this.x.toArray())+"."+td(this.y.toArray())}static fromString(e){let[t,i]=e.split(".");return new t1(new P(th(t)),new P(th(i)))}}class t2{points;threshold;constructor(e,t){this.points=e,this.threshold=t??e.length}static fromPrivateKey(e,t){let i=new tH().p,r=[new t1(new P(0),new P(e.toArray()))];for(let e=1;e<t;e++){let e=new P(t0(32)).umod(i),t=new P(t0(32)).umod(i);r.push(new t1(e,t))}return new t2(r)}valueAt(e){let t=new tH().p,i=new P(0);for(let r=0;r<this.threshold;r++){let n=this.points[r].y;for(let i=0;i<this.threshold;i++)if(r!==i){let a=this.points[i].x,s=this.points[r].x,o=e.sub(a).umod(t),c=s.sub(a).umod(t).invm(t),l=o.mul(c).umod(t);n=n.mul(l).umod(t)}i=i.add(n).umod(t)}return i}}class t8{points;threshold;integrity;constructor(e,t,i){this.points=e,this.threshold=t,this.integrity=i}static fromBackupFormat(e){let t=0,i="";return new t8(e.map((e,r)=>{let n=e.split(".");if(4!==n.length)throw Error("Invalid share format in share "+r.toString()+'. Expected format: "x.y.t.i" - received '+e);let[a,s,o,c]=n;if(void 0===o)throw Error("Threshold not found in share "+r.toString());if(void 0===c)throw Error("Integrity not found in share "+r.toString());let l=parseInt(o);if(0!==r&&t!==l)throw Error("Threshold mismatch in share "+r.toString());if(0!==r&&i!==c)throw Error("Integrity mismatch in share "+r.toString());return t=l,i=c,t1.fromString([a,s].join("."))}),t,i)}toBackupFormat(){return this.points.map(e=>e.toString()+"."+this.threshold.toString()+"."+this.integrity)}}class t3 extends P{static fromRandom(){return new t3(t0(32))}static fromString(e,t="hex"){return new t3(super.fromString(e,t).toArray())}static fromHex(e){return new t3(super.fromHex(e,"big"))}static fromWif(e,t=1){let i=tf(e,void 0,t);if(33!==i.data.length)throw Error("Invalid WIF length");if(1!==i.data[32])throw Error("Invalid WIF padding");return new t3(i.data.slice(0,32))}constructor(e=0,t=10,i="be",r="apply"){if(e instanceof P?(super(),e.copy(this)):super(e,t,i),"nocheck"!==r){const e=this.checkInField();if(!e.inField){if("error"===r)throw Error("Input is out of field");P.move(this,e.modN)}}}checkInField(){let e=new tH,t=this.mod(e.n);return{inField:0===this.cmp(t),modN:t}}isValid(){return this.checkInField().inField}sign(e,t,i=!0,r){return tG(new P(ea(e,t),16),this,i,r)}verify(e,t,i){return tY(new P(ea(e,i),16),t,this.toPublicKey())}toPublicKey(){let e=new tH().g.mulCT(this);return new tJ(e.x,e.y)}toWif(e=[128]){if(!this.isValid())throw Error("Value is out of field");return tu([...this.toArray("be",32),1],e)}toAddress(e=[0]){return this.toPublicKey().toAddress(e)}toHex(){return super.toHex(32)}toString(e="hex",t=64){return super.toString(e,t)}deriveSharedSecret(e){if(!e.validate())throw Error("Public key not valid for ECDH secret derivation");return e.mulCT(this)}deriveChild(e,t,i,r){let n;if("function"==typeof r){let t=r(this,e);void 0!==t?n=t:(n=this.deriveSharedSecret(e),"function"==typeof i&&i(this,e,n))}else n=this.deriveSharedSecret(e);let a=ti(t,"utf8"),s=el(n.encode(!0),a),o=new tH;return new t3(this.add(new P(s)).mod(o.n).toArray())}toKeyShares(e,t){if("number"!=typeof e||"number"!=typeof t)throw Error("threshold and totalShares must be numbers");if(e<2)throw Error("threshold must be at least 2");if(t<2)throw Error("totalShares must be at least 2");if(e>t)throw Error("threshold should be less than or equal to totalShares");let i=t2.fromPrivateKey(this,e),r=[],n=new Set,a=new tH,s=t0(64);for(let e=0;e<t;e++){let t,o=0;do if(t=new P(eh(s,[e,o,...t0(32)])).umod(a.p),++o>5)throw Error("Failed to generate unique x coordinate after 5 attempts");while(t.isZero()||n.has(t.toString()));n.add(t.toString());let c=i.valueAt(t);r.push(new t1(t,c))}return new t8(r,e,this.toPublicKey().toHash("hex").slice(0,8))}toBackupShares(e,t){return this.toKeyShares(e,t).toBackupFormat()}static fromBackupShares(e){return t3.fromKeyShares(t8.fromBackupFormat(e))}static fromKeyShares(e){let{points:t,threshold:i,integrity:r}=e;if(i<2)throw Error("threshold must be at least 2");if(t.length<i)throw Error(`At least ${i} shares are required to reconstruct the private key`);for(let e=0;e<i;e++)for(let r=e+1;r<i;r++)if(t[e].x.eq(t[r].x))throw Error("Duplicate share detected, each must be unique.");let n=new t3(new t2(t,i).valueAt(new P(0)).toArray());if(n.toPublicKey().toHash("hex").slice(0,8)!==r)throw Error("Integrity hash mismatch");return n}}let t6=new Uint8Array([99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22]),t4=[[0,0,0,0],[1,0,0,0],[2,0,0,0],[4,0,0,0],[8,0,0,0],[16,0,0,0],[32,0,0,0],[64,0,0,0],[128,0,0,0],[27,0,0,0],[54,0,0,0]].map(e=>new Uint8Array(e)),t5=new Uint8Array(256),t7=new Uint8Array(256);for(let e=0;e<256;e++){let t=(e<<1^27*((128&e)!=0))&255;t5[e]=t,t7[e]=t^e}function t9(e,t,i){for(let r=0;r<4;r++){let n=t[i+r];for(let t=0;t<4;t++)e[t][r]^=n[t]}}function ie(e){for(let t=0;t<4;t++)e[t]=t6[e[t]]}function it(e,t){let i,r,n,a,s=[[],[],[],[]],o=[],c=Array.from(t);if(16===c.length)a=11;else if(24===c.length)a=13;else if(32===c.length)a=15;else throw Error("Illegal key length: "+String(c.length));let l=function(e,t){let i=t.length/4,r=[];for(let e=0;e<t.length;e++)e%4==0&&r.push([]),r[e>>2].push(t[e]);for(let t=i;t<4*e;t++){r[t]=[];let e=r[t-1].slice();if(t%i==0){!function(e){let t=e[0];e[0]=e[1],e[1]=e[2],e[2]=e[3],e[3]=t}(e),ie(e);let r=t4[t/i];for(let t=0;t<4;t++)e[t]^=r[t]}else i>6&&t%i==4&&ie(e);for(let n=0;n<4;n++)r[t][n]=r[t-i][n]^e[n]}return r}(a,c);for(let t=0;t<4;t++)s[0][t]=e[4*t],s[1][t]=e[4*t+1],s[2][t]=e[4*t+2],s[3][t]=e[4*t+3];for(t9(s,l,0),n=1;n<a;n++){for(let e=0;e<4;e++)for(let t=0;t<4;t++)s[e][t]=t6[s[e][t]];!function(e){let t=e[1][0];e[1][0]=e[1][1],e[1][1]=e[1][2],e[1][2]=e[1][3],e[1][3]=t,t=e[2][0];let i=e[2][1];e[2][0]=e[2][2],e[2][1]=e[2][3],e[2][2]=t,e[2][3]=i,t=e[3][3],e[3][3]=e[3][2],e[3][2]=e[3][1],e[3][1]=e[3][0],e[3][0]=t}(s),n+1<a&&function(e){for(let t=0;t<4;t++){let i=e[0][t],r=e[1][t],n=e[2][t],a=e[3][t];e[0][t]=t5[i]^t7[r]^n^a,e[1][t]=i^t5[r]^t7[n]^a,e[2][t]=i^r^t5[n]^t7[a],e[3][t]=t7[i]^r^n^t5[a]}}(s),t9(s,l,4*n)}for(i=0;i<4;i++)for(r=0;r<4;r++)o.push(s[r][i]);return o}let ii=function(e){if(e<0||e>Number.MAX_SAFE_INTEGER)throw Error("getBytes64: value out of range");let t=Math.floor(e/0x100000000),i=e>>>0;return[t>>>24&255,t>>>16&255,t>>>8&255,255&t,i>>>24&255,i>>>16&255,i>>>8&255,255&i]},ir=function(e){return new Uint8Array(e)},ia=((n=new Uint8Array(16))[0]=225,n),is=(...e)=>{let t=0;for(let i of e)t+=i.length;let i=new Uint8Array(t),r=0;for(let t of e)i.set(t,r),r+=t.length;return i},io=function(e){let t=0,i=0;for(let r=0;r<e.length;r++)i=t,t=1&e[r],e[r]=e[r]>>1,0!==i&&(e[r]=128|e[r]);return e},ic=function(e,t){let i=t.slice(),r=ir(16);for(let t=0;t<16;t++){let n=e[t];for(let e=7;e>=0;e--){let t=255&-(n>>e&1);for(let e=0;e<16;e++)r[e]^=i[e]&t;let a=255&-(1&i[15]);io(i);for(let e=0;e<16;e++)i[e]^=ia[e]&a}}return r},il=function(e){let t=e.slice();for(let e=15;e>11&&(t[e]=t[e]+1&255,0===t[e]);e--);return t};function ih(e,t){let i=ir(16),r=new Uint8Array(16);for(let n=0;n<e.length;n+=16){r.set(i);for(let t=0;t<16;t++)r[t]^=e[n+t]??0;i=ic(r,t)}return i}function id(e,t,i){if(0===e.length)return new Uint8Array(0);let r=new Uint8Array(e.length),n=t.slice(),a=0,s=Math.ceil(e.length/16);for(let t=0;t<s;t++){let o=it(n,i),c=Math.min(16,e.length-a);for(let t=0;t<c;t++)r[a]=e[a]^o[t],a++;t+1<s&&(n=il(n))}return r}function iu(e){let t,i,r=8*e.length;t=0===e.length?16:e.length%16==0?0:16-e.length%16;let n=new Uint8Array(16+e.length+t+16);i=16,n.set(e,i),i+=e.length,i+=t;let a=ii(0);n.set(a,i),i+=8;let s=ii(r);return n.set(s,i),n}class ip extends P{static fromRandom(){return new ip(t0(32))}encrypt(e,t){let i=new Uint8Array(t0(32)),{result:r,authenticationTag:n}=function(e,t,i){let r;if(0===t.length)throw Error("Initialization vector must not be empty");if(0===i.length)throw Error("Key must not be empty");let n=new Uint8Array(it(ir(16),i));if(12===t.length)r=is(t,ir(3),new Uint8Array([1]));else{let e=t;e.length%16!=0&&(e=is(e,ir(16-e.length%16)));let i=ii(8*t.length);r=ih(is(e,ir(8),new Uint8Array(i)),n)}let a=id(e,il(r),i),s=id(ih(iu(a),n),r,i);return{result:a,authenticationTag:s}}(new Uint8Array(ti(e,t)),i,new Uint8Array(this.toArray("be",32))),a=new Uint8Array(i.length+r.length+n.length),s=0;return a.set(i,s),s+=i.length,a.set(r,s),s+=r.length,a.set(n,s),to(Array.from(a),t)}decrypt(e,t){let i=new Uint8Array(ti(e,t));if(i.length<48)throw Error("Ciphertext too short");let r=i.slice(0,32),n=i.length-16,a=function(e,t,i,r){let n;if(0===e.length)throw Error("Cipher text must not be empty");if(0===t.length)throw Error("Initialization vector must not be empty");if(0===r.length)throw Error("Key must not be empty");let a=new Uint8Array(it(ir(16),r));if(12===t.length)n=is(t,ir(3),new Uint8Array([1]));else{let e=t;e.length%16!=0&&(e=is(e,ir(16-e.length%16)));let i=ii(8*t.length);n=ih(is(e,ir(8),new Uint8Array(i)),a)}let s=id(e,il(n),r),o=id(ih(iu(e),a),n,r);if(o.length!==i.length)return null;let c=0;for(let e=0;e<o.length;e++)c|=o[e]^i[e];return 0!==c?null:s}(i.slice(32,n),r,i.slice(n),new Uint8Array(this.toArray("be",32)));if(null===a)throw Error("Decryption failed!");return to(Array.from(a),t)}}let ig={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SPLIT:127,OP_NUM2BIN:128,OP_BIN2NUM:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_NOP3:178,OP_NOP4:179,OP_SUBSTR:179,OP_NOP5:180,OP_LEFT:180,OP_NOP6:181,OP_RIGHT:181,OP_NOP7:182,OP_LSHIFTNUM:182,OP_NOP8:183,OP_RSHIFTNUM:183,OP_NOP9:184,OP_NOP10:185,OP_NOP11:186,OP_NOP12:187,OP_NOP13:188,OP_NOP14:189,OP_NOP15:190,OP_NOP16:191,OP_NOP17:192,OP_NOP18:193,OP_NOP19:194,OP_NOP20:195,OP_NOP21:196,OP_NOP22:197,OP_NOP23:198,OP_NOP24:199,OP_NOP25:200,OP_NOP26:201,OP_NOP27:202,OP_NOP28:203,OP_NOP29:204,OP_NOP30:205,OP_NOP31:206,OP_NOP32:207,OP_NOP33:208,OP_NOP34:209,OP_NOP35:210,OP_NOP36:211,OP_NOP37:212,OP_NOP38:213,OP_NOP39:214,OP_NOP40:215,OP_NOP41:216,OP_NOP42:217,OP_NOP43:218,OP_NOP44:219,OP_NOP45:220,OP_NOP46:221,OP_NOP47:222,OP_NOP48:223,OP_NOP49:224,OP_NOP50:225,OP_NOP51:226,OP_NOP52:227,OP_NOP53:228,OP_NOP54:229,OP_NOP55:230,OP_NOP56:231,OP_NOP57:232,OP_NOP58:233,OP_NOP59:234,OP_NOP60:235,OP_NOP61:236,OP_NOP62:237,OP_NOP63:238,OP_NOP64:239,OP_NOP65:240,OP_NOP66:241,OP_NOP67:242,OP_NOP68:243,OP_NOP69:244,OP_NOP70:245,OP_NOP71:246,OP_NOP72:247,OP_NOP73:248,OP_NOP77:252,OP_SMALLDATA:249,OP_SMALLINTEGER:250,OP_PUBKEYS:251,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};for(let e in ig)ig[ig[e]]=e;let im=ig,iy="u">typeof globalThis?globalThis.Buffer:void 0;class ib{_chunks;parsed;rawBytesCache;hexCache;static fromASM(e){let t=[],i=e.split(" "),r=0;for(;r<i.length;){let e,n=i[r],a=0;if(n.startsWith("OP_")&&void 0!==im[n]&&(e=n,a=im[n]),"0"===n)a=0,t.push({op:a}),r+=1;else if("-1"===n)a=im.OP_1NEGATE,t.push({op:a}),r+=1;else if(void 0===e){let e=i[r];e.length%2!=0&&(e="0"+e);let n=ti(e,"hex");if(to(n,"hex")!==e)throw Error("invalid hex string in script");let s=n.length;s>=0&&s<im.OP_PUSHDATA1?a=s:s<256?a=im.OP_PUSHDATA1:s<65536?a=im.OP_PUSHDATA2:s<0x100000000&&(a=im.OP_PUSHDATA4),t.push({data:n,op:a}),r+=1}else a===im.OP_PUSHDATA1||a===im.OP_PUSHDATA2||a===im.OP_PUSHDATA4?(t.push({data:ti(i[r+2],"hex"),op:a}),r+=3):(t.push({op:a}),r+=1)}return new ib(t)}static fromHex(e){if(0===e.length)return ib.fromBinary([]);if(e.length%2!=0)throw Error("There is an uneven number of characters in the string which suggests it is not hex encoded.");if(!/^[0-9a-fA-F]+$/.test(e))throw Error("Some elements in this string are not hex encoded.");let t=ti(e,"hex");return new ib([],Uint8Array.from(t),e.toLowerCase(),!1)}static fromBinary(e){return new ib([],Uint8Array.from(e),void 0,!1)}constructor(e=[],t,i,r=!0){this._chunks=e,this.parsed=r,this.rawBytesCache=t,this.hexCache=i}get chunks(){return this.ensureParsed(),this._chunks}set chunks(e){this._chunks=e,this.parsed=!0,this.invalidateSerializationCaches()}ensureParsed(){this.parsed||(null!=this.rawBytesCache?this._chunks=ib.parseChunks(this.rawBytesCache):this._chunks=[],this.parsed=!0)}toASM(){let e="";for(let t=0;t<this.chunks.length;t++){let i=this.chunks[t];e+=this._chunkToString(i)}return e.slice(1)}toHex(){if(null!=this.hexCache)return this.hexCache;null==this.rawBytesCache&&(this.rawBytesCache=this.serializeChunksToBytes());let e=null!=iy?iy.from(this.rawBytesCache).toString("hex"):to(Array.from(this.rawBytesCache),"hex");return this.hexCache=e,e}toBinary(){return Array.from(this.toUint8Array())}toUint8Array(){return null==this.rawBytesCache&&(this.rawBytesCache=this.serializeChunksToBytes()),this.rawBytesCache}writeScript(e){return this.invalidateSerializationCaches(),this.chunks=this.chunks.concat(e.chunks),this}writeOpCode(e){return this.invalidateSerializationCaches(),this.chunks.push({op:e}),this}setChunkOpCode(e,t){return this.invalidateSerializationCaches(),this.chunks[e]={op:t},this}writeBn(e){if(this.invalidateSerializationCaches(),e.cmpn(0)===im.OP_0)this.chunks.push({op:im.OP_0});else if(0===e.cmpn(-1))this.chunks.push({op:im.OP_1NEGATE});else if(e.cmpn(1)>=0&&0>=e.cmpn(16))this.chunks.push({op:e.toNumber()+im.OP_1-1});else{let t=e.toSm("little");this.writeBin(t)}return this}writeBin(e){let t;this.invalidateSerializationCaches();let i=e.length>0?e:void 0;if(e.length>0&&e.length<im.OP_PUSHDATA1)t=e.length;else if(0===e.length)t=im.OP_0;else if(e.length<256)t=im.OP_PUSHDATA1;else if(e.length<65536)t=im.OP_PUSHDATA2;else if(e.length<0x100000000)t=im.OP_PUSHDATA4;else throw Error("You can't push that much data");return this.chunks.push({data:i,op:t}),this}writeNumber(e){return this.invalidateSerializationCaches(),this.writeBn(new P(e)),this}removeCodeseparators(){this.invalidateSerializationCaches();let e=[];for(let t=0;t<this.chunks.length;t++)this.chunks[t].op!==im.OP_CODESEPARATOR&&e.push(this.chunks[t]);return this.chunks=e,this}findAndDelete(e){this.invalidateSerializationCaches();let t=e.toUint8Array(),i=t.length;if(0===i)return this;let r=t[0]??0,n=e=>{if(e.op!==r)return!1;let n=e.data??[],a=n.length;if(0===a)return 1===i;if(e.op===im.OP_RETURN||e.op<im.OP_PUSHDATA1){if(i!==1+a)return!1;for(let e=0;e<a;e++)if(t[1+e]!==n[e])return!1;return!0}if(e.op===im.OP_PUSHDATA1){if(i!==2+a||t[1]!==(255&a))return!1;for(let e=0;e<a;e++)if(t[2+e]!==n[e])return!1;return!0}if(e.op===im.OP_PUSHDATA2){if(i!==3+a||t[1]!==(255&a)||t[2]!==(a>>8&255))return!1;for(let e=0;e<a;e++)if(t[3+e]!==n[e])return!1;return!0}if(e.op===im.OP_PUSHDATA4){if(i!==5+a)return!1;let e=a>>>0;if(t[1]!==(255&e)||t[2]!==(e>>8&255)||t[3]!==(e>>16&255)||t[4]!==(e>>24&255))return!1;for(let e=0;e<a;e++)if(t[5+e]!==n[e])return!1;return!0}return!1};for(let e=0;e<this.chunks.length;)n(this.chunks[e])?this.chunks.splice(e,1):e++;return this}isPushOnly(){for(let e=0;e<this.chunks.length;e++)if(this.chunks[e].op>im.OP_16)return!1;return!0}isLockingScript(){throw Error("Not implemented")}isUnlockingScript(){throw Error("Not implemented")}static computeSerializedLength(e){let t=0;for(let i of e){if(t+=1,null==i.data)continue;let e=i.data.length;if(i.op===im.OP_RETURN){t+=e;break}i.op<im.OP_PUSHDATA1?t+=e:i.op===im.OP_PUSHDATA1?t+=1+e:i.op===im.OP_PUSHDATA2?t+=2+e:i.op===im.OP_PUSHDATA4&&(t+=4+e)}return t}serializeChunksToBytes(){let e=this.chunks,t=new Uint8Array(ib.computeSerializedLength(e)),i=0;for(let r=0;r<e.length;r++){let n=e[r];if(t[i++]=n.op,null!=n.data){if(n.op===im.OP_RETURN){t.set(n.data,i),i+=n.data.length;break}i=ib.writeChunkData(t,i,n.op,n.data)}}return t}invalidateSerializationCaches(){this.rawBytesCache=void 0,this.hexCache=void 0}static writeChunkData(e,t,i,r){let n=r.length;if(i<im.OP_PUSHDATA1)return e.set(r,t),t+n;if(i===im.OP_PUSHDATA1)return e[t++]=255&n,e.set(r,t),t+n;if(i===im.OP_PUSHDATA2)return e[t++]=255&n,e[t++]=n>>8&255,e.set(r,t),t+n;if(i===im.OP_PUSHDATA4){let i=n>>>0;return e[t++]=255&i,e[t++]=i>>8&255,e[t++]=i>>16&255,e[t++]=i>>24&255,e.set(r,t),t+n}return t}static parseChunks(e){let t=[],i=e.length,r=0,n=0;for(;r<i;){let a=e[r++]??0;if(a===im.OP_RETURN&&0===n){t.push({op:a,data:ib.copyRange(e,r,i)});break}if(a===im.OP_IF||a===im.OP_NOTIF||a===im.OP_VERIF||a===im.OP_VERNOTIF?n++:a===im.OP_ENDIF&&n--,a>0&&a<im.OP_PUSHDATA1){let n=Math.min(r+a,i);t.push({data:ib.copyRange(e,r,n),op:a}),r=n}else if(a===im.OP_PUSHDATA1){let n=r<i?e[r++]??0:0,s=Math.min(r+n,i);t.push({data:ib.copyRange(e,r,s),op:a}),r=s}else if(a===im.OP_PUSHDATA2){let n=(e[r]??0)|(e[r+1]??0)<<8,s=Math.min((r=Math.min(r+2,i))+n,i);t.push({data:ib.copyRange(e,r,s),op:a}),r=s}else if(a===im.OP_PUSHDATA4){let n=((e[r]??0)|(e[r+1]??0)<<8|(e[r+2]??0)<<16|(e[r+3]??0)<<24)>>>0,s=Math.min((r=Math.min(r+4,i))+n,i);t.push({data:ib.copyRange(e,r,s),op:a}),r=s}else t.push({op:a})}return t}static copyRange(e,t,i){let r=Math.max(i-t,0),n=Array(r);for(let i=0;i<r;i++)n[i]=e[t+i]??0;return n}_chunkToString(e){let t=e.op,i="";if(void 0===e.data){let e=im[t];i=`${i} ${e}`}else i=`${i} ${te(e.data)}`;return i}}let iw=new Uint8Array(0);class iv extends tK{static SIGHASH_ALL=1;static SIGHASH_NONE=2;static SIGHASH_SINGLE=3;static SIGHASH_CHRONICLE=32;static SIGHASH_FORKID=64;static SIGHASH_ANYONECANPAY=128;scope;static formatOTDA(e){let t=(e.scope&iv.SIGHASH_ANYONECANPAY)===iv.SIGHASH_ANYONECANPAY,i=(31&e.scope)===iv.SIGHASH_SINGLE,r=(31&e.scope)===iv.SIGHASH_NONE,n=(31&e.scope)===iv.SIGHASH_ALL||!i&&!r,a=new ib([...e.subscript.chunks]);a.findAndDelete(new ib().writeOpCode(im.OP_CODESEPARATOR));let s={sourceTXID:e.sourceTXID,sourceOutputIndex:e.sourceOutputIndex,sequence:e.inputSequence,script:a.toBinary()},o=new tp;function c(e){for(let t of(o.writeVarIntNum(e.length),e))o.writeReverse(ti(t.sourceTXID,"hex")),o.writeUInt32LE(t.sourceOutputIndex),o.writeVarIntNum(t.script.length),o.write(t.script),o.writeUInt32LE(t.sequence)}function l(e){for(let t of(o.writeVarIntNum(e.length),e))o.writeUInt64LE(t.satoshis),o.writeVarIntNum(t.script.length),o.write(t.script)}o.writeInt32LE(e.transactionVersion);let h=new ib().toBinary();if(t)t&&c([s]);else{let t=e.otherInputs.map(e=>({sourceTXID:e.sourceTXID??e.sourceTransaction?.id("hex")??"",sourceOutputIndex:e.sourceOutputIndex,sequence:i||r?0:e.sequence??0xffffffff,script:h}));t.splice(e.inputIndex,0,s),c(t)}if(n)l(e.outputs.map(e=>({satoshis:e.satoshis??0,script:e.lockingScript.toBinary()})));else if(i){let t=[];for(let i=0;i<e.inputIndex;i++)t.push({satoshis:-1,script:h});let i=e.outputs[e.inputIndex];void 0!==i&&t.push({satoshis:i.satoshis??0,script:i.lockingScript.toBinary()}),l(t)}else r&&l([]);return o.writeUInt32LE(e.lockTime),o.writeUInt32LE(e.scope>>>0),o.toUint8Array()}static formatBip143(e){let t=e.cache,i={sourceTXID:e.sourceTXID,sourceOutputIndex:e.sourceOutputIndex,sequence:e.inputSequence},r=[...e.otherInputs];function n(t){let i=new tp;if(void 0===t)for(let t of e.outputs){let e=t.satoshis??0;i.writeUInt64LE(e);let r=t.lockingScript?.toUint8Array()??iw;i.writeVarIntNum(r.length),i.write(r)}else{let r=e.outputs[t];if(void 0===r)throw Error(`Output at index ${t} does not exist`);let n=r.satoshis??0;i.writeUInt64LE(n);let a=r.lockingScript?.toUint8Array()??iw;i.writeVarIntNum(a.length),i.write(a)}return eo(i.toUint8Array())}r.splice(e.inputIndex,0,i);let a=Array(32).fill(0),s=Array(32).fill(0),o=Array(32).fill(0);if((e.scope&iv.SIGHASH_ANYONECANPAY)==0&&(t?.hashPrevouts!=null?a=t.hashPrevouts:(a=(()=>{let e=new tp;for(let t of r){if(void 0===t.sourceTXID){if(null==t.sourceTransaction)throw Error("Missing sourceTransaction for input");e.write(t.sourceTransaction.hash())}else e.writeReverse(ti(t.sourceTXID,"hex"));e.writeUInt32LE(t.sourceOutputIndex)}return eo(e.toUint8Array())})(),null!=t&&(t.hashPrevouts=a))),(e.scope&iv.SIGHASH_ANYONECANPAY)==0&&(31&e.scope)!==iv.SIGHASH_SINGLE&&(31&e.scope)!==iv.SIGHASH_NONE&&(t?.hashSequence!=null?s=t.hashSequence:(s=(()=>{let e=new tp;for(let t of r){let i=t.sequence??0xffffffff;e.writeUInt32LE(i)}return eo(e.toUint8Array())})(),null!=t&&(t.hashSequence=s))),(31&e.scope)!==iv.SIGHASH_SINGLE&&(31&e.scope)!==iv.SIGHASH_NONE)t?.hashOutputsAll!=null?o=t.hashOutputsAll:(o=n(),null!=t&&(t.hashOutputsAll=o));else if((31&e.scope)===iv.SIGHASH_SINGLE&&e.inputIndex<e.outputs.length){let i=e.inputIndex,r=t?.hashOutputsSingle?.get(i);null!=r?o=r:(o=n(i),null!=t&&(null==t.hashOutputsSingle&&(t.hashOutputsSingle=new Map),t.hashOutputsSingle.set(i,o)))}let c=new tp;c.writeInt32LE(e.transactionVersion),c.write(a),c.write(s),c.writeReverse(ti(e.sourceTXID,"hex")),c.writeUInt32LE(e.sourceOutputIndex);let l=e.subscript.toUint8Array();c.writeVarIntNum(l.length),c.write(l),c.writeUInt64LE(e.sourceSatoshis);let h=i.sequence;return c.writeUInt32LE(h),c.write(o),c.writeUInt32LE(e.lockTime),c.writeUInt32LE(e.scope>>>0),c.toUint8Array()}static format(e){return Array.from(this.formatBytes(e))}static formatBytes(e){let t=(e.scope&iv.SIGHASH_FORKID)!=0,i=!0!==e.ignoreChronicle&&(e.scope&iv.SIGHASH_CHRONICLE)!=0;return t&&!i?iv.formatBip143(e):!t||t&&i?iv.formatOTDA(e):new Uint8Array(0)}static fromChecksigFormat(e){if(0===e.length)return new iv(new P(1),new P(1),1);let t=e[e.length-1],i=e.slice(0,e.length-1),r=tK.fromDER(i);return new iv(r.r,r.s,t)}constructor(e,t,i){super(e,t),this.scope=i}hasLowS(){return!(this.s.ltn(1)||this.s.gt(new P("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))}toChecksigFormat(){return[...this.toDER(),this.scope]}}class iI{curve;constructor(){this.curve=new tH}generateProof(e,t,i,r){let n=t3.fromRandom(),a=n.toPublicKey(),s=i.mul(n),o=this.computeChallenge(t,i,r,s,a);return{R:a,SPrime:s,z:n.add(o.mul(e)).umod(this.curve.n)}}verifyProof(e,t,i,r){let{R:n,SPrime:a,z:s}=r,o=this.computeChallenge(e,t,i,a,n),c=this.curve.g.mul(s),l=n.add(e.mul(o));if(!c.eq(l))return!1;let h=t.mul(s),d=a.add(i.mul(o));return!!h.eq(d)}computeChallenge(e,t,i,r,n){return new P(ea([...e.encode(!0),...t.encode(!0),...i.encode(!0),...r.encode(!0),...n.encode(!0)])).umod(this.curve.n)}}let ik=/^[0-9a-fA-F]+$/,iS=BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),iE=BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),ix=iS-3n,iP=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),iA={x:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),y:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")},iN=iE>>1n;class iO{p=iS;n=iE;a=ix;b=iP;g=iA;mod(e,t=this.p){let i=e%t;return i>=0n?i:i+t}modInv(e,t){if(0n===e||t<=0n)throw Error("Invalid mod inverse input");let[i,r]=[this.mod(e,t),t],[n,a]=[1n,0n];for(;0n!==r;){let e=i/r;[i,r]=[r,i-e*r],[n,a]=[a,n-e*a]}if(1n!==i)throw Error("Inverse does not exist");return this.mod(n,t)}modPow(e,t,i){if(1n===i)return 0n;let r=1n,n=this.mod(e,i),a=t;for(;a>0n;)(1n&a)===1n&&(r=this.mod(r*n,i)),a>>=1n,n=this.mod(n*n,i);return r}isInfinity(e){return null===e}assertOnCurve(e){if(this.isInfinity(e))return;let{x:t,y:i}=e;if(this.mod(i*i)!==this.mod(this.mod(t*t*t+this.a*t)+this.b))throw Error("Point is not on secp256r1")}pointFromAffine(e,t){let i={x:this.mod(e),y:this.mod(t)};return this.assertOnCurve(i),i}pointFromHex(e){if(e.startsWith("04")){let t=BigInt("0x"+e.slice(2,66)),i=BigInt("0x"+e.slice(66));return this.pointFromAffine(t,i)}if(e.startsWith("02")||e.startsWith("03")){let t=BigInt("0x"+e.slice(2)),i=this.mod(this.mod(t*t*t+this.a*t)+this.b),r=this.modPow(i,this.p+1n>>2n,this.p),n=(1n&r)===1n===e.startsWith("03")?r:this.p-r;return this.pointFromAffine(t,n)}throw Error("Invalid point encoding")}pointToHex(e,t=!1){if(this.isInfinity(e))return"00";let i=this.to32BytesHex(e.x),r=this.to32BytesHex(e.y);return t?((1n&e.y)===0n?"02":"03")+i:"04"+i+r}addPoints(e,t){if(this.isInfinity(e))return t;if(this.isInfinity(t))return e;let{x:i,y:r}=e,{x:n,y:a}=t;if(i===n)return r===a?this.doublePoint(e):null;let s=this.mod((a-r)*this.modInv(n-i,this.p)),o=this.mod(s*s-i-n),c=this.mod(s*(i-o)-r);return{x:o,y:c}}doublePoint(e){if(this.isInfinity(e))return e;if(0n===e.y)return null;let t=this.mod((3n*e.x*e.x+this.a)*this.modInv(2n*e.y,this.p)),i=this.mod(t*t-2n*e.x),r=this.mod(t*(e.x-i)-e.y);return{x:i,y:r}}add(e,t){return this.addPoints(e,t)}multiply(e,t){if(0n===t||this.isInfinity(e))return null;let i=this.mod(t,this.n),r=null,n=e;for(;i>0n;)(1n&i)===1n&&(r=this.addPoints(r,n)),n=this.doublePoint(n),i>>=1n;return r}multiplyBase(e){return this.multiply(this.g,e)}isOnCurve(e){try{return this.assertOnCurve(e),!0}catch(e){return!1}}generatePrivateKeyHex(){return this.to32BytesHex(this.randomScalar())}randomScalar(){for(;;){let e=BigInt("0x"+te(t0(32)));if(e>0n&&e<this.n)return e}}normalizePrivateKey(e){let t=this.mod(e,this.n);if(0n===t)throw Error("Invalid private key");return t}toScalar(e){if("bigint"==typeof e)return this.normalizePrivateKey(e);let t=e.startsWith("0x")?e.slice(2):e;if(!ik.test(t)||0===t.length||t.length>64)throw Error("Private key must be a hex string <= 32 bytes");let i=BigInt("0x"+t.padStart(64,"0"));return this.normalizePrivateKey(i)}publicKeyFromPrivate(e){let t=this.toScalar(e);return this.multiplyBase(t)}sign(e,t,i={}){let{prehashed:r=!1,nonce:n}=i,a=this.toScalar(t),s=this.normalizeMessage(e,r),o=this.bytesToScalar(s),c=n??this.deterministicNonce(a,s);for(;;){let e=this.multiplyBase(c);if(this.isInfinity(e)){c=n??this.deterministicNonce(a,s);continue}let t=this.mod(e.x,this.n);if(0n===t){c=n??this.deterministicNonce(a,s);continue}let i=this.modInv(c,this.n),r=this.mod(i*(o+t*a),this.n);if(0n===r){c=n??this.deterministicNonce(a,s);continue}return r>iN&&(r=this.n-r),{r:this.to32BytesHex(t),s:this.to32BytesHex(r)}}}verify(e,t,i,r={}){let n,{prehashed:a=!1}=r;try{n="string"==typeof i?this.pointFromHex(i):i}catch{return!1}if(null==n||!this.isOnCurve(n))return!1;let s="bigint"==typeof t.r?t.r:BigInt("0x"+t.r),o="bigint"==typeof t.s?t.s:BigInt("0x"+t.s);if(s<=0n||s>=this.n||o<=0n||o>=this.n)return!1;let c=this.bytesToScalar(this.normalizeMessage(e,a)),l=this.modInv(o,this.n),h=this.mod(c*l,this.n),d=this.mod(s*l,this.n),u=this.addPoints(this.multiplyBase(h),this.multiply(n,d));return!this.isInfinity(u)&&this.mod(u.x,this.n)===s}normalizeMessage(e,t){let i=this.toBytes(e);return t?i:new Uint8Array(ea(i))}bytesToScalar(e){return BigInt("0x"+te(Array.from(e)))%this.n}deterministicNonce(e,t){let i=ti(this.to32BytesHex(e),"hex"),r=0;for(;r<1024;){let e=BigInt("0x"+te(el(i,0===r?Array.from(t):Array.from(t).concat([255&r]))))%this.n;if(e>0n)return e;r++}throw Error("Failed to derive deterministic nonce")}toBytes(e){if("string"==typeof e){let t=ik.test(e)&&e.length%2==0;return Uint8Array.from(ti(e,t?"hex":"utf8"))}if(e instanceof Uint8Array)return e;if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw Error("Unsupported message format")}to32BytesHex(e){return e.toString(16).padStart(64,"0")}}class iT extends ib{isLockingScript(){return!0}isUnlockingScript(){return!1}}class i_ extends ib{isLockingScript(){return!1}isUnlockingScript(){return!0}}class iR extends Error{txid;outputIndex;context;programCounter;stackState;altStackState;ifStackState;stackMem;altStackMem;constructor(e){const t=e.stackState.map(e=>null!=e&&void 0!==e.length?te(e):null==e?"null/undef":"INVALID_STACK_ITEM").join(", "),i=e.altStackState.map(e=>null!=e&&void 0!==e.length?te(e):null==e?"null/undef":"INVALID_STACK_ITEM").join(", "),r=`Context: ${e.context}, PC: ${e.programCounter}`,n=`Stack: [${t}] (len: ${e.stackState.length}, mem: ${e.stackMem})`,a=`AltStack: [${i}] (len: ${e.altStackState.length}, mem: ${e.altStackMem})`,s=`IfStack: [${e.ifStackState.join(", ")}]`;super(`Script evaluation error: ${e.message}
2
2
  TXID: ${e.txid}, OutputIdx: ${e.outputIndex}
3
3
  ${r}
4
4
  ${n}