UNPKG

@stacks/bns

Version:

Library for working with the Stacks Blockchain Naming System BNS.

2 lines 106 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.StacksBns=e():t.StacksBns=e()}(this,()=>(()=>{var t,e,n={74:(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(452);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")}},258:(t,e,n)=>{"use strict";e.ns=e.bJ=void 0;n(669),n(639);const r=n(877);Object.defineProperty(e,"bJ",{enumerable:!0,get:function(){return r.c32address}}),Object.defineProperty(e,"ns",{enumerable:!0,get:function(){return r.c32addressDecode}})},290:(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]",f="[object Map]",h="[object Number]",l="[object Object]",d="[object Promise]",p="[object RegExp]",y="[object Set]",g="[object String]",b="[object Symbol]",w="[object WeakMap]",m="[object ArrayBuffer]",v="[object DataView]",A="[object Float32Array]",x="[object Float64Array]",E="[object Int8Array]",S="[object Int16Array]",C="[object Int32Array]",B="[object Uint8Array]",T="[object Uint8ClampedArray]",I="[object Uint16Array]",U="[object Uint32Array]",k=/\w*$/,P=/^\[object .+?Constructor\]$/,N=/^(?:0|[1-9]\d*)$/,$={};$[o]=$["[object Array]"]=$[m]=$[v]=$[s]=$[a]=$[A]=$[x]=$[E]=$[S]=$[C]=$[f]=$[h]=$[l]=$[p]=$[y]=$[g]=$[b]=$[B]=$[T]=$[I]=$[U]=!0,$["[object Error]"]=$[c]=$[w]=!1;var O="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,H="object"==typeof self&&self&&self.Object===Object&&self,_=O||H||Function("return this")(),L=e&&!e.nodeType&&e,j=L&&t&&!t.nodeType&&t,M=j&&j.exports===L;function F(t,e){return t.set(e[0],e[1]),t}function R(t,e){return t.add(e),t}function D(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 K(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}function V(t){var e=-1,n=Array(t.size);return t.forEach(function(t,r){n[++e]=[r,t]}),n}function z(t,e){return function(n){return t(e(n))}}function W(t){var e=-1,n=Array(t.size);return t.forEach(function(t){n[++e]=t}),n}var q,G=Array.prototype,Z=Function.prototype,J=Object.prototype,X=_["__core-js_shared__"],Q=(q=/[^.]+$/.exec(X&&X.keys&&X.keys.IE_PROTO||""))?"Symbol(src)_1."+q:"",Y=Z.toString,tt=J.hasOwnProperty,et=J.toString,nt=RegExp("^"+Y.call(tt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),rt=M?_.Buffer:void 0,it=_.Symbol,ot=_.Uint8Array,st=z(Object.getPrototypeOf,Object),at=Object.create,ct=J.propertyIsEnumerable,ut=G.splice,ft=Object.getOwnPropertySymbols,ht=rt?rt.isBuffer:void 0,lt=z(Object.keys,Object),dt=_t(_,"DataView"),pt=_t(_,"Map"),yt=_t(_,"Promise"),gt=_t(_,"Set"),bt=_t(_,"WeakMap"),wt=_t(Object,"create"),mt=Rt(dt),vt=Rt(pt),At=Rt(yt),xt=Rt(gt),Et=Rt(bt),St=it?it.prototype:void 0,Ct=St?St.valueOf:void 0;function Bt(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 It(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 Ut(t){this.__data__=new Tt(t)}function kt(t,e,n){var r=t[e];tt.call(t,e)&&Dt(r,n)&&(void 0!==n||e in t)||(t[e]=n)}function Pt(t,e){for(var n=t.length;n--;)if(Dt(t[n][0],e))return n;return-1}function Nt(t,e,n,r,i,d,w){var P;if(r&&(P=d?r(t,i,d,w):r(t)),void 0!==P)return P;if(!qt(t))return t;var N=Kt(t);if(N){if(P=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,P)}else{var O=jt(t),H=O==c||O==u;if(zt(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(O==l||O==o||H&&!d){if(K(t))return d?t:{};if(P=function(t){return"function"!=typeof t.constructor||Ft(t)?{}:qt(e=st(t))?at(e):{};var e}(H?{}:t),!e)return function(t,e){return Ot(t,Lt(t),e)}(t,function(t,e){return t&&Ot(e,Gt(e),t)}(P,t))}else{if(!$[O])return d?t:{};P=function(t,e,n,r){var i,o=t.constructor;switch(e){case m:return $t(t);case s:case a:return new o(+t);case v:return function(t,e){var n=e?$t(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,r);case A:case x:case E:case S:case C:case B:case T:case I:case U:return function(t,e){var n=e?$t(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}(t,r);case f:return function(t,e,n){return D(e?n(V(t),!0):V(t),F,new t.constructor)}(t,r,n);case h:case g: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 y:return function(t,e,n){return D(e?n(W(t),!0):W(t),R,new t.constructor)}(t,r,n);case b:return i=t,Ct?Object(Ct.call(i)):{}}}(t,O,Nt,e)}}w||(w=new Ut);var _=w.get(t);if(_)return _;if(w.set(t,P),!N)var L=n?function(t){return function(t,e,n){var r=e(t);return Kt(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,Gt,Lt)}(t):Gt(t);return function(t,e){for(var n=-1,r=t?t.length:0;++n<r&&!1!==e(t[n],n););}(L||t,function(i,o){L&&(i=t[o=i]),kt(P,o,Nt(i,e,n,r,o,t,w))}),P}function $t(t){var e=new t.constructor(t.byteLength);return new ot(e).set(new ot(t)),e}function Ot(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 Ht(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 _t(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return function(t){return!(!qt(t)||(e=t,Q&&Q in e))&&(Wt(t)||K(t)?nt:P).test(Rt(t));var e}(n)?n:void 0}Bt.prototype.clear=function(){this.__data__=wt?wt(null):{}},Bt.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},Bt.prototype.get=function(t){var e=this.__data__;if(wt){var n=e[t];return n===r?void 0:n}return tt.call(e,t)?e[t]:void 0},Bt.prototype.has=function(t){var e=this.__data__;return wt?void 0!==e[t]:tt.call(e,t)},Bt.prototype.set=function(t,e){return this.__data__[t]=wt&&void 0===e?r:e,this},Tt.prototype.clear=function(){this.__data__=[]},Tt.prototype.delete=function(t){var e=this.__data__,n=Pt(e,t);return!(n<0||(n==e.length-1?e.pop():ut.call(e,n,1),0))},Tt.prototype.get=function(t){var e=this.__data__,n=Pt(e,t);return n<0?void 0:e[n][1]},Tt.prototype.has=function(t){return Pt(this.__data__,t)>-1},Tt.prototype.set=function(t,e){var n=this.__data__,r=Pt(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},It.prototype.clear=function(){this.__data__={hash:new Bt,map:new(pt||Tt),string:new Bt}},It.prototype.delete=function(t){return Ht(this,t).delete(t)},It.prototype.get=function(t){return Ht(this,t).get(t)},It.prototype.has=function(t){return Ht(this,t).has(t)},It.prototype.set=function(t,e){return Ht(this,t).set(t,e),this},Ut.prototype.clear=function(){this.__data__=new Tt},Ut.prototype.delete=function(t){return this.__data__.delete(t)},Ut.prototype.get=function(t){return this.__data__.get(t)},Ut.prototype.has=function(t){return this.__data__.has(t)},Ut.prototype.set=function(t,e){var n=this.__data__;if(n instanceof Tt){var r=n.__data__;if(!pt||r.length<199)return r.push([t,e]),this;n=this.__data__=new It(r)}return n.set(t,e),this};var Lt=ft?z(ft,Object):function(){return[]},jt=function(t){return et.call(t)};function Mt(t,e){return!!(e=null==e?i:e)&&("number"==typeof t||N.test(t))&&t>-1&&t%1==0&&t<e}function Ft(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||J)}function Rt(t){if(null!=t){try{return Y.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function Dt(t,e){return t===e||t!=t&&e!=e}(dt&&jt(new dt(new ArrayBuffer(1)))!=v||pt&&jt(new pt)!=f||yt&&jt(yt.resolve())!=d||gt&&jt(new gt)!=y||bt&&jt(new bt)!=w)&&(jt=function(t){var e=et.call(t),n=e==l?t.constructor:void 0,r=n?Rt(n):void 0;if(r)switch(r){case mt:return v;case vt:return f;case At:return d;case xt:return y;case Et:return w}return e});var Kt=Array.isArray;function Vt(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=i}(t.length)&&!Wt(t)}var zt=ht||function(){return!1};function Wt(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 Gt(t){return Vt(t)?function(t,e){var n=Kt(t)||function(t){return function(t){return function(t){return!!t&&"object"==typeof t}(t)&&Vt(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||Mt(s,r))||n.push(s);return n}(t):function(t){if(!Ft(t))return lt(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 Nt(t,!0,!0)}},403: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 f(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 f=t.charCodeAt(n);if(f>255)return;var h=e[f];if(255===h)return;for(var l=0,d=o-1;(0!==h||l<i)&&-1!==d;d--,l++)h+=s*u[d]>>>0,u[d]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");i=l,n++}for(var p=o-i;p!==o&&0===u[p];)p++;for(var y=new Uint8Array(r+(o-p)),g=r;p!==o;)y[g++]=u[p++];return y}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,f=new Uint8Array(c);i!==o;){for(var h=e[i],l=0,d=c-1;(0!==h||l<r)&&-1!==d;d--,l++)h+=256*f[d]>>>0,f[d]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");r=l,i++}for(var p=c-r;p!==c&&0===f[p];)p++;for(var y=a.repeat(n);p<c;++p)y+=t.charAt(f[p]);return y},decodeUnsafe:f,decode:function(t){var e=f(t);if(e)return e;throw new Error("Non-base"+s+" character")}}}},414:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.decode=e.encode=void 0;const r=n(688),i=n(74),o=n(403),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}}},452:(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}},460:(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},546:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SHA2=void 0;const r=n(460),i=n(74);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){const e=(0,i.createView)(t);for(;o<=s-r;r+=o)this.process(e,r);continue}n.set(t.subarray(r,r+a),this.pos),this.pos+=a,r+=a,this.pos===o&&(this.process(e,0),this.pos=0)}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 f=u/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<f;t++)c.setUint32(4*t,h[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},639:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.c32checkDecode=e.c32checkEncode=void 0;const r=n(688),i=n(74),o=n(669);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)]}},669:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.c32decode=e.c32normalize=e.c32encode=e.c32=void 0;const r=n(74);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,f=e.c32[r+u];s=c,o.unshift(f)}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 f=0;for(let t=0;t<a.length&&"0"===a[t];t++)f++;a=a.slice(f-f%2);let h=a.join("");for(let t=0;t<s;t++)h=`00${h}`;if(n){const t=2*n-h.length;for(let e=0;e<t;e+=2)h=`00${h}`}return h}},688:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.sha224=e.sha256=void 0;const r=n(546),i=n(74),o=(t,e,n)=>t&e^~t&n,s=(t,e,n)=>t&e^t&n^e&n,a=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]),c=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=new Uint32Array(64);class f extends r.SHA2{constructor(){super(64,32,8,!1),this.A=0|c[0],this.B=0|c[1],this.C=0|c[2],this.D=0|c[3],this.E=0|c[4],this.F=0|c[5],this.G=0|c[6],this.H=0|c[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)u[n]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=u[t-15],n=u[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;u[t]=o+u[t-7]+r+u[t-16]|0}let{A:n,B:r,C:c,D:f,E:h,F:l,G:d,H:p}=this;for(let t=0;t<64;t++){const e=p+((0,i.rotr)(h,6)^(0,i.rotr)(h,11)^(0,i.rotr)(h,25))+o(h,l,d)+a[t]+u[t]|0,y=((0,i.rotr)(n,2)^(0,i.rotr)(n,13)^(0,i.rotr)(n,22))+s(n,r,c)|0;p=d,d=l,l=h,h=f+e|0,f=c,c=r,r=n,n=e+y|0}n=n+this.A|0,r=r+this.B|0,c=c+this.C|0,f=f+this.D|0,h=h+this.E|0,l=l+this.F|0,d=d+this.G|0,p=p+this.H|0,this.set(n,r,c,f,h,l,d,p)}roundClean(){u.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class h extends f{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 f),e.sha224=(0,i.wrapConstructor)(()=>new h)},877:(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(639),i=n(414),o=n(74);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)}},976:()=>{}},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||"function"==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 a(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(v(t,Uint8Array))return BigInt(`0x${f(t)}`);throw new TypeError("intToBigInt: Invalid value type. Must be a number, bigint, BigInt-compatible string, or Uint8Array.")}function n(t){if("string"!=typeof t)throw new TypeError("hexToBigInt: expected string, got "+typeof t);return BigInt(`0x${t}`)}function r(t,n=8){return("bigint"==typeof t?t:e(t)).toString(16).padStart(2*n,"0")}function s(t){return parseInt(t,16)}function a(t,e=16){return h(r(t,e))}function c(t){return e=BigInt(`0x${f(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,{BNS_CONTRACT_NAME:()=>Fi,buildImportNameTx:()=>Gi,buildPreorderNameTx:()=>Ji,buildPreorderNamespaceTx:()=>Wi,buildReadyNamespaceTx:()=>Zi,buildRegisterNameTx:()=>Xi,buildRenewNameTx:()=>eo,buildRevealNamespaceTx:()=>qi,buildRevokeNameTx:()=>to,buildTransferNameTx:()=>Yi,buildUpdateNameTx:()=>Qi,canRegisterName:()=>Ki,getNamePrice:()=>zi,getNamespacePrice:()=>Vi});const u=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function f(t){if(!(t instanceof Uint8Array))throw new Error("Uint8Array expected");let e="";for(const n of t)e+=u[n];return e}function h(t){if("string"!=typeof t)throw new TypeError("hexToBytes: expected string, got "+typeof t);var e;t=(e=t,t=/^0x/i.test(e)?e.slice(2):e).length%2?`0${t}`:t;const n=new Uint8Array(t.length/2);for(let e=0;e<n.length;e++){const r=2*e,i=t.slice(r,r+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");n[e]=o}return n}function l(t){return(new TextEncoder).encode(t)}function d(t){return(new TextDecoder).decode(t)}function p(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 g(t){return!Number.isInteger(t)||t<0||t>255}function b(t){if(t.some(g))throw new Error("Some values are invalid bytes.");return new Uint8Array(t)}function w(...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 w(...t.map(t=>"number"==typeof t?b([t]):t instanceof Array?b(t):t))}function v(t,e){return t instanceof e||t?.constructor?.name?.toLowerCase()===e.name}const A=33,x={referrerPolicy:"origin",headers:{"x-hiro-product":"stacksjs"}};async function E(t,e){const n={};return Object.assign(n,x,e),await fetch(t,n)}function S(...t){const{fetchLib:e,middlewares:n}=function(t){let e=E,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,B,T,I,U;!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"}(B||(B={})),C.Mainnet,(U=T||(T={}))[U.Mainnet=0]="Mainnet",U[U.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"}(I||(I={})),T.Mainnet;const k={chainId:C.Mainnet,transactionVersion:T.Mainnet,peerNetworkId:B.Mainnet,magicBytes:"X2",bootAddress:"SP000000000000000000002Q6VF78",addressVersion:{singleSig:I.MainnetSingleSig,multiSig:I.MainnetMultiSig},client:{baseUrl:"https://api.mainnet.hiro.so"}},P={chainId:C.Testnet,transactionVersion:T.Testnet,peerNetworkId:B.Testnet,magicBytes:"T2",bootAddress:"ST000000000000000000002AMW42H",addressVersion:{singleSig:I.TestnetSingleSig,multiSig:I.TestnetMultiSig},client:{baseUrl:"https://api.testnet.hiro.so"}},N={...P,addressVersion:{...P.addressVersion},magicBytes:"id",client:{baseUrl:"http://localhost:3999"}},$={...N,addressVersion:{...N.addressVersion},client:{...N.client}};function O(t){return"string"==typeof t?function(t){switch(t){case"mainnet":return k;case"testnet":return P;case"devnet":return N;case"mocknet":return $;default:throw new Error(`Unknown network name: ${t}`)}}(t):t}function H(t){return t.client.fetch?t.client:{...t.client,fetch:S()}}var _=i(258);function L(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}const j=128,M=128,F=16,R=65,D=34;var K,V,z,W,q,G;(G=K||(K={}))[G.TokenTransfer=0]="TokenTransfer",G[G.SmartContract=1]="SmartContract",G[G.VersionedSmartContract=6]="VersionedSmartContract",G[G.ContractCall=2]="ContractCall",G[G.PoisonMicroblock=3]="PoisonMicroblock",G[G.Coinbase=4]="Coinbase",G[G.CoinbaseToAltRecipient=5]="CoinbaseToAltRecipient",G[G.TenureChange=7]="TenureChange",G[G.NakamotoCoinbase=8]="NakamotoCoinbase",(q=V||(V={}))[q.Clarity1=1]="Clarity1",q[q.Clarity2=2]="Clarity2",q[q.Clarity3=3]="Clarity3",q[q.Clarity4=4]="Clarity4",q[q.Clarity5=5]="Clarity5",(W=z||(z={}))[W.OnChainOnly=1]="OnChainOnly",W[W.OffChainOnly=2]="OffChainOnly",W[W.Any=3]="Any";var Z,J,X,Q,Y,tt,et,nt,rt,it,ot,st,at,ct,ut,ft,ht,lt,dt,pt;z.OnChainOnly,z.OffChainOnly,z.Any,z.OnChainOnly,z.OnChainOnly,z.OffChainOnly,z.OffChainOnly,z.Any,z.Any,(pt=Z||(Z={}))[pt.Allow=1]="Allow",pt[pt.Deny=2]="Deny",pt[pt.Originator=3]="Originator",(dt=J||(J={}))[dt.STX=0]="STX",dt[dt.Fungible=1]="Fungible",dt[dt.NonFungible=2]="NonFungible",(lt=X||(X={}))[lt.Standard=4]="Standard",lt[lt.Sponsored=5]="Sponsored",(ht=Q||(Q={}))[ht.P2PKH=0]="P2PKH",ht[ht.P2SH=1]="P2SH",ht[ht.P2WPKH=2]="P2WPKH",ht[ht.P2WSH=3]="P2WSH",ht[ht.P2SHNonSequential=5]="P2SHNonSequential",ht[ht.P2WSHNonSequential=7]="P2WSHNonSequential",(ft=Y||(Y={}))[ft.Compressed=0]="Compressed",ft[ft.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"}(tt||(tt={})),function(t){t[t.Sends=16]="Sends",t[t.DoesNotSend=17]="DoesNotSend",t[t.MaybeSent=18]="MaybeSent"}(et||(et={})),(ut=nt||(nt={}))[ut.Origin=1]="Origin",ut[ut.Standard=2]="Standard",ut[ut.Contract=3]="Contract",function(t){t[t.STX=0]="STX",t[t.Fungible=1]="Fungible",t[t.NonFungible=2]="NonFungible"}(rt||(rt={})),(ct=it||(it={}))[ct.BlockFound=0]="BlockFound",ct[ct.Extended=1]="Extended",ct[ct.ExtendedRuntime=2]="ExtendedRuntime",ct[ct.ExtendedReadCount=3]="ExtendedReadCount",ct[ct.ExtendedReadLength=4]="ExtendedReadLength",ct[ct.ExtendedWriteCount=5]="ExtendedWriteCount",ct[ct.ExtendedWriteLength=6]="ExtendedWriteLength",(at=ot||(ot={}))[at.PublicKeyCompressed=0]="PublicKeyCompressed",at[at.PublicKeyUncompressed=1]="PublicKeyUncompressed",at[at.SignatureCompressed=2]="SignatureCompressed",at[at.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"}(st||(st={}));class yt extends Error{constructor(t){super(t),this.message=t,this.name=this.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}class gt extends yt{constructor(t){super(t)}}class bt extends yt{constructor(t){super(t)}}class wt extends yt{constructor(t){super(t)}}class mt extends yt{constructor(t){super(t)}}class vt extends yt{constructor(t){super(t)}}function At(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function xt(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}`)}const Et={number:At,bool:function(t){if("boolean"!=typeof t)throw new Error(`Expected boolean, not ${t}`)},bytes:xt,hash:function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");At(t.outputLen),At(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){xt(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}},St=("object"==typeof self&&"crypto"in self&&self.crypto,t=>new DataView(t.buffer,t.byteOffset,t.byteLength)),Ct=(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 Bt(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 Tt{clone(){return this._cloneInto()}}function It(t){const e=e=>t().update(Bt(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}class Ut extends Tt{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Et.hash(t);const n=Bt(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new TypeError("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?t.create().update(n).digest():n);for(let t=0;t<i.length;t++)i[t]^=54;this.iHash.update(i),this.oHash=t.create();for(let t=0;t<i.length;t++)i[t]^=106;this.oHash.update(i),i.fill(0)}update(t){return Et.exists(this),this.iHash.update(t),this}digestInto(t){Et.exists(this),Et.bytes(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:n,finished:r,destroyed:i,blockLen:o,outputLen:s}=this;return t.finished=r,t.destroyed=i,t.blockLen=o,t.outputLen=s,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const kt=(t,e,n)=>new Ut(t,e).update(n).digest();kt.create=(t,e)=>new Ut(t,e);class Pt extends Tt{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=St(this.buffer)}update(t){Et.exists(this);const{view:e,buffer:n,blockLen:r}=this,i=(t=Bt(t)).length;for(let o=0;o<i;){const s=Math.min(r-this.pos,i-o);if(s===r){const e=St(t);for(;r<=i-o;o+=r)this.process(e,o);continue}n.set(t.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Et.exists(this),Et.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=St(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 Nt=(t,e,n)=>t&e^~t&n,$t=(t,e,n)=>t&e^t&n^e&n,Ot=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]),Ht=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),_t=new Uint32Array(64);class Lt extends Pt{constructor(){super(64,32,8,!1),this.A=0|Ht[0],this.B=0|Ht[1],this.C=0|Ht[2],this.D=0|Ht[3],this.E=0|Ht[4],this.F=0|Ht[5],this.G=0|Ht[6],this.H=0|Ht[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)_t[n]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=_t[t-15],n=_t[t-2],r=Ct(e,7)^Ct(e,18)^e>>>3,i=Ct(n,17)^Ct(n,19)^n>>>10;_t[t]=i+_t[t-7]+r+_t[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+(Ct(s,6)^Ct(s,11)^Ct(s,25))+Nt(s,a,c)+Ot[t]+_t[t]|0,f=(Ct(n,2)^Ct(n,13)^Ct(n,22))+$t(n,r,i)|0;u=c,c=a,a=s,s=o+e|0,o=i,i=r,r=n,n=e+f|0}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(){_t.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class jt extends Lt{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 Mt=It(()=>new Lt);It(()=>new jt);var Ft=i(976),Rt=i.t(Ft,2);const Dt=BigInt(0),Kt=BigInt(1),Vt=BigInt(2),zt=BigInt(3),Wt=BigInt(8),qt=Object.freeze({a:Dt,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:Kt,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")}),Gt=(t,e)=>(t+e/Vt)/e,Zt={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(t){const{n:e}=qt,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Kt*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=n,s=BigInt("0x100000000000000000000000000000000"),a=Gt(o*t,e),c=Gt(-r*t,e);let u=me(t-a*n-c*i,e),f=me(-a*r-c*o,e);const h=u>s,l=f>s;if(h&&(u=e-u),l&&(f=e-f),u>s||f>s)throw new Error("splitScalarEndo: Endomorphism failed, k="+t);return{k1neg:h,k1:u,k2neg:l,k2:f}}};function Jt(t){const{a:e,b:n}=qt,r=me(t*t),i=me(r*t);return me(i+e*t+n)}const Xt=qt.a===Dt;class Qt extends Error{constructor(t){super(t)}}function Yt(t){if(!(t instanceof te))throw new TypeError("JacobianPoint expected")}class te{constructor(t,e,n){this.x=t,this.y=e,this.z=n}static fromAffine(t){if(!(t instanceof re))throw new TypeError("JacobianPoint#fromAffine: expected Point");return t.equals(re.ZERO)?te.ZERO:new te(t.x,t.y,Kt)}static toAffineBatch(t){const e=function(t,e=qt.P){const n=new Array(t.length),r=Ae(t.reduce((t,r,i)=>r===Dt?t:(n[i]=t,me(t*r,e)),Kt),e);return t.reduceRight((t,r,i)=>r===Dt?t:(n[i]=me(t*n[i],e),me(t*r,e)),r),n}(t.map(t=>t.z));return t.map((t,n)=>t.toAffine(e[n]))}static normalizeZ(t){return te.toAffineBatch(t).map(te.fromAffine)}equals(t){Yt(t);const{x:e,y:n,z:r}=this,{x:i,y:o,z:s}=t,a=me(r*r),c=me(s*s),u=me(e*c),f=me(i*a),h=me(me(n*s)*c),l=me(me(o*r)*a);return u===f&&h===l}negate(){return new te(this.x,me(-this.y),this.z)}double(){const{x:t,y:e,z:n}=this,r=me(t*t),i=me(e*e),o=me(i*i),s=t+i,a=me(Vt*(me(s*s)-r-o)),c=me(zt*r),u=me(c*c),f=me(u-Vt*a),h=me(c*(a-f)-Wt*o),l=me(Vt*e*n);return new te(f,h,l)}add(t){Yt(t);const{x:e,y:n,z:r}=this,{x:i,y:o,z:s}=t;if(i===Dt||o===Dt)return this;if(e===Dt||n===Dt)return t;const a=me(r*r),c=me(s*s),u=me(e*c),f=me(i*a),h=me(me(n*s)*c),l=me(me(o*r)*a),d=me(f-u),p=me(l-h);if(d===Dt)return p===Dt?this.double():te.ZERO;const y=me(d*d),g=me(d*y),b=me(u*y),w=me(p*p-g-Vt*b),m=me(p*(b-w)-h*g),v=me(r*s*d);return new te(w,m,v)}subtract(t){return this.add(t.negate())}multiplyUnsafe(t){const e=te.ZERO;if("bigint"==typeof t&&t===Dt)return e;let n=we(t);if(n===Kt)return this;if(!Xt){let t=e,r=this;for(;n>Dt;)n&Kt&&(t=t.add(r)),r=r.double(),n>>=Kt;return t}let{k1neg:r,k1:i,k2neg:o,k2:s}=Zt.splitScalar(n),a=e,c=e,u=this;for(;i>Dt||s>Dt;)i&Kt&&(a=a.add(u)),s&Kt&&(c=c.add(u)),u=u.double(),i>>=Kt,s>>=Kt;return r&&(a=a.negate()),o&&(c=c.negate()),c=new te(me(c.x*Zt.beta),c.y,c.z),a.add(c)}precomputeWindow(t){const e=Xt?128/t+1:256/t+1,n=[];let r=this,i=r;for(let o=0;o<e;o++){i=r,n.push(i);for(let e=1;e<2**(t-1);e++)i=i.add(r),n.push(i);r=i.double()}return n}wNAF(t,e){!e&&this.equals(te.BASE)&&(e=re.BASE);const n=e&&e._WINDOW_SIZE||1;if(256%n)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let r=e&&ne.get(e);r||(r=this.precomputeWindow(n),e&&1!==n&&(r=te.normalizeZ(r),ne.set(e,r)));let i=te.ZERO,o=te.BASE;const s=1+(Xt?128/n:256/n),a=2**(n-1),c=BigInt(2**n-1),u=2**n,f=BigInt(n);for(let e=0;e<s;e++){const n=e*a;let s=Number(t&c);t>>=f,s>a&&(s-=u,t+=Kt);const h=n,l=n+Math.abs(s)-1,d=e%2!=0,p=s<0;0===s?o=o.add(ee(d,r[h])):i=i.add(ee(p,r[l]))}return{p:i,f:o}}multiply(t,e){let n,r,i=we(t);if(Xt){const{k1neg:t,k1:o,k2neg:s,k2:a}=Zt.splitScalar(i);let{p:c,f:u}=this.wNAF(o,e),{p:f,f:h}=this.wNAF(a,e);c=ee(t,c),f=ee(s,f),f=new te(me(f.x*Zt.beta),f.y,f.z),n=c.add(f),r=u.add(h)}else{const{p:t,f:o}=this.wNAF(i,e);n=t,r=o}return te.normalizeZ([n,r])[0]}toAffine(t){const{x:e,y:n,z:r}=this,i=this.equals(te.ZERO);null==t&&(t=i?Wt:Ae(r));const o=t,s=me(o*o),a=me(s*o),c=me(e*s),u=me(n*a),f=me(r*o);if(i)return re.ZERO;if(f!==Kt)throw new Error("invZ was invalid");return new re(c,u)}}function ee(t,e){const n=e.negate();return t?n:e}te.BASE=new te(qt.Gx,qt.Gy,Kt),te.ZERO=new te(Dt,Kt,Dt);const ne=new WeakMap;class re{constructor(t,e){this.x=t,this.y=e}_setWindowSize(t){this._WINDOW_SIZE=t,ne.delete(this)}hasEvenY(){return this.y%Vt===Dt}static fromCompressedHex(t){const e=32===t.length,n=ge(e?t:t.subarray(1));if(!Te(n))throw new Error("Point is not on curve");let r=function(t){const{P:e}=qt,n=BigInt(6),r=BigInt(11),i=BigInt(22),o=BigInt(23),s=BigInt(44),a=BigInt(88),c=t*t*t%e,u=c*c*t%e,f=ve(u,zt)*u%e,h=ve(f,zt)*u%e,l=ve(h,Vt)*c%e,d=ve(l,r)*l%e,p=ve(d,i)*d%e,y=ve(p,s)*p%e,g=ve(y,a)*y%e,b=ve(g,s)*p%e,w=ve(b,zt)*u%e,m=ve(w,o)*d%e,v=ve(m,n)*c%e,A=ve(v,Vt);if(A*A%e!==t)throw new Error("Cannot find square root");return A}(Jt(n));const i=(r&Kt)===Kt;e?i&&(r=me(-r)):!(1&~t[0])!==i&&(r=me(-r));const o=new re(n,r);return o.assertValidity(),o}static fromUncompressedHex(t){const e=ge(t.subarray(1,33)),n=ge(t.subarray(33,65)),r=new re(e,n);return r.assertValidity(),r}static fromHex(t){const e=be(t),n=e.length,r=e[0];if(32===n)return this.fromCompressedHex(e);if(33===n&&(2===r||3===r))return this.fromCompressedHex(e);if(65===n&&4===r)return this.fromUncompressedHex(e);throw new Error(`Point.fromHex: received invalid point. Expected 32-33 compressed bytes or 65 uncompressed bytes, not ${n}`)}static fromPrivateKey(t){return re.BASE.multiply(Ue(t))}static fromSignature(t,e,n){const{r,s:i}=function(t){if(t instanceof se)return t.assertValidity(),t;try{return se.fromDER(t)}catch(e){return se.fromCompact(t)}}(e);if(![0,1,2,3].includes(n))throw new Error("Cannot recover: invalid recovery bit");const o=xe(be(t)),{n:s}=qt,a=2===n||3===n?r+s:r,c=Ae(a,s),u=me(-o*c,s),f=me(i*c,s),h=1&n?"03":"02",l=re.fromHex(h+he(a)),d=re.BASE.multiplyAndAddUnsafe(l,u,f);if(!d)throw new Error("Cannot recover signature: point at infinify");return d.assertValidity(),d}toRawBytes(t=!1){return ye(this.toHex(t))}toHex(t=!1){const e=he(this.x);return t?`${this.hasEvenY()?"02":"03"}${e}`:`04${e}${he(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const t="Point is not on elliptic curve",{x:e,y:n}=this;if(!Te(e)||!Te(n))throw new Error(t);const r=me(n*n);if(me(r-Jt(e))!==Dt)throw new Error(t)}equals(t){return this.x===t.x&&this.y===t.y}negate(){return new re(this.x,me(-this.y))}double(){return te.fromAffine(this).double().toAffine()}add(t){return te.fromAffine(this).add(te.fromAffine(t)).toAffine()}subtract(t){return this.add(t.negate())}multiply(t){return te.fromAffine(this).multiply(t,this).toAffine()}multiplyAndAddUnsafe(t,e,n){const r=te.fromAffine(this),i=e===Dt||e===Kt||this!==re.BASE?r.multiplyUnsafe(e):r.multiply(e),o=te.fromAffine(t).multiplyUnsafe(n),s=i.add(o);return s.equals(te.ZERO)?void 0:s.toAffine()}}function ie(t){return Number.parseInt(t[0],16)>=8?"00"+t:t}function oe(t){if(t.length<2||2!==t[0])throw new Error(`Invalid signature integer tag: ${ue(t)}`);const e=t[1],n=t.subarray(2,e+2);if(!e||n.length!==e)throw new Error("Invalid signature integer: wrong length");if(0===n[0]&&n[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:ge(n),left:t.subarray(e+2)}}re.BASE=new re(qt.Gx,qt.Gy),re.ZERO=new re(Dt,Dt);class se{constructor(t,e){this.r=t,this.s=e,this.assertValidity()}static fromCompact(t){const e=t instanceof Uint8Array,n="Signature.fromCompact";if("string"!=typeof t&&!e)throw new TypeError(`${n}: Expected string or Uint8Array`);const r=e?ue(t):t;if(128!==r.length)throw new Error(`${n}: Expected 64-byte hex`);return new se(pe(r.slice(0,64)),pe(r.slice(64,128)))}static fromDER(t){const e=t instanceof Uint8Array;if("string"!=typeof t&&!e)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:n,s:r}=function(t){if(t.length<2||48!=t[0])throw new Error(`Invalid signature tag: ${ue(t)}`);if(t[1]!==t.length-2)throw new Error("Invalid signature: incorrect length");const{data:e,left:n}=oe(t.subarray(2)),{data:r,left:i}=oe(n);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${ue(i)}`);return{r:e,s:r}}(e?t:ye(t));return new se(n,r)}static fromHex(t){return this.fromDER(t)}assertValidity(){const{r:t,s:e}=this;if(!Be(t))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Be(e))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const t=qt.n>>Kt;return this.s>t}normalizeS(){return this.hasHighS()?new se(this.r,me(-this.s,qt.n)):this}toDERRawBytes(){return ye(this.toDERHex())}toDERHex(){const t=ie(de(this.s)),e=ie(de(this.r)),n=t.length/2,r=e.length/2,i=de(n),o=de(r);return`30${de(r+n+4)}02${o}${e}02${i}${t}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return ye(this.toCompactHex())}toCompactHex(){return he(this.r)+he(this.s)}}function ae(...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}const ce=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ue(t){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");let e="";for(let n=0;n<t.length;n++)e+=ce[t[n]];return e}const fe=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function he(t){if("bigint"!=typeof t)throw new Error("Expected bigint");if(!(Dt<=t&&t<fe))throw new Error("Expected number 0 <= n < 2^256");return t.toString(16).padStart(64,"0")}function le(t){const e=ye(he(t));if(32!==e.length)throw new Error("Error: expected 32 bytes");return e}function de(t){const e=t.toString(16