UNPKG

did-jwt

Version:

Library for Signing and Verifying JWTs that use DIDs as issuers and JWEs that use DIDs as recipients

2 lines โ€ข 126 kB
/*! For license information please see did-jwt.js.LICENSE.txt */ var e={84:e=>{e.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var n=0;n<e.length;n++){var o=e.charAt(n),i=o.charCodeAt(0);if(255!==t[i])throw new TypeError(o+" is ambiguous");t[i]=n}var s=e.length,c=e.charAt(0),a=Math.log(s)/Math.log(256),f=Math.log(256)/Math.log(s);function u(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var r=0;if(" "!==e[r]){for(var n=0,o=0;e[r]===c;)n++,r++;for(var i=(e.length-r)*a+1>>>0,f=new Uint8Array(i);e[r];){var u=t[e.charCodeAt(r)];if(255===u)return;for(var h=0,d=i-1;(0!==u||h<o)&&-1!==d;d--,h++)u+=s*f[d]>>>0,f[d]=u%256>>>0,u=u/256>>>0;if(0!==u)throw new Error("Non-zero carry");o=h,r++}if(" "!==e[r]){for(var l=i-o;l!==i&&0===f[l];)l++;for(var p=new Uint8Array(n+(i-l)),y=n;l!==i;)p[y++]=f[l++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,o=0,i=t.length;o!==i&&0===t[o];)o++,r++;for(var a=(i-o)*f+1>>>0,u=new Uint8Array(a);o!==i;){for(var h=t[o],d=0,l=a-1;(0!==h||d<n)&&-1!==l;l--,d++)h+=256*u[l]>>>0,u[l]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,o++}for(var p=a-n;p!==a&&0===u[p];)p++;for(var y=c.repeat(r);p<a;++p)y+=e.charAt(u[p]);return y},decodeUnsafe:u,decode:function(e){var t=u(e);if(t)return t;throw new Error("Non-base"+s+" character")}}}},341:e=>{e.exports=function e(t){if("number"==typeof t&&isNaN(t))throw new Error("NaN is not allowed");if("number"==typeof t&&!isFinite(t))throw new Error("Infinity is not allowed");return null===t||"object"!=typeof t?JSON.stringify(t):t.toJSON instanceof Function?e(t.toJSON()):Array.isArray(t)?`[${t.reduce(((t,r,n)=>`${t}${0===n?"":","}${e(void 0===r||"symbol"==typeof r?null:r)}`),"")}]`:`{${Object.keys(t).sort().reduce(((r,n)=>void 0===t[n]||"symbol"==typeof t[n]?r:`${r}${0===r.length?"":","}${e(n)}:${e(t[n])}`),"")}}`}},417:e=>{e.exports={rfc4648:e=>t=>({encode:r=>((e,t,r)=>{const n="="===t[t.length-1],o=(1<<r)-1;let i="",s=0,c=0;for(let n=0;n<e.length;++n)for(c=c<<8|e[n],s+=8;s>r;)s-=r,i+=t[o&c>>s];if(s&&(i+=t[o&c<<r-s]),n)for(;i.length*r&7;)i+="=";return i})(r,t,e),decode:r=>((e,t,r)=>{const n={};for(let e=0;e<t.length;++e)n[t[e]]=e;let o=e.length;for(;"="===e[o-1];)--o;const i=new Uint8Array(o*r/8|0);let s=0,c=0,a=0;for(let t=0;t<o;++t){const o=n[e[t]];if(void 0===o)throw new SyntaxError("Invalid character "+e[t]);c=c<<r|o,s+=r,s>=8&&(s-=8,i[a++]=255&c>>s)}if(s>=r||255&c<<8-s)throw new SyntaxError("Unexpected end of data");return i})(r,t,e)})}},466:(e,t,r)=>{const n=r(579),{encodeText:o,decodeText:i,concat:s}=r(703);function c(e){if(Object.prototype.hasOwnProperty.call(n.names,e))return n.names[e];if(Object.prototype.hasOwnProperty.call(n.codes,e))return n.codes[e];throw new Error(`Unsupported encoding: ${e}`)}(t=e.exports=function(e,t){if(!t)throw new Error("requires an encoded Uint8Array");const{name:r,codeBuf:n}=c(e);return function(e,t){c(e).decode(i(t))}(r,t),s([n,t],n.length+t.length)}).encode=function(e,t){const r=c(e),n=o(r.encode(t));return s([r.codeBuf,n],r.codeBuf.length+n.length)},t.decode=function(e){e instanceof Uint8Array&&(e=i(e));const t=e[0];return["f","F","v","V","t","T","b","B","c","C","h","k","K"].includes(t)&&(e=e.toLowerCase()),c(e[0]).decode(e.substring(1))},t.isEncoded=function(e){if(e instanceof Uint8Array&&(e=i(e)),"[object String]"!==Object.prototype.toString.call(e))return!1;try{return c(e[0]).name}catch(e){return!1}},t.encoding=c,t.encodingFromData=function(e){return e instanceof Uint8Array&&(e=i(e)),c(e[0])};const a=Object.freeze(n.names),f=Object.freeze(n.codes);t.names=a,t.codes=f},579:(e,t,r)=>{const n=r(84),o=r(633),{rfc4648:i}=r(417),{decodeText:s,encodeText:c}=r(703),a=[["identity","\0",()=>({encode:s,decode:c}),""],["base2","0",i(1),"01"],["base8","7",i(3),"01234567"],["base10","9",n,"0123456789"],["base16","f",i(4),"0123456789abcdef"],["base16upper","F",i(4),"0123456789ABCDEF"],["base32hex","v",i(5),"0123456789abcdefghijklmnopqrstuv"],["base32hexupper","V",i(5),"0123456789ABCDEFGHIJKLMNOPQRSTUV"],["base32hexpad","t",i(5),"0123456789abcdefghijklmnopqrstuv="],["base32hexpadupper","T",i(5),"0123456789ABCDEFGHIJKLMNOPQRSTUV="],["base32","b",i(5),"abcdefghijklmnopqrstuvwxyz234567"],["base32upper","B",i(5),"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"],["base32pad","c",i(5),"abcdefghijklmnopqrstuvwxyz234567="],["base32padupper","C",i(5),"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567="],["base32z","h",i(5),"ybndrfg8ejkmcpqxot1uwisza345h769"],["base36","k",n,"0123456789abcdefghijklmnopqrstuvwxyz"],["base36upper","K",n,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"],["base58btc","z",n,"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],["base58flickr","Z",n,"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],["base64","m",i(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],["base64pad","M",i(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="],["base64url","u",i(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"],["base64urlpad","U",i(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_="]],f=a.reduce(((e,t)=>(e[t[0]]=new o(t[0],t[1],t[2],t[3]),e)),{}),u=a.reduce(((e,t)=>(e[t[1]]=f[t[0]],e)),{});e.exports={names:f,codes:u}},633:(e,t,r)=>{const{encodeText:n}=r(703);e.exports=class{constructor(e,t,r,o){this.name=e,this.code=t,this.codeBuf=n(this.code),this.alphabet=o,this.codec=r(o)}encode(e){return this.codec.encode(e)}decode(e){for(const t of e)if(this.alphabet&&this.alphabet.indexOf(t)<0)throw new Error(`invalid character '${t}' in '${e}'`);return this.codec.decode(e)}}},703:e=>{const t=new TextDecoder,r=new TextEncoder;e.exports={decodeText:e=>t.decode(e),encodeText:e=>r.encode(e),concat:function(e,t){const r=new Uint8Array(t);let n=0;for(const t of e)r.set(t,n),n+=t.length;return r}}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};r.r(n),r.d(n,{identity:()=>O});var o={};r.r(o),r.d(o,{base2:()=>T});var i={};r.r(i),r.d(i,{base8:()=>R});var s={};r.r(s),r.d(s,{base10:()=>N});var c={};r.r(c),r.d(c,{base16:()=>K,base16upper:()=>L});var a={};r.r(a),r.d(a,{base32:()=>C,base32hex:()=>$,base32hexpad:()=>z,base32hexpadupper:()=>V,base32hexupper:()=>H,base32pad:()=>_,base32padupper:()=>j,base32upper:()=>D,base32z:()=>F});var f={};r.r(f),r.d(f,{base36:()=>J,base36upper:()=>W});var u={};r.r(u),r.d(u,{base58btc:()=>M,base58flickr:()=>q});var h={};r.r(h),r.d(h,{base64:()=>G,base64pad:()=>Z,base64url:()=>X,base64urlpad:()=>Y});var d={};r.r(d),r.d(d,{base256emoji:()=>re});var l={};r.r(l),r.d(l,{sha256:()=>Se,sha512:()=>Ie});var p={};r.r(p),r.d(p,{identity:()=>Ue});var y={};r.r(y),r.d(y,{code:()=>Oe,decode:()=>Re,encode:()=>Te,name:()=>Pe});var g={};function w(e){return null!=globalThis.Buffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function b(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?w(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}function m(e,t){t||(t=e.reduce(((e,t)=>e+t.length),0));const r=b(t);let n=0;for(const t of e)r.set(t,n),n+=t.length;return w(r)}r.r(g),r.d(g,{code:()=>Ce,decode:()=>_e,encode:()=>De,name:()=>Le});const v=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(255!==r[s])throw new TypeError(i+" is ambiguous");r[s]=o}var c=e.length,a=e.charAt(0),f=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function h(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,o=0;e[t]===a;)n++,t++;for(var i=(e.length-t)*f+1>>>0,s=new Uint8Array(i);e[t];){var u=r[e.charCodeAt(t)];if(255===u)return;for(var h=0,d=i-1;(0!==u||h<o)&&-1!==d;d--,h++)u+=c*s[d]>>>0,s[d]=u%256>>>0,u=u/256>>>0;if(0!==u)throw new Error("Non-zero carry");o=h,t++}if(" "!==e[t]){for(var l=i-o;l!==i&&0===s[l];)l++;for(var p=new Uint8Array(n+(i-l)),y=n;l!==i;)p[y++]=s[l++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,o=0,i=t.length;o!==i&&0===t[o];)o++,r++;for(var s=(i-o)*u+1>>>0,f=new Uint8Array(s);o!==i;){for(var h=t[o],d=0,l=s-1;(0!==h||d<n)&&-1!==l;l--,d++)h+=256*f[l]>>>0,f[l]=h%c>>>0,h=h/c>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,o++}for(var p=s-n;p!==s&&0===f[p];)p++;for(var y=a.repeat(r);p<s;++p)y+=e.charAt(f[p]);return y},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error(`Non-${t} character`)}}},E=(new Uint8Array(0),e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")});class x{constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class A{constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"==typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return S(this,e)}}class B{constructor(e){this.decoders=e}or(e){return S(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const S=(e,t)=>new B({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class I{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new x(e,t,r),this.decoder=new A(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const k=({name:e,prefix:t,encode:r,decode:n})=>new I(e,t,r,n),U=({prefix:e,name:t,alphabet:r})=>{const{encode:n,decode:o}=v(r,t);return k({prefix:e,name:t,encode:n,decode:e=>E(o(e))})},P=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>k({prefix:t,name:e,encode:e=>((e,t,r)=>{const n="="===t[t.length-1],o=(1<<r)-1;let i="",s=0,c=0;for(let n=0;n<e.length;++n)for(c=c<<8|e[n],s+=8;s>r;)s-=r,i+=t[o&c>>s];if(s&&(i+=t[o&c<<r-s]),n)for(;i.length*r&7;)i+="=";return i})(e,n,r),decode:t=>((e,t,r,n)=>{const o={};for(let e=0;e<t.length;++e)o[t[e]]=e;let i=e.length;for(;"="===e[i-1];)--i;const s=new Uint8Array(i*r/8|0);let c=0,a=0,f=0;for(let t=0;t<i;++t){const i=o[e[t]];if(void 0===i)throw new SyntaxError(`Non-${n} character`);a=a<<r|i,c+=r,c>=8&&(c-=8,s[f++]=255&a>>c)}if(c>=r||255&a<<8-c)throw new SyntaxError("Unexpected end of data");return s})(t,n,r,e)}),O=k({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>(e=>(new TextEncoder).encode(e))(e)}),T=P({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),R=P({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),N=U({prefix:"9",name:"base10",alphabet:"0123456789"}),K=P({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),L=P({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),C=P({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),D=P({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),_=P({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),j=P({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),$=P({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),H=P({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),z=P({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),V=P({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),F=P({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),J=U({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),W=U({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),M=U({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),q=U({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),G=P({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Z=P({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),X=P({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Y=P({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),Q=Array.from("๐Ÿš€๐Ÿชโ˜„๐Ÿ›ฐ๐ŸŒŒ๐ŸŒ‘๐ŸŒ’๐ŸŒ“๐ŸŒ”๐ŸŒ•๐ŸŒ–๐ŸŒ—๐ŸŒ˜๐ŸŒ๐ŸŒ๐ŸŒŽ๐Ÿ‰โ˜€๐Ÿ’ป๐Ÿ–ฅ๐Ÿ’พ๐Ÿ’ฟ๐Ÿ˜‚โค๐Ÿ˜๐Ÿคฃ๐Ÿ˜Š๐Ÿ™๐Ÿ’•๐Ÿ˜ญ๐Ÿ˜˜๐Ÿ‘๐Ÿ˜…๐Ÿ‘๐Ÿ˜๐Ÿ”ฅ๐Ÿฅฐ๐Ÿ’”๐Ÿ’–๐Ÿ’™๐Ÿ˜ข๐Ÿค”๐Ÿ˜†๐Ÿ™„๐Ÿ’ช๐Ÿ˜‰โ˜บ๐Ÿ‘Œ๐Ÿค—๐Ÿ’œ๐Ÿ˜”๐Ÿ˜Ž๐Ÿ˜‡๐ŸŒน๐Ÿคฆ๐ŸŽ‰๐Ÿ’žโœŒโœจ๐Ÿคท๐Ÿ˜ฑ๐Ÿ˜Œ๐ŸŒธ๐Ÿ™Œ๐Ÿ˜‹๐Ÿ’—๐Ÿ’š๐Ÿ˜๐Ÿ’›๐Ÿ™‚๐Ÿ’“๐Ÿคฉ๐Ÿ˜„๐Ÿ˜€๐Ÿ–ค๐Ÿ˜ƒ๐Ÿ’ฏ๐Ÿ™ˆ๐Ÿ‘‡๐ŸŽถ๐Ÿ˜’๐Ÿคญโฃ๐Ÿ˜œ๐Ÿ’‹๐Ÿ‘€๐Ÿ˜ช๐Ÿ˜‘๐Ÿ’ฅ๐Ÿ™‹๐Ÿ˜ž๐Ÿ˜ฉ๐Ÿ˜ก๐Ÿคช๐Ÿ‘Š๐Ÿฅณ๐Ÿ˜ฅ๐Ÿคค๐Ÿ‘‰๐Ÿ’ƒ๐Ÿ˜ณโœ‹๐Ÿ˜š๐Ÿ˜๐Ÿ˜ด๐ŸŒŸ๐Ÿ˜ฌ๐Ÿ™ƒ๐Ÿ€๐ŸŒท๐Ÿ˜ป๐Ÿ˜“โญโœ…๐Ÿฅบ๐ŸŒˆ๐Ÿ˜ˆ๐Ÿค˜๐Ÿ’ฆโœ”๐Ÿ˜ฃ๐Ÿƒ๐Ÿ’โ˜น๐ŸŽŠ๐Ÿ’˜๐Ÿ˜ โ˜๐Ÿ˜•๐ŸŒบ๐ŸŽ‚๐ŸŒป๐Ÿ˜๐Ÿ–•๐Ÿ’๐Ÿ™Š๐Ÿ˜น๐Ÿ—ฃ๐Ÿ’ซ๐Ÿ’€๐Ÿ‘‘๐ŸŽต๐Ÿคž๐Ÿ˜›๐Ÿ”ด๐Ÿ˜ค๐ŸŒผ๐Ÿ˜ซโšฝ๐Ÿค™โ˜•๐Ÿ†๐Ÿคซ๐Ÿ‘ˆ๐Ÿ˜ฎ๐Ÿ™†๐Ÿป๐Ÿƒ๐Ÿถ๐Ÿ’๐Ÿ˜ฒ๐ŸŒฟ๐Ÿงก๐ŸŽโšก๐ŸŒž๐ŸŽˆโŒโœŠ๐Ÿ‘‹๐Ÿ˜ฐ๐Ÿคจ๐Ÿ˜ถ๐Ÿค๐Ÿšถ๐Ÿ’ฐ๐Ÿ“๐Ÿ’ข๐ŸคŸ๐Ÿ™๐Ÿšจ๐Ÿ’จ๐Ÿคฌโœˆ๐ŸŽ€๐Ÿบ๐Ÿค“๐Ÿ˜™๐Ÿ’Ÿ๐ŸŒฑ๐Ÿ˜–๐Ÿ‘ถ๐Ÿฅดโ–ถโžกโ“๐Ÿ’Ž๐Ÿ’ธโฌ‡๐Ÿ˜จ๐ŸŒš๐Ÿฆ‹๐Ÿ˜ท๐Ÿ•บโš ๐Ÿ™…๐Ÿ˜Ÿ๐Ÿ˜ต๐Ÿ‘Ž๐Ÿคฒ๐Ÿค ๐Ÿคง๐Ÿ“Œ๐Ÿ”ต๐Ÿ’…๐Ÿง๐Ÿพ๐Ÿ’๐Ÿ˜—๐Ÿค‘๐ŸŒŠ๐Ÿคฏ๐Ÿทโ˜Ž๐Ÿ’ง๐Ÿ˜ฏ๐Ÿ’†๐Ÿ‘†๐ŸŽค๐Ÿ™‡๐Ÿ‘โ„๐ŸŒด๐Ÿ’ฃ๐Ÿธ๐Ÿ’Œ๐Ÿ“๐Ÿฅ€๐Ÿคข๐Ÿ‘…๐Ÿ’ก๐Ÿ’ฉ๐Ÿ‘๐Ÿ“ธ๐Ÿ‘ป๐Ÿค๐Ÿคฎ๐ŸŽผ๐Ÿฅต๐Ÿšฉ๐ŸŽ๐ŸŠ๐Ÿ‘ผ๐Ÿ’๐Ÿ“ฃ๐Ÿฅ‚"),ee=Q.reduce(((e,t,r)=>(e[r]=t,e)),[]),te=Q.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]),re=k({prefix:"๐Ÿš€",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+ee[t]),"")},decode:function(e){const t=[];for(const r of e){const e=te[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}});var ne=128,oe=-128,ie=Math.pow(2,31),se=128,ce=127,ae=Math.pow(2,7),fe=Math.pow(2,14),ue=Math.pow(2,21),he=Math.pow(2,28),de=Math.pow(2,35),le=Math.pow(2,42),pe=Math.pow(2,49),ye=Math.pow(2,56),ge=Math.pow(2,63);const we={encode:function e(t,r,n){r=r||[];for(var o=n=n||0;t>=ie;)r[n++]=255&t|ne,t/=128;for(;t&oe;)r[n++]=255&t|ne,t>>>=7;return r[n]=0|t,e.bytes=n-o+1,r},decode:function e(t,r){var n,o=0,i=0,s=r=r||0,c=t.length;do{if(s>=c)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],o+=i<28?(n&ce)<<i:(n&ce)*Math.pow(2,i),i+=7}while(n>=se);return e.bytes=s-r,o},encodingLength:function(e){return e<ae?1:e<fe?2:e<ue?3:e<he?4:e<de?5:e<le?6:e<pe?7:e<ye?8:e<ge?9:10}},be=(e,t,r=0)=>(we.encode(e,t,r),t),me=e=>we.encodingLength(e),ve=(e,t)=>{const r=t.byteLength,n=me(e),o=n+me(r),i=new Uint8Array(o+r);return be(e,i,0),be(r,i,n),i.set(t,o),new Ee(e,r,t,i)};class Ee{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const xe=({name:e,code:t,encode:r})=>new Ae(e,t,r);class Ae{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?ve(this.code,t):t.then((e=>ve(this.code,e)))}throw Error("Unknown type, must be binary type")}}const Be=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),Se=xe({name:"sha2-256",code:18,encode:Be("SHA-256")}),Ie=xe({name:"sha2-512",code:19,encode:Be("SHA-512")}),ke=E,Ue={code:0,name:"identity",encode:ke,digest:e=>ve(0,ke(e))},Pe="raw",Oe=85,Te=e=>E(e),Re=e=>E(e),Ne=new TextEncoder,Ke=new TextDecoder,Le="json",Ce=512,De=e=>Ne.encode(JSON.stringify(e)),_e=e=>JSON.parse(Ke.decode(e));Symbol.toStringTag,Symbol.for("nodejs.util.inspect.custom"),Symbol.for("@ipld/js-cid/CID");const je={...n,...o,...i,...s,...c,...a,...f,...u,...h,...d};function $e(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const He=$e("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),ze=$e("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=b((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),Ve={utf8:He,"utf-8":He,hex:je.base16,latin1:ze,ascii:ze,binary:ze,...je};function Fe(e,t="utf8"){const r=Ve[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?r.decoder.decode(`${r.prefix}${e}`):w(globalThis.Buffer.from(e,"utf-8"))}function Je(e,t="utf8"){const r=Ve[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?r.encoder.encode(e).substring(1):globalThis.Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("utf8")}const We="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function Me(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function qe(e,...t){if(!((r=e)instanceof Uint8Array||ArrayBuffer.isView(r)&&"Uint8Array"===r.constructor.name))throw new Error("Uint8Array expected");var r;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Ge(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Ze(e,t){qe(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Xe(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Ye(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Qe(e,t){return e<<32-t|e>>>t}function et(e,t){return e<<t|e>>>32-t>>>0}const tt=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])()?e=>e:function(e){for(let r=0;r<e.length;r++)e[r]=(t=e[r])<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;var t;return e};function rt(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e)),qe(e),e}class nt{}function ot(e){const t=t=>e().update(rt(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function it(e=32){if(We&&"function"==typeof We.getRandomValues)return We.getRandomValues(new Uint8Array(e));if(We&&"function"==typeof We.randomBytes)return Uint8Array.from(We.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function st(e,t,r){return e&t^e&r^t&r}class ct extends nt{constructor(e,t,r,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.buffer=new Uint8Array(e),this.view=Ye(this.buffer)}update(e){Ge(this),qe(e=rt(e));const{view:t,buffer:r,blockLen:n}=this,o=e.length;for(let i=0;i<o;){const s=Math.min(n-this.pos,o-i);if(s!==n)r.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===n&&(this.process(t,0),this.pos=0);else{const t=Ye(e);for(;n<=o-i;i+=n)this.process(t,i)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ge(this),Ze(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:n,isLE:o}=this;let{pos:i}=this;t[i++]=128,Xe(this.buffer.subarray(i)),this.padOffset>n-i&&(this.process(r,0),i=0);for(let e=i;e<n;e++)t[e]=0;!function(e,t,r,n){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,n);const o=BigInt(32),i=BigInt(4294967295),s=Number(r>>o&i),c=Number(r&i),a=n?4:0,f=n?0:4;e.setUint32(t+a,s,n),e.setUint32(t+f,c,n)}(r,n-8,BigInt(8*this.length),o),this.process(r,0);const s=Ye(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const a=c/4,f=this.get();if(a>f.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<a;e++)s.setUint32(4*e,f[e],o)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:n,finished:o,destroyed:i,pos:s}=this;return e.destroyed=i,e.finished=o,e.length=n,e.pos=s,n%t&&e.buffer.set(r),e}clone(){return this._cloneInto()}}const at=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ft=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),ut=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),ht=BigInt(2**32-1),dt=BigInt(32);function lt(e,t=!1){return t?{h:Number(e&ht),l:Number(e>>dt&ht)}:{h:0|Number(e>>dt&ht),l:0|Number(e&ht)}}function pt(e,t=!1){const r=e.length;let n=new Uint32Array(r),o=new Uint32Array(r);for(let i=0;i<r;i++){const{h:r,l:s}=lt(e[i],t);[n[i],o[i]]=[r,s]}return[n,o]}const yt=(e,t,r)=>e>>>r,gt=(e,t,r)=>e<<32-r|t>>>r,wt=(e,t,r)=>e>>>r|t<<32-r,bt=(e,t,r)=>e<<32-r|t>>>r,mt=(e,t,r)=>e<<64-r|t>>>r-32,vt=(e,t,r)=>e>>>r-32|t<<64-r;function Et(e,t,r,n){const o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:0|o}}const xt=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),At=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,Bt=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),St=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,It=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),kt=(e,t,r,n,o,i)=>t+r+n+o+i+(e/2**32|0)|0,Ut=Uint32Array.from([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]),Pt=new Uint32Array(64);class Ot extends ct{constructor(e=32){super(64,e,8,!1),this.A=0|at[0],this.B=0|at[1],this.C=0|at[2],this.D=0|at[3],this.E=0|at[4],this.F=0|at[5],this.G=0|at[6],this.H=0|at[7]}get(){const{A:e,B:t,C:r,D:n,E:o,F:i,G:s,H:c}=this;return[e,t,r,n,o,i,s,c]}set(e,t,r,n,o,i,s,c){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|o,this.F=0|i,this.G=0|s,this.H=0|c}process(e,t){for(let r=0;r<16;r++,t+=4)Pt[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=Pt[e-15],r=Pt[e-2],n=Qe(t,7)^Qe(t,18)^t>>>3,o=Qe(r,17)^Qe(r,19)^r>>>10;Pt[e]=o+Pt[e-7]+n+Pt[e-16]|0}let{A:r,B:n,C:o,D:i,E:s,F:c,G:a,H:f}=this;for(let e=0;e<64;e++){const t=f+(Qe(s,6)^Qe(s,11)^Qe(s,25))+((u=s)&c^~u&a)+Ut[e]+Pt[e]|0,h=(Qe(r,2)^Qe(r,13)^Qe(r,22))+st(r,n,o)|0;f=a,a=c,c=s,s=i+t|0,i=o,o=n,n=r,r=t+h|0}var u;r=r+this.A|0,n=n+this.B|0,o=o+this.C|0,i=i+this.D|0,s=s+this.E|0,c=c+this.F|0,a=a+this.G|0,f=f+this.H|0,this.set(r,n,o,i,s,c,a,f)}roundClean(){Xe(Pt)}destroy(){this.set(0,0,0,0,0,0,0,0),Xe(this.buffer)}}const Tt=(()=>pt(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((e=>BigInt(e)))))(),Rt=(()=>Tt[0])(),Nt=(()=>Tt[1])(),Kt=new Uint32Array(80),Lt=new Uint32Array(80);class Ct extends ct{constructor(e=64){super(128,e,16,!1),this.Ah=0|ut[0],this.Al=0|ut[1],this.Bh=0|ut[2],this.Bl=0|ut[3],this.Ch=0|ut[4],this.Cl=0|ut[5],this.Dh=0|ut[6],this.Dl=0|ut[7],this.Eh=0|ut[8],this.El=0|ut[9],this.Fh=0|ut[10],this.Fl=0|ut[11],this.Gh=0|ut[12],this.Gl=0|ut[13],this.Hh=0|ut[14],this.Hl=0|ut[15]}get(){const{Ah:e,Al:t,Bh:r,Bl:n,Ch:o,Cl:i,Dh:s,Dl:c,Eh:a,El:f,Fh:u,Fl:h,Gh:d,Gl:l,Hh:p,Hl:y}=this;return[e,t,r,n,o,i,s,c,a,f,u,h,d,l,p,y]}set(e,t,r,n,o,i,s,c,a,f,u,h,d,l,p,y){this.Ah=0|e,this.Al=0|t,this.Bh=0|r,this.Bl=0|n,this.Ch=0|o,this.Cl=0|i,this.Dh=0|s,this.Dl=0|c,this.Eh=0|a,this.El=0|f,this.Fh=0|u,this.Fl=0|h,this.Gh=0|d,this.Gl=0|l,this.Hh=0|p,this.Hl=0|y}process(e,t){for(let r=0;r<16;r++,t+=4)Kt[r]=e.getUint32(t),Lt[r]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|Kt[e-15],r=0|Lt[e-15],n=wt(t,r,1)^wt(t,r,8)^yt(t,0,7),o=bt(t,r,1)^bt(t,r,8)^gt(t,r,7),i=0|Kt[e-2],s=0|Lt[e-2],c=wt(i,s,19)^mt(i,s,61)^yt(i,0,6),a=bt(i,s,19)^vt(i,s,61)^gt(i,s,6),f=Bt(o,a,Lt[e-7],Lt[e-16]),u=St(f,n,c,Kt[e-7],Kt[e-16]);Kt[e]=0|u,Lt[e]=0|f}let{Ah:r,Al:n,Bh:o,Bl:i,Ch:s,Cl:c,Dh:a,Dl:f,Eh:u,El:h,Fh:d,Fl:l,Gh:p,Gl:y,Hh:g,Hl:w}=this;for(let e=0;e<80;e++){const t=wt(u,h,14)^wt(u,h,18)^mt(u,h,41),b=bt(u,h,14)^bt(u,h,18)^vt(u,h,41),m=u&d^~u&p,v=It(w,b,h&l^~h&y,Nt[e],Lt[e]),E=kt(v,g,t,m,Rt[e],Kt[e]),x=0|v,A=wt(r,n,28)^mt(r,n,34)^mt(r,n,39),B=bt(r,n,28)^vt(r,n,34)^vt(r,n,39),S=r&o^r&s^o&s,I=n&i^n&c^i&c;g=0|p,w=0|y,p=0|d,y=0|l,d=0|u,l=0|h,({h:u,l:h}=Et(0|a,0|f,0|E,0|x)),a=0|s,f=0|c,s=0|o,c=0|i,o=0|r,i=0|n;const k=xt(x,B,I);r=At(k,E,A,S),n=0|k}({h:r,l:n}=Et(0|this.Ah,0|this.Al,0|r,0|n)),({h:o,l:i}=Et(0|this.Bh,0|this.Bl,0|o,0|i)),({h:s,l:c}=Et(0|this.Ch,0|this.Cl,0|s,0|c)),({h:a,l:f}=Et(0|this.Dh,0|this.Dl,0|a,0|f)),({h:u,l:h}=Et(0|this.Eh,0|this.El,0|u,0|h)),({h:d,l}=Et(0|this.Fh,0|this.Fl,0|d,0|l)),({h:p,l:y}=Et(0|this.Gh,0|this.Gl,0|p,0|y)),({h:g,l:w}=Et(0|this.Hh,0|this.Hl,0|g,0|w)),this.set(r,n,o,i,s,c,a,f,u,h,d,l,p,y,g,w)}roundClean(){Xe(Kt,Lt)}destroy(){Xe(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class Dt extends Ct{constructor(){super(48),this.Ah=0|ft[0],this.Al=0|ft[1],this.Bh=0|ft[2],this.Bl=0|ft[3],this.Ch=0|ft[4],this.Cl=0|ft[5],this.Dh=0|ft[6],this.Dl=0|ft[7],this.Eh=0|ft[8],this.El=0|ft[9],this.Fh=0|ft[10],this.Fl=0|ft[11],this.Gh=0|ft[12],this.Gl=0|ft[13],this.Hh=0|ft[14],this.Hl=0|ft[15]}}const _t=ot((()=>new Ot)),jt=ot((()=>new Ct)),$t=ot((()=>new Dt)),Ht=BigInt(0),zt=BigInt(1);function Vt(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function Ft(e){if(!Vt(e))throw new Error("Uint8Array expected")}function Jt(e,t){if("boolean"!=typeof t)throw new Error(e+" boolean expected, got "+t)}function Wt(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function Mt(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?Ht:BigInt("0x"+e)}const qt="function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex,Gt=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function Zt(e){if(Ft(e),qt)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Gt[e[r]];return t}function Xt(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function Yt(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(qt)return Uint8Array.fromHex(e);const t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(r);for(let t=0,o=0;t<r;t++,o+=2){const r=Xt(e.charCodeAt(o)),i=Xt(e.charCodeAt(o+1));if(void 0===r||void 0===i){const t=e[o]+e[o+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+o)}n[t]=16*r+i}return n}function Qt(e){return Mt(Zt(e))}function er(e){return Ft(e),Mt(Zt(Uint8Array.from(e).reverse()))}function tr(e,t){return Yt(e.toString(16).padStart(2*t,"0"))}function rr(e,t){return tr(e,t).reverse()}function nr(e,t,r){let n;if("string"==typeof t)try{n=Yt(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!Vt(t))throw new Error(e+" must be hex string or Uint8Array");n=Uint8Array.from(t)}const o=n.length;if("number"==typeof r&&o!==r)throw new Error(e+" of length "+r+" expected, got "+o);return n}function or(...e){let t=0;for(let r=0;r<e.length;r++){const n=e[r];Ft(n),t+=n.length}const r=new Uint8Array(t);for(let t=0,n=0;t<e.length;t++){const o=e[t];r.set(o,n),n+=o.length}return r}const ir=e=>"bigint"==typeof e&&Ht<=e;function sr(e,t,r){return ir(e)&&ir(t)&&ir(r)&&t<=e&&e<r}function cr(e,t,r,n){if(!sr(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}const ar=e=>(zt<<BigInt(e))-zt,fr=e=>new Uint8Array(e),ur=e=>Uint8Array.from(e),hr={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||Vt(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};function dr(e,t,r={}){const n=(t,r,n)=>{const o=hr[r];if("function"!=typeof o)throw new Error("invalid validator function");const i=e[t];if(!(n&&void 0===i||o(i,e)))throw new Error("param "+String(t)+" is invalid. Expected "+r+", got "+i)};for(const[e,r]of Object.entries(t))n(e,r,!1);for(const[e,t]of Object.entries(r))n(e,t,!0);return e}function lr(e){const t=new WeakMap;return(r,...n)=>{const o=t.get(r);if(void 0!==o)return o;const i=e(r,...n);return t.set(r,i),i}}const pr=BigInt(0),yr=BigInt(1),gr=BigInt(2),wr=BigInt(3),br=BigInt(4),mr=BigInt(5),vr=BigInt(8);function Er(e,t){const r=e%t;return r>=pr?r:t+r}function xr(e,t,r){let n=e;for(;t-- >pr;)n*=n,n%=r;return n}function Ar(e,t){if(e===pr)throw new Error("invert: expected non-zero number");if(t<=pr)throw new Error("invert: expected positive modulus, got "+t);let r=Er(e,t),n=t,o=pr,i=yr,s=yr,c=pr;for(;r!==pr;){const e=n/r,t=n%r,a=o-s*e,f=i-c*e;n=r,r=t,o=s,i=c,s=a,c=f}if(n!==yr)throw new Error("invert: does not exist");return Er(o,t)}function Br(e,t){const r=(e.ORDER+yr)/br,n=e.pow(t,r);if(!e.eql(e.sqr(n),t))throw new Error("Cannot find square root");return n}function Sr(e,t){const r=(e.ORDER-mr)/vr,n=e.mul(t,gr),o=e.pow(n,r),i=e.mul(t,o),s=e.mul(e.mul(i,gr),o),c=e.mul(i,e.sub(s,e.ONE));if(!e.eql(e.sqr(c),t))throw new Error("Cannot find square root");return c}const Ir=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function kr(e,t,r=!1){const n=new Array(t.length).fill(r?e.ZERO:void 0),o=t.reduce(((t,r,o)=>e.is0(r)?t:(n[o]=t,e.mul(t,r))),e.ONE),i=e.inv(o);return t.reduceRight(((t,r,o)=>e.is0(r)?t:(n[o]=e.mul(t,n[o]),e.mul(t,r))),i),n}function Ur(e,t){const r=(e.ORDER-yr)/gr,n=e.pow(t,r),o=e.eql(n,e.ONE),i=e.eql(n,e.ZERO),s=e.eql(n,e.neg(e.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function Pr(e,t){void 0!==t&&Me(t);const r=void 0!==t?t:e.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function Or(e,t,r=!1,n={}){if(e<=pr)throw new Error("invalid field: expected ORDER > 0, got "+e);const{nBitLength:o,nByteLength:i}=Pr(e,t);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s;const c=Object.freeze({ORDER:e,isLE:r,BITS:o,BYTES:i,MASK:ar(o),ZERO:pr,ONE:yr,create:t=>Er(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return pr<=t&&t<e},is0:e=>e===pr,isOdd:e=>(e&yr)===yr,neg:t=>Er(-t,e),eql:(e,t)=>e===t,sqr:t=>Er(t*t,e),add:(t,r)=>Er(t+r,e),sub:(t,r)=>Er(t-r,e),mul:(t,r)=>Er(t*r,e),pow:(e,t)=>function(e,t,r){if(r<pr)throw new Error("invalid exponent, negatives unsupported");if(r===pr)return e.ONE;if(r===yr)return t;let n=e.ONE,o=t;for(;r>pr;)r&yr&&(n=e.mul(n,o)),o=e.sqr(o),r>>=yr;return n}(c,e,t),div:(t,r)=>Er(t*Ar(r,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>Ar(t,e),sqrt:n.sqrt||(t=>{return s||(s=(r=e)%br===wr?Br:r%vr===mr?Sr:function(e){if(e<BigInt(3))throw new Error("sqrt is not defined for small field");let t=e-yr,r=0;for(;t%gr===pr;)t/=gr,r++;let n=gr;const o=Or(e);for(;1===Ur(o,n);)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===r)return Br;let i=o.pow(n,t);const s=(t+yr)/gr;return function(e,n){if(e.is0(n))return n;if(1!==Ur(e,n))throw new Error("Cannot find square root");let o=r,c=e.mul(e.ONE,i),a=e.pow(n,t),f=e.pow(n,s);for(;!e.eql(a,e.ONE);){if(e.is0(a))return e.ZERO;let t=1,r=e.sqr(a);for(;!e.eql(r,e.ONE);)if(t++,r=e.sqr(r),t===o)throw new Error("Cannot find square root");const n=yr<<BigInt(o-t-1),i=e.pow(c,n);o=t,c=e.sqr(i),a=e.mul(a,c),f=e.mul(f,i)}return f}}(r)),s(c,t);var r}),toBytes:e=>r?rr(e,i):tr(e,i),fromBytes:e=>{if(e.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+e.length);return r?er(e):Qt(e)},invertBatch:e=>kr(c,e),cmov:(e,t,r)=>r?t:e});return Object.freeze(c)}function Tr(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function Rr(e){const t=Tr(e);return t+Math.ceil(t/2)}const Nr=BigInt(0),Kr=BigInt(1);function Lr(e,t){const r=t.negate();return e?r:t}function Cr(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Dr(e,t){Cr(e,t);const r=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:ar(e),maxNumber:r,shiftBy:BigInt(e)}}function _r(e,t,r){const{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r;let c=Number(e&o),a=e>>s;c>n&&(c-=i,a+=Kr);const f=t*n;return{nextN:a,offset:f+Math.abs(c)-1,isZero:0===c,isNeg:c<0,isNegF:t%2!=0,offsetF:f}}const jr=new WeakMap,$r=new WeakMap;function Hr(e){return $r.get(e)||1}function zr(e,t){return{constTimeNegate:Lr,hasPrecomputes:e=>1!==Hr(e),unsafeLadder(t,r,n=e.ZERO){let o=t;for(;r>Nr;)r&Kr&&(n=n.add(o)),o=o.double(),r>>=Kr;return n},precomputeWindow(e,r){const{windows:n,windowSize:o}=Dr(r,t),i=[];let s=e,c=s;for(let e=0;e<n;e++){c=s,i.push(c);for(let e=1;e<o;e++)c=c.add(s),i.push(c);s=c.double()}return i},wNAF(r,n,o){let i=e.ZERO,s=e.BASE;const c=Dr(r,t);for(let e=0;e<c.windows;e++){const{nextN:t,offset:r,isZero:a,isNeg:f,isNegF:u,offsetF:h}=_r(o,e,c);o=t,a?s=s.add(Lr(u,n[h])):i=i.add(Lr(f,n[r]))}return{p:i,f:s}},wNAFUnsafe(r,n,o,i=e.ZERO){const s=Dr(r,t);for(let e=0;e<s.windows&&o!==Nr;e++){const{nextN:t,offset:r,isZero:c,isNeg:a}=_r(o,e,s);if(o=t,!c){const e=n[r];i=i.add(a?e.negate():e)}}return i},getPrecomputes(e,t,r){let n=jr.get(t);return n||(n=this.precomputeWindow(t,e),1!==e&&jr.set(t,r(n))),n},wNAFCached(e,t,r){const n=Hr(e);return this.wNAF(n,this.getPrecomputes(n,e,r),t)},wNAFCachedUnsafe(e,t,r,n){const o=Hr(e);return 1===o?this.unsafeLadder(e,t,n):this.wNAFUnsafe(o,this.getPrecomputes(o,e,r),t,n)},setWindowSize(e,r){Cr(r,t),$r.set(e,r),jr.delete(e)}}}function Vr(e,t,r,n){(function(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach(((e,r)=>{if(!(e instanceof t))throw new Error("invalid point at index "+r)}))})(r,e),function(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach(((e,r)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+r)}))}(n,t);const o=r.length,i=n.length;if(o!==i)throw new Error("arrays of points and scalars must have equal length");const s=e.ZERO,c=function(e){let t;for(t=0;e>Ht;e>>=zt,t+=1);return t}(BigInt(o));let a=1;c>12?a=c-3:c>4?a=c-2:c>0&&(a=2);const f=ar(a),u=new Array(Number(f)+1).fill(s);let h=s;for(let e=Math.floor((t.BITS-1)/a)*a;e>=0;e-=a){u.fill(s);for(let t=0;t<i;t++){const o=n[t],i=Number(o>>BigInt(e)&f);u[i]=u[i].add(r[t])}let t=s;for(let e=u.length-1,r=s;e>0;e--)r=r.add(u[e]),t=t.add(r);if(h=h.add(t),0!==e)for(let e=0;e<a;e++)h=h.double()}return h}function Fr(e){return dr(e.Fp,Ir.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),dr(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Pr(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}const Jr=BigInt(0),Wr=BigInt(1),Mr=BigInt(2),qr=BigInt(8),Gr={zip215:!0};const Zr=BigInt(0),Xr=BigInt(1),Yr=BigInt(2);const Qr=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),en=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),tn=(BigInt(0),BigInt(1)),rn=BigInt(2),nn=BigInt(3),on=BigInt(5),sn=BigInt(8);function cn(e){const t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=Qr,s=e*e%i*e%i,c=xr(s,rn,i)*s%i,a=xr(c,tn,i)*e%i,f=xr(a,on,i)*a%i,u=xr(f,t,i)*f%i,h=xr(u,r,i)*u%i,d=xr(h,n,i)*h%i,l=xr(d,o,i)*d%i,p=xr(l,o,i)*d%i,y=xr(p,t,i)*f%i;return{pow_p_5_8:xr(y,rn,i)*e%i,b2:s}}function an(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function fn(e,t){const r=Qr,n=Er(t*t*t,r),o=Er(n*n*t,r);let i=Er(e*n*cn(e*o).pow_p_5_8,r);const s=Er(t*i*i,r),c=i,a=Er(i*en,r),f=s===e,u=s===Er(-e,r),h=s===Er(-e*en,r);return f&&(i=c),(u||h)&&(i=a),(Er(i,r)&yr)===yr&&(i=Er(-i,r)),{isValid:f||u,value:i}}const un=(()=>Or(Qr,void 0,!0))(),hn=(()=>({a:un.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:un,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:sn,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:jt,randomBytes:it,adjustScalarBytes:an,uvRatio:fn}))(),dn=(()=>function(e){const t=function(e){const t=Fr(e);return dr(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}(e),{Fp:r,n,prehash:o,hash:i,randomBytes:s,nByteLength:c,h:a}=t,f=Mr<<BigInt(8*c)-Wr,u=r.create,h=Or(t.n,t.nBitLength);if(!function(e,n){const o=r.sqr(e),i=r.sqr(n),s=r.add(r.mul(t.a,o),i),c=r.add(r.ONE,r.mul(t.d,r.mul(o,i)));return r.eql(s,c)}(t.Gx,t.Gy))throw new Error("bad curve params: generator point");const d=t.uvRatio||((e,t)=>{try{return{isValid:!0,value:r.sqrt(e*r.inv(t))}}catch(e){return{isValid:!1,value:Jr}}}),l=t.adjustScalarBytes||(e=>e),p=t.domain||((e,t,r)=>{if(Jt("phflag",r),t.length||r)throw new Error("Contexts/pre-hash are not supported");return e});function y(e,t,r=!1){cr("coordinate "+e,t,r?Wr:Jr,f)}function g(e){if(!(e instanceof m))throw new Error("ExtendedPoint expected")}const w=lr(((e,t)=>{const{ex:n,ey:o,ez:i}=e,s=e.is0();null==t&&(t=s?qr:r.inv(i));const c=u(n*t),a=u(o*t),f=u(i*t);if(s)return{x:Jr,y:Wr};if(f!==Wr)throw new Error("invZ was invalid");return{x:c,y:a}})),b=lr((e=>{const{a:r,d:n}=t;if(e.is0())throw new Error("bad point: ZERO");const{ex:o,ey:i,ez:s,et:c}=e,a=u(o*o),f=u(i*i),h=u(s*s),d=u(h*h),l=u(a*r);if(u(h*u(l+f))!==u(d+u(n*u(a*f))))throw new Error("bad point: equation left != right (1)");if(u(o*i)!==u(s*c))throw new Error("bad point: equation left != right (2)");return!0}));class m{constructor(e,t,r,n){y("x",e),y("y",t),y("z",r,!0),y("t",n),this.ex=e,this.ey=t,this.ez=r,this.et=n,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(e){if(e instanceof m)throw new Error("extended point not allowed");const{x:t,y:r}=e||{};return y("x",t),y("y",r),new m(t,r,Wr,u(t*r))}static normalizeZ(e){const t=kr(r,e.map((e=>e.ez)));return e.map(((e,r)=>e.toAffine(t[r]))).map(m.fromAffine)}static msm(e,t){return Vr(m,h,e,t)}_setWindowSize(e){x.setWindowSize(this,e)}assertValidity(){b(this)}equals(e){g(e);const{ex:t,ey:r,ez:n}=this,{ex:o,ey:i,ez:s}=e,c=u(t*s),a=u(o*n),f=u(r*s),h=u(i*n);return c===a&&f===h}is0(){return this.equals(m.ZERO)}negate(){return new m(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){const{a:e}=t,{ex:r,ey:n,ez:o}=this,i=u(r*r),s=u(n*n),c=u(Mr*u(o*o)),a=u(e*i),f=r+n,h=u(u(f*f)-i-s),d=a+s,l=d-c,p=a-s,y=u(h*l),g=u(d*p),w=u(h*p),b=u(l*d);return new m(y,g,b,w)}add(e){g(e);const{a:r,d:n}=t,{ex:o,ey:i,ez:s,et:c}=this,{ex:a,ey:f,ez:h,et:d}=e,l=u(o*a),p=u(i*f),y=u(c*n*d),w=u(s*h),b=u((o+i)*(a+f)-l-p),v=w-y,E=w+y,x=u(p-r*l),A=u(b*v),B=u(E*x),S=u(b*x),I=u(v*E);return new m(A,B,I,S)}subtract(e){return this.add(e.negate())}wNAF(e){return x.wNAFCached(this,e,m.normalizeZ)}multiply(e){const t=e;cr("scalar",t,Wr,n);const{p:r,f:o}=this.wNAF(t);return m.normalizeZ([r,o])[0]}multiplyUnsafe(e,t=m.ZERO){const r=e;return cr("scalar",r,Jr,n),r===Jr?E:this.is0()||r===Wr?this:x.wNAFCachedUnsafe(this,r,m.normalizeZ,t)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return x.unsafeLadder(this,n).is0()}toAffine(e){return w(this,e)}clearCofactor(){const{h:e}=t;return e===Wr?this:this.multiplyUnsafe(e)}static fromHex(e,n=!1){const{d:o,a:i}=t,s=r.BYTES;e=nr("pointHex",e,s),Jt("zip215",n);const c=e.slice(),a=e[s-1];c[s-1]=-129&a;const h=er(c),l=n?f:r.ORDER;cr("pointHex.y",h,Jr,l);const p=u(h*h),y=u(p-Wr),g=u(o*p-i);let{isValid:w,value:b}=d(y,g);if(!w)throw new Error("Point.fromHex: invalid y coordinate");const v=(b&Wr)===Wr,E=!!(128&a);if(!n&&b===Jr&&E)throw new Error("Point.fromHex: x=0 and x_0=1");return E!==v&&(b=u(-b)),m.fromAffine({x:b,y:h})}static fromPrivateKey(e){const{scalar:t}=S(e);return v.multiply(t)}toRawBytes(){const{x:e,y:t}=this.toAffine(),n=rr(t,r.BYTES);return n[n.length-1]|=e&Wr?128:0,n}toHex(){return Zt(this.toRawBytes())}}m.BASE=new m(t.Gx,t.Gy,Wr,u(t.Gx*t.Gy)),m.ZERO=new m(Jr,Wr,Wr,Jr);const{BASE:v,ZERO:E}=m,x=zr(m,8*c);function A(e){return Er(e,n)}function B(e){return A(er(e))}function S(e){const t=r.BYTES;e=nr("private key",e,t);const n=nr("hashed private key",i(e),2*t),o=l(n.slice(0,t));return{head:o,prefix:n.slice(t,2*t),scalar:B(o)}}function I(e){const{head:t,prefix:r,scalar:n}=S(e),o=v.multiply(n),i=o.toRawBytes();return{head:t,prefix:r,scalar:n,point:o,pointBytes:i}}function k(e=Uint8Array.of(),...t){const r=or(...t);return B(i(p(r,nr("context",e),!!o)))}const U=Gr;return v._setWindowSize(8),{CURVE:t,getPublicKey:function(e){return I(e).pointBytes},sign:function(e,t,i={}){e=nr("message",e),o&&(e=o(e));const{prefix:s,scalar:c,pointBytes:a}=I(t),f=k(i.context,s,e),u=v.multiply(f).toRawBytes(),h=A(f+k(i.context,u,a,e)*c);return cr("signature.s",h,Jr,n),nr("result",or(u,rr(h,r.BYTES)),2*r.BYTES)},verify:function(e,t,n,i=U){const{context:s,zip215:c}=i,a=r.BYTES;e=nr("signature",e,2*a),t=nr("message",t),n=nr("publicKey",n,a),void 0!==c&&Jt("zip215",c),o&&(t=o(t));const f=er(e.slice(a,2*a));let u,h,d;try{u=m.fromHex(n,c),h=m.fromHex(e.slice(0,a),c),d=v.multiplyUnsafe(f)}catch(e){return!1}if(!c&&u.isSmallOrder())return!1;const l=k(s,h.toRawBytes(),u.toRawBytes(),t);return h.add(u.multiplyUnsafe(l)).subtract(d).clearCofactor().equals(m.ZERO)},ExtendedPoint:m,utils:{getExtendedPublicKey:I,randomPrivateKey:()=>s(r.BYTES),precompute:(e=8,t=m.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)}}}(hn))(),ln=(()=>function(e){const t=(dr(r=e,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...r}));var r;const{P:n,type:o,adjustScalarBytes:i,powPminus2:s}=t,c="x25519"===o;if(!c&&"x448"!==o)throw new Error("invalid type");const a=c?255:448,f=c?32:56,u=c?BigInt(9):BigInt(5),h=c?BigInt(121665):BigInt(39081),d=c?Yr**BigInt(254):Yr**BigInt(447),l=c?BigInt(8)*Yr**BigInt(251)-Xr:BigInt(4)*Yr**BigInt(445)-Xr,p=d+l+Xr,y=e=>Er(e,n),g=w(u);function w(e){return rr(y(e),f)}function b(e,t){const r=function(e,t){cr("u",e,Zr,n),cr("scalar",t,d,p);const r=t,o=e;let i=Xr,c=Zr,f=e,u=Xr,l=Zr;for(let e=BigInt(a-1);e>=Zr;e--){const t=r>>e&Xr;l^=t,({x_2:i,x_3:f}=v(l,i,f)),({x_2:c,x_3:u}=v(l,c,u)),l=t;const n=i+c,s=y(n*n),a=i-c,d=y(a*a),p=s-d,g=f+u,w=y((f-u)*n),b=y(g*a),m=w+b,E=w-b;f=y(m*m),u=y(o*y(E*E)),i=y(s*d),c=y(p*(s+y(h*p)))}({x_2:i,x_3:f}=v(l,i,f)),({x_2:c,x_3:u}=v(l,c,u));const g=s(c);return y(i*g)}(function(e){const t=nr("u coordinate",e,f);return c&&(t[31]&=127),y(er(t))}(t),function(e){return er(i(nr("scalar",e,f)))}(e));if(r===Zr)throw new Error("invalid private or public key received");return w(r)}function m(e){return b(e,g)}function v(e,t,r){const n=y(e*(t-r));return{x_2:t=y(t-n),x_3:r=y(r+n)}}return{scalarMult:b,scalarMultBase:m,getSharedSecret:(e,t)=>b(e,t),getPublicKey:e=>m(e),utils:{randomPrivateKey:()=>t.randomBytes(f)},GuBytes:g.slice()}}({P:Qr,type:"x25519",powPminus2:e=>{const t=Qr,{pow_p_5_8:r,b2:n}=cn(e);return Er(xr(r,nn,t)*n,t)},adjustScalarBytes:an,randomBytes:it}))();var pn=r(466);class yn extends nt{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");Me(e.outputLen),Me(e.blockLen)}(e);const r=rt(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?e.create().update(r).digest():r);for(let e=0;e<o.length;e++)o[e]^=54;this.iHash.update(o),this.oHash=e.create();for(let e=0;e<o.length;e++)o[e]^=106;this.oHash.update(o),Xe(o)}update(e){return Ge(this),this.iHash.update(e),this}digestInto(e){Ge(this),qe(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:r,finished:n,destroyed:o,blockLen:i,outputLen:s}=this;return e.finished=n,e.destroyed=o,e.blockLen=i,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const gn=(e,t,r)=>new yn(e,t).update(r).digest();function wn(e){void 0!==e.lowS&&Jt("lowS",e.lowS),void 0!==e.prehash&&Jt("prehash",e.prehash)}gn.create=(e,t)=>new yn(e,t);class bn extends Error{constructor(e=""){super(e)}}const mn={Err:bn,_tlv:{encode:(e,t)=>{const{Err:r}=mn;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(1&t.length)throw new r("tlv.encode: unpadded data");const n=t.length/2,o=Wt(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");const i=n>127?Wt(o.length/2|128):"";return Wt(e)+i+o+t},decode(e,t){const{Err:r}=mn;let n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");const o=t[n++];let i=0;if(128&o){const e=127&o;if(!e)throw new r("tlv.decode(long): indefinite length not supported");if(e>4)throw new r("tlv.decode(long): byte length is too big");const s=t.subarray(n,n+e);if(s.length!==e)throw new r("tlv.decode: length bytes not complete");if(0===s[0])throw new r("tlv.decode(long): zero leftmost byte");for(const e of s)i=i<<8|e;if(n+=e,i<128)throw new r("tlv.decode(long): not minimal encoding")}else i=o;const s=t.subarray(n,n+i);if(s.length!==i)throw new r("tlv.decode: wrong value length");return{v:s,l:t.subarray(n+i)}}},_int:{encode(e){const{Err:t}=mn;if(e<En)throw new t("integer: negative integers are not allowed");let r=Wt(e);if(8&Number.parseInt(r[0],16)&&(r="00"+r),1&r.length)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){const{Err:t}=mn;if(128&e[0])throw new t("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new t("invalid signature integer: unnecessary leading zero");return Qt(e)}},toSig(e){const{Err:t,_int:r,_tlv:n}=mn,o=nr("signature",e),{v:i,l:s}=n.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");const{v:c,l:a}=n.decode(2,i),{v:f,l:u}=n.decode(2,a);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(f)}},hexFromSig(e){const{_tlv:t,_int:r}=mn,n=t.encode(2,r.encode(e.r))+t.encode(2,r.encode(e.s));return t.encode(48,n)}};function vn(e,t){return Zt(tr(e,t))}const En=BigInt(0),xn=BigInt(1),An=(BigInt(2),BigInt(3)),Bn