@blockcerts/blockcerts-verifier 1.61.0 → 1.62.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/{EcdsaSecp256k1Signature2019-Z9cbZqwb-BZqYyWXC.js → EcdsaSecp256k1Signature2019-aV3C41Ue-_mP0Wq_n.js} +2 -2
- package/dist/{Ed25519Signature2020-gHlOabgN-BQNMKhh-.js → Ed25519Signature2020-CL2yKnJW-NRYSGvkI.js} +5 -5
- package/dist/{HashlinkVerifier-JKby3RuX-Bn4E9EeP.js → HashlinkVerifier-MEwSZe4T-BdYYAALa.js} +1 -1
- package/dist/{MerkleProof2017-qKpIAsVw-Diu6ftp6.js → MerkleProof2017-CNSx436a-FBaGRIN1.js} +1 -1
- package/dist/{MerkleProof2019-lYqSLW83-CdVVDNe8.js → MerkleProof2019-DnbP3r0f-Cp4GWjQh.js} +1 -1
- package/dist/{checkCredentialSchemaConformity-wYKX-T36-TKejNdGn.js → checkCredentialSchemaConformity-QPmIWPLG-De1kKyvF.js} +1 -1
- package/dist/{checkRevocationStatusList2021-Zs7RTfS8-B_SBTuUQ.js → checkRevocationStatusList2021-Cy-rWyh7-CVOeAbdp.js} +1 -1
- package/dist/controlVerificationMethod-CXzAI0QS-b45qIaR4.js +1 -0
- package/dist/{did-key-common.esm-pD02457t-BaQe2n2J.js → did-key-common.esm-CJj7pea6-Er8YwHoJ.js} +3 -3
- package/dist/{did-key-ed25519.esm-QkrYsBOv-KuYPtNeV.js → did-key-ed25519.esm-hEATvNhJ-CHAq7sf1.js} +1 -1
- package/dist/{did-key-secp256k1.esm-byA8GFc3-AosubhwX.js → did-key-secp256k1.esm-CIEM56eq-EQahxyFZ.js} +1 -1
- package/dist/{index-zUaES8qy-CMAhMZvu.js → index-DWAZG7Ja-CBt_boC3.js} +2 -2
- package/dist/{jsonld-signatures-Lb-laFSH-v4kRGxlk.js → jsonld-signatures-zDEkNjYR-D3vK8GYH.js} +7 -7
- package/dist/main.js +42 -32
- package/dist/{x25519-axOdeC_8-BeczdkXC.js → x25519-BzvT3haI-DcUk09rC.js} +1 -1
- package/package.json +2 -2
- package/dist/controlVerificationMethod-MnvnHDi1-BAzkUIZW.js +0 -1
- /package/dist/{Suite-Bhitn5l3-D1ucdMDB.js → Suite-B7Vy9AuU-D1ucdMDB.js} +0 -0
- /package/dist/{_commonjs-dynamic-modules-F7P8sER7-BHR_E30J.js → _commonjs-dynamic-modules-COweQ1RR-BHR_E30J.js} +0 -0
- /package/dist/{base64url-qi3FT6uz-vkTPfQOh.js → base64url-Cy03LJLt-vkTPfQOh.js} +0 -0
- /package/dist/{elliptic-ycTr8sXF-D-NH8siB.js → elliptic-DVE5q-l5-D-NH8siB.js} +0 -0
- /package/dist/{ensureNotRevoked-EDQJmT-v-DvMIgM4L.js → ensureNotRevoked-bD_ITwQb-DvMIgM4L.js} +0 -0
- /package/dist/{ensureValidIssuingKey-_gUzjB7e-frafTbMl.js → ensureValidIssuingKey-wRebznsK-frafTbMl.js} +0 -0
- /package/dist/{index-tKimblBp-Dgus2xdV.js → index-CcA_A5fd-Dgus2xdV.js} +0 -0
- /package/dist/{index-CZOUZnn4-ZifknGWx.js → index-DUjMpuQT-ZifknGWx.js} +0 -0
- /package/dist/{index-qAZ-fmOX-CHN5LgUq.js → index-yP42zfkJ-CHN5LgUq.js} +0 -0
- /package/dist/{jsonld-8ujMRGin-D_C9ciG_.js → jsonld-Pr6hPH-i-D_C9ciG_.js} +0 -0
- /package/dist/{pako.esm-jjCKMBM4-HambcU-w.js → pako.esm-DnD5dZGi-HambcU-w.js} +0 -0
- /package/dist/{sha256-OznnmV9J-BYFBxJ7m.js → sha256-wKiO0px2-BYFBxJ7m.js} +0 -0
- /package/dist/{tslib.es6-M1zqH4el-CmLYFWVC.js → tslib.es6-CNEFicEt-CmLYFWVC.js} +0 -0
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as e,B as t,i as r,p as n,d as i,j as o,r as s,k as a,l as u,h as c,m as f,S as h,n as p}from"./main.js";import{s as l}from"./index-qAZ-fmOX-CHN5LgUq.js";import{s as d,r as y,a as g,b as w,k as m,c as b,d as E}from"./index-zUaES8qy-CMAhMZvu.js";import{r as _,e as v}from"./elliptic-ycTr8sXF-D-NH8siB.js";import{j as S}from"./jsonld-signatures-Lb-laFSH-v4kRGxlk.js";import{j as I}from"./jsonld-8ujMRGin-D_C9ciG_.js";import{s as T}from"./sha256-OznnmV9J-BYFBxJ7m.js";import"./pako.esm-jjCKMBM4-HambcU-w.js";import{e as k}from"./ensureValidIssuingKey-_gUzjB7e-frafTbMl.js";import"./index-tKimblBp-Dgus2xdV.js";import{S as A}from"./Suite-Bhitn5l3-D1ucdMDB.js";const P={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:O}=l;var N={validate:O(P)};var U,x={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}}}},B={},R={exports:{}};U=R,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,L=21,M=-1e7,H=1e7,C=!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>H?y.c=y.e=null:e.e<M?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>H?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)>H)y.c=y.e=null;else if(f<M)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>=L)?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)>H?e.c=e.e=null:r<M?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>H?e.c=e.e=null:e.e<M&&(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>=L?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],L=r[1]):(g(r,-p,p,t),R=-(L=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),M=r[0],H=r[1];else{if(g(r,-p,p,t),!r)throw Error(o+t+" cannot be zero: "+r);M=-(H=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 C=!r,Error(o+"crypto unavailable");C=r}else C=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,L],RANGE:[M,H],CRYPTO:C,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),C)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 C=!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(!C)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=H,H=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],H=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>=L?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,U.exports?U.exports=t:(e||(e="undefined"!=typeof self&&self?self:window),e.BigNumber=t)}(e);var L=R.exports,M={},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=g,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(0!=(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")}}(M);const C=g,D=H.MT,F=H.SIMPLE,j=H.SYMS;let V=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+")"}[C.inspect.custom](e,t){return"simple("+this.value+")"}inspect(e,t){return"simple("+this.value+")"}encodeCBOR(e){return e._pushInt(this.value,D.SIMPLE_FLOAT)}static isSimple(t){return t instanceof e}static decode(t,r=!0,n=!1){switch(t){case F.FALSE:return!1;case F.TRUE:return!0;case F.NULL:return r?null:j.NULL;case F.UNDEFINED:return r?void 0:j.UNDEFINED;case-1:if(!r||!n)throw new Error("Invalid BREAK");return j.BREAK;default:return new e(t)}}};var K=V;const G=w,W=g;let q=class e extends G.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)&&W.TextDecoder){return new W.TextDecoder("utf8",{fatal:!0,ignoreBOM:!0}).decode(i)}return i.toString(e,t,n)}inspect(e,t){return this[W.inspect.custom](e,t)}[W.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"):W.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 X(e,t){return function(n){const i=this.read(t);return r(i)?i[e].call(i,0,!0):null}}function z(e,r){return function(n){const i=t.alloc(r);return i[e].call(i,n,0,!0),this.push(i)}}Object.assign(q.prototype,{writeUInt8:z("writeUInt8",1),writeUInt16LE:z("writeUInt16LE",2),writeUInt16BE:z("writeUInt16BE",2),writeUInt32LE:z("writeUInt32LE",4),writeUInt32BE:z("writeUInt32BE",4),writeInt8:z("writeInt8",1),writeInt16LE:z("writeInt16LE",2),writeInt16BE:z("writeInt16BE",2),writeInt32LE:z("writeInt32LE",4),writeInt32BE:z("writeInt32BE",4),writeFloatLE:z("writeFloatLE",4),writeFloatBE:z("writeFloatBE",4),writeDoubleLE:z("writeDoubleLE",8),writeDoubleBE:z("writeDoubleBE",8),readUInt8:X("readUInt8",1),readUInt16LE:X("readUInt16LE",2),readUInt16BE:X("readUInt16BE",2),readUInt32LE:X("readUInt32LE",4),readUInt32BE:X("readUInt32BE",4),readInt8:X("readInt8",1),readInt16LE:X("readInt16LE",2),readInt16BE:X("readInt16BE",2),readInt32LE:X("readInt32LE",4),readInt32BE:X("readInt32BE",4),readFloatLE:X("readFloatLE",4),readFloatBE:X("readFloatBE",4),readDoubleLE:X("readDoubleLE",8),readDoubleBE:X("readDoubleBE",8)});var $=q;const Y=$,J=w.Transform;var Q=class extends J{constructor(e){super(e),this._writableState.objectMode=!1,this._readableState.objectMode=!0,this.bs=new Y,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 Z=L.BigNumber,ee=M,te=u,re=new Z(-1),ne=new Z(2);var ie=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 ee.bufferToBignumber(e)}static _tag_3(e){return re.minus(ee.bufferToBignumber(e))}static _tag_4(e){return Z(e[1]).shiftedBy(e[0])}static _tag_5(e){return ne.pow(e[0]).times(e[1])}static _tag_32(e){return te.parse(e)}static _tag_35(e){return new RegExp(e)}};const oe=w,se=Q,ae=ie,ue=K,ce=M,fe=L.BigNumber,he=$,pe=H,le=pe.MT,de=pe.NUMBYTES,ye=pe.SYMS,ge=ce.bigIntize(pe.BI),we=pe.BN,me=Symbol("count"),be=Symbol("major type"),Ee=Symbol("error"),_e=Symbol("not found");function ve(e,t,r){const n=[];return n[me]=r,n[ye.PARENT]=e,n[be]=t,n}function Se(e,t){const r=new he;return r[me]=-1,r[ye.PARENT]=e,r[be]=t,r}function Ie(e){return ce.bufferToBigInt(e)}function Te(e){return ge.MINUS_ONE-ce.bufferToBigInt(e)}let ke=class e extends se{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=!!ce.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]=Ie),null==this.tags[3]&&(this.tags[3]=Te))}static nullcheck(e){switch(e){case ye.NULL:return null;case ye.UNDEFINED:return;case _e: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=ce.extend({},r),n=i.encoding,delete i.encoding}const o=new e(i),s=t instanceof oe.Readable?t:new he(t,null!=n?n:ce.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=ce.extend({},r),n=i.encoding,delete i.encoding}const o=new e(i),s=t instanceof oe.Readable?t:new he(t,null!=n?n:ce.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=ce.guessEncoding(t);break;case"string":s=r;break;case"object":i=ce.extend({},r),s=null!=i.encoding?i.encoding:ce.guessEncoding(t),delete i.encoding,o=null!=i.required&&i.required,delete i.required}const a=new e(i);let u=_e;const c=new Promise(((t,r)=>{a.on("data",(t=>{u=e.nullcheck(t),a.close()})),a.once("error",(e=>(u!==_e&&(e.value=u),u=Ee,a.close(),r(e)))),a.once("end",(()=>{switch(u){case _e:return o?r(new Error("No CBOR found")):t(u);case Ee: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=ce.guessEncoding(t);break;case"string":o=r;break;case"object":i=ce.extend({},r),o=null!=i.encoding?i.encoding:ce.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[be]:void 0,u=null!=e?e.length:void 0;switch(s){case de.ONE:this.emit("more-bytes",o,1,a,u),n=(yield 1)[0];break;case de.TWO:case de.FOUR:case de.EIGHT:const e=1<<s-24;this.emit("more-bytes",o,e,a,u);const t=yield e;n=o===le.SIMPLE_FLOAT?t:ce.parseCBORint(s,t);break;case 28:case 29:case 30:throw this.running=!1,new Error("Additional info not implemented: "+s);case de.INDEFINITE:switch(o){case le.POS_INT:case le.NEG_INT:case le.TAG:throw new Error(`Invalid indefinite encoding for MT ${o}`)}n=-1;break;default:n=s}switch(o){case le.POS_INT:break;case le.NEG_INT:n=n===Number.MAX_SAFE_INTEGER?we.NEG_MAX:n instanceof fe?we.MINUS_ONE.minus(n):-1-n;break;case le.BYTE_STRING:case le.UTF8_STRING:switch(n){case 0:this.emit("start-string",o,n,a,u),n=o===le.BYTE_STRING?t.allocUnsafe(0):"";break;case-1:this.emit("start",o,ye.STREAM,a,u),e=Se(e,o),r++;continue;default:this.emit("start-string",o,n,a,u),n=yield n,o===le.UTF8_STRING&&(n=ce.utf8(n))}break;case le.ARRAY:case le.MAP:switch(n){case 0:n=o===le.MAP?{}:[];break;case-1:this.emit("start",o,ye.STREAM,a,u),e=ve(e,o,-1),r++;continue;default:this.emit("start",o,n,a,u),e=ve(e,o,n*(o-3)),r++;continue}break;case le.TAG:this.emit("start",o,n,a,u),e=ve(e,o,1),e.push(n),r++;continue;case le.SIMPLE_FLOAT:if("number"==typeof n){if(s===de.ONE&&n<32)throw new Error(`Invalid two-byte encoding of simple value ${n}`);const t=null!=e;n=ue.decode(n,t,t&&e[me]<0)}else n=ce.parseCBORfloat(n)}this.emit("value",n,a,u,s);let c=!1;for(;null!=e;){switch(!1){case n!==ye.BREAK:e[me]=1;break;case!Array.isArray(e):e.push(n);break;case!(e instanceof he):const t=e[be];if(null!=t&&t!==o)throw this.running=!1,new Error("Invalid major type in indefinite encoding");e.write(n)}if(0!=--e[me]){c=!0;break}if(--r,delete e[me],Array.isArray(e))switch(e[be]){case le.ARRAY:n=e;break;case le.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 le.TAG:n=new ae(e[0],e[1]).convert(this.tags)}else if(e instanceof he)switch(e[be]){case le.BYTE_STRING:n=e.slice();break;case le.UTF8_STRING:n=e.toString("utf-8")}this.emit("stop",e[be]);const t=e;e=e[ye.PARENT],delete t[ye.PARENT],delete t[be]}if(!c)return n}}};ke.NOT_FOUND=_e;var Ae=ke;const Pe=w,Oe=g,Ne=Ae,Ue=H,xe=L.BigNumber,Be=$,Re=Ue.MT,Le=Ue.NUMBYTES,Me=Ue.SYMS;function He(e){return e>1?"s":""}class Ce extends Pe.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 Be,t.tags={24:this._tag_24.bind(this)},this.parser=new Ne(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 Ce({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 Be,s=new Ce({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 Re.POS_INT:i="Positive number,";break;case Re.NEG_INT:i="Negative number,";break;case Re.ARRAY:i="Array, length";break;case Re.MAP:i="Map, count";break;case Re.BYTE_STRING:i="Bytes, length";break;case Re.UTF8_STRING:i="String, length";break;case Re.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 Re.BYTE_STRING:i="Bytes, length: "+t;break;case Re.UTF8_STRING:i="String, length: "+t.toString()}return this.push(i+"\n")}_on_start(e,t,r,n){if(this.depth++,t!==Me.BREAK)switch(r){case Re.ARRAY:this.push(`[${n}], `);break;case Re.MAP:n%2?this.push(`{Val:${Math.floor(n/2)}}, `):this.push(`{Key:${Math.floor(n/2)}}, `)}switch(e){case Re.TAG:this.push(`Tag #${t}`),24==t&&this.push(" Encoded CBOR data item");break;case Re.ARRAY:t===Me.STREAM?this.push("Array (streaming)"):this.push(`Array, ${t} item${He(t)}`);break;case Re.MAP:t===Me.STREAM?this.push("Map (streaming)"):this.push(`Map, ${t} pair${He(t)}`);break;case Re.BYTE_STRING:this.push("Bytes (streaming)");break;case Re.UTF8_STRING:this.push("String (streaming)")}return this.push("\n")}_on_stop(e){return this.depth--}_on_value(e,t,n,i){if(e!==Me.BREAK)switch(t){case Re.ARRAY:this.push(`[${n}], `);break;case Re.MAP:n%2?this.push(`{Val:${Math.floor(n/2)}}, `):this.push(`{Key:${Math.floor(n/2)}}, `)}switch(e===Me.BREAK?this.push("BREAK\n"):e===Me.NULL?this.push("null\n"):e===Me.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 xe?(this.push(e.toString()),this.push("\n")):(this.push(Oe.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 De=Ce;const Fe=w,je=g,Ve=Ae,Ke=M,Ge=H,We=L.BigNumber,qe=$,Xe=Ge.MT,ze=Ge.SYMS;class $e extends Fe.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 Ve(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=Ke.guessEncoding(e);break;case"object":n=Ke.extend({},t),i=null!=n.encoding?n.encoding:Ke.guessEncoding(e),delete n.encoding;break;default:i=null!=t?t:"hex"}const o=new qe,s=new $e(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===Xe.SIMPLE_FLOAT)return this.float_bytes={2:1,4:2,8:3}[t]}_fore(e,t){switch(e){case Xe.BYTE_STRING:case Xe.UTF8_STRING:case Xe.ARRAY:if(t>0)return this.push(", ");break;case Xe.MAP:if(t>0)return t%2?this.push(": "):this.push(", ")}}_on_value(e,t,n){if(e!==ze.BREAK)return this._fore(t,n),this.push((()=>{switch(!1){case e!==ze.NULL:return"null";case e!==ze.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,je.inspect(e)+"_"+t;case!r(e):return"h'"+e.toString("hex")+"'";case!(e instanceof We):return e.toString();default:return je.inspect(e)}})())}_on_start(e,t,r,n){switch(this._fore(r,n),e){case Xe.TAG:this.push(`${t}(`);break;case Xe.ARRAY:this.push("[");break;case Xe.MAP:this.push("{");break;case Xe.BYTE_STRING:case Xe.UTF8_STRING:this.push("(")}if(t===ze.STREAM)return this.push("_ ")}_on_stop(e){switch(e){case Xe.TAG:return this.push(")");case Xe.ARRAY:return this.push("]");case Xe.MAP:return this.push("}");case Xe.BYTE_STRING:case Xe.UTF8_STRING:return this.push(")")}}_on_data(){return this.push(this.separator)}}var Ye=$e;const Je=w,Qe=u;L.BigNumber;const Ze=$,et=M,tt=H,rt=tt.MT,nt=tt.NUMBYTES,it=tt.SHIFT32,ot=tt.SYMS,st=tt.TAG,at=tt.MT.SIMPLE_FLOAT<<5|tt.NUMBYTES.TWO,ut=tt.MT.SIMPLE_FLOAT<<5|tt.NUMBYTES.FOUR,ct=tt.MT.SIMPLE_FLOAT<<5|tt.NUMBYTES.EIGHT,ft=tt.MT.SIMPLE_FLOAT<<5|tt.SIMPLE.TRUE,ht=tt.MT.SIMPLE_FLOAT<<5|tt.SIMPLE.FALSE,pt=tt.MT.SIMPLE_FLOAT<<5|tt.SIMPLE.UNDEFINED,lt=tt.MT.SIMPLE_FLOAT<<5|tt.SIMPLE.NULL,dt=t.from([255]),yt=et.bigIntize(tt.BI),gt=tt.BN,wt=t.from("f97e00","hex"),mt=t.from("f9fc00","hex"),bt=t.from("f97c00","hex"),Et=t.from("f98000","hex"),_t=Symbol("CBOR_LOOP_DETECT");let vt=class e extends Je.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},Qe.Url&&this.addSemanticType("Url",this._pushUrl),Qe.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(wt)}_pushInfinity(e){const t=e<0?mt:bt;return this.push(t)}_pushFloat(e){if(this.canonical){const r=t.allocUnsafe(2);if(et.writeHalf(r,e))return this._pushUInt8(at)&&this.push(r)}return Math.fround(e)===e?this._pushUInt8(ut)&&this._pushFloatBE(e):this._pushUInt8(ct)&&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|nt.ONE)&&this._pushUInt8(e);case!(e<=65535):return this._pushUInt8(n|nt.TWO)&&this._pushUInt16BE(e);case!(e<=4294967295):return this._pushUInt8(n|nt.FOUR)&&this._pushUInt32BE(e);case!(e<=Number.MAX_SAFE_INTEGER):return this._pushUInt8(n|nt.EIGHT)&&this._pushUInt32BE(Math.floor(e/it))&&this._pushUInt32BE(e%it);default:return t===rt.NEG_INT?this._pushFloat(r):this._pushFloat(e)}}_pushIntNum(e){return Object.is(e,-0)?this.push(Et):e<0?this._pushInt(-e-1,rt.NEG_INT,e):this._pushInt(e,rt.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,rt.UTF8_STRING)&&this.push(e,"utf8")}_pushBoolean(e){return this._pushUInt8(e?ft:ht)}_pushUndefined(e){switch(typeof this.encodeUndefined){case"undefined":return this._pushUInt8(pt);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(lt)}_pushArray(e,t,r){r=Object.assign({indefinite:!1},r);const n=t.length;if(r.indefinite){if(!e._pushUInt8(rt.ARRAY<<5|nt.INDEFINITE))return!1}else if(!e._pushInt(n,rt.ARRAY))return!1;for(let r=0;r<n;r++)if(!e.pushAny(t[r]))return!1;return!(r.indefinite&&!e.push(dt))}_pushTag(e){return this._pushInt(e,rt.TAG)}_pushDate(e,t){switch(e.dateType){case"string":return e._pushTag(st.DATE_STRING)&&e._pushString(t.toISOString());case"int":case"integer":return e._pushTag(st.DATE_EPOCH)&&e._pushIntNum(Math.round(t/1e3));case"float":return e._pushTag(st.DATE_EPOCH)&&e._pushFloat(t/1e3);default:return e._pushTag(st.DATE_EPOCH)&&e.pushAny(t/1e3)}}_pushBuffer(e,t){return e._pushInt(t.length,rt.BYTE_STRING)&&e.push(t)}_pushNoFilter(e,t){return e._pushBuffer(e,t.slice())}_pushRegexp(e,t){return e._pushTag(st.REGEXP)&&e.pushAny(t.source)}_pushSet(e,t){if(!e._pushInt(t.size,rt.ARRAY))return!1;for(const r of t)if(!e.pushAny(r))return!1;return!0}_pushUrl(e,t){return e._pushTag(st.URI)&&e.pushAny(t.format())}_pushURL(e,t){return e._pushTag(st.URI)&&e.pushAny(t.toString())}_pushBigint(e){let r=rt.POS_INT,n=st.POS_BIGINT;if(e.isNegative()&&(e=e.negated().minus(1),r=rt.NEG_INT,n=st.NEG_BIGINT),this.collapseBigIntegers&&e.lte(gt.MAXINT64))return e.lte(gt.MAXINT32)?this._pushInt(e.toNumber(),r):this._pushUInt8(r<<5|nt.EIGHT)&&this._pushUInt32BE(e.dividedToIntegerBy(gt.SHIFT32).toNumber())&&this._pushUInt32BE(e.mod(gt.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=rt.POS_INT,n=st.POS_BIGINT;if(e<0&&(e=-e+yt.MINUS_ONE,r=rt.NEG_INT,n=st.NEG_BIGINT),this.collapseBigIntegers&&e<=yt.MAXINT64)return e<=4294967295?this._pushInt(Number(e),r):this._pushUInt8(r<<5|nt.EIGHT)&&this._pushUInt32BE(Number(e/yt.SHIFT32))&&this._pushUInt32BE(Number(e%yt.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(st.DECIMAL_FRAC)||!e._pushInt(2,rt.ARRAY))return!1;const r=t.decimalPlaces(),n=t.shiftedBy(r);return!!e._pushIntNum(-r)&&(n.abs().isLessThan(gt.MAXINT)?e._pushIntNum(n.toNumber()):e._pushBigint(n))}_pushMap(t,r,n){if((n=Object.assign({indefinite:!1},n)).indefinite){if(!t._pushUInt8(rt.MAP<<5|nt.INDEFINITE))return!1}else if(!t._pushInt(r.size,rt.MAP))return!1;if(t.canonical){const n=[...r.entries()],i=new e(this),o=new Ze({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(dt))}_pushUint8Array(e,r){return e._pushBuffer(e,t.from(r))}_pushFloat32Array(e,t){const r=t.length;if(!e._pushInt(r,rt.ARRAY))return!1;for(let n=0;n<r;n++)if(!e._pushUInt8(ut)||!e._pushFloatBE(t[n]))return!1;return!0}_pushFloat64Array(e,t){const r=t.length;if(!e._pushInt(r,rt.ARRAY))return!1;for(let n=0;n<r;n++)if(!e._pushUInt8(ct)||!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[_t];if(!r)return!1;if(null==t)t=r;else if(t!==r)return!1;if(delete e[_t],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[_t]===this.detectLoops)throw new Error("Loop detected while CBOR encoding");t[_t]=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(rt.MAP<<5|nt.INDEFINITE))return!1}else if(!this._pushInt(n.length,rt.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(dt))}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 ot.NULL:return this._pushNull(null);case ot.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 Ze({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(rt.UTF8_STRING<<5|nt.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(dt)}else if(r(t)){i=i&&e._pushUInt8(rt.BYTE_STRING<<5|nt.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(dt)}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 St=vt;const It=St,Tt=Ae,kt=H.MT;class At extends Map{constructor(e){super(e)}static _encode(e){return It.encodeCanonical(e).toString("base64")}static _decode(e){return Tt.decodeFirstSync(e,"base64")}get(e){return super.get(At._encode(e))}set(e,t){return super.set(At._encode(e),t)}delete(e){return super.delete(At._encode(e))}has(e){return super.has(At._encode(e))}*keys(){for(const e of super.keys())yield At._decode(e)}*entries(){for(const e of super.entries())yield[At._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],At._decode(t[0]),this)}encodeCBOR(e){if(!e._pushInt(this.size,kt.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 Pt,Ot=At;(Pt=B).BigNumber=L.BigNumber,Pt.Commented=De,Pt.Diagnose=Ye,Pt.Decoder=Ae,Pt.Encoder=St,Pt.Simple=K,Pt.Tagged=ie,Pt.Map=Ot,Pt.comment=Pt.Commented.comment,Pt.decodeAll=Pt.Decoder.decodeAll,Pt.decodeFirst=Pt.Decoder.decodeFirst,Pt.decodeAllSync=Pt.Decoder.decodeAllSync,Pt.decodeFirstSync=Pt.Decoder.decodeFirstSync,Pt.diagnose=Pt.Diagnose.diagnose,Pt.encode=Pt.Encoder.encode,Pt.encodeCanonical=Pt.Encoder.encodeCanonical,Pt.encodeOne=Pt.Encoder.encodeOne,Pt.encodeAsync=Pt.Encoder.encodeAsync,Pt.decode=Pt.Decoder.decodeFirstSync,Pt.leveldb={decode:Pt.Decoder.decodeAllSync,encode:Pt.Encoder.encode,buffer:!0,name:"cbor"},Pt.hasBigInt=M.hasBigInt;var Nt={exports:{}};var Ut=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}},xt=d.Buffer;var Bt=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 xt.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=xt.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=xt.from(t)),!xt.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:Rt}=_;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:Mt}=_;const Ht=Ut,Ct=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)}}},Dt=function(e){const t=e.indexOf("=")>-1,r=e.indexOf("-")>-1&&e.indexOf("_")>-1;return{encode(e){let n="";n="string"==typeof e?Mt.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 Mt.from(t,"base64")}}},Ft=[["base1","1","","1"],["base2","0",Bt,"01"],["base8","7",Bt,"01234567"],["base10","9",Bt,"0123456789"],["base16","f",function(e){return{encode:e=>"string"==typeof e?Rt.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 Rt.from(t,"hex")}}},"0123456789abcdef"],["base32","b",Ct,"abcdefghijklmnopqrstuvwxyz234567"],["base32pad","c",Ct,"abcdefghijklmnopqrstuvwxyz234567="],["base32hex","v",Ct,"0123456789abcdefghijklmnopqrstuv"],["base32hexpad","t",Ct,"0123456789abcdefghijklmnopqrstuv="],["base32z","h",Ct,"ybndrfg8ejkmcpqxot1uwisza345h769"],["base58flickr","Z",Bt,"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],["base58btc","z",Bt,"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],["base64","m",Dt,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],["base64pad","M",Dt,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="],["base64url","u",Dt,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"],["base64urlpad","U",Dt,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_="]],jt=Ft.reduce(((e,t)=>(e[t[0]]=new Ht(t[0],t[1],t[2],t[3]),e)),{}),Vt=Ft.reduce(((e,t)=>(e[t[1]]=jt[t[0]],e)),{});var Kt={names:jt,codes:Vt};!function(e,t){const{Buffer:r}=_,n=Kt;(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}}(Nt,Nt.exports);var Gt=Nt.exports,Wt=9007199254740991,qt="[object Arguments]",Xt="[object Function]",zt="[object GeneratorFunction]",$t="object"==typeof e&&e&&e.Object===Object&&e,Yt="object"==typeof self&&self&&self.Object===Object&&self,Jt=$t||Yt||Function("return this")();function Qt(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}var Zt=Object.prototype,er=Zt.hasOwnProperty,tr=Zt.toString,rr=Jt.Symbol,nr=Zt.propertyIsEnumerable,ir=rr?rr.isConcatSpreadable:void 0;function or(e,t,r,n,i){var o=-1,s=e.length;for(r||(r=sr),i||(i=[]);++o<s;){var a=e[o];t>0&&r(a)?t>1?or(a,t-1,r,n,i):Qt(i,a):n||(i[i.length]=a)}return i}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<=Wt}(e.length)&&!function(e){var t=function(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}(e)?tr.call(e):"";return t==Xt||t==zt}(e)}(e)}(e)&&er.call(e,"callee")&&(!nr.call(e,"callee")||tr.call(e)==qt)}(e)||!!(ir&&e&&e[ir])}var ar=Array.isArray;var ur=function(e){return(e?e.length:0)?or(e,1):[]};const{validate:cr}=N,fr=x,hr=B,pr=Gt,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=Br(e)||function(e){return function(e){return function(e){return!!e&&"object"==typeof e}(e)&&Rr(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)!t&&!Sr.call(e,o)||i&&("length"==o||xr(o,n))||r.push(o);return r}var Pr,Or=function(e,t,r){for(var n=-1,i=Object(e),o=r(e),s=o.length;s--;){var a=o[Pr?s:++n];if(!1===t(i[a],a,i))break}return e};function Nr(e,t,r,n){return function(e,t){e&&Or(e,t,Cr)}(e,(function(e,i,o){t(n,r(e),i,o)})),n}function Ur(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 xr(e,t){return!!(t=null==t?yr:t)&&("number"==typeof e||br.test(e))&&e>-1&&e%1==0&&e<t}var Br=Array.isArray;function Rr(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 Lr,Mr,Hr=(Lr=function(e,t,r){e[t]=r},Mr=function(e){return function(){return e}}((function(e){return e})),function(e,t){return Nr(e,Lr,Mr(t),{})});function Cr(e){return Rr(e)?Ar(e):Ur(e)}var Dr=Hr,Fr={exports:{}};!function(t,r){var n="__lodash_hash_undefined__",i=1,o=2,s=1/0,a=9007199254740991,u="[object Arguments]",c="[object Array]",f="[object Boolean]",h="[object Date]",p="[object Error]",l="[object Function]",d="[object GeneratorFunction]",y="[object Map]",g="[object Number]",w="[object Object]",m="[object Promise]",b="[object RegExp]",E="[object Set]",_="[object String]",v="[object Symbol]",S="[object WeakMap]",I="[object ArrayBuffer]",T="[object DataView]",k=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,A=/^\w*$/,P=/^\./,O=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,N=/\\(\\)?/g,U=/^\[object .+?Constructor\]$/,x=/^(?:0|[1-9]\d*)$/,B={};B["[object Float32Array]"]=B["[object Float64Array]"]=B["[object Int8Array]"]=B["[object Int16Array]"]=B["[object Int32Array]"]=B["[object Uint8Array]"]=B["[object Uint8ClampedArray]"]=B["[object Uint16Array]"]=B["[object Uint32Array]"]=!0,B[u]=B[c]=B[I]=B[f]=B[T]=B[h]=B[p]=B[l]=B[y]=B[g]=B[w]=B[b]=B[E]=B[_]=B[S]=!1;var R="object"==typeof e&&e&&e.Object===Object&&e,L="object"==typeof self&&self&&self.Object===Object&&self,M=R||L||Function("return this")(),H=r&&!r.nodeType&&r,C=H&&t&&!t.nodeType&&t,D=C&&C.exports===H&&R.process,F=function(){try{return D&&D.binding("util")}catch(e){}}(),j=F&&F.isTypedArray;function V(e,t){for(var r=-1,n=e?e.length:0;++r<n;)if(t(e[r],r,e))return!0;return!1}function K(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}function G(e){var t=-1,r=Array(e.size);return e.forEach((function(e,n){r[++t]=[n,e]})),r}function W(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=e})),r}var q,X=Array.prototype,z=Function.prototype,$=Object.prototype,Y=M["__core-js_shared__"],J=(q=/[^.]+$/.exec(Y&&Y.keys&&Y.keys.IE_PROTO||""))?"Symbol(src)_1."+q:"",Q=z.toString,Z=$.hasOwnProperty,ee=$.toString,te=RegExp("^"+Q.call(Z).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),re=M.Symbol,ne=M.Uint8Array,ie=$.propertyIsEnumerable,oe=X.splice,se=function(e,t){return function(r){return e(t(r))}}(Object.keys,Object),ae=Ce(M,"DataView"),ue=Ce(M,"Map"),ce=Ce(M,"Promise"),fe=Ce(M,"Set"),he=Ce(M,"WeakMap"),pe=Ce(Object,"create"),le=qe(ae),de=qe(ue),ye=qe(ce),ge=qe(fe),we=qe(he),me=re?re.prototype:void 0,be=me?me.valueOf:void 0,Ee=me?me.toString:void 0;function _e(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 ve(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 Se(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 Ie(e){var t=-1,r=e?e.length:0;for(this.__data__=new Se;++t<r;)this.add(e[t])}function Te(e){this.__data__=new ve(e)}function ke(e,t){var r=Ye(e)||$e(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)!t&&!Z.call(e,o)||i&&("length"==o||Fe(o,n))||r.push(o);return r}function Ae(e,t){for(var r=e.length;r--;)if(ze(e[r][0],t))return r;return-1}_e.prototype.clear=function(){this.__data__=pe?pe(null):{}},_e.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},_e.prototype.get=function(e){var t=this.__data__;if(pe){var r=t[e];return r===n?void 0:r}return Z.call(t,e)?t[e]:void 0},_e.prototype.has=function(e){var t=this.__data__;return pe?void 0!==t[e]:Z.call(t,e)},_e.prototype.set=function(e,t){return this.__data__[e]=pe&&void 0===t?n:t,this},ve.prototype.clear=function(){this.__data__=[]},ve.prototype.delete=function(e){var t=this.__data__,r=Ae(t,e);return!(r<0)&&(r==t.length-1?t.pop():oe.call(t,r,1),!0)},ve.prototype.get=function(e){var t=this.__data__,r=Ae(t,e);return r<0?void 0:t[r][1]},ve.prototype.has=function(e){return Ae(this.__data__,e)>-1},ve.prototype.set=function(e,t){var r=this.__data__,n=Ae(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Se.prototype.clear=function(){this.__data__={hash:new _e,map:new(ue||ve),string:new _e}},Se.prototype.delete=function(e){return He(this,e).delete(e)},Se.prototype.get=function(e){return He(this,e).get(e)},Se.prototype.has=function(e){return He(this,e).has(e)},Se.prototype.set=function(e,t){return He(this,e).set(e,t),this},Ie.prototype.add=Ie.prototype.push=function(e){return this.__data__.set(e,n),this},Ie.prototype.has=function(e){return this.__data__.has(e)},Te.prototype.clear=function(){this.__data__=new ve},Te.prototype.delete=function(e){return this.__data__.delete(e)},Te.prototype.get=function(e){return this.__data__.get(e)},Te.prototype.has=function(e){return this.__data__.has(e)},Te.prototype.set=function(e,t){var r=this.__data__;if(r instanceof ve){var n=r.__data__;if(!ue||n.length<199)return n.push([e,t]),this;r=this.__data__=new Se(n)}return r.set(e,t),this};var Pe=function(e){return function(t,r,n){for(var i=-1,o=Object(t),s=n(t),a=s.length;a--;){var u=s[e?a:++i];if(!1===r(o[u],u,o))break}return t}}();function Oe(e,t){for(var r=0,n=(t=je(t,e)?[t]:Le(t)).length;null!=e&&r<n;)e=e[We(t[r++])];return r&&r==n?e:void 0}function Ne(e,t){return null!=e&&t in Object(e)}function Ue(e,t,r,n){return function(e,t){e&&Pe(e,t,ot)}(e,(function(e,i,o){t(n,r(e),i,o)})),n}function xe(e,t,r,n,s){return e===t||(null==e||null==t||!et(e)&&!tt(t)?e!=e&&t!=t:function(e,t,r,n,s,a){var l=Ye(e),d=Ye(t),m=c,S=c;l||(m=(m=De(e))==u?w:m);d||(S=(S=De(t))==u?w:S);var k=m==w&&!K(e),A=S==w&&!K(t),P=m==S;if(P&&!k)return a||(a=new Te),l||nt(e)?Me(e,t,r,n,s,a):function(e,t,r,n,s,a,u){switch(r){case T:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case I:return!(e.byteLength!=t.byteLength||!n(new ne(e),new ne(t)));case f:case h:case g:return ze(+e,+t);case p:return e.name==t.name&&e.message==t.message;case b:case _:return e==t+"";case y:var c=G;case E:var l=a&o;if(c||(c=W),e.size!=t.size&&!l)return!1;var d=u.get(e);if(d)return d==t;a|=i,u.set(e,t);var w=Me(c(e),c(t),n,s,a,u);return u.delete(e),w;case v:if(be)return be.call(e)==be.call(t)}return!1}(e,t,m,r,n,s,a);if(!(s&o)){var O=k&&Z.call(e,"__wrapped__"),N=A&&Z.call(t,"__wrapped__");if(O||N){var U=O?e.value():e,x=N?t.value():t;return a||(a=new Te),r(U,x,n,s,a)}}if(!P)return!1;return a||(a=new Te),function(e,t,r,n,i,s){var a=i&o,u=ot(e),c=u.length,f=ot(t),h=f.length;if(c!=h&&!a)return!1;var p=c;for(;p--;){var l=u[p];if(!(a?l in t:Z.call(t,l)))return!1}var d=s.get(e);if(d&&s.get(t))return d==t;var y=!0;s.set(e,t),s.set(t,e);var g=a;for(;++p<c;){var w=e[l=u[p]],m=t[l];if(n)var b=a?n(m,w,l,t,e,s):n(w,m,l,e,t,s);if(!(void 0===b?w===m||r(w,m,n,i,s):b)){y=!1;break}g||(g="constructor"==l)}if(y&&!g){var E=e.constructor,_=t.constructor;E==_||!("constructor"in e)||!("constructor"in t)||"function"==typeof E&&E instanceof E&&"function"==typeof _&&_ instanceof _||(y=!1)}return s.delete(e),s.delete(t),y}(e,t,r,n,s,a)}(e,t,xe,r,n,s))}function Be(e){return!(!et(e)||function(e){return!!J&&J in e}(e))&&(Qe(e)||K(e)?te:U).test(qe(e))}function Re(e){if(!function(e){var t=e&&e.constructor,r="function"==typeof t&&t.prototype||$;return e===r}(e))return se(e);var t=[];for(var r in Object(e))Z.call(e,r)&&"constructor"!=r&&t.push(r);return t}function Le(e){return Ye(e)?e:Ge(e)}function Me(e,t,r,n,s,a){var u=s&o,c=e.length,f=t.length;if(c!=f&&!(u&&f>c))return!1;var h=a.get(e);if(h&&a.get(t))return h==t;var p=-1,l=!0,d=s&i?new Ie:void 0;for(a.set(e,t),a.set(t,e);++p<c;){var y=e[p],g=t[p];if(n)var w=u?n(g,y,p,t,e,a):n(y,g,p,e,t,a);if(void 0!==w){if(w)continue;l=!1;break}if(d){if(!V(t,(function(e,t){if(!d.has(t)&&(y===e||r(y,e,n,s,a)))return d.add(t)}))){l=!1;break}}else if(y!==g&&!r(y,g,n,s,a)){l=!1;break}}return a.delete(e),a.delete(t),l}function He(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 Ce(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return Be(r)?r:void 0}var De=function(e){return ee.call(e)};function Fe(e,t){return!!(t=null==t?a:t)&&("number"==typeof e||x.test(e))&&e>-1&&e%1==0&&e<t}function je(e,t){if(Ye(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!rt(e))||(A.test(e)||!k.test(e)||null!=t&&e in Object(t))}function Ve(e){return e==e&&!et(e)}function Ke(e,t){return function(r){return null!=r&&(r[e]===t&&(void 0!==t||e in Object(r)))}}(ae&&De(new ae(new ArrayBuffer(1)))!=T||ue&&De(new ue)!=y||ce&&De(ce.resolve())!=m||fe&&De(new fe)!=E||he&&De(new he)!=S)&&(De=function(e){var t=ee.call(e),r=t==w?e.constructor:void 0,n=r?qe(r):void 0;if(n)switch(n){case le:return T;case de:return y;case ye:return m;case ge:return E;case we:return S}return t});var Ge=Xe((function(e){e=function(e){return null==e?"":function(e){if("string"==typeof e)return e;if(rt(e))return Ee?Ee.call(e):"";var t=e+"";return"0"==t&&1/e==-s?"-0":t}(e)}(e);var t=[];return P.test(e)&&t.push(""),e.replace(O,(function(e,r,n,i){t.push(n?i.replace(N,"$1"):r||e)})),t}));function We(e){if("string"==typeof e||rt(e))return e;var t=e+"";return"0"==t&&1/e==-s?"-0":t}function qe(e){if(null!=e){try{return Q.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Xe(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(Xe.Cache||Se),r}function ze(e,t){return e===t||e!=e&&t!=t}function $e(e){return function(e){return tt(e)&&Je(e)}(e)&&Z.call(e,"callee")&&(!ie.call(e,"callee")||ee.call(e)==u)}Xe.Cache=Se;var Ye=Array.isArray;function Je(e){return null!=e&&Ze(e.length)&&!Qe(e)}function Qe(e){var t=et(e)?ee.call(e):"";return t==l||t==d}function Ze(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=a}function et(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function tt(e){return!!e&&"object"==typeof e}function rt(e){return"symbol"==typeof e||tt(e)&&ee.call(e)==v}var nt=j?function(e){return function(t){return e(t)}}(j):function(e){return tt(e)&&Ze(e.length)&&!!B[ee.call(e)]};var it=function(e,t){return function(r,n){return Ue(r,e,t(n),{})}}((function(e,t,r){Z.call(e,t)?e[t].push(r):e[t]=[r]}),(function(e){return"function"==typeof e?e:null==e?st:"object"==typeof e?Ye(e)?function(e,t){if(je(e)&&Ve(t))return Ke(We(e),t);return function(r){var n=function(e,t,r){var n=null==e?void 0:Oe(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=je(t,e)?[t]:Le(t);var n,i=-1,o=t.length;for(;++i<o;){var s=We(t[i]);if(!(n=null!=e&&r(e,s)))break;e=e[s]}if(n)return n;o=e?e.length:0;return!!o&&Ze(o)&&Fe(s,o)&&(Ye(e)||$e(e))}(e,t,Ne)}(r,e):xe(t,n,void 0,i|o)}}(e[0],e[1]):function(e){var t=function(e){var t=ot(e),r=t.length;for(;r--;){var n=t[r],i=e[n];t[r]=[n,i,Ve(i)]}return t}(e);if(1==t.length&&t[0][2])return Ke(t[0][0],t[0][1]);return function(r){return r===e||function(e,t,r,n){var s=r.length,a=s,u=!n;if(null==e)return!a;for(e=Object(e);s--;){var c=r[s];if(u&&c[2]?c[1]!==e[c[0]]:!(c[0]in e))return!1}for(;++s<a;){var f=(c=r[s])[0],h=e[f],p=c[1];if(u&&c[2]){if(void 0===h&&!(f in e))return!1}else{var l=new Te;if(n)var d=n(h,p,f,e,t,l);if(!(void 0===d?xe(p,h,n,i|o,l):d))return!1}}return!0}(r,e,t)}}(e):function(e){return je(e)?(t=We(e),function(e){return null==e?void 0:e[t]}):function(e){return function(t){return Oe(t,e)}}(e);var t}(e)}));function ot(e){return Je(e)?ke(e):Re(e)}function st(e){return e}t.exports=it}(Fr,Fr.exports);const jr=x,Vr=B,Kr=Gt,Gr=Dr,Wr=Fr.exports;var qr=class{constructor(e){if(!Kr.isEncoded(e))throw new Error("Base58 string is invalid. Cannot construct Decoder.");this.base58=e}constructRootJSON(e){const r=Gr(jr.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=Vr.decode(o).toString("hex")),e[i]=o,e}),{})}constructAnchorsJSON(e){const t=Wr(jr.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}:${Gr(jr.chain[t].networks)[r[1]]}`}return`${e}:${Vr.decode(r[1]).toString("hex")}`}),"blink")))}constructPathJSON(e){const t=Gr(jr.path);return e.map((e=>({[t[e[0]]]:Vr.decode(e[1]).toString("hex")})))}decode(){const e=Kr.decode(this.base58),t=Vr.decode(e);return this.constructRootJSON(t)}};var Xr={Encoder:dr,Decoder:qr,Keymap:x};function zr(e){return Object.keys(p).map((e=>p[e])).find((t=>t.signatureValue===e))}function $r(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 zr(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 zr(i)}(r)}return null}function Yr(e,t){const r=e.findIndex((e=>e===t));r>-1&&e.splice(r,1)}var Jr={"@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"}]},Qr={"@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"}}},Zr={"@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"}}},en={"@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 tn(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}c["https://w3id.org/blockcerts/schema/2.0-alpha/context.json"]=Jr,c["https://www.blockcerts.org/schema/2.0-alpha/context.json"]=Jr,c["https://www.blockcerts.org/schema/3.0-alpha/context.json"]=Qr,c["https://w3id.org/blockcerts/schema/3.0-alpha/context.json"]=Qr,c["https://w3id.org/blockcerts/v3.0-alpha"]=Qr,c["https://www.blockcerts.org/schema/3.0-beta/context.json"]=Zr,c["https://w3id.org/blockcerts/schema/3.0-beta/context.json"]=Zr,c["https://w3id.org/blockcerts/v3.0-beta"]=Zr,c["https://w3id.org/security/suites/ed25519-2020/v1"]=en;class rn extends Error{constructor(e,t){super(t),this.stepCode=e}}var nn={locale:"en-US"},on={"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 sn(e,t){return e&&t?on[nn.locale]?on[nn.locale][e]?on[nn.locale][e][t]?on[nn.locale][e][t]||"":"[missing locale item data]":"[missing locale group data]":"[missing locale data]":""}var an=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 un(e,t=null,r=(e=>an(this,void 0,void 0,(function*(){return Promise})))){return an(this,void 0,void 0,(function*(){e["@context"].find((e=>{return(t=e)===Object(t)&&"@vocab"in e;var t}))||e["@context"].push({"@vocab":"http://fallback.org/"});const n=JSON.parse(JSON.stringify(e));if(Array.isArray(n.proof)){if(!t)throw new rn("computeLocalHash",sn("errors","noProofSpecified"));const e=n.proof.findIndex((e=>e.proofValue===t.proofValue));n.proof=n.proof.slice(0,e)}else delete n.proof;const i={algorithm:"URDNA2015",format:"application/nquads",documentLoader:function(e){return an(this,void 0,void 0,(function*(){return null!=r&&(yield r(e)),e in c?{contextUrl:null,document:c[e],documentUrl:e}:I.documentLoader(e)}))},safe:!1};let o;try{o=yield I.normalize(n,i)}catch(e){throw console.error(e),new rn("computeLocalHash",sn("errors","failedJsonLdNormalization"))}const s=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}(o);if(s)throw new rn("computeLocalHash",`${sn("errors","foundUnmappedFields")}: ${s.join(", ")}`);return T(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}(o))}))}var cn=d.Buffer;var fn=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 cn.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=cn.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=cn.from(t)),!cn.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")}}};fn("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");const hn=t,pn=e=>{const t=(e=>{const t=m.from(Object.assign(Object.assign({},e),{crv:"K-256"}),"jwk").toString("blk","public"),r=b.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&&0==(127&e[n-1])&&(n<=1||0==(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 Ln(e,t){Error.captureStackTrace&&Error.captureStackTrace(e,t)}function Mn(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 Hn(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 "+Mn(e)+", got"+(""!==r?" "+r:"")+(""!==n?" "+n:"")}function Cn(e,t,r){r=r||Rn(t),this.message=Hn(e,t,r),Ln(this,Cn),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 '),Hn('property "'+Mn(r)+o+Mn(e),n,i)}(e,r,t,n,i)):this.message='Unexpected property "'+t+'"',Ln(this,Cn),this.__label=r,this.__property=t,this.__type=e,this.__value=n,this.__valueTypeName=i}Cn.prototype=Object.create(Error.prototype),Cn.prototype.constructor=Cn,Dn.prototype=Object.create(Error.prototype),Dn.prototype.constructor=Cn;var Fn,jn,Vn={TfTypeError:Cn,TfPropertyTypeError:Dn,tfCustomError:function(e,t){return new Cn(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 Cn&&(e=new Dn(e.__type,t,r,e.__value,e.__valueTypeName)),Ln(e),e},tfJSON:Mn,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.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(`Wrong positive integer: ${e}`)}function Bi(e){if("boolean"!=typeof e)throw new Error(`Expected boolean, not ${e}`)}function Ri(e,...t){if(!((r=e)instanceof Uint8Array||null!=r&&"object"==typeof r&&"Uint8Array"===r.constructor.name))throw new Error("Expected Uint8Array");var r;if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array 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 Mi(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){Ri(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=void 0,Ui.number=xi,Ui.bool=Bi,Ui.bytes=Ri,Ui.hash=Li,Ui.exists=Mi,Ui.output=Hi;const Ci={number:xi,bool:Bi,bytes:Ri,hash:Li,exists:Mi,output:Hi};Ui.default=Ci;var Di={},Fi={};Object.defineProperty(Fi,"__esModule",{value:!0}),Fi.crypto=void 0,Fi.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,function(e){
|
|
1
|
+
import{a as e,B as t,i as r,p as n,d as i,j as o,r as s,k as a,l as u,h as c,m as f,S as h,n as p}from"./main.js";import{s as l}from"./index-yP42zfkJ-CHN5LgUq.js";import{s as d,r as y,a as g,b as w,k as m,c as b,d as E}from"./index-DWAZG7Ja-CBt_boC3.js";import{r as _,e as v}from"./elliptic-DVE5q-l5-D-NH8siB.js";import{j as S}from"./jsonld-signatures-zDEkNjYR-D3vK8GYH.js";import{j as I}from"./jsonld-Pr6hPH-i-D_C9ciG_.js";import{s as T}from"./sha256-wKiO0px2-BYFBxJ7m.js";import"./pako.esm-DnD5dZGi-HambcU-w.js";import{e as k}from"./ensureValidIssuingKey-wRebznsK-frafTbMl.js";import"./index-CcA_A5fd-Dgus2xdV.js";import{S as A}from"./Suite-B7Vy9AuU-D1ucdMDB.js";const P={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:O}=l;var N={validate:O(P)};var U,x={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}}}},B={},R={exports:{}};U=R,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,L=21,M=-1e7,H=1e7,C=!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>H?y.c=y.e=null:e.e<M?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>H?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)>H)y.c=y.e=null;else if(f<M)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>=L)?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)>H?e.c=e.e=null:r<M?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>H?e.c=e.e=null:e.e<M&&(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>=L?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],L=r[1]):(g(r,-p,p,t),R=-(L=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),M=r[0],H=r[1];else{if(g(r,-p,p,t),!r)throw Error(o+t+" cannot be zero: "+r);M=-(H=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 C=!r,Error(o+"crypto unavailable");C=r}else C=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,L],RANGE:[M,H],CRYPTO:C,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),C)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 C=!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(!C)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=H,H=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],H=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>=L?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,U.exports?U.exports=t:(e||(e="undefined"!=typeof self&&self?self:window),e.BigNumber=t)}(e);var L=R.exports,M={},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=g,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(0!=(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")}}(M);const C=g,D=H.MT,F=H.SIMPLE,j=H.SYMS;let V=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+")"}[C.inspect.custom](e,t){return"simple("+this.value+")"}inspect(e,t){return"simple("+this.value+")"}encodeCBOR(e){return e._pushInt(this.value,D.SIMPLE_FLOAT)}static isSimple(t){return t instanceof e}static decode(t,r=!0,n=!1){switch(t){case F.FALSE:return!1;case F.TRUE:return!0;case F.NULL:return r?null:j.NULL;case F.UNDEFINED:return r?void 0:j.UNDEFINED;case-1:if(!r||!n)throw new Error("Invalid BREAK");return j.BREAK;default:return new e(t)}}};var K=V;const G=w,W=g;let q=class e extends G.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)&&W.TextDecoder){return new W.TextDecoder("utf8",{fatal:!0,ignoreBOM:!0}).decode(i)}return i.toString(e,t,n)}inspect(e,t){return this[W.inspect.custom](e,t)}[W.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"):W.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 X(e,t){return function(n){const i=this.read(t);return r(i)?i[e].call(i,0,!0):null}}function z(e,r){return function(n){const i=t.alloc(r);return i[e].call(i,n,0,!0),this.push(i)}}Object.assign(q.prototype,{writeUInt8:z("writeUInt8",1),writeUInt16LE:z("writeUInt16LE",2),writeUInt16BE:z("writeUInt16BE",2),writeUInt32LE:z("writeUInt32LE",4),writeUInt32BE:z("writeUInt32BE",4),writeInt8:z("writeInt8",1),writeInt16LE:z("writeInt16LE",2),writeInt16BE:z("writeInt16BE",2),writeInt32LE:z("writeInt32LE",4),writeInt32BE:z("writeInt32BE",4),writeFloatLE:z("writeFloatLE",4),writeFloatBE:z("writeFloatBE",4),writeDoubleLE:z("writeDoubleLE",8),writeDoubleBE:z("writeDoubleBE",8),readUInt8:X("readUInt8",1),readUInt16LE:X("readUInt16LE",2),readUInt16BE:X("readUInt16BE",2),readUInt32LE:X("readUInt32LE",4),readUInt32BE:X("readUInt32BE",4),readInt8:X("readInt8",1),readInt16LE:X("readInt16LE",2),readInt16BE:X("readInt16BE",2),readInt32LE:X("readInt32LE",4),readInt32BE:X("readInt32BE",4),readFloatLE:X("readFloatLE",4),readFloatBE:X("readFloatBE",4),readDoubleLE:X("readDoubleLE",8),readDoubleBE:X("readDoubleBE",8)});var $=q;const Y=$,J=w.Transform;var Q=class extends J{constructor(e){super(e),this._writableState.objectMode=!1,this._readableState.objectMode=!0,this.bs=new Y,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 Z=L.BigNumber,ee=M,te=u,re=new Z(-1),ne=new Z(2);var ie=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 ee.bufferToBignumber(e)}static _tag_3(e){return re.minus(ee.bufferToBignumber(e))}static _tag_4(e){return Z(e[1]).shiftedBy(e[0])}static _tag_5(e){return ne.pow(e[0]).times(e[1])}static _tag_32(e){return te.parse(e)}static _tag_35(e){return new RegExp(e)}};const oe=w,se=Q,ae=ie,ue=K,ce=M,fe=L.BigNumber,he=$,pe=H,le=pe.MT,de=pe.NUMBYTES,ye=pe.SYMS,ge=ce.bigIntize(pe.BI),we=pe.BN,me=Symbol("count"),be=Symbol("major type"),Ee=Symbol("error"),_e=Symbol("not found");function ve(e,t,r){const n=[];return n[me]=r,n[ye.PARENT]=e,n[be]=t,n}function Se(e,t){const r=new he;return r[me]=-1,r[ye.PARENT]=e,r[be]=t,r}function Ie(e){return ce.bufferToBigInt(e)}function Te(e){return ge.MINUS_ONE-ce.bufferToBigInt(e)}let ke=class e extends se{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=!!ce.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]=Ie),null==this.tags[3]&&(this.tags[3]=Te))}static nullcheck(e){switch(e){case ye.NULL:return null;case ye.UNDEFINED:return;case _e: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=ce.extend({},r),n=i.encoding,delete i.encoding}const o=new e(i),s=t instanceof oe.Readable?t:new he(t,null!=n?n:ce.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=ce.extend({},r),n=i.encoding,delete i.encoding}const o=new e(i),s=t instanceof oe.Readable?t:new he(t,null!=n?n:ce.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=ce.guessEncoding(t);break;case"string":s=r;break;case"object":i=ce.extend({},r),s=null!=i.encoding?i.encoding:ce.guessEncoding(t),delete i.encoding,o=null!=i.required&&i.required,delete i.required}const a=new e(i);let u=_e;const c=new Promise(((t,r)=>{a.on("data",(t=>{u=e.nullcheck(t),a.close()})),a.once("error",(e=>(u!==_e&&(e.value=u),u=Ee,a.close(),r(e)))),a.once("end",(()=>{switch(u){case _e:return o?r(new Error("No CBOR found")):t(u);case Ee: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=ce.guessEncoding(t);break;case"string":o=r;break;case"object":i=ce.extend({},r),o=null!=i.encoding?i.encoding:ce.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[be]:void 0,u=null!=e?e.length:void 0;switch(s){case de.ONE:this.emit("more-bytes",o,1,a,u),n=(yield 1)[0];break;case de.TWO:case de.FOUR:case de.EIGHT:const e=1<<s-24;this.emit("more-bytes",o,e,a,u);const t=yield e;n=o===le.SIMPLE_FLOAT?t:ce.parseCBORint(s,t);break;case 28:case 29:case 30:throw this.running=!1,new Error("Additional info not implemented: "+s);case de.INDEFINITE:switch(o){case le.POS_INT:case le.NEG_INT:case le.TAG:throw new Error(`Invalid indefinite encoding for MT ${o}`)}n=-1;break;default:n=s}switch(o){case le.POS_INT:break;case le.NEG_INT:n=n===Number.MAX_SAFE_INTEGER?we.NEG_MAX:n instanceof fe?we.MINUS_ONE.minus(n):-1-n;break;case le.BYTE_STRING:case le.UTF8_STRING:switch(n){case 0:this.emit("start-string",o,n,a,u),n=o===le.BYTE_STRING?t.allocUnsafe(0):"";break;case-1:this.emit("start",o,ye.STREAM,a,u),e=Se(e,o),r++;continue;default:this.emit("start-string",o,n,a,u),n=yield n,o===le.UTF8_STRING&&(n=ce.utf8(n))}break;case le.ARRAY:case le.MAP:switch(n){case 0:n=o===le.MAP?{}:[];break;case-1:this.emit("start",o,ye.STREAM,a,u),e=ve(e,o,-1),r++;continue;default:this.emit("start",o,n,a,u),e=ve(e,o,n*(o-3)),r++;continue}break;case le.TAG:this.emit("start",o,n,a,u),e=ve(e,o,1),e.push(n),r++;continue;case le.SIMPLE_FLOAT:if("number"==typeof n){if(s===de.ONE&&n<32)throw new Error(`Invalid two-byte encoding of simple value ${n}`);const t=null!=e;n=ue.decode(n,t,t&&e[me]<0)}else n=ce.parseCBORfloat(n)}this.emit("value",n,a,u,s);let c=!1;for(;null!=e;){switch(!1){case n!==ye.BREAK:e[me]=1;break;case!Array.isArray(e):e.push(n);break;case!(e instanceof he):const t=e[be];if(null!=t&&t!==o)throw this.running=!1,new Error("Invalid major type in indefinite encoding");e.write(n)}if(0!=--e[me]){c=!0;break}if(--r,delete e[me],Array.isArray(e))switch(e[be]){case le.ARRAY:n=e;break;case le.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 le.TAG:n=new ae(e[0],e[1]).convert(this.tags)}else if(e instanceof he)switch(e[be]){case le.BYTE_STRING:n=e.slice();break;case le.UTF8_STRING:n=e.toString("utf-8")}this.emit("stop",e[be]);const t=e;e=e[ye.PARENT],delete t[ye.PARENT],delete t[be]}if(!c)return n}}};ke.NOT_FOUND=_e;var Ae=ke;const Pe=w,Oe=g,Ne=Ae,Ue=H,xe=L.BigNumber,Be=$,Re=Ue.MT,Le=Ue.NUMBYTES,Me=Ue.SYMS;function He(e){return e>1?"s":""}class Ce extends Pe.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 Be,t.tags={24:this._tag_24.bind(this)},this.parser=new Ne(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 Ce({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 Be,s=new Ce({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 Re.POS_INT:i="Positive number,";break;case Re.NEG_INT:i="Negative number,";break;case Re.ARRAY:i="Array, length";break;case Re.MAP:i="Map, count";break;case Re.BYTE_STRING:i="Bytes, length";break;case Re.UTF8_STRING:i="String, length";break;case Re.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 Re.BYTE_STRING:i="Bytes, length: "+t;break;case Re.UTF8_STRING:i="String, length: "+t.toString()}return this.push(i+"\n")}_on_start(e,t,r,n){if(this.depth++,t!==Me.BREAK)switch(r){case Re.ARRAY:this.push(`[${n}], `);break;case Re.MAP:n%2?this.push(`{Val:${Math.floor(n/2)}}, `):this.push(`{Key:${Math.floor(n/2)}}, `)}switch(e){case Re.TAG:this.push(`Tag #${t}`),24==t&&this.push(" Encoded CBOR data item");break;case Re.ARRAY:t===Me.STREAM?this.push("Array (streaming)"):this.push(`Array, ${t} item${He(t)}`);break;case Re.MAP:t===Me.STREAM?this.push("Map (streaming)"):this.push(`Map, ${t} pair${He(t)}`);break;case Re.BYTE_STRING:this.push("Bytes (streaming)");break;case Re.UTF8_STRING:this.push("String (streaming)")}return this.push("\n")}_on_stop(e){return this.depth--}_on_value(e,t,n,i){if(e!==Me.BREAK)switch(t){case Re.ARRAY:this.push(`[${n}], `);break;case Re.MAP:n%2?this.push(`{Val:${Math.floor(n/2)}}, `):this.push(`{Key:${Math.floor(n/2)}}, `)}switch(e===Me.BREAK?this.push("BREAK\n"):e===Me.NULL?this.push("null\n"):e===Me.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 xe?(this.push(e.toString()),this.push("\n")):(this.push(Oe.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 De=Ce;const Fe=w,je=g,Ve=Ae,Ke=M,Ge=H,We=L.BigNumber,qe=$,Xe=Ge.MT,ze=Ge.SYMS;class $e extends Fe.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 Ve(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=Ke.guessEncoding(e);break;case"object":n=Ke.extend({},t),i=null!=n.encoding?n.encoding:Ke.guessEncoding(e),delete n.encoding;break;default:i=null!=t?t:"hex"}const o=new qe,s=new $e(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===Xe.SIMPLE_FLOAT)return this.float_bytes={2:1,4:2,8:3}[t]}_fore(e,t){switch(e){case Xe.BYTE_STRING:case Xe.UTF8_STRING:case Xe.ARRAY:if(t>0)return this.push(", ");break;case Xe.MAP:if(t>0)return t%2?this.push(": "):this.push(", ")}}_on_value(e,t,n){if(e!==ze.BREAK)return this._fore(t,n),this.push((()=>{switch(!1){case e!==ze.NULL:return"null";case e!==ze.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,je.inspect(e)+"_"+t;case!r(e):return"h'"+e.toString("hex")+"'";case!(e instanceof We):return e.toString();default:return je.inspect(e)}})())}_on_start(e,t,r,n){switch(this._fore(r,n),e){case Xe.TAG:this.push(`${t}(`);break;case Xe.ARRAY:this.push("[");break;case Xe.MAP:this.push("{");break;case Xe.BYTE_STRING:case Xe.UTF8_STRING:this.push("(")}if(t===ze.STREAM)return this.push("_ ")}_on_stop(e){switch(e){case Xe.TAG:return this.push(")");case Xe.ARRAY:return this.push("]");case Xe.MAP:return this.push("}");case Xe.BYTE_STRING:case Xe.UTF8_STRING:return this.push(")")}}_on_data(){return this.push(this.separator)}}var Ye=$e;const Je=w,Qe=u;L.BigNumber;const Ze=$,et=M,tt=H,rt=tt.MT,nt=tt.NUMBYTES,it=tt.SHIFT32,ot=tt.SYMS,st=tt.TAG,at=tt.MT.SIMPLE_FLOAT<<5|tt.NUMBYTES.TWO,ut=tt.MT.SIMPLE_FLOAT<<5|tt.NUMBYTES.FOUR,ct=tt.MT.SIMPLE_FLOAT<<5|tt.NUMBYTES.EIGHT,ft=tt.MT.SIMPLE_FLOAT<<5|tt.SIMPLE.TRUE,ht=tt.MT.SIMPLE_FLOAT<<5|tt.SIMPLE.FALSE,pt=tt.MT.SIMPLE_FLOAT<<5|tt.SIMPLE.UNDEFINED,lt=tt.MT.SIMPLE_FLOAT<<5|tt.SIMPLE.NULL,dt=t.from([255]),yt=et.bigIntize(tt.BI),gt=tt.BN,wt=t.from("f97e00","hex"),mt=t.from("f9fc00","hex"),bt=t.from("f97c00","hex"),Et=t.from("f98000","hex"),_t=Symbol("CBOR_LOOP_DETECT");let vt=class e extends Je.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},Qe.Url&&this.addSemanticType("Url",this._pushUrl),Qe.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(wt)}_pushInfinity(e){const t=e<0?mt:bt;return this.push(t)}_pushFloat(e){if(this.canonical){const r=t.allocUnsafe(2);if(et.writeHalf(r,e))return this._pushUInt8(at)&&this.push(r)}return Math.fround(e)===e?this._pushUInt8(ut)&&this._pushFloatBE(e):this._pushUInt8(ct)&&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|nt.ONE)&&this._pushUInt8(e);case!(e<=65535):return this._pushUInt8(n|nt.TWO)&&this._pushUInt16BE(e);case!(e<=4294967295):return this._pushUInt8(n|nt.FOUR)&&this._pushUInt32BE(e);case!(e<=Number.MAX_SAFE_INTEGER):return this._pushUInt8(n|nt.EIGHT)&&this._pushUInt32BE(Math.floor(e/it))&&this._pushUInt32BE(e%it);default:return t===rt.NEG_INT?this._pushFloat(r):this._pushFloat(e)}}_pushIntNum(e){return Object.is(e,-0)?this.push(Et):e<0?this._pushInt(-e-1,rt.NEG_INT,e):this._pushInt(e,rt.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,rt.UTF8_STRING)&&this.push(e,"utf8")}_pushBoolean(e){return this._pushUInt8(e?ft:ht)}_pushUndefined(e){switch(typeof this.encodeUndefined){case"undefined":return this._pushUInt8(pt);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(lt)}_pushArray(e,t,r){r=Object.assign({indefinite:!1},r);const n=t.length;if(r.indefinite){if(!e._pushUInt8(rt.ARRAY<<5|nt.INDEFINITE))return!1}else if(!e._pushInt(n,rt.ARRAY))return!1;for(let r=0;r<n;r++)if(!e.pushAny(t[r]))return!1;return!(r.indefinite&&!e.push(dt))}_pushTag(e){return this._pushInt(e,rt.TAG)}_pushDate(e,t){switch(e.dateType){case"string":return e._pushTag(st.DATE_STRING)&&e._pushString(t.toISOString());case"int":case"integer":return e._pushTag(st.DATE_EPOCH)&&e._pushIntNum(Math.round(t/1e3));case"float":return e._pushTag(st.DATE_EPOCH)&&e._pushFloat(t/1e3);default:return e._pushTag(st.DATE_EPOCH)&&e.pushAny(t/1e3)}}_pushBuffer(e,t){return e._pushInt(t.length,rt.BYTE_STRING)&&e.push(t)}_pushNoFilter(e,t){return e._pushBuffer(e,t.slice())}_pushRegexp(e,t){return e._pushTag(st.REGEXP)&&e.pushAny(t.source)}_pushSet(e,t){if(!e._pushInt(t.size,rt.ARRAY))return!1;for(const r of t)if(!e.pushAny(r))return!1;return!0}_pushUrl(e,t){return e._pushTag(st.URI)&&e.pushAny(t.format())}_pushURL(e,t){return e._pushTag(st.URI)&&e.pushAny(t.toString())}_pushBigint(e){let r=rt.POS_INT,n=st.POS_BIGINT;if(e.isNegative()&&(e=e.negated().minus(1),r=rt.NEG_INT,n=st.NEG_BIGINT),this.collapseBigIntegers&&e.lte(gt.MAXINT64))return e.lte(gt.MAXINT32)?this._pushInt(e.toNumber(),r):this._pushUInt8(r<<5|nt.EIGHT)&&this._pushUInt32BE(e.dividedToIntegerBy(gt.SHIFT32).toNumber())&&this._pushUInt32BE(e.mod(gt.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=rt.POS_INT,n=st.POS_BIGINT;if(e<0&&(e=-e+yt.MINUS_ONE,r=rt.NEG_INT,n=st.NEG_BIGINT),this.collapseBigIntegers&&e<=yt.MAXINT64)return e<=4294967295?this._pushInt(Number(e),r):this._pushUInt8(r<<5|nt.EIGHT)&&this._pushUInt32BE(Number(e/yt.SHIFT32))&&this._pushUInt32BE(Number(e%yt.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(st.DECIMAL_FRAC)||!e._pushInt(2,rt.ARRAY))return!1;const r=t.decimalPlaces(),n=t.shiftedBy(r);return!!e._pushIntNum(-r)&&(n.abs().isLessThan(gt.MAXINT)?e._pushIntNum(n.toNumber()):e._pushBigint(n))}_pushMap(t,r,n){if((n=Object.assign({indefinite:!1},n)).indefinite){if(!t._pushUInt8(rt.MAP<<5|nt.INDEFINITE))return!1}else if(!t._pushInt(r.size,rt.MAP))return!1;if(t.canonical){const n=[...r.entries()],i=new e(this),o=new Ze({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(dt))}_pushUint8Array(e,r){return e._pushBuffer(e,t.from(r))}_pushFloat32Array(e,t){const r=t.length;if(!e._pushInt(r,rt.ARRAY))return!1;for(let n=0;n<r;n++)if(!e._pushUInt8(ut)||!e._pushFloatBE(t[n]))return!1;return!0}_pushFloat64Array(e,t){const r=t.length;if(!e._pushInt(r,rt.ARRAY))return!1;for(let n=0;n<r;n++)if(!e._pushUInt8(ct)||!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[_t];if(!r)return!1;if(null==t)t=r;else if(t!==r)return!1;if(delete e[_t],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[_t]===this.detectLoops)throw new Error("Loop detected while CBOR encoding");t[_t]=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(rt.MAP<<5|nt.INDEFINITE))return!1}else if(!this._pushInt(n.length,rt.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(dt))}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 ot.NULL:return this._pushNull(null);case ot.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 Ze({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(rt.UTF8_STRING<<5|nt.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(dt)}else if(r(t)){i=i&&e._pushUInt8(rt.BYTE_STRING<<5|nt.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(dt)}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 St=vt;const It=St,Tt=Ae,kt=H.MT;class At extends Map{constructor(e){super(e)}static _encode(e){return It.encodeCanonical(e).toString("base64")}static _decode(e){return Tt.decodeFirstSync(e,"base64")}get(e){return super.get(At._encode(e))}set(e,t){return super.set(At._encode(e),t)}delete(e){return super.delete(At._encode(e))}has(e){return super.has(At._encode(e))}*keys(){for(const e of super.keys())yield At._decode(e)}*entries(){for(const e of super.entries())yield[At._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],At._decode(t[0]),this)}encodeCBOR(e){if(!e._pushInt(this.size,kt.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 Pt,Ot=At;(Pt=B).BigNumber=L.BigNumber,Pt.Commented=De,Pt.Diagnose=Ye,Pt.Decoder=Ae,Pt.Encoder=St,Pt.Simple=K,Pt.Tagged=ie,Pt.Map=Ot,Pt.comment=Pt.Commented.comment,Pt.decodeAll=Pt.Decoder.decodeAll,Pt.decodeFirst=Pt.Decoder.decodeFirst,Pt.decodeAllSync=Pt.Decoder.decodeAllSync,Pt.decodeFirstSync=Pt.Decoder.decodeFirstSync,Pt.diagnose=Pt.Diagnose.diagnose,Pt.encode=Pt.Encoder.encode,Pt.encodeCanonical=Pt.Encoder.encodeCanonical,Pt.encodeOne=Pt.Encoder.encodeOne,Pt.encodeAsync=Pt.Encoder.encodeAsync,Pt.decode=Pt.Decoder.decodeFirstSync,Pt.leveldb={decode:Pt.Decoder.decodeAllSync,encode:Pt.Encoder.encode,buffer:!0,name:"cbor"},Pt.hasBigInt=M.hasBigInt;var Nt={exports:{}};var Ut=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}},xt=d.Buffer;var Bt=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 xt.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=xt.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=xt.from(t)),!xt.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:Rt}=_;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:Mt}=_;const Ht=Ut,Ct=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)}}},Dt=function(e){const t=e.indexOf("=")>-1,r=e.indexOf("-")>-1&&e.indexOf("_")>-1;return{encode(e){let n="";n="string"==typeof e?Mt.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 Mt.from(t,"base64")}}},Ft=[["base1","1","","1"],["base2","0",Bt,"01"],["base8","7",Bt,"01234567"],["base10","9",Bt,"0123456789"],["base16","f",function(e){return{encode:e=>"string"==typeof e?Rt.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 Rt.from(t,"hex")}}},"0123456789abcdef"],["base32","b",Ct,"abcdefghijklmnopqrstuvwxyz234567"],["base32pad","c",Ct,"abcdefghijklmnopqrstuvwxyz234567="],["base32hex","v",Ct,"0123456789abcdefghijklmnopqrstuv"],["base32hexpad","t",Ct,"0123456789abcdefghijklmnopqrstuv="],["base32z","h",Ct,"ybndrfg8ejkmcpqxot1uwisza345h769"],["base58flickr","Z",Bt,"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],["base58btc","z",Bt,"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],["base64","m",Dt,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],["base64pad","M",Dt,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="],["base64url","u",Dt,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"],["base64urlpad","U",Dt,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_="]],jt=Ft.reduce(((e,t)=>(e[t[0]]=new Ht(t[0],t[1],t[2],t[3]),e)),{}),Vt=Ft.reduce(((e,t)=>(e[t[1]]=jt[t[0]],e)),{});var Kt={names:jt,codes:Vt};!function(e,t){const{Buffer:r}=_,n=Kt;(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}}(Nt,Nt.exports);var Gt=Nt.exports,Wt=9007199254740991,qt="[object Arguments]",Xt="[object Function]",zt="[object GeneratorFunction]",$t="object"==typeof e&&e&&e.Object===Object&&e,Yt="object"==typeof self&&self&&self.Object===Object&&self,Jt=$t||Yt||Function("return this")();function Qt(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}var Zt=Object.prototype,er=Zt.hasOwnProperty,tr=Zt.toString,rr=Jt.Symbol,nr=Zt.propertyIsEnumerable,ir=rr?rr.isConcatSpreadable:void 0;function or(e,t,r,n,i){var o=-1,s=e.length;for(r||(r=sr),i||(i=[]);++o<s;){var a=e[o];t>0&&r(a)?t>1?or(a,t-1,r,n,i):Qt(i,a):n||(i[i.length]=a)}return i}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<=Wt}(e.length)&&!function(e){var t=function(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}(e)?tr.call(e):"";return t==Xt||t==zt}(e)}(e)}(e)&&er.call(e,"callee")&&(!nr.call(e,"callee")||tr.call(e)==qt)}(e)||!!(ir&&e&&e[ir])}var ar=Array.isArray;var ur=function(e){return(e?e.length:0)?or(e,1):[]};const{validate:cr}=N,fr=x,hr=B,pr=Gt,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=Br(e)||function(e){return function(e){return function(e){return!!e&&"object"==typeof e}(e)&&Rr(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)!t&&!Sr.call(e,o)||i&&("length"==o||xr(o,n))||r.push(o);return r}var Pr,Or=function(e,t,r){for(var n=-1,i=Object(e),o=r(e),s=o.length;s--;){var a=o[Pr?s:++n];if(!1===t(i[a],a,i))break}return e};function Nr(e,t,r,n){return function(e,t){e&&Or(e,t,Cr)}(e,(function(e,i,o){t(n,r(e),i,o)})),n}function Ur(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 xr(e,t){return!!(t=null==t?yr:t)&&("number"==typeof e||br.test(e))&&e>-1&&e%1==0&&e<t}var Br=Array.isArray;function Rr(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 Lr,Mr,Hr=(Lr=function(e,t,r){e[t]=r},Mr=function(e){return function(){return e}}((function(e){return e})),function(e,t){return Nr(e,Lr,Mr(t),{})});function Cr(e){return Rr(e)?Ar(e):Ur(e)}var Dr=Hr,Fr={exports:{}};!function(t,r){var n="__lodash_hash_undefined__",i=1,o=2,s=1/0,a=9007199254740991,u="[object Arguments]",c="[object Array]",f="[object Boolean]",h="[object Date]",p="[object Error]",l="[object Function]",d="[object GeneratorFunction]",y="[object Map]",g="[object Number]",w="[object Object]",m="[object Promise]",b="[object RegExp]",E="[object Set]",_="[object String]",v="[object Symbol]",S="[object WeakMap]",I="[object ArrayBuffer]",T="[object DataView]",k=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,A=/^\w*$/,P=/^\./,O=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,N=/\\(\\)?/g,U=/^\[object .+?Constructor\]$/,x=/^(?:0|[1-9]\d*)$/,B={};B["[object Float32Array]"]=B["[object Float64Array]"]=B["[object Int8Array]"]=B["[object Int16Array]"]=B["[object Int32Array]"]=B["[object Uint8Array]"]=B["[object Uint8ClampedArray]"]=B["[object Uint16Array]"]=B["[object Uint32Array]"]=!0,B[u]=B[c]=B[I]=B[f]=B[T]=B[h]=B[p]=B[l]=B[y]=B[g]=B[w]=B[b]=B[E]=B[_]=B[S]=!1;var R="object"==typeof e&&e&&e.Object===Object&&e,L="object"==typeof self&&self&&self.Object===Object&&self,M=R||L||Function("return this")(),H=r&&!r.nodeType&&r,C=H&&t&&!t.nodeType&&t,D=C&&C.exports===H&&R.process,F=function(){try{return D&&D.binding("util")}catch(e){}}(),j=F&&F.isTypedArray;function V(e,t){for(var r=-1,n=e?e.length:0;++r<n;)if(t(e[r],r,e))return!0;return!1}function K(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}function G(e){var t=-1,r=Array(e.size);return e.forEach((function(e,n){r[++t]=[n,e]})),r}function W(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=e})),r}var q,X=Array.prototype,z=Function.prototype,$=Object.prototype,Y=M["__core-js_shared__"],J=(q=/[^.]+$/.exec(Y&&Y.keys&&Y.keys.IE_PROTO||""))?"Symbol(src)_1."+q:"",Q=z.toString,Z=$.hasOwnProperty,ee=$.toString,te=RegExp("^"+Q.call(Z).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),re=M.Symbol,ne=M.Uint8Array,ie=$.propertyIsEnumerable,oe=X.splice,se=function(e,t){return function(r){return e(t(r))}}(Object.keys,Object),ae=Ce(M,"DataView"),ue=Ce(M,"Map"),ce=Ce(M,"Promise"),fe=Ce(M,"Set"),he=Ce(M,"WeakMap"),pe=Ce(Object,"create"),le=qe(ae),de=qe(ue),ye=qe(ce),ge=qe(fe),we=qe(he),me=re?re.prototype:void 0,be=me?me.valueOf:void 0,Ee=me?me.toString:void 0;function _e(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 ve(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 Se(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 Ie(e){var t=-1,r=e?e.length:0;for(this.__data__=new Se;++t<r;)this.add(e[t])}function Te(e){this.__data__=new ve(e)}function ke(e,t){var r=Ye(e)||$e(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)!t&&!Z.call(e,o)||i&&("length"==o||Fe(o,n))||r.push(o);return r}function Ae(e,t){for(var r=e.length;r--;)if(ze(e[r][0],t))return r;return-1}_e.prototype.clear=function(){this.__data__=pe?pe(null):{}},_e.prototype.delete=function(e){return this.has(e)&&delete this.__data__[e]},_e.prototype.get=function(e){var t=this.__data__;if(pe){var r=t[e];return r===n?void 0:r}return Z.call(t,e)?t[e]:void 0},_e.prototype.has=function(e){var t=this.__data__;return pe?void 0!==t[e]:Z.call(t,e)},_e.prototype.set=function(e,t){return this.__data__[e]=pe&&void 0===t?n:t,this},ve.prototype.clear=function(){this.__data__=[]},ve.prototype.delete=function(e){var t=this.__data__,r=Ae(t,e);return!(r<0)&&(r==t.length-1?t.pop():oe.call(t,r,1),!0)},ve.prototype.get=function(e){var t=this.__data__,r=Ae(t,e);return r<0?void 0:t[r][1]},ve.prototype.has=function(e){return Ae(this.__data__,e)>-1},ve.prototype.set=function(e,t){var r=this.__data__,n=Ae(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},Se.prototype.clear=function(){this.__data__={hash:new _e,map:new(ue||ve),string:new _e}},Se.prototype.delete=function(e){return He(this,e).delete(e)},Se.prototype.get=function(e){return He(this,e).get(e)},Se.prototype.has=function(e){return He(this,e).has(e)},Se.prototype.set=function(e,t){return He(this,e).set(e,t),this},Ie.prototype.add=Ie.prototype.push=function(e){return this.__data__.set(e,n),this},Ie.prototype.has=function(e){return this.__data__.has(e)},Te.prototype.clear=function(){this.__data__=new ve},Te.prototype.delete=function(e){return this.__data__.delete(e)},Te.prototype.get=function(e){return this.__data__.get(e)},Te.prototype.has=function(e){return this.__data__.has(e)},Te.prototype.set=function(e,t){var r=this.__data__;if(r instanceof ve){var n=r.__data__;if(!ue||n.length<199)return n.push([e,t]),this;r=this.__data__=new Se(n)}return r.set(e,t),this};var Pe=function(e){return function(t,r,n){for(var i=-1,o=Object(t),s=n(t),a=s.length;a--;){var u=s[e?a:++i];if(!1===r(o[u],u,o))break}return t}}();function Oe(e,t){for(var r=0,n=(t=je(t,e)?[t]:Le(t)).length;null!=e&&r<n;)e=e[We(t[r++])];return r&&r==n?e:void 0}function Ne(e,t){return null!=e&&t in Object(e)}function Ue(e,t,r,n){return function(e,t){e&&Pe(e,t,ot)}(e,(function(e,i,o){t(n,r(e),i,o)})),n}function xe(e,t,r,n,s){return e===t||(null==e||null==t||!et(e)&&!tt(t)?e!=e&&t!=t:function(e,t,r,n,s,a){var l=Ye(e),d=Ye(t),m=c,S=c;l||(m=(m=De(e))==u?w:m);d||(S=(S=De(t))==u?w:S);var k=m==w&&!K(e),A=S==w&&!K(t),P=m==S;if(P&&!k)return a||(a=new Te),l||nt(e)?Me(e,t,r,n,s,a):function(e,t,r,n,s,a,u){switch(r){case T:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case I:return!(e.byteLength!=t.byteLength||!n(new ne(e),new ne(t)));case f:case h:case g:return ze(+e,+t);case p:return e.name==t.name&&e.message==t.message;case b:case _:return e==t+"";case y:var c=G;case E:var l=a&o;if(c||(c=W),e.size!=t.size&&!l)return!1;var d=u.get(e);if(d)return d==t;a|=i,u.set(e,t);var w=Me(c(e),c(t),n,s,a,u);return u.delete(e),w;case v:if(be)return be.call(e)==be.call(t)}return!1}(e,t,m,r,n,s,a);if(!(s&o)){var O=k&&Z.call(e,"__wrapped__"),N=A&&Z.call(t,"__wrapped__");if(O||N){var U=O?e.value():e,x=N?t.value():t;return a||(a=new Te),r(U,x,n,s,a)}}if(!P)return!1;return a||(a=new Te),function(e,t,r,n,i,s){var a=i&o,u=ot(e),c=u.length,f=ot(t),h=f.length;if(c!=h&&!a)return!1;var p=c;for(;p--;){var l=u[p];if(!(a?l in t:Z.call(t,l)))return!1}var d=s.get(e);if(d&&s.get(t))return d==t;var y=!0;s.set(e,t),s.set(t,e);var g=a;for(;++p<c;){var w=e[l=u[p]],m=t[l];if(n)var b=a?n(m,w,l,t,e,s):n(w,m,l,e,t,s);if(!(void 0===b?w===m||r(w,m,n,i,s):b)){y=!1;break}g||(g="constructor"==l)}if(y&&!g){var E=e.constructor,_=t.constructor;E==_||!("constructor"in e)||!("constructor"in t)||"function"==typeof E&&E instanceof E&&"function"==typeof _&&_ instanceof _||(y=!1)}return s.delete(e),s.delete(t),y}(e,t,r,n,s,a)}(e,t,xe,r,n,s))}function Be(e){return!(!et(e)||function(e){return!!J&&J in e}(e))&&(Qe(e)||K(e)?te:U).test(qe(e))}function Re(e){if(!function(e){var t=e&&e.constructor,r="function"==typeof t&&t.prototype||$;return e===r}(e))return se(e);var t=[];for(var r in Object(e))Z.call(e,r)&&"constructor"!=r&&t.push(r);return t}function Le(e){return Ye(e)?e:Ge(e)}function Me(e,t,r,n,s,a){var u=s&o,c=e.length,f=t.length;if(c!=f&&!(u&&f>c))return!1;var h=a.get(e);if(h&&a.get(t))return h==t;var p=-1,l=!0,d=s&i?new Ie:void 0;for(a.set(e,t),a.set(t,e);++p<c;){var y=e[p],g=t[p];if(n)var w=u?n(g,y,p,t,e,a):n(y,g,p,e,t,a);if(void 0!==w){if(w)continue;l=!1;break}if(d){if(!V(t,(function(e,t){if(!d.has(t)&&(y===e||r(y,e,n,s,a)))return d.add(t)}))){l=!1;break}}else if(y!==g&&!r(y,g,n,s,a)){l=!1;break}}return a.delete(e),a.delete(t),l}function He(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 Ce(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return Be(r)?r:void 0}var De=function(e){return ee.call(e)};function Fe(e,t){return!!(t=null==t?a:t)&&("number"==typeof e||x.test(e))&&e>-1&&e%1==0&&e<t}function je(e,t){if(Ye(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!rt(e))||(A.test(e)||!k.test(e)||null!=t&&e in Object(t))}function Ve(e){return e==e&&!et(e)}function Ke(e,t){return function(r){return null!=r&&(r[e]===t&&(void 0!==t||e in Object(r)))}}(ae&&De(new ae(new ArrayBuffer(1)))!=T||ue&&De(new ue)!=y||ce&&De(ce.resolve())!=m||fe&&De(new fe)!=E||he&&De(new he)!=S)&&(De=function(e){var t=ee.call(e),r=t==w?e.constructor:void 0,n=r?qe(r):void 0;if(n)switch(n){case le:return T;case de:return y;case ye:return m;case ge:return E;case we:return S}return t});var Ge=Xe((function(e){e=function(e){return null==e?"":function(e){if("string"==typeof e)return e;if(rt(e))return Ee?Ee.call(e):"";var t=e+"";return"0"==t&&1/e==-s?"-0":t}(e)}(e);var t=[];return P.test(e)&&t.push(""),e.replace(O,(function(e,r,n,i){t.push(n?i.replace(N,"$1"):r||e)})),t}));function We(e){if("string"==typeof e||rt(e))return e;var t=e+"";return"0"==t&&1/e==-s?"-0":t}function qe(e){if(null!=e){try{return Q.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Xe(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(Xe.Cache||Se),r}function ze(e,t){return e===t||e!=e&&t!=t}function $e(e){return function(e){return tt(e)&&Je(e)}(e)&&Z.call(e,"callee")&&(!ie.call(e,"callee")||ee.call(e)==u)}Xe.Cache=Se;var Ye=Array.isArray;function Je(e){return null!=e&&Ze(e.length)&&!Qe(e)}function Qe(e){var t=et(e)?ee.call(e):"";return t==l||t==d}function Ze(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=a}function et(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function tt(e){return!!e&&"object"==typeof e}function rt(e){return"symbol"==typeof e||tt(e)&&ee.call(e)==v}var nt=j?function(e){return function(t){return e(t)}}(j):function(e){return tt(e)&&Ze(e.length)&&!!B[ee.call(e)]};var it=function(e,t){return function(r,n){return Ue(r,e,t(n),{})}}((function(e,t,r){Z.call(e,t)?e[t].push(r):e[t]=[r]}),(function(e){return"function"==typeof e?e:null==e?st:"object"==typeof e?Ye(e)?function(e,t){if(je(e)&&Ve(t))return Ke(We(e),t);return function(r){var n=function(e,t,r){var n=null==e?void 0:Oe(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=je(t,e)?[t]:Le(t);var n,i=-1,o=t.length;for(;++i<o;){var s=We(t[i]);if(!(n=null!=e&&r(e,s)))break;e=e[s]}if(n)return n;o=e?e.length:0;return!!o&&Ze(o)&&Fe(s,o)&&(Ye(e)||$e(e))}(e,t,Ne)}(r,e):xe(t,n,void 0,i|o)}}(e[0],e[1]):function(e){var t=function(e){var t=ot(e),r=t.length;for(;r--;){var n=t[r],i=e[n];t[r]=[n,i,Ve(i)]}return t}(e);if(1==t.length&&t[0][2])return Ke(t[0][0],t[0][1]);return function(r){return r===e||function(e,t,r,n){var s=r.length,a=s,u=!n;if(null==e)return!a;for(e=Object(e);s--;){var c=r[s];if(u&&c[2]?c[1]!==e[c[0]]:!(c[0]in e))return!1}for(;++s<a;){var f=(c=r[s])[0],h=e[f],p=c[1];if(u&&c[2]){if(void 0===h&&!(f in e))return!1}else{var l=new Te;if(n)var d=n(h,p,f,e,t,l);if(!(void 0===d?xe(p,h,n,i|o,l):d))return!1}}return!0}(r,e,t)}}(e):function(e){return je(e)?(t=We(e),function(e){return null==e?void 0:e[t]}):function(e){return function(t){return Oe(t,e)}}(e);var t}(e)}));function ot(e){return Je(e)?ke(e):Re(e)}function st(e){return e}t.exports=it}(Fr,Fr.exports);const jr=x,Vr=B,Kr=Gt,Gr=Dr,Wr=Fr.exports;var qr=class{constructor(e){if(!Kr.isEncoded(e))throw new Error("Base58 string is invalid. Cannot construct Decoder.");this.base58=e}constructRootJSON(e){const r=Gr(jr.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=Vr.decode(o).toString("hex")),e[i]=o,e}),{})}constructAnchorsJSON(e){const t=Wr(jr.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}:${Gr(jr.chain[t].networks)[r[1]]}`}return`${e}:${Vr.decode(r[1]).toString("hex")}`}),"blink")))}constructPathJSON(e){const t=Gr(jr.path);return e.map((e=>({[t[e[0]]]:Vr.decode(e[1]).toString("hex")})))}decode(){const e=Kr.decode(this.base58),t=Vr.decode(e);return this.constructRootJSON(t)}};var Xr={Encoder:dr,Decoder:qr,Keymap:x};function zr(e){return Object.keys(p).map((e=>p[e])).find((t=>t.signatureValue===e))}function $r(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 zr(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 zr(i)}(r)}return null}function Yr(e,t){const r=e.findIndex((e=>e===t));r>-1&&e.splice(r,1)}var Jr={"@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"}]},Qr={"@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"}}},Zr={"@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"}}},en={"@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 tn(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}c["https://w3id.org/blockcerts/schema/2.0-alpha/context.json"]=Jr,c["https://www.blockcerts.org/schema/2.0-alpha/context.json"]=Jr,c["https://www.blockcerts.org/schema/3.0-alpha/context.json"]=Qr,c["https://w3id.org/blockcerts/schema/3.0-alpha/context.json"]=Qr,c["https://w3id.org/blockcerts/v3.0-alpha"]=Qr,c["https://www.blockcerts.org/schema/3.0-beta/context.json"]=Zr,c["https://w3id.org/blockcerts/schema/3.0-beta/context.json"]=Zr,c["https://w3id.org/blockcerts/v3.0-beta"]=Zr,c["https://w3id.org/security/suites/ed25519-2020/v1"]=en;class rn extends Error{constructor(e,t){super(t),this.stepCode=e}}var nn={locale:"en-US"},on={"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 sn(e,t){return e&&t?on[nn.locale]?on[nn.locale][e]?on[nn.locale][e][t]?on[nn.locale][e][t]||"":"[missing locale item data]":"[missing locale group data]":"[missing locale data]":""}var an=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 un(e,t=null,r=(e=>an(this,void 0,void 0,(function*(){return Promise})))){return an(this,void 0,void 0,(function*(){e["@context"].find((e=>{return(t=e)===Object(t)&&"@vocab"in e;var t}))||e["@context"].push({"@vocab":"http://fallback.org/"});const n=JSON.parse(JSON.stringify(e));if(Array.isArray(n.proof)){if(!t)throw new rn("computeLocalHash",sn("errors","noProofSpecified"));const e=n.proof.findIndex((e=>e.proofValue===t.proofValue));n.proof=n.proof.slice(0,e)}else delete n.proof;const i={algorithm:"URDNA2015",format:"application/nquads",documentLoader:function(e){return an(this,void 0,void 0,(function*(){return null!=r&&(yield r(e)),e in c?{contextUrl:null,document:c[e],documentUrl:e}:I.documentLoader(e)}))},safe:!1};let o;try{o=yield I.normalize(n,i)}catch(e){throw console.error(e),new rn("computeLocalHash",sn("errors","failedJsonLdNormalization"))}const s=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}(o);if(s)throw new rn("computeLocalHash",`${sn("errors","foundUnmappedFields")}: ${s.join(", ")}`);return T(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}(o))}))}var cn=d.Buffer;var fn=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 cn.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=cn.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=cn.from(t)),!cn.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")}}};fn("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");const hn=t,pn=e=>{const t=(e=>{const t=m.from(Object.assign(Object.assign({},e),{crv:"K-256"}),"jwk").toString("blk","public"),r=b.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&&0==(127&e[n-1])&&(n<=1||0==(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 Ln(e,t){Error.captureStackTrace&&Error.captureStackTrace(e,t)}function Mn(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 Hn(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 "+Mn(e)+", got"+(""!==r?" "+r:"")+(""!==n?" "+n:"")}function Cn(e,t,r){r=r||Rn(t),this.message=Hn(e,t,r),Ln(this,Cn),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 '),Hn('property "'+Mn(r)+o+Mn(e),n,i)}(e,r,t,n,i)):this.message='Unexpected property "'+t+'"',Ln(this,Cn),this.__label=r,this.__property=t,this.__type=e,this.__value=n,this.__valueTypeName=i}Cn.prototype=Object.create(Error.prototype),Cn.prototype.constructor=Cn,Dn.prototype=Object.create(Error.prototype),Dn.prototype.constructor=Cn;var Fn,jn,Vn={TfTypeError:Cn,TfPropertyTypeError:Dn,tfCustomError:function(e,t){return new Cn(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 Cn&&(e=new Dn(e.__type,t,r,e.__value,e.__valueTypeName)),Ln(e),e},tfJSON:Mn,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.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(`Wrong positive integer: ${e}`)}function Bi(e){if("boolean"!=typeof e)throw new Error(`Expected boolean, not ${e}`)}function Ri(e,...t){if(!((r=e)instanceof Uint8Array||null!=r&&"object"==typeof r&&"Uint8Array"===r.constructor.name))throw new Error("Expected Uint8Array");var r;if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array 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 Mi(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){Ri(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=void 0,Ui.number=xi,Ui.bool=Bi,Ui.bytes=Ri,Ui.hash=Li,Ui.exists=Mi,Ui.output=Hi;const Ci={number:xi,bool:Bi,bytes:Ri,hash:Li,exists:Mi,output:Hi};Ui.default=Ci;var Di={},Fi={};Object.defineProperty(Fi,"__esModule",{value:!0}),Fi.crypto=void 0,Fi.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,function(e){
|
|
2
2
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3
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.isLE=e.rotr=e.createView=e.u32=e.u8=void 0;const t=Fi;e.u8=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength);function r(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}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);if(e.rotr=(e,t)=>e<<32-t|e>>>t,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],!e.isLE)throw new Error("Non little-endian hardware is not supported");const n=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));e.bytesToHex=function(e){if(!r(e))throw new Error("Uint8Array expected");let t="";for(let r=0;r<e.length;r++)t+=n[e[r]];return t};const i={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function o(e){return e>=i._0&&e<=i._9?e-i._0:e>=i._A&&e<=i._F?e-(i._A-10):e>=i._a&&e<=i._f?e-(i._a-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=o(e.charCodeAt(i)),s=o(e.charCodeAt(i+1));if(void 0===r||void 0===s){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+s}return n};function s(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function a(e){if("string"==typeof e&&(e=s(e)),!r(e))throw new Error("expected Uint8Array, got "+typeof e);return 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=s,e.toBytes=a,e.concatBytes=function(...e){let t=0;for(let n=0;n<e.length;n++){const i=e[n];if(!r(i))throw new Error("Uint8Array expected");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 u={}.toString;e.checkOpts=function(e,t){if(void 0!==t&&"[object Object]"!==u.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(a(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(a(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(a(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")}}(Di),Object.defineProperty(Ni,"__esModule",{value:!0}),Ni.SHA2=void 0;const ji=Ui,Vi=Di;Ni.SHA2=class extends Vi.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,Vi.createView)(this.buffer)}update(e){(0,ji.exists)(this);const{view:t,buffer:r,blockLen:n}=this,i=(e=(0,Vi.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,Vi.createView)(e);for(;n<=i-o;o+=n)this.process(t,o)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,ji.exists)(this),(0,ji.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,Vi.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 Ki=Ni,Gi=Di,Wi=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),qi=Uint8Array.from({length:16},((e,t)=>t));let Xi=[qi],zi=[qi.map((e=>(9*e+5)%16))];for(let e=0;e<4;e++)for(let t of[Xi,zi])t.push(t[e].map((e=>Wi[e])));const $i=[[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))),Yi=Xi.map(((e,t)=>e.map((e=>$i[t][e])))),Ji=zi.map(((e,t)=>e.map((e=>$i[t][e])))),Qi=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),Zi=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]),eo=(e,t)=>e<<t|e>>>32-t;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 Ki.SHA2{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=Qi[e],l=Zi[e],d=Xi[e],y=zi[e],g=Yi[e],w=Ji[e];for(let t=0;t<16;t++){const n=eo(r+to(e,i,s,u)+ro[d[t]]+p,g[t])+f|0;r=f,f=u,u=0|eo(s,10),s=i,i=n}for(let e=0;e<16;e++){const r=eo(n+to(t,o,a,c)+ro[y[e]]+l,w[e])+h|0;n=h,h=c,c=0|eo(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,Gi.wrapConstructor)((()=>new no));var io={};Object.defineProperty(io,"__esModule",{value:!0}),io.sha1=void 0;const oo=Ni,so=Di,ao=(e,t)=>e<<t|e>>>32-t>>>0,uo=(e,t,r)=>e&t^e&r^t&r,co=new Uint32Array([1732584193,4023233417,2562383102,271733878,3285377520]),fo=new Uint32Array(80);class ho extends oo.SHA2{constructor(){super(64,20,8,!1),this.A=0|co[0],this.B=0|co[1],this.C=0|co[2],this.D=0|co[3],this.E=0|co[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)fo[r]=e.getUint32(t,!1);for(let e=16;e<80;e++)fo[e]=ao(fo[e-3]^fo[e-8]^fo[e-14]^fo[e-16],1);let{A:r,B:n,C:i,D:o,E:s}=this;for(let e=0;e<80;e++){let t,u;e<20?(t=(a=n)&i^~a&o,u=1518500249):e<40?(t=n^i^o,u=1859775393):e<60?(t=uo(n,i,o),u=2400959708):(t=n^i^o,u=3395469782);const c=ao(r,5)+t+s+u+fo[e]|0;s=o,o=i,i=ao(n,30),n=r,r=c}var a;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(){fo.fill(0)}destroy(){this.set(0,0,0,0,0),this.buffer.fill(0)}}io.sha1=(0,so.wrapConstructor)((()=>new ho));var po={};Object.defineProperty(po,"__esModule",{value:!0}),po.sha224=po.sha256=void 0;const lo=Ni,yo=Di,go=(e,t,r)=>e&t^e&r^t&r,wo=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]),mo=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),bo=new Uint32Array(64);class Eo extends lo.SHA2{constructor(){super(64,32,8,!1),this.A=0|mo[0],this.B=0|mo[1],this.C=0|mo[2],this.D=0|mo[3],this.E=0|mo[4],this.F=0|mo[5],this.G=0|mo[6],this.H=0|mo[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)bo[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=bo[e-15],r=bo[e-2],n=(0,yo.rotr)(t,7)^(0,yo.rotr)(t,18)^t>>>3,i=(0,yo.rotr)(r,17)^(0,yo.rotr)(r,19)^r>>>10;bo[e]=i+bo[e-7]+n+bo[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,yo.rotr)(s,6)^(0,yo.rotr)(s,11)^(0,yo.rotr)(s,25))+((f=s)&a^~f&u)+wo[e]+bo[e]|0,h=((0,yo.rotr)(r,2)^(0,yo.rotr)(r,13)^(0,yo.rotr)(r,22))+go(r,n,i)|0;c=u,u=a,a=s,s=o+t|0,o=i,i=n,n=r,r=t+h|0}var f;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(){bo.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class _o extends Eo{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}}po.sha256=(0,yo.wrapConstructor)((()=>new Eo)),po.sha224=(0,yo.wrapConstructor)((()=>new _o)),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=po;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 vo=E,{sha256:So}=po,Io=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),vo.encode(o,i)},decode:function(e){var r=t(vo.decode(e));if(!r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(e){var r=vo.decodeUnsafe(e);if(r)return t(r)}}};var To=Io((function(e){return So(So(e))}));Object.defineProperty(Ai,"__esModule",{value:!0}),Ai.p2pkh=void 0;const ko=Pi,Ao=yn,Po=mn,Oo=Pn,No=ai,Uo=To,xo=Po.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,Oo.typeforce)({network:Oo.typeforce.maybe(Oo.typeforce.Object),address:Oo.typeforce.maybe(Oo.typeforce.String),hash:Oo.typeforce.maybe(Oo.typeforce.BufferN(20)),output:Oo.typeforce.maybe(Oo.typeforce.BufferN(25)),pubkey:Oo.typeforce.maybe(Oo.isPoint),signature:Oo.typeforce.maybe(Po.isCanonicalScriptSignature),input:Oo.typeforce.maybe(Oo.typeforce.Buffer)},e);const n=No.value((()=>{const r=t.from(Uo.decode(e.address));return{version:r.readUInt8(0),hash:r.slice(1)}})),i=No.value((()=>Po.decompile(e.input))),o=e.network||Ao.bitcoin,s={name:"p2pkh",network:o};if(No.prop(s,"address",(()=>{if(!s.hash)return;const e=t.allocUnsafe(21);return e.writeUInt8(o.pubKeyHash,0),s.hash.copy(e,1),Uo.encode(e)})),No.prop(s,"hash",(()=>e.output?e.output.slice(3,23):e.address?n().hash:e.pubkey||s.pubkey?ko.hash160(e.pubkey||s.pubkey):void 0)),No.prop(s,"output",(()=>{if(s.hash)return Po.compile([xo.OP_DUP,xo.OP_HASH160,s.hash,xo.OP_EQUALVERIFY,xo.OP_CHECKSIG])})),No.prop(s,"pubkey",(()=>{if(e.input)return i()[1]})),No.prop(s,"signature",(()=>{if(e.input)return i()[0]})),No.prop(s,"input",(()=>{if(e.pubkey&&e.signature)return Po.compile([e.signature,e.pubkey])})),No.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]!==xo.OP_DUP||e.output[1]!==xo.OP_HASH160||20!==e.output[2]||e.output[23]!==xo.OP_EQUALVERIFY||e.output[24]!==xo.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=ko.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(!Po.isCanonicalScriptSignature(t[0]))throw new TypeError("Input has invalid signature");if(!(0,Oo.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=ko.hash160(t[1]);if(r.length>0&&!r.equals(n))throw new TypeError("Hash mismatch")}}return Object.assign(s,e)};var Bo={};Object.defineProperty(Bo,"__esModule",{value:!0}),Bo.p2sh=void 0;const Ro=Pi,Lo=yn,Mo=mn,Ho=Pn,Co=ai,Do=To,Fo=Mo.OPS;Bo.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,Ho.typeforce)({network:Ho.typeforce.maybe(Ho.typeforce.Object),address:Ho.typeforce.maybe(Ho.typeforce.String),hash:Ho.typeforce.maybe(Ho.typeforce.BufferN(20)),output:Ho.typeforce.maybe(Ho.typeforce.BufferN(23)),redeem:Ho.typeforce.maybe({network:Ho.typeforce.maybe(Ho.typeforce.Object),output:Ho.typeforce.maybe(Ho.typeforce.Buffer),input:Ho.typeforce.maybe(Ho.typeforce.Buffer),witness:Ho.typeforce.maybe(Ho.typeforce.arrayOf(Ho.typeforce.Buffer))}),input:Ho.typeforce.maybe(Ho.typeforce.Buffer),witness:Ho.typeforce.maybe(Ho.typeforce.arrayOf(Ho.typeforce.Buffer))},e);let i=e.network;i||(i=e.redeem&&e.redeem.network||Lo.bitcoin);const o={network:i},s=Co.value((()=>{const r=t.from(Do.decode(e.address));return{version:r.readUInt8(0),hash:r.slice(1)}})),a=Co.value((()=>Mo.decompile(e.input))),u=Co.value((()=>{const r=a(),n=r[r.length-1];return{network:i,output:n===Fo.OP_FALSE?t.from([]):n,input:Mo.compile(r.slice(0,-1)),witness:e.witness||[]}}));if(Co.prop(o,"address",(()=>{if(!o.hash)return;const e=t.allocUnsafe(21);return e.writeUInt8(o.network.scriptHash,0),o.hash.copy(e,1),Do.encode(e)})),Co.prop(o,"hash",(()=>e.output?e.output.slice(2,22):e.address?s().hash:o.redeem&&o.redeem.output?Ro.hash160(o.redeem.output):void 0)),Co.prop(o,"output",(()=>{if(o.hash)return Mo.compile([Fo.OP_HASH160,o.hash,Fo.OP_EQUAL])})),Co.prop(o,"redeem",(()=>{if(e.input)return u()})),Co.prop(o,"input",(()=>{if(e.redeem&&e.redeem.input&&e.redeem.output)return Mo.compile([].concat(Mo.decompile(e.redeem.input),e.redeem.output))})),Co.prop(o,"witness",(()=>o.redeem&&o.redeem.witness?o.redeem.witness:o.input?[]:void 0)),Co.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]!==Fo.OP_HASH160||20!==e.output[1]||e.output[22]!==Fo.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=Mo.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(Mo.countNonPushOnlyOPs(t)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const r=Ro.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=Mo.decompile(e.input);if(!Mo.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 jo={},Vo={};Object.defineProperty(Vo,"__esModule",{value:!0}),Vo.bech32m=Vo.bech32=void 0;const Ko="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Go={};for(let e=0;e<32;e++){const t=Ko.charAt(e);Go[t]=e}function Wo(e){const t=e>>25;return(33554431&e)<<5^996825010&-(t>>0&1)^642813549&-(t>>1&1)^513874426&-(t>>2&1)^1027748829&-(t>>3&1)^705979059&-(t>>4&1)}function qo(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=Wo(t)^n>>5}t=Wo(t);for(let r=0;r<e.length;++r){const n=e.charCodeAt(r);t=Wo(t)^31&n}return t}function Xo(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 zo(e){return Xo(e,8,5,!0)}function $o(e){const t=Xo(e,5,8,!1);if(Array.isArray(t))return t}function Yo(e){const t=Xo(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function Jo(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=qo(s);if("string"==typeof u)return u;const c=[];for(let e=0;e<a.length;++e){const t=a.charAt(e),r=Go[t];if(void 0===r)return"Unknown character "+t;u=Wo(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=qo(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!=0)throw new Error("Non 5-bit word");i=Wo(i)^t,o+=Ko.charAt(t)}for(let e=0;e<6;++e)i=Wo(i);i^=t;for(let e=0;e<6;++e){o+=Ko.charAt(i>>5*(5-e)&31)}return o},toWords:zo,fromWordsUnsafe:$o,fromWords:Yo}}Vo.bech32=Jo("bech32"),Vo.bech32m=Jo("bech32m"),Object.defineProperty(jo,"__esModule",{value:!0}),jo.p2wpkh=void 0;const Qo=Pi,Zo=yn,es=mn,ts=Pn,rs=ai,ns=Vo,is=es.OPS,os=t.alloc(0);jo.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,ts.typeforce)({address:ts.typeforce.maybe(ts.typeforce.String),hash:ts.typeforce.maybe(ts.typeforce.BufferN(20)),input:ts.typeforce.maybe(ts.typeforce.BufferN(0)),network:ts.typeforce.maybe(ts.typeforce.Object),output:ts.typeforce.maybe(ts.typeforce.BufferN(22)),pubkey:ts.typeforce.maybe(ts.isPoint),signature:ts.typeforce.maybe(es.isCanonicalScriptSignature),witness:ts.typeforce.maybe(ts.typeforce.arrayOf(ts.typeforce.Buffer))},e);const n=rs.value((()=>{const r=ns.bech32.decode(e.address),n=r.words.shift(),i=ns.bech32.fromWords(r.words);return{version:n,prefix:r.prefix,data:t.from(i)}})),i=e.network||Zo.bitcoin,o={name:"p2wpkh",network:i};if(rs.prop(o,"address",(()=>{if(!o.hash)return;const e=ns.bech32.toWords(o.hash);return e.unshift(0),ns.bech32.encode(i.bech32,e)})),rs.prop(o,"hash",(()=>e.output?e.output.slice(2,22):e.address?n().data:e.pubkey||o.pubkey?Qo.hash160(e.pubkey||o.pubkey):void 0)),rs.prop(o,"output",(()=>{if(o.hash)return es.compile([is.OP_0,o.hash])})),rs.prop(o,"pubkey",(()=>e.pubkey?e.pubkey:e.witness?e.witness[1]:void 0)),rs.prop(o,"signature",(()=>{if(e.witness)return e.witness[0]})),rs.prop(o,"input",(()=>{if(o.witness)return os})),rs.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]!==is.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=Qo.hash160(e.pubkey);if(r.length>0&&!r.equals(t))throw new TypeError("Hash mismatch");if(r=t,!(0,ts.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(!es.isCanonicalScriptSignature(e.witness[0]))throw new TypeError("Witness has invalid signature");if(!(0,ts.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=Qo.hash160(e.witness[1]);if(r.length>0&&!r.equals(t))throw new TypeError("Hash mismatch")}}return Object.assign(o,e)};var ss={};Object.defineProperty(ss,"__esModule",{value:!0}),ss.p2wsh=void 0;const as=Pi,us=yn,cs=mn,fs=Pn,hs=ai,ps=Vo,ls=cs.OPS,ds=t.alloc(0);function ys(e){return!(!r(e)||65!==e.length||4!==e[0]||!(0,fs.isPoint)(e))}ss.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,fs.typeforce)({network:fs.typeforce.maybe(fs.typeforce.Object),address:fs.typeforce.maybe(fs.typeforce.String),hash:fs.typeforce.maybe(fs.typeforce.BufferN(32)),output:fs.typeforce.maybe(fs.typeforce.BufferN(34)),redeem:fs.typeforce.maybe({input:fs.typeforce.maybe(fs.typeforce.Buffer),network:fs.typeforce.maybe(fs.typeforce.Object),output:fs.typeforce.maybe(fs.typeforce.Buffer),witness:fs.typeforce.maybe(fs.typeforce.arrayOf(fs.typeforce.Buffer))}),input:fs.typeforce.maybe(fs.typeforce.BufferN(0)),witness:fs.typeforce.maybe(fs.typeforce.arrayOf(fs.typeforce.Buffer))},e);const n=hs.value((()=>{const r=ps.bech32.decode(e.address),n=r.words.shift(),i=ps.bech32.fromWords(r.words);return{version:n,prefix:r.prefix,data:t.from(i)}})),i=hs.value((()=>cs.decompile(e.redeem.input)));let o=e.network;o||(o=e.redeem&&e.redeem.network||us.bitcoin);const s={network:o};if(hs.prop(s,"address",(()=>{if(!s.hash)return;const e=ps.bech32.toWords(s.hash);return e.unshift(0),ps.bech32.encode(o.bech32,e)})),hs.prop(s,"hash",(()=>e.output?e.output.slice(2):e.address?n().data:s.redeem&&s.redeem.output?as.sha256(s.redeem.output):void 0)),hs.prop(s,"output",(()=>{if(s.hash)return cs.compile([ls.OP_0,s.hash])})),hs.prop(s,"redeem",(()=>{if(e.witness)return{output:e.witness[e.witness.length-1],input:ds,witness:e.witness.slice(0,-1)}})),hs.prop(s,"input",(()=>{if(s.witness)return ds})),hs.prop(s,"witness",(()=>{if(e.redeem&&e.redeem.input&&e.redeem.input.length>0&&e.redeem.output&&e.redeem.output.length>0){const t=cs.toStack(i());return s.redeem=Object.assign({witness:t},e.redeem),s.redeem.input=ds,[].concat(t,e.redeem.output)}if(e.redeem&&e.redeem.output&&e.redeem.witness)return[].concat(e.redeem.witness,e.redeem.output)})),hs.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]!==ls.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=cs.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(cs.countNonPushOnlyOPs(t)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const n=as.sha256(e.redeem.output);if(r.length>0&&!r.equals(n))throw new TypeError("Hash mismatch");r=n}if(e.redeem.input&&!cs.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(ys)||e.redeem.output&&(cs.decompile(e.redeem.output)||[]).some(ys))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(ys)||(cs.decompile(t)||[]).some(ys))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(s,e)};var gs={},ws={};Object.defineProperty(ws,"__esModule",{value:!0}),ws.getEccLib=ws.initEccLib=void 0;const ms={};ws.initEccLib=function(e){var r;e?e!==ms.eccLib&&(Es("function"==typeof(r=e).isXOnlyPoint),Es(r.isXOnlyPoint(bs("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),Es(r.isXOnlyPoint(bs("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))),Es(r.isXOnlyPoint(bs("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))),Es(r.isXOnlyPoint(bs("0000000000000000000000000000000000000000000000000000000000000001"))),Es(!r.isXOnlyPoint(bs("0000000000000000000000000000000000000000000000000000000000000000"))),Es(!r.isXOnlyPoint(bs("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))),Es("function"==typeof r.xOnlyPointAddTweak),_s.forEach((e=>{const n=r.xOnlyPointAddTweak(bs(e.pubkey),bs(e.tweak));null===e.result?Es(null===n):(Es(null!==n),Es(n.parity===e.parity),Es(t.from(n.xOnlyPubkey).equals(bs(e.result))))})),ms.eccLib=e):ms.eccLib=e},ws.getEccLib=function(){if(!ms.eccLib)throw new Error("No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance");return ms.eccLib};const bs=e=>t.from(e,"hex");function Es(e){if(!e)throw new Error("ecc library invalid")}const _s=[{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 vs={},Ss={},Is=d.Buffer,Ts=9007199254740991;function ks(e){if(e<0||e>Ts||e%1!=0)throw new RangeError("value out of range")}function As(e){return ks(e),e<253?1:e<=65535?3:e<=4294967295?5:9}var Ps={encode:function e(t,r,n){if(ks(t),r||(r=Is.allocUnsafe(As(t))),!Is.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(!Is.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 ks(o),o},encodingLength:As};Object.defineProperty(Ss,"__esModule",{value:!0}),Ss.BufferReader=Ss.BufferWriter=Ss.cloneBuffer=Ss.reverseBuffer=Ss.writeUInt64LE=Ss.readUInt64LE=Ss.varuint=void 0;const Os=Pn,{typeforce:Ns}=Os,Us=Ps;function xs(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 Bs(e,t){const r=e.readUInt32LE(t);let n=e.readUInt32LE(t+4);return n*=4294967296,xs(n+r,9007199254740991),n+r}function Rs(e,t,r){return xs(t,9007199254740991),e.writeInt32LE(-1&t,r),e.writeUInt32LE(Math.floor(t/4294967296),r+4),r+8}Ss.varuint=Us,Ss.readUInt64LE=Bs,Ss.writeUInt64LE=Rs,Ss.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},Ss.cloneBuffer=function(e){const r=t.allocUnsafe(e.length);return e.copy(r),r};class Ls{static withCapacity(e){return new Ls(t.alloc(e))}constructor(e,t=0){this.buffer=e,this.offset=t,Ns(Os.tuple(Os.Buffer,Os.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=Rs(this.buffer,e,this.offset)}writeVarInt(e){Us.encode(e,this.buffer,this.offset),this.offset+=Us.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}`)}}Ss.BufferWriter=Ls;Ss.BufferReader=class{constructor(e,t=0){this.buffer=e,this.offset=t,Ns(Os.tuple(Os.Buffer,Os.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=Bs(this.buffer,this.offset);return this.offset+=8,e}readVarInt(){const e=Us.decode(this.buffer,this.offset);return this.offset+=Us.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=_,r=ws,n=Pi,i=Ss,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}}(vs),Object.defineProperty(gs,"__esModule",{value:!0}),gs.p2tr=void 0;const Ms=_,Hs=yn,Cs=mn,Ds=Pn,Fs=ws,js=vs,Vs=ai,Ks=Vo,Gs=Cs.OPS;gs.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,Ds.typeforce)({address:Ds.typeforce.maybe(Ds.typeforce.String),input:Ds.typeforce.maybe(Ds.typeforce.BufferN(0)),network:Ds.typeforce.maybe(Ds.typeforce.Object),output:Ds.typeforce.maybe(Ds.typeforce.BufferN(34)),internalPubkey:Ds.typeforce.maybe(Ds.typeforce.BufferN(32)),hash:Ds.typeforce.maybe(Ds.typeforce.BufferN(32)),pubkey:Ds.typeforce.maybe(Ds.typeforce.BufferN(32)),signature:Ds.typeforce.maybe(Ds.typeforce.anyOf(Ds.typeforce.BufferN(64),Ds.typeforce.BufferN(65))),witness:Ds.typeforce.maybe(Ds.typeforce.arrayOf(Ds.typeforce.Buffer)),scriptTree:Ds.typeforce.maybe(Ds.isTaptree),redeem:Ds.typeforce.maybe({output:Ds.typeforce.maybe(Ds.typeforce.Buffer),redeemVersion:Ds.typeforce.maybe(Ds.typeforce.Number),witness:Ds.typeforce.maybe(Ds.typeforce.arrayOf(Ds.typeforce.Buffer))}),redeemVersion:Ds.typeforce.maybe(Ds.typeforce.Number)},e);const r=Vs.value((()=>{const t=Ks.bech32m.decode(e.address),r=t.words.shift(),n=Ks.bech32m.fromWords(t.words);return{version:r,prefix:t.prefix,data:Ms.Buffer.from(n)}})),n=Vs.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=Vs.value((()=>e.scriptTree?(0,js.toHashTree)(e.scriptTree):e.hash?{hash:e.hash}:void 0)),o=e.network||Hs.bitcoin,s={name:"p2tr",network:o};if(Vs.prop(s,"address",(()=>{if(!s.pubkey)return;const e=Ks.bech32m.toWords(s.pubkey);return e.unshift(1),Ks.bech32m.encode(o.bech32,e)})),Vs.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]&Ds.TAPLEAF_VERSION_MASK,n=t[t.length-2],i=(0,js.tapleafHash)({output:n,version:r});return(0,js.rootHashFromPath)(e,i)}return null})),Vs.prop(s,"output",(()=>{if(s.pubkey)return Cs.compile([Gs.OP_1,s.pubkey])})),Vs.prop(s,"redeemVersion",(()=>e.redeemVersion?e.redeemVersion:e.redeem&&void 0!==e.redeem.redeemVersion&&null!==e.redeem.redeemVersion?e.redeem.redeemVersion:js.LEAF_VERSION_TAPSCRIPT)),Vs.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]&Ds.TAPLEAF_VERSION_MASK}})),Vs.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,js.tweakKey)(s.internalPubkey,s.hash);if(e)return e.x}})),Vs.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})),Vs.prop(s,"signature",(()=>{if(e.signature)return e.signature;const t=n();return t&&1===t.length?t[0]:void 0})),Vs.prop(s,"witness",(()=>{if(e.witness)return e.witness;const t=i();if(t&&e.redeem&&e.redeem.output&&e.internalPubkey){const r=(0,js.tapleafHash)({output:e.redeem.output,version:s.redeemVersion}),n=(0,js.findScriptPath)(t,r);if(!n)return;const i=(0,js.tweakKey)(e.internalPubkey,t.hash);if(!i)return;const o=Ms.Buffer.concat([Ms.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=Ms.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]!==Gs.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,js.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,Fs.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,js.tapleafHash)({output:e.redeem.output,version:s.redeemVersion});if(!(0,js.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===Cs.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,Fs.getEccLib)().isXOnlyPoint(i))throw new TypeError("Invalid internalPubkey for p2tr witness");const o=r[0]&Ds.TAPLEAF_VERSION_MASK,s=u[u.length-2],a=(0,js.tapleafHash)({output:s,version:o}),c=(0,js.rootHashFromPath)(r,a),f=(0,js.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=Bo;Object.defineProperty(e,"p2sh",{enumerable:!0,get:function(){return o.p2sh}});const s=jo;Object.defineProperty(e,"p2wpkh",{enumerable:!0,get:function(){return s.p2wpkh}});const a=ss;Object.defineProperty(e,"p2wsh",{enumerable:!0,get:function(){return a.p2wsh}});const u=gs;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 Ws=yn,qs=gn,Xs=mn,zs=Pn,$s=Vo,Ys=To,Js=40,Qs=2,Zs=16,ea=2,ta=80,ra="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 na(e){const r=t.from(Ys.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 ia(e){let r,n;try{r=$s.bech32.decode(e)}catch(e){}if(r){if(n=r.words[0],0!==n)throw new TypeError(e+" uses wrong encoding")}else if(r=$s.bech32m.decode(e),n=r.words[0],0===n)throw new TypeError(e+" uses wrong encoding");const i=$s.bech32.fromWords(r.words.slice(1));return{version:n,prefix:r.prefix,data:t.from(i)}}function oa(e,t,r){const n=$s.bech32.toWords(e);return n.unshift(t),0===t?$s.bech32.encode(r,n):$s.bech32m.encode(r,n)}dn.fromBase58Check=na,dn.fromBech32=ia,dn.toBase58Check=function(e,r){(0,zs.typeforce)((0,zs.tuple)(zs.Hash160bit,zs.UInt8),arguments);const n=t.allocUnsafe(21);return n.writeUInt8(r,0),e.copy(n,1),Ys.encode(n)},dn.toBech32=oa,dn.fromOutputScript=function(e,t){t=t||Ws.bitcoin;try{return qs.p2pkh({output:e,network:t}).address}catch(e){}try{return qs.p2sh({output:e,network:t}).address}catch(e){}try{return qs.p2wpkh({output:e,network:t}).address}catch(e){}try{return qs.p2wsh({output:e,network:t}).address}catch(e){}try{return qs.p2tr({output:e,network:t}).address}catch(e){}try{return function(e,t){const r=e.slice(2);if(r.length<Qs||r.length>Js)throw new TypeError("Invalid program length for segwit address");const n=e[0]-ta;if(n<ea||n>Zs)throw new TypeError("Invalid version for segwit address");if(e[1]!==r.length)throw new TypeError("Invalid script for segwit address");return console.warn(ra),oa(r,n,t.bech32)}(e,t)}catch(e){}throw new Error(Xs.toASM(e)+" has no matching Address")},dn.toOutputScript=function(e,t){let r,n;t=t||Ws.bitcoin;try{r=na(e)}catch(e){}if(r){if(r.version===t.pubKeyHash)return qs.p2pkh({hash:r.hash}).output;if(r.version===t.scriptHash)return qs.p2sh({hash:r.hash}).output}else{try{n=ia(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 qs.p2wpkh({hash:n.data}).output;if(32===n.data.length)return qs.p2wsh({hash:n.data}).output}else if(1===n.version){if(32===n.data.length)return qs.p2tr({pubkey:n.data}).output}else if(n.version>=ea&&n.version<=Zs&&n.data.length>=Qs&&n.data.length<=Js)return console.warn(ra),Xs.compile([n.version+ta,n.data])}}throw new Error(e+" has no matching Script")};var sa={},aa={};Object.defineProperty(aa,"__esModule",{value:!0}),aa.fastMerkleRoot=void 0,aa.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 ua={};Object.defineProperty(ua,"__esModule",{value:!0}),ua.Transaction=void 0;const ca=Ss,fa=Pi,ha=mn,pa=mn,la=Pn,{typeforce:da}=la;function ya(e){const t=e.length;return ca.varuint.encodingLength(t)+t}const ga=t.allocUnsafe(0),wa=[],ma=t.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),ba=t.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),Ea=t.from("ffffffffffffffff","hex"),_a={script:ga,valueBuffer:Ea};class va{constructor(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}static fromBuffer(e,t){const r=new ca.BufferReader(e),n=new va;n.version=r.readInt32();const i=r.readUInt8(),o=r.readUInt8();let s=!1;i===va.ADVANCED_TRANSACTION_MARKER&&o===va.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:wa});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 va.fromBuffer(t.from(e,"hex"),!1)}static isCoinbaseHash(e){da(la.Hash256bit,e);for(let t=0;t<32;++t)if(0!==e[t])return!1;return!0}isCoinbase(){return 1===this.ins.length&&va.isCoinbaseHash(this.ins[0].hash)}addInput(e,t,r,n){return da(la.tuple(la.Hash256bit,la.UInt32,la.maybe(la.UInt32),la.maybe(la.Buffer)),arguments),la.Null(r)&&(r=va.DEFAULT_SEQUENCE),this.ins.push({hash:e,index:t,script:n||ga,sequence:r,witness:wa})-1}addOutput(e,t){return da(la.tuple(la.Buffer,la.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)+ca.varuint.encodingLength(this.ins.length)+ca.varuint.encodingLength(this.outs.length)+this.ins.reduce(((e,t)=>e+40+ya(t.script)),0)+this.outs.reduce(((e,t)=>e+8+ya(t.script)),0)+(t?this.ins.reduce(((e,t)=>e+function(e){const t=e.length;return ca.varuint.encodingLength(t)+e.reduce(((e,t)=>e+ya(t)),0)}(t.witness)),0):0)}clone(){const e=new va;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(da(la.tuple(la.UInt32,la.Buffer,la.Number),arguments),e>=this.ins.length)return ba;const i=ha.compile(ha.decompile(r).filter((e=>e!==pa.OPS.OP_CODESEPARATOR))),o=this.clone();if((31&n)===va.SIGHASH_NONE)o.outs=[],o.ins.forEach(((t,r)=>{r!==e&&(t.sequence=0)}));else if((31&n)===va.SIGHASH_SINGLE){if(e>=this.outs.length)return ba;o.outs.length=e+1;for(let t=0;t<e;t++)o.outs[t]=_a;o.ins.forEach(((t,r)=>{r!==e&&(t.sequence=0)}))}n&va.SIGHASH_ANYONECANPAY?(o.ins=[o.ins[e]],o.ins[0].script=i):(o.ins.forEach((e=>{e.script=ga})),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),fa.hash256(s)}hashForWitnessV1(e,r,n,i,o,s){if(da(la.tuple(la.UInt32,da.arrayOf(la.Buffer),da.arrayOf(la.Satoshi),la.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===va.SIGHASH_DEFAULT?va.SIGHASH_ALL:i&va.SIGHASH_OUTPUT_MASK,u=(i&va.SIGHASH_INPUT_MASK)===va.SIGHASH_ANYONECANPAY,c=a===va.SIGHASH_NONE,f=a===va.SIGHASH_SINGLE;let h=ga,p=ga,l=ga,d=ga,y=ga;if(!u){let e=ca.BufferWriter.withCapacity(36*this.ins.length);this.ins.forEach((t=>{e.writeSlice(t.hash),e.writeUInt32(t.index)})),h=fa.sha256(e.end()),e=ca.BufferWriter.withCapacity(8*this.ins.length),n.forEach((t=>e.writeUInt64(t))),p=fa.sha256(e.end()),e=ca.BufferWriter.withCapacity(r.map(ya).reduce(((e,t)=>e+t))),r.forEach((t=>e.writeVarSlice(t))),l=fa.sha256(e.end()),e=ca.BufferWriter.withCapacity(4*this.ins.length),this.ins.forEach((t=>e.writeUInt32(t.sequence))),d=fa.sha256(e.end())}if(c||f){if(f&&e<this.outs.length){const t=this.outs[e],r=ca.BufferWriter.withCapacity(8+ya(t.script));r.writeUInt64(t.value),r.writeVarSlice(t.script),y=fa.sha256(r.end())}}else{const e=this.outs.map((e=>8+ya(e.script))).reduce(((e,t)=>e+t)),t=ca.BufferWriter.withCapacity(e);this.outs.forEach((e=>{t.writeUInt64(e.value),t.writeVarSlice(e.script)})),y=fa.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=ca.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=ca.BufferWriter.withCapacity(ya(s));e.writeVarSlice(s),m.writeSlice(fa.sha256(e.end()))}return f&&m.writeSlice(y),o&&(m.writeSlice(o),m.writeUInt8(0),m.writeUInt32(4294967295)),fa.taggedHash("TapSighash",t.concat([t.from([0]),m.end()]))}hashForWitnessV0(e,r,n,i){da(la.tuple(la.UInt32,la.Buffer,la.Satoshi,la.UInt32),arguments);let o,s=t.from([]),a=ma,u=ma,c=ma;if(i&va.SIGHASH_ANYONECANPAY||(s=t.allocUnsafe(36*this.ins.length),o=new ca.BufferWriter(s,0),this.ins.forEach((e=>{o.writeSlice(e.hash),o.writeUInt32(e.index)})),u=fa.hash256(s)),i&va.SIGHASH_ANYONECANPAY||(31&i)===va.SIGHASH_SINGLE||(31&i)===va.SIGHASH_NONE||(s=t.allocUnsafe(4*this.ins.length),o=new ca.BufferWriter(s,0),this.ins.forEach((e=>{o.writeUInt32(e.sequence)})),c=fa.hash256(s)),(31&i)!==va.SIGHASH_SINGLE&&(31&i)!==va.SIGHASH_NONE){const e=this.outs.reduce(((e,t)=>e+8+ya(t.script)),0);s=t.allocUnsafe(e),o=new ca.BufferWriter(s,0),this.outs.forEach((e=>{o.writeUInt64(e.value),o.writeVarSlice(e.script)})),a=fa.hash256(s)}else if((31&i)===va.SIGHASH_SINGLE&&e<this.outs.length){const r=this.outs[e];s=t.allocUnsafe(8+ya(r.script)),o=new ca.BufferWriter(s,0),o.writeUInt64(r.value),o.writeVarSlice(r.script),a=fa.hash256(s)}s=t.allocUnsafe(156+ya(r)),o=new ca.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),fa.hash256(s)}getHash(e){return e&&this.isCoinbase()?t.alloc(32,0):fa.hash256(this.__toBuffer(void 0,void 0,e))}getId(){return(0,ca.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){da(la.tuple(la.Number,la.Buffer),arguments),this.ins[e].script=t}setWitness(e,t){da(la.tuple(la.Number,[la.Buffer]),arguments),this.ins[e].witness=t}__toBuffer(e,r,n=!1){e||(e=t.allocUnsafe(this.byteLength(n)));const i=new ca.BufferWriter(e,r||0);i.writeInt32(this.version);const o=n&&this.hasWitnesses();return o&&(i.writeUInt8(va.ADVANCED_TRANSACTION_MARKER),i.writeUInt8(va.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}}ua.Transaction=va,va.DEFAULT_SEQUENCE=4294967295,va.SIGHASH_DEFAULT=0,va.SIGHASH_ALL=1,va.SIGHASH_NONE=2,va.SIGHASH_SINGLE=3,va.SIGHASH_ANYONECANPAY=128,va.SIGHASH_OUTPUT_MASK=3,va.SIGHASH_INPUT_MASK=128,va.ADVANCED_TRANSACTION_MARKER=0,va.ADVANCED_TRANSACTION_FLAG=1,Object.defineProperty(sa,"__esModule",{value:!0}),sa.Block=void 0;const Sa=Ss,Ia=Pi,Ta=aa,ka=ua,Aa=Pn,{typeforce:Pa}=Aa,Oa=new TypeError("Cannot compute merkle root for zero transactions"),Na=new TypeError("Cannot compute witness commit for non-segwit block");class Ua{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 Sa.BufferReader(e),r=new Ua;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=ka.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 Ua.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(Pa([{getHash:Aa.Function}],e),0===e.length)throw Oa;if(r&&!xa(e))throw Na;const n=e.map((e=>e.getHash(r))),i=(0,Ta.fastMerkleRoot)(n,Ia.hash256);return r?Ia.hash256(t.concat([i,e[0].ins[0].witness[0]])):i}getWitnessCommit(){if(!xa(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+Sa.varuint.encodingLength(this.transactions.length)+this.transactions.reduce(((e,r)=>e+r.byteLength(t)),0)}getHash(){return Ia.hash256(this.toBuffer(!0))}getId(){return(0,Sa.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 Sa.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||(Sa.varuint.encode(this.transactions.length,r,n.offset),n.offset+=Sa.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,Sa.reverseBuffer)(this.getHash()),t=Ua.calculateTarget(this.bits);return e.compare(t)<=0}__checkMerkleRoot(){if(!this.transactions)throw Oa;const e=Ua.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(e)}__checkWitnessCommit(){if(!this.transactions)throw Oa;if(!this.hasWitnessCommit())throw Na;const e=Ua.calculateMerkleRoot(this.transactions,!0);return 0===this.witnessCommit.compare(e)}}function xa(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}sa.Block=Ua;var Ba={},Ra={},La={},Ma={},Ha={},Ca={},Da={};!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"]}(Da);var Fa={};Object.defineProperty(Fa,"__esModule",{value:!0});const ja=Da;Fa.decode=function(e){if(e.key[0]!==ja.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},Fa.encode=function(e){const r=t.from([ja.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}},Fa.expected="{ masterFingerprint: Buffer; extendedPubkey: Buffer; path: string; }",Fa.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+'?)*$/)},Fa.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 Va={};Object.defineProperty(Va,"__esModule",{value:!0});const Ka=Da;Va.encode=function(e){return{key:t.from([Ka.GlobalTypes.UNSIGNED_TX]),value:e.toBuffer()}};var Ga={};Object.defineProperty(Ga,"__esModule",{value:!0});const Wa=Da;Ga.decode=function(e){if(e.key[0]!==Wa.InputTypes.FINAL_SCRIPTSIG)throw new Error("Decode Error: could not decode finalScriptSig with key 0x"+e.key.toString("hex"));return e.value},Ga.encode=function(e){return{key:t.from([Wa.InputTypes.FINAL_SCRIPTSIG]),value:e}},Ga.expected="Buffer",Ga.check=function(e){return r(e)},Ga.canAdd=function(e,t){return!!e&&!!t&&void 0===e.finalScriptSig};var qa={};Object.defineProperty(qa,"__esModule",{value:!0});const Xa=Da;qa.decode=function(e){if(e.key[0]!==Xa.InputTypes.FINAL_SCRIPTWITNESS)throw new Error("Decode Error: could not decode finalScriptWitness with key 0x"+e.key.toString("hex"));return e.value},qa.encode=function(e){return{key:t.from([Xa.InputTypes.FINAL_SCRIPTWITNESS]),value:e}},qa.expected="Buffer",qa.check=function(e){return r(e)},qa.canAdd=function(e,t){return!!e&&!!t&&void 0===e.finalScriptWitness};var za={};Object.defineProperty(za,"__esModule",{value:!0});const $a=Da;za.decode=function(e){if(e.key[0]!==$a.InputTypes.NON_WITNESS_UTXO)throw new Error("Decode Error: could not decode nonWitnessUtxo with key 0x"+e.key.toString("hex"));return e.value},za.encode=function(e){return{key:t.from([$a.InputTypes.NON_WITNESS_UTXO]),value:e}},za.expected="Buffer",za.check=function(e){return r(e)},za.canAdd=function(e,t){return!!e&&!!t&&void 0===e.nonWitnessUtxo};var Ya={};Object.defineProperty(Ya,"__esModule",{value:!0});const Ja=Da;Ya.decode=function(e){if(e.key[0]!==Ja.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}},Ya.encode=function(e){const r=t.from([Ja.InputTypes.PARTIAL_SIG]);return{key:t.concat([r,e.pubkey]),value:e.signature}},Ya.expected="{ pubkey: Buffer; signature: Buffer; }",Ya.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)},Ya.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 Qa={};Object.defineProperty(Qa,"__esModule",{value:!0});const Za=Da;Qa.decode=function(e){if(e.key[0]!==Za.InputTypes.POR_COMMITMENT)throw new Error("Decode Error: could not decode porCommitment with key 0x"+e.key.toString("hex"));return e.value.toString("utf8")},Qa.encode=function(e){return{key:t.from([Za.InputTypes.POR_COMMITMENT]),value:t.from(e,"utf8")}},Qa.expected="string",Qa.check=function(e){return"string"==typeof e},Qa.canAdd=function(e,t){return!!e&&!!t&&void 0===e.porCommitment};var eu={};Object.defineProperty(eu,"__esModule",{value:!0});const tu=Da;eu.decode=function(e){if(e.key[0]!==tu.InputTypes.SIGHASH_TYPE)throw new Error("Decode Error: could not decode sighashType with key 0x"+e.key.toString("hex"));return e.value.readUInt32LE(0)},eu.encode=function(e){const r=t.from([tu.InputTypes.SIGHASH_TYPE]),n=t.allocUnsafe(4);return n.writeUInt32LE(e,0),{key:r,value:n}},eu.expected="number",eu.check=function(e){return"number"==typeof e},eu.canAdd=function(e,t){return!!e&&!!t&&void 0===e.sighashType};var ru={};Object.defineProperty(ru,"__esModule",{value:!0});const nu=Da;function iu(e){return r(e)&&(64===e.length||65===e.length)}ru.decode=function(e){if(e.key[0]!==nu.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(!iu(e.value))throw new Error("Decode Error: tapKeySig not a valid 64-65-byte BIP340 signature");return e.value},ru.encode=function(e){return{key:t.from([nu.InputTypes.TAP_KEY_SIG]),value:e}},ru.expected="Buffer",ru.check=iu,ru.canAdd=function(e,t){return!!e&&!!t&&void 0===e.tapKeySig};var ou={};Object.defineProperty(ou,"__esModule",{value:!0});const su=Da;ou.decode=function(e){if(e.key[0]!==su.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}},ou.encode=function(e){const r=t.from([su.InputTypes.TAP_LEAF_SCRIPT]),n=t.from([e.leafVersion]);return{key:t.concat([r,e.controlBlock]),value:t.concat([e.script,n])}},ou.expected="{ controlBlock: Buffer; leafVersion: number, script: Buffer; }",ou.check=function(e){return r(e.controlBlock)&&(e.controlBlock.length-1)%32==0&&(254&e.controlBlock[0])===e.leafVersion&&r(e.script)},ou.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 au={};Object.defineProperty(au,"__esModule",{value:!0});const uu=Da;function cu(e){return r(e)&&32===e.length}au.decode=function(e){if(e.key[0]!==uu.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(!cu(e.value))throw new Error("Decode Error: tapMerkleRoot not a 32-byte hash");return e.value},au.encode=function(e){return{key:t.from([uu.InputTypes.TAP_MERKLE_ROOT]),value:e}},au.expected="Buffer",au.check=cu,au.canAdd=function(e,t){return!!e&&!!t&&void 0===e.tapMerkleRoot};var fu={};Object.defineProperty(fu,"__esModule",{value:!0});const hu=Da;fu.decode=function(e){if(e.key[0]!==hu.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}},fu.encode=function(e){const r=t.from([hu.InputTypes.TAP_SCRIPT_SIG]);return{key:t.concat([r,e.pubkey,e.leafHash]),value:e.signature}},fu.expected="{ pubkey: Buffer; leafHash: Buffer; signature: Buffer; }",fu.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)},fu.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 pu={},lu={},du={};Object.defineProperty(du,"__esModule",{value:!0});const yu=9007199254740991;function gu(e){if(e<0||e>yu||e%1!=0)throw new RangeError("value out of range")}function wu(e){return gu(e),e<253?1:e<=65535?3:e<=4294967295?5:9}du.encode=function e(n,i,o){if(gu(n),i||(i=t.allocUnsafe(wu(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},du.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 gu(i),i}},du.encodingLength=wu,Object.defineProperty(lu,"__esModule",{value:!0});const mu=du;function bu(e){const r=e.key.length,n=e.value.length,i=mu.encodingLength(r),o=mu.encodingLength(n),s=t.allocUnsafe(i+r+o+n);return mu.encode(r,s,0),e.key.copy(s,i),mu.encode(n,s,i+r),e.value.copy(s,i+r+o),s}function Eu(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")}lu.range=e=>[...Array(e).keys()],lu.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},lu.keyValsToBuffer=function(e){const r=e.map(bu);return r.push(t.from([0])),t.concat(r)},lu.keyValToBuffer=bu,lu.readUInt64LE=function(e,t){const r=e.readUInt32LE(t);let n=e.readUInt32LE(t+4);return n*=4294967296,Eu(n+r,9007199254740991),n+r},lu.writeUInt64LE=function(e,t,r){return Eu(t,9007199254740991),e.writeInt32LE(-1&t,r),e.writeUInt32LE(Math.floor(t/4294967296),r+4),r+8},Object.defineProperty(pu,"__esModule",{value:!0});const _u=Da,vu=lu,Su=du;pu.decode=function(e){if(e.key[0]!==_u.InputTypes.WITNESS_UTXO)throw new Error("Decode Error: could not decode witnessUtxo with key 0x"+e.key.toString("hex"));const t=vu.readUInt64LE(e.value,0);let r=8;const n=Su.decode(e.value,r);r+=Su.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}},pu.encode=function(e){const{script:r,value:n}=e,i=Su.encodingLength(r.length),o=t.allocUnsafe(8+i+r.length);return vu.writeUInt64LE(o,n,0),Su.encode(r.length,o,8),r.copy(o,8+i),{key:t.from([_u.InputTypes.WITNESS_UTXO]),value:o}},pu.expected="{ script: Buffer; value: number; }",pu.check=function(e){return r(e.script)&&"number"==typeof e.value},pu.canAdd=function(e,t){return!!e&&!!t&&void 0===e.witnessUtxo};var Iu={};Object.defineProperty(Iu,"__esModule",{value:!0});const Tu=Da,ku=du;Iu.decode=function(e){if(e.key[0]!==Tu.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=ku.decode(e.value,t);t+=ku.encodingLength(o),r.push({depth:n,leafVersion:i,script:e.value.slice(t,t+o)}),t+=o}return{leaves:r}},Iu.encode=function(e){const r=t.from([Tu.OutputTypes.TAP_TREE]),n=[].concat(...e.leaves.map((e=>[t.of(e.depth,e.leafVersion),ku.encode(e.script.length),e.script])));return{key:r,value:t.concat(n)}},Iu.expected="{ leaves: [{ depth: number; leafVersion: number, script: Buffer; }] }",Iu.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)))},Iu.canAdd=function(e,t){return!!e&&!!t&&void 0===e.tapTree};var Au={};Object.defineProperty(Au,"__esModule",{value:!0});const Pu=e=>33===e.length&&[2,3].includes(e[0])||65===e.length&&4===e[0];Au.makeConverter=function(e,n=Pu){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 Ou={};Object.defineProperty(Ou,"__esModule",{value:!0}),Ou.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 Nu={};Object.defineProperty(Nu,"__esModule",{value:!0}),Nu.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 Uu={};Object.defineProperty(Uu,"__esModule",{value:!0});const xu=du,Bu=Au,Ru=e=>32===e.length;Uu.makeConverter=function(e){const n=Bu.makeConverter(e,Ru);return{decode:function(e){const t=xu.decode(e.value),r=xu.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=xu.encodingLength(e.leafHashes.length),o=t.allocUnsafe(i);xu.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 Lu={};Object.defineProperty(Lu,"__esModule",{value:!0}),Lu.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 Mu={};Object.defineProperty(Mu,"__esModule",{value:!0}),Mu.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(Ca,"__esModule",{value:!0});const Hu=Da,Cu=Ga,Du=qa,Fu=za,ju=Ya,Vu=Qa,Ku=eu,Gu=ru,Wu=ou,qu=au,Xu=fu,zu=pu,$u=Iu,Yu=Au,Ju=Ou,Qu=Nu,Zu=Uu,ec=Lu,tc=Mu,rc={unsignedTx:Va,globalXpub:Fa,checkPubkey:Ju.makeChecker([])};Ca.globals=rc;const nc={nonWitnessUtxo:Fu,partialSig:ju,sighashType:Ku,finalScriptSig:Cu,finalScriptWitness:Du,porCommitment:Vu,witnessUtxo:zu,bip32Derivation:Yu.makeConverter(Hu.InputTypes.BIP32_DERIVATION),redeemScript:Qu.makeConverter(Hu.InputTypes.REDEEM_SCRIPT),witnessScript:tc.makeConverter(Hu.InputTypes.WITNESS_SCRIPT),checkPubkey:Ju.makeChecker([Hu.InputTypes.PARTIAL_SIG,Hu.InputTypes.BIP32_DERIVATION]),tapKeySig:Gu,tapScriptSig:Xu,tapLeafScript:Wu,tapBip32Derivation:Zu.makeConverter(Hu.InputTypes.TAP_BIP32_DERIVATION),tapInternalKey:ec.makeConverter(Hu.InputTypes.TAP_INTERNAL_KEY),tapMerkleRoot:qu};Ca.inputs=nc;const ic={bip32Derivation:Yu.makeConverter(Hu.OutputTypes.BIP32_DERIVATION),redeemScript:Qu.makeConverter(Hu.OutputTypes.REDEEM_SCRIPT),witnessScript:tc.makeConverter(Hu.OutputTypes.WITNESS_SCRIPT),checkPubkey:Ju.makeChecker([Hu.OutputTypes.BIP32_DERIVATION]),tapBip32Derivation:Zu.makeConverter(Hu.OutputTypes.TAP_BIP32_DERIVATION),tapTree:$u,tapInternalKey:ec.makeConverter(Hu.OutputTypes.TAP_INTERNAL_KEY)};Ca.outputs=ic,Object.defineProperty(Ha,"__esModule",{value:!0});const oc=Ca,sc=lu,ac=du,uc=Da;function cc(e,r,n){if(!r.equals(t.from([n])))throw new Error(`Format Error: Invalid ${e} key: ${r.toString("hex")}`)}function fc(e,{globalMapKeyVals:t,inputKeyVals:r,outputKeyVals:n}){const i={unsignedTx:e};let o=0;for(const e of t)switch(e.key[0]){case uc.GlobalTypes.UNSIGNED_TX:if(cc("global",e.key,uc.GlobalTypes.UNSIGNED_TX),o>0)throw new Error("Format Error: GlobalMap has multiple UNSIGNED_TX");o++;break;case uc.GlobalTypes.GLOBAL_XPUB:void 0===i.globalXpub&&(i.globalXpub=[]),i.globalXpub.push(oc.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 sc.range(s)){const t={};for(const n of r[e])switch(oc.inputs.checkPubkey(n),n.key[0]){case uc.InputTypes.NON_WITNESS_UTXO:if(cc("input",n.key,uc.InputTypes.NON_WITNESS_UTXO),void 0!==t.nonWitnessUtxo)throw new Error("Format Error: Input has multiple NON_WITNESS_UTXO");t.nonWitnessUtxo=oc.inputs.nonWitnessUtxo.decode(n);break;case uc.InputTypes.WITNESS_UTXO:if(cc("input",n.key,uc.InputTypes.WITNESS_UTXO),void 0!==t.witnessUtxo)throw new Error("Format Error: Input has multiple WITNESS_UTXO");t.witnessUtxo=oc.inputs.witnessUtxo.decode(n);break;case uc.InputTypes.PARTIAL_SIG:void 0===t.partialSig&&(t.partialSig=[]),t.partialSig.push(oc.inputs.partialSig.decode(n));break;case uc.InputTypes.SIGHASH_TYPE:if(cc("input",n.key,uc.InputTypes.SIGHASH_TYPE),void 0!==t.sighashType)throw new Error("Format Error: Input has multiple SIGHASH_TYPE");t.sighashType=oc.inputs.sighashType.decode(n);break;case uc.InputTypes.REDEEM_SCRIPT:if(cc("input",n.key,uc.InputTypes.REDEEM_SCRIPT),void 0!==t.redeemScript)throw new Error("Format Error: Input has multiple REDEEM_SCRIPT");t.redeemScript=oc.inputs.redeemScript.decode(n);break;case uc.InputTypes.WITNESS_SCRIPT:if(cc("input",n.key,uc.InputTypes.WITNESS_SCRIPT),void 0!==t.witnessScript)throw new Error("Format Error: Input has multiple WITNESS_SCRIPT");t.witnessScript=oc.inputs.witnessScript.decode(n);break;case uc.InputTypes.BIP32_DERIVATION:void 0===t.bip32Derivation&&(t.bip32Derivation=[]),t.bip32Derivation.push(oc.inputs.bip32Derivation.decode(n));break;case uc.InputTypes.FINAL_SCRIPTSIG:cc("input",n.key,uc.InputTypes.FINAL_SCRIPTSIG),t.finalScriptSig=oc.inputs.finalScriptSig.decode(n);break;case uc.InputTypes.FINAL_SCRIPTWITNESS:cc("input",n.key,uc.InputTypes.FINAL_SCRIPTWITNESS),t.finalScriptWitness=oc.inputs.finalScriptWitness.decode(n);break;case uc.InputTypes.POR_COMMITMENT:cc("input",n.key,uc.InputTypes.POR_COMMITMENT),t.porCommitment=oc.inputs.porCommitment.decode(n);break;case uc.InputTypes.TAP_KEY_SIG:cc("input",n.key,uc.InputTypes.TAP_KEY_SIG),t.tapKeySig=oc.inputs.tapKeySig.decode(n);break;case uc.InputTypes.TAP_SCRIPT_SIG:void 0===t.tapScriptSig&&(t.tapScriptSig=[]),t.tapScriptSig.push(oc.inputs.tapScriptSig.decode(n));break;case uc.InputTypes.TAP_LEAF_SCRIPT:void 0===t.tapLeafScript&&(t.tapLeafScript=[]),t.tapLeafScript.push(oc.inputs.tapLeafScript.decode(n));break;case uc.InputTypes.TAP_BIP32_DERIVATION:void 0===t.tapBip32Derivation&&(t.tapBip32Derivation=[]),t.tapBip32Derivation.push(oc.inputs.tapBip32Derivation.decode(n));break;case uc.InputTypes.TAP_INTERNAL_KEY:cc("input",n.key,uc.InputTypes.TAP_INTERNAL_KEY),t.tapInternalKey=oc.inputs.tapInternalKey.decode(n);break;case uc.InputTypes.TAP_MERKLE_ROOT:cc("input",n.key,uc.InputTypes.TAP_MERKLE_ROOT),t.tapMerkleRoot=oc.inputs.tapMerkleRoot.decode(n);break;default:t.unknownKeyVals||(t.unknownKeyVals=[]),t.unknownKeyVals.push(n)}u.push(t)}for(const e of sc.range(a)){const t={};for(const r of n[e])switch(oc.outputs.checkPubkey(r),r.key[0]){case uc.OutputTypes.REDEEM_SCRIPT:if(cc("output",r.key,uc.OutputTypes.REDEEM_SCRIPT),void 0!==t.redeemScript)throw new Error("Format Error: Output has multiple REDEEM_SCRIPT");t.redeemScript=oc.outputs.redeemScript.decode(r);break;case uc.OutputTypes.WITNESS_SCRIPT:if(cc("output",r.key,uc.OutputTypes.WITNESS_SCRIPT),void 0!==t.witnessScript)throw new Error("Format Error: Output has multiple WITNESS_SCRIPT");t.witnessScript=oc.outputs.witnessScript.decode(r);break;case uc.OutputTypes.BIP32_DERIVATION:void 0===t.bip32Derivation&&(t.bip32Derivation=[]),t.bip32Derivation.push(oc.outputs.bip32Derivation.decode(r));break;case uc.OutputTypes.TAP_INTERNAL_KEY:cc("output",r.key,uc.OutputTypes.TAP_INTERNAL_KEY),t.tapInternalKey=oc.outputs.tapInternalKey.decode(r);break;case uc.OutputTypes.TAP_TREE:cc("output",r.key,uc.OutputTypes.TAP_TREE),t.tapTree=oc.outputs.tapTree.decode(r);break;case uc.OutputTypes.TAP_BIP32_DERIVATION:void 0===t.tapBip32Derivation&&(t.tapBip32Derivation=[]),t.tapBip32Derivation.push(oc.outputs.tapBip32Derivation.decode(r));break;default:t.unknownKeyVals||(t.unknownKeyVals=[]),t.unknownKeyVals.push(r)}c.push(t)}return{globalMap:i,inputs:u,outputs:c}}Ha.psbtFromBuffer=function(e,t){let r=0;function n(){const t=ac.decode(e,r);r+=ac.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]===uc.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 sc.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 sc.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 fc(c,{globalMapKeyVals:s,inputKeyVals:p,outputKeyVals:l})},Ha.checkKeyBuffer=cc,Ha.psbtFromKeyVals=fc;var hc={};Object.defineProperty(hc,"__esModule",{value:!0});const pc=Ca,lc=lu;hc.psbtToBuffer=function({globalMap:e,inputs:r,outputs:n}){const{globalKeyVals:i,inputKeyVals:o,outputKeyVals:s}=gc({globalMap:e,inputs:r,outputs:n}),a=lc.keyValsToBuffer(i),u=e=>0===e.length?[t.from([0])]:e.map(lc.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 dc=(e,t)=>e.key.compare(t.key);function yc(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(dc)}function gc({globalMap:e,inputs:t,outputs:r}){return{globalKeyVals:yc(e,pc.globals),inputKeyVals:t.map((e=>yc(e,pc.inputs))),outputKeyVals:r.map((e=>yc(e,pc.outputs)))}}hc.psbtToKeyVals=gc,function(e){function t(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}Object.defineProperty(e,"__esModule",{value:!0}),t(Ha),t(hc)}(Ma),Object.defineProperty(La,"__esModule",{value:!0});const wc=Ma;function mc(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 bc(e){return e.globalMap.unsignedTx}function Ec(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}La.combine=function(e){const t=e[0],r=wc.psbtToKeyVals(t),n=e.slice(1);if(0===n.length)throw new Error("Combine: Nothing to combine");const i=bc(t);if(void 0===i)throw new Error("Combine: Self missing transaction");const o=Ec(r.globalKeyVals),s=r.inputKeyVals.map(Ec),a=r.outputKeyVals.map(Ec);for(const e of n){const t=bc(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=wc.psbtToKeyVals(e);Ec(n.globalKeyVals).forEach(mc(o,r.globalKeyVals,n.globalKeyVals));n.inputKeyVals.map(Ec).forEach(((e,t)=>e.forEach(mc(s[t],r.inputKeyVals[t],n.inputKeyVals[t]))));n.outputKeyVals.map(Ec).forEach(((e,t)=>e.forEach(mc(a[t],r.outputKeyVals[t],n.outputKeyVals[t]))))}return wc.psbtFromKeyVals(i,{globalMapKeyVals:r.globalKeyVals,inputKeyVals:r.inputKeyVals,outputKeyVals:r.outputKeyVals})};var _c={};!function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=Ca;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}}(_c),Object.defineProperty(Ra,"__esModule",{value:!0});const vc=La,Sc=Ma,Ic=Da,Tc=_c;Ra.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=Sc.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 Sc.psbtToBuffer(this)}updateGlobal(e){return Tc.updateGlobal(e,this.globalMap),this}updateInput(e,t){const r=Tc.checkForInput(this.inputs,e);return Tc.updateInput(t,r),this}updateOutput(e,t){const r=Tc.checkForOutput(this.outputs,e);return Tc.updateOutput(t,r),this}addUnknownKeyValToGlobal(e){return Tc.checkHasKey(e,this.globalMap.unknownKeyVals,Tc.getEnumLength(Ic.GlobalTypes)),this.globalMap.unknownKeyVals||(this.globalMap.unknownKeyVals=[]),this.globalMap.unknownKeyVals.push(e),this}addUnknownKeyValToInput(e,t){const r=Tc.checkForInput(this.inputs,e);return Tc.checkHasKey(t,r.unknownKeyVals,Tc.getEnumLength(Ic.InputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(t),this}addUnknownKeyValToOutput(e,t){const r=Tc.checkForOutput(this.outputs,e);return Tc.checkHasKey(t,r.unknownKeyVals,Tc.getEnumLength(Ic.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))),Tc.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))),Tc.addOutputAttributes(this.outputs,e),this}clearFinalizedInput(e){const t=Tc.checkForInput(this.inputs,e);Tc.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=vc.combine([this].concat(e));return Object.assign(this,t),this}getTransaction(){return this.globalMap.unsignedTx.toBuffer()}};var kc={},Ac={};Object.defineProperty(Ac,"__esModule",{value:!0}),Ac.signatureBlocksAction=Ac.checkInputForSig=Ac.pubkeyInScript=Ac.pubkeyPositionInScript=Ac.witnessStackToScriptWitness=Ac.isP2TR=Ac.isP2SHScript=Ac.isP2WSHScript=Ac.isP2WPKH=Ac.isP2PKH=Ac.isP2PK=Ac.isP2MS=void 0;const Pc=du,Oc=mn,Nc=ua,Uc=Pi,xc=gn;function Bc(e){return t=>{try{return e({output:t}),!0}catch(e){return!1}}}function Rc(e,t){const r=(0,Uc.hash160)(e),n=e.slice(1,33),i=Oc.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 Lc(e,t,r){const{hashType:n}=t(e),i=[];n&Nc.Transaction.SIGHASH_ANYONECANPAY&&i.push("addInput");switch(31&n){case Nc.Transaction.SIGHASH_ALL:break;case Nc.Transaction.SIGHASH_SINGLE:case Nc.Transaction.SIGHASH_NONE:i.push("addOutput"),i.push("setInputSequence")}return-1===i.indexOf(r)}Ac.isP2MS=Bc(xc.p2ms),Ac.isP2PK=Bc(xc.p2pk),Ac.isP2PKH=Bc(xc.p2pkh),Ac.isP2WPKH=Bc(xc.p2wpkh),Ac.isP2WSHScript=Bc(xc.p2wsh),Ac.isP2SHScript=Bc(xc.p2sh),Ac.isP2TR=Bc(xc.p2tr),Ac.witnessStackToScriptWitness=function(e){let r=t.allocUnsafe(0);function n(e){const n=r.length,i=Pc.encodingLength(e);r=t.concat([r,t.allocUnsafe(i)]),Pc.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},Ac.pubkeyPositionInScript=Rc,Ac.pubkeyInScript=function(e,t){return-1!==Rc(e,t)},Ac.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&&Oc.decompile(e.finalScriptSig)||[],n=e.finalScriptWitness&&Oc.decompile(e.finalScriptWitness)||[];return t.concat(n).filter((e=>r(e)&&Oc.isCanonicalScriptSignature(e))).map((e=>({signature:e})))}(e)}else t=e.partialSig;return t.map((e=>e.signature))}(e).some((e=>Lc(e,Oc.signature.decode,t)))},Ac.signatureBlocksAction=Lc,Object.defineProperty(kc,"__esModule",{value:!0}),kc.checkTaprootInputForSigs=kc.tapTreeFromList=kc.tapTreeToList=kc.tweakInternalPubKey=kc.checkTaprootOutputFields=kc.checkTaprootInputFields=kc.isTaprootOutput=kc.isTaprootInput=kc.serializeTaprootSignature=kc.tapScriptFinalizer=kc.toXOnly=void 0;const Mc=Pn,Hc=ua,Cc=Ac,Dc=vs,Fc=gn,jc=Ac;function Vc(e){return e&&!!(e.tapInternalKey||e.tapMerkleRoot||e.tapLeafScript&&e.tapLeafScript.length||e.tapBip32Derivation&&e.tapBip32Derivation.length||e.witnessUtxo&&(0,Cc.isP2TR)(e.witnessUtxo.script))}function Kc(e,t){return e&&!!(e.tapInternalKey||e.tapTree||e.tapBip32Derivation&&e.tapBip32Derivation.length||t&&(0,Cc.isP2TR)(t))}function Gc(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=Xc(r,t),!t)throw new Error("No room left to insert tapleaf in tree");return t}(e)}function Wc(e){return{signature:e.slice(0,64),hashType:e.slice(64)[0]||Hc.Transaction.SIGHASH_DEFAULT}}function qc(e,t=[],r=0){if(r>Dc.MAX_TAPTREE_DEPTH)throw new Error("Max taptree depth exceeded.");return e?(0,Mc.isTapleaf)(e)?(t.push({depth:r,leafVersion:e.version||Dc.LEAF_VERSION_TAPSCRIPT,script:e.output}),t):(e[0]&&qc(e[0],t,r+1),e[1]&&qc(e[1],t,r+1),t):[]}function Xc(e,t,r=0){if(r>Dc.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,Mc.isTapleaf)(t))return;const n=Xc(e,t&&t[0],r+1);if(n)return[n,t&&t[1]];const i=Xc(e,t&&t[1],r+1);return i?[t&&t[0],i]:void 0}function zc(e,t){if(!t)return!0;const r=(0,Dc.tapleafHash)({output:e.script,version:e.leafVersion});return(0,Dc.rootHashFromPath)(e.controlBlock,r).equals(t)}function $c(e){return e&&!!(e.redeemScript||e.witnessScript||e.bip32Derivation&&e.bip32Derivation.length)}kc.toXOnly=e=>32===e.length?e:e.slice(1,33),kc.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,Dc.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,Dc.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,Cc.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,Cc.witnessStackToScriptWitness)(r)}}catch(t){throw new Error(`Can not finalize taproot input #${e}: ${t}`)}},kc.serializeTaprootSignature=function(e,r){const n=r?t.from([r]):t.from([]);return t.concat([e,n])},kc.isTaprootInput=Vc,kc.isTaprootOutput=Kc,kc.checkTaprootInputFields=function(e,t,r){!function(e,t,r){const n=Vc(e)&&$c(t),i=$c(e)&&Vc(t),o=e===t&&Vc(t)&&$c(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=>zc(e,t.tapMerkleRoot))),i=(e.tapLeafScript||[]).every((e=>zc(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=>zc(t,e.tapMerkleRoot))))throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}}(e,t,r)},kc.checkTaprootOutputFields=function(e,t,r){!function(e,t,r){const n=Kc(e)&&$c(t),i=$c(e)&&Kc(t),o=e===t&&Kc(t)&&$c(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&&Gc(t.leaves),{output:n}=(0,Fc.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)},kc.tweakInternalPubKey=function(e,t){const r=t.tapInternalKey,n=r&&(0,Dc.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},kc.tapTreeToList=function(e){if(!(0,Mc.isTaptree)(e))throw new Error("Cannot convert taptree to tapleaf list. Expecting a tapree structure.");return qc(e)},kc.tapTreeFromList=Gc,kc.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,jc.signatureBlocksAction)(e,Wc,t)))},Object.defineProperty(Ba,"__esModule",{value:!0}),Ba.Psbt=void 0;const Yc=Ra,Jc=du,Qc=_c,Zc=dn,ef=Ss,tf=gn,rf=vs,nf=mn,of=ua,sf=kc,af=Ac,uf={network:yn.bitcoin,maximumFeeRate:5e3};class cf{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=Yc.Psbt.fromBuffer(e,ff),n=new cf(t,r);var i,o;return i=n.__CACHE.__TX,o=n.__CACHE,i.ins.forEach((e=>{bf(o,e)})),n}constructor(e={},t=new Yc.Psbt(new hf)){this.data=t,this.opts=Object.assign({},uf,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,ef.cloneBuffer)(e.hash),index:e.index,sequence:e.sequence})))}get txOutputs(){return this.__CACHE.__TX.outs.map((e=>{let t;try{t=(0,Zc.fromOutputScript)(e.script,this.opts.network)}catch(e){}return{script:(0,ef.cloneBuffer)(e.script),value:e.value,address:t}}))}combine(...e){return this.data.combine(...e.map((e=>e.data))),this}clone(){const e=cf.fromBuffer(this.data.toBuffer());return e.opts=JSON.parse(JSON.stringify(this.opts)),e}setMaximumFeeRate(e){gf(e),this.opts.maximumFeeRate=e}setVersion(e){gf(e),wf(this.data.inputs,"setVersion");const t=this.__CACHE;return t.__TX.version=e,t.__EXTRACTED_TX=void 0,this}setLocktime(e){gf(e),wf(this.data.inputs,"setLocktime");const t=this.__CACHE;return t.__TX.locktime=e,t.__EXTRACTED_TX=void 0,this}setInputSequence(e,t){gf(t),wf(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,sf.checkTaprootInputFields)(e,e,"addInput"),wf(this.data.inputs,"addInput"),e.witnessScript&&Ff(e.witnessScript);const t=this.__CACHE;this.data.addInput(e);bf(t,t.__TX.ins[t.__TX.ins.length-1]);const r=this.data.inputs.length-1,n=this.data.inputs[r];return n.nonWitnessUtxo&&Bf(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]");wf(this.data.inputs,"addOutput");const{address:t}=e;if("string"==typeof t){const{network:r}=this.opts,n=(0,Zc.toOutputScript)(t,r);e=Object.assign(e,{script:n})}(0,sf.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(df))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 Rf(this.data.inputs,r,t,!0),r}getFeeRate(){return Sf("__FEE_RATE","fee rate",this.data.inputs,this.__CACHE)}getFee(){return Sf("__FEE","fee",this.data.inputs,this.__CACHE)}finalizeAllInputs(){return(0,Qc.checkForInput)(this.data.inputs,0),Vf(this.data.inputs.length).forEach((e=>this.finalizeInput(e))),this}finalizeInput(e,t){const r=(0,Qc.checkForInput)(this.data.inputs,e);return(0,sf.isTaprootInput)(r)?this._finalizeTaprootInput(e,r,void 0,t):this._finalizeInput(e,r,t)}finalizeTaprootInput(e,t,r=sf.tapScriptFinalizer){const n=(0,Qc.checkForInput)(this.data.inputs,e);if((0,sf.isTaprootInput)(n))return this._finalizeTaprootInput(e,n,t,r);throw new Error(`Cannot finalize input #${e}. Not Taproot.`)}_finalizeInput(e,t,r=If){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=Lf(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,af.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}=nf.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=sf.tapScriptFinalizer){if(!t.witnessUtxo)throw new Error(`Cannot finalize input #${e}. Missing withness utxo.`);if(t.tapKeySig){const r=tf.p2tr({output:t.witnessUtxo.script,signature:t.tapKeySig}),n=(0,af.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,Qc.checkForInput)(this.data.inputs,e),n=Df(Mf(e,t,this.__CACHE),e,"input",t.redeemScript||function(e){if(!e)return;const t=nf.decompile(e);if(!t)return;const n=t[t.length-1];if(!r(n)||Cf(n)||(i=n,nf.isCanonicalScriptSignature(i)))return;var i;if(!nf.decompile(n))return;return n}(t.finalScriptSig),t.witnessScript||function(e){if(!e)return;const t=xf(e),r=t[t.length-1];if(Cf(r))return;if(!nf.decompile(r))return;return r}(t.finalScriptWitness));return("raw"===n.type?"":n.type+"-")+jf(n.meaningfulScript)}inputHasPubkey(e,t){return function(e,t,r,n){const i=Mf(r,t,n),{meaningfulScript:o}=Df(i,r,"input",t.redeemScript,t.witnessScript);return(0,af.pubkeyInScript)(e,o)}(t,(0,Qc.checkForInput)(this.data.inputs,e),e,this.__CACHE)}inputHasHDKey(e,t){const r=(0,Qc.checkForInput)(this.data.inputs,e),n=yf(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}=Df(i,r,"output",t.redeemScript,t.witnessScript);return(0,af.pubkeyInScript)(e,o)}(t,(0,Qc.checkForOutput)(this.data.outputs,e),e,this.__CACHE)}outputHasHDKey(e,t){const r=(0,Qc.checkForOutput)(this.data.outputs,e),n=yf(t);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}validateSignaturesOfAllInputs(e){(0,Qc.checkForInput)(this.data.inputs,0);return Vf(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,sf.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=nf.signature.decode(r.signature),{hash:o,script:f}=c!==i.hashType?kf(e,Object.assign({},n,{sighashType:i.hashType}),this.__CACHE,!0):{hash:a,script:u};c=i.hashType,a=o,u=f,mf(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,sf.toXOnly)(r))?Of(e,n,this.data.inputs,r,this.__CACHE):function(e,t,r,n){const i=[];if(t.tapInternalKey){const r=Af(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=>Of(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,Pf(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,Pf(e.signature)))return!1;u++}}return u>0}signAllInputsHD(e,t=[of.Transaction.SIGHASH_ALL]){if(!e||!e.publicKey||!e.fingerprint)throw new Error("Need HDSigner to sign input");const r=[];for(const n of Vf(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=[of.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 Vf(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=[of.Transaction.SIGHASH_ALL]){if(!t||!t.publicKey||!t.fingerprint)throw new Error("Need HDSigner to sign input");return Uf(e,this.data.inputs,t).forEach((t=>this.signInput(e,t,r))),this}signInputHDAsync(e,t,r=[of.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=Uf(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 Vf(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,Qc.checkForInput)(this.data.inputs,e);return(0,sf.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,Qc.checkForInput)(this.data.inputs,e);if((0,sf.isTaprootInput)(i))return this._signTaprootInput(e,i,t,r,n);throw new Error(`Input #${e} is not of type Taproot.`)}_signInput(e,t,r=[of.Transaction.SIGHASH_ALL]){const{hash:n,sighashType:i}=Tf(this.data.inputs,e,t.publicKey,this.__CACHE,r),o=[{pubkey:t.publicKey,signature:nf.signature.encode(t.sign(n),i)}];return this.data.updateInput(e,{partialSig:o}),this}_signTaprootInput(e,t,r,n,i=[of.Transaction.SIGHASH_DEFAULT]){const o=this.checkTaprootHashesForSig(e,t,r,n,i),s=o.filter((e=>!e.leafHash)).map((e=>(0,sf.serializeTaprootSignature)(r.signSchnorr(e.hash),t.sighashType)))[0],a=o.filter((e=>!!e.leafHash)).map((e=>({pubkey:(0,sf.toXOnly)(r.publicKey),signature:(0,sf.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,Qc.checkForInput)(this.data.inputs,e);return(0,sf.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,Qc.checkForInput)(this.data.inputs,e);if((0,sf.isTaprootInput)(i))return this._signTaprootInputAsync(e,i,t,r,n);throw new Error(`Input #${e} is not of type Taproot.`)}))}_signInputAsync(e,t,r=[of.Transaction.SIGHASH_ALL]){const{hash:n,sighashType:i}=Tf(this.data.inputs,e,t.publicKey,this.__CACHE,r);return Promise.resolve(t.sign(n)).then((r=>{const n=[{pubkey:t.publicKey,signature:nf.signature.encode(r,i)}];this.data.updateInput(e,{partialSig:n})}))}async _signTaprootInputAsync(e,t,r,n,i=[of.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,sf.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,sf.toXOnly)(r.publicKey),signature:(0,sf.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=Of(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 pf(this.__CACHE),this.data.toBuffer()}toHex(){return pf(this.__CACHE),this.data.toHex()}toBase64(){return pf(this.__CACHE),this.data.toBase64()}updateGlobal(e){return this.data.updateGlobal(e),this}updateInput(e,t){return t.witnessScript&&Ff(t.witnessScript),(0,sf.checkTaprootInputFields)(this.data.inputs[e],t,"updateInput"),this.data.updateInput(e,t),t.nonWitnessUtxo&&Bf(this.__CACHE,this.data.inputs[e],e),this}updateOutput(e,t){const r=this.data.outputs[e];return(0,sf.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}}Ba.Psbt=cf;const ff=e=>new hf(e);class hf{constructor(e=t.from([2,0,0,0,0,0,0,0,0,0])){this.tx=of.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,ef.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 pf(e){if(!1!==e.__UNSAFE_SIGN_NONSEGWIT)throw new Error("Not BIP174 compliant, can not export")}function lf(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 df(e){return!!e.finalScriptSig||!!e.finalScriptWitness}function yf(e){return t=>!!t.masterFingerprint.equals(e.fingerprint)&&!!e.derivePath(t.path).publicKey.equals(t.pubkey)}function gf(e){if("number"!=typeof e||e!==Math.floor(e)||e>4294967295||e<0)throw new Error("Invalid 32 bit integer")}function wf(e,t){e.forEach((e=>{if((0,sf.isTaprootInput)(e)?(0,sf.checkTaprootInputForSigs)(e,t):(0,af.checkInputForSig)(e,t))throw new Error("Can not modify transaction, signatures exist.")}))}function mf(e,t,r){if(!(0,af.pubkeyInScript)(e,t))throw new Error(`Can not ${r} for this input with the key ${e.toString("hex")}`)}function bf(e,r){const n=(0,ef.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 Ef(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 _f=Ef(tf.p2sh,"Redeem script"),vf=Ef(tf.p2wsh,"Witness script");function Sf(e,t,r,n){if(!r.every(df))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(),Rf(r,i,n,o),"__FEE_RATE"===e?n.__FEE_RATE:"__FEE"===e?n.__FEE:void 0}function If(e,t,r,n,i,o){const s=jf(r);if(!function(e,t,r){switch(r){case"pubkey":case"pubkeyhash":case"witnesspubkeyhash":return lf(1,e.partialSig);case"multisig":const r=tf.p2ms({output:t});return lf(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=tf.p2ms({output:e});return r.pubkeys.map((e=>(t.filter((t=>t.pubkey.equals(e)))[0]||{}).signature)).filter((e=>!!e))}(e,r);n=tf.p2ms({output:e,signatures:t});break;case"pubkey":n=tf.p2pk({output:e,signature:r[0].signature});break;case"pubkeyhash":n=tf.p2pkh({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break;case"witnesspubkeyhash":n=tf.p2wpkh({output:e,pubkey:r[0].pubkey,signature:r[0].signature})}return n}(e,t,r),c=o?tf.p2wsh({redeem:u}):null,f=i?tf.p2sh({redeem:c||u}):null;n?(a=c?(0,af.witnessStackToScriptWitness)(c.witness):(0,af.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 Tf(e,t,r,n,i){const o=(0,Qc.checkForInput)(e,t),{hash:s,sighashType:a,script:u}=kf(t,o,n,!1,i);return mf(r,u,"sign"),{hash:s,sighashType:a}}function kf(e,t,r,n,i){const o=r.__TX,s=t.sighashType||of.Transaction.SIGHASH_ALL;let a,u;if(Nf(s,i),t.nonWitnessUtxo){const n=Lf(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}=Df(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,af.isP2WPKH)(c)){const t=tf.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 Af(e,t,r){const{script:n}=Hf(e,t,r);return(0,af.isP2TR)(n)?n.subarray(2,34):null}function Pf(e){return 64===e.length?e:e.subarray(0,64)}function Of(e,r,n,i,o,s,a){const u=o.__TX,c=r.sighashType||of.Transaction.SIGHASH_DEFAULT;Nf(c,a);const f=n.map(((e,t)=>Hf(t,e,o))),h=f.map((e=>e.script)),p=f.map((e=>e.value)),l=[];if(r.tapInternalKey&&!s){const n=Af(e,r,o)||t.from([]);if((0,sf.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,af.pubkeyInScript)(i,e.script))).map((e=>{const t=(0,rf.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,of.Transaction.SIGHASH_DEFAULT,t.hash);return{pubkey:i,hash:r,leafHash:t.hash}}));return l.concat(d)}function Nf(e,t){if(t&&t.indexOf(e)<0){const t=function(e){let t=e&of.Transaction.SIGHASH_ANYONECANPAY?"SIGHASH_ANYONECANPAY | ":"";switch(31&e){case of.Transaction.SIGHASH_ALL:t+="SIGHASH_ALL";break;case of.Transaction.SIGHASH_SINGLE:t+="SIGHASH_SINGLE";break;case of.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 Uf(e,t,r){const n=(0,Qc.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 xf(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 Bf(e,t,r){e.__NON_WITNESS_UTXO_BUF_CACHE[r]=t.nonWitnessUtxo;const n=of.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 Rf(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=xf(e.finalScriptWitness)),e.witnessUtxo)i+=e.witnessUtxo.value;else if(e.nonWitnessUtxo){const n=Lf(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 Lf(e,t,r){const n=e.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||Bf(e,t,r),n[r]}function Mf(e,t,r){const{script:n}=Hf(e,t,r);return n}function Hf(e,t,r){if(void 0!==t.witnessUtxo)return{script:t.witnessUtxo.script,value:t.witnessUtxo.value};if(void 0!==t.nonWitnessUtxo){const n=Lf(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 Cf(e){return 33===e.length&&nf.isCanonicalPubKey(e)}function Df(e,t,r,n,i){const o=(0,af.isP2SHScript)(e),s=o&&n&&(0,af.isP2WSHScript)(n),a=(0,af.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,_f(t,e,n,r),vf(t,n,i,r),Ff(u)):a?(u=i,vf(t,e,i,r),Ff(u)):o?(u=n,_f(t,e,n,r)):u=e,{meaningfulScript:u,type:s?"p2sh-p2wsh":o?"p2sh":a?"p2wsh":"raw"}}function Ff(e){if((0,af.isP2WPKH)(e)||(0,af.isP2SHScript)(e))throw new Error("P2WPKH or P2SH can not be contained within P2WSH")}function jf(e){return(0,af.isP2WPKH)(e)?"witnesspubkeyhash":(0,af.isP2PKH)(e)?"pubkeyhash":(0,af.isP2MS)(e)?"multisig":(0,af.isP2PK)(e)?"pubkey":"nonstandard"}function Vf(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=sa;Object.defineProperty(e,"Block",{enumerable:!0,get:function(){return s.Block}});var a=Ba;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=ua;Object.defineProperty(e,"Transaction",{enumerable:!0,get:function(){return c.Transaction}});var f=ws;Object.defineProperty(e,"initEccLib",{enumerable:!0,get:function(){return f.initEccLib}})}(ln);var Kf={exports:{}};!function(t){!function(){var r="input is invalid type",i="object"==typeof window,o=i?window:{};o.JS_SHA3_NO_WINDOW&&(i=!1);var s=!i&&"object"==typeof self;!o.JS_SHA3_NO_NODE_JS&&"object"==typeof n&&n.versions&&n.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,L,M,H,C,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,L=e[2]<<1|e[3]>>>31,M=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,H=e[14]<<6|e[15]>>>26,C=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]=L^~H&D,e[21]=M^~C&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]=H^~D&j,e[23]=C^~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&L,e[27]=V^~G&M,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^~L&H,e[29]=G^~M&C,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]]}()}(Kf);var Gf=Kf.exports;function Wf(e,r){const n=pn(e.publicKeyJwk),i=sn("errors","identityErrorBaseMessage");let o="";switch(r.code){case h.Bitcoin:case h.Mocknet:case h.Testnet:o=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:o=function(e,r){const n=e.toString("hex"),i=new v.ec("secp256k1").keyFromPublic(n,"hex").getPublic().encode("hex").slice(2),o=t;return`0x${Gf.keccak256(o.from(i,"hex")).slice(24).toString()}`}(n);break;default:throw new rn("deriveIssuingAddressFromPublicKey",`${i} - ${sn("errors","deriveIssuingAddressFromPublicKey")}`)}return o}function qf(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 Xf=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:zf}=S.suites;class $f extends zf{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(),qf(this.chain)&&(this.adaptProofVerificationProcessToMocknet(),this.adaptIdentityVerificationProcessToMocknet())}static decodeMerkleProof2019(e){return new Xr.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=$f.decodeMerkleProof2019(this.proof)}verifyProof({documentLoader:e,verifyIdentity:t}={documentLoader:e=>{},verifyIdentity:!0}){return Xf(this,void 0,void 0,(function*(){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 Xf(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 qf(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=$r(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(){Yr(this.proofVerificationProcess,"getTransactionId"),Yr(this.proofVerificationProcess,"fetchRemoteHash"),Yr(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,r=""){return Xf(this,void 0,void 0,(function*(){return yield t()}))}verifyProcess(e){return Xf(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 Xf(this,void 0,void 0,(function*(){yield this.executeStep("checkMerkleRoot",(()=>function(e,t){if(e!==t)throw new rn("checkMerkleRoot",sn("errors","ensureMerkleRootEqual"));return!0}(this.proofValue.merkleRoot,this.txData.remoteHash)),this.type)}))}compareHashes(){return Xf(this,void 0,void 0,(function*(){yield this.executeStep("compareHashes",(()=>function(e,t){if(e!==t)throw new rn("compareHashes",sn("errors","ensureHashesEqual"));return!0}(this.localDocumentHash,this.proofValue.targetHash)),this.type)}))}computeLocalHash(){return Xf(this,void 0,void 0,(function*(){this.localDocumentHash=yield this.executeStep("computeLocalHash",(()=>Xf(this,void 0,void 0,(function*(){return yield un(this.document,this.proof,this.documentLoader)}))),this.type)}))}checkReceipt(){return Xf(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=tn(`${n.left}${t}`),t=T(i);else{if(void 0===n.right)throw new rn("checkReceipt","Trigger catch error.");i=tn(`${t}${n.right}`),t=T(i)}}}catch(e){throw new rn("checkReceipt",sn("errors","ensureValidReceipt"))}if(t!==r)throw new rn("checkReceipt",sn("errors","invalidMerkleReceipt"))}(this.proofValue)}),this.type)}))}getTransactionId(){return Xf(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 rn("getTransactionId",sn("errors","isTransactionIdValid"))}(this.transactionId)),this.type)}))}fetchRemoteHash(){return Xf(this,void 0,void 0,(function*(){this.txData=yield this.executeStep("fetchRemoteHash",(()=>Xf(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 Xf(this,void 0,void 0,(function*(){this.derivedIssuingAddress=yield this.executeStep("deriveIssuingAddressFromPublicKey",(()=>Wf(this.verificationMethod,this.chain)),this.type)}))}compareIssuingAddress(){return Xf(this,void 0,void 0,(function*(){yield this.executeStep("compareIssuingAddress",(()=>{!function(e,t){const r=sn("errors","identityErrorBaseMessage");if(e!==t)throw new rn("compareIssuingAddress",`${r} - ${sn("errors","compareIssuingAddress")}`)}(this.getIssuerPublicKey(),this.derivedIssuingAddress)}),this.type)}))}}var Yf;function Jf(e){return $f.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"}(Yf||(Yf={}));class Qf extends A{proofVerificationProcess=[Yf.parseIssuerKeys,Yf.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=Jf(this.proof),this.transactionId=i.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=>i.verifier.convertToVerificationSubsteps(e,t)))}getIdentityVerificationSteps(e){return this.hasDid?this.suite.getIdentityVerificationProcess().map((t=>i.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 i.certificates.getTransactionId(this.getReceipt())}getTransactionLink(){return i.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).transactionLink}getRawTransactionLink(){return i.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=y(this.getTargetVerificationMethodContainer(),o(this.proof)),this.suite=new $f({document:this.documentToVerify,proof:this.proof,verificationMethod:this.verificationMethodPublicKey,options:{explorerAPIs:this.explorerAPIs,executeStepMethod:this.executeStep}})}adaptVerificationProcessToChain(){i.chains.isMockChain(this.chain)&&(s(this.proofVerificationProcess,Yf.parseIssuerKeys),s(this.proofVerificationProcess,Yf.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 i.verifier.getIssuerProfile(e)}}setHasDid(){if(this.getProofIndex()>0){const e=this.proof.verificationMethod.split("#")[0];this.hasDid=a(e)}else this.hasDid=!!this.issuer.didDocument}validateProofType(){const e=this.isProofChain()?this.proof.chainedProofType:this.proof.type;if(("DataIntegrityProof"!==e||this.proof.cryptosuite!==this.cryptosuite)&&e!==this.type)throw new Error(`Incompatible proof type passed. Expected: ${this.type}, 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(Yf.parseIssuerKeys,(()=>i.verifier.parseIssuerKeys(this.issuer)),this.type)}async checkAuthenticity(){await this.executeStep(Yf.checkAuthenticity,(()=>{k(this.issuerPublicKeyList,this.getIssuerPublicKey(),this.getIssuanceTime())}),this.type)}}export{Qf as default,Jf as parseReceipt};
|