@blockcerts/blockcerts-verifier 1.73.0 → 1.74.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/bundle-stats.html +1 -1
  2. package/coverage/lcov.info +104 -104
  3. package/dist/{DataIntegrityProof-D8TnXEkl-CGiIg0kn.js → DataIntegrityProof-DRK-bLb_-CItV0ZXY.js} +2 -2
  4. package/dist/EcdsaSd2023-CdilbQE4-BlaeM9K_.js +26 -0
  5. package/dist/EcdsaSecp256k1Signature2019-rfxWS2XE-C73WHAtH.js +1 -0
  6. package/dist/{Ed25519Signature2020-D2tdrIA4-PSi5TCQH.js → Ed25519Signature2020-CDbX0d2Z-Dc1L-exZ.js} +8 -8
  7. package/dist/{EddsaRdfc2022-CpZAUc7W-BJP0532C.js → EddsaRdfc2022-Do0HFpDb-BcV_n8Fk.js} +4 -4
  8. package/dist/{HashlinkVerifier-BcdAFe02-DMjUYzMR.js → HashlinkVerifier-Cdnza1Dw-A9htzw7A.js} +1 -1
  9. package/dist/MerkleProof2017-5uQFQKSe-dtmePIpg.js +1 -0
  10. package/dist/MerkleProof2019-DraC60XD-B9XV8wNx.js +5 -0
  11. package/dist/checkBitStringStatusList-CKk6xxUL-D99R7EXK.js +1 -0
  12. package/dist/checkCredentialSchemaConformity-U2NlIuJZ-swOY09NS.js +1 -0
  13. package/dist/controlVerificationMethod-Blm4pE1t-BYBRLxNP.js +1 -0
  14. package/dist/{downloadPDF-BU6CfP-N.js → downloadPDF-C-y2U2YC.js} +2 -2
  15. package/dist/{ensureNotRevoked-BWp1jPEo-DSQMtjrj.js → ensureNotRevoked-DrQAPfcJ-BheL-ZKZ.js} +1 -1
  16. package/dist/ensureValidIssuingKey-D7OT4D35--HN0afRq.js +1 -0
  17. package/dist/index-BNsIYV4r-BnYxKy2f.js +14 -0
  18. package/dist/{index-OtXtCWrq-CyttRwCk.js → index-C4ZZHHRx-BOdwDnYa.js} +1 -1
  19. package/dist/index-CVS5Gn9h-DNgvq6Wk.js +7 -0
  20. package/dist/index-D2bS6rRi-D_ppNIsb.js +66 -0
  21. package/dist/{index-CB7VaVsF-G_Mj6xql.js → index-Dr7MpiEc-D5LHgMik.js} +12 -12
  22. package/dist/{index.es-C2GPR7m7.js → index.es-BmC2s_4v.js} +1 -1
  23. package/dist/jsonld-DOUjwF6J-dtl20tiV.js +33 -0
  24. package/dist/jsonld-signatures-BJXipuab-CB799Kkm.js +56 -0
  25. package/dist/main.js +122 -122
  26. package/dist/retrieveVerificationMethodPublicKey-CT9YA_Wr-Djl8Ri41.js +1 -0
  27. package/dist/{verifyIssuerProfile-zkczSLpC-CTHpISfH.js → verifyIssuerProfile-BG-odQrl-0JjZhiiC.js} +1 -1
  28. package/package.json +2 -2
  29. package/dist/EcdsaSd2023-D2eJBmaY-mHNjbn8h.js +0 -26
  30. package/dist/EcdsaSecp256k1Signature2019-BRdQnZ0o-D_QN8KrS.js +0 -1
  31. package/dist/MerkleProof2017-DW_9FhLr-C0dPtifx.js +0 -1
  32. package/dist/MerkleProof2019-DJbo7uW--CHlhsnHk.js +0 -5
  33. package/dist/checkBitStringStatusList-BUPuVWy_-CYedocxJ.js +0 -13
  34. package/dist/checkCredentialSchemaConformity-CJdGwNcY-CaSak-bD.js +0 -1
  35. package/dist/controlVerificationMethod-C71lJp3H-n-AbzkO8.js +0 -1
  36. package/dist/ensureValidIssuingKey-BYAR3LEF-76kiqVKA.js +0 -1
  37. package/dist/index-Jn9Q6fuB-uChPhl1c.js +0 -56
  38. package/dist/jsonld-DqC1oHcn-ruRlORc0.js +0 -88
  39. package/dist/retrieveVerificationMethodPublicKey-Dai7em0K-BqIH8qzD.js +0 -1
  40. /package/dist/{index-BCu3PGuw-Dh4-8Ruv.js → index-uKBVup0_-Dh4-8Ruv.js} +0 -0
  41. /package/dist/{index-KzSDgEl9-Dgus2xdV.js → index-yOIIz7AL-Dgus2xdV.js} +0 -0
  42. /package/dist/{webcrypto.es-9hytEjC6-gGk5JRJH.js → webcrypto.es-FKUHCUj--gGk5JRJH.js} +0 -0
