@blockcerts/blockcerts-verifier 1.52.1 → 1.52.2

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/dist/ie11.js CHANGED
@@ -526,7 +526,7 @@ var ZD=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?a
526
526
  /*!
527
527
  * Copyright (c) 2010-2018 Digital Bazaar, Inc. All rights reserved.
528
528
  */
529
- var sF={},uF=sF,lF=bD;Object.assign(sF,lF);var AF=function(){function e(){s(this,e)}var t,i;return l(e,[{key:"add",value:(i=a(r().mark((function e(t){var i,o,a,s,u,l,A,c=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=c.length>1&&void 0!==c[1]?c[1]:{},o=i.suite,a=i.purpose,s=i.documentLoader,u=i.expansionMap,o){e.next=3;break}throw new TypeError('"options.suite" is required.');case 3:if(a){e.next=5;break}throw new TypeError('"options.purpose" is required.');case 5:return s=s?FD(s):PD,void 0===u?u=LD:!1===u&&(u=void 0),delete(l=n({},t)).proof,e.next=10,o.createProof({document:l,purpose:a,documentLoader:s,expansionMap:u});case 10:return A=e.sent,e.abrupt("return",(DD.addValue(t,"proof",A),t));case 12:case"end":return e.stop()}}),e)}))),function(e){return i.apply(this,arguments)})},{key:"verify",value:(t=a(r().mark((function e(t){var i,o,s,u,l,A,c,h,f,d,p,g,v,y,m,w=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=w.length>1&&void 0!==w[1]?w[1]:{},o=i.suite,s=i.purpose,u=i.documentLoader,l=i.expansionMap,o){e.next=3;break}throw new TypeError('"options.suite" is required.');case 3:if(s){e.next=5;break}throw new TypeError('"options.purpose" is required.');case 5:if(0!==(A=Array.isArray(o)?o:[o]).length){e.next=8;break}throw new TypeError("At least one suite is required.");case 8:return u=u?FD(u):PD,void 0===l?l=LD:!1===l&&(l=void 0),e.prev=9,t=n({},t),e.next=13,function(){var e=a(r().mark((function e(t){var i,o,a;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=t.document,o=DD.getValues(i,"proof"),delete i.proof,0!==o.length){e.next=3;break}throw new Error("No matching proofs found in the given document.");case 3:return a=i["@context"]||ND.SECURITY_CONTEXT_URL,e.abrupt("return",(o=o.map((function(e){return n({"@context":a},e)})),{proofSet:o,document:i}));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()({document:t,documentLoader:u,expansionMap:l});case 13:return c=e.sent,h=c.proofSet,f=c.document,t=f,e.next=19,function(){var e=a(r().mark((function e(t){var n,i,o,s,u,l,A,c,h,f,d;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.document,i=t.suites,o=t.proofSet,s=t.purpose,u=t.documentLoader,l=t.expansionMap,A=Array.isArray(s)?s:[s],c=new Map,h=new Map,f=new Map,e.next=4,Promise.all(A.map((function(e){return(t=a(r().mark((function e(t){var n,i,o,a,s,u,l,A,c,h,f,d,p,g,v,y,m,w,b;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=t.purposeToProofs,i=t.proofToSuite,o=t.purpose,a=t.proofSet,s=t.suites,u=t.suiteMatchQueue,l=t.document,A=t.documentLoader,c=t.expansionMap,h=F(a),e.prev=2,h.s();case 4:if((f=h.n()).done){e.next=38;break}return d=f.value,e.next=8,o.match(d,{document:l,documentLoader:A,expansionMap:c});case 8:if(e.sent){e.next=10;break}return e.abrupt("continue",36);case 10:p=!1,g=F(s),e.prev=12,g.s();case 14:if((v=g.n()).done){e.next=27;break}return y=v.value,(m=u.get(y))||u.set(y,m=new Map),(w=m.get(d))||(w=y.matchProof({proof:d,document:l,documentLoader:A,expansionMap:c}),m.set(d,w)),e.next=22,w;case 22:if(!e.sent){e.next=25;break}return p=!0,i.set(d,y),e.abrupt("break",27);case 25:e.next=14;break;case 27:e.next=32;break;case 29:e.prev=29,e.t0=e.catch(12),g.e(e.t0);case 32:return e.prev=32,g.f(),e.finish(32);case 35:p&&((b=n.get(o))?b.push(d):n.set(o,[d]));case 36:e.next=4;break;case 38:e.next=43;break;case 40:e.prev=40,e.t1=e.catch(2),h.e(e.t1);case 43:return e.prev=43,h.f(),e.finish(43);case 46:case"end":return e.stop()}}),e,null,[[2,40,43,46],[12,29,32,35]])}))),function(e){return t.apply(this,arguments)})({purposeToProofs:c,proofToSuite:h,purpose:e,proofSet:o,suites:i,suiteMatchQueue:f,document:n,documentLoader:u,expansionMap:l});var t})));case 4:if(!(c.size<A.length)){e.next=6;break}return e.abrupt("return",[]);case 6:return d=new Map,e.next=9,Promise.all(k(h.entries()).map(function(){var e=a(r().mark((function e(t){var i,o,s,A,c,h,f,p,g,v;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=C(t,2),o=i[0],s=i[1],e.prev=1,h={validate:function(){var e=a(r().mark((function e(t,n){var i;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=n.verificationMethod,e.abrupt("return",(c=i,{valid:!0}));case 2:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}()},e.next=5,s.verifyProof({proof:o,document:n,purpose:h,documentLoader:u,expansionMap:l});case 5:f=e.sent,p=f.verified,g=f.verificationMethod,v=f.error,c||(c=g),A={proof:o,verified:p,verificationMethod:c,error:v},e.next=15;break;case 12:e.prev=12,e.t0=e.catch(1),A={proof:o,verified:!1,error:e.t0};case 15:A.error&&MD(A.error),d.set(o,A);case 16:case"end":return e.stop()}}),e,null,[[1,12]])})));return function(t){return e.apply(this,arguments)}}()));case 9:return e.next=11,Promise.all(k(c.entries()).map(function(){var e=a(r().mark((function e(t){var i,o,a,s,A,c,f,p,g,v;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=C(t,2),o=i[0],a=i[1],s=F(a),e.prev=2,s.s();case 4:if((A=s.n()).done){e.next=23;break}if(c=A.value,(f=d.get(c)).verified){e.next=9;break}return e.abrupt("continue",21);case 9:return p=f.verificationMethod,g=h.get(c),v=void 0,e.prev=11,e.next=14,o.validate(c,{document:n,suite:g,verificationMethod:p,documentLoader:u,expansionMap:l});case 14:v=e.sent,e.next=20;break;case 17:e.prev=17,e.t0=e.catch(11),v={valid:!1,error:e.t0};case 20:f.purposeResult?Array.isArray(f.purposeResult)?f.purposeResult.push(v):f.purposeResult=[f.purposeResult,v]:f.purposeResult=v,v.valid||(MD(v.error),f.error||(f.verified=!1,f.error=v.error));case 21:e.next=4;break;case 23:e.next=28;break;case 25:e.prev=25,e.t1=e.catch(2),s.e(e.t1);case 28:return e.prev=28,s.f(),e.finish(28);case 31:case"end":return e.stop()}}),e,null,[[2,25,28,31],[11,17]])})));return function(t){return e.apply(this,arguments)}}()));case 11:return e.abrupt("return",k(d.values()));case 12:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()({document:t,suites:A,proofSet:h,purpose:s,documentLoader:u,expansionMap:l});case 19:if(0!==(d=e.sent).length){e.next=23;break}throw(p=new Error("Did not verify any proofs; insufficient proofs matched the acceptable suite(s) and required purpose(s).")).name="NotFoundError",p;case 23:if(g=d.some((function(e){return e.verified})),g){e.next=27;break}return y=(v=[]).concat.apply(v,k(d.filter((function(e){return e.error})).map((function(e){return e.error})))),m={verified:g,results:d},e.abrupt("return",(y.length>0&&(m.error=y),m));case 27:return e.abrupt("return",{verified:g,results:d});case 30:return e.prev=30,e.t0=e.catch(9),e.abrupt("return",(MD(e.t0),{verified:!1,error:e.t0}));case 33:case"end":return e.stop()}}),e,null,[[9,30]])}))),function(e){return t.apply(this,arguments)})}]),e}(),cF=RD;function hF(e){var t=Object.keys(Ul).map((function(e){return Ul[e]})).find((function(t){return t.signatureValue===e}));return t}function fF(e,t){var n=e.findIndex((function(e){return e===t}));n>-1&&e.splice(n,1)}sF.sign=function(){var e=a(r().mark((function e(t){var n,o,a,s,u,l,A,c,h,f=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=f.length>1&&void 0!==f[1]?f[1]:{},o=n.suite,a=n.purpose,s=n.documentLoader,u=n.expansionMap,l=n.addSuiteContext,A=void 0===l||l,"object"==i(t)){e.next=3;break}throw new TypeError('The "document" parameter must be an object.');case 3:return o.ensureSuiteContext({document:t,addSuiteContext:A}),e.prev=4,e.next=7,(new AF).add(t,{suite:o,purpose:a,documentLoader:s,expansionMap:u});case 7:return e.abrupt("return",e.sent);case 10:if(e.prev=10,e.t0=e.catch(4),s||"jsonld.InvalidUrl"!==e.t0.name){e.next=15;break}throw c=e.t0.details.url,(h=new Error('A URL "'.concat(c,'" could not be fetched; you need to pass "documentLoader" or resolve the URL before calling "sign".'))).cause=e.t0,h;case 15:throw e.t0;case 16:case"end":return e.stop()}}),e,null,[[4,10]])})));return function(t){return e.apply(this,arguments)}}(),sF.verify=function(){var e=a(r().mark((function e(t){var n,o,a,s,u,l,A,c,h,f=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=f.length>1&&void 0!==f[1]?f[1]:{},o=n.suite,a=n.purpose,s=n.documentLoader,u=n.expansionMap,"object"==i(t)){e.next=3;break}throw new TypeError('The "document" parameter must be an object.');case 3:return e.next=5,(new AF).verify(t,{suite:o,purpose:a,documentLoader:s,expansionMap:u});case 5:return l=e.sent,(A=l.error)&&(s||"jsonld.InvalidUrl"!==A.name?l.error=new cF(A):(c=A.details.url,h=new Error('A URL "'.concat(c,'" could not be fetched; you need to pass "documentLoader" or resolve the URL before calling "verify".')),l.error=new cF(h))),e.abrupt("return",l);case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),sF.suites=WD.suites,sF.purposes=aF.purposes,Object.assign(sF,xD);var dF={"@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"}]},pF={"@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"}}},gF={"@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"}}};function vF(e){e=e.trim();for(var t=[],n=0;n<e.length;n+=2)t.push(parseInt(e.substring(n,n+2),16));return t}Rf["https://w3id.org/blockcerts/schema/2.0-alpha/context.json"]=dF,Rf["https://www.blockcerts.org/schema/2.0-alpha/context.json"]=dF,Rf["https://www.blockcerts.org/schema/3.0-alpha/context.json"]=pF,Rf["https://w3id.org/blockcerts/schema/3.0-alpha/context.json"]=pF,Rf["https://w3id.org/blockcerts/v3.0-alpha"]=pF,Rf["https://www.blockcerts.org/schema/3.0-beta/context.json"]=gF,Rf["https://w3id.org/blockcerts/schema/3.0-beta/context.json"]=gF,Rf["https://w3id.org/blockcerts/v3.0-beta"]=gF,Rf["https://w3id.org/security/suites/ed25519-2020/v1"]={"@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"}}}}};var yF=function(e){c(n,e);var t=b(n);function n(e,r){var i;return s(this,n),(i=t.call(this,r)).stepCode=e,i}return l(n)}(g(Error)),mF="en-US",wF={"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 bF(e,t){return e&&t?wF[mF]?wF[mF][e]?wF[mF][e][t]?wF[mF][e][t]||"":"[missing locale item data]":"[missing locale group data]":"[missing locale data]":""}var IF=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){e.done?i(e.value):function(e){return e instanceof n?e:new n((function(t){t(e)}))}(e.value).then(a,s)}u((r=r.apply(e,t||[])).next())}))};function BF(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(e){};return IF(this,void 0,void 0,r().mark((function i(){var o,a,s,u,l;return r().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(e["@context"].find((function(e){return(t=e)===Object(t)&&"@vocab"in e;var t}))||e["@context"].push({"@vocab":"http://fallback.org/"}),o=JSON.parse(JSON.stringify(e)),!Array.isArray(o.proof)){i.next=9;break}if(t){i.next=5;break}throw new yF("computeLocalHash",bF("errors","noProofSpecified"));case 5:a=o.proof.findIndex((function(e){return e.proofValue===t.proofValue})),o.proof=o.proof.slice(0,a),i.next=10;break;case 9:delete o.proof;case 10:return s={algorithm:"URDNA2015",format:"application/nquads",documentLoader:function(e){return IF(this,void 0,void 0,r().mark((function t(){return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.t0=null!=n,!t.t0){t.next=4;break}return t.next=4,n(e);case 4:return t.abrupt("return",e in Rf?{contextUrl:null,document:Rf[e],documentUrl:e}:nw.documentLoader(e));case 5:case"end":return t.stop()}}),t)})))}},i.prev=11,i.next=14,nw.normalize(o,s);case 14:u=i.sent,i.next=20;break;case 17:throw i.prev=17,i.t0=i.catch(11),console.error(i.t0),new yF("computeLocalHash",bF("errors","failedJsonLdNormalization"));case 20:if(l=function(e){var t=e.split("\n"),n=/<http:\/\/fallback\.org\/(.*)>/,r=t.map((function(e){return n.exec(e)})).filter((function(e){return null!=e}));if(r.length>0){var i=r.map((function(e){return e[1]})).sort();return Array.from(new Set(i))}return null}(u),!l){i.next=23;break}throw new yF("computeLocalHash","".concat(bF("errors","foundUnmappedFields"),": ").concat(l.join(", ")));case 23:return i.abrupt("return",vk(function(e){for(var t=[],n=0;n<e.length;n++){var r=e.charCodeAt(n);r<128?t.push(r):r<2048?t.push(192|r>>6,128|63&r):r<55296||r>=57344?t.push(224|r>>12,128|r>>6&63,128|63&r):(n++,r=65536+((1023&r)<<10|1023&e.charCodeAt(n)),t.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|63&r))}return t}(u)));case 24:case"end":return i.stop()}}),i,null,[[11,17]])})))}var EF,CF=function(e){c(n,e);var t=b(n);function n(e){return s(this,n),t.call(this,e||"This operation is not supported for this key type")}return l(n)}(g(Error)),xF=CF,kF=function(e){c(n,e);var t=b(n);function n(){return s(this,n),t.call(this,"This has not been implemented yet")}return l(n)}(g(Error)),SF=function(){function e(){s(this,e),this.registry=[],this.classes={}}return l(e,[{key:"find",value:function(e){return this.registry.find(e)}},{key:"define",value:function(e,t){var n=this;e.forEach((function(e){var r=e.kty;if(!r)throw new Error("Invalid type definition");n.classes[r]||(n.classes[r]=t),n.registry.push(e)}))}},{key:"normalize",value:function(e,t,n){var r=this.classes[e],i=this.find((function(e){return e[t]===n}));if(!r||!i)throw new Error("Invalid type");return new r(i)}}]),e}(),QF=kF,_F=function(){function e(t){s(this,e),this.params=t}return l(e,[{key:"fromPrivatePKCS1",value:function(e){throw new QF}},{key:"fromPrivatePKCS8",value:function(e){throw new QF}},{key:"fromPublicPKCS1",value:function(e){throw new QF}},{key:"fromPublicPKCS8",value:function(e){throw new QF}},{key:"fromPrivateBlk",value:function(e){throw new QF}},{key:"fromPublicBlk",value:function(e){throw new QF}},{key:"fromJwk",value:function(e){throw new QF}},{key:"toPrivatePKCS1",value:function(e){throw new QF}},{key:"toPrivatePKCS8",value:function(e){throw new QF}},{key:"toPublicPKCS1",value:function(e){throw new QF}},{key:"toPublicPKCS8",value:function(e){throw new QF}},{key:"toPrivateBlk",value:function(e){throw new QF}},{key:"toPublicBlk",value:function(e){throw new QF}},{key:"toPrivateJwk",value:function(e){throw new QF}},{key:"toPublicJwk",value:function(e){throw new QF}}],[{key:"formatPem",value:function(e,t){return"-----BEGIN ".concat(t," KEY-----\n")+e.match(/.{1,64}/g).join("\n")+"\n-----END ".concat(t," KEY-----")}}]),e}(),NF={},DF={},FF={},PF=Fa,UF=PF.Buffer,LF={};for(EF in PF)PF.hasOwnProperty(EF)&&"SlowBuffer"!==EF&&"Buffer"!==EF&&(LF[EF]=PF[EF]);var MF=LF.Buffer={};for(EF in UF)UF.hasOwnProperty(EF)&&"allocUnsafe"!==EF&&"allocUnsafeSlow"!==EF&&(MF[EF]=UF[EF]);if(LF.Buffer.prototype=UF.prototype,MF.from&&MF.from!==Uint8Array.from||(MF.from=function(e,t,n){if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type '+i(e));if(e&&void 0===e.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+i(e));return UF(e,t,n)}),MF.alloc||(MF.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError('The "size" argument must be of type number. Received type '+i(e));if(e<0||e>=2*(1<<30))throw new RangeError('The value "'+e+'" is invalid for option "size"');var r=UF(e);return t&&0!==t.length?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r}),!LF.kStringMaxLength)try{LF.kStringMaxLength=lA.binding("buffer").kStringMaxLength}catch(e){}LF.constants||(LF.constants={MAX_LENGTH:LF.kMaxLength},LF.kStringMaxLength&&(LF.constants.MAX_STRING_LENGTH=LF.kStringMaxLength));var TF=LF,RF={},OF=KI.exports;function HF(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function KF(e,t){this.path=e,this.rethrow(t)}RF.Reporter=HF,HF.prototype.isError=function(e){return e instanceof KF},HF.prototype.save=function(){var e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},HF.prototype.restore=function(e){var t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},HF.prototype.enterKey=function(e){return this._reporterState.path.push(e)},HF.prototype.exitKey=function(e){var t=this._reporterState;t.path=t.path.slice(0,e-1)},HF.prototype.leaveKey=function(e,t,n){var r=this._reporterState;this.exitKey(e),null!==r.obj&&(r.obj[t]=n)},HF.prototype.path=function(){return this._reporterState.path.join("/")},HF.prototype.enterObject=function(){var e=this._reporterState,t=e.obj;return e.obj={},t},HF.prototype.leaveObject=function(e){var t=this._reporterState,n=t.obj;return t.obj=e,n},HF.prototype.error=function(e){var t,n=this._reporterState,r=e instanceof KF;if(t=r?e:new KF(n.path.map((function(e){return"["+JSON.stringify(e)+"]"})).join(""),e.message||e,e.stack),!n.options.partial)throw t;return r||n.errors.push(t),t},HF.prototype.wrapResult=function(e){var t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},OF(KF,Error),KF.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,KF),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this};var jF={},GF=KI.exports,qF=RF.Reporter,VF=TF.Buffer;function zF(e,t){qF.call(this,t),VF.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function JF(e,t){if(Array.isArray(e))this.length=0,this.value=e.map((function(e){return JF.isEncoderBuffer(e)||(e=new JF(e,t)),this.length+=e.length,e}),this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=VF.byteLength(e);else{if(!VF.isBuffer(e))return t.error("Unsupported type: "+i(e));this.value=e,this.length=e.length}}GF(zF,qF),jF.DecoderBuffer=zF,zF.isDecoderBuffer=function(e){return e instanceof zF||"object"==i(e)&&VF.isBuffer(e.base)&&"DecoderBuffer"===e.constructor.name&&"number"==typeof e.offset&&"number"==typeof e.length&&"function"==typeof e.save&&"function"==typeof e.restore&&"function"==typeof e.isEmpty&&"function"==typeof e.readUInt8&&"function"==typeof e.skip&&"function"==typeof e.raw},zF.prototype.save=function(){return{offset:this.offset,reporter:qF.prototype.save.call(this)}},zF.prototype.restore=function(e){var t=new zF(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,qF.prototype.restore.call(this,e.reporter),t},zF.prototype.isEmpty=function(){return this.offset===this.length},zF.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},zF.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");var n=new zF(this.base);return n._reporterState=this._reporterState,n.offset=this.offset,n.length=this.offset+e,this.offset+=e,n},zF.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},jF.EncoderBuffer=JF,JF.isEncoderBuffer=function(e){return e instanceof JF||"object"==i(e)&&"EncoderBuffer"===e.constructor.name&&"number"==typeof e.length&&"function"==typeof e.join},JF.prototype.join=function(e,t){return e||(e=VF.alloc(this.length)),t||(t=0),0===this.length||(Array.isArray(this.value)?this.value.forEach((function(n){n.join(e,t),t+=n.length})):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):VF.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length)),e};var YF=RF.Reporter,XF=jF.EncoderBuffer,WF=jF.DecoderBuffer,ZF=xI,$F=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],eP=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat($F);function tP(e,t,n){var r={};this._baseState=r,r.name=n,r.enc=e,r.parent=t||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r.default=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}var nP=tP,rP=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];tP.prototype.clone=function(){var e=this._baseState,t={};rP.forEach((function(n){t[n]=e[n]}));var n=new this.constructor(t.parent);return n._baseState=t,n},tP.prototype._wrap=function(){var e=this._baseState;eP.forEach((function(t){this[t]=function(){var n=new this.constructor(this);return e.children.push(n),n[t].apply(n,arguments)}}),this)},tP.prototype._init=function(e){var t=this._baseState;ZF(null===t.parent),e.call(this),t.children=t.children.filter((function(e){return e._baseState.parent===this}),this),ZF.equal(t.children.length,1,"Root node can have only one child")},tP.prototype._useArgs=function(e){var t=this._baseState,n=e.filter((function(e){return e instanceof this.constructor}),this);e=e.filter((function(e){return!(e instanceof this.constructor)}),this),0!==n.length&&(ZF(null===t.children),t.children=n,n.forEach((function(e){e._baseState.parent=this}),this)),0!==e.length&&(ZF(null===t.args),t.args=e,t.reverseArgs=e.map((function(e){if("object"!=i(e)||e.constructor!==Object)return e;var t={};return Object.keys(e).forEach((function(n){n==(0|n)&&(n|=0);var r=e[n];t[r]=n})),t})))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach((function(e){tP.prototype[e]=function(){var t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}})),$F.forEach((function(e){tP.prototype[e]=function(){var t=this._baseState,n=Array.prototype.slice.call(arguments);return ZF(null===t.tag),t.tag=e,this._useArgs(n),this}})),tP.prototype.use=function(e){ZF(e);var t=this._baseState;return ZF(null===t.use),t.use=e,this},tP.prototype.optional=function(){return this._baseState.optional=!0,this},tP.prototype.def=function(e){var t=this._baseState;return ZF(null===t.default),t.default=e,t.optional=!0,this},tP.prototype.explicit=function(e){var t=this._baseState;return ZF(null===t.explicit&&null===t.implicit),t.explicit=e,this},tP.prototype.implicit=function(e){var t=this._baseState;return ZF(null===t.explicit&&null===t.implicit),t.implicit=e,this},tP.prototype.obj=function(){var e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},tP.prototype.key=function(e){var t=this._baseState;return ZF(null===t.key),t.key=e,this},tP.prototype.any=function(){return this._baseState.any=!0,this},tP.prototype.choice=function(e){var t=this._baseState;return ZF(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map((function(t){return e[t]}))),this},tP.prototype.contains=function(e){var t=this._baseState;return ZF(null===t.use),t.contains=e,this},tP.prototype._decode=function(e,t){var n=this._baseState;if(null===n.parent)return e.wrapResult(n.children[0]._decode(e,t));var r,i=n.default,o=!0,a=null;if(null!==n.key&&(a=e.enterKey(n.key)),n.optional){var s=null;if(null!==n.explicit?s=n.explicit:null!==n.implicit?s=n.implicit:null!==n.tag&&(s=n.tag),null!==s||n.any){if(o=this._peekTag(e,s,n.any),e.isError(o))return o}else{var u=e.save();try{null===n.choice?this._decodeGeneric(n.tag,e,t):this._decodeChoice(e,t),o=!0}catch(e){o=!1}e.restore(u)}}if(n.obj&&o&&(r=e.enterObject()),o){if(null!==n.explicit){var l=this._decodeTag(e,n.explicit);if(e.isError(l))return l;e=l}var A=e.offset;if(null===n.use&&null===n.choice){var c;n.any&&(c=e.save());var h=this._decodeTag(e,null!==n.implicit?n.implicit:n.tag,n.any);if(e.isError(h))return h;n.any?i=e.raw(c):e=h}if(t&&t.track&&null!==n.tag&&t.track(e.path(),A,e.length,"tagged"),t&&t.track&&null!==n.tag&&t.track(e.path(),e.offset,e.length,"content"),n.any||(i=null===n.choice?this._decodeGeneric(n.tag,e,t):this._decodeChoice(e,t)),e.isError(i))return i;if(n.any||null!==n.choice||null===n.children||n.children.forEach((function(n){n._decode(e,t)})),n.contains&&("octstr"===n.tag||"bitstr"===n.tag)){var f=new WF(i);i=this._getUse(n.contains,e._reporterState.obj)._decode(f,t)}}return n.obj&&o&&(i=e.leaveObject(r)),null===n.key||null===i&&!0!==o?null!==a&&e.exitKey(a):e.leaveKey(a,n.key,i),i},tP.prototype._decodeGeneric=function(e,t,n){var r=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,r.args[0],n):/str$/.test(e)?this._decodeStr(t,e,n):"objid"===e&&r.args?this._decodeObjid(t,r.args[0],r.args[1],n):"objid"===e?this._decodeObjid(t,null,null,n):"gentime"===e||"utctime"===e?this._decodeTime(t,e,n):"null_"===e?this._decodeNull(t,n):"bool"===e?this._decodeBool(t,n):"objDesc"===e?this._decodeStr(t,e,n):"int"===e||"enum"===e?this._decodeInt(t,r.args&&r.args[0],n):null!==r.use?this._getUse(r.use,t._reporterState.obj)._decode(t,n):t.error("unknown tag: "+e)},tP.prototype._getUse=function(e,t){var n=this._baseState;return n.useDecoder=this._use(e,t),ZF(null===n.useDecoder._baseState.parent),n.useDecoder=n.useDecoder._baseState.children[0],n.implicit!==n.useDecoder._baseState.implicit&&(n.useDecoder=n.useDecoder.clone(),n.useDecoder._baseState.implicit=n.implicit),n.useDecoder},tP.prototype._decodeChoice=function(e,t){var n=this._baseState,r=null,i=!1;return Object.keys(n.choice).some((function(o){var a=e.save(),s=n.choice[o];try{var u=s._decode(e,t);if(e.isError(u))return!1;r={type:o,value:u},i=!0}catch(t){return e.restore(a),!1}return!0}),this),i?r:e.error("Choice not matched")},tP.prototype._createEncoderBuffer=function(e){return new XF(e,this.reporter)},tP.prototype._encode=function(e,t,n){var r=this._baseState;if(null===r.default||r.default!==e){var i=this._encodeValue(e,t,n);return void 0===i||this._skipDefault(i,t,n)?void 0:i}},tP.prototype._encodeValue=function(e,t,n){var r=this._baseState;if(null===r.parent)return r.children[0]._encode(e,t||new YF);var o=null;if(this.reporter=t,r.optional&&void 0===e){if(null===r.default)return;e=r.default}var a=null,s=!1;if(r.any)o=this._createEncoderBuffer(e);else if(r.choice)o=this._encodeChoice(e,t);else if(r.contains)a=this._getUse(r.contains,n)._encode(e,t),s=!0;else if(r.children)a=r.children.map((function(n){if("null_"===n._baseState.tag)return n._encode(null,t,e);if(null===n._baseState.key)return t.error("Child should have a key");var r=t.enterKey(n._baseState.key);if("object"!=i(e))return t.error("Child expected, but input is not object");var o=n._encode(e[n._baseState.key],t,e);return t.leaveKey(r),o}),this).filter((function(e){return e})),a=this._createEncoderBuffer(a);else if("seqof"===r.tag||"setof"===r.tag){if(!r.args||1!==r.args.length)return t.error("Too many args for : "+r.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");var u=this.clone();u._baseState.implicit=null,a=this._createEncoderBuffer(e.map((function(n){var r=this._baseState;return this._getUse(r.args[0],e)._encode(n,t)}),u))}else null!==r.use?o=this._getUse(r.use,n)._encode(e,t):(a=this._encodePrimitive(r.tag,e),s=!0);if(!r.any&&null===r.choice){var l=null!==r.implicit?r.implicit:r.tag,A=null===r.implicit?"universal":"context";null===l?null===r.use&&t.error("Tag could be omitted only for .use()"):null===r.use&&(o=this._encodeComposite(l,s,A,a))}return null!==r.explicit&&(o=this._encodeComposite(r.explicit,!1,"context",o)),o},tP.prototype._encodeChoice=function(e,t){var n=this._baseState,r=n.choice[e.type];return r||ZF(!1,e.type+" not found in "+JSON.stringify(Object.keys(n.choice))),r._encode(e.value,t)},tP.prototype._encodePrimitive=function(e,t){var n=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&n.args)return this._encodeObjid(t,n.reverseArgs[0],n.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,n.args&&n.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},tP.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},tP.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(e)};var iP={};!function(e){function t(e){var t={};return Object.keys(e).forEach((function(n){(0|n)==n&&(n|=0);var r=e[n];t[r]=n})),t}e.tagClass={0:"universal",1:"application",2:"context",3:"private"},e.tagClassByName=t(e.tagClass),e.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},e.tagByName=t(e.tag)}(iP);var oP=KI.exports,aP=TF.Buffer,sP=nP,uP=iP;function lP(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new cP,this.tree._init(e.body)}var AP=lP;function cP(e){sP.call(this,"der",e)}function hP(e){return e<10?"0"+e:e}lP.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},oP(cP,sP),cP.prototype._encodeComposite=function(e,t,n,r){var i=function(e,t,n,r){var i;if("seqof"===e?e="seq":"setof"===e&&(e="set"),uP.tagByName.hasOwnProperty(e))i=uP.tagByName[e];else{if("number"!=typeof e||(0|e)!==e)return r.error("Unknown tag: "+e);i=e}return i>=31?r.error("Multi-octet tag encoding unsupported"):(t||(i|=32),i|=uP.tagClassByName[n||"universal"]<<6)}(e,t,n,this.reporter);if(r.length<128){var o=aP.alloc(2);return o[0]=i,o[1]=r.length,this._createEncoderBuffer([o,r])}for(var a=1,s=r.length;s>=256;s>>=8)a++;var u=aP.alloc(2+a);u[0]=i,u[1]=128|a;for(var l=1+a,A=r.length;A>0;l--,A>>=8)u[l]=255&A;return this._createEncoderBuffer([u,r])},cP.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){for(var n=aP.alloc(2*e.length),r=0;r<e.length;r++)n.writeUInt16BE(e.charCodeAt(r),2*r);return this._createEncoderBuffer(n)}return"numstr"===t?this._isNumstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===t?this._isPrintstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(t)||"objDesc"===t?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: "+t+" unsupported")},cP.prototype._encodeObjid=function(e,t,n){if("string"==typeof e){if(!t)return this.reporter.error("string objid given, but no values map found");if(!t.hasOwnProperty(e))return this.reporter.error("objid not found in values map");e=t[e].split(/[\s.]+/g);for(var r=0;r<e.length;r++)e[r]|=0}else if(Array.isArray(e)){e=e.slice();for(var i=0;i<e.length;i++)e[i]|=0}if(!Array.isArray(e))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(e));if(!n){if(e[1]>=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}for(var o=0,a=0;a<e.length;a++){var s=e[a];for(o++;s>=128;s>>=7)o++}for(var u=aP.alloc(o),l=u.length-1,A=e.length-1;A>=0;A--){var c=e[A];for(u[l--]=127&c;(c>>=7)>0;)u[l--]=128|127&c}return this._createEncoderBuffer(u)},cP.prototype._encodeTime=function(e,t){var n,r=new Date(e);return"gentime"===t?n=[hP(r.getUTCFullYear()),hP(r.getUTCMonth()+1),hP(r.getUTCDate()),hP(r.getUTCHours()),hP(r.getUTCMinutes()),hP(r.getUTCSeconds()),"Z"].join(""):"utctime"===t?n=[hP(r.getUTCFullYear()%100),hP(r.getUTCMonth()+1),hP(r.getUTCDate()),hP(r.getUTCHours()),hP(r.getUTCMinutes()),hP(r.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(n,"octstr")},cP.prototype._encodeNull=function(){return this._createEncoderBuffer("")},cP.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!aP.isBuffer(e)){var n=e.toArray();!e.sign&&128&n[0]&&n.unshift(0),e=aP.from(n)}if(aP.isBuffer(e)){var r=e.length;0===e.length&&r++;var i=aP.alloc(r);return e.copy(i),0===e.length&&(i[0]=0),this._createEncoderBuffer(i)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);for(var o=1,a=e;a>=256;a>>=8)o++;for(var s=new Array(o),u=s.length-1;u>=0;u--)s[u]=255&e,e>>=8;return 128&s[0]&&s.unshift(0),this._createEncoderBuffer(aP.from(s))},cP.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},cP.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},cP.prototype._skipDefault=function(e,t,n){var r,i=this._baseState;if(null===i.default)return!1;var o=e.join();if(void 0===i.defaultBuffer&&(i.defaultBuffer=this._encodeValue(i.default,t,n).join()),o.length!==i.defaultBuffer.length)return!1;for(r=0;r<o.length;r++)if(o[r]!==i.defaultBuffer[r])return!1;return!0};var fP=KI.exports,dP=AP;function pP(e){dP.call(this,e),this.enc="pem"}fP(pP,dP);var gP=pP;pP.prototype.encode=function(e,t){for(var n=dP.prototype.encode.call(this,e).toString("base64"),r=["-----BEGIN "+t.label+"-----"],i=0;i<n.length;i+=64)r.push(n.slice(i,i+64));return r.push("-----END "+t.label+"-----"),r.join("\n")},function(e){var t=e;t.der=AP,t.pem=gP}(FF);var vP={},yP=KI.exports,mP=CI.exports,wP=jF.DecoderBuffer,bP=nP,IP=iP;function BP(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new CP,this.tree._init(e.body)}var EP=BP;function CP(e){bP.call(this,"der",e)}function xP(e,t){var n=e.readUInt8(t);if(e.isError(n))return n;var r=IP.tagClass[n>>6],i=0==(32&n);if(31==(31&n)){var o=n;for(n=0;128==(128&o);){if(o=e.readUInt8(t),e.isError(o))return o;n<<=7,n|=127&o}}else n&=31;return{cls:r,primitive:i,tag:n,tagStr:IP.tag[n]}}function kP(e,t,n){var r=e.readUInt8(n);if(e.isError(r))return r;if(!t&&128===r)return null;if(0==(128&r))return r;var i=127&r;if(i>4)return e.error("length octect is too long");r=0;for(var o=0;o<i;o++){r<<=8;var a=e.readUInt8(n);if(e.isError(a))return a;r|=a}return r}BP.prototype.decode=function(e,t){return wP.isDecoderBuffer(e)||(e=new wP(e,t)),this.tree._decode(e,t)},yP(CP,bP),CP.prototype._peekTag=function(e,t,n){if(e.isEmpty())return!1;var r=e.save(),i=xP(e,'Failed to peek tag: "'+t+'"');return e.isError(i)?i:(e.restore(r),i.tag===t||i.tagStr===t||i.tagStr+"of"===t||n)},CP.prototype._decodeTag=function(e,t,n){var r=xP(e,'Failed to decode tag of "'+t+'"');if(e.isError(r))return r;var i=kP(e,r.primitive,'Failed to get length of "'+t+'"');if(e.isError(i))return i;if(!n&&r.tag!==t&&r.tagStr!==t&&r.tagStr+"of"!==t)return e.error('Failed to match tag: "'+t+'"');if(r.primitive||null!==i)return e.skip(i,'Failed to match body of: "'+t+'"');var o=e.save(),a=this._skipUntilEnd(e,'Failed to skip indefinite length body: "'+this.tag+'"');return e.isError(a)?a:(i=e.offset-o.offset,e.restore(o),e.skip(i,'Failed to match body of: "'+t+'"'))},CP.prototype._skipUntilEnd=function(e,t){for(;;){var n=xP(e,t);if(e.isError(n))return n;var r=kP(e,n.primitive,t);if(e.isError(r))return r;var i;if(i=n.primitive||null!==r?e.skip(r):this._skipUntilEnd(e,t),e.isError(i))return i;if("end"===n.tagStr)break}},CP.prototype._decodeList=function(e,t,n,r){for(var i=[];!e.isEmpty();){var o=this._peekTag(e,"end");if(e.isError(o))return o;var a=n.decode(e,"der",r);if(e.isError(a)&&o)break;i.push(a)}return i},CP.prototype._decodeStr=function(e,t){if("bitstr"===t){var n=e.readUInt8();return e.isError(n)?n:{unused:n,data:e.raw()}}if("bmpstr"===t){var r=e.raw();if(r.length%2==1)return e.error("Decoding of string type: bmpstr length mismatch");for(var i="",o=0;o<r.length/2;o++)i+=String.fromCharCode(r.readUInt16BE(2*o));return i}if("numstr"===t){var a=e.raw().toString("ascii");return this._isNumstr(a)?a:e.error("Decoding of string type: numstr unsupported characters")}if("octstr"===t)return e.raw();if("objDesc"===t)return e.raw();if("printstr"===t){var s=e.raw().toString("ascii");return this._isPrintstr(s)?s:e.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(t)?e.raw().toString():e.error("Decoding of string type: "+t+" unsupported")},CP.prototype._decodeObjid=function(e,t,n){for(var r,i=[],o=0,a=0;!e.isEmpty();)o<<=7,o|=127&(a=e.readUInt8()),0==(128&a)&&(i.push(o),o=0);128&a&&i.push(o);var s=i[0]/40|0,u=i[0]%40;if(r=n?i:[s,u].concat(i.slice(1)),t){var l=t[r.join(" ")];void 0===l&&(l=t[r.join(".")]),void 0!==l&&(r=l)}return r},CP.prototype._decodeTime=function(e,t){var n,r,i,o,a,s,u=e.raw().toString();if("gentime"===t)n=0|u.slice(0,4),r=0|u.slice(4,6),i=0|u.slice(6,8),o=0|u.slice(8,10),a=0|u.slice(10,12),s=0|u.slice(12,14);else{if("utctime"!==t)return e.error("Decoding "+t+" time is not supported yet");n=0|u.slice(0,2),r=0|u.slice(2,4),i=0|u.slice(4,6),o=0|u.slice(6,8),a=0|u.slice(8,10),s=0|u.slice(10,12),n=n<70?2e3+n:1900+n}return Date.UTC(n,r-1,i,o,a,s,0)},CP.prototype._decodeNull=function(){return null},CP.prototype._decodeBool=function(e){var t=e.readUInt8();return e.isError(t)?t:0!==t},CP.prototype._decodeInt=function(e,t){var n=e.raw(),r=new mP(n);return t&&(r=t[r.toString(10)]||r),r},CP.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getDecoder("der").tree};var SP=KI.exports,QP=TF.Buffer,_P=EP;function NP(e){_P.call(this,e),this.enc="pem"}SP(NP,_P);var DP=NP;NP.prototype.decode=function(e,t){for(var n=e.toString().split(/[\r\n]+/g),r=t.label.toUpperCase(),i=/^-----(BEGIN|END) ([^-]+)-----$/,o=-1,a=-1,s=0;s<n.length;s++){var u=n[s].match(i);if(null!==u&&u[2]===r){if(-1!==o){if("END"!==u[1])break;a=s;break}if("BEGIN"!==u[1])break;o=s}}if(-1===o||-1===a)throw new Error("PEM section not found for: "+r);var l=n.slice(o+1,a).join("");l.replace(/[^a-z0-9+/=]+/gi,"");var A=QP.from(l,"base64");return _P.prototype.decode.call(this,A,t)},function(e){var t=e;t.der=EP,t.pem=DP}(vP),function(e){var t=FF,n=vP,r=KI.exports;function i(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}e.define=function(e,t){return new i(e,t)},i.prototype._createNamed=function(e){var t=this.name;function n(e){this._initNamed(e,t)}return r(n,e),n.prototype._initNamed=function(t,n){e.call(this,t,n)},new n(this)},i.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(n[e])),this.decoders[e]},i.prototype.decode=function(e,t,n){return this._getDecoder(t).decode(e,n)},i.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(t[e])),this.encoders[e]},i.prototype.encode=function(e,t,n){return this._getEncoder(t).encode(e,n)}}(DF);var FP={};!function(e){var t=FP;t.Reporter=RF.Reporter,t.DecoderBuffer=jF.DecoderBuffer,t.EncoderBuffer=jF.EncoderBuffer,t.Node=nP}();var PP={};!function(e){var t=e;t._reverse=function(e){var t={};return Object.keys(e).forEach((function(n){(0|n)==n&&(n|=0);var r=e[n];t[r]=n})),t},t.der=iP}(PP),function(e){var t=NF;t.bignum=CI.exports,t.define=DF.define,t.base=FP,t.constants=PP,t.decoders=vP,t.encoders=FF}();var UP={exports:{}},LP={},MP={};Object.defineProperty(MP,"__esModule",{value:!0}),MP.default=function(e){var t=e.length,n=t%4;if(!n)return e;var r=t,i=4-n,o=t+i,a=Yo.alloc(o);for(a.write(e);i--;)a.write("=",r++);return a.toString()},Object.defineProperty(LP,"__esModule",{value:!0});var TP=MP;function RP(e,t){return void 0===t&&(t="utf8"),Na(e)?HP(e.toString("base64")):HP(Yo.from(e,t).toString("base64"))}function OP(e){return e=e.toString(),TP.default(e).replace(/\-/g,"+").replace(/_/g,"/")}function HP(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}var KP=RP;KP.encode=RP,KP.decode=function(e,t){return void 0===t&&(t="utf8"),Yo.from(OP(e),"base64").toString(t)},KP.toBase64=OP,KP.fromBase64=HP,KP.toBuffer=function(e){return Yo.from(OP(e),"base64")},LP.default=KP,function(e){e.exports=LP.default,e.exports.default=e.exports}(UP);var jP=UP.exports,GP=NF,qP=UP.exports,VP=function(){function e(){s(this,e)}return l(e,null,[{key:"convert",value:function(e,t,n){if(e){if(t===n)return e;var r;if("raw"===t||e instanceof Yo)r=e;else if("uint8_array"===t||Array.isArray(e))r=Yo.from(e);else if("hex"===t)r=Yo.from(e,"hex");else if("base64"===t)r=Yo.from(e,"base64");else if("base64url"===t)r=qP.toBuffer(e);else{if("bn"!==t&&"bignum"!==t)throw new Error("Invalid fromType");r=Yo.from(this.pad(e.toString(16)),"hex")}if("raw"===n)return r;if("uint8_array"===n)return Array.from(r);if("hex"===n)return r.toString("hex");if("base64"===n)return r.toString("base64");if("base64url"===n)return qP.fromBase64(r.toString("base64"));if("bn"===n||"bignum"===n)return new GP.bignum(r);throw new Error("Invalid toType")}}},{key:"pad",value:function(e){return e.length%2==1?"0".concat(e):e}}]),e}(),zP=NF,JP=function(){function e(){s(this,e),Object.defineProperty(this,"_registry",{value:{}})}return l(e,[{key:"registry",get:function(){return this._registry}},{key:"define",value:function(e,t){this._registry[e]=zP.define(e,t(this))}},{key:"normalize",value:function(e){return this.registry[e]}}]),e}(),YP=new JP;YP.define("Version",(function(e){return function(){this.int({0:"two-prime",1:"multi"})}})),YP.define("OtherPrimeInfos",(function(e){return function(){this.seq().obj(this.key("ri").int(),this.key("di").int(),this.key("ti").int())}})),YP.define("AlgorithmIdentifier",(function(e){return function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional().any())}})),YP.define("PrivateKeyInfo",(function(e){var t=e.normalize("Version"),n=e.normalize("AlgorithmIdentifier");return function(){this.seq().obj(this.key("version").use(t),this.key("algorithm").use(n),this.key("privateKey").octstr())}})),YP.define("PublicKeyInfo",(function(e){var t=e.normalize("AlgorithmIdentifier");return function(){this.seq().obj(this.key("algorithm").use(t),this.key("publicKey").bitstr())}})),YP.define("RSAPrivateKey",(function(e){var t=e.normalize("Version"),n=e.normalize("OtherPrimeInfos");return function(){this.seq().obj(this.key("version").use(t),this.key("n").int(),this.key("e").int(),this.key("d").int(),this.key("p").int(),this.key("q").int(),this.key("dp").int(),this.key("dq").int(),this.key("qi").int(),this.key("other").optional().use(n))}})),YP.define("RSAPublicKey",(function(e){return function(){this.seq().obj(this.key("n").int(),this.key("e").int())}})),YP.define("ECPrivateKey",(function(e){return function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").explicit(0).optional().choice({namedCurve:this.objid()}),this.key("publicKey").explicit(1).optional().bitstr())}}));var XP=YP,WP=VP,ZP=XP,$P=function(e){c(n,e);var t=b(n);function n(){return s(this,n),t.apply(this,arguments)}return l(n,[{key:"fromPrivatePKCS1",value:function(e){var t=ZP.normalize("RSAPrivateKey").decode(e,"der"),n=t.n,r=t.e,i=t.d,o=t.p,a=t.q,s=t.dp,u=t.dq,l=t.qi;return{n:WP.convert(n,"bn","raw"),e:WP.convert(r,"bn","raw"),d:WP.convert(i,"bn","raw"),p:WP.convert(o,"bn","raw"),q:WP.convert(a,"bn","raw"),dp:WP.convert(s,"bn","raw"),dq:WP.convert(u,"bn","raw"),qi:WP.convert(l,"bn","raw")}}},{key:"fromPrivatePKCS8",value:function(e){var t=ZP.normalize("PrivateKeyInfo"),n=ZP.normalize("RSAPrivateKey"),r=t.decode(e,"der"),i=n.decode(r.privateKey,"der"),o=i.n,a=i.e,s=i.d,u=i.p,l=i.q,A=i.dp,c=i.dq,h=i.qi;return{n:WP.convert(o,"bn","raw"),e:WP.convert(a,"bn","raw"),d:WP.convert(s,"bn","raw"),p:WP.convert(u,"bn","raw"),q:WP.convert(l,"bn","raw"),dp:WP.convert(A,"bn","raw"),dq:WP.convert(c,"bn","raw"),qi:WP.convert(h,"bn","raw")}}},{key:"fromPublicPKCS1",value:function(e){var t=ZP.normalize("RSAPublicKey").decode(e,"der"),n=t.n,r=t.e;return{n:WP.convert(n,"bn","raw"),e:WP.convert(r,"bn","raw")}}},{key:"fromPublicPKCS8",value:function(e){var t=ZP.normalize("PublicKeyInfo"),n=ZP.normalize("RSAPublicKey"),r=t.decode(e,"der"),i=n.decode(r.publicKey.data,"der"),o=i.n,a=i.e;return{n:WP.convert(o,"bn","raw"),e:WP.convert(a,"bn","raw")}}},{key:"fromJwk",value:function(e){var t=e.n,n=e.e,r=e.d,i=e.p,o=e.q,a=e.dp,s=e.dq,u=e.qi;return e.alg,{n:WP.convert(t,"base64url","raw"),e:WP.convert(n,"base64url","raw"),d:WP.convert(r,"base64url","raw"),p:WP.convert(i,"base64url","raw"),q:WP.convert(o,"base64url","raw"),dp:WP.convert(a,"base64url","raw"),dq:WP.convert(s,"base64url","raw"),qi:WP.convert(u,"base64url","raw")}}},{key:"toPrivatePKCS1",value:function(e){var t=e.n,r=e.e,i=e.d,o=e.p,a=e.q,s=e.dp,u=e.dq,l=e.qi,A=this.params.version,c=ZP.normalize("RSAPrivateKey").encode({version:A,n:WP.convert(t,"raw","bn"),e:WP.convert(r,"raw","bn"),d:WP.convert(i,"raw","bn"),p:WP.convert(o,"raw","bn"),q:WP.convert(a,"raw","bn"),dp:WP.convert(s,"raw","bn"),dq:WP.convert(u,"raw","bn"),qi:WP.convert(l,"raw","bn")},"der").toString("base64");return n.formatPem(c,"RSA PRIVATE")}},{key:"toPrivatePKCS8",value:function(e){var t=e.n,r=e.e,i=e.d,o=e.p,a=e.q,s=e.dp,u=e.dq,l=e.qi,A=this.params,c=A.oid,h=A.algParameters,f=A.version,d=ZP.normalize("PrivateKeyInfo"),p=ZP.normalize("RSAPrivateKey").encode({version:f,n:WP.convert(t,"raw","bn"),e:WP.convert(r,"raw","bn"),d:WP.convert(i,"raw","bn"),p:WP.convert(o,"raw","bn"),q:WP.convert(a,"raw","bn"),dp:WP.convert(s,"raw","bn"),dq:WP.convert(u,"raw","bn"),qi:WP.convert(l,"raw","bn")},"der"),g=d.encode({version:f,algorithm:{algorithm:c.split("."),parameters:Yo.from(h,"hex")},privateKey:p},"der").toString("base64");return n.formatPem(g,"PRIVATE")}},{key:"toPublicPKCS1",value:function(e){var t=e.n,r=e.e,i=this.params.version,o=ZP.normalize("RSAPublicKey").encode({version:i,n:WP.convert(t,"raw","bn"),e:WP.convert(r,"raw","bn")},"der").toString("base64");return n.formatPem(o,"RSA PUBLIC")}},{key:"toPublicPKCS8",value:function(e){var t=e.n,r=e.e,i=this.params,o=i.oid,a=i.algParameters,s=ZP.normalize("PublicKeyInfo"),u=ZP.normalize("RSAPublicKey").encode({n:WP.convert(t,"raw","bn"),e:WP.convert(r,"raw","bn")},"der"),l=s.encode({algorithm:{algorithm:o.split("."),parameters:Yo.from(a,"hex")},publicKey:{unused:0,data:u}},"der").toString("base64");return n.formatPem(l,"PUBLIC")}},{key:"toPrivateJwk",value:function(e){var t=e.n,n=e.e,r=e.d,i=e.p,o=e.q,a=e.dp,s=e.dq,u=e.qi;return{kty:this.params.kty,n:WP.convert(t,"raw","base64url"),e:WP.convert(n,"raw","base64url"),d:WP.convert(r,"raw","base64url"),p:WP.convert(i,"raw","base64url"),q:WP.convert(o,"raw","base64url"),dp:WP.convert(a,"raw","base64url"),dq:WP.convert(s,"raw","base64url"),qi:WP.convert(u,"raw","base64url")}}},{key:"toPublicJwk",value:function(e){var t=e.n,n=e.e;return{kty:this.params.kty,n:WP.convert(t,"raw","base64url"),e:WP.convert(n,"raw","base64url")}}}]),n}(_F),eU=$P,tU=new BI.ec("secp256k1"),nU=VP,rU=XP,iU=function(e){c(n,e);var t=b(n);function n(){return s(this,n),t.apply(this,arguments)}return l(n,[{key:"fromPrivatePKCS1",value:function(e){var t=rU.normalize("ECPrivateKey").decode(e,"der"),r=t.privateKey,i=t.publicKey.data,o=nU.convert(i,"raw","hex"),a=n.getPoint(o);return{d:r,x:a.x,y:a.y}}},{key:"fromPrivatePKCS8",value:function(e){var t=rU.normalize("PrivateKeyInfo"),r=rU.normalize("ECPrivateKey"),i=t.decode(e,"der"),o=r.decode(i.privateKey,"der"),a=o.privateKey,s=o.publicKey.data,u=nU.convert(s,"raw","hex"),l=n.getPoint(u);return{d:a,x:l.x,y:l.y}}},{key:"fromPublicPKCS8",value:function(e){var t=rU.normalize("PublicKeyInfo").decode(e,"der"),r=nU.convert(t.publicKey.data,"raw","hex");return n.getPoint(r)}},{key:"fromPrivateBlk",value:function(e){var t=tU.keyFromPrivate(e,"hex"),n=t.getPublic();return{d:nU.convert(t.priv,"bn","raw"),x:nU.convert(n.getX(),"bn","raw"),y:nU.convert(n.getY(),"bn","raw")}}},{key:"fromPublicBlk",value:function(e){return n.getPoint(e)}},{key:"fromJwk",value:function(e){var t=e.d,n=e.x,r=e.y;return{d:nU.convert(t,"base64url","raw"),x:nU.convert(n,"base64url","raw"),y:nU.convert(r,"base64url","raw")}}},{key:"toPrivatePKCS1",value:function(e){var t=this.params,r=t.namedCurve,i=t.keyVersion,o=e.d,a=e.x,s=e.y,u=rU.normalize("ECPrivateKey"),l=n.makePoint(a,s),A=u.encode({version:i,privateKey:o,parameters:{type:"namedCurve",value:r.split(".")},publicKey:{unused:0,data:l}},"der").toString("base64");return n.formatPem(A,"EC PRIVATE")}},{key:"toPrivatePKCS8",value:function(e){var t=this.params,r=t.oid,i=t.algParameters,o=t.keyVersion,a=t.infoVersion,s=e.d,u=e.x,l=e.y,A=rU.normalize("PrivateKeyInfo"),c=rU.normalize("ECPrivateKey"),h=n.makePoint(u,l),f=c.encode({version:o,privateKey:s,publicKey:{unused:0,data:h}},"der"),d=A.encode({version:a,algorithm:{algorithm:r.split("."),parameters:Yo.from(i,"hex")},privateKey:f},"der").toString("base64");return n.formatPem(d,"PRIVATE")}},{key:"toPublicPKCS8",value:function(e){var t=this.params,r=t.oid,i=t.algParameters,o=e.x,a=e.y,s=rU.normalize("PublicKeyInfo"),u=n.makePoint(o,a),l=s.encode({algorithm:{algorithm:r.split("."),parameters:Yo.from(i,"hex")},publicKey:{unused:0,data:u}},"der").toString("base64");return n.formatPem(l,"PUBLIC")}},{key:"toPrivateBlk",value:function(e){return e.d.toString("hex")}},{key:"toPublicBlk",value:function(e){return nU.convert(n.makePoint(e.x,e.y),"raw","hex")}},{key:"toPrivateJwk",value:function(e){var t=this.params,n=t.crv,r=t.kty,i=e.d,o=e.x,a=e.y;return{kty:r,crv:n,d:nU.convert(i,"raw","base64url"),x:nU.convert(o,"raw","base64url"),y:nU.convert(a,"raw","base64url")}}},{key:"toPublicJwk",value:function(e){var t=this.params,n=t.crv,r=t.kty,i=e.x,o=e.y;return{kty:r,crv:n,x:nU.convert(i,"raw","base64url"),y:nU.convert(o,"raw","base64url")}}}],[{key:"getPoint",value:function(e){var t=e.slice(2,(e.length-2)/2+2),n=e.slice((e.length-2)/2+2);return{x:nU.convert(t,"hex","raw"),y:nU.convert(n,"hex","raw")}}},{key:"makePoint",value:function(e,t){var n=Yo.from("04","hex");return Yo.concat([n,e,t],n.length+e.length+t.length)}}]),n}(_F),oU=iU,aU=VP,sU=XP,uU=function(e){c(n,e);var t=b(n);function n(){return s(this,n),t.apply(this,arguments)}return l(n,[{key:"fromPrivatePKCS8",value:function(e){var t=sU.normalize("PrivateKeyInfo").decode(e,"der").privateKey.slice(2);return{d:t,x:this.publicKeyFromPrivate(t)}}},{key:"fromPublicPKCS8",value:function(e){var t=sU.normalize("PublicKeyInfo").decode(e,"der");return{x:aU.convert(t.publicKey.data,"hex","raw")}}},{key:"fromJwk",value:function(e){var t=e.d,n=e.x;return{d:aU.convert(t,"base64url","raw"),x:aU.convert(n,"base64url","raw")}}},{key:"toPrivatePKCS8",value:function(e){var t=this.params,r=t.oid,i=t.infoVersion,o=e.d,a=sU.normalize("PrivateKeyInfo"),s=this.privateKeyPadding(o),u=a.encode({version:i,algorithm:{algorithm:r.split(".")},privateKey:s},"der").toString("base64");return n.formatPem(u,"PRIVATE")}},{key:"toPublicPKCS8",value:function(e){var t=this.params.oid,r=e.x,i=sU.normalize("PublicKeyInfo").encode({algorithm:{algorithm:t.split(".")},publicKey:{unused:0,data:aU.convert(r,"hex","raw")}},"der").toString("base64");return n.formatPem(i,"PUBLIC")}},{key:"toPrivateJwk",value:function(e){var t=this.params,n=t.crv,r=t.kty,i=e.d,o=e.x;return{kty:r,crv:n,d:aU.convert(i,"raw","base64url"),x:aU.convert(o,"raw","base64url")}}},{key:"toPublicJwk",value:function(e){var t=this.params,n=t.crv,r=t.kty,i=e.x;return{kty:r,crv:n,x:aU.convert(i,"raw","base64url")}}},{key:"privateKeyPadding",value:function(e){var t;if("Ed25519"!==this.params.crv)throw new Error("".concat(this.params.crv," is an invalid curve for EdDSA"));return t=Yo.from("0420","hex"),Yo.concat([t,e],t.length+e.length)}},{key:"publicKeyFromPrivate",value:function(e){if("Ed25519"===this.params.crv){var t=new BI.eddsa("ed25519");return Yo.from(t.keyFromSecret(e).getPublic())}throw new Error("".concat(this.params.crv," is an invalid curve for EdDSA"))}}]),n}(_F),lU=eU,AU=oU,cU=uU,hU=new SF;hU.define([{kty:"RSA",oid:"1.2.840.113549.1.1.1",algParameters:"0500",version:"two-prime"}],lU),hU.define([{kty:"EC",crv:"K-256",oid:"1.2.840.10045.2.1",namedCurve:"1.3.132.0.10",algParameters:"06052b8104000a",keyVersion:1,infoVersion:"two-prime"},{kty:"EC",crv:"P-256",oid:"1.2.840.10045.2.1",namedCurve:"1.2.840.10045.3.1.7",algParameters:"06082a8648ce3d030107",keyVersion:1,infoVersion:"two-prime"},{kty:"EC",crv:"P-384",oid:"1.2.840.10045.2.1",namedCurve:"1.3.132.0.34",algParameters:"06052b81040022",keyVersion:1,infoVersion:"two-prime"},{kty:"EC",crv:"P-521",oid:"1.2.840.10045.2.1",namedCurve:"1.3.132.0.35",algParameters:"06052b81040023",keyVersion:1,infoVersion:"two-prime"}],AU),hU.define([{kty:"OKP",crv:"Ed25519",oid:"1.3.101.112",infoVersion:"two-prime"}],cU);var fU=xF,dU=kF,pU=hU,gU=XP,vU=RegExp("\r?\n","g"),yU=function(){function e(t,n){if(s(this,e),!t)throw new fU("key is required");if(!n)throw new fU("options are required");var r=n.kty,i=n.format,o=n.selector,a=n.crv,u=n.oid;if(!n.kty)throw new fU("options.kty is required");if(!n.format)throw new fU("options.format is required");if(!n.selector)throw new fU("options.selector is required");if(!n.crv&&!n.oid)throw new fU("options.crv or options.oid is required");this.kty=r,this.format=i,this.selector=o,this.crv=a,this.oid=u,this.key=this.parseKey(t)}return l(e,[{key:"alg",get:function(){var e=this.kty,t=this.crv,n=this.oid;if(!this.algorithm){if(t)Object.defineProperty(this,"algorithm",{value:pU.normalize(e,"crv",t)});else{if(!n)throw new Error("Both crv and oid are undefined");Object.defineProperty(this,"algorithm",{value:pU.normalize(e,"oid",n)})}if(!this.algorithm)throw new Error("".concat(this.crv||this.oid," is not implemented yet"))}return this.algorithm}},{key:"parseKey",value:function(e){var t=this.alg,n=this.format,r=this.selector;if("pem"===n)switch(r){case"public_pkcs1":return t.fromPublicPKCS1(e);case"public_pkcs8":return t.fromPublicPKCS8(e);case"private_pkcs1":return t.fromPrivatePKCS1(e);case"private_pkcs8":return t.fromPrivatePKCS8(e);default:throw new Error("Invalid selector value")}if("jwk"===n)return t.fromJwk(e,r);if("blk"===n)switch(r){case"public":return t.fromPublicBlk(e);case"private":return t.fromPrivateBlk(e)}}},{key:"toJwk",value:function(e){var t=this.key,n=this.alg,r=this.selector;switch(e){case"public":return n.toPublicJwk(t);case"private":if(r.includes("public"))throw new fU("Cannot export a private key from a public key");return n.toPrivateJwk(t);default:throw new Error("Invalid key selector")}}},{key:"toString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"pem",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"public_pkcs8",n=this.key,r=this.alg,i=this.selector;if("pem"===e)switch(t){case"public_pkcs1":return r.toPublicPKCS1(n);case"public_pkcs8":return r.toPublicPKCS8(n);case"private_pkcs1":if(i.includes("public"))throw new fU("Cannot export a private key from a public key");return r.toPrivatePKCS1(n);case"private_pkcs8":if(i.includes("public"))throw new fU("Cannot export a private key from a public key");return r.toPrivatePKCS8(n);default:throw new Error("Invalid key selector")}else if("jwk"===e)switch(t){case"public":return JSON.stringify(r.toPublicJwk(n));case"private":if(i.includes("public"))throw new fU("Cannot export a private key from a public key");return JSON.stringify(r.toPrivateJwk(n));default:throw new Error("Invalid key selector")}else if("blk"===e)switch(t){case"private":if(i.includes("public"))throw new fU("Cannot export a private key from a public key");return r.toPrivateBlk(n);case"public":return r.toPublicBlk(n);default:throw new Error("Invalid key selector")}throw new dU}}],[{key:"from",value:function(t,n){if(!t)throw new fU("key is required");if(!n)throw new fU("format is required");if("jwk"===n){var r;if("string"==typeof t)try{r=JSON.parse(t)}catch(t){throw new fU("key is not a valid JWK")}else"object"==i(t)&&(r=t);var o,a=r,s=a.kty,u=a.crv;if(!s)throw new fU("kty is required for JWK");if("EC"===s&&!u)throw new fU("crv is required for EC JWK");"RSA"===s&&(o=pU.find((function(e){return e.kty===s})).oid);var l=r.d?"private":"public";return new e(r,{kty:s,crv:u,oid:o,format:n,selector:l})}if("pem"===n){if("string"!=typeof t)throw new fU("key is not a valid PEM string");var A=t.split(vU),c=A.splice(0,1);A.splice(A.length-1,1);var h,f,d=A.join(""),p=/^-----BEGIN ((RSA|EC) )?(PUBLIC|PRIVATE) KEY-----$/.exec(c),g=p?p[2]:void 0,v=p?p[3]:void 0,y=Yo.from(d,"base64");if(!v)throw new fU("key is not a valid PEM string");if(g){if("RSA"===g)v="PRIVATE"===v?"private_pkcs1":"public_pkcs1",h=pU.find((function(e){return e.kty===g})).oid;else if("EC"===g){var m;if("PRIVATE"===v)v="private_pkcs1",m=gU.normalize("".concat(g,"PrivateKey")).decode(y,"der");else if("PUBLIC"===v){v="public_pkcs1",m=gU.normalize("".concat(g,"PrivateKey")).decode(y,"der")}var w=m.parameters.value;f=pU.find((function(e){return e.namedCurve===w.join(".")})).crv}}else{var b,I=gU.normalize("PrivateKeyInfo"),B=gU.normalize("PublicKeyInfo");"PRIVATE"===v?(v="private_pkcs8",b=I.decode(y,"der")):"PUBLIC"===v&&(v="public_pkcs8",b=B.decode(y,"der"));var E=b.algorithm,C=E.algorithm,x=E.parameters;C=C.join("."),x=x?x.toString("hex"):void 0;var k=pU.find((function(e){return e.oid===C}));if(!(g=k?k.kty:void 0))throw new fU("".concat(C," is not supported"));"RSA"===g||"OKP"===g?h=C:"EC"===g&&(f=pU.find((function(e){return e.algParameters===x})).crv)}return new e(y,{kty:g,oid:h,crv:f,format:n,selector:v})}if("blk"===n)return new e(t,{kty:"EC",crv:"K-256",format:n,selector:t.length>64?"public":"private"});throw new fU("Invalid format ".concat(n))}}]),e}(),mU=yU,wU=qN("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),bU=Yo,IU={},BU={},EU={};Object.defineProperty(EU,"__esModule",{value:!0}),EU.testnet=EU.regtest=EU.bitcoin=void 0,EU.bitcoin={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},EU.regtest={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bcrt",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},EU.testnet={messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};var CU={},xU={},kU={},SU={};Object.defineProperty(SU,"__esModule",{value:!0}),SU.encode=SU.decode=SU.check=void 0,SU.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;var t=e[3];if(0===t)return!1;if(5+t>=e.length)return!1;if(2!==e[4+t])return!1;var n=e[5+t];return!(0===n||6+t+n!==e.length||128&e[4]||t>1&&0===e[4]&&!(128&e[5])||128&e[t+6]||n>1&&0===e[t+6]&&!(128&e[t+7]))},SU.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");var 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)");var n=e[5+t];if(0===n)throw new Error("S length is zero");if(6+t+n!==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(n>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)}},SU.encode=function(e,t){var n=e.length,r=t.length;if(0===n)throw new Error("R length is zero");if(0===r)throw new Error("S length is zero");if(n>33)throw new Error("R length is too long");if(r>33)throw new Error("S length is too long");if(128&e[0])throw new Error("R value is negative");if(128&t[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(r>1&&0===t[0]&&!(128&t[1]))throw new Error("S value excessively padded");var i=Yo.allocUnsafe(6+n+r);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=e.length,e.copy(i,4),i[4+n]=2,i[5+n]=t.length,t.copy(i,6+n),i};var QU={};Object.defineProperty(QU,"__esModule",{value:!0}),QU.REVERSE_OPS=QU.OPS=void 0;var _U={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_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};QU.OPS=_U;var NU={};QU.REVERSE_OPS=NU;for(var DU=0,FU=Object.keys(_U);DU<FU.length;DU++){var PU=FU[DU];NU[_U[PU]]=PU}var UU={};Object.defineProperty(UU,"__esModule",{value:!0}),UU.decode=UU.encode=UU.encodingLength=void 0;var LU=QU;function MU(e){return e<LU.OPS.OP_PUSHDATA1?1:e<=255?2:e<=65535?3:5}UU.encodingLength=MU,UU.encode=function(e,t,n){var r=MU(t);return 1===r?e.writeUInt8(t,n):2===r?(e.writeUInt8(LU.OPS.OP_PUSHDATA1,n),e.writeUInt8(t,n+1)):3===r?(e.writeUInt8(LU.OPS.OP_PUSHDATA2,n),e.writeUInt16LE(t,n+1)):(e.writeUInt8(LU.OPS.OP_PUSHDATA4,n),e.writeUInt32LE(t,n+1)),r},UU.decode=function(e,t){var n,r,i=e.readUInt8(t);if(i<LU.OPS.OP_PUSHDATA1)n=i,r=1;else if(i===LU.OPS.OP_PUSHDATA1){if(t+2>e.length)return null;n=e.readUInt8(t+1),r=2}else if(i===LU.OPS.OP_PUSHDATA2){if(t+3>e.length)return null;n=e.readUInt16LE(t+1),r=3}else{if(t+5>e.length)return null;if(i!==LU.OPS.OP_PUSHDATA4)throw new Error("Unexpected opcode");n=e.readUInt32LE(t+1),r=5}return{opcode:i,number:n,size:r}};var TU={};Object.defineProperty(TU,"__esModule",{value:!0}),TU.encode=TU.decode=void 0,TU.decode=function(e,t,n){t=t||4,n=void 0===n||n;var r=e.length;if(0===r)return 0;if(r>t)throw new TypeError("Script number overflow");if(n&&0==(127&e[r-1])&&(r<=1||0==(128&e[r-2])))throw new Error("Non-minimally encoded script number");if(5===r){var i=e.readUInt32LE(0),o=e.readUInt8(4);return 128&o?-(4294967296*(-129&o)+i):4294967296*o+i}for(var a=0,s=0;s<r;++s)a|=e[s]<<8*s;return 128&e[r-1]?-(a&~(128<<8*(r-1))):a},TU.encode=function(e){for(var t,n=Math.abs(e),r=(t=n)>2147483647?5:t>8388607?4:t>32767?3:t>127?2:t>0?1:0,i=Yo.allocUnsafe(r),o=e<0,a=0;a<r;++a)i.writeUInt8(255&n,a),n>>=8;return 128&i[r-1]?i.writeUInt8(o?128:0,r-1):o&&(i[r-1]|=128),i};var RU={},OU={},HU={Array:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((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"==i(e)},String:function(e){return"string"==typeof e},"":function(){return!0}};for(var KU in HU.Null=HU.Nil,HU)HU[KU].toJSON=function(e){return e}.bind(null,KU);var jU=HU,GU=jU;function qU(e){return e.name||e.toString().match(/function (.*?)\s*\(/)[1]}function VU(e){return GU.Nil(e)?"":qU(e.constructor)}function zU(e,t){Error.captureStackTrace&&Error.captureStackTrace(e,t)}function JU(e){return GU.Function(e)?e.toJSON?e.toJSON():qU(e):GU.Array(e)?"Array":e&&GU.Object(e)?"Object":void 0!==e?e:""}function YU(e,t,n){var r=function(e){return GU.Function(e)?"":GU.String(e)?JSON.stringify(e):e&&GU.Object(e)?"":e}(t);return"Expected "+JU(e)+", got"+(""!==n?" "+n:"")+(""!==r?" "+r:"")}function XU(e,t,n){n=n||VU(t),this.message=YU(e,t,n),zU(this,XU),this.__type=e,this.__value=t,this.__valueTypeName=n}function WU(e,t,n,r,i){e?(i=i||VU(r),this.message=function(e,t,n,r,i){var o='" of type ';return"key"===t&&(o='" with key type '),YU('property "'+JU(n)+o+JU(e),r,i)}(e,n,t,r,i)):this.message='Unexpected property "'+t+'"',zU(this,XU),this.__label=n,this.__property=t,this.__type=e,this.__value=r,this.__valueTypeName=i}XU.prototype=Object.create(Error.prototype),XU.prototype.constructor=XU,WU.prototype=Object.create(Error.prototype),WU.prototype.constructor=XU;var ZU={TfTypeError:XU,TfPropertyTypeError:WU,tfCustomError:function(e,t){return new XU(e,{},t)},tfSubError:function(e,t,n){return e instanceof WU?(t=t+"."+e.__property,e=new WU(e.__type,t,e.__label,e.__value,e.__valueTypeName)):e instanceof XU&&(e=new WU(e.__type,t,n,e.__value,e.__valueTypeName)),zU(e),e},tfJSON:JU,getValueTypeName:VU},$U=jU,eL=ZU;function tL(e){return Na(e)}function nL(e){return"string"==typeof e&&/^([0-9a-f]{2})+$/i.test(e)}function rL(e,t){var n=e.toJSON();function r(r){if(!e(r))return!1;if(r.length===t)return!0;throw eL.tfCustomError(n+"(Length: "+t+")",n+"(Length: "+r.length+")")}return r.toJSON=function(){return n},r}var iL=rL.bind(null,$U.Array),oL=rL.bind(null,tL),aL=rL.bind(null,nL),sL=rL.bind(null,$U.String),uL=Math.pow(2,53)-1,lL={ArrayN:iL,Buffer:tL,BufferN:oL,Finite:function(e){return"number"==typeof e&&isFinite(e)},Hex:nL,HexN:aL,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>=-uL&&e<=uL&&Math.floor(e)===e},Range:function(e,t,n){function r(r,i){return n(r,i)&&r>e&&r<t}return n=n||$U.Number,r.toJSON=function(){return"".concat(n.toJSON()," between [").concat(e,", ").concat(t,"]")},r},StringN:sL,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<=uL&&Math.floor(e)===e}};for(var AL in lL)lL[AL].toJSON=function(e){return e}.bind(null,AL);var cL=lL,hL=jU,fL=ZU.tfJSON,dL=ZU.TfTypeError,pL=ZU.TfPropertyTypeError,gL=ZU.tfSubError,vL=ZU.getValueTypeName,yL={arrayOf:function(e,t){function n(n,r){return!!hL.Array(n)&&!hL.Nil(n)&&!(void 0!==t.minLength&&n.length<t.minLength)&&!(void 0!==t.maxLength&&n.length>t.maxLength)&&(void 0===t.length||n.length===t.length)&&n.every((function(t,n){try{return wL(e,t,r)}catch(e){throw gL(e,n)}}))}return e=mL(e),t=t||{},n.toJSON=function(){var n="["+fL(e)+"]";return void 0!==t.length?n+="{"+t.length+"}":void 0===t.minLength&&void 0===t.maxLength||(n+="{"+(void 0===t.minLength?0:t.minLength)+","+(void 0===t.maxLength?1/0:t.maxLength)+"}"),n},n},maybe:function e(t){function n(n,r){return hL.Nil(n)||t(n,r,e)}return t=mL(t),n.toJSON=function(){return"?"+fL(t)},n},map:function(e,t){function n(n,r){if(!hL.Object(n))return!1;if(hL.Nil(n))return!1;for(var i in n){try{t&&wL(t,i,r)}catch(e){throw gL(e,i,"key")}try{var o=n[i];wL(e,o,r)}catch(e){throw gL(e,i)}}return!0}return e=mL(e),t&&(t=mL(t)),n.toJSON=t?function(){return"{"+fL(t)+": "+fL(e)+"}"}:function(){return"{"+fL(e)+"}"},n},object:function(e){var t={};for(var n in e)t[n]=mL(e[n]);function r(e,n){if(!hL.Object(e))return!1;if(hL.Nil(e))return!1;var r;try{for(r in t)wL(t[r],e[r],n)}catch(e){throw gL(e,r)}if(n)for(r in e)if(!t[r])throw new pL(void 0,r);return!0}return r.toJSON=function(){return fL(t)},r},anyOf:function(){var e=[].slice.call(arguments).map(mL);function t(t,n){return e.some((function(e){try{return wL(e,t,n)}catch(e){return!1}}))}return t.toJSON=function(){return e.map(fL).join("|")},t},allOf:function(){var e=[].slice.call(arguments).map(mL);function t(t,n){return e.every((function(e){try{return wL(e,t,n)}catch(e){return!1}}))}return t.toJSON=function(){return e.map(fL).join(" & ")},t},quacksLike:function(e){function t(t){return e===vL(t)}return t.toJSON=function(){return e},t},tuple:function(){var e=[].slice.call(arguments).map(mL);function t(t,n){return!hL.Nil(t)&&!hL.Nil(t.length)&&(!n||t.length===e.length)&&e.every((function(e,r){try{return wL(e,t[r],n)}catch(e){throw gL(e,r)}}))}return t.toJSON=function(){return"("+e.map(fL).join(", ")+")"},t},value:function(e){function t(t){return t===e}return t.toJSON=function(){return e},t}};function mL(e){if(hL.String(e))return"?"===e[0]?yL.maybe(e.slice(1)):hL[e]||yL.quacksLike(e);if(e&&hL.Object(e)){if(hL.Array(e)){if(1!==e.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return yL.arrayOf(e[0])}return yL.object(e)}return hL.Function(e)?e:yL.value(e)}function wL(e,t,n,r){if(hL.Function(e)){if(e(t,n))return!0;throw new dL(r||e,t)}return wL(mL(e),t,n)}for(var bL in yL.oneOf=yL.anyOf,hL)wL[bL]=hL[bL];for(bL in yL)wL[bL]=yL[bL];var IL=cL;for(bL in IL)wL[bL]=IL[bL];wL.compile=mL,wL.TfTypeError=dL,wL.TfPropertyTypeError=pL;var BL=wL;!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.Network=e.ECPoint=e.Satoshi=e.Signer=e.BIP32Path=e.UInt31=e.isPoint=e.typeforce=void 0;var t=Fa;e.typeforce=BL;var n=t.Buffer.alloc(32,0),r=t.Buffer.from("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f","hex");e.isPoint=function(e){if(!t.Buffer.isBuffer(e))return!1;if(e.length<33)return!1;var i=e[0],o=e.slice(1,33);if(0===o.compare(n))return!1;if(o.compare(r)>=0)return!1;if((2===i||3===i)&&33===e.length)return!0;var a=e.slice(33);return 0!==a.compare(n)&&!(a.compare(r)>=0)&&4===i&&65===e.length};var 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=function(){return"BIP32 derivation path"},e.Signer=function(t){return(e.typeforce.Buffer(t.publicKey)||"function"==typeof t.getPublicKey)&&"function"==typeof t.sign},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.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}(OU),Object.defineProperty(RU,"__esModule",{value:!0}),RU.encode=RU.decode=void 0;var EL=SU,CL=OU,xL=CL.typeforce,kL=Yo.alloc(1,0);function SL(e){for(var t=0;0===e[t];)++t;return t===e.length?kL:128&(e=e.slice(t))[0]?Yo.concat([kL,e],1+e.length):e}function QL(e){0===e[0]&&(e=e.slice(1));var t=Yo.alloc(32,0),n=Math.max(0,32-e.length);return e.copy(t,n),t}RU.decode=function(e){var t=e.readUInt8(e.length-1),n=-129&t;if(n<=0||n>=4)throw new Error("Invalid hashType "+t);var r=EL.decode(e.slice(0,-1)),i=QL(r.r),o=QL(r.s);return{signature:Yo.concat([i,o],64),hashType:t}},RU.encode=function(e,t){xL({signature:CL.BufferN(64),hashType:CL.UInt8},{signature:e,hashType:t});var n=-129&t;if(n<=0||n>=4)throw new Error("Invalid hashType "+t);var r=Yo.allocUnsafe(1);r.writeUInt8(t,0);var i=SL(e.slice(0,32)),o=SL(e.slice(32,64));return Yo.concat([EL.encode(i,o),r])},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.isPushOnly=e.OPS=void 0;var t=SU,n=QU;Object.defineProperty(e,"OPS",{enumerable:!0,get:function(){return n.OPS}});var r=UU,i=TU,o=RU,a=OU,s=a.typeforce,u=n.OPS.OP_RESERVED;function l(e){return a.Buffer(e)||function(e){return a.Number(e)&&(e===n.OPS.OP_0||e>=n.OPS.OP_1&&e<=n.OPS.OP_16||e===n.OPS.OP_1NEGATE)}(e)}function A(e){return a.Array(e)&&e.every(l)}function c(e){return 0===e.length?n.OPS.OP_0:1===e.length?e[0]>=1&&e[0]<=16?u+e[0]:129===e[0]?n.OPS.OP_1NEGATE:void 0:void 0}function h(e){return Na(e)}function f(e){return Na(e)}function d(e){if(h(e))return e;s(a.Array,e);var t=e.reduce((function(e,t){return f(t)?1===t.length&&void 0!==c(t)?e+1:e+r.encodingLength(t.length)+t.length:e+1}),0),n=Yo.allocUnsafe(t),i=0;if(e.forEach((function(e){if(f(e)){var t=c(e);if(void 0!==t)return n.writeUInt8(t,i),void(i+=1);i+=r.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 p(e){if(t=e,a.Array(t))return e;var t;s(a.Buffer,e);for(var i=[],o=0;o<e.length;){var u=e[o];if(u>n.OPS.OP_0&&u<=n.OPS.OP_PUSHDATA4){var l=r.decode(e,o);if(null===l)return null;if((o+=l.size)+l.number>e.length)return null;var A=e.slice(o,o+l.number);o+=l.number;var h=c(A);void 0!==h?i.push(h):i.push(A)}else i.push(u),o+=1}return i}function g(e){var t=-129&e;return t>0&&t<4}e.isPushOnly=A,e.compile=d,e.decompile=p,e.toASM=function(e){return h(e)&&(e=p(e)),e.map((function(e){if(f(e)){var t=c(e);if(void 0===t)return e.toString("hex");e=t}return n.REVERSE_OPS[e]})).join(" ")},e.fromASM=function(e){return s(a.String,e),d(e.split(" ").map((function(e){return void 0!==n.OPS[e]?n.OPS[e]:(s(a.Hex,e),Yo.from(e,"hex"))})))},e.toStack=function(e){return e=p(e),s(A,e),e.map((function(e){return f(e)?e:e===n.OPS.OP_0?Yo.allocUnsafe(0):i.encode(e-u)}))},e.isCanonicalPubKey=function(e){return a.isPoint(e)},e.isDefinedHashType=g,e.isCanonicalScriptSignature=function(e){return!!Na(e)&&!!g(e[e.length-1])&&t.check(e.slice(0,-1))},e.number=i,e.signature=o}(kU);var _L={};Object.defineProperty(_L,"__esModule",{value:!0}),_L.value=_L.prop=void 0,_L.prop=function(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get:function(){var e=n.call(this);return this[t]=e,e},set:function(e){Object.defineProperty(this,t,{configurable:!0,enumerable:!0,value:e,writable:!0})}})},_L.value=function(e){var t;return function(){return void 0!==t||(t=e()),t}},Object.defineProperty(xU,"__esModule",{value:!0}),xU.p2data=void 0;var NL=EU,DL=kU,FL=OU,PL=_L,UL=DL.OPS;xU.p2data=function(e,t){if(!e.data&&!e.output)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,FL.typeforce)({network:FL.typeforce.maybe(FL.typeforce.Object),output:FL.typeforce.maybe(FL.typeforce.Buffer),data:FL.typeforce.maybe(FL.typeforce.arrayOf(FL.typeforce.Buffer))},e);var n={name:"embed",network:e.network||NL.bitcoin};if(PL.prop(n,"output",(function(){if(e.data)return DL.compile([UL.OP_RETURN].concat(e.data))})),PL.prop(n,"data",(function(){if(e.output)return DL.decompile(e.output).slice(1)})),t.validate&&e.output){var r=DL.decompile(e.output);if(r[0]!==UL.OP_RETURN)throw new TypeError("Output is invalid");if(!r.slice(1).every(FL.typeforce.Buffer))throw new TypeError("Output is invalid");if(e.data&&!function(e,t){return e.length===t.length&&e.every((function(e,n){return e.equals(t[n])}))}(e.data,n.data))throw new TypeError("Data mismatch")}return Object.assign(n,e)};var LL={};Object.defineProperty(LL,"__esModule",{value:!0}),LL.p2ms=void 0;var ML=EU,TL=kU,RL=OU,OL=_L,HL=TL.OPS,KL=HL.OP_RESERVED;function jL(e,t){return e.length===t.length&&e.every((function(e,n){return e.equals(t[n])}))}LL.p2ms=function(e,t){if(!(e.input||e.output||e.pubkeys&&void 0!==e.m||e.signatures))throw new TypeError("Not enough data");function n(e){return TL.isCanonicalScriptSignature(e)||void 0!==(t.allowIncomplete&&e===HL.OP_0)}t=Object.assign({validate:!0},t||{}),(0,RL.typeforce)({network:RL.typeforce.maybe(RL.typeforce.Object),m:RL.typeforce.maybe(RL.typeforce.Number),n:RL.typeforce.maybe(RL.typeforce.Number),output:RL.typeforce.maybe(RL.typeforce.Buffer),pubkeys:RL.typeforce.maybe(RL.typeforce.arrayOf(RL.isPoint)),signatures:RL.typeforce.maybe(RL.typeforce.arrayOf(n)),input:RL.typeforce.maybe(RL.typeforce.Buffer)},e);var r={network:e.network||ML.bitcoin},i=[],o=!1;function a(e){o||(o=!0,i=TL.decompile(e),r.m=i[0]-KL,r.n=i[i.length-2]-KL,r.pubkeys=i.slice(1,-2))}if(OL.prop(r,"output",(function(){if(e.m&&r.n&&e.pubkeys)return TL.compile([].concat(KL+e.m,e.pubkeys,KL+r.n,HL.OP_CHECKMULTISIG))})),OL.prop(r,"m",(function(){if(r.output)return a(r.output),r.m})),OL.prop(r,"n",(function(){if(r.pubkeys)return r.pubkeys.length})),OL.prop(r,"pubkeys",(function(){if(e.output)return a(e.output),r.pubkeys})),OL.prop(r,"signatures",(function(){if(e.input)return TL.decompile(e.input).slice(1)})),OL.prop(r,"input",(function(){if(e.signatures)return TL.compile([HL.OP_0].concat(e.signatures))})),OL.prop(r,"witness",(function(){if(r.input)return[]})),OL.prop(r,"name",(function(){if(r.m&&r.n)return"p2ms(".concat(r.m," of ").concat(r.n,")")})),t.validate){if(e.output){if(a(e.output),!RL.typeforce.Number(i[0]))throw new TypeError("Output is invalid");if(!RL.typeforce.Number(i[i.length-2]))throw new TypeError("Output is invalid");if(i[i.length-1]!==HL.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(r.m<=0||r.n>16||r.m>r.n||r.n!==i.length-3)throw new TypeError("Output is invalid");if(!r.pubkeys.every((function(e){return(0,RL.isPoint)(e)})))throw new TypeError("Output is invalid");if(void 0!==e.m&&e.m!==r.m)throw new TypeError("m mismatch");if(void 0!==e.n&&e.n!==r.n)throw new TypeError("n mismatch");if(e.pubkeys&&!jL(e.pubkeys,r.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(r.n=e.pubkeys.length,r.n<r.m)throw new TypeError("Pubkey count cannot be less than m")}if(e.signatures){if(e.signatures.length<r.m)throw new TypeError("Not enough signatures provided");if(e.signatures.length>r.m)throw new TypeError("Too many signatures provided")}if(e.input){if(e.input[0]!==HL.OP_0)throw new TypeError("Input is invalid");if(0===r.signatures.length||!r.signatures.every(n))throw new TypeError("Input has invalid signature(s)");if(e.signatures&&!jL(e.signatures,r.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(r,e)};var GL={};Object.defineProperty(GL,"__esModule",{value:!0}),GL.p2pk=void 0;var qL=EU,VL=kU,zL=OU,JL=_L,YL=VL.OPS;GL.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,zL.typeforce)({network:zL.typeforce.maybe(zL.typeforce.Object),output:zL.typeforce.maybe(zL.typeforce.Buffer),pubkey:zL.typeforce.maybe(zL.isPoint),signature:zL.typeforce.maybe(VL.isCanonicalScriptSignature),input:zL.typeforce.maybe(zL.typeforce.Buffer)},e);var n=JL.value((function(){return VL.decompile(e.input)})),r={name:"p2pk",network:e.network||qL.bitcoin};if(JL.prop(r,"output",(function(){if(e.pubkey)return VL.compile([e.pubkey,YL.OP_CHECKSIG])})),JL.prop(r,"pubkey",(function(){if(e.output)return e.output.slice(1,-1)})),JL.prop(r,"signature",(function(){if(e.input)return n()[0]})),JL.prop(r,"input",(function(){if(e.signature)return VL.compile([e.signature])})),JL.prop(r,"witness",(function(){if(r.input)return[]})),t.validate){if(e.output){if(e.output[e.output.length-1]!==YL.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!(0,zL.isPoint)(r.pubkey))throw new TypeError("Output pubkey is invalid");if(e.pubkey&&!e.pubkey.equals(r.pubkey))throw new TypeError("Pubkey mismatch")}if(e.signature&&e.input&&!e.input.equals(r.input))throw new TypeError("Signature mismatch");if(e.input){if(1!==n().length)throw new TypeError("Input is invalid");if(!VL.isCanonicalScriptSignature(r.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(r,e)};var XL={},WL={},ZL={exports:{}},$L={},eM=Do(eh),tM=eM.EventEmitter;function nM(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function rM(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var iM=Fa.Buffer,oM=sb.inspect,aM=oM&&oM.custom||"inspect";function sM(e,t,n){iM.prototype.copy.call(e,t,n)}var uM=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}var t;return t=[{key:"push",value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n}},{key:"concat",value:function(e){if(0===this.length)return iM.alloc(0);for(var t=iM.allocUnsafe(e>>>0),n=this.head,r=0;n;)sM(n.data,t,r),r+=n.data.length,n=n.next;return t}},{key:"consume",value:function(e,t){var n;return e<this.head.data.length?(n=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):n=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),n}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,n=1,r=t.data;for(e-=r.length;t=t.next;){var i=t.data,o=e>i.length?i.length:e;if(o===i.length?r+=i:r+=i.slice(0,e),0==(e-=o)){o===i.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(o));break}++n}return this.length-=n,r}},{key:"_getBuffer",value:function(e){var t=iM.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var i=n.data,o=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,o),0==(e-=o)){o===i.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=i.slice(o));break}++r}return this.length-=r,t}},{key:aM,value:function(e,t){return oM(this,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?nM(Object(n),!0).forEach((function(t){rM(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):nM(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},t,{depth:0,customInspect:!1}))}}],t&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(e.prototype,t),e}();function lM(e,t){cM(e,t),AM(e)}function AM(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function cM(e,t){e.emit("error",t)}var hM={destroy:function(e,t){var n=this,r=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return r||i?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,Xl(cM,this,e)):Xl(cM,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,(function(e){!t&&e?n._writableState?n._writableState.errorEmitted?Xl(AM,n):(n._writableState.errorEmitted=!0,Xl(lM,n,e)):Xl(lM,n,e):t?(Xl(AM,n),t(e)):Xl(AM,n)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(e,t){var n=e._readableState,r=e._writableState;n&&n.autoDestroy||r&&r.autoDestroy?e.destroy(t):e.emit("error",t)}},fM={},dM={};function pM(e,t,n){n||(n=Error);var r=function(e){var n,r;function i(n,r,i){return e.call(this,function(e,n,r){return"string"==typeof t?t:t(e,n,r)}(n,r,i))||this}return r=e,(n=i).prototype=Object.create(r.prototype),n.prototype.constructor=n,n.__proto__=r,i}(n);r.prototype.name=n.name,r.prototype.code=e,dM[e]=r}function gM(e,t){if(Array.isArray(e)){var n=e.length;return e=e.map((function(e){return String(e)})),n>2?"one of ".concat(t," ").concat(e.slice(0,n-1).join(", "),", or ")+e[n-1]:2===n?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}pM("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),pM("ERR_INVALID_ARG_TYPE",(function(e,t,n){var r,o,a;if("string"==typeof t&&(o="not ",t.substr(0,o.length)===o)?(r="must not be",t=t.replace(/^not /,"")):r="must be",function(e,t,n){return(void 0===n||n>e.length)&&(n=e.length),e.substring(n-t.length,n)===t}(e," argument"))a="The ".concat(e," ").concat(r," ").concat(gM(t,"type"));else{var s=function(e,t,n){return"number"!=typeof n&&(n=0),!(n+".".length>e.length)&&-1!==e.indexOf(".",n)}(e)?"property":"argument";a='The "'.concat(e,'" ').concat(s," ").concat(r," ").concat(gM(t,"type"))}return a+". Received type ".concat(i(n))}),TypeError),pM("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),pM("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),pM("ERR_STREAM_PREMATURE_CLOSE","Premature close"),pM("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),pM("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),pM("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),pM("ERR_STREAM_WRITE_AFTER_END","write after end"),pM("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),pM("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),pM("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),fM.codes=dM;var vM=fM.codes.ERR_INVALID_OPT_VALUE,yM=function(e,t,n,r){var i=function(e,t,n){return null!=e.highWaterMark?e.highWaterMark:t?e[n]:null}(t,r,n);if(null!=i){if(!isFinite(i)||Math.floor(i)!==i||i<0)throw new vM(r?n:"highWaterMark",i);return Math.floor(i)}return e.objectMode?16:16384},mM={},wM=jN.exports.Buffer,bM=wM.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function IM(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(wM.isEncoding===bM||!bM(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=CM,this.end=xM,t=4;break;case"utf8":this.fillLast=EM,t=4;break;case"base64":this.text=kM,this.end=SM,t=3;break;default:return this.write=QM,void(this.end=_M)}this.lastNeed=0,this.lastTotal=0,this.lastChar=wM.allocUnsafe(t)}function BM(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function EM(e){var t=this.lastTotal-this.lastNeed,n=function(e,t,n){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==n?n:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function CM(e,t){if((e.length-t)%2==0){var n=e.toString("utf16le",t);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function xM(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function kM(e,t){var n=(e.length-t)%3;return 0===n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-n))}function SM(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function QM(e){return e.toString(this.encoding)}function _M(e){return e&&e.length?this.write(e):""}mM.StringDecoder=IM,IM.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||""},IM.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},IM.prototype.text=function(e,t){var n=function(e,t,n){var r=t.length-1;if(r<n)return 0;var i=BM(t[r]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--r<n||-2===i?0:(i=BM(t[r]))>=0?(i>0&&(e.lastNeed=i-2),i):--r<n||-2===i?0:(i=BM(t[r]))>=0?(i>0&&(2===i?i=0:e.lastNeed=i-3),i):0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var r=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString("utf8",t,r)},IM.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};var NM=fM.codes.ERR_STREAM_PREMATURE_CLOSE;function DM(){}var FM,PM=function e(t,n,r){if("function"==typeof n)return e(t,null,n);n||(n={}),r=function(e){var t=!1;return function(){if(!t){t=!0;for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];e.apply(this,r)}}}(r||DM);var i=n.readable||!1!==n.readable&&t.readable,o=n.writable||!1!==n.writable&&t.writable,a=function(){t.writable||u()},s=t._writableState&&t._writableState.finished,u=function(){o=!1,s=!0,i||r.call(t)},l=t._readableState&&t._readableState.endEmitted,A=function(){i=!1,l=!0,o||r.call(t)},c=function(e){r.call(t,e)},h=function(){var e;return i&&!l?(t._readableState&&t._readableState.ended||(e=new NM),r.call(t,e)):o&&!s?(t._writableState&&t._writableState.ended||(e=new NM),r.call(t,e)):void 0},f=function(){t.req.on("finish",u)};return function(e){return e.setHeader&&"function"==typeof e.abort}(t)?(t.on("complete",u),t.on("abort",h),t.req?f():t.on("request",f)):o&&!t._writableState&&(t.on("end",a),t.on("close",a)),t.on("end",A),t.on("finish",u),!1!==n.error&&t.on("error",c),t.on("close",h),function(){t.removeListener("complete",u),t.removeListener("abort",h),t.removeListener("request",f),t.req&&t.req.removeListener("finish",u),t.removeListener("end",a),t.removeListener("close",a),t.removeListener("finish",u),t.removeListener("end",A),t.removeListener("error",c),t.removeListener("close",h)}};function UM(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var LM=PM,MM=Symbol("lastResolve"),TM=Symbol("lastReject"),RM=Symbol("error"),OM=Symbol("ended"),HM=Symbol("lastPromise"),KM=Symbol("handlePromise"),jM=Symbol("stream");function GM(e,t){return{value:e,done:t}}function qM(e){var t=e[MM];if(null!==t){var n=e[jM].read();null!==n&&(e[HM]=null,e[MM]=null,e[TM]=null,t(GM(n,!1)))}}function VM(e){Xl(qM,e)}var zM=Object.getPrototypeOf((function(){})),JM=Object.setPrototypeOf((FM={get stream(){return this[jM]},next:function(){var e=this,t=this[RM];if(null!==t)return Promise.reject(t);if(this[OM])return Promise.resolve(GM(void 0,!0));if(this[jM].destroyed)return new Promise((function(t,n){Xl((function(){e[RM]?n(e[RM]):t(GM(void 0,!0))}))}));var n,r=this[HM];if(r)n=new Promise(function(e,t){return function(n,r){e.then((function(){t[OM]?n(GM(void 0,!0)):t[KM](n,r)}),r)}}(r,this));else{var i=this[jM].read();if(null!==i)return Promise.resolve(GM(i,!1));n=new Promise(this[KM])}return this[HM]=n,n}},UM(FM,Symbol.asyncIterator,(function(){return this})),UM(FM,"return",(function(){var e=this;return new Promise((function(t,n){e[jM].destroy(null,(function(e){e?n(e):t(GM(void 0,!0))}))}))})),FM),zM),YM=function(e){var t,n=Object.create(JM,(UM(t={},jM,{value:e,writable:!0}),UM(t,MM,{value:null,writable:!0}),UM(t,TM,{value:null,writable:!0}),UM(t,RM,{value:null,writable:!0}),UM(t,OM,{value:e._readableState.endEmitted,writable:!0}),UM(t,KM,{value:function(e,t){var r=n[jM].read();r?(n[HM]=null,n[MM]=null,n[TM]=null,e(GM(r,!1))):(n[MM]=e,n[TM]=t)},writable:!0}),t));return n[HM]=null,LM(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=n[TM];return null!==t&&(n[HM]=null,n[MM]=null,n[TM]=null,t(e)),void(n[RM]=e)}var r=n[MM];null!==r&&(n[HM]=null,n[MM]=null,n[TM]=null,r(GM(void 0,!0))),n[OM]=!0})),e.on("readable",VM.bind(null,n)),n},XM=function(){throw new Error("Readable.from is not available in the browser")},WM=$L;WM.Readable=yT,yT.ReadableState=vT,eM.EventEmitter;var ZM,$M=function(e,t){return e.listeners(t).length},eT=tM,tT=Fa.Buffer,nT=No.Uint8Array||function(){},rT=sb;ZM=rT&&rT.debuglog?rT.debuglog("stream"):function(){};var iT,oT,aT,sT=uM,uT=hM,lT=yM,AT=fM.codes,cT=AT.ERR_INVALID_ARG_TYPE,hT=AT.ERR_STREAM_PUSH_AFTER_EOF,fT=AT.ERR_METHOD_NOT_IMPLEMENTED,dT=AT.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;KI.exports(yT,eT);var pT=uT.errorOrDestroy,gT=["error","close","destroy","pause","resume"];function vT(e,t,n){e=e||{},"boolean"!=typeof n&&(n=t instanceof WM.Duplex),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=lT(this,e,"readableHighWaterMark",n),this.buffer=new sT,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(iT||(iT=mM.StringDecoder),this.decoder=new iT(e.encoding),this.encoding=e.encoding)}function yT(e){if(!(this instanceof yT))return new yT(e);var t=this instanceof WM.Duplex;this._readableState=new vT(e,this,t),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),eT.call(this)}function mT(e,t,n,r,i){ZM("readableAddChunk",t);var o,a=e._readableState;if(null===t)a.reading=!1,function(e,t){if(ZM("onEofChunk"),!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,t.sync?IT(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,BT(e)))}}(e,a);else if(i||(o=function(e,t){var n,r;return r=t,tT.isBuffer(r)||r instanceof nT||"string"==typeof t||void 0===t||e.objectMode||(n=new cT("chunk",["string","Buffer","Uint8Array"],t)),n}(a,t)),o)pT(e,o);else if(a.objectMode||t&&t.length>0)if("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===tT.prototype||(t=function(e){return tT.from(e)}(t)),r)a.endEmitted?pT(e,new dT):wT(e,a,t,!0);else if(a.ended)pT(e,new hT);else{if(a.destroyed)return!1;a.reading=!1,a.decoder&&!n?(t=a.decoder.write(t),a.objectMode||0!==t.length?wT(e,a,t,!1):ET(e,a)):wT(e,a,t,!1)}else r||(a.reading=!1,ET(e,a));return!a.ended&&(a.length<a.highWaterMark||0===a.length)}function wT(e,t,n,r){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",n)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&IT(e)),ET(e,t)}function bT(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=function(e){return e>=1073741824?e=1073741824:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function IT(e){var t=e._readableState;ZM("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(ZM("emitReadable",t.flowing),t.emittedReadable=!0,Xl(BT,e))}function BT(e){var t=e._readableState;ZM("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,QT(e)}function ET(e,t){t.readingMore||(t.readingMore=!0,Xl(CT,e,t))}function CT(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){var n=t.length;if(ZM("maybeReadMore read 0"),e.read(0),n===t.length)break}t.readingMore=!1}function xT(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function kT(e){ZM("readable nexttick read 0"),e.read(0)}function ST(e,t){ZM("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),QT(e),t.flowing&&!t.reading&&e.read(0)}function QT(e){var t=e._readableState;for(ZM("flow",t.flowing);t.flowing&&null!==e.read(););}function _T(e,t){return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n);var n}function NT(e){var t=e._readableState;ZM("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,Xl(DT,t,e))}function DT(e,t){if(ZM("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var n=t._writableState;(!n||n.autoDestroy&&n.finished)&&t.destroy()}}function FT(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}Object.defineProperty(yT.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),yT.prototype.destroy=uT.destroy,yT.prototype._undestroy=uT.undestroy,yT.prototype._destroy=function(e,t){t(e)},yT.prototype.push=function(e,t){var n,r=this._readableState;return r.objectMode?n=!0:"string"==typeof e&&((t=t||r.defaultEncoding)!==r.encoding&&(e=tT.from(e,t),t=""),n=!0),mT(this,e,t,!1,n)},yT.prototype.unshift=function(e){return mT(this,e,null,!0,!1)},yT.prototype.isPaused=function(){return!1===this._readableState.flowing},yT.prototype.setEncoding=function(e){iT||(iT=mM.StringDecoder);var t=new iT(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,r="";null!==n;)r+=t.write(n.data),n=n.next;return this._readableState.buffer.clear(),""!==r&&this._readableState.buffer.push(r),this._readableState.length=r.length,this},yT.prototype.read=function(e){ZM("read",e),e=parseInt(e,10);var t=this._readableState,n=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&((0!==t.highWaterMark?t.length>=t.highWaterMark:t.length>0)||t.ended))return ZM("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?NT(this):IT(this),null;if(0===(e=bT(e,t))&&t.ended)return 0===t.length&&NT(this),null;var r,i=t.needReadable;return ZM("need readable",i),(0===t.length||t.length-e<t.highWaterMark)&&ZM("length less than watermark",i=!0),t.ended||t.reading?ZM("reading or ended",i=!1):i&&(ZM("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=bT(n,t))),null===(r=e>0?_T(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&NT(this)),null!==r&&this.emit("data",r),r},yT.prototype._read=function(e){pT(this,new fT("_read()"))},yT.prototype.pipe=function(e,t){var n=this,r=this._readableState;switch(r.pipesCount){case 0:r.pipes=e;break;case 1:r.pipes=[r.pipes,e];break;default:r.pipes.push(e)}r.pipesCount+=1,ZM("pipe count=%d opts=%j",r.pipesCount,t);var i=t&&!1===t.end||e===lA.stdout||e===lA.stderr?h:o;function o(){ZM("onend"),e.end()}r.endEmitted?Xl(i):n.once("end",i),e.on("unpipe",(function t(i,f){ZM("onunpipe"),i===n&&f&&!1===f.hasUnpiped&&(f.hasUnpiped=!0,ZM("cleanup"),e.removeListener("close",A),e.removeListener("finish",c),e.removeListener("drain",a),e.removeListener("error",l),e.removeListener("unpipe",t),n.removeListener("end",o),n.removeListener("end",h),n.removeListener("data",u),s=!0,!r.awaitDrain||e._writableState&&!e._writableState.needDrain||a())}));var a=function(e){return function(){var t=e._readableState;ZM("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&$M(e,"data")&&(t.flowing=!0,QT(e))}}(n);e.on("drain",a);var s=!1;function u(t){ZM("ondata");var i=e.write(t);ZM("dest.write",i),!1===i&&((1===r.pipesCount&&r.pipes===e||r.pipesCount>1&&-1!==FT(r.pipes,e))&&!s&&(ZM("false write response, pause",r.awaitDrain),r.awaitDrain++),n.pause())}function l(t){ZM("onerror",t),h(),e.removeListener("error",l),0===$M(e,"error")&&pT(e,t)}function A(){e.removeListener("finish",c),h()}function c(){ZM("onfinish"),e.removeListener("close",A),h()}function h(){ZM("unpipe"),n.unpipe(e)}return n.on("data",u),function(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}(e,"error",l),e.once("close",A),e.once("finish",c),e.emit("pipe",n),r.flowing||(ZM("pipe resume"),n.resume()),e},yT.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n)),this;if(!e){var r=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)r[o].emit("unpipe",this,{hasUnpiped:!1});return this}var a=FT(t.pipes,e);return-1===a||(t.pipes.splice(a,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,n)),this},yT.prototype.on=function(e,t){var n=eT.prototype.on.call(this,e,t),r=this._readableState;return"data"===e?(r.readableListening=this.listenerCount("readable")>0,!1!==r.flowing&&this.resume()):"readable"===e&&(r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.flowing=!1,r.emittedReadable=!1,ZM("on readable",r.length,r.reading),r.length?IT(this):r.reading||Xl(kT,this))),n},yT.prototype.addListener=yT.prototype.on,yT.prototype.removeListener=function(e,t){var n=eT.prototype.removeListener.call(this,e,t);return"readable"===e&&Xl(xT,this),n},yT.prototype.removeAllListeners=function(e){var t=eT.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||Xl(xT,this),t},yT.prototype.resume=function(){var e=this._readableState;return e.flowing||(ZM("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,Xl(ST,e,t))}(this,e)),e.paused=!1,this},yT.prototype.pause=function(){return ZM("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(ZM("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},yT.prototype.wrap=function(e){var t=this,n=this._readableState,r=!1;for(var i in e.on("end",(function(){if(ZM("wrapped end"),n.decoder&&!n.ended){var e=n.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(i){ZM("wrapped data"),n.decoder&&(i=n.decoder.write(i)),n.objectMode&&null==i||(n.objectMode||i&&i.length)&&(t.push(i)||(r=!0,e.pause()))})),e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var o=0;o<gT.length;o++)e.on(gT[o],this.emit.bind(this,gT[o]));return this._read=function(t){ZM("wrapped _read",t),r&&(r=!1,e.resume())},this},"function"==typeof Symbol&&(yT.prototype[Symbol.asyncIterator]=function(){return void 0===oT&&(oT=YM),oT(this)}),Object.defineProperty(yT.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(yT.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(yT.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),yT._fromList=_T,Object.defineProperty(yT.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(yT.from=function(e,t){return void 0===aT&&(aT=XM),aT(yT,e,t)});function PT(e){try{if(!No.localStorage)return!1}catch(e){return!1}var t=No.localStorage[e];return null!=t&&"true"===String(t).toLowerCase()}var UT=$L;function LT(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,n){var r=e.entry;for(e.entry=null;r;){var i=r.callback;t.pendingcb--,i(undefined),r=r.next}t.corkedRequestsFree.next=e}(t,e)}}UT.Writable=nR,nR.WritableState=tR;var MT,TT=function(e,t){if(PT("noDeprecation"))return e;var n=!1;return function(){if(!n){if(PT("throwDeprecation"))throw new Error(t);PT("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}},RT=tM,OT=Fa.Buffer,HT=No.Uint8Array||function(){},KT=hM,jT=yM,GT=fM.codes,qT=GT.ERR_INVALID_ARG_TYPE,VT=GT.ERR_METHOD_NOT_IMPLEMENTED,zT=GT.ERR_MULTIPLE_CALLBACK,JT=GT.ERR_STREAM_CANNOT_PIPE,YT=GT.ERR_STREAM_DESTROYED,XT=GT.ERR_STREAM_NULL_VALUES,WT=GT.ERR_STREAM_WRITE_AFTER_END,ZT=GT.ERR_UNKNOWN_ENCODING,$T=KT.errorOrDestroy;function eR(){}function tR(e,t,n){e=e||{},"boolean"!=typeof n&&(n=t instanceof UT.Duplex),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=jT(this,e,"writableHighWaterMark",n),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var r=!1===e.decodeStrings;this.decodeStrings=!r,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var n=e._writableState,r=n.sync,i=n.writecb;if("function"!=typeof i)throw new zT;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(n),t)!function(e,t,n,r,i){--t.pendingcb,n?(Xl(i,r),Xl(uR,e,t),e._writableState.errorEmitted=!0,$T(e,r)):(i(r),e._writableState.errorEmitted=!0,$T(e,r),uR(e,t))}(e,n,r,t,i);else{var o=aR(n)||e.destroyed;o||n.corked||n.bufferProcessing||!n.bufferedRequest||oR(e,n),r?Xl(iR,e,n,o,i):iR(e,n,o,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new LT(this)}function nR(e){var t=this instanceof UT.Duplex;if(!t&&!MT.call(nR,this))return new nR(e);this._writableState=new tR(e,this,t),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),RT.call(this)}function rR(e,t,n,r,i,o,a){t.writelen=r,t.writecb=a,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new YT("write")):n?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function iR(e,t,n,r){n||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,r(),uR(e,t)}function oR(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=t.bufferedRequestCount,i=new Array(r),o=t.corkedRequestsFree;o.entry=n;for(var a=0,s=!0;n;)i[a]=n,n.isBuf||(s=!1),n=n.next,a+=1;i.allBuffers=s,rR(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new LT(t),t.bufferedRequestCount=0}else{for(;n;){var u=n.chunk,l=n.encoding,A=n.callback;if(rR(e,t,!1,t.objectMode?1:u.length,u,l,A),n=n.next,t.bufferedRequestCount--,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function aR(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function sR(e,t){e._final((function(n){t.pendingcb--,n&&$T(e,n),t.prefinished=!0,e.emit("prefinish"),uR(e,t)}))}function uR(e,t){var n=aR(t);if(n&&(function(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,Xl(sR,e,t)))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var r=e._readableState;(!r||r.autoDestroy&&r.endEmitted)&&e.destroy()}return n}KI.exports(nR,RT),tR.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(tR.prototype,"buffer",{get:TT((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(MT=Function.prototype[Symbol.hasInstance],Object.defineProperty(nR,Symbol.hasInstance,{value:function(e){return!!MT.call(this,e)||this===nR&&e&&e._writableState instanceof tR}})):MT=function(e){return e instanceof this},nR.prototype.pipe=function(){$T(this,new JT)},nR.prototype.write=function(e,t,n){var r,i=this._writableState,o=!1,a=!i.objectMode&&(r=e,OT.isBuffer(r)||r instanceof HT);return a&&!OT.isBuffer(e)&&(e=function(e){return OT.from(e)}(e)),"function"==typeof t&&(n=t,t=null),a?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof n&&(n=eR),i.ending?function(e,t){var n=new WT;$T(e,n),Xl(t,n)}(this,n):(a||function(e,t,n,r){var i;return null===n?i=new XT:"string"==typeof n||t.objectMode||(i=new qT("chunk",["string","Buffer"],n)),!i||($T(e,i),Xl(r,i),!1)}(this,i,e,n))&&(i.pendingcb++,o=function(e,t,n,r,i,o){if(!n){var a=function(e,t,n){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=OT.from(t,n)),t}(t,r,i);r!==a&&(n=!0,i="buffer",r=a)}var s=t.objectMode?1:r.length;t.length+=s;var u=t.length<t.highWaterMark;if(u||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:i,isBuf:n,callback:o,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else rR(e,t,!1,s,r,i,o);return u}(this,i,a,e,t,n)),o},nR.prototype.cork=function(){this._writableState.corked++},nR.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||oR(this,e))},nR.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new ZT(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(nR.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(nR.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),nR.prototype._write=function(e,t,n){n(new VT("_write()"))},nR.prototype._writev=null,nR.prototype.end=function(e,t,n){var r=this._writableState;return"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!=e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||function(e,t,n){t.ending=!0,uR(e,t),n&&(t.finished?Xl(n):e.once("finish",n)),t.ended=!0,e.writable=!1}(this,r,n),this},Object.defineProperty(nR.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(nR.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),nR.prototype.destroy=KT.destroy,nR.prototype._undestroy=KT.undestroy,nR.prototype._destroy=function(e,t){t(e)};var lR=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t},AR=$L;AR.Duplex=dR,KI.exports(dR,AR.Readable);for(var cR=lR(AR.Writable.prototype),hR=0;hR<cR.length;hR++){var fR=cR[hR];dR.prototype[fR]||(dR.prototype[fR]=AR.Writable.prototype[fR])}function dR(e){if(!(this instanceof dR))return new dR(e);AR.Readable.call(this,e),AR.Writable.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",pR)))}function pR(){this._writableState.ended||Xl(gR,this)}function gR(e){e.end()}Object.defineProperty(dR.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(dR.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(dR.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(dR.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}});var vR=$L;vR.Transform=ER;var yR=fM.codes,mR=yR.ERR_METHOD_NOT_IMPLEMENTED,wR=yR.ERR_MULTIPLE_CALLBACK,bR=yR.ERR_TRANSFORM_ALREADY_TRANSFORMING,IR=yR.ERR_TRANSFORM_WITH_LENGTH_0;function BR(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new wR);n.writechunk=null,n.writecb=null,null!=t&&this.push(t),r(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function ER(e){if(!(this instanceof ER))return new ER(e);vR.Duplex.call(this,e),this._transformState={afterTransform:BR.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",CR)}function CR(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?xR(this,null,null):this._flush((function(t,n){xR(e,t,n)}))}function xR(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new IR;if(e._transformState.transforming)throw new bR;return e.push(null)}KI.exports(ER,vR.Duplex),ER.prototype.push=function(e,t){return this._transformState.needTransform=!1,vR.Duplex.prototype.push.call(this,e,t)},ER.prototype._transform=function(e,t,n){n(new mR("_transform()"))},ER.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},ER.prototype._read=function(e){var t=this._transformState;null===t.writechunk||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))},ER.prototype._destroy=function(e,t){vR.Duplex.prototype._destroy.call(this,e,(function(e){t(e)}))};var kR,SR=$L;function QR(e){if(!(this instanceof QR))return new QR(e);Transform.call(this,e)}SR.PassThrough=QR,KI.exports(QR,SR.Transform),QR.prototype._transform=function(e,t,n){n(null,e)};var _R=fM.codes,NR=_R.ERR_MISSING_ARGS,DR=_R.ERR_STREAM_DESTROYED;function FR(e){if(e)throw e}function PR(e,t,n,r){r=function(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}(r);var i=!1;e.on("close",(function(){i=!0})),void 0===kR&&(kR=PM),kR(e,{readable:t,writable:n},(function(e){if(e)return r(e);i=!0,r()}));var o=!1;return function(t){if(!i&&!o)return o=!0,function(e){return e.setHeader&&"function"==typeof e.abort}(e)?e.abort():"function"==typeof e.destroy?e.destroy():void r(t||new DR("pipe"))}}function UR(e){e()}function LR(e,t){return e.pipe(t)}function MR(e){return e.length?"function"!=typeof e[e.length-1]?FR:e.pop():FR}var TR=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r,i=MR(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new NR("streams");var o=t.map((function(e,n){var a=n<t.length-1;return PR(e,a,n>0,(function(e){r||(r=e),e&&o.forEach(UR),a||(o.forEach(UR),i(r))}))}));return t.reduce(LR)};!function(e,t){var n=$L;(t=ZL.exports=n.Readable).Stream=n.Readable,t.Readable=n.Readable,t.Writable=n.Writable,t.Duplex=n.Duplex,t.Transform=n.Transform,t.PassThrough=n.PassThrough,t.finished=PM,t.pipeline=TR}(0,ZL.exports);var RR=jN.exports.Buffer,OR=ZL.exports;function HR(e){OR.Stream.Transform.call(this),this._block=RR.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}(0,KI.exports)(HR,OR.Stream.Transform),HR.prototype._transform=function(e,t,n){var r=null;try{this.update(e,t)}catch(e){r=e}n(r)},HR.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)},HR.prototype.update=function(e,t){if(function(e,t){if(!RR.isBuffer(e)&&"string"!=typeof e)throw new TypeError("Data must be a string or a buffer")}(e),this._finalized)throw new Error("Digest already called");RR.isBuffer(e)||(e=RR.from(e,t));for(var n=this._block,r=0;this._blockOffset+e.length-r>=this._blockSize;){for(var i=this._blockOffset;i<this._blockSize;)n[i++]=e[r++];this._update(),this._blockOffset=0}for(;r<e.length;)n[this._blockOffset++]=e[r++];for(var o=0,a=8*e.length;a>0;++o)this._length[o]+=a,(a=this._length[o]/4294967296|0)>0&&(this._length[o]-=4294967296*a);return this},HR.prototype._update=function(){throw new Error("_update is not implemented")},HR.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var n=0;n<4;++n)this._length[n]=0;return t},HR.prototype._digest=function(){throw new Error("_digest is not implemented")};var KR=HR,jR=KI.exports,GR=KR,qR=jN.exports.Buffer,VR=new Array(16);function zR(){GR.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function JR(e,t){return e<<t|e>>>32-t}function YR(e,t,n,r,i,o,a){return JR(e+(t&n|~t&r)+i+o|0,a)+t|0}function XR(e,t,n,r,i,o,a){return JR(e+(t&r|n&~r)+i+o|0,a)+t|0}function WR(e,t,n,r,i,o,a){return JR(e+(t^n^r)+i+o|0,a)+t|0}function ZR(e,t,n,r,i,o,a){return JR(e+(n^(t|~r))+i+o|0,a)+t|0}jR(zR,GR),zR.prototype._update=function(){for(var e=VR,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var n=this._a,r=this._b,i=this._c,o=this._d;n=YR(n,r,i,o,e[0],3614090360,7),o=YR(o,n,r,i,e[1],3905402710,12),i=YR(i,o,n,r,e[2],606105819,17),r=YR(r,i,o,n,e[3],3250441966,22),n=YR(n,r,i,o,e[4],4118548399,7),o=YR(o,n,r,i,e[5],1200080426,12),i=YR(i,o,n,r,e[6],2821735955,17),r=YR(r,i,o,n,e[7],4249261313,22),n=YR(n,r,i,o,e[8],1770035416,7),o=YR(o,n,r,i,e[9],2336552879,12),i=YR(i,o,n,r,e[10],4294925233,17),r=YR(r,i,o,n,e[11],2304563134,22),n=YR(n,r,i,o,e[12],1804603682,7),o=YR(o,n,r,i,e[13],4254626195,12),i=YR(i,o,n,r,e[14],2792965006,17),n=XR(n,r=YR(r,i,o,n,e[15],1236535329,22),i,o,e[1],4129170786,5),o=XR(o,n,r,i,e[6],3225465664,9),i=XR(i,o,n,r,e[11],643717713,14),r=XR(r,i,o,n,e[0],3921069994,20),n=XR(n,r,i,o,e[5],3593408605,5),o=XR(o,n,r,i,e[10],38016083,9),i=XR(i,o,n,r,e[15],3634488961,14),r=XR(r,i,o,n,e[4],3889429448,20),n=XR(n,r,i,o,e[9],568446438,5),o=XR(o,n,r,i,e[14],3275163606,9),i=XR(i,o,n,r,e[3],4107603335,14),r=XR(r,i,o,n,e[8],1163531501,20),n=XR(n,r,i,o,e[13],2850285829,5),o=XR(o,n,r,i,e[2],4243563512,9),i=XR(i,o,n,r,e[7],1735328473,14),n=WR(n,r=XR(r,i,o,n,e[12],2368359562,20),i,o,e[5],4294588738,4),o=WR(o,n,r,i,e[8],2272392833,11),i=WR(i,o,n,r,e[11],1839030562,16),r=WR(r,i,o,n,e[14],4259657740,23),n=WR(n,r,i,o,e[1],2763975236,4),o=WR(o,n,r,i,e[4],1272893353,11),i=WR(i,o,n,r,e[7],4139469664,16),r=WR(r,i,o,n,e[10],3200236656,23),n=WR(n,r,i,o,e[13],681279174,4),o=WR(o,n,r,i,e[0],3936430074,11),i=WR(i,o,n,r,e[3],3572445317,16),r=WR(r,i,o,n,e[6],76029189,23),n=WR(n,r,i,o,e[9],3654602809,4),o=WR(o,n,r,i,e[12],3873151461,11),i=WR(i,o,n,r,e[15],530742520,16),n=ZR(n,r=WR(r,i,o,n,e[2],3299628645,23),i,o,e[0],4096336452,6),o=ZR(o,n,r,i,e[7],1126891415,10),i=ZR(i,o,n,r,e[14],2878612391,15),r=ZR(r,i,o,n,e[5],4237533241,21),n=ZR(n,r,i,o,e[12],1700485571,6),o=ZR(o,n,r,i,e[3],2399980690,10),i=ZR(i,o,n,r,e[10],4293915773,15),r=ZR(r,i,o,n,e[1],2240044497,21),n=ZR(n,r,i,o,e[8],1873313359,6),o=ZR(o,n,r,i,e[15],4264355552,10),i=ZR(i,o,n,r,e[6],2734768916,15),r=ZR(r,i,o,n,e[13],1309151649,21),n=ZR(n,r,i,o,e[4],4149444226,6),o=ZR(o,n,r,i,e[11],3174756917,10),i=ZR(i,o,n,r,e[2],718787259,15),r=ZR(r,i,o,n,e[9],3951481745,21),this._a=this._a+n|0,this._b=this._b+r|0,this._c=this._c+i|0,this._d=this._d+o|0},zR.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=qR.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e};var $R=zR,eO=Fa.Buffer,tO=KI.exports,nO=KR,rO=new Array(16),iO=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],oO=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],aO=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],sO=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],uO=[0,1518500249,1859775393,2400959708,2840853838],lO=[1352829926,1548603684,1836072691,2053994217,0];function AO(){nO.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function cO(e,t){return e<<t|e>>>32-t}function hO(e,t,n,r,i,o,a,s){return cO(e+(t^n^r)+o+a|0,s)+i|0}function fO(e,t,n,r,i,o,a,s){return cO(e+(t&n|~t&r)+o+a|0,s)+i|0}function dO(e,t,n,r,i,o,a,s){return cO(e+((t|~n)^r)+o+a|0,s)+i|0}function pO(e,t,n,r,i,o,a,s){return cO(e+(t&r|n&~r)+o+a|0,s)+i|0}function gO(e,t,n,r,i,o,a,s){return cO(e+(t^(n|~r))+o+a|0,s)+i|0}tO(AO,nO),AO.prototype._update=function(){for(var e=rO,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);for(var n=0|this._a,r=0|this._b,i=0|this._c,o=0|this._d,a=0|this._e,s=0|this._a,u=0|this._b,l=0|this._c,A=0|this._d,c=0|this._e,h=0;h<80;h+=1){var f,d;h<16?(f=hO(n,r,i,o,a,e[iO[h]],uO[0],aO[h]),d=gO(s,u,l,A,c,e[oO[h]],lO[0],sO[h])):h<32?(f=fO(n,r,i,o,a,e[iO[h]],uO[1],aO[h]),d=pO(s,u,l,A,c,e[oO[h]],lO[1],sO[h])):h<48?(f=dO(n,r,i,o,a,e[iO[h]],uO[2],aO[h]),d=dO(s,u,l,A,c,e[oO[h]],lO[2],sO[h])):h<64?(f=pO(n,r,i,o,a,e[iO[h]],uO[3],aO[h]),d=fO(s,u,l,A,c,e[oO[h]],lO[3],sO[h])):(f=gO(n,r,i,o,a,e[iO[h]],uO[4],aO[h]),d=hO(s,u,l,A,c,e[oO[h]],lO[4],sO[h])),n=a,a=o,o=cO(i,10),i=r,r=f,s=c,c=A,A=cO(l,10),l=u,u=d}var p=this._b+i+A|0;this._b=this._c+o+c|0,this._c=this._d+a+s|0,this._d=this._e+n+u|0,this._e=this._a+r+l|0,this._a=p},AO.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=eO.alloc?eO.alloc(20):new eO(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e};var vO=AO,yO={exports:{}},mO=jN.exports.Buffer;function wO(e,t){this._block=mO.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}wO.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=mO.from(e,t));for(var n=this._block,r=this._blockSize,i=e.length,o=this._len,a=0;a<i;){for(var s=o%r,u=Math.min(i-a,r-s),l=0;l<u;l++)n[s+l]=e[a+l];a+=u,(o+=u)%r==0&&this._update(n)}return this._len+=i,this},wO.prototype.digest=function(e){var t=this._len%this._blockSize;this._block[t]=128,this._block.fill(0,t+1),t>=this._finalSize&&(this._update(this._block),this._block.fill(0));var n=8*this._len;if(n<=4294967295)this._block.writeUInt32BE(n,this._blockSize-4);else{var r=(4294967295&n)>>>0,i=(n-r)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(r,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o},wO.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var bO=wO,IO=KI.exports,BO=bO,EO=jN.exports.Buffer,CO=[1518500249,1859775393,-1894007588,-899497514],xO=new Array(80);function kO(){this.init(),this._w=xO,BO.call(this,64,56)}function SO(e){return e<<30|e>>>2}function QO(e,t,n,r){return 0===e?t&n|~t&r:2===e?t&n|t&r|n&r:t^n^r}IO(kO,BO),kO.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},kO.prototype._update=function(e){for(var t,n=this._w,r=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,s=0|this._e,u=0;u<16;++u)n[u]=e.readInt32BE(4*u);for(;u<80;++u)n[u]=n[u-3]^n[u-8]^n[u-14]^n[u-16];for(var l=0;l<80;++l){var A=~~(l/20),c=0|((t=r)<<5|t>>>27)+QO(A,i,o,a)+s+n[l]+CO[A];s=a,a=o,o=SO(i),i=r,r=c}this._a=r+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=s+this._e|0},kO.prototype._hash=function(){var e=EO.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e};var _O=kO,NO=KI.exports,DO=bO,FO=jN.exports.Buffer,PO=[1518500249,1859775393,-1894007588,-899497514],UO=new Array(80);function LO(){this.init(),this._w=UO,DO.call(this,64,56)}function MO(e){return e<<5|e>>>27}function TO(e){return e<<30|e>>>2}function RO(e,t,n,r){return 0===e?t&n|~t&r:2===e?t&n|t&r|n&r:t^n^r}NO(LO,DO),LO.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},LO.prototype._update=function(e){for(var t,n=this._w,r=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,s=0|this._e,u=0;u<16;++u)n[u]=e.readInt32BE(4*u);for(;u<80;++u)n[u]=(t=n[u-3]^n[u-8]^n[u-14]^n[u-16])<<1|t>>>31;for(var l=0;l<80;++l){var A=~~(l/20),c=MO(r)+RO(A,i,o,a)+s+n[l]+PO[A]|0;s=a,a=o,o=TO(i),i=r,r=c}this._a=r+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=s+this._e|0},LO.prototype._hash=function(){var e=FO.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e};var OO=LO,HO=KI.exports,KO=bO,jO=jN.exports.Buffer,GO=[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],qO=new Array(64);function VO(){this.init(),this._w=qO,KO.call(this,64,56)}function zO(e,t,n){return n^e&(t^n)}function JO(e,t,n){return e&t|n&(e|t)}function YO(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function XO(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function WO(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function ZO(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}HO(VO,KO),VO.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},VO.prototype._update=function(e){for(var t=this._w,n=0|this._a,r=0|this._b,i=0|this._c,o=0|this._d,a=0|this._e,s=0|this._f,u=0|this._g,l=0|this._h,A=0;A<16;++A)t[A]=e.readInt32BE(4*A);for(;A<64;++A)t[A]=ZO(t[A-2])+t[A-7]+WO(t[A-15])+t[A-16]|0;for(var c=0;c<64;++c){var h=l+XO(a)+zO(a,s,u)+GO[c]+t[c]|0,f=YO(n)+JO(n,r,i)|0;l=u,u=s,s=a,a=o+h|0,o=i,i=r,r=n,n=h+f|0}this._a=n+this._a|0,this._b=r+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0,this._f=s+this._f|0,this._g=u+this._g|0,this._h=l+this._h|0},VO.prototype._hash=function(){var e=jO.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e};var $O=VO,eH=KI.exports,tH=$O,nH=bO,rH=jN.exports.Buffer,iH=new Array(64);function oH(){this.init(),this._w=iH,nH.call(this,64,56)}eH(oH,tH),oH.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},oH.prototype._hash=function(){var e=rH.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e};var aH=oH,sH=KI.exports,uH=bO,lH=jN.exports.Buffer,AH=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],cH=new Array(160);function hH(){this.init(),this._w=cH,uH.call(this,128,112)}function fH(e,t,n){return n^e&(t^n)}function dH(e,t,n){return e&t|n&(e|t)}function pH(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function gH(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function vH(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function yH(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function mH(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function wH(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function bH(e,t){return e>>>0<t>>>0?1:0}sH(hH,uH),hH.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},hH.prototype._update=function(e){for(var t=this._w,n=0|this._ah,r=0|this._bh,i=0|this._ch,o=0|this._dh,a=0|this._eh,s=0|this._fh,u=0|this._gh,l=0|this._hh,A=0|this._al,c=0|this._bl,h=0|this._cl,f=0|this._dl,d=0|this._el,p=0|this._fl,g=0|this._gl,v=0|this._hl,y=0;y<32;y+=2)t[y]=e.readInt32BE(4*y),t[y+1]=e.readInt32BE(4*y+4);for(;y<160;y+=2){var m=t[y-30],w=t[y-30+1],b=vH(m,w),I=yH(w,m),B=mH(m=t[y-4],w=t[y-4+1]),E=wH(w,m),C=t[y-14],x=t[y-14+1],k=t[y-32],S=t[y-32+1],Q=I+x|0,_=b+C+bH(Q,I)|0;_=(_=_+B+bH(Q=Q+E|0,E)|0)+k+bH(Q=Q+S|0,S)|0,t[y]=_,t[y+1]=Q}for(var N=0;N<160;N+=2){_=t[N],Q=t[N+1];var D=dH(n,r,i),F=dH(A,c,h),P=pH(n,A),U=pH(A,n),L=gH(a,d),M=gH(d,a),T=AH[N],R=AH[N+1],O=fH(a,s,u),H=fH(d,p,g),K=v+M|0,j=l+L+bH(K,v)|0;j=(j=(j=j+O+bH(K=K+H|0,H)|0)+T+bH(K=K+R|0,R)|0)+_+bH(K=K+Q|0,Q)|0;var G=U+F|0,q=P+D+bH(G,U)|0;l=u,v=g,u=s,g=p,s=a,p=d,a=o+j+bH(d=f+K|0,f)|0,o=i,f=h,i=r,h=c,r=n,c=A,n=j+q+bH(A=K+G|0,K)|0}this._al=this._al+A|0,this._bl=this._bl+c|0,this._cl=this._cl+h|0,this._dl=this._dl+f|0,this._el=this._el+d|0,this._fl=this._fl+p|0,this._gl=this._gl+g|0,this._hl=this._hl+v|0,this._ah=this._ah+n+bH(this._al,A)|0,this._bh=this._bh+r+bH(this._bl,c)|0,this._ch=this._ch+i+bH(this._cl,h)|0,this._dh=this._dh+o+bH(this._dl,f)|0,this._eh=this._eh+a+bH(this._el,d)|0,this._fh=this._fh+s+bH(this._fl,p)|0,this._gh=this._gh+u+bH(this._gl,g)|0,this._hh=this._hh+l+bH(this._hl,v)|0},hH.prototype._hash=function(){var e=lH.allocUnsafe(64);function t(t,n,r){e.writeInt32BE(t,r),e.writeInt32BE(n,r+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e};var IH=hH,BH=KI.exports,EH=IH,CH=bO,xH=jN.exports.Buffer,kH=new Array(160);function SH(){this.init(),this._w=kH,CH.call(this,128,112)}BH(SH,EH),SH.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},SH.prototype._hash=function(){var e=xH.allocUnsafe(48);function t(t,n,r){e.writeInt32BE(t,r),e.writeInt32BE(n,r+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e};var QH=SH,_H=yO.exports=function(e){e=e.toLowerCase();var t=_H[e];if(!t)throw new Error(e+" is not supported (we accept pull requests)");return new t};_H.sha=_O,_H.sha1=OO,_H.sha224=aH,_H.sha256=$O,_H.sha384=QH,_H.sha512=IH;var NH=Do(sh),DH=jN.exports.Buffer,FH=JQ.Transform,PH=NH.StringDecoder;function UH(e){FH.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}(0,KI.exports)(UH,FH),UH.prototype.update=function(e,t,n){"string"==typeof e&&(e=DH.from(e,t));var r=this._update(e);return this.hashMode?this:(n&&(r=this._toString(r,n)),r)},UH.prototype.setAutoPadding=function(){},UH.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},UH.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},UH.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},UH.prototype._transform=function(e,t,n){var r;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){r=e}finally{n(r)}},UH.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},UH.prototype._finalOrDigest=function(e){var t=this.__final()||DH.alloc(0);return e&&(t=this._toString(t,e,!0)),t},UH.prototype._toString=function(e,t,n){if(this._decoder||(this._decoder=new PH(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var r=this._decoder.write(e);return n&&(r+=this._decoder.end()),r};var LH=UH,MH=KI.exports,TH=$R,RH=vO,OH=yO.exports,HH=LH;function KH(e){HH.call(this,"digest"),this._hash=e}MH(KH,HH),KH.prototype._update=function(e){this._hash.update(e)},KH.prototype._final=function(){return this._hash.digest()};var jH=function(e){return"md5"===(e=e.toLowerCase())?new TH:"rmd160"===e||"ripemd160"===e?new RH:new KH(OH(e))};Object.defineProperty(WL,"__esModule",{value:!0}),WL.taggedHash=WL.hash256=WL.hash160=WL.sha256=WL.sha1=WL.ripemd160=void 0;var GH=jH,qH=vO;function VH(e){try{return GH("rmd160").update(e).digest()}catch(t){try{return GH("ripemd160").update(e).digest()}catch(t){return(new qH).update(e).digest()}}}function zH(e){return GH("sha256").update(e).digest()}WL.ripemd160=VH,WL.sha1=function(e){return GH("sha1").update(e).digest()},WL.sha256=zH,WL.hash160=function(e){return VH(zH(e))},WL.hash256=function(e){return zH(zH(e))};var JH=Object.fromEntries(["BIP0340/challenge","BIP0340/aux","BIP0340/nonce","TapLeaf","TapBranch","TapSighash","TapTweak","KeyAgg list","KeyAgg coefficient"].map((function(e){var t=zH(Yo.from(e));return[e,Yo.concat([t,t])]})));WL.taggedHash=function(e,t){return zH(Yo.concat([JH[e],t]))};var YH=wU,XH=jN.exports.Buffer,WH=jH,ZH=function(e){function t(t){var n=t.slice(0,-4),r=t.slice(-4),i=e(n);if(!(r[0]^i[0]|r[1]^i[1]|r[2]^i[2]|r[3]^i[3]))return n}return{encode:function(t){var n=e(t);return YH.encode(XH.concat([t,n],t.length+4))},decode:function(e){var n=t(YH.decode(e));if(!n)throw new Error("Invalid checksum");return n},decodeUnsafe:function(e){var n=YH.decodeUnsafe(e);if(n)return t(n)}}}((function(e){var t=WH("sha256").update(e).digest();return WH("sha256").update(t).digest()}));Object.defineProperty(XL,"__esModule",{value:!0}),XL.p2pkh=void 0;var $H=WL,eK=EU,tK=kU,nK=OU,rK=_L,iK=ZH,oK=tK.OPS;XL.p2pkh=function(e,t){if(!(e.address||e.hash||e.output||e.pubkey||e.input))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,nK.typeforce)({network:nK.typeforce.maybe(nK.typeforce.Object),address:nK.typeforce.maybe(nK.typeforce.String),hash:nK.typeforce.maybe(nK.typeforce.BufferN(20)),output:nK.typeforce.maybe(nK.typeforce.BufferN(25)),pubkey:nK.typeforce.maybe(nK.isPoint),signature:nK.typeforce.maybe(tK.isCanonicalScriptSignature),input:nK.typeforce.maybe(nK.typeforce.Buffer)},e);var n=rK.value((function(){var t=iK.decode(e.address);return{version:t.readUInt8(0),hash:t.slice(1)}})),r=rK.value((function(){return tK.decompile(e.input)})),i=e.network||eK.bitcoin,o={name:"p2pkh",network:i};if(rK.prop(o,"address",(function(){if(o.hash){var e=Yo.allocUnsafe(21);return e.writeUInt8(i.pubKeyHash,0),o.hash.copy(e,1),iK.encode(e)}})),rK.prop(o,"hash",(function(){return e.output?e.output.slice(3,23):e.address?n().hash:e.pubkey||o.pubkey?$H.hash160(e.pubkey||o.pubkey):void 0})),rK.prop(o,"output",(function(){if(o.hash)return tK.compile([oK.OP_DUP,oK.OP_HASH160,o.hash,oK.OP_EQUALVERIFY,oK.OP_CHECKSIG])})),rK.prop(o,"pubkey",(function(){if(e.input)return r()[1]})),rK.prop(o,"signature",(function(){if(e.input)return r()[0]})),rK.prop(o,"input",(function(){if(e.pubkey&&e.signature)return tK.compile([e.signature,e.pubkey])})),rK.prop(o,"witness",(function(){if(o.input)return[]})),t.validate){var a=Yo.from([]);if(e.address){if(n().version!==i.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(20!==n().hash.length)throw new TypeError("Invalid address");a=n().hash}if(e.hash){if(a.length>0&&!a.equals(e.hash))throw new TypeError("Hash mismatch");a=e.hash}if(e.output){if(25!==e.output.length||e.output[0]!==oK.OP_DUP||e.output[1]!==oK.OP_HASH160||20!==e.output[2]||e.output[23]!==oK.OP_EQUALVERIFY||e.output[24]!==oK.OP_CHECKSIG)throw new TypeError("Output is invalid");var s=e.output.slice(3,23);if(a.length>0&&!a.equals(s))throw new TypeError("Hash mismatch");a=s}if(e.pubkey){var u=$H.hash160(e.pubkey);if(a.length>0&&!a.equals(u))throw new TypeError("Hash mismatch");a=u}if(e.input){var l=r();if(2!==l.length)throw new TypeError("Input is invalid");if(!tK.isCanonicalScriptSignature(l[0]))throw new TypeError("Input has invalid signature");if(!(0,nK.isPoint)(l[1]))throw new TypeError("Input has invalid pubkey");if(e.signature&&!e.signature.equals(l[0]))throw new TypeError("Signature mismatch");if(e.pubkey&&!e.pubkey.equals(l[1]))throw new TypeError("Pubkey mismatch");var A=$H.hash160(l[1]);if(a.length>0&&!a.equals(A))throw new TypeError("Hash mismatch")}}return Object.assign(o,e)};var aK={};Object.defineProperty(aK,"__esModule",{value:!0}),aK.p2sh=void 0;var sK=WL,uK=EU,lK=kU,AK=OU,cK=_L,hK=ZH,fK=lK.OPS;aK.p2sh=function(e,t){if(!(e.address||e.hash||e.output||e.redeem||e.input))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,AK.typeforce)({network:AK.typeforce.maybe(AK.typeforce.Object),address:AK.typeforce.maybe(AK.typeforce.String),hash:AK.typeforce.maybe(AK.typeforce.BufferN(20)),output:AK.typeforce.maybe(AK.typeforce.BufferN(23)),redeem:AK.typeforce.maybe({network:AK.typeforce.maybe(AK.typeforce.Object),output:AK.typeforce.maybe(AK.typeforce.Buffer),input:AK.typeforce.maybe(AK.typeforce.Buffer),witness:AK.typeforce.maybe(AK.typeforce.arrayOf(AK.typeforce.Buffer))}),input:AK.typeforce.maybe(AK.typeforce.Buffer),witness:AK.typeforce.maybe(AK.typeforce.arrayOf(AK.typeforce.Buffer))},e);var n=e.network;n||(n=e.redeem&&e.redeem.network||uK.bitcoin);var r={network:n},i=cK.value((function(){var t=hK.decode(e.address);return{version:t.readUInt8(0),hash:t.slice(1)}})),o=cK.value((function(){return lK.decompile(e.input)})),a=cK.value((function(){var t=o(),r=t[t.length-1];return{network:n,output:r===fK.OP_FALSE?Yo.from([]):r,input:lK.compile(t.slice(0,-1)),witness:e.witness||[]}}));if(cK.prop(r,"address",(function(){if(r.hash){var e=Yo.allocUnsafe(21);return e.writeUInt8(r.network.scriptHash,0),r.hash.copy(e,1),hK.encode(e)}})),cK.prop(r,"hash",(function(){return e.output?e.output.slice(2,22):e.address?i().hash:r.redeem&&r.redeem.output?sK.hash160(r.redeem.output):void 0})),cK.prop(r,"output",(function(){if(r.hash)return lK.compile([fK.OP_HASH160,r.hash,fK.OP_EQUAL])})),cK.prop(r,"redeem",(function(){if(e.input)return a()})),cK.prop(r,"input",(function(){if(e.redeem&&e.redeem.input&&e.redeem.output)return lK.compile([].concat(lK.decompile(e.redeem.input),e.redeem.output))})),cK.prop(r,"witness",(function(){return r.redeem&&r.redeem.witness?r.redeem.witness:r.input?[]:void 0})),cK.prop(r,"name",(function(){var e=["p2sh"];return void 0!==r.redeem&&void 0!==r.redeem.name&&e.push(r.redeem.name),e.join("-")})),t.validate){var s=Yo.from([]);if(e.address){if(i().version!==n.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(20!==i().hash.length)throw new TypeError("Invalid address");s=i().hash}if(e.hash){if(s.length>0&&!s.equals(e.hash))throw new TypeError("Hash mismatch");s=e.hash}if(e.output){if(23!==e.output.length||e.output[0]!==fK.OP_HASH160||20!==e.output[1]||e.output[22]!==fK.OP_EQUAL)throw new TypeError("Output is invalid");var u=e.output.slice(2,22);if(s.length>0&&!s.equals(u))throw new TypeError("Hash mismatch");s=u}var l=function(e){if(e.output){var t=lK.decompile(e.output);if(!t||t.length<1)throw new TypeError("Redeem.output too short");var n=sK.hash160(e.output);if(s.length>0&&!s.equals(n))throw new TypeError("Hash mismatch");s=n}if(e.input){var r=e.input.length>0,i=e.witness&&e.witness.length>0;if(!r&&!i)throw new TypeError("Empty input");if(r&&i)throw new TypeError("Input and witness provided");if(r){var o=lK.decompile(e.input);if(!lK.isPushOnly(o))throw new TypeError("Non push-only scriptSig")}}};if(e.input){var A=o();if(!A||A.length<1)throw new TypeError("Input too short");if(!Na(a().output))throw new TypeError("Input is invalid");l(a())}if(e.redeem){if(e.redeem.network&&e.redeem.network!==n)throw new TypeError("Network mismatch");if(e.input){var c=a();if(e.redeem.output&&!e.redeem.output.equals(c.output))throw new TypeError("Redeem.output mismatch");if(e.redeem.input&&!e.redeem.input.equals(c.input))throw new TypeError("Redeem.input mismatch")}l(e.redeem)}if(e.witness&&e.redeem&&e.redeem.witness&&!function(e,t){return e.length===t.length&&e.every((function(e,n){return e.equals(t[n])}))}(e.redeem.witness,e.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(r,e)};var dK={},pK={};Object.defineProperty(pK,"__esModule",{value:!0}),pK.bech32m=pK.bech32=void 0;for(var gK="qpzry9x8gf2tvdw0s3jn54khce6mua7l",vK={},yK=0;yK<gK.length;yK++){var mK=gK.charAt(yK);vK[mK]=yK}function wK(e){var 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 bK(e){for(var t=1,n=0;n<e.length;++n){var r=e.charCodeAt(n);if(r<33||r>126)return"Invalid prefix ("+e+")";t=wK(t)^r>>5}t=wK(t);for(var i=0;i<e.length;++i){var o=e.charCodeAt(i);t=wK(t)^31&o}return t}function IK(e,t,n,r){for(var i=0,o=0,a=(1<<n)-1,s=[],u=0;u<e.length;++u)for(i=i<<t|e[u],o+=t;o>=n;)o-=n,s.push(i>>o&a);if(r)o>0&&s.push(i<<n-o&a);else{if(o>=t)return"Excess padding";if(i<<n-o&a)return"Non-zero padding"}return s}function BK(e){return IK(e,8,5,!0)}function EK(e){var t=IK(e,5,8,!1);if(Array.isArray(t))return t}function CK(e){var t=IK(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function xK(e){var t;function n(e,n){if(n=n||90,e.length<8)return e+" too short";if(e.length>n)return"Exceeds length limit";var r=e.toLowerCase(),i=e.toUpperCase();if(e!==r&&e!==i)return"Mixed-case string "+e;var o=(e=r).lastIndexOf("1");if(-1===o)return"No separator character for "+e;if(0===o)return"Missing prefix for "+e;var a=e.slice(0,o),s=e.slice(o+1);if(s.length<6)return"Data too short";var u=bK(a);if("string"==typeof u)return u;for(var l=[],A=0;A<s.length;++A){var c=s.charAt(A),h=vK[c];if(void 0===h)return"Unknown character "+c;u=wK(u)^h,A+6>=s.length||l.push(h)}return u!==t?"Invalid checksum for "+e:{prefix:a,words:l}}return t="bech32"===e?1:734539939,{decodeUnsafe:function(e,t){var r=n(e,t);if("object"==i(r))return r},decode:function(e,t){var r=n(e,t);if("object"==i(r))return r;throw new Error(r)},encode:function(e,n,r){if(r=r||90,e.length+7+n.length>r)throw new TypeError("Exceeds length limit");var i=bK(e=e.toLowerCase());if("string"==typeof i)throw new Error(i);for(var o=e+"1",a=0;a<n.length;++a){var s=n[a];if(s>>5!=0)throw new Error("Non 5-bit word");i=wK(i)^s,o+=gK.charAt(s)}for(var u=0;u<6;++u)i=wK(i);i^=t;for(var l=0;l<6;++l)o+=gK.charAt(i>>5*(5-l)&31);return o},toWords:BK,fromWordsUnsafe:EK,fromWords:CK}}pK.bech32=xK("bech32"),pK.bech32m=xK("bech32m"),Object.defineProperty(dK,"__esModule",{value:!0}),dK.p2wpkh=void 0;var kK=WL,SK=EU,QK=kU,_K=OU,NK=_L,DK=pK,FK=QK.OPS,PK=Yo.alloc(0);dK.p2wpkh=function(e,t){if(!(e.address||e.hash||e.output||e.pubkey||e.witness))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,_K.typeforce)({address:_K.typeforce.maybe(_K.typeforce.String),hash:_K.typeforce.maybe(_K.typeforce.BufferN(20)),input:_K.typeforce.maybe(_K.typeforce.BufferN(0)),network:_K.typeforce.maybe(_K.typeforce.Object),output:_K.typeforce.maybe(_K.typeforce.BufferN(22)),pubkey:_K.typeforce.maybe(_K.isPoint),signature:_K.typeforce.maybe(QK.isCanonicalScriptSignature),witness:_K.typeforce.maybe(_K.typeforce.arrayOf(_K.typeforce.Buffer))},e);var n=NK.value((function(){var t=DK.bech32.decode(e.address),n=t.words.shift(),r=DK.bech32.fromWords(t.words);return{version:n,prefix:t.prefix,data:Yo.from(r)}})),r=e.network||SK.bitcoin,i={name:"p2wpkh",network:r};if(NK.prop(i,"address",(function(){if(i.hash){var e=DK.bech32.toWords(i.hash);return e.unshift(0),DK.bech32.encode(r.bech32,e)}})),NK.prop(i,"hash",(function(){return e.output?e.output.slice(2,22):e.address?n().data:e.pubkey||i.pubkey?kK.hash160(e.pubkey||i.pubkey):void 0})),NK.prop(i,"output",(function(){if(i.hash)return QK.compile([FK.OP_0,i.hash])})),NK.prop(i,"pubkey",(function(){return e.pubkey?e.pubkey:e.witness?e.witness[1]:void 0})),NK.prop(i,"signature",(function(){if(e.witness)return e.witness[0]})),NK.prop(i,"input",(function(){if(i.witness)return PK})),NK.prop(i,"witness",(function(){if(e.pubkey&&e.signature)return[e.signature,e.pubkey]})),t.validate){var o=Yo.from([]);if(e.address){if(r&&r.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");o=n().data}if(e.hash){if(o.length>0&&!o.equals(e.hash))throw new TypeError("Hash mismatch");o=e.hash}if(e.output){if(22!==e.output.length||e.output[0]!==FK.OP_0||20!==e.output[1])throw new TypeError("Output is invalid");if(o.length>0&&!o.equals(e.output.slice(2)))throw new TypeError("Hash mismatch");o=e.output.slice(2)}if(e.pubkey){var a=kK.hash160(e.pubkey);if(o.length>0&&!o.equals(a))throw new TypeError("Hash mismatch");if(o=a,!(0,_K.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(!QK.isCanonicalScriptSignature(e.witness[0]))throw new TypeError("Witness has invalid signature");if(!(0,_K.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");var s=kK.hash160(e.witness[1]);if(o.length>0&&!o.equals(s))throw new TypeError("Hash mismatch")}}return Object.assign(i,e)};var UK={};Object.defineProperty(UK,"__esModule",{value:!0}),UK.p2wsh=void 0;var LK=WL,MK=EU,TK=kU,RK=OU,OK=_L,HK=pK,KK=TK.OPS,jK=Yo.alloc(0);function GK(e){return!(!Na(e)||65!==e.length||4!==e[0]||!(0,RK.isPoint)(e))}UK.p2wsh=function(e,t){if(!(e.address||e.hash||e.output||e.redeem||e.witness))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,RK.typeforce)({network:RK.typeforce.maybe(RK.typeforce.Object),address:RK.typeforce.maybe(RK.typeforce.String),hash:RK.typeforce.maybe(RK.typeforce.BufferN(32)),output:RK.typeforce.maybe(RK.typeforce.BufferN(34)),redeem:RK.typeforce.maybe({input:RK.typeforce.maybe(RK.typeforce.Buffer),network:RK.typeforce.maybe(RK.typeforce.Object),output:RK.typeforce.maybe(RK.typeforce.Buffer),witness:RK.typeforce.maybe(RK.typeforce.arrayOf(RK.typeforce.Buffer))}),input:RK.typeforce.maybe(RK.typeforce.BufferN(0)),witness:RK.typeforce.maybe(RK.typeforce.arrayOf(RK.typeforce.Buffer))},e);var n=OK.value((function(){var t=HK.bech32.decode(e.address),n=t.words.shift(),r=HK.bech32.fromWords(t.words);return{version:n,prefix:t.prefix,data:Yo.from(r)}})),r=OK.value((function(){return TK.decompile(e.redeem.input)})),i=e.network;i||(i=e.redeem&&e.redeem.network||MK.bitcoin);var o={network:i};if(OK.prop(o,"address",(function(){if(o.hash){var e=HK.bech32.toWords(o.hash);return e.unshift(0),HK.bech32.encode(i.bech32,e)}})),OK.prop(o,"hash",(function(){return e.output?e.output.slice(2):e.address?n().data:o.redeem&&o.redeem.output?LK.sha256(o.redeem.output):void 0})),OK.prop(o,"output",(function(){if(o.hash)return TK.compile([KK.OP_0,o.hash])})),OK.prop(o,"redeem",(function(){if(e.witness)return{output:e.witness[e.witness.length-1],input:jK,witness:e.witness.slice(0,-1)}})),OK.prop(o,"input",(function(){if(o.witness)return jK})),OK.prop(o,"witness",(function(){if(e.redeem&&e.redeem.input&&e.redeem.input.length>0&&e.redeem.output&&e.redeem.output.length>0){var t=TK.toStack(r());return o.redeem=Object.assign({witness:t},e.redeem),o.redeem.input=jK,[].concat(t,e.redeem.output)}if(e.redeem&&e.redeem.output&&e.redeem.witness)return[].concat(e.redeem.witness,e.redeem.output)})),OK.prop(o,"name",(function(){var e=["p2wsh"];return void 0!==o.redeem&&void 0!==o.redeem.name&&e.push(o.redeem.name),e.join("-")})),t.validate){var a=Yo.from([]);if(e.address){if(n().prefix!==i.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");a=n().data}if(e.hash){if(a.length>0&&!a.equals(e.hash))throw new TypeError("Hash mismatch");a=e.hash}if(e.output){if(34!==e.output.length||e.output[0]!==KK.OP_0||32!==e.output[1])throw new TypeError("Output is invalid");var s=e.output.slice(2);if(a.length>0&&!a.equals(s))throw new TypeError("Hash mismatch");a=s}if(e.redeem){if(e.redeem.network&&e.redeem.network!==i)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){if(0===TK.decompile(e.redeem.output).length)throw new TypeError("Redeem.output is invalid");var u=LK.sha256(e.redeem.output);if(a.length>0&&!a.equals(u))throw new TypeError("Hash mismatch");a=u}if(e.redeem.input&&!TK.isPushOnly(r()))throw new TypeError("Non push-only scriptSig");if(e.witness&&e.redeem.witness&&!function(e,t){return e.length===t.length&&e.every((function(e,n){return e.equals(t[n])}))}(e.witness,e.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(e.redeem.input&&r().some(GK)||e.redeem.output&&(TK.decompile(e.redeem.output)||[]).some(GK))throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey")}if(e.witness&&e.witness.length>0){var l=e.witness[e.witness.length-1];if(e.redeem&&e.redeem.output&&!e.redeem.output.equals(l))throw new TypeError("Witness and redeem.output mismatch");if(e.witness.some(GK)||(TK.decompile(l)||[]).some(GK))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(o,e)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.p2wsh=e.p2wpkh=e.p2sh=e.p2pkh=e.p2pk=e.p2ms=e.embed=void 0;var t=xU;Object.defineProperty(e,"embed",{enumerable:!0,get:function(){return t.p2data}});var n=LL;Object.defineProperty(e,"p2ms",{enumerable:!0,get:function(){return n.p2ms}});var r=GL;Object.defineProperty(e,"p2pk",{enumerable:!0,get:function(){return r.p2pk}});var i=XL;Object.defineProperty(e,"p2pkh",{enumerable:!0,get:function(){return i.p2pkh}});var o=aK;Object.defineProperty(e,"p2sh",{enumerable:!0,get:function(){return o.p2sh}});var a=dK;Object.defineProperty(e,"p2wpkh",{enumerable:!0,get:function(){return a.p2wpkh}});var s=UK;Object.defineProperty(e,"p2wsh",{enumerable:!0,get:function(){return s.p2wsh}})}(CU),Object.defineProperty(BU,"__esModule",{value:!0}),BU.toOutputScript=BU.fromOutputScript=BU.toBech32=BU.toBase58Check=BU.fromBech32=BU.fromBase58Check=void 0;var qK=EU,VK=CU,zK=kU,JK=OU,YK=pK,XK=ZH,WK=JK.typeforce,ZK="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 $K(e){var t=XK.decode(e);if(t.length<21)throw new TypeError(e+" is too short");if(t.length>21)throw new TypeError(e+" is too long");return{version:t.readUInt8(0),hash:t.slice(1)}}function ej(e){var t,n;try{t=YK.bech32.decode(e)}catch(e){}if(t){if(0!==(n=t.words[0]))throw new TypeError(e+" uses wrong encoding")}else if(0===(n=(t=YK.bech32m.decode(e)).words[0]))throw new TypeError(e+" uses wrong encoding");var r=YK.bech32.fromWords(t.words.slice(1));return{version:n,prefix:t.prefix,data:Yo.from(r)}}function tj(e,t,n){var r=YK.bech32.toWords(e);return r.unshift(t),0===t?YK.bech32.encode(n,r):YK.bech32m.encode(n,r)}BU.fromBase58Check=$K,BU.fromBech32=ej,BU.toBase58Check=function(e,t){WK(JK.tuple(JK.Hash160bit,JK.UInt8),arguments);var n=Yo.allocUnsafe(21);return n.writeUInt8(t,0),e.copy(n,1),XK.encode(n)},BU.toBech32=tj,BU.fromOutputScript=function(e,t){t=t||qK.bitcoin;try{return VK.p2pkh({output:e,network:t}).address}catch(e){}try{return VK.p2sh({output:e,network:t}).address}catch(e){}try{return VK.p2wpkh({output:e,network:t}).address}catch(e){}try{return VK.p2wsh({output:e,network:t}).address}catch(e){}try{return function(e,t){var n=e.slice(2);if(n.length<2||n.length>40)throw new TypeError("Invalid program length for segwit address");var r=e[0]-80;if(r<1||r>16)throw new TypeError("Invalid version for segwit address");if(e[1]!==n.length)throw new TypeError("Invalid script for segwit address");return console.warn(ZK),tj(n,r,t.bech32)}(e,t)}catch(e){}throw new Error(zK.toASM(e)+" has no matching Address")},BU.toOutputScript=function(e,t){var n,r;t=t||qK.bitcoin;try{n=$K(e)}catch(e){}if(n){if(n.version===t.pubKeyHash)return VK.p2pkh({hash:n.hash}).output;if(n.version===t.scriptHash)return VK.p2sh({hash:n.hash}).output}else{try{r=ej(e)}catch(e){}if(r){if(r.prefix!==t.bech32)throw new Error(e+" has an invalid prefix");if(0===r.version){if(20===r.data.length)return VK.p2wpkh({hash:r.data}).output;if(32===r.data.length)return VK.p2wsh({hash:r.data}).output}else if(r.version>=1&&r.version<=16&&r.data.length>=2&&r.data.length<=40)return console.warn(ZK),zK.compile([r.version+80,r.data])}}throw new Error(e+" has no matching Script")};var nj={},rj={},ij=jN.exports.Buffer;function oj(e){if(e<0||e>9007199254740991||e%1!=0)throw new RangeError("value out of range")}function aj(e){return oj(e),e<253?1:e<=65535?3:e<=4294967295?5:9}var sj={encode:function e(t,n,r){if(oj(t),n||(n=ij.allocUnsafe(aj(t))),!ij.isBuffer(n))throw new TypeError("buffer must be a Buffer instance");return r||(r=0),t<253?(n.writeUInt8(t,r),e.bytes=1):t<=65535?(n.writeUInt8(253,r),n.writeUInt16LE(t,r+1),e.bytes=3):t<=4294967295?(n.writeUInt8(254,r),n.writeUInt32LE(t,r+1),e.bytes=5):(n.writeUInt8(255,r),n.writeUInt32LE(t>>>0,r+1),n.writeUInt32LE(t/4294967296|0,r+5),e.bytes=9),n},decode:function e(t,n){if(!ij.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");n||(n=0);var r=t.readUInt8(n);if(r<253)return e.bytes=1,r;if(253===r)return e.bytes=3,t.readUInt16LE(n+1);if(254===r)return e.bytes=5,t.readUInt32LE(n+1);e.bytes=9;var i=t.readUInt32LE(n+1),o=4294967296*t.readUInt32LE(n+5)+i;return oj(o),o},encodingLength:aj};Object.defineProperty(rj,"__esModule",{value:!0}),rj.BufferReader=rj.BufferWriter=rj.cloneBuffer=rj.reverseBuffer=rj.writeUInt64LE=rj.readUInt64LE=rj.varuint=void 0;var uj=OU,lj=uj.typeforce,Aj=sj;function cj(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 hj(e,t){var n=e.readUInt32LE(t),r=e.readUInt32LE(t+4);return cj((r*=4294967296)+n,9007199254740991),r+n}function fj(e,t,n){return cj(t,9007199254740991),e.writeInt32LE(-1&t,n),e.writeUInt32LE(Math.floor(t/4294967296),n+4),n+8}rj.varuint=Aj,rj.readUInt64LE=hj,rj.writeUInt64LE=fj,rj.reverseBuffer=function(e){if(e.length<1)return e;for(var t=e.length-1,n=0,r=0;r<e.length/2;r++)n=e[r],e[r]=e[t],e[t]=n,t--;return e},rj.cloneBuffer=function(e){var t=Yo.allocUnsafe(e.length);return e.copy(t),t};var dj=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;s(this,e),this.buffer=t,this.offset=n,lj(uj.tuple(uj.Buffer,uj.UInt32),[t,n])}return l(e,[{key:"writeUInt8",value:function(e){this.offset=this.buffer.writeUInt8(e,this.offset)}},{key:"writeInt32",value:function(e){this.offset=this.buffer.writeInt32LE(e,this.offset)}},{key:"writeUInt32",value:function(e){this.offset=this.buffer.writeUInt32LE(e,this.offset)}},{key:"writeUInt64",value:function(e){this.offset=fj(this.buffer,e,this.offset)}},{key:"writeVarInt",value:function(e){Aj.encode(e,this.buffer,this.offset),this.offset+=Aj.encode.bytes}},{key:"writeSlice",value:function(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)}},{key:"writeVarSlice",value:function(e){this.writeVarInt(e.length),this.writeSlice(e)}},{key:"writeVector",value:function(e){var t=this;this.writeVarInt(e.length),e.forEach((function(e){return t.writeVarSlice(e)}))}},{key:"end",value:function(){if(this.buffer.length===this.offset)return this.buffer;throw new Error("buffer size ".concat(this.buffer.length,", offset ").concat(this.offset))}}],[{key:"withCapacity",value:function(t){return new e(Yo.alloc(t))}}]),e}();rj.BufferWriter=dj,rj.BufferReader=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;s(this,e),this.buffer=t,this.offset=n,lj(uj.tuple(uj.Buffer,uj.UInt32),[t,n])}return l(e,[{key:"readUInt8",value:function(){var e=this.buffer.readUInt8(this.offset);return this.offset++,e}},{key:"readInt32",value:function(){var e=this.buffer.readInt32LE(this.offset);return this.offset+=4,e}},{key:"readUInt32",value:function(){var e=this.buffer.readUInt32LE(this.offset);return this.offset+=4,e}},{key:"readUInt64",value:function(){var e=hj(this.buffer,this.offset);return this.offset+=8,e}},{key:"readVarInt",value:function(){var e=Aj.decode(this.buffer,this.offset);return this.offset+=Aj.decode.bytes,e}},{key:"readSlice",value:function(e){if(this.buffer.length<this.offset+e)throw new Error("Cannot read slice out of bounds");var t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}},{key:"readVarSlice",value:function(){return this.readSlice(this.readVarInt())}},{key:"readVector",value:function(){for(var e=this.readVarInt(),t=[],n=0;n<e;n++)t.push(this.readVarSlice());return t}}]),e}();var pj={};Object.defineProperty(pj,"__esModule",{value:!0}),pj.fastMerkleRoot=void 0,pj.fastMerkleRoot=function(e,t){if(!Array.isArray(e))throw TypeError("Expected values Array");if("function"!=typeof t)throw TypeError("Expected digest Function");for(var n=e.length,r=e.concat();n>1;){for(var i=0,o=0;o<n;o+=2,++i){var a=r[o],s=o+1===n?a:r[o+1],u=Yo.concat([a,s]);r[i]=t(u)}n=i}return r[0]};var gj={};Object.defineProperty(gj,"__esModule",{value:!0}),gj.Transaction=void 0;var vj=rj,yj=WL,mj=kU,wj=kU,bj=OU,Ij=bj.typeforce;function Bj(e){var t=e.length;return vj.varuint.encodingLength(t)+t}var Ej=Yo.allocUnsafe(0),Cj=[],xj=Yo.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),kj=Yo.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),Sj=Yo.from("ffffffffffffffff","hex"),Qj={script:Ej,valueBuffer:Sj},_j=function(){function e(){s(this,e),this.version=1,this.locktime=0,this.ins=[],this.outs=[]}return l(e,[{key:"isCoinbase",value:function(){return 1===this.ins.length&&e.isCoinbaseHash(this.ins[0].hash)}},{key:"addInput",value:function(t,n,r,i){return Ij(bj.tuple(bj.Hash256bit,bj.UInt32,bj.maybe(bj.UInt32),bj.maybe(bj.Buffer)),arguments),bj.Null(r)&&(r=e.DEFAULT_SEQUENCE),this.ins.push({hash:t,index:n,script:i||Ej,sequence:r,witness:Cj})-1}},{key:"addOutput",value:function(e,t){return Ij(bj.tuple(bj.Buffer,bj.Satoshi),arguments),this.outs.push({script:e,value:t})-1}},{key:"hasWitnesses",value:function(){return this.ins.some((function(e){return 0!==e.witness.length}))}},{key:"weight",value:function(){return 3*this.byteLength(!1)+this.byteLength(!0)}},{key:"virtualSize",value:function(){return Math.ceil(this.weight()/4)}},{key:"byteLength",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=e&&this.hasWitnesses();return(t?10:8)+vj.varuint.encodingLength(this.ins.length)+vj.varuint.encodingLength(this.outs.length)+this.ins.reduce((function(e,t){return e+40+Bj(t.script)}),0)+this.outs.reduce((function(e,t){return e+8+Bj(t.script)}),0)+(t?this.ins.reduce((function(e,t){return e+function(e){var t=e.length;return vj.varuint.encodingLength(t)+e.reduce((function(e,t){return e+Bj(t)}),0)}(t.witness)}),0):0)}},{key:"clone",value:function(){var t=new e;return t.version=this.version,t.locktime=this.locktime,t.ins=this.ins.map((function(e){return{hash:e.hash,index:e.index,script:e.script,sequence:e.sequence,witness:e.witness}})),t.outs=this.outs.map((function(e){return{script:e.script,value:e.value}})),t}},{key:"hashForSignature",value:function(t,n,r){if(Ij(bj.tuple(bj.UInt32,bj.Buffer,bj.Number),arguments),t>=this.ins.length)return kj;var i=mj.compile(mj.decompile(n).filter((function(e){return e!==wj.OPS.OP_CODESEPARATOR}))),o=this.clone();if((31&r)===e.SIGHASH_NONE)o.outs=[],o.ins.forEach((function(e,n){n!==t&&(e.sequence=0)}));else if((31&r)===e.SIGHASH_SINGLE){if(t>=this.outs.length)return kj;o.outs.length=t+1;for(var a=0;a<t;a++)o.outs[a]=Qj;o.ins.forEach((function(e,n){n!==t&&(e.sequence=0)}))}r&e.SIGHASH_ANYONECANPAY?(o.ins=[o.ins[t]],o.ins[0].script=i):(o.ins.forEach((function(e){e.script=Ej})),o.ins[t].script=i);var s=Yo.allocUnsafe(o.byteLength(!1)+4);return s.writeInt32LE(r,s.length-4),o.__toBuffer(s,0,!1),yj.hash256(s)}},{key:"hashForWitnessV1",value:function(t,n,r,i,o,a){if(Ij(bj.tuple(bj.UInt32,Ij.arrayOf(bj.Buffer),Ij.arrayOf(bj.Satoshi),bj.UInt32),arguments),r.length!==this.ins.length||n.length!==this.ins.length)throw new Error("Must supply prevout script and value for all inputs");var s=i===e.SIGHASH_DEFAULT?e.SIGHASH_ALL:i&e.SIGHASH_OUTPUT_MASK,u=(i&e.SIGHASH_INPUT_MASK)===e.SIGHASH_ANYONECANPAY,l=s===e.SIGHASH_NONE,A=s===e.SIGHASH_SINGLE,c=Ej,h=Ej,f=Ej,d=Ej,p=Ej;if(!u){var g=vj.BufferWriter.withCapacity(36*this.ins.length);this.ins.forEach((function(e){g.writeSlice(e.hash),g.writeUInt32(e.index)})),c=yj.sha256(g.end()),g=vj.BufferWriter.withCapacity(8*this.ins.length),r.forEach((function(e){return g.writeUInt64(e)})),h=yj.sha256(g.end()),g=vj.BufferWriter.withCapacity(n.map(Bj).reduce((function(e,t){return e+t}))),n.forEach((function(e){return g.writeVarSlice(e)})),f=yj.sha256(g.end()),g=vj.BufferWriter.withCapacity(4*this.ins.length),this.ins.forEach((function(e){return g.writeUInt32(e.sequence)})),d=yj.sha256(g.end())}if(l||A){if(A&&t<this.outs.length){var v=this.outs[t],y=vj.BufferWriter.withCapacity(8+Bj(v.script));y.writeUInt64(v.value),y.writeVarSlice(v.script),p=yj.sha256(y.end())}}else{var m=this.outs.map((function(e){return 8+Bj(e.script)})).reduce((function(e,t){return e+t})),w=vj.BufferWriter.withCapacity(m);this.outs.forEach((function(e){w.writeUInt64(e.value),w.writeVarSlice(e.script)})),p=yj.sha256(w.end())}var b=(o?2:0)+(a?1:0),I=174-(u?49:0)-(l?32:0)+(a?32:0)+(o?37:0),B=vj.BufferWriter.withCapacity(I);if(B.writeUInt8(i),B.writeInt32(this.version),B.writeUInt32(this.locktime),B.writeSlice(c),B.writeSlice(h),B.writeSlice(f),B.writeSlice(d),l||A||B.writeSlice(p),B.writeUInt8(b),u){var E=this.ins[t];B.writeSlice(E.hash),B.writeUInt32(E.index),B.writeUInt64(r[t]),B.writeVarSlice(n[t]),B.writeUInt32(E.sequence)}else B.writeUInt32(t);if(a){var C=vj.BufferWriter.withCapacity(Bj(a));C.writeVarSlice(a),B.writeSlice(yj.sha256(C.end()))}return A&&B.writeSlice(p),o&&(B.writeSlice(o),B.writeUInt8(0),B.writeUInt32(4294967295)),yj.taggedHash("TapSighash",Yo.concat([Yo.of(0),B.end()]))}},{key:"hashForWitnessV0",value:function(t,n,r,i){Ij(bj.tuple(bj.UInt32,bj.Buffer,bj.Satoshi,bj.UInt32),arguments);var o,a=Yo.from([]),s=xj,u=xj,l=xj;if(i&e.SIGHASH_ANYONECANPAY||(a=Yo.allocUnsafe(36*this.ins.length),o=new vj.BufferWriter(a,0),this.ins.forEach((function(e){o.writeSlice(e.hash),o.writeUInt32(e.index)})),u=yj.hash256(a)),i&e.SIGHASH_ANYONECANPAY||(31&i)===e.SIGHASH_SINGLE||(31&i)===e.SIGHASH_NONE||(a=Yo.allocUnsafe(4*this.ins.length),o=new vj.BufferWriter(a,0),this.ins.forEach((function(e){o.writeUInt32(e.sequence)})),l=yj.hash256(a)),(31&i)!==e.SIGHASH_SINGLE&&(31&i)!==e.SIGHASH_NONE){var A=this.outs.reduce((function(e,t){return e+8+Bj(t.script)}),0);a=Yo.allocUnsafe(A),o=new vj.BufferWriter(a,0),this.outs.forEach((function(e){o.writeUInt64(e.value),o.writeVarSlice(e.script)})),s=yj.hash256(a)}else if((31&i)===e.SIGHASH_SINGLE&&t<this.outs.length){var c=this.outs[t];a=Yo.allocUnsafe(8+Bj(c.script)),(o=new vj.BufferWriter(a,0)).writeUInt64(c.value),o.writeVarSlice(c.script),s=yj.hash256(a)}a=Yo.allocUnsafe(156+Bj(n)),o=new vj.BufferWriter(a,0);var h=this.ins[t];return o.writeInt32(this.version),o.writeSlice(u),o.writeSlice(l),o.writeSlice(h.hash),o.writeUInt32(h.index),o.writeVarSlice(n),o.writeUInt64(r),o.writeUInt32(h.sequence),o.writeSlice(s),o.writeUInt32(this.locktime),o.writeUInt32(i),yj.hash256(a)}},{key:"getHash",value:function(e){return e&&this.isCoinbase()?Yo.alloc(32,0):yj.hash256(this.__toBuffer(void 0,void 0,e))}},{key:"getId",value:function(){return(0,vj.reverseBuffer)(this.getHash(!1)).toString("hex")}},{key:"toBuffer",value:function(e,t){return this.__toBuffer(e,t,!0)}},{key:"toHex",value:function(){return this.toBuffer(void 0,void 0).toString("hex")}},{key:"setInputScript",value:function(e,t){Ij(bj.tuple(bj.Number,bj.Buffer),arguments),this.ins[e].script=t}},{key:"setWitness",value:function(e,t){Ij(bj.tuple(bj.Number,[bj.Buffer]),arguments),this.ins[e].witness=t}},{key:"__toBuffer",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t||(t=Yo.allocUnsafe(this.byteLength(r)));var i=new vj.BufferWriter(t,n||0);i.writeInt32(this.version);var o=r&&this.hasWitnesses();return o&&(i.writeUInt8(e.ADVANCED_TRANSACTION_MARKER),i.writeUInt8(e.ADVANCED_TRANSACTION_FLAG)),i.writeVarInt(this.ins.length),this.ins.forEach((function(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((function(e){void 0!==e.value?i.writeUInt64(e.value):i.writeSlice(e.valueBuffer),i.writeVarSlice(e.script)})),o&&this.ins.forEach((function(e){i.writeVector(e.witness)})),i.writeUInt32(this.locktime),void 0!==n?t.slice(n,i.offset):t}}],[{key:"fromBuffer",value:function(t,n){var r=new vj.BufferReader(t),i=new e;i.version=r.readInt32();var o=r.readUInt8(),a=r.readUInt8(),s=!1;o===e.ADVANCED_TRANSACTION_MARKER&&a===e.ADVANCED_TRANSACTION_FLAG?s=!0:r.offset-=2;for(var u=r.readVarInt(),l=0;l<u;++l)i.ins.push({hash:r.readSlice(32),index:r.readUInt32(),script:r.readVarSlice(),sequence:r.readUInt32(),witness:Cj});for(var A=r.readVarInt(),c=0;c<A;++c)i.outs.push({value:r.readUInt64(),script:r.readVarSlice()});if(s){for(var h=0;h<u;++h)i.ins[h].witness=r.readVector();if(!i.hasWitnesses())throw new Error("Transaction has superfluous witness data")}if(i.locktime=r.readUInt32(),n)return i;if(r.offset!==t.length)throw new Error("Transaction has unexpected data");return i}},{key:"fromHex",value:function(t){return e.fromBuffer(Yo.from(t,"hex"),!1)}},{key:"isCoinbaseHash",value:function(e){Ij(bj.Hash256bit,e);for(var t=0;t<32;++t)if(0!==e[t])return!1;return!0}}]),e}();gj.Transaction=_j,_j.DEFAULT_SEQUENCE=4294967295,_j.SIGHASH_DEFAULT=0,_j.SIGHASH_ALL=1,_j.SIGHASH_NONE=2,_j.SIGHASH_SINGLE=3,_j.SIGHASH_ANYONECANPAY=128,_j.SIGHASH_OUTPUT_MASK=3,_j.SIGHASH_INPUT_MASK=128,_j.ADVANCED_TRANSACTION_MARKER=0,_j.ADVANCED_TRANSACTION_FLAG=1,Object.defineProperty(nj,"__esModule",{value:!0}),nj.Block=void 0;var Nj=rj,Dj=WL,Fj=pj,Pj=gj,Uj=OU,Lj=Uj.typeforce,Mj=new TypeError("Cannot compute merkle root for zero transactions"),Tj=new TypeError("Cannot compute witness commit for non-segwit block"),Rj=function(){function e(){s(this,e),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}return l(e,[{key:"getWitnessCommit",value:function(){if(!Oj(this.transactions))return null;var e=this.transactions[0].outs.filter((function(e){return e.script.slice(0,6).equals(Yo.from("6a24aa21a9ed","hex"))})).map((function(e){return e.script.slice(6,38)}));if(0===e.length)return null;var t=e[e.length-1];return t instanceof Yo&&32===t.length?t:null}},{key:"hasWitnessCommit",value:function(){return this.witnessCommit instanceof Yo&&32===this.witnessCommit.length||null!==this.getWitnessCommit()}},{key:"hasWitness",value:function(){return(e=this.transactions)instanceof Array&&e.some((function(e){return"object"==i(e)&&e.ins instanceof Array&&e.ins.some((function(e){return"object"==i(e)&&e.witness instanceof Array&&e.witness.length>0}))}));var e}},{key:"weight",value:function(){return 3*this.byteLength(!1,!1)+this.byteLength(!1,!0)}},{key:"byteLength",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return e||!this.transactions?80:80+Nj.varuint.encodingLength(this.transactions.length)+this.transactions.reduce((function(e,n){return e+n.byteLength(t)}),0)}},{key:"getHash",value:function(){return Dj.hash256(this.toBuffer(!0))}},{key:"getId",value:function(){return(0,Nj.reverseBuffer)(this.getHash()).toString("hex")}},{key:"getUTCDate",value:function(){var e=new Date(0);return e.setUTCSeconds(this.timestamp),e}},{key:"toBuffer",value:function(e){var t=Yo.allocUnsafe(this.byteLength(e)),n=new Nj.BufferWriter(t);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||(Nj.varuint.encode(this.transactions.length,t,n.offset),n.offset+=Nj.varuint.encode.bytes,this.transactions.forEach((function(e){var r=e.byteLength();e.toBuffer(t,n.offset),n.offset+=r}))),t}},{key:"toHex",value:function(e){return this.toBuffer(e).toString("hex")}},{key:"checkTxRoots",value:function(){var e=this.hasWitnessCommit();return!(!e&&this.hasWitness())&&this.__checkMerkleRoot()&&(!e||this.__checkWitnessCommit())}},{key:"checkProofOfWork",value:function(){var t=(0,Nj.reverseBuffer)(this.getHash()),n=e.calculateTarget(this.bits);return t.compare(n)<=0}},{key:"__checkMerkleRoot",value:function(){if(!this.transactions)throw Mj;var t=e.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(t)}},{key:"__checkWitnessCommit",value:function(){if(!this.transactions)throw Mj;if(!this.hasWitnessCommit())throw Tj;var t=e.calculateMerkleRoot(this.transactions,!0);return 0===this.witnessCommit.compare(t)}}],[{key:"fromBuffer",value:function(t){if(t.length<80)throw new Error("Buffer too small (< 80 bytes)");var n=new Nj.BufferReader(t),r=new e;if(r.version=n.readInt32(),r.prevHash=n.readSlice(32),r.merkleRoot=n.readSlice(32),r.timestamp=n.readUInt32(),r.bits=n.readUInt32(),r.nonce=n.readUInt32(),80===t.length)return r;var i=function(){var e=Pj.Transaction.fromBuffer(n.buffer.slice(n.offset),!0);return n.offset+=e.byteLength(),e},o=n.readVarInt();r.transactions=[];for(var a=0;a<o;++a){var s=i();r.transactions.push(s)}var u=r.getWitnessCommit();return u&&(r.witnessCommit=u),r}},{key:"fromHex",value:function(t){return e.fromBuffer(Yo.from(t,"hex"))}},{key:"calculateTarget",value:function(e){var t=((4278190080&e)>>24)-3,n=8388607&e,r=Yo.alloc(32,0);return r.writeUIntBE(n,29-t,3),r}},{key:"calculateMerkleRoot",value:function(e,t){if(Lj([{getHash:Uj.Function}],e),0===e.length)throw Mj;if(t&&!Oj(e))throw Tj;var n=e.map((function(e){return e.getHash(t)})),r=(0,Fj.fastMerkleRoot)(n,Dj.hash256);return t?Dj.hash256(Yo.concat([r,e[0].ins[0].witness[0]])):r}}]),e}();function Oj(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}nj.Block=Rj;var Hj={},Kj={},jj={},Gj={},qj={},Vj={},zj={};!function(e){var t,n,r;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"],(n=e.InputTypes||(e.InputTypes={}))[n.NON_WITNESS_UTXO=0]="NON_WITNESS_UTXO",n[n.WITNESS_UTXO=1]="WITNESS_UTXO",n[n.PARTIAL_SIG=2]="PARTIAL_SIG",n[n.SIGHASH_TYPE=3]="SIGHASH_TYPE",n[n.REDEEM_SCRIPT=4]="REDEEM_SCRIPT",n[n.WITNESS_SCRIPT=5]="WITNESS_SCRIPT",n[n.BIP32_DERIVATION=6]="BIP32_DERIVATION",n[n.FINAL_SCRIPTSIG=7]="FINAL_SCRIPTSIG",n[n.FINAL_SCRIPTWITNESS=8]="FINAL_SCRIPTWITNESS",n[n.POR_COMMITMENT=9]="POR_COMMITMENT",n[n.TAP_KEY_SIG=19]="TAP_KEY_SIG",n[n.TAP_SCRIPT_SIG=20]="TAP_SCRIPT_SIG",n[n.TAP_LEAF_SCRIPT=21]="TAP_LEAF_SCRIPT",n[n.TAP_BIP32_DERIVATION=22]="TAP_BIP32_DERIVATION",n[n.TAP_INTERNAL_KEY=23]="TAP_INTERNAL_KEY",n[n.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"],(r=e.OutputTypes||(e.OutputTypes={}))[r.REDEEM_SCRIPT=0]="REDEEM_SCRIPT",r[r.WITNESS_SCRIPT=1]="WITNESS_SCRIPT",r[r.BIP32_DERIVATION=2]="BIP32_DERIVATION",r[r.TAP_INTERNAL_KEY=5]="TAP_INTERNAL_KEY",r[r.TAP_TREE=6]="TAP_TREE",r[r.TAP_BIP32_DERIVATION=7]="TAP_BIP32_DERIVATION",e.OUTPUT_TYPE_NAMES=["redeemScript","witnessScript","bip32Derivation","tapInternalKey","tapTree","tapBip32Derivation"]}(zj);var Jj={};Object.defineProperty(Jj,"__esModule",{value:!0});var Yj=zj;Jj.decode=function(e){if(e.key[0]!==Yj.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");for(var t,n=e.key.slice(1),r={masterFingerprint:e.value.slice(0,4),extendedPubkey:n,path:"m"},i=0,o=(t=e.value.length/4-1,k(Array(t).keys()));i<o.length;i++){var a=o[i],s=e.value.readUInt32LE(4*a+4),u=!!(2147483648&s),l=2147483647&s;r.path+="/"+l.toString(10)+(u?"'":"")}return r},Jj.encode=function(e){var t=Yo.from([Yj.GlobalTypes.GLOBAL_XPUB]),n=Yo.concat([t,e.extendedPubkey]),r=e.path.split("/"),i=Yo.allocUnsafe(4*r.length);e.masterFingerprint.copy(i,0);var o=4;return r.slice(1).forEach((function(e){var t="'"===e.slice(-1),n=2147483647&parseInt(t?e.slice(0,-1):e,10);t&&(n+=2147483648),i.writeUInt32LE(n,o),o+=4})),{key:n,value:i}},Jj.expected="{ masterFingerprint: Buffer; extendedPubkey: Buffer; path: string; }",Jj.check=function(e){var t=e.extendedPubkey,n=e.masterFingerprint,r=e.path;return Na(t)&&78===t.length&&[2,3].indexOf(t[45])>-1&&Na(n)&&4===n.length&&"string"==typeof r&&!!r.match(/^m(\/\d+'?)*$/)},Jj.canAddToArray=function(e,t,n){var r=t.extendedPubkey.toString("hex");return!n.has(r)&&(n.add(r),0===e.filter((function(e){return e.extendedPubkey.equals(t.extendedPubkey)})).length)};var Xj={};Object.defineProperty(Xj,"__esModule",{value:!0});var Wj=zj;Xj.encode=function(e){return{key:Yo.from([Wj.GlobalTypes.UNSIGNED_TX]),value:e.toBuffer()}};var Zj={};Object.defineProperty(Zj,"__esModule",{value:!0});var $j=zj;Zj.decode=function(e){if(e.key[0]!==$j.InputTypes.FINAL_SCRIPTSIG)throw new Error("Decode Error: could not decode finalScriptSig with key 0x"+e.key.toString("hex"));return e.value},Zj.encode=function(e){return{key:Yo.from([$j.InputTypes.FINAL_SCRIPTSIG]),value:e}},Zj.expected="Buffer",Zj.check=function(e){return Na(e)},Zj.canAdd=function(e,t){return!!e&&!!t&&void 0===e.finalScriptSig};var eG={};Object.defineProperty(eG,"__esModule",{value:!0});var tG=zj;eG.decode=function(e){if(e.key[0]!==tG.InputTypes.FINAL_SCRIPTWITNESS)throw new Error("Decode Error: could not decode finalScriptWitness with key 0x"+e.key.toString("hex"));return e.value},eG.encode=function(e){return{key:Yo.from([tG.InputTypes.FINAL_SCRIPTWITNESS]),value:e}},eG.expected="Buffer",eG.check=function(e){return Na(e)},eG.canAdd=function(e,t){return!!e&&!!t&&void 0===e.finalScriptWitness};var nG={};Object.defineProperty(nG,"__esModule",{value:!0});var rG=zj;nG.decode=function(e){if(e.key[0]!==rG.InputTypes.NON_WITNESS_UTXO)throw new Error("Decode Error: could not decode nonWitnessUtxo with key 0x"+e.key.toString("hex"));return e.value},nG.encode=function(e){return{key:Yo.from([rG.InputTypes.NON_WITNESS_UTXO]),value:e}},nG.expected="Buffer",nG.check=function(e){return Na(e)},nG.canAdd=function(e,t){return!!e&&!!t&&void 0===e.nonWitnessUtxo};var iG={};Object.defineProperty(iG,"__esModule",{value:!0});var oG=zj;iG.decode=function(e){if(e.key[0]!==oG.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}},iG.encode=function(e){var t=Yo.from([oG.InputTypes.PARTIAL_SIG]);return{key:Yo.concat([t,e.pubkey]),value:e.signature}},iG.expected="{ pubkey: Buffer; signature: Buffer; }",iG.check=function(e){return Na(e.pubkey)&&Na(e.signature)&&[33,65].includes(e.pubkey.length)&&[2,3,4].includes(e.pubkey[0])&&function(e){if(!Na(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;var t=e[3];if(t>33||t<1)return!1;if(2!==e[3+t+1])return!1;var n=e[3+t+2];return!(n>33||n<1)&&e.length===3+t+2+n+2}(e.signature)},iG.canAddToArray=function(e,t,n){var r=t.pubkey.toString("hex");return!n.has(r)&&(n.add(r),0===e.filter((function(e){return e.pubkey.equals(t.pubkey)})).length)};var aG={};Object.defineProperty(aG,"__esModule",{value:!0});var sG=zj;aG.decode=function(e){if(e.key[0]!==sG.InputTypes.POR_COMMITMENT)throw new Error("Decode Error: could not decode porCommitment with key 0x"+e.key.toString("hex"));return e.value.toString("utf8")},aG.encode=function(e){return{key:Yo.from([sG.InputTypes.POR_COMMITMENT]),value:Yo.from(e,"utf8")}},aG.expected="string",aG.check=function(e){return"string"==typeof e},aG.canAdd=function(e,t){return!!e&&!!t&&void 0===e.porCommitment};var uG={};Object.defineProperty(uG,"__esModule",{value:!0});var lG=zj;uG.decode=function(e){if(e.key[0]!==lG.InputTypes.SIGHASH_TYPE)throw new Error("Decode Error: could not decode sighashType with key 0x"+e.key.toString("hex"));return e.value.readUInt32LE(0)},uG.encode=function(e){var t=Yo.from([lG.InputTypes.SIGHASH_TYPE]),n=Yo.allocUnsafe(4);return n.writeUInt32LE(e,0),{key:t,value:n}},uG.expected="number",uG.check=function(e){return"number"==typeof e},uG.canAdd=function(e,t){return!!e&&!!t&&void 0===e.sighashType};var AG={};Object.defineProperty(AG,"__esModule",{value:!0});var cG=zj;function hG(e){return Na(e)&&(64===e.length||65===e.length)}AG.decode=function(e){if(e.key[0]!==cG.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(!hG(e.value))throw new Error("Decode Error: tapKeySig not a valid 64-65-byte BIP340 signature");return e.value},AG.encode=function(e){return{key:Yo.from([cG.InputTypes.TAP_KEY_SIG]),value:e}},AG.expected="Buffer",AG.check=hG,AG.canAdd=function(e,t){return!!e&&!!t&&void 0===e.tapKeySig};var fG={};Object.defineProperty(fG,"__esModule",{value:!0});var dG=zj;fG.decode=function(e){if(e.key[0]!==dG.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"));var 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"));var n=e.value.slice(0,-1);return{controlBlock:e.key.slice(1),script:n,leafVersion:t}},fG.encode=function(e){var t=Yo.from([dG.InputTypes.TAP_LEAF_SCRIPT]),n=Yo.from([e.leafVersion]);return{key:Yo.concat([t,e.controlBlock]),value:Yo.concat([e.script,n])}},fG.expected="{ controlBlock: Buffer; leafVersion: number, script: Buffer; }",fG.check=function(e){return Na(e.controlBlock)&&(e.controlBlock.length-1)%32==0&&(254&e.controlBlock[0])===e.leafVersion&&Na(e.script)},fG.canAddToArray=function(e,t,n){var r=t.controlBlock.toString("hex");return!n.has(r)&&(n.add(r),0===e.filter((function(e){return e.controlBlock.equals(t.controlBlock)})).length)};var pG={};Object.defineProperty(pG,"__esModule",{value:!0});var gG=zj;function vG(e){return Na(e)&&32===e.length}pG.decode=function(e){if(e.key[0]!==gG.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(!vG(e.value))throw new Error("Decode Error: tapMerkleRoot not a 32-byte hash");return e.value},pG.encode=function(e){return{key:Yo.from([gG.InputTypes.TAP_MERKLE_ROOT]),value:e}},pG.expected="Buffer",pG.check=vG,pG.canAdd=function(e,t){return!!e&&!!t&&void 0===e.tapMerkleRoot};var yG={};Object.defineProperty(yG,"__esModule",{value:!0});var mG=zj;yG.decode=function(e){if(e.key[0]!==mG.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}},yG.encode=function(e){var t=Yo.from([mG.InputTypes.TAP_SCRIPT_SIG]);return{key:Yo.concat([t,e.pubkey,e.leafHash]),value:e.signature}},yG.expected="{ pubkey: Buffer; leafHash: Buffer; signature: Buffer; }",yG.check=function(e){return Na(e.pubkey)&&Na(e.leafHash)&&Na(e.signature)&&32===e.pubkey.length&&32===e.leafHash.length&&(64===e.signature.length||65===e.signature.length)},yG.canAddToArray=function(e,t,n){var r=t.pubkey.toString("hex")+t.leafHash.toString("hex");return!n.has(r)&&(n.add(r),0===e.filter((function(e){return e.pubkey.equals(t.pubkey)&&e.leafHash.equals(t.leafHash)})).length)};var wG={},bG={},IG={};function BG(e){if(e<0||e>9007199254740991||e%1!=0)throw new RangeError("value out of range")}function EG(e){return BG(e),e<253?1:e<=65535?3:e<=4294967295?5:9}Object.defineProperty(IG,"__esModule",{value:!0}),IG.encode=function e(t,n,r){if(BG(t),n||(n=Yo.allocUnsafe(EG(t))),!Na(n))throw new TypeError("buffer must be a Buffer instance");return r||(r=0),t<253?(n.writeUInt8(t,r),Object.assign(e,{bytes:1})):t<=65535?(n.writeUInt8(253,r),n.writeUInt16LE(t,r+1),Object.assign(e,{bytes:3})):t<=4294967295?(n.writeUInt8(254,r),n.writeUInt32LE(t,r+1),Object.assign(e,{bytes:5})):(n.writeUInt8(255,r),n.writeUInt32LE(t>>>0,r+1),n.writeUInt32LE(t/4294967296|0,r+5),Object.assign(e,{bytes:9})),n},IG.decode=function e(t,n){if(!Na(t))throw new TypeError("buffer must be a Buffer instance");n||(n=0);var r=t.readUInt8(n);if(r<253)return Object.assign(e,{bytes:1}),r;if(253===r)return Object.assign(e,{bytes:3}),t.readUInt16LE(n+1);if(254===r)return Object.assign(e,{bytes:5}),t.readUInt32LE(n+1);Object.assign(e,{bytes:9});var i=t.readUInt32LE(n+1),o=4294967296*t.readUInt32LE(n+5)+i;return BG(o),o},IG.encodingLength=EG,Object.defineProperty(bG,"__esModule",{value:!0});var CG=IG;function xG(e){var t=e.key.length,n=e.value.length,r=CG.encodingLength(t),i=CG.encodingLength(n),o=Yo.allocUnsafe(r+t+i+n);return CG.encode(t,o,0),e.key.copy(o,r),CG.encode(n,o,r+t),e.value.copy(o,r+t+i),o}function kG(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")}bG.range=function(e){return k(Array(e).keys())},bG.reverseBuffer=function(e){if(e.length<1)return e;for(var t=e.length-1,n=0,r=0;r<e.length/2;r++)n=e[r],e[r]=e[t],e[t]=n,t--;return e},bG.keyValsToBuffer=function(e){var t=e.map(xG);return t.push(Yo.from([0])),Yo.concat(t)},bG.keyValToBuffer=xG,bG.readUInt64LE=function(e,t){var n=e.readUInt32LE(t),r=e.readUInt32LE(t+4);return kG((r*=4294967296)+n,9007199254740991),r+n},bG.writeUInt64LE=function(e,t,n){return kG(t,9007199254740991),e.writeInt32LE(-1&t,n),e.writeUInt32LE(Math.floor(t/4294967296),n+4),n+8},Object.defineProperty(wG,"__esModule",{value:!0});var SG=zj,QG=bG,_G=IG;wG.decode=function(e){if(e.key[0]!==SG.InputTypes.WITNESS_UTXO)throw new Error("Decode Error: could not decode witnessUtxo with key 0x"+e.key.toString("hex"));var t=QG.readUInt64LE(e.value,0),n=8,r=_G.decode(e.value,n);n+=_G.encodingLength(r);var i=e.value.slice(n);if(i.length!==r)throw new Error("Decode Error: WITNESS_UTXO script is not proper length");return{script:i,value:t}},wG.encode=function(e){var t=e.script,n=e.value,r=_G.encodingLength(t.length),i=Yo.allocUnsafe(8+r+t.length);return QG.writeUInt64LE(i,n,0),_G.encode(t.length,i,8),t.copy(i,8+r),{key:Yo.from([SG.InputTypes.WITNESS_UTXO]),value:i}},wG.expected="{ script: Buffer; value: number; }",wG.check=function(e){return Na(e.script)&&"number"==typeof e.value},wG.canAdd=function(e,t){return!!e&&!!t&&void 0===e.witnessUtxo};var NG={};Object.defineProperty(NG,"__esModule",{value:!0});var DG=zj,FG=IG;NG.decode=function(e){if(e.key[0]!==DG.OutputTypes.TAP_TREE||1!==e.key.length)throw new Error("Decode Error: could not decode tapTree with key 0x"+e.key.toString("hex"));for(var t=0,n=[];t<e.value.length;){var r=e.value[t++],i=e.value[t++],o=FG.decode(e.value,t);t+=FG.encodingLength(o),n.push({depth:r,leafVersion:i,script:e.value.slice(t,t+o)}),t+=o}return{leaves:n}},NG.encode=function(e){var t,n=Yo.from([DG.OutputTypes.TAP_TREE]),r=(t=[]).concat.apply(t,k(e.leaves.map((function(e){return[Yo.of(e.depth,e.leafVersion),FG.encode(e.script.length),e.script]}))));return{key:n,value:Yo.concat(r)}},NG.expected="{ leaves: [{ depth: number; leafVersion: number, script: Buffer; }] }",NG.check=function(e){return Array.isArray(e.leaves)&&e.leaves.every((function(e){return e.depth>=0&&e.depth<=128&&(254&e.leafVersion)===e.leafVersion&&Na(e.script)}))},NG.canAdd=function(e,t){return!!e&&!!t&&void 0===e.tapTree};var PG={};Object.defineProperty(PG,"__esModule",{value:!0});var UG=function(e){return 33===e.length&&[2,3].includes(e[0])||65===e.length&&4===e[0]};PG.makeConverter=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:UG;return{decode:function(n){if(n.key[0]!==e)throw new Error("Decode Error: could not decode bip32Derivation with key 0x"+n.key.toString("hex"));var r=n.key.slice(1);if(!t(r))throw new Error("Decode Error: bip32Derivation has invalid pubkey in key 0x"+n.key.toString("hex"));if(n.value.length/4%1!=0)throw new Error("Decode Error: Input BIP32_DERIVATION value length should be multiple of 4");for(var i,o={masterFingerprint:n.value.slice(0,4),pubkey:r,path:"m"},a=0,s=(i=n.value.length/4-1,k(Array(i).keys()));a<s.length;a++){var u=s[a],l=n.value.readUInt32LE(4*u+4),A=!!(2147483648&l),c=2147483647&l;o.path+="/"+c.toString(10)+(A?"'":"")}return o},encode:function(t){var n=Yo.from([e]),r=Yo.concat([n,t.pubkey]),i=t.path.split("/"),o=Yo.allocUnsafe(4*i.length);t.masterFingerprint.copy(o,0);var a=4;return i.slice(1).forEach((function(e){var t="'"===e.slice(-1),n=2147483647&parseInt(t?e.slice(0,-1):e,10);t&&(n+=2147483648),o.writeUInt32LE(n,a),a+=4})),{key:r,value:o}},check:function(e){return Na(e.pubkey)&&Na(e.masterFingerprint)&&"string"==typeof e.path&&t(e.pubkey)&&4===e.masterFingerprint.length},expected:"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; }",canAddToArray:function(e,t,n){var r=t.pubkey.toString("hex");return!n.has(r)&&(n.add(r),0===e.filter((function(e){return e.pubkey.equals(t.pubkey)})).length)}}};var LG={};Object.defineProperty(LG,"__esModule",{value:!0}),LG.makeChecker=function(e){return function(t){var n;if(e.includes(t.key[0])&&(33!==(n=t.key.slice(1)).length&&65!==n.length||![2,3,4].includes(n[0])))throw new Error("Format Error: invalid pubkey in key 0x"+t.key.toString("hex"));return n}};var MG={};Object.defineProperty(MG,"__esModule",{value:!0}),MG.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(t){return{key:Yo.from([e]),value:t}},check:function(e){return Na(e)},expected:"Buffer",canAdd:function(e,t){return!!e&&!!t&&void 0===e.redeemScript}}};var TG={};Object.defineProperty(TG,"__esModule",{value:!0});var RG=IG,OG=PG,HG=function(e){return 32===e.length};TG.makeConverter=function(e){var t=OG.makeConverter(e,HG);return{decode:function(e){for(var n=RG.decode(e.value),r=RG.encodingLength(n),i=t.decode({key:e.key,value:e.value.slice(r+32*n)}),o=new Array(n),a=0,s=r;a<n;a++,s+=32)o[a]=e.value.slice(s,s+32);return Object.assign({},i,{leafHashes:o})},encode:function(e){var n=t.encode(e),r=RG.encodingLength(e.leafHashes.length),i=Yo.allocUnsafe(r);RG.encode(e.leafHashes.length,i);var o=Yo.concat([i].concat(k(e.leafHashes),[n.value]));return Object.assign({},n,{value:o})},check:function(e){return Array.isArray(e.leafHashes)&&e.leafHashes.every((function(e){return Na(e)&&32===e.length}))&&t.check(e)},expected:"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; leafHashes: Buffer[]; }",canAddToArray:t.canAddToArray}};var KG={};Object.defineProperty(KG,"__esModule",{value:!0}),KG.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(t){return{key:Yo.from([e]),value:t}},check:function(e){return Na(e)&&32===e.length},expected:"Buffer",canAdd:function(e,t){return!!e&&!!t&&void 0===e.tapInternalKey}}};var jG={};Object.defineProperty(jG,"__esModule",{value:!0}),jG.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(t){return{key:Yo.from([e]),value:t}},check:function(e){return Na(e)},expected:"Buffer",canAdd:function(e,t){return!!e&&!!t&&void 0===e.witnessScript}}},Object.defineProperty(Vj,"__esModule",{value:!0});var GG=zj,qG=Zj,VG=eG,zG=nG,JG=iG,YG=aG,XG=uG,WG=AG,ZG=fG,$G=pG,eq=yG,tq=wG,nq=NG,rq=PG,iq=LG,oq=MG,aq=TG,sq=KG,uq=jG,lq={unsignedTx:Xj,globalXpub:Jj,checkPubkey:iq.makeChecker([])};Vj.globals=lq;var Aq={nonWitnessUtxo:zG,partialSig:JG,sighashType:XG,finalScriptSig:qG,finalScriptWitness:VG,porCommitment:YG,witnessUtxo:tq,bip32Derivation:rq.makeConverter(GG.InputTypes.BIP32_DERIVATION),redeemScript:oq.makeConverter(GG.InputTypes.REDEEM_SCRIPT),witnessScript:uq.makeConverter(GG.InputTypes.WITNESS_SCRIPT),checkPubkey:iq.makeChecker([GG.InputTypes.PARTIAL_SIG,GG.InputTypes.BIP32_DERIVATION]),tapKeySig:WG,tapScriptSig:eq,tapLeafScript:ZG,tapBip32Derivation:aq.makeConverter(GG.InputTypes.TAP_BIP32_DERIVATION),tapInternalKey:sq.makeConverter(GG.InputTypes.TAP_INTERNAL_KEY),tapMerkleRoot:$G};Vj.inputs=Aq;var cq={bip32Derivation:rq.makeConverter(GG.OutputTypes.BIP32_DERIVATION),redeemScript:oq.makeConverter(GG.OutputTypes.REDEEM_SCRIPT),witnessScript:uq.makeConverter(GG.OutputTypes.WITNESS_SCRIPT),checkPubkey:iq.makeChecker([GG.OutputTypes.BIP32_DERIVATION]),tapBip32Derivation:aq.makeConverter(GG.OutputTypes.TAP_BIP32_DERIVATION),tapTree:nq,tapInternalKey:sq.makeConverter(GG.OutputTypes.TAP_INTERNAL_KEY)};Vj.outputs=cq,Object.defineProperty(qj,"__esModule",{value:!0});var hq=Vj,fq=bG,dq=IG,pq=zj;function gq(e,t,n){if(!t.equals(Yo.from([n])))throw new Error("Format Error: Invalid ".concat(e," key: ").concat(t.toString("hex")))}function vq(e,t){var n,r=t.globalMapKeyVals,i=t.inputKeyVals,o=t.outputKeyVals,a={unsignedTx:e},s=0,u=F(r);try{for(u.s();!(n=u.n()).done;){var l=n.value;switch(l.key[0]){case pq.GlobalTypes.UNSIGNED_TX:if(gq("global",l.key,pq.GlobalTypes.UNSIGNED_TX),s>0)throw new Error("Format Error: GlobalMap has multiple UNSIGNED_TX");s++;break;case pq.GlobalTypes.GLOBAL_XPUB:void 0===a.globalXpub&&(a.globalXpub=[]),a.globalXpub.push(hq.globals.globalXpub.decode(l));break;default:a.unknownKeyVals||(a.unknownKeyVals=[]),a.unknownKeyVals.push(l)}}}catch(e){u.e(e)}finally{u.f()}var A,c=i.length,h=o.length,f=[],d=[],p=F(fq.range(c));try{for(p.s();!(A=p.n()).done;){var g,v=A.value,y={},m=F(i[v]);try{for(m.s();!(g=m.n()).done;){var w=g.value;switch(hq.inputs.checkPubkey(w),w.key[0]){case pq.InputTypes.NON_WITNESS_UTXO:if(gq("input",w.key,pq.InputTypes.NON_WITNESS_UTXO),void 0!==y.nonWitnessUtxo)throw new Error("Format Error: Input has multiple NON_WITNESS_UTXO");y.nonWitnessUtxo=hq.inputs.nonWitnessUtxo.decode(w);break;case pq.InputTypes.WITNESS_UTXO:if(gq("input",w.key,pq.InputTypes.WITNESS_UTXO),void 0!==y.witnessUtxo)throw new Error("Format Error: Input has multiple WITNESS_UTXO");y.witnessUtxo=hq.inputs.witnessUtxo.decode(w);break;case pq.InputTypes.PARTIAL_SIG:void 0===y.partialSig&&(y.partialSig=[]),y.partialSig.push(hq.inputs.partialSig.decode(w));break;case pq.InputTypes.SIGHASH_TYPE:if(gq("input",w.key,pq.InputTypes.SIGHASH_TYPE),void 0!==y.sighashType)throw new Error("Format Error: Input has multiple SIGHASH_TYPE");y.sighashType=hq.inputs.sighashType.decode(w);break;case pq.InputTypes.REDEEM_SCRIPT:if(gq("input",w.key,pq.InputTypes.REDEEM_SCRIPT),void 0!==y.redeemScript)throw new Error("Format Error: Input has multiple REDEEM_SCRIPT");y.redeemScript=hq.inputs.redeemScript.decode(w);break;case pq.InputTypes.WITNESS_SCRIPT:if(gq("input",w.key,pq.InputTypes.WITNESS_SCRIPT),void 0!==y.witnessScript)throw new Error("Format Error: Input has multiple WITNESS_SCRIPT");y.witnessScript=hq.inputs.witnessScript.decode(w);break;case pq.InputTypes.BIP32_DERIVATION:void 0===y.bip32Derivation&&(y.bip32Derivation=[]),y.bip32Derivation.push(hq.inputs.bip32Derivation.decode(w));break;case pq.InputTypes.FINAL_SCRIPTSIG:gq("input",w.key,pq.InputTypes.FINAL_SCRIPTSIG),y.finalScriptSig=hq.inputs.finalScriptSig.decode(w);break;case pq.InputTypes.FINAL_SCRIPTWITNESS:gq("input",w.key,pq.InputTypes.FINAL_SCRIPTWITNESS),y.finalScriptWitness=hq.inputs.finalScriptWitness.decode(w);break;case pq.InputTypes.POR_COMMITMENT:gq("input",w.key,pq.InputTypes.POR_COMMITMENT),y.porCommitment=hq.inputs.porCommitment.decode(w);break;case pq.InputTypes.TAP_KEY_SIG:gq("input",w.key,pq.InputTypes.TAP_KEY_SIG),y.tapKeySig=hq.inputs.tapKeySig.decode(w);break;case pq.InputTypes.TAP_SCRIPT_SIG:void 0===y.tapScriptSig&&(y.tapScriptSig=[]),y.tapScriptSig.push(hq.inputs.tapScriptSig.decode(w));break;case pq.InputTypes.TAP_LEAF_SCRIPT:void 0===y.tapLeafScript&&(y.tapLeafScript=[]),y.tapLeafScript.push(hq.inputs.tapLeafScript.decode(w));break;case pq.InputTypes.TAP_BIP32_DERIVATION:void 0===y.tapBip32Derivation&&(y.tapBip32Derivation=[]),y.tapBip32Derivation.push(hq.inputs.tapBip32Derivation.decode(w));break;case pq.InputTypes.TAP_INTERNAL_KEY:gq("input",w.key,pq.InputTypes.TAP_INTERNAL_KEY),y.tapInternalKey=hq.inputs.tapInternalKey.decode(w);break;case pq.InputTypes.TAP_MERKLE_ROOT:gq("input",w.key,pq.InputTypes.TAP_MERKLE_ROOT),y.tapMerkleRoot=hq.inputs.tapMerkleRoot.decode(w);break;default:y.unknownKeyVals||(y.unknownKeyVals=[]),y.unknownKeyVals.push(w)}}}catch(e){m.e(e)}finally{m.f()}f.push(y)}}catch(e){p.e(e)}finally{p.f()}var b,I=F(fq.range(h));try{for(I.s();!(b=I.n()).done;){var B,E=b.value,C={},x=F(o[E]);try{for(x.s();!(B=x.n()).done;){var k=B.value;switch(hq.outputs.checkPubkey(k),k.key[0]){case pq.OutputTypes.REDEEM_SCRIPT:if(gq("output",k.key,pq.OutputTypes.REDEEM_SCRIPT),void 0!==C.redeemScript)throw new Error("Format Error: Output has multiple REDEEM_SCRIPT");C.redeemScript=hq.outputs.redeemScript.decode(k);break;case pq.OutputTypes.WITNESS_SCRIPT:if(gq("output",k.key,pq.OutputTypes.WITNESS_SCRIPT),void 0!==C.witnessScript)throw new Error("Format Error: Output has multiple WITNESS_SCRIPT");C.witnessScript=hq.outputs.witnessScript.decode(k);break;case pq.OutputTypes.BIP32_DERIVATION:void 0===C.bip32Derivation&&(C.bip32Derivation=[]),C.bip32Derivation.push(hq.outputs.bip32Derivation.decode(k));break;case pq.OutputTypes.TAP_INTERNAL_KEY:gq("output",k.key,pq.OutputTypes.TAP_INTERNAL_KEY),C.tapInternalKey=hq.outputs.tapInternalKey.decode(k);break;case pq.OutputTypes.TAP_TREE:gq("output",k.key,pq.OutputTypes.TAP_TREE),C.tapTree=hq.outputs.tapTree.decode(k);break;case pq.OutputTypes.TAP_BIP32_DERIVATION:void 0===C.tapBip32Derivation&&(C.tapBip32Derivation=[]),C.tapBip32Derivation.push(hq.outputs.tapBip32Derivation.decode(k));break;default:C.unknownKeyVals||(C.unknownKeyVals=[]),C.unknownKeyVals.push(k)}}}catch(e){x.e(e)}finally{x.f()}d.push(C)}}catch(e){I.e(e)}finally{I.f()}return{globalMap:a,inputs:f,outputs:d}}qj.psbtFromBuffer=function(e,t){var n=0;function r(){var t=dq.decode(e,n);n+=dq.encodingLength(t);var r=e.slice(n,n+t);return n+=t,r}function i(){return{key:r(),value:r()}}function o(){if(n>=e.length)throw new Error("Format Error: Unexpected End of PSBT");var t=0===e.readUInt8(n);return t&&n++,t}if(1886610036!==function(){var t=e.readUInt32BE(n);return n+=4,t}())throw new Error("Format Error: Invalid Magic Number");if(255!==function(){var t=e.readUInt8(n);return n+=1,t}())throw new Error("Format Error: Magic Number must be followed by 0xff separator");for(var a=[],s={};!o();){var u=i(),l=u.key.toString("hex");if(s[l])throw new Error("Format Error: Keys must be unique for global keymap: key "+l);s[l]=1,a.push(u)}var A=a.filter((function(e){return e.key[0]===pq.GlobalTypes.UNSIGNED_TX}));if(1!==A.length)throw new Error("Format Error: Only one UNSIGNED_TX allowed");var c,h=t(A[0].value),f=h.getInputOutputCounts(),d=f.inputCount,p=f.outputCount,g=[],v=[],y=F(fq.range(d));try{for(y.s();!(c=y.n()).done;){for(var m=c.value,w={},b=[];!o();){var I=i(),B=I.key.toString("hex");if(w[B])throw new Error("Format Error: Keys must be unique for each input: input index "+m+" key "+B);w[B]=1,b.push(I)}g.push(b)}}catch(e){y.e(e)}finally{y.f()}var E,C=F(fq.range(p));try{for(C.s();!(E=C.n()).done;){for(var x=E.value,k={},S=[];!o();){var Q=i(),_=Q.key.toString("hex");if(k[_])throw new Error("Format Error: Keys must be unique for each output: output index "+x+" key "+_);k[_]=1,S.push(Q)}v.push(S)}}catch(e){C.e(e)}finally{C.f()}return vq(h,{globalMapKeyVals:a,inputKeyVals:g,outputKeyVals:v})},qj.checkKeyBuffer=gq,qj.psbtFromKeyVals=vq;var yq={};Object.defineProperty(yq,"__esModule",{value:!0});var mq=Vj,wq=bG;yq.psbtToBuffer=function(e){var t=Bq({globalMap:e.globalMap,inputs:e.inputs,outputs:e.outputs}),n=t.globalKeyVals,r=t.inputKeyVals,i=t.outputKeyVals,o=wq.keyValsToBuffer(n),a=function(e){return 0===e.length?[Yo.from([0])]:e.map(wq.keyValsToBuffer)},s=a(r),u=a(i),l=Yo.allocUnsafe(5);return l.writeUIntBE(482972169471,0,5),Yo.concat([l,o].concat(s,u))};var bq=function(e,t){return e.key.compare(t.key)};function Iq(e,t){var n=new Set,r=Object.entries(e).reduce((function(e,r){var i=C(r,2),o=i[0],a=i[1];if("unknownKeyVals"===o)return e;var s=t[o];if(void 0===s)return e;var u=(Array.isArray(a)?a:[a]).map(s.encode);return u.map((function(e){return e.key.toString("hex")})).forEach((function(e){if(n.has(e))throw new Error("Serialize Error: Duplicate key: "+e);n.add(e)})),e.concat(u)}),[]),i=e.unknownKeyVals?e.unknownKeyVals.filter((function(e){return!n.has(e.key.toString("hex"))})):[];return r.concat(i).sort(bq)}function Bq(e){var t=e.globalMap,n=e.inputs,r=e.outputs;return{globalKeyVals:Iq(t,mq.globals),inputKeyVals:n.map((function(e){return Iq(e,mq.inputs)})),outputKeyVals:r.map((function(e){return Iq(e,mq.outputs)}))}}yq.psbtToKeyVals=Bq,function(e){function t(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}Object.defineProperty(e,"__esModule",{value:!0}),t(qj),t(yq)}(Gj),Object.defineProperty(jj,"__esModule",{value:!0});var Eq=Gj;function Cq(e,t,n){return function(r){if(!e.has(r)){var i=n.filter((function(e){return e.key.toString("hex")===r}))[0];t.push(i),e.add(r)}}}function xq(e){return e.globalMap.unsignedTx}function kq(e){var t=new Set;return e.forEach((function(e){var n=e.key.toString("hex");if(t.has(n))throw new Error("Combine: KeyValue Map keys should be unique");t.add(n)})),t}jj.combine=function(e){var t=e[0],n=Eq.psbtToKeyVals(t),r=e.slice(1);if(0===r.length)throw new Error("Combine: Nothing to combine");var i=xq(t);if(void 0===i)throw new Error("Combine: Self missing transaction");var o,a=kq(n.globalKeyVals),s=n.inputKeyVals.map(kq),u=n.outputKeyVals.map(kq),l=F(r);try{var A=function(){var e=o.value,t=xq(e);if(void 0===t||!t.toBuffer().equals(i.toBuffer()))throw new Error("Combine: One of the Psbts does not have the same transaction.");var r=Eq.psbtToKeyVals(e);kq(r.globalKeyVals).forEach(Cq(a,n.globalKeyVals,r.globalKeyVals)),r.inputKeyVals.map(kq).forEach((function(e,t){return e.forEach(Cq(s[t],n.inputKeyVals[t],r.inputKeyVals[t]))})),r.outputKeyVals.map(kq).forEach((function(e,t){return e.forEach(Cq(u[t],n.outputKeyVals[t],r.outputKeyVals[t]))}))};for(l.s();!(o=l.n()).done;)A()}catch(e){l.e(e)}finally{l.f()}return Eq.psbtFromKeyVals(i,{globalMapKeyVals:n.globalKeyVals,inputKeyVals:n.inputKeyVals,outputKeyVals:n.outputKeyVals})};var Sq={};!function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=Vj;function n(e,t){var n=e[t];if(void 0===n)throw new Error("No input #".concat(t));return n}function r(e,t){var n=e[t];if(void 0===n)throw new Error("No output #".concat(t));return n}function i(e,t,n,r){throw new Error("Data for ".concat(e," key ").concat(t," is incorrect: Expected ").concat(n," and got ").concat(JSON.stringify(r)))}function o(e){return function(n,r){for(var o=function(){var o=s[a],u=n[o],l=t[e+"s"][o]||{},A=l.canAdd,c=l.canAddToArray,h=l.check,f=l.expected;if(h)if(!!c){if(!Array.isArray(u)||r[o]&&!Array.isArray(r[o]))throw new Error("Key type ".concat(o," must be an array"));u.every(h)||i(e,o,f,u);var d=r[o]||[],p=new Set;if(!u.every((function(e){return c(d,e,p)})))throw new Error("Can not add duplicate data to array");r[o]=d.concat(u)}else{if(h(u)||i(e,o,f,u),!A(r,u))throw new Error("Can not add duplicate data to ".concat(e));r[o]=u}},a=0,s=Object.keys(n);a<s.length;a++)o()}}e.checkForInput=n,e.checkForOutput=r,e.checkHasKey=function(e,t,n){if(e.key[0]<n)throw new Error("Use the method for your specific key instead of addUnknownKeyVal*");if(t&&0!==t.filter((function(t){return t.key.equals(e.key)})).length)throw new Error("Duplicate Key: ".concat(e.key.toString("hex")))},e.getEnumLength=function(e){var t=0;return Object.keys(e).forEach((function(e){Number(isNaN(Number(e)))&&t++})),t},e.inputCheckUncleanFinalized=function(e,t){var n=!1;if(t.nonWitnessUtxo||t.witnessUtxo){var r=!!t.redeemScript,i=!!t.witnessScript,o=!r||!!t.finalScriptSig,a=!i||!!t.finalScriptWitness,s=!!t.finalScriptSig||!!t.finalScriptWitness;n=o&&a&&s}if(!1===n)throw new Error("Input #".concat(e," has too much or too little data to clean"))},e.updateGlobal=o("global"),e.updateInput=o("input"),e.updateOutput=o("output"),e.addInputAttributes=function(t,r){var i=n(t,t.length-1);e.updateInput(r,i)},e.addOutputAttributes=function(t,n){var i=r(t,t.length-1);e.updateOutput(n,i)},e.defaultVersionSetter=function(e,t){if(!Na(t)||t.length<4)throw new Error("Set Version: Invalid Transaction");return t.writeUInt32LE(e,0),t},e.defaultLocktimeSetter=function(e,t){if(!Na(t)||t.length<4)throw new Error("Set Locktime: Invalid Transaction");return t.writeUInt32LE(e,t.length-4),t}}(Sq),Object.defineProperty(Kj,"__esModule",{value:!0});var Qq=jj,_q=Gj,Nq=zj,Dq=Sq;Kj.Psbt=function(){function e(t){s(this,e),this.inputs=[],this.outputs=[],this.globalMap={unsignedTx:t}}return l(e,[{key:"toBase64",value:function(){return this.toBuffer().toString("base64")}},{key:"toHex",value:function(){return this.toBuffer().toString("hex")}},{key:"toBuffer",value:function(){return _q.psbtToBuffer(this)}},{key:"updateGlobal",value:function(e){return Dq.updateGlobal(e,this.globalMap),this}},{key:"updateInput",value:function(e,t){var n=Dq.checkForInput(this.inputs,e);return Dq.updateInput(t,n),this}},{key:"updateOutput",value:function(e,t){var n=Dq.checkForOutput(this.outputs,e);return Dq.updateOutput(t,n),this}},{key:"addUnknownKeyValToGlobal",value:function(e){return Dq.checkHasKey(e,this.globalMap.unknownKeyVals,Dq.getEnumLength(Nq.GlobalTypes)),this.globalMap.unknownKeyVals||(this.globalMap.unknownKeyVals=[]),this.globalMap.unknownKeyVals.push(e),this}},{key:"addUnknownKeyValToInput",value:function(e,t){var n=Dq.checkForInput(this.inputs,e);return Dq.checkHasKey(t,n.unknownKeyVals,Dq.getEnumLength(Nq.InputTypes)),n.unknownKeyVals||(n.unknownKeyVals=[]),n.unknownKeyVals.push(t),this}},{key:"addUnknownKeyValToOutput",value:function(e,t){var n=Dq.checkForOutput(this.outputs,e);return Dq.checkHasKey(t,n.unknownKeyVals,Dq.getEnumLength(Nq.OutputTypes)),n.unknownKeyVals||(n.unknownKeyVals=[]),n.unknownKeyVals.push(t),this}},{key:"addInput",value:function(e){var t=this;this.globalMap.unsignedTx.addInput(e),this.inputs.push({unknownKeyVals:[]});var n=e.unknownKeyVals||[],r=this.inputs.length-1;if(!Array.isArray(n))throw new Error("unknownKeyVals must be an Array");return n.forEach((function(e){return t.addUnknownKeyValToInput(r,e)})),Dq.addInputAttributes(this.inputs,e),this}},{key:"addOutput",value:function(e){var t=this;this.globalMap.unsignedTx.addOutput(e),this.outputs.push({unknownKeyVals:[]});var n=e.unknownKeyVals||[],r=this.outputs.length-1;if(!Array.isArray(n))throw new Error("unknownKeyVals must be an Array");return n.forEach((function(e){return t.addUnknownKeyValToInput(r,e)})),Dq.addOutputAttributes(this.outputs,e),this}},{key:"clearFinalizedInput",value:function(e){var t=Dq.checkForInput(this.inputs,e);Dq.inputCheckUncleanFinalized(e,t);for(var n=0,r=Object.keys(t);n<r.length;n++){var i=r[n];["witnessUtxo","nonWitnessUtxo","finalScriptSig","finalScriptWitness","unknownKeyVals"].includes(i)||delete t[i]}return this}},{key:"combine",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=Qq.combine([this].concat(t));return Object.assign(this,r),this}},{key:"getTransaction",value:function(){return this.globalMap.unsignedTx.toBuffer()}}],[{key:"fromBase64",value:function(e,t){var n=Yo.from(e,"base64");return this.fromBuffer(n,t)}},{key:"fromHex",value:function(e,t){var n=Yo.from(e,"hex");return this.fromBuffer(n,t)}},{key:"fromBuffer",value:function(e,t){var n=_q.psbtFromBuffer(e,t),r=new this(n.globalMap.unsignedTx);return Object.assign(r,n),r}}]),e}(),Object.defineProperty(Hj,"__esModule",{value:!0}),Hj.Psbt=void 0;var Fq=Kj,Pq=IG,Uq=Sq,Lq=BU,Mq=rj,Tq=WL,Rq=CU,Oq=kU,Hq=gj,Kq={network:EU.bitcoin,maximumFeeRate:5e3},jq=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Fq.Psbt(new qq);s(this,e),this.data=n,this.opts=Object.assign({},Kq,t),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);var r=function(e,t,n,r){return Object.defineProperty(e,t,{enumerable:n,writable:r})};r(this,"__CACHE",!1,!0),r(this,"opts",!1,!0)}return l(e,[{key:"inputCount",get:function(){return this.data.inputs.length}},{key:"version",get:function(){return this.__CACHE.__TX.version},set:function(e){this.setVersion(e)}},{key:"locktime",get:function(){return this.__CACHE.__TX.locktime},set:function(e){this.setLocktime(e)}},{key:"txInputs",get:function(){return this.__CACHE.__TX.ins.map((function(e){return{hash:(0,Mq.cloneBuffer)(e.hash),index:e.index,sequence:e.sequence}}))}},{key:"txOutputs",get:function(){var e=this;return this.__CACHE.__TX.outs.map((function(t){var n;try{n=(0,Lq.fromOutputScript)(t.script,e.opts.network)}catch(t){}return{script:(0,Mq.cloneBuffer)(t.script),value:t.value,address:n}}))}},{key:"combine",value:function(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(e=this.data).combine.apply(e,k(n.map((function(e){return e.data})))),this}},{key:"clone",value:function(){var t=e.fromBuffer(this.data.toBuffer());return t.opts=JSON.parse(JSON.stringify(this.opts)),t}},{key:"setMaximumFeeRate",value:function(e){rV(e),this.opts.maximumFeeRate=e}},{key:"setVersion",value:function(e){rV(e),iV(this.data.inputs,"setVersion");var t=this.__CACHE;return t.__TX.version=e,t.__EXTRACTED_TX=void 0,this}},{key:"setLocktime",value:function(e){rV(e),iV(this.data.inputs,"setLocktime");var t=this.__CACHE;return t.__TX.locktime=e,t.__EXTRACTED_TX=void 0,this}},{key:"setInputSequence",value:function(e,t){rV(t),iV(this.data.inputs,"setInputSequence");var n=this.__CACHE;if(n.__TX.ins.length<=e)throw new Error("Input index too high");return n.__TX.ins[e].sequence=t,n.__EXTRACTED_TX=void 0,this}},{key:"addInputs",value:function(e){var t=this;return e.forEach((function(e){return t.addInput(e)})),this}},{key:"addInput",value:function(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]");iV(this.data.inputs,"addInput"),e.witnessScript&&IV(e.witnessScript);var t=this.__CACHE;this.data.addInput(e),aV(t,t.__TX.ins[t.__TX.ins.length-1]);var n=this.data.inputs.length-1,r=this.data.inputs[n];return r.nonWitnessUtxo&&gV(this.__CACHE,r,n),t.__FEE=void 0,t.__FEE_RATE=void 0,t.__EXTRACTED_TX=void 0,this}},{key:"addOutputs",value:function(e){var t=this;return e.forEach((function(e){return t.addOutput(e)})),this}},{key:"addOutput",value:function(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]");iV(this.data.inputs,"addOutput");var t=e,n=t.address;if("string"==typeof n){var r=this.opts.network,i=(0,Lq.toOutputScript)(n,r);e=Object.assign(e,{script:i})}var o=this.__CACHE;return this.data.addOutput(e),o.__FEE=void 0,o.__FEE_RATE=void 0,o.__EXTRACTED_TX=void 0,this}},{key:"extractTransaction",value:function(e){if(!this.data.inputs.every(Jq))throw new Error("Not finalized");var t=this.__CACHE;if(e||function(e,t,n){var r=t.__FEE_RATE||e.getFeeRate(),i=t.__EXTRACTED_TX.virtualSize(),o=r*i;if(r>=n.maximumFeeRate)throw new Error("Warning: You are paying around ".concat((o/1e8).toFixed(8)," in fees, which is ").concat(r," satoshi per byte for a transaction with a VSize of ").concat(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;var n=t.__TX.clone();return vV(this.data.inputs,n,t,!0),n}},{key:"getFeeRate",value:function(){return AV("__FEE_RATE","fee rate",this.data.inputs,this.__CACHE)}},{key:"getFee",value:function(){return AV("__FEE","fee",this.data.inputs,this.__CACHE)}},{key:"finalizeAllInputs",value:function(){var e=this;return(0,Uq.checkForInput)(this.data.inputs,0),CV(this.data.inputs.length).forEach((function(t){return e.finalizeInput(t)})),this}},{key:"finalizeInput",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:cV,n=(0,Uq.checkForInput)(this.data.inputs,e),r=function(e,t,n){var r=n.__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){var o=yV(n,t,e),a=r.ins[e].index;i.script=o.outs[a].script}else t.witnessUtxo&&(i.script=t.witnessUtxo.script);return(t.witnessScript||$q(i.script))&&(i.isSegwit=!0),i}(e,n,this.__CACHE),i=r.script,o=r.isP2SH,a=r.isP2WSH,s=r.isSegwit;if(!i)throw new Error("No script found for input #".concat(e));!function(e){if(e.sighashType&&e.partialSig){var t=e.partialSig,n=e.sighashType;t.forEach((function(e){var t=Oq.signature.decode(e.signature).hashType;if(n!==t)throw new Error("Signature sighash does not match input sighash type")}))}}(n);var u=t(e,n,i,s,o,a),l=u.finalScriptSig,A=u.finalScriptWitness;if(l&&this.data.updateInput(e,{finalScriptSig:l}),A&&this.data.updateInput(e,{finalScriptWitness:A}),!l&&!A)throw new Error("Unknown error finalizing input #".concat(e));return this.data.clearFinalizedInput(e),this}},{key:"getInputType",value:function(e){var t=(0,Uq.checkForInput)(this.data.inputs,e),n=bV(mV(e,t,this.__CACHE),e,"input",t.redeemScript||function(e){if(e){var t=Oq.decompile(e);if(t){var n,r=t[t.length-1];if(Na(r)&&!wV(r)&&(n=r,!Oq.isCanonicalScriptSignature(n)))if(Oq.decompile(r))return r}}}(t.finalScriptSig),t.witnessScript||function(e){if(e){var t=pV(e),n=t[t.length-1];if(!wV(n)&&Oq.decompile(n))return n}}(t.finalScriptWitness));return("raw"===n.type?"":n.type+"-")+EV(n.meaningfulScript)}},{key:"inputHasPubkey",value:function(e,t){return function(e,t,n,r){return BV(e,bV(mV(n,t,r),n,"input",t.redeemScript,t.witnessScript).meaningfulScript)}(t,(0,Uq.checkForInput)(this.data.inputs,e),e,this.__CACHE)}},{key:"inputHasHDKey",value:function(e,t){var n=(0,Uq.checkForInput)(this.data.inputs,e),r=nV(t);return!!n.bip32Derivation&&n.bip32Derivation.some(r)}},{key:"outputHasPubkey",value:function(e,t){return function(e,t,n,r){return BV(e,bV(r.__TX.outs[n].script,n,"output",t.redeemScript,t.witnessScript).meaningfulScript)}(t,(0,Uq.checkForOutput)(this.data.outputs,e),e,this.__CACHE)}},{key:"outputHasHDKey",value:function(e,t){var n=(0,Uq.checkForOutput)(this.data.outputs,e),r=nV(t);return!!n.bip32Derivation&&n.bip32Derivation.some(r)}},{key:"validateSignaturesOfAllInputs",value:function(e){var t=this;return(0,Uq.checkForInput)(this.data.inputs,0),CV(this.data.inputs.length).map((function(n){return t.validateSignaturesOfInput(n,e)})).reduce((function(e,t){return!0===t&&e}),!0)}},{key:"validateSignaturesOfInput",value:function(e,t,n){var r=this.data.inputs[e],i=(r||{}).partialSig;if(!r||!i||i.length<1)throw new Error("No signatures to validate");if("function"!=typeof t)throw new Error("Need validator function to validate signatures");var o=n?i.filter((function(e){return e.pubkey.equals(n)})):i;if(o.length<1)throw new Error("No signatures for this pubkey");var a,s,u,l,A=[],c=F(o);try{for(c.s();!(l=c.n()).done;){var h=l.value,f=Oq.signature.decode(h.signature),d=u!==f.hashType?fV(e,Object.assign({},r,{sighashType:f.hashType}),this.__CACHE,!0):{hash:a,script:s},p=d.hash,g=d.script;u=f.hashType,a=p,s=g,oV(h.pubkey,g,"verify"),A.push(t(h.pubkey,p,f.signature))}}catch(e){c.e(e)}finally{c.f()}return A.every((function(e){return!0===e}))}},{key:"signAllInputsHD",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[Hq.Transaction.SIGHASH_ALL];if(!e||!e.publicKey||!e.fingerprint)throw new Error("Need HDSigner to sign input");var n,r=[],i=F(CV(this.data.inputs.length));try{for(i.s();!(n=i.n()).done;){var o=n.value;try{this.signInputHD(o,e,t),r.push(!0)}catch(e){r.push(!1)}}}catch(e){i.e(e)}finally{i.f()}if(r.every((function(e){return!1===e})))throw new Error("No inputs were signed");return this}},{key:"signAllInputsHDAsync",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[Hq.Transaction.SIGHASH_ALL];return new Promise((function(r,i){if(!e||!e.publicKey||!e.fingerprint)return i(new Error("Need HDSigner to sign input"));var o,a=[],s=[],u=F(CV(t.data.inputs.length));try{for(u.s();!(o=u.n()).done;){var l=o.value;s.push(t.signInputHDAsync(l,e,n).then((function(){a.push(!0)}),(function(){a.push(!1)})))}}catch(e){u.e(e)}finally{u.f()}return Promise.all(s).then((function(){if(a.every((function(e){return!1===e})))return i(new Error("No inputs were signed"));r()}))}))}},{key:"signInputHD",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[Hq.Transaction.SIGHASH_ALL];if(!t||!t.publicKey||!t.fingerprint)throw new Error("Need HDSigner to sign input");return dV(e,this.data.inputs,t).forEach((function(t){return n.signInput(e,t,r)})),this}},{key:"signInputHDAsync",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[Hq.Transaction.SIGHASH_ALL];return new Promise((function(i,o){if(!t||!t.publicKey||!t.fingerprint)return o(new Error("Need HDSigner to sign input"));var a=dV(e,n.data.inputs,t).map((function(t){return n.signInputAsync(e,t,r)}));return Promise.all(a).then((function(){i()})).catch(o)}))}},{key:"signAllInputs",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[Hq.Transaction.SIGHASH_ALL];if(!e||!e.publicKey)throw new Error("Need Signer to sign input");var n,r=[],i=F(CV(this.data.inputs.length));try{for(i.s();!(n=i.n()).done;){var o=n.value;try{this.signInput(o,e,t),r.push(!0)}catch(e){r.push(!1)}}}catch(e){i.e(e)}finally{i.f()}if(r.every((function(e){return!1===e})))throw new Error("No inputs were signed");return this}},{key:"signAllInputsAsync",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[Hq.Transaction.SIGHASH_ALL];return new Promise((function(r,i){if(!e||!e.publicKey)return i(new Error("Need Signer to sign input"));var o,a=[],s=[],u=F(t.data.inputs.entries());try{for(u.s();!(o=u.n()).done;){var l=C(o.value,1)[0];s.push(t.signInputAsync(l,e,n).then((function(){a.push(!0)}),(function(){a.push(!1)})))}}catch(e){u.e(e)}finally{u.f()}return Promise.all(s).then((function(){if(a.every((function(e){return!1===e})))return i(new Error("No inputs were signed"));r()}))}))}},{key:"signInput",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[Hq.Transaction.SIGHASH_ALL];if(!t||!t.publicKey)throw new Error("Need Signer to sign input");var r=hV(this.data.inputs,e,t.publicKey,this.__CACHE,n),i=r.hash,o=r.sighashType,a=[{pubkey:t.publicKey,signature:Oq.signature.encode(t.sign(i),o)}];return this.data.updateInput(e,{partialSig:a}),this}},{key:"signInputAsync",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[Hq.Transaction.SIGHASH_ALL];return Promise.resolve().then((function(){if(!t||!t.publicKey)throw new Error("Need Signer to sign input");var i=hV(n.data.inputs,e,t.publicKey,n.__CACHE,r),o=i.hash,a=i.sighashType;return Promise.resolve(t.sign(o)).then((function(r){var i=[{pubkey:t.publicKey,signature:Oq.signature.encode(r,a)}];n.data.updateInput(e,{partialSig:i})}))}))}},{key:"toBuffer",value:function(){return Vq(this.__CACHE),this.data.toBuffer()}},{key:"toHex",value:function(){return Vq(this.__CACHE),this.data.toHex()}},{key:"toBase64",value:function(){return Vq(this.__CACHE),this.data.toBase64()}},{key:"updateGlobal",value:function(e){return this.data.updateGlobal(e),this}},{key:"updateInput",value:function(e,t){return t.witnessScript&&IV(t.witnessScript),this.data.updateInput(e,t),t.nonWitnessUtxo&&gV(this.__CACHE,this.data.inputs[e],e),this}},{key:"updateOutput",value:function(e,t){return this.data.updateOutput(e,t),this}},{key:"addUnknownKeyValToGlobal",value:function(e){return this.data.addUnknownKeyValToGlobal(e),this}},{key:"addUnknownKeyValToInput",value:function(e,t){return this.data.addUnknownKeyValToInput(e,t),this}},{key:"addUnknownKeyValToOutput",value:function(e,t){return this.data.addUnknownKeyValToOutput(e,t),this}},{key:"clearFinalizedInput",value:function(e){return this.data.clearFinalizedInput(e),this}}],[{key:"fromBase64",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=Yo.from(e,"base64");return this.fromBuffer(n,t)}},{key:"fromHex",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=Yo.from(e,"hex");return this.fromBuffer(n,t)}},{key:"fromBuffer",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=Fq.Psbt.fromBuffer(t,Gq),i=new e(n,r);return function(e,t){e.ins.forEach((function(e){aV(t,e)}))}(i.__CACHE.__TX,i.__CACHE),i}}]),e}();Hj.Psbt=jq;var Gq=function(e){return new qq(e)},qq=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Yo.from([2,0,0,0,0,0,0,0,0,0]);s(this,e),this.tx=Hq.Transaction.fromBuffer(t),function(e){if(!e.ins.every((function(e){return 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})}return l(e,[{key:"getInputOutputCounts",value:function(){return{inputCount:this.tx.ins.length,outputCount:this.tx.outs.length}}},{key:"addInput",value:function(e){if(void 0===e.hash||void 0===e.index||!Na(e.hash)&&"string"!=typeof e.hash||"number"!=typeof e.index)throw new Error("Error adding input.");var t="string"==typeof e.hash?(0,Mq.reverseBuffer)(Yo.from(e.hash,"hex")):e.hash;this.tx.addInput(t,e.index,e.sequence)}},{key:"addOutput",value:function(e){if(void 0===e.script||void 0===e.value||!Na(e.script)||"number"!=typeof e.value)throw new Error("Error adding output.");this.tx.addOutput(e.script,e.value)}},{key:"toBuffer",value:function(){return this.tx.toBuffer()}}]),e}();function Vq(e){if(!1!==e.__UNSAFE_SIGN_NONSEGWIT)throw new Error("Not BIP174 compliant, can not export")}function zq(e,t,n){if(!t)return!1;var r;if(r=n?n.map((function(e){var n=function(e){if(65===e.length){var t=1&e[64],n=e.slice(0,33);return n[0]=2|t,n}return e.slice()}(e);return t.find((function(e){return e.pubkey.equals(n)}))})).filter((function(e){return!!e})):t,r.length>e)throw new Error("Too many signatures");return r.length===e}function Jq(e){return!!e.finalScriptSig||!!e.finalScriptWitness}function Yq(e){return function(t){try{return e({output:t}),!0}catch(e){return!1}}}var Xq=Yq(Rq.p2ms),Wq=Yq(Rq.p2pk),Zq=Yq(Rq.p2pkh),$q=Yq(Rq.p2wpkh),eV=Yq(Rq.p2wsh),tV=Yq(Rq.p2sh);function nV(e){return function(t){return!!t.masterFingerprint.equals(e.fingerprint)&&!!e.derivePath(t.path).publicKey.equals(t.pubkey)}}function rV(e){if("number"!=typeof e||e!==Math.floor(e)||e>4294967295||e<0)throw new Error("Invalid 32 bit integer")}function iV(e,t){e.forEach((function(e){var n=!1,r=[];if(0===(e.partialSig||[]).length){if(!e.finalScriptSig&&!e.finalScriptWitness)return;r=function(e){var t=e.finalScriptSig&&Oq.decompile(e.finalScriptSig)||[],n=e.finalScriptWitness&&Oq.decompile(e.finalScriptWitness)||[];return t.concat(n).filter((function(e){return Na(e)&&Oq.isCanonicalScriptSignature(e)})).map((function(e){return{signature:e}}))}(e)}else r=e.partialSig;if(r.forEach((function(e){var r=Oq.signature.decode(e.signature).hashType,i=[];switch(r&Hq.Transaction.SIGHASH_ANYONECANPAY&&i.push("addInput"),31&r){case Hq.Transaction.SIGHASH_ALL:break;case Hq.Transaction.SIGHASH_SINGLE:case Hq.Transaction.SIGHASH_NONE:i.push("addOutput"),i.push("setInputSequence")}-1===i.indexOf(t)&&(n=!0)})),n)throw new Error("Can not modify transaction, signatures exist.")}))}function oV(e,t,n){if(!BV(e,t))throw new Error("Can not ".concat(n," for this input with the key ").concat(e.toString("hex")))}function aV(e,t){var n=(0,Mq.reverseBuffer)(Yo.from(t.hash)).toString("hex")+":"+t.index;if(e.__TX_IN_CACHE[n])throw new Error("Duplicate input detected.");e.__TX_IN_CACHE[n]=1}function sV(e,t){return function(n,r,i,o){var a=e({redeem:{output:i}}).output;if(!r.equals(a))throw new Error("".concat(t," for ").concat(o," #").concat(n," doesn't match the scriptPubKey in the prevout"))}}var uV=sV(Rq.p2sh,"Redeem script"),lV=sV(Rq.p2wsh,"Witness script");function AV(e,t,n,r){if(!n.every(Jq))throw new Error("PSBT must be finalized to calculate ".concat(t));if("__FEE_RATE"===e&&r.__FEE_RATE)return r.__FEE_RATE;if("__FEE"===e&&r.__FEE)return r.__FEE;var i,o=!0;return r.__EXTRACTED_TX?(i=r.__EXTRACTED_TX,o=!1):i=r.__TX.clone(),vV(n,i,r,o),"__FEE_RATE"===e?r.__FEE_RATE:"__FEE"===e?r.__FEE:void 0}function cV(e,t,n,r,i,o){var a=EV(n);if(!function(e,t,n){switch(n){case"pubkey":case"pubkeyhash":case"witnesspubkeyhash":return zq(1,e.partialSig);case"multisig":var r=Rq.p2ms({output:t});return zq(r.m,e.partialSig,r.pubkeys);default:return!1}}(t,n,a))throw new Error("Can not finalize input #".concat(e));return function(e,t,n,r,i,o){var a,s,u=function(e,t,n){var r;switch(t){case"multisig":var i=function(e,t){return Rq.p2ms({output:e}).pubkeys.map((function(e){return(t.filter((function(t){return t.pubkey.equals(e)}))[0]||{}).signature})).filter((function(e){return!!e}))}(e,n);r=Rq.p2ms({output:e,signatures:i});break;case"pubkey":r=Rq.p2pk({output:e,signature:n[0].signature});break;case"pubkeyhash":r=Rq.p2pkh({output:e,pubkey:n[0].pubkey,signature:n[0].signature});break;case"witnesspubkeyhash":r=Rq.p2wpkh({output:e,pubkey:n[0].pubkey,signature:n[0].signature})}return r}(e,t,n),l=o?Rq.p2wsh({redeem:u}):null,A=i?Rq.p2sh({redeem:l||u}):null;return r?(s=function(e){var t,n=Yo.allocUnsafe(0);function r(e){var t=n.length,r=Pq.encodingLength(e);n=Yo.concat([n,Yo.allocUnsafe(r)]),Pq.encode(e,n,t)}function i(e){r(e.length),function(e){n=Yo.concat([n,Yo.from(e)])}(e)}return r((t=e).length),t.forEach(i),n}(l?l.witness:u.witness),A&&(a=A.input)):a=A?A.input:u.input,{finalScriptSig:a,finalScriptWitness:s}}(n,a,t.partialSig,r,i,o)}function hV(e,t,n,r,i){var o=fV(t,(0,Uq.checkForInput)(e,t),r,!1,i),a=o.hash,s=o.sighashType;return oV(n,o.script,"sign"),{hash:a,sighashType:s}}function fV(e,t,n,r,i){var o,a,s=n.__TX,u=t.sighashType||Hq.Transaction.SIGHASH_ALL;if(i&&i.indexOf(u)<0){var l=function(e){var t=e&Hq.Transaction.SIGHASH_ANYONECANPAY?"SIGHASH_ANYONECANPAY | ":"";switch(31&e){case Hq.Transaction.SIGHASH_ALL:t+="SIGHASH_ALL";break;case Hq.Transaction.SIGHASH_SINGLE:t+="SIGHASH_SINGLE";break;case Hq.Transaction.SIGHASH_NONE:t+="SIGHASH_NONE"}return t}(u);throw new Error("Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ".concat(l))}if(t.nonWitnessUtxo){var A=yV(n,t,e),c=s.ins[e].hash,h=A.getHash();if(!c.equals(h))throw new Error("Non-witness UTXO hash for input #".concat(e," doesn't match the hash specified in the prevout"));var f=s.ins[e].index;a=A.outs[f]}else{if(!t.witnessUtxo)throw new Error("Need a Utxo input item for signing");a=t.witnessUtxo}var d=bV(a.script,e,"input",t.redeemScript,t.witnessScript),p=d.meaningfulScript,g=d.type;if(["p2sh-p2wsh","p2wsh"].indexOf(g)>=0)o=s.hashForWitnessV0(e,p,a.value,u);else if($q(p)){var v=Rq.p2pkh({hash:p.slice(2)}).output;o=s.hashForWitnessV0(e,v,a.value,u)}else{if(void 0===t.nonWitnessUtxo&&!1===n.__UNSAFE_SIGN_NONSEGWIT)throw new Error("Input #".concat(e," has witnessUtxo but non-segwit script: ").concat(p.toString("hex")));r||!1===n.__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*********************"),o=s.hashForSignature(e,p,u)}return{script:p,sighashType:u,hash:o}}function dV(e,t,n){var r=(0,Uq.checkForInput)(t,e);if(!r.bip32Derivation||0===r.bip32Derivation.length)throw new Error("Need bip32Derivation to sign with HD");var i=r.bip32Derivation.map((function(e){return e.masterFingerprint.equals(n.fingerprint)?e:void 0})).filter((function(e){return!!e}));if(0===i.length)throw new Error("Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint");var o=i.map((function(e){var t=n.derivePath(e.path);if(!e.pubkey.equals(t.publicKey))throw new Error("pubkey did not match bip32Derivation");return t}));return o}function pV(e){var t=0;function n(){var n=Pq.decode(e,t);return t+=Pq.decode.bytes,n}function r(){return r=n(),t+=r,e.slice(t-r,t);var r}return function(){for(var e=n(),t=[],i=0;i<e;i++)t.push(r());return t}()}function gV(e,t,n){e.__NON_WITNESS_UTXO_BUF_CACHE[n]=t.nonWitnessUtxo;var r=Hq.Transaction.fromBuffer(t.nonWitnessUtxo);e.__NON_WITNESS_UTXO_TX_CACHE[n]=r;var i=e,o=n;delete t.nonWitnessUtxo,Object.defineProperty(t,"nonWitnessUtxo",{enumerable:!0,get:function(){var e=i.__NON_WITNESS_UTXO_BUF_CACHE[o],t=i.__NON_WITNESS_UTXO_TX_CACHE[o];if(void 0!==e)return e;var n=t.toBuffer();return i.__NON_WITNESS_UTXO_BUF_CACHE[o]=n,n},set:function(e){i.__NON_WITNESS_UTXO_BUF_CACHE[o]=e}})}function vV(e,t,n,r){var i=0;e.forEach((function(e,o){if(r&&e.finalScriptSig&&(t.ins[o].script=e.finalScriptSig),r&&e.finalScriptWitness&&(t.ins[o].witness=pV(e.finalScriptWitness)),e.witnessUtxo)i+=e.witnessUtxo.value;else if(e.nonWitnessUtxo){var a=yV(n,e,o),s=t.ins[o].index,u=a.outs[s];i+=u.value}}));var o=t.outs.reduce((function(e,t){return e+t.value}),0),a=i-o;if(a<0)throw new Error("Outputs are spending more than Inputs");var s=t.virtualSize();n.__FEE=a,n.__EXTRACTED_TX=t,n.__FEE_RATE=Math.floor(a/s)}function yV(e,t,n){var r=e.__NON_WITNESS_UTXO_TX_CACHE;return r[n]||gV(e,t,n),r[n]}function mV(e,t,n){if(void 0!==t.witnessUtxo)return t.witnessUtxo.script;if(void 0!==t.nonWitnessUtxo)return yV(n,t,e).outs[n.__TX.ins[e].index].script;throw new Error("Can't find pubkey in input without Utxo data")}function wV(e){return 33===e.length&&Oq.isCanonicalPubKey(e)}function bV(e,t,n,r,i){var o,a=tV(e),s=a&&r&&eV(r),u=eV(e);if(a&&void 0===r)throw new Error("scriptPubkey is P2SH but redeemScript missing");if((u||s)&&void 0===i)throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");return s?(o=i,uV(t,e,r,n),lV(t,r,i,n),IV(o)):u?(o=i,lV(t,e,i,n),IV(o)):a?(o=r,uV(t,e,r,n)):o=e,{meaningfulScript:o,type:s?"p2sh-p2wsh":a?"p2sh":u?"p2wsh":"raw"}}function IV(e){if($q(e)||tV(e))throw new Error("P2WPKH or P2SH can not be contained within P2WSH")}function BV(e,t){var n=(0,Tq.hash160)(e),r=Oq.decompile(t);if(null===r)throw new Error("Unknown script error");return r.some((function(t){return"number"!=typeof t&&(t.equals(e)||t.equals(n))}))}function EV(e){return $q(e)?"witnesspubkeyhash":Zq(e)?"pubkeyhash":Xq(e)?"multisig":Wq(e)?"pubkey":"nonstandard"}function CV(e){return k(Array(e).keys())}!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Transaction=e.opcodes=e.Psbt=e.Block=e.script=e.payments=e.networks=e.crypto=e.address=void 0;var t=BU;e.address=t;var n=WL;e.crypto=n;var r=EU;e.networks=r;var i=CU;e.payments=i;var o=kU;e.script=o;var a=nj;Object.defineProperty(e,"Block",{enumerable:!0,get:function(){return a.Block}});var s=Hj;Object.defineProperty(e,"Psbt",{enumerable:!0,get:function(){return s.Psbt}});var u=QU;Object.defineProperty(e,"opcodes",{enumerable:!0,get:function(){return u.OPS}});var l=gj;Object.defineProperty(e,"Transaction",{enumerable:!0,get:function(){return l.Transaction}})}(IU);var xV={exports:{}};function kV(e,t){var n=function(e){for(var t=function(e){var t=mU.from(Object.assign(Object.assign({},e),{crv:"K-256"}),"jwk").toString("blk","public"),n=hx.publicKeyConvert(bU.from(t,"hex"),!0);return bU.from(n).toString("hex")}(e),n=bU.from(t,"hex"),r=32-n.length;r>0;)n=bU.concat([bU.from("00","hex"),n]),r--;return n}(e.publicKeyJwk),r=bF("errors","identityErrorBaseMessage"),i="";switch(t.code){case Dl.Bitcoin:case Dl.Mocknet:case Dl.Testnet:i=function(e,t){return IU.payments.p2pkh({pubkey:e,network:IU.networks[t.code]}).address}(n,t);break;case Dl.Ethmain:case Dl.Ethropst:case Dl.Ethrinkeby:case Dl.Ethgoerli:case Dl.Ethsepolia:i=function(e,t){var n=e.toString("hex"),r=new BI.ec("secp256k1").keyFromPublic(n,"hex").getPublic().encode("hex").slice(2),i=Yo;return"0x".concat(xV.exports.keccak256(i.from(r,"hex")).slice(24).toString())}(n);break;default:throw new yF("deriveIssuingAddressFromPublicKey","".concat(r," - ").concat(bF("errors","deriveIssuingAddressFromPublicKey")))}return i}function SV(e){if(e){var t="string"==typeof e?e:e.code;return!!Object.keys(Ul).some((function(e){return e===t}))&&!!Ul[t].test}return!1}!function(e){!function(){var t="input is invalid type",n="object"==("undefined"==typeof window?"undefined":i(window)),r=n?window:{};r.JS_SHA3_NO_WINDOW&&(n=!1);var o=!n&&"object"==("undefined"==typeof self?"undefined":i(self));!r.JS_SHA3_NO_NODE_JS&&"object"==i(lA)&&lA.versions&&lA.versions.node?r=No:o&&(r=self);var a=!r.JS_SHA3_NO_COMMON_JS&&e.exports,s=!r.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,u="0123456789abcdef".split(""),l=[4,1024,262144,67108864],A=[0,8,16,24],c=[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],h=[224,256,384,512],f=[128,256],d=["hex","buffer","arrayBuffer","array","digest"],p={128:168,256:136};!r.JS_SHA3_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!s||!r.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"==i(e)&&e.buffer&&e.buffer.constructor===ArrayBuffer});for(var g=function(e,t,n){return function(r){return new N(e,t,e).update(r)[n]()}},v=function(e,t,n){return function(r,i){return new N(e,t,i).update(r)[n]()}},y=function(e,t,n){return function(t,r,i,o){return B["cshake"+e].update(t,r,i,o)[n]()}},m=function(e,t,n){return function(t,r,i,o){return B["kmac"+e].update(t,r,i,o)[n]()}},w=function(e,t,n,r){for(var i=0;i<d.length;++i){var o=d[i];e[o]=t(n,r,o)}return e},b=function(e,t){var n=g(e,t,"hex");return n.create=function(){return new N(e,t,e)},n.update=function(e){return n.create().update(e)},w(n,g,e,t)},I=[{name:"keccak",padding:[1,256,65536,16777216],bits:h,createMethod:b},{name:"sha3",padding:[6,1536,393216,100663296],bits:h,createMethod:b},{name:"shake",padding:[31,7936,2031616,520093696],bits:f,createMethod:function(e,t){var n=v(e,t,"hex");return n.create=function(n){return new N(e,t,n)},n.update=function(e,t){return n.create(t).update(e)},w(n,v,e,t)}},{name:"cshake",padding:l,bits:f,createMethod:function(e,t){var n=p[e],r=y(e,0,"hex");return r.create=function(r,i,o){return i||o?new N(e,t,r).bytepad([i,o],n):B["shake"+e].create(r)},r.update=function(e,t,n,i){return r.create(t,n,i).update(e)},w(r,y,e,t)}},{name:"kmac",padding:l,bits:f,createMethod:function(e,t){var n=p[e],r=m(e,0,"hex");return r.create=function(r,i,o){return new D(e,t,i).bytepad(["KMAC",o],n).bytepad([r],n)},r.update=function(e,t,n,i){return r.create(e,n,i).update(t)},w(r,m,e,t)}}],B={},E=[],C=0;C<I.length;++C)for(var x=I[C],k=x.bits,S=0;S<k.length;++S){var Q=x.name+"_"+k[S];if(E.push(Q),B[Q]=x.createMethod(k[S],x.padding),"sha3"!==x.name){var _=x.name+k[S];E.push(_),B[_]=B[Q]}}function N(e,t,n){this.blocks=[],this.s=[],this.padding=t,this.outputBits=n,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=n>>5,this.extraBytes=(31&n)>>3;for(var r=0;r<50;++r)this.s[r]=0}function D(e,t,n){N.call(this,e,t,n)}N.prototype.update=function(e){if(this.finalized)throw new Error("finalize already called");var n,r=i(e);if("string"!==r){if("object"!==r)throw new Error(t);if(null===e)throw new Error(t);if(s&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||s&&ArrayBuffer.isView(e)))throw new Error(t);n=!0}for(var o,a,u=this.blocks,l=this.byteCount,c=e.length,h=this.blockCount,f=0,d=this.s;f<c;){if(this.reset)for(this.reset=!1,u[0]=this.block,o=1;o<h+1;++o)u[o]=0;if(n)for(o=this.start;f<c&&o<l;++f)u[o>>2]|=e[f]<<A[3&o++];else for(o=this.start;f<c&&o<l;++f)(a=e.charCodeAt(f))<128?u[o>>2]|=a<<A[3&o++]:a<2048?(u[o>>2]|=(192|a>>6)<<A[3&o++],u[o>>2]|=(128|63&a)<<A[3&o++]):a<55296||a>=57344?(u[o>>2]|=(224|a>>12)<<A[3&o++],u[o>>2]|=(128|a>>6&63)<<A[3&o++],u[o>>2]|=(128|63&a)<<A[3&o++]):(a=65536+((1023&a)<<10|1023&e.charCodeAt(++f)),u[o>>2]|=(240|a>>18)<<A[3&o++],u[o>>2]|=(128|a>>12&63)<<A[3&o++],u[o>>2]|=(128|a>>6&63)<<A[3&o++],u[o>>2]|=(128|63&a)<<A[3&o++]);if(this.lastByteIndex=o,o>=l){for(this.start=o-l,this.block=u[h],o=0;o<h;++o)d[o]^=u[o];F(d),this.reset=!0}else this.start=o}return this},N.prototype.encode=function(e,t){var n=255&e,r=1,i=[n];for(n=255&(e>>=8);n>0;)i.unshift(n),n=255&(e>>=8),++r;return t?i.push(r):i.unshift(r),this.update(i),i.length},N.prototype.encodeString=function(e){var n,r=i(e);if("string"!==r){if("object"!==r)throw new Error(t);if(null===e)throw new Error(t);if(s&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||s&&ArrayBuffer.isView(e)))throw new Error(t);n=!0}var o=0,a=e.length;if(n)o=a;else for(var u=0;u<e.length;++u){var l=e.charCodeAt(u);l<128?o+=1:l<2048?o+=2:l<55296||l>=57344?o+=3:(l=65536+((1023&l)<<10|1023&e.charCodeAt(++u)),o+=4)}return o+=this.encode(8*o),this.update(e),o},N.prototype.bytepad=function(e,t){for(var n=this.encode(t),r=0;r<e.length;++r)n+=this.encodeString(e[r]);var i=t-n%t,o=[];return o.length=i,this.update(o),this},N.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex,n=this.blockCount,r=this.s;if(e[t>>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[n],t=1;t<n+1;++t)e[t]=0;for(e[n-1]|=2147483648,t=0;t<n;++t)r[t]^=e[t];F(r)}},N.prototype.toString=N.prototype.hex=function(){this.finalize();for(var e,t=this.blockCount,n=this.s,r=this.outputBlocks,i=this.extraBytes,o=0,a=0,s="";a<r;){for(o=0;o<t&&a<r;++o,++a)e=n[o],s+=u[e>>4&15]+u[15&e]+u[e>>12&15]+u[e>>8&15]+u[e>>20&15]+u[e>>16&15]+u[e>>28&15]+u[e>>24&15];a%t==0&&(F(n),o=0)}return i&&(e=n[o],s+=u[e>>4&15]+u[15&e],i>1&&(s+=u[e>>12&15]+u[e>>8&15]),i>2&&(s+=u[e>>20&15]+u[e>>16&15])),s},N.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,n=this.s,r=this.outputBlocks,i=this.extraBytes,o=0,a=0,s=this.outputBits>>3;e=i?new ArrayBuffer(r+1<<2):new ArrayBuffer(s);for(var u=new Uint32Array(e);a<r;){for(o=0;o<t&&a<r;++o,++a)u[a]=n[o];a%t==0&&F(n)}return i&&(u[o]=n[o],e=e.slice(0,s)),e},N.prototype.buffer=N.prototype.arrayBuffer,N.prototype.digest=N.prototype.array=function(){this.finalize();for(var e,t,n=this.blockCount,r=this.s,i=this.outputBlocks,o=this.extraBytes,a=0,s=0,u=[];s<i;){for(a=0;a<n&&s<i;++a,++s)e=s<<2,t=r[a],u[e]=255&t,u[e+1]=t>>8&255,u[e+2]=t>>16&255,u[e+3]=t>>24&255;s%n==0&&F(r)}return o&&(e=s<<2,t=r[a],u[e]=255&t,o>1&&(u[e+1]=t>>8&255),o>2&&(u[e+2]=t>>16&255)),u},D.prototype=new N,D.prototype.finalize=function(){return this.encode(this.outputBits,!0),N.prototype.finalize.call(this)};var F=function(e){var t,n,r,i,o,a,s,u,l,A,h,f,d,p,g,v,y,m,w,b,I,B,E,C,x,k,S,Q,_,N,D,F,P,U,L,M,T,R,O,H,K,j,G,q,V,z,J,Y,X,W,Z,$,ee,te,ne,re,ie,oe,ae,se,ue,le,Ae;for(r=0;r<48;r+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],a=e[2]^e[12]^e[22]^e[32]^e[42],s=e[3]^e[13]^e[23]^e[33]^e[43],u=e[4]^e[14]^e[24]^e[34]^e[44],l=e[5]^e[15]^e[25]^e[35]^e[45],A=e[6]^e[16]^e[26]^e[36]^e[46],h=e[7]^e[17]^e[27]^e[37]^e[47],t=(f=e[8]^e[18]^e[28]^e[38]^e[48])^(a<<1|s>>>31),n=(d=e[9]^e[19]^e[29]^e[39]^e[49])^(s<<1|a>>>31),e[0]^=t,e[1]^=n,e[10]^=t,e[11]^=n,e[20]^=t,e[21]^=n,e[30]^=t,e[31]^=n,e[40]^=t,e[41]^=n,t=i^(u<<1|l>>>31),n=o^(l<<1|u>>>31),e[2]^=t,e[3]^=n,e[12]^=t,e[13]^=n,e[22]^=t,e[23]^=n,e[32]^=t,e[33]^=n,e[42]^=t,e[43]^=n,t=a^(A<<1|h>>>31),n=s^(h<<1|A>>>31),e[4]^=t,e[5]^=n,e[14]^=t,e[15]^=n,e[24]^=t,e[25]^=n,e[34]^=t,e[35]^=n,e[44]^=t,e[45]^=n,t=u^(f<<1|d>>>31),n=l^(d<<1|f>>>31),e[6]^=t,e[7]^=n,e[16]^=t,e[17]^=n,e[26]^=t,e[27]^=n,e[36]^=t,e[37]^=n,e[46]^=t,e[47]^=n,t=A^(i<<1|o>>>31),n=h^(o<<1|i>>>31),e[8]^=t,e[9]^=n,e[18]^=t,e[19]^=n,e[28]^=t,e[29]^=n,e[38]^=t,e[39]^=n,e[48]^=t,e[49]^=n,p=e[0],g=e[1],z=e[11]<<4|e[10]>>>28,J=e[10]<<4|e[11]>>>28,Q=e[20]<<3|e[21]>>>29,_=e[21]<<3|e[20]>>>29,se=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,j=e[40]<<18|e[41]>>>14,G=e[41]<<18|e[40]>>>14,U=e[2]<<1|e[3]>>>31,L=e[3]<<1|e[2]>>>31,v=e[13]<<12|e[12]>>>20,y=e[12]<<12|e[13]>>>20,Y=e[22]<<10|e[23]>>>22,X=e[23]<<10|e[22]>>>22,N=e[33]<<13|e[32]>>>19,D=e[32]<<13|e[33]>>>19,le=e[42]<<2|e[43]>>>30,Ae=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,ne=e[4]<<30|e[5]>>>2,M=e[14]<<6|e[15]>>>26,T=e[15]<<6|e[14]>>>26,m=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,W=e[34]<<15|e[35]>>>17,Z=e[35]<<15|e[34]>>>17,F=e[45]<<29|e[44]>>>3,P=e[44]<<29|e[45]>>>3,C=e[6]<<28|e[7]>>>4,x=e[7]<<28|e[6]>>>4,re=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,R=e[26]<<25|e[27]>>>7,O=e[27]<<25|e[26]>>>7,b=e[36]<<21|e[37]>>>11,I=e[37]<<21|e[36]>>>11,$=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,q=e[8]<<27|e[9]>>>5,V=e[9]<<27|e[8]>>>5,k=e[18]<<20|e[19]>>>12,S=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,ae=e[28]<<7|e[29]>>>25,H=e[38]<<8|e[39]>>>24,K=e[39]<<8|e[38]>>>24,B=e[48]<<14|e[49]>>>18,E=e[49]<<14|e[48]>>>18,e[0]=p^~v&m,e[1]=g^~y&w,e[10]=C^~k&Q,e[11]=x^~S&_,e[20]=U^~M&R,e[21]=L^~T&O,e[30]=q^~z&Y,e[31]=V^~J&X,e[40]=te^~re&oe,e[41]=ne^~ie&ae,e[2]=v^~m&b,e[3]=y^~w&I,e[12]=k^~Q&N,e[13]=S^~_&D,e[22]=M^~R&H,e[23]=T^~O&K,e[32]=z^~Y&W,e[33]=J^~X&Z,e[42]=re^~oe&se,e[43]=ie^~ae&ue,e[4]=m^~b&B,e[5]=w^~I&E,e[14]=Q^~N&F,e[15]=_^~D&P,e[24]=R^~H&j,e[25]=O^~K&G,e[34]=Y^~W&$,e[35]=X^~Z&ee,e[44]=oe^~se&le,e[45]=ae^~ue&Ae,e[6]=b^~B&p,e[7]=I^~E&g,e[16]=N^~F&C,e[17]=D^~P&x,e[26]=H^~j&U,e[27]=K^~G&L,e[36]=W^~$&q,e[37]=Z^~ee&V,e[46]=se^~le&te,e[47]=ue^~Ae&ne,e[8]=B^~p&v,e[9]=E^~g&y,e[18]=F^~C&k,e[19]=P^~x&S,e[28]=j^~U&M,e[29]=G^~L&T,e[38]=$^~q&z,e[39]=ee^~V&J,e[48]=le^~te&re,e[49]=Ae^~ne&ie,e[0]^=c[r],e[1]^=c[r+1]};if(a)e.exports=B;else for(C=0;C<E.length;++C)r[E[C]]=B[E[C]]}()}(xV);var QV,_V,NV=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){e.done?i(e.value):function(e){return e instanceof n?e:new n((function(t){t(e)}))}(e.value).then(a,s)}u((r=r.apply(e,t||[])).next())}))},DV=function(e){c(n,e);var t=b(n);function n(e){var r,i=e.issuer,o=void 0===i?null:i,a=e.verificationMethod,u=void 0===a?null:a,l=e.document,A=void 0===l?null:l,c=e.proof,h=void 0===c?null:c,f=e.options,d=void 0===f?{}:f;if(s(this,n),(r=t.call(this,{type:"MerkleProof2019"})).type="MerkleProof2019",r.issuer=null,r.verificationMethod=null,r.proof=null,r.proofValue=null,r.document=null,r.explorerAPIs=[],r.documentLoader=null,r.proofVerificationProcess=["getTransactionId","computeLocalHash","fetchRemoteHash","compareHashes","checkMerkleRoot","checkReceipt"],r.identityVerificationProcess=["deriveIssuingAddressFromPublicKey","compareIssuingAddress"],r.transactionId="",!A)throw new Error("A document signed by MerkleProof2019 is required for the verification process.");return r.issuer=o,r.verificationMethod=u,r.document=A,r.setProof(h),r.setOptions(d),r.getChain(),w(r)}return l(n,[{key:"setProof",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=null!=e?e:this.document.proof;if(!t)throw new Error("The passed document is not signed.");this.proof=t,this.proofValue=n.decodeMerkleProof2019(this.proof)}},{key:"verifyProof",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{documentLoader:function(e){},verifyIdentity:!0},t=e.documentLoader,n=e.verifyIdentity;return NV(this,void 0,void 0,r().mark((function e(){var i,o;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.documentLoader=t,o="",SV(this.chain)&&(this.adaptProofVerificationProcessToMocknet(),this.adaptIdentityVerificationProcessToMocknet()),e.prev=3,e.next=6,this.verifyProcess(this.proofVerificationProcess);case 6:if(e.t0=n,!e.t0){e.next=10;break}return e.next=10,this.verifyIdentity();case 10:i=!0,e.next=16;break;case 13:e.prev=13,e.t1=e.catch(3),console.error(e.t1),i=!1,o=e.t1.message;case 16:return e.abrupt("return",{verificationMethod:this.verificationMethod,verified:i,error:o});case 17:case"end":return e.stop()}}),e,this,[[3,13]])})))}},{key:"verifyIdentity",value:function(){return NV(this,void 0,void 0,r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==this.verificationMethod){e.next=9;break}return e.prev=1,e.next=4,this.verifyProcess(this.identityVerificationProcess);case 4:e.next=9;break;case 6:throw e.prev=6,e.t0=e.catch(1),new Error(e.t0);case 9:case"end":return e.stop()}}),e,this,[[1,6]])})))}},{key:"getProofVerificationProcess",value:function(){return this.proofVerificationProcess}},{key:"getIdentityVerificationProcess",value:function(){return this.identityVerificationProcess}},{key:"getIssuerPublicKey",value:function(){var e,t;return SV(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:""}},{key:"getIssuanceTime",value:function(){var e,t;return null!==(t=null===(e=this.getTxData())||void 0===e?void 0:e.time)&&void 0!==t?t:""}},{key:"getChain",value:function(){return this.chain||(this.chain=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(null==e?void 0:e.anchors){var t=e.anchors[0];if("string"==typeof t)return function(e){var t,n=e.split(":");switch(n[1]){case Ul.mocknet.blinkCode:return hF(Ul.mocknet.signatureValue);case Ul.bitcoin.blinkCode:t=Ul.bitcoin.name;break;case Ul.ethmain.blinkCode:t=Ul.ethmain.name;break;default:throw new Error("Could not retrieve chain.")}var r=n[2],i=t.toLowerCase()+function(e){var t=e.substr(0,1),n=e.substr(1,e.length-1);return t.toUpperCase()+n.toLowerCase()}(r);return hF(i)}(t)}return null}(this.proofValue)),this.chain}},{key:"getTxData",value:function(){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)}},{key:"adaptProofVerificationProcessToMocknet",value:function(){fF(this.proofVerificationProcess,"getTransactionId"),fF(this.proofVerificationProcess,"fetchRemoteHash"),fF(this.proofVerificationProcess,"checkMerkleRoot")}},{key:"adaptIdentityVerificationProcessToMocknet",value:function(){this.identityVerificationProcess=[]}},{key:"setOptions",value:function(e){var t;this.explorerAPIs=null!==(t=e.explorerAPIs)&&void 0!==t?t:[],e.executeStepMethod&&"function"==typeof e.executeStepMethod&&(this.executeStep=e.executeStepMethod)}},{key:"executeStep",value:function(e,t){return NV(this,void 0,void 0,r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}},{key:"verifyProcess",value:function(e){return NV(this,void 0,void 0,r().mark((function t(){var n,i,o;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=F(e),t.prev=1,n.s();case 3:if((i=n.n()).done){t.next=11;break}if(this[o=i.value]){t.next=7;break}return t.abrupt("return",void console.error("verification logic for",o,"not implemented"));case 7:return t.next=9,this[o]();case 9:t.next=3;break;case 11:t.next=16;break;case 13:t.prev=13,t.t0=t.catch(1),n.e(t.t0);case 16:return t.prev=16,n.f(),t.finish(16);case 19:case"end":return t.stop()}}),t,this,[[1,13,16,19]])})))}},{key:"checkMerkleRoot",value:function(){return NV(this,void 0,void 0,r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep("checkMerkleRoot",(function(){return function(e,t){if(e!==t)throw new yF("checkMerkleRoot",bF("errors","ensureMerkleRootEqual"));return!0}(t.proofValue.merkleRoot,t.txData.remoteHash)}),this.type);case 2:case"end":return e.stop()}}),e,this)})))}},{key:"compareHashes",value:function(){return NV(this,void 0,void 0,r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep("compareHashes",(function(){return function(e,t){if(e!==t)throw new yF("compareHashes",bF("errors","ensureHashesEqual"));return!0}(t.localDocumentHash,t.proofValue.targetHash)}),this.type);case 2:case"end":return e.stop()}}),e,this)})))}},{key:"computeLocalHash",value:function(){return NV(this,void 0,void 0,r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep("computeLocalHash",(function(){return NV(t,void 0,void 0,r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,BF(this.document,this.proof,this.documentLoader);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}),this.type);case 2:this.localDocumentHash=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}},{key:"checkReceipt",value:function(){return NV(this,void 0,void 0,r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep("checkReceipt",(function(){return function(e){var t=e.targetHash,n=e.merkleRoot;try{var r=e.path;if(r&&t)for(var i in r){var o=r[i],a=void 0;if(void 0!==o.left)a=vF("".concat(o.left).concat(t)),t=vk(a);else{if(void 0===o.right)throw new yF("checkReceipt","Trigger catch error.");a=vF("".concat(t).concat(o.right)),t=vk(a)}}}catch(e){throw new yF("checkReceipt",bF("errors","ensureValidReceipt"))}if(t!==n)throw new yF("checkReceipt",bF("errors","invalidMerkleReceipt"))}(t.proofValue)}),this.type);case 2:case"end":return e.stop()}}),e,this)})))}},{key:"getTransactionId",value:function(){return NV(this,void 0,void 0,r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.transactionId=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(!e)throw new Error("DecodedProof is not set");var t=e.anchors,n=t[0];if("string"==typeof n)return n.split(":").pop();throw new Error("Could not retrieve transaction id as was provided an unexpected format")}(this.proofValue),e.next=3,this.executeStep("getTransactionId",(function(){return function(e){if("string"==typeof e&&e.length>0)return e;throw new yF("getTransactionId",bF("errors","isTransactionIdValid"))}(t.transactionId)}),this.type);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"fetchRemoteHash",value:function(){return NV(this,void 0,void 0,r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep("fetchRemoteHash",(function(){return NV(t,void 0,void 0,r().mark((function e(){var t;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Ff({transactionId:this.transactionId,chain:null===(t=this.chain)||void 0===t?void 0:t.code,explorerAPIs:this.explorerAPIs});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}),this.type);case 2:this.txData=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}},{key:"deriveIssuingAddressFromPublicKey",value:function(){return NV(this,void 0,void 0,r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep("deriveIssuingAddressFromPublicKey",(function(){return kV(t.verificationMethod,t.chain)}),this.type);case 2:this.derivedIssuingAddress=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}},{key:"compareIssuingAddress",value:function(){return NV(this,void 0,void 0,r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep("compareIssuingAddress",(function(){return function(e,t){var n=bF("errors","identityErrorBaseMessage");if(e!==t)throw new yF("compareIssuingAddress","".concat(n," - ").concat(bF("errors","compareIssuingAddress")))}(t.getIssuerPublicKey(),t.derivedIssuingAddress)}),this.type);case 2:case"end":return e.stop()}}),e,this)})))}}],[{key:"decodeMerkleProof2019",value:function(e){return new dD.Decoder(e.proofValue).decode()}}]),n}(uF.suites.LinkedDataProof),FV=l((function e(t){s(this,e)}));function PV(e){return Array.isArray(e)?e.find((function(e){return"ChainedProof2021"!==e.type})).verificationMethod:e.verificationMethod}!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"}(QV||(QV={}));var UV=function(e){c(v,e);var t,n,i,o,u,h,f,d,p,g=b(v);function v(e){var t,n;return s(this,v),A(m(t=g.call(this,e)),"proofVerificationProcess",[QV.parseIssuerKeys,QV.checkAuthenticity]),A(m(t),"transactionId",void 0),A(m(t),"localHash",void 0),A(m(t),"documentToVerify",void 0),A(m(t),"txData",void 0),A(m(t),"chain",void 0),A(m(t),"explorerAPIs",void 0),A(m(t),"receipt",void 0),A(m(t),"issuerPublicKeyList",void 0),A(m(t),"issuer",void 0),A(m(t),"verificationMethodPublicKey",void 0),A(m(t),"derivedIssuingAddress",void 0),A(m(t),"hasDid",void 0),A(m(t),"proof",void 0),A(m(t),"type","MerkleProof2019"),A(m(t),"suite",void 0),t.executeStep=e.executeStep,t.documentToVerify=e.document,t.explorerAPIs=e.explorerAPIs,t.proof=e.proof,t.issuer=e.issuer,t.validateProofType(),t.receipt=(n=t.proof,DV.decodeMerkleProof2019(n)),t.transactionId=ek.certificates.getTransactionId(t.receipt),t.setHasDid(),t}return l(v,[{key:"init",value:(p=a(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.setVerificationSuite();case 2:this.chain=this.suite.getChain(),this.adaptVerificationProcessToChain();case 4:case"end":return e.stop()}}),e,this)}))),function(){return p.apply(this,arguments)})},{key:"verifyProof",value:(d=a(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.suite.verifyProof({verifyIdentity:!1});case 2:return e.next=4,this.verifyProcess(this.proofVerificationProcess);case 4:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"verifyIdentity",value:(f=a(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.suite.verifyIdentity();case 2:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"getProofVerificationSteps",value:function(e){return[].concat(k(this.suite.getProofVerificationProcess()),k(this.proofVerificationProcess)).map((function(t){return ek.verifier.convertToVerificationSubsteps(e,t)}))}},{key:"getIdentityVerificationSteps",value:function(e){return this.hasDid?this.suite.getIdentityVerificationProcess().map((function(t){return ek.verifier.convertToVerificationSubsteps(e,t)})):[]}},{key:"getIssuerPublicKey",value:function(){return this.suite.getIssuerPublicKey()}},{key:"getIssuanceTime",value:function(){return this.suite.getIssuanceTime()}},{key:"getIssuerName",value:function(){return this.issuer.name}},{key:"getIssuerProfileDomain",value:function(){var e;return null===(e=new URL(this.getIssuerProfileUrl()))||void 0===e?void 0:e.hostname}},{key:"getIssuerProfileUrl",value:function(){return this.issuer.id}},{key:"getSigningDate",value:function(){return this.proof.created}},{key:"getChain",value:function(){return this.suite.getChain()}},{key:"getReceipt",value:function(){return this.receipt}},{key:"getTransactionIdString",value:function(){return ek.certificates.getTransactionId(this.getReceipt())}},{key:"getTransactionLink",value:function(){return ek.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).transactionLink}},{key:"getRawTransactionLink",value:function(){return ek.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).rawTransactionLink}},{key:"executeStep",value:(h=a(r().mark((function e(t,n,i){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("executeStep method needs to be overwritten by injecting from Verifier");case 1:case"end":return e.stop()}}),e)}))),function(e,t,n){return h.apply(this,arguments)})},{key:"setVerificationSuite",value:(u=a(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.setIssuerFromProofVerificationMethod();case 2:this.verificationMethodPublicKey=kk(this.getTargetVerificationMethodContainer(),PV(this.proof)),this.suite=new DV({document:this.documentToVerify,proof:this.proof,verificationMethod:this.verificationMethodPublicKey,options:{explorerAPIs:this.explorerAPIs,executeStepMethod:this.executeStep}});case 4:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"adaptVerificationProcessToChain",value:function(){ek.chains.isMockChain(this.chain)&&(nd(this.proofVerificationProcess,QV.parseIssuerKeys),nd(this.proofVerificationProcess,QV.checkAuthenticity))}},{key:"getTargetVerificationMethodContainer",value:function(){var e;return null!==(e=this.issuer.didDocument)&&void 0!==e?e:this.issuer}},{key:"isProofChain",value:function(){return"ChainedProof2021"===this.proof.type}},{key:"setIssuerFromProofVerificationMethod",value:(o=a(r().mark((function e(){var t;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isProofChain()){e.next=5;break}return t=this.proof.verificationMethod.split("#")[0],e.next=4,ek.verifier.getIssuerProfile(t);case 4:this.issuer=e.sent;case 5:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"setHasDid",value:function(){if(this.isProofChain()){var e=this.proof.verificationMethod.split("#")[0];this.hasDid=ld(e)}else this.hasDid=!!this.issuer.didDocument}},{key:"validateProofType",value:function(){var e=this.isProofChain()?this.proof.chainedProofType:this.proof.type;if(e!==this.type)throw new Error("Incompatible proof type passed. Expected: ".concat(this.type,", Got: ").concat(e))}},{key:"verifyProcess",value:(i=a(r().mark((function e(t){var n,i,o;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=F(t),e.prev=1,n.s();case 3:if((i=n.n()).done){e.next=11;break}if(this[o=i.value]){e.next=7;break}return e.abrupt("return",void console.error("verification logic for",o,"not implemented"));case 7:return e.next=9,this[o]();case 9:e.next=3;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),n.e(e.t0);case 16:return e.prev=16,n.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,this,[[1,13,16,19]])}))),function(e){return i.apply(this,arguments)})},{key:"parseIssuerKeys",value:(n=a(r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep(QV.parseIssuerKeys,(function(){return ek.verifier.parseIssuerKeys(t.issuer)}),this.type);case 2:this.issuerPublicKeyList=e.sent;case 3:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"checkAuthenticity",value:(t=a(r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep(QV.checkAuthenticity,(function(){return Ck(t.issuerPublicKeyList,t.getIssuerPublicKey(),t.getIssuanceTime())}),this.type);case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),v}(FV);!function(e){e.getTransactionId="getTransactionId",e.computeLocalHash="computeLocalHash",e.fetchRemoteHash="fetchRemoteHash",e.parseIssuerKeys="parseIssuerKeys",e.compareHashes="compareHashes",e.checkMerkleRoot="checkMerkleRoot",e.checkReceipt="checkReceipt",e.checkAuthenticity="checkAuthenticity"}(_V||(_V={}));var LV=function(e){c(I,e);var t,n,i,o,u,h,f,d,p,g,v,y,w=b(I);function I(e){var t;return s(this,I),A(m(t=w.call(this,e)),"verificationProcess",[_V.getTransactionId,_V.computeLocalHash,_V.fetchRemoteHash,_V.compareHashes,_V.checkMerkleRoot,_V.checkReceipt,_V.parseIssuerKeys,_V.checkAuthenticity]),A(m(t),"transactionId",void 0),A(m(t),"localHash",void 0),A(m(t),"documentToVerify",void 0),A(m(t),"txData",void 0),A(m(t),"chain",void 0),A(m(t),"explorerAPIs",void 0),A(m(t),"receipt",void 0),A(m(t),"issuerPublicKeyList",void 0),A(m(t),"issuer",void 0),A(m(t),"proof",void 0),A(m(t),"type","MerkleProof2017"),e.executeStep&&(t.executeStep=e.executeStep),t.documentToVerify=e.document,t.explorerAPIs=e.explorerAPIs,t.issuer=e.issuer,t.proof=e.proof,t.validateProofType(),t.receipt=t.documentToVerify.signature,t.chain=ek.certificates.getChain("",t.receipt),t.transactionId=ek.certificates.getTransactionId(t.receipt),t.adaptVerificationProcessToChain(),t}return l(I,[{key:"init",value:(y=a(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)}))),function(){return y.apply(this,arguments)})},{key:"verifyProof",value:(v=a(r().mark((function e(){var t,n,i;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=F(this.verificationProcess),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=11;break}if(this[i=n.value]){e.next=7;break}return e.abrupt("return",void console.error("verification logic for",i,"not implemented"));case 7:return e.next=9,this[i]();case 9:e.next=3;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),t.e(e.t0);case 16:return e.prev=16,t.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,this,[[1,13,16,19]])}))),function(){return v.apply(this,arguments)})},{key:"verifyIdentity",value:(g=a(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)}))),function(){return g.apply(this,arguments)})},{key:"getProofVerificationSteps",value:function(e){return this.verificationProcess.map((function(t){return ek.verifier.convertToVerificationSubsteps(e,t)}))}},{key:"getIdentityVerificationSteps",value:function(){return[]}},{key:"getIssuerPublicKey",value:function(){return ek.chains.isMockChain(this.chain)?"This mock chain does not support issuing addresses":this.txData?this.txData.issuingAddress:void console.error("Trying to access issuing address when txData not available yet. Did you run the `verify` method yet?")}},{key:"getIssuerName",value:function(){return this.issuer.name}},{key:"getIssuerProfileDomain",value:function(){var e;return null===(e=new URL(this.getIssuerProfileUrl()))||void 0===e?void 0:e.hostname}},{key:"getIssuerProfileUrl",value:function(){return this.issuer.id}},{key:"getSigningDate",value:function(){return this.documentToVerify.issuedOn}},{key:"getChain",value:function(){return this.chain}},{key:"getReceipt",value:function(){return this.receipt}},{key:"getTransactionIdString",value:function(){return ek.certificates.getTransactionId(this.getReceipt())}},{key:"getTransactionLink",value:function(){return ek.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).transactionLink}},{key:"getRawTransactionLink",value:function(){return ek.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).rawTransactionLink}},{key:"validateProofType",value:function(){if(this.proof.type[0]!==this.type)throw new Error("Incompatible proof type passed. Expected: ".concat(this.type,", Got: ").concat(this.proof.type[0]))}},{key:"adaptVerificationProcessToChain",value:function(){ek.chains.isMockChain(this.chain)&&(nd(this.verificationProcess,_V.getTransactionId),nd(this.verificationProcess,_V.fetchRemoteHash),nd(this.verificationProcess,_V.parseIssuerKeys),nd(this.verificationProcess,_V.checkMerkleRoot),nd(this.verificationProcess,_V.checkAuthenticity))}},{key:"executeStep",value:(p=a(r().mark((function e(t,n,i){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("doAction method needs to be overwritten by injecting from CVJS");case 1:case"end":return e.stop()}}),e)}))),function(e,t,n){return p.apply(this,arguments)})},{key:"getTransactionId",value:(d=a(r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep(_V.getTransactionId,(function(){return function(e){if("string"==typeof e&&e.length>0)return e;throw new $f("getTransactionId",zf("errors","isTransactionIdValid"))}(t.transactionId)}),this.type);case 2:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"computeLocalHash",value:(f=a(r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep(_V.computeLocalHash,a(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Bk(t.documentToVerify);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)}))),this.type);case 2:this.localHash=e.sent;case 3:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"fetchRemoteHash",value:(h=a(r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep(_V.fetchRemoteHash,a(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ek.verifier.lookForTx({transactionId:t.transactionId,chain:t.chain.code,explorerAPIs:t.explorerAPIs});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)}))),this.type);case 2:this.txData=e.sent;case 3:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"compareHashes",value:(u=a(r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep(_V.compareHashes,(function(){return function(e,t){if(e!==t)throw new $f("compareHashes",zf("errors","ensureHashesEqual"));return!0}(t.localHash,t.receipt.targetHash)}),this.type);case 2:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"checkMerkleRoot",value:(o=a(r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep(_V.checkMerkleRoot,(function(){return function(e,t){if(e!==t)throw new $f("checkMerkleRoot",zf("errors","ensureMerkleRootEqual"));return!0}(t.receipt.merkleRoot,t.txData.remoteHash)}),this.type);case 2:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"checkReceipt",value:(i=a(r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep(_V.checkReceipt,(function(){return function(e){var t=e.targetHash,n=e.merkleRoot;try{var r=e.proof||e.path;if(r)for(var i in r){var o=r[i],a=void 0;if(void 0!==o.left)a=yk("".concat(o.left).concat(t)),t=vk(a);else{if(void 0===o.right)throw new $f("checkReceipt","Trigger catch error.");a=yk("".concat(t).concat(o.right)),t=vk(a)}}}catch(e){throw new $f("checkReceipt",zf("errors","ensureValidReceipt"))}if(t!==n)throw new $f("checkReceipt",zf("errors","invalidMerkleReceipt"))}(t.receipt)}),this.type);case 2:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"parseIssuerKeys",value:(n=a(r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep(_V.parseIssuerKeys,(function(){return ek.verifier.parseIssuerKeys(t.issuer)}),this.type);case 2:this.issuerPublicKeyList=e.sent;case 3:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"checkAuthenticity",value:(t=a(r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep(_V.checkAuthenticity,(function(){return Ck(t.issuerPublicKeyList,t.txData.issuingAddress,t.txData.time)}),this.type);case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),I}(FV),MV={};function TV(e,t){return function(e,t,n){if(!(e instanceof Uint8Array))throw new TypeError('"input" must be a Uint8Array.');if(void 0!==n&&"number"!=typeof n)throw new TypeError('"maxline" must be a number.');if(0===e.length)return"";var r="",i=0,o=t.length,a=t.charAt(0),s=[0];for(i=0;i<e.length;++i){for(var u=e[i],l=0;l<s.length;++l)u+=s[l]<<8,s[l]=u%o,u=u/o|0;for(;u>0;)s.push(u%o),u=u/o|0}for(i=0;0===e[i]&&i<e.length-1;++i)r+=a;for(i=s.length-1;i>=0;--i)r+=t[s[i]];if(n){var A=new RegExp(".{1,"+n+"}","g");r=r.match(A).join("\r\n")}return r}(e,"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",t)}function RV(e){return function(e,t){if("string"!=typeof e)throw new TypeError('"input" must be a string.');if(0===e.length)return new Uint8Array;var n=MV[t];if(!n){n=MV[t]=[];for(var r=0;r<t.length;++r)n[t.charCodeAt(r)]=r}e=e.replace(/\s/g,"");for(var i=t.length,o=t.charAt(0),a=[0],s=0;s<e.length;s++){var u=n[e.charCodeAt(s)];if(void 0===u)return;for(var l=u,A=0;A<a.length;++A)l+=a[A]*i,a[A]=255&l,l>>=8;for(;l>0;)a.push(255&l),l>>=8}for(var c=0;e[c]===o&&c<e.length-1;++c)a.push(0);return new Uint8Array(a.reverse())}
529
+ var sF={},uF=sF,lF=bD;Object.assign(sF,lF);var AF=function(){function e(){s(this,e)}var t,i;return l(e,[{key:"add",value:(i=a(r().mark((function e(t){var i,o,a,s,u,l,A,c=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=c.length>1&&void 0!==c[1]?c[1]:{},o=i.suite,a=i.purpose,s=i.documentLoader,u=i.expansionMap,o){e.next=3;break}throw new TypeError('"options.suite" is required.');case 3:if(a){e.next=5;break}throw new TypeError('"options.purpose" is required.');case 5:return s=s?FD(s):PD,void 0===u?u=LD:!1===u&&(u=void 0),delete(l=n({},t)).proof,e.next=10,o.createProof({document:l,purpose:a,documentLoader:s,expansionMap:u});case 10:return A=e.sent,e.abrupt("return",(DD.addValue(t,"proof",A),t));case 12:case"end":return e.stop()}}),e)}))),function(e){return i.apply(this,arguments)})},{key:"verify",value:(t=a(r().mark((function e(t){var i,o,s,u,l,A,c,h,f,d,p,g,v,y,m,w=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=w.length>1&&void 0!==w[1]?w[1]:{},o=i.suite,s=i.purpose,u=i.documentLoader,l=i.expansionMap,o){e.next=3;break}throw new TypeError('"options.suite" is required.');case 3:if(s){e.next=5;break}throw new TypeError('"options.purpose" is required.');case 5:if(0!==(A=Array.isArray(o)?o:[o]).length){e.next=8;break}throw new TypeError("At least one suite is required.");case 8:return u=u?FD(u):PD,void 0===l?l=LD:!1===l&&(l=void 0),e.prev=9,t=n({},t),e.next=13,function(){var e=a(r().mark((function e(t){var i,o,a;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=t.document,o=DD.getValues(i,"proof"),delete i.proof,0!==o.length){e.next=3;break}throw new Error("No matching proofs found in the given document.");case 3:return a=i["@context"]||ND.SECURITY_CONTEXT_URL,e.abrupt("return",(o=o.map((function(e){return n({"@context":a},e)})),{proofSet:o,document:i}));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()({document:t,documentLoader:u,expansionMap:l});case 13:return c=e.sent,h=c.proofSet,f=c.document,t=f,e.next=19,function(){var e=a(r().mark((function e(t){var n,i,o,s,u,l,A,c,h,f,d;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.document,i=t.suites,o=t.proofSet,s=t.purpose,u=t.documentLoader,l=t.expansionMap,A=Array.isArray(s)?s:[s],c=new Map,h=new Map,f=new Map,e.next=4,Promise.all(A.map((function(e){return(t=a(r().mark((function e(t){var n,i,o,a,s,u,l,A,c,h,f,d,p,g,v,y,m,w,b;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=t.purposeToProofs,i=t.proofToSuite,o=t.purpose,a=t.proofSet,s=t.suites,u=t.suiteMatchQueue,l=t.document,A=t.documentLoader,c=t.expansionMap,h=F(a),e.prev=2,h.s();case 4:if((f=h.n()).done){e.next=38;break}return d=f.value,e.next=8,o.match(d,{document:l,documentLoader:A,expansionMap:c});case 8:if(e.sent){e.next=10;break}return e.abrupt("continue",36);case 10:p=!1,g=F(s),e.prev=12,g.s();case 14:if((v=g.n()).done){e.next=27;break}return y=v.value,(m=u.get(y))||u.set(y,m=new Map),(w=m.get(d))||(w=y.matchProof({proof:d,document:l,documentLoader:A,expansionMap:c}),m.set(d,w)),e.next=22,w;case 22:if(!e.sent){e.next=25;break}return p=!0,i.set(d,y),e.abrupt("break",27);case 25:e.next=14;break;case 27:e.next=32;break;case 29:e.prev=29,e.t0=e.catch(12),g.e(e.t0);case 32:return e.prev=32,g.f(),e.finish(32);case 35:p&&((b=n.get(o))?b.push(d):n.set(o,[d]));case 36:e.next=4;break;case 38:e.next=43;break;case 40:e.prev=40,e.t1=e.catch(2),h.e(e.t1);case 43:return e.prev=43,h.f(),e.finish(43);case 46:case"end":return e.stop()}}),e,null,[[2,40,43,46],[12,29,32,35]])}))),function(e){return t.apply(this,arguments)})({purposeToProofs:c,proofToSuite:h,purpose:e,proofSet:o,suites:i,suiteMatchQueue:f,document:n,documentLoader:u,expansionMap:l});var t})));case 4:if(!(c.size<A.length)){e.next=6;break}return e.abrupt("return",[]);case 6:return d=new Map,e.next=9,Promise.all(k(h.entries()).map(function(){var e=a(r().mark((function e(t){var i,o,s,A,c,h,f,p,g,v;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=C(t,2),o=i[0],s=i[1],e.prev=1,h={validate:function(){var e=a(r().mark((function e(t,n){var i;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=n.verificationMethod,e.abrupt("return",(c=i,{valid:!0}));case 2:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}()},e.next=5,s.verifyProof({proof:o,document:n,purpose:h,documentLoader:u,expansionMap:l});case 5:f=e.sent,p=f.verified,g=f.verificationMethod,v=f.error,c||(c=g),A={proof:o,verified:p,verificationMethod:c,error:v},e.next=15;break;case 12:e.prev=12,e.t0=e.catch(1),A={proof:o,verified:!1,error:e.t0};case 15:A.error&&MD(A.error),d.set(o,A);case 16:case"end":return e.stop()}}),e,null,[[1,12]])})));return function(t){return e.apply(this,arguments)}}()));case 9:return e.next=11,Promise.all(k(c.entries()).map(function(){var e=a(r().mark((function e(t){var i,o,a,s,A,c,f,p,g,v;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=C(t,2),o=i[0],a=i[1],s=F(a),e.prev=2,s.s();case 4:if((A=s.n()).done){e.next=23;break}if(c=A.value,(f=d.get(c)).verified){e.next=9;break}return e.abrupt("continue",21);case 9:return p=f.verificationMethod,g=h.get(c),v=void 0,e.prev=11,e.next=14,o.validate(c,{document:n,suite:g,verificationMethod:p,documentLoader:u,expansionMap:l});case 14:v=e.sent,e.next=20;break;case 17:e.prev=17,e.t0=e.catch(11),v={valid:!1,error:e.t0};case 20:f.purposeResult?Array.isArray(f.purposeResult)?f.purposeResult.push(v):f.purposeResult=[f.purposeResult,v]:f.purposeResult=v,v.valid||(MD(v.error),f.error||(f.verified=!1,f.error=v.error));case 21:e.next=4;break;case 23:e.next=28;break;case 25:e.prev=25,e.t1=e.catch(2),s.e(e.t1);case 28:return e.prev=28,s.f(),e.finish(28);case 31:case"end":return e.stop()}}),e,null,[[2,25,28,31],[11,17]])})));return function(t){return e.apply(this,arguments)}}()));case 11:return e.abrupt("return",k(d.values()));case 12:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()({document:t,suites:A,proofSet:h,purpose:s,documentLoader:u,expansionMap:l});case 19:if(0!==(d=e.sent).length){e.next=23;break}throw(p=new Error("Did not verify any proofs; insufficient proofs matched the acceptable suite(s) and required purpose(s).")).name="NotFoundError",p;case 23:if(g=d.some((function(e){return e.verified})),g){e.next=27;break}return y=(v=[]).concat.apply(v,k(d.filter((function(e){return e.error})).map((function(e){return e.error})))),m={verified:g,results:d},e.abrupt("return",(y.length>0&&(m.error=y),m));case 27:return e.abrupt("return",{verified:g,results:d});case 30:return e.prev=30,e.t0=e.catch(9),e.abrupt("return",(MD(e.t0),{verified:!1,error:e.t0}));case 33:case"end":return e.stop()}}),e,null,[[9,30]])}))),function(e){return t.apply(this,arguments)})}]),e}(),cF=RD;function hF(e){var t=Object.keys(Ul).map((function(e){return Ul[e]})).find((function(t){return t.signatureValue===e}));return t}function fF(e,t){var n=e.findIndex((function(e){return e===t}));n>-1&&e.splice(n,1)}sF.sign=function(){var e=a(r().mark((function e(t){var n,o,a,s,u,l,A,c,h,f=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=f.length>1&&void 0!==f[1]?f[1]:{},o=n.suite,a=n.purpose,s=n.documentLoader,u=n.expansionMap,l=n.addSuiteContext,A=void 0===l||l,"object"==i(t)){e.next=3;break}throw new TypeError('The "document" parameter must be an object.');case 3:return o.ensureSuiteContext({document:t,addSuiteContext:A}),e.prev=4,e.next=7,(new AF).add(t,{suite:o,purpose:a,documentLoader:s,expansionMap:u});case 7:return e.abrupt("return",e.sent);case 10:if(e.prev=10,e.t0=e.catch(4),s||"jsonld.InvalidUrl"!==e.t0.name){e.next=15;break}throw c=e.t0.details.url,(h=new Error('A URL "'.concat(c,'" could not be fetched; you need to pass "documentLoader" or resolve the URL before calling "sign".'))).cause=e.t0,h;case 15:throw e.t0;case 16:case"end":return e.stop()}}),e,null,[[4,10]])})));return function(t){return e.apply(this,arguments)}}(),sF.verify=function(){var e=a(r().mark((function e(t){var n,o,a,s,u,l,A,c,h,f=arguments;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=f.length>1&&void 0!==f[1]?f[1]:{},o=n.suite,a=n.purpose,s=n.documentLoader,u=n.expansionMap,"object"==i(t)){e.next=3;break}throw new TypeError('The "document" parameter must be an object.');case 3:return e.next=5,(new AF).verify(t,{suite:o,purpose:a,documentLoader:s,expansionMap:u});case 5:return l=e.sent,(A=l.error)&&(s||"jsonld.InvalidUrl"!==A.name?l.error=new cF(A):(c=A.details.url,h=new Error('A URL "'.concat(c,'" could not be fetched; you need to pass "documentLoader" or resolve the URL before calling "verify".')),l.error=new cF(h))),e.abrupt("return",l);case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),sF.suites=WD.suites,sF.purposes=aF.purposes,Object.assign(sF,xD);var dF={"@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"}]},pF={"@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"}}},gF={"@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"}}};function vF(e){e=e.trim();for(var t=[],n=0;n<e.length;n+=2)t.push(parseInt(e.substring(n,n+2),16));return t}Rf["https://w3id.org/blockcerts/schema/2.0-alpha/context.json"]=dF,Rf["https://www.blockcerts.org/schema/2.0-alpha/context.json"]=dF,Rf["https://www.blockcerts.org/schema/3.0-alpha/context.json"]=pF,Rf["https://w3id.org/blockcerts/schema/3.0-alpha/context.json"]=pF,Rf["https://w3id.org/blockcerts/v3.0-alpha"]=pF,Rf["https://www.blockcerts.org/schema/3.0-beta/context.json"]=gF,Rf["https://w3id.org/blockcerts/schema/3.0-beta/context.json"]=gF,Rf["https://w3id.org/blockcerts/v3.0-beta"]=gF,Rf["https://w3id.org/security/suites/ed25519-2020/v1"]={"@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"}}}}};var yF=function(e){c(n,e);var t=b(n);function n(e,r){var i;return s(this,n),(i=t.call(this,r)).stepCode=e,i}return l(n)}(g(Error)),mF="en-US",wF={"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 bF(e,t){return e&&t?wF[mF]?wF[mF][e]?wF[mF][e][t]?wF[mF][e][t]||"":"[missing locale item data]":"[missing locale group data]":"[missing locale data]":""}var IF=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){e.done?i(e.value):function(e){return e instanceof n?e:new n((function(t){t(e)}))}(e.value).then(a,s)}u((r=r.apply(e,t||[])).next())}))};function BF(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(e){};return IF(this,void 0,void 0,r().mark((function i(){var o,a,s,u,l;return r().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(e["@context"].find((function(e){return(t=e)===Object(t)&&"@vocab"in e;var t}))||e["@context"].push({"@vocab":"http://fallback.org/"}),o=JSON.parse(JSON.stringify(e)),!Array.isArray(o.proof)){i.next=9;break}if(t){i.next=5;break}throw new yF("computeLocalHash",bF("errors","noProofSpecified"));case 5:a=o.proof.findIndex((function(e){return e.proofValue===t.proofValue})),o.proof=o.proof.slice(0,a),i.next=10;break;case 9:delete o.proof;case 10:return s={algorithm:"URDNA2015",format:"application/nquads",documentLoader:function(e){return IF(this,void 0,void 0,r().mark((function t(){return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.t0=null!=n,!t.t0){t.next=4;break}return t.next=4,n(e);case 4:return t.abrupt("return",e in Rf?{contextUrl:null,document:Rf[e],documentUrl:e}:nw.documentLoader(e));case 5:case"end":return t.stop()}}),t)})))}},i.prev=11,i.next=14,nw.normalize(o,s);case 14:u=i.sent,i.next=20;break;case 17:throw i.prev=17,i.t0=i.catch(11),console.error(i.t0),new yF("computeLocalHash",bF("errors","failedJsonLdNormalization"));case 20:if(l=function(e){var t=e.split("\n"),n=/<http:\/\/fallback\.org\/(.*)>/,r=t.map((function(e){return n.exec(e)})).filter((function(e){return null!=e}));if(r.length>0){var i=r.map((function(e){return e[1]})).sort();return Array.from(new Set(i))}return null}(u),!l){i.next=23;break}throw new yF("computeLocalHash","".concat(bF("errors","foundUnmappedFields"),": ").concat(l.join(", ")));case 23:return i.abrupt("return",vk(function(e){for(var t=[],n=0;n<e.length;n++){var r=e.charCodeAt(n);r<128?t.push(r):r<2048?t.push(192|r>>6,128|63&r):r<55296||r>=57344?t.push(224|r>>12,128|r>>6&63,128|63&r):(n++,r=65536+((1023&r)<<10|1023&e.charCodeAt(n)),t.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|63&r))}return t}(u)));case 24:case"end":return i.stop()}}),i,null,[[11,17]])})))}var EF,CF=function(e){c(n,e);var t=b(n);function n(e){return s(this,n),t.call(this,e||"This operation is not supported for this key type")}return l(n)}(g(Error)),xF=CF,kF=function(e){c(n,e);var t=b(n);function n(){return s(this,n),t.call(this,"This has not been implemented yet")}return l(n)}(g(Error)),SF=function(){function e(){s(this,e),this.registry=[],this.classes={}}return l(e,[{key:"find",value:function(e){return this.registry.find(e)}},{key:"define",value:function(e,t){var n=this;e.forEach((function(e){var r=e.kty;if(!r)throw new Error("Invalid type definition");n.classes[r]||(n.classes[r]=t),n.registry.push(e)}))}},{key:"normalize",value:function(e,t,n){var r=this.classes[e],i=this.find((function(e){return e[t]===n}));if(!r||!i)throw new Error("Invalid type");return new r(i)}}]),e}(),QF=kF,_F=function(){function e(t){s(this,e),this.params=t}return l(e,[{key:"fromPrivatePKCS1",value:function(e){throw new QF}},{key:"fromPrivatePKCS8",value:function(e){throw new QF}},{key:"fromPublicPKCS1",value:function(e){throw new QF}},{key:"fromPublicPKCS8",value:function(e){throw new QF}},{key:"fromPrivateBlk",value:function(e){throw new QF}},{key:"fromPublicBlk",value:function(e){throw new QF}},{key:"fromJwk",value:function(e){throw new QF}},{key:"toPrivatePKCS1",value:function(e){throw new QF}},{key:"toPrivatePKCS8",value:function(e){throw new QF}},{key:"toPublicPKCS1",value:function(e){throw new QF}},{key:"toPublicPKCS8",value:function(e){throw new QF}},{key:"toPrivateBlk",value:function(e){throw new QF}},{key:"toPublicBlk",value:function(e){throw new QF}},{key:"toPrivateJwk",value:function(e){throw new QF}},{key:"toPublicJwk",value:function(e){throw new QF}}],[{key:"formatPem",value:function(e,t){return"-----BEGIN ".concat(t," KEY-----\n")+e.match(/.{1,64}/g).join("\n")+"\n-----END ".concat(t," KEY-----")}}]),e}(),NF={},DF={},FF={},PF=Fa,UF=PF.Buffer,LF={};for(EF in PF)PF.hasOwnProperty(EF)&&"SlowBuffer"!==EF&&"Buffer"!==EF&&(LF[EF]=PF[EF]);var MF=LF.Buffer={};for(EF in UF)UF.hasOwnProperty(EF)&&"allocUnsafe"!==EF&&"allocUnsafeSlow"!==EF&&(MF[EF]=UF[EF]);if(LF.Buffer.prototype=UF.prototype,MF.from&&MF.from!==Uint8Array.from||(MF.from=function(e,t,n){if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type '+i(e));if(e&&void 0===e.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+i(e));return UF(e,t,n)}),MF.alloc||(MF.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError('The "size" argument must be of type number. Received type '+i(e));if(e<0||e>=2*(1<<30))throw new RangeError('The value "'+e+'" is invalid for option "size"');var r=UF(e);return t&&0!==t.length?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r}),!LF.kStringMaxLength)try{LF.kStringMaxLength=lA.binding("buffer").kStringMaxLength}catch(e){}LF.constants||(LF.constants={MAX_LENGTH:LF.kMaxLength},LF.kStringMaxLength&&(LF.constants.MAX_STRING_LENGTH=LF.kStringMaxLength));var TF=LF,RF={},OF=KI.exports;function HF(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function KF(e,t){this.path=e,this.rethrow(t)}RF.Reporter=HF,HF.prototype.isError=function(e){return e instanceof KF},HF.prototype.save=function(){var e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},HF.prototype.restore=function(e){var t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},HF.prototype.enterKey=function(e){return this._reporterState.path.push(e)},HF.prototype.exitKey=function(e){var t=this._reporterState;t.path=t.path.slice(0,e-1)},HF.prototype.leaveKey=function(e,t,n){var r=this._reporterState;this.exitKey(e),null!==r.obj&&(r.obj[t]=n)},HF.prototype.path=function(){return this._reporterState.path.join("/")},HF.prototype.enterObject=function(){var e=this._reporterState,t=e.obj;return e.obj={},t},HF.prototype.leaveObject=function(e){var t=this._reporterState,n=t.obj;return t.obj=e,n},HF.prototype.error=function(e){var t,n=this._reporterState,r=e instanceof KF;if(t=r?e:new KF(n.path.map((function(e){return"["+JSON.stringify(e)+"]"})).join(""),e.message||e,e.stack),!n.options.partial)throw t;return r||n.errors.push(t),t},HF.prototype.wrapResult=function(e){var t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},OF(KF,Error),KF.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,KF),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this};var jF={},GF=KI.exports,qF=RF.Reporter,VF=TF.Buffer;function zF(e,t){qF.call(this,t),VF.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function JF(e,t){if(Array.isArray(e))this.length=0,this.value=e.map((function(e){return JF.isEncoderBuffer(e)||(e=new JF(e,t)),this.length+=e.length,e}),this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=VF.byteLength(e);else{if(!VF.isBuffer(e))return t.error("Unsupported type: "+i(e));this.value=e,this.length=e.length}}GF(zF,qF),jF.DecoderBuffer=zF,zF.isDecoderBuffer=function(e){return e instanceof zF||"object"==i(e)&&VF.isBuffer(e.base)&&"DecoderBuffer"===e.constructor.name&&"number"==typeof e.offset&&"number"==typeof e.length&&"function"==typeof e.save&&"function"==typeof e.restore&&"function"==typeof e.isEmpty&&"function"==typeof e.readUInt8&&"function"==typeof e.skip&&"function"==typeof e.raw},zF.prototype.save=function(){return{offset:this.offset,reporter:qF.prototype.save.call(this)}},zF.prototype.restore=function(e){var t=new zF(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,qF.prototype.restore.call(this,e.reporter),t},zF.prototype.isEmpty=function(){return this.offset===this.length},zF.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},zF.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");var n=new zF(this.base);return n._reporterState=this._reporterState,n.offset=this.offset,n.length=this.offset+e,this.offset+=e,n},zF.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},jF.EncoderBuffer=JF,JF.isEncoderBuffer=function(e){return e instanceof JF||"object"==i(e)&&"EncoderBuffer"===e.constructor.name&&"number"==typeof e.length&&"function"==typeof e.join},JF.prototype.join=function(e,t){return e||(e=VF.alloc(this.length)),t||(t=0),0===this.length||(Array.isArray(this.value)?this.value.forEach((function(n){n.join(e,t),t+=n.length})):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):VF.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length)),e};var YF=RF.Reporter,XF=jF.EncoderBuffer,WF=jF.DecoderBuffer,ZF=xI,$F=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],eP=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat($F);function tP(e,t,n){var r={};this._baseState=r,r.name=n,r.enc=e,r.parent=t||null,r.children=null,r.tag=null,r.args=null,r.reverseArgs=null,r.choice=null,r.optional=!1,r.any=!1,r.obj=!1,r.use=null,r.useDecoder=null,r.key=null,r.default=null,r.explicit=null,r.implicit=null,r.contains=null,r.parent||(r.children=[],this._wrap())}var nP=tP,rP=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];tP.prototype.clone=function(){var e=this._baseState,t={};rP.forEach((function(n){t[n]=e[n]}));var n=new this.constructor(t.parent);return n._baseState=t,n},tP.prototype._wrap=function(){var e=this._baseState;eP.forEach((function(t){this[t]=function(){var n=new this.constructor(this);return e.children.push(n),n[t].apply(n,arguments)}}),this)},tP.prototype._init=function(e){var t=this._baseState;ZF(null===t.parent),e.call(this),t.children=t.children.filter((function(e){return e._baseState.parent===this}),this),ZF.equal(t.children.length,1,"Root node can have only one child")},tP.prototype._useArgs=function(e){var t=this._baseState,n=e.filter((function(e){return e instanceof this.constructor}),this);e=e.filter((function(e){return!(e instanceof this.constructor)}),this),0!==n.length&&(ZF(null===t.children),t.children=n,n.forEach((function(e){e._baseState.parent=this}),this)),0!==e.length&&(ZF(null===t.args),t.args=e,t.reverseArgs=e.map((function(e){if("object"!=i(e)||e.constructor!==Object)return e;var t={};return Object.keys(e).forEach((function(n){n==(0|n)&&(n|=0);var r=e[n];t[r]=n})),t})))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach((function(e){tP.prototype[e]=function(){var t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}})),$F.forEach((function(e){tP.prototype[e]=function(){var t=this._baseState,n=Array.prototype.slice.call(arguments);return ZF(null===t.tag),t.tag=e,this._useArgs(n),this}})),tP.prototype.use=function(e){ZF(e);var t=this._baseState;return ZF(null===t.use),t.use=e,this},tP.prototype.optional=function(){return this._baseState.optional=!0,this},tP.prototype.def=function(e){var t=this._baseState;return ZF(null===t.default),t.default=e,t.optional=!0,this},tP.prototype.explicit=function(e){var t=this._baseState;return ZF(null===t.explicit&&null===t.implicit),t.explicit=e,this},tP.prototype.implicit=function(e){var t=this._baseState;return ZF(null===t.explicit&&null===t.implicit),t.implicit=e,this},tP.prototype.obj=function(){var e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},tP.prototype.key=function(e){var t=this._baseState;return ZF(null===t.key),t.key=e,this},tP.prototype.any=function(){return this._baseState.any=!0,this},tP.prototype.choice=function(e){var t=this._baseState;return ZF(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map((function(t){return e[t]}))),this},tP.prototype.contains=function(e){var t=this._baseState;return ZF(null===t.use),t.contains=e,this},tP.prototype._decode=function(e,t){var n=this._baseState;if(null===n.parent)return e.wrapResult(n.children[0]._decode(e,t));var r,i=n.default,o=!0,a=null;if(null!==n.key&&(a=e.enterKey(n.key)),n.optional){var s=null;if(null!==n.explicit?s=n.explicit:null!==n.implicit?s=n.implicit:null!==n.tag&&(s=n.tag),null!==s||n.any){if(o=this._peekTag(e,s,n.any),e.isError(o))return o}else{var u=e.save();try{null===n.choice?this._decodeGeneric(n.tag,e,t):this._decodeChoice(e,t),o=!0}catch(e){o=!1}e.restore(u)}}if(n.obj&&o&&(r=e.enterObject()),o){if(null!==n.explicit){var l=this._decodeTag(e,n.explicit);if(e.isError(l))return l;e=l}var A=e.offset;if(null===n.use&&null===n.choice){var c;n.any&&(c=e.save());var h=this._decodeTag(e,null!==n.implicit?n.implicit:n.tag,n.any);if(e.isError(h))return h;n.any?i=e.raw(c):e=h}if(t&&t.track&&null!==n.tag&&t.track(e.path(),A,e.length,"tagged"),t&&t.track&&null!==n.tag&&t.track(e.path(),e.offset,e.length,"content"),n.any||(i=null===n.choice?this._decodeGeneric(n.tag,e,t):this._decodeChoice(e,t)),e.isError(i))return i;if(n.any||null!==n.choice||null===n.children||n.children.forEach((function(n){n._decode(e,t)})),n.contains&&("octstr"===n.tag||"bitstr"===n.tag)){var f=new WF(i);i=this._getUse(n.contains,e._reporterState.obj)._decode(f,t)}}return n.obj&&o&&(i=e.leaveObject(r)),null===n.key||null===i&&!0!==o?null!==a&&e.exitKey(a):e.leaveKey(a,n.key,i),i},tP.prototype._decodeGeneric=function(e,t,n){var r=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,r.args[0],n):/str$/.test(e)?this._decodeStr(t,e,n):"objid"===e&&r.args?this._decodeObjid(t,r.args[0],r.args[1],n):"objid"===e?this._decodeObjid(t,null,null,n):"gentime"===e||"utctime"===e?this._decodeTime(t,e,n):"null_"===e?this._decodeNull(t,n):"bool"===e?this._decodeBool(t,n):"objDesc"===e?this._decodeStr(t,e,n):"int"===e||"enum"===e?this._decodeInt(t,r.args&&r.args[0],n):null!==r.use?this._getUse(r.use,t._reporterState.obj)._decode(t,n):t.error("unknown tag: "+e)},tP.prototype._getUse=function(e,t){var n=this._baseState;return n.useDecoder=this._use(e,t),ZF(null===n.useDecoder._baseState.parent),n.useDecoder=n.useDecoder._baseState.children[0],n.implicit!==n.useDecoder._baseState.implicit&&(n.useDecoder=n.useDecoder.clone(),n.useDecoder._baseState.implicit=n.implicit),n.useDecoder},tP.prototype._decodeChoice=function(e,t){var n=this._baseState,r=null,i=!1;return Object.keys(n.choice).some((function(o){var a=e.save(),s=n.choice[o];try{var u=s._decode(e,t);if(e.isError(u))return!1;r={type:o,value:u},i=!0}catch(t){return e.restore(a),!1}return!0}),this),i?r:e.error("Choice not matched")},tP.prototype._createEncoderBuffer=function(e){return new XF(e,this.reporter)},tP.prototype._encode=function(e,t,n){var r=this._baseState;if(null===r.default||r.default!==e){var i=this._encodeValue(e,t,n);return void 0===i||this._skipDefault(i,t,n)?void 0:i}},tP.prototype._encodeValue=function(e,t,n){var r=this._baseState;if(null===r.parent)return r.children[0]._encode(e,t||new YF);var o=null;if(this.reporter=t,r.optional&&void 0===e){if(null===r.default)return;e=r.default}var a=null,s=!1;if(r.any)o=this._createEncoderBuffer(e);else if(r.choice)o=this._encodeChoice(e,t);else if(r.contains)a=this._getUse(r.contains,n)._encode(e,t),s=!0;else if(r.children)a=r.children.map((function(n){if("null_"===n._baseState.tag)return n._encode(null,t,e);if(null===n._baseState.key)return t.error("Child should have a key");var r=t.enterKey(n._baseState.key);if("object"!=i(e))return t.error("Child expected, but input is not object");var o=n._encode(e[n._baseState.key],t,e);return t.leaveKey(r),o}),this).filter((function(e){return e})),a=this._createEncoderBuffer(a);else if("seqof"===r.tag||"setof"===r.tag){if(!r.args||1!==r.args.length)return t.error("Too many args for : "+r.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");var u=this.clone();u._baseState.implicit=null,a=this._createEncoderBuffer(e.map((function(n){var r=this._baseState;return this._getUse(r.args[0],e)._encode(n,t)}),u))}else null!==r.use?o=this._getUse(r.use,n)._encode(e,t):(a=this._encodePrimitive(r.tag,e),s=!0);if(!r.any&&null===r.choice){var l=null!==r.implicit?r.implicit:r.tag,A=null===r.implicit?"universal":"context";null===l?null===r.use&&t.error("Tag could be omitted only for .use()"):null===r.use&&(o=this._encodeComposite(l,s,A,a))}return null!==r.explicit&&(o=this._encodeComposite(r.explicit,!1,"context",o)),o},tP.prototype._encodeChoice=function(e,t){var n=this._baseState,r=n.choice[e.type];return r||ZF(!1,e.type+" not found in "+JSON.stringify(Object.keys(n.choice))),r._encode(e.value,t)},tP.prototype._encodePrimitive=function(e,t){var n=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&n.args)return this._encodeObjid(t,n.reverseArgs[0],n.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,n.args&&n.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},tP.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},tP.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(e)};var iP={};!function(e){function t(e){var t={};return Object.keys(e).forEach((function(n){(0|n)==n&&(n|=0);var r=e[n];t[r]=n})),t}e.tagClass={0:"universal",1:"application",2:"context",3:"private"},e.tagClassByName=t(e.tagClass),e.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},e.tagByName=t(e.tag)}(iP);var oP=KI.exports,aP=TF.Buffer,sP=nP,uP=iP;function lP(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new cP,this.tree._init(e.body)}var AP=lP;function cP(e){sP.call(this,"der",e)}function hP(e){return e<10?"0"+e:e}lP.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},oP(cP,sP),cP.prototype._encodeComposite=function(e,t,n,r){var i=function(e,t,n,r){var i;if("seqof"===e?e="seq":"setof"===e&&(e="set"),uP.tagByName.hasOwnProperty(e))i=uP.tagByName[e];else{if("number"!=typeof e||(0|e)!==e)return r.error("Unknown tag: "+e);i=e}return i>=31?r.error("Multi-octet tag encoding unsupported"):(t||(i|=32),i|=uP.tagClassByName[n||"universal"]<<6)}(e,t,n,this.reporter);if(r.length<128){var o=aP.alloc(2);return o[0]=i,o[1]=r.length,this._createEncoderBuffer([o,r])}for(var a=1,s=r.length;s>=256;s>>=8)a++;var u=aP.alloc(2+a);u[0]=i,u[1]=128|a;for(var l=1+a,A=r.length;A>0;l--,A>>=8)u[l]=255&A;return this._createEncoderBuffer([u,r])},cP.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){for(var n=aP.alloc(2*e.length),r=0;r<e.length;r++)n.writeUInt16BE(e.charCodeAt(r),2*r);return this._createEncoderBuffer(n)}return"numstr"===t?this._isNumstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===t?this._isPrintstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(t)||"objDesc"===t?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: "+t+" unsupported")},cP.prototype._encodeObjid=function(e,t,n){if("string"==typeof e){if(!t)return this.reporter.error("string objid given, but no values map found");if(!t.hasOwnProperty(e))return this.reporter.error("objid not found in values map");e=t[e].split(/[\s.]+/g);for(var r=0;r<e.length;r++)e[r]|=0}else if(Array.isArray(e)){e=e.slice();for(var i=0;i<e.length;i++)e[i]|=0}if(!Array.isArray(e))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(e));if(!n){if(e[1]>=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}for(var o=0,a=0;a<e.length;a++){var s=e[a];for(o++;s>=128;s>>=7)o++}for(var u=aP.alloc(o),l=u.length-1,A=e.length-1;A>=0;A--){var c=e[A];for(u[l--]=127&c;(c>>=7)>0;)u[l--]=128|127&c}return this._createEncoderBuffer(u)},cP.prototype._encodeTime=function(e,t){var n,r=new Date(e);return"gentime"===t?n=[hP(r.getUTCFullYear()),hP(r.getUTCMonth()+1),hP(r.getUTCDate()),hP(r.getUTCHours()),hP(r.getUTCMinutes()),hP(r.getUTCSeconds()),"Z"].join(""):"utctime"===t?n=[hP(r.getUTCFullYear()%100),hP(r.getUTCMonth()+1),hP(r.getUTCDate()),hP(r.getUTCHours()),hP(r.getUTCMinutes()),hP(r.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(n,"octstr")},cP.prototype._encodeNull=function(){return this._createEncoderBuffer("")},cP.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!aP.isBuffer(e)){var n=e.toArray();!e.sign&&128&n[0]&&n.unshift(0),e=aP.from(n)}if(aP.isBuffer(e)){var r=e.length;0===e.length&&r++;var i=aP.alloc(r);return e.copy(i),0===e.length&&(i[0]=0),this._createEncoderBuffer(i)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);for(var o=1,a=e;a>=256;a>>=8)o++;for(var s=new Array(o),u=s.length-1;u>=0;u--)s[u]=255&e,e>>=8;return 128&s[0]&&s.unshift(0),this._createEncoderBuffer(aP.from(s))},cP.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},cP.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},cP.prototype._skipDefault=function(e,t,n){var r,i=this._baseState;if(null===i.default)return!1;var o=e.join();if(void 0===i.defaultBuffer&&(i.defaultBuffer=this._encodeValue(i.default,t,n).join()),o.length!==i.defaultBuffer.length)return!1;for(r=0;r<o.length;r++)if(o[r]!==i.defaultBuffer[r])return!1;return!0};var fP=KI.exports,dP=AP;function pP(e){dP.call(this,e),this.enc="pem"}fP(pP,dP);var gP=pP;pP.prototype.encode=function(e,t){for(var n=dP.prototype.encode.call(this,e).toString("base64"),r=["-----BEGIN "+t.label+"-----"],i=0;i<n.length;i+=64)r.push(n.slice(i,i+64));return r.push("-----END "+t.label+"-----"),r.join("\n")},function(e){var t=e;t.der=AP,t.pem=gP}(FF);var vP={},yP=KI.exports,mP=CI.exports,wP=jF.DecoderBuffer,bP=nP,IP=iP;function BP(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new CP,this.tree._init(e.body)}var EP=BP;function CP(e){bP.call(this,"der",e)}function xP(e,t){var n=e.readUInt8(t);if(e.isError(n))return n;var r=IP.tagClass[n>>6],i=0==(32&n);if(31==(31&n)){var o=n;for(n=0;128==(128&o);){if(o=e.readUInt8(t),e.isError(o))return o;n<<=7,n|=127&o}}else n&=31;return{cls:r,primitive:i,tag:n,tagStr:IP.tag[n]}}function kP(e,t,n){var r=e.readUInt8(n);if(e.isError(r))return r;if(!t&&128===r)return null;if(0==(128&r))return r;var i=127&r;if(i>4)return e.error("length octect is too long");r=0;for(var o=0;o<i;o++){r<<=8;var a=e.readUInt8(n);if(e.isError(a))return a;r|=a}return r}BP.prototype.decode=function(e,t){return wP.isDecoderBuffer(e)||(e=new wP(e,t)),this.tree._decode(e,t)},yP(CP,bP),CP.prototype._peekTag=function(e,t,n){if(e.isEmpty())return!1;var r=e.save(),i=xP(e,'Failed to peek tag: "'+t+'"');return e.isError(i)?i:(e.restore(r),i.tag===t||i.tagStr===t||i.tagStr+"of"===t||n)},CP.prototype._decodeTag=function(e,t,n){var r=xP(e,'Failed to decode tag of "'+t+'"');if(e.isError(r))return r;var i=kP(e,r.primitive,'Failed to get length of "'+t+'"');if(e.isError(i))return i;if(!n&&r.tag!==t&&r.tagStr!==t&&r.tagStr+"of"!==t)return e.error('Failed to match tag: "'+t+'"');if(r.primitive||null!==i)return e.skip(i,'Failed to match body of: "'+t+'"');var o=e.save(),a=this._skipUntilEnd(e,'Failed to skip indefinite length body: "'+this.tag+'"');return e.isError(a)?a:(i=e.offset-o.offset,e.restore(o),e.skip(i,'Failed to match body of: "'+t+'"'))},CP.prototype._skipUntilEnd=function(e,t){for(;;){var n=xP(e,t);if(e.isError(n))return n;var r=kP(e,n.primitive,t);if(e.isError(r))return r;var i;if(i=n.primitive||null!==r?e.skip(r):this._skipUntilEnd(e,t),e.isError(i))return i;if("end"===n.tagStr)break}},CP.prototype._decodeList=function(e,t,n,r){for(var i=[];!e.isEmpty();){var o=this._peekTag(e,"end");if(e.isError(o))return o;var a=n.decode(e,"der",r);if(e.isError(a)&&o)break;i.push(a)}return i},CP.prototype._decodeStr=function(e,t){if("bitstr"===t){var n=e.readUInt8();return e.isError(n)?n:{unused:n,data:e.raw()}}if("bmpstr"===t){var r=e.raw();if(r.length%2==1)return e.error("Decoding of string type: bmpstr length mismatch");for(var i="",o=0;o<r.length/2;o++)i+=String.fromCharCode(r.readUInt16BE(2*o));return i}if("numstr"===t){var a=e.raw().toString("ascii");return this._isNumstr(a)?a:e.error("Decoding of string type: numstr unsupported characters")}if("octstr"===t)return e.raw();if("objDesc"===t)return e.raw();if("printstr"===t){var s=e.raw().toString("ascii");return this._isPrintstr(s)?s:e.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(t)?e.raw().toString():e.error("Decoding of string type: "+t+" unsupported")},CP.prototype._decodeObjid=function(e,t,n){for(var r,i=[],o=0,a=0;!e.isEmpty();)o<<=7,o|=127&(a=e.readUInt8()),0==(128&a)&&(i.push(o),o=0);128&a&&i.push(o);var s=i[0]/40|0,u=i[0]%40;if(r=n?i:[s,u].concat(i.slice(1)),t){var l=t[r.join(" ")];void 0===l&&(l=t[r.join(".")]),void 0!==l&&(r=l)}return r},CP.prototype._decodeTime=function(e,t){var n,r,i,o,a,s,u=e.raw().toString();if("gentime"===t)n=0|u.slice(0,4),r=0|u.slice(4,6),i=0|u.slice(6,8),o=0|u.slice(8,10),a=0|u.slice(10,12),s=0|u.slice(12,14);else{if("utctime"!==t)return e.error("Decoding "+t+" time is not supported yet");n=0|u.slice(0,2),r=0|u.slice(2,4),i=0|u.slice(4,6),o=0|u.slice(6,8),a=0|u.slice(8,10),s=0|u.slice(10,12),n=n<70?2e3+n:1900+n}return Date.UTC(n,r-1,i,o,a,s,0)},CP.prototype._decodeNull=function(){return null},CP.prototype._decodeBool=function(e){var t=e.readUInt8();return e.isError(t)?t:0!==t},CP.prototype._decodeInt=function(e,t){var n=e.raw(),r=new mP(n);return t&&(r=t[r.toString(10)]||r),r},CP.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getDecoder("der").tree};var SP=KI.exports,QP=TF.Buffer,_P=EP;function NP(e){_P.call(this,e),this.enc="pem"}SP(NP,_P);var DP=NP;NP.prototype.decode=function(e,t){for(var n=e.toString().split(/[\r\n]+/g),r=t.label.toUpperCase(),i=/^-----(BEGIN|END) ([^-]+)-----$/,o=-1,a=-1,s=0;s<n.length;s++){var u=n[s].match(i);if(null!==u&&u[2]===r){if(-1!==o){if("END"!==u[1])break;a=s;break}if("BEGIN"!==u[1])break;o=s}}if(-1===o||-1===a)throw new Error("PEM section not found for: "+r);var l=n.slice(o+1,a).join("");l.replace(/[^a-z0-9+/=]+/gi,"");var A=QP.from(l,"base64");return _P.prototype.decode.call(this,A,t)},function(e){var t=e;t.der=EP,t.pem=DP}(vP),function(e){var t=FF,n=vP,r=KI.exports;function i(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}e.define=function(e,t){return new i(e,t)},i.prototype._createNamed=function(e){var t=this.name;function n(e){this._initNamed(e,t)}return r(n,e),n.prototype._initNamed=function(t,n){e.call(this,t,n)},new n(this)},i.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(n[e])),this.decoders[e]},i.prototype.decode=function(e,t,n){return this._getDecoder(t).decode(e,n)},i.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(t[e])),this.encoders[e]},i.prototype.encode=function(e,t,n){return this._getEncoder(t).encode(e,n)}}(DF);var FP={};!function(e){var t=FP;t.Reporter=RF.Reporter,t.DecoderBuffer=jF.DecoderBuffer,t.EncoderBuffer=jF.EncoderBuffer,t.Node=nP}();var PP={};!function(e){var t=e;t._reverse=function(e){var t={};return Object.keys(e).forEach((function(n){(0|n)==n&&(n|=0);var r=e[n];t[r]=n})),t},t.der=iP}(PP),function(e){var t=NF;t.bignum=CI.exports,t.define=DF.define,t.base=FP,t.constants=PP,t.decoders=vP,t.encoders=FF}();var UP={exports:{}},LP={},MP={};Object.defineProperty(MP,"__esModule",{value:!0}),MP.default=function(e){var t=e.length,n=t%4;if(!n)return e;var r=t,i=4-n,o=t+i,a=Yo.alloc(o);for(a.write(e);i--;)a.write("=",r++);return a.toString()},Object.defineProperty(LP,"__esModule",{value:!0});var TP=MP;function RP(e,t){return void 0===t&&(t="utf8"),Na(e)?HP(e.toString("base64")):HP(Yo.from(e,t).toString("base64"))}function OP(e){return e=e.toString(),TP.default(e).replace(/\-/g,"+").replace(/_/g,"/")}function HP(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}var KP=RP;KP.encode=RP,KP.decode=function(e,t){return void 0===t&&(t="utf8"),Yo.from(OP(e),"base64").toString(t)},KP.toBase64=OP,KP.fromBase64=HP,KP.toBuffer=function(e){return Yo.from(OP(e),"base64")},LP.default=KP,function(e){e.exports=LP.default,e.exports.default=e.exports}(UP);var jP=UP.exports,GP=NF,qP=UP.exports,VP=function(){function e(){s(this,e)}return l(e,null,[{key:"convert",value:function(e,t,n){if(e){if(t===n)return e;var r;if("raw"===t||e instanceof Yo)r=e;else if("uint8_array"===t||Array.isArray(e))r=Yo.from(e);else if("hex"===t)r=Yo.from(e,"hex");else if("base64"===t)r=Yo.from(e,"base64");else if("base64url"===t)r=qP.toBuffer(e);else{if("bn"!==t&&"bignum"!==t)throw new Error("Invalid fromType");r=Yo.from(this.pad(e.toString(16)),"hex")}if("raw"===n)return r;if("uint8_array"===n)return Array.from(r);if("hex"===n)return r.toString("hex");if("base64"===n)return r.toString("base64");if("base64url"===n)return qP.fromBase64(r.toString("base64"));if("bn"===n||"bignum"===n)return new GP.bignum(r);throw new Error("Invalid toType")}}},{key:"pad",value:function(e){return e.length%2==1?"0".concat(e):e}}]),e}(),zP=NF,JP=function(){function e(){s(this,e),Object.defineProperty(this,"_registry",{value:{}})}return l(e,[{key:"registry",get:function(){return this._registry}},{key:"define",value:function(e,t){this._registry[e]=zP.define(e,t(this))}},{key:"normalize",value:function(e){return this.registry[e]}}]),e}(),YP=new JP;YP.define("Version",(function(e){return function(){this.int({0:"two-prime",1:"multi"})}})),YP.define("OtherPrimeInfos",(function(e){return function(){this.seq().obj(this.key("ri").int(),this.key("di").int(),this.key("ti").int())}})),YP.define("AlgorithmIdentifier",(function(e){return function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional().any())}})),YP.define("PrivateKeyInfo",(function(e){var t=e.normalize("Version"),n=e.normalize("AlgorithmIdentifier");return function(){this.seq().obj(this.key("version").use(t),this.key("algorithm").use(n),this.key("privateKey").octstr())}})),YP.define("PublicKeyInfo",(function(e){var t=e.normalize("AlgorithmIdentifier");return function(){this.seq().obj(this.key("algorithm").use(t),this.key("publicKey").bitstr())}})),YP.define("RSAPrivateKey",(function(e){var t=e.normalize("Version"),n=e.normalize("OtherPrimeInfos");return function(){this.seq().obj(this.key("version").use(t),this.key("n").int(),this.key("e").int(),this.key("d").int(),this.key("p").int(),this.key("q").int(),this.key("dp").int(),this.key("dq").int(),this.key("qi").int(),this.key("other").optional().use(n))}})),YP.define("RSAPublicKey",(function(e){return function(){this.seq().obj(this.key("n").int(),this.key("e").int())}})),YP.define("ECPrivateKey",(function(e){return function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").explicit(0).optional().choice({namedCurve:this.objid()}),this.key("publicKey").explicit(1).optional().bitstr())}}));var XP=YP,WP=VP,ZP=XP,$P=function(e){c(n,e);var t=b(n);function n(){return s(this,n),t.apply(this,arguments)}return l(n,[{key:"fromPrivatePKCS1",value:function(e){var t=ZP.normalize("RSAPrivateKey").decode(e,"der"),n=t.n,r=t.e,i=t.d,o=t.p,a=t.q,s=t.dp,u=t.dq,l=t.qi;return{n:WP.convert(n,"bn","raw"),e:WP.convert(r,"bn","raw"),d:WP.convert(i,"bn","raw"),p:WP.convert(o,"bn","raw"),q:WP.convert(a,"bn","raw"),dp:WP.convert(s,"bn","raw"),dq:WP.convert(u,"bn","raw"),qi:WP.convert(l,"bn","raw")}}},{key:"fromPrivatePKCS8",value:function(e){var t=ZP.normalize("PrivateKeyInfo"),n=ZP.normalize("RSAPrivateKey"),r=t.decode(e,"der"),i=n.decode(r.privateKey,"der"),o=i.n,a=i.e,s=i.d,u=i.p,l=i.q,A=i.dp,c=i.dq,h=i.qi;return{n:WP.convert(o,"bn","raw"),e:WP.convert(a,"bn","raw"),d:WP.convert(s,"bn","raw"),p:WP.convert(u,"bn","raw"),q:WP.convert(l,"bn","raw"),dp:WP.convert(A,"bn","raw"),dq:WP.convert(c,"bn","raw"),qi:WP.convert(h,"bn","raw")}}},{key:"fromPublicPKCS1",value:function(e){var t=ZP.normalize("RSAPublicKey").decode(e,"der"),n=t.n,r=t.e;return{n:WP.convert(n,"bn","raw"),e:WP.convert(r,"bn","raw")}}},{key:"fromPublicPKCS8",value:function(e){var t=ZP.normalize("PublicKeyInfo"),n=ZP.normalize("RSAPublicKey"),r=t.decode(e,"der"),i=n.decode(r.publicKey.data,"der"),o=i.n,a=i.e;return{n:WP.convert(o,"bn","raw"),e:WP.convert(a,"bn","raw")}}},{key:"fromJwk",value:function(e){var t=e.n,n=e.e,r=e.d,i=e.p,o=e.q,a=e.dp,s=e.dq,u=e.qi;return e.alg,{n:WP.convert(t,"base64url","raw"),e:WP.convert(n,"base64url","raw"),d:WP.convert(r,"base64url","raw"),p:WP.convert(i,"base64url","raw"),q:WP.convert(o,"base64url","raw"),dp:WP.convert(a,"base64url","raw"),dq:WP.convert(s,"base64url","raw"),qi:WP.convert(u,"base64url","raw")}}},{key:"toPrivatePKCS1",value:function(e){var t=e.n,r=e.e,i=e.d,o=e.p,a=e.q,s=e.dp,u=e.dq,l=e.qi,A=this.params.version,c=ZP.normalize("RSAPrivateKey").encode({version:A,n:WP.convert(t,"raw","bn"),e:WP.convert(r,"raw","bn"),d:WP.convert(i,"raw","bn"),p:WP.convert(o,"raw","bn"),q:WP.convert(a,"raw","bn"),dp:WP.convert(s,"raw","bn"),dq:WP.convert(u,"raw","bn"),qi:WP.convert(l,"raw","bn")},"der").toString("base64");return n.formatPem(c,"RSA PRIVATE")}},{key:"toPrivatePKCS8",value:function(e){var t=e.n,r=e.e,i=e.d,o=e.p,a=e.q,s=e.dp,u=e.dq,l=e.qi,A=this.params,c=A.oid,h=A.algParameters,f=A.version,d=ZP.normalize("PrivateKeyInfo"),p=ZP.normalize("RSAPrivateKey").encode({version:f,n:WP.convert(t,"raw","bn"),e:WP.convert(r,"raw","bn"),d:WP.convert(i,"raw","bn"),p:WP.convert(o,"raw","bn"),q:WP.convert(a,"raw","bn"),dp:WP.convert(s,"raw","bn"),dq:WP.convert(u,"raw","bn"),qi:WP.convert(l,"raw","bn")},"der"),g=d.encode({version:f,algorithm:{algorithm:c.split("."),parameters:Yo.from(h,"hex")},privateKey:p},"der").toString("base64");return n.formatPem(g,"PRIVATE")}},{key:"toPublicPKCS1",value:function(e){var t=e.n,r=e.e,i=this.params.version,o=ZP.normalize("RSAPublicKey").encode({version:i,n:WP.convert(t,"raw","bn"),e:WP.convert(r,"raw","bn")},"der").toString("base64");return n.formatPem(o,"RSA PUBLIC")}},{key:"toPublicPKCS8",value:function(e){var t=e.n,r=e.e,i=this.params,o=i.oid,a=i.algParameters,s=ZP.normalize("PublicKeyInfo"),u=ZP.normalize("RSAPublicKey").encode({n:WP.convert(t,"raw","bn"),e:WP.convert(r,"raw","bn")},"der"),l=s.encode({algorithm:{algorithm:o.split("."),parameters:Yo.from(a,"hex")},publicKey:{unused:0,data:u}},"der").toString("base64");return n.formatPem(l,"PUBLIC")}},{key:"toPrivateJwk",value:function(e){var t=e.n,n=e.e,r=e.d,i=e.p,o=e.q,a=e.dp,s=e.dq,u=e.qi;return{kty:this.params.kty,n:WP.convert(t,"raw","base64url"),e:WP.convert(n,"raw","base64url"),d:WP.convert(r,"raw","base64url"),p:WP.convert(i,"raw","base64url"),q:WP.convert(o,"raw","base64url"),dp:WP.convert(a,"raw","base64url"),dq:WP.convert(s,"raw","base64url"),qi:WP.convert(u,"raw","base64url")}}},{key:"toPublicJwk",value:function(e){var t=e.n,n=e.e;return{kty:this.params.kty,n:WP.convert(t,"raw","base64url"),e:WP.convert(n,"raw","base64url")}}}]),n}(_F),eU=$P,tU=new BI.ec("secp256k1"),nU=VP,rU=XP,iU=function(e){c(n,e);var t=b(n);function n(){return s(this,n),t.apply(this,arguments)}return l(n,[{key:"fromPrivatePKCS1",value:function(e){var t=rU.normalize("ECPrivateKey").decode(e,"der"),r=t.privateKey,i=t.publicKey.data,o=nU.convert(i,"raw","hex"),a=n.getPoint(o);return{d:r,x:a.x,y:a.y}}},{key:"fromPrivatePKCS8",value:function(e){var t=rU.normalize("PrivateKeyInfo"),r=rU.normalize("ECPrivateKey"),i=t.decode(e,"der"),o=r.decode(i.privateKey,"der"),a=o.privateKey,s=o.publicKey.data,u=nU.convert(s,"raw","hex"),l=n.getPoint(u);return{d:a,x:l.x,y:l.y}}},{key:"fromPublicPKCS8",value:function(e){var t=rU.normalize("PublicKeyInfo").decode(e,"der"),r=nU.convert(t.publicKey.data,"raw","hex");return n.getPoint(r)}},{key:"fromPrivateBlk",value:function(e){var t=tU.keyFromPrivate(e,"hex"),n=t.getPublic();return{d:nU.convert(t.priv,"bn","raw"),x:nU.convert(n.getX(),"bn","raw"),y:nU.convert(n.getY(),"bn","raw")}}},{key:"fromPublicBlk",value:function(e){return n.getPoint(e)}},{key:"fromJwk",value:function(e){var t=e.d,n=e.x,r=e.y;return{d:nU.convert(t,"base64url","raw"),x:nU.convert(n,"base64url","raw"),y:nU.convert(r,"base64url","raw")}}},{key:"toPrivatePKCS1",value:function(e){var t=this.params,r=t.namedCurve,i=t.keyVersion,o=e.d,a=e.x,s=e.y,u=rU.normalize("ECPrivateKey"),l=n.makePoint(a,s),A=u.encode({version:i,privateKey:o,parameters:{type:"namedCurve",value:r.split(".")},publicKey:{unused:0,data:l}},"der").toString("base64");return n.formatPem(A,"EC PRIVATE")}},{key:"toPrivatePKCS8",value:function(e){var t=this.params,r=t.oid,i=t.algParameters,o=t.keyVersion,a=t.infoVersion,s=e.d,u=e.x,l=e.y,A=rU.normalize("PrivateKeyInfo"),c=rU.normalize("ECPrivateKey"),h=n.makePoint(u,l),f=c.encode({version:o,privateKey:s,publicKey:{unused:0,data:h}},"der"),d=A.encode({version:a,algorithm:{algorithm:r.split("."),parameters:Yo.from(i,"hex")},privateKey:f},"der").toString("base64");return n.formatPem(d,"PRIVATE")}},{key:"toPublicPKCS8",value:function(e){var t=this.params,r=t.oid,i=t.algParameters,o=e.x,a=e.y,s=rU.normalize("PublicKeyInfo"),u=n.makePoint(o,a),l=s.encode({algorithm:{algorithm:r.split("."),parameters:Yo.from(i,"hex")},publicKey:{unused:0,data:u}},"der").toString("base64");return n.formatPem(l,"PUBLIC")}},{key:"toPrivateBlk",value:function(e){return e.d.toString("hex")}},{key:"toPublicBlk",value:function(e){return nU.convert(n.makePoint(e.x,e.y),"raw","hex")}},{key:"toPrivateJwk",value:function(e){var t=this.params,n=t.crv,r=t.kty,i=e.d,o=e.x,a=e.y;return{kty:r,crv:n,d:nU.convert(i,"raw","base64url"),x:nU.convert(o,"raw","base64url"),y:nU.convert(a,"raw","base64url")}}},{key:"toPublicJwk",value:function(e){var t=this.params,n=t.crv,r=t.kty,i=e.x,o=e.y;return{kty:r,crv:n,x:nU.convert(i,"raw","base64url"),y:nU.convert(o,"raw","base64url")}}}],[{key:"getPoint",value:function(e){var t=e.slice(2,(e.length-2)/2+2),n=e.slice((e.length-2)/2+2);return{x:nU.convert(t,"hex","raw"),y:nU.convert(n,"hex","raw")}}},{key:"makePoint",value:function(e,t){var n=Yo.from("04","hex");return Yo.concat([n,e,t],n.length+e.length+t.length)}}]),n}(_F),oU=iU,aU=VP,sU=XP,uU=function(e){c(n,e);var t=b(n);function n(){return s(this,n),t.apply(this,arguments)}return l(n,[{key:"fromPrivatePKCS8",value:function(e){var t=sU.normalize("PrivateKeyInfo").decode(e,"der").privateKey.slice(2);return{d:t,x:this.publicKeyFromPrivate(t)}}},{key:"fromPublicPKCS8",value:function(e){var t=sU.normalize("PublicKeyInfo").decode(e,"der");return{x:aU.convert(t.publicKey.data,"hex","raw")}}},{key:"fromJwk",value:function(e){var t=e.d,n=e.x;return{d:aU.convert(t,"base64url","raw"),x:aU.convert(n,"base64url","raw")}}},{key:"toPrivatePKCS8",value:function(e){var t=this.params,r=t.oid,i=t.infoVersion,o=e.d,a=sU.normalize("PrivateKeyInfo"),s=this.privateKeyPadding(o),u=a.encode({version:i,algorithm:{algorithm:r.split(".")},privateKey:s},"der").toString("base64");return n.formatPem(u,"PRIVATE")}},{key:"toPublicPKCS8",value:function(e){var t=this.params.oid,r=e.x,i=sU.normalize("PublicKeyInfo").encode({algorithm:{algorithm:t.split(".")},publicKey:{unused:0,data:aU.convert(r,"hex","raw")}},"der").toString("base64");return n.formatPem(i,"PUBLIC")}},{key:"toPrivateJwk",value:function(e){var t=this.params,n=t.crv,r=t.kty,i=e.d,o=e.x;return{kty:r,crv:n,d:aU.convert(i,"raw","base64url"),x:aU.convert(o,"raw","base64url")}}},{key:"toPublicJwk",value:function(e){var t=this.params,n=t.crv,r=t.kty,i=e.x;return{kty:r,crv:n,x:aU.convert(i,"raw","base64url")}}},{key:"privateKeyPadding",value:function(e){var t;if("Ed25519"!==this.params.crv)throw new Error("".concat(this.params.crv," is an invalid curve for EdDSA"));return t=Yo.from("0420","hex"),Yo.concat([t,e],t.length+e.length)}},{key:"publicKeyFromPrivate",value:function(e){if("Ed25519"===this.params.crv){var t=new BI.eddsa("ed25519");return Yo.from(t.keyFromSecret(e).getPublic())}throw new Error("".concat(this.params.crv," is an invalid curve for EdDSA"))}}]),n}(_F),lU=eU,AU=oU,cU=uU,hU=new SF;hU.define([{kty:"RSA",oid:"1.2.840.113549.1.1.1",algParameters:"0500",version:"two-prime"}],lU),hU.define([{kty:"EC",crv:"K-256",oid:"1.2.840.10045.2.1",namedCurve:"1.3.132.0.10",algParameters:"06052b8104000a",keyVersion:1,infoVersion:"two-prime"},{kty:"EC",crv:"P-256",oid:"1.2.840.10045.2.1",namedCurve:"1.2.840.10045.3.1.7",algParameters:"06082a8648ce3d030107",keyVersion:1,infoVersion:"two-prime"},{kty:"EC",crv:"P-384",oid:"1.2.840.10045.2.1",namedCurve:"1.3.132.0.34",algParameters:"06052b81040022",keyVersion:1,infoVersion:"two-prime"},{kty:"EC",crv:"P-521",oid:"1.2.840.10045.2.1",namedCurve:"1.3.132.0.35",algParameters:"06052b81040023",keyVersion:1,infoVersion:"two-prime"}],AU),hU.define([{kty:"OKP",crv:"Ed25519",oid:"1.3.101.112",infoVersion:"two-prime"}],cU);var fU=xF,dU=kF,pU=hU,gU=XP,vU=RegExp("\r?\n","g"),yU=function(){function e(t,n){if(s(this,e),!t)throw new fU("key is required");if(!n)throw new fU("options are required");var r=n.kty,i=n.format,o=n.selector,a=n.crv,u=n.oid;if(!n.kty)throw new fU("options.kty is required");if(!n.format)throw new fU("options.format is required");if(!n.selector)throw new fU("options.selector is required");if(!n.crv&&!n.oid)throw new fU("options.crv or options.oid is required");this.kty=r,this.format=i,this.selector=o,this.crv=a,this.oid=u,this.key=this.parseKey(t)}return l(e,[{key:"alg",get:function(){var e=this.kty,t=this.crv,n=this.oid;if(!this.algorithm){if(t)Object.defineProperty(this,"algorithm",{value:pU.normalize(e,"crv",t)});else{if(!n)throw new Error("Both crv and oid are undefined");Object.defineProperty(this,"algorithm",{value:pU.normalize(e,"oid",n)})}if(!this.algorithm)throw new Error("".concat(this.crv||this.oid," is not implemented yet"))}return this.algorithm}},{key:"parseKey",value:function(e){var t=this.alg,n=this.format,r=this.selector;if("pem"===n)switch(r){case"public_pkcs1":return t.fromPublicPKCS1(e);case"public_pkcs8":return t.fromPublicPKCS8(e);case"private_pkcs1":return t.fromPrivatePKCS1(e);case"private_pkcs8":return t.fromPrivatePKCS8(e);default:throw new Error("Invalid selector value")}if("jwk"===n)return t.fromJwk(e,r);if("blk"===n)switch(r){case"public":return t.fromPublicBlk(e);case"private":return t.fromPrivateBlk(e)}}},{key:"toJwk",value:function(e){var t=this.key,n=this.alg,r=this.selector;switch(e){case"public":return n.toPublicJwk(t);case"private":if(r.includes("public"))throw new fU("Cannot export a private key from a public key");return n.toPrivateJwk(t);default:throw new Error("Invalid key selector")}}},{key:"toString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"pem",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"public_pkcs8",n=this.key,r=this.alg,i=this.selector;if("pem"===e)switch(t){case"public_pkcs1":return r.toPublicPKCS1(n);case"public_pkcs8":return r.toPublicPKCS8(n);case"private_pkcs1":if(i.includes("public"))throw new fU("Cannot export a private key from a public key");return r.toPrivatePKCS1(n);case"private_pkcs8":if(i.includes("public"))throw new fU("Cannot export a private key from a public key");return r.toPrivatePKCS8(n);default:throw new Error("Invalid key selector")}else if("jwk"===e)switch(t){case"public":return JSON.stringify(r.toPublicJwk(n));case"private":if(i.includes("public"))throw new fU("Cannot export a private key from a public key");return JSON.stringify(r.toPrivateJwk(n));default:throw new Error("Invalid key selector")}else if("blk"===e)switch(t){case"private":if(i.includes("public"))throw new fU("Cannot export a private key from a public key");return r.toPrivateBlk(n);case"public":return r.toPublicBlk(n);default:throw new Error("Invalid key selector")}throw new dU}}],[{key:"from",value:function(t,n){if(!t)throw new fU("key is required");if(!n)throw new fU("format is required");if("jwk"===n){var r;if("string"==typeof t)try{r=JSON.parse(t)}catch(t){throw new fU("key is not a valid JWK")}else"object"==i(t)&&(r=t);var o,a=r,s=a.kty,u=a.crv;if(!s)throw new fU("kty is required for JWK");if("EC"===s&&!u)throw new fU("crv is required for EC JWK");"RSA"===s&&(o=pU.find((function(e){return e.kty===s})).oid);var l=r.d?"private":"public";return new e(r,{kty:s,crv:u,oid:o,format:n,selector:l})}if("pem"===n){if("string"!=typeof t)throw new fU("key is not a valid PEM string");var A=t.split(vU),c=A.splice(0,1);A.splice(A.length-1,1);var h,f,d=A.join(""),p=/^-----BEGIN ((RSA|EC) )?(PUBLIC|PRIVATE) KEY-----$/.exec(c),g=p?p[2]:void 0,v=p?p[3]:void 0,y=Yo.from(d,"base64");if(!v)throw new fU("key is not a valid PEM string");if(g){if("RSA"===g)v="PRIVATE"===v?"private_pkcs1":"public_pkcs1",h=pU.find((function(e){return e.kty===g})).oid;else if("EC"===g){var m;if("PRIVATE"===v)v="private_pkcs1",m=gU.normalize("".concat(g,"PrivateKey")).decode(y,"der");else if("PUBLIC"===v){v="public_pkcs1",m=gU.normalize("".concat(g,"PrivateKey")).decode(y,"der")}var w=m.parameters.value;f=pU.find((function(e){return e.namedCurve===w.join(".")})).crv}}else{var b,I=gU.normalize("PrivateKeyInfo"),B=gU.normalize("PublicKeyInfo");"PRIVATE"===v?(v="private_pkcs8",b=I.decode(y,"der")):"PUBLIC"===v&&(v="public_pkcs8",b=B.decode(y,"der"));var E=b.algorithm,C=E.algorithm,x=E.parameters;C=C.join("."),x=x?x.toString("hex"):void 0;var k=pU.find((function(e){return e.oid===C}));if(!(g=k?k.kty:void 0))throw new fU("".concat(C," is not supported"));"RSA"===g||"OKP"===g?h=C:"EC"===g&&(f=pU.find((function(e){return e.algParameters===x})).crv)}return new e(y,{kty:g,oid:h,crv:f,format:n,selector:v})}if("blk"===n)return new e(t,{kty:"EC",crv:"K-256",format:n,selector:t.length>64?"public":"private"});throw new fU("Invalid format ".concat(n))}}]),e}(),mU=yU,wU=qN("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),bU=Yo,IU={},BU={},EU={};Object.defineProperty(EU,"__esModule",{value:!0}),EU.testnet=EU.regtest=EU.bitcoin=void 0,EU.bitcoin={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},EU.regtest={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bcrt",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},EU.testnet={messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};var CU={},xU={},kU={},SU={};Object.defineProperty(SU,"__esModule",{value:!0}),SU.encode=SU.decode=SU.check=void 0,SU.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;var t=e[3];if(0===t)return!1;if(5+t>=e.length)return!1;if(2!==e[4+t])return!1;var n=e[5+t];return!(0===n||6+t+n!==e.length||128&e[4]||t>1&&0===e[4]&&!(128&e[5])||128&e[t+6]||n>1&&0===e[t+6]&&!(128&e[t+7]))},SU.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");var 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)");var n=e[5+t];if(0===n)throw new Error("S length is zero");if(6+t+n!==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(n>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)}},SU.encode=function(e,t){var n=e.length,r=t.length;if(0===n)throw new Error("R length is zero");if(0===r)throw new Error("S length is zero");if(n>33)throw new Error("R length is too long");if(r>33)throw new Error("S length is too long");if(128&e[0])throw new Error("R value is negative");if(128&t[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(r>1&&0===t[0]&&!(128&t[1]))throw new Error("S value excessively padded");var i=Yo.allocUnsafe(6+n+r);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=e.length,e.copy(i,4),i[4+n]=2,i[5+n]=t.length,t.copy(i,6+n),i};var QU={};Object.defineProperty(QU,"__esModule",{value:!0}),QU.REVERSE_OPS=QU.OPS=void 0;var _U={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_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};QU.OPS=_U;var NU={};QU.REVERSE_OPS=NU;for(var DU=0,FU=Object.keys(_U);DU<FU.length;DU++){var PU=FU[DU];NU[_U[PU]]=PU}var UU={};Object.defineProperty(UU,"__esModule",{value:!0}),UU.decode=UU.encode=UU.encodingLength=void 0;var LU=QU;function MU(e){return e<LU.OPS.OP_PUSHDATA1?1:e<=255?2:e<=65535?3:5}UU.encodingLength=MU,UU.encode=function(e,t,n){var r=MU(t);return 1===r?e.writeUInt8(t,n):2===r?(e.writeUInt8(LU.OPS.OP_PUSHDATA1,n),e.writeUInt8(t,n+1)):3===r?(e.writeUInt8(LU.OPS.OP_PUSHDATA2,n),e.writeUInt16LE(t,n+1)):(e.writeUInt8(LU.OPS.OP_PUSHDATA4,n),e.writeUInt32LE(t,n+1)),r},UU.decode=function(e,t){var n,r,i=e.readUInt8(t);if(i<LU.OPS.OP_PUSHDATA1)n=i,r=1;else if(i===LU.OPS.OP_PUSHDATA1){if(t+2>e.length)return null;n=e.readUInt8(t+1),r=2}else if(i===LU.OPS.OP_PUSHDATA2){if(t+3>e.length)return null;n=e.readUInt16LE(t+1),r=3}else{if(t+5>e.length)return null;if(i!==LU.OPS.OP_PUSHDATA4)throw new Error("Unexpected opcode");n=e.readUInt32LE(t+1),r=5}return{opcode:i,number:n,size:r}};var TU={};Object.defineProperty(TU,"__esModule",{value:!0}),TU.encode=TU.decode=void 0,TU.decode=function(e,t,n){t=t||4,n=void 0===n||n;var r=e.length;if(0===r)return 0;if(r>t)throw new TypeError("Script number overflow");if(n&&0==(127&e[r-1])&&(r<=1||0==(128&e[r-2])))throw new Error("Non-minimally encoded script number");if(5===r){var i=e.readUInt32LE(0),o=e.readUInt8(4);return 128&o?-(4294967296*(-129&o)+i):4294967296*o+i}for(var a=0,s=0;s<r;++s)a|=e[s]<<8*s;return 128&e[r-1]?-(a&~(128<<8*(r-1))):a},TU.encode=function(e){for(var t,n=Math.abs(e),r=(t=n)>2147483647?5:t>8388607?4:t>32767?3:t>127?2:t>0?1:0,i=Yo.allocUnsafe(r),o=e<0,a=0;a<r;++a)i.writeUInt8(255&n,a),n>>=8;return 128&i[r-1]?i.writeUInt8(o?128:0,r-1):o&&(i[r-1]|=128),i};var RU={},OU={},HU={Array:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((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"==i(e)},String:function(e){return"string"==typeof e},"":function(){return!0}};for(var KU in HU.Null=HU.Nil,HU)HU[KU].toJSON=function(e){return e}.bind(null,KU);var jU=HU,GU=jU;function qU(e){return e.name||e.toString().match(/function (.*?)\s*\(/)[1]}function VU(e){return GU.Nil(e)?"":qU(e.constructor)}function zU(e,t){Error.captureStackTrace&&Error.captureStackTrace(e,t)}function JU(e){return GU.Function(e)?e.toJSON?e.toJSON():qU(e):GU.Array(e)?"Array":e&&GU.Object(e)?"Object":void 0!==e?e:""}function YU(e,t,n){var r=function(e){return GU.Function(e)?"":GU.String(e)?JSON.stringify(e):e&&GU.Object(e)?"":e}(t);return"Expected "+JU(e)+", got"+(""!==n?" "+n:"")+(""!==r?" "+r:"")}function XU(e,t,n){n=n||VU(t),this.message=YU(e,t,n),zU(this,XU),this.__type=e,this.__value=t,this.__valueTypeName=n}function WU(e,t,n,r,i){e?(i=i||VU(r),this.message=function(e,t,n,r,i){var o='" of type ';return"key"===t&&(o='" with key type '),YU('property "'+JU(n)+o+JU(e),r,i)}(e,n,t,r,i)):this.message='Unexpected property "'+t+'"',zU(this,XU),this.__label=n,this.__property=t,this.__type=e,this.__value=r,this.__valueTypeName=i}XU.prototype=Object.create(Error.prototype),XU.prototype.constructor=XU,WU.prototype=Object.create(Error.prototype),WU.prototype.constructor=XU;var ZU={TfTypeError:XU,TfPropertyTypeError:WU,tfCustomError:function(e,t){return new XU(e,{},t)},tfSubError:function(e,t,n){return e instanceof WU?(t=t+"."+e.__property,e=new WU(e.__type,t,e.__label,e.__value,e.__valueTypeName)):e instanceof XU&&(e=new WU(e.__type,t,n,e.__value,e.__valueTypeName)),zU(e),e},tfJSON:JU,getValueTypeName:VU},$U=jU,eL=ZU;function tL(e){return Na(e)}function nL(e){return"string"==typeof e&&/^([0-9a-f]{2})+$/i.test(e)}function rL(e,t){var n=e.toJSON();function r(r){if(!e(r))return!1;if(r.length===t)return!0;throw eL.tfCustomError(n+"(Length: "+t+")",n+"(Length: "+r.length+")")}return r.toJSON=function(){return n},r}var iL=rL.bind(null,$U.Array),oL=rL.bind(null,tL),aL=rL.bind(null,nL),sL=rL.bind(null,$U.String),uL=Math.pow(2,53)-1,lL={ArrayN:iL,Buffer:tL,BufferN:oL,Finite:function(e){return"number"==typeof e&&isFinite(e)},Hex:nL,HexN:aL,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>=-uL&&e<=uL&&Math.floor(e)===e},Range:function(e,t,n){function r(r,i){return n(r,i)&&r>e&&r<t}return n=n||$U.Number,r.toJSON=function(){return"".concat(n.toJSON()," between [").concat(e,", ").concat(t,"]")},r},StringN:sL,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<=uL&&Math.floor(e)===e}};for(var AL in lL)lL[AL].toJSON=function(e){return e}.bind(null,AL);var cL=lL,hL=jU,fL=ZU.tfJSON,dL=ZU.TfTypeError,pL=ZU.TfPropertyTypeError,gL=ZU.tfSubError,vL=ZU.getValueTypeName,yL={arrayOf:function(e,t){function n(n,r){return!!hL.Array(n)&&!hL.Nil(n)&&!(void 0!==t.minLength&&n.length<t.minLength)&&!(void 0!==t.maxLength&&n.length>t.maxLength)&&(void 0===t.length||n.length===t.length)&&n.every((function(t,n){try{return wL(e,t,r)}catch(e){throw gL(e,n)}}))}return e=mL(e),t=t||{},n.toJSON=function(){var n="["+fL(e)+"]";return void 0!==t.length?n+="{"+t.length+"}":void 0===t.minLength&&void 0===t.maxLength||(n+="{"+(void 0===t.minLength?0:t.minLength)+","+(void 0===t.maxLength?1/0:t.maxLength)+"}"),n},n},maybe:function e(t){function n(n,r){return hL.Nil(n)||t(n,r,e)}return t=mL(t),n.toJSON=function(){return"?"+fL(t)},n},map:function(e,t){function n(n,r){if(!hL.Object(n))return!1;if(hL.Nil(n))return!1;for(var i in n){try{t&&wL(t,i,r)}catch(e){throw gL(e,i,"key")}try{var o=n[i];wL(e,o,r)}catch(e){throw gL(e,i)}}return!0}return e=mL(e),t&&(t=mL(t)),n.toJSON=t?function(){return"{"+fL(t)+": "+fL(e)+"}"}:function(){return"{"+fL(e)+"}"},n},object:function(e){var t={};for(var n in e)t[n]=mL(e[n]);function r(e,n){if(!hL.Object(e))return!1;if(hL.Nil(e))return!1;var r;try{for(r in t)wL(t[r],e[r],n)}catch(e){throw gL(e,r)}if(n)for(r in e)if(!t[r])throw new pL(void 0,r);return!0}return r.toJSON=function(){return fL(t)},r},anyOf:function(){var e=[].slice.call(arguments).map(mL);function t(t,n){return e.some((function(e){try{return wL(e,t,n)}catch(e){return!1}}))}return t.toJSON=function(){return e.map(fL).join("|")},t},allOf:function(){var e=[].slice.call(arguments).map(mL);function t(t,n){return e.every((function(e){try{return wL(e,t,n)}catch(e){return!1}}))}return t.toJSON=function(){return e.map(fL).join(" & ")},t},quacksLike:function(e){function t(t){return e===vL(t)}return t.toJSON=function(){return e},t},tuple:function(){var e=[].slice.call(arguments).map(mL);function t(t,n){return!hL.Nil(t)&&!hL.Nil(t.length)&&(!n||t.length===e.length)&&e.every((function(e,r){try{return wL(e,t[r],n)}catch(e){throw gL(e,r)}}))}return t.toJSON=function(){return"("+e.map(fL).join(", ")+")"},t},value:function(e){function t(t){return t===e}return t.toJSON=function(){return e},t}};function mL(e){if(hL.String(e))return"?"===e[0]?yL.maybe(e.slice(1)):hL[e]||yL.quacksLike(e);if(e&&hL.Object(e)){if(hL.Array(e)){if(1!==e.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return yL.arrayOf(e[0])}return yL.object(e)}return hL.Function(e)?e:yL.value(e)}function wL(e,t,n,r){if(hL.Function(e)){if(e(t,n))return!0;throw new dL(r||e,t)}return wL(mL(e),t,n)}for(var bL in yL.oneOf=yL.anyOf,hL)wL[bL]=hL[bL];for(bL in yL)wL[bL]=yL[bL];var IL=cL;for(bL in IL)wL[bL]=IL[bL];wL.compile=mL,wL.TfTypeError=dL,wL.TfPropertyTypeError=pL;var BL=wL;!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.Network=e.ECPoint=e.Satoshi=e.Signer=e.BIP32Path=e.UInt31=e.isPoint=e.typeforce=void 0;var t=Fa;e.typeforce=BL;var n=t.Buffer.alloc(32,0),r=t.Buffer.from("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f","hex");e.isPoint=function(e){if(!t.Buffer.isBuffer(e))return!1;if(e.length<33)return!1;var i=e[0],o=e.slice(1,33);if(0===o.compare(n))return!1;if(o.compare(r)>=0)return!1;if((2===i||3===i)&&33===e.length)return!0;var a=e.slice(33);return 0!==a.compare(n)&&!(a.compare(r)>=0)&&4===i&&65===e.length};var 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=function(){return"BIP32 derivation path"},e.Signer=function(t){return(e.typeforce.Buffer(t.publicKey)||"function"==typeof t.getPublicKey)&&"function"==typeof t.sign},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.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}(OU),Object.defineProperty(RU,"__esModule",{value:!0}),RU.encode=RU.decode=void 0;var EL=SU,CL=OU,xL=CL.typeforce,kL=Yo.alloc(1,0);function SL(e){for(var t=0;0===e[t];)++t;return t===e.length?kL:128&(e=e.slice(t))[0]?Yo.concat([kL,e],1+e.length):e}function QL(e){0===e[0]&&(e=e.slice(1));var t=Yo.alloc(32,0),n=Math.max(0,32-e.length);return e.copy(t,n),t}RU.decode=function(e){var t=e.readUInt8(e.length-1),n=-129&t;if(n<=0||n>=4)throw new Error("Invalid hashType "+t);var r=EL.decode(e.slice(0,-1)),i=QL(r.r),o=QL(r.s);return{signature:Yo.concat([i,o],64),hashType:t}},RU.encode=function(e,t){xL({signature:CL.BufferN(64),hashType:CL.UInt8},{signature:e,hashType:t});var n=-129&t;if(n<=0||n>=4)throw new Error("Invalid hashType "+t);var r=Yo.allocUnsafe(1);r.writeUInt8(t,0);var i=SL(e.slice(0,32)),o=SL(e.slice(32,64));return Yo.concat([EL.encode(i,o),r])},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.isPushOnly=e.OPS=void 0;var t=SU,n=QU;Object.defineProperty(e,"OPS",{enumerable:!0,get:function(){return n.OPS}});var r=UU,i=TU,o=RU,a=OU,s=a.typeforce,u=n.OPS.OP_RESERVED;function l(e){return a.Buffer(e)||function(e){return a.Number(e)&&(e===n.OPS.OP_0||e>=n.OPS.OP_1&&e<=n.OPS.OP_16||e===n.OPS.OP_1NEGATE)}(e)}function A(e){return a.Array(e)&&e.every(l)}function c(e){return 0===e.length?n.OPS.OP_0:1===e.length?e[0]>=1&&e[0]<=16?u+e[0]:129===e[0]?n.OPS.OP_1NEGATE:void 0:void 0}function h(e){return Na(e)}function f(e){return Na(e)}function d(e){if(h(e))return e;s(a.Array,e);var t=e.reduce((function(e,t){return f(t)?1===t.length&&void 0!==c(t)?e+1:e+r.encodingLength(t.length)+t.length:e+1}),0),n=Yo.allocUnsafe(t),i=0;if(e.forEach((function(e){if(f(e)){var t=c(e);if(void 0!==t)return n.writeUInt8(t,i),void(i+=1);i+=r.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 p(e){if(t=e,a.Array(t))return e;var t;s(a.Buffer,e);for(var i=[],o=0;o<e.length;){var u=e[o];if(u>n.OPS.OP_0&&u<=n.OPS.OP_PUSHDATA4){var l=r.decode(e,o);if(null===l)return null;if((o+=l.size)+l.number>e.length)return null;var A=e.slice(o,o+l.number);o+=l.number;var h=c(A);void 0!==h?i.push(h):i.push(A)}else i.push(u),o+=1}return i}function g(e){var t=-129&e;return t>0&&t<4}e.isPushOnly=A,e.compile=d,e.decompile=p,e.toASM=function(e){return h(e)&&(e=p(e)),e.map((function(e){if(f(e)){var t=c(e);if(void 0===t)return e.toString("hex");e=t}return n.REVERSE_OPS[e]})).join(" ")},e.fromASM=function(e){return s(a.String,e),d(e.split(" ").map((function(e){return void 0!==n.OPS[e]?n.OPS[e]:(s(a.Hex,e),Yo.from(e,"hex"))})))},e.toStack=function(e){return e=p(e),s(A,e),e.map((function(e){return f(e)?e:e===n.OPS.OP_0?Yo.allocUnsafe(0):i.encode(e-u)}))},e.isCanonicalPubKey=function(e){return a.isPoint(e)},e.isDefinedHashType=g,e.isCanonicalScriptSignature=function(e){return!!Na(e)&&!!g(e[e.length-1])&&t.check(e.slice(0,-1))},e.number=i,e.signature=o}(kU);var _L={};Object.defineProperty(_L,"__esModule",{value:!0}),_L.value=_L.prop=void 0,_L.prop=function(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get:function(){var e=n.call(this);return this[t]=e,e},set:function(e){Object.defineProperty(this,t,{configurable:!0,enumerable:!0,value:e,writable:!0})}})},_L.value=function(e){var t;return function(){return void 0!==t||(t=e()),t}},Object.defineProperty(xU,"__esModule",{value:!0}),xU.p2data=void 0;var NL=EU,DL=kU,FL=OU,PL=_L,UL=DL.OPS;xU.p2data=function(e,t){if(!e.data&&!e.output)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,FL.typeforce)({network:FL.typeforce.maybe(FL.typeforce.Object),output:FL.typeforce.maybe(FL.typeforce.Buffer),data:FL.typeforce.maybe(FL.typeforce.arrayOf(FL.typeforce.Buffer))},e);var n={name:"embed",network:e.network||NL.bitcoin};if(PL.prop(n,"output",(function(){if(e.data)return DL.compile([UL.OP_RETURN].concat(e.data))})),PL.prop(n,"data",(function(){if(e.output)return DL.decompile(e.output).slice(1)})),t.validate&&e.output){var r=DL.decompile(e.output);if(r[0]!==UL.OP_RETURN)throw new TypeError("Output is invalid");if(!r.slice(1).every(FL.typeforce.Buffer))throw new TypeError("Output is invalid");if(e.data&&!function(e,t){return e.length===t.length&&e.every((function(e,n){return e.equals(t[n])}))}(e.data,n.data))throw new TypeError("Data mismatch")}return Object.assign(n,e)};var LL={};Object.defineProperty(LL,"__esModule",{value:!0}),LL.p2ms=void 0;var ML=EU,TL=kU,RL=OU,OL=_L,HL=TL.OPS,KL=HL.OP_RESERVED;function jL(e,t){return e.length===t.length&&e.every((function(e,n){return e.equals(t[n])}))}LL.p2ms=function(e,t){if(!(e.input||e.output||e.pubkeys&&void 0!==e.m||e.signatures))throw new TypeError("Not enough data");function n(e){return TL.isCanonicalScriptSignature(e)||void 0!==(t.allowIncomplete&&e===HL.OP_0)}t=Object.assign({validate:!0},t||{}),(0,RL.typeforce)({network:RL.typeforce.maybe(RL.typeforce.Object),m:RL.typeforce.maybe(RL.typeforce.Number),n:RL.typeforce.maybe(RL.typeforce.Number),output:RL.typeforce.maybe(RL.typeforce.Buffer),pubkeys:RL.typeforce.maybe(RL.typeforce.arrayOf(RL.isPoint)),signatures:RL.typeforce.maybe(RL.typeforce.arrayOf(n)),input:RL.typeforce.maybe(RL.typeforce.Buffer)},e);var r={network:e.network||ML.bitcoin},i=[],o=!1;function a(e){o||(o=!0,i=TL.decompile(e),r.m=i[0]-KL,r.n=i[i.length-2]-KL,r.pubkeys=i.slice(1,-2))}if(OL.prop(r,"output",(function(){if(e.m&&r.n&&e.pubkeys)return TL.compile([].concat(KL+e.m,e.pubkeys,KL+r.n,HL.OP_CHECKMULTISIG))})),OL.prop(r,"m",(function(){if(r.output)return a(r.output),r.m})),OL.prop(r,"n",(function(){if(r.pubkeys)return r.pubkeys.length})),OL.prop(r,"pubkeys",(function(){if(e.output)return a(e.output),r.pubkeys})),OL.prop(r,"signatures",(function(){if(e.input)return TL.decompile(e.input).slice(1)})),OL.prop(r,"input",(function(){if(e.signatures)return TL.compile([HL.OP_0].concat(e.signatures))})),OL.prop(r,"witness",(function(){if(r.input)return[]})),OL.prop(r,"name",(function(){if(r.m&&r.n)return"p2ms(".concat(r.m," of ").concat(r.n,")")})),t.validate){if(e.output){if(a(e.output),!RL.typeforce.Number(i[0]))throw new TypeError("Output is invalid");if(!RL.typeforce.Number(i[i.length-2]))throw new TypeError("Output is invalid");if(i[i.length-1]!==HL.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(r.m<=0||r.n>16||r.m>r.n||r.n!==i.length-3)throw new TypeError("Output is invalid");if(!r.pubkeys.every((function(e){return(0,RL.isPoint)(e)})))throw new TypeError("Output is invalid");if(void 0!==e.m&&e.m!==r.m)throw new TypeError("m mismatch");if(void 0!==e.n&&e.n!==r.n)throw new TypeError("n mismatch");if(e.pubkeys&&!jL(e.pubkeys,r.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(r.n=e.pubkeys.length,r.n<r.m)throw new TypeError("Pubkey count cannot be less than m")}if(e.signatures){if(e.signatures.length<r.m)throw new TypeError("Not enough signatures provided");if(e.signatures.length>r.m)throw new TypeError("Too many signatures provided")}if(e.input){if(e.input[0]!==HL.OP_0)throw new TypeError("Input is invalid");if(0===r.signatures.length||!r.signatures.every(n))throw new TypeError("Input has invalid signature(s)");if(e.signatures&&!jL(e.signatures,r.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(r,e)};var GL={};Object.defineProperty(GL,"__esModule",{value:!0}),GL.p2pk=void 0;var qL=EU,VL=kU,zL=OU,JL=_L,YL=VL.OPS;GL.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,zL.typeforce)({network:zL.typeforce.maybe(zL.typeforce.Object),output:zL.typeforce.maybe(zL.typeforce.Buffer),pubkey:zL.typeforce.maybe(zL.isPoint),signature:zL.typeforce.maybe(VL.isCanonicalScriptSignature),input:zL.typeforce.maybe(zL.typeforce.Buffer)},e);var n=JL.value((function(){return VL.decompile(e.input)})),r={name:"p2pk",network:e.network||qL.bitcoin};if(JL.prop(r,"output",(function(){if(e.pubkey)return VL.compile([e.pubkey,YL.OP_CHECKSIG])})),JL.prop(r,"pubkey",(function(){if(e.output)return e.output.slice(1,-1)})),JL.prop(r,"signature",(function(){if(e.input)return n()[0]})),JL.prop(r,"input",(function(){if(e.signature)return VL.compile([e.signature])})),JL.prop(r,"witness",(function(){if(r.input)return[]})),t.validate){if(e.output){if(e.output[e.output.length-1]!==YL.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!(0,zL.isPoint)(r.pubkey))throw new TypeError("Output pubkey is invalid");if(e.pubkey&&!e.pubkey.equals(r.pubkey))throw new TypeError("Pubkey mismatch")}if(e.signature&&e.input&&!e.input.equals(r.input))throw new TypeError("Signature mismatch");if(e.input){if(1!==n().length)throw new TypeError("Input is invalid");if(!VL.isCanonicalScriptSignature(r.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(r,e)};var XL={},WL={},ZL={exports:{}},$L={},eM=Do(eh),tM=eM.EventEmitter;function nM(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function rM(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var iM=Fa.Buffer,oM=sb.inspect,aM=oM&&oM.custom||"inspect";function sM(e,t,n){iM.prototype.copy.call(e,t,n)}var uM=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}var t;return t=[{key:"push",value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n}},{key:"concat",value:function(e){if(0===this.length)return iM.alloc(0);for(var t=iM.allocUnsafe(e>>>0),n=this.head,r=0;n;)sM(n.data,t,r),r+=n.data.length,n=n.next;return t}},{key:"consume",value:function(e,t){var n;return e<this.head.data.length?(n=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):n=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),n}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,n=1,r=t.data;for(e-=r.length;t=t.next;){var i=t.data,o=e>i.length?i.length:e;if(o===i.length?r+=i:r+=i.slice(0,e),0==(e-=o)){o===i.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(o));break}++n}return this.length-=n,r}},{key:"_getBuffer",value:function(e){var t=iM.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var i=n.data,o=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,o),0==(e-=o)){o===i.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=i.slice(o));break}++r}return this.length-=r,t}},{key:aM,value:function(e,t){return oM(this,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?nM(Object(n),!0).forEach((function(t){rM(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):nM(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},t,{depth:0,customInspect:!1}))}}],t&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(e.prototype,t),e}();function lM(e,t){cM(e,t),AM(e)}function AM(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function cM(e,t){e.emit("error",t)}var hM={destroy:function(e,t){var n=this,r=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return r||i?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,Xl(cM,this,e)):Xl(cM,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,(function(e){!t&&e?n._writableState?n._writableState.errorEmitted?Xl(AM,n):(n._writableState.errorEmitted=!0,Xl(lM,n,e)):Xl(lM,n,e):t?(Xl(AM,n),t(e)):Xl(AM,n)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(e,t){var n=e._readableState,r=e._writableState;n&&n.autoDestroy||r&&r.autoDestroy?e.destroy(t):e.emit("error",t)}},fM={},dM={};function pM(e,t,n){n||(n=Error);var r=function(e){var n,r;function i(n,r,i){return e.call(this,function(e,n,r){return"string"==typeof t?t:t(e,n,r)}(n,r,i))||this}return r=e,(n=i).prototype=Object.create(r.prototype),n.prototype.constructor=n,n.__proto__=r,i}(n);r.prototype.name=n.name,r.prototype.code=e,dM[e]=r}function gM(e,t){if(Array.isArray(e)){var n=e.length;return e=e.map((function(e){return String(e)})),n>2?"one of ".concat(t," ").concat(e.slice(0,n-1).join(", "),", or ")+e[n-1]:2===n?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}pM("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),pM("ERR_INVALID_ARG_TYPE",(function(e,t,n){var r,o,a;if("string"==typeof t&&(o="not ",t.substr(0,o.length)===o)?(r="must not be",t=t.replace(/^not /,"")):r="must be",function(e,t,n){return(void 0===n||n>e.length)&&(n=e.length),e.substring(n-t.length,n)===t}(e," argument"))a="The ".concat(e," ").concat(r," ").concat(gM(t,"type"));else{var s=function(e,t,n){return"number"!=typeof n&&(n=0),!(n+".".length>e.length)&&-1!==e.indexOf(".",n)}(e)?"property":"argument";a='The "'.concat(e,'" ').concat(s," ").concat(r," ").concat(gM(t,"type"))}return a+". Received type ".concat(i(n))}),TypeError),pM("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),pM("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),pM("ERR_STREAM_PREMATURE_CLOSE","Premature close"),pM("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),pM("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),pM("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),pM("ERR_STREAM_WRITE_AFTER_END","write after end"),pM("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),pM("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),pM("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),fM.codes=dM;var vM=fM.codes.ERR_INVALID_OPT_VALUE,yM=function(e,t,n,r){var i=function(e,t,n){return null!=e.highWaterMark?e.highWaterMark:t?e[n]:null}(t,r,n);if(null!=i){if(!isFinite(i)||Math.floor(i)!==i||i<0)throw new vM(r?n:"highWaterMark",i);return Math.floor(i)}return e.objectMode?16:16384},mM={},wM=jN.exports.Buffer,bM=wM.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function IM(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(wM.isEncoding===bM||!bM(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=CM,this.end=xM,t=4;break;case"utf8":this.fillLast=EM,t=4;break;case"base64":this.text=kM,this.end=SM,t=3;break;default:return this.write=QM,void(this.end=_M)}this.lastNeed=0,this.lastTotal=0,this.lastChar=wM.allocUnsafe(t)}function BM(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function EM(e){var t=this.lastTotal-this.lastNeed,n=function(e,t,n){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==n?n:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function CM(e,t){if((e.length-t)%2==0){var n=e.toString("utf16le",t);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function xM(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function kM(e,t){var n=(e.length-t)%3;return 0===n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-n))}function SM(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function QM(e){return e.toString(this.encoding)}function _M(e){return e&&e.length?this.write(e):""}mM.StringDecoder=IM,IM.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||""},IM.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},IM.prototype.text=function(e,t){var n=function(e,t,n){var r=t.length-1;if(r<n)return 0;var i=BM(t[r]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--r<n||-2===i?0:(i=BM(t[r]))>=0?(i>0&&(e.lastNeed=i-2),i):--r<n||-2===i?0:(i=BM(t[r]))>=0?(i>0&&(2===i?i=0:e.lastNeed=i-3),i):0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var r=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString("utf8",t,r)},IM.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};var NM=fM.codes.ERR_STREAM_PREMATURE_CLOSE;function DM(){}var FM,PM=function e(t,n,r){if("function"==typeof n)return e(t,null,n);n||(n={}),r=function(e){var t=!1;return function(){if(!t){t=!0;for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];e.apply(this,r)}}}(r||DM);var i=n.readable||!1!==n.readable&&t.readable,o=n.writable||!1!==n.writable&&t.writable,a=function(){t.writable||u()},s=t._writableState&&t._writableState.finished,u=function(){o=!1,s=!0,i||r.call(t)},l=t._readableState&&t._readableState.endEmitted,A=function(){i=!1,l=!0,o||r.call(t)},c=function(e){r.call(t,e)},h=function(){var e;return i&&!l?(t._readableState&&t._readableState.ended||(e=new NM),r.call(t,e)):o&&!s?(t._writableState&&t._writableState.ended||(e=new NM),r.call(t,e)):void 0},f=function(){t.req.on("finish",u)};return function(e){return e.setHeader&&"function"==typeof e.abort}(t)?(t.on("complete",u),t.on("abort",h),t.req?f():t.on("request",f)):o&&!t._writableState&&(t.on("end",a),t.on("close",a)),t.on("end",A),t.on("finish",u),!1!==n.error&&t.on("error",c),t.on("close",h),function(){t.removeListener("complete",u),t.removeListener("abort",h),t.removeListener("request",f),t.req&&t.req.removeListener("finish",u),t.removeListener("end",a),t.removeListener("close",a),t.removeListener("finish",u),t.removeListener("end",A),t.removeListener("error",c),t.removeListener("close",h)}};function UM(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var LM=PM,MM=Symbol("lastResolve"),TM=Symbol("lastReject"),RM=Symbol("error"),OM=Symbol("ended"),HM=Symbol("lastPromise"),KM=Symbol("handlePromise"),jM=Symbol("stream");function GM(e,t){return{value:e,done:t}}function qM(e){var t=e[MM];if(null!==t){var n=e[jM].read();null!==n&&(e[HM]=null,e[MM]=null,e[TM]=null,t(GM(n,!1)))}}function VM(e){Xl(qM,e)}var zM=Object.getPrototypeOf((function(){})),JM=Object.setPrototypeOf((FM={get stream(){return this[jM]},next:function(){var e=this,t=this[RM];if(null!==t)return Promise.reject(t);if(this[OM])return Promise.resolve(GM(void 0,!0));if(this[jM].destroyed)return new Promise((function(t,n){Xl((function(){e[RM]?n(e[RM]):t(GM(void 0,!0))}))}));var n,r=this[HM];if(r)n=new Promise(function(e,t){return function(n,r){e.then((function(){t[OM]?n(GM(void 0,!0)):t[KM](n,r)}),r)}}(r,this));else{var i=this[jM].read();if(null!==i)return Promise.resolve(GM(i,!1));n=new Promise(this[KM])}return this[HM]=n,n}},UM(FM,Symbol.asyncIterator,(function(){return this})),UM(FM,"return",(function(){var e=this;return new Promise((function(t,n){e[jM].destroy(null,(function(e){e?n(e):t(GM(void 0,!0))}))}))})),FM),zM),YM=function(e){var t,n=Object.create(JM,(UM(t={},jM,{value:e,writable:!0}),UM(t,MM,{value:null,writable:!0}),UM(t,TM,{value:null,writable:!0}),UM(t,RM,{value:null,writable:!0}),UM(t,OM,{value:e._readableState.endEmitted,writable:!0}),UM(t,KM,{value:function(e,t){var r=n[jM].read();r?(n[HM]=null,n[MM]=null,n[TM]=null,e(GM(r,!1))):(n[MM]=e,n[TM]=t)},writable:!0}),t));return n[HM]=null,LM(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=n[TM];return null!==t&&(n[HM]=null,n[MM]=null,n[TM]=null,t(e)),void(n[RM]=e)}var r=n[MM];null!==r&&(n[HM]=null,n[MM]=null,n[TM]=null,r(GM(void 0,!0))),n[OM]=!0})),e.on("readable",VM.bind(null,n)),n},XM=function(){throw new Error("Readable.from is not available in the browser")},WM=$L;WM.Readable=yT,yT.ReadableState=vT,eM.EventEmitter;var ZM,$M=function(e,t){return e.listeners(t).length},eT=tM,tT=Fa.Buffer,nT=No.Uint8Array||function(){},rT=sb;ZM=rT&&rT.debuglog?rT.debuglog("stream"):function(){};var iT,oT,aT,sT=uM,uT=hM,lT=yM,AT=fM.codes,cT=AT.ERR_INVALID_ARG_TYPE,hT=AT.ERR_STREAM_PUSH_AFTER_EOF,fT=AT.ERR_METHOD_NOT_IMPLEMENTED,dT=AT.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;KI.exports(yT,eT);var pT=uT.errorOrDestroy,gT=["error","close","destroy","pause","resume"];function vT(e,t,n){e=e||{},"boolean"!=typeof n&&(n=t instanceof WM.Duplex),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=lT(this,e,"readableHighWaterMark",n),this.buffer=new sT,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(iT||(iT=mM.StringDecoder),this.decoder=new iT(e.encoding),this.encoding=e.encoding)}function yT(e){if(!(this instanceof yT))return new yT(e);var t=this instanceof WM.Duplex;this._readableState=new vT(e,this,t),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),eT.call(this)}function mT(e,t,n,r,i){ZM("readableAddChunk",t);var o,a=e._readableState;if(null===t)a.reading=!1,function(e,t){if(ZM("onEofChunk"),!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,t.sync?IT(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,BT(e)))}}(e,a);else if(i||(o=function(e,t){var n,r;return r=t,tT.isBuffer(r)||r instanceof nT||"string"==typeof t||void 0===t||e.objectMode||(n=new cT("chunk",["string","Buffer","Uint8Array"],t)),n}(a,t)),o)pT(e,o);else if(a.objectMode||t&&t.length>0)if("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===tT.prototype||(t=function(e){return tT.from(e)}(t)),r)a.endEmitted?pT(e,new dT):wT(e,a,t,!0);else if(a.ended)pT(e,new hT);else{if(a.destroyed)return!1;a.reading=!1,a.decoder&&!n?(t=a.decoder.write(t),a.objectMode||0!==t.length?wT(e,a,t,!1):ET(e,a)):wT(e,a,t,!1)}else r||(a.reading=!1,ET(e,a));return!a.ended&&(a.length<a.highWaterMark||0===a.length)}function wT(e,t,n,r){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",n)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&IT(e)),ET(e,t)}function bT(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=function(e){return e>=1073741824?e=1073741824:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function IT(e){var t=e._readableState;ZM("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(ZM("emitReadable",t.flowing),t.emittedReadable=!0,Xl(BT,e))}function BT(e){var t=e._readableState;ZM("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,QT(e)}function ET(e,t){t.readingMore||(t.readingMore=!0,Xl(CT,e,t))}function CT(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){var n=t.length;if(ZM("maybeReadMore read 0"),e.read(0),n===t.length)break}t.readingMore=!1}function xT(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function kT(e){ZM("readable nexttick read 0"),e.read(0)}function ST(e,t){ZM("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),QT(e),t.flowing&&!t.reading&&e.read(0)}function QT(e){var t=e._readableState;for(ZM("flow",t.flowing);t.flowing&&null!==e.read(););}function _T(e,t){return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n);var n}function NT(e){var t=e._readableState;ZM("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,Xl(DT,t,e))}function DT(e,t){if(ZM("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var n=t._writableState;(!n||n.autoDestroy&&n.finished)&&t.destroy()}}function FT(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}Object.defineProperty(yT.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),yT.prototype.destroy=uT.destroy,yT.prototype._undestroy=uT.undestroy,yT.prototype._destroy=function(e,t){t(e)},yT.prototype.push=function(e,t){var n,r=this._readableState;return r.objectMode?n=!0:"string"==typeof e&&((t=t||r.defaultEncoding)!==r.encoding&&(e=tT.from(e,t),t=""),n=!0),mT(this,e,t,!1,n)},yT.prototype.unshift=function(e){return mT(this,e,null,!0,!1)},yT.prototype.isPaused=function(){return!1===this._readableState.flowing},yT.prototype.setEncoding=function(e){iT||(iT=mM.StringDecoder);var t=new iT(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,r="";null!==n;)r+=t.write(n.data),n=n.next;return this._readableState.buffer.clear(),""!==r&&this._readableState.buffer.push(r),this._readableState.length=r.length,this},yT.prototype.read=function(e){ZM("read",e),e=parseInt(e,10);var t=this._readableState,n=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&((0!==t.highWaterMark?t.length>=t.highWaterMark:t.length>0)||t.ended))return ZM("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?NT(this):IT(this),null;if(0===(e=bT(e,t))&&t.ended)return 0===t.length&&NT(this),null;var r,i=t.needReadable;return ZM("need readable",i),(0===t.length||t.length-e<t.highWaterMark)&&ZM("length less than watermark",i=!0),t.ended||t.reading?ZM("reading or ended",i=!1):i&&(ZM("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=bT(n,t))),null===(r=e>0?_T(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&NT(this)),null!==r&&this.emit("data",r),r},yT.prototype._read=function(e){pT(this,new fT("_read()"))},yT.prototype.pipe=function(e,t){var n=this,r=this._readableState;switch(r.pipesCount){case 0:r.pipes=e;break;case 1:r.pipes=[r.pipes,e];break;default:r.pipes.push(e)}r.pipesCount+=1,ZM("pipe count=%d opts=%j",r.pipesCount,t);var i=t&&!1===t.end||e===lA.stdout||e===lA.stderr?h:o;function o(){ZM("onend"),e.end()}r.endEmitted?Xl(i):n.once("end",i),e.on("unpipe",(function t(i,f){ZM("onunpipe"),i===n&&f&&!1===f.hasUnpiped&&(f.hasUnpiped=!0,ZM("cleanup"),e.removeListener("close",A),e.removeListener("finish",c),e.removeListener("drain",a),e.removeListener("error",l),e.removeListener("unpipe",t),n.removeListener("end",o),n.removeListener("end",h),n.removeListener("data",u),s=!0,!r.awaitDrain||e._writableState&&!e._writableState.needDrain||a())}));var a=function(e){return function(){var t=e._readableState;ZM("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&$M(e,"data")&&(t.flowing=!0,QT(e))}}(n);e.on("drain",a);var s=!1;function u(t){ZM("ondata");var i=e.write(t);ZM("dest.write",i),!1===i&&((1===r.pipesCount&&r.pipes===e||r.pipesCount>1&&-1!==FT(r.pipes,e))&&!s&&(ZM("false write response, pause",r.awaitDrain),r.awaitDrain++),n.pause())}function l(t){ZM("onerror",t),h(),e.removeListener("error",l),0===$M(e,"error")&&pT(e,t)}function A(){e.removeListener("finish",c),h()}function c(){ZM("onfinish"),e.removeListener("close",A),h()}function h(){ZM("unpipe"),n.unpipe(e)}return n.on("data",u),function(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}(e,"error",l),e.once("close",A),e.once("finish",c),e.emit("pipe",n),r.flowing||(ZM("pipe resume"),n.resume()),e},yT.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n)),this;if(!e){var r=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)r[o].emit("unpipe",this,{hasUnpiped:!1});return this}var a=FT(t.pipes,e);return-1===a||(t.pipes.splice(a,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,n)),this},yT.prototype.on=function(e,t){var n=eT.prototype.on.call(this,e,t),r=this._readableState;return"data"===e?(r.readableListening=this.listenerCount("readable")>0,!1!==r.flowing&&this.resume()):"readable"===e&&(r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.flowing=!1,r.emittedReadable=!1,ZM("on readable",r.length,r.reading),r.length?IT(this):r.reading||Xl(kT,this))),n},yT.prototype.addListener=yT.prototype.on,yT.prototype.removeListener=function(e,t){var n=eT.prototype.removeListener.call(this,e,t);return"readable"===e&&Xl(xT,this),n},yT.prototype.removeAllListeners=function(e){var t=eT.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||Xl(xT,this),t},yT.prototype.resume=function(){var e=this._readableState;return e.flowing||(ZM("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,Xl(ST,e,t))}(this,e)),e.paused=!1,this},yT.prototype.pause=function(){return ZM("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(ZM("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},yT.prototype.wrap=function(e){var t=this,n=this._readableState,r=!1;for(var i in e.on("end",(function(){if(ZM("wrapped end"),n.decoder&&!n.ended){var e=n.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(i){ZM("wrapped data"),n.decoder&&(i=n.decoder.write(i)),n.objectMode&&null==i||(n.objectMode||i&&i.length)&&(t.push(i)||(r=!0,e.pause()))})),e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var o=0;o<gT.length;o++)e.on(gT[o],this.emit.bind(this,gT[o]));return this._read=function(t){ZM("wrapped _read",t),r&&(r=!1,e.resume())},this},"function"==typeof Symbol&&(yT.prototype[Symbol.asyncIterator]=function(){return void 0===oT&&(oT=YM),oT(this)}),Object.defineProperty(yT.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(yT.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(yT.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),yT._fromList=_T,Object.defineProperty(yT.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(yT.from=function(e,t){return void 0===aT&&(aT=XM),aT(yT,e,t)});function PT(e){try{if(!No.localStorage)return!1}catch(e){return!1}var t=No.localStorage[e];return null!=t&&"true"===String(t).toLowerCase()}var UT=$L;function LT(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,n){var r=e.entry;for(e.entry=null;r;){var i=r.callback;t.pendingcb--,i(undefined),r=r.next}t.corkedRequestsFree.next=e}(t,e)}}UT.Writable=nR,nR.WritableState=tR;var MT,TT=function(e,t){if(PT("noDeprecation"))return e;var n=!1;return function(){if(!n){if(PT("throwDeprecation"))throw new Error(t);PT("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}},RT=tM,OT=Fa.Buffer,HT=No.Uint8Array||function(){},KT=hM,jT=yM,GT=fM.codes,qT=GT.ERR_INVALID_ARG_TYPE,VT=GT.ERR_METHOD_NOT_IMPLEMENTED,zT=GT.ERR_MULTIPLE_CALLBACK,JT=GT.ERR_STREAM_CANNOT_PIPE,YT=GT.ERR_STREAM_DESTROYED,XT=GT.ERR_STREAM_NULL_VALUES,WT=GT.ERR_STREAM_WRITE_AFTER_END,ZT=GT.ERR_UNKNOWN_ENCODING,$T=KT.errorOrDestroy;function eR(){}function tR(e,t,n){e=e||{},"boolean"!=typeof n&&(n=t instanceof UT.Duplex),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=jT(this,e,"writableHighWaterMark",n),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var r=!1===e.decodeStrings;this.decodeStrings=!r,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var n=e._writableState,r=n.sync,i=n.writecb;if("function"!=typeof i)throw new zT;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(n),t)!function(e,t,n,r,i){--t.pendingcb,n?(Xl(i,r),Xl(uR,e,t),e._writableState.errorEmitted=!0,$T(e,r)):(i(r),e._writableState.errorEmitted=!0,$T(e,r),uR(e,t))}(e,n,r,t,i);else{var o=aR(n)||e.destroyed;o||n.corked||n.bufferProcessing||!n.bufferedRequest||oR(e,n),r?Xl(iR,e,n,o,i):iR(e,n,o,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new LT(this)}function nR(e){var t=this instanceof UT.Duplex;if(!t&&!MT.call(nR,this))return new nR(e);this._writableState=new tR(e,this,t),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),RT.call(this)}function rR(e,t,n,r,i,o,a){t.writelen=r,t.writecb=a,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new YT("write")):n?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function iR(e,t,n,r){n||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,r(),uR(e,t)}function oR(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=t.bufferedRequestCount,i=new Array(r),o=t.corkedRequestsFree;o.entry=n;for(var a=0,s=!0;n;)i[a]=n,n.isBuf||(s=!1),n=n.next,a+=1;i.allBuffers=s,rR(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new LT(t),t.bufferedRequestCount=0}else{for(;n;){var u=n.chunk,l=n.encoding,A=n.callback;if(rR(e,t,!1,t.objectMode?1:u.length,u,l,A),n=n.next,t.bufferedRequestCount--,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function aR(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function sR(e,t){e._final((function(n){t.pendingcb--,n&&$T(e,n),t.prefinished=!0,e.emit("prefinish"),uR(e,t)}))}function uR(e,t){var n=aR(t);if(n&&(function(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,Xl(sR,e,t)))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var r=e._readableState;(!r||r.autoDestroy&&r.endEmitted)&&e.destroy()}return n}KI.exports(nR,RT),tR.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(tR.prototype,"buffer",{get:TT((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(MT=Function.prototype[Symbol.hasInstance],Object.defineProperty(nR,Symbol.hasInstance,{value:function(e){return!!MT.call(this,e)||this===nR&&e&&e._writableState instanceof tR}})):MT=function(e){return e instanceof this},nR.prototype.pipe=function(){$T(this,new JT)},nR.prototype.write=function(e,t,n){var r,i=this._writableState,o=!1,a=!i.objectMode&&(r=e,OT.isBuffer(r)||r instanceof HT);return a&&!OT.isBuffer(e)&&(e=function(e){return OT.from(e)}(e)),"function"==typeof t&&(n=t,t=null),a?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof n&&(n=eR),i.ending?function(e,t){var n=new WT;$T(e,n),Xl(t,n)}(this,n):(a||function(e,t,n,r){var i;return null===n?i=new XT:"string"==typeof n||t.objectMode||(i=new qT("chunk",["string","Buffer"],n)),!i||($T(e,i),Xl(r,i),!1)}(this,i,e,n))&&(i.pendingcb++,o=function(e,t,n,r,i,o){if(!n){var a=function(e,t,n){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=OT.from(t,n)),t}(t,r,i);r!==a&&(n=!0,i="buffer",r=a)}var s=t.objectMode?1:r.length;t.length+=s;var u=t.length<t.highWaterMark;if(u||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:i,isBuf:n,callback:o,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else rR(e,t,!1,s,r,i,o);return u}(this,i,a,e,t,n)),o},nR.prototype.cork=function(){this._writableState.corked++},nR.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||oR(this,e))},nR.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new ZT(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(nR.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(nR.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),nR.prototype._write=function(e,t,n){n(new VT("_write()"))},nR.prototype._writev=null,nR.prototype.end=function(e,t,n){var r=this._writableState;return"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!=e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||function(e,t,n){t.ending=!0,uR(e,t),n&&(t.finished?Xl(n):e.once("finish",n)),t.ended=!0,e.writable=!1}(this,r,n),this},Object.defineProperty(nR.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(nR.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),nR.prototype.destroy=KT.destroy,nR.prototype._undestroy=KT.undestroy,nR.prototype._destroy=function(e,t){t(e)};var lR=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t},AR=$L;AR.Duplex=dR,KI.exports(dR,AR.Readable);for(var cR=lR(AR.Writable.prototype),hR=0;hR<cR.length;hR++){var fR=cR[hR];dR.prototype[fR]||(dR.prototype[fR]=AR.Writable.prototype[fR])}function dR(e){if(!(this instanceof dR))return new dR(e);AR.Readable.call(this,e),AR.Writable.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",pR)))}function pR(){this._writableState.ended||Xl(gR,this)}function gR(e){e.end()}Object.defineProperty(dR.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(dR.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(dR.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(dR.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}});var vR=$L;vR.Transform=ER;var yR=fM.codes,mR=yR.ERR_METHOD_NOT_IMPLEMENTED,wR=yR.ERR_MULTIPLE_CALLBACK,bR=yR.ERR_TRANSFORM_ALREADY_TRANSFORMING,IR=yR.ERR_TRANSFORM_WITH_LENGTH_0;function BR(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new wR);n.writechunk=null,n.writecb=null,null!=t&&this.push(t),r(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function ER(e){if(!(this instanceof ER))return new ER(e);vR.Duplex.call(this,e),this._transformState={afterTransform:BR.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",CR)}function CR(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?xR(this,null,null):this._flush((function(t,n){xR(e,t,n)}))}function xR(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new IR;if(e._transformState.transforming)throw new bR;return e.push(null)}KI.exports(ER,vR.Duplex),ER.prototype.push=function(e,t){return this._transformState.needTransform=!1,vR.Duplex.prototype.push.call(this,e,t)},ER.prototype._transform=function(e,t,n){n(new mR("_transform()"))},ER.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},ER.prototype._read=function(e){var t=this._transformState;null===t.writechunk||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))},ER.prototype._destroy=function(e,t){vR.Duplex.prototype._destroy.call(this,e,(function(e){t(e)}))};var kR,SR=$L;function QR(e){if(!(this instanceof QR))return new QR(e);Transform.call(this,e)}SR.PassThrough=QR,KI.exports(QR,SR.Transform),QR.prototype._transform=function(e,t,n){n(null,e)};var _R=fM.codes,NR=_R.ERR_MISSING_ARGS,DR=_R.ERR_STREAM_DESTROYED;function FR(e){if(e)throw e}function PR(e,t,n,r){r=function(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}(r);var i=!1;e.on("close",(function(){i=!0})),void 0===kR&&(kR=PM),kR(e,{readable:t,writable:n},(function(e){if(e)return r(e);i=!0,r()}));var o=!1;return function(t){if(!i&&!o)return o=!0,function(e){return e.setHeader&&"function"==typeof e.abort}(e)?e.abort():"function"==typeof e.destroy?e.destroy():void r(t||new DR("pipe"))}}function UR(e){e()}function LR(e,t){return e.pipe(t)}function MR(e){return e.length?"function"!=typeof e[e.length-1]?FR:e.pop():FR}var TR=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r,i=MR(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new NR("streams");var o=t.map((function(e,n){var a=n<t.length-1;return PR(e,a,n>0,(function(e){r||(r=e),e&&o.forEach(UR),a||(o.forEach(UR),i(r))}))}));return t.reduce(LR)};!function(e,t){var n=$L;(t=ZL.exports=n.Readable).Stream=n.Readable,t.Readable=n.Readable,t.Writable=n.Writable,t.Duplex=n.Duplex,t.Transform=n.Transform,t.PassThrough=n.PassThrough,t.finished=PM,t.pipeline=TR}(0,ZL.exports);var RR=jN.exports.Buffer,OR=ZL.exports;function HR(e){OR.Stream.Transform.call(this),this._block=RR.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}(0,KI.exports)(HR,OR.Stream.Transform),HR.prototype._transform=function(e,t,n){var r=null;try{this.update(e,t)}catch(e){r=e}n(r)},HR.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)},HR.prototype.update=function(e,t){if(function(e,t){if(!RR.isBuffer(e)&&"string"!=typeof e)throw new TypeError("Data must be a string or a buffer")}(e),this._finalized)throw new Error("Digest already called");RR.isBuffer(e)||(e=RR.from(e,t));for(var n=this._block,r=0;this._blockOffset+e.length-r>=this._blockSize;){for(var i=this._blockOffset;i<this._blockSize;)n[i++]=e[r++];this._update(),this._blockOffset=0}for(;r<e.length;)n[this._blockOffset++]=e[r++];for(var o=0,a=8*e.length;a>0;++o)this._length[o]+=a,(a=this._length[o]/4294967296|0)>0&&(this._length[o]-=4294967296*a);return this},HR.prototype._update=function(){throw new Error("_update is not implemented")},HR.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var n=0;n<4;++n)this._length[n]=0;return t},HR.prototype._digest=function(){throw new Error("_digest is not implemented")};var KR=HR,jR=KI.exports,GR=KR,qR=jN.exports.Buffer,VR=new Array(16);function zR(){GR.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function JR(e,t){return e<<t|e>>>32-t}function YR(e,t,n,r,i,o,a){return JR(e+(t&n|~t&r)+i+o|0,a)+t|0}function XR(e,t,n,r,i,o,a){return JR(e+(t&r|n&~r)+i+o|0,a)+t|0}function WR(e,t,n,r,i,o,a){return JR(e+(t^n^r)+i+o|0,a)+t|0}function ZR(e,t,n,r,i,o,a){return JR(e+(n^(t|~r))+i+o|0,a)+t|0}jR(zR,GR),zR.prototype._update=function(){for(var e=VR,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var n=this._a,r=this._b,i=this._c,o=this._d;n=YR(n,r,i,o,e[0],3614090360,7),o=YR(o,n,r,i,e[1],3905402710,12),i=YR(i,o,n,r,e[2],606105819,17),r=YR(r,i,o,n,e[3],3250441966,22),n=YR(n,r,i,o,e[4],4118548399,7),o=YR(o,n,r,i,e[5],1200080426,12),i=YR(i,o,n,r,e[6],2821735955,17),r=YR(r,i,o,n,e[7],4249261313,22),n=YR(n,r,i,o,e[8],1770035416,7),o=YR(o,n,r,i,e[9],2336552879,12),i=YR(i,o,n,r,e[10],4294925233,17),r=YR(r,i,o,n,e[11],2304563134,22),n=YR(n,r,i,o,e[12],1804603682,7),o=YR(o,n,r,i,e[13],4254626195,12),i=YR(i,o,n,r,e[14],2792965006,17),n=XR(n,r=YR(r,i,o,n,e[15],1236535329,22),i,o,e[1],4129170786,5),o=XR(o,n,r,i,e[6],3225465664,9),i=XR(i,o,n,r,e[11],643717713,14),r=XR(r,i,o,n,e[0],3921069994,20),n=XR(n,r,i,o,e[5],3593408605,5),o=XR(o,n,r,i,e[10],38016083,9),i=XR(i,o,n,r,e[15],3634488961,14),r=XR(r,i,o,n,e[4],3889429448,20),n=XR(n,r,i,o,e[9],568446438,5),o=XR(o,n,r,i,e[14],3275163606,9),i=XR(i,o,n,r,e[3],4107603335,14),r=XR(r,i,o,n,e[8],1163531501,20),n=XR(n,r,i,o,e[13],2850285829,5),o=XR(o,n,r,i,e[2],4243563512,9),i=XR(i,o,n,r,e[7],1735328473,14),n=WR(n,r=XR(r,i,o,n,e[12],2368359562,20),i,o,e[5],4294588738,4),o=WR(o,n,r,i,e[8],2272392833,11),i=WR(i,o,n,r,e[11],1839030562,16),r=WR(r,i,o,n,e[14],4259657740,23),n=WR(n,r,i,o,e[1],2763975236,4),o=WR(o,n,r,i,e[4],1272893353,11),i=WR(i,o,n,r,e[7],4139469664,16),r=WR(r,i,o,n,e[10],3200236656,23),n=WR(n,r,i,o,e[13],681279174,4),o=WR(o,n,r,i,e[0],3936430074,11),i=WR(i,o,n,r,e[3],3572445317,16),r=WR(r,i,o,n,e[6],76029189,23),n=WR(n,r,i,o,e[9],3654602809,4),o=WR(o,n,r,i,e[12],3873151461,11),i=WR(i,o,n,r,e[15],530742520,16),n=ZR(n,r=WR(r,i,o,n,e[2],3299628645,23),i,o,e[0],4096336452,6),o=ZR(o,n,r,i,e[7],1126891415,10),i=ZR(i,o,n,r,e[14],2878612391,15),r=ZR(r,i,o,n,e[5],4237533241,21),n=ZR(n,r,i,o,e[12],1700485571,6),o=ZR(o,n,r,i,e[3],2399980690,10),i=ZR(i,o,n,r,e[10],4293915773,15),r=ZR(r,i,o,n,e[1],2240044497,21),n=ZR(n,r,i,o,e[8],1873313359,6),o=ZR(o,n,r,i,e[15],4264355552,10),i=ZR(i,o,n,r,e[6],2734768916,15),r=ZR(r,i,o,n,e[13],1309151649,21),n=ZR(n,r,i,o,e[4],4149444226,6),o=ZR(o,n,r,i,e[11],3174756917,10),i=ZR(i,o,n,r,e[2],718787259,15),r=ZR(r,i,o,n,e[9],3951481745,21),this._a=this._a+n|0,this._b=this._b+r|0,this._c=this._c+i|0,this._d=this._d+o|0},zR.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=qR.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e};var $R=zR,eO=Fa.Buffer,tO=KI.exports,nO=KR,rO=new Array(16),iO=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],oO=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],aO=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],sO=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],uO=[0,1518500249,1859775393,2400959708,2840853838],lO=[1352829926,1548603684,1836072691,2053994217,0];function AO(){nO.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function cO(e,t){return e<<t|e>>>32-t}function hO(e,t,n,r,i,o,a,s){return cO(e+(t^n^r)+o+a|0,s)+i|0}function fO(e,t,n,r,i,o,a,s){return cO(e+(t&n|~t&r)+o+a|0,s)+i|0}function dO(e,t,n,r,i,o,a,s){return cO(e+((t|~n)^r)+o+a|0,s)+i|0}function pO(e,t,n,r,i,o,a,s){return cO(e+(t&r|n&~r)+o+a|0,s)+i|0}function gO(e,t,n,r,i,o,a,s){return cO(e+(t^(n|~r))+o+a|0,s)+i|0}tO(AO,nO),AO.prototype._update=function(){for(var e=rO,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);for(var n=0|this._a,r=0|this._b,i=0|this._c,o=0|this._d,a=0|this._e,s=0|this._a,u=0|this._b,l=0|this._c,A=0|this._d,c=0|this._e,h=0;h<80;h+=1){var f,d;h<16?(f=hO(n,r,i,o,a,e[iO[h]],uO[0],aO[h]),d=gO(s,u,l,A,c,e[oO[h]],lO[0],sO[h])):h<32?(f=fO(n,r,i,o,a,e[iO[h]],uO[1],aO[h]),d=pO(s,u,l,A,c,e[oO[h]],lO[1],sO[h])):h<48?(f=dO(n,r,i,o,a,e[iO[h]],uO[2],aO[h]),d=dO(s,u,l,A,c,e[oO[h]],lO[2],sO[h])):h<64?(f=pO(n,r,i,o,a,e[iO[h]],uO[3],aO[h]),d=fO(s,u,l,A,c,e[oO[h]],lO[3],sO[h])):(f=gO(n,r,i,o,a,e[iO[h]],uO[4],aO[h]),d=hO(s,u,l,A,c,e[oO[h]],lO[4],sO[h])),n=a,a=o,o=cO(i,10),i=r,r=f,s=c,c=A,A=cO(l,10),l=u,u=d}var p=this._b+i+A|0;this._b=this._c+o+c|0,this._c=this._d+a+s|0,this._d=this._e+n+u|0,this._e=this._a+r+l|0,this._a=p},AO.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=eO.alloc?eO.alloc(20):new eO(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e};var vO=AO,yO={exports:{}},mO=jN.exports.Buffer;function wO(e,t){this._block=mO.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}wO.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=mO.from(e,t));for(var n=this._block,r=this._blockSize,i=e.length,o=this._len,a=0;a<i;){for(var s=o%r,u=Math.min(i-a,r-s),l=0;l<u;l++)n[s+l]=e[a+l];a+=u,(o+=u)%r==0&&this._update(n)}return this._len+=i,this},wO.prototype.digest=function(e){var t=this._len%this._blockSize;this._block[t]=128,this._block.fill(0,t+1),t>=this._finalSize&&(this._update(this._block),this._block.fill(0));var n=8*this._len;if(n<=4294967295)this._block.writeUInt32BE(n,this._blockSize-4);else{var r=(4294967295&n)>>>0,i=(n-r)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(r,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o},wO.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var bO=wO,IO=KI.exports,BO=bO,EO=jN.exports.Buffer,CO=[1518500249,1859775393,-1894007588,-899497514],xO=new Array(80);function kO(){this.init(),this._w=xO,BO.call(this,64,56)}function SO(e){return e<<30|e>>>2}function QO(e,t,n,r){return 0===e?t&n|~t&r:2===e?t&n|t&r|n&r:t^n^r}IO(kO,BO),kO.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},kO.prototype._update=function(e){for(var t,n=this._w,r=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,s=0|this._e,u=0;u<16;++u)n[u]=e.readInt32BE(4*u);for(;u<80;++u)n[u]=n[u-3]^n[u-8]^n[u-14]^n[u-16];for(var l=0;l<80;++l){var A=~~(l/20),c=0|((t=r)<<5|t>>>27)+QO(A,i,o,a)+s+n[l]+CO[A];s=a,a=o,o=SO(i),i=r,r=c}this._a=r+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=s+this._e|0},kO.prototype._hash=function(){var e=EO.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e};var _O=kO,NO=KI.exports,DO=bO,FO=jN.exports.Buffer,PO=[1518500249,1859775393,-1894007588,-899497514],UO=new Array(80);function LO(){this.init(),this._w=UO,DO.call(this,64,56)}function MO(e){return e<<5|e>>>27}function TO(e){return e<<30|e>>>2}function RO(e,t,n,r){return 0===e?t&n|~t&r:2===e?t&n|t&r|n&r:t^n^r}NO(LO,DO),LO.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},LO.prototype._update=function(e){for(var t,n=this._w,r=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,s=0|this._e,u=0;u<16;++u)n[u]=e.readInt32BE(4*u);for(;u<80;++u)n[u]=(t=n[u-3]^n[u-8]^n[u-14]^n[u-16])<<1|t>>>31;for(var l=0;l<80;++l){var A=~~(l/20),c=MO(r)+RO(A,i,o,a)+s+n[l]+PO[A]|0;s=a,a=o,o=TO(i),i=r,r=c}this._a=r+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=s+this._e|0},LO.prototype._hash=function(){var e=FO.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e};var OO=LO,HO=KI.exports,KO=bO,jO=jN.exports.Buffer,GO=[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],qO=new Array(64);function VO(){this.init(),this._w=qO,KO.call(this,64,56)}function zO(e,t,n){return n^e&(t^n)}function JO(e,t,n){return e&t|n&(e|t)}function YO(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function XO(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function WO(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function ZO(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}HO(VO,KO),VO.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},VO.prototype._update=function(e){for(var t=this._w,n=0|this._a,r=0|this._b,i=0|this._c,o=0|this._d,a=0|this._e,s=0|this._f,u=0|this._g,l=0|this._h,A=0;A<16;++A)t[A]=e.readInt32BE(4*A);for(;A<64;++A)t[A]=ZO(t[A-2])+t[A-7]+WO(t[A-15])+t[A-16]|0;for(var c=0;c<64;++c){var h=l+XO(a)+zO(a,s,u)+GO[c]+t[c]|0,f=YO(n)+JO(n,r,i)|0;l=u,u=s,s=a,a=o+h|0,o=i,i=r,r=n,n=h+f|0}this._a=n+this._a|0,this._b=r+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=a+this._e|0,this._f=s+this._f|0,this._g=u+this._g|0,this._h=l+this._h|0},VO.prototype._hash=function(){var e=jO.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e};var $O=VO,eH=KI.exports,tH=$O,nH=bO,rH=jN.exports.Buffer,iH=new Array(64);function oH(){this.init(),this._w=iH,nH.call(this,64,56)}eH(oH,tH),oH.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},oH.prototype._hash=function(){var e=rH.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e};var aH=oH,sH=KI.exports,uH=bO,lH=jN.exports.Buffer,AH=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],cH=new Array(160);function hH(){this.init(),this._w=cH,uH.call(this,128,112)}function fH(e,t,n){return n^e&(t^n)}function dH(e,t,n){return e&t|n&(e|t)}function pH(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function gH(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function vH(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function yH(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function mH(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function wH(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function bH(e,t){return e>>>0<t>>>0?1:0}sH(hH,uH),hH.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},hH.prototype._update=function(e){for(var t=this._w,n=0|this._ah,r=0|this._bh,i=0|this._ch,o=0|this._dh,a=0|this._eh,s=0|this._fh,u=0|this._gh,l=0|this._hh,A=0|this._al,c=0|this._bl,h=0|this._cl,f=0|this._dl,d=0|this._el,p=0|this._fl,g=0|this._gl,v=0|this._hl,y=0;y<32;y+=2)t[y]=e.readInt32BE(4*y),t[y+1]=e.readInt32BE(4*y+4);for(;y<160;y+=2){var m=t[y-30],w=t[y-30+1],b=vH(m,w),I=yH(w,m),B=mH(m=t[y-4],w=t[y-4+1]),E=wH(w,m),C=t[y-14],x=t[y-14+1],k=t[y-32],S=t[y-32+1],Q=I+x|0,_=b+C+bH(Q,I)|0;_=(_=_+B+bH(Q=Q+E|0,E)|0)+k+bH(Q=Q+S|0,S)|0,t[y]=_,t[y+1]=Q}for(var N=0;N<160;N+=2){_=t[N],Q=t[N+1];var D=dH(n,r,i),F=dH(A,c,h),P=pH(n,A),U=pH(A,n),L=gH(a,d),M=gH(d,a),T=AH[N],R=AH[N+1],O=fH(a,s,u),H=fH(d,p,g),K=v+M|0,j=l+L+bH(K,v)|0;j=(j=(j=j+O+bH(K=K+H|0,H)|0)+T+bH(K=K+R|0,R)|0)+_+bH(K=K+Q|0,Q)|0;var G=U+F|0,q=P+D+bH(G,U)|0;l=u,v=g,u=s,g=p,s=a,p=d,a=o+j+bH(d=f+K|0,f)|0,o=i,f=h,i=r,h=c,r=n,c=A,n=j+q+bH(A=K+G|0,K)|0}this._al=this._al+A|0,this._bl=this._bl+c|0,this._cl=this._cl+h|0,this._dl=this._dl+f|0,this._el=this._el+d|0,this._fl=this._fl+p|0,this._gl=this._gl+g|0,this._hl=this._hl+v|0,this._ah=this._ah+n+bH(this._al,A)|0,this._bh=this._bh+r+bH(this._bl,c)|0,this._ch=this._ch+i+bH(this._cl,h)|0,this._dh=this._dh+o+bH(this._dl,f)|0,this._eh=this._eh+a+bH(this._el,d)|0,this._fh=this._fh+s+bH(this._fl,p)|0,this._gh=this._gh+u+bH(this._gl,g)|0,this._hh=this._hh+l+bH(this._hl,v)|0},hH.prototype._hash=function(){var e=lH.allocUnsafe(64);function t(t,n,r){e.writeInt32BE(t,r),e.writeInt32BE(n,r+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e};var IH=hH,BH=KI.exports,EH=IH,CH=bO,xH=jN.exports.Buffer,kH=new Array(160);function SH(){this.init(),this._w=kH,CH.call(this,128,112)}BH(SH,EH),SH.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},SH.prototype._hash=function(){var e=xH.allocUnsafe(48);function t(t,n,r){e.writeInt32BE(t,r),e.writeInt32BE(n,r+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e};var QH=SH,_H=yO.exports=function(e){e=e.toLowerCase();var t=_H[e];if(!t)throw new Error(e+" is not supported (we accept pull requests)");return new t};_H.sha=_O,_H.sha1=OO,_H.sha224=aH,_H.sha256=$O,_H.sha384=QH,_H.sha512=IH;var NH=Do(sh),DH=jN.exports.Buffer,FH=JQ.Transform,PH=NH.StringDecoder;function UH(e){FH.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}(0,KI.exports)(UH,FH),UH.prototype.update=function(e,t,n){"string"==typeof e&&(e=DH.from(e,t));var r=this._update(e);return this.hashMode?this:(n&&(r=this._toString(r,n)),r)},UH.prototype.setAutoPadding=function(){},UH.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},UH.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},UH.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},UH.prototype._transform=function(e,t,n){var r;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){r=e}finally{n(r)}},UH.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},UH.prototype._finalOrDigest=function(e){var t=this.__final()||DH.alloc(0);return e&&(t=this._toString(t,e,!0)),t},UH.prototype._toString=function(e,t,n){if(this._decoder||(this._decoder=new PH(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var r=this._decoder.write(e);return n&&(r+=this._decoder.end()),r};var LH=UH,MH=KI.exports,TH=$R,RH=vO,OH=yO.exports,HH=LH;function KH(e){HH.call(this,"digest"),this._hash=e}MH(KH,HH),KH.prototype._update=function(e){this._hash.update(e)},KH.prototype._final=function(){return this._hash.digest()};var jH=function(e){return"md5"===(e=e.toLowerCase())?new TH:"rmd160"===e||"ripemd160"===e?new RH:new KH(OH(e))};Object.defineProperty(WL,"__esModule",{value:!0}),WL.taggedHash=WL.hash256=WL.hash160=WL.sha256=WL.sha1=WL.ripemd160=void 0;var GH=jH,qH=vO;function VH(e){try{return GH("rmd160").update(e).digest()}catch(t){try{return GH("ripemd160").update(e).digest()}catch(t){return(new qH).update(e).digest()}}}function zH(e){return GH("sha256").update(e).digest()}WL.ripemd160=VH,WL.sha1=function(e){return GH("sha1").update(e).digest()},WL.sha256=zH,WL.hash160=function(e){return VH(zH(e))},WL.hash256=function(e){return zH(zH(e))};var JH=Object.fromEntries(["BIP0340/challenge","BIP0340/aux","BIP0340/nonce","TapLeaf","TapBranch","TapSighash","TapTweak","KeyAgg list","KeyAgg coefficient"].map((function(e){var t=zH(Yo.from(e));return[e,Yo.concat([t,t])]})));WL.taggedHash=function(e,t){return zH(Yo.concat([JH[e],t]))};var YH=wU,XH=jN.exports.Buffer,WH=jH,ZH=function(e){function t(t){var n=t.slice(0,-4),r=t.slice(-4),i=e(n);if(!(r[0]^i[0]|r[1]^i[1]|r[2]^i[2]|r[3]^i[3]))return n}return{encode:function(t){var n=e(t);return YH.encode(XH.concat([t,n],t.length+4))},decode:function(e){var n=t(YH.decode(e));if(!n)throw new Error("Invalid checksum");return n},decodeUnsafe:function(e){var n=YH.decodeUnsafe(e);if(n)return t(n)}}}((function(e){var t=WH("sha256").update(e).digest();return WH("sha256").update(t).digest()}));Object.defineProperty(XL,"__esModule",{value:!0}),XL.p2pkh=void 0;var $H=WL,eK=EU,tK=kU,nK=OU,rK=_L,iK=ZH,oK=tK.OPS;XL.p2pkh=function(e,t){if(!(e.address||e.hash||e.output||e.pubkey||e.input))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,nK.typeforce)({network:nK.typeforce.maybe(nK.typeforce.Object),address:nK.typeforce.maybe(nK.typeforce.String),hash:nK.typeforce.maybe(nK.typeforce.BufferN(20)),output:nK.typeforce.maybe(nK.typeforce.BufferN(25)),pubkey:nK.typeforce.maybe(nK.isPoint),signature:nK.typeforce.maybe(tK.isCanonicalScriptSignature),input:nK.typeforce.maybe(nK.typeforce.Buffer)},e);var n=rK.value((function(){var t=iK.decode(e.address);return{version:t.readUInt8(0),hash:t.slice(1)}})),r=rK.value((function(){return tK.decompile(e.input)})),i=e.network||eK.bitcoin,o={name:"p2pkh",network:i};if(rK.prop(o,"address",(function(){if(o.hash){var e=Yo.allocUnsafe(21);return e.writeUInt8(i.pubKeyHash,0),o.hash.copy(e,1),iK.encode(e)}})),rK.prop(o,"hash",(function(){return e.output?e.output.slice(3,23):e.address?n().hash:e.pubkey||o.pubkey?$H.hash160(e.pubkey||o.pubkey):void 0})),rK.prop(o,"output",(function(){if(o.hash)return tK.compile([oK.OP_DUP,oK.OP_HASH160,o.hash,oK.OP_EQUALVERIFY,oK.OP_CHECKSIG])})),rK.prop(o,"pubkey",(function(){if(e.input)return r()[1]})),rK.prop(o,"signature",(function(){if(e.input)return r()[0]})),rK.prop(o,"input",(function(){if(e.pubkey&&e.signature)return tK.compile([e.signature,e.pubkey])})),rK.prop(o,"witness",(function(){if(o.input)return[]})),t.validate){var a=Yo.from([]);if(e.address){if(n().version!==i.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(20!==n().hash.length)throw new TypeError("Invalid address");a=n().hash}if(e.hash){if(a.length>0&&!a.equals(e.hash))throw new TypeError("Hash mismatch");a=e.hash}if(e.output){if(25!==e.output.length||e.output[0]!==oK.OP_DUP||e.output[1]!==oK.OP_HASH160||20!==e.output[2]||e.output[23]!==oK.OP_EQUALVERIFY||e.output[24]!==oK.OP_CHECKSIG)throw new TypeError("Output is invalid");var s=e.output.slice(3,23);if(a.length>0&&!a.equals(s))throw new TypeError("Hash mismatch");a=s}if(e.pubkey){var u=$H.hash160(e.pubkey);if(a.length>0&&!a.equals(u))throw new TypeError("Hash mismatch");a=u}if(e.input){var l=r();if(2!==l.length)throw new TypeError("Input is invalid");if(!tK.isCanonicalScriptSignature(l[0]))throw new TypeError("Input has invalid signature");if(!(0,nK.isPoint)(l[1]))throw new TypeError("Input has invalid pubkey");if(e.signature&&!e.signature.equals(l[0]))throw new TypeError("Signature mismatch");if(e.pubkey&&!e.pubkey.equals(l[1]))throw new TypeError("Pubkey mismatch");var A=$H.hash160(l[1]);if(a.length>0&&!a.equals(A))throw new TypeError("Hash mismatch")}}return Object.assign(o,e)};var aK={};Object.defineProperty(aK,"__esModule",{value:!0}),aK.p2sh=void 0;var sK=WL,uK=EU,lK=kU,AK=OU,cK=_L,hK=ZH,fK=lK.OPS;aK.p2sh=function(e,t){if(!(e.address||e.hash||e.output||e.redeem||e.input))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,AK.typeforce)({network:AK.typeforce.maybe(AK.typeforce.Object),address:AK.typeforce.maybe(AK.typeforce.String),hash:AK.typeforce.maybe(AK.typeforce.BufferN(20)),output:AK.typeforce.maybe(AK.typeforce.BufferN(23)),redeem:AK.typeforce.maybe({network:AK.typeforce.maybe(AK.typeforce.Object),output:AK.typeforce.maybe(AK.typeforce.Buffer),input:AK.typeforce.maybe(AK.typeforce.Buffer),witness:AK.typeforce.maybe(AK.typeforce.arrayOf(AK.typeforce.Buffer))}),input:AK.typeforce.maybe(AK.typeforce.Buffer),witness:AK.typeforce.maybe(AK.typeforce.arrayOf(AK.typeforce.Buffer))},e);var n=e.network;n||(n=e.redeem&&e.redeem.network||uK.bitcoin);var r={network:n},i=cK.value((function(){var t=hK.decode(e.address);return{version:t.readUInt8(0),hash:t.slice(1)}})),o=cK.value((function(){return lK.decompile(e.input)})),a=cK.value((function(){var t=o(),r=t[t.length-1];return{network:n,output:r===fK.OP_FALSE?Yo.from([]):r,input:lK.compile(t.slice(0,-1)),witness:e.witness||[]}}));if(cK.prop(r,"address",(function(){if(r.hash){var e=Yo.allocUnsafe(21);return e.writeUInt8(r.network.scriptHash,0),r.hash.copy(e,1),hK.encode(e)}})),cK.prop(r,"hash",(function(){return e.output?e.output.slice(2,22):e.address?i().hash:r.redeem&&r.redeem.output?sK.hash160(r.redeem.output):void 0})),cK.prop(r,"output",(function(){if(r.hash)return lK.compile([fK.OP_HASH160,r.hash,fK.OP_EQUAL])})),cK.prop(r,"redeem",(function(){if(e.input)return a()})),cK.prop(r,"input",(function(){if(e.redeem&&e.redeem.input&&e.redeem.output)return lK.compile([].concat(lK.decompile(e.redeem.input),e.redeem.output))})),cK.prop(r,"witness",(function(){return r.redeem&&r.redeem.witness?r.redeem.witness:r.input?[]:void 0})),cK.prop(r,"name",(function(){var e=["p2sh"];return void 0!==r.redeem&&void 0!==r.redeem.name&&e.push(r.redeem.name),e.join("-")})),t.validate){var s=Yo.from([]);if(e.address){if(i().version!==n.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(20!==i().hash.length)throw new TypeError("Invalid address");s=i().hash}if(e.hash){if(s.length>0&&!s.equals(e.hash))throw new TypeError("Hash mismatch");s=e.hash}if(e.output){if(23!==e.output.length||e.output[0]!==fK.OP_HASH160||20!==e.output[1]||e.output[22]!==fK.OP_EQUAL)throw new TypeError("Output is invalid");var u=e.output.slice(2,22);if(s.length>0&&!s.equals(u))throw new TypeError("Hash mismatch");s=u}var l=function(e){if(e.output){var t=lK.decompile(e.output);if(!t||t.length<1)throw new TypeError("Redeem.output too short");var n=sK.hash160(e.output);if(s.length>0&&!s.equals(n))throw new TypeError("Hash mismatch");s=n}if(e.input){var r=e.input.length>0,i=e.witness&&e.witness.length>0;if(!r&&!i)throw new TypeError("Empty input");if(r&&i)throw new TypeError("Input and witness provided");if(r){var o=lK.decompile(e.input);if(!lK.isPushOnly(o))throw new TypeError("Non push-only scriptSig")}}};if(e.input){var A=o();if(!A||A.length<1)throw new TypeError("Input too short");if(!Na(a().output))throw new TypeError("Input is invalid");l(a())}if(e.redeem){if(e.redeem.network&&e.redeem.network!==n)throw new TypeError("Network mismatch");if(e.input){var c=a();if(e.redeem.output&&!e.redeem.output.equals(c.output))throw new TypeError("Redeem.output mismatch");if(e.redeem.input&&!e.redeem.input.equals(c.input))throw new TypeError("Redeem.input mismatch")}l(e.redeem)}if(e.witness&&e.redeem&&e.redeem.witness&&!function(e,t){return e.length===t.length&&e.every((function(e,n){return e.equals(t[n])}))}(e.redeem.witness,e.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(r,e)};var dK={},pK={};Object.defineProperty(pK,"__esModule",{value:!0}),pK.bech32m=pK.bech32=void 0;for(var gK="qpzry9x8gf2tvdw0s3jn54khce6mua7l",vK={},yK=0;yK<gK.length;yK++){var mK=gK.charAt(yK);vK[mK]=yK}function wK(e){var 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 bK(e){for(var t=1,n=0;n<e.length;++n){var r=e.charCodeAt(n);if(r<33||r>126)return"Invalid prefix ("+e+")";t=wK(t)^r>>5}t=wK(t);for(var i=0;i<e.length;++i){var o=e.charCodeAt(i);t=wK(t)^31&o}return t}function IK(e,t,n,r){for(var i=0,o=0,a=(1<<n)-1,s=[],u=0;u<e.length;++u)for(i=i<<t|e[u],o+=t;o>=n;)o-=n,s.push(i>>o&a);if(r)o>0&&s.push(i<<n-o&a);else{if(o>=t)return"Excess padding";if(i<<n-o&a)return"Non-zero padding"}return s}function BK(e){return IK(e,8,5,!0)}function EK(e){var t=IK(e,5,8,!1);if(Array.isArray(t))return t}function CK(e){var t=IK(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function xK(e){var t;function n(e,n){if(n=n||90,e.length<8)return e+" too short";if(e.length>n)return"Exceeds length limit";var r=e.toLowerCase(),i=e.toUpperCase();if(e!==r&&e!==i)return"Mixed-case string "+e;var o=(e=r).lastIndexOf("1");if(-1===o)return"No separator character for "+e;if(0===o)return"Missing prefix for "+e;var a=e.slice(0,o),s=e.slice(o+1);if(s.length<6)return"Data too short";var u=bK(a);if("string"==typeof u)return u;for(var l=[],A=0;A<s.length;++A){var c=s.charAt(A),h=vK[c];if(void 0===h)return"Unknown character "+c;u=wK(u)^h,A+6>=s.length||l.push(h)}return u!==t?"Invalid checksum for "+e:{prefix:a,words:l}}return t="bech32"===e?1:734539939,{decodeUnsafe:function(e,t){var r=n(e,t);if("object"==i(r))return r},decode:function(e,t){var r=n(e,t);if("object"==i(r))return r;throw new Error(r)},encode:function(e,n,r){if(r=r||90,e.length+7+n.length>r)throw new TypeError("Exceeds length limit");var i=bK(e=e.toLowerCase());if("string"==typeof i)throw new Error(i);for(var o=e+"1",a=0;a<n.length;++a){var s=n[a];if(s>>5!=0)throw new Error("Non 5-bit word");i=wK(i)^s,o+=gK.charAt(s)}for(var u=0;u<6;++u)i=wK(i);i^=t;for(var l=0;l<6;++l)o+=gK.charAt(i>>5*(5-l)&31);return o},toWords:BK,fromWordsUnsafe:EK,fromWords:CK}}pK.bech32=xK("bech32"),pK.bech32m=xK("bech32m"),Object.defineProperty(dK,"__esModule",{value:!0}),dK.p2wpkh=void 0;var kK=WL,SK=EU,QK=kU,_K=OU,NK=_L,DK=pK,FK=QK.OPS,PK=Yo.alloc(0);dK.p2wpkh=function(e,t){if(!(e.address||e.hash||e.output||e.pubkey||e.witness))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,_K.typeforce)({address:_K.typeforce.maybe(_K.typeforce.String),hash:_K.typeforce.maybe(_K.typeforce.BufferN(20)),input:_K.typeforce.maybe(_K.typeforce.BufferN(0)),network:_K.typeforce.maybe(_K.typeforce.Object),output:_K.typeforce.maybe(_K.typeforce.BufferN(22)),pubkey:_K.typeforce.maybe(_K.isPoint),signature:_K.typeforce.maybe(QK.isCanonicalScriptSignature),witness:_K.typeforce.maybe(_K.typeforce.arrayOf(_K.typeforce.Buffer))},e);var n=NK.value((function(){var t=DK.bech32.decode(e.address),n=t.words.shift(),r=DK.bech32.fromWords(t.words);return{version:n,prefix:t.prefix,data:Yo.from(r)}})),r=e.network||SK.bitcoin,i={name:"p2wpkh",network:r};if(NK.prop(i,"address",(function(){if(i.hash){var e=DK.bech32.toWords(i.hash);return e.unshift(0),DK.bech32.encode(r.bech32,e)}})),NK.prop(i,"hash",(function(){return e.output?e.output.slice(2,22):e.address?n().data:e.pubkey||i.pubkey?kK.hash160(e.pubkey||i.pubkey):void 0})),NK.prop(i,"output",(function(){if(i.hash)return QK.compile([FK.OP_0,i.hash])})),NK.prop(i,"pubkey",(function(){return e.pubkey?e.pubkey:e.witness?e.witness[1]:void 0})),NK.prop(i,"signature",(function(){if(e.witness)return e.witness[0]})),NK.prop(i,"input",(function(){if(i.witness)return PK})),NK.prop(i,"witness",(function(){if(e.pubkey&&e.signature)return[e.signature,e.pubkey]})),t.validate){var o=Yo.from([]);if(e.address){if(r&&r.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");o=n().data}if(e.hash){if(o.length>0&&!o.equals(e.hash))throw new TypeError("Hash mismatch");o=e.hash}if(e.output){if(22!==e.output.length||e.output[0]!==FK.OP_0||20!==e.output[1])throw new TypeError("Output is invalid");if(o.length>0&&!o.equals(e.output.slice(2)))throw new TypeError("Hash mismatch");o=e.output.slice(2)}if(e.pubkey){var a=kK.hash160(e.pubkey);if(o.length>0&&!o.equals(a))throw new TypeError("Hash mismatch");if(o=a,!(0,_K.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(!QK.isCanonicalScriptSignature(e.witness[0]))throw new TypeError("Witness has invalid signature");if(!(0,_K.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");var s=kK.hash160(e.witness[1]);if(o.length>0&&!o.equals(s))throw new TypeError("Hash mismatch")}}return Object.assign(i,e)};var UK={};Object.defineProperty(UK,"__esModule",{value:!0}),UK.p2wsh=void 0;var LK=WL,MK=EU,TK=kU,RK=OU,OK=_L,HK=pK,KK=TK.OPS,jK=Yo.alloc(0);function GK(e){return!(!Na(e)||65!==e.length||4!==e[0]||!(0,RK.isPoint)(e))}UK.p2wsh=function(e,t){if(!(e.address||e.hash||e.output||e.redeem||e.witness))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,RK.typeforce)({network:RK.typeforce.maybe(RK.typeforce.Object),address:RK.typeforce.maybe(RK.typeforce.String),hash:RK.typeforce.maybe(RK.typeforce.BufferN(32)),output:RK.typeforce.maybe(RK.typeforce.BufferN(34)),redeem:RK.typeforce.maybe({input:RK.typeforce.maybe(RK.typeforce.Buffer),network:RK.typeforce.maybe(RK.typeforce.Object),output:RK.typeforce.maybe(RK.typeforce.Buffer),witness:RK.typeforce.maybe(RK.typeforce.arrayOf(RK.typeforce.Buffer))}),input:RK.typeforce.maybe(RK.typeforce.BufferN(0)),witness:RK.typeforce.maybe(RK.typeforce.arrayOf(RK.typeforce.Buffer))},e);var n=OK.value((function(){var t=HK.bech32.decode(e.address),n=t.words.shift(),r=HK.bech32.fromWords(t.words);return{version:n,prefix:t.prefix,data:Yo.from(r)}})),r=OK.value((function(){return TK.decompile(e.redeem.input)})),i=e.network;i||(i=e.redeem&&e.redeem.network||MK.bitcoin);var o={network:i};if(OK.prop(o,"address",(function(){if(o.hash){var e=HK.bech32.toWords(o.hash);return e.unshift(0),HK.bech32.encode(i.bech32,e)}})),OK.prop(o,"hash",(function(){return e.output?e.output.slice(2):e.address?n().data:o.redeem&&o.redeem.output?LK.sha256(o.redeem.output):void 0})),OK.prop(o,"output",(function(){if(o.hash)return TK.compile([KK.OP_0,o.hash])})),OK.prop(o,"redeem",(function(){if(e.witness)return{output:e.witness[e.witness.length-1],input:jK,witness:e.witness.slice(0,-1)}})),OK.prop(o,"input",(function(){if(o.witness)return jK})),OK.prop(o,"witness",(function(){if(e.redeem&&e.redeem.input&&e.redeem.input.length>0&&e.redeem.output&&e.redeem.output.length>0){var t=TK.toStack(r());return o.redeem=Object.assign({witness:t},e.redeem),o.redeem.input=jK,[].concat(t,e.redeem.output)}if(e.redeem&&e.redeem.output&&e.redeem.witness)return[].concat(e.redeem.witness,e.redeem.output)})),OK.prop(o,"name",(function(){var e=["p2wsh"];return void 0!==o.redeem&&void 0!==o.redeem.name&&e.push(o.redeem.name),e.join("-")})),t.validate){var a=Yo.from([]);if(e.address){if(n().prefix!==i.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");a=n().data}if(e.hash){if(a.length>0&&!a.equals(e.hash))throw new TypeError("Hash mismatch");a=e.hash}if(e.output){if(34!==e.output.length||e.output[0]!==KK.OP_0||32!==e.output[1])throw new TypeError("Output is invalid");var s=e.output.slice(2);if(a.length>0&&!a.equals(s))throw new TypeError("Hash mismatch");a=s}if(e.redeem){if(e.redeem.network&&e.redeem.network!==i)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){if(0===TK.decompile(e.redeem.output).length)throw new TypeError("Redeem.output is invalid");var u=LK.sha256(e.redeem.output);if(a.length>0&&!a.equals(u))throw new TypeError("Hash mismatch");a=u}if(e.redeem.input&&!TK.isPushOnly(r()))throw new TypeError("Non push-only scriptSig");if(e.witness&&e.redeem.witness&&!function(e,t){return e.length===t.length&&e.every((function(e,n){return e.equals(t[n])}))}(e.witness,e.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(e.redeem.input&&r().some(GK)||e.redeem.output&&(TK.decompile(e.redeem.output)||[]).some(GK))throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey")}if(e.witness&&e.witness.length>0){var l=e.witness[e.witness.length-1];if(e.redeem&&e.redeem.output&&!e.redeem.output.equals(l))throw new TypeError("Witness and redeem.output mismatch");if(e.witness.some(GK)||(TK.decompile(l)||[]).some(GK))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(o,e)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.p2wsh=e.p2wpkh=e.p2sh=e.p2pkh=e.p2pk=e.p2ms=e.embed=void 0;var t=xU;Object.defineProperty(e,"embed",{enumerable:!0,get:function(){return t.p2data}});var n=LL;Object.defineProperty(e,"p2ms",{enumerable:!0,get:function(){return n.p2ms}});var r=GL;Object.defineProperty(e,"p2pk",{enumerable:!0,get:function(){return r.p2pk}});var i=XL;Object.defineProperty(e,"p2pkh",{enumerable:!0,get:function(){return i.p2pkh}});var o=aK;Object.defineProperty(e,"p2sh",{enumerable:!0,get:function(){return o.p2sh}});var a=dK;Object.defineProperty(e,"p2wpkh",{enumerable:!0,get:function(){return a.p2wpkh}});var s=UK;Object.defineProperty(e,"p2wsh",{enumerable:!0,get:function(){return s.p2wsh}})}(CU),Object.defineProperty(BU,"__esModule",{value:!0}),BU.toOutputScript=BU.fromOutputScript=BU.toBech32=BU.toBase58Check=BU.fromBech32=BU.fromBase58Check=void 0;var qK=EU,VK=CU,zK=kU,JK=OU,YK=pK,XK=ZH,WK=JK.typeforce,ZK="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 $K(e){var t=XK.decode(e);if(t.length<21)throw new TypeError(e+" is too short");if(t.length>21)throw new TypeError(e+" is too long");return{version:t.readUInt8(0),hash:t.slice(1)}}function ej(e){var t,n;try{t=YK.bech32.decode(e)}catch(e){}if(t){if(0!==(n=t.words[0]))throw new TypeError(e+" uses wrong encoding")}else if(0===(n=(t=YK.bech32m.decode(e)).words[0]))throw new TypeError(e+" uses wrong encoding");var r=YK.bech32.fromWords(t.words.slice(1));return{version:n,prefix:t.prefix,data:Yo.from(r)}}function tj(e,t,n){var r=YK.bech32.toWords(e);return r.unshift(t),0===t?YK.bech32.encode(n,r):YK.bech32m.encode(n,r)}BU.fromBase58Check=$K,BU.fromBech32=ej,BU.toBase58Check=function(e,t){WK(JK.tuple(JK.Hash160bit,JK.UInt8),arguments);var n=Yo.allocUnsafe(21);return n.writeUInt8(t,0),e.copy(n,1),XK.encode(n)},BU.toBech32=tj,BU.fromOutputScript=function(e,t){t=t||qK.bitcoin;try{return VK.p2pkh({output:e,network:t}).address}catch(e){}try{return VK.p2sh({output:e,network:t}).address}catch(e){}try{return VK.p2wpkh({output:e,network:t}).address}catch(e){}try{return VK.p2wsh({output:e,network:t}).address}catch(e){}try{return function(e,t){var n=e.slice(2);if(n.length<2||n.length>40)throw new TypeError("Invalid program length for segwit address");var r=e[0]-80;if(r<1||r>16)throw new TypeError("Invalid version for segwit address");if(e[1]!==n.length)throw new TypeError("Invalid script for segwit address");return console.warn(ZK),tj(n,r,t.bech32)}(e,t)}catch(e){}throw new Error(zK.toASM(e)+" has no matching Address")},BU.toOutputScript=function(e,t){var n,r;t=t||qK.bitcoin;try{n=$K(e)}catch(e){}if(n){if(n.version===t.pubKeyHash)return VK.p2pkh({hash:n.hash}).output;if(n.version===t.scriptHash)return VK.p2sh({hash:n.hash}).output}else{try{r=ej(e)}catch(e){}if(r){if(r.prefix!==t.bech32)throw new Error(e+" has an invalid prefix");if(0===r.version){if(20===r.data.length)return VK.p2wpkh({hash:r.data}).output;if(32===r.data.length)return VK.p2wsh({hash:r.data}).output}else if(r.version>=1&&r.version<=16&&r.data.length>=2&&r.data.length<=40)return console.warn(ZK),zK.compile([r.version+80,r.data])}}throw new Error(e+" has no matching Script")};var nj={},rj={},ij=jN.exports.Buffer;function oj(e){if(e<0||e>9007199254740991||e%1!=0)throw new RangeError("value out of range")}function aj(e){return oj(e),e<253?1:e<=65535?3:e<=4294967295?5:9}var sj={encode:function e(t,n,r){if(oj(t),n||(n=ij.allocUnsafe(aj(t))),!ij.isBuffer(n))throw new TypeError("buffer must be a Buffer instance");return r||(r=0),t<253?(n.writeUInt8(t,r),e.bytes=1):t<=65535?(n.writeUInt8(253,r),n.writeUInt16LE(t,r+1),e.bytes=3):t<=4294967295?(n.writeUInt8(254,r),n.writeUInt32LE(t,r+1),e.bytes=5):(n.writeUInt8(255,r),n.writeUInt32LE(t>>>0,r+1),n.writeUInt32LE(t/4294967296|0,r+5),e.bytes=9),n},decode:function e(t,n){if(!ij.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");n||(n=0);var r=t.readUInt8(n);if(r<253)return e.bytes=1,r;if(253===r)return e.bytes=3,t.readUInt16LE(n+1);if(254===r)return e.bytes=5,t.readUInt32LE(n+1);e.bytes=9;var i=t.readUInt32LE(n+1),o=4294967296*t.readUInt32LE(n+5)+i;return oj(o),o},encodingLength:aj};Object.defineProperty(rj,"__esModule",{value:!0}),rj.BufferReader=rj.BufferWriter=rj.cloneBuffer=rj.reverseBuffer=rj.writeUInt64LE=rj.readUInt64LE=rj.varuint=void 0;var uj=OU,lj=uj.typeforce,Aj=sj;function cj(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 hj(e,t){var n=e.readUInt32LE(t),r=e.readUInt32LE(t+4);return cj((r*=4294967296)+n,9007199254740991),r+n}function fj(e,t,n){return cj(t,9007199254740991),e.writeInt32LE(-1&t,n),e.writeUInt32LE(Math.floor(t/4294967296),n+4),n+8}rj.varuint=Aj,rj.readUInt64LE=hj,rj.writeUInt64LE=fj,rj.reverseBuffer=function(e){if(e.length<1)return e;for(var t=e.length-1,n=0,r=0;r<e.length/2;r++)n=e[r],e[r]=e[t],e[t]=n,t--;return e},rj.cloneBuffer=function(e){var t=Yo.allocUnsafe(e.length);return e.copy(t),t};var dj=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;s(this,e),this.buffer=t,this.offset=n,lj(uj.tuple(uj.Buffer,uj.UInt32),[t,n])}return l(e,[{key:"writeUInt8",value:function(e){this.offset=this.buffer.writeUInt8(e,this.offset)}},{key:"writeInt32",value:function(e){this.offset=this.buffer.writeInt32LE(e,this.offset)}},{key:"writeUInt32",value:function(e){this.offset=this.buffer.writeUInt32LE(e,this.offset)}},{key:"writeUInt64",value:function(e){this.offset=fj(this.buffer,e,this.offset)}},{key:"writeVarInt",value:function(e){Aj.encode(e,this.buffer,this.offset),this.offset+=Aj.encode.bytes}},{key:"writeSlice",value:function(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)}},{key:"writeVarSlice",value:function(e){this.writeVarInt(e.length),this.writeSlice(e)}},{key:"writeVector",value:function(e){var t=this;this.writeVarInt(e.length),e.forEach((function(e){return t.writeVarSlice(e)}))}},{key:"end",value:function(){if(this.buffer.length===this.offset)return this.buffer;throw new Error("buffer size ".concat(this.buffer.length,", offset ").concat(this.offset))}}],[{key:"withCapacity",value:function(t){return new e(Yo.alloc(t))}}]),e}();rj.BufferWriter=dj,rj.BufferReader=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;s(this,e),this.buffer=t,this.offset=n,lj(uj.tuple(uj.Buffer,uj.UInt32),[t,n])}return l(e,[{key:"readUInt8",value:function(){var e=this.buffer.readUInt8(this.offset);return this.offset++,e}},{key:"readInt32",value:function(){var e=this.buffer.readInt32LE(this.offset);return this.offset+=4,e}},{key:"readUInt32",value:function(){var e=this.buffer.readUInt32LE(this.offset);return this.offset+=4,e}},{key:"readUInt64",value:function(){var e=hj(this.buffer,this.offset);return this.offset+=8,e}},{key:"readVarInt",value:function(){var e=Aj.decode(this.buffer,this.offset);return this.offset+=Aj.decode.bytes,e}},{key:"readSlice",value:function(e){if(this.buffer.length<this.offset+e)throw new Error("Cannot read slice out of bounds");var t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}},{key:"readVarSlice",value:function(){return this.readSlice(this.readVarInt())}},{key:"readVector",value:function(){for(var e=this.readVarInt(),t=[],n=0;n<e;n++)t.push(this.readVarSlice());return t}}]),e}();var pj={};Object.defineProperty(pj,"__esModule",{value:!0}),pj.fastMerkleRoot=void 0,pj.fastMerkleRoot=function(e,t){if(!Array.isArray(e))throw TypeError("Expected values Array");if("function"!=typeof t)throw TypeError("Expected digest Function");for(var n=e.length,r=e.concat();n>1;){for(var i=0,o=0;o<n;o+=2,++i){var a=r[o],s=o+1===n?a:r[o+1],u=Yo.concat([a,s]);r[i]=t(u)}n=i}return r[0]};var gj={};Object.defineProperty(gj,"__esModule",{value:!0}),gj.Transaction=void 0;var vj=rj,yj=WL,mj=kU,wj=kU,bj=OU,Ij=bj.typeforce;function Bj(e){var t=e.length;return vj.varuint.encodingLength(t)+t}var Ej=Yo.allocUnsafe(0),Cj=[],xj=Yo.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),kj=Yo.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),Sj=Yo.from("ffffffffffffffff","hex"),Qj={script:Ej,valueBuffer:Sj},_j=function(){function e(){s(this,e),this.version=1,this.locktime=0,this.ins=[],this.outs=[]}return l(e,[{key:"isCoinbase",value:function(){return 1===this.ins.length&&e.isCoinbaseHash(this.ins[0].hash)}},{key:"addInput",value:function(t,n,r,i){return Ij(bj.tuple(bj.Hash256bit,bj.UInt32,bj.maybe(bj.UInt32),bj.maybe(bj.Buffer)),arguments),bj.Null(r)&&(r=e.DEFAULT_SEQUENCE),this.ins.push({hash:t,index:n,script:i||Ej,sequence:r,witness:Cj})-1}},{key:"addOutput",value:function(e,t){return Ij(bj.tuple(bj.Buffer,bj.Satoshi),arguments),this.outs.push({script:e,value:t})-1}},{key:"hasWitnesses",value:function(){return this.ins.some((function(e){return 0!==e.witness.length}))}},{key:"weight",value:function(){return 3*this.byteLength(!1)+this.byteLength(!0)}},{key:"virtualSize",value:function(){return Math.ceil(this.weight()/4)}},{key:"byteLength",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=e&&this.hasWitnesses();return(t?10:8)+vj.varuint.encodingLength(this.ins.length)+vj.varuint.encodingLength(this.outs.length)+this.ins.reduce((function(e,t){return e+40+Bj(t.script)}),0)+this.outs.reduce((function(e,t){return e+8+Bj(t.script)}),0)+(t?this.ins.reduce((function(e,t){return e+function(e){var t=e.length;return vj.varuint.encodingLength(t)+e.reduce((function(e,t){return e+Bj(t)}),0)}(t.witness)}),0):0)}},{key:"clone",value:function(){var t=new e;return t.version=this.version,t.locktime=this.locktime,t.ins=this.ins.map((function(e){return{hash:e.hash,index:e.index,script:e.script,sequence:e.sequence,witness:e.witness}})),t.outs=this.outs.map((function(e){return{script:e.script,value:e.value}})),t}},{key:"hashForSignature",value:function(t,n,r){if(Ij(bj.tuple(bj.UInt32,bj.Buffer,bj.Number),arguments),t>=this.ins.length)return kj;var i=mj.compile(mj.decompile(n).filter((function(e){return e!==wj.OPS.OP_CODESEPARATOR}))),o=this.clone();if((31&r)===e.SIGHASH_NONE)o.outs=[],o.ins.forEach((function(e,n){n!==t&&(e.sequence=0)}));else if((31&r)===e.SIGHASH_SINGLE){if(t>=this.outs.length)return kj;o.outs.length=t+1;for(var a=0;a<t;a++)o.outs[a]=Qj;o.ins.forEach((function(e,n){n!==t&&(e.sequence=0)}))}r&e.SIGHASH_ANYONECANPAY?(o.ins=[o.ins[t]],o.ins[0].script=i):(o.ins.forEach((function(e){e.script=Ej})),o.ins[t].script=i);var s=Yo.allocUnsafe(o.byteLength(!1)+4);return s.writeInt32LE(r,s.length-4),o.__toBuffer(s,0,!1),yj.hash256(s)}},{key:"hashForWitnessV1",value:function(t,n,r,i,o,a){if(Ij(bj.tuple(bj.UInt32,Ij.arrayOf(bj.Buffer),Ij.arrayOf(bj.Satoshi),bj.UInt32),arguments),r.length!==this.ins.length||n.length!==this.ins.length)throw new Error("Must supply prevout script and value for all inputs");var s=i===e.SIGHASH_DEFAULT?e.SIGHASH_ALL:i&e.SIGHASH_OUTPUT_MASK,u=(i&e.SIGHASH_INPUT_MASK)===e.SIGHASH_ANYONECANPAY,l=s===e.SIGHASH_NONE,A=s===e.SIGHASH_SINGLE,c=Ej,h=Ej,f=Ej,d=Ej,p=Ej;if(!u){var g=vj.BufferWriter.withCapacity(36*this.ins.length);this.ins.forEach((function(e){g.writeSlice(e.hash),g.writeUInt32(e.index)})),c=yj.sha256(g.end()),g=vj.BufferWriter.withCapacity(8*this.ins.length),r.forEach((function(e){return g.writeUInt64(e)})),h=yj.sha256(g.end()),g=vj.BufferWriter.withCapacity(n.map(Bj).reduce((function(e,t){return e+t}))),n.forEach((function(e){return g.writeVarSlice(e)})),f=yj.sha256(g.end()),g=vj.BufferWriter.withCapacity(4*this.ins.length),this.ins.forEach((function(e){return g.writeUInt32(e.sequence)})),d=yj.sha256(g.end())}if(l||A){if(A&&t<this.outs.length){var v=this.outs[t],y=vj.BufferWriter.withCapacity(8+Bj(v.script));y.writeUInt64(v.value),y.writeVarSlice(v.script),p=yj.sha256(y.end())}}else{var m=this.outs.map((function(e){return 8+Bj(e.script)})).reduce((function(e,t){return e+t})),w=vj.BufferWriter.withCapacity(m);this.outs.forEach((function(e){w.writeUInt64(e.value),w.writeVarSlice(e.script)})),p=yj.sha256(w.end())}var b=(o?2:0)+(a?1:0),I=174-(u?49:0)-(l?32:0)+(a?32:0)+(o?37:0),B=vj.BufferWriter.withCapacity(I);if(B.writeUInt8(i),B.writeInt32(this.version),B.writeUInt32(this.locktime),B.writeSlice(c),B.writeSlice(h),B.writeSlice(f),B.writeSlice(d),l||A||B.writeSlice(p),B.writeUInt8(b),u){var E=this.ins[t];B.writeSlice(E.hash),B.writeUInt32(E.index),B.writeUInt64(r[t]),B.writeVarSlice(n[t]),B.writeUInt32(E.sequence)}else B.writeUInt32(t);if(a){var C=vj.BufferWriter.withCapacity(Bj(a));C.writeVarSlice(a),B.writeSlice(yj.sha256(C.end()))}return A&&B.writeSlice(p),o&&(B.writeSlice(o),B.writeUInt8(0),B.writeUInt32(4294967295)),yj.taggedHash("TapSighash",Yo.concat([Yo.of(0),B.end()]))}},{key:"hashForWitnessV0",value:function(t,n,r,i){Ij(bj.tuple(bj.UInt32,bj.Buffer,bj.Satoshi,bj.UInt32),arguments);var o,a=Yo.from([]),s=xj,u=xj,l=xj;if(i&e.SIGHASH_ANYONECANPAY||(a=Yo.allocUnsafe(36*this.ins.length),o=new vj.BufferWriter(a,0),this.ins.forEach((function(e){o.writeSlice(e.hash),o.writeUInt32(e.index)})),u=yj.hash256(a)),i&e.SIGHASH_ANYONECANPAY||(31&i)===e.SIGHASH_SINGLE||(31&i)===e.SIGHASH_NONE||(a=Yo.allocUnsafe(4*this.ins.length),o=new vj.BufferWriter(a,0),this.ins.forEach((function(e){o.writeUInt32(e.sequence)})),l=yj.hash256(a)),(31&i)!==e.SIGHASH_SINGLE&&(31&i)!==e.SIGHASH_NONE){var A=this.outs.reduce((function(e,t){return e+8+Bj(t.script)}),0);a=Yo.allocUnsafe(A),o=new vj.BufferWriter(a,0),this.outs.forEach((function(e){o.writeUInt64(e.value),o.writeVarSlice(e.script)})),s=yj.hash256(a)}else if((31&i)===e.SIGHASH_SINGLE&&t<this.outs.length){var c=this.outs[t];a=Yo.allocUnsafe(8+Bj(c.script)),(o=new vj.BufferWriter(a,0)).writeUInt64(c.value),o.writeVarSlice(c.script),s=yj.hash256(a)}a=Yo.allocUnsafe(156+Bj(n)),o=new vj.BufferWriter(a,0);var h=this.ins[t];return o.writeInt32(this.version),o.writeSlice(u),o.writeSlice(l),o.writeSlice(h.hash),o.writeUInt32(h.index),o.writeVarSlice(n),o.writeUInt64(r),o.writeUInt32(h.sequence),o.writeSlice(s),o.writeUInt32(this.locktime),o.writeUInt32(i),yj.hash256(a)}},{key:"getHash",value:function(e){return e&&this.isCoinbase()?Yo.alloc(32,0):yj.hash256(this.__toBuffer(void 0,void 0,e))}},{key:"getId",value:function(){return(0,vj.reverseBuffer)(this.getHash(!1)).toString("hex")}},{key:"toBuffer",value:function(e,t){return this.__toBuffer(e,t,!0)}},{key:"toHex",value:function(){return this.toBuffer(void 0,void 0).toString("hex")}},{key:"setInputScript",value:function(e,t){Ij(bj.tuple(bj.Number,bj.Buffer),arguments),this.ins[e].script=t}},{key:"setWitness",value:function(e,t){Ij(bj.tuple(bj.Number,[bj.Buffer]),arguments),this.ins[e].witness=t}},{key:"__toBuffer",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t||(t=Yo.allocUnsafe(this.byteLength(r)));var i=new vj.BufferWriter(t,n||0);i.writeInt32(this.version);var o=r&&this.hasWitnesses();return o&&(i.writeUInt8(e.ADVANCED_TRANSACTION_MARKER),i.writeUInt8(e.ADVANCED_TRANSACTION_FLAG)),i.writeVarInt(this.ins.length),this.ins.forEach((function(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((function(e){void 0!==e.value?i.writeUInt64(e.value):i.writeSlice(e.valueBuffer),i.writeVarSlice(e.script)})),o&&this.ins.forEach((function(e){i.writeVector(e.witness)})),i.writeUInt32(this.locktime),void 0!==n?t.slice(n,i.offset):t}}],[{key:"fromBuffer",value:function(t,n){var r=new vj.BufferReader(t),i=new e;i.version=r.readInt32();var o=r.readUInt8(),a=r.readUInt8(),s=!1;o===e.ADVANCED_TRANSACTION_MARKER&&a===e.ADVANCED_TRANSACTION_FLAG?s=!0:r.offset-=2;for(var u=r.readVarInt(),l=0;l<u;++l)i.ins.push({hash:r.readSlice(32),index:r.readUInt32(),script:r.readVarSlice(),sequence:r.readUInt32(),witness:Cj});for(var A=r.readVarInt(),c=0;c<A;++c)i.outs.push({value:r.readUInt64(),script:r.readVarSlice()});if(s){for(var h=0;h<u;++h)i.ins[h].witness=r.readVector();if(!i.hasWitnesses())throw new Error("Transaction has superfluous witness data")}if(i.locktime=r.readUInt32(),n)return i;if(r.offset!==t.length)throw new Error("Transaction has unexpected data");return i}},{key:"fromHex",value:function(t){return e.fromBuffer(Yo.from(t,"hex"),!1)}},{key:"isCoinbaseHash",value:function(e){Ij(bj.Hash256bit,e);for(var t=0;t<32;++t)if(0!==e[t])return!1;return!0}}]),e}();gj.Transaction=_j,_j.DEFAULT_SEQUENCE=4294967295,_j.SIGHASH_DEFAULT=0,_j.SIGHASH_ALL=1,_j.SIGHASH_NONE=2,_j.SIGHASH_SINGLE=3,_j.SIGHASH_ANYONECANPAY=128,_j.SIGHASH_OUTPUT_MASK=3,_j.SIGHASH_INPUT_MASK=128,_j.ADVANCED_TRANSACTION_MARKER=0,_j.ADVANCED_TRANSACTION_FLAG=1,Object.defineProperty(nj,"__esModule",{value:!0}),nj.Block=void 0;var Nj=rj,Dj=WL,Fj=pj,Pj=gj,Uj=OU,Lj=Uj.typeforce,Mj=new TypeError("Cannot compute merkle root for zero transactions"),Tj=new TypeError("Cannot compute witness commit for non-segwit block"),Rj=function(){function e(){s(this,e),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}return l(e,[{key:"getWitnessCommit",value:function(){if(!Oj(this.transactions))return null;var e=this.transactions[0].outs.filter((function(e){return e.script.slice(0,6).equals(Yo.from("6a24aa21a9ed","hex"))})).map((function(e){return e.script.slice(6,38)}));if(0===e.length)return null;var t=e[e.length-1];return t instanceof Yo&&32===t.length?t:null}},{key:"hasWitnessCommit",value:function(){return this.witnessCommit instanceof Yo&&32===this.witnessCommit.length||null!==this.getWitnessCommit()}},{key:"hasWitness",value:function(){return(e=this.transactions)instanceof Array&&e.some((function(e){return"object"==i(e)&&e.ins instanceof Array&&e.ins.some((function(e){return"object"==i(e)&&e.witness instanceof Array&&e.witness.length>0}))}));var e}},{key:"weight",value:function(){return 3*this.byteLength(!1,!1)+this.byteLength(!1,!0)}},{key:"byteLength",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return e||!this.transactions?80:80+Nj.varuint.encodingLength(this.transactions.length)+this.transactions.reduce((function(e,n){return e+n.byteLength(t)}),0)}},{key:"getHash",value:function(){return Dj.hash256(this.toBuffer(!0))}},{key:"getId",value:function(){return(0,Nj.reverseBuffer)(this.getHash()).toString("hex")}},{key:"getUTCDate",value:function(){var e=new Date(0);return e.setUTCSeconds(this.timestamp),e}},{key:"toBuffer",value:function(e){var t=Yo.allocUnsafe(this.byteLength(e)),n=new Nj.BufferWriter(t);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||(Nj.varuint.encode(this.transactions.length,t,n.offset),n.offset+=Nj.varuint.encode.bytes,this.transactions.forEach((function(e){var r=e.byteLength();e.toBuffer(t,n.offset),n.offset+=r}))),t}},{key:"toHex",value:function(e){return this.toBuffer(e).toString("hex")}},{key:"checkTxRoots",value:function(){var e=this.hasWitnessCommit();return!(!e&&this.hasWitness())&&this.__checkMerkleRoot()&&(!e||this.__checkWitnessCommit())}},{key:"checkProofOfWork",value:function(){var t=(0,Nj.reverseBuffer)(this.getHash()),n=e.calculateTarget(this.bits);return t.compare(n)<=0}},{key:"__checkMerkleRoot",value:function(){if(!this.transactions)throw Mj;var t=e.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(t)}},{key:"__checkWitnessCommit",value:function(){if(!this.transactions)throw Mj;if(!this.hasWitnessCommit())throw Tj;var t=e.calculateMerkleRoot(this.transactions,!0);return 0===this.witnessCommit.compare(t)}}],[{key:"fromBuffer",value:function(t){if(t.length<80)throw new Error("Buffer too small (< 80 bytes)");var n=new Nj.BufferReader(t),r=new e;if(r.version=n.readInt32(),r.prevHash=n.readSlice(32),r.merkleRoot=n.readSlice(32),r.timestamp=n.readUInt32(),r.bits=n.readUInt32(),r.nonce=n.readUInt32(),80===t.length)return r;var i=function(){var e=Pj.Transaction.fromBuffer(n.buffer.slice(n.offset),!0);return n.offset+=e.byteLength(),e},o=n.readVarInt();r.transactions=[];for(var a=0;a<o;++a){var s=i();r.transactions.push(s)}var u=r.getWitnessCommit();return u&&(r.witnessCommit=u),r}},{key:"fromHex",value:function(t){return e.fromBuffer(Yo.from(t,"hex"))}},{key:"calculateTarget",value:function(e){var t=((4278190080&e)>>24)-3,n=8388607&e,r=Yo.alloc(32,0);return r.writeUIntBE(n,29-t,3),r}},{key:"calculateMerkleRoot",value:function(e,t){if(Lj([{getHash:Uj.Function}],e),0===e.length)throw Mj;if(t&&!Oj(e))throw Tj;var n=e.map((function(e){return e.getHash(t)})),r=(0,Fj.fastMerkleRoot)(n,Dj.hash256);return t?Dj.hash256(Yo.concat([r,e[0].ins[0].witness[0]])):r}}]),e}();function Oj(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}nj.Block=Rj;var Hj={},Kj={},jj={},Gj={},qj={},Vj={},zj={};!function(e){var t,n,r;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"],(n=e.InputTypes||(e.InputTypes={}))[n.NON_WITNESS_UTXO=0]="NON_WITNESS_UTXO",n[n.WITNESS_UTXO=1]="WITNESS_UTXO",n[n.PARTIAL_SIG=2]="PARTIAL_SIG",n[n.SIGHASH_TYPE=3]="SIGHASH_TYPE",n[n.REDEEM_SCRIPT=4]="REDEEM_SCRIPT",n[n.WITNESS_SCRIPT=5]="WITNESS_SCRIPT",n[n.BIP32_DERIVATION=6]="BIP32_DERIVATION",n[n.FINAL_SCRIPTSIG=7]="FINAL_SCRIPTSIG",n[n.FINAL_SCRIPTWITNESS=8]="FINAL_SCRIPTWITNESS",n[n.POR_COMMITMENT=9]="POR_COMMITMENT",n[n.TAP_KEY_SIG=19]="TAP_KEY_SIG",n[n.TAP_SCRIPT_SIG=20]="TAP_SCRIPT_SIG",n[n.TAP_LEAF_SCRIPT=21]="TAP_LEAF_SCRIPT",n[n.TAP_BIP32_DERIVATION=22]="TAP_BIP32_DERIVATION",n[n.TAP_INTERNAL_KEY=23]="TAP_INTERNAL_KEY",n[n.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"],(r=e.OutputTypes||(e.OutputTypes={}))[r.REDEEM_SCRIPT=0]="REDEEM_SCRIPT",r[r.WITNESS_SCRIPT=1]="WITNESS_SCRIPT",r[r.BIP32_DERIVATION=2]="BIP32_DERIVATION",r[r.TAP_INTERNAL_KEY=5]="TAP_INTERNAL_KEY",r[r.TAP_TREE=6]="TAP_TREE",r[r.TAP_BIP32_DERIVATION=7]="TAP_BIP32_DERIVATION",e.OUTPUT_TYPE_NAMES=["redeemScript","witnessScript","bip32Derivation","tapInternalKey","tapTree","tapBip32Derivation"]}(zj);var Jj={};Object.defineProperty(Jj,"__esModule",{value:!0});var Yj=zj;Jj.decode=function(e){if(e.key[0]!==Yj.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");for(var t,n=e.key.slice(1),r={masterFingerprint:e.value.slice(0,4),extendedPubkey:n,path:"m"},i=0,o=(t=e.value.length/4-1,k(Array(t).keys()));i<o.length;i++){var a=o[i],s=e.value.readUInt32LE(4*a+4),u=!!(2147483648&s),l=2147483647&s;r.path+="/"+l.toString(10)+(u?"'":"")}return r},Jj.encode=function(e){var t=Yo.from([Yj.GlobalTypes.GLOBAL_XPUB]),n=Yo.concat([t,e.extendedPubkey]),r=e.path.split("/"),i=Yo.allocUnsafe(4*r.length);e.masterFingerprint.copy(i,0);var o=4;return r.slice(1).forEach((function(e){var t="'"===e.slice(-1),n=2147483647&parseInt(t?e.slice(0,-1):e,10);t&&(n+=2147483648),i.writeUInt32LE(n,o),o+=4})),{key:n,value:i}},Jj.expected="{ masterFingerprint: Buffer; extendedPubkey: Buffer; path: string; }",Jj.check=function(e){var t=e.extendedPubkey,n=e.masterFingerprint,r=e.path;return Na(t)&&78===t.length&&[2,3].indexOf(t[45])>-1&&Na(n)&&4===n.length&&"string"==typeof r&&!!r.match(/^m(\/\d+'?)*$/)},Jj.canAddToArray=function(e,t,n){var r=t.extendedPubkey.toString("hex");return!n.has(r)&&(n.add(r),0===e.filter((function(e){return e.extendedPubkey.equals(t.extendedPubkey)})).length)};var Xj={};Object.defineProperty(Xj,"__esModule",{value:!0});var Wj=zj;Xj.encode=function(e){return{key:Yo.from([Wj.GlobalTypes.UNSIGNED_TX]),value:e.toBuffer()}};var Zj={};Object.defineProperty(Zj,"__esModule",{value:!0});var $j=zj;Zj.decode=function(e){if(e.key[0]!==$j.InputTypes.FINAL_SCRIPTSIG)throw new Error("Decode Error: could not decode finalScriptSig with key 0x"+e.key.toString("hex"));return e.value},Zj.encode=function(e){return{key:Yo.from([$j.InputTypes.FINAL_SCRIPTSIG]),value:e}},Zj.expected="Buffer",Zj.check=function(e){return Na(e)},Zj.canAdd=function(e,t){return!!e&&!!t&&void 0===e.finalScriptSig};var eG={};Object.defineProperty(eG,"__esModule",{value:!0});var tG=zj;eG.decode=function(e){if(e.key[0]!==tG.InputTypes.FINAL_SCRIPTWITNESS)throw new Error("Decode Error: could not decode finalScriptWitness with key 0x"+e.key.toString("hex"));return e.value},eG.encode=function(e){return{key:Yo.from([tG.InputTypes.FINAL_SCRIPTWITNESS]),value:e}},eG.expected="Buffer",eG.check=function(e){return Na(e)},eG.canAdd=function(e,t){return!!e&&!!t&&void 0===e.finalScriptWitness};var nG={};Object.defineProperty(nG,"__esModule",{value:!0});var rG=zj;nG.decode=function(e){if(e.key[0]!==rG.InputTypes.NON_WITNESS_UTXO)throw new Error("Decode Error: could not decode nonWitnessUtxo with key 0x"+e.key.toString("hex"));return e.value},nG.encode=function(e){return{key:Yo.from([rG.InputTypes.NON_WITNESS_UTXO]),value:e}},nG.expected="Buffer",nG.check=function(e){return Na(e)},nG.canAdd=function(e,t){return!!e&&!!t&&void 0===e.nonWitnessUtxo};var iG={};Object.defineProperty(iG,"__esModule",{value:!0});var oG=zj;iG.decode=function(e){if(e.key[0]!==oG.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}},iG.encode=function(e){var t=Yo.from([oG.InputTypes.PARTIAL_SIG]);return{key:Yo.concat([t,e.pubkey]),value:e.signature}},iG.expected="{ pubkey: Buffer; signature: Buffer; }",iG.check=function(e){return Na(e.pubkey)&&Na(e.signature)&&[33,65].includes(e.pubkey.length)&&[2,3,4].includes(e.pubkey[0])&&function(e){if(!Na(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;var t=e[3];if(t>33||t<1)return!1;if(2!==e[3+t+1])return!1;var n=e[3+t+2];return!(n>33||n<1)&&e.length===3+t+2+n+2}(e.signature)},iG.canAddToArray=function(e,t,n){var r=t.pubkey.toString("hex");return!n.has(r)&&(n.add(r),0===e.filter((function(e){return e.pubkey.equals(t.pubkey)})).length)};var aG={};Object.defineProperty(aG,"__esModule",{value:!0});var sG=zj;aG.decode=function(e){if(e.key[0]!==sG.InputTypes.POR_COMMITMENT)throw new Error("Decode Error: could not decode porCommitment with key 0x"+e.key.toString("hex"));return e.value.toString("utf8")},aG.encode=function(e){return{key:Yo.from([sG.InputTypes.POR_COMMITMENT]),value:Yo.from(e,"utf8")}},aG.expected="string",aG.check=function(e){return"string"==typeof e},aG.canAdd=function(e,t){return!!e&&!!t&&void 0===e.porCommitment};var uG={};Object.defineProperty(uG,"__esModule",{value:!0});var lG=zj;uG.decode=function(e){if(e.key[0]!==lG.InputTypes.SIGHASH_TYPE)throw new Error("Decode Error: could not decode sighashType with key 0x"+e.key.toString("hex"));return e.value.readUInt32LE(0)},uG.encode=function(e){var t=Yo.from([lG.InputTypes.SIGHASH_TYPE]),n=Yo.allocUnsafe(4);return n.writeUInt32LE(e,0),{key:t,value:n}},uG.expected="number",uG.check=function(e){return"number"==typeof e},uG.canAdd=function(e,t){return!!e&&!!t&&void 0===e.sighashType};var AG={};Object.defineProperty(AG,"__esModule",{value:!0});var cG=zj;function hG(e){return Na(e)&&(64===e.length||65===e.length)}AG.decode=function(e){if(e.key[0]!==cG.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(!hG(e.value))throw new Error("Decode Error: tapKeySig not a valid 64-65-byte BIP340 signature");return e.value},AG.encode=function(e){return{key:Yo.from([cG.InputTypes.TAP_KEY_SIG]),value:e}},AG.expected="Buffer",AG.check=hG,AG.canAdd=function(e,t){return!!e&&!!t&&void 0===e.tapKeySig};var fG={};Object.defineProperty(fG,"__esModule",{value:!0});var dG=zj;fG.decode=function(e){if(e.key[0]!==dG.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"));var 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"));var n=e.value.slice(0,-1);return{controlBlock:e.key.slice(1),script:n,leafVersion:t}},fG.encode=function(e){var t=Yo.from([dG.InputTypes.TAP_LEAF_SCRIPT]),n=Yo.from([e.leafVersion]);return{key:Yo.concat([t,e.controlBlock]),value:Yo.concat([e.script,n])}},fG.expected="{ controlBlock: Buffer; leafVersion: number, script: Buffer; }",fG.check=function(e){return Na(e.controlBlock)&&(e.controlBlock.length-1)%32==0&&(254&e.controlBlock[0])===e.leafVersion&&Na(e.script)},fG.canAddToArray=function(e,t,n){var r=t.controlBlock.toString("hex");return!n.has(r)&&(n.add(r),0===e.filter((function(e){return e.controlBlock.equals(t.controlBlock)})).length)};var pG={};Object.defineProperty(pG,"__esModule",{value:!0});var gG=zj;function vG(e){return Na(e)&&32===e.length}pG.decode=function(e){if(e.key[0]!==gG.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(!vG(e.value))throw new Error("Decode Error: tapMerkleRoot not a 32-byte hash");return e.value},pG.encode=function(e){return{key:Yo.from([gG.InputTypes.TAP_MERKLE_ROOT]),value:e}},pG.expected="Buffer",pG.check=vG,pG.canAdd=function(e,t){return!!e&&!!t&&void 0===e.tapMerkleRoot};var yG={};Object.defineProperty(yG,"__esModule",{value:!0});var mG=zj;yG.decode=function(e){if(e.key[0]!==mG.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}},yG.encode=function(e){var t=Yo.from([mG.InputTypes.TAP_SCRIPT_SIG]);return{key:Yo.concat([t,e.pubkey,e.leafHash]),value:e.signature}},yG.expected="{ pubkey: Buffer; leafHash: Buffer; signature: Buffer; }",yG.check=function(e){return Na(e.pubkey)&&Na(e.leafHash)&&Na(e.signature)&&32===e.pubkey.length&&32===e.leafHash.length&&(64===e.signature.length||65===e.signature.length)},yG.canAddToArray=function(e,t,n){var r=t.pubkey.toString("hex")+t.leafHash.toString("hex");return!n.has(r)&&(n.add(r),0===e.filter((function(e){return e.pubkey.equals(t.pubkey)&&e.leafHash.equals(t.leafHash)})).length)};var wG={},bG={},IG={};function BG(e){if(e<0||e>9007199254740991||e%1!=0)throw new RangeError("value out of range")}function EG(e){return BG(e),e<253?1:e<=65535?3:e<=4294967295?5:9}Object.defineProperty(IG,"__esModule",{value:!0}),IG.encode=function e(t,n,r){if(BG(t),n||(n=Yo.allocUnsafe(EG(t))),!Na(n))throw new TypeError("buffer must be a Buffer instance");return r||(r=0),t<253?(n.writeUInt8(t,r),Object.assign(e,{bytes:1})):t<=65535?(n.writeUInt8(253,r),n.writeUInt16LE(t,r+1),Object.assign(e,{bytes:3})):t<=4294967295?(n.writeUInt8(254,r),n.writeUInt32LE(t,r+1),Object.assign(e,{bytes:5})):(n.writeUInt8(255,r),n.writeUInt32LE(t>>>0,r+1),n.writeUInt32LE(t/4294967296|0,r+5),Object.assign(e,{bytes:9})),n},IG.decode=function e(t,n){if(!Na(t))throw new TypeError("buffer must be a Buffer instance");n||(n=0);var r=t.readUInt8(n);if(r<253)return Object.assign(e,{bytes:1}),r;if(253===r)return Object.assign(e,{bytes:3}),t.readUInt16LE(n+1);if(254===r)return Object.assign(e,{bytes:5}),t.readUInt32LE(n+1);Object.assign(e,{bytes:9});var i=t.readUInt32LE(n+1),o=4294967296*t.readUInt32LE(n+5)+i;return BG(o),o},IG.encodingLength=EG,Object.defineProperty(bG,"__esModule",{value:!0});var CG=IG;function xG(e){var t=e.key.length,n=e.value.length,r=CG.encodingLength(t),i=CG.encodingLength(n),o=Yo.allocUnsafe(r+t+i+n);return CG.encode(t,o,0),e.key.copy(o,r),CG.encode(n,o,r+t),e.value.copy(o,r+t+i),o}function kG(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")}bG.range=function(e){return k(Array(e).keys())},bG.reverseBuffer=function(e){if(e.length<1)return e;for(var t=e.length-1,n=0,r=0;r<e.length/2;r++)n=e[r],e[r]=e[t],e[t]=n,t--;return e},bG.keyValsToBuffer=function(e){var t=e.map(xG);return t.push(Yo.from([0])),Yo.concat(t)},bG.keyValToBuffer=xG,bG.readUInt64LE=function(e,t){var n=e.readUInt32LE(t),r=e.readUInt32LE(t+4);return kG((r*=4294967296)+n,9007199254740991),r+n},bG.writeUInt64LE=function(e,t,n){return kG(t,9007199254740991),e.writeInt32LE(-1&t,n),e.writeUInt32LE(Math.floor(t/4294967296),n+4),n+8},Object.defineProperty(wG,"__esModule",{value:!0});var SG=zj,QG=bG,_G=IG;wG.decode=function(e){if(e.key[0]!==SG.InputTypes.WITNESS_UTXO)throw new Error("Decode Error: could not decode witnessUtxo with key 0x"+e.key.toString("hex"));var t=QG.readUInt64LE(e.value,0),n=8,r=_G.decode(e.value,n);n+=_G.encodingLength(r);var i=e.value.slice(n);if(i.length!==r)throw new Error("Decode Error: WITNESS_UTXO script is not proper length");return{script:i,value:t}},wG.encode=function(e){var t=e.script,n=e.value,r=_G.encodingLength(t.length),i=Yo.allocUnsafe(8+r+t.length);return QG.writeUInt64LE(i,n,0),_G.encode(t.length,i,8),t.copy(i,8+r),{key:Yo.from([SG.InputTypes.WITNESS_UTXO]),value:i}},wG.expected="{ script: Buffer; value: number; }",wG.check=function(e){return Na(e.script)&&"number"==typeof e.value},wG.canAdd=function(e,t){return!!e&&!!t&&void 0===e.witnessUtxo};var NG={};Object.defineProperty(NG,"__esModule",{value:!0});var DG=zj,FG=IG;NG.decode=function(e){if(e.key[0]!==DG.OutputTypes.TAP_TREE||1!==e.key.length)throw new Error("Decode Error: could not decode tapTree with key 0x"+e.key.toString("hex"));for(var t=0,n=[];t<e.value.length;){var r=e.value[t++],i=e.value[t++],o=FG.decode(e.value,t);t+=FG.encodingLength(o),n.push({depth:r,leafVersion:i,script:e.value.slice(t,t+o)}),t+=o}return{leaves:n}},NG.encode=function(e){var t,n=Yo.from([DG.OutputTypes.TAP_TREE]),r=(t=[]).concat.apply(t,k(e.leaves.map((function(e){return[Yo.of(e.depth,e.leafVersion),FG.encode(e.script.length),e.script]}))));return{key:n,value:Yo.concat(r)}},NG.expected="{ leaves: [{ depth: number; leafVersion: number, script: Buffer; }] }",NG.check=function(e){return Array.isArray(e.leaves)&&e.leaves.every((function(e){return e.depth>=0&&e.depth<=128&&(254&e.leafVersion)===e.leafVersion&&Na(e.script)}))},NG.canAdd=function(e,t){return!!e&&!!t&&void 0===e.tapTree};var PG={};Object.defineProperty(PG,"__esModule",{value:!0});var UG=function(e){return 33===e.length&&[2,3].includes(e[0])||65===e.length&&4===e[0]};PG.makeConverter=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:UG;return{decode:function(n){if(n.key[0]!==e)throw new Error("Decode Error: could not decode bip32Derivation with key 0x"+n.key.toString("hex"));var r=n.key.slice(1);if(!t(r))throw new Error("Decode Error: bip32Derivation has invalid pubkey in key 0x"+n.key.toString("hex"));if(n.value.length/4%1!=0)throw new Error("Decode Error: Input BIP32_DERIVATION value length should be multiple of 4");for(var i,o={masterFingerprint:n.value.slice(0,4),pubkey:r,path:"m"},a=0,s=(i=n.value.length/4-1,k(Array(i).keys()));a<s.length;a++){var u=s[a],l=n.value.readUInt32LE(4*u+4),A=!!(2147483648&l),c=2147483647&l;o.path+="/"+c.toString(10)+(A?"'":"")}return o},encode:function(t){var n=Yo.from([e]),r=Yo.concat([n,t.pubkey]),i=t.path.split("/"),o=Yo.allocUnsafe(4*i.length);t.masterFingerprint.copy(o,0);var a=4;return i.slice(1).forEach((function(e){var t="'"===e.slice(-1),n=2147483647&parseInt(t?e.slice(0,-1):e,10);t&&(n+=2147483648),o.writeUInt32LE(n,a),a+=4})),{key:r,value:o}},check:function(e){return Na(e.pubkey)&&Na(e.masterFingerprint)&&"string"==typeof e.path&&t(e.pubkey)&&4===e.masterFingerprint.length},expected:"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; }",canAddToArray:function(e,t,n){var r=t.pubkey.toString("hex");return!n.has(r)&&(n.add(r),0===e.filter((function(e){return e.pubkey.equals(t.pubkey)})).length)}}};var LG={};Object.defineProperty(LG,"__esModule",{value:!0}),LG.makeChecker=function(e){return function(t){var n;if(e.includes(t.key[0])&&(33!==(n=t.key.slice(1)).length&&65!==n.length||![2,3,4].includes(n[0])))throw new Error("Format Error: invalid pubkey in key 0x"+t.key.toString("hex"));return n}};var MG={};Object.defineProperty(MG,"__esModule",{value:!0}),MG.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(t){return{key:Yo.from([e]),value:t}},check:function(e){return Na(e)},expected:"Buffer",canAdd:function(e,t){return!!e&&!!t&&void 0===e.redeemScript}}};var TG={};Object.defineProperty(TG,"__esModule",{value:!0});var RG=IG,OG=PG,HG=function(e){return 32===e.length};TG.makeConverter=function(e){var t=OG.makeConverter(e,HG);return{decode:function(e){for(var n=RG.decode(e.value),r=RG.encodingLength(n),i=t.decode({key:e.key,value:e.value.slice(r+32*n)}),o=new Array(n),a=0,s=r;a<n;a++,s+=32)o[a]=e.value.slice(s,s+32);return Object.assign({},i,{leafHashes:o})},encode:function(e){var n=t.encode(e),r=RG.encodingLength(e.leafHashes.length),i=Yo.allocUnsafe(r);RG.encode(e.leafHashes.length,i);var o=Yo.concat([i].concat(k(e.leafHashes),[n.value]));return Object.assign({},n,{value:o})},check:function(e){return Array.isArray(e.leafHashes)&&e.leafHashes.every((function(e){return Na(e)&&32===e.length}))&&t.check(e)},expected:"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; leafHashes: Buffer[]; }",canAddToArray:t.canAddToArray}};var KG={};Object.defineProperty(KG,"__esModule",{value:!0}),KG.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(t){return{key:Yo.from([e]),value:t}},check:function(e){return Na(e)&&32===e.length},expected:"Buffer",canAdd:function(e,t){return!!e&&!!t&&void 0===e.tapInternalKey}}};var jG={};Object.defineProperty(jG,"__esModule",{value:!0}),jG.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(t){return{key:Yo.from([e]),value:t}},check:function(e){return Na(e)},expected:"Buffer",canAdd:function(e,t){return!!e&&!!t&&void 0===e.witnessScript}}},Object.defineProperty(Vj,"__esModule",{value:!0});var GG=zj,qG=Zj,VG=eG,zG=nG,JG=iG,YG=aG,XG=uG,WG=AG,ZG=fG,$G=pG,eq=yG,tq=wG,nq=NG,rq=PG,iq=LG,oq=MG,aq=TG,sq=KG,uq=jG,lq={unsignedTx:Xj,globalXpub:Jj,checkPubkey:iq.makeChecker([])};Vj.globals=lq;var Aq={nonWitnessUtxo:zG,partialSig:JG,sighashType:XG,finalScriptSig:qG,finalScriptWitness:VG,porCommitment:YG,witnessUtxo:tq,bip32Derivation:rq.makeConverter(GG.InputTypes.BIP32_DERIVATION),redeemScript:oq.makeConverter(GG.InputTypes.REDEEM_SCRIPT),witnessScript:uq.makeConverter(GG.InputTypes.WITNESS_SCRIPT),checkPubkey:iq.makeChecker([GG.InputTypes.PARTIAL_SIG,GG.InputTypes.BIP32_DERIVATION]),tapKeySig:WG,tapScriptSig:eq,tapLeafScript:ZG,tapBip32Derivation:aq.makeConverter(GG.InputTypes.TAP_BIP32_DERIVATION),tapInternalKey:sq.makeConverter(GG.InputTypes.TAP_INTERNAL_KEY),tapMerkleRoot:$G};Vj.inputs=Aq;var cq={bip32Derivation:rq.makeConverter(GG.OutputTypes.BIP32_DERIVATION),redeemScript:oq.makeConverter(GG.OutputTypes.REDEEM_SCRIPT),witnessScript:uq.makeConverter(GG.OutputTypes.WITNESS_SCRIPT),checkPubkey:iq.makeChecker([GG.OutputTypes.BIP32_DERIVATION]),tapBip32Derivation:aq.makeConverter(GG.OutputTypes.TAP_BIP32_DERIVATION),tapTree:nq,tapInternalKey:sq.makeConverter(GG.OutputTypes.TAP_INTERNAL_KEY)};Vj.outputs=cq,Object.defineProperty(qj,"__esModule",{value:!0});var hq=Vj,fq=bG,dq=IG,pq=zj;function gq(e,t,n){if(!t.equals(Yo.from([n])))throw new Error("Format Error: Invalid ".concat(e," key: ").concat(t.toString("hex")))}function vq(e,t){var n,r=t.globalMapKeyVals,i=t.inputKeyVals,o=t.outputKeyVals,a={unsignedTx:e},s=0,u=F(r);try{for(u.s();!(n=u.n()).done;){var l=n.value;switch(l.key[0]){case pq.GlobalTypes.UNSIGNED_TX:if(gq("global",l.key,pq.GlobalTypes.UNSIGNED_TX),s>0)throw new Error("Format Error: GlobalMap has multiple UNSIGNED_TX");s++;break;case pq.GlobalTypes.GLOBAL_XPUB:void 0===a.globalXpub&&(a.globalXpub=[]),a.globalXpub.push(hq.globals.globalXpub.decode(l));break;default:a.unknownKeyVals||(a.unknownKeyVals=[]),a.unknownKeyVals.push(l)}}}catch(e){u.e(e)}finally{u.f()}var A,c=i.length,h=o.length,f=[],d=[],p=F(fq.range(c));try{for(p.s();!(A=p.n()).done;){var g,v=A.value,y={},m=F(i[v]);try{for(m.s();!(g=m.n()).done;){var w=g.value;switch(hq.inputs.checkPubkey(w),w.key[0]){case pq.InputTypes.NON_WITNESS_UTXO:if(gq("input",w.key,pq.InputTypes.NON_WITNESS_UTXO),void 0!==y.nonWitnessUtxo)throw new Error("Format Error: Input has multiple NON_WITNESS_UTXO");y.nonWitnessUtxo=hq.inputs.nonWitnessUtxo.decode(w);break;case pq.InputTypes.WITNESS_UTXO:if(gq("input",w.key,pq.InputTypes.WITNESS_UTXO),void 0!==y.witnessUtxo)throw new Error("Format Error: Input has multiple WITNESS_UTXO");y.witnessUtxo=hq.inputs.witnessUtxo.decode(w);break;case pq.InputTypes.PARTIAL_SIG:void 0===y.partialSig&&(y.partialSig=[]),y.partialSig.push(hq.inputs.partialSig.decode(w));break;case pq.InputTypes.SIGHASH_TYPE:if(gq("input",w.key,pq.InputTypes.SIGHASH_TYPE),void 0!==y.sighashType)throw new Error("Format Error: Input has multiple SIGHASH_TYPE");y.sighashType=hq.inputs.sighashType.decode(w);break;case pq.InputTypes.REDEEM_SCRIPT:if(gq("input",w.key,pq.InputTypes.REDEEM_SCRIPT),void 0!==y.redeemScript)throw new Error("Format Error: Input has multiple REDEEM_SCRIPT");y.redeemScript=hq.inputs.redeemScript.decode(w);break;case pq.InputTypes.WITNESS_SCRIPT:if(gq("input",w.key,pq.InputTypes.WITNESS_SCRIPT),void 0!==y.witnessScript)throw new Error("Format Error: Input has multiple WITNESS_SCRIPT");y.witnessScript=hq.inputs.witnessScript.decode(w);break;case pq.InputTypes.BIP32_DERIVATION:void 0===y.bip32Derivation&&(y.bip32Derivation=[]),y.bip32Derivation.push(hq.inputs.bip32Derivation.decode(w));break;case pq.InputTypes.FINAL_SCRIPTSIG:gq("input",w.key,pq.InputTypes.FINAL_SCRIPTSIG),y.finalScriptSig=hq.inputs.finalScriptSig.decode(w);break;case pq.InputTypes.FINAL_SCRIPTWITNESS:gq("input",w.key,pq.InputTypes.FINAL_SCRIPTWITNESS),y.finalScriptWitness=hq.inputs.finalScriptWitness.decode(w);break;case pq.InputTypes.POR_COMMITMENT:gq("input",w.key,pq.InputTypes.POR_COMMITMENT),y.porCommitment=hq.inputs.porCommitment.decode(w);break;case pq.InputTypes.TAP_KEY_SIG:gq("input",w.key,pq.InputTypes.TAP_KEY_SIG),y.tapKeySig=hq.inputs.tapKeySig.decode(w);break;case pq.InputTypes.TAP_SCRIPT_SIG:void 0===y.tapScriptSig&&(y.tapScriptSig=[]),y.tapScriptSig.push(hq.inputs.tapScriptSig.decode(w));break;case pq.InputTypes.TAP_LEAF_SCRIPT:void 0===y.tapLeafScript&&(y.tapLeafScript=[]),y.tapLeafScript.push(hq.inputs.tapLeafScript.decode(w));break;case pq.InputTypes.TAP_BIP32_DERIVATION:void 0===y.tapBip32Derivation&&(y.tapBip32Derivation=[]),y.tapBip32Derivation.push(hq.inputs.tapBip32Derivation.decode(w));break;case pq.InputTypes.TAP_INTERNAL_KEY:gq("input",w.key,pq.InputTypes.TAP_INTERNAL_KEY),y.tapInternalKey=hq.inputs.tapInternalKey.decode(w);break;case pq.InputTypes.TAP_MERKLE_ROOT:gq("input",w.key,pq.InputTypes.TAP_MERKLE_ROOT),y.tapMerkleRoot=hq.inputs.tapMerkleRoot.decode(w);break;default:y.unknownKeyVals||(y.unknownKeyVals=[]),y.unknownKeyVals.push(w)}}}catch(e){m.e(e)}finally{m.f()}f.push(y)}}catch(e){p.e(e)}finally{p.f()}var b,I=F(fq.range(h));try{for(I.s();!(b=I.n()).done;){var B,E=b.value,C={},x=F(o[E]);try{for(x.s();!(B=x.n()).done;){var k=B.value;switch(hq.outputs.checkPubkey(k),k.key[0]){case pq.OutputTypes.REDEEM_SCRIPT:if(gq("output",k.key,pq.OutputTypes.REDEEM_SCRIPT),void 0!==C.redeemScript)throw new Error("Format Error: Output has multiple REDEEM_SCRIPT");C.redeemScript=hq.outputs.redeemScript.decode(k);break;case pq.OutputTypes.WITNESS_SCRIPT:if(gq("output",k.key,pq.OutputTypes.WITNESS_SCRIPT),void 0!==C.witnessScript)throw new Error("Format Error: Output has multiple WITNESS_SCRIPT");C.witnessScript=hq.outputs.witnessScript.decode(k);break;case pq.OutputTypes.BIP32_DERIVATION:void 0===C.bip32Derivation&&(C.bip32Derivation=[]),C.bip32Derivation.push(hq.outputs.bip32Derivation.decode(k));break;case pq.OutputTypes.TAP_INTERNAL_KEY:gq("output",k.key,pq.OutputTypes.TAP_INTERNAL_KEY),C.tapInternalKey=hq.outputs.tapInternalKey.decode(k);break;case pq.OutputTypes.TAP_TREE:gq("output",k.key,pq.OutputTypes.TAP_TREE),C.tapTree=hq.outputs.tapTree.decode(k);break;case pq.OutputTypes.TAP_BIP32_DERIVATION:void 0===C.tapBip32Derivation&&(C.tapBip32Derivation=[]),C.tapBip32Derivation.push(hq.outputs.tapBip32Derivation.decode(k));break;default:C.unknownKeyVals||(C.unknownKeyVals=[]),C.unknownKeyVals.push(k)}}}catch(e){x.e(e)}finally{x.f()}d.push(C)}}catch(e){I.e(e)}finally{I.f()}return{globalMap:a,inputs:f,outputs:d}}qj.psbtFromBuffer=function(e,t){var n=0;function r(){var t=dq.decode(e,n);n+=dq.encodingLength(t);var r=e.slice(n,n+t);return n+=t,r}function i(){return{key:r(),value:r()}}function o(){if(n>=e.length)throw new Error("Format Error: Unexpected End of PSBT");var t=0===e.readUInt8(n);return t&&n++,t}if(1886610036!==function(){var t=e.readUInt32BE(n);return n+=4,t}())throw new Error("Format Error: Invalid Magic Number");if(255!==function(){var t=e.readUInt8(n);return n+=1,t}())throw new Error("Format Error: Magic Number must be followed by 0xff separator");for(var a=[],s={};!o();){var u=i(),l=u.key.toString("hex");if(s[l])throw new Error("Format Error: Keys must be unique for global keymap: key "+l);s[l]=1,a.push(u)}var A=a.filter((function(e){return e.key[0]===pq.GlobalTypes.UNSIGNED_TX}));if(1!==A.length)throw new Error("Format Error: Only one UNSIGNED_TX allowed");var c,h=t(A[0].value),f=h.getInputOutputCounts(),d=f.inputCount,p=f.outputCount,g=[],v=[],y=F(fq.range(d));try{for(y.s();!(c=y.n()).done;){for(var m=c.value,w={},b=[];!o();){var I=i(),B=I.key.toString("hex");if(w[B])throw new Error("Format Error: Keys must be unique for each input: input index "+m+" key "+B);w[B]=1,b.push(I)}g.push(b)}}catch(e){y.e(e)}finally{y.f()}var E,C=F(fq.range(p));try{for(C.s();!(E=C.n()).done;){for(var x=E.value,k={},S=[];!o();){var Q=i(),_=Q.key.toString("hex");if(k[_])throw new Error("Format Error: Keys must be unique for each output: output index "+x+" key "+_);k[_]=1,S.push(Q)}v.push(S)}}catch(e){C.e(e)}finally{C.f()}return vq(h,{globalMapKeyVals:a,inputKeyVals:g,outputKeyVals:v})},qj.checkKeyBuffer=gq,qj.psbtFromKeyVals=vq;var yq={};Object.defineProperty(yq,"__esModule",{value:!0});var mq=Vj,wq=bG;yq.psbtToBuffer=function(e){var t=Bq({globalMap:e.globalMap,inputs:e.inputs,outputs:e.outputs}),n=t.globalKeyVals,r=t.inputKeyVals,i=t.outputKeyVals,o=wq.keyValsToBuffer(n),a=function(e){return 0===e.length?[Yo.from([0])]:e.map(wq.keyValsToBuffer)},s=a(r),u=a(i),l=Yo.allocUnsafe(5);return l.writeUIntBE(482972169471,0,5),Yo.concat([l,o].concat(s,u))};var bq=function(e,t){return e.key.compare(t.key)};function Iq(e,t){var n=new Set,r=Object.entries(e).reduce((function(e,r){var i=C(r,2),o=i[0],a=i[1];if("unknownKeyVals"===o)return e;var s=t[o];if(void 0===s)return e;var u=(Array.isArray(a)?a:[a]).map(s.encode);return u.map((function(e){return e.key.toString("hex")})).forEach((function(e){if(n.has(e))throw new Error("Serialize Error: Duplicate key: "+e);n.add(e)})),e.concat(u)}),[]),i=e.unknownKeyVals?e.unknownKeyVals.filter((function(e){return!n.has(e.key.toString("hex"))})):[];return r.concat(i).sort(bq)}function Bq(e){var t=e.globalMap,n=e.inputs,r=e.outputs;return{globalKeyVals:Iq(t,mq.globals),inputKeyVals:n.map((function(e){return Iq(e,mq.inputs)})),outputKeyVals:r.map((function(e){return Iq(e,mq.outputs)}))}}yq.psbtToKeyVals=Bq,function(e){function t(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}Object.defineProperty(e,"__esModule",{value:!0}),t(qj),t(yq)}(Gj),Object.defineProperty(jj,"__esModule",{value:!0});var Eq=Gj;function Cq(e,t,n){return function(r){if(!e.has(r)){var i=n.filter((function(e){return e.key.toString("hex")===r}))[0];t.push(i),e.add(r)}}}function xq(e){return e.globalMap.unsignedTx}function kq(e){var t=new Set;return e.forEach((function(e){var n=e.key.toString("hex");if(t.has(n))throw new Error("Combine: KeyValue Map keys should be unique");t.add(n)})),t}jj.combine=function(e){var t=e[0],n=Eq.psbtToKeyVals(t),r=e.slice(1);if(0===r.length)throw new Error("Combine: Nothing to combine");var i=xq(t);if(void 0===i)throw new Error("Combine: Self missing transaction");var o,a=kq(n.globalKeyVals),s=n.inputKeyVals.map(kq),u=n.outputKeyVals.map(kq),l=F(r);try{var A=function(){var e=o.value,t=xq(e);if(void 0===t||!t.toBuffer().equals(i.toBuffer()))throw new Error("Combine: One of the Psbts does not have the same transaction.");var r=Eq.psbtToKeyVals(e);kq(r.globalKeyVals).forEach(Cq(a,n.globalKeyVals,r.globalKeyVals)),r.inputKeyVals.map(kq).forEach((function(e,t){return e.forEach(Cq(s[t],n.inputKeyVals[t],r.inputKeyVals[t]))})),r.outputKeyVals.map(kq).forEach((function(e,t){return e.forEach(Cq(u[t],n.outputKeyVals[t],r.outputKeyVals[t]))}))};for(l.s();!(o=l.n()).done;)A()}catch(e){l.e(e)}finally{l.f()}return Eq.psbtFromKeyVals(i,{globalMapKeyVals:n.globalKeyVals,inputKeyVals:n.inputKeyVals,outputKeyVals:n.outputKeyVals})};var Sq={};!function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=Vj;function n(e,t){var n=e[t];if(void 0===n)throw new Error("No input #".concat(t));return n}function r(e,t){var n=e[t];if(void 0===n)throw new Error("No output #".concat(t));return n}function i(e,t,n,r){throw new Error("Data for ".concat(e," key ").concat(t," is incorrect: Expected ").concat(n," and got ").concat(JSON.stringify(r)))}function o(e){return function(n,r){for(var o=function(){var o=s[a],u=n[o],l=t[e+"s"][o]||{},A=l.canAdd,c=l.canAddToArray,h=l.check,f=l.expected;if(h)if(!!c){if(!Array.isArray(u)||r[o]&&!Array.isArray(r[o]))throw new Error("Key type ".concat(o," must be an array"));u.every(h)||i(e,o,f,u);var d=r[o]||[],p=new Set;if(!u.every((function(e){return c(d,e,p)})))throw new Error("Can not add duplicate data to array");r[o]=d.concat(u)}else{if(h(u)||i(e,o,f,u),!A(r,u))throw new Error("Can not add duplicate data to ".concat(e));r[o]=u}},a=0,s=Object.keys(n);a<s.length;a++)o()}}e.checkForInput=n,e.checkForOutput=r,e.checkHasKey=function(e,t,n){if(e.key[0]<n)throw new Error("Use the method for your specific key instead of addUnknownKeyVal*");if(t&&0!==t.filter((function(t){return t.key.equals(e.key)})).length)throw new Error("Duplicate Key: ".concat(e.key.toString("hex")))},e.getEnumLength=function(e){var t=0;return Object.keys(e).forEach((function(e){Number(isNaN(Number(e)))&&t++})),t},e.inputCheckUncleanFinalized=function(e,t){var n=!1;if(t.nonWitnessUtxo||t.witnessUtxo){var r=!!t.redeemScript,i=!!t.witnessScript,o=!r||!!t.finalScriptSig,a=!i||!!t.finalScriptWitness,s=!!t.finalScriptSig||!!t.finalScriptWitness;n=o&&a&&s}if(!1===n)throw new Error("Input #".concat(e," has too much or too little data to clean"))},e.updateGlobal=o("global"),e.updateInput=o("input"),e.updateOutput=o("output"),e.addInputAttributes=function(t,r){var i=n(t,t.length-1);e.updateInput(r,i)},e.addOutputAttributes=function(t,n){var i=r(t,t.length-1);e.updateOutput(n,i)},e.defaultVersionSetter=function(e,t){if(!Na(t)||t.length<4)throw new Error("Set Version: Invalid Transaction");return t.writeUInt32LE(e,0),t},e.defaultLocktimeSetter=function(e,t){if(!Na(t)||t.length<4)throw new Error("Set Locktime: Invalid Transaction");return t.writeUInt32LE(e,t.length-4),t}}(Sq),Object.defineProperty(Kj,"__esModule",{value:!0});var Qq=jj,_q=Gj,Nq=zj,Dq=Sq;Kj.Psbt=function(){function e(t){s(this,e),this.inputs=[],this.outputs=[],this.globalMap={unsignedTx:t}}return l(e,[{key:"toBase64",value:function(){return this.toBuffer().toString("base64")}},{key:"toHex",value:function(){return this.toBuffer().toString("hex")}},{key:"toBuffer",value:function(){return _q.psbtToBuffer(this)}},{key:"updateGlobal",value:function(e){return Dq.updateGlobal(e,this.globalMap),this}},{key:"updateInput",value:function(e,t){var n=Dq.checkForInput(this.inputs,e);return Dq.updateInput(t,n),this}},{key:"updateOutput",value:function(e,t){var n=Dq.checkForOutput(this.outputs,e);return Dq.updateOutput(t,n),this}},{key:"addUnknownKeyValToGlobal",value:function(e){return Dq.checkHasKey(e,this.globalMap.unknownKeyVals,Dq.getEnumLength(Nq.GlobalTypes)),this.globalMap.unknownKeyVals||(this.globalMap.unknownKeyVals=[]),this.globalMap.unknownKeyVals.push(e),this}},{key:"addUnknownKeyValToInput",value:function(e,t){var n=Dq.checkForInput(this.inputs,e);return Dq.checkHasKey(t,n.unknownKeyVals,Dq.getEnumLength(Nq.InputTypes)),n.unknownKeyVals||(n.unknownKeyVals=[]),n.unknownKeyVals.push(t),this}},{key:"addUnknownKeyValToOutput",value:function(e,t){var n=Dq.checkForOutput(this.outputs,e);return Dq.checkHasKey(t,n.unknownKeyVals,Dq.getEnumLength(Nq.OutputTypes)),n.unknownKeyVals||(n.unknownKeyVals=[]),n.unknownKeyVals.push(t),this}},{key:"addInput",value:function(e){var t=this;this.globalMap.unsignedTx.addInput(e),this.inputs.push({unknownKeyVals:[]});var n=e.unknownKeyVals||[],r=this.inputs.length-1;if(!Array.isArray(n))throw new Error("unknownKeyVals must be an Array");return n.forEach((function(e){return t.addUnknownKeyValToInput(r,e)})),Dq.addInputAttributes(this.inputs,e),this}},{key:"addOutput",value:function(e){var t=this;this.globalMap.unsignedTx.addOutput(e),this.outputs.push({unknownKeyVals:[]});var n=e.unknownKeyVals||[],r=this.outputs.length-1;if(!Array.isArray(n))throw new Error("unknownKeyVals must be an Array");return n.forEach((function(e){return t.addUnknownKeyValToInput(r,e)})),Dq.addOutputAttributes(this.outputs,e),this}},{key:"clearFinalizedInput",value:function(e){var t=Dq.checkForInput(this.inputs,e);Dq.inputCheckUncleanFinalized(e,t);for(var n=0,r=Object.keys(t);n<r.length;n++){var i=r[n];["witnessUtxo","nonWitnessUtxo","finalScriptSig","finalScriptWitness","unknownKeyVals"].includes(i)||delete t[i]}return this}},{key:"combine",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=Qq.combine([this].concat(t));return Object.assign(this,r),this}},{key:"getTransaction",value:function(){return this.globalMap.unsignedTx.toBuffer()}}],[{key:"fromBase64",value:function(e,t){var n=Yo.from(e,"base64");return this.fromBuffer(n,t)}},{key:"fromHex",value:function(e,t){var n=Yo.from(e,"hex");return this.fromBuffer(n,t)}},{key:"fromBuffer",value:function(e,t){var n=_q.psbtFromBuffer(e,t),r=new this(n.globalMap.unsignedTx);return Object.assign(r,n),r}}]),e}(),Object.defineProperty(Hj,"__esModule",{value:!0}),Hj.Psbt=void 0;var Fq=Kj,Pq=IG,Uq=Sq,Lq=BU,Mq=rj,Tq=WL,Rq=CU,Oq=kU,Hq=gj,Kq={network:EU.bitcoin,maximumFeeRate:5e3},jq=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Fq.Psbt(new qq);s(this,e),this.data=n,this.opts=Object.assign({},Kq,t),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);var r=function(e,t,n,r){return Object.defineProperty(e,t,{enumerable:n,writable:r})};r(this,"__CACHE",!1,!0),r(this,"opts",!1,!0)}return l(e,[{key:"inputCount",get:function(){return this.data.inputs.length}},{key:"version",get:function(){return this.__CACHE.__TX.version},set:function(e){this.setVersion(e)}},{key:"locktime",get:function(){return this.__CACHE.__TX.locktime},set:function(e){this.setLocktime(e)}},{key:"txInputs",get:function(){return this.__CACHE.__TX.ins.map((function(e){return{hash:(0,Mq.cloneBuffer)(e.hash),index:e.index,sequence:e.sequence}}))}},{key:"txOutputs",get:function(){var e=this;return this.__CACHE.__TX.outs.map((function(t){var n;try{n=(0,Lq.fromOutputScript)(t.script,e.opts.network)}catch(t){}return{script:(0,Mq.cloneBuffer)(t.script),value:t.value,address:n}}))}},{key:"combine",value:function(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(e=this.data).combine.apply(e,k(n.map((function(e){return e.data})))),this}},{key:"clone",value:function(){var t=e.fromBuffer(this.data.toBuffer());return t.opts=JSON.parse(JSON.stringify(this.opts)),t}},{key:"setMaximumFeeRate",value:function(e){rV(e),this.opts.maximumFeeRate=e}},{key:"setVersion",value:function(e){rV(e),iV(this.data.inputs,"setVersion");var t=this.__CACHE;return t.__TX.version=e,t.__EXTRACTED_TX=void 0,this}},{key:"setLocktime",value:function(e){rV(e),iV(this.data.inputs,"setLocktime");var t=this.__CACHE;return t.__TX.locktime=e,t.__EXTRACTED_TX=void 0,this}},{key:"setInputSequence",value:function(e,t){rV(t),iV(this.data.inputs,"setInputSequence");var n=this.__CACHE;if(n.__TX.ins.length<=e)throw new Error("Input index too high");return n.__TX.ins[e].sequence=t,n.__EXTRACTED_TX=void 0,this}},{key:"addInputs",value:function(e){var t=this;return e.forEach((function(e){return t.addInput(e)})),this}},{key:"addInput",value:function(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]");iV(this.data.inputs,"addInput"),e.witnessScript&&IV(e.witnessScript);var t=this.__CACHE;this.data.addInput(e),aV(t,t.__TX.ins[t.__TX.ins.length-1]);var n=this.data.inputs.length-1,r=this.data.inputs[n];return r.nonWitnessUtxo&&gV(this.__CACHE,r,n),t.__FEE=void 0,t.__FEE_RATE=void 0,t.__EXTRACTED_TX=void 0,this}},{key:"addOutputs",value:function(e){var t=this;return e.forEach((function(e){return t.addOutput(e)})),this}},{key:"addOutput",value:function(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]");iV(this.data.inputs,"addOutput");var t=e,n=t.address;if("string"==typeof n){var r=this.opts.network,i=(0,Lq.toOutputScript)(n,r);e=Object.assign(e,{script:i})}var o=this.__CACHE;return this.data.addOutput(e),o.__FEE=void 0,o.__FEE_RATE=void 0,o.__EXTRACTED_TX=void 0,this}},{key:"extractTransaction",value:function(e){if(!this.data.inputs.every(Jq))throw new Error("Not finalized");var t=this.__CACHE;if(e||function(e,t,n){var r=t.__FEE_RATE||e.getFeeRate(),i=t.__EXTRACTED_TX.virtualSize(),o=r*i;if(r>=n.maximumFeeRate)throw new Error("Warning: You are paying around ".concat((o/1e8).toFixed(8)," in fees, which is ").concat(r," satoshi per byte for a transaction with a VSize of ").concat(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;var n=t.__TX.clone();return vV(this.data.inputs,n,t,!0),n}},{key:"getFeeRate",value:function(){return AV("__FEE_RATE","fee rate",this.data.inputs,this.__CACHE)}},{key:"getFee",value:function(){return AV("__FEE","fee",this.data.inputs,this.__CACHE)}},{key:"finalizeAllInputs",value:function(){var e=this;return(0,Uq.checkForInput)(this.data.inputs,0),CV(this.data.inputs.length).forEach((function(t){return e.finalizeInput(t)})),this}},{key:"finalizeInput",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:cV,n=(0,Uq.checkForInput)(this.data.inputs,e),r=function(e,t,n){var r=n.__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){var o=yV(n,t,e),a=r.ins[e].index;i.script=o.outs[a].script}else t.witnessUtxo&&(i.script=t.witnessUtxo.script);return(t.witnessScript||$q(i.script))&&(i.isSegwit=!0),i}(e,n,this.__CACHE),i=r.script,o=r.isP2SH,a=r.isP2WSH,s=r.isSegwit;if(!i)throw new Error("No script found for input #".concat(e));!function(e){if(e.sighashType&&e.partialSig){var t=e.partialSig,n=e.sighashType;t.forEach((function(e){var t=Oq.signature.decode(e.signature).hashType;if(n!==t)throw new Error("Signature sighash does not match input sighash type")}))}}(n);var u=t(e,n,i,s,o,a),l=u.finalScriptSig,A=u.finalScriptWitness;if(l&&this.data.updateInput(e,{finalScriptSig:l}),A&&this.data.updateInput(e,{finalScriptWitness:A}),!l&&!A)throw new Error("Unknown error finalizing input #".concat(e));return this.data.clearFinalizedInput(e),this}},{key:"getInputType",value:function(e){var t=(0,Uq.checkForInput)(this.data.inputs,e),n=bV(mV(e,t,this.__CACHE),e,"input",t.redeemScript||function(e){if(e){var t=Oq.decompile(e);if(t){var n,r=t[t.length-1];if(Na(r)&&!wV(r)&&(n=r,!Oq.isCanonicalScriptSignature(n)))if(Oq.decompile(r))return r}}}(t.finalScriptSig),t.witnessScript||function(e){if(e){var t=pV(e),n=t[t.length-1];if(!wV(n)&&Oq.decompile(n))return n}}(t.finalScriptWitness));return("raw"===n.type?"":n.type+"-")+EV(n.meaningfulScript)}},{key:"inputHasPubkey",value:function(e,t){return function(e,t,n,r){return BV(e,bV(mV(n,t,r),n,"input",t.redeemScript,t.witnessScript).meaningfulScript)}(t,(0,Uq.checkForInput)(this.data.inputs,e),e,this.__CACHE)}},{key:"inputHasHDKey",value:function(e,t){var n=(0,Uq.checkForInput)(this.data.inputs,e),r=nV(t);return!!n.bip32Derivation&&n.bip32Derivation.some(r)}},{key:"outputHasPubkey",value:function(e,t){return function(e,t,n,r){return BV(e,bV(r.__TX.outs[n].script,n,"output",t.redeemScript,t.witnessScript).meaningfulScript)}(t,(0,Uq.checkForOutput)(this.data.outputs,e),e,this.__CACHE)}},{key:"outputHasHDKey",value:function(e,t){var n=(0,Uq.checkForOutput)(this.data.outputs,e),r=nV(t);return!!n.bip32Derivation&&n.bip32Derivation.some(r)}},{key:"validateSignaturesOfAllInputs",value:function(e){var t=this;return(0,Uq.checkForInput)(this.data.inputs,0),CV(this.data.inputs.length).map((function(n){return t.validateSignaturesOfInput(n,e)})).reduce((function(e,t){return!0===t&&e}),!0)}},{key:"validateSignaturesOfInput",value:function(e,t,n){var r=this.data.inputs[e],i=(r||{}).partialSig;if(!r||!i||i.length<1)throw new Error("No signatures to validate");if("function"!=typeof t)throw new Error("Need validator function to validate signatures");var o=n?i.filter((function(e){return e.pubkey.equals(n)})):i;if(o.length<1)throw new Error("No signatures for this pubkey");var a,s,u,l,A=[],c=F(o);try{for(c.s();!(l=c.n()).done;){var h=l.value,f=Oq.signature.decode(h.signature),d=u!==f.hashType?fV(e,Object.assign({},r,{sighashType:f.hashType}),this.__CACHE,!0):{hash:a,script:s},p=d.hash,g=d.script;u=f.hashType,a=p,s=g,oV(h.pubkey,g,"verify"),A.push(t(h.pubkey,p,f.signature))}}catch(e){c.e(e)}finally{c.f()}return A.every((function(e){return!0===e}))}},{key:"signAllInputsHD",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[Hq.Transaction.SIGHASH_ALL];if(!e||!e.publicKey||!e.fingerprint)throw new Error("Need HDSigner to sign input");var n,r=[],i=F(CV(this.data.inputs.length));try{for(i.s();!(n=i.n()).done;){var o=n.value;try{this.signInputHD(o,e,t),r.push(!0)}catch(e){r.push(!1)}}}catch(e){i.e(e)}finally{i.f()}if(r.every((function(e){return!1===e})))throw new Error("No inputs were signed");return this}},{key:"signAllInputsHDAsync",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[Hq.Transaction.SIGHASH_ALL];return new Promise((function(r,i){if(!e||!e.publicKey||!e.fingerprint)return i(new Error("Need HDSigner to sign input"));var o,a=[],s=[],u=F(CV(t.data.inputs.length));try{for(u.s();!(o=u.n()).done;){var l=o.value;s.push(t.signInputHDAsync(l,e,n).then((function(){a.push(!0)}),(function(){a.push(!1)})))}}catch(e){u.e(e)}finally{u.f()}return Promise.all(s).then((function(){if(a.every((function(e){return!1===e})))return i(new Error("No inputs were signed"));r()}))}))}},{key:"signInputHD",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[Hq.Transaction.SIGHASH_ALL];if(!t||!t.publicKey||!t.fingerprint)throw new Error("Need HDSigner to sign input");return dV(e,this.data.inputs,t).forEach((function(t){return n.signInput(e,t,r)})),this}},{key:"signInputHDAsync",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[Hq.Transaction.SIGHASH_ALL];return new Promise((function(i,o){if(!t||!t.publicKey||!t.fingerprint)return o(new Error("Need HDSigner to sign input"));var a=dV(e,n.data.inputs,t).map((function(t){return n.signInputAsync(e,t,r)}));return Promise.all(a).then((function(){i()})).catch(o)}))}},{key:"signAllInputs",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[Hq.Transaction.SIGHASH_ALL];if(!e||!e.publicKey)throw new Error("Need Signer to sign input");var n,r=[],i=F(CV(this.data.inputs.length));try{for(i.s();!(n=i.n()).done;){var o=n.value;try{this.signInput(o,e,t),r.push(!0)}catch(e){r.push(!1)}}}catch(e){i.e(e)}finally{i.f()}if(r.every((function(e){return!1===e})))throw new Error("No inputs were signed");return this}},{key:"signAllInputsAsync",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[Hq.Transaction.SIGHASH_ALL];return new Promise((function(r,i){if(!e||!e.publicKey)return i(new Error("Need Signer to sign input"));var o,a=[],s=[],u=F(t.data.inputs.entries());try{for(u.s();!(o=u.n()).done;){var l=C(o.value,1)[0];s.push(t.signInputAsync(l,e,n).then((function(){a.push(!0)}),(function(){a.push(!1)})))}}catch(e){u.e(e)}finally{u.f()}return Promise.all(s).then((function(){if(a.every((function(e){return!1===e})))return i(new Error("No inputs were signed"));r()}))}))}},{key:"signInput",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[Hq.Transaction.SIGHASH_ALL];if(!t||!t.publicKey)throw new Error("Need Signer to sign input");var r=hV(this.data.inputs,e,t.publicKey,this.__CACHE,n),i=r.hash,o=r.sighashType,a=[{pubkey:t.publicKey,signature:Oq.signature.encode(t.sign(i),o)}];return this.data.updateInput(e,{partialSig:a}),this}},{key:"signInputAsync",value:function(e,t){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[Hq.Transaction.SIGHASH_ALL];return Promise.resolve().then((function(){if(!t||!t.publicKey)throw new Error("Need Signer to sign input");var i=hV(n.data.inputs,e,t.publicKey,n.__CACHE,r),o=i.hash,a=i.sighashType;return Promise.resolve(t.sign(o)).then((function(r){var i=[{pubkey:t.publicKey,signature:Oq.signature.encode(r,a)}];n.data.updateInput(e,{partialSig:i})}))}))}},{key:"toBuffer",value:function(){return Vq(this.__CACHE),this.data.toBuffer()}},{key:"toHex",value:function(){return Vq(this.__CACHE),this.data.toHex()}},{key:"toBase64",value:function(){return Vq(this.__CACHE),this.data.toBase64()}},{key:"updateGlobal",value:function(e){return this.data.updateGlobal(e),this}},{key:"updateInput",value:function(e,t){return t.witnessScript&&IV(t.witnessScript),this.data.updateInput(e,t),t.nonWitnessUtxo&&gV(this.__CACHE,this.data.inputs[e],e),this}},{key:"updateOutput",value:function(e,t){return this.data.updateOutput(e,t),this}},{key:"addUnknownKeyValToGlobal",value:function(e){return this.data.addUnknownKeyValToGlobal(e),this}},{key:"addUnknownKeyValToInput",value:function(e,t){return this.data.addUnknownKeyValToInput(e,t),this}},{key:"addUnknownKeyValToOutput",value:function(e,t){return this.data.addUnknownKeyValToOutput(e,t),this}},{key:"clearFinalizedInput",value:function(e){return this.data.clearFinalizedInput(e),this}}],[{key:"fromBase64",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=Yo.from(e,"base64");return this.fromBuffer(n,t)}},{key:"fromHex",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=Yo.from(e,"hex");return this.fromBuffer(n,t)}},{key:"fromBuffer",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=Fq.Psbt.fromBuffer(t,Gq),i=new e(n,r);return function(e,t){e.ins.forEach((function(e){aV(t,e)}))}(i.__CACHE.__TX,i.__CACHE),i}}]),e}();Hj.Psbt=jq;var Gq=function(e){return new qq(e)},qq=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Yo.from([2,0,0,0,0,0,0,0,0,0]);s(this,e),this.tx=Hq.Transaction.fromBuffer(t),function(e){if(!e.ins.every((function(e){return 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})}return l(e,[{key:"getInputOutputCounts",value:function(){return{inputCount:this.tx.ins.length,outputCount:this.tx.outs.length}}},{key:"addInput",value:function(e){if(void 0===e.hash||void 0===e.index||!Na(e.hash)&&"string"!=typeof e.hash||"number"!=typeof e.index)throw new Error("Error adding input.");var t="string"==typeof e.hash?(0,Mq.reverseBuffer)(Yo.from(e.hash,"hex")):e.hash;this.tx.addInput(t,e.index,e.sequence)}},{key:"addOutput",value:function(e){if(void 0===e.script||void 0===e.value||!Na(e.script)||"number"!=typeof e.value)throw new Error("Error adding output.");this.tx.addOutput(e.script,e.value)}},{key:"toBuffer",value:function(){return this.tx.toBuffer()}}]),e}();function Vq(e){if(!1!==e.__UNSAFE_SIGN_NONSEGWIT)throw new Error("Not BIP174 compliant, can not export")}function zq(e,t,n){if(!t)return!1;var r;if(r=n?n.map((function(e){var n=function(e){if(65===e.length){var t=1&e[64],n=e.slice(0,33);return n[0]=2|t,n}return e.slice()}(e);return t.find((function(e){return e.pubkey.equals(n)}))})).filter((function(e){return!!e})):t,r.length>e)throw new Error("Too many signatures");return r.length===e}function Jq(e){return!!e.finalScriptSig||!!e.finalScriptWitness}function Yq(e){return function(t){try{return e({output:t}),!0}catch(e){return!1}}}var Xq=Yq(Rq.p2ms),Wq=Yq(Rq.p2pk),Zq=Yq(Rq.p2pkh),$q=Yq(Rq.p2wpkh),eV=Yq(Rq.p2wsh),tV=Yq(Rq.p2sh);function nV(e){return function(t){return!!t.masterFingerprint.equals(e.fingerprint)&&!!e.derivePath(t.path).publicKey.equals(t.pubkey)}}function rV(e){if("number"!=typeof e||e!==Math.floor(e)||e>4294967295||e<0)throw new Error("Invalid 32 bit integer")}function iV(e,t){e.forEach((function(e){var n=!1,r=[];if(0===(e.partialSig||[]).length){if(!e.finalScriptSig&&!e.finalScriptWitness)return;r=function(e){var t=e.finalScriptSig&&Oq.decompile(e.finalScriptSig)||[],n=e.finalScriptWitness&&Oq.decompile(e.finalScriptWitness)||[];return t.concat(n).filter((function(e){return Na(e)&&Oq.isCanonicalScriptSignature(e)})).map((function(e){return{signature:e}}))}(e)}else r=e.partialSig;if(r.forEach((function(e){var r=Oq.signature.decode(e.signature).hashType,i=[];switch(r&Hq.Transaction.SIGHASH_ANYONECANPAY&&i.push("addInput"),31&r){case Hq.Transaction.SIGHASH_ALL:break;case Hq.Transaction.SIGHASH_SINGLE:case Hq.Transaction.SIGHASH_NONE:i.push("addOutput"),i.push("setInputSequence")}-1===i.indexOf(t)&&(n=!0)})),n)throw new Error("Can not modify transaction, signatures exist.")}))}function oV(e,t,n){if(!BV(e,t))throw new Error("Can not ".concat(n," for this input with the key ").concat(e.toString("hex")))}function aV(e,t){var n=(0,Mq.reverseBuffer)(Yo.from(t.hash)).toString("hex")+":"+t.index;if(e.__TX_IN_CACHE[n])throw new Error("Duplicate input detected.");e.__TX_IN_CACHE[n]=1}function sV(e,t){return function(n,r,i,o){var a=e({redeem:{output:i}}).output;if(!r.equals(a))throw new Error("".concat(t," for ").concat(o," #").concat(n," doesn't match the scriptPubKey in the prevout"))}}var uV=sV(Rq.p2sh,"Redeem script"),lV=sV(Rq.p2wsh,"Witness script");function AV(e,t,n,r){if(!n.every(Jq))throw new Error("PSBT must be finalized to calculate ".concat(t));if("__FEE_RATE"===e&&r.__FEE_RATE)return r.__FEE_RATE;if("__FEE"===e&&r.__FEE)return r.__FEE;var i,o=!0;return r.__EXTRACTED_TX?(i=r.__EXTRACTED_TX,o=!1):i=r.__TX.clone(),vV(n,i,r,o),"__FEE_RATE"===e?r.__FEE_RATE:"__FEE"===e?r.__FEE:void 0}function cV(e,t,n,r,i,o){var a=EV(n);if(!function(e,t,n){switch(n){case"pubkey":case"pubkeyhash":case"witnesspubkeyhash":return zq(1,e.partialSig);case"multisig":var r=Rq.p2ms({output:t});return zq(r.m,e.partialSig,r.pubkeys);default:return!1}}(t,n,a))throw new Error("Can not finalize input #".concat(e));return function(e,t,n,r,i,o){var a,s,u=function(e,t,n){var r;switch(t){case"multisig":var i=function(e,t){return Rq.p2ms({output:e}).pubkeys.map((function(e){return(t.filter((function(t){return t.pubkey.equals(e)}))[0]||{}).signature})).filter((function(e){return!!e}))}(e,n);r=Rq.p2ms({output:e,signatures:i});break;case"pubkey":r=Rq.p2pk({output:e,signature:n[0].signature});break;case"pubkeyhash":r=Rq.p2pkh({output:e,pubkey:n[0].pubkey,signature:n[0].signature});break;case"witnesspubkeyhash":r=Rq.p2wpkh({output:e,pubkey:n[0].pubkey,signature:n[0].signature})}return r}(e,t,n),l=o?Rq.p2wsh({redeem:u}):null,A=i?Rq.p2sh({redeem:l||u}):null;return r?(s=function(e){var t,n=Yo.allocUnsafe(0);function r(e){var t=n.length,r=Pq.encodingLength(e);n=Yo.concat([n,Yo.allocUnsafe(r)]),Pq.encode(e,n,t)}function i(e){r(e.length),function(e){n=Yo.concat([n,Yo.from(e)])}(e)}return r((t=e).length),t.forEach(i),n}(l?l.witness:u.witness),A&&(a=A.input)):a=A?A.input:u.input,{finalScriptSig:a,finalScriptWitness:s}}(n,a,t.partialSig,r,i,o)}function hV(e,t,n,r,i){var o=fV(t,(0,Uq.checkForInput)(e,t),r,!1,i),a=o.hash,s=o.sighashType;return oV(n,o.script,"sign"),{hash:a,sighashType:s}}function fV(e,t,n,r,i){var o,a,s=n.__TX,u=t.sighashType||Hq.Transaction.SIGHASH_ALL;if(i&&i.indexOf(u)<0){var l=function(e){var t=e&Hq.Transaction.SIGHASH_ANYONECANPAY?"SIGHASH_ANYONECANPAY | ":"";switch(31&e){case Hq.Transaction.SIGHASH_ALL:t+="SIGHASH_ALL";break;case Hq.Transaction.SIGHASH_SINGLE:t+="SIGHASH_SINGLE";break;case Hq.Transaction.SIGHASH_NONE:t+="SIGHASH_NONE"}return t}(u);throw new Error("Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ".concat(l))}if(t.nonWitnessUtxo){var A=yV(n,t,e),c=s.ins[e].hash,h=A.getHash();if(!c.equals(h))throw new Error("Non-witness UTXO hash for input #".concat(e," doesn't match the hash specified in the prevout"));var f=s.ins[e].index;a=A.outs[f]}else{if(!t.witnessUtxo)throw new Error("Need a Utxo input item for signing");a=t.witnessUtxo}var d=bV(a.script,e,"input",t.redeemScript,t.witnessScript),p=d.meaningfulScript,g=d.type;if(["p2sh-p2wsh","p2wsh"].indexOf(g)>=0)o=s.hashForWitnessV0(e,p,a.value,u);else if($q(p)){var v=Rq.p2pkh({hash:p.slice(2)}).output;o=s.hashForWitnessV0(e,v,a.value,u)}else{if(void 0===t.nonWitnessUtxo&&!1===n.__UNSAFE_SIGN_NONSEGWIT)throw new Error("Input #".concat(e," has witnessUtxo but non-segwit script: ").concat(p.toString("hex")));r||!1===n.__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*********************"),o=s.hashForSignature(e,p,u)}return{script:p,sighashType:u,hash:o}}function dV(e,t,n){var r=(0,Uq.checkForInput)(t,e);if(!r.bip32Derivation||0===r.bip32Derivation.length)throw new Error("Need bip32Derivation to sign with HD");var i=r.bip32Derivation.map((function(e){return e.masterFingerprint.equals(n.fingerprint)?e:void 0})).filter((function(e){return!!e}));if(0===i.length)throw new Error("Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint");var o=i.map((function(e){var t=n.derivePath(e.path);if(!e.pubkey.equals(t.publicKey))throw new Error("pubkey did not match bip32Derivation");return t}));return o}function pV(e){var t=0;function n(){var n=Pq.decode(e,t);return t+=Pq.decode.bytes,n}function r(){return r=n(),t+=r,e.slice(t-r,t);var r}return function(){for(var e=n(),t=[],i=0;i<e;i++)t.push(r());return t}()}function gV(e,t,n){e.__NON_WITNESS_UTXO_BUF_CACHE[n]=t.nonWitnessUtxo;var r=Hq.Transaction.fromBuffer(t.nonWitnessUtxo);e.__NON_WITNESS_UTXO_TX_CACHE[n]=r;var i=e,o=n;delete t.nonWitnessUtxo,Object.defineProperty(t,"nonWitnessUtxo",{enumerable:!0,get:function(){var e=i.__NON_WITNESS_UTXO_BUF_CACHE[o],t=i.__NON_WITNESS_UTXO_TX_CACHE[o];if(void 0!==e)return e;var n=t.toBuffer();return i.__NON_WITNESS_UTXO_BUF_CACHE[o]=n,n},set:function(e){i.__NON_WITNESS_UTXO_BUF_CACHE[o]=e}})}function vV(e,t,n,r){var i=0;e.forEach((function(e,o){if(r&&e.finalScriptSig&&(t.ins[o].script=e.finalScriptSig),r&&e.finalScriptWitness&&(t.ins[o].witness=pV(e.finalScriptWitness)),e.witnessUtxo)i+=e.witnessUtxo.value;else if(e.nonWitnessUtxo){var a=yV(n,e,o),s=t.ins[o].index,u=a.outs[s];i+=u.value}}));var o=t.outs.reduce((function(e,t){return e+t.value}),0),a=i-o;if(a<0)throw new Error("Outputs are spending more than Inputs");var s=t.virtualSize();n.__FEE=a,n.__EXTRACTED_TX=t,n.__FEE_RATE=Math.floor(a/s)}function yV(e,t,n){var r=e.__NON_WITNESS_UTXO_TX_CACHE;return r[n]||gV(e,t,n),r[n]}function mV(e,t,n){if(void 0!==t.witnessUtxo)return t.witnessUtxo.script;if(void 0!==t.nonWitnessUtxo)return yV(n,t,e).outs[n.__TX.ins[e].index].script;throw new Error("Can't find pubkey in input without Utxo data")}function wV(e){return 33===e.length&&Oq.isCanonicalPubKey(e)}function bV(e,t,n,r,i){var o,a=tV(e),s=a&&r&&eV(r),u=eV(e);if(a&&void 0===r)throw new Error("scriptPubkey is P2SH but redeemScript missing");if((u||s)&&void 0===i)throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");return s?(o=i,uV(t,e,r,n),lV(t,r,i,n),IV(o)):u?(o=i,lV(t,e,i,n),IV(o)):a?(o=r,uV(t,e,r,n)):o=e,{meaningfulScript:o,type:s?"p2sh-p2wsh":a?"p2sh":u?"p2wsh":"raw"}}function IV(e){if($q(e)||tV(e))throw new Error("P2WPKH or P2SH can not be contained within P2WSH")}function BV(e,t){var n=(0,Tq.hash160)(e),r=Oq.decompile(t);if(null===r)throw new Error("Unknown script error");return r.some((function(t){return"number"!=typeof t&&(t.equals(e)||t.equals(n))}))}function EV(e){return $q(e)?"witnesspubkeyhash":Zq(e)?"pubkeyhash":Xq(e)?"multisig":Wq(e)?"pubkey":"nonstandard"}function CV(e){return k(Array(e).keys())}!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Transaction=e.opcodes=e.Psbt=e.Block=e.script=e.payments=e.networks=e.crypto=e.address=void 0;var t=BU;e.address=t;var n=WL;e.crypto=n;var r=EU;e.networks=r;var i=CU;e.payments=i;var o=kU;e.script=o;var a=nj;Object.defineProperty(e,"Block",{enumerable:!0,get:function(){return a.Block}});var s=Hj;Object.defineProperty(e,"Psbt",{enumerable:!0,get:function(){return s.Psbt}});var u=QU;Object.defineProperty(e,"opcodes",{enumerable:!0,get:function(){return u.OPS}});var l=gj;Object.defineProperty(e,"Transaction",{enumerable:!0,get:function(){return l.Transaction}})}(IU);var xV={exports:{}};function kV(e,t){var n=function(e){for(var t=function(e){var t=mU.from(Object.assign(Object.assign({},e),{crv:"K-256"}),"jwk").toString("blk","public"),n=hx.publicKeyConvert(bU.from(t,"hex"),!0);return bU.from(n).toString("hex")}(e),n=bU.from(t,"hex"),r=32-n.length;r>0;)n=bU.concat([bU.from("00","hex"),n]),r--;return n}(e.publicKeyJwk),r=bF("errors","identityErrorBaseMessage"),i="";switch(t.code){case Dl.Bitcoin:case Dl.Mocknet:case Dl.Testnet:i=function(e,t){return IU.payments.p2pkh({pubkey:e,network:IU.networks[t.code]}).address}(n,t);break;case Dl.Ethmain:case Dl.Ethropst:case Dl.Ethrinkeby:case Dl.Ethgoerli:case Dl.Ethsepolia:i=function(e,t){var n=e.toString("hex"),r=new BI.ec("secp256k1").keyFromPublic(n,"hex").getPublic().encode("hex").slice(2),i=Yo;return"0x".concat(xV.exports.keccak256(i.from(r,"hex")).slice(24).toString())}(n);break;default:throw new yF("deriveIssuingAddressFromPublicKey","".concat(r," - ").concat(bF("errors","deriveIssuingAddressFromPublicKey")))}return i}function SV(e){if(e){var t="string"==typeof e?e:e.code;return!!Object.keys(Ul).some((function(e){return e===t}))&&!!Ul[t].test}return!1}!function(e){!function(){var t="input is invalid type",n="object"==("undefined"==typeof window?"undefined":i(window)),r=n?window:{};r.JS_SHA3_NO_WINDOW&&(n=!1);var o=!n&&"object"==("undefined"==typeof self?"undefined":i(self));!r.JS_SHA3_NO_NODE_JS&&"object"==i(lA)&&lA.versions&&lA.versions.node?r=No:o&&(r=self);var a=!r.JS_SHA3_NO_COMMON_JS&&e.exports,s=!r.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,u="0123456789abcdef".split(""),l=[4,1024,262144,67108864],A=[0,8,16,24],c=[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],h=[224,256,384,512],f=[128,256],d=["hex","buffer","arrayBuffer","array","digest"],p={128:168,256:136};!r.JS_SHA3_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!s||!r.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"==i(e)&&e.buffer&&e.buffer.constructor===ArrayBuffer});for(var g=function(e,t,n){return function(r){return new N(e,t,e).update(r)[n]()}},v=function(e,t,n){return function(r,i){return new N(e,t,i).update(r)[n]()}},y=function(e,t,n){return function(t,r,i,o){return B["cshake"+e].update(t,r,i,o)[n]()}},m=function(e,t,n){return function(t,r,i,o){return B["kmac"+e].update(t,r,i,o)[n]()}},w=function(e,t,n,r){for(var i=0;i<d.length;++i){var o=d[i];e[o]=t(n,r,o)}return e},b=function(e,t){var n=g(e,t,"hex");return n.create=function(){return new N(e,t,e)},n.update=function(e){return n.create().update(e)},w(n,g,e,t)},I=[{name:"keccak",padding:[1,256,65536,16777216],bits:h,createMethod:b},{name:"sha3",padding:[6,1536,393216,100663296],bits:h,createMethod:b},{name:"shake",padding:[31,7936,2031616,520093696],bits:f,createMethod:function(e,t){var n=v(e,t,"hex");return n.create=function(n){return new N(e,t,n)},n.update=function(e,t){return n.create(t).update(e)},w(n,v,e,t)}},{name:"cshake",padding:l,bits:f,createMethod:function(e,t){var n=p[e],r=y(e,0,"hex");return r.create=function(r,i,o){return i||o?new N(e,t,r).bytepad([i,o],n):B["shake"+e].create(r)},r.update=function(e,t,n,i){return r.create(t,n,i).update(e)},w(r,y,e,t)}},{name:"kmac",padding:l,bits:f,createMethod:function(e,t){var n=p[e],r=m(e,0,"hex");return r.create=function(r,i,o){return new D(e,t,i).bytepad(["KMAC",o],n).bytepad([r],n)},r.update=function(e,t,n,i){return r.create(e,n,i).update(t)},w(r,m,e,t)}}],B={},E=[],C=0;C<I.length;++C)for(var x=I[C],k=x.bits,S=0;S<k.length;++S){var Q=x.name+"_"+k[S];if(E.push(Q),B[Q]=x.createMethod(k[S],x.padding),"sha3"!==x.name){var _=x.name+k[S];E.push(_),B[_]=B[Q]}}function N(e,t,n){this.blocks=[],this.s=[],this.padding=t,this.outputBits=n,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=n>>5,this.extraBytes=(31&n)>>3;for(var r=0;r<50;++r)this.s[r]=0}function D(e,t,n){N.call(this,e,t,n)}N.prototype.update=function(e){if(this.finalized)throw new Error("finalize already called");var n,r=i(e);if("string"!==r){if("object"!==r)throw new Error(t);if(null===e)throw new Error(t);if(s&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||s&&ArrayBuffer.isView(e)))throw new Error(t);n=!0}for(var o,a,u=this.blocks,l=this.byteCount,c=e.length,h=this.blockCount,f=0,d=this.s;f<c;){if(this.reset)for(this.reset=!1,u[0]=this.block,o=1;o<h+1;++o)u[o]=0;if(n)for(o=this.start;f<c&&o<l;++f)u[o>>2]|=e[f]<<A[3&o++];else for(o=this.start;f<c&&o<l;++f)(a=e.charCodeAt(f))<128?u[o>>2]|=a<<A[3&o++]:a<2048?(u[o>>2]|=(192|a>>6)<<A[3&o++],u[o>>2]|=(128|63&a)<<A[3&o++]):a<55296||a>=57344?(u[o>>2]|=(224|a>>12)<<A[3&o++],u[o>>2]|=(128|a>>6&63)<<A[3&o++],u[o>>2]|=(128|63&a)<<A[3&o++]):(a=65536+((1023&a)<<10|1023&e.charCodeAt(++f)),u[o>>2]|=(240|a>>18)<<A[3&o++],u[o>>2]|=(128|a>>12&63)<<A[3&o++],u[o>>2]|=(128|a>>6&63)<<A[3&o++],u[o>>2]|=(128|63&a)<<A[3&o++]);if(this.lastByteIndex=o,o>=l){for(this.start=o-l,this.block=u[h],o=0;o<h;++o)d[o]^=u[o];F(d),this.reset=!0}else this.start=o}return this},N.prototype.encode=function(e,t){var n=255&e,r=1,i=[n];for(n=255&(e>>=8);n>0;)i.unshift(n),n=255&(e>>=8),++r;return t?i.push(r):i.unshift(r),this.update(i),i.length},N.prototype.encodeString=function(e){var n,r=i(e);if("string"!==r){if("object"!==r)throw new Error(t);if(null===e)throw new Error(t);if(s&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||s&&ArrayBuffer.isView(e)))throw new Error(t);n=!0}var o=0,a=e.length;if(n)o=a;else for(var u=0;u<e.length;++u){var l=e.charCodeAt(u);l<128?o+=1:l<2048?o+=2:l<55296||l>=57344?o+=3:(l=65536+((1023&l)<<10|1023&e.charCodeAt(++u)),o+=4)}return o+=this.encode(8*o),this.update(e),o},N.prototype.bytepad=function(e,t){for(var n=this.encode(t),r=0;r<e.length;++r)n+=this.encodeString(e[r]);var i=t-n%t,o=[];return o.length=i,this.update(o),this},N.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex,n=this.blockCount,r=this.s;if(e[t>>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[n],t=1;t<n+1;++t)e[t]=0;for(e[n-1]|=2147483648,t=0;t<n;++t)r[t]^=e[t];F(r)}},N.prototype.toString=N.prototype.hex=function(){this.finalize();for(var e,t=this.blockCount,n=this.s,r=this.outputBlocks,i=this.extraBytes,o=0,a=0,s="";a<r;){for(o=0;o<t&&a<r;++o,++a)e=n[o],s+=u[e>>4&15]+u[15&e]+u[e>>12&15]+u[e>>8&15]+u[e>>20&15]+u[e>>16&15]+u[e>>28&15]+u[e>>24&15];a%t==0&&(F(n),o=0)}return i&&(e=n[o],s+=u[e>>4&15]+u[15&e],i>1&&(s+=u[e>>12&15]+u[e>>8&15]),i>2&&(s+=u[e>>20&15]+u[e>>16&15])),s},N.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,n=this.s,r=this.outputBlocks,i=this.extraBytes,o=0,a=0,s=this.outputBits>>3;e=i?new ArrayBuffer(r+1<<2):new ArrayBuffer(s);for(var u=new Uint32Array(e);a<r;){for(o=0;o<t&&a<r;++o,++a)u[a]=n[o];a%t==0&&F(n)}return i&&(u[o]=n[o],e=e.slice(0,s)),e},N.prototype.buffer=N.prototype.arrayBuffer,N.prototype.digest=N.prototype.array=function(){this.finalize();for(var e,t,n=this.blockCount,r=this.s,i=this.outputBlocks,o=this.extraBytes,a=0,s=0,u=[];s<i;){for(a=0;a<n&&s<i;++a,++s)e=s<<2,t=r[a],u[e]=255&t,u[e+1]=t>>8&255,u[e+2]=t>>16&255,u[e+3]=t>>24&255;s%n==0&&F(r)}return o&&(e=s<<2,t=r[a],u[e]=255&t,o>1&&(u[e+1]=t>>8&255),o>2&&(u[e+2]=t>>16&255)),u},D.prototype=new N,D.prototype.finalize=function(){return this.encode(this.outputBits,!0),N.prototype.finalize.call(this)};var F=function(e){var t,n,r,i,o,a,s,u,l,A,h,f,d,p,g,v,y,m,w,b,I,B,E,C,x,k,S,Q,_,N,D,F,P,U,L,M,T,R,O,H,K,j,G,q,V,z,J,Y,X,W,Z,$,ee,te,ne,re,ie,oe,ae,se,ue,le,Ae;for(r=0;r<48;r+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],a=e[2]^e[12]^e[22]^e[32]^e[42],s=e[3]^e[13]^e[23]^e[33]^e[43],u=e[4]^e[14]^e[24]^e[34]^e[44],l=e[5]^e[15]^e[25]^e[35]^e[45],A=e[6]^e[16]^e[26]^e[36]^e[46],h=e[7]^e[17]^e[27]^e[37]^e[47],t=(f=e[8]^e[18]^e[28]^e[38]^e[48])^(a<<1|s>>>31),n=(d=e[9]^e[19]^e[29]^e[39]^e[49])^(s<<1|a>>>31),e[0]^=t,e[1]^=n,e[10]^=t,e[11]^=n,e[20]^=t,e[21]^=n,e[30]^=t,e[31]^=n,e[40]^=t,e[41]^=n,t=i^(u<<1|l>>>31),n=o^(l<<1|u>>>31),e[2]^=t,e[3]^=n,e[12]^=t,e[13]^=n,e[22]^=t,e[23]^=n,e[32]^=t,e[33]^=n,e[42]^=t,e[43]^=n,t=a^(A<<1|h>>>31),n=s^(h<<1|A>>>31),e[4]^=t,e[5]^=n,e[14]^=t,e[15]^=n,e[24]^=t,e[25]^=n,e[34]^=t,e[35]^=n,e[44]^=t,e[45]^=n,t=u^(f<<1|d>>>31),n=l^(d<<1|f>>>31),e[6]^=t,e[7]^=n,e[16]^=t,e[17]^=n,e[26]^=t,e[27]^=n,e[36]^=t,e[37]^=n,e[46]^=t,e[47]^=n,t=A^(i<<1|o>>>31),n=h^(o<<1|i>>>31),e[8]^=t,e[9]^=n,e[18]^=t,e[19]^=n,e[28]^=t,e[29]^=n,e[38]^=t,e[39]^=n,e[48]^=t,e[49]^=n,p=e[0],g=e[1],z=e[11]<<4|e[10]>>>28,J=e[10]<<4|e[11]>>>28,Q=e[20]<<3|e[21]>>>29,_=e[21]<<3|e[20]>>>29,se=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,j=e[40]<<18|e[41]>>>14,G=e[41]<<18|e[40]>>>14,U=e[2]<<1|e[3]>>>31,L=e[3]<<1|e[2]>>>31,v=e[13]<<12|e[12]>>>20,y=e[12]<<12|e[13]>>>20,Y=e[22]<<10|e[23]>>>22,X=e[23]<<10|e[22]>>>22,N=e[33]<<13|e[32]>>>19,D=e[32]<<13|e[33]>>>19,le=e[42]<<2|e[43]>>>30,Ae=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,ne=e[4]<<30|e[5]>>>2,M=e[14]<<6|e[15]>>>26,T=e[15]<<6|e[14]>>>26,m=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,W=e[34]<<15|e[35]>>>17,Z=e[35]<<15|e[34]>>>17,F=e[45]<<29|e[44]>>>3,P=e[44]<<29|e[45]>>>3,C=e[6]<<28|e[7]>>>4,x=e[7]<<28|e[6]>>>4,re=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,R=e[26]<<25|e[27]>>>7,O=e[27]<<25|e[26]>>>7,b=e[36]<<21|e[37]>>>11,I=e[37]<<21|e[36]>>>11,$=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,q=e[8]<<27|e[9]>>>5,V=e[9]<<27|e[8]>>>5,k=e[18]<<20|e[19]>>>12,S=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,ae=e[28]<<7|e[29]>>>25,H=e[38]<<8|e[39]>>>24,K=e[39]<<8|e[38]>>>24,B=e[48]<<14|e[49]>>>18,E=e[49]<<14|e[48]>>>18,e[0]=p^~v&m,e[1]=g^~y&w,e[10]=C^~k&Q,e[11]=x^~S&_,e[20]=U^~M&R,e[21]=L^~T&O,e[30]=q^~z&Y,e[31]=V^~J&X,e[40]=te^~re&oe,e[41]=ne^~ie&ae,e[2]=v^~m&b,e[3]=y^~w&I,e[12]=k^~Q&N,e[13]=S^~_&D,e[22]=M^~R&H,e[23]=T^~O&K,e[32]=z^~Y&W,e[33]=J^~X&Z,e[42]=re^~oe&se,e[43]=ie^~ae&ue,e[4]=m^~b&B,e[5]=w^~I&E,e[14]=Q^~N&F,e[15]=_^~D&P,e[24]=R^~H&j,e[25]=O^~K&G,e[34]=Y^~W&$,e[35]=X^~Z&ee,e[44]=oe^~se&le,e[45]=ae^~ue&Ae,e[6]=b^~B&p,e[7]=I^~E&g,e[16]=N^~F&C,e[17]=D^~P&x,e[26]=H^~j&U,e[27]=K^~G&L,e[36]=W^~$&q,e[37]=Z^~ee&V,e[46]=se^~le&te,e[47]=ue^~Ae&ne,e[8]=B^~p&v,e[9]=E^~g&y,e[18]=F^~C&k,e[19]=P^~x&S,e[28]=j^~U&M,e[29]=G^~L&T,e[38]=$^~q&z,e[39]=ee^~V&J,e[48]=le^~te&re,e[49]=Ae^~ne&ie,e[0]^=c[r],e[1]^=c[r+1]};if(a)e.exports=B;else for(C=0;C<E.length;++C)r[E[C]]=B[E[C]]}()}(xV);var QV,_V,NV=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){e.done?i(e.value):function(e){return e instanceof n?e:new n((function(t){t(e)}))}(e.value).then(a,s)}u((r=r.apply(e,t||[])).next())}))},DV=function(e){c(n,e);var t=b(n);function n(e){var r,i=e.issuer,o=void 0===i?null:i,a=e.verificationMethod,u=void 0===a?null:a,l=e.document,A=void 0===l?null:l,c=e.proof,h=void 0===c?null:c,f=e.options,d=void 0===f?{}:f;if(s(this,n),(r=t.call(this,{type:"MerkleProof2019"})).type="MerkleProof2019",r.issuer=null,r.verificationMethod=null,r.proof=null,r.proofValue=null,r.document=null,r.explorerAPIs=[],r.documentLoader=null,r.proofVerificationProcess=["getTransactionId","computeLocalHash","fetchRemoteHash","compareHashes","checkMerkleRoot","checkReceipt"],r.identityVerificationProcess=["deriveIssuingAddressFromPublicKey","compareIssuingAddress"],r.transactionId="",!A)throw new Error("A document signed by MerkleProof2019 is required for the verification process.");return r.issuer=o,r.verificationMethod=u,r.document=A,r.setProof(h),r.setOptions(d),r.getChain(),SV(r.chain)&&(r.adaptProofVerificationProcessToMocknet(),r.adaptIdentityVerificationProcessToMocknet()),w(r)}return l(n,[{key:"setProof",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=null!=e?e:this.document.proof;if(!t)throw new Error("The passed document is not signed.");this.proof=t,this.proofValue=n.decodeMerkleProof2019(this.proof)}},{key:"verifyProof",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{documentLoader:function(e){},verifyIdentity:!0},t=e.documentLoader,n=e.verifyIdentity;return NV(this,void 0,void 0,r().mark((function e(){var i,o;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.documentLoader=t,o="",e.prev=2,e.next=5,this.verifyProcess(this.proofVerificationProcess);case 5:if(e.t0=n,!e.t0){e.next=9;break}return e.next=9,this.verifyIdentity();case 9:i=!0,e.next=15;break;case 12:e.prev=12,e.t1=e.catch(2),console.error(e.t1),i=!1,o=e.t1.message;case 15:return e.abrupt("return",{verificationMethod:this.verificationMethod,verified:i,error:o});case 16:case"end":return e.stop()}}),e,this,[[2,12]])})))}},{key:"verifyIdentity",value:function(){return NV(this,void 0,void 0,r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==this.verificationMethod){e.next=9;break}return e.prev=1,e.next=4,this.verifyProcess(this.identityVerificationProcess);case 4:e.next=9;break;case 6:throw e.prev=6,e.t0=e.catch(1),new Error(e.t0);case 9:case"end":return e.stop()}}),e,this,[[1,6]])})))}},{key:"getProofVerificationProcess",value:function(){return this.proofVerificationProcess}},{key:"getIdentityVerificationProcess",value:function(){return this.identityVerificationProcess}},{key:"getIssuerPublicKey",value:function(){var e,t;return SV(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:""}},{key:"getIssuanceTime",value:function(){var e,t;return null!==(t=null===(e=this.getTxData())||void 0===e?void 0:e.time)&&void 0!==t?t:""}},{key:"getChain",value:function(){return this.chain||(this.chain=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(null==e?void 0:e.anchors){var t=e.anchors[0];if("string"==typeof t)return function(e){var t,n=e.split(":");switch(n[1]){case Ul.mocknet.blinkCode:return hF(Ul.mocknet.signatureValue);case Ul.bitcoin.blinkCode:t=Ul.bitcoin.name;break;case Ul.ethmain.blinkCode:t=Ul.ethmain.name;break;default:throw new Error("Could not retrieve chain.")}var r=n[2],i=t.toLowerCase()+function(e){var t=e.substr(0,1),n=e.substr(1,e.length-1);return t.toUpperCase()+n.toLowerCase()}(r);return hF(i)}(t)}return null}(this.proofValue)),this.chain}},{key:"getTxData",value:function(){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)}},{key:"adaptProofVerificationProcessToMocknet",value:function(){fF(this.proofVerificationProcess,"getTransactionId"),fF(this.proofVerificationProcess,"fetchRemoteHash"),fF(this.proofVerificationProcess,"checkMerkleRoot")}},{key:"adaptIdentityVerificationProcessToMocknet",value:function(){this.identityVerificationProcess=[]}},{key:"setOptions",value:function(e){var t;this.explorerAPIs=null!==(t=e.explorerAPIs)&&void 0!==t?t:[],e.executeStepMethod&&"function"==typeof e.executeStepMethod&&(this.executeStep=e.executeStepMethod)}},{key:"executeStep",value:function(e,t){return NV(this,void 0,void 0,r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))}},{key:"verifyProcess",value:function(e){return NV(this,void 0,void 0,r().mark((function t(){var n,i,o;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=F(e),t.prev=1,n.s();case 3:if((i=n.n()).done){t.next=11;break}if(this[o=i.value]){t.next=7;break}return t.abrupt("return",void console.error("verification logic for",o,"not implemented"));case 7:return t.next=9,this[o]();case 9:t.next=3;break;case 11:t.next=16;break;case 13:t.prev=13,t.t0=t.catch(1),n.e(t.t0);case 16:return t.prev=16,n.f(),t.finish(16);case 19:case"end":return t.stop()}}),t,this,[[1,13,16,19]])})))}},{key:"checkMerkleRoot",value:function(){return NV(this,void 0,void 0,r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep("checkMerkleRoot",(function(){return function(e,t){if(e!==t)throw new yF("checkMerkleRoot",bF("errors","ensureMerkleRootEqual"));return!0}(t.proofValue.merkleRoot,t.txData.remoteHash)}),this.type);case 2:case"end":return e.stop()}}),e,this)})))}},{key:"compareHashes",value:function(){return NV(this,void 0,void 0,r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep("compareHashes",(function(){return function(e,t){if(e!==t)throw new yF("compareHashes",bF("errors","ensureHashesEqual"));return!0}(t.localDocumentHash,t.proofValue.targetHash)}),this.type);case 2:case"end":return e.stop()}}),e,this)})))}},{key:"computeLocalHash",value:function(){return NV(this,void 0,void 0,r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep("computeLocalHash",(function(){return NV(t,void 0,void 0,r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,BF(this.document,this.proof,this.documentLoader);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}),this.type);case 2:this.localDocumentHash=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}},{key:"checkReceipt",value:function(){return NV(this,void 0,void 0,r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep("checkReceipt",(function(){return function(e){var t=e.targetHash,n=e.merkleRoot;try{var r=e.path;if(r&&t)for(var i in r){var o=r[i],a=void 0;if(void 0!==o.left)a=vF("".concat(o.left).concat(t)),t=vk(a);else{if(void 0===o.right)throw new yF("checkReceipt","Trigger catch error.");a=vF("".concat(t).concat(o.right)),t=vk(a)}}}catch(e){throw new yF("checkReceipt",bF("errors","ensureValidReceipt"))}if(t!==n)throw new yF("checkReceipt",bF("errors","invalidMerkleReceipt"))}(t.proofValue)}),this.type);case 2:case"end":return e.stop()}}),e,this)})))}},{key:"getTransactionId",value:function(){return NV(this,void 0,void 0,r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.transactionId=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(!e)throw new Error("DecodedProof is not set");var t=e.anchors,n=t[0];if("string"==typeof n)return n.split(":").pop();throw new Error("Could not retrieve transaction id as was provided an unexpected format")}(this.proofValue),e.next=3,this.executeStep("getTransactionId",(function(){return function(e){if("string"==typeof e&&e.length>0)return e;throw new yF("getTransactionId",bF("errors","isTransactionIdValid"))}(t.transactionId)}),this.type);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"fetchRemoteHash",value:function(){return NV(this,void 0,void 0,r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep("fetchRemoteHash",(function(){return NV(t,void 0,void 0,r().mark((function e(){var t;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Ff({transactionId:this.transactionId,chain:null===(t=this.chain)||void 0===t?void 0:t.code,explorerAPIs:this.explorerAPIs});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}),this.type);case 2:this.txData=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}},{key:"deriveIssuingAddressFromPublicKey",value:function(){return NV(this,void 0,void 0,r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep("deriveIssuingAddressFromPublicKey",(function(){return kV(t.verificationMethod,t.chain)}),this.type);case 2:this.derivedIssuingAddress=e.sent;case 3:case"end":return e.stop()}}),e,this)})))}},{key:"compareIssuingAddress",value:function(){return NV(this,void 0,void 0,r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep("compareIssuingAddress",(function(){return function(e,t){var n=bF("errors","identityErrorBaseMessage");if(e!==t)throw new yF("compareIssuingAddress","".concat(n," - ").concat(bF("errors","compareIssuingAddress")))}(t.getIssuerPublicKey(),t.derivedIssuingAddress)}),this.type);case 2:case"end":return e.stop()}}),e,this)})))}}],[{key:"decodeMerkleProof2019",value:function(e){return new dD.Decoder(e.proofValue).decode()}}]),n}(uF.suites.LinkedDataProof),FV=l((function e(t){s(this,e)}));function PV(e){return Array.isArray(e)?e.find((function(e){return"ChainedProof2021"!==e.type})).verificationMethod:e.verificationMethod}!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"}(QV||(QV={}));var UV=function(e){c(v,e);var t,n,i,o,u,h,f,d,p,g=b(v);function v(e){var t,n;return s(this,v),A(m(t=g.call(this,e)),"proofVerificationProcess",[QV.parseIssuerKeys,QV.checkAuthenticity]),A(m(t),"transactionId",void 0),A(m(t),"localHash",void 0),A(m(t),"documentToVerify",void 0),A(m(t),"txData",void 0),A(m(t),"chain",void 0),A(m(t),"explorerAPIs",void 0),A(m(t),"receipt",void 0),A(m(t),"issuerPublicKeyList",void 0),A(m(t),"issuer",void 0),A(m(t),"verificationMethodPublicKey",void 0),A(m(t),"derivedIssuingAddress",void 0),A(m(t),"hasDid",void 0),A(m(t),"proof",void 0),A(m(t),"type","MerkleProof2019"),A(m(t),"suite",void 0),t.executeStep=e.executeStep,t.documentToVerify=e.document,t.explorerAPIs=e.explorerAPIs,t.proof=e.proof,t.issuer=e.issuer,t.validateProofType(),t.receipt=(n=t.proof,DV.decodeMerkleProof2019(n)),t.transactionId=ek.certificates.getTransactionId(t.receipt),t.setHasDid(),t}return l(v,[{key:"init",value:(p=a(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.setVerificationSuite();case 2:this.chain=this.suite.getChain(),this.adaptVerificationProcessToChain();case 4:case"end":return e.stop()}}),e,this)}))),function(){return p.apply(this,arguments)})},{key:"verifyProof",value:(d=a(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.suite.verifyProof({verifyIdentity:!1});case 2:return e.next=4,this.verifyProcess(this.proofVerificationProcess);case 4:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"verifyIdentity",value:(f=a(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.suite.verifyIdentity();case 2:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"getProofVerificationSteps",value:function(e){return[].concat(k(this.suite.getProofVerificationProcess()),k(this.proofVerificationProcess)).map((function(t){return ek.verifier.convertToVerificationSubsteps(e,t)}))}},{key:"getIdentityVerificationSteps",value:function(e){return this.hasDid?this.suite.getIdentityVerificationProcess().map((function(t){return ek.verifier.convertToVerificationSubsteps(e,t)})):[]}},{key:"getIssuerPublicKey",value:function(){return this.suite.getIssuerPublicKey()}},{key:"getIssuanceTime",value:function(){return this.suite.getIssuanceTime()}},{key:"getIssuerName",value:function(){return this.issuer.name}},{key:"getIssuerProfileDomain",value:function(){var e;return null===(e=new URL(this.getIssuerProfileUrl()))||void 0===e?void 0:e.hostname}},{key:"getIssuerProfileUrl",value:function(){return this.issuer.id}},{key:"getSigningDate",value:function(){return this.proof.created}},{key:"getChain",value:function(){return this.suite.getChain()}},{key:"getReceipt",value:function(){return this.receipt}},{key:"getTransactionIdString",value:function(){return ek.certificates.getTransactionId(this.getReceipt())}},{key:"getTransactionLink",value:function(){return ek.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).transactionLink}},{key:"getRawTransactionLink",value:function(){return ek.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).rawTransactionLink}},{key:"executeStep",value:(h=a(r().mark((function e(t,n,i){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("executeStep method needs to be overwritten by injecting from Verifier");case 1:case"end":return e.stop()}}),e)}))),function(e,t,n){return h.apply(this,arguments)})},{key:"setVerificationSuite",value:(u=a(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.setIssuerFromProofVerificationMethod();case 2:this.verificationMethodPublicKey=kk(this.getTargetVerificationMethodContainer(),PV(this.proof)),this.suite=new DV({document:this.documentToVerify,proof:this.proof,verificationMethod:this.verificationMethodPublicKey,options:{explorerAPIs:this.explorerAPIs,executeStepMethod:this.executeStep}});case 4:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"adaptVerificationProcessToChain",value:function(){ek.chains.isMockChain(this.chain)&&(nd(this.proofVerificationProcess,QV.parseIssuerKeys),nd(this.proofVerificationProcess,QV.checkAuthenticity))}},{key:"getTargetVerificationMethodContainer",value:function(){var e;return null!==(e=this.issuer.didDocument)&&void 0!==e?e:this.issuer}},{key:"isProofChain",value:function(){return"ChainedProof2021"===this.proof.type}},{key:"setIssuerFromProofVerificationMethod",value:(o=a(r().mark((function e(){var t;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isProofChain()){e.next=5;break}return t=this.proof.verificationMethod.split("#")[0],e.next=4,ek.verifier.getIssuerProfile(t);case 4:this.issuer=e.sent;case 5:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"setHasDid",value:function(){if(this.isProofChain()){var e=this.proof.verificationMethod.split("#")[0];this.hasDid=ld(e)}else this.hasDid=!!this.issuer.didDocument}},{key:"validateProofType",value:function(){var e=this.isProofChain()?this.proof.chainedProofType:this.proof.type;if(e!==this.type)throw new Error("Incompatible proof type passed. Expected: ".concat(this.type,", Got: ").concat(e))}},{key:"verifyProcess",value:(i=a(r().mark((function e(t){var n,i,o;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=F(t),e.prev=1,n.s();case 3:if((i=n.n()).done){e.next=11;break}if(this[o=i.value]){e.next=7;break}return e.abrupt("return",void console.error("verification logic for",o,"not implemented"));case 7:return e.next=9,this[o]();case 9:e.next=3;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),n.e(e.t0);case 16:return e.prev=16,n.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,this,[[1,13,16,19]])}))),function(e){return i.apply(this,arguments)})},{key:"parseIssuerKeys",value:(n=a(r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep(QV.parseIssuerKeys,(function(){return ek.verifier.parseIssuerKeys(t.issuer)}),this.type);case 2:this.issuerPublicKeyList=e.sent;case 3:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"checkAuthenticity",value:(t=a(r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep(QV.checkAuthenticity,(function(){return Ck(t.issuerPublicKeyList,t.getIssuerPublicKey(),t.getIssuanceTime())}),this.type);case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),v}(FV);!function(e){e.getTransactionId="getTransactionId",e.computeLocalHash="computeLocalHash",e.fetchRemoteHash="fetchRemoteHash",e.parseIssuerKeys="parseIssuerKeys",e.compareHashes="compareHashes",e.checkMerkleRoot="checkMerkleRoot",e.checkReceipt="checkReceipt",e.checkAuthenticity="checkAuthenticity"}(_V||(_V={}));var LV=function(e){c(I,e);var t,n,i,o,u,h,f,d,p,g,v,y,w=b(I);function I(e){var t;return s(this,I),A(m(t=w.call(this,e)),"verificationProcess",[_V.getTransactionId,_V.computeLocalHash,_V.fetchRemoteHash,_V.compareHashes,_V.checkMerkleRoot,_V.checkReceipt,_V.parseIssuerKeys,_V.checkAuthenticity]),A(m(t),"transactionId",void 0),A(m(t),"localHash",void 0),A(m(t),"documentToVerify",void 0),A(m(t),"txData",void 0),A(m(t),"chain",void 0),A(m(t),"explorerAPIs",void 0),A(m(t),"receipt",void 0),A(m(t),"issuerPublicKeyList",void 0),A(m(t),"issuer",void 0),A(m(t),"proof",void 0),A(m(t),"type","MerkleProof2017"),e.executeStep&&(t.executeStep=e.executeStep),t.documentToVerify=e.document,t.explorerAPIs=e.explorerAPIs,t.issuer=e.issuer,t.proof=e.proof,t.validateProofType(),t.receipt=t.documentToVerify.signature,t.chain=ek.certificates.getChain("",t.receipt),t.transactionId=ek.certificates.getTransactionId(t.receipt),t.adaptVerificationProcessToChain(),t}return l(I,[{key:"init",value:(y=a(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)}))),function(){return y.apply(this,arguments)})},{key:"verifyProof",value:(v=a(r().mark((function e(){var t,n,i;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=F(this.verificationProcess),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=11;break}if(this[i=n.value]){e.next=7;break}return e.abrupt("return",void console.error("verification logic for",i,"not implemented"));case 7:return e.next=9,this[i]();case 9:e.next=3;break;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),t.e(e.t0);case 16:return e.prev=16,t.f(),e.finish(16);case 19:case"end":return e.stop()}}),e,this,[[1,13,16,19]])}))),function(){return v.apply(this,arguments)})},{key:"verifyIdentity",value:(g=a(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)}))),function(){return g.apply(this,arguments)})},{key:"getProofVerificationSteps",value:function(e){return this.verificationProcess.map((function(t){return ek.verifier.convertToVerificationSubsteps(e,t)}))}},{key:"getIdentityVerificationSteps",value:function(){return[]}},{key:"getIssuerPublicKey",value:function(){return ek.chains.isMockChain(this.chain)?"This mock chain does not support issuing addresses":this.txData?this.txData.issuingAddress:void console.error("Trying to access issuing address when txData not available yet. Did you run the `verify` method yet?")}},{key:"getIssuerName",value:function(){return this.issuer.name}},{key:"getIssuerProfileDomain",value:function(){var e;return null===(e=new URL(this.getIssuerProfileUrl()))||void 0===e?void 0:e.hostname}},{key:"getIssuerProfileUrl",value:function(){return this.issuer.id}},{key:"getSigningDate",value:function(){return this.documentToVerify.issuedOn}},{key:"getChain",value:function(){return this.chain}},{key:"getReceipt",value:function(){return this.receipt}},{key:"getTransactionIdString",value:function(){return ek.certificates.getTransactionId(this.getReceipt())}},{key:"getTransactionLink",value:function(){return ek.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).transactionLink}},{key:"getRawTransactionLink",value:function(){return ek.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).rawTransactionLink}},{key:"validateProofType",value:function(){if(this.proof.type[0]!==this.type)throw new Error("Incompatible proof type passed. Expected: ".concat(this.type,", Got: ").concat(this.proof.type[0]))}},{key:"adaptVerificationProcessToChain",value:function(){ek.chains.isMockChain(this.chain)&&(nd(this.verificationProcess,_V.getTransactionId),nd(this.verificationProcess,_V.fetchRemoteHash),nd(this.verificationProcess,_V.parseIssuerKeys),nd(this.verificationProcess,_V.checkMerkleRoot),nd(this.verificationProcess,_V.checkAuthenticity))}},{key:"executeStep",value:(p=a(r().mark((function e(t,n,i){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("doAction method needs to be overwritten by injecting from CVJS");case 1:case"end":return e.stop()}}),e)}))),function(e,t,n){return p.apply(this,arguments)})},{key:"getTransactionId",value:(d=a(r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep(_V.getTransactionId,(function(){return function(e){if("string"==typeof e&&e.length>0)return e;throw new $f("getTransactionId",zf("errors","isTransactionIdValid"))}(t.transactionId)}),this.type);case 2:case"end":return e.stop()}}),e,this)}))),function(){return d.apply(this,arguments)})},{key:"computeLocalHash",value:(f=a(r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep(_V.computeLocalHash,a(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Bk(t.documentToVerify);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)}))),this.type);case 2:this.localHash=e.sent;case 3:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"fetchRemoteHash",value:(h=a(r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep(_V.fetchRemoteHash,a(r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ek.verifier.lookForTx({transactionId:t.transactionId,chain:t.chain.code,explorerAPIs:t.explorerAPIs});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)}))),this.type);case 2:this.txData=e.sent;case 3:case"end":return e.stop()}}),e,this)}))),function(){return h.apply(this,arguments)})},{key:"compareHashes",value:(u=a(r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep(_V.compareHashes,(function(){return function(e,t){if(e!==t)throw new $f("compareHashes",zf("errors","ensureHashesEqual"));return!0}(t.localHash,t.receipt.targetHash)}),this.type);case 2:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"checkMerkleRoot",value:(o=a(r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep(_V.checkMerkleRoot,(function(){return function(e,t){if(e!==t)throw new $f("checkMerkleRoot",zf("errors","ensureMerkleRootEqual"));return!0}(t.receipt.merkleRoot,t.txData.remoteHash)}),this.type);case 2:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"checkReceipt",value:(i=a(r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep(_V.checkReceipt,(function(){return function(e){var t=e.targetHash,n=e.merkleRoot;try{var r=e.proof||e.path;if(r)for(var i in r){var o=r[i],a=void 0;if(void 0!==o.left)a=yk("".concat(o.left).concat(t)),t=vk(a);else{if(void 0===o.right)throw new $f("checkReceipt","Trigger catch error.");a=yk("".concat(t).concat(o.right)),t=vk(a)}}}catch(e){throw new $f("checkReceipt",zf("errors","ensureValidReceipt"))}if(t!==n)throw new $f("checkReceipt",zf("errors","invalidMerkleReceipt"))}(t.receipt)}),this.type);case 2:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"parseIssuerKeys",value:(n=a(r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep(_V.parseIssuerKeys,(function(){return ek.verifier.parseIssuerKeys(t.issuer)}),this.type);case 2:this.issuerPublicKeyList=e.sent;case 3:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"checkAuthenticity",value:(t=a(r().mark((function e(){var t=this;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.executeStep(_V.checkAuthenticity,(function(){return Ck(t.issuerPublicKeyList,t.txData.issuingAddress,t.txData.time)}),this.type);case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),I}(FV),MV={};function TV(e,t){return function(e,t,n){if(!(e instanceof Uint8Array))throw new TypeError('"input" must be a Uint8Array.');if(void 0!==n&&"number"!=typeof n)throw new TypeError('"maxline" must be a number.');if(0===e.length)return"";var r="",i=0,o=t.length,a=t.charAt(0),s=[0];for(i=0;i<e.length;++i){for(var u=e[i],l=0;l<s.length;++l)u+=s[l]<<8,s[l]=u%o,u=u/o|0;for(;u>0;)s.push(u%o),u=u/o|0}for(i=0;0===e[i]&&i<e.length-1;++i)r+=a;for(i=s.length-1;i>=0;--i)r+=t[s[i]];if(n){var A=new RegExp(".{1,"+n+"}","g");r=r.match(A).join("\r\n")}return r}(e,"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",t)}function RV(e){return function(e,t){if("string"!=typeof e)throw new TypeError('"input" must be a string.');if(0===e.length)return new Uint8Array;var n=MV[t];if(!n){n=MV[t]=[];for(var r=0;r<t.length;++r)n[t.charCodeAt(r)]=r}e=e.replace(/\s/g,"");for(var i=t.length,o=t.charAt(0),a=[0],s=0;s<e.length;s++){var u=n[e.charCodeAt(s)];if(void 0===u)return;for(var l=u,A=0;A<a.length;++A)l+=a[A]*i,a[A]=255&l,l>>=8;for(;l>0;)a.push(255&l),l>>=8}for(var c=0;e[c]===o&&c<e.length-1;++c)a.push(0);return new Uint8Array(a.reverse())}
530
530
  /*!
531
531
  * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
532
532
  */(e,"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")}