@blockcerts/blockcerts-verifier 1.62.2 → 1.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle-stats.html +1 -1
- package/dist/{EcdsaSd2023-jnIXPui8-Ecil79Z6.js → EcdsaSd2023-DZGap3SM-mPG0cLDm.js} +7 -7
- package/dist/EcdsaSecp256k1Signature2019-n7E_p_GN-CK56BVKZ.js +1 -0
- package/dist/Ed25519Signature2020-_cT8vvaO-DsdBcpgb.js +52 -0
- package/dist/HashlinkVerifier-DgB7rgX8-dg5WNZnc.js +11 -0
- package/dist/{MerkleProof2017-Cy_nkz4C-gnoFFWMW.js → MerkleProof2017-C7joZBSg-D3Ose_hz.js} +1 -1
- package/dist/MerkleProof2019-B6RcT8nL-CW7PatZk.js +3 -0
- package/dist/checkCredentialSchemaConformity-BFdwoe1d-SeiEjHaf.js +1 -0
- package/dist/{controlVerificationMethod-BxseSDWK-Ghg2o_Hj.js → controlVerificationMethod-DZMPBpH4-DAL92l4K.js} +1 -1
- package/dist/did-key-common.esm-Dpr3yDzE-TRogf7i4.js +9 -0
- package/dist/did-key-ed25519.esm-Cds5njOI-zlZoO68S.js +1 -0
- package/dist/did-key-secp256k1.esm-D1IImaHL-CTenolkL.js +1 -0
- package/dist/elliptic-Bf4jfo3V-BRLTdj5Y.js +1 -0
- package/dist/{ensureValidIssuingKey-C7MTkDyV-frafTbMl.js → ensureValidIssuingKey-DVA5iNXJ-wu9SdYxL.js} +1 -1
- package/dist/index-ByRXJxEU-CtZ_5kyD.js +22 -0
- package/dist/index-CAl7T2GU-LqbKlBZ6.js +1 -0
- package/dist/index-Chj6rFU_-DwRdQV-L.js +60 -0
- package/dist/index-DsWS3N1O-C0eXpZGn.js +1 -0
- package/dist/jsonld-CkyvX_Vg-C61cS9xX.js +33 -0
- package/dist/main.js +110 -111
- package/dist/{retrieveVerificationMethodPublicKey-fVSjg83n-B4VhVtVk.js → retrieveVerificationMethodPublicKey-Dz3Z2B9t-C2YmGxIc.js} +1 -1
- package/dist/sha256-Dr-8c5iF-C1PUWFZm.js +1 -0
- package/dist/webcrypto.es-InUVnvpc-B87Lqr9a.js +40 -0
- package/dist/x25519-KEey2Qx1-NSl6svWQ.js +1 -0
- package/package.json +2 -2
- package/dist/EcdsaSecp256k1Signature2019-CBV4BwnM-C2qGlq2W.js +0 -4
- package/dist/Ed25519Signature2020-MQoWd113-PNuci9U2.js +0 -52
- package/dist/HashlinkVerifier-DykIKn5i-CYewU55u.js +0 -11
- package/dist/MerkleProof2019-DpwH-snR-ClzVR6uC.js +0 -3
- package/dist/checkCredentialSchemaConformity-DOGmtCq0-CnEpCN-s.js +0 -1
- package/dist/did-key-common.esm-C42sQiXe-DN5hgDGM.js +0 -9
- package/dist/did-key-ed25519.esm-CO7qImeZ-BR5JRBUU.js +0 -1
- package/dist/did-key-secp256k1.esm-BblZ1xRe-4Ak_uTKC.js +0 -1
- package/dist/elliptic-6eMlPaPZ-CGOSt2J1.js +0 -1
- package/dist/index-BZds3Ljo-CHN5LgUq.js +0 -1
- package/dist/index-Dzjg2qbR-DK7tzt5T.js +0 -22
- package/dist/index-VOqA2-xz-CKqwdkuf.js +0 -70
- package/dist/index-WN144sZ6-DKm58evR.js +0 -3
- package/dist/jsonld-BpvX3DRL-qZrjsUmJ.js +0 -75
- package/dist/sha256-D_qJpPFT-BYFBxJ7m.js +0 -1
- package/dist/webcrypto.es-DQnPRx8R-BJSH271h.js +0 -41
- package/dist/x25519-Dm-l65ld-DcUk09rC.js +0 -1
- /package/dist/{checkRevocationStatusList2021-CNtaPjVp-XCu3zkCJ.js → checkRevocationStatusList2021-BEXdT3FD-XCu3zkCJ.js} +0 -0
- /package/dist/{ensureNotRevoked-D9_PlMpD-DvMIgM4L.js → ensureNotRevoked-zJYOGU17-DvMIgM4L.js} +0 -0
- /package/dist/{index-CWugL4dz-Dgus2xdV.js → index-CgNQmXGo-Dgus2xdV.js} +0 -0
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{a as e,B as t,i as r,h as n,p as i,d as o,j as s,r as a,k as u,l as c,m as f,S as h,n as p}from"./main.js";import{s as l}from"./index-BZds3Ljo-CHN5LgUq.js";import{s as d,r as y,a as g,k as w,b as m,c as b}from"./index-WN144sZ6-DKm58evR.js";import{r as E,e as _}from"./elliptic-6eMlPaPZ-CGOSt2J1.js";import{j as v}from"./index-VOqA2-xz-CKqwdkuf.js";import{j as S}from"./jsonld-BpvX3DRL-qZrjsUmJ.js";import{s as I}from"./sha256-D_qJpPFT-BYFBxJ7m.js";import{t as T}from"./index-Dzjg2qbR-DK7tzt5T.js";import"./pako.esm-DnD5dZGi-Bw1vqMku.js";import{e as k}from"./ensureValidIssuingKey-C7MTkDyV-frafTbMl.js";import"./index-CWugL4dz-Dgus2xdV.js";import{r as A}from"./retrieveVerificationMethodPublicKey-fVSjg83n-B4VhVtVk.js";import{S as P}from"./Suite-B7Vy9AuU-D1ucdMDB.js";import"./base64url-Cy03LJLt-vkTPfQOh.js";const O={type:"object",required:["merkleRoot","targetHash","anchors"],properties:{merkleRoot:{type:"string",minLength:64,maxLength:64},targetHash:{type:"string",minLength:64,maxLength:64},anchors:{type:"array",minItems:1,contains:{type:"string"}}}},{validator:N}=l;var U={validate:N(O)};var x,B={root:{merkleRoot:0,targetHash:1,anchors:2,path:3},path:{left:0,right:1},chain:{btc:{id:0,networks:{mainnet:1,testnet:3}},eth:{id:1,networks:{mainnet:1,ropsten:3,rinkeby:4,goerli:5,sepolia:11155111}},mtc:{id:2,networks:{mainnet:137,mumbai:80001}},mocknet:{id:-1,networks:{mocknet:-1}}}},R={},M={exports:{}};x=M,function(e){var t,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,o="[BigNumber Error] ",s=o+"Number primitive has more than 15 significant digits: ",a=1e14,u=14,c=9007199254740991,f=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],h=1e7,p=1e9;function l(e){var t=0|e;return e>0||e===t?t:t-1}function d(e){for(var t,r,n=1,i=e.length,o=e[0]+"";n<i;){for(t=e[n++]+"",r=u-t.length;r--;t="0"+t);o+=t}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function y(e,t){var r,n,i=e.c,o=t.c,s=e.s,a=t.s,u=e.e,c=t.e;if(!s||!a)return null;if(r=i&&!i[0],n=o&&!o[0],r||n)return r?n?0:-a:s;if(s!=a)return s;if(r=s<0,n=u==c,!i||!o)return n?0:!i^r?1:-1;if(!n)return u>c^r?1:-1;for(a=(u=i.length)<(c=o.length)?u:c,s=0;s<a;s++)if(i[s]!=o[s])return i[s]>o[s]^r?1:-1;return u==c?0:u>c^r?1:-1}function g(e,t,r,n){if(e<t||e>r||e!==i(e))throw Error(o+(n||"Argument")+("number"==typeof e?e<t||e>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function w(e){var t=e.c.length-1;return l(e.e/u)==t&&e.c[t]%2!=0}function m(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function b(e,t,r){var n,i;if(t<0){for(i=r+".";++t;i+=r);e=i+e}else if(++t>(n=e.length)){for(i=r,t-=n;--t;i+=r);e+=i}else t<n&&(e=e.slice(0,t)+"."+e.slice(t));return e}t=function e(t){var E,_,v,S,I,T,k,A,P,O,N=G.prototype={constructor:G,toString:null,valueOf:null},U=new G(1),x=20,B=4,R=-7,M=21,L=-1e7,C=1e7,H=!1,D=1,F=0,j={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},V="0123456789abcdefghijklmnopqrstuvwxyz",K=!0;function G(e,t){var n,o,a,f,h,p,l,d,y=this;if(!(y instanceof G))return new G(e,t);if(null==t){if(e&&!0===e._isBigNumber)return y.s=e.s,void(!e.c||e.e>C?y.c=y.e=null:e.e<L?y.c=[y.e=0]:(y.e=e.e,y.c=e.c.slice()));if((p="number"==typeof e)&&0*e==0){if(y.s=1/e<0?(e=-e,-1):1,e===~~e){for(f=0,h=e;h>=10;h/=10,f++);return void(f>C?y.c=y.e=null:(y.e=f,y.c=[e]))}d=String(e)}else{if(!r.test(d=String(e)))return v(y,d,p);y.s=45==d.charCodeAt(0)?(d=d.slice(1),-1):1}(f=d.indexOf("."))>-1&&(d=d.replace(".","")),(h=d.search(/e/i))>0?(f<0&&(f=h),f+=+d.slice(h+1),d=d.substring(0,h)):f<0&&(f=d.length)}else{if(g(t,2,V.length,"Base"),10==t&&K)return z(y=new G(e),x+y.e+1,B);if(d=String(e),p="number"==typeof e){if(0*e!=0)return v(y,d,p,t);if(y.s=1/e<0?(d=d.slice(1),-1):1,G.DEBUG&&d.replace(/^0\.0*|\./,"").length>15)throw Error(s+e)}else y.s=45===d.charCodeAt(0)?(d=d.slice(1),-1):1;for(n=V.slice(0,t),f=h=0,l=d.length;h<l;h++)if(n.indexOf(o=d.charAt(h))<0){if("."==o){if(h>f){f=l;continue}}else if(!a&&(d==d.toUpperCase()&&(d=d.toLowerCase())||d==d.toLowerCase()&&(d=d.toUpperCase()))){a=!0,h=-1,f=0;continue}return v(y,String(e),p,t)}p=!1,(f=(d=_(d,t,10,y.s)).indexOf("."))>-1?d=d.replace(".",""):f=d.length}for(h=0;48===d.charCodeAt(h);h++);for(l=d.length;48===d.charCodeAt(--l););if(d=d.slice(h,++l)){if(l-=h,p&&G.DEBUG&&l>15&&(e>c||e!==i(e)))throw Error(s+y.s*e);if((f=f-h-1)>C)y.c=y.e=null;else if(f<L)y.c=[y.e=0];else{if(y.e=f,y.c=[],h=(f+1)%u,f<0&&(h+=u),h<l){for(h&&y.c.push(+d.slice(0,h)),l-=u;h<l;)y.c.push(+d.slice(h,h+=u));h=u-(d=d.slice(h)).length}else h-=l;for(;h--;d+="0");y.c.push(+d)}}else y.c=[y.e=0]}function W(e,t,r,n){var i,o,s,a,u;if(null==r?r=B:g(r,0,8),!e.c)return e.toString();if(i=e.c[0],s=e.e,null==t)u=d(e.c),u=1==n||2==n&&(s<=R||s>=M)?m(u,s):b(u,s,"0");else if(o=(e=z(new G(e),t,r)).e,a=(u=d(e.c)).length,1==n||2==n&&(t<=o||o<=R)){for(;a<t;u+="0",a++);u=m(u,o)}else if(t-=s,u=b(u,o,"0"),o+1>a){if(--t>0)for(u+=".";t--;u+="0");}else if((t+=o-a)>0)for(o+1==a&&(u+=".");t--;u+="0");return e.s<0&&i?"-"+u:u}function q(e,t){for(var r,n,i=1,o=new G(e[0]);i<e.length;i++)(!(n=new G(e[i])).s||(r=y(o,n))===t||0===r&&o.s===t)&&(o=n);return o}function X(e,t,r){for(var n=1,i=t.length;!t[--i];t.pop());for(i=t[0];i>=10;i/=10,n++);return(r=n+r*u-1)>C?e.c=e.e=null:r<L?e.c=[e.e=0]:(e.e=r,e.c=t),e}function z(e,t,r,o){var s,c,h,p,l,d,y,g=e.c,w=f;if(g){e:{for(s=1,p=g[0];p>=10;p/=10,s++);if((c=t-s)<0)c+=u,h=t,l=g[d=0],y=i(l/w[s-h-1]%10);else if((d=n((c+1)/u))>=g.length){if(!o)break e;for(;g.length<=d;g.push(0));l=y=0,s=1,h=(c%=u)-u+1}else{for(l=p=g[d],s=1;p>=10;p/=10,s++);y=(h=(c%=u)-u+s)<0?0:i(l/w[s-h-1]%10)}if(o=o||t<0||null!=g[d+1]||(h<0?l:l%w[s-h-1]),o=r<4?(y||o)&&(0==r||r==(e.s<0?3:2)):y>5||5==y&&(4==r||o||6==r&&(c>0?h>0?l/w[s-h]:0:g[d-1])%10&1||r==(e.s<0?8:7)),t<1||!g[0])return g.length=0,o?(t-=e.e+1,g[0]=w[(u-t%u)%u],e.e=-t||0):g[0]=e.e=0,e;if(0==c?(g.length=d,p=1,d--):(g.length=d+1,p=w[u-c],g[d]=h>0?i(l/w[s-h]%w[h])*p:0),o)for(;;){if(0==d){for(c=1,h=g[0];h>=10;h/=10,c++);for(h=g[0]+=p,p=1;h>=10;h/=10,p++);c!=p&&(e.e++,g[0]==a&&(g[0]=1));break}if(g[d]+=p,g[d]!=a)break;g[d--]=0,p=1}for(c=g.length;0===g[--c];g.pop());}e.e>C?e.c=e.e=null:e.e<L&&(e.c=[e.e=0])}return e}function $(e){var t,r=e.e;return null===r?e.toString():(t=d(e.c),t=r<=R||r>=M?m(t,r):b(t,r,"0"),e.s<0?"-"+t:t)}return G.clone=e,G.ROUND_UP=0,G.ROUND_DOWN=1,G.ROUND_CEIL=2,G.ROUND_FLOOR=3,G.ROUND_HALF_UP=4,G.ROUND_HALF_DOWN=5,G.ROUND_HALF_EVEN=6,G.ROUND_HALF_CEIL=7,G.ROUND_HALF_FLOOR=8,G.EUCLID=9,G.config=G.set=function(e){var t,r;if(null!=e){if("object"!=typeof e)throw Error(o+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(g(r=e[t],0,p,t),x=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(g(r=e[t],0,8,t),B=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(g(r[0],-p,0,t),g(r[1],0,p,t),R=r[0],M=r[1]):(g(r,-p,p,t),R=-(M=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)g(r[0],-p,-1,t),g(r[1],1,p,t),L=r[0],C=r[1];else{if(g(r,-p,p,t),!r)throw Error(o+t+" cannot be zero: "+r);L=-(C=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(o+t+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw H=!r,Error(o+"crypto unavailable");H=r}else H=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(g(r=e[t],0,9,t),D=r),e.hasOwnProperty(t="POW_PRECISION")&&(g(r=e[t],0,p,t),F=r),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(r=e[t]))throw Error(o+t+" not an object: "+r);j=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(o+t+" invalid: "+r);K="0123456789"==r.slice(0,10),V=r}}return{DECIMAL_PLACES:x,ROUNDING_MODE:B,EXPONENTIAL_AT:[R,M],RANGE:[L,C],CRYPTO:H,MODULO_MODE:D,POW_PRECISION:F,FORMAT:j,ALPHABET:V}},G.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!G.DEBUG)return!0;var t,r,n=e.c,s=e.e,c=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===c||-1===c)&&s>=-p&&s<=p&&s===i(s)){if(0===n[0]){if(0===s&&1===n.length)return!0;break e}if((t=(s+1)%u)<1&&(t+=u),String(n[0]).length==t){for(t=0;t<n.length;t++)if((r=n[t])<0||r>=a||r!==i(r))break e;if(0!==r)return!0}}}else if(null===n&&null===s&&(null===c||1===c||-1===c))return!0;throw Error(o+"Invalid BigNumber: "+e)},G.maximum=G.max=function(){return q(arguments,-1)},G.minimum=G.min=function(){return q(arguments,1)},G.random=(S=9007199254740992,I=Math.random()*S&2097151?function(){return i(Math.random()*S)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,r,s,a,c,h=0,l=[],d=new G(U);if(null==e?e=x:g(e,0,p),a=n(e/u),H)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(a*=2));h<a;)(c=131072*t[h]+(t[h+1]>>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),t[h]=r[0],t[h+1]=r[1]):(l.push(c%1e14),h+=2);h=a/2}else{if(!crypto.randomBytes)throw H=!1,Error(o+"crypto unavailable");for(t=crypto.randomBytes(a*=7);h<a;)(c=281474976710656*(31&t[h])+1099511627776*t[h+1]+4294967296*t[h+2]+16777216*t[h+3]+(t[h+4]<<16)+(t[h+5]<<8)+t[h+6])>=9e15?crypto.randomBytes(7).copy(t,h):(l.push(c%1e14),h+=7);h=a/7}if(!H)for(;h<a;)(c=I())<9e15&&(l[h++]=c%1e14);for(a=l[--h],e%=u,a&&e&&(c=f[u-e],l[h]=i(a/c)*c);0===l[h];l.pop(),h--);if(h<0)l=[s=0];else{for(s=-1;0===l[0];l.splice(0,1),s-=u);for(h=1,c=l[0];c>=10;c/=10,h++);h<u&&(s-=u-h)}return d.e=s,d.c=l,d}),G.sum=function(){for(var e=1,t=arguments,r=new G(t[0]);e<t.length;)r=r.plus(t[e++]);return r},_=function(){var e="0123456789";function t(e,t,r,n){for(var i,o,s=[0],a=0,u=e.length;a<u;){for(o=s.length;o--;s[o]*=t);for(s[0]+=n.indexOf(e.charAt(a++)),i=0;i<s.length;i++)s[i]>r-1&&(null==s[i+1]&&(s[i+1]=0),s[i+1]+=s[i]/r|0,s[i]%=r)}return s.reverse()}return function(r,n,i,o,s){var a,u,c,f,h,p,l,y,g=r.indexOf("."),w=x,m=B;for(g>=0&&(f=F,F=0,r=r.replace(".",""),p=(y=new G(n)).pow(r.length-g),F=f,y.c=t(b(d(p.c),p.e,"0"),10,i,e),y.e=y.c.length),c=f=(l=t(r,n,i,s?(a=V,e):(a=e,V))).length;0==l[--f];l.pop());if(!l[0])return a.charAt(0);if(g<0?--c:(p.c=l,p.e=c,p.s=o,l=(p=E(p,y,w,m,i)).c,h=p.r,c=p.e),g=l[u=c+w+1],f=i/2,h=h||u<0||null!=l[u+1],h=m<4?(null!=g||h)&&(0==m||m==(p.s<0?3:2)):g>f||g==f&&(4==m||h||6==m&&1&l[u-1]||m==(p.s<0?8:7)),u<1||!l[0])r=h?b(a.charAt(1),-w,a.charAt(0)):a.charAt(0);else{if(l.length=u,h)for(--i;++l[--u]>i;)l[u]=0,u||(++c,l=[1].concat(l));for(f=l.length;!l[--f];);for(g=0,r="";g<=f;r+=a.charAt(l[g++]));r=b(r,c,a.charAt(0))}return r}}(),E=function(){function e(e,t,r){var n,i,o,s,a=0,u=e.length,c=t%h,f=t/h|0;for(e=e.slice();u--;)a=((i=c*(o=e[u]%h)+(n=f*o+(s=e[u]/h|0)*c)%h*h+a)/r|0)+(n/h|0)+f*s,e[u]=i%r;return a&&(e=[a].concat(e)),e}function t(e,t,r,n){var i,o;if(r!=n)o=r>n?1:-1;else for(i=o=0;i<r;i++)if(e[i]!=t[i]){o=e[i]>t[i]?1:-1;break}return o}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]<t[r]?1:0,e[r]=i*n+e[r]-t[r];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(n,o,s,c,f){var h,p,d,y,g,w,m,b,E,_,v,S,I,T,k,A,P,O=n.s==o.s?1:-1,N=n.c,U=o.c;if(!(N&&N[0]&&U&&U[0]))return new G(n.s&&o.s&&(N?!U||N[0]!=U[0]:U)?N&&0==N[0]||!U?0*O:O/0:NaN);for(E=(b=new G(O)).c=[],O=s+(p=n.e-o.e)+1,f||(f=a,p=l(n.e/u)-l(o.e/u),O=O/u|0),d=0;U[d]==(N[d]||0);d++);if(U[d]>(N[d]||0)&&p--,O<0)E.push(1),y=!0;else{for(T=N.length,A=U.length,d=0,O+=2,(g=i(f/(U[0]+1)))>1&&(U=e(U,g,f),N=e(N,g,f),A=U.length,T=N.length),I=A,v=(_=N.slice(0,A)).length;v<A;_[v++]=0);P=U.slice(),P=[0].concat(P),k=U[0],U[1]>=f/2&&k++;do{if(g=0,(h=t(U,_,A,v))<0){if(S=_[0],A!=v&&(S=S*f+(_[1]||0)),(g=i(S/k))>1)for(g>=f&&(g=f-1),m=(w=e(U,g,f)).length,v=_.length;1==t(w,_,m,v);)g--,r(w,A<m?P:U,m,f),m=w.length,h=1;else 0==g&&(h=g=1),m=(w=U.slice()).length;if(m<v&&(w=[0].concat(w)),r(_,w,v,f),v=_.length,-1==h)for(;t(U,_,A,v)<1;)g++,r(_,A<v?P:U,v,f),v=_.length}else 0===h&&(g++,_=[0]);E[d++]=g,_[0]?_[v++]=N[I]||0:(_=[N[I]],v=1)}while((I++<T||null!=_[0])&&O--);y=null!=_[0],E[0]||E.splice(0,1)}if(f==a){for(d=1,O=E[0];O>=10;O/=10,d++);z(b,s+(b.e=d+p*u-1)+1,c,y)}else b.e=p,b.r=+y;return b}}(),T=/^(-?)0([xbo])(?=\w[\w.]*$)/i,k=/^([^.]+)\.$/,A=/^\.([^.]+)$/,P=/^-?(Infinity|NaN)$/,O=/^\s*\+(?=[\w.])|^\s+|\s+$/g,v=function(e,t,r,n){var i,s=r?t:t.replace(O,"");if(P.test(s))e.s=isNaN(s)?null:s<0?-1:1;else{if(!r&&(s=s.replace(T,(function(e,t,r){return i="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=i?e:t})),n&&(i=n,s=s.replace(k,"$1").replace(A,"0.$1")),t!=s))return new G(s,i);if(G.DEBUG)throw Error(o+"Not a"+(n?" base "+n:"")+" number: "+t);e.s=null}e.c=e.e=null},N.absoluteValue=N.abs=function(){var e=new G(this);return e.s<0&&(e.s=1),e},N.comparedTo=function(e,t){return y(this,new G(e,t))},N.decimalPlaces=N.dp=function(e,t){var r,n,i,o=this;if(null!=e)return g(e,0,p),null==t?t=B:g(t,0,8),z(new G(o),e+o.e+1,t);if(!(r=o.c))return null;if(n=((i=r.length-1)-l(this.e/u))*u,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},N.dividedBy=N.div=function(e,t){return E(this,new G(e,t),x,B)},N.dividedToIntegerBy=N.idiv=function(e,t){return E(this,new G(e,t),0,1)},N.exponentiatedBy=N.pow=function(e,t){var r,s,a,c,f,h,p,l,d=this;if((e=new G(e)).c&&!e.isInteger())throw Error(o+"Exponent not an integer: "+$(e));if(null!=t&&(t=new G(t)),f=e.e>14,!d.c||!d.c[0]||1==d.c[0]&&!d.e&&1==d.c.length||!e.c||!e.c[0])return l=new G(Math.pow(+$(d),f?e.s*(2-w(e)):+$(e))),t?l.mod(t):l;if(h=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new G(NaN);(s=!h&&d.isInteger()&&t.isInteger())&&(d=d.mod(t))}else{if(e.e>9&&(d.e>0||d.e<-1||(0==d.e?d.c[0]>1||f&&d.c[1]>=24e7:d.c[0]<8e13||f&&d.c[0]<=9999975e7)))return c=d.s<0&&w(e)?-0:0,d.e>-1&&(c=1/c),new G(h?1/c:c);F&&(c=n(F/u+2))}for(f?(r=new G(.5),h&&(e.s=1),p=w(e)):p=(a=Math.abs(+$(e)))%2,l=new G(U);;){if(p){if(!(l=l.times(d)).c)break;c?l.c.length>c&&(l.c.length=c):s&&(l=l.mod(t))}if(a){if(0===(a=i(a/2)))break;p=a%2}else if(z(e=e.times(r),e.e+1,1),e.e>14)p=w(e);else{if(0==(a=+$(e)))break;p=a%2}d=d.times(d),c?d.c&&d.c.length>c&&(d.c.length=c):s&&(d=d.mod(t))}return s?l:(h&&(l=U.div(l)),t?l.mod(t):c?z(l,F,B,void 0):l)},N.integerValue=function(e){var t=new G(this);return null==e?e=B:g(e,0,8),z(t,t.e+1,e)},N.isEqualTo=N.eq=function(e,t){return 0===y(this,new G(e,t))},N.isFinite=function(){return!!this.c},N.isGreaterThan=N.gt=function(e,t){return y(this,new G(e,t))>0},N.isGreaterThanOrEqualTo=N.gte=function(e,t){return 1===(t=y(this,new G(e,t)))||0===t},N.isInteger=function(){return!!this.c&&l(this.e/u)>this.c.length-2},N.isLessThan=N.lt=function(e,t){return y(this,new G(e,t))<0},N.isLessThanOrEqualTo=N.lte=function(e,t){return-1===(t=y(this,new G(e,t)))||0===t},N.isNaN=function(){return!this.s},N.isNegative=function(){return this.s<0},N.isPositive=function(){return this.s>0},N.isZero=function(){return!!this.c&&0==this.c[0]},N.minus=function(e,t){var r,n,i,o,s=this,c=s.s;if(t=(e=new G(e,t)).s,!c||!t)return new G(NaN);if(c!=t)return e.s=-t,s.plus(e);var f=s.e/u,h=e.e/u,p=s.c,d=e.c;if(!f||!h){if(!p||!d)return p?(e.s=-t,e):new G(d?s:NaN);if(!p[0]||!d[0])return d[0]?(e.s=-t,e):new G(p[0]?s:3==B?-0:0)}if(f=l(f),h=l(h),p=p.slice(),c=f-h){for((o=c<0)?(c=-c,i=p):(h=f,i=d),i.reverse(),t=c;t--;i.push(0));i.reverse()}else for(n=(o=(c=p.length)<(t=d.length))?c:t,c=t=0;t<n;t++)if(p[t]!=d[t]){o=p[t]<d[t];break}if(o&&(i=p,p=d,d=i,e.s=-e.s),(t=(n=d.length)-(r=p.length))>0)for(;t--;p[r++]=0);for(t=a-1;n>c;){if(p[--n]<d[n]){for(r=n;r&&!p[--r];p[r]=t);--p[r],p[n]+=a}p[n]-=d[n]}for(;0==p[0];p.splice(0,1),--h);return p[0]?X(e,p,h):(e.s=3==B?-1:1,e.c=[e.e=0],e)},N.modulo=N.mod=function(e,t){var r,n,i=this;return e=new G(e,t),!i.c||!e.s||e.c&&!e.c[0]?new G(NaN):!e.c||i.c&&!i.c[0]?new G(i):(9==D?(n=e.s,e.s=1,r=E(i,e,0,3),e.s=n,r.s*=n):r=E(i,e,0,D),(e=i.minus(r.times(e))).c[0]||1!=D||(e.s=i.s),e)},N.multipliedBy=N.times=function(e,t){var r,n,i,o,s,c,f,p,d,y,g,w,m,b,E,_=this,v=_.c,S=(e=new G(e,t)).c;if(!(v&&S&&v[0]&&S[0]))return!_.s||!e.s||v&&!v[0]&&!S||S&&!S[0]&&!v?e.c=e.e=e.s=null:(e.s*=_.s,v&&S?(e.c=[0],e.e=0):e.c=e.e=null),e;for(n=l(_.e/u)+l(e.e/u),e.s*=_.s,(f=v.length)<(y=S.length)&&(m=v,v=S,S=m,i=f,f=y,y=i),i=f+y,m=[];i--;m.push(0));for(b=a,E=h,i=y;--i>=0;){for(r=0,g=S[i]%E,w=S[i]/E|0,o=i+(s=f);o>i;)r=((p=g*(p=v[--s]%E)+(c=w*p+(d=v[s]/E|0)*g)%E*E+m[o]+r)/b|0)+(c/E|0)+w*d,m[o--]=p%b;m[o]=r}return r?++n:m.splice(0,1),X(e,m,n)},N.negated=function(){var e=new G(this);return e.s=-e.s||null,e},N.plus=function(e,t){var r,n=this,i=n.s;if(t=(e=new G(e,t)).s,!i||!t)return new G(NaN);if(i!=t)return e.s=-t,n.minus(e);var o=n.e/u,s=e.e/u,c=n.c,f=e.c;if(!o||!s){if(!c||!f)return new G(i/0);if(!c[0]||!f[0])return f[0]?e:new G(c[0]?n:0*i)}if(o=l(o),s=l(s),c=c.slice(),i=o-s){for(i>0?(s=o,r=f):(i=-i,r=c),r.reverse();i--;r.push(0));r.reverse()}for((i=c.length)-(t=f.length)<0&&(r=f,f=c,c=r,t=i),i=0;t;)i=(c[--t]=c[t]+f[t]+i)/a|0,c[t]=a===c[t]?0:c[t]%a;return i&&(c=[i].concat(c),++s),X(e,c,s)},N.precision=N.sd=function(e,t){var r,n,i,o=this;if(null!=e&&e!==!!e)return g(e,1,p),null==t?t=B:g(t,0,8),z(new G(o),e,t);if(!(r=o.c))return null;if(n=(i=r.length-1)*u+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return e&&o.e+1>n&&(n=o.e+1),n},N.shiftedBy=function(e){return g(e,-9007199254740991,c),this.times("1e"+e)},N.squareRoot=N.sqrt=function(){var e,t,r,n,i,o=this,s=o.c,a=o.s,u=o.e,c=x+4,f=new G("0.5");if(1!==a||!s||!s[0])return new G(!a||a<0&&(!s||s[0])?NaN:s?o:1/0);if(0==(a=Math.sqrt(+$(o)))||a==1/0?(((t=d(s)).length+u)%2==0&&(t+="0"),a=Math.sqrt(+t),u=l((u+1)/2)-(u<0||u%2),r=new G(t=a==1/0?"5e"+u:(t=a.toExponential()).slice(0,t.indexOf("e")+1)+u)):r=new G(a+""),r.c[0])for((a=(u=r.e)+c)<3&&(a=0);;)if(i=r,r=f.times(i.plus(E(o,i,c,1))),d(i.c).slice(0,a)===(t=d(r.c)).slice(0,a)){if(r.e<u&&--a,"9999"!=(t=t.slice(a-3,a+1))&&(n||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(z(r,r.e+x+2,1),e=!r.times(r).eq(o));break}if(!n&&(z(i,i.e+x+2,0),i.times(i).eq(o))){r=i;break}c+=4,a+=4,n=1}return z(r,r.e+x+1,B,e)},N.toExponential=function(e,t){return null!=e&&(g(e,0,p),e++),W(this,e,t,1)},N.toFixed=function(e,t){return null!=e&&(g(e,0,p),e=e+this.e+1),W(this,e,t)},N.toFormat=function(e,t,r){var n,i=this;if(null==r)null!=e&&t&&"object"==typeof t?(r=t,t=null):e&&"object"==typeof e?(r=e,e=t=null):r=j;else if("object"!=typeof r)throw Error(o+"Argument not an object: "+r);if(n=i.toFixed(e,t),i.c){var s,a=n.split("."),u=+r.groupSize,c=+r.secondaryGroupSize,f=r.groupSeparator||"",h=a[0],p=a[1],l=i.s<0,d=l?h.slice(1):h,y=d.length;if(c&&(s=u,u=c,c=s,y-=s),u>0&&y>0){for(s=y%u||u,h=d.substr(0,s);s<y;s+=u)h+=f+d.substr(s,u);c>0&&(h+=f+d.slice(s)),l&&(h="-"+h)}n=p?h+(r.decimalSeparator||"")+((c=+r.fractionGroupSize)?p.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):p):h}return(r.prefix||"")+n+(r.suffix||"")},N.toFraction=function(e){var t,r,n,i,s,a,c,h,p,l,y,g,w=this,m=w.c;if(null!=e&&(!(c=new G(e)).isInteger()&&(c.c||1!==c.s)||c.lt(U)))throw Error(o+"Argument "+(c.isInteger()?"out of range: ":"not an integer: ")+$(c));if(!m)return new G(w);for(t=new G(U),p=r=new G(U),n=h=new G(U),g=d(m),s=t.e=g.length-w.e-1,t.c[0]=f[(a=s%u)<0?u+a:a],e=!e||c.comparedTo(t)>0?s>0?t:p:c,a=C,C=1/0,c=new G(g),h.c[0]=0;l=E(c,t,0,1),1!=(i=r.plus(l.times(n))).comparedTo(e);)r=n,n=i,p=h.plus(l.times(i=p)),h=i,t=c.minus(l.times(i=t)),c=i;return i=E(e.minus(r),n,0,1),h=h.plus(i.times(p)),r=r.plus(i.times(n)),h.s=p.s=w.s,y=E(p,n,s*=2,B).minus(w).abs().comparedTo(E(h,r,s,B).minus(w).abs())<1?[p,n]:[h,r],C=a,y},N.toNumber=function(){return+$(this)},N.toPrecision=function(e,t){return null!=e&&g(e,1,p),W(this,e,t,2)},N.toString=function(e){var t,r=this,n=r.s,i=r.e;return null===i?n?(t="Infinity",n<0&&(t="-"+t)):t="NaN":(null==e?t=i<=R||i>=M?m(d(r.c),i):b(d(r.c),i,"0"):10===e&&K?t=b(d((r=z(new G(r),x+i+1,B)).c),r.e,"0"):(g(e,2,V.length,"Base"),t=_(b(d(r.c),i,"0"),10,e,n,!0)),n<0&&r.c[0]&&(t="-"+t)),t},N.valueOf=N.toJSON=function(){return $(this)},N._isBigNumber=!0,null!=t&&G.set(t),G}(),t.default=t.BigNumber=t,x.exports?x.exports=t:(e||(e="undefined"!=typeof self&&self?self:window),e.BigNumber=t)}(e);var L=M.exports,C={},H={};!function(e){const t=L.BigNumber;e.MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7},e.TAG={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,REGEXP:35,MIME:36},e.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31},e.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23},e.SYMS={NULL:Symbol("null"),UNDEFINED:Symbol("undef"),PARENT:Symbol("parent"),BREAK:Symbol("break"),STREAM:Symbol("stream")},e.SHIFT32=4294967296,e.BI={MINUS_ONE:-1,MAXINT32:4294967295,MAXINT64:"0xffffffffffffffff",SHIFT32:e.SHIFT32};const r=new t(-1);e.BN={MINUS_ONE:r,NEG_MAX:r.minus(new t(Number.MAX_SAFE_INTEGER.toString(16),16)),MAXINT:new t("0x20000000000000"),MAXINT32:new t(4294967295),MAXINT64:new t("0xffffffffffffffff"),SHIFT32:new t(e.SHIFT32)}}(H),function(e){const n=y,i=L.BigNumber,o=H.NUMBYTES,s=H.SHIFT32;e.hasBigInt="function"==typeof BigInt;const a="function"==typeof TextDecoder?TextDecoder:n.TextDecoder;if(a){const t=new a("utf8",{fatal:!0,ignoreBOM:!0});e.utf8=e=>t.decode(e),e.utf8.checksUTF8=!0}else e.utf8=e=>e.toString("utf8"),e.utf8.checksUTF8=!1;e.parseCBORint=function(e,t){switch(e){case o.ONE:return t.readUInt8(0);case o.TWO:return t.readUInt16BE(0);case o.FOUR:return t.readUInt32BE(0);case o.EIGHT:const r=t.readUInt32BE(0),n=t.readUInt32BE(4);return r>2097151?new i(r).times(s).plus(n):r*s+n;default:throw new Error("Invalid additional info for int: "+e)}},e.writeHalf=function(e,r){const n=t.allocUnsafe(4);n.writeFloatBE(r,0);const i=n.readUInt32BE(0);if(8191&i)return!1;let o=i>>16&32768;const s=i>>23&255,a=8388607&i;if(s>=113&&s<=142)o+=(s-112<<10)+(a>>13);else{if(!(s>=103&&s<113))return!1;if(a&(1<<126-s)-1)return!1;o+=a+8388608>>126-s}return e.writeUInt16BE(o),!0},e.parseHalf=function(e){const t=128&e[0]?-1:1,r=(124&e[0])>>2,n=(3&e[0])<<8|e[1];return r?31===r?t*(n?NaN:Infinity):t*Math.pow(2,r-25)*(1024+n):5.960464477539063e-8*t*n},e.parseCBORfloat=function(t){switch(t.length){case 2:return e.parseHalf(t);case 4:return t.readFloatBE(0);case 8:return t.readDoubleBE(0);default:throw new Error("Invalid float size: "+t.length)}},e.hex=function(e){return t.from(e.replace(/^0x/,""),"hex")},e.bin=function(e){let r=0,n=(e=e.replace(/\s/g,"")).length%8||8;const i=[];for(;n<=e.length;)i.push(parseInt(e.slice(r,n),2)),r=n,n+=8;return t.from(i)},e.extend=function(e={},...t){const r=t.length;for(let n=0;n<r;n++){const r=t[n];for(const t in r){const n=r[t];e[t]=n}}return e},e.arrayEqual=function(e,t){return null==e&&null==t||null!=e&&null!=t&&(e.length===t.length&&e.every(((e,r)=>e===t[r])))},e.bufferEqual=function(e,t){if(null==e&&null==t)return!0;if(null==e||null==t)return!1;if(!r(e)||!r(t)||e.length!==t.length)return!1;const n=e.length;let i,o,s=!0;for(i=o=0;o<n;i=++o){const r=e[i];s=s&&t[i]===r}return!!s},e.bufferToBignumber=function(e){return new i(e.toString("hex"),16)},e.toBigInt=function(t){return e.hasBigInt?BigInt(t):Number(t)},e.bigIntize=function(t){const r={};for(const n in t)r[n]=e.toBigInt(t[n]);return r},e.bufferToBigInt=function(t){return e.toBigInt("0x"+t.toString("hex"))},e.guessEncoding=function(e){if("string"==typeof e)return"hex";if(!r(e))throw new Error("Unknown input type")}}(C);const D=y,F=H.MT,j=H.SIMPLE,V=H.SYMS;let K=class e{constructor(e){if("number"!=typeof e)throw new Error("Invalid Simple type: "+typeof e);if(e<0||e>255||(0|e)!==e)throw new Error("value must be a small positive integer: "+e);this.value=e}toString(){return"simple("+this.value+")"}[D.inspect.custom](e,t){return"simple("+this.value+")"}inspect(e,t){return"simple("+this.value+")"}encodeCBOR(e){return e._pushInt(this.value,F.SIMPLE_FLOAT)}static isSimple(t){return t instanceof e}static decode(t,r=!0,n=!1){switch(t){case j.FALSE:return!1;case j.TRUE:return!0;case j.NULL:return r?null:V.NULL;case j.UNDEFINED:return r?void 0:V.UNDEFINED;case-1:if(!r||!n)throw new Error("Invalid BREAK");return V.BREAK;default:return new e(t)}}};var G=K;const W=g,q=y;let X=class e extends W.Transform{constructor(e,t,n){let i,o;switch(null==n&&(n={}),typeof e){case"object":r(e)?(i=e,null!=t&&"object"==typeof t&&(n=t)):n=e;break;case"string":i=e,null!=t&&"object"==typeof t?n=t:o=t}null==n&&(n={}),null==i&&(i=n.input),null==o&&(o=n.inputEncoding),delete n.input,delete n.inputEncoding;const s=null==n.watchPipe||n.watchPipe;delete n.watchPipe;const a=!!n.readError;delete n.readError,super(n),this.readError=a,s&&this.on("pipe",(e=>{const t=e._readableState.objectMode;if(this.length>0&&t!==this._readableState.objectMode)throw new Error("Do not switch objectMode in the middle of the stream");return this._readableState.objectMode=t,this._writableState.objectMode=t})),null!=i&&this.end(i,o)}static isNoFilter(e){return e instanceof this}static compare(e,t){if(!(e instanceof this))throw new TypeError("Arguments must be NoFilters");return e===t?0:e.compare(t)}static concat(n,i){if(!Array.isArray(n))throw new TypeError("list argument must be an Array of NoFilters");if(0===n.length||0===i)return t.alloc(0);null==i&&(i=n.reduce(((t,r)=>{if(!(r instanceof e))throw new TypeError("list argument must be an Array of NoFilters");return t+r.length}),0));let o=!0,s=!0;const a=n.map((t=>{if(!(t instanceof e))throw new TypeError("list argument must be an Array of NoFilters");const n=t.slice();return r(n)?s=!1:o=!1,n}));if(o)return t.concat(a,i);if(s)return[].concat(...a).slice(0,i);throw new Error("Concatenating mixed object and byte streams not supported")}_transform(e,n,i){this._readableState.objectMode||r(e)||(e=t.from(e,n)),this.push(e),i()}_bufArray(){let e=this._readableState.buffer;if(!Array.isArray(e)){let t=e.head;for(e=[];null!=t;)e.push(t.data),t=t.next}return e}read(e){const t=super.read(e);if(null!=t){if(this.emit("read",t),this.readError&&t.length<e)throw new Error(`Read ${t.length}, wanted ${e}`)}else if(this.readError)throw new Error(`No data available, wanted ${e}`);return t}promise(e){let t=!1;return new Promise(((r,n)=>{this.on("finish",(()=>{const n=this.read();null==e||t||(t=!0,e(null,n)),r(n)})),this.on("error",(r=>{null==e||t||(t=!0,e(r)),n(r)}))}))}compare(t){if(!(t instanceof e))throw new TypeError("Arguments must be NoFilters");if(this===t)return 0;{const e=this.slice(),n=t.slice();if(r(e)&&r(n))return e.compare(n);throw new Error("Cannot compare streams in object mode")}}equals(e){return 0===this.compare(e)}slice(e,r){if(this._readableState.objectMode)return this._bufArray().slice(e,r);const n=this._bufArray();switch(n.length){case 0:return t.alloc(0);case 1:return n[0].slice(e,r);default:return t.concat(n).slice(e,r)}}get(e){return this.slice()[e]}toJSON(){const e=this.slice();return r(e)?e.toJSON():e}toString(e,t,n){const i=this.slice(t,n);if(!r(i))return JSON.stringify(i);if((!e||"utf8"===e)&&q.TextDecoder){return new q.TextDecoder("utf8",{fatal:!0,ignoreBOM:!0}).decode(i)}return i.toString(e,t,n)}inspect(e,t){return this[q.inspect.custom](e,t)}[q.inspect.custom](e,t){const n=this._bufArray().map((e=>r(e)?(null!=t?t.stylize:void 0)?t.stylize(e.toString("hex"),"string"):e.toString("hex"):q.inspect(e,t))).join(", ");return`${this.constructor.name} [${n}]`}get length(){return this._readableState.length}writeBigInt(e){let r=e.toString(16);if(e<0){const t=BigInt(Math.floor(r.length/2));r=(e=(BigInt(1)<<t*BigInt(8))+e).toString(16)}return r.length%2&&(r="0"+r),this.push(t.from(r,"hex"))}readUBigInt(e){const t=this.read(e);return r(t)?BigInt("0x"+t.toString("hex")):null}readBigInt(e){const t=this.read(e);if(!r(t))return null;let n=BigInt("0x"+t.toString("hex"));if(128&t[0]){n-=BigInt(1)<<BigInt(t.length)*BigInt(8)}return n}};function z(e,t){return function(n){const i=this.read(t);return r(i)?i[e].call(i,0,!0):null}}function $(e,r){return function(n){const i=t.alloc(r);return i[e].call(i,n,0,!0),this.push(i)}}Object.assign(X.prototype,{writeUInt8:$("writeUInt8",1),writeUInt16LE:$("writeUInt16LE",2),writeUInt16BE:$("writeUInt16BE",2),writeUInt32LE:$("writeUInt32LE",4),writeUInt32BE:$("writeUInt32BE",4),writeInt8:$("writeInt8",1),writeInt16LE:$("writeInt16LE",2),writeInt16BE:$("writeInt16BE",2),writeInt32LE:$("writeInt32LE",4),writeInt32BE:$("writeInt32BE",4),writeFloatLE:$("writeFloatLE",4),writeFloatBE:$("writeFloatBE",4),writeDoubleLE:$("writeDoubleLE",8),writeDoubleBE:$("writeDoubleBE",8),readUInt8:z("readUInt8",1),readUInt16LE:z("readUInt16LE",2),readUInt16BE:z("readUInt16BE",2),readUInt32LE:z("readUInt32LE",4),readUInt32BE:z("readUInt32BE",4),readInt8:z("readInt8",1),readInt16LE:z("readInt16LE",2),readInt16BE:z("readInt16BE",2),readInt32LE:z("readInt32LE",4),readInt32BE:z("readInt32BE",4),readFloatLE:z("readFloatLE",4),readFloatBE:z("readFloatBE",4),readDoubleLE:z("readDoubleLE",8),readDoubleBE:z("readDoubleBE",8)});var Y=X;const J=Y,Q=g.Transform;var Z=class extends Q{constructor(e){super(e),this._writableState.objectMode=!1,this._readableState.objectMode=!0,this.bs=new J,this.__restart()}_transform(e,t,r){for(this.bs.write(e);this.bs.length>=this.__needed;){let e;const t=null===this.__needed?void 0:this.bs.read(this.__needed);try{e=this.__parser.next(t)}catch(e){return r(e)}this.__needed&&(this.__fresh=!1),e.done?(this.push(e.value),this.__restart()):this.__needed=e.value||0}return r()}*_parse(){throw new Error("Must be implemented in subclass")}__restart(){this.__needed=null,this.__parser=this._parse(),this.__fresh=!0}_flush(e){e(this.__fresh?null:new Error("unexpected end of input"))}};const ee=L.BigNumber,te=C,re=c,ne=new ee(-1),ie=new ee(2);var oe=class e{constructor(e,t,r){if(this.tag=e,this.value=t,this.err=r,"number"!=typeof this.tag)throw new Error("Invalid tag type ("+typeof this.tag+")");if(this.tag<0||(0|this.tag)!==this.tag)throw new Error("Tag must be a positive integer: "+this.tag)}toString(){return`${this.tag}(${JSON.stringify(this.value)})`}encodeCBOR(e){return e._pushTag(this.tag),e.pushAny(this.value)}convert(t){let r=null!=t?t[this.tag]:void 0;if("function"!=typeof r&&(r=e["_tag_"+this.tag],"function"!=typeof r))return this;try{return r.call(e,this.value)}catch(e){return this.err=e,this}}static _tag_0(e){return new Date(e)}static _tag_1(e){return new Date(1e3*e)}static _tag_2(e){return te.bufferToBignumber(e)}static _tag_3(e){return ne.minus(te.bufferToBignumber(e))}static _tag_4(e){return ee(e[1]).shiftedBy(e[0])}static _tag_5(e){return ie.pow(e[0]).times(e[1])}static _tag_32(e){return re.parse(e)}static _tag_35(e){return new RegExp(e)}};const se=g,ae=Z,ue=oe,ce=G,fe=C,he=L.BigNumber,pe=Y,le=H,de=le.MT,ye=le.NUMBYTES,ge=le.SYMS,we=fe.bigIntize(le.BI),me=le.BN,be=Symbol("count"),Ee=Symbol("major type"),_e=Symbol("error"),ve=Symbol("not found");function Se(e,t,r){const n=[];return n[be]=r,n[ge.PARENT]=e,n[Ee]=t,n}function Ie(e,t){const r=new pe;return r[be]=-1,r[ge.PARENT]=e,r[Ee]=t,r}function Te(e){return fe.bufferToBigInt(e)}function ke(e){return we.MINUS_ONE-fe.bufferToBigInt(e)}let Ae=class e extends ae{constructor(e){const t=(e=e||{}).tags;delete e.tags;const r=null!=e.max_depth?e.max_depth:-1;delete e.max_depth;const n=!!fe.hasBigInt&&!!e.bigint;delete e.bigint,super(e),this.running=!0,this.max_depth=r,this.tags=t,n&&(null==this.tags&&(this.tags={}),null==this.tags[2]&&(this.tags[2]=Te),null==this.tags[3]&&(this.tags[3]=ke))}static nullcheck(e){switch(e){case ge.NULL:return null;case ge.UNDEFINED:return;case ve:throw new Error("Value not found");default:return e}}static decodeFirstSync(t,r){let n,i={};switch(typeof(r=r||{encoding:"hex"})){case"string":n=r;break;case"object":i=fe.extend({},r),n=i.encoding,delete i.encoding}const o=new e(i),s=t instanceof se.Readable?t:new pe(t,null!=n?n:fe.guessEncoding(t)),a=o._parse();let u=a.next();for(;!u.done;){const e=s.read(u.value);if(null==e||e.length!==u.value)throw new Error("Insufficient data");u=a.next(e)}const c=e.nullcheck(u.value);if(s.length>0){const e=s.read(1);s.unshift(e);const t=new Error("Unexpected data: 0x"+e[0].toString(16));throw t.value=c,t}return c}static decodeAllSync(t,r){let n,i={};switch(typeof(r=r||{encoding:"hex"})){case"string":n=r;break;case"object":i=fe.extend({},r),n=i.encoding,delete i.encoding}const o=new e(i),s=t instanceof se.Readable?t:new pe(t,null!=n?n:fe.guessEncoding(t)),a=[];for(;s.length>0;){const t=o._parse();let r=t.next();for(;!r.done;){const e=s.read(r.value);if(null==e||e.length!==r.value)throw new Error("Insufficient data");r=t.next(e)}a.push(e.nullcheck(r.value))}return a}static decodeFirst(t,r,n){let i={},o=!1,s="hex";switch(typeof r){case"function":n=r,s=fe.guessEncoding(t);break;case"string":s=r;break;case"object":i=fe.extend({},r),s=null!=i.encoding?i.encoding:fe.guessEncoding(t),delete i.encoding,o=null!=i.required&&i.required,delete i.required}const a=new e(i);let u=ve;const c=new Promise(((t,r)=>{a.on("data",(t=>{u=e.nullcheck(t),a.close()})),a.once("error",(e=>(u!==ve&&(e.value=u),u=_e,a.close(),r(e)))),a.once("end",(()=>{switch(u){case ve:return o?r(new Error("No CBOR found")):t(u);case _e:return;default:return t(u)}}))}));return"function"==typeof n&&c.then((e=>n(null,e)),n),a.end(t,s),c}static decodeAll(t,r,n){let i={},o="hex";switch(typeof r){case"function":n=r,o=fe.guessEncoding(t);break;case"string":o=r;break;case"object":i=fe.extend({},r),o=null!=i.encoding?i.encoding:fe.guessEncoding(t),delete i.encoding}const s=new e(i),a=[];s.on("data",(t=>a.push(e.nullcheck(t))));const u=new Promise(((e,t)=>{s.on("error",t),s.on("end",(()=>e(a)))}));return"function"==typeof n&&u.then((e=>n(null,e)),n),s.end(t,o),u}close(){this.running=!1,this.__fresh=!0}*_parse(){let e=null,r=0,n=null;for(;;){if(this.max_depth>=0&&r>this.max_depth)throw new Error("Maximum depth "+this.max_depth+" exceeded");const i=(yield 1)[0];if(!this.running)throw new Error("Unexpected data: 0x"+i.toString(16));const o=i>>5,s=31&i,a=null!=e?e[Ee]:void 0,u=null!=e?e.length:void 0;switch(s){case ye.ONE:this.emit("more-bytes",o,1,a,u),n=(yield 1)[0];break;case ye.TWO:case ye.FOUR:case ye.EIGHT:const e=1<<s-24;this.emit("more-bytes",o,e,a,u);const t=yield e;n=o===de.SIMPLE_FLOAT?t:fe.parseCBORint(s,t);break;case 28:case 29:case 30:throw this.running=!1,new Error("Additional info not implemented: "+s);case ye.INDEFINITE:switch(o){case de.POS_INT:case de.NEG_INT:case de.TAG:throw new Error(`Invalid indefinite encoding for MT ${o}`)}n=-1;break;default:n=s}switch(o){case de.POS_INT:break;case de.NEG_INT:n=n===Number.MAX_SAFE_INTEGER?me.NEG_MAX:n instanceof he?me.MINUS_ONE.minus(n):-1-n;break;case de.BYTE_STRING:case de.UTF8_STRING:switch(n){case 0:this.emit("start-string",o,n,a,u),n=o===de.BYTE_STRING?t.allocUnsafe(0):"";break;case-1:this.emit("start",o,ge.STREAM,a,u),e=Ie(e,o),r++;continue;default:this.emit("start-string",o,n,a,u),n=yield n,o===de.UTF8_STRING&&(n=fe.utf8(n))}break;case de.ARRAY:case de.MAP:switch(n){case 0:n=o===de.MAP?{}:[];break;case-1:this.emit("start",o,ge.STREAM,a,u),e=Se(e,o,-1),r++;continue;default:this.emit("start",o,n,a,u),e=Se(e,o,n*(o-3)),r++;continue}break;case de.TAG:this.emit("start",o,n,a,u),e=Se(e,o,1),e.push(n),r++;continue;case de.SIMPLE_FLOAT:if("number"==typeof n){if(s===ye.ONE&&n<32)throw new Error(`Invalid two-byte encoding of simple value ${n}`);const t=null!=e;n=ce.decode(n,t,t&&e[be]<0)}else n=fe.parseCBORfloat(n)}this.emit("value",n,a,u,s);let c=!1;for(;null!=e;){switch(!1){case n!==ge.BREAK:e[be]=1;break;case!Array.isArray(e):e.push(n);break;case!(e instanceof pe):const t=e[Ee];if(null!=t&&t!==o)throw this.running=!1,new Error("Invalid major type in indefinite encoding");e.write(n)}if(0!=--e[be]){c=!0;break}if(--r,delete e[be],Array.isArray(e))switch(e[Ee]){case de.ARRAY:n=e;break;case de.MAP:let t=!0;if(e.length%2!=0)throw new Error("Invalid map length: "+e.length);for(let r=0,n=e.length;r<n;r+=2)if("string"!=typeof e[r]){t=!1;break}if(t){n={};for(let t=0,r=e.length;t<r;t+=2)n[e[t]]=e[t+1]}else{n=new Map;for(let t=0,r=e.length;t<r;t+=2)n.set(e[t],e[t+1])}break;case de.TAG:n=new ue(e[0],e[1]).convert(this.tags)}else if(e instanceof pe)switch(e[Ee]){case de.BYTE_STRING:n=e.slice();break;case de.UTF8_STRING:n=e.toString("utf-8")}this.emit("stop",e[Ee]);const t=e;e=e[ge.PARENT],delete t[ge.PARENT],delete t[Ee]}if(!c)return n}}};Ae.NOT_FOUND=ve;var Pe=Ae;const Oe=g,Ne=y,Ue=Pe,xe=H,Be=L.BigNumber,Re=Y,Me=xe.MT,Le=xe.NUMBYTES,Ce=xe.SYMS;function He(e){return e>1?"s":""}class De extends Oe.Transform{constructor(e){const t=Object.assign({depth:1,max_depth:10,no_summary:!1},e,{readableObjectMode:!1,writableObjectMode:!1}),r=t.max_depth;delete t.max_depth;const n=t.depth;delete t.depth,super(t),this.depth=n,this.max_depth=r,this.all=new Re,t.tags={24:this._tag_24.bind(this)},this.parser=new Ue(t),this.parser.on("value",this._on_value.bind(this)),this.parser.on("start",this._on_start.bind(this)),this.parser.on("start-string",this._on_start_string.bind(this)),this.parser.on("stop",this._on_stop.bind(this)),this.parser.on("more-bytes",this._on_more.bind(this)),this.parser.on("error",this._on_error.bind(this)),t.no_summary||this.parser.on("data",this._on_data.bind(this)),this.parser.bs.on("read",this._on_read.bind(this))}_tag_24(e){const t=new De({depth:this.depth+1,no_summary:!0});t.on("data",(e=>this.push(e))),t.on("error",(e=>this.emit("error",e))),t.end(e)}_transform(e,t,r){this.parser.write(e,t,r)}_flush(e){return this.parser._flush(e)}static comment(e,t,r){if(null==e)throw new Error("input required");let n="string"==typeof e?"hex":void 0,i=10;switch(typeof t){case"function":r=t;break;case"string":n=t;break;case"number":i=t;break;case"object":const e=t.encoding,o=t.max_depth;n=null!=e?e:n,i=null!=o?o:i;break;case"undefined":break;default:throw new Error("Unknown option type")}const o=new Re,s=new De({max_depth:i});let a=null;return"function"==typeof r?(s.on("end",(()=>{r(null,o.toString("utf8"))})),s.on("error",r)):a=new Promise(((e,t)=>(s.on("end",(()=>{e(o.toString("utf8"))})),s.on("error",t)))),s.pipe(o),s.end(e,n),a}_on_error(e){this.push("ERROR: "),this.push(e.toString()),this.push("\n")}_on_read(e){this.all.write(e);const t=e.toString("hex");this.push(new Array(this.depth+1).join(" ")),this.push(t);let r=2*(this.max_depth-this.depth);return r-=t.length,r<1&&(r=1),this.push(new Array(r+1).join(" ")),this.push("-- ")}_on_more(e,t,r,n){this.depth++;let i="";switch(e){case Me.POS_INT:i="Positive number,";break;case Me.NEG_INT:i="Negative number,";break;case Me.ARRAY:i="Array, length";break;case Me.MAP:i="Map, count";break;case Me.BYTE_STRING:i="Bytes, length";break;case Me.UTF8_STRING:i="String, length";break;case Me.SIMPLE_FLOAT:i=1===t?"Simple value,":"Float,"}return this.push(i+" next "+t+" byte"+He(t)+"\n")}_on_start_string(e,t,r,n){this.depth++;let i="";switch(e){case Me.BYTE_STRING:i="Bytes, length: "+t;break;case Me.UTF8_STRING:i="String, length: "+t.toString()}return this.push(i+"\n")}_on_start(e,t,r,n){if(this.depth++,t!==Ce.BREAK)switch(r){case Me.ARRAY:this.push(`[${n}], `);break;case Me.MAP:n%2?this.push(`{Val:${Math.floor(n/2)}}, `):this.push(`{Key:${Math.floor(n/2)}}, `)}switch(e){case Me.TAG:this.push(`Tag #${t}`),24==t&&this.push(" Encoded CBOR data item");break;case Me.ARRAY:t===Ce.STREAM?this.push("Array (streaming)"):this.push(`Array, ${t} item${He(t)}`);break;case Me.MAP:t===Ce.STREAM?this.push("Map (streaming)"):this.push(`Map, ${t} pair${He(t)}`);break;case Me.BYTE_STRING:this.push("Bytes (streaming)");break;case Me.UTF8_STRING:this.push("String (streaming)")}return this.push("\n")}_on_stop(e){return this.depth--}_on_value(e,t,n,i){if(e!==Ce.BREAK)switch(t){case Me.ARRAY:this.push(`[${n}], `);break;case Me.MAP:n%2?this.push(`{Val:${Math.floor(n/2)}}, `):this.push(`{Key:${Math.floor(n/2)}}, `)}switch(e===Ce.BREAK?this.push("BREAK\n"):e===Ce.NULL?this.push("null\n"):e===Ce.UNDEFINED?this.push("undefined\n"):"string"==typeof e?(this.depth--,e.length>0&&(this.push(JSON.stringify(e)),this.push("\n"))):r(e)?(this.depth--,e.length>0&&(this.push(e.toString("hex")),this.push("\n"))):e instanceof Be?(this.push(e.toString()),this.push("\n")):(this.push(Ne.inspect(e)),this.push("\n")),i){case Le.ONE:case Le.TWO:case Le.FOUR:case Le.EIGHT:this.depth--}}_on_data(){return this.push("0x"),this.push(this.all.read().toString("hex")),this.push("\n")}}var Fe=De;const je=g,Ve=y,Ke=Pe,Ge=C,We=H,qe=L.BigNumber,Xe=Y,ze=We.MT,$e=We.SYMS;class Ye extends je.Transform{constructor(e){const t=Object.assign({separator:"\n",stream_errors:!1},e,{readableObjectMode:!1,writableObjectMode:!1}),r=t.separator;delete t.separator;const n=t.stream_errors;delete t.stream_errors,super(t),this.float_bytes=-1,this.separator=r,this.stream_errors=n,this.parser=new Ke(t),this.parser.on("more-bytes",this._on_more.bind(this)),this.parser.on("value",this._on_value.bind(this)),this.parser.on("start",this._on_start.bind(this)),this.parser.on("stop",this._on_stop.bind(this)),this.parser.on("data",this._on_data.bind(this)),this.parser.on("error",this._on_error.bind(this))}_transform(e,t,r){return this.parser.write(e,t,r)}_flush(e){return this.parser._flush((t=>this.stream_errors?(t&&this._on_error(t),e()):e(t)))}static diagnose(e,t,r){if(null==e)throw new Error("input required");let n={},i="hex";switch(typeof t){case"function":r=t,i=Ge.guessEncoding(e);break;case"object":n=Ge.extend({},t),i=null!=n.encoding?n.encoding:Ge.guessEncoding(e),delete n.encoding;break;default:i=null!=t?t:"hex"}const o=new Xe,s=new Ye(n);let a=null;return"function"==typeof r?(s.on("end",(()=>r(null,o.toString("utf8")))),s.on("error",r)):a=new Promise(((e,t)=>(s.on("end",(()=>e(o.toString("utf8")))),s.on("error",t)))),s.pipe(o),s.end(e,i),a}_on_error(e){return this.stream_errors?this.push(e.toString()):this.emit("error",e)}_on_more(e,t,r,n){if(e===ze.SIMPLE_FLOAT)return this.float_bytes={2:1,4:2,8:3}[t]}_fore(e,t){switch(e){case ze.BYTE_STRING:case ze.UTF8_STRING:case ze.ARRAY:if(t>0)return this.push(", ");break;case ze.MAP:if(t>0)return t%2?this.push(": "):this.push(", ")}}_on_value(e,t,n){if(e!==$e.BREAK)return this._fore(t,n),this.push((()=>{switch(!1){case e!==$e.NULL:return"null";case e!==$e.UNDEFINED:return"undefined";case"string"!=typeof e:return JSON.stringify(e);case!(this.float_bytes>0):const t=this.float_bytes;return this.float_bytes=-1,Ve.inspect(e)+"_"+t;case!r(e):return"h'"+e.toString("hex")+"'";case!(e instanceof qe):return e.toString();default:return Ve.inspect(e)}})())}_on_start(e,t,r,n){switch(this._fore(r,n),e){case ze.TAG:this.push(`${t}(`);break;case ze.ARRAY:this.push("[");break;case ze.MAP:this.push("{");break;case ze.BYTE_STRING:case ze.UTF8_STRING:this.push("(")}if(t===$e.STREAM)return this.push("_ ")}_on_stop(e){switch(e){case ze.TAG:return this.push(")");case ze.ARRAY:return this.push("]");case ze.MAP:return this.push("}");case ze.BYTE_STRING:case ze.UTF8_STRING:return this.push(")")}}_on_data(){return this.push(this.separator)}}var Je=Ye;const Qe=g,Ze=c;L.BigNumber;const et=Y,tt=C,rt=H,nt=rt.MT,it=rt.NUMBYTES,ot=rt.SHIFT32,st=rt.SYMS,at=rt.TAG,ut=rt.MT.SIMPLE_FLOAT<<5|rt.NUMBYTES.TWO,ct=rt.MT.SIMPLE_FLOAT<<5|rt.NUMBYTES.FOUR,ft=rt.MT.SIMPLE_FLOAT<<5|rt.NUMBYTES.EIGHT,ht=rt.MT.SIMPLE_FLOAT<<5|rt.SIMPLE.TRUE,pt=rt.MT.SIMPLE_FLOAT<<5|rt.SIMPLE.FALSE,lt=rt.MT.SIMPLE_FLOAT<<5|rt.SIMPLE.UNDEFINED,dt=rt.MT.SIMPLE_FLOAT<<5|rt.SIMPLE.NULL,yt=t.from([255]),gt=tt.bigIntize(rt.BI),wt=rt.BN,mt=t.from("f97e00","hex"),bt=t.from("f9fc00","hex"),Et=t.from("f97c00","hex"),_t=t.from("f98000","hex"),vt=Symbol("CBOR_LOOP_DETECT");let St=class e extends Qe.Transform{constructor(e){const t=Object.assign({},e,{readableObjectMode:!1,writableObjectMode:!0});super(t),this.canonical=t.canonical,this.encodeUndefined=t.encodeUndefined,this.disallowUndefinedKeys=!!t.disallowUndefinedKeys,this.dateType=null!=t.dateType?t.dateType.toLowerCase():"number",this.collapseBigIntegers=!!t.collapseBigIntegers,"symbol"==typeof t.detectLoops?this.detectLoops=t.detectLoops:this.detectLoops=t.detectLoops?Symbol("CBOR_DETECT"):null,this.semanticTypes={Array:this._pushArray,Date:this._pushDate,Buffer:this._pushBuffer,Map:this._pushMap,NoFilter:this._pushNoFilter,RegExp:this._pushRegexp,Set:this._pushSet,BigNumber:this._pushBigNumber,ArrayBuffer:this._pushUint8Array,Uint8ClampedArray:this._pushUint8Array,Uint8Array:this._pushUint8Array,Uint16Array:this._pushArray,Uint32Array:this._pushArray,Int8Array:this._pushArray,Int16Array:this._pushArray,Int32Array:this._pushArray,Float32Array:this._pushFloat32Array,Float64Array:this._pushFloat64Array},Ze.Url&&this.addSemanticType("Url",this._pushUrl),Ze.URL&&this.addSemanticType("URL",this._pushURL);const r=t.genTypes||[];for(let e=0,t=r.length;e<t;e+=2)this.addSemanticType(r[e],r[e+1])}_transform(e,t,r){return r(!1===this.pushAny(e)?new Error("Push Error"):void 0)}_flush(e){return e()}addSemanticType(e,t){if("function"!=typeof t)throw new TypeError("fun must be of type function");const r="string"==typeof e?e:e.name,n=this.semanticTypes[r];return this.semanticTypes[r]=t,n}_pushUInt8(e){const r=t.allocUnsafe(1);return r.writeUInt8(e,0),this.push(r)}_pushUInt16BE(e){const r=t.allocUnsafe(2);return r.writeUInt16BE(e,0),this.push(r)}_pushUInt32BE(e){const r=t.allocUnsafe(4);return r.writeUInt32BE(e,0),this.push(r)}_pushFloatBE(e){const r=t.allocUnsafe(4);return r.writeFloatBE(e,0),this.push(r)}_pushDoubleBE(e){const r=t.allocUnsafe(8);return r.writeDoubleBE(e,0),this.push(r)}_pushNaN(){return this.push(mt)}_pushInfinity(e){const t=e<0?bt:Et;return this.push(t)}_pushFloat(e){if(this.canonical){const r=t.allocUnsafe(2);if(tt.writeHalf(r,e))return this._pushUInt8(ut)&&this.push(r)}return Math.fround(e)===e?this._pushUInt8(ct)&&this._pushFloatBE(e):this._pushUInt8(ft)&&this._pushDoubleBE(e)}_pushInt(e,t,r){const n=t<<5;switch(!1){case!(e<24):return this._pushUInt8(n|e);case!(e<=255):return this._pushUInt8(n|it.ONE)&&this._pushUInt8(e);case!(e<=65535):return this._pushUInt8(n|it.TWO)&&this._pushUInt16BE(e);case!(e<=4294967295):return this._pushUInt8(n|it.FOUR)&&this._pushUInt32BE(e);case!(e<=Number.MAX_SAFE_INTEGER):return this._pushUInt8(n|it.EIGHT)&&this._pushUInt32BE(Math.floor(e/ot))&&this._pushUInt32BE(e%ot);default:return t===nt.NEG_INT?this._pushFloat(r):this._pushFloat(e)}}_pushIntNum(e){return Object.is(e,-0)?this.push(_t):e<0?this._pushInt(-e-1,nt.NEG_INT,e):this._pushInt(e,nt.POS_INT)}_pushNumber(e){switch(!1){case!isNaN(e):return this._pushNaN();case isFinite(e):return this._pushInfinity(e);case Math.round(e)!==e:return this._pushIntNum(e);default:return this._pushFloat(e)}}_pushString(e){const r=t.byteLength(e,"utf8");return this._pushInt(r,nt.UTF8_STRING)&&this.push(e,"utf8")}_pushBoolean(e){return this._pushUInt8(e?ht:pt)}_pushUndefined(e){switch(typeof this.encodeUndefined){case"undefined":return this._pushUInt8(lt);case"function":return this.pushAny(this.encodeUndefined.call(this,e));case"object":if(r(this.encodeUndefined))return this.push(this.encodeUndefined)}return this.pushAny(this.encodeUndefined)}_pushNull(e){return this._pushUInt8(dt)}_pushArray(e,t,r){r=Object.assign({indefinite:!1},r);const n=t.length;if(r.indefinite){if(!e._pushUInt8(nt.ARRAY<<5|it.INDEFINITE))return!1}else if(!e._pushInt(n,nt.ARRAY))return!1;for(let r=0;r<n;r++)if(!e.pushAny(t[r]))return!1;return!(r.indefinite&&!e.push(yt))}_pushTag(e){return this._pushInt(e,nt.TAG)}_pushDate(e,t){switch(e.dateType){case"string":return e._pushTag(at.DATE_STRING)&&e._pushString(t.toISOString());case"int":case"integer":return e._pushTag(at.DATE_EPOCH)&&e._pushIntNum(Math.round(t/1e3));case"float":return e._pushTag(at.DATE_EPOCH)&&e._pushFloat(t/1e3);default:return e._pushTag(at.DATE_EPOCH)&&e.pushAny(t/1e3)}}_pushBuffer(e,t){return e._pushInt(t.length,nt.BYTE_STRING)&&e.push(t)}_pushNoFilter(e,t){return e._pushBuffer(e,t.slice())}_pushRegexp(e,t){return e._pushTag(at.REGEXP)&&e.pushAny(t.source)}_pushSet(e,t){if(!e._pushInt(t.size,nt.ARRAY))return!1;for(const r of t)if(!e.pushAny(r))return!1;return!0}_pushUrl(e,t){return e._pushTag(at.URI)&&e.pushAny(t.format())}_pushURL(e,t){return e._pushTag(at.URI)&&e.pushAny(t.toString())}_pushBigint(e){let r=nt.POS_INT,n=at.POS_BIGINT;if(e.isNegative()&&(e=e.negated().minus(1),r=nt.NEG_INT,n=at.NEG_BIGINT),this.collapseBigIntegers&&e.lte(wt.MAXINT64))return e.lte(wt.MAXINT32)?this._pushInt(e.toNumber(),r):this._pushUInt8(r<<5|it.EIGHT)&&this._pushUInt32BE(e.dividedToIntegerBy(wt.SHIFT32).toNumber())&&this._pushUInt32BE(e.mod(wt.SHIFT32).toNumber());let i=e.toString(16);i.length%2&&(i="0"+i);const o=t.from(i,"hex");return this._pushTag(n)&&this._pushBuffer(this,o)}_pushJSBigint(e){let r=nt.POS_INT,n=at.POS_BIGINT;if(e<0&&(e=-e+gt.MINUS_ONE,r=nt.NEG_INT,n=at.NEG_BIGINT),this.collapseBigIntegers&&e<=gt.MAXINT64)return e<=4294967295?this._pushInt(Number(e),r):this._pushUInt8(r<<5|it.EIGHT)&&this._pushUInt32BE(Number(e/gt.SHIFT32))&&this._pushUInt32BE(Number(e%gt.SHIFT32));let i=e.toString(16);i.length%2&&(i="0"+i);const o=t.from(i,"hex");return this._pushTag(n)&&this._pushBuffer(this,o)}_pushBigNumber(e,t){if(t.isNaN())return e._pushNaN();if(!t.isFinite())return e._pushInfinity(t.isNegative()?-1/0:1/0);if(t.isInteger())return e._pushBigint(t);if(!e._pushTag(at.DECIMAL_FRAC)||!e._pushInt(2,nt.ARRAY))return!1;const r=t.decimalPlaces(),n=t.shiftedBy(r);return!!e._pushIntNum(-r)&&(n.abs().isLessThan(wt.MAXINT)?e._pushIntNum(n.toNumber()):e._pushBigint(n))}_pushMap(t,r,n){if((n=Object.assign({indefinite:!1},n)).indefinite){if(!t._pushUInt8(nt.MAP<<5|it.INDEFINITE))return!1}else if(!t._pushInt(r.size,nt.MAP))return!1;if(t.canonical){const n=[...r.entries()],i=new e(this),o=new et({highWaterMark:this.readableHighWaterMark});i.pipe(o),n.sort((([e],[t])=>{i.pushAny(e);const r=o.read();i.pushAny(t);const n=o.read();return r.compare(n)}));for(const[e,r]of n){if(t.disallowUndefinedKeys&&void 0===e)throw new Error("Invalid Map key: undefined");if(!t.pushAny(e)||!t.pushAny(r))return!1}}else for(const[e,n]of r){if(t.disallowUndefinedKeys&&void 0===e)throw new Error("Invalid Map key: undefined");if(!t.pushAny(e)||!t.pushAny(n))return!1}return!(n.indefinite&&!t.push(yt))}_pushUint8Array(e,r){return e._pushBuffer(e,t.from(r))}_pushFloat32Array(e,t){const r=t.length;if(!e._pushInt(r,nt.ARRAY))return!1;for(let n=0;n<r;n++)if(!e._pushUInt8(ct)||!e._pushFloatBE(t[n]))return!1;return!0}_pushFloat64Array(e,t){const r=t.length;if(!e._pushInt(r,nt.ARRAY))return!1;for(let n=0;n<r;n++)if(!e._pushUInt8(ft)||!e._pushDoubleBE(t[n]))return!1;return!0}removeLoopDetectors(t){return!!this.detectLoops&&e.removeLoopDetectors(t,this.detectLoops)}static removeLoopDetectors(e,t=null){if("object"!=typeof e||!e)return!1;const r=e[vt];if(!r)return!1;if(null==t)t=r;else if(t!==r)return!1;if(delete e[vt],Array.isArray(e))for(const r of e)this.removeLoopDetectors(r,t);else for(const r in e)this.removeLoopDetectors(e[r],t);return!0}_pushObject(t,r){if(!t)return this._pushNull(t);if(!(r=Object.assign({indefinite:!1,skipTypes:!1},r)).indefinite&&this.detectLoops){if(t[vt]===this.detectLoops)throw new Error("Loop detected while CBOR encoding");t[vt]=this.detectLoops}if(!r.skipTypes){const e=t.encodeCBOR;if("function"==typeof e)return e.call(t,this);const r=this.semanticTypes[t.constructor.name];if(r)return r.call(t,this,t)}const n=Object.keys(t).filter((e=>"function"!=typeof t[e])),i={};if(this.canonical&&n.sort(((t,r)=>{const n=i[t]||(i[t]=e.encode(t)),o=i[r]||(i[r]=e.encode(r));return n.compare(o)})),r.indefinite){if(!this._pushUInt8(nt.MAP<<5|it.INDEFINITE))return!1}else if(!this._pushInt(n.length,nt.MAP))return!1;let o;for(let e=0,r=n.length;e<r;e++){const r=n[e];if(this.canonical&&(o=i[r])){if(!this.push(o))return!1}else if(!this._pushString(r))return!1;if(!this.pushAny(t[r]))return!1}return!(r.indefinite&&!this.push(yt))}pushAny(e){switch(typeof e){case"number":return this._pushNumber(e);case"bigint":return this._pushJSBigint(e);case"string":return this._pushString(e);case"boolean":return this._pushBoolean(e);case"undefined":return this._pushUndefined(e);case"object":return this._pushObject(e);case"symbol":switch(e){case st.NULL:return this._pushNull(null);case st.UNDEFINED:return this._pushUndefined(void 0);default:throw new Error("Unknown symbol: "+e.toString())}default:throw new Error("Unknown type: "+typeof e+", "+(e.toString?e.toString():""))}}_pushAny(e){return this.pushAny(e)}_encodeAll(e){const t=new et({highWaterMark:this.readableHighWaterMark});this.pipe(t);for(const t of e)this.pushAny(t);return this.end(),t.read()}static encodeIndefinite(e,t,n){if(null==t){if(null==this)throw new Error("No object to encode");t=this}n=Object.assign({chunkSize:4096},n);let i=!0;const o=typeof t;if("string"===o){i=i&&e._pushUInt8(nt.UTF8_STRING<<5|it.INDEFINITE);let r=0;for(;r<t.length;){const o=r+n.chunkSize;i=i&&e._pushString(t.slice(r,o)),r=o}i=i&&e.push(yt)}else if(r(t)){i=i&&e._pushUInt8(nt.BYTE_STRING<<5|it.INDEFINITE);let r=0;for(;r<t.length;){const o=r+n.chunkSize;i=i&&e._pushBuffer(e,t.slice(r,o)),r=o}i=i&&e.push(yt)}else if(Array.isArray(t))i=i&&e._pushArray(e,t,{indefinite:!0});else if(t instanceof Map)i=i&&e._pushMap(e,t,{indefinite:!0});else{if("object"!==o)throw new Error("Invalid indefinite encoding");i=i&&e._pushObject(t,{indefinite:!0,skipTypes:!0})}return i}static encode(...t){return(new e)._encodeAll(t)}static encodeCanonical(...t){return new e({canonical:!0})._encodeAll(t)}static encodeOne(t,r){return new e(r)._encodeAll([t])}static encodeAsync(r,n){return new Promise(((i,o)=>{const s=[],a=new e(n);a.on("data",(e=>s.push(e))),a.on("error",o),a.on("finish",(()=>i(t.concat(s)))),a.pushAny(r),a.end()}))}};var It=St;const Tt=It,kt=Pe,At=H.MT;class Pt extends Map{constructor(e){super(e)}static _encode(e){return Tt.encodeCanonical(e).toString("base64")}static _decode(e){return kt.decodeFirstSync(e,"base64")}get(e){return super.get(Pt._encode(e))}set(e,t){return super.set(Pt._encode(e),t)}delete(e){return super.delete(Pt._encode(e))}has(e){return super.has(Pt._encode(e))}*keys(){for(const e of super.keys())yield Pt._decode(e)}*entries(){for(const e of super.entries())yield[Pt._decode(e[0]),e[1]]}[Symbol.iterator](){return this.entries()}forEach(e,t){if("function"!=typeof e)throw new TypeError("Must be function");for(const t of super.entries())e.call(this,t[1],Pt._decode(t[0]),this)}encodeCBOR(e){if(!e._pushInt(this.size,At.MAP))return!1;if(e.canonical){const r=Array.from(super.entries()).map((e=>[t.from(e[0],"base64"),e[1]]));r.sort(((e,t)=>e[0].compare(t[0])));for(const t of r)if(!e.push(t[0])||!e.pushAny(t[1]))return!1}else for(const r of super.entries())if(!e.push(t.from(r[0],"base64"))||!e.pushAny(r[1]))return!1;return!0}}var Ot,Nt=Pt;(Ot=R).BigNumber=L.BigNumber,Ot.Commented=Fe,Ot.Diagnose=Je,Ot.Decoder=Pe,Ot.Encoder=It,Ot.Simple=G,Ot.Tagged=oe,Ot.Map=Nt,Ot.comment=Ot.Commented.comment,Ot.decodeAll=Ot.Decoder.decodeAll,Ot.decodeFirst=Ot.Decoder.decodeFirst,Ot.decodeAllSync=Ot.Decoder.decodeAllSync,Ot.decodeFirstSync=Ot.Decoder.decodeFirstSync,Ot.diagnose=Ot.Diagnose.diagnose,Ot.encode=Ot.Encoder.encode,Ot.encodeCanonical=Ot.Encoder.encodeCanonical,Ot.encodeOne=Ot.Encoder.encodeOne,Ot.encodeAsync=Ot.Encoder.encodeAsync,Ot.decode=Ot.Decoder.decodeFirstSync,Ot.leveldb={decode:Ot.Decoder.decodeAllSync,encode:Ot.Encoder.encode,buffer:!0,name:"cbor"},Ot.hasBigInt=C.hasBigInt;var Ut={exports:{}};var xt=class{constructor(e,t,r,n){this.name=e,this.code=t,this.alphabet=n,r&&n&&(this.engine=r(n))}encode(e){return this.engine.encode(e)}decode(e){return this.engine.decode(e)}isImplemented(){return this.engine}},Bt=d.Buffer;var Rt=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 i=e.charAt(n),o=i.charCodeAt(0);if(255!==t[o])throw new TypeError(i+" is ambiguous");t[o]=n}var s=e.length,a=e.charAt(0),u=Math.log(s)/Math.log(256),c=Math.log(256)/Math.log(s);function f(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return Bt.alloc(0);for(var r=0,n=0,i=0;e[r]===a;)n++,r++;for(var o=(e.length-r)*u+1>>>0,c=new Uint8Array(o);e[r];){var f=t[e.charCodeAt(r)];if(255===f)return;for(var h=0,p=o-1;(0!==f||h<i)&&-1!==p;p--,h++)f+=s*c[p]>>>0,c[p]=f%256>>>0,f=f/256>>>0;if(0!==f)throw new Error("Non-zero carry");i=h,r++}for(var l=o-i;l!==o&&0===c[l];)l++;var d=Bt.allocUnsafe(n+(o-l));d.fill(0,0,n);for(var y=n;l!==o;)d[y++]=c[l++];return d}return{encode:function(t){if((Array.isArray(t)||t instanceof Uint8Array)&&(t=Bt.from(t)),!Bt.isBuffer(t))throw new TypeError("Expected Buffer");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var u=(o-i)*c+1>>>0,f=new Uint8Array(u);i!==o;){for(var h=t[i],p=0,l=u-1;(0!==h||p<n)&&-1!==l;l--,p++)h+=256*f[l]>>>0,f[l]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");n=p,i++}for(var d=u-n;d!==u&&0===f[d];)d++;for(var y=a.repeat(r);d<u;++d)y+=e.charAt(f[d]);return y},decodeUnsafe:f,decode:function(e){var t=f(e);if(t)return t;throw new Error("Non-base"+s+" character")}}};const{Buffer:Mt}=E;function Lt(e,t){const r=e.byteLength,n=new Uint8Array(e),i=t.indexOf("=")===t.length-1;i&&(t=t.substring(0,t.length-1));let o=0,s=0,a="";for(let e=0;e<r;e++)for(s=s<<8|n[e],o+=8;o>=5;)a+=t[s>>>o-5&31],o-=5;if(o>0&&(a+=t[s<<5-o&31]),i)for(;a.length%8!=0;)a+="=";return a}const{Buffer:Ct}=E;const Ht=xt,Dt=function(e){return{encode:t=>Lt("string"==typeof t?Uint8Array.from(t):t,e),decode(t){for(const r of t)if(e.indexOf(r)<0)throw new Error("invalid base32 character");return function(e,t){const r=(e=e.replace(new RegExp("=","g"),"")).length;let n=0,i=0,o=0;const s=new Uint8Array(5*r/8|0);for(let a=0;a<r;a++)i=i<<5|t.indexOf(e[a]),n+=5,n>=8&&(s[o++]=i>>>n-8&255,n-=8);return s.buffer}(t,e)}}},Ft=function(e){const t=e.indexOf("=")>-1,r=e.indexOf("-")>-1&&e.indexOf("_")>-1;return{encode(e){let n="";n="string"==typeof e?Ct.from(e).toString("base64"):e.toString("base64"),r&&(n=n.replace(/\+/g,"-").replace(/\//g,"_"));const i=n.indexOf("=");return i>0&&!t&&(n=n.substring(0,i)),n},decode(t){for(const r of t)if(e.indexOf(r)<0)throw new Error("invalid base64 character");return Ct.from(t,"base64")}}},jt=[["base1","1","","1"],["base2","0",Rt,"01"],["base8","7",Rt,"01234567"],["base10","9",Rt,"0123456789"],["base16","f",function(e){return{encode:e=>"string"==typeof e?Mt.from(e).toString("hex"):e.toString("hex"),decode(t){for(const r of t)if(e.indexOf(r)<0)throw new Error("invalid base16 character");return Mt.from(t,"hex")}}},"0123456789abcdef"],["base32","b",Dt,"abcdefghijklmnopqrstuvwxyz234567"],["base32pad","c",Dt,"abcdefghijklmnopqrstuvwxyz234567="],["base32hex","v",Dt,"0123456789abcdefghijklmnopqrstuv"],["base32hexpad","t",Dt,"0123456789abcdefghijklmnopqrstuv="],["base32z","h",Dt,"ybndrfg8ejkmcpqxot1uwisza345h769"],["base58flickr","Z",Rt,"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],["base58btc","z",Rt,"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],["base64","m",Ft,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],["base64pad","M",Ft,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="],["base64url","u",Ft,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"],["base64urlpad","U",Ft,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_="]],Vt=jt.reduce(((e,t)=>(e[t[0]]=new Ht(t[0],t[1],t[2],t[3]),e)),{}),Kt=jt.reduce(((e,t)=>(e[t[1]]=Vt[t[0]],e)),{});var Gt={names:Vt,codes:Kt};!function(e,t){const{Buffer:r}=E,n=Gt;(t=e.exports=o).encode=function(e,t){const n=s(e),i=n.name;return o(i,r.from(n.encode(t)))},t.decode=function(e){r.isBuffer(e)&&(e=e.toString());const t=e.substring(0,1);"string"==typeof(e=e.substring(1,e.length))&&(e=r.from(e));const n=s(t);return r.from(n.decode(e.toString()))},t.isEncoded=function(e){r.isBuffer(e)&&(e=e.toString());if("[object String]"!==Object.prototype.toString.call(e))return!1;const t=e.substring(0,1);try{return s(t).name}catch(e){return!1}},t.names=Object.freeze(Object.keys(n.names)),t.codes=Object.freeze(Object.keys(n.codes));const i=new Error("Unsupported encoding");function o(e,t){if(!t)throw new Error("requires an encoded buffer");const n=s(e),i=r.from(n.code);return function(e,t){const r=s(e);r.decode(t.toString())}(n.name,t),r.concat([i,t])}function s(e){let t;if(n.names[e])t=n.names[e];else{if(!n.codes[e])throw i;t=n.codes[e]}if(!t.isImplemented())throw new Error("Base "+e+" is not implemented yet");return t}}(Ut,Ut.exports);var Wt=Ut.exports,qt=9007199254740991,Xt="[object Arguments]",zt="[object Function]",$t="[object GeneratorFunction]",Yt="object"==typeof e&&e&&e.Object===Object&&e,Jt="object"==typeof self&&self&&self.Object===Object&&self,Qt=Yt||Jt||Function("return this")();function Zt(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}var er=Object.prototype,tr=er.hasOwnProperty,rr=er.toString,nr=Qt.Symbol,ir=er.propertyIsEnumerable,or=nr?nr.isConcatSpreadable:void 0;function sr(e){return ar(e)||function(e){return function(e){return function(e){return!!e&&"object"==typeof e}(e)&&function(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=qt}(e.length)&&!function(e){var t=function(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}(e)?rr.call(e):"";return t==zt||t==$t}(e)}(e)}(e)&&tr.call(e,"callee")&&(!ir.call(e,"callee")||rr.call(e)==Xt)}(e)||!!(or&&e&&e[or])}var ar=Array.isArray;var ur=function(e){return(e?e.length:0)?function(e,t,r,n,i){var o=-1,s=e.length;for(r||(r=sr),i||(i=[]);++o<s;){var a=e[o];r(a)?Zt(i,a):i[i.length]=a}return i}(e):[]};const{validate:cr}=U,fr=B,hr=R,pr=Wt,lr=ur;var dr=class{constructor(e){if(!cr(e))throw new Error("JSON is invalid. Cannot construct Encoder.");this.json=e}constructRootMap(){return Object.keys(this.json).map((e=>{let r=this.json[e];return"string"==typeof r&&(r=hr.encode(t.from(r,"hex"))),r instanceof Array&&("anchors"===e&&(r=this.constructAnchorsMap(r)),"path"===e&&(r=this.constructPathMap(r))),[fr.root[e],r]}))}constructAnchorsMap(e){return e.map((e=>{let r=e.split(":");return r.shift(),r.map(((e,n)=>0===n?[n,fr.chain[e].id]:1===n?[n,fr.chain[r[n-1]].networks[e]]:[n,hr.encode(t.from(e,"hex"))]))}))}constructPathMap(e){return lr(e.map((e=>Object.keys(e).map((r=>[fr.path[r],hr.encode(t.from(e[r],"hex"))])))))}encode(){const e=this.constructRootMap(),t=hr.encode(e);return pr.encode("base58btc",t)}},yr=9007199254740991,gr="[object Arguments]",wr="[object Function]",mr="[object GeneratorFunction]",br=/^(?:0|[1-9]\d*)$/;var Er,_r,vr=Object.prototype,Sr=vr.hasOwnProperty,Ir=vr.toString,Tr=vr.propertyIsEnumerable,kr=(Er=Object.keys,_r=Object,function(e){return Er(_r(e))});function Ar(e,t){var r=xr(e)||function(e){return function(e){return function(e){return!!e&&"object"==typeof e}(e)&&Br(e)}(e)&&Sr.call(e,"callee")&&(!Tr.call(e,"callee")||Ir.call(e)==gr)}(e)?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],n=r.length,i=!!n;for(var o in e)!Sr.call(e,o)||i&&("length"==o||Ur(o,n))||r.push(o);return r}var Pr=function(e,t,r){for(var n=-1,i=Object(e),o=r(e),s=o.length;s--;){var a=o[++n];if(!1===t(i[a],a,i))break}return e};function Or(e,t,r,n){return function(e,t){e&&Pr(e,t,Cr)}(e,(function(e,i,o){t(n,r(e),i,o)})),n}function Nr(e){if(!function(e){var t=e&&e.constructor,r="function"==typeof t&&t.prototype||vr;return e===r}(e))return kr(e);var t=[];for(var r in Object(e))Sr.call(e,r)&&"constructor"!=r&&t.push(r);return t}function Ur(e,t){return!!(t=null==t?yr:t)&&("number"==typeof e||br.test(e))&&e>-1&&e%1==0&&e<t}var xr=Array.isArray;function Br(e){return null!=e&&function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=yr}(e.length)&&!function(e){var t=function(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}(e)?Ir.call(e):"";return t==wr||t==mr}(e)}var Rr,Mr,Lr=(Rr=function(e,t,r){e[t]=r},Mr=function(e){return function(){return e}}((function(e){return e})),function(e,t){return Or(e,Rr,Mr(t),{})});function Cr(e){return Br(e)?Ar(e):Nr(e)}var Hr=Lr,Dr={exports:{}};!function(t,r){var n="__lodash_hash_undefined__",i=9007199254740991,o="[object Arguments]",s="[object Array]",a="[object Boolean]",u="[object Date]",c="[object Error]",f="[object Function]",h="[object Map]",p="[object Number]",l="[object Object]",d="[object Promise]",y="[object RegExp]",g="[object Set]",w="[object String]",m="[object Symbol]",b="[object WeakMap]",E="[object ArrayBuffer]",_="[object DataView]",v=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,S=/^\w*$/,I=/^\./,T=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,k=/\\(\\)?/g,A=/^\[object .+?Constructor\]$/,P=/^(?:0|[1-9]\d*)$/,O={};O["[object Float32Array]"]=O["[object Float64Array]"]=O["[object Int8Array]"]=O["[object Int16Array]"]=O["[object Int32Array]"]=O["[object Uint8Array]"]=O["[object Uint8ClampedArray]"]=O["[object Uint16Array]"]=O["[object Uint32Array]"]=!0,O[o]=O[s]=O[E]=O[a]=O[_]=O[u]=O[c]=O[f]=O[h]=O[p]=O[l]=O[y]=O[g]=O[w]=O[b]=!1;var N="object"==typeof e&&e&&e.Object===Object&&e,U="object"==typeof self&&self&&self.Object===Object&&self,x=N||U||Function("return this")(),B=r&&!r.nodeType&&r,R=B&&t&&!t.nodeType&&t,M=R&&R.exports===B&&N.process,L=function(){try{return M&&M.binding("util")}catch(e){}}(),C=L&&L.isTypedArray;function H(e,t){for(var r=-1,n=e?e.length:0;++r<n;)if(t(e[r],r,e))return!0;return!1}function D(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}function F(e){var t=-1,r=Array(e.size);return e.forEach((function(e,n){r[++t]=[n,e]})),r}function j(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=e})),r}var V,K=Array.prototype,G=Function.prototype,W=Object.prototype,q=x["__core-js_shared__"],X=(V=/[^.]+$/.exec(q&&q.keys&&q.keys.IE_PROTO||""))?"Symbol(src)_1."+V:"",z=G.toString,$=W.hasOwnProperty,Y=W.toString,J=RegExp("^"+z.call($).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Q=x.Symbol,Z=x.Uint8Array,ee=W.propertyIsEnumerable,te=K.splice,re=function(e,t){return function(r){return e(t(r))}}(Object.keys,Object),ne=Re(x,"DataView"),ie=Re(x,"Map"),oe=Re(x,"Promise"),se=Re(x,"Set"),ae=Re(x,"WeakMap"),ue=Re(Object,"create"),ce=Ve(ne),fe=Ve(ie),he=Ve(oe),pe=Ve(se),le=Ve(ae),de=Q?Q.prototype:void 0,ye=de?de.valueOf:void 0,ge=de?de.toString:void 0;function we(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function me(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function be(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Ee(e){var t=-1,r=e?e.length:0;for(this.__data__=new be;++t<r;)this.add(e[t])}function _e(e){this.__data__=new me(e)}function ve(e,t){var r=qe(e)||We(e)?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],n=r.length,i=!!n;for(var o in e)!$.call(e,o)||i&&("length"==o||Le(o,n))||r.push(o);return r}function Se(e,t){for(var r=e.length;r--;)if(Ge(e[r][0],t))return r;return-1}we.prototype.clear=function(){this.__data__=ue?ue(null):{}},we.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},we.prototype.get=function(e){var t=this.__data__;if(ue){var r=t[e];return r===n?void 0:r}return $.call(t,e)?t[e]:void 0},we.prototype.has=function(e){var t=this.__data__;return ue?void 0!==t[e]:$.call(t,e)},we.prototype.set=function(e,t){return this.__data__[e]=ue&&void 0===t?n:t,this},me.prototype.clear=function(){this.__data__=[]},me.prototype.delete=function(e){var t=this.__data__,r=Se(t,e);return!(r<0)&&(r==t.length-1?t.pop():te.call(t,r,1),!0)},me.prototype.get=function(e){var t=this.__data__,r=Se(t,e);return r<0?void 0:t[r][1]},me.prototype.has=function(e){return Se(this.__data__,e)>-1},me.prototype.set=function(e,t){var r=this.__data__,n=Se(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},be.prototype.clear=function(){this.__data__={hash:new we,map:new(ie||me),string:new we}},be.prototype.delete=function(e){return Be(this,e).delete(e)},be.prototype.get=function(e){return Be(this,e).get(e)},be.prototype.has=function(e){return Be(this,e).has(e)},be.prototype.set=function(e,t){return Be(this,e).set(e,t),this},Ee.prototype.add=Ee.prototype.push=function(e){return this.__data__.set(e,n),this},Ee.prototype.has=function(e){return this.__data__.has(e)},_e.prototype.clear=function(){this.__data__=new me},_e.prototype.delete=function(e){return this.__data__.delete(e)},_e.prototype.get=function(e){return this.__data__.get(e)},_e.prototype.has=function(e){return this.__data__.has(e)},_e.prototype.set=function(e,t){var r=this.__data__;if(r instanceof me){var n=r.__data__;if(!ie||n.length<199)return n.push([e,t]),this;r=this.__data__=new be(n)}return r.set(e,t),this};var Ie=function(e,t,r){for(var n=-1,i=Object(e),o=r(e),s=o.length;s--;){var a=o[++n];if(!1===t(i[a],a,i))break}return e};function Te(e,t){for(var r=0,n=(t=Ce(t,e)?[t]:Ue(t)).length;null!=e&&r<n;)e=e[je(t[r++])];return r&&r==n?e:void 0}function ke(e,t){return null!=e&&t in Object(e)}function Ae(e,t,r,n){return function(e,t){e&&Ie(e,t,tt)}(e,(function(e,i,o){t(n,r(e),i,o)})),n}function Pe(e,t,r,n,i){return e===t||(null==e||null==t||!Ye(e)&&!Je(t)?e!=e&&t!=t:function(e,t,r,n,i,f){var d=qe(e),b=qe(t),v=s,S=s;d||(v=(v=Me(e))==o?l:v);b||(S=(S=Me(t))==o?l:S);var I=v==l&&!D(e),T=S==l&&!D(t),k=v==S;if(k&&!I)return f||(f=new _e),d||Ze(e)?xe(e,t,r,n,i,f):function(e,t,r,n,i,o,s){switch(r){case _:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case E:return!(e.byteLength!=t.byteLength||!n(new Z(e),new Z(t)));case a:case u:case p:return Ge(+e,+t);case c:return e.name==t.name&&e.message==t.message;case y:case w:return e==t+"";case h:var f=F;case g:var l=2&o;if(f||(f=j),e.size!=t.size&&!l)return!1;var d=s.get(e);if(d)return d==t;o|=1,s.set(e,t);var b=xe(f(e),f(t),n,i,o,s);return s.delete(e),b;case m:if(ye)return ye.call(e)==ye.call(t)}return!1}(e,t,v,r,n,i,f);if(!(2&i)){var A=I&&$.call(e,"__wrapped__"),P=T&&$.call(t,"__wrapped__");if(A||P){var O=A?e.value():e,N=P?t.value():t;return f||(f=new _e),r(O,N,n,i,f)}}if(!k)return!1;return f||(f=new _e),function(e,t,r,n,i,o){var s=2&i,a=tt(e),u=a.length,c=tt(t),f=c.length;if(u!=f&&!s)return!1;var h=u;for(;h--;){var p=a[h];if(!(s?p in t:$.call(t,p)))return!1}var l=o.get(e);if(l&&o.get(t))return l==t;var d=!0;o.set(e,t),o.set(t,e);var y=s;for(;++h<u;){var g=e[p=a[h]],w=t[p];if(n)var m=s?n(w,g,p,t,e,o):n(g,w,p,e,t,o);if(!(void 0===m?g===w||r(g,w,n,i,o):m)){d=!1;break}y||(y="constructor"==p)}if(d&&!y){var b=e.constructor,E=t.constructor;b==E||!("constructor"in e)||!("constructor"in t)||"function"==typeof b&&b instanceof b&&"function"==typeof E&&E instanceof E||(d=!1)}return o.delete(e),o.delete(t),d}(e,t,r,n,i,f)}(e,t,Pe,r,n,i))}function Oe(e){return!(!Ye(e)||function(e){return!!X&&X in e}(e))&&(ze(e)||D(e)?J:A).test(Ve(e))}function Ne(e){if(!function(e){var t=e&&e.constructor,r="function"==typeof t&&t.prototype||W;return e===r}(e))return re(e);var t=[];for(var r in Object(e))$.call(e,r)&&"constructor"!=r&&t.push(r);return t}function Ue(e){return qe(e)?e:Fe(e)}function xe(e,t,r,n,i,o){var s=2&i,a=e.length,u=t.length;if(a!=u&&!(s&&u>a))return!1;var c=o.get(e);if(c&&o.get(t))return c==t;var f=-1,h=!0,p=1&i?new Ee:void 0;for(o.set(e,t),o.set(t,e);++f<a;){var l=e[f],d=t[f];if(n)var y=s?n(d,l,f,t,e,o):n(l,d,f,e,t,o);if(void 0!==y){if(y)continue;h=!1;break}if(p){if(!H(t,(function(e,t){if(!p.has(t)&&(l===e||r(l,e,n,i,o)))return p.add(t)}))){h=!1;break}}else if(l!==d&&!r(l,d,n,i,o)){h=!1;break}}return o.delete(e),o.delete(t),h}function Be(e,t){var r=e.__data__;return function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?r["string"==typeof t?"string":"hash"]:r.map}function Re(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return Oe(r)?r:void 0}var Me=function(e){return Y.call(e)};function Le(e,t){return!!(t=null==t?i:t)&&("number"==typeof e||P.test(e))&&e>-1&&e%1==0&&e<t}function Ce(e,t){if(qe(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!Qe(e))||(S.test(e)||!v.test(e)||null!=t&&e in Object(t))}function He(e){return e==e&&!Ye(e)}function De(e,t){return function(r){return null!=r&&(r[e]===t&&(void 0!==t||e in Object(r)))}}(ne&&Me(new ne(new ArrayBuffer(1)))!=_||ie&&Me(new ie)!=h||oe&&Me(oe.resolve())!=d||se&&Me(new se)!=g||ae&&Me(new ae)!=b)&&(Me=function(e){var t=Y.call(e),r=t==l?e.constructor:void 0,n=r?Ve(r):void 0;if(n)switch(n){case ce:return _;case fe:return h;case he:return d;case pe:return g;case le:return b}return t});var Fe=Ke((function(e){e=function(e){return null==e?"":function(e){if("string"==typeof e)return e;if(Qe(e))return ge?ge.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(e)}(e);var t=[];return I.test(e)&&t.push(""),e.replace(T,(function(e,r,n,i){t.push(n?i.replace(k,"$1"):r||e)})),t}));function je(e){if("string"==typeof e||Qe(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function Ve(e){if(null!=e){try{return z.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Ke(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError("Expected a function");var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var s=e.apply(this,n);return r.cache=o.set(i,s),s};return r.cache=new(Ke.Cache||be),r}function Ge(e,t){return e===t||e!=e&&t!=t}function We(e){return function(e){return Je(e)&&Xe(e)}(e)&&$.call(e,"callee")&&(!ee.call(e,"callee")||Y.call(e)==o)}Ke.Cache=be;var qe=Array.isArray;function Xe(e){return null!=e&&$e(e.length)&&!ze(e)}function ze(e){var t=Ye(e)?Y.call(e):"";return t==f||"[object GeneratorFunction]"==t}function $e(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=i}function Ye(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Je(e){return!!e&&"object"==typeof e}function Qe(e){return"symbol"==typeof e||Je(e)&&Y.call(e)==m}var Ze=C?function(e){return function(t){return e(t)}}(C):function(e){return Je(e)&&$e(e.length)&&!!O[Y.call(e)]};var et=function(e,t){return function(r,n){return Ae(r,e,t(n),{})}}((function(e,t,r){$.call(e,t)?e[t].push(r):e[t]=[r]}),(function(e){return"function"==typeof e?e:null==e?rt:"object"==typeof e?qe(e)?function(e,t){if(Ce(e)&&He(t))return De(je(e),t);return function(r){var n=function(e,t,r){var n=null==e?void 0:Te(e,t);return void 0===n?r:n}(r,e);return void 0===n&&n===t?function(e,t){return null!=e&&function(e,t,r){t=Ce(t,e)?[t]:Ue(t);var n,i=-1,o=t.length;for(;++i<o;){var s=je(t[i]);if(!(n=null!=e&&r(e,s)))break;e=e[s]}if(n)return n;o=e?e.length:0;return!!o&&$e(o)&&Le(s,o)&&(qe(e)||We(e))}(e,t,ke)}(r,e):Pe(t,n,void 0,3)}}(e[0],e[1]):function(e){var t=function(e){var t=tt(e),r=t.length;for(;r--;){var n=t[r],i=e[n];t[r]=[n,i,He(i)]}return t}(e);if(1==t.length&&t[0][2])return De(t[0][0],t[0][1]);return function(r){return r===e||function(e,t,r,n){var i=r.length,o=i;if(null==e)return!o;for(e=Object(e);i--;){var s=r[i];if(s[2]?s[1]!==e[s[0]]:!(s[0]in e))return!1}for(;++i<o;){var a=(s=r[i])[0],u=e[a],c=s[1];if(s[2]){if(void 0===u&&!(a in e))return!1}else if(!Pe(c,u,n,3,new _e))return!1}return!0}(r,0,t)}}(e):function(e){return Ce(e)?(t=je(e),function(e){return null==e?void 0:e[t]}):function(e){return function(t){return Te(t,e)}}(e);var t}(e)}));function tt(e){return Xe(e)?ve(e):Ne(e)}function rt(e){return e}t.exports=et}(Dr,Dr.exports);const Fr=B,jr=R,Vr=Wt,Kr=Hr,Gr=Dr.exports;var Wr=class{constructor(e){if(!Vr.isEncoded(e))throw new Error("Base58 string is invalid. Cannot construct Decoder.");this.base58=e}constructRootJSON(e){const r=Kr(Fr.root);return e.reduce(((e,n)=>{const i=r[n[0]];let o=n[1];return o instanceof Array&&("anchors"===i&&(o=this.constructAnchorsJSON(o)),"path"===i&&(o=this.constructPathJSON(o))),o instanceof t&&(o=jr.decode(o).toString("hex")),e[i]=o,e}),{})}constructAnchorsJSON(e){const t=Gr(Fr.chain,(e=>e.id));return e.map((e=>e.reduce(((e,r)=>{if(0===r[0])return`${e}:${t[r[1]]}`;if(1===r[0]){const t=e.split(":").pop();return`${e}:${Kr(Fr.chain[t].networks)[r[1]]}`}return`${e}:${jr.decode(r[1]).toString("hex")}`}),"blink")))}constructPathJSON(e){const t=Kr(Fr.path);return e.map((e=>({[t[e[0]]]:jr.decode(e[1]).toString("hex")})))}decode(){const e=Vr.decode(this.base58),t=jr.decode(e);return this.constructRootJSON(t)}};var qr={Encoder:dr,Decoder:Wr,Keymap:B};function Xr(e){return Object.keys(p).map((e=>p[e])).find((t=>t.signatureValue===e))}function zr(e=null){if(null==e?void 0:e.anchors){const{anchors:t}=e,r=t[0];if("string"==typeof r)return function(e){const t=e.split(":");let r;switch(t[1]){case p.mocknet.blinkCode:return Xr(p.mocknet.signatureValue);case p.bitcoin.blinkCode:r=p.bitcoin.name;break;case p.ethmain.blinkCode:r=p.ethmain.name;break;default:throw new Error("Could not retrieve chain.")}const n=t[2],i=r.toLowerCase()+function(e){const t=e.substr(0,1),r=e.substr(1,e.length-1);return t.toUpperCase()+r.toLowerCase()}(n);return Xr(i)}(r)}return null}function $r(e,t){const r=e.findIndex((e=>e===t));r>-1&&e.splice(r,1)}var Yr={"@context":{id:"@id",type:"@type",bc:"https://w3id.org/blockcerts#",obi:"https://w3id.org/openbadges#",cp:"https://w3id.org/chainpoint#",schema:"http://schema.org/",sec:"https://w3id.org/security#",xsd:"http://www.w3.org/2001/XMLSchema#",MerkleProof2017:"sec:MerkleProof2017",RecipientProfile:"bc:RecipientProfile",SignatureLine:"bc:SignatureLine",MerkleProofVerification2017:"bc:MerkleProofVerification2017",recipientProfile:"bc:recipientProfile",signatureLines:"bc:signatureLines",introductionUrl:{"@id":"bc:introductionUrl","@type":"@id"},subtitle:"bc:subtitle",jobTitle:"schema:jobTitle",creator:{"@id":"dc:creator","@type":"@id"},expires:{"@id":"sec:expiration","@type":"xsd:dateTime"},revoked:{"@id":"sec:expiration","@type":"xsd:dateTime"},CryptographicKey:"sec:Key",signature:"sec:signature",verification:"bc:verification",publicKeys:"bc:publicKeys",ChainpointSHA256v2:"cp:ChainpointSHA256v2",BTCOpReturn:"cp:BTCOpReturn",targetHash:"cp:targetHash",merkleRoot:"cp:merkleRoot",proof:"cp:proof",anchors:"cp:anchors",sourceId:"cp:sourceId",right:"cp:right",left:"cp:left"},"obi:validation":[{"obi:validatesType":"RecipientProfile","obi:validationSchema":"https://w3id.org/blockcerts/schema/2.0-alpha/recipientSchema.json"},{"obi:validatesType":"SignatureLine","obi:validationSchema":"https://w3id.org/blockcerts/schema/2.0-alpha/signatureLineSchema.json"},{"obi:validatesType":"MerkleProof2017","obi:validationSchema":"https://w3id.org/blockcerts/schema/2.0-alpha/merkleProof2017Schema.json"}]},Jr={"@context":{id:"@id",type:"@type",bc:"https://w3id.org/blockcerts#",cp:"https://w3id.org/chainpoint#",schema:"http://schema.org/",sec:"https://w3id.org/security#",xsd:"http://www.w3.org/2001/XMLSchema#",MerkleProof2019:"sec:MerkleProof2019",BlockcertsCredential:"bc:BlockcertsCredential",introductionUrl:{"@id":"bc:introductionUrl","@type":"@id"},CryptographicKey:"sec:Key",domain:"sec:domain",nonce:"sec:nonce",proofValue:"sec:proofValue",assertionMethod:{"@id":"sec:assertionMethod","@type":"@id","@container":"@set"},proofPurpose:{"@id":"sec:proofPurpose","@type":"@vocab"},verificationMethod:{"@id":"sec:verificationMethod","@type":"@id"},created:{"@id":"bc:created","@type":"xsd:dateTime"},name:{"@id":"schema:name"}}},Qr={"@context":{id:"@id",type:"@type",bc:"https://w3id.org/blockcerts#",cp:"https://w3id.org/chainpoint#",vc:"https://www.w3.org/2018/credentials/v1",schema:"https://schema.org/",sec:"https://w3id.org/security#",xsd:"http://www.w3.org/2001/XMLSchema#",MerkleProof2019:"sec:MerkleProof2019",BlockcertsCredential:"bc:BlockcertsCredential",introductionUrl:{"@id":"bc:introductionUrl","@type":"@id"},metadata:"bc:metadata",display:{"@id":"bc:display","@context":{id:"@id",type:"@type",contentMediaType:{"@id":"bc:contentMediaType","@type":"@id"},contentEncoding:{"@id":"bc:contentEncoding","@type":"@id"},content:{"@id":"bc:content","@type":"@id"}}},CryptographicKey:"sec:Key",domain:"sec:domain",nonce:"sec:nonce",proofValue:"sec:proofValue",assertionMethod:{"@id":"sec:assertionMethod","@type":"@id","@container":"@set"},authentication:{"@id":"sec:authenticationMethod","@type":"@id","@container":"@set"},proofPurpose:{"@id":"sec:proofPurpose","@type":"@vocab"},verificationMethod:{"@id":"sec:verificationMethod","@type":"@id"},created:{"@id":"https://purl.org/dc/terms/created","@type":"xsd:dateTime"},challenge:"sec:challenge",expires:{"@id":"sec:expiration","@type":"xsd:dateTime"},name:{"@id":"schema:name"},description:{"@id":"schema:description"},email:{"@id":"schema:email"},publicKey:{"@id":"sec:publicKey","@type":"@id"},url:{"@id":"schema:url","@type":"@id"},image:{"@id":"schema:image","@type":"@id"}}},Zr={"@context":{id:"@id",type:"@type","@protected":!0,proof:{"@id":"https://w3id.org/security#proof","@type":"@id","@container":"@graph"},Ed25519VerificationKey2020:{"@id":"https://w3id.org/security#Ed25519VerificationKey2020","@context":{"@protected":!0,id:"@id",type:"@type",controller:{"@id":"https://w3id.org/security#controller","@type":"@id"},revoked:{"@id":"https://w3id.org/security#revoked","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},publicKeyMultibase:{"@id":"https://w3id.org/security#publicKeyMultibase","@type":"https://w3id.org/security#multibase"}}},Ed25519Signature2020:{"@id":"https://w3id.org/security#Ed25519Signature2020","@context":{"@protected":!0,id:"@id",type:"@type",challenge:"https://w3id.org/security#challenge",created:{"@id":"http://purl.org/dc/terms/created","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},domain:"https://w3id.org/security#domain",expires:{"@id":"https://w3id.org/security#expiration","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},nonce:"https://w3id.org/security#nonce",proofPurpose:{"@id":"https://w3id.org/security#proofPurpose","@type":"@vocab","@context":{"@protected":!0,id:"@id",type:"@type",assertionMethod:{"@id":"https://w3id.org/security#assertionMethod","@type":"@id","@container":"@set"},authentication:{"@id":"https://w3id.org/security#authenticationMethod","@type":"@id","@container":"@set"},capabilityInvocation:{"@id":"https://w3id.org/security#capabilityInvocationMethod","@type":"@id","@container":"@set"},capabilityDelegation:{"@id":"https://w3id.org/security#capabilityDelegationMethod","@type":"@id","@container":"@set"},keyAgreement:{"@id":"https://w3id.org/security#keyAgreementMethod","@type":"@id","@container":"@set"}}},proofValue:{"@id":"https://w3id.org/security#proofValue","@type":"https://w3id.org/security#multibase"},verificationMethod:{"@id":"https://w3id.org/security#verificationMethod","@type":"@id"}}}}};function en(e){e=e.trim();const t=[];for(let r=0;r<e.length;r+=2)t.push(parseInt(e.substring(r,r+2),16));return t}n["https://w3id.org/blockcerts/schema/2.0-alpha/context.json"]=Yr,n["https://www.blockcerts.org/schema/2.0-alpha/context.json"]=Yr,n["https://www.blockcerts.org/schema/3.0-alpha/context.json"]=Jr,n["https://w3id.org/blockcerts/schema/3.0-alpha/context.json"]=Jr,n["https://w3id.org/blockcerts/v3.0-alpha"]=Jr,n["https://www.blockcerts.org/schema/3.0-beta/context.json"]=Qr,n["https://w3id.org/blockcerts/schema/3.0-beta/context.json"]=Qr,n["https://w3id.org/blockcerts/v3.0-beta"]=Qr,n["https://w3id.org/security/suites/ed25519-2020/v1"]=Zr;class tn extends Error{constructor(e,t){super(t),this.stepCode=e}}var rn="en-US",nn={"en-US":{errors:{ensureHashesEqual:"Computed hash does not match remote hash",ensureMerkleRootEqual:"Merkle root does not match remote hash.",ensureValidReceipt:"The receipt is malformed. There was a problem navigating the merkle tree in the receipt.",failedJsonLdNormalization:"Failed JSON-LD normalization",foundUnmappedFields:"Found unmapped fields during JSON-LD normalization",identityErrorBaseMessage:"Issuer identity mismatch",deriveIssuingAddressFromPublicKey:"Unsupported blockchain for DID verification",compareIssuingAddress:"The provided verification method does not match the issuer identity",getTransactionId:"Cannot verify this certificate without a transaction ID to compare against.",invalidMerkleReceipt:"Invalid Merkle Receipt. Proof hash did not match Merkle root",isTransactionIdValid:"Cannot verify this certificate without a transaction ID to compare against.",noProofSpecified:"Document proof is an array but no target proof was specified to know what to verify."}},fr:{errors:{ensureHashesEqual:"Calcul du hash local différent du hash distant",ensureMerkleRootEqual:"Le Merkle root ne correspond pas au hash distant",ensureValidReceipt:"Erreur d'écriture du reçu. Un problème est survenu lors de la navigation de l'arbre Merkle du reçu.",failedJsonLdNormalization:"Erreur de normalisation JSON-LD",foundUnmappedFields:"Champs non liés découverts durant la normalisation JSON-LD",identityErrorBaseMessage:"Identité de l'émetteur invalide",deriveIssuingAddressFromPublicKey:"Cette blockchain n'est pas supportée pour la vérification de l'identité décentralisée.",compareIssuingAddress:"La méthode de vérification n'a pas permis d'établir l'identité de l'émetteur.",getTransactionId:"Impossible de vérifier ce certificat sans un identifiant de transaction valide",invalidMerkleReceipt:"Reçu Merkle invalide. Hash de preuve différent du Merkle root",isTransactionIdValid:"Impossible de vérifier ce certificat sans un identifiant de transaction valide",noProofSpecified:"La propriété 'proof' du document est un tableau mais aucune preuve n'a été passée pour savoir ce qu'il faut vérifier"}},es:{errors:{ensureHashesEqual:"La cadena binaria calculada no corresponde con la cadena binaria remota",ensureMerkleRootEqual:"La raíz Merkle no corresponde con la cadena binaria remota",ensureValidReceipt:"El recibo está malformado. Hubo un problema navegando el árbol Merkle en el recibo",failedJsonLdNormalization:"La normalización del JSON-LD ha fallado",foundUnmappedFields:"Se han encontrado campos no mapeados durante la normalización de JSON-LD",identityErrorBaseMessage:"Identitad del emisor inválida",deriveIssuingAddressFromPublicKey:"No se puede validar la identitad decentalisada con esta cadena binaria.",compareIssuingAddress:"El metodo de verificación no corresponde a la identitad del emisor.",getTransactionId:"No se puede verificar este certificado sin una identificación de transacción que sirva como comparación",invalidMerkleReceipt:"Recibo Merkle inválido. La cadena binaria de prueba no corresponde con la raíz Merkle",isTransactionIdValid:"No se puede verificar este certificado sin una identificación de transacción que sirva como comparación",noProofSpecified:"La propiedad 'proof' del documento es una lista, pero no prueba especifica ha sido declarada para conocer el punto de verificación"}},mt:{errors:{ensureHashesEqual:"Il-hash ikkalkulat ma jikkorrispondix mar-remote hash",ensureMerkleRootEqual:"Merkle root ma taqbilx mar-remote hash",ensureValidReceipt:"L-irċevuta hija malformata. Kien hemm problema fin-navigazzjoni tal-merkle tree fl-irċevuta",failedJsonLdNormalization:"In-normalizzazzjoni ta' JSON-LD ma rnexxietx",foundUnmappedFields:"Instabu unmapped fields matul in-normalizzazzjoni JSON-LD",identityErrorBaseMessage:"Issuer identity mismatch",deriveIssuingAddressFromPublicKey:"Unsupported blockchain for DID verification",compareIssuingAddress:"The provided verification method does not match the issuer identity",getTransactionId:"Dan iċ-ċertifikat ma jistax jiġi vverifikat mingħajr ID ta' tranżazzjoni mqabbla miegħu",invalidMerkleReceipt:"Irċevuta Merkle invalida. Il-proof hash ma kienx jaqbel mal-Merkle root",isTransactionIdValid:"Dan iċ-ċertifikat ma jistax jiġi vverifikat mingħajr ID ta' tranżazzjoni mqabbla miegħu",noProofSpecified:"Document proof is an array but no target proof was specified to know what to verify."}},"it-IT":{errors:{ensureHashesEqual:"L'hash calcolato non corrisponde all'hash remoto",ensureMerkleRootEqual:"La radice di Merkle non corrisponde all'hash remoto.",ensureValidReceipt:"La ricevuta è malformata. C'è stato un problema nella navigazione dell'albero di Merkle nella ricevuta.",failedJsonLdNormalization:"Normalizzazione JSON-LD fallita",foundUnmappedFields:"Campi non mappati trovati durante la normalizzazione JSON-LD",identityErrorBaseMessage:"Issuer identity mismatch",deriveIssuingAddressFromPublicKey:"Unsupported blockchain for DID verification",compareIssuingAddress:"The provided verification method does not match the issuer identity",getTransactionId:"Impossibile verificare questo certificato senza un ID transazione da confrontare.",invalidMerkleReceipt:"Ricevuta Merkle non valida. L'hash di prova non corrisponde alla radice di Merkle",isTransactionIdValid:"Impossibile verificare questo certificato senza un ID transazione da confrontare.",noProofSpecified:"Document proof is an array but no target proof was specified to know what to verify."}},ja:{errors:{ensureHashesEqual:"算出されたハッシュがリモートハッシュと一致しませんでした",ensureMerkleRootEqual:"Merkle rootがリモートハッシュと一致しませんでした",ensureValidReceipt:"レシートが異常です。レシート内のMerkle treeを辿る際に問題が発生しました。",failedJsonLdNormalization:"JSON-LDの正規化に失敗しました",foundUnmappedFields:"JSON-LDの正規化時にマップされていないフィールドを検出しました",identityErrorBaseMessage:"Issuer identity mismatch",deriveIssuingAddressFromPublicKey:"Unsupported blockchain for DID verification",compareIssuingAddress:"The provided verification method does not match the issuer identity",getTransactionId:"照合のための取引IDがないため、この証明書を認証できません。",invalidMerkleReceipt:"Merkleレシートが無効です。証明ハッシュがMerkle rootと一致しませんでした。",isTransactionIdValid:"照合するための取引IDがないため、この証明書を認証できません。",noProofSpecified:"Document proof is an array but no target proof was specified to know what to verify."}}};function on(e,t){return e&&t?nn[rn]?nn[rn][e]?nn[rn][e][t]?nn[rn][e][t]||"":"[missing locale item data]":"[missing locale group data]":"[missing locale data]":""}var sn=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(s,a)}u((n=n.apply(e,t||[])).next())}))};function an(e){return sn(this,arguments,void 0,(function*(e,t=null,r=e=>sn(this,void 0,void 0,(function*(){return Promise}))){e["@context"].find((e=>{return(t=e)===Object(t)&&"@vocab"in e;var t}))||e["@context"].push({"@vocab":"http://fallback.org/"});const i=JSON.parse(JSON.stringify(e));if(Array.isArray(i.proof)){if(!t)throw new tn("computeLocalHash",on("errors","noProofSpecified"));const e=i.proof.findIndex((e=>e.proofValue===t.proofValue));i.proof=i.proof.slice(0,e)}else delete i.proof;const o={algorithm:"URDNA2015",format:"application/nquads",documentLoader:function(e){return sn(this,void 0,void 0,(function*(){return null!=r&&(yield r(e)),e in n?{contextUrl:null,document:n[e],documentUrl:e}:S.documentLoader(e)}))},safe:!1};let s;try{s=yield S.normalize(i,o)}catch(e){throw console.error(e),new tn("computeLocalHash",on("errors","failedJsonLdNormalization"))}const a=function(e){const t=e.split("\n"),r=/<http:\/\/fallback\.org\/(.*)>/,n=t.map((e=>r.exec(e))).filter((e=>null!=e));if(n.length>0){const e=n.map((e=>e[1])).sort();return Array.from(new Set(e))}return null}(s);if(a)throw new tn("computeLocalHash",`${on("errors","foundUnmappedFields")}: ${a.join(", ")}`);return I(function(e){const t=[];for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);n<128?t.push(n):n<2048?t.push(192|n>>6,128|63&n):n<55296||n>=57344?t.push(224|n>>12,128|n>>6&63,128|63&n):(r++,n=65536+((1023&n)<<10|1023&e.charCodeAt(r)),t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n))}return t}(s))}))}var un=d.Buffer;var cn=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 i=e.charAt(n),o=i.charCodeAt(0);if(255!==t[o])throw new TypeError(i+" is ambiguous");t[o]=n}var s=e.length,a=e.charAt(0),u=Math.log(s)/Math.log(256),c=Math.log(256)/Math.log(s);function f(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return un.alloc(0);for(var r=0,n=0,i=0;e[r]===a;)n++,r++;for(var o=(e.length-r)*u+1>>>0,c=new Uint8Array(o);e[r];){var f=t[e.charCodeAt(r)];if(255===f)return;for(var h=0,p=o-1;(0!==f||h<i)&&-1!==p;p--,h++)f+=s*c[p]>>>0,c[p]=f%256>>>0,f=f/256>>>0;if(0!==f)throw new Error("Non-zero carry");i=h,r++}for(var l=o-i;l!==o&&0===c[l];)l++;var d=un.allocUnsafe(n+(o-l));d.fill(0,0,n);for(var y=n;l!==o;)d[y++]=c[l++];return d}return{encode:function(t){if((Array.isArray(t)||t instanceof Uint8Array)&&(t=un.from(t)),!un.isBuffer(t))throw new TypeError("Expected Buffer");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var u=(o-i)*c+1>>>0,f=new Uint8Array(u);i!==o;){for(var h=t[i],p=0,l=u-1;(0!==h||p<n)&&-1!==l;l--,p++)h+=256*f[l]>>>0,f[l]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");n=p,i++}for(var d=u-n;d!==u&&0===f[d];)d++;for(var y=a.repeat(r);d<u;++d)y+=e.charAt(f[d]);return y},decodeUnsafe:f,decode:function(e){var t=f(e);if(t)return t;throw new Error("Non-base"+s+" character")}}};cn("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");var fn=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(s,a)}u((n=n.apply(e,t||[])).next())}))};const hn=t,pn=e=>{const t=(e=>{const t=w.from(Object.assign(Object.assign({},e),{crv:"K-256"}),"jwk").toString("blk","public"),r=m.publicKeyConvert(hn.from(t,"hex"),!0);return hn.from(r).toString("hex")})(e);let r=hn.from(t,"hex"),n=32-r.length;for(;n>0;)r=hn.concat([hn.from("00","hex"),r]),n--;return r};var ln={},dn={},yn={};Object.defineProperty(yn,"__esModule",{value:!0}),yn.testnet=yn.regtest=yn.bitcoin=void 0,yn.bitcoin={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},yn.regtest={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bcrt",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},yn.testnet={messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};var gn={},wn={},mn={},bn={};Object.defineProperty(bn,"__esModule",{value:!0}),bn.encode=bn.decode=bn.check=void 0,bn.check=function(e){if(e.length<8)return!1;if(e.length>72)return!1;if(48!==e[0])return!1;if(e[1]!==e.length-2)return!1;if(2!==e[2])return!1;const t=e[3];if(0===t)return!1;if(5+t>=e.length)return!1;if(2!==e[4+t])return!1;const r=e[5+t];return 0!==r&&(6+t+r===e.length&&(!(128&e[4])&&(!(t>1&&0===e[4]&&!(128&e[5]))&&(!(128&e[t+6])&&!(r>1&&0===e[t+6]&&!(128&e[t+7]))))))},bn.decode=function(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(48!==e[0])throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(2!==e[2])throw new Error("Expected DER integer");const t=e[3];if(0===t)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(2!==e[4+t])throw new Error("Expected DER integer (2)");const r=e[5+t];if(0===r)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(128&e[4])throw new Error("R value is negative");if(t>1&&0===e[4]&&!(128&e[5]))throw new Error("R value excessively padded");if(128&e[t+6])throw new Error("S value is negative");if(r>1&&0===e[t+6]&&!(128&e[t+7]))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}},bn.encode=function(e,r){const n=e.length,i=r.length;if(0===n)throw new Error("R length is zero");if(0===i)throw new Error("S length is zero");if(n>33)throw new Error("R length is too long");if(i>33)throw new Error("S length is too long");if(128&e[0])throw new Error("R value is negative");if(128&r[0])throw new Error("S value is negative");if(n>1&&0===e[0]&&!(128&e[1]))throw new Error("R value excessively padded");if(i>1&&0===r[0]&&!(128&r[1]))throw new Error("S value excessively padded");const o=t.allocUnsafe(6+n+i);return o[0]=48,o[1]=o.length-2,o[2]=2,o[3]=e.length,e.copy(o,4),o[4+n]=2,o[5+n]=r.length,r.copy(o,6+n),o};var En={};Object.defineProperty(En,"__esModule",{value:!0}),En.REVERSE_OPS=En.OPS=void 0;const _n={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_CHECKSIGADD:186,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};En.OPS=_n;const vn={};En.REVERSE_OPS=vn;for(const e of Object.keys(_n)){vn[_n[e]]=e}var Sn={};Object.defineProperty(Sn,"__esModule",{value:!0}),Sn.decode=Sn.encode=Sn.encodingLength=void 0;const In=En;function Tn(e){return e<In.OPS.OP_PUSHDATA1?1:e<=255?2:e<=65535?3:5}Sn.encodingLength=Tn,Sn.encode=function(e,t,r){const n=Tn(t);return 1===n?e.writeUInt8(t,r):2===n?(e.writeUInt8(In.OPS.OP_PUSHDATA1,r),e.writeUInt8(t,r+1)):3===n?(e.writeUInt8(In.OPS.OP_PUSHDATA2,r),e.writeUInt16LE(t,r+1)):(e.writeUInt8(In.OPS.OP_PUSHDATA4,r),e.writeUInt32LE(t,r+1)),n},Sn.decode=function(e,t){const r=e.readUInt8(t);let n,i;if(r<In.OPS.OP_PUSHDATA1)n=r,i=1;else if(r===In.OPS.OP_PUSHDATA1){if(t+2>e.length)return null;n=e.readUInt8(t+1),i=2}else if(r===In.OPS.OP_PUSHDATA2){if(t+3>e.length)return null;n=e.readUInt16LE(t+1),i=3}else{if(t+5>e.length)return null;if(r!==In.OPS.OP_PUSHDATA4)throw new Error("Unexpected opcode");n=e.readUInt32LE(t+1),i=5}return{opcode:r,number:n,size:i}};var kn={};Object.defineProperty(kn,"__esModule",{value:!0}),kn.encode=kn.decode=void 0,kn.decode=function(e,t,r){t=t||4,r=void 0===r||r;const n=e.length;if(0===n)return 0;if(n>t)throw new TypeError("Script number overflow");if(r&&!(127&e[n-1]||!(n<=1)&&128&e[n-2]))throw new Error("Non-minimally encoded script number");if(5===n){const t=e.readUInt32LE(0),r=e.readUInt8(4);return 128&r?-(4294967296*(-129&r)+t):4294967296*r+t}let i=0;for(let t=0;t<n;++t)i|=e[t]<<8*t;return 128&e[n-1]?-(i&~(128<<8*(n-1))):i},kn.encode=function(e){let r=Math.abs(e);const n=(i=r)>2147483647?5:i>8388607?4:i>32767?3:i>127?2:i>0?1:0;var i;const o=t.allocUnsafe(n),s=e<0;for(let e=0;e<n;++e)o.writeUInt8(255&r,e),r>>=8;return 128&o[n-1]?o.writeUInt8(s?128:0,n-1):s&&(o[n-1]|=128),o};var An={},Pn={},On={Array:function(e){return null!=e&&e.constructor===Array},Boolean:function(e){return"boolean"==typeof e},Function:function(e){return"function"==typeof e},Nil:function(e){return null==e},Number:function(e){return"number"==typeof e},Object:function(e){return"object"==typeof e},String:function(e){return"string"==typeof e},"":function(){return!0}};for(var Nn in On.Null=On.Nil,On)On[Nn].toJSON=function(e){return e}.bind(null,Nn);var Un=On,xn=Un;function Bn(e){return e.name||e.toString().match(/function (.*?)\s*\(/)[1]}function Rn(e){return xn.Nil(e)?"":Bn(e.constructor)}function Mn(e,t){Error.captureStackTrace&&Error.captureStackTrace(e,t)}function Ln(e){return xn.Function(e)?e.toJSON?e.toJSON():Bn(e):xn.Array(e)?"Array":e&&xn.Object(e)?"Object":void 0!==e?e:""}function Cn(e,t,r){var n=function(e){return xn.Function(e)?"":xn.String(e)?JSON.stringify(e):e&&xn.Object(e)?"":e}(t);return"Expected "+Ln(e)+", got"+(""!==r?" "+r:"")+(""!==n?" "+n:"")}function Hn(e,t,r){r=r||Rn(t),this.message=Cn(e,t,r),Mn(this,Hn),this.__type=e,this.__value=t,this.__valueTypeName=r}function Dn(e,t,r,n,i){e?(i=i||Rn(n),this.message=function(e,t,r,n,i){var o='" of type ';return"key"===t&&(o='" with key type '),Cn('property "'+Ln(r)+o+Ln(e),n,i)}(e,r,t,n,i)):this.message='Unexpected property "'+t+'"',Mn(this,Hn),this.__label=r,this.__property=t,this.__type=e,this.__value=n,this.__valueTypeName=i}Hn.prototype=Object.create(Error.prototype),Hn.prototype.constructor=Hn,Dn.prototype=Object.create(Error.prototype),Dn.prototype.constructor=Hn;var Fn,jn,Vn={TfTypeError:Hn,TfPropertyTypeError:Dn,tfCustomError:function(e,t){return new Hn(e,{},t)},tfSubError:function(e,t,r){return e instanceof Dn?(t=t+"."+e.__property,e=new Dn(e.__type,t,e.__label,e.__value,e.__valueTypeName)):e instanceof Hn&&(e=new Dn(e.__type,t,r,e.__value,e.__valueTypeName)),Mn(e),e},tfJSON:Ln,getValueTypeName:Rn};var Kn=Un,Gn=Vn.tfJSON,Wn=Vn.TfTypeError,qn=Vn.TfPropertyTypeError,Xn=Vn.tfSubError,zn=Vn.getValueTypeName,$n={arrayOf:function(e,t){function r(r,n){return!!Kn.Array(r)&&(!Kn.Nil(r)&&(!(void 0!==t.minLength&&r.length<t.minLength)&&(!(void 0!==t.maxLength&&r.length>t.maxLength)&&((void 0===t.length||r.length===t.length)&&r.every((function(t,r){try{return Jn(e,t,n)}catch(e){throw Xn(e,r)}}))))))}return e=Yn(e),t=t||{},r.toJSON=function(){var r="["+Gn(e)+"]";return void 0!==t.length?r+="{"+t.length+"}":void 0===t.minLength&&void 0===t.maxLength||(r+="{"+(void 0===t.minLength?0:t.minLength)+","+(void 0===t.maxLength?1/0:t.maxLength)+"}"),r},r},maybe:function e(t){function r(r,n){return Kn.Nil(r)||t(r,n,e)}return t=Yn(t),r.toJSON=function(){return"?"+Gn(t)},r},map:function(e,t){function r(r,n){if(!Kn.Object(r))return!1;if(Kn.Nil(r))return!1;for(var i in r){try{t&&Jn(t,i,n)}catch(e){throw Xn(e,i,"key")}try{var o=r[i];Jn(e,o,n)}catch(e){throw Xn(e,i)}}return!0}return e=Yn(e),t&&(t=Yn(t)),r.toJSON=t?function(){return"{"+Gn(t)+": "+Gn(e)+"}"}:function(){return"{"+Gn(e)+"}"},r},object:function(e){var t={};for(var r in e)t[r]=Yn(e[r]);function n(e,r){if(!Kn.Object(e))return!1;if(Kn.Nil(e))return!1;var n;try{for(n in t){Jn(t[n],e[n],r)}}catch(e){throw Xn(e,n)}if(r)for(n in e)if(!t[n])throw new qn(void 0,n);return!0}return n.toJSON=function(){return Gn(t)},n},anyOf:function(){var e=[].slice.call(arguments).map(Yn);function t(t,r){return e.some((function(e){try{return Jn(e,t,r)}catch(e){return!1}}))}return t.toJSON=function(){return e.map(Gn).join("|")},t},allOf:function(){var e=[].slice.call(arguments).map(Yn);function t(t,r){return e.every((function(e){try{return Jn(e,t,r)}catch(e){return!1}}))}return t.toJSON=function(){return e.map(Gn).join(" & ")},t},quacksLike:function(e){function t(t){return e===zn(t)}return t.toJSON=function(){return e},t},tuple:function(){var e=[].slice.call(arguments).map(Yn);function t(t,r){return!Kn.Nil(t)&&(!Kn.Nil(t.length)&&((!r||t.length===e.length)&&e.every((function(e,n){try{return Jn(e,t[n],r)}catch(e){throw Xn(e,n)}}))))}return t.toJSON=function(){return"("+e.map(Gn).join(", ")+")"},t},value:function(e){function t(t){return t===e}return t.toJSON=function(){return e},t}};function Yn(e){if(Kn.String(e))return"?"===e[0]?$n.maybe(e.slice(1)):Kn[e]||$n.quacksLike(e);if(e&&Kn.Object(e)){if(Kn.Array(e)){if(1!==e.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return $n.arrayOf(e[0])}return $n.object(e)}return Kn.Function(e)?e:$n.value(e)}function Jn(e,t,r,n){if(Kn.Function(e)){if(e(t,r))return!0;throw new Wn(n||e,t)}return Jn(Yn(e),t,r)}for(var Qn in $n.oneOf=$n.anyOf,Kn)Jn[Qn]=Kn[Qn];for(Qn in $n)Jn[Qn]=$n[Qn];var Zn=function(){if(jn)return Fn;jn=1;var e=Un,t=Vn;function n(e){return r(e)}function i(e){return"string"==typeof e&&/^([0-9a-f]{2})+$/i.test(e)}function o(e,r){var n=e.toJSON();function i(i){if(!e(i))return!1;if(i.length===r)return!0;throw t.tfCustomError(n+"(Length: "+r+")",n+"(Length: "+i.length+")")}return i.toJSON=function(){return n},i}var s=o.bind(null,e.Array),a=o.bind(null,n),u=o.bind(null,i),c=o.bind(null,e.String),f=Math.pow(2,53)-1,h={ArrayN:s,Buffer:n,BufferN:a,Finite:function(e){return"number"==typeof e&&isFinite(e)},Hex:i,HexN:u,Int8:function(e){return e<<24>>24===e},Int16:function(e){return e<<16>>16===e},Int32:function(e){return(0|e)===e},Int53:function(e){return"number"==typeof e&&e>=-f&&e<=f&&Math.floor(e)===e},Range:function(t,r,n){function i(e,i){return n(e,i)&&e>t&&e<r}return n=n||e.Number,i.toJSON=function(){return`${n.toJSON()} between [${t}, ${r}]`},i},StringN:c,UInt8:function(e){return(255&e)===e},UInt16:function(e){return(65535&e)===e},UInt32:function(e){return e>>>0===e},UInt53:function(e){return"number"==typeof e&&e>=0&&e<=f&&Math.floor(e)===e}};for(var p in h)h[p].toJSON=function(e){return e}.bind(null,p);return Fn=h}();for(Qn in Zn)Jn[Qn]=Zn[Qn];Jn.compile=Yn,Jn.TfTypeError=Wn,Jn.TfPropertyTypeError=qn;var ei=Jn;!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.oneOf=e.Null=e.BufferN=e.Function=e.UInt32=e.UInt8=e.tuple=e.maybe=e.Hex=e.Buffer=e.String=e.Boolean=e.Array=e.Number=e.Hash256bit=e.Hash160bit=e.Buffer256bit=e.isTaptree=e.isTapleaf=e.TAPLEAF_VERSION_MASK=e.Network=e.ECPoint=e.Satoshi=e.Signer=e.BIP32Path=e.UInt31=e.isPoint=e.typeforce=void 0;const t=E;e.typeforce=ei;const r=t.Buffer.alloc(32,0),n=t.Buffer.from("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f","hex");e.isPoint=function(e){if(!t.Buffer.isBuffer(e))return!1;if(e.length<33)return!1;const i=e[0],o=e.slice(1,33);if(0===o.compare(r))return!1;if(o.compare(n)>=0)return!1;if((2===i||3===i)&&33===e.length)return!0;const s=e.slice(33);return 0!==s.compare(r)&&(!(s.compare(n)>=0)&&(4===i&&65===e.length))};const i=Math.pow(2,31)-1;function o(t){return e.typeforce.String(t)&&!!t.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}e.UInt31=function(t){return e.typeforce.UInt32(t)&&t<=i},e.BIP32Path=o,o.toJSON=()=>"BIP32 derivation path",e.Signer=function(t){return(e.typeforce.Buffer(t.publicKey)||"function"==typeof t.getPublicKey)&&"function"==typeof t.sign};function s(r){return!(!r||!("output"in r))&&(!!t.Buffer.isBuffer(r.output)&&(void 0===r.version||(r.version&e.TAPLEAF_VERSION_MASK)===r.version))}e.Satoshi=function(t){return e.typeforce.UInt53(t)&&t<=21e14},e.ECPoint=e.typeforce.quacksLike("Point"),e.Network=e.typeforce.compile({messagePrefix:e.typeforce.oneOf(e.typeforce.Buffer,e.typeforce.String),bip32:{public:e.typeforce.UInt32,private:e.typeforce.UInt32},pubKeyHash:e.typeforce.UInt8,scriptHash:e.typeforce.UInt8,wif:e.typeforce.UInt8}),e.TAPLEAF_VERSION_MASK=254,e.isTapleaf=s,e.isTaptree=function t(r){return(0,e.Array)(r)?2===r.length&&r.every((e=>t(e))):s(r)},e.Buffer256bit=e.typeforce.BufferN(32),e.Hash160bit=e.typeforce.BufferN(20),e.Hash256bit=e.typeforce.BufferN(32),e.Number=e.typeforce.Number,e.Array=e.typeforce.Array,e.Boolean=e.typeforce.Boolean,e.String=e.typeforce.String,e.Buffer=e.typeforce.Buffer,e.Hex=e.typeforce.Hex,e.maybe=e.typeforce.maybe,e.tuple=e.typeforce.tuple,e.UInt8=e.typeforce.UInt8,e.UInt32=e.typeforce.UInt32,e.Function=e.typeforce.Function,e.BufferN=e.typeforce.BufferN,e.Null=e.typeforce.Null,e.oneOf=e.typeforce.oneOf}(Pn),Object.defineProperty(An,"__esModule",{value:!0}),An.encode=An.decode=void 0;const ti=bn,ri=Pn,{typeforce:ni}=ri,ii=t.alloc(1,0);function oi(e){let r=0;for(;0===e[r];)++r;return r===e.length?ii:128&(e=e.slice(r))[0]?t.concat([ii,e],1+e.length):e}function si(e){0===e[0]&&(e=e.slice(1));const r=t.alloc(32,0),n=Math.max(0,32-e.length);return e.copy(r,n),r}An.decode=function(e){const r=e.readUInt8(e.length-1),n=-129&r;if(n<=0||n>=4)throw new Error("Invalid hashType "+r);const i=ti.decode(e.slice(0,-1)),o=si(i.r),s=si(i.s);return{signature:t.concat([o,s],64),hashType:r}},An.encode=function(e,r){ni({signature:ri.BufferN(64),hashType:ri.UInt8},{signature:e,hashType:r});const n=-129&r;if(n<=0||n>=4)throw new Error("Invalid hashType "+r);const i=t.allocUnsafe(1);i.writeUInt8(r,0);const o=oi(e.slice(0,32)),s=oi(e.slice(32,64));return t.concat([ti.encode(o,s),i])},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.signature=e.number=e.isCanonicalScriptSignature=e.isDefinedHashType=e.isCanonicalPubKey=e.toStack=e.fromASM=e.toASM=e.decompile=e.compile=e.countNonPushOnlyOPs=e.isPushOnly=e.OPS=void 0;const n=bn,i=En;Object.defineProperty(e,"OPS",{enumerable:!0,get:function(){return i.OPS}});const o=Sn,s=kn,a=An,u=Pn,{typeforce:c}=u,f=i.OPS.OP_RESERVED;function h(e){return u.Buffer(e)||function(e){return u.Number(e)&&(e===i.OPS.OP_0||e>=i.OPS.OP_1&&e<=i.OPS.OP_16||e===i.OPS.OP_1NEGATE)}(e)}function p(e){return u.Array(e)&&e.every(h)}function l(e){return 0===e.length?i.OPS.OP_0:1===e.length?e[0]>=1&&e[0]<=16?f+e[0]:129===e[0]?i.OPS.OP_1NEGATE:void 0:void 0}function d(e){return r(e)}function y(e){return r(e)}function g(e){if(d(e))return e;c(u.Array,e);const r=e.reduce(((e,t)=>y(t)?1===t.length&&void 0!==l(t)?e+1:e+o.encodingLength(t.length)+t.length:e+1),0),n=t.allocUnsafe(r);let i=0;if(e.forEach((e=>{if(y(e)){const t=l(e);if(void 0!==t)return n.writeUInt8(t,i),void(i+=1);i+=o.encode(n,e.length,i),e.copy(n,i),i+=e.length}else n.writeUInt8(e,i),i+=1})),i!==n.length)throw new Error("Could not decode chunks");return n}function w(e){if(t=e,u.Array(t))return e;var t;c(u.Buffer,e);const r=[];let n=0;for(;n<e.length;){const t=e[n];if(t>i.OPS.OP_0&&t<=i.OPS.OP_PUSHDATA4){const t=o.decode(e,n);if(null===t)return null;if(n+=t.size,n+t.number>e.length)return null;const i=e.slice(n,n+t.number);n+=t.number;const s=l(i);void 0!==s?r.push(s):r.push(i)}else r.push(t),n+=1}return r}function m(e){const t=-129&e;return t>0&&t<4}e.isPushOnly=p,e.countNonPushOnlyOPs=function(e){return e.length-e.filter(h).length},e.compile=g,e.decompile=w,e.toASM=function(e){return d(e)&&(e=w(e)),e.map((e=>{if(y(e)){const t=l(e);if(void 0===t)return e.toString("hex");e=t}return i.REVERSE_OPS[e]})).join(" ")},e.fromASM=function(e){return c(u.String,e),g(e.split(" ").map((e=>void 0!==i.OPS[e]?i.OPS[e]:(c(u.Hex,e),t.from(e,"hex")))))},e.toStack=function(e){return e=w(e),c(p,e),e.map((e=>y(e)?e:e===i.OPS.OP_0?t.allocUnsafe(0):s.encode(e-f)))},e.isCanonicalPubKey=function(e){return u.isPoint(e)},e.isDefinedHashType=m,e.isCanonicalScriptSignature=function(e){return!!r(e)&&(!!m(e[e.length-1])&&n.check(e.slice(0,-1)))},e.number=s,e.signature=a}(mn);var ai={};Object.defineProperty(ai,"__esModule",{value:!0}),ai.value=ai.prop=void 0,ai.prop=function(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){const e=r.call(this);return this[t]=e,e},set(e){Object.defineProperty(this,t,{configurable:!0,enumerable:!0,value:e,writable:!0})}})},ai.value=function(e){let t;return()=>(void 0!==t||(t=e()),t)},Object.defineProperty(wn,"__esModule",{value:!0}),wn.p2data=void 0;const ui=yn,ci=mn,fi=Pn,hi=ai,pi=ci.OPS;wn.p2data=function(e,t){if(!e.data&&!e.output)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,fi.typeforce)({network:fi.typeforce.maybe(fi.typeforce.Object),output:fi.typeforce.maybe(fi.typeforce.Buffer),data:fi.typeforce.maybe(fi.typeforce.arrayOf(fi.typeforce.Buffer))},e);const r={name:"embed",network:e.network||ui.bitcoin};if(hi.prop(r,"output",(()=>{if(e.data)return ci.compile([pi.OP_RETURN].concat(e.data))})),hi.prop(r,"data",(()=>{if(e.output)return ci.decompile(e.output).slice(1)})),t.validate&&e.output){const t=ci.decompile(e.output);if(t[0]!==pi.OP_RETURN)throw new TypeError("Output is invalid");if(!t.slice(1).every(fi.typeforce.Buffer))throw new TypeError("Output is invalid");if(e.data&&!function(e,t){return e.length===t.length&&e.every(((e,r)=>e.equals(t[r])))}(e.data,r.data))throw new TypeError("Data mismatch")}return Object.assign(r,e)};var li={};Object.defineProperty(li,"__esModule",{value:!0}),li.p2ms=void 0;const di=yn,yi=mn,gi=Pn,wi=ai,mi=yi.OPS,bi=mi.OP_RESERVED;function Ei(e,t){return e.length===t.length&&e.every(((e,r)=>e.equals(t[r])))}li.p2ms=function(e,t){if(!(e.input||e.output||e.pubkeys&&void 0!==e.m||e.signatures))throw new TypeError("Not enough data");function r(e){return yi.isCanonicalScriptSignature(e)||void 0!==(t.allowIncomplete&&e===mi.OP_0)}t=Object.assign({validate:!0},t||{}),(0,gi.typeforce)({network:gi.typeforce.maybe(gi.typeforce.Object),m:gi.typeforce.maybe(gi.typeforce.Number),n:gi.typeforce.maybe(gi.typeforce.Number),output:gi.typeforce.maybe(gi.typeforce.Buffer),pubkeys:gi.typeforce.maybe(gi.typeforce.arrayOf(gi.isPoint)),signatures:gi.typeforce.maybe(gi.typeforce.arrayOf(r)),input:gi.typeforce.maybe(gi.typeforce.Buffer)},e);const n={network:e.network||di.bitcoin};let i=[],o=!1;function s(e){o||(o=!0,i=yi.decompile(e),n.m=i[0]-bi,n.n=i[i.length-2]-bi,n.pubkeys=i.slice(1,-2))}if(wi.prop(n,"output",(()=>{if(e.m&&n.n&&e.pubkeys)return yi.compile([].concat(bi+e.m,e.pubkeys,bi+n.n,mi.OP_CHECKMULTISIG))})),wi.prop(n,"m",(()=>{if(n.output)return s(n.output),n.m})),wi.prop(n,"n",(()=>{if(n.pubkeys)return n.pubkeys.length})),wi.prop(n,"pubkeys",(()=>{if(e.output)return s(e.output),n.pubkeys})),wi.prop(n,"signatures",(()=>{if(e.input)return yi.decompile(e.input).slice(1)})),wi.prop(n,"input",(()=>{if(e.signatures)return yi.compile([mi.OP_0].concat(e.signatures))})),wi.prop(n,"witness",(()=>{if(n.input)return[]})),wi.prop(n,"name",(()=>{if(n.m&&n.n)return`p2ms(${n.m} of ${n.n})`})),t.validate){if(e.output){if(s(e.output),!gi.typeforce.Number(i[0]))throw new TypeError("Output is invalid");if(!gi.typeforce.Number(i[i.length-2]))throw new TypeError("Output is invalid");if(i[i.length-1]!==mi.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(n.m<=0||n.n>16||n.m>n.n||n.n!==i.length-3)throw new TypeError("Output is invalid");if(!n.pubkeys.every((e=>(0,gi.isPoint)(e))))throw new TypeError("Output is invalid");if(void 0!==e.m&&e.m!==n.m)throw new TypeError("m mismatch");if(void 0!==e.n&&e.n!==n.n)throw new TypeError("n mismatch");if(e.pubkeys&&!Ei(e.pubkeys,n.pubkeys))throw new TypeError("Pubkeys mismatch")}if(e.pubkeys){if(void 0!==e.n&&e.n!==e.pubkeys.length)throw new TypeError("Pubkey count mismatch");if(n.n=e.pubkeys.length,n.n<n.m)throw new TypeError("Pubkey count cannot be less than m")}if(e.signatures){if(e.signatures.length<n.m)throw new TypeError("Not enough signatures provided");if(e.signatures.length>n.m)throw new TypeError("Too many signatures provided")}if(e.input){if(e.input[0]!==mi.OP_0)throw new TypeError("Input is invalid");if(0===n.signatures.length||!n.signatures.every(r))throw new TypeError("Input has invalid signature(s)");if(e.signatures&&!Ei(e.signatures,n.signatures))throw new TypeError("Signature mismatch");if(void 0!==e.m&&e.m!==e.signatures.length)throw new TypeError("Signature count mismatch")}}return Object.assign(n,e)};var _i={};Object.defineProperty(_i,"__esModule",{value:!0}),_i.p2pk=void 0;const vi=yn,Si=mn,Ii=Pn,Ti=ai,ki=Si.OPS;_i.p2pk=function(e,t){if(!(e.input||e.output||e.pubkey||e.input||e.signature))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,Ii.typeforce)({network:Ii.typeforce.maybe(Ii.typeforce.Object),output:Ii.typeforce.maybe(Ii.typeforce.Buffer),pubkey:Ii.typeforce.maybe(Ii.isPoint),signature:Ii.typeforce.maybe(Si.isCanonicalScriptSignature),input:Ii.typeforce.maybe(Ii.typeforce.Buffer)},e);const r=Ti.value((()=>Si.decompile(e.input))),n={name:"p2pk",network:e.network||vi.bitcoin};if(Ti.prop(n,"output",(()=>{if(e.pubkey)return Si.compile([e.pubkey,ki.OP_CHECKSIG])})),Ti.prop(n,"pubkey",(()=>{if(e.output)return e.output.slice(1,-1)})),Ti.prop(n,"signature",(()=>{if(e.input)return r()[0]})),Ti.prop(n,"input",(()=>{if(e.signature)return Si.compile([e.signature])})),Ti.prop(n,"witness",(()=>{if(n.input)return[]})),t.validate){if(e.output){if(e.output[e.output.length-1]!==ki.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!(0,Ii.isPoint)(n.pubkey))throw new TypeError("Output pubkey is invalid");if(e.pubkey&&!e.pubkey.equals(n.pubkey))throw new TypeError("Pubkey mismatch")}if(e.signature&&e.input&&!e.input.equals(n.input))throw new TypeError("Signature mismatch");if(e.input){if(1!==r().length)throw new TypeError("Input is invalid");if(!Si.isCanonicalScriptSignature(n.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(n,e)};var Ai={},Pi={},Oi={},Ni={},Ui={};function xi(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Bi(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function Ri(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function Mi(e,...t){if(!Ri(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function Li(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");xi(e.outputLen),xi(e.blockLen)}function Ci(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 Hi(e,t){Mi(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}Object.defineProperty(Ui,"__esModule",{value:!0}),Ui.output=Ui.exists=Ui.hash=Ui.bytes=Ui.bool=Ui.number=Ui.isBytes=void 0,Ui.number=xi,Ui.bool=Bi,Ui.isBytes=Ri,Ui.bytes=Mi,Ui.hash=Li,Ui.exists=Ci,Ui.output=Hi;const Di={number:xi,bool:Bi,bytes:Mi,hash:Li,exists:Ci,output:Hi};Ui.default=Di;var Fi={},ji={};Object.defineProperty(ji,"__esModule",{value:!0}),ji.crypto=void 0,ji.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,function(e){
|
|
2
|
-
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3
|
-
Object.defineProperty(e,"__esModule",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.byteSwap32=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=e.isBytes=void 0;const t=ji,r=Ui;e.isBytes=function(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name};e.u8=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength);e.u32=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));e.createView=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);e.rotr=(e,t)=>e<<32-t|e>>>t;e.rotl=(e,t)=>e<<t|e>>>32-t>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];e.byteSwap=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,e.byteSwapIfBE=e.isLE?e=>e:t=>(0,e.byteSwap)(t),e.byteSwap32=function(t){for(let r=0;r<t.length;r++)t[r]=(0,e.byteSwap)(t[r])};const n=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));e.bytesToHex=function(e){(0,r.bytes)(e);let t="";for(let r=0;r<e.length;r++)t+=n[e[r]];return t};const i=48,o=57,s=65,a=70,u=97,c=102;function f(e){return e>=i&&e<=o?e-i:e>=s&&e<=a?e-(s-10):e>=u&&e<=c?e-(u-10):void 0}e.hexToBytes=function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,r=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(r);for(let t=0,i=0;t<r;t++,i+=2){const r=f(e.charCodeAt(i)),o=f(e.charCodeAt(i+1));if(void 0===r||void 0===o){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}n[t]=16*r+o}return n};function h(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function p(e){return"string"==typeof e&&(e=h(e)),(0,r.bytes)(e),e}e.nextTick=async()=>{},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o<t;o++){n(o);const t=Date.now()-i;t>=0&&t<r||(await(0,e.nextTick)(),i+=t)}},e.utf8ToBytes=h,e.toBytes=p,e.concatBytes=function(...e){let t=0;for(let n=0;n<e.length;n++){const i=e[n];(0,r.bytes)(i),t+=i.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const i=e[t];n.set(i,r),r+=i.length}return n};e.Hash=class{clone(){return this._cloneInto()}};const l={}.toString;e.checkOpts=function(e,t){if(void 0!==t&&"[object Object]"!==l.call(t))throw new Error("Options should be object or undefined");return Object.assign(e,t)},e.wrapConstructor=function(e){const t=t=>e().update(p(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t},e.wrapConstructorWithOpts=function(e){const t=(t,r)=>e(r).update(p(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t},e.wrapXOFConstructorWithOpts=function(e){const t=(t,r)=>e(r).update(p(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t},e.randomBytes=function(e=32){if(t.crypto&&"function"==typeof t.crypto.getRandomValues)return t.crypto.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}}(Fi),Object.defineProperty(Ni,"__esModule",{value:!0}),Ni.HashMD=Ni.Maj=Ni.Chi=void 0;const Vi=Ui,Ki=Fi;Ni.Chi=(e,t,r)=>e&t^~e&r;Ni.Maj=(e,t,r)=>e&t^e&r^t&r;Ni.HashMD=class extends Ki.Hash{constructor(e,t,r,n){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=(0,Ki.createView)(this.buffer)}update(e){(0,Vi.exists)(this);const{view:t,buffer:r,blockLen:n}=this,i=(e=(0,Ki.toBytes)(e)).length;for(let o=0;o<i;){const s=Math.min(n-this.pos,i-o);if(s!==n)r.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(t,0),this.pos=0);else{const t=(0,Ki.createView)(e);for(;n<=i-o;o+=n)this.process(t,o)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,Vi.exists)(this),(0,Vi.output)(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:n,isLE:i}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(r,0),o=0);for(let e=o;e<n;e++)t[e]=0;!function(e,t,r,n){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),u=n?4:0,c=n?0:4;e.setUint32(t+u,s,n),e.setUint32(t+c,a,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const s=(0,Ki.createView)(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=a/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<u;e++)s.setUint32(4*e,c[e],i)}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:i,destroyed:o,pos:s}=this;return e.length=n,e.pos=s,e.finished=i,e.destroyed=o,n%t&&e.buffer.set(r),e}},Object.defineProperty(Oi,"__esModule",{value:!0}),Oi.ripemd160=Oi.RIPEMD160=void 0;const Gi=Ni,Wi=Fi,qi=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Xi=new Uint8Array(new Array(16).fill(0).map(((e,t)=>t)));let zi=[Xi],$i=[Xi.map((e=>(9*e+5)%16))];for(let e=0;e<4;e++)for(let t of[zi,$i])t.push(t[e].map((e=>qi[e])));const Yi=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map((e=>new Uint8Array(e))),Ji=zi.map(((e,t)=>e.map((e=>Yi[t][e])))),Qi=$i.map(((e,t)=>e.map((e=>Yi[t][e])))),Zi=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),eo=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function to(e,t,r,n){return 0===e?t^r^n:1===e?t&r|~t&n:2===e?(t|~r)^n:3===e?t&n|r&~n:t^(r|~n)}const ro=new Uint32Array(16);class no extends Gi.HashMD{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:e,h1:t,h2:r,h3:n,h4:i}=this;return[e,t,r,n,i]}set(e,t,r,n,i){this.h0=0|e,this.h1=0|t,this.h2=0|r,this.h3=0|n,this.h4=0|i}process(e,t){for(let r=0;r<16;r++,t+=4)ro[r]=e.getUint32(t,!0);let r=0|this.h0,n=r,i=0|this.h1,o=i,s=0|this.h2,a=s,u=0|this.h3,c=u,f=0|this.h4,h=f;for(let e=0;e<5;e++){const t=4-e,p=Zi[e],l=eo[e],d=zi[e],y=$i[e],g=Ji[e],w=Qi[e];for(let t=0;t<16;t++){const n=(0,Wi.rotl)(r+to(e,i,s,u)+ro[d[t]]+p,g[t])+f|0;r=f,f=u,u=0|(0,Wi.rotl)(s,10),s=i,i=n}for(let e=0;e<16;e++){const r=(0,Wi.rotl)(n+to(t,o,a,c)+ro[y[e]]+l,w[e])+h|0;n=h,h=c,c=0|(0,Wi.rotl)(a,10),a=o,o=r}}this.set(this.h1+s+c|0,this.h2+u+h|0,this.h3+f+n|0,this.h4+r+o|0,this.h0+i+a|0)}roundClean(){ro.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}Oi.RIPEMD160=no,Oi.ripemd160=(0,Wi.wrapConstructor)((()=>new no));var io={};Object.defineProperty(io,"__esModule",{value:!0}),io.sha1=void 0;const oo=Ni,so=Fi,ao=new Uint32Array([1732584193,4023233417,2562383102,271733878,3285377520]),uo=new Uint32Array(80);class co extends oo.HashMD{constructor(){super(64,20,8,!1),this.A=0|ao[0],this.B=0|ao[1],this.C=0|ao[2],this.D=0|ao[3],this.E=0|ao[4]}get(){const{A:e,B:t,C:r,D:n,E:i}=this;return[e,t,r,n,i]}set(e,t,r,n,i){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|i}process(e,t){for(let r=0;r<16;r++,t+=4)uo[r]=e.getUint32(t,!1);for(let e=16;e<80;e++)uo[e]=(0,so.rotl)(uo[e-3]^uo[e-8]^uo[e-14]^uo[e-16],1);let{A:r,B:n,C:i,D:o,E:s}=this;for(let e=0;e<80;e++){let t,a;e<20?(t=(0,oo.Chi)(n,i,o),a=1518500249):e<40?(t=n^i^o,a=1859775393):e<60?(t=(0,oo.Maj)(n,i,o),a=2400959708):(t=n^i^o,a=3395469782);const u=(0,so.rotl)(r,5)+t+s+a+uo[e]|0;s=o,o=i,i=(0,so.rotl)(n,30),n=r,r=u}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,this.set(r,n,i,o,s)}roundClean(){uo.fill(0)}destroy(){this.set(0,0,0,0,0),this.buffer.fill(0)}}io.sha1=(0,so.wrapConstructor)((()=>new co));var fo={};Object.defineProperty(fo,"__esModule",{value:!0}),fo.sha224=fo.sha256=void 0;const ho=Ni,po=Fi,lo=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]),yo=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),go=new Uint32Array(64);class wo extends ho.HashMD{constructor(){super(64,32,8,!1),this.A=0|yo[0],this.B=0|yo[1],this.C=0|yo[2],this.D=0|yo[3],this.E=0|yo[4],this.F=0|yo[5],this.G=0|yo[6],this.H=0|yo[7]}get(){const{A:e,B:t,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[e,t,r,n,i,o,s,a]}set(e,t,r,n,i,o,s,a){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(e,t){for(let r=0;r<16;r++,t+=4)go[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=go[e-15],r=go[e-2],n=(0,po.rotr)(t,7)^(0,po.rotr)(t,18)^t>>>3,i=(0,po.rotr)(r,17)^(0,po.rotr)(r,19)^r>>>10;go[e]=i+go[e-7]+n+go[e-16]|0}let{A:r,B:n,C:i,D:o,E:s,F:a,G:u,H:c}=this;for(let e=0;e<64;e++){const t=c+((0,po.rotr)(s,6)^(0,po.rotr)(s,11)^(0,po.rotr)(s,25))+(0,ho.Chi)(s,a,u)+lo[e]+go[e]|0,f=((0,po.rotr)(r,2)^(0,po.rotr)(r,13)^(0,po.rotr)(r,22))+(0,ho.Maj)(r,n,i)|0;c=u,u=a,a=s,s=o+t|0,o=i,i=n,n=r,r=t+f|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(r,n,i,o,s,a,u,c)}roundClean(){go.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class mo extends wo{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}}fo.sha256=(0,po.wrapConstructor)((()=>new wo)),fo.sha224=(0,po.wrapConstructor)((()=>new mo)),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.taggedHash=e.TAGGED_HASH_PREFIXES=e.TAGS=e.hash256=e.hash160=e.sha256=e.sha1=e.ripemd160=void 0;const r=Oi,n=io,i=fo;function o(e){return t.from((0,i.sha256)(Uint8Array.from(e)))}e.ripemd160=function(e){return t.from((0,r.ripemd160)(Uint8Array.from(e)))},e.sha1=function(e){return t.from((0,n.sha1)(Uint8Array.from(e)))},e.sha256=o,e.hash160=function(e){return t.from((0,r.ripemd160)((0,i.sha256)(Uint8Array.from(e))))},e.hash256=function(e){return t.from((0,i.sha256)((0,i.sha256)(Uint8Array.from(e))))},e.TAGS=["BIP0340/challenge","BIP0340/aux","BIP0340/nonce","TapLeaf","TapBranch","TapSighash","TapTweak","KeyAgg list","KeyAgg coefficient"],e.TAGGED_HASH_PREFIXES={"BIP0340/challenge":t.from([123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124,123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124]),"BIP0340/aux":t.from([241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144,241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144]),"BIP0340/nonce":t.from([7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47,7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47]),TapLeaf:t.from([174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238,174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238]),TapBranch:t.from([25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21,25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21]),TapSighash:t.from([244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49,244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49]),TapTweak:t.from([232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233,232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233]),"KeyAgg list":t.from([72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240,72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240]),"KeyAgg coefficient":t.from([191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129,191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129])},e.taggedHash=function(r,n){return o(t.concat([e.TAGGED_HASH_PREFIXES[r],n]))}}(Pi);var bo=b,{sha256:Eo}=fo,_o=function(e){function t(t){var r=t.slice(0,-4),n=t.slice(-4),i=e(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(t){var r=Uint8Array.from(t),n=e(r),i=r.length+4,o=new Uint8Array(i);return o.set(r,0),o.set(n.subarray(0,4),r.length),bo.encode(o,i)},decode:function(e){var r=t(bo.decode(e));if(!r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(e){var r=bo.decodeUnsafe(e);if(r)return t(r)}}};var vo=_o((function(e){return Eo(Eo(e))}));Object.defineProperty(Ai,"__esModule",{value:!0}),Ai.p2pkh=void 0;const So=Pi,Io=yn,To=mn,ko=Pn,Ao=ai,Po=vo,Oo=To.OPS;Ai.p2pkh=function(e,r){if(!(e.address||e.hash||e.output||e.pubkey||e.input))throw new TypeError("Not enough data");r=Object.assign({validate:!0},r||{}),(0,ko.typeforce)({network:ko.typeforce.maybe(ko.typeforce.Object),address:ko.typeforce.maybe(ko.typeforce.String),hash:ko.typeforce.maybe(ko.typeforce.BufferN(20)),output:ko.typeforce.maybe(ko.typeforce.BufferN(25)),pubkey:ko.typeforce.maybe(ko.isPoint),signature:ko.typeforce.maybe(To.isCanonicalScriptSignature),input:ko.typeforce.maybe(ko.typeforce.Buffer)},e);const n=Ao.value((()=>{const r=t.from(Po.decode(e.address));return{version:r.readUInt8(0),hash:r.slice(1)}})),i=Ao.value((()=>To.decompile(e.input))),o=e.network||Io.bitcoin,s={name:"p2pkh",network:o};if(Ao.prop(s,"address",(()=>{if(!s.hash)return;const e=t.allocUnsafe(21);return e.writeUInt8(o.pubKeyHash,0),s.hash.copy(e,1),Po.encode(e)})),Ao.prop(s,"hash",(()=>e.output?e.output.slice(3,23):e.address?n().hash:e.pubkey||s.pubkey?So.hash160(e.pubkey||s.pubkey):void 0)),Ao.prop(s,"output",(()=>{if(s.hash)return To.compile([Oo.OP_DUP,Oo.OP_HASH160,s.hash,Oo.OP_EQUALVERIFY,Oo.OP_CHECKSIG])})),Ao.prop(s,"pubkey",(()=>{if(e.input)return i()[1]})),Ao.prop(s,"signature",(()=>{if(e.input)return i()[0]})),Ao.prop(s,"input",(()=>{if(e.pubkey&&e.signature)return To.compile([e.signature,e.pubkey])})),Ao.prop(s,"witness",(()=>{if(s.input)return[]})),r.validate){let r=t.from([]);if(e.address){if(n().version!==o.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(20!==n().hash.length)throw new TypeError("Invalid address");r=n().hash}if(e.hash){if(r.length>0&&!r.equals(e.hash))throw new TypeError("Hash mismatch");r=e.hash}if(e.output){if(25!==e.output.length||e.output[0]!==Oo.OP_DUP||e.output[1]!==Oo.OP_HASH160||20!==e.output[2]||e.output[23]!==Oo.OP_EQUALVERIFY||e.output[24]!==Oo.OP_CHECKSIG)throw new TypeError("Output is invalid");const t=e.output.slice(3,23);if(r.length>0&&!r.equals(t))throw new TypeError("Hash mismatch");r=t}if(e.pubkey){const t=So.hash160(e.pubkey);if(r.length>0&&!r.equals(t))throw new TypeError("Hash mismatch");r=t}if(e.input){const t=i();if(2!==t.length)throw new TypeError("Input is invalid");if(!To.isCanonicalScriptSignature(t[0]))throw new TypeError("Input has invalid signature");if(!(0,ko.isPoint)(t[1]))throw new TypeError("Input has invalid pubkey");if(e.signature&&!e.signature.equals(t[0]))throw new TypeError("Signature mismatch");if(e.pubkey&&!e.pubkey.equals(t[1]))throw new TypeError("Pubkey mismatch");const n=So.hash160(t[1]);if(r.length>0&&!r.equals(n))throw new TypeError("Hash mismatch")}}return Object.assign(s,e)};var No={};Object.defineProperty(No,"__esModule",{value:!0}),No.p2sh=void 0;const Uo=Pi,xo=yn,Bo=mn,Ro=Pn,Mo=ai,Lo=vo,Co=Bo.OPS;No.p2sh=function(e,n){if(!(e.address||e.hash||e.output||e.redeem||e.input))throw new TypeError("Not enough data");n=Object.assign({validate:!0},n||{}),(0,Ro.typeforce)({network:Ro.typeforce.maybe(Ro.typeforce.Object),address:Ro.typeforce.maybe(Ro.typeforce.String),hash:Ro.typeforce.maybe(Ro.typeforce.BufferN(20)),output:Ro.typeforce.maybe(Ro.typeforce.BufferN(23)),redeem:Ro.typeforce.maybe({network:Ro.typeforce.maybe(Ro.typeforce.Object),output:Ro.typeforce.maybe(Ro.typeforce.Buffer),input:Ro.typeforce.maybe(Ro.typeforce.Buffer),witness:Ro.typeforce.maybe(Ro.typeforce.arrayOf(Ro.typeforce.Buffer))}),input:Ro.typeforce.maybe(Ro.typeforce.Buffer),witness:Ro.typeforce.maybe(Ro.typeforce.arrayOf(Ro.typeforce.Buffer))},e);let i=e.network;i||(i=e.redeem&&e.redeem.network||xo.bitcoin);const o={network:i},s=Mo.value((()=>{const r=t.from(Lo.decode(e.address));return{version:r.readUInt8(0),hash:r.slice(1)}})),a=Mo.value((()=>Bo.decompile(e.input))),u=Mo.value((()=>{const r=a(),n=r[r.length-1];return{network:i,output:n===Co.OP_FALSE?t.from([]):n,input:Bo.compile(r.slice(0,-1)),witness:e.witness||[]}}));if(Mo.prop(o,"address",(()=>{if(!o.hash)return;const e=t.allocUnsafe(21);return e.writeUInt8(o.network.scriptHash,0),o.hash.copy(e,1),Lo.encode(e)})),Mo.prop(o,"hash",(()=>e.output?e.output.slice(2,22):e.address?s().hash:o.redeem&&o.redeem.output?Uo.hash160(o.redeem.output):void 0)),Mo.prop(o,"output",(()=>{if(o.hash)return Bo.compile([Co.OP_HASH160,o.hash,Co.OP_EQUAL])})),Mo.prop(o,"redeem",(()=>{if(e.input)return u()})),Mo.prop(o,"input",(()=>{if(e.redeem&&e.redeem.input&&e.redeem.output)return Bo.compile([].concat(Bo.decompile(e.redeem.input),e.redeem.output))})),Mo.prop(o,"witness",(()=>o.redeem&&o.redeem.witness?o.redeem.witness:o.input?[]:void 0)),Mo.prop(o,"name",(()=>{const e=["p2sh"];return void 0!==o.redeem&&void 0!==o.redeem.name&&e.push(o.redeem.name),e.join("-")})),n.validate){let n=t.from([]);if(e.address){if(s().version!==i.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(20!==s().hash.length)throw new TypeError("Invalid address");n=s().hash}if(e.hash){if(n.length>0&&!n.equals(e.hash))throw new TypeError("Hash mismatch");n=e.hash}if(e.output){if(23!==e.output.length||e.output[0]!==Co.OP_HASH160||20!==e.output[1]||e.output[22]!==Co.OP_EQUAL)throw new TypeError("Output is invalid");const t=e.output.slice(2,22);if(n.length>0&&!n.equals(t))throw new TypeError("Hash mismatch");n=t}const o=e=>{if(e.output){const t=Bo.decompile(e.output);if(!t||t.length<1)throw new TypeError("Redeem.output too short");if(e.output.byteLength>520)throw new TypeError("Redeem.output unspendable if larger than 520 bytes");if(Bo.countNonPushOnlyOPs(t)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const r=Uo.hash160(e.output);if(n.length>0&&!n.equals(r))throw new TypeError("Hash mismatch");n=r}if(e.input){const t=e.input.length>0,r=e.witness&&e.witness.length>0;if(!t&&!r)throw new TypeError("Empty input");if(t&&r)throw new TypeError("Input and witness provided");if(t){const t=Bo.decompile(e.input);if(!Bo.isPushOnly(t))throw new TypeError("Non push-only scriptSig")}}};if(e.input){const e=a();if(!e||e.length<1)throw new TypeError("Input too short");if(!r(u().output))throw new TypeError("Input is invalid");o(u())}if(e.redeem){if(e.redeem.network&&e.redeem.network!==i)throw new TypeError("Network mismatch");if(e.input){const t=u();if(e.redeem.output&&!e.redeem.output.equals(t.output))throw new TypeError("Redeem.output mismatch");if(e.redeem.input&&!e.redeem.input.equals(t.input))throw new TypeError("Redeem.input mismatch")}o(e.redeem)}if(e.witness&&e.redeem&&e.redeem.witness&&!function(e,t){return e.length===t.length&&e.every(((e,r)=>e.equals(t[r])))}(e.redeem.witness,e.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(o,e)};var Ho={},Do={};Object.defineProperty(Do,"__esModule",{value:!0}),Do.bech32m=Do.bech32=void 0;const Fo="qpzry9x8gf2tvdw0s3jn54khce6mua7l",jo={};for(let e=0;e<32;e++){const t=Fo.charAt(e);jo[t]=e}function Vo(e){const t=e>>25;return(33554431&e)<<5^996825010&-(1&t)^642813549&-(t>>1&1)^513874426&-(t>>2&1)^1027748829&-(t>>3&1)^705979059&-(t>>4&1)}function Ko(e){let t=1;for(let r=0;r<e.length;++r){const n=e.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+e+")";t=Vo(t)^n>>5}t=Vo(t);for(let r=0;r<e.length;++r){const n=e.charCodeAt(r);t=Vo(t)^31&n}return t}function Go(e,t,r,n){let i=0,o=0;const s=(1<<r)-1,a=[];for(let n=0;n<e.length;++n)for(i=i<<t|e[n],o+=t;o>=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<<r-o&s);else{if(o>=t)return"Excess padding";if(i<<r-o&s)return"Non-zero padding"}return a}function Wo(e){return Go(e,8,5,!0)}function qo(e){const t=Go(e,5,8,!1);if(Array.isArray(t))return t}function Xo(e){const t=Go(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function zo(e){let t;function r(e,r){if(r=r||90,e.length<8)return e+" too short";if(e.length>r)return"Exceeds length limit";const n=e.toLowerCase(),i=e.toUpperCase();if(e!==n&&e!==i)return"Mixed-case string "+e;const o=(e=n).lastIndexOf("1");if(-1===o)return"No separator character for "+e;if(0===o)return"Missing prefix for "+e;const s=e.slice(0,o),a=e.slice(o+1);if(a.length<6)return"Data too short";let u=Ko(s);if("string"==typeof u)return u;const c=[];for(let e=0;e<a.length;++e){const t=a.charAt(e),r=jo[t];if(void 0===r)return"Unknown character "+t;u=Vo(u)^r,e+6>=a.length||c.push(r)}return u!==t?"Invalid checksum for "+e:{prefix:s,words:c}}return t="bech32"===e?1:734539939,{decodeUnsafe:function(e,t){const n=r(e,t);if("object"==typeof n)return n},decode:function(e,t){const n=r(e,t);if("object"==typeof n)return n;throw new Error(n)},encode:function(e,r,n){if(n=n||90,e.length+7+r.length>n)throw new TypeError("Exceeds length limit");let i=Ko(e=e.toLowerCase());if("string"==typeof i)throw new Error(i);let o=e+"1";for(let e=0;e<r.length;++e){const t=r[e];if(t>>5)throw new Error("Non 5-bit word");i=Vo(i)^t,o+=Fo.charAt(t)}for(let e=0;e<6;++e)i=Vo(i);i^=t;for(let e=0;e<6;++e){o+=Fo.charAt(i>>5*(5-e)&31)}return o},toWords:Wo,fromWordsUnsafe:qo,fromWords:Xo}}Do.bech32=zo("bech32"),Do.bech32m=zo("bech32m"),Object.defineProperty(Ho,"__esModule",{value:!0}),Ho.p2wpkh=void 0;const $o=Pi,Yo=yn,Jo=mn,Qo=Pn,Zo=ai,es=Do,ts=Jo.OPS,rs=t.alloc(0);Ho.p2wpkh=function(e,r){if(!(e.address||e.hash||e.output||e.pubkey||e.witness))throw new TypeError("Not enough data");r=Object.assign({validate:!0},r||{}),(0,Qo.typeforce)({address:Qo.typeforce.maybe(Qo.typeforce.String),hash:Qo.typeforce.maybe(Qo.typeforce.BufferN(20)),input:Qo.typeforce.maybe(Qo.typeforce.BufferN(0)),network:Qo.typeforce.maybe(Qo.typeforce.Object),output:Qo.typeforce.maybe(Qo.typeforce.BufferN(22)),pubkey:Qo.typeforce.maybe(Qo.isPoint),signature:Qo.typeforce.maybe(Jo.isCanonicalScriptSignature),witness:Qo.typeforce.maybe(Qo.typeforce.arrayOf(Qo.typeforce.Buffer))},e);const n=Zo.value((()=>{const r=es.bech32.decode(e.address),n=r.words.shift(),i=es.bech32.fromWords(r.words);return{version:n,prefix:r.prefix,data:t.from(i)}})),i=e.network||Yo.bitcoin,o={name:"p2wpkh",network:i};if(Zo.prop(o,"address",(()=>{if(!o.hash)return;const e=es.bech32.toWords(o.hash);return e.unshift(0),es.bech32.encode(i.bech32,e)})),Zo.prop(o,"hash",(()=>e.output?e.output.slice(2,22):e.address?n().data:e.pubkey||o.pubkey?$o.hash160(e.pubkey||o.pubkey):void 0)),Zo.prop(o,"output",(()=>{if(o.hash)return Jo.compile([ts.OP_0,o.hash])})),Zo.prop(o,"pubkey",(()=>e.pubkey?e.pubkey:e.witness?e.witness[1]:void 0)),Zo.prop(o,"signature",(()=>{if(e.witness)return e.witness[0]})),Zo.prop(o,"input",(()=>{if(o.witness)return rs})),Zo.prop(o,"witness",(()=>{if(e.pubkey&&e.signature)return[e.signature,e.pubkey]})),r.validate){let r=t.from([]);if(e.address){if(i&&i.bech32!==n().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(0!==n().version)throw new TypeError("Invalid address version");if(20!==n().data.length)throw new TypeError("Invalid address data");r=n().data}if(e.hash){if(r.length>0&&!r.equals(e.hash))throw new TypeError("Hash mismatch");r=e.hash}if(e.output){if(22!==e.output.length||e.output[0]!==ts.OP_0||20!==e.output[1])throw new TypeError("Output is invalid");if(r.length>0&&!r.equals(e.output.slice(2)))throw new TypeError("Hash mismatch");r=e.output.slice(2)}if(e.pubkey){const t=$o.hash160(e.pubkey);if(r.length>0&&!r.equals(t))throw new TypeError("Hash mismatch");if(r=t,!(0,Qo.isPoint)(e.pubkey)||33!==e.pubkey.length)throw new TypeError("Invalid pubkey for p2wpkh")}if(e.witness){if(2!==e.witness.length)throw new TypeError("Witness is invalid");if(!Jo.isCanonicalScriptSignature(e.witness[0]))throw new TypeError("Witness has invalid signature");if(!(0,Qo.isPoint)(e.witness[1])||33!==e.witness[1].length)throw new TypeError("Witness has invalid pubkey");if(e.signature&&!e.signature.equals(e.witness[0]))throw new TypeError("Signature mismatch");if(e.pubkey&&!e.pubkey.equals(e.witness[1]))throw new TypeError("Pubkey mismatch");const t=$o.hash160(e.witness[1]);if(r.length>0&&!r.equals(t))throw new TypeError("Hash mismatch")}}return Object.assign(o,e)};var ns={};Object.defineProperty(ns,"__esModule",{value:!0}),ns.p2wsh=void 0;const is=Pi,os=yn,ss=mn,as=Pn,us=ai,cs=Do,fs=ss.OPS,hs=t.alloc(0);function ps(e){return!(!r(e)||65!==e.length||4!==e[0]||!(0,as.isPoint)(e))}ns.p2wsh=function(e,r){if(!(e.address||e.hash||e.output||e.redeem||e.witness))throw new TypeError("Not enough data");r=Object.assign({validate:!0},r||{}),(0,as.typeforce)({network:as.typeforce.maybe(as.typeforce.Object),address:as.typeforce.maybe(as.typeforce.String),hash:as.typeforce.maybe(as.typeforce.BufferN(32)),output:as.typeforce.maybe(as.typeforce.BufferN(34)),redeem:as.typeforce.maybe({input:as.typeforce.maybe(as.typeforce.Buffer),network:as.typeforce.maybe(as.typeforce.Object),output:as.typeforce.maybe(as.typeforce.Buffer),witness:as.typeforce.maybe(as.typeforce.arrayOf(as.typeforce.Buffer))}),input:as.typeforce.maybe(as.typeforce.BufferN(0)),witness:as.typeforce.maybe(as.typeforce.arrayOf(as.typeforce.Buffer))},e);const n=us.value((()=>{const r=cs.bech32.decode(e.address),n=r.words.shift(),i=cs.bech32.fromWords(r.words);return{version:n,prefix:r.prefix,data:t.from(i)}})),i=us.value((()=>ss.decompile(e.redeem.input)));let o=e.network;o||(o=e.redeem&&e.redeem.network||os.bitcoin);const s={network:o};if(us.prop(s,"address",(()=>{if(!s.hash)return;const e=cs.bech32.toWords(s.hash);return e.unshift(0),cs.bech32.encode(o.bech32,e)})),us.prop(s,"hash",(()=>e.output?e.output.slice(2):e.address?n().data:s.redeem&&s.redeem.output?is.sha256(s.redeem.output):void 0)),us.prop(s,"output",(()=>{if(s.hash)return ss.compile([fs.OP_0,s.hash])})),us.prop(s,"redeem",(()=>{if(e.witness)return{output:e.witness[e.witness.length-1],input:hs,witness:e.witness.slice(0,-1)}})),us.prop(s,"input",(()=>{if(s.witness)return hs})),us.prop(s,"witness",(()=>{if(e.redeem&&e.redeem.input&&e.redeem.input.length>0&&e.redeem.output&&e.redeem.output.length>0){const t=ss.toStack(i());return s.redeem=Object.assign({witness:t},e.redeem),s.redeem.input=hs,[].concat(t,e.redeem.output)}if(e.redeem&&e.redeem.output&&e.redeem.witness)return[].concat(e.redeem.witness,e.redeem.output)})),us.prop(s,"name",(()=>{const e=["p2wsh"];return void 0!==s.redeem&&void 0!==s.redeem.name&&e.push(s.redeem.name),e.join("-")})),r.validate){let r=t.from([]);if(e.address){if(n().prefix!==o.bech32)throw new TypeError("Invalid prefix or Network mismatch");if(0!==n().version)throw new TypeError("Invalid address version");if(32!==n().data.length)throw new TypeError("Invalid address data");r=n().data}if(e.hash){if(r.length>0&&!r.equals(e.hash))throw new TypeError("Hash mismatch");r=e.hash}if(e.output){if(34!==e.output.length||e.output[0]!==fs.OP_0||32!==e.output[1])throw new TypeError("Output is invalid");const t=e.output.slice(2);if(r.length>0&&!r.equals(t))throw new TypeError("Hash mismatch");r=t}if(e.redeem){if(e.redeem.network&&e.redeem.network!==o)throw new TypeError("Network mismatch");if(e.redeem.input&&e.redeem.input.length>0&&e.redeem.witness&&e.redeem.witness.length>0)throw new TypeError("Ambiguous witness source");if(e.redeem.output){const t=ss.decompile(e.redeem.output);if(!t||t.length<1)throw new TypeError("Redeem.output is invalid");if(e.redeem.output.byteLength>3600)throw new TypeError("Redeem.output unspendable if larger than 3600 bytes");if(ss.countNonPushOnlyOPs(t)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const n=is.sha256(e.redeem.output);if(r.length>0&&!r.equals(n))throw new TypeError("Hash mismatch");r=n}if(e.redeem.input&&!ss.isPushOnly(i()))throw new TypeError("Non push-only scriptSig");if(e.witness&&e.redeem.witness&&!function(e,t){return e.length===t.length&&e.every(((e,r)=>e.equals(t[r])))}(e.witness,e.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(e.redeem.input&&i().some(ps)||e.redeem.output&&(ss.decompile(e.redeem.output)||[]).some(ps))throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey")}if(e.witness&&e.witness.length>0){const t=e.witness[e.witness.length-1];if(e.redeem&&e.redeem.output&&!e.redeem.output.equals(t))throw new TypeError("Witness and redeem.output mismatch");if(e.witness.some(ps)||(ss.decompile(t)||[]).some(ps))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(s,e)};var ls={},ds={};Object.defineProperty(ds,"__esModule",{value:!0}),ds.getEccLib=ds.initEccLib=void 0;const ys={};ds.initEccLib=function(e){var r;e?e!==ys.eccLib&&(ws("function"==typeof(r=e).isXOnlyPoint),ws(r.isXOnlyPoint(gs("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),ws(r.isXOnlyPoint(gs("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))),ws(r.isXOnlyPoint(gs("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))),ws(r.isXOnlyPoint(gs("0000000000000000000000000000000000000000000000000000000000000001"))),ws(!r.isXOnlyPoint(gs("0000000000000000000000000000000000000000000000000000000000000000"))),ws(!r.isXOnlyPoint(gs("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))),ws("function"==typeof r.xOnlyPointAddTweak),ms.forEach((e=>{const n=r.xOnlyPointAddTweak(gs(e.pubkey),gs(e.tweak));null===e.result?ws(null===n):(ws(null!==n),ws(n.parity===e.parity),ws(t.from(n.xOnlyPubkey).equals(gs(e.result))))})),ys.eccLib=e):ys.eccLib=e},ds.getEccLib=function(){if(!ys.eccLib)throw new Error("No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance");return ys.eccLib};const gs=e=>t.from(e,"hex");function ws(e){if(!e)throw new Error("ecc library invalid")}const ms=[{pubkey:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",tweak:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",parity:-1,result:null},{pubkey:"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b",tweak:"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac",parity:1,result:"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"},{pubkey:"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991",tweak:"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47",parity:0,result:"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"}];var bs={},Es={},_s=d.Buffer;function vs(e){if(e<0||e>9007199254740991||e%1!=0)throw new RangeError("value out of range")}function Ss(e){return vs(e),e<253?1:e<=65535?3:e<=4294967295?5:9}var Is={encode:function e(t,r,n){if(vs(t),r||(r=_s.allocUnsafe(Ss(t))),!_s.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return n||(n=0),t<253?(r.writeUInt8(t,n),e.bytes=1):t<=65535?(r.writeUInt8(253,n),r.writeUInt16LE(t,n+1),e.bytes=3):t<=4294967295?(r.writeUInt8(254,n),r.writeUInt32LE(t,n+1),e.bytes=5):(r.writeUInt8(255,n),r.writeUInt32LE(t>>>0,n+1),r.writeUInt32LE(t/4294967296|0,n+5),e.bytes=9),r},decode:function e(t,r){if(!_s.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");r||(r=0);var n=t.readUInt8(r);if(n<253)return e.bytes=1,n;if(253===n)return e.bytes=3,t.readUInt16LE(r+1);if(254===n)return e.bytes=5,t.readUInt32LE(r+1);e.bytes=9;var i=t.readUInt32LE(r+1),o=4294967296*t.readUInt32LE(r+5)+i;return vs(o),o},encodingLength:Ss};Object.defineProperty(Es,"__esModule",{value:!0}),Es.BufferReader=Es.BufferWriter=Es.cloneBuffer=Es.reverseBuffer=Es.writeUInt64LE=Es.readUInt64LE=Es.varuint=void 0;const Ts=Pn,{typeforce:ks}=Ts,As=Is;function Ps(e,t){if("number"!=typeof e)throw new Error("cannot write a non-number as a number");if(e<0)throw new Error("specified a negative value for writing an unsigned value");if(e>t)throw new Error("RangeError: value out of range");if(Math.floor(e)!==e)throw new Error("value has a fractional component")}function Os(e,t){const r=e.readUInt32LE(t);let n=e.readUInt32LE(t+4);return n*=4294967296,Ps(n+r,9007199254740991),n+r}function Ns(e,t,r){return Ps(t,9007199254740991),e.writeInt32LE(-1&t,r),e.writeUInt32LE(Math.floor(t/4294967296),r+4),r+8}Es.varuint=As,Es.readUInt64LE=Os,Es.writeUInt64LE=Ns,Es.reverseBuffer=function(e){if(e.length<1)return e;let t=e.length-1,r=0;for(let n=0;n<e.length/2;n++)r=e[n],e[n]=e[t],e[t]=r,t--;return e},Es.cloneBuffer=function(e){const r=t.allocUnsafe(e.length);return e.copy(r),r};class Us{static withCapacity(e){return new Us(t.alloc(e))}constructor(e,t=0){this.buffer=e,this.offset=t,ks(Ts.tuple(Ts.Buffer,Ts.UInt32),[e,t])}writeUInt8(e){this.offset=this.buffer.writeUInt8(e,this.offset)}writeInt32(e){this.offset=this.buffer.writeInt32LE(e,this.offset)}writeUInt32(e){this.offset=this.buffer.writeUInt32LE(e,this.offset)}writeUInt64(e){this.offset=Ns(this.buffer,e,this.offset)}writeVarInt(e){As.encode(e,this.buffer,this.offset),this.offset+=As.encode.bytes}writeSlice(e){if(this.buffer.length<this.offset+e.length)throw new Error("Cannot write slice out of bounds");this.offset+=e.copy(this.buffer,this.offset)}writeVarSlice(e){this.writeVarInt(e.length),this.writeSlice(e)}writeVector(e){this.writeVarInt(e.length),e.forEach((e=>this.writeVarSlice(e)))}end(){if(this.buffer.length===this.offset)return this.buffer;throw new Error(`buffer size ${this.buffer.length}, offset ${this.offset}`)}}Es.BufferWriter=Us;Es.BufferReader=class{constructor(e,t=0){this.buffer=e,this.offset=t,ks(Ts.tuple(Ts.Buffer,Ts.UInt32),[e,t])}readUInt8(){const e=this.buffer.readUInt8(this.offset);return this.offset++,e}readInt32(){const e=this.buffer.readInt32LE(this.offset);return this.offset+=4,e}readUInt32(){const e=this.buffer.readUInt32LE(this.offset);return this.offset+=4,e}readUInt64(){const e=Os(this.buffer,this.offset);return this.offset+=8,e}readVarInt(){const e=As.decode(this.buffer,this.offset);return this.offset+=As.decode.bytes,e}readSlice(e){if(this.buffer.length<this.offset+e)throw new Error("Cannot read slice out of bounds");const t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}readVarSlice(){return this.readSlice(this.readVarInt())}readVector(){const e=this.readVarInt(),t=[];for(let r=0;r<e;r++)t.push(this.readVarSlice());return t}},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.tweakKey=e.tapTweakHash=e.tapleafHash=e.findScriptPath=e.toHashTree=e.rootHashFromPath=e.MAX_TAPTREE_DEPTH=e.LEAF_VERSION_TAPSCRIPT=void 0;const t=E,r=ds,n=Pi,i=Es,o=Pn;e.LEAF_VERSION_TAPSCRIPT=192,e.MAX_TAPTREE_DEPTH=128;function s(r){const i=r.version||e.LEAF_VERSION_TAPSCRIPT;return n.taggedHash("TapLeaf",t.Buffer.concat([t.Buffer.from([i]),c(r.output)]))}function a(e,r){return n.taggedHash("TapTweak",t.Buffer.concat(r?[e,r]:[e]))}function u(e,r){return n.taggedHash("TapBranch",t.Buffer.concat([e,r]))}function c(e){const r=i.varuint.encodingLength(e.length),n=t.Buffer.allocUnsafe(r);return i.varuint.encode(e.length,n),t.Buffer.concat([n,e])}e.rootHashFromPath=function(e,t){if(e.length<33)throw new TypeError(`The control-block length is too small. Got ${e.length}, expected min 33.`);const r=(e.length-33)/32;let n=t;for(let t=0;t<r;t++){const r=e.slice(33+32*t,65+32*t);n=n.compare(r)<0?u(n,r):u(r,n)}return n},e.toHashTree=function e(t){if((0,o.isTapleaf)(t))return{hash:s(t)};const r=[e(t[0]),e(t[1])];r.sort(((e,t)=>e.hash.compare(t.hash)));const[n,i]=r;return{hash:u(n.hash,i.hash),left:n,right:i}},e.findScriptPath=function e(t,r){if("left"in(n=t)&&"right"in n){const n=e(t.left,r);if(void 0!==n)return[...n,t.right.hash];const i=e(t.right,r);if(void 0!==i)return[...i,t.left.hash]}else if(t.hash.equals(r))return[];var n},e.tapleafHash=s,e.tapTweakHash=a,e.tweakKey=function(e,n){if(!t.Buffer.isBuffer(e))return null;if(32!==e.length)return null;if(n&&32!==n.length)return null;const i=a(e,n),o=(0,r.getEccLib)().xOnlyPointAddTweak(e,i);return o&&null!==o.xOnlyPubkey?{parity:o.parity,x:t.Buffer.from(o.xOnlyPubkey)}:null}}(bs),Object.defineProperty(ls,"__esModule",{value:!0}),ls.p2tr=void 0;const xs=E,Bs=yn,Rs=mn,Ms=Pn,Ls=ds,Cs=bs,Hs=ai,Ds=Do,Fs=Rs.OPS;ls.p2tr=function(e,t){if(!(e.address||e.output||e.pubkey||e.internalPubkey||e.witness&&e.witness.length>1))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,Ms.typeforce)({address:Ms.typeforce.maybe(Ms.typeforce.String),input:Ms.typeforce.maybe(Ms.typeforce.BufferN(0)),network:Ms.typeforce.maybe(Ms.typeforce.Object),output:Ms.typeforce.maybe(Ms.typeforce.BufferN(34)),internalPubkey:Ms.typeforce.maybe(Ms.typeforce.BufferN(32)),hash:Ms.typeforce.maybe(Ms.typeforce.BufferN(32)),pubkey:Ms.typeforce.maybe(Ms.typeforce.BufferN(32)),signature:Ms.typeforce.maybe(Ms.typeforce.anyOf(Ms.typeforce.BufferN(64),Ms.typeforce.BufferN(65))),witness:Ms.typeforce.maybe(Ms.typeforce.arrayOf(Ms.typeforce.Buffer)),scriptTree:Ms.typeforce.maybe(Ms.isTaptree),redeem:Ms.typeforce.maybe({output:Ms.typeforce.maybe(Ms.typeforce.Buffer),redeemVersion:Ms.typeforce.maybe(Ms.typeforce.Number),witness:Ms.typeforce.maybe(Ms.typeforce.arrayOf(Ms.typeforce.Buffer))}),redeemVersion:Ms.typeforce.maybe(Ms.typeforce.Number)},e);const r=Hs.value((()=>{const t=Ds.bech32m.decode(e.address),r=t.words.shift(),n=Ds.bech32m.fromWords(t.words);return{version:r,prefix:t.prefix,data:xs.Buffer.from(n)}})),n=Hs.value((()=>{if(e.witness&&e.witness.length)return e.witness.length>=2&&80===e.witness[e.witness.length-1][0]?e.witness.slice(0,-1):e.witness.slice()})),i=Hs.value((()=>e.scriptTree?(0,Cs.toHashTree)(e.scriptTree):e.hash?{hash:e.hash}:void 0)),o=e.network||Bs.bitcoin,s={name:"p2tr",network:o};if(Hs.prop(s,"address",(()=>{if(!s.pubkey)return;const e=Ds.bech32m.toWords(s.pubkey);return e.unshift(1),Ds.bech32m.encode(o.bech32,e)})),Hs.prop(s,"hash",(()=>{const e=i();if(e)return e.hash;const t=n();if(t&&t.length>1){const e=t[t.length-1],r=e[0]&Ms.TAPLEAF_VERSION_MASK,n=t[t.length-2],i=(0,Cs.tapleafHash)({output:n,version:r});return(0,Cs.rootHashFromPath)(e,i)}return null})),Hs.prop(s,"output",(()=>{if(s.pubkey)return Rs.compile([Fs.OP_1,s.pubkey])})),Hs.prop(s,"redeemVersion",(()=>e.redeemVersion?e.redeemVersion:e.redeem&&void 0!==e.redeem.redeemVersion&&null!==e.redeem.redeemVersion?e.redeem.redeemVersion:Cs.LEAF_VERSION_TAPSCRIPT)),Hs.prop(s,"redeem",(()=>{const e=n();if(e&&!(e.length<2))return{output:e[e.length-2],witness:e.slice(0,-2),redeemVersion:e[e.length-1][0]&Ms.TAPLEAF_VERSION_MASK}})),Hs.prop(s,"pubkey",(()=>{if(e.pubkey)return e.pubkey;if(e.output)return e.output.slice(2);if(e.address)return r().data;if(s.internalPubkey){const e=(0,Cs.tweakKey)(s.internalPubkey,s.hash);if(e)return e.x}})),Hs.prop(s,"internalPubkey",(()=>{if(e.internalPubkey)return e.internalPubkey;const t=n();return t&&t.length>1?t[t.length-1].slice(1,33):void 0})),Hs.prop(s,"signature",(()=>{if(e.signature)return e.signature;const t=n();return t&&1===t.length?t[0]:void 0})),Hs.prop(s,"witness",(()=>{if(e.witness)return e.witness;const t=i();if(t&&e.redeem&&e.redeem.output&&e.internalPubkey){const r=(0,Cs.tapleafHash)({output:e.redeem.output,version:s.redeemVersion}),n=(0,Cs.findScriptPath)(t,r);if(!n)return;const i=(0,Cs.tweakKey)(e.internalPubkey,t.hash);if(!i)return;const o=xs.Buffer.concat([xs.Buffer.from([s.redeemVersion|i.parity]),e.internalPubkey].concat(n));return[e.redeem.output,o]}return e.signature?[e.signature]:void 0})),t.validate){let t=xs.Buffer.from([]);if(e.address){if(o&&o.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(1!==r().version)throw new TypeError("Invalid address version");if(32!==r().data.length)throw new TypeError("Invalid address data");t=r().data}if(e.pubkey){if(t.length>0&&!t.equals(e.pubkey))throw new TypeError("Pubkey mismatch");t=e.pubkey}if(e.output){if(34!==e.output.length||e.output[0]!==Fs.OP_1||32!==e.output[1])throw new TypeError("Output is invalid");if(t.length>0&&!t.equals(e.output.slice(2)))throw new TypeError("Pubkey mismatch");t=e.output.slice(2)}if(e.internalPubkey){const r=(0,Cs.tweakKey)(e.internalPubkey,s.hash);if(t.length>0&&!t.equals(r.x))throw new TypeError("Pubkey mismatch");t=r.x}if(t&&t.length&&!(0,Ls.getEccLib)().isXOnlyPoint(t))throw new TypeError("Invalid pubkey for p2tr");const a=i();if(e.hash&&a&&!e.hash.equals(a.hash))throw new TypeError("Hash mismatch");if(e.redeem&&e.redeem.output&&a){const t=(0,Cs.tapleafHash)({output:e.redeem.output,version:s.redeemVersion});if(!(0,Cs.findScriptPath)(a,t))throw new TypeError("Redeem script not in tree")}const u=n();if(e.redeem&&s.redeem){if(e.redeem.redeemVersion&&e.redeem.redeemVersion!==s.redeem.redeemVersion)throw new TypeError("Redeem.redeemVersion and witness mismatch");if(e.redeem.output){if(0===Rs.decompile(e.redeem.output).length)throw new TypeError("Redeem.output is invalid");if(s.redeem.output&&!e.redeem.output.equals(s.redeem.output))throw new TypeError("Redeem.output and witness mismatch")}if(e.redeem.witness&&s.redeem.witness&&!function(e,t){return e.length===t.length&&e.every(((e,r)=>e.equals(t[r])))}(e.redeem.witness,s.redeem.witness))throw new TypeError("Redeem.witness and witness mismatch")}if(u&&u.length)if(1===u.length){if(e.signature&&!e.signature.equals(u[0]))throw new TypeError("Signature mismatch")}else{const r=u[u.length-1];if(r.length<33)throw new TypeError(`The control-block length is too small. Got ${r.length}, expected min 33.`);if((r.length-33)%32!=0)throw new TypeError(`The control-block length of ${r.length} is incorrect!`);const n=(r.length-33)/32;if(n>128)throw new TypeError(`The script path is too long. Got ${n}, expected max 128.`);const i=r.slice(1,33);if(e.internalPubkey&&!e.internalPubkey.equals(i))throw new TypeError("Internal pubkey mismatch");if(!(0,Ls.getEccLib)().isXOnlyPoint(i))throw new TypeError("Invalid internalPubkey for p2tr witness");const o=r[0]&Ms.TAPLEAF_VERSION_MASK,s=u[u.length-2],a=(0,Cs.tapleafHash)({output:s,version:o}),c=(0,Cs.rootHashFromPath)(r,a),f=(0,Cs.tweakKey)(i,c);if(!f)throw new TypeError("Invalid outputKey for p2tr witness");if(t.length&&!t.equals(f.x))throw new TypeError("Pubkey mismatch for p2tr witness");if(f.parity!==(1&r[0]))throw new Error("Incorrect parity")}}return Object.assign(s,e)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.p2tr=e.p2wsh=e.p2wpkh=e.p2sh=e.p2pkh=e.p2pk=e.p2ms=e.embed=void 0;const t=wn;Object.defineProperty(e,"embed",{enumerable:!0,get:function(){return t.p2data}});const r=li;Object.defineProperty(e,"p2ms",{enumerable:!0,get:function(){return r.p2ms}});const n=_i;Object.defineProperty(e,"p2pk",{enumerable:!0,get:function(){return n.p2pk}});const i=Ai;Object.defineProperty(e,"p2pkh",{enumerable:!0,get:function(){return i.p2pkh}});const o=No;Object.defineProperty(e,"p2sh",{enumerable:!0,get:function(){return o.p2sh}});const s=Ho;Object.defineProperty(e,"p2wpkh",{enumerable:!0,get:function(){return s.p2wpkh}});const a=ns;Object.defineProperty(e,"p2wsh",{enumerable:!0,get:function(){return a.p2wsh}});const u=ls;Object.defineProperty(e,"p2tr",{enumerable:!0,get:function(){return u.p2tr}})}(gn),Object.defineProperty(dn,"__esModule",{value:!0}),dn.toOutputScript=dn.fromOutputScript=dn.toBech32=dn.toBase58Check=dn.fromBech32=dn.fromBase58Check=void 0;const js=yn,Vs=gn,Ks=mn,Gs=Pn,Ws=Do,qs=vo,Xs="WARNING: Sending to a future segwit version address can lead to loss of funds. End users MUST be warned carefully in the GUI and asked if they wish to proceed with caution. Wallets should verify the segwit version from the output of fromBech32, then decide when it is safe to use which version of segwit.";function zs(e){const r=t.from(qs.decode(e));if(r.length<21)throw new TypeError(e+" is too short");if(r.length>21)throw new TypeError(e+" is too long");return{version:r.readUInt8(0),hash:r.slice(1)}}function $s(e){let r,n;try{r=Ws.bech32.decode(e)}catch(e){}if(r){if(n=r.words[0],0!==n)throw new TypeError(e+" uses wrong encoding")}else if(r=Ws.bech32m.decode(e),n=r.words[0],0===n)throw new TypeError(e+" uses wrong encoding");const i=Ws.bech32.fromWords(r.words.slice(1));return{version:n,prefix:r.prefix,data:t.from(i)}}function Ys(e,t,r){const n=Ws.bech32.toWords(e);return n.unshift(t),0===t?Ws.bech32.encode(r,n):Ws.bech32m.encode(r,n)}dn.fromBase58Check=zs,dn.fromBech32=$s,dn.toBase58Check=function(e,r){(0,Gs.typeforce)((0,Gs.tuple)(Gs.Hash160bit,Gs.UInt8),arguments);const n=t.allocUnsafe(21);return n.writeUInt8(r,0),e.copy(n,1),qs.encode(n)},dn.toBech32=Ys,dn.fromOutputScript=function(e,t){t=t||js.bitcoin;try{return Vs.p2pkh({output:e,network:t}).address}catch(e){}try{return Vs.p2sh({output:e,network:t}).address}catch(e){}try{return Vs.p2wpkh({output:e,network:t}).address}catch(e){}try{return Vs.p2wsh({output:e,network:t}).address}catch(e){}try{return Vs.p2tr({output:e,network:t}).address}catch(e){}try{return function(e,t){const r=e.slice(2);if(r.length<2||r.length>40)throw new TypeError("Invalid program length for segwit address");const n=e[0]-80;if(n<2||n>16)throw new TypeError("Invalid version for segwit address");if(e[1]!==r.length)throw new TypeError("Invalid script for segwit address");return console.warn(Xs),Ys(r,n,t.bech32)}(e,t)}catch(e){}throw new Error(Ks.toASM(e)+" has no matching Address")},dn.toOutputScript=function(e,t){let r,n;t=t||js.bitcoin;try{r=zs(e)}catch(e){}if(r){if(r.version===t.pubKeyHash)return Vs.p2pkh({hash:r.hash}).output;if(r.version===t.scriptHash)return Vs.p2sh({hash:r.hash}).output}else{try{n=$s(e)}catch(e){}if(n){if(n.prefix!==t.bech32)throw new Error(e+" has an invalid prefix");if(0===n.version){if(20===n.data.length)return Vs.p2wpkh({hash:n.data}).output;if(32===n.data.length)return Vs.p2wsh({hash:n.data}).output}else if(1===n.version){if(32===n.data.length)return Vs.p2tr({pubkey:n.data}).output}else if(n.version>=2&&n.version<=16&&n.data.length>=2&&n.data.length<=40)return console.warn(Xs),Ks.compile([n.version+80,n.data])}}throw new Error(e+" has no matching Script")};var Js={},Qs={};Object.defineProperty(Qs,"__esModule",{value:!0}),Qs.fastMerkleRoot=void 0,Qs.fastMerkleRoot=function(e,r){if(!Array.isArray(e))throw TypeError("Expected values Array");if("function"!=typeof r)throw TypeError("Expected digest Function");let n=e.length;const i=e.concat();for(;n>1;){let e=0;for(let o=0;o<n;o+=2,++e){const s=i[o],a=o+1===n?s:i[o+1],u=t.concat([s,a]);i[e]=r(u)}n=e}return i[0]};var Zs={};Object.defineProperty(Zs,"__esModule",{value:!0}),Zs.Transaction=void 0;const ea=Es,ta=Pi,ra=mn,na=mn,ia=Pn,{typeforce:oa}=ia;function sa(e){const t=e.length;return ea.varuint.encodingLength(t)+t}const aa=t.allocUnsafe(0),ua=[],ca=t.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),fa=t.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),ha=t.from("ffffffffffffffff","hex"),pa={script:aa,valueBuffer:ha};class la{constructor(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}static fromBuffer(e,t){const r=new ea.BufferReader(e),n=new la;n.version=r.readInt32();const i=r.readUInt8(),o=r.readUInt8();let s=!1;i===la.ADVANCED_TRANSACTION_MARKER&&o===la.ADVANCED_TRANSACTION_FLAG?s=!0:r.offset-=2;const a=r.readVarInt();for(let e=0;e<a;++e)n.ins.push({hash:r.readSlice(32),index:r.readUInt32(),script:r.readVarSlice(),sequence:r.readUInt32(),witness:ua});const u=r.readVarInt();for(let e=0;e<u;++e)n.outs.push({value:r.readUInt64(),script:r.readVarSlice()});if(s){for(let e=0;e<a;++e)n.ins[e].witness=r.readVector();if(!n.hasWitnesses())throw new Error("Transaction has superfluous witness data")}if(n.locktime=r.readUInt32(),t)return n;if(r.offset!==e.length)throw new Error("Transaction has unexpected data");return n}static fromHex(e){return la.fromBuffer(t.from(e,"hex"),!1)}static isCoinbaseHash(e){oa(ia.Hash256bit,e);for(let t=0;t<32;++t)if(0!==e[t])return!1;return!0}isCoinbase(){return 1===this.ins.length&&la.isCoinbaseHash(this.ins[0].hash)}addInput(e,t,r,n){return oa(ia.tuple(ia.Hash256bit,ia.UInt32,ia.maybe(ia.UInt32),ia.maybe(ia.Buffer)),arguments),ia.Null(r)&&(r=la.DEFAULT_SEQUENCE),this.ins.push({hash:e,index:t,script:n||aa,sequence:r,witness:ua})-1}addOutput(e,t){return oa(ia.tuple(ia.Buffer,ia.Satoshi),arguments),this.outs.push({script:e,value:t})-1}hasWitnesses(){return this.ins.some((e=>0!==e.witness.length))}weight(){return 3*this.byteLength(!1)+this.byteLength(!0)}virtualSize(){return Math.ceil(this.weight()/4)}byteLength(e=!0){const t=e&&this.hasWitnesses();return(t?10:8)+ea.varuint.encodingLength(this.ins.length)+ea.varuint.encodingLength(this.outs.length)+this.ins.reduce(((e,t)=>e+40+sa(t.script)),0)+this.outs.reduce(((e,t)=>e+8+sa(t.script)),0)+(t?this.ins.reduce(((e,t)=>e+function(e){const t=e.length;return ea.varuint.encodingLength(t)+e.reduce(((e,t)=>e+sa(t)),0)}(t.witness)),0):0)}clone(){const e=new la;return e.version=this.version,e.locktime=this.locktime,e.ins=this.ins.map((e=>({hash:e.hash,index:e.index,script:e.script,sequence:e.sequence,witness:e.witness}))),e.outs=this.outs.map((e=>({script:e.script,value:e.value}))),e}hashForSignature(e,r,n){if(oa(ia.tuple(ia.UInt32,ia.Buffer,ia.Number),arguments),e>=this.ins.length)return fa;const i=ra.compile(ra.decompile(r).filter((e=>e!==na.OPS.OP_CODESEPARATOR))),o=this.clone();if((31&n)===la.SIGHASH_NONE)o.outs=[],o.ins.forEach(((t,r)=>{r!==e&&(t.sequence=0)}));else if((31&n)===la.SIGHASH_SINGLE){if(e>=this.outs.length)return fa;o.outs.length=e+1;for(let t=0;t<e;t++)o.outs[t]=pa;o.ins.forEach(((t,r)=>{r!==e&&(t.sequence=0)}))}n&la.SIGHASH_ANYONECANPAY?(o.ins=[o.ins[e]],o.ins[0].script=i):(o.ins.forEach((e=>{e.script=aa})),o.ins[e].script=i);const s=t.allocUnsafe(o.byteLength(!1)+4);return s.writeInt32LE(n,s.length-4),o.__toBuffer(s,0,!1),ta.hash256(s)}hashForWitnessV1(e,r,n,i,o,s){if(oa(ia.tuple(ia.UInt32,oa.arrayOf(ia.Buffer),oa.arrayOf(ia.Satoshi),ia.UInt32),arguments),n.length!==this.ins.length||r.length!==this.ins.length)throw new Error("Must supply prevout script and value for all inputs");const a=i===la.SIGHASH_DEFAULT?la.SIGHASH_ALL:i&la.SIGHASH_OUTPUT_MASK,u=(i&la.SIGHASH_INPUT_MASK)===la.SIGHASH_ANYONECANPAY,c=a===la.SIGHASH_NONE,f=a===la.SIGHASH_SINGLE;let h=aa,p=aa,l=aa,d=aa,y=aa;if(!u){let e=ea.BufferWriter.withCapacity(36*this.ins.length);this.ins.forEach((t=>{e.writeSlice(t.hash),e.writeUInt32(t.index)})),h=ta.sha256(e.end()),e=ea.BufferWriter.withCapacity(8*this.ins.length),n.forEach((t=>e.writeUInt64(t))),p=ta.sha256(e.end()),e=ea.BufferWriter.withCapacity(r.map(sa).reduce(((e,t)=>e+t))),r.forEach((t=>e.writeVarSlice(t))),l=ta.sha256(e.end()),e=ea.BufferWriter.withCapacity(4*this.ins.length),this.ins.forEach((t=>e.writeUInt32(t.sequence))),d=ta.sha256(e.end())}if(c||f){if(f&&e<this.outs.length){const t=this.outs[e],r=ea.BufferWriter.withCapacity(8+sa(t.script));r.writeUInt64(t.value),r.writeVarSlice(t.script),y=ta.sha256(r.end())}}else{const e=this.outs.map((e=>8+sa(e.script))).reduce(((e,t)=>e+t)),t=ea.BufferWriter.withCapacity(e);this.outs.forEach((e=>{t.writeUInt64(e.value),t.writeVarSlice(e.script)})),y=ta.sha256(t.end())}const g=(o?2:0)+(s?1:0),w=174-(u?49:0)-(c?32:0)+(s?32:0)+(o?37:0),m=ea.BufferWriter.withCapacity(w);if(m.writeUInt8(i),m.writeInt32(this.version),m.writeUInt32(this.locktime),m.writeSlice(h),m.writeSlice(p),m.writeSlice(l),m.writeSlice(d),c||f||m.writeSlice(y),m.writeUInt8(g),u){const t=this.ins[e];m.writeSlice(t.hash),m.writeUInt32(t.index),m.writeUInt64(n[e]),m.writeVarSlice(r[e]),m.writeUInt32(t.sequence)}else m.writeUInt32(e);if(s){const e=ea.BufferWriter.withCapacity(sa(s));e.writeVarSlice(s),m.writeSlice(ta.sha256(e.end()))}return f&&m.writeSlice(y),o&&(m.writeSlice(o),m.writeUInt8(0),m.writeUInt32(4294967295)),ta.taggedHash("TapSighash",t.concat([t.from([0]),m.end()]))}hashForWitnessV0(e,r,n,i){oa(ia.tuple(ia.UInt32,ia.Buffer,ia.Satoshi,ia.UInt32),arguments);let o,s=t.from([]),a=ca,u=ca,c=ca;if(i&la.SIGHASH_ANYONECANPAY||(s=t.allocUnsafe(36*this.ins.length),o=new ea.BufferWriter(s,0),this.ins.forEach((e=>{o.writeSlice(e.hash),o.writeUInt32(e.index)})),u=ta.hash256(s)),i&la.SIGHASH_ANYONECANPAY||(31&i)===la.SIGHASH_SINGLE||(31&i)===la.SIGHASH_NONE||(s=t.allocUnsafe(4*this.ins.length),o=new ea.BufferWriter(s,0),this.ins.forEach((e=>{o.writeUInt32(e.sequence)})),c=ta.hash256(s)),(31&i)!==la.SIGHASH_SINGLE&&(31&i)!==la.SIGHASH_NONE){const e=this.outs.reduce(((e,t)=>e+8+sa(t.script)),0);s=t.allocUnsafe(e),o=new ea.BufferWriter(s,0),this.outs.forEach((e=>{o.writeUInt64(e.value),o.writeVarSlice(e.script)})),a=ta.hash256(s)}else if((31&i)===la.SIGHASH_SINGLE&&e<this.outs.length){const r=this.outs[e];s=t.allocUnsafe(8+sa(r.script)),o=new ea.BufferWriter(s,0),o.writeUInt64(r.value),o.writeVarSlice(r.script),a=ta.hash256(s)}s=t.allocUnsafe(156+sa(r)),o=new ea.BufferWriter(s,0);const f=this.ins[e];return o.writeInt32(this.version),o.writeSlice(u),o.writeSlice(c),o.writeSlice(f.hash),o.writeUInt32(f.index),o.writeVarSlice(r),o.writeUInt64(n),o.writeUInt32(f.sequence),o.writeSlice(a),o.writeUInt32(this.locktime),o.writeUInt32(i),ta.hash256(s)}getHash(e){return e&&this.isCoinbase()?t.alloc(32,0):ta.hash256(this.__toBuffer(void 0,void 0,e))}getId(){return(0,ea.reverseBuffer)(this.getHash(!1)).toString("hex")}toBuffer(e,t){return this.__toBuffer(e,t,!0)}toHex(){return this.toBuffer(void 0,void 0).toString("hex")}setInputScript(e,t){oa(ia.tuple(ia.Number,ia.Buffer),arguments),this.ins[e].script=t}setWitness(e,t){oa(ia.tuple(ia.Number,[ia.Buffer]),arguments),this.ins[e].witness=t}__toBuffer(e,r,n=!1){e||(e=t.allocUnsafe(this.byteLength(n)));const i=new ea.BufferWriter(e,r||0);i.writeInt32(this.version);const o=n&&this.hasWitnesses();return o&&(i.writeUInt8(la.ADVANCED_TRANSACTION_MARKER),i.writeUInt8(la.ADVANCED_TRANSACTION_FLAG)),i.writeVarInt(this.ins.length),this.ins.forEach((e=>{i.writeSlice(e.hash),i.writeUInt32(e.index),i.writeVarSlice(e.script),i.writeUInt32(e.sequence)})),i.writeVarInt(this.outs.length),this.outs.forEach((e=>{void 0!==e.value?i.writeUInt64(e.value):i.writeSlice(e.valueBuffer),i.writeVarSlice(e.script)})),o&&this.ins.forEach((e=>{i.writeVector(e.witness)})),i.writeUInt32(this.locktime),void 0!==r?e.slice(r,i.offset):e}}Zs.Transaction=la,la.DEFAULT_SEQUENCE=4294967295,la.SIGHASH_DEFAULT=0,la.SIGHASH_ALL=1,la.SIGHASH_NONE=2,la.SIGHASH_SINGLE=3,la.SIGHASH_ANYONECANPAY=128,la.SIGHASH_OUTPUT_MASK=3,la.SIGHASH_INPUT_MASK=128,la.ADVANCED_TRANSACTION_MARKER=0,la.ADVANCED_TRANSACTION_FLAG=1,Object.defineProperty(Js,"__esModule",{value:!0}),Js.Block=void 0;const da=Es,ya=Pi,ga=Qs,wa=Zs,ma=Pn,{typeforce:ba}=ma,Ea=new TypeError("Cannot compute merkle root for zero transactions"),_a=new TypeError("Cannot compute witness commit for non-segwit block");class va{constructor(){this.version=1,this.prevHash=void 0,this.merkleRoot=void 0,this.timestamp=0,this.witnessCommit=void 0,this.bits=0,this.nonce=0,this.transactions=void 0}static fromBuffer(e){if(e.length<80)throw new Error("Buffer too small (< 80 bytes)");const t=new da.BufferReader(e),r=new va;if(r.version=t.readInt32(),r.prevHash=t.readSlice(32),r.merkleRoot=t.readSlice(32),r.timestamp=t.readUInt32(),r.bits=t.readUInt32(),r.nonce=t.readUInt32(),80===e.length)return r;const n=()=>{const e=wa.Transaction.fromBuffer(t.buffer.slice(t.offset),!0);return t.offset+=e.byteLength(),e},i=t.readVarInt();r.transactions=[];for(let e=0;e<i;++e){const e=n();r.transactions.push(e)}const o=r.getWitnessCommit();return o&&(r.witnessCommit=o),r}static fromHex(e){return va.fromBuffer(t.from(e,"hex"))}static calculateTarget(e){const r=((4278190080&e)>>24)-3,n=8388607&e,i=t.alloc(32,0);return i.writeUIntBE(n,29-r,3),i}static calculateMerkleRoot(e,r){if(ba([{getHash:ma.Function}],e),0===e.length)throw Ea;if(r&&!Sa(e))throw _a;const n=e.map((e=>e.getHash(r))),i=(0,ga.fastMerkleRoot)(n,ya.hash256);return r?ya.hash256(t.concat([i,e[0].ins[0].witness[0]])):i}getWitnessCommit(){if(!Sa(this.transactions))return null;const e=this.transactions[0].outs.filter((e=>e.script.slice(0,6).equals(t.from("6a24aa21a9ed","hex")))).map((e=>e.script.slice(6,38)));if(0===e.length)return null;const r=e[e.length-1];return r instanceof t&&32===r.length?r:null}hasWitnessCommit(){return this.witnessCommit instanceof t&&32===this.witnessCommit.length||null!==this.getWitnessCommit()}hasWitness(){return(e=this.transactions)instanceof Array&&e.some((e=>"object"==typeof e&&e.ins instanceof Array&&e.ins.some((e=>"object"==typeof e&&e.witness instanceof Array&&e.witness.length>0))));var e}weight(){return 3*this.byteLength(!1,!1)+this.byteLength(!1,!0)}byteLength(e,t=!0){return e||!this.transactions?80:80+da.varuint.encodingLength(this.transactions.length)+this.transactions.reduce(((e,r)=>e+r.byteLength(t)),0)}getHash(){return ya.hash256(this.toBuffer(!0))}getId(){return(0,da.reverseBuffer)(this.getHash()).toString("hex")}getUTCDate(){const e=new Date(0);return e.setUTCSeconds(this.timestamp),e}toBuffer(e){const r=t.allocUnsafe(this.byteLength(e)),n=new da.BufferWriter(r);return n.writeInt32(this.version),n.writeSlice(this.prevHash),n.writeSlice(this.merkleRoot),n.writeUInt32(this.timestamp),n.writeUInt32(this.bits),n.writeUInt32(this.nonce),e||!this.transactions||(da.varuint.encode(this.transactions.length,r,n.offset),n.offset+=da.varuint.encode.bytes,this.transactions.forEach((e=>{const t=e.byteLength();e.toBuffer(r,n.offset),n.offset+=t}))),r}toHex(e){return this.toBuffer(e).toString("hex")}checkTxRoots(){const e=this.hasWitnessCommit();return!(!e&&this.hasWitness())&&(this.__checkMerkleRoot()&&(!e||this.__checkWitnessCommit()))}checkProofOfWork(){const e=(0,da.reverseBuffer)(this.getHash()),t=va.calculateTarget(this.bits);return e.compare(t)<=0}__checkMerkleRoot(){if(!this.transactions)throw Ea;const e=va.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(e)}__checkWitnessCommit(){if(!this.transactions)throw Ea;if(!this.hasWitnessCommit())throw _a;const e=va.calculateMerkleRoot(this.transactions,!0);return 0===this.witnessCommit.compare(e)}}function Sa(e){return e instanceof Array&&e[0]&&e[0].ins&&e[0].ins instanceof Array&&e[0].ins[0]&&e[0].ins[0].witness&&e[0].ins[0].witness instanceof Array&&e[0].ins[0].witness.length>0}Js.Block=va;var Ia={},Ta={},ka={},Aa={},Pa={},Oa={},Na={};!function(e){var t,r,n;Object.defineProperty(e,"__esModule",{value:!0}),(t=e.GlobalTypes||(e.GlobalTypes={}))[t.UNSIGNED_TX=0]="UNSIGNED_TX",t[t.GLOBAL_XPUB=1]="GLOBAL_XPUB",e.GLOBAL_TYPE_NAMES=["unsignedTx","globalXpub"],(r=e.InputTypes||(e.InputTypes={}))[r.NON_WITNESS_UTXO=0]="NON_WITNESS_UTXO",r[r.WITNESS_UTXO=1]="WITNESS_UTXO",r[r.PARTIAL_SIG=2]="PARTIAL_SIG",r[r.SIGHASH_TYPE=3]="SIGHASH_TYPE",r[r.REDEEM_SCRIPT=4]="REDEEM_SCRIPT",r[r.WITNESS_SCRIPT=5]="WITNESS_SCRIPT",r[r.BIP32_DERIVATION=6]="BIP32_DERIVATION",r[r.FINAL_SCRIPTSIG=7]="FINAL_SCRIPTSIG",r[r.FINAL_SCRIPTWITNESS=8]="FINAL_SCRIPTWITNESS",r[r.POR_COMMITMENT=9]="POR_COMMITMENT",r[r.TAP_KEY_SIG=19]="TAP_KEY_SIG",r[r.TAP_SCRIPT_SIG=20]="TAP_SCRIPT_SIG",r[r.TAP_LEAF_SCRIPT=21]="TAP_LEAF_SCRIPT",r[r.TAP_BIP32_DERIVATION=22]="TAP_BIP32_DERIVATION",r[r.TAP_INTERNAL_KEY=23]="TAP_INTERNAL_KEY",r[r.TAP_MERKLE_ROOT=24]="TAP_MERKLE_ROOT",e.INPUT_TYPE_NAMES=["nonWitnessUtxo","witnessUtxo","partialSig","sighashType","redeemScript","witnessScript","bip32Derivation","finalScriptSig","finalScriptWitness","porCommitment","tapKeySig","tapScriptSig","tapLeafScript","tapBip32Derivation","tapInternalKey","tapMerkleRoot"],(n=e.OutputTypes||(e.OutputTypes={}))[n.REDEEM_SCRIPT=0]="REDEEM_SCRIPT",n[n.WITNESS_SCRIPT=1]="WITNESS_SCRIPT",n[n.BIP32_DERIVATION=2]="BIP32_DERIVATION",n[n.TAP_INTERNAL_KEY=5]="TAP_INTERNAL_KEY",n[n.TAP_TREE=6]="TAP_TREE",n[n.TAP_BIP32_DERIVATION=7]="TAP_BIP32_DERIVATION",e.OUTPUT_TYPE_NAMES=["redeemScript","witnessScript","bip32Derivation","tapInternalKey","tapTree","tapBip32Derivation"]}(Na);var Ua={};Object.defineProperty(Ua,"__esModule",{value:!0});const xa=Na;Ua.decode=function(e){if(e.key[0]!==xa.GlobalTypes.GLOBAL_XPUB)throw new Error("Decode Error: could not decode globalXpub with key 0x"+e.key.toString("hex"));if(79!==e.key.length||![2,3].includes(e.key[46]))throw new Error("Decode Error: globalXpub has invalid extended pubkey in key 0x"+e.key.toString("hex"));if(e.value.length/4%1!=0)throw new Error("Decode Error: Global GLOBAL_XPUB value length should be multiple of 4");const t=e.key.slice(1),r={masterFingerprint:e.value.slice(0,4),extendedPubkey:t,path:"m"};for(const t of(n=e.value.length/4-1,[...Array(n).keys()])){const n=e.value.readUInt32LE(4*t+4),i=!!(2147483648&n),o=2147483647&n;r.path+="/"+o.toString(10)+(i?"'":"")}var n;return r},Ua.encode=function(e){const r=t.from([xa.GlobalTypes.GLOBAL_XPUB]),n=t.concat([r,e.extendedPubkey]),i=e.path.split("/"),o=t.allocUnsafe(4*i.length);e.masterFingerprint.copy(o,0);let s=4;return i.slice(1).forEach((e=>{const t="'"===e.slice(-1);let r=2147483647&parseInt(t?e.slice(0,-1):e,10);t&&(r+=2147483648),o.writeUInt32LE(r,s),s+=4})),{key:n,value:o}},Ua.expected="{ masterFingerprint: Buffer; extendedPubkey: Buffer; path: string; }",Ua.check=function(e){const t=e.extendedPubkey,n=e.masterFingerprint,i=e.path;return r(t)&&78===t.length&&[2,3].indexOf(t[45])>-1&&r(n)&&4===n.length&&"string"==typeof i&&!!i.match(/^m(\/\d+'?)*$/)},Ua.canAddToArray=function(e,t,r){const n=t.extendedPubkey.toString("hex");return!r.has(n)&&(r.add(n),0===e.filter((e=>e.extendedPubkey.equals(t.extendedPubkey))).length)};var Ba={};Object.defineProperty(Ba,"__esModule",{value:!0});const Ra=Na;Ba.encode=function(e){return{key:t.from([Ra.GlobalTypes.UNSIGNED_TX]),value:e.toBuffer()}};var Ma={};Object.defineProperty(Ma,"__esModule",{value:!0});const La=Na;Ma.decode=function(e){if(e.key[0]!==La.InputTypes.FINAL_SCRIPTSIG)throw new Error("Decode Error: could not decode finalScriptSig with key 0x"+e.key.toString("hex"));return e.value},Ma.encode=function(e){return{key:t.from([La.InputTypes.FINAL_SCRIPTSIG]),value:e}},Ma.expected="Buffer",Ma.check=function(e){return r(e)},Ma.canAdd=function(e,t){return!!e&&!!t&&void 0===e.finalScriptSig};var Ca={};Object.defineProperty(Ca,"__esModule",{value:!0});const Ha=Na;Ca.decode=function(e){if(e.key[0]!==Ha.InputTypes.FINAL_SCRIPTWITNESS)throw new Error("Decode Error: could not decode finalScriptWitness with key 0x"+e.key.toString("hex"));return e.value},Ca.encode=function(e){return{key:t.from([Ha.InputTypes.FINAL_SCRIPTWITNESS]),value:e}},Ca.expected="Buffer",Ca.check=function(e){return r(e)},Ca.canAdd=function(e,t){return!!e&&!!t&&void 0===e.finalScriptWitness};var Da={};Object.defineProperty(Da,"__esModule",{value:!0});const Fa=Na;Da.decode=function(e){if(e.key[0]!==Fa.InputTypes.NON_WITNESS_UTXO)throw new Error("Decode Error: could not decode nonWitnessUtxo with key 0x"+e.key.toString("hex"));return e.value},Da.encode=function(e){return{key:t.from([Fa.InputTypes.NON_WITNESS_UTXO]),value:e}},Da.expected="Buffer",Da.check=function(e){return r(e)},Da.canAdd=function(e,t){return!!e&&!!t&&void 0===e.nonWitnessUtxo};var ja={};Object.defineProperty(ja,"__esModule",{value:!0});const Va=Na;ja.decode=function(e){if(e.key[0]!==Va.InputTypes.PARTIAL_SIG)throw new Error("Decode Error: could not decode partialSig with key 0x"+e.key.toString("hex"));if(34!==e.key.length&&66!==e.key.length||![2,3,4].includes(e.key[1]))throw new Error("Decode Error: partialSig has invalid pubkey in key 0x"+e.key.toString("hex"));return{pubkey:e.key.slice(1),signature:e.value}},ja.encode=function(e){const r=t.from([Va.InputTypes.PARTIAL_SIG]);return{key:t.concat([r,e.pubkey]),value:e.signature}},ja.expected="{ pubkey: Buffer; signature: Buffer; }",ja.check=function(e){return r(e.pubkey)&&r(e.signature)&&[33,65].includes(e.pubkey.length)&&[2,3,4].includes(e.pubkey[0])&&function(e){if(!r(e)||e.length<9)return!1;if(48!==e[0])return!1;if(e.length!==e[1]+3)return!1;if(2!==e[2])return!1;const t=e[3];if(t>33||t<1)return!1;if(2!==e[3+t+1])return!1;const n=e[3+t+2];return!(n>33||n<1)&&e.length===3+t+2+n+2}(e.signature)},ja.canAddToArray=function(e,t,r){const n=t.pubkey.toString("hex");return!r.has(n)&&(r.add(n),0===e.filter((e=>e.pubkey.equals(t.pubkey))).length)};var Ka={};Object.defineProperty(Ka,"__esModule",{value:!0});const Ga=Na;Ka.decode=function(e){if(e.key[0]!==Ga.InputTypes.POR_COMMITMENT)throw new Error("Decode Error: could not decode porCommitment with key 0x"+e.key.toString("hex"));return e.value.toString("utf8")},Ka.encode=function(e){return{key:t.from([Ga.InputTypes.POR_COMMITMENT]),value:t.from(e,"utf8")}},Ka.expected="string",Ka.check=function(e){return"string"==typeof e},Ka.canAdd=function(e,t){return!!e&&!!t&&void 0===e.porCommitment};var Wa={};Object.defineProperty(Wa,"__esModule",{value:!0});const qa=Na;Wa.decode=function(e){if(e.key[0]!==qa.InputTypes.SIGHASH_TYPE)throw new Error("Decode Error: could not decode sighashType with key 0x"+e.key.toString("hex"));return e.value.readUInt32LE(0)},Wa.encode=function(e){const r=t.from([qa.InputTypes.SIGHASH_TYPE]),n=t.allocUnsafe(4);return n.writeUInt32LE(e,0),{key:r,value:n}},Wa.expected="number",Wa.check=function(e){return"number"==typeof e},Wa.canAdd=function(e,t){return!!e&&!!t&&void 0===e.sighashType};var Xa={};Object.defineProperty(Xa,"__esModule",{value:!0});const za=Na;function $a(e){return r(e)&&(64===e.length||65===e.length)}Xa.decode=function(e){if(e.key[0]!==za.InputTypes.TAP_KEY_SIG||1!==e.key.length)throw new Error("Decode Error: could not decode tapKeySig with key 0x"+e.key.toString("hex"));if(!$a(e.value))throw new Error("Decode Error: tapKeySig not a valid 64-65-byte BIP340 signature");return e.value},Xa.encode=function(e){return{key:t.from([za.InputTypes.TAP_KEY_SIG]),value:e}},Xa.expected="Buffer",Xa.check=$a,Xa.canAdd=function(e,t){return!!e&&!!t&&void 0===e.tapKeySig};var Ya={};Object.defineProperty(Ya,"__esModule",{value:!0});const Ja=Na;Ya.decode=function(e){if(e.key[0]!==Ja.InputTypes.TAP_LEAF_SCRIPT)throw new Error("Decode Error: could not decode tapLeafScript with key 0x"+e.key.toString("hex"));if((e.key.length-2)%32!=0)throw new Error("Decode Error: tapLeafScript has invalid control block in key 0x"+e.key.toString("hex"));const t=e.value[e.value.length-1];if((254&e.key[1])!==t)throw new Error("Decode Error: tapLeafScript bad leaf version in key 0x"+e.key.toString("hex"));const r=e.value.slice(0,-1);return{controlBlock:e.key.slice(1),script:r,leafVersion:t}},Ya.encode=function(e){const r=t.from([Ja.InputTypes.TAP_LEAF_SCRIPT]),n=t.from([e.leafVersion]);return{key:t.concat([r,e.controlBlock]),value:t.concat([e.script,n])}},Ya.expected="{ controlBlock: Buffer; leafVersion: number, script: Buffer; }",Ya.check=function(e){return r(e.controlBlock)&&(e.controlBlock.length-1)%32==0&&(254&e.controlBlock[0])===e.leafVersion&&r(e.script)},Ya.canAddToArray=function(e,t,r){const n=t.controlBlock.toString("hex");return!r.has(n)&&(r.add(n),0===e.filter((e=>e.controlBlock.equals(t.controlBlock))).length)};var Qa={};Object.defineProperty(Qa,"__esModule",{value:!0});const Za=Na;function eu(e){return r(e)&&32===e.length}Qa.decode=function(e){if(e.key[0]!==Za.InputTypes.TAP_MERKLE_ROOT||1!==e.key.length)throw new Error("Decode Error: could not decode tapMerkleRoot with key 0x"+e.key.toString("hex"));if(!eu(e.value))throw new Error("Decode Error: tapMerkleRoot not a 32-byte hash");return e.value},Qa.encode=function(e){return{key:t.from([Za.InputTypes.TAP_MERKLE_ROOT]),value:e}},Qa.expected="Buffer",Qa.check=eu,Qa.canAdd=function(e,t){return!!e&&!!t&&void 0===e.tapMerkleRoot};var tu={};Object.defineProperty(tu,"__esModule",{value:!0});const ru=Na;tu.decode=function(e){if(e.key[0]!==ru.InputTypes.TAP_SCRIPT_SIG)throw new Error("Decode Error: could not decode tapScriptSig with key 0x"+e.key.toString("hex"));if(65!==e.key.length)throw new Error("Decode Error: tapScriptSig has invalid key 0x"+e.key.toString("hex"));if(64!==e.value.length&&65!==e.value.length)throw new Error("Decode Error: tapScriptSig has invalid signature in key 0x"+e.key.toString("hex"));return{pubkey:e.key.slice(1,33),leafHash:e.key.slice(33),signature:e.value}},tu.encode=function(e){const r=t.from([ru.InputTypes.TAP_SCRIPT_SIG]);return{key:t.concat([r,e.pubkey,e.leafHash]),value:e.signature}},tu.expected="{ pubkey: Buffer; leafHash: Buffer; signature: Buffer; }",tu.check=function(e){return r(e.pubkey)&&r(e.leafHash)&&r(e.signature)&&32===e.pubkey.length&&32===e.leafHash.length&&(64===e.signature.length||65===e.signature.length)},tu.canAddToArray=function(e,t,r){const n=t.pubkey.toString("hex")+t.leafHash.toString("hex");return!r.has(n)&&(r.add(n),0===e.filter((e=>e.pubkey.equals(t.pubkey)&&e.leafHash.equals(t.leafHash))).length)};var nu={},iu={},ou={};Object.defineProperty(ou,"__esModule",{value:!0});function su(e){if(e<0||e>9007199254740991||e%1!=0)throw new RangeError("value out of range")}function au(e){return su(e),e<253?1:e<=65535?3:e<=4294967295?5:9}ou.encode=function e(n,i,o){if(su(n),i||(i=t.allocUnsafe(au(n))),!r(i))throw new TypeError("buffer must be a Buffer instance");return o||(o=0),n<253?(i.writeUInt8(n,o),Object.assign(e,{bytes:1})):n<=65535?(i.writeUInt8(253,o),i.writeUInt16LE(n,o+1),Object.assign(e,{bytes:3})):n<=4294967295?(i.writeUInt8(254,o),i.writeUInt32LE(n,o+1),Object.assign(e,{bytes:5})):(i.writeUInt8(255,o),i.writeUInt32LE(n>>>0,o+1),i.writeUInt32LE(n/4294967296|0,o+5),Object.assign(e,{bytes:9})),i},ou.decode=function e(t,n){if(!r(t))throw new TypeError("buffer must be a Buffer instance");n||(n=0);const i=t.readUInt8(n);if(i<253)return Object.assign(e,{bytes:1}),i;if(253===i)return Object.assign(e,{bytes:3}),t.readUInt16LE(n+1);if(254===i)return Object.assign(e,{bytes:5}),t.readUInt32LE(n+1);{Object.assign(e,{bytes:9});const r=t.readUInt32LE(n+1),i=4294967296*t.readUInt32LE(n+5)+r;return su(i),i}},ou.encodingLength=au,Object.defineProperty(iu,"__esModule",{value:!0});const uu=ou;function cu(e){const r=e.key.length,n=e.value.length,i=uu.encodingLength(r),o=uu.encodingLength(n),s=t.allocUnsafe(i+r+o+n);return uu.encode(r,s,0),e.key.copy(s,i),uu.encode(n,s,i+r),e.value.copy(s,i+r+o),s}function fu(e,t){if("number"!=typeof e)throw new Error("cannot write a non-number as a number");if(e<0)throw new Error("specified a negative value for writing an unsigned value");if(e>t)throw new Error("RangeError: value out of range");if(Math.floor(e)!==e)throw new Error("value has a fractional component")}iu.range=e=>[...Array(e).keys()],iu.reverseBuffer=function(e){if(e.length<1)return e;let t=e.length-1,r=0;for(let n=0;n<e.length/2;n++)r=e[n],e[n]=e[t],e[t]=r,t--;return e},iu.keyValsToBuffer=function(e){const r=e.map(cu);return r.push(t.from([0])),t.concat(r)},iu.keyValToBuffer=cu,iu.readUInt64LE=function(e,t){const r=e.readUInt32LE(t);let n=e.readUInt32LE(t+4);return n*=4294967296,fu(n+r,9007199254740991),n+r},iu.writeUInt64LE=function(e,t,r){return fu(t,9007199254740991),e.writeInt32LE(-1&t,r),e.writeUInt32LE(Math.floor(t/4294967296),r+4),r+8},Object.defineProperty(nu,"__esModule",{value:!0});const hu=Na,pu=iu,lu=ou;nu.decode=function(e){if(e.key[0]!==hu.InputTypes.WITNESS_UTXO)throw new Error("Decode Error: could not decode witnessUtxo with key 0x"+e.key.toString("hex"));const t=pu.readUInt64LE(e.value,0);let r=8;const n=lu.decode(e.value,r);r+=lu.encodingLength(n);const i=e.value.slice(r);if(i.length!==n)throw new Error("Decode Error: WITNESS_UTXO script is not proper length");return{script:i,value:t}},nu.encode=function(e){const{script:r,value:n}=e,i=lu.encodingLength(r.length),o=t.allocUnsafe(8+i+r.length);return pu.writeUInt64LE(o,n,0),lu.encode(r.length,o,8),r.copy(o,8+i),{key:t.from([hu.InputTypes.WITNESS_UTXO]),value:o}},nu.expected="{ script: Buffer; value: number; }",nu.check=function(e){return r(e.script)&&"number"==typeof e.value},nu.canAdd=function(e,t){return!!e&&!!t&&void 0===e.witnessUtxo};var du={};Object.defineProperty(du,"__esModule",{value:!0});const yu=Na,gu=ou;du.decode=function(e){if(e.key[0]!==yu.OutputTypes.TAP_TREE||1!==e.key.length)throw new Error("Decode Error: could not decode tapTree with key 0x"+e.key.toString("hex"));let t=0;const r=[];for(;t<e.value.length;){const n=e.value[t++],i=e.value[t++],o=gu.decode(e.value,t);t+=gu.encodingLength(o),r.push({depth:n,leafVersion:i,script:e.value.slice(t,t+o)}),t+=o}return{leaves:r}},du.encode=function(e){const r=t.from([yu.OutputTypes.TAP_TREE]),n=[].concat(...e.leaves.map((e=>[t.of(e.depth,e.leafVersion),gu.encode(e.script.length),e.script])));return{key:r,value:t.concat(n)}},du.expected="{ leaves: [{ depth: number; leafVersion: number, script: Buffer; }] }",du.check=function(e){return Array.isArray(e.leaves)&&e.leaves.every((e=>e.depth>=0&&e.depth<=128&&(254&e.leafVersion)===e.leafVersion&&r(e.script)))},du.canAdd=function(e,t){return!!e&&!!t&&void 0===e.tapTree};var wu={};Object.defineProperty(wu,"__esModule",{value:!0});const mu=e=>33===e.length&&[2,3].includes(e[0])||65===e.length&&4===e[0];wu.makeConverter=function(e,n=mu){return{decode:function(t){if(t.key[0]!==e)throw new Error("Decode Error: could not decode bip32Derivation with key 0x"+t.key.toString("hex"));const r=t.key.slice(1);if(!n(r))throw new Error("Decode Error: bip32Derivation has invalid pubkey in key 0x"+t.key.toString("hex"));if(t.value.length/4%1!=0)throw new Error("Decode Error: Input BIP32_DERIVATION value length should be multiple of 4");const i={masterFingerprint:t.value.slice(0,4),pubkey:r,path:"m"};for(const e of(o=t.value.length/4-1,[...Array(o).keys()])){const r=t.value.readUInt32LE(4*e+4),n=!!(2147483648&r),o=2147483647&r;i.path+="/"+o.toString(10)+(n?"'":"")}var o;return i},encode:function(r){const n=t.from([e]),i=t.concat([n,r.pubkey]),o=r.path.split("/"),s=t.allocUnsafe(4*o.length);r.masterFingerprint.copy(s,0);let a=4;return o.slice(1).forEach((e=>{const t="'"===e.slice(-1);let r=2147483647&parseInt(t?e.slice(0,-1):e,10);t&&(r+=2147483648),s.writeUInt32LE(r,a),a+=4})),{key:i,value:s}},check:function(e){return r(e.pubkey)&&r(e.masterFingerprint)&&"string"==typeof e.path&&n(e.pubkey)&&4===e.masterFingerprint.length},expected:"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; }",canAddToArray:function(e,t,r){const n=t.pubkey.toString("hex");return!r.has(n)&&(r.add(n),0===e.filter((e=>e.pubkey.equals(t.pubkey))).length)}}};var bu={};Object.defineProperty(bu,"__esModule",{value:!0}),bu.makeChecker=function(e){return function(t){let r;if(e.includes(t.key[0])&&(r=t.key.slice(1),33!==r.length&&65!==r.length||![2,3,4].includes(r[0])))throw new Error("Format Error: invalid pubkey in key 0x"+t.key.toString("hex"));return r}};var Eu={};Object.defineProperty(Eu,"__esModule",{value:!0}),Eu.makeConverter=function(e){return{decode:function(t){if(t.key[0]!==e)throw new Error("Decode Error: could not decode redeemScript with key 0x"+t.key.toString("hex"));return t.value},encode:function(r){return{key:t.from([e]),value:r}},check:function(e){return r(e)},expected:"Buffer",canAdd:function(e,t){return!!e&&!!t&&void 0===e.redeemScript}}};var _u={};Object.defineProperty(_u,"__esModule",{value:!0});const vu=ou,Su=wu,Iu=e=>32===e.length;_u.makeConverter=function(e){const n=Su.makeConverter(e,Iu);return{decode:function(e){const t=vu.decode(e.value),r=vu.encodingLength(t),i=n.decode({key:e.key,value:e.value.slice(r+32*t)}),o=new Array(t);for(let n=0,i=r;n<t;n++,i+=32)o[n]=e.value.slice(i,i+32);return Object.assign({},i,{leafHashes:o})},encode:function(e){const r=n.encode(e),i=vu.encodingLength(e.leafHashes.length),o=t.allocUnsafe(i);vu.encode(e.leafHashes.length,o);const s=t.concat([o,...e.leafHashes,r.value]);return Object.assign({},r,{value:s})},check:function(e){return Array.isArray(e.leafHashes)&&e.leafHashes.every((e=>r(e)&&32===e.length))&&n.check(e)},expected:"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; leafHashes: Buffer[]; }",canAddToArray:n.canAddToArray}};var Tu={};Object.defineProperty(Tu,"__esModule",{value:!0}),Tu.makeConverter=function(e){return{decode:function(t){if(t.key[0]!==e||1!==t.key.length)throw new Error("Decode Error: could not decode tapInternalKey with key 0x"+t.key.toString("hex"));if(32!==t.value.length)throw new Error("Decode Error: tapInternalKey not a 32-byte x-only pubkey");return t.value},encode:function(r){return{key:t.from([e]),value:r}},check:function(e){return r(e)&&32===e.length},expected:"Buffer",canAdd:function(e,t){return!!e&&!!t&&void 0===e.tapInternalKey}}};var ku={};Object.defineProperty(ku,"__esModule",{value:!0}),ku.makeConverter=function(e){return{decode:function(t){if(t.key[0]!==e)throw new Error("Decode Error: could not decode witnessScript with key 0x"+t.key.toString("hex"));return t.value},encode:function(r){return{key:t.from([e]),value:r}},check:function(e){return r(e)},expected:"Buffer",canAdd:function(e,t){return!!e&&!!t&&void 0===e.witnessScript}}},Object.defineProperty(Oa,"__esModule",{value:!0});const Au=Na,Pu=Ma,Ou=Ca,Nu=Da,Uu=ja,xu=Ka,Bu=Wa,Ru=Xa,Mu=Ya,Lu=Qa,Cu=tu,Hu=nu,Du=du,Fu=wu,ju=bu,Vu=Eu,Ku=_u,Gu=Tu,Wu=ku,qu={unsignedTx:Ba,globalXpub:Ua,checkPubkey:ju.makeChecker([])};Oa.globals=qu;const Xu={nonWitnessUtxo:Nu,partialSig:Uu,sighashType:Bu,finalScriptSig:Pu,finalScriptWitness:Ou,porCommitment:xu,witnessUtxo:Hu,bip32Derivation:Fu.makeConverter(Au.InputTypes.BIP32_DERIVATION),redeemScript:Vu.makeConverter(Au.InputTypes.REDEEM_SCRIPT),witnessScript:Wu.makeConverter(Au.InputTypes.WITNESS_SCRIPT),checkPubkey:ju.makeChecker([Au.InputTypes.PARTIAL_SIG,Au.InputTypes.BIP32_DERIVATION]),tapKeySig:Ru,tapScriptSig:Cu,tapLeafScript:Mu,tapBip32Derivation:Ku.makeConverter(Au.InputTypes.TAP_BIP32_DERIVATION),tapInternalKey:Gu.makeConverter(Au.InputTypes.TAP_INTERNAL_KEY),tapMerkleRoot:Lu};Oa.inputs=Xu;const zu={bip32Derivation:Fu.makeConverter(Au.OutputTypes.BIP32_DERIVATION),redeemScript:Vu.makeConverter(Au.OutputTypes.REDEEM_SCRIPT),witnessScript:Wu.makeConverter(Au.OutputTypes.WITNESS_SCRIPT),checkPubkey:ju.makeChecker([Au.OutputTypes.BIP32_DERIVATION]),tapBip32Derivation:Ku.makeConverter(Au.OutputTypes.TAP_BIP32_DERIVATION),tapTree:Du,tapInternalKey:Gu.makeConverter(Au.OutputTypes.TAP_INTERNAL_KEY)};Oa.outputs=zu,Object.defineProperty(Pa,"__esModule",{value:!0});const $u=Oa,Yu=iu,Ju=ou,Qu=Na;function Zu(e,r,n){if(!r.equals(t.from([n])))throw new Error(`Format Error: Invalid ${e} key: ${r.toString("hex")}`)}function ec(e,{globalMapKeyVals:t,inputKeyVals:r,outputKeyVals:n}){const i={unsignedTx:e};let o=0;for(const e of t)switch(e.key[0]){case Qu.GlobalTypes.UNSIGNED_TX:if(Zu("global",e.key,Qu.GlobalTypes.UNSIGNED_TX),o>0)throw new Error("Format Error: GlobalMap has multiple UNSIGNED_TX");o++;break;case Qu.GlobalTypes.GLOBAL_XPUB:void 0===i.globalXpub&&(i.globalXpub=[]),i.globalXpub.push($u.globals.globalXpub.decode(e));break;default:i.unknownKeyVals||(i.unknownKeyVals=[]),i.unknownKeyVals.push(e)}const s=r.length,a=n.length,u=[],c=[];for(const e of Yu.range(s)){const t={};for(const n of r[e])switch($u.inputs.checkPubkey(n),n.key[0]){case Qu.InputTypes.NON_WITNESS_UTXO:if(Zu("input",n.key,Qu.InputTypes.NON_WITNESS_UTXO),void 0!==t.nonWitnessUtxo)throw new Error("Format Error: Input has multiple NON_WITNESS_UTXO");t.nonWitnessUtxo=$u.inputs.nonWitnessUtxo.decode(n);break;case Qu.InputTypes.WITNESS_UTXO:if(Zu("input",n.key,Qu.InputTypes.WITNESS_UTXO),void 0!==t.witnessUtxo)throw new Error("Format Error: Input has multiple WITNESS_UTXO");t.witnessUtxo=$u.inputs.witnessUtxo.decode(n);break;case Qu.InputTypes.PARTIAL_SIG:void 0===t.partialSig&&(t.partialSig=[]),t.partialSig.push($u.inputs.partialSig.decode(n));break;case Qu.InputTypes.SIGHASH_TYPE:if(Zu("input",n.key,Qu.InputTypes.SIGHASH_TYPE),void 0!==t.sighashType)throw new Error("Format Error: Input has multiple SIGHASH_TYPE");t.sighashType=$u.inputs.sighashType.decode(n);break;case Qu.InputTypes.REDEEM_SCRIPT:if(Zu("input",n.key,Qu.InputTypes.REDEEM_SCRIPT),void 0!==t.redeemScript)throw new Error("Format Error: Input has multiple REDEEM_SCRIPT");t.redeemScript=$u.inputs.redeemScript.decode(n);break;case Qu.InputTypes.WITNESS_SCRIPT:if(Zu("input",n.key,Qu.InputTypes.WITNESS_SCRIPT),void 0!==t.witnessScript)throw new Error("Format Error: Input has multiple WITNESS_SCRIPT");t.witnessScript=$u.inputs.witnessScript.decode(n);break;case Qu.InputTypes.BIP32_DERIVATION:void 0===t.bip32Derivation&&(t.bip32Derivation=[]),t.bip32Derivation.push($u.inputs.bip32Derivation.decode(n));break;case Qu.InputTypes.FINAL_SCRIPTSIG:Zu("input",n.key,Qu.InputTypes.FINAL_SCRIPTSIG),t.finalScriptSig=$u.inputs.finalScriptSig.decode(n);break;case Qu.InputTypes.FINAL_SCRIPTWITNESS:Zu("input",n.key,Qu.InputTypes.FINAL_SCRIPTWITNESS),t.finalScriptWitness=$u.inputs.finalScriptWitness.decode(n);break;case Qu.InputTypes.POR_COMMITMENT:Zu("input",n.key,Qu.InputTypes.POR_COMMITMENT),t.porCommitment=$u.inputs.porCommitment.decode(n);break;case Qu.InputTypes.TAP_KEY_SIG:Zu("input",n.key,Qu.InputTypes.TAP_KEY_SIG),t.tapKeySig=$u.inputs.tapKeySig.decode(n);break;case Qu.InputTypes.TAP_SCRIPT_SIG:void 0===t.tapScriptSig&&(t.tapScriptSig=[]),t.tapScriptSig.push($u.inputs.tapScriptSig.decode(n));break;case Qu.InputTypes.TAP_LEAF_SCRIPT:void 0===t.tapLeafScript&&(t.tapLeafScript=[]),t.tapLeafScript.push($u.inputs.tapLeafScript.decode(n));break;case Qu.InputTypes.TAP_BIP32_DERIVATION:void 0===t.tapBip32Derivation&&(t.tapBip32Derivation=[]),t.tapBip32Derivation.push($u.inputs.tapBip32Derivation.decode(n));break;case Qu.InputTypes.TAP_INTERNAL_KEY:Zu("input",n.key,Qu.InputTypes.TAP_INTERNAL_KEY),t.tapInternalKey=$u.inputs.tapInternalKey.decode(n);break;case Qu.InputTypes.TAP_MERKLE_ROOT:Zu("input",n.key,Qu.InputTypes.TAP_MERKLE_ROOT),t.tapMerkleRoot=$u.inputs.tapMerkleRoot.decode(n);break;default:t.unknownKeyVals||(t.unknownKeyVals=[]),t.unknownKeyVals.push(n)}u.push(t)}for(const e of Yu.range(a)){const t={};for(const r of n[e])switch($u.outputs.checkPubkey(r),r.key[0]){case Qu.OutputTypes.REDEEM_SCRIPT:if(Zu("output",r.key,Qu.OutputTypes.REDEEM_SCRIPT),void 0!==t.redeemScript)throw new Error("Format Error: Output has multiple REDEEM_SCRIPT");t.redeemScript=$u.outputs.redeemScript.decode(r);break;case Qu.OutputTypes.WITNESS_SCRIPT:if(Zu("output",r.key,Qu.OutputTypes.WITNESS_SCRIPT),void 0!==t.witnessScript)throw new Error("Format Error: Output has multiple WITNESS_SCRIPT");t.witnessScript=$u.outputs.witnessScript.decode(r);break;case Qu.OutputTypes.BIP32_DERIVATION:void 0===t.bip32Derivation&&(t.bip32Derivation=[]),t.bip32Derivation.push($u.outputs.bip32Derivation.decode(r));break;case Qu.OutputTypes.TAP_INTERNAL_KEY:Zu("output",r.key,Qu.OutputTypes.TAP_INTERNAL_KEY),t.tapInternalKey=$u.outputs.tapInternalKey.decode(r);break;case Qu.OutputTypes.TAP_TREE:Zu("output",r.key,Qu.OutputTypes.TAP_TREE),t.tapTree=$u.outputs.tapTree.decode(r);break;case Qu.OutputTypes.TAP_BIP32_DERIVATION:void 0===t.tapBip32Derivation&&(t.tapBip32Derivation=[]),t.tapBip32Derivation.push($u.outputs.tapBip32Derivation.decode(r));break;default:t.unknownKeyVals||(t.unknownKeyVals=[]),t.unknownKeyVals.push(r)}c.push(t)}return{globalMap:i,inputs:u,outputs:c}}Pa.psbtFromBuffer=function(e,t){let r=0;function n(){const t=Ju.decode(e,r);r+=Ju.encodingLength(t);const n=e.slice(r,r+t);return r+=t,n}function i(){return{key:n(),value:n()}}function o(){if(r>=e.length)throw new Error("Format Error: Unexpected End of PSBT");const t=0===e.readUInt8(r);return t&&r++,t}if(1886610036!==function(){const t=e.readUInt32BE(r);return r+=4,t}())throw new Error("Format Error: Invalid Magic Number");if(255!==function(){const t=e.readUInt8(r);return r+=1,t}())throw new Error("Format Error: Magic Number must be followed by 0xff separator");const s=[],a={};for(;!o();){const e=i(),t=e.key.toString("hex");if(a[t])throw new Error("Format Error: Keys must be unique for global keymap: key "+t);a[t]=1,s.push(e)}const u=s.filter((e=>e.key[0]===Qu.GlobalTypes.UNSIGNED_TX));if(1!==u.length)throw new Error("Format Error: Only one UNSIGNED_TX allowed");const c=t(u[0].value),{inputCount:f,outputCount:h}=c.getInputOutputCounts(),p=[],l=[];for(const e of Yu.range(f)){const t={},r=[];for(;!o();){const n=i(),o=n.key.toString("hex");if(t[o])throw new Error("Format Error: Keys must be unique for each input: input index "+e+" key "+o);t[o]=1,r.push(n)}p.push(r)}for(const e of Yu.range(h)){const t={},r=[];for(;!o();){const n=i(),o=n.key.toString("hex");if(t[o])throw new Error("Format Error: Keys must be unique for each output: output index "+e+" key "+o);t[o]=1,r.push(n)}l.push(r)}return ec(c,{globalMapKeyVals:s,inputKeyVals:p,outputKeyVals:l})},Pa.checkKeyBuffer=Zu,Pa.psbtFromKeyVals=ec;var tc={};Object.defineProperty(tc,"__esModule",{value:!0});const rc=Oa,nc=iu;tc.psbtToBuffer=function({globalMap:e,inputs:r,outputs:n}){const{globalKeyVals:i,inputKeyVals:o,outputKeyVals:s}=sc({globalMap:e,inputs:r,outputs:n}),a=nc.keyValsToBuffer(i),u=e=>0===e.length?[t.from([0])]:e.map(nc.keyValsToBuffer),c=u(o),f=u(s),h=t.allocUnsafe(5);return h.writeUIntBE(482972169471,0,5),t.concat([h,a].concat(c,f))};const ic=(e,t)=>e.key.compare(t.key);function oc(e,t){const r=new Set,n=Object.entries(e).reduce(((e,[n,i])=>{if("unknownKeyVals"===n)return e;const o=t[n];if(void 0===o)return e;const s=(Array.isArray(i)?i:[i]).map(o.encode);return s.map((e=>e.key.toString("hex"))).forEach((e=>{if(r.has(e))throw new Error("Serialize Error: Duplicate key: "+e);r.add(e)})),e.concat(s)}),[]),i=e.unknownKeyVals?e.unknownKeyVals.filter((e=>!r.has(e.key.toString("hex")))):[];return n.concat(i).sort(ic)}function sc({globalMap:e,inputs:t,outputs:r}){return{globalKeyVals:oc(e,rc.globals),inputKeyVals:t.map((e=>oc(e,rc.inputs))),outputKeyVals:r.map((e=>oc(e,rc.outputs)))}}tc.psbtToKeyVals=sc,function(e){function t(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}Object.defineProperty(e,"__esModule",{value:!0}),t(Pa),t(tc)}(Aa),Object.defineProperty(ka,"__esModule",{value:!0});const ac=Aa;function uc(e,t,r){return n=>{if(e.has(n))return;const i=r.filter((e=>e.key.toString("hex")===n))[0];t.push(i),e.add(n)}}function cc(e){return e.globalMap.unsignedTx}function fc(e){const t=new Set;return e.forEach((e=>{const r=e.key.toString("hex");if(t.has(r))throw new Error("Combine: KeyValue Map keys should be unique");t.add(r)})),t}ka.combine=function(e){const t=e[0],r=ac.psbtToKeyVals(t),n=e.slice(1);if(0===n.length)throw new Error("Combine: Nothing to combine");const i=cc(t);if(void 0===i)throw new Error("Combine: Self missing transaction");const o=fc(r.globalKeyVals),s=r.inputKeyVals.map(fc),a=r.outputKeyVals.map(fc);for(const e of n){const t=cc(e);if(void 0===t||!t.toBuffer().equals(i.toBuffer()))throw new Error("Combine: One of the Psbts does not have the same transaction.");const n=ac.psbtToKeyVals(e);fc(n.globalKeyVals).forEach(uc(o,r.globalKeyVals,n.globalKeyVals));n.inputKeyVals.map(fc).forEach(((e,t)=>e.forEach(uc(s[t],r.inputKeyVals[t],n.inputKeyVals[t]))));n.outputKeyVals.map(fc).forEach(((e,t)=>e.forEach(uc(a[t],r.outputKeyVals[t],n.outputKeyVals[t]))))}return ac.psbtFromKeyVals(i,{globalMapKeyVals:r.globalKeyVals,inputKeyVals:r.inputKeyVals,outputKeyVals:r.outputKeyVals})};var hc={};!function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=Oa;function n(e,t){const r=e[t];if(void 0===r)throw new Error(`No input #${t}`);return r}function i(e,t){const r=e[t];if(void 0===r)throw new Error(`No output #${t}`);return r}function o(e,t,r,n){throw new Error(`Data for ${e} key ${t} is incorrect: Expected ${r} and got ${JSON.stringify(n)}`)}function s(e){return(r,n)=>{for(const i of Object.keys(r)){const s=r[i],{canAdd:a,canAddToArray:u,check:c,expected:f}=t[e+"s"][i]||{};if(c)if(!!u){if(!Array.isArray(s)||n[i]&&!Array.isArray(n[i]))throw new Error(`Key type ${i} must be an array`);s.every(c)||o(e,i,f,s);const t=n[i]||[],r=new Set;if(!s.every((e=>u(t,e,r))))throw new Error("Can not add duplicate data to array");n[i]=t.concat(s)}else{if(c(s)||o(e,i,f,s),!a(n,s))throw new Error(`Can not add duplicate data to ${e}`);n[i]=s}}}}e.checkForInput=n,e.checkForOutput=i,e.checkHasKey=function(e,t,r){if(e.key[0]<r)throw new Error("Use the method for your specific key instead of addUnknownKeyVal*");if(t&&0!==t.filter((t=>t.key.equals(e.key))).length)throw new Error(`Duplicate Key: ${e.key.toString("hex")}`)},e.getEnumLength=function(e){let t=0;return Object.keys(e).forEach((e=>{Number(isNaN(Number(e)))&&t++})),t},e.inputCheckUncleanFinalized=function(e,t){let r=!1;if(t.nonWitnessUtxo||t.witnessUtxo){const e=!!t.redeemScript,n=!!t.witnessScript,i=!e||!!t.finalScriptSig,o=!n||!!t.finalScriptWitness,s=!!t.finalScriptSig||!!t.finalScriptWitness;r=i&&o&&s}if(!1===r)throw new Error(`Input #${e} has too much or too little data to clean`)},e.updateGlobal=s("global"),e.updateInput=s("input"),e.updateOutput=s("output"),e.addInputAttributes=function(t,r){const i=n(t,t.length-1);e.updateInput(r,i)},e.addOutputAttributes=function(t,r){const n=i(t,t.length-1);e.updateOutput(r,n)},e.defaultVersionSetter=function(e,t){if(!r(t)||t.length<4)throw new Error("Set Version: Invalid Transaction");return t.writeUInt32LE(e,0),t},e.defaultLocktimeSetter=function(e,t){if(!r(t)||t.length<4)throw new Error("Set Locktime: Invalid Transaction");return t.writeUInt32LE(e,t.length-4),t}}(hc),Object.defineProperty(Ta,"__esModule",{value:!0});const pc=ka,lc=Aa,dc=Na,yc=hc;Ta.Psbt=class{constructor(e){this.inputs=[],this.outputs=[],this.globalMap={unsignedTx:e}}static fromBase64(e,r){const n=t.from(e,"base64");return this.fromBuffer(n,r)}static fromHex(e,r){const n=t.from(e,"hex");return this.fromBuffer(n,r)}static fromBuffer(e,t){const r=lc.psbtFromBuffer(e,t),n=new this(r.globalMap.unsignedTx);return Object.assign(n,r),n}toBase64(){return this.toBuffer().toString("base64")}toHex(){return this.toBuffer().toString("hex")}toBuffer(){return lc.psbtToBuffer(this)}updateGlobal(e){return yc.updateGlobal(e,this.globalMap),this}updateInput(e,t){const r=yc.checkForInput(this.inputs,e);return yc.updateInput(t,r),this}updateOutput(e,t){const r=yc.checkForOutput(this.outputs,e);return yc.updateOutput(t,r),this}addUnknownKeyValToGlobal(e){return yc.checkHasKey(e,this.globalMap.unknownKeyVals,yc.getEnumLength(dc.GlobalTypes)),this.globalMap.unknownKeyVals||(this.globalMap.unknownKeyVals=[]),this.globalMap.unknownKeyVals.push(e),this}addUnknownKeyValToInput(e,t){const r=yc.checkForInput(this.inputs,e);return yc.checkHasKey(t,r.unknownKeyVals,yc.getEnumLength(dc.InputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(t),this}addUnknownKeyValToOutput(e,t){const r=yc.checkForOutput(this.outputs,e);return yc.checkHasKey(t,r.unknownKeyVals,yc.getEnumLength(dc.OutputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(t),this}addInput(e){this.globalMap.unsignedTx.addInput(e),this.inputs.push({unknownKeyVals:[]});const t=e.unknownKeyVals||[],r=this.inputs.length-1;if(!Array.isArray(t))throw new Error("unknownKeyVals must be an Array");return t.forEach((e=>this.addUnknownKeyValToInput(r,e))),yc.addInputAttributes(this.inputs,e),this}addOutput(e){this.globalMap.unsignedTx.addOutput(e),this.outputs.push({unknownKeyVals:[]});const t=e.unknownKeyVals||[],r=this.outputs.length-1;if(!Array.isArray(t))throw new Error("unknownKeyVals must be an Array");return t.forEach((e=>this.addUnknownKeyValToOutput(r,e))),yc.addOutputAttributes(this.outputs,e),this}clearFinalizedInput(e){const t=yc.checkForInput(this.inputs,e);yc.inputCheckUncleanFinalized(e,t);for(const e of Object.keys(t))["witnessUtxo","nonWitnessUtxo","finalScriptSig","finalScriptWitness","unknownKeyVals"].includes(e)||delete t[e];return this}combine(...e){const t=pc.combine([this].concat(e));return Object.assign(this,t),this}getTransaction(){return this.globalMap.unsignedTx.toBuffer()}};var gc={},wc={};Object.defineProperty(wc,"__esModule",{value:!0}),wc.signatureBlocksAction=wc.checkInputForSig=wc.pubkeyInScript=wc.pubkeyPositionInScript=wc.witnessStackToScriptWitness=wc.isP2TR=wc.isP2SHScript=wc.isP2WSHScript=wc.isP2WPKH=wc.isP2PKH=wc.isP2PK=wc.isP2MS=void 0;const mc=ou,bc=mn,Ec=Zs,_c=Pi,vc=gn;function Sc(e){return t=>{try{return e({output:t}),!0}catch(e){return!1}}}function Ic(e,t){const r=(0,_c.hash160)(e),n=e.slice(1,33),i=bc.decompile(t);if(null===i)throw new Error("Unknown script error");return i.findIndex((t=>"number"!=typeof t&&(t.equals(e)||t.equals(r)||t.equals(n))))}function Tc(e,t,r){const{hashType:n}=t(e),i=[];n&Ec.Transaction.SIGHASH_ANYONECANPAY&&i.push("addInput");switch(31&n){case Ec.Transaction.SIGHASH_ALL:break;case Ec.Transaction.SIGHASH_SINGLE:case Ec.Transaction.SIGHASH_NONE:i.push("addOutput"),i.push("setInputSequence")}return-1===i.indexOf(r)}wc.isP2MS=Sc(vc.p2ms),wc.isP2PK=Sc(vc.p2pk),wc.isP2PKH=Sc(vc.p2pkh),wc.isP2WPKH=Sc(vc.p2wpkh),wc.isP2WSHScript=Sc(vc.p2wsh),wc.isP2SHScript=Sc(vc.p2sh),wc.isP2TR=Sc(vc.p2tr),wc.witnessStackToScriptWitness=function(e){let r=t.allocUnsafe(0);function n(e){const n=r.length,i=mc.encodingLength(e);r=t.concat([r,t.allocUnsafe(i)]),mc.encode(e,r,n)}function i(e){n(e.length),function(e){r=t.concat([r,t.from(e)])}(e)}var o;return n((o=e).length),o.forEach(i),r},wc.pubkeyPositionInScript=Ic,wc.pubkeyInScript=function(e,t){return-1!==Ic(e,t)},wc.checkInputForSig=function(e,t){return function(e){let t=[];if(0===(e.partialSig||[]).length){if(!e.finalScriptSig&&!e.finalScriptWitness)return[];t=function(e){const t=e.finalScriptSig&&bc.decompile(e.finalScriptSig)||[],n=e.finalScriptWitness&&bc.decompile(e.finalScriptWitness)||[];return t.concat(n).filter((e=>r(e)&&bc.isCanonicalScriptSignature(e))).map((e=>({signature:e})))}(e)}else t=e.partialSig;return t.map((e=>e.signature))}(e).some((e=>Tc(e,bc.signature.decode,t)))},wc.signatureBlocksAction=Tc,Object.defineProperty(gc,"__esModule",{value:!0}),gc.checkTaprootInputForSigs=gc.tapTreeFromList=gc.tapTreeToList=gc.tweakInternalPubKey=gc.checkTaprootOutputFields=gc.checkTaprootInputFields=gc.isTaprootOutput=gc.isTaprootInput=gc.serializeTaprootSignature=gc.tapScriptFinalizer=gc.toXOnly=void 0;const kc=Pn,Ac=Zs,Pc=wc,Oc=bs,Nc=gn,Uc=wc;function xc(e){return e&&!!(e.tapInternalKey||e.tapMerkleRoot||e.tapLeafScript&&e.tapLeafScript.length||e.tapBip32Derivation&&e.tapBip32Derivation.length||e.witnessUtxo&&(0,Pc.isP2TR)(e.witnessUtxo.script))}function Bc(e,t){return e&&!!(e.tapInternalKey||e.tapTree||e.tapBip32Derivation&&e.tapBip32Derivation.length||t&&(0,Pc.isP2TR)(t))}function Rc(e=[]){return 1===e.length&&0===e[0].depth?{output:e[0].script,version:e[0].leafVersion}:function(e){let t;for(const r of e)if(t=Cc(r,t),!t)throw new Error("No room left to insert tapleaf in tree");return t}(e)}function Mc(e){return{signature:e.slice(0,64),hashType:e.slice(64)[0]||Ac.Transaction.SIGHASH_DEFAULT}}function Lc(e,t=[],r=0){if(r>Oc.MAX_TAPTREE_DEPTH)throw new Error("Max taptree depth exceeded.");return e?(0,kc.isTapleaf)(e)?(t.push({depth:r,leafVersion:e.version||Oc.LEAF_VERSION_TAPSCRIPT,script:e.output}),t):(e[0]&&Lc(e[0],t,r+1),e[1]&&Lc(e[1],t,r+1),t):[]}function Cc(e,t,r=0){if(r>Oc.MAX_TAPTREE_DEPTH)throw new Error("Max taptree depth exceeded.");if(e.depth===r)return t?void 0:{output:e.script,version:e.leafVersion};if((0,kc.isTapleaf)(t))return;const n=Cc(e,t&&t[0],r+1);if(n)return[n,t&&t[1]];const i=Cc(e,t&&t[1],r+1);return i?[t&&t[0],i]:void 0}function Hc(e,t){if(!t)return!0;const r=(0,Oc.tapleafHash)({output:e.script,version:e.leafVersion});return(0,Oc.rootHashFromPath)(e.controlBlock,r).equals(t)}function Dc(e){return e&&!!(e.redeemScript||e.witnessScript||e.bip32Derivation&&e.bip32Derivation.length)}gc.toXOnly=e=>32===e.length?e:e.slice(1,33),gc.tapScriptFinalizer=function(e,t,r){const n=function(e,t,r){if(!e.tapScriptSig||!e.tapScriptSig.length)throw new Error(`Can not finalize taproot input #${t}. No tapleaf script signature provided.`);const n=(e.tapLeafScript||[]).sort(((e,t)=>e.controlBlock.length-t.controlBlock.length)).find((t=>function(e,t,r){const n=(0,Oc.tapleafHash)({output:e.script,version:e.leafVersion}),i=!r||r.equals(n);return i&&void 0!==t.find((e=>e.leafHash.equals(n)))}(t,e.tapScriptSig,r)));if(!n)throw new Error(`Can not finalize taproot input #${t}. Signature for tapleaf script not found.`);return n}(t,e,r);try{const e=function(e,t){const r=(0,Oc.tapleafHash)({output:t.script,version:t.leafVersion});return(e.tapScriptSig||[]).filter((e=>e.leafHash.equals(r))).map((e=>function(e,t){return Object.assign({positionInScript:(0,Pc.pubkeyPositionInScript)(t.pubkey,e)},t)}(t.script,e))).sort(((e,t)=>t.positionInScript-e.positionInScript)).map((e=>e.signature))}(t,n),r=e.concat(n.script).concat(n.controlBlock);return{finalScriptWitness:(0,Pc.witnessStackToScriptWitness)(r)}}catch(t){throw new Error(`Can not finalize taproot input #${e}: ${t}`)}},gc.serializeTaprootSignature=function(e,r){const n=r?t.from([r]):t.from([]);return t.concat([e,n])},gc.isTaprootInput=xc,gc.isTaprootOutput=Bc,gc.checkTaprootInputFields=function(e,t,r){!function(e,t,r){const n=xc(e)&&Dc(t),i=Dc(e)&&xc(t),o=e===t&&xc(t)&&Dc(t);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}(e,t,r),function(e,t,r){if(t.tapMerkleRoot){const n=(t.tapLeafScript||[]).every((e=>Hc(e,t.tapMerkleRoot))),i=(e.tapLeafScript||[]).every((e=>Hc(e,t.tapMerkleRoot)));if(!n||!i)throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}else if(e.tapMerkleRoot){if(!(t.tapLeafScript||[]).every((t=>Hc(t,e.tapMerkleRoot))))throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}}(e,t,r)},gc.checkTaprootOutputFields=function(e,t,r){!function(e,t,r){const n=Bc(e)&&Dc(t),i=Dc(e)&&Bc(t),o=e===t&&Bc(t)&&Dc(t);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}(e,t,r),function(e,t){if(!t.tapTree&&!t.tapInternalKey)return;const r=t.tapInternalKey||e.tapInternalKey,n=t.tapTree||e.tapTree;if(r){const{script:t}=e,i=function(e,t){const r=t&&Rc(t.leaves),{output:n}=(0,Nc.p2tr)({internalPubkey:e,scriptTree:r});return n}(r,n);if(t&&!t.equals(i))throw new Error("Error adding output. Script or address missmatch.")}}(e,t)},gc.tweakInternalPubKey=function(e,t){const r=t.tapInternalKey,n=r&&(0,Oc.tweakKey)(r,t.tapMerkleRoot);if(!n)throw new Error(`Cannot tweak tap internal key for input #${e}. Public key: ${r&&r.toString("hex")}`);return n.x},gc.tapTreeToList=function(e){if(!(0,kc.isTaptree)(e))throw new Error("Cannot convert taptree to tapleaf list. Expecting a tapree structure.");return Lc(e)},gc.tapTreeFromList=Rc,gc.checkTaprootInputForSigs=function(e,t){const r=function(e){const t=[];e.tapKeySig&&t.push(e.tapKeySig);e.tapScriptSig&&t.push(...e.tapScriptSig.map((e=>e.signature)));if(!t.length){const r=function(e){if(!e)return;const t=e.slice(2);if(64===t.length||65===t.length)return t}(e.finalScriptWitness);r&&t.push(r)}return t}(e);return r.some((e=>(0,Uc.signatureBlocksAction)(e,Mc,t)))},Object.defineProperty(Ia,"__esModule",{value:!0}),Ia.Psbt=void 0;const Fc=Ta,jc=ou,Vc=hc,Kc=dn,Gc=Es,Wc=gn,qc=bs,Xc=mn,zc=Zs,$c=gc,Yc=wc,Jc={network:yn.bitcoin,maximumFeeRate:5e3};class Qc{static fromBase64(e,r={}){const n=t.from(e,"base64");return this.fromBuffer(n,r)}static fromHex(e,r={}){const n=t.from(e,"hex");return this.fromBuffer(n,r)}static fromBuffer(e,t={}){const r=Fc.Psbt.fromBuffer(e,Zc),n=new Qc(t,r);var i,o;return i=n.__CACHE.__TX,o=n.__CACHE,i.ins.forEach((e=>{cf(o,e)})),n}constructor(e={},t=new Fc.Psbt(new ef)){this.data=t,this.opts=Object.assign({},Jc,e),this.__CACHE={__NON_WITNESS_UTXO_TX_CACHE:[],__NON_WITNESS_UTXO_BUF_CACHE:[],__TX_IN_CACHE:{},__TX:this.data.globalMap.unsignedTx.tx,__UNSAFE_SIGN_NONSEGWIT:!1},0===this.data.inputs.length&&this.setVersion(2);const r=(e,t,r,n)=>Object.defineProperty(e,t,{enumerable:r,writable:n});r(this,"__CACHE",!1,!0),r(this,"opts",!1,!0)}get inputCount(){return this.data.inputs.length}get version(){return this.__CACHE.__TX.version}set version(e){this.setVersion(e)}get locktime(){return this.__CACHE.__TX.locktime}set locktime(e){this.setLocktime(e)}get txInputs(){return this.__CACHE.__TX.ins.map((e=>({hash:(0,Gc.cloneBuffer)(e.hash),index:e.index,sequence:e.sequence})))}get txOutputs(){return this.__CACHE.__TX.outs.map((e=>{let t;try{t=(0,Kc.fromOutputScript)(e.script,this.opts.network)}catch(e){}return{script:(0,Gc.cloneBuffer)(e.script),value:e.value,address:t}}))}combine(...e){return this.data.combine(...e.map((e=>e.data))),this}clone(){const e=Qc.fromBuffer(this.data.toBuffer());return e.opts=JSON.parse(JSON.stringify(this.opts)),e}setMaximumFeeRate(e){sf(e),this.opts.maximumFeeRate=e}setVersion(e){sf(e),af(this.data.inputs,"setVersion");const t=this.__CACHE;return t.__TX.version=e,t.__EXTRACTED_TX=void 0,this}setLocktime(e){sf(e),af(this.data.inputs,"setLocktime");const t=this.__CACHE;return t.__TX.locktime=e,t.__EXTRACTED_TX=void 0,this}setInputSequence(e,t){sf(t),af(this.data.inputs,"setInputSequence");const r=this.__CACHE;if(r.__TX.ins.length<=e)throw new Error("Input index too high");return r.__TX.ins[e].sequence=t,r.__EXTRACTED_TX=void 0,this}addInputs(e){return e.forEach((e=>this.addInput(e))),this}addInput(e){if(arguments.length>1||!e||void 0===e.hash||void 0===e.index)throw new Error("Invalid arguments for Psbt.addInput. Requires single object with at least [hash] and [index]");(0,$c.checkTaprootInputFields)(e,e,"addInput"),af(this.data.inputs,"addInput"),e.witnessScript&&Nf(e.witnessScript);const t=this.__CACHE;this.data.addInput(e);cf(t,t.__TX.ins[t.__TX.ins.length-1]);const r=this.data.inputs.length-1,n=this.data.inputs[r];return n.nonWitnessUtxo&&Sf(this.__CACHE,n,r),t.__FEE=void 0,t.__FEE_RATE=void 0,t.__EXTRACTED_TX=void 0,this}addOutputs(e){return e.forEach((e=>this.addOutput(e))),this}addOutput(e){if(arguments.length>1||!e||void 0===e.value||void 0===e.address&&void 0===e.script)throw new Error("Invalid arguments for Psbt.addOutput. Requires single object with at least [script or address] and [value]");af(this.data.inputs,"addOutput");const{address:t}=e;if("string"==typeof t){const{network:r}=this.opts,n=(0,Kc.toOutputScript)(t,r);e=Object.assign(e,{script:n})}(0,$c.checkTaprootOutputFields)(e,e,"addOutput");const r=this.__CACHE;return this.data.addOutput(e),r.__FEE=void 0,r.__FEE_RATE=void 0,r.__EXTRACTED_TX=void 0,this}extractTransaction(e){if(!this.data.inputs.every(nf))throw new Error("Not finalized");const t=this.__CACHE;if(e||function(e,t,r){const n=t.__FEE_RATE||e.getFeeRate(),i=t.__EXTRACTED_TX.virtualSize(),o=n*i;if(n>=r.maximumFeeRate)throw new Error(`Warning: You are paying around ${(o/1e8).toFixed(8)} in fees, which is ${n} satoshi per byte for a transaction with a VSize of ${i} bytes (segwit counted as 0.25 byte per byte). Use setMaximumFeeRate method to raise your threshold, or pass true to the first arg of extractTransaction.`)}(this,t,this.opts),t.__EXTRACTED_TX)return t.__EXTRACTED_TX;const r=t.__TX.clone();return If(this.data.inputs,r,t,!0),r}getFeeRate(){return lf("__FEE_RATE","fee rate",this.data.inputs,this.__CACHE)}getFee(){return lf("__FEE","fee",this.data.inputs,this.__CACHE)}finalizeAllInputs(){return(0,Vc.checkForInput)(this.data.inputs,0),xf(this.data.inputs.length).forEach((e=>this.finalizeInput(e))),this}finalizeInput(e,t){const r=(0,Vc.checkForInput)(this.data.inputs,e);return(0,$c.isTaprootInput)(r)?this._finalizeTaprootInput(e,r,void 0,t):this._finalizeInput(e,r,t)}finalizeTaprootInput(e,t,r=$c.tapScriptFinalizer){const n=(0,Vc.checkForInput)(this.data.inputs,e);if((0,$c.isTaprootInput)(n))return this._finalizeTaprootInput(e,n,t,r);throw new Error(`Cannot finalize input #${e}. Not Taproot.`)}_finalizeInput(e,t,r=df){const{script:n,isP2SH:i,isP2WSH:o,isSegwit:s}=function(e,t,r){const n=r.__TX,i={script:null,isSegwit:!1,isP2SH:!1,isP2WSH:!1};if(i.isP2SH=!!t.redeemScript,i.isP2WSH=!!t.witnessScript,t.witnessScript)i.script=t.witnessScript;else if(t.redeemScript)i.script=t.redeemScript;else if(t.nonWitnessUtxo){const o=Tf(r,t,e),s=n.ins[e].index;i.script=o.outs[s].script}else t.witnessUtxo&&(i.script=t.witnessUtxo.script);(t.witnessScript||(0,Yc.isP2WPKH)(i.script))&&(i.isSegwit=!0);return i}(e,t,this.__CACHE);if(!n)throw new Error(`No script found for input #${e}`);!function(e){if(!e.sighashType||!e.partialSig)return;const{partialSig:t,sighashType:r}=e;t.forEach((e=>{const{hashType:t}=Xc.signature.decode(e.signature);if(r!==t)throw new Error("Signature sighash does not match input sighash type")}))}(t);const{finalScriptSig:a,finalScriptWitness:u}=r(e,t,n,s,i,o);if(a&&this.data.updateInput(e,{finalScriptSig:a}),u&&this.data.updateInput(e,{finalScriptWitness:u}),!a&&!u)throw new Error(`Unknown error finalizing input #${e}`);return this.data.clearFinalizedInput(e),this}_finalizeTaprootInput(e,t,r,n=$c.tapScriptFinalizer){if(!t.witnessUtxo)throw new Error(`Cannot finalize input #${e}. Missing withness utxo.`);if(t.tapKeySig){const r=Wc.p2tr({output:t.witnessUtxo.script,signature:t.tapKeySig}),n=(0,Yc.witnessStackToScriptWitness)(r.witness);this.data.updateInput(e,{finalScriptWitness:n})}else{const{finalScriptWitness:i}=n(e,t,r);this.data.updateInput(e,{finalScriptWitness:i})}return this.data.clearFinalizedInput(e),this}getInputType(e){const t=(0,Vc.checkForInput)(this.data.inputs,e),n=Of(kf(e,t,this.__CACHE),e,"input",t.redeemScript||function(e){if(!e)return;const t=Xc.decompile(e);if(!t)return;const n=t[t.length-1];if(!r(n)||Pf(n)||(i=n,Xc.isCanonicalScriptSignature(i)))return;var i;if(!Xc.decompile(n))return;return n}(t.finalScriptSig),t.witnessScript||function(e){if(!e)return;const t=vf(e),r=t[t.length-1];if(Pf(r))return;if(!Xc.decompile(r))return;return r}(t.finalScriptWitness));return("raw"===n.type?"":n.type+"-")+Uf(n.meaningfulScript)}inputHasPubkey(e,t){return function(e,t,r,n){const i=kf(r,t,n),{meaningfulScript:o}=Of(i,r,"input",t.redeemScript,t.witnessScript);return(0,Yc.pubkeyInScript)(e,o)}(t,(0,Vc.checkForInput)(this.data.inputs,e),e,this.__CACHE)}inputHasHDKey(e,t){const r=(0,Vc.checkForInput)(this.data.inputs,e),n=of(t);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}outputHasPubkey(e,t){return function(e,t,r,n){const i=n.__TX.outs[r].script,{meaningfulScript:o}=Of(i,r,"output",t.redeemScript,t.witnessScript);return(0,Yc.pubkeyInScript)(e,o)}(t,(0,Vc.checkForOutput)(this.data.outputs,e),e,this.__CACHE)}outputHasHDKey(e,t){const r=(0,Vc.checkForOutput)(this.data.outputs,e),n=of(t);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}validateSignaturesOfAllInputs(e){(0,Vc.checkForInput)(this.data.inputs,0);return xf(this.data.inputs.length).map((t=>this.validateSignaturesOfInput(t,e))).reduce(((e,t)=>!0===t&&e),!0)}validateSignaturesOfInput(e,t,r){const n=this.data.inputs[e];return(0,$c.isTaprootInput)(n)?this.validateSignaturesOfTaprootInput(e,t,r):this._validateSignaturesOfInput(e,t,r)}_validateSignaturesOfInput(e,t,r){const n=this.data.inputs[e],i=(n||{}).partialSig;if(!n||!i||i.length<1)throw new Error("No signatures to validate");if("function"!=typeof t)throw new Error("Need validator function to validate signatures");const o=r?i.filter((e=>e.pubkey.equals(r))):i;if(o.length<1)throw new Error("No signatures for this pubkey");const s=[];let a,u,c;for(const r of o){const i=Xc.signature.decode(r.signature),{hash:o,script:f}=c!==i.hashType?gf(e,Object.assign({},n,{sighashType:i.hashType}),this.__CACHE,!0):{hash:a,script:u};c=i.hashType,a=o,u=f,uf(r.pubkey,f,"verify"),s.push(t(r.pubkey,o,i.signature))}return s.every((e=>!0===e))}validateSignaturesOfTaprootInput(e,t,r){const n=this.data.inputs[e],i=(n||{}).tapKeySig,o=(n||{}).tapScriptSig;if(!n&&!i&&(!o||o.length))throw new Error("No signatures to validate");if("function"!=typeof t)throw new Error("Need validator function to validate signatures");const s=(r=r&&(0,$c.toXOnly)(r))?bf(e,n,this.data.inputs,r,this.__CACHE):function(e,t,r,n){const i=[];if(t.tapInternalKey){const r=wf(e,t,n);r&&i.push(r)}if(t.tapScriptSig){const e=t.tapScriptSig.map((e=>e.pubkey));i.push(...e)}const o=i.map((i=>bf(e,t,r,i,n)));return o.flat()}(e,n,this.data.inputs,this.__CACHE);if(!s.length)throw new Error("No signatures for this pubkey");const a=s.find((e=>!e.leafHash));let u=0;if(i&&a){if(!t(a.pubkey,a.hash,mf(i)))return!1;u++}if(o)for(const e of o){const r=s.find((t=>e.pubkey.equals(t.pubkey)));if(r){if(!t(e.pubkey,r.hash,mf(e.signature)))return!1;u++}}return u>0}signAllInputsHD(e,t=[zc.Transaction.SIGHASH_ALL]){if(!e||!e.publicKey||!e.fingerprint)throw new Error("Need HDSigner to sign input");const r=[];for(const n of xf(this.data.inputs.length))try{this.signInputHD(n,e,t),r.push(!0)}catch(e){r.push(!1)}if(r.every((e=>!1===e)))throw new Error("No inputs were signed");return this}signAllInputsHDAsync(e,t=[zc.Transaction.SIGHASH_ALL]){return new Promise(((r,n)=>{if(!e||!e.publicKey||!e.fingerprint)return n(new Error("Need HDSigner to sign input"));const i=[],o=[];for(const r of xf(this.data.inputs.length))o.push(this.signInputHDAsync(r,e,t).then((()=>{i.push(!0)}),(()=>{i.push(!1)})));return Promise.all(o).then((()=>{if(i.every((e=>!1===e)))return n(new Error("No inputs were signed"));r()}))}))}signInputHD(e,t,r=[zc.Transaction.SIGHASH_ALL]){if(!t||!t.publicKey||!t.fingerprint)throw new Error("Need HDSigner to sign input");return _f(e,this.data.inputs,t).forEach((t=>this.signInput(e,t,r))),this}signInputHDAsync(e,t,r=[zc.Transaction.SIGHASH_ALL]){return new Promise(((n,i)=>{if(!t||!t.publicKey||!t.fingerprint)return i(new Error("Need HDSigner to sign input"));const o=_f(e,this.data.inputs,t).map((t=>this.signInputAsync(e,t,r)));return Promise.all(o).then((()=>{n()})).catch(i)}))}signAllInputs(e,t){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");const r=[];for(const n of xf(this.data.inputs.length))try{this.signInput(n,e,t),r.push(!0)}catch(e){r.push(!1)}if(r.every((e=>!1===e)))throw new Error("No inputs were signed");return this}signAllInputsAsync(e,t){return new Promise(((r,n)=>{if(!e||!e.publicKey)return n(new Error("Need Signer to sign input"));const i=[],o=[];for(const[r]of this.data.inputs.entries())o.push(this.signInputAsync(r,e,t).then((()=>{i.push(!0)}),(()=>{i.push(!1)})));return Promise.all(o).then((()=>{if(i.every((e=>!1===e)))return n(new Error("No inputs were signed"));r()}))}))}signInput(e,t,r){if(!t||!t.publicKey)throw new Error("Need Signer to sign input");const n=(0,Vc.checkForInput)(this.data.inputs,e);return(0,$c.isTaprootInput)(n)?this._signTaprootInput(e,n,t,void 0,r):this._signInput(e,t,r)}signTaprootInput(e,t,r,n){if(!t||!t.publicKey)throw new Error("Need Signer to sign input");const i=(0,Vc.checkForInput)(this.data.inputs,e);if((0,$c.isTaprootInput)(i))return this._signTaprootInput(e,i,t,r,n);throw new Error(`Input #${e} is not of type Taproot.`)}_signInput(e,t,r=[zc.Transaction.SIGHASH_ALL]){const{hash:n,sighashType:i}=yf(this.data.inputs,e,t.publicKey,this.__CACHE,r),o=[{pubkey:t.publicKey,signature:Xc.signature.encode(t.sign(n),i)}];return this.data.updateInput(e,{partialSig:o}),this}_signTaprootInput(e,t,r,n,i=[zc.Transaction.SIGHASH_DEFAULT]){const o=this.checkTaprootHashesForSig(e,t,r,n,i),s=o.filter((e=>!e.leafHash)).map((e=>(0,$c.serializeTaprootSignature)(r.signSchnorr(e.hash),t.sighashType)))[0],a=o.filter((e=>!!e.leafHash)).map((e=>({pubkey:(0,$c.toXOnly)(r.publicKey),signature:(0,$c.serializeTaprootSignature)(r.signSchnorr(e.hash),t.sighashType),leafHash:e.leafHash})));return s&&this.data.updateInput(e,{tapKeySig:s}),a.length&&this.data.updateInput(e,{tapScriptSig:a}),this}signInputAsync(e,t,r){return Promise.resolve().then((()=>{if(!t||!t.publicKey)throw new Error("Need Signer to sign input");const n=(0,Vc.checkForInput)(this.data.inputs,e);return(0,$c.isTaprootInput)(n)?this._signTaprootInputAsync(e,n,t,void 0,r):this._signInputAsync(e,t,r)}))}signTaprootInputAsync(e,t,r,n){return Promise.resolve().then((()=>{if(!t||!t.publicKey)throw new Error("Need Signer to sign input");const i=(0,Vc.checkForInput)(this.data.inputs,e);if((0,$c.isTaprootInput)(i))return this._signTaprootInputAsync(e,i,t,r,n);throw new Error(`Input #${e} is not of type Taproot.`)}))}_signInputAsync(e,t,r=[zc.Transaction.SIGHASH_ALL]){const{hash:n,sighashType:i}=yf(this.data.inputs,e,t.publicKey,this.__CACHE,r);return Promise.resolve(t.sign(n)).then((r=>{const n=[{pubkey:t.publicKey,signature:Xc.signature.encode(r,i)}];this.data.updateInput(e,{partialSig:n})}))}async _signTaprootInputAsync(e,t,r,n,i=[zc.Transaction.SIGHASH_DEFAULT]){const o=this.checkTaprootHashesForSig(e,t,r,n,i),s=[],a=o.filter((e=>!e.leafHash))[0];if(a){const e=Promise.resolve(r.signSchnorr(a.hash)).then((e=>({tapKeySig:(0,$c.serializeTaprootSignature)(e,t.sighashType)})));s.push(e)}const u=o.filter((e=>!!e.leafHash));if(u.length){const e=u.map((e=>Promise.resolve(r.signSchnorr(e.hash)).then((n=>({tapScriptSig:[{pubkey:(0,$c.toXOnly)(r.publicKey),signature:(0,$c.serializeTaprootSignature)(n,t.sighashType),leafHash:e.leafHash}]})))));s.push(...e)}return Promise.all(s).then((t=>{t.forEach((t=>this.data.updateInput(e,t)))}))}checkTaprootHashesForSig(e,t,r,n,i){if("function"!=typeof r.signSchnorr)throw new Error(`Need Schnorr Signer to sign taproot input #${e}.`);const o=bf(e,t,this.data.inputs,r.publicKey,this.__CACHE,n,i);if(!o||!o.length)throw new Error(`Can not sign for input #${e} with the key ${r.publicKey.toString("hex")}`);return o}toBuffer(){return tf(this.__CACHE),this.data.toBuffer()}toHex(){return tf(this.__CACHE),this.data.toHex()}toBase64(){return tf(this.__CACHE),this.data.toBase64()}updateGlobal(e){return this.data.updateGlobal(e),this}updateInput(e,t){return t.witnessScript&&Nf(t.witnessScript),(0,$c.checkTaprootInputFields)(this.data.inputs[e],t,"updateInput"),this.data.updateInput(e,t),t.nonWitnessUtxo&&Sf(this.__CACHE,this.data.inputs[e],e),this}updateOutput(e,t){const r=this.data.outputs[e];return(0,$c.checkTaprootOutputFields)(r,t,"updateOutput"),this.data.updateOutput(e,t),this}addUnknownKeyValToGlobal(e){return this.data.addUnknownKeyValToGlobal(e),this}addUnknownKeyValToInput(e,t){return this.data.addUnknownKeyValToInput(e,t),this}addUnknownKeyValToOutput(e,t){return this.data.addUnknownKeyValToOutput(e,t),this}clearFinalizedInput(e){return this.data.clearFinalizedInput(e),this}}Ia.Psbt=Qc;const Zc=e=>new ef(e);class ef{constructor(e=t.from([2,0,0,0,0,0,0,0,0,0])){this.tx=zc.Transaction.fromBuffer(e),function(e){if(!e.ins.every((e=>e.script&&0===e.script.length&&e.witness&&0===e.witness.length)))throw new Error("Format Error: Transaction ScriptSigs are not empty")}(this.tx),Object.defineProperty(this,"tx",{enumerable:!1,writable:!0})}getInputOutputCounts(){return{inputCount:this.tx.ins.length,outputCount:this.tx.outs.length}}addInput(e){if(void 0===e.hash||void 0===e.index||!r(e.hash)&&"string"!=typeof e.hash||"number"!=typeof e.index)throw new Error("Error adding input.");const n="string"==typeof e.hash?(0,Gc.reverseBuffer)(t.from(e.hash,"hex")):e.hash;this.tx.addInput(n,e.index,e.sequence)}addOutput(e){if(void 0===e.script||void 0===e.value||!r(e.script)||"number"!=typeof e.value)throw new Error("Error adding output.");this.tx.addOutput(e.script,e.value)}toBuffer(){return this.tx.toBuffer()}}function tf(e){if(!1!==e.__UNSAFE_SIGN_NONSEGWIT)throw new Error("Not BIP174 compliant, can not export")}function rf(e,t,r){if(!t)return!1;let n;if(n=r?r.map((e=>{const r=function(e){if(65===e.length){const t=1&e[64],r=e.slice(0,33);return r[0]=2|t,r}return e.slice()}(e);return t.find((e=>e.pubkey.equals(r)))})).filter((e=>!!e)):t,n.length>e)throw new Error("Too many signatures");return n.length===e}function nf(e){return!!e.finalScriptSig||!!e.finalScriptWitness}function of(e){return t=>!!t.masterFingerprint.equals(e.fingerprint)&&!!e.derivePath(t.path).publicKey.equals(t.pubkey)}function sf(e){if("number"!=typeof e||e!==Math.floor(e)||e>4294967295||e<0)throw new Error("Invalid 32 bit integer")}function af(e,t){e.forEach((e=>{if((0,$c.isTaprootInput)(e)?(0,$c.checkTaprootInputForSigs)(e,t):(0,Yc.checkInputForSig)(e,t))throw new Error("Can not modify transaction, signatures exist.")}))}function uf(e,t,r){if(!(0,Yc.pubkeyInScript)(e,t))throw new Error(`Can not ${r} for this input with the key ${e.toString("hex")}`)}function cf(e,r){const n=(0,Gc.reverseBuffer)(t.from(r.hash)).toString("hex")+":"+r.index;if(e.__TX_IN_CACHE[n])throw new Error("Duplicate input detected.");e.__TX_IN_CACHE[n]=1}function ff(e,t){return(r,n,i,o)=>{const s=e({redeem:{output:i}}).output;if(!n.equals(s))throw new Error(`${t} for ${o} #${r} doesn't match the scriptPubKey in the prevout`)}}const hf=ff(Wc.p2sh,"Redeem script"),pf=ff(Wc.p2wsh,"Witness script");function lf(e,t,r,n){if(!r.every(nf))throw new Error(`PSBT must be finalized to calculate ${t}`);if("__FEE_RATE"===e&&n.__FEE_RATE)return n.__FEE_RATE;if("__FEE"===e&&n.__FEE)return n.__FEE;let i,o=!0;return n.__EXTRACTED_TX?(i=n.__EXTRACTED_TX,o=!1):i=n.__TX.clone(),If(r,i,n,o),"__FEE_RATE"===e?n.__FEE_RATE:"__FEE"===e?n.__FEE:void 0}function df(e,t,r,n,i,o){const s=Uf(r);if(!function(e,t,r){switch(r){case"pubkey":case"pubkeyhash":case"witnesspubkeyhash":return rf(1,e.partialSig);case"multisig":const r=Wc.p2ms({output:t});return rf(r.m,e.partialSig,r.pubkeys);default:return!1}}(t,r,s))throw new Error(`Can not finalize input #${e}`);return function(e,t,r,n,i,o){let s,a;const u=function(e,t,r){let n;switch(t){case"multisig":const t=function(e,t){const r=Wc.p2ms({output:e});return r.pubkeys.map((e=>(t.filter((t=>t.pubkey.equals(e)))[0]||{}).signature)).filter((e=>!!e))}(e,r);n=Wc.p2ms({output:e,signatures:t});break;case"pubkey":n=Wc.p2pk({output:e,signature:r[0].signature});break;case"pubkeyhash":n=Wc.p2pkh({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break;case"witnesspubkeyhash":n=Wc.p2wpkh({output:e,pubkey:r[0].pubkey,signature:r[0].signature})}return n}(e,t,r),c=o?Wc.p2wsh({redeem:u}):null,f=i?Wc.p2sh({redeem:c||u}):null;n?(a=c?(0,Yc.witnessStackToScriptWitness)(c.witness):(0,Yc.witnessStackToScriptWitness)(u.witness),f&&(s=f.input)):s=f?f.input:u.input;return{finalScriptSig:s,finalScriptWitness:a}}(r,s,t.partialSig,n,i,o)}function yf(e,t,r,n,i){const o=(0,Vc.checkForInput)(e,t),{hash:s,sighashType:a,script:u}=gf(t,o,n,!1,i);return uf(r,u,"sign"),{hash:s,sighashType:a}}function gf(e,t,r,n,i){const o=r.__TX,s=t.sighashType||zc.Transaction.SIGHASH_ALL;let a,u;if(Ef(s,i),t.nonWitnessUtxo){const n=Tf(r,t,e),i=o.ins[e].hash,s=n.getHash();if(!i.equals(s))throw new Error(`Non-witness UTXO hash for input #${e} doesn't match the hash specified in the prevout`);const a=o.ins[e].index;u=n.outs[a]}else{if(!t.witnessUtxo)throw new Error("Need a Utxo input item for signing");u=t.witnessUtxo}const{meaningfulScript:c,type:f}=Of(u.script,e,"input",t.redeemScript,t.witnessScript);if(["p2sh-p2wsh","p2wsh"].indexOf(f)>=0)a=o.hashForWitnessV0(e,c,u.value,s);else if((0,Yc.isP2WPKH)(c)){const t=Wc.p2pkh({hash:c.slice(2)}).output;a=o.hashForWitnessV0(e,t,u.value,s)}else{if(void 0===t.nonWitnessUtxo&&!1===r.__UNSAFE_SIGN_NONSEGWIT)throw new Error(`Input #${e} has witnessUtxo but non-segwit script: ${c.toString("hex")}`);n||!1===r.__UNSAFE_SIGN_NONSEGWIT||console.warn("Warning: Signing non-segwit inputs without the full parent transaction means there is a chance that a miner could feed you incorrect information to trick you into paying large fees. This behavior is the same as Psbt's predecesor (TransactionBuilder - now removed) when signing non-segwit scripts. You are not able to export this Psbt with toBuffer|toBase64|toHex since it is not BIP174 compliant.\n*********************\nPROCEED WITH CAUTION!\n*********************"),a=o.hashForSignature(e,c,s)}return{script:c,sighashType:s,hash:a}}function wf(e,t,r){const{script:n}=Af(e,t,r);return(0,Yc.isP2TR)(n)?n.subarray(2,34):null}function mf(e){return 64===e.length?e:e.subarray(0,64)}function bf(e,r,n,i,o,s,a){const u=o.__TX,c=r.sighashType||zc.Transaction.SIGHASH_DEFAULT;Ef(c,a);const f=n.map(((e,t)=>Af(t,e,o))),h=f.map((e=>e.script)),p=f.map((e=>e.value)),l=[];if(r.tapInternalKey&&!s){const n=wf(e,r,o)||t.from([]);if((0,$c.toXOnly)(i).equals(n)){const t=u.hashForWitnessV1(e,h,p,c);l.push({pubkey:i,hash:t})}}const d=(r.tapLeafScript||[]).filter((e=>(0,Yc.pubkeyInScript)(i,e.script))).map((e=>{const t=(0,qc.tapleafHash)({output:e.script,version:e.leafVersion});return Object.assign({hash:t},e)})).filter((e=>!s||s.equals(e.hash))).map((t=>{const r=u.hashForWitnessV1(e,h,p,zc.Transaction.SIGHASH_DEFAULT,t.hash);return{pubkey:i,hash:r,leafHash:t.hash}}));return l.concat(d)}function Ef(e,t){if(t&&t.indexOf(e)<0){const t=function(e){let t=e&zc.Transaction.SIGHASH_ANYONECANPAY?"SIGHASH_ANYONECANPAY | ":"";switch(31&e){case zc.Transaction.SIGHASH_ALL:t+="SIGHASH_ALL";break;case zc.Transaction.SIGHASH_SINGLE:t+="SIGHASH_SINGLE";break;case zc.Transaction.SIGHASH_NONE:t+="SIGHASH_NONE"}return t}(e);throw new Error(`Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ${t}`)}}function _f(e,t,r){const n=(0,Vc.checkForInput)(t,e);if(!n.bip32Derivation||0===n.bip32Derivation.length)throw new Error("Need bip32Derivation to sign with HD");const i=n.bip32Derivation.map((e=>e.masterFingerprint.equals(r.fingerprint)?e:void 0)).filter((e=>!!e));if(0===i.length)throw new Error("Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint");return i.map((e=>{const t=r.derivePath(e.path);if(!e.pubkey.equals(t.publicKey))throw new Error("pubkey did not match bip32Derivation");return t}))}function vf(e){let t=0;function r(){const r=jc.decode(e,t);return t+=jc.decode.bytes,r}function n(){return n=r(),t+=n,e.slice(t-n,t);var n}return function(){const e=r(),t=[];for(let r=0;r<e;r++)t.push(n());return t}()}function Sf(e,t,r){e.__NON_WITNESS_UTXO_BUF_CACHE[r]=t.nonWitnessUtxo;const n=zc.Transaction.fromBuffer(t.nonWitnessUtxo);e.__NON_WITNESS_UTXO_TX_CACHE[r]=n;const i=e,o=r;delete t.nonWitnessUtxo,Object.defineProperty(t,"nonWitnessUtxo",{enumerable:!0,get(){const e=i.__NON_WITNESS_UTXO_BUF_CACHE[o],t=i.__NON_WITNESS_UTXO_TX_CACHE[o];if(void 0!==e)return e;{const e=t.toBuffer();return i.__NON_WITNESS_UTXO_BUF_CACHE[o]=e,e}},set(e){i.__NON_WITNESS_UTXO_BUF_CACHE[o]=e}})}function If(e,t,r,n){let i=0;e.forEach(((e,o)=>{if(n&&e.finalScriptSig&&(t.ins[o].script=e.finalScriptSig),n&&e.finalScriptWitness&&(t.ins[o].witness=vf(e.finalScriptWitness)),e.witnessUtxo)i+=e.witnessUtxo.value;else if(e.nonWitnessUtxo){const n=Tf(r,e,o),s=t.ins[o].index,a=n.outs[s];i+=a.value}}));const o=t.outs.reduce(((e,t)=>e+t.value),0),s=i-o;if(s<0)throw new Error("Outputs are spending more than Inputs");const a=t.virtualSize();r.__FEE=s,r.__EXTRACTED_TX=t,r.__FEE_RATE=Math.floor(s/a)}function Tf(e,t,r){const n=e.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||Sf(e,t,r),n[r]}function kf(e,t,r){const{script:n}=Af(e,t,r);return n}function Af(e,t,r){if(void 0!==t.witnessUtxo)return{script:t.witnessUtxo.script,value:t.witnessUtxo.value};if(void 0!==t.nonWitnessUtxo){const n=Tf(r,t,e).outs[r.__TX.ins[e].index];return{script:n.script,value:n.value}}throw new Error("Can't find pubkey in input without Utxo data")}function Pf(e){return 33===e.length&&Xc.isCanonicalPubKey(e)}function Of(e,t,r,n,i){const o=(0,Yc.isP2SHScript)(e),s=o&&n&&(0,Yc.isP2WSHScript)(n),a=(0,Yc.isP2WSHScript)(e);if(o&&void 0===n)throw new Error("scriptPubkey is P2SH but redeemScript missing");if((a||s)&&void 0===i)throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");let u;return s?(u=i,hf(t,e,n,r),pf(t,n,i,r),Nf(u)):a?(u=i,pf(t,e,i,r),Nf(u)):o?(u=n,hf(t,e,n,r)):u=e,{meaningfulScript:u,type:s?"p2sh-p2wsh":o?"p2sh":a?"p2wsh":"raw"}}function Nf(e){if((0,Yc.isP2WPKH)(e)||(0,Yc.isP2SHScript)(e))throw new Error("P2WPKH or P2SH can not be contained within P2WSH")}function Uf(e){return(0,Yc.isP2WPKH)(e)?"witnesspubkeyhash":(0,Yc.isP2PKH)(e)?"pubkeyhash":(0,Yc.isP2MS)(e)?"multisig":(0,Yc.isP2PK)(e)?"pubkey":"nonstandard"}function xf(e){return[...Array(e).keys()]}!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.initEccLib=e.Transaction=e.opcodes=e.Psbt=e.Block=e.script=e.payments=e.networks=e.crypto=e.address=void 0;const t=dn;e.address=t;const r=Pi;e.crypto=r;const n=yn;e.networks=n;const i=gn;e.payments=i;const o=mn;e.script=o;var s=Js;Object.defineProperty(e,"Block",{enumerable:!0,get:function(){return s.Block}});var a=Ia;Object.defineProperty(e,"Psbt",{enumerable:!0,get:function(){return a.Psbt}});var u=En;Object.defineProperty(e,"opcodes",{enumerable:!0,get:function(){return u.OPS}});var c=Zs;Object.defineProperty(e,"Transaction",{enumerable:!0,get:function(){return c.Transaction}});var f=ds;Object.defineProperty(e,"initEccLib",{enumerable:!0,get:function(){return f.initEccLib}})}(ln);var Bf={exports:{}};!function(t){!function(){var r="input is invalid type",n="object"==typeof window,o=n?window:{};o.JS_SHA3_NO_WINDOW&&(n=!1);var s=!n&&"object"==typeof self;!o.JS_SHA3_NO_NODE_JS&&"object"==typeof i&&i.versions&&i.versions.node?o=e:s&&(o=self);var a=!o.JS_SHA3_NO_COMMON_JS&&t.exports,u=!o.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,c="0123456789abcdef".split(""),f=[4,1024,262144,67108864],h=[0,8,16,24],p=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],l=[224,256,384,512],d=[128,256],y=["hex","buffer","arrayBuffer","array","digest"],g={128:168,256:136};!o.JS_SHA3_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!u||!o.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});for(var w=function(e,t,r){return function(n){return new x(e,t,e).update(n)[r]()}},m=function(e,t,r){return function(n,i){return new x(e,t,i).update(n)[r]()}},b=function(e,t,r){return function(t,n,i,o){return I["cshake"+e].update(t,n,i,o)[r]()}},E=function(e,t,r){return function(t,n,i,o){return I["kmac"+e].update(t,n,i,o)[r]()}},_=function(e,t,r,n){for(var i=0;i<y.length;++i){var o=y[i];e[o]=t(r,n,o)}return e},v=function(e,t){var r=w(e,t,"hex");return r.create=function(){return new x(e,t,e)},r.update=function(e){return r.create().update(e)},_(r,w,e,t)},S=[{name:"keccak",padding:[1,256,65536,16777216],bits:l,createMethod:v},{name:"sha3",padding:[6,1536,393216,100663296],bits:l,createMethod:v},{name:"shake",padding:[31,7936,2031616,520093696],bits:d,createMethod:function(e,t){var r=m(e,t,"hex");return r.create=function(r){return new x(e,t,r)},r.update=function(e,t){return r.create(t).update(e)},_(r,m,e,t)}},{name:"cshake",padding:f,bits:d,createMethod:function(e,t){var r=g[e],n=b(e,0,"hex");return n.create=function(n,i,o){return i||o?new x(e,t,n).bytepad([i,o],r):I["shake"+e].create(n)},n.update=function(e,t,r,i){return n.create(t,r,i).update(e)},_(n,b,e,t)}},{name:"kmac",padding:f,bits:d,createMethod:function(e,t){var r=g[e],n=E(e,0,"hex");return n.create=function(n,i,o){return new B(e,t,i).bytepad(["KMAC",o],r).bytepad([n],r)},n.update=function(e,t,r,i){return n.create(e,r,i).update(t)},_(n,E,e,t)}}],I={},T=[],k=0;k<S.length;++k)for(var A=S[k],P=A.bits,O=0;O<P.length;++O){var N=A.name+"_"+P[O];if(T.push(N),I[N]=A.createMethod(P[O],A.padding),"sha3"!==A.name){var U=A.name+P[O];T.push(U),I[U]=I[N]}}function x(e,t,r){this.blocks=[],this.s=[],this.padding=t,this.outputBits=r,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(e<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}function B(e,t,r){x.call(this,e,t,r)}x.prototype.update=function(e){if(this.finalized)throw new Error("finalize already called");var t,n=typeof e;if("string"!==n){if("object"!==n)throw new Error(r);if(null===e)throw new Error(r);if(u&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||u&&ArrayBuffer.isView(e)))throw new Error(r);t=!0}for(var i,o,s=this.blocks,a=this.byteCount,c=e.length,f=this.blockCount,p=0,l=this.s;p<c;){if(this.reset)for(this.reset=!1,s[0]=this.block,i=1;i<f+1;++i)s[i]=0;if(t)for(i=this.start;p<c&&i<a;++p)s[i>>2]|=e[p]<<h[3&i++];else for(i=this.start;p<c&&i<a;++p)(o=e.charCodeAt(p))<128?s[i>>2]|=o<<h[3&i++]:o<2048?(s[i>>2]|=(192|o>>6)<<h[3&i++],s[i>>2]|=(128|63&o)<<h[3&i++]):o<55296||o>=57344?(s[i>>2]|=(224|o>>12)<<h[3&i++],s[i>>2]|=(128|o>>6&63)<<h[3&i++],s[i>>2]|=(128|63&o)<<h[3&i++]):(o=65536+((1023&o)<<10|1023&e.charCodeAt(++p)),s[i>>2]|=(240|o>>18)<<h[3&i++],s[i>>2]|=(128|o>>12&63)<<h[3&i++],s[i>>2]|=(128|o>>6&63)<<h[3&i++],s[i>>2]|=(128|63&o)<<h[3&i++]);if(this.lastByteIndex=i,i>=a){for(this.start=i-a,this.block=s[f],i=0;i<f;++i)l[i]^=s[i];R(l),this.reset=!0}else this.start=i}return this},x.prototype.encode=function(e,t){var r=255&e,n=1,i=[r];for(r=255&(e>>=8);r>0;)i.unshift(r),r=255&(e>>=8),++n;return t?i.push(n):i.unshift(n),this.update(i),i.length},x.prototype.encodeString=function(e){var t,n=typeof e;if("string"!==n){if("object"!==n)throw new Error(r);if(null===e)throw new Error(r);if(u&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||u&&ArrayBuffer.isView(e)))throw new Error(r);t=!0}var i=0,o=e.length;if(t)i=o;else for(var s=0;s<e.length;++s){var a=e.charCodeAt(s);a<128?i+=1:a<2048?i+=2:a<55296||a>=57344?i+=3:(a=65536+((1023&a)<<10|1023&e.charCodeAt(++s)),i+=4)}return i+=this.encode(8*i),this.update(e),i},x.prototype.bytepad=function(e,t){for(var r=this.encode(t),n=0;n<e.length;++n)r+=this.encodeString(e[n]);var i=t-r%t,o=[];return o.length=i,this.update(o),this},x.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex,r=this.blockCount,n=this.s;if(e[t>>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t<r+1;++t)e[t]=0;for(e[r-1]|=2147483648,t=0;t<r;++t)n[t]^=e[t];R(n)}},x.prototype.toString=x.prototype.hex=function(){this.finalize();for(var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,s=0,a="";s<n;){for(o=0;o<t&&s<n;++o,++s)e=r[o],a+=c[e>>4&15]+c[15&e]+c[e>>12&15]+c[e>>8&15]+c[e>>20&15]+c[e>>16&15]+c[e>>28&15]+c[e>>24&15];s%t==0&&(R(r),o=0)}return i&&(e=r[o],a+=c[e>>4&15]+c[15&e],i>1&&(a+=c[e>>12&15]+c[e>>8&15]),i>2&&(a+=c[e>>20&15]+c[e>>16&15])),a},x.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,s=0,a=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(a);for(var u=new Uint32Array(e);s<n;){for(o=0;o<t&&s<n;++o,++s)u[s]=r[o];s%t==0&&R(r)}return i&&(u[o]=r[o],e=e.slice(0,a)),e},x.prototype.buffer=x.prototype.arrayBuffer,x.prototype.digest=x.prototype.array=function(){this.finalize();for(var e,t,r=this.blockCount,n=this.s,i=this.outputBlocks,o=this.extraBytes,s=0,a=0,u=[];a<i;){for(s=0;s<r&&a<i;++s,++a)e=a<<2,t=n[s],u[e]=255&t,u[e+1]=t>>8&255,u[e+2]=t>>16&255,u[e+3]=t>>24&255;a%r==0&&R(n)}return o&&(e=a<<2,t=n[s],u[e]=255&t,o>1&&(u[e+1]=t>>8&255),o>2&&(u[e+2]=t>>16&255)),u},B.prototype=new x,B.prototype.finalize=function(){return this.encode(this.outputBits,!0),x.prototype.finalize.call(this)};var R=function(e){var t,r,n,i,o,s,a,u,c,f,h,l,d,y,g,w,m,b,E,_,v,S,I,T,k,A,P,O,N,U,x,B,R,M,L,C,H,D,F,j,V,K,G,W,q,X,z,$,Y,J,Q,Z,ee,te,re,ne,ie,oe,se,ae,ue,ce,fe;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],s=e[2]^e[12]^e[22]^e[32]^e[42],a=e[3]^e[13]^e[23]^e[33]^e[43],u=e[4]^e[14]^e[24]^e[34]^e[44],c=e[5]^e[15]^e[25]^e[35]^e[45],f=e[6]^e[16]^e[26]^e[36]^e[46],h=e[7]^e[17]^e[27]^e[37]^e[47],t=(l=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|a>>>31),r=(d=e[9]^e[19]^e[29]^e[39]^e[49])^(a<<1|s>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(u<<1|c>>>31),r=o^(c<<1|u>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=s^(f<<1|h>>>31),r=a^(h<<1|f>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=u^(l<<1|d>>>31),r=c^(d<<1|l>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=f^(i<<1|o>>>31),r=h^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,y=e[0],g=e[1],X=e[11]<<4|e[10]>>>28,z=e[10]<<4|e[11]>>>28,O=e[20]<<3|e[21]>>>29,N=e[21]<<3|e[20]>>>29,ae=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,K=e[40]<<18|e[41]>>>14,G=e[41]<<18|e[40]>>>14,M=e[2]<<1|e[3]>>>31,L=e[3]<<1|e[2]>>>31,w=e[13]<<12|e[12]>>>20,m=e[12]<<12|e[13]>>>20,$=e[22]<<10|e[23]>>>22,Y=e[23]<<10|e[22]>>>22,U=e[33]<<13|e[32]>>>19,x=e[32]<<13|e[33]>>>19,ce=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,C=e[14]<<6|e[15]>>>26,H=e[15]<<6|e[14]>>>26,b=e[25]<<11|e[24]>>>21,E=e[24]<<11|e[25]>>>21,J=e[34]<<15|e[35]>>>17,Q=e[35]<<15|e[34]>>>17,B=e[45]<<29|e[44]>>>3,R=e[44]<<29|e[45]>>>3,T=e[6]<<28|e[7]>>>4,k=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,F=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,v=e[37]<<21|e[36]>>>11,Z=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,W=e[8]<<27|e[9]>>>5,q=e[9]<<27|e[8]>>>5,A=e[18]<<20|e[19]>>>12,P=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,se=e[28]<<7|e[29]>>>25,j=e[38]<<8|e[39]>>>24,V=e[39]<<8|e[38]>>>24,S=e[48]<<14|e[49]>>>18,I=e[49]<<14|e[48]>>>18,e[0]=y^~w&b,e[1]=g^~m&E,e[10]=T^~A&O,e[11]=k^~P&N,e[20]=M^~C&D,e[21]=L^~H&F,e[30]=W^~X&$,e[31]=q^~z&Y,e[40]=te^~ne&oe,e[41]=re^~ie&se,e[2]=w^~b&_,e[3]=m^~E&v,e[12]=A^~O&U,e[13]=P^~N&x,e[22]=C^~D&j,e[23]=H^~F&V,e[32]=X^~$&J,e[33]=z^~Y&Q,e[42]=ne^~oe&ae,e[43]=ie^~se&ue,e[4]=b^~_&S,e[5]=E^~v&I,e[14]=O^~U&B,e[15]=N^~x&R,e[24]=D^~j&K,e[25]=F^~V&G,e[34]=$^~J&Z,e[35]=Y^~Q&ee,e[44]=oe^~ae&ce,e[45]=se^~ue&fe,e[6]=_^~S&y,e[7]=v^~I&g,e[16]=U^~B&T,e[17]=x^~R&k,e[26]=j^~K&M,e[27]=V^~G&L,e[36]=J^~Z&W,e[37]=Q^~ee&q,e[46]=ae^~ce&te,e[47]=ue^~fe&re,e[8]=S^~y&w,e[9]=I^~g&m,e[18]=B^~T&A,e[19]=R^~k&P,e[28]=K^~M&C,e[29]=G^~L&H,e[38]=Z^~W&X,e[39]=ee^~q&z,e[48]=ce^~te&ne,e[49]=fe^~re&ie,e[0]^=p[n],e[1]^=p[n+1]};if(a)t.exports=I;else for(k=0;k<T.length;++k)o[T[k]]=I[T[k]]}()}(Bf);var Rf=Bf.exports;var Mf=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(s,a)}u((n=n.apply(e,t||[])).next())}))};function Lf(e,r){return Mf(this,void 0,void 0,(function*(){let n;var i;"publicKeyJwk"in e?n=pn(e.publicKeyJwk):"publicKeyMultibase"in e&&(n=yield(i=e,fn(void 0,void 0,void 0,(function*(){const e=yield T({keyPair:i});return pn(e)}))));const o=on("errors","identityErrorBaseMessage");let s="";switch(r.code){case h.Bitcoin:case h.Mocknet:case h.Testnet:s=function(e,t){return ln.payments.p2pkh({pubkey:e,network:ln.networks[t.code]}).address}(n,r);break;case h.Ethmain:case h.Ethropst:case h.Ethrinkeby:case h.Ethgoerli:case h.Ethsepolia:s=function(e){const r=e.toString("hex"),n=new _.ec("secp256k1").keyFromPublic(r,"hex").getPublic().encode("hex").slice(2),i=t;return`0x${Rf.keccak256(i.from(n,"hex")).slice(24).toString()}`}(n);break;default:throw new tn("deriveIssuingAddressFromPublicKey",`${o} - ${on("errors","deriveIssuingAddressFromPublicKey")}`)}return s}))}function Cf(e){if(e){const t="string"==typeof e?e:e.code;return!!Object.keys(p).some((e=>e===t))&&!!p[t].test}return!1}var Hf=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(s,a)}u((n=n.apply(e,t||[])).next())}))};const{LinkedDataProof:Df}=v.suites;class Ff extends Df{constructor({issuer:e=null,verificationMethod:t=null,document:r=null,proof:n=null,options:i={}}){if(super({type:"MerkleProof2019"}),this.type="MerkleProof2019",this.issuer=null,this.verificationMethod=null,this.proof=null,this.proofValue=null,this.document=null,this.explorerAPIs=[],this.documentLoader=null,this.proofVerificationProcess=["getTransactionId","computeLocalHash","fetchRemoteHash","compareHashes","checkMerkleRoot","checkReceipt"],this.identityVerificationProcess=["deriveIssuingAddressFromPublicKey","compareIssuingAddress"],this.transactionId="",!r)throw new Error("A document signed by MerkleProof2019 is required for the verification process.");this.issuer=e,this.verificationMethod=t,this.document=r,this.setProof(n),this.setOptions(i),this.getChain(),Cf(this.chain)&&(this.adaptProofVerificationProcessToMocknet(),this.adaptIdentityVerificationProcessToMocknet())}static decodeMerkleProof2019(e){return new qr.Decoder(e.proofValue).decode()}setProof(e=null){const t=null!=e?e:this.document.proof;if(!t)throw new Error("The passed document is not signed.");this.proof=t,this.proofValue=Ff.decodeMerkleProof2019(this.proof)}verifyProof(){return Hf(this,arguments,void 0,(function*({documentLoader:e,verifyIdentity:t}={documentLoader:e=>{},verifyIdentity:!0}){let r;this.documentLoader=e;let n="";try{yield this.verifyProcess(this.proofVerificationProcess),t&&(yield this.verifyIdentity()),r=!0}catch(e){console.error(e),r=!1,n=e.message}return{verificationMethod:this.verificationMethod,verified:r,error:n}}))}verifyIdentity(){return Hf(this,void 0,void 0,(function*(){if(null!=this.verificationMethod)try{yield this.verifyProcess(this.identityVerificationProcess)}catch(e){throw new Error(e)}}))}getProofVerificationProcess(){return this.proofVerificationProcess}getIdentityVerificationProcess(){return this.identityVerificationProcess}getIssuerPublicKey(){var e,t;return Cf(this.chain)?"This mock chain does not support issuing addresses":null!==(t=null===(e=this.getTxData())||void 0===e?void 0:e.issuingAddress)&&void 0!==t?t:""}getIssuanceTime(){var e,t;return null!==(t=null===(e=this.getTxData())||void 0===e?void 0:e.time)&&void 0!==t?t:""}getChain(){return this.chain||(this.chain=zr(this.proofValue)),this.chain}getTxData(){return this.txData?this.txData:(console.error("Trying to access issuing address when txData not available yet. Did you run the `verify` method yet?"),null)}adaptProofVerificationProcessToMocknet(){$r(this.proofVerificationProcess,"getTransactionId"),$r(this.proofVerificationProcess,"fetchRemoteHash"),$r(this.proofVerificationProcess,"checkMerkleRoot")}adaptIdentityVerificationProcessToMocknet(){this.identityVerificationProcess=[]}setOptions(e){var t;this.explorerAPIs=null!==(t=e.explorerAPIs)&&void 0!==t?t:[],e.executeStepMethod&&"function"==typeof e.executeStepMethod&&(this.executeStep=e.executeStepMethod)}executeStep(e,t){return Hf(this,arguments,void 0,(function*(e,t,r=""){return yield t()}))}verifyProcess(e){return Hf(this,void 0,void 0,(function*(){for(const t of e){if(!this[t])return void console.error("verification logic for",t,"not implemented");yield this[t]()}}))}checkMerkleRoot(){return Hf(this,void 0,void 0,(function*(){yield this.executeStep("checkMerkleRoot",(()=>function(e,t){if(e!==t)throw new tn("checkMerkleRoot",on("errors","ensureMerkleRootEqual"));return!0}(this.proofValue.merkleRoot,this.txData.remoteHash)),this.type)}))}compareHashes(){return Hf(this,void 0,void 0,(function*(){yield this.executeStep("compareHashes",(()=>function(e,t){if(e!==t)throw new tn("compareHashes",on("errors","ensureHashesEqual"));return!0}(this.localDocumentHash,this.proofValue.targetHash)),this.type)}))}computeLocalHash(){return Hf(this,void 0,void 0,(function*(){this.localDocumentHash=yield this.executeStep("computeLocalHash",(()=>Hf(this,void 0,void 0,(function*(){return yield an(this.document,this.proof,this.documentLoader)}))),this.type)}))}checkReceipt(){return Hf(this,void 0,void 0,(function*(){yield this.executeStep("checkReceipt",(()=>{!function(e){let t=e.targetHash;const r=e.merkleRoot;try{const r=e.path;if(r&&t)for(const e in r){const n=r[e];let i;if(void 0!==n.left)i=en(`${n.left}${t}`),t=I(i);else{if(void 0===n.right)throw new tn("checkReceipt","Trigger catch error.");i=en(`${t}${n.right}`),t=I(i)}}}catch(e){throw new tn("checkReceipt",on("errors","ensureValidReceipt"))}if(t!==r)throw new tn("checkReceipt",on("errors","invalidMerkleReceipt"))}(this.proofValue)}),this.type)}))}getTransactionId(){return Hf(this,void 0,void 0,(function*(){this.transactionId=function(e=null){if(!e)throw new Error("DecodedProof is not set");const{anchors:t}=e,r=t[0];if("string"==typeof r)return r.split(":").pop();throw new Error("Could not retrieve transaction id as was provided an unexpected format")}(this.proofValue);return yield this.executeStep("getTransactionId",(()=>function(e){if("string"==typeof e&&e.length>0)return e;throw new tn("getTransactionId",on("errors","isTransactionIdValid"))}(this.transactionId)),this.type)}))}fetchRemoteHash(){return Hf(this,void 0,void 0,(function*(){this.txData=yield this.executeStep("fetchRemoteHash",(()=>Hf(this,void 0,void 0,(function*(){var e;return yield f({transactionId:this.transactionId,chain:null===(e=this.chain)||void 0===e?void 0:e.code,explorerAPIs:this.explorerAPIs})}))),this.type)}))}deriveIssuingAddressFromPublicKey(){return Hf(this,void 0,void 0,(function*(){this.derivedIssuingAddress=yield this.executeStep("deriveIssuingAddressFromPublicKey",(()=>Hf(this,void 0,void 0,(function*(){return yield Lf(this.verificationMethod,this.chain)}))),this.type)}))}compareIssuingAddress(){return Hf(this,void 0,void 0,(function*(){yield this.executeStep("compareIssuingAddress",(()=>{!function(e,t){const r=on("errors","identityErrorBaseMessage");if(e.toLowerCase()!==t.toLowerCase())throw new tn("compareIssuingAddress",`${r} - ${on("errors","compareIssuingAddress")}`)}(this.getIssuerPublicKey(),this.derivedIssuingAddress)}),this.type)}))}}var jf;function Vf(e){return Ff.decodeMerkleProof2019(e)}!function(e){e.getTransactionId="getTransactionId",e.computeLocalHash="computeLocalHash",e.fetchRemoteHash="fetchRemoteHash",e.parseIssuerKeys="parseIssuerKeys",e.compareHashes="compareHashes",e.checkImagesIntegrity="checkImagesIntegrity",e.checkMerkleRoot="checkMerkleRoot",e.checkReceipt="checkReceipt",e.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",e.deriveIssuingAddressFromPublicKey="deriveIssuingAddressFromPublicKey",e.compareIssuingAddress="compareIssuingAddress",e.checkAuthenticity="checkAuthenticity"}(jf||(jf={}));class Kf extends P{proofVerificationProcess=[jf.parseIssuerKeys,jf.checkAuthenticity];transactionId;localHash;documentToVerify;txData;chain;explorerAPIs;receipt;issuerPublicKeyList;issuer;verificationMethodPublicKey;derivedIssuingAddress;hasDid;proof;type="MerkleProof2019";cryptosuite="merkle-proof-2019";suite;constructor(e){super(e),this.executeStep=e.executeStep,this.documentToVerify=e.document,this.explorerAPIs=e.explorerAPIs,this.proof=e.proof,this.issuer=e.issuer,this.validateProofType(),this.receipt=Vf(this.proof),this.transactionId=o.certificates.getTransactionId(this.receipt),this.setHasDid()}async init(){await this.setVerificationSuite(),this.chain=this.suite.getChain(),this.adaptVerificationProcessToChain()}async verifyProof(){await this.suite.verifyProof({verifyIdentity:!1}),await this.verifyProcess(this.proofVerificationProcess)}async verifyIdentity(){await this.suite.verifyIdentity()}getProofVerificationSteps(e){return[...this.suite.getProofVerificationProcess(),...this.proofVerificationProcess].map((t=>o.verifier.convertToVerificationSubsteps(e,t)))}getIdentityVerificationSteps(e){return this.hasDid?this.suite.getIdentityVerificationProcess().map((t=>o.verifier.convertToVerificationSubsteps(e,t))):[]}getIssuerPublicKey(){return this.suite.getIssuerPublicKey()}getIssuanceTime(){return this.suite.getIssuanceTime()}getIssuerName(){return this.issuer.name}getIssuerProfileDomain(){const e=new URL(this.getIssuerProfileUrl());return e?.hostname}getIssuerProfileUrl(){return this.issuer.id}getSigningDate(){return this.proof.created}getChain(){return this.suite.getChain()}getReceipt(){return this.receipt}getTransactionIdString(){return o.certificates.getTransactionId(this.getReceipt())}getTransactionLink(){return o.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).transactionLink}getRawTransactionLink(){return o.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).rawTransactionLink}async executeStep(e,t,r){throw new Error("executeStep method needs to be overwritten by injecting from Verifier")}async setVerificationSuite(){await this.setIssuerFromProofVerificationMethod(),this.verificationMethodPublicKey=A(this.getTargetVerificationMethodContainer(),s(this.proof)),this.suite=new Ff({document:this.documentToVerify,proof:this.proof,verificationMethod:this.verificationMethodPublicKey,options:{explorerAPIs:this.explorerAPIs,executeStepMethod:this.executeStep}})}adaptVerificationProcessToChain(){o.chains.isMockChain(this.chain)&&(a(this.proofVerificationProcess,jf.parseIssuerKeys),a(this.proofVerificationProcess,jf.checkAuthenticity))}getTargetVerificationMethodContainer(){return this.issuer.didDocument??this.issuer}isProofChain(){return"ChainedProof2021"===this.proof.type}isMultipleProof(){return Array.isArray(this.documentToVerify.proof)}getProofIndex(){return this.isMultipleProof()?this.documentToVerify.proof.findIndex((e=>e.proofValue===this.proof.proofValue)):-1}async setIssuerFromProofVerificationMethod(){if(this.getProofIndex()>0){const e=this.proof.verificationMethod.split("#")[0];this.issuer=await o.verifier.getIssuerProfile(e)}}setHasDid(){if(this.getProofIndex()>0){const e=this.proof.verificationMethod.split("#")[0];this.hasDid=u(e)}else this.hasDid=!!this.issuer.didDocument}validateProofType(){const e=this.isProofChain()?this.proof.chainedProofType:this.proof.type;if("DataIntegrityProof"!==e){if(e!==this.type)throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${e}`)}else{const e=this.proof.cryptosuite;if(!e)throw new Error(`Malformed proof passed. With DataIntegrityProof a cryptosuite must be defined. Expected: ${this.cryptosuite}`);if(e!==this.cryptosuite)throw new Error(`Incompatible proof cryptosuite passed. Expected: ${this.cryptosuite}, Got: ${e}`)}}async verifyProcess(e){for(const t of e){if(!this[t])return void console.error("verification logic for",t,"not implemented");await this[t]()}}async parseIssuerKeys(){this.issuerPublicKeyList=await this.executeStep(jf.parseIssuerKeys,(()=>o.verifier.parseIssuerKeys(this.issuer)),this.type)}async checkAuthenticity(){await this.executeStep(jf.checkAuthenticity,(()=>{k(this.issuerPublicKeyList,this.getIssuerPublicKey(),this.getIssuanceTime())}),this.type)}}export{Kf as default,Vf as parseReceipt};
|