@@ -0,0 +1,5 @@
1
+ import{s as e}from"./index-uKBVup0_-Dh4-8Ruv.js";import{d as t,b as r,r as n,c as i,l as o,e as s,B as a,f as c,S as u,h,p as f,j as l,k as d,m as p,n as y,o as g,q as E}from"./main.js";import{j as m}from"./jsonld-signatures-BJXipuab-CB799Kkm.js";import{j as _}from"./jsonld-DOUjwF6J-dtl20tiV.js";import{e as I,s as w}from"./ensureValidIssuingKey-D7OT4D35--HN0afRq.js";import{t as P,a as b}from"./index-Dr7MpiEc-D5LHgMik.js";import"./index-yOIIz7AL-Dgus2xdV.js";import{r as A}from"./retrieveVerificationMethodPublicKey-CT9YA_Wr-Djl8Ri41.js";import{S as O}from"./Suite-BmP2Qu19-D1ucdMDB.js";var T,R,S={type:"object",required:["merkleRoot","targetHash","anchors"],properties:{merkleRoot:{type:"string",minLength:64,maxLength:64},targetHash:{type:"string",minLength:64,maxLength:64},anchors:{type:"array",minItems:1,contains:{type:"string"}}}};e.validator(S);var v,N,U=h(R?T:(R=1,T={root:{merkleRoot:0,targetHash:1,anchors:2,path:3},path:{left:0,right:1},chain:{btc:{id:0,networks:{mainnet:1,testnet:3}},eth:{id:1,networks:{mainnet:1,ropsten:3,rinkeby:4,goerli:5,sepolia:11155111}},mtc:{id:2,networks:{mainnet:137,mumbai:80001}},mocknet:{id:-1,networks:{mocknet:-1}}}})),k={};function M(){if(N)return v;N=1;const e=p,{Buffer:t}=d,r=new TextDecoder("utf8",{fatal:!0,ignoreBOM:!0});class n extends e.Transform{constructor(e,r,n={}){let i=null,o=null;switch(typeof e){case"object":t.isBuffer(e)?i=e:e&&(n=e);break;case"string":i=e;break;case"undefined":break;default:throw new TypeError("Invalid input")}switch(typeof r){case"object":r&&(n=r);break;case"string":o=r;break;case"undefined":break;default:throw new TypeError("Invalid inputEncoding")}if(!n||"object"!=typeof n)throw new TypeError("Invalid options");null==i&&(i=n.input),null==o&&(o=n.inputEncoding),delete n.input,delete n.inputEncoding;const s=null==n.watchPipe||n.watchPipe;delete n.watchPipe;const a=Boolean(n.readError);delete n.readError,super(n),this.readError=a,s&&this.on("pipe",e=>{const t=e._readableState.objectMode;if(this.length>0&&t!==this._readableState.objectMode)throw new Error("Do not switch objectMode in the middle of the stream");this._readableState.objectMode=t,this._writableState.objectMode=t}),null!=i&&this.end(i,o)}static isNoFilter(e){return e instanceof this}static compare(e,t){if(!(e instanceof this))throw new TypeError("Arguments must be NoFilters");return e===t?0:e.compare(t)}static concat(e,r){if(!Array.isArray(e))throw new TypeError("list argument must be an Array of NoFilters");if(0===e.length||0===r)return t.alloc(0);null==r&&(r=e.reduce((e,t)=>{if(!(t instanceof n))throw new TypeError("list argument must be an Array of NoFilters");return e+t.length},0));let i=!0,o=!0;const s=e.map(e=>{if(!(e instanceof n))throw new TypeError("list argument must be an Array of NoFilters");const r=e.slice();return t.isBuffer(r)?o=!1:i=!1,r});if(i)return t.concat(s,r);if(o)return[].concat(...s).slice(0,r);throw new Error("Concatenating mixed object and byte streams not supported")}_transform(e,r,n){this._readableState.objectMode||t.isBuffer(e)||(e=t.from(e,r)),this.push(e),n()}_bufArray(){let e=this._readableState.buffer;if(!Array.isArray(e)){let t=e.head;for(e=[];null!=t;)e.push(t.data),t=t.next}return e}read(e){const t=super.read(e);if(null!=t){if(this.emit("read",t),this.readError&&t.length<e)throw new Error(`Read ${t.length}, wanted ${e}`)}else if(this.readError)throw new Error(`No data available, wanted ${e}`);return t}readFull(e){let t=null,r=null,n=null;return new Promise((i,o)=>{this.length>=e?i(this.read(e)):this.writableFinished?o(new Error(`Stream finished before ${e} bytes were available`)):(t=t=>{this.length>=e&&i(this.read(e))},r=()=>{o(new Error(`Stream finished before ${e} bytes were available`))},n=o,this.on("readable",t),this.on("error",n),this.on("finish",r))}).finally(()=>{t&&(this.removeListener("readable",t),this.removeListener("error",n),this.removeListener("finish",r))})}promise(e){let t=!1;return new Promise((r,n)=>{this.on("finish",()=>{const n=this.read();null==e||t||(t=!0,e(null,n)),r(n)}),this.on("error",r=>{null==e||t||(t=!0,e(r)),n(r)})})}compare(e){if(!(e instanceof n))throw new TypeError("Arguments must be NoFilters");if(this===e)return 0;const r=this.slice(),i=e.slice();if(t.isBuffer(r)&&t.isBuffer(i))return r.compare(i);throw new Error("Cannot compare streams in object mode")}equals(e){return 0===this.compare(e)}slice(e,r){if(this._readableState.objectMode)return this._bufArray().slice(e,r);const n=this._bufArray();switch(n.length){case 0:return t.alloc(0);case 1:return n[0].slice(e,r);default:return t.concat(n).slice(e,r)}}get(e){return this.slice()[e]}toJSON(){const e=this.slice();return t.isBuffer(e)?e.toJSON():e}toString(e,n,i){const o=this.slice(n,i);return t.isBuffer(o)?e&&"utf8"!==e?o.toString(e):r.decode(o):JSON.stringify(o)}[Symbol.for("nodejs.util.inspect.custom")](e,r){const n=this._bufArray().map(e=>t.isBuffer(e)?r.stylize(e.toString("hex"),"string"):JSON.stringify(e)).join(", ");return`${this.constructor.name} [${n}]`}get length(){return this._readableState.length}writeBigInt(e){let r=e.toString(16);if(e<0){const t=BigInt(Math.floor(r.length/2));r=(e=(BigInt(1)<<t*BigInt(8))+e).toString(16)}return r.length%2&&(r=`0${r}`),this.push(t.from(r,"hex"))}readUBigInt(e){const r=this.read(e);return t.isBuffer(r)?BigInt(`0x${r.toString("hex")}`):null}readBigInt(e){const r=this.read(e);if(!t.isBuffer(r))return null;let n=BigInt(`0x${r.toString("hex")}`);if(128&r[0]){n-=BigInt(1)<<BigInt(r.length)*BigInt(8)}return n}writeUInt8(e){const r=t.from([e]);return this.push(r)}writeUInt16LE(e){const r=t.alloc(2);return r.writeUInt16LE(e),this.push(r)}writeUInt16BE(e){const r=t.alloc(2);return r.writeUInt16BE(e),this.push(r)}writeUInt32LE(e){const r=t.alloc(4);return r.writeUInt32LE(e),this.push(r)}writeUInt32BE(e){const r=t.alloc(4);return r.writeUInt32BE(e),this.push(r)}writeInt8(e){const r=t.from([e]);return this.push(r)}writeInt16LE(e){const r=t.alloc(2);return r.writeUInt16LE(e),this.push(r)}writeInt16BE(e){const r=t.alloc(2);return r.writeUInt16BE(e),this.push(r)}writeInt32LE(e){const r=t.alloc(4);return r.writeUInt32LE(e),this.push(r)}writeInt32BE(e){const r=t.alloc(4);return r.writeUInt32BE(e),this.push(r)}writeFloatLE(e){const r=t.alloc(4);return r.writeFloatLE(e),this.push(r)}writeFloatBE(e){const r=t.alloc(4);return r.writeFloatBE(e),this.push(r)}writeDoubleLE(e){const r=t.alloc(8);return r.writeDoubleLE(e),this.push(r)}writeDoubleBE(e){const r=t.alloc(8);return r.writeDoubleBE(e),this.push(r)}writeBigInt64LE(e){const r=t.alloc(8);return r.writeBigInt64LE(e),this.push(r)}writeBigInt64BE(e){const r=t.alloc(8);return r.writeBigInt64BE(e),this.push(r)}writeBigUInt64LE(e){const r=t.alloc(8);return r.writeBigUInt64LE(e),this.push(r)}writeBigUInt64BE(e){const r=t.alloc(8);return r.writeBigUInt64BE(e),this.push(r)}readUInt8(){const e=this.read(1);return t.isBuffer(e)?e.readUInt8():null}readUInt16LE(){const e=this.read(2);return t.isBuffer(e)?e.readUInt16LE():null}readUInt16BE(){const e=this.read(2);return t.isBuffer(e)?e.readUInt16BE():null}readUInt32LE(){const e=this.read(4);return t.isBuffer(e)?e.readUInt32LE():null}readUInt32BE(){const e=this.read(4);return t.isBuffer(e)?e.readUInt32BE():null}readInt8(){const e=this.read(1);return t.isBuffer(e)?e.readInt8():null}readInt16LE(){const e=this.read(2);return t.isBuffer(e)?e.readInt16LE():null}readInt16BE(){const e=this.read(2);return t.isBuffer(e)?e.readInt16BE():null}readInt32LE(){const e=this.read(4);return t.isBuffer(e)?e.readInt32LE():null}readInt32BE(){const e=this.read(4);return t.isBuffer(e)?e.readInt32BE():null}readFloatLE(){const e=this.read(4);return t.isBuffer(e)?e.readFloatLE():null}readFloatBE(){const e=this.read(4);return t.isBuffer(e)?e.readFloatBE():null}readDoubleLE(){const e=this.read(8);return t.isBuffer(e)?e.readDoubleLE():null}readDoubleBE(){const e=this.read(8);return t.isBuffer(e)?e.readDoubleBE():null}readBigInt64LE(){const e=this.read(8);return t.isBuffer(e)?e.readBigInt64LE():null}readBigInt64BE(){const e=this.read(8);return t.isBuffer(e)?e.readBigInt64BE():null}readBigUInt64LE(){const e=this.read(8);return t.isBuffer(e)?e.readBigUInt64LE():null}readBigUInt64BE(){const e=this.read(8);return t.isBuffer(e)?e.readBigUInt64BE():null}}return v=n}var L,B,x,D,C,V,F,H,G,j,K,$,Y,z,W,J,q,X,Q,Z,ee,te,re,ne,ie={};function oe(){return L||(L=1,(e=ie).MT={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7},e.TAG={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,DECIMAL_FRAC:4,BIGFLOAT:5,BASE64URL_EXPECTED:21,BASE64_EXPECTED:22,BASE16_EXPECTED:23,CBOR:24,URI:32,BASE64URL:33,BASE64:34,REGEXP:35,MIME:36,SET:258},e.NUMBYTES={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31},e.SIMPLE={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23},e.SYMS={NULL:Symbol.for("github.com/hildjj/node-cbor/null"),UNDEFINED:Symbol.for("github.com/hildjj/node-cbor/undef"),PARENT:Symbol.for("github.com/hildjj/node-cbor/parent"),BREAK:Symbol.for("github.com/hildjj/node-cbor/break"),STREAM:Symbol.for("github.com/hildjj/node-cbor/stream")},e.SHIFT32=4294967296,e.BI={MINUS_ONE:BigInt(-1),NEG_MAX:BigInt(-1)-BigInt(Number.MAX_SAFE_INTEGER),MAXINT32:BigInt("0xffffffff"),MAXINT64:BigInt("0xffffffffffffffff"),SHIFT32:BigInt(e.SHIFT32)}),ie;var e}function se(){return B||(B=1,function(e){const{Buffer:t}=d,r=M(),n=p,i=oe(),{NUMBYTES:o,SHIFT32:s,BI:a,SYMS:c}=i,u=new TextDecoder("utf8",{fatal:!0,ignoreBOM:!0});e.utf8=e=>u.decode(e),e.utf8.checksUTF8=!0,e.isBufferish=function(e){return e&&"object"==typeof e&&(t.isBuffer(e)||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof ArrayBuffer||e instanceof DataView)},e.bufferishToBuffer=function(e){return t.isBuffer(e)?e:ArrayBuffer.isView(e)?t.from(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer?t.from(e):null},e.parseCBORint=function(e,t){switch(e){case o.ONE:return t.readUInt8(0);case o.TWO:return t.readUInt16BE(0);case o.FOUR:return t.readUInt32BE(0);case o.EIGHT:{const e=t.readUInt32BE(0),r=t.readUInt32BE(4);return e>2097151?BigInt(e)*a.SHIFT32+BigInt(r):e*s+r}default:throw new Error(`Invalid additional info for int: ${e}`)}},e.writeHalf=function(e,r){const n=t.allocUnsafe(4);n.writeFloatBE(r,0);const i=n.readUInt32BE(0);if(8191&i)return!1;let o=i>>16&32768;const s=i>>23&255,a=8388607&i;if(s>=113&&s<=142)o+=(s-112<<10)+(a>>13);else{if(!(s>=103&&s<113))return!1;if(a&(1<<126-s)-1)return!1;o+=a+8388608>>126-s}return e.writeUInt16BE(o),!0},e.parseHalf=function(e){const t=128&e[0]?-1:1,r=(124&e[0])>>2,n=(3&e[0])<<8|e[1];return r?31===r?t*(n?NaN:1/0):t*2**(r-25)*(1024+n):5.960464477539063e-8*t*n},e.parseCBORfloat=function(t){switch(t.length){case 2:return e.parseHalf(t);case 4:return t.readFloatBE(0);case 8:return t.readDoubleBE(0);default:throw new Error(`Invalid float size: ${t.length}`)}},e.hex=function(e){return t.from(e.replace(/^0x/,""),"hex")},e.bin=function(e){let r=0,n=(e=e.replace(/\s/g,"")).length%8||8;const i=[];for(;n<=e.length;)i.push(parseInt(e.slice(r,n),2)),r=n,n+=8;return t.from(i)},e.arrayEqual=function(e,t){return null==e&&null==t||null!=e&&null!=t&&(e.length===t.length&&e.every((e,r)=>e===t[r]))},e.bufferToBigInt=function(e){return BigInt(`0x${e.toString("hex")}`)},e.cborValueToString=function(t,r=-1){switch(typeof t){case"symbol":{switch(t){case c.NULL:return"null";case c.UNDEFINED:return"undefined";case c.BREAK:return"BREAK"}if(t.description)return t.description;const e=t.toString().match(/^Symbol\((?<name>.*)\)/);return e&&e.groups.name?e.groups.name:"Symbol"}case"string":return JSON.stringify(t);case"bigint":return t.toString();case"number":{const e=Object.is(t,-0)?"-0":String(t);return r>0?`${e}_${r}`:e}case"object":{if(!t)return"null";const n=e.bufferishToBuffer(t);if(n){const e=n.toString("hex");return r===-1/0?e:`h'${e}'`}return t&&"function"==typeof t[Symbol.for("nodejs.util.inspect.custom")]?t[Symbol.for("nodejs.util.inspect.custom")]():Array.isArray(t)?"[]":"{}"}}return String(t)},e.guessEncoding=function(t,i){if("string"==typeof t)return new r(t,null==i?"hex":i);const o=e.bufferishToBuffer(t);if(o)return new r(o);if((s=t)instanceof n.Readable||["read","on","pipe"].every(e=>"function"==typeof s[e]))return t;var s;throw new Error("Unknown input type")};const h={"=":"","+":"-","/":"_"};e.base64url=function(t){return e.bufferishToBuffer(t).toString("base64").replace(/[=+/]/g,e=>h[e])},e.base64=function(t){return e.bufferishToBuffer(t).toString("base64")},e.isBigEndian=function(){const e=new Uint8Array(4);return!((new Uint32Array(e.buffer)[0]=1)&e[0])}}(k)),k}function ae(){if(V)return C;V=1;const e=oe(),t=se(),r=Symbol("INTERNAL_JSON");function n(e,r){if(t.isBufferish(e))e.toJSON=r;else if(Array.isArray(e))for(const t of e)n(t,r);else if(e&&"object"==typeof e&&(!(e instanceof f)||e.tag<21||e.tag>23))for(const t of Object.values(e))n(t,r)}function i(){return t.base64(this)}function o(){return t.base64url(this)}function s(){return this.toString("hex")}const a={0:e=>new Date(e),1:e=>new Date(1e3*e),2:e=>t.bufferToBigInt(e),3:r=>e.BI.MINUS_ONE-t.bufferToBigInt(r),21:(e,i)=>(t.isBufferish(e)?i[r]=o:n(e,o),i),22:(e,o)=>(t.isBufferish(e)?o[r]=i:n(e,i),o),23:(e,i)=>(t.isBufferish(e)?i[r]=s:n(e,s),i),32:e=>new URL(e),33:(e,t)=>{if(!e.match(/^[a-zA-Z0-9_-]+$/))throw new Error("Invalid base64url characters");const r=e.length%4;if(1===r)throw new Error("Invalid base64url length");if(2===r){if(-1==="AQgw".indexOf(e[e.length-1]))throw new Error("Invalid base64 padding")}else if(3===r&&-1==="AEIMQUYcgkosw048".indexOf(e[e.length-1]))throw new Error("Invalid base64 padding");return t},34:(e,t)=>{const r=e.match(/^[a-zA-Z0-9+/]+(?<padding>={0,2})$/);if(!r)throw new Error("Invalid base64 characters");if(e.length%4!=0)throw new Error("Invalid base64 length");if("="===r.groups.padding){if(-1==="AQgw".indexOf(e[e.length-2]))throw new Error("Invalid base64 padding")}else if("=="===r.groups.padding&&-1==="AEIMQUYcgkosw048".indexOf(e[e.length-3]))throw new Error("Invalid base64 padding");return t},35:e=>new RegExp(e),258:e=>new Set(e)},c={64:Uint8Array,65:Uint16Array,66:Uint32Array,68:Uint8ClampedArray,69:Uint16Array,70:Uint32Array,72:Int8Array,73:Int16Array,74:Int32Array,77:Int16Array,78:Int32Array,81:Float32Array,82:Float64Array,85:Float32Array,86:Float64Array};function u(e,r){if(!t.isBufferish(e))throw new TypeError("val not a buffer");const{tag:n}=r,i=c[n];if(!i)throw new Error(`Invalid typed array tag: ${n}`);const o=2**(((16&n)>>4)+(3&n));!(4&n)!==t.isBigEndian()&&o>1&&function(e,t,r,n){const i=new DataView(e),[o,s]={2:[i.getUint16,i.setUint16],4:[i.getUint32,i.setUint32],8:[i.getBigUint64,i.setBigUint64]}[t],a=r+n;for(let e=r;e<a;e+=t)s.call(i,e,o.call(i,e,!0))}(e.buffer,o,e.byteOffset,e.byteLength);return new i(e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength))}"undefined"!=typeof BigUint64Array&&(c[67]=BigUint64Array,c[71]=BigUint64Array),"undefined"!=typeof BigInt64Array&&(c[75]=BigInt64Array,c[79]=BigInt64Array);for(const e of Object.keys(c))a[e]=u;let h={};class f{constructor(e,t,r){if(this.tag=e,this.value=t,this.err=r,"number"!=typeof this.tag)throw new Error(`Invalid tag type (${typeof this.tag})`);if(this.tag<0||(0|this.tag)!==this.tag)throw new Error(`Tag must be a positive integer: ${this.tag}`)}toJSON(){if(this[r])return this[r].call(this.value);const e={tag:this.tag,value:this.value};return this.err&&(e.err=this.err),e}toString(){return`${this.tag}(${JSON.stringify(this.value)})`}encodeCBOR(e){return e._pushTag(this.tag),e.pushAny(this.value)}convert(e){let t=null==e?void 0:e[this.tag];if(null===t)return this;if("function"!=typeof t&&(t=f.TAGS[this.tag],"function"!=typeof t))return this;try{return t.call(this,this.value,this)}catch(e){return e&&e.message&&e.message.length>0?this.err=e.message:this.err=e,this}}static get TAGS(){return h}static set TAGS(e){h=e}static reset(){f.TAGS={...a}}}return f.INTERNAL_JSON=r,f.reset(),C=f}function ce(){if(H)return F;H=1;const{MT:e,SIMPLE:t,SYMS:r}=oe();class n{constructor(e){if("number"!=typeof e)throw new Error("Invalid Simple type: "+typeof e);if(e<0||e>255||(0|e)!==e)throw new Error(`value must be a small positive integer: ${e}`);this.value=e}toString(){return`simple(${this.value})`}[Symbol.for("nodejs.util.inspect.custom")](e,t){return`simple(${this.value})`}encodeCBOR(t){return t._pushInt(this.value,e.SIMPLE_FLOAT)}static isSimple(e){return e instanceof n}static decode(e,i=!0,o=!1){switch(e){case t.FALSE:return!1;case t.TRUE:return!0;case t.NULL:return i?null:r.NULL;case t.UNDEFINED:if(i)return;return r.UNDEFINED;case-1:if(!i||!o)throw new Error("Invalid BREAK");return r.BREAK;default:return new n(e)}}}return F=n}function ue(){if(j)return G;j=1;const e=function(){if(D)return x;D=1;const e=p,t=M();class r extends e.Transform{constructor(e){super(e),this._writableState.objectMode=!1,this._readableState.objectMode=!0,this.bs=new t,this.__restart()}_transform(e,t,r){for(this.bs.write(e);this.bs.length>=this.__needed;){let e=null;const t=null===this.__needed?void 0:this.bs.read(this.__needed);try{e=this.__parser.next(t)}catch(e){return r(e)}this.__needed&&(this.__fresh=!1),e.done?(this.push(e.value),this.__restart()):this.__needed=e.value||1/0}return r()}*_parse(){throw new Error("Must be implemented in subclass")}__restart(){this.__needed=null,this.__parser=this._parse(),this.__fresh=!0}_flush(e){e(this.__fresh?null:new Error("unexpected end of input"))}}return x=r}(),t=ae(),r=ce(),n=se(),i=M(),o=oe(),{MT:s,NUMBYTES:a,SYMS:c,BI:u}=o,{Buffer:h}=d,f=Symbol("count"),l=Symbol("major type"),y=Symbol("error"),g=Symbol("not found");function E(e,t,r){const n=[];return n[f]=r,n[c.PARENT]=e,n[l]=t,n}function m(e,t){const r=new i;return r[f]=-1,r[c.PARENT]=e,r[l]=t,r}class _ extends Error{constructor(e,t){super(`Unexpected data: 0x${e.toString(16)}`),this.name="UnexpectedDataError",this.byte=e,this.value=t}}function I(e,t){switch(typeof e){case"function":return{options:{},cb:e};case"string":return{options:{encoding:e},cb:t};case"object":return{options:e||{},cb:t};default:throw new TypeError("Unknown option type")}}class w extends e{constructor(e={}){const{tags:t={},max_depth:r=-1,preferMap:n=!1,preferWeb:o=!1,required:s=!1,encoding:a="hex",extendedResults:c=!1,preventDuplicateKeys:u=!1,...h}=e;super({defaultEncoding:a,...h}),this.running=!0,this.max_depth=r,this.tags=t,this.preferMap=n,this.preferWeb=o,this.extendedResults=c,this.required=s,this.preventDuplicateKeys=u,c&&(this.bs.on("read",this._onRead.bind(this)),this.valueBytes=new i)}static nullcheck(e){switch(e){case c.NULL:return null;case c.UNDEFINED:return;case g:throw new Error("Value not found");default:return e}}static decodeFirstSync(e,t={}){if(null==e)throw new TypeError("input required");({options:t}=I(t));const{encoding:r="hex",...i}=t,o=new w(i),s=n.guessEncoding(e,r),a=o._parse();let c=a.next();for(;!c.done;){const e=s.read(c.value);if(null==e||e.length!==c.value)throw new Error("Insufficient data");o.extendedResults&&o.valueBytes.write(e),c=a.next(e)}let u=null;if(o.extendedResults)u=c.value,u.unused=s.read();else if(u=w.nullcheck(c.value),s.length>0){const e=s.read(1);throw s.unshift(e),new _(e[0],u)}return u}static decodeAllSync(e,t={}){if(null==e)throw new TypeError("input required");({options:t}=I(t));const{encoding:r="hex",...i}=t,o=new w(i),s=n.guessEncoding(e,r),a=[];for(;s.length>0;){const e=o._parse();let t=e.next();for(;!t.done;){const r=s.read(t.value);if(null==r||r.length!==t.value)throw new Error("Insufficient data");o.extendedResults&&o.valueBytes.write(r),t=e.next(r)}a.push(w.nullcheck(t.value))}return a}static decodeFirst(e,t={},r=null){if(null==e)throw new TypeError("input required");({options:t,cb:r}=I(t,r));const{encoding:i="hex",required:o=!1,...s}=t,a=new w(s);let c=g;const u=n.guessEncoding(e,i),h=new Promise((e,t)=>{a.on("data",e=>{c=w.nullcheck(e),a.close()}),a.once("error",r=>a.extendedResults&&r instanceof _?(c.unused=a.bs.slice(),e(c)):(c!==g&&(r.value=c),c=y,a.close(),t(r))),a.once("end",()=>{switch(c){case g:return o?t(new Error("No CBOR found")):e(c);case y:return;default:return e(c)}})});return"function"==typeof r&&h.then(e=>r(null,e),r),u.pipe(a),h}static decodeAll(e,t={},r=null){if(null==e)throw new TypeError("input required");({options:t,cb:r}=I(t,r));const{encoding:i="hex",...o}=t,s=new w(o),a=[];s.on("data",e=>a.push(w.nullcheck(e)));const c=new Promise((e,t)=>{s.on("error",t),s.on("end",()=>e(a))});return"function"==typeof r&&c.then(e=>r(void 0,e),e=>r(e,void 0)),n.guessEncoding(e,i).pipe(s),c}close(){this.running=!1,this.__fresh=!0}_onRead(e){this.valueBytes.write(e)}*_parse(){let e=null,o=0,d=null;for(;;){if(this.max_depth>=0&&o>this.max_depth)throw new Error(`Maximum depth ${this.max_depth} exceeded`);const[p]=yield 1;if(!this.running)throw this.bs.unshift(h.from([p])),new _(p);const y=p>>5,g=31&p,I=null==e?void 0:e[l],P=null==e?void 0:e.length;switch(g){case a.ONE:this.emit("more-bytes",y,1,I,P),[d]=yield 1;break;case a.TWO:case a.FOUR:case a.EIGHT:{const e=1<<g-24;this.emit("more-bytes",y,e,I,P);const t=yield e;d=y===s.SIMPLE_FLOAT?t:n.parseCBORint(g,t);break}case 28:case 29:case 30:throw this.running=!1,new Error(`Additional info not implemented: ${g}`);case a.INDEFINITE:switch(y){case s.POS_INT:case s.NEG_INT:case s.TAG:throw new Error(`Invalid indefinite encoding for MT ${y}`)}d=-1;break;default:d=g}switch(y){case s.POS_INT:break;case s.NEG_INT:d=d===Number.MAX_SAFE_INTEGER?u.NEG_MAX:"bigint"==typeof d?u.MINUS_ONE-d:-1-d;break;case s.BYTE_STRING:case s.UTF8_STRING:switch(d){case 0:this.emit("start-string",y,d,I,P),d=y===s.UTF8_STRING?"":this.preferWeb?new Uint8Array(0):h.allocUnsafe(0);break;case-1:this.emit("start",y,c.STREAM,I,P),e=m(e,y),o++;continue;default:this.emit("start-string",y,d,I,P),d=yield d,y===s.UTF8_STRING?d=n.utf8(d):this.preferWeb&&(d=new Uint8Array(d.buffer,d.byteOffset,d.length))}break;case s.ARRAY:case s.MAP:switch(d){case 0:d=y===s.MAP?this.preferMap?new Map:{}:[];break;case-1:this.emit("start",y,c.STREAM,I,P),e=E(e,y,-1),o++;continue;default:this.emit("start",y,d,I,P),e=E(e,y,d*(y-3)),o++;continue}break;case s.TAG:this.emit("start",y,d,I,P),e=E(e,y,1),e.push(d),o++;continue;case s.SIMPLE_FLOAT:if("number"==typeof d){if(g===a.ONE&&d<32)throw new Error(`Invalid two-byte encoding of simple value ${d}`);const t=null!=e;d=r.decode(d,t,t&&e[f]<0)}else d=n.parseCBORfloat(d)}this.emit("value",d,I,P,g);let b=!1;for(;null!=e;){if(d===c.BREAK)e[f]=1;else if(Array.isArray(e))e.push(d);else{const t=e[l];if(null!=t&&t!==y)throw this.running=!1,new Error("Invalid major type in indefinite encoding");e.write(d)}if(0!==--e[f]){b=!0;break}if(--o,delete e[f],Array.isArray(e))switch(e[l]){case s.ARRAY:d=e;break;case s.MAP:{let t=!this.preferMap;if(e.length%2!=0)throw new Error(`Invalid map length: ${e.length}`);for(let r=0,n=e.length;t&&r<n;r+=2)if("string"!=typeof e[r]||"__proto__"===e[r]){t=!1;break}if(t){d={};for(let t=0,r=e.length;t<r;t+=2){if(this.preventDuplicateKeys&&Object.prototype.hasOwnProperty.call(d,e[t]))throw new Error("Duplicate keys in a map");d[e[t]]=e[t+1]}}else{d=new Map;for(let t=0,r=e.length;t<r;t+=2){if(this.preventDuplicateKeys&&d.has(e[t]))throw new Error("Duplicate keys in a map");d.set(e[t],e[t+1])}}break}case s.TAG:d=new t(e[0],e[1]).convert(this.tags);break}else if(e instanceof i)switch(e[l]){case s.BYTE_STRING:d=e.slice(),this.preferWeb&&(d=new Uint8Array(d.buffer,d.byteOffset,d.length));break;case s.UTF8_STRING:d=e.toString("utf-8")}this.emit("stop",e[l]);const r=e;e=e[c.PARENT],delete r[c.PARENT],delete r[l]}if(!b){if(this.extendedResults){const e=this.valueBytes.slice(),t={value:w.nullcheck(d),bytes:e,length:e.length};return this.valueBytes=new i,t}return d}}}}return w.NOT_FOUND=g,G=w}function he(){if($)return K;$=1;const e=p,t=se(),r=ue(),n=M(),{MT:i,NUMBYTES:o,SYMS:s}=oe(),{Buffer:a}=d;function c(e){return e>1?"s":""}class u extends e.Transform{constructor(e={}){const{depth:t=1,max_depth:i=10,no_summary:o=!1,tags:s={},preferWeb:a,encoding:c,...u}=e;super({...u,readableObjectMode:!1,writableObjectMode:!1}),this.depth=t,this.max_depth=i,this.all=new n,s[24]||(s[24]=this._tag_24.bind(this)),this.parser=new r({tags:s,max_depth:i,preferWeb:a,encoding:c}),this.parser.on("value",this._on_value.bind(this)),this.parser.on("start",this._on_start.bind(this)),this.parser.on("start-string",this._on_start_string.bind(this)),this.parser.on("stop",this._on_stop.bind(this)),this.parser.on("more-bytes",this._on_more.bind(this)),this.parser.on("error",this._on_error.bind(this)),o||this.parser.on("data",this._on_data.bind(this)),this.parser.bs.on("read",this._on_read.bind(this))}_tag_24(e){const t=new u({depth:this.depth+1,no_summary:!0});t.on("data",e=>this.push(e)),t.on("error",e=>this.emit("error",e)),t.end(e)}_transform(e,t,r){this.parser.write(e,t,r)}_flush(e){return this.parser._flush(e)}static comment(e,r={},i=null){if(null==e)throw new Error("input required");({options:r,cb:i}=function(e,t){switch(typeof e){case"function":return{options:{},cb:e};case"string":return{options:{encoding:e},cb:t};case"number":return{options:{max_depth:e},cb:t};case"object":return{options:e||{},cb:t};default:throw new TypeError("Unknown option type")}}(r,i));const o=new n,{encoding:s="hex",...a}=r,c=new u(a);let h=null;return"function"==typeof i?(c.on("end",()=>{i(null,o.toString("utf8"))}),c.on("error",i)):h=new Promise((e,t)=>{c.on("end",()=>{e(o.toString("utf8"))}),c.on("error",t)}),c.pipe(o),t.guessEncoding(e,s).pipe(c),h}_on_error(e){this.push("ERROR: "),this.push(e.toString()),this.push("\n")}_on_read(e){this.all.write(e);const t=e.toString("hex");this.push(new Array(this.depth+1).join(" ")),this.push(t);let r=2*(this.max_depth-this.depth)-t.length;r<1&&(r=1),this.push(new Array(r+1).join(" ")),this.push("-- ")}_on_more(e,t,r,n){let o="";switch(this.depth++,e){case i.POS_INT:o="Positive number,";break;case i.NEG_INT:o="Negative number,";break;case i.ARRAY:o="Array, length";break;case i.MAP:o="Map, count";break;case i.BYTE_STRING:o="Bytes, length";break;case i.UTF8_STRING:o="String, length";break;case i.SIMPLE_FLOAT:o=1===t?"Simple value,":"Float,"}this.push(`${o} next ${t} byte${c(t)}\n`)}_on_start_string(e,t,r,n){let o="";switch(this.depth++,e){case i.BYTE_STRING:o=`Bytes, length: ${t}`;break;case i.UTF8_STRING:o=`String, length: ${t.toString()}`}this.push(`${o}\n`)}_on_start(e,t,r,n){switch(this.depth++,r){case i.ARRAY:this.push(`[${n}], `);break;case i.MAP:n%2?this.push(`{Val:${Math.floor(n/2)}}, `):this.push(`{Key:${Math.floor(n/2)}}, `)}switch(e){case i.TAG:this.push(`Tag #${t}`),24===t&&this.push(" Encoded CBOR data item");break;case i.ARRAY:t===s.STREAM?this.push("Array (streaming)"):this.push(`Array, ${t} item${c(t)}`);break;case i.MAP:t===s.STREAM?this.push("Map (streaming)"):this.push(`Map, ${t} pair${c(t)}`);break;case i.BYTE_STRING:this.push("Bytes (streaming)");break;case i.UTF8_STRING:this.push("String (streaming)")}this.push("\n")}_on_stop(e){this.depth--}_on_value(e,r,n,c){if(e!==s.BREAK)switch(r){case i.ARRAY:this.push(`[${n}], `);break;case i.MAP:n%2?this.push(`{Val:${Math.floor(n/2)}}, `):this.push(`{Key:${Math.floor(n/2)}}, `)}const u=t.cborValueToString(e,-1/0);switch("string"==typeof e||a.isBuffer(e)?(e.length>0&&(this.push(u),this.push("\n")),this.depth--):(this.push(u),this.push("\n")),c){case o.ONE:case o.TWO:case o.FOUR:case o.EIGHT:this.depth--}}_on_data(){this.push("0x"),this.push(this.all.read().toString("hex")),this.push("\n")}}return K=u}function fe(){if(z)return Y;z=1;const e=p,t=ue(),r=se(),n=M(),{MT:i,SYMS:o}=oe();class s extends e.Transform{constructor(e={}){const{separator:r="\n",stream_errors:n=!1,tags:i,max_depth:o,preferWeb:s,encoding:a,...c}=e;super({...c,readableObjectMode:!1,writableObjectMode:!1}),this.float_bytes=-1,this.separator=r,this.stream_errors=n,this.parser=new t({tags:i,max_depth:o,preferWeb:s,encoding:a}),this.parser.on("more-bytes",this._on_more.bind(this)),this.parser.on("value",this._on_value.bind(this)),this.parser.on("start",this._on_start.bind(this)),this.parser.on("stop",this._on_stop.bind(this)),this.parser.on("data",this._on_data.bind(this)),this.parser.on("error",this._on_error.bind(this))}_transform(e,t,r){this.parser.write(e,t,r)}_flush(e){this.parser._flush(t=>this.stream_errors?(t&&this._on_error(t),e()):e(t))}static diagnose(e,t={},i=null){if(null==e)throw new TypeError("input required");({options:t,cb:i}=function(e,t){switch(typeof e){case"function":return{options:{},cb:e};case"string":return{options:{encoding:e},cb:t};case"object":return{options:e||{},cb:t};default:throw new TypeError("Unknown option type")}}(t,i));const{encoding:o="hex",...a}=t,c=new n,u=new s(a);let h=null;return"function"==typeof i?(u.on("end",()=>i(null,c.toString("utf8"))),u.on("error",i)):h=new Promise((e,t)=>{u.on("end",()=>e(c.toString("utf8"))),u.on("error",t)}),u.pipe(c),r.guessEncoding(e,o).pipe(u),h}_on_error(e){this.stream_errors?this.push(e.toString()):this.emit("error",e)}_on_more(e,t,r,n){e===i.SIMPLE_FLOAT&&(this.float_bytes={2:1,4:2,8:3}[t])}_fore(e,t){switch(e){case i.BYTE_STRING:case i.UTF8_STRING:case i.ARRAY:t>0&&this.push(", ");break;case i.MAP:t>0&&(t%2?this.push(": "):this.push(", "))}}_on_value(e,t,n){if(e===o.BREAK)return;this._fore(t,n);const i=this.float_bytes;this.float_bytes=-1,this.push(r.cborValueToString(e,i))}_on_start(e,t,r,n){switch(this._fore(r,n),e){case i.TAG:this.push(`${t}(`);break;case i.ARRAY:this.push("[");break;case i.MAP:this.push("{");break;case i.BYTE_STRING:case i.UTF8_STRING:this.push("(")}t===o.STREAM&&this.push("_ ")}_on_stop(e){switch(e){case i.TAG:this.push(")");break;case i.ARRAY:this.push("]");break;case i.MAP:this.push("}");break;case i.BYTE_STRING:case i.UTF8_STRING:this.push(")")}}_on_data(){this.push(this.separator)}}return Y=s}function le(){if(J)return W;J=1;const e=p,t=M(),r=se(),n=oe(),{MT:i,NUMBYTES:o,SHIFT32:s,SIMPLE:a,SYMS:c,TAG:u,BI:h}=n,{Buffer:f}=d,l=i.SIMPLE_FLOAT<<5|o.TWO,y=i.SIMPLE_FLOAT<<5|o.FOUR,g=i.SIMPLE_FLOAT<<5|o.EIGHT,E=i.SIMPLE_FLOAT<<5|a.TRUE,m=i.SIMPLE_FLOAT<<5|a.FALSE,_=i.SIMPLE_FLOAT<<5|a.UNDEFINED,I=i.SIMPLE_FLOAT<<5|a.NULL,w=f.from([255]),P=f.from("f97e00","hex"),b=f.from("f9fc00","hex"),A=f.from("f97c00","hex"),O=f.from("f98000","hex"),T={};let R={};class S extends e.Transform{constructor(e={}){const{canonical:t=!1,encodeUndefined:r,disallowUndefinedKeys:n=!1,dateType:i="number",collapseBigIntegers:o=!1,detectLoops:s=!1,omitUndefinedProperties:a=!1,genTypes:c=[],...u}=e;if(super({...u,readableObjectMode:!1,writableObjectMode:!0}),this.canonical=t,this.encodeUndefined=r,this.disallowUndefinedKeys=n,this.dateType=function(e){if(!e)return"number";switch(e.toLowerCase()){case"number":return"number";case"float":return"float";case"int":case"integer":return"int";case"string":return"string"}throw new TypeError(`dateType invalid, got "${e}"`)}(i),this.collapseBigIntegers=!!this.canonical||o,this.detectLoops=void 0,"boolean"==typeof s)s&&(this.detectLoops=new WeakSet);else{if(!(s instanceof WeakSet))throw new TypeError("detectLoops must be boolean or WeakSet");this.detectLoops=s}if(this.omitUndefinedProperties=a,this.semanticTypes={...S.SEMANTIC_TYPES},Array.isArray(c))for(let e=0,t=c.length;e<t;e+=2)this.addSemanticType(c[e],c[e+1]);else for(const[e,t]of Object.entries(c))this.addSemanticType(e,t)}_transform(e,t,r){r(!1===this.pushAny(e)?new Error("Push Error"):void 0)}_flush(e){e()}_pushUInt8(e){const t=f.allocUnsafe(1);return t.writeUInt8(e,0),this.push(t)}_pushUInt16BE(e){const t=f.allocUnsafe(2);return t.writeUInt16BE(e,0),this.push(t)}_pushUInt32BE(e){const t=f.allocUnsafe(4);return t.writeUInt32BE(e,0),this.push(t)}_pushFloatBE(e){const t=f.allocUnsafe(4);return t.writeFloatBE(e,0),this.push(t)}_pushDoubleBE(e){const t=f.allocUnsafe(8);return t.writeDoubleBE(e,0),this.push(t)}_pushNaN(){return this.push(P)}_pushInfinity(e){const t=e<0?b:A;return this.push(t)}_pushFloat(e){if(this.canonical){const t=f.allocUnsafe(2);if(r.writeHalf(t,e))return this._pushUInt8(l)&&this.push(t)}return Math.fround(e)===e?this._pushUInt8(y)&&this._pushFloatBE(e):this._pushUInt8(g)&&this._pushDoubleBE(e)}_pushInt(e,t,r){const n=t<<5;if(e<24)return this._pushUInt8(n|e);if(e<=255)return this._pushUInt8(n|o.ONE)&&this._pushUInt8(e);if(e<=65535)return this._pushUInt8(n|o.TWO)&&this._pushUInt16BE(e);if(e<=4294967295)return this._pushUInt8(n|o.FOUR)&&this._pushUInt32BE(e);let a=Number.MAX_SAFE_INTEGER;return t===i.NEG_INT&&a--,e<=a?this._pushUInt8(n|o.EIGHT)&&this._pushUInt32BE(Math.floor(e/s))&&this._pushUInt32BE(e%s):t===i.NEG_INT?this._pushFloat(r):this._pushFloat(e)}_pushIntNum(e){return Object.is(e,-0)?this.push(O):e<0?this._pushInt(-e-1,i.NEG_INT,e):this._pushInt(e,i.POS_INT)}_pushNumber(e){return isNaN(e)?this._pushNaN():isFinite(e)?Math.round(e)===e?this._pushIntNum(e):this._pushFloat(e):this._pushInfinity(e)}_pushString(e){const t=f.byteLength(e,"utf8");return this._pushInt(t,i.UTF8_STRING)&&this.push(e,"utf8")}_pushBoolean(e){return this._pushUInt8(e?E:m)}_pushUndefined(e){switch(typeof this.encodeUndefined){case"undefined":return this._pushUInt8(_);case"function":return this.pushAny(this.encodeUndefined(e));case"object":{const e=r.bufferishToBuffer(this.encodeUndefined);if(e)return this.push(e)}}return this.pushAny(this.encodeUndefined)}_pushNull(e){return this._pushUInt8(I)}_pushTag(e){return this._pushInt(e,i.TAG)}_pushJSBigint(e){let t=i.POS_INT,r=u.POS_BIGINT;if(e<0&&(e=-e+h.MINUS_ONE,t=i.NEG_INT,r=u.NEG_BIGINT),this.collapseBigIntegers&&e<=h.MAXINT64)return e<=4294967295?this._pushInt(Number(e),t):this._pushUInt8(t<<5|o.EIGHT)&&this._pushUInt32BE(Number(e/h.SHIFT32))&&this._pushUInt32BE(Number(e%h.SHIFT32));let n=e.toString(16);n.length%2&&(n=`0${n}`);const s=f.from(n,"hex");return this._pushTag(r)&&S._pushBuffer(this,s)}_pushObject(e,t){if(!e)return this._pushNull(e);if(!(t={indefinite:!1,skipTypes:!1,...t}).indefinite&&this.detectLoops){if(this.detectLoops.has(e))throw new Error("Loop detected while CBOR encoding.\nCall removeLoopDetectors before resuming.");this.detectLoops.add(e)}if(!t.skipTypes){const t=e.encodeCBOR;if("function"==typeof t)return t.call(e,this);const r=this.semanticTypes[e.constructor.name];if(r)return r.call(e,this,e)}const r=Object.keys(e).filter(t=>{const r=typeof e[t];return"function"!==r&&(!this.omitUndefinedProperties||"undefined"!==r)}),n={};if(this.canonical&&r.sort((e,t)=>{const r=n[e]||(n[e]=S.encode(e)),i=n[t]||(n[t]=S.encode(t));return r.compare(i)}),t.indefinite){if(!this._pushUInt8(i.MAP<<5|o.INDEFINITE))return!1}else if(!this._pushInt(r.length,i.MAP))return!1;let s=null;for(let t=0,i=r.length;t<i;t++){const i=r[t];if(this.canonical&&(s=n[i])){if(!this.push(s))return!1}else if(!this._pushString(i))return!1;if(!this.pushAny(e[i]))return!1}if(t.indefinite){if(!this.push(w))return!1}else this.detectLoops&&this.detectLoops.delete(e);return!0}_encodeAll(e){const r=new t({highWaterMark:this.readableHighWaterMark});this.pipe(r);for(const t of e)this.pushAny(t);return this.end(),r.read()}addSemanticType(e,t){const r="string"==typeof e?e:e.name,n=this.semanticTypes[r];if(t){if("function"!=typeof t)throw new TypeError("fun must be of type function");this.semanticTypes[r]=t}else n&&delete this.semanticTypes[r];return n}pushAny(e){switch(typeof e){case"number":return this._pushNumber(e);case"bigint":return this._pushJSBigint(e);case"string":return this._pushString(e);case"boolean":return this._pushBoolean(e);case"undefined":return this._pushUndefined(e);case"object":return this._pushObject(e);case"symbol":switch(e){case c.NULL:return this._pushNull(null);case c.UNDEFINED:return this._pushUndefined(void 0);default:throw new TypeError(`Unknown symbol: ${e.toString()}`)}default:throw new TypeError(`Unknown type: ${typeof e}, ${"function"==typeof e.toString?e.toString():""}`)}}static pushArray(e,t,r){r={indefinite:!1,...r};const n=t.length;if(r.indefinite){if(!e._pushUInt8(i.ARRAY<<5|o.INDEFINITE))return!1}else if(!e._pushInt(n,i.ARRAY))return!1;for(let r=0;r<n;r++)if(!e.pushAny(t[r]))return!1;return!(r.indefinite&&!e.push(w))}removeLoopDetectors(){return!!this.detectLoops&&(this.detectLoops=new WeakSet,!0)}static _pushDate(e,t){switch(e.dateType){case"string":return e._pushTag(u.DATE_STRING)&&e._pushString(t.toISOString());case"int":return e._pushTag(u.DATE_EPOCH)&&e._pushIntNum(Math.round(t.getTime()/1e3));case"float":return e._pushTag(u.DATE_EPOCH)&&e._pushFloat(t.getTime()/1e3);default:return e._pushTag(u.DATE_EPOCH)&&e.pushAny(t.getTime()/1e3)}}static _pushBuffer(e,t){return e._pushInt(t.length,i.BYTE_STRING)&&e.push(t)}static _pushNoFilter(e,t){return S._pushBuffer(e,t.slice())}static _pushRegexp(e,t){return e._pushTag(u.REGEXP)&&e.pushAny(t.source)}static _pushSet(e,t){if(!e._pushTag(u.SET))return!1;if(!e._pushInt(t.size,i.ARRAY))return!1;for(const r of t)if(!e.pushAny(r))return!1;return!0}static _pushURL(e,t){return e._pushTag(u.URI)&&e.pushAny(t.toString())}static _pushBoxed(e,t){return e.pushAny(t.valueOf())}static _pushMap(e,r,n){n={indefinite:!1,...n};let s=[...r.entries()];if(e.omitUndefinedProperties&&(s=s.filter(([e,t])=>void 0!==t)),n.indefinite){if(!e._pushUInt8(i.MAP<<5|o.INDEFINITE))return!1}else if(!e._pushInt(s.length,i.MAP))return!1;if(e.canonical){const r=new S({genTypes:e.semanticTypes,canonical:e.canonical,detectLoops:Boolean(e.detectLoops),dateType:e.dateType,disallowUndefinedKeys:e.disallowUndefinedKeys,collapseBigIntegers:e.collapseBigIntegers}),n=new t({highWaterMark:e.readableHighWaterMark});r.pipe(n),s.sort(([e],[t])=>{r.pushAny(e);const i=n.read();r.pushAny(t);const o=n.read();return i.compare(o)});for(const[t,r]of s){if(e.disallowUndefinedKeys&&void 0===t)throw new Error("Invalid Map key: undefined");if(!e.pushAny(t)||!e.pushAny(r))return!1}}else for(const[t,r]of s){if(e.disallowUndefinedKeys&&void 0===t)throw new Error("Invalid Map key: undefined");if(!e.pushAny(t)||!e.pushAny(r))return!1}return!(n.indefinite&&!e.push(w))}static _pushTypedArray(e,t){let n=64,i=t.BYTES_PER_ELEMENT;const{name:o}=t.constructor;return o.startsWith("Float")?(n|=16,i/=2):o.includes("U")||(n|=8),(o.includes("Clamped")||1!==i&&!r.isBigEndian())&&(n|=4),n|={1:0,2:1,4:2,8:3}[i],!!e._pushTag(n)&&S._pushBuffer(e,f.from(t.buffer,t.byteOffset,t.byteLength))}static _pushArrayBuffer(e,t){return S._pushBuffer(e,f.from(t))}static encodeIndefinite(e,t,n={}){if(null==t){if(null==this)throw new Error("No object to encode");t=this}const{chunkSize:s=4096}=n;let a=!0;const c=typeof t;let u=null;if("string"===c){a=a&&e._pushUInt8(i.UTF8_STRING<<5|o.INDEFINITE);let r=0;for(;r<t.length;){const n=r+s;a=a&&e._pushString(t.slice(r,n)),r=n}a=a&&e.push(w)}else if(u=r.bufferishToBuffer(t)){a=a&&e._pushUInt8(i.BYTE_STRING<<5|o.INDEFINITE);let t=0;for(;t<u.length;){const r=t+s;a=a&&S._pushBuffer(e,u.slice(t,r)),t=r}a=a&&e.push(w)}else if(Array.isArray(t))a=a&&S.pushArray(e,t,{indefinite:!0});else if(t instanceof Map)a=a&&S._pushMap(e,t,{indefinite:!0});else{if("object"!==c)throw new Error("Invalid indefinite encoding");a=a&&e._pushObject(t,{indefinite:!0,skipTypes:!0})}return a}static encode(...e){return(new S)._encodeAll(e)}static encodeCanonical(...e){return new S({canonical:!0})._encodeAll(e)}static encodeOne(e,t){return new S(t)._encodeAll([e])}static encodeAsync(e,t){return new Promise((r,n)=>{const i=[],o=new S(t);o.on("data",e=>i.push(e)),o.on("error",n),o.on("finish",()=>r(f.concat(i))),o.pushAny(e),o.end()})}static get SEMANTIC_TYPES(){return R}static set SEMANTIC_TYPES(e){R=e}static reset(){S.SEMANTIC_TYPES={...T}}}return Object.assign(T,{Array:S.pushArray,Date:S._pushDate,Buffer:S._pushBuffer,[f.name]:S._pushBuffer,Map:S._pushMap,NoFilter:S._pushNoFilter,[t.name]:S._pushNoFilter,RegExp:S._pushRegexp,Set:S._pushSet,ArrayBuffer:S._pushArrayBuffer,Uint8ClampedArray:S._pushTypedArray,Uint8Array:S._pushTypedArray,Uint16Array:S._pushTypedArray,Uint32Array:S._pushTypedArray,Int8Array:S._pushTypedArray,Int16Array:S._pushTypedArray,Int32Array:S._pushTypedArray,Float32Array:S._pushTypedArray,Float64Array:S._pushTypedArray,URL:S._pushURL,Boolean:S._pushBoxed,Number:S._pushBoxed,String:S._pushBoxed}),"undefined"!=typeof BigUint64Array&&(T[BigUint64Array.name]=S._pushTypedArray),"undefined"!=typeof BigInt64Array&&(T[BigInt64Array.name]=S._pushTypedArray),S.reset(),W=S}function de(){if(X)return q;X=1;const{Buffer:e}=d,t=le(),r=ue(),{MT:n}=oe();class i extends Map{constructor(e){super(e)}static _encode(e){return t.encodeCanonical(e).toString("base64")}static _decode(e){return r.decodeFirstSync(e,"base64")}get(e){return super.get(i._encode(e))}set(e,t){return super.set(i._encode(e),t)}delete(e){return super.delete(i._encode(e))}has(e){return super.has(i._encode(e))}*keys(){for(const e of super.keys())yield i._decode(e)}*entries(){for(const e of super.entries())yield[i._decode(e[0]),e[1]]}[Symbol.iterator](){return this.entries()}forEach(e,t=this){if("function"!=typeof e)throw new TypeError("Must be function");for(const r of super.entries())e.call(t,r[1],i._decode(r[0]),this)}encodeCBOR(t){if(!t._pushInt(this.size,n.MAP))return!1;if(t.canonical){const r=Array.from(super.entries()).map(t=>[e.from(t[0],"base64"),t[1]]);r.sort((e,t)=>e[0].compare(t[0]));for(const e of r)if(!t.push(e[0])||!t.pushAny(e[1]))return!1}else for(const r of super.entries())if(!t.push(e.from(r[0],"base64"))||!t.pushAny(r[1]))return!1;return!0}}return q=i}function pe(){if(te)return ee;te=1;const e=le(),t=function(){if(Z)return Q;Z=1;class e{constructor(){this.clear()}clear(){this.map=new WeakMap,this.count=0,this.recording=!0}stop(){this.recording=!1}check(t){const r=this.map.get(t);if(r)return r.length>1?r[0]||this.recording?r[1]:(r[0]=!0,e.FIRST):this.recording?(r.push(this.count++),r[1]):e.NEVER;if(!this.recording)throw new Error("New object detected when not recording");return this.map.set(t,[!1]),e.NEVER}}return e.NEVER=-1,e.FIRST=-2,Q=e}(),{Buffer:r}=d;class n extends e{constructor(e){super(e),this.valueSharing=new t}_pushObject(e,r){if(null!==e){const r=this.valueSharing.check(e);switch(r){case t.FIRST:this._pushTag(28);break;case t.NEVER:break;default:return this._pushTag(29)&&this._pushIntNum(r)}}return super._pushObject(e,r)}stopRecording(){this.valueSharing.stop()}clearRecording(){this.valueSharing.clear()}static encode(...e){const t=new n;t.on("data",()=>{});for(const r of e)t.pushAny(r);return t.stopRecording(),t.removeAllListeners("data"),t._encodeAll(e)}static encodeCanonical(...e){throw new Error("Cannot encode canonically in a SharedValueEncoder, which serializes objects multiple times.")}static encodeOne(e,t){const r=new n(t);return r.on("data",()=>{}),r.pushAny(e),r.stopRecording(),r.removeAllListeners("data"),r._encodeAll([e])}static encodeAsync(e,t){return new Promise((i,o)=>{const s=[],a=new n(t);a.on("data",()=>{}),a.on("error",o),a.on("finish",()=>i(r.concat(s))),a.pushAny(e),a.stopRecording(),a.removeAllListeners("data"),a.on("data",e=>s.push(e)),a.pushAny(e),a.end()})}}return ee=n}var ye,ge=function(){if(ne)return re;ne=1;const e=he(),t=fe(),r=ue(),n=le(),i=ce(),o=ae(),s=de(),a=pe();return re={Commented:e,Diagnose:t,Decoder:r,Encoder:n,Simple:i,Tagged:o,Map:s,SharedValueEncoder:a,comment:e.comment,decodeAll:r.decodeAll,decodeFirst:r.decodeFirst,decodeAllSync:r.decodeAllSync,decodeFirstSync:r.decodeFirstSync,diagnose:t.diagnose,encode:n.encode,encodeCanonical:n.encodeCanonical,encodeOne:n.encodeOne,encodeAsync:n.encodeAsync,decode:r.decodeFirstSync,leveldb:{decode:r.decodeFirstSync,encode:n.encode,buffer:!0,name:"cbor"},reset(){n.reset(),o.reset()}}}(),Ee=h(ge);function me(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[t,e]))}class _e{constructor(e){if(!function(e){if("string"!=typeof e)return!1;if(e.length<=1)return!1;if("z"!==e[0])return!1;const t=e.slice(1);return/^[1-9A-HJ-NP-Za-km-z]+$/.test(t)}(e))throw new Error("Base58 string is invalid. Cannot construct Decoder.");this.base58=e}constructRootJSON(e){const t=me(U.root);return e.reduce((e,r)=>{const n=t[r[0]];let i=r[1];return i instanceof Array&&("anchors"===n&&(i=this.constructAnchorsJSON(i)),"path"===n&&(i=this.constructPathJSON(i))),(i instanceof a||i instanceof Uint8Array)&&(i=Ee.decode(i).toString("hex")),e[n]=i,e},{})}constructAnchorsJSON(e){const t=(r=U.chain,n=e=>e.id,Object.entries(r).reduce((e,[t,r])=>{const i=n(r);return(e[i]||=[]).push(t),e},{}));var r,n;return e.map(e=>e.reduce((e,r)=>{if(0===r[0])return`${e}:${t[r[1]]}`;if(1===r[0]){const t=e.split(":").pop();return`${e}:${me(U.chain[t].networks)[r[1]]}`}return`${e}:${Ee.decode(r[1]).toString("hex")}`},"blink"))}constructPathJSON(e){const t=me(U.path);return e.map(e=>({[t[e[0]]]:Ee.decode(e[1]).toString("hex")}))}decode(){const e=c(this.base58.slice(1)),t=Ee.decode(a.from(e));return this.constructRootJSON(t)}}function Ie(e){return Object.keys(s).map(e=>s[e]).find(t=>t.signatureValue===e)}function we(e=null){if(e?.anchors){const{anchors:t}=e,r=t[0];if("string"==typeof r)return function(e){const t=e.split(":");let r;switch(t[1]){case s.mocknet.blinkCode:return Ie(s.mocknet.signatureValue);case s.bitcoin.blinkCode:r=s.bitcoin.name;break;case s.ethmain.blinkCode:r=s.ethmain.name;break;default:throw new Error("Could not retrieve chain.")}const n=t[2],i=r.toLowerCase()+function(e){const t=e.substr(0,1),r=e.substr(1,e.length-1);return t.toUpperCase()+r.toLowerCase()}(n);return Ie(i)}(r)}return null}function Pe(e,t){const r=e.findIndex(e=>e===t);r>-1&&e.splice(r,1)}class be extends Error{stepCode;problemDetails;constructor(e,t,r){super(t),this.stepCode=e,r&&(this.problemDetails={type:r,detail:t})}}!function(e){e.PARSING_ERROR="https://www.w3.org/TR/vc-data-model#PARSING_ERROR",e.CRYPTOGRAPHIC_SECURITY_ERROR="https://www.w3.org/TR/vc-data-model#CRYPTOGRAPHIC_SECURITY_ERROR",e.MALFORMED_VALUE_ERROR="https://www.w3.org/TR/vc-data-model#MALFORMED_VALUE_ERROR",e.RANGE_ERROR="https://www.w3.org/TR/vc-data-model#RANGE_ERROR",e.PROOF_VERIFICATION_ERROR="https://w3id.org/security#PROOF_VERIFICATION_ERROR",e.PROOF_TRANSFORMATION_ERROR="https://w3id.org/security#PROOF_TRANSFORMATION_ERROR"}(ye||(ye={}));var Ae="en-US",Oe={"en-US":{errors:{assertProofValidityPurposeVerifier:"Invalid proof purpose. Expected ${expectedProofPurpose} but received ${proof.proofPurpose}",assertProofValidityPurposeIssuerKey:"The verification method ${proof.verificationMethod} is not allowed for the proof purpose ${expectedProofPurpose}",assertProofValidityDomainVerifier:"The proof is not authorized for this domain",assertProofValidityInvalidChallenge:"The proof's challenge does not match the verifier's challenge",assertProofValidityNoProofPurpose:"`proofPurpose` property is missing from proof",assertProofValidityNoCreated:"`created` property is missing from proof",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:{assertProofValidityPurposeVerifier:"Objectif de la signature invalide. Attendu: ${expectedProofPurpose} mais la signature a un objectif de ${proof.proofPurpose}",assertProofValidityPurposeIssuerKey:"La méthode de vérification ${proof.verificationMethod} n'est pas autorisée pour l'objectif de verification: ${expectedProofPurpose}",assertProofValidityDomainVerifier:"La signature n'est pas autorisée pour ce domaine",assertProofValidityInvalidChallenge:"Le challenge de la signature ne correspond pas au challenge de vérification",assertProofValidityNoProofPurpose:"La propriété `proofPurpose` est manquante dans la signature",assertProofValidityNoCreated:"La propriété `created` est manquante dans la signature",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:{assertProofValidityPurposeVerifier:"Objectivo de verificación invalido. Se esperaba ${expectedProofPurpose} pero recibió ${proof.proofPurpose}",assertProofValidityPurposeIssuerKey:"El método de verificación ${proof.verificationMethod} no está permitido para el objectivo de verificación ${expectedProofPurpose}",assertProofValidityDomainVerifier:"La prueba no está autorizada para este dominio",assertProofValidityInvalidChallenge:"El reto de la prueba no coincide con el reto de verificación",assertProofValidityNoProofPurpose:"Falta propiedad `proofPurpose` en la prueba",assertProofValidityNoCreated:"Falta propiedad `created` en la prueba",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:{assertProofValidityPurposeVerifier:"Invalid proof purpose. Expected ${expectedProofPurpose} but received ${proof.proofPurpose}",assertProofValidityPurposeIssuerKey:"The verification method ${proof.verificationMethod} is not allowed for the proof purpose ${expectedProofPurpose}",assertProofValidityDomainVerifier:"The proof is not authorized for this domain",assertProofValidityInvalidChallenge:"The proof's challenge does not match the verifier's challenge",assertProofValidityNoProofPurpose:"`proofPurpose` property is missing from proof",assertProofValidityNoCreated:"`created` property is missing from proof",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:{assertProofValidityPurposeVerifier:"Invalid proof purpose. Expected ${expectedProofPurpose} but received ${proof.proofPurpose}",assertProofValidityPurposeIssuerKey:"The verification method ${proof.verificationMethod} is not allowed for the proof purpose ${expectedProofPurpose}",assertProofValidityDomainVerifier:"The proof is not authorized for this domain",assertProofValidityInvalidChallenge:"The proof's challenge does not match the verifier's challenge",assertProofValidityNoProofPurpose:"`proofPurpose` property is missing from proof",assertProofValidityNoCreated:"`created` property is missing from proof",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:{assertProofValidityPurposeVerifier:"Invalid proof purpose. Expected ${expectedProofPurpose} but received ${proof.proofPurpose}",assertProofValidityPurposeIssuerKey:"The verification method ${proof.verificationMethod} is not allowed for the proof purpose ${expectedProofPurpose}",assertProofValidityDomainVerifier:"The proof is not authorized for this domain",assertProofValidityInvalidChallenge:"The proof's challenge does not match the verifier's challenge",assertProofValidityNoProofPurpose:"`proofPurpose` property is missing from proof",assertProofValidityNoCreated:"`created` property is missing from proof",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 Te(e,t){return t?Oe[Ae]?Oe[Ae][e]?Oe[Ae][e][t]?Oe[Ae][e][t]||"":"[missing locale item data]":"[missing locale group data]":"[missing locale data]":""}function Re({expectedProofPurpose:e,expectedDomain:t,expectedChallenge:r,proof:n,issuer:i}){if(!n.proofPurpose)throw new be("assertProofValidity",Te("errors","assertProofValidityNoProofPurpose"),ye.MALFORMED_VALUE_ERROR);if(!n.created)throw new be("assertProofValidity",Te("errors","assertProofValidityNoCreated"),ye.MALFORMED_VALUE_ERROR);return n.proofPurpose&&function({expectedProofPurpose:e,proof:t,issuer:r}){if(t.proofPurpose!==e)throw new be("assertProofValidity",Te("errors","assertProofValidityPurposeVerifier").replace("${expectedProofPurpose}",e).replace("${proof.proofPurpose}",t.proofPurpose),ye.MALFORMED_VALUE_ERROR);if(r&&!r[e]?.includes(t.verificationMethod))throw new be("assertProofValidity",Te("errors","assertProofValidityPurposeIssuerKey").replace("${proof.verificationMethod}",t.verificationMethod).replace("${expectedProofPurpose}",e),ye.CRYPTOGRAPHIC_SECURITY_ERROR);"authentication"!==e||t.domain||console.warn("No domain found in proof, but it is recommended for authentication purposes")}({expectedProofPurpose:e,proof:n,issuer:i}),n.domain&&function({expectedDomain:e,proof:t,expectedChallenge:r}){if(!e.includes(t.domain))throw new be("assertProofValidity",Te("errors","assertProofValidityDomainVerifier").replace("${expectedDomain}",e.join(", ")).replace("${proof.domain}",t.domain),ye.MALFORMED_VALUE_ERROR);if(t.domain&&!t.challenge&&console.warn("No challenge found in proof, but it is recommended for domain verification"),t.challenge&&t.challenge!==r)throw new be("assertProofValidity",Te("errors","assertProofValidityInvalidChallenge"),ye.MALFORMED_VALUE_ERROR)}({expectedDomain:t,proof:n,expectedChallenge:r}),!0}var Se={"@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"}]},ve={"@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"}}},Ne={"@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"}}},Ue={"@context":{id:"@id",type:"@type","@protected":!0,proof:{"@id":"https://w3id.org/security#proof","@type":"@id","@container":"@graph"},Ed25519VerificationKey2020:{"@id":"https://w3id.org/security#Ed25519VerificationKey2020","@context":{"@protected":!0,id:"@id",type:"@type",controller:{"@id":"https://w3id.org/security#controller","@type":"@id"},revoked:{"@id":"https://w3id.org/security#revoked","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},publicKeyMultibase:{"@id":"https://w3id.org/security#publicKeyMultibase","@type":"https://w3id.org/security#multibase"}}},Ed25519Signature2020:{"@id":"https://w3id.org/security#Ed25519Signature2020","@context":{"@protected":!0,id:"@id",type:"@type",challenge:"https://w3id.org/security#challenge",created:{"@id":"http://purl.org/dc/terms/created","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},domain:"https://w3id.org/security#domain",expires:{"@id":"https://w3id.org/security#expiration","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},nonce:"https://w3id.org/security#nonce",proofPurpose:{"@id":"https://w3id.org/security#proofPurpose","@type":"@vocab","@context":{"@protected":!0,id:"@id",type:"@type",assertionMethod:{"@id":"https://w3id.org/security#assertionMethod","@type":"@id","@container":"@set"},authentication:{"@id":"https://w3id.org/security#authenticationMethod","@type":"@id","@container":"@set"},capabilityInvocation:{"@id":"https://w3id.org/security#capabilityInvocationMethod","@type":"@id","@container":"@set"},capabilityDelegation:{"@id":"https://w3id.org/security#capabilityDelegationMethod","@type":"@id","@container":"@set"},keyAgreement:{"@id":"https://w3id.org/security#keyAgreementMethod","@type":"@id","@container":"@set"}}},proofValue:{"@id":"https://w3id.org/security#proofValue","@type":"https://w3id.org/security#multibase"},verificationMethod:{"@id":"https://w3id.org/security#verificationMethod","@type":"@id"}}}}};function ke(e){e=e.trim();const t=[];for(let r=0;r<e.length;r+=2)t.push(parseInt(e.substring(r,r+2),16));return t}async function Me(e,t=null,r=async e=>Promise){e["@context"].find(e=>{return(t=e)===Object(t)&&"@vocab"in e;var t})||e["@context"].push({"@vocab":"http://fallback.org/"});const n=JSON.parse(JSON.stringify(e));if(Array.isArray(n.proof)){if(!t)throw new be("computeLocalHash",Te("errors","noProofSpecified"),ye.MALFORMED_VALUE_ERROR);const e=n.proof.findIndex(e=>e.proofValue===t.proofValue);n.proof=n.proof.slice(0,e)}else delete n.proof;const i={algorithm:"URDNA2015",format:"application/nquads",documentLoader:async function(e){return null!=r&&await r(e),e in f?{contextUrl:null,document:f[e],documentUrl:e}:_.documentLoader(e)},safe:!1};let o;try{o=await _.normalize(n,i)}catch(e){throw console.error(e),new be("computeLocalHash",Te("errors","failedJsonLdNormalization"),ye.PROOF_TRANSFORMATION_ERROR)}const s=function(e){const t=e.split("\n"),r=/<http:\/\/fallback\.org\/(.*)>/,n=t.map(e=>r.exec(e)).filter(e=>null!=e);if(n.length>0){const e=n.map(e=>e[1]).sort();return Array.from(new Set(e))}return null}(o);if(s)throw new be("computeLocalHash",`${Te("errors","foundUnmappedFields")}: ${s.join(", ")}`,ye.MALFORMED_VALUE_ERROR);return a.from(w(Uint8Array.from(function(e){const t=[];for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);n<128?t.push(n):n<2048?t.push(192|n>>6,128|63&n):n<55296||n>=57344?t.push(224|n>>12,128|n>>6&63,128|63&n):(r++,n=65536+((1023&n)<<10|1023&e.charCodeAt(r)),t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n))}return t}(o)))).toString("hex")}f["https://w3id.org/blockcerts/schema/2.0-alpha/context.json"]=Se,f["https://www.blockcerts.org/schema/2.0-alpha/context.json"]=Se,f["https://www.blockcerts.org/schema/3.0-alpha/context.json"]=ve,f["https://w3id.org/blockcerts/schema/3.0-alpha/context.json"]=ve,f["https://w3id.org/blockcerts/v3.0-alpha"]=ve,f["https://www.blockcerts.org/schema/3.0-beta/context.json"]=Ne,f["https://w3id.org/blockcerts/schema/3.0-beta/context.json"]=Ne,f["https://w3id.org/blockcerts/v3.0-beta"]=Ne,f["https://w3id.org/security/suites/ed25519-2020/v1"]=Ue;const Le=a,Be=e=>{const t=(e=>{e={...e,crv:"K-256"};const t=b({jwk:e});return Le.from(t).toString("hex")})(e);let r=Le.from(t,"hex"),n=32-r.length;for(;n>0;)r=Le.concat([Le.from("00","hex"),r]),n--;return r},xe={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128};var De,Ce=Object.freeze({__proto__:null,bitcoin:xe,regtest:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"bcrt",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},testnet:{messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239}});!function(e){e[e.OP_FALSE=0]="OP_FALSE",e[e.OP_0=0]="OP_0",e[e.OP_PUSHDATA1=76]="OP_PUSHDATA1",e[e.OP_PUSHDATA2=77]="OP_PUSHDATA2",e[e.OP_PUSHDATA4=78]="OP_PUSHDATA4",e[e.OP_1NEGATE=79]="OP_1NEGATE",e[e.OP_RESERVED=80]="OP_RESERVED",e[e.OP_TRUE=81]="OP_TRUE",e[e.OP_1=81]="OP_1",e[e.OP_2=82]="OP_2",e[e.OP_3=83]="OP_3",e[e.OP_4=84]="OP_4",e[e.OP_5=85]="OP_5",e[e.OP_6=86]="OP_6",e[e.OP_7=87]="OP_7",e[e.OP_8=88]="OP_8",e[e.OP_9=89]="OP_9",e[e.OP_10=90]="OP_10",e[e.OP_11=91]="OP_11",e[e.OP_12=92]="OP_12",e[e.OP_13=93]="OP_13",e[e.OP_14=94]="OP_14",e[e.OP_15=95]="OP_15",e[e.OP_16=96]="OP_16",e[e.OP_NOP=97]="OP_NOP",e[e.OP_VER=98]="OP_VER",e[e.OP_IF=99]="OP_IF",e[e.OP_NOTIF=100]="OP_NOTIF",e[e.OP_VERIF=101]="OP_VERIF",e[e.OP_VERNOTIF=102]="OP_VERNOTIF",e[e.OP_ELSE=103]="OP_ELSE",e[e.OP_ENDIF=104]="OP_ENDIF",e[e.OP_VERIFY=105]="OP_VERIFY",e[e.OP_RETURN=106]="OP_RETURN",e[e.OP_TOALTSTACK=107]="OP_TOALTSTACK",e[e.OP_FROMALTSTACK=108]="OP_FROMALTSTACK",e[e.OP_2DROP=109]="OP_2DROP",e[e.OP_2DUP=110]="OP_2DUP",e[e.OP_3DUP=111]="OP_3DUP",e[e.OP_2OVER=112]="OP_2OVER",e[e.OP_2ROT=113]="OP_2ROT",e[e.OP_2SWAP=114]="OP_2SWAP",e[e.OP_IFDUP=115]="OP_IFDUP",e[e.OP_DEPTH=116]="OP_DEPTH",e[e.OP_DROP=117]="OP_DROP",e[e.OP_DUP=118]="OP_DUP",e[e.OP_NIP=119]="OP_NIP",e[e.OP_OVER=120]="OP_OVER",e[e.OP_PICK=121]="OP_PICK",e[e.OP_ROLL=122]="OP_ROLL",e[e.OP_ROT=123]="OP_ROT",e[e.OP_SWAP=124]="OP_SWAP",e[e.OP_TUCK=125]="OP_TUCK",e[e.OP_CAT=126]="OP_CAT",e[e.OP_SUBSTR=127]="OP_SUBSTR",e[e.OP_LEFT=128]="OP_LEFT",e[e.OP_RIGHT=129]="OP_RIGHT",e[e.OP_SIZE=130]="OP_SIZE",e[e.OP_INVERT=131]="OP_INVERT",e[e.OP_AND=132]="OP_AND",e[e.OP_OR=133]="OP_OR",e[e.OP_XOR=134]="OP_XOR",e[e.OP_EQUAL=135]="OP_EQUAL",e[e.OP_EQUALVERIFY=136]="OP_EQUALVERIFY",e[e.OP_RESERVED1=137]="OP_RESERVED1",e[e.OP_RESERVED2=138]="OP_RESERVED2",e[e.OP_1ADD=139]="OP_1ADD",e[e.OP_1SUB=140]="OP_1SUB",e[e.OP_2MUL=141]="OP_2MUL",e[e.OP_2DIV=142]="OP_2DIV",e[e.OP_NEGATE=143]="OP_NEGATE",e[e.OP_ABS=144]="OP_ABS",e[e.OP_NOT=145]="OP_NOT",e[e.OP_0NOTEQUAL=146]="OP_0NOTEQUAL",e[e.OP_ADD=147]="OP_ADD",e[e.OP_SUB=148]="OP_SUB",e[e.OP_MUL=149]="OP_MUL",e[e.OP_DIV=150]="OP_DIV",e[e.OP_MOD=151]="OP_MOD",e[e.OP_LSHIFT=152]="OP_LSHIFT",e[e.OP_RSHIFT=153]="OP_RSHIFT",e[e.OP_BOOLAND=154]="OP_BOOLAND",e[e.OP_BOOLOR=155]="OP_BOOLOR",e[e.OP_NUMEQUAL=156]="OP_NUMEQUAL",e[e.OP_NUMEQUALVERIFY=157]="OP_NUMEQUALVERIFY",e[e.OP_NUMNOTEQUAL=158]="OP_NUMNOTEQUAL",e[e.OP_LESSTHAN=159]="OP_LESSTHAN",e[e.OP_GREATERTHAN=160]="OP_GREATERTHAN",e[e.OP_LESSTHANOREQUAL=161]="OP_LESSTHANOREQUAL",e[e.OP_GREATERTHANOREQUAL=162]="OP_GREATERTHANOREQUAL",e[e.OP_MIN=163]="OP_MIN",e[e.OP_MAX=164]="OP_MAX",e[e.OP_WITHIN=165]="OP_WITHIN",e[e.OP_RIPEMD160=166]="OP_RIPEMD160",e[e.OP_SHA1=167]="OP_SHA1",e[e.OP_SHA256=168]="OP_SHA256",e[e.OP_HASH160=169]="OP_HASH160",e[e.OP_HASH256=170]="OP_HASH256",e[e.OP_CODESEPARATOR=171]="OP_CODESEPARATOR",e[e.OP_CHECKSIG=172]="OP_CHECKSIG",e[e.OP_CHECKSIGVERIFY=173]="OP_CHECKSIGVERIFY",e[e.OP_CHECKMULTISIG=174]="OP_CHECKMULTISIG",e[e.OP_CHECKMULTISIGVERIFY=175]="OP_CHECKMULTISIGVERIFY",e[e.OP_NOP1=176]="OP_NOP1",e[e.OP_CHECKLOCKTIMEVERIFY=177]="OP_CHECKLOCKTIMEVERIFY",e[e.OP_NOP2=177]="OP_NOP2",e[e.OP_CHECKSEQUENCEVERIFY=178]="OP_CHECKSEQUENCEVERIFY",e[e.OP_NOP3=178]="OP_NOP3",e[e.OP_NOP4=179]="OP_NOP4",e[e.OP_NOP5=180]="OP_NOP5",e[e.OP_NOP6=181]="OP_NOP6",e[e.OP_NOP7=182]="OP_NOP7",e[e.OP_NOP8=183]="OP_NOP8",e[e.OP_NOP9=184]="OP_NOP9",e[e.OP_NOP10=185]="OP_NOP10",e[e.OP_CHECKSIGADD=186]="OP_CHECKSIGADD",e[e.OP_PUBKEYHASH=253]="OP_PUBKEYHASH",e[e.OP_PUBKEY=254]="OP_PUBKEY",e[e.OP_INVALIDOPCODE=255]="OP_INVALIDOPCODE"}(De||(De={}));const Ve="0123456789abcdefABCDEF",Fe=Ve.split("").map(e=>e.codePointAt(0)),He=Array(256).fill(!0).map((e,t)=>{const r=String.fromCodePoint(t),n=Ve.indexOf(r);return n<0?void 0:n<16?n:n-6}),Ge=new TextEncoder,je=new TextDecoder;function Ke(e){const t=e.reduce((e,t)=>e+t.length,0),r=new Uint8Array(t);let n=0;for(const t of e)r.set(t,n),n+=t.length;return r}function $e(e){const t=e||new Uint8Array;return t.length>512?function(e){const t=new Uint8Array(2*e.length);for(let r=0;r<e.length;++r)t[2*r]=Fe[e[r]>>4],t[2*r+1]=Fe[15&e[r]];return je.decode(t)}(t):function(e){let t="";for(let r=0;r<e.length;++r)t+=Ve[He[Fe[e[r]>>4]]],t+=Ve[He[Fe[15&e[r]]]];return t}(t)}function Ye(e){const t=Ge.encode(e||""),r=new Uint8Array(Math.floor(t.length/2));let n;for(n=0;n<r.length;n++){const e=He[t[2*n]],i=He[t[2*n+1]];if(void 0===e||void 0===i)break;r[n]=e<<4|i}return n===r.length?r:r.slice(0,n)}function ze(e,t){const r=Math.min(e.length,t.length);for(let n=0;n<r;++n)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return e.length===t.length?0:e.length>t.length?1:-1}function We(e,t,r){if(t+1>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(r>255)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 255. Received ${r}`);return e[t]=r,t+1}function Je(e,t,r,n){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>4294967295)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 4294967295. Received ${r}`);return"LE"===n?(e[t]=255&r,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255):(e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r),t+4}function qe(e,t){if(t+1>e.length)throw new Error("Offset is outside the bounds of Uint8Array");return e[t]}function Xe(e,t,r){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if("LE"===(r=r.toUpperCase())){let r=0;return r=(r<<8)+e[t+3]>>>0,r=(r<<8)+e[t+2]>>>0,r=(r<<8)+e[t+1]>>>0,r=(r<<8)+e[t]>>>0,r}{let r=0;return r=(r<<8)+e[t]>>>0,r=(r<<8)+e[t+1]>>>0,r=(r<<8)+e[t+2]>>>0,r=(r<<8)+e[t+3]>>>0,r}}function Qe(e){return e<De.OP_PUSHDATA1?1:e<=255?2:e<=65535?3:5}function Ze(e,t,r){const n=Qe(t);return 1===n?We(e,r,t):2===n?(We(e,r,De.OP_PUSHDATA1),We(e,r+1,t)):3===n?(We(e,r,De.OP_PUSHDATA2),function(e,t,r,n){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>65535)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 65535. Received ${r}`);"LE"===n?(e[t]=255&r,e[t+1]=r>>8&255):(e[t]=r>>8&255,e[t+1]=255&r)}(e,r+1,t,"LE")):(We(e,r,De.OP_PUSHDATA4),Je(e,r+1,t,"LE")),n}function et(e,t){const r=qe(e,t);let n,i;if(r<De.OP_PUSHDATA1)n=r,i=1;else if(r===De.OP_PUSHDATA1){if(t+2>e.length)return null;n=qe(e,t+1),i=2}else if(r===De.OP_PUSHDATA2){if(t+3>e.length)return null;n=function(e,t,r){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if("LE"===(r=r.toUpperCase())){let r=0;return r=(r<<8)+e[t+1],r=(r<<8)+e[t],r}{let r=0;return r=(r<<8)+e[t],r=(r<<8)+e[t+1],r}}(e,t+1,"LE"),i=3}else{if(t+5>e.length)return null;if(r!==De.OP_PUSHDATA4)throw new Error("Unexpected opcode");n=Xe(e,t+1,"LE"),i=5}return{opcode:r,number:n,size:i}}const tt={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function rt(e){return tt}function nt(e){const t=typeof e;return"string"===t?`"${e}"`:"number"===t||"bigint"===t||"boolean"===t?`${e}`:"object"===t||"function"===t?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}function it(e,t,r,n,i){const o=i&&"input"in i?i.input:r.value,s=i?.expected??e.expects??null,a=i?.received??nt(o),c={kind:e.kind,type:e.type,input:o,expected:s,received:a,message:`Invalid ${t}: ${s?`Expected ${s} but r`:"R"}eceived ${a}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},u="schema"===e.kind,h=i?.message??e.message??(e.reference,void c.lang)??(u?void c.lang:null)??n.message??void c.lang;void 0!==h&&(c.message="function"==typeof h?h(c):h),u&&(r.typed=!1),r.issues?r.issues.push(c):r.issues=[c]}const ot=new WeakMap;function st(e){let t=ot.get(e);return t||(t={version:1,vendor:"valibot",validate:t=>e["~run"]({value:t},rt())},ot.set(e,t)),t}function at(e,t){const r=[...new Set(e)];return r.length>1?`(${r.join(` ${t} `)})`:r[0]??"never"}var ct=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function ut(e,t){return{kind:"validation",type:"length",reference:ut,async:!1,expects:`${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length!==this.requirement&&it(this,"length",e,t,{received:`${e.value.length}`}),e}}}const ht={abortEarly:!0};function ft(e,t,r){return"function"==typeof e.fallback?e.fallback(t,r):e.fallback}function lt(e,t,r){return"function"==typeof e.default?e.default(t,r):e.default}function dt(e,t){return{kind:"schema",type:"custom",reference:dt,expects:"unknown",async:!1,check:e,message:t,get"~standard"(){return st(this)},"~run"(e,t){return this.check(e.value)?e.typed=!0:it(this,"type",e,t),e}}}function pt(e,t){return{kind:"schema",type:"instance",reference:pt,expects:e.name,async:!1,class:e,message:t,get"~standard"(){return st(this)},"~run"(e,t){return e.value instanceof this.class?e.typed=!0:it(this,"type",e,t),e}}}function yt(e,t){return{kind:"schema",type:"object",reference:yt,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return st(this)},"~run"(e,t){const r=e.value;if(r&&"object"==typeof r){e.typed=!0,e.value={};for(const n in this.entries){const i=this.entries[n];if(n in r||("exact_optional"===i.type||"optional"===i.type||"nullish"===i.type)&&void 0!==i.default){const o=n in r?r[n]:lt(i),s=i["~run"]({value:o},t);if(s.issues){const i={type:"object",origin:"value",input:r,key:n,value:o};for(const t of s.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||(e.issues=s.issues),t.abortEarly){e.typed=!1;break}}s.typed||(e.typed=!1),e.value[n]=s.value}else if(void 0!==i.fallback)e.value[n]=ft(i);else if("exact_optional"!==i.type&&"optional"!==i.type&&"nullish"!==i.type&&(it(this,"key",e,t,{input:void 0,expected:`"${n}"`,path:[{type:"object",origin:"key",input:r,key:n,value:r[n]}]}),t.abortEarly))break}}else it(this,"type",e,t);return e}}}function gt(e,t){return{kind:"schema",type:"optional",reference:gt,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return st(this)},"~run"(e,t){return void 0===e.value&&(void 0!==this.default&&(e.value=lt(this,e,t)),void 0===e.value)?(e.typed=!0,e):this.wrapped["~run"](e,t)}}}function Et(e){return{kind:"schema",type:"string",reference:Et,expects:"string",async:!1,message:e,get"~standard"(){return st(this)},"~run"(e,t){return"string"==typeof e.value?e.typed=!0:it(this,"type",e,t),e}}}function mt(e){let t;if(e)for(const r of e)if(t)for(const e of r.issues)t.push(e);else t=r.issues;return t}function _t(e,t,r){const n=e["~run"]({value:t},rt());if(n.issues)throw new ct(n.issues);return n.value}const It=new Uint8Array(32),wt=Ye("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Pt=e=>function(...e){return{...e[0],pipe:e,get"~standard"(){return st(this)},"~run"(t,r){for(const n of e)if("metadata"!==n.kind){if(t.issues&&("schema"===n.kind||"transformation"===n.kind)){t.typed=!1;break}t.issues&&(r.abortEarly||r.abortPipeEarly)||(t=n["~run"](t,r))}return t}}}(pt(Uint8Array),ut(e));function bt(e){if(!(e instanceof Uint8Array))return!1;if(e.length<33)return!1;const t=e[0],r=e.slice(1,33);if(0===ze(It,r))return!1;if(ze(r,wt)>=0)return!1;if((2===t||3===t)&&33===e.length)return!0;const n=e.slice(33);return 0!==ze(It,n)&&(!(ze(n,wt)>=0)&&(4===t&&65===e.length))}const At=Pt(20),Ot=pt(Uint8Array),Tt=De.OP_RESERVED,Rt=function e(t,r){return{kind:"schema",type:"array",reference:e,expects:"Array",async:!1,item:t,message:r,get"~standard"(){return st(this)},"~run"(e,t){const r=e.value;if(Array.isArray(r)){e.typed=!0,e.value=[];for(let n=0;n<r.length;n++){const i=r[n],o=this.item["~run"]({value:i},t);if(o.issues){const s={type:"array",origin:"value",input:r,key:n,value:i};for(const t of o.issues)t.path?t.path.unshift(s):t.path=[s],e.issues?.push(t);if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value.push(o.value)}}else it(this,"type",e,t);return e}}}(function e(t,r){return{kind:"schema",type:"union",reference:e,expects:at(t.map(e=>e.expects),"|"),async:!1,options:t,message:r,get"~standard"(){return st(this)},"~run"(e,t){let r,n,i;for(const o of this.options){const s=o["~run"]({value:e.value},t);if(s.typed){if(!s.issues){r=s;break}n?n.push(s):n=[s]}else i?i.push(s):i=[s]}if(r)return r;if(n){if(1===n.length)return n[0];it(this,"type",e,t,{issues:mt(n)}),e.typed=!0}else{if(1===i?.length)return i[0];it(this,"type",e,t,{issues:mt(i)})}return e}}}([pt(Uint8Array),function e(t){return{kind:"schema",type:"number",reference:e,expects:"number",async:!1,message:t,get"~standard"(){return st(this)},"~run"(e,t){return"number"!=typeof e.value||isNaN(e.value)?it(this,"type",e,t):e.typed=!0,e}}}()]));function St(e){return 0===e.length?De.OP_0:1===e.length?e[0]>=1&&e[0]<=16?Tt+e[0]:129===e[0]?De.OP_1NEGATE:void 0:void 0}function vt(e){return function(e,t){return!e["~run"]({value:t},ht).issues}(Rt,e)}function Nt(e){return e instanceof Uint8Array}function Ut(e){if(e instanceof Uint8Array)return e;_t(Rt,e);const t=e.reduce((e,t)=>Nt(t)?1===t.length&&void 0!==St(t)?e+1:e+Qe(t.length)+t.length:e+1,0),r=new Uint8Array(t);let n=0;if(e.forEach(e=>{if(Nt(e)){const t=St(e);if(void 0!==t)return We(r,n,t),void(n+=1);n+=Ze(r,e.length,n),r.set(e,n),n+=e.length}else We(r,n,e),n+=1}),n!==r.length)throw new Error("Could not decode chunks");return r}function kt(e){return e instanceof Uint8Array&&(!!function(e){const t=-129&e;return t>0&&t<4}(e[e.length-1])&&function(e){if(e.length<8)return!1;if(e.length>72)return!1;if(48!==e[0])return!1;if(e[1]!==e.length-2)return!1;if(2!==e[2])return!1;const t=e[3];if(0===t)return!1;if(5+t>=e.length)return!1;if(2!==e[4+t])return!1;const r=e[5+t];return!(0===r||6+t+r!==e.length||128&e[4]||t>1&&0===e[4]&&!(128&e[5])||128&e[t+6]||r>1&&0===e[t+6]&&!(128&e[t+7]))}(e.slice(0,-1)))}function Mt(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){const e=r.call(this);return this[t]=e,e},set(e){Object.defineProperty(this,t,{configurable:!0,enumerable:!0,value:e,writable:!0})}})}function Lt(e){let t;return()=>(void 0!==t||(t=e()),t)}function Bt(e,...t){if(!((r=e)instanceof Uint8Array||ArrayBuffer.isView(r)&&"Uint8Array"===r.constructor.name))throw new Error("Uint8Array expected");
2
+ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3
+ var r;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function xt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Dt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Ct(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Vt(e,t){return e<<32-t|e>>>t}function Ft(e,t){return e<<t|e>>>32-t>>>0}function Ht(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e)),Bt(e),e}De.OP_RESERVED;let Gt=class{};function jt(e){const t=t=>e().update(Ht(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Kt(e,t,r){return e&t^~e&r}function $t(e,t,r){return e&t^e&r^t&r}let Yt=class extends Gt{constructor(e,t,r,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.buffer=new Uint8Array(e),this.view=Ct(this.buffer)}update(e){xt(this),Bt(e=Ht(e));const{view:t,buffer:r,blockLen:n}=this,i=e.length;for(let o=0;o<i;){const s=Math.min(n-this.pos,i-o);if(s===n){const t=Ct(e);for(;n<=i-o;o+=n)this.process(t,o);continue}r.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){xt(this),function(e,t){Bt(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:n,isLE:i}=this;let{pos:o}=this;t[o++]=128,Dt(this.buffer.subarray(o)),this.padOffset>n-o&&(this.process(r,0),o=0);for(let e=o;e<n;e++)t[e]=0;!function(e,t,r,n){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),c=n?4:0,u=n?0:4;e.setUint32(t+c,s,n),e.setUint32(t+u,a,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const s=Ct(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)s.setUint32(4*e,u[e],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return e.destroyed=o,e.finished=i,e.length=n,e.pos=s,n%t&&e.buffer.set(r),e}clone(){return this._cloneInto()}};const zt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Wt=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Jt=(()=>Uint8Array.from(new Array(16).fill(0).map((e,t)=>t)))(),qt=(()=>Jt.map(e=>(9*e+5)%16))(),Xt=(()=>{const e=[[Jt],[qt]];for(let t=0;t<4;t++)for(let r of e)r.push(r[t].map(e=>Wt[e]));return e})(),Qt=(()=>Xt[0])(),Zt=(()=>Xt[1])(),er=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(e=>Uint8Array.from(e)),tr=Qt.map((e,t)=>e.map(e=>er[t][e])),rr=Zt.map((e,t)=>e.map(e=>er[t][e])),nr=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),ir=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function or(e,t,r,n){return 0===e?t^r^n:1===e?t&r|~t&n:2===e?(t|~r)^n:3===e?t&n|r&~n:t^(r|~n)}const sr=new Uint32Array(16);class ar extends Yt{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:e,h1:t,h2:r,h3:n,h4:i}=this;return[e,t,r,n,i]}set(e,t,r,n,i){this.h0=0|e,this.h1=0|t,this.h2=0|r,this.h3=0|n,this.h4=0|i}process(e,t){for(let r=0;r<16;r++,t+=4)sr[r]=e.getUint32(t,!0);let r=0|this.h0,n=r,i=0|this.h1,o=i,s=0|this.h2,a=s,c=0|this.h3,u=c,h=0|this.h4,f=h;for(let e=0;e<5;e++){const t=4-e,l=nr[e],d=ir[e],p=Qt[e],y=Zt[e],g=tr[e],E=rr[e];for(let t=0;t<16;t++){const n=Ft(r+or(e,i,s,c)+sr[p[t]]+l,g[t])+h|0;r=h,h=c,c=0|Ft(s,10),s=i,i=n}for(let e=0;e<16;e++){const r=Ft(n+or(t,o,a,u)+sr[y[e]]+d,E[e])+f|0;n=f,f=u,u=0|Ft(a,10),a=o,o=r}}this.set(this.h1+s+u|0,this.h2+c+f|0,this.h3+h+n|0,this.h4+r+o|0,this.h0+i+a|0)}roundClean(){Dt(sr)}destroy(){this.destroyed=!0,Dt(this.buffer),this.set(0,0,0,0,0)}}const cr=jt(()=>new ar),ur=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),hr=new Uint32Array(64);let fr=class extends Yt{constructor(e=32){super(64,e,8,!1),this.A=0|zt[0],this.B=0|zt[1],this.C=0|zt[2],this.D=0|zt[3],this.E=0|zt[4],this.F=0|zt[5],this.G=0|zt[6],this.H=0|zt[7]}get(){const{A:e,B:t,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[e,t,r,n,i,o,s,a]}set(e,t,r,n,i,o,s,a){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(e,t){for(let r=0;r<16;r++,t+=4)hr[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=hr[e-15],r=hr[e-2],n=Vt(t,7)^Vt(t,18)^t>>>3,i=Vt(r,17)^Vt(r,19)^r>>>10;hr[e]=i+hr[e-7]+n+hr[e-16]|0}let{A:r,B:n,C:i,D:o,E:s,F:a,G:c,H:u}=this;for(let e=0;e<64;e++){const t=u+(Vt(s,6)^Vt(s,11)^Vt(s,25))+Kt(s,a,c)+ur[e]+hr[e]|0,h=(Vt(r,2)^Vt(r,13)^Vt(r,22))+$t(r,n,i)|0;u=c,c=a,a=s,s=o+t|0,o=i,i=n,n=r,r=t+h|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,n,i,o,s,a,c,u)}roundClean(){Dt(hr)}destroy(){this.set(0,0,0,0,0,0,0,0),Dt(this.buffer)}};const lr=jt(()=>new fr);function dr(e){return cr(lr(e))}function pr(e,...t){if(!((r=e)instanceof Uint8Array||ArrayBuffer.isView(r)&&"Uint8Array"===r.constructor.name))throw new Error("Uint8Array expected");
4
+ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
5
+ var r;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function yr(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function gr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Er(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function mr(e,t){return e<<32-t|e>>>t}function _r(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e)),pr(e),e}Uint8Array.from([123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124,123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124]),Uint8Array.from([241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144,241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144]),Uint8Array.from([7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47,7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47]),Uint8Array.from([174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238,174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238]),Uint8Array.from([25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21,25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21]),Uint8Array.from([244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49,244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49]),Uint8Array.from([232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233,232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233]),Uint8Array.from([72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240,72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240]),Uint8Array.from([191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129,191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129]);class Ir{}function wr(e){const t=t=>e().update(_r(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Pr(e,t,r){return e&t^~e&r}function br(e,t,r){return e&t^e&r^t&r}class Ar extends Ir{constructor(e,t,r,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.buffer=new Uint8Array(e),this.view=Er(this.buffer)}update(e){yr(this),pr(e=_r(e));const{view:t,buffer:r,blockLen:n}=this,i=e.length;for(let o=0;o<i;){const s=Math.min(n-this.pos,i-o);if(s===n){const t=Er(e);for(;n<=i-o;o+=n)this.process(t,o);continue}r.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){yr(this),function(e,t){pr(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:n,isLE:i}=this;let{pos:o}=this;t[o++]=128,gr(this.buffer.subarray(o)),this.padOffset>n-o&&(this.process(r,0),o=0);for(let e=o;e<n;e++)t[e]=0;!function(e,t,r,n){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),c=n?4:0,u=n?0:4;e.setUint32(t+c,s,n),e.setUint32(t+u,a,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const s=Er(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)s.setUint32(4*e,u[e],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return e.destroyed=o,e.finished=i,e.length=n,e.pos=s,n%t&&e.buffer.set(r),e}clone(){return this._cloneInto()}}const Or=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Tr=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Rr=new Uint32Array(64);class Sr extends Ar{constructor(e=32){super(64,e,8,!1),this.A=0|Or[0],this.B=0|Or[1],this.C=0|Or[2],this.D=0|Or[3],this.E=0|Or[4],this.F=0|Or[5],this.G=0|Or[6],this.H=0|Or[7]}get(){const{A:e,B:t,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[e,t,r,n,i,o,s,a]}set(e,t,r,n,i,o,s,a){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(e,t){for(let r=0;r<16;r++,t+=4)Rr[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=Rr[e-15],r=Rr[e-2],n=mr(t,7)^mr(t,18)^t>>>3,i=mr(r,17)^mr(r,19)^r>>>10;Rr[e]=i+Rr[e-7]+n+Rr[e-16]|0}let{A:r,B:n,C:i,D:o,E:s,F:a,G:c,H:u}=this;for(let e=0;e<64;e++){const t=u+(mr(s,6)^mr(s,11)^mr(s,25))+Pr(s,a,c)+Tr[e]+Rr[e]|0,h=(mr(r,2)^mr(r,13)^mr(r,22))+br(r,n,i)|0;u=c,c=a,a=s,s=o+t|0,o=i,i=n,n=r,r=t+h|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,n,i,o,s,a,c,u)}roundClean(){gr(Rr)}destroy(){this.set(0,0,0,0,0,0,0,0),gr(this.buffer)}}const vr=wr(()=>new Sr);var Nr=function(e){function t(t){var r=t.slice(0,-4),n=t.slice(-4),i=e(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(t){var r=Uint8Array.from(t),n=e(r),i=r.length+4,o=new Uint8Array(i);return o.set(r,0),o.set(n.subarray(0,4),r.length),E.encode(o)},decode:function(e){var r=t(E.decode(e));if(null==r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(e){var r=E.decodeUnsafe(e);if(null!=r)return t(r)}}}(function(e){return vr(vr(e))});const Ur=De;function kr(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||{}),_t(function(e){const t={};for(const r in e.entries)t[r]=gt(e.entries[r]);return{...e,entries:t,get"~standard"(){return st(this)}}}(yt({network:yt({}),address:Et(),hash:At,output:Pt(25),pubkey:dt(bt),signature:dt(kt),input:Ot})),e);const r=Lt(()=>{const t=Nr.decode(e.address);return{version:qe(t,0),hash:t.slice(1)}}),n=Lt(()=>function(e){if(vt(e))return e;_t(Ot,e);const t=[];let r=0;for(;r<e.length;){const n=e[r];if(n>De.OP_0&&n<=De.OP_PUSHDATA4){const n=et(e,r);if(null===n)return null;if(r+=n.size,r+n.number>e.length)return null;const i=e.slice(r,r+n.number);r+=n.number;const o=St(i);void 0!==o?t.push(o):t.push(i)}else t.push(n),r+=1}return t}(e.input)),i=e.network||xe,o={name:"p2pkh",network:i};if(Mt(o,"address",()=>{if(!o.hash)return;const e=new Uint8Array(21);return We(e,0,i.pubKeyHash),e.set(o.hash,1),Nr.encode(e)}),Mt(o,"hash",()=>e.output?e.output.slice(3,23):e.address?r().hash:e.pubkey||o.pubkey?dr(e.pubkey||o.pubkey):void 0),Mt(o,"output",()=>{if(o.hash)return Ut([Ur.OP_DUP,Ur.OP_HASH160,o.hash,Ur.OP_EQUALVERIFY,Ur.OP_CHECKSIG])}),Mt(o,"pubkey",()=>{if(e.input)return n()[1]}),Mt(o,"signature",()=>{if(e.input)return n()[0]}),Mt(o,"input",()=>{if(e.pubkey&&e.signature)return Ut([e.signature,e.pubkey])}),Mt(o,"witness",()=>{if(o.input)return[]}),t.validate){let t=Uint8Array.from([]);if(e.address){if(r().version!==i.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(20!==r().hash.length)throw new TypeError("Invalid address");t=r().hash}if(e.hash){if(t.length>0&&0!==ze(t,e.hash))throw new TypeError("Hash mismatch");t=e.hash}if(e.output){if(25!==e.output.length||e.output[0]!==Ur.OP_DUP||e.output[1]!==Ur.OP_HASH160||20!==e.output[2]||e.output[23]!==Ur.OP_EQUALVERIFY||e.output[24]!==Ur.OP_CHECKSIG)throw new TypeError("Output is invalid");const r=e.output.slice(3,23);if(t.length>0&&0!==ze(t,r))throw new TypeError("Hash mismatch");t=r}if(e.pubkey){const r=dr(e.pubkey);if(t.length>0&&0!==ze(t,r))throw new TypeError("Hash mismatch");t=r}if(e.input){const r=n();if(2!==r.length)throw new TypeError("Input is invalid");if(!kt(r[0]))throw new TypeError("Input has invalid signature");if(!bt(r[1]))throw new TypeError("Input has invalid pubkey");if(e.signature&&0!==ze(e.signature,r[0]))throw new TypeError("Signature mismatch");if(e.pubkey&&0!==ze(e.pubkey,r[1]))throw new TypeError("Pubkey mismatch");const i=dr(r[1]);if(t.length>0&&0!==ze(t,i))throw new TypeError("Hash mismatch")}}return Object.assign(o,e)}var Mr,Lr={};!function(){if(Mr)return Lr;Mr=1,Object.defineProperty(Lr,"__esModule",{value:!0}),Lr.bech32m=Lr.bech32=void 0;const e="qpzry9x8gf2tvdw0s3jn54khce6mua7l",t={};for(let r=0;r<32;r++){const n=e.charAt(r);t[n]=r}function r(e){const t=e>>25;return(33554431&e)<<5^996825010&-(1&t)^642813549&-(t>>1&1)^513874426&-(t>>2&1)^1027748829&-(t>>3&1)^705979059&-(t>>4&1)}function n(e){let t=1;for(let n=0;n<e.length;++n){const i=e.charCodeAt(n);if(i<33||i>126)return"Invalid prefix ("+e+")";t=r(t)^i>>5}t=r(t);for(let n=0;n<e.length;++n){const i=e.charCodeAt(n);t=r(t)^31&i}return t}function i(e,t,r,n){let i=0,o=0;const s=(1<<r)-1,a=[];for(let n=0;n<e.length;++n)for(i=i<<t|e[n],o+=t;o>=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<<r-o&s);else{if(o>=t)return"Excess padding";if(i<<r-o&s)return"Non-zero padding"}return a}function o(e){return i(e,8,5,!0)}function s(e){const t=i(e,5,8,!1);if(Array.isArray(t))return t}function a(e){const t=i(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function c(i){let c;function u(e,i){if(i=i||90,e.length<8)return e+" too short";if(e.length>i)return"Exceeds length limit";const o=e.toLowerCase(),s=e.toUpperCase();if(e!==o&&e!==s)return"Mixed-case string "+e;const a=(e=o).lastIndexOf("1");if(-1===a)return"No separator character for "+e;if(0===a)return"Missing prefix for "+e;const u=e.slice(0,a),h=e.slice(a+1);if(h.length<6)return"Data too short";let f=n(u);if("string"==typeof f)return f;const l=[];for(let e=0;e<h.length;++e){const n=h.charAt(e),i=t[n];if(void 0===i)return"Unknown character "+n;f=r(f)^i,e+6>=h.length||l.push(i)}return f!==c?"Invalid checksum for "+e:{prefix:u,words:l}}return c="bech32"===i?1:734539939,{decodeUnsafe:function(e,t){const r=u(e,t);if("object"==typeof r)return r},decode:function(e,t){const r=u(e,t);if("object"==typeof r)return r;throw new Error(r)},encode:function(t,i,o){if(o=o||90,t.length+7+i.length>o)throw new TypeError("Exceeds length limit");let s=n(t=t.toLowerCase());if("string"==typeof s)throw new Error(s);let a=t+"1";for(let t=0;t<i.length;++t){const n=i[t];if(n>>5)throw new Error("Non 5-bit word");s=r(s)^n,a+=e.charAt(n)}for(let e=0;e<6;++e)s=r(s);s^=c;for(let t=0;t<6;++t){a+=e.charAt(s>>5*(5-t)&31)}return a},toWords:o,fromWordsUnsafe:s,fromWords:a}}Lr.bech32=c("bech32"),Lr.bech32m=c("bech32m")}();const Br="0123456789abcdefABCDEF";Br.split("").map(e=>e.codePointAt(0)),Array(256).fill(!0).map((e,t)=>{const r=String.fromCodePoint(t),n=Br.indexOf(r);return n<0?void 0:n<16?n:n-6}),new TextEncoder,new TextDecoder;function xr(e){"number"==typeof e?function(e){if(e<0||e>Number.MAX_SAFE_INTEGER||e%1!=0)throw new RangeError("value out of range")}(e):(e=>{if(e<0||e>0xffffffffffffffffn)throw new RangeError("value out of range")})(e)}function Dr(e,t,r){xr(e),void 0===r&&(r=0),void 0===t&&(t=new Uint8Array(Vr(e)));let n=0;return e<253?(t.set([Number(e)],r),n=1):e<=65535?(t.set([253],r),function(e,t,r,n){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>65535)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 65535. Received ${r}`);"LE"===n?(e[t]=255&r,e[t+1]=r>>8&255):(e[t]=r>>8&255,e[t+1]=255&r)}(t,r+1,Number(e),"LE"),n=3):e<=4294967295?(t.set([254],r),function(e,t,r,n){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>4294967295)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 4294967295. Received ${r}`);"LE"===n?(e[t]=255&r,e[t+1]=r>>8&255,e[t+2]=r>>16&255,e[t+3]=r>>24&255):(e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r)}(t,r+1,Number(e),"LE"),n=5):(t.set([255],r),function(e,t,r,n){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if(n=n.toUpperCase(),r>0xffffffffffffffffn)throw new Error(`The value of "value" is out of range. It must be >= 0 and <= 18446744073709551615. Received ${r}`);"LE"===n?(e[t]=Number(0xffn&r),e[t+1]=Number(r>>8n&0xffn),e[t+2]=Number(r>>16n&0xffn),e[t+3]=Number(r>>24n&0xffn),e[t+4]=Number(r>>32n&0xffn),e[t+5]=Number(r>>40n&0xffn),e[t+6]=Number(r>>48n&0xffn),e[t+7]=Number(r>>56n&0xffn)):(e[t]=Number(r>>56n&0xffn),e[t+1]=Number(r>>48n&0xffn),e[t+2]=Number(r>>40n&0xffn),e[t+3]=Number(r>>32n&0xffn),e[t+4]=Number(r>>24n&0xffn),e[t+5]=Number(r>>16n&0xffn),e[t+6]=Number(r>>8n&0xffn),e[t+7]=Number(0xffn&r))}(t,r+1,BigInt(e),"LE"),n=9),{buffer:t,bytes:n}}function Cr(e,t){void 0===t&&(t=0);const r=e.at(t);if(void 0===r)throw new Error("buffer too small");if(r<253)return{numberValue:r,bigintValue:BigInt(r),bytes:1};if(253===r){const r=function(e,t,r){if(t+2>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if("LE"===(r=r.toUpperCase())){let r=0;return r=(r<<8)+e[t+1],r=(r<<8)+e[t],r}{let r=0;return r=(r<<8)+e[t],r=(r<<8)+e[t+1],r}}(e,t+1,"LE");return{numberValue:r,bigintValue:BigInt(r),bytes:3}}if(254===r){const r=function(e,t,r){if(t+4>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if("LE"===(r=r.toUpperCase())){let r=0;return r=(r<<8)+e[t+3]>>>0,r=(r<<8)+e[t+2]>>>0,r=(r<<8)+e[t+1]>>>0,r=(r<<8)+e[t]>>>0,r}{let r=0;return r=(r<<8)+e[t]>>>0,r=(r<<8)+e[t+1]>>>0,r=(r<<8)+e[t+2]>>>0,r=(r<<8)+e[t+3]>>>0,r}}(e,t+1,"LE");return{numberValue:r,bigintValue:BigInt(r),bytes:5}}{const r=function(e,t,r){if(t+8>e.length)throw new Error("Offset is outside the bounds of Uint8Array");if("LE"===(r=r.toUpperCase())){let r=0n;return r=(r<<8n)+BigInt(e[t+7]),r=(r<<8n)+BigInt(e[t+6]),r=(r<<8n)+BigInt(e[t+5]),r=(r<<8n)+BigInt(e[t+4]),r=(r<<8n)+BigInt(e[t+3]),r=(r<<8n)+BigInt(e[t+2]),r=(r<<8n)+BigInt(e[t+1]),r=(r<<8n)+BigInt(e[t]),r}{let r=0n;return r=(r<<8n)+BigInt(e[t]),r=(r<<8n)+BigInt(e[t+1]),r=(r<<8n)+BigInt(e[t+2]),r=(r<<8n)+BigInt(e[t+3]),r=(r<<8n)+BigInt(e[t+4]),r=(r<<8n)+BigInt(e[t+5]),r=(r<<8n)+BigInt(e[t+6]),r=(r<<8n)+BigInt(e[t+7]),r}}(e,t+1,"LE");return{numberValue:r<=Number.MAX_SAFE_INTEGER?Number(r):null,bigintValue:r,bytes:9}}}function Vr(e){return xr(e),e<253?1:e<=65535?3:e<=4294967295?5:9}var Fr,Hr,Gr;Ye("0000000000000000000000000000000000000000000000000000000000000000"),Ye("0000000000000000000000000000000000000000000000000000000000000001"),Ye("ffffffffffffffff"),function(e){e[e.UNSIGNED_TX=0]="UNSIGNED_TX",e[e.GLOBAL_XPUB=1]="GLOBAL_XPUB"}(Fr||(Fr={})),function(e){e[e.NON_WITNESS_UTXO=0]="NON_WITNESS_UTXO",e[e.WITNESS_UTXO=1]="WITNESS_UTXO",e[e.PARTIAL_SIG=2]="PARTIAL_SIG",e[e.SIGHASH_TYPE=3]="SIGHASH_TYPE",e[e.REDEEM_SCRIPT=4]="REDEEM_SCRIPT",e[e.WITNESS_SCRIPT=5]="WITNESS_SCRIPT",e[e.BIP32_DERIVATION=6]="BIP32_DERIVATION",e[e.FINAL_SCRIPTSIG=7]="FINAL_SCRIPTSIG",e[e.FINAL_SCRIPTWITNESS=8]="FINAL_SCRIPTWITNESS",e[e.POR_COMMITMENT=9]="POR_COMMITMENT",e[e.TAP_KEY_SIG=19]="TAP_KEY_SIG",e[e.TAP_SCRIPT_SIG=20]="TAP_SCRIPT_SIG",e[e.TAP_LEAF_SCRIPT=21]="TAP_LEAF_SCRIPT",e[e.TAP_BIP32_DERIVATION=22]="TAP_BIP32_DERIVATION",e[e.TAP_INTERNAL_KEY=23]="TAP_INTERNAL_KEY",e[e.TAP_MERKLE_ROOT=24]="TAP_MERKLE_ROOT"}(Hr||(Hr={})),function(e){e[e.REDEEM_SCRIPT=0]="REDEEM_SCRIPT",e[e.WITNESS_SCRIPT=1]="WITNESS_SCRIPT",e[e.BIP32_DERIVATION=2]="BIP32_DERIVATION",e[e.TAP_INTERNAL_KEY=5]="TAP_INTERNAL_KEY",e[e.TAP_TREE=6]="TAP_TREE",e[e.TAP_BIP32_DERIVATION=7]="TAP_BIP32_DERIVATION"}(Gr||(Gr={}));const jr=e=>33===e.length&&[2,3].includes(e[0])||65===e.length&&4===e[0];function Kr(e,t=jr){return{decode:function(r){if(r.key[0]!==e)throw new Error("Decode Error: could not decode bip32Derivation with key 0x"+$e(r.key));const n=r.key.slice(1);if(!t(n))throw new Error("Decode Error: bip32Derivation has invalid pubkey in key 0x"+$e(r.key));if(r.value.length/4%1!=0)throw new Error("Decode Error: Input BIP32_DERIVATION value length should be multiple of 4");const i={masterFingerprint:r.value.slice(0,4),pubkey:n,path:"m"};for(const e of(o=r.value.length/4-1,[...Array(o).keys()])){const t=Xe(r.value,4*e+4,"LE"),n=!!(2147483648&t),o=2147483647&t;i.path+="/"+o.toString(10)+(n?"'":"")}var o;return i},encode:function(t){const r=Ke([Uint8Array.from([e]),t.pubkey]),n=t.path.split("/"),i=new Uint8Array(4*n.length);i.set(t.masterFingerprint,0);let o=4;return n.slice(1).forEach(e=>{const t="'"===e.slice(-1);let r=2147483647&parseInt(t?e.slice(0,-1):e,10);t&&(r+=2147483648),Je(i,o,r,"LE"),o+=4}),{key:r,value:i}},check:function(e){return e.pubkey instanceof Uint8Array&&e.masterFingerprint instanceof Uint8Array&&"string"==typeof e.path&&t(e.pubkey)&&4===e.masterFingerprint.length},expected:"{ masterFingerprint: Uint8Array; pubkey: Uint8Array; path: string; }",canAddToArray:function(e,t,r){const n=$e(t.pubkey);return!r.has(n)&&(r.add(n),0===e.filter(e=>0===ze(e.pubkey,t.pubkey)).length)}}}function $r(e){return function(t){let r;if(e.includes(t.key[0])&&(r=t.key.slice(1),33!==r.length&&65!==r.length||![2,3,4].includes(r[0])))throw new Error("Format Error: invalid pubkey in key 0x"+$e(t.key));return r}}function Yr(e){return{decode:function(t){if(t.key[0]!==e)throw new Error("Decode Error: could not decode redeemScript with key 0x"+$e(t.key));return t.value},encode:function(t){return{key:Uint8Array.from([e]),value:t}},check:function(e){return e instanceof Uint8Array},expected:"Uint8Array",canAdd:function(e,t){return!!e&&!!t&&void 0===e.redeemScript}}}const zr=e=>32===e.length;function Wr(e){const t=Kr(e,zr);return{decode:function(e){const{numberValue:r,bytes:n}=Cr(e.value),i=t.decode({key:e.key,value:e.value.slice(n+32*Number(r))}),o=new Array(Number(r));for(let t=0,i=n;t<r;t++,i+=32)o[t]=e.value.slice(i,i+32);return{...i,leafHashes:o}},encode:function(e){const r=t.encode(e),n=Vr(e.leafHashes.length),i=new Uint8Array(n);Dr(e.leafHashes.length,i);const o=Ke([i,...e.leafHashes,r.value]);return{...r,value:o}},check:function(e){return Array.isArray(e.leafHashes)&&e.leafHashes.every(e=>e instanceof Uint8Array&&32===e.length)&&t.check(e)},expected:"{ masterFingerprint: Uint8Array; pubkey: Uint8Array; path: string; leafHashes: Uint8Array[]; }",canAddToArray:t.canAddToArray}}function Jr(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"+$e(t.key));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:Uint8Array.from([e]),value:t}},check:function(e){return e instanceof Uint8Array&&32===e.length},expected:"Uint8Array",canAdd:function(e,t){return!!e&&!!t&&void 0===e.tapInternalKey}}}function qr(e){return{decode:function(t){if(t.key[0]!==e)throw new Error("Decode Error: could not decode witnessScript with key 0x"+$e(t.key));return t.value},encode:function(t){return{key:Uint8Array.from([e]),value:t}},check:function(e){return e instanceof Uint8Array},expected:"Uint8Array",canAdd:function(e,t){return!!e&&!!t&&void 0===e.witnessScript}}}Kr(Hr.BIP32_DERIVATION),Yr(Hr.REDEEM_SCRIPT),qr(Hr.WITNESS_SCRIPT),$r([Hr.PARTIAL_SIG,Hr.BIP32_DERIVATION]),Wr(Hr.TAP_BIP32_DERIVATION),Jr(Hr.TAP_INTERNAL_KEY),Kr(Gr.BIP32_DERIVATION),Yr(Gr.REDEEM_SCRIPT),qr(Gr.WITNESS_SCRIPT),$r([Gr.BIP32_DERIVATION]),Wr(Gr.TAP_BIP32_DERIVATION),Jr(Gr.TAP_INTERNAL_KEY);var Xr,Qr={exports:{}};var Zr,en=(Xr||(Xr=1,Zr=Qr,function(){var e="input is invalid type",t="object"==typeof window,r=t?window:{};r.JS_SHA3_NO_WINDOW&&(t=!1);var n=!t&&"object"==typeof self;!r.JS_SHA3_NO_NODE_JS&&"object"==typeof y&&y.versions&&y.versions.node?r=g:n&&(r=self);var i=!r.JS_SHA3_NO_COMMON_JS&&Zr.exports,o=!r.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,s="0123456789abcdef".split(""),a=[4,1024,262144,67108864],c=[0,8,16,24],u=[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],l=["hex","buffer","arrayBuffer","array","digest"],d={128:168,256:136};!r.JS_SHA3_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!o||!r.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});for(var p=function(e,t,r){return function(n){return new U(e,t,e).update(n)[r]()}},E=function(e,t,r){return function(n,i){return new U(e,t,i).update(n)[r]()}},m=function(e,t,r){return function(t,n,i,o){return b["cshake"+e].update(t,n,i,o)[r]()}},_=function(e,t,r){return function(t,n,i,o){return b["kmac"+e].update(t,n,i,o)[r]()}},I=function(e,t,r,n){for(var i=0;i<l.length;++i){var o=l[i];e[o]=t(r,n,o)}return e},w=function(e,t){var r=p(e,t,"hex");return r.create=function(){return new U(e,t,e)},r.update=function(e){return r.create().update(e)},I(r,p,e,t)},P=[{name:"keccak",padding:[1,256,65536,16777216],bits:h,createMethod:w},{name:"sha3",padding:[6,1536,393216,100663296],bits:h,createMethod:w},{name:"shake",padding:[31,7936,2031616,520093696],bits:f,createMethod:function(e,t){var r=E(e,t,"hex");return r.create=function(r){return new U(e,t,r)},r.update=function(e,t){return r.create(t).update(e)},I(r,E,e,t)}},{name:"cshake",padding:a,bits:f,createMethod:function(e,t){var r=d[e],n=m(e,0,"hex");return n.create=function(n,i,o){return i||o?new U(e,t,n).bytepad([i,o],r):b["shake"+e].create(n)},n.update=function(e,t,r,i){return n.create(t,r,i).update(e)},I(n,m,e,t)}},{name:"kmac",padding:a,bits:f,createMethod:function(e,t){var r=d[e],n=_(e,0,"hex");return n.create=function(n,i,o){return new k(e,t,i).bytepad(["KMAC",o],r).bytepad([n],r)},n.update=function(e,t,r,i){return n.create(e,r,i).update(t)},I(n,_,e,t)}}],b={},A=[],O=0;O<P.length;++O)for(var T=P[O],R=T.bits,S=0;S<R.length;++S){var v=T.name+"_"+R[S];if(A.push(v),b[v]=T.createMethod(R[S],T.padding),"sha3"!==T.name){var N=T.name+R[S];A.push(N),b[N]=b[v]}}function U(e,t,r){this.blocks=[],this.s=[],this.padding=t,this.outputBits=r,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(e<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}function k(e,t,r){U.call(this,e,t,r)}U.prototype.update=function(t){if(this.finalized)throw new Error("finalize already called");var r,n=typeof t;if("string"!==n){if("object"!==n)throw new Error(e);if(null===t)throw new Error(e);if(o&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||o&&ArrayBuffer.isView(t)))throw new Error(e);r=!0}for(var i,s,a=this.blocks,u=this.byteCount,h=t.length,f=this.blockCount,l=0,d=this.s;l<h;){if(this.reset)for(this.reset=!1,a[0]=this.block,i=1;i<f+1;++i)a[i]=0;if(r)for(i=this.start;l<h&&i<u;++l)a[i>>2]|=t[l]<<c[3&i++];else for(i=this.start;l<h&&i<u;++l)(s=t.charCodeAt(l))<128?a[i>>2]|=s<<c[3&i++]:s<2048?(a[i>>2]|=(192|s>>6)<<c[3&i++],a[i>>2]|=(128|63&s)<<c[3&i++]):s<55296||s>=57344?(a[i>>2]|=(224|s>>12)<<c[3&i++],a[i>>2]|=(128|s>>6&63)<<c[3&i++],a[i>>2]|=(128|63&s)<<c[3&i++]):(s=65536+((1023&s)<<10|1023&t.charCodeAt(++l)),a[i>>2]|=(240|s>>18)<<c[3&i++],a[i>>2]|=(128|s>>12&63)<<c[3&i++],a[i>>2]|=(128|s>>6&63)<<c[3&i++],a[i>>2]|=(128|63&s)<<c[3&i++]);if(this.lastByteIndex=i,i>=u){for(this.start=i-u,this.block=a[f],i=0;i<f;++i)d[i]^=a[i];M(d),this.reset=!0}else this.start=i}return this},U.prototype.encode=function(e,t){var r=255&e,n=1,i=[r];for(r=255&(e>>=8);r>0;)i.unshift(r),r=255&(e>>=8),++n;return t?i.push(n):i.unshift(n),this.update(i),i.length},U.prototype.encodeString=function(t){var r,n=typeof t;if("string"!==n){if("object"!==n)throw new Error(e);if(null===t)throw new Error(e);if(o&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||o&&ArrayBuffer.isView(t)))throw new Error(e);r=!0}var i=0,s=t.length;if(r)i=s;else for(var a=0;a<t.length;++a){var c=t.charCodeAt(a);c<128?i+=1:c<2048?i+=2:c<55296||c>=57344?i+=3:(c=65536+((1023&c)<<10|1023&t.charCodeAt(++a)),i+=4)}return i+=this.encode(8*i),this.update(t),i},U.prototype.bytepad=function(e,t){for(var r=this.encode(t),n=0;n<e.length;++n)r+=this.encodeString(e[n]);var i=t-r%t,o=[];return o.length=i,this.update(o),this},U.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex,r=this.blockCount,n=this.s;if(e[t>>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t<r+1;++t)e[t]=0;for(e[r-1]|=2147483648,t=0;t<r;++t)n[t]^=e[t];M(n)}},U.prototype.toString=U.prototype.hex=function(){this.finalize();for(var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,a=0,c="";a<n;){for(o=0;o<t&&a<n;++o,++a)e=r[o],c+=s[e>>4&15]+s[15&e]+s[e>>12&15]+s[e>>8&15]+s[e>>20&15]+s[e>>16&15]+s[e>>28&15]+s[e>>24&15];a%t===0&&(M(r),o=0)}return i&&(e=r[o],c+=s[e>>4&15]+s[15&e],i>1&&(c+=s[e>>12&15]+s[e>>8&15]),i>2&&(c+=s[e>>20&15]+s[e>>16&15])),c},U.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,s=0,a=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(a);for(var c=new Uint32Array(e);s<n;){for(o=0;o<t&&s<n;++o,++s)c[s]=r[o];s%t===0&&M(r)}return i&&(c[o]=r[o],e=e.slice(0,a)),e},U.prototype.buffer=U.prototype.arrayBuffer,U.prototype.digest=U.prototype.array=function(){this.finalize();for(var e,t,r=this.blockCount,n=this.s,i=this.outputBlocks,o=this.extraBytes,s=0,a=0,c=[];a<i;){for(s=0;s<r&&a<i;++s,++a)e=a<<2,t=n[s],c[e]=255&t,c[e+1]=t>>8&255,c[e+2]=t>>16&255,c[e+3]=t>>24&255;a%r===0&&M(n)}return o&&(e=a<<2,t=n[s],c[e]=255&t,o>1&&(c[e+1]=t>>8&255),o>2&&(c[e+2]=t>>16&255)),c},k.prototype=new U,k.prototype.finalize=function(){return this.encode(this.outputBits,!0),U.prototype.finalize.call(this)};var M=function(e){var t,r,n,i,o,s,a,c,h,f,l,d,p,y,g,E,m,_,I,w,P,b,A,O,T,R,S,v,N,U,k,M,L,B,x,D,C,V,F,H,G,j,K,$,Y,z,W,J,q,X,Q,Z,ee,te,re,ne,ie,oe,se,ae,ce,ue,he;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],s=e[2]^e[12]^e[22]^e[32]^e[42],a=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],h=e[5]^e[15]^e[25]^e[35]^e[45],f=e[6]^e[16]^e[26]^e[36]^e[46],l=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|a>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(a<<1|s>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(c<<1|h>>>31),r=o^(h<<1|c>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=s^(f<<1|l>>>31),r=a^(l<<1|f>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=c^(d<<1|p>>>31),r=h^(p<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=f^(i<<1|o>>>31),r=l^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,y=e[0],g=e[1],z=e[11]<<4|e[10]>>>28,W=e[10]<<4|e[11]>>>28,v=e[20]<<3|e[21]>>>29,N=e[21]<<3|e[20]>>>29,ae=e[31]<<9|e[30]>>>23,ce=e[30]<<9|e[31]>>>23,j=e[40]<<18|e[41]>>>14,K=e[41]<<18|e[40]>>>14,B=e[2]<<1|e[3]>>>31,x=e[3]<<1|e[2]>>>31,E=e[13]<<12|e[12]>>>20,m=e[12]<<12|e[13]>>>20,J=e[22]<<10|e[23]>>>22,q=e[23]<<10|e[22]>>>22,U=e[33]<<13|e[32]>>>19,k=e[32]<<13|e[33]>>>19,ue=e[42]<<2|e[43]>>>30,he=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,D=e[14]<<6|e[15]>>>26,C=e[15]<<6|e[14]>>>26,_=e[25]<<11|e[24]>>>21,I=e[24]<<11|e[25]>>>21,X=e[34]<<15|e[35]>>>17,Q=e[35]<<15|e[34]>>>17,M=e[45]<<29|e[44]>>>3,L=e[44]<<29|e[45]>>>3,O=e[6]<<28|e[7]>>>4,T=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,V=e[26]<<25|e[27]>>>7,F=e[27]<<25|e[26]>>>7,w=e[36]<<21|e[37]>>>11,P=e[37]<<21|e[36]>>>11,Z=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,$=e[8]<<27|e[9]>>>5,Y=e[9]<<27|e[8]>>>5,R=e[18]<<20|e[19]>>>12,S=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,se=e[28]<<7|e[29]>>>25,H=e[38]<<8|e[39]>>>24,G=e[39]<<8|e[38]>>>24,b=e[48]<<14|e[49]>>>18,A=e[49]<<14|e[48]>>>18,e[0]=y^~E&_,e[1]=g^~m&I,e[10]=O^~R&v,e[11]=T^~S&N,e[20]=B^~D&V,e[21]=x^~C&F,e[30]=$^~z&J,e[31]=Y^~W&q,e[40]=te^~ne&oe,e[41]=re^~ie&se,e[2]=E^~_&w,e[3]=m^~I&P,e[12]=R^~v&U,e[13]=S^~N&k,e[22]=D^~V&H,e[23]=C^~F&G,e[32]=z^~J&X,e[33]=W^~q&Q,e[42]=ne^~oe&ae,e[43]=ie^~se&ce,e[4]=_^~w&b,e[5]=I^~P&A,e[14]=v^~U&M,e[15]=N^~k&L,e[24]=V^~H&j,e[25]=F^~G&K,e[34]=J^~X&Z,e[35]=q^~Q&ee,e[44]=oe^~ae&ue,e[45]=se^~ce&he,e[6]=w^~b&y,e[7]=P^~A&g,e[16]=U^~M&O,e[17]=k^~L&T,e[26]=H^~j&B,e[27]=G^~K&x,e[36]=X^~Z&$,e[37]=Q^~ee&Y,e[46]=ae^~ue&te,e[47]=ce^~he&re,e[8]=b^~y&E,e[9]=A^~g&m,e[18]=M^~O&R,e[19]=L^~T&S,e[28]=j^~B&D,e[29]=K^~x&C,e[38]=Z^~$&z,e[39]=ee^~Y&W,e[48]=ue^~te&ne,e[49]=he^~re&ie,e[0]^=u[n],e[1]^=u[n+1]};if(i)Zr.exports=b;else for(O=0;O<A.length;++O)r[A[O]]=b[A[O]]}()),Qr.exports),tn=h(en);let rn=!1,nn=!1;const on={debug:1,default:2,info:2,warning:3,error:4,off:5};let sn=on.default,an=null;const cn=function(){try{const e=[];if(["NFD","NFC","NFKD","NFKC"].forEach(t=>{try{if("test"!=="test".normalize(t))throw new Error("bad normalize")}catch(r){e.push(t)}}),e.length)throw new Error("missing "+e.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(e){return e.message}return null}();var un,hn;!function(e){e.DEBUG="DEBUG",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR",e.OFF="OFF"}(un||(un={})),function(e){e.UNKNOWN_ERROR="UNKNOWN_ERROR",e.NOT_IMPLEMENTED="NOT_IMPLEMENTED",e.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",e.NETWORK_ERROR="NETWORK_ERROR",e.SERVER_ERROR="SERVER_ERROR",e.TIMEOUT="TIMEOUT",e.BUFFER_OVERRUN="BUFFER_OVERRUN",e.NUMERIC_FAULT="NUMERIC_FAULT",e.MISSING_NEW="MISSING_NEW",e.INVALID_ARGUMENT="INVALID_ARGUMENT",e.MISSING_ARGUMENT="MISSING_ARGUMENT",e.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",e.CALL_EXCEPTION="CALL_EXCEPTION",e.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",e.NONCE_EXPIRED="NONCE_EXPIRED",e.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",e.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",e.TRANSACTION_REPLACED="TRANSACTION_REPLACED",e.ACTION_REJECTED="ACTION_REJECTED"}(hn||(hn={}));const fn="0123456789abcdef";class ln{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){const r=e.toLowerCase();null==on[r]&&this.throwArgumentError("invalid log level name","logLevel",e),sn>on[r]||console.log.apply(console,t)}debug(...e){this._log(ln.levels.DEBUG,e)}info(...e){this._log(ln.levels.INFO,e)}warn(...e){this._log(ln.levels.WARNING,e)}makeError(e,t,r){if(nn)return this.makeError("censored error",t,{});t||(t=ln.errors.UNKNOWN_ERROR),r||(r={});const n=[];Object.keys(r).forEach(e=>{const t=r[e];try{if(t instanceof Uint8Array){let r="";for(let e=0;e<t.length;e++)r+=fn[t[e]>>4],r+=fn[15&t[e]];n.push(e+"=Uint8Array(0x"+r+")")}else n.push(e+"="+JSON.stringify(t))}catch(t){n.push(e+"="+JSON.stringify(r[e].toString()))}}),n.push(`code=${t}`),n.push(`version=${this.version}`);const i=e;let o="";switch(t){case hn.NUMERIC_FAULT:{o="NUMERIC_FAULT";const t=e;switch(t){case"overflow":case"underflow":case"division-by-zero":o+="-"+t;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result"}break}case hn.CALL_EXCEPTION:case hn.INSUFFICIENT_FUNDS:case hn.MISSING_NEW:case hn.NONCE_EXPIRED:case hn.REPLACEMENT_UNDERPRICED:case hn.TRANSACTION_REPLACED:case hn.UNPREDICTABLE_GAS_LIMIT:o=t}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),n.length&&(e+=" ("+n.join(", ")+")");const s=new Error(e);return s.reason=i,s.code=t,Object.keys(r).forEach(function(e){s[e]=r[e]}),s}throwError(e,t,r){throw this.makeError(e,t,r)}throwArgumentError(e,t,r){return this.throwError(e,ln.errors.INVALID_ARGUMENT,{argument:t,value:r})}assert(e,t,r,n){e||this.throwError(t,r,n)}assertArgument(e,t,r,n){e||this.throwArgumentError(t,r,n)}checkNormalize(e){cn&&this.throwError("platform missing String.prototype.normalize",ln.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:cn})}checkSafeUint53(e,t){"number"==typeof e&&(null==t&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,ln.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,ln.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,r){r=r?": "+r:"",e<t&&this.throwError("missing argument"+r,ln.errors.MISSING_ARGUMENT,{count:e,expectedCount:t}),e>t&&this.throwError("too many arguments"+r,ln.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){e!==Object&&null!=e||this.throwError("missing new",ln.errors.MISSING_NEW,{name:t.name})}checkAbstract(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",ln.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):e!==Object&&null!=e||this.throwError("missing new",ln.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return an||(an=new ln("logger/5.8.0")),an}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",ln.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),rn){if(!e)return;this.globalLogger().throwError("error censorship permanent",ln.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}nn=!!e,rn=!!t}static setLogLevel(e){const t=on[e.toLowerCase()];null!=t?sn=t:ln.globalLogger().warn("invalid log level - "+e)}static from(e){return new ln(e)}}ln.errors=hn,ln.levels=un;const dn=new ln("bytes/5.8.0");function pn(e){return e.slice||(e.slice=function(){const t=Array.prototype.slice.call(arguments);return pn(new Uint8Array(Array.prototype.slice.apply(e,t)))}),e}function yn(e){return"number"==typeof e&&e==e&&e%1==0}function gn(e,t){if(t||(t={}),"number"==typeof e){dn.checkSafeUint53(e,"invalid arrayify value");const t=[];for(;e;)t.unshift(255&e),e=parseInt(String(e/256));return 0===t.length&&t.push(0),pn(new Uint8Array(t))}if(t.allowMissingPrefix&&"string"==typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),function(e){return!!e.toHexString}(e)&&(e=e.toHexString()),function(e){if("string"!=typeof e||!e.match(/^0x[0-9A-Fa-f]*$/))return!1;return!0}(e)){let r=e.substring(2);r.length%2&&("left"===t.hexPad?r="0"+r:"right"===t.hexPad?r+="0":dn.throwArgumentError("hex data is odd-length","value",e));const n=[];for(let e=0;e<r.length;e+=2)n.push(parseInt(r.substring(e,e+2),16));return pn(new Uint8Array(n))}return function(e){if(null==e)return!1;if(e.constructor===Uint8Array)return!0;if("string"==typeof e)return!1;if(!yn(e.length)||e.length<0)return!1;for(let t=0;t<e.length;t++){const r=e[t];if(!yn(r)||r<0||r>=256)return!1}return!0}(e)?pn(new Uint8Array(e)):dn.throwArgumentError("invalid arrayify value","value",e)}function En(e,t){const r=a,n=e.toString("hex"),i=r.from(l.fromHex(n).toBytes(!1)).toString("hex").slice(2);var o;return`0x${(o=r.from(i,"hex"),"0x"+tn.keccak_256(gn(o))).slice(26).toString()}`}async function mn(e,t){let r;"publicKeyJwk"in e?r=Be(e.publicKeyJwk):void 0!==e.publicKeyMultibase&&(r=await(async({publicKeyMultibase:e})=>{const t=await P({keyPair:{publicKeyMultibase:e}});return Be(t)})(e));const n=Te("errors","identityErrorBaseMessage");let i="";switch(t.code){case u.Bitcoin:case u.Mocknet:case u.Testnet:i=function(e,t){return kr({pubkey:e,network:Ce[t.code]}).address}(r,t);break;case u.Ethmain:case u.Ethropst:case u.Ethrinkeby:case u.Ethgoerli:case u.Ethsepolia:i=En(r);break;default:throw new be("deriveIssuingAddressFromPublicKey",`${n} - ${Te("errors","deriveIssuingAddressFromPublicKey")}`,ye.MALFORMED_VALUE_ERROR)}return i}function _n(e){if(e){const t="string"==typeof e?e:e.code;return!!Object.keys(s).some(e=>e===t)&&!!s[t].test}return!1}const{LinkedDataProof:In}=m.suites;class wn extends In{challenge;domain;type="MerkleProof2019";issuer=null;issuerEndpoint="";verificationMethod=null;externalProof=null;proof=null;proofValue=null;proofPurpose;document=null;explorerAPIs=[];chain;txData;localDocumentHash;derivedIssuingAddress;documentLoader=null;proofVerificationProcess=["assertProofValidity","getTransactionId","computeLocalHash","fetchRemoteHash","compareHashes","checkMerkleRoot","checkReceipt"];identityVerificationProcess=["deriveIssuingAddressFromPublicKey","ensureVerificationMethodValidity","compareIssuingAddress"];transactionId="";constructor({issuer:e=null,verificationMethod:t=null,document:r=null,proof:n=null,options:i={},proofPurpose:o="assertionMethod",domain:s=[],challenge:a=""}){super({type:"MerkleProof2019"}),this.issuer=e,this.verificationMethod=t,this.document=r,this.proofPurpose=o,this.domain=Array.isArray(s)?s:[s],this.challenge=a,this.externalProof=n,this.setOptions(i),(this.externalProof||this.document)&&(this.setProof(this.externalProof),this.getChain(),_n(this.chain)&&(this.adaptProofVerificationProcessToMocknet(),this.adaptIdentityVerificationProcessToMocknet()))}static decodeMerkleProof2019(e){return new _e(e.proofValue).decode()}createVerifier(){}createVerifyData(){}setProof(e=null){const t=e??this.document.proof;if(!t)throw new Error("The passed document is not signed.");this.proof=t,this.proofValue=wn.decodeMerkleProof2019(this.proof)}async verifyProof({documentLoader:e,verifyIdentity:t,document:r,proof:n}={documentLoader:e=>{},verifyIdentity:!0}){let i;this.documentLoader=e;let o="";if(r&&(this.document=r),n&&this.setProof(n),this.getChain(),_n(this.chain)&&(this.adaptProofVerificationProcessToMocknet(),this.adaptIdentityVerificationProcessToMocknet()),!this.document)throw new Error("A document signed by MerkleProof2019 is required for the verification process.");try{await this.verifyProcess(this.proofVerificationProcess),t&&await this.verifyIdentity(),i=!0}catch(e){console.error(e),i=!1,o=e.message}return{verificationMethod:this.verificationMethod,verified:i,error:o}}async createProof({document:e,purpose:t="assertionMethod"}){if(!this.issuerEndpoint)throw new Error("No issuer endpoint provided. Please set the issuerEndpoint option when instantiating the suite.");const r=await fetch(this.issuerEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({credential:e})}).then(e=>e.json()).catch(e=>{console.error(e)});if(r.verifiableCredential)return r.verifiableCredential.proof;console.error("An error occurred while creating the proof:",r)}async createProofValue({document:e}){const t=await this.createProof({document:e});return t?t.proofValue:"error creating proof"}ensureSuiteContext(){}async verifyIdentity(){if(null!=this.verificationMethod)try{await this.verifyProcess(this.identityVerificationProcess)}catch(e){throw new Error(e)}}getProofVerificationProcess(){return this.proofVerificationProcess}getIdentityVerificationProcess(){return this.identityVerificationProcess}getIssuerPublicKey(){return _n(this.chain)?"This mock chain does not support issuing addresses":this.getTxData()?.issuingAddress??""}getIssuanceTime(){return this.getTxData()?.time??""}getChain(){return this.chain||(this.chain=we(this.proofValue)),this.chain}getTxData(){return this.txData?this.txData:(console.error("Trying to access issuing address when txData not available yet. Did you run the `verify` method yet?"),null)}adaptProofVerificationProcessToMocknet(){Pe(this.proofVerificationProcess,"getTransactionId"),Pe(this.proofVerificationProcess,"fetchRemoteHash"),Pe(this.proofVerificationProcess,"checkMerkleRoot")}adaptIdentityVerificationProcessToMocknet(){this.identityVerificationProcess=["ensureVerificationMethodValidity"]}setOptions(e){this.explorerAPIs=e.explorerAPIs??[],e.executeStepMethod&&"function"==typeof e.executeStepMethod&&(this.executeStep=e.executeStepMethod),this.issuerEndpoint=e.issuerEndpoint??""}async executeStep(e,t,r=""){return await t()}async verifyProcess(e){for(const t of e){if(!this[t])return void console.error("verification logic for",t,"not implemented");await this[t]()}}async assertProofValidity(){await this.executeStep("assertProofValidity",()=>Re({expectedProofPurpose:this.proofPurpose,expectedDomain:this.domain,expectedChallenge:this.challenge,proof:this.proof,issuer:this.issuer}),this.type)}async checkMerkleRoot(){await this.executeStep("checkMerkleRoot",()=>function(e,t){if(e!==t)throw new be("checkMerkleRoot",Te("errors","ensureMerkleRootEqual"),ye.CRYPTOGRAPHIC_SECURITY_ERROR);return!0}(this.proofValue.merkleRoot,this.txData.remoteHash),this.type)}async compareHashes(){await this.executeStep("compareHashes",()=>function(e,t){if(e!==t)throw new be("compareHashes",Te("errors","ensureHashesEqual"),ye.CRYPTOGRAPHIC_SECURITY_ERROR);return!0}(this.localDocumentHash,this.proofValue.targetHash),this.type)}async computeLocalHash(){this.localDocumentHash=await this.executeStep("computeLocalHash",async()=>await Me(this.document,this.proof,this.documentLoader),this.type)}async checkReceipt(){await this.executeStep("checkReceipt",()=>{!function(e){let t=e.targetHash;const r=e.merkleRoot;try{const r=e.path;if(r&&t)for(const e in r){const n=r[e];let i;if(void 0!==n.left)i=ke(`${n.left}${t}`),t=a.from(w(Uint8Array.from(i))).toString("hex");else{if(void 0===n.right)throw new be("checkReceipt","Trigger catch error.");i=ke(`${t}${n.right}`),t=a.from(w(Uint8Array.from(i))).toString("hex")}}}catch(e){throw new be("checkReceipt",Te("errors","ensureValidReceipt"),ye.CRYPTOGRAPHIC_SECURITY_ERROR)}if(t!==r)throw new be("checkReceipt",Te("errors","invalidMerkleReceipt"),ye.CRYPTOGRAPHIC_SECURITY_ERROR)}(this.proofValue)},this.type)}async getTransactionId(){this.transactionId=function(e=null){if(!e)throw new Error("DecodedProof is not set");const{anchors:t}=e,r=t[0];if("string"==typeof r)return r.split(":").pop();throw new Error("Could not retrieve transaction id as was provided an unexpected format")}(this.proofValue);return await this.executeStep("getTransactionId",()=>function(e){if("string"==typeof e&&e.length>0)return e;throw new be("getTransactionId",Te("errors","isTransactionIdValid"),ye.MALFORMED_VALUE_ERROR)}(this.transactionId),this.type)}async fetchRemoteHash(){this.txData=await this.executeStep("fetchRemoteHash",async()=>await o({transactionId:this.transactionId,chain:this.chain?.code,explorerAPIs:this.explorerAPIs}),this.type)}async deriveIssuingAddressFromPublicKey(){this.derivedIssuingAddress=await this.executeStep("deriveIssuingAddressFromPublicKey",async()=>await mn(this.verificationMethod,this.chain),this.type)}async ensureVerificationMethodValidity(){await this.executeStep("ensureVerificationMethodValidity",async()=>{if(this.verificationMethod.expires){if(new Date(this.verificationMethod.expires).getTime()<Date.now())throw new be("ensureVerificationMethodValidity","The verification key has expired",ye.CRYPTOGRAPHIC_SECURITY_ERROR)}if(this.verificationMethod.revoked)throw new be("ensureVerificationMethodValidity","The verification key has been revoked",ye.CRYPTOGRAPHIC_SECURITY_ERROR)},this.type)}async compareIssuingAddress(){await this.executeStep("compareIssuingAddress",()=>{!function(e,t){const r=Te("errors","identityErrorBaseMessage");if(e.toLowerCase()!==t.toLowerCase())throw new be("compareIssuingAddress",`${r} - ${Te("errors","compareIssuingAddress")}`,ye.CRYPTOGRAPHIC_SECURITY_ERROR)}(this.getIssuerPublicKey(),this.derivedIssuingAddress)},this.type)}}var Pn;function bn(e){return wn.decodeMerkleProof2019(e)}!function(e){e.getTransactionId="getTransactionId",e.computeLocalHash="computeLocalHash",e.fetchRemoteHash="fetchRemoteHash",e.parseIssuerKeys="parseIssuerKeys",e.compareHashes="compareHashes",e.checkImagesIntegrity="checkImagesIntegrity",e.checkMerkleRoot="checkMerkleRoot",e.checkReceipt="checkReceipt",e.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",e.ensureVerificationMethodValidity="ensureVerificationMethodValidity",e.deriveIssuingAddressFromPublicKey="deriveIssuingAddressFromPublicKey",e.compareIssuingAddress="compareIssuingAddress",e.checkAuthenticity="checkAuthenticity"}(Pn||(Pn={}));class An extends O{proofVerificationProcess=[Pn.parseIssuerKeys,Pn.checkAuthenticity];transactionId;localHash;documentToVerify;txData;chain;explorerAPIs;receipt;issuerPublicKeyList;issuer;verificationMethod;derivedIssuingAddress;hasDid;proof;type="MerkleProof2019";cryptosuite="merkle-proof-2019";suite;proofPurpose;proofDomain;proofChallenge;constructor(e){super(e),this.executeStep=e.executeStep,this.documentToVerify=e.document,this.explorerAPIs=e.explorerAPIs,this.proof=e.proof,this.issuer=e.issuer,this.proofPurpose=e.proofPurpose,this.proofDomain=e.proofDomain,this.proofChallenge=e.proofChallenge,this.validateProofType(),this.receipt=bn(this.proof),this.transactionId=t.certificates.getTransactionId(this.receipt),this.setHasDid()}async init(){await this.setVerificationSuite(),this.chain=this.suite.getChain(),this.adaptVerificationProcessToChain()}async verifyProof(){await this.suite.verifyProof({verifyIdentity:!1}),await this.verifyProcess(this.proofVerificationProcess)}async verifyIdentity(){await this.suite.verifyIdentity()}getProofVerificationSteps(e){return[...this.suite.getProofVerificationProcess(),...this.proofVerificationProcess].map(r=>t.verifier.convertToVerificationSubsteps(e,r))}getIdentityVerificationSteps(e){return this.hasDid?this.suite.getIdentityVerificationProcess().map(r=>t.verifier.convertToVerificationSubsteps(e,r)):[]}getIssuerPublicKey(){return this.suite.getIssuerPublicKey()}getIssuanceTime(){return this.suite.getIssuanceTime()}getIssuerName(){return this.issuer.name}getIssuerProfileDomain(){const e=new URL(this.getIssuerProfileUrl());return e?.hostname}getIssuerProfileUrl(){return this.issuer.id}getSigningDate(){return this.proof.created}getChain(){return this.suite.getChain()}getReceipt(){return this.receipt}getTransactionIdString(){return t.certificates.getTransactionId(this.getReceipt())}getTransactionLink(){return t.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).transactionLink}getRawTransactionLink(){return t.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).rawTransactionLink}async executeStep(e,t,r){throw new Error("executeStep method needs to be overwritten by injecting from Verifier")}async setVerificationSuite(){await this.setIssuerFromProofVerificationMethod(),this.verificationMethod=A(this.getTargetVerificationMethodContainer(),r(this.proof)),this.suite=new wn({document:this.documentToVerify,proof:this.proof,verificationMethod:this.verificationMethod,proofPurpose:this.proofPurpose,domain:this.proofDomain,challenge:this.proofChallenge,options:{explorerAPIs:this.explorerAPIs,executeStepMethod:this.executeStep}})}adaptVerificationProcessToChain(){t.chains.isMockChain(this.chain)&&(n(this.proofVerificationProcess,Pn.parseIssuerKeys),n(this.proofVerificationProcess,Pn.checkAuthenticity))}getTargetVerificationMethodContainer(){if(this.issuer.didDocument)return this.issuer.didDocument;const e={...this.issuer};return delete e.didDocument,e}findVerificationMethod(e,t){return e?.find(e=>e.id===this.proof.verificationMethod||t+e.id===this.proof.verificationMethod)??null}isProofChain(){return"ChainedProof2021"===this.proof.type}isMultipleProof(){return Array.isArray(this.documentToVerify.proof)}getProofIndex(){return this.isMultipleProof()?this.documentToVerify.proof.findIndex(e=>e.proofValue===this.proof.proofValue):-1}async setIssuerFromProofVerificationMethod(){if(this.getProofIndex()>0){const e=this.proof.verificationMethod.split("#")[0];this.issuer=await t.verifier.getIssuerProfile(e)}}setHasDid(){if(this.getProofIndex()>0){const e=this.proof.verificationMethod.split("#")[0];return void(this.hasDid=i(e))}this.hasDid=!!this.issuer.didDocument}validateProofType(){const e=this.isProofChain()?this.proof.chainedProofType:this.proof.type;if("DataIntegrityProof"===e){const e=this.proof.cryptosuite;if(!e)throw new Error(`Malformed proof passed. With DataIntegrityProof a cryptosuite must be defined. Expected: ${this.cryptosuite}`);if(e!==this.cryptosuite)throw new Error(`Incompatible proof cryptosuite passed. Expected: ${this.cryptosuite}, Got: ${e}`);return}if(e!==this.type)throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${e}`)}async verifyProcess(e){for(const t of e){if(!this[t])return void console.error("verification logic for",t,"not implemented");await this[t]()}}async parseIssuerKeys(){this.issuerPublicKeyList=await this.executeStep(Pn.parseIssuerKeys,()=>t.verifier.parseIssuerKeys(this.issuer),this.type)}async checkAuthenticity(){await this.executeStep(Pn.checkAuthenticity,()=>{I(this.issuerPublicKeyList,this.getIssuerPublicKey(),this.getIssuanceTime())},this.type)}}export{An as default,bn as parseReceipt};
@@ -0,0 +1 @@
1
+ import{V as t,z as e,d as n,P as o,C as a,A as r,D as i,F as c}from"./main.js";const s=131072;function u(t){const e=t?.credentialSubject?.ttl;return"number"==typeof e?e:void 0}function R(t){return/^https?:\/\//i.test(t)}function d(a){if("undefined"==typeof process||!process.versions?.node)throw new t(e.checkRevokedStatus,`${n.i18n.getText("revocation","filesystemCacheUnsupported")} ${a}.`,o.STATUS_RETRIEVAL_ERROR)}function f(t){if(!R(t))return t;try{const e=new URL(t);return`${e.origin}${e.pathname}`}catch(e){return t}}function w(a,r){if(!a||"object"!=typeof a||!a.credential||"number"!=typeof a.cachedAt)throw new t(e.checkRevokedStatus,`${n.i18n.getText("revocation","invalidStatusListCacheResponse")} ${f(r)}.`,o.STATUS_RETRIEVAL_ERROR);return a}function h(t,e){const n=new URL(t);return n.searchParams.set("url",e),n.toString()}async function l(a){d(a);const{readFile:r}=await import("fs/promises");let i;try{i=await r(a,"utf-8")}catch(t){if("ENOENT"===t?.code)return{};throw t}try{return JSON.parse(i)}catch(r){throw console.error(r),new t(e.checkRevokedStatus,`${n.i18n.getText("revocation","invalidStatusListCacheResponse")} ${a}.`,o.STATUS_RETRIEVAL_ERROR)}}async function S(a,i){return R(a)?await async function(a,i){let c,s;try{c=await r({url:h(a,i)})}catch(t){return void console.error(t)}if(c){try{s=JSON.parse(c)}catch(r){throw console.error(r),new t(e.checkRevokedStatus,`${n.i18n.getText("revocation","invalidStatusListCacheResponse")} ${f(a)}.`,o.STATUS_RETRIEVAL_ERROR)}return w(s,a)}}(a,i):await async function(e,n){let o;try{o=await l(e)}catch(e){if(e instanceof t)throw e;return void console.error(e)}const a=o[n];if(void 0!==a)return w(a,e)}(a,i)}async function v(e,n,o){R(e)?await async function(t,e,n){try{await r({url:t,method:"POST",body:JSON.stringify({url:e,credential:n,cachedAt:Date.now()})})}catch(t){console.error(t)}}(e,n,o):await async function(e,n,o){d(e);try{const{mkdir:a,writeFile:r}=await import("fs/promises"),{dirname:i}=await import("./_polyfill-node.path-hKwMKLNw-B7aPtphV.js"),c=await l(e).catch(e=>{if(e instanceof t)throw e;return{}});c[n]={credential:o,cachedAt:Date.now()},await a(i(e),{recursive:!0}),await r(e,JSON.stringify(c),"utf-8")}catch(e){if(e instanceof t)throw e;console.error(e)}}(e,n,o)}async function y(a,i){if(i){const t=await S(i,a);if(t&&function(t){const e=u(t.credential);return"number"==typeof e&&Date.now()-t.cachedAt<e}(t))return t.credential}const c=await r({url:a}).catch(r=>{throw console.error(r),new t(e.checkRevokedStatus,`${n.i18n.getText("revocation","noRevocationStatusList2021Found")} ${a}.`,o.STATUS_RETRIEVAL_ERROR)});if(c){let r;try{r=JSON.parse(c)}catch(r){throw console.error(r),new t(e.checkRevokedStatus,`${n.i18n.getText("revocation","noRevocationStatusList2021Found")} ${a}.`,o.STATUS_RETRIEVAL_ERROR)}return i&&"number"==typeof u(r)&&await v(i,a,r),r}return c}async function T(t,e){let n;({decodeList:n}="BitstringStatusList"===t?await import("./index-BNsIYV4r-BnYxKy2f.js"):await import("./index-CVS5Gn9h-DNgvq6Wk.js"));const o=await n({encodedList:e});return{length:o.length,isSet:t=>o.bitstring.get(t)}}async function p(a){const r=new i(a);await r.init();if((await r.verify()).status===c.FAILURE)throw new t(e.checkRevokedStatus,n.i18n.getText("revocation","revocationListAuthenticityFailure"),o.STATUS_VERIFICATION_ERROR)}async function E(r,i={}){const{statusListCredentialCacheUrl:c}=i;c&&!R(c)&&await async function(t){let e;d(t);try{e=await l(t)}catch(t){return void console.error(t)}let n=!1;const o={};for(const[t,a]of Object.entries(e)){const e=!!a&&"number"==typeof a.cachedAt&&!!a.credential,r=e?u(a.credential):void 0;!e||"number"!=typeof r||Date.now()-a.cachedAt<r?o[t]=a:n=!0}if(n)try{const{writeFile:e}=await import("fs/promises");await e(t,JSON.stringify(o),"utf-8")}catch(t){console.error(t)}}(c),Array.isArray(r)||(r=[r]),r=[...r].sort((t,e)=>"revocation"===t.statusPurpose?-1:"revocation"===e.statusPurpose?1:0);for(const c of r){const r=parseInt(c.statusListIndex,10),u=await y(c.statusListCredential,i.statusListCredentialCacheUrl);if(!u)throw new t(e.checkRevokedStatus,`${n.i18n.getText("revocation","noRevocationStatusList2021Found")} ${c.statusListCredential}.`,o.STATUS_RETRIEVAL_ERROR);await p(u);const{encodedList:R}=u.credentialSubject,d=await T(u.credentialSubject.type,R);if(d.length<s)throw new t(e.checkRevokedStatus,`${n.i18n.getText("revocation","statusListLengthError")} (${d.length} < 131072).`,o.STATUS_LIST_LENGTH_ERROR);let f;try{if(!Number.isInteger(r)||r<0)throw new Error(`statusListIndex "${c.statusListIndex}" is not a valid non-negative integer.`);f=d.isSet(r)}catch(a){throw new t(e.checkRevokedStatus,`${n.i18n.getText("revocation","statusListIndexOutOfRange")} (${a.message})`,o.RANGE_ERROR)}if(f){const o="revocation"===c.statusPurpose?a.REVOKED:a.SUSPENDED;throw new t(e.checkRevokedStatus,n.certificates.generateRevocationReason("",o))}}}export{E as default};
@@ -0,0 +1 @@
1
+ import{s as r}from"./index-uKBVup0_-Dh4-8Ruv.js";import{A as a,V as o,z as e,P as t,g as s}from"./main.js";async function c(c,i){Array.isArray(i)||(i=[i]),Array.isArray(c)||(c=[c]);for(const n of i){const i=await a({url:n.id});let f;try{f=JSON.parse(i)}catch(r){throw console.error(r),new o(e.checkCredentialSchemaConformity,`Specified schema at url: ${n.id} could not be parsed`,t.PARSING_ERROR)}const m=r.validator(f);for(const r of c){if(!m(r))throw new o(e.checkCredentialSchemaConformity,s("errors","checkCredentialSchemaConformity"),t.MALFORMED_VALUE_ERROR)}}}export{c as default};
@@ -0,0 +1 @@
1
+ import{V as o,z as t,d as i,P as r}from"./main.js";import{b as n}from"./index-yOIIz7AL-Dgus2xdV.js";function e(e,s=""){const a=function(o){return o.id}(e);if(a!==s.split("#")[0])throw new o(t.controlVerificationMethod,`${n} - ${i.i18n.getText("errors","controlVerificationMethod")}`,r.CRYPTOGRAPHIC_SECURITY_ERROR)}export{e as default};