UNPKG

@stacks/stacking

Version:
2 lines 140 kB
/*! For license information please see index.js.LICENSE.txt */ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.StacksStacking=e():t.StacksStacking=e()}(this,(()=>(()=>{var t,e,n={525:(t,e)=>{"use strict";function n(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function r(t){if("boolean"!=typeof t)throw new Error(`Expected boolean, not ${t}`)}function i(t,...e){if(!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new TypeError(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function o(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");n(t.outputLen),n(t.blockLen)}function s(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function a(t,e){i(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}Object.defineProperty(e,"__esModule",{value:!0}),e.output=e.exists=e.hash=e.bytes=e.bool=e.number=void 0,e.number=n,e.bool=r,e.bytes=i,e.hash=o,e.exists=s,e.output=a;const c={number:n,bool:r,bytes:i,hash:o,exists:s,output:a};e.default=c},350:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SHA2=void 0;const r=n(525),i=n(64);class o extends i.Hash{constructor(t,e,n,r){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,i.createView)(this.buffer)}update(t){r.default.exists(this);const{view:e,buffer:n,blockLen:o}=this,s=(t=(0,i.toBytes)(t)).length;for(let r=0;r<s;){const a=Math.min(o-this.pos,s-r);if(a!==o)n.set(t.subarray(r,r+a),this.pos),this.pos+=a,r+=a,this.pos===o&&(this.process(e,0),this.pos=0);else{const e=(0,i.createView)(t);for(;o<=s-r;r+=o)this.process(e,r)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){r.default.exists(this),r.default.output(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:o,isLE:s}=this;let{pos:a}=this;e[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>o-a&&(this.process(n,0),a=0);for(let t=a;t<o;t++)e[t]=0;!function(t,e,n,r){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),c=r?4:0,u=r?0:4;t.setUint32(e+c,s,r),t.setUint32(e+u,a,r)}(n,o-8,BigInt(8*this.length),s),this.process(n,0);const c=(0,i.createView)(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const h=u/4,d=this.get();if(h>d.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<h;t++)c.setUint32(4*t,d[t],s)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:n,length:r,finished:i,destroyed:o,pos:s}=this;return t.length=r,t.pos=s,t.finished=i,t.destroyed=o,r%e&&t.buffer.set(n),t}}e.SHA2=o},661:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.crypto=void 0,e.crypto={node:void 0,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0}},53:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.sha224=e.sha256=void 0;const r=n(350),i=n(64),o=(t,e,n)=>t&e^t&n^e&n,s=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),a=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),c=new Uint32Array(64);class u extends r.SHA2{constructor(){super(64,32,8,!1),this.A=0|a[0],this.B=0|a[1],this.C=0|a[2],this.D=0|a[3],this.E=0|a[4],this.F=0|a[5],this.G=0|a[6],this.H=0|a[7]}get(){const{A:t,B:e,C:n,D:r,E:i,F:o,G:s,H:a}=this;return[t,e,n,r,i,o,s,a]}set(t,e,n,r,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let n=0;n<16;n++,e+=4)c[n]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=c[t-15],n=c[t-2],r=(0,i.rotr)(e,7)^(0,i.rotr)(e,18)^e>>>3,o=(0,i.rotr)(n,17)^(0,i.rotr)(n,19)^n>>>10;c[t]=o+c[t-7]+r+c[t-16]|0}let{A:n,B:r,C:a,D:u,E:h,F:d,G:f,H:l}=this;for(let t=0;t<64;t++){const e=l+((0,i.rotr)(h,6)^(0,i.rotr)(h,11)^(0,i.rotr)(h,25))+((p=h)&d^~p&f)+s[t]+c[t]|0,g=((0,i.rotr)(n,2)^(0,i.rotr)(n,13)^(0,i.rotr)(n,22))+o(n,r,a)|0;l=f,f=d,d=h,h=u+e|0,u=a,a=r,r=n,n=e+g|0}var p;n=n+this.A|0,r=r+this.B|0,a=a+this.C|0,u=u+this.D|0,h=h+this.E|0,d=d+this.F|0,f=f+this.G|0,l=l+this.H|0,this.set(n,r,a,u,h,d,f,l)}roundClean(){c.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class h extends u{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}e.sha256=(0,i.wrapConstructor)((()=>new u)),e.sha224=(0,i.wrapConstructor)((()=>new h))},64:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.randomBytes=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.isLE=e.rotr=e.createView=e.u32=e.u8=void 0;const r=n(661);if(e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength),e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),e.rotr=(t,e)=>t<<32-e|t>>>e,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],!e.isLE)throw new Error("Non little-endian hardware is not supported");const i=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function o(t){if("string"!=typeof t)throw new TypeError("utf8ToBytes expected string, got "+typeof t);return(new TextEncoder).encode(t)}function s(t){if("string"==typeof t&&(t=o(t)),!(t instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof t})`);return t}e.bytesToHex=function(t){if(!(t instanceof Uint8Array))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=i[t[n]];return e},e.hexToBytes=function(t){if("string"!=typeof t)throw new TypeError("hexToBytes: expected string, got "+typeof t);if(t.length%2)throw new Error("hexToBytes: received invalid unpadded hex");const e=new Uint8Array(t.length/2);for(let n=0;n<e.length;n++){const r=2*n,i=t.slice(r,r+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");e[n]=o}return e},e.nextTick=async()=>{},e.asyncLoop=async function(t,n,r){let i=Date.now();for(let o=0;o<t;o++){r(o);const t=Date.now()-i;t>=0&&t<n||(await(0,e.nextTick)(),i+=t)}},e.utf8ToBytes=o,e.toBytes=s,e.concatBytes=function(...t){if(!t.every((t=>t instanceof Uint8Array)))throw new Error("Uint8Array list expected");if(1===t.length)return t[0];const e=t.reduce(((t,e)=>t+e.length),0),n=new Uint8Array(e);for(let e=0,r=0;e<t.length;e++){const i=t[e];n.set(i,r),r+=i.length}return n},e.Hash=class{clone(){return this._cloneInto()}},e.checkOpts=function(t,e){if(void 0!==e&&("object"!=typeof e||(n=e,"[object Object]"!==Object.prototype.toString.call(n)||n.constructor!==Object)))throw new TypeError("Options should be object or undefined");var n;return Object.assign(t,e)},e.wrapConstructor=function(t){const e=e=>t().update(s(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,n)=>t(n).update(s(e)).digest(),n=t({});return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(r.crypto.web)return r.crypto.web.getRandomValues(new Uint8Array(t));if(r.crypto.node)return new Uint8Array(r.crypto.node.randomBytes(t).buffer);throw new Error("The environment doesn't have randomBytes function")}},166:t=>{"use strict";t.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var r=0;r<t.length;r++){var i=t.charAt(r),o=i.charCodeAt(0);if(255!==e[o])throw new TypeError(i+" is ambiguous");e[o]=r}var s=t.length,a=t.charAt(0),c=Math.log(s)/Math.log(256),u=Math.log(256)/Math.log(s);function h(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return new Uint8Array;for(var n=0,r=0,i=0;t[n]===a;)r++,n++;for(var o=(t.length-n)*c+1>>>0,u=new Uint8Array(o);t[n];){var h=e[t.charCodeAt(n)];if(255===h)return;for(var d=0,f=o-1;(0!==h||d<i)&&-1!==f;f--,d++)h+=s*u[f]>>>0,u[f]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");i=d,n++}for(var l=o-i;l!==o&&0===u[l];)l++;for(var p=new Uint8Array(r+(o-l)),g=r;l!==o;)p[g++]=u[l++];return p}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";for(var n=0,r=0,i=0,o=e.length;i!==o&&0===e[i];)i++,n++;for(var c=(o-i)*u+1>>>0,h=new Uint8Array(c);i!==o;){for(var d=e[i],f=0,l=c-1;(0!==d||f<r)&&-1!==l;l--,f++)d+=256*h[l]>>>0,h[l]=d%s>>>0,d=d/s>>>0;if(0!==d)throw new Error("Non-zero carry");r=f,i++}for(var p=c-r;p!==c&&0===h[p];)p++;for(var g=a.repeat(n);p<c;++p)g+=t.charAt(h[p]);return g},decodeUnsafe:h,decode:function(t){var e=h(t);if(e)return e;throw new Error("Non-base"+s+" character")}}}},766:(t,e)=>{"use strict";for(var n=[],r=[],i=("undefined"!=typeof Uint8Array&&Uint8Array,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),o=0;o<64;++o)n[o]=i[o],r[i.charCodeAt(o)]=o;r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},22:(t,e,n)=>{const r=n(166);t.exports=r("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},98:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.c32ToB58=e.b58ToC32=e.c32addressDecode=e.c32address=e.versions=void 0;const r=n(392),i=n(716),o=n(64);e.versions={mainnet:{p2pkh:22,p2sh:20},testnet:{p2pkh:26,p2sh:21}};const s={};s[0]=e.versions.mainnet.p2pkh,s[5]=e.versions.mainnet.p2sh,s[111]=e.versions.testnet.p2pkh,s[196]=e.versions.testnet.p2sh;const a={};function c(t,e){if(!e.match(/^[0-9a-fA-F]{40}$/))throw new Error("Invalid argument: not a hash160 hex string");return`S${(0,r.c32checkEncode)(t,e)}`}function u(t){if(t.length<=5)throw new Error("Invalid c32 address: invalid length");if("S"!=t[0])throw new Error('Invalid c32 address: must start with "S"');return(0,r.c32checkDecode)(t.slice(1))}a[e.versions.mainnet.p2pkh]=0,a[e.versions.mainnet.p2sh]=5,a[e.versions.testnet.p2pkh]=111,a[e.versions.testnet.p2sh]=196,e.c32address=c,e.c32addressDecode=u,e.b58ToC32=function(t,e=-1){const n=i.decode(t),r=(0,o.bytesToHex)(n.data),a=parseInt((0,o.bytesToHex)(n.prefix),16);let u;return e<0?(u=a,void 0!==s[a]&&(u=s[a])):u=e,c(u,r)},e.c32ToB58=function(t,e=-1){const n=u(t),r=n[0],o=n[1];let s;e<0?(s=r,void 0!==a[r]&&(s=a[r])):s=e;let c=s.toString(16);return 1===c.length&&(c=`0${c}`),i.encode(o,c)}},716:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.decode=e.encode=void 0;const r=n(53),i=n(64),o=n(166),s="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";e.encode=function(t,e="00"){const n="string"==typeof t?(0,i.hexToBytes)(t):t,a="string"==typeof e?(0,i.hexToBytes)(e):t;if(!(n instanceof Uint8Array&&a instanceof Uint8Array))throw new TypeError("Argument must be of type Uint8Array or string");const c=(0,r.sha256)((0,r.sha256)(new Uint8Array([...a,...n])));return o(s).encode([...a,...n,...c.slice(0,4)])},e.decode=function(t){const e=o(s).decode(t),n=e.slice(0,1),i=e.slice(1,-4),a=(0,r.sha256)((0,r.sha256)(new Uint8Array([...n,...i])));return e.slice(-4).forEach(((t,e)=>{if(t!==a[e])throw new Error("Invalid checksum")})),{prefix:n,data:i}}},392:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.c32checkDecode=e.c32checkEncode=void 0;const r=n(53),i=n(64),o=n(103);function s(t){const e=(0,r.sha256)((0,r.sha256)((0,i.hexToBytes)(t)));return(0,i.bytesToHex)(e.slice(0,4))}e.c32checkEncode=function(t,e){if(t<0||t>=32)throw new Error("Invalid version (must be between 0 and 31)");if(!e.match(/^[0-9a-fA-F]*$/))throw new Error("Invalid data (not a hex string)");(e=e.toLowerCase()).length%2!=0&&(e=`0${e}`);let n=t.toString(16);1===n.length&&(n=`0${n}`);const r=s(`${n}${e}`),i=(0,o.c32encode)(`${e}${r}`);return`${o.c32[t]}${i}`},e.c32checkDecode=function(t){t=(0,o.c32normalize)(t);const e=(0,o.c32decode)(t.slice(1)),n=t[0],r=o.c32.indexOf(n),i=e.slice(-8);let a=r.toString(16);if(1===a.length&&(a=`0${a}`),s(`${a}${e.substring(0,e.length-8)}`)!==i)throw new Error("Invalid c32check string: checksum mismatch");return[r,e.substring(0,e.length-8)]}},103:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.c32decode=e.c32normalize=e.c32encode=e.c32=void 0;const r=n(64);e.c32="0123456789ABCDEFGHJKMNPQRSTVWXYZ";const i="0123456789abcdef";function o(t){return t.toUpperCase().replace(/O/g,"0").replace(/L|I/g,"1")}e.c32encode=function(t,n){if(!t.match(/^[0-9a-fA-F]*$/))throw new Error("Not a hex-encoded string");t.length%2!=0&&(t=`0${t}`);let o=[],s=0;for(let n=(t=t.toLowerCase()).length-1;n>=0;n--)if(s<4){const r=i.indexOf(t[n])>>s;let a=0;0!==n&&(a=i.indexOf(t[n-1]));const c=1+s,u=a%(1<<c)<<5-c,h=e.c32[r+u];s=c,o.unshift(h)}else s=0;let a=0;for(let t=0;t<o.length&&"0"===o[t];t++)a++;o=o.slice(a);const c=(new TextDecoder).decode((0,r.hexToBytes)(t)).match(/^\u0000*/),u=c?c[0].length:0;for(let t=0;t<u;t++)o.unshift(e.c32[0]);if(n){const t=n-o.length;for(let n=0;n<t;n++)o.unshift(e.c32[0])}return o.join("")},e.c32normalize=o,e.c32decode=function(t,n){if(!(t=o(t)).match(`^[${e.c32}]*$`))throw new Error("Not a c32-encoded string");const r=t.match(`^${e.c32[0]}*`),s=r?r[0].length:0;let a=[],c=0,u=0;for(let n=t.length-1;n>=0;n--){4===u&&(a.unshift(i[c]),u=0,c=0);const r=(e.c32.indexOf(t[n])<<u)+c,o=i[r%16];if(u+=1,c=r>>4,c>1<<u)throw new Error("Panic error in decoding.");a.unshift(o)}a.unshift(i[c]),a.length%2==1&&a.unshift("0");let h=0;for(let t=0;t<a.length&&"0"===a[t];t++)h++;a=a.slice(h-h%2);let d=a.join("");for(let t=0;t<s;t++)d=`00${d}`;if(n){const t=2*n-d.length;for(let e=0;e<t;e+=2)d=`00${d}`}return d}},870:(t,e,n)=>{"use strict";e.yI=e.H4=void 0;n(103),n(392);const r=n(98);Object.defineProperty(e,"H4",{enumerable:!0,get:function(){return r.c32address}}),Object.defineProperty(e,"yI",{enumerable:!0,get:function(){return r.c32addressDecode}})},907:(t,e,n)=>{t=n.nmd(t);var r="__lodash_hash_undefined__",i=9007199254740991,o="[object Arguments]",s="[object Boolean]",a="[object Date]",c="[object Function]",u="[object GeneratorFunction]",h="[object Map]",d="[object Number]",f="[object Object]",l="[object Promise]",p="[object RegExp]",g="[object Set]",y="[object String]",w="[object Symbol]",b="[object WeakMap]",A="[object ArrayBuffer]",m="[object DataView]",E="[object Float32Array]",S="[object Float64Array]",v="[object Int8Array]",x="[object Int16Array]",I="[object Int32Array]",C="[object Uint8Array]",_="[object Uint8ClampedArray]",T="[object Uint16Array]",P="[object Uint32Array]",k=/\w*$/,R=/^\[object .+?Constructor\]$/,O=/^(?:0|[1-9]\d*)$/,N={};N[o]=N["[object Array]"]=N[A]=N[m]=N[s]=N[a]=N[E]=N[S]=N[v]=N[x]=N[I]=N[h]=N[d]=N[f]=N[p]=N[g]=N[y]=N[w]=N[C]=N[_]=N[T]=N[P]=!0,N["[object Error]"]=N[c]=N[b]=!1;var B="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,U="object"==typeof self&&self&&self.Object===Object&&self,H=B||U||Function("return this")(),$=e&&!e.nodeType&&e,D=$&&t&&!t.nodeType&&t,L=D&&D.exports===$;function K(t,e){return t.set(e[0],e[1]),t}function M(t,e){return t.add(e),t}function j(t,e,n,r){var i=-1,o=t?t.length:0;for(r&&o&&(n=t[++i]);++i<o;)n=e(n,t[i],i,t);return n}function G(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}function F(t){var e=-1,n=Array(t.size);return t.forEach((function(t,r){n[++e]=[r,t]})),n}function W(t,e){return function(n){return t(e(n))}}function V(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t})),n}var q,z=Array.prototype,X=Function.prototype,Z=Object.prototype,J=H["__core-js_shared__"],Y=(q=/[^.]+$/.exec(J&&J.keys&&J.keys.IE_PROTO||""))?"Symbol(src)_1."+q:"",Q=X.toString,tt=Z.hasOwnProperty,et=Z.toString,nt=RegExp("^"+Q.call(tt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),rt=L?H.Buffer:void 0,it=H.Symbol,ot=H.Uint8Array,st=W(Object.getPrototypeOf,Object),at=Object.create,ct=Z.propertyIsEnumerable,ut=z.splice,ht=Object.getOwnPropertySymbols,dt=rt?rt.isBuffer:void 0,ft=W(Object.keys,Object),lt=Ht(H,"DataView"),pt=Ht(H,"Map"),gt=Ht(H,"Promise"),yt=Ht(H,"Set"),wt=Ht(H,"WeakMap"),bt=Ht(Object,"create"),At=Mt(lt),mt=Mt(pt),Et=Mt(gt),St=Mt(yt),vt=Mt(wt),xt=it?it.prototype:void 0,It=xt?xt.valueOf:void 0;function Ct(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function _t(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Tt(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Pt(t){this.__data__=new _t(t)}function kt(t,e,n){var r=t[e];tt.call(t,e)&&jt(r,n)&&(void 0!==n||e in t)||(t[e]=n)}function Rt(t,e){for(var n=t.length;n--;)if(jt(t[n][0],e))return n;return-1}function Ot(t,e,n,r,i,l,b){var R;if(r&&(R=l?r(t,i,l,b):r(t)),void 0!==R)return R;if(!qt(t))return t;var O=Gt(t);if(O){if(R=function(t){var e=t.length,n=t.constructor(e);return e&&"string"==typeof t[0]&&tt.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(t),!e)return function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e}(t,R)}else{var B=Dt(t),U=B==c||B==u;if(Wt(t))return function(t,e){if(e)return t.slice();var n=new t.constructor(t.length);return t.copy(n),n}(t,e);if(B==f||B==o||U&&!l){if(G(t))return l?t:{};if(R=function(t){return"function"!=typeof t.constructor||Kt(t)?{}:qt(e=st(t))?at(e):{};var e}(U?{}:t),!e)return function(t,e){return Bt(t,$t(t),e)}(t,function(t,e){return t&&Bt(e,zt(e),t)}(R,t))}else{if(!N[B])return l?t:{};R=function(t,e,n,r){var i,o=t.constructor;switch(e){case A:return Nt(t);case s:case a:return new o(+t);case m:return function(t,e){var n=e?Nt(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,r);case E:case S:case v:case x:case I:case C:case _:case T:case P:return function(t,e){var n=e?Nt(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}(t,r);case h:return function(t,e,n){return j(e?n(F(t),!0):F(t),K,new t.constructor)}(t,r,n);case d:case y:return new o(t);case p:return function(t){var e=new t.constructor(t.source,k.exec(t));return e.lastIndex=t.lastIndex,e}(t);case g:return function(t,e,n){return j(e?n(V(t),!0):V(t),M,new t.constructor)}(t,r,n);case w:return i=t,It?Object(It.call(i)):{}}}(t,B,Ot,e)}}b||(b=new Pt);var H=b.get(t);if(H)return H;if(b.set(t,R),!O)var $=n?function(t){return function(t,e,n){var r=e(t);return Gt(t)?r:function(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t}(r,n(t))}(t,zt,$t)}(t):zt(t);return function(t,e){for(var n=-1,r=t?t.length:0;++n<r&&!1!==e(t[n],n););}($||t,(function(i,o){$&&(i=t[o=i]),kt(R,o,Ot(i,e,n,r,o,t,b))})),R}function Nt(t){var e=new t.constructor(t.byteLength);return new ot(e).set(new ot(t)),e}function Bt(t,e,n,r){n||(n={});for(var i=-1,o=e.length;++i<o;){var s=e[i],a=r?r(n[s],t[s],s,n,t):void 0;kt(n,s,void 0===a?t[s]:a)}return n}function Ut(t,e){var n,r,i=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof e?"string":"hash"]:i.map}function Ht(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return function(t){return!(!qt(t)||(e=t,Y&&Y in e))&&(Vt(t)||G(t)?nt:R).test(Mt(t));var e}(n)?n:void 0}Ct.prototype.clear=function(){this.__data__=bt?bt(null):{}},Ct.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},Ct.prototype.get=function(t){var e=this.__data__;if(bt){var n=e[t];return n===r?void 0:n}return tt.call(e,t)?e[t]:void 0},Ct.prototype.has=function(t){var e=this.__data__;return bt?void 0!==e[t]:tt.call(e,t)},Ct.prototype.set=function(t,e){return this.__data__[t]=bt&&void 0===e?r:e,this},_t.prototype.clear=function(){this.__data__=[]},_t.prototype.delete=function(t){var e=this.__data__,n=Rt(e,t);return!(n<0||(n==e.length-1?e.pop():ut.call(e,n,1),0))},_t.prototype.get=function(t){var e=this.__data__,n=Rt(e,t);return n<0?void 0:e[n][1]},_t.prototype.has=function(t){return Rt(this.__data__,t)>-1},_t.prototype.set=function(t,e){var n=this.__data__,r=Rt(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},Tt.prototype.clear=function(){this.__data__={hash:new Ct,map:new(pt||_t),string:new Ct}},Tt.prototype.delete=function(t){return Ut(this,t).delete(t)},Tt.prototype.get=function(t){return Ut(this,t).get(t)},Tt.prototype.has=function(t){return Ut(this,t).has(t)},Tt.prototype.set=function(t,e){return Ut(this,t).set(t,e),this},Pt.prototype.clear=function(){this.__data__=new _t},Pt.prototype.delete=function(t){return this.__data__.delete(t)},Pt.prototype.get=function(t){return this.__data__.get(t)},Pt.prototype.has=function(t){return this.__data__.has(t)},Pt.prototype.set=function(t,e){var n=this.__data__;if(n instanceof _t){var r=n.__data__;if(!pt||r.length<199)return r.push([t,e]),this;n=this.__data__=new Tt(r)}return n.set(t,e),this};var $t=ht?W(ht,Object):function(){return[]},Dt=function(t){return et.call(t)};function Lt(t,e){return!!(e=null==e?i:e)&&("number"==typeof t||O.test(t))&&t>-1&&t%1==0&&t<e}function Kt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Z)}function Mt(t){if(null!=t){try{return Q.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function jt(t,e){return t===e||t!=t&&e!=e}(lt&&Dt(new lt(new ArrayBuffer(1)))!=m||pt&&Dt(new pt)!=h||gt&&Dt(gt.resolve())!=l||yt&&Dt(new yt)!=g||wt&&Dt(new wt)!=b)&&(Dt=function(t){var e=et.call(t),n=e==f?t.constructor:void 0,r=n?Mt(n):void 0;if(r)switch(r){case At:return m;case mt:return h;case Et:return l;case St:return g;case vt:return b}return e});var Gt=Array.isArray;function Ft(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=i}(t.length)&&!Vt(t)}var Wt=dt||function(){return!1};function Vt(t){var e=qt(t)?et.call(t):"";return e==c||e==u}function qt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function zt(t){return Ft(t)?function(t,e){var n=Gt(t)||function(t){return function(t){return function(t){return!!t&&"object"==typeof t}(t)&&Ft(t)}(t)&&tt.call(t,"callee")&&(!ct.call(t,"callee")||et.call(t)==o)}(t)?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],r=n.length,i=!!r;for(var s in t)!e&&!tt.call(t,s)||i&&("length"==s||Lt(s,r))||n.push(s);return n}(t):function(t){if(!Kt(t))return ft(t);var e=[];for(var n in Object(t))tt.call(t,n)&&"constructor"!=n&&e.push(n);return e}(t)}t.exports=function(t){return Ot(t,!0,!0)}},314:()=>{}},r={};function i(t){var e=r[t];if(void 0!==e)return e.exports;var o=r[t]={id:t,loaded:!1,exports:{}};return n[t](o,o.exports,i),o.loaded=!0,o.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},e=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__,i.t=function(n,r){if(1&r&&(n=this(n)),8&r)return n;if("object"==typeof n&&n){if(4&r&&n.__esModule)return n;if(16&r&&"function"==typeof n.then)return n}var o=Object.create(null);i.r(o);var s={};t=t||[null,e({}),e([]),e(e)];for(var a=2&r&&n;"object"==typeof a&&!~t.indexOf(a);a=e(a))Object.getOwnPropertyNames(a).forEach((t=>s[t]=()=>n[t]));return s.default=()=>n,i.d(o,s),o},i.d=(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.nmd=t=>(t.paths=[],t.children||(t.children=[]),t);var o={};return(()=>{"use strict";function t(t,n){return c(e(t),n)}function e(t){if("bigint"==typeof t)return t;if("string"==typeof t)return BigInt(t);if("number"==typeof t){if(!Number.isInteger(t))throw new RangeError("Invalid value. Values of type 'number' must be an integer.");if(t>Number.MAX_SAFE_INTEGER)throw new RangeError(`Invalid value. Values of type 'number' must be less than or equal to ${Number.MAX_SAFE_INTEGER}. For larger values, try using a BigInt instead.`);return BigInt(t)}if(E(t,Uint8Array))return BigInt(`0x${d(t)}`);throw new TypeError("intToBigInt: Invalid value type. Must be a number, bigint, BigInt-compatible string, or Uint8Array.")}function n(t){return/^0x/i.test(t)?t.slice(2):t}function r(t){if("string"!=typeof t)throw new TypeError("hexToBigInt: expected string, got "+typeof t);return BigInt(`0x${t}`)}function s(t,n=8){return("bigint"==typeof t?t:e(t)).toString(16).padStart(2*n,"0")}function a(t){return parseInt(t,16)}function c(t,e=16){return f(s(t,e))}function u(t){return e=BigInt(`0x${d(t)}`),n=BigInt(8*t.byteLength),function(t,e){return t&BigInt(1)<<e}(e,n-BigInt(1))?e-(BigInt(1)<<n):e;var e,n}i.r(o),i.d(o,{InvalidAddressError:()=>jo,Pox4SignatureTopic:()=>ns,StackingClient:()=>ls,btcAddressVersionToLegacyHashMode:()=>Go,decodeBtcAddress:()=>Fo,decodeBtcAddressBytes:()=>Wo,ensureLegacyBtcAddressForPox1:()=>ts,ensurePox2Activated:()=>Qo,ensureSignerArgsReadiness:()=>es,extractPoxAddressFromClarityValue:()=>Vo,getErrorString:()=>qo,pox4SignatureMessage:()=>os,poxAddressToBtcAddress:()=>Zo,poxAddressToTuple:()=>zo,signPox4SignatureHash:()=>rs,unwrap:()=>Jo,unwrapMap:()=>Yo,verifyPox4SignatureHash:()=>is});const h=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function d(t){if(!(t instanceof Uint8Array))throw new Error("Uint8Array expected");let e="";for(const n of t)e+=h[n];return e}function f(t){if("string"!=typeof t)throw new TypeError("hexToBytes: expected string, got "+typeof t);t=(t=n(t)).length%2?`0${t}`:t;const e=new Uint8Array(t.length/2);for(let n=0;n<e.length;n++){const r=2*n,i=t.slice(r,r+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");e[n]=o}return e}function l(t){return(new TextEncoder).encode(t)}function p(t){return(new TextDecoder).decode(t)}function g(t){const e=[];for(let n=0;n<t.length;n++)e.push(255&t.charCodeAt(n));return new Uint8Array(e)}function y(t){return String.fromCharCode.apply(null,t)}function w(t){return!Number.isInteger(t)||t<0||t>255}function b(t){if(t.some(w))throw new Error("Some values are invalid bytes.");return new Uint8Array(t)}function A(...t){if(!t.every((t=>t instanceof Uint8Array)))throw new Error("Uint8Array list expected");if(1===t.length)return t[0];const e=t.reduce(((t,e)=>t+e.length),0),n=new Uint8Array(e);for(let e=0,r=0;e<t.length;e++){const i=t[e];n.set(i,r),r+=i.length}return n}function m(t){return A(...t.map((t=>"number"==typeof t?b([t]):t instanceof Array?b(t):t)))}function E(t,e){return t instanceof e||t?.constructor?.name?.toLowerCase()===e.name}const S=33,v={referrerPolicy:"origin",headers:{"x-hiro-product":"stacksjs"}};async function x(t,e){const n={};return Object.assign(n,v,e),await fetch(t,n)}function I(...t){const{fetchLib:e,middlewares:n}=function(t){let e=x,n=[];return t.length>0&&"function"==typeof t[0]&&(e=t.shift()),t.length>0&&(n=t),{fetchLib:e,middlewares:n}}(t);return async(t,r)=>{let i={url:t,init:r??{}};for(const t of n)"function"==typeof t.pre&&(i=await Promise.resolve(t.pre({fetch:e,...i}))??i);let o=await e(i.url,i.init);for(const t of n)if("function"==typeof t.post){const n=await Promise.resolve(t.post({fetch:e,url:i.url,init:i.init,response:o?.clone()??o}));o=n??o}return o}}var C,_,T,P,k;!function(t){t[t.Mainnet=1]="Mainnet",t[t.Testnet=2147483648]="Testnet"}(C||(C={})),function(t){t[t.Mainnet=385875968]="Mainnet",t[t.Testnet=4278190080]="Testnet"}(_||(_={})),C.Mainnet,(k=T||(T={}))[k.Mainnet=0]="Mainnet",k[k.Testnet=128]="Testnet",function(t){t[t.MainnetSingleSig=22]="MainnetSingleSig",t[t.MainnetMultiSig=20]="MainnetMultiSig",t[t.TestnetSingleSig=26]="TestnetSingleSig",t[t.TestnetMultiSig=21]="TestnetMultiSig"}(P||(P={})),T.Mainnet;const R={chainId:C.Mainnet,transactionVersion:T.Mainnet,peerNetworkId:_.Mainnet,magicBytes:"X2",bootAddress:"SP000000000000000000002Q6VF78",addressVersion:{singleSig:P.MainnetSingleSig,multiSig:P.MainnetMultiSig},client:{baseUrl:"https://api.mainnet.hiro.so"}},O={chainId:C.Testnet,transactionVersion:T.Testnet,peerNetworkId:_.Testnet,magicBytes:"T2",bootAddress:"ST000000000000000000002AMW42H",addressVersion:{singleSig:P.TestnetSingleSig,multiSig:P.TestnetMultiSig},client:{baseUrl:"https://api.testnet.hiro.so"}},N={...O,addressVersion:{...O.addressVersion},magicBytes:"id",client:{baseUrl:"http://localhost:3999"}},B={...N,addressVersion:{...N.addressVersion},client:{...N.client}},U=["mainnet","testnet","devnet","mocknet"];function H(t){return"string"==typeof t?function(t){switch(t){case"mainnet":return R;case"testnet":return O;case"devnet":return N;case"mocknet":return B;default:throw new Error(`Unknown network name: ${t}`)}}(t):t}function $(t){return t.client.fetch?t.client:{...t.client,fetch:I()}}class D extends Error{constructor(t){super(t),this.message=t,this.name=this.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}class L extends D{constructor(t){super(t)}}class K extends D{constructor(t){super(t)}}class M extends D{constructor(t){super(t)}}class j extends D{constructor(t){super(t)}}class G extends D{constructor(t){super(t)}}function F(t,e){return t[e]}function W(t,e,n=0){return t[n]=e,t}function V(t,e,n=0){return t[n+3]=e,e>>>=8,t[n+2]=e,e>>>=8,t[n+1]=e,e>>>=8,t[n]=e,t}function q(t,e,n=0){return t[n+0]=255&e,e>>>=8,t[n+1]=255&e,e>>>=8,t[n+2]=255&e,e>>>=8,t[n+3]=255&e,t}const z=new Map;function X(t,e){const n=z.get(t);if(void 0!==n)return n(e);const r=function(t){const e=Object.values(t).filter((t=>"number"==typeof t)),n=new Set(e);return t=>n.has(t)}(t);return z.set(t,r),X(t,e)}class Z{constructor(t){this.consumed=0,this.source="string"==typeof t?f(t):t}readBytes(t){const e=this.source.subarray(this.consumed,this.consumed+t);return this.consumed+=t,e}readUInt32BE(){return(t=this.readBytes(4))[0]*2**24+65536*t[1]+256*t[2]+t[3];var t}readUInt8(){return F(this.readBytes(1),0)}readUInt16BE(){return((t=this.readBytes(2))[0+0]<<8|t[1])>>>0;var t}readBigUIntLE(t){const e=d(this.readBytes(t).slice().reverse());return BigInt(`0x${e}`)}readBigUIntBE(t){const e=d(this.readBytes(t));return BigInt(`0x${e}`)}get readOffset(){return this.consumed}set readOffset(t){this.consumed=t}get internalBytes(){return this.source}readUInt8Enum(t,e){const n=this.readUInt8();if(X(t,n))return n;throw e(n)}}const J=128,Y=128,Q=16,tt=65,et=34;var nt,rt,it,ot,st,at;(at=nt||(nt={}))[at.TokenTransfer=0]="TokenTransfer",at[at.SmartContract=1]="SmartContract",at[at.VersionedSmartContract=6]="VersionedSmartContract",at[at.ContractCall=2]="ContractCall",at[at.PoisonMicroblock=3]="PoisonMicroblock",at[at.Coinbase=4]="Coinbase",at[at.CoinbaseToAltRecipient=5]="CoinbaseToAltRecipient",at[at.TenureChange=7]="TenureChange",at[at.NakamotoCoinbase=8]="NakamotoCoinbase",(st=rt||(rt={}))[st.Clarity1=1]="Clarity1",st[st.Clarity2=2]="Clarity2",st[st.Clarity3=3]="Clarity3",(ot=it||(it={}))[ot.OnChainOnly=1]="OnChainOnly",ot[ot.OffChainOnly=2]="OffChainOnly",ot[ot.Any=3]="Any";var ct,ut,ht,dt,ft,lt,pt,gt,yt,wt,bt,At,mt,Et,St,vt,xt,It,Ct,_t;function Tt(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function Pt(t,...e){if(!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new TypeError(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}it.OnChainOnly,it.OffChainOnly,it.Any,it.OnChainOnly,it.OnChainOnly,it.OffChainOnly,it.OffChainOnly,it.Any,it.Any,(_t=ct||(ct={}))[_t.Allow=1]="Allow",_t[_t.Deny=2]="Deny",(Ct=ut||(ut={}))[Ct.STX=0]="STX",Ct[Ct.Fungible=1]="Fungible",Ct[Ct.NonFungible=2]="NonFungible",(It=ht||(ht={}))[It.Standard=4]="Standard",It[It.Sponsored=5]="Sponsored",(xt=dt||(dt={}))[xt.P2PKH=0]="P2PKH",xt[xt.P2SH=1]="P2SH",xt[xt.P2WPKH=2]="P2WPKH",xt[xt.P2WSH=3]="P2WSH",xt[xt.P2SHNonSequential=5]="P2SHNonSequential",xt[xt.P2WSHNonSequential=7]="P2WSHNonSequential",(vt=ft||(ft={}))[vt.Compressed=0]="Compressed",vt[vt.Uncompressed=1]="Uncompressed",function(t){t[t.Equal=1]="Equal",t[t.Greater=2]="Greater",t[t.GreaterEqual=3]="GreaterEqual",t[t.Less=4]="Less",t[t.LessEqual=5]="LessEqual"}(lt||(lt={})),function(t){t[t.Sends=16]="Sends",t[t.DoesNotSend=17]="DoesNotSend"}(pt||(pt={})),(St=gt||(gt={}))[St.Origin=1]="Origin",St[St.Standard=2]="Standard",St[St.Contract=3]="Contract",function(t){t[t.STX=0]="STX",t[t.Fungible=1]="Fungible",t[t.NonFungible=2]="NonFungible"}(yt||(yt={})),(Et=wt||(wt={}))[Et.BlockFound=0]="BlockFound",Et[Et.Extended=1]="Extended",(mt=bt||(bt={}))[mt.PublicKeyCompressed=0]="PublicKeyCompressed",mt[mt.PublicKeyUncompressed=1]="PublicKeyUncompressed",mt[mt.SignatureCompressed=2]="SignatureCompressed",mt[mt.SignatureUncompressed=3]="SignatureUncompressed",function(t){t.Serialization="Serialization",t.Deserialization="Deserialization",t.SignatureValidation="SignatureValidation",t.FeeTooLow="FeeTooLow",t.BadNonce="BadNonce",t.NotEnoughFunds="NotEnoughFunds",t.NoSuchContract="NoSuchContract",t.NoSuchPublicFunction="NoSuchPublicFunction",t.BadFunctionArgument="BadFunctionArgument",t.ContractAlreadyExists="ContractAlreadyExists",t.PoisonMicroblocksDoNotConflict="PoisonMicroblocksDoNotConflict",t.PoisonMicroblockHasUnknownPubKeyHash="PoisonMicroblockHasUnknownPubKeyHash",t.PoisonMicroblockIsInvalid="PoisonMicroblockIsInvalid",t.BadAddressVersionByte="BadAddressVersionByte",t.NoCoinbaseViaMempool="NoCoinbaseViaMempool",t.ServerFailureNoSuchChainTip="ServerFailureNoSuchChainTip",t.ServerFailureDatabase="ServerFailureDatabase",t.ServerFailureOther="ServerFailureOther"}(At||(At={}));const kt={number:Tt,bool:function(t){if("boolean"!=typeof t)throw new Error(`Expected boolean, not ${t}`)},bytes:Pt,hash:function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");Tt(t.outputLen),Tt(t.blockLen)},exists:function(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")},output:function(t,e){Pt(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}},Rt=("object"==typeof self&&"crypto"in self&&self.crypto,t=>new DataView(t.buffer,t.byteOffset,t.byteLength)),Ot=(t,e)=>t<<32-e|t>>>e;if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function Nt(t){if("string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new TypeError("utf8ToBytes expected string, got "+typeof t);return(new TextEncoder).encode(t)}(t)),!(t instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof t})`);return t}Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));class Bt{clone(){return this._cloneInto()}}function Ut(t){const e=e=>t().update(Nt(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}class Ht extends Bt{constructor(t,e,n,r){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Rt(this.buffer)}update(t){kt.exists(this);const{view:e,buffer:n,blockLen:r}=this,i=(t=Nt(t)).length;for(let o=0;o<i;){const s=Math.min(r-this.pos,i-o);if(s!==r)n.set(t.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(e,0),this.pos=0);else{const e=Rt(t);for(;r<=i-o;o+=r)this.process(e,o)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){kt.exists(this),kt.output(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:r,isLE:i}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>r-o&&(this.process(n,0),o=0);for(let t=o;t<r;t++)e[t]=0;!function(t,e,n,r){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),c=r?4:0,u=r?0:4;t.setUint32(e+c,s,r),t.setUint32(e+u,a,r)}(n,r-8,BigInt(8*this.length),i),this.process(n,0);const s=Rt(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<c;t++)s.setUint32(4*t,u[t],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:n,length:r,finished:i,destroyed:o,pos:s}=this;return t.length=r,t.pos=s,t.finished=i,t.destroyed=o,r%e&&t.buffer.set(n),t}}const $t=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Dt=Uint8Array.from({length:16},((t,e)=>e)),Lt=Dt.map((t=>(9*t+5)%16));let Kt=[Dt],Mt=[Lt];for(let t=0;t<4;t++)for(let e of[Kt,Mt])e.push(e[t].map((t=>$t[t])));const jt=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map((t=>new Uint8Array(t))),Gt=Kt.map(((t,e)=>t.map((t=>jt[e][t])))),Ft=Mt.map(((t,e)=>t.map((t=>jt[e][t])))),Wt=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),Vt=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),qt=(t,e)=>t<<e|t>>>32-e;function zt(t,e,n,r){return 0===t?e^n^r:1===t?e&n|~e&r:2===t?(e|~n)^r:3===t?e&r|n&~r:e^(n|~r)}const Xt=new Uint32Array(16);class Zt extends Ht{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:e,h2:n,h3:r,h4:i}=this;return[t,e,n,r,i]}set(t,e,n,r,i){this.h0=0|t,this.h1=0|e,this.h2=0|n,this.h3=0|r,this.h4=0|i}process(t,e){for(let n=0;n<16;n++,e+=4)Xt[n]=t.getUint32(e,!0);let n=0|this.h0,r=n,i=0|this.h1,o=i,s=0|this.h2,a=s,c=0|this.h3,u=c,h=0|this.h4,d=h;for(let t=0;t<5;t++){const e=4-t,f=Wt[t],l=Vt[t],p=Kt[t],g=Mt[t],y=Gt[t],w=Ft[t];for(let e=0;e<16;e++){const r=qt(n+zt(t,i,s,c)+Xt[p[e]]+f,y[e])+h|0;n=h,h=c,c=0|qt(s,10),s=i,i=r}for(let t=0;t<16;t++){const n=qt(r+zt(e,o,a,u)+Xt[g[t]]+l,w[t])+d|0;r=d,d=u,u=0|qt(a,10),a=o,o=n}}this.set(this.h1+s+u|0,this.h2+c+d|0,this.h3+h+r|0,this.h4+n+o|0,this.h0+i+a|0)}roundClean(){Xt.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}const Jt=Ut((()=>new Zt)),Yt=(t,e,n)=>t&e^t&n^e&n,Qt=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),te=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ee=new Uint32Array(64);class ne extends Ht{constructor(){super(64,32,8,!1),this.A=0|te[0],this.B=0|te[1],this.C=0|te[2],this.D=0|te[3],this.E=0|te[4],this.F=0|te[5],this.G=0|te[6],this.H=0|te[7]}get(){const{A:t,B:e,C:n,D:r,E:i,F:o,G:s,H:a}=this;return[t,e,n,r,i,o,s,a]}set(t,e,n,r,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let n=0;n<16;n++,e+=4)ee[n]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=ee[t-15],n=ee[t-2],r=Ot(e,7)^Ot(e,18)^e>>>3,i=Ot(n,17)^Ot(n,19)^n>>>10;ee[t]=i+ee[t-7]+r+ee[t-16]|0}let{A:n,B:r,C:i,D:o,E:s,F:a,G:c,H:u}=this;for(let t=0;t<64;t++){const e=u+(Ot(s,6)^Ot(s,11)^Ot(s,25))+((h=s)&a^~h&c)+Qt[t]+ee[t]|0,d=(Ot(n,2)^Ot(n,13)^Ot(n,22))+Yt(n,r,i)|0;u=c,c=a,a=s,s=o+e|0,o=i,i=r,r=n,n=e+d|0}var h;n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(n,r,i,o,s,a,c,u)}roundClean(){ee.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class re extends ne{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const ie=Ut((()=>new ne)),oe=(Ut((()=>new re)),BigInt(2**32-1)),se=BigInt(32);function ae(t,e=!1){return e?{h:Number(t&oe),l:Number(t>>se&oe)}:{h:0|Number(t>>se&oe),l:0|Number(t&oe)}}const ce=function(t,e=!1){let n=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:o,l:s}=ae(t[i],e);[n[i],r[i]]=[o,s]}return[n,r]},ue=(t,e,n)=>t>>>n,he=(t,e,n)=>t<<32-n|e>>>n,de=(t,e,n)=>t>>>n|e<<32-n,fe=(t,e,n)=>t<<32-n|e>>>n,le=(t,e,n)=>t<<64-n|e>>>n-32,pe=(t,e,n)=>t>>>n-32|e<<64-n,ge=function(t,e,n,r){const i=(e>>>0)+(r>>>0);return{h:t+n+(i/2**32|0)|0,l:0|i}},ye=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),we=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,be=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),Ae=(t,e,n,r,i)=>e+n+r+i+(t/2**32|0)|0,me=(t,e,n,r,i,o)=>e+n+r+i+o+(t/2**32|0)|0,Ee=(t,e,n,r,i)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(i>>>0),[Se,ve]=ce(["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((t=>BigInt(t)))),xe=new Uint32Array(80),Ie=new Uint32Array(80);class Ce extends Ht{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:e,Bh:n,Bl:r,Ch:i,Cl:o,Dh:s,Dl:a,Eh:c,El:u,Fh:h,Fl:d,Gh:f,Gl:l,Hh:p,Hl:g}=this;return[t,e,n,r,i,o,s,a,c,u,h,d,f,l,p,g]}set(t,e,n,r,i,o,s,a,c,u,h,d,f,l,p,g){this.Ah=0|t,this.Al=0|e,this.Bh=0|n,this.Bl=0|r,this.Ch=0|i,this.Cl=0|o,this.Dh=0|s,this.Dl=0|a,this.Eh=0|c,this.El=0|u,this.Fh=0|h,this.Fl=0|d,this.Gh=0|f,this.Gl=0|l,this.Hh=0|p,this.Hl=0|g}process(t,e){for(let n=0;n<16;n++,e+=4)xe[n]=t.getUint32(e),Ie[n]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|xe[t-15],n=0|Ie[t-15],r=de(e,n,1)^de(e,n,8)^ue(e,n,7),i=fe(e,n,1)^fe(e,n,8)^he(e,n,7),o=0|xe[t-2],s=0|Ie[t-2],a=de(o,s,19)^le(o,s,61)^ue(o,s,6),c=fe(o,s,19)^pe(o,s,61)^he(o,s,6),u=be(i,c,Ie[t-7],Ie[t-16]),h=Ae(u,r,a,xe[t-7],xe[t-16]);xe[t]=0|h,Ie[t]=0|u}let{Ah:n,Al:r,Bh:i,Bl:o,Ch:s,Cl:a,Dh:c,Dl:u,Eh:h,El:d,Fh:f,Fl:l,Gh:p,Gl:g,Hh:y,Hl:w}=this;for(let t=0;t<80;t++){const e=de(h,d,14)^de(h,d,18)^le(h,d,41),b=fe(h,d,14)^fe(h,d,18)^pe(h,d,41),A=h&f^~h&p,m=Ee(w,b,d&l^~d&g,ve[t],Ie[t]),E=me(m,y,e,A,Se[t],xe[t]),S=0|m,v=de(n,r,28)^le(n,r,34)^le(n,r,39),x=fe(n,r,28)^pe(n,r,34)^pe(n,r,39),I=n&i^n&s^i&s,C=r&o^r&a^o&a;y=0|p,w=0|g,p=0|f,g=0|l,f=0|h,l=0|d,({h,l:d}=ge(0|c,0|u,0|E,0|S)),c=0|s,u=0|a,s=0|i,a=0|o,i=0|n,o=0|r;const _=ye(S,x,C);n=we(_,E,v,I),r=0|_}({h:n,l:r}=ge(0|this.Ah,0|this.Al,0|n,0|r)),({h:i,l:o}=ge(0|this.Bh,0|this.Bl,0|i,0|o)),({h:s,l:a}=ge(0|this.Ch,0|this.Cl,0|s,0|a)),({h:c,l:u}=ge(0|this.Dh,0|this.Dl,0|c,0|u)),({h,l:d}=ge(0|this.Eh,0|this.El,0|h,0|d)),({h:f,l}=ge(0|this.Fh,0|this.Fl,0|f,0|l)),({h:p,l:g}=ge(0|this.Gh,0|this.Gl,0|p,0|g)),({h:y,l:w}=ge(0|this.Hh,0|this.Hl,0|y,0|w)),this.set(n,r,i,o,s,a,c,u,h,d,f,l,p,g,y,w)}roundClean(){xe.fill(0),Ie.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class _e extends Ce{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}class Te extends Ce{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}class Pe extends Ce{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}Ut((()=>new Ce)),Ut((()=>new _e));const ke=Ut((()=>new Te));Ut((()=>new Pe));var Re=i(314),Oe=i.t(Re,2);const Ne=BigInt(0),Be=BigInt(1),Ue=BigInt(2),He=BigInt(3),$e=BigInt(8),De=Object.freeze({a:Ne,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:Be,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")}),Le=(t,e)=>(t+e/Ue)/e,Ke={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(t){const{n:e}=De,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Be*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=n,s=BigInt("0x100000000000000000000000000000000"),a=Le(o*t,e),c=Le(-r*t,e);let u=yn(t-a*n-c*i,e),h=yn(-a*r-c*o,e);const d=u>s,f=h>s;if(d&&(u=e-u),f&&(h=e-h),u>s||h>s)throw new Error("splitScalarEndo: Endomorphism failed, k="+t);return{k1neg:d,k1:u,k2neg:f,k2:h}}},Me=32,je=32,Ge=32,Fe=Me+1,We=2*Me+1;function Ve(t){const{a:e,b:n}=De,r=yn(t*t),i=yn(r*t);return yn(i+e*t+n)}const qe=De.a===Ne;class ze extends Error{constructor(t){super(t)}}function Xe(t){if(!(t instanceof Ze))throw new TypeError("JacobianPoint expected")}class Ze{constructor(t,e,n){this.x=t,this.y=e,this.z=n}static fromAffine(t){if(!(t instanceof Qe))throw new TypeError("JacobianPoint#fromAffine: expected Point");return t.equals(Qe.ZERO)?Ze.ZERO:new Ze(t.x,t.y,Be)}static toAffineBatch(t){const e=function(t,e=De.P){const n=new Array(t.length),r=bn(t.reduce(((t,r,i)=>r===Ne?t:(n[i]=t,yn(t*r,e))),Be),e);return t.reduceRight(((t,r,i)=>r===Ne?t:(n[i]=yn(t*n[i],e),yn(t*r,e))),r),n}(t.map((t=>t.z)));return t.map(((t,n)=>t.toAffine(e[n])))}static normalizeZ(t){return Ze.toAffineBatch(t).map(Ze.fromAffine)}equals(t){Xe(t);const{x:e,y:n,z:r}=this,{x:i,y:o,z:s}=t,a=yn(r*r),c=yn(s*s),u=yn(e*c),h=yn(i*a),d=yn(yn(n*s)*c),f=yn(yn(o*r)*a);return u===h&&d===f}negate(){return new Ze(this.x,yn(-this.y),this.z)}double(){const{x:t,y:e,z:n}=this,r=yn(t*t),i=yn(e*e),o=yn(i*i),s=t+i,a=yn(Ue*(yn(s*s)-r-o)),c=yn(He*r),u=yn(c*c),h=yn(u-Ue*a),d=yn(c*(a-h)-$e*o),f=yn(Ue*e*n);return new Ze(h,d,f)}add(t){Xe(t);const{x:e,y:n,z:r}=this,{x:i,y:o,z:s}=t;if(i===Ne||o===Ne)return this;if(e===Ne||n===Ne)